blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
f7ec36f2266507585f19110ac46c5e0cc0852047
203f8465075e098f69912a6bbfa3498c36ce2a60
/motion_planning/planning_environment/src/util/construct_object.cpp
138e0baf0249955fc654c0a5e31d0dbd037415af
[]
no_license
robcn/personalrobots-pkg
a4899ff2db9aef00a99274d70cb60644124713c9
4dcf3ca1142d3c3cb85f6d42f7afa33c59e2240a
refs/heads/master
2021-06-20T16:28:29.549716
2009-09-04T23:56:10
2009-09-04T23:56:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,358
cpp
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2008, Willow Garage, 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: * * * 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 the Willow Garage 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. *********************************************************************/ /** \author Ioan Sucan */ #include "planning_environment/util/construct_object.h" #include <ros/console.h> shapes::Shape* planning_environment::constructObject(const mapping_msgs::Object &obj) { shapes::Shape *shape = NULL; if (obj.type == mapping_msgs::Object::SPHERE) { if (obj.dimensions.size() != 1) ROS_ERROR("Unexpected number of dimensions in sphere definition"); else shape = new shapes::Sphere(obj.dimensions[0]); } else if (obj.type == mapping_msgs::Object::BOX) { if (obj.dimensions.size() != 3) ROS_ERROR("Unexpected number of dimensions in box definition"); else shape = new shapes::Box(obj.dimensions[0], obj.dimensions[1], obj.dimensions[2]); } else if (obj.type == mapping_msgs::Object::CYLINDER) { if (obj.dimensions.size() != 2) ROS_ERROR("Unexpected number of dimensions in cylinder definition"); else shape = new shapes::Cylinder(obj.dimensions[0], obj.dimensions[1]); } else if (obj.type == mapping_msgs::Object::MESH) { if (obj.dimensions.size() != 0) ROS_ERROR("Unexpected number of dimensions in mesh definition"); else { if (obj.triangles.size() % 3 != 0) ROS_ERROR("Number of triangle indices is not divisible by 3"); else { if (obj.triangles.empty() || obj.vertices.empty()) ROS_ERROR("Mesh definition is empty"); else { std::vector<btVector3> vertices(obj.vertices.size()); std::vector<unsigned int> triangles(obj.triangles.size()); for (unsigned int i = 0 ; i < obj.vertices.size() ; ++i) vertices[i].setValue(obj.vertices[i].x, obj.vertices[i].y, obj.vertices[i].z); for (unsigned int i = 0 ; i < obj.triangles.size() ; ++i) triangles[i] = obj.triangles[i]; shape = shapes::createMeshFromVertices(vertices, triangles); } } } } if (shape == NULL) ROS_ERROR("Unable to construct shape corresponding to object of type %d", (int)obj.type); return shape; } bool planning_environment::constructObjectMsg(const shapes::Shape* shape, mapping_msgs::Object &obj) { obj.dimensions.clear(); obj.vertices.clear(); obj.triangles.clear(); if (shape->type == shapes::SPHERE) { obj.type = mapping_msgs::Object::SPHERE; obj.dimensions.push_back(static_cast<const shapes::Sphere*>(shape)->radius); } else if (shape->type == shapes::BOX) { obj.type = mapping_msgs::Object::BOX; const double* sz = static_cast<const shapes::Box*>(shape)->size; obj.dimensions.push_back(sz[0]); obj.dimensions.push_back(sz[1]); obj.dimensions.push_back(sz[2]); } else if (shape->type == shapes::CYLINDER) { obj.type = mapping_msgs::Object::CYLINDER; obj.dimensions.push_back(static_cast<const shapes::Cylinder*>(shape)->radius); obj.dimensions.push_back(static_cast<const shapes::Cylinder*>(shape)->length); } else if (shape->type == shapes::MESH) { const shapes::Mesh *mesh = static_cast<const shapes::Mesh*>(shape); const unsigned int t3 = mesh->triangleCount * 3; obj.vertices.resize(mesh->vertexCount); obj.triangles.resize(t3); for (unsigned int i = 0 ; i < mesh->vertexCount ; ++i) { obj.vertices[i].x = mesh->vertices[3 * i ]; obj.vertices[i].y = mesh->vertices[3 * i + 1]; obj.vertices[i].z = mesh->vertices[3 * i + 2]; } for (unsigned int i = 0 ; i < t3 ; ++i) obj.triangles[i] = mesh->triangles[i]; } else { ROS_ERROR("Unable to construct object message for shape of type %d", (int)shape->type); return false; } return true; }
[ "isucan@f5854215-dd47-0410-b2c4-cdd35faa7885" ]
isucan@f5854215-dd47-0410-b2c4-cdd35faa7885
66f5062f76b13cfe3e96b459dfa925691e4cf965
bc7656e48461f8a34a8c6d210005457214cc9785
/Zohar/Zohar/Event.h
1f7167fca153ac1878ef027e5bafdfd2cd300572
[]
no_license
Shchori/Software-Engineering-Methods
5ebd750a7d14d9dd0d3ab89a25f2cf5320fa3c37
280f2f773b78151df837056680571d31a92ae637
refs/heads/master
2021-01-21T04:30:38.871941
2016-07-08T19:10:26
2016-07-08T19:10:26
53,124,257
0
1
null
2016-06-25T11:19:48
2016-03-04T09:34:53
C++
UTF-8
C++
false
false
282
h
/*#pragma once #include <stdio.h> #include <string> #include <windows.h> using namespace std; class Event { public: virtual int mouseEvent(MOUSE_EVENT_RECORD mer, HANDLE output, Lable &lable) = 0; virtual int keyPress(KEY_EVENT_RECORD ker, HANDLE output, COORD) = 0; }; */
[ "tz.zohar@gmail.com" ]
tz.zohar@gmail.com
e17c3c7d682879c054551ccfd003f0633a62f2b0
ed5669151a0ebe6bcc8c4b08fc6cde6481803d15
/magma-1.5.0/testing/testing_dgeadd.cpp
d77b699e0c8be88e8f9a9e16610b1e41d68fe2de
[]
no_license
JieyangChen7/DVFS-MAGMA
1c36344bff29eeb0ce32736cadc921ff030225d4
e7b83fe3a51ddf2cad0bed1d88a63f683b006f54
refs/heads/master
2021-09-26T09:11:28.772048
2018-05-27T01:45:43
2018-05-27T01:45:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,609
cpp
/* -- MAGMA (version 1.5.0) -- Univ. of Tennessee, Knoxville Univ. of California, Berkeley Univ. of Colorado, Denver @date September 2014 @generated from testing_zgeadd.cpp normal z -> d, Wed Sep 17 15:08:40 2014 @author Mark Gates */ // includes, system #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <cuda_runtime_api.h> #include <cublas.h> // includes, project #include "magma.h" #include "magma_lapack.h" #include "testings.h" /* //////////////////////////////////////////////////////////////////////////// -- Testing dgeadd */ int main( int argc, char** argv) { TESTING_INIT(); real_Double_t gflops, gpu_perf, gpu_time, cpu_perf, cpu_time; double error, work[1]; double *h_A, *h_B, *d_A, *d_B; double alpha = MAGMA_D_MAKE( 3.1415, 2.718 ); double c_neg_one = MAGMA_D_NEG_ONE; magma_int_t M, N, size, lda, ldda; magma_int_t ione = 1; magma_int_t ISEED[4] = {0,0,0,1}; magma_int_t status = 0; magma_opts opts; parse_opts( argc, argv, &opts ); double tol = opts.tolerance * lapackf77_dlamch("E"); /* Uncomment these lines to check parameters. * magma_xerbla calls lapack's xerbla to print out error. */ //magmablas_dgeadd( -1, N, alpha, d_A, ldda, d_B, ldda ); //magmablas_dgeadd( M, -1, alpha, d_A, ldda, d_B, ldda ); //magmablas_dgeadd( M, N, alpha, d_A, M-1, d_B, ldda ); //magmablas_dgeadd( M, N, alpha, d_A, ldda, d_B, N-1 ); printf(" M N CPU GFlop/s (ms) GPU GFlop/s (ms) |Bl-Bm|/|Bl|\n"); printf("=========================================================================\n"); for( int itest = 0; itest < opts.ntest; ++itest ) { for( int iter = 0; iter < opts.niter; ++iter ) { M = opts.msize[itest]; N = opts.nsize[itest]; lda = M; ldda = ((M+31)/32)*32; size = lda*N; gflops = 2.*M*N / 1e9; TESTING_MALLOC_CPU( h_A, double, lda *N ); TESTING_MALLOC_CPU( h_B, double, lda *N ); TESTING_MALLOC_DEV( d_A, double, ldda*N ); TESTING_MALLOC_DEV( d_B, double, ldda*N ); lapackf77_dlarnv( &ione, ISEED, &size, h_A ); lapackf77_dlarnv( &ione, ISEED, &size, h_B ); /* ==================================================================== Performs operation using MAGMA =================================================================== */ magma_dsetmatrix( M, N, h_A, lda, d_A, ldda ); magma_dsetmatrix( M, N, h_B, lda, d_B, ldda ); gpu_time = magma_sync_wtime( NULL ); magmablas_dgeadd( M, N, alpha, d_A, ldda, d_B, ldda ); gpu_time = magma_sync_wtime( NULL ) - gpu_time; gpu_perf = gflops / gpu_time; /* ===================================================================== Performs operation using LAPACK =================================================================== */ cpu_time = magma_wtime(); for( int j = 0; j < N; ++j ) { blasf77_daxpy( &M, &alpha, &h_A[j*lda], &ione, &h_B[j*lda], &ione ); } cpu_time = magma_wtime() - cpu_time; cpu_perf = gflops / cpu_time; /* ===================================================================== Check result =================================================================== */ magma_dgetmatrix( M, N, d_B, ldda, h_A, lda ); error = lapackf77_dlange( "F", &M, &N, h_B, &lda, work ); blasf77_daxpy( &size, &c_neg_one, h_A, &ione, h_B, &ione ); error = lapackf77_dlange( "F", &M, &N, h_B, &lda, work ) / error; printf("%5d %5d %7.2f (%7.2f) %7.2f (%7.2f) %8.2e %s\n", (int) M, (int) N, cpu_perf, cpu_time*1000., gpu_perf, gpu_time*1000., error, (error < tol ? "ok" : "failed")); status += ! (error < tol); TESTING_FREE_CPU( h_A ); TESTING_FREE_CPU( h_B ); TESTING_FREE_DEV( d_A ); TESTING_FREE_DEV( d_B ); fflush( stdout ); } if ( opts.niter > 1 ) { printf( "\n" ); } } TESTING_FINALIZE(); return status; }
[ "cjy7117@gmail.com" ]
cjy7117@gmail.com
07ef43f3ab1171a1f44b114d593567faee981617
950e7c95184048524ad07734d4d14d7c449146a2
/pac_2.cc
de81d261b6efe9b3bc8c24b77cb0050c823e1879
[]
no_license
vrexhausen/OGinterpreter
940762a7a8111fb9e858390541fb21c3272908dc
0c406a074e2bfadd2d64194e9bf48e4b01a5c543
refs/heads/master
2021-05-23T12:24:40.923781
2020-04-05T16:54:38
2020-04-05T16:54:38
253,284,866
0
0
null
null
null
null
UTF-8
C++
false
false
1,485
cc
#include "system.h" #include "prototypes.h" //Package 2 - reservation node & pressure void pac_2(int input_lines, int num_nodes , int &resv_node , double &resv_pres, bool &sol_valid, bool debug ) { // string fn = "packet 2 function" ; user_trace(debug , 1 , fn) ; // string rawline, resv_nodestr , resv_presstr ; getline(cin, rawline) ; int nchars = rawline.length(); int lead_spaces = rawline.find_first_not_of(' '); rawline.erase(0, lead_spaces); //serparte by ' ' int space_loc = rawline.find(' ') ; resv_nodestr = rawline.substr ( 0, space_loc ) ; space_loc = space_loc+1 ; int space_loc2 = rawline.find_last_not_of(' ') ; int buffer = (space_loc2 - space_loc) ; resv_presstr = rawline.substr ( space_loc, buffer+1 ) ; resv_node = stoi(resv_nodestr) ; resv_pres = stoi(resv_presstr) ; // check reservoir node if (resv_node <=0 || resv_node > num_nodes) { user_message(7) ; cout << endl << "Reservoir node must be greater than 0 and less than the total number of nodes." << endl << "Reservoir node has been set to the default (1)." << endl ; resv_node = 1 ; } // check resrevoir node pressure if (resv_pres <= 0) { user_message(7) ; user_message(10) ; resv_pres = 1000.0 ; } if (debug) { cout << "Reservoir node number: " << resv_node << endl << "Reservoir head: " << resv_pres << endl << flush ; } sol_valid = false ; // user_trace(debug , 2 , fn) ; // return ; }
[ "noreply@github.com" ]
noreply@github.com
aa676dab163e6aaf4e0bb50ff6805ea935a5e288
fd0c132f979ecd77168511c6f4d276c480147e57
/ios/Classes/Native/mscorlib_System_Collections_Generic_List_1_Enumera2485358880.h
e6b02d998616261ff531d6b6962046e6acec0896
[]
no_license
ping203/gb
9a4ab562cc6e50145660d2499f860e07a0b6e592
e1f69a097928c367042192619183d7445de90d85
refs/heads/master
2020-04-23T02:29:53.957543
2017-02-17T10:33:25
2017-02-17T10:33:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,597
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> // System.Collections.Generic.List`1<Spine.Unity.Modules.SkeletonRendererCustomMaterials/SlotMaterialOverride> struct List_1_t2950629206; #include "mscorlib_System_ValueType3507792607.h" #include "AssemblyU2DCSharp_Spine_Unity_Modules_SkeletonRend3581508074.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Collections.Generic.List`1/Enumerator<Spine.Unity.Modules.SkeletonRendererCustomMaterials/SlotMaterialOverride> struct Enumerator_t2485358880 { public: // System.Collections.Generic.List`1<T> System.Collections.Generic.List`1/Enumerator::l List_1_t2950629206 * ___l_0; // System.Int32 System.Collections.Generic.List`1/Enumerator::next int32_t ___next_1; // System.Int32 System.Collections.Generic.List`1/Enumerator::ver int32_t ___ver_2; // T System.Collections.Generic.List`1/Enumerator::current SlotMaterialOverride_t3581508074 ___current_3; public: inline static int32_t get_offset_of_l_0() { return static_cast<int32_t>(offsetof(Enumerator_t2485358880, ___l_0)); } inline List_1_t2950629206 * get_l_0() const { return ___l_0; } inline List_1_t2950629206 ** get_address_of_l_0() { return &___l_0; } inline void set_l_0(List_1_t2950629206 * value) { ___l_0 = value; Il2CppCodeGenWriteBarrier(&___l_0, value); } inline static int32_t get_offset_of_next_1() { return static_cast<int32_t>(offsetof(Enumerator_t2485358880, ___next_1)); } inline int32_t get_next_1() const { return ___next_1; } inline int32_t* get_address_of_next_1() { return &___next_1; } inline void set_next_1(int32_t value) { ___next_1 = value; } inline static int32_t get_offset_of_ver_2() { return static_cast<int32_t>(offsetof(Enumerator_t2485358880, ___ver_2)); } inline int32_t get_ver_2() const { return ___ver_2; } inline int32_t* get_address_of_ver_2() { return &___ver_2; } inline void set_ver_2(int32_t value) { ___ver_2 = value; } inline static int32_t get_offset_of_current_3() { return static_cast<int32_t>(offsetof(Enumerator_t2485358880, ___current_3)); } inline SlotMaterialOverride_t3581508074 get_current_3() const { return ___current_3; } inline SlotMaterialOverride_t3581508074 * get_address_of_current_3() { return &___current_3; } inline void set_current_3(SlotMaterialOverride_t3581508074 value) { ___current_3 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "nguyenhaian@outlook.com" ]
nguyenhaian@outlook.com
a8329f66b057976ae2b27e0d19c5387cf055fb97
483fd22da445730c22b595bb59b809d570bee561
/DualLedSwitch/DualLedSwitch.ino
d44b386544f5f5d9c1c8a4e8816ec923f650842b
[]
no_license
javatarz/Arduino
283d007220be9a132fdb14bee40a1e5c9c1b2fdb
f4ef4f39de3dd3b00670a46ae1565696056681ec
refs/heads/master
2021-05-27T09:58:09.110074
2013-06-16T18:45:31
2013-06-16T18:45:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,122
ino
// constants won't change. They're used here to // set pin numbers: const int buttonPin = 3; // the number of the pushbutton pin const int led1Pin = 13; // the number of the LED pin const int led2Pin = 12; // the number of the LED pin // Variables will change: int ledState = HIGH; // the current state of the output pin int buttonState; // the current reading from the input pin int lastButtonState = LOW; // the previous reading from the input pin // the following variables are long's because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. long lastDebounceTime = 0; // the last time the output pin was toggled long debounceDelay = 50; // the debounce time; increase if the output flickers void setup() { pinMode(buttonPin, INPUT); pinMode(led1Pin, OUTPUT); pinMode(led2Pin, OUTPUT); // set initial LED state digitalWrite(led1Pin, ledState); digitalWrite(led2Pin, ledState == 0 ? 1 : 0); } void loop() { // 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 LOW to HIGH), 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 toggle the LED if the new button state is HIGH if (buttonState == HIGH) { ledState = !ledState; } } } // set the LED: digitalWrite(led1Pin, ledState); digitalWrite(led2Pin, ledState == 0 ? 1 : 0); // save the reading. Next time through the loop, // it'll be the lastButtonState: lastButtonState = reading; }
[ "me@karunab.com" ]
me@karunab.com
2ccdcaea848efc585e6c6013ad4480f046d655cb
d8d2f4808cc3e1bad6549d2a303af5fa7f97c6f4
/Notice-me-Zen.py/Notice-me-Zen.py.ino
eb46183e73371d87ce5364acfc086431b17cdc7f
[]
no_license
ghowlettgomez/Notice-me-Zen.py
c60209465586daaa6216724a06c569071faf822d
b89d8d334299eff15dd517114bb00de06fb35ba4
refs/heads/master
2021-01-11T22:32:22.287888
2017-01-16T05:19:12
2017-01-16T05:19:12
78,985,832
0
1
null
null
null
null
UTF-8
C++
false
false
2,530
ino
#include <Servo.h> #define MAX_STEPS 200.0 #define S1_PIN 5 #define S2_PIN 6 typedef struct move_queue_node move_queue_node_t; struct move_queue_node { int a1, a2; move_queue_node_t *next; }; move_queue_node_t *head, *tail; Servo s1, s2; float demo_set[][2] = { {90, 0}, {90, 0}, {90, 0}, {90, 0} }; int curr = 0; void setup() { while (!Serial); Serial.begin(9600); s1.attach(S1_PIN); s2.attach(S2_PIN); head = (move_queue_node_t *)malloc(sizeof(move_queue_node_t)); head->a1 = s1.read(); head->a2 = s2.read(); head->next = NULL; move_queue_node_t *curr; move_queue_node_t *prev = head; for (int i = 0; i < 4; i++) { curr = (move_queue_node_t *)malloc(sizeof(move_queue_node_t)); curr->a1 = demo_set[i][0]; curr->a2 = demo_set[i][1]; curr->next = NULL; Serial.print(curr->a1); Serial.print(", "); Serial.println(curr->a2); prev->next = curr; prev = curr; } curr = head; while (curr->next != NULL) { curr = curr->next; } tail = curr; } void loop() { if (Serial.available() > 0) { int a1_temp = Serial.parseInt(); int a2_temp = Serial.parseInt(); if (a1_temp > 5 && a2_temp > 5) { tail->next = (move_queue_node_t *)malloc(sizeof(move_queue_node_t)); tail->next->a1 = a1_temp; tail->next->a2 = a2_temp; tail->next->next = NULL; tail = tail->next; } } if (head->next != NULL) { float a1_step = (head->next->a1 - head->a1) / MAX_STEPS; float a2_step = (head->next->a2 - head->a2) / MAX_STEPS; for (int i = 0; i < MAX_STEPS - 1; i++) { s1.write(head->a1 + a1_step * i); s2.write(head->a2 + a2_step * i); delay(20); } s1.write(head->next->a1); s2.write(head->next->a2); move_queue_node_t *tmp = head->next; free(head); head = tmp; } // if (curr < 6) { // int same = 0; // if (demo_set[curr][0] != demo_set[curr + 1][0]) { // s1.write(demo_set[curr][0]); // if (demo_set[curr][0] < demo_set[curr + 1][0]) { // demo_set[curr][0]++; // } else { // demo_set[curr][0]--; // } // } else { // same++; // } // if (demo_set[curr][1] != demo_set[curr + 1][1]) { // s2.write(demo_set[curr][1]); // if (demo_set[curr][1] < demo_set[curr + 1][1]) { // demo_set[curr][1]++; // } else { // demo_set[curr][1]--; // } // } else { // same++; // } // if (same > 1) { // curr++; // } }
[ "ghowlettgomez@gmail.com" ]
ghowlettgomez@gmail.com
dae62c432baa8da8f2a646844995e2bd2471db59
cb5a726130e813280800e11f560fca0d1673141a
/PasswordDlg.h
9bfb04cfef48ebcbf867e004ebdba2db53ae65dc
[]
no_license
IlyaMuramec/Saneso
75afb0a230dfbe4f9299aedbf4799d8ccb99c83b
b1ca5787c24461a08e2529c31fedb4013e7792e7
refs/heads/main
2023-01-08T04:05:54.754139
2020-10-21T19:03:36
2020-10-21T19:03:36
306,112,654
1
0
null
null
null
null
UTF-8
C++
false
false
540
h
#pragma once #include "resource.h" #include "afxwin.h" // CPasswordDlg dialog class CPasswordDlg : public CDialog { DECLARE_DYNAMIC(CPasswordDlg) public: CPasswordDlg(CWnd* pParent = NULL); // standard constructor virtual ~CPasswordDlg(); BOOL OnInitDialog(); // Dialog Data enum { IDD = IDD_PASSWORD }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedOk(); CEdit m_EditPassword; CString m_Password; };
[ "noreply@github.com" ]
noreply@github.com
afe188b246f6739b9eade4cd251b3b4eab6da45d
9903c3c5481c543c783d50315b480fd6824de204
/db/test/testutil.hpp
67a0821ddc066320a134a4d9b46f99618d6dba07
[ "MIT" ]
permissive
streamich/ron-cxx
63f00870b9e9975b7ed6d644fb562dfa64ff1308
c1ea4479228e52688d9d31f767e3c7e5c77ba0bd
refs/heads/master
2022-05-09T16:35:49.020228
2019-07-09T08:57:18
2019-07-09T09:18:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
492
hpp
#include "gtest/gtest.h" #include "../fs.hpp" #define DEBUG 1 namespace ron { template<class Frame> Status Compare(const Frame& a, const Frame& b) { Status ok = CompareFrames(a, b); if (!ok) { cerr<<"FRAME A:\n"<<a.data()<<".\n"; cerr<<"FRAME B:\n"<<b.data()<<".\n"; } return ok; } ::testing::AssertionResult IsOK(Status ok) { if (ok) return ::testing::AssertionSuccess(); else return ::testing::AssertionFailure() << ok.str(); } }
[ "gritzko@pm.me" ]
gritzko@pm.me
5d707522de90e2910368a73c78a1ab4b625c377f
8e03a46915ea742ef645bf67eca150495921879d
/modules/boost/simd/predicates/include/boost/simd/toolbox/predicates/functions/simd/sse/sse4_2/is_gtz.hpp
f2e84959a0e9f3c90546432707fdf975c93998be
[ "BSL-1.0" ]
permissive
Quanteek/nt2
03fb4da84c0e499b6426078fc58566df44cc7eee
47009031c60cecc9c509f6b7595d6421acdfe811
refs/heads/master
2021-01-18T10:48:44.921773
2012-05-01T20:00:26
2012-05-01T20:00:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,429
hpp
//============================================================================== // Copyright 2003 - 2011 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2011 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #ifndef BOOST_SIMD_TOOLBOX_PREDICATES_FUNCTIONS_SIMD_SSE_SSE4_2_IS_GTZ_HPP_INCLUDED #define BOOST_SIMD_TOOLBOX_PREDICATES_FUNCTIONS_SIMD_SSE_SSE4_2_IS_GTZ_HPP_INCLUDED #ifdef BOOST_SIMD_HAS_SSE4_2_SUPPORT #include <boost/simd/sdk/simd/logical.hpp> #include <boost/simd/include/functions/is_greater.hpp> #include <boost/simd/include/constants/zero.hpp> namespace boost { namespace simd { namespace ext { BOOST_SIMD_FUNCTOR_IMPLEMENTATION( boost::simd::tag::is_gtz_, boost::simd::tag::sse4_2_, (A0) , ((simd_<int64_<A0>,boost::simd::tag::sse_>)) ) { typedef typename meta::as_logical<A0>::type result_type; BOOST_SIMD_FUNCTOR_CALL(1) { return is_greater(a0, Zero<A0>()); } }; } } } #endif #endif
[ "jtlapreste@gmail.com" ]
jtlapreste@gmail.com
a138e827047754089ac38e71dbbc34875e08aa18
d1a70aea21c7aea899c51f8d548f72464faea29f
/Ribe2/BGMMaker.cpp
fe88957cdff58fc78be6d2230c1310f30fc73b42
[ "MIT" ]
permissive
ttlatex/SpiritualBlade-GeraHa
a3af09a08c21bcd77bf31436503d09f5650a0fa1
57ff8a7335a29adbe74f95a75d934291e9cba23d
refs/heads/master
2021-04-28T21:07:05.335303
2017-11-17T00:34:53
2017-11-17T00:34:53
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
5,134
cpp
// BGMMaker.cpp: BGMMaker クラスのインプリメンテーション // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "MusicPortSelecter.h" #include "BGMMaker.h" ////////////////////////////////////////////////////////////////////// // 構築/消滅 ////////////////////////////////////////////////////////////////////// BGMMaker::BGMMaker() { LastVolume = BaseVolume = 0; } BGMMaker::~BGMMaker() { if( pPlayer != NULL )pPlayer->CloseDown(); } long BGMMaker::SetBaseVolume( long NewVolume ) { // if( BaseVolume == NewVolume )return LastVolume+BaseVolume; BaseVolume = NewVolume; ChangeVolume( LastVolume ); return LastVolume+BaseVolume; } // 初期化します ディレクトリを指定しない場合はカレント下の "Midi" フォルダを探します HRESULT BGMMaker::Init( LPCTSTR pBGMDirectry ) { pPlayer.Release(); pLoader.Release(); pBGMPath.Release(); DWORD PathType = DMUS_APATH_SHARED_STEREOPLUSREVERB; DWORD ChannelCount = 64; HRESULT ret = CoCreateInstance(CLSID_DirectMusicLoader,NULL,CLSCTX_INPROC,IID_IDirectMusicLoader8,(void **)&pLoader); // HRESULT ret = pLoader.CoCreateInstance(CLSID_DirectMusicLoader); if( FAILED(ret) )return ret; CComBSTR SerachDirectry; if( pBGMDirectry != NULL ) { SerachDirectry = pBGMDirectry; } else { TCHAR dir[MAX_PATH]; AllZero( dir ); GetCurrentDirectory(MAX_PATH,dir); SerachDirectry = dir; SerachDirectry += L"\\Midi"; } // pLoader->SetSearchDirectory( GUID_DirectMusicAllTypes, SerachDirectry, FALSE ); DMUS_AUDIOPARAMS Params; AllZero(Params).dwSize = sizeof(Params); ret = CoCreateInstance(CLSID_DirectMusicPerformance,NULL,CLSCTX_INPROC,IID_IDirectMusicPerformance8,(void **)&pPlayer); // ret = pPlayer.CoCreateInstance(CLSID_DirectMusicPerformance); if( FAILED(ret) )return ret; ret = pPlayer->InitAudio(NULL ,NULL,NULL, PathType, ChannelCount, DMUS_AUDIOF_ALL, &Params); FAILEDTRACE(ret); if( FAILED(ret) )return ret; ret = pPlayer->CreateStandardAudioPath( PathType, ChannelCount, TRUE, &pBGMPath ); if( FAILED(ret) )return ret; /* CComPtr<IDirectMusicPort> pPort; pBGMPath->GetObjectInPath( 0, DMUS_PATH_PORT , 0, GUID_All_Objects, 0, IID_IDirectMusicPort, (void**)&pPort); DMUS_PORTCAPS Caps; AllZero(Caps).dwSize = sizeof(DMUS_PORTCAPS); pPort->GetCaps( &Caps ); */ return S_OK; } // ファイルの読み込み HRESULT BGMMaker::LoadMusic( MUSICOBJECT** ppMusicObject, LPCTSTR pFileName ) { if( ppMusicObject == NULL )return E_POINTER; if( pLoader == NULL )return E_PENDING; if( pFileName == NULL )return E_INVALIDARG; CComBSTR FileName( pFileName ); HRESULT ret = pLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, FileName, (void **)ppMusicObject ); FAILEDTRACE(ret); if( FAILED(ret) )return ret; /* DMUS_OBJECTDESC Desc; AllZero(Desc).dwSize = sizeof(DMUS_OBJECTDESC); Desc.guidObject = GUID_DefaultGMCollection; Desc.guidClass = CLSID_DirectMusicCollection; Desc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_OBJECT; CComPtr<IDirectMusicCollection8> pCollection; ret = pLoader->GetObject(&Desc, IID_IDirectMusicCollection8, (void **) &pCollection); */ ret = (*ppMusicObject)->SetParam(GUID_StandardMIDIFile, (DWORD)-1, 0, 0, NULL ); // if( FAILED(ret) )return ret; // ret = (*ppMusicObject)->SetParam(GUID_ConnectToDLSCollection, (DWORD)-1, 0, 0, pCollection ); // if( FAILED(ret) )return ret; ret = (*ppMusicObject)->Download( pPlayer ); if( FAILED(ret) )return ret; return S_OK; } // BGMとして再生 HRESULT BGMMaker::PlayBGM( LPCTSTR pFileName, MUSIC_TIME LoopStart ) { if( pPlayer == NULL )return E_PENDING; if( pLoader == NULL )return E_PENDING; CComPtr<MUSICOBJECT> pMusic; HRESULT ret = LoadMusic( &pMusic, pFileName ); if( FAILED(ret) )return ret; if( LoopStart > 0 ) { MUSIC_TIME LoopEnd = 0; ret = pMusic->GetLength( &LoopEnd ); if( LoopEnd > LoopStart )ret = pMusic->SetLoopPoints( LoopStart, LoopEnd ); } ret = pMusic->SetRepeats( DMUS_SEG_REPEAT_INFINITE ); StopAll(); ret = pMusic->Download( pPlayer ); if( FAILED(ret) )return ret; ret = pPlayer->PlaySegmentEx( pMusic, NULL, NULL, DMUS_SEGF_DEFAULT, 0,NULL, NULL, pBGMPath ); if( FAILED(ret) )return ret; pLastMusic = pMusic; return S_OK; } // とまります HRESULT BGMMaker::StopAll() { if( pPlayer == NULL )return E_PENDING; HRESULT hr = pPlayer->Stop( NULL, NULL, 0, 0 ); if( pLastMusic != NULL ) { pLastMusic->Unload( pPlayer ); pLastMusic = NULL; } return hr; } // 音量変更 HRESULT BGMMaker::ChangeVolume( long Volume, long DelayTime ) { if( pBGMPath == NULL )return E_PENDING; LastVolume = Volume; Volume += BaseVolume; if( Volume > 0 )Volume = 0; if( Volume < -9600 )Volume = -9600; return pBGMPath->SetVolume( Volume, DelayTime ); } // キャッシュのみ HRESULT BGMMaker::CacheFile( LPCTSTR FilePath ) { CComPtr<MUSICOBJECT> pObject; return LoadMusic( &pObject, FilePath ); } // キャッシュ開放 HRESULT BGMMaker::ReleaseCache() { if( pLoader == NULL )return E_PENDING; return pLoader->ClearCache( GUID_DirectMusicAllTypes ); }
[ "stnsllet.ml@gmail.com" ]
stnsllet.ml@gmail.com
f3b285d55401d0bbf4048d22fb7f8bb518803d73
8b4e37a0e465050a938b27a0762f1dce880830a3
/WinLoseState.h
360024b6be647a7c7c57b169eaa4bc762ae5c6fa
[]
no_license
Draglan/minesweeper
93edea09f954d4f03b0e44eb311916a00f2ff273
fc81229c25a81a2324be80b1319466ef6452fbbf
refs/heads/master
2020-04-12T12:48:35.671839
2019-04-25T18:52:29
2019-04-25T18:52:29
162,502,752
0
1
null
2019-04-25T18:52:30
2018-12-19T23:43:59
C++
UTF-8
C++
false
false
508
h
#ifndef WIN_LOSE_STATE_H #define WIN_LOSE_STATE_H #include "IGameState.h" #include "Button.h" #include "ScreenWriter.h" #include "PopupMenu.h" class WinLoseState : public IGameState { public: WinLoseState(bool didWin); virtual ~WinLoseState() {} // IGameState overrides // virtual void HandleInput(const SDL_Event& ev) override; virtual void Update(Uint32 ticks) override; virtual void Draw(const Window& w) const override; private: bool win_; PopupMenu menu_; }; #endif /* WIN_LOSE_STATE_H */
[ "wwentworth8857@gmail.com" ]
wwentworth8857@gmail.com
ca9fe3c8e0de738f46233e90fbc67ee2b38b887e
04d464c5325803e1e662e753c14d5c996ce30de0
/MyBodyParser.h
fa2102983f3ee929db7eb31aadda6625cbd5f4d2
[]
no_license
mrDarky/machinery
23f4f3d7e3b3ae218feeb300955ae5d4797258fa
37f09808c344fcd73508f49605566aff86597bed
refs/heads/master
2016-09-13T09:38:40.771681
2016-05-08T23:40:22
2016-05-08T23:40:22
56,714,626
0
0
null
null
null
null
UTF-8
C++
false
false
486
h
#pragma once #include <string> #include "cocos2d.h" USING_NS_CC; #include "rapidjson/document.h" class MyBodyParser { MyBodyParser(){} rapidjson::Document doc; public: static MyBodyParser* getInstance(); bool parseJsonFile(const std::string& pFile); bool parse(unsigned char* buffer, long length); void clearCache(); PhysicsBody* bodyFormJson(Node* pNode, const std::string& name, PhysicsMaterial material); void generateMap(cocos2d::Layer *layer); };
[ "mr.pesotskyi@mail.ru" ]
mr.pesotskyi@mail.ru
0368ceb8feac23da7470c41e8fc708750fae9570
4b77ab97f97309fe75067059d230dd4250801938
/src/Library/PhotonMapping/GlobalSpectralPhotonMap.h
5e28d34158ed097d93795f47ca0f32382fe89a93
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
aravindkrishnaswamy/RISE
de862c1ab15fe2ed1bc620f3c3939430b801d54d
297d0339a7f7acd1418e322a30a21f44c7dbbb1d
refs/heads/master
2020-04-12T16:22:44.305654
2018-12-20T17:27:30
2018-12-20T17:27:30
162,610,783
1
0
null
null
null
null
UTF-8
C++
false
false
2,455
h
////////////////////////////////////////////////////////////////////// // // GlobalSpectralPhotonMap.h - Definition of the global spectral photon // map class // // Author: Aravind Krishnaswamy // Date of Birth: May 6, 2004 // Tabs: 4 // Comments: // // License Information: Please see the attached LICENSE.TXT file // ////////////////////////////////////////////////////////////////////// #ifndef GLOBAL_SPECTRAL_PHOTON_MAP_ #define GLOBAL_SPECTRAL_PHOTON_MAP_ #include "PhotonMap.h" namespace RISE { namespace Implementation { class GlobalSpectralPhotonMap : public ISpectralPhotonMap, public PhotonMapDirectionalHelper<SpectralPhoton> { protected: Scalar nm_range; // range of wavelengths to search for a NM irradiance estimate public: GlobalSpectralPhotonMap( const unsigned int max_photons, const IPhotonTracer* tracer ); virtual ~GlobalSpectralPhotonMap( ); bool Store( const Scalar power, const Scalar nm, const Point3& pos, const Vector3& dir ); void SetGatherParamsNM( const Scalar radius, const Scalar ellipse_ratio, const unsigned int nminphotons, const unsigned int nmaxphotons, const Scalar nm_range_, IProgressCallback* pFunc ) { PhotonMapCore<SpectralPhoton>::SetGatherParams( radius, ellipse_ratio, nminphotons, nmaxphotons, pFunc ); nm_range = nm_range_; } void GetGatherParamsNM( Scalar& radius, Scalar& ellipse_ratio, unsigned int& nminphotons, unsigned int& nmaxphotons, Scalar& nm_range_ ) { PhotonMapCore<SpectralPhoton>::GetGatherParams( radius, ellipse_ratio, nminphotons, nmaxphotons ); nm_range_ = nm_range; } void RadianceEstimate( RISEPel& rad, // returned radiance const RayIntersectionGeometric& ri, // ray-surface intersection information const IBSDF& brdf // BRDF of the surface to estimate irradiance from ) const; void RadianceEstimateNM( const Scalar nm, // wavelength for the estimate Scalar& rad, // returned irradiance for the particular wavelength const RayIntersectionGeometric& ri, // ray-surface intersection information const IBSDF& brdf // BRDF of the surface to estimate irradiance from ) const; void Serialize( IWriteBuffer& buffer ///< [in] Buffer to serialize to ) const; void Deserialize( IReadBuffer& buffer ///< [in] Buffer to deserialize from ); }; } } #endif
[ "git@aravind.ca" ]
git@aravind.ca
80e9cec20ee72a3cef8f16be241ae3a24851cc0c
001cfc06d55c891558db5d1f6ab52d1214f59669
/erythrocyte/nishino_2009/RC-MAP/PumpMgProcess.cpp
92a2ff8ee9fac4f8c88c53456ecf2b5734cd0643
[]
no_license
naito/ecell3_models
4818171d7f09bd91a368dcd70e0ff4924f70fad1
0fe92aa7146a10f5d43ddf03e9b4ab2f57c80d8a
refs/heads/master
2021-01-18T22:39:56.189148
2016-04-19T05:04:51
2016-04-19T05:04:51
2,242,023
1
1
null
2013-09-11T04:55:28
2011-08-21T03:13:14
C++
UTF-8
C++
false
false
2,910
cpp
#include "libecs.hpp" #include "Process.hpp" #include "Stepper.hpp" #include "ContinuousProcess.hpp" USE_LIBECS; LIBECS_DM_CLASS( PumpMgProcess, ContinuousProcess ) { public: LIBECS_DM_OBJECT( PumpMgProcess, Process ){ INHERIT_PROPERTIES( Process ); PROPERTYSLOT_SET_GET( Real, Km ); PROPERTYSLOT_SET_GET( Real, Vm ); PROPERTYSLOT_SET_GET( Real, B1 ); PROPERTYSLOT_SET_GET( Real, B2 ); PROPERTYSLOT_SET_GET( Real, B3 ); PROPERTYSLOT_SET_GET( Real, k2k1 ); PROPERTYSLOT_SET_GET( Real, k3k1 ); PROPERTYSLOT_SET_GET( Real, z ); } PumpMgProcess() : Km( 0.0 ), Vm( 0.0 ), B1( 0.0 ), B2( 0.0 ), B3( 0.0 ), k2k1( 0.0 ), k3k1( 0.0 ), z( 0.0 ) { ; // do nothing } SIMPLE_SET_GET_METHOD( Real, Km ); SIMPLE_SET_GET_METHOD( Real, Vm ); SIMPLE_SET_GET_METHOD( Real, B1 ); SIMPLE_SET_GET_METHOD( Real, B2 ); SIMPLE_SET_GET_METHOD( Real, B3 ); SIMPLE_SET_GET_METHOD( Real, k2k1 ); SIMPLE_SET_GET_METHOD( Real, k3k1 ); SIMPLE_SET_GET_METHOD( Real, z ); virtual void initialize(){ Process::initialize(); S0 = getVariableReference( "S0" ); S1 = getVariableReference( "S1" ); S2 = getVariableReference( "S2" ); P0 = getVariableReference( "P0" ); P1 = getVariableReference( "P1" ); P2 = getVariableReference( "P2" ); P3 = getVariableReference( "P3" ); C0 = getVariableReference( "C0" ); E0 = getVariableReference( "E0" ); E1 = getVariableReference( "E1" ); } virtual void fire(){ Real velocity = 1; Real ActCo = E0.getVariable()->getValue(); if( ActCo == 0 ){ velocity = ConstAct; } else{ Real SKe = 1000 * S1.getVariable()->getMolarConc(); Real SNai = 1000 * S2.getVariable()->getMolarConc(); Real Satpt = 1000 * E1.getVariable()->getMolarConc(); Real BSNai = B3 / SNai + 1; velocity = ( Satpt / ( Satpt + Km ) ) * ( Vm / 2 ) * ( SKe * SKe + B2 * SKe * z / 2 ) / ( B1 * B2 + 2 * B2 * SKe + SKe * SKe + BSNai * BSNai * BSNai * ( B1 * B2 * k2k1 + k3k1 * ( SKe * SKe + B2 * SKe * z ) ) ); velocity *= N_A * S0.getVariable()->getSuperSystem()->getSize(); velocity *= ActCo / 1000 / 3600 / 1000; } setFlux( velocity ); } protected: VariableReference S0; VariableReference S1; VariableReference S2; VariableReference P0; VariableReference P1; VariableReference P2; VariableReference P3; VariableReference C0; VariableReference E0; VariableReference E1; Real ConstAct; Real Km; Real Vm; Real B1; Real B2; Real B3; Real k2k1; Real k3k1; Real z; }; LIBECS_DM_INIT( PumpMgProcess, Process );
[ "taiko@sfc.keio.ac.jp" ]
taiko@sfc.keio.ac.jp
ecc637f4b0fe048a11c42dde6aece87abad893aa
67ddedc825a4852349bb3e54f7d31cdeb34c64aa
/src/test/sighash_tests.cpp
e821ba0daf227f68073d6c80264437caef4a26eb
[ "MIT" ]
permissive
geranium-coin/geranium
3500632ed8e666d30d1b28494b1b7b5003c18ecc
93c08aa10ea151f4efd8337c1d5599ee7e8d58ea
refs/heads/master
2022-07-28T21:28:55.717800
2022-01-10T17:30:13
2022-01-10T17:30:13
440,774,432
2
0
MIT
2022-01-04T08:33:10
2021-12-22T07:39:53
C++
UTF-8
C++
false
false
6,928
cpp
// Copyright (c) 2013-2019 The Geranium Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <consensus/tx_check.h> #include <consensus/validation.h> #include <test/data/sighash.json.h> #include <hash.h> #include <script/interpreter.h> #include <script/script.h> #include <serialize.h> #include <streams.h> #include <test/util/setup_common.h> #include <util/system.h> #include <util/strencodings.h> #include <version.h> #include <iostream> #include <boost/test/unit_test.hpp> #include <univalue.h> extern UniValue read_json(const std::string& jsondata); // Old script.cpp SignatureHash function uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType) { if (nIn >= txTo.vin.size()) { return UINT256_ONE(); } CMutableTransaction txTmp(txTo); // In case concatenating two scripts ends up with two codeseparators, // or an extra one at the end, this prevents all those possible incompatibilities. FindAndDelete(scriptCode, CScript(OP_CODESEPARATOR)); // Blank out other inputs' signatures for (unsigned int i = 0; i < txTmp.vin.size(); i++) txTmp.vin[i].scriptSig = CScript(); txTmp.vin[nIn].scriptSig = scriptCode; // Blank out some of the outputs if ((nHashType & 0x1f) == SIGHASH_NONE) { // Wildcard payee txTmp.vout.clear(); // Let the others update at will for (unsigned int i = 0; i < txTmp.vin.size(); i++) if (i != nIn) txTmp.vin[i].nSequence = 0; } else if ((nHashType & 0x1f) == SIGHASH_SINGLE) { // Only lock-in the txout payee at same index as txin unsigned int nOut = nIn; if (nOut >= txTmp.vout.size()) { return UINT256_ONE(); } txTmp.vout.resize(nOut+1); for (unsigned int i = 0; i < nOut; i++) txTmp.vout[i].SetNull(); // Let the others update at will for (unsigned int i = 0; i < txTmp.vin.size(); i++) if (i != nIn) txTmp.vin[i].nSequence = 0; } // Blank out other inputs completely, not recommended for open transactions if (nHashType & SIGHASH_ANYONECANPAY) { txTmp.vin[0] = txTmp.vin[nIn]; txTmp.vin.resize(1); } // Serialize and hash CHashWriter ss(SER_GETHASH, SERIALIZE_TRANSACTION_NO_WITNESS); ss << txTmp << nHashType; return ss.GetHash(); } void static RandomScript(CScript &script) { static const opcodetype oplist[] = {OP_FALSE, OP_1, OP_2, OP_3, OP_CHECKSIG, OP_IF, OP_VERIF, OP_RETURN, OP_CODESEPARATOR}; script = CScript(); int ops = (InsecureRandRange(10)); for (int i=0; i<ops; i++) script << oplist[InsecureRandRange(sizeof(oplist)/sizeof(oplist[0]))]; } void static RandomTransaction(CMutableTransaction &tx, bool fSingle) { tx.nVersion = InsecureRand32(); tx.vin.clear(); tx.vout.clear(); tx.nLockTime = (InsecureRandBool()) ? InsecureRand32() : 0; int ins = (InsecureRandBits(2)) + 1; int outs = fSingle ? ins : (InsecureRandBits(2)) + 1; for (int in = 0; in < ins; in++) { tx.vin.push_back(CTxIn()); CTxIn &txin = tx.vin.back(); txin.prevout.hash = InsecureRand256(); txin.prevout.n = InsecureRandBits(2); RandomScript(txin.scriptSig); txin.nSequence = (InsecureRandBool()) ? InsecureRand32() : std::numeric_limits<uint32_t>::max(); } for (int out = 0; out < outs; out++) { tx.vout.push_back(CTxOut()); CTxOut &txout = tx.vout.back(); txout.nValue = InsecureRandRange(100000000); RandomScript(txout.scriptPubKey); } } BOOST_FIXTURE_TEST_SUITE(sighash_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(sighash_test) { #if defined(PRINT_SIGHASH_JSON) std::cout << "[\n"; std::cout << "\t[\"raw_transaction, script, input_index, hashType, signature_hash (result)\"],\n"; int nRandomTests = 500; #else int nRandomTests = 50000; #endif for (int i=0; i<nRandomTests; i++) { int nHashType = InsecureRand32(); CMutableTransaction txTo; RandomTransaction(txTo, (nHashType & 0x1f) == SIGHASH_SINGLE); CScript scriptCode; RandomScript(scriptCode); int nIn = InsecureRandRange(txTo.vin.size()); uint256 sh, sho; sho = SignatureHashOld(scriptCode, CTransaction(txTo), nIn, nHashType); sh = SignatureHash(scriptCode, txTo, nIn, nHashType, 0, SigVersion::BASE); #if defined(PRINT_SIGHASH_JSON) CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << txTo; std::cout << "\t[\"" ; std::cout << HexStr(ss.begin(), ss.end()) << "\", \""; std::cout << HexStr(scriptCode) << "\", "; std::cout << nIn << ", "; std::cout << nHashType << ", \""; std::cout << sho.GetHex() << "\"]"; if (i+1 != nRandomTests) { std::cout << ","; } std::cout << "\n"; #endif BOOST_CHECK(sh == sho); } #if defined(PRINT_SIGHASH_JSON) std::cout << "]\n"; #endif } // Goal: check that SignatureHash generates correct hash BOOST_AUTO_TEST_CASE(sighash_from_data) { UniValue tests = read_json(std::string(json_tests::sighash, json_tests::sighash + sizeof(json_tests::sighash))); for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; std::string strTest = test.write(); if (test.size() < 1) // Allow for extra stuff (useful for comments) { BOOST_ERROR("Bad test: " << strTest); continue; } if (test.size() == 1) continue; // comment std::string raw_tx, raw_script, sigHashHex; int nIn, nHashType; uint256 sh; CTransactionRef tx; CScript scriptCode = CScript(); try { // deserialize test data raw_tx = test[0].get_str(); raw_script = test[1].get_str(); nIn = test[2].get_int(); nHashType = test[3].get_int(); sigHashHex = test[4].get_str(); CDataStream stream(ParseHex(raw_tx), SER_NETWORK, PROTOCOL_VERSION); stream >> tx; TxValidationState state; BOOST_CHECK_MESSAGE(CheckTransaction(*tx, state), strTest); BOOST_CHECK(state.IsValid()); std::vector<unsigned char> raw = ParseHex(raw_script); scriptCode.insert(scriptCode.end(), raw.begin(), raw.end()); } catch (...) { BOOST_ERROR("Bad test, couldn't deserialize data: " << strTest); continue; } sh = SignatureHash(scriptCode, *tx, nIn, nHashType, 0, SigVersion::BASE); BOOST_CHECK_MESSAGE(sh.GetHex() == sigHashHex, strTest); } } BOOST_AUTO_TEST_SUITE_END()
[ "manomay.jyotish.vadhuvar@gmail.com" ]
manomay.jyotish.vadhuvar@gmail.com
aa82cc2bf820d87451be56d70773037310512dfe
5791d786c0f26fc287ac0fa7b293fe7339e041c2
/Classes/circuit/worklayer/UI/device/baseDevice/Capacitor/CCELeCapacitor.h
aa94767683de82200f1ea250391d8ee7af163740
[]
no_license
fengmm521/myspice
2c2da3e9c250e0a4193d2d999b2eb119c18f0d38
aacf57b4a11a34aa8ed38ee3557f6dc532aabffb
refs/heads/master
2021-01-10T11:26:53.150769
2015-09-27T16:28:59
2015-09-27T16:28:59
43,237,336
3
2
null
null
null
null
UTF-8
C++
false
false
444
h
// // CCELeCapacitor.h // myspice // 精灵类,主要用来创建一些定制的精灵动画。 // Created by woodcol on 15/9/27. // // #ifndef __myspice__CCELeCapacitor__ #define __myspice__CCELeCapacitor__ #include "cocos2d.h" #include "CCCapacitor.h" //电解电容器 class CCELeCapacitor:public CCCapacitor { public: CREATE_FUNC(CCELeCapacitor); virtual bool init(); }; #endif /* defined(__myspice__CCELeCapacitor__) */
[ "fengmm521@gmail.com" ]
fengmm521@gmail.com
ae6eb7ddaf2ad638c6bbc61d865a2a9178c39647
e6d37821568e951670ad4efdf6ceb28ae6fd3bca
/Src/SDE/SimulateNavigate/Network/SingleLayerNW.h
f1c26497ef435384cb87fadd1aaa05e49164d0b2
[]
no_license
xzrunner/sde
8e927f1cad72182935053ffcb89b16cbeb07406e
ad1b5a2252e84bd8351205f9b2386358dc5c9c3b
refs/heads/master
2020-03-22T18:57:04.442857
2018-07-10T22:28:19
2018-07-10T22:28:19
140,493,562
0
0
null
null
null
null
UTF-8
C++
false
false
2,494
h
#ifndef _IS_SDE_SIMULATE_NAVIGATE_NETWORK_SINGLE_LAYER_NW_H_ #define _IS_SDE_SIMULATE_NAVIGATE_NETWORK_SINGLE_LAYER_NW_H_ #include "../NavigateBase.h" #include "../../BasicType/BasicGMType.h" #include "../../BasicType/Rect.h" #include "../../NVDataPublish/Network/AdjacencyList.h" namespace IS_SDE { namespace SimulateNavigate { namespace Network { typedef NVDataPublish::Network::Connection S_CONN; class BindPoint; class SingleLayerNW : public INetWork { public: SingleLayerNW(IStorageManager* sm, const IPointBindLine* bind, const NVDataPublish::ILookUp* table, bool bPreLoadTable); SingleLayerNW(IStorageManager* sm); virtual double getShortestDistance(size_t src, size_t dest) const; double computeShortestPath(BetweenTwoNodeSearchingInfo& info) const; virtual double computeShortestPath(SingleRouteSearchingInfo& info) const; virtual void computeShortestPath(MultiRoutesSearchingInfo& info) const; size_t queryTopoNodeID(const MapPos2D& p) const; void getTopoNodePos(size_t nodeID, MapPos2D* pos) const; size_t getConnectionSetID(size_t nodeID) const; void getTopoNodeConnection(size_t nodeID, std::vector<S_CONN>* conns, bool bUsedInMLSearch = false) const; void getStorageInfo(size_t* firstLeafPage, size_t* firstIndexPage) const { *firstLeafPage = m_firstLeafPage, *firstIndexPage = m_firstIndexPage; } size_t getTopoNodeSize() const; const Rect& getTotScope() const { return m_scope; } void test() const; private: void parseHeader(); void parseRouteResult(const std::vector<size_t>& nodeIDs, BetweenTwoNodeSearchingInfo& info) const; void parseRouteResult(const std::vector<size_t>& nodeIDs, const BindPoint& s, const BindPoint& e, SingleRouteSearchingInfo& info) const; void parseRouteResult(std::vector<std::vector<size_t> > multiRouteNodeIDs, MultiRoutesSearchingInfo& info) const; void retrieveIndex(const MapPos2D& p, std::vector<size_t>* IDs) const; void retrieveLeaf(const MapPos2D& p, size_t page, size_t offset, const Rect& s, std::vector<size_t>* IDs) const; private: IStorageManager* m_buffer; const IPointBindLine* m_bind; const NVDataPublish::ILookUp* m_table; bool m_bPreLoadTable; Rect m_scope; bool m_rootBeLeaf; size_t m_firstLeafPage, m_firstIndexPage; friend class SLSpatialIndex; }; // SingleLayerNW } } } #endif // _IS_SDE_SIMULATE_NAVIGATE_NETWORK_SINGLE_LAYER_NW_H_
[ "zhuguang@ejoy.com" ]
zhuguang@ejoy.com
83bf7007de5eaea25e625b694ca8783257e62cfa
091afb7001e86146209397ea362da70ffd63a916
/inst/include/nt2/predicates/include/functions/isequaln.hpp
21ec3e4026cc63800727fbcf880a4a20f5d05226
[]
no_license
RcppCore/RcppNT2
f156b58c08863243f259d1e609c9a7a8cf669990
cd7e548daa2d679b6ccebe19744b9a36f1e9139c
refs/heads/master
2021-01-10T16:15:16.861239
2016-02-02T22:18:25
2016-02-02T22:18:25
50,460,545
15
1
null
2019-11-15T22:08:50
2016-01-26T21:29:34
C++
UTF-8
C++
false
false
295
hpp
#ifndef NT2_PREDICATES_INCLUDE_FUNCTIONS_ISEQUALN_HPP_INCLUDED #define NT2_PREDICATES_INCLUDE_FUNCTIONS_ISEQUALN_HPP_INCLUDED #include <nt2/predicates/functions/isequaln.hpp> #include <nt2/predicates/functions/scalar/isequaln.hpp> #include <nt2/predicates/functions/table/isequaln.hpp> #endif
[ "kevinushey@gmail.com" ]
kevinushey@gmail.com
1732ee53aab1d84fceb02901c35c9fcb84ecab3f
f949cadd265b636c44cbfbc4dcb23a1e9223dcf9
/helpers.h
dd8e2102d495277cd81b240c43cab0847aa25e91
[]
no_license
nickkray/cs130a
00ad735be77cd1c8ad37d8e9923463b7a0c2474e
522c4dc244c1c54433d61f387fd5a5afa61c4b33
refs/heads/master
2021-03-16T05:20:27.617804
2015-11-17T00:21:45
2015-11-17T00:21:45
43,441,464
0
0
null
null
null
null
UTF-8
C++
false
false
399
h
#ifndef __cs130a__helpers__ #define __cs130a__helpers__ #include <string> #include <sstream> #include <limits> #include "linkedlist.h" using namespace std; void writeStringToFile(string filename, string input); string readFromFile(string filename); string takeStringInput(string prompt, int maxLen); int takeIntInput(string prompt); linkedlist<string> split(string s, string delimiter); #endif
[ "nick@renttrack.com" ]
nick@renttrack.com
35a4f0db83c6d7e7deed1122e8b1571a0eff6358
eb2c686badb1fed07bd68b91a97dbfb19ba14055
/_MODEL_FOLDERS_/springBoard/baseMain/_LOCATION_STRINGS.cpp
0a9fdf541b51813e4971fe389064b02619b8b8c1
[]
no_license
marcclintdion/a7_WalkingWalker
ad26cb394437ba2ad3959c0e6cf69233a6b8be52
b7dba58a46a03f41f07cd58320e9d1e380a527f6
refs/heads/master
2021-05-29T20:24:29.021677
2015-09-22T07:47:55
2015-09-22T07:47:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,894
cpp
//==================================================================================== #include "_MODEL_FOLDERS_/baseMain/baseMain_Globals.cpp" //==================================================================================== #include "_MODEL_FOLDERS_/baseMain/baseMain_Init.cpp" //==================================================================================== #include "_MODEL_FOLDERS_/baseMain/baseMain_Shadow_01.cpp" //==================================================================================== #include "_MODEL_FOLDERS_/baseMain/baseMain_Shadow_00.cpp" //==================================================================================== #include "_MODEL_FOLDERS_/baseMain/baseMain_Render.cpp" //==================================================================================== #include "_MODEL_FOLDERS_/baseMain/baseMain_Keyboard.cpp" //==================================================================================== #include "_MODEL_FOLDERS_/baseMain/baseMain_Shutdown.cpp" //====================================================================================
[ "marcclintdion@Marcs-iMac.local" ]
marcclintdion@Marcs-iMac.local
1ef8c840a1e4798eaae2997d22581ea167f14e2e
2f78e134c5b55c816fa8ee939f54bde4918696a5
/code/ai/aibehaviour_combat.cpp
61c4239a808f7febf7bfb0d0576e872ce2294abd
[]
no_license
narayanr7/HeavenlySword
b53afa6a7a6c344e9a139279fbbd74bfbe70350c
a255b26020933e2336f024558fefcdddb48038b2
refs/heads/master
2022-08-23T01:32:46.029376
2020-05-26T04:45:56
2020-05-26T04:45:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,897
cpp
//------------------------------------------------------------------------------------------ //! //! \file aibehaviour_combat.cpp //! //------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ // Includes //------------------------------------------------------------------------------------------ #include "core/visualdebugger.h" #include "ai/aibehaviour_combat.h" #include "game/entitymanager.h" #include "game/entity.h" #include "game/entity.inl" #include "game/aicomponent.h" #include "game/attacks.h" #include "game/randmanager.h" //------------------------------------------------------------------------------------------ //! //! AIBehaviour_Combat::States //! State Update - This is really just stopping other behaviours from doing anything to //! screw up combat. //! //------------------------------------------------------------------------------------------ bool AIBehaviour_Combat::States(const STATE_MACHINE_EVENT eEvent, const int iState, const float fTimeDelta) { UNUSED( fTimeDelta ); if(!CEntityManager::Get().GetPlayer()) return false; CPoint ptPlayer = CEntityManager::Get().GetPlayer()->GetPosition(); CPoint ptMyPos = m_pobAIComp->GetParent()->GetPosition(); COMBAT_STATE eState = m_pobAIComp->GetParent()->GetAttackComponent()->AI_Access_GetState(); BeginStateMachine // Update the combat component first OnUpdate AIState(COMBAT_CHOOSE_POSITION) OnEnter OnUpdate if( (eState == CS_STANDARD) ) { CDirection dirToMe(ptMyPos - ptPlayer); dirToMe.Normalise(); m_fMovementSpeed = 0.5f + grandf( 0.4f ); float fAngle = dirToMe.Dot( CDirection( 0.0f, 0.0f, 1.0f ) ); fAngle += (grandf(PI) - HALF_PI); float fRadius = 3.0f; NinjaLua::LuaFunctionRet<float> obGetRadius = NinjaLua::LuaFunctionRet<float>( CLuaGlobal::Get().State().GetGlobals()["GavShieldsmanAICombat"]["Radius"] ); if( !obGetRadius.IsNil() ) fRadius = obGetRadius(); m_obDestPoint = CPoint( ptPlayer.X() + (fRadius * fcosf(fAngle)), ptPlayer.Y(), ptPlayer.Z() + (fRadius * fsinf(fAngle))); SetState(COMBAT_MOVING_TO_POSITION); } OnExit AIState(COMBAT_MOVING_TO_POSITION) OnEnter OnUpdate //g_VisualDebug->RenderLine( ptPlayer, m_obDestPoint, 0xFFFFFFFF ); if( eState != CS_STANDARD ) SetState(COMBAT_CHOOSE_POSITION); if( (ptMyPos - m_obDestPoint).LengthSquared() > (0.5f * 0.5f) ) { m_pobAIComp->SetAction(ACTION_STRAFE); m_pobAIComp->SetActionStyle(AS_AGGRESSIVE); m_pobAIComp->SetActionFacing(CDirection(ptPlayer - ptMyPos)); m_pobAIComp->SetActionDest(m_obDestPoint); m_pobAIComp->SetActionMoveSpeed(m_fMovementSpeed); } else { SetState(COMBAT_READY); } OnExit AIState(COMBAT_READY) OnEnter m_pobAIComp->SetAction(ACTION_INFORMATION_ANIM); m_pobAIComp->SetActionStyle(AS_AGGRESSIVE); //m_fCombatReadyDelay = 1.0f + grandf( 2.f ); OnUpdate if( eState != CS_STANDARD ) SetState(COMBAT_CHOOSE_POSITION); m_fCombatReadyDelay -= fTimeDelta; if( m_fCombatReadyDelay <= 0.0f ) SetState(COMBAT_CHOOSE_POSITION); OnExit EndStateMachine }
[ "hopefullyidontgetbanned735@gmail.com" ]
hopefullyidontgetbanned735@gmail.com
0c51ebc303142536106cb348ba624c450e04caf1
8c8820fb84dea70d31c1e31dd57d295bd08dd644
/RuntimeAssetCache/Private/RuntimeAssetCacheBucket.h
5e3b25e879fa2dbb7f192841b42987968b0ec060
[]
no_license
redisread/UE-Runtime
e1a56df95a4591e12c0fd0e884ac6e54f69d0a57
48b9e72b1ad04458039c6ddeb7578e4fc68a7bac
refs/heads/master
2022-11-15T08:30:24.570998
2020-06-20T06:37:55
2020-06-20T06:37:55
274,085,558
3
0
null
null
null
null
UTF-8
C++
false
false
2,977
h
// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Misc/AssertionMacros.h" #include "Containers/UnrealString.h" #include "Containers/Map.h" #include "Misc/ScopeLock.h" class FCacheEntryMetadata; /** Forward declarations. */ class FCacheEntryMetadata; /** * Holds data about cache entries. */ class FRuntimeAssetCacheBucket { public: /** Default constructor. */ FRuntimeAssetCacheBucket() : Size(DefaultBucketSize) , CurrentSize(0) { } /** * Constructor * @param InSize Size of bucket in bytes. */ FRuntimeAssetCacheBucket(int32 InSize) : Size(InSize) , CurrentSize(0) { } /** Destructor. */ ~FRuntimeAssetCacheBucket(); /** Gets size in bytes of the bucket. */ int32 GetSize() const { return Size; } /** * Cleans up all metadata entries. */ void Reset(); /** * Gets metadata entry for given key. * @param Key Key to get metadata for. * @return Metadata for given key. Default value if Key is not found. */ FCacheEntryMetadata* GetMetadata(const FString& Key); /** * Removes metadata entry for given key. * @param Key Key to remove metadata for. * @param bBuildFailed Indicates that building cache entry failed and some checks should be skipped. */ void RemoveMetadataEntry(const FString& Key, bool bBuildFailed = false); /** * Adds metadata entry for given key. * @param Key Key to add metadata for. * @param Value Metadata to add. If there is an entry for given key, it gets overwritten. * @param bUpdateSize If true, function will update current size of bucket. Otherwise, it's up to caller. */ void AddMetadataEntry(const FString& Key, FCacheEntryMetadata* Value, bool bUpdateSize); /** * Gets number of bytes used in cache so far. */ int32 GetCurrentSize() { FScopeLock Lock(&CurrentSizeCriticalSection); return CurrentSize; } /** * Adds to number of bytes used in cache so far. * @param Value Number of bytes to add. Can be negative. */ void AddToCurrentSize(int32 Value) { FScopeLock Lock(&CurrentSizeCriticalSection); CurrentSize += Value; check(CurrentSize <= Size); } /** * Gets oldest metadata entry in cache. * @return Oldest metadata entry. */ FCacheEntryMetadata* GetOldestEntry(); /** Default size of bucket in case it wasn't specified in config. */ static const int32 DefaultBucketSize; private: /** Map of cache keys to cache entries metadata. */ TMap<FString, FCacheEntryMetadata*> CacheMetadata; /** Guard for modifying CacheMetadata (adding/removing elements). Each element has individual guard for modifying it. */ FCriticalSection MetadataCriticalSection; /** Cache bucket size in bytes. */ int32 Size; /** Used bucket size in bytes. */ int32 CurrentSize; /** Guard for modifying current size from multiple threads. */ FCriticalSection CurrentSizeCriticalSection; /** Helper friend class to guard critical sections on scope basis. */ friend class FRuntimeAssetCacheBucketScopeLock; };
[ "wujiahong19981022@outlook.com" ]
wujiahong19981022@outlook.com
dc568a27a82d097f1f4228b543e9cb42324eeb15
3054ded5d75ec90aac29ca5d601e726cf835f76c
/Training/ITMOx Course/Semana 2/H.c++
3367460140ce33fd9825b7a5a51e2f0454fb33c8
[]
no_license
Yefri97/Competitive-Programming
ef8c5806881bee797deeb2ef12416eee83c03add
2b267ded55d94c819e720281805fb75696bed311
refs/heads/master
2022-11-09T20:19:00.983516
2022-04-29T21:29:45
2022-04-29T21:29:45
60,136,956
10
0
null
null
null
null
UTF-8
C++
false
false
688
/* * ITMOx Course - 1st Week Problems * Problem: Win the Competition! * Level: Easy */ #include <bits/stdc++.h> #define endl '\n' using namespace std; const int MAX_N = 15; int n, arr[MAX_N + 10]; int solver(int id, int val) { if (id == n) return 0; if (arr[id] > val) return solver(id + 1, val); return max(solver(id + 1, val), solver(id + 1, val - arr[id]) + 1); } int main() { ios::sync_with_stdio(false); // Fast input - output ifstream fin("input.txt"); // File Input ofstream fout("output.txt"); // File Output /*** Code ***/ fin >> n; for (int i = 0; i < n; i++) fin >> arr[i]; int ans = solver(0, 18000); fout << ans << endl; return 0; }
[ "yefri.gaitan97@gmail.com" ]
yefri.gaitan97@gmail.com
f6b2172ce7fea7584863947375b8293b80fefc2f
ad3bc509c4f61424492b2949e03c60628f631a31
/test/stadfa/stadfa_05.re
05d25bc9fc8c96a1f0f5ccacd951d0464fe31513
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-public-domain" ]
permissive
sergeyklay/re2c
0b1cdbfe40b4514be33320b2e1d263cf5d6426d6
88ff1e5a2ad57d424fe999e17960c564886d36f4
refs/heads/master
2021-12-23T22:24:30.716697
2021-06-26T22:56:00
2021-06-27T15:23:28
299,206,360
0
0
NOASSERTION
2021-06-19T10:49:05
2020-09-28T06:10:35
C
UTF-8
C++
false
false
78
re
// re2c $INPUT -o $OUTPUT -i --tags --stadfa /*!re2c [b] @t | [a] {} "" {} */
[ "skvadrik@gmail.com" ]
skvadrik@gmail.com
b78faee5cf05a159f86a9f936ec120f77b3626d7
ae526c5669bda2992fb550e8b655203f2911f3af
/examples/example-cpp-app/cocos2d/extensions/Particle3D/PU/CCPUSphereCollider.h
cf0dbf1bdbf4d645b0a6050af0fc58747714dc25
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
bugsnag/bugsnag-cocos2dx
681e5237031c49acc7f0261ab012a718cccb5ea4
2bf8fb015a939aba5cfde6851e94bdd844e3f8a0
refs/heads/next
2022-09-14T16:59:57.085853
2022-09-14T12:22:28
2022-09-14T12:22:28
223,420,560
1
2
MIT
2022-09-14T12:22:30
2019-11-22T14:28:55
C++
UTF-8
C++
false
false
2,910
h
/**************************************************************************** Copyright (C) 2013 Henry van Merode. All rights reserved. Copyright (c) 2015-2016 Chukong Technologies Inc. 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 __CC_PU_PARTICLE_3D_SPHERE_COLLIDER_H__ #define __CC_PU_PARTICLE_3D_SPHERE_COLLIDER_H__ #include "CCPUBaseCollider.h" #include "extensions/Particle3D/PU/CCPUSphere.h" #include "base/ccTypes.h" NS_CC_BEGIN class CC_DLL PUSphereCollider : public PUBaseCollider { public: // Constants static const float DEFAULT_RADIUS; static PUSphereCollider* create(); virtual void preUpdateAffector(float deltaTime) override; virtual void updatePUAffector(PUParticle3D *particle, float deltaTime) override; /** Returns the radius of the sphere */ float getRadius() const; /** Sets the radius of the sphere */ void setRadius(const float radius); /** Returns indication whether the collision is inside or outside of the box @remarks If value is true, the collision is inside of the box. */ bool isInnerCollision(void) const; /** Set indication whether the collision is inside or outside of the box @remarks If value is set to true, the collision is inside of the box. */ void setInnerCollision(bool innerCollision); /** */ void calculateDirectionAfterCollision(PUParticle3D* particle, Vec3 distance, float distanceLength); virtual void copyAttributesTo (PUAffector* affector) override; CC_CONSTRUCTOR_ACCESS: PUSphereCollider(void); virtual ~PUSphereCollider(void); protected: float _radius; PUSphere _sphere; Vec3 _predictedPosition; bool _innerCollision; }; NS_CC_END #endif
[ "iskanamagus@gmail.com" ]
iskanamagus@gmail.com
f02c9596aab33870aed3e52df8bfb28c72cd1ed3
e50e1a6eb07ce75f61a30d0dc75fb67b7052add6
/include/product.h
c5c07caa4bd23b8edc63d8f56e5f1781ed2dc63c
[]
no_license
fanyachaoizhu/joi-grad-shopping-cart-cpp
26eca2f37d299847bddfa3c5aecb85ac67a74b7a
6e823a0ca22b9ef388a24ec40dd0b9e1f1c1930e
refs/heads/master
2023-05-11T08:51:33.096230
2021-01-14T06:45:37
2021-01-14T06:45:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
770
h
#ifndef JOI_GRAD_SHOPPING_CART_CPP_PRODUCT_H #define JOI_GRAD_SHOPPING_CART_CPP_PRODUCT_H #include <string> class Product { public: Product() {}; Product(double price, std::string product_code, std::string name) : price_(price), product_code_(std::move(product_code)), name_(std::move(name)) {} double GetPrice() const { return price_; } std::string GetProductCode() const { return product_code_; } std::string GetName() const { return name_; } private: const double price_ = 0; const std::string product_code_; const std::string name_; }; #endif //JOI_GRAD_SHOPPING_CART_CPP_PRODUCT_H
[ "noreply@github.com" ]
noreply@github.com
c94d2b50bc9c858f08f43d10971dda0a2d31b8aa
0cfdb34d75b119e426199e296c902d3d69545dd4
/src/polynomial.cpp
edbd9936aa227cee09a6b35ef2b86dbd7f9289e2
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
lparolin/polynomial
7261e952b9a210af754306cc4477b3d131b34977
5cdacaba45503a41d3a9d191f0b0d45a63dc673a
refs/heads/master
2021-01-22T05:24:02.494314
2017-02-12T15:15:13
2017-02-12T15:15:13
81,657,853
0
0
null
2017-02-11T15:47:22
2017-02-11T14:23:57
null
UTF-8
C++
false
false
122
cpp
#include "polynomial.hpp" ///@todo write me #include <iostream> int main() { std::cout << "Hallo." << std::endl; }
[ "lucapar@gmail.com" ]
lucapar@gmail.com
43edb285efb459bb7d2b3e22de421933d4781b9d
c77ea1df17b39926f517a4d0bcd797c0f2e5dc60
/src/UI/UI_VisualPath.h
00f0afbf32f4764366be822c896030461572dd38
[ "MIT" ]
permissive
Nyarlana/Tactical-RPG
d7fad931cc42a990d95463859943ecd1a5eec573
9b55e35cce5dbeba481d3db7113c15e572b320e1
refs/heads/master
2023-02-11T04:57:47.562541
2021-01-14T19:25:29
2021-01-14T19:25:29
298,213,302
0
0
null
null
null
null
UTF-8
C++
false
false
569
h
#include "UI_Component.h" #ifndef UI_VISUALPATH #define UI_VISUALPATH /**@class UI_VisualPath @brief displays an inner path using grid coordinates*/ class UI_VisualPath : public UI_Component { public: /**@brief class constructor*/ UI_VisualPath(std::vector<sf::Vector2i> path); /**@brief add to path*/ void add_To_Path(sf::Vector2i node); // inheritance virtual void _init(); virtual void _update(); virtual void _draw(sf::RenderWindow & window); virtual void on_Notify(Component* subject, Event event); private: sf::VertexArray array; }; #endif
[ "52347671+Nyarlana@users.noreply.github.com" ]
52347671+Nyarlana@users.noreply.github.com
a0f16543047365e16372ba8392750b8d5bfb09f4
a91cb8785be8ba51831b815deb0eb1dd59b9a9a8
/tool/lcp.h
cd16a9d911eb4077c5cefb6a34d99ae9b6db7940
[]
no_license
maxime-tournier/pouf
137f1917cb6deea21fd75f4767b9fbdbdd4adb39
afe6ec8d408b3b1b199576106887d3feb12447fc
refs/heads/master
2021-01-18T23:27:12.598897
2016-05-25T13:30:49
2016-05-25T13:30:49
18,585,362
3
0
null
null
null
null
UTF-8
C++
false
false
767
h
#ifndef POUF_TOOL_LCP_H #define POUF_TOOL_LCP_H #include <math/types.h> #include <fstream> // TODO proper header/source namespace tool { static void write_vec(std::ofstream& out, const math::vec& v) { for(unsigned j = 0, n = v.size(); j < n; ++j) { out << v(j); if( j < n - 1 ) out << "\t"; } out << std::endl; } template<class Matrix> static void write_lcp(const std::string& filename, const Matrix& M, const math::vec& q) { using namespace math; std::ofstream out(filename); unsigned n = q.size(); out << n << std::endl; math::vec unit = vec::Zero(n); math::vec tmp; for(unsigned i = 0; i < n; ++i) { unit(i) = 1; write_vec(out, M(unit) ); unit(i) = 0; } write_vec( out, q ); } } #endif
[ "maxime.tournier@brain.riken.jp" ]
maxime.tournier@brain.riken.jp
eb754260eabd3814ba3f7b1b57eeafc7b0e820b6
10bb3d7109ffc0054a5cd4ca48cb2d8aed5613f2
/Auto/Codigo/codigoWIFI/codigoWIFI.ino
ad1c8cc71ba7f2eef3212fc827eed242981da082
[]
no_license
RodrigoMolina/TallerDeProyectosII
5cfa97ad56ee87011e4cdd9f0d267fd124367197
edb184ee59323960582b7ec87eb52041b3cc9889
refs/heads/master
2021-05-16T07:01:25.101809
2017-12-20T21:39:47
2017-12-20T21:39:47
103,593,467
0
0
null
null
null
null
UTF-8
C++
false
false
1,468
ino
#include <SoftwareSerial.h> #include <ESP8266WiFi.h> #include <WiFiClient.h> #include <ESP8266WebServer.h> #include "index.h" //SSID y contraseña de la red const char* ssid = "AutoTallerII"; const char* password = "12345678"; ESP8266WebServer server(80); //Server en puerto 80 SoftwareSerial SerialESP(1, 0); //======================================================================= // Esta rutina es ejecutada cuando el dispositivo navega en la pagina //======================================================================= void handleRoot() { String s = MAIN_page; //Lee el contenido HTML server.send(200, "text/html", s); //Envia la pagina web String dato = (server.arg("Data")); Serial.write(dato[0]); } //=============================================================== // Configuracion //=============================================================== void setup(void){ Serial.begin(9600); WiFi.mode(WIFI_AP); //Configura el modulo wifi como access point WiFi.softAP(ssid, password); server.on("/", handleRoot); //Cuando se navega a la raiz de la pagina se ejecuta //se ejecuta la funcion handleRoot() server.begin(); //Inicia el servidor } //=============================================================== // LOOP //=============================================================== void loop(void){ server.handleClient(); }
[ "rodrimolina22@gmail.com" ]
rodrimolina22@gmail.com
f7979800358ba40266050febc83130f8bb3bb520
0c4879e185659e22674c01611e5d67088fa9c795
/src/qt/editaddressdialog.cpp
78018fc645cd9c73a3bca3d993113f1e9b302026
[ "MIT" ]
permissive
Fancycoin/Fancycoin
4a4e2038d63ea32fa73240a3d9267e07935cc942
2e354071d5073ff279e549ac6ac9206d29291016
refs/heads/master
2021-01-23T11:09:04.461177
2015-03-25T02:07:51
2015-03-25T02:07:51
32,623,818
0
0
null
null
null
null
UTF-8
C++
false
false
3,566
cpp
#include "editaddressdialog.h" #include "ui_editaddressdialog.h" #include "addresstablemodel.h" #include "guiutil.h" #include <QDataWidgetMapper> #include <QMessageBox> EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) : QDialog(parent), ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0) { ui->setupUi(this); GUIUtil::setupAddressWidget(ui->addressEdit, this); switch(mode) { case NewReceivingAddress: setWindowTitle(tr("New receiving address")); ui->addressEdit->setEnabled(false); break; case NewSendingAddress: setWindowTitle(tr("New sending address")); break; case EditReceivingAddress: setWindowTitle(tr("Edit receiving address")); ui->addressEdit->setDisabled(true); break; case EditSendingAddress: setWindowTitle(tr("Edit sending address")); break; } mapper = new QDataWidgetMapper(this); mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); } EditAddressDialog::~EditAddressDialog() { delete ui; } void EditAddressDialog::setModel(AddressTableModel *model) { this->model = model; mapper->setModel(model); mapper->addMapping(ui->labelEdit, AddressTableModel::Label); mapper->addMapping(ui->addressEdit, AddressTableModel::Address); } void EditAddressDialog::loadRow(int row) { mapper->setCurrentIndex(row); } bool EditAddressDialog::saveCurrentRow() { if(!model) return false; switch(mode) { case NewReceivingAddress: case NewSendingAddress: address = model->addRow( mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive, ui->labelEdit->text(), ui->addressEdit->text()); break; case EditReceivingAddress: case EditSendingAddress: if(mapper->submit()) { address = ui->addressEdit->text(); } break; } return !address.isEmpty(); } void EditAddressDialog::accept() { if(!model) return; if(!saveCurrentRow()) { switch(model->getEditStatus()) { case AddressTableModel::DUPLICATE_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::INVALID_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is not a valid Fancycoin address.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); return; case AddressTableModel::WALLET_UNLOCK_FAILURE: QMessageBox::critical(this, windowTitle(), tr("Could not unlock wallet."), QMessageBox::Ok, QMessageBox::Ok); return; case AddressTableModel::KEY_GENERATION_FAILURE: QMessageBox::critical(this, windowTitle(), tr("New key generation failed."), QMessageBox::Ok, QMessageBox::Ok); return; case AddressTableModel::OK: // Failed with unknown reason. Just reject. break; } return; } QDialog::accept(); } QString EditAddressDialog::getAddress() const { return address; } void EditAddressDialog::setAddress(const QString &address) { this->address = address; ui->addressEdit->setText(address); }
[ "fcydev@gmail.com" ]
fcydev@gmail.com
9fbd2d726aab364b02b2ed91d61d82380e961ca4
07cda1295da0370c630697701df0fc5e3e45ca28
/base/trace_event/trace_event_etw_export_win.h
eefe820481217ceb8f32f9f30a6b005f2628f07b
[ "BSD-3-Clause" ]
permissive
anawhj/chromium-crosswalk
8221f9510bfb9df29dab12e6cdc57030380eb3f5
97959a5c98a1e18513f3ea21697323634d2fd696
refs/heads/master
2021-01-24T17:23:55.447032
2015-08-11T23:14:52
2015-08-11T23:14:52
40,750,463
0
1
null
2015-08-15T07:18:53
2015-08-15T07:18:52
null
UTF-8
C++
false
false
2,491
h
// Copyright 2015 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. // This file contains the Windows-specific exporting to ETW. #ifndef BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_ #define BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_ #include "base/base_export.h" #include "base/trace_event/trace_event_impl.h" // Fwd. template <typename Type> struct StaticMemorySingletonTraits; namespace base { namespace trace_event { class BASE_EXPORT TraceEventETWExport { public: ~TraceEventETWExport(); // Retrieves the singleton. // Note that this may return NULL post-AtExit processing. static TraceEventETWExport* GetInstance(); // Enables/disables exporting of events to ETW. If disabled, // AddEvent and AddCustomEvent will simply return when called. static void EnableETWExport(); static void DisableETWExport(); static bool isETWExportEnabled() { return (GetInstance() && GetInstance()->ETWExportEnabled_); } // Exports an event to ETW. This is mainly used in // TraceLog::AddTraceEventWithThreadIdAndTimestamp to export internal events. static void AddEvent( char phase, const unsigned char* category_group_enabled, const char* name, unsigned long long id, int num_args, const char** arg_names, const unsigned char* arg_types, const unsigned long long* arg_values, const scoped_refptr<ConvertableToTraceFormat>* convertable_values); // Exports an event to ETW. This should be used when exporting an event only // to ETW. Supports three arguments to be passed to ETW. // TODO(georgesak): Allow different providers. static void AddCustomEvent(const char* name, char const* phase, const char* arg_name_1, const char* arg_value_1, const char* arg_name_2, const char* arg_value_2, const char* arg_name_3, const char* arg_value_3); void Resurrect(); private: bool ETWExportEnabled_; // Ensure only the provider can construct us. friend struct StaticMemorySingletonTraits<TraceEventETWExport>; TraceEventETWExport(); DISALLOW_COPY_AND_ASSIGN(TraceEventETWExport); }; } // namespace trace_event } // namespace base #endif // BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
f6d81ce14d80324b4339fd7b1e78a660928252b2
5c1f23daf797e2b776b7e43e9f342a0f86915901
/字节跳动2019春招研发部分编程题汇总/5.cpp
239bcf1779c8bb19d0d6dbf706ec7ef388e49908
[]
no_license
ttzztztz/CampusHire-CodeSolutions
a5ca25e66cc78fbddfc3e4ec310767049eb247a8
c117c47571044fba9388507793e00990b07615f9
refs/heads/master
2021-05-25T15:26:56.206497
2021-03-28T10:35:27
2021-03-28T10:35:27
253,808,223
3
0
null
null
null
null
UTF-8
C++
false
false
884
cpp
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <climits> using namespace std; int N; vector<vector<int>> matrix; vector<vector<int>> f; int dfs(int u, int state) { if (state == (1 << N) - 1) return matrix[u][0]; if (f[u][state] != -1) return f[u][state]; int answer = numeric_limits<int>::max(); for (int v = 0; v < N; v++) { if (!(state & (1 << v))) { answer = min(answer, matrix[u][v] + dfs(v, state | (1 << v))); } } return f[u][state] = answer; } int main() { cin >> N; matrix = vector<vector<int>>(N + 5, vector<int>(N + 5, 0)); f = vector<vector<int>>(N + 1, vector<int>((1 << N) + 5, -1)); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cin >> matrix[i][j]; } } cout << dfs(0, 1) << endl; return 0; }
[ "ttzztztz@outlook.com" ]
ttzztztz@outlook.com
b645694e592bd04cd3474939a6c6237b975b80d5
65a7b5e58f2ccd4adb1f38901a44a20d3f58926f
/ccf/2013-12-4/2013-12-4/2013-12-4.cpp
f63a6bc954e240cf7f7a89dac7feb3755d48ccef
[]
no_license
playerxq/ccf
3ae64f4a41877d6628f2b9bda2eac1ad63ce219a
ff0b1d1d5bd730a5bb99bc96c77256c3216d33fa
refs/heads/master
2020-06-29T05:18:54.556717
2016-11-22T07:41:47
2016-11-22T07:41:47
74,446,721
0
0
null
null
null
null
GB18030
C++
false
false
3,886
cpp
// 2013-12-4.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <cstdio> #include <iostream> #include <string.h> #include <math.h> #include <vector> #include <queue> #include<iomanip> #include <ctype.h> #include <algorithm> using namespace std; int n; int cnt; int dp[1005][16]; int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); scanf("%d",&n); memset(dp,0,sizeof(dp)); dp[1][2]=1; for(int i = 2;i<=n;i++) { for(int j = 0;j<16;j++) { if((j&1)&&(j&2)&&(j&4)&&(j&8))//全有 只能加1 3 { dp[i][j] += (dp[i-1][j]+dp[i-1][j])%1000000007; dp[i][j] %=1000000007; } else if((!(j&1))&&(j&2)&&(j&4)&&(j&8))//只没有3 可以加1 2 3 { dp[i][j] += (dp[i-1][j]+dp[i-1][j])%1000000007;//加1 2 dp[i][j] %=1000000007; dp[i][j|1] += dp[i-1][j];//加3 dp[i][j|1] %= 1000000007; } else if((j&1)&&(!(j&2))&&(j&4)&&(j&8))//只没有2 可以加1 { dp[i][j] += dp[i-1][j];//加1 dp[i][j] %= 1000000007; } else if((j&1)&&(j&2)&&(!(j&4))&&(j&8))//只没有1 可以加0 1 3 { dp[i][j] += (dp[i-1][j]+dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|4] += dp[i-1][j];//加1 dp[i][j|4] %= 1000000007; } else if((j&1)&&(j&2)&&(j&4)&&(!(j&8)))//只没有0 可以加1 3 { dp[i][j] += (dp[i-1][j]+dp[i-1][j])%1000000007; dp[i][j] %=1000000007; } else if((!(j&1))&&(!(j&2))&&(j&4)&&(j&8))//没有3 2 可以放1 2 { dp[i][j] += (dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|2] += dp[i-1][j]; dp[i][j|2] %= 1000000007; } else if((!(j&1))&&(j&2)&&(!(j&4))&&(j&8))//没有3 1 可以放0 1 2 3 { dp[i][j] += (dp[i-1][j]+dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|1] += dp[i-1][j]; dp[i][j|1] %= 1000000007; dp[i][j|4] += dp[i-1][j]; dp[i][j|4] %= 1000000007; } else if((!(j&1))&&(j&2)&&(j&4)&&(!(j&8)))//没有3 0 可以放1 2 3 { dp[i][j] += (dp[i-1][j]+dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|1] += dp[i-1][j];//放3 dp[i][j|1] %= 1000000007; } else if((j&1)&&(!(j&2))&&(!(j&4))&&(j&8))//没有2 1 可以放0 1 3 { dp[i][j] += (dp[i-1][j]+dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|4] += dp[i-1][j];//放1 dp[i][j|4] %= 1000000007; } else if((j&1)&&(!(j&2))&&(j&4)&&(!(j&8)))//没有2 0 可以放1 3 { dp[i][j] += (dp[i-1][j]+dp[i-1][j])%1000000007; dp[i][j] %=1000000007; } else if((j&1)&&(j&2)&&(!(j&4))&&(!(j&8)))//没有1 0 只能加0 3 { dp[i][j] += (dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|8] += dp[i-1][j];//加0 dp[i][j|8] %= 1000000007; } else if((!(j&1))&&(!(j&2))&&(!(j&4))&&(j&8))//没有3 2 1 只能放0 1 2 { dp[i][j] += (dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|4] += dp[i-1][j]; dp[i][j|4] %= 1000000007; dp[i][j|2] += dp[i-1][j]; dp[i][j|2] %= 1000000007; } else if((!(j&1))&&(!(j&2))&&(j&4)&&(!(j&8)))//没有3 2 0 只能放1 2 { dp[i][j] += (dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|2] += dp[i-1][j]; dp[i][j|2] %= 1000000007; } else if((j&1)&&(!(j&2))&&(!(j&4))&&(!(j&8)))//没有0 1 2 可以放1 3 { dp[i][j] += (dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|4] += dp[i-1][j]; dp[i][j|4] %= 1000000007; } else if((!(j&1))&&(j&2)&&(!(j&4))&&(!(j&8)))//没有0 1 3 可以放0 2 3 { dp[i][j] += (dp[i-1][j])%1000000007; dp[i][j] %=1000000007; dp[i][j|8] += dp[i-1][j]; dp[i][j|8] %= 1000000007; dp[i][j|1] += dp[i-1][j]; dp[i][j|1] %= 1000000007; } else//全没有 只能放0 2 { dp[i][j|8] += dp[i-1][j]; dp[i][j|8] %= 1000000007; dp[i][j|2] += dp[i-1][j]; dp[i][j|2] %= 1000000007; } } } printf("%d\n",dp[n][15]); }
[ "1062842783@qq.com" ]
1062842783@qq.com
e3f2f4bd4a092eca2bcbe7be63267480927160bd
a66323d75f18b6c20079fd89918cede4b3c23b76
/src/Client/Network/NetworkManagerClient.h
0c7f554b735d1acedd8d45251162d22320e77376
[]
no_license
themesiah/networked_game
78c4c62e4c4dad995b1123c5b42345d5c09a0bc4
e1ff267843a48a277b57ee3900b96180dec69d06
refs/heads/master
2021-04-27T21:30:27.193748
2018-04-22T21:05:42
2018-04-22T21:05:42
122,400,913
0
0
null
null
null
null
UTF-8
C++
false
false
1,126
h
#pragma once #ifndef H_NETWORK_MANAGER_CLIENT #define H_NETWORK_MANAGER_CLIENT #include "Common\NetworkManager.h" #include "Serializer\PacketStream.h" #include "Serializer\OutputMemoryBitStream.h" #define SEGMENT_SIZE 1500 class CNetworkManagerClient : public NetworkManager { public: enum ClientState { NOT_CONNECTED = 0, CONNECTED, HELLO_SENT, PLAYING, PENDING_DISCONNECTION }; CNetworkManagerClient(); virtual ~CNetworkManagerClient(); virtual bool Init(uint16_t aPort) override; bool Connect(); void UpdateSendingSockets(float aDeltaTime); void UpdateReceivingSockets(float aDeltaTime); void UpdatePackets(float aDeltaTime); void ManageDisconnection(); void RenderImGui(); void RPCSend(OutputMemoryBitStream& lOutput); float GetAverageTimeBetweenPackets() { return m_AverageTimeBetweenPackets; } ClientState GetState() { return m_State; } private: ClientState m_State; PacketStream m_PacketStream; virtual bool InitReflection() override; void AddSample(float sample); float m_AverageTimeBetweenPackets; uint32_t m_NumberOfSamples; float m_Timer; std::string m_Reason; }; #endif
[ "marc.palenzuela.reyes@gmail.com" ]
marc.palenzuela.reyes@gmail.com
47846e5240c441a81db0dd18c826590533df3046
2167e333023a6b209e55e3643dfce3fe47fd5ae8
/144A - Arrival of the General.cpp
daeb1db53e5a746a1ee58307afd7c2f16463f5fe
[]
no_license
yindoria07/100DaysOfCode
e55ccca0db61d5668928492fb5e4e896688994c2
a837d0da2e4860b78d55578b19d800247507fc48
refs/heads/master
2022-08-10T15:31:56.701188
2020-02-20T00:54:56
2020-02-20T00:54:56
221,945,030
0
4
null
2022-08-04T14:02:20
2019-11-15T14:54:59
C++
UTF-8
C++
false
false
596
cpp
#include <iostream> using namespace std; int main(){ int n; int min_index = 0; int max_index = 0; int result = 0; cin >> n; int arr[n] ; for(int i=0; i<n; i++){ cin >> arr[i] ; } for(int i=1; i<n; i++){ if(arr[min_index] >= arr[i]){ min_index = i ; } if(arr[max_index] < arr[i]){ max_index = i ; } } if(min_index < max_index){ result = max_index + (n-min_index-1) -1 ; } else{ result = max_index + (n-min_index-1) ; } cout << result << endl; return 0; }
[ "yindoria07@gmail.com" ]
yindoria07@gmail.com
d649ae327f482542266745d9fd8bf3e2d233655c
11a7c0bb1569cc6a07b9764de36f49316c4f18bb
/bazel_ros2_rules/ros2/resources/rmw_isolation/test/isolated_listener.cc
6cbe22e1a9f96f31658e4e8323e8e742144cb9a3
[]
no_license
adeeb10abbas/playground
fadc39bceaacd37ab075a302ef90fa5c17ced12d
6d8aab225ef7bd52661ea48303f428578c2949bd
refs/heads/master
2022-11-30T08:45:24.060186
2022-11-26T04:37:57
2022-11-26T04:37:57
279,903,347
0
0
null
2020-07-15T19:39:00
2020-07-15T15:19:07
Python
UTF-8
C++
false
false
1,709
cc
#include <chrono> #include <memory> #include <rclcpp/rclcpp.hpp> #include <std_msgs/msg/string.hpp> #include "rmw_isolation/rmw_isolation.h" using std::placeholders::_1; class IsolatedListener : public rclcpp::Node { public: IsolatedListener(const std::string& uuid) : rclcpp::Node("isolated_listener"), uuid_(uuid) { double timeout = this->declare_parameter("timeout", 2.0); subscription_ = this->create_subscription<std_msgs::msg::String>( "uuid", 10, std::bind(&IsolatedListener::topic_callback, this, _1)); timer_ = this->create_wall_timer( std::chrono::duration<double>(timeout), std::bind(&IsolatedListener::timer_callback, this)); } private: void topic_callback(const std_msgs::msg::String::SharedPtr msg) { if (msg->data != uuid_) { throw std::runtime_error("I heard '" + msg->data + "' yet " + "I was expecting '" + uuid_ + "'!"); } ++expected_messages_count_; } void timer_callback() const { if (0u == expected_messages_count_) { throw std::runtime_error("I did not hear '" + uuid_ + "' even once!"); } rclcpp::shutdown(); } rclcpp::Subscription<std_msgs::msg::String>::SharedPtr subscription_; rclcpp::TimerBase::SharedPtr timer_; size_t expected_messages_count_{0u}; std::string uuid_; }; int main(int argc, char* argv[]) { const char* TEST_TMPDIR = std::getenv("TEST_TMPDIR"); if (TEST_TMPDIR != nullptr) { ros2::isolate_rmw_by_path(argv[0], TEST_TMPDIR); } rclcpp::init(argc, argv); std::string uuid{TEST_TMPDIR != nullptr ? TEST_TMPDIR : "none"}; rclcpp::spin(std::make_shared<IsolatedListener>(uuid)); rclcpp::shutdown(); return 0; }
[ "aa4239@drexel.edu" ]
aa4239@drexel.edu
244c84bffd47c5d2e47265b36fbbd568080e3eee
1c1c1fed0952aeacb4ccd3ce9374f67f0e92cae6
/exerc11.cpp
b6e5a95be6e58c34df57c1a2faf4a73a4532f8db
[]
no_license
guipolicarpo/C
1e0898de96b9fb9106dc5dc42c06f98d3d78f7a2
acb61820d01993af7a574e0797c51be40be2aa4d
refs/heads/main
2023-02-08T03:07:13.997048
2021-01-04T18:32:57
2021-01-04T18:32:57
326,767,171
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
267
cpp
#include<stdio.h> #include <stdlib.h> #include <locale.h> #include<math.h> main(){ setlocale(LC_ALL, "Portuguese"); int c; float total=0; for(c=1; c<=20; c++){ total=total+c/2; } printf("\nA soma de todos os quadrados é: %.2f\n",total); }
[ "noreply@github.com" ]
noreply@github.com
fabfee56c72b2d087829d59e3d41b5e449f41d43
0ad1e75df68fb14976c79c8921249dcd6e74f967
/LASTDIG - The last digit.cpp
a9cfb6b8861c806bef837bb730ce8d10d6e98354
[]
no_license
variablemayank/competetive-programming-codes
9010d215832f4937735d6b35b1df35df0f8a59e6
71bbc70049089fcc24444471dd4504b1d29c371f
refs/heads/master
2021-09-06T04:17:29.052221
2018-02-02T08:57:56
2018-02-02T08:57:56
119,955,414
1
1
null
null
null
null
UTF-8
C++
false
false
534
cpp
# include<bits/stdc++.h> using namespace std; int Modulo(int a, string b) { int mod = 0; for (int i=0; i<(b).size(); i++) mod = (mod*10 + b[i] - '0')%a; return mod; } void LastDigit(string a,string b) { int len_a = a.size(), len_b =b.size(); int exp = (Modulo(4,b)==0)? 4 : Modulo(4, b); int res = pow(a[len_a - 1] - '0', exp); cout<<res%10; } int main() { int t; cin>>t; while(t--) { string a,b; cin>>a>>b; LastDigit(a,b); cout<<endl; } }
[ "mayank202020@rediffmail.com" ]
mayank202020@rediffmail.com
7e6353d951aae335480aaa27794faaa71380e8b2
73903e30de4a163cc48a1ce574e94623fb215a22
/cpp/dlib/dlibImage/dlibclassfiy.cpp
8f823a58735abb360c449d6f0c5f112ccdf600ec
[]
no_license
fuxiang90/code-fuxiang90
3d60972214f30b909222339d4373190e84ef8afc
a6258a82f992faa3d4c20f240dace033bede1375
refs/heads/master
2020-04-05T22:41:25.927586
2014-05-02T02:04:49
2014-05-02T02:04:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,323
cpp
#include "dlibclassfiy.h" //typedef one_vs_one_trainer<any_trainer<sample_type> > ovo_trainer; //typedef matrix<double,500,1> sample_type; // Finally, make the one_vs_one_trainer. void dlibClassfiy::Train(string filename) { ifstream fin(filename.c_str()); int n ; fin>>n; for(int i = 0 ; i < n ; ++i){ double label; fin>>label; train_labels.push_back(label); double num; sample_type temp; for(int j = 0 ; j < features_num ; ++j){ fin>>num; temp(j) = num; } train_feature.push_back(temp); } fin.close(); // Finally, make the one_vs_one_trainer. // Next, we will make two different binary classification trainer objects. One // which uses kernel ridge regression and RBF kernels and another which uses a // support vector machine and polynomial kernels. The particular details don't matter. // The point of this part of the example is that you can use any kind of trainer object // with the one_vs_one_trainer. typedef polynomial_kernel<sample_type> poly_kernel; typedef radial_basis_kernel<sample_type> rbf_kernel; // make the binary trainers and set some parameters krr_trainer<rbf_kernel> rbf_trainer; svm_nu_trainer<poly_kernel> poly_trainer; poly_trainer.set_kernel(poly_kernel(0.1, 1, 2)); rbf_trainer.set_kernel(rbf_kernel(0.1)); // Now tell the one_vs_one_trainer that, by default, it should use the rbf_trainer // to solve the individual binary classification subproblems. trainer.set_trainer(rbf_trainer); // We can also get more specific. Here we tell the one_vs_one_trainer to use the // poly_trainer to solve the class 1 vs class 2 subproblem. All the others will // still be solved with the rbf_trainer. trainer.set_trainer(poly_trainer, 1, 2); df = trainer.train(train_feature, train_labels); cout << "predicted label: "<< df(train_feature[0]) << ", true label: "<< train_labels[0] << endl; cout << "predicted label: "<< df(train_feature[2]) << ", true label: "<< train_labels[2] << endl; } void dlibClassfiy::Predict(string filename) { ifstream fin(filename.c_str()); int n ; fin>>n; //add for bai // int realresult[40]={4,3,4,3,4,3,4,3,4,3,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}; for(int i = 0 ; i < n ; ++i){ double label; fin>>label; //label = realresult[i]; test_labels.push_back(label); double num; sample_type temp; for(int j = 0 ; j < features_num ; ++j){ fin>>num; temp(j) = num; } test_feature.push_back(temp); } fin.close(); //one_vs_one_decision_function<ovo_trainer> df = trainer.train(train_feature, train_labels); int test_num = test_feature.size(); int rigth_num = 0; for(int i = 0 ; i < test_num ; i ++){ cout << "predicted label: "<< df(test_feature[i]) << ", true label: "<< test_labels[i] << endl; if(df(test_feature[i]) == test_labels[i]) rigth_num ++; } cout << rigth_num*1.0/test_num <<endl; } void testMain() { dlibClassfiy test(1000); test.Train("featurevector"); cout << "-----------------------------" <<endl; test.Predict("testfeaturevector"); }
[ "fuxiang90@gmail.com" ]
fuxiang90@gmail.com
051ee64555d7b00b5a4dcd5f9232a14f8472b5b4
b22c254d7670522ec2caa61c998f8741b1da9388
/dependencies/OpenSceneGraph/include/osg/Drawable
6b748a6f40febfe99e82c77e2a86a8737899681a
[]
no_license
ldaehler/lbanet
341ddc4b62ef2df0a167caff46c2075fdfc85f5c
ecb54fc6fd691f1be3bae03681e355a225f92418
refs/heads/master
2021-01-23T13:17:19.963262
2011-03-22T21:49:52
2011-03-22T21:49:52
39,529,945
0
1
null
null
null
null
UTF-8
C++
false
false
44,221
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * 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 * OpenSceneGraph Public License for more details. */ #ifndef OSG_DRAWABLE #define OSG_DRAWABLE 1 #include <osg/BoundingBox> #include <osg/Shape> #include <osg/BufferObject> #include <osg/PrimitiveSet> #include <osg/RenderInfo> #ifndef GL_NV_occlusion_query #define GL_OCCLUSION_TEST_HP 0x8165 #define GL_OCCLUSION_TEST_RESULT_HP 0x8166 #define GL_PIXEL_COUNTER_BITS_NV 0x8864 #define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 #define GL_PIXEL_COUNT_NV 0x8866 #define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 #endif #ifndef GL_ARB_occlusion_query #define GL_SAMPLES_PASSED_ARB 0x8914 #define GL_QUERY_COUNTER_BITS_ARB 0x8864 #define GL_CURRENT_QUERY_ARB 0x8865 #define GL_QUERY_RESULT_ARB 0x8866 #define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 #endif #ifndef GL_TIME_ELAPSED #define GL_TIME_ELAPSED 0x88BF #endif #ifndef GL_QUERY_RESULT #define GL_QUERY_RESULT 0x8866 #define GL_QUERY_RESULT_AVAILABLE 0x8867 #endif #if !defined(GL_EXT_timer_query) && !defined(OSG_GL3_AVAILABLE) #ifdef _WIN32 typedef __int64 GLint64EXT; typedef unsigned __int64 GLuint64EXT; #else typedef long long int GLint64EXT; typedef unsigned long long int GLuint64EXT; #endif #endif namespace osg { class Vec2f; class Vec3f; class Vec4f; class Vec4ub; class Geometry; class NodeVisitor; class ArrayDispatchers; // this is defined to alter the way display lists are compiled inside the // the draw method, it has been found that the NVidia drivers fail completely // to optimize COMPILE_AND_EXECUTE in fact make it go slower than for no display // lists, but optimize a separate COMPILE very well?! Define it as default // the use of a separate COMPILE, then glCallList rather than use COMPILE_AND_EXECUTE. #define USE_SEPARATE_COMPILE_AND_EXECUTE /** Pure virtual base class for drawable geometry. In OSG, everything that can * be rendered is implemented as a class derived from \c Drawable. The * \c Drawable class contains no drawing primitives, since these are provided * by subclasses such as \c osg::Geometry. * <p>Notice that a \c Drawable is not a \c Node, and therefore it cannot be * directly added to a scene graph. Instead, <tt>Drawable</tt>s are attached to * <tt>Geode</tt>s, which are scene graph nodes. * <p>The OpenGL state that must be used when rendering a \c Drawable is * represented by a \c StateSet. Since a \c Drawable has a reference * (\c osg::ref_ptr) to a \c StateSet, <tt>StateSet</tt>s can be shared between * different <tt>Drawable</tt>s. In fact, sharing <tt>StateSet</tt>s is a good * way to improve performance, since this allows OSG to reduce the number of * expensive changes in the OpenGL state. * <p>Finally, <tt>Drawable</tt>s can also be shared between different * <tt>Geode</tt>s, so that the same geometry (loaded to memory just once) can * be used in different parts of the scene graph. */ class OSG_EXPORT Drawable : public Object { public: static unsigned int s_numberDrawablesReusedLastInLastFrame; static unsigned int s_numberNewDrawablesInLastFrame; static unsigned int s_numberDeletedDrawablesInLastFrame; Drawable(); /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ Drawable(const Drawable& drawable,const CopyOp& copyop=CopyOp::SHALLOW_COPY); virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Drawable*>(obj)!=NULL; } virtual const char* libraryName() const { return "osg"; } virtual const char* className() const { return "Drawable"; } /** Convert 'this' into a Geometry pointer if Drawable is a Geometry, otherwise return 0. * Equivalent to dynamic_cast<Geometry*>(this).*/ virtual Geometry* asGeometry() { return 0; } /** Convert 'const this' into a const Geometry pointer if Drawable is a Geometry, otherwise return 0. * Equivalent to dynamic_cast<const Geometry*>(this).*/ virtual const Geometry* asGeometry() const { return 0; } /** Compute the DataVariance based on an assessment of callback etc.*/ virtual void computeDataVariance(); /** A vector of osg::Node pointers which is used to store the parent(s) of drawable.*/ typedef std::vector<Node*> ParentList; /** Get the parent list of drawable. */ inline const ParentList& getParents() const { return _parents; } /** Get the a copy of parent list of node. A copy is returned to * prevent modification of the parent list.*/ inline ParentList getParents() { return _parents; } /** Get a single parent of Drawable. * @param i index of the parent to get. * @return the parent i. */ inline Node* getParent(unsigned int i) { return _parents[i]; } /** Get a single const parent of Drawable. * @param i index of the parent to get. * @return the parent i. */ inline const Node* getParent(unsigned int i) const { return _parents[i]; } /** * Get the number of parents of node. * @return the number of parents of this node. */ inline unsigned int getNumParents() const { return static_cast<unsigned int>(_parents.size()); } /** Get the list of matrices that transform this node from local coordinates to world coordinates. * The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. */ MatrixList getWorldMatrices(const osg::Node* haltTraversalAtNode=0) const; /** Set the StateSet attached to the Drawable. Previously attached StateSet are automatically unreferenced on assignment of a new drawstate.*/ void setStateSet(StateSet* stateset); /** Get the attached StateSet.*/ inline StateSet* getStateSet() { return _stateset.get();} /** Get the attached const StateSet.*/ inline const StateSet* getStateSet() const { return _stateset.get();} /** Get the attached const StateSet, * if one is not already attached create one, * attach it to the drawable and return a pointer to it.*/ StateSet* getOrCreateStateSet(); /** Set the initial bounding volume to use when computing the overall bounding volume.*/ void setInitialBound(const osg::BoundingBox& bbox) { _initialBound = bbox; dirtyBound(); } /** Set the initial bounding volume to use when computing the overall bounding volume.*/ const BoundingBox& getInitialBound() const { return _initialBound; } /** Dirty the bounding box, forcing a computeBound() on the next call * to getBound(). Should be called in the internal geometry of the Drawable * is modified.*/ void dirtyBound(); /** Get BoundingBox of Drawable. * If the BoundingBox is not up to date then its updated via an internal call to computeBond(). */ inline const BoundingBox& getBound() const { if(!_boundingBoxComputed) { _boundingBox = _initialBound; if (_computeBoundCallback.valid()) _boundingBox.expandBy(_computeBoundCallback->computeBound(*this)); else _boundingBox.expandBy(computeBound()); _boundingBoxComputed = true; } return _boundingBox; } /** Compute the bounding box around Drawables's geometry.*/ virtual BoundingBox computeBound() const; /** Callback to allow users to override the default computation of bounding volume. */ struct ComputeBoundingBoxCallback : public osg::Object { ComputeBoundingBoxCallback() {} ComputeBoundingBoxCallback(const ComputeBoundingBoxCallback&,const CopyOp&) {} META_Object(osg,ComputeBoundingBoxCallback); virtual BoundingBox computeBound(const osg::Drawable&) const { return BoundingBox(); } }; /** Set the compute bound callback to override the default computeBound.*/ void setComputeBoundingBoxCallback(ComputeBoundingBoxCallback* callback) { _computeBoundCallback = callback; } /** Get the compute bound callback.*/ ComputeBoundingBoxCallback* getComputeBoundingBoxCallback() { return _computeBoundCallback.get(); } /** Get the const compute bound callback.*/ const ComputeBoundingBoxCallback* getComputeBoundingBoxCallback() const { return _computeBoundCallback.get(); } /** Set the Shape of the \c Drawable. The shape can be used to * speed up collision detection or as a guide for procedural * geometry generation. * @see osg::Shape. */ inline void setShape(Shape* shape) { _shape = shape; } /** Get the Shape of the Drawable.*/ inline Shape* getShape() { return _shape.get(); } /** Get the const Shape of the const Drawable.*/ inline const Shape* getShape() const { return _shape.get(); } /** Set the drawable so that it can or cannot be used in conjunction with OpenGL * display lists. When set to true, calls to Drawable::setUseDisplayList, * whereas when set to false, no display lists can be created and calls * to setUseDisplayList are ignored, and a warning is produced. The latter * is typically used to guard against the switching on of display lists * on objects with dynamic internal data such as continuous Level of Detail * algorithms.*/ void setSupportsDisplayList(bool flag); /** Get whether display lists are supported for this drawable instance.*/ inline bool getSupportsDisplayList() const { return _supportsDisplayList; } /** When set to true, force the draw method to use OpenGL Display List for rendering. If false, rendering directly. If the display list has not been compiled already, the next call to draw will automatically create the display list.*/ void setUseDisplayList(bool flag); /** Return whether OpenGL display lists are being used for rendering.*/ inline bool getUseDisplayList() const { return _useDisplayList; } /** Return OpenGL display list for specified contextID. */ inline GLuint& getDisplayList(unsigned int contextID) const { return _globjList[contextID]; } /** When set to true, ignore the setUseDisplayList() settings, and hints to the drawImplementation method to use OpenGL vertex buffer objects for rendering.*/ virtual void setUseVertexBufferObjects(bool flag); /** Return whether OpenGL vertex buffer objects should be used when supported by OpenGL driver.*/ inline bool getUseVertexBufferObjects() const { return _useVertexBufferObjects; } /** Force a recompile on next draw() of any OpenGL display list associated with this geoset.*/ virtual void dirtyDisplayList(); /** Return the estimated size of GLObjects (display lists/vertex buffer objects) that are associated with this drawable. * This size is used a hint for reuse of deleted display lists/vertex buffer objects. */ virtual unsigned int getGLObjectSizeHint() const { return 0; } /** Draw OpenGL primitives. * If the \c Drawable has \c _useDisplayList set to \c true, then use * an OpenGL display list, automatically compiling one if required. * Otherwise, call \c drawImplementation(). * @note This method should \e not be overridden in subclasses, as it * manages the optional display list (notice this is not even * \c virtual). Subclasses should override * \c drawImplementation() instead. */ inline void draw(RenderInfo& renderInfo) const; /** Immediately compile this \c Drawable into an OpenGL Display List/VertexBufferObjects. * @note Operation is ignored if \c _useDisplayList is \c false or VertexBufferObjects are not used. */ virtual void compileGLObjects(RenderInfo& renderInfo) const; /** Set whether to use a mutex to ensure ref() and unref() are thread safe.*/ virtual void setThreadSafeRefUnref(bool threadSafe); /** Resize any per context GLObject buffers to specified size. */ virtual void resizeGLObjectBuffers(unsigned int maxSize); /** If State is non-zero, this function releases OpenGL objects for * the specified graphics context. Otherwise, releases OpenGL objects * for all graphics contexts. */ virtual void releaseGLObjects(State* state=0) const; struct UpdateCallback : public virtual osg::Object { UpdateCallback() {} UpdateCallback(const UpdateCallback&,const CopyOp&) {} META_Object(osg,UpdateCallback); /** do customized update code.*/ virtual void update(osg::NodeVisitor*, osg::Drawable*) {} }; /** Set the UpdateCallback which allows users to attach customize the updating of an object during the update traversal. */ virtual void setUpdateCallback(UpdateCallback* ac); /** Get the non const UpdateCallback.*/ UpdateCallback* getUpdateCallback() { return _updateCallback.get(); } /** Get the const UpdateCallback.*/ const UpdateCallback* getUpdateCallback() const { return _updateCallback.get(); } /** Return whether this Drawable has update callbacks associated with it, and therefore must be traversed.*/ bool requiresUpdateTraversal() const { return _updateCallback.valid() || (_stateset.valid() && _stateset->requiresUpdateTraversal()); } struct EventCallback : public virtual osg::Object { EventCallback() {} EventCallback(const EventCallback&,const CopyOp&) {} META_Object(osg,EventCallback); /** do customized Event code. */ virtual void event(osg::NodeVisitor*, osg::Drawable*) {} }; /** Set the EventCallback which allows users to attach customize the updating of an object during the Event traversal.*/ virtual void setEventCallback(EventCallback* ac); /** Get the non const EventCallback.*/ EventCallback* getEventCallback() { return _eventCallback.get(); } /** Get the const EventCallback.*/ const EventCallback* getEventCallback() const { return _eventCallback.get(); } /** Return whether this Drawable has event callbacks associated with it, and therefore must be traversed.*/ bool requiresEventTraversal() const { return _eventCallback.valid() || (_stateset.valid() && _stateset->requiresEventTraversal()); } struct CullCallback : public virtual osg::Object { CullCallback() {} CullCallback(const CullCallback&,const CopyOp&) {} META_Object(osg,CullCallback); /** deprecated.*/ virtual bool cull(osg::NodeVisitor*, osg::Drawable*, osg::State*) const { return false; } /** do customized cull code, return true if drawable should be culled.*/ virtual bool cull(osg::NodeVisitor* nv, osg::Drawable* drawable, osg::RenderInfo* renderInfo) const { return cull(nv, drawable, renderInfo? renderInfo->getState():0); } }; /** Set the CullCallback which allows users to customize the culling of Drawable during the cull traversal.*/ virtual void setCullCallback(CullCallback* cc) { _cullCallback=cc; } /** Get the non const CullCallback.*/ CullCallback* getCullCallback() { return _cullCallback.get(); } /** Get the const CullCallback.*/ const CullCallback* getCullCallback() const { return _cullCallback.get(); } /** Callback attached to an Drawable which allows the users to customize the drawing of an exist Drawable object. * The draw callback is implement as a replacement to the Drawable's own drawImplementation() method, if the * the user intends to decorate the existing draw code then simple call the drawable->drawImplementation() from * with the callbacks drawImplementation() method. This allows the users to do both pre and post callbacks * without fuss and can even disable the inner draw if required.*/ struct DrawCallback : public virtual osg::Object { DrawCallback() {} DrawCallback(const DrawCallback&,const CopyOp&) {} META_Object(osg,DrawCallback); /** do customized draw code.*/ virtual void drawImplementation(osg::RenderInfo& /*renderInfo*/,const osg::Drawable* /*drawable*/) const {} }; /** Set the DrawCallback which allows users to attach customize the drawing of existing Drawable object.*/ virtual void setDrawCallback(DrawCallback* dc) { _drawCallback=dc; dirtyDisplayList(); } /** Get the non const DrawCallback.*/ DrawCallback* getDrawCallback() { return _drawCallback.get(); } /** Get the const DrawCallback.*/ const DrawCallback* getDrawCallback() const { return _drawCallback.get(); } /** drawImplementation(RenderInfo&) is a pure virtual method for the actual implementation of OpenGL drawing calls, such as vertex arrays and primitives, that * must be implemented in concrete subclasses of the Drawable base class, examples include osg::Geometry and osg::ShapeDrawable. * drawImplementation(RenderInfo&) is called from the draw(RenderInfo&) method, with the draw method handling management of OpenGL display lists, * and drawImplementation(RenderInfo&) handling the actual drawing itself. * @param renderInfo The osg::RenderInfo object that encapsulates the current rendering information including the osg::State OpenGL state for the current graphics context. */ virtual void drawImplementation(RenderInfo& renderInfo) const = 0; /** Return a OpenGL display list handle a newly generated or reused from display list cache. */ static GLuint generateDisplayList(unsigned int contextID, unsigned int sizeHint = 0); /** Set the minimum number of display lists to retain in the deleted display list cache. */ static void setMinimumNumberOfDisplayListsToRetainInCache(unsigned int minimum); /** Get the minimum number of display lists to retain in the deleted display list cache. */ static unsigned int getMinimumNumberOfDisplayListsToRetainInCache(); /** Use deleteDisplayList instead of glDeleteList to allow * OpenGL display list to be cached until they can be deleted * by the OpenGL context in which they were created, specified * by contextID.*/ static void deleteDisplayList(unsigned int contextID,GLuint globj, unsigned int sizeHint = 0); /** Flush all the cached display list which need to be deleted * in the OpenGL context related to contextID.*/ static void flushAllDeletedDisplayLists(unsigned int contextID); /** Flush all the cached display list which need to be deleted * in the OpenGL context related to contextID. * Note, unlike flush no OpenGL calls are made, instead the handles are all removed. * this call is useful for when an OpenGL context has been destroyed. */ static void discardAllDeletedDisplayLists(unsigned int contextID); /** Flush the cached display list which need to be deleted * in the OpenGL context related to contextID.*/ static void flushDeletedDisplayLists(unsigned int contextID,double& availableTime); typedef unsigned int AttributeType; enum AttributeTypes { VERTICES = 0, WEIGHTS = 1, NORMALS = 2, COLORS = 3, SECONDARY_COLORS = 4, FOG_COORDS = 5, ATTRIBUTE_6 = 6, ATTRIBUTE_7 = 7, TEXTURE_COORDS = 8, TEXTURE_COORDS_0 = TEXTURE_COORDS, TEXTURE_COORDS_1 = TEXTURE_COORDS_0+1, TEXTURE_COORDS_2 = TEXTURE_COORDS_0+2, TEXTURE_COORDS_3 = TEXTURE_COORDS_0+3, TEXTURE_COORDS_4 = TEXTURE_COORDS_0+4, TEXTURE_COORDS_5 = TEXTURE_COORDS_0+5, TEXTURE_COORDS_6 = TEXTURE_COORDS_0+6, TEXTURE_COORDS_7 = TEXTURE_COORDS_0+7 // only eight texture coord examples provided here, but underlying code can handle any no of texture units, // simply co them as (TEXTURE_COORDS_0+unit). }; class AttributeFunctor { public: virtual ~AttributeFunctor() {} virtual void apply(AttributeType,unsigned int,GLbyte*) {} virtual void apply(AttributeType,unsigned int,GLshort*) {} virtual void apply(AttributeType,unsigned int,GLint*) {} virtual void apply(AttributeType,unsigned int,GLubyte*) {} virtual void apply(AttributeType,unsigned int,GLushort*) {} virtual void apply(AttributeType,unsigned int,GLuint*) {} virtual void apply(AttributeType,unsigned int,float*) {} virtual void apply(AttributeType,unsigned int,Vec2*) {} virtual void apply(AttributeType,unsigned int,Vec3*) {} virtual void apply(AttributeType,unsigned int,Vec4*) {} virtual void apply(AttributeType,unsigned int,Vec4ub*) {} virtual void apply(AttributeType,unsigned int,double*) {} virtual void apply(AttributeType,unsigned int,Vec2d*) {} virtual void apply(AttributeType,unsigned int,Vec3d*) {} virtual void apply(AttributeType,unsigned int,Vec4d*) {} }; /** Return true if the Drawable subclass supports accept(AttributeFunctor&).*/ virtual bool supports(const AttributeFunctor&) const { return false; } /** accept an AttributeFunctor and call its methods to tell it about the internal attributes that this Drawable has. * return true if functor handled by drawable, * return false on failure of drawable to generate functor calls.*/ virtual void accept(AttributeFunctor&) {} class ConstAttributeFunctor { public: virtual ~ConstAttributeFunctor() {} virtual void apply(AttributeType,unsigned int,const GLbyte*) {} virtual void apply(AttributeType,unsigned int,const GLshort*) {} virtual void apply(AttributeType,unsigned int,const GLint*) {} virtual void apply(AttributeType,unsigned int,const GLubyte*) {} virtual void apply(AttributeType,unsigned int,const GLushort*) {} virtual void apply(AttributeType,unsigned int,const GLuint*) {} virtual void apply(AttributeType,unsigned int,const float*) {} virtual void apply(AttributeType,unsigned int,const Vec2*) {} virtual void apply(AttributeType,unsigned int,const Vec3*) {} virtual void apply(AttributeType,unsigned int,const Vec4*) {} virtual void apply(AttributeType,unsigned int,const Vec4ub*) {} virtual void apply(AttributeType,unsigned int,const double*) {} virtual void apply(AttributeType,unsigned int,const Vec2d*) {} virtual void apply(AttributeType,unsigned int,const Vec3d*) {} virtual void apply(AttributeType,unsigned int,const Vec4d*) {} }; /** Return true if the Drawable subclass supports accept(ConstAttributeFunctor&).*/ virtual bool supports(const ConstAttributeFunctor&) const { return false; } /** Accept an AttributeFunctor and call its methods to tell it about the internal attributes that this Drawable has. * return true if functor handled by drawable, * return false on failure of drawable to generate functor calls.*/ virtual void accept(ConstAttributeFunctor&) const {} /** Return true if the Drawable subclass supports accept(PrimitiveFunctor&).*/ virtual bool supports(const PrimitiveFunctor&) const { return false; } /** Accept a PrimitiveFunctor and call its methods to tell it about the internal primitives that this Drawable has. * return true if functor handled by drawable, return false on failure of drawable to generate functor calls. * Note, PrimtiveFunctor only provides const access of the primitives, as primitives may be procedurally generated * so one cannot modify it.*/ virtual void accept(PrimitiveFunctor&) const {} /** Return true if the Drawable subclass supports accept(PrimitiveIndexFunctor&).*/ virtual bool supports(const PrimitiveIndexFunctor&) const { return false; } /** Accept a PrimitiveIndexFunctor and call its methods to tell it about the internal primitives that this Drawable has. * return true if functor handled by drawable, return false on failure of drawable to generate functor calls. * Note, PrimtiveIndexFunctor only provide const access of the primitives, as primitives may be procedurally generated * so one cannot modify it.*/ virtual void accept(PrimitiveIndexFunctor&) const {} /** Extensions class which encapsulates the querying of extensions and * associated function pointers, and provide convenience wrappers to * check for the extensions or use the associated functions.*/ class OSG_EXPORT Extensions : public osg::Referenced { public: Extensions(unsigned int contextID); Extensions(const Extensions& rhs); void lowestCommonDenominator(const Extensions& rhs); void setupGLExtensions(unsigned int contextID); void setVertexProgramSupported(bool flag) { _isVertexProgramSupported=flag; } bool isVertexProgramSupported() const { return _isVertexProgramSupported; } void setSecondaryColorSupported(bool flag) { _isSecondaryColorSupported=flag; } bool isSecondaryColorSupported() const { return _isSecondaryColorSupported; } void setFogCoordSupported(bool flag) { _isFogCoordSupported=flag; } bool isFogCoordSupported() const { return _isFogCoordSupported; } void setMultiTexSupported(bool flag) { _isMultiTexSupported=flag; } bool isMultiTexSupported() const { return _isMultiTexSupported; } void setOcclusionQuerySupported(bool flag) { _isOcclusionQuerySupported=flag; } bool isOcclusionQuerySupported() const { return _isOcclusionQuerySupported; } void setARBOcclusionQuerySupported(bool flag) { _isARBOcclusionQuerySupported=flag; } bool isARBOcclusionQuerySupported() const { return _isARBOcclusionQuerySupported; } void setTimerQuerySupported(bool flag) { _isTimerQuerySupported = flag; } bool isTimerQuerySupported() const { return _isTimerQuerySupported; } void glSecondaryColor3ubv(const GLubyte* coord) const; void glSecondaryColor3fv(const GLfloat* coord) const; void glFogCoordfv(const GLfloat* coord) const; void glMultiTexCoord1f(GLenum target,GLfloat coord) const; void glMultiTexCoord2fv(GLenum target,const GLfloat* coord) const; void glMultiTexCoord3fv(GLenum target,const GLfloat* coord) const; void glMultiTexCoord4fv(GLenum target,const GLfloat* coord) const; void glMultiTexCoord1d(GLenum target,GLdouble coord) const; void glMultiTexCoord2dv(GLenum target,const GLdouble* coord) const; void glMultiTexCoord3dv(GLenum target,const GLdouble* coord) const; void glMultiTexCoord4dv(GLenum target,const GLdouble* coord) const; void glVertexAttrib1s(unsigned int index, GLshort s) const; void glVertexAttrib1f(unsigned int index, GLfloat f) const; void glVertexAttrib1d(unsigned int index, GLdouble f) const; void glVertexAttrib2fv(unsigned int index, const GLfloat * v) const; void glVertexAttrib3fv(unsigned int index, const GLfloat * v) const; void glVertexAttrib4fv(unsigned int index, const GLfloat * v) const; void glVertexAttrib2dv(unsigned int index, const GLdouble * v) const; void glVertexAttrib3dv(unsigned int index, const GLdouble * v) const; void glVertexAttrib4dv(unsigned int index, const GLdouble * v) const; void glVertexAttrib4ubv(unsigned int index, const GLubyte * v) const; void glVertexAttrib4Nubv(unsigned int index, const GLubyte * v) const; void glGenBuffers (GLsizei n, GLuint *buffers) const; void glBindBuffer (GLenum target, GLuint buffer) const; void glBufferData (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage) const; void glBufferSubData (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data) const; void glDeleteBuffers (GLsizei n, const GLuint *buffers) const; GLboolean glIsBuffer (GLuint buffer) const; void glGetBufferSubData (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data) const; GLvoid* glMapBuffer (GLenum target, GLenum access) const; GLboolean glUnmapBuffer (GLenum target) const; void glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params) const; void glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params) const; void glGenOcclusionQueries( GLsizei n, GLuint *ids ) const; void glDeleteOcclusionQueries( GLsizei n, const GLuint *ids ) const; GLboolean glIsOcclusionQuery( GLuint id ) const; void glBeginOcclusionQuery( GLuint id ) const; void glEndOcclusionQuery() const; void glGetOcclusionQueryiv( GLuint id, GLenum pname, GLint *params ) const; void glGetOcclusionQueryuiv( GLuint id, GLenum pname, GLuint *params ) const; void glGetQueryiv(GLenum target, GLenum pname, GLint *params) const; void glGenQueries(GLsizei n, GLuint *ids) const; void glBeginQuery(GLenum target, GLuint id) const; void glEndQuery(GLenum target) const; GLboolean glIsQuery(GLuint id) const; void glDeleteQueries(GLsizei n, const GLuint *ids) const; void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) const; void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) const; void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params) const; protected: friend class ArrayDispatchers; typedef void (APIENTRY * FogCoordProc) (const GLfloat* coord); typedef void (APIENTRY * VertexAttrib1sProc) (GLuint index, GLshort s); typedef void (APIENTRY * VertexAttrib1fProc) (GLuint index, GLfloat f); typedef void (APIENTRY * VertexAttrib1dProc) (GLuint index, GLdouble f); typedef void (APIENTRY * VertexAttribfvProc) (GLuint index, const GLfloat * v); typedef void (APIENTRY * VertexAttribdvProc) (GLuint index, const GLdouble * v); typedef void (APIENTRY * VertexAttribubvProc) (GLuint index, const GLubyte * v); typedef void (APIENTRY * SecondaryColor3ubvProc) (const GLubyte* coord); typedef void (APIENTRY * SecondaryColor3fvProc) (const GLfloat* coord); typedef void (APIENTRY * MultiTexCoord1fProc) (GLenum target,GLfloat coord); typedef void (APIENTRY * MultiTexCoordfvProc) (GLenum target,const GLfloat* coord); typedef void (APIENTRY * MultiTexCoord1dProc) (GLenum target,GLdouble coord); typedef void (APIENTRY * MultiTexCoorddvProc) (GLenum target,const GLdouble* coord); typedef void (APIENTRY * GenBuffersProc) (GLsizei n, GLuint *buffers); typedef void (APIENTRY * BindBufferProc) (GLenum target, GLuint buffer); typedef void (APIENTRY * BufferDataProc) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); typedef void (APIENTRY * BufferSubDataProc) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); typedef void (APIENTRY * DeleteBuffersProc) (GLsizei n, const GLuint *buffers); typedef GLboolean (APIENTRY * IsBufferProc) (GLuint buffer); typedef void (APIENTRY * GetBufferSubDataProc) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); typedef GLvoid* (APIENTRY * MapBufferProc) (GLenum target, GLenum access); typedef GLboolean (APIENTRY * UnmapBufferProc) (GLenum target); typedef void (APIENTRY * GetBufferParameterivProc) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRY * GetBufferPointervProc) (GLenum target, GLenum pname, GLvoid* *params); typedef void (APIENTRY * GenOcclusionQueriesProc) ( GLsizei n, GLuint *ids ); typedef void (APIENTRY * DeleteOcclusionQueriesProc) ( GLsizei n, const GLuint *ids ); typedef GLboolean (APIENTRY * IsOcclusionQueryProc) ( GLuint id ); typedef void (APIENTRY * BeginOcclusionQueryProc) ( GLuint id ); typedef void (APIENTRY * EndOcclusionQueryProc) (); typedef void (APIENTRY * GetOcclusionQueryivProc) ( GLuint id, GLenum pname, GLint *params ); typedef void (APIENTRY * GetOcclusionQueryuivProc) ( GLuint id, GLenum pname, GLuint *params ); typedef void (APIENTRY * GetOcclusionQueryui64vProc) ( GLuint id, GLenum pname, GLuint64EXT *params ); typedef void (APIENTRY *GenQueriesProc) (GLsizei n, GLuint *ids); typedef void (APIENTRY *DeleteQueriesProc) (GLsizei n, const GLuint *ids); typedef GLboolean (APIENTRY *IsQueryProc) (GLuint id); typedef void (APIENTRY *BeginQueryProc) (GLenum target, GLuint id); typedef void (APIENTRY *EndQueryProc) (GLenum target); typedef void (APIENTRY *GetQueryivProc) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRY *GetQueryObjectivProc) (GLuint id, GLenum pname, GLint *params); typedef void (APIENTRY *GetQueryObjectuivProc) (GLuint id, GLenum pname, GLuint *params); typedef void (APIENTRY *GetQueryObjectui64vProc) (GLuint id, GLenum pname, GLuint64EXT *params); ~Extensions() {} bool _isVertexProgramSupported; bool _isSecondaryColorSupported; bool _isFogCoordSupported; bool _isMultiTexSupported; bool _isOcclusionQuerySupported; bool _isARBOcclusionQuerySupported; bool _isTimerQuerySupported; FogCoordProc _glFogCoordfv; SecondaryColor3ubvProc _glSecondaryColor3ubv; SecondaryColor3fvProc _glSecondaryColor3fv; VertexAttrib1sProc _glVertexAttrib1s; VertexAttrib1fProc _glVertexAttrib1f; VertexAttrib1dProc _glVertexAttrib1d; VertexAttribfvProc _glVertexAttrib1fv; VertexAttribfvProc _glVertexAttrib2fv; VertexAttribfvProc _glVertexAttrib3fv; VertexAttribfvProc _glVertexAttrib4fv; VertexAttribdvProc _glVertexAttrib1dv; VertexAttribdvProc _glVertexAttrib2dv; VertexAttribdvProc _glVertexAttrib3dv; VertexAttribdvProc _glVertexAttrib4dv; VertexAttribubvProc _glVertexAttrib4ubv; VertexAttribubvProc _glVertexAttrib4Nubv; MultiTexCoord1fProc _glMultiTexCoord1f; MultiTexCoordfvProc _glMultiTexCoord1fv; MultiTexCoordfvProc _glMultiTexCoord2fv; MultiTexCoordfvProc _glMultiTexCoord3fv; MultiTexCoordfvProc _glMultiTexCoord4fv; MultiTexCoord1dProc _glMultiTexCoord1d; MultiTexCoorddvProc _glMultiTexCoord1dv; MultiTexCoorddvProc _glMultiTexCoord2dv; MultiTexCoorddvProc _glMultiTexCoord3dv; MultiTexCoorddvProc _glMultiTexCoord4dv; GenBuffersProc _glGenBuffers; BindBufferProc _glBindBuffer; BufferDataProc _glBufferData; BufferSubDataProc _glBufferSubData; DeleteBuffersProc _glDeleteBuffers; IsBufferProc _glIsBuffer; GetBufferSubDataProc _glGetBufferSubData; MapBufferProc _glMapBuffer; UnmapBufferProc _glUnmapBuffer; GetBufferParameterivProc _glGetBufferParameteriv; GetBufferPointervProc _glGetBufferPointerv; GenOcclusionQueriesProc _glGenOcclusionQueries; DeleteOcclusionQueriesProc _glDeleteOcclusionQueries; IsOcclusionQueryProc _glIsOcclusionQuery; BeginOcclusionQueryProc _glBeginOcclusionQuery; EndOcclusionQueryProc _glEndOcclusionQuery; GetOcclusionQueryivProc _glGetOcclusionQueryiv; GetOcclusionQueryuivProc _glGetOcclusionQueryuiv; GenQueriesProc _gl_gen_queries_arb; DeleteQueriesProc _gl_delete_queries_arb; IsQueryProc _gl_is_query_arb; BeginQueryProc _gl_begin_query_arb; EndQueryProc _gl_end_query_arb; GetQueryivProc _gl_get_queryiv_arb; GetQueryObjectivProc _gl_get_query_objectiv_arb; GetQueryObjectuivProc _gl_get_query_objectuiv_arb; GetQueryObjectui64vProc _gl_get_query_objectui64v; }; /** Function to call to get the extension of a specified context. * If the Extension object for that context has not yet been created * and the 'createIfNotInitalized' flag been set to false then returns NULL. * If 'createIfNotInitalized' is true then the Extensions object is * automatically created. However, in this case the extension object is * only created with the graphics context associated with ContextID..*/ static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized); /** setExtensions allows users to override the extensions across graphics contexts. * typically used when you have different extensions supported across graphics pipes * but need to ensure that they all use the same low common denominator extensions.*/ static void setExtensions(unsigned int contextID,Extensions* extensions); protected: Drawable& operator = (const Drawable&) { return *this;} virtual ~Drawable(); /** set the bounding box .*/ void setBound(const BoundingBox& bb) const; void addParent(osg::Node* node); void removeParent(osg::Node* node); ParentList _parents; friend class Node; friend class Geode; friend class StateSet; ref_ptr<StateSet> _stateset; BoundingBox _initialBound; ref_ptr<ComputeBoundingBoxCallback> _computeBoundCallback; mutable BoundingBox _boundingBox; mutable bool _boundingBoxComputed; ref_ptr<Shape> _shape; bool _supportsDisplayList; bool _useDisplayList; bool _supportsVertexBufferObjects; bool _useVertexBufferObjects; typedef osg::buffered_value<GLuint> GLObjectList; mutable GLObjectList _globjList; ref_ptr<UpdateCallback> _updateCallback; unsigned int _numChildrenRequiringUpdateTraversal; void setNumChildrenRequiringUpdateTraversal(unsigned int num); unsigned int getNumChildrenRequiringUpdateTraversal() const { return _numChildrenRequiringUpdateTraversal; } ref_ptr<EventCallback> _eventCallback; unsigned int _numChildrenRequiringEventTraversal; void setNumChildrenRequiringEventTraversal(unsigned int num); unsigned int getNumChildrenRequiringEventTraversal() const { return _numChildrenRequiringEventTraversal; } ref_ptr<CullCallback> _cullCallback; ref_ptr<DrawCallback> _drawCallback; }; inline void Drawable::draw(RenderInfo& renderInfo) const { #ifdef OSG_GL_DISPLAYLISTS_AVAILABLE if (_useDisplayList && !(_supportsVertexBufferObjects && _useVertexBufferObjects && renderInfo.getState()->isVertexBufferObjectSupported())) { // get the contextID (user defined ID of 0 upwards) for the // current OpenGL context. unsigned int contextID = renderInfo.getContextID(); // get the globj for the current contextID. GLuint& globj = _globjList[contextID]; // call the globj if already set otherwise compile and execute. if( globj != 0 ) { glCallList( globj ); } else if (_useDisplayList) { #ifdef USE_SEPARATE_COMPILE_AND_EXECUTE globj = generateDisplayList(contextID, getGLObjectSizeHint()); glNewList( globj, GL_COMPILE ); if (_drawCallback.valid()) _drawCallback->drawImplementation(renderInfo,this); else drawImplementation(renderInfo); glEndList(); glCallList( globj); #else globj = generateDisplayList(contextID, getGLObjectSizeHint()); glNewList( globj, GL_COMPILE_AND_EXECUTE ); if (_drawCallback.valid()) _drawCallback->drawImplementation(renderInfo,this); else drawImplementation(renderInfo); glEndList(); #endif } return; } #endif // draw object as nature intended.. if (_drawCallback.valid()) _drawCallback->drawImplementation(renderInfo,this); else drawImplementation(renderInfo); } } #endif
[ "vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13" ]
vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13
f7da31daa581d99c9dd18c4e0eb70615fe25af27
2896fa8c8fa20081c8b5da47e024cf0f15ee9e06
/src/mfc/afxrebarstate.cpp
2df9591aea517e9e6c1d3bce7c0f9151392bf8b3
[]
no_license
adzm/atlmfc
f2b7f1f0200df07a000cea31f62b146fb094b253
ea3ab8e4dee965905ae14f34d04b44ad1027827b
refs/heads/master
2021-05-17T02:41:49.896685
2020-03-27T16:30:55
2020-03-27T16:30:55
250,580,780
10
1
null
null
null
null
UTF-8
C++
false
false
5,089
cpp
// This is a part of the Microsoft Foundation Classes C++ library. // Copyright (C) Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product. #include "stdafx.h" #include "afxsettingsstore.h" #include "afxrebar.h" #include "afxrebarstate.h" #define AFX_REBAR_FORMAT_KEY _T("Rebar-%ld") #define AFX_REBAR_KEY _T("RBI") #define AFX_REBAR_ID_KEY _T("IDs") BOOL CMFCReBarState::LoadRebarStateProc(HWND hwnd, LPARAM lParam) { // determine if this is a rebar: CWnd* pWnd = CWnd::FromHandle(hwnd); if (!pWnd->IsKindOf(RUNTIME_CLASS(CMFCReBar))) { return TRUE; } CReBarCtrl& rc = reinterpret_cast<CMFCReBar*>(pWnd)->GetReBarCtrl(); const UINT nBandInfoSize = reinterpret_cast<CMFCReBar*>(pWnd)->GetReBarBandInfoSize (); // retrieve our registry section: CString strRegSection = reinterpret_cast<LPCTSTR>(lParam); CString strRebar; strRebar.Format(AFX_REBAR_FORMAT_KEY, GetWindowLong(rc.GetSafeHwnd(), GWL_ID)); strRegSection += strRebar; CSettingsStoreSP regSP; CSettingsStore& reg = regSP.Create(FALSE, TRUE); if (!reg.Open(strRegSection)) { return FALSE; } UINT nBands = 0; // attempt to load this rebar: REBARBANDINFO* aBandInfo = NULL; if (!reg.Read(AFX_REBAR_KEY, reinterpret_cast<BYTE**>(&aBandInfo), &nBands)) { if (aBandInfo != NULL) { delete [] aBandInfo; } return TRUE; } LONG_PTR* aBandIds = NULL; if (!reg.Read(AFX_REBAR_ID_KEY, reinterpret_cast<BYTE**>(&aBandIds), &nBands)) { delete [] aBandInfo; if (aBandIds != NULL) { delete [] aBandIds; } return TRUE; } // band count should be identical nBands /= sizeof(LONG_PTR); if (nBands != rc.GetBandCount()) { delete [] aBandInfo; delete [] aBandIds; return TRUE; } // reorder the bands: REBARBANDINFO rbi; for (int i = 0 ; i < (int)nBands ; i++) { // check all bands(in a release build the assert above won't fire if there's a mixup // and we'll happily do our best) for (int j = i; j < (int) rc.GetBandCount(); j++) { memset(&rbi, 0, nBandInfoSize); rbi.cbSize = nBandInfoSize; rbi.fMask = RBBIM_CHILD; rc.GetBandInfo(j, &rbi); if (aBandIds[i] != GetWindowLong(rbi.hwndChild, GWL_ID)) continue; if (i != j) rc.MoveBand(j, i); // make sure that unpersistable information is not used when setting the band info aBandInfo[i].lpText = NULL; aBandInfo[i].cch = 0; aBandInfo[i].hwndChild = NULL; aBandInfo[i].hbmBack = NULL; aBandInfo[i].lParam = NULL; aBandInfo[i].fMask &= ~(RBBIM_TEXT | RBBIM_CHILD | RBBIM_BACKGROUND | RBBIM_LPARAM); rc.SetBandInfo(i, &aBandInfo[i]); break; } } delete [] aBandInfo; delete [] aBandIds; return TRUE; } BOOL CMFCReBarState::SaveRebarStateProc(HWND hwnd, LPARAM lParam) { // determine if this is a rebar: CWnd* pWnd = CWnd::FromHandle(hwnd); if (!pWnd->IsKindOf(RUNTIME_CLASS(CMFCReBar))) { return TRUE; } CReBarCtrl& rc = reinterpret_cast<CMFCReBar*>(pWnd)->GetReBarCtrl(); const UINT nBandInfoSize = reinterpret_cast<CMFCReBar*>(pWnd)->GetReBarBandInfoSize (); // retrieve our registry section: CString strRegSection = reinterpret_cast<LPCTSTR>(lParam); CString strRebar; strRebar.Format(AFX_REBAR_FORMAT_KEY, GetWindowLong(rc.GetSafeHwnd(), GWL_ID)); strRegSection += strRebar; CSettingsStoreSP regSP; CSettingsStore& reg = regSP.Create(FALSE, FALSE); if (!reg.CreateKey(strRegSection)) { return FALSE; } UINT nBands = rc.GetBandCount(); if (nBands == 0) { return TRUE; } #pragma warning(disable : 6211) REBARBANDINFO* aBandInfo = new REBARBANDINFO[nBands]; LONG_PTR* aBandIds = new LONG_PTR[nBands]; memset(aBandInfo, 0, nBands * nBandInfoSize); for (UINT i = 0; i < nBands; i++) { REBARBANDINFO& rbi = aBandInfo [i]; rbi.cbSize = nBandInfoSize; rbi.fMask = RBBIM_CHILD | RBBIM_ID | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE | RBBIM_STYLE | RBBIM_HEADERSIZE; rc.GetBandInfo(i, &aBandInfo[i]); // apparently fixed size bands mis-report their cxMinChildSize: rbi.cxMinChild += rbi.fStyle & RBBS_FIXEDSIZE ? 4 : 0; aBandIds[i] = (LONG_PTR)GetWindowLong(rbi.hwndChild, GWL_ID); rbi.hwndChild = 0; rbi.fMask ^= RBBIM_CHILD; } reg.Write(AFX_REBAR_KEY, reinterpret_cast<BYTE*>(aBandInfo), nBands * sizeof(REBARBANDINFO)); reg.Write(AFX_REBAR_ID_KEY, reinterpret_cast<BYTE*>(aBandIds), nBands * sizeof(LONG_PTR)); delete [] aBandIds; delete [] aBandInfo; #pragma warning(default : 6211) return TRUE; } void __stdcall CMFCReBarState::LoadState(CString& strRegKey, CFrameWnd* pFrrame) { ASSERT_VALID(pFrrame); EnumChildWindows(pFrrame->GetSafeHwnd(), LoadRebarStateProc, (LPARAM)(LPCTSTR)strRegKey); } void __stdcall CMFCReBarState::SaveState(CString& strRegKey, CFrameWnd* pFrrame) { ASSERT_VALID(pFrrame); EnumChildWindows(pFrrame->GetSafeHwnd(), SaveRebarStateProc, (LPARAM)(LPCTSTR)strRegKey); }
[ "adam.walling@gmail.com" ]
adam.walling@gmail.com
13be0704afd563de674d7eafb1d6994d376f4317
b17cbed0564263b7c0b77e467eed3983db63e9a9
/trunk/src/ProxySwitcher/MainTester/IEAdapterMFCTest.h
d10aabda628a250deb79d36e4697f09b982782ef
[]
no_license
sanco60/ProxySwitcher
b8923334782563a0a37bd95a2543808b78d01870
912ba3ee2f71a1ad6aa89b2ab90d6d6eca1364ce
refs/heads/master
2021-01-20T08:16:16.207819
2017-05-03T08:28:51
2017-05-03T08:28:51
90,124,908
0
0
null
null
null
null
UTF-8
C++
false
false
248
h
#pragma once #include "stdafx.h" #include "IEAdapterMFC.h" #include "MainTester.h" class CIEAdapterMFCTest { public: CIEAdapterMFCTest(); ~CIEAdapterMFCTest(); int run(CMainTester* tester); //CComQIPtr<IWebBrowser2> m_pWebBrowser2; };
[ "sanco60@163.com" ]
sanco60@163.com
6ec008eb21fe55f523da8c21107719f87a6c7aa4
e5a978f079c0a19f6d90f5c1b726e5868297236e
/examples/chip-tool/commands/common/Command.h
fe51dc51a929814ffd0a1b91468b91f4c4142fe4
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
sonvoque/connectedhomeip
8877e31030eabc60f6d4a141478291240558cfb5
7c173190cd9ed4f3d6918df1d9eb6fcf9fac9898
refs/heads/master
2023-01-16T05:34:47.312387
2020-11-27T06:05:26
2020-11-27T06:05:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,075
h
/* * Copyright (c) 2020 Project CHIP Authors * All rights reserved. * * 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 <controller/CHIPDeviceController_deprecated.h> #include <inet/InetInterface.h> #include <support/logging/CHIPLogging.h> #include <memory> #include <vector> class Command; template <typename T, typename... Args> std::unique_ptr<Command> make_unique(Args &&... args) { return std::unique_ptr<Command>(new T(std::forward<Args>(args)...)); } struct movable_initializer_list { movable_initializer_list(std::unique_ptr<Command> && in) : item(std::move(in)) {} operator std::unique_ptr<Command>() const && { return std::move(item); } mutable std::unique_ptr<Command> item; }; typedef std::initializer_list<movable_initializer_list> commands_list; enum ArgumentType { Number_uint8, Number_uint16, Number_uint32, Number_uint64, Number_int8, Number_int16, Number_int32, Number_int64, String, Attribute, Address }; struct Argument { const char * name; ArgumentType type; int64_t min; uint64_t max; void * value; }; class Command { public: using ChipDeviceController = ::chip::DeviceController::ChipDeviceController; using IPAddress = ::chip::Inet::IPAddress; using PacketBuffer = ::chip::System::PacketBuffer; using PacketBufferHandle = ::chip::System::PacketBufferHandle; using NodeId = ::chip::NodeId; struct AddressWithInterface { ::chip::Inet::IPAddress address; ::chip::Inet::InterfaceId interfaceId; }; Command(const char * commandName) : mName(commandName) {} virtual ~Command() {} const char * GetName(void) const { return mName; } const char * GetAttribute(void) const; const char * GetArgumentName(size_t index) const; size_t GetArgumentsCount(void) const { return mArgs.size(); } bool InitArguments(int argc, char ** argv); size_t AddArgument(const char * name, const char * value); /** * @brief * Add a string command argument * * @param name The name that will be displayed in the command help * @param value A pointer to a `char *` where the argv value will be stored * @returns The number of arguments currently added to the command */ size_t AddArgument(const char * name, char ** value); size_t AddArgument(const char * name, AddressWithInterface * out); size_t AddArgument(const char * name, int64_t min, uint64_t max, int8_t * out) { return AddArgument(name, min, max, reinterpret_cast<void *>(out), Number_int8); } size_t AddArgument(const char * name, int64_t min, uint64_t max, int16_t * out) { return AddArgument(name, min, max, reinterpret_cast<void *>(out), Number_int16); } size_t AddArgument(const char * name, int64_t min, uint64_t max, int32_t * out) { return AddArgument(name, min, max, reinterpret_cast<void *>(out), Number_int32); } size_t AddArgument(const char * name, int64_t min, uint64_t max, int64_t * out) { return AddArgument(name, min, max, reinterpret_cast<void *>(out), Number_int64); } size_t AddArgument(const char * name, int64_t min, uint64_t max, uint8_t * out) { return AddArgument(name, min, max, reinterpret_cast<void *>(out), Number_uint8); } size_t AddArgument(const char * name, int64_t min, uint64_t max, uint16_t * out) { return AddArgument(name, min, max, reinterpret_cast<void *>(out), Number_uint16); } size_t AddArgument(const char * name, int64_t min, uint64_t max, uint32_t * out) { return AddArgument(name, min, max, reinterpret_cast<void *>(out), Number_uint32); } size_t AddArgument(const char * name, int64_t min, uint64_t max, uint64_t * out) { return AddArgument(name, min, max, reinterpret_cast<void *>(out), Number_uint64); } virtual CHIP_ERROR Run(ChipDeviceController * dc, NodeId remoteId) = 0; bool GetCommandExitStatus() const { return mCommandExitStatus; } void SetCommandExitStatus(bool status) { mCommandExitStatus = status; } private: bool InitArgument(size_t argIndex, const char * argValue); size_t AddArgument(const char * name, int64_t min, uint64_t max, void * out, ArgumentType type); size_t AddArgument(const char * name, int64_t min, uint64_t max, void * out); bool mCommandExitStatus = false; const char * mName = nullptr; std::vector<Argument> mArgs; };
[ "noreply@github.com" ]
noreply@github.com
35c5ce9e765e4415baa105acaf580bc1507933ea
364d3b872c28975abbd7d472669ee43eb9c0a9fa
/Homework/Assignment 5/Gaddis_8thEd_ch.6_Prob.18_PaintJobEstimator/main.cpp
c69b504a5e354ae130285dfa16c43eb99b44c0f1
[]
no_license
dlandry1/Landry-Daniel_CIS-5_40107
853eb5266a136db2705925554c5e4b70abed19ca
7a80be18c0735aca34514b2d7b217bccb65d2023
refs/heads/master
2021-01-12T03:00:14.709978
2017-02-09T14:02:12
2017-02-09T14:02:12
78,146,330
0
0
null
null
null
null
UTF-8
C++
false
false
2,910
cpp
/* * File: main.cpp * Author: Daniel landry * Created on Feb 2, 2017, 10:07 AM * Purpose: Estimate the price for a paint job */ //System Libraries Here #include <iostream> #include <iomanip> using namespace std; //User Libraries Here //Global Constants Only, No Global Variables //Like PI, e, Gravity, or conversions //Function Prototypes Here float nRooms(); //number of rooms and sqr feet of the wall float PrcPnt(); //price of paint void Charges(float, float); //the total charges are calculate //Program Execution Begins Here int main(int argc, char** argv) { //Declare all Variables Here float TSqrFt, PPaint; //sqr ft and the price of paint //Input or initialize values Here cout<<"This program will estimate the cost of a Paint job."<<endl; //Process/Calculations Here TSqrFt= nRooms(); //square footage of each room PPaint= PrcPnt(); //price of paint Charges(TSqrFt, PPaint); //calculate the charge //Output Located Here //Exit return 0; } float nRooms(){ float sqrfeet, nRooms, Totsqft; do{ cout<<"How many rooms are to be painted?"<<endl; cout<<"(value must be at least one)"<<endl; cin>>nRooms; //number of rooms } while(nRooms<1); for (int i= 1;i<=nRooms;i++) { //square ft per room do{ cout<<"How many square feet room "<<i<<"?"<<endl; cout<<"(can not be a negative value)"<<endl; cin>>sqrfeet; //square feet of a room }while (sqrfeet<0); Totsqft+=sqrfeet; cout<<"total square feet ="<<Totsqft<<endl; } cout<<"total square feet ="<<Totsqft<<endl; return Totsqft; } //****************************************************************************** //****************************************************************************** float PrcPnt(){ float PPaint; do{ //input control cout<<"What is the price per gallon of paint?"<<endl; cout<<"(must be $10 or more)"<<endl; cin>>PPaint; } while(PPaint>=10); return PPaint; } //****************************************************************************** //****************************************************************************** void Charges(float TSqrFt,float PrcPnt){ float galn= 110; float Totgal; //total paint required float HrsLabr; //hours of labor float LCharg; //labor cost float Total; //total of all Totgal= TSqrFt/galn; HrsLabr= Totgal*8; LCharg= HrsLabr*25.00f; Total= LCharg+PrcPnt; //total of paint and labor cout<<setprecision(2)<<fixed; cout<<"The number of gallons of paint required = "<<Totgal<<" gals."<<endl; cout<<"The hours of labor required = "<<HrsLabr<<" hours."<<endl; cout<<"The cost of paint will be = $"<<PrcPnt<<endl; cout<<"The labor charge = $"<<LCharg<<endl; cout<<"Total cost = $"<<Total<<endl; }
[ "Daniel Landry" ]
Daniel Landry
47c5eddf2b11caaf4b4f7ebd5bc01ac6185bab4f
a561d1286b6b9d8dde739856c1b87cc7eba816e6
/Programming/pointers/stdafx.cpp
52b95ae1e853ba21d3d885243347437f9a0bd561
[]
no_license
Vinessa/VinessaAIEProgramming
d04f7a532c367bf071af9f4d1d2c4fef080f0db5
e7bcff30dd8a62bec450deac987a204fadc557fc
refs/heads/master
2022-11-24T07:43:24.516803
2014-04-23T19:49:44
2014-04-23T19:49:44
12,902,119
0
1
null
2022-11-21T17:22:17
2013-09-17T17:33:36
Python
UTF-8
C++
false
false
287
cpp
// stdafx.cpp : source file that includes just the standard includes // pointers.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "Vinessa.Mayer@students.aie.edu.au" ]
Vinessa.Mayer@students.aie.edu.au
4e5399ce7a02a87295fb68891668e5a2a10f4b91
a6c1139ce5989786ec86baa74e6d5b579b7be6f6
/DisCrawler/include/LayerCluster.h
e264cb696b334cb67b99928a10e96f606072a702
[]
no_license
spectrum968/dfwbi
99b35bfb39450d4bd686a9ef35b7c41ded4a59f8
5f004dd5027f17884fe6d398620019090e8c6d4c
refs/heads/master
2022-06-29T14:17:04.417249
2014-01-19T15:25:13
2014-01-19T15:25:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,155
h
#include <string> #include <map> #include <list> #include "distance.h" #ifndef __LAYERCLUSTER_H__ #define __LAYERCLUSTER_H__ class LayerCluster { private: Distance ld; std::map<int,std::list<std::string> > vatts; std::list<std::pair<int, std::list<int> > > classes; std::map<int,double> distMap; public: LayerCluster() :vatts(),classes(),distMap() { } bool AddString(std::string str,int i); bool AddString(std::list<std::string> &list,int index); bool AddString(const std::map<int,std::list<std::string> > &strs); std::list<int> GetClassID(); std::list<int> GetClassByID(int id); std::list<std::string> GetAtt(int index); int CacuCenter(std::list<int> &indexs); bool ChangeCenter(std::string dest); double CacuTDist(std::list<int> &indexs,int index); double GetClassDist(int index); double AttDist(int i,int j); bool Cluster(int dy_high,int dy_low); std::pair<int, std::list<int> > MergeClass(const std::pair<int, std::list<int> > &class1,const std::pair<int, std::list<int> > &class2); void printClass(); void printAtts(); }; #endif
[ "xiao.xf@ed9c2fc4-ad36-11dd-8324-037e16aeffe8" ]
xiao.xf@ed9c2fc4-ad36-11dd-8324-037e16aeffe8
16121a52674a9324467836cfd23dabbd3946a38f
01370e1d6d628834d00d74d6c27556ff39320410
/VirtualBox-5.0.12-Thinputer/src/VBox/Main/src-client/KeyboardImpl.cpp
f19ad004a25a6fd79038f7a1d9e71758015b3c6c
[]
no_license
stonezk/Thinputer3D_ReadBack
13ca19c0cfc05af88082321dfc524240961dca7f
09418b420e82bb7eb6ce76e066145fcf240aaec9
refs/heads/master
2021-07-14T05:31:01.057984
2017-10-13T01:26:15
2017-10-13T01:26:15
104,833,018
2
0
null
null
null
null
UTF-8
C++
false
false
12,896
cpp
/* $Id: KeyboardImpl.cpp $ */ /** @file * VirtualBox COM class implementation */ /* * Copyright (C) 2006-2014 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. */ #include "KeyboardImpl.h" #include "ConsoleImpl.h" #include "AutoCaller.h" #include "Logging.h" #include <VBox/com/array.h> #include <VBox/vmm/pdmdrv.h> #include <iprt/asm.h> #include <iprt/cpp/utils.h> // defines //////////////////////////////////////////////////////////////////////////////// // globals //////////////////////////////////////////////////////////////////////////////// /** @name Keyboard device capabilities bitfield * @{ */ enum { /** The keyboard device does not wish to receive keystrokes. */ KEYBOARD_DEVCAP_DISABLED = 0, /** The keyboard device does wishes to receive keystrokes. */ KEYBOARD_DEVCAP_ENABLED = 1 }; /** * Keyboard driver instance data. */ typedef struct DRVMAINKEYBOARD { /** Pointer to the keyboard object. */ Keyboard *pKeyboard; /** Pointer to the driver instance structure. */ PPDMDRVINS pDrvIns; /** Pointer to the keyboard port interface of the driver/device above us. */ PPDMIKEYBOARDPORT pUpPort; /** Our keyboard connector interface. */ PDMIKEYBOARDCONNECTOR IConnector; /** The capabilities of this device. */ uint32_t u32DevCaps; } DRVMAINKEYBOARD, *PDRVMAINKEYBOARD; // constructor / destructor //////////////////////////////////////////////////////////////////////////////// Keyboard::Keyboard() : mParent(NULL) { } Keyboard::~Keyboard() { } HRESULT Keyboard::FinalConstruct() { RT_ZERO(mpDrv); mpVMMDev = NULL; mfVMMDevInited = false; menmLeds = PDMKEYBLEDS_NONE; return BaseFinalConstruct(); } void Keyboard::FinalRelease() { uninit(); BaseFinalRelease(); } // public methods //////////////////////////////////////////////////////////////////////////////// /** * Initializes the keyboard object. * * @returns COM result indicator * @param parent handle of our parent object */ HRESULT Keyboard::init(Console *aParent) { LogFlowThisFunc(("aParent=%p\n", aParent)); ComAssertRet(aParent, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; unconst(mEventSource).createObject(); HRESULT rc = mEventSource->init(); AssertComRCReturnRC(rc); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; } /** * Uninitializes the instance and sets the ready flag to FALSE. * Called either from FinalRelease() or by the parent when it gets destroyed. */ void Keyboard::uninit() { LogFlowThisFunc(("\n")); /* Enclose the state transition Ready->InUninit->NotReady */ AutoUninitSpan autoUninitSpan(this); if (autoUninitSpan.uninitDone()) return; for (unsigned i = 0; i < KEYBOARD_MAX_DEVICES; ++i) { if (mpDrv[i]) mpDrv[i]->pKeyboard = NULL; mpDrv[i] = NULL; } mpVMMDev = NULL; mfVMMDevInited = true; menmLeds = PDMKEYBLEDS_NONE; unconst(mParent) = NULL; unconst(mEventSource).setNull(); } /** * Sends a scancode to the keyboard. * * @returns COM status code * @param aScancode The scancode to send */ HRESULT Keyboard::putScancode(LONG aScancode) { std::vector<LONG> scancodes; scancodes.resize(1); scancodes[0] = aScancode; return putScancodes(scancodes, NULL); } /** * Sends a list of scancodes to the keyboard. * * @returns COM status code * @param aScancodes Pointer to the first scancode * @param aCodesStored Address of variable to store the number * of scancodes that were sent to the keyboard. This value can be NULL. */ HRESULT Keyboard::putScancodes(const std::vector<LONG> &aScancodes, ULONG *aCodesStored) { AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); CHECK_CONSOLE_DRV(mpDrv[0]); /* Send input to the last enabled device. Relies on the fact that * the USB keyboard is always initialized after the PS/2 keyboard. */ PPDMIKEYBOARDPORT pUpPort = NULL; for (int i = KEYBOARD_MAX_DEVICES - 1; i >= 0 ; --i) { if (mpDrv[i] && (mpDrv[i]->u32DevCaps & KEYBOARD_DEVCAP_ENABLED)) { pUpPort = mpDrv[i]->pUpPort; break; } } /* No enabled keyboard - throw the input away. */ if (!pUpPort) { if (aCodesStored) *aCodesStored = (uint32_t)aScancodes.size(); return S_OK; } int vrc = VINF_SUCCESS; uint32_t sent; for (sent = 0; (sent < aScancodes.size()) && RT_SUCCESS(vrc); ++sent) vrc = pUpPort->pfnPutEventScan(pUpPort, (uint8_t)aScancodes[sent]); if (aCodesStored) *aCodesStored = sent; com::SafeArray<LONG> keys(aScancodes.size()); for (size_t i = 0; i < aScancodes.size(); ++i) keys[i] = aScancodes[i]; VBoxEventDesc evDesc; evDesc.init(mEventSource, VBoxEventType_OnGuestKeyboard, ComSafeArrayAsInParam(keys)); evDesc.fire(0); if (RT_FAILURE(vrc)) return setError(VBOX_E_IPRT_ERROR, tr("Could not send all scan codes to the virtual keyboard (%Rrc)"), vrc); return S_OK; } /** * Sends Control-Alt-Delete to the keyboard. This could be done otherwise * but it's so common that we'll be nice and supply a convenience API. * * @returns COM status code * */ HRESULT Keyboard::putCAD() { static std::vector<LONG> cadSequence; cadSequence.resize(8); cadSequence[0] = 0x1d; // Ctrl down cadSequence[1] = 0x38; // Alt down cadSequence[2] = 0xe0; // Del down 1 cadSequence[3] = 0x53; // Del down 2 cadSequence[4] = 0xe0; // Del up 1 cadSequence[5] = 0xd3; // Del up 2 cadSequence[6] = 0xb8; // Alt up cadSequence[7] = 0x9d; // Ctrl up return putScancodes(cadSequence, NULL); } /** * Releases all currently held keys in the virtual keyboard. * * @returns COM status code * */ HRESULT Keyboard::releaseKeys() { std::vector<LONG> scancodes; scancodes.resize(1); scancodes[0] = 0xFC; /* Magic scancode, see PS/2 and USB keyboard devices. */ return putScancodes(scancodes, NULL); } HRESULT Keyboard::getKeyboardLEDs(std::vector<KeyboardLED_T> &aKeyboardLEDs) { AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); aKeyboardLEDs.resize(0); if (menmLeds & PDMKEYBLEDS_NUMLOCK) aKeyboardLEDs.push_back(KeyboardLED_NumLock); if (menmLeds & PDMKEYBLEDS_CAPSLOCK) aKeyboardLEDs.push_back(KeyboardLED_CapsLock); if (menmLeds & PDMKEYBLEDS_SCROLLLOCK) aKeyboardLEDs.push_back(KeyboardLED_ScrollLock); return S_OK; } HRESULT Keyboard::getEventSource(ComPtr<IEventSource> &aEventSource) { // No need to lock - lifetime constant mEventSource.queryInterfaceTo(aEventSource.asOutParam()); return S_OK; } // // private methods // void Keyboard::onKeyboardLedsChange(PDMKEYBLEDS enmLeds) { AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Save the current status. */ menmLeds = enmLeds; alock.release(); i_getParent()->i_onKeyboardLedsChange(RT_BOOL(enmLeds & PDMKEYBLEDS_NUMLOCK), RT_BOOL(enmLeds & PDMKEYBLEDS_CAPSLOCK), RT_BOOL(enmLeds & PDMKEYBLEDS_SCROLLLOCK)); } DECLCALLBACK(void) Keyboard::i_keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds) { PDRVMAINKEYBOARD pDrv = RT_FROM_MEMBER(pInterface, DRVMAINKEYBOARD, IConnector); pDrv->pKeyboard->onKeyboardLedsChange(enmLeds); } /** * @interface_method_impl{PDMIKEYBOARDCONNECTOR,pfnSetActive} */ DECLCALLBACK(void) Keyboard::i_keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive) { PDRVMAINKEYBOARD pDrv = RT_FROM_MEMBER(pInterface, DRVMAINKEYBOARD, IConnector); if (fActive) pDrv->u32DevCaps |= KEYBOARD_DEVCAP_ENABLED; else pDrv->u32DevCaps &= ~KEYBOARD_DEVCAP_ENABLED; } /** * @interface_method_impl{PDMIBASE,pfnQueryInterface} */ DECLCALLBACK(void *) Keyboard::i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID) { PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); PDRVMAINKEYBOARD pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINKEYBOARD); PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); PDMIBASE_RETURN_INTERFACE(pszIID, PDMIKEYBOARDCONNECTOR, &pDrv->IConnector); return NULL; } /** * Destruct a keyboard driver instance. * * @returns VBox status code. * @param pDrvIns The driver instance data. */ DECLCALLBACK(void) Keyboard::i_drvDestruct(PPDMDRVINS pDrvIns) { PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); PDRVMAINKEYBOARD pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINKEYBOARD); LogFlow(("Keyboard::drvDestruct: iInstance=%d\n", pDrvIns->iInstance)); if (pThis->pKeyboard) { AutoWriteLock kbdLock(pThis->pKeyboard COMMA_LOCKVAL_SRC_POS); for (unsigned cDev = 0; cDev < KEYBOARD_MAX_DEVICES; ++cDev) if (pThis->pKeyboard->mpDrv[cDev] == pThis) { pThis->pKeyboard->mpDrv[cDev] = NULL; break; } pThis->pKeyboard->mpVMMDev = NULL; } } /** * Construct a keyboard driver instance. * * @copydoc FNPDMDRVCONSTRUCT */ DECLCALLBACK(int) Keyboard::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags) { PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); PDRVMAINKEYBOARD pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINKEYBOARD); LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance)); /* * Validate configuration. */ if (!CFGMR3AreValuesValid(pCfg, "Object\0")) return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES; AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER, ("Configuration error: Not possible to attach anything to this driver!\n"), VERR_PDM_DRVINS_NO_ATTACH); /* * IBase. */ pDrvIns->IBase.pfnQueryInterface = Keyboard::i_drvQueryInterface; pThis->IConnector.pfnLedStatusChange = i_keyboardLedStatusChange; pThis->IConnector.pfnSetActive = Keyboard::i_keyboardSetActive; /* * Get the IKeyboardPort interface of the above driver/device. */ pThis->pUpPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIKEYBOARDPORT); if (!pThis->pUpPort) { AssertMsgFailed(("Configuration error: No keyboard port interface above!\n")); return VERR_PDM_MISSING_INTERFACE_ABOVE; } /* * Get the Keyboard object pointer and update the mpDrv member. */ void *pv; int rc = CFGMR3QueryPtr(pCfg, "Object", &pv); if (RT_FAILURE(rc)) { AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc)); return rc; } pThis->pKeyboard = (Keyboard *)pv; /** @todo Check this cast! */ unsigned cDev; for (cDev = 0; cDev < KEYBOARD_MAX_DEVICES; ++cDev) if (!pThis->pKeyboard->mpDrv[cDev]) { pThis->pKeyboard->mpDrv[cDev] = pThis; break; } if (cDev == KEYBOARD_MAX_DEVICES) return VERR_NO_MORE_HANDLES; return VINF_SUCCESS; } /** * Keyboard driver registration record. */ const PDMDRVREG Keyboard::DrvReg = { /* u32Version */ PDM_DRVREG_VERSION, /* szName */ "MainKeyboard", /* szRCMod */ "", /* szR0Mod */ "", /* pszDescription */ "Main keyboard driver (Main as in the API).", /* fFlags */ PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT, /* fClass. */ PDM_DRVREG_CLASS_KEYBOARD, /* cMaxInstances */ ~0U, /* cbInstance */ sizeof(DRVMAINKEYBOARD), /* pfnConstruct */ Keyboard::i_drvConstruct, /* pfnDestruct */ Keyboard::i_drvDestruct, /* pfnRelocate */ NULL, /* pfnIOCtl */ NULL, /* pfnPowerOn */ NULL, /* pfnReset */ NULL, /* pfnSuspend */ NULL, /* pfnResume */ NULL, /* pfnAttach */ NULL, /* pfnDetach */ NULL, /* pfnPowerOff */ NULL, /* pfnSoftReset */ NULL, /* u32EndVersion */ PDM_DRVREG_VERSION }; /* vi: set tabstop=4 shiftwidth=4 expandtab: */
[ "zhengke_stone@foxmail.com" ]
zhengke_stone@foxmail.com
44e83308244088dae58a1ef3cb6e5384f9323cb4
7be64827a77f2fabf87106fa9b69928db51d4486
/List.h
db36918c9c8ff2918d9dcf888ca760b26a439393
[]
no_license
odganzorig/List_lab
63bd3f80dbcbd0e3dc2d01c107e0ec98c27f3fab
c62f93a05f7a5d6e89a08cf402703075df70f94f
refs/heads/master
2020-04-01T12:10:14.787070
2018-10-15T23:30:38
2018-10-15T23:30:38
153,194,528
0
0
null
null
null
null
UTF-8
C++
false
false
5,371
h
/* * List.h * Header file for CS 223, Lab 4 * Created by: Barb Wahl, 2-15-16 * Revised 2-18-18 * List is a circular, doubly-linked list with sentinel node. */ #ifndef List_H_DLL #define List_H_DLL #include "DLL_node.h" // which already includes Person.h namespace cs223_dll { class List { public: // ***** Basic Member Functions ***** // default constructor // Postcondition: the list has no items (just a sentinel node) List(); // destructor - test it indirectly by checking for memory leaks ~List(); // is_empty - checks if the list is empty // Postcondition: Returns true iff there are no items in the list. bool is_empty() const; // clear - deletes all items from the list // Postcondition: List is empty. void clear(); // front - get the value at the front of the list // Precondition: This list is not empty. // Postcondition: Return value is a copy of the value stored at // the front of the list. DLL_node::value_type front() const; // back - get the value at the end of the list // Precondition: This list is not empty. // Postcondition: Return value is a copy of the value stored at // the back of the list. DLL_node::value_type back() const; // head_insert - add an item to the front of the list // Postcondition: The list has one more node than before, and the // value `val` is stored at the front of the list. // EXAMPLE: If the list had items: <r, o, n, t>, and then the call was // to head_insert('f'), the list now has items: <f, r, o, n, t> void head_insert(DLL_node::value_type val); // tail_insert - add an item to the end of the list // Postcondition: The list has one more node than before, and the // value `val` is stored at the end of the list. // EXAMPLE: If the list had items: <p, i, g>, and then the call was // to tail_insert('g'), the list now has items: <p, i, g, g> void tail_insert(DLL_node::value_type val); // ***** Other Member Functions ***** // head_remove - remove an item from the front of the list // Postcondition: Return value is `true` iff an item was removed. // If the list was empty before head_remove(), return value is // `false`. // EXAMPLE: If the list had items <f, r, o, g> before the call to // head_remove(), after the call the list has: <r, o, g> bool head_remove(); // tail_remove - remove an item from the end of the list // Postcondition: Return value is `true` iff an item was removed. // If the list was empty before tail_remove(), return value is // `false`. // EXAMPLE: If the list had items <c, a, t, s> before the call to // tail_remove(), after the call the list has: <c, a, t> bool tail_remove(); // contains - checks for an item in the list // Postcondition: Returns true iff there is an item equivalent to // `val` in this list. bool contains(DLL_node::value_type val) const; // remove_first_of - tries to remove the first instance of an item // from the list // Postcondition: Removes the front-most item in the list that is // equivalent (==) to the given value `val`. Return value is // true iff an item was removed from the list. // NOTE: If no item in the list is equivalent to `val`, the list // is unchanged and `false` is returned. // EXAMPLE: The list has items: <2, 9, 2>. A call to // remove_first_of('2') will return true, and the list items // are now: <9, 2> bool remove_first_of(DLL_node::value_type val); // ***** Copy Constructor and Assignment Operator ***** // copy constructor // Postcondition: The new list is an independent copy of `other`. // Subsequent changes to one of the lists will *not* affect the // other list. List(const List &other); // assignment operator // Postcondition: This list becomes an identical -- but indepedent -- // copy of `other` list. // NOTE: Returns the updated list to enable chaining of assignment. List& operator=(const List &other); // bracket-indexing operator, operator[] // Precondition: i >= 0 // Precondition: the list has more than i items // Postcondition: returns the ith item in the list, where indexing begins // with 0 // EXAMPLE: If myList is <D, O, G>, then myList[0] returns 'D', // myList[1] returns 'O', and myList[2] returns 'G'. DLL_node::value_type operator[](int i); // FRIEND FUNCTIONS friend std::ostream& operator <<(std::ostream& out, const List& list); private: DLL_node * head_ptr; // pointer to sentinel node }; // stream output operator - implementation provided // Postcondition: For lists with length > 0, contents of the list are placed // into the given // output stream using the following format: // "List:\nfirst_item\n...\nlast_item\n" // For lists of length = 0, the following will be placed into the // given output stream: // "Empty List\n" // EXAMPLE: If myList is <rain, grass, flowers>, then cout << myList will // produce the following in standard out: // List: // rain // grass // flowers std::ostream& operator <<(std::ostream& out, const List& list); } // namespace cs223_dll #endif
[ "od.ganzorig12@gmail.com" ]
od.ganzorig12@gmail.com
3303c6465fb38defdb6bf293525011cdefec53a3
24f34da81ca2c04055351a78b847d9b594f8a4d8
/others/RFID.ino
867d8115137be6563d5ce1daecaef81d9f5b451a
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
trienagarcia/iics-attendance-monitoring-sysytem
058c191457e1345e341ba802001d5eb74b65868d
67b49ee8622632c1a012cdcf4be1270603ab40ce
refs/heads/master
2022-07-19T00:58:47.862157
2020-05-28T17:51:25
2020-05-28T17:51:25
262,586,383
0
0
null
null
null
null
UTF-8
C++
false
false
1,102
ino
#include <MFRC522.h> #include <SPI.h> int RST_PIN = 9; int SS_PIN = 10; MFRC522 mfrc522(SS_PIN, RST_PIN); MFRC522::MIFARE_Key key; const int maximum = 5; byte RFID_CARDID[maximum] = {202,235,239,210,115}; String RFID_USER[maximum] = {"WHITE","BLUE","JULI","JAR","IGNA"}; void setup() { Serial.begin(9600); SPI.begin(); mfrc522.PCD_Init(); } void loop() { // Serial.println("Hello world"); if(!mfrc522.PICC_IsNewCardPresent()) return; if(!mfrc522.PICC_ReadCardSerial()) return; dump(mfrc522.uid.uidByte, mfrc522.uid.size); delay(1000); } void dump(byte *buffer, byte bufferSize) { byte total = 0; //print UID // Serial.print("Card UID: "); for(byte i = 0; i < bufferSize; i++) Serial.print(buffer[i], HEX); Serial.println(); //print USERNAME // Serial.print("Username: "); // // for(byte i = 0; i < bufferSize; i++) // total += buffer[i]; // // for(int i = 0; i < maximum; i++) // if(total == RFID_CARDID[i]) // Serial.println(RFID_USER[i]); // // Serial.println(); } // white A7 C1 10 52 // blue C6 79 B4 F8
[ "jansenmarsonang@gmail.com" ]
jansenmarsonang@gmail.com
b1ee8909386a44a45e68ff3643e4c3e99b84533f
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/inetsrv/iis/svcs/smtp/adminsso/dl.cpp
11fc868301488b3fb506b85bce9a2f55528f5132
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
9,052
cpp
// dl.cpp : Implementation of CsmtpadmApp and DLL registration. #include "stdafx.h" #include "smtpadm.h" #include "dl.h" #include "oleutil.h" #include "smtpapi.h" #include <lmapibuf.h> #include "smtpcmn.h" // Must define THIS_FILE_* macros to use SmtpCreateException() #define THIS_FILE_HELP_CONTEXT 0 #define THIS_FILE_PROG_ID _T("Smtpadm.DL.1") #define THIS_FILE_IID IID_ISmtpAdminDL #define DEFAULT_NEWSGROUP_NAME _T("") #define DEFAULT_NEWSGROUP_DESCRIPTION _T("") #define DEFAULT_NEWSGROUP_MODERATOR _T("") #define DEFAULT_NEWSGROUP_READONLY FALSE ///////////////////////////////////////////////////////////////////////////// // // // Use a macro to define all the default methods // DECLARE_METHOD_IMPLEMENTATION_FOR_STANDARD_EXTENSION_INTERFACES(SmtpAdminDL, CSmtpAdminDL, IID_ISmtpAdminDL) STDMETHODIMP CSmtpAdminDL::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = { &IID_ISmtpAdminDL, }; for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++) { if (InlineIsEqualGUID(*arr[i],riid)) return S_OK; } return S_FALSE; } CSmtpAdminDL::CSmtpAdminDL () // CComBSTR's are initialized to NULL by default. { m_pSmtpNameList = NULL; m_lType = NAME_TYPE_LIST_NORMAL; m_lCount = 0; m_lMemberType = NAME_TYPE_USER; m_iadsImpl.SetService ( MD_SERVICE_NAME ); m_iadsImpl.SetName ( _T("DL") ); m_iadsImpl.SetClass ( _T("IIsSmtpDL") ); } CSmtpAdminDL::~CSmtpAdminDL () { if ( m_pSmtpNameList ) { ::NetApiBufferFree ( m_pSmtpNameList ); m_pSmtpNameList = NULL; } // All CComBSTR's are freed automatically. } ////////////////////////////////////////////////////////////////////// // Properties: ////////////////////////////////////////////////////////////////////// // // IADs methods: // DECLARE_SIMPLE_IADS_IMPLEMENTATION(CSmtpAdminDL,m_iadsImpl) // DL property STDMETHODIMP CSmtpAdminDL::get_DLName ( BSTR * pstrDLName ) { return StdPropertyGet ( m_strDLName, pstrDLName ); } STDMETHODIMP CSmtpAdminDL::put_DLName ( BSTR strDLName ) { return StdPropertyPut ( &m_strDLName, strDLName ); } STDMETHODIMP CSmtpAdminDL::get_Domain ( BSTR * pstrDomain ) { return StdPropertyGet ( m_strDomain, pstrDomain ); } STDMETHODIMP CSmtpAdminDL::put_Domain ( BSTR strDomain ) { return StdPropertyPut ( &m_strDomain, strDomain ); } STDMETHODIMP CSmtpAdminDL::get_Type ( long * plType ) { return StdPropertyGet ( m_lType, plType ); } STDMETHODIMP CSmtpAdminDL::put_Type ( long lType ) { return StdPropertyPut ( &m_lType, lType ); } STDMETHODIMP CSmtpAdminDL::get_MemberName ( BSTR * pstrMemberName ) { return StdPropertyGet ( m_strMemberName, pstrMemberName ); } STDMETHODIMP CSmtpAdminDL::put_MemberName ( BSTR strMemberName ) { return StdPropertyPut ( &m_strMemberName, strMemberName ); } STDMETHODIMP CSmtpAdminDL::get_MemberDomain ( BSTR * pstrMemberDomain ) { return StdPropertyGet ( m_strMemberDomain, pstrMemberDomain ); } STDMETHODIMP CSmtpAdminDL::put_MemberDomain ( BSTR strMemberDomain ) { return StdPropertyPut ( &m_strMemberDomain, strMemberDomain ); } STDMETHODIMP CSmtpAdminDL::get_MemberType( long * plMemberType ) { return StdPropertyGet ( m_lMemberType, plMemberType ); } // enumeration STDMETHODIMP CSmtpAdminDL::get_Count ( long * plCount ) { return StdPropertyGet ( m_lCount, plCount ); } ////////////////////////////////////////////////////////////////////// // Methods: ////////////////////////////////////////////////////////////////////// STDMETHODIMP CSmtpAdminDL::Create ( ) { TraceFunctEnter ( "CSmtpAdminDL::Create" ); HRESULT hr = NOERROR; DWORD dwErr = NOERROR; if( !m_strDLName || !m_strDomain ) { hr = SmtpCreateException ( IDS_SMTPEXCEPTION_INVALID_ADDRESS ); goto Exit; } WCHAR szFullName[512]; wsprintfW( szFullName, L"%s@%s", (LPWSTR) m_strDLName, (LPWSTR) m_strDomain ); dwErr = SmtpCreateDistList( m_iadsImpl.QueryComputer(), szFullName, m_lType, m_iadsImpl.QueryInstance() ); if ( dwErr != NOERROR ) { ErrorTrace ( (LPARAM) this, "Failed to create DL: %x", dwErr ); hr = SmtpCreateExceptionFromWin32Error ( dwErr ); goto Exit; } Exit: TraceFunctLeave (); return hr; } STDMETHODIMP CSmtpAdminDL::Delete ( ) { TraceFunctEnter ( "CSmtpAdminDL::Delete" ); HRESULT hr = NOERROR; DWORD dwErr = NOERROR; if( !m_strDLName || !m_strDomain ) { hr = SmtpCreateException ( IDS_SMTPEXCEPTION_INVALID_ADDRESS ); goto Exit; } WCHAR szFullName[512]; wsprintfW( szFullName, L"%s@%s", (LPWSTR) m_strDLName, (LPWSTR) m_strDomain ); dwErr = SmtpDeleteDistList( m_iadsImpl.QueryComputer(), szFullName, m_iadsImpl.QueryInstance() ); if ( dwErr != NOERROR ) { ErrorTrace ( (LPARAM) this, "Failed to delete DL: %x", dwErr ); hr = SmtpCreateExceptionFromWin32Error ( dwErr ); goto Exit; } Exit: TraceFunctLeave (); return hr; } STDMETHODIMP CSmtpAdminDL::AddMember ( ) { TraceFunctEnter ( "CSmtpAdminDL::AddMember" ); HRESULT hr = NOERROR; DWORD dwErr = NOERROR; if( !m_strDLName || !m_strDomain || !m_strMemberName || !m_strMemberDomain ) { hr = SmtpCreateException ( IDS_SMTPEXCEPTION_INVALID_ADDRESS ); goto Exit; } WCHAR szFullDLName[512]; WCHAR szFullMemName[512]; wsprintfW( szFullDLName, L"%s@%s", (LPWSTR) m_strDLName, (LPWSTR) m_strDomain ); wsprintfW( szFullMemName, L"%s@%s", (LPWSTR) m_strMemberName, (LPWSTR) m_strMemberDomain ); dwErr = SmtpCreateDistListMember( m_iadsImpl.QueryComputer(), szFullDLName, szFullMemName, m_iadsImpl.QueryInstance() ); if ( dwErr != NOERROR ) { ErrorTrace ( (LPARAM) this, "Failed to add DL member: %x", dwErr ); hr = SmtpCreateExceptionFromWin32Error ( dwErr ); goto Exit; } Exit: TraceFunctLeave (); return hr; } STDMETHODIMP CSmtpAdminDL::RemoveMember ( ) { TraceFunctEnter ( "CSmtpAdminDL::RemoveMember" ); HRESULT hr = NOERROR; DWORD dwErr = NOERROR; if( !m_strDLName || !m_strDomain || !m_strMemberName || !m_strMemberDomain ) { hr = SmtpCreateException ( IDS_SMTPEXCEPTION_INVALID_ADDRESS ); goto Exit; } WCHAR szFullDLName[512]; WCHAR szFullMemName[512]; wsprintfW( szFullDLName, L"%s@%s", (LPWSTR) m_strDLName, (LPWSTR) m_strDomain ); wsprintfW( szFullMemName, L"%s@%s", (LPWSTR) m_strMemberName, (LPWSTR) m_strMemberDomain ); dwErr = SmtpDeleteDistListMember( m_iadsImpl.QueryComputer(), szFullDLName, szFullMemName, m_iadsImpl.QueryInstance() ); if ( dwErr != NOERROR ) { ErrorTrace ( (LPARAM) this, "Failed to remove DL member: %x", dwErr ); hr = SmtpCreateExceptionFromWin32Error ( dwErr ); goto Exit; } Exit: TraceFunctLeave (); return hr; } STDMETHODIMP CSmtpAdminDL::FindMembers( BSTR strWildmat, long cMaxResults ) { TraceFunctEnter ( "CSmtpAdminDL::FindMembers" ); HRESULT hr = NOERROR; DWORD dwErr = NOERROR; if( !m_strDLName || !m_strDomain ) { hr = SmtpCreateException ( IDS_SMTPEXCEPTION_INVALID_ADDRESS ); goto Exit; } // Free the old name list: if ( m_pSmtpNameList ) { ::NetApiBufferFree ( m_pSmtpNameList ); m_pSmtpNameList = NULL; } m_lCount = 0; WCHAR szFullDLName[512]; wsprintfW( szFullDLName, L"%s@%s", (LPWSTR) m_strDLName, (LPWSTR) m_strDomain ); dwErr = SmtpGetNameListFromList ( m_iadsImpl.QueryComputer(), szFullDLName, strWildmat, NAME_TYPE_ALL, cMaxResults, TRUE, &m_pSmtpNameList, m_iadsImpl.QueryInstance()); if ( dwErr != 0 ) { ErrorTraceX ( (LPARAM) this, "Failed to find alias: %x", dwErr ); SetLastError( dwErr ); hr = SmtpCreateExceptionFromWin32Error ( dwErr ); goto Exit; } m_lCount = m_pSmtpNameList->cEntries; Exit: TraceFunctLeave (); return hr; } STDMETHODIMP CSmtpAdminDL::GetNthMember ( long lIndex ) { TraceFunctEnter ( "CSmtpAdminDL::GetNthMember" ); WCHAR* pchStartOfDomain = NULL; WCHAR* p = NULL; LPSMTP_NAME_ENTRY pNameEntry; if( !m_pSmtpNameList ) { return SmtpCreateException (IDS_SMTPEXCEPTION_DIDNT_ENUMERATE); } if( lIndex < 0 || lIndex >= m_lCount ) { return SmtpCreateException (IDS_SMTPEXCEPTION_INVALID_INDEX); } //_ASSERT( CAddr::ValidateEmailName(m_pSmtpNameList[lIndex].lpszName) ); pNameEntry = &m_pSmtpNameList->aNameEntry[lIndex]; p = pNameEntry->lpszName; while( *p && *p != '@' ) p++; _ASSERT( *p ); if( !*p ) { return SmtpCreateException (IDS_SMTPEXCEPTION_INVALID_ADDRESS); } pchStartOfDomain = p+1; m_lMemberType = pNameEntry->dwType; m_strMemberDomain = (LPCWSTR) pchStartOfDomain; *(pchStartOfDomain-1) = '\0'; m_strMemberName = pNameEntry->lpszName; // converted to UNICODE *(pchStartOfDomain-1) = '@'; // turn it back return NOERROR; }
[ "seta7D5@protonmail.com" ]
seta7D5@protonmail.com
40ed675a70bf12896ec10fa09608dd3354e342fe
91fad1a1d4cbd82dec5836895ef282e8b55d9c61
/visualtestdebug.hpp
177dab6fa2443641a614b9ffbe20d887c4d4a68c
[]
no_license
RichardTang75/hpa
a52541068138b5bcf04b8a7f043d1a771ba0e4cf
5ec15770e9502d10ffdebe8ac192c71d2782fc11
refs/heads/update
2021-09-17T22:17:09.710598
2018-07-06T02:01:12
2018-07-06T02:01:12
100,321,048
0
0
null
2018-01-21T02:24:04
2017-08-15T00:28:40
C++
UTF-8
C++
false
false
301
hpp
// // visualtestdebug.hpp // take2 // // Created by asdfuiop on 5/28/18. // Copyright © 2018 asdfuiop. All rights reserved. // #ifndef visualtestdebug_hpp #define visualtestdebug_hpp void checkthis(vectormap& in, int map_x, int map_y, int rows, int cols); #endif /* visualtestdebug_hpp */
[ "richardtang75@gmail.com" ]
richardtang75@gmail.com
1a53aa9e70ab81c663c337c5a4368daa3a8b9190
3e644fa536a60c449ed44c674ec437c10d4e74bf
/Foundation/ConfigAPI.h
f76bf2f17c6b9a51d56304f36ee93f41bd6ed257
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jarmovh/naali
3a29a2baff715637a0986ed56d3f6e433772f9e2
bcbd92499cdbb6e891774a4694a150bf06499e22
refs/heads/master
2021-01-09T05:40:50.550403
2011-08-12T05:42:22
2011-08-12T05:42:22
1,462,841
0
0
null
null
null
null
UTF-8
C++
false
false
5,729
h
// For conditions of distribution and use, see copyright notice in license.txt #ifndef incl_Foundation_ConfigAPI_h #define incl_Foundation_ConfigAPI_h #include <QObject> #include <QVariant> #include <QString> namespace Foundation { class Framework; } /*! \brief Configuration API for getting and setting config values. \details Configuration API for getting and setting config values. Utilizing the ini file format and QSettings class. The API will return QVariant values and the user will have to know what type the value is and use the extensive QVariants::to*() functions to get the correct type. The Config API supports ini sections but you may also write to the root of the ini document without a section. This class is kept simple and easy to use and designed to be script language friendly. The API is registered to 'config' dynamic property. JavaScript example on usage: \code var file = "myconfig"; config.Set(file, "world", new QUrl("http://server.com")); // QUrl config.Set(file, "port", 8013); // int config.Set(file, "login data", "username", "John Doe"); // QString config.Set(file, "login data", "password", "pass123"); // QString var username = config.Get(file, "login data", "username"); if (username != null) print("Hello there", username); etc. \endcode \note QSettings/QVariant and JavaScript booleans don't mix up too well. It will give you a string back of the config value. This is problematic because new Boolean("false") in JavaScript returns a true boolean. The current work around would be to set config booleans as JavaScript booleans, but when reading one from config always expect it to be "true", "false" or null if the key could not be located. Then do checks of the string value and set a proper JavaScript boolean to your boolean var. \note All file, key and section parameters are case insensitive. This means all of them are transformed to lower case before any accessing files. "MyKey" will get and set you same value as "mykey". */ class ConfigAPI : public QObject { Q_OBJECT public slots: //! Check if a config has a value for section/key. /// \param file QString. Name of the file. For example: "foundation" or "foundation.ini" you can omit the .ini extension. /// \param key QString. Key that value gets returned. For example: "username". /// \return bool True if value exists in section/key of file, false otherwise. bool HasValue(const QString &file, QString key); //! Check if a config has a value for section/key. /// \param file QString. Name of the file. For example: "foundation" or "foundation.ini" you can omit the .ini extension. /// \param section QString. The section in the config where key is. For example: "login". /// \param key QString. Key that value gets returned. For example: "username". /// \return bool True if value exists in section/key of file, false otherwise. bool HasValue(const QString &file, const QString &section, QString key); //! Gets a value of key from a config file /// \param file QString. Name of the file. For example: "foundation" or "foundation.ini" you can omit the .ini extension. /// \param key QString. Key that value gets returned. For example: "username". /// \return QVariant The value of key in file. QVariant Get(const QString &file, const QString &key); //! Gets a value of key from a config file /// \param file QString. Name of the file. For example: "foundation" or "foundation.ini" you can omit the .ini extension. /// \param section QString. The section in the config where key is. For example: "login". /// \param key QString. Key that value gets returned. For example: "username". /// \return QVariant The value of key in file. QVariant Get(const QString &file, const QString &section, const QString &key); //! Sets the value of key in a config file. /// \param file QString. Name of the file. For example: "foundation" or "foundation.ini" you can omit the .ini extension. /// \param key QString. Key that value gets returned. For example: "username". /// \param value QVariant. New Value of key in file. void Set(const QString &file, const QString &key, const QVariant &value); //! Sets the value of key in a config file. /// \param file QString. Name of the file. For example: "foundation" or "foundation.ini" you can omit the .ini extension. /// \param section QString. The section in the config where key is. For example: "login". /// \param key QString. Key that value gets returned. For example: "username". /// \param value QVariant. New Value of key in file. void Set(const QString &file, const QString &section, const QString &key, const QVariant &value); //! Gets the absolute path to the config folder where configs are stored. Guaranteed to have a trailing forward slash '/'. /// \return QString. Absolute path to config storage folder. QString GetConfigFolder() const { return configFolder_; } private slots: //! Get absolute file path for file. Guarantees that it ends with .ini. QString GetFilePath(const QString &file); private: Q_DISABLE_COPY(ConfigAPI) friend class Foundation::Framework; //! Constructs the Config API. /// \param framework Framework. Takes ownership of the object. /// \param configFolder QString. Tells the config api where to store config files. ConfigAPI(Foundation::Framework *framework, const QString &configFolder); //! Framework ptr. Foundation::Framework *framework_; //! Absolute path to the folder where to store the config files. QString configFolder_; }; #endif
[ "jonne.nauha@evocativi.com" ]
jonne.nauha@evocativi.com
fedac6f2e73a96de09dbd5c1df196fc176da92d9
afe10b84e7285afcff588e45067e2958fda0961f
/Arduino/기초/led3_Test/led3_Test.ino
0390db684df536e27e58cffe52e512c0b9498e34
[]
no_license
pnko/program
ae903f4a461b6a0d22c542fb66d1201dfb469cbc
8da0427eada7065599db78d41ce93a9180ffd622
refs/heads/master
2021-01-19T12:24:13.370781
2018-06-15T08:37:21
2018-06-15T08:37:21
82,310,526
1
0
null
null
null
null
UTF-8
C++
false
false
808
ino
#define RED 11 #define GREEN 10 #define BLUE 9 #define RED_BUTTON 4 #define GREEN_BUTTON 3 #define BLUE_BUTTON 2 int r = 0, g = 0, b = 0 ; void setup() { // put your setup code here, to run once: // randomSeed(analogRead(0)); Serial.begin(9600); pinMode(RED_BUTTON, INPUT); pinMode(GREEN_BUTTON, INPUT); pinMode(BLUE_BUTTON, INPUT); } void loop() { // put your main code here, to run repeatedly: if (digitalRead(RED_BUTTON) == HIGH) { ++r; if (r > 255) { r = 0; } } if (digitalRead(GREEN_BUTTON) == HIGH) { ++g; if (g > 255) { g = 0; } } if (digitalRead(BLUE_BUTTON) == HIGH) { ++b; if (b > 255) { b = 0; } } analogWrite(RED, r); analogWrite(GREEN, g); analogWrite(BLUE, b); delay(10); Serial.println("r:" + r); }
[ "kim@kimui-MacBook-Pro.local" ]
kim@kimui-MacBook-Pro.local
cada699c6ad84175037101820828ac8d1dfa6ee3
8947812c9c0be1f0bb6c30d1bb225d4d6aafb488
/02_Library/Include/XMCocos2D-v3/scripting/javascript/bindings/js_manual_conversions.h
2148eca252ea167aca2f11ca81ae2e07448550fb
[ "MIT" ]
permissive
alissastanderwick/OpenKODE-Framework
cbb298974e7464d736a21b760c22721281b9c7ec
d4382d781da7f488a0e7667362a89e8e389468dd
refs/heads/master
2021-10-25T01:33:37.821493
2016-07-12T01:29:35
2016-07-12T01:29:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,144
h
// // Created by Rohan Kuruvilla // Copyright (c) 2012 Zynga Inc. All rights reserved. // #ifndef __JS_MANUAL_CONVERSIONS_H__ #define __JS_MANUAL_CONVERSIONS_H__ #include "XMJs/jsapi.h" #include "js_bindings_core.h" #include "cocos2d.h" extern JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **out ); extern JSBool jsval_to_int( JSContext *cx, jsval vp, int *out); extern JSBool jsval_to_uint( JSContext *cx, jsval vp, unsigned int *out); extern JSBool jsval_to_long( JSContext *cx, jsval vp, long *out); extern JSBool jsval_to_c_class( JSContext *cx, jsval vp, void **out_native, struct jsb_c_proxy_s **out_proxy); /** converts a jsval (JS string) into a char */ extern JSBool jsval_to_charptr( JSContext *cx, jsval vp, const char **out); extern jsval opaque_to_jsval( JSContext *cx, void* opaque); extern jsval c_class_to_jsval( JSContext *cx, void* handle, JSObject* object, JSClass *klass, const char* class_name); extern jsval long_to_jsval( JSContext *cx, long number ); extern jsval longlong_to_jsval( JSContext *cx, long long number ); /* Converts a char ptr into a jsval (using JS string) */ extern jsval charptr_to_jsval( JSContext *cx, const char *str); extern JSBool JSB_jsval_typedarray_to_dataptr( JSContext *cx, jsval vp, GLsizei *count, void **data, JSArrayBufferViewType t); extern JSBool JSB_get_arraybufferview_dataptr( JSContext *cx, jsval vp, GLsizei *count, GLvoid **data ); // some utility functions // to native JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *ret ); JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *ret ); JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *ret ); JSBool jsval_to_long_long(JSContext *cx, jsval v, long long* ret); JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret); JSBool jsval_to_ccpoint(JSContext *cx, jsval v, cocos2d::Point* ret); JSBool jsval_to_ccrect(JSContext *cx, jsval v, cocos2d::Rect* ret); JSBool jsval_to_ccsize(JSContext *cx, jsval v, cocos2d::Size* ret); JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, cocos2d::Color4B* ret); JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, cocos2d::Color4F* ret); JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, cocos2d::Color3B* ret); JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, cocos2d::Point **points, int *numPoints); JSBool jsval_to_ccarray(JSContext* cx, jsval v, cocos2d::Array** ret); JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, cocos2d::Dictionary** ret); JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, cocos2d::Acceleration* ret); JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, cocos2d::Array** ret); JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, cocos2d::AffineTransform* ret); JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, cocos2d::FontDefinition* ret ); // from native jsval int32_to_jsval( JSContext *cx, int32_t l); jsval uint32_to_jsval( JSContext *cx, uint32_t number ); jsval long_long_to_jsval(JSContext* cx, long long v); jsval std_string_to_jsval(JSContext* cx, const std::string& v); jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length = -1); jsval ccpoint_to_jsval(JSContext* cx, const cocos2d::Point& v); jsval ccrect_to_jsval(JSContext* cx, const cocos2d::Rect& v); jsval ccsize_to_jsval(JSContext* cx, const cocos2d::Size& v); jsval cccolor4b_to_jsval(JSContext* cx, const cocos2d::Color4B& v); jsval cccolor4f_to_jsval(JSContext* cx, const cocos2d::Color4F& v); jsval cccolor3b_to_jsval(JSContext* cx, const cocos2d::Color3B& v); jsval ccdictionary_to_jsval(JSContext* cx, cocos2d::Dictionary *dict); jsval ccarray_to_jsval(JSContext* cx, cocos2d::Array *arr); jsval ccacceleration_to_jsval(JSContext* cx, const cocos2d::Acceleration& v); jsval ccaffinetransform_to_jsval(JSContext* cx, const cocos2d::AffineTransform& t); jsval FontDefinition_to_jsval(JSContext* cx, const cocos2d::FontDefinition& t); JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *out ); jsval CGPoint_to_jsval( JSContext *cx, cpVect p ); #define cpVect_to_jsval CGPoint_to_jsval #define jsval_to_cpVect jsval_to_CGPoint #endif /* __JS_MANUAL_CONVERSIONS_H__ */
[ "mcodegeeks@gmail.com" ]
mcodegeeks@gmail.com
cfd45402d72c9fb86e0c3950ddc17fcfcbbfecd3
2c06dc415a2bde572c15cd2466223948999cfea9
/Control 1/Pregunta2 Control.cpp
35d865f0543a6c4db6bf686059a282eedf1f266b
[]
no_license
PaoDeVi/Paolo-Rafael-Delgado-Vidal
1dd400b19c5a08b70f291c2ca5937a43dd3e62af
dcc2399403f88429c62ec58666f34a49c5c7ef0e
refs/heads/main
2023-04-05T22:39:40.828887
2021-04-30T00:10:12
2021-04-30T00:10:12
351,830,848
0
0
null
null
null
null
ISO-8859-1
C++
false
false
598
cpp
#include<iostream> #include<string> #include<cstdlib> using namespace std; int main(){ string numero; int num; cout<<"Ingrese un numero: ";cin>>numero; cout<<"El número en texto es: "<<numero<<endl; num = atoi(numero.c_str()); cout<<"El numero convertido a entero es: "<<num<<endl; cout<<"Por lo tanto, "<<num<<" sumado a 100 da "<<num+100<<endl; string nuevo_numero = to_string(num); cout<<"El numero convertido a string es: "<<nuevo_numero<<endl; cout<<"Por lo tanto, "<<nuevo_numero<<" puede concatenarse "<<nuevo_numero +" ahora es una cadena"<<endl; }
[ "noreply@github.com" ]
noreply@github.com
8c01ef1af5f4f8871bba7ac2bccf8bcd3dee6853
8380b5eb12e24692e97480bfa8939a199d067bce
/Carberp Botnet/source - absource/pro/all source/BJWJ/include/webbrwsr/nsIWebBrowserChrome.h
8d17e238912be9e0c0862faaafa5776645d31af0
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
RamadhanAmizudin/malware
788ee745b5bb23b980005c2af08f6cb8763981c2
62d0035db6bc9aa279b7c60250d439825ae65e41
refs/heads/master
2023-02-05T13:37:18.909646
2023-01-26T08:43:18
2023-01-26T08:43:18
53,407,812
873
291
null
2023-01-26T08:43:19
2016-03-08T11:44:21
C++
UTF-8
C++
false
false
11,110
h
/* * DO NOT EDIT. THIS FILE IS GENERATED FROM e:/builds/moz2_slave/mozilla-1.9.1-win32-xulrunner/build/embedding/browser/webBrowser/nsIWebBrowserChrome.idl */ #ifndef __gen_nsIWebBrowserChrome_h__ #define __gen_nsIWebBrowserChrome_h__ #ifndef __gen_nsISupports_h__ #include "nsISupports.h" #endif /* For IDL files that don't want to include root IDL files. */ #ifndef NS_NO_VTABLE #define NS_NO_VTABLE #endif class nsIWebBrowser; /* forward declaration */ class nsIDocShellTreeItem; /* forward declaration */ /* starting interface: nsIWebBrowserChrome */ #define NS_IWEBBROWSERCHROME_IID_STR "ba434c60-9d52-11d3-afb0-00a024ffc08c" #define NS_IWEBBROWSERCHROME_IID \ {0xba434c60, 0x9d52, 0x11d3, \ { 0xaf, 0xb0, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c }} /** * nsIWebBrowserChrome corresponds to the top-level, outermost window * containing an embedded Gecko web browser. * * @status FROZEN */ class NS_NO_VTABLE NS_SCRIPTABLE nsIWebBrowserChrome : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEBBROWSERCHROME_IID) enum { STATUS_SCRIPT = 1U }; enum { STATUS_SCRIPT_DEFAULT = 2U }; enum { STATUS_LINK = 3U }; /** * Called when the status text in the chrome needs to be updated. * @param statusType indicates what is setting the text * @param status status string. null is an acceptable value meaning * no status. */ /* void setStatus (in unsigned long statusType, in wstring status); */ NS_SCRIPTABLE NS_IMETHOD SetStatus(PRUint32 statusType, const PRUnichar *status) = 0; /** * The currently loaded WebBrowser. The browser chrome may be * told to set the WebBrowser object to a new object by setting this * attribute. In this case the implementer is responsible for taking the * new WebBrowser object and doing any necessary initialization or setup * as if it had created the WebBrowser itself. This includes positioning * setting up listeners etc. */ /* attribute nsIWebBrowser webBrowser; */ NS_SCRIPTABLE NS_IMETHOD GetWebBrowser(nsIWebBrowser * *aWebBrowser) = 0; NS_SCRIPTABLE NS_IMETHOD SetWebBrowser(nsIWebBrowser * aWebBrowser) = 0; /** * Definitions for the chrome flags */ enum { CHROME_DEFAULT = 1U }; enum { CHROME_WINDOW_BORDERS = 2U }; enum { CHROME_WINDOW_CLOSE = 4U }; enum { CHROME_WINDOW_RESIZE = 8U }; enum { CHROME_MENUBAR = 16U }; enum { CHROME_TOOLBAR = 32U }; enum { CHROME_LOCATIONBAR = 64U }; enum { CHROME_STATUSBAR = 128U }; enum { CHROME_PERSONAL_TOOLBAR = 256U }; enum { CHROME_SCROLLBARS = 512U }; enum { CHROME_TITLEBAR = 1024U }; enum { CHROME_EXTRA = 2048U }; enum { CHROME_WITH_SIZE = 4096U }; enum { CHROME_WITH_POSITION = 8192U }; enum { CHROME_WINDOW_MIN = 16384U }; enum { CHROME_WINDOW_POPUP = 32768U }; enum { CHROME_WINDOW_RAISED = 33554432U }; enum { CHROME_WINDOW_LOWERED = 67108864U }; enum { CHROME_CENTER_SCREEN = 134217728U }; enum { CHROME_DEPENDENT = 268435456U }; enum { CHROME_MODAL = 536870912U }; enum { CHROME_OPENAS_DIALOG = 1073741824U }; enum { CHROME_OPENAS_CHROME = 2147483648U }; enum { CHROME_ALL = 4094U }; /** * The chrome flags for this browser chrome. The implementation should * reflect the value of this attribute by hiding or showing its chrome * appropriately. */ /* attribute unsigned long chromeFlags; */ NS_SCRIPTABLE NS_IMETHOD GetChromeFlags(PRUint32 *aChromeFlags) = 0; NS_SCRIPTABLE NS_IMETHOD SetChromeFlags(PRUint32 aChromeFlags) = 0; /** * Asks the implementer to destroy the window associated with this * WebBrowser object. */ /* void destroyBrowserWindow (); */ NS_SCRIPTABLE NS_IMETHOD DestroyBrowserWindow(void) = 0; /** * Tells the chrome to size itself such that the browser will be the * specified size. * @param aCX new width of the browser * @param aCY new height of the browser */ /* void sizeBrowserTo (in long aCX, in long aCY); */ NS_SCRIPTABLE NS_IMETHOD SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) = 0; /** * Shows the window as a modal window. * @return (the function error code) the status value specified by * in exitModalEventLoop. */ /* void showAsModal (); */ NS_SCRIPTABLE NS_IMETHOD ShowAsModal(void) = 0; /** * Is the window modal (that is, currently executing a modal loop)? * @return true if it's a modal window */ /* boolean isWindowModal (); */ NS_SCRIPTABLE NS_IMETHOD IsWindowModal(PRBool *_retval NS_OUTPARAM) = 0; /** * Exit a modal event loop if we're in one. The implementation * should also exit out of the loop if the window is destroyed. * @param aStatus - the result code to return from showAsModal */ /* void exitModalEventLoop (in nsresult aStatus); */ NS_SCRIPTABLE NS_IMETHOD ExitModalEventLoop(nsresult aStatus) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebBrowserChrome, NS_IWEBBROWSERCHROME_IID) /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_NSIWEBBROWSERCHROME \ NS_SCRIPTABLE NS_IMETHOD SetStatus(PRUint32 statusType, const PRUnichar *status); \ NS_SCRIPTABLE NS_IMETHOD GetWebBrowser(nsIWebBrowser * *aWebBrowser); \ NS_SCRIPTABLE NS_IMETHOD SetWebBrowser(nsIWebBrowser * aWebBrowser); \ NS_SCRIPTABLE NS_IMETHOD GetChromeFlags(PRUint32 *aChromeFlags); \ NS_SCRIPTABLE NS_IMETHOD SetChromeFlags(PRUint32 aChromeFlags); \ NS_SCRIPTABLE NS_IMETHOD DestroyBrowserWindow(void); \ NS_SCRIPTABLE NS_IMETHOD SizeBrowserTo(PRInt32 aCX, PRInt32 aCY); \ NS_SCRIPTABLE NS_IMETHOD ShowAsModal(void); \ NS_SCRIPTABLE NS_IMETHOD IsWindowModal(PRBool *_retval NS_OUTPARAM); \ NS_SCRIPTABLE NS_IMETHOD ExitModalEventLoop(nsresult aStatus); /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_NSIWEBBROWSERCHROME(_to) \ NS_SCRIPTABLE NS_IMETHOD SetStatus(PRUint32 statusType, const PRUnichar *status) { return _to SetStatus(statusType, status); } \ NS_SCRIPTABLE NS_IMETHOD GetWebBrowser(nsIWebBrowser * *aWebBrowser) { return _to GetWebBrowser(aWebBrowser); } \ NS_SCRIPTABLE NS_IMETHOD SetWebBrowser(nsIWebBrowser * aWebBrowser) { return _to SetWebBrowser(aWebBrowser); } \ NS_SCRIPTABLE NS_IMETHOD GetChromeFlags(PRUint32 *aChromeFlags) { return _to GetChromeFlags(aChromeFlags); } \ NS_SCRIPTABLE NS_IMETHOD SetChromeFlags(PRUint32 aChromeFlags) { return _to SetChromeFlags(aChromeFlags); } \ NS_SCRIPTABLE NS_IMETHOD DestroyBrowserWindow(void) { return _to DestroyBrowserWindow(); } \ NS_SCRIPTABLE NS_IMETHOD SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) { return _to SizeBrowserTo(aCX, aCY); } \ NS_SCRIPTABLE NS_IMETHOD ShowAsModal(void) { return _to ShowAsModal(); } \ NS_SCRIPTABLE NS_IMETHOD IsWindowModal(PRBool *_retval NS_OUTPARAM) { return _to IsWindowModal(_retval); } \ NS_SCRIPTABLE NS_IMETHOD ExitModalEventLoop(nsresult aStatus) { return _to ExitModalEventLoop(aStatus); } /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_NSIWEBBROWSERCHROME(_to) \ NS_SCRIPTABLE NS_IMETHOD SetStatus(PRUint32 statusType, const PRUnichar *status) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetStatus(statusType, status); } \ NS_SCRIPTABLE NS_IMETHOD GetWebBrowser(nsIWebBrowser * *aWebBrowser) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetWebBrowser(aWebBrowser); } \ NS_SCRIPTABLE NS_IMETHOD SetWebBrowser(nsIWebBrowser * aWebBrowser) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetWebBrowser(aWebBrowser); } \ NS_SCRIPTABLE NS_IMETHOD GetChromeFlags(PRUint32 *aChromeFlags) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetChromeFlags(aChromeFlags); } \ NS_SCRIPTABLE NS_IMETHOD SetChromeFlags(PRUint32 aChromeFlags) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetChromeFlags(aChromeFlags); } \ NS_SCRIPTABLE NS_IMETHOD DestroyBrowserWindow(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->DestroyBrowserWindow(); } \ NS_SCRIPTABLE NS_IMETHOD SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) { return !_to ? NS_ERROR_NULL_POINTER : _to->SizeBrowserTo(aCX, aCY); } \ NS_SCRIPTABLE NS_IMETHOD ShowAsModal(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->ShowAsModal(); } \ NS_SCRIPTABLE NS_IMETHOD IsWindowModal(PRBool *_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsWindowModal(_retval); } \ NS_SCRIPTABLE NS_IMETHOD ExitModalEventLoop(nsresult aStatus) { return !_to ? NS_ERROR_NULL_POINTER : _to->ExitModalEventLoop(aStatus); } #if 0 /* Use the code below as a template for the implementation class for this interface. */ /* Header file */ class nsWebBrowserChrome : public nsIWebBrowserChrome { public: NS_DECL_ISUPPORTS NS_DECL_NSIWEBBROWSERCHROME nsWebBrowserChrome(); private: ~nsWebBrowserChrome(); protected: /* additional members */ }; /* Implementation file */ NS_IMPL_ISUPPORTS1(nsWebBrowserChrome, nsIWebBrowserChrome) nsWebBrowserChrome::nsWebBrowserChrome() { /* member initializers and constructor code */ } nsWebBrowserChrome::~nsWebBrowserChrome() { /* destructor code */ } /* void setStatus (in unsigned long statusType, in wstring status); */ NS_IMETHODIMP nsWebBrowserChrome::SetStatus(PRUint32 statusType, const PRUnichar *status) { return NS_ERROR_NOT_IMPLEMENTED; } /* attribute nsIWebBrowser webBrowser; */ NS_IMETHODIMP nsWebBrowserChrome::GetWebBrowser(nsIWebBrowser * *aWebBrowser) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP nsWebBrowserChrome::SetWebBrowser(nsIWebBrowser * aWebBrowser) { return NS_ERROR_NOT_IMPLEMENTED; } /* attribute unsigned long chromeFlags; */ NS_IMETHODIMP nsWebBrowserChrome::GetChromeFlags(PRUint32 *aChromeFlags) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP nsWebBrowserChrome::SetChromeFlags(PRUint32 aChromeFlags) { return NS_ERROR_NOT_IMPLEMENTED; } /* void destroyBrowserWindow (); */ NS_IMETHODIMP nsWebBrowserChrome::DestroyBrowserWindow() { return NS_ERROR_NOT_IMPLEMENTED; } /* void sizeBrowserTo (in long aCX, in long aCY); */ NS_IMETHODIMP nsWebBrowserChrome::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) { return NS_ERROR_NOT_IMPLEMENTED; } /* void showAsModal (); */ NS_IMETHODIMP nsWebBrowserChrome::ShowAsModal() { return NS_ERROR_NOT_IMPLEMENTED; } /* boolean isWindowModal (); */ NS_IMETHODIMP nsWebBrowserChrome::IsWindowModal(PRBool *_retval NS_OUTPARAM) { return NS_ERROR_NOT_IMPLEMENTED; } /* void exitModalEventLoop (in nsresult aStatus); */ NS_IMETHODIMP nsWebBrowserChrome::ExitModalEventLoop(nsresult aStatus) { return NS_ERROR_NOT_IMPLEMENTED; } /* End of implementation class template. */ #endif #endif /* __gen_nsIWebBrowserChrome_h__ */
[ "fdiskyou@users.noreply.github.com" ]
fdiskyou@users.noreply.github.com
a5081017a82d383a49627753c4bcbd51f3a165de
396e3a3b77ed662ce7e233fe6e53a36df2509c74
/1. Beginner/AVG.cpp
f7385e21f4b17f2490053e19e2460c04a0d343cb
[]
no_license
ddvader44/Competitive-Coding
c54e351a78c66a089d69f6bfaab13315f474c2ba
dd7e825747bdbb37f09484c153c8d562411baea7
refs/heads/master
2023-01-30T05:14:21.060119
2020-12-14T13:30:51
2020-12-14T13:30:51
311,452,762
0
0
null
null
null
null
UTF-8
C++
false
false
536
cpp
#include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t--){ int n,k,v; cin >> n >> k >> v; int x; int a[n]; for(int i = 0; i < n; i++){ cin>>a[i]; } int sum=0; for(int i = 0; i < n; i++){ sum = sum + a[i]; } x=(v*n+v*k-sum)/k ; if((v*n+v*k-sum)%k ==0 && (v*n+v*k) > sum){ cout<<x<<endl; } else{ cout << "-1" << endl; } } return 0; }
[ "40226856+ddvader44@users.noreply.github.com" ]
40226856+ddvader44@users.noreply.github.com
bd2150db69854fc7ff588fcf8cf0f06fd2758a60
93f0e8b027300169717cb08206ac7f6ced9fcbc6
/hengda_server-cj/utility/de_serv_impl.cpp
d31cc69e64587114eec431f7d2bb4411cac38d64
[]
no_license
chenjian123456/hengda-cj
09f3e75c70b40576422eab103c62aa04c43fd1de
76a42358f867a0780047e3d1fe4331f045655eed
refs/heads/master
2022-04-04T08:17:00.009089
2020-02-15T14:33:08
2020-02-15T14:33:08
240,664,548
0
0
null
null
null
null
UTF-8
C++
false
false
5,923
cpp
#include "de_serv_impl.h" #include "bordersloader.h" #include "base/log.h" #include "base/fs.h" // for fs::file #include "base/hash.h" // for base64_encode #include "json11.hpp" #include "bordersloader.h" DeServImpl::DeServImpl() { } DeServImpl::~DeServImpl() { } void DeServImpl::set_egbd_task(const Json& req, Json& res) { LOG << "set_egbd_task: " << req; res.add_member("req_id", req["req_id"]); res.add_member("method", req["method"]); fastring s = req["params"].str(); if (s.empty()) { res.add_member("code", 400); res.add_member("code_msg", "400 params not found"); return; } Json params = req["params"]; fastring streamName = params["rtsp_url"].get_string(); if (streamName.empty()) { res.add_member("code", 404); res.add_member("err_msg", "400 rtsp_url not found"); return; } uint32_t GRAPH_ID = 100 + process_num; string ip = params["ip"].get_string(); string content = params["rtsp_url"].get_string(); ifstream config(configFileName); // if(!config.is_open()){ printf("open file failed\n"); } const string newconfigFileName = "graph" +to_string(process_num)+".config"; ofstream config_new(newconfigFileName); string temp; int linenum = 1;//读取的内容行数 //边读config边写进临时config文件 while(getline(config, temp)){ //如果是需要的行,进行修改 if(linenum == 18){ temp = temp.substr(0,temp.find(":") + 1)+"\"" + content + "\""; config_new << temp; config_new << endl; linenum++; } //如果是第二行,改变GraphID else if(linenum == 2){ temp = temp.substr(0,temp.find(":") + 1)+to_string(GRAPH_ID); config_new << temp; config_new << endl; linenum++; } else if(linenum == 76){ temp = temp.substr(0,temp.find(":") + 1)+"\""+ip + "\""; config_new << temp; config_new << endl; linenum++; } //其他行直接复制 else{ config_new << temp; config_new << endl; linenum++; } } config.close(); config_new.close(); // init Graph HIAI_StatusT status = HIAI_InitAndStartGraph(newconfigFileName,GRAPH_ID); if (status != HIAI_OK) { printf("[main] Fail to start graph\n"); return; } // send data std::shared_ptr<hiai::Graph> graph = hiai::Graph::GetInstance(GRAPH_ID); if (nullptr == graph) { printf("Fail to get the graph-%u\n", GRAPH_ID); return; } hiai::EnginePortID engine_id; engine_id.graph_id = GRAPH_ID; engine_id.engine_id = SRC_ENGINE; engine_id.port_id = 0; std::shared_ptr<std::string> src_data(new std::string()); graph->SendData(engine_id, "string", std::static_pointer_cast<void>(src_data)); pidMap[content] = GRAPH_ID; process_num++; //startStream(streamName); res.add_member("code", 200); res.add_member("code_msg", "200 ok"); } void DeServImpl::get_key_frame(const Json& req, Json& res) { LOG << "get_key_frame: " << req; res.add_member("req_id", req["req_id"]); res.add_member("method", req["method"]); std::string ip= req["params"]["ip"].get_string(); std::string filename = "/home/" + ip + ".jpg"; fs::file f(filename.c_str(), 'r'); if (f) { fastring s = f.read(f.size()); res.add_member("code", 200); res.add_member("code_msg", "200 ok"); res.add_member("data", base64_encode(s)); } else { res.add_member("code", 400); res.add_member("code_msg", "400 key frame not found"); } f.close(); } void DeServImpl::set_border_info(const Json& req, Json& res) { LOG << "set_border_info: " << req; res.add_member("req_id", req["req_id"]); res.add_member("method", req["method"]); Json params = req["params"]; fastring s = params["info"].str(); fastring filename_ = params["ip"].get_string(); std::string filename = filename_.c_str(); filename += ".json"; std::string err; json11::Json borders; borders = json11::Json::parse(s.c_str(), err); if(!err.empty()) { borders = json11::Json::array(); res.add_member("code", "400"); res.add_member("code_msg", "400 parse borders error"); return; } LOG << "save borders: " << s; std::cout << "border filename is "<< filename; LOG << "filename is " << filename; BordersLoader::Instance().save(borders,filename); res.add_member("code", 200); res.add_member("code_msg", "200 ok"); } HIAI_StatusT DeServImpl::HIAI_InitAndStartGraph(const std::string& configFile,uint32_t GRAPH_ID) { std::cout << "HIAI_InitAndStartGraph: configFile is " << configFile << std::endl; // Step1: Global System Initialization before using HIAI Engine HIAI_StatusT status = HIAI_Init(0); // Step2: Create and Start the Graph status = hiai::Graph::CreateGraph(configFile); if (status != HIAI_OK) { HIAI_ENGINE_LOG(status, "Fail to start graph"); printf("Fail to start graph: %#X\n", status); return status; } // Step3: Set DataRecv Functor std::shared_ptr<hiai::Graph> graph = hiai::Graph::GetInstance(GRAPH_ID); if (graph == nullptr) { HIAI_ENGINE_LOG("Fail to get the graph-%u", GRAPH_ID); return status; } hiai::EnginePortID target_port_config; target_port_config.graph_id = GRAPH_ID; target_port_config.engine_id = ENGINE_ID; target_port_config.port_id = 0; graph->SetDataRecvFunctor(target_port_config, std::make_shared<CustomDataRecvInterface>("")); return HIAI_OK; }
[ "1075891372@qq.com" ]
1075891372@qq.com
50847c3165f9d1eb005f2318bca44061a357e809
095eda43725d319cd95a4f830e0ddf4357a778c7
/Engine/Source/Platforms/OSX/System/File/FsFileImplOSX.cpp
db6b8cdd971b804bf86727010ebc1a51db05be10
[ "LicenseRef-scancode-public-domain", "Zlib", "MIT", "BSD-3-Clause" ]
permissive
Psybrus/Psybrus
b9fb6a5f7c56ed35533babaed53165c9bf268c05
000ea00ffcccc5fe388eff66e388d2d5c94a104d
refs/heads/develop
2021-01-20T11:43:56.290703
2016-11-01T09:48:29
2016-11-01T09:48:29
1,612,818
26
3
null
2015-12-13T00:03:29
2011-04-14T05:11:24
C
UTF-8
C++
false
false
3,520
cpp
/************************************************************************** * * File: FsFileImplOSX.cpp * Author: Neil Richardson * Ver/Date: * Description: * * * * * **************************************************************************/ #include "System/File/FsFileImplOSX.h" #include "System/File/FsCore.h" #include "System/File/FsCoreImplOSX.h" ////////////////////////////////////////////////////////////////////////// // Ctor FsFileImplOSX::FsFileImplOSX(): pFileHandle_( NULL ), FileSize_( 0 ) { } ////////////////////////////////////////////////////////////////////////// // Dtor //virtual FsFileImplOSX::~FsFileImplOSX() { BcAssert( pFileHandle_ == NULL ); } ////////////////////////////////////////////////////////////////////////// // open //virtual BcBool FsFileImplOSX::open( const BcChar* FileName, eFsFileMode FileMode ) { BcBool RetVal = BcFalse; if( pFileHandle_ == NULL ) { FileName_ = FileName; // Read access. if( FileMode == fsFM_READ ) { pFileHandle_ = fopen( FileName, "rb" ); if( pFileHandle_ != NULL ) { fseek( pFileHandle_, 0, SEEK_END ); FileSize_ = ftell( pFileHandle_ ); fseek( pFileHandle_, 0, SEEK_SET ); } } else if( FileMode == fsFM_WRITE ) { pFileHandle_ = fopen( FileName, "wb+" ); } // Return value. if( pFileHandle_ != NULL ) { RetVal = BcTrue; } } return RetVal; } ////////////////////////////////////////////////////////////////////////// // close //virtual BcBool FsFileImplOSX::close() { BcBool RetVal = BcFalse; if( pFileHandle_ != NULL ) { fclose( pFileHandle_ ); pFileHandle_ = NULL; FileSize_ = 0; FileName_.clear(); RetVal = BcTrue; } return RetVal; } ////////////////////////////////////////////////////////////////////////// // fileName //virtual const BcChar* FsFileImplOSX::fileName() const { return FileName_.c_str(); } ////////////////////////////////////////////////////////////////////////// // size //virtual BcSize FsFileImplOSX::size() const { return (BcSize)FileSize_; } ////////////////////////////////////////////////////////////////////////// // tell //virtual BcSize FsFileImplOSX::tell() const { return (BcSize)ftell( pFileHandle_ ); } ////////////////////////////////////////////////////////////////////////// // seek //virtual void FsFileImplOSX::seek( BcSize Position ) { fseek( pFileHandle_, (long)Position, SEEK_SET ); } ////////////////////////////////////////////////////////////////////////// // eof //virtual BcBool FsFileImplOSX::eof() const { return feof( pFileHandle_ ) != 0; } ////////////////////////////////////////////////////////////////////////// // read void FsFileImplOSX::read( void* pDest, BcSize Bytes ) { fread( pDest, (long)Bytes, 1, pFileHandle_ ); } ////////////////////////////////////////////////////////////////////////// // write void FsFileImplOSX::write( void* pSrc, BcSize Bytes ) { fwrite( pSrc, (long)Bytes, 1, pFileHandle_ ); } ////////////////////////////////////////////////////////////////////////// // readAsync //virtual void FsFileImplOSX::readAsync( BcSize Position, void* pData, BcSize Bytes, FsFileOpCallback DoneCallback ) { FsCore::pImpl()->addReadOp( this, Position, pData, Bytes, DoneCallback ); } ////////////////////////////////////////////////////////////////////////// // writeAsync //virtual void FsFileImplOSX::writeAsync( BcSize Position, void* pData, BcSize Bytes, FsFileOpCallback DoneCallback ) { FsCore::pImpl()->addWriteOp( this, Position, pData, Bytes, DoneCallback ); }
[ "neilo@neilo.gd" ]
neilo@neilo.gd
5f2d81b4192c2e5999a9fc2ae563aad7826ca6dc
f739df1f252d7c961ed881be3b8babaf62ff4170
/softs/SCADAsoft/5.3.3_P2/ACE_Wrappers/TAO/TAO_IDL/be/be_root.cpp
3676fc989deabe18bbd3d1793ad0a80efbe3762a
[]
no_license
billpwchan/SCADA-nsl
739484691c95181b262041daa90669d108c54234
1287edcd38b2685a675f1261884f1035f7f288db
refs/heads/master
2023-04-30T09:15:49.104944
2021-01-10T21:53:10
2021-01-10T21:53:10
328,486,982
0
0
null
2023-04-22T07:10:56
2021-01-10T21:53:19
C++
UTF-8
C++
false
false
2,460
cpp
// $Id: be_root.cpp 935 2008-12-10 21:47:27Z mitza $ // ============================================================================ // // = LIBRARY // TAO IDL // // = FILENAME // be_root.cpp // // = DESCRIPTION // Extension of class AST_Root that provides additional means for C++ // mapping. // // = AUTHOR // Copyright 1994-1995 by Sun Microsystems, Inc. // and // Aniruddha Gokhale // // ============================================================================ #include "be_root.h" #include "be_visitor.h" #include "ast_sequence.h" #include "ast_string.h" #include "ast_array.h" ACE_RCSID (be, be_root, "$Id: be_root.cpp 935 2008-12-10 21:47:27Z mitza $") // Default Constructor. be_root::be_root (void) : COMMON_Base (), AST_Decl (), UTL_Scope (), AST_Root (), be_scope (), be_decl () { } // Constructor used to build the root of the abstract syntax tree (AST). be_root::be_root (UTL_ScopedName *n) : COMMON_Base (), AST_Decl (AST_Decl::NT_root, n), UTL_Scope (AST_Decl::NT_root), AST_Module (n), AST_Root (n), be_scope (AST_Decl::NT_root), be_decl (AST_Decl::NT_root, n) { } be_root::~be_root (void) { } // We had to provide these since the AST_Root::fe_* method was setting the // names of these three to "local type". // Add this AST_Sequence to the locally defined types in this scope. AST_Sequence * be_root::fe_add_sequence (AST_Sequence *t) { if (t == 0) { return 0; } add_to_local_types (t); return t; } // Add this AST_String to the locally defined types in this scope AST_String * be_root::fe_add_string (AST_String *t) { if (t == 0) { return 0; } add_to_local_types (t); return t; } // Add this AST_Array to the locally defined types in this scope AST_Array * be_root::fe_add_array (AST_Array *t) { if (t == 0) { return 0; } add_to_local_types (t); return t; } void be_root::destroy (void) { // Call the destroy methods of our base classes. // The scope of the root is handled specially, since we may // be processing multiple IDL files and we want to keep // the predefined types around until we are all done. // be_scope::destroy (); // be_decl::destroy (); AST_Root::destroy (); } int be_root::accept (be_visitor *visitor) { return visitor->visit_root (this); } IMPL_NARROW_FROM_DECL (be_root) IMPL_NARROW_FROM_SCOPE (be_root)
[ "billpwchan@hotmail.com" ]
billpwchan@hotmail.com
c5152b30af52cb0c8a9d871e0665fcb0b1ac4aca
db2895065b2dcba203c3d0023ef575b892d383a2
/libvpvl2/test/ProjectTest.cc
7c8325151620aa83629a3fe61114b7a09e91e76c
[ "BSD-3-Clause" ]
permissive
r1cebank/MMDAI
a1efbbf6e706ba424d7aed6840b1575130b00cf0
22afb1aacfeda551ea27952d0e6ef71c4112b06c
refs/heads/master
2020-12-11T06:05:44.261619
2013-12-07T13:56:57
2013-12-07T13:56:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
28,108
cc
#include "Common.h" #include "vpvl2/vpvl2.h" #include "vpvl2/extensions/XMLProject.h" #include "vpvl2/extensions/icu4c/Encoding.h" #include "vpvl2/mvd/AssetKeyframe.h" #include "vpvl2/mvd/AssetSection.h" #include "vpvl2/mvd/BoneKeyframe.h" #include "vpvl2/mvd/BoneSection.h" #include "vpvl2/mvd/CameraKeyframe.h" #include "vpvl2/mvd/CameraSection.h" #include "vpvl2/mvd/EffectKeyframe.h" #include "vpvl2/mvd/EffectSection.h" #include "vpvl2/mvd/LightKeyframe.h" #include "vpvl2/mvd/LightSection.h" #include "vpvl2/mvd/ModelKeyframe.h" #include "vpvl2/mvd/ModelSection.h" #include "vpvl2/mvd/MorphKeyframe.h" #include "vpvl2/mvd/MorphSection.h" #include "vpvl2/mvd/Motion.h" #include "vpvl2/mvd/ProjectKeyframe.h" #include "vpvl2/mvd/ProjectSection.h" #include "vpvl2/vmd/BoneAnimation.h" #include "vpvl2/vmd/BoneKeyframe.h" #include "vpvl2/vmd/CameraAnimation.h" #include "vpvl2/vmd/CameraKeyframe.h" #include "vpvl2/vmd/LightAnimation.h" #include "vpvl2/vmd/LightKeyframe.h" #include "vpvl2/vmd/MorphAnimation.h" #include "vpvl2/vmd/MorphKeyframe.h" #include "vpvl2/vmd/Motion.h" #include "mock/Model.h" #include "mock/RenderEngine.h" using namespace ::testing; using namespace vpvl2; using namespace vpvl2::extensions; using namespace vpvl2::extensions::icu4c; namespace { const XMLProject::UUID kAsset1UUID = "{EEBC6A85-F333-429A-ADF8-B6188908A517}"; const XMLProject::UUID kAsset2UUID = "{D4403C60-3D6C-4051-9B28-51DEFE021F59}"; const XMLProject::UUID kModel1UUID = "{D41F00F2-FB75-4BFC-8DE8-0B1390F862F6}"; const XMLProject::UUID kModel2UUID = "{B18ACADC-89FD-4945-9192-8E8FBC849E52}"; const XMLProject::UUID kMotion1UUID = "{E75F84CD-5DE0-4E95-A0DE-494E5AAE1DB6}"; const XMLProject::UUID kMotion2UUID = "{481E1B4E-FC24-4D61-841D-C8AB7CF1096D}"; const XMLProject::UUID kMotion3UUID = "{766CF45D-DE91-4387-9704-4B3D5B1414DC}"; class Delegate : public XMLProject::IDelegate { public: Delegate() : m_codec(QTextCodec::codecForName("Shift-JIS")), m_encoding(&m_dictionary), m_factory(&m_encoding) { } ~Delegate() { } const std::string toStdFromString(const IString *value) const { if (value) { const std::string &s = String::toStdString(static_cast<const String *>(value)->value()); return s; } return std::string(); } IString *toStringFromStd(const std::string &value) const { const QString &s = m_codec->toUnicode(value.c_str()); return new String(UnicodeString::fromUTF8(s.toStdString())); } bool loadModel(const XMLProject::UUID & /* uuid */, const XMLProject::StringMap & /* settings */, IModel::Type type, IModel *&model, IRenderEngine *&engine, int &priority) { model = m_factory.newModel(type); engine = new MockIRenderEngine(); priority = 0; return true; } private: const QTextCodec *m_codec; Encoding::Dictionary m_dictionary; Encoding m_encoding; Factory m_factory; }; static void TestGlobalSettings(const XMLProject &project) { ASSERT_STREQ("", project.globalSetting("no_such_key").c_str()); ASSERT_STREQ("640", project.globalSetting("width").c_str()); ASSERT_STREQ("480", project.globalSetting("height").c_str()); } static void TestLocalSettings(const XMLProject &project) { IModel *asset1 = project.findModel(kAsset1UUID), *asset2 = project.findModel(kAsset2UUID); IModel *model1 = project.findModel(kModel1UUID), *model2 = project.findModel(kModel2UUID); ASSERT_STREQ("asset:/foo/bar/baz", project.modelSetting(asset1, XMLProject::kSettingURIKey).c_str()); ASSERT_STREQ("model:/foo/bar/baz", project.modelSetting(model1, XMLProject::kSettingURIKey).c_str()); ASSERT_STREQ("1.0", project.modelSetting(model1, "edge").c_str()); ASSERT_STREQ("asset:/baz/bar/foo", project.modelSetting(asset2, XMLProject::kSettingURIKey).c_str()); ASSERT_STREQ("model:/baz/bar/foo", project.modelSetting(model2, XMLProject::kSettingURIKey).c_str()); ASSERT_STREQ("0.5", project.modelSetting(model2, "edge").c_str()); } static void TestBoneMotion(const IMotion *motion, bool hasLayer) { const String bar("bar"), baz("baz"); QuadWord q; ASSERT_EQ(2, motion->countKeyframes(IKeyframe::kBoneKeyframe)); { const IBoneKeyframe *keyframe = motion->findBoneKeyframeRefAt(0); ASSERT_EQ(IKeyframe::TimeIndex(1), keyframe->timeIndex()); ASSERT_TRUE(keyframe->name()->equals(&bar)); ASSERT_TRUE(CompareVector(Vector3(1, 2, -3), keyframe->localTranslation())); ASSERT_TRUE(CompareVector(Quaternion(-1, -2, 3, 4), keyframe->localOrientation())); // ASSERT_TRUE(ba.frameAt(0)->isIKEnabled()); for (int i = 0; i < IBoneKeyframe::kMaxBoneInterpolationType; i++) { int offset = i * 4; keyframe->getInterpolationParameter(static_cast<IBoneKeyframe::InterpolationType>(i), q); ASSERT_TRUE(CompareVector(QuadWord(offset + 1, offset + 2, offset + 3, offset + 4), q)); } } { const IBoneKeyframe *keyframe = motion->findBoneKeyframeRefAt(1); ASSERT_EQ(IKeyframe::TimeIndex(2), keyframe->timeIndex()); ASSERT_EQ(IKeyframe::LayerIndex(hasLayer ? 1 : 0), keyframe->layerIndex()); ASSERT_TRUE(keyframe->name()->equals(&baz)); ASSERT_TRUE(CompareVector(Vector3(3, 1, -2), keyframe->localTranslation())); ASSERT_TRUE(CompareVector(Quaternion(-4, -3, 2, 1), keyframe->localOrientation())); // ASSERT_FALSE(ba.frameAt(1)->isIKEnabled()); for (int i = IBoneKeyframe::kMaxBoneInterpolationType - 1; i >= 0; i--) { int offset = (IBoneKeyframe::kMaxBoneInterpolationType - 1 - i) * 4; keyframe->getInterpolationParameter(static_cast<IBoneKeyframe::InterpolationType>(i), q); ASSERT_TRUE(CompareVector(QuadWord(offset + 4, offset + 3, offset + 2, offset + 1), q)); } } } static void TestMorphMotion(const IMotion *motion) { String bar("bar"), baz("baz"); ASSERT_EQ(2, motion->countKeyframes(IKeyframe::kMorphKeyframe)); { const IMorphKeyframe *keyframe = motion->findMorphKeyframeRefAt(0); ASSERT_EQ(IKeyframe::TimeIndex(1), keyframe->timeIndex()); ASSERT_TRUE(keyframe->name()->equals(&bar)); ASSERT_FLOAT_EQ(IMorph::WeightPrecision(0), keyframe->weight()); } { const IMorphKeyframe *keyframe = motion->findMorphKeyframeRefAt(1); ASSERT_EQ(IKeyframe::TimeIndex(2), keyframe->timeIndex()); ASSERT_TRUE(keyframe->name()->equals(&baz)); ASSERT_FLOAT_EQ(IMorph::WeightPrecision(1), keyframe->weight()); } } static void TestCameraMotion(const IMotion *motion, bool hasLayer) { QuadWord q; ASSERT_EQ(2, motion->countKeyframes(IKeyframe::kCameraKeyframe)); { const ICameraKeyframe *keyframe = motion->findCameraKeyframeRefAt(0); ASSERT_EQ(IKeyframe::TimeIndex(1), keyframe->timeIndex()); ASSERT_TRUE(CompareVector(Vector3(1, 2, -3), keyframe->lookAt())); const Vector3 &angle1 = keyframe->angle(); ASSERT_TRUE(qFuzzyCompare(angle1.x(), -btDegrees(1))); ASSERT_TRUE(qFuzzyCompare(angle1.y(), -btDegrees(2))); ASSERT_TRUE(qFuzzyCompare(angle1.z(), -btDegrees(3))); ASSERT_FLOAT_EQ(15.0f, keyframe->fov()); ASSERT_FLOAT_EQ(150.0f, keyframe->distance()); if (motion->type() == IMotion::kMVDMotion) { for (int i = 0; i < ICameraKeyframe::kCameraMaxInterpolationType; i++) { int offset = (i < 3 ? 0 : i - 2) * 4; keyframe->getInterpolationParameter(static_cast<ICameraKeyframe::InterpolationType>(i), q); ASSERT_TRUE(CompareVector(QuadWord(offset + 1, offset + 2, offset + 3, offset + 4), q)); } } else { for (int i = 0; i < ICameraKeyframe::kCameraMaxInterpolationType; i++) { int offset = i * 4; keyframe->getInterpolationParameter(static_cast<ICameraKeyframe::InterpolationType>(i), q); ASSERT_TRUE(CompareVector(QuadWord(offset + 1, offset + 2, offset + 3, offset + 4), q)); } } } { const ICameraKeyframe *keyframe = motion->findCameraKeyframeRefAt(1); ASSERT_EQ(IKeyframe::TimeIndex(2), keyframe->timeIndex()); ASSERT_EQ(IKeyframe::LayerIndex(hasLayer ? 1 : 0), keyframe->layerIndex()); ASSERT_EQ(Vector3(3, 1, -2), keyframe->lookAt()); const Vector3 &angle2 = keyframe->angle(); ASSERT_TRUE(qFuzzyCompare(angle2.x(), -btDegrees(3))); ASSERT_TRUE(qFuzzyCompare(angle2.y(), -btDegrees(1))); ASSERT_TRUE(qFuzzyCompare(angle2.z(), -btDegrees(2))); ASSERT_FLOAT_EQ(30.0f, keyframe->fov()); ASSERT_FLOAT_EQ(300.0f, keyframe->distance()); if (motion->type() == IMotion::kMVDMotion) { for (int max = ICameraKeyframe::kCameraMaxInterpolationType - 1, i = max; i >= 0; i--) { int offset = qMin((max - i) * 4, 12); keyframe->getInterpolationParameter(static_cast<ICameraKeyframe::InterpolationType>(i), q); ASSERT_TRUE(CompareVector(QuadWord(offset + 4, offset + 3, offset + 2, offset + 1), q)); } } else { for (int max = ICameraKeyframe::kCameraMaxInterpolationType - 1, i = max; i >= 0; i--) { int offset = (max - i) * 4; keyframe->getInterpolationParameter(static_cast<ICameraKeyframe::InterpolationType>(i), q); ASSERT_TRUE(CompareVector(QuadWord(offset + 4, offset + 3, offset + 2, offset + 1), q)); } } } } static void TestLightMotion(const IMotion *motion) { ASSERT_EQ(2, motion->countKeyframes(IKeyframe::kLightKeyframe)); { const ILightKeyframe *keyframe = motion->findLightKeyframeRefAt(0); ASSERT_EQ(IKeyframe::TimeIndex(1), keyframe->timeIndex()); ASSERT_TRUE(CompareVector(Vector3(1, 2, 3), keyframe->color())); ASSERT_TRUE(CompareVector(Vector3(1, 2, 3), keyframe->direction())); } { const ILightKeyframe *keyframe = motion->findLightKeyframeRefAt(1); ASSERT_EQ(IKeyframe::TimeIndex(2), keyframe->timeIndex()); ASSERT_TRUE(CompareVector(Vector3(3, 1, 2), keyframe->color())); ASSERT_TRUE(CompareVector(Vector3(3, 1, 2), keyframe->direction())); } } static void TestEffectMotion(const IMotion *motion) { if (motion->type() == IMotion::kMVDMotion) { ASSERT_EQ(2, motion->countKeyframes(IKeyframe::kEffectKeyframe)); { const IEffectKeyframe *keyframe = motion->findEffectKeyframeRefAt(0); ASSERT_EQ(IKeyframe::TimeIndex(1), keyframe->timeIndex()); ASSERT_EQ(true, keyframe->isVisible()); ASSERT_EQ(false, keyframe->isAddBlendEnabled()); ASSERT_EQ(true, keyframe->isShadowEnabled()); ASSERT_FLOAT_EQ(0.42f, keyframe->scaleFactor()); ASSERT_FLOAT_EQ(0.24f, keyframe->opacity()); } { const IEffectKeyframe *keyframe = motion->findEffectKeyframeRefAt(1); ASSERT_EQ(IKeyframe::TimeIndex(2), keyframe->timeIndex()); ASSERT_EQ(false, keyframe->isVisible()); ASSERT_EQ(true, keyframe->isAddBlendEnabled()); ASSERT_EQ(false, keyframe->isShadowEnabled()); ASSERT_FLOAT_EQ(0.24f, keyframe->scaleFactor()); ASSERT_FLOAT_EQ(0.42f, keyframe->opacity()); } } else { ASSERT_EQ(0, motion->countKeyframes(IKeyframe::kEffectKeyframe)); } } static void TestModelMotion(const IMotion *motion) { if (motion->type() == IMotion::kMVDMotion) { ASSERT_EQ(2, motion->countKeyframes(IKeyframe::kModelKeyframe)); { const IModelKeyframe *keyframe = motion->findModelKeyframeRefAt(0); ASSERT_EQ(IKeyframe::TimeIndex(1), keyframe->timeIndex()); ASSERT_EQ(true, keyframe->isVisible()); ASSERT_EQ(false, keyframe->isAddBlendEnabled()); ASSERT_EQ(true, keyframe->isPhysicsEnabled()); ASSERT_EQ(0, keyframe->physicsStillMode()); ASSERT_FLOAT_EQ(0.24f, keyframe->edgeWidth()); ASSERT_TRUE(CompareVector(Color(0.1, 0.2, 0.3, 0.4), keyframe->edgeColor())); } { const IModelKeyframe *keyframe = motion->findModelKeyframeRefAt(1); ASSERT_EQ(IKeyframe::TimeIndex(2), keyframe->timeIndex()); ASSERT_EQ(false, keyframe->isVisible()); ASSERT_EQ(true, keyframe->isAddBlendEnabled()); ASSERT_EQ(false, keyframe->isPhysicsEnabled()); ASSERT_EQ(1, keyframe->physicsStillMode()); ASSERT_FLOAT_EQ(0.42f, keyframe->edgeWidth()); ASSERT_TRUE(CompareVector(Color(0.4, 0.3, 0.2, 0.1), keyframe->edgeColor())); } } else { ASSERT_EQ(0, motion->countKeyframes(IKeyframe::kModelKeyframe)); } } static void TestProjectMotion(const IMotion *motion) { if (motion->type() == IMotion::kMVDMotion) { ASSERT_EQ(2, motion->countKeyframes(IKeyframe::kProjectKeyframe)); { const IProjectKeyframe *keyframe = motion->findProjectKeyframeRefAt(0); ASSERT_EQ(IKeyframe::TimeIndex(1), keyframe->timeIndex()); ASSERT_FLOAT_EQ(9.8f, keyframe->gravityFactor()); ASSERT_TRUE(CompareVector(Vector3(0.1, 0.2, 0.3), keyframe->gravityDirection())); ASSERT_EQ(0, keyframe->shadowMode()); ASSERT_FLOAT_EQ(0.24f, keyframe->shadowDepth()); ASSERT_FLOAT_EQ(0.42f, keyframe->shadowDistance()); } { const IProjectKeyframe *keyframe = motion->findProjectKeyframeRefAt(1); ASSERT_EQ(IKeyframe::TimeIndex(2), keyframe->timeIndex()); ASSERT_FLOAT_EQ(8.9f, keyframe->gravityFactor()); ASSERT_TRUE(CompareVector(Vector3(0.3, 0.1, 0.2), keyframe->gravityDirection())); ASSERT_EQ(1, keyframe->shadowMode()); ASSERT_FLOAT_EQ(0.42f, keyframe->shadowDepth()); ASSERT_FLOAT_EQ(0.24f, keyframe->shadowDistance()); } } else { ASSERT_EQ(0, motion->countKeyframes(IKeyframe::kProjectKeyframe)); } } } TEST(ProjectTest, Load) { Delegate delegate; Encoding encoding(0); Factory factory(&encoding); XMLProject project(&delegate, &factory, true); /* duplicated UUID doesn't allow */ ASSERT_FALSE(XMLProject(&delegate, &factory, true).load("../../docs/project_uuid_dup.xml")); ASSERT_TRUE(project.load("../../docs/project.xml")); ASSERT_FALSE(project.isDirty()); ASSERT_STREQ("0.1", project.version().c_str()); ASSERT_EQ(vsize(4), project.modelUUIDs().size()); ASSERT_EQ(vsize(3), project.motionUUIDs().size()); TestGlobalSettings(project); TestLocalSettings(project); /* VMD motion for model */ IMotion *motion = project.findMotion(kMotion1UUID); ASSERT_EQ(IMotion::kVMDMotion, motion->type()); ASSERT_EQ(project.findModel(kModel1UUID), motion->parentModelRef()); TestBoneMotion(motion, false); TestMorphMotion(motion); TestCameraMotion(motion, false); TestLightMotion(motion); TestEffectMotion(motion); TestModelMotion(motion); TestProjectMotion(motion); /* MVD motion */ IMotion *motion2 = project.findMotion(kMotion2UUID); ASSERT_EQ(IMotion::kMVDMotion, motion2->type()); ASSERT_EQ(project.findModel(kModel2UUID), motion2->parentModelRef()); TestBoneMotion(motion2, true); TestMorphMotion(motion2); TestCameraMotion(motion2, true); TestLightMotion(motion2); TestEffectMotion(motion2); TestModelMotion(motion2); TestProjectMotion(motion2); /* VMD motion for asset */ IMotion *motion3 = project.findMotion(kMotion3UUID); ASSERT_EQ(IMotion::kVMDMotion, motion3->type()); ASSERT_EQ(project.findModel(kAsset2UUID), motion3->parentModelRef()); TestBoneMotion(motion3, false); TestMorphMotion(motion3); } TEST(ProjectTest, Save) { Delegate delegate; Encoding encoding(0); Factory factory(&encoding); XMLProject project(&delegate, &factory, true); ASSERT_TRUE(project.load("../../docs/project.xml")); QTemporaryFile file; file.open(); file.setAutoRemove(true); project.setDirty(true); project.save(file.fileName().toUtf8()); ASSERT_FALSE(project.isDirty()); XMLProject project2(&delegate, &factory, true); ASSERT_TRUE(project2.load(file.fileName().toUtf8())); QString s; s.sprintf("%.1f", XMLProject::formatVersion()); ASSERT_STREQ(qPrintable(s), project2.version().c_str()); ASSERT_EQ(vsize(4), project2.modelUUIDs().size()); ASSERT_EQ(vsize(3), project2.motionUUIDs().size()); TestGlobalSettings(project2); TestLocalSettings(project2); /* VMD motion for model */ IMotion *motion = project2.findMotion(kMotion1UUID); ASSERT_EQ(project2.findModel(kModel1UUID), motion->parentModelRef()); ASSERT_EQ(IMotion::kVMDMotion, motion->type()); TestBoneMotion(motion, false); TestMorphMotion(motion); TestCameraMotion(motion, false); TestLightMotion(motion); TestEffectMotion(motion); TestModelMotion(motion); TestProjectMotion(motion); /* MVD motion */ IMotion *motion2 = project2.findMotion(kMotion2UUID); ASSERT_EQ(IMotion::kMVDMotion, motion2->type()); ASSERT_EQ(project2.findModel(kModel2UUID), motion2->parentModelRef()); TestBoneMotion(motion2, true); TestMorphMotion(motion2); TestCameraMotion(motion2, true); TestLightMotion(motion2); TestEffectMotion(motion2); TestModelMotion(motion2); TestProjectMotion(motion2); /* VMD motion for asset */ IMotion *motion3 = project.findMotion(kMotion3UUID); ASSERT_EQ(IMotion::kVMDMotion, motion3->type()); ASSERT_EQ(project.findModel(kAsset2UUID), motion3->parentModelRef()); TestBoneMotion(motion3, false); TestMorphMotion(motion3); } TEST(ProjectTest, HandleAssets) { const QString &uuid = QUuid::createUuid().toString(); Delegate delegate; Encoding encoding(0); Factory factory(&encoding); XMLProject project(&delegate, &factory, true); QScopedPointer<IModel> asset(factory.newModel(IModel::kAssetModel)); IModel *model = asset.data(); /* before adding an asset to the project */ ASSERT_FALSE(project.containsModel(model)); ASSERT_EQ(XMLProject::kNullUUID, project.modelUUID(0)); project.addModel(model, 0, uuid.toStdString(), 0); /* after adding an asset to the project */ ASSERT_TRUE(project.isDirty()); ASSERT_TRUE(project.containsModel(model)); /* reference will be null because render engine instance is not passed */ ASSERT_EQ(static_cast<Scene *>(0), model->parentSceneRef()); ASSERT_EQ(vsize(1), project.modelUUIDs().size()); ASSERT_EQ(uuid.toStdString(), project.modelUUID(model)); ASSERT_EQ(model, project.findModel(uuid.toStdString())); /* finding inexists asset should returns null */ ASSERT_EQ(static_cast<IModel*>(0), project.findModel(XMLProject::kNullUUID)); project.removeModel(model); ASSERT_EQ(static_cast<Scene *>(0), model->parentSceneRef()); /* finding removed asset should returns null */ ASSERT_FALSE(project.containsModel(model)); ASSERT_EQ(vsize(0), project.modelUUIDs().size()); ASSERT_TRUE(project.isDirty()); project.setDirty(false); /* removing removed asset should not be dirty */ project.removeModel(model); ASSERT_FALSE(project.isDirty()); model = asset.take(); /* deleting removed asset should do nothing */ project.deleteModel(model); ASSERT_FALSE(model); } TEST(ProjectTest, HandleModels) { const QString &uuid = QUuid::createUuid().toString(); Delegate delegate; Encoding encoding(0); Factory factory(&encoding); XMLProject project(&delegate, &factory, true); QScopedPointer<IModel> modelPtr(factory.newModel(IModel::kPMDModel)); IModel *model = modelPtr.data(); /* before adding a model to the project */ ASSERT_FALSE(project.containsModel(model)); ASSERT_EQ(XMLProject::kNullUUID, project.modelUUID(0)); project.addModel(model, 0, uuid.toStdString(), 0); /* before adding a model to the project */ ASSERT_TRUE(project.isDirty()); ASSERT_TRUE(project.containsModel(model)); /* reference will be null because render engine instance is not passed */ ASSERT_EQ(static_cast<Scene *>(0), model->parentSceneRef()); ASSERT_EQ(vsize(1), project.modelUUIDs().size()); ASSERT_EQ(uuid.toStdString(), project.modelUUID(model)); ASSERT_EQ(model, project.findModel(uuid.toStdString())); /* finding inexists model should returns null */ ASSERT_EQ(static_cast<IModel*>(0), project.findModel(XMLProject::kNullUUID)); project.removeModel(model); ASSERT_EQ(static_cast<Scene *>(0), model->parentSceneRef()); /* finding removed model should returns null */ ASSERT_FALSE(project.containsModel(model)); ASSERT_EQ(vsize(0), project.modelUUIDs().size()); ASSERT_TRUE(project.isDirty()); project.setDirty(false); /* removing removed model should not be dirty */ project.removeModel(model); ASSERT_FALSE(project.isDirty()); model = modelPtr.take(); /* deleting removed model should do nothing */ project.deleteModel(model); ASSERT_FALSE(model); } TEST(ProjectTest, HandleMotions) { const QString &uuid = QUuid::createUuid().toString(); Delegate delegate; Encoding encoding(0); Factory factory(&encoding); XMLProject project(&delegate, &factory, true); QScopedPointer<IMotion> motionPtr(factory.newMotion(IMotion::kVMDMotion, 0)); IMotion *motion = motionPtr.data(); /* before adding a motion to the project */ ASSERT_FALSE(project.containsMotion(motion)); ASSERT_EQ(XMLProject::kNullUUID, project.motionUUID(0)); project.addMotion(motion, uuid.toStdString()); /* after adding a motion to the project */ ASSERT_TRUE(project.isDirty()); ASSERT_TRUE(project.containsMotion(motion)); ASSERT_EQ(motion, project.findMotion(uuid.toStdString())); /* finding inexists motion should returns null */ ASSERT_EQ(static_cast<IMotion*>(0), project.findMotion(XMLProject::kNullUUID)); project.setDirty(false); /* finding removed motion should returns null */ project.removeMotion(motion); ASSERT_FALSE(project.containsMotion(motion)); ASSERT_TRUE(project.isDirty()); project.setDirty(false); /* removing removed motion should not be dirty */ project.removeMotion(motion); ASSERT_FALSE(project.isDirty()); } TEST(ProjectTest, HandleNullUUID) { Delegate delegate; Encoding encoding(0); Factory factory(&encoding); XMLProject project(&delegate, &factory, true); QScopedPointer<IModel> asset(factory.newModel(IModel::kAssetModel)); IModel *model = asset.data(); /* null model can be added */ project.addModel(model, 0, XMLProject::kNullUUID, 0); /* reference will be null because render engine instance is not passed */ ASSERT_EQ(static_cast<Scene *>(0), model->parentSceneRef()); ASSERT_EQ(vsize(1), project.modelUUIDs().size()); /* and null model can be removed */ project.removeModel(model); ASSERT_EQ(vsize(0), project.modelUUIDs().size()); model = asset.take(); project.deleteModel(model); ASSERT_FALSE(model); QScopedPointer<IModel> modelPtr(factory.newModel(IModel::kPMDModel)); model = modelPtr.data(); /* null model can be added */ project.addModel(model, 0, XMLProject::kNullUUID, 0); /* reference will be null because render engine instance is not passed */ ASSERT_EQ(0, model->parentSceneRef()); ASSERT_EQ(vsize(1), project.modelUUIDs().size()); /* and null model can be removed */ project.removeModel(model); ASSERT_EQ(vsize(0), project.modelUUIDs().size()); model = modelPtr.take(); project.deleteModel(model); ASSERT_FALSE(model); QScopedPointer<IMotion> motionPtr(factory.newMotion(IMotion::kVMDMotion, 0)); IMotion *motion = motionPtr.data(); /* null motion can be added */ project.addMotion(motion, XMLProject::kNullUUID); ASSERT_EQ(vsize(1), project.motionUUIDs().size()); /* and null motion can be removed */ project.removeMotion(motion); ASSERT_EQ(vsize(0), project.motionUUIDs().size()); modelPtr.reset(factory.newModel(IModel::kPMDModel)); model = modelPtr.data(); motionPtr.reset(factory.newMotion(IMotion::kVMDMotion, 0)); motion = motionPtr.data(); /* duplicated null motion should be integrated into one */ project.addModel(model, 0, XMLProject::kNullUUID, 0); project.addMotion(motion, XMLProject::kNullUUID); project.removeMotion(motion); ASSERT_EQ(vsize(0), project.motionUUIDs().size()); project.removeModel(model); model = modelPtr.take(); project.deleteModel(model); ASSERT_FALSE(model); } TEST(ProjectTest, SaveSceneState) { Delegate delegate; Encoding encoding(0); Factory factory(&encoding); XMLProject project(&delegate, &factory, true); ICamera *cameraRef = project.cameraRef(); cameraRef->setAngle(Vector3(0.1, 0.2, 0.3)); cameraRef->setDistance(4.5); cameraRef->setFov(5.6); cameraRef->setLookAt(Vector3(0.7, 0.8, 0.9)); ILight *lightRef = project.lightRef(); lightRef->setColor(Vector3(0.11, 0.22, 0.33)); lightRef->setDirection(Vector3(0.44, 0.55, 0.66)); QTemporaryFile file; file.open(); file.setAutoRemove(true); project.save(file.fileName().toUtf8()); XMLProject project2(&delegate, &factory, true); ASSERT_TRUE(project2.load(file.fileName().toUtf8())); ASSERT_TRUE(CompareVector(project2.cameraRef()->angle(), cameraRef->angle())); ASSERT_FLOAT_EQ(project2.cameraRef()->distance(), cameraRef->distance()); ASSERT_FLOAT_EQ(project2.cameraRef()->fov(), cameraRef->fov()); ASSERT_TRUE(CompareVector(project2.cameraRef()->lookAt(), cameraRef->lookAt())); ASSERT_TRUE(CompareVector(project2.lightRef()->color(), lightRef->color())); ASSERT_TRUE(CompareVector(project2.lightRef()->direction(), lightRef->direction())); } class ProjectModelTest : public TestWithParam<IModel::Type> {}; TEST_P(ProjectModelTest, SaveSceneState) { Delegate delegate; Encoding::Dictionary dictionary; Encoding encoding(&dictionary); Factory factory(&encoding); XMLProject project(&delegate, &factory, true); IModel::Type modelType = GetParam(); QScopedPointer<IModel> modelPtr(factory.newModel(modelType)), model2Ptr(factory.newModel(modelType)); QScopedPointer<IRenderEngine> enginePtr(new MockIRenderEngine()), engine2Ptr(new MockIRenderEngine()); modelPtr->setEdgeColor(Color(0.1, 0.2, 0.3, 1.0)); modelPtr->setEdgeWidth(0.4); modelPtr->setOpacity(0.5); modelPtr->setWorldTranslation(Vector3(0.11, 0.22, 0.33)); modelPtr->setWorldOrientation(Quaternion(0.44, 0.55, 0.66, 0.77)); modelPtr->setParentModelRef(model2Ptr.data()); project.addModel(modelPtr.data(), enginePtr.take(), kModel1UUID, 0); project.addModel(model2Ptr.take(), engine2Ptr.take(), kModel2UUID, 0); IModel *model = modelPtr.take(); QTemporaryFile file; file.open(); file.setAutoRemove(true); project.save(file.fileName().toUtf8()); XMLProject project2(&delegate, &factory, true); ASSERT_TRUE(project2.load(file.fileName().toUtf8())); const IModel *model2 = project2.findModel(kModel1UUID); ASSERT_TRUE(CompareVector(model2->edgeColor(), model->edgeColor())); ASSERT_FLOAT_EQ(model2->edgeWidth(), model->edgeWidth()); ASSERT_FLOAT_EQ(model2->opacity(), model->opacity()); ASSERT_TRUE(CompareVector(model2->worldTranslation(), model->worldTranslation())); ASSERT_TRUE(CompareVector(model2->worldOrientation(), model->worldOrientation())); ASSERT_EQ(model2->parentModelRef(), project2.findModel(kModel2UUID)); /* FIXME: parentBoneRef test */ } INSTANTIATE_TEST_CASE_P(ProjectInstance, ProjectModelTest, Values(IModel::kAssetModel, IModel::kPMDModel, IModel::kPMXModel));
[ "hikarin.jp@gmail.com" ]
hikarin.jp@gmail.com
0e165295d1586c14b2a693b863682b10e0be9cd6
b22588340d7925b614a735bbbde1b351ad657ffc
/athena/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/MuonSimEventTPCnv/TGCSimHitCollectionCnv_p2.h
f1d392ac3ec988020527d6fab80f5f43c9853dc5
[]
no_license
rushioda/PIXELVALID_athena
90befe12042c1249cbb3655dde1428bb9b9a42ce
22df23187ef85e9c3120122c8375ea0e7d8ea440
refs/heads/master
2020-12-14T22:01:15.365949
2020-01-19T03:59:35
2020-01-19T03:59:35
234,836,993
1
0
null
null
null
null
UTF-8
C++
false
false
922
h
/* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef TGCSimHitCOLLECTIONCNV_P2_H #define TGCSimHitCOLLECTIONCNV_P2_H #include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" #include "MuonSimEvent/TGCSimHitCollection.h" #include "TGCSimHitCollection_p2.h" class TGCSimHitCollectionCnv_p2 : public T_AthenaPoolTPCnvBase<TGCSimHitCollection, Muon::TGCSimHitCollection_p2> { public: TGCSimHitCollectionCnv_p2() {}; virtual TGCSimHitCollection* createTransient(const Muon::TGCSimHitCollection_p2* persObj, MsgStream &log); virtual void persToTrans(const Muon::TGCSimHitCollection_p2* persCont, TGCSimHitCollection* transCont, MsgStream &log) ; virtual void transToPers(const TGCSimHitCollection* transCont, Muon::TGCSimHitCollection_p2* persCont, MsgStream &log) ; }; #endif // TGCSimHitCOLLECTIONCNV_P2_H
[ "rushioda@lxplus754.cern.ch" ]
rushioda@lxplus754.cern.ch
3040c53b51b2f156799b1d6c45e69eb21c16a858
7da1c227214c48d9934c8aea2e8c6ec25fa77bf2
/cqtprodb.cpp
e8ac9a4cec9e79744ed96bb612c316cf83dcd087
[]
no_license
SnakStar/QT-200
732261058ba03493b0f7ffaa4215e47a41748f8a
0e7dd3a6f0707392c06c3b589b6fc82c13a985ec
refs/heads/master
2020-04-05T13:35:32.808063
2018-04-18T06:15:28
2018-04-18T06:15:28
83,541,325
1
0
null
null
null
null
UTF-8
C++
false
false
9,411
cpp
/******************************************************************* * Copyright(c) 2000-2020 Company Name * All rights reserved. * * 文件名称: cqtprodb.cpp * 简要描述: 数据库实现文件,实现数据库连接、表格创建、sql语句执行 * * 创建日期: 2016-5-21 * 作者: HuaT * 说明: * * 修改日期: * 作者: * 说明: ******************************************************************/ #include "cqtprodb.h" CQtProDB::CQtProDB() { } CQtProDB::~CQtProDB() { if(m_query){ m_query->clear(); delete m_query; m_query = NULL; } } /* void CQtProDB::ShowTableData(QString strSql) { if(m_query->exec(strSql)){ int nRow = 0; m_tableWidget->setRowCount(0); while(m_query->next()){ m_tableWidget->insertRow(nRow); for(int i=1; i<m_query->record().count(); i++){ if(i == 1){ QTableWidgetItem* item = new QTableWidgetItem(); item->setCheckState(Qt::Unchecked); item->setText(m_query->value(i).toString()); m_tableWidget->setItem(nRow,0,item); //m_tableWidget->setItem(nRow,i-1,new QTableWidgetItem(m_query->value(i).toString())); continue; } m_tableWidget->setItem(nRow,i-1,new QTableWidgetItem(m_query->value(i).toString())); } nRow++; } } } */ /******************************************************** *@Name:ConnectDB *@Author:HuaT *@Description:连接指定路径数据库 *@Param:数据库路径 *@Return:连接数据库是否成功 *@Version:1.0 *@Date:2016-5-13 ********************************************************/ bool CQtProDB::ConnectDB(QString dbPath) { m_db = QSqlDatabase::addDatabase("QSQLITE"); m_db.setDatabaseName(dbPath); if(m_db.open()){ if(m_db.isValid()){ m_query = new QSqlQuery(m_db); if(!CreateTable()){ qDebug() << "CQtProDB::ConnectDB : create table fail!"; return false; } return true; } } return false; } /******************************************************** *@Name:connectDB *@Author:HuaT *@Description:连接默认数据库,位置为当前目录下的qtdb.db *@Param:无 *@Return:连接是否成功 *@Version:1.0 *@Date:2016-5-13 ********************************************************/ bool CQtProDB::ConnectDB() { //QString CurrentPath = QDir::currentPath(); m_db = QSqlDatabase::addDatabase("QSQLITE"); QString dbFilePath; //dbFilePath = CurrentPath + "/qtdb.db"; dbFilePath = "/home/root/qt200/qtdb.db"; m_db.setDatabaseName(dbFilePath); if(m_db.open()){ if(m_db.isValid()){ m_query = new QSqlQuery(m_db); if(!CreateTable()){ qDebug() << "CQtProDB::ConnectDB : create table fail!" << m_query->lastError(); return false; } return true; } } return false; } /******************************************************** *@Name:GetSqlQuery *@Author:HuaT *@Description:获取数据库查询对象 *@Param:无 *@Return:返回数据库查询实例对象 *@Version:1.0 *@Date:2016-5-13 ********************************************************/ QSqlQuery *CQtProDB::GetSqlQuery() { return m_query; } /******************************************************** *@Name: GetDatabase *@Author:HuaT *@Description: 获取数据库实例 *@Param:无 *@Return:返回数据库实例对象 *@Version:1.0 *@Date:2016-5-13 ********************************************************/ QSqlDatabase *CQtProDB::GetDatabase() { return &m_db; } /******************************************************** *@Name: Exec *@Author: HuaT *@Description: 执行SQL语句 *@Param: SQL语句 *@Return: 执行是否成功 *@Version: 1.0 *@Date: 2016-5-13 ********************************************************/ bool CQtProDB::Exec(QString strSql) { return m_query->exec(strSql); } /******************************************************** *@Name: ExecQuery *@Author: HuaT *@Description: 执行SQL查询语句,返回查询结果 *@Param: SQL语句 *@Return: 查询结果列表 *@Version: 1.0 *@Date: 2016-12-29 ********************************************************/ QStringList CQtProDB::ExecQuery(QString strSql) { QStringList listResult; if(!m_query->exec(strSql)){ return listResult; }else{ while(m_query->next()){ for(int i=0; i<m_query->record().count(); i++){ listResult.append(m_query->value(i).toString()); } } return listResult; } } /************************************ *Name: LastError *Author: HuaT *Description: 返回数据库操作时的错误信息 *Param: 无 *Return: 错误信息内容 *Version: 1.0 *Date: 2017-3-3 ************************************/ QString CQtProDB::LastError() { return m_query->lastError().text(); } /************************************ *Name:CreateTable *Author:HuaT *Description:检测数据库中是否有指定表,如果没有则新建 *Param:无 *Return:创建数据库表是否成功,有一个表创建失败返回FALSE *Version:1.0 *Date:2016-5-13 ************************************/ bool CQtProDB::CreateTable() { bool bOK1 = false; bool bOK2 = false; bool bOK3 = false; bool bOK4 = false; bool bOK5 = false; bool bOK6 = false; bool bOK7 = false; bool bOK8 = false; //病人信息表 QString strCreateTable = "create table if not exists \ Patient(ID INTEGER PRIMARY KEY AUTOINCREMENT,\ Number integer,\ Name text,\ Age smallint,\ Sex integer,\ Item text,\ Result text,\ TestDate datetime,\ RawData text,\ Channel integer)"; bOK1 = m_query->exec(strCreateTable); if(!bOK1){ qDebug()<<"Patient:"<<m_query->lastError().text(); } //日志表 strCreateTable = "create table if not exists \ Log(ID INTEGER PRIMARY KEY AUTOINCREMENT,\ LogType integer,\ TestNumbel integer,\ LogContent text,\ LogDate datetime)"; bOK2 = m_query->exec(strCreateTable); if(!bOK2){ qDebug()<<"Log:"<<m_query->lastError().text(); } //质控结果表 strCreateTable = "create table if not exists \ Qc(ID INTEGER PRIMARY KEY AUTOINCREMENT,\ Item text,\ BatchNo text,\ Result text,\ RawData text,\ CheckDate datetime)"; bOK3 = m_query->exec(strCreateTable); if(!bOK3){ qDebug()<<"Qc:"<<m_query->lastError().text(); } /*strCreateTable = "create table if not exists \ RenfValue(ID INTEGER PRIMARY KEY AUTOINCREMENT,\ Items text,\ Value text,\ Age smallint,\ Sex text)";*/ //结果参考值表 strCreateTable = "create table if not exists \ RenfValue(Item text,\ Value text,\ AgeLow text,\ AgeHight text,\ Sex smallint)"; bOK4 = m_query->exec(strCreateTable); if(!bOK4){ qDebug()<<"RenfValue:"<<m_query->lastError().text(); } //ID卡表 strCreateTable = "create table if not exists \ IDCard(ID INTEGER PRIMARY KEY AUTOINCREMENT,\ CardNo integer,\ BarCode text,\ Item text,\ BatchNumber text,\ CardNumber text,\ ValidDate datetime,\ InputTime datatime,\ Data text)"; bOK5 = m_query->exec(strCreateTable); if(!bOK5){ qDebug()<<"IDCard:"<<m_query->lastError().text(); } //质控参考值表 strCreateTable = "create table if not exists \ QCRenfValue(ID INTEGER PRIMARY KEY AUTOINCREMENT,\ Item text,\ BatchNo text,\ Upper text,\ Lower text,\ InputTime datetime)"; bOK6 = m_query->exec(strCreateTable); if(!bOK6){ qDebug()<<m_query->lastError().text(); } //测试项目记录表 strCreateTable = "create table if not exists \ ItemType(ID INTEGER PRIMARY KEY AUTOINCREMENT,\ Item text)"; bOK7 = m_query->exec(strCreateTable); if(!bOK7){ qDebug()<<m_query->lastError().text(); } //创建索引 QString strIndex; strIndex = "Create INDEX IF NOT EXISTS index_Number ON Patient(number,testdate)"; bOK8 = m_query->exec(strIndex); if(!bOK8){ qDebug()<<m_query->lastError().text(); } return bOK1&&bOK2&&bOK3&&bOK4&&bOK5&&bOK6&&bOK7&&bOK8; }
[ "164348931@qq.com" ]
164348931@qq.com
650c8adaa75499f88e42b2e5e363e3b89525c6dc
81f7c7cb5b83380bb326207f3aaf142340080c34
/draw.cpp
28735df28e349b409b0f5f13310e1caf71ea8943
[]
no_license
piotrcholody/Interference
f24c1344355ca1172cdde9f5bd7afd3a257bc43f
75034deeae2f7a254f96290ca5d87b745b71885a
refs/heads/master
2021-04-28T11:14:17.871228
2018-02-19T16:10:20
2018-02-19T16:10:20
122,086,595
2
0
null
null
null
null
UTF-8
C++
false
false
2,655
cpp
#include "draw.h" struct Point { double x; double y; }; static double points[300][300]; static Point coord[300][300]; static std::vector<Generator> interference; void Draw::restart() { interference.clear(); } void Draw::source(int x, int y, double t, double freq, double amp, double wvl) { int i, j; for(i = 0; i < 300; i++) { for(j = 0; j < 300; j++) { if(abs(coord[i][j].x - x) == 0 && abs(coord[i][j].y - y) == 0) { break; } } if(abs(coord[i][j].x - x) == 0 && abs(coord[i][j].y - y) == 0) { break; } } if (i < 300 && j < 300) { interference.push_back(Generator(i, j, freq/10.0, amp, wvl, t)); } } void Draw::generateFunction(double t) { for(int i = 0;i < 300; i++) { for(int j = 0; j < 300; j++) { points[i][j] = 0; for(std::vector<Generator>::iterator iter = interference.begin(); iter != interference.end(); ++iter) { points[i][j] += iter->returnValue(i, j, t); } } } } void Draw::draw(double hor, wxDC* dc, double x, double y, double vert, double t) { dc->Clear(); wxPen pen; pen.SetWidth(3); Vector4 vec; Matrix4 matrix(vert, hor); generateFunction(t); double maximum = 0; int colour; for(std::vector<Generator>::iterator iter = interference.begin(); iter != interference.end(); ++iter) { maximum += iter->returnAmplitude(); } if(hor == 100 || hor < 50) { for(int i = 299, k = 0; k < 300; i--, k++) { for(int j = 299, m = 0; m < 300; j--, m++) { vec.set(150 - i, 150 - j, points[i][j]); vec = matrix * vec; colour = (points[i][j] / maximum + 1) * 100; pen.SetColour(wxColour(colour, colour, colour)); dc->SetPen(pen); dc->DrawPoint(vec.data[0] + x/2, vec.data[1] + y/2); coord[i][j].x = vec.data[0] + x/2; coord[i][j].y = vec.data[1] + y/2; } } } else { for(int i = 0, k = 0; k < 300; i++, k++) { for(int j = 0, m = 0; m < 300; j++, m++) { vec.set(150 - i, 150 - j, points[i][j]); vec = matrix * vec; colour = (points[i][j] / maximum + 1)*100; pen.SetColour(wxColour(colour, colour, colour)); dc->SetPen(pen); dc->DrawPoint(vec.data[0] + x/2, vec.data[1] + y/2); coord[i][j].x = vec.data[0] + x/2; coord[i][j].y = vec.data[1] + y/2; } } } }
[ "noreply@github.com" ]
noreply@github.com
ce729e0433caa939b5283fb6b639316e2c2d1fb0
73bc9cdb7ea210c6d34c74f0449f8d1a2a25d478
/zouba/src/logic/routefinder.h
562d24ade8795c1b4755948ae8448c2258e20843
[]
no_license
nikobockerman/AtoBe
ba127f9b06f0e1ee3c81051736188f8f36796d29
84ba06ea18ec63198b7d5abe1b9e42e49cff1a8f
refs/heads/master
2016-09-05T11:48:50.104758
2011-07-10T16:24:23
2011-07-10T16:24:23
2,026,126
0
0
null
null
null
null
UTF-8
C++
false
false
737
h
#ifndef ROUTEFINDER_H #define ROUTEFINDER_H #include <QThread> #include <QMutex> #include "location.h" #include "routenew.h" #include "locationfinder.h" class RouteFinder : public QObject { Q_OBJECT public: explicit RouteFinder(const Location &from, const Location &to, QObject *parent = 0); ~RouteFinder(); RouteNew* getRoute(int index) const; int getNumberOfRoutes() const; signals: void finished(); public slots: private slots: void fromLocationFound(); void toLocationFound(); void requestFinished(); private: void startRouteSearch(); Location *from, *to; LocationFinder *fromFinder, *toFinder; QNetworkReply *reply; QList<RouteNew*> routes; }; #endif // ROUTENEW_H
[ "niko@nikosdesktop.(none)" ]
niko@nikosdesktop.(none)
b5de07bb4b205fe0c5ea3c562a64d2f2afa0893e
7bad63752ca277e79ecb89336d2b854ec6870107
/camdroid/frameworks/av/services/display/libdisplayservice/DisplayClient.h
58db03ced29055551a26cd5882d1a4a548b53aa4
[]
no_license
wangweigang0/-v3s-camdriod
8da473ecdc22f18feba8a8ba409bafe0e4555f23
a4532cac0cea06cd1001ab602f30b2a13dbc74ed
refs/heads/master
2023-02-18T16:15:16.347672
2018-04-17T02:15:41
2018-04-17T02:15:41
329,496,374
1
3
null
null
null
null
UTF-8
C++
false
false
2,027
h
/* * Copyright (C) 2012 The Android Open Source Project * * 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. */ #ifndef ANDROID_SERVERS_DISPLAY_DISPLAYCLIENT_H #define ANDROID_SERVERS_DISPLAY_DISPLAYCLIENT_H #include "DisplayService.h" #include <hwdisplay.h> namespace android { class HwDisplay; class DisplayClient : public DisplayService::Client { public: // IDisplay interface (see IDisplay for details) virtual void disconnect(); virtual status_t connect(const sp<IDisplayClient>& client); // Interface used by DisplayService DisplayClient(const sp<DisplayService>& displayService, const sp<IDisplayClient>& displayClient, int displayId, int clientPid, int servicePid); ~DisplayClient(); status_t initialize(); status_t requestSurface(const unsigned int sur); status_t setPreviewBottom(const unsigned int hlay); status_t setPreviewTop(const unsigned int hlay); status_t releaseSurface(const unsigned int hlay); status_t setPreviewRect(const unsigned int pRect); status_t exchangeSurface(const unsigned int hlay1, const unsigned int hlay2, const int otherOnTop); status_t otherScreen(const int screen, const unsigned int hlay1, const unsigned int hlay2); status_t openSurface(const unsigned int hlay, const int open); status_t clearSurface(const unsigned int hlay1); private: status_t checkPid() const; mutable Mutex mLock; HwDisplay* mHwDisplay; int mHlay; }; } #endif
[ "252915145@qq.com" ]
252915145@qq.com
785ab4722748c20cfeec66b8b835a30daed13c98
0e44257aa418a506b1bb2f76c715e403cb893f13
/NWNXLib/API/Mac/API/curl_tlssessioninfo.cpp
58173d97aef1b5f00cd6c8bc773ff796fd3c3117
[ "MIT" ]
permissive
Silvard/nwnxee
58bdfa023348edcc88f9d3cfd9ff77fdd6194058
0989acb86e4d2b2bdcf25f6eabc16df7a72fb315
refs/heads/master
2020-04-15T22:04:43.925619
2019-10-10T14:18:53
2019-10-10T14:18:53
165,058,523
0
0
MIT
2019-10-10T14:18:57
2019-01-10T12:44:36
C++
UTF-8
C++
false
false
137
cpp
#include "curl_tlssessioninfo.hpp" #include "API/Functions.hpp" #include "Platform/ASLR.hpp" namespace NWNXLib { namespace API { } }
[ "liarethnwn@gmail.com" ]
liarethnwn@gmail.com
4cb500a2be3ea30040f521358bc61fe53f0031e1
e6f76906be471413914dfd744a5e523902044e72
/google/cloud/pubsub/ack_handler.cc
ed6fe7487c3395ab2279165c6043406e4c693d61
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
nschonni/google-cloud-cpp
82ae068adffc28a57b3b60e21b8a761c20138298
0f5e785f14fc21315d6c6fc98ace87da9182dbaa
refs/heads/main
2023-07-13T15:45:08.722409
2021-08-13T23:17:00
2021-08-13T23:17:00
396,100,461
1
0
Apache-2.0
2021-08-14T18:55:02
2021-08-14T18:55:02
null
UTF-8
C++
false
false
1,439
cc
// Copyright 2020 Google LLC // // 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. #include "google/cloud/pubsub/ack_handler.h" #include <type_traits> namespace google { namespace cloud { namespace pubsub { inline namespace GOOGLE_CLOUD_CPP_PUBSUB_NS { static_assert(!std::is_copy_assignable<AckHandler>::value, "AckHandler should not be CopyAssignable"); static_assert(!std::is_copy_constructible<AckHandler>::value, "AckHandler should not be CopyConstructible"); static_assert(std::is_move_assignable<AckHandler>::value, "AckHandler should be MoveAssignable"); static_assert(std::is_move_constructible<AckHandler>::value, "AckHandler should be MoveConstructible"); AckHandler::~AckHandler() { if (impl_) impl_->nack(); } AckHandler::Impl::~Impl() = default; } // namespace GOOGLE_CLOUD_CPP_PUBSUB_NS } // namespace pubsub } // namespace cloud } // namespace google
[ "noreply@github.com" ]
noreply@github.com
63816126786e75ba4bfd0217797e615f2b864ae1
fbf7ecb58e438b479f89e2e4ca919a4b0d7e17fa
/Midnight/Src/Audio/cute_audio/soundCute.hpp
be288ceffecc329dc483be3d55f517a37606b5de
[ "MIT" ]
permissive
camolezi/Midnight-Engine
4876487d32f59f71ce13fa48ab3599546fc11c8e
fb2e3742447381f777dcb72558964946dd3a92f3
refs/heads/master
2020-12-01T19:57:38.975906
2020-07-18T20:51:23
2020-07-18T20:56:48
230,748,905
3
0
MIT
2020-07-18T20:56:50
2019-12-29T12:43:40
C++
UTF-8
C++
false
false
491
hpp
#ifndef SOUNDCUTE_SOUND #define SOUNDCUTE_SOUND #include <audioEngine.hpp> #include <string> #include <cute_sound.h> namespace MN { class SoundCute : public Sound{ public: void loadSound(const std::string& path) override; SoundCute(const std::string& path) { loadSound(path); } void* getSoundData() override; void reContext() override; void setVolume(float volume) override; ~SoundCute(); private: cs_loaded_sound_t audioFile; cs_playing_sound_t def; }; } #endif
[ "camolezi@usp.br" ]
camolezi@usp.br
f677568f1286ca15c05b82bfe5195a8935a277b3
4f0802c231661c95aa3f1132de49156a74549f09
/LargeImage.cpp
dda162b86d5dad5fa71533e35abd8f5c2ad4a409
[]
no_license
seanlanepgh/ObjectOrientatedFindingWally
6e15e0951d34ee365ae33969c848895649e3ea7a
cd46fd6be9403b7320b4314f789e283b6c561121
refs/heads/master
2020-03-19T07:05:09.332212
2018-06-04T21:12:11
2018-06-04T21:12:11
136,083,481
0
0
null
null
null
null
UTF-8
C++
false
false
7,644
cpp
#include "LargeImage.h" //LargeImage Constructor LargeImage::LargeImage(int rowSize, int columnSize, double *inputData, vector<MatchImage*>Matches) :BaseImage(rowSize, columnSize, inputData) { MatchImages = Matches; } //LargeImage Destructor LargeImage :: ~LargeImage() {}; //LargeImage Copy Constructor LargeImage::LargeImage(LargeImage& copyConstructor) { int row = copyConstructor.GetRow(); int col = copyConstructor.GetColumn(); this->SetRow(row); this->SetColumn(col); //Copys the baseImagedata over using the baseImageDataPointer for (int i = 0; i < row*col; i++) { this->baseImageDataPointer[i] = copyConstructor.baseImageDataPointer[i]; } //Copys the vector of MatchImages MatchImages = copyConstructor.MatchImages; } //getBlock function returns a block object pointer from the scene image that it is called by BaseImage* LargeImage::getBlock(int startRow, int endRow, int startColumn, int endColumn) { //Calculate rows and columns int rows = endRow - startRow; int columns = endColumn - startColumn; //Get the sceneColumn size int sceneColumn = this->GetColumn(); //Create new BaseImage block object pointer using rows and columns BaseImage *blockObjectPointer = new BaseImage(rows, columns); double* largeImageData = this->GetData();//Get the data from the large image double* block = new double[rows*columns]; blockObjectPointer->SetData(block); /*Loops through the rows and columns and gets elements from the large image and store them in the block object pointer data */ for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { // calcuates the index using this formula int index = (startRow + row) * sceneColumn + (startColumn + column); //Use operator overload to get the element from large image and store it in the block object pointer data blockObjectPointer->operator()(row, column, largeImageData[index]); } } return blockObjectPointer; }; //Function plots the outlines of the match image on the clutter scene image void LargeImage::plotOutlineOfMatch(int& startRow, int &endRow, int &startColumn, int& endColumn) { //Get the number of columns of the scene int largeColumn = this->GetColumn(); double*largeImageData = this->GetData(); //Loops through and does the left and right side of the outline of the match image and adds a 3 pixel width on these sides for (int row = startRow; row <= endRow; row++) { // calcuates the index using this formula int index = row * largeColumn + startColumn; //Set the value to 0 so it would be black on the image largeImageData[index] = 0; largeImageData[index + 1] = 0; largeImageData[index + 2] = 0; index = row * largeColumn + endColumn; largeImageData[index] = 0; largeImageData[index - 1] = 0; largeImageData[index - 2] = 0; } //Loops through and does the top and the bottom side of the outline of the match image for (int column = startColumn; column < endColumn; column++) { int index = startRow * largeColumn + column; largeImageData[index] = 0; index = endRow* largeColumn + column; largeImageData[index] = 0; } this->SetData(largeImageData); }; //Gets the disimilarity score and returns the sum without using the * and - operator overloads double LargeImage::SSD1(BaseImage *wally, BaseImage *block) { //This function finds wally in the cluttered scene double sum = 0; int rows = wally->GetRow(); int columns = wally->GetColumn(); /* Loops through the rows and columns of the wally compare image object pointer and the current block object pointer*/ for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { //Get the element value from the wally object pointer double elementValue = wally->operator()(row, column); /*Checks if the value is white. If is not white then do the calculation of the disimilarity score.This allows us to get a more accurate score as the wally compare image has lots of white in the background. Where as the location of wally in the cluttered scene has not got a white background. */ if (elementValue != 255) { /*Get the element value of from the block object pointer and substracts it from the wally object pointer element value*/ elementValue -= block->operator()(row, column); //Square the result of the substraction and adds it to create a disimilarity score elementValue *= elementValue; sum += elementValue; } } } return sum; } //Gets the disimilarity score and returns the sum using the * and - operator overloads double LargeImage::SSD2(BaseImage* wally, BaseImage* block) { //This function doesn't find wally in the cluttered scene double sum = 0; //Uses the - operator overload to take away the data in the wally object pointer by the block object pointer and create a new base image object pointer called diff BaseImage* diff = *wally - *block; //Uses the * operator overload to multiply the new base image object pointer by itself diff = *diff * *diff; int rows = diff->GetRow(); int columns = diff->GetColumn(); //Loop through the rows and columns to get the sum of each value in the new base image object pointer for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { sum += diff->operator()(row, column); } } return sum; }; //Sets the MatchImages void LargeImage::Set_MatchImages(vector<MatchImage*>&vectorOfMatchImages) { MatchImages = vectorOfMatchImages; }; //Gets the MatchImages vector<MatchImage*> LargeImage::Get_MatchImages() { return this->MatchImages; } //Compares and Sorts the Match Image object pointers void LargeImage::CompareandSort(MatchImage* Match , int numOfMatches) { //if the MatchImages vector has not reached the size of N matches if (MatchImages.size() < numOfMatches) { //Then push it into the MatchImages vector MatchImages.push_back(Match); } else { //If the MatchImages vector has N matches already then //Call CompareScore and then Bubble Sort functions CompareScore(Match, MatchImages,numOfMatches); BubbleSort(MatchImages); } } //Bubble Sort to sort the N match image object pointers by NNSScore in the MatchImages vector void LargeImage::BubbleSort(vector<MatchImage*> & data) { int length = data.size(); //Goes through and compares each of the pairs of the indexs for (int index = 0; index < length; ++index) { bool swapped = false;//Used bool to check if it data has been swapped for (int index2 = 0; index2 < length - (index + 1); ++index2) { double matchImageScore = data[index2]->Get_Score(); double matchImageScore2 = data[index2 + 1]->Get_Score(); //Compares the current index and the next indexs scores if (matchImageScore > matchImageScore2) { //If the first score is greater then call swap function swap(data, index2, index2 + 1); swapped = true;//Also use bool to show there was a swap } } if (!swapped) break; } } //Swap function void LargeImage::swap(vector<MatchImage*> & data, int matchImage1, int matchImage2) { //Swaps over the match image object pointers MatchImage* tempMatchImage = data[matchImage1]; data[matchImage1] = data[matchImage2]; data[matchImage2] = tempMatchImage; } //Function used to compare the disimilarity score void LargeImage::CompareScore(MatchImage*Match, vector<MatchImage*>&MatchImages ,int numOfMatches) { //If the new match score is less than the last score in the vector of MatchImages if (Match->Get_Score() < MatchImages[numOfMatches-1]->Get_Score()) { //Then add it to the last score position and replace it MatchImages[numOfMatches-1] = Match; } else { //else do nothing with it } }
[ "seanlane997@gmail.com" ]
seanlane997@gmail.com
569b01bbf27b2fc0d4778b62ce9ab1eb5dfcd3a0
83780d3582064951600799a61a1d03ec28df7ac7
/FGIST/src/touwenjianF.h
81139b9e042f75300d4d80b130b3844891979d97
[]
no_license
wozys/Team-homework-for-the-final-exam
faa1c489a7942ac61f6304979e748f6de0bb26f2
ea175babc619201ea4e70270477e2032c700ff3e
refs/heads/master
2021-05-14T01:54:49.565181
2018-01-07T16:27:18
2018-01-07T16:27:18
116,579,984
0
0
null
null
null
null
UTF-8
C++
false
false
475
h
#include <RcppArmadillo.h> #include<Rcpp.h> using namespace Rcpp; using namespace arma; double PenaltyF(double t,double lambda, double eta){ double p=0; if(fabs(t) < lambda/(1+eta)) p=-0.5*t*t+lambda*fabs(t); else p=0.5*eta*t*t+0.5*lambda*lambda/(1+eta); return p; } double ThetaholdingF(double& t, double& lambda, double& eta){ double HRholding; if(fabs(t) < lambda){ HRholding = 0 ; }else{ HRholding = t/(1+eta); } return HRholding; }
[ "zhouya@zhouyadeMacBook-Pro.local" ]
zhouya@zhouyadeMacBook-Pro.local
f0258687e550d1cb7cbb1a18ee1aecb37db6788a
9055fccba0dbb0019ff656d68c09dba8e8914621
/framework/C++/engine/Square.h
5eec0c14c4a7bd86bd554ca0241d5c8efbeafaa8
[]
no_license
lilezek/ActividadCodeCamp18
51cf2e7e3de51ee32cba6c9372b65a8c81725e05
ee6dd53876721cb03f9517e33330d25a781a7b92
refs/heads/master
2021-09-07T10:59:08.814509
2018-02-18T17:36:15
2018-02-18T17:36:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,083
h
#ifndef SQUARE_H_ #define SQUARE_H_ #include <vector> #include <unordered_set> #include "Location.h" /* struct for representing a square in the grid. */ struct Square { bool isVisible, isWater, isHill, isFood, alreadyMoved; int ant, hillPlayer; int theAnt; std::vector<int> deadAnts; std::unordered_set<Location> ownPresence; std::unordered_set<Location> enemyPresence; int danger; double influence; Square() { isVisible = isWater = isHill = isFood = 0; ant = hillPlayer = -1; theAnt = -1; influence = danger = 0; alreadyMoved = false; }; /** * Devuelve verdadero si se puede andar: no hay otra hormiga ni hay agua. */ bool isWalkable() const { return !isWater && ant == -1; } //resets the information for the square except water information void reset() { isVisible = 0; isHill = 0; isFood = 0; ant = hillPlayer = -1; theAnt = -1; deadAnts.clear(); ownPresence.clear(); enemyPresence.clear(); influence = danger = 0; alreadyMoved = false; }; }; #endif //SQUARE_H_
[ "devezek@gmail.com" ]
devezek@gmail.com
ca25ec751ba75c588128d5f3aaab709b8c2cd71f
4fa9a86ef8962b9e0a61edb7af031b16f4fc2cb5
/Tracer.h
3dcf1807ce2bcc197792eff1cc30ebc97b647c8f
[]
no_license
pawkrol/simple_raytracer
586e6576495473de47204f52b0f176f4f6966531
3abe0be74ad6e096164936a780a59cdbbd66e0c3
refs/heads/master
2020-03-07T07:00:51.059641
2018-04-12T17:15:12
2018-04-12T17:15:12
127,337,855
0
0
null
null
null
null
UTF-8
C++
false
false
346
h
#ifndef RIVAL_DEALER_TRACER_H #define RIVAL_DEALER_TRACER_H #include "math/Vector.h" #include "Screen.h" #include "Scene.h" #include "Shader.h" class Tracer { public: Vector* render(Screen screen, Scene scene, Shader shader); private: Vector trace(Scene scene, Ray ray, Shader shader, int depth); }; #endif //RIVAL_DEALER_TRACER_H
[ "pawkrol19@gmail.com" ]
pawkrol19@gmail.com
fecda15bcbadd5fdffbf701aecf470463899ff76
314f76c0f1a208af3e6edaabe79dcfd90d656742
/utils/utils.hpp
259daa2d171b670e5e4282a572f7ff95094a9182
[]
no_license
lxp2013/depth-aware-motion-deblurring
c870dcc71b5ea8f9c7bfb174719c9e11fd40ed96
52373cc9b3aa3289ad3d81a1a2fdff5e38d8cd94
refs/heads/master
2020-03-07T00:07:40.067812
2016-07-27T21:23:46
2016-07-27T21:23:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,700
hpp
/*********************************************************************** * Author: Franziska Krüger * Requirements: OpenCV 3 * * Description: * ------------ * Collection of some useful functions. * *********************************************************************** */ #ifndef UTILS_COLLECTION_H #define UTILS_COLLECTION_H #include <vector> #include <algorithm> // std::sort #include <array> #include <cmath> // sqrt #include <opencv2/opencv.hpp> namespace deblur { /** * Enumeration for conviniend call of two views */ enum view { LEFT, RIGHT }; /** * Flags for matlabs conv2 method */ enum ConvShape { FULL, SAME, VALID, }; inline float norm(float a, float b) { return sqrt(a * a + b * b); } /** * Computes the cross correlation between two images * * @param X first iamge * @param Y second iamge * @return correlation value */ float crossCorrelation(cv::Mat& X, cv::Mat& Y, const cv::Mat& mask = cv::Mat()); /** * Works like matlab conv2 * * The shape parameter controls the result matrix size: * * - FULL Returns the full two-dimensional convolution * - SAME Returns the central part of the convolution of the same size as A * - VALID Returns only those parts of the convolution that are computed without * the zero-padded edges */ void conv2(const cv::Mat& src, cv::Mat& dst, const cv::Mat& kernel, ConvShape shape = FULL); /** * Applies DFT after expanding input image to optimal size for Fourier transformation * * @param src input image with 1 channel * @param dst result as 2 channel matrix with complex numbers */ void fft(const cv::Mat& src, cv::Mat& dst); /** * Calls OpenCv dft function with adding the input matrix * as real channel of a complex matrix (2-channel matrix). * Without any padding! * * @param src input image with 1 channel * @param dst result as 2 channel matrix with complex numbers */ void dft(const cv::Mat& src, cv::Mat& dst); /** * Converts a matrix containing floats to a matrix * conatining uchars * * @param src input matrix * @param dst resulting matrix */ void convertFloatToUchar(const cv::Mat& src, cv::Mat& dst); /** * Displays a float matrix * which entries are outside range [0,1] * * @param name window name * @param src float matrix */ void showFloat(const std::string name, const cv::Mat& src, const bool write = false); /** * Displays a float matrix as for gradients in range [-1, 1] * where the zero becomes 128 as grayvalue. * * @param name window name * @param src float matrix */ void showGradients(const std::string name, const cv::Mat& src, const bool write = false); /** * Rearrange quadrants of an image so that the origin is at the image center. * This is useful for fourier images. */ void swapQuadrants(cv::Mat& image); /** * Displays a matrix with complex numbers stored as 2 channels * Copied from: http://docs.opencv.org/2.4/doc/tutorials/core/ * discrete_fourier_transform/discrete_fourier_transform.html * * @param windowName name of window * @param complex matrix that should be displayed */ void showComplexImage(const std::string windowName, const cv::Mat& complex); /** * Returns the real part of a complex matrix. Same as the "real()" * function in MatLab * * @param src Complex input matrix of floats * @return Real part of the complex matrix */ cv::Mat realMat(const cv::Mat& src); /** * Computes one channel gradients: * sqrt(x² + y²) * * @param gradients gradients of x- and y-direction * @param gradient resulting combined gradients */ void normedGradients(std::array<cv::Mat, 2>& gradients, cv::Mat& gradient); /** * Normalizes an input array into range [-1, 1] by conserving * zero. * * Example: * * [-415, 471] => [-0.88, 1] * * Works inplace. * * @param src Input matrix * @param dst Normalized matrix */ void normalizeOne(cv::Mat& src, cv::Mat& dst); /** * Convinient shorthand for inplace-normalization into range * [-1, 1] * * @param input source and destination */ inline void normalizeOne(cv::Mat& input) { normalizeOne(input, input); } template<typename T> void normalizeOne(T& src, T& dst) { std::array<double,4> extrema; std::array<double,4> maxima; cv::minMaxLoc(src[0], &(extrema[0]), &(extrema[1])); cv::minMaxLoc(src[1], &(extrema[2]), &(extrema[3])); for (int i = 0; i < 4; ++i) { maxima[i] = std::abs(extrema[i]); } std::sort(maxima.begin(), maxima.end()); const double scale = maxima[3]; cv::normalize(src[0], dst[0], extrema[0] / scale, extrema[1] / scale, cv::NORM_MINMAX); cv::normalize(src[1], dst[1], extrema[2] / scale, extrema[3] / scale, cv::NORM_MINMAX); } inline void normalizeOne(std::array<cv::Mat,2>& src, std::array<cv::Mat,2>& dst) { normalizeOne<std::array<cv::Mat,2>>(src, dst); } inline void normalizeOne(std::array<cv::Mat,2>& input) { normalizeOne<std::array<cv::Mat,2>>(input, input); } inline void normalizeOne(std::vector<cv::Mat>& src, std::vector<cv::Mat>& dst) { assert(src.size() == 2 && "Vector must contain 2 channels"); normalizeOne<std::vector<cv::Mat>>(src, dst); } inline void normalizeOne(std::vector<cv::Mat>& input) { normalizeOne<std::vector<cv::Mat>>(input, input); } /** * Fills pixel in a given range with a given uchar. * * @param image image to work on * @param start starting point * @param end end point * @param color color for filling */ void fillPixel(cv::Mat& image, const cv::Point start, const cv::Point end, const uchar color); /** * fill the black regions with the neighboring pixel colors (half way the left one * and half way the right one) and blur the resulting image. Copy the original region * over it. * * @param taperedRegion resulting image * @param region region image * @param mask mask of region */ void edgeTaper(cv::Mat& taperedRegion, cv::Mat& region, cv::Mat& mask, cv::Mat& image); } #endif
[ "kruegerfr@gmail.com" ]
kruegerfr@gmail.com
2157acb8f571c7cb006967f7e92e69a41064445c
ba181fa3354c6962d7b82b422cb605c0754cedd7
/toolchain/UIDesigner/Widget/UiListBox.h
bd233b30b57198f6e071acc294bde8801d3814d4
[ "MIT", "Zlib" ]
permissive
aismann/Bulllord-Engine
f8e2099c668b97083762d2527721e415341a1c5c
4b85f17f29365a56a5c6919b84762f35960ba98c
refs/heads/master
2020-03-28T01:10:34.484708
2018-08-31T22:50:42
2018-08-31T22:50:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,880
h
#ifndef UILISTBOX_H #define UILISTBOX_H #include "UiWidget.h" #include "GeneratedFiles/ui_listboxediterdialog.h" #include <QtWidgets/QDialog> class ListBoxEditerDialog : public QDialog , public Ui::ListBoxEditerDialog { Q_OBJECT public: ListBoxEditerDialog(QWidget *parent = 0); void setInitItems(QStringList items); QStringList getItems() const { return _itemList; } private: void initUi(); void initSignal(); protected slots: void slotAddBtnClicked(); void slotDelBtnClicked(); void slotUpBtnClicked(); void slotDownBtnClicked(); void slotOkBtnClicked(); private: QStringList _itemList; }; class UiListBox : public UiWidget { Q_OBJECT Q_CLASSINFO("uiClassName", "c_listbox") Q_PROPERTY(int rowHeight READ getRowHeight WRITE setRowHeight) Q_PROPERTY(SkinImageEx backGroundImage READ getBackImg WRITE setBackImg) Q_PROPERTY(QStringList items READ getItems WRITE setItems DESIGNABLE false) Q_PROPERTY(QColor textColor READ getTextColor WRITE setTextColor) public: int getRowHeight() const; void setRowHeight(int height); SkinImageEx getBackImg(); void setBackImg(const SkinImageEx &backImg); QStringList getItems() const; void setItems(const QStringList items); QColor getTextColor() const; void setTextColor(const QColor &color); public: Q_INVOKABLE UiListBox(UiWidget *parent = 0); virtual bool acceptChildern() const { return true; } virtual void getDefaultSize(int &width, int &height) const; virtual QString getUiClassName() const { return "c_listbox"; } virtual bool handleDoubleClicked(int x, int y); virtual QString getSerializedClassName() const { return "lib"; } virtual QDomElement serialize( QDomDocument &doc, const QDomElement &extElement); virtual void readExt(QXmlStreamReader &reader); protected Q_SLOTS: virtual void slotSkinFileChanged(const SkinFile &skinFile); private: SkinImageEx _backImage; }; #endif //UILISTBOX_H
[ "marilyndafa@163.com" ]
marilyndafa@163.com
b6688daa2daa7d9639ad32b68e4204754691a36b
ea454686ee8e25dfc16b23033aecb2f2043999c8
/Kattis/DA-Sort/dasort.cpp
49db3ea1bb44273858b80795a58f4058bed59870
[]
no_license
EmilRNielsen/Personal-Projects
62d9908927cf0de9cfd5bf24b25ebfe8ba9fce77
20ddaf8fa3c810fa860b2a9db382e4b8e2fe144a
refs/heads/master
2020-12-26T18:27:59.255775
2020-02-11T20:14:07
2020-02-11T20:14:07
237,595,974
0
0
null
null
null
null
UTF-8
C++
false
false
527
cpp
#include <iostream> using namespace std; int main() { int datasets; cin >> datasets; int currentDataset, length; for(int i = 1; i < datasets + 1; i++) { cin >> currentDataset; cin >> length; int j = 0; int current; cin >> current; int temp; int deletesNeeded; while(j < length) { cin >> temp; if(temp >= current) { current = temp; j++; } else if } } return 0; }
[ "enie@itu.dk" ]
enie@itu.dk
305b9b9dfe8ed359cfec2b1fb8fa90d6b4d1d350
d794475a73c660d04dc04ebd38a602c2bba8d4d8
/haxe/export/linux64/cpp/obj/include/__ASSET__flixel_images_ui_button_png.h
5c8dbb7f33a8ff15c1a5b3c012f6d1b2f4843c3d
[ "MIT" ]
permissive
syonfox/PixelPlanetSandbox
9753e9e51f6d59bd9f9c90c004bfdbb5bab0ace5
a33e1d0f198f8fcec551b4c0ec485f19049a802f
refs/heads/master
2021-01-12T12:15:53.093871
2017-08-27T02:56:05
2017-08-27T02:56:05
72,397,156
0
1
null
2017-01-13T20:01:33
2016-10-31T03:42:28
C++
UTF-8
C++
false
false
1,783
h
#ifndef INCLUDED___ASSET__flixel_images_ui_button_png #define INCLUDED___ASSET__flixel_images_ui_button_png #ifndef HXCPP_H #include <hxcpp.h> #endif #ifndef INCLUDED_openfl__legacy_display_BitmapData #include <openfl/_legacy/display/BitmapData.h> #endif HX_DECLARE_CLASS0(__ASSET__flixel_images_ui_button_png) HX_DECLARE_CLASS3(openfl,_legacy,display,BitmapData) HX_DECLARE_CLASS3(openfl,_legacy,display,IBitmapDrawable) class HXCPP_CLASS_ATTRIBUTES __ASSET__flixel_images_ui_button_png_obj : public ::openfl::_legacy::display::BitmapData_obj{ public: typedef ::openfl::_legacy::display::BitmapData_obj super; typedef __ASSET__flixel_images_ui_button_png_obj OBJ_; __ASSET__flixel_images_ui_button_png_obj(); Void __construct(int width,int height,Dynamic __o_transparent,Dynamic __o_fillRGBA); public: inline void *operator new( size_t inSize, bool inContainer=true,const char *inName="__ASSET__flixel_images_ui_button_png") { return hx::Object::operator new(inSize,inContainer,inName); } static hx::ObjectPtr< __ASSET__flixel_images_ui_button_png_obj > __new(int width,int height,Dynamic __o_transparent,Dynamic __o_fillRGBA); static Dynamic __CreateEmpty(); static Dynamic __Create(hx::DynamicArray inArgs); //~__ASSET__flixel_images_ui_button_png_obj(); HX_DO_RTTI_ALL; static bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp); static bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp); static void __register(); ::String __ToString() const { return HX_HCSTRING("__ASSET__flixel_images_ui_button_png","\x13","\x11","\x39","\x10"); } static void __boot(); static ::String resourceName; }; #endif /* INCLUDED___ASSET__flixel_images_ui_button_png */
[ "kierl@sfu.ca" ]
kierl@sfu.ca
bc43403153d516e7d1ce649bf08aee74708ff94a
5539d4a34be95a00614657e484ed50b2f353631e
/Code/FlowNodes/TrackPadFlowNode.h
32b4cb826abd2693af07bd768376f9320297fd20
[]
no_license
nigelhardy/VR_PlantGrowth
9cd2dbbb044c82b45f38ba4b4b99fd838e6c68dd
a754a53015bbb440bf580ef75d2bd632a5f2aa83
refs/heads/master
2021-08-30T08:37:39.504799
2017-12-17T01:35:04
2017-12-17T01:35:04
107,835,633
1
0
null
null
null
null
UTF-8
C++
false
false
782
h
#pragma once #include <CryFlowGraph\IFlowBaseNode.h> class CFlowNode_TrackPad final : public CFlowBaseNode<eNCT_Instanced> { public: enum EInputPorts { eInputPort_TrackPadVec0 = 0, eInputPort_SomeInput1, eInputPort_SomeInput2, eInputPort_Num }; enum EOutputPorts { eOutputPorts_ChangeFilterX = 0, eOutputPorts_ChangeFilterY, eOutputPorts_Num }; Vec3 lastTrackPadPos = Vec3(0, 0, 0); Vec3 lastTrackPadPosAlways = Vec3(0, 0, 0); public: CFlowNode_TrackPad(SActivationInfo* pActInfo); virtual IFlowNodePtr Clone(SActivationInfo *pActInfo) override; virtual void GetMemoryUsage(ICrySizer* s) const override; virtual void GetConfiguration(SFlowNodeConfig& config) override; virtual void ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo) override; };
[ "nigeljames.12@gmail.com" ]
nigeljames.12@gmail.com
247737dd0a00f32f23b1ed3127346b28cd4f7b83
d16ed0109b7b7809744a4e64b5cb8fae6853aebb
/src/engine/engine.h
d94453f7f12d642aad3860baf61efc0df3d9702f
[ "MIT" ]
permissive
morgenm/PMC-Game
56b0fe2caf17877d175f368eafb8fd0de723fba1
ae09b3df200bd1cf47bcf8888939112e5ac42d38
refs/heads/master
2020-12-30T01:07:45.915466
2020-09-21T17:23:41
2020-09-21T17:23:41
238,807,221
0
0
null
null
null
null
UTF-8
C++
false
false
226
h
/* Engine The Base class abstraction for engines to inherit from. */ #pragma once #include "msg_sys/feed_register_req.h" class Engine { public: virtual EngineFeedRegisterRequest GetFeedRegisterRequest() = 0; };
[ "morgenm@protonmail.com" ]
morgenm@protonmail.com
a9e43c526598391abb199bd269618e29a023f897
d67fff8c356a3ccde70622c9400130d2f3fc6f39
/education/e74/A/main.cpp
1e9c4b7e763af9c50d12302a1ca620981957ccf1
[]
no_license
6clc/Codeforces
9b1f1025aad7cad7c768ea49901f6db663d66281
34a1620981c7506f64e12c02cc4bd2ece747c0bc
refs/heads/master
2020-12-03T01:01:04.987185
2020-04-24T11:33:07
2020-04-24T11:33:07
231,167,030
0
0
null
null
null
null
UTF-8
C++
false
false
337
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; void solve(){ ll x; ll y; cin >> x >> y; ll n = x - y; if(n!=1) cout << "YES" << endl; else cout << "NO" << endl; } int main() { // std::cout << "Hello, World!" << std::endl; int t; cin >> t; while(t--) solve(); return 0; }
[ "569519574@qq.com" ]
569519574@qq.com
e11129cd56c883812680136d2a06bbd3c04ebdd2
8605f243a2f0750d67bd31ff35f77f7f72a8997f
/abc.cpp
026dc5fed12c6c23baa2e7badca3a1e65c330f76
[]
no_license
AnuragGundi/CRYPTO_PROJECT
f85d2e70b960a4b86395ce1ba288f0ef4819a8db
7dfb59bdbc489e94be6d400719ae981d7c5dcaac
refs/heads/master
2020-12-30T14:01:06.906603
2017-05-14T22:48:16
2017-05-14T22:48:16
91,276,085
0
0
null
null
null
null
UTF-8
C++
false
false
4,006
cpp
//project //implementing given algo #include<iostream> #include<string.h> #include<stdlib.h> #include<cmath> #include<time.h> clock_t start,end; double msecs; using namespace std; int cur=0; void revers(char * ar,int st,int en) { int temp; while(st<=en) { temp=ar[st]; ar[st]=ar[en]; ar[en]=temp; st++; en--; } } void mirror(char * ar,int len) { int i,st=0,en,sum=0; int limiter=log(len)/log(2); for(i=0;i<=limiter;i++) { en=st+pow(2,i)-1; revers(ar,st,en); st=en+1; } } void preorder(char * pre,char *ar,int index,int len) { if(index>=len) return; pre[cur++]=ar[index]; preorder(pre,ar,2*index+1,len); preorder(pre,ar,2*index+2,len); } int main() { start=clock(); char st[100]; printf("Enter your Message(plain text): "); gets(st); int str_len=strlen(st); int t1=log(str_len)/log(2); t1=t1+1; int len=pow(2,t1)-1; char ar[len]; for(int i=0;i<str_len;i++) ar[i]=st[i]; for(int i=str_len;i<len;i++) ar[i]='%'; cout<<"\n\n\nENCRYPTION PROCESS\n\n\n"; cout<<"\n\nAfter Adding Padding Bits:\n"; for(int i=0;i<len;i++) cout<<ar[i]<<' '; revers(ar,0,len-1); cout<<"\n\nAfter Reversing The Text:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<ar[i]<<' '; mirror(ar,len); cout<<"\n\nAfter Mirroring:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<ar[i]<<' '; char * temp; char pre[len]; cur=0; preorder(pre,ar,0,len); cout<<"\n\nFirst Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<pre[i]<<' '; cur=0; preorder(ar,pre,0,len); cout<<"\n\nSecond Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<ar[i]<<' '; cur=0; preorder(pre,ar,0,len); cout<<"\n\nThird Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<pre[i]<<' '; cur=0; preorder(ar,pre,0,len); cout<<"\n\nFourth Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<ar[i]<<' '; cur=0; preorder(pre,ar,0,len); cout<<"\n\nFifth Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<pre[i]<<' '; cout<<"\n\n\nDECRYPTION PROCESS\n\n\n"; cur=0; preorder(ar,pre,0,len); cout<<"\n\nFirst Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<ar[i]<<' '; cur=0; preorder(pre,ar,0,len); cout<<"\n\nSecond Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<pre[i]<<' '; cur=0; preorder(ar,pre,0,len); cout<<"\n\nThird Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<ar[i]<<' '; cur=0; preorder(pre,ar,0,len); cout<<"\n\nFourth Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<pre[i]<<' '; cur=0; preorder(ar,pre,0,len); cout<<"\n\nFifth Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<ar[i]<<' '; cur=0; preorder(pre,ar,0,len); cout<<"\n\nSixth Preorder Traversal:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<pre[i]<<' '; mirror(pre,len); cout<<"\n\nAfter Mirroring:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<pre[i]<<' '; revers(pre,0,len-1); cout<<"\n\nAfter Reversing The Text:\n"; cout<<'\n'; for(int i=0;i<len;i++) cout<<pre[i]<<' '; cout<<"\nAfter Removing Padding Bits:\n"; for(int i=0;i<str_len;i++) cout<<pre[i]<<' '; end=clock(); msecs=(((double)(end-start))*1000)/CLOCKS_PER_SEC; cout<<"\n"<<"the execution time is "<<msecs<<"\n"; }
[ "harshita_gundi@gatekeepers-MBP.fios-router.home" ]
harshita_gundi@gatekeepers-MBP.fios-router.home
50a53f9d27a78e75ce5a3eebe0752c3c4ae8374e
f5482a3ab886652827a0b996f2971569e6635e41
/sequential/test/2d/50000/full_iterations.cpp
4541504c8b5960ea97060ef8bba5792fa24b3742
[ "MIT" ]
permissive
w00zie/kmeans
dc8419851cb70192ae64ea013806ebc9068ca83a
ccaeee19c4afc87b22d828c668f84ae3ae073d96
refs/heads/main
2023-03-08T06:16:16.659859
2021-02-24T18:40:00
2021-02-24T18:40:00
337,354,907
2
0
null
null
null
null
UTF-8
C++
false
false
1,457
cpp
#include <cassert> #include <chrono> #include "../../../../include/container_io.h" #include "../../../kmeans.h" #include "../../../../include/sample.h" bool run_kmeans() { const size_t num_points = 50000; const size_t dim = 2; const size_t k = 3; const size_t niter = 100; const std::string data_path = "../../../../datasets/2d/50000_samples_3_centers/data.csv"; const std::string centroids_path = "../../../../datasets/2d/50000_samples_3_centers/centroids.csv"; const double eps_to_real = 1; const kmeans::mat<float, num_points, dim> data = kmeans::io::load_csv<float, num_points, dim>(data_path, ','); kmeans::hash<float, dim> sampled_centroids = kmeans::sample::sample_centroids_from_data<float, num_points, k, dim>(data); kmeans::hash<float, dim> centroids = kmeans::seq::kmeans<float, num_points, k, dim>(data, sampled_centroids, niter); const kmeans::mat<float, k, dim> real_centroids = kmeans::io::load_csv<float, k, dim>(centroids_path, ','); return(kmeans::are_close_to_real<float, k, dim>(centroids, real_centroids, eps_to_real)); return 0; } int main(int argc, char *argv[]) { const unsigned int NUM_RUNS = std::stoul(argv[1]); const unsigned int SUCCESS_THRESHOLD = std::stoul(argv[2]); unsigned int OK = 0; for (unsigned int i = 0; i < NUM_RUNS; ++i) { if ( run_kmeans() ) OK += 1; } assert(OK > SUCCESS_THRESHOLD); return 0; }
[ "giovanni.bindi@stud.unifi.it" ]
giovanni.bindi@stud.unifi.it
8608b2cf3cb34bdb09489c785bd1116e02d93391
32fd42f7a316393f3c269ffb99f4a162a177b2bb
/yss/inc/sac/MassStorage.h
5efd935e0d014b3203f1f1248fe4a36e2a4d0980
[]
no_license
kimdukheung/yss
d1752b99088321f2cf35e7bd8a472202c22ee1ef
916b619ae654fc03c4cb9dfef81e6b95949a732a
refs/heads/master
2023-04-18T15:42:02.842979
2021-05-02T05:51:22
2021-05-02T05:51:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,853
h
//////////////////////////////////////////////////////////////////////////////////////// // // 저작권 표기 License_ver_2.0 // 본 소스코드의 소유권은 yss Embedded Operating System 네이버 카페 관리자와 운영진에게 있습니다. // 운영진이 임의로 코드의 권한을 타인에게 양도할 수 없습니다. // 본 소스코드는 아래 사항에 동의할 경우에 사용 가능합니다. // 아래 사항에 대해 동의하지 않거나 이해하지 못했을 경우 사용을 금합니다. // 본 소스코드를 사용하였다면 아래 사항을 모두 동의하는 것으로 자동 간주 합니다. // 본 소스코드의 상업적 또는 비상업적 이용이 가능합니다. // 본 소스코드의 내용을 임의로 수정하여 재배포하는 행위를 금합니다. // 본 소스코드의 내용을 무단 전재하는 행위를 금합니다. // 본 소스코드의 사용으로 인해 발생하는 모든 사고에 대해서 어떤한 법적 책임을 지지 않습니다. // // Home Page : http://cafe.naver.com/yssoperatingsystem // Copyright 2020. yss Embedded Operating System all right reserved. // // 주담당자 : 아이구 (mymy49@nate.com) 2016.04.30 ~ 현재 // 부담당자 : - // //////////////////////////////////////////////////////////////////////////////////////// #ifndef YSS_SAC_MASS_STORAGE__H_ #define YSS_SAC_MASS_STORAGE__H_ #include <yss/thread.h> #include <drv/peripherals.h> namespace sac { class MassStorage { protected : virtual bool writeBlock(unsigned long block, void *src) = 0; virtual bool readBlock(unsigned long block, void *des) = 0; public : virtual unsigned long getBlockSize(void) = 0; virtual unsigned long getNumOfBlock(void) = 0; bool write(unsigned long block, void *src); bool read(unsigned long block, void *des); }; } #endif
[ "mymy49@nate.com" ]
mymy49@nate.com
ae48411ec81c5d09b566b589c3de378dd8db16a5
74a93a9f0e3ccb5f8149b4921361848105de9187
/functions.cpp
733b8780a7dc34967e3b89509c4271df63202107
[]
no_license
theSTremblay/Polynomial-Math
9bf7366d6a8781794141261110c59769648bd4d2
2d28a8ab4369500821509ca06b86c4c92c22f3b8
refs/heads/master
2021-09-05T14:38:14.900333
2018-01-29T00:01:36
2018-01-29T00:01:36
119,309,619
0
0
null
null
null
null
UTF-8
C++
false
false
6,231
cpp
#include "functions.hh" Node Node_Creator(double v) { Node New_node(0, 0); return (New_node); } //int getDegree(Poly p1) { // int counter = 0; // Node *node1_pointer; // node1_pointer = (p1.getHead()); // while (node1_pointer->next != 0) { // counter++; // node1_pointer = node1_pointer->next; // } // counter++; // If there are two nodes it will give you a value of 2 // // return counter; // //} Poly addPolynomials(Poly p1, Poly p2) { /* Change code below */ Poly p; int true_max = 0; int polynomial_max1 = 0; int polynomial_max2 = 0; double added_value = 0; Node *node1_pointer; //node1_pointer = p1.getHead(); polynomial_max1 = p1.getDegree(p1); polynomial_max2 = p2.getDegree(p2); Node *node2_pointer; //node2_pointer = p2.getHead(); Node *Main_node_pointer; //Main_node_pointer = p.getHead(); if (polynomial_max1 > polynomial_max2) { true_max = polynomial_max1; } else if(polynomial_max1 < polynomial_max2){ true_max = polynomial_max2; } else { true_max = polynomial_max2; } while (true_max != 1) { added_value = 0; if (true_max <= polynomial_max1) { added_value += p1.node_pointer.next->value; if (p1.node_pointer.next != 0) { p1.node_pointer = *(p1.node_pointer.next); } } if (true_max <= polynomial_max2) { added_value += p2.node_pointer.next->value; if (p2.node_pointer.next != 0) { p2.node_pointer = *(p2.node_pointer.next); } } p.changing_node_pointer->value = added_value; if (true_max > 2) { p.changing_node_pointer->next = (new Node(0, 0)); p.changing_node_pointer = (p.changing_node_pointer->next); } else { p.changing_node_pointer->next = 0; } true_max--; } return p; } Poly subtractPolynomials(Poly p1, Poly p2) { Poly p; int true_max = 0; int polynomial_max1 = 0; int polynomial_max2 = 0; double added_value = 0; Node *node1_pointer; //node1_pointer = p1.getHead(); polynomial_max1 = p1.getDegree(p1); polynomial_max2 = p2.getDegree(p2); Node *node2_pointer; //node2_pointer = p2.getHead(); Node *Main_node_pointer; //Main_node_pointer = p.getHead(); if (polynomial_max1 > polynomial_max2) { true_max = polynomial_max1; } else if (polynomial_max1 < polynomial_max2) { true_max = polynomial_max2; } else { true_max = polynomial_max2; } while (true_max != 1) { added_value = 0; if (true_max <= polynomial_max1) { added_value += p1.node_pointer.next->value; if (p1.node_pointer.next != 0) { p1.node_pointer = *(p1.node_pointer.next); } } if (true_max <= polynomial_max2) { added_value -= p2.node_pointer.next->value; if (p2.node_pointer.next != 0) { p2.node_pointer = *(p2.node_pointer.next); } } p.changing_node_pointer->value = added_value; if (true_max > 2) { p.changing_node_pointer->next = (new Node(0, 0)); p.changing_node_pointer = (p.changing_node_pointer->next); } else { p.changing_node_pointer->next = 0; } true_max--; } return p; } Poly multiplyPolynomials(Poly p1, Poly p2) { Poly p; int true_max = 0; int true_max2 = 0; int variable_max = 0; int polynomial_max1 = 0; int polynomial_max2 = 0; double added_value = 0; Node *node1_pointer; //node1_pointer = p1.getHead(); polynomial_max1 = p1.getDegree(p1); polynomial_max2 = p2.getDegree(p2); Node *node2_pointer; //node2_pointer = p2.getHead(); Node *Main_node_pointer; //Main_node_pointer = p.getHead(); // In this case just act like the true_max is a flag that stipulates which for loop gets what polynomials max degree if (polynomial_max1 > polynomial_max2) { true_max = 1; } else if (polynomial_max1 < polynomial_max2) { true_max = 0; } else { true_max = 1; } for (int i = 0; i < (polynomial_max1 + polynomial_max2); i++) { p.changing_node_pointer->next = (new Node(0, 0)); p.changing_node_pointer = p.changing_node_pointer->next; } p.changing_node_pointer = &(p.node_pointer); p1.changing_node_pointer = &(p1.node_pointer); //multiplication happens on the highest degree for (int i = 1; i < polynomial_max1; i++) { added_value = 0; true_max = (polynomial_max1 - (i-1)); p2.changing_node_pointer = &(p2.node_pointer); p.changing_node_pointer = &(p.node_pointer); for (int k = (polynomial_max1 - i); k < (polynomial_max1 -1); k++) { p.changing_node_pointer = p.changing_node_pointer->next; } /*p.changing_node_pointer = p.changing_node_pointer->next;*/ if (p1.changing_node_pointer->next != 0) { added_value += p1.changing_node_pointer->next->value; } for (int j = 1; j < polynomial_max2; j++) { if (p2.changing_node_pointer->next != 0 ) { true_max2 = (polynomial_max2 - (j-1)); variable_max = true_max - true_max2; if (variable_max < 0) { variable_max = ((-1) * (variable_max)); } added_value *= p2.changing_node_pointer->next->value; p.changing_node_pointer->value = added_value + p.changing_node_pointer->value; if (i != (polynomial_max1 - 1) || j != (polynomial_max2 - 1) ){ p.changing_node_pointer = p.changing_node_pointer->next; } else { p.changing_node_pointer->next = 0; } } if (p1.changing_node_pointer->next != 0) { p1.changing_node_pointer = p1.changing_node_pointer->next; } } } /*while (true_max != 0) { added_value = 0; if (true_max <= polynomial_max1) { added_value += p1.changing_node_pointer->value; if (p1.changing_node_pointer->next != 0) { p1.changing_node_pointer = (p1.changing_node_pointer->next); } } if (true_max <= polynomial_max2) { if (added_value != 0) { added_value *= p2.node_pointer.value; } else { added_value += p2.node_pointer.value; } if (p2.node_pointer.next != 0) { p2.node_pointer = *(p2.node_pointer.next); } } p.node_pointer.value = added_value; if (true_max > 1) { p.node_pointer.next = &(Node_Creator(added_value)); p.node_pointer = *(p.node_pointer.next); } else { p.node_pointer.next = 0; } } */ return p; }
[ "noreply@github.com" ]
noreply@github.com
9024c514ebc356a7074e5eaa3fea2f88d84953e8
51e0524b60c6c43358621d913c564ba70da68beb
/src/blob.h
1f42c23dab6c7caf54eeb8ac6d7513719ee0b522
[ "Apache-2.0", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
fendaq/FeatherCNNEx
8e3d34eb75e920c3a038eb163ee614ece3a7c9db
561e22430e0919d6add6d005d1ff37ca3359ce54
refs/heads/master
2020-03-27T16:00:36.450373
2018-08-29T02:37:09
2018-08-29T02:37:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,564
h
//Tencent is pleased to support the open source community by making FeatherCNN available. //Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. //Licensed under the BSD 3-Clause License (the "License"); you may not use this file except //in compliance with the License. You may obtain a copy of the License at // //https://opensource.org/licenses/BSD-3-Clause // //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 <string> #include <assert.h> #include <stdio.h> #include <common.h> #include "aes.h" namespace feather { template <class Dtype> class Blob { public: Blob() : _num(0), _channels(0), _height(0), _width(0), _fractions(0), _data(NULL), globalData(0) {} explicit Blob(const size_t num, const size_t channels, const size_t height, const size_t width) : _data(NULL), _num(num), _channels(channels), _height(height), _width(width), _fractions(0), globalData(0), _name() {} explicit Blob(Dtype* data, const size_t num, const size_t channels, const size_t height, const size_t width) : _data(data), _num(num), _channels(channels), _height(height), _width(width), _fractions(0), globalData(0), _name() {} explicit Blob(Dtype* data, size_t num, size_t channels, size_t height, size_t width, std::string name) : _data(data), _num(num), _channels(channels), _height(height), _width(width), _fractions(0), globalData(0), _name(name) {} ~Blob() { //printf("blob del: %s %d %p ok\n", _name.c_str(), globalData, this->_data); if ((0 == globalData) && (this->_data)) _mm_free(this->_data); } void Alloc(); void CopyData(const Dtype* data) { size_t size = _num * _channels * _height * _width; memcpy(_data, data, sizeof(Dtype) * size); } void CopyShape(const Blob<Dtype>* p_blob) { this->_num = p_blob->num(); this->_channels = p_blob->channels(); this->_width = p_blob->width(); this->_height = p_blob->height(); this->_fractions = p_blob->fractions(); } void Copy(const Blob<Dtype>* p_blob) { CopyShape(p_blob); assert(p_blob->data_size() == this->data_size()); if (0 == p_blob->globalData) { this->Alloc(); CopyData(p_blob->data()); } else { this->_data = p_blob->data(); this->globalData = 1; } } void FromProto(const void *proto_in);//proto MUST be of type BlobProto* void setData(Dtype *pData) { globalData = 1; _data = pData; _name = "SetData"; } Dtype* data() const { return _data; } size_t data_size() const { return _num * _channels * _height *_width; } size_t element_size() const { return sizeof(Dtype); } std::string name() { return _name; } size_t num() const { return _num; } size_t channels() const { return _channels; } size_t height() const { return _height; } size_t width() const { return _width; } size_t setChannels( size_t channels) { return _channels = channels; } size_t setHeight(size_t height) { return _height = height; } size_t setWidth(size_t width) { return _width = width; } size_t fractions() const { return _fractions; } void PrintBlobInfo() const { printf("----BlobInfo----\n"); printf("Shape in nchw (%zu %zu %zu %zu) [Fractions: %zu]\n", _num, _channels, _height, _width, _fractions); if (0 == _fractions) printf("Data (%9.6f %9.6f %9.6f %9.6f)\n", *((Dtype*)_data+0), *((Dtype*)_data+1), *((Dtype*)_data+2), *((Dtype*)_data+3)); else printf("Data (%d %d %d %d)\n", *((Dtype*)_data+0), *((Dtype*)_data+1), *((Dtype*)_data+2), *((Dtype*)_data+3)); printf("----------------\n"); } void *pNet; std::string _name; private: Dtype* _data; size_t _num; size_t _channels; size_t _height; size_t _width; size_t _fractions; size_t _crypto; size_t _validSize; size_t _data_length; unsigned char globalData; }; };
[ "tianylijun@163.com" ]
tianylijun@163.com
dd92b5b18e20ea228db6ab306427c3eea0cfe4c3
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/AtCoder/agc002/C/825178.cpp
4abd23588dc3fb887475b9a51e99943c534f1516
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
C++
false
false
2,470
cpp
#include <vector> #include <iostream> #include <unordered_map> #include <map> #include <iomanip> #include <functional> #include <algorithm> #include <cassert> #include <cmath> #include <string> #include <sstream> using namespace std; #ifndef MDEBUG #define NDEBUG #endif #define x first #define y second #define ll long long #define d double #define ld long double #define pii pair<int,int> #define pil pair<int,ll> #define pli pair<ll,int> #define pll pair<ll,ll> #define pss pair<string,string> #define psi pair<string,int> #define pis pair<int,string> #define psl pair<string,ll> #define pls pair<ll,string> #define wh(x) (x).begin(),(x).end() #define ri(x) int x;cin>>x; #define rii(x,y) int x,y;cin>>x>>y; #define rl(x) ll x;cin>>x; #define rv(v) for(auto&_cinv:v) cin>>_cinv; #define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl; #define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl; #define MOD 1000000007 namespace std { template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}}; } // auto fraclt = [](auto&a,auto&b) { return (ll)a.x * b.y < (ll)b.x * a.y; }; template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;} template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;} template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; } template<typename T> void fracn(pair<T,T>&a) {auto g=gcd(a.x,a.y);a.x/=g;a.y/=g;} template<typename T> struct Index { int operator[](const T&t){auto i=m.find(t);return i!=m.end()?i->y:m[t]=m.size();}int s(){return m.size();} unordered_map<T,int> m; }; int main(int,char**) { ios_base::sync_with_stdio(false); int N,L; scanf("%d %d", &N, &L); vector<int> A(N); for(int&a:A) scanf("%d", &a); int tie = -1; for (int i = 0; i < N-1; i++) { if (A[i] + A[i+1] >= L) { tie = i; break; } } if (tie == -1) { printf("Impossible\n"); } else { printf("Possible\n"); for (int i = 1; i <= tie; i++) { printf("%d\n", i); } for (int i = N-1; i > tie+1 ; --i) { printf("%d\n", i); } printf("%d\n", tie+1); } }
[ "kwnafi@yahoo.com" ]
kwnafi@yahoo.com
75daa2579191bed215d9a79245e2c5cd97e000b6
1da7d378d84fb995bf118e94839a4131a178499b
/sinkworld/tentacle/python/add_LineCacheEntry.cpp
c162cc76b4bc5634d20bebf54fac69ab8de8ae11
[ "MIT" ]
permissive
calandoa/zxite
f85ed7b8cc0f3ed5194b5ea3c4ce5859cb487312
8122da2e5dc2907ccb84fe295a9a86e843402378
refs/heads/master
2021-07-14T21:14:16.559063
2017-10-20T16:12:09
2017-10-20T16:12:09
28,239,704
0
1
null
null
null
null
UTF-8
C++
false
false
1,531
cpp
#include <boost/python.hpp> #include <boost/cstdint.hpp> #include <string> #include <iostream> #include <assert.h> #include "base.h" #include "lexers.h" // Using ======================================================================= using namespace boost::python; typedef void *HWND; typedef void *HINSTANCE; #include "PhysicalLayout.h" #include "RegisteredLexers.h" #include "RGBColor.h" #include "IDecoration.h" #include "BaseDecoration.h" #include "RegisteredDecorations.h" #include "Style.h" #include "StyleModification.h" #include "StyleSet.h" #include "StyleSetCollection.h" #include "FontDescription.h" #include "Surface.h" #include "ChangeLayer.h" #include "ChangeFinder.h" #include "StyleLayer.h" #include "SubstanceLayer.h" #include "PositionCache.h" #include "LinePositionCache.h" #include "ChangePositionsCache.h" #include "Document.h" #include "PhasedPaint.h" #include "TextView.h" #include "RangeSelection.h" #include "DecorationBox.h" #include "DecorationButton.h" #include "DecorationCaret.h" #include "DecorationGraduatedBox.h" #include "DecorationStrikeOut.h" #include "DecorationRoundedBox.h" #include "DecorationUnderLine.h" #include "TentacleControl.h" #include "SWWrappers.h" void add_LineCacheEntry() { class_< LineCacheEntry, boost::noncopyable >("LineCacheEntry", init< >()) .def_readwrite("line", &LineCacheEntry::line) .def_readwrite("positions", &LineCacheEntry::positions) .def("Match", &LineCacheEntry::Match) .def("Set", &LineCacheEntry::Set) ; }
[ "antoine.calando@intel.com" ]
antoine.calando@intel.com
15867bbd111e6cd5e6ff78c704b64f5e1d238ad5
c16bd3b3037a579166697dd7ff571705508e78c5
/BSc/semester-3/Qt/build-2tut-Desktop_Qt_5_1_0_MinGW_32bit-Debug/debug/moc_mainwindow.cpp
6257f1a8aaf912e9003eefb89d14ac84d85fa842
[]
no_license
kevinhartyanyi/school
ed2e7492a5e9a29d1b7a68589a7b0816be7511ba
a19968064435c47c8a91612cd951b0def18eff31
refs/heads/master
2020-03-26T03:57:46.690519
2019-07-03T04:58:23
2019-07-03T04:58:23
144,479,150
0
0
null
null
null
null
UTF-8
C++
false
false
2,582
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'mainwindow.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.1.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../2tut/mainwindow.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'mainwindow.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.1.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_MainWindow_t { QByteArrayData data[1]; char stringdata[12]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ offsetof(qt_meta_stringdata_MainWindow_t, stringdata) + ofs \ - idx * sizeof(QByteArrayData) \ ) static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = { { QT_MOC_LITERAL(0, 0, 10) }, "MainWindow\0" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_MainWindow[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount 0 // eod }; void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { Q_UNUSED(_o); Q_UNUSED(_id); Q_UNUSED(_c); Q_UNUSED(_a); } const QMetaObject MainWindow::staticMetaObject = { { &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow.data, qt_meta_data_MainWindow, qt_static_metacall, 0, 0} }; const QMetaObject *MainWindow::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *MainWindow::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata)) return static_cast<void*>(const_cast< MainWindow*>(this)); return QMainWindow::qt_metacast(_clname); } int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_END_MOC_NAMESPACE
[ "hartyanyi.kevin@gmail.com" ]
hartyanyi.kevin@gmail.com
c8d230145fd0cf0258d0e3b4430e4ca9c997e258
c4511cfda185dd2af7018474e8ab0fc6d9e4c492
/Heap-sort/Heap-sort.cpp
78e6dc87e053ff9704cc78775270636a2eb5d380
[]
no_license
shipengAlan/Algorithms
2764a05fd0caccd5a5a555d459124e8be1fb694c
6baa42b1d14e24c6c7e706ba0d8521af047fb865
refs/heads/master
2021-06-26T19:38:30.959708
2017-03-04T10:22:32
2017-03-04T10:22:32
39,228,855
1
0
null
null
null
null
UTF-8
C++
false
false
1,103
cpp
#include<iostream> using namespace std; /* 大根堆的调整,时间复杂度为O(logn) */ void Max_Heapify(int a[], int k, int size){ int l = (k+1) * 2 -1; int r = (k+1) * 2; int large = k; if(l<size&&a[l]>a[k]){ large = l; } if(r<size&&a[r]>a[large]){ large = r; } if(large!=k){ int temp = a[k]; a[k] = a[large]; a[large] = temp; Max_Heapify(a, large, size); } } /* 大根堆建立,时间复杂度O(nlogn) */ void Build_Max_Heap(int a[], int size){ for(int i=size/2;i>=0;i--){ Max_Heapify(a, i, size); } } /* 堆排序算法,不稳定的内排序,时间复杂度为O(nlogn) */ void Heap_sort(int a[], int n){ Build_Max_Heap(a, n); int key = n-1; int size = n; while(key>0){ int temp = a[0]; a[0] = a[key]; a[key] = temp; size--; Max_Heapify(a, 0, size); key--; //Max_Heapify(a, 0, size); } } int main(){ int a[7] = {8, 2, 5, 4, 6, 9, 7}; Heap_sort(a, 7); for(int i=0;i<7;i++) cout<<a[i]<<","; cout<<endl; int b[11] = {1, 5, 8, 5, 0, 6, 7, 6, 5, 8, 3}; Heap_sort(b, 11); for(int i=0;i<11;i++) cout<<b[i]<<","; cout<<endl; return 0; }
[ "shipeng.alan@gmail.com" ]
shipeng.alan@gmail.com
0ad0dea8f5c7fb73e0c5340845094da300f182d8
8fd6bf09deb98988e838bf183e2f7bb97738f9b7
/mods/coreutils/mingw-std-threads/tests/tests.cpp
3e5dc97e61470ac46b91d434531aea1e7d6be2aa
[ "LGPL-2.1-only", "MIT" ]
permissive
lmorchard/apone
549392bfc657aa4028bbdca4b10c07364b673eaf
1fa82927a9fbcbe953976ac9796f32092ad52ac2
refs/heads/master
2020-03-28T16:07:13.797132
2018-09-04T15:45:57
2018-09-04T15:46:57
148,661,417
0
0
MIT
2018-09-13T15:48:29
2018-09-13T15:48:28
null
UTF-8
C++
false
false
1,366
cpp
#include "../mingw.thread.h" #include <mutex> #include "../mingw.mutex.h" #include "../mingw.condition_variable.h" #include <atomic> using namespace std; bool cond = false; std::mutex m; std::condition_variable cv; int main() { std::thread t([](int a, const char* b, int c)mutable { try { // printf("Thread started: arg = %d, %s, %d\n", a, b, c); // fflush(stdout); this_thread::sleep_for(std::chrono::milliseconds(5000)); { lock_guard<mutex> lock(m); cond = true; cv.notify_all(); } printf("thread finished\n"); fflush(stdout); } catch(std::exception& e) { printf("EXCEPTION in thread: %s\n", e.what()); } }, 1, "test message", 3); try { // printf("trylock: %d\n", m.try_lock()); // fflush(stdout); printf("condvar waiting\n"); fflush(stdout); { std::unique_lock<mutex> lk(m); cv.wait(lk, []{ return cond;} ); printf("condvar notified, cond = %d\n", cond); fflush(stdout); } printf("waiting for thread to terminate\n"); fflush(stdout); t.join(); printf("join complete\n"); fflush(stdout); } catch(std::exception& e) { printf("EXCEPTION in main thread: %s\n", e.what()); } return 0; }
[ "sasq64@gmail.com" ]
sasq64@gmail.com
9864770d1e6f288c32e5c0d8f4fc4b556ab49233
ee95f3624ee4925f224f0622bc0b4fa8cb61813a
/Plugins/YangInteract/Source/YangInteract/Public/LatentInteractableComp.h
46c868a23ba6578676a8112d0c33d5ad217b54cd
[]
no_license
renkin4/MegaGameJam2018
8e595e49ead2420452df798c4da5ab9a4eb9081c
d17ab3b583738c7a143f3be7d8184833a675db79
refs/heads/master
2020-04-05T17:25:05.840266
2018-11-15T02:05:18
2018-11-15T02:05:18
157,059,825
0
0
null
null
null
null
UTF-8
C++
false
false
1,444
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "InteractableComp.h" #include "LatentInteractableComp.generated.h" /** * */ UCLASS(ClassGroup = (Interact), meta = (BlueprintSpawnableComponent)) class YANGINTERACT_API ULatentInteractableComp : public UInteractableComp { GENERATED_BODY() public: ULatentInteractableComp(); virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void TryToInterrupt() override; protected: /** [Server] On interact */ virtual void OnInteract(UInteractorComp* InteractorComp) override; /** [Server] On Interact, this function will run to check condition on every tick*/ virtual void OnInteractLatent(); /** [Server] + [Local] A value that determine how long the interaction will take place for*/ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Interact") float InteractDelayDuration; private: /** [Server] World Time during Interaction */ UPROPERTY(Transient) float InteractTime; /** * If true this Will set so that you don't have to hold for the Timer to continue */ UPROPERTY(EditDefaultsOnly, Category = "Interact") uint8 bTriggerTimer : 1; /** * If True, Character have to be facing at the actor while interacting */ UPROPERTY(EditDefaultsOnly, Category = "Interact") uint8 bShouldFaceInteractable : 1; };
[ "yangah9991@gmail.com" ]
yangah9991@gmail.com
0bd6a9a3364e9bddfee5c2b7b386bd499d16511d
24535f0ca647185cf9e5f54f30cf7d528d697068
/include/ezl/helper/meta/typeInfo.hpp
157029f2efdf03764d09a2248d0534e82d06cc83
[ "BSL-1.0" ]
permissive
littleflute/easyLambda
b04657f54e48d12f80afff70ec62e2d52079871b
e496a3e3070b806e8c48124d3454543c4cebc9b7
refs/heads/master
2021-01-21T07:21:17.422179
2016-04-06T21:59:42
2016-04-06T21:59:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,932
hpp
/*! * @file * Type info related to general operations, Map and Reduce(All) classes. * * This file is a part of easyLambda(ezl) project for parallel data * processing with modern C++ and MPI. * * @copyright Utkarsh Bhardwaj <haptork@gmail.com> 2015-2016 * Distributed under the Boost Software License, Version 1.0. * (See accompanying LICENSE.md or copy at * http://boost.org/LICENSE_1_0.txt) * */ #ifndef TYPEINFO_EZL_H #define TYPEINFO_EZL_H #include <vector> #include <tuple> #include <type_traits> #include <ezl/helper/meta/funcInvoke.hpp> #include <ezl/helper/meta/slctTuple.hpp> #include <ezl/helper/meta/slct.hpp> namespace ezl { namespace detail { namespace meta { // gives a uniform way/data-type wrapper abstraction by converting a type, tuple // of types, vector of type or vector of tuple in the tuple and vector of tuple // format. user defined function (UDF) can return in any of the format and it // can be fetched in the same way as tuple or vector of tuple. // // Not the best way but works for now. // TODO: implement in a way to reduce redundant code @haptork // For free types, delegates to tuple type /* template <typename... Ts> struct GetTupleType { // TODO: 1-decay 2-AOS2SOA @haptork using type = std::tuple<Ts...>; static auto getVTResults(Ts&&... t) { return GetTupleType<type>::getVTResults(std::make_tuple(std::forward<Ts>(t)...)); } static auto getTResults(Ts... t) { return GetTupleType<type>::getTResults(std::make_tuple(std::forward<Ts>(t)...)); } }; */ template <typename T> struct GetTupleType { // TODO: 1-decay 2-AOS2SOA @haptork using type = std::tuple<T>; auto getVTResults(T&& t) { std::vector<T> v; v.push_back(std::forward<T>(t)); return v; } auto getTResults(T t) { return t; } }; template <typename... Ts> struct GetTupleType<std::tuple<Ts...>> { using type = std::tuple<Ts...>; auto getVTResults(std::tuple<Ts...>&& a) { std::vector<type> v; v.push_back(std::move(a)); return v; } auto getTResults(std::tuple<Ts...> a) { return a; } }; template <typename T> struct GetTupleType<std::vector<T>> { using type = std::tuple<typename std::vector<T>::value_type>; auto getVTResults(std::vector<T> a) { return a; } }; template <typename... Ts> struct GetTupleType<std::vector<std::tuple<Ts...>>> { using type = std::tuple<Ts...>; auto getVTResults(std::vector<std::tuple<Ts...>> a) { return a; } }; // a collection of types that might be needed by a map based on the // input data type, selection and function. template <class I, class MSlct, class Func> struct MapDefTypes { using finp = typename SlctTupleType<I, MSlct>::type; using fout = typename GetTupleType<decltype(invokeMap( std::declval<typename std::add_lvalue_reference<Func>::type>(), std::declval<typename std::add_lvalue_reference<finp>::type>()))>:: type; using odefslct = typename fillSlct<0, std::tuple_size<I>::value + std::tuple_size<fout>::value>::type; }; // a collection of types that might be needed by a map based on the // input data type, selection and function. template <class I, class Func> struct MapDefTypesNoSlct { using fout = typename GetTupleType<decltype(invokeMap( std::declval<typename std::add_lvalue_reference<Func>::type>(), std::declval<typename std::add_lvalue_reference<I>::type>()))>:: type; using odefslct = typename fillSlct<0, std::tuple_size<I>::value + std::tuple_size<fout>::value>::type; }; // a collection of types that might be needed by a map based on the // input data type, selection, function and output type. template <class IT, class MSlct, class Func, class OSlct> struct MapTypes { using I = IT; using S = MSlct; using F = Func; using finp = typename SlctTupleRefType<I, MSlct>::type; using fout = typename GetTupleType<decltype(invokeMap( std::declval<typename std::add_lvalue_reference<Func>::type>(), std::declval<typename std::add_lvalue_reference<finp>::type>()))>:: type; constexpr static auto outsize = std::tuple_size<I>::value + std::tuple_size<fout>::value; using O = saneSlct_t<outsize, OSlct>; using otype = typename SlctTupleRefType<TupleTieType<I, fout>, O>::type; }; // BufType is needed for reduce-all in addition to tuple type as a // type wrapper extraction for the SOA/AOS type used in UDF. // // Again, not the best way but works for now. template <typename F, typename KT, typename VT, typename enable = void> struct BufType { static_assert(!std::is_same<enable, void>::value, "Function provided for\ reduceAll does not match the columns."); }; // buffer type for SOA template <typename F, typename... Ks, typename... Vs> struct BufType< F, std::tuple<Ks...>, std::tuple<Vs...>, typename std::enable_if<( can_call<F, std::tuple<Ks...>, std::tuple<std::vector<Vs>...>>{} || can_call<F, Ks..., std::vector<Vs>...>{})>::type> { using type = std::tuple<std::vector<Vs>...>; }; // buffer type for AOS template <typename F, typename... Ks, typename... Vs> struct BufType< F, std::tuple<Ks...>, std::tuple<Vs...>, typename std::enable_if<( can_call<F, std::tuple<Ks...>, std::vector<std::tuple<Vs...>>>{} || can_call<F, Ks..., std::vector<std::tuple<Vs...>>>{})>::type> { using type = std::vector<std::tuple<Vs...>>; }; // a collection of types for getting type info for reduce-all with default // output selection input data type, selection and function. template <class I, class Kslct, class Fslct, class Func> struct ReduceAllDefTypes { using ktype = typename SlctTupleRefType<I, Kslct>::type; using vtype = typename SlctTupleType<I, Fslct>::type; using buftype = typename BufType<Func, ktype, vtype>::type; using fout = typename GetTupleType<decltype(invokeReduceAll( std::declval<typename std::add_lvalue_reference<Func>::type>(), std::declval<typename std::add_lvalue_reference<ktype>::type>(), std::declval<typename std::add_lvalue_reference<buftype>::type>()))>:: type; using odefslct = typename fillSlct<0, std::tuple_size<ktype>::value + std::tuple_size<fout>::value>::type; }; // a collection of types for getting type info for reduce-all with default // output selection input data type, selection, function and output selection. template <class I, class K, class V, class F, class O> struct ReduceAllTypes { using itype = I; using Kslct = K; using Vslct = V; using Func = F; using ktype = typename SlctTupleType<I, K>::type; using vtype = typename SlctTupleType<I, V>::type; using buftype = typename BufType<F, ktype, vtype>::type; using fout = typename GetTupleType<decltype(invokeReduceAll( std::declval<typename std::add_lvalue_reference<F>::type>(), std::declval<typename std::add_lvalue_reference<ktype>::type>(), std::declval<typename std::add_lvalue_reference<buftype>::type>()))>:: type; constexpr static auto outsize = std::tuple_size<ktype>::value + std::tuple_size<fout>::value; using Oslct = saneSlct_t<outsize, O>; using otype = typename SlctTupleRefType<TupleTieType<ktype, fout>, saneSlct_t<outsize, Oslct>>::type; }; // a collection of types for getting type info for reduce with default // output selection input data type, selection and function. template <class I, class Kslct, class fout> struct ReduceDefTypes { using ktype = typename SlctTupleRefType<I, Kslct>::type; //using vtype = typename SlctTupleRefType<I, Vslct>::type; using odefslct = typename fillSlct<0, std::tuple_size<ktype>::value + std::tuple_size<fout>::value>::type; }; // a collection of types for getting type info for reduce with default // output selection input data type, selection, function and output selection. template <class I, class Kslct, class Vslct, class F, class fout, class OSlct> struct ReduceTypes { using itype = I; using K = Kslct; using V = Vslct; using Func = F; using FO = fout; using ktype = typename SlctTupleType<I, Kslct>::type; using ftuple = typename GetTupleType<fout>::type; constexpr static auto outsize = std::tuple_size<ktype>::value + std::tuple_size<ftuple>::value; using Oslct = saneSlct_t<outsize, OSlct>; using otype = typename SlctTupleRefType<TupleTieType<ktype, ftuple>, saneSlct_t<outsize, OSlct>>::type; using vtype = typename SlctTupleRefType<I, Vslct>::type; constexpr static bool isRefRes = std::is_lvalue_reference<decltype(invokeReduce( std::declval<typename std::add_lvalue_reference<F>::type>(), std::declval<typename std::add_lvalue_reference<ktype>::type>(), std::declval<typename std::add_lvalue_reference<vtype>::type>(), std::declval< typename std::add_lvalue_reference<fout>::type>()))>::value; }; template <class F, class P> struct LoadTypesImpl { using type = typename meta::SlctTupleRefType< typename GetTupleType< std::decay_t<decltype((std::get<0>(std::declval<P>())))> >::type >::type; }; template <class F, class T, class A> struct LoadTypesImpl<F, std::vector<T, A>> { using type = typename meta::SlctTupleRefType<typename GetTupleType<T>::type>::type; }; // types for Load template <class F> struct LoadTypes : LoadTypesImpl<F, decltype(std::declval<F>()())> {}; template<typename T> struct isVector : public std::false_type {}; template<typename T, typename A> struct isVector<std::vector<T, A>> : public std::true_type {}; template<typename... T> struct isTuple : public std::false_type {}; template<typename... T> struct isTuple<std::tuple<T...>> : public std::true_type {}; } }} // namespace ezl detail meta #endif //!TYPEINFO_EZL_H
[ "hap_tork@hotmail.com" ]
hap_tork@hotmail.com
abb12c8f93ea2e69b392b641e47677b31f8a27a2
09a5c6d7362cfa79c436f622a9b9229a659866d8
/src/othello.h
8890a8c71999008d41c3da07478a28c811857515
[]
no_license
nakamarusun/othello-minimax
a2f5ddbb1f2a409ac56be2503c9513a96e6f0b74
74dc648cca4d89304b4ccb39670300ecd3a3f894
refs/heads/main
2023-03-31T20:14:16.484125
2021-04-07T14:46:54
2021-04-07T14:46:54
353,460,862
0
0
null
null
null
null
UTF-8
C++
false
false
3,186
h
#pragma once #include <list> #include <stack> #include "othutil.h" #include "othengine.h" namespace oth { // 8 Directions to iterate, when checking adjacent cells const static int direction[8][2] = { {1, 1},{1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {0, 1} }; class Engine; /* Here, we define the othello board. Multiple othello boards can be made in this config */ class Othello { private: friend class Engine; // Describes what color a cell is occupying. // It also describes possible moves. struct Cell { // The piece color that occupies this cell. Color col; Cell(); }; // Struct for the undo stack. struct UndoData { Color col; Point coor; UndoData(Color col, Point coor); }; // Scores int whiteScore; int blackScore; // Store engine objects. Engine* whiteEngine; Engine* blackEngine; // Helper variable to keep trach whether a tile is checked for potential moves. bool** _checked; // Matrix to store the current state of the board with the cells. Cell** board; // List to store all the active pieces' coordinates. std::list<Point> activePieces; // Makes everything in checked to be false. void _resetChecked(); // Reset all the potential moves. void _resetPotentialMoves(); // This function adds a new piece to the board, and do all the game calculations. // Returns whether the operation is successful. bool updatePiece(Color color, int x, int y); // Recalculates all possible moves, and puts it in an array. void updateValidMoves(); // Checks if a tile can be placed in this position. void updatePotentialCell(int x, int y); // Walks the board to the specified direction. Will return the color // Of something that is different. Color walkBoard(int x, int y, const int* direction); public: // Store potential moves std::list<Point> whiteMove; std::list<Point> blackMove; // Board size const int size; // Game pauses after "enter" is inputted. bool pauseEveryTurn = true; // Whose turn is it Color turn; // Stack to store the undos // The first index of the list is always the move that is played. std::stack<std::list<UndoData>> undos; // Initializes the othello board, with all the variables. Othello(int size, Engine& whiteEngine, Engine& blackEngine); // Deallocate mem ~Othello(); // This function is to add a new piece to the board and nothing else. void playPiece(Color color, int x, int y, bool addUndoStack); // Gets the score of the specified color int getScore(Color color); // Undoes one move, and pops one from the stack. void undoMove(); // Draws the board in the command line. void drawBoard(); // Swaps the turn, and returns the current turn. Color switchTurn(); // Starts the game, with turn being the first color to go. // pauseEveryTurn dictates whether the game needs "enter" input // Everytime a turn is over. void startGame(Color turn); }; }
[ "nakamarujc@gmail.com" ]
nakamarujc@gmail.com
16e35d358ad246542332f600cea5663c483ccaff
1de4785a61b3673359ce1067bd285d70abc88cd6
/src/event/evshortpress.h
242093d228b05cae920046a27f1384b79fda8136
[]
no_license
MartinMeyer1/ButtonManager
6c1a5b921bd3e37893814ba58ba897376191c0ac
4f4aa5d86637830872c5ce56e2177c0abd326a17
refs/heads/master
2021-04-23T22:12:10.545198
2020-04-07T20:28:31
2020-04-07T20:28:31
250,017,811
0
0
null
null
null
null
UTF-8
C++
false
false
338
h
/* * evshortpress.h * * Created on: 6 avr. 2020 * Author: meyer */ #ifndef EVSHORTPRESS_H_ #define EVSHORTPRESS_H_ #include "xf/customevent.h" #include "events.h" class evShortPress : public XFCustomEvent { public: evShortPress(int buttonIndex); virtual ~evShortPress(); int buttonIndex; }; #endif /* EVSHORTPRESS_H_ */
[ "meyer.mart@outlook.com" ]
meyer.mart@outlook.com
e31550fca56d086cbd4468bdf2cfb515e909db48
bf77777f45ee31412d11a8f8132ae90da2a372ba
/Libraries/LibJS/Cell.cpp
3aedb7cb66d565dd69712fee13c7acc74bb164f8
[ "BSD-2-Clause" ]
permissive
adityavs/serenity
27d0821f7c334fe05f394d1fb48087b184646e95
11aac6fdceb9a3904ad3eb51d887c63a6dc91b74
refs/heads/master
2021-03-05T06:21:58.065524
2020-03-09T13:37:08
2020-03-09T13:37:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,688
cpp
/* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> * 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 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. */ #include <AK/LogStream.h> #include <LibJS/Cell.h> namespace JS { const LogStream& operator<<(const LogStream& stream, const Cell* cell) { if (!cell) return stream << "Cell{nullptr}"; return stream << cell->class_name() << '{' << static_cast<const void*>(cell) << '}'; } }
[ "kling@serenityos.org" ]
kling@serenityos.org
e152533fcfebdd5c284687c30c22076df1359314
7105d8cf4a4d14e326dda4adf5c8a5403f3d092f
/ImplicitAndExplicitScheme/ExplicitScheme.h
e31e84a5c3e0c5c9f8beded8a95d34dda90a57ce
[]
no_license
Etienne-So/computational_methods
337484eabdc027c0d03aa59b07dc03f47cea208d
37a5541504533c8d73d7f17ce7e1d368056b1038
refs/heads/main
2023-02-12T03:06:45.386174
2021-01-12T15:46:05
2021-01-12T15:46:05
329,029,144
0
1
null
null
null
null
UTF-8
C++
false
false
1,180
h
#ifndef EXPLICITSCHEME_H //include guard #define EXPLICITSCHEME_H #include "Scheme.h" //Mother class #include <iostream> //generic IO #include <string> //for string methods #pragma once /** * Inherited class, which includes implicit schemes like: * Up Wind Forward-Time Backward-Space and Forward-Time Central-Space. * Additionally, class includes private method with Thomas Algorithm. **/ class ExplicitScheme : public Scheme { public: /** * Default, empty constructor for ExplicitScheme class. **/ ExplicitScheme(); /** * Public method, which solves the difference using explicit scheme Up Wind Forward-Time Backward-Space * @return string - name of method for saving result into files with proper name * @see SaveResultIntoFiles(double deltaT, string schemeName) **/ string ExplicitUpWindFTBS(); /** * Public method, which solves the difference using explicit scheme Lax-Wandroff * @return string - name of method for saving result into files with proper name * @see SaveResultIntoFiles(double deltaT, string schemeName) **/ string ExplicitLaxWandroff(); /** *Default, empty destructor for ExplicitScheme class. **/ ~ExplicitScheme(); }; #endif
[ "noreply@github.com" ]
noreply@github.com
590a0c8112ce2632f6e206bedc6bd76f0aac542f
4259be0689846ad5bd384262a8582d31500eb416
/basics/src/bitwise.cpp
9fbb5dc2d7a554dfac1ee010d4c1579de41f333e
[]
no_license
tearoom6/opencv3-samples
f4ea33dc19e86be68510702f6f3bc054b06d4415
3e859af41bd66a32041f355016df6cf99b55be17
refs/heads/master
2021-04-09T17:07:41.076443
2018-03-18T06:17:11
2018-03-18T06:17:11
125,697,933
0
0
null
null
null
null
UTF-8
C++
false
false
722
cpp
// // Original copyright: // (c)Copyright Spacesoft corp., 2016 All rights reserved. // Hiro KITAYAMA // #include <opencv2/opencv.hpp> #pragma comment(lib,"opencv_world310.lib") using namespace cv; using namespace std; int main(int argc, char* argv[]) { try { UMat src, dst; if (argc < 2) throw ("not enough parameters specified. Specify: <filename>."); imread(argv[1]).copyTo(src); bitwise_not(src, dst); imshow("src", src); imshow("dst", dst); imwrite("tmp/bitwise.jpg", dst.getMat(ACCESS_RW)); waitKey(0); } catch (const char* str) { cerr << str << endl; } return 0; }
[ "tomohiro.murota@gmail.com" ]
tomohiro.murota@gmail.com
4927b34e42b93ae862ff085b4ba21035481fa292
3039194199bedf2373989aba10a8fb9e81a696be
/Src/BlueLightSPS/Blue/UILib/SwitchButton.h
c5f06ef2512f44b09f73cf589e50ac955b4e3823
[]
no_license
Patrick-Wang/BlueRay
c85f3f24cf8a5bae7b08e81098d367973ca68365
6d25157eb292c59210b3520937e8fed1597f4479
refs/heads/master
2021-01-19T01:56:57.008275
2017-06-05T01:55:21
2017-06-05T01:55:21
25,848,961
0
0
null
null
null
null
UTF-8
C++
false
false
1,501
h
/*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C Class: CSwitchButton Summary: Author: sunfd 2011/6/11 Methods: C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ #pragma once #include "bsbutton.h" #include "BSStatic.h" #define WM_SWITCH_POS_CHANGE WM_APP + 521 typedef enum tagSwitchPicEnum { LEFT, RIGHT, SWITCH_END }SwitchEnum; typedef enum tagStateEnum { SWST_NORMAL, SWST_PUSH, SWBTN_END = 2 }StateEnum; class CSwitchButton : public CBSButton { public: CSwitchButton(void); ~CSwitchButton(void); void SetSwitchPic(SwitchEnum enSwitchBtn, StateEnum enSwitchState, UINT uiID); void SetSwitchText(SwitchEnum enSwitchPic, CString cstrText); void SetSwithcColor(SwitchEnum enSwitchPic, COLORREF dwColor); void SetSwitchState(SwitchEnum enSwitch); SwitchEnum GetSwitchState(void) {return m_enSwitch;} void SetInnerScale(float fScale_X, float fScale_Y); void SetInnerOffSet(POINT& pt); DECLARE_MESSAGE_MAP() void GetSwitchRect(CRect& rcSwtich); void OnMouseMove(UINT nFlags, CPoint point); //void OnLButtonDown(UINT nFlags, CPoint point); //void OnLButtonUp(UINT nFlags, CPoint point); void OnLButtonDblClk(UINT nFlags, CPoint point);//wsh add afx_msg void OnPaint(); protected: UINT m_auiPicID[SWITCH_END][SWBTN_END]; CString m_astrText[SWITCH_END]; COLORREF m_adwColor[SWITCH_END]; SwitchEnum m_enSwitch; StateEnum m_enSwState; float m_fInnerScale_X; float m_fInnerScale_Y; CPoint m_ptOffset; };
[ "sun.sunshine@163.com" ]
sun.sunshine@163.com