blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
sequencelengths
1
1
author_id
stringlengths
0
158
1d339718cc7e1c25a075c930089ef6fb6826d821
6f37f529bae8bbcc99244468477f14e9f96ff95c
/wxWidgets-2.8.12/contrib/src/fl/rowlayoutpl.cpp
4fc9699b07afd4ed8ac7f0ae47f9ec4e081f5d8d
[]
no_license
darknebuli/darknebuli-RM-graph
13326ddbc9a210605926f7ad4b70672a48b1b2f2
bf169c01f787fdd144e19fae6732a5b58fdbdafd
refs/heads/master
2020-05-16T23:40:56.853727
2012-04-30T22:14:24
2012-04-30T22:14:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
40,475
cpp
U2FsdGVkX19fTms3OENxUoetnOKy1AyJ49jWWmkNc76HrZzistQMiePY1lppDXO+ h62c4rLUDInj2NZaaQ1zvoetnOKy1AyJ49jWWmkNc758g4KpHaB8LwCS1iqVEAa/ Q/Pnymw6MzgrKAf7KAefcNY2wcOMnLZ7gyEQwKm2MauzoMBNlBeXGdMINqmBapp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G5VnIERLENQ2o iXsfydtok8f8PiloWQCP4gJA2tR7Dw0D47EXhPJTh4Q=
251c2485fa5201531bdaeb27da3d49cec2a556cc
63ae1d58e96558cab0882e1266a209fe0f894624
/dev/test/so_5_extra/env_infrastructures/asio/simple_mtsafe/stats_wt_activity/main.cpp
37132f7111a7f6c67bfaf05792417ee127e494b0
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Stiffstream/so5extra
666ebe8fe9b1498ad816d72d1180a5684f6514c8
b6b3f504b3ddf28bb223ae830f8d33f4759e982e
refs/heads/master
2023-07-06T07:08:56.315741
2023-06-30T08:08:45
2023-06-30T08:08:45
187,648,911
19
3
null
null
null
null
UTF-8
C++
false
false
1,851
cpp
#include <so_5_extra/env_infrastructures/asio/simple_mtsafe.hpp> #include <so_5/all.hpp> #include <test/3rd_party/various_helpers/time_limited_execution.hpp> class a_test_t : public so_5::agent_t { public : a_test_t( context_t ctx ) : so_5::agent_t( ctx ) {} virtual void so_define_agent() override { so_default_state().event( so_environment().stats_controller().mbox(), &a_test_t::evt_thread_activity ); } virtual void so_evt_start() override { // This big value can lead to test failure if there is an // error in implementation of autoshutdown feature. so_environment().stats_controller(). set_distribution_period( std::chrono::seconds(30) ); so_environment().stats_controller().turn_on(); } private : void evt_thread_activity( const so_5::stats::messages::work_thread_activity & evt ) { namespace stats = so_5::stats; std::cout << evt.m_prefix.c_str() << evt.m_suffix.c_str() << ": [" << evt.m_thread_id << "] = (" << evt.m_stats.m_working_stats << ", " << evt.m_stats.m_waiting_stats << ")" << std::endl; so_deregister_agent_coop_normally(); } }; void init( so_5::environment_t & env ) { env.register_agent_as_coop( env.make_agent< a_test_t >() ); } int main() { try { run_with_time_limit( []() { asio::io_context io_svc; so_5::launch( &init, [&]( so_5::environment_params_t & params ) { params.turn_work_thread_activity_tracking_on(); using namespace so_5::extra::env_infrastructures::asio::simple_mtsafe; params.infrastructure_factory( factory(io_svc) ); } ); }, 20, "simple work thread activity monitoring test" ); } catch( const std::exception & ex ) { std::cerr << "Error: " << ex.what() << std::endl; return 1; } return 0; }
17855762089217d4d2bc7bd0f857ed31e1c98d88
2dbb6208f065a6e6bc4c3d3996f3dd4253821cfb
/editor/echo/Editor/UI/ShaderEditor/Compiler/ShaderCompiler.cpp
e407ebf3705d359e0b9e2e9651d01d1efd7f07f9
[ "MIT" ]
permissive
ShalokShalom/echo
2ef7475f6f3bd65fe106a1bb730de2ade0b64bab
02e3d9d8f0066f47cbc25288666977cef3e26a2f
refs/heads/master
2022-12-13T07:14:49.064952
2020-09-17T02:08:41
2020-09-17T02:08:41
296,278,603
0
0
MIT
2020-09-17T09:21:31
2020-09-17T09:21:30
null
UTF-8
C++
false
false
12,560
cpp
#include "ShaderCompiler.h" #include <engine/core/render/base/glslcc/GLSLCrossCompiler.h> static const char* g_VsTemplate = R"(#version 450 ${VS_MACROS} // uniforms layout(binding = 0) uniform UBO { mat4 u_WorldMatrix; mat4 u_ViewProjMatrix; } vs_ubo; // inputs layout(location = 0) in vec3 a_Position; #ifdef ENABLE_VERTEX_POSITION layout(location = 0) out vec3 v_Position; #endif #ifdef ENABLE_VERTEX_NORMAL layout(location = 1) in vec3 a_Normal; layout(location = 1) out vec3 v_Normal; #ifdef HAS_TANGENTS layout(location = 2) in vec4 a_Tangent; layout(location = 2) out mat3 v_TBN; #endif #endif #ifdef ENABLE_VERTEX_COLOR layout(location = 3) in vec4 a_Color; layout(location = 3) out vec4 v_Color; #endif #ifdef ENABLE_VERTEX_UV0 layout(location = 4) in vec2 a_UV; layout(location = 4) out vec2 v_UV; #endif #ifdef ENABLE_VERTEX_BLENDING layout(location = 5) in vec4 a_Weight; layout(location = 5) out vec4 v_Weight; layout(location = 6) in vec4 a_Joint; layout(location = 6) out vec4 v_Joint; #endif void main(void) { vec4 position = vs_ubo.u_WorldMatrix * vec4(a_Position, 1.0); position = vs_ubo.u_ViewProjMatrix * position; gl_Position = position; #ifdef ENABLE_VERTEX_POSITION v_Position = position.xyz; #endif #ifdef ENABLE_VERTEX_NORMAL #ifdef HAS_TANGENTS vec3 normalW = normalize(vec3(vs_ubo.u_WorldMatrix * vec4(a_Normal.xyz, 0.0))); vec3 tangentW = normalize(vec3(vs_ubo.u_WorldMatrix * vec4(a_Tangent.xyz, 0.0))); vec3 bitangentW = cross(normalW, tangentW) * a_Tangent.w; v_Normal = normalW; v_TBN = mat3(tangentW, bitangentW, normalW); #else // HAS_TANGENTS != 1 v_Normal = normalize(vec3(vs_ubo.u_WorldMatrix * vec4(a_Normal.xyz, 0.0))); #endif #endif #ifdef ENABLE_VERTEX_COLOR v_Color = a_Color; #endif #ifdef ENABLE_VERTEX_UV0 v_UV = a_UV; #endif #ifdef ENABLE_VERTEX_BLENDING v_Weight = a_Weight; v_Joint = a_Joint; #endif } )"; static const char* g_PsTemplate = R"(#version 450 ${FS_MACROS} precision mediump float; // uniforms ${FS_UNIFORMS} // texture uniforms ${FS_TEXTURE_UNIFORMS} // inputs #ifdef ENABLE_VERTEX_POSITION layout(location = 0) in vec3 v_Position; #endif #ifdef ENABLE_VERTEX_NORMAL layout(location = 1) in vec3 v_Normal; #ifdef HAS_TANGENTS layout(location = 2) in mat3 v_TBN; #endif #endif #ifdef ENABLE_VERTEX_COLOR layout(location = 3) in vec4 v_Color; #endif #ifdef ENABLE_VERTEX_UV0 layout(location = 4) in vec2 v_UV; #endif #ifdef ENABLE_VERTEX_BLENDING layout(location = 5) in vec4 v_Weight; layout(location = 6) in vec4 v_Joint; #endif // outputs layout(location = 0) out vec4 o_FragColor; // functions #define SRGB_FAST_APPROXIMATION vec3 SRgbToLinear(vec3 srgbIn) { #ifdef SRGB_FAST_APPROXIMATION return pow(srgbIn,vec3(2.2)); #else return srgbIn; #endif } vec3 LinearToSRgb(vec3 linearIn) { #ifdef SRGB_FAST_APPROXIMATION return pow(linearIn,vec3(1.0/2.2)); #else return srgbIn; #endif } // normal map vec3 _NormalMapFun(vec3 n) { #ifdef HAS_TANGENTS return normalize(v_TBN * (2.0 * n - 1.0)); #else return normalize(2.0 * n - 1.0); #endif } // Encapsulate the various inputs used by the various functions in the shading equation // We store values in this struct to simplify the integration of alternative implementations // of the shading terms, outlined in the Readme.MD Appendix. struct PBRInfo { float NdotL; // cos angle between normal and light direction float NdotV; // cos angle between normal and view direction float NdotH; // cos angle between normal and half vector float LdotH; // cos angle between light direction and half vector float VdotH; // cos angle between view direction and half vector float perceptualRoughness; // roughness value, as authored by the model creator (input to shader) float metalness; // metallic value at the surface vec3 reflectance0; // full reflectance color (normal incidence angle) vec3 reflectance90; // reflectance color at grazing angle float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2]) vec3 diffuseColor; // color contribution from diffuse lighting vec3 specularColor; // color contribution from specular lighting }; const float M_PI = 3.141592653589793; const float c_MinRoughness = 0.04; // Basic Lambertian diffuse // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog // See also [1], Equation 1 vec3 diffuse(PBRInfo pbrInputs) { return pbrInputs.diffuseColor / M_PI; } // The following equation models the Fresnel reflectance term of the spec equation (aka F()) // Implementation of fresnel from [4], Equation 15 vec3 specularReflection(PBRInfo pbrInputs) { return pbrInputs.reflectance0 + (pbrInputs.reflectance90 - pbrInputs.reflectance0) * pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0); } // This calculates the specular geometric attenuation (aka G()), // where rougher material will reflect less light back to the viewer. // This implementation is based on [1] Equation 4, and we adopt their modifications to // alphaRoughness as input as originally proposed in [2]. float geometricOcclusion(PBRInfo pbrInputs) { float NdotL = pbrInputs.NdotL; float NdotV = pbrInputs.NdotV; float r = pbrInputs.alphaRoughness; float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); return attenuationL * attenuationV; } // The following equation(s) model the distribution of microfacet normals across the area being drawn (aka D()) // Implementation from "Average Irregularity Representation of a Roughened Surface for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz // Follows the distribution function recommended in the SIGGRAPH 2013 course notes from EPIC Games [1], Equation 3. float microfacetDistribution(PBRInfo pbrInputs) { float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness; float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0; return roughnessSq / (M_PI * f * f); } vec3 PbrLighting(vec3 pixelPosition, vec3 baseColor, vec3 normal, float metallic, float perceptualRoughness, vec3 eyePosition) { // Roughness is authored as perceptual roughness; as is convention, // convert to material roughness by squaring the perceptual roughness [2]. float alphaRoughness = perceptualRoughness * perceptualRoughness; vec3 f0 = vec3(0.04); vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0); diffuseColor *= 1.0 - metallic; vec3 specularColor = mix(f0, baseColor.rgb, metallic); // Compute reflectance. float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = specularColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; vec3 n = normal; // normal at surface point vec3 v = normalize(eyePosition - pixelPosition);// Vector from surface point to camera float NdotV = abs(dot(n, v)) + 0.001; // Multiple lights vec3 _lightDir = normalize(vec3(1.0, 1.0, 1.0)); vec3 _lightColor = SRgbToLinear(vec3(1.2, 1.2, 1.2)); // depend on light direction vec3 l = normalize(_lightDir); // Vector from surface point to light vec3 h = normalize(l+v); // Half vector between both l and v vec3 reflection = -normalize(reflect(v, n)); float NdotL = clamp(dot(n, l), 0.001, 1.0); float NdotH = clamp(dot(n, h), 0.0, 1.0); float LdotH = clamp(dot(l, h), 0.0, 1.0); float VdotH = clamp(dot(v, h), 0.0, 1.0); PBRInfo pbrInputs = PBRInfo( NdotL, NdotV, NdotH, LdotH, VdotH, perceptualRoughness, metallic, specularEnvironmentR0, specularEnvironmentR90, alphaRoughness, diffuseColor, specularColor ); // Calculate the shading terms for the microfacet specular shading model vec3 F = specularReflection(pbrInputs); float G = geometricOcclusion(pbrInputs); float D = microfacetDistribution(pbrInputs); // Calculation of analytical lighting contribution vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs); vec3 specContrib = F * G * D / (4.0 * NdotL * NdotV); vec3 color = NdotL * _lightColor * (diffuseContrib + specContrib); // environment color vec3 _environmentLightColor = SRgbToLinear(vec3(0.3, 0.3, 0.3)); color += baseColor * _environmentLightColor; return color; } void main(void) { ${FS_SHADER_CODE} #ifndef ENABLE_BASE_COLOR vec3 __BaseColor = SRgbToLinear(vec3(0.75)); #endif #ifndef ENABLE_OPACITY float __Opacity = 1.0; #endif #ifndef ENABLE_METALIC float __Metalic = 0.2; #endif #ifndef ENABLE_ROUGHNESS float __PerceptualRoughness = 0.5; #endif #ifdef ENABLE_LIGHTING_CALCULATION __BaseColor = PbrLighting(v_Position, __BaseColor, __Normal, __Metalic, __PerceptualRoughness, fs_ubo.u_CameraPosition); #endif #ifdef ENABLE_OCCLUSION __BaseColor.rgb = __BaseColor.rgb * __AmbientOcclusion; #endif #ifdef ENABLE_EMISSIVE __BaseColor.rgb += __Emissive; #endif o_FragColor = vec4(LinearToSRgb(__BaseColor.rgb), __Opacity); } )"; namespace DataFlowProgramming { ShaderCompiler::ShaderCompiler() { } ShaderCompiler::~ShaderCompiler() { } void ShaderCompiler::reset() { m_texturesCount = 0; m_macros.clear(); m_fsUniforms.clear(); m_fsUniformsCode.clear(); m_fsTextureUniforms.clear(); m_fsCode.clear(); } bool ShaderCompiler::compile() { if (!m_fsUniformsCode.empty()) { m_fsUniformsCode = "layout(binding = 0) uniform UBO \n{\n" + m_fsUniformsCode + "} fs_ubo;"; } Echo::String vsCode = g_VsTemplate; vsCode = Echo::StringUtil::Replace(vsCode, "${VS_MACROS}", m_macros.c_str()); vsCode = Echo::StringUtil::Replace(vsCode, "\t", " "); Echo::String psCode = g_PsTemplate; psCode = Echo::StringUtil::Replace(psCode, "${FS_MACROS}", m_macros.c_str()); psCode = Echo::StringUtil::Replace(psCode, "${FS_UNIFORMS}", m_fsUniformsCode.c_str()); psCode = Echo::StringUtil::Replace(psCode, "${FS_TEXTURE_UNIFORMS}", m_fsTextureUniforms.c_str()); psCode = Echo::StringUtil::Replace(psCode, "${FS_SHADER_CODE}", m_fsCode.c_str()); psCode = Echo::StringUtil::Replace(psCode, "\t", " "); // convert to GLSL Echo::GLSLCrossCompiler glslCompiler; // set input glslCompiler.setInput(vsCode.c_str(), psCode.c_str(), nullptr); m_finalVsCode = glslCompiler.getOutput(Echo::GLSLCrossCompiler::ShaderLanguage::GLSL, Echo::GLSLCrossCompiler::ShaderType::VS).c_str(); m_finalPsCode = glslCompiler.getOutput(Echo::GLSLCrossCompiler::ShaderLanguage::GLSL, Echo::GLSLCrossCompiler::ShaderType::FS).c_str(); return true; } Echo::String ShaderCompiler::getVsCode() { return m_finalVsCode; } Echo::String ShaderCompiler::getPsCode() { return m_finalPsCode; } bool ShaderCompiler::isValid() { return !m_finalVsCode.empty() && !m_finalPsCode.empty(); } void ShaderCompiler::addMacro(const Echo::String& macroName) { if (!Echo::StringUtil::Contain(m_macros, macroName)) { m_macros += Echo::StringUtil::Format("#define %s\n", macroName.c_str()); } } void ShaderCompiler::addUniform(const Echo::String& type, const Echo::String& name) { for (const Uniform& uniform : m_fsUniforms) { if (uniform.m_name == name && uniform.m_type == type) return; } m_fsUniforms.emplace_back(type, name); // refresh code m_fsUniformsCode.clear(); for (const Uniform& uniform : m_fsUniforms) { m_fsUniformsCode += Echo::StringUtil::Format("\t%s %s;\n", uniform.m_type.c_str(), uniform.m_name.c_str()); } } void ShaderCompiler::addTextureUniform(const Echo::String& uniformName) { m_texturesCount++; m_fsTextureUniforms += Echo::StringUtil::Format("layout(binding = %d) uniform sampler2D %s;\n", m_texturesCount, uniformName.c_str()); } void ShaderCompiler::addCode(const Echo::String& codeChunk) { m_fsCode += codeChunk; } }
5f4e5d502cbc94d715488ffa51e095d0e17d64c9
8e65370be946921a3c6153479704d75a8e2d0289
/app/src/main/cpp/Base/MojingString_FormatUtil.cpp
80356341c2b3a83b4964f873845d98cc951c8c63
[]
no_license
Matt-Meng/myrender
19dfabf7505adadfb8ec7d2d1ad9bf0a8085eb45
d568f6f3fcad33d18bf8babaf9f1b21dfd3908e0
refs/heads/master
2023-06-04T08:38:23.496473
2017-11-23T10:28:07
2017-11-23T10:28:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
631
cpp
#include "MojingString.h" #include "MojingLog.h" namespace Baofeng { namespace Mojing { void StringBuffer::AppendFormat(const char* format, ...) { va_list argList; va_start(argList, format); UPInt size = MJ_vscprintf(format, argList); va_end(argList); char* buffer = (char*)MJ_ALLOC(sizeof(char)* (size + 1)); va_start(argList, format); UPInt result = MJ_vsprintf(buffer, size + 1, format, argList); MJ_UNUSED1(result); va_end(argList); MJ_ASSERT_LOG(result == size, ("Error in MJ_vsprintf")); AppendString(buffer); MJ_FREE(buffer); } } } // OVR
fb9253a8c7a732f9e7b46ae5351fb3cb6104cd2d
6be2a9cb5ee17fe7b812dee59b49e4cb87b67bc1
/source/main.cpp
2c6be4dbe350333b118f5ca0ccbf4c78dc29b39c
[]
no_license
Tomek52/catch_example
e3d4ff9f435f9028adee847e714f9480859ac69d
1f56f6ee344375e8829b38abc8b8863d4fb68600
refs/heads/master
2020-03-26T02:01:34.600783
2018-08-11T18:45:57
2018-08-11T18:45:57
144,393,476
0
0
null
null
null
null
UTF-8
C++
false
false
114
cpp
#define CATCH_CONFIG_MAIN #include "catch.hpp" #include <iostream> TEST_CASE("lol", "xD") { REQUIRE(1==2); }
04550397a1f233559bdfa714cafa40d3d32d76fd
533c54472da78d183356180f128977977cbbb853
/src/beast/include/beast/http/impl/read.ipp
38c09eb5687b3df0364c9425526e11623b875041
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference", "MIT-Wu", "MIT", "ISC" ]
permissive
gcbpay/R9RIppleRoutes
7d3caec3181f3075527656d4c96e7b5948e19aec
8fdef0379a3fa05cf783b805b07ef87570db8886
refs/heads/master
2021-01-19T06:08:23.662331
2018-03-23T03:17:31
2018-03-23T03:17:31
72,002,525
7
3
null
null
null
null
UTF-8
C++
false
false
12,829
ipp
// // Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BEAST_HTTP_IMPL_READ_IPP_HPP #define BEAST_HTTP_IMPL_READ_IPP_HPP #include <beast/http/concepts.hpp> #include <beast/http/parser_v1.hpp> #include <beast/core/bind_handler.hpp> #include <beast/core/handler_alloc.hpp> #include <beast/core/stream_concepts.hpp> #include <cassert> namespace beast { namespace http { namespace detail { template<class Stream, class DynamicBuffer, class Parser, class Handler> class parse_op { using alloc_type = handler_alloc<char, Handler>; struct data { Stream& s; DynamicBuffer& db; Parser& p; Handler h; bool started = false; bool cont; int state = 0; template<class DeducedHandler> data(DeducedHandler&& h_, Stream& s_, DynamicBuffer& sb_, Parser& p_) : s(s_) , db(sb_) , p(p_) , h(std::forward<DeducedHandler>(h_)) , cont(boost_asio_handler_cont_helpers:: is_continuation(h)) { } }; std::shared_ptr<data> d_; public: parse_op(parse_op&&) = default; parse_op(parse_op const&) = default; template<class DeducedHandler, class... Args> parse_op(DeducedHandler&& h, Stream& s, Args&&... args) : d_(std::allocate_shared<data>(alloc_type{h}, std::forward<DeducedHandler>(h), s, std::forward<Args>(args)...)) { (*this)(error_code{}, 0, false); } void operator()(error_code ec, std::size_t bytes_transferred, bool again = true); friend void* asio_handler_allocate( std::size_t size, parse_op* op) { return boost_asio_handler_alloc_helpers:: allocate(size, op->d_->h); } friend void asio_handler_deallocate( void* p, std::size_t size, parse_op* op) { return boost_asio_handler_alloc_helpers:: deallocate(p, size, op->d_->h); } friend bool asio_handler_is_continuation(parse_op* op) { return op->d_->cont; } template <class Function> friend void asio_handler_invoke(Function&& f, parse_op* op) { return boost_asio_handler_invoke_helpers:: invoke(f, op->d_->h); } }; template<class Stream, class DynamicBuffer, class Parser, class Handler> void parse_op<Stream, DynamicBuffer, Parser, Handler>:: operator()(error_code ec, std::size_t bytes_transferred, bool again) { auto& d = *d_; d.cont = d.cont || again; while(d.state != 99) { switch(d.state) { case 0: { auto const used = d.p.write(d.db.data(), ec); if(ec) { // call handler d.state = 99; d.s.get_io_service().post( bind_handler(std::move(*this), ec, 0)); return; } if(used > 0) d.started = true; d.db.consume(used); if(d.p.complete()) { // call handler d.state = 99; d.s.get_io_service().post( bind_handler(std::move(*this), ec, 0)); return; } d.state = 1; break; } case 1: // read d.state = 2; d.s.async_read_some(d.db.prepare( read_size_helper(d.db, 65536)), std::move(*this)); return; // got data case 2: { if(ec == boost::asio::error::eof) { if(! d.started) { // call handler d.state = 99; break; } // Caller will see eof on next read. ec = {}; d.p.write_eof(ec); assert(ec || d.p.complete()); // call handler d.state = 99; break; } if(ec) { // call handler d.state = 99; break; } d.db.commit(bytes_transferred); auto const used = d.p.write(d.db.data(), ec); if(ec) { // call handler d.state = 99; break; } if(used > 0) d.started = true; d.db.consume(used); if(d.p.complete()) { // call handler d.state = 99; break; } d.state = 1; break; } } } d.h(ec); } //------------------------------------------------------------------------------ template<class Stream, class DynamicBuffer, bool isRequest, class Body, class Headers, class Handler> class read_op { using alloc_type = handler_alloc<char, Handler>; using parser_type = parser_v1<isRequest, Body, Headers>; using message_type = message_v1<isRequest, Body, Headers>; struct data { Stream& s; DynamicBuffer& db; message_type& m; parser_type p; Handler h; bool started = false; bool cont; int state = 0; template<class DeducedHandler> data(DeducedHandler&& h_, Stream& s_, DynamicBuffer& sb_, message_type& m_) : s(s_) , db(sb_) , m(m_) , h(std::forward<DeducedHandler>(h_)) , cont(boost_asio_handler_cont_helpers:: is_continuation(h)) { } }; std::shared_ptr<data> d_; public: read_op(read_op&&) = default; read_op(read_op const&) = default; template<class DeducedHandler, class... Args> read_op(DeducedHandler&& h, Stream& s, Args&&... args) : d_(std::allocate_shared<data>(alloc_type{h}, std::forward<DeducedHandler>(h), s, std::forward<Args>(args)...)) { (*this)(error_code{}, false); } void operator()(error_code ec, bool again = true); friend void* asio_handler_allocate( std::size_t size, read_op* op) { return boost_asio_handler_alloc_helpers:: allocate(size, op->d_->h); } friend void asio_handler_deallocate( void* p, std::size_t size, read_op* op) { return boost_asio_handler_alloc_helpers:: deallocate(p, size, op->d_->h); } friend bool asio_handler_is_continuation(read_op* op) { return op->d_->cont; } template <class Function> friend void asio_handler_invoke(Function&& f, read_op* op) { return boost_asio_handler_invoke_helpers:: invoke(f, op->d_->h); } }; template<class Stream, class DynamicBuffer, bool isRequest, class Body, class Headers, class Handler> void read_op<Stream, DynamicBuffer, isRequest, Body, Headers, Handler>:: operator()(error_code ec, bool again) { auto& d = *d_; d.cont = d.cont || again; while(! ec && d.state != 99) { switch(d.state) { case 0: d.state = 1; async_parse(d.s, d.db, d.p, std::move(*this)); return; case 1: // call handler d.state = 99; d.m = d.p.release(); break; } } d.h(ec); } } // detail //------------------------------------------------------------------------------ template<class SyncReadStream, class DynamicBuffer, class Parser> void parse(SyncReadStream& stream, DynamicBuffer& dynabuf, Parser& parser) { static_assert(is_SyncReadStream<SyncReadStream>::value, "SyncReadStream requirements not met"); static_assert(is_DynamicBuffer<DynamicBuffer>::value, "DynamicBuffer requirements not met"); static_assert(is_Parser<Parser>::value, "Parser requirements not met"); error_code ec; parse(stream, dynabuf, parser, ec); if(ec) throw boost::system::system_error{ec}; } template<class SyncReadStream, class DynamicBuffer, class Parser> void parse(SyncReadStream& stream, DynamicBuffer& dynabuf, Parser& parser, error_code& ec) { static_assert(is_SyncReadStream<SyncReadStream>::value, "SyncReadStream requirements not met"); static_assert(is_DynamicBuffer<DynamicBuffer>::value, "DynamicBuffer requirements not met"); static_assert(is_Parser<Parser>::value, "Parser requirements not met"); bool started = false; for(;;) { auto used = parser.write(dynabuf.data(), ec); if(ec) return; dynabuf.consume(used); if(used > 0) started = true; if(parser.complete()) break; dynabuf.commit(stream.read_some( dynabuf.prepare(read_size_helper( dynabuf, 65536)), ec)); if(ec && ec != boost::asio::error::eof) return; if(ec == boost::asio::error::eof) { if(! started) return; // Caller will see eof on next read. ec = {}; parser.write_eof(ec); if(ec) return; assert(parser.complete()); break; } } } template<class AsyncReadStream, class DynamicBuffer, class Parser, class ReadHandler> typename async_completion< ReadHandler, void(error_code)>::result_type async_parse(AsyncReadStream& stream, DynamicBuffer& dynabuf, Parser& parser, ReadHandler&& handler) { static_assert(is_AsyncReadStream<AsyncReadStream>::value, "AsyncReadStream requirements not met"); static_assert(is_DynamicBuffer<DynamicBuffer>::value, "DynamicBuffer requirements not met"); static_assert(is_Parser<Parser>::value, "Parser requirements not met"); beast::async_completion<ReadHandler, void(error_code)> completion(handler); detail::parse_op<AsyncReadStream, DynamicBuffer, Parser, decltype(completion.handler)>{ completion.handler, stream, dynabuf, parser}; return completion.result.get(); } template<class SyncReadStream, class DynamicBuffer, bool isRequest, class Body, class Headers> void read(SyncReadStream& stream, DynamicBuffer& dynabuf, message_v1<isRequest, Body, Headers>& msg) { static_assert(is_SyncReadStream<SyncReadStream>::value, "SyncReadStream requirements not met"); static_assert(is_DynamicBuffer<DynamicBuffer>::value, "DynamicBuffer requirements not met"); static_assert(is_ReadableBody<Body>::value, "ReadableBody requirements not met"); error_code ec; read(stream, dynabuf, msg, ec); if(ec) throw system_error{ec}; } template<class SyncReadStream, class DynamicBuffer, bool isRequest, class Body, class Headers> void read(SyncReadStream& stream, DynamicBuffer& dynabuf, message_v1<isRequest, Body, Headers>& m, error_code& ec) { static_assert(is_SyncReadStream<SyncReadStream>::value, "SyncReadStream requirements not met"); static_assert(is_DynamicBuffer<DynamicBuffer>::value, "DynamicBuffer requirements not met"); static_assert(is_ReadableBody<Body>::value, "ReadableBody requirements not met"); parser_v1<isRequest, Body, Headers> p; parse(stream, dynabuf, p, ec); if(ec) return; assert(p.complete()); m = p.release(); } template<class AsyncReadStream, class DynamicBuffer, bool isRequest, class Body, class Headers, class ReadHandler> typename async_completion< ReadHandler, void(error_code)>::result_type async_read(AsyncReadStream& stream, DynamicBuffer& dynabuf, message_v1<isRequest, Body, Headers>& m, ReadHandler&& handler) { static_assert(is_AsyncReadStream<AsyncReadStream>::value, "AsyncReadStream requirements not met"); static_assert(is_DynamicBuffer<DynamicBuffer>::value, "DynamicBuffer requirements not met"); static_assert(is_ReadableBody<Body>::value, "ReadableBody requirements not met"); beast::async_completion<ReadHandler, void(error_code)> completion(handler); detail::read_op<AsyncReadStream, DynamicBuffer, isRequest, Body, Headers, decltype( completion.handler)>{completion.handler, stream, dynabuf, m}; return completion.result.get(); } } // http } // beast #endif
e91f08c17e565afc3755a768e992683d133a22c1
f826d0b777b369bb0bec14277da882d4538f0ecd
/src/filters/coloradjustment/ConvertToGrayscale.h
bf1a94b6f46631390c30c0207211799cb65969e5
[]
no_license
CelesterSpencer/SImP
9e3412703535be8114c739f51cd09a2a6038c052
ecba9ccd37f728a8deab1255f7677e20351f1b9e
refs/heads/master
2021-01-23T02:35:09.628422
2017-06-18T23:29:24
2017-06-18T23:29:24
86,008,132
0
0
null
null
null
null
UTF-8
C++
false
false
373
h
#ifndef SRCCMAKE_CONVERTTOGRAYSCALE_H #define SRCCMAKE_CONVERTTOGRAYSCALE_H #include <vector> #include <string> #include "core/scene/ImageFilter.h" class ConvertToGrayscale : public ImageFilter { public: ConvertToGrayscale(); void process(); private: std::vector<std::string> m_options; int m_selectedOption; }; #endif //SRCCMAKE_CONVERTTOGRAYSCALE_H
a99b80eb37f1123f541ff4daead7e86868939858
3bad1ce8cd4aafd2870a3b570d297de22cff6bda
/engine/src/rgbplain.cpp
18fbfe48d54f39e91521cc530ec1070d9dd8608f
[ "Apache-2.0" ]
permissive
hveld/qlcplus
64ee591e641a3bfa3358f942ad2875c814841f16
1dd61a5a3a2c93d7fe88cd2a90574c4849b64829
refs/heads/master
2021-01-16T17:52:15.266518
2015-06-17T19:10:50
2015-06-17T19:10:50
22,361,368
0
0
null
null
null
null
UTF-8
C++
false
false
2,697
cpp
/* Q Light Controller Plus rgbplain.cpp Copyright (c) Massimo Callegari Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <QDomDocument> #include <QDomElement> #include <QDebug> #include "rgbplain.h" #include "audiocapture.h" #include "doc.h" RGBPlain::RGBPlain(const Doc * doc) : RGBAlgorithm(doc) { } RGBPlain::RGBPlain(const RGBPlain& a, QObject *parent) : QObject(parent) , RGBAlgorithm(a.doc()) { } RGBPlain::~RGBPlain() { } RGBAlgorithm* RGBPlain::clone() const { RGBPlain* plain = new RGBPlain(*this); return static_cast<RGBAlgorithm*> (plain); } /**************************************************************************** * RGBAlgorithm ****************************************************************************/ int RGBPlain::rgbMapStepCount(const QSize& size) { Q_UNUSED(size); return 1; } RGBMap RGBPlain::rgbMap(const QSize& size, uint rgb, int step) { Q_UNUSED(step) RGBMap map(size.height()); for (int y = 0; y < size.height(); y++) { map[y].resize(size.width()); map[y].fill(rgb); } return map; } QString RGBPlain::name() const { return QString("Plain Color"); } QString RGBPlain::author() const { return QString("Massimo Callegari"); } int RGBPlain::apiVersion() const { return 1; } void RGBPlain::setColors(QColor start, QColor end) { RGBAlgorithm::setColors(start, end); } RGBAlgorithm::Type RGBPlain::type() const { return RGBAlgorithm::Plain; } bool RGBPlain::loadXML(const QDomElement& root) { if (root.tagName() != KXMLQLCRGBAlgorithm) { qWarning() << Q_FUNC_INFO << "RGB Algorithm node not found"; return false; } if (root.attribute(KXMLQLCRGBAlgorithmType) != KXMLQLCRGBPlain) { qWarning() << Q_FUNC_INFO << "RGB Algorithm is not Plain"; return false; } return true; } bool RGBPlain::saveXML(QDomDocument* doc, QDomElement* mtx_root) const { Q_ASSERT(doc != NULL); Q_ASSERT(mtx_root != NULL); QDomElement root = doc->createElement(KXMLQLCRGBAlgorithm); root.setAttribute(KXMLQLCRGBAlgorithmType, KXMLQLCRGBPlain); mtx_root->appendChild(root); return true; }
e3168674a25232d034d4a5dede4d3d35182ea778
5bb55ef3638f8f5609e07f689c1087d8c28e4f00
/2740陶陶摘苹果.cpp
a9255ea4e8f9f2d6d77a52e8dd82bf35b3451715
[]
no_license
xihaban/C-
6bb11e1ac1d2965cf1c093cd5a8d4d195ea2d108
76b3c824e9ec288e6ce321b30e4b70f178f6c4b5
refs/heads/master
2020-03-28T14:27:13.119766
2018-09-12T13:49:03
2018-09-12T13:49:03
148,487,862
0
0
null
null
null
null
UTF-8
C++
false
false
185
cpp
#include<stdio.h> main() { int a[10],i,n,count=0; for(i=0;i<10;i++) scanf("%d",&a[i]); scanf("%d",&n); for(i=0;i<10;i++) { if(n+30>=a[i]) count++; } printf("%d\n",count); }
94122e9761fc2566d7e937ce4ff7ebc0688f56d0
f194974b8431ba62b232e362c8b1b555d9a07ac3
/shared/renderer/oxide_user_script_scheduler.cc
b1ce68b05a92e244567c1b5041edef27e3bde869
[]
no_license
rubencarneiro/oxide
9a0e8adc16c8f05d5a7a014ee566a8cc7b0f8fe2
c05c51d79a4d4ab18740e6542ddff02becd9b49c
refs/heads/master
2021-08-28T05:22:28.877979
2017-04-19T13:43:03
2017-04-19T13:43:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,465
cc
// vim:expandtab:shiftwidth=2:tabstop=2: // Copyright (C) 2013 Canonical Ltd. // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "oxide_user_script_scheduler.h" #include "base/bind.h" #include "base/threading/thread_task_runner_handle.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "shared/grit/oxide_resources.h" #include "shared/common/oxide_user_script.h" #include "oxide_user_script_slave.h" namespace oxide { void UserScriptScheduler::DoIdleInject() { idle_posted_ = false; for (std::set<blink::WebLocalFrame *>::const_iterator it = pending_idle_frames_.begin(); it != pending_idle_frames_.end(); ++it) { blink::WebLocalFrame* frame = *it; UserScriptSlave::GetInstance()->InjectScripts(frame, UserScript::DOCUMENT_IDLE); } pending_idle_frames_.clear(); } UserScriptScheduler::UserScriptScheduler(content::RenderView* render_view) : content::RenderViewObserver(render_view), idle_posted_(false), weak_factory_(this) {} void UserScriptScheduler::OnDestruct() { delete this; } void UserScriptScheduler::DidFinishLoad(blink::WebLocalFrame* frame) { pending_idle_frames_.insert(frame); if (idle_posted_) { return; } idle_posted_ = true; base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&UserScriptScheduler::DoIdleInject, weak_factory_.GetWeakPtr())); } void UserScriptScheduler::FrameDetached(blink::WebFrame* frame) { if (!idle_posted_) { return; } blink::WebLocalFrame* local_frame = frame->toWebLocalFrame(); if (local_frame) { pending_idle_frames_.erase(local_frame); } } } // namespace oxide
91dcd4606c3a6d359b24ae927a558bad692fab9b
a9a7d3798efa6ad5fce8ae776df000caad165218
/PowerSupplyHardware.cpp
f440f02dbd0552cf028a4e90ea4c747777e38f62
[]
no_license
cbott/PowerSupply
517eb69f9b345d14b4c6c3f2ad3bbac3d73b915d
e22344c1034a8863ba936877f53937cb4bd32210
refs/heads/master
2021-05-01T14:28:03.968448
2018-02-11T21:03:33
2018-02-11T21:03:33
121,086,848
0
1
null
null
null
null
UTF-8
C++
false
false
4,103
cpp
#include "PowerSupplyHardware.h" PowerSupplyHardware::PowerSupplyHardware() : control_knob(ENCODER_A_PIN, ENCODER_B_PIN), voltage_output_1s(DIGIT1_DATA_PIN, DIGIT1_CLOCK_PIN, DIGIT1_LATCH_PIN), voltage_output_10s(DIGIT2_DATA_PIN, DIGIT2_CLOCK_PIN, DIGIT2_LATCH_PIN), voltage_adjuster(DIGIPOT_CS_PIN, POT_RESISTANCE, POT_TAPS) { pinMode(RED_LED_PIN, OUTPUT); pinMode(GREEN_LED_PIN, OUTPUT); pinMode(BLUE_LED_PIN, OUTPUT); pinMode(BUTTON_PIN, INPUT); } static PowerSupplyHardware &PowerSupplyHardware::GetInstance(){ static PowerSupplyHardware instance; return instance; } bool PowerSupplyHardware::button_state(){ return digitalRead(BUTTON_PIN); } void PowerSupplyHardware::set_knob_color(bool r, bool g, bool b){ digitalWrite(RED_LED_PIN, !r); digitalWrite(GREEN_LED_PIN, !g); digitalWrite(BLUE_LED_PIN, !b); } long PowerSupplyHardware::get_constrained_knob_pos(){ // Prevent knob from setting to value that cannot be set on the digipot // TODO: possibly remove long knob_pos = control_knob.read(); long adjusted_knob_pos = constrain(knob_pos, 0, POT_TAPS * ENC_PULSES_PER_TAP); if(knob_pos != adjusted_knob_pos){ control_knob.write(adjusted_knob_pos); } return adjusted_knob_pos; } float PowerSupplyHardware::get_voltage(){ // Return the current voltage of the power supply output // Measured from the voltage divider /* VCC---/\/\/\/---.---/\/\/\/---GND R1 | R2 Analog In */ long R1 = 65450; long R2 = 21800; int reading = analogRead(VOLTAGE_MEASUREMENT_PIN); float measured_voltage = reading * 4.968 / 1023; // On a 5v scale float actual_voltage = measured_voltage * (R1 + R2) / R2; // Convert to 20v scale return actual_voltage; } void PowerSupplyHardware::set_voltage_raw(int taps){ // TODO: replace with actual set voltage voltage_adjuster.set_raw(taps); } float PowerSupplyHardware::get_current(){ int reading = analogRead(CURRENT_MEASUREMENT_PIN); // Sensor spec: 0.185v/A --> 5.4 A/v // 5.4 A/v * 5v / 1023 analog = 0.0264 A / analog // 0v --> -13.51 A const float SLOPE = 5.4;//A/v const float SYS_VOLTAGE = 5;//v const float A_TO_D_RES = 1023; const float CURRENT_SENSE_ZERO = 2.482;//v float measured_voltage = SYS_VOLTAGE / A_TO_D_RES * reading; return SLOPE * (measured_voltage - CURRENT_SENSE_ZERO); } void PowerSupplyHardware::display_two_digits(float number){ number = round(abs(number)*10) / 10.0; if(number < 10){ disp_digit(DIGIT10s, (int)number, true); disp_digit(DIGIT1s, (int)(number * 10) % 10, false); } else { number = round(number); disp_digit(DIGIT10s, ((int)number / 10) % 10, false); disp_digit(DIGIT1s, ((int)number) % 10, false); } } const int PowerSupplyHardware::DIGIT_1_CODES[10] = { 0b11011110, 0b00011000, 0b11001101, 0b10011101, 0b00011011, 0b10010111, 0b11010111, 0b00011100, 0b11011111, 0b10011111 }; const int PowerSupplyHardware::DIGIT_10_CODES[10] = { 0b11011110, 0b01000010, 0b11101100, 0b11100110, 0b01110010, 0b10110110, 0b10111110, 0b11000010, 0b11111110, 0b11110110 }; void PowerSupplyHardware::disp_digit(DIGIT pos, int number, bool period){ int *codes; int decimal_bit; // Bit to set the period/decimal point on the digit Shift7Segment *shift_reg; if(pos == DIGIT1s){ codes = DIGIT_1_CODES; decimal_bit = 5; shift_reg = &voltage_output_1s; } else if(pos == DIGIT10s){ codes = DIGIT_10_CODES; decimal_bit = 0; shift_reg = &voltage_output_10s; } else { return; // Invalid digit selection } byte code = 0; if(number >= 0 && number < 10){ code = codes[number]; } if(period){ bitWrite(code, decimal_bit, 1); // set period bit } shift_reg->disp_byte(code); } void PowerSupplyHardware::load_state(int eeprom_address){ // recall last saved control value long saved_knob_pos; EEPROM.get(eeprom_address, saved_knob_pos); control_knob.write(saved_knob_pos); } void PowerSupplyHardware::save_state(int eeprom_address){ EEPROM.put(eeprom_address, get_constrained_knob_pos()); }
6cab4248c399d82c67e840473c1979d481e15f91
85503c319ef1062989371daedad40bfc728cd166
/HulkAction/Classes/HelloWorldScene.cpp
e44880642c7055631f8e68c2530b7a31eebc8d08
[]
no_license
kimxyz/cocos2dx-dev
a6a6bf777da3904c660ea6f1a78143cc8a17ae6f
89cf6f401089357433cb22e1a3b962cb8008c722
refs/heads/master
2023-05-30T12:05:22.350490
2020-12-28T16:08:58
2020-12-28T16:08:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,237
cpp
#include "HelloWorldScene.h" using namespace cocos2d; using namespace CocosDenshion ; CCScene* HelloWorld::scene() { CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object HelloWorld *layer = HelloWorld::node(); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; } // on "init" you need to initialize your instance bool HelloWorld::init() { bool bRet = false; do { ////////////////////////////////////////////////////////////////////////// // super init first ////////////////////////////////////////////////////////////////////////// CC_BREAK_IF(! CCLayer::init()); ////////////////////////////////////////////////////////////////////////// // add your codes below... ////////////////////////////////////////////////////////////////////////// // 1. Add a menu item with "X" image, which is clicked to quit the program. // Create a "close" menu item with close icon, it's an auto release object. CCMenuItemImage *pCloseItem = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, menu_selector(HelloWorld::menuCloseCallback)); CC_BREAK_IF(! pCloseItem); // Place the menu item bottom-right conner. pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); // Create a menu with the "close" menu item, it's an auto release object. CCMenu* pMenu = CCMenu::createWithItem(pCloseItem); pMenu->setPosition(CCPointZero); CC_BREAK_IF(! pMenu); // Add the menu to HelloWorld layer as a child layer. this->addChild(pMenu, 1); // 2. Add a label shows "Hello World". // Create a label and initialize with string "Hello World". CCLabelTTF* pLabel = CCLabelTTF::create("THE HULK", "Thonburi", 34); CC_BREAK_IF(! pLabel); // Get window size and place the label upper. CCSize size = CCDirector::sharedDirector()->getWinSize(); pLabel->setPosition(ccp(size.width / 2, size.height - 20)); // Add the label to HelloWorld layer as a child layer. this->addChild(pLabel, 1); // add "HelloWorld" splash screen" CCSprite* pSprite = CCSprite::create("streetbackground.jpg"); // position the sprite on the center of the screen pSprite->setPosition( ccp(size.width/2, size.height/2) ); // add the sprite as a child to this layer this->addChild(pSprite, 0); /////////////////////////////////////////////////////////////////////////////// //Generate Menu bar for hulk actions generateHulkMenu(); /////////////////////////////////////////////////////////////////////////////// CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("hulkmoves.plist"); CCSpriteBatchNode * sceneSpriteBatchNode = CCSpriteBatchNode::create("hulkmoves.png"); this->addChild(sceneSpriteBatchNode, 0); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //hulk= CCSprite::spriteWithFile("slice_0_1.png.png"); hulk=CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("slice_0_1.png")); hulk->setScale(0.8); hulk->setPosition(ccp(winSize.width/2,winSize.height*0.4)); addChild(hulk, 1); bRet = true; } while (0); return bRet; } void HelloWorld::GenerateHulkAnimation(char *Name,int Max,cocos2d::CCSprite* sp) { char *frameName = new char[1024]; cocos2d::CCAnimate *_curAnimate; CCAnimation* animaiton = CCAnimation::create(); for(int i = 1; i <= Max; ++i){ sprintf(frameName, "%s%d.png", Name, i); animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName)); } for(int i = 1; i <= Max; ++i){ animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName)); } animaiton->setDelayPerUnit(0.1); _curAnimate = CCAnimate::create(animaiton); //CCActionInterval* action = CCAnimate::actionWithDuration(1); //CCRepeatForever* repeatAction = CCRepeatForever::actionWithAction(action); //sp->runAction(repeatAction); sp->runAction(_curAnimate); } void HelloWorld::generateHulkMenu() { CCMenuItemImage *punchItem = CCMenuItemImage::create( "punchbutton.png", "punchbutton.png", this, menu_selector(HelloWorld::runPunchAnimation)); punchItem->setPosition((ccp(CCDirector::sharedDirector()->getWinSize().width /2 -200,CCDirector::sharedDirector()->getWinSize().height -30))); CCMenu* pMenu = CCMenu::createWithItem(punchItem); pMenu->setPosition(CCPointZero); this->addChild(pMenu, 1); ///////////////////////////////////////////////////////////////////////////////// CCMenuItemImage *namasteItem = CCMenuItemImage::create( "namastebutton.png", "namastebutton.png", this, menu_selector(HelloWorld::runNamasteAnimation)); namasteItem->setPosition((ccp(CCDirector::sharedDirector()->getWinSize().width /2 -200,CCDirector::sharedDirector()->getWinSize().height -80))); CCMenu* pMenu2 = CCMenu::createWithItem(namasteItem); pMenu2->setPosition(CCPointZero); this->addChild(pMenu2, 1); ///////////////////////////////////////////////////////////////////////////////// CCMenuItemImage *fistItem = CCMenuItemImage::create( "fistbutton.png", "fistbutton.png", this, menu_selector(HelloWorld::runFistAnimation)); fistItem->setPosition((ccp(CCDirector::sharedDirector()->getWinSize().width /2 -200,CCDirector::sharedDirector()->getWinSize().height -130))); CCMenu* pMenu3 = CCMenu::createWithItem(fistItem); pMenu3->setPosition(CCPointZero); this->addChild(pMenu3, 1); ///////////////////////////////////////////////////////////////////////////////// CCMenuItemImage *throwItem = CCMenuItemImage::create( "throwbutton.png", "throwbutton.png", this, menu_selector(HelloWorld::runThrowAnimation)); throwItem->setPosition((ccp(CCDirector::sharedDirector()->getWinSize().width /2 -200,CCDirector::sharedDirector()->getWinSize().height -180))); CCMenu* pMenu4 = CCMenu::createWithItem(throwItem); pMenu4->setPosition(CCPointZero); this->addChild(pMenu4, 1); } void HelloWorld::runPunchAnimation(CCObject* pSender) { SimpleAudioEngine::sharedEngine()->playEffect("angrypunch.mp3"); GenerateHulkAnimation("slice_0_",7,hulk); } void HelloWorld::runFistAnimation(CCObject* pSender) { // GenerateHulkAnimation("fist_thump_1_",6,hulk); SimpleAudioEngine::sharedEngine()->playEffect("angrypunch.mp3"); cocos2d::CCAnimate *_curAnimate; CCAnimation* animaiton = CCAnimation::create(); for(int i = 1; i <= 6; ++i){ char *frameName = new char[1024]; sprintf(frameName, "%s%d.png", "fist_thump_1_", i); animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName)); } for(int i = 1; i <= 6; ++i){ animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("fist_thump_1_6.png")); } animaiton->setDelayPerUnit(0.1); _curAnimate = CCAnimate::create(animaiton); // CCActionInterval* action = CCAnimate::actionWithDuration(1); //CCRepeatForever* repeatAction = CCRepeatForever::actionWithAction(action); //sp->runAction(repeatAction); hulk->runAction(_curAnimate); } void HelloWorld::runThrowAnimation(CCObject* pSender) { SimpleAudioEngine::sharedEngine()->playEffect("angrypunch.mp3"); GenerateHulkAnimation("stone_throw_3_",8,hulk); } void HelloWorld::runNamasteAnimation(CCObject* pSender) { SimpleAudioEngine::sharedEngine()->playEffect("angrypunch.mp3"); //GenerateHulkAnimation("namaste_1_",4,hulk); cocos2d::CCAnimate *_curAnimate; CCAnimation* animaiton = CCAnimation::create(); for(int i = 1; i <= 4; ++i){ char *frameName = new char[1024]; sprintf(frameName, "%s%d.png", "namaste_1_", i); animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName)); } for(int i = 1; i <= 8; ++i){ animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("namaste_1_4.png")); } animaiton->setDelayPerUnit(0.1); _curAnimate = CCAnimate::create(animaiton); // CCActionInterval* action = CCAnimate::actionWithDuration(1); //CCRepeatForever* repeatAction = CCRepeatForever::actionWithAction(action); //sp->runAction(repeatAction); hulk->runAction(_curAnimate); } void HelloWorld::menuCloseCallback(CCObject* pSender) { // "close" menu item clicked CCDirector::sharedDirector()->end(); }
[ "pdpdds@9eae94da-17f8-0410-9712-9035c0ba4dfd" ]
pdpdds@9eae94da-17f8-0410-9712-9035c0ba4dfd
54ea5eaf396d4b5bdbea89ee1ac9494f7fa4a212
2da28852b8e688aefb7a5c34090ba4f6d4d918d6
/Brandisher/source/gui/programming_interface.cpp
22e22cac58b178d186a241d5a009f4f10db22d77
[ "Apache-2.0" ]
permissive
winksaville/lava
9e09b09f30ca7b26e17043506db1b5960a341a5d
13fbb442407e24360664263f56af41b77ca6bdf0
refs/heads/master
2020-03-21T11:22:14.483669
2018-06-15T14:23:38
2018-06-15T14:23:38
138,503,348
0
1
Apache-2.0
2018-06-24T17:48:51
2018-06-24T17:48:51
null
UTF-8
C++
false
false
40,399
cpp
/* * Nana GUI Programming Interface Implementation * Nana C++ Library(http://www.nanapro.org) * Copyright(C) 2003-2017 Jinhao([email protected]) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * @file: nana/gui/programming_interface.cpp * @author: Jinhao */ #include <nana/gui/programming_interface.hpp> #include <nana/gui/detail/bedrock.hpp> #include <nana/gui/detail/basic_window.hpp> #include <nana/gui/detail/window_manager.hpp> #include <nana/system/platform.hpp> #include <nana/gui/detail/native_window_interface.hpp> #include <nana/gui/widgets/widget.hpp> #include <nana/gui/detail/events_operation.hpp> namespace nana { //restrict // this name is only visible for this compiling-unit namespace restrict { namespace { auto& bedrock = detail::bedrock::instance(); inline detail::window_manager& wd_manager() { return bedrock.wd_manager(); } } } namespace effects { class effects_accessor { public: static bground_interface * create(const bground_factory_interface& factory) { return factory.create(); } }; } namespace API { using basic_window = ::nana::detail::basic_window; using interface_type = ::nana::detail::native_interface; namespace detail { ::nana::widget_geometrics* make_scheme(::nana::detail::scheme_factory_interface&& factory) { return restrict::bedrock.scheme().create(static_cast<::nana::detail::scheme_factory_interface&&>(factory)); } bool emit_event(event_code evt_code, window wd, const ::nana::event_arg& arg) { return restrict::bedrock.emit(evt_code, reinterpret_cast<::nana::detail::basic_window*>(wd), arg, true, restrict::bedrock.get_thread_context(), false); } bool emit_internal_event(event_code evt_code, window wd, const ::nana::event_arg& arg) { return restrict::bedrock.emit(evt_code, reinterpret_cast<::nana::detail::basic_window*>(wd), arg, true, restrict::bedrock.get_thread_context(), true); } void enum_widgets_function_base::enum_widgets(window wd, bool recursive) { using basic_window = ::nana::detail::basic_window; internal_scope_guard lock; auto children = restrict::wd_manager().get_children(reinterpret_cast<basic_window*>(wd)); for (auto child : children) { auto widget_ptr = API::get_widget(reinterpret_cast<window>(child)); if (widget_ptr) { _m_enum_fn(widget_ptr); if (recursive) enum_widgets(reinterpret_cast<window>(child), recursive); } } } general_events* get_general_events(window wd) { if (!restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) return nullptr; return reinterpret_cast<basic_window*>(wd)->annex.events_ptr.get(); } }//end namespace detail void effects_edge_nimbus(window wd, effects::edge_nimbus en) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard isg; if(restrict::wd_manager().available(iwd)) { auto & cont = iwd->root_widget->other.attribute.root->effects_edge_nimbus; if(effects::edge_nimbus::none != en) { if (iwd->effect.edge_nimbus == effects::edge_nimbus::none) { cont.emplace_back(basic_window::edge_nimbus_action{ iwd, false}); } iwd->effect.edge_nimbus = static_cast<effects::edge_nimbus>(static_cast<unsigned>(en) | static_cast<unsigned>(iwd->effect.edge_nimbus)); } else { if(effects::edge_nimbus::none != iwd->effect.edge_nimbus) { for(auto i = cont.begin(); i != cont.end(); ++i) if(i->window == iwd) { cont.erase(i); break; } } iwd->effect.edge_nimbus = effects::edge_nimbus::none; } } } effects::edge_nimbus effects_edge_nimbus(window wd) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard isg; return (restrict::wd_manager().available(iwd) ? iwd->effect.edge_nimbus : effects::edge_nimbus::none); } void effects_bground(window wd, const effects::bground_factory_interface& factory, double fade_rate) { if (fade_rate < 0.0 || fade_rate > 1.0) throw std::invalid_argument("effects_bground: value range of fade_rate must be [0, 1]."); auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard isg; if(restrict::wd_manager().available(iwd)) { auto new_effect_ptr = effects::effects_accessor::create(factory); if(nullptr == new_effect_ptr) return; delete iwd->effect.bground; iwd->effect.bground = new_effect_ptr; iwd->effect.bground_fade_rate = fade_rate; restrict::wd_manager().enable_effects_bground(iwd, true); if (fade_rate < 0.01) iwd->flags.make_bground_declared = true; API::refresh_window(wd); } } void effects_bground(std::initializer_list<window> wdgs, const effects::bground_factory_interface& factory, double fade_rate) { for (auto wd : wdgs) effects_bground(wd, factory, fade_rate); } bground_mode effects_bground_mode(window wd) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard isg; if(restrict::wd_manager().available(iwd) && iwd->effect.bground) return (iwd->effect.bground_fade_rate <= 0.009 ? bground_mode::basic : bground_mode::blend); return bground_mode::none; } void effects_bground_remove(window wd) { const auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard isg; if(restrict::wd_manager().available(iwd)) { if(restrict::wd_manager().enable_effects_bground(iwd, false)) API::refresh_window(wd); } } namespace dev { void affinity_execute(window window_handle, const std::function<void()>& fn) { interface_type::affinity_execute(root(window_handle), fn); } bool set_events(window wd, const std::shared_ptr<general_events>& gep) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) iwd->set_events(gep); return false; } void set_scheme(window wd, widget_geometrics* wdg_geom) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) iwd->annex.scheme = wdg_geom; } widget_geometrics* get_scheme(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; return (restrict::wd_manager().available(iwd) ? iwd->annex.scheme : nullptr); } void set_measurer(window wd, ::nana::dev::widget_content_measurer_interface* measurer) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) iwd->annex.content_measurer = measurer; } void attach_drawer(widget& wd, drawer_trigger& dr) { const auto iwd = reinterpret_cast<basic_window*>(wd.handle()); internal_scope_guard isg; if(restrict::wd_manager().available(iwd)) { iwd->drawer.graphics.make(iwd->dimension); iwd->drawer.graphics.rectangle(true, iwd->annex.scheme->background.get_color()); iwd->drawer.attached(wd, dr); iwd->drawer.refresh(); //Always redrawe no matter it is visible or invisible. This can make the graphics data correctly. } } ::nana::detail::native_string_type window_caption(window wd) throw() { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard isg; if(restrict::wd_manager().available(iwd)) { if (category::flags::root == iwd->other.category) return interface_type::window_caption(iwd->root); return iwd->title; } return {}; } void window_caption(window wd, ::nana::detail::native_string_type title) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { iwd->title.swap(title); if (iwd->other.category == category::flags::root) interface_type::window_caption(iwd->root, iwd->title); restrict::wd_manager().update(iwd, true, false); } } window create_window(window owner, bool nested, const rectangle& r, const appearance& ap, widget* wdg) { return reinterpret_cast<window>(restrict::wd_manager().create_root(reinterpret_cast<basic_window*>(owner), nested, r, ap, wdg)); } window create_widget(window parent, const rectangle& r, widget* wdg) { return reinterpret_cast<window>(restrict::wd_manager().create_widget(reinterpret_cast<basic_window*>(parent), r, false, wdg)); } window create_lite_widget(window parent, const rectangle& r, widget* wdg) { return reinterpret_cast<window>(restrict::wd_manager().create_widget(reinterpret_cast<basic_window*>(parent), r, true, wdg)); } #ifndef WIDGET_FRAME_DEPRECATED window create_frame(window parent, const rectangle& r, widget* wdg) { return reinterpret_cast<window>(restrict::wd_manager().create_frame(reinterpret_cast<basic_window*>(parent), r, wdg)); } #endif paint::graphics* window_graphics(window wd) { internal_scope_guard isg; if(restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) return &reinterpret_cast<basic_window*>(wd)->drawer.graphics; return nullptr; } void delay_restore(bool enable) { restrict::bedrock.delay_restore(enable ? 0 : 1); } void register_menu_window(window wd, bool has_keyboard) { internal_scope_guard lock; if (restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) restrict::bedrock.set_menu(reinterpret_cast<basic_window*>(wd)->root, has_keyboard); } void set_menubar(window wd, bool attach) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { auto root_attr = iwd->root_widget->other.attribute.root; if (attach) { if (!root_attr->menubar) root_attr->menubar = iwd; } else { if (iwd == root_attr->menubar) root_attr->menubar = nullptr; } } } void enable_space_click(window wd, bool enable) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) iwd->flags.space_click_enabled = enable; } bool copy_transparent_background(window wd, paint::graphics& graph) { auto & buf = reinterpret_cast<basic_window*>(wd)->other.glass_buffer; internal_scope_guard lock; if (bground_mode::basic != API::effects_bground_mode(wd)) return false; buf.paste(rectangle{ buf.size() }, graph, 0, 0); return true; } bool copy_transparent_background(window wd, const rectangle& src_r, paint::graphics& graph, const point& dst_pt) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (bground_mode::basic != API::effects_bground_mode(wd)) return false; iwd->other.glass_buffer.paste(src_r, graph, dst_pt.x, dst_pt.y); return true; } void lazy_refresh() { restrict::bedrock.thread_context_lazy_refresh(); } void draw_shortkey_underline(paint::graphics& graph, const std::string& text, wchar_t shortkey, std::size_t shortkey_position, const point& text_pos, const color& line_color) { if (shortkey) { auto off_x = (shortkey_position ? graph.text_extent_size(text.c_str(), shortkey_position).width : 0); auto key_px = static_cast<int>(graph.text_extent_size(&shortkey, 1).width); unsigned ascent, descent, inleading; graph.text_metrics(ascent, descent, inleading); int x = text_pos.x + static_cast<int>(off_x); int y = text_pos.y + static_cast<int>(ascent + 2); graph.line({ x, y }, {x + key_px - 1, y}, line_color); } } }//end namespace dev widget* get_widget(window wd) { internal_scope_guard lock; if (restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) return reinterpret_cast<basic_window*>(wd)->widget_notifier->widget_ptr(); return nullptr; } //close all windows in current thread void exit() { internal_scope_guard lock; restrict::bedrock.close_thread_window(nana::system::this_thread_id()); } //close all windows void exit_all() { internal_scope_guard lock; restrict::bedrock.close_thread_window(0); } //transform_shortkey_text //@brief: This function searchs whether the text contains a '&' and removes the character for transforming. // If the text contains more than one '&' charachers, the others are ignored. e.g // text = "&&a&bcd&ef", the result should be "&abcdef", shortkey = 'b', and pos = 2. //@param, text: the text is transformed. //@param, shortkey: the character which indicates a short key. //@param, skpos: retrives the shortkey position if it is not a null_ptr; std::string transform_shortkey_text(std::string text, wchar_t &shortkey, std::string::size_type *skpos) { shortkey = 0; std::string::size_type off = 0; while(true) { auto pos = text.find_first_of('&', off); if(pos != std::wstring::npos) { text.erase(pos, 1); if(shortkey == 0 && pos < text.length()) { shortkey = utf::char_at(text.c_str() + pos, 0, nullptr); if(shortkey == '&') //This indicates the text contains "&&", it means the symbol have to be ignored. shortkey = 0; else if(skpos) *skpos = pos; } off = pos + 1; } else break; } return text; } bool register_shortkey(window wd, unsigned long key) { return restrict::wd_manager().register_shortkey(reinterpret_cast<basic_window*>(wd), key); } void unregister_shortkey(window wd) { restrict::wd_manager().unregister_shortkey(reinterpret_cast<basic_window*>(wd), false); } ::nana::point cursor_position() { return interface_type::cursor_position(); } ::nana::rectangle make_center(unsigned width, unsigned height) { auto screen = interface_type::primary_monitor_size(); return{ static_cast<int>(width > screen.width ? 0 : (screen.width - width) >> 1), static_cast<int>(height > screen.height ? 0 : (screen.height - height) >> 1), width, height }; } ::nana::rectangle make_center(window wd, unsigned width, unsigned height) { nana::rectangle r = make_center(width, height); nana::point pos{ r.x, r.y }; calc_window_point(wd, pos); r.position(pos); return r; } void window_icon_default(const paint::image& small_icon, const paint::image& big_icon) { restrict::wd_manager().icon(nullptr, small_icon, big_icon); } void window_icon(window wd, const paint::image& small_icon, const paint::image& big_icon) { if(nullptr != wd) restrict::wd_manager().icon(reinterpret_cast<basic_window*>(wd), small_icon, big_icon); } bool empty_window(window wd) { return (restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd)) == false); } bool is_window(window wd) { return restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd)); } bool is_destroying(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (!restrict::wd_manager().available(iwd)) return false; return iwd->flags.destroying; } void enable_dropfiles(window wd, bool enb) { internal_scope_guard lock; auto iwd = reinterpret_cast<basic_window*>(wd); auto native_handle = API::root(wd); if (native_handle) { iwd->flags.dropable = enb; interface_type::enable_dropfiles(native_handle, enb); } } bool is_transparent_background(window wd) { return (bground_mode::basic == effects_bground_mode(wd)); } native_window_type root(window wd) { internal_scope_guard lock; if(is_window(wd)) return reinterpret_cast<basic_window*>(wd)->root; return nullptr; } window root(native_window_type wd) { return reinterpret_cast<window>(restrict::wd_manager().root(wd)); } void enable_double_click(window wd, bool dbl) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) iwd->flags.dbl_click = dbl; } void fullscreen(window wd, bool v) { internal_scope_guard lock; if(restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) reinterpret_cast<basic_window*>(wd)->flags.fullscreen = v; } #ifndef WIDGET_FRAME_DEPRECATED bool insert_frame(window frame, native_window_type native_window) { return restrict::wd_manager().insert_frame(reinterpret_cast<basic_window*>(frame), native_window); } native_window_type frame_container(window frame) { auto frm = reinterpret_cast<basic_window*>(frame); internal_scope_guard lock; if (restrict::wd_manager().available(frm) && (frm->other.category == category::flags::frame)) return frm->other.attribute.frame->container; return nullptr; } native_window_type frame_element(window frame, unsigned index) { auto frm = reinterpret_cast<basic_window*>(frame); internal_scope_guard lock; if (restrict::wd_manager().available(frm) && (frm->other.category == category::flags::frame)) { if (index < frm->other.attribute.frame->attach.size()) return frm->other.attribute.frame->attach.at(index); } return nullptr; } #endif void close_window(window wd) { restrict::wd_manager().close(reinterpret_cast<basic_window*>(wd)); } void show_window(window wd, bool show) { restrict::wd_manager().show(reinterpret_cast<basic_window*>(wd), show); } bool visible(window wd) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { if(iwd->other.category == category::flags::root) return interface_type::is_window_visible(iwd->root); return iwd->visible; } return false; } void restore_window(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { if(iwd->other.category == category::flags::root) interface_type::restore_window(iwd->root); } } void zoom_window(window wd, bool ask_for_max) { auto core_wd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(core_wd)) { if(category::flags::root == core_wd->other.category) interface_type::zoom_window(core_wd->root, ask_for_max); } } window get_parent_window(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) return reinterpret_cast<window>(iwd->parent); return nullptr; } window get_owner_window(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd) && (iwd->other.category == category::flags::root)) { auto owner = interface_type::get_owner_window(iwd->root); if(owner) return reinterpret_cast<window>(restrict::wd_manager().root(owner)); } return nullptr; } bool set_parent_window(window wd, window new_parent) { return restrict::wd_manager().set_parent(reinterpret_cast<basic_window*>(wd), reinterpret_cast<basic_window*>(new_parent)); } void umake_event(event_handle eh) { restrict::bedrock.evt_operation().erase(eh); } nana::point window_position(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { return ( (iwd->other.category == category::flags::root) ? interface_type::window_position(iwd->root) : iwd->pos_owner); } return nana::point{}; } void move_window(window wd, const point& pos) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().move(iwd, pos.x, pos.y, false)) { basic_window* update_wd = nullptr; if (iwd->displayed() && iwd->effect.bground) { update_wd = iwd; restrict::wd_manager().update(iwd, true, false); } basic_window* anc = iwd; if (category::flags::root != iwd->other.category) anc = iwd->seek_non_lite_widget_ancestor(); if (anc != update_wd) restrict::wd_manager().update(anc, false, false); } } void move_window(window wd, const rectangle& r) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().move(iwd, r)) { if (category::flags::root != iwd->other.category) iwd = iwd->seek_non_lite_widget_ancestor(); restrict::wd_manager().update(iwd, false, false); } } void bring_top(window wd, bool activated) { interface_type::bring_top(root(wd), activated); } bool set_window_z_order(window wd, window wd_after, z_order_action action_if_no_wd_after) { auto iwd = reinterpret_cast<basic_window*>(wd); native_window_type native_after = nullptr; internal_scope_guard lock; if (restrict::wd_manager().available(iwd) && (category::flags::root == iwd->other.category)) { if(wd_after) { auto iwd_after = reinterpret_cast<basic_window*>(wd_after); if (restrict::wd_manager().available(iwd_after) && (iwd_after->other.category == category::flags::root)) { native_after = iwd_after->root; action_if_no_wd_after = z_order_action::none; } else return false; } interface_type::set_window_z_order(iwd->root, native_after, action_if_no_wd_after); return true; } return false; } void draw_through(window wd, std::function<void()> draw_fn) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (!restrict::wd_manager().available(iwd)) throw std::invalid_argument("draw_through: invalid window parameter"); if (::nana::category::flags::root != iwd->other.category) throw std::invalid_argument("draw_through: the window is not a root widget"); iwd->other.attribute.root->draw_through.swap(draw_fn); } void map_through_widgets(window wd, native_drawable_type drawable) { auto iwd = reinterpret_cast<::nana::detail::basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd) && iwd->is_draw_through() ) restrict::bedrock.map_through_widgets(iwd, drawable); } nana::size window_size(window wd) { nana::rectangle r; API::get_window_rectangle(wd, r); return{ r.width, r.height }; } void window_size(window wd, const size& sz) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().size(iwd, sz, false, false)) { if (category::flags::root != iwd->other.category) iwd = iwd->seek_non_lite_widget_ancestor(); restrict::wd_manager().update(iwd, false, false); } } ::nana::size window_outline_size(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (!restrict::wd_manager().available(iwd)) return{}; auto sz = window_size(wd); sz.width += iwd->extra_width; sz.height += iwd->extra_height; return sz; } void window_outline_size(window wd, const size& sz) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { if (category::flags::root == iwd->other.category) { size inner_size = sz; if (inner_size.width < iwd->extra_width) inner_size.width = 0; else inner_size.width -= iwd->extra_width; if (inner_size.height < iwd->extra_height) inner_size.height = 0; else inner_size.height -= iwd->extra_height; window_size(wd, inner_size); } else window_size(wd, sz); } } bool get_window_rectangle(window wd, rectangle& r) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { r = rectangle(iwd->pos_owner, iwd->dimension); return true; } return false; } bool track_window_size(window wd, const nana::size& sz, bool true_for_max) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd) == false) return false; nana::size & ts = (true_for_max ? iwd->max_track_size : iwd->min_track_size); if(!sz.empty()) { if(true_for_max) { //Make sure the new size is larger than min size if (iwd->min_track_size.width > sz.width || iwd->min_track_size.height > sz.height) return false; } else { //Make sure that the new size is less than max size if ((iwd->max_track_size.width || iwd->max_track_size.height) && (iwd->max_track_size.width < sz.width || iwd->max_track_size.height < sz.height)) return false; } ts = interface_type::check_track_size(sz, iwd->extra_width, iwd->extra_height, true_for_max); } else ts.width = ts.height = 0; return true; } void window_enabled(window wd, bool enabled) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd) && (iwd->flags.enabled != enabled)) { iwd->flags.enabled = enabled; restrict::wd_manager().update(iwd, true, true); if(category::flags::root == iwd->other.category) interface_type::enable_window(iwd->root, enabled); } } bool window_enabled(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; return (restrict::wd_manager().available(iwd) ? iwd->flags.enabled : false); } //refresh_window //@brief: Refresh the window and display it immediately. void refresh_window(window wd) { restrict::wd_manager().update(reinterpret_cast<basic_window*>(wd), true, false); } void refresh_window_tree(window wd) { restrict::wd_manager().refresh_tree(reinterpret_cast<basic_window*>(wd)); } //update_window //@brief: it displays a window immediately without refreshing. void update_window(window wd) { restrict::wd_manager().update(reinterpret_cast<basic_window*>(wd), false, true); } void window_caption(window wd, const std::string& title_utf8) { throw_not_utf8(title_utf8); auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) iwd->widget_notifier->caption(to_nstring(title_utf8)); } void window_caption(window wd, const std::wstring& title) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) iwd->widget_notifier->caption(to_nstring(title)); } std::string window_caption(window wd) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) return to_utf8(iwd->widget_notifier->caption()); return{}; } void window_cursor(window wd, cursor cur) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { iwd->predef_cursor = cur; restrict::bedrock.update_cursor(iwd); } } cursor window_cursor(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) return iwd->predef_cursor; return cursor::arrow; } bool is_focus_ready(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) return (iwd->root_widget->other.attribute.root->focus == iwd); return false; } void activate_window(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { if(iwd->flags.take_active) interface_type::activate_window(iwd->root); } } window focus_window() { internal_scope_guard lock; return reinterpret_cast<window>(restrict::bedrock.focus()); } void focus_window(window wd) { restrict::wd_manager().set_focus(reinterpret_cast<basic_window*>(wd), false, arg_focus::reason::general); restrict::wd_manager().update(reinterpret_cast<basic_window*>(wd), false, false); } window capture_window() { return reinterpret_cast<window>(restrict::wd_manager().capture_window()); } void set_capture(window wd, bool ignore_children) { restrict::wd_manager().capture_window(reinterpret_cast<basic_window*>(wd), true, ignore_children); } void release_capture(window wd) { //The 3rd parameter is useless when the 2nd parameter is false. restrict::wd_manager().capture_window(reinterpret_cast<basic_window*>(wd), false, false); } void modal_window(window wd) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard isg; if (!restrict::wd_manager().available(iwd)) return; if ((iwd->other.category == category::flags::root) && (iwd->flags.modal == false)) { iwd->flags.modal = true; #if defined(NANA_X11) interface_type::set_modal(iwd->root); #endif restrict::wd_manager().show(iwd, true); } else return; //modal has to guarantee that does not lock the mutex of window_manager before invokeing the pump_event, //otherwise, the modal will prevent the other thread access the window. restrict::bedrock.pump_event(wd, true); } void wait_for(window wd) { internal_scope_guard lock; if (restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) restrict::bedrock.pump_event(wd, false); } color fgcolor(window wd) { internal_scope_guard lock; if (restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) return reinterpret_cast<basic_window*>(wd)->annex.scheme->foreground.get_color(); return{}; } color fgcolor(window wd, const color& clr) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { auto prev = iwd->annex.scheme->foreground.get_color(); if (prev != clr) { iwd->annex.scheme->foreground = clr; restrict::wd_manager().update(iwd, true, false); } return prev; } return{}; } color bgcolor(window wd) { internal_scope_guard lock; if (restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) return reinterpret_cast<basic_window*>(wd)->annex.scheme->background.get_color(); return{}; } color bgcolor(window wd, const color& clr) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { auto prev = iwd->annex.scheme->background.get_color(); if (prev != clr) { iwd->annex.scheme->background = clr; //If the bground mode of this window is basic, it should remake the background if (iwd->effect.bground && iwd->effect.bground_fade_rate < 0.01) // fade rate < 0.01 means it is basic mode iwd->flags.make_bground_declared = true; restrict::wd_manager().update(iwd, true, false); } return prev; } return{}; } color activated_color(window wd) { internal_scope_guard lock; if (restrict::wd_manager().available(reinterpret_cast<basic_window*>(wd))) return reinterpret_cast<basic_window*>(wd)->annex.scheme->activated.get_color(); return{}; } color activated_color(window wd, const color& clr) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { auto prev = iwd->annex.scheme->activated.get_color(); if (prev != clr) { iwd->annex.scheme->activated = clr; restrict::wd_manager().update(iwd, true, false); } return prev; } return{}; } class caret_proxy : public caret_interface { public: caret_proxy(basic_window* wd) : window_{ wd } {} void disable_throw() noexcept override { throw_ = false; } void effective_range(const rectangle& range) override { internal_scope_guard lock; auto caret = _m_caret(); if (caret) caret->effective_range(range); } void position(const point& pos) override { internal_scope_guard lock; auto caret = _m_caret(); if (caret) caret->position(pos); } point position() const override { internal_scope_guard lock; auto caret = _m_caret(); if (caret) return caret->position(); return{}; } void dimension(const size& size) override { internal_scope_guard lock; auto caret = _m_caret(); if (caret) caret->dimension(size); } size dimension() const override { internal_scope_guard lock; auto caret = _m_caret(); if (caret) return caret->dimension(); return{}; } void visible(bool visibility) override { internal_scope_guard lock; auto caret = _m_caret(); if (caret) caret->visible(visibility); } bool visible() const override { internal_scope_guard lock; auto caret = _m_caret(); return (caret && caret->visible()); } bool activated() const override { internal_scope_guard lock; auto caret = _m_caret(); return (caret && caret->activated()); } private: caret_interface* _m_caret() const { if (restrict::wd_manager().available(window_) && window_->annex.caret_ptr) return window_->annex.caret_ptr; if (throw_) throw std::runtime_error("nana.api: access invalid caret"); return nullptr; } private: basic_window* const window_; bool throw_{ true }; }; void create_caret(window wd, const size& caret_size) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd) && !(iwd->annex.caret_ptr)) iwd->annex.caret_ptr = new ::nana::detail::caret(iwd, caret_size); } void destroy_caret(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { auto p = iwd->annex.caret_ptr; iwd->annex.caret_ptr = nullptr; delete p; } } std::unique_ptr<caret_interface> open_caret(window window_handle, bool disable_throw) { auto p = new caret_proxy{ reinterpret_cast<basic_window*>(window_handle) }; if (disable_throw) p->disable_throw(); return std::unique_ptr<caret_interface>{ p }; } void tabstop(window wd) { restrict::wd_manager().enable_tabstop(reinterpret_cast<basic_window*>(wd)); } //eat_tabstop //@brief: set a eating tab window that it processes a pressing of tab itself void eat_tabstop(window wd, bool eat) { if(wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard isg; if(restrict::wd_manager().available(iwd)) { if(eat) iwd->flags.tab |= ::nana::detail::tab_type::eating; else iwd->flags.tab &= ~::nana::detail::tab_type::eating; } } } window move_tabstop(window wd, bool next) { basic_window* ts_wd = restrict::wd_manager().tabstop(reinterpret_cast<basic_window*>(wd), next); restrict::wd_manager().set_focus(ts_wd, false, arg_focus::reason::general); restrict::wd_manager().update(ts_wd, false, false); return reinterpret_cast<window>(ts_wd); } void take_active(window wd, bool active, window take_if_active_false) { auto const iwd = reinterpret_cast<basic_window*>(wd); auto take_if_false = reinterpret_cast<basic_window*>(take_if_active_false); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { if (active || (take_if_false && (restrict::wd_manager().available(take_if_false) == false))) take_if_false = 0; iwd->flags.take_active = active; iwd->other.active_window = take_if_false; } } bool window_graphics(window wd, nana::paint::graphics& graph) { return restrict::wd_manager().get_graphics(reinterpret_cast<basic_window*>(wd), graph); } bool root_graphics(window wd, nana::paint::graphics& graph) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { graph = *(iwd->root_graph); return true; } return false; } bool get_visual_rectangle(window wd, nana::rectangle& r) { return restrict::wd_manager().get_visual_rectangle(reinterpret_cast<basic_window*>(wd), r); } void typeface(window wd, const nana::paint::font& font) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { iwd->drawer.graphics.typeface(font); iwd->drawer.typeface_changed(); restrict::wd_manager().update(iwd, true, false); } } nana::paint::font typeface(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) return iwd->drawer.graphics.typeface(); return{}; } bool calc_screen_point(window wd, nana::point& pos) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { pos += iwd->pos_root; return interface_type::calc_screen_point(iwd->root, pos); } return false; } bool calc_window_point(window wd, nana::point& pos) { return restrict::wd_manager().calc_window_point(reinterpret_cast<basic_window*>(wd), pos); } window find_window(const nana::point& pos) { auto wd = interface_type::find_window(pos.x, pos.y); if(wd) { ::nana::point clipos{pos}; interface_type::calc_window_point(wd, clipos); return reinterpret_cast<window>( restrict::wd_manager().find_window(wd, clipos)); } return nullptr; } bool is_window_zoomed(window wd, bool ask_for_max) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { if (iwd->other.category == nana::category::flags::root) return interface_type::is_window_zoomed(iwd->root, ask_for_max); } return false; } void widget_borderless(window wd, bool enabled) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { if ((category::flags::widget == iwd->other.category) && (iwd->flags.borderless != enabled)) { iwd->flags.borderless = enabled; restrict::wd_manager().update(iwd, true, false); } } } bool widget_borderless(window wd) { auto const iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) return iwd->flags.borderless; return false; } nana::mouse_action mouse_action(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) return iwd->flags.action; return nana::mouse_action::normal; } nana::element_state element_state(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if(restrict::wd_manager().available(iwd)) { const bool is_focused = (iwd->root_widget->other.attribute.root->focus == iwd); switch(iwd->flags.action) { case nana::mouse_action::normal: case nana::mouse_action::normal_captured: return (is_focused ? nana::element_state::focus_normal : nana::element_state::normal); case nana::mouse_action::hovered: return (is_focused ? nana::element_state::focus_hovered : nana::element_state::hovered); case nana::mouse_action::pressed: return nana::element_state::pressed; default: if(false == iwd->flags.enabled) return nana::element_state::disabled; } } return nana::element_state::normal; } bool ignore_mouse_focus(window wd, bool ignore) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd)) { auto state = iwd->flags.ignore_mouse_focus; iwd->flags.ignore_mouse_focus = ignore; return state; } return false; } bool ignore_mouse_focus(window wd) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; return (restrict::wd_manager().available(iwd) ? iwd->flags.ignore_mouse_focus : false); } void at_safe_place(window wd, std::function<void()> fn) { restrict::wd_manager().set_safe_place(reinterpret_cast<basic_window*>(wd), std::move(fn)); } optional<std::pair<size, size>> content_extent(window wd, unsigned limited_px, bool limit_width) { auto iwd = reinterpret_cast<basic_window*>(wd); internal_scope_guard lock; if (restrict::wd_manager().available(iwd) && iwd->annex.content_measurer) { paint::graphics* graph = &iwd->drawer.graphics; paint::graphics temp_graph; if (graph->empty()) { temp_graph.make({ 1, 1 }); temp_graph.typeface(graph->typeface()); graph = &temp_graph; } auto extent = iwd->annex.content_measurer->measure(*graph, limited_px, limit_width); if (extent) return std::make_pair(extent.value(), extent.value() + iwd->annex.content_measurer->extension()); } return{}; } }//end namespace API }//end namespace nana
adf74f46dadb644d40a778031e0ee61ece20b15c
16e21287e52f91485098ab3416d53ebd9b992226
/HomeStudy/Cartsort/GameUI.cpp
8140c2d762753a9e6ffe260dae35677030a6afe2
[]
no_license
LeeMyeungJun/INHAstudy
e4ab14d897b23de10531072d231e3e01055ec65b
0be8d4bf597b413dcd99d93dbbf15a45983cf325
refs/heads/master
2023-04-02T22:16:36.785554
2020-10-15T08:37:45
2020-10-15T08:37:45
283,198,221
0
0
null
null
null
null
UTF-8
C++
false
false
159
cpp
#include "stdafx.h" #include "GameUI.h" GameUI::GameUI() { } GameUI::~GameUI() { } void GameUI::Draw(HWND hWnd, HDC hdc) { } void GameUI::Free(void) { }
815fd864de2db170616d1841a29ab9afe7f473ab
a90546b830d2c37e5db9284fe099b0f0658e723a
/libraries/rodeos/include/b1/rodeos/constants.hpp
40bb13c133d47251e4ac22f33c141c3a00535de5
[ "MIT" ]
permissive
NorseGaud/Eden
afba632342c2b56018e8d5d5bb8db38d81189f8f
56610ebea830c3e7febe3f0c42d8fdc7dec609a5
refs/heads/main
2023-05-02T19:20:36.591718
2021-05-17T13:36:30
2021-05-17T21:39:01
365,883,543
0
0
MIT
2021-05-10T01:19:47
2021-05-10T01:19:47
null
UTF-8
C++
false
false
353
hpp
#pragma once #include <eosio/name.hpp> namespace b1::rodeos { // kv database which stores rodeos state, including a mirror of nodeos state inline constexpr eosio::name state_database{"eosio.state"}; // account within state_database which stores state inline constexpr eosio::name state_account{"eosio.state"}; } // namespace b1::rodeos
71dee3d13022a950491a888e0ddcdcbbfa8b53b6
6a5cbcba6a8f3c249b96894cbfe38c98407c0459
/lists.cpp
22fd7d0d60d5a494cd6f2bfa8bd6e3ba07d15b81
[]
no_license
DevSeq/LC_baseTools
41525bdb6589b3d728983ad27b48388db23a3ec3
aa9cc7cc975e145747134e28842ebfafbc9da3a8
refs/heads/master
2022-11-15T23:59:57.876868
2020-07-03T03:55:26
2020-07-03T03:55:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,623
cpp
#include "lists.h" // *************** linkListObj ******************** // A none too bright node with a tail. linkListObj::linkListObj(void) { next = NULL; } linkListObj::~linkListObj(void) { // Bit of trouble here. We are single linked, so we // have no idea who's pointing to us. Therefore we must // Trust whomever is killing us off to take care of // unlinking us from our list. } // We're given a pointer to one of our instances and told to link in after this guy. // We can do that. void linkListObj::linkAfter(linkListObj* present) { if (present) { // Little sanity, don't link to NULL pointer. next = present->next; present->next = this; } } void linkListObj::linkToEnd(linkListObj* present) { if (present) { // If they're handing us NULL pointers, this is not our problem. while(present->next!=NULL) { // There's more?! present = present->next; // jump over to the next one! } // We should be sitting on the last one now.. present->next = this; // link in! } } // There are times when its nice to just ask. linkListObj* linkListObj::getNext(void) { return next; } // Lets point somewhere else.. void linkListObj::setNext(linkListObj* ptr) { next = ptr; } // Call delete on everyone hooked to us. void linkListObj::deleteTail(void) { linkListObj* temp; while (next) { temp = next; next = temp->next; delete(temp); } } // *** If you plan on sorting, its a good idea to fill out both! Even if one is a just function of the other. *** // // Are we greater than the linkListObj that has been passed in? You fill this out if you // plan to use the sorting method of linkList. bool linkListObj::isGreaterThan(linkListObj* compObj) { return false; } // Are we less than the linkListObj that has been passed in? You fill this out if you // plan to use the sorting method of linkList. bool linkListObj::isLessThan(linkListObj* compObj) { return false; } //********************* linkList ************************* // your basic linked list. Good base for linked list things, you know. // When we recieve an object to link up. Do we own it? Or are // we just tracking other people's laundry? Here is what we do. // They can pull out the ones they want whenever. We dump the rest. linkList::linkList(void) { theList = NULL; } linkList::~linkList(void) { dumpList(); } void linkList::addToTop(linkListObj* newObj) { newObj->setNext(theList); // Empty or not, it does the right thing. theList = newObj; } void linkList::addToEnd(linkListObj* newObj) { if (theList==NULL) { // No list huh? theList = newObj; } else { newObj->linkToEnd(theList); // Run along little object, go find your friends and link yourself in. } } // This one trusts you to keep track of the old top we are unlinking. void linkList::unlinkTop(void) { if (theList) { // if we have something there. theList = theList->getNext(); // unlink. } } // This does NOT delete the object, just unlinks it for you. // Better not loose it! void linkList::unlinkObj(linkListObj* oldObj) { linkListObj* temp; if (oldObj) { // They didn't hand us a NULL pointer. if(theList==oldObj) { // Were pointing at it. theList = oldObj->getNext(); // unlink.. } else { // We ain't pointing at it.. temp = theList; // We're going to have to go look for it. while(temp->getNext()!=oldObj && temp->getNext()!=NULL) { temp = temp->getNext(); } if (temp->getNext()==oldObj) { // Found it! temp->setNext(oldObj->getNext()); // unlink.. } } } } // Calls delete on all the object of the list. void linkList::dumpList(void) { linkListObj* trace; // Temp pointer. while(theList) { // While we still have something in the list. trace = getFirst(); // Point at the top of the list. unlinkTop(); // Unlink the top. delete(trace); // Delete the old top. } } bool linkList::isEmpty(void) { return(theList == NULL); } linkListObj* linkList::getFirst(void) { return theList; } linkListObj* linkList::getLast(void) { linkListObj* trace; trace = theList; if(trace) { while(trace->getNext()) { trace = trace->getNext(); } } return trace; } int linkList::getCount(void) { linkListObj* trace; long count; count = 0; trace = theList; while(trace) { count++; trace = trace->getNext(); } return count; } // And there are times it would be nice to grab one by index. // Like an array. Returns NULL if not found. linkListObj* linkList::getByIndex(int index) { linkListObj* trace; if (index>=0) { // Sanity, may be a Bozo calling. trace = theList; while(trace && index) { trace = trace->getNext(); index--; } return trace; } return NULL; } linkListObj* linkList::findMax(linkListObj* present) { linkListObj* trace; linkListObj* maxNode; maxNode = present; trace = present; while(trace) { if (trace->isGreaterThan(maxNode)) { maxNode = trace; } trace = trace->getNext(); } return maxNode; } linkListObj* linkList::findMin(linkListObj* present) { linkListObj* trace; linkListObj* minNode; minNode = present; trace = present; while(trace) { if (trace->isLessThan(minNode)) { minNode = trace; } trace = trace->getNext(); } return minNode; } // If the virtual isGreaterThan() and isLessThan() methods have been filled out this will // sort your list for you. void linkList::sort(bool ascending) { linkListObj* sorted; linkListObj* maxMin; sorted = NULL; while(!isEmpty()) { if (ascending) { maxMin = findMax(theList); } else { maxMin = findMin(theList); } if (maxMin) { unlinkObj(maxMin); maxMin->setNext(sorted); sorted = maxMin; } } theList = sorted; } // ********** stack **************** // Your basic stack. Mostly pass throughs with the usual names. stack::stack(void) : linkList() { } stack::~stack(void) { } void stack::push(linkListObj* newObj) { addToTop(newObj); } linkListObj* stack::pop(void) { linkListObj* topObj; topObj = getFirst(); if (topObj) { unlinkTop(); } return topObj; } linkListObj* stack::peek(void) { return getFirst(); } // ********** queue **************** // Your basic queue. Mostly pass throughs with the usual names. queue::queue(void) : linkList() { } queue::~queue(void) { } void queue::push(linkListObj* newObj) { addToEnd(newObj); } linkListObj* queue::peek(void) { return getFirst(); } linkListObj* queue::pop(void) { linkListObj* topObj; topObj = getFirst(); if (topObj) { unlinkTop(); } return topObj; } // ********** double linked list **************** dblLinkListObj::dblLinkListObj(void) { dllPrev = NULL; dllNext = NULL; } dblLinkListObj::~dblLinkListObj(void) { unhook(); } // Given a pointer to a node, link yourself after it. void dblLinkListObj::linkAfter(dblLinkListObj* present) { if (present) { dllNext = present->dllNext; dllPrev = present; present->dllNext = this; if (dllNext) dllNext->dllPrev = this; } } // Given a pointer to a node, link yourself before it. void dblLinkListObj::linkBefore(dblLinkListObj* present) { if (present) { dllPrev = present->dllPrev; dllNext = present; present->dllPrev = this; if (dllPrev) dllPrev->dllNext = this; } } dblLinkListObj* dblLinkListObj::getFirst(void) { dblLinkListObj* trace = this; while(trace->dllPrev) { trace = trace->dllPrev; } return trace; } dblLinkListObj* dblLinkListObj::getLast(void) { dblLinkListObj* trace; trace = this; while(trace->dllNext) { trace = trace->dllNext; } return trace; } // Given a pointer to a node, link yourself after the last in the chain. void dblLinkListObj::linkToEnd(dblLinkListObj* present) { if (present) linkAfter(present->getLast()); } // Given a pointer to a node, link yourself before the first in the chain. void dblLinkListObj::linkToStart(dblLinkListObj* present) { if (present) linkBefore(present->getFirst()); } // Unlink us and, if in list, patch the hole. void dblLinkListObj::unhook(void) { if (dllPrev) dllPrev->dllNext = dllNext; if (dllNext) dllNext->dllPrev = dllPrev; dllNext = NULL; dllPrev = NULL; } // Hand back the "nth" one of our tail. Starting at 0; dblLinkListObj* dblLinkListObj::getTailObj(int index) { dblLinkListObj* trace; int count; trace = dllNext; count = 0; while(trace&&count<index) { count++; trace = trace->dllNext; } return trace; } // Delete entire tail. delete calls unhook before deleting the object. void dblLinkListObj::dumpTail(void) { while(dllNext) delete dllNext; } // Delete entire head section. delete calls unhook before deleting the object. void dblLinkListObj::dumpHead(void) { while(dllPrev) delete dllPrev; } // Dump both head & tail, leaving ourselves. All alone.. void dblLinkListObj::dumpList(void) { dumpHead(); dumpTail(); } // How many nodes long is our tail? int dblLinkListObj::countTail(void) { dblLinkListObj* trace; int count; trace = dllNext; count = 0; while(trace) { count++; trace = trace->dllNext; } return count; } // How many nodes long is our head? int dblLinkListObj::countHead(void) { dblLinkListObj* trace; int count; trace = dllPrev; count = 0; while(trace) { count++; trace = dllPrev; } return count; }
162ac5eff01598244049c2ffb441fd360af8dda9
a90a4dafc296ff4551a2553fb0b71b369c16551e
/src/BCB.h
236e14618ce0a38c8a6449db8bb097b1d3f443ab
[]
no_license
USTCWzy/DataBaseLab
43aa40a525e1afc0fb622ad184567fba05ee61c6
df342103996d8a1cc876358db37acceba7144607
refs/heads/master
2023-02-07T09:11:01.151661
2020-12-26T02:11:46
2020-12-26T02:11:46
324,283,416
0
0
null
null
null
null
UTF-8
C++
false
false
311
h
// // Created by wzy1999 on 2020/12/8. // #ifndef PROJECT_BCB_H #define PROJECT_BCB_H class BCB { public: BCB(); BCB(int pid, int fid, int lat = 0, int cou = 0, int dit = 0); int page_id; int frame_id; int latch; int count; int dirty; BCB * next; }; #endif //PROJECT_BCB_H
a8c2a4aa75c66d4889ca58b7bdb0882434b42d89
222cbd1c2c3c50e70371960c19d0718efe417147
/abstractdb.h
946472d826460340704f2dfc96e5071da102164d
[]
no_license
iElaine/mcc
b412426d85e9f8ab34d47c37f931cd48ca521723
d6b2dbe5318a5a5689e01f696cdd14ba68bb506f
refs/heads/master
2020-06-03T20:54:19.545313
2013-12-12T09:11:32
2013-12-12T09:11:32
14,889,103
0
1
null
null
null
null
UTF-8
C++
false
false
785
h
#include <vector> class TrunkInfo { public: inline int localPort() const { mLocalPort;} inline int remotePort() const { mRemotePort;} inline int remoteMatrix() const { return mRemoteMatrix;} protected: int mLocalPort; int mRemotePort; int mRemoteMatrix; }; class CameraInfo { public: inline int port() const { mPort;} protected: int mPort; }; class MonitorInfo { public: inline int port() const { mPort;} protected: int mPort; }; class AbstractDb { public: virtual std::vector<TrunkInfo>& getTrunks() = 0; virtual std::vector<CameraInfo>& getCameras() = 0; virtual std::vector<MonitorInfo>& getMonitors() = 0; virtual int getUserInfo(const char *username, User& user) const = 0; virtual int getCameraInfo(int camera_id, Camera& cam) const = 0; };
60d0f9bbe5c11ad6923a90af2db65af70c21c157
c59592714400b575d770a70d792db34906179de3
/Classes/MarsGate/PublicComponentV2/longlink_packer.cc
7e8f0595d0fab500b44e0dfa93ae40e7f192bd24
[]
no_license
moky/StarGate
a7e4b466943eb6da29c53caae8a975081121bc6e
a4a35ffa7764e13b51105f3c3fb2971c2d254c74
refs/heads/master
2023-04-07T10:16:24.890993
2023-03-01T12:03:24
2023-03-01T12:03:24
171,844,942
0
0
null
null
null
null
UTF-8
C++
false
false
5,619
cc
// Tencent is pleased to support the open source community by making Mars available. // Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. // Licensed under the MIT License (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://opensource.org/licenses/MIT // Unless required by applicable law or agreed to in writing, software distributed under the License is // distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. /* * longlink_packer.cc * * Created on: 2012-7-18 * Author: yerungui, caoshaokun */ #include "longlink_packer.h" #ifndef WIN32 #include <arpa/inet.h> #endif // !WIN32 #ifdef __APPLE__ #include "mars/xlog/xlogger.h" #else #include "mars/comm/xlogger/xlogger.h" #endif #include "mars/comm/autobuffer.h" #include "mars/stn/stn.h" static uint32_t sg_client_version = 0; #pragma pack(push, 1) struct __STNetMsgXpHeader { uint32_t head_length; uint32_t client_version; uint32_t cmdid; uint32_t seq; uint32_t body_length; }; #pragma pack(pop) namespace mars { namespace stn { longlink_tracker* (*longlink_tracker::Create)() = []() { return new longlink_tracker; }; void SetClientVersion(uint32_t _client_version) { sg_client_version = _client_version; } static int __unpack_test(const void* _packed, size_t _packed_len, uint32_t& _cmdid, uint32_t& _seq, size_t& _package_len, size_t& _body_len) { __STNetMsgXpHeader st = {0}; if (_packed_len < sizeof(__STNetMsgXpHeader)) { _package_len = 0; _body_len = 0; return LONGLINK_UNPACK_CONTINUE; } memcpy(&st, _packed, sizeof(__STNetMsgXpHeader)); uint32_t head_len = ntohl(st.head_length); uint32_t client_version = ntohl(st.client_version); if (client_version != sg_client_version) { _package_len = 0; _body_len = 0; return LONGLINK_UNPACK_FALSE; } _cmdid = ntohl(st.cmdid); _seq = ntohl(st.seq); _body_len = ntohl(st.body_length); _package_len = head_len + _body_len; if (_package_len > 1024*1024) { return LONGLINK_UNPACK_FALSE; } if (_package_len > _packed_len) { return LONGLINK_UNPACK_CONTINUE; } return LONGLINK_UNPACK_OK; } void (*longlink_pack)(uint32_t _cmdid, uint32_t _seq, const AutoBuffer& _body, const AutoBuffer& _extension, AutoBuffer& _packed, longlink_tracker* _tracker) = [](uint32_t _cmdid, uint32_t _seq, const AutoBuffer& _body, const AutoBuffer& _extension, AutoBuffer& _packed, longlink_tracker* _tracker) { __STNetMsgXpHeader st = {0}; st.head_length = htonl(sizeof(__STNetMsgXpHeader)); st.client_version = htonl(sg_client_version); st.cmdid = htonl(_cmdid); st.seq = htonl(_seq); st.body_length = htonl(_body.Length()); _packed.AllocWrite(sizeof(__STNetMsgXpHeader) + _body.Length()); _packed.Write(&st, sizeof(st)); if (NULL != _body.Ptr()) _packed.Write(_body.Ptr(), _body.Length()); _packed.Seek(0, AutoBuffer::ESeekStart); }; int (*longlink_unpack)(const AutoBuffer& _packed, uint32_t& _cmdid, uint32_t& _seq, size_t& _package_len, AutoBuffer& _body, AutoBuffer& _extension, longlink_tracker* _tracker) = [](const AutoBuffer& _packed, uint32_t& _cmdid, uint32_t& _seq, size_t& _package_len, AutoBuffer& _body, AutoBuffer& _extension, longlink_tracker* _tracker) { size_t body_len = 0; int ret = __unpack_test(_packed.Ptr(), _packed.Length(), _cmdid, _seq, _package_len, body_len); if (LONGLINK_UNPACK_OK != ret) return ret; _body.Write(AutoBuffer::ESeekCur, _packed.Ptr(_package_len-body_len), body_len); return ret; }; #define NOOP_CMDID 6 #define SIGNALKEEP_CMDID 243 #define PUSH_DATA_TASKID 0 uint32_t (*longlink_noop_cmdid)() = []() -> uint32_t { return NOOP_CMDID; }; bool (*longlink_noop_isresp)(uint32_t _taskid, uint32_t _cmdid, uint32_t _recv_seq, const AutoBuffer& _body, const AutoBuffer& _extend) = [](uint32_t _taskid, uint32_t _cmdid, uint32_t _recv_seq, const AutoBuffer& _body, const AutoBuffer& _extend) { return Task::kNoopTaskID == _taskid && NOOP_CMDID == _cmdid; }; uint32_t (*signal_keep_cmdid)() = []() -> uint32_t { return SIGNALKEEP_CMDID; }; void (*longlink_noop_req_body)(AutoBuffer& _body, AutoBuffer& _extend) = [](AutoBuffer& _body, AutoBuffer& _extend) { }; void (*longlink_noop_resp_body)(const AutoBuffer& _body, const AutoBuffer& _extend) = [](const AutoBuffer& _body, const AutoBuffer& _extend) { }; uint32_t (*longlink_noop_interval)() = []() -> uint32_t { return 0; }; bool (*longlink_complexconnect_need_verify)() = []() { // 如果设为 true 经过心跳包验证的连接才认为是成功的连接。 // 如果你的长连接建立连接后第一个包必须是验证包,该函数的返回值一定要设为false。 return false; }; bool (*longlink_ispush)(uint32_t _cmdid, uint32_t _taskid, const AutoBuffer& _body, const AutoBuffer& _extend) = [](uint32_t _cmdid, uint32_t _taskid, const AutoBuffer& _body, const AutoBuffer& _extend) { return PUSH_DATA_TASKID == _taskid; }; bool (*longlink_identify_isresp)(uint32_t _sent_seq, uint32_t _cmdid, uint32_t _recv_seq, const AutoBuffer& _body, const AutoBuffer& _extend) = [](uint32_t _sent_seq, uint32_t _cmdid, uint32_t _recv_seq, const AutoBuffer& _body, const AutoBuffer& _extend) { return _sent_seq == _recv_seq && 0 != _sent_seq; }; } }
eaf06e087720a56f0cae822c5ed78002e5ee8f82
1743d6f133c7129e793dba0bc8788ac077c58f3c
/Nano-side/HC-12-start-nano/HC-12-start-nano.ino
cc19978d07e40689a09ce1243d6750c9d890c03b
[]
no_license
AndreiRadchenko/Brain-arduino
629ea1e74458e09b505630c226697f064ed9526a
f39361573c3d6dcaa0a2bf30f55fd03ec696a4e2
refs/heads/master
2020-04-16T20:09:15.665096
2019-01-27T10:46:16
2019-01-27T10:46:16
165,888,573
0
0
null
null
null
null
UTF-8
C++
false
false
11,856
ino
/* Data packet structure * * |_ _| |_ _| |_ _ _ ..._| - up to 64 byte * /\ /\ /\ * || || || * receiver sender payload * ID ID * * allowed command * Command example: 0100AT-C001 -> set nano with ID=01 to 1 radio chanel * 0200AT-RX -> get all HC12 settings for nano with ID=02 * 0100MODE-0 -> set nano with ID=01 to LASER_CALIBRATION mode * 0100MODE-1 -> set nano with ID=01 to LASER_RUN mode * 0100MODE-2 -> set nano with ID=01 to LASER_CONFIG mode * 0100MODE -> get active mod from nano with ID=01 * 0000MODE-1 -> set all nanos to LASER_RUN mode * 0100THRESHOLD-300 -> set light sensor threshold level * 0100THRESHOLD -> get light sensor threshold level * * Sending sequence * 0003 MODE: RUN THRES: 600 SENSOR: 555 VSS: 3999 BTN: OFF LASERCROSS 1//OFF->1 ON->0 * 0003;0;600;555;3999;1;1; * 0003 THRESHOLD DONE * 0003 BTN: ON * */ #include <SoftwareSerial.h> #define settingsPin 12 #define buttonPin 2 // Mode types supported: enum mode {LASER_CALIBRATION, LASER_RUN, LASER_CONFIG}; mode activeMode = LASER_CALIBRATION; unsigned long Interval = 5000; // milliseconds between updates unsigned long lastUpdate = 0; // last update of position int sensorPin = A0; // select the input pin for the photoresestor int sensorValue = 0; // variable to store the value coming from the sensor int sensor_threshold = 1024; // threshold for light sensor long vssValue = 0; int buttonState = HIGH; // the current reading from the input pin int lastButtonState = HIGH; // the previous reading from the input pin int laserCrossState = 1; // the current reading from the light sensor, 1- laser crossed int lastlaserCrossState = 1; // the previous reading from the light sensor // the following variables are unsigned longs because the time, measured in // milliseconds, will quickly become a bigger number than can be stored in an int. unsigned long lastDebounceTime = 0; // the last time the output pin was toggled unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers byte incomingByte; String readBuffer = ""; String header; String payload; String _ID = "01"; //Nano transceiver ID - unique for each Nano-HC-12 accemble String MASTER_ID = "00"; SoftwareSerial HC12(10,11); // HC-12 TX Pin, HC-12 RX Pin void setup() { Serial.begin(19200); // Serial port to computer HC12.begin(19200); // Serial port to HC12 pinMode(settingsPin, OUTPUT); digitalWrite(settingsPin, HIGH); pinMode(LED_BUILTIN, OUTPUT); pinMode(buttonPin, INPUT_PULLUP); digitalWrite(LED_BUILTIN, LOW); analogReference(DEFAULT); } void loop() { //sensorValue = analogRead(sensorPin); readButtonState(); readLaserState(); readBuffer = ""; // Clear readBuffer if (Serial.available()) { while (Serial.available()) { // If Serial monitor has data incomingByte = Serial.read(); // Store each icoming byte from HC-12 readBuffer += char(incomingByte); // Add each byte to ReadBuffer string variable delay(20); }; Serial.println(readBuffer); checkATCommand(); } else if (HC12.available()) { delay(100); if (receiveRadioData()) { //Serial.println(readBuffer); checkATCommand(); checkModeCommand(); } } else { switch (activeMode) { case LASER_CALIBRATION: if ((millis()-lastUpdate) > Interval) { lightMeasurement(); payload = getModuleState(); Serial.println(payload); if (!HC12.available()){ HC12.print(payload); //delay(5000); } lastUpdate = millis(); } break; case LASER_RUN: //checkLaserCross(); break; case LASER_CONFIG: delay(50); break; default: delay(50); break; } }; } // ==== Custom function - Check whether we have received an AT Command via the Serial Monitor void checkATCommand () { if (readBuffer.startsWith("AT")) { // Check whether the String starts with "AT" digitalWrite(settingsPin, LOW); // Set HC-12 into AT Command mode delay(200); // Wait for the HC-12 to enter AT Command mode HC12.print(readBuffer); // Send AT Command to HC-12 HC12.flush(); delay(200); while (HC12.available()) { // If HC-12 has data (the AT Command response) Serial.write(HC12.read()); // Send the data to Serial monitor } delay(200); digitalWrite(settingsPin, HIGH); // Exit AT Command mode } } void lightMeasurement() { sensorValue = analogRead(sensorPin); vssValue = readVcc(); vssValue = vssValue*1.38; //1.265 for ID=01 - enother type of mega328 chip } /* * return true if packet intended for this sensor */ bool receiveRadioData() { while (HC12.available()) { // If HC-12 has data incomingByte = HC12.read(); // Store each icoming byte from HC-12 readBuffer += char(incomingByte); // Add each byte to ReadBuffer string variable }; //Serial.println(readBuffer); header = readBuffer.substring(0,4); //Serial.println(header); //Serial.println(_ID+MASTER_ID); if (header.equals(_ID+MASTER_ID) || header.equals(MASTER_ID+MASTER_ID) ) { //separate only broadcast command or command for _ID-module readBuffer = readBuffer.substring(4); return true; } else { readBuffer = ""; return false; } } void checkModeCommand() { String payload = MASTER_ID + _ID; if (readBuffer.startsWith("MODE")) { // Check whether the String starts with "MODE" if (readBuffer.length() == 5) { payload = getModuleState(); Serial.println(payload); if (!HC12.available()){ HC12.print(payload); } } else { payload = readBuffer.substring(5,6); // Set active mode activeMode = payload.toInt(); // payload = getModuleState(); Serial.println(payload); if (!HC12.available()){ HC12.print(payload); //delay(5000); } } } if (readBuffer.startsWith("THRESHOLD")) { // Check whether the String starts with "MODE" if (readBuffer.length() == 10) { payload = getModuleState(); Serial.println(payload); if (!HC12.available()){ HC12.print(payload); } } else { payload = readBuffer.substring(10); // Get threshold level if (payload.toInt()>0) sensor_threshold = payload.toInt(); payload = getModuleState(); Serial.println(payload); if (!HC12.available()){ HC12.print(payload); } } } readBuffer = ""; } void checkLaserCross() { String payload = MASTER_ID + _ID; char serialbuff[64]; sensorValue = analogRead(sensorPin); delay(1); if (sensorValue > sensor_threshold) { //sprintf(serialbuff, "0001Sensor Value: %d", sensorValue); sprintf(serialbuff, " THRESHOLD DONE"); payload.concat(serialbuff); Serial.println(payload); while (activeMode == LASER_RUN) { //wait for transmission available if (!HC12.available()) { HC12.print(payload); delay(20); activeMode = LASER_CALIBRATION; } } } } void readButtonState() { // read the state of the switch into a local variable: int reading = digitalRead(buttonPin); // check to see if you just pressed the button // (i.e. the input went from HIGH to LOW), and you've waited long enough // since the last press to ignore any noise: // If the switch changed, due to noise or pressing: if (reading != lastButtonState) { // reset the debouncing timer lastDebounceTime = millis(); } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer than the debounce // delay, so take it as the actual current state: // if the button state has changed: if (reading != buttonState) { buttonState = reading; // only send message if the new button state is LOW if (buttonState == LOW) { String payload = MASTER_ID + _ID; char serialbuff[64]; //sprintf(serialbuff, "0001Sensor Value: %d", sensorValue); sprintf(serialbuff, " BTN: ON"); payload.concat(serialbuff); Serial.println(payload); //while (activeMode == LASER_RUN) { //wait for transmission available if (!HC12.available()) { HC12.print(payload); delay(20); //activeMode = LASER_CALIBRATION; } //} } } } // save the reading. Next time through the loop, it'll be the lastButtonState: lastButtonState = reading; } void readLaserState() { // read the state of the switch into a local variable: int reading; sensorValue = analogRead(sensorPin); delay(1); if (sensorValue > sensor_threshold) reading = 1; else reading = 0; // if the laser state has changed: if (reading != laserCrossState) { laserCrossState = reading; // only send message if the new laserCrossState state is 1 if (laserCrossState == 1) { String payload = MASTER_ID + _ID; char serialbuff[64]; //sprintf(serialbuff, "0001Sensor Value: %d", sensorValue); sprintf(serialbuff, " THRESHOLD DONE"); payload.concat(serialbuff); Serial.println(payload); //while (activeMode == LASER_RUN) { //wait for transmission available if (!HC12.available()) { HC12.print(payload); delay(300); //activeMode = LASER_CALIBRATION; } //} } } // save the reading. Next time through the loop, it'll be the lastButtonState: lastlaserCrossState = reading; } void moduleReplayDelay() { int replayDelay = 1000 + _ID.toInt()*100; delay(replayDelay); } long readVcc() { //measure applyed vss +5V on arduino board long result; // Read 1.1V reference against AVcc ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Convert while (bit_is_set(ADCSRA,ADSC)); result = ADCL; result |= ADCH<<8; result = 1125300L / result; // Back-calculate AVcc in mV return result; } /* return sending sequence * 0003 MODE: RUN THRES: 600 SENSOR: 555 VSS: 3999 BTN: OFF * 0003;0;600;555;3999;0; */ String getModuleState() { String payload = MASTER_ID + _ID + ';'; payload += String(activeMode) + ';'; payload += String(sensor_threshold) + ';'; payload += String(sensorValue) + ';'; payload += String(vssValue) + ';'; payload += String(buttonState) + ';'; payload += String(laserCrossState) + ';'; return payload; }
5a73b3e590913f054195f998ef5d52c70512fbae
8ecdbfc9e5ec00098200cb0335a97ee756ffab61
/games-generated/Stencyl_Vertical_Shooter/Export/windows/obj/include/box2D/collision/B2RayCastOutput.h
916d99f6a4ef4d066299c1f94b1cae1de47017d2
[]
no_license
elsandkls/Stencyl_VerticalSpaceShooter
89ccaafe717297a2620d6b777441e67f8751f0ec
87e501dcca05eaa5f8aeacc9f563b5d5080ffb53
refs/heads/master
2021-07-06T11:08:31.016728
2020-10-01T05:57:11
2020-10-01T05:57:11
184,013,592
1
0
null
null
null
null
UTF-8
C++
false
true
1,800
h
// Generated by Haxe 3.4.7 #ifndef INCLUDED_box2D_collision_B2RayCastOutput #define INCLUDED_box2D_collision_B2RayCastOutput #ifndef HXCPP_H #include <hxcpp.h> #endif HX_DECLARE_CLASS2(box2D,collision,B2RayCastOutput) HX_DECLARE_CLASS3(box2D,common,math,B2Vec2) namespace box2D{ namespace collision{ class HXCPP_CLASS_ATTRIBUTES B2RayCastOutput_obj : public hx::Object { public: typedef hx::Object super; typedef B2RayCastOutput_obj OBJ_; B2RayCastOutput_obj(); public: enum { _hx_ClassId = 0x0d4bf77d }; void __construct(); inline void *operator new(size_t inSize, bool inContainer=true,const char *inName="box2D.collision.B2RayCastOutput") { return hx::Object::operator new(inSize,inContainer,inName); } inline void *operator new(size_t inSize, int extra) { return hx::Object::operator new(inSize+extra,true,"box2D.collision.B2RayCastOutput"); } static hx::ObjectPtr< B2RayCastOutput_obj > __new(); static hx::ObjectPtr< B2RayCastOutput_obj > __alloc(hx::Ctx *_hx_ctx); static void * _hx_vtable; static Dynamic __CreateEmpty(); static Dynamic __Create(hx::DynamicArray inArgs); //~B2RayCastOutput_obj(); HX_DO_RTTI_ALL; hx::Val __Field(const ::String &inString, hx::PropertyAccess inCallProp); hx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp); void __GetFields(Array< ::String> &outFields); static void __register(); void __Mark(HX_MARK_PARAMS); void __Visit(HX_VISIT_PARAMS); bool _hx_isInstanceOf(int inClassId); ::String __ToString() const { return HX_HCSTRING("B2RayCastOutput","\xda","\xa5","\x79","\xa4"); } ::box2D::common::math::B2Vec2 normal; Float fraction; }; } // end namespace box2D } // end namespace collision #endif /* INCLUDED_box2D_collision_B2RayCastOutput */
903254bb3b697da3a8a4739b1e4052b4196ed0a3
9b4f4ad42b82800c65f12ae507d2eece02935ff6
/header/Net/RTPASource.h
00e18d8a8b3d592d673e1280ebcdfeaf9311e7b4
[]
no_license
github188/SClass
f5ef01247a8bcf98d64c54ee383cad901adf9630
ca1b7efa6181f78d6f01a6129c81f0a9dd80770b
refs/heads/main
2023-07-03T01:25:53.067293
2021-08-06T18:19:22
2021-08-06T18:19:22
393,572,232
0
1
null
2021-08-07T03:57:17
2021-08-07T03:57:16
null
UTF-8
C++
false
false
947
h
#ifndef _SM_NET_RTPASOURCE #define _SM_NET_RTPASOURCE #include "Media/IAudioSource.h" #include "Net/RTPCliChannel.h" #include "Net/RTPAPLHandler.h" namespace Net { class RTPASource : public Media::IAudioSource { private: Net::RTPCliChannel *ch; Net::RTPAPLHandler *hdlr; public: RTPASource(Net::RTPCliChannel *ch, Net::RTPAPLHandler *hdlr); virtual ~RTPASource(); virtual UTF8Char *GetSourceName(UTF8Char *buff); virtual Bool CanSeek(); virtual Int32 GetStreamTime(); virtual UInt32 SeekToTime(UInt32 time); virtual Bool TrimStream(UInt32 trimTimeStart, UInt32 trimTimeEnd, Int32 *syncTime); virtual void GetFormat(Media::AudioFormat *format); virtual Bool Start(Sync::Event *evt, UOSInt blkSize); virtual void Stop(); virtual UOSInt ReadBlock(UInt8 *buff, UOSInt blkSize); virtual UOSInt GetMinBlockSize(); virtual UInt32 GetCurrTime(); virtual Bool IsEnd(); }; } #endif
82c13ae814559de904d1498f0e17a1247da7948a
018eac278e23bf4611b1b5d4aa0ac106dff8238b
/problem/UVA - 12627 Erratic Expansion(分治).cpp
70bc1e778a70334b892187df39459abcd50f69ad
[]
no_license
qian99/acm
250294b153455913442d13bb5caed1a82cd0b9e3
4f88f34cbd6ee33476eceeeec47974c1fe2748d8
refs/heads/master
2021-01-11T17:38:56.835301
2017-01-23T15:00:46
2017-01-23T15:00:47
79,812,471
3
2
null
null
null
null
UTF-8
C++
false
false
911
cpp
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<map> #include<queue> #include<stack> #include<cmath> #include<vector> #include<bitset> #include<set> #define inf 0x3f3f3f3f #define Inf 0x3FFFFFFFFFFFFFFFLL #define eps 1e-6 #define pi acos(-1.0) using namespace std; typedef long long ll; ll dp[35]; ll f(int n,int k) { if(n==0) return k>=1; if(dp[n]!=-1&&(1<<n)==k) return dp[n]; n--; if(k<=(1<<n)) return f(n,k)*2; dp[n]=f(n,1<<n); return dp[n]*2+f(n,k-(1<<n)); } int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); memset(dp,0xff,sizeof(dp)); int t,tcase=0; scanf("%d",&t); int K,A,B; while(t--) { scanf("%d%d%d",&K,&A,&B); ll ans=f(K,B)-f(K,A-1); printf("Case %d: %lld\n",++tcase,ans); } return 0; }
6e8a5e37a1fa11bd07763626141336972df3f7a9
eed3040703f502a22b0b3e30704776a6851a751e
/online-judges/SPOJ/oldStuff_cpp/EGYPIZZA.cpp
b01324af084ba1b1933a99d09a79b2b22cf6271d
[]
no_license
velazqua/competitive-programming
a6b5fcc8a9169de43d1f6f1fbf3ed2241749ccfc
cf8cda1132a5791917f4861f313b8098934f3c6b
refs/heads/master
2021-01-01T16:20:11.103309
2014-03-02T03:45:44
2014-03-02T03:45:44
12,732,139
1
3
null
null
null
null
UTF-8
C++
false
false
829
cpp
#include <iostream> #include <map> using namespace std; int main () { int N; cin >> N; int q=0, h=0, t=0; string temp; int minPizza=0; for (int i=0;i<N;++i) { cin >> temp; if (temp == "1/2") ++h; else if (temp == "3/4") ++t; else ++q; } //cout << q << " " << h << " " << t << endl; int mini; // 3/4s with 1/4s if (q && t) { mini=(q<t)?q:t; q -= mini; t -= mini; minPizza += mini; } // 1/4 with 1/4s if (q>1) { h += q/2; q %= 2; } // 1/2s with 1/2s if (h>1) { minPizza += h/2; h %= 2; } // 1/2s with 1/4s if (h || q) { minPizza++; } cout << t+minPizza+1 << endl; }
088a71ded3c6735771194933dc631b4c36acd62a
59db5ff05c428bad93cb74f9a460a46627c49b06
/Data structures/list/listnode.cpp
37ff7535a44b7e91dfd07a0a5b016a37cf754e28
[]
no_license
n0n1/algolist
2956011dca033d85ad3f656202462bd7bceb116c
e7dbb0b6220f57d465a23773243dc123ac14218f
refs/heads/master
2021-01-23T13:43:10.191105
2014-01-25T23:34:10
2014-01-25T23:34:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
671
cpp
#include "listnode.h" ListNode::ListNode() { _data = 0; _next = nullptr; } void ListNode::insertNext(int d) { ListNode *new_node = new ListNode(); // создаем новый узел new_node->_data = d; // заполняем данные узла new_node->_next = _next; // значение поля текущего элемента _next = new_node; // текущий узел указывает на вновь созданный } ListNode *ListNode::next() { return _next; } int ListNode::data() { return _data; } void ListNode::setNext(ListNode *node) { _next = node; } void ListNode::setData(int d) { _data = d; }
55ba0c5923a824a459ecbbc4ecea067634de4a1a
ad7a774330b2d5ad8a08c4a65113bd43964c3c1d
/031821BlackJack/031821BlackJack/BlackJack.cpp
3607ad9436e04ef4ccd94e7ba7d2d99026f9bda9
[]
no_license
jacob7123/CPLUSPLUS-Project
2e2e18a93372f06e738a76e761d0ca92046e2312
d26a372e378c95a64b1402c4f3212b01a43ca9a0
refs/heads/master
2023-04-13T06:09:58.172016
2021-03-29T23:08:18
2021-03-29T23:08:18
349,576,314
0
0
null
null
null
null
UTF-8
C++
false
false
7,627
cpp
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <ctime> using namespace std; class Card { public: enum rank { ACE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, Nine, TEN, JACK, QUEEN, KING }; enum suit { SPADES, HEARTS, DIAMONDS, CLUBS }; friend ostream& operator<<(ostream& os, const Card& aCard); Card(rank r = ACE, suit = SPADES, bool ifu = true); //Get value int GetValue() const; //Show card void Flip(); private: rank m_Rank;//Card's value suit m_Suit;//Card's suit bool m_IsFaceUp;//show or not show }; Card::Card(rank r, suit s, bool ifu):m_Rank(r), m_Suit(s), m_IsFaceUp(ifu){ } int Card::GetValue() const { //If card face down, the value is 0 int value = 0; if (m_IsFaceUp) { value = m_Rank; if (value > 10) { value = 10; } } return value; } void Card::Flip() { m_IsFaceUp = !(m_IsFaceUp); } class Hand { public: Hand(); virtual ~Hand(); void Add(Card* pCard); void Clear(); int GetTotal() const;//Calculate value protected: vector<Card*> m_Cards; }; Hand::Hand() { m_Cards.reserve(7); } Hand::~Hand(){ Clear(); } void Hand::Add(Card* pCard) { m_Cards.push_back(pCard); } void Hand::Clear() { vector<Card*>::iterator iter; for (iter = m_Cards.begin(); iter != m_Cards.end(); ++iter) { delete *iter; *iter = nullptr; } m_Cards.clear(); } int Hand::GetTotal()const { if (m_Cards.empty()) return 0; if (m_Cards[0]->GetValue() == 0) return 0; //If Ace = 1 int total = 0; vector<Card*>::const_iterator iter; for (iter = m_Cards.begin(); iter != m_Cards.end(); ++iter) { total += (*iter)->GetValue(); } bool containAce = false; for (iter = m_Cards.begin(); iter != m_Cards.end(); ++iter){ if ((*iter)->GetValue() == Card::ACE) containAce = true; } //If have ACE, and value is small, Ace = 11 if (containAce && total <= 11) total += 10; return total; } class GenericPlayer : public Hand { friend ostream& operator<<(ostream& os, const GenericPlayer& aGeneticPlayer); public: GenericPlayer(const string& name = ""); virtual ~GenericPlayer(){} virtual bool IsHitting() const = 0; bool IsBusted() const { return (GetTotal() > 21); } void Bust()const { cout << m_Name << ", Your value large than 21" << endl; } protected: string m_Name; }; GenericPlayer::GenericPlayer(const string& name):m_Name(name) {} class Player : public GenericPlayer { public: Player(const string& name = ""); virtual ~Player() { } virtual bool IsHitting()const; void Win() const; void Lose() const; void Push() const; }; Player::Player(const string& name) : GenericPlayer(name) {} void Player::Win()const { cout << m_Name << " win" << endl; } void Player::Lose()const { cout << m_Name << " lose" << endl; } void Player::Push()const { cout << m_Name << " tie" << endl; } bool Player::IsHitting() const { cout << m_Name << ", you want more card?(Y/N)" << endl; char response; cin >> response; while (toupper(response) != 'Y' && toupper(response) != 'N') { cout << "Please enter Y/y or N/n." << endl; cin >> response; } return (toupper(response) == 'Y'); } class House : public GenericPlayer { public: House(const string& name = "House") :GenericPlayer(name) {} virtual ~House(){} virtual bool IsHitting()const { return (GetTotal() <= 16); } inline void FilpFirstCard() { if (!(m_Cards.empty())) { m_Cards[0]->Flip(); } else { cout << "No card is hidding." << endl; } } }; class Deck : Hand { public: Deck(); virtual ~Deck(){} void Populate();//create 52 cards void Shuffle(); void Deal(Hand& hand);//Give card void AdditionalCards(GenericPlayer& aGeneticPlayer); }; Deck::Deck() { m_Cards.reserve(52); Populate(); } void Deck::Populate() { Clear(); for (int s = Card::SPADES; s <= Card::CLUBS; ++s) { for (int r = Card::ACE; r <= Card::KING; ++r) { Add(new Card(static_cast<Card::rank>(r), static_cast<Card::suit>(s))); } } } void Deck::Shuffle() { random_shuffle(m_Cards.begin(), m_Cards.end()); } void Deck::Deal(Hand& hand) { if (!m_Cards.empty()) { hand.Add(m_Cards.back()); m_Cards.pop_back(); } else { cout << "There are no any card can given." << endl; } } void Deck::AdditionalCards(GenericPlayer& aGen) { cout << endl; while (!(aGen.IsBusted()) && aGen.IsHitting()) { Deal(aGen); cout << aGen << endl; if (aGen.IsBusted()) { aGen.Bust(); } } } class Game { public: Game(const vector<string>& names); void Play(); private: Deck m_Deck; House m_House; vector<Player> m_Player; }; Game::Game(const vector<string>& names) { vector<string>::const_iterator p_Name; for (p_Name = names.begin(); p_Name != names.end(); ++p_Name) { m_Player.push_back(Player(*p_Name)); } srand(static_cast<unsigned int>(time(0))); m_Deck.Populate(); m_Deck.Shuffle(); } void Game::Play() { vector<Player>::iterator p_Player; for (int i = 0; i < 2; ++i) { for (p_Player = m_Player.begin(); p_Player != m_Player.end(); ++p_Player) { m_Deck.Deal(*p_Player); } m_Deck.Deal(m_House); } m_House.FilpFirstCard(); for (p_Player = m_Player.begin(); p_Player != m_Player.end(); ++p_Player) { cout << *p_Player << endl; } cout << m_House << endl; for (p_Player = m_Player.begin(); p_Player != m_Player.end(); ++p_Player) { m_Deck.AdditionalCards(*p_Player); } m_House.FilpFirstCard(); cout << endl << m_House << endl; m_Deck.AdditionalCards(m_House); if (m_House.IsBusted()) { for (p_Player = m_Player.begin(); p_Player != m_Player.end(); ++p_Player) { if (!p_Player->IsBusted()) { p_Player->Win(); } } } else { for (p_Player = m_Player.begin(); p_Player != m_Player.end(); ++p_Player) { if (!p_Player->IsBusted()) { if (p_Player->GetTotal() > m_House.GetTotal()) p_Player->Win(); else if (p_Player->GetTotal() < m_House.GetTotal()) p_Player->Lose(); else p_Player->Push(); } else p_Player->Lose(); } } for (p_Player = m_Player.begin(); p_Player != m_Player.end(); ++p_Player) { p_Player->Clear(); } m_House.Clear(); } ostream& operator <<(ostream&, const Card& aCard); ostream& operator <<(ostream&, const GenericPlayer& aGenericPlater); int main(void) { cout << "Welcome to play BlacJack by Chingyen Huang" << endl; int num_Player = 0; while (num_Player < 1 || num_Player > 7) { cout << "Please enter number of players:"; cin >> num_Player; cout << endl; } vector<string> names; string name; for (int i = 0; i < num_Player; ++i) { cout << "Please enter player name:"; cin >> name; names.push_back(name); } cout << endl; Game aGame(names); char ans = 'y'; while (toupper(ans) != 'N') { aGame.Play(); cout << "Do you want to play again?(y/n):"; cin >> ans; cout << endl; } cout << "Thank you for your time!! Have good day. Bye~~" << endl; system("pause"); return 0; } ostream& operator <<(ostream& os, const Card& aCard) { const string RANKS[] = { "0", "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" }; //SPADES, HEARTS, DIAMONDS, CLUBS const string SUITS[] = { "SPADES", "HEARTS", "DIAMONDS", "CLUBS" }; if (aCard.m_IsFaceUp) { os << SUITS[aCard.m_Suit] << " " << RANKS[aCard.m_Rank]; } else { os << "XX"; } return os; } ostream& operator <<(ostream& os, const GenericPlayer& aGenericPlayer) { os << aGenericPlayer.m_Name << ":\t"; vector<Card*>::const_iterator p_Card; if (!aGenericPlayer.m_Cards.empty()) { for (p_Card = aGenericPlayer.m_Cards.begin(); p_Card != aGenericPlayer.m_Cards.end(); ++p_Card) { os << *(*p_Card) << "\t"; } if (aGenericPlayer.GetTotal() != 0) cout << "(" << aGenericPlayer.GetTotal() << ")"; } else cout << "<empty>"; return os; }
22c1f72fe9bb177c9d11cfc2c17d76cc76f0a76e
a7779fc4092f81346a79850c5ced18cd8cd0bd18
/scripts/TaggerAnalysis/taggerAnalysisLib.cxx
8e50a5c39b77c2522c77cde651cc4ac3732619fc
[]
no_license
ncbtaggeranalysis/ncb-tagger-analysis
d3d1aef5edb17ccbd6b87735691cab741cb63699
7841f670f6ced6e29532f6c304a93cc8d2fdd8ac
refs/heads/master
2020-04-24T14:54:29.570709
2019-02-22T13:11:57
2019-02-22T13:11:57
172,043,046
0
0
null
null
null
null
UTF-8
C++
false
false
6,090
cxx
#include <TObjArray.h> #include <TObjString.h> #include <TSystem.h> #include "taggerAnalysisLib.h" namespace TaggerAnalysisLib { pair<TString,TString> getDatasetProjectTagAndPeriod(int runNumber) { pair<TString,TString> res; if ((runNumber>=266904&&runNumber<=267167) || runNumber==267638 || runNumber==267639) res={"data15_13TeV","periodA"}; if (runNumber>=267358&&runNumber<=267599) res={"data15_13TeV","periodB"}; if (runNumber>=270441&&runNumber<=272531) res={"data15_13TeV","periodC"}; if (runNumber>=276073&&runNumber<=276954) res={"data15_13TeV","periodD"}; if (runNumber>=278727&&runNumber<=279928) res={"data15_13TeV","periodE"}; if (runNumber>=296939&&runNumber<=300287) res={"data16_13TeV","periodA"}; if (runNumber>=300345&&runNumber<=300908) res={"data16_13TeV","periodB"}; if (runNumber>=324320&&runNumber<=325558) res={"data17_13TeV","periodA"}; if (runNumber>=325713&&runNumber<=328393) res={"data17_13TeV","periodB"}; if (runNumber>=348197&&runNumber<=348836) res={"data18_13TeV","periodA"}; if (runNumber>=348885&&runNumber<=349533) res={"data18_13TeV","periodB"}; if (runNumber>=349534&&runNumber<=350220) res={"data18_13TeV","periodC"}; if (runNumber>=350310&&runNumber<=352107) res={"data18_13TeV","periodD"}; if (runNumber>=352123&&runNumber<=352137) res={"data18_13TeV","periodE"}; if (runNumber>=352274&&runNumber<=352514) res={"data18_13TeV","periodF"}; if (runNumber>=354107&&runNumber<=354396) res={"data18_13TeV","periodG"}; if (runNumber>=354826&&runNumber<=355224) res={"data18_13TeV","periodH"}; if (runNumber>=355261&&runNumber<=355273) res={"data18_13TeV","periodI"}; if (runNumber>=355331&&runNumber<=355468) res={"data18_13TeV","periodJ"}; if (runNumber>=355529&&runNumber<=356259) res={"data18_13TeV","periodK"}; if (runNumber>=357050&&runNumber<=359171) res={"data18_13TeV","periodL"}; if (runNumber>=359191&&runNumber<=360414) res={"data18_13TeV","periodM"}; if (runNumber>=361635&&runNumber<=361696) res={"data18_13TeV","periodN"}; if (runNumber>=361738&&runNumber<=363400) res={"data18_13TeV","periodO"}; if (runNumber>=363664&&runNumber<=364292) res={"data18_13TeV","periodQ"}; if (res.first=="") cout << Form("getDatasetProjectTagAndPeriod: unknown runNumber: %i", runNumber) << endl; return res; } void getDatasetInfo(TString filename, TString& projectTag, int& runNumber, TString& period, TString& stream) { projectTag=""; runNumber=0; period=""; stream=""; TString runNumberStr=""; TString dirname = gSystem->DirName(filename); TString dirnameBase = gSystem->BaseName(dirname); TString filenameBase = gSystem->BaseName(filename); TObjArray* objArray = filenameBase.Tokenize("."); for (int i=0;i<objArray->GetEntries();i++) { TString word = objArray->At(i)->GetName(); if (word == "data15_13TeV" || word == "data16_13TeV" || word == "data17_13TeV" || word == "data18_13TeV" || word == "mc16_13TeV") { projectTag = word; if (i+1<objArray->GetEntries()) { runNumberStr= objArray->At(i+1)->GetName(); if (runNumberStr.IsDigit()) runNumber = runNumberStr.Atoi(); } break; } } objArray = dirnameBase.Tokenize("."); for (int i=0;i<objArray->GetEntries();i++) { TString word = objArray->At(i)->GetName(); if (word == "data15_13TeV" || word == "data16_13TeV" || word == "data17_13TeV" || word == "data18_13TeV" || word == "mc16_13TeV") { projectTag = word; if (i+1<objArray->GetEntries()) { runNumberStr= objArray->At(i+1)->GetName(); if (runNumberStr.IsDigit()) runNumber = runNumberStr.Atoi(); } break; } } if (!projectTag.Contains("data") && !projectTag.Contains("mc")) throw "wrong projectTag=" + projectTag+" for filename="+filename; if (runNumber==0||projectTag=="") throw Form("getDatasetInfo: failed to set runNumber(%i) or projectTag(%s)," "filename=%s", runNumber, projectTag.Data(),filename.Data()); //cout<<"projectTag="<<projectTag<<endl; if (projectTag.Contains("data")) { period = getDatasetProjectTagAndPeriod(runNumber).second; if (filename.Contains("physics_Main")) stream="physics_Main"; else if (filename.Contains("physics_Background")) stream="physics_Background"; } } int getDatasetRunNumber(TString ds) { TObjArray* objArray = TString(gSystem->BaseName(ds)).Tokenize("."); TString runNumberStr=""; for (int i=0;i<objArray->GetEntries();i++) { TString word = objArray->At(i)->GetName(); if (word == "data15_13TeV" || word == "data16_13TeV" || word == "data17_13TeV" || word == "data18_13TeV" || word == "mc16_13TeV") { runNumberStr= objArray->At(i+1)->GetName(); break; } } return runNumberStr.Atoi(); } vector<TString> getListOfFilesInDirectory(TString inDir, TString pattern) { TSystemDirectory dir("",inDir); TList* list = dir.GetListOfFiles(); if (!list) throw "getListOfFilesInDirectory: pointer to the list of files is null"; vector<string> filenameVec; for (int i=0;i<list->GetEntries();i++) { TString filename=list->At(i)->GetName(); if (!filename.Contains(pattern)) continue; filenameVec.push_back(filename.Data()); } std::sort(filenameVec.begin(),filenameVec.end()); vector<TString> fileList; for (string filename : filenameVec) fileList.push_back(inDir + TString("/") + filename.data()); return fileList; } pair<float,float> getEfficiency(int nsample, int ntagged) { float mean_eff = (nsample !=0) ? (float)ntagged/nsample : 0; float statErrorUp=TEfficiency::Normal(nsample,ntagged,0.683,true)-mean_eff; float statErrorDown=mean_eff-TEfficiency::Normal(nsample,ntagged,0.683,false); pair<float, float> res; res.first = mean_eff; res.second = 0.5*(statErrorUp+statErrorDown); return res; } }
f696aca2f3bf5dfc19973551c358ff1434672f07
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_1483485_0/C++/StephYDX/main.cpp
a3117873d98d36a45ca770e373f8a66b7b5de82b
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,735
cpp
#include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <set> #include <map> #include <queue> #include <time.h> using namespace std; typedef long long llong; inline int bit(int x, int i){ return (x>>i) & 1;} inline int setb(int x, int i){ return x | (1 << i);} inline int clrb(int x, int i){ return x & (~(1 << i));} inline int lowb(int x){return x & (-x);} const char *hint[][2]={ { "ejp mysljylc kd kxveddknmc re jsicpdrysi", "our language is impossible to understand", }, { "rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd", "there are twenty six factorial possibilities", }, { "de kr kd eoya kw aej tysr re ujdr lkgc jv", "so it is okay if you want to just give up", }, { "y qee", "a zoo", }, { "z", "q", }, }; char rep[256]; int main(){ freopen("A-small-attempt0.in", "r", stdin); freopen("As0.txt", "w", stdout); for(int i = 0;i < 256; ++i) rep[i] = '_'; int cnt_h = sizeof(hint) / sizeof(hint[0]); for(int i = 0;i < cnt_h; ++i){ const char *s1 = hint[i][0]; const char *s2 = hint[i][1]; while(*s1){ /* if(rep[*s1] != '_' && rep[*s1] != *s2){ puts("ERROR"); printf("%c -> %c %c", *s1, rep[*s1], *s2); }*/ rep[*s1] = *s2; ++s1; ++s2; } } //for(int i = 'a'; i <= 'z'; ++i) printf("%c",i);puts(""); //for(int i = 'a'; i <= 'z'; ++i) printf("%c",rep[i]);puts(""); int TT; char buf[105]; scanf("%d", &TT); gets(buf); for(int cas = 1; cas <= TT; ++cas){ gets(buf); for(int i = 0;buf[i]; ++i){ buf[i] = rep[buf[i]]; } printf("Case #%d: %s\n", cas, buf); } return 0; }
f4bae652f86382d50b1ff331e69a3bed7a92dea5
c90a56e7d7752b041fc5eb38257c5573cef346c6
/src-linux/Quantity_tmpl.hxx
dc8ef5999e3cd3acc81834659595be58dab3a5cf
[]
no_license
random-builder/design_cadquery_ocp
a4c572a72699bad52ca5f43f30bb7c15d89072ff
2af799a9f1b2d81fd39e519b2f73e12b34a14c0a
refs/heads/master
2021-05-21T23:10:23.833461
2020-03-29T15:34:46
2020-03-29T15:34:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,933
hxx
#pragma once // pybind 11 related includes #include <pybind11/pybind11.h> #include <pybind11/stl.h> namespace py = pybind11; // Standard Handle #include <Standard_Handle.hxx> // includes to resolve forward declarations #include <Quantity_DateDefinitionError.hxx> #include <Standard_OutOfRange.hxx> #include <Quantity_Period.hxx> #include <Quantity_PeriodDefinitionError.hxx> #include <Quantity_ColorDefinitionError.hxx> // module includes #include <Quantity_LuminousFlux.hxx> #include <Quantity_Rate.hxx> #include <Quantity_PlaneAngle.hxx> #include <Quantity_Index.hxx> #include <Quantity_Mass.hxx> #include <Quantity_PeriodDefinitionError.hxx> #include <Quantity_Inductance.hxx> #include <Quantity_Concentration.hxx> #include <Quantity_MagneticFlux.hxx> #include <Quantity_Coefficient.hxx> #include <Quantity_PhysicalQuantity.hxx> #include <Quantity_Conductivity.hxx> #include <Quantity_Luminance.hxx> #include <Quantity_Impedance.hxx> #include <Quantity_Consumption.hxx> #include <Quantity_MolarConcentration.hxx> #include <Quantity_ColorHasher.hxx> #include <Quantity_Activity.hxx> #include <Quantity_Frequency.hxx> #include <Quantity_ElectricCapacitance.hxx> #include <Quantity_HArray1OfColor.hxx> #include <Quantity_Enthalpy.hxx> #include <Quantity_Quotient.hxx> #include <Quantity_Ratio.hxx> #include <Quantity_Normality.hxx> #include <Quantity_VolumeFlow.hxx> #include <Quantity_ColorRGBAHasher.hxx> #include <Quantity_Momentum.hxx> #include <Quantity_TypeOfColor.hxx> #include <Quantity_KinematicViscosity.hxx> #include <Quantity_Length.hxx> #include <Quantity_Force.hxx> #include <Quantity_ElectricPotential.hxx> #include <Quantity_SurfaceTension.hxx> #include <Quantity_Area.hxx> #include <Quantity_Parameter.hxx> #include <Quantity_AcousticIntensity.hxx> #include <Quantity_Volume.hxx> #include <Quantity_KineticMoment.hxx> #include <Quantity_MolarVolume.hxx> #include <Quantity_Scalaire.hxx> #include <Quantity_LuminousIntensity.hxx> #include <Quantity_AmountOfSubstance.hxx> #include <Quantity_Resistance.hxx> #include <Quantity_Admittance.hxx> #include <Quantity_DateDefinitionError.hxx> #include <Quantity_Torque.hxx> #include <Quantity_Molarity.hxx> #include <Quantity_Date.hxx> #include <Quantity_Energy.hxx> #include <Quantity_CoefficientOfExpansion.hxx> #include <Quantity_MomentOfInertia.hxx> #include <Quantity_AbsorbedDose.hxx> #include <Quantity_MomentOfAForce.hxx> #include <Quantity_ElectricCurrent.hxx> #include <Quantity_Work.hxx> #include <Quantity_ThermalConductivity.hxx> #include <Quantity_Weight.hxx> #include <Quantity_NameOfColor.hxx> #include <Quantity_MagneticFieldStrength.hxx> #include <Quantity_MolarMass.hxx> #include <Quantity_Period.hxx> #include <Quantity_Entropy.hxx> #include <Quantity_Color.hxx> #include <Quantity_Viscosity.hxx> #include <Quantity_AngularVelocity.hxx> #include <Quantity_Power.hxx> #include <Quantity_SoundIntensity.hxx> #include <Quantity_ColorRGBA.hxx> #include <Quantity_ColorDefinitionError.hxx> #include <Quantity_SolidAngle.hxx> #include <Quantity_Reluctance.hxx> #include <Quantity_Resistivity.hxx> #include <Quantity_Acceleration.hxx> #include <Quantity_Velocity.hxx> #include <Quantity_ElectricCharge.hxx> #include <Quantity_Array2OfColor.hxx> #include <Quantity_LuminousEfficacity.hxx> #include <Quantity_MagneticFluxDensity.hxx> #include <Quantity_Illuminance.hxx> #include <Quantity_Factor.hxx> #include <Quantity_MassFlow.hxx> #include <Quantity_LuminousExposition.hxx> #include <Quantity_Constant.hxx> #include <Quantity_Temperature.hxx> #include <Quantity_Array1OfColor.hxx> #include <Quantity_Pressure.hxx> #include <Quantity_DoseEquivalent.hxx> #include <Quantity_Speed.hxx> #include <Quantity_Capacitance.hxx> #include <Quantity_Content.hxx> #include <Quantity_ElectricFieldStrength.hxx> #include <Quantity_Density.hxx> #include <Quantity_SpecificHeatCapacity.hxx> // user-defined pre #include "OCP_specific.inc" // Class template handling functions // ./opencascade/Quantity_LuminousFlux.hxx // ./opencascade/Quantity_Rate.hxx // ./opencascade/Quantity_PlaneAngle.hxx // ./opencascade/Quantity_Index.hxx // ./opencascade/Quantity_Mass.hxx // ./opencascade/Quantity_PeriodDefinitionError.hxx // ./opencascade/Quantity_Inductance.hxx // ./opencascade/Quantity_Concentration.hxx // ./opencascade/Quantity_MagneticFlux.hxx // ./opencascade/Quantity_Coefficient.hxx // ./opencascade/Quantity_PhysicalQuantity.hxx // ./opencascade/Quantity_Conductivity.hxx // ./opencascade/Quantity_Luminance.hxx // ./opencascade/Quantity_Impedance.hxx // ./opencascade/Quantity_Consumption.hxx // ./opencascade/Quantity_MolarConcentration.hxx // ./opencascade/Quantity_ColorHasher.hxx // ./opencascade/Quantity_Activity.hxx // ./opencascade/Quantity_Frequency.hxx // ./opencascade/Quantity_ElectricCapacitance.hxx // ./opencascade/Quantity_HArray1OfColor.hxx // ./opencascade/Quantity_Enthalpy.hxx // ./opencascade/Quantity_Quotient.hxx // ./opencascade/Quantity_Ratio.hxx // ./opencascade/Quantity_Normality.hxx // ./opencascade/Quantity_VolumeFlow.hxx // ./opencascade/Quantity_ColorRGBAHasher.hxx // ./opencascade/Quantity_Momentum.hxx // ./opencascade/Quantity_TypeOfColor.hxx // ./opencascade/Quantity_KinematicViscosity.hxx // ./opencascade/Quantity_Length.hxx // ./opencascade/Quantity_Force.hxx // ./opencascade/Quantity_ElectricPotential.hxx // ./opencascade/Quantity_SurfaceTension.hxx // ./opencascade/Quantity_Area.hxx // ./opencascade/Quantity_Parameter.hxx // ./opencascade/Quantity_AcousticIntensity.hxx // ./opencascade/Quantity_Volume.hxx // ./opencascade/Quantity_KineticMoment.hxx // ./opencascade/Quantity_MolarVolume.hxx // ./opencascade/Quantity_Scalaire.hxx // ./opencascade/Quantity_LuminousIntensity.hxx // ./opencascade/Quantity_AmountOfSubstance.hxx // ./opencascade/Quantity_Resistance.hxx // ./opencascade/Quantity_Admittance.hxx // ./opencascade/Quantity_DateDefinitionError.hxx // ./opencascade/Quantity_Torque.hxx // ./opencascade/Quantity_Molarity.hxx // ./opencascade/Quantity_Date.hxx // ./opencascade/Quantity_Energy.hxx // ./opencascade/Quantity_CoefficientOfExpansion.hxx // ./opencascade/Quantity_MomentOfInertia.hxx // ./opencascade/Quantity_AbsorbedDose.hxx // ./opencascade/Quantity_MomentOfAForce.hxx // ./opencascade/Quantity_ElectricCurrent.hxx // ./opencascade/Quantity_Work.hxx // ./opencascade/Quantity_ThermalConductivity.hxx // ./opencascade/Quantity_Weight.hxx // ./opencascade/Quantity_NameOfColor.hxx // ./opencascade/Quantity_MagneticFieldStrength.hxx // ./opencascade/Quantity_MolarMass.hxx // ./opencascade/Quantity_Period.hxx // ./opencascade/Quantity_Entropy.hxx // ./opencascade/Quantity_Color.hxx // ./opencascade/Quantity_Viscosity.hxx // ./opencascade/Quantity_AngularVelocity.hxx // ./opencascade/Quantity_Power.hxx // ./opencascade/Quantity_SoundIntensity.hxx // ./opencascade/Quantity_ColorRGBA.hxx // ./opencascade/Quantity_ColorDefinitionError.hxx // ./opencascade/Quantity_SolidAngle.hxx // ./opencascade/Quantity_Reluctance.hxx // ./opencascade/Quantity_Resistivity.hxx // ./opencascade/Quantity_Acceleration.hxx // ./opencascade/Quantity_Velocity.hxx // ./opencascade/Quantity_ElectricCharge.hxx // ./opencascade/Quantity_Array2OfColor.hxx // ./opencascade/Quantity_LuminousEfficacity.hxx // ./opencascade/Quantity_MagneticFluxDensity.hxx // ./opencascade/Quantity_Illuminance.hxx // ./opencascade/Quantity_Factor.hxx // ./opencascade/Quantity_MassFlow.hxx // ./opencascade/Quantity_LuminousExposition.hxx // ./opencascade/Quantity_Constant.hxx // ./opencascade/Quantity_Temperature.hxx // ./opencascade/Quantity_Array1OfColor.hxx // ./opencascade/Quantity_Pressure.hxx // ./opencascade/Quantity_DoseEquivalent.hxx // ./opencascade/Quantity_Speed.hxx // ./opencascade/Quantity_Capacitance.hxx // ./opencascade/Quantity_Content.hxx // ./opencascade/Quantity_ElectricFieldStrength.hxx // ./opencascade/Quantity_Density.hxx // ./opencascade/Quantity_SpecificHeatCapacity.hxx // user-defined post
58e90ca01fbfe4142ab778604312eede75dcf5cc
79432d86096d2ab02ff4ef01db35264b5bb0159a
/Classes/DayStartScene.h
feeba814bae9f0fa82f84bd8e0b12224ca44dd34
[]
no_license
KatyaAnk/DeathIsGuaranteed
4a6840f10c101ff7294a6d1be17fc4813ecd892d
2b993ded7f9ef8fbd4cc7e00d7b973d2f6ecdecc
refs/heads/master
2023-02-02T08:29:30.523806
2020-12-21T01:49:43
2020-12-21T01:49:43
323,203,553
0
0
null
null
null
null
UTF-8
C++
false
false
1,619
h
/**************************************************************************** Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __DAYSTART_SCENE_H__ #define __DAYSTART_SCENE_H__ #include "cocos2d.h" class DayStartScene : public cocos2d::Scene { public: static cocos2d::Scene* createScene(); virtual bool init(); // implement the "static create()" method manually CREATE_FUNC(DayStartScene); }; #endif // __DAYSTART_SCENE_H__
500ff362d4203b3ca0ce03d6fc1fadf0506f374b
7cfad4f342ca60bbf09bbb6c8912a01f9d03c865
/FlexBison/include/generator.hpp
583ba249504628258badab6ef4769ed9e7f46046
[]
no_license
FarOutWest/CSCI450
8616593b9b587f68e63fbb40056d8136d04035ae
ce99bbfd4f26c78ae015bf3b84919cdbd17ba96f
refs/heads/master
2021-01-20T10:56:51.864599
2017-11-29T17:26:35
2017-11-29T17:26:35
101,660,858
0
0
null
null
null
null
UTF-8
C++
false
false
272
hpp
#pragma once #include "ast.hpp" #include <memory.h> struct Generator { NodePtr ast; Generator(const NodePtr &_ast); virtual void generate(std::ostream &out) = 0; }; typedef std::shared_ptr <Generator> GeneratorPtr; GeneratorPtr generator(const NodePtr &ast);
16f6317a63620681244dea90d9b936b89a8e9908
252fe2c91d3ab5e59524ef5096bdcfc79c27daa5
/src/RBTree.cpp
a13c8561b608024720c16cf231e73bee1285e3f5
[ "WTFPL" ]
permissive
Numb4r/RBTree
267683182e81a68f9a916190704178a30d100ae6
4544053a42540e7cd4bafc0ed9c92629c91cdf8c
refs/heads/master
2023-03-06T07:34:18.289358
2021-02-15T21:34:57
2021-02-15T21:34:57
337,541,646
0
0
null
null
null
null
UTF-8
C++
false
false
10,015
cpp
#include "RBTree.hpp" /* Funcoes Print */ void RBTree::inOrder(NODE* n){ if (n == Tnil) return; inOrder(n->left); std::cout<<n->key<<" "; inOrder(n->right); } void RBTree::preOrder(NODE* n){ if (n == Tnil) return; std::cout<<n->key<<" "; preOrder(n->left); preOrder(n->right); } void RBTree::posOrder(NODE* n){ if (n == Tnil) return; posOrder(n->left); posOrder(n->right); std::cout<<n->key<<" "; } void RBTree::PlotRecurse(NODE* node,std::string separator,bool last) { if(node != Tnil){ std::cout<< separator; if(last){ std::cout<<"R----"; separator+=" "; }else{ std::cout<<"L----"; separator+="| "; } std::cout <<node->key <<"("<<(node->color ? "RED" : "BLACK") <<")"<<std::endl; PlotRecurse(node->left,separator,false); PlotRecurse(node->right,separator,true); } } void RBTree::plot() noexcept{ PlotRecurse(root,"",false); } NODE* RBTree::search(const int key)const noexcept{ NODE *pNode = root; while (pNode != Tnil && pNode->key != key) if(key > pNode->key) pNode = pNode->right; else pNode = pNode->left; return pNode; } void RBTree::show(const show_t show) noexcept{ switch (show) { case INORDER: inOrder(root); break; case POSORDER: posOrder(root); break; case PREORDER: preOrder(root); break; case PLOT: default: plot(); break; } } /* Funcoes Print */ /*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ /* Funcoes Auxiliares */ void RBTree::NDReplace(NODE* x,NODE* y){ if (x->parent == Tnil ) this->root = y; else if(x==x->parent->left) x->parent->left = y; else x->parent->right = y; y->parent = x->parent; } NODE* RBTree::TreeMinimum(NODE* node){ while (node->left != Tnil) node = node->left; return node; } NODE* RBTree::TreeMaximum(NODE* node){ while (node->right != Tnil) node = node->right; return node; } void RBTree::RotateLeft(NODE* x){ NODE* y = x->right; x->right = y->left; if (y->left != Tnil) { y->left->parent = x; } y->parent = x->parent; if (x->parent == Tnil) { root = y; } else if (x == x->parent->left) { x->parent->left = y; } else { x->parent->right = y; } y->left = x; x->parent = y; } void RBTree::RotateRight(NODE* x){ NODE* y = x->left; x->left = y->right; if (y->right != Tnil) { y->right->parent = x; } y->parent = x->parent; if (x->parent == Tnil) { root = y; } else if (x == x->parent->right) { x->parent->right = y; } else { x->parent->left = y; } y->right = x; x->parent = y; } /* Funcoes Auxiliares */ /*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ /* Funcoes Insersao */ void RBTree::InsertRepairTree(NODE* pNode){ NODE* pAux; while (pNode->parent->color == RED) { if(pNode->parent == pNode->parent->parent->right){//right pAux = pNode->parent->parent->left; // uncle if(pAux->color == RED){//case 1 pAux->color = BLACK; pNode->parent->color = BLACK; pNode->parent->parent->color=RED; pNode = pNode->parent->parent; }else{ if(pNode==pNode->parent->left){//case 2 pNode = pNode->parent; RotateRight(pNode); } //case 3 pNode->parent->color = BLACK; pNode->parent->parent->color = RED; RotateLeft(pNode->parent->parent); } }else{//left pAux = pNode->parent->parent->right; if(pAux->color == RED){ pAux->color = BLACK; pNode->parent->color = BLACK; pNode->parent->parent->color = RED; pNode = pNode->parent->parent; }else{ if(pNode == pNode->parent->right){ pNode = pNode->parent; RotateLeft(pNode); } pNode->parent->color = BLACK; pNode->parent->parent->color = RED; RotateRight(pNode->parent->parent); } } } root->color = BLACK; } void RBTree::insert(const int key) noexcept{ NODE* pNode = new NODE(key,Tnil,Tnil);// left = right = Null NODE* pParent = Tnil; NODE* pSentinel = root; while (pSentinel != Tnil) { pParent = pSentinel; // Ao final do loop pParent sera o parente de pNode if(pNode->key > pSentinel->key) pSentinel = pSentinel->right; else pSentinel = pSentinel->left; } pNode->parent= pParent; if (pParent == Tnil ) { /*Caso seja o primeiro item,sera preto e nao precisara fazer nada*/ root = pNode; }else{ if(pNode->key > pParent->key) pParent->right = pNode; else pParent->left = pNode; } InsertRepairTree(pNode); } /* Funcoes Insersao */ /*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ /* Funcoes Remocao */ void RBTree::DeleteRepairTree(NODE* x){ NODE* w; while (x != root && x->color == BLACK) { if(x == x->parent->left){ // left w = x->parent->right; if (w->color==RED)//Case 1 { w->color = BLACK; x->parent->color = RED; RotateLeft(x->parent); w = x->parent->right; } if(w->left->color == BLACK && w->right->color == BLACK){//case 2 w->color = RED; x = x->parent; }else{ if (w->right->color == BLACK)//case 3 { w->left->color = BLACK; w->color = RED; RotateRight(w); w = x->parent->right; } //case 4 w->color = x->parent->color; x->parent->color = BLACK; w->right->color = BLACK; RotateLeft(x->parent); x = root; } }else{//right w = x->parent->left; if(w->color == RED){ // case 1 w->color = BLACK; x->parent->color = RED; RotateRight(x->parent); w = x->parent->left; } if (w->right->color == BLACK && w->left->color == BLACK)//case 2 { w->color = RED; x = x->parent; }else{ if(w->left->color == BLACK){//case 3 w->right->color = BLACK; w->color = RED; RotateLeft(w); w = x->parent->left; } //case 4 x->color = x->parent->color; x->parent->color = BLACK; w->left->color = BLACK; RotateRight(x->parent); x = root; } } } x->color = BLACK; } void RBTree::eraseTree(NODE* n){ if (n == Tnil) return; eraseTree(n->left); eraseTree(n->right); delete n; n = nullptr; } void RBTree::erase(const int key) { NODE* z = this->search(key); if(z == Tnil || z->key != key) { throw "Couldn`t find key in the tree"; return; } NODE* y = z; NODE* x; color_t y_original_color = y->color; //Confere se possui algum filho null if(z->left == Tnil){ x = z->right; NDReplace(z,z->right); if(z == root) root = x; }else if(z->right == Tnil){ x=z->left; NDReplace(z,z->left); if(z == root) root = x; }else{//Possui 2 filhos y = TreeMinimum(z->right); y_original_color = y->color; x = y->right; if(y->parent == z){ x->parent = y; }else{ NDReplace(y,y->right); y->right = z->right; y->right->parent = y; } NDReplace(z,y); y->left = z->left; y->left->parent = y; y->color = z->color; if(z == root) root = y; } delete z; z = nullptr; if(y_original_color == BLACK) DeleteRepairTree(x); } /* Funcoes Remocao */ /*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ RBTree::RBTree(){ Tnil = new NODE(BLACK); root = Tnil; } RBTree::~RBTree(){ eraseTree(root); delete Tnil; Tnil = nullptr; } RBTree::RBTree(std::initializer_list<int> list):RBTree(){ for (auto &&i : list) this->insert(i); }
bce6c0a5237a9341f0dad8438c9148de0e25b910
8ae275d30bd0559653826462c43671787ac57591
/edu/talks/sean_parent/concept_based_poly_test.cc
23f1ac586fe5c0da33535719e3b3ace7aefb6723
[]
no_license
zaqwes8811/cpp-tricks
bea1ec4fac69a8fa74c0285183c519b8708d905d
74e0db5ab422fe7bbeb19afc57ea4b77818c9871
refs/heads/master
2023-05-11T13:28:15.980184
2023-05-10T17:56:39
2023-05-10T17:56:39
12,433,207
0
0
null
2022-02-01T19:50:47
2013-08-28T12:40:37
C++
UTF-8
C++
false
false
5,978
cc
/** http://stackoverflow.com/questions/21821948/concept-based-polymorphism http://thinkthencode.blogspot.ru/2013/02/concept-based-polymorphism.html */ #include <gtest/gtest.h> #include <algorithm> #include <iostream> #include <memory> #include <string> #include <typeinfo> #include <vector> using std::cout; using std::endl; using std::move; using std::ostream; using std::string; using std::vector; namespace ps_sample_shared_extend { class object_t { public: template <typename T> object_t(const T &x) : self_(std::make_shared<model<T>>(move(x))) {} friend void draw(const object_t &x, ostream &out, size_t position) { x.self_->draw_(out, position); // cout << x } private: class concept_t { public: virtual ~concept_t() = default; virtual void draw_(ostream &out, size_t position) const = 0; }; template <typename T> struct model : concept_t { model(const T &x) : data_(move(x)) {} void draw_(ostream &out, size_t position) const { // draw(data_, out, position); } T data_; // главный вопрос в куче ли? Да - см в Мейсере 35 }; std::shared_ptr<const concept_t> self_; // ссылки на immutable }; using document_t = vector<object_t>; // полиморфизм только через shared_ptrs template <typename T> void draw(const T &x, ostream &out, size_t position) { out << string(position, ' ') << x << endl; } void draw(const document_t &x, ostream &out, size_t position) { out << string(position, ' ') << "<document>" << endl; for (const auto &e : x) draw(e, out, position + 2); out << string(position, ' ') << "</document>" << endl; } /// Ps using history_t = vector<document_t>; void commit(history_t &x) { assert(x.size()); x.push_back(x.back()); } void undo(history_t &x) { assert(x.size()); x.pop_back(); } document_t &current(history_t &x) { assert(x.size()); return x.back(); } } // namespace ps_sample_shared_extend namespace external_space { // не нужно ничего наследовать. class my_class_t { public: my_class_t() {} my_class_t(const my_class_t &) { cout << "copy mc\n"; } int arr[10]; private: // FIXME: What the hell? static void *operator new(size_t size); static void operator delete(void *ptr); }; void draw(const my_class_t &, ostream &out, size_t position) { out << string(position, ' ') << "my_class_t()" << endl; } } // namespace external_space TEST(EvelPsExtend, App) { using namespace ps_sample_shared_extend; using namespace external_space; history_t h(1); // Работаем с верхним элементом // current(h).emplace_back(0); // current(h).emplace_back(string("Hello!")); current(h).emplace_back(my_class_t()); current(h).emplace_back(my_class_t()); current(h).emplace_back(my_class_t()); draw(current(h), cout, 0); cout << "-------------" << endl; std::reverse(current(h).begin(), current(h).end()); commit(h); // сохраняем текущую и ее копируем на верх. cout << "-------------" << endl; // current(h).emplace_back(current(h)); current(h).emplace_back(my_class_t()); current(h)[4] = my_class_t(); draw(current(h), cout, 0); cout << "-------------" << endl; undo(h); draw(current(h), cout, 0); } namespace database { /** \fixme const troubles \attention how reduce 2 hier.? */ namespace detail { struct pq_tag {}; struct sqlite_tab {}; template <typename T> struct holder_traits; template <> struct holder_traits<string> { typedef sqlite_tab category; }; template <> struct holder_traits<int> { typedef pq_tag category; }; } // namespace detail namespace real_objs { // no inh.! struct sqlite { sqlite(string _s) : s(_s) {} void drop() {} string build() { return s; } string s; }; struct sqlite_builder { // sqlite_builder() }; struct postgresql { postgresql(int _s) : s(_s) {} void drop() {} int build() { return s; } int s; }; } // namespace real_objs // Dropable class object_t { public: template <typename T> object_t(const T &x) : self_(std::make_shared<model<T>>(move(x))) {} // FIXME: it's bad. must be friend? void drop() { // no way to know dyn. type self_->drop_(); } // generate // template <typename T private: class concept_t { public: virtual ~concept_t() = default; virtual void drop_() = 0; virtual ps_sample_shared_extend::object_t build_() = 0; }; template <typename T> struct model : concept_t { model(const T &x) : data_(move(x)) {} void drop_() override { data_.drop(); } ps_sample_shared_extend::object_t build_() override { return ps_sample_shared_extend::object_t(data_.build()); } T data_; }; std::shared_ptr< // const // can't concept_t> self_; // ссылки на immutable }; // Fabric: template <typename T> object_t create(std::weak_ptr<T> p) { return object_t(0); } // by value, not by type enum db_vars { DB_SQLITE, DB_POSTGRES }; // if (selector == DB_POSTGRES) object_t build_data_base(const int selector) { using namespace real_objs; if (selector == DB_SQLITE) return object_t(sqlite("")); else return object_t(postgresql(0)); } } // namespace database TEST(DB, Test) { using namespace database; using namespace database::real_objs; // db.registerBeanClass<Obj>() auto a = object_t(sqlite("")); auto b = object_t(postgresql(0)); a.drop(); // FIXME: how connect multy DB drivers? int selector = 0; auto db = build_data_base(selector); // 1. Put handler - db specific - to queries builder // 2. Builder store in some high level object // 3. Want make queries on base getted handler }
64f51839e51846a13c7374eec488e68be07289e4
6d2901a69fbdd1a758a69d963d830ada6b7a6eea
/Lw 2/2.2/CGraph.h
30139fede33d6f0253c960aa72ec81b689170032
[]
no_license
MaxMartST/Combinatorial-Matmatics
22655bdec5e52f4ef8048780f308e33ec643210d
5627f63baedf5c3b16c511033365b6691f16f0dd
refs/heads/master
2021-01-03T01:20:20.782920
2020-06-28T16:02:55
2020-06-28T16:02:55
239,855,507
1
0
null
null
null
null
UTF-8
C++
false
false
932
h
#pragma once #include <string> class CMatrixIterator; class CGraph { public: CGraph(std::istream& in); int GetNumberOfVertices() const { return numberOfVertices; } friend class CMatrixIterator; private: template <class T> std::vector<T> ConvertStringToVector(std::string& line); std::vector<std::vector<int>> adjacencyMatrix; int numberOfVertices; void UploadGraph(std::istream& in); static const size_t NUMBER_INPUT_PARAMETERS = 1; static const size_t MAX_POINTS_COUNT = 400; }; class CMatrixIterator { private: const CGraph& m_graph; int i, v; public: CMatrixIterator(const CGraph& graph, int v) : m_graph(graph) , v(v) , i(-1) { } int beg() { i = -1; return nxt(); } int nxt() { for (i++; i < m_graph.GetNumberOfVertices(); i++) { if (m_graph.adjacencyMatrix[v][i] == 1) { return i; } } return -1; } bool end() { return i >= m_graph.GetNumberOfVertices(); } };
76903851a2185ce5f5fd9869d7b74b859b08d4dd
21fb16a81acb4d77f1c6346045283d0ace0f811d
/SPOJ/INCSEQ.cpp
4eb49959fc7f4cb9dec7b715c9dad1b7467f017d
[]
no_license
fmejbah/Solve
667ce02375a7069b0e37e85bfada4a9b40baff1a
028bbff58062c143617f7a151f9616c6b8e0f2d4
refs/heads/master
2021-04-03T07:19:00.026638
2018-03-08T17:34:15
2018-03-08T17:34:15
124,426,604
0
1
null
null
null
null
UTF-8
C++
false
false
801
cpp
/* * Biborno * fb.com/mfmejbah * [email protected] * * INCSEQ.cpp * Date: 25 Jan 2017 */ #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 3; int fenwick[51][N]; void update(int k, int idx, int val) { while (idx < N) { fenwick[k][idx] += val; if (fenwick[k][idx] >= 5000000) fenwick[k][idx] -= 5000000; idx += idx & -idx; } } int read(int k, int idx) { int sum = 0; while (idx > 0) { sum += fenwick[k][idx]; if (sum >= 5000000) sum -= 5000000; idx -= idx & -idx; } return sum; } int main() { //memset(fenwick, 0, sizeof fenwick); int n, k, x; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &x); x++; update(1, x, 1); for (int j = 2; j <= k; j++) update(j, x, read(j - 1, x - 1)); } printf("%d\n", read(k, N - 1)); }
a30ed5cc5e134e3e610e23fb91bd62d440efa105
b35b6032868edc7ca74ce927676205aa217480cd
/Builder/src/Application.cpp
51f48bfeb500e8a26e38758d059ed72f7cba89ec
[]
no_license
drewProgram/design-patterns-cpp
c59bab39e8ce8a04d6fa91c1312892bad0a8422b
cb556374d7692f632dc7cee63c4f70e94380da9a
refs/heads/main
2023-06-25T05:04:52.211887
2021-07-29T17:26:59
2021-07-29T17:26:59
375,843,877
0
0
null
null
null
null
UTF-8
C++
false
false
1,030
cpp
#include <iostream> #include "Director.h" #include "ConcreteBuilder1.h" /** * The client code creates a builder object, passes it to the director * and then initiates the construction process. The end result is * retrieved from the builder object. * * It has been used raw pointer for simplicity but it may be better * to use smart pointers here. */ // TODO: check smart pointer implementation here. void ClientCode(Director& director) { ConcreteBuilder1* builder = new ConcreteBuilder1(); director.SetBuilder(builder); std::cout << "Standard basic product:" << std::endl; director.BuildMinimalViableProduct(); Product1* p = builder->GetProduct(); p->ListParts(); delete p; std::cout << "Standard full featured product:" << std::endl; director.BuildFullFeaturedProduct(); p = builder->GetProduct(); p->ListParts(); delete p; delete builder; } int main() { std::cout << "BUILDER PATTERN!!\n" << std::endl; Director* director = new Director(); ClientCode(*director); delete director; return 0; }
305195f92a215c417bd136a58cc37a86c16f312a
592699556860534d1588413f360d06d3a2423e2a
/course_work/client/notice.cpp
86ddefe67902693f118f77d207f10fc3b4e2f774
[]
no_license
Pcheeela/OOP_labs
bc5125786188cd9d1440749e80446ce1be385542
3b5b031785b171578fc03d69eceb7af340adb6f2
refs/heads/master
2023-06-25T05:22:02.662214
2021-07-31T23:07:39
2021-07-31T23:07:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,355
cpp
#include "notice.hpp" #include <QPainter> #include <QApplication> #include <QScreen> #include <QDebug> Notice::Notice(QWidget *parent) : QWidget(parent) { setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint); setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_ShowWithoutActivating); animation.setTargetObject(this); animation.setPropertyName("popupOpacity"); connect(&animation, &QAbstractAnimation::finished, this, &Notice::hide); label.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); label.setStyleSheet("QLabel {" "color: white;" "margin-top: 3px;" "margin-bottom: 3px;" "margin-left: 6px;" "margin-right: 6px;}"); layout.addWidget(&label, 0, 0); setLayout(&layout); timer = new QTimer(); connect(timer, &QTimer::timeout, this, &Notice::hideAnimation); } void Notice::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QRect roundedRect; roundedRect.setX(rect().x() + 5); roundedRect.setY(rect().y() + 5); roundedRect.setWidth(rect().width() - 10); roundedRect.setHeight(rect().height() - 10); painter.setBrush(QBrush(notice_color_)); painter.setPen(Qt::NoPen); painter.drawRoundedRect(roundedRect, 10, 10); } void Notice::setProperties(const QColor& notice_color, const QString &text) { notice_color_ = notice_color; label.setText(text); adjustSize(); } void Notice::show() { setWindowOpacity(0.0); animation.setDuration(150); animation.setStartValue(0.0); animation.setEndValue(1.0); setFixedSize(width(), height()); QWidget::show(); animation.start(); timer->start(1500); } void Notice::hideAnimation() { timer->stop(); animation.setDuration(1000); animation.setStartValue(1.0); animation.setEndValue(0.0); animation.start(); } void Notice::hide() { if(getPopupOpacity() == 0.0){ QWidget::hide(); } } void Notice::setPopupOpacity(float opacity) { popupOpacity = opacity; setWindowOpacity(opacity); } float Notice::getPopupOpacity() const { return popupOpacity; }
7f528f6ce2d4841ea7cdc12d98cfe2a07e0f6e5d
3ee9a41b8b2c101857453cee06ad279724732393
/daemon/mcbp_privileges.h
4eb616d73dc02f79a3d56b87371246298c0c3c8b
[]
no_license
Chippiewill/memcached
76882847595c36165fe9008c4b182c678e2be954
d4fb440eb15cdaa4b780c179c1c97d1a4061517d
refs/heads/master
2021-01-21T00:52:40.043733
2016-12-02T12:56:15
2016-12-02T13:01:52
50,431,966
0
0
null
2016-01-26T13:56:58
2016-01-26T13:56:57
null
UTF-8
C++
false
false
2,612
h
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2016 Couchbase, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <array> #include <memcached/protocol_binary.h> #include <memcached/privileges.h> #include "cookie.h" #include "function_chain.h" /** * The MCBP privilege chains. * * This class contains the privilege chains for each of the specified * opcodes to allow for a first defence to deny connections access to * certain commands. The implementation of certain commands may perform * additional checks. */ class McbpPrivilegeChains { public: McbpPrivilegeChains(); McbpPrivilegeChains(const McbpPrivilegeChains&) = delete; /** * Invoke the chain for the command. If no rule is set up for the command * we should fail the request (That would most likely help us not forget * to add new rules when people add new commands ;-)) * * @param command the opcode of the command to check access for * @param cookie the cookie representing the connection / command * @return Ok - the connection holds the appropriate privilege * Fail - the connection does not hold the privileges needed * Stale - the authentication context is out of date */ PrivilegeAccess invoke(protocol_binary_command command, const Cookie& cookie) { auto& chain = commandChains[command]; if (chain.empty()) { return PrivilegeAccess::Fail; } else { return chain.invoke(cookie); } } protected: /* * Silently ignores any attempt to push the same function onto the chain. */ void setup(protocol_binary_command command, PrivilegeAccess(* f)(const Cookie&)) { commandChains[command].push_unique(makeFunction<PrivilegeAccess, PrivilegeAccess::Ok, const Cookie&>(f)); } std::array<FunctionChain<PrivilegeAccess, PrivilegeAccess::Ok, const Cookie&>, 0x100> commandChains; };
d9e9d76a7287437a63e13421d0056e258d20d022
f81124e4a52878ceeb3e4b85afca44431ce68af2
/re20_2/processor47/5/p
4e51971a2cd8e0c344bc8f89cb34e96ea8c753d0
[]
no_license
chaseguy15/coe-of2
7f47a72987638e60fd7491ee1310ee6a153a5c10
dc09e8d5f172489eaa32610e08e1ee7fc665068c
refs/heads/master
2023-03-29T16:59:14.421456
2021-04-06T23:26:52
2021-04-06T23:26:52
355,040,336
0
1
null
null
null
null
UTF-8
C++
false
false
8,880
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "5"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 392 ( 0.00971632 0.00923145 0.00876031 0.00970691 0.00922285 0.00875246 0.0096881 0.00920567 0.00873677 0.00965992 0.00917993 0.00871324 0.0096224 0.00914566 0.00868193 0.0095756 0.00910291 0.00864285 0.00951957 0.00905171 0.00859605 0.00945438 0.00899214 0.00854159 0.00938011 0.00892427 0.00847953 0.00929687 0.00884818 0.00840993 0.00920475 0.00876396 0.00833289 0.00910387 0.00867171 0.00824847 0.00899436 0.00857153 0.00815679 0.00887636 0.00846355 0.00805794 0.00875001 0.00834789 0.00795203 0.00756476 0.00822468 0.00783919 0.0074614 0.00809404 0.00771951 0.00735173 0.00795602 0.00759304 0.0072358 0.00781099 0.0074601 0.00711391 0.00766024 0.00732186 0.00698714 0.00750354 0.00717805 0.00685515 0.00732957 0.00701819 0.00670828 0.00712681 0.00683203 0.00653747 0.00698952 0.0067077 0.00642471 0.0072788 0.00698067 0.00668013 0.00653322 0.00628813 0.00603762 0.00584835 0.00565062 0.0054447 0.00521467 0.00505961 0.00489381 0.00456054 0.00444815 0.00432263 0.00389356 0.00382332 0.00373774 0.0032227 0.00319356 0.00314704 0.00255123 0.00256196 0.00255346 0.00188218 0.0019314 0.00195974 0.0012186 0.00130482 0.00136867 0.000563242 0.000684857 0.000782808 -8.14232e-05 7.39201e-05 0.000204472 -0.000713197 -0.000525842 -0.000364241 -0.000225605 -0.00133012 -0.0011125 -0.000921437 -0.000754232 -0.00193049 -0.00168434 -0.00146542 -0.00127111 -0.00251278 -0.00223985 -0.00199468 -0.00177476 -0.00307573 -0.00277772 -0.00250789 -0.00226383 -0.00361821 -0.0032968 -0.0030039 -0.00273715 -0.00379614 -0.00348169 -0.00319371 -0.00427492 -0.00394041 -0.0036326 -0.00473245 -0.00437933 -0.00405307 -0.00516818 -0.00479784 -0.00445446 -0.00558167 -0.00519546 -0.00483623 -0.00597258 -0.00557177 -0.00519794 -0.00634064 -0.00592647 -0.0055392 -0.00668568 -0.00625929 -0.00585974 -0.00700756 -0.00657008 -0.00615931 -0.00730623 -0.00685869 -0.00643775 -0.00758164 -0.00712504 -0.00669491 -0.0078338 -0.0073691 -0.00693072 -0.00806274 -0.00759084 -0.0071451 -0.00826852 -0.00779026 -0.00733802 -0.0084512 -0.00796739 -0.00750947 -0.00861084 -0.00812226 -0.00765944 -0.00874751 -0.00825491 -0.00778795 -0.00886128 -0.00836537 -0.007895 -0.00895222 -0.00845368 -0.00798061 -0.00902037 -0.00851989 -0.00804481 -0.0090658 -0.00856403 -0.00808761 -0.00908846 -0.00858605 -0.00810897 0.00727883 0.00653325 0.00584838 0.0052147 0.00456057 0.00389359 0.00322272 0.00255126 0.0018822 0.00121862 0.000563262 -8.14042e-05 -0.000713179 -0.00133011 -0.00193047 -0.00251277 -0.00307572 -0.00361821 -0.00413932 -0.00463828 -0.00511448 -0.00556742 -0.00599674 -0.00640214 -0.00678344 -0.00714052 -0.00747333 -0.00778184 -0.0080661 -0.00832617 -0.00856213 -0.00877407 -0.00896211 -0.00912635 -0.0092669 -0.00938386 -0.00947731 -0.00954733 -0.009594 -0.00961727 0.00698069 0.00628816 0.00565064 0.00505963 0.00444817 0.00382335 0.00319358 0.00256199 0.00193143 0.00130484 0.000684875 7.39365e-05 -0.000525827 -0.00111249 -0.00168433 -0.00223984 -0.00277771 -0.0032968 -0.00379614 -0.00427492 -0.00473245 -0.00516818 -0.00558168 -0.00597259 -0.00634065 -0.00668569 -0.00700758 -0.00730624 -0.00758165 -0.00783381 -0.00806276 -0.00826854 -0.00845122 -0.00861086 -0.00874753 -0.0088613 -0.00895224 -0.0090204 -0.00906582 -0.00908849 0.00668015 0.00603764 0.00544472 0.00489383 0.00432265 0.00373777 0.00314706 0.00255348 0.00195976 0.00136868 0.000782823 0.000204486 -0.000364229 -0.000921426 -0.00146541 -0.00199467 -0.00250789 -0.00300389 -0.00348169 -0.00394041 -0.00437933 -0.00479785 -0.00519547 -0.00557178 -0.00592647 -0.0062593 -0.00657009 -0.0068587 -0.00712506 -0.00736911 -0.00759085 -0.00779028 -0.00796741 -0.00812228 -0.00825493 -0.00836539 -0.0084537 -0.00851991 -0.00856405 -0.00858607 0.00698955 0.00670773 0.00642474 0.00712684 0.00683206 0.0065375 0.0073296 0.00701821 0.0067083 0.00750357 0.00717808 0.00685518 0.00766027 0.00732189 0.00698716 0.00781102 0.00746012 0.00711394 0.00795605 0.00759306 0.00723583 0.00809406 0.00771954 0.00735175 0.00822471 0.00783922 0.00746142 0.00875003 0.00834791 0.00795205 0.00756478 0.00887638 0.00846357 0.00805795 0.00899438 0.00857155 0.00815681 0.00910389 0.00867173 0.00824849 0.00920477 0.00876398 0.0083329 0.00929689 0.0088482 0.00840995 0.00938013 0.00892429 0.00847954 0.00945439 0.00899215 0.0085416 0.00951958 0.00905172 0.00859606 0.00957561 0.00910291 0.00864285 0.00962241 0.00914567 0.00868193 0.00965993 0.00917994 0.00871325 0.00968811 0.00920568 0.00873677 0.00970691 0.00922285 0.00875246 0.00971632 0.00923145 0.00876031 ) ; boundaryField { inlet { type zeroGradient; } outlet { type fixedValue; value nonuniform 0(); } cylinder { type zeroGradient; } top { type symmetryPlane; } bottom { type symmetryPlane; } defaultFaces { type empty; } procBoundary47to46 { type processor; value nonuniform List<scalar> 131 ( 0.0102131 0.0102028 0.0101822 0.0101513 0.0101102 0.010059 0.00999765 0.00992629 0.00984502 0.00975394 0.00965318 0.00954287 0.00942315 0.00929418 0.00915614 0.00861548 0.00861548 0.00847288 0.00832229 0.00816411 0.00799974 0.00782901 0.00763978 0.00741909 0.00726733 0.00757121 0.00676954 0.00603452 0.00535557 0.00465635 0.00394499 0.00323101 0.00251787 0.00180871 0.00110672 0.000414742 -0.00026469 -0.000929343 -0.00157725 -0.0022067 -0.00281621 -0.00340453 -0.00397061 -0.00413932 -0.00413932 -0.00463828 -0.00511448 -0.00556742 -0.00599673 -0.00640213 -0.00678343 -0.00714051 -0.00747332 -0.00778183 -0.00806609 -0.00832615 -0.00856211 -0.00877405 -0.00896209 -0.00912633 -0.00926688 -0.00938383 -0.00947728 -0.00954731 -0.00959397 -0.00961725 0.00757124 0.00676957 0.00603455 0.0053556 0.00465638 0.00394502 0.00323104 0.0025179 0.00180874 0.00110674 0.000414766 -0.000264668 -0.000929323 -0.00157723 -0.00220668 -0.0028162 -0.00340452 -0.00397061 -0.00451358 -0.00503276 -0.00552757 -0.00599762 -0.00644259 -0.00686229 -0.0072566 -0.00762547 -0.00796893 -0.00828702 -0.00857986 -0.00884755 -0.00909025 -0.00930811 -0.00950128 -0.00966991 -0.00981415 -0.00993414 -0.01003 -0.0101018 -0.0101496 -0.0101735 0.00726736 0.00741912 0.00763981 0.00782904 0.00799977 0.00816414 0.00832232 0.0084729 0.0086155 0.0086155 0.00915616 0.0092942 0.00942317 0.00954289 0.0096532 0.00975396 0.00984503 0.0099263 0.00999766 0.010059 0.0101103 0.0101513 0.0101822 0.0102028 0.0102131 ) ; } procBoundary47to48 { type processor; value nonuniform List<scalar> 131 ( 0.00830439 0.00829722 0.00828287 0.00826136 0.00823273 0.00819699 0.00815419 0.00810438 0.00804761 0.00798394 0.00791344 0.00783618 0.00775225 0.00766175 0.00766175 0.00718769 0.00709296 0.00699243 0.00688614 0.00677437 0.00665808 0.00653693 0.00640202 0.00624537 0.00614295 0.00638003 0.00578453 0.00523351 0.00472026 0.00418701 0.00363987 0.0030862 0.00252878 0.0019702 0.00141313 0.000860022 0.000313097 0.000313097 -0.000107377 -0.00060839 -0.001099 -0.00157772 -0.00204325 -0.00249438 -0.0029301 -0.00334948 -0.00375172 -0.00413616 -0.00450221 -0.00484937 -0.00517723 -0.00548546 -0.00577379 -0.00604198 -0.00628988 -0.00651734 -0.00672427 -0.00691059 -0.00707626 -0.00722125 -0.00734553 -0.0074491 -0.00753195 -0.00759409 -0.00763552 -0.0076562 0.00638004 0.00578455 0.00523353 0.00472028 0.00418703 0.00363989 0.00308622 0.0025288 0.00197022 0.00141315 0.000860036 0.000313109 -0.000225594 -0.000754223 -0.00127111 -0.00177475 -0.00226382 -0.00273715 -0.00319371 -0.0036326 -0.00405307 -0.00445446 -0.00483624 -0.00519794 -0.00553921 -0.00585975 -0.00615933 -0.00643776 -0.00669493 -0.00693073 -0.00714511 -0.00733804 -0.00750949 -0.00765946 -0.00778797 -0.00789502 -0.00798063 -0.00804483 -0.00808763 -0.00810899 0.00614298 0.0062454 0.00640205 0.00653696 0.0066581 0.00677439 0.00688617 0.00699246 0.00709298 0.00718771 0.00766176 0.00766176 0.00775227 0.0078362 0.00791345 0.00798395 0.00804762 0.00810439 0.0081542 0.008197 0.00823273 0.00826137 0.00828287 0.00829722 0.0083044 ) ; } } // ************************************************************************* //
24e19bd89a91a53a3d583959b79f990b23871122
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
/source/graphics/fonttexturemanager.h
72ac5414a7438666723b298870d0ae48ebdb1559
[]
no_license
roxygen/maid2
230319e05d6d6e2f345eda4c4d9d430fae574422
455b6b57c4e08f3678948827d074385dbc6c3f58
refs/heads/master
2021-01-23T17:19:44.876818
2010-07-02T02:43:45
2010-07-02T02:43:45
38,671,921
0
0
null
null
null
null
UTF-8
C++
false
false
1,429
h
/*! @file @brief フォントテクスチャの管理クラス */ #ifndef maid2_graphics_fonttexturemanager_h #define maid2_graphics_fonttexturemanager_h #include"../config/define.h" #include"../auxiliary/cachemanager.h" #include"../auxiliary/globalpointer.h" #include"../graphics/core/ifontdevice.h" #include"surface.h" #include"graphicsobjecttemplate.h" #include"graphicscore.h" #include"texture2dbase.h" #include"font.h" #include<map> #include<boost/smart_ptr.hpp> namespace Maid { class FontTexture : public Texture2DBase , public GlobalPointer<GraphicsCore> { public: void Load( const Surface& surf ); void Destroy(); }; class FontTextureManager { public: FontTextureManager(); ~FontTextureManager(); void Initialize(); void Finalize(); const FontTexture& GetTexture( const Font& font, unt32 FontCode ); void ClearCache(); void SetCacheSize( int Size ); void Garbage(); private: //! 検索に使うキャッシュキー struct CACHEKEY { CACHEKEY(); CACHEKEY( const CACHEKEY& rha ); CACHEKEY( const Font& f, unt32 code ); const Font font; unt32 Code; bool operator < ( const CACHEKEY& rhs ) const; }; typedef CacheManager<CACHEKEY,FontTexture> CACHETABLE; CACHETABLE m_CacheTable; }; } #endif
51538df122f52280b0e81306ce8df7e3efd294a0
6a8aa0ea1c80926af82ee2292e6f5fc531f880ec
/plugins/experimental/inliner/html-parser.cc
ecd88fd4d14e648735bfdd7ed79c58868d13d0d2
[ "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-3-Clause", "TCL", "MIT", "HPND", "ISC", "BSD-2-Clause", "LicenseRef-scancode-unknown" ]
permissive
researchgate/trafficserver
5f98b6d0a07d9d2506d166b202a1c22a47d9fa24
4a6fb442a59d0784140f7d918774fcc2c73a80a1
refs/heads/master
2023-04-14T19:02:59.283546
2016-04-20T10:01:54
2016-04-20T10:01:54
56,670,862
0
1
Apache-2.0
2023-04-07T07:55:13
2016-04-20T08:45:31
C++
UTF-8
C++
false
false
7,508
cc
/** @file Inlines base64 images from the ATS cache @section license License Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <assert.h> #include <locale> #include <string> #include "html-parser.h" namespace ats { namespace inliner { Attributes::operator std::string(void) const { std::string result; for (Attributes::const_iterator item = begin(); item != end(); ++item) { if (!item->first.empty()) { if (!item->second.empty()) { result += item->first + "=\"" + item->second += "\" "; } else { result += item->first; } } } return result; } bool HtmlParser::parseTag(const char c) { switch (c) { case ' ': case '/': case '>': case '\b': case '\n': case '\r': case '\t': return tag_ == Tag::kTagIMG || tag_ == Tag::kTagLINK || tag_ == Tag::kTagSCRIPT || tag_ == Tag::kTagSTYLE; break; case 'R': case 'r': if (tag_ == Tag::kTagSC) { tag_ = Tag::kTagSCR; return false; } break; case 'C': case 'c': if (tag_ == Tag::kTagS) { tag_ = Tag::kTagSC; return false; } break; case 'S': case 's': if (tag_ == Tag::kTag) { tag_ = Tag::kTagS; return false; } break; case 'T': case 't': if (tag_ == Tag::kTagS) { tag_ = Tag::kTagST; return false; } else if (tag_ == Tag::kTagSCRIP) { tag_ = Tag::kTagSCRIPT; return false; } break; case 'I': case 'i': if (tag_ == Tag::kTag) { tag_ = Tag::kTagI; return false; } else if (tag_ == Tag::kTagSCR) { tag_ = Tag::kTagSCRI; return false; } else if (tag_ == Tag::kTagL) { tag_ = Tag::kTagLI; return false; } break; case 'P': case 'p': if (tag_ == Tag::kTagSCRI) { tag_ = Tag::kTagSCRIP; return false; } break; case 'Y': case 'y': if (tag_ == Tag::kTagST) { tag_ = Tag::kTagSTY; return false; } break; case 'L': case 'l': if (tag_ == Tag::kTag) { tag_ = Tag::kTagL; return false; } else if (tag_ == Tag::kTagSTY) { tag_ = Tag::kTagSTYL; return false; } break; case 'E': case 'e': if (tag_ == Tag::kTagSTYL) { tag_ = Tag::kTagSTYLE; return false; } break; case 'N': case 'n': if (tag_ == Tag::kTagLI) { tag_ = Tag::kTagLIN; return false; } break; case 'K': case 'k': if (tag_ == Tag::kTagLIN) { tag_ = Tag::kTagLINK; return false; } break; case 'M': case 'm': if (tag_ == Tag::kTagI) { tag_ = Tag::kTagIM; return false; } break; case 'G': case 'g': if (tag_ == Tag::kTagIM) { tag_ = Tag::kTagIMG; return false; } break; } tag_ = Tag::kTagInvalid; return false; } bool AttributeParser::parse(const char c) { switch (state_) { case Attribute::kPreName: if (isValidName(c)) { state_ = Attribute::kName; attributes.push_back(Pair()); attributes.back().first += c; } else if (c == '/' || c == '>') { return true; } break; case Attribute::kName: if (isValidName(c)) { attributes.back().first += c; } else if (c == '=') { state_ = Attribute::kPreValue; } else if (c == '/' || c == '>') { return true; } else { state_ = Attribute::kPostName; } break; case Attribute::kPostName: if (isValidName(c)) { state_ = Attribute::kName; attributes.push_back(Pair()); attributes.back().first += c; } else if (c == '=') { state_ = Attribute::kPreValue; } else if (c == '/' || c == '>') { return true; } break; case Attribute::kPreValue: // TODO(dmorilha) add the unquoted value. if (c == '\'') { state_ = Attribute::kSingleQuotedValue; } else if (c == '"') { state_ = Attribute::kDoubleQuotedValue; // VERY BROKEN SYNTAX } else if (c == '/' || c == '>') { return true; } else if (isValidValue(c)) { state_ = Attribute::kUnquotedValue; attributes.back().second += c; } break; case Attribute::kUnquotedValue: if (isValidValue(c)) { attributes.back().second += c; } else if (c == '/' || c == '>' || c == '"' || c == '\'') { return true; // space? } else { state_ = Attribute::kPreName; } break; case Attribute::kSingleQuotedValue: if (c == '\'') { state_ = Attribute::kPreName; } else { attributes.back().second += c; } break; case Attribute::kDoubleQuotedValue: if (c == '"') { state_ = Attribute::kPreName; } else { attributes.back().second += c; } break; default: assert(false); // UNREACHABLE; break; } return false; } size_t HtmlParser::parse(const char *b, size_t l, size_t o) { const char *const end = b + l, *c = b; size_t done = 0; for (; c != end; ++c) { if (state_ == State::kAttributes) { if (attributeParser_.parse(*c)) { switch (tag_) { case Tag::kTagIMG: handleImage(attributeParser_.attributes); attributeParser_.reset(); o += c - b; l -= c - b; b = c; break; default: break; } state_ = State::kTagBypass; } continue; } if (state_ == State::kTag) { if (parseTag(*c)) { state_ = State::kAttributes; attributeParser_.reset(); const size_t p = c - b; if (p > 0 && tag_ == Tag::kTagIMG) { done += bypass(p, o); o += p; l -= p; b = c; } } else if (tag_ == Tag::kTagInvalid) { state_ = State::kTagBypass; } continue; } if (state_ == State::kTagBypass) { if (*c == '>') { state_ = State::kUndefined; } continue; } if (state_ == State::kUndefined) { if (*c == '<') { state_ = State::kTag; tag_ = Tag::kTag; } continue; } } if (l > 0 && (state_ != State::kAttributes || tag_ != Tag::kTagIMG)) { done += bypass(l, o); } return done; } } // end of inliner namespace } // end of ats namespace
31cd9540437cd66e45f8ebdb0ce4aad36f0125ee
208fa772d426c4665f458813537fb110be490e82
/other_misc_codebender_files/codebender_files/smart_software_project_week11_lab1v1/smart_car_movement.cpp
e9e4d063a14fd1e6c136973c5417afe6a7a02d69
[]
no_license
KoreaHaos/code_bender_cleanup_2016
1d0cc76b2ea1886157309df9fe675ac4b93cb413
a2d69684f453c9ad05ac56c8522c95b0362a2cbd
refs/heads/master
2021-01-09T20:23:24.494343
2016-06-09T21:57:06
2016-06-09T21:57:06
60,807,939
0
0
null
null
null
null
UTF-8
C++
false
false
5,038
cpp
/* ToDo: Mod this to be more OO. ToDo: Create getters and setters for motor speed. ToDo: Create getter for ms since last motion? ToDo: Figure out if the variables can be declared in the header file and then set either in the setup function or by getter/setters. */ #include "Arduino.h" #define LEFT_MD_A 22 #define LEFT_MD_B 23 #define RIGHT_MD_A 24 #define RIGHT_MD_B 25 #define LEFT_MOTOR_EN 4 #define RIGHT_MOTOR_EN 5 // This function needs to be called during setup of IC. void setup_ports_for_movement() { pinMode(LEFT_MD_A, OUTPUT); pinMode(LEFT_MD_B, OUTPUT); pinMode(RIGHT_MD_A, OUTPUT); pinMode(RIGHT_MD_B, OUTPUT); pinMode(LEFT_MOTOR_EN, OUTPUT); pinMode(RIGHT_MOTOR_EN, OUTPUT); // Set everything to be off. digitalWrite(LEFT_MD_A, LOW); digitalWrite(LEFT_MD_B, LOW); digitalWrite(RIGHT_MD_A, LOW); digitalWrite(RIGHT_MD_B, LOW); digitalWrite(LEFT_MOTOR_EN, LOW); digitalWrite(RIGHT_MOTOR_EN, LOW); } void move_forward() { // Setup pin output to rotate counterclockwise for left motor. digitalWrite(LEFT_MD_A, HIGH); digitalWrite(LEFT_MD_B, LOW); // Setup pin output to rotate clockwise for right motor digitalWrite(RIGHT_MD_A, LOW); digitalWrite(RIGHT_MD_B, HIGH); // Turn both motors on. analogWrite(LEFT_MOTOR_EN, 100); analogWrite(RIGHT_MOTOR_EN, 100); } void move_backward() { // Setup pin output to rotate clockwise for left motor digitalWrite(LEFT_MD_A, LOW); digitalWrite(LEFT_MD_B, HIGH); // Setup pin output to rotate counterclockwise for right motor digitalWrite(RIGHT_MD_A, HIGH); digitalWrite(RIGHT_MD_B, LOW); // Turn both motors on. analogWrite(LEFT_MOTOR_EN, 100); analogWrite(RIGHT_MOTOR_EN, 100); } void turn_left() { //Rotate clockwise for right motor //Setup pin output to rotate right motor clockwise. digitalWrite(RIGHT_MD_A, LOW); digitalWrite(RIGHT_MD_B, HIGH); // Turn on right motor and turn off left motor. analogWrite(LEFT_MOTOR_EN,0); analogWrite(RIGHT_MOTOR_EN, 150); } void turn_right() { //Setup pin output to rotate left motor counterclockwise. digitalWrite(LEFT_MD_A, HIGH); digitalWrite(LEFT_MD_B, LOW); // Turn on left motor and turn off right motor. analogWrite(LEFT_MOTOR_EN, 150); analogWrite(RIGHT_MOTOR_EN,0); } void move_stop() { // Turn off both motors. analogWrite(LEFT_MOTOR_EN, 0); analogWrite(RIGHT_MOTOR_EN, 0); } boolean left_wheels_are_moving_forward = true; boolean right_wheels_are_moving_forward = true; void move_car_for_line_tracing(int left, int right) { /* if (left < 0 && ! left_wheels_are_moving_forward) { move_stop(); delay(500); } */ if (left >= 0 && right >= 0) { // Setup pin output to rotate counterclockwise for left motor. digitalWrite(LEFT_MD_A, HIGH); digitalWrite(LEFT_MD_B, LOW); // Setup pin output to rotate clockwise for right motor digitalWrite(RIGHT_MD_A, LOW); digitalWrite(RIGHT_MD_B, HIGH); } else if (left < 0 && right >= 0) { // Setup pin output to rotate counterclockwise for left motor. digitalWrite(LEFT_MD_A, HIGH); digitalWrite(LEFT_MD_B, LOW); // Setup pin output to rotate counterclockwise for right motor digitalWrite(RIGHT_MD_A, HIGH); digitalWrite(RIGHT_MD_B, LOW); right = abs(right); } else if (left >= 0 && right < 0) { // Setup pin output to rotate clockwise for left motor. digitalWrite(LEFT_MD_A, LOW); digitalWrite(LEFT_MD_B, HIGH); left = abs(left); // Setup pin output to rotate clockwise for right motor digitalWrite(RIGHT_MD_A, LOW); digitalWrite(RIGHT_MD_B, HIGH); } else { // Setup pin output to rotate clockwise for left motor. digitalWrite(LEFT_MD_A, LOW); digitalWrite(LEFT_MD_B, HIGH); // Setup pin output to rotate counterclockwise for right motor digitalWrite(RIGHT_MD_A, HIGH); digitalWrite(RIGHT_MD_B, LOW); right = abs(right); left = abs(left); } // Turn both motors on. analogWrite(LEFT_MOTOR_EN, left); analogWrite(RIGHT_MOTOR_EN, right); } void move_forward_speed(int left, int right) { move_car_for_line_tracing(left, right); } void turn_left_speed(int left, int right) { move_car_for_line_tracing(left, right); // turn_left(); } void turn_right_speed(int left, int right) { move_car_for_line_tracing(left, right); //turn_right(); } void turn_pivot_left_speed(int left, int right) { move_car_for_line_tracing(left, right); //turn_left(); } void turn_pivot_right_speed(int left, int right) { move_car_for_line_tracing(left, right); //turn_right(); }
ca12301afe7ba2876c9ea952a2a588cc93895193
910317f6edbc13556b90c7646ecd8e0b932fc8f6
/gc_pointer.h
6b98439f2590eb5381b0398a808ef7fea892134a
[]
no_license
lazarus432/garbage-collector
8be0755f7090d5d2c6b1ed961546b1cf1dabf27d
0ec03bd90400e85335483289344e64db9856129e
refs/heads/master
2020-06-19T15:32:29.130540
2019-07-23T00:21:12
2019-07-23T00:21:12
196,764,899
0
0
null
null
null
null
UTF-8
C++
false
false
6,471
h
#ifndef GC_POINTER_H #define GC_POINTER_H #include <iostream> #include <list> #include <typeinfo> #include <cstdlib> #include "gc_details.h" #include "gc_iterator.h" using namespace std; template <class T, int size = 0> class Pointer{ private: // refContainer maintains the garbage collection list. static list<PtrDetails<T>> refContainer; T *addr = nullptr; bool is_array = false; unsigned array_size = 0; static bool first; typename list<PtrDetails<T>>::iterator findPtrInfo(T *ptr); public: // Define an iterator type for Pointer<T>. typedef Iter<T> GCiterator; Pointer(){ Pointer(NULL); } Pointer(T*); Pointer(const Pointer &); ~Pointer(); // Collect garbage. Returns true if at least // one object was freed. static bool collect(); T* operator=(T *t); // Overload assignment of Pointer to Pointer. Pointer &operator=(Pointer &rv); // Return a reference to the object pointed to by this Pointer. T& operator*(){ return *addr; } // Return the address being pointed to. T* operator->() { return addr; } // Return a reference to the object at the // index specified by i. T& operator[](int i){ return addr[i];} // Conversion function to T *. operator T *() { return addr; } // Return an Iter to the start of the allocated memory. Iter<T> begin(){ int _size; if (is_array) { _size = array_size; } else { _size = 1; } return Iter<T>(addr, addr, addr + _size); } // Return an Iter to one past the end of an allocated array. Iter<T> end(){ int _size; if (is_array) { _size = array_size; } else { _size = 1; } return Iter<T>(addr + _size, addr, addr + _size); } // Return the size of refContainer for this type of Pointer. static int refContainerSize() { return refContainer.size(); } // A utility function that displays refContainer. static void showlist(); // Clear refContainer when program exits. static void shutdown(); }; // STATIC INITIALIZATION // Creates storage for the static variables template <class T, int size> list<PtrDetails<T>> Pointer<T, size>::refContainer; template <class T, int size> bool Pointer<T, size>::first = true; // Constructor for both initialized and uninitialized objects. -> see class interface template<class T,int size> Pointer<T,size>::Pointer(T *t){ // Register shutdown() as an exit function. if (first) atexit(shutdown); first = false; typename list<PtrDetails<T>>::iterator p = findPtrInfo(t); if(p == refContainer.end()) { PtrDetails<T> newPtr(t, size); if(size > 0) { is_array = true; array_size = size; } refContainer.push_back(newPtr); } else { p->ref_count++; } this->addr = t; } // Copy constructor. template< class T, int size> Pointer<T,size>::Pointer(const Pointer &ob) { typename list<PtrDetails<T>>::iterator p = findPtrInfo(ob.addr); p->ref_count++; this->is_array = ob.is_array; this->array_size = ob.array_size; this->addr = ob.addr; } // Destructor for Pointer. template <class T, int size> Pointer<T, size>::~Pointer() { typename list<PtrDetails<T>>::iterator p = findPtrInfo(addr); p->ref_count--; if(p->ref_count == 0)collect(); } // Collect garbage. Returns true if at least // one object was freed. template <class T, int size> bool Pointer<T, size>::collect(){ bool memFreed = false; typename list<PtrDetails<T>>::iterator p = refContainer.begin(); do { for(; p != refContainer.end(); p++){ if(p->ref_count > 0)continue; if(p->mem_ptr) { if(p->is_array){ delete[] p->mem_ptr; } else delete p->mem_ptr; refContainer.erase(p--); } } } while (p != refContainer.end()); return memFreed; } // Overload assignment of pointer to Pointer. template <class T, int size> T* Pointer<T, size>::operator=(T *t){ typename list<PtrDetails<T>>::iterator p = findPtrInfo(addr); p->ref_count--; if(p->ref_count == 0) collect(); p = findPtrInfo(t); if (p == refContainer.end()){ PtrDetails<T> newPtr(t, size); refContainer.push_back(newPtr); } else { p->ref_count++; } if (size > 0) { is_array = true; array_size = size; } this->addr = t; return addr; } // Overload assignment of Pointer to Pointer. template <class T, int size> Pointer<T, size> &Pointer<T, size>::operator=(Pointer &rv){ if (*this == rv) { return *this; } typename list<PtrDetails<T>>::iterator p = findPtrInfo(addr); p->ref_count--; if (p->ref_count == 0) { collect(); } p = findPtrInfo(rv.addr); p->ref_count++; this->addr = rv.addr; this->is_array = rv.is_array; this->array_size = rv.array_size; return *this; } // A utility function that displays refContainer. template <class T, int size> void Pointer<T, size>::showlist(){ typename list<PtrDetails<T> >::iterator p; cout << "refContainer<" << typeid(T).name() << ", " << size << ">:\n"; cout << "mem_ptr ref_count value\n "; if (refContainer.begin() == refContainer.end()) { cout << " Container is empty!\n\n "; } for (p = refContainer.begin(); p != refContainer.end(); p++) { cout << "[" << (void *)p->mem_ptr << "]" << " " << p->ref_count << " "; if (p->mem_ptr) cout << " " << *p->mem_ptr; else cout << "---"; cout << endl; } cout << endl; } // Find a pointer in refContainer. template <class T, int size> typename list<PtrDetails<T>>::iterator Pointer<T, size>::findPtrInfo(T *ptr){ typename list<PtrDetails<T>>::iterator p; for (p = refContainer.begin(); p != refContainer.end(); p++) if (p->mem_ptr == ptr) return p; return p; } // Clear refContainer when program exits. template <class T, int size> void Pointer<T, size>::shutdown(){ if (refContainerSize() == 0) return; // list is empty typename list<PtrDetails<T> >::iterator p; for (p = refContainer.begin(); p != refContainer.end(); p++){ // Set all reference counts to zero p->ref_count = 0; } collect(); } #endif
786e1b9307b6489117420d9d72027918b6bc2b8a
3e5ae9b260b16fcc86bb0669c1bd4e56912b5433
/VCB600ENU1/MSDN_VCB/SAMPLES/VC98/ATL/ATLTANGRAM/MFCTANGRAM/MAINFRM.CPP
8f93141a2e95dc81b7f5df3d17676f6408241ba1
[]
no_license
briancpark/deitel-cpp
e8612c7011c9d9d748290419ae2708d2f3f11543
90cdae5661718e65ab945bcf45fe6adff30c1e10
refs/heads/main
2023-06-14T14:07:05.497253
2021-07-05T01:46:04
2021-07-05T01:46:04
382,984,213
0
0
null
null
null
null
UTF-8
C++
false
false
14,401
cpp
// MainFrm.cpp : implementation of the CMFCMainFrame class // // This is a part of the Active Template Library. // Copyright (C) 1996-1998 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Active Template Library Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Active Template Library product. #include "stdafx.h" #include "MFCTangram.h" #include "MainFrm.h" #include "MFCTangramConfigDlg.h" #include "objbase.h" #include <oleauto.h> #include <stdlib.h> //for rand() #include <time.h> // Interface definitions. #include "ATLModel.h" #include "ATLModel_i.c" #include "AtlTangramCanvas.h" #include "AtlTangramCanvas_i.c" #include "AtlGdiWorld_i.c" #include "AtlGdiWorld.h" #include "AtlGLWorld.h" #include "AtlGLWorld_i.c" // Others #include "util.h" #include "util.cpp" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif const int POLYGONS = 7; /////////////////////////////////////////////////////////// // // Statics // CString CMFCMainFrame::s_strClassName = "" ; ///////////////////////////////////////////////////////////////////////////// // CMFCMainFrame BEGIN_MESSAGE_MAP(CMFCMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMFCMainFrame) ON_WM_CREATE() ON_WM_PAINT() ON_WM_MOUSEMOVE() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_RBUTTONDOWN() ON_WM_RBUTTONUP() ON_WM_PALETTECHANGED() ON_WM_QUERYNEWPALETTE() ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMFCMainFrame construction/destruction /////////////////////////////////////////////////////////// // // Constructor // CMFCMainFrame::CMFCMainFrame() : m_pWorld(NULL), m_pSelectedVisual(NULL) { m_sizedDiff.cx = 0.0 ; m_sizedDiff.cy = 0.0 ; } /////////////////////////////////////////////////////////// // // Destructor // CMFCMainFrame::~CMFCMainFrame() { if (m_pWorld != NULL) { m_pWorld->Release() ; } POSITION pos = m_ModelList.GetHeadPosition(); while( pos != NULL ) { IATLTangramModel* pITangramModel = m_ModelList.GetNext( pos ) ; pITangramModel->Release(); m_ModelList.RemoveHead(); } m_ModelList.RemoveAll(); /**/ } int CMFCMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) { TRACE0("Could not create main window.\r\n") ; return -1; } // Initialize CRect aRect ; GetClientRect(&aRect) ; if (!Initialize(aRect.Width(), aRect.Height())) { TRACE0("Cannot initialize main window.\r\n") ; return -1 ; } return 0; } BOOL CMFCMainFrame::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CFrameWnd::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CMFCMainFrame diagnostics #ifdef _DEBUG void CMFCMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMFCMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG /////////////////////////////////////////////////////////// // // Initialize // BOOL CMFCMainFrame::Initialize(int cx, int cy) { ASSERT( (cx != 0) && (cy != 0)) ; // Which components are in the IWorldComponent Category. CMFCTangramConfigDlg dlg; if (dlg.DoModal() != IDOK) { TRACE0("User canceled the dialog box. Fail initialization.\r\n") ; return FALSE ; } // Did the user want to use local or inproc? DWORD clsctx = (dlg.m_bLocalModel) ? CLSCTX_LOCAL_SERVER : CLSCTX_INPROC_SERVER ; // Create the desired world selected component. HRESULT hr = ::CoCreateInstance( dlg.m_clsid, // either Gdi or GL NULL, CLSCTX_INPROC_SERVER, IID_IAtlTangramWorld, reinterpret_cast<void**>(&m_pWorld)) ; if (FAILED(hr)) { ErrorMessage("Failed to create the world component.", hr) ; return FALSE ; } // Initialize the world. hr = m_pWorld->Initialize(m_hWnd, 20.0, 20.0) ; if (FAILED(hr)) { ErrorMessage("Cannot initialize World.\r\n", hr) ; m_pWorld->Release() ; m_pWorld = NULL ; return FALSE ; } // Create and initialize the tangrams pieces. struct PolygonInit{ int iSides ; TangramPoint2d points[4] ; }; PolygonInit polygons[7] = { // Sides Vertex 0 1 2 3 { 4, {{0.0, 0.0 }, {1.0, 0.0 }, {1.0, 1.0 }, {0.0, 1.0 }} }, // Square { 3, {{0.0, 0.0 }, {1.0, 0.0 }, {0.0, 1.0 }, {9.9, 9.9 }} }, // Small Triangle { 3, {{0.0, 0.0 }, {1.0, 0.0 }, {0.0, 1.0 }, {9.9, 9.9 }} }, // Small Triangle { 3, {{0.0, 0.0 }, {2.0, 0.0 }, {1.0, 1.0 }, {9.9, 9.9 }} }, // Medium Triangle { 3, {{0.0, 0.0 }, {2.0, 0.0 }, {0.0, 2.0 }, {9.9, 9.9 }} }, // Big Triangle { 3, {{0.0, 0.0 }, {2.0, 0.0 }, {0.0, 2.0 }, {9.9, 9.9 }} }, // Big Triangle { 4, {{0.0, 0.0 }, {1.0, 0.0 }, {2.0, 1.0 }, {1.0, 1.0 }} }, // Paralelagram }; double x = 0.0 ; IATLTangramModel* pITangramModel = NULL ; for (int i = 0 ; i < POLYGONS ; i ++) { hr = ::CoCreateInstance(CLSID_ATLTangramModel, NULL, clsctx , IID_IATLTangramModel, (void**)&pITangramModel); if (FAILED(hr)) { ErrorMessage("Failed to create Tangram piece.", hr) ; return FALSE ; } // Set the vertices for this model. hr = pITangramModel->SetVertices(polygons[i].iSides, polygons[i].points) ; ASSERT_HRESULT(hr) ; // Add the interface to the array. // This makes a copy of the pointer without // an AddRef(), so we don't have to Release() the // model m_ModelList.AddTail(pITangramModel) ; hr = m_pWorld->CreateVisualForModel(pITangramModel) ; ASSERT_HRESULT(hr) ; // Get the IATLTangramTransform interface. IATLTangramTransform* pITangramTransform = NULL ; HRESULT hr = pITangramModel->QueryInterface(IID_IATLTangramTransform, (void**)&pITangramTransform ) ; ASSERT_HRESULT(hr) ; // Place the tangram piece. pITangramTransform->Translate(x, 1.0) ; x += 2.0 ; // We are done with IATLTangramTransform. pITangramTransform->Release() ; } return TRUE ; } /////////////////////////////////////////////////////////// // // Create - Helper function for creating the window class // and window. // BOOL CMFCMainFrame::Create() { if (s_strClassName.IsEmpty()) { s_strClassName = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, AfxGetApp()->LoadStandardCursor(IDC_ARROW), 0, AfxGetApp()->LoadIcon(IDR_MAINFRAME)); } // Set screen size. CClientDC dc(NULL) ; int cx = 640 ; int cy = 480 ; return CWnd::CreateEx( 0, s_strClassName, AfxGetAppName(), WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU| WS_BORDER|WS_MINIMIZEBOX|WS_VISIBLE, 0,0, cx, cy, NULL, NULL); } /////////////////////////////////////////////////////////// // // OnPaint // void CMFCMainFrame::OnPaint() { CPaintDC dc(this); // Get ICanvas interface pointer. IAtlTangramCanvas* pCanvas = NULL ; HRESULT hr = m_pWorld->QueryInterface(IID_IAtlTangramCanvas, (void**)&pCanvas) ; ASSERT_HRESULT(hr) ; // Use it. hr = pCanvas->Paint(dc.m_hDC, dc.m_ps.rcPaint) ; ASSERT_HRESULT(hr) ; // Lose it. pCanvas->Release() ; } /////////////////////////////////////////////////////////// // // Handle both left and right button down messages. // void CMFCMainFrame::DoButtonDown(UINT nWhichButton, CPoint point) { if (m_pSelectedVisual != NULL) { // User may have pressed right button then left button. TRACE0("OnLButtonDown: Visual already selected.\r\n") ; return ; } HRESULT hr = m_pWorld->VisualFromPoint(point, IID_IAtlTangramVisual, (IUnknown**)&m_pSelectedVisual) ; //@ ASSERT(SUCCEEDED(hr)) ; if (hr == S_OK) { ASSERT(m_pSelectedVisual != NULL) ; // // Get mouse pointer offset from model's origin. // // Convert to Model Coordinates. TangramPoint2d ptModel ; hr = m_pWorld->DeviceToModel(point, &ptModel); ASSERT_HRESULT(hr) ; // Get the Model's ITrangramTransform interface. IATLTangramTransform* pITangramTransform = NULL ; hr = m_pSelectedVisual->GetModel(IID_IATLTangramTransform, (IUnknown**)&pITangramTransform) ; ASSERT_HRESULT(hr) ; // Where does the model reside. TangramPoint2d ptOrigin ; hr = pITangramTransform->GetTranslation(&ptOrigin) ; ASSERT_HRESULT(hr) ; // Release ITangramTransfrom. pITangramTransform->Release() ; pITangramTransform = NULL ; // Get difference between where the mouse clicked and the origin of the piece. m_sizedDiff.cx = ptModel.x - ptOrigin.x ; m_sizedDiff.cy = ptModel.y - ptOrigin.y ; // Select the visual. hr = m_pWorld->SelectVisual(m_pSelectedVisual, TRUE) ; ASSERT_HRESULT(hr) ; // Update the display hr = m_pWorld->Animate() ; ASSERT_HRESULT(hr) ; // Capture the mouse. SetCapture() ; } else { TRACE0("DoButtonDown: PtInVisual returned Null.\r\n") ; } } void CMFCMainFrame::PostNcDestroy() { delete this; } /////////////////////////////////////////////////////////// // // OnLButtonDown Message Handler // void CMFCMainFrame::OnLButtonDown(UINT nWhichButton, CPoint point) { DoButtonDown(nWhichButton, point) ; } /////////////////////////////////////////////////////////// // // OnLButtonUp Message Handler // void CMFCMainFrame::OnLButtonUp(UINT nWhichButton, CPoint point) { if (::GetCapture() != m_hWnd) { return ; } if (m_pSelectedVisual != NULL) { // De-select the currently selected model. HRESULT hr = m_pWorld->SelectVisual(m_pSelectedVisual, FALSE) ; ASSERT_HRESULT(hr) ; // Cleanup m_pSelectedVisual->Release() ; m_pSelectedVisual = NULL ; } // We don't need the mouse capture any more. ::ReleaseCapture() ; } /////////////////////////////////////////////////////////// // // OnMouseMove Message Handler // void CMFCMainFrame::OnMouseMove(UINT nWhichButton, CPoint point) { if ((::GetCapture() != m_hWnd) || (nWhichButton & (MK_SHIFT | MK_CONTROL))) { // Return if another window has captured the mouse or // if the SHIFT or CTRL key is pressed, signaling rotation. return ; } // Make sure that mouse is not outside of our client area. CRect rectClient ; GetClientRect(&rectClient) ; if (!rectClient.PtInRect(point)) { return ; } ASSERT(m_pSelectedVisual != NULL) ; // Convert to Model Coordinates. TangramPoint2d ptModel ; HRESULT hr = m_pWorld->DeviceToModel(point, &ptModel); ASSERT_HRESULT(hr) ; //Get the Model's ITangramTransfrom interface. IATLTangramTransform* pITangramTransform = NULL ; hr = m_pSelectedVisual->GetModel(IID_IATLTangramTransform, (IUnknown**)&pITangramTransform) ; ASSERT_HRESULT(hr) ; // Move the model. hr = pITangramTransform->Translate(ptModel.x - m_sizedDiff.cx, ptModel.y - m_sizedDiff.cy); ASSERT_HRESULT(hr) ; // Release the interface. pITangramTransform->Release() ; } /////////////////////////////////////////////////////////// // // Rotate using the right mouse button. // void CMFCMainFrame::OnRButtonDown(UINT nWhichButton, CPoint point) { DoButtonDown(nWhichButton, point) ; } /////////////////////////////////////////////////////////// // // Rotate the model. Shift key determines direction. // void CMFCMainFrame::OnRButtonUp(UINT nWhichButton, CPoint point) { if (::GetCapture() != m_hWnd) { return ; } if (m_pSelectedVisual != NULL) { //----- Rotate the shape. ----- // Check to see of the mouse pointer is still over the same visual. IAtlTangramVisual* pSameVisual = NULL ; HRESULT hr = m_pWorld->VisualFromPoint(point, IID_IAtlTangramVisual, (IUnknown**)&pSameVisual) ; ASSERT_HRESULT(hr) ; ASSERT(pSameVisual != NULL) ; if (::InterfacesAreOnSameComponent(m_pSelectedVisual, pSameVisual)) { //Get the Model's IATLTangramTransform interface. IATLTangramTransform* pITangramTransform = NULL ; hr = m_pSelectedVisual->GetModel(IID_IATLTangramTransform, (IUnknown**)&pITangramTransform); ASSERT_HRESULT(hr) ; // Rotate the model. int iRotationDirection = (nWhichButton & MK_SHIFT) ? -1 : 1 ; double dDegrees ; pITangramTransform->GetRotation(&dDegrees) ; pITangramTransform->Rotate(dDegrees + 45.0*iRotationDirection); // Release IATLTangramTransform pITangramTransform->Release() ; pITangramTransform = NULL ; } // Cleanup pSameVisual->Release() ; pSameVisual = NULL ; // De-select the currently selected model. hr = m_pWorld->SelectVisual(m_pSelectedVisual, FALSE) ; ASSERT_HRESULT(hr) ; // Cleanup m_pSelectedVisual->Release() ; m_pSelectedVisual = NULL ; } // We don't need the mouse capture any more. ::ReleaseCapture() ; } /////////////////////////////////////////////////////////// // // OnPaletteChanged Message Handler // void CMFCMainFrame::OnPaletteChanged(CWnd* pFocusWnd) { if (pFocusWnd != this) { OnQueryNewPalette() ; } } /////////////////////////////////////////////////////////// // // QueryNewPalette Message Handler // BOOL CMFCMainFrame::OnQueryNewPalette() { if (m_hWnd == NULL) { return FALSE ; } // Get ICanvas interface pointer. IAtlTangramCanvas* pCanvas = NULL ; HRESULT hr = m_pWorld->QueryInterface(IID_IAtlTangramCanvas, (void**)&pCanvas) ; if (SUCCEEDED(hr)) { // Use it. hr = pCanvas->OnQueryNewPalette(m_hWnd); // Lose it. pCanvas->Release() ; } return SUCCEEDED(hr); } void CMFCMainFrame::OnDestroy() { CFrameWnd::OnDestroy(); /* POSITION pos = m_ModelList.GetHeadPosition(); while( pos != NULL ) { IATLTangramModel* pITangramModel = m_ModelList.GetNext( pos ) ; pITangramModel->Release(); m_ModelList.RemoveHead(); } m_ModelList.RemoveAll(); if (m_pWorld != NULL) { m_pWorld->Release() ; } */ }
caebac7161f25c75739ecbd1b1aa0d9c83f5cf5d
f3eed6a3866e4f11ef94006a2316f271cd3a157f
/src/core/common/locator.cpp
0748c3dcd636123c829559401b94ce6a3f3ae138
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
xzm7358/openthread
3cf7cdee66569f05c6f11a4dcd8af1d34f28c7b9
6805cfa81e181cf35770d0f24cb42cbb86a88594
refs/heads/master
2021-05-02T13:19:53.200357
2018-02-07T17:15:28
2018-02-07T17:15:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,256
cpp
/* * Copyright (c) 2017, The OpenThread Authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /** * @file * This file implements the locator class for OpenThread objects. */ #define WPP_NAME "locator.tmh" #include "locator.hpp" #include "common/instance.hpp" #include "net/ip6.hpp" namespace ot { #if !OPENTHREAD_ENABLE_MULTIPLE_INSTANCES Instance &InstanceLocator::GetInstance(void) const { return Instance::Get(); } #endif Ip6::Ip6 &InstanceLocator::GetIp6(void) const { return GetInstance().GetIp6(); } ThreadNetif &InstanceLocator::GetNetif(void) const { return GetInstance().GetThreadNetif(); } Notifier &InstanceLocator::GetNotifier(void) const { return GetInstance().GetNotifier(); } } // namespace ot
0c31d2d218f8a147c0a7236c2c38ce0702119010
badf5496f1025a66cc44bc37890baf545d058ae2
/testMPU/testMPU.ino
f1829bf4c4250c9cc432d46a0f61eea72f719922
[]
no_license
1164513233/catMini
b683f7bbc12e992819939e929b24352b97412c9a
125c3c8455c7418e31feee8858116d045b468fa9
refs/heads/master
2021-10-16T08:56:14.510669
2019-02-09T14:57:11
2019-02-09T14:57:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,969
ino
// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class using DMP (MotionApps v2.0) // 6/21/2012 by Jeff Rowberg <[email protected]> // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib // // Changelog: // 2013-05-08 - added seamless Fastwire support // - added note about gyro calibration // 2012-06-21 - added note about Arduino 1.0.1 + Leonardo compatibility error // 2012-06-20 - improved FIFO overflow handling and simplified read process // 2012-06-19 - completely rearranged DMP initialization code and simplification // 2012-06-13 - pull gyro and accel data from FIFO packet instead of reading directly // 2012-06-09 - fix broken FIFO read sequence and change interrupt detection to RISING // 2012-06-05 - add gravity-compensated initial reference frame acceleration output // - add 3D math helper file to DMP6 example sketch // - add Euler output and Yaw/Pitch/Roll output formats // 2012-06-04 - remove accel offset clearing for better results (thanks Sungon Lee) // 2012-06-01 - fixed gyro sensitivity to be 2000 deg/sec instead of 250 // 2012-05-30 - basic DMP initialization working // calibration: http://42bots.com/tutorials/arduino-script-for-mpu-6050-auto-calibration/ /* ============================================ I2Cdev device library code is placed under the MIT license Copyright (c) 2012 Jeff Rowberg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =============================================== */ // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files // for both classes must be in the include path of your project #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" //#include "MPU6050.h" // not necessary if using MotionApps include file // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation // is used in I2Cdev.h #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif // class default I2C address is 0x68 // specific I2C addresses may be passed as a parameter here // AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board) // AD0 high = 0x69 MPU6050 mpu; //MPU6050 mpu(0x69); // <-- use for AD0 high /* ========================================================================= NOTE: In addition to connection 3.3v, GND, SDA, and SCL, this sketch depends on the MPU-6050's INT pin being connected to the Arduino's external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is digital I/O pin 2. * ========================================================================= */ /* ========================================================================= NOTE: Arduino v1.0.1 with the Leonardo board generates a compile error when using Serial.write(buf, len). The Teapot output uses this method. The solution requires a modification to the Arduino USBAPI.h file, which is fortunately simple, but annoying. This will be fixed in the next IDE release. For more info, see these links: http://arduino.cc/forum/index.php/topic,109987.0.html http://code.google.com/p/arduino/issues/detail?id=958 * ========================================================================= */ // uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual // quaternion components in a [w, x, y, z] format (not best for parsing // on a remote host such as Processing or something though) //#define OUTPUT_READABLE_QUATERNION // uncomment "OUTPUT_READABLE_EULER" if you want to see Euler angles // (in degrees) calculated from the quaternions coming from the FIFO. // Note that Euler angles suffer from gimbal lock (for more info, see // http://en.wikipedia.org/wiki/Gimbal_lock) //#define OUTPUT_READABLE_EULER // uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/ // pitch/roll angles (in degrees) calculated from the quaternions coming // from the FIFO. Note this also requires gravity vector calculations. // Also note that yaw/pitch/roll angles suffer from gimbal lock (for // more info, see: http://en.wikipedia.org/wiki/Gimbal_lock) #define OUTPUT_READABLE_YAWPITCHROLL // uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration // components with gravity removed. This acceleration reference frame is // not compensated for orientation, so +X is always +X according to the // sensor, just without the effects of gravity. If you want acceleration // compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead. //#define OUTPUT_READABLE_REALACCEL // uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration // components with gravity removed and adjusted for the world frame of // reference (yaw is relative to initial orientation, since no magnetometer // is present in this case). Could be quite handy in some cases. //#define OUTPUT_READABLE_WORLDACCEL // uncomment "OUTPUT_TEAPOT" if you want output that matches the // format used for the InvenSense teapot demo //#define OUTPUT_TEAPOT #define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6) bool blinkState = false; // MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer[64]; // FIFO storage buffer // orientation/motion vars Quaternion q; // [w, x, y, z] quaternion container VectorInt16 aa; // [x, y, z] accel sensor measurements VectorInt16 aaReal; // [x, y, z] gravity-free accel sensor measurements VectorInt16 aaWorld; // [x, y, z] world-frame accel sensor measurements VectorFloat gravity; // [x, y, z] gravity vector float euler[3]; // [psi, theta, phi] Euler angle container float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector // packet structure for InvenSense teapot demo uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' }; // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } // ================================================================ // === INITIAL SETUP === // ================================================================ void setup() { // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz) #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif // initialize serial communication // (115200 chosen because it is required for Teapot Demo output, but it's // really up to you depending on your project) Serial.begin(57600); while (!Serial); // wait for Leonardo enumeration, others continue immediately // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to // the baud timing being too misaligned with processor ticks. You must use // 38400 or slower in these cases, or use some kind of external separate // crystal solution for the UART timer. // initialize device Serial.println(F("Initializing I2C devices...")); mpu.initialize(); // verify connection Serial.println(F("Testing device connections...")); Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed")); // wait for ready Serial.println(F("\nSend any character to begin DMP programming and demo: ")); // while (Serial.available() && Serial.read()); // empty buffer // while (!Serial.available()); // wait for data // while (Serial.available() && Serial.read()); // empty buffer again // load and configure the DMP Serial.println(F("Initializing DMP...")); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(135); mpu.setYGyroOffset(34); mpu.setZGyroOffset(-30); mpu.setZAccelOffset(1736); // 1688 factory default for my test chip // make sure it worked (returns 0 if so) if (devStatus == 0) { // turn on the DMP, now that it's ready Serial.println(F("Enabling DMP...")); mpu.setDMPEnabled(true); // enable Arduino interrupt detection Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); attachInterrupt(0, dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus(); // set our DMP Ready flag so the main loop() function knows it's okay to use it Serial.println(F("DMP ready! Waiting for first interrupt...")); dmpReady = true; // get expected DMP packet size for later comparison packetSize = mpu.dmpGetFIFOPacketSize(); } else { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) Serial.print(F("DMP Initialization failed (code ")); Serial.print(devStatus); Serial.println(F(")")); } // configure LED for output pinMode(LED_PIN, OUTPUT); } // ================================================================ // === MAIN PROGRAM LOOP === // ================================================================ void loop() { // if programming failed, don't try to do anything if (!dmpReady) return; // wait for MPU interrupt or extra packet(s) available while (!mpuInterrupt && fifoCount < packetSize) { // other program behavior stuff here // . // . // . // if you are really paranoid you can frequently test in between other // stuff to see if mpuInterrupt is true, and if so, "break;" from the // while() loop to immediately process the MPU data // . // . // . } // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); // get current FIFO count fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else if (mpuIntStatus & 0x02) { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; #ifdef OUTPUT_READABLE_QUATERNION // display quaternion values in easy matrix form: w x y z mpu.dmpGetQuaternion(&q, fifoBuffer); Serial.print("quat\t"); Serial.print(q.w); Serial.print("\t"); Serial.print(q.x); Serial.print("\t"); Serial.print(q.y); Serial.print("\t"); Serial.println(q.z); #endif #ifdef OUTPUT_READABLE_EULER // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetEuler(euler, &q); Serial.print("euler\t"); Serial.print(euler[0] * 180/M_PI); Serial.print("\t"); Serial.print(euler[1] * 180/M_PI); Serial.print("\t"); Serial.println(euler[2] * 180/M_PI); #endif #ifdef OUTPUT_READABLE_YAWPITCHROLL // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); Serial.print("ypr\t"); Serial.print(ypr[0] * 180/M_PI); Serial.print("\t"); Serial.print(ypr[1] * 180/M_PI); Serial.print("\t"); Serial.println(ypr[2] * 180/M_PI); #endif #ifdef OUTPUT_READABLE_REALACCEL // display real acceleration, adjusted to remove gravity mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); Serial.print("areal\t"); Serial.print(aaReal.x); Serial.print("\t"); Serial.print(aaReal.y); Serial.print("\t"); Serial.println(aaReal.z); #endif #ifdef OUTPUT_READABLE_WORLDACCEL // display initial world-frame acceleration, adjusted to remove gravity // and rotated based on known orientation from quaternion mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetAccel(&aa, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q); Serial.print("aworld\t"); Serial.print(aaWorld.x); Serial.print("\t"); Serial.print(aaWorld.y); Serial.print("\t"); Serial.println(aaWorld.z); #endif #ifdef OUTPUT_TEAPOT // display quaternion values in InvenSense Teapot demo format: teapotPacket[2] = fifoBuffer[0]; teapotPacket[3] = fifoBuffer[1]; teapotPacket[4] = fifoBuffer[4]; teapotPacket[5] = fifoBuffer[5]; teapotPacket[6] = fifoBuffer[8]; teapotPacket[7] = fifoBuffer[9]; teapotPacket[8] = fifoBuffer[12]; teapotPacket[9] = fifoBuffer[13]; Serial.write(teapotPacket, 14); teapotPacket[11]++; // packetCount, loops at 0xFF on purpose #endif // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } }
8312834d51116dc65768c46c72d97719759b888b
9103aca62b53519cdf662aaba6368f0a9de8c4dc
/Arduino/1122/ex2/ex2.ino
feb37c769725e8c2d9c10c699dc321d51403d645
[]
no_license
Sylvaingbrt/Maeda-Hiroki-2018
98cae2d3e111c7ad14f116c9e13502d53b8cbaf3
c10a2a428c693308620511ac74ee5919739fd997
refs/heads/master
2020-04-07T07:06:54.946962
2018-11-30T01:47:06
2018-11-30T01:47:06
158,164,237
0
0
null
null
null
null
UTF-8
C++
false
false
399
ino
void setup() { // put your setup code here, to run once: pinMode(6,OUTPUT); } void loop() { // put your main code here, to run repeatedly: int i; for(i=0;i<10;i++){ analogWrite(6,255*i*0.1); delay(500); } for(i=10;i>0;i--){ analogWrite(6,255*i*0.1); delay(500); } /* for(i=0;i<2*3.14;i+=0.01){ analogWrite(6,255*abs(sin(i*3.14))); delay(10); } */ }
6c5fae3ba12c0b3be74094636fc66ce18a122b20
1358ed615e79bc01afb5ae4fb9f11c544855a3cf
/lib/structs/wct_type.h
9f6b48bf579dcf73be522fee5c0e7ea851a26809
[ "MIT" ]
permissive
SimonMossmyr/w3x_t
0521b6d1f48aa67ad57bbd760c9260e210a9df9a
53044e6fb7aac9c12ed134d6e33edf839ccb3da6
refs/heads/master
2021-07-11T14:18:52.320687
2020-11-18T22:09:00
2020-11-18T22:09:00
218,337,876
0
0
null
null
null
null
UTF-8
C++
false
false
286
h
struct custom_text_trigger_type { int length; std::string contents; }; struct wct_type { int format_version; std::string comment; custom_text_trigger_type ctt; int n_ctt; std::vector<custom_text_trigger_type> custom_text_triggers; byte_type unknown; };
9a40a47d0c8416c4f04fbf123d520bca1d99f26a
14541a9f2cef091b474677fb9c3baf4ef3a315d0
/abchperson/ewsabchpersonhandler.cpp
fdfdb690f9746ff361ebdccf0327f6770b969668
[]
no_license
StefanBruens/akonadi-ews
45f5b75445c16b9e3a26cd35900212a41663acb4
05ce7e24547fbdb559de55dabda86d337716cfba
refs/heads/master
2021-01-21T23:23:27.304824
2017-10-04T07:52:29
2017-10-04T07:52:29
95,236,655
0
0
null
2017-06-23T16:20:49
2017-06-23T16:20:49
null
UTF-8
C++
false
false
2,626
cpp
/* This file is part of Akonadi EWS Resource Copyright (C) 2015-2016 Krzysztof Nowicki <[email protected]> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "ewsabchpersonhandler.h" #include <KCalCore/Todo> #include "ewsfetchabchpersondetailjob.h" #include "ewsmodifyabchpersonjob.h" #include "ewscreateabchpersonjob.h" using namespace Akonadi; EwsAbchPersonHandler::EwsAbchPersonHandler() { } EwsAbchPersonHandler::~EwsAbchPersonHandler() { } EwsItemHandler *EwsAbchPersonHandler::factory() { return new EwsAbchPersonHandler(); } EwsFetchItemDetailJob *EwsAbchPersonHandler::fetchItemDetailJob(EwsClient &client, QObject *parent, const Akonadi::Collection &collection) { return new EwsFetchAbchContactDetailsJob(client, parent, collection); } void EwsAbchPersonHandler::setSeenFlag(Item &item, bool value) { Q_UNUSED(item) Q_UNUSED(value) } QString EwsAbchPersonHandler::mimeType() { return KCalCore::Todo::todoMimeType(); } bool EwsAbchPersonHandler::setItemPayload(Akonadi::Item &item, const EwsItem &ewsItem) { Q_UNUSED(item) Q_UNUSED(ewsItem) return true; } EwsModifyItemJob *EwsAbchPersonHandler::modifyItemJob(EwsClient& client, const QVector<Akonadi::Item> &items, const QSet<QByteArray> &parts, QObject *parent) { return new EwsModifyAbchPersonJob(client, items, parts, parent); } EwsCreateItemJob *EwsAbchPersonHandler::createItemJob(EwsClient& client, const Akonadi::Item &item, const Akonadi::Collection &collection, EwsTagStore *tagStore, EwsResource *parent) { return new EwsCreateAbchPersonJob(client, item, collection, tagStore, parent); } EWS_DECLARE_ITEM_HANDLER(EwsAbchPersonHandler, EwsItemTypeAbchPerson)
68502e00dccf37f439f489bcf29de529cd9c775e
e217eaf05d0dab8dd339032b6c58636841aa8815
/Infrastructure/src/OpenInfraPlatform/Infrastructure/EnergyConsumption/Calculators/KineticEnergyCalculator.cpp
314df0a28629a960505e84e3068b1ce074043f5f
[]
no_license
bigdoods/OpenInfraPlatform
f7785ebe4cb46e24d7f636e1b4110679d78a4303
0266e86a9f25f2ea9ec837d8d340d31a58a83c8e
refs/heads/master
2021-01-21T03:41:20.124443
2016-01-26T23:20:21
2016-01-26T23:20:21
57,377,206
0
1
null
2016-04-29T10:38:19
2016-04-29T10:38:19
null
UTF-8
C++
false
false
509
cpp
/*! \verbatim * \copyright Copyright (c) 2015 Technische Universität München * Chair of Computational Modeling and Simulation. All rights reserved. * \author Julian Amann <[email protected]> (https://www.cms.bgu.tum.de/en/team/amann) * \brief This file is part of the TUM Open Infra Platform. * \endverbatim */ #include "KineticEnergyCalculator.h" BlueFramework::Infrastructure::EnergyConsumption::KineticEnergyCalculator::KineticEnergyCalculator() { }
b22306dbed79ed2e6db154d259ab7849a91c5b02
58f69613317191b27607f437889095bfbd4a19b9
/src/PoolTable.cpp
4376718295bde1b420c11935fbe479c9d42cc253
[]
no_license
emlowry/Billiards
49e6002511b2298dd7a18e6bacbb824bef8b955a
702a5173d8a611e939ec92107690e77baf409906
refs/heads/master
2016-08-11T07:49:56.607585
2015-06-08T03:13:49
2015-06-08T03:13:49
36,889,913
2
0
null
null
null
null
UTF-8
C++
false
false
10,590
cpp
#include "PoolTable.h" #include "Engine.h" #include "Mesh.h" #include <GL/glew.h> #include <GLFW/glfw3.h> #include <glm/ext.hpp> PoolTable::PoolTable() {} PoolTable::~PoolTable() {} void PoolTable::Start() { // create a perspective projection matrix with a 90 degree field-of-view and widescreen aspect ratio glm::vec2 windowSize = Engine::GetWindowSize(); Engine::PushProjectionMatrix(glm::perspective(glm::pi<float>() * 0.25f, windowSize.x / windowSize.y, 0.1f, 1000.0f)); // create a world-space matrix for a camera m_cameraMatrix = glm::inverse( glm::lookAt(glm::vec3(20,20,20),glm::vec3(0,0,0), glm::vec3(0,1,0)) ); Renderer::SetCameraPosition(m_cameraMatrix[3].xyz()); // load meshes m_boxMesh = Mesh::GenerateCubeMesh(); m_ballMesh = Mesh::GenerateSphereMesh(); // add a light Renderer::Light light; light.color = glm::vec3(1); light.direction = glm::vec3(0, -1, 0); light.position = glm::vec3(0, 15, 0); light.power = 1; light.attenuation = 0.001f; light.angle = 60; light.blur = 0.1f; Renderer::AddLight(light); Renderer::SetAmbientLight(glm::vec3(0.1f)); // set up pool table Actor::Material felt(1.0f, 0.5f, 2.0f, 2.0f); //Actor::Material wood(1.0f, 0.9f, 0.9f, 0.9f); Texture green(glm::vec4(0, 0.625f, 0.125f, 1), glm::vec4(0)); /*AddActor(new Actor(Geometry::Plane(40, 1.0f, glm::vec3(0), glm::vec3(0, 1, 0), glm::vec3(0, 0, -1)), false, felt, Texture(0, 1, 0, 0, 0)));/**/ AddActor(new Actor(Geometry::Box(glm::vec3(10, 1, 19.5), glm::vec3(0, -1, 0)), m_boxMesh, false, felt, green)); AddActor(new Actor(Geometry::Box(glm::vec3(1, 1, 8), glm::vec3(11, 1, 9.5)), m_boxMesh, false, felt, green)); AddActor(new Actor(Geometry::Box(glm::vec3(1, 1, 8), glm::vec3(11, 1, -9.5)), m_boxMesh, false, felt, green)); AddActor(new Actor(Geometry::Box(glm::vec3(1, 1, 8), glm::vec3(-11, 1, 9.5)), m_boxMesh, false, felt, green)); AddActor(new Actor(Geometry::Box(glm::vec3(1, 1, 8), glm::vec3(-11, 1, -9.5)), m_boxMesh, false, felt, green)); AddActor(new Actor(Geometry::Box(glm::vec3(8, 1, 1), glm::vec3(0, 1, 20.5)), m_boxMesh, false, felt, green)); AddActor(new Actor(Geometry::Box(glm::vec3(8, 1, 1), glm::vec3(0, 1, -20.5)), m_boxMesh, false, felt, green)); // load ball textures m_cueBallTexture = Texture("images/BallCue.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[0] = Texture("images/Ball1.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[1] = Texture("images/Ball2.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[2] = Texture("images/Ball3.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[3] = Texture("images/Ball4.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[4] = Texture("images/Ball5.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[5] = Texture("images/Ball6.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[6] = Texture("images/Ball7.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[7] = Texture("images/Ball8.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[8] = Texture("images/Ball9.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[9] = Texture("images/Ball10.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[10] = Texture("images/Ball11.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[11] = Texture("images/Ball12.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[12] = Texture("images/Ball13.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[13] = Texture("images/Ball14.jpg", glm::vec4(1), glm::vec4(1)); m_ballTextures[14] = Texture("images/Ball15.jpg", glm::vec4(1), glm::vec4(1)); // add balls m_cueBall = nullptr; for (unsigned int i = 0; i < BALL_COUNT; ++i) m_balls[i] = nullptr; Setup(); m_threshold = -1.5f; } void PoolTable::ClearBalls() { if (nullptr != m_cueBall) { DestroyActor(m_cueBall); m_cueBall = nullptr; } for (unsigned int i = 0; i < BALL_COUNT; ++i) { if (nullptr != m_balls[i]) { DestroyActor(m_balls[i]); m_balls[i] = nullptr; } } } void PoolTable::Setup() { // remove existing balls ClearBalls(); // create balls Actor::Material ivory; m_cueBall = new Actor(Geometry::Sphere(1, glm::vec3(0, 1, 10)), m_ballMesh, ivory, m_cueBallTexture); m_balls[0] = new Actor(Geometry::Sphere(1, glm::vec3(0, 1, -10)), m_ballMesh, ivory, m_ballTextures[0]); m_balls[1] = new Actor(Geometry::Sphere(1, glm::vec3(1.01, 1, -11.75)), m_ballMesh, ivory, m_ballTextures[1]); m_balls[2] = new Actor(Geometry::Sphere(1, glm::vec3(-1.01, 1, -11.75)), m_ballMesh, ivory, m_ballTextures[2]); m_balls[3] = new Actor(Geometry::Sphere(1, glm::vec3(2.02, 1, -13.5)), m_ballMesh, ivory, m_ballTextures[3]); m_balls[4] = new Actor(Geometry::Sphere(1, glm::vec3(0, 1, -13.5)), m_ballMesh, ivory, m_ballTextures[4]); m_balls[5] = new Actor(Geometry::Sphere(1, glm::vec3(-2.02, 1, -13.5)), m_ballMesh, ivory, m_ballTextures[5]); m_balls[6] = new Actor(Geometry::Sphere(1, glm::vec3(3.03, 1, -15.25)), m_ballMesh, ivory, m_ballTextures[6]); m_balls[7] = new Actor(Geometry::Sphere(1, glm::vec3(1.01, 1, -15.25)), m_ballMesh, ivory, m_ballTextures[7]); m_balls[8] = new Actor(Geometry::Sphere(1, glm::vec3(-1.01, 1, -15.25)), m_ballMesh, ivory, m_ballTextures[8]); m_balls[9] = new Actor(Geometry::Sphere(1, glm::vec3(-3.03, 1, -15.25)), m_ballMesh, ivory, m_ballTextures[9]); m_balls[10] = new Actor(Geometry::Sphere(1, glm::vec3(4.04, 1, -17)), m_ballMesh, ivory, m_ballTextures[10]); m_balls[11] = new Actor(Geometry::Sphere(1, glm::vec3(2.02, 1, -17)), m_ballMesh, ivory, m_ballTextures[11]); m_balls[12] = new Actor(Geometry::Sphere(1, glm::vec3(0, 1, -17)), m_ballMesh, ivory, m_ballTextures[12]); m_balls[13] = new Actor(Geometry::Sphere(1, glm::vec3(-2.02, 1, -17)), m_ballMesh, ivory, m_ballTextures[13]); m_balls[14] = new Actor(Geometry::Sphere(1, glm::vec3(-4.04, 1, -17)), m_ballMesh, ivory, m_ballTextures[14]); // add balls to scene AddActor(m_cueBall); for (auto ball : m_balls) AddActor(ball); m_aiming = m_cued = false; } // Copied from Utilities.cpp in AIEFramework static void freeMovement(glm::mat4& a_transform, double a_deltaTime, double a_speed, const glm::vec3& a_up = glm::vec3(0,1,0)) { GLFWwindow* window = Engine::GetWindow(); double frameSpeed = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS ? a_deltaTime * a_speed * 2 : a_deltaTime * a_speed; // translate if (glfwGetKey(window, 'W') == GLFW_PRESS) a_transform[3] -= a_transform[2] * frameSpeed; if (glfwGetKey(window, 'S') == GLFW_PRESS) a_transform[3] += a_transform[2] * frameSpeed; if (glfwGetKey(window, 'D') == GLFW_PRESS) a_transform[3] += a_transform[0] * frameSpeed; if (glfwGetKey(window, 'A') == GLFW_PRESS) a_transform[3] -= a_transform[0] * frameSpeed; if (glfwGetKey(window, 'Q') == GLFW_PRESS) a_transform[3] += a_transform[1] * frameSpeed; if (glfwGetKey(window, 'E') == GLFW_PRESS) a_transform[3] -= a_transform[1] * frameSpeed; // check for rotation static bool sbMouseButtonDown = false; if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_2) == GLFW_PRESS) { static double siPrevMouseX = 0; static double siPrevMouseY = 0; if (sbMouseButtonDown == false) { sbMouseButtonDown = true; glfwGetCursorPos(window, &siPrevMouseX, &siPrevMouseY); } double mouseX = 0, mouseY = 0; glfwGetCursorPos(window, &mouseX, &mouseY); double iDeltaX = mouseX - siPrevMouseX; double iDeltaY = mouseY - siPrevMouseY; siPrevMouseX = mouseX; siPrevMouseY = mouseY; glm::mat4 mMat; // pitch if (iDeltaY != 0) { mMat = glm::axisAngleMatrix(a_transform[0].xyz(), (float)-iDeltaY / 150.0f); a_transform[0] = mMat * a_transform[0]; a_transform[1] = mMat * a_transform[1]; a_transform[2] = mMat * a_transform[2]; } // yaw if (iDeltaX != 0) { mMat = glm::axisAngleMatrix(a_up, (float)-iDeltaX / 150.0f); a_transform[0] = mMat * a_transform[0]; a_transform[1] = mMat * a_transform[1]; a_transform[2] = mMat * a_transform[2]; } } else { sbMouseButtonDown = false; } } void PoolTable::Update() { // update our camera matrix using the keyboard/mouse freeMovement( m_cameraMatrix, Engine::GetDeltaTime(), 0.001 ); Renderer::SetCameraPosition(m_cameraMatrix[3].xyz()); glm::mat4 viewMatrix = glm::inverse(m_cameraMatrix); Engine::SwapViewMatrix(viewMatrix); Scene::Update(); if (!m_cued) { // get window dimensions to calculate aspect ratio int width = 0, height = 0; glfwGetWindowSize(Engine::GetWindow(), &width, &height); double mouseX = 0, mouseY = 0; glfwGetCursorPos(Engine::GetWindow(), &mouseX, &mouseY); glm::vec3 screenCoord(mouseX, (float)height - mouseY, 0); glm::vec4 viewPort = glm::vec4(0.f, 0.f, width, height); glm::vec3 worldPos = glm::unProject(screenCoord, viewMatrix, Engine::GetProjectionMatrix(), viewPort); glm::vec3 rayOrigin = m_cameraMatrix[3].xyz(); glm::vec3 rayDirection = glm::normalize(worldPos - m_cameraMatrix[3].xyz()); glm::vec3 up(0, 1, 0); float d = glm::dot(rayDirection, up); if (0 != d) { glm::vec3 cue = rayOrigin + rayDirection * glm::dot(up - rayOrigin, up) / d; if (glfwGetMouseButton(Engine::GetWindow(), GLFW_MOUSE_BUTTON_1) == GLFW_PRESS) { m_aiming = true; //Gizmos::addLine(cue, m_cueBall->GetPosition(), glm::vec4(1)); } else if (m_aiming) { m_aiming = false; m_cued = true; glm::vec3 aim = m_cueBall->GetPosition() - cue; m_cueBall->ApplyImpulse(aim * 2.0f * m_cueBall->GetMass(), m_cueBall->GetGeometry().ClosestSurfacePointTo(cue)); } } } else { if (m_cueBall->GetPosition().y < m_threshold) Setup(); bool still = glm::vec3(0) == m_cueBall->GetVelocity(); unsigned int remainingBalls = 0; for (unsigned int i = 0; i < BALL_COUNT; ++i) { if (nullptr == m_balls[i]) continue; ++remainingBalls; if (m_balls[i]->GetPosition().y < m_threshold) { DestroyActor(m_balls[i]); m_balls[i] = nullptr; --remainingBalls; } else if (still) { still = glm::vec3(0) == m_balls[i]->GetVelocity(); } } if (0 == remainingBalls) { Setup(); } else if (still) { m_aiming = m_cued = false; } } // quit our application when escape is pressed if (glfwGetKey(Engine::GetWindow(),GLFW_KEY_ESCAPE) == GLFW_PRESS) Engine::Quit(); } void PoolTable::Draw() { Renderer::ClearMeshQueue(); QueueMeshes(); Renderer::DrawQueuedMeshes(); } void PoolTable::Stop() { ClearBalls(); m_boxMesh.Destroy(); m_ballMesh.Destroy(); m_cueBallTexture.Destroy(); for (Texture texture : m_ballTextures) texture.Destroy(); }
635eec7527a93c5194f9f1cf6e068b210ff52233
5a9ea797da94f7ef59f5564cfb5290df5502eb30
/include/proto.h
ac8e58266ada3893dfddcffd1794d19baebf4ad1
[]
no_license
patrickjmann/reservoir-1d-upwind
44494cd77d97584f393e26751f5d1dadd16601ff
be3d41e1c4f330e6c7f9be6624f7e81681ec9340
refs/heads/master
2021-03-19T07:06:41.058945
2013-01-04T20:46:51
2013-01-04T20:46:51
7,171,374
2
0
null
null
null
null
UTF-8
C++
false
false
868
h
//############################################################################# /**\file proto.h $Source: /home/mann/Dropbox/research/1/ReservoirSimulation/1d/upwind1/include/RCS/proto.h,v $ $Revision: 1.1 $ $Date: 2012/10/02 21:52:01 $ \author P.J.Mann */ //----------------------------------------------------------------------------- #if ! defined CONS1_PROTO_H #define CONS1_PROTO_H using namespace std; // Various useful utilities int GetId(); void MakeOutFiles(); void Set_OS_Stuff( ); // Primitive variables solver int fvalue( const double pcurrent, const double S, const double D, const double E, const double gamma, double& f, double& fprime ); int PrimitiveSolve( const double S, const double D, const double E, const double gamma, const double pguess, double& v, double& rho0, double& eps, double& p ); #endif
fe1f03f69c7d6b10814e76440c3591e2ee0f91ab
b9ddbb0e5e70d5ea428be072f40d9d668f563039
/src/tasks/task-joint-bounds.cpp
1af3ca34e821f802af2abaf742e10bc1fc6b15be
[]
no_license
jkw0701/HQP_basic
e3cb191432a1d62adbd39ece670d51b11f515aba
298918c306e48d711e2c54acada25b1d375f58f1
refs/heads/master
2022-11-30T01:28:01.176926
2020-08-04T08:30:01
2020-08-04T08:30:01
284,919,216
2
1
null
null
null
null
UTF-8
C++
false
false
4,974
cpp
#include "tasks/task-joint-bounds.h" namespace HQP { namespace tasks { using namespace constraint; using namespace trajectories; TaskJointLimit::TaskJointLimit(const std::string & name, RobotModel & robot) : TaskBase(name, robot), m_constraint(name, robot.nv(), robot.nv()) { m_robot = robot; m_velocity_limit_ = 2000.0; if (robot.type() == 0) { m_constraint.setLowerBound(-m_velocity_limit_ * VectorXd(robot.nv()).setOnes()); m_constraint.setUpperBound(m_velocity_limit_ * VectorXd(robot.nv()).setOnes()); m_Kp.setZero(robot.nv()); m_Kd.setZero(robot.nv()); VectorXd m = VectorXd::Ones(robot.nv()); mask(m); } else if (robot.type() == 1) { m_constraint.setLowerBound(-m_velocity_limit_ * VectorXd(robot.nv()).setOnes()); m_constraint.setUpperBound(m_velocity_limit_ * VectorXd(robot.nv()).setOnes()); m_Kp.setZero(robot.nv()); m_Kd.setZero(robot.nv()); VectorXd m = VectorXd::Ones(robot.nv()); mask(m); } m_buffer = 0.0 * M_PI / 180.0; } int TaskJointLimit::dim() const { return m_robot.nv(); } const ConstraintBase & TaskJointLimit::compute(const double t, Cref_vectorXd q, Cref_vectorXd v) { if (m_robot.type() == 0) { for (int i = 0; i < m_robot.nv(); i++) { if (q(i) < m_q_lbound(i) + m_buffer) { m_constraint.lowerBound()(i) = m_Kp(i) * ((m_q_lbound(i) + m_buffer) - q(i)) - m_Kd(i) * v(i); m_constraint.upperBound()(i) = m_velocity_limit_; if (m_constraint.lowerBound()(i) > m_velocity_limit_) m_constraint.lowerBound()(i) = m_velocity_limit_; m_constraint.upperBound()(i) = m_velocity_limit_; } else if (q(i) > m_q_ubound(i) - m_buffer) { m_constraint.upperBound()(i) = m_Kp(i) * ((m_q_ubound(i) - m_buffer) - q(i)) - m_Kd(i) * v(i); m_constraint.lowerBound()(i) = -m_velocity_limit_; if (m_constraint.upperBound()(i) < -m_velocity_limit_) m_constraint.upperBound()(i) = -m_velocity_limit_; m_constraint.lowerBound()(i) = -m_velocity_limit_; } else { m_constraint.upperBound()(i) = m_velocity_limit_; m_constraint.lowerBound()(i) = -m_velocity_limit_; } } MatrixXd A(m_robot.nv(), m_robot.nv()); A.setIdentity(); m_constraint.setMatrix(A); return m_constraint; } else if (m_robot.type() == 1) { for (int i = 0; i < 2; i++) { m_constraint.lowerBound()(i) = m_q_lbound(i); m_constraint.upperBound()(i) = m_q_ubound(i); } for (int i = 2; i < m_robot.nv(); i++) { if (q(i+3) < m_q_lbound(i) + m_buffer) { m_constraint.lowerBound()(i) = m_Kp(i) * ((m_q_lbound(i) + m_buffer) - q(i+3)) - m_Kd(i) * v(i+3); if (m_constraint.lowerBound()(i) > m_velocity_limit_) m_constraint.lowerBound()(i) = m_velocity_limit_; m_constraint.upperBound()(i) = m_velocity_limit_; } else if (q(i+3) > m_q_ubound(i) - m_buffer) { //cout << q(i+3) <<"\t " << m_q_ubound(i) - m_buffer <<endl; m_constraint.upperBound()(i) = m_Kp(i) * ((m_q_ubound(i) - m_buffer) - q(i+3)) - m_Kd(i) * v(i+3); if (m_constraint.upperBound()(i) < -m_velocity_limit_) m_constraint.upperBound()(i) = -m_velocity_limit_; m_constraint.lowerBound()(i) = -m_velocity_limit_; } else { m_constraint.upperBound()(i) = m_velocity_limit_; m_constraint.lowerBound()(i) = -m_velocity_limit_; } } //if (m_robot.getManipulability(0, m_robot.getJointPosition()) < 0.01) { // VectorXd Jd = m_robot.getManipulabilityJacobian(0); // for (int i = 0; i < dof / 2; i++) { // m_constraint.lowerBound()(i + 2) = 0.000005 / Jd(i) * (m_robot.getManipulability(0, m_robot.getJointPosition()) - 0.005); // if (m_constraint.lowerBound()(i + 2) > 2000.0) // m_constraint.upperBound()(i + 2) = m_constraint.lowerBound()(i + 2); // } //} MatrixXd A(m_robot.nv(), m_robot.nv()); A.setIdentity(); m_constraint.setMatrix(A); return m_constraint; } } const ConstraintBase & TaskJointLimit::getConstraint() const{ return m_constraint; } void TaskJointLimit::setJointLimit(Cref_vectorXd q_low, Cref_vectorXd q_high) { assert(q_low.size() == m_robot.nv() && q_high.size() == m_robot.nv()); for (int i = 0; i < q_low.size(); i++) assert(q_low(i) <= q_high(i)); m_q_lbound = q_low; m_q_ubound = q_high; } const VectorXd & TaskJointLimit::mask() const { } void TaskJointLimit::mask(const VectorXd & mask) { } const VectorXd & TaskJointLimit::Kp() { return m_Kp; } const VectorXd & TaskJointLimit::Kd() { return m_Kd; } void TaskJointLimit::Kp(Cref_vectorXd Kp) { assert(Kp.size() == m_robot.nv()); m_Kp = Kp; } void TaskJointLimit::Kd(Cref_vectorXd Kd) { assert(Kd.size() == m_robot.nv()); m_Kd = Kd; } } }
99bba8437d8c681a809e9d085fee098f65fad388
90047daeb462598a924d76ddf4288e832e86417c
/components/suggestions/suggestions_service_impl_unittest.cc
84c28fd3d131703d27a14d486f28a67e06ef81bc
[ "BSD-3-Clause" ]
permissive
massbrowser/android
99b8c21fa4552a13c06bbedd0f9c88dd4a4ad080
a9c4371682c9443d6e1d66005d4db61a24a9617c
refs/heads/master
2022-11-04T21:15:50.656802
2017-06-08T12:31:39
2017-06-08T12:31:39
93,747,579
2
2
BSD-3-Clause
2022-10-31T10:34:25
2017-06-08T12:36:07
null
UTF-8
C++
false
false
30,737
cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/suggestions/suggestions_service_impl.h" #include <stdint.h> #include <memory> #include <utility> #include "base/bind.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/test/mock_callback.h" #include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" #include "components/signin/core/browser/fake_signin_manager.h" #include "components/signin/core/browser/test_signin_client.h" #include "components/suggestions/blacklist_store.h" #include "components/suggestions/image_manager.h" #include "components/suggestions/proto/suggestions.pb.h" #include "components/suggestions/suggestions_store.h" #include "components/sync/driver/fake_sync_service.h" #include "components/sync/driver/sync_service.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "net/http/http_response_headers.h" #include "net/http/http_status_code.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_request_status.h" #include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/image/image.h" using sync_preferences::TestingPrefServiceSyncable; using testing::_; using testing::AnyNumber; using testing::DoAll; using testing::Eq; using testing::Return; using testing::SetArgPointee; using testing::StrictMock; namespace { const char kAccountId[] = "account"; const char kTestTitle[] = "a title"; const char kTestUrl[] = "http://go.com"; const char kTestFaviconUrl[] = "https://s2.googleusercontent.com/s2/favicons?domain_url=" "http://go.com&alt=s&sz=32"; const char kBlacklistedUrl[] = "http://blacklist.com"; const char kBlacklistedUrlAlt[] = "http://blacklist-atl.com"; const int64_t kTestDefaultExpiry = 1402200000000000; const int64_t kTestSetExpiry = 1404792000000000; std::unique_ptr<net::FakeURLFetcher> CreateURLFetcher( const GURL& url, net::URLFetcherDelegate* delegate, const std::string& response_data, net::HttpStatusCode response_code, net::URLRequestStatus::Status status) { std::unique_ptr<net::FakeURLFetcher> fetcher(new net::FakeURLFetcher( url, delegate, response_data, response_code, status)); if (response_code == net::HTTP_OK) { scoped_refptr<net::HttpResponseHeaders> download_headers( new net::HttpResponseHeaders("")); download_headers->AddHeader("Content-Type: text/html"); fetcher->set_response_headers(download_headers); } return fetcher; } // GMock matcher for protobuf equality. MATCHER_P(EqualsProto, message, "") { // This implementation assumes protobuf serialization is deterministic, which // is true in practice but technically not something that code is supposed // to rely on. However, it vastly simplifies the implementation. std::string expected_serialized, actual_serialized; message.SerializeToString(&expected_serialized); arg.SerializeToString(&actual_serialized); return expected_serialized == actual_serialized; } } // namespace namespace suggestions { SuggestionsProfile CreateSuggestionsProfile() { SuggestionsProfile profile; profile.set_timestamp(123); ChromeSuggestion* suggestion = profile.add_suggestions(); suggestion->set_title(kTestTitle); suggestion->set_url(kTestUrl); suggestion->set_expiry_ts(kTestSetExpiry); return profile; } // Creates one suggestion with expiry timestamp and one without. SuggestionsProfile CreateSuggestionsProfileWithExpiryTimestamps() { SuggestionsProfile profile; profile.set_timestamp(123); ChromeSuggestion* suggestion = profile.add_suggestions(); suggestion->set_title(kTestTitle); suggestion->set_url(kTestUrl); suggestion->set_expiry_ts(kTestSetExpiry); suggestion = profile.add_suggestions(); suggestion->set_title(kTestTitle); suggestion->set_url(kTestUrl); return profile; } class MockSyncService : public syncer::FakeSyncService { public: MockSyncService() {} virtual ~MockSyncService() {} MOCK_CONST_METHOD0(CanSyncStart, bool()); MOCK_CONST_METHOD0(IsSyncActive, bool()); MOCK_CONST_METHOD0(ConfigurationDone, bool()); MOCK_CONST_METHOD0(GetActiveDataTypes, syncer::ModelTypeSet()); }; class TestSuggestionsStore : public suggestions::SuggestionsStore { public: TestSuggestionsStore() { cached_suggestions = CreateSuggestionsProfile(); } bool LoadSuggestions(SuggestionsProfile* suggestions) override { suggestions->CopyFrom(cached_suggestions); return cached_suggestions.suggestions_size(); } bool StoreSuggestions(const SuggestionsProfile& suggestions) override { cached_suggestions.CopyFrom(suggestions); return true; } void ClearSuggestions() override { cached_suggestions = SuggestionsProfile(); } SuggestionsProfile cached_suggestions; }; class MockImageManager : public suggestions::ImageManager { public: MockImageManager() {} virtual ~MockImageManager() {} MOCK_METHOD1(Initialize, void(const SuggestionsProfile&)); MOCK_METHOD2(GetImageForURL, void(const GURL&, base::Callback<void(const GURL&, const gfx::Image&)>)); MOCK_METHOD2(AddImageURL, void(const GURL&, const GURL&)); }; class MockBlacklistStore : public suggestions::BlacklistStore { public: MOCK_METHOD1(BlacklistUrl, bool(const GURL&)); MOCK_METHOD0(ClearBlacklist, void()); MOCK_METHOD1(GetTimeUntilReadyForUpload, bool(base::TimeDelta*)); MOCK_METHOD2(GetTimeUntilURLReadyForUpload, bool(const GURL&, base::TimeDelta*)); MOCK_METHOD1(GetCandidateForUpload, bool(GURL*)); MOCK_METHOD1(RemoveUrl, bool(const GURL&)); MOCK_METHOD1(FilterSuggestions, void(SuggestionsProfile*)); }; class SuggestionsServiceTest : public testing::Test { protected: SuggestionsServiceTest() : signin_client_(&pref_service_), signin_manager_(&signin_client_, &account_tracker_), factory_(nullptr, base::Bind(&CreateURLFetcher)), mock_thumbnail_manager_(nullptr), mock_blacklist_store_(nullptr), test_suggestions_store_(nullptr) { SigninManagerBase::RegisterProfilePrefs(pref_service_.registry()); SigninManagerBase::RegisterPrefs(pref_service_.registry()); signin_manager_.SignIn(kAccountId); token_service_.UpdateCredentials(kAccountId, "refresh_token"); token_service_.set_auto_post_fetch_response_on_message_loop(true); } ~SuggestionsServiceTest() override {} void SetUp() override { request_context_ = new net::TestURLRequestContextGetter(io_message_loop_.task_runner()); EXPECT_CALL(mock_sync_service_, CanSyncStart()) .Times(AnyNumber()) .WillRepeatedly(Return(true)); EXPECT_CALL(mock_sync_service_, IsSyncActive()) .Times(AnyNumber()) .WillRepeatedly(Return(true)); EXPECT_CALL(mock_sync_service_, ConfigurationDone()) .Times(AnyNumber()) .WillRepeatedly(Return(true)); EXPECT_CALL(mock_sync_service_, GetActiveDataTypes()) .Times(AnyNumber()) .WillRepeatedly( Return(syncer::ModelTypeSet(syncer::HISTORY_DELETE_DIRECTIVES))); // These objects are owned by the SuggestionsService, but we keep the // pointers around for testing. test_suggestions_store_ = new TestSuggestionsStore(); mock_thumbnail_manager_ = new StrictMock<MockImageManager>(); mock_blacklist_store_ = new StrictMock<MockBlacklistStore>(); suggestions_service_ = base::MakeUnique<SuggestionsServiceImpl>( &signin_manager_, &token_service_, &mock_sync_service_, request_context_.get(), base::WrapUnique(test_suggestions_store_), base::WrapUnique(mock_thumbnail_manager_), base::WrapUnique(mock_blacklist_store_)); } bool HasPendingSuggestionsRequest() const { return !!suggestions_service_->pending_request_.get(); } protected: base::MessageLoopForIO io_message_loop_; TestingPrefServiceSyncable pref_service_; AccountTrackerService account_tracker_; TestSigninClient signin_client_; FakeSigninManagerBase signin_manager_; net::FakeURLFetcherFactory factory_; FakeProfileOAuth2TokenService token_service_; MockSyncService mock_sync_service_; scoped_refptr<net::TestURLRequestContextGetter> request_context_; // Owned by the SuggestionsService. MockImageManager* mock_thumbnail_manager_; MockBlacklistStore* mock_blacklist_store_; TestSuggestionsStore* test_suggestions_store_; std::unique_ptr<SuggestionsServiceImpl> suggestions_service_; private: DISALLOW_COPY_AND_ASSIGN(SuggestionsServiceTest); }; TEST_F(SuggestionsServiceTest, FetchSuggestionsData) { base::MockCallback<SuggestionsService::ResponseCallback> callback; auto subscription = suggestions_service_->AddCallback(callback.Get()); // Set up net::FakeURLFetcherFactory. factory_.SetFakeResponse(SuggestionsServiceImpl::BuildSuggestionsURL(), CreateSuggestionsProfile().SerializeAsString(), net::HTTP_OK, net::URLRequestStatus::SUCCESS); EXPECT_CALL(*mock_thumbnail_manager_, Initialize(_)); EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(Return(false)); // Send the request. The data should be returned to the callback. suggestions_service_->FetchSuggestionsData(); EXPECT_CALL(callback, Run(_)); // Let the network request run. base::RunLoop().RunUntilIdle(); SuggestionsProfile suggestions; test_suggestions_store_->LoadSuggestions(&suggestions); ASSERT_EQ(1, suggestions.suggestions_size()); EXPECT_EQ(kTestTitle, suggestions.suggestions(0).title()); EXPECT_EQ(kTestUrl, suggestions.suggestions(0).url()); EXPECT_EQ(kTestFaviconUrl, suggestions.suggestions(0).favicon_url()); } TEST_F(SuggestionsServiceTest, IgnoresNoopSyncChange) { base::MockCallback<SuggestionsService::ResponseCallback> callback; EXPECT_CALL(callback, Run(_)).Times(0); auto subscription = suggestions_service_->AddCallback(callback.Get()); factory_.SetFakeResponse(SuggestionsServiceImpl::BuildSuggestionsURL(), CreateSuggestionsProfile().SerializeAsString(), net::HTTP_OK, net::URLRequestStatus::SUCCESS); // An no-op change should not result in a suggestions refresh. suggestions_service_->OnStateChanged(&mock_sync_service_); // Let any network request run (there shouldn't be one). base::RunLoop().RunUntilIdle(); } TEST_F(SuggestionsServiceTest, IgnoresUninterestingSyncChange) { base::MockCallback<SuggestionsService::ResponseCallback> callback; EXPECT_CALL(callback, Run(_)).Times(0); auto subscription = suggestions_service_->AddCallback(callback.Get()); factory_.SetFakeResponse(SuggestionsServiceImpl::BuildSuggestionsURL(), CreateSuggestionsProfile().SerializeAsString(), net::HTTP_OK, net::URLRequestStatus::SUCCESS); // An uninteresting change should not result in a network request (the // SyncState is INITIALIZED_ENABLED_HISTORY before and after). EXPECT_CALL(mock_sync_service_, GetActiveDataTypes()) .Times(AnyNumber()) .WillRepeatedly(Return(syncer::ModelTypeSet( syncer::HISTORY_DELETE_DIRECTIVES, syncer::BOOKMARKS))); suggestions_service_->OnStateChanged(&mock_sync_service_); // Let any network request run (there shouldn't be one). base::RunLoop().RunUntilIdle(); } // During startup, the state changes from NOT_INITIALIZED_ENABLED to // INITIALIZED_ENABLED_HISTORY (for a signed-in user with history sync enabled). // This should *not* result in an automatic fetch. TEST_F(SuggestionsServiceTest, DoesNotFetchOnStartup) { // The sync service starts out inactive. EXPECT_CALL(mock_sync_service_, IsSyncActive()).WillRepeatedly(Return(false)); suggestions_service_->OnStateChanged(&mock_sync_service_); ASSERT_EQ(SuggestionsServiceImpl::NOT_INITIALIZED_ENABLED, suggestions_service_->ComputeSyncState()); base::MockCallback<SuggestionsService::ResponseCallback> callback; EXPECT_CALL(callback, Run(_)).Times(0); auto subscription = suggestions_service_->AddCallback(callback.Get()); factory_.SetFakeResponse(SuggestionsServiceImpl::BuildSuggestionsURL(), CreateSuggestionsProfile().SerializeAsString(), net::HTTP_OK, net::URLRequestStatus::SUCCESS); // Sync getting enabled should not result in a fetch. EXPECT_CALL(mock_sync_service_, IsSyncActive()).WillRepeatedly(Return(true)); suggestions_service_->OnStateChanged(&mock_sync_service_); ASSERT_EQ(SuggestionsServiceImpl::INITIALIZED_ENABLED_HISTORY, suggestions_service_->ComputeSyncState()); // Let any network request run (there shouldn't be one). base::RunLoop().RunUntilIdle(); } TEST_F(SuggestionsServiceTest, FetchSuggestionsDataSyncNotInitializedEnabled) { EXPECT_CALL(mock_sync_service_, IsSyncActive()).WillRepeatedly(Return(false)); suggestions_service_->OnStateChanged(&mock_sync_service_); base::MockCallback<SuggestionsService::ResponseCallback> callback; EXPECT_CALL(callback, Run(_)).Times(0); auto subscription = suggestions_service_->AddCallback(callback.Get()); // Try to fetch suggestions. Since sync is not active, no network request // should be sent. suggestions_service_->FetchSuggestionsData(); // Let any network request run (there shouldn't be one). base::RunLoop().RunUntilIdle(); // |test_suggestions_store_| should still contain the default values. SuggestionsProfile suggestions; test_suggestions_store_->LoadSuggestions(&suggestions); EXPECT_THAT(suggestions, EqualsProto(CreateSuggestionsProfile())); } TEST_F(SuggestionsServiceTest, FetchSuggestionsDataSyncDisabled) { EXPECT_CALL(mock_sync_service_, CanSyncStart()).WillRepeatedly(Return(false)); base::MockCallback<SuggestionsService::ResponseCallback> callback; auto subscription = suggestions_service_->AddCallback(callback.Get()); // Tell SuggestionsService that the sync state changed. The cache should be // cleared and empty data returned to the callback. EXPECT_CALL(callback, Run(EqualsProto(SuggestionsProfile()))); suggestions_service_->OnStateChanged(&mock_sync_service_); // Try to fetch suggestions. Since sync is not active, no network request // should be sent. suggestions_service_->FetchSuggestionsData(); // Let any network request run. base::RunLoop().RunUntilIdle(); } TEST_F(SuggestionsServiceTest, FetchSuggestionsDataNoAccessToken) { token_service_.set_auto_post_fetch_response_on_message_loop(false); base::MockCallback<SuggestionsService::ResponseCallback> callback; EXPECT_CALL(callback, Run(_)).Times(0); auto subscription = suggestions_service_->AddCallback(callback.Get()); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(Return(false)); suggestions_service_->FetchSuggestionsData(); token_service_.IssueErrorForAllPendingRequests(GoogleServiceAuthError( GoogleServiceAuthError::State::INVALID_GAIA_CREDENTIALS)); // No network request should be sent. base::RunLoop().RunUntilIdle(); EXPECT_FALSE(HasPendingSuggestionsRequest()); } TEST_F(SuggestionsServiceTest, IssueRequestIfNoneOngoingError) { // Fake a request error. factory_.SetFakeResponse(SuggestionsServiceImpl::BuildSuggestionsURL(), "irrelevant", net::HTTP_OK, net::URLRequestStatus::FAILED); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(Return(false)); // Send the request. Empty data will be returned to the callback. suggestions_service_->IssueRequestIfNoneOngoing( SuggestionsServiceImpl::BuildSuggestionsURL()); // (Testing only) wait until suggestion fetch is complete. base::RunLoop().RunUntilIdle(); } TEST_F(SuggestionsServiceTest, IssueRequestIfNoneOngoingResponseNotOK) { // Fake a non-200 response code. factory_.SetFakeResponse(SuggestionsServiceImpl::BuildSuggestionsURL(), "irrelevant", net::HTTP_BAD_REQUEST, net::URLRequestStatus::SUCCESS); // Expect that an upload to the blacklist is scheduled. EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(Return(false)); // Send the request. Empty data will be returned to the callback. suggestions_service_->IssueRequestIfNoneOngoing( SuggestionsServiceImpl::BuildSuggestionsURL()); // (Testing only) wait until suggestion fetch is complete. base::RunLoop().RunUntilIdle(); // Expect no suggestions in the cache. SuggestionsProfile empty_suggestions; EXPECT_FALSE(test_suggestions_store_->LoadSuggestions(&empty_suggestions)); } TEST_F(SuggestionsServiceTest, BlacklistURL) { const base::TimeDelta no_delay = base::TimeDelta::FromSeconds(0); suggestions_service_->set_blacklist_delay(no_delay); base::MockCallback<SuggestionsService::ResponseCallback> callback; auto subscription = suggestions_service_->AddCallback(callback.Get()); const GURL blacklisted_url(kBlacklistedUrl); const GURL request_url( SuggestionsServiceImpl::BuildSuggestionsBlacklistURL(blacklisted_url)); factory_.SetFakeResponse(request_url, CreateSuggestionsProfile().SerializeAsString(), net::HTTP_OK, net::URLRequestStatus::SUCCESS); EXPECT_CALL(*mock_thumbnail_manager_, Initialize(_)).Times(2); // Expected calls to the blacklist store. EXPECT_CALL(*mock_blacklist_store_, BlacklistUrl(Eq(blacklisted_url))) .WillOnce(Return(true)); EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)).Times(2); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(DoAll(SetArgPointee<0>(no_delay), Return(true))) .WillOnce(Return(false)); EXPECT_CALL(*mock_blacklist_store_, GetCandidateForUpload(_)) .WillOnce(DoAll(SetArgPointee<0>(blacklisted_url), Return(true))); EXPECT_CALL(*mock_blacklist_store_, RemoveUrl(Eq(blacklisted_url))) .WillOnce(Return(true)); EXPECT_CALL(callback, Run(_)).Times(2); EXPECT_TRUE(suggestions_service_->BlacklistURL(blacklisted_url)); // Wait on the upload task, the blacklist request and the next blacklist // scheduling task. This only works when the scheduling task is not for future // execution (note how both the SuggestionsService's scheduling delay and the // BlacklistStore's candidacy delay are zero). base::RunLoop().RunUntilIdle(); SuggestionsProfile suggestions; test_suggestions_store_->LoadSuggestions(&suggestions); ASSERT_EQ(1, suggestions.suggestions_size()); EXPECT_EQ(kTestTitle, suggestions.suggestions(0).title()); EXPECT_EQ(kTestUrl, suggestions.suggestions(0).url()); EXPECT_EQ(kTestFaviconUrl, suggestions.suggestions(0).favicon_url()); } TEST_F(SuggestionsServiceTest, BlacklistURLFails) { base::MockCallback<SuggestionsService::ResponseCallback> callback; EXPECT_CALL(callback, Run(_)).Times(0); auto subscription = suggestions_service_->AddCallback(callback.Get()); const GURL blacklisted_url(kBlacklistedUrl); EXPECT_CALL(*mock_blacklist_store_, BlacklistUrl(Eq(blacklisted_url))) .WillOnce(Return(false)); EXPECT_FALSE(suggestions_service_->BlacklistURL(blacklisted_url)); } // Initial blacklist request fails, triggering a second which succeeds. TEST_F(SuggestionsServiceTest, BlacklistURLRequestFails) { const base::TimeDelta no_delay = base::TimeDelta::FromSeconds(0); suggestions_service_->set_blacklist_delay(no_delay); base::MockCallback<SuggestionsService::ResponseCallback> callback; auto subscription = suggestions_service_->AddCallback(callback.Get()); const GURL blacklisted_url(kBlacklistedUrl); const GURL request_url( SuggestionsServiceImpl::BuildSuggestionsBlacklistURL(blacklisted_url)); const GURL blacklisted_url_alt(kBlacklistedUrlAlt); const GURL request_url_alt( SuggestionsServiceImpl::BuildSuggestionsBlacklistURL( blacklisted_url_alt)); // Note: we want to set the response for the blacklist URL to first // succeed, then fail. This doesn't seem possible. For simplicity of testing, // we'll pretend the URL changed in the BlacklistStore between the first and // the second request, and adjust expectations accordingly. factory_.SetFakeResponse(request_url, "irrelevant", net::HTTP_OK, net::URLRequestStatus::FAILED); factory_.SetFakeResponse(request_url_alt, CreateSuggestionsProfile().SerializeAsString(), net::HTTP_OK, net::URLRequestStatus::SUCCESS); // Expectations. EXPECT_CALL(*mock_thumbnail_manager_, Initialize(_)).Times(2); EXPECT_CALL(*mock_blacklist_store_, BlacklistUrl(Eq(blacklisted_url))) .WillOnce(Return(true)); EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)).Times(2); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(DoAll(SetArgPointee<0>(no_delay), Return(true))) .WillOnce(DoAll(SetArgPointee<0>(no_delay), Return(true))) .WillOnce(Return(false)); EXPECT_CALL(*mock_blacklist_store_, GetCandidateForUpload(_)) .WillOnce(DoAll(SetArgPointee<0>(blacklisted_url), Return(true))) .WillOnce(DoAll(SetArgPointee<0>(blacklisted_url_alt), Return(true))); EXPECT_CALL(*mock_blacklist_store_, RemoveUrl(Eq(blacklisted_url_alt))) .WillOnce(Return(true)); EXPECT_CALL(callback, Run(_)).Times(2); // Blacklist call, first request attempt. EXPECT_TRUE(suggestions_service_->BlacklistURL(blacklisted_url)); // Wait for the first scheduling, the first request, the second scheduling, // second request and the third scheduling. Again, note that calling // RunUntilIdle on the MessageLoop only works when the task is not posted for // the future. base::RunLoop().RunUntilIdle(); SuggestionsProfile suggestions; test_suggestions_store_->LoadSuggestions(&suggestions); ASSERT_EQ(1, suggestions.suggestions_size()); EXPECT_EQ(kTestTitle, suggestions.suggestions(0).title()); EXPECT_EQ(kTestUrl, suggestions.suggestions(0).url()); EXPECT_EQ(kTestFaviconUrl, suggestions.suggestions(0).favicon_url()); } TEST_F(SuggestionsServiceTest, UndoBlacklistURL) { // Ensure scheduling the request doesn't happen before undo. const base::TimeDelta delay = base::TimeDelta::FromHours(1); suggestions_service_->set_blacklist_delay(delay); base::MockCallback<SuggestionsService::ResponseCallback> callback; auto subscription = suggestions_service_->AddCallback(callback.Get()); const GURL blacklisted_url(kBlacklistedUrl); // Blacklist expectations. EXPECT_CALL(*mock_blacklist_store_, BlacklistUrl(Eq(blacklisted_url))) .WillOnce(Return(true)); EXPECT_CALL(*mock_thumbnail_manager_, Initialize(EqualsProto(CreateSuggestionsProfile()))) .Times(AnyNumber()); EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)).Times(AnyNumber()); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(DoAll(SetArgPointee<0>(delay), Return(true))); // Undo expectations. EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilURLReadyForUpload(Eq(blacklisted_url), _)) .WillOnce(DoAll(SetArgPointee<1>(delay), Return(true))); EXPECT_CALL(*mock_blacklist_store_, RemoveUrl(Eq(blacklisted_url))) .WillOnce(Return(true)); EXPECT_CALL(callback, Run(_)).Times(2); EXPECT_TRUE(suggestions_service_->BlacklistURL(blacklisted_url)); EXPECT_TRUE(suggestions_service_->UndoBlacklistURL(blacklisted_url)); } TEST_F(SuggestionsServiceTest, ClearBlacklist) { // Ensure scheduling the request doesn't happen before undo. const base::TimeDelta delay = base::TimeDelta::FromHours(1); suggestions_service_->set_blacklist_delay(delay); base::MockCallback<SuggestionsService::ResponseCallback> callback; auto subscription = suggestions_service_->AddCallback(callback.Get()); const SuggestionsProfile suggestions_profile = CreateSuggestionsProfile(); const GURL blacklisted_url(kBlacklistedUrl); factory_.SetFakeResponse( SuggestionsServiceImpl::BuildSuggestionsBlacklistClearURL(), suggestions_profile.SerializeAsString(), net::HTTP_OK, net::URLRequestStatus::SUCCESS); // Blacklist expectations. EXPECT_CALL(*mock_blacklist_store_, BlacklistUrl(Eq(blacklisted_url))) .WillOnce(Return(true)); EXPECT_CALL(*mock_thumbnail_manager_, Initialize(EqualsProto(suggestions_profile))) .Times(AnyNumber()); EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)).Times(AnyNumber()); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(DoAll(SetArgPointee<0>(delay), Return(true))); EXPECT_CALL(*mock_blacklist_store_, ClearBlacklist()); EXPECT_CALL(callback, Run(_)).Times(2); EXPECT_TRUE(suggestions_service_->BlacklistURL(blacklisted_url)); suggestions_service_->ClearBlacklist(); } TEST_F(SuggestionsServiceTest, UndoBlacklistURLFailsIfNotInBlacklist) { // Ensure scheduling the request doesn't happen before undo. const base::TimeDelta delay = base::TimeDelta::FromHours(1); suggestions_service_->set_blacklist_delay(delay); base::MockCallback<SuggestionsService::ResponseCallback> callback; auto subscription = suggestions_service_->AddCallback(callback.Get()); const GURL blacklisted_url(kBlacklistedUrl); // Blacklist expectations. EXPECT_CALL(*mock_blacklist_store_, BlacklistUrl(Eq(blacklisted_url))) .WillOnce(Return(true)); EXPECT_CALL(*mock_thumbnail_manager_, Initialize(EqualsProto(CreateSuggestionsProfile()))); EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(DoAll(SetArgPointee<0>(delay), Return(true))); // URL is not in local blacklist. EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilURLReadyForUpload(Eq(blacklisted_url), _)) .WillOnce(Return(false)); EXPECT_CALL(callback, Run(_)); EXPECT_TRUE(suggestions_service_->BlacklistURL(blacklisted_url)); EXPECT_FALSE(suggestions_service_->UndoBlacklistURL(blacklisted_url)); } TEST_F(SuggestionsServiceTest, UndoBlacklistURLFailsIfAlreadyCandidate) { // Ensure scheduling the request doesn't happen before undo. const base::TimeDelta delay = base::TimeDelta::FromHours(1); suggestions_service_->set_blacklist_delay(delay); base::MockCallback<SuggestionsService::ResponseCallback> callback; auto subscription = suggestions_service_->AddCallback(callback.Get()); const GURL blacklisted_url(kBlacklistedUrl); // Blacklist expectations. EXPECT_CALL(*mock_blacklist_store_, BlacklistUrl(Eq(blacklisted_url))) .WillOnce(Return(true)); EXPECT_CALL(*mock_thumbnail_manager_, Initialize(EqualsProto(CreateSuggestionsProfile()))); EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilReadyForUpload(_)) .WillOnce(DoAll(SetArgPointee<0>(delay), Return(true))); // URL is not yet candidate for upload. base::TimeDelta negative_delay = base::TimeDelta::FromHours(-1); EXPECT_CALL(*mock_blacklist_store_, GetTimeUntilURLReadyForUpload(Eq(blacklisted_url), _)) .WillOnce(DoAll(SetArgPointee<1>(negative_delay), Return(true))); EXPECT_CALL(callback, Run(_)); EXPECT_TRUE(suggestions_service_->BlacklistURL(blacklisted_url)); EXPECT_FALSE(suggestions_service_->UndoBlacklistURL(blacklisted_url)); } TEST_F(SuggestionsServiceTest, GetBlacklistedUrlNotBlacklistRequest) { // Not a blacklist request. std::unique_ptr<net::FakeURLFetcher> fetcher( CreateURLFetcher(GURL("http://not-blacklisting.com/a?b=c"), nullptr, "", net::HTTP_OK, net::URLRequestStatus::SUCCESS)); GURL retrieved_url; EXPECT_FALSE( SuggestionsServiceImpl::GetBlacklistedUrl(*fetcher, &retrieved_url)); } TEST_F(SuggestionsServiceTest, GetBlacklistedUrlBlacklistRequest) { // An actual blacklist request. const GURL blacklisted_url("http://blacklisted.com/a?b=c&d=e"); const std::string encoded_blacklisted_url = "http%3A%2F%2Fblacklisted.com%2Fa%3Fb%3Dc%26d%3De"; const std::string blacklist_request_prefix( SuggestionsServiceImpl::BuildSuggestionsBlacklistURLPrefix()); std::unique_ptr<net::FakeURLFetcher> fetcher(CreateURLFetcher( GURL(blacklist_request_prefix + encoded_blacklisted_url), nullptr, "", net::HTTP_OK, net::URLRequestStatus::SUCCESS)); GURL retrieved_url; EXPECT_TRUE( SuggestionsServiceImpl::GetBlacklistedUrl(*fetcher, &retrieved_url)); EXPECT_EQ(blacklisted_url, retrieved_url); } TEST_F(SuggestionsServiceTest, UpdateBlacklistDelay) { const base::TimeDelta initial_delay = suggestions_service_->blacklist_delay(); // Delay unchanged on success. suggestions_service_->UpdateBlacklistDelay(true); EXPECT_EQ(initial_delay, suggestions_service_->blacklist_delay()); // Delay increases on failure. suggestions_service_->UpdateBlacklistDelay(false); EXPECT_GT(suggestions_service_->blacklist_delay(), initial_delay); // Delay resets on success. suggestions_service_->UpdateBlacklistDelay(true); EXPECT_EQ(initial_delay, suggestions_service_->blacklist_delay()); } TEST_F(SuggestionsServiceTest, CheckDefaultTimeStamps) { SuggestionsProfile suggestions = CreateSuggestionsProfileWithExpiryTimestamps(); suggestions_service_->SetDefaultExpiryTimestamp(&suggestions, kTestDefaultExpiry); EXPECT_EQ(kTestSetExpiry, suggestions.suggestions(0).expiry_ts()); EXPECT_EQ(kTestDefaultExpiry, suggestions.suggestions(1).expiry_ts()); } TEST_F(SuggestionsServiceTest, GetPageThumbnail) { const GURL test_url(kTestUrl); const GURL thumbnail_url("https://www.thumbnails.com/thumb.jpg"); base::Callback<void(const GURL&, const gfx::Image&)> dummy_callback; EXPECT_CALL(*mock_thumbnail_manager_, GetImageForURL(test_url, _)); suggestions_service_->GetPageThumbnail(test_url, dummy_callback); EXPECT_CALL(*mock_thumbnail_manager_, AddImageURL(test_url, thumbnail_url)); EXPECT_CALL(*mock_thumbnail_manager_, GetImageForURL(test_url, _)); suggestions_service_->GetPageThumbnailWithURL(test_url, thumbnail_url, dummy_callback); } } // namespace suggestions
40ee0688ee672b76ff85f7cb22e01061fdafcdd0
2d745800357af60f01885cebbdb2552505a2c73a
/src/walletdb.h
8397cf4ebffcd90463f111184606ca4e5336104d
[ "MIT" ]
permissive
Ace-Of-Fades/HOST
ac469d4347bd04e02ffbcd933c68640c6f4c9dfd
e704fa8e5f1a3a0bd9eaea14bf39aa77bd01d430
refs/heads/master
2020-06-27T20:05:35.197796
2016-12-12T18:29:20
2016-12-12T18:29:20
76,279,404
1
0
null
null
null
null
UTF-8
C++
false
false
5,853
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2016 The Bitcoin developers // Copyright (c) 2016 The HOST developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_WALLETDB_H #define BITCOIN_WALLETDB_H #include "db.h" #include "base58.h" class CKeyPool; class CAccount; class CAccountingEntry; /** Error statuses for the wallet database */ enum DBErrors { DB_LOAD_OK, DB_CORRUPT, DB_NONCRITICAL_ERROR, DB_TOO_NEW, DB_LOAD_FAIL, DB_NEED_REWRITE }; class CKeyMetadata { public: static const int CURRENT_VERSION=1; int nVersion; int64_t nCreateTime; // 0 means unknown CKeyMetadata() { SetNull(); } CKeyMetadata(int64_t nCreateTime_) { nVersion = CKeyMetadata::CURRENT_VERSION; nCreateTime = nCreateTime_; } IMPLEMENT_SERIALIZE ( READWRITE(this->nVersion); nVersion = this->nVersion; READWRITE(nCreateTime); ) void SetNull() { nVersion = CKeyMetadata::CURRENT_VERSION; nCreateTime = 0; } }; /** Access to the wallet database (wallet.dat) */ class CWalletDB : public CDB { public: CWalletDB(std::string strFilename, const char* pszMode="r+") : CDB(strFilename.c_str(), pszMode) { } private: CWalletDB(const CWalletDB&); void operator=(const CWalletDB&); public: bool WriteName(const std::string& strAddress, const std::string& strName); bool EraseName(const std::string& strAddress); bool WriteTx(uint256 hash, const CWalletTx& wtx) { nWalletDBUpdated++; return Write(std::make_pair(std::string("tx"), hash), wtx); } bool EraseTx(uint256 hash) { nWalletDBUpdated++; return Erase(std::make_pair(std::string("tx"), hash)); } bool WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata &keyMeta) { nWalletDBUpdated++; if(!Write(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta)) return false; return Write(std::make_pair(std::string("key"), vchPubKey.Raw()), vchPrivKey, false); } bool WriteCryptedKey(const CPubKey& vchPubKey, const std::vector<unsigned char>& vchCryptedSecret, const CKeyMetadata &keyMeta) { nWalletDBUpdated++; bool fEraseUnencryptedKey = true; if(!Write(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta)) return false; if (!Write(std::make_pair(std::string("ckey"), vchPubKey.Raw()), vchCryptedSecret, false)) return false; if (fEraseUnencryptedKey) { Erase(std::make_pair(std::string("key"), vchPubKey.Raw())); Erase(std::make_pair(std::string("wkey"), vchPubKey.Raw())); } return true; } bool WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey) { nWalletDBUpdated++; return Write(std::make_pair(std::string("mkey"), nID), kMasterKey, true); } bool WriteCScript(const uint160& hash, const CScript& redeemScript) { nWalletDBUpdated++; return Write(std::make_pair(std::string("cscript"), hash), redeemScript, false); } bool WriteBestBlock(const CBlockLocator& locator) { nWalletDBUpdated++; return Write(std::string("bestblock"), locator); } bool ReadBestBlock(CBlockLocator& locator) { return Read(std::string("bestblock"), locator); } bool WriteOrderPosNext(int64_t nOrderPosNext) { nWalletDBUpdated++; return Write(std::string("orderposnext"), nOrderPosNext); } bool WriteDefaultKey(const CPubKey& vchPubKey) { nWalletDBUpdated++; return Write(std::string("defaultkey"), vchPubKey.Raw()); } bool ReadPool(int64_t nPool, CKeyPool& keypool) { return Read(std::make_pair(std::string("pool"), nPool), keypool); } bool WritePool(int64_t nPool, const CKeyPool& keypool) { nWalletDBUpdated++; return Write(std::make_pair(std::string("pool"), nPool), keypool); } bool ErasePool(int64_t nPool) { nWalletDBUpdated++; return Erase(std::make_pair(std::string("pool"), nPool)); } // Settings are no longer stored in wallet.dat; these are // used only for backwards compatibility: template<typename T> bool ReadSetting(const std::string& strKey, T& value) { return Read(std::make_pair(std::string("setting"), strKey), value); } template<typename T> bool WriteSetting(const std::string& strKey, const T& value) { nWalletDBUpdated++; return Write(std::make_pair(std::string("setting"), strKey), value); } bool EraseSetting(const std::string& strKey) { nWalletDBUpdated++; return Erase(std::make_pair(std::string("setting"), strKey)); } bool WriteMinVersion(int nVersion) { return Write(std::string("minversion"), nVersion); } bool ReadAccount(const std::string& strAccount, CAccount& account); bool WriteAccount(const std::string& strAccount, const CAccount& account); private: bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry); public: bool WriteAccountingEntry(const CAccountingEntry& acentry); int64_t GetAccountCreditDebit(const std::string& strAccount); void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries); DBErrors ReorderTransactions(CWallet*); DBErrors LoadWallet(CWallet* pwallet); static bool Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys); static bool Recover(CDBEnv& dbenv, std::string filename); }; #endif // BITCOIN_WALLETDB_H
640199a49255f4e25286b2130e30fb778d107b8f
5b45c4c1fcdf9b2ba9ba312a283e8f3ea8e00f32
/FindNumbersWithSum.cpp
9bfc5f2f2eaf33d191515ebe977b7bf6af227c19
[]
no_license
Maicius/TargetOffer
d8bcf5a450e831779ab59928c38ee783ee70f42b
ac2cb9ef7e811165c3c7a798e47faa51fdfb804b
refs/heads/master
2020-08-23T00:47:26.053031
2019-11-07T04:55:01
2019-11-07T04:55:01
216,509,455
1
0
null
null
null
null
UTF-8
C++
false
false
2,234
cpp
#include<iostream> #include<vector> using namespace std; typedef vector<int> vi; class Solution { public: vector<int> FindNumbersWithSum(vector<int> array,int sum) { int low = 0, high = 1; vector<int> res; if (array.size() == 0) return res; int cur; while (low < array.size() - 2) { cur = array[low] + array[high]; if (cur == sum) { if (res.size() > 0) { int mul1 = array[low] * array[high]; int mul2 = res[0] * res[1]; if (mul1 < mul2) { res.clear(); res.push_back(array[low]); res.push_back(array[high]); } } else { res.push_back(array[low]); res.push_back(array[high]); } low++; high = low + 1; } high++; if (array[high] > sum) { low++; high = low + 1; } } return res; } /** 数列满足递增,设两个头尾两个指针i和j, 若ai + aj == sum,就是答案(相差越远乘积越小) 若ai + aj > sum,aj肯定不是答案之一(前面已得出 i 前面的数已是不可能),j -= 1 若ai + aj < sum,ai肯定不是答案之一(前面已得出 j 后面的数已是不可能),i += 1 */ vi FindNumbersWithSum2(const vi& a,int sum) { vi res; int n = a.size(); int i = 0, j = n - 1; while(i < j){ if(a[i] + a[j] == sum){ res.push_back(a[i]); res.push_back(a[j]); break; } while(i < j && a[i] + a[j] > sum) --j; while(i < j && a[i] + a[j] < sum) ++i; } return res; } }; int main() { int data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; vector<int> data1(data, data + 10); Solution *so = new Solution(); vector<int> res = so -> FindNumbersWithSum2(data1, 10); for (int i = 0; i < res.size(); i++) { cout << res[i]; } }
cc6768b0da5a77c876ad85a547ee105108ca3b7b
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/23/b341d5b7b847c9/main.cpp
30d660653249e99a0cc8d696fbdc0b0401a26b11
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
687
cpp
#include <iostream> #include <string> #include <set> #include <boost/circular_buffer.hpp> int main() { static constexpr unsigned MAX_UNDO = 5; boost::circular_buffer<std::unique_ptr<int>> m_buffer{MAX_UNDO}; m_buffer.push_back(std::make_unique<int>(10)); m_buffer.push_back(std::make_unique<int>(20)); m_buffer.push_back(std::make_unique<int>(30)); m_buffer.push_back(std::make_unique<int>(40)); m_buffer.push_back(std::make_unique<int>(50)); m_buffer.push_back(std::make_unique<int>(60)); std::for_each(m_buffer.begin(), m_buffer.end(), [](auto const& int_ptr) { std::cout << *int_ptr << '\n'; }); }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df
49ed09aeb73eb2d243a7578a03d42cc2279427ae
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function13851/function13851_schedule_7/function13851_schedule_7.cpp
0b68d4133948b8778e52ef61300f9b733ff71454
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
681
cpp
#include <tiramisu/tiramisu.h> using namespace tiramisu; int main(int argc, char **argv){ tiramisu::init("function13851_schedule_7"); constant c0("c0", 1024), c1("c1", 64), c2("c2", 1024); var i0("i0", 0, c0), i1("i1", 0, c1), i2("i2", 0, c2), i01("i01"), i02("i02"), i03("i03"), i04("i04"); computation comp0("comp0", {i0, i1, i2}, 8 + 8); comp0.tile(i0, i1, 64, 64, i01, i02, i03, i04); comp0.parallelize(i01); buffer buf0("buf0", {1024, 64, 1024}, p_int32, a_output); comp0.store_in(&buf0); tiramisu::codegen({&buf0}, "../data/programs/function13851/function13851_schedule_7/function13851_schedule_7.o"); return 0; }
11731d28005862d84d909ec7769583571fb1bad9
12d64b16d0735eb156f4cc4c93492c29ec70a9d9
/include/Audio.h
990c0bec966a927c86cfc7201f06c7b773803891
[]
no_license
blinkkin/ia
72e83e0009b5b3a4f80c1d93605584b6047a22ad
661f9143babf98fc099eb0d3bada74ca8ee056b7
refs/heads/master
2021-01-19T23:41:32.621996
2013-11-26T22:32:43
2013-11-26T22:32:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
820
h
#ifndef AUDIO_H #define AUDIO_H #include "SDL/SDL_mixer.h" #include "CommonTypes.h" #include "AudioIds.h" class Engine; using namespace std; class Audio { public: Audio(Engine* engine); ~Audio(); void initAndClearPrev(); //Returns channel playing on int play(const Sfx_t sfx, const int VOL_PERCENT_TOT = 100, const int VOL_PERCENT_L = 50); void playFromDir(const Sfx_t sfx, const Dir_t dir, const int DISTANCE_PERCENT); void tryPlayAmb(const int ONE_IN_N_CHANCE_TO_PLAY); void fadeOutChannel(const int CHANNEL_NR); private: Sfx_t getAmbSfxSuitableForDlvl() const; void loadAudioFile(const Sfx_t sfx, const string& filename); void freeAssets(); int curChannel; Mix_Chunk* audioChunks[endOfSfx]; int timeAtLastAmb; Engine* eng; }; #endif
795c8aab92640f0efd4c556edf5f4cc16d78a00e
af1d419ab26ed699557eda12adfabe79b1ef9c9f
/Final/relativepose/median.cc
3e6ac7e543ac0ceb4ecb3ade00313f996935b104
[]
no_license
smclemo/ARdroneUAV
a39704a5224f279cbae81c983106ce69afaef6be
a402f2d7f8c475b6806abdb2874eaa36f3314a34
refs/heads/master
2020-04-16T17:37:57.185940
2012-11-12T02:29:22
2012-11-12T02:29:22
3,686,507
4
2
null
null
null
null
UTF-8
C++
false
false
437
cc
/* * median.cc * * Created on: 22/02/2012 * Author: winston */ #include "median.h" #include <algorithm> TooN::Vector<2> findMedian(std::vector<TooN::Vector<2> > &in) { size_t const n = in.size()/2; std::nth_element(in.begin(), in.begin() + n, in.end(), cmpl_Linf); return in[n]; } bool cmpl_Linf(TooN::Vector<2> const & lhs, TooN::Vector<2> const &rhs) { return std::max(lhs[0],lhs[1]) < std::max(rhs[0], rhs[1]); }
ff38cdfaa181afc6203c2977c19d02439c503d66
3387244856041685a94b72264d41a80ae35c3f80
/source/TowerEnergyBomb.cpp
6569d37697608bfe080bcee5e39d142330e67a54
[]
no_license
kinfung0602/ogre-tower-defense
768c9ae0c0972379cfbddf91361cf343b8c76dfb
ce950d36b49ea46e294d936f3cd363bcc73c8468
refs/heads/master
2021-01-10T08:22:05.424893
2011-07-11T01:32:05
2011-07-11T01:32:05
53,152,007
0
0
null
null
null
null
UTF-8
C++
false
false
7,432
cpp
#include "TowerEnergyBomb.h" #include <OgreStringConverter.h> #include <OgreSceneManager.h> #include <OgreSceneNode.h> #include <OgreEntity.h> #include "TowerFactory.h" #include "Common.h" #include "AlienFactory.h" // :TEMP: TowerEnergyBomb::TowerEnergyBomb(TowerBase* parent) : Tower(parent, "EnergyBomb", OFFENSIVE), mShotSpeed(200.0f) { mpShotGraphics = NULL; mpShotNode = NULL; setRange(1500.0f); setAttackSpeed(0.25f); mAtkPower = 20.0f; mSquaredTargetTolerance = 1; mShooting = false; } TowerEnergyBomb::~TowerEnergyBomb(void) { printf("~TowerEnergyBomb\n"); if (mpShotGraphics) { // Remove from scene node if (mpShotNode) { mpShotNode->removeAndDestroyAllChildren(); mpShotNode->getParentSceneNode()->removeChild(mpShotNode); mpsSceneMgr->destroySceneNode(mpShotNode); mpShotNode = NULL; } // Destroy shot graphics mpsSceneMgr->destroyEntity(mpShotGraphics); mpShotGraphics = NULL; } } void TowerEnergyBomb::upgrade(void) { if (mLevel < 3) { mValue += TowerFactory::getSingleton().getUpgradeCost(mType, mLevel); mLevel++; // Adjust the scale of the tower based on its level Ogre::Real sy = 1.0f; if (mLevel == 2) sy = 1.25f; else if (mLevel == 3) sy = 1.5f; mpNode->setScale(1.0f, sy, 1.0f); } } void TowerEnergyBomb::sell(void) { } bool TowerEnergyBomb::createGraphics(void) { bool retval = false; if (mpsSceneMgr) { mMaterialName = "Material/Tower/EnergyBomb"; // Create simple graphics retval = createSimpleGraphics(mStrUid); // Create shot graphics if (retval) { mpShotGraphics = mpsSceneMgr->createEntity("Tower/ShotGraphics_" + mStrUid, Ogre::SceneManager::PT_SPHERE); mpShotGraphics->setMaterialName("Material/Tower/EnergyBomb"); mpShotGraphics->setQueryFlags(0); mpShotGraphics->setVisible(false); // :TODO: height of node shouldn't be hard coded mpShotNode = mpNode->createChildSceneNode(Ogre::Vector3(0, 60, 0)); mpShotNode->setScale(0.1, 0.1, 0.1); mpShotNode->attachObject(mpShotGraphics); } } return retval; } void TowerEnergyBomb::update(float t) { static const float sShotFadeOut = 0.05f; mTimeSinceLastAction += t; if (mTimeSinceLastAction >= 1.0f/mAtkSpeed) { Alien* alien = NULL; // Get the highest priority target that is within range of this tower unsigned int id = getHighestPriorityTarget(); if (id != -1 && (alien = AlienFactory::getSingleton().getAlien(id)) != NULL) { Ogre::Vector3 alienPos = alien->getPosition() + Ogre::Vector3(0, alien->getCenterOffset(), 0); // Calculate how long it's going to take for the bomb to reach that position float t = mpShotNode->_getDerivedPosition().distance(alienPos) / mShotSpeed; // d = rt // r = d/t // t = d/r // Calculate how far the alien is going to move in that time float dist = alien->getWalkSpeed() * t; // Estimate where the alien is going to be at that time //mShotTarget = alienPos + (alien->getDirection() * dist); bool valid; mShotTarget = getShotTarget(alienPos, alien->getDirection() * alien->getWalkSpeed(), valid); // The target's position needs to be relative to the shot graphics. //mShotTarget = mShotTarget - mpShotNode->_getDerivedPosition(); std::cout << "Shot target = (" << Ogre::StringConverter::toString(mShotTarget) << ")\n"; // << std::end; // Update the ends of the shot graphics mpShotGraphics->setVisible(true); mShooting = true; // Reset the time since last action mTimeSinceLastAction = 0; } else { // If no alien was targeted, hide the shot graphics mpShotGraphics->setVisible(false); } } else if (mShooting) { // Calculate the new position of the shot graphics const Ogre::Vector3& pos = mpShotNode->_getDerivedPosition(); Ogre::Vector3 dir = mShotTarget - pos; Ogre::Vector3 newPos = mpShotNode->getPosition() + (dir.normalisedCopy() * mShotSpeed * t); bool reachedTarget = false; // See if we're within the tollerance to the target node if ((mShotTarget - pos).squaredLength() < mSquaredTargetTolerance) { reachedTarget = true; } // See if we just over shot the target (low FPS may cause this) else if (sign(mShotTarget.x - pos.x) != sign(mShotTarget.x - newPos.x) && sign(mShotTarget.z - pos.z) != sign(mShotTarget.z - newPos.z)) { reachedTarget = true; // Update the shot graphics' position with the target position mpShotNode->setPosition(mShotTarget); } else { mpShotNode->setPosition(newPos); } // If the graphics reached its target this frame, do damage and hide the graphics if (reachedTarget) { // Need to update getTargetsInRange to take a position and range instead of just // using the tower's position and range. UIntVector targetIds = getTargetsInRange(); // Damage all aliens in the blast area for (size_t i = 0; i < targetIds.size(); ++i) { unsigned int id = targetIds[i]; Alien* alien = AlienFactory::getSingleton().getAlien(id); if (alien) alien->damage(mAtkPower/mAtkSpeed); } // Stop shooting mpShotNode->setVisible(false); mpShotNode->setPosition(0, 60, 0); // reset position mShooting = false; } } //else if (mTimeSinceLastAction >= sShotFadeOut) //{ // // Hide the shot graphics after the shot fadeout periods // mpShotGraphics->setVisible(false); //} } Ogre::Vector3 TowerEnergyBomb::getShotTarget(const Ogre::Vector3& targetPos, const Ogre::Vector3& targetVel, bool& valid) { const int maxIts = 100; // Minimum Time is if the target is moving toward the tower float minTime = targetPos.length() / (targetVel.length() + mShotSpeed); // Maximum Time is if the target is moving away from the tower (avoid divide by 0) float maxTime = (abs(mShotSpeed - targetVel.length()) > 0.0001) ? (targetPos.length() / (mShotSpeed - targetVel.length())) : (0); if (maxTime < 0) maxTime = 0; float t = (minTime + maxTime)/2.0f; float dist; float accuracy = 1.0f; float inc = t / 2.0f; int its = 0; Ogre::Vector3 newPos; do { its++; //update the targets Postion at time (t) newPos = targetPos + (targetVel*t); dist = newPos.length();; // If the distance is greater than what the projectile would travel // in time t, increase t if (dist > mShotSpeed * t) { t = t + inc; inc = inc / 2.0f; } // If the distance is less than what the projectile would travel // in time t, decrease t else if (dist < mShotSpeed * t) { t = t - inc; inc = inc / 2.0f; } } while(its < maxIts && abs(dist - mShotSpeed * t) > accuracy); // If we exceeded the max iterations, odds are the projectile will // never reach the target, so return false if (its >= maxIts) { valid = false; return Ogre::Vector3::ZERO; } // Return the point where the target will be at time t valid = true; return targetPos + (targetVel*t); }
dadee0e03c403db78604667e8e327ccb6a4151c9
f8693e34af59381fe55e3021caf2f26e92983c4a
/src/rpc/net.cpp
047dd0e6f667226ffa64f40af2311e36b273c71b
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
antonjuniordev/DonCoin
8165d6cea2602fd9ac0728e4908b51e730dd606e
b4951f591d61d7d929f17eb98e52954fef3c2035
refs/heads/master
2021-08-06T06:30:10.705476
2017-11-03T15:51:17
2017-11-03T15:51:17
107,980,292
0
0
null
null
null
null
UTF-8
C++
false
false
28,978
cpp
// Copyright (c) 2009-2017 The Bitcoin Core developers // Copyright (c) 2017-2017 The Bitcore Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "rpc/server.h" #include "chainparams.h" #include "clientversion.h" #include "validation.h" #include "net.h" #include "net_processing.h" #include "netbase.h" #include "policy/policy.h" #include "protocol.h" #include "sync.h" #include "timedata.h" #include "ui_interface.h" #include "util.h" #include "utilstrencodings.h" #include "version.h" #include <boost/foreach.hpp> #include <univalue.h> using namespace std; UniValue getconnectioncount(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw runtime_error( "getconnectioncount\n" "\nReturns the number of connections to other nodes.\n" "\nResult:\n" "n (numeric) The connection count\n" "\nExamples:\n" + HelpExampleCli("getconnectioncount", "") + HelpExampleRpc("getconnectioncount", "") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); return (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL); } UniValue ping(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw runtime_error( "ping\n" "\nRequests that a ping be sent to all other nodes, to measure ping time.\n" "Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n" "Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.\n" "\nExamples:\n" + HelpExampleCli("ping", "") + HelpExampleRpc("ping", "") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); // Request that each node send a ping during next message processing pass g_connman->ForEachNode([](CNode* pnode) { pnode->fPingQueued = true; }); return NullUniValue; } UniValue getpeerinfo(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw runtime_error( "getpeerinfo\n" "\nReturns data about each connected network node as a json array of objects.\n" "\nResult:\n" "[\n" " {\n" " \"id\": n, (numeric) Peer index\n" " \"addr\":\"host:port\", (string) The ip address and port of the peer\n" " \"addrlocal\":\"ip:port\", (string) local address\n" " \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n" " \"relaytxes\":true|false, (boolean) Whether peer has asked us to relay transactions to it\n" " \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n" " \"lastrecv\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive\n" " \"bytessent\": n, (numeric) The total bytes sent\n" " \"bytesrecv\": n, (numeric) The total bytes received\n" " \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n" " \"timeoffset\": ttt, (numeric) The time offset in seconds\n" " \"pingtime\": n, (numeric) ping time (if available)\n" " \"minping\": n, (numeric) minimum observed ping time (if any at all)\n" " \"pingwait\": n, (numeric) ping wait (if non-zero)\n" " \"version\": v, (numeric) The peer version, such as 7001\n" " \"subver\": \"/Satoshi:0.8.5/\", (string) The string version\n" " \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n" " \"addnode\": true|false, (boolean) Whether connection was due to addnode and is using an addnode slot\n" " \"startingheight\": n, (numeric) The starting height (block) of the peer\n" " \"banscore\": n, (numeric) The ban score\n" " \"synced_headers\": n, (numeric) The last header we have in common with this peer\n" " \"synced_blocks\": n, (numeric) The last block we have in common with this peer\n" " \"inflight\": [\n" " n, (numeric) The heights of blocks we're currently asking from this peer\n" " ...\n" " ],\n" " \"whitelisted\": true|false, (boolean) Whether the peer is whitelisted\n" " \"bytessent_per_msg\": {\n" " \"addr\": n, (numeric) The total bytes sent aggregated by message type\n" " ...\n" " },\n" " \"bytesrecv_per_msg\": {\n" " \"addr\": n, (numeric) The total bytes received aggregated by message type\n" " ...\n" " }\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("getpeerinfo", "") + HelpExampleRpc("getpeerinfo", "") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); vector<CNodeStats> vstats; g_connman->GetNodeStats(vstats); UniValue ret(UniValue::VARR); BOOST_FOREACH(const CNodeStats& stats, vstats) { UniValue obj(UniValue::VOBJ); CNodeStateStats statestats; bool fStateStats = GetNodeStateStats(stats.nodeid, statestats); obj.push_back(Pair("id", stats.nodeid)); obj.push_back(Pair("addr", stats.addrName)); if (!(stats.addrLocal.empty())) obj.push_back(Pair("addrlocal", stats.addrLocal)); obj.push_back(Pair("services", strprintf("%016x", stats.nServices))); obj.push_back(Pair("relaytxes", stats.fRelayTxes)); obj.push_back(Pair("lastsend", stats.nLastSend)); obj.push_back(Pair("lastrecv", stats.nLastRecv)); obj.push_back(Pair("bytessent", stats.nSendBytes)); obj.push_back(Pair("bytesrecv", stats.nRecvBytes)); obj.push_back(Pair("conntime", stats.nTimeConnected)); obj.push_back(Pair("timeoffset", stats.nTimeOffset)); if (stats.dPingTime > 0.0) obj.push_back(Pair("pingtime", stats.dPingTime)); if (stats.dMinPing < std::numeric_limits<int64_t>::max()/1e6) obj.push_back(Pair("minping", stats.dMinPing)); if (stats.dPingWait > 0.0) obj.push_back(Pair("pingwait", stats.dPingWait)); obj.push_back(Pair("version", stats.nVersion)); // Use the sanitized form of subver here, to avoid tricksy remote peers from // corrupting or modifying the JSON output by putting special characters in // their ver message. obj.push_back(Pair("subver", stats.cleanSubVer)); obj.push_back(Pair("inbound", stats.fInbound)); obj.push_back(Pair("addnode", stats.fAddnode)); obj.push_back(Pair("startingheight", stats.nStartingHeight)); if (fStateStats) { obj.push_back(Pair("banscore", statestats.nMisbehavior)); obj.push_back(Pair("synced_headers", statestats.nSyncHeight)); obj.push_back(Pair("synced_blocks", statestats.nCommonHeight)); UniValue heights(UniValue::VARR); BOOST_FOREACH(int height, statestats.vHeightInFlight) { heights.push_back(height); } obj.push_back(Pair("inflight", heights)); } obj.push_back(Pair("whitelisted", stats.fWhitelisted)); UniValue sendPerMsgCmd(UniValue::VOBJ); BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapSendBytesPerMsgCmd) { if (i.second > 0) sendPerMsgCmd.push_back(Pair(i.first, i.second)); } obj.push_back(Pair("bytessent_per_msg", sendPerMsgCmd)); UniValue recvPerMsgCmd(UniValue::VOBJ); BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapRecvBytesPerMsgCmd) { if (i.second > 0) recvPerMsgCmd.push_back(Pair(i.first, i.second)); } obj.push_back(Pair("bytesrecv_per_msg", recvPerMsgCmd)); ret.push_back(obj); } return ret; } UniValue addnode(const JSONRPCRequest& request) { string strCommand; if (request.params.size() == 2) strCommand = request.params[1].get_str(); if (request.fHelp || request.params.size() != 2 || (strCommand != "onetry" && strCommand != "add" && strCommand != "remove")) throw runtime_error( "addnode \"node\" \"add|remove|onetry\"\n" "\nAttempts add or remove a node from the addnode list.\n" "Or try a connection to a node once.\n" "\nArguments:\n" "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n" "2. \"command\" (string, required) 'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once\n" "\nExamples:\n" + HelpExampleCli("addnode", "\"192.168.0.6:8555\" \"onetry\"") + HelpExampleRpc("addnode", "\"192.168.0.6:8555\", \"onetry\"") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); string strNode = request.params[0].get_str(); if (strCommand == "onetry") { CAddress addr; g_connman->OpenNetworkConnection(addr, false, NULL, strNode.c_str()); return NullUniValue; } if (strCommand == "add") { if(!g_connman->AddNode(strNode)) throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Node already added"); } else if(strCommand == "remove") { if(!g_connman->RemoveAddedNode(strNode)) throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added."); } return NullUniValue; } UniValue disconnectnode(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "disconnectnode \"address\" \n" "\nImmediately disconnects from the specified node.\n" "\nArguments:\n" "1. \"address\" (string, required) The node (see address/port of the node)\n" + HelpExampleCli("disconnectnode", "\"192.168.0.6:8555\"") + HelpExampleRpc("disconnectnode", "\"192.168.0.6:8555\"") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); bool ret = g_connman->DisconnectNode(request.params[0].get_str()); if (!ret) throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes"); return NullUniValue; } UniValue getaddednodeinfo(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() > 1) throw runtime_error( "getaddednodeinfo ( \"node\" )\n" "\nReturns information about the given added node, or all added nodes\n" "(note that onetry addnodes are not listed here)\n" "\nArguments:\n" "1. \"node\" (string, optional) If provided, return information about this specific node, otherwise all nodes are returned.\n" "\nResult:\n" "[\n" " {\n" " \"addednode\" : \"192.168.0.201\", (string) The node ip address or name (as provided to addnode)\n" " \"connected\" : true|false, (boolean) If connected\n" " \"addresses\" : [ (list of objects) Only when connected = true\n" " {\n" " \"address\" : \"192.168.0.201:8555\", (string) The doncoin server IP and port we're connected to\n" " \"connected\" : \"outbound\" (string) connection, inbound or outbound\n" " }\n" " ]\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("getaddednodeinfo", "true") + HelpExampleCli("getaddednodeinfo", "true \"192.168.0.201\"") + HelpExampleRpc("getaddednodeinfo", "true, \"192.168.0.201\"") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); std::vector<AddedNodeInfo> vInfo = g_connman->GetAddedNodeInfo(); if (request.params.size() == 1) { bool found = false; for (const AddedNodeInfo& info : vInfo) { if (info.strAddedNode == request.params[0].get_str()) { vInfo.assign(1, info); found = true; break; } } if (!found) { throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added."); } } UniValue ret(UniValue::VARR); for (const AddedNodeInfo& info : vInfo) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("addednode", info.strAddedNode)); obj.push_back(Pair("connected", info.fConnected)); UniValue addresses(UniValue::VARR); if (info.fConnected) { UniValue address(UniValue::VOBJ); address.push_back(Pair("address", info.resolvedAddress.ToString())); address.push_back(Pair("connected", info.fInbound ? "inbound" : "outbound")); addresses.push_back(address); } obj.push_back(Pair("addresses", addresses)); ret.push_back(obj); } return ret; } UniValue getnettotals(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() > 0) throw runtime_error( "getnettotals\n" "\nReturns information about network traffic, including bytes in, bytes out,\n" "and current time.\n" "\nResult:\n" "{\n" " \"totalbytesrecv\": n, (numeric) Total bytes received\n" " \"totalbytessent\": n, (numeric) Total bytes sent\n" " \"timemillis\": t, (numeric) Current UNIX time in milliseconds\n" " \"uploadtarget\":\n" " {\n" " \"timeframe\": n, (numeric) Length of the measuring timeframe in seconds\n" " \"target\": n, (numeric) Target in bytes\n" " \"target_reached\": true|false, (boolean) True if target is reached\n" " \"serve_historical_blocks\": true|false, (boolean) True if serving historical blocks\n" " \"bytes_left_in_cycle\": t, (numeric) Bytes left in current time cycle\n" " \"time_left_in_cycle\": t (numeric) Seconds left in current time cycle\n" " }\n" "}\n" "\nExamples:\n" + HelpExampleCli("getnettotals", "") + HelpExampleRpc("getnettotals", "") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("totalbytesrecv", g_connman->GetTotalBytesRecv())); obj.push_back(Pair("totalbytessent", g_connman->GetTotalBytesSent())); obj.push_back(Pair("timemillis", GetTimeMillis())); UniValue outboundLimit(UniValue::VOBJ); outboundLimit.push_back(Pair("timeframe", g_connman->GetMaxOutboundTimeframe())); outboundLimit.push_back(Pair("target", g_connman->GetMaxOutboundTarget())); outboundLimit.push_back(Pair("target_reached", g_connman->OutboundTargetReached(false))); outboundLimit.push_back(Pair("serve_historical_blocks", !g_connman->OutboundTargetReached(true))); outboundLimit.push_back(Pair("bytes_left_in_cycle", g_connman->GetOutboundTargetBytesLeft())); outboundLimit.push_back(Pair("time_left_in_cycle", g_connman->GetMaxOutboundTimeLeftInCycle())); obj.push_back(Pair("uploadtarget", outboundLimit)); return obj; } static UniValue GetNetworksInfo() { UniValue networks(UniValue::VARR); for(int n=0; n<NET_MAX; ++n) { enum Network network = static_cast<enum Network>(n); if(network == NET_UNROUTABLE) continue; proxyType proxy; UniValue obj(UniValue::VOBJ); GetProxy(network, proxy); obj.push_back(Pair("name", GetNetworkName(network))); obj.push_back(Pair("limited", IsLimited(network))); obj.push_back(Pair("reachable", IsReachable(network))); obj.push_back(Pair("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())); obj.push_back(Pair("proxy_randomize_credentials", proxy.randomize_credentials)); networks.push_back(obj); } return networks; } UniValue getnetworkinfo(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw runtime_error( "getnetworkinfo\n" "Returns an object containing various state info regarding P2P networking.\n" "\nResult:\n" "{\n" " \"version\": xxxxx, (numeric) the server version\n" " \"subversion\": \"/Satoshi:x.x.x/\", (string) the server subversion string\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n" " \"localrelay\": true|false, (bool) true if transaction relay is requested from peers\n" " \"timeoffset\": xxxxx, (numeric) the time offset\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"networkactive\": true|false, (bool) whether p2p networking is enabled\n" " \"networks\": [ (array) information per network\n" " {\n" " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n" " \"limited\": true|false, (boolean) is the network limited using -onlynet?\n" " \"reachable\": true|false, (boolean) is the network reachable?\n" " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n" " \"proxy_randomize_credentials\": true|false, (string) Whether randomized credentials are used\n" " }\n" " ,...\n" " ],\n" " \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for non-free transactions in " + CURRENCY_UNIT + "/kB\n" " \"incrementalfee\": x.xxxxxxxx, (numeric) minimum fee increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kB\n" " \"localaddresses\": [ (array) list of local addresses\n" " {\n" " \"address\": \"xxxx\", (string) network address\n" " \"port\": xxx, (numeric) network port\n" " \"score\": xxx (numeric) relative score\n" " }\n" " ,...\n" " ]\n" " \"warnings\": \"...\" (string) any network warnings\n" "}\n" "\nExamples:\n" + HelpExampleCli("getnetworkinfo", "") + HelpExampleRpc("getnetworkinfo", "") ); LOCK(cs_main); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("version", CLIENT_VERSION)); obj.push_back(Pair("subversion", strSubVersion)); obj.push_back(Pair("protocolversion",PROTOCOL_VERSION)); if(g_connman) obj.push_back(Pair("localservices", strprintf("%016x", g_connman->GetLocalServices()))); obj.push_back(Pair("localrelay", fRelayTxes)); obj.push_back(Pair("timeoffset", GetTimeOffset())); if (g_connman) { obj.push_back(Pair("networkactive", g_connman->GetNetworkActive())); obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL))); } obj.push_back(Pair("networks", GetNetworksInfo())); obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()))); UniValue localAddresses(UniValue::VARR); { LOCK(cs_mapLocalHost); BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost) { UniValue rec(UniValue::VOBJ); rec.push_back(Pair("address", item.first.ToString())); rec.push_back(Pair("port", item.second.nPort)); rec.push_back(Pair("score", item.second.nScore)); localAddresses.push_back(rec); } } obj.push_back(Pair("localaddresses", localAddresses)); obj.push_back(Pair("warnings", GetWarnings("statusbar"))); return obj; } UniValue setban(const JSONRPCRequest& request) { string strCommand; if (request.params.size() >= 2) strCommand = request.params[1].get_str(); if (request.fHelp || request.params.size() < 2 || (strCommand != "add" && strCommand != "remove")) throw runtime_error( "setban \"subnet\" \"add|remove\" (bantime) (absolute)\n" "\nAttempts add or remove a IP/Subnet from the banned list.\n" "\nArguments:\n" "1. \"subnet\" (string, required) The IP/Subnet (see getpeerinfo for nodes ip) with a optional netmask (default is /32 = single ip)\n" "2. \"command\" (string, required) 'add' to add a IP/Subnet to the list, 'remove' to remove a IP/Subnet from the list\n" "3. \"bantime\" (numeric, optional) time in seconds how long (or until when if [absolute] is set) the ip is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)\n" "4. \"absolute\" (boolean, optional) If set, the bantime must be a absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n" "\nExamples:\n" + HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400") + HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"") + HelpExampleRpc("setban", "\"192.168.0.6\", \"add\", 86400") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); CSubNet subNet; CNetAddr netAddr; bool isSubnet = false; if (request.params[0].get_str().find("/") != string::npos) isSubnet = true; if (!isSubnet) { CNetAddr resolved; LookupHost(request.params[0].get_str().c_str(), resolved, false); netAddr = resolved; } else LookupSubNet(request.params[0].get_str().c_str(), subNet); if (! (isSubnet ? subNet.IsValid() : netAddr.IsValid()) ) throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Invalid IP/Subnet"); if (strCommand == "add") { if (isSubnet ? g_connman->IsBanned(subNet) : g_connman->IsBanned(netAddr)) throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: IP/Subnet already banned"); int64_t banTime = 0; //use standard bantime if not specified if (request.params.size() >= 3 && !request.params[2].isNull()) banTime = request.params[2].get_int64(); bool absolute = false; if (request.params.size() == 4 && request.params[3].isTrue()) absolute = true; isSubnet ? g_connman->Ban(subNet, BanReasonManuallyAdded, banTime, absolute) : g_connman->Ban(netAddr, BanReasonManuallyAdded, banTime, absolute); } else if(strCommand == "remove") { if (!( isSubnet ? g_connman->Unban(subNet) : g_connman->Unban(netAddr) )) throw JSONRPCError(RPC_MISC_ERROR, "Error: Unban failed"); } return NullUniValue; } UniValue listbanned(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw runtime_error( "listbanned\n" "\nList all banned IPs/Subnets.\n" "\nExamples:\n" + HelpExampleCli("listbanned", "") + HelpExampleRpc("listbanned", "") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); banmap_t banMap; g_connman->GetBanned(banMap); UniValue bannedAddresses(UniValue::VARR); for (banmap_t::iterator it = banMap.begin(); it != banMap.end(); it++) { CBanEntry banEntry = (*it).second; UniValue rec(UniValue::VOBJ); rec.push_back(Pair("address", (*it).first.ToString())); rec.push_back(Pair("banned_until", banEntry.nBanUntil)); rec.push_back(Pair("ban_created", banEntry.nCreateTime)); rec.push_back(Pair("ban_reason", banEntry.banReasonToString())); bannedAddresses.push_back(rec); } return bannedAddresses; } UniValue clearbanned(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw runtime_error( "clearbanned\n" "\nClear all banned IPs.\n" "\nExamples:\n" + HelpExampleCli("clearbanned", "") + HelpExampleRpc("clearbanned", "") ); if(!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); g_connman->ClearBanned(); return NullUniValue; } UniValue setnetworkactive(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 1) { throw runtime_error( "setnetworkactive true|false\n" "\nDisable/enable all p2p network activity.\n" "\nArguments:\n" "1. \"state\" (boolean, required) true to enable networking, false to disable\n" ); } if (!g_connman) { throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); } g_connman->SetNetworkActive(request.params[0].get_bool()); return g_connman->GetNetworkActive(); } static const CRPCCommand commands[] = { // category name actor (function) okSafeMode // --------------------- ------------------------ ----------------------- ---------- { "network", "getconnectioncount", &getconnectioncount, true, {} }, { "network", "ping", &ping, true, {} }, { "network", "getpeerinfo", &getpeerinfo, true, {} }, { "network", "addnode", &addnode, true, {"node","command"} }, { "network", "disconnectnode", &disconnectnode, true, {"address"} }, { "network", "getaddednodeinfo", &getaddednodeinfo, true, {"node"} }, { "network", "getnettotals", &getnettotals, true, {} }, { "network", "getnetworkinfo", &getnetworkinfo, true, {} }, { "network", "setban", &setban, true, {"subnet", "command", "bantime", "absolute"} }, { "network", "listbanned", &listbanned, true, {} }, { "network", "clearbanned", &clearbanned, true, {} }, { "network", "setnetworkactive", &setnetworkactive, true, {"state"} }, }; void RegisterNetRPCCommands(CRPCTable &t) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) t.appendCommand(commands[vcidx].name, &commands[vcidx]); }
be63efd76da410438d94c635dd88bd845be9ca90
9f8a532b212c75d5635e2f5fb35e893b9ece2bcb
/Demos/Pysics/Physics Stuff/Physics Stuff/ISE-Demo/AssetMng.h
2fb33df6b697b1c27ab79218f4e6e98312ba5440
[]
no_license
Brandon-Ashworth/Physics-Simulation
021ea735eef5e4ac83af3aa1b48b1e055d795298
ed7e914669212aaacf97285b35d104df39b76459
refs/heads/master
2020-05-29T18:49:52.840330
2016-08-07T13:25:30
2016-08-07T13:25:30
46,367,232
0
0
null
null
null
null
UTF-8
C++
false
false
2,067
h
#pragma once #include <string> #include <functional> #include <map> #include "VAO.h" #include "objLoader.h" #include "Texture.h" #include "Sound.h" /** * @brief This class stores and manages all the assets in the engine * @details It takes in all Assets and loads them in, it will then take in the asset and only load it once. when asked for data it will return the same data if the request is the same. * * @author Umar Badat * @bug This function does not use the best of design, it could be easier to expand with the use of factories. */ class AssetMng { public: AssetMng(void); ~AssetMng(void); enum AS_TYPE { AS_TEXTURE = 0, AS_OBJ, AS_SOUND }; /** * @brief Load in an asset from a file location * @details A file is specified along with its asset type (texture, object or sound) * an AS_TYPE is passed in to specify the type, while the string is for the location. * This class checks to see if it exists to ensure assets are only loaded once. * * @param E AS_TYPE specifying what kind of data structure is waiting for it * @param location the relative file location, and it is also the name */ void Load(AS_TYPE,std::string location); /** * @brief gets a VAO of the data with that string as its name * @details Takes in a string of the name and gives back a common data struxture * * @param location String, This is both the location and the name * @param data VAO, a data structure that we will assign the data to. */ void getData(std::string location,VAO &data); /** * @brief Get the texture associated with that file location (name) * * * @param location String, both the name and location of the file you want the data from * @param text a place for us to assign the data you want */ //void getData(std::string location, Texture &text); void getData(std::string location); Sound* getData(std::string location, AS_TYPE type); private: std::map<int,VAO> object; std::map<int,Texture*> texture; std::map<int,Sound> sounds; Error err; std::hash<std::string> strToInt; };
f72fd4956465d1107890175b7980cb20f8338451
3b701b21a412ee1b3d1b496675b886e9d402efa9
/src/LevelFactory.h
22ff9a50aa1e742e21b9f28774db09032cac4a09
[]
no_license
andrea-corradetti/carGame
bdcaa9f2d22ce9afdba44ad3ebb3b0c015ac383c
cc345b7ffc084bd3334c270b1b857ce3eafd9b93
refs/heads/main
2023-03-14T02:34:24.923208
2021-03-08T11:42:13
2021-03-08T11:42:13
324,536,030
0
0
null
null
null
null
UTF-8
C++
false
false
690
h
// // Created by Andrea on 01/02/2021. // #ifndef UNTITLEDCARGAME_LEVELFACTORY_H #define UNTITLEDCARGAME_LEVELFACTORY_H #include <random> #include "Level.h" class LevelFactory { public: LevelFactory(); Level* previousLevel(); Level* nextLevel(); void resetLevels(); void updateLevel(int score); Level* currentLevel; unsigned int getCurrentLevelNo() const; private: Level* createLevel(unsigned int seed); int currentLevelNo; std::mt19937 randGen; //pseudo random generator std::random_device randDev; //generates random numbers based on hardware state std::vector<Level*> generatedLevels; }; #endif //UNTITLEDCARGAME_LEVELFACTORY_H
3a329058eb057cff7601bf3093fe75c14cacf139
043f873d808df18dddee13f10c4d07e8ea81ef6e
/DesignPattern/Abstract Factory Pattern/Abstract Factory Pattern/Square.h
dc889625a38313ab49007fdf4726167bff8ac194
[]
no_license
nguyenviettien13/CodeLearning
3e318e527601ad44f5fe99760fb6138ed48e3871
666bacd5d9a1023171f481a330712357236e0439
refs/heads/master
2021-09-25T02:30:40.795527
2018-10-16T16:01:46
2018-10-16T16:01:46
153,311,228
1
0
null
null
null
null
UTF-8
C++
false
false
130
h
#pragma once #include "Shape.h" class Square: public Shape { public: Square(); ~Square(); virtual void draw(); };
9ebeba6efaf0c8e933a10566790007899b5599e6
70a945a89b7bb2e592d0878cb1e2a0bddc4e9feb
/extensions/ndns-server-app.cpp
accd133f4b7214dde4b7459dacfa965081689b61
[]
no_license
ndncomm/ndns-scenario
645f9b1273757b82865a1395416d814537c896af
218d6cf8aabb7c354c2ef564d8f45363ed761ac5
refs/heads/master
2021-01-17T21:28:21.173537
2015-09-28T00:04:02
2015-09-28T00:04:02
43,218,812
1
1
null
2015-09-26T19:24:15
2015-09-26T19:04:16
Python
UTF-8
C++
false
false
939
cpp
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 University of California, Los Angeles * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "ndns-server-app.hpp" namespace ns3 { namespace ndn { NS_OBJECT_ENSURE_REGISTERED(NdnsServerApp); } // namespace ndn } // namespace ns3
0d25a4fe39cebc786dd2481a49ed4d94cffa910c
d3761b92329de471852bc69ebd3a4ddfe5eae321
/ArduMoto/examples/Braking/Braking.ino
718474b3b16732c99a2f4a538f4d2aa937b8788a
[]
no_license
4Robots/arduino-ardumotor-library
f915ea2a2e317783b2ab4a6bc9263df9529e6591
022237faac9c354c07f0fc2e1ae096ce8614230d
refs/heads/master
2021-01-24T20:58:15.978920
2013-10-17T13:44:26
2013-10-17T13:44:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
621
ino
// Braking.ino - Arduino sketch to show a braking example of a DC motor using the ArduMoto Shield // Copyright 2012 Jeroen Doggen ([email protected]) // // Program flow: // - start motor at 100% speed // - brake motor (motor should stop suddenly) // - set motor speed to -100% // - set motor speed to 0% (motor slows down slowly) #include <ArduMoto.h> ArduMoto Moto; void setup() { Serial.begin(115200); Moto.begin(); } void loop() { Moto.setSpeed('A',100); delay (2000); Moto.brake('A'); delay (2000); Moto.setSpeed('A',-100); delay (2000); Moto.setSpeed('A',-0); delay (2000); }
cb0efc6c522a825e659340f8d7ad00227f090e09
537f9cbeb61b12f6a6b0000d924e4c9459fbe714
/src/SimpleGraph.cpp
0d56d232605969f0de8453276f2f9fd91bd6e74b
[]
no_license
JurBartels/dbTech2
430088a76b57fdc338c4a60416deb2ff21be5154
707ebe4f8198e8d7c30eae33adbfb3a9e0a64a97
refs/heads/master
2021-04-06T01:10:04.587452
2018-04-20T13:34:03
2018-04-20T13:34:03
124,537,614
0
0
null
null
null
null
UTF-8
C++
false
false
3,130
cpp
// // Created by Nikolay Yakovets on 2018-01-31. // #include "SimpleGraph.h" SimpleGraph::SimpleGraph(uint32_t n) { setNoVertices(n); } uint32_t SimpleGraph::getNoVertices() const { return V; } void SimpleGraph::setNoVertices(uint32_t n) { V = n; adj.resize(V); } uint32_t SimpleGraph::getNoEdges() const { uint32_t sum = 0; for (const auto & l : adj) sum += l.size(); return sum; } // sort on the second item in the pair, then on the first (ascending order) bool sortPairs(const std::pair<uint32_t,uint32_t> &a, const std::pair<uint32_t,uint32_t> &b) { if (a.second < b.second) return true; if (a.second == b.second) return a.first < b.first; return false; } uint32_t SimpleGraph::getNoDistinctEdges() const { uint32_t sum = 0; for (auto sourceVec : adj) { std::sort(sourceVec.begin(), sourceVec.end(), sortPairs); uint32_t prevTarget = 0; uint32_t prevLabel = 0; bool first = true; for (const auto &labelTgtPair : sourceVec) { if (first || !(prevTarget == labelTgtPair.second && prevLabel == labelTgtPair.first)) { first = false; sum++; prevTarget = labelTgtPair.second; prevLabel = labelTgtPair.first; } } } return sum; } uint32_t SimpleGraph::getNoLabels() const { return L; } void SimpleGraph::setNoLabels(uint32_t noLabels) { L = noLabels; } void SimpleGraph::addEdge(uint32_t from, uint32_t to, uint32_t edgeLabel) { if(from >= V || to >= V || edgeLabel >= L) throw std::runtime_error(std::string("Edge data out of bounds: ") + "(" + std::to_string(from) + "," + std::to_string(to) + "," + std::to_string(edgeLabel) + ")"); adj[from].emplace_back(std::make_pair(edgeLabel, to)); //reverse_adj[to].emplace_back(std::make_pair(edgeLabel, from)); } void SimpleGraph::readFromContiguousFile(const std::string &fileName) { std::string line; std::ifstream graphFile { fileName }; std::regex edgePat (R"((\d+)\s(\d+)\s(\d+)\s\.)"); // subject predicate object . std::regex headerPat (R"((\d+),(\d+),(\d+))"); // noNodes,noEdges,noLabels // parse the header (1st line) std::getline(graphFile, line); std::smatch matches; if(std::regex_search(line, matches, headerPat)) { uint32_t noNodes = (uint32_t) std::stoul(matches[1]); uint32_t noLabels = (uint32_t) std::stoul(matches[3]); setNoVertices(noNodes); setNoLabels(noLabels); } else { throw std::runtime_error(std::string("Invalid graph header!")); } // parse edge data while(std::getline(graphFile, line)) { if(std::regex_search(line, matches, edgePat)) { uint32_t subject = (uint32_t) std::stoul(matches[1]); uint32_t predicate = (uint32_t) std::stoul(matches[2]); uint32_t object = (uint32_t) std::stoul(matches[3]); addEdge(subject, object, predicate); } } graphFile.close(); }
78e9773b23ee9b265251709bbe3d96ba21a63a24
00507ef2ec3a8a28d2c0e6a3283226cc77e79180
/Toffee Boxes/main.cpp
85d9fb9a94f8654d6a28bbefb599bcc31ec6cdbf
[]
no_license
AnandDev006/CPlusPlusCodes
bac2167fd664e665e755a1fe20b5880353055b26
7f13292f97e7089ff470152d7a893bb095a768a5
refs/heads/master
2021-08-08T13:38:27.426066
2021-05-17T14:30:47
2021-05-17T14:30:47
114,906,052
2
0
null
null
null
null
UTF-8
C++
false
false
1,939
cpp
// https://www.codechef.com/DI15R080/problems/MINMAXTF #include <bits/stdc++.h> using namespace std; map < pair< pair< int, int>, int>, int> memeTable; // For Memoization, F : ( range, numSplits) -> soln int solve( int arr[], int numSplits, int csum[], int start, int finish){ int minim = INT_MAX; if( finish < start + numSplits ) // no valid splitting possible return INT_MAX; if( numSplits == 1 ){ // split entire array into 1 piece = whole array itself // therefore sum of array elements minim = csum[finish-1] - csum[start] + arr[start]; // Memoize memeTable[ make_pair( make_pair( start, finish), numSplits)] = minim; return csum[finish-1] - csum[start] + arr[start]; } // If data already available in memo table, return that if( memeTable.find( make_pair( make_pair( start, finish), numSplits)) != memeTable.end() ) return memeTable[ make_pair( make_pair( start, finish), numSplits)]; for( int i = start ; i <= finish - (numSplits - 1) ; ++i ){ // minimum among all solns of current state // curr state solns = max( sum(A[:i]), solve_subproblem(A[i:]) ) minim = min( minim, max( csum[i] - csum[start] + arr[start], solve( arr, numSplits - 1, csum, i + 1, finish) )); } // Memoize memeTable[ make_pair( make_pair( start, finish), numSplits)] = minim; return minim; } int main(){ int inputSize, numSplits; cin >> inputSize >> numSplits; int arr[inputSize]; for( int i = 0 ; i < inputSize ; ++i ) cin >> arr[i]; int csum[inputSize] = {0}; // cumilative sum array csum[0] = arr[0]; for( int i = 1 ; i < inputSize ; ++i ) csum[i] = csum[i-1] + arr[i]; int result = solve( arr, numSplits, csum, 0, inputSize); result = result == INT_MAX ? -1 : result; cout << result << endl; return 0; }
3fdab6b0781c2c315cc0a97513d104a58698e54a
7d5b22941862884b36f111f9eddea956275b03b6
/OpenGL/Windows/_PROGRAMMABLE_/_Template/Template_Programmable.cpp
bd491eecbc17a43289daf3ac28ac110ebe7fb350
[]
no_license
blckopps/RTR_Assignments
df6d9845111a862cca7a7d03a1104acc62359c7d
6a05a2cb9c8dfef1d4313c97c48e26f5035db61e
refs/heads/master
2022-12-10T14:39:07.063238
2020-05-22T19:54:59
2020-05-22T19:54:59
295,221,570
2
0
null
null
null
null
UTF-8
C++
false
false
7,023
cpp
#include<Windows.h> #include<stdio.h> #include<GL/glew.h> #include<gl/GL.h> #pragma comment(lib,"openGL32.lib") #pragma comment(lib,"glew32.lib") #define WIN_WIDTH 800 #define WIN_HEIGHT 600 FILE *gpfile = NULL; LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); //GLOBAL VARIABLES bool bFullScreen=false; DWORD dwstyle; WINDOWPLACEMENT wpPrev={sizeof(WINDOWPLACEMENT)}; HWND ghwnd=NULL; bool gbActiveWindow=false; HDC ghdc=NULL; HGLRC ghrc=NULL; int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int iCmdShow) { //FUnction declaration int initialize(void); void display(void); //variable decl int iret=0; bool bdone=false; WNDCLASSEX wndclass; HWND hwnd; MSG msg; TCHAR szAppName[]=TEXT("MYWINDOW "); if(fopen_s(&gpfile, "log.txt","w")!=0) { MessageBox(NULL, TEXT("Cant create log"),TEXT("ERROR!!!"),MB_OK); } else { fprintf(gpfile, "log file created\n"); } wndclass.cbSize=sizeof(WNDCLASSEX); wndclass.style=CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.lpfnWndProc=WndProc; wndclass.hInstance=hInstance; wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); wndclass.lpszClassName=szAppName; wndclass.lpszMenuName=NULL; wndclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION); RegisterClassEx(&wndclass); //create window hwnd=CreateWindowEx(WS_EX_APPWINDOW, szAppName, TEXT("TEMPLATE_PROGRAMMABLE-SHUBHAM"), WS_OVERLAPPEDWINDOW |WS_CLIPCHILDREN | WS_CLIPCHILDREN |WS_VISIBLE, 100, 100, WIN_WIDTH, WIN_HEIGHT, NULL, NULL, hInstance, NULL); ghwnd=hwnd; iret=initialize(); //handling return values and create log if(iret == -1) { fprintf(gpfile,"CHoice pixel format failed!!\n"); DestroyWindow(hwnd); } else if(iret == -2) { fprintf(gpfile,"SetPixelFormat failed!! \n"); DestroyWindow(hwnd); } else if(iret == -3) { fprintf(gpfile,"create context failed\n"); DestroyWindow(hwnd); } else if(iret == -4) { fprintf(gpfile,"wgl make current failed!!\n"); DestroyWindow(hwnd); } else { fprintf(gpfile,"Initialization Successfull!!\n"); } ShowWindow(hwnd,iCmdShow); SetForegroundWindow(hwnd); SetFocus(hwnd); //call in game loop UpdateWindow(hwnd); while(bdone == false) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if(msg.message == WM_QUIT) { bdone = true; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } else { if(gbActiveWindow == true) { //here call update } display(); } } return((int)msg.wParam); } LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam) { //FUnction Declarations void resize(int ,int); void uninitialize(void); void toogle_screen(void); switch(iMsg) { case WM_KEYDOWN: switch(wParam) { case 0x46: // MessageBox(hwnd,TEXT("P BUTTON PRESSED!!"),TEXT("BUTTON P"),MB_OK); toogle_screen(); break; case VK_ESCAPE: if(bFullScreen == true) //We should exit from fullscreen and then destroy the window. { SetWindowLong(ghwnd, GWL_STYLE, dwstyle | WS_OVERLAPPEDWINDOW); SetWindowPlacement(ghwnd,&wpPrev); SetWindowPos(ghwnd, HWND_TOP, 0,0,0,0, SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE| SWP_NOOWNERZORDER); ShowCursor(TRUE); } DestroyWindow(hwnd); break; } break; case WM_SETFOCUS: gbActiveWindow = true; break; case WM_KILLFOCUS: gbActiveWindow = false; break; case WM_SIZE: resize(LOWORD(lParam),HIWORD(lParam)); break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_ERASEBKGND: return 0; case WM_DESTROY: //MessageBox(hwnd,TEXT("This is WM_DESTROY!!"),TEXT("In Wm_DESTROY"),MB_OK); uninitialize(); PostQuitMessage(0); break; } return(DefWindowProc(hwnd,iMsg,wParam,lParam)); } //User Defined Functions void toogle_screen(void) { //MONITORINFO mi; if(bFullScreen == false) { dwstyle=GetWindowLong(ghwnd, GWL_STYLE); if(dwstyle & WS_OVERLAPPEDWINDOW) { MONITORINFO mi= {sizeof(MONITORINFO)}; if(GetWindowPlacement(ghwnd, &wpPrev) && GetMonitorInfo(MonitorFromWindow(ghwnd,MONITORINFOF_PRIMARY),&mi)) { SetWindowLong(ghwnd, GWL_STYLE,dwstyle&~WS_OVERLAPPEDWINDOW); SetWindowPos(ghwnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right-mi.rcMonitor.left, mi.rcMonitor.bottom-mi.rcMonitor.top, SWP_NOZORDER | SWP_FRAMECHANGED ); } } ShowCursor(FALSE); bFullScreen=true; } else { SetWindowLong(ghwnd, GWL_STYLE, dwstyle | WS_OVERLAPPEDWINDOW); SetWindowPlacement(ghwnd,&wpPrev); SetWindowPos(ghwnd, HWND_TOP, 0,0,0,0, SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE| SWP_NOOWNERZORDER); ShowCursor(TRUE); bFullScreen=false; } } int initialize(void) { void resize(int,int); void uninitialize(void); PIXELFORMATDESCRIPTOR pfd; int iPixelFormatIndex; GLenum result; //code ZeroMemory(&pfd,sizeof(PPIXELFORMATDESCRIPTOR)); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; pfd.cRedBits = 8; pfd.cGreenBits = 8; pfd.cBlueBits = 8; pfd.cAlphaBits = 8; pfd.cDepthBits = 32; ghdc = GetDC(ghwnd); iPixelFormatIndex = ChoosePixelFormat(ghdc, &pfd); if(iPixelFormatIndex == 0) { return -1; } if(SetPixelFormat(ghdc, iPixelFormatIndex, &pfd) == FALSE) { return -2; } ghrc = wglCreateContext(ghdc); if(ghrc == NULL) { return -3; } if(wglMakeCurrent(ghdc, ghrc) == FALSE) { return -4; } /// result = glewInit(); if(result != GLEW_OK) { fprintf(gpfile,"glewInit failed"); uninitialize(); DestroyWindow(ghwnd); } glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glClearColor(0.0f, 0.0f, 1.0f, 1.0f); glClearDepth(1.0f); resize(WIN_WIDTH, WIN_HEIGHT); return 0; } void resize(int width, int height) { if(height == 0) { height = 1; } glViewport(0, 0, (GLsizei)width,(GLsizei)height); } void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SwapBuffers(ghdc); } void uninitialize(void) { if(bFullScreen == true) { SetWindowLong(ghwnd, GWL_STYLE, dwstyle | WS_OVERLAPPEDWINDOW); SetWindowPlacement(ghwnd,&wpPrev); SetWindowPos(ghwnd, HWND_TOP, 0,0,0,0, SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE| SWP_NOOWNERZORDER); ShowCursor(TRUE); } if(wglGetCurrentContext() == ghrc) { wglMakeCurrent(NULL, NULL); } if(ghrc) { wglDeleteContext(ghrc); ghrc = NULL; } if(ghdc) { ReleaseDC(ghwnd, ghdc); ghdc = NULL; } }
c9fa61721bda61e75c0a56f4050f010f40c63d01
2eaf8fbfc07e5e1cd906a7146ad2a5ef7d2e6208
/Algorithm_TD5/lib/TP5.cpp
5b3c343fbb6b278135772028ffad4421fa014fda
[]
no_license
LibertAntoine/Algorithmic_TP
3a5cd5d492aa535cddaff17ea1fdadd5b520081a
73e09833e0ddf455255313fbecadcd839daf218d
refs/heads/master
2022-12-23T23:01:08.147730
2020-10-08T11:24:07
2020-10-08T11:24:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,553
cpp
#include "TP5.h" HashTable &HashWindow::newHashTable(int size) { HashTable* array = new HashTable(size); this->dirty = true; std::this_thread::sleep_for(std::chrono::milliseconds(MainWindow::instruction_duration / 3)); return *array; } void HashTableInsertThread::run() { std::this_thread::sleep_for(std::chrono::milliseconds(2000)); try { qsrand(time(nullptr)); std::vector<string> content; for (int i=0; i<table.size();++i) { int value = qrand() % 5; table.insert(HashTable::names[value]); content.push_back(HashTable::names[value]); } assertHashTable(content); _message = QString("Hash insertion correctly finished !"); success = true; } catch(std::exception& e) { _message = QString(e.what()); } } int hash(HashTable& t, string s) { return ((int)s[0]) % t.size(); } void HashTableInsertThread::assertHashTable(std::vector<string>& content) { for (int i=0; i<content.size(); ++i) { string s = content[i]; int index = hash(table, s); if (index != table.hash(s) || table[index] != s) { QString message("%1 is not at %2, ' %3 ' found instead !"); throw std::runtime_error(message.arg(QString::fromStdString(s)).arg(index) .arg(QString::fromStdString(table[index])).toStdString()); } } } void HashTableContainsThread::run() { std::this_thread::sleep_for(std::chrono::milliseconds(2000)); try { qsrand(time(nullptr)); for (int i=0; i<table.size();++i) { int value = qrand() % 20; table.insert(HashTable::names[value]); } for (int i=0; i<5; i++) { int index = qrand() % 20; string s = HashTable::names[index]; bool contains = false; for (int i=0; i<table.size(); i++) if (table[i] == s) { contains = true; break; } if (table.contains(s) != contains) { QString message; if (contains) message = "%1 is in the table but you didn't find it"; else message = "%1 is not in the table but you found it"; throw std::runtime_error(message.arg(QString::fromStdString(s)).toStdString()); } } _message = QString("Hash contains method works !"); success = true; } catch(std::exception& e) { _message = QString(e.what()); } } void HashWindow::handleResult() { Base::handleResult(); this->dirty = true; if (!(*currentThread)->succeeded()) return; currentThread++; if (currentThread != threads.end()) { workerThread = *currentThread; connect(workerThread, SIGNAL(finished()), this, SLOT(handleResult())); } } void HashWindow::updateScene() { Base::updateScene(); }
05873fad175b6c0bbb4e9cb098b8621215b2a277
18e2f5b9de8c2a8ba8dba0e9e96f8dbdb1c7e01d
/MeetingManager/MeetingManager/UnderlineTabWidget.cpp
af610cd7922d2cdfd57c72f710b289d1237ebe04
[ "MIT" ]
permissive
hyq5436/playground
f544b2d77042c85d2e6e321e044918eaa65e3743
828b9d2266dbb7d0311e2e73b295fcafb101d94f
refs/heads/master
2021-06-19T16:35:12.188195
2021-01-27T03:07:59
2021-01-27T03:07:59
172,729,316
2
0
null
null
null
null
UTF-8
C++
false
false
453
cpp
#include "UnderlineTabWidget.h" #include "UnderlineTabBar.h" UnderlineTabWidget::UnderlineTabWidget(QWidget *parent) : QTabWidget(parent) { setTabBar(new UnderlineTabBar); QString styleSheet = "QTabWidget:pane{" " border: 1px solid none; " " border-top-color: #eaeaea;" "}"; setStyleSheet(styleSheet); } UnderlineTabWidget::~UnderlineTabWidget() { }
273dc190a493551b20b2d2d51f68319a69ea98c2
b6a498064700c808cb4bef8646c4a9243d15195f
/src/isomorphicStrings/isomrphic_strings.cpp
f17b48aaa9a0fb7e92c4dc8b5292a5575070b642
[]
no_license
kuring/leetcode
8461393d90f5e23179232ed46cd9cdb650a283b0
e679d53674f52395e23f644c20f6075a62b8a09f
refs/heads/master
2021-01-17T17:41:04.502211
2015-05-29T13:52:41
2015-05-29T13:52:41
25,693,937
0
0
null
null
null
null
UTF-8
C++
false
false
889
cpp
#include <string> #include <iostream> #include <vector> #include <map> using namespace std; bool isIsomorphic(string s, string t) { if (s.length() != t.length()) { return false; } map<char, char> forward; map<char, char> reverse; for (size_t i = 0; i < s.length(); i++) { if (forward.find(s[i]) != forward.end()) { if (forward[s[i]] != t[i]) { return false; } } else { forward[s[i]] = t[i]; } if (reverse.find(t[i]) != reverse.end()) { if (reverse[t[i]] != s[i]) { return false; } } else { reverse[t[i]] = s[i]; } } return true; } int main() { cout << isIsomorphic("foo", "bar") << endl; return 1; }
df09c6be62851ebd04b78514a52449a3960bcdfb
e97ef07be160080c6fe8cf7fca9974fd1a596cd7
/chapter-03/section-03/camelot.cc
9b5407591bbfce421e65390dcd7a0f5a279cb572
[]
no_license
007kevin/usaco
625d2e6ea4222cc84c496aeb99c904834e98661a
ea70ef13a870f2ee1fb638569ce7efbfe9b03635
refs/heads/master
2021-01-17T00:21:34.976328
2016-10-31T03:44:52
2016-10-31T03:44:52
51,709,758
0
0
null
null
null
null
UTF-8
C++
false
false
3,574
cc
/* ID: min_j LANG: C++ TASK: camelot Date: 01/06/2016 Anaylsis: */ #include <iostream> #include <fstream> #include <queue> #include <cstdlib> #include <climits> #include <cassert> using namespace std; #define DEBUG #define infinity INT_MAX #define MROW 30 #define MCOL 26 int R,C; int mover[] = {-1,-1,+1,+1,+2,-2,+2,-2}; int movec[] = {+2,-2,+2,-2,-1,-1,+1,+1}; int kingr[] = {-1,-1,0,+1,+1,+1,0,-1}; int kingc[] = {0,+1,+1,+1,0,-1,-1,-1}; struct coord { int r,c,d; coord(int row,int col, int dist){ r = row; c = col; d = dist; }; bool operator<(const coord& rhs) const{ return d < rhs.d; } }; char piece[MROW][MCOL]; int boards[MROW*MCOL][MROW][MCOL]; int K,Krow[MROW*MCOL],Kcol[MROW*MCOL]; // King is when K=0 bool valid(int (*board)[MCOL], int r, int c){ if (r < 0 || r >= R || c < 0 || c >= C) return false; return true; } void bfs_from(int (*board)[MCOL], int r, int c){ queue<coord> Q; Q.push(coord(r,c,0)); while(!Q.empty()){ coord cur = Q.front(); Q.pop(); if (!valid(board,cur.r,cur.c) || board[cur.r][cur.c] != infinity) continue; board[cur.r][cur.c] = cur.d; for (int i = 0; i < 8; ++i) Q.push(coord(cur.r+mover[i],cur.c+movec[i],cur.d+1)); } } void bfs_king(int (*board)[MCOL], int r, int c){ queue<coord> Q; Q.push(coord(r,c,0)); while(!Q.empty()){ coord cur = Q.front(); Q.pop(); if (!valid(board,cur.r,cur.c) || board[cur.r][cur.c] != infinity) continue; board[cur.r][cur.c] = cur.d; for (int i = 0; i < 8; ++i) Q.push(coord(cur.r+kingr[i],cur.c+kingc[i],cur.d+1)); } } void reset(int (*board)[MCOL]){ for (int i = 0; i < R*C; ++i) board[i/C][i%C] = infinity; } #ifdef DEBUG void debugprint(int (*board)[MCOL]){ cout << endl; cout << "\t"; for (int i = 0; i < C; ++i) cout << (char) ('A'+i) << "\t"; cout << endl; for (int i = 0; i < R; ++i){ cout << i+1 << '\t'; for (int j = 0 ; j < C; ++j){ if (board[i][j] != infinity) cout << board[i][j] << "\t"; else cout << '-' << '\t'; } cout << endl; } } #endif int main(){ ifstream fin("camelot.in.t"); ofstream fout("camelot.out"); assert(fin.is_open() && fout.is_open()); fin>>R>>C; string col,row; int c,r; fin>>col>>row; r = atoi(row.c_str())-1; c = col[0]-'A'; piece[r][c] = 'K'; Krow[K] = r; Kcol[K] = c; K++; while (fin>>col>>row){ r = atoi(row.c_str())-1; c = col[0]-'A'; piece[r][c] = 'k'; Krow[K] = r; Kcol[K] = c; K++; } fin.close(); if (K == 1){ fout << 0 << endl; fout.close(); return 0; } reset(boards[0]); bfs_king(boards[0],Krow[0],Kcol[0]); for (int i = 1; i < K; ++i){ reset(boards[i]); bfs_from(boards[i],Krow[i],Kcol[i]); } int output[MROW][MCOL]; int minimum = infinity; for (int i = 0; i < R*C; ++i) output[i/C][i%C] = 0; for (int i = 0; i < R; ++i) for (int j = 0; j < C; ++j){ for (int k = 1; k < K; ++k){ output[i][j]+=boards[k][i][j]; if (k == K-1 && output[i][j] < minimum) minimum = output[i][j]; } } #ifdef DEBUG cout << " "; for (int i = 0; i < C; ++i) cout << (char) ('A'+i) << " "; cout << endl; for (int i = 0; i < R; ++i){ cout << i+1 << ' '; for (int j = 0 ; j < C; ++j){ if (piece[i][j] == 0) cout << '-' << ' '; else cout << piece[i][j] << ' '; } cout << endl; } for (int k = 0; k < K; ++k) debugprint(boards[k]); debugprint(output); #endif fout.close(); return 0; }
eccc61a1cf2da2cd807242adf8b460f618390f5b
8f80fc53b229eef4be826c86a60cfecdb142bf31
/Section11-Functions/FunctionDefinitions/main.cpp
59101cb522a33896944acb1d2da737ec36b14c58
[]
no_license
eh-jogos/UdemyCppCourse
fe012aac30890ffa82f57c26deb23907a2ea2448
b0231505d605674493f9d63bf3967f905231236e
refs/heads/main
2023-07-04T09:40:48.984834
2021-07-31T18:03:52
2021-07-31T18:03:52
391,324,655
0
0
null
null
null
null
UTF-8
C++
false
false
876
cpp
#include <iostream> using namespace std; const double pi {3.14159}; double calc_area_circle(double radius){ return pi * radius * radius; } void area_circle(){ double radius {}; cout << "\nEnter the radius of the circle: "; cin >> radius; cout << "The area of a circle with a radius of " << radius << " is " << calc_area_circle(radius) << endl; } double calc_volume_cylinder(double radius, double height){ return calc_area_circle(radius) * height; } void volume_cylinder(){ double radius {}; double height {}; cout << "\nEnter the radius of the cylinder: "; cin >> radius; cout << "\nEnter the height of the cylinder: "; cin >> height; cout << "The volume of a cylinder with radius " << radius << " and height " << height << " is " << calc_volume_cylinder(radius, height) << endl; } int main() { area_circle(); volume_cylinder(); return 0; }
973e6e421a10bd1a169bb360f5f92ffc9de21291
f06f6f03d8a57a09127896eea3e84e57a1b0b3d5
/DxEEngine/DxEEngine/Component.h
1242ced053996c6c44953c898f0720db6a1cd927
[]
no_license
NamidaEro/Dx11
8d40547035e8be38dafb4ed305f5e68480fdf80c
55d4ab12a633a672cadc780eafffb8cba1a60baf
refs/heads/master
2023-01-02T16:10:13.076084
2020-10-18T07:28:04
2020-10-18T07:28:04
303,683,580
0
0
null
null
null
null
UHC
C++
false
false
653
h
#ifndef COMPONENT_H__ #define COMPONENT_H__ #include "Includes.h" START(dxengine) class DXAPI Component : public IObject { // IObject을(를) 통해 상속됨 virtual void Awake() override; virtual void OnEnable() override; virtual void Start() override; virtual void FixedUpdate() override; virtual void Update() override; virtual void LateUpdate() override; virtual void OnPreRender() override; virtual void OnRenderObject() override; virtual void OnPostRender() override; virtual void OnGUI() override; virtual void OnDisable() override; virtual void OnDestroy() override; public: Component() {} }; END #endif // !COMPONENT_H__
a99b4a22f52aa3b128b6159360defac21519179f
7668a38611fa5775b8f6ec31d7dda23f5cb0a56e
/00-kuka_joint_hold_pos/orientation_error_test.cpp
86fca7fc7366b338e4c8da02f7ab7dbe0ae794cf
[]
no_license
keven425/demo_application
aa507ff4985b684543a5dd448b2f396dff7f6622
e1e5ebe5acf9a6a394450fb92fd8eca755a9bfe9
refs/heads/master
2020-03-08T12:49:12.925816
2018-04-25T21:19:23
2018-04-25T21:19:23
128,138,185
0
0
null
2018-04-05T00:07:56
2018-04-05T00:07:56
null
UTF-8
C++
false
false
1,196
cpp
#include "Sai2Model.h" #include "redis/RedisClient.h" #include "timer/LoopTimer.h" #include <iostream> #include <string> #include <tinyxml2.h> #include <signal.h> #include <math.h> using namespace std; using namespace Eigen; int main() { Vector3d rotation_error = Vector3d(0.0, 0.0, 0.0); Matrix3d desired_orientation; desired_orientation << 1., 0., 0., 0., 1., 0., 0., 0., -1.; Matrix3d current_orientation; current_orientation << 0.633458, -0.673123, 0.381624, -0.67511, -0.239795, 0.697657, -0.378098, -0.699574, -0.606331; Sai2Model::orientationError(rotation_error, desired_orientation, current_orientation); cout << "rotation matrix rotation_error: " << rotation_error << endl; Quaterniond desired_orientation_q = Quaterniond(1., 0., 0., 0.); Quaterniond current_orientation_q = Quaterniond(-0.4436585, 0.7873348, -0.4281003, 0.0011196); Sai2Model::orientationError(rotation_error, desired_orientation_q, current_orientation_q); cout << "quaternion rotation_error: " << rotation_error << endl; /* rotation matrix rotation_error: -0.0009585 -0.001763 -0.0009935 quaternion rotation_error: -1.57467 0.856201 -0.0022392 */ }
4fdaefb8e9a5cef30184d3ee9d859b35c847b53e
097f7ff95b2e1a027595f275b957a0127ec80651
/BattleForTheSpace/Intermediate/Build/Win64/UE4Editor/Inc/BattleForTheSpace/BattleForTheSpaceGameMode.gen.cpp
201b732d3b73e3534931448e05b7a3b5f96efaef
[]
no_license
PolygonBear/BattleForTheSpace
d25e05b4819427dc7c9835882cf3383dd0fb5bff
bfbbe01257111f637be7ee1cda5b9ef028b1ed23
refs/heads/main
2023-07-15T06:49:33.475340
2021-08-27T15:52:49
2021-08-27T15:52:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,784
cpp
// Copyright Epic Games, Inc. All Rights Reserved. /*=========================================================================== Generated code exported from UnrealHeaderTool. DO NOT modify this manually! Edit the corresponding .h files instead! ===========================================================================*/ #include "UObject/GeneratedCppIncludes.h" #include "BattleForTheSpace/BattleForTheSpaceGameMode.h" #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable : 4883) #endif PRAGMA_DISABLE_DEPRECATION_WARNINGS void EmptyLinkFunctionForGeneratedCodeBattleForTheSpaceGameMode() {} // Cross Module References BATTLEFORTHESPACE_API UClass* Z_Construct_UClass_ABattleForTheSpaceGameMode_NoRegister(); BATTLEFORTHESPACE_API UClass* Z_Construct_UClass_ABattleForTheSpaceGameMode(); ENGINE_API UClass* Z_Construct_UClass_AGameModeBase(); UPackage* Z_Construct_UPackage__Script_BattleForTheSpace(); // End Cross Module References void ABattleForTheSpaceGameMode::StaticRegisterNativesABattleForTheSpaceGameMode() { } UClass* Z_Construct_UClass_ABattleForTheSpaceGameMode_NoRegister() { return ABattleForTheSpaceGameMode::StaticClass(); } struct Z_Construct_UClass_ABattleForTheSpaceGameMode_Statics { static UObject* (*const DependentSingletons[])(); #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam Class_MetaDataParams[]; #endif static const FCppClassTypeInfoStatic StaticCppClassTypeInfo; static const UE4CodeGen_Private::FClassParams ClassParams; }; UObject* (*const Z_Construct_UClass_ABattleForTheSpaceGameMode_Statics::DependentSingletons[])() = { (UObject* (*)())Z_Construct_UClass_AGameModeBase, (UObject* (*)())Z_Construct_UPackage__Script_BattleForTheSpace, }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_ABattleForTheSpaceGameMode_Statics::Class_MetaDataParams[] = { { "HideCategories", "Info Rendering MovementReplication Replication Actor Input Movement Collision Rendering Utilities|Transformation" }, { "IncludePath", "BattleForTheSpaceGameMode.h" }, { "ModuleRelativePath", "BattleForTheSpaceGameMode.h" }, { "ShowCategories", "Input|MouseInput Input|TouchInput" }, }; #endif const FCppClassTypeInfoStatic Z_Construct_UClass_ABattleForTheSpaceGameMode_Statics::StaticCppClassTypeInfo = { TCppClassTypeTraits<ABattleForTheSpaceGameMode>::IsAbstract, }; const UE4CodeGen_Private::FClassParams Z_Construct_UClass_ABattleForTheSpaceGameMode_Statics::ClassParams = { &ABattleForTheSpaceGameMode::StaticClass, "Game", &StaticCppClassTypeInfo, DependentSingletons, nullptr, nullptr, nullptr, UE_ARRAY_COUNT(DependentSingletons), 0, 0, 0, 0x008802ACu, METADATA_PARAMS(Z_Construct_UClass_ABattleForTheSpaceGameMode_Statics::Class_MetaDataParams, UE_ARRAY_COUNT(Z_Construct_UClass_ABattleForTheSpaceGameMode_Statics::Class_MetaDataParams)) }; UClass* Z_Construct_UClass_ABattleForTheSpaceGameMode() { static UClass* OuterClass = nullptr; if (!OuterClass) { UE4CodeGen_Private::ConstructUClass(OuterClass, Z_Construct_UClass_ABattleForTheSpaceGameMode_Statics::ClassParams); } return OuterClass; } IMPLEMENT_CLASS(ABattleForTheSpaceGameMode, 2313962094); template<> BATTLEFORTHESPACE_API UClass* StaticClass<ABattleForTheSpaceGameMode>() { return ABattleForTheSpaceGameMode::StaticClass(); } static FCompiledInDefer Z_CompiledInDefer_UClass_ABattleForTheSpaceGameMode(Z_Construct_UClass_ABattleForTheSpaceGameMode, &ABattleForTheSpaceGameMode::StaticClass, TEXT("/Script/BattleForTheSpace"), TEXT("ABattleForTheSpaceGameMode"), false, nullptr, nullptr, nullptr); DEFINE_VTABLE_PTR_HELPER_CTOR(ABattleForTheSpaceGameMode); PRAGMA_ENABLE_DEPRECATION_WARNINGS #ifdef _MSC_VER #pragma warning (pop) #endif
932412959896858ce54b433f6fc3c442a3225274
5898d3bd9e4cb58043b40fa58961c7452182db08
/part3/ch25/25-3-3-specialized-order/src/Vector.h
2e19578a00351f672b010ea1ff75ac392badc571
[]
no_license
sasaki-seiji/ProgrammingLanguageCPP4th
1e802f3cb15fc2ac51fa70403b95f52878223cff
2f686b385b485c27068328c6533926903b253687
refs/heads/master
2020-04-04T06:10:32.942026
2017-08-10T11:35:08
2017-08-10T11:35:08
53,772,682
2
0
null
null
null
null
UTF-8
C++
false
false
4,519
h
/* * Vector.h * * Created on: 2016/09/19 * Author: sasaki */ #ifndef VECTOR_H_ #define VECTOR_H_ #include <memory> #include <initializer_list> #include <iostream> template<typename T> class Vector { T* v; size_t sz; public: Vector(); explicit Vector(size_t); Vector(std::initializer_list<T>); Vector(const Vector&) = delete; Vector& operator=(const Vector&) = delete ; ~Vector() { delete []v; } T& elem(int i) { return v[i]; } T& operator[](int i); void swap(Vector&); T* begin() { return v; } const T* begin() const { return v; } T* end() { return v+sz; } const T* end() const { return v+sz; } }; template<typename T> Vector<T>::Vector() : v{nullptr}, sz{0} { std::cout << "Vector<T>::Vector()\n"; } template<typename T> Vector<T>::Vector(size_t s) : v{new T[s]}, sz{s} { std::cout << "Vector<T>::Vector(int)\n"; std::fill(v,v+s,T{}); } template<typename T> Vector<T>::Vector(std::initializer_list<T> il) : v{new T[il.size()]}, sz{il.size()} { std::cout << "Vector<T>::Vector(std::initializer_list<T>)\n"; std::copy(il.begin(), il.end(), v); } template<> class Vector<void*> { void** v; size_t sz; public: Vector(); explicit Vector(size_t); Vector(const Vector&) = delete; Vector& operator=(const Vector&) = delete ; ~Vector() { delete []v; } void*& elem(int i) { return v[i]; } void*& operator[](int i); void swap(Vector&); void** begin() { return v; } void** end() { return v+sz; } }; //template<> // error: template-id 'Vector<>' for 'Vector<void*>::Vector()' does not match any template declaration inline Vector<void*>::Vector() : v{nullptr}, sz{0} { std::cout << "Vector<void*>::Vector()\n"; } inline Vector<void*>::Vector(size_t s) : v{new void*[s]}, sz{s} { std::cout << "Vector<void*>::Vector(int)\n"; std::fill(v,v+s,nullptr); } template<> class Vector<const void*> { const void** v; size_t sz; public: Vector(); explicit Vector(size_t); Vector(const Vector&) = delete; Vector& operator=(const Vector&) = delete ; ~Vector() { delete []v; } const void*& elem(int i) { return v[i]; } const void*& operator[](int i); void swap(Vector&); const void** begin() { return v; } const void** end() { return v+sz; } }; //template<> // error: template-id 'Vector<>' for 'Vector<void*>::Vector()' does not match any template declaration inline Vector<const void*>::Vector() : v{nullptr}, sz{0} { std::cout << "Vector<const void*>::Vector()\n"; } inline Vector<const void*>::Vector(size_t s) : v{new const void*[s]}, sz{s} { std::cout << "Vector<const void*>::Vector(int)\n"; std::uninitialized_fill(v,v+s,nullptr); } template<typename T> class Vector<T*> : private Vector<void*>{ public: using Base = Vector<void*>; Vector(); explicit Vector(int i); Vector(std::initializer_list<T*> il) ; Vector(const Vector&) = delete; Vector& operator=(const Vector&) = delete ; T*& elem(int i) { return reinterpret_cast<T*&>(Base::elem(i)); } T*& operator[](int i) { return reinterpret_cast<T*&>(Base::operator[](i)); } void swap(Vector&); T** begin() { return reinterpret_cast<T**>(Base::begin()); } T** end() { return reinterpret_cast<T**>(Base::end()); } }; template<typename T> Vector<T*>::Vector() { std::cout << "Vector<T*>::Vector()\n"; } template<typename T> Vector<T*>::Vector(int i) :Base(i) { std::cout << "Vector<T*>::Vector(int)\n"; } template<typename T> Vector<T*>::Vector(std::initializer_list<T*> il) :Base(il.size()) { std::cout << "Vector<T*>::Vector(std::initializer_list<T*>)\n"; std::copy(il.begin(), il.end(), begin()); } template<typename T> class Vector<const T*> : private Vector<const void*>{ public: using Base = Vector<const void*>; Vector(); explicit Vector(int i); Vector(std::initializer_list<const T*> il) ; Vector(const Vector&) = delete; Vector& operator=(const Vector&) = delete ; const T*& elem(int i) { return reinterpret_cast<const T*&>(Base::elem(i)); } const T*& operator[](int i) { return reinterpret_cast<const T*&>(Base::operator[](i)); } void swap(Vector&); const T** begin() { return reinterpret_cast<const T**>(Base::begin()); } const T** end() { return reinterpret_cast<const T**>(Base::end()); } }; template<typename T> Vector<const T*>::Vector() { std::cout << "Vector<const T*>::Vector()\n"; } template<typename T> Vector<const T*>::Vector(std::initializer_list<const T*> il) :Base(il.size()) { std::cout << "Vector<const T*>::Vector(std::initializer_list<const T*>)\n"; std::copy(il.begin(), il.end(), begin()); } #endif /* VECTOR_H_ */
53b298a8ae0e3a3d75de3a5d7d0d3824db4a9637
2c103e727edf3f92fd4cdaa36ae71607322f0e39
/Hurin.cpp
cbe5196e33cadd04fa035751eb2c2cf359f4cf87
[]
no_license
chriswasser/Workspace_C
c41b02510f36bdd09b0b9f94ea4d18fbfcbbcd24
c63e635a02a5644511f70773f4199af452d2c87a
refs/heads/master
2021-06-12T15:32:57.542455
2017-03-19T11:57:10
2017-03-19T11:57:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,958
cpp
#include <iostream> #include <vector> #include <cstdlib> #include <initializer_list> using namespace std; template <typename T> class MyQueue { class myiterator { private: const MyQueue & q; size_t index; public: myiterator(const MyQueue & _q, size_t _index) : q(_q), index(_index) { } bool operator!=(const myiterator& rhs) const { return (&q == &rhs.q) && (index!=rhs.index); } double operator*() const { return q.fifo[index]; } const myiterator& operator++() { ++index; return *this; } }; private: vector<T> fifo; public: typedef T value_type; myiterator begin() const { return myiterator(*this, 0); } myiterator end() const { return myiterator(*this, fifo.size()); } MyQueue(const initializer_list<T>& i) { for(T element : i) { fifo.push_back(element); } } void enqueue(T i) { fifo.push_back(i); } T dequeue() { T value = fifo[0]; fifo.erase(fifo.begin()); return value; } friend ostream & operator<<(ostream & os, const MyQueue & q) { unsigned int i; os << "begin [ "; for (i = 0; i < q.fifo.size(); i++) { os << q.fifo[i] << " "; } os << "] end"; return os; } }; int main() { MyQueue<double> q = {3.21,2.213,4,2123.2,21213.3,421,12.89}; cout << "Current state of the queue: " << q << endl; cout << "Processing element: " << q.dequeue() << endl; cout << "Processing element: " << q.dequeue() << endl; q.enqueue(3); q.enqueue(827); cout << "Current state of the queue: " << q << endl; cout << "The queue's content is currently:" << endl; for(auto i : q) { cout << i << endl; } return 0; }
b57a6a767e0b5880d97854d402be2ea828cbb60e
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_1/MP+dmb.ldll+dmb.syap.c.cbmc_out.cpp
a5f9a556a4e92e1856c5072ee70e4921117cacaf
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
29,850
cpp
// 0:vars:2 // 2:atom_1_X0_1:1 // 3:atom_1_X2_0:1 // 4:thr0:1 // 5:thr1:1 #define ADDRSIZE 6 #define NPROC 3 #define NCONTEXT 1 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NPROC*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NPROC*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NPROC*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NPROC*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NPROC*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NPROC*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NPROC*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NPROC*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NPROC*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NPROC]; int cdy[NPROC]; int cds[NPROC]; int cdl[NPROC]; int cisb[NPROC]; int caddr[NPROC]; int cctrl[NPROC]; int cstart[NPROC]; int creturn[NPROC]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; int r0= 0; char creg_r0; int r1= 0; char creg_r1; int r2= 0; char creg_r2; int r3= 0; char creg_r3; int r4= 0; char creg_r4; int r5= 0; char creg_r5; int r6= 0; char creg_r6; int r7= 0; char creg_r7; int r8= 0; char creg_r8; char old_cctrl= 0; char old_cr= 0; char old_cdy= 0; char old_cw= 0; char new_creg= 0; buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; buff(0,4) = 0; pw(0,4) = 0; cr(0,4) = 0; iw(0,4) = 0; cw(0,4) = 0; cx(0,4) = 0; is(0,4) = 0; cs(0,4) = 0; crmax(0,4) = 0; buff(0,5) = 0; pw(0,5) = 0; cr(0,5) = 0; iw(0,5) = 0; cw(0,5) = 0; cx(0,5) = 0; is(0,5) = 0; cs(0,5) = 0; crmax(0,5) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; buff(1,4) = 0; pw(1,4) = 0; cr(1,4) = 0; iw(1,4) = 0; cw(1,4) = 0; cx(1,4) = 0; is(1,4) = 0; cs(1,4) = 0; crmax(1,4) = 0; buff(1,5) = 0; pw(1,5) = 0; cr(1,5) = 0; iw(1,5) = 0; cw(1,5) = 0; cx(1,5) = 0; is(1,5) = 0; cs(1,5) = 0; crmax(1,5) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; buff(2,4) = 0; pw(2,4) = 0; cr(2,4) = 0; iw(2,4) = 0; cw(2,4) = 0; cx(2,4) = 0; is(2,4) = 0; cs(2,4) = 0; crmax(2,4) = 0; buff(2,5) = 0; pw(2,5) = 0; cr(2,5) = 0; iw(2,5) = 0; cw(2,5) = 0; cx(2,5) = 0; is(2,5) = 0; cs(2,5) = 0; crmax(2,5) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(2+0,0) = 0; mem(3+0,0) = 0; mem(4+0,0) = 0; mem(5+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; co(1,0) = 0; delta(1,0) = -1; co(2,0) = 0; delta(2,0) = -1; co(3,0) = 0; delta(3,0) = -1; co(4,0) = 0; delta(4,0) = -1; co(5,0) = 0; delta(5,0) = -1; // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !35, metadata !DIExpression()), !dbg !44 // br label %label_1, !dbg !45 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !43), !dbg !46 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !36, metadata !DIExpression()), !dbg !47 // call void @llvm.dbg.value(metadata i64 1, metadata !39, metadata !DIExpression()), !dbg !47 // store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !48 // ST: Guess // : Release iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); ASSUME(cw(1,0) >= cr(1,0+0)); ASSUME(cw(1,0) >= cr(1,0+1)); ASSUME(cw(1,0) >= cr(1,2+0)); ASSUME(cw(1,0) >= cr(1,3+0)); ASSUME(cw(1,0) >= cr(1,4+0)); ASSUME(cw(1,0) >= cr(1,5+0)); ASSUME(cw(1,0) >= cw(1,0+0)); ASSUME(cw(1,0) >= cw(1,0+1)); ASSUME(cw(1,0) >= cw(1,2+0)); ASSUME(cw(1,0) >= cw(1,3+0)); ASSUME(cw(1,0) >= cw(1,4+0)); ASSUME(cw(1,0) >= cw(1,5+0)); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 1; mem(0,cw(1,0)) = 1; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; is(1,0) = iw(1,0); cs(1,0) = cw(1,0); ASSUME(creturn[1] >= cw(1,0)); // call void (...) @dmbld(), !dbg !49 // dumbld: Guess cdl[1] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdl[1] >= cdy[1]); ASSUME(cdl[1] >= cr(1,0+0)); ASSUME(cdl[1] >= cr(1,0+1)); ASSUME(cdl[1] >= cr(1,2+0)); ASSUME(cdl[1] >= cr(1,3+0)); ASSUME(cdl[1] >= cr(1,4+0)); ASSUME(cdl[1] >= cr(1,5+0)); ASSUME(creturn[1] >= cdl[1]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !40, metadata !DIExpression()), !dbg !50 // call void @llvm.dbg.value(metadata i64 1, metadata !42, metadata !DIExpression()), !dbg !50 // store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) release, align 8, !dbg !51 // ST: Guess // : Release iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0+1*1)] == 1); ASSUME(active[cw(1,0+1*1)] == 1); ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(cw(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cw(1,0+1*1) >= old_cw); ASSUME(cw(1,0+1*1) >= cr(1,0+1*1)); ASSUME(cw(1,0+1*1) >= cl[1]); ASSUME(cw(1,0+1*1) >= cisb[1]); ASSUME(cw(1,0+1*1) >= cdy[1]); ASSUME(cw(1,0+1*1) >= cdl[1]); ASSUME(cw(1,0+1*1) >= cds[1]); ASSUME(cw(1,0+1*1) >= cctrl[1]); ASSUME(cw(1,0+1*1) >= caddr[1]); ASSUME(cw(1,0+1*1) >= cr(1,0+0)); ASSUME(cw(1,0+1*1) >= cr(1,0+1)); ASSUME(cw(1,0+1*1) >= cr(1,2+0)); ASSUME(cw(1,0+1*1) >= cr(1,3+0)); ASSUME(cw(1,0+1*1) >= cr(1,4+0)); ASSUME(cw(1,0+1*1) >= cr(1,5+0)); ASSUME(cw(1,0+1*1) >= cw(1,0+0)); ASSUME(cw(1,0+1*1) >= cw(1,0+1)); ASSUME(cw(1,0+1*1) >= cw(1,2+0)); ASSUME(cw(1,0+1*1) >= cw(1,3+0)); ASSUME(cw(1,0+1*1) >= cw(1,4+0)); ASSUME(cw(1,0+1*1) >= cw(1,5+0)); // Update caddr[1] = max(caddr[1],0); buff(1,0+1*1) = 1; mem(0+1*1,cw(1,0+1*1)) = 1; co(0+1*1,cw(1,0+1*1))+=1; delta(0+1*1,cw(1,0+1*1)) = -1; is(1,0+1*1) = iw(1,0+1*1); cs(1,0+1*1) = cw(1,0+1*1); ASSUME(creturn[1] >= cw(1,0+1*1)); // ret i8* null, !dbg !52 ret_thread_1 = (- 1); // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !55, metadata !DIExpression()), !dbg !74 // br label %label_2, !dbg !56 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !73), !dbg !76 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !58, metadata !DIExpression()), !dbg !77 // %0 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) acquire, align 8, !dbg !59 // LD: Guess // : Acquire old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); ASSUME(cr(2,0+1*1) >= cx(2,0+1*1)); ASSUME(cr(2,0+1*1) >= cs(2,0+0)); ASSUME(cr(2,0+1*1) >= cs(2,0+1)); ASSUME(cr(2,0+1*1) >= cs(2,2+0)); ASSUME(cr(2,0+1*1) >= cs(2,3+0)); ASSUME(cr(2,0+1*1) >= cs(2,4+0)); ASSUME(cr(2,0+1*1) >= cs(2,5+0)); // Update creg_r0 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r0 = buff(2,0+1*1); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r0 = mem(0+1*1,cr(2,0+1*1)); } cl[2] = max(cl[2],cr(2,0+1*1)); ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !60, metadata !DIExpression()), !dbg !77 // %conv = trunc i64 %0 to i32, !dbg !60 // call void @llvm.dbg.value(metadata i32 %conv, metadata !56, metadata !DIExpression()), !dbg !74 // call void (...) @dmbsy(), !dbg !61 // dumbsy: Guess old_cdy = cdy[2]; cdy[2] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[2] >= old_cdy); ASSUME(cdy[2] >= cisb[2]); ASSUME(cdy[2] >= cdl[2]); ASSUME(cdy[2] >= cds[2]); ASSUME(cdy[2] >= cctrl[2]); ASSUME(cdy[2] >= cw(2,0+0)); ASSUME(cdy[2] >= cw(2,0+1)); ASSUME(cdy[2] >= cw(2,2+0)); ASSUME(cdy[2] >= cw(2,3+0)); ASSUME(cdy[2] >= cw(2,4+0)); ASSUME(cdy[2] >= cw(2,5+0)); ASSUME(cdy[2] >= cr(2,0+0)); ASSUME(cdy[2] >= cr(2,0+1)); ASSUME(cdy[2] >= cr(2,2+0)); ASSUME(cdy[2] >= cr(2,3+0)); ASSUME(cdy[2] >= cr(2,4+0)); ASSUME(cdy[2] >= cr(2,5+0)); ASSUME(creturn[2] >= cdy[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !62, metadata !DIExpression()), !dbg !81 // %1 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !63 // LD: Guess old_cr = cr(2,0); cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0)] == 2); ASSUME(cr(2,0) >= iw(2,0)); ASSUME(cr(2,0) >= 0); ASSUME(cr(2,0) >= cdy[2]); ASSUME(cr(2,0) >= cisb[2]); ASSUME(cr(2,0) >= cdl[2]); ASSUME(cr(2,0) >= cl[2]); // Update creg_r1 = cr(2,0); crmax(2,0) = max(crmax(2,0),cr(2,0)); caddr[2] = max(caddr[2],0); if(cr(2,0) < cw(2,0)) { r1 = buff(2,0); } else { if(pw(2,0) != co(0,cr(2,0))) { ASSUME(cr(2,0) >= old_cr); } pw(2,0) = co(0,cr(2,0)); r1 = mem(0,cr(2,0)); } ASSUME(creturn[2] >= cr(2,0)); // call void @llvm.dbg.value(metadata i64 %1, metadata !64, metadata !DIExpression()), !dbg !81 // %conv4 = trunc i64 %1 to i32, !dbg !64 // call void @llvm.dbg.value(metadata i32 %conv4, metadata !61, metadata !DIExpression()), !dbg !74 // %cmp = icmp eq i32 %conv, 1, !dbg !65 // %conv5 = zext i1 %cmp to i32, !dbg !65 // call void @llvm.dbg.value(metadata i32 %conv5, metadata !65, metadata !DIExpression()), !dbg !74 // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !66, metadata !DIExpression()), !dbg !85 // %2 = zext i32 %conv5 to i64 // call void @llvm.dbg.value(metadata i64 %2, metadata !68, metadata !DIExpression()), !dbg !85 // store atomic i64 %2, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !67 // ST: Guess iw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,2); cw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,2)] == 2); ASSUME(active[cw(2,2)] == 2); ASSUME(sforbid(2,cw(2,2))== 0); ASSUME(iw(2,2) >= max(creg_r0,0)); ASSUME(iw(2,2) >= 0); ASSUME(cw(2,2) >= iw(2,2)); ASSUME(cw(2,2) >= old_cw); ASSUME(cw(2,2) >= cr(2,2)); ASSUME(cw(2,2) >= cl[2]); ASSUME(cw(2,2) >= cisb[2]); ASSUME(cw(2,2) >= cdy[2]); ASSUME(cw(2,2) >= cdl[2]); ASSUME(cw(2,2) >= cds[2]); ASSUME(cw(2,2) >= cctrl[2]); ASSUME(cw(2,2) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,2) = (r0==1); mem(2,cw(2,2)) = (r0==1); co(2,cw(2,2))+=1; delta(2,cw(2,2)) = -1; ASSUME(creturn[2] >= cw(2,2)); // %cmp7 = icmp eq i32 %conv4, 0, !dbg !68 // %conv8 = zext i1 %cmp7 to i32, !dbg !68 // call void @llvm.dbg.value(metadata i32 %conv8, metadata !69, metadata !DIExpression()), !dbg !74 // call void @llvm.dbg.value(metadata i64* @atom_1_X2_0, metadata !70, metadata !DIExpression()), !dbg !88 // %3 = zext i32 %conv8 to i64 // call void @llvm.dbg.value(metadata i64 %3, metadata !72, metadata !DIExpression()), !dbg !88 // store atomic i64 %3, i64* @atom_1_X2_0 seq_cst, align 8, !dbg !70 // ST: Guess iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,3); cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,3)] == 2); ASSUME(active[cw(2,3)] == 2); ASSUME(sforbid(3,cw(2,3))== 0); ASSUME(iw(2,3) >= max(creg_r1,0)); ASSUME(iw(2,3) >= 0); ASSUME(cw(2,3) >= iw(2,3)); ASSUME(cw(2,3) >= old_cw); ASSUME(cw(2,3) >= cr(2,3)); ASSUME(cw(2,3) >= cl[2]); ASSUME(cw(2,3) >= cisb[2]); ASSUME(cw(2,3) >= cdy[2]); ASSUME(cw(2,3) >= cdl[2]); ASSUME(cw(2,3) >= cds[2]); ASSUME(cw(2,3) >= cctrl[2]); ASSUME(cw(2,3) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,3) = (r1==0); mem(3,cw(2,3)) = (r1==0); co(3,cw(2,3))+=1; delta(3,cw(2,3)) = -1; ASSUME(creturn[2] >= cw(2,3)); // ret i8* null, !dbg !71 ret_thread_2 = (- 1); // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !98, metadata !DIExpression()), !dbg !126 // call void @llvm.dbg.value(metadata i8** %argv, metadata !99, metadata !DIExpression()), !dbg !126 // %0 = bitcast i64* %thr0 to i8*, !dbg !69 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #6, !dbg !69 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !100, metadata !DIExpression()), !dbg !128 // %1 = bitcast i64* %thr1 to i8*, !dbg !71 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #6, !dbg !71 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !104, metadata !DIExpression()), !dbg !130 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !105, metadata !DIExpression()), !dbg !131 // call void @llvm.dbg.value(metadata i64 0, metadata !107, metadata !DIExpression()), !dbg !131 // store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !74 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !108, metadata !DIExpression()), !dbg !133 // call void @llvm.dbg.value(metadata i64 0, metadata !110, metadata !DIExpression()), !dbg !133 // store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !76 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !111, metadata !DIExpression()), !dbg !135 // call void @llvm.dbg.value(metadata i64 0, metadata !113, metadata !DIExpression()), !dbg !135 // store atomic i64 0, i64* @atom_1_X0_1 monotonic, align 8, !dbg !78 // ST: Guess iw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,2); cw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,2)] == 0); ASSUME(active[cw(0,2)] == 0); ASSUME(sforbid(2,cw(0,2))== 0); ASSUME(iw(0,2) >= 0); ASSUME(iw(0,2) >= 0); ASSUME(cw(0,2) >= iw(0,2)); ASSUME(cw(0,2) >= old_cw); ASSUME(cw(0,2) >= cr(0,2)); ASSUME(cw(0,2) >= cl[0]); ASSUME(cw(0,2) >= cisb[0]); ASSUME(cw(0,2) >= cdy[0]); ASSUME(cw(0,2) >= cdl[0]); ASSUME(cw(0,2) >= cds[0]); ASSUME(cw(0,2) >= cctrl[0]); ASSUME(cw(0,2) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,2) = 0; mem(2,cw(0,2)) = 0; co(2,cw(0,2))+=1; delta(2,cw(0,2)) = -1; ASSUME(creturn[0] >= cw(0,2)); // call void @llvm.dbg.value(metadata i64* @atom_1_X2_0, metadata !114, metadata !DIExpression()), !dbg !137 // call void @llvm.dbg.value(metadata i64 0, metadata !116, metadata !DIExpression()), !dbg !137 // store atomic i64 0, i64* @atom_1_X2_0 monotonic, align 8, !dbg !80 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #6, !dbg !81 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call7 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #6, !dbg !82 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %2 = load i64, i64* %thr0, align 8, !dbg !83, !tbaa !84 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,4)] == 0); ASSUME(cr(0,4) >= iw(0,4)); ASSUME(cr(0,4) >= 0); ASSUME(cr(0,4) >= cdy[0]); ASSUME(cr(0,4) >= cisb[0]); ASSUME(cr(0,4) >= cdl[0]); ASSUME(cr(0,4) >= cl[0]); // Update creg_r3 = cr(0,4); crmax(0,4) = max(crmax(0,4),cr(0,4)); caddr[0] = max(caddr[0],0); if(cr(0,4) < cw(0,4)) { r3 = buff(0,4); } else { if(pw(0,4) != co(4,cr(0,4))) { ASSUME(cr(0,4) >= old_cr); } pw(0,4) = co(4,cr(0,4)); r3 = mem(4,cr(0,4)); } ASSUME(creturn[0] >= cr(0,4)); // %call8 = call i32 @pthread_join(i64 noundef %2, i8** noundef null), !dbg !88 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %3 = load i64, i64* %thr1, align 8, !dbg !89, !tbaa !84 // LD: Guess old_cr = cr(0,5); cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,5)] == 0); ASSUME(cr(0,5) >= iw(0,5)); ASSUME(cr(0,5) >= 0); ASSUME(cr(0,5) >= cdy[0]); ASSUME(cr(0,5) >= cisb[0]); ASSUME(cr(0,5) >= cdl[0]); ASSUME(cr(0,5) >= cl[0]); // Update creg_r4 = cr(0,5); crmax(0,5) = max(crmax(0,5),cr(0,5)); caddr[0] = max(caddr[0],0); if(cr(0,5) < cw(0,5)) { r4 = buff(0,5); } else { if(pw(0,5) != co(5,cr(0,5))) { ASSUME(cr(0,5) >= old_cr); } pw(0,5) = co(5,cr(0,5)); r4 = mem(5,cr(0,5)); } ASSUME(creturn[0] >= cr(0,5)); // %call9 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !90 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,2+0)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,2+0)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !118, metadata !DIExpression()), !dbg !149 // %4 = load atomic i64, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !92 // LD: Guess old_cr = cr(0,2); cr(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,2)] == 0); ASSUME(cr(0,2) >= iw(0,2)); ASSUME(cr(0,2) >= 0); ASSUME(cr(0,2) >= cdy[0]); ASSUME(cr(0,2) >= cisb[0]); ASSUME(cr(0,2) >= cdl[0]); ASSUME(cr(0,2) >= cl[0]); // Update creg_r5 = cr(0,2); crmax(0,2) = max(crmax(0,2),cr(0,2)); caddr[0] = max(caddr[0],0); if(cr(0,2) < cw(0,2)) { r5 = buff(0,2); } else { if(pw(0,2) != co(2,cr(0,2))) { ASSUME(cr(0,2) >= old_cr); } pw(0,2) = co(2,cr(0,2)); r5 = mem(2,cr(0,2)); } ASSUME(creturn[0] >= cr(0,2)); // call void @llvm.dbg.value(metadata i64 %4, metadata !120, metadata !DIExpression()), !dbg !149 // %conv = trunc i64 %4 to i32, !dbg !93 // call void @llvm.dbg.value(metadata i32 %conv, metadata !117, metadata !DIExpression()), !dbg !126 // call void @llvm.dbg.value(metadata i64* @atom_1_X2_0, metadata !122, metadata !DIExpression()), !dbg !152 // %5 = load atomic i64, i64* @atom_1_X2_0 seq_cst, align 8, !dbg !95 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r6 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r6 = buff(0,3); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r6 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i64 %5, metadata !124, metadata !DIExpression()), !dbg !152 // %conv13 = trunc i64 %5 to i32, !dbg !96 // call void @llvm.dbg.value(metadata i32 %conv13, metadata !121, metadata !DIExpression()), !dbg !126 // %and = and i32 %conv, %conv13, !dbg !97 creg_r7 = max(creg_r5,creg_r6); ASSUME(active[creg_r7] == 0); r7 = r5 & r6; // call void @llvm.dbg.value(metadata i32 %and, metadata !125, metadata !DIExpression()), !dbg !126 // %cmp = icmp eq i32 %and, 1, !dbg !98 // br i1 %cmp, label %if.then, label %if.end, !dbg !100 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg_r7); ASSUME(cctrl[0] >= 0); if((r7==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([105 x i8], [105 x i8]* @.str.1, i64 0, i64 0), i32 noundef 56, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #7, !dbg !101 // unreachable, !dbg !101 r8 = 1; T0BLOCK2: // %6 = bitcast i64* %thr1 to i8*, !dbg !104 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %6) #6, !dbg !104 // %7 = bitcast i64* %thr0 to i8*, !dbg !104 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %7) #6, !dbg !104 // ret i32 0, !dbg !105 ret_thread_0 = 0; ASSERT(r8== 0); }
e0865f24d662ce5429320e877aac2618944f894c
f41dba42b2aaf9df9b52e09e47cdc25da2e6e0e9
/Trees/Child_Parent_Sum_Property.cpp
4628db8835b6166e92c131a5015164a8122b164f
[]
no_license
Satzyakiz/CP
5c9642fdede7fbe213fb98f259deda978712ef49
e869dfd2bd6f3fc692e9223c2d370b5c95904701
refs/heads/master
2023-03-02T11:52:52.472154
2021-02-03T06:50:32
2021-02-03T06:50:32
258,285,110
1
0
null
null
null
null
UTF-8
C++
false
false
914
cpp
// Given a Binary Tree. Check whether all of its nodes have the value equal // to the sum of their child nodes. // // Example 1: // // Input: // 10 // / // 10 // Output: 1 // Explanation: Here, every node is sum of // its left and right child. // Example 2: // // Input: // 1 // / \ // 4 3 // / \ // 5 N // Output: 0 // Explanation: Here, 1 is the root node // and 4, 3 are its child nodes. 4 + 3 = // 7 which is not equal to the value of // root node. Hence, this tree does not // satisfy the given conditions. int isSumProperty(Node *root) { // Add your code here if(!root) return 1; if(!root->left && !root->right) return 1; int left = root->left ? root->left->data : 0; int right = root->right ? root->right->data : 0; if(root->data != left + right) return 0; return isSumProperty(root->left) && isSumProperty(root->right); }
fd770b613b4b27bb850d88a39619d329b5861256
cc87e20a050cf557bb0266bd3945b82d35792b66
/src/exceptions.cpp
628a6125eb6ec7a1ce520a17fb6a0572076fbaac
[ "MIT" ]
permissive
thesstefan/OpenTorium
8583480469e0847b73e85e26c90e72c72191ccd3
5d419251553b6ac04fed08a96309397bc232e816
refs/heads/master
2022-01-01T06:54:09.805211
2021-10-10T10:52:37
2021-10-10T10:52:37
139,284,537
2
0
null
null
null
null
UTF-8
C++
false
false
964
cpp
#include "exceptions.h" LevelLoadFail::LevelLoadFail(const std::string& message) : std::runtime_error(message) {} const char *LevelLoadFail::what() const noexcept { return std::runtime_error::what(); } LevelIdentifierFail::LevelIdentifierFail(const std::string& message) : std::runtime_error(message) {} const char *LevelIdentifierFail::what() const noexcept { return std::runtime_error::what(); } EOFReached::EOFReached(const std::string& message) : std::runtime_error(message) {} const char *EOFReached::what() const noexcept { return std::runtime_error::what(); } UnknownType::UnknownType(const std::string& message) : std::runtime_error(message) {} const char *UnknownType::what() const noexcept { return std::runtime_error::what(); } ExtractError::ExtractError(const std::string& message) : std::runtime_error(message) {} const char *ExtractError::what() const noexcept { return std::runtime_error::what(); }
22f9c24ffaf6c3aff8c1b65aa136d99fd3869f8c
6ced41da926682548df646099662e79d7a6022c5
/aws-cpp-sdk-accessanalyzer/include/aws/accessanalyzer/model/SqsQueueConfiguration.h
a970d307161f0c7185cbf384d25d31f079996c2a
[ "Apache-2.0", "MIT", "JSON" ]
permissive
irods/aws-sdk-cpp
139104843de529f615defa4f6b8e20bc95a6be05
2c7fb1a048c96713a28b730e1f48096bd231e932
refs/heads/main
2023-07-25T12:12:04.363757
2022-08-26T15:33:31
2022-08-26T15:33:31
141,315,346
0
1
Apache-2.0
2022-08-26T17:45:09
2018-07-17T16:24:06
C++
UTF-8
C++
false
false
3,508
h
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/accessanalyzer/AccessAnalyzer_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace AccessAnalyzer { namespace Model { /** * <p>The proposed access control configuration for an Amazon SQS queue. You can * propose a configuration for a new Amazon SQS queue or an existing Amazon SQS * queue that you own by specifying the Amazon SQS policy. If the configuration is * for an existing Amazon SQS queue and you do not specify the Amazon SQS policy, * the access preview uses the existing Amazon SQS policy for the queue. If the * access preview is for a new resource and you do not specify the policy, the * access preview assumes an Amazon SQS queue without a policy. To propose deletion * of an existing Amazon SQS queue policy, you can specify an empty string for the * Amazon SQS policy. For more information about Amazon SQS policy limits, see <a * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-policies.html">Quotas * related to policies</a>.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/accessanalyzer-2019-11-01/SqsQueueConfiguration">AWS * API Reference</a></p> */ class AWS_ACCESSANALYZER_API SqsQueueConfiguration { public: SqsQueueConfiguration(); SqsQueueConfiguration(Aws::Utils::Json::JsonView jsonValue); SqsQueueConfiguration& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p> The proposed resource policy for the Amazon SQS queue. </p> */ inline const Aws::String& GetQueuePolicy() const{ return m_queuePolicy; } /** * <p> The proposed resource policy for the Amazon SQS queue. </p> */ inline bool QueuePolicyHasBeenSet() const { return m_queuePolicyHasBeenSet; } /** * <p> The proposed resource policy for the Amazon SQS queue. </p> */ inline void SetQueuePolicy(const Aws::String& value) { m_queuePolicyHasBeenSet = true; m_queuePolicy = value; } /** * <p> The proposed resource policy for the Amazon SQS queue. </p> */ inline void SetQueuePolicy(Aws::String&& value) { m_queuePolicyHasBeenSet = true; m_queuePolicy = std::move(value); } /** * <p> The proposed resource policy for the Amazon SQS queue. </p> */ inline void SetQueuePolicy(const char* value) { m_queuePolicyHasBeenSet = true; m_queuePolicy.assign(value); } /** * <p> The proposed resource policy for the Amazon SQS queue. </p> */ inline SqsQueueConfiguration& WithQueuePolicy(const Aws::String& value) { SetQueuePolicy(value); return *this;} /** * <p> The proposed resource policy for the Amazon SQS queue. </p> */ inline SqsQueueConfiguration& WithQueuePolicy(Aws::String&& value) { SetQueuePolicy(std::move(value)); return *this;} /** * <p> The proposed resource policy for the Amazon SQS queue. </p> */ inline SqsQueueConfiguration& WithQueuePolicy(const char* value) { SetQueuePolicy(value); return *this;} private: Aws::String m_queuePolicy; bool m_queuePolicyHasBeenSet; }; } // namespace Model } // namespace AccessAnalyzer } // namespace Aws
36f4816f6fba7aa62c7286f3f4a716af1a7efc14
36c8cf395214abaad868ec06bd97bf418733b1b0
/src/dpdk_wrapper/hugepage_allocator.cpp
90e06e8fd9a02294d881d4e4eb578f0d4af7afc6
[ "BSD-3-Clause" ]
permissive
south-potato/poseidonos
69435ecb2dd80c1eb702f36501156705b1908111
35c5bbd392a261d257f1ead3e8be7c3f44c5831a
refs/heads/main
2023-08-12T13:31:32.495095
2021-09-30T09:59:22
2021-10-05T02:27:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,721
cpp
/* * BSD LICENSE * Copyright (c) 2021 Samsung Electronics Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "hugepage_allocator.h" #include <rte_malloc.h> #include "src/logger/logger.h" #include "src/include/pos_event_id.hpp" using namespace pos; void* HugepageAllocator::AllocFromSocket(const uint32_t size, const uint32_t count, const uint32_t socket) { void* ret = rte_malloc_socket(nullptr, size * count, size, socket); // best effort for another socket id to avoid memory allocation fail if (ret == nullptr) { POS_TRACE_WARN(POS_EVENT_ID::HUGEPAGE_ALLOCATION_FAIL, "Failed to allocate Hugepages in socket {}. Try to another socket.", socket); ret = rte_malloc(nullptr, size * count, size); } if (ret == nullptr) { POS_TRACE_WARN(POS_EVENT_ID::HUGEPAGE_ALLOCATION_FAIL, "Failed to allocate Hugepages"); } return ret; } void HugepageAllocator::Free(void* addr) { rte_free(addr); addr = nullptr; } uint32_t HugepageAllocator::GetDefaultPageSize(void) { return DEFAULT_PAGE_SIZE; } HugepageAllocator::~HugepageAllocator(void) { }
52510f7ff17435e3d80d170443375e65801b30ea
9b3875cddd4ffc30d0cb1148ebb0a1f6a7f0479c
/run_server.cpp
5d7b1d4ca6cc2bd221da5d8fa42478340692f591
[]
no_license
smelskiyd/Cryptography
3889d1b7bd6ef1abfd87fcfac70d1d5fbfcf3cb9
0c544bd44c9efa48d46e886e1f57d31c170366dd
refs/heads/main
2023-04-16T22:56:44.201854
2021-05-08T14:30:59
2021-05-08T14:30:59
365,534,231
0
0
null
null
null
null
UTF-8
C++
false
false
187
cpp
// // Created by daniilsmelskiy on 24.04.21. // #include "server.h" #define DEFAULT_PORT 8888 int main(int argc , char* argv[]) { Server server; server.run(DEFAULT_PORT, 3); }
75c794c68a70c75c34af6e2e91ad889f3b0c5dca
0b74b4859c1242fd0793611e36d5778c1c9ece38
/extern/llvm/tools/clang/test/ASTMerge/Inputs/class-template1.cpp
1d8c8131eaca2def8328dfded6e090e4b31debd2
[ "NCSA", "MIT" ]
permissive
abduld/clreflect
682b98694ec50dfcd65168fdf40e7d04ec44e0e5
76b47c518d9b046382618a5e5863f8fe6163e595
refs/heads/master
2022-07-15T21:02:58.217422
2015-04-07T16:06:07
2015-04-07T16:06:07
35,754,939
0
0
MIT
2020-02-22T09:59:11
2015-05-17T06:36:28
C++
UTF-8
C++
false
false
432
cpp
template<typename T> struct X0; template<int I> struct X1; template<int I> struct X2; template<int I> struct X3; template<template<int I> class> struct X4; template<template<long> class> struct X5; template<typename> struct X6; extern X0<int> *x0i; extern X0<long> *x0l; extern X0<float> *x0r; template<> struct X0<char> { int member; }; template<> struct X0<wchar_t> { int member; };
85f6d887252809a52914ec89b496846dd17120e4
ed9b2767f35c37dd9ba6ff63950e6118cd2bf6e2
/vsg/src/vsg/core/Visitor.cpp
8905ddc018d18f7fd2232e7c9bbeebe696f9b556
[ "MIT" ]
permissive
robertosfield/VulkanPBRT
7bf2fc972b9819bfb71ab588eeda321388c477c1
52c15bf87c20724ddb485c9326f0cc5c7999eba2
refs/heads/master
2023-04-22T23:04:23.564145
2021-05-05T18:27:42
2021-05-05T18:27:42
366,449,423
1
0
MIT
2021-05-11T16:34:35
2021-05-11T16:34:34
null
UTF-8
C++
false
false
16,102
cpp
/* <editor-fold desc="MIT License"> Copyright(c) 2018 Robert Osfield Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. </editor-fold> */ #include <vsg/all.h> using namespace vsg; Visitor::Visitor() { } void Visitor::apply(Object&) { } void Visitor::apply(Objects& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(External& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(Data& value) { apply(static_cast<Object&>(value)); } //////////////////////////////////////////////////////////////////////////////// // // Values // void Visitor::apply(stringValue& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(boolValue& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(intValue& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uintValue& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(floatValue& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(doubleValue& value) { apply(static_cast<Data&>(value)); } //////////////////////////////////////////////////////////////////////////////// // // Arrays // void Visitor::apply(byteArray& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubyteArray& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(shortArray& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ushortArray& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(intArray& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uintArray& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(floatArray& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(doubleArray& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec2Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec3Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec2Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec3Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(bvec2Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(bvec3Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(bvec4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(svec2Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(svec3Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(svec4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ivec2Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ivec3Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ivec4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec2Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec3Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(usvec2Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(usvec3Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(usvec4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uivec2Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uivec3Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uivec4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(mat4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dmat4Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(block64Array& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(block128Array& value) { apply(static_cast<Data&>(value)); } //////////////////////////////////////////////////////////////////////////////// // // Array2Ds // void Visitor::apply(ubyteArray2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ushortArray2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uintArray2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(floatArray2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(doubleArray2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec2Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec3Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec4Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec2Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec3Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec4Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(bvec2Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(bvec3Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(bvec4Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(svec2Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(svec3Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(svec4Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ivec2Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ivec3Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ivec4Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec2Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec3Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec4Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(usvec2Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(usvec3Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(usvec4Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uivec2Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uivec3Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uivec4Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(block64Array2D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(block128Array2D& value) { apply(static_cast<Data&>(value)); } //////////////////////////////////////////////////////////////////////////////// // // Array3Ds // void Visitor::apply(ubyteArray3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ushortArray3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(uintArray3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(floatArray3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(doubleArray3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec2Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec3Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(vec4Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec2Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec3Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(dvec4Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec2Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec3Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(ubvec4Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(block64Array3D& value) { apply(static_cast<Data&>(value)); } void Visitor::apply(block128Array3D& value) { apply(static_cast<Data&>(value)); } //////////////////////////////////////////////////////////////////////////////// // // Nodes // void Visitor::apply(Node& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(Commands& value) { apply(static_cast<Node&>(value)); } void Visitor::apply(Group& value) { apply(static_cast<Node&>(value)); } void Visitor::apply(QuadGroup& value) { apply(static_cast<Node&>(value)); } void Visitor::apply(LOD& value) { apply(static_cast<Node&>(value)); } void Visitor::apply(PagedLOD& value) { apply(static_cast<Node&>(value)); } void Visitor::apply(StateGroup& value) { apply(static_cast<Group&>(value)); } void Visitor::apply(CullGroup& value) { apply(static_cast<Group&>(value)); } void Visitor::apply(CullNode& value) { apply(static_cast<Node&>(value)); } void Visitor::apply(MatrixTransform& value) { apply(static_cast<Group&>(value)); } void Visitor::apply(Geometry& value) { apply(static_cast<Command&>(value)); } void Visitor::apply(VertexIndexDraw& value) { apply(static_cast<Command&>(value)); } //////////////////////////////////////////////////////////////////////////////// // // Vulkan Object // void Visitor::apply(Command& value) { apply(static_cast<Node&>(value)); } void Visitor::apply(StateCommand& value) { apply(static_cast<Command&>(value)); } void Visitor::apply(CommandBuffer& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(RenderPass& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(BindDescriptorSet& value) { apply(static_cast<StateCommand&>(value)); } void Visitor::apply(BindDescriptorSets& value) { apply(static_cast<StateCommand&>(value)); } void Visitor::apply(Descriptor& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(DescriptorSet& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(BindVertexBuffers& value) { apply(static_cast<Command&>(value)); } void Visitor::apply(BindIndexBuffer& value) { apply(static_cast<Command&>(value)); } void Visitor::apply(BindComputePipeline& value) { apply(static_cast<StateCommand&>(value)); } void Visitor::apply(BindGraphicsPipeline& value) { apply(static_cast<StateCommand&>(value)); } void Visitor::apply(BindRayTracingPipeline& value) { apply(static_cast<StateCommand&>(value)); } void Visitor::apply(GraphicsPipeline& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(ComputePipeline& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(RayTracingPipeline& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(GraphicsPipelineState& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(ShaderStage& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(VertexInputState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(InputAssemblyState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(TessellationState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(ViewportState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(RasterizationState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(MultisampleState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(DepthStencilState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(ColorBlendState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(DynamicState& value) { apply(static_cast<GraphicsPipelineState&>(value)); } void Visitor::apply(ResourceHints& value) { apply(static_cast<Object&>(value)); } void Visitor::apply(Draw& value) { apply(static_cast<Command&>(value)); } void Visitor::apply(DrawIndexed& value) { apply(static_cast<Command&>(value)); } void Visitor::apply(ClearAttachments& value) { apply(static_cast<Command&>(value)); } //////////////////////////////////////////////////////////////////////////////// // // RTX // void Visitor::apply(DrawMeshTasks& dmt) { apply(static_cast<Command&>(dmt)); } void Visitor::apply(DrawMeshTasksIndirect& dmti) { apply(static_cast<Command&>(dmti)); } void Visitor::apply(DrawMeshTasksIndirectCount& dmtic) { apply(static_cast<Command&>(dmtic)); } //////////////////////////////////////////////////////////////////////////////// // // UI Events // void Visitor::apply(UIEvent& event) { apply(static_cast<Object&>(event)); } void Visitor::apply(WindowEvent& event) { apply(static_cast<UIEvent&>(event)); } void Visitor::apply(ExposeWindowEvent& event) { apply(static_cast<WindowEvent&>(event)); } void Visitor::apply(ConfigureWindowEvent& event) { apply(static_cast<WindowEvent&>(event)); } void Visitor::apply(CloseWindowEvent& event) { apply(static_cast<WindowEvent&>(event)); } void Visitor::apply(KeyEvent& event) { apply(static_cast<WindowEvent&>(event)); } void Visitor::apply(KeyPressEvent& event) { apply(static_cast<KeyEvent&>(event)); } void Visitor::apply(KeyReleaseEvent& event) { apply(static_cast<KeyEvent&>(event)); } void Visitor::apply(PointerEvent& event) { apply(static_cast<WindowEvent&>(event)); } void Visitor::apply(ButtonPressEvent& event) { apply(static_cast<PointerEvent&>(event)); } void Visitor::apply(ButtonReleaseEvent& event) { apply(static_cast<PointerEvent&>(event)); } void Visitor::apply(MoveEvent& event) { apply(static_cast<PointerEvent&>(event)); } void Visitor::apply(TouchEvent& event) { apply(static_cast<WindowEvent&>(event)); } void Visitor::apply(TouchDownEvent& event) { apply(static_cast<TouchEvent&>(event)); } void Visitor::apply(TouchUpEvent& event) { apply(static_cast<TouchEvent&>(event)); } void Visitor::apply(TouchMoveEvent& event) { apply(static_cast<TouchEvent&>(event)); } void Visitor::apply(ScrollWheelEvent& event) { apply(static_cast<WindowEvent&>(event)); } void Visitor::apply(TerminateEvent& event) { apply(static_cast<UIEvent&>(event)); } void Visitor::apply(FrameEvent& event) { apply(static_cast<UIEvent&>(event)); } //////////////////////////////////////////////////////////////////////////////// // // Viewer classes // void Visitor::apply(Camera& camera) { apply(static_cast<Object&>(camera)); } void Visitor::apply(CommandGraph& cg) { apply(static_cast<Group&>(cg)); } void Visitor::apply(RenderGraph& rg) { apply(static_cast<Group&>(rg)); } void Visitor::apply(View& view) { apply(static_cast<Group&>(view)); } void Visitor::apply(Viewer& viewer) { apply(static_cast<Object&>(viewer)); } //////////////////////////////////////////////////////////////////////////////// // // General classes // void Visitor::apply(FrameStamp& fs) { apply(static_cast<Object&>(fs)); }
cbd7d1a992f8e535c2c3aa620ec7df87cdfb4038
0958cceb81de1c7ee74b0c436b800a1dc54dd48a
/wincewebkit/WebKit/chromium/public/WebIDBCursor.h
09df063f34c3cb6a047d3e37078140725340465c
[ "BSD-2-Clause" ]
permissive
datadiode/WinCEWebKit
3586fac69ba7ce9efbde42250266ddbc5c920c5e
d331d103dbc58406ed610410736b59899d688632
refs/heads/master
2023-03-15T23:47:30.374484
2014-08-14T14:41:13
2014-08-14T14:41:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,660
h
/* * Copyright (C) 2010 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef WebIDBCursor_h #define WebIDBCursor_h #include "WebCommon.h" #include "WebExceptionCode.h" #include "WebIDBCallbacks.h" #include "WebIDBKey.h" #include "WebSerializedScriptValue.h" #include "WebString.h" namespace WebKit { // See comment in WebIDBFactory for a high level overview these classes. class WebIDBCursor { public: virtual ~WebIDBCursor() { } virtual unsigned short direction() const { WEBKIT_ASSERT_NOT_REACHED(); return 0; } virtual WebIDBKey key() const { WEBKIT_ASSERT_NOT_REACHED(); return WebIDBKey::createInvalid(); } // One or the other will set, depending on what type of cursor this is. virtual void value(WebSerializedScriptValue& serializedScriptValue, WebIDBKey& idbKey) const { WEBKIT_ASSERT_NOT_REACHED(); } virtual void update(const WebSerializedScriptValue&, WebIDBCallbacks*, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } virtual void continueFunction(const WebIDBKey&, WebIDBCallbacks*, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } virtual void remove(WebIDBCallbacks*, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } protected: WebIDBCursor() { } }; } // namespace WebKit #endif // WebIDBCursor_h
a95458343558341c7cbcbbbcb81090fbc0a72bba
786de89be635eb21295070a6a3452f3a7fe6712c
/pypdsdata/tags/V01-01-01/pyext/types/bld/BldDataEBeamV2.h
e6c690f29c692e2c70df5bb9b7413f5889141393
[]
no_license
connectthefuture/psdmrepo
85267cfe8d54564f99e17035efe931077c8f7a37
f32870a987a7493e7bf0f0a5c1712a5a030ef199
refs/heads/master
2021-01-13T03:26:35.494026
2015-09-03T22:22:11
2015-09-03T22:22:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,533
h
#ifndef PYPDSDATA_BLD_BLDDATAEBEAMV2_H #define PYPDSDATA_BLD_BLDDATAEBEAMV2_H //-------------------------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Class BldDataEBeamV2. // //------------------------------------------------------------------------ //----------------- // C/C++ Headers -- //----------------- //---------------------- // Base Class Headers -- //---------------------- #include "../PdsDataType.h" //------------------------------- // Collaborating Class Headers -- //------------------------------- //------------------------------------ // Collaborating Class Declarations -- //------------------------------------ #include "pdsdata/psddl/bld.ddl.h" // --------------------- // -- Class Interface -- // --------------------- namespace pypdsdata { namespace Bld { /// @addtogroup pypdsdata /** * @ingroup pypdsdata * * This software was developed for the LUSI project. If you use all or * part of it, please give an appropriate acknowledgment. * * @version $Id$ * * @author Andrei Salnikov */ class BldDataEBeamV2 : public PdsDataType<BldDataEBeamV2,Pds::Bld::BldDataEBeamV2> { public: typedef PdsDataType<BldDataEBeamV2,Pds::Bld::BldDataEBeamV2> BaseType; /// Initialize Python type and register it in a module static void initType( PyObject* module ); // dump to a stream void print(std::ostream& out) const; }; } // namespace Bld } // namespace pypdsdata #endif // PYPDSDATA_BLD_BLDDATAEBEAMV2_H
[ "[email protected]@b967ad99-d558-0410-b138-e0f6c56caec7" ]
[email protected]@b967ad99-d558-0410-b138-e0f6c56caec7
3dd713782eae940d6811f10679813e4223bb63da
522547e1ae4452ba9235e97b1dc00d6d55b196ec
/Character count.cpp
6b31fff96525b13741669eb48123d72562650cab
[]
no_license
nachomonllor/Codechef
2045edf65be8de83583f7eb9c6b1435ef5563587
a49f7ac45b242694d13fa215f40b9e397b79599e
refs/heads/master
2023-01-12T08:10:26.271742
2023-01-01T02:11:53
2023-01-01T02:11:53
216,129,034
0
0
null
null
null
null
UTF-8
C++
false
false
380
cpp
https://www.codechef.com/problems/R101 #include <iostream> #include <stdio.h> using namespace std; int main() { std::string s; char ch; std::getline(std::cin, s); cin >> ch; int answer =0; for(int i =0; i<s.size(); i++) { if(s[i] == ch) { answer++; } } cout << answer << endl; //system("pause"); return 0; }
0e0dc8eddc028b54b0532897e346e888a871f39d
63c759faed96b9606fcb02b380cb281ca7b4f741
/DS_Project/MarsStation.h
f44a6f2f3a7d895cd8791c651a94779413653d52
[]
no_license
MennaTalhHossamAlden/Mars_Exploration
29eb983af519e322dd80513277b75775f6f8dbd9
40a9a049588d5a6fb0e2b83020b1a8d64fa07108
refs/heads/master
2023-05-18T19:32:49.041432
2021-06-07T20:38:46
2021-06-07T20:38:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,178
h
#pragma once #include "Event.h" #include "Rover.h" #include "Mission.h" #include "Defs.h" #include "PEvent.h" #include "FEvent.h" #include "CEvent.h" #include "UI.h" using namespace std; class MarsStation { private: UI userInterface; // Object from UI class int no_EmerR, no_polarR, no_mountainousR; // int Max_Mission_before_checkup; int P_CK, M_CK, E_CK; int AutoP; int no_events; int formulated; int cancelled; int WaitingM; int InExecution; int Rovers; int CheckupRovers; int CompletedM; int UImode; bool Exit; // boolean Expression to terminate the program Queue<Event*> EventList; PriorityQueue<Rover*> Emergency_Rovers; PriorityQueue<Rover*> Mountainous_Rovers; PriorityQueue<Rover*> Polar_Rovers; PriorityQueue<Rover*> RoversInCheckUp; PriorityQueue<Rover*> RoversInExecution; PriorityQueue<Missions*> Emergency_Missions; LinkedList<Missions*> Mountainous_Missions; Queue<Missions*> Polar_Missions; Queue<Missions*> CompletedMissions; int countAutoPromotion; int CurrentStep; int Mmissions; // to use it in output File public: MarsStation(); void GetInput();//Get Input From User bool DeleteFromMountList(int id, Missions* &m);//Delete From Mountainous List void AddToEmergencyList(Missions*, float);//Add To Emergency List void AddToPolarList(Missions*);//Add To Polar List void AddToMountList(Missions*);//Add To Mountainous List void Simulation();//Simulation Of The Program void AssignToRover();//Assigning Rover To Mission void ExecuteEvent();//Execution Event void endCheckUp(); // Extract the rovers from the checkup list bool startCheckUp(Rover* myRover); // start the checkup of a rover void checkCompleted(); // check if the mission is completed or not void dayDetails(); void AddToPolarRover(Rover* P); void AddToMountRover(Rover* M); void AddToEmerRover(Rover* E); void printDay(); void AutoPromote(); // Increment Auto Promoted to use it in Output File void incrementAutoP(); // Increment Cancelled to use it in Output File void incrementCancelled(); //needed for getting information from input File int getCountAutoPromotion(); // Create Output File void outputFile(); ~MarsStation(); };
0fbc09da60756981f21a8f5b33c538b9963a95c9
73e7c20803be5d8ae467af1feba8a4a7fe219f4b
/Modules/Filtering/Deconvolution/include/itkProjectedLandweberDeconvolutionImageFilter.h
28ee16173e6d7d61b3364b66de239db25ac4864c
[ "LicenseRef-scancode-other-permissive", "SMLNJ", "BSD-3-Clause", "LicenseRef-scancode-mit-old-style", "LicenseRef-scancode-free-unknown", "BSD-4.3TAHOE", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-unknown-license-reference", "IJG", "Zlib", "Spencer-86", "libtiff", "Apache-2.0", "MIT", "LicenseRef-scancode-public-domain", "NTP", "BSD-2-Clause", "GPL-1.0-or-later", "FSFUL", "Libpng" ]
permissive
CIBC-Internal/itk
deaa8aabe3995f3465ec70a46805bd333967ed5b
6f7b1014a73857115d6da738583492008bea8205
refs/heads/master
2021-01-10T18:48:58.502855
2018-01-26T21:25:51
2018-01-26T21:25:51
31,582,564
0
2
Apache-2.0
2018-05-21T07:59:53
2015-03-03T06:12:12
C++
UTF-8
C++
false
false
3,790
h
/*========================================================================= * * Copyright Insight Software Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef itkProjectedLandweberDeconvolutionImageFilter_h #define itkProjectedLandweberDeconvolutionImageFilter_h #include "itkProjectedIterativeDeconvolutionImageFilter.h" #include "itkLandweberDeconvolutionImageFilter.h" namespace itk { /** \class ProjectedLandweberDeconvolutionImageFilter * \brief Deconvolve an image using the projected Landweber * deconvolution algorithm. * * This filter performs the same calculation per iteration as the * LandweberDeconvolutionImageFilter. However, at each iteration, * negative pixels in the intermediate result are projected (set) to * zero. This is useful if the solution is assumed to always be * non-negative, which is the case when dealing with images formed by * counting photons, for example. * * This code was adapted from the Insight Journal contribution: * * "Deconvolution: infrastructure and reference algorithms" * by Gaetan Lehmann * https://hdl.handle.net/10380/3207 * * \author Gaetan Lehmann, Biologie du Developpement et de la Reproduction, INRA de Jouy-en-Josas, France * \author Cory Quammen, The University of North Carolina at Chapel Hill * * \ingroup ITKDeconvolution * \sa IterativeDeconvolutionImageFilter * \sa RichardsonLucyDeconvolutionImageFilter * \sa LandweberDeconvolutionImageFilter */ template< typename TInputImage, typename TKernelImage=TInputImage, typename TOutputImage=TInputImage, typename TInternalPrecision=double > class ProjectedLandweberDeconvolutionImageFilter : public ProjectedIterativeDeconvolutionImageFilter< LandweberDeconvolutionImageFilter< TInputImage, TKernelImage, TOutputImage, TInternalPrecision > > { public: /** Standard typedefs. */ typedef ProjectedLandweberDeconvolutionImageFilter Self; typedef ProjectedIterativeDeconvolutionImageFilter< LandweberDeconvolutionImageFilter< TInputImage, TKernelImage, TOutputImage, TInternalPrecision > > Superclass; typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; /** Other useful typedefs. */ typedef TInputImage InputImageType; typedef TKernelImage KernelImageType; typedef TOutputImage OutputImageType; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Runtime information support. */ itkTypeMacro(ProjectedLandweberDeconvolutionImageFilter, ProjectedIterativeDeconvolutionImageFilter); protected: ProjectedLandweberDeconvolutionImageFilter(); virtual ~ProjectedLandweberDeconvolutionImageFilter(); private: ProjectedLandweberDeconvolutionImageFilter(const Self &) ITK_DELETE_FUNCTION; void operator=(const Self &) ITK_DELETE_FUNCTION; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkProjectedLandweberDeconvolutionImageFilter.hxx" #endif #endif
44d10d8272946faa3b76c8466fc49db6980a427c
db0912a96da31747e147a3a16ddf1bbfe6adaa21
/Proxy.cpp
569a73c28f0afbe37b7db869c64a4c03893fe629
[]
no_license
Intrets/ui
c4be36f9587e9b8680c35675f433e01df661adcd
a015515345aaef2ada343bcedaa2ea2854dc3854
refs/heads/master
2023-06-16T16:54:09.895518
2021-07-14T20:47:25
2021-07-14T20:47:25
383,297,099
0
0
null
null
null
null
UTF-8
C++
false
false
120
cpp
#include "Proxy.h" namespace ui { UniqueReference<Base, Base> Proxy::getMain() { return std::move(this->main); } }
711db2739bffe94d0d64292d25a32ae5687ed506
5e4dc2622d59a9b6f151a4abb964c2db49a02c43
/Libraries/LibGUI/GAction.h
58cf4a7c10ee9f7dce4bec14dbf0bd35fe0caba0
[ "BSD-2-Clause" ]
permissive
HasanulRafi/serenity
575077ce1440064c968bde49b84566dae4b761c4
78a63930cca64e78a6ba7ed30d46ec8570dd3bde
refs/heads/master
2020-12-05T21:52:07.636762
2020-01-06T20:04:57
2020-01-06T20:04:57
232,256,992
1
0
BSD-2-Clause
2020-01-07T06:21:06
2020-01-07T06:21:05
null
UTF-8
C++
false
false
5,312
h
#pragma once #include <AK/String.h> #include <AK/Badge.h> #include <AK/Function.h> #include <AK/HashTable.h> #include <AK/NonnullRefPtr.h> #include <AK/RefCounted.h> #include <AK/WeakPtr.h> #include <AK/Weakable.h> #include <LibDraw/GraphicsBitmap.h> #include <LibGUI/GShortcut.h> #include <LibGUI/GWindow.h> class GAction; class GActionGroup; class GButton; class GMenuItem; class GWidget; namespace GCommonActions { NonnullRefPtr<GAction> make_open_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_undo_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_redo_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_cut_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_copy_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_paste_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_delete_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_move_to_front_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_move_to_back_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_fullscreen_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_quit_action(Function<void(GAction&)>); NonnullRefPtr<GAction> make_go_back_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_go_forward_action(Function<void(GAction&)>, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_go_home_action(Function<void(GAction&)> callback, GWidget* widget = nullptr); NonnullRefPtr<GAction> make_reload_action(Function<void(GAction&)>, GWidget* widget = nullptr); }; class GAction : public RefCounted<GAction> , public Weakable<GAction> { public: enum class ShortcutScope { None, ApplicationGlobal, WidgetLocal, }; static NonnullRefPtr<GAction> create(const StringView& text, Function<void(GAction&)> callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, move(callback), widget)); } static NonnullRefPtr<GAction> create(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, move(icon), move(callback), widget)); } static NonnullRefPtr<GAction> create(const StringView& text, const GShortcut& shortcut, Function<void(GAction&)> callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, shortcut, move(callback), widget)); } static NonnullRefPtr<GAction> create(const StringView& text, const GShortcut& shortcut, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, shortcut, move(icon), move(callback), widget)); } ~GAction(); GWidget* widget() { return m_widget.ptr(); } const GWidget* widget() const { return m_widget.ptr(); } String text() const { return m_text; } GShortcut shortcut() const { return m_shortcut; } const GraphicsBitmap* icon() const { return m_icon.ptr(); } void set_icon(const GraphicsBitmap* icon) { m_icon = icon; } const CObject* activator() const { return m_activator.ptr(); } CObject* activator() { return m_activator.ptr(); } Function<void(GAction&)> on_activation; void activate(CObject* activator = nullptr); bool is_enabled() const { return m_enabled; } void set_enabled(bool); bool is_checkable() const { return m_checkable; } void set_checkable(bool checkable) { m_checkable = checkable; } bool is_checked() const { ASSERT(is_checkable()); return m_checked; } void set_checked(bool); void register_button(Badge<GButton>, GButton&); void unregister_button(Badge<GButton>, GButton&); void register_menu_item(Badge<GMenuItem>, GMenuItem&); void unregister_menu_item(Badge<GMenuItem>, GMenuItem&); const GActionGroup* group() const { return m_action_group.ptr(); } void set_group(Badge<GActionGroup>, GActionGroup*); private: GAction(const StringView& text, Function<void(GAction&)> = nullptr, GWidget* = nullptr); GAction(const StringView& text, const GShortcut&, Function<void(GAction&)> = nullptr, GWidget* = nullptr); GAction(const StringView& text, const GShortcut&, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> = nullptr, GWidget* = nullptr); GAction(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> = nullptr, GWidget* = nullptr); template<typename Callback> void for_each_toolbar_button(Callback); template<typename Callback> void for_each_menu_item(Callback); String m_text; RefPtr<GraphicsBitmap> m_icon; GShortcut m_shortcut; bool m_enabled { true }; bool m_checkable { false }; bool m_checked { false }; ShortcutScope m_scope { ShortcutScope::None }; HashTable<GButton*> m_buttons; HashTable<GMenuItem*> m_menu_items; WeakPtr<GWidget> m_widget; WeakPtr<GActionGroup> m_action_group; WeakPtr<CObject> m_activator; };
c1f9b36e408b8c6da77b4b85360b7cfd840906db
68183d5b5d3f2cbebbdd71e0a182161528645937
/C语言程序设计与实践/插入排序 002.cpp
ce4e6735e4142271ee9add7af507fca658ed0ece
[]
no_license
xfhy/C-programming-road
0e9d6d117e459bbdf62cc26eac787af9b2f7b06c
9c0ea7dffe849e890e9b34d7b415b56715306eaf
refs/heads/master
2021-01-22T07:22:34.631809
2017-02-13T09:52:50
2017-02-13T09:52:50
81,809,382
1
0
null
null
null
null
GB18030
C++
false
false
709
cpp
/* 2015年4月9日16:57:51 插入排序 */ # include <stdio.h> int main(void) { int a[10] = {151,154,15,2365,14,1654,26,3216,45,28}; int b[10] = {0}; //依次从a中取数,插入到b中,保持b有序 int i,j; int x,k,n=0; for(i=0; i<10; i++) { x = a[i]; for(j=0; j<n; j++) { if(b[j]>x) //找到第一个大于x 的位置 { break; } } k = j; for(j=n-1; j>=k; j--) //从k开始,一直到最后那个(n-1) { b[j+1] = b[j]; //往后移一个 } b[k] = x; //将x赋给刚好将x夹在中间的那个地方 n++; //n持续增加 n为元素个数 } for(i=0; i<10; i++) printf("%5d",b[i]); return 0; }
6f2fec5ed07fd7cdad3082a3f4ee40ab5116265f
0d2deffa50a1596fbc5c4b04b7235932c0f6a695
/src/db.h
564a3569b4aa65b9a74fa119b540196b7aac7e69
[ "MIT" ]
permissive
cjcoingit/cjcoingitrepo
031cf3f3abdb07cfcfc5aa5d6d93916ff58e2b1a
edbf67c2bfd9050862334f32f9a1922c684857b2
refs/heads/master
2021-01-18T23:34:52.463067
2017-04-10T18:28:41
2017-04-10T18:28:41
87,119,204
1
2
null
null
null
null
UTF-8
C++
false
false
8,735
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2016 The Bitcoin developers // Copyright (c) 2016 The Cryptojournal developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_DB_H #define BITCOIN_DB_H #include "main.h" #include <map> #include <string> #include <vector> #include <db_cxx.h> class CAddress; class CAddrMan; class CBlockLocator; class CDiskBlockIndex; class CDiskTxPos; class CMasterKey; class COutPoint; class CTxIndex; class CWallet; class CWalletTx; extern unsigned int nWalletDBUpdated; void ThreadFlushWalletDB(void* parg); bool BackupWallet(const CWallet& wallet, const std::string& strDest); class CDBEnv { private: bool fDetachDB; bool fDbEnvInit; bool fMockDb; boost::filesystem::path pathEnv; std::string strPath; void EnvShutdown(); public: mutable CCriticalSection cs_db; DbEnv dbenv; std::map<std::string, int> mapFileUseCount; std::map<std::string, Db*> mapDb; CDBEnv(); ~CDBEnv(); void MakeMock(); bool IsMock() { return fMockDb; }; /* * Verify that database file strFile is OK. If it is not, * call the callback to try to recover. * This must be called BEFORE strFile is opened. * Returns true if strFile is OK. */ enum VerifyResult { VERIFY_OK, RECOVER_OK, RECOVER_FAIL }; VerifyResult Verify(std::string strFile, bool (*recoverFunc)(CDBEnv& dbenv, std::string strFile)); /* * Salvage data from a file that Verify says is bad. * fAggressive sets the DB_AGGRESSIVE flag (see berkeley DB->verify() method documentation). * Appends binary key/value pairs to vResult, returns true if successful. * NOTE: reads the entire database into memory, so cannot be used * for huge databases. */ typedef std::pair<std::vector<unsigned char>, std::vector<unsigned char> > KeyValPair; bool Salvage(std::string strFile, bool fAggressive, std::vector<KeyValPair>& vResult); bool Open(boost::filesystem::path pathEnv_); void Close(); void Flush(bool fShutdown); void CheckpointLSN(std::string strFile); void SetDetach(bool fDetachDB_) { fDetachDB = fDetachDB_; } bool GetDetach() { return fDetachDB; } void CloseDb(const std::string& strFile); bool RemoveDb(const std::string& strFile); DbTxn *TxnBegin(int flags=DB_TXN_WRITE_NOSYNC) { DbTxn* ptxn = NULL; int ret = dbenv.txn_begin(NULL, &ptxn, flags); if (!ptxn || ret != 0) return NULL; return ptxn; } }; extern CDBEnv bitdb; /** RAII class that provides access to a Berkeley database */ class CDB { protected: Db* pdb; std::string strFile; DbTxn *activeTxn; bool fReadOnly; explicit CDB(const char* pszFile, const char* pszMode="r+"); ~CDB() { Close(); } public: void Close(); private: CDB(const CDB&); void operator=(const CDB&); protected: template<typename K, typename T> bool Read(const K& key, T& value) { if (!pdb) return false; // Key CDataStream ssKey(SER_DISK, CLIENT_VERSION); ssKey.reserve(1000); ssKey << key; Dbt datKey(&ssKey[0], ssKey.size()); // Read Dbt datValue; datValue.set_flags(DB_DBT_MALLOC); int ret = pdb->get(activeTxn, &datKey, &datValue, 0); memset(datKey.get_data(), 0, datKey.get_size()); if (datValue.get_data() == NULL) return false; // Unserialize value try { CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION); ssValue >> value; } catch (std::exception &e) { return false; } // Clear and free memory memset(datValue.get_data(), 0, datValue.get_size()); free(datValue.get_data()); return (ret == 0); } template<typename K, typename T> bool Write(const K& key, const T& value, bool fOverwrite=true) { if (!pdb) return false; if (fReadOnly) assert(!"Write called on database in read-only mode"); // Key CDataStream ssKey(SER_DISK, CLIENT_VERSION); ssKey.reserve(1000); ssKey << key; Dbt datKey(&ssKey[0], ssKey.size()); // Value CDataStream ssValue(SER_DISK, CLIENT_VERSION); ssValue.reserve(10000); ssValue << value; Dbt datValue(&ssValue[0], ssValue.size()); // Write int ret = pdb->put(activeTxn, &datKey, &datValue, (fOverwrite ? 0 : DB_NOOVERWRITE)); // Clear memory in case it was a private key memset(datKey.get_data(), 0, datKey.get_size()); memset(datValue.get_data(), 0, datValue.get_size()); return (ret == 0); } template<typename K> bool Erase(const K& key) { if (!pdb) return false; if (fReadOnly) assert(!"Erase called on database in read-only mode"); // Key CDataStream ssKey(SER_DISK, CLIENT_VERSION); ssKey.reserve(1000); ssKey << key; Dbt datKey(&ssKey[0], ssKey.size()); // Erase int ret = pdb->del(activeTxn, &datKey, 0); // Clear memory memset(datKey.get_data(), 0, datKey.get_size()); return (ret == 0 || ret == DB_NOTFOUND); } template<typename K> bool Exists(const K& key) { if (!pdb) return false; // Key CDataStream ssKey(SER_DISK, CLIENT_VERSION); ssKey.reserve(1000); ssKey << key; Dbt datKey(&ssKey[0], ssKey.size()); // Exists int ret = pdb->exists(activeTxn, &datKey, 0); // Clear memory memset(datKey.get_data(), 0, datKey.get_size()); return (ret == 0); } Dbc* GetCursor() { if (!pdb) return NULL; Dbc* pcursor = NULL; int ret = pdb->cursor(NULL, &pcursor, 0); if (ret != 0) return NULL; return pcursor; } int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags=DB_NEXT) { // Read at cursor Dbt datKey; if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) { datKey.set_data(&ssKey[0]); datKey.set_size(ssKey.size()); } Dbt datValue; if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) { datValue.set_data(&ssValue[0]); datValue.set_size(ssValue.size()); } datKey.set_flags(DB_DBT_MALLOC); datValue.set_flags(DB_DBT_MALLOC); int ret = pcursor->get(&datKey, &datValue, fFlags); if (ret != 0) return ret; else if (datKey.get_data() == NULL || datValue.get_data() == NULL) return 99999; // Convert to streams ssKey.SetType(SER_DISK); ssKey.clear(); ssKey.write((char*)datKey.get_data(), datKey.get_size()); ssValue.SetType(SER_DISK); ssValue.clear(); ssValue.write((char*)datValue.get_data(), datValue.get_size()); // Clear and free memory memset(datKey.get_data(), 0, datKey.get_size()); memset(datValue.get_data(), 0, datValue.get_size()); free(datKey.get_data()); free(datValue.get_data()); return 0; } public: bool TxnBegin() { if (!pdb || activeTxn) return false; DbTxn* ptxn = bitdb.TxnBegin(); if (!ptxn) return false; activeTxn = ptxn; return true; } bool TxnCommit() { if (!pdb || !activeTxn) return false; int ret = activeTxn->commit(0); activeTxn = NULL; return (ret == 0); } bool TxnAbort() { if (!pdb || !activeTxn) return false; int ret = activeTxn->abort(); activeTxn = NULL; return (ret == 0); } bool ReadVersion(int& nVersion) { nVersion = 0; return Read(std::string("version"), nVersion); } bool WriteVersion(int nVersion) { return Write(std::string("version"), nVersion); } bool static Rewrite(const std::string& strFile, const char* pszSkip = NULL); }; /** Access to the (IP) address database (peers.dat) */ class CAddrDB { private: boost::filesystem::path pathAddr; public: CAddrDB(); bool Write(const CAddrMan& addr); bool Read(CAddrMan& addr); }; #endif // BITCOIN_DB_H
1aa62cd368b658a642de359a72144d46edf5a322
404547b1ec3237f02342fe65e957f32851ce1495
/Importer/ge_meshimporter.h
0444d7202df661eb6112e852c787e30cee177b82
[]
no_license
Adanos-Gotoman/GenomeSDK-R
c5e3a5d57c4fb721b15bb7f572454f2a3021561a
cf87f21fca83b37d2e186fb69b083b72932f9c8c
refs/heads/master
2023-03-16T07:05:00.799421
2021-02-19T16:07:09
2021-02-19T16:07:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,799
h
#ifndef GE_MESHIMPORTER_H_INCLUDED #define GE_MESHIMPORTER_H_INCLUDED #pragma warning( push ) #pragma warning( disable : 4251 ) // class 'bTPtrArray<T>' needs to have dll-interface to be used by clients of class 'iCMeshImporter' class GE_DLLIMPORT iCMeshImporter { public: virtual void Destroy( void ); public: virtual GEBool Create( void ); public: virtual GEBool CopyFrom( iCMeshImporter const & ); public: virtual ~iCMeshImporter( void ); protected: bCString m_strImportFilePath; bCString m_strLayerName; bCString m_strMeshFilePath; bCString m_strMaterialFilePath; bCString m_strImageFilePath; bCString m_strCellifiedMeshName; GEBool m_bMaterialWrite; GEBool m_bMeshWrite; GEBool m_bReplaceOldMeshFiles; GEBool m_bReplaceOldMaterialFiles; GEBool m_bSkipCollisionMeshes; GEBool m_bCalculateAmbientOcclusion; GEBool m_bWriteStaticEntities; GEBool m_bCellifierEnabled; GEBool m_bFixScaling; GEBool m_bEntityUpdate; GEBool m_bEntityDelete; GEBool m_bMultipleEntityWriteForLODMesh; GEFloat m_fAOShadowSoftness; GEFloat m_fScaleFactor; GEFloat m_fCellSize; gCSector * m_pSector; bTPtrArray< gCDynamicLayer * > m_arrLayers; protected: GEBool CollectCellEntities( eCEntity *, bTPtrArray< eCEntity * > & ); eCEntity * CreateVisualEntity( eCEntity *, bCString const &, GEBool ); void Invalidate( void ); public: void FillImportMeshValues( void ); void FillImportSceneValues( GEBool ); void FillStandardValues( void ); GEFloat GetAOShadowSoftness( void ) const; GEBool GetCalculateAmbientOcclusion( void ) const; GEFloat GetCellSize( void ) const; bCString const & GetCellifiedMeshName( void ) const; GEBool GetCellifierEnabled( void ) const; GEBool GetEntityDelete( void ) const; GEBool GetEntityUpdate( void ) const; GEBool GetFixScaling( void ) const; bCString const & GetImageFilePath( void ) const; bCString const & GetImportFilePath( void ) const; bCString const & GetLayerName( void ) const; bCString const & GetMaterialFilePath( void ) const; GEBool GetMaterialWrite( void ) const; bCString const & GetMeshFilePath( void ) const; GEBool GetMeshWrite( void ) const; GEBool GetMultipleEntityWriteForLODMesh( void ) const; GEBool GetReplaceOldMaterialFiles( void ) const; GEBool GetReplaceOldMeshFiles( void ) const; GEFloat GetScaleFactor( void ) const; gCSector * GetSector( void ) const; GEBool GetSkipCollisionMeshes( void ) const; GEBool GetWriteStaticEntities( void ) const; GEBool Process( void ); GEBool ProcessMeshOnly( void ); void SetAOShadowSoftness( GEFloat ); void SetCalculateAmbientOcclusion( GEBool ); void SetCellSize( GEFloat ); void SetCellifiedMeshName( bCString const & ); void SetCellifierEnable( GEBool ); void SetEntityDelete( GEBool ); void SetEntityUpdate( GEBool ); void SetFixScaling( GEBool ); void SetImageFilePath( bCString const & ); void SetImportFilePath( bCString const & ); void SetLayerName( bCString const & ); void SetMaterialFilePath( bCString const & ); void SetMaterialWrite( GEBool ); void SetMeshFilePath( bCString const & ); void SetMeshWrite( GEBool ); void SetMultipleEntityWriteForLODMesh( GEBool ); void SetReplaceOldMaterialFiles( GEBool ); void SetReplaceOldMeshFiles( GEBool ); void SetScaleFactor( GEFloat ); void SetSector( gCSector * ); void SetSkipCollisionMeshes( GEBool ); void SetWriteStaticEntities( GEBool ); public: iCMeshImporter & operator = ( iCMeshImporter const & ); public: iCMeshImporter( iCMeshImporter const & ); iCMeshImporter( void ); }; GE_ASSERT_SIZEOF( iCMeshImporter, 0x0044 ) #pragma warning( pop ) #endif
0c803135c3536cb2141ec6ef84e0e78252aa4f97
2266e6c2e4713279a7fef0293d1806808a944a25
/Linked_List/dellistll.cpp
79d8be4940f098a29baf0c84239eaaeb739e89d5
[ "MIT" ]
permissive
Nilesh-Das/dsalgo
9e2d7d1c050995c5195ce77b7051934abbaec564
2454f272a5de47e7b9cfbde73bf7c01d0d1492a2
refs/heads/main
2023-06-24T18:07:55.131414
2021-07-24T22:15:15
2021-07-24T22:15:15
389,197,236
0
0
null
null
null
null
UTF-8
C++
false
false
1,381
cpp
// C++ program to delete a linked list #include <bits/stdc++.h> using namespace std; /* Link list node */ class Node { public: int data; Node* next; }; /* Function to delete the entire linked list */ void deleteList(Node** head_ref) { /* deref head_ref to get the real head */ Node* current = *head_ref; Node* next; while (current != NULL) { next = current->next; free(current); current = next; } /* deref head_ref to affect the real head back in the caller. */ *head_ref = NULL; } /* Given a reference (pointer to pointer) to the head of a list and an int, push a new node on the front of the list. */ void push(Node** head_ref, int new_data) { /* allocate node */ Node* new_node = new Node(); /* put in the data */ new_node->data = new_data; /* link the old list off the new node */ new_node->next = (*head_ref); /* move the head to point to the new node */ (*head_ref) = new_node; } /* Driver code*/ int main() { /* Start with the empty list */ Node* head = NULL; /* Use push() to construct below list 1->12->1->4->1 */ push(&head, 1); push(&head, 4); push(&head, 1); push(&head, 12); push(&head, 1); cout << "Deleting linked list"; deleteList(&head); cout << "\nLinked list deleted"; }
45721785ca261e14a82eb370e6bdc6cf74e39e28
c46f36a0000c27fce27f413032b7c11c0fb55528
/glbuttonlist.h
f19a86d1da8de7ec770570694285b8c3e63b41c2
[]
no_license
mikejg/shinyPlayer
8b141d3cb71ae2d647fe3247061903819e30b9db
e48b03f217dbfb0291faad3214255df09c78b30e
refs/heads/master
2016-09-05T23:28:40.872874
2012-04-21T12:50:14
2012-04-21T12:50:14
2,242,896
0
0
null
null
null
null
UTF-8
C++
false
false
715
h
/*GlButtonList hält eine anzahl von GlButtons. Wird ein Button angeklickt sendet GlButtonList das Signal buttonClicked mit dem Text des Buttons*/ #ifndef GLBUTTONLIST_H #define GLBUTTONLIST_H #include "globject.h" #include "glbutton.h" #include <QList> class GlButtonList : public GlObject { Q_OBJECT private: QList<GlButton *> buttonList; public: GlButtonList(GlObject* parent = 0); void draw(QPainter *p); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void setGeometry(int posX, int posY, int w, int h); void setLarge(); public slots: void clicked(); signals: void buttonClicked(QString); }; #endif // GLBUTTONLIST_H