blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
5347eb46e14d3a9b014e255dba3de1718471f7da
a9e416db797908d0533da4062dae4060a07ff7fd
/src/loaders/grid_game_loader.cpp
3e695755cfe827385564b795d1cb3737b9e513fb
[ "WTFPL" ]
permissive
dfyx/jumping-cubes-tactics
b7a1f73d3742816b2bc3ce07ae751181af0cf7d9
30a96816ebe698302f3cc0a8d4971f68689508a0
refs/heads/master
2021-01-22T04:49:17.013675
2015-01-28T19:56:40
2015-01-28T19:56:40
15,534,874
1
0
null
null
null
null
UTF-8
C++
false
false
3,932
cpp
#include "grid_game_loader.h" #include "grid_game_loader_p.h" #include "../gamedata/game.h" #include "../gamedata/node.h" #include "../gamedata/edge.h" #include "../graphics/node_sprite.h" #include "../graphics/edge_sprite.h" #include <vector> namespace JCT_SFML { namespace Loaders { GridGameLoader::GridGameLoader(unsigned int width, unsigned int height, float distance) { d = new GridGameLoaderPrivate(); d->width = width; d->height = height; d->distance = distance; d->game = NULL; } GridGameLoader::~GridGameLoader() { delete d; } Gamedata::Game *GridGameLoader::game() { if(d->game == NULL) { generateGame(); } return d->game; } std::vector<Graphics::NodeSprite*> GridGameLoader::nodeSprites() { if(d->game == NULL) { generateGame(); } return d->nodeSprites; } std::vector<Graphics::EdgeSprite*> GridGameLoader::edgeSprites() { if(d->game == NULL) { generateGame(); } return d->edgeSprites; } void GridGameLoader::generateGame() { d->game = new Gamedata::Game(); std::vector<Gamedata::Node*> nodes; std::vector<Gamedata::Edge*> edges; // Generate nodes for(int y = 0; y < d->height; y++) { for(int x = 0; x < d->width; x++) { Gamedata::Node* node = new Gamedata::Node(); Graphics::NodeSprite* nodeSprite = new Graphics::NodeSprite(node); nodeSprite->setPosition(sf::Vector2f((x + 1) * d->distance, (y + 1) * d->distance)); d->game->addNode(node); nodes.push_back(node); d->nodeSprites.push_back(nodeSprite); } } // Generate edges for(int y = 0; y < d->height; y++) { for(int x = 0; x < d->width; x++) { Gamedata::Node *node = nodes[y * d->width + x]; Graphics::NodeSprite *nodeSprite = d->nodeSprites[y * d->width + x]; if(x > 0) { size_t index = y * d->width + x - 1; Gamedata::Edge* edge = new Gamedata::Edge(node, nodes[index]); Graphics::EdgeSprite* edgeSprite = new Graphics::EdgeSprite(nodeSprite, d->nodeSprites[index]); node->addEdge(edge); edges.push_back(edge); d->edgeSprites.push_back(edgeSprite); } if(y > 0) { size_t index = (y - 1) * d->width + x; Gamedata::Edge* edge = new Gamedata::Edge(node, nodes[index]); Graphics::EdgeSprite* edgeSprite = new Graphics::EdgeSprite(nodeSprite, d->nodeSprites[index]); node->addEdge(edge); edges.push_back(edge); d->edgeSprites.push_back(edgeSprite); } if(x < d->width - 1) { size_t index = y * d->width + x + 1; Gamedata::Edge* edge = new Gamedata::Edge(node, nodes[index]); node->addEdge(edge); } if(y < d->height - 1) { size_t index = (y + 1) * d->width + x; Gamedata::Edge* edge = new Gamedata::Edge(node, nodes[index]); node->addEdge(edge); } } } } } }
[ "dfyx@wecallit42.de" ]
dfyx@wecallit42.de
4ccec7a8369ef378c398ba8ab9344d9d77558571
c8d01fd999a74fd3912bc43c942e2a924ef8f3ef
/数值计算/第三次实验/3_1.cpp
6fefe0149868eb99723cb5c495cc580de6c14aeb
[]
no_license
fdl66/homework
1166359019d3e8bee7c04f01267d5e3b8f6ec789
8a8b8ff5c14e1149b01f9a6d9c8e93eba704aca6
refs/heads/master
2021-01-17T20:43:42.764358
2016-06-30T13:50:13
2016-06-30T13:50:24
60,970,802
0
0
null
null
null
null
GB18030
C++
false
false
499
cpp
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> using namespace std; double f(double x) { return 1/(1+pow(x,2)); } int main() { int k,n; cout<<"请输入区间等分次数:"<<endl; cin>>k; n=pow(2,k); double fk[20]; memset(fk,0,sizeof(fk)); double ans=0; for(int i=0;i<=n;i++){ fk[i]=f(i/(n)); } ans+=(fk[0]+fk[n]); for(int i=1;i<=n-1;i++){ if(i%2==1)ans+=fk[i]*4; else ans+=fk[i]*2; } ans/=(6*n/2); printf("方程的解为:%lf\n",ans); return 0; }
[ "fan0816fan@163.com" ]
fan0816fan@163.com
0abfd3d267d1873b2b7a1e1f8124d4621095dfc8
e648e2159d46592105ec9980870af113c1aa9d7f
/MGS1600.cpp
096d5d088f7d8baea327938d9c4aaf45541a04cd
[]
no_license
imamovSokhib/RoboteQ_MGS1600_Arduino_library
1fdf8c006a5e2b6c4ece151ea40a2dc2d7d84391
36ee405bcdae3c04c7861223be53f63bd976fc0f
refs/heads/master
2021-03-15T09:50:07.723600
2016-08-15T16:03:11
2016-08-15T16:03:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,363
cpp
#include "MGS1600.h" //-- public methods --// //<<constructor>> MGS1600::MGS1600(int _powerControl, int _forkRight, int _forkLeft, int _analogOut, int _pwmOut, int _leftMarker, int _rightMarker, int _trackPresent) { powerControl = _powerControl; forkRight = _forkRight; forkLeft = _forkLeft; analogOut = _analogOut; pwmOut = _pwmOut; leftMarker = _leftMarker; rightMarker = _rightMarker; trackPresent = _trackPresent; leftMarkerDetected = false; rightMarkerDetected = false; // configure pin I/O state pinMode(powerControl, OUTPUT); pinMode(forkRight, OUTPUT); pinMode(forkLeft, OUTPUT); pinMode(analogOut, INPUT); pinMode(pwmOut, INPUT); pinMode(leftMarker, INPUT); pinMode(rightMarker, INPUT); pinMode(trackPresent, INPUT); // initialize outputs digitalWrite(powerControl, HIGH); // turn sensor on digitalWrite(forkRight, LOW); digitalWrite(forkLeft, HIGH); } //<<destructor>> MGS1600::~MGS1600() { } unsigned int MGS1600::readAnalog() { return analogRead(analogOut); } unsigned long MGS1600::readPulse() { return pulseIn(pwmOut, HIGH, 5000); } bool MGS1600::trackDetected() { return digitalRead(trackPresent); } void MGS1600::setForkLeft() { digitalWrite(forkLeft, true); digitalWrite(forkRight, false); } void MGS1600::setForkRight() { digitalWrite(forkLeft, false); digitalWrite(forkRight, true); } //-- private methods --//
[ "SuperDroid Robots" ]
SuperDroid Robots
b7b76cf7f129fb26c36435270c09c1476ee04f85
053b02a2d36956d2ed45bd8a4a6177e3ba8493e3
/testxau.cpp
a22e4efb41b8f6ea3fc0ffaba70bd7c0a4d5bb0f
[]
no_license
phgtrungduc/C
89740bd24a5834027e8146b24979e843ecb7302e
88ea844e791a1c8728e461e211f91b56881654f1
refs/heads/master
2022-12-05T18:17:07.812578
2020-08-19T14:14:58
2020-08-19T14:14:58
288,749,295
0
0
null
null
null
null
UTF-8
C++
false
false
289
cpp
#include<stdio.h> #include<string.h> int main() { int n,i,j; char a[1000]; printf("nhap xau: "); gets(a); n= strlen(a); for (i=0;i<n;i++) { if (a[i]==' ') { for (j=i;j<n;j++) a[j]=a[j+1]; i--; } } for (i=strlen(a)-1;i>=0;i--) { printf("%c",a[i]); } return 0; }
[ "duc.pt173030@sis.hust.edu.vn" ]
duc.pt173030@sis.hust.edu.vn
3bbaedf0c2db4abc858bebfd12e77618af224bae
d20cf7de868dfb2c53578a70d0dda21306167d72
/data/preprocessed/train/student_48/headers/Renderer.h
e9e7f4c4a4074d3406cb393300a4a224f37038d0
[]
no_license
bulacu-magda/Alemia
905a84ca79157fb657eb424e337b0303fd3323bd
0fd019c4517064d300399feb94dbcb0f467e8d48
refs/heads/main
2023-03-01T17:41:08.788500
2021-02-05T08:00:35
2021-02-05T08:00:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
732
h
#pragma once #include "Transform.h" #include "Sprite.h" #include "NextLevelConsoleHandler.h" class Renderer final: public Component // public Component<Renderer> { ConsoleHandlerV2& output; const Transform& transform; const Sprite& spriteToRender; public: Renderer() = delete; Renderer(const Renderer&) = delete; Renderer& operator=(const Renderer&) = delete; Renderer(const Transform& transform, const Sprite& sprite); Renderer(const Transform& transform, const Sprite& sprite, const bool isRemovable); ~Renderer(); private: void Update() override final; void Start() override final; void End() override final; void print(const C2D::Vector2&, int, int); }; // std::string Component<Renderer>::_desc = "Renderer";
[ "ionutm.bajan@yahoo.com" ]
ionutm.bajan@yahoo.com
132849d844cc95d19784669b6cd44681a80b77af
0e042c084880bf05a2915f331fb727160333f964
/Programming/tensor++/array.cpp
ea2ce05f40eda62e78a8c75773634204286fc06c
[]
no_license
gravmath/Projects
5e60372141edca97e04468efef1294a74d1b6a36
4cc6f662742cbb2bdd1bc75fa34401a4251e2388
refs/heads/master
2023-06-24T13:36:26.705562
2023-06-19T17:11:51
2023-06-19T17:11:51
1,188,266
1
0
null
null
null
null
UTF-8
C++
false
false
29,067
cpp
//****************************************************************************** //Name: array.cpp * // * //Purpose: source file for defining the array class * // * //Modification History: 10/24/98 - added modification history field * // 05/21/99 - improve speed performance by coding member * // functions as direct access for 7 or fewer * // indices - affected Set, Val, * // 05/21/99 - made the straight Set and Val calls inlines* // 05/23/99 - made inline functions to return the number * // of array elements and the scales array * // made the NumIndices inline * // made a Resize0 for speed * // 06/18/99 - renamed Resize0 to Mimic and moved the data* // structure to public * // 06/19/99 - new implementation of Resize0 * // 04/05/03 - added path name for array.hpp include //****************************************************************************** #include "\school\Programming\tensor++\array.hpp" //****************************************************************************** //Name: array constructor * // * //Purpose: allocate flat space for storage and index data for accessing * // * //Takes: no args and is the default constructor * //****************************************************************************** array::array(void) { //Allocate space for the structure that holds the array p = new array_rep; //Default number of indices and product p->num_indices = 1; p->product = 3; //Allocate the range array and set its default p->range = new int [p->num_indices]; p->range[0] = 3; //Allocate the scales array and set its default p->scales = new int [p->num_indices]; p->scales[0] = 1; //Allocate space for the actual array to accomodate operator = definition p->m = new double [p->product]; //Initialize the array to zeros memset(p->m,0,p->product*sizeof(double)); //Record number of objects pointing to the same memory p->n = 1; } //****************************************************************************** //Name: array constructor * // * //Purpose: allocate flat space for storage and index data for accessing * // * //Takes: variable argument list with the number of indices and range for each * //****************************************************************************** array::array(int num_indices, int range1, ...) { va_list arg_pnt; int product; int range_i; int i; int one_already = 0; //Allocate space for the structure that handles the array and its relations p = new array_rep; //Set the structures number of indices p->num_indices = num_indices; //Allocate space for the relations that allow indexing into the array p->range = new int [p->num_indices]; p->scales = new int [p->num_indices]; //Set a pointer to the variable list va_start(arg_pnt, range1); //Fill in the range array p->range[0] = range1; product = range1; for( i = 1; i < num_indices ; i++) { range_i = va_arg(arg_pnt, int); p->range[i] = range_i; product *= range_i; } //Fill in the scales array p->scales[0] = product/p->range[0]; for( i = 1; i< num_indices; i++) { p->scales[i] = p->scales[i-1]/p->range[i]; if( p->scales[i] == 1 && one_already == 1) p->scales[i] = 0; if( p->scales[i] == 1 && one_already == 0) one_already = 1; } //Clean up the variable arg list pointer va_end(arg_pnt); //Set the structure's knowledge of the number of total items in the array p->product = product; //Allocate space for the actual array p->m = new double [ product ]; //Initialize the array to zeros memset(p->m,0,product*sizeof(double)); //Record number of objects pointing to the same memory p->n = 1; } //****************************************************************************** //Name: array copy constructor * // * //Purpose: point copy to the same memory and keep track of duplicates * // * //Takes: address of array to be copied * //****************************************************************************** array::array(array &x) { x.p->n++; p = x.p; } //****************************************************************************** //Name: array operator assignment * // * //Purpose: set the memory of one object equal to another * // * //Takes: address of array to be assigned * //****************************************************************************** array& array::operator=(const array &rval) { if( --p->n == 0 ) { delete [] p->m; delete [] p->range; delete [] p->scales; delete p; } rval.p->n++; p = rval.p; return *this; } //****************************************************************************** //Name: array non-referencing assignment * // * //Purpose: memcpy the memory of one array to another * // * //Takes: address of array to be assigned * //****************************************************************************** array& array::operator<=(const array &rval) { int i; int n, *r; int test = 0; //Check to see if the two arrays have the same size and number of indices //if not resize this if( (p->product != rval.p->product) || (p->num_indices != rval.p->num_indices) ) { n = rval.NumIndices(); r = rval.Ranges(); Resize(n,r); delete [] r; } //Check to see if the two arrays have the same ranges //if not resize this for( i = 0; i < p->num_indices ; i++ ) if( p->range[i] != rval.p->range[i] ) test = 1; if( test == 1 ) { n = rval.NumIndices(); r = rval.Ranges(); Resize(n,r); delete [] r; } //Now memcpy the rval arrays values into this memcpy( p->m, rval.p->m, p->product*sizeof(double) ); return *this; } //****************************************************************************** //Name: array destructor * // * //Purpose: delete object but care after the memory * // * //Takes: nothing * //****************************************************************************** array::~array() { if( --(p->n) == 0) { delete [] p->m; delete [] p->range; delete [] p->scales; delete p; } } //****************************************************************************** //Name: array Ranges * // * //Purpose: returns a pointer to an array containing the ranges for each index * // * //Takes: * //****************************************************************************** int* array::Ranges(void) const { int *range; //Allocate space for the range array range = new int[p->num_indices]; //Now memcpy the rval arrays values into this memcpy( range, p->range, p->num_indices*sizeof(int) ); return range; } //****************************************************************************** //Name: array Scales * // * //Purpose: returns a pointer to an array containing the scales for each index * // * //Takes: * //****************************************************************************** int* array::Scales(void) const { int *scales; //Allocate space for the range array scales = new int[p->num_indices]; //Now memcpy the rval arrays values into this memcpy( scales, p->scales, p->num_indices*sizeof(int) ); return scales; } //****************************************************************************** //Name: array SetName * // * //Purpose: set the name in the array with an input string (for debug) * // * //Takes: * //****************************************************************************** void array::SetName(char *name) { //string copy the name into the member data strcpy(p->name,name); } //****************************************************************************** //Name: array Resize * // * //Purpose: allocate flat space for storage and index data for accessing * // * //Takes: number of indices, first range, ... * //****************************************************************************** int array::Resize(int num_indices, int range1, ...) { int i, *range; //Allocate space for the range array range = new int[num_indices]; va_list arg_resize; //Set up the pointer to the variable arg list va_start(arg_resize, range1); //Pack the range array range[0] = range1; for(i = 1; i < num_indices; i++) range[i] = va_arg(arg_resize,int); //Call Resize to change size of structure parameters if( !Resize(num_indices, range) ) return FALSE; //Clean up va_end(arg_resize); delete [] range; return TRUE; } //****************************************************************************** //Name: array Resize -- To Be Called from a Derived Class * // * //Purpose: allocate flat space for storage and index data for accessing * // * //Takes: number of indices, range array, * //****************************************************************************** int array::Resize(int num_indices, int *range) { int product; int i; int one_already; one_already = 0; //check to make sure nobody else is pointing at the memory if( p->n != 1) error("Resize error:", "Cannot Resize - multiple objects pointing to the same memory"); delete [] p->m; delete [] p->range; delete [] p->scales; //Reallocate the range and scale arrays with the new size p->range = new int [num_indices]; p->scales = new int [num_indices]; //Update the structure's knowledge of the number of indices p->num_indices = num_indices; //Setup range array p->range[0] = range[0]; product = range[0]; for( i = 1; i < num_indices ; i++) { if( range[i] == 0 ) error("Resize error:","missing or bad index"); p->range[i] = range[i]; product *= range[i]; } //Setup scales array p->scales[0] = product/p->range[0]; for( i = 1; i< num_indices; i++) { p->scales[i] = p->scales[i-1]/p->range[i]; if( p->scales[i] == 1 && one_already == 1) p->scales[i] = 0; if( p->scales[i] == 1 && one_already == 0) one_already = 1; } //Tell the structure how many array elements there are p->product = product; //Allocate space for the actual array p->m = new double [ product ]; //Initialize the array to zeros memset(p->m,0,product*sizeof(double)); //Reset the number of things pointing p->n = 1; return TRUE; } //****************************************************************************** //Name: array Resize0 -- To Be Called from a Derived Class (for speed) * // * //Purpose: allocate flat space for storage and index data for accessing but * // doesn't initialize the data array // * //Takes: number of indices, range array, * //****************************************************************************** int array::Resize0(int num_indices, int *range) { int product; int i; int one_already; one_already = 0; //check to make sure nobody else is pointing at the memory if( p->n != 1) error("Resize error:", "Canot Resize - multiple objects pointing to the same memory"); delete [] p->m; delete [] p->range; delete [] p->scales; //Reallocate the range and scale arrays with the new size p->range = new int [num_indices]; p->scales = new int [num_indices]; //Update the structure's knowledge of the number of indices p->num_indices = num_indices; //Setup range array p->range[0] = range[0]; product = range[0]; for( i = 1; i < num_indices ; i++) { if( range[i] == 0 ) error("Resize error:","missing or bad index"); p->range[i] = range[i]; product *= range[i]; } //Setup scales array p->scales[0] = product/p->range[0]; for( i = 1; i< num_indices; i++) { p->scales[i] = p->scales[i-1]/p->range[i]; if( p->scales[i] == 1 && one_already == 1) p->scales[i] = 0; if( p->scales[i] == 1 && one_already == 0) one_already = 1; } //Tell the structure how many array elements there are p->product = product; //Allocate space for the actual array p->m = new double [ product ]; //Reset the number of things pointing p->n = 1; return TRUE; } //****************************************************************************** //Name: array Mimic -- To Be Called from a Derived Class for speed * // * //Purpose: make the data structure for the lval object mimic the rval without * // copying the data values * // * //Takes: number of indices, range array, * //****************************************************************************** int array::Mimic(const array &rval) { //check to make sure nobody else is pointing at the memory if( p->n != 1) error("Mimic error:", "Cannot Mimic - multiple objects pointing to the same memory"); delete [] p->m; delete [] p->range; delete [] p->scales; //Reallocate the range and scale arrays with the new size p->range = new int [rval.p->num_indices]; p->scales = new int [rval.p->num_indices]; //Update the structure's knowledge of the number of indices p->num_indices = rval.p->num_indices; memcpy( p->range, rval.p->range, p->num_indices*sizeof(int) ); memcpy( p->scales, rval.p->scales, p->num_indices*sizeof(int) ); p->product = rval.p->product; //Allocate space for the actual array p->m = new double [ p->product ]; //Reset the number of things pointing p->n = 1; return TRUE; } //****************************************************************************** //Name: array Val * // * //Purpose: returns to value of the array given the indices * // * //Takes: variable list of indices * //****************************************************************************** double array::Val(int range0, int range1, int range2, int range3, int range4, int range5, int range6, int range7, ...) const { double return_val; int *range, i; //Allocate space for the range array range = new int[p->num_indices]; //Initialize the variable argument list va_list arg_pnt; va_start(arg_pnt,range7); //Pack the range array range[0] = range0; range[1] = range1; range[2] = range2; range[3] = range3; range[4] = range4; range[5] = range5; range[6] = range6; range[7] = range7; for(i = 8; i < p->num_indices; i++) range[i] = va_arg(arg_pnt,int); //Get the return value return_val = Val(range); //Clean up va_end(arg_pnt); delete [] range; return return_val; } //****************************************************************************** //Name: array Val * // * //Purpose: returns to value of the array given the indices * // * //Takes: array of indices -- for use by derived classes * //****************************************************************************** double array::Val(int *range) const { int i, product; product = range[0] * p->scales[0]; if( p->num_indices == 1 && p->range[0] == 1) product = 0; for( i = 1; i < p->num_indices; i++) product += range[i] * p->scales[i]; if( product > p->product ) error("Value error:","indices out of bounds"); return p->m[product]; } //****************************************************************************** //Name: array Set * // * //Purpose: allows the value of the array to be set given the indices * // * //Takes: variable list of indices * //****************************************************************************** void array::Set(double value, int range0, int range1, int range2, int range3, int range4, int range5, int range6, int range7, ...) { int *range, i; //Allocate space for the range array range = new int[p->num_indices]; //Initialize the variable argument list va_list arg_pnt; va_start(arg_pnt,range7); //Pack the range array range[0] = range0; range[1] = range1; range[2] = range2; range[3] = range3; range[4] = range4; range[5] = range5; range[6] = range6; range[7] = range7; for(i = 8; i < p->num_indices; i++) range[i] = va_arg(arg_pnt,int); //Set the value Set(value, range); //Clean up va_end(arg_pnt); delete [] range; } //****************************************************************************** //Name: array Set * // * //Purpose: allows the value of the array to be set given the indices * // * //Takes: array of indices * //****************************************************************************** void array::Set(double value, int *range) { int product, i; product = range[0] * p->scales[0]; if(p->num_indices == 1 && p->range[0] == 1) product = 0; for( i = 1; i < p->num_indices; i++) product += range[i] * p->scales[i]; if( product > p->product ) error("Set error:", "indices out of bound"); p->m[product] = value; } //****************************************************************************** //Name: array max * // * //Purpose: returns the maximum absolute value of an array * // * //Takes: * //****************************************************************************** double array::max(void) const { double ret_val = 0; double temp; int i; for( i = 0; i < p->product; i++) { temp = fabs(p->m[i]); if( temp > ret_val ) ret_val = temp; } return ret_val; } //****************************************************************************** //Name: array print * // * //Purpose: prints out the value of the array given the indices * // * //Takes: a message string and variable list of indices * //****************************************************************************** void array::print(const char *msg, int range1, ...) const { int *range, i; //Allocate space for the range array range = new int[p->num_indices]; //Initialize the variable argument list va_list arg_list; va_start(arg_list,range1); //Pack the range array range[0] = range1; for(i = 1; i < p->num_indices; i++) range[i] = va_arg(arg_list,int); double value; value = Val(range); if(*msg) cout << msg; cout << setw(6) << setprecision(3) << value; //Clean up va_end(arg_list); delete [] range; } //****************************************************************************** //Name: array print * // * //Purpose: prints out the values in the whole array with indices * // * //Takes: * //****************************************************************************** void array::print(const char *msg, char **buffer) const { int *index, i, j, temp, counter, num_indices; int size_of_name; //find the size of the name //accounting for the [0,0,..] = ## format //using 2*p->num_indices - 1 for the 0,0,... format //using 5 for the [ ] space = space format //using 30 digits for the output size_of_name = strlen(msg); size_of_name = size_of_name + 2*p->num_indices - 1 + 5 + 30; if( *buffer != NULL ) delete [] *buffer; *buffer = new char[p->product*size_of_name + 1]; (*buffer)[0] = '\0'; //handle scalars separately if(p->product == 1) { //fill the buffer line counter = strlen(*buffer); strcpy((*buffer)+counter,msg); counter = strlen(*buffer) - 1; (*buffer)[counter + 1] = '['; (*buffer)[counter + 2] = '0'; (*buffer)[counter + 3] = ']'; (*buffer)[counter + 4] = ' '; (*buffer)[counter + 5] = '='; (*buffer)[counter + 6] = ' '; sprintf((*buffer)+ counter + 7,"%g\n",Val(0)); counter = strlen(*buffer); (*buffer)[counter] = '\0'; return; } //test for range = 1 indices num_indices = p->num_indices; for(i = 0; i < p->num_indices; i++) { if(p->range[i] == 1) num_indices--; } index = new int[p->num_indices]; for(i = 0; i < p->product; i++) { //pack the index array testing for range = 1 cases temp = 0; for(j = 0; j < num_indices - 1; j++) { index[j] = (i - i%p->scales[j] - temp)/p->scales[j]; temp += index[j] * p->scales[j]; } //range = 1 testing starts here if( num_indices < p->num_indices) { index[num_indices - 1] = (i - temp)/p->scales[num_indices - 1]; for(j = num_indices; j < p->num_indices; j++) index[j] = 0; } else { index[j] = (i - temp)/p->scales[j]; } //fill the buffer line counter = strlen(*buffer); strcpy((*buffer)+counter,msg); counter = strlen(*buffer) - 1; (*buffer)[counter + 1] = '['; (*buffer)[counter + 2] = '\0'; for(j = 0; j < p->num_indices; j++) { counter = strlen(*buffer); sprintf( ((*buffer) + counter),"%d,\0",index[j]); } counter = strlen(*buffer); (*buffer)[counter - 1] = ']'; (*buffer)[counter] = ' '; (*buffer)[counter + 1] = '='; (*buffer)[counter + 2] = ' '; sprintf((*buffer)+ counter + 3,"%g\n",Val(index)); } //terminate the string properly counter = strlen(*buffer); (*buffer)[counter+1] = '\0'; //clean-up delete [] index; } //****************************************************************************** //Name: array print * // * //Purpose: prints out the values in the whole array without indices * // * //Takes: * //****************************************************************************** void array::print(char **buffer) const { int *index, i, j, temp, num_indices, counter; //test for range = 1 indices num_indices = p->num_indices; for(i = 0; i < p->num_indices; i++) { if(p->range[i] == 1) num_indices--; } index = new int[p->num_indices]; if( *buffer != NULL ) delete [] *buffer; *buffer = new char[p->product*41 + 1]; (*buffer)[0] = '\0'; for(i = 0; i < p->product; i++) { //pack the index array testing for range = 1 cases temp = 0; for(j = 0; j < num_indices - 1; j++) { index[j] = (i - i%p->scales[j] - temp)/p->scales[j]; temp += index[j] * p->scales[j]; } //range = 1 testing starts here if( num_indices < p->num_indices) { index[num_indices - 1] = (i - temp)/p->scales[num_indices - 1]; for(j = num_indices; j < p->num_indices; j++) index[j] = 0; } else { index[j] = (i - temp)/p->scales[j]; } //fill the buffer line counter = strlen(*buffer); sprintf((*buffer)+counter,"%g\n",Val(index)); } //terminate the string properly counter = strlen(*buffer); (*buffer)[counter+1] = '\0'; //clean-up delete [] index; } //****************************************************************************** //Name: array error * // * //Purpose: prints out an error message * // * //Takes: two message strings * //****************************************************************************** void array::error(char *msg1, char *msg2) const { cerr << "\nerror: " << msg1 << " " << msg2 << endl; exit(1); }
[ "gravmath@yahoo.com" ]
gravmath@yahoo.com
909e34777734726e6c9954146133784754c98388
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/third_party/mediapipe/src/mediapipe/framework/tool/switch_container.cc
bb17a914387689d5b02ecc23f544f4388bddaa85
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "dtoa", "BSD-3-Clause", "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
16,756
cc
// Copyright 2019 The MediaPipe Authors. // // 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 <functional> #include <map> #include <memory> #include <set> #include <string> #include <utility> #include <vector> #include "absl/strings/str_cat.h" #include "mediapipe/framework/calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/calculator_options.pb.h" #include "mediapipe/framework/port/canonical_errors.h" #include "mediapipe/framework/port/ret_check.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/tool/container_util.h" #include "mediapipe/framework/tool/name_util.h" #include "mediapipe/framework/tool/subgraph_expansion.h" #include "mediapipe/framework/tool/switch_container.pb.h" #include "absl/log/absl_check.h" namespace mediapipe { namespace tool { using mediapipe::SwitchContainerOptions; // A graph factory producing a CalculatorGraphConfig routing packets to // one of several contained CalculatorGraphConfigs. // // Usage example: // // node { // calculator: "SwitchContainer" // input_stream: "ENABLE:enable" // input_stream: "INPUT_VIDEO:video_frames" // output_stream: "OUTPUT_VIDEO:output_frames" // options { // [mediapipe.SwitchContainerOptions.ext] { // contained_node: { calculator: "BasicSubgraph" } // contained_node: { calculator: "AdvancedSubgraph" } // } // } // } // // Note that the input and output stream tags supplied to the container node // must match the input and output stream tags required by the contained nodes, // such as "INPUT_VIDEO" and "OUTPUT_VIDEO" in the example above. // // Input stream "ENABLE" specifies routing of packets to either contained_node 0 // or contained_node 1, given "ENABLE:false" or "ENABLE:true" respectively. // Input-side-packet "ENABLE" and input-stream "SELECT" can also be used // similarly to specify the active channel. // // Note that this container defaults to use ImmediateInputStreamHandler, // which can be used to accept infrequent "enable" packets asynchronously. // However, it can be overridden to work with DefaultInputStreamHandler, // which can be used to accept frequent "enable" packets synchronously. class SwitchContainer : public Subgraph { public: SwitchContainer() = default; absl::StatusOr<CalculatorGraphConfig> GetConfig( const Subgraph::SubgraphOptions& options) override; }; REGISTER_MEDIAPIPE_GRAPH(SwitchContainer); using TagIndex = std::pair<std::string, int>; // Returns the stream name for one of the demux output channels. // This is the channel number followed by the stream name separated by "__". // For example, the channel-name for sream "frame" on channel 1 is "c1__frame". std::string ChannelName(const std::string& name, int channel) { return absl::StrCat("c", channel, "__", name); } // Returns a SwitchDemuxCalculator node. CalculatorGraphConfig::Node* BuildDemuxNode( const std::map<TagIndex, std::string>& input_tags, const CalculatorGraphConfig::Node& container_node, CalculatorGraphConfig* config) { CalculatorGraphConfig::Node* result = config->add_node(); *result->mutable_calculator() = "SwitchDemuxCalculator"; return result; } // Returns a SwitchMuxCalculator node. CalculatorGraphConfig::Node* BuildMuxNode( const std::map<TagIndex, std::string>& output_tags, CalculatorGraphConfig* config) { CalculatorGraphConfig::Node* result = config->add_node(); *result->mutable_calculator() = "SwitchMuxCalculator"; return result; } // Returns a PacketSequencerCalculator node. CalculatorGraphConfig::Node* BuildTimestampNode(CalculatorGraphConfig* config, bool async_selection) { CalculatorGraphConfig::Node* result = config->add_node(); *result->mutable_calculator() = "PacketSequencerCalculator"; if (!async_selection) { *result->mutable_input_stream_handler()->mutable_input_stream_handler() = "DefaultInputStreamHandler"; } return result; } // Copies options from one node to another. void CopyOptions(const CalculatorGraphConfig::Node& source, CalculatorGraphConfig::Node* dest) { if (source.has_options()) { *dest->mutable_options() = source.options(); } *dest->mutable_node_options() = source.node_options(); } // Clears options that are consumed by the container and not forwarded. void ClearContainerOptions(SwitchContainerOptions* result) { result->clear_contained_node(); } // Clears options that are consumed by the container and not forwarded. void ClearContainerOptions(CalculatorGraphConfig::Node* dest) { if (dest->has_options() && dest->mutable_options()->HasExtension(SwitchContainerOptions::ext)) { ClearContainerOptions( dest->mutable_options()->MutableExtension(SwitchContainerOptions::ext)); } for (google::protobuf::Any& a : *dest->mutable_node_options()) { if (a.Is<SwitchContainerOptions>()) { SwitchContainerOptions extension; a.UnpackTo(&extension); ClearContainerOptions(&extension); a.PackFrom(extension); } } } // Returns an unused name similar to a specified name. std::string UniqueName(std::string name, std::set<std::string>* names) { ABSL_CHECK(names != nullptr); std::string result = name; int suffix = 2; while (names->count(result) > 0) { result = absl::StrCat(name, "_", suffix++); } names->insert(result); return result; } // Parses tag, index, and name from a list of stream identifiers. void ParseTags(const proto_ns::RepeatedPtrField<std::string>& streams, std::map<TagIndex, std::string>* result) { ABSL_CHECK(result != nullptr); std::set<std::string> used_names; int used_index = -1; for (const std::string& stream : streams) { std::string name = UniqueName(ParseNameFromStream(stream), &used_names); TagIndex tag_index = ParseTagIndexFromStream(stream); if (tag_index.second == -1) { tag_index.second = ++used_index; } result->insert({tag_index, name}); } } // Removes the entry for a tag and index from a map. void EraseTag(const std::string& stream, std::map<TagIndex, std::string>* streams) { ABSL_CHECK(streams != nullptr); streams->erase(ParseTagIndexFromStream(absl::StrCat(stream, ":u"))); } // Removes the entry for a tag and index from a list. void EraseTag(const std::string& stream, proto_ns::RepeatedPtrField<std::string>* streams) { ABSL_CHECK(streams != nullptr); TagIndex stream_tag = ParseTagIndexFromStream(absl::StrCat(stream, ":u")); for (int i = streams->size() - 1; i >= 0; --i) { TagIndex tag = ParseTagIndexFromStream(streams->at(i)); if (tag == stream_tag) { streams->erase(streams->begin() + i); } } } // Returns the stream names for the container node. void GetContainerNodeStreams(const CalculatorGraphConfig::Node& node, CalculatorGraphConfig::Node* result) { ABSL_CHECK(result != nullptr); *result->mutable_input_stream() = node.input_stream(); *result->mutable_output_stream() = node.output_stream(); *result->mutable_input_side_packet() = node.input_side_packet(); *result->mutable_output_side_packet() = node.output_side_packet(); EraseTag("ENABLE", result->mutable_input_stream()); EraseTag("ENABLE", result->mutable_input_side_packet()); EraseTag("SELECT", result->mutable_input_stream()); EraseTag("SELECT", result->mutable_input_side_packet()); } // Validate all subgraph inputs and outputs. absl::Status ValidateContract( const CalculatorGraphConfig::Node& subgraph_node, const Subgraph::SubgraphOptions& subgraph_options) { auto options = Subgraph::GetOptions<mediapipe::SwitchContainerOptions>(subgraph_options); std::map<TagIndex, std::string> input_tags, side_tags; ParseTags(subgraph_node.input_stream(), &input_tags); ParseTags(subgraph_node.input_side_packet(), &side_tags); if (options.has_select() && options.has_enable()) { return absl::InvalidArgumentError( "Only one of SwitchContainer options 'enable' and 'select' can be " "specified"); } if (side_tags.count({"SELECT", 0}) + side_tags.count({"ENABLE", 0}) > 1 || input_tags.count({"SELECT", 0}) + input_tags.count({"ENABLE", 0}) > 1) { return absl::InvalidArgumentError( "Only one of SwitchContainer inputs 'ENABLE' and 'SELECT' can be " "specified"); } return absl::OkStatus(); } // Returns true if a set of streams references a certain tag name. bool HasTag(const proto_ns::RepeatedPtrField<std::string>& streams, std::string tag) { std::map<TagIndex, std::string> tags; ParseTags(streams, &tags); return tags.count({tag, 0}) > 0; } // Returns true if a set of "TAG::index" includes a TagIndex. bool ContainsTag(const proto_ns::RepeatedPtrField<std::string>& tags, TagIndex item) { for (const std::string& t : tags) { if (ParseTagIndex(t) == item) return true; } return false; } absl::StatusOr<CalculatorGraphConfig> SwitchContainer::GetConfig( const Subgraph::SubgraphOptions& options) { CalculatorGraphConfig config; std::vector<CalculatorGraphConfig::Node*> subnodes; std::vector<CalculatorGraphConfig::Node> substreams; // Parse all input and output tags from the container node. auto container_node = Subgraph::GetNode(options); MP_RETURN_IF_ERROR(ValidateContract(container_node, options)); CalculatorGraphConfig::Node container_streams; GetContainerNodeStreams(container_node, &container_streams); std::map<TagIndex, std::string> input_tags, output_tags; std::map<TagIndex, std::string> side_input_tags, side_output_tags; ParseTags(container_streams.input_stream(), &input_tags); ParseTags(container_streams.output_stream(), &output_tags); ParseTags(container_streams.input_side_packet(), &side_input_tags); ParseTags(container_streams.output_side_packet(), &side_output_tags); CalculatorGraphConfig::Node* select_node = nullptr; CalculatorGraphConfig::Node* enable_node = nullptr; std::string select_stream = "SELECT:gate_select"; std::string enable_stream = "ENABLE:gate_enable"; // Add a PacketSequencerCalculator node for "SELECT" or "ENABLE" streams. const auto& switch_options = Subgraph::GetOptions<mediapipe::SwitchContainerOptions>(options); bool async_selection = switch_options.async_selection(); if (HasTag(container_node.input_stream(), "SELECT")) { select_node = BuildTimestampNode(&config, async_selection); select_node->add_input_stream("INPUT:gate_select"); select_node->add_output_stream("OUTPUT:gate_select_timed"); select_stream = "SELECT:gate_select_timed"; } if (HasTag(container_node.input_stream(), "ENABLE")) { enable_node = BuildTimestampNode(&config, async_selection); enable_node->add_input_stream("INPUT:gate_enable"); enable_node->add_output_stream("OUTPUT:gate_enable_timed"); enable_stream = "ENABLE:gate_enable_timed"; } // Add a graph node for the demux, mux. auto demux = BuildDemuxNode(input_tags, container_node, &config); CopyOptions(container_node, demux); ClearContainerOptions(demux); demux->add_input_stream(select_stream); demux->add_input_stream(enable_stream); demux->add_input_side_packet("SELECT:gate_select"); demux->add_input_side_packet("ENABLE:gate_enable"); auto mux = BuildMuxNode(output_tags, &config); CopyOptions(container_node, mux); ClearContainerOptions(mux); mux->add_input_stream(select_stream); mux->add_input_stream(enable_stream); mux->add_input_side_packet("SELECT:gate_select"); mux->add_input_side_packet("ENABLE:gate_enable"); // Add input streams for graph and demux. config.add_input_stream("SELECT:gate_select"); config.add_input_stream("ENABLE:gate_enable"); config.add_input_side_packet("SELECT:gate_select"); config.add_input_side_packet("ENABLE:gate_enable"); int tick_index = 0; for (const auto& p : input_tags) { std::string stream = CatStream(p.first, p.second); config.add_input_stream(stream); demux->add_input_stream(stream); } // Add input streams for the timestamper. auto& tick_streams = switch_options.tick_input_stream(); for (const auto& p : input_tags) { if (!tick_streams.empty() && !ContainsTag(tick_streams, p.first)) continue; TagIndex tick_tag{"TICK", tick_index++}; if (select_node) { select_node->add_input_stream(CatStream(tick_tag, p.second)); } if (enable_node) { enable_node->add_input_stream(CatStream(tick_tag, p.second)); } } // Add output streams for graph and mux. for (const auto& p : output_tags) { std::string stream = CatStream(p.first, p.second); config.add_output_stream(stream); mux->add_output_stream(stream); } for (const auto& p : side_input_tags) { std::string side = CatStream(p.first, p.second); config.add_input_side_packet(side); demux->add_input_side_packet(side); } for (const auto& p : side_output_tags) { std::string side = CatStream(p.first, p.second); config.add_output_side_packet(side); mux->add_output_side_packet(side); } // Add a subnode for each contained_node. auto nodes = Subgraph::GetOptions<mediapipe::SwitchContainerOptions>(options) .contained_node(); std::vector<CalculatorGraphConfig::Node> contained_nodes(nodes.begin(), nodes.end()); for (int i = 0; i < contained_nodes.size(); ++i) { auto subnode = config.add_node(); *subnode = contained_nodes[i]; subnodes.push_back(subnode); substreams.push_back(container_streams); } // Connect each contained graph node to demux and mux. for (int channel = 0; channel < subnodes.size(); ++channel) { CalculatorGraphConfig::Node& streams = substreams[channel]; // Connect each contained graph node input to a demux output. std::map<TagIndex, std::string> input_stream_tags; ParseTags(streams.input_stream(), &input_stream_tags); for (auto& it : input_stream_tags) { TagIndex tag_index = it.first; std::string tag = ChannelTag(tag_index.first, channel); std::string name = ChannelName(input_tags[tag_index], channel); std::string demux_stream = CatStream({tag, tag_index.second}, name); demux->add_output_stream(demux_stream); subnodes[channel]->add_input_stream(CatStream(tag_index, name)); } // Connect each contained graph node output to a mux input. std::map<TagIndex, std::string> output_stream_tags; ParseTags(streams.output_stream(), &output_stream_tags); for (auto& it : output_stream_tags) { TagIndex tag_index = it.first; std::string tag = ChannelTag(tag_index.first, channel); std::string name = ChannelName(output_tags[tag_index], channel); subnodes[channel]->add_output_stream(CatStream(tag_index, name)); mux->add_input_stream(CatStream({tag, tag_index.second}, name)); } // Connect each contained graph node side-input to a demux side-output. std::map<TagIndex, std::string> input_side_tags; ParseTags(streams.input_side_packet(), &input_side_tags); for (auto& it : input_side_tags) { TagIndex tag_index = it.first; std::string tag = ChannelTag(tag_index.first, channel); std::string name = ChannelName(side_input_tags[tag_index], channel); std::string demux_stream = CatStream({tag, tag_index.second}, name); demux->add_output_side_packet(demux_stream); subnodes[channel]->add_input_side_packet(CatStream(tag_index, name)); } // Connect each contained graph node side-output to a mux side-input. std::map<TagIndex, std::string> output_side_tags; ParseTags(streams.output_side_packet(), &output_side_tags); for (auto& it : output_side_tags) { TagIndex tag_index = it.first; std::string tag = ChannelTag(tag_index.first, channel); std::string name = ChannelName(side_output_tags[tag_index], channel); subnodes[channel]->add_output_side_packet(CatStream(tag_index, name)); mux->add_input_side_packet(CatStream({tag, tag_index.second}, name)); } } return config; } } // namespace tool } // namespace mediapipe
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
1fb976b56e86ac98784a0d1809689c1ba81082aa
53a59cc39939c19cbed54f784c34210eecd5a4ce
/Darnel/src/Application.cpp
25df77200379a261a11adb7b9c39df890620c6c3
[]
no_license
keelimeguy/Darnel-Engine
4938f2384842966ba2443133c478afa51794c1f8
7805735f9b837368d3abdbb8a68f65dddba56017
refs/heads/master
2021-08-07T15:49:58.822277
2020-04-30T02:50:05
2020-04-30T02:50:05
165,546,474
1
0
null
null
null
null
UTF-8
C++
false
false
4,680
cpp
#include "Application.h" #include "Sprite.h" namespace darnel { Application *Application::s_Instance = nullptr; Application::Application(std::string name, unsigned int width, unsigned int height) { DARNEL_ASSERT(!s_Instance, "Application already exists!"); s_Instance = this; m_Windows.push_back(Window::Create(name, width, height)); m_ActiveWindow = m_Windows.back().get(); m_ActiveWindow->AddEventCallback(std::bind(&Application::OnEvent, this, std::placeholders::_1, m_ActiveWindow)); m_ImGuiLayer = new ImGuiLayer(); PushOverlay(m_ImGuiLayer); } Application::~Application() { Sprite::SpriteContext::s_ib = nullptr; Sprite::SpriteContext::s_shader = nullptr; Renderer::Get()->Terminate(&m_Windows); } std::weak_ptr<Window> Application::NewWindow(std::string name, unsigned int width, unsigned int height) { m_Windows.push_back(Window::Create(name, width, height)); auto window = m_Windows.back(); window->AddEventCallback(std::bind(&Application::OnEvent, this, std::placeholders::_1, window.get())); std::cout << "[" << name << "] " << "Created" << std::endl << std::flush; m_ActiveWindow->Focus(); return window; } std::weak_ptr<Window> Application::NewChildWindow(Window *parent, std::string name, unsigned int width, unsigned int height) { m_Windows.push_back(parent->MakeChild(name, width, height)); auto window = m_Windows.back(); window->AddEventCallback(std::bind(&Application::OnEvent, this, std::placeholders::_1, window.get())); std::cout << "[" << name << "] " << "Created" << std::endl << std::flush; m_ActiveWindow->Focus(); return window; } void Application::PushLayer(Layer *layer) { m_LayerStack.PushLayer(layer); layer->OnAttach(); } void Application::PushOverlay(Layer *layer) { m_LayerStack.PushOverlay(layer); layer->OnAttach(); } void Application::OnEvent(Event &e, Window *window) { std::cout << "[" << window->GetName() << "] " << e.ToString() << std::endl << std::flush; EventDispatcher dispatcher(e); if (dispatcher.Dispatch<WindowCloseEvent>(std::bind(&Application::OnWindowClose, this, std::placeholders::_1, window))) ; else if (dispatcher.Dispatch<WindowFocusEvent>(std::bind(&Application::OnWindowFocus, this, std::placeholders::_1, window))) ; else { for (auto it = m_LayerStack.end(); it != m_LayerStack.begin(); ) { (*--it)->OnEvent(e); if (e.IsHandled()) break; } } } void Application::Run() { while (m_Running) { Window::PollEvents(); RenderCommand::SetClearColor({0.0f, 0.0f, 0.0f, 1.0f}); RenderCommand::Clear(); for (Layer *layer : m_LayerStack) layer->OnUpdate(); m_ImGuiLayer->Begin(); for (Layer *layer : m_LayerStack) layer->OnImGuiRender(); m_ImGuiLayer->End(); for (auto &window : m_Windows) window->OnUpdate(); } } bool Application::OnWindowClose(WindowCloseEvent &e, Window *window) { // We need a context still active during termination, // so don't delete the window if it is the last one if (m_Windows.size() == 1) { DARNEL_ASSERT(m_Windows[0].get() == window, "Closing unknown window"); m_Running = false; } else { if (window == m_ActiveWindow) { m_ActiveWindow = nullptr; } auto it = std::find_if(m_Windows.begin(), m_Windows.end(), [window](auto & wnd) { return wnd.get() == window; } ); DARNEL_ASSERT(it != m_Windows.end(), "Closing unknown window"); DARNEL_ASSERT(it->get() == window, "Found wrong window"); auto wnd = *it; // Prevents immediate deletion of child windows m_Windows.erase(it); if (!m_ActiveWindow) m_ActiveWindow = m_Windows.back().get(); } return true; } bool Application::OnWindowFocus(WindowFocusEvent &e, Window *window) { auto it = std::find_if(m_Windows.begin(), m_Windows.end(), [window](auto & wnd) { return wnd.get() == window; } ); DARNEL_ASSERT(it != m_Windows.end(), "Set focus on unknown window"); m_ActiveWindow = it->get(); return true; } }
[ "keelinwheeler@gmail.com" ]
keelinwheeler@gmail.com
8683e123460a14fd5ca9bea10548e58561b3966f
0e22d8e3be6bba082547ac323638d70c01a8ff72
/include/functions.hpp
3c250081f1087d802abc98eedfd9f2757dc8be33
[]
no_license
davawen/Barnes-Hut
34085e89268e09488077bc97deb53f7b2401aff9
cf9cb59b146ba77e1e8bf1b15de4f70f71929694
refs/heads/master
2023-04-28T00:48:00.847333
2021-05-05T21:06:59
2021-05-05T21:06:59
362,603,766
0
0
null
null
null
null
UTF-8
C++
false
false
419
hpp
/*-------- Header Guard --------*/ #ifndef __COLOR_H__ #define __COLOR_H__ // This is essentially a group of crap utility functions #include <iostream> #include <math.h> #include <algorithm> #include <SFML/Graphics.hpp> float clamp(float value, float min, float max); float lerp(float a, float b, float t); uint32_t colorLerp(uint32_t color1, uint32_t color2, float t); float randf(); #endif /* __COLOR_H__ */
[ "56738724+davawen@users.noreply.github.com" ]
56738724+davawen@users.noreply.github.com
070043a8a8d00e8798658b42a59966db8928d1f2
41918d8f1f97637232060b3af3a994c20e343ca3
/src/rpcmining.cpp
58428e7ce372b9c2ffa0a04fe88f6ff698fc5c7c
[ "MIT" ]
permissive
mauisabily/AyuCoin
6c6b3aee6faa0b88fc5c58ab033754fbbef54de8
94bee25df2338d63ae6cac732a26b9b16cd493ee
refs/heads/master
2021-06-22T18:33:20.924814
2020-11-19T23:59:52
2020-11-19T23:59:52
132,910,400
0
1
null
null
null
null
UTF-8
C++
false
false
19,188
cpp
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "main.h" #include "db.h" #include "txdb.h" #include "init.h" #include "miner.h" #include "bitcoinrpc.h" using namespace json_spirit; using namespace std; Value getsubsidy(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getsubsidy [nTarget]\n" "Returns proof-of-work subsidy value for the specified value of target."); return (uint64_t)GetProofOfWorkReward(0); } Value getmininginfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( "getmininginfo\n" "Returns an object containing mining-related information."); uint64_t nMinWeight = 0, nMaxWeight = 0, nWeight = 0; pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight); Object obj, diff, weight; obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx)); diff.push_back(Pair("proof-of-work", GetDifficulty())); diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); diff.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); obj.push_back(Pair("difficulty", diff)); obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(0))); obj.push_back(Pair("netmhashps", GetPoWMHashPS())); obj.push_back(Pair("netstakeweight", GetPoSKernelPS())); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); weight.push_back(Pair("minimum", (uint64_t)nMinWeight)); weight.push_back(Pair("maximum", (uint64_t)nMaxWeight)); weight.push_back(Pair("combined", (uint64_t)nWeight)); obj.push_back(Pair("stakeweight", weight)); obj.push_back(Pair("stakeinterest", (uint64_t)COIN_YEAR_REWARD)); obj.push_back(Pair("testnet", fTestNet)); return obj; } Value getstakinginfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( "getstakinginfo\n" "Returns an object containing staking-related information."); uint64_t nMinWeight = 0, nMaxWeight = 0, nWeight = 0; pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight); uint64_t nNetworkWeight = GetPoSKernelPS(); bool staking = nLastCoinStakeSearchInterval && nWeight; int nExpectedTime = staking ? (nTargetSpacing * nNetworkWeight / nWeight) : -1; Object obj; obj.push_back(Pair("enabled", GetBoolArg("-staking", true))); obj.push_back(Pair("staking", staking)); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("difficulty", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); obj.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); obj.push_back(Pair("weight", (uint64_t)nWeight)); obj.push_back(Pair("netstakeweight", (uint64_t)nNetworkWeight)); obj.push_back(Pair("expectedtime", nExpectedTime)); return obj; } Value getworkex(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) throw runtime_error( "getworkex [data, coinbase]\n" "If [data, coinbase] is not specified, returns extended work data.\n" ); if (vNodes.empty()) throw JSONRPCError(-9, "AyuCoin is not connected!"); if (IsInitialBlockDownload()) throw JSONRPCError(-10, "AyuCoin is downloading blocks..."); if (pindexBest->nHeight >= LAST_POW_BLOCK) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t; static mapNewBlock_t mapNewBlock; static vector<CBlock*> vNewBlock; static CReserveKey reservekey(pwalletMain); if (params.size() == 0) { // Update block static unsigned int nTransactionsUpdatedLast; static CBlockIndex* pindexPrev; static int64_t nStart; static CBlock* pblock; if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)) { if (pindexPrev != pindexBest) { // Deallocate old blocks since they're obsolete now mapNewBlock.clear(); BOOST_FOREACH(CBlock* pblock, vNewBlock) delete pblock; vNewBlock.clear(); } nTransactionsUpdatedLast = nTransactionsUpdated; pindexPrev = pindexBest; nStart = GetTime(); // Create new block pblock = CreateNewBlock(pwalletMain); if (!pblock) throw JSONRPCError(-7, "Out of memory"); vNewBlock.push_back(pblock); } // Update nTime pblock->nTime = max(pindexPrev->GetPastTimeLimit()+1, GetAdjustedTime()); pblock->nNonce = 0; // Update nExtraNonce static unsigned int nExtraNonce = 0; IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); // Save mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig); // Prebuild hash buffers char pmidstate[32]; char pdata[128]; char phash1[64]; FormatHashBuffers(pblock, pmidstate, pdata, phash1); uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); CTransaction coinbaseTx = pblock->vtx[0]; std::vector<uint256> merkle = pblock->GetMerkleBranch(0); Object result; result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata)))); result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget)))); CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << coinbaseTx; result.push_back(Pair("coinbase", HexStr(ssTx.begin(), ssTx.end()))); Array merkle_arr; BOOST_FOREACH(uint256 merkleh, merkle) { merkle_arr.push_back(HexStr(BEGIN(merkleh), END(merkleh))); } result.push_back(Pair("merkle", merkle_arr)); return result; } else { // Parse parameters vector<unsigned char> vchData = ParseHex(params[0].get_str()); vector<unsigned char> coinbase; if(params.size() == 2) coinbase = ParseHex(params[1].get_str()); if (vchData.size() != 128) throw JSONRPCError(-8, "Invalid parameter"); CBlock* pdata = (CBlock*)&vchData[0]; // Byte reverse for (int i = 0; i < 128/4; i++) ((unsigned int*)pdata)[i] = ByteReverse(((unsigned int*)pdata)[i]); // Get saved block if (!mapNewBlock.count(pdata->hashMerkleRoot)) return false; CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first; pblock->nTime = pdata->nTime; pblock->nNonce = pdata->nNonce; if(coinbase.size() == 0) pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; else CDataStream(coinbase, SER_NETWORK, PROTOCOL_VERSION) >> pblock->vtx[0]; // FIXME - HACK! pblock->hashMerkleRoot = pblock->BuildMerkleTree(); return CheckWork(pblock, *pwalletMain, reservekey); } } Value getwork(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getwork [data]\n" "If [data] is not specified, returns formatted hash data to work on:\n" " \"midstate\" : precomputed hash state after hashing the first half of the data (DEPRECATED)\n" // deprecated " \"data\" : block data\n" " \"hash1\" : formatted hash buffer for second hash (DEPRECATED)\n" // deprecated " \"target\" : little endian hash target\n" "If [data] is specified, tries to solve the block and returns true if it was successful."); if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "AyuCoin is not connected!"); if (IsInitialBlockDownload()) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "AyuCoin is downloading blocks..."); if (pindexBest->nHeight >= LAST_POW_BLOCK) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t; static mapNewBlock_t mapNewBlock; // FIXME: thread safety static vector<CBlock*> vNewBlock; static CReserveKey reservekey(pwalletMain); if (params.size() == 0) { // Update block static unsigned int nTransactionsUpdatedLast; static CBlockIndex* pindexPrev; static int64_t nStart; static CBlock* pblock; if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)) { if (pindexPrev != pindexBest) { // Deallocate old blocks since they're obsolete now mapNewBlock.clear(); BOOST_FOREACH(CBlock* pblock, vNewBlock) delete pblock; vNewBlock.clear(); } // Clear pindexPrev so future getworks make a new block, despite any failures from here on pindexPrev = NULL; // Store the pindexBest used before CreateNewBlock, to avoid races nTransactionsUpdatedLast = nTransactionsUpdated; CBlockIndex* pindexPrevNew = pindexBest; nStart = GetTime(); // Create new block pblock = CreateNewBlock(pwalletMain); if (!pblock) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); vNewBlock.push_back(pblock); // Need to update only after we know CreateNewBlock succeeded pindexPrev = pindexPrevNew; } // Update nTime pblock->UpdateTime(pindexPrev); pblock->nNonce = 0; // Update nExtraNonce static unsigned int nExtraNonce = 0; IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); // Save mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig); // Pre-build hash buffers char pmidstate[32]; char pdata[128]; char phash1[64]; FormatHashBuffers(pblock, pmidstate, pdata, phash1); uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); Object result; result.push_back(Pair("midstate", HexStr(BEGIN(pmidstate), END(pmidstate)))); // deprecated result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata)))); result.push_back(Pair("hash1", HexStr(BEGIN(phash1), END(phash1)))); // deprecated result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget)))); return result; } else { // Parse parameters vector<unsigned char> vchData = ParseHex(params[0].get_str()); if (vchData.size() != 128) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); CBlock* pdata = (CBlock*)&vchData[0]; // Byte reverse for (int i = 0; i < 128/4; i++) ((unsigned int*)pdata)[i] = ByteReverse(((unsigned int*)pdata)[i]); // Get saved block if (!mapNewBlock.count(pdata->hashMerkleRoot)) return false; CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first; pblock->nTime = pdata->nTime; pblock->nNonce = pdata->nNonce; pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; pblock->hashMerkleRoot = pblock->BuildMerkleTree(); return CheckWork(pblock, *pwalletMain, reservekey); } } Value getblocktemplate(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getblocktemplate [params]\n" "Returns data needed to construct a block to work on:\n" " \"version\" : block version\n" " \"previousblockhash\" : hash of current highest block\n" " \"transactions\" : contents of non-coinbase transactions that should be included in the next block\n" " \"coinbaseaux\" : data that should be included in coinbase\n" " \"coinbasevalue\" : maximum allowable input to coinbase transaction, including the generation award and transaction fees\n" " \"target\" : hash target\n" " \"mintime\" : minimum timestamp appropriate for next block\n" " \"curtime\" : current timestamp\n" " \"mutable\" : list of ways the block template may be changed\n" " \"noncerange\" : range of valid nonces\n" " \"sigoplimit\" : limit of sigops in blocks\n" " \"sizelimit\" : limit of block size\n" " \"bits\" : compressed target of next block\n" " \"height\" : height of the next block\n" "See https://en.bitcoin.it/wiki/BIP_0022 for full specification."); std::string strMode = "template"; if (params.size() > 0) { const Object& oparam = params[0].get_obj(); const Value& modeval = find_value(oparam, "mode"); if (modeval.type() == str_type) strMode = modeval.get_str(); else if (modeval.type() == null_type) { /* Do nothing */ } else throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); } if (strMode != "template") throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "AyuCoin is not connected!"); if (IsInitialBlockDownload()) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "AyuCoin is downloading blocks..."); if (pindexBest->nHeight >= LAST_POW_BLOCK) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); static CReserveKey reservekey(pwalletMain); // Update block static unsigned int nTransactionsUpdatedLast; static CBlockIndex* pindexPrev; static int64_t nStart; static CBlock* pblock; if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5)) { // Clear pindexPrev so future calls make a new block, despite any failures from here on pindexPrev = NULL; // Store the pindexBest used before CreateNewBlock, to avoid races nTransactionsUpdatedLast = nTransactionsUpdated; CBlockIndex* pindexPrevNew = pindexBest; nStart = GetTime(); // Create new block if(pblock) { delete pblock; pblock = NULL; } pblock = CreateNewBlock(pwalletMain); if (!pblock) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); // Need to update only after we know CreateNewBlock succeeded pindexPrev = pindexPrevNew; } // Update nTime pblock->UpdateTime(pindexPrev); pblock->nNonce = 0; Array transactions; map<uint256, int64_t> setTxIndex; int i = 0; CTxDB txdb("r"); BOOST_FOREACH (CTransaction& tx, pblock->vtx) { uint256 txHash = tx.GetHash(); setTxIndex[txHash] = i++; if (tx.IsCoinBase() || tx.IsCoinStake()) continue; Object entry; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << tx; entry.push_back(Pair("data", HexStr(ssTx.begin(), ssTx.end()))); entry.push_back(Pair("hash", txHash.GetHex())); MapPrevTx mapInputs; map<uint256, CTxIndex> mapUnused; bool fInvalid = false; if (tx.FetchInputs(txdb, mapUnused, false, false, mapInputs, fInvalid)) { entry.push_back(Pair("fee", (int64_t)(tx.GetValueIn(mapInputs) - tx.GetValueOut()))); Array deps; BOOST_FOREACH (MapPrevTx::value_type& inp, mapInputs) { if (setTxIndex.count(inp.first)) deps.push_back(setTxIndex[inp.first]); } entry.push_back(Pair("depends", deps)); int64_t nSigOps = tx.GetLegacySigOpCount(); nSigOps += tx.GetP2SHSigOpCount(mapInputs); entry.push_back(Pair("sigops", nSigOps)); } transactions.push_back(entry); } Object aux; aux.push_back(Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end()))); uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); static Array aMutable; if (aMutable.empty()) { aMutable.push_back("time"); aMutable.push_back("transactions"); aMutable.push_back("prevblock"); } Object result; result.push_back(Pair("version", pblock->nVersion)); result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.push_back(Pair("transactions", transactions)); result.push_back(Pair("coinbaseaux", aux)); result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); result.push_back(Pair("target", hashTarget.GetHex())); result.push_back(Pair("mintime", (int64_t)pindexPrev->GetPastTimeLimit()+1)); result.push_back(Pair("mutable", aMutable)); result.push_back(Pair("noncerange", "00000000ffffffff")); result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS)); result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE)); result.push_back(Pair("curtime", (int64_t)pblock->nTime)); result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); return result; } Value submitblock(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( "submitblock <hex data> [optional-params-obj]\n" "[optional-params-obj] parameter is currently ignored.\n" "Attempts to submit new block to network.\n" "See https://en.bitcoin.it/wiki/BIP_0022 for full specification."); vector<unsigned char> blockData(ParseHex(params[0].get_str())); CDataStream ssBlock(blockData, SER_NETWORK, PROTOCOL_VERSION); CBlock block; try { ssBlock >> block; } catch (std::exception &e) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); } bool fAccepted = ProcessBlock(NULL, &block); if (!fAccepted) return "rejected"; return Value::null; }
[ "88+gpcash@users.noreply.github.com" ]
88+gpcash@users.noreply.github.com
899c9a20a0134f01245d45317c0332566b2553f6
8b91268944935d17960084bc99359a604e3f1c86
/Inzva_30w/dp1/online/Halil and Freelance.cpp
f06972a274a6803a66641a27fd6580d5e31b51fe
[]
no_license
AlpYilmazz/Algorithmic_Competition_v2
9b1450e6b4d32fbc4edbb5d863627ec22f60ffd2
4f3c8c9766ae56a9288061243558fe07a7cb4d40
refs/heads/master
2020-06-11T08:35:44.796188
2019-12-05T13:08:46
2019-12-05T13:08:46
193,905,035
1
1
null
null
null
null
UTF-8
C++
false
false
682
cpp
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; vector<int> jobs; vector<int> length; int main() { int i, j; int ni; int n; cin >> n; for(i = 0; i < n; i++){ cin >> ni; jobs.push_back(ni); } length.resize(n, 1); for(i = 0; i < n; i++){ for(j = 0; j < i; j++){ if(jobs[j] < jobs[i]){ length[i] = max(length[i], length[j]+1); } } } int longest = 1; for(i = 0; i < length.size(); i++){ longest = max(longest, length[i]); } cout << longest << endl; return 0; }
[ "alperen0098@gmail.com" ]
alperen0098@gmail.com
def3d45cb028072be1a1c823f0fe9126d03d3e5d
a0f221050c41d08cee9b0e31154d48122dad3cd1
/ComponentFramework/GameObject.h
03fd2a2b4ec185a7cf1cc03ba6202076c559fa2a
[]
no_license
Warkingi/Graphics
ad1d13a30d2eee4002e96c93a74150e5b59f44f1
f36afc27a838426e644f100ea84e7a2c004e669a
refs/heads/master
2020-08-17T20:10:04.747911
2019-10-17T04:56:57
2019-10-17T04:56:57
215,706,725
0
1
null
null
null
null
UTF-8
C++
false
false
620
h
#ifndef GAMEOBJECT_H #define GAMEOBJECT_H #include <glew.h> #include "Matrix.h" using namespace MATH; class GameObject { private: Matrix4 modelMatrix; GLuint modelMatrixID; GLuint normalMatrixID; class Mesh *mesh; class Shader *shader; class Texture *texture; public: GameObject(Mesh *mesh_, Shader *shader_, Texture *texture_); ~GameObject(); void Render() const; void Update(float deltaTime_); inline Shader* getShader() const { return shader; } inline void setModelMatrix(const Matrix4 &modelMatrix_) { modelMatrix = modelMatrix_; } inline Matrix4& getModelMatrix() { return modelMatrix; } }; #endif
[ "ncracknell.1@gmail.com" ]
ncracknell.1@gmail.com
f441bcc465d6b4c468f5642fdc97de5a7585fecc
8734579a38e8529ff4667e81321a806aaf39c094
/main.cpp
e69cf4349a3f94ad760099d0b2d44ad41637a8a3
[]
no_license
withoutCoffee/Template_Queue
483c75b1f33f1636106e281192b62856863e833d
2199b36b01f8be4be7cd2deb6cc7ad58c1371272
refs/heads/master
2020-12-30T03:50:05.926100
2020-02-07T05:27:10
2020-02-07T05:27:10
238,850,367
0
0
null
null
null
null
UTF-8
C++
false
false
336
cpp
#include <iostream> #include "Fila.h" #include <vector> using namespace std; int main(){ Fila<int> fila(3); fila.push(40); cout<<fila.pop()<<endl; fila.push(10); fila.push(50); fila.push(90); cout<<fila.pop()<<endl; cout<<fila.pop()<<endl; cout<<fila.pop()<<endl; return 0; }
[ "noreply@github.com" ]
withoutCoffee.noreply@github.com
7d75bf360134361c0adecfb1a80a82bdca58089a
756b849ba9192c1c6a261f57c6c282bf6d316ecf
/Source/Group315/Group315.cpp
d12bc1f2d7f15274804ca7869ee21720976daa33
[]
no_license
MeepTheOtter/315-Shooter-Game
f7485beb8cec9fe76693d9136e289602e18de671
0adf12337e6cf36b31bcabc2466088ac578db39c
refs/heads/master
2023-01-07T12:47:00.420414
2020-11-10T23:24:23
2020-11-10T23:24:23
309,904,146
0
0
null
null
null
null
UTF-8
C++
false
false
189
cpp
// Copyright Epic Games, Inc. All Rights Reserved. #include "Group315.h" #include "Modules/ModuleManager.h" IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Group315, "Group315" );
[ "jacobklukas@aol.com" ]
jacobklukas@aol.com
1d05d435e053050a4e2d782b741237782d053ccc
55d560fe6678a3edc9232ef14de8fafd7b7ece12
/libs/config/test/no_cxx11_hdr_condition_variable_fail.cpp
72aab2c0ddab68f9423526a99a03fa0d2d700474
[ "BSL-1.0" ]
permissive
stardog-union/boost
ec3abeeef1b45389228df031bf25b470d3d123c5
caa4a540db892caa92e5346e0094c63dea51cbfb
refs/heads/stardog/develop
2021-06-25T02:15:10.697006
2020-11-17T19:50:35
2020-11-17T19:50:35
148,681,713
0
0
BSL-1.0
2020-11-17T19:50:36
2018-09-13T18:38:54
C++
UTF-8
C++
false
false
1,145
cpp
// This file was automatically generated on Fri May 15 11:57:42 2009 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/config for the most recent version.// // Revision $Id$ // // Test file for macro BOOST_NO_CXX11_HDR_CONDITION_VARIABLE // This file should not compile, if it does then // BOOST_NO_CXX11_HDR_CONDITION_VARIABLE should not be defined. // See file boost_no_cxx11_hdr_condition_variable.ipp for details // Must not have BOOST_ASSERT_CONFIG set; it defeats // the objective of this file: #ifdef BOOST_ASSERT_CONFIG # undef BOOST_ASSERT_CONFIG #endif #include <boost/config.hpp> #include "test.hpp" #ifdef BOOST_NO_CXX11_HDR_CONDITION_VARIABLE #include "boost_no_cxx11_hdr_condition_variable.ipp" #else #error "this file should not compile" #endif int main( int, char *[] ) { return boost_no_cxx11_hdr_condition_variable::test(); }
[ "james.pack@stardog.com" ]
james.pack@stardog.com
69a3414a681c9279fb868c2c90387be86153ec4e
93343c49771b6e6f2952d03df7e62e6a4ea063bb
/HDOJ/3008_autoAC.cpp
60c2a4f08340f9f45be238b5c8095e50a8ca274c
[]
no_license
Kiritow/OJ-Problems-Source
5aab2c57ab5df01a520073462f5de48ad7cb5b22
1be36799dda7d0e60bd00448f3906b69e7c79b26
refs/heads/master
2022-10-21T08:55:45.581935
2022-09-24T06:13:47
2022-09-24T06:13:47
55,874,477
36
9
null
2018-07-07T00:03:15
2016-04-10T01:06:42
C++
UTF-8
C++
false
false
1,409
cpp
#include<iostream> #include<algorithm> using namespace std; #define inf 110 int dp[inf][inf]; #define Max(a,b) a>b?a:b struct node { int ai,bi; }b[inf]; int cmp(struct node a,struct node b){return a.ai<b.ai;} int main() { int n,p,t,i,j; while(cin>>n>>t>>p) { if(n==0&&t==0&&p==0) break; memset(b,0,sizeof(b)); for(i=1;i<=n;i++) scanf("%d%d",&b[i].ai,&b[i].bi); sort(b+1,b+n+1,cmp); b[0].ai=0; b[0].bi=1; b[n+1].bi=b[n+1].ai=100; memset(dp,0,sizeof(dp)); int T=(100+p-1)/p; int k; for(i=1;i<=T;i++) { for(j=0;j<=100;j++) { int max=0; for(k=0;k<=n;k++) { if(b[k].ai+j>100) break; max=Max(max,dp[i-1][j+b[k].ai]+b[k].bi); } dp[i][j]=max; } for(j=99;j>100-t;j--) dp[i][100]=Max(dp[i][j],dp[i][100]); for(j=100-t;j>=0;j--) dp[i][j+t]=Max(dp[i][j],dp[i][j+t]); } for(i=1;i<=T;i++) { for(j=0;j<=100;j++) if(dp[i][j]>=100) break; if(j<=100) {printf("%d\n",i);break;} } if(i>T)printf("My god\n"); } return 0; }
[ "noreply@github.com" ]
Kiritow.noreply@github.com
c8a69d2ea381c1e4bd090faed1da6e0d94e279ea
8afb5afd38548c631f6f9536846039ef6cb297b9
/MY_REPOS/misc-experiments/_FIREBFIRE/grpc/src/core/lib/surface/server.cc
c94551545d19e28e4baac35d096fdff8b35c523d
[ "MIT", "Apache-2.0" ]
permissive
bgoonz/UsefulResourceRepo2.0
d87588ffd668bb498f7787b896cc7b20d83ce0ad
2cb4b45dd14a230aa0e800042e893f8dfb23beda
refs/heads/master
2023-03-17T01:22:05.254751
2022-08-11T03:18:22
2022-08-11T03:18:22
382,628,698
10
12
MIT
2022-10-10T14:13:54
2021-07-03T13:58:52
null
UTF-8
C++
false
false
57,094
cc
// // Copyright 2015-2016 gRPC authors. // // 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 <grpc/support/port_platform.h> #include "src/core/lib/surface/server.h" #include <limits.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <atomic> #include <iterator> #include <list> #include <queue> #include <utility> #include <vector> #include "absl/types/optional.h" #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/spinlock.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/mpscq.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/surface/init.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" namespace grpc_core { TraceFlag grpc_server_channel_trace(false, "server_channel"); // // Server::RequestedCall // struct Server::RequestedCall { enum class Type { BATCH_CALL, REGISTERED_CALL }; RequestedCall(void* tag_arg, grpc_completion_queue* call_cq, grpc_call** call_arg, grpc_metadata_array* initial_md, grpc_call_details* details) : type(Type::BATCH_CALL), tag(tag_arg), cq_bound_to_call(call_cq), call(call_arg), initial_metadata(initial_md) { details->reserved = nullptr; data.batch.details = details; } RequestedCall(void* tag_arg, grpc_completion_queue* call_cq, grpc_call** call_arg, grpc_metadata_array* initial_md, RegisteredMethod* rm, gpr_timespec* deadline, grpc_byte_buffer** optional_payload) : type(Type::REGISTERED_CALL), tag(tag_arg), cq_bound_to_call(call_cq), call(call_arg), initial_metadata(initial_md) { data.registered.method = rm; data.registered.deadline = deadline; data.registered.optional_payload = optional_payload; } MultiProducerSingleConsumerQueue::Node mpscq_node; const Type type; void* const tag; grpc_completion_queue* const cq_bound_to_call; grpc_call** const call; grpc_cq_completion completion; grpc_metadata_array* const initial_metadata; union { struct { grpc_call_details* details; } batch; struct { RegisteredMethod* method; gpr_timespec* deadline; grpc_byte_buffer** optional_payload; } registered; } data; }; // // Server::RegisteredMethod // struct Server::RegisteredMethod { RegisteredMethod( const char* method_arg, const char* host_arg, grpc_server_register_method_payload_handling payload_handling_arg, uint32_t flags_arg) : method(method_arg == nullptr ? "" : method_arg), host(host_arg == nullptr ? "" : host_arg), payload_handling(payload_handling_arg), flags(flags_arg) {} ~RegisteredMethod() = default; const std::string method; const std::string host; const grpc_server_register_method_payload_handling payload_handling; const uint32_t flags; // One request matcher per method. std::unique_ptr<RequestMatcherInterface> matcher; }; // // Server::RequestMatcherInterface // // RPCs that come in from the transport must be matched against RPC requests // from the application. An incoming request from the application can be matched // to an RPC that has already arrived or can be queued up for later use. // Likewise, an RPC coming in from the transport can either be matched to a // request that already arrived from the application or can be queued up for // later use (marked pending). If there is a match, the request's tag is posted // on the request's notification CQ. // // RequestMatcherInterface is the base class to provide this functionality. class Server::RequestMatcherInterface { public: virtual ~RequestMatcherInterface() {} // Unref the calls associated with any incoming RPCs in the pending queue (not // yet matched to an application-requested RPC). virtual void ZombifyPending() = 0; // Mark all application-requested RPCs failed if they have not been matched to // an incoming RPC. The error parameter indicates why the RPCs are being // failed (always server shutdown in all current implementations). virtual void KillRequests(grpc_error* error) = 0; // How many request queues are supported by this matcher. This is an abstract // concept that essentially maps to gRPC completion queues. virtual size_t request_queue_count() const = 0; // This function is invoked when the application requests a new RPC whose // information is in the call parameter. The request_queue_index marks the // queue onto which to place this RPC, and is typically associated with a gRPC // CQ. If there are pending RPCs waiting to be matched, publish one (match it // and notify the CQ). virtual void RequestCallWithPossiblePublish(size_t request_queue_index, RequestedCall* call) = 0; // This function is invoked on an incoming RPC, represented by the calld // object. The RequestMatcher will try to match it against an // application-requested RPC if possible or will place it in the pending queue // otherwise. To enable some measure of fairness between server CQs, the match // is done starting at the start_request_queue_index parameter in a cyclic // order rather than always starting at 0. virtual void MatchOrQueue(size_t start_request_queue_index, CallData* calld) = 0; // Returns the server associated with this request matcher virtual Server* server() const = 0; }; // The RealRequestMatcher is an implementation of RequestMatcherInterface that // actually uses all the features of RequestMatcherInterface: expecting the // application to explicitly request RPCs and then matching those to incoming // RPCs, along with a slow path by which incoming RPCs are put on a locked // pending list if they aren't able to be matched to an application request. class Server::RealRequestMatcher : public RequestMatcherInterface { public: explicit RealRequestMatcher(Server* server) : server_(server), requests_per_cq_(server->cqs_.size()) {} ~RealRequestMatcher() override { for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) { GPR_ASSERT(queue.Pop() == nullptr); } } void ZombifyPending() override { while (!pending_.empty()) { CallData* calld = pending_.front(); calld->SetState(CallData::CallState::ZOMBIED); calld->KillZombie(); pending_.pop(); } } void KillRequests(grpc_error* error) override { for (size_t i = 0; i < requests_per_cq_.size(); i++) { RequestedCall* rc; while ((rc = reinterpret_cast<RequestedCall*>( requests_per_cq_[i].Pop())) != nullptr) { server_->FailCall(i, rc, GRPC_ERROR_REF(error)); } } GRPC_ERROR_UNREF(error); } size_t request_queue_count() const override { return requests_per_cq_.size(); } void RequestCallWithPossiblePublish(size_t request_queue_index, RequestedCall* call) override { if (requests_per_cq_[request_queue_index].Push(&call->mpscq_node)) { /* this was the first queued request: we need to lock and start matching calls */ struct PendingCall { RequestedCall* rc = nullptr; CallData* calld; }; auto pop_next_pending = [this, request_queue_index] { PendingCall pending_call; { MutexLock lock(&server_->mu_call_); if (!pending_.empty()) { pending_call.rc = reinterpret_cast<RequestedCall*>( requests_per_cq_[request_queue_index].Pop()); if (pending_call.rc != nullptr) { pending_call.calld = pending_.front(); pending_.pop(); } } } return pending_call; }; while (true) { PendingCall next_pending = pop_next_pending(); if (next_pending.rc == nullptr) break; if (!next_pending.calld->MaybeActivate()) { // Zombied Call next_pending.calld->KillZombie(); } else { next_pending.calld->Publish(request_queue_index, next_pending.rc); } } } } void MatchOrQueue(size_t start_request_queue_index, CallData* calld) override { for (size_t i = 0; i < requests_per_cq_.size(); i++) { size_t cq_idx = (start_request_queue_index + i) % requests_per_cq_.size(); RequestedCall* rc = reinterpret_cast<RequestedCall*>(requests_per_cq_[cq_idx].TryPop()); if (rc != nullptr) { GRPC_STATS_INC_SERVER_CQS_CHECKED(i); calld->SetState(CallData::CallState::ACTIVATED); calld->Publish(cq_idx, rc); return; } } // No cq to take the request found; queue it on the slow list. GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED(); // We need to ensure that all the queues are empty. We do this under // the server mu_call_ lock to ensure that if something is added to // an empty request queue, it will block until the call is actually // added to the pending list. RequestedCall* rc = nullptr; size_t cq_idx = 0; size_t loop_count; { MutexLock lock(&server_->mu_call_); for (loop_count = 0; loop_count < requests_per_cq_.size(); loop_count++) { cq_idx = (start_request_queue_index + loop_count) % requests_per_cq_.size(); rc = reinterpret_cast<RequestedCall*>(requests_per_cq_[cq_idx].Pop()); if (rc != nullptr) { break; } } if (rc == nullptr) { calld->SetState(CallData::CallState::PENDING); pending_.push(calld); return; } } GRPC_STATS_INC_SERVER_CQS_CHECKED(loop_count + requests_per_cq_.size()); calld->SetState(CallData::CallState::ACTIVATED); calld->Publish(cq_idx, rc); } Server* server() const override { return server_; } private: Server* const server_; std::queue<CallData*> pending_; std::vector<LockedMultiProducerSingleConsumerQueue> requests_per_cq_; }; // AllocatingRequestMatchers don't allow the application to request an RPC in // advance or queue up any incoming RPC for later match. Instead, MatchOrQueue // will call out to an allocation function passed in at the construction of the // object. These request matchers are designed for the C++ callback API, so they // only support 1 completion queue (passed in at the constructor). class Server::AllocatingRequestMatcherBase : public RequestMatcherInterface { public: AllocatingRequestMatcherBase(Server* server, grpc_completion_queue* cq) : server_(server), cq_(cq) { size_t idx; for (idx = 0; idx < server->cqs_.size(); idx++) { if (server->cqs_[idx] == cq) { break; } } GPR_ASSERT(idx < server->cqs_.size()); cq_idx_ = idx; } void ZombifyPending() override {} void KillRequests(grpc_error* error) override { GRPC_ERROR_UNREF(error); } size_t request_queue_count() const override { return 0; } void RequestCallWithPossiblePublish(size_t /*request_queue_index*/, RequestedCall* /*call*/) final { GPR_ASSERT(false); } Server* server() const override { return server_; } // Supply the completion queue related to this request matcher grpc_completion_queue* cq() const { return cq_; } // Supply the completion queue's index relative to the server. size_t cq_idx() const { return cq_idx_; } private: Server* const server_; grpc_completion_queue* const cq_; size_t cq_idx_; }; // An allocating request matcher for non-registered methods (used for generic // API and unimplemented RPCs). class Server::AllocatingRequestMatcherBatch : public AllocatingRequestMatcherBase { public: AllocatingRequestMatcherBatch(Server* server, grpc_completion_queue* cq, std::function<BatchCallAllocation()> allocator) : AllocatingRequestMatcherBase(server, cq), allocator_(std::move(allocator)) {} void MatchOrQueue(size_t /*start_request_queue_index*/, CallData* calld) override { BatchCallAllocation call_info = allocator_(); GPR_ASSERT(server()->ValidateServerRequest( cq(), static_cast<void*>(call_info.tag), nullptr, nullptr) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall( static_cast<void*>(call_info.tag), cq(), call_info.call, call_info.initial_metadata, call_info.details); calld->SetState(CallData::CallState::ACTIVATED); calld->Publish(cq_idx(), rc); } private: std::function<BatchCallAllocation()> allocator_; }; // An allocating request matcher for registered methods. class Server::AllocatingRequestMatcherRegistered : public AllocatingRequestMatcherBase { public: AllocatingRequestMatcherRegistered( Server* server, grpc_completion_queue* cq, RegisteredMethod* rm, std::function<RegisteredCallAllocation()> allocator) : AllocatingRequestMatcherBase(server, cq), registered_method_(rm), allocator_(std::move(allocator)) {} void MatchOrQueue(size_t /*start_request_queue_index*/, CallData* calld) override { RegisteredCallAllocation call_info = allocator_(); GPR_ASSERT( server()->ValidateServerRequest(cq(), static_cast<void*>(call_info.tag), call_info.optional_payload, registered_method_) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall( static_cast<void*>(call_info.tag), cq(), call_info.call, call_info.initial_metadata, registered_method_, call_info.deadline, call_info.optional_payload); calld->SetState(CallData::CallState::ACTIVATED); calld->Publish(cq_idx(), rc); } private: RegisteredMethod* const registered_method_; std::function<RegisteredCallAllocation()> allocator_; }; // // ChannelBroadcaster // namespace { class ChannelBroadcaster { public: // This can have an empty constructor and destructor since we want to control // when the actual setup and shutdown broadcast take place. // Copies over the channels from the locked server. void FillChannelsLocked(std::vector<grpc_channel*> channels) { GPR_DEBUG_ASSERT(channels_.empty()); channels_ = std::move(channels); } // Broadcasts a shutdown on each channel. void BroadcastShutdown(bool send_goaway, grpc_error* force_disconnect) { for (grpc_channel* channel : channels_) { SendShutdown(channel, send_goaway, GRPC_ERROR_REF(force_disconnect)); GRPC_CHANNEL_INTERNAL_UNREF(channel, "broadcast"); } channels_.clear(); // just for safety against double broadcast GRPC_ERROR_UNREF(force_disconnect); } private: struct ShutdownCleanupArgs { grpc_closure closure; grpc_slice slice; }; static void ShutdownCleanup(void* arg, grpc_error* /*error*/) { ShutdownCleanupArgs* a = static_cast<ShutdownCleanupArgs*>(arg); grpc_slice_unref_internal(a->slice); delete a; } static void SendShutdown(grpc_channel* channel, bool send_goaway, grpc_error* send_disconnect) { ShutdownCleanupArgs* sc = new ShutdownCleanupArgs; GRPC_CLOSURE_INIT(&sc->closure, ShutdownCleanup, sc, grpc_schedule_on_exec_ctx); grpc_transport_op* op = grpc_make_transport_op(&sc->closure); grpc_channel_element* elem; op->goaway_error = send_goaway ? grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_OK) : GRPC_ERROR_NONE; op->set_accept_stream = true; sc->slice = grpc_slice_from_copied_string("Server shutdown"); op->disconnect_with_error = send_disconnect; elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0); elem->filter->start_transport_op(elem, op); } std::vector<grpc_channel*> channels_; }; } // namespace // // Server // const grpc_channel_filter Server::kServerTopFilter = { Server::CallData::StartTransportStreamOpBatch, grpc_channel_next_op, sizeof(Server::CallData), Server::CallData::InitCallElement, grpc_call_stack_ignore_set_pollset_or_pollset_set, Server::CallData::DestroyCallElement, sizeof(Server::ChannelData), Server::ChannelData::InitChannelElement, Server::ChannelData::DestroyChannelElement, grpc_channel_next_get_info, "server", }; namespace { grpc_resource_user* CreateDefaultResourceUser(const grpc_channel_args* args) { if (args != nullptr) { grpc_resource_quota* resource_quota = grpc_resource_quota_from_channel_args(args, false /* create */); if (resource_quota != nullptr) { return grpc_resource_user_create(resource_quota, "default"); } } return nullptr; } RefCountedPtr<channelz::ServerNode> CreateChannelzNode( Server* server, const grpc_channel_args* args) { RefCountedPtr<channelz::ServerNode> channelz_node; if (grpc_channel_args_find_bool(args, GRPC_ARG_ENABLE_CHANNELZ, GRPC_ENABLE_CHANNELZ_DEFAULT)) { size_t channel_tracer_max_memory = grpc_channel_args_find_integer( args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE, {GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX}); channelz_node = MakeRefCounted<channelz::ServerNode>(channel_tracer_max_memory); channelz_node->AddTraceEvent( channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string("Server created")); } return channelz_node; } } // namespace Server::Server(const grpc_channel_args* args) : channel_args_(grpc_channel_args_copy(args)), default_resource_user_(CreateDefaultResourceUser(args)), channelz_node_(CreateChannelzNode(this, args)) {} Server::~Server() { grpc_channel_args_destroy(channel_args_); for (size_t i = 0; i < cqs_.size(); i++) { GRPC_CQ_INTERNAL_UNREF(cqs_[i], "server"); } } void Server::AddListener(OrphanablePtr<ListenerInterface> listener) { channelz::ListenSocketNode* listen_socket_node = listener->channelz_listen_socket_node(); if (listen_socket_node != nullptr && channelz_node_ != nullptr) { channelz_node_->AddChildListenSocket(listen_socket_node->Ref()); } listeners_.emplace_back(std::move(listener)); } void Server::Start() { started_ = true; for (grpc_completion_queue* cq : cqs_) { if (grpc_cq_can_listen(cq)) { pollsets_.push_back(grpc_cq_pollset(cq)); } } if (unregistered_request_matcher_ == nullptr) { unregistered_request_matcher_ = absl::make_unique<RealRequestMatcher>(this); } for (std::unique_ptr<RegisteredMethod>& rm : registered_methods_) { if (rm->matcher == nullptr) { rm->matcher = absl::make_unique<RealRequestMatcher>(this); } } { MutexLock lock(&mu_global_); starting_ = true; } for (auto& listener : listeners_) { listener.listener->Start(this, &pollsets_); } MutexLock lock(&mu_global_); starting_ = false; starting_cv_.Signal(); } void Server::SetupTransport( grpc_transport* transport, grpc_pollset* accepting_pollset, const grpc_channel_args* args, const RefCountedPtr<grpc_core::channelz::SocketNode>& socket_node, grpc_resource_user* resource_user) { // Create channel. grpc_channel* channel = grpc_channel_create( nullptr, args, GRPC_SERVER_CHANNEL, transport, resource_user); ChannelData* chand = static_cast<ChannelData*>( grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0) ->channel_data); // Set up CQs. size_t cq_idx; for (cq_idx = 0; cq_idx < cqs_.size(); cq_idx++) { if (grpc_cq_pollset(cqs_[cq_idx]) == accepting_pollset) break; } if (cq_idx == cqs_.size()) { // Completion queue not found. Pick a random one to publish new calls to. cq_idx = static_cast<size_t>(rand()) % cqs_.size(); } // Set up channelz node. intptr_t channelz_socket_uuid = 0; if (socket_node != nullptr) { channelz_socket_uuid = socket_node->uuid(); channelz_node_->AddChildSocket(socket_node); } // Initialize chand. chand->InitTransport(Ref(), channel, cq_idx, transport, channelz_socket_uuid); } bool Server::HasOpenConnections() { MutexLock lock(&mu_global_); return !channels_.empty(); } void Server::SetRegisteredMethodAllocator( grpc_completion_queue* cq, void* method_tag, std::function<RegisteredCallAllocation()> allocator) { RegisteredMethod* rm = static_cast<RegisteredMethod*>(method_tag); rm->matcher = absl::make_unique<AllocatingRequestMatcherRegistered>( this, cq, rm, std::move(allocator)); } void Server::SetBatchMethodAllocator( grpc_completion_queue* cq, std::function<BatchCallAllocation()> allocator) { GPR_DEBUG_ASSERT(unregistered_request_matcher_ == nullptr); unregistered_request_matcher_ = absl::make_unique<AllocatingRequestMatcherBatch>(this, cq, std::move(allocator)); } void Server::RegisterCompletionQueue(grpc_completion_queue* cq) { for (grpc_completion_queue* queue : cqs_) { if (queue == cq) return; } GRPC_CQ_INTERNAL_REF(cq, "server"); cqs_.push_back(cq); } namespace { bool streq(const std::string& a, const char* b) { return (a.empty() && b == nullptr) || ((b != nullptr) && !strcmp(a.c_str(), b)); } } // namespace Server::RegisteredMethod* Server::RegisterMethod( const char* method, const char* host, grpc_server_register_method_payload_handling payload_handling, uint32_t flags) { if (!method) { gpr_log(GPR_ERROR, "grpc_server_register_method method string cannot be NULL"); return nullptr; } for (std::unique_ptr<RegisteredMethod>& m : registered_methods_) { if (streq(m->method, method) && streq(m->host, host)) { gpr_log(GPR_ERROR, "duplicate registration for %s@%s", method, host ? host : "*"); return nullptr; } } if ((flags & ~GRPC_INITIAL_METADATA_USED_MASK) != 0) { gpr_log(GPR_ERROR, "grpc_server_register_method invalid flags 0x%08x", flags); return nullptr; } registered_methods_.emplace_back(absl::make_unique<RegisteredMethod>( method, host, payload_handling, flags)); return registered_methods_.back().get(); } void Server::DoneRequestEvent(void* req, grpc_cq_completion* /*c*/) { delete static_cast<RequestedCall*>(req); } void Server::FailCall(size_t cq_idx, RequestedCall* rc, grpc_error* error) { *rc->call = nullptr; rc->initial_metadata->count = 0; GPR_ASSERT(error != GRPC_ERROR_NONE); grpc_cq_end_op(cqs_[cq_idx], rc->tag, error, DoneRequestEvent, rc, &rc->completion); } // Before calling MaybeFinishShutdown(), we must hold mu_global_ and not // hold mu_call_. void Server::MaybeFinishShutdown() { if (!shutdown_flag_.load(std::memory_order_acquire) || shutdown_published_) { return; } { MutexLock lock(&mu_call_); KillPendingWorkLocked( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown")); } if (!channels_.empty() || listeners_destroyed_ < listeners_.size()) { if (gpr_time_cmp(gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_shutdown_message_time_), gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) { last_shutdown_message_time_ = gpr_now(GPR_CLOCK_REALTIME); gpr_log(GPR_DEBUG, "Waiting for %" PRIuPTR " channels and %" PRIuPTR "/%" PRIuPTR " listeners to be destroyed before shutting down server", channels_.size(), listeners_.size() - listeners_destroyed_, listeners_.size()); } return; } shutdown_published_ = true; for (auto& shutdown_tag : shutdown_tags_) { Ref().release(); grpc_cq_end_op(shutdown_tag.cq, shutdown_tag.tag, GRPC_ERROR_NONE, DoneShutdownEvent, this, &shutdown_tag.completion); } } void Server::KillPendingWorkLocked(grpc_error* error) { if (started_) { unregistered_request_matcher_->KillRequests(GRPC_ERROR_REF(error)); unregistered_request_matcher_->ZombifyPending(); for (std::unique_ptr<RegisteredMethod>& rm : registered_methods_) { rm->matcher->KillRequests(GRPC_ERROR_REF(error)); rm->matcher->ZombifyPending(); } } GRPC_ERROR_UNREF(error); } std::vector<grpc_channel*> Server::GetChannelsLocked() const { std::vector<grpc_channel*> channels; channels.reserve(channels_.size()); for (const ChannelData* chand : channels_) { channels.push_back(chand->channel()); GRPC_CHANNEL_INTERNAL_REF(chand->channel(), "broadcast"); } return channels; } void Server::ListenerDestroyDone(void* arg, grpc_error* /*error*/) { Server* server = static_cast<Server*>(arg); MutexLock lock(&server->mu_global_); server->listeners_destroyed_++; server->MaybeFinishShutdown(); } namespace { void DonePublishedShutdown(void* /*done_arg*/, grpc_cq_completion* storage) { delete storage; } } // namespace // - Kills all pending requests-for-incoming-RPC-calls (i.e., the requests made // via grpc_server_request_call() and grpc_server_request_registered_call() // will now be cancelled). See KillPendingWorkLocked(). // // - Shuts down the listeners (i.e., the server will no longer listen on the // port for new incoming channels). // // - Iterates through all channels on the server and sends shutdown msg (see // ChannelBroadcaster::BroadcastShutdown() for details) to the clients via // the transport layer. The transport layer then guarantees the following: // -- Sends shutdown to the client (e.g., HTTP2 transport sends GOAWAY). // -- If the server has outstanding calls that are in the process, the // connection is NOT closed until the server is done with all those calls. // -- Once there are no more calls in progress, the channel is closed. void Server::ShutdownAndNotify(grpc_completion_queue* cq, void* tag) { ChannelBroadcaster broadcaster; { // Wait for startup to be finished. Locks mu_global. MutexLock lock(&mu_global_); starting_cv_.WaitUntil(&mu_global_, [this] { return !starting_; }); // Stay locked, and gather up some stuff to do. GPR_ASSERT(grpc_cq_begin_op(cq, tag)); if (shutdown_published_) { grpc_cq_end_op(cq, tag, GRPC_ERROR_NONE, DonePublishedShutdown, nullptr, new grpc_cq_completion); return; } shutdown_tags_.emplace_back(tag, cq); if (shutdown_flag_.load(std::memory_order_acquire)) { return; } last_shutdown_message_time_ = gpr_now(GPR_CLOCK_REALTIME); broadcaster.FillChannelsLocked(GetChannelsLocked()); shutdown_flag_.store(true, std::memory_order_release); // Collect all unregistered then registered calls. { MutexLock lock(&mu_call_); KillPendingWorkLocked( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown")); } MaybeFinishShutdown(); } // Shutdown listeners. for (auto& listener : listeners_) { channelz::ListenSocketNode* channelz_listen_socket_node = listener.listener->channelz_listen_socket_node(); if (channelz_node_ != nullptr && channelz_listen_socket_node != nullptr) { channelz_node_->RemoveChildListenSocket( channelz_listen_socket_node->uuid()); } GRPC_CLOSURE_INIT(&listener.destroy_done, ListenerDestroyDone, this, grpc_schedule_on_exec_ctx); listener.listener->SetOnDestroyDone(&listener.destroy_done); listener.listener.reset(); } broadcaster.BroadcastShutdown(/*send_goaway=*/true, GRPC_ERROR_NONE); } void Server::CancelAllCalls() { ChannelBroadcaster broadcaster; { MutexLock lock(&mu_global_); broadcaster.FillChannelsLocked(GetChannelsLocked()); } broadcaster.BroadcastShutdown( /*send_goaway=*/false, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Cancelling all calls")); } void Server::Orphan() { { MutexLock lock(&mu_global_); GPR_ASSERT(shutdown_flag_.load(std::memory_order_acquire) || listeners_.empty()); GPR_ASSERT(listeners_destroyed_ == listeners_.size()); } if (default_resource_user_ != nullptr) { grpc_resource_quota_unref(grpc_resource_user_quota(default_resource_user_)); grpc_resource_user_shutdown(default_resource_user_); grpc_resource_user_unref(default_resource_user_); } Unref(); } grpc_call_error Server::ValidateServerRequest( grpc_completion_queue* cq_for_notification, void* tag, grpc_byte_buffer** optional_payload, RegisteredMethod* rm) { if ((rm == nullptr && optional_payload != nullptr) || ((rm != nullptr) && ((optional_payload == nullptr) != (rm->payload_handling == GRPC_SRM_PAYLOAD_NONE)))) { return GRPC_CALL_ERROR_PAYLOAD_TYPE_MISMATCH; } if (grpc_cq_begin_op(cq_for_notification, tag) == false) { return GRPC_CALL_ERROR_COMPLETION_QUEUE_SHUTDOWN; } return GRPC_CALL_OK; } grpc_call_error Server::ValidateServerRequestAndCq( size_t* cq_idx, grpc_completion_queue* cq_for_notification, void* tag, grpc_byte_buffer** optional_payload, RegisteredMethod* rm) { size_t idx; for (idx = 0; idx < cqs_.size(); idx++) { if (cqs_[idx] == cq_for_notification) { break; } } if (idx == cqs_.size()) { return GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE; } grpc_call_error error = ValidateServerRequest(cq_for_notification, tag, optional_payload, rm); if (error != GRPC_CALL_OK) { return error; } *cq_idx = idx; return GRPC_CALL_OK; } grpc_call_error Server::QueueRequestedCall(size_t cq_idx, RequestedCall* rc) { if (shutdown_flag_.load(std::memory_order_acquire)) { FailCall(cq_idx, rc, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown")); return GRPC_CALL_OK; } RequestMatcherInterface* rm; switch (rc->type) { case RequestedCall::Type::BATCH_CALL: rm = unregistered_request_matcher_.get(); break; case RequestedCall::Type::REGISTERED_CALL: rm = rc->data.registered.method->matcher.get(); break; } rm->RequestCallWithPossiblePublish(cq_idx, rc); return GRPC_CALL_OK; } grpc_call_error Server::RequestCall(grpc_call** call, grpc_call_details* details, grpc_metadata_array* request_metadata, grpc_completion_queue* cq_bound_to_call, grpc_completion_queue* cq_for_notification, void* tag) { size_t cq_idx; grpc_call_error error = ValidateServerRequestAndCq( &cq_idx, cq_for_notification, tag, nullptr, nullptr); if (error != GRPC_CALL_OK) { return error; } RequestedCall* rc = new RequestedCall(tag, cq_bound_to_call, call, request_metadata, details); return QueueRequestedCall(cq_idx, rc); } grpc_call_error Server::RequestRegisteredCall( RegisteredMethod* rm, grpc_call** call, gpr_timespec* deadline, grpc_metadata_array* request_metadata, grpc_byte_buffer** optional_payload, grpc_completion_queue* cq_bound_to_call, grpc_completion_queue* cq_for_notification, void* tag_new) { size_t cq_idx; grpc_call_error error = ValidateServerRequestAndCq( &cq_idx, cq_for_notification, tag_new, optional_payload, rm); if (error != GRPC_CALL_OK) { return error; } RequestedCall* rc = new RequestedCall(tag_new, cq_bound_to_call, call, request_metadata, rm, deadline, optional_payload); return QueueRequestedCall(cq_idx, rc); } // // Server::ChannelData::ConnectivityWatcher // class Server::ChannelData::ConnectivityWatcher : public AsyncConnectivityStateWatcherInterface { public: explicit ConnectivityWatcher(ChannelData* chand) : chand_(chand) { GRPC_CHANNEL_INTERNAL_REF(chand_->channel_, "connectivity"); } ~ConnectivityWatcher() { GRPC_CHANNEL_INTERNAL_UNREF(chand_->channel_, "connectivity"); } private: void OnConnectivityStateChange(grpc_connectivity_state new_state, const absl::Status& /*status*/) override { // Don't do anything until we are being shut down. if (new_state != GRPC_CHANNEL_SHUTDOWN) return; // Shut down channel. MutexLock lock(&chand_->server_->mu_global_); chand_->Destroy(); } ChannelData* chand_; }; // // Server::ChannelData // Server::ChannelData::~ChannelData() { if (registered_methods_ != nullptr) { for (const ChannelRegisteredMethod& crm : *registered_methods_) { grpc_slice_unref_internal(crm.method); GPR_DEBUG_ASSERT(crm.method.refcount == &kNoopRefcount || crm.method.refcount == nullptr); if (crm.has_host) { grpc_slice_unref_internal(crm.host); GPR_DEBUG_ASSERT(crm.host.refcount == &kNoopRefcount || crm.host.refcount == nullptr); } } registered_methods_.reset(); } if (server_ != nullptr) { if (server_->channelz_node_ != nullptr && channelz_socket_uuid_ != 0) { server_->channelz_node_->RemoveChildSocket(channelz_socket_uuid_); } { MutexLock lock(&server_->mu_global_); if (list_position_.has_value()) { server_->channels_.erase(*list_position_); list_position_.reset(); } server_->MaybeFinishShutdown(); } } } void Server::ChannelData::InitTransport(RefCountedPtr<Server> server, grpc_channel* channel, size_t cq_idx, grpc_transport* transport, intptr_t channelz_socket_uuid) { server_ = std::move(server); channel_ = channel; cq_idx_ = cq_idx; channelz_socket_uuid_ = channelz_socket_uuid; // Build a lookup table phrased in terms of mdstr's in this channels context // to quickly find registered methods. size_t num_registered_methods = server_->registered_methods_.size(); if (num_registered_methods > 0) { uint32_t max_probes = 0; size_t slots = 2 * num_registered_methods; registered_methods_.reset(new std::vector<ChannelRegisteredMethod>(slots)); for (std::unique_ptr<RegisteredMethod>& rm : server_->registered_methods_) { ExternallyManagedSlice host; ExternallyManagedSlice method(rm->method.c_str()); const bool has_host = !rm->host.empty(); if (has_host) { host = ExternallyManagedSlice(rm->host.c_str()); } uint32_t hash = GRPC_MDSTR_KV_HASH(has_host ? host.Hash() : 0, method.Hash()); uint32_t probes = 0; for (probes = 0; (*registered_methods_)[(hash + probes) % slots] .server_registered_method != nullptr; probes++) { } if (probes > max_probes) max_probes = probes; ChannelRegisteredMethod* crm = &(*registered_methods_)[(hash + probes) % slots]; crm->server_registered_method = rm.get(); crm->flags = rm->flags; crm->has_host = has_host; if (has_host) { crm->host = host; } crm->method = method; } GPR_ASSERT(slots <= UINT32_MAX); registered_method_max_probes_ = max_probes; } // Publish channel. { MutexLock lock(&server_->mu_global_); server_->channels_.push_front(this); list_position_ = server_->channels_.begin(); } // Start accept_stream transport op. grpc_transport_op* op = grpc_make_transport_op(nullptr); op->set_accept_stream = true; op->set_accept_stream_fn = AcceptStream; op->set_accept_stream_user_data = this; op->start_connectivity_watch = MakeOrphanable<ConnectivityWatcher>(this); if (server_->shutdown_flag_.load(std::memory_order_acquire)) { op->disconnect_with_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"); } grpc_transport_perform_op(transport, op); } Server::ChannelRegisteredMethod* Server::ChannelData::GetRegisteredMethod( const grpc_slice& host, const grpc_slice& path, bool is_idempotent) { if (registered_methods_ == nullptr) return nullptr; /* TODO(ctiller): unify these two searches */ /* check for an exact match with host */ uint32_t hash = GRPC_MDSTR_KV_HASH(grpc_slice_hash_internal(host), grpc_slice_hash_internal(path)); for (size_t i = 0; i <= registered_method_max_probes_; i++) { ChannelRegisteredMethod* rm = &(*registered_methods_)[(hash + i) % registered_methods_->size()]; if (rm->server_registered_method == nullptr) break; if (!rm->has_host) continue; if (rm->host != host) continue; if (rm->method != path) continue; if ((rm->flags & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) && !is_idempotent) { continue; } return rm; } /* check for a wildcard method definition (no host set) */ hash = GRPC_MDSTR_KV_HASH(0, grpc_slice_hash_internal(path)); for (size_t i = 0; i <= registered_method_max_probes_; i++) { ChannelRegisteredMethod* rm = &(*registered_methods_)[(hash + i) % registered_methods_->size()]; if (rm->server_registered_method == nullptr) break; if (rm->has_host) continue; if (rm->method != path) continue; if ((rm->flags & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) && !is_idempotent) { continue; } return rm; } return nullptr; } void Server::ChannelData::AcceptStream(void* arg, grpc_transport* /*transport*/, const void* transport_server_data) { auto* chand = static_cast<Server::ChannelData*>(arg); /* create a call */ grpc_call_create_args args; args.channel = chand->channel_; args.server = chand->server_.get(); args.parent = nullptr; args.propagation_mask = 0; args.cq = nullptr; args.pollset_set_alternative = nullptr; args.server_transport_data = transport_server_data; args.add_initial_metadata = nullptr; args.add_initial_metadata_count = 0; args.send_deadline = GRPC_MILLIS_INF_FUTURE; grpc_call* call; grpc_error* error = grpc_call_create(&args, &call); grpc_call_element* elem = grpc_call_stack_element(grpc_call_get_call_stack(call), 0); auto* calld = static_cast<Server::CallData*>(elem->call_data); if (error != GRPC_ERROR_NONE) { GRPC_ERROR_UNREF(error); calld->FailCallCreation(); return; } calld->Start(elem); } void Server::ChannelData::FinishDestroy(void* cd, grpc_error* /*error*/) { auto* chand = static_cast<Server::ChannelData*>(cd); Server* server = chand->server_.get(); GRPC_CHANNEL_INTERNAL_UNREF(chand->channel_, "server"); server->Unref(); } void Server::ChannelData::Destroy() { if (!list_position_.has_value()) return; GPR_ASSERT(server_ != nullptr); server_->channels_.erase(*list_position_); list_position_.reset(); server_->Ref().release(); server_->MaybeFinishShutdown(); GRPC_CLOSURE_INIT(&finish_destroy_channel_closure_, FinishDestroy, this, grpc_schedule_on_exec_ctx); if (GRPC_TRACE_FLAG_ENABLED(grpc_server_channel_trace)) { gpr_log(GPR_INFO, "Disconnected client"); } grpc_transport_op* op = grpc_make_transport_op(&finish_destroy_channel_closure_); op->set_accept_stream = true; grpc_channel_next_op( grpc_channel_stack_element(grpc_channel_get_channel_stack(channel_), 0), op); } grpc_error* Server::ChannelData::InitChannelElement( grpc_channel_element* elem, grpc_channel_element_args* args) { GPR_ASSERT(args->is_first); GPR_ASSERT(!args->is_last); new (elem->channel_data) ChannelData(); return GRPC_ERROR_NONE; } void Server::ChannelData::DestroyChannelElement(grpc_channel_element* elem) { auto* chand = static_cast<ChannelData*>(elem->channel_data); chand->~ChannelData(); } // // Server::CallData // Server::CallData::CallData(grpc_call_element* elem, const grpc_call_element_args& args, RefCountedPtr<Server> server) : server_(std::move(server)), call_(grpc_call_from_top_element(elem)), call_combiner_(args.call_combiner) { GRPC_CLOSURE_INIT(&recv_initial_metadata_ready_, RecvInitialMetadataReady, elem, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&recv_trailing_metadata_ready_, RecvTrailingMetadataReady, elem, grpc_schedule_on_exec_ctx); } Server::CallData::~CallData() { GPR_ASSERT(state_.Load(MemoryOrder::RELAXED) != CallState::PENDING); GRPC_ERROR_UNREF(recv_initial_metadata_error_); if (host_.has_value()) { grpc_slice_unref_internal(*host_); } if (path_.has_value()) { grpc_slice_unref_internal(*path_); } grpc_metadata_array_destroy(&initial_metadata_); grpc_byte_buffer_destroy(payload_); } void Server::CallData::SetState(CallState state) { state_.Store(state, MemoryOrder::RELAXED); } bool Server::CallData::MaybeActivate() { CallState expected = CallState::PENDING; return state_.CompareExchangeStrong(&expected, CallState::ACTIVATED, MemoryOrder::ACQ_REL, MemoryOrder::RELAXED); } void Server::CallData::FailCallCreation() { CallState expected_not_started = CallState::NOT_STARTED; CallState expected_pending = CallState::PENDING; if (state_.CompareExchangeStrong(&expected_not_started, CallState::ZOMBIED, MemoryOrder::ACQ_REL, MemoryOrder::ACQUIRE)) { KillZombie(); } else if (state_.CompareExchangeStrong(&expected_pending, CallState::ZOMBIED, MemoryOrder::ACQ_REL, MemoryOrder::RELAXED)) { // Zombied call will be destroyed when it's removed from the pending // queue... later. } } void Server::CallData::Start(grpc_call_element* elem) { grpc_op op; op.op = GRPC_OP_RECV_INITIAL_METADATA; op.flags = 0; op.reserved = nullptr; op.data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_; GRPC_CLOSURE_INIT(&recv_initial_metadata_batch_complete_, RecvInitialMetadataBatchComplete, elem, grpc_schedule_on_exec_ctx); grpc_call_start_batch_and_execute(call_, &op, 1, &recv_initial_metadata_batch_complete_); } void Server::CallData::Publish(size_t cq_idx, RequestedCall* rc) { grpc_call_set_completion_queue(call_, rc->cq_bound_to_call); *rc->call = call_; cq_new_ = server_->cqs_[cq_idx]; GPR_SWAP(grpc_metadata_array, *rc->initial_metadata, initial_metadata_); switch (rc->type) { case RequestedCall::Type::BATCH_CALL: GPR_ASSERT(host_.has_value()); GPR_ASSERT(path_.has_value()); rc->data.batch.details->host = grpc_slice_ref_internal(*host_); rc->data.batch.details->method = grpc_slice_ref_internal(*path_); rc->data.batch.details->deadline = grpc_millis_to_timespec(deadline_, GPR_CLOCK_MONOTONIC); rc->data.batch.details->flags = recv_initial_metadata_flags_; break; case RequestedCall::Type::REGISTERED_CALL: *rc->data.registered.deadline = grpc_millis_to_timespec(deadline_, GPR_CLOCK_MONOTONIC); if (rc->data.registered.optional_payload != nullptr) { *rc->data.registered.optional_payload = payload_; payload_ = nullptr; } break; default: GPR_UNREACHABLE_CODE(return ); } grpc_cq_end_op(cq_new_, rc->tag, GRPC_ERROR_NONE, Server::DoneRequestEvent, rc, &rc->completion, true); } void Server::CallData::PublishNewRpc(void* arg, grpc_error* error) { grpc_call_element* call_elem = static_cast<grpc_call_element*>(arg); auto* calld = static_cast<Server::CallData*>(call_elem->call_data); auto* chand = static_cast<Server::ChannelData*>(call_elem->channel_data); RequestMatcherInterface* rm = calld->matcher_; Server* server = rm->server(); if (error != GRPC_ERROR_NONE || server->shutdown_flag_.load(std::memory_order_acquire)) { calld->state_.Store(CallState::ZOMBIED, MemoryOrder::RELAXED); calld->KillZombie(); return; } rm->MatchOrQueue(chand->cq_idx(), calld); } namespace { void KillZombieClosure(void* call, grpc_error* /*error*/) { grpc_call_unref(static_cast<grpc_call*>(call)); } } // namespace void Server::CallData::KillZombie() { GRPC_CLOSURE_INIT(&kill_zombie_closure_, KillZombieClosure, call_, grpc_schedule_on_exec_ctx); ExecCtx::Run(DEBUG_LOCATION, &kill_zombie_closure_, GRPC_ERROR_NONE); } void Server::CallData::StartNewRpc(grpc_call_element* elem) { auto* chand = static_cast<ChannelData*>(elem->channel_data); if (server_->shutdown_flag_.load(std::memory_order_acquire)) { state_.Store(CallState::ZOMBIED, MemoryOrder::RELAXED); KillZombie(); return; } // Find request matcher. matcher_ = server_->unregistered_request_matcher_.get(); grpc_server_register_method_payload_handling payload_handling = GRPC_SRM_PAYLOAD_NONE; if (path_.has_value() && host_.has_value()) { ChannelRegisteredMethod* rm = chand->GetRegisteredMethod(*host_, *path_, (recv_initial_metadata_flags_ & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST)); if (rm != nullptr) { matcher_ = rm->server_registered_method->matcher.get(); payload_handling = rm->server_registered_method->payload_handling; } } // Start recv_message op if needed. switch (payload_handling) { case GRPC_SRM_PAYLOAD_NONE: PublishNewRpc(elem, GRPC_ERROR_NONE); break; case GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER: { grpc_op op; op.op = GRPC_OP_RECV_MESSAGE; op.flags = 0; op.reserved = nullptr; op.data.recv_message.recv_message = &payload_; GRPC_CLOSURE_INIT(&publish_, PublishNewRpc, elem, grpc_schedule_on_exec_ctx); grpc_call_start_batch_and_execute(call_, &op, 1, &publish_); break; } } } void Server::CallData::RecvInitialMetadataBatchComplete(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast<grpc_call_element*>(arg); auto* calld = static_cast<Server::CallData*>(elem->call_data); if (error != GRPC_ERROR_NONE) { calld->FailCallCreation(); return; } calld->StartNewRpc(elem); } void Server::CallData::StartTransportStreamOpBatchImpl( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { if (batch->recv_initial_metadata) { GPR_ASSERT(batch->payload->recv_initial_metadata.recv_flags == nullptr); recv_initial_metadata_ = batch->payload->recv_initial_metadata.recv_initial_metadata; original_recv_initial_metadata_ready_ = batch->payload->recv_initial_metadata.recv_initial_metadata_ready; batch->payload->recv_initial_metadata.recv_initial_metadata_ready = &recv_initial_metadata_ready_; batch->payload->recv_initial_metadata.recv_flags = &recv_initial_metadata_flags_; } if (batch->recv_trailing_metadata) { original_recv_trailing_metadata_ready_ = batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready; batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready = &recv_trailing_metadata_ready_; } grpc_call_next_op(elem, batch); } void Server::CallData::RecvInitialMetadataReady(void* ptr, grpc_error* error) { grpc_call_element* elem = static_cast<grpc_call_element*>(ptr); CallData* calld = static_cast<CallData*>(elem->call_data); grpc_millis op_deadline; if (error == GRPC_ERROR_NONE) { GPR_DEBUG_ASSERT(calld->recv_initial_metadata_->idx.named.path != nullptr); GPR_DEBUG_ASSERT(calld->recv_initial_metadata_->idx.named.authority != nullptr); calld->path_.emplace(grpc_slice_ref_internal( GRPC_MDVALUE(calld->recv_initial_metadata_->idx.named.path->md))); calld->host_.emplace(grpc_slice_ref_internal( GRPC_MDVALUE(calld->recv_initial_metadata_->idx.named.authority->md))); grpc_metadata_batch_remove(calld->recv_initial_metadata_, GRPC_BATCH_PATH); grpc_metadata_batch_remove(calld->recv_initial_metadata_, GRPC_BATCH_AUTHORITY); } else { GRPC_ERROR_REF(error); } op_deadline = calld->recv_initial_metadata_->deadline; if (op_deadline != GRPC_MILLIS_INF_FUTURE) { calld->deadline_ = op_deadline; } if (calld->host_.has_value() && calld->path_.has_value()) { /* do nothing */ } else { /* Pass the error reference to calld->recv_initial_metadata_error */ grpc_error* src_error = error; error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Missing :authority or :path", &src_error, 1); GRPC_ERROR_UNREF(src_error); calld->recv_initial_metadata_error_ = GRPC_ERROR_REF(error); } grpc_closure* closure = calld->original_recv_initial_metadata_ready_; calld->original_recv_initial_metadata_ready_ = nullptr; if (calld->seen_recv_trailing_metadata_ready_) { GRPC_CALL_COMBINER_START(calld->call_combiner_, &calld->recv_trailing_metadata_ready_, calld->recv_trailing_metadata_error_, "continue server recv_trailing_metadata_ready"); } Closure::Run(DEBUG_LOCATION, closure, error); } void Server::CallData::RecvTrailingMetadataReady(void* user_data, grpc_error* error) { grpc_call_element* elem = static_cast<grpc_call_element*>(user_data); CallData* calld = static_cast<CallData*>(elem->call_data); if (calld->original_recv_initial_metadata_ready_ != nullptr) { calld->recv_trailing_metadata_error_ = GRPC_ERROR_REF(error); calld->seen_recv_trailing_metadata_ready_ = true; GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready_, RecvTrailingMetadataReady, elem, grpc_schedule_on_exec_ctx); GRPC_CALL_COMBINER_STOP(calld->call_combiner_, "deferring server recv_trailing_metadata_ready " "until after recv_initial_metadata_ready"); return; } error = grpc_error_add_child(GRPC_ERROR_REF(error), GRPC_ERROR_REF(calld->recv_initial_metadata_error_)); Closure::Run(DEBUG_LOCATION, calld->original_recv_trailing_metadata_ready_, error); } grpc_error* Server::CallData::InitCallElement( grpc_call_element* elem, const grpc_call_element_args* args) { auto* chand = static_cast<ChannelData*>(elem->channel_data); new (elem->call_data) Server::CallData(elem, *args, chand->server()); return GRPC_ERROR_NONE; } void Server::CallData::DestroyCallElement( grpc_call_element* elem, const grpc_call_final_info* /*final_info*/, grpc_closure* /*ignored*/) { auto* calld = static_cast<CallData*>(elem->call_data); calld->~CallData(); } void Server::CallData::StartTransportStreamOpBatch( grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { auto* calld = static_cast<CallData*>(elem->call_data); calld->StartTransportStreamOpBatchImpl(elem, batch); } } // namespace grpc_core // // C-core API // grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) { grpc_core::ExecCtx exec_ctx; GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved)); grpc_server* c_server = new grpc_server; c_server->core_server = grpc_core::MakeOrphanable<grpc_core::Server>(args); return c_server; } void grpc_server_register_completion_queue(grpc_server* server, grpc_completion_queue* cq, void* reserved) { GRPC_API_TRACE( "grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3, (server, cq, reserved)); GPR_ASSERT(!reserved); auto cq_type = grpc_get_cq_completion_type(cq); if (cq_type != GRPC_CQ_NEXT && cq_type != GRPC_CQ_CALLBACK) { gpr_log(GPR_INFO, "Completion queue of type %d is being registered as a " "server-completion-queue", static_cast<int>(cq_type)); /* Ideally we should log an error and abort but ruby-wrapped-language API calls grpc_completion_queue_pluck() on server completion queues */ } server->core_server->RegisterCompletionQueue(cq); } void* grpc_server_register_method( grpc_server* server, const char* method, const char* host, grpc_server_register_method_payload_handling payload_handling, uint32_t flags) { GRPC_API_TRACE( "grpc_server_register_method(server=%p, method=%s, host=%s, " "flags=0x%08x)", 4, (server, method, host, flags)); return server->core_server->RegisterMethod(method, host, payload_handling, flags); } void grpc_server_start(grpc_server* server) { grpc_core::ExecCtx exec_ctx; GRPC_API_TRACE("grpc_server_start(server=%p)", 1, (server)); server->core_server->Start(); } void grpc_server_shutdown_and_notify(grpc_server* server, grpc_completion_queue* cq, void* tag) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; GRPC_API_TRACE("grpc_server_shutdown_and_notify(server=%p, cq=%p, tag=%p)", 3, (server, cq, tag)); server->core_server->ShutdownAndNotify(cq, tag); } void grpc_server_cancel_all_calls(grpc_server* server) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; GRPC_API_TRACE("grpc_server_cancel_all_calls(server=%p)", 1, (server)); server->core_server->CancelAllCalls(); } void grpc_server_destroy(grpc_server* server) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; GRPC_API_TRACE("grpc_server_destroy(server=%p)", 1, (server)); delete server; } grpc_call_error grpc_server_request_call( grpc_server* server, grpc_call** call, grpc_call_details* details, grpc_metadata_array* request_metadata, grpc_completion_queue* cq_bound_to_call, grpc_completion_queue* cq_for_notification, void* tag) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; GRPC_STATS_INC_SERVER_REQUESTED_CALLS(); GRPC_API_TRACE( "grpc_server_request_call(" "server=%p, call=%p, details=%p, initial_metadata=%p, " "cq_bound_to_call=%p, cq_for_notification=%p, tag=%p)", 7, (server, call, details, request_metadata, cq_bound_to_call, cq_for_notification, tag)); return server->core_server->RequestCall(call, details, request_metadata, cq_bound_to_call, cq_for_notification, tag); } grpc_call_error grpc_server_request_registered_call( grpc_server* server, void* rmp, grpc_call** call, gpr_timespec* deadline, grpc_metadata_array* request_metadata, grpc_byte_buffer** optional_payload, grpc_completion_queue* cq_bound_to_call, grpc_completion_queue* cq_for_notification, void* tag_new) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; GRPC_STATS_INC_SERVER_REQUESTED_CALLS(); auto* rm = static_cast<grpc_core::Server::RegisteredMethod*>(rmp); GRPC_API_TRACE( "grpc_server_request_registered_call(" "server=%p, rmp=%p, call=%p, deadline=%p, request_metadata=%p, " "optional_payload=%p, cq_bound_to_call=%p, cq_for_notification=%p, " "tag=%p)", 9, (server, rmp, call, deadline, request_metadata, optional_payload, cq_bound_to_call, cq_for_notification, tag_new)); return server->core_server->RequestRegisteredCall( rm, call, deadline, request_metadata, optional_payload, cq_bound_to_call, cq_for_notification, tag_new); }
[ "bryan.guner@gmail.com" ]
bryan.guner@gmail.com
cd115fd069c0c0bf6513204939062d1143998a79
67c856a66973b16ae8472b9f32223ed082f7c612
/boj/11727.cpp
c46b44cea4c8de71f8f0ef752d5105eeda02c736
[]
no_license
jin60641/acm
9d5739f6cb4e745766daa9a1a589482c2a546b61
b07c578f998816d60890d049da322e66f40f5928
refs/heads/master
2021-01-23T06:15:16.831142
2019-09-20T03:00:56
2019-09-20T03:00:56
86,347,575
0
0
null
null
null
null
UTF-8
C++
false
false
196
cpp
#include<stdio.h> int main(){ int N; int dp[1010]; scanf("%d",&N); dp[1] = 1; dp[2] = 3; for( int i = 3; i <= N; ++i ){ dp[i] = ( dp[i-1] + dp[i-2]*2 ) % 10007; } printf("%d",dp[N]); }
[ "jin60641@naver.com" ]
jin60641@naver.com
0d6af82b09184b3256ed1e2ce625650ae4a3deea
86c531e1156d302cfa1b5fa85cd138e08da2a7a2
/BEE.cpp
3d963f46ebac36b71969e27a6534ac745ed939c2
[]
no_license
phatbs21/Thuat-Toan
397faed3e8b2a51e7a982dc4278362396a48335c
684d30243be100ef558e252277e28c16e8bcf884
refs/heads/main
2023-08-30T20:43:36.115540
2021-09-01T15:55:21
2021-09-01T15:55:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
538
cpp
#include <bits/stdc++.h> #define nmod 1000000000 using namespace std; long n,dx[10]={1,1,0,-1,-1,0},dy[10]={0,-1,-1,0,1,1}; long long f[57][107][107]; int main() { ios_base::sync_with_stdio(0); freopen("BEE.inp","r",stdin); freopen("BEE.out","w",stdout); cin >> n; f[0][51][51]=1; for (long k=1; k<=n; k++) for (long i=1; i<=100; i++) for (long j=1; j<=100; j++) for (long x=0; x<=5; x++) f[k][i][j]=(f[k][i][j]+f[k-1][i+dx[x]][j+dy[x]]) % nmod; cout << f[n][51][51]; }
[ "53256916+phatbs21@users.noreply.github.com" ]
53256916+phatbs21@users.noreply.github.com
44a0228122d5e2078b6d9264853079cb48bf031e
2fe081a3db8c374461d942d954a5bdf11500fd64
/3667_17034420_AC_1016MS_3436K.cc
41d9ec367c5da8ec1fc1d499c0b7b6519ab845d8
[]
no_license
zhaofeng37/POJ
4946a864658628f7bec723173357533c74f870e0
ec361f5d32e258677530a1f92493226e413ceaec
refs/heads/master
2020-03-29T13:22:12.338841
2019-07-18T03:23:59
2019-07-18T03:23:59
149,955,032
0
0
null
null
null
null
UTF-8
C++
false
false
4,382
cc
// POJ 3667 http://poj.org/problem?id=3667 /** 1. Traditional Segment Tree Problem 2. segNode has 6 components. - 2.1 l is the left postion of this segment r is the right position of this segment [l...r] is closed interval - 2.2 tl is the total empty room length under this segment node. - 2.3 ll is the maximal empty room length start at the leftmost postion - 2.4 rl is the maximal empty room length end at the leftmost postion - 2.5 m has 3 status. * -1 means lazy flag is clear. No need to descend flag to children segNode. * 0 means room is empty. * 1 means room is ouccupied * Descend the flag 0 and/or 1 in query&update method 3. build the binary segment tree and fill the content of the segNode recursively. The initial m in the segNode is 0 which referred to every room is available. 4. query is a recursive method. The core thinking is descend the m in root segNode to the left and right children and then update them. - 4.1 the total empty room count is equal and more than request call query recursivly to find the precision position - 4.2 the summary of rightmost empty room in left child and leftmost empty room in right child is equal and more than request, we find the precision position which is the start of the leftmost in left child. - 4.3 there is no empty room in hotel now if the upper 3 cases can NOT staisfy the conditions. 5. It is as less as the algorithm need to try to update the segNode ll, tl, rl and descend the m in the same time. - 5.1 one segNode has only one m status. This implys that m will be set to 1 if all room occupied in this node, in contrast m would be 0 if all room empty. Otherwise -1 will be found in m. - 5.2 compare to the thinking of the segment tree, the principle of update ll, tl, rl is much easier, see the code */ #include <stdio.h> #include <algorithm> #define N 50008 #define LC(a) (a << 1) #define RC(a) (a << 1 | 1) // [1...X] 闭闭区间 struct segNode { int l, r, m, tl, ll, rl; int mid() { return (l + r) >> 1; } int len() { return r - l + 1; } void update() { tl = ll = rl = (m ? 0 : r - l + 1); } } sn[N * 4]; void build(int rt, int l, int r) { sn[rt].l = l; sn[rt].r = r; sn[rt].m = 0; sn[rt].ll = sn[rt].rl = sn[rt].tl = sn[rt].len(); if (l == r) return; int mid = sn[rt].mid(); build(LC(rt), l, mid); build(RC(rt), mid + 1, r); } int query(int rt, int w) { if (sn[rt].l == sn[rt].r && 1 == w) return sn[rt].l; if (-1 != sn[rt].m) { sn[LC(rt)].m = sn[RC(rt)].m = sn[rt].m; sn[rt].m = -1; sn[LC(rt)].update(); sn[RC(rt)].update(); } if (sn[LC(rt)].tl >= w) return query(LC(rt), w); if (sn[LC(rt)].rl + sn[RC(rt)].ll >= w) return sn[LC(rt)].r - sn[LC(rt)].rl + 1; if (sn[RC(rt)].tl >= w) return query(RC(rt), w); return 0; } void update(int l, int r, int m, int rt) { if (l == sn[rt].l && r == sn[rt].r) { sn[rt].m = m; sn[rt].update(); return; } if (-1 != sn[rt].m) { sn[LC(rt)].m = sn[RC(rt)].m = sn[rt].m; sn[rt].m = -1; sn[LC(rt)].update(); sn[RC(rt)].update(); } int mid = sn[rt].mid(); if (l > mid) update(l, r, m, RC(rt)); else if (r <= mid) update(l, r, m, LC(rt)); else { update(l, mid, m, LC(rt)); update(mid + 1, r, m, RC(rt)); } sn[rt].tl = std::max(sn[LC(rt)].tl, sn[RC(rt)].tl); sn[rt].tl = std::max(sn[rt].tl, (sn[LC(rt)].rl + sn[RC(rt)].ll)); if (sn[LC(rt)].len() > sn[LC(rt)].ll) sn[rt].ll = sn[LC(rt)].ll; else sn[rt].ll = sn[LC(rt)].ll + sn[RC(rt)].ll; if (sn[RC(rt)].len() > sn[RC(rt)].rl) sn[rt].rl = sn[RC(rt)].rl; else sn[rt].rl = sn[LC(rt)].rl + sn[RC(rt)].rl; } int main() { int l, r, c, w, idx, io; while (~scanf("%d %d", &r, &c)) { build(1, 1, r); while (c--) { scanf("%d", &io); if (1 == io) { // ci scanf("%d", &w); idx = query(1, w); printf("%d\n", idx); if (idx) update(idx, idx + w - 1, 1, 1); } else { // co scanf("%d %d", &l, &w); update(l, l + w - 1, 0, 1); } } } return 0; }
[ "zhao.f@hotmail.com" ]
zhao.f@hotmail.com
79ddc1b646b4e58826462325b6a64f72cfccc79f
505357c0375dd10f43fdaff7413a07b054797bf5
/DllMssr/DllMssr/commFunc.cpp
f7bcaa0bbcaa06ffb7af356ee9ffa2f9ca7f02d4
[]
no_license
yinxsdawn/-
a1d899ee151aaa1c39891da02a4bfe2858b72701
9dfec348972ebeb617bf5ff1da7db13e2c9a04a8
refs/heads/master
2020-03-27T21:55:30.275214
2018-09-03T10:16:05
2018-09-03T10:16:05
147,187,344
1
0
null
null
null
null
GB18030
C++
false
false
1,485
cpp
/////////////////////////// // by art ////////////////////////// #include "StdAfx.h" #include "commFunc.h" //UTF-8转换到GB3212 string U2G(const char* utf8) { int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0); wchar_t* wstr = new wchar_t[len+1]; memset(wstr, 0, len+1); MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wstr, len); len = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL); char* str = new char[len+1]; memset(str, 0, len+1); WideCharToMultiByte(CP_ACP, 0, wstr, -1, str, len, NULL, NULL); if(wstr) delete[] wstr; string strRet = str; delete []str; return strRet; } //GB2312到UTF-8的转换 string G2U(const char* gb2312) { int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0); wchar_t* wstr = new wchar_t[len+1]; memset(wstr, 0, len+1); MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len); len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL); char* str = new char[len+1]; memset(str, 0, len+1); WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL); if(wstr) delete[] wstr; string strRet = str; delete []str; return strRet; } string GetModuleFilePath() { char szFilePath[MAX_PATH]={0}; string sModuleFilePath; GetModuleFileName(NULL, szFilePath, MAX_PATH); if(szFilePath != NULL) { sModuleFilePath=szFilePath; int nPos=sModuleFilePath.find_last_of('\\'); sModuleFilePath = sModuleFilePath.substr(0, nPos); } else { sModuleFilePath = ""; } return sModuleFilePath; }
[ "yxshuang@workway.com.cn" ]
yxshuang@workway.com.cn
b4a87dbac40c940712515f093df89ffb440f4967
298ad4ba059eb16a2da1d4a4a998b72af209c212
/is_detected.hpp
47a5ff27f05e40b85445087c68a23f6a7ef82240
[]
no_license
jaredhoberock/pointer_adaptor
e9bf072feb61569b739b0422e8f7179ed1f1aac5
4c2472b74d4bab18e0e4d6e1d2e529c0a4f4d793
refs/heads/master
2021-09-19T11:51:59.029603
2018-07-27T19:46:30
2018-07-27T19:46:30
106,730,029
1
1
null
null
null
null
UTF-8
C++
false
false
3,377
hpp
// Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include <type_traits> template<class...> using void_t = void; struct nonesuch { nonesuch() = delete; ~nonesuch() = delete; nonesuch(const nonesuch&) = delete; void operator=(const nonesuch&) = delete; }; template<class Default, class AlwaysVoid, template<class...> class Op, class... Args> struct detector { using value_t = std::false_type; using type = Default; }; template<class Default, template<class...> class Op, class... Args> struct detector<Default, void_t<Op<Args...>>, Op, Args...> { using value_t = std::true_type; using type = Op<Args...>; }; template<template<class...> class Op, class... Args> using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t; template<template<class...> class Op, class... Args> using detected_t = typename detector<nonesuch, void, Op, Args...>::type; template<class Default, template<class...> class Op, class... Args> using detected_or = detector<Default, void, Op, Args...>; template<class Default, template<class...> class Op, class... Args> using detected_or_t = typename detected_or<Default,Op,Args...>::type; template<class Expected, template<class...> class Op, class... Args> using is_detected_exact = std::is_same<Expected, detected_t<Op,Args...>>; template<class To, template<class...> class Op, class... Args> using is_detected_convertible = std::is_convertible<detected_t<Op, Args...>, To>; #if defined(__cpp_variable_templates) template<class Expected, template<class...> class Op, class... Args> constexpr bool is_detected_exact_v = is_detected_exact<Expected, Op, Args...>::value; template<class To, template<class...> class Op, class... Args> constexpr bool is_detected_convertible_v = is_detected_convertible<To, Op, Args...>::value; #endif
[ "jaredhoberock@gmail.com" ]
jaredhoberock@gmail.com
d1205b042260b0857cd53485e349c22feab63980
22e7f4cb1950ac8fcf9cf0a69701edf78d15af4b
/src/isle/cpp/bind/integrator.cpp
40acde69a8d8b4a1d90af3fffcede631aa176e3b
[ "MIT" ]
permissive
sunatthegilddotcom/isle
fa4c333051f017414db3f9a21951f30a5fcb81f7
cabb136737c258146882a87e79dedcba4b850108
refs/heads/master
2023-03-28T10:18:32.509960
2020-05-19T18:15:59
2020-05-19T18:15:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
785
cpp
#include "integrator.hpp" #include "../integrator.hpp" using namespace pybind11::literals; using namespace isle; namespace bind { void bindIntegrators(py::module &mod) { mod.def("leapfrog", leapfrog, "phi"_a, "pi"_a, "action"_a, "length"_a, "nsteps"_a, "direction"_a=+1); mod.def("rungeKutta4Flow", rungeKutta4Flow, "phi"_a, "action"_a, "length"_a, "stepSize"_a, "actVal"_a=std::complex<double>(std::nan(""), std::nan("")), "n"_a=0, "direction"_a=+1, "adaptAttenuation"_a=0.9, "adaptThreshold"_a=1.0e-12, "minStepSize"_a=std::nan(""), "imActTolerance"_a=0.001); } }
[ "j-l.wynen@hotmail.de" ]
j-l.wynen@hotmail.de
7b5371f8dcd3d173cc38e48a996572045d003a47
90f84d39df7c2d58a7084fd46e4e4c39d16adfe6
/apps/samples/shaperectst/shaperectst.cpp
723cef2d0b4b8c7e10e32045545fb4dfde19f447
[]
no_license
amitdo/Lipitk
08c3c1848998fba7b5a94ef9a39775f628961328
23d51c3bc0505c35511e8fc8e91af455b9342461
refs/heads/master
2021-01-16T22:50:20.018371
2011-11-08T18:31:04
2011-11-08T18:31:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,363
cpp
/***************************************************************************************** * Copyright (c) 2006 Hewlett-Packard Development Company, L.P. * 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. *****************************************************************************************/ /************************************************************************ * SVN MACROS * * $LastChangedDate: 2008-07-18 15:00:39 +0530 (Fri, 18 Jul 2008) $ * $Revision: 561 $ * $Author: sharmnid $ * ************************************************************************/ /************************************************************************ * FILE DESCR: Sample test application for Shape Recognition * * CONTENTS: * main * * CHANGE HISTORY: * Author Date Description of change ************************************************************************/ #include "shaperectst.h" #include "LTKLoggerUtil.h" #include "LTKErrors.h" #include "LTKOSUtilFactory.h" #include "LTKOSUtil.h" char strLogFile[MAX_PATH] = "shaperectst.log"; string strLogFileName; LTKOSUtil* utilPtr = LTKOSUtilFactory::getInstance(); int main(int argc, char** argv) { char *envstring = NULL; int iResult; // first argument is the logical project name and the // second argument is the ink file to recognize if(argc < 3) { cout << endl << "Usage:"; cout << endl << "shaperectst <logical projectname> <ink file to recognize>"; cout << endl; delete utilPtr; return -1; } //Get the LIPI_ROOT environment variable envstring = getenv(LIPIROOT_ENV_STRING); if(envstring == NULL) { cout << endl << "Error, Environment variable is not set LIPI_ROOT" << endl; delete utilPtr; return -1; } //Load the LipiEngine.DLL hLipiEngine = NULL; iResult = utilPtr->loadSharedLib(envstring, LIPIENGINE_MODULE_STR, &hLipiEngine); if(iResult != SUCCESS) { cout << "Error loading LipiEngine module" << endl; delete utilPtr; return -1; } if(MapFunctions() != 0) { cout << "Error fetching exported functions of the module" << endl; delete utilPtr; return -1; } //create an instance of LipiEngine Module ptrObj = createLTKLipiEngine(); // set the LIPI_ROOT path in Lipiengine module instance ptrObj->setLipiRootPath(envstring); //Initialize the LipiEngine module iResult = ptrObj->initializeLipiEngine(); if(iResult != SUCCESS) { cout << iResult <<": Error initializing LipiEngine." << endl; utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return -1; } //Assign the logical name of the project to this string, i.e. TAMIL_CHAR //(or) "HINDI_GESTURES" string strLogicalName = string(argv[1]); string strProfName; LTKShapeRecognizer *pShapeReco = NULL; ptrObj->createShapeRecognizer(strLogicalName,strProfName, &pShapeReco); if(pShapeReco == NULL) { cout << endl << "Error creating Shape Recognizer" << endl; //cout << getError(ptrObj->getLastError()) << endl; utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return -1; } //You can also use project and profile name to create LipiEngine instance as follows... //string strProjectName = "hindi_gestures"; //string strProfileName = "default"; //LTKShapeRecognizer *pReco = ptrObj->createShapeRecognizer(&strProjectName, &strProfileName); //Load the model data into memory before starting the recognition... iResult = pShapeReco->loadModelData(); if(iResult != SUCCESS) { cout << endl << iResult << ": Error loading Model data." << endl; // cout << getError(pShapeReco->getLastError()) << endl; ptrObj->deleteShapeRecognizer(&pShapeReco); utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return -1; } //Declare variables to be used for recognition... LTKCaptureDevice captureDevice; LTKScreenContext screenContext; //vector<bool> shapeSubset; vector<int> shapeSubset; int numChoices = 2; float confThreshold = 0.0f; vector<LTKShapeRecoResult> results; LTKTraceGroup inTraceGroup; // You can directly read the UNIPEN ink file which has all the // device context, screen context and ink information and pass it to // recognize function. Or you can create your own LTKTrace and populate // device and screen information as in commented code below. //Read the ink to be recognized from the file... string path(argv[2]); LTKInkFileReader::readUnipenInkFile(path, inTraceGroup, captureDevice, screenContext); // Set device context information to pass onto the recognizer // Uncomment and pass proper values here... //captureDevice.setSamplingRate(<float value>); //captureDevice.setXDPI(<float value>); //captureDevice.setYDPI(<float value>); //captureDevice.setLatency(<float value>); //captureDevice.setUniformSampling(<true or false>); // Set the device context, once before starting the recognition... pShapeReco->setDeviceContext(captureDevice); results.reserve(numChoices); // Uncomment and edit the following lines to pass ink from the pen device // to recognize function. // The functions should copy the values from your local ink & screen // structures into inTraceGroup and screenContext variables. // CopyToTraceGroup(inTraceGroup, <your ink structure>); // CopyScreenContext(screenContext, <your screen info>); //now call the "recognize" method iResult = pShapeReco->recognize(inTraceGroup, screenContext, shapeSubset, confThreshold, numChoices, results); if(iResult != SUCCESS) { cout << iResult << ": Error while recognizing." << endl; //cout << getError(pShapeReco->getLastError()) << endl; ptrObj->deleteShapeRecognizer(&pShapeReco); utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return -1; } cout << endl << "Input Logical project name = " << strLogicalName << endl; cout << endl << "Input ink file for recognition = " << path << endl; cout << endl << "Recognition Results" << endl; //Display the recognized results... for(int index =0; index < results.size(); ++index) { cout << endl << "Choice[" << index << "] " << "Recognized Shapeid = " << results[index].getShapeId() << " Confidence = " << results[index].getConfidence() << endl; } //Delete the shape recognizer object ptrObj->deleteShapeRecognizer(&pShapeReco); //unload the LipiEngine module from memory... utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return 0; } /********************************************************************************** * NAME : MapFunctions * DESCRIPTION : This method fetches the address of the exported function of * lipiengine module * ARGUMENTS : * RETURNS : 0 on success, -1 on Failure. * NOTES : * CHANGE HISTROY * Author Date Description of change * *************************************************************************************/ int MapFunctions() { createLTKLipiEngine = NULL; void* functionHandle = NULL; int iErrorCode = utilPtr->getFunctionAddress(hLipiEngine, "createLTKLipiEngine", &functionHandle); createLTKLipiEngine = (FN_PTR_CREATELTKLIPIENGINE)functionHandle; if(iErrorCode != SUCCESS) { cout << "Error mapping the createLTKLipiEngine function" << endl; return -1; } return 0; }
[ "anirudhsharma.crypto@gmail.com" ]
anirudhsharma.crypto@gmail.com
28057ac40d4eefe9bc0490a420c03b37fafcc951
5aa0c66bdf5166313f78bc6699c9667e6c9d45a9
/KPZ_LAB2/EmployeeDB/Employee.cpp
45755844d764d745c84ce6b3d02d1b692c513414
[]
no_license
katin-acts1/KPZ_LAB2
a325dca4664853eecb5f5b0f510f3e7f5a080fa4
f9215d67d4a707474a391bc597e0a64121d05206
refs/heads/master
2021-01-10T09:39:44.708095
2016-02-22T17:04:02
2016-02-22T17:04:02
52,289,870
1
0
null
null
null
null
UTF-8
C++
false
false
1,659
cpp
// Employee.cpp #include <iostream> #include "Employee.h" using namespace std; namespace Records { Employee::Employee() : mFirstName("") , mLastName("") , mEmployeeNumber(-1) , mSalary(kDefaultStartingSalary) , bHired(false) { } void Employee::promote(int inRaiseAmount) { setSalary(getSalary() + inRaiseAmount); } void Employee::demote(int inDemeritAmount) { setSalary(getSalary() - inDemeritAmount); } void Employee::hire() { bHired = true; } void Employee::fire() { bHired = false; } void Employee::display() const { cout << "Employee: " << getLastName() << ", " << getFirstName() << endl; cout << "-------------------------" << endl; cout << (bHired ? "Current Employee" : "Former Employee") << endl; cout << "Employee Number: " << getEmployeeNumber() << endl; cout << "Salary: $" << getSalary() << endl; cout << endl; } // Accessors and setters void Employee::setFirstName(string inFirstName) { mFirstName = inFirstName; } string Employee::getFirstName() const { return mFirstName; } void Employee::setLastName(string inLastName) { mLastName = inLastName; } string Employee::getLastName() const { return mLastName; } void Employee::setEmployeeNumber(int inEmployeeNumber) { mEmployeeNumber = inEmployeeNumber; } int Employee::getEmployeeNumber() const { return mEmployeeNumber; } void Employee::setSalary(int inSalary) { mSalary = inSalary; } int Employee::getSalary() const { return mSalary; } bool Employee::getIsHired() const { return bHired; } }
[ "kodinp@gmail.com" ]
kodinp@gmail.com
a85b80e041706e26d32620de3f831abf5adb0982
097ac82e76553bbb6dd2ce830bda68549210ca07
/shixun3/Examples/weak_ptr.cpp
c7354859d6a5e126b8d514758418ffa66dbd85a5
[]
no_license
katarXu/compile_lab
c385bdaaee99591b64e0381d0a3445c5fb894226
e2ebaa361ca9b41aa463c8dbb0d0064f792b7238
refs/heads/master
2023-07-17T18:30:25.254762
2021-09-09T01:43:33
2021-09-09T01:43:33
404,549,077
0
0
null
null
null
null
UTF-8
C++
false
false
941
cpp
#include<iostream> #include<memory> using namespace std; template <typename T> class B; class A { public: shared_ptr<B<A>> pb_; ~A() { cout<<"A delete\n"; } }; class A1 { public: weak_ptr<B<A1>> pb_; ~A1() { cout<<"A1 delete\n"; } }; template <typename T> class B { public: shared_ptr<T> pa_; ~B() { cout<<"B delete\n"; } }; void fun() { shared_ptr<B<A>> pb(new B<A>()); shared_ptr<A> pa(new A()); pb->pa_ = pa; pa->pb_ = pb; cout<<"fun : "<<pb.use_count()<<endl; cout<<"fun : "<<pa.use_count()<<endl; // 这个函数执行完会出现相互引用导致的内存泄漏 } void fun1() { shared_ptr<B<A1>> pb(new B<A1>()); shared_ptr<A1> pa(new A1()); pb->pa_ = pa; pa->pb_ = pb; cout<<"fun1 : "<<pb.use_count()<<endl; cout<<"fun1 : "<<pa.use_count()<<endl; } int main() { fun(); fun1(); return 0; }
[ "xujh2649@outlook.com" ]
xujh2649@outlook.com
6bdda692fe4ed35eb8ae591a7ab8760cc168c343
720d01dc22de521e42b5ef71c91fb415b1457f04
/code/data_movement_ex.cpp
c523f409750468824d007156fef6fa36039199fd
[ "Apache-2.0" ]
permissive
sherry-1001/oneAPI_course
e7eea7f2da8d2331a9ae6c77cb3f4d61f771946b
b1b815a41839c2eaa2fb8f598fe05324f1e2f315
refs/heads/main
2023-08-20T15:24:01.946713
2021-10-28T07:00:50
2021-10-28T07:00:50
422,099,830
1
0
null
null
null
null
UTF-8
C++
false
false
1,081
cpp
// Patric Zhao: patric.zhao@intel.com #include <CL/sycl.hpp> #include <iostream> using namespace sycl; constexpr int N = 10; int main() { queue my_gpu_queue( gpu_selector{} ); std::cout << "Selected GPU device: " << my_gpu_queue.get_device().get_info<info::device::name>() << "\n"; int *host_mem = malloc_host<int>(N, my_gpu_queue); int *device_mem = malloc_device<int>(N, my_gpu_queue); // Init CPU data for(int i = 0; i < N; i++) { host_mem[i] = i; } // Copy from host(CPU) to device(GPU) my_gpu_queue.memcpy(device_mem, host_mem, N * sizeof(int)).wait(); // do some works on GPU // ...... // // Copy back from GPU to CPU my_gpu_queue.memcpy(host_mem, device_mem, N * sizeof(int)).wait(); printf("\nData Result\n"); for(int i = 0; i < N; i++) { printf("%d, ", host_mem[i]); } printf("\nTask Done!\n"); free(host_mem, my_gpu_queue); free(device_mem, my_gpu_queue); return 0; }
[ "noreply@github.com" ]
sherry-1001.noreply@github.com
32462f342ac7e224db03e1b709c38c3694f22038
5cb7861cf5787dec2ff4bb0d5f2f96803e4b7ede
/tensorflow/core/tfrt/runtime/tf_threadpool_concurrent_work_queue.cc
e6ad2dc1682a8b02964f464f8a9bd84def04fdd5
[ "Apache-2.0", "MIT", "BSD-2-Clause" ]
permissive
VeriSilicon/tensorflow
c94887193d562c9d320b5c56d476629682c4ce58
2a1fa53a7c3a06eedec16b8aa751fb7deba8f4c5
refs/heads/xla_npu_v270
2022-06-02T16:53:51.549104
2022-04-18T10:19:46
2022-04-18T10:19:46
93,762,772
4
29
Apache-2.0
2022-04-18T10:19:47
2017-06-08T15:05:39
C++
UTF-8
C++
false
false
2,859
cc
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/core/tfrt/runtime/tf_threadpool_concurrent_work_queue.h" #include <assert.h> #include <utility> #include "llvm/ADT/None.h" #include "tensorflow/core/platform/status.h" #include "tensorflow/core/platform/threadpool_interface.h" #include "tfrt/host_context/async_value.h" // from @tf_runtime #include "tfrt/host_context/execution_context.h" // from @tf_runtime #include "tfrt/host_context/task_function.h" // from @tf_runtime #include "tfrt/support/forward_decls.h" // from @tf_runtime #include "tfrt/support/latch.h" // from @tf_runtime namespace tensorflow { namespace tfrt_stub { using ::tensorflow::thread::ThreadPoolInterface; tensorflow::Status TfThreadPoolWorkQueue::InitializeRequest( ::tfrt::RequestContextBuilder* request_context_builder, ThreadPoolInterface** intra_op_threadpool) const { DCHECK(intra_op_threadpool); *intra_op_threadpool = intra_op_threadpool_; return tensorflow::Status::OK(); } void TfThreadPoolWorkQueue::AddTask(tfrt::TaskFunction work) { auto* copy = new tfrt::TaskFunction(std::move(work)); inter_op_threadpool_->Schedule([copy] { (*copy)(); delete copy; }); } llvm::Optional<tfrt::TaskFunction> TfThreadPoolWorkQueue::AddBlockingTask( tfrt::TaskFunction work, bool allow_queuing) { AddTask(std::move(work)); return llvm::None; } void TfThreadPoolWorkQueue::Quiesce() { // TODO(b/186668821): implement this CHECK(false); // Crash OK } // From // third_party/tensorflow/core/tfrt/run_handler_thread_pool/run_handler_concurrent_work_queue.cc void TfThreadPoolWorkQueue::Await( tfrt::ArrayRef<tfrt::RCReference<tfrt::AsyncValue>> values) { // We are done when values_remaining drops to zero. tfrt::latch values_remaining(values.size()); // As each value becomes available, we decrement the count. for (auto& value : values) { value->AndThen([&values_remaining]() { values_remaining.count_down(); }); } // Wait until all values are resolved. values_remaining.wait(); } bool TfThreadPoolWorkQueue::IsInWorkerThread() const { // TODO(b/192247530): Check if we have cases it is not true. return true; } } // namespace tfrt_stub } // namespace tensorflow
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
e08e2a5ea638b08a32052e668a2c0f139806f098
ac4ca0a2c6b41832a84853c58c619940e15ed779
/test/marnav/ais/Test_ais_message_23.cpp
f4c7fb9527a5cbb426a50afee22e436174f17f44
[ "BSD-3-Clause", "BSD-4-Clause" ]
permissive
mariokonrad/marnav
12c2fff7117dfee356b8318e8e964ee8d6e81459
01c55205736fcc8157891b84e3efe387a221ff3a
refs/heads/master
2023-06-08T13:53:39.701103
2023-04-28T15:15:06
2023-05-04T15:50:15
37,308,245
84
48
NOASSERTION
2023-06-05T14:16:36
2015-06-12T07:26:41
C++
UTF-8
C++
false
false
808
cpp
#include <marnav/ais/message_23.hpp> #include <marnav/ais/ais.hpp> #include <gtest/gtest.h> namespace { using namespace marnav; class test_ais_message_23 : public ::testing::Test { }; TEST_F(test_ais_message_23, parse) { static const std::vector<std::vector<std::pair<std::string, uint32_t>>> TESTS = { {{"G00000000000000000000000000", 2}}, }; for (const auto & test : TESTS) { auto result = ais::make_message(test); EXPECT_TRUE(result != nullptr); if (result) { auto m = ais::message_cast<ais::message_23>(result); EXPECT_TRUE(m != nullptr); } } } TEST_F(test_ais_message_23, encode_default_values) { ais::message_23 m; auto v = ais::encode_message(m); ASSERT_EQ(1u, v.size()); EXPECT_STREQ("G000001b3Qba3D73EB000000000", v[0].first.c_str()); EXPECT_EQ(2u, v[0].second); } }
[ "mario.konrad@gmx.net" ]
mario.konrad@gmx.net
1cd6b374b3ca2b633de3ecfb06f8ef343612fdbb
dfb7297f114bbff7a89fea86cb9b8e0e16243d01
/PAT/PAT/1042.cpp
2e85b0a909f2f4d654412cc4e0d0608115d99c4f
[]
no_license
rainingapple/algorithm-competition-code
c06bd549d44e14c64e808d7026a0204d285f1fb3
809bff5cdf092568de47def7d24d36edef8d0c1e
refs/heads/main
2023-03-30T13:11:23.359366
2021-04-09T01:29:18
2021-04-09T01:29:18
343,407,072
0
0
null
null
null
null
UTF-8
C++
false
false
787
cpp
//#include<iostream> //using namespace std; //int* A = new int[60]; //int* B = new int[60]; //int order[60]; //string temp[4] = { "S","H","C","D" }; //void fuc(int x) { // if (x <= 52) { // cout << temp[(x-1) / 13]; // if (x % 13 != 0) // cout << x % 13; // else // cout << 13; // } // else if (x == 53) { // cout << "J1"; // } // else { // cout << "J2"; // } //} //int main() { // int n; // cin >> n; // for (int i = 1;i <= 54;i++) { // A[i] = i; // } // for (int i = 1;i <= 54;i++) { // cin >> order[i]; // } // for (int k = 0;k < n;k++) { // for (int i = 1;i <= 54;i++) { // B[order[i]] = A[i]; // } // swap(A, B); // } // for (int i = 1;i <= 54;i++) { // fuc(A[i]); // if (i != 54) // cout << " "; // } // return 0; //}
[ "825140645@qq.com" ]
825140645@qq.com
3369a85fb336b3edba59b6177ef7fc0368d5d98d
6373e3249d0bb1c03cef21c8e7be4636907c63f5
/Compiler/Compiler/main.cpp
987a9aba84308e03b103a172bc8186db04bc555f
[]
no_license
MaxKang1995/Compiler
395cc63c2238a1c867612fae215bcbe601bdcf50
f422da225efbe9b783a88a3a1a371548bc0cf506
refs/heads/master
2021-08-19T16:37:29.791482
2017-11-27T00:00:45
2017-11-27T00:00:45
112,126,738
0
0
null
null
null
null
UTF-8
C++
false
false
270
cpp
#include "Parser.h" #include <string> #include <iostream> using namespace std; int main() { string s; cout << "Input test file path:"; getline(cin, s); parser(s); //parser("sample.txt"); //parser("source.txt"); system("pause"); }
[ "noreply@github.com" ]
MaxKang1995.noreply@github.com
7b77e84836789959a79283a992ec24e3cf387af8
51a0ef26647df5c27226ecd4eb45a35a8a023968
/lecture4/vector1.cpp
00a5d908fa57499da94b6453fce4fb36f5b52912
[]
no_license
jha-prachi/dsa
c1855e203f76f9788c17499fe2524b90b9f83488
14781792a41020d07ac7a32511addd4813e8e3d6
refs/heads/master
2022-12-29T02:18:22.573415
2020-10-16T18:20:17
2020-10-16T18:20:17
213,044,139
0
1
null
2020-10-16T18:20:19
2019-10-05T17:43:28
C++
UTF-8
C++
false
false
676
cpp
#include<iostream> //#include<vector> using namespace std; // void display(vector<int>&arr){ // for(int i=0;i<arr.size();i++) // cout<<arr[i]; // } // int main(int args,char**argv){ // cout<<"enter your array size : "; // int n; // cin>>n; // vector<int>arr(n,0); // cout<<"enter your array element : "; // for(int i=0;i<arr.size();i++){ // cin>>arr[i]; // } // display(arr); // } // Another Method to travesrse the array int main() { int arr[5]={10, 0, 20, 0, 30}; //creating and initializing array //traversing array for (int i: arr) { cout<<i<<"\n"; } }
[ "prachi.princy97@gmail.com" ]
prachi.princy97@gmail.com
e0f8c265c91b0505425f102ffe489366f3f92309
f1bd4d38d8a279163f472784c1ead12920b70be2
/xr_3da/IGame_Persistent.h
f6f6d4cd382c3074e557661417043a8d873ed067
[]
no_license
YURSHAT/stk_2005
49613f4e4a9488ae5e3fd99d2b60fd9c6aca2c83
b68bbf136688d57740fd9779423459ef5cbfbdbb
refs/heads/master
2023-04-05T16:08:44.658227
2021-04-18T09:08:18
2021-04-18T18:35:59
361,129,668
1
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,432
h
#ifndef IGame_PersistentH #define IGame_PersistentH #pragma once #include "Environment.h" #ifndef _EDITOR #include "IGame_ObjectPool.h" #endif class IMainUI; class ENGINE_API CPS_Instance; //----------------------------------------------------------------------------------------------------------- class ENGINE_API IGame_Persistent : #ifndef _EDITOR public DLL_Pure, #endif public pureAppStart, public pureAppEnd, public pureAppActivate, public pureAppDeactivate, public pureFrame { public: union params { struct { string256 m_game_or_spawn; string256 m_game_type; string256 m_alife; string256 m_new_or_load; }; string256 m_params[4]; params () { reset(); } void reset () { for (int i=0; i<4; ++i) strcpy (m_params[i],""); } void parse_cmd_line (LPCSTR cmd_line) { reset (); int n = _min(4,_GetItemCount(cmd_line,'/')); for (int i=0; i<n; ++i) { _GetItem (cmd_line,i,m_params[i],'/'); strlwr (m_params[i]); } } }; params m_game_params; public: xr_set<CPS_Instance*> ps_active; xr_vector<CPS_Instance*> ps_destroy; xr_vector<CPS_Instance*> ps_needtoplay; public: void destroy_particles (const bool &all_particles); virtual void Start (LPCSTR op); virtual void Disconnect (); #ifndef _EDITOR IGame_ObjectPool ObjectPool; #endif IMainUI* m_pMainUI; CEnvironment Environment; BOOL bDedicatedServer ; virtual void OnAppStart (); virtual void OnAppEnd (); virtual void OnAppActivate (); virtual void OnAppDeactivate (); virtual void OnFrame (); // вызывается только когда изменяется тип игры virtual void OnGameStart (); virtual void OnGameEnd (); virtual void RegisterModel (IRender_Visual* V) #ifndef _EDITOR = 0; #else {} #endif virtual float MtlTransparent (u32 mtl_idx) #ifndef _EDITOR = 0; #else {return 1.f;} #endif IGame_Persistent (); virtual ~IGame_Persistent (); virtual u32 GameType () {return 0;}; virtual void Statistics (CGameFont* F) #ifndef _EDITOR = 0; #else {} #endif }; class IMainUI { public: virtual ~IMainUI () {}; virtual void Activate (bool bActive) =0; virtual bool IsActive () =0; }; extern ENGINE_API IGame_Persistent* g_pGamePersistent; #endif //IGame_PersistentH
[ "loxotron@bk.ru" ]
loxotron@bk.ru
20324331722ac6909a7a5da0863b1627dad6f701
aa55316c3d406418445d749215afcdd8f61b4c72
/demo/FaceDetect.cpp
6e62bf33e5e14aa160a53c051bf159dffb7d676a
[]
no_license
cyummy/Assessment-of-facal-skin-health
678dccdee35add147b6e39f5d9fa1122e80529a9
f193c6ae20a0e88c9aa14892e278dfce0fa74a37
refs/heads/master
2020-04-24T07:44:45.126710
2019-02-21T05:53:14
2019-02-21T05:53:14
171,807,923
8
0
null
null
null
null
GB18030
C++
false
false
32,835
cpp
// FaceDetect.cpp: implementation of the FaceDetect class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "demo1.h" #include "FaceDetect.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// FaceDetect::FaceDetect() { m_pImgDataOut=NULL;//输出图像位图数据指针为空 m_lpColorTableOut=NULL;//输出图像颜色表指针为空 m_nColorTableLengthOut=0;//输出图像颜色表长度为0 m_nBitCountOut=0;//输出图像每像素位数为0 m_imgWidthOut=0;//输出图像的宽为0 m_imgHeightOut=0;//输出图像的高为0 } FaceDetect::FaceDetect(CSize size, int nBitCount, LPRGBQUAD lpColorTable, unsigned char *pImgData1,unsigned char *pImgData2): ImageDib(size, nBitCount, lpColorTable, pImgData1) { m_pImgDataOut=NULL;//输出图像位图数据指针为空 m_lpColorTableOut=NULL;//输出图像颜色表指针为空 m_nColorTableLengthOut=0;//输出图像颜色表长度为0 m_nBitCountOut=0;//输出图像每像素位数为0 m_imgWidthOut=0;//输出图像的宽为0 m_imgHeightOut=0;//输出图像的高为0 m_pImgDataIn1=pImgData1;//m_pImgData; m_pImgDataIn2=pImgData2; //肤色模型参数定义 Cb_Mean=117.4361; //参数可调 根据不同的图像 Cr_Mean=156.5599; Cov00=160.1301; Cov01=12.1430; Cov10=12.1430; Cov11=299.4574; } FaceDetect::~FaceDetect() { } CSize FaceDetect::GetDimensions() { if(m_pImgDataOut == NULL) return CSize(0, 0); return CSize(m_imgWidthOut, m_imgHeightOut); } void FaceDetect::CalMedFl(double **s, int w, int h, int n) //中值滤波平滑 { int i,j; double **temp; temp = new double*[h+2*(int)(n/2)]; for(i=0;i<h+2*(int)(n/2);i++) temp[i] = new double[w+2*(int)(n/2)]; for(i=0;i<w+2*(int)(n/2);i++) for(j=0;j<h+2*(int)(n/2);j++) temp[j][i] = 0.0; for(i=0;i<h;i++) for(j=0;j<w;j++) temp[i+(int)(n/2)][j+(int)(n/2)]=s[i][j]; for(i=0;i<h;i++) for(j=0;j<w;j++) { s[i][j]=0.0; for(int r=0;r<n;r++) for(int c=0;c<n;c++) s[i][j]+=temp[i+r][j+c]; s[i][j]/=n*n; } if(temp!=NULL) { for(i=0;i<h+2;i++) if(temp[i]!=NULL) delete temp[i]; delete temp; } } /*********************************************************************** * 函数名称:CalSim() * 函数参数:无 * 返回值: 无 * 说明: 相似度计算 ***********************************************************************/ void FaceDetect::CalSim() { //若灰度图像,则返回 if(m_nBitCount==8) return; //释放旧的输出图像数据及颜色表缓冲区 if(m_pImgDataOut!=NULL){ delete []m_pImgDataOut; m_pImgDataOut=NULL; } if(m_lpColorTableOut!=NULL){ delete []m_lpColorTableOut; m_lpColorTableOut=NULL; } //灰值化后,每像素位数为8比特 m_nBitCountOut=8; //颜色表长度 m_nColorTableLengthOut=ComputeColorTabalLength(m_nBitCountOut); //申请颜色表缓冲区,生成灰度图像的颜色表 if(m_nColorTableLengthOut!=0){ m_lpColorTableOut=new RGBQUAD[m_nColorTableLengthOut]; for(int i=0; i<m_nColorTableLengthOut;i++){ m_lpColorTableOut[i].rgbBlue=i; m_lpColorTableOut[i].rgbGreen=i; m_lpColorTableOut[i].rgbRed=i; m_lpColorTableOut[i].rgbReserved=0; } } //输入图像每像素字节数,彩色图像为3字节/像素 int pixelByteIn=3; //输入图像每行像素所占字节数,必须是4的倍数 int lineByteIn=(m_imgWidth*pixelByteIn+3)/4*4; //输出图像的宽高,与输入图像相等 m_imgWidthOut=m_imgWidth; m_imgHeightOut=m_imgHeight; //输出图像每行像素所占字节数,必须是4的倍数 int lineByteOut=(m_imgWidth*m_nBitCountOut/8+3)/4*4; //申请输出图像位图数据缓冲区 m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeight]; //循环变量,图像的坐标 int i,j,k; char c_t1[4]; for(i=0;i<m_imgHeight;i++){ for(j=0;j<m_imgWidth;j++){ *(m_pImgDataOut+i*lineByteOut+j)=255; //全白 } } m_pSimArray = new double*[m_imgHeight]; for(i=0;i<m_imgHeight;i++) m_pSimArray[i] = new double[m_imgWidth]; for(i=0;i<m_imgHeight;i++){ for (j=0;j<m_imgWidth;j++){ for(k=0;k<3;k++){ c_t1[k]=*(m_pImgDataIn1+i*lineByteIn+j*pixelByteIn+k); } int C_b=(int)c_t1[0]&255; int C_g=(int)c_t1[1]&255; int C_r=(int)c_t1[2]&255; //从RGB色彩空间映射到YCbCr色彩空间 double Cb=(128-37.797*C_r/255-74.203*C_g/255+112*C_b/255); double Cr=(128+112*C_r/255-93.786*C_g/255-18.214*C_b/255); //利用肤色模型,求相似度矩阵 double tt =(Cb-Cb_Mean)*((Cb-Cb_Mean)*Cov11-(Cr-Cr_Mean)*Cov10)+(Cr-Cr_Mean)*(-(Cb-Cb_Mean)*Cov01+(Cr-Cr_Mean)*Cov00); tt =(-0.5*tt)/(Cov00*Cov11-Cov01*Cov10); m_pSimArray[i][j]=exp(tt); } } CalMedFl(m_pSimArray,m_imgWidth, m_imgHeight,9); //中值滤波 //用相似度矩阵中的最大值对相似度矩阵进行归一化 double max=0.0; for(i=0;i<m_imgHeight;i++){ for (j=0;j<m_imgWidth;j++){ if(m_pSimArray[i][j]>max) max=m_pSimArray[i][j]; } } for( i=0;i<m_imgHeight;i++){ for (j=0;j<m_imgWidth;j++){ m_pSimArray[i][j]= m_pSimArray[i][j]/max; } } for(i=0;i<m_imgHeight;i++){ for(j=0;j<m_imgWidth;j++){ *(m_pImgDataOut+i*lineByteOut+j)=(int)(m_pSimArray[i][j]*255); } } } /*********************************************************************** * 函数名称:CalSBound * 函数参数:int top,int bottom,int left,int right * 返回值: 无 * 说明: 脸内轮廓提取 ***********************************************************************/ void FaceDetect::CalSBound(int top,int bottom,int left,int right) { //若灰度图像,则返回 if(m_nBitCount==8) return; //释放旧的输出图像数据及颜色表缓冲区 if(m_pImgDataOut!=NULL){ delete []m_pImgDataOut; m_pImgDataOut=NULL; } if(m_lpColorTableOut!=NULL){ delete []m_lpColorTableOut; m_lpColorTableOut=NULL; } //灰值化后,每像素位数为8比特 m_nBitCountOut=8; //颜色表长度 m_nColorTableLengthOut=ComputeColorTabalLength(m_nBitCountOut); //申请颜色表缓冲区,生成灰度图像的颜色表 if(m_nColorTableLengthOut!=0){ m_lpColorTableOut=new RGBQUAD[m_nColorTableLengthOut]; for(int i=0; i<m_nColorTableLengthOut;i++){ m_lpColorTableOut[i].rgbBlue=i; m_lpColorTableOut[i].rgbGreen=i; m_lpColorTableOut[i].rgbRed=i; m_lpColorTableOut[i].rgbReserved=0; } } //输入图像每像素字节数,彩色图像为3字节/像素 int pixelByteIn=3; //输入图像每行像素所占字节数,必须是4的倍数 int lineByteIn=(m_imgWidth*pixelByteIn+3)/4*4; //输出图像的宽高,与输入图像相等 m_imgWidthOut=m_imgWidth; m_imgHeightOut=m_imgHeight; //输出图像每行像素所占字节数,必须是4的倍数 int lineByteOut=(m_imgWidth*m_nBitCountOut/8+3)/4*4; //申请输出图像位图数据缓冲区 m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeight]; //循环变量,图像的坐标 int i,j,l; double **result; result = new double*[m_imgHeight]; for(l=0 ; l<m_imgHeight; l++){ result[l] = new double[m_imgWidth]; for(j=0; j<m_imgWidth; j++) result[l][j] = *(m_pImgDataIn1+l*lineByteIn+j*pixelByteIn+2); } for(i=0; i<m_imgHeight; i++) for(j=0; j<m_imgWidth; j++){ double r,g,temp; //归一化 temp = *(m_pImgDataIn1+i*lineByteIn+j*pixelByteIn)+ *(m_pImgDataIn1+i*lineByteIn+j*pixelByteIn+1)+ *(m_pImgDataIn1+i*lineByteIn+j*pixelByteIn+2); r = (double)*(m_pImgDataIn1+i*lineByteIn+j*pixelByteIn+2)/temp; g = (double)*(m_pImgDataIn1+i*lineByteIn+j*pixelByteIn+1)/temp; //通过肤色检测脸的位置 if(g<0.398 && g > 0.246 && r<0.664 && r>0.233 && r>g && g>=0.5*(1-r)){ *(m_pImgDataOut+i*lineByteOut+j)=255; } else *(m_pImgDataOut+i*lineByteOut+j)=0; } //高斯 拉普拉斯边缘算子 for(i=top+2; i<bottom-2; i++) for(j=left+2; j<right-2; j++){ result[i][j] = (0-2.0/24.0)*((unsigned char)*(m_pImgDataOut+(i-2)*lineByteOut+j-2)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i-2)*lineByteOut+j-1)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i-2)*lineByteOut+j)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i-2)*lineByteOut+j+1)) + (0-2.0/24.0)*((unsigned char)*(m_pImgDataOut+(i-2)*lineByteOut+j+2)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i-1)*lineByteOut+j-2)) + (8.0/24.0) *((unsigned char)*(m_pImgDataOut+(i-1)*lineByteOut+j)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i-1)*lineByteOut+j+2)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+i*lineByteOut+j-2)) + (8.0/24.0) *((unsigned char)*(m_pImgDataOut+i*lineByteOut+j-1)) + (1.0) *((unsigned char)*(m_pImgDataOut+i*lineByteOut+j)) + (8.0/24.0) *((unsigned char)*(m_pImgDataOut+i*lineByteOut+j+1)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+i*lineByteOut+j+2)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i+1)*lineByteOut+j-2)) + (8.0/24.0) *((unsigned char)*(m_pImgDataOut+(i+1)*lineByteOut+j)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i+1)*lineByteOut+j+2)) + (0-2.0/24.0)*((unsigned char)*(m_pImgDataOut+(i+2)*lineByteOut+j-2)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i+2)*lineByteOut+j-1)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i+2)*lineByteOut+j)) + (0-4.0/24.0)*((unsigned char)*(m_pImgDataOut+(i+2)*lineByteOut+j+1)) + (0-2.0/24.0)*((unsigned char)*(m_pImgDataOut+(i+2)*lineByteOut+j+2)); } for(i=0;i<m_imgHeight;i++){ for(j=0;j<m_imgWidth;j++){ *(m_pImgDataOut+i*lineByteOut+j)=255; //像素点设为全白 } } for(i=top+1; i<bottom-1; i++) for(j=left+1; j<right-1; j++){ int positive = 0; int negtive = 0; //3*3的子窗口 满足条件的像素点设为黑色 描出脸内轮廓 for(int m=-1;m<=1;m++) for(int n=-1;n<=1;n++) if(m!=0 || n!=0){ if(result[i+m][j+n]<-5)negtive++; if(result[i+m][j+n]>=5)positive++; } if(positive>2 && negtive>2){ *(m_pImgDataOut+i*lineByteOut+j) = 0; } } if(result!=NULL){ for (int i=0 ;i<m_imgHeight;i++) if(result[i]!=NULL) delete result[i]; delete result; } } void FaceDetect::ImageCut(int F_top,int F_bottom,int F_left,int F_right) { //若灰度图像,则返回 if(m_nBitCount==8) return; //释放旧的输出图像数据及颜色表缓冲区 if(m_pImgDataOut!=NULL){ delete []m_pImgDataOut; m_pImgDataOut=NULL; } if(m_lpColorTableOut!=NULL){ delete []m_lpColorTableOut; m_lpColorTableOut=NULL; } //每像素位数为24比特 m_nBitCountOut=24; //输入图像每像素字节数,彩色图像为3字节/像素 int pixelByteIn=3; //输出图像每像素字节数,彩色图像为3字节/像素 int pixelByteOut=3; //输入图像每行像素所占字节数,必须是4的倍数 int lineByteIn=(m_imgWidth*pixelByteIn+3)/4*4; //输出图像每行像素所占字节数,必须是4的倍数 int lineByteOut=(m_imgWidth*pixelByteOut+3)/4*4; //输出图像的宽高,与输入图像相等 m_imgWidthOut=m_imgWidth; m_imgHeightOut=m_imgHeight; //申请输出图像位图数据缓冲区 m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeight]; //循环变量,图像的坐标 int i,j; for(i=0;i<m_imgHeight;i++){ for(j=0;j<m_imgWidth;j++){ *(m_pImgDataOut+i*lineByteOut+j*3+0)=255; *(m_pImgDataOut+i*lineByteOut+j*3+1)=255; *(m_pImgDataOut+i*lineByteOut+j*3+2)=255;//像素点设为全白 } } //定位框 for(i=F_top;i<=F_bottom;i++){ *(m_pImgDataOut+i*lineByteOut+F_left*3)=0; *(m_pImgDataOut+i*lineByteOut+F_left*3+1)=255; *(m_pImgDataOut+i*lineByteOut+F_left*3+2)=0; *(m_pImgDataOut+i*lineByteOut+F_right*3)=0; *(m_pImgDataOut+i*lineByteOut+F_right*3+1)=255; *(m_pImgDataOut+i*lineByteOut+F_right*3+2)=0; *(m_pImgDataOut+i*lineByteOut+(F_left+1)*3)=0; *(m_pImgDataOut+i*lineByteOut+(F_left+1)*3+1)=255; *(m_pImgDataOut+i*lineByteOut+(F_left+1)*3+2)=0; *(m_pImgDataOut+i*lineByteOut+(F_right+1)*3)=0; *(m_pImgDataOut+i*lineByteOut+(F_right+1)*3+1)=255; *(m_pImgDataOut+i*lineByteOut+(F_right+1)*3+2)=0; *(m_pImgDataOut+i*lineByteOut+(F_left-1)*3)=0; *(m_pImgDataOut+i*lineByteOut+(F_left-1)*3+1)=255; *(m_pImgDataOut+i*lineByteOut+(F_left-1)*3+2)=0; *(m_pImgDataOut+i*lineByteOut+(F_right-1)*3)=0; *(m_pImgDataOut+i*lineByteOut+(F_right-1)*3+1)=255; *(m_pImgDataOut+i*lineByteOut+(F_right-1)*3+2)=0; } for(j=F_left;j<=F_right;j++){ *(m_pImgDataOut+F_bottom*lineByteOut+j*3)=0; *(m_pImgDataOut+F_bottom*lineByteOut+j*3+1)=255; *(m_pImgDataOut+F_bottom*lineByteOut+j*3+2)=0; *(m_pImgDataOut+F_top*lineByteOut+j*3)=0; *(m_pImgDataOut+F_top*lineByteOut+j*3+1)=255; *(m_pImgDataOut+F_top*lineByteOut+j*3+2)=0; *(m_pImgDataOut+(F_bottom-1)*lineByteOut+j*3)=0; *(m_pImgDataOut+(F_bottom-1)*lineByteOut+j*3+1)=255; *(m_pImgDataOut+(F_bottom-1)*lineByteOut+j*3+2)=0; *(m_pImgDataOut+(F_top-1)*lineByteOut+j*3)=0; *(m_pImgDataOut+(F_top-1)*lineByteOut+j*3+1)=255; *(m_pImgDataOut+(F_top-1)*lineByteOut+j*3+2)=0; *(m_pImgDataOut+(F_bottom+1)*lineByteOut+j*3)=0; *(m_pImgDataOut+(F_bottom+1)*lineByteOut+j*3+1)=255; *(m_pImgDataOut+(F_bottom+1)*lineByteOut+j*3+2)=0; *(m_pImgDataOut+(F_top+1)*lineByteOut+j*3)=0; *(m_pImgDataOut+(F_top+1)*lineByteOut+j*3+1)=255; *(m_pImgDataOut+(F_top+1)*lineByteOut+j*3+2)=0; } for(i=F_top+2;i<F_bottom-1;i++){ for(j=F_left+2;j<F_right-1;j++){ *(m_pImgDataOut+i*lineByteOut+j*3+0)=*(m_pImgDataIn1+i*lineByteIn+j*3+0); *(m_pImgDataOut+i*lineByteOut+j*3+1)=*(m_pImgDataIn1+i*lineByteIn+j*3+1); *(m_pImgDataOut+i*lineByteOut+j*3+2)=*(m_pImgDataIn1+i*lineByteIn+j*3+2); } } } float MIN(float a,float b){ float min; min=a; if(b<a) min=b; return min; } float MAX(float a,float b){ float max; max=a; if(b>a) max=b; return max; } void RGBtoHSV(float r, float g, float b, float *h, float *s, float *v){ float min, max, delta; min = MIN( r, MIN( g, b )); max = MAX( r, MAX( g, b )); *v = max; // v在0到1之间 delta = max - min; if( max != 0 ) *s = delta / max; // s在0到1之间 else { // r = g = b = 0 // s = 0, v is undefined *s = 0; *h = -1; return; } if( r == max ) *h = ( g - b ) *60/ delta; // between yellow & magenta else if( g == max ) *h =( 2 + ( b - r ) )*60/ delta; // between cyan & yellow else *h = (4 + ( r - g)) *60/ delta; // between magenta & cyan // degrees if( *h < 0 ) *h += 360; //h在0到360之间 } void HSVtoRGB( float *r, float *g, float *b, float h, float s, float v ){ int i; float f, p, q, t; if( s == 0 ) { // achromatic (grey) *r = *g = *b = v; return; } h /= 60; // sector 0 to 5 i = floor( h ); f = h - i; // factorial part of h p = v * ( 1 - s ); q = v * ( 1 - s * f ); t = v * ( 1 - s * ( 1 - f ) ); switch( i ) { case 0: *r = v; *g = t; *b = p; break; case 1: *r = q; *g = v; *b = p; break; case 2: *r = p; *g = v; *b = t; break; case 3: *r = p; *g = q; *b = v; break; case 4: *r = t; *g = p; *b = v; break; default: // case 5: *r = v; *g = p; *b = q; break; } } //传统同态滤波 void FaceDetect::Homomorphicfilter() { //若灰度图像,则返回 if(m_nBitCount==8) return; //释放旧的输出图像缓冲区 if(m_pImgDataOut!=NULL){ delete []m_pImgDataOut; m_pImgDataOut=NULL; } if(m_lpColorTableOut!=NULL){ delete []m_lpColorTableOut; m_lpColorTableOut=NULL; } //灰度图像输出 /* m_nBitCountOut=8; //颜色表长度 m_nColorTableLengthOut=ComputeColorTabalLength(m_nBitCountOut); //申请颜色表缓冲区,生成灰度图像的颜色表 if(m_nColorTableLengthOut!=0){ m_lpColorTableOut=new RGBQUAD[m_nColorTableLengthOut]; for(int i=0; i<m_nColorTableLengthOut;i++){ m_lpColorTableOut[i].rgbBlue=i; m_lpColorTableOut[i].rgbGreen=i; m_lpColorTableOut[i].rgbRed=i; m_lpColorTableOut[i].rgbReserved=0; } } int lineByteOut=(m_imgWidth*m_nBitCountOut/8+3)/4*4; //输出图像的宽高,与输入图像相等 m_imgWidthOut=m_imgWidth; m_imgHeightOut=m_imgHeight; m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeight]; m_nBitCountOut1=8; int lineByteOut1=(m_imgWidth*m_nBitCountOut1/8+3)/4*4; //输入图像每像素字节数,彩色图像为3字节/像素 int m_nBitCount=24; //输入图像每行像素所占字节数,必须是4的倍数 int lineByteIn=(m_imgWidth*m_nBitCount/8+3)/4*4;*/ //彩色图像输出 m_nBitCountOut=24; int pixelByteOut=3; int lineByteOut=(m_imgWidth*m_nBitCountOut/8+3)/4*4; //输出图像的宽高,与输入图像相等 m_imgWidthOut=m_imgWidth; m_imgHeightOut=m_imgHeight; m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeight]; m_nBitCountOut1=8; m_nBitCountOut2=8; //输出图像每行像素所占字节数,必须是4的倍数 int lineByteOut1=(m_imgWidth*m_nBitCountOut1/8+3)/4*4; int lineByteOut2=(m_imgWidth*m_nBitCountOut2/8+3)/4*4; //输入图像每像素字节数,彩色图像为3字节/像素 int m_nBitCount=24; //输入图像每行像素所占字节数,必须是4的倍数 int lineByteIn=(m_imgWidth*m_nBitCount/8+3)/4*4; //申请输出图像位图数据缓冲区 m_pImgDataOut1=new unsigned char[lineByteOut1*m_imgHeight]; //循环变量,图像的坐标 int m,n; int r,g,b; float R,G,B,H,S,V; float *pa,*pb,*pc; pa=new float[1000000];//V pb=new float[1000000];//S pc=new float[1000000];//H for(m=0;m<m_imgHeight;m++){ for(n=0;n<m_imgWidth;n++){ b=*(m_pImgDataIn1+m*lineByteIn+n*3+0); g=*(m_pImgDataIn1+m*lineByteIn+n*3+1); r=*(m_pImgDataIn1+m*lineByteIn+n*3+2); B=b/255.0; //整型转浮点型 G=g/255.0; R=r/255.0; RGBtoHSV(R, G, B, pc+m*lineByteOut1+n, pb+m*lineByteOut1+n, pa+m*lineByteOut1+n); V=*(pa+m*lineByteOut1+n); float K=-log(V)*100; if(K>255.0f) K=255.0f; *(m_pImgDataOut1+m*lineByteOut1+n)=(unsigned char)(K); } } int y ; int x ; double dTmpOne ; double dTmpTwo ; double D; // 傅立叶变换的宽度和高度(2的整数次幂) int nTransWidth ; int nTransHeight; // 计算进行傅立叶变换的点数 (2的整数次幂) dTmpOne = log(m_imgWidth)/log(2); dTmpTwo = ceil(dTmpOne) ; dTmpTwo = pow(2,dTmpTwo) ; nTransWidth = (int) dTmpTwo ; // 计算进行傅立叶变换的点数 (2的整数次幂) dTmpOne = log(m_imgHeight)/log(2); dTmpTwo = ceil(dTmpOne) ; dTmpTwo = pow(2,dTmpTwo) ; nTransHeight = (int) dTmpTwo ; //滤波的半径不能超过频域的最大半径 double D0=10; if(D0 > nTransWidth-1 || D0 > nTransHeight-1) { return ; } //申请输出图像缓冲区,并初始化为0 m_pImgDataOut2=new unsigned char[m_imgWidthOut*m_imgHeightOut]; memset(m_pImgDataOut2, 0, m_imgWidthOut*m_imgHeightOut); //申请傅立叶缓冲区,并初始化为0 FFtTrans.m_pFFTBuf=new ComplexNumber[m_imgWidthOut*m_imgHeightOut]; memset(FFtTrans.m_pFFTBuf, 0, sizeof(ComplexNumber)*m_imgWidthOut*m_imgHeightOut); //输入图像数据进行二维傅立叶变换 FFtTrans.ImageFFt2D(m_pImgDataOut1, m_imgWidthOut, m_imgHeightOut,m_pImgDataOut2);//m_pImgDataOut2存的是频谱图像 double Rh=2; double Rl=0.5; double c=1.4; double tha,spec; // 下面开始实施ButterWorth高通滤波 for(y=0; y<nTransHeight; y++) { for(x=0; x<nTransWidth; x++) { D = (double)((y-(nTransHeight-1)/2)*(y-(nTransHeight-1)/2)+(x-(nTransWidth-1)/2)*(x-(nTransWidth-1)/2)); D=D*D*c*c*c*c; D = (D0 * D0 * D0 * D0) / D; D = 1/(1+D); D = D*(Rh-Rl)+Rl; //FFtTrans.m_pFFTBuf[y*nTransWidth + x].real=(FFtTrans.m_pFFTBuf[y*nTransWidth + x].real)*D; //FFtTrans.m_pFFTBuf[y*nTransWidth + x].imag=(FFtTrans.m_pFFTBuf[y*nTransWidth + x].imag)*D; tha=atan2(FFtTrans.m_pFFTBuf[y*nTransWidth + x].imag,FFtTrans.m_pFFTBuf[y*nTransWidth + x].real); spec=sqrt(pow(FFtTrans.m_pFFTBuf[y*nTransWidth + x].real,2) + pow(FFtTrans.m_pFFTBuf[y*nTransWidth + x].imag,2))*D;//*(m_pImgDataOut2+y*lineByteOut2+x)*1; FFtTrans.m_pFFTBuf[y*nTransWidth + x].real=spec*cos(tha); FFtTrans.m_pFFTBuf[y*nTransWidth + x].imag=spec*sin(tha); } } // 经过高通滤波的图象进行反变换 FFtTrans.ImageRevFFt2D(m_pImgDataOut1,m_imgWidthOut, m_imgHeightOut); for(m=0;m<m_imgHeight;m++){ for(n=0;n<m_imgWidth;n++){ V=*(m_pImgDataOut1+m*lineByteOut1+n)/100.0f; pa[m*lineByteOut1+n]=1/exp(V); V=pa[m*lineByteOut1+n]; S=pb[m*lineByteOut1+n]; H=pc[m*lineByteOut1+n]; HSVtoRGB( pc+m*lineByteOut1+n, pb+m*lineByteOut1+n, pa+m*lineByteOut1+n, H, S, V ); *(m_pImgDataOut+m*lineByteOut+n*pixelByteOut+0)=*(pa+m*lineByteOut1+n)*255; *(m_pImgDataOut+m*lineByteOut+n*pixelByteOut+1)=*(pb+m*lineByteOut1+n)*255; *(m_pImgDataOut+m*lineByteOut+n*pixelByteOut+2)=*(pc+m*lineByteOut1+n)*255; } } } void FaceDetect::Adaptivethresegment() { //若灰度图像,则返回 if(m_nBitCount==8) return; //释放旧的输出图像数据及颜色表缓冲区 if(m_pImgDataOut!=NULL){ delete []m_pImgDataOut; m_pImgDataOut=NULL; } if(m_lpColorTableOut!=NULL){ delete []m_lpColorTableOut; m_lpColorTableOut=NULL; } //释放旧的输出图像数据及颜色表缓冲区 if(m_pImgDataOut1!=NULL){ delete []m_pImgDataOut; m_pImgDataOut=NULL; } if(m_lpColorTableOut1!=NULL){ delete []m_lpColorTableOut; m_lpColorTableOut=NULL; } //灰值化后,每像素位数为8比特 m_nBitCountOut=8; m_nBitCountOut1=8; //颜色表长度 m_nColorTableLengthOut=ComputeColorTabalLength(m_nBitCountOut); m_nColorTableLengthOut1=ComputeColorTabalLength(m_nBitCountOut1); //申请颜色表缓冲区,生成灰度图像的颜色表 if(m_nColorTableLengthOut!=0){ m_lpColorTableOut=new RGBQUAD[m_nColorTableLengthOut]; for(int i=0; i<m_nColorTableLengthOut;i++){ m_lpColorTableOut[i].rgbBlue=i; m_lpColorTableOut[i].rgbGreen=i; m_lpColorTableOut[i].rgbRed=i; m_lpColorTableOut[i].rgbReserved=0; } } //申请颜色表缓冲区,生成灰度图像的颜色表 if(m_nColorTableLengthOut1!=0){ m_lpColorTableOut1=new RGBQUAD[m_nColorTableLengthOut1]; for(int i=0; i<m_nColorTableLengthOut1;i++){ m_lpColorTableOut1[i].rgbBlue=i; m_lpColorTableOut1[i].rgbGreen=i; m_lpColorTableOut1[i].rgbRed=i; m_lpColorTableOut1[i].rgbReserved=0; } } //输入图像每像素字节数,彩色图像为3字节/像素 int pixelByteIn=3; //输入图像每行像素所占字节数,必须是4的倍数 int lineByteIn=(m_imgWidth*pixelByteIn+3)/4*4; //输出图像的宽高,与输入图像相等 m_imgWidthOut=m_imgWidth; m_imgHeightOut=m_imgHeight; //输出图像每行像素所占字节数,必须是4的倍数 int lineByteOut=(m_imgWidth*m_nBitCountOut/8+3)/4*4; int lineByteOut1=(m_imgWidth*m_nBitCountOut1/8+3)/4*4; //申请输出图像位图数据缓冲区 m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeight]; m_pImgDataOut1=new unsigned char[lineByteOut1*m_imgHeight]; memset(m_pImgDataOut, 255, m_imgWidthOut*m_imgHeightOut); //通过遍历整幅图像 获取输入图像人脸定位框的边界值 int i,j,right,left,top,bottom; for(i=0;i<m_imgHeight;i++){ for(j=0;j<m_imgWidth;j++){ if(*(m_pImgData+i*lineByteIn+j*pixelByteIn+1)==255&& *(m_pImgData+i*lineByteIn+j*pixelByteIn+0)==0&& *(m_pImgData+i*lineByteIn+j*pixelByteIn+2)==0) break; } if(*(m_pImgData+i*lineByteIn+j*pixelByteIn+1)==255&& *(m_pImgData+i*lineByteIn+j*pixelByteIn+0)==0&& *(m_pImgData+i*lineByteIn+j*pixelByteIn+2)==0) break; } left=j+1; top=i+1; for(i=m_imgHeight-1;i>=0;i--){ for(j=m_imgWidth-1;j>=0;j--){ if(*(m_pImgData+i*lineByteIn+j*pixelByteIn+1)==255&& *(m_pImgData+i*lineByteIn+j*pixelByteIn+0)==0&& *(m_pImgData+i*lineByteIn+j*pixelByteIn+2)==0) break; } if(*(m_pImgData+i*lineByteIn+j*pixelByteIn+1)==255&& *(m_pImgData+i*lineByteIn+j*pixelByteIn+0)==0&& *(m_pImgData+i*lineByteIn+j*pixelByteIn+2)==0) break; } right=j-1; bottom=i-1; int m,n; //int MAX; //根据灰值化公式为输出图像赋值 for(m=top+2;m<bottom-1;m++){ for(n=left+2;n<right-1;n++){ *(m_pImgDataOut1+m*lineByteOut1+n)=0.11**(m_pImgData+m*lineByteIn+n*pixelByteIn+0) +0.59**(m_pImgData+m*lineByteIn+n*pixelByteIn+1) +0.30**(m_pImgData+m*lineByteIn+n*pixelByteIn+2)+0.5; } } /* MAX=*(m_pImgDataOut1+(top+2)*lineByteOut1+left+2); for(m=top+2;m<bottom-1;m++){ for(n=left+2;n<right-1;n++){ if(*(m_pImgDataOut1+m*lineByteOut1+n)>MAX) MAX=*(m_pImgDataOut1+m*lineByteOut1+n); } } for(m=top+2;m<bottom-1;m++){ for(n=left+2;n<right-1;n++){ *(m_pImgDataOut1+m*lineByteOut1+n)=*(m_pImgDataOut1+m*lineByteOut1+n)/MAX; *(m_pImgDataOut1+m*lineByteOut1+n)=*(m_pImgDataOut1+m*lineByteOut1+n)*255; } }*/ int C=7,N=9;//需要调整一系列参数 使得识别效果达到最佳 int nLocAvg ; // 子图象的平均值 int max,min; double r,g,temp; // 对图像逐点扫描: for(m=top+2+(N-1)/2;m<bottom-1-(N-1)/2;m++){ for(n=left+2+(N-1)/2;n<right-1-(N-1)/2;n++){ max=min=*(m_pImgDataOut1+m*lineByteOut1+n); nLocAvg = 0 ; for(i=0;i<N;i++){ for(j=0;j<N;j++){ if(*(m_pImgDataOut1+(m-(N-1)/2+i)*lineByteOut1+(n-(N-1)/2+j))>max) max=*(m_pImgDataOut1+(m-(N-1)/2+i)*lineByteOut1+(n-(N-1)/2+j)); if(*(m_pImgDataOut1+(m-(N-1)/2+i)*lineByteOut1+(n-(N-1)/2+j))<min) min=*(m_pImgDataOut1+(m-(N-1)/2+i)*lineByteOut1+(n-(N-1)/2+j)); } } nLocAvg=(max+min)/2; //归一化 temp = *(m_pImgData+m*lineByteIn+n*pixelByteIn)+ *(m_pImgData+m*lineByteIn+n*pixelByteIn+1)+ *(m_pImgData+m*lineByteIn+n*pixelByteIn+2); r = (double)*(m_pImgData+m*lineByteIn+n*pixelByteIn+2)/temp; g = (double)*(m_pImgData+m*lineByteIn+n*pixelByteIn+1)/temp; if(abs(*(m_pImgDataOut1+m*lineByteOut1+n)-nLocAvg)>C && g<0.398 && g > 0.246 && r<0.664 && r>0.233 && r>g && g>=0.5*(1-r)) *(m_pImgDataOut+m*lineByteOut+n)=0; else *(m_pImgDataOut+m*lineByteOut+n)=255; } } // filter = Morphology(CSize(m_imgWidthOut,m_imgHeightOut),m_nBitCountOut,m_lpColorTableOut,m_pImgDataOut); //memcpy(filter.m_pImgData, m_pImgDataOut, m_imgWidthOut*m_imgHeightOut); // filter.Close(); } void FaceDetect::DWThomomorphicfilter() { //若灰度图像,则返回 if(m_nBitCount==8) return; //释放旧的输出图像缓冲区 if(m_pImgDataOut!=NULL){ delete []m_pImgDataOut; m_pImgDataOut=NULL; } if(m_lpColorTableOut!=NULL){ delete []m_lpColorTableOut; m_lpColorTableOut=NULL; } //灰度图像输出 /* m_nBitCountOut=8; //颜色表长度 m_nColorTableLengthOut=ComputeColorTabalLength(m_nBitCountOut); //申请颜色表缓冲区,生成灰度图像的颜色表 if(m_nColorTableLengthOut!=0){ m_lpColorTableOut=new RGBQUAD[m_nColorTableLengthOut]; for(int i=0; i<m_nColorTableLengthOut;i++){ m_lpColorTableOut[i].rgbBlue=i; m_lpColorTableOut[i].rgbGreen=i; m_lpColorTableOut[i].rgbRed=i; m_lpColorTableOut[i].rgbReserved=0; } } int lineByteOut=(m_imgWidth*m_nBitCountOut/8+3)/4*4; //输出图像的宽高,与输入图像相等 m_imgWidthOut=m_imgWidth; m_imgHeightOut=m_imgHeight; m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeight]; m_nBitCountOut1=8; int lineByteOut1=(m_imgWidth*m_nBitCountOut1/8+3)/4*4; //输入图像每像素字节数,彩色图像为3字节/像素 int m_nBitCount=24; //输入图像每行像素所占字节数,必须是4的倍数 int lineByteIn=(m_imgWidth*m_nBitCount/8+3)/4*4;*/ //彩色图像输出 m_nBitCountOut=24; int pixelByteOut=3; int lineByteOut=(m_imgWidth*m_nBitCountOut/8+3)/4*4; //输出图像的宽高,与输入图像相等 m_imgWidthOut=m_imgWidth; m_imgHeightOut=m_imgHeight; m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeight]; m_nBitCountOut1=8; //颜色表长度 m_nColorTableLengthOut1=ComputeColorTabalLength(m_nBitCountOut1); //申请颜色表缓冲区,生成灰度图像的颜色表 if(m_nColorTableLengthOut1!=0){ m_lpColorTableOut1=new RGBQUAD[m_nColorTableLengthOut1]; for(int i=0; i<m_nColorTableLengthOut1;i++){ m_lpColorTableOut1[i].rgbBlue=i; m_lpColorTableOut1[i].rgbGreen=i; m_lpColorTableOut1[i].rgbRed=i; m_lpColorTableOut1[i].rgbReserved=0; } } //输出图像每行像素所占字节数,必须是4的倍数 int lineByteOut1=(m_imgWidth*m_nBitCountOut1/8+3)/4*4; //申请输出图像位图数据缓冲区 m_pImgDataOut1=new unsigned char[lineByteOut1*m_imgHeight]; //输入图像每像素字节数,彩色图像为3字节/像素 int m_nBitCount=24; //输入图像每行像素所占字节数,必须是4的倍数 int lineByteIn=(m_imgWidth*m_nBitCount/8+3)/4*4; //循环变量,图像的坐标 int m,n; int r,g,b; float R,G,B,H,S,V; float *pa,*pb,*pc; pa=new float[1000000];//V pb=new float[1000000];//S pc=new float[1000000];//H for(m=0;m<m_imgHeight;m++){ for(n=0;n<m_imgWidth;n++){ b=*(m_pImgDataIn1+m*lineByteIn+n*3+0); g=*(m_pImgDataIn1+m*lineByteIn+n*3+1); r=*(m_pImgDataIn1+m*lineByteIn+n*3+2); B=b/255.0; //整型转浮点型 G=g/255.0; R=r/255.0; RGBtoHSV(R, G, B, pc+m*lineByteOut1+n, pb+m*lineByteOut1+n, pa+m*lineByteOut1+n); V=*(pa+m*lineByteOut1+n); float K=-log(V)*100; if(K>255.0f) K=255.0f; *(m_pImgDataOut1+m*lineByteOut1+n)=(unsigned char)(K); //*(m_pImgDataOut+m*lineByteOut+n)=(unsigned char)(K); } } DWtTrans.InputImageData(CSize(m_imgWidth,m_imgHeight),m_nBitCountOut1, m_lpColorTableOut1, m_pImgDataOut1); DWtTrans.BasicWaveletTrans(3); //DWtTrans.BasicWaveletReverse(); //m_pImgDataOut = DWtTrans.m_pImgDataOut; //DWtTrans.InputImageData(CSize(m_imgWidth,m_imgHeight),m_nBitCountOut, m_lpColorTableOut, m_pImgDataOut); DWtTrans.BasicWaveletReverse(); m_pImgDataOut1 = DWtTrans.m_pImgDataOut; //输入图像数据进行小波变换 //经过高通滤波的图象进行反变换 for(m=0;m<m_imgHeight;m++){ for(n=0;n<m_imgWidth;n++){ V=*(m_pImgDataOut1+m*lineByteOut1+n)/100.0f; pa[m*lineByteOut1+n]=1/exp(V); V=pa[m*lineByteOut1+n]; S=pb[m*lineByteOut1+n]; H=pc[m*lineByteOut1+n]; HSVtoRGB( pc+m*lineByteOut1+n, pb+m*lineByteOut1+n, pa+m*lineByteOut1+n, H, S, V ); *(m_pImgDataOut+m*lineByteOut+n*pixelByteOut+0)=*(pa+m*lineByteOut1+n)*255; *(m_pImgDataOut+m*lineByteOut+n*pixelByteOut+1)=*(pb+m*lineByteOut1+n)*255; *(m_pImgDataOut+m*lineByteOut+n*pixelByteOut+2)=*(pc+m*lineByteOut1+n)*255; } } }
[ "cyummy@buaa.edu.cn" ]
cyummy@buaa.edu.cn
8346b97500403a2b263693879e32a4652ea72dd1
dae4878b1febbdc8350a53402a9db051b272c1e2
/src/modules/vtol_att_control/standard.cpp
70a934298d63137e70a67a457ff0fa7c8391d964
[]
no_license
ANCL/UAV_DOBIBS
5c86a38e65a58654957ae8344205ef2581ff00a8
65f39f5ff8baeed71338b7476963d7f4662bc6a6
refs/heads/master
2020-09-05T04:07:33.932986
2020-08-05T15:44:45
2020-08-05T15:44:45
219,977,726
6
5
null
2020-03-18T03:10:25
2019-11-06T11:08:15
C
UTF-8
C++
false
false
18,097
cpp
/**************************************************************************** * * Copyright (c) 2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name PX4 nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ /** * @file standard.cpp * * @author Simon Wilks <simon@uaventure.com> * @author Roman Bapst <bapstroman@gmail.com> * @author Andreas Antener <andreas@uaventure.com> * @author Sander Smeets <sander@droneslab.com> * */ #include "standard.h" #include "vtol_att_control_main.h" Standard::Standard(VtolAttitudeControl *attc) : VtolType(attc), _flag_enable_mc_motors(true), _pusher_throttle(0.0f), _airspeed_trans_blend_margin(0.0f) { _vtol_schedule.flight_mode = MC_MODE; _vtol_schedule.transition_start = 0; _pusher_active = false; _mc_roll_weight = 1.0f; _mc_pitch_weight = 1.0f; _mc_yaw_weight = 1.0f; _mc_throttle_weight = 1.0f; _params_handles_standard.front_trans_dur = param_find("VT_F_TRANS_DUR"); _params_handles_standard.back_trans_dur = param_find("VT_B_TRANS_DUR"); _params_handles_standard.pusher_trans = param_find("VT_TRANS_THR"); _params_handles_standard.airspeed_blend = param_find("VT_ARSP_BLEND"); _params_handles_standard.airspeed_trans = param_find("VT_ARSP_TRANS"); _params_handles_standard.front_trans_timeout = param_find("VT_TRANS_TIMEOUT"); _params_handles_standard.front_trans_time_min = param_find("VT_TRANS_MIN_TM"); _params_handles_standard.down_pitch_max = param_find("VT_DWN_PITCH_MAX"); _params_handles_standard.forward_thrust_scale = param_find("VT_FWD_THRUST_SC"); _params_handles_standard.airspeed_mode = param_find("FW_ARSP_MODE"); } Standard::~Standard() { } void Standard::parameters_update() { float v; int i; /* duration of a forwards transition to fw mode */ param_get(_params_handles_standard.front_trans_dur, &v); _params_standard.front_trans_dur = math::constrain(v, 0.0f, 5.0f); /* duration of a back transition to mc mode */ param_get(_params_handles_standard.back_trans_dur, &v); _params_standard.back_trans_dur = math::constrain(v, 0.0f, 5.0f); /* target throttle value for pusher motor during the transition to fw mode */ param_get(_params_handles_standard.pusher_trans, &v); _params_standard.pusher_trans = math::constrain(v, 0.0f, 5.0f); /* airspeed at which we should switch to fw mode */ param_get(_params_handles_standard.airspeed_trans, &v); _params_standard.airspeed_trans = math::constrain(v, 1.0f, 20.0f); /* airspeed at which we start blending mc/fw controls */ param_get(_params_handles_standard.airspeed_blend, &v); _params_standard.airspeed_blend = math::constrain(v, 0.0f, 20.0f); _airspeed_trans_blend_margin = _params_standard.airspeed_trans - _params_standard.airspeed_blend; /* timeout for transition to fw mode */ param_get(_params_handles_standard.front_trans_timeout, &_params_standard.front_trans_timeout); /* minimum time for transition to fw mode */ param_get(_params_handles_standard.front_trans_time_min, &_params_standard.front_trans_time_min); /* maximum down pitch allowed */ param_get(_params_handles_standard.down_pitch_max, &v); _params_standard.down_pitch_max = math::radians(v); /* scale for fixed wing thrust used for forward acceleration in multirotor mode */ param_get(_params_handles_standard.forward_thrust_scale, &_params_standard.forward_thrust_scale); /* airspeed mode */ param_get(_params_handles_standard.airspeed_mode, &i); _params_standard.airspeed_mode = math::constrain(i, 0, 2); } void Standard::update_vtol_state() { /* After flipping the switch the vehicle will start the pusher (or tractor) motor, picking up * forward speed. After the vehicle has picked up enough speed the rotors shutdown. * For the back transition the pusher motor is immediately stopped and rotors reactivated. */ if (!_attc->is_fixed_wing_requested()) { // the transition to fw mode switch is off if (_vtol_schedule.flight_mode == MC_MODE) { // in mc mode _vtol_schedule.flight_mode = MC_MODE; _mc_roll_weight = 1.0f; _mc_pitch_weight = 1.0f; _mc_yaw_weight = 1.0f; _mc_throttle_weight = 1.0f; } else if (_vtol_schedule.flight_mode == FW_MODE) { // transition to mc mode if (_vtol_vehicle_status->vtol_transition_failsafe == true) { // Failsafe event, engage mc motors immediately _vtol_schedule.flight_mode = MC_MODE; _flag_enable_mc_motors = true; } else { // Regular backtransition _vtol_schedule.flight_mode = TRANSITION_TO_MC; _flag_enable_mc_motors = true; _vtol_schedule.transition_start = hrt_absolute_time(); } } else if (_vtol_schedule.flight_mode == TRANSITION_TO_FW) { // failsafe back to mc mode _vtol_schedule.flight_mode = MC_MODE; _mc_roll_weight = 1.0f; _mc_pitch_weight = 1.0f; _mc_yaw_weight = 1.0f; _mc_throttle_weight = 1.0f; } else if (_vtol_schedule.flight_mode == TRANSITION_TO_MC) { // transition to MC mode if transition time has passed // XXX: base this on XY hold velocity of MC if (hrt_elapsed_time(&_vtol_schedule.transition_start) > (_params_standard.back_trans_dur * 1000000.0f)) { _vtol_schedule.flight_mode = MC_MODE; } } // the pusher motor should never be powered when in or transitioning to mc mode _pusher_throttle = 0.0f; } else { // the transition to fw mode switch is on if (_vtol_schedule.flight_mode == MC_MODE || _vtol_schedule.flight_mode == TRANSITION_TO_MC) { // start transition to fw mode /* NOTE: The failsafe transition to fixed-wing was removed because it can result in an * unsafe flying state. */ _vtol_schedule.flight_mode = TRANSITION_TO_FW; _vtol_schedule.transition_start = hrt_absolute_time(); } else if (_vtol_schedule.flight_mode == FW_MODE) { // in fw mode _vtol_schedule.flight_mode = FW_MODE; _mc_roll_weight = 0.0f; _mc_pitch_weight = 0.0f; _mc_yaw_weight = 0.0f; _mc_throttle_weight = 0.0f; } else if (_vtol_schedule.flight_mode == TRANSITION_TO_FW) { // continue the transition to fw mode while monitoring airspeed for a final switch to fw mode if (((_params_standard.airspeed_mode == control_state_s::AIRSPD_MODE_DISABLED || _airspeed->indicated_airspeed_m_s >= _params_standard.airspeed_trans) && (float)hrt_elapsed_time(&_vtol_schedule.transition_start) > (_params_standard.front_trans_time_min * 1000000.0f)) || can_transition_on_ground()) { _vtol_schedule.flight_mode = FW_MODE; // we can turn off the multirotor motors now _flag_enable_mc_motors = false; // don't set pusher throttle here as it's being ramped up elsewhere _trans_finished_ts = hrt_absolute_time(); } } } // map specific control phases to simple control modes switch (_vtol_schedule.flight_mode) { case MC_MODE: _vtol_mode = mode::ROTARY_WING; break; case FW_MODE: _vtol_mode = mode::FIXED_WING; break; case TRANSITION_TO_FW: _vtol_mode = mode::TRANSITION_TO_MC; break; case TRANSITION_TO_MC: _vtol_mode = mode::TRANSITION_TO_FW; break; } } void Standard::update_transition_state() { VtolType::update_transition_state(); // copy virtual attitude setpoint to real attitude setpoint memcpy(_v_att_sp, _mc_virtual_att_sp, sizeof(vehicle_attitude_setpoint_s)); if (_vtol_schedule.flight_mode == TRANSITION_TO_FW) { if (_params_standard.front_trans_dur <= 0.0f) { // just set the final target throttle value _pusher_throttle = _params_standard.pusher_trans; } else if (_pusher_throttle <= _params_standard.pusher_trans) { // ramp up throttle to the target throttle value _pusher_throttle = _params_standard.pusher_trans * (float)hrt_elapsed_time(&_vtol_schedule.transition_start) / (_params_standard.front_trans_dur * 1000000.0f); } // do blending of mc and fw controls if a blending airspeed has been provided and the minimum transition time has passed if (_airspeed_trans_blend_margin > 0.0f && _airspeed->indicated_airspeed_m_s >= _params_standard.airspeed_blend && (float)hrt_elapsed_time(&_vtol_schedule.transition_start) > (_params_standard.front_trans_time_min * 1000000.0f) ) { float weight = 1.0f - fabsf(_airspeed->indicated_airspeed_m_s - _params_standard.airspeed_blend) / _airspeed_trans_blend_margin; _mc_roll_weight = weight; _mc_pitch_weight = weight; _mc_yaw_weight = weight; _mc_throttle_weight = weight; // time based blending when no airspeed sensor is set } else if (_params_standard.airspeed_mode == control_state_s::AIRSPD_MODE_DISABLED && (float)hrt_elapsed_time(&_vtol_schedule.transition_start) < (_params_standard.front_trans_time_min * 1000000.0f) && (float)hrt_elapsed_time(&_vtol_schedule.transition_start) > ((_params_standard.front_trans_time_min / 2.0f) * 1000000.0f) ) { float weight = 1.0f - ((float)(hrt_elapsed_time(&_vtol_schedule.transition_start) - (( _params_standard.front_trans_time_min / 2.0f) * 1000000.0f)) / ((_params_standard.front_trans_time_min / 2.0f) * 1000000.0f)); weight = math::constrain(weight, 0.0f, 1.0f); _mc_roll_weight = weight; _mc_pitch_weight = weight; _mc_yaw_weight = weight; _mc_throttle_weight = weight; } else { // at low speeds give full weight to mc _mc_roll_weight = 1.0f; _mc_pitch_weight = 1.0f; _mc_yaw_weight = 1.0f; _mc_throttle_weight = 1.0f; } // check front transition timeout if (_params_standard.front_trans_timeout > FLT_EPSILON) { if ((float)hrt_elapsed_time(&_vtol_schedule.transition_start) > (_params_standard.front_trans_timeout * 1000000.0f)) { // transition timeout occured, abort transition _attc->abort_front_transition("Transition timeout"); } } } else if (_vtol_schedule.flight_mode == TRANSITION_TO_MC) { // continually increase mc attitude control as we transition back to mc mode if (_params_standard.back_trans_dur > 0.0f) { float weight = (float)hrt_elapsed_time(&_vtol_schedule.transition_start) / (_params_standard.back_trans_dur * 1000000.0f); _mc_roll_weight = weight; _mc_pitch_weight = weight; _mc_yaw_weight = weight; _mc_throttle_weight = weight; } else { _mc_roll_weight = 1.0f; _mc_pitch_weight = 1.0f; _mc_yaw_weight = 1.0f; _mc_throttle_weight = 1.0f; } // in fw mode we need the multirotor motors to stop spinning, in backtransition mode we let them spin up again if (_flag_enable_mc_motors) { set_max_mc(2000); set_idle_mc(); _flag_enable_mc_motors = false; } } _mc_roll_weight = math::constrain(_mc_roll_weight, 0.0f, 1.0f); _mc_pitch_weight = math::constrain(_mc_pitch_weight, 0.0f, 1.0f); _mc_yaw_weight = math::constrain(_mc_yaw_weight, 0.0f, 1.0f); _mc_throttle_weight = math::constrain(_mc_throttle_weight, 0.0f, 1.0f); } void Standard::update_mc_state() { VtolType::update_mc_state(); // enable MC motors here in case we transitioned directly to MC mode if (_flag_enable_mc_motors) { set_max_mc(2000); set_idle_mc(); _flag_enable_mc_motors = false; } // if the thrust scale param is zero then the pusher-for-pitch strategy is disabled and we can return if (_params_standard.forward_thrust_scale < FLT_EPSILON) { return; } matrix::Dcmf R(matrix::Quatf(_v_att->q)); matrix::Dcmf R_sp(matrix::Quatf(_v_att_sp->q_d)); matrix::Eulerf euler(R); matrix::Eulerf euler_sp(R_sp); _pusher_throttle = 0.0f; // direction of desired body z axis represented in earth frame matrix::Vector3f body_z_sp(R_sp(0, 2), R_sp(1, 2), R_sp(2, 2)); // rotate desired body z axis into new frame which is rotated in z by the current // heading of the vehicle. we refer to this as the heading frame. matrix::Dcmf R_yaw = matrix::Eulerf(0.0f, 0.0f, -euler(2)); body_z_sp = R_yaw * body_z_sp; body_z_sp.normalize(); // calculate the desired pitch seen in the heading frame // this value corresponds to the amount the vehicle would try to pitch forward float pitch_forward = atan2f(body_z_sp(0), body_z_sp(2)); // only allow pitching forward up to threshold, the rest of the desired // forward acceleration will be compensated by the pusher if (pitch_forward < -_params_standard.down_pitch_max) { // desired roll angle in heading frame stays the same float roll_new = -asinf(body_z_sp(1)); _pusher_throttle = (sinf(-pitch_forward) - sinf(_params_standard.down_pitch_max)) * _v_att_sp->thrust * _params_standard.forward_thrust_scale; // limit desired pitch float pitch_new = -_params_standard.down_pitch_max; // create corrected desired body z axis in heading frame matrix::Dcmf R_tmp = matrix::Eulerf(roll_new, pitch_new, 0.0f); matrix::Vector3f tilt_new(R_tmp(0, 2), R_tmp(1, 2), R_tmp(2, 2)); // rotate the vector into a new frame which is rotated in z by the desired heading // with respect to the earh frame. float yaw_error = _wrap_pi(euler_sp(2) - euler(2)); matrix::Dcmf R_yaw_correction = matrix::Eulerf(0.0f, 0.0f, -yaw_error); tilt_new = R_yaw_correction * tilt_new; // now extract roll and pitch setpoints _v_att_sp->pitch_body = atan2f(tilt_new(0), tilt_new(2)); _v_att_sp->roll_body = -asinf(tilt_new(1)); R_sp = matrix::Eulerf(_v_att_sp->roll_body, _v_att_sp->pitch_body, euler_sp(2)); matrix::Quatf q_sp(R_sp); memcpy(&_v_att_sp->q_d[0], &q_sp._data[0], sizeof(_v_att_sp->q_d)); } _pusher_throttle = _pusher_throttle < 0.0f ? 0.0f : _pusher_throttle; } void Standard::update_fw_state() { VtolType::update_fw_state(); // in fw mode we need the multirotor motors to stop spinning, in backtransition mode we let them spin up again if (!_flag_enable_mc_motors) { set_max_mc(950); set_idle_fw(); // force them to stop, not just idle _flag_enable_mc_motors = true; } } /** * Prepare message to acutators with data from mc and fw attitude controllers. An mc attitude weighting will determine * what proportion of control should be applied to each of the control groups (mc and fw). */ void Standard::fill_actuator_outputs() { // multirotor controls _actuators_out_0->timestamp = _actuators_mc_in->timestamp; // roll _actuators_out_0->control[actuator_controls_s::INDEX_ROLL] = _actuators_mc_in->control[actuator_controls_s::INDEX_ROLL] * _mc_roll_weight; // pitch _actuators_out_0->control[actuator_controls_s::INDEX_PITCH] = _actuators_mc_in->control[actuator_controls_s::INDEX_PITCH] * _mc_pitch_weight; // yaw _actuators_out_0->control[actuator_controls_s::INDEX_YAW] = _actuators_mc_in->control[actuator_controls_s::INDEX_YAW] * _mc_yaw_weight; // throttle _actuators_out_0->control[actuator_controls_s::INDEX_THROTTLE] = _actuators_mc_in->control[actuator_controls_s::INDEX_THROTTLE] * _mc_throttle_weight; // fixed wing controls _actuators_out_1->timestamp = _actuators_fw_in->timestamp; //roll _actuators_out_1->control[actuator_controls_s::INDEX_ROLL] = -_actuators_fw_in->control[actuator_controls_s::INDEX_ROLL] * (1 - _mc_roll_weight); //pitch _actuators_out_1->control[actuator_controls_s::INDEX_PITCH] = (_actuators_fw_in->control[actuator_controls_s::INDEX_PITCH] + _params->fw_pitch_trim) * (1 - _mc_pitch_weight); // yaw _actuators_out_1->control[actuator_controls_s::INDEX_YAW] = _actuators_fw_in->control[actuator_controls_s::INDEX_YAW] * (1 - _mc_yaw_weight); // set the fixed wing throttle control if (_vtol_schedule.flight_mode == FW_MODE && _armed->armed) { // take the throttle value commanded by the fw controller _actuators_out_1->control[actuator_controls_s::INDEX_THROTTLE] = _actuators_fw_in->control[actuator_controls_s::INDEX_THROTTLE]; } else { // otherwise we may be ramping up the throttle during the transition to fw mode _actuators_out_1->control[actuator_controls_s::INDEX_THROTTLE] = _pusher_throttle; } } void Standard::waiting_on_tecs() { // keep thrust from transition _v_att_sp->thrust = _pusher_throttle; }; /** * Disable all multirotor motors when in fw mode. */ void Standard::set_max_mc(unsigned pwm_value) { int ret; unsigned servo_count; const char *dev = PWM_OUTPUT0_DEVICE_PATH; int fd = px4_open(dev, 0); if (fd < 0) { PX4_WARN("can't open %s", dev); } ret = px4_ioctl(fd, PWM_SERVO_GET_COUNT, (unsigned long)&servo_count); struct pwm_output_values pwm_values; memset(&pwm_values, 0, sizeof(pwm_values)); for (int i = 0; i < _params->vtol_motor_count; i++) { pwm_values.values[i] = pwm_value; pwm_values.channel_count = _params->vtol_motor_count; } ret = px4_ioctl(fd, PWM_SERVO_SET_MAX_PWM, (long unsigned int)&pwm_values); if (ret != OK) { PX4_WARN("failed setting max values"); } px4_close(fd); }
[ "moeini@ualberta.ca" ]
moeini@ualberta.ca
f30408506c2e11bd1cc4e5f47db767652077c3be
e9a00c41cc6a3219ddb61b893accf9ffc91c7dff
/C_Diamond_Miner.cpp
6b3944b561fb31bf8ef21957f93d9f5ccada5777
[]
no_license
powxconsensus/CP-Practice
10e585db0eef62a08777674da42a1ca8c9b6c30f
ad24fbde677933225e4e099727c74857fbe8f50b
refs/heads/master
2023-03-22T18:26:05.301238
2021-03-17T12:41:16
2021-03-17T12:41:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,360
cpp
#include <iostream> #include <algorithm> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <unordered_set> #include <set> #include <climits> #include <stack> #include <unordered_map> #include <queue> #include <bitset> #include <ctime> using namespace std; #define mod 998244353 #define lli long long int #define ll long long #define li long int #define FastIO \ ios::sync_with_stdio(0); \ cin.tie(0) class PNC { public: vector<unsigned lli> f; lli m; PNC(lli n, lli m = mod) { f.resize(n + 1); this->m = m; f[0] = 1; for (int i = 1; i <= n; i++) { f[i] = (i * f[i - 1]) % m; } } lli power(lli b, lli p, lli m = mod) { lli res = 1; while (p > 0) { if (p & 1) res = ((res % m) * (b % m)) % m; b = ((b % m) * (b % m)) % m; p = p >> 1; } return res; } lli modInverse(lli n, lli m = mod) { return power(n, m - 2, m); } lli factorial(lli n) { return f[n]; } lli nCr(lli n, lli r) { if (r == 0) return 1; return (f[n] * modInverse(f[r], m) % m * modInverse(f[n - r], m) % m) % m; } lli nPr(lli n, lli r) { if (r == 0) return 1; return (f[n] * modInverse(f[n - r], m) % m) % m; } }; int main() { ll tc; cin >> tc; while (tc--) { ll N; cin >> N; vector<pair<ll, ll>> diamond(N), miner(N); ll x, y, w = 0, z = 0; for (ll i = 0; i < 2 * N; i++) { cin >> x >> y; if (x == 0) { miner[w++] = {x, abs(y)}; } else { diamond[z++] = {abs(x), y}; } } sort(miner.begin(), miner.end(), greater<>()); sort(diamond.begin(), diamond.end(), greater<>()); double ans = 0.0; for (ll i = 0; i < N; i++) { ans += (double)sqrt(miner[i].second * miner[i].second + diamond[i].first * diamond[i].first); } cout << fixed << setprecision(18) << ans << "\n"; } }
[ "mpriyanshu263@gmail.com" ]
mpriyanshu263@gmail.com
405f7bec581dbeaf09d64874a07f7ea84b661c96
747ba24e58c9c432f9063a7b19690fa29000b18b
/chapter14/14.30a.h
e6b964db499d3e54ba5af607dda948a9772d92c8
[]
no_license
edwinpadron/Cpp-Primer
294288bd64aa5bdad318c4405e7e0de96862ce4c
efd642c8f4f3cbd98cc7eb3fe00620405216f0bf
refs/heads/master
2023-08-20T07:27:41.837282
2021-03-08T17:37:52
2021-03-08T17:37:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,424
h
/* * Exercise 14.30: Add dereference and arrow operators to your StrBlobPtr class * and to the ConstStrBlobPtr class that you defined in exercise 12.22 from § * 12.1.6 (p. 476). Note that the operators in constStrBlobPtr must return * const references because the data member in constStrBlobPtr points to a * const vector. * * By Faisal Saadatmand */ #ifndef STR_BLOB_H #define STR_BLOB_H #include <exception> #include <iostream> #include <memory> #include <string> #include <vector> class StrBlobPtr; class StrBlob { friend bool operator==(const StrBlob &, const StrBlob &); friend bool operator!=(const StrBlob &, const StrBlob &); friend bool operator<(const StrBlob &, const StrBlob &); public: friend class StrBlobPtr; using size_type = std::vector<std::string>::size_type; StrBlob(); StrBlob(std::initializer_list<std::string> il); StrBlob(const StrBlob &rhs) : // copy constructor data(std::make_shared<std::vector<std::string>> (*rhs.data)) { } StrBlob& operator=(const StrBlob &); // copy assignment operator StrBlobPtr begin() const; // return StrBlobPtr to the first element StrBlobPtr end() const; // and one past the last element size_type size() const { return data->size(); } bool empty() const { return data->empty(); } // add and remove elements void push_back(const std::string &); void push_back(std::string &&); void pop_back(); // element access std::string& front(); std::string& back(); std::string& front() const; std::string& back() const; std::string& operator[](std::size_t n) { return data->at(n); } const std::string& operator[](std::size_t n) const { return data->at(n); } private: std::shared_ptr<std::vector<std::string>> data; // throws msg if data[i] isn't valid void check(size_type i, const std::string &msg) const; }; // constructors StrBlob::StrBlob() : data(std::make_shared<std::vector<std::string>>()) {} StrBlob::StrBlob(std::initializer_list<std::string> il) : data(std::make_shared<std::vector<std::string>>(il)) {} // copy assignment operator StrBlob& StrBlob::operator=(const StrBlob &rhs) { auto temp = std::make_shared<std::vector<std::string>>(*rhs.data); data = temp; return *this; } // members void StrBlob::check(size_t i, const std::string &msg) const { if (i >= data->size()) throw std::out_of_range(msg); } void StrBlob::pop_back() { check(0, "back on empty StrBlob"); data->pop_back(); } std::string& StrBlob::front() { check(0, "front on empty StrBlob"); return data->front(); } std::string& StrBlob::front() const { check(0, "front on empty StrBlob"); return data->front(); } std::string& StrBlob::back() { check(0, "back on empty StrBlob"); return data->back(); } std::string& StrBlob::back() const { check(0, "back on empty StrBlob"); return data->back(); } void StrBlob::push_back(const std::string &t) { data->push_back(t); std::cout << "bush_back(const std::string &) &\n"; } void StrBlob::push_back(std::string &&t) { data->push_back(std::move(t)); std::cout << "bush_back(const std::string &) &&\n"; } // StrBlobPtr throws an exception on attempts to access a nonexistent element class StrBlobPtr { friend bool operator==(const StrBlobPtr &, const StrBlobPtr &); friend bool operator!=(const StrBlobPtr &, const StrBlobPtr &); friend bool operator<(const StrBlobPtr &, const StrBlobPtr &); friend StrBlobPtr operator-(const StrBlobPtr &, const StrBlobPtr &); friend StrBlobPtr operator+(const StrBlobPtr &, const size_t); friend StrBlobPtr operator-(const StrBlobPtr &, const size_t); public: StrBlobPtr() : curr(0) {} StrBlobPtr(const StrBlob &a, size_t sz = 0) : wptr(a.data), curr(sz) {} std::string& operator[](std::size_t); const std::string& operator[](std::size_t) const; StrBlobPtr& operator-=(const StrBlobPtr &); StrBlobPtr& operator+=(const size_t); StrBlobPtr& operator-=(const size_t); StrBlobPtr operator++(); StrBlobPtr operator++(int); StrBlobPtr operator--(); StrBlobPtr operator--(int); std::string& operator*() const; std::string* operator->() const; private: // check returns a shared_ptr to the vector if the check succeeds std::shared_ptr<std::vector<std::string>> check(std::size_t, const std::string &) const; // store a weak_ptr, which means the underlying vector might be destroyed std::weak_ptr<std::vector<std::string>> wptr; size_t curr; // current position within the array }; std::shared_ptr<std::vector<std::string>> StrBlobPtr::check(std::size_t i, const std::string &msg) const { auto ret = wptr.lock(); // is the vector still around if (!ret) throw std::runtime_error("unbound StrBlobPtr"); if (i >= ret->size()) throw std::out_of_range(msg); return ret; // otherwise, return a shared_ptr to the vector } // prefix: return a reference to the incremented object StrBlobPtr StrBlobPtr::operator++() { check(curr, "increment past end of StrBlobPtr"); ++curr; return *this; } // postfix: increment/decrement the object but return the unchanged value StrBlobPtr StrBlobPtr::operator++(int) { auto ret = *this; ++*this; // call class' prefix increment return ret; } // prefix: return a reference to the decremented object StrBlobPtr StrBlobPtr::operator--() { check(curr, "increment past end of StrBlobPtr"); --curr; return *this; } // postfix: decrement the object but return the unchanged value StrBlobPtr StrBlobPtr::operator--(int) { auto ret = *this; --*this; // call class' prefix increment return ret; } // subscript: return reference at n std::string& StrBlobPtr::operator[](std::size_t n) { auto p = check(n, "subscript out of bound"); return (*p)[n]; } const std::string& StrBlobPtr::operator[](std::size_t n) const { auto p = check(n, "subscript out of bound"); return (*p)[n]; } StrBlobPtr& StrBlobPtr::operator-=(const StrBlobPtr &rhs) { curr -= rhs.curr; return *this; } StrBlobPtr& StrBlobPtr::operator+=(const size_t n) { curr += n; return *this; } StrBlobPtr& StrBlobPtr::operator-=(const size_t n) { curr -= n; return *this; } std::string& StrBlobPtr::operator*() const { auto p = check(curr, "dereference past end"); return (*p)[curr]; } std::string* StrBlobPtr::operator->() const { return & this->operator*(); } // these members can't be defined until StrStrBlob and StrBlobPtr are defined. StrBlobPtr StrBlob::begin() const { return StrBlobPtr(*this); } StrBlobPtr StrBlob::end() const { return StrBlobPtr(*this, data->size()); } // non-member function bool operator==(const StrBlob &lhs, const StrBlob &rhs) { return *lhs.data == *rhs.data; } bool operator!=(const StrBlob &lhs, const StrBlob &rhs) { return !(lhs == rhs); // delegates to == class operator } bool operator<(const StrBlob &lhs, const StrBlob &rhs) { return *lhs.data < *rhs.data; } bool operator==(const StrBlobPtr &lhs, const StrBlobPtr &rhs) { return *lhs == *rhs; } bool operator!=(const StrBlobPtr &lhs, const StrBlobPtr &rhs) { return !(lhs == rhs); } bool operator<(const StrBlobPtr &lhs, const StrBlobPtr &rhs) { return *lhs < *rhs; } StrBlobPtr operator-(const StrBlobPtr &lhs, const StrBlobPtr &rhs) { auto total = lhs; total -= rhs; return total; } StrBlobPtr operator+(const StrBlobPtr &lhs, const size_t n) { auto sum = lhs; sum += n; return sum; } StrBlobPtr operator-(const StrBlobPtr &lhs, const size_t n) { auto total = lhs; total -= n; return total; } #endif
[ "cdude996@gmail.com" ]
cdude996@gmail.com
bf7e32c8be35027e1662a3c14fb6c9c519bc155e
c787b20135024cd749e485bf679cd16e8cf6e302
/include/unstickymem/mode/DisabledMode.hpp
a9b7641d5183a6bbda56861903d6254873728869
[]
no_license
epeec/BWAP
d477a14209b40ceec51b41e01863a887c3c5fb7b
bd1b638f6845aff70bd7d92bcbe0cf3f5433b59f
refs/heads/master
2022-10-12T19:48:41.433031
2020-03-12T20:27:07
2020-03-12T20:27:07
270,960,300
2
2
null
null
null
null
UTF-8
C++
false
false
606
hpp
#ifndef UNSTICKYMEM_DISABLEDMODE_HPP_ #define UNSTICKYMEM_DISABLEDMODE_HPP_ #include <string> #include "unstickymem/mode/Mode.hpp" namespace unstickymem { class DisabledMode : public Mode { public: static std::string name() { return "disabled"; } static std::string description() { return "Do Nothing"; } static std::unique_ptr<Mode> createInstance() { return std::make_unique<DisabledMode>(); } po::options_description getOptions(); void printParameters(); void start(); void startMemInit(); }; } // namespace unstickymem #endif // UNSTICKYMEM_DISABLEDMODE_HPP_
[ "david.gureya@ist.utl.pt" ]
david.gureya@ist.utl.pt
6b373293bcc3eafbca7a77ecdb23d380f770c7e4
9f284dfa8a4adbca71b34ce781b2aca3959e5332
/source/include/handDriver.cpp
c7bd9ac7e54a232c61d6006aa96379e574c2dfef
[]
no_license
sapertuz/RoboticHand_OS
2cca920f9f33b70ea1b9a23b63c6c1795b974b2e
5b4988af93e3179c6666a7d53b83a60aeb509fff
refs/heads/master
2022-12-22T04:49:08.021243
2020-09-15T18:25:22
2020-09-15T18:25:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,096
cpp
/***************************** Include Files *******************************/ #include "handDriver.hpp" /************************** Function Definitions ***************************/ handDriver::handDriver() { set_control(0); // set control off initialize(); } int handDriver::initialize() { /* * Initialize the XAdc driver. * { */ int Status; ConfigPtr = XAdcPs_LookupConfig(XPAR_XADCPS_0_DEVICE_ID); if (ConfigPtr == NULL) { return XST_FAILURE; } XAdcPs_CfgInitialize(this->XAdcInstPtr, ConfigPtr, ConfigPtr->BaseAddress); /* * Self Test the XADC/ADC device */ Status = XAdcPs_SelfTest(this->XAdcInstPtr); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Enable the Channel Sequencer before configuring the Sequence * registers. */ XAdcPs_SetSequencerMode(this->XAdcInstPtr, XADCPS_SEQ_MODE_CONTINPASS); /*}*/ //motorDriver motorsHandler; this->motorsHandler.setAddress(addr_motorMod); this->motorsHandler.disableMotors(); //motorsHandler_p = &motorsHandler; /** * Initialize sensorMod * { */ // Initialize SensorMod //sensorMod sensorHandler; this->sensorHandler.setAddress(addr_sensorMod); this->sensorHandler.setDataMonitor(posIn_f, currIn_f, voltOut, pos_filt, vel_filt, curr_filt); const _real ab[2] = {a, b}; this->sensorHandler.set_Kalman(DT, R, nQ); this->sensorHandler.set_butter(ab); this->sensorHandler.set_2ADC(DEG_ADC, mA_ADC); this->calibrateCurrentS(); this->calibratePositionS(posStart_f); /*}*/ for (uint16_t i=0; i<10; i++ ){ // Sensors Update and filtering this->update_sensors(); this->sensorHandler.start(); usleep(5000); } /** * Initialize Impedance * { */ for(uint32_t nMod=0; nMod<Nmodules; nMod++){ this->ImpControllers[nMod].Configure(&this->curr_filt[nMod], &this->pos_filt[nMod], &this->vel_filt[nMod], &this->impOut[nMod], &this->imp_sp[nMod], M, B, K, DIRECT); this->ImpControllers[nMod].SetSampleTime(DT*10); } /*}*/ /** * Initialize PID * { */ for(uint32_t nMod=0; nMod<Nmodules; nMod++){ this->pidControllers[nMod].Configure( &this->pos_filt[nMod], &this->voltOut[nMod], &this->impOut[nMod], P, 0.0, 0.0, P_ON_E, DIRECT); this->pidControllers[nMod].SetSampleTime(DT*10); this->pidControllers[nMod].SetOutputLimits(outMin, outMax); } /*}*/ this->init_controllers(); this->imp_index = TRI_FINGERS; return XST_SUCCESS; } void handDriver::init_controllers(){ /** * Start SensorMod Handler and Controllers * { */ for(uint32_t nMod=0; nMod<Nmodules; nMod++){ this->ImpControllers[nMod].SetMode(AUTOMATIC); this->pidControllers[nMod].SetMode(AUTOMATIC); } this->init_impOut(); // start sp for position control /*}*/ // Init Variables for (uint32_t j=0; j<Nmodules; j++){ this->voltOut[j]= 0; this->imp_sp[j] = 0; } } void handDriver::set_control(uint8_t _control_t) { control_t = _control_t; this->shutdown(); for(uint32_t nMod=0; nMod<Nmodules; nMod++){ this->ImpControllers[nMod].Restart(); this->imp_sp[nMod] = 0.0; } } void handDriver::calibrateCurrentS() { uint16_t nData = 10; // 100 Data for calibrate uint16_t calibrate_delay = 10000; // 10 ms between each measure uint32_t cenP1_acum=0, cenC_acum=0, cenI1_acum=0; this->shutdown(); // Calibrate Current Sensors for (uint32_t j = 0; j < nData; j++){ //this->update_sensors(); cenP1_acum += XAdcPs_GetAdcData(XAdcInstPtr,anCurr_P1); cenC_acum += XAdcPs_GetAdcData(XAdcInstPtr,anCurr_C); cenI1_acum += XAdcPs_GetAdcData(XAdcInstPtr,anCurr_I1); usleep(calibrate_delay); } this->cenCurr_f[i_P1] += (_real)cenP1_acum/(_real)nData; this->cenCurr_f[i_C] += (_real)cenC_acum /(_real)nData; this->cenCurr_f[i_I1] += (_real)cenI1_acum/(_real)nData; for (uint32_t i = 0; i < Nmodules; i++) this->sensorHandler.set_centerCurr(cenCurr_f[i],i); } void handDriver::calibratePositionS(_real * poStart){ // Calibrate start value of position sensors for (uint32_t i = 0; i < Nmodules; i++) this->sensorHandler.set_positionStart(poStart[i],i); } void handDriver::getSensors(_real *_posIn_f,_real *_currIn_f) { for (uint16_t i=0; i<Nmodules; i++){ _posIn_f[i] = this->posIn_f[i]; _currIn_f[i] = this->currIn_f[i]; } } void handDriver::getSenFilters(_real *_pos_filt, _real *_vel_filt, _real *_curr_filt) { for (uint16_t i=0; i<Nmodules; i++){ _pos_filt[i] = this->pos_filt[i] ; _vel_filt[i] = this->vel_filt[i] ; _curr_filt[i] = this->curr_filt[i]; } } void handDriver::getControl(_real *_voltOut, _real *_imp_sp,_real *_impOut) { for (uint16_t i=0; i<Nmodules; i++){ _voltOut[i] = this->voltOut[i]; _imp_sp[i] = this->imp_sp[i] ; _impOut[i] = this->impOut[i] ; } } void handDriver::compute(){ // Sensors Update and filtering this->update_sensors(); this->sensorHandler.start(); // COntrol Action switch (control_t) { case UNOPERATIONAL: this->shutdown(); break; case MANUAL_MOTORS: // Manual Control for (uint32_t nMod=0; nMod<Nmodules; nMod++){ this->motorsHandler.setMotor(nMod, voltOut[nMod]); } break; case P_ONLY: // P controller for (uint32_t nMod=0; nMod<Nmodules; nMod++){ this->pidControllers[nMod].Compute(); this->motorsHandler.setMotor(nMod, voltOut[nMod]); } break; case FULL_IMPEDANCE: // Impedance controller for (uint32_t nMod=0; nMod<Nmodules; nMod++){ uint16_t flag = (this->imp_index >> nMod) & 1; if (flag){ this->ImpControllers[nMod].Compute(); this->pidControllers[nMod].Compute(); this->motorsHandler.setMotor(nMod, voltOut[nMod]); } } break; default: this->shutdown(); break; } } void handDriver::shutdown(){ motorsHandler.disableMotors(); for (uint32_t nMod=0; nMod<Nmodules; nMod++) voltOut[nMod] = 0.0; } void handDriver::update_sensors(){ this->currIn_f[i_P1]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anCurr_P1); this->currIn_f[i_C]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anCurr_C); this->currIn_f[i_I1]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anCurr_I1); this->posIn_f[i_P1]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_P1);// 3.3v this->posIn_f[i_I1]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_I1);// 3.3v this->posIn_f[i_C]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_C); // 3.3v this->posIn_f[i_A]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_A); // 3.3v this->posIn_f[i_M]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_M); // 3.3v this->posIn_f[i_P2]= (_real)(65535 -XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_P2));// 3.3v } void handDriver::init_impOut(){ this->shutdown(); this->impOut[i_P1]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_P1)*DEG_ADC; // 3.3v this->impOut[i_I1]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_I1)*DEG_ADC; // 3.3v this->impOut[i_C]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_C) *DEG_ADC; // 3.3v this->impOut[i_A]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_A) *DEG_ADC; // 3.3v this->impOut[i_M]= (_real)XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_M) *DEG_ADC; // 3.3v this->impOut[i_P2]= (_real)(65535 - XAdcPs_GetAdcData(this->XAdcInstPtr,anPos_P2))*DEG_ADC; // 3.3v for (uint16_t nMod=0; nMod<Nmodules; nMod++){ this->ImpControllers[nMod].Restart(); } } void handDriver::set_impFingers(uint8_t impFingers){ this->imp_index = impFingers; } int handDriver::set_currSP(_real *currSP){ if (this->control_t == FULL_IMPEDANCE) { for(uint16_t nMod=0; nMod<Nmodules; nMod++){ this->imp_sp[nMod] = currSP[nMod]; } return XST_SUCCESS; }else { return XST_FAILURE; } } int handDriver::set_posSP(_real *posSP){ if (this->control_t == P_ONLY) { for(uint16_t nMod=0; nMod<Nmodules; nMod++){ this->impOut[nMod] = posSP[nMod]; } return XST_SUCCESS; }else { return XST_FAILURE; } } int handDriver::set_motorV(_real *volt){ if (this->control_t == MANUAL_MOTORS) { for(uint16_t nMod=0; nMod<Nmodules; nMod++){ this->voltOut[nMod] = volt[nMod]; } return XST_SUCCESS; }else { return XST_FAILURE; } } void handDriver::printConfig(){ this->sensorHandler.printConfig(); }
[ "sapertuz@gmail.com" ]
sapertuz@gmail.com
9cb592f5457c2a6e86daeedd40485aa3db772a62
a04796e9ac552cb0417255c636a8f9c5d53b89d4
/src/Bomb.h
e6d389be044cd1d5889c01500cfd9ec7e7390f89
[]
no_license
daniilpastukhov/bomberman
388e39aacdf3baa44eebf697419c213384620ea0
b120cf66f4c65a2078465bdd7ca9083024c50c7f
refs/heads/master
2020-05-22T17:56:22.685422
2019-07-23T09:18:00
2019-07-23T09:18:00
186,461,240
0
0
null
null
null
null
UTF-8
C++
false
false
1,407
h
// // Created by Daniil Pastukhov on 2019-04-25. // #ifndef BOMBERMAN_BOMB_H #define BOMBERMAN_BOMB_H //#include "Types.h" #include "Object.h" #include "Player.h" #include <unistd.h> #include <ncurses.h> #include <algorithm> /** * @brief A class to represent a bomb. */ class Bomb : public Object { public: /** * @param[in] _x Coordinate x. * @param[in] _y Coordinate y. * @param[in] _t Explode time. */ Bomb(int _x, int _y, int _t); char symbol() const override; Colors color() const override; /** * @brief Detonate a bomb and destroy all objects it collides with. * @param[in] radius Radius of explosion. * @param[in] g Instance of the game. * @param[in] p Player who the bomb belongs to. */ void detonate(int radius, Game &g, Player &p); /** * @brief Decrease bomb timer. */ void decreaseTimer(); /** * @brief Check collision with a bomb. * @param[in] i Iterator to the object from game class. * @param[in] g Instance of the game. * @param[in] p Player who the bomb belongs to. * @return True if another bomb was detonated, false otherwise. */ bool checkBombCollision(std::vector<std::shared_ptr<Object>>::iterator &i, Game &g, Player &p); // Getters int getTimer() const; private: int explode_time; bool was_detonated; }; #endif //BOMBERMAN_BOMB_H
[ "pastudan@fit.cvut.cz" ]
pastudan@fit.cvut.cz
632fc67b8e2abb63726d57de7225156435eeae99
1942a0d16bd48962e72aa21fad8d034fa9521a6c
/aws-cpp-sdk-ec2/source/model/DeleteCustomerGatewayRequest.cpp
5649d6f4a123a695400ed4d17cc6041aec9a2ada
[ "Apache-2.0", "JSON", "MIT" ]
permissive
yecol/aws-sdk-cpp
1aff09a21cfe618e272c2c06d358cfa0fb07cecf
0b1ea31e593d23b5db49ee39d0a11e5b98ab991e
refs/heads/master
2021-01-20T02:53:53.557861
2018-02-11T11:14:58
2018-02-11T11:14:58
83,822,910
0
1
null
2017-03-03T17:17:00
2017-03-03T17:17:00
null
UTF-8
C++
false
false
1,368
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/ec2/model/DeleteCustomerGatewayRequest.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> using namespace Aws::EC2::Model; using namespace Aws::Utils; DeleteCustomerGatewayRequest::DeleteCustomerGatewayRequest() : m_dryRun(false), m_dryRunHasBeenSet(false), m_customerGatewayIdHasBeenSet(false) { } Aws::String DeleteCustomerGatewayRequest::SerializePayload() const { Aws::StringStream ss; ss << "Action=DeleteCustomerGateway&"; if(m_dryRunHasBeenSet) { ss << "DryRun=" << std::boolalpha << m_dryRun << "&"; } if(m_customerGatewayIdHasBeenSet) { ss << "CustomerGatewayId=" << StringUtils::URLEncode(m_customerGatewayId.c_str()) << "&"; } ss << "Version=2016-11-15"; return ss.str(); }
[ "henso@amazon.com" ]
henso@amazon.com
5039a15a57f8ed82ab6743b7742a8110fb239f13
621aaff052be79515ea25cb6c5559ec98402fbde
/ED/Monitoria01 - Introdução/day8++/Q18.cpp
e7596cf273a277878e0e0d7a9207467ff6252e66
[]
no_license
HenrickyL/monitoria-2021.1
bf2ba3688d30ea36fbcceb97c4af7af0373a283a
a4211eecf22908e5da976fc26f76947738e2901a
refs/heads/main
2023-07-07T11:24:48.756459
2021-08-13T23:16:05
2021-08-13T23:16:05
365,626,249
1
0
null
null
null
null
UTF-8
C++
false
false
1,317
cpp
#include<iostream> using namespace std; int** criaMatriz(int n){ //crio a matriz int **M = new int*[n]; for(int i=0; i<n; i++){ //criando os vetores M[i]= new int[n]; } return M; } void setMatriz(int** M, int n){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cin>>M[i][j]; } } } void printMatriz(int**M, int n){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cout<<M[i][j]<< " "; } cout<<"\n"; } } void deleteMatriz(int** M, int n){ for(int i=0; i< n; i++) delete[] M[i]; delete[] M; } int** somaMatriz(int** A, int** B, int n){ //cria a matriz int** C = new int*[n]; for(int i=0;i<n;i++){ //cria os ponteiros internos C[i] = new int[n]; for(int j=0;j<n;j++){ //set valores C[i][j] = A[i][j] + B[i][j]; } } return C; } int main(){ int n; cin>>n; int** A = criaMatriz(n); setMatriz(A,n); int** B = criaMatriz(n); setMatriz(B,n); int** C = somaMatriz(A,B,n); cout<<"A\n"; printMatriz(A,n); cout<<"B\n"; printMatriz(B,n); cout<<"C=A+B\n"; printMatriz(C,n); deleteMatriz(A,n); deleteMatriz(B,n); deleteMatriz(C,n); return 0; }
[ "henrickyl1@gmail.com" ]
henrickyl1@gmail.com
c5849c6201c5137ed8a4713b4578c6f4fbaa777b
418da2b13b3a937402c0cc4ee1719bfae9bae03d
/codechef/july challenge 2020/ADAKING.cpp
9c0d635be322933ae8ec2b8483a71a525dedec2f
[]
no_license
git-shashwat/Competitive-Programming
d66890a07a56cdd7150524f38d768b3dc714e6d5
bd29038221275ee5f8f59c7bdfc70a26aeef0b89
refs/heads/master
2021-06-09T22:24:22.830384
2021-05-12T10:54:18
2021-05-12T10:54:18
178,396,122
3
0
null
null
null
null
UTF-8
C++
false
false
740
cpp
//https://www.codechef.com/JULY20B/problems/ADAKING #include<bits/stdc++.h> #define FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define test int t; cin>>t; while(t--) #define loop(a,b) for(int i=a;i<b;++i) #define loop0(b) for(int i=0;i<b;++i) #define MOD 1000000007 #define ull unsigned long long #define ll long long #define all(x) x.begin(), x.end() #define pb push_back #define po pop_back using namespace std; int main(){ test { int k; cin>>k; for (int i = 0; i < 8; ++i) { for (int j = 0; j < 8; ++j) { if (i == 0 && j == 0) { cout<<"O"; --k; } else { if(--k >= 0) { cout<<"."; } else { cout<<"X"; } } } cout<<"\n"; } } return 0; }
[ "noreply@github.com" ]
git-shashwat.noreply@github.com
0713126296e623dd6e106461c5cd3eb4f813c402
4bd63b62ab5ebd08f978813db26d8f6700533470
/App/statespace.cpp
0c2f86399982ba0b8189f5039feed9918ac61cdc
[]
no_license
lacriment/HesitantWarrior
f43cc4f0e62f447b88405bb16dacc5d7e783dc4c
25e2b599bb6270c0e59d0756ad4d9672c95f84e2
refs/heads/master
2021-01-21T06:39:32.018120
2017-05-28T00:36:14
2017-05-28T00:36:14
91,580,472
3
0
null
null
null
null
UTF-8
C++
false
false
1,756
cpp
#include "statespace.h" Player StateSpace::getPlayer() const { return player; } void StateSpace::setPlayerSpeed(int s) { this->player.speed = s; } // Has the player arrived to the finishing point? bool StateSpace::isItGoal() { return finishPoint.first == player.position.first && finishPoint.second == player.position.second; } bool StateSpace::equals(StateSpace *state) { if (state->player.position == player.position && state->getPlayer().speed == player.speed) { return true; } return false; } // Initilize the starting point and finishing point void StateSpace::setPlayer(const Player &value) { player = value; } void StateSpace::setPlayerPosition(int x, int y) { this->player.position = qMakePair(x, y); } std::array<std::array<State, 8>, 8> StateSpace::getBoard() const { return board; } void StateSpace::setBoard(const std::array<std::array<State, 8>, 8> &value) { board = value; } void StateSpace::setFinishPoint(QPair<int, int> point) { this->finishPoint= point; } void StateSpace::setFinishPoint(int x, int y) { this->finishPoint.first = x; this->finishPoint.second = y; } StateSpace::StateSpace(QObject *parent) : QObject(parent) { this->player.speed = 2; } QPair<int, int> StateSpace::getFinishPoint() const { return finishPoint; } State StateSpace::getBoardElement(int x, int y) { return this->board[x][y]; } State StateSpace::getBoardElement(QPair<int, int> pos) { return this->board[pos.first][pos.second]; } void StateSpace::setBoardElement(int x, int y, State value) { this->board[x][y] = value; } void StateSpace::setBoardElement(QPair<int, int> pos, State value) { this->board[pos.first][pos.second] = value; }
[ "lacriment@gmail.com" ]
lacriment@gmail.com
609849063f9e7234617c4b0d1592966f1ba71a8a
d9a642ed3b0047b56045a05e243a018069dc8133
/source code/2096_내려가기.cpp
744bfefe0be34ba79399d22efc80f5fad6b200e0
[]
no_license
kingkk31/BOJ
7562c7b92a1761120ad159653107e0ec23be2b29
03335203cd880607803d28a1fb5cd862e7013e4b
refs/heads/master
2021-05-04T11:39:05.781066
2018-01-09T16:52:15
2018-01-09T16:52:15
49,325,443
2
0
null
null
null
null
UTF-8
C++
false
false
1,059
cpp
#include <iostream> #include <stdio.h> #include <queue> #include <vector> #include <set> #include <list> #include <string> #include <string.h> #include <math.h> #include <algorithm> #pragma warning(disable:4996) using namespace std; int main(void) { int n; cin >> n; vector<int> vt1(3); //min vector<int> vt2(3); //max vector<int> temp(3); int f, s, t; cin >> f >> s >> t; vt1[0] = vt2[0] = f; vt1[1] = vt2[1] = s; vt1[2] = vt2[2] = t; for (int i = 1; i < n; i++) { int first, second, third; cin >> first >> second >> third; temp[0] = min(vt1[0], vt1[1]) + first; temp[1] = min(vt1[0], min(vt1[1], vt1[2])) + second; temp[2] = min(vt1[1], vt1[2]) + third; vt1[0] = temp[0]; vt1[1] = temp[1]; vt1[2] = temp[2]; temp[0] = max(vt2[0], vt2[1]) + first; temp[1] = max(vt2[0], max(vt2[1], vt2[2])) + second; temp[2] = max(vt2[1], vt2[2]) + third; vt2[0] = temp[0]; vt2[1] = temp[1]; vt2[2] = temp[2]; } cout << max(vt2[0], max(vt2[1], vt2[2])) << " " << min(vt1[0], min(vt1[1], vt1[2])) << endl; return 0; }
[ "kingkk31@naver.com" ]
kingkk31@naver.com
8f9a387676b99cf7ee2f525fc59f4d5e476484d5
07ba30c8beca93faf618e08cc2669c2e242e9b76
/Head.h
ee0724faf6bc2c5d27c97ae0ce6650afcdfed519
[]
no_license
caldi5/Snake
ec3b1b3efedd4426e70a63a813b06d55e6aaaa2c
ea77cc899513ee7b6be716add4a1d7a778ada1ce
refs/heads/master
2021-01-10T12:59:42.598829
2016-02-10T20:24:36
2016-02-10T20:24:36
51,469,249
0
0
null
null
null
null
UTF-8
C++
false
false
205
h
#pragma once #include "SnakeSquare.h" class Head : public SnakeSquare { public: Head(int x = 0, int y = 0, int sizeX = 30, int sizeY = 30, sf::Color = sf::Color::Red); ~Head(); protected: private: };
[ "andweij@gmail.com" ]
andweij@gmail.com
d456313b2c4836b20560969867d24772b26d1191
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/httpd/gumtree/httpd_repos_function_362_httpd-2.0.43.cpp
5404fcd36158bff737cd64d50b3e8aa222a8d165
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
943
cpp
dav_error *dav_open_propdb(request_rec *r, dav_lockdb *lockdb, const dav_resource *resource, int ro, apr_array_header_t * ns_xlate, dav_propdb **p_propdb) { dav_propdb *propdb = apr_pcalloc(r->pool, sizeof(*propdb)); *p_propdb = NULL; #if DAV_DEBUG if (resource->uri == NULL) { return dav_new_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, 0, "INTERNAL DESIGN ERROR: resource must define " "its URI."); } #endif propdb->r = r; propdb->p = r->pool; /* ### get rid of this */ propdb->resource = resource; propdb->ns_xlate = ns_xlate; propdb->db_hooks = DAV_GET_HOOKS_PROPDB(r); propdb->lockdb = lockdb; /* always defer actual open, to avoid expense of accessing db * when only live properties are involved */ propdb->deferred = 1; /* ### what to do about closing the propdb on server failure? */ *p_propdb = propdb; return NULL; }
[ "993273596@qq.com" ]
993273596@qq.com
0ad25c63066f100988e1f3d1769d61191502ea6d
7e22725944fb5024ace01a533af24d89b67c4f48
/400-499/432.all-o-one-data-structure.cpp
a140977af082d4b601681496128ee6bd40bcbc9e
[]
no_license
egg0315/LeetCode
8746892eea594f86cf86184b10849129c819e813
e4361f897ea8694d2e60953a6cb3a9dca54edb65
refs/heads/master
2020-07-22T14:09:35.243206
2019-11-05T08:33:30
2019-11-05T08:33:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,766
cpp
/* * @lc app=leetcode id=432 lang=cpp * * [432] All O`one Data Structure * * https://leetcode.com/problems/all-oone-data-structure/description/ * * algorithms * Hard (30.49%) * Likes: 409 * Dislikes: 59 * Total Accepted: 22K * Total Submissions: 71.8K * Testcase Example: '["AllOne","getMaxKey","getMinKey"]\n[[],[],[]]' * * Implement a data structure supporting the following operations: * * * * Inc(Key) - Inserts a new key with value 1. Or increments an existing key by * 1. Key is guaranteed to be a non-empty string. * Dec(Key) - If Key's value is 1, remove it from the data structure. Otherwise * decrements an existing key by 1. If the key does not exist, this function * does nothing. Key is guaranteed to be a non-empty string. * GetMaxKey() - Returns one of the keys with maximal value. If no element * exists, return an empty string "". * GetMinKey() - Returns one of the keys with minimal value. If no element * exists, return an empty string "". * * * * * Challenge: Perform all these in O(1) time complexity. * */ class AllOne { public: /** Initialize your data structure here. */ AllOne() { } /** Inserts a new key <Key> with value 1. Or increments an existing key by 1. */ void inc(string key) { // new key if (iters.find(key) == iters.end()) { if (buckets.empty() || buckets.begin()->first != 1) { buckets.insert(buckets.begin(), {1, {key}}); } else { buckets.begin()->second.insert(key); } iters[key] = buckets.begin(); } else { auto it = iters[key]; auto next = it; ++next; if (next != buckets.end() && next->first == it->first + 1) { next->second.insert(key); } else { next = buckets.insert(next, {it->first + 1, {key}}); } iters[key] = next; // deal with old it->second.erase(key); if (it->second.empty()) buckets.erase(it); } } /** Decrements an existing key by 1. If Key's value is 1, remove it from the data structure. */ void dec(string key) { if (iters.find(key) != iters.end()) { auto it = iters[key], prev = it; if (it != buckets.begin()) { --prev; } if (it->first != 1) { if (it == buckets.begin() || prev->first != it->first - 1) { prev = buckets.insert(it, {it->first - 1, {}}); } prev->second.insert(key); iters[key] = prev; } else { iters.erase(key); } it->second.erase(key); if (it->second.empty()) { buckets.erase(it); } } } /** Returns one of the keys with maximal value. */ string getMaxKey() { return buckets.empty() ? "" : *buckets.rbegin()->second.begin(); } /** Returns one of the keys with Minimal value. */ string getMinKey() { return buckets.empty() ? "" : *buckets.begin()->second.begin(); } private: list<pair<int, unordered_set<string>>> buckets; unordered_map<string, list<pair<int, unordered_set<string>>>::iterator> iters; }; /** * Your AllOne object will be instantiated and called as such: * AllOne* obj = new AllOne(); * obj->inc(key); * obj->dec(key); * string param_3 = obj->getMaxKey(); * string param_4 = obj->getMinKey(); */
[ "cf2200@gmail.com" ]
cf2200@gmail.com
38fb57b0a2eed5c18b20dbf530f65f413c94172a
02d25808b6a8f0d0ba4fa4b061384934f832f57d
/src/person.cpp
7f6015a620808f282ac278677efe4d1872a7de66
[]
no_license
Alexandra984/UniversityManager
9e8fe4352242c8d359e08f8a6e86b31d8fbd2146
14817464491b27e85a4ad5832303aa77a6795452
refs/heads/master
2020-04-11T19:40:36.672928
2019-01-07T21:41:52
2019-01-07T21:41:52
162,043,061
0
0
null
null
null
null
UTF-8
C++
false
false
1,048
cpp
#include "person.hpp" #include <iostream> Person::~Person() {} Person:: Person(const std::string& first_name, const std::string& last_name, const std::string& email, long long cnp) : _first_name(first_name), _last_name(last_name), _email(email), _cnp(cnp) { } std::string Person::GetFirstName() { return _first_name; } std::string Person::GetLastName() { return _last_name; } std::string Person::GetEmail() { return _email; } int Person::GetCnp() { return _cnp; } void Person::SetFirstName(const std::string& first_name) { _first_name = first_name; } void Person::SetLastName(const std::string& last_name) { _last_name = last_name; } void Person::SetEmail(const std::string& email) { _email = email; } void Person::SetCnp(int cnp) { _cnp = cnp; } std::ostream& operator<<(std::ostream& out, Person& person) { out << person._first_name << ' ' << person._last_name << '\n'; out << "Email: " << person._email << '\n'; out << "CNP: " << person._cnp << '\n'; person.PrintAdditional(out); return out; }
[ "alexandragrecu984@yahoo.com" ]
alexandragrecu984@yahoo.com
b56c5dfb003333cf75f18956f3cb9dca5f4bdbdd
e9de846258f623bf6b43cb24aec3d299d2db781d
/CVMFC/CVMFC/Processing.cpp
774645884dcd4ee8c99f1e74f4e4a96c3d69a8e1
[]
no_license
MathsionYang/OpenCV_-picture-processing-
2a36db8c6fdfc7ba39e877e10d3cbf138176ed61
d3aface11a4562350f9f406afff0464cb89c9f01
refs/heads/master
2020-06-17T05:21:58.555905
2019-07-08T13:04:19
2019-07-08T13:04:19
195,810,380
8
0
null
null
null
null
GB18030
C++
false
false
11,622
cpp
#include "stdafx.h" //--------------------------------------------------------- LPBITMAPINFO CtreateMapInfo(IplImage* workImg,int flag) { // 建立位图信息 BITMAPINFOHEADER BIH={40,1,1,1,8,0,0,0,0,0,0}; LPBITMAPINFO lpBmi; int wid,hei,bits,colors,i; wid =workImg->width; hei =workImg->height; bits=workImg->depth*workImg->nChannels; if (bits>8) colors=0; else colors=1<<bits; lpBmi=(LPBITMAPINFO) malloc(40+4*colors); BIH.biWidth =wid; BIH.biHeight =hei; BIH.biBitCount=(BYTE) bits; memcpy(lpBmi,&BIH,40); // 复制位图信息头 if (bits==8) { // 256 色位图 if (flag==1) { // 设置灰阶调色板 for (i=0;i<256;i++) { VgaColorTab[i].rgbRed=VgaColorTab[i].rgbGreen= VgaColorTab[i].rgbBlue=(BYTE) i; } memcpy(lpBmi->bmiColors,VgaColorTab,1024); } else if (flag==2) { // 设置默认调色板 memcpy(lpBmi->bmiColors,VgaDefPal,1024); } else if (flag==3) { // 设置自定义调色板 memcpy(lpBmi->bmiColors,VgaColorTab,1024); } } return(lpBmi); } int imageType(IplImage* p) { int i,j,k,bpl,n,pg[256]; BYTE *buf; k=p->nChannels; if (k==1) { // 检查二值图像 for (i=0;i<256;i++) pg[i]=0; buf=(BYTE*)p->imageData; bpl=p->widthStep; for (i=0;i<p->height;i++) { for (j=0;j<p->width;j++) pg[buf[j]]++; buf+=bpl; } for (i=0,n=0;i<256;i++) { if (pg[i]) n++; } if (n==2) k=-1; // 二值图像 } return(k); } int imageClone(IplImage* pi,IplImage** ppo) // 复制 IplImage 位图 { if (*ppo) { cvReleaseImage(ppo); // 释放原来位图 } (*ppo) = cvCloneImage(pi); // 复制新位图 return(1); } int imageReplace(IplImage* pi,IplImage** ppo) // 位图替换 { if (*ppo) cvReleaseImage(ppo); // 释放原来位图 (*ppo) = pi; // 位图换名 return(1); } //--------------------------------------------------------- // VGA 256色默认调色板数据 RGBQUAD VgaDefPal[256] = { {0x00,0x00,0x00,0x00},{0xa8,0x00,0x00,0x00},{0x00,0xa8,0x00,0x00},{0xa8,0xa8,0x00,0x00}, {0x00,0x00,0xa8,0x00},{0xa8,0x00,0xa8,0x00},{0x00,0x54,0xa8,0x00},{0xa8,0xa8,0xa8,0x00}, {0x54,0x54,0x54,0x00},{0xfc,0x54,0x54,0x00},{0x54,0xfc,0x54,0x00},{0xfc,0xfc,0x54,0x00}, {0x54,0x54,0xfc,0x00},{0xfc,0x54,0xfc,0x00},{0x54,0xfc,0xfc,0x00},{0xfc,0xfc,0xfc,0x00}, {0x00,0x00,0x00,0x00},{0x14,0x14,0x14,0x00},{0x20,0x20,0x20,0x00},{0x2c,0x2c,0x2c,0x00}, {0x38,0x38,0x38,0x00},{0x44,0x44,0x44,0x00},{0x50,0x50,0x50,0x00},{0x60,0x60,0x60,0x00}, {0x70,0x70,0x70,0x00},{0x80,0x80,0x80,0x00},{0x90,0x90,0x90,0x00},{0xa0,0xa0,0xa0,0x00}, {0xb4,0xb4,0xb4,0x00},{0xc8,0xc8,0xc8,0x00},{0xe0,0xe0,0xe0,0x00},{0xfc,0xfc,0xfc,0x00}, {0xfc,0x00,0x00,0x00},{0xfc,0x00,0x40,0x00},{0xfc,0x00,0x7c,0x00},{0xfc,0x00,0xbc,0x00}, {0xfc,0x00,0xfc,0x00},{0xbc,0x00,0xfc,0x00},{0x7c,0x00,0xfc,0x00},{0x40,0x00,0xfc,0x00}, {0x00,0x00,0xfc,0x00},{0x00,0x40,0xfc,0x00},{0x00,0x7c,0xfc,0x00},{0x00,0xbc,0xfc,0x00}, {0x00,0xfc,0xfc,0x00},{0x00,0xfc,0xbc,0x00},{0x00,0xfc,0x7c,0x00},{0x00,0xfc,0x40,0x00}, {0x00,0xfc,0x00,0x00},{0x40,0xfc,0x00,0x00},{0x7c,0xfc,0x00,0x00},{0xbc,0xfc,0x00,0x00}, {0xfc,0xfc,0x00,0x00},{0xfc,0xbc,0x00,0x00},{0xfc,0x7c,0x00,0x00},{0xfc,0x40,0x00,0x00}, {0xfc,0x7c,0x7c,0x00},{0xfc,0x7c,0x9c,0x00},{0xfc,0x7c,0xbc,0x00},{0xfc,0x7c,0xdc,0x00}, {0xfc,0x7c,0xfc,0x00},{0xdc,0x7c,0xfc,0x00},{0xbc,0x7c,0xfc,0x00},{0x9c,0x7c,0xfc,0x00}, {0x7c,0x7c,0xfc,0x00},{0x7c,0x9c,0xfc,0x00},{0x7c,0xbc,0xfc,0x00},{0x7c,0xdc,0xfc,0x00}, {0x7c,0xfc,0xfc,0x00},{0x7c,0xfc,0xdc,0x00},{0x7c,0xfc,0xbc,0x00},{0x7c,0xfc,0x9c,0x00}, {0x7c,0xfc,0x7c,0x00},{0x9c,0xfc,0x7c,0x00},{0xbc,0xfc,0x7c,0x00},{0xdc,0xfc,0x7c,0x00}, {0xfc,0xfc,0x7c,0x00},{0xfc,0xdc,0x7c,0x00},{0xfc,0xbc,0x7c,0x00},{0xfc,0x9c,0x7c,0x00}, {0xfc,0xb4,0xb4,0x00},{0xfc,0xb4,0xc4,0x00},{0xfc,0xb4,0xd8,0x00},{0xfc,0xb4,0xe8,0x00}, {0xfc,0xb4,0xfc,0x00},{0xe8,0xb4,0xfc,0x00},{0xd8,0xb4,0xfc,0x00},{0xc4,0xb4,0xfc,0x00}, {0xb4,0xb4,0xfc,0x00},{0xb4,0xc4,0xfc,0x00},{0xb4,0xd8,0xfc,0x00},{0xb4,0xe8,0xfc,0x00}, {0xb4,0xfc,0xfc,0x00},{0xb4,0xfc,0xe8,0x00},{0xb4,0xfc,0xd8,0x00},{0xb4,0xfc,0xc4,0x00}, {0xb4,0xfc,0xb4,0x00},{0xc4,0xfc,0xb4,0x00},{0xd8,0xfc,0xb4,0x00},{0xe8,0xfc,0xb4,0x00}, {0xfc,0xfc,0xb4,0x00},{0xfc,0xe8,0xb4,0x00},{0xfc,0xd8,0xb4,0x00},{0xfc,0xc4,0xb4,0x00}, {0x70,0x00,0x00,0x00},{0x70,0x00,0x1c,0x00},{0x70,0x00,0x38,0x00},{0x70,0x00,0x54,0x00}, {0x70,0x00,0x70,0x00},{0x54,0x00,0x70,0x00},{0x38,0x00,0x70,0x00},{0x1c,0x00,0x70,0x00}, {0x00,0x00,0x70,0x00},{0x00,0x1c,0x70,0x00},{0x00,0x38,0x70,0x00},{0x00,0x54,0x70,0x00}, {0x00,0x70,0x70,0x00},{0x00,0x70,0x54,0x00},{0x00,0x70,0x38,0x00},{0x00,0x70,0x1c,0x00}, {0x00,0x70,0x00,0x00},{0x1c,0x70,0x00,0x00},{0x38,0x70,0x00,0x00},{0x54,0x70,0x00,0x00}, {0x70,0x70,0x00,0x00},{0x70,0x54,0x00,0x00},{0x70,0x38,0x00,0x00},{0x70,0x1c,0x00,0x00}, {0x70,0x38,0x38,0x00},{0x70,0x38,0x44,0x00},{0x70,0x38,0x54,0x00},{0x70,0x38,0x60,0x00}, {0x70,0x38,0x70,0x00},{0x60,0x38,0x70,0x00},{0x54,0x38,0x70,0x00},{0x44,0x38,0x70,0x00}, {0x38,0x38,0x70,0x00},{0x38,0x44,0x70,0x00},{0x38,0x54,0x70,0x00},{0x38,0x60,0x70,0x00}, {0x38,0x70,0x70,0x00},{0x38,0x70,0x60,0x00},{0x38,0x70,0x54,0x00},{0x38,0x70,0x44,0x00}, {0x38,0x70,0x38,0x00},{0x44,0x70,0x38,0x00},{0x54,0x70,0x38,0x00},{0x60,0x70,0x38,0x00}, {0x70,0x70,0x38,0x00},{0x70,0x60,0x38,0x00},{0x70,0x54,0x38,0x00},{0x70,0x44,0x38,0x00}, {0x70,0x50,0x50,0x00},{0x70,0x50,0x58,0x00},{0x70,0x50,0x60,0x00},{0x70,0x50,0x68,0x00}, {0x70,0x50,0x70,0x00},{0x68,0x50,0x70,0x00},{0x60,0x50,0x70,0x00},{0x58,0x50,0x70,0x00}, {0x50,0x50,0x70,0x00},{0x50,0x58,0x70,0x00},{0x50,0x60,0x70,0x00},{0x50,0x68,0x70,0x00}, {0x50,0x70,0x70,0x00},{0x50,0x70,0x68,0x00},{0x50,0x70,0x60,0x00},{0x50,0x70,0x58,0x00}, {0x50,0x70,0x50,0x00},{0x58,0x70,0x50,0x00},{0x60,0x70,0x50,0x00},{0x68,0x70,0x50,0x00}, {0x70,0x70,0x50,0x00},{0x70,0x68,0x50,0x00},{0x70,0x60,0x50,0x00},{0x70,0x58,0x50,0x00}, {0x40,0x00,0x00,0x00},{0x40,0x00,0x10,0x00},{0x40,0x00,0x20,0x00},{0x40,0x00,0x30,0x00}, {0x40,0x00,0x40,0x00},{0x30,0x00,0x40,0x00},{0x20,0x00,0x40,0x00},{0x10,0x00,0x40,0x00}, {0x00,0x00,0x40,0x00},{0x00,0x10,0x40,0x00},{0x00,0x20,0x40,0x00},{0x00,0x30,0x40,0x00}, {0x00,0x40,0x40,0x00},{0x00,0x40,0x30,0x00},{0x00,0x40,0x20,0x00},{0x00,0x40,0x10,0x00}, {0x00,0x40,0x00,0x00},{0x10,0x40,0x00,0x00},{0x20,0x40,0x00,0x00},{0x30,0x40,0x00,0x00}, {0x40,0x40,0x00,0x00},{0x40,0x30,0x00,0x00},{0x40,0x20,0x00,0x00},{0x40,0x10,0x00,0x00}, {0x40,0x20,0x20,0x00},{0x40,0x20,0x28,0x00},{0x40,0x20,0x30,0x00},{0x40,0x20,0x38,0x00}, {0x40,0x20,0x40,0x00},{0x38,0x20,0x40,0x00},{0x30,0x20,0x40,0x00},{0x28,0x20,0x40,0x00}, {0x20,0x20,0x40,0x00},{0x20,0x28,0x40,0x00},{0x20,0x30,0x40,0x00},{0x20,0x38,0x40,0x00}, {0x20,0x40,0x40,0x00},{0x20,0x40,0x38,0x00},{0x20,0x40,0x30,0x00},{0x20,0x40,0x28,0x00}, {0x20,0x40,0x20,0x00},{0x28,0x40,0x20,0x00},{0x30,0x40,0x20,0x00},{0x38,0x40,0x20,0x00}, {0x40,0x40,0x20,0x00},{0x40,0x38,0x20,0x00},{0x40,0x30,0x20,0x00},{0x40,0x28,0x20,0x00}, {0x40,0x2c,0x2c,0x00},{0x40,0x2c,0x30,0x00},{0x40,0x2c,0x34,0x00},{0x40,0x2c,0x3c,0x00}, {0x40,0x2c,0x40,0x00},{0x3c,0x2c,0x40,0x00},{0x34,0x2c,0x40,0x00},{0x30,0x2c,0x40,0x00}, {0x2c,0x2c,0x40,0x00},{0x2c,0x30,0x40,0x00},{0x2c,0x34,0x40,0x00},{0x2c,0x3c,0x40,0x00}, {0x2c,0x40,0x40,0x00},{0x2c,0x40,0x3c,0x00},{0x2c,0x40,0x34,0x00},{0x2c,0x40,0x30,0x00}, {0x2c,0x40,0x2c,0x00},{0x30,0x40,0x2c,0x00},{0x34,0x40,0x2c,0x00},{0x3c,0x40,0x2c,0x00}, {0x40,0x40,0x2c,0x00},{0x40,0x3c,0x2c,0x00},{0x40,0x34,0x2c,0x00},{0x40,0x30,0x2c,0x00}, {0xa8,0xa8,0xa8,0x00},{0x54,0xfc,0xfc,0x00},{0xfc,0x54,0xfc,0x00},{0xfc,0xfc,0x54,0x00}, {0xfc,0x54,0x54,0x00},{0x54,0xfc,0x54,0x00},{0x54,0x54,0xfc,0x00},{0xfc,0xfc,0xfc,0x00} }; RGBQUAD VgaColorTab[256]; //--------------------------------------------------------- // 常规图像处理 void ImageDwindle(IplImage *pi,IplImage *po,int n,int nCnls) { // 图像整数倍缩小 int i,j,k,bpl,bplt; char *buf,*buft; bpl=pi->widthStep; bplt=po->widthStep; buf=pi->imageData; buft=po->imageData; for (i=0;i<pi->height;i+=n) { for (j=0,k=0;j<pi->width*nCnls;k+=nCnls,j+=n*nCnls) memcpy(&buft[k],&buf[j],nCnls); // 复制一个像素 buf+=n*bpl; buft+=bplt; } } int NextColor(int start,int k,int step) // 下一彩色号 { k++; // 修改颜色号 if (k==7) k+=2; // 跳过默认调色板7、8号颜色 else if (k==15) k+=17; // 跳过默认调色板15~31号颜色 if (k>32) k+=step-1; if (k>247) k=start; // 超过默认调色板248号颜色,从头开始 return(k); } void Histog(BYTE *buf,int *pg,int Dx,int Dy) { // 统计直方图 int i; for (i=0;i<256;i++) pg[i]=0; for (i=0;i<Dx*Dy;i++) pg[buf[i]]++; } int BasicGlobalThreshold(int *pg,int start,int end) { // 基本全局阈值法 int i,t,t1,t2,k1,k2; double u,u1,u2; t=0; u=0; for (i=start;i<end;i++) { t+=pg[i]; u+=i*pg[i]; } k2=(int) (u/t); // 计算此范围灰度的平均值 do { k1=k2; t1=0; u1=0; for (i=start;i<=k1;i++) { // 计算低灰度组的累加和 t1+=pg[i]; u1+=i*pg[i]; } t2=t-t1; u2=u-u1; if (t1) u1=u1/t1; // 计算低灰度组的平均值 else u1=0; if (t2) u2=u2/t2; // 计算高灰度组的平均值 else u2=0; k2=(int) ((u1+u2)/2); // 得到新的阈值估计值 } while(k1!=k2); // 数据未稳定,继续 return(k1); // 返回阈值 } void Thresholding(BYTE *buf,int Dx,int Dy,int thre,int m) { // 实现灰度变换 BYTE **list; int i,j,T_gray[256]; list=(BYTE**) malloc(Dy*sizeof(BYTE*)); // 申请二维输入数组 for(i=0;i<Dy;i++) list[i]=buf+i*Dx; for (i=0;i<thre;i++) T_gray[i]=0; // 低于阈值改黑色 for (i=thre;i<256;i++) T_gray[i]=m; // 高于、等于阈值改白色 for (i=0;i<Dy;i++) { for (j=0;j<Dx;j++) { list[i][j]=(BYTE) T_gray[list[i][j]]; } } free(list); } void GrayColorTransfor(RGBQUAD *pal) { int i,j; for (i=0,j=0;i<64;i++,j+=4) { // 按变换曲线送各单元颜色分量 pal[i].rgbRed =0; pal[i].rgbGreen=(BYTE) j; pal[i].rgbBlue =255; } for (i=64,j=0;i<128;i++,j+=4) { // 按变换曲线送各单元颜色分量 pal[i].rgbRed =0; pal[i].rgbGreen=255; pal[i].rgbBlue =(BYTE) (255-j); } for (i=128,j=0;i<192;i++,j+=4) { // 按变换曲线送各单元颜色分量 pal[i].rgbRed =(BYTE) j; pal[i].rgbGreen=255; pal[i].rgbBlue =0; } for (i=192,j=0;i<256;i++,j+=4) { // 按变换曲线送各单元颜色分量 pal[i].rgbRed =255; pal[i].rgbGreen=(BYTE) (255-j); pal[i].rgbBlue =0; } }
[ "1114809057@qq.com" ]
1114809057@qq.com
5457c12db7fb3ac6cf41688058ff7b9b05551926
aadc1a8ab3f904556a68df12916ea08cc8132df0
/Practice/galaga/Win32_API/imageManager.h
d2f83eb32f2b89b2c8f129be6dafb3dc5f14e283
[]
no_license
kuris13/WIN_API
4a1f68ad81409ef8ca47aa854469239ed1e08406
a640c3d221b80acfd153ad1912696d92d95780ce
refs/heads/master
2022-12-06T07:19:31.916410
2020-09-01T18:11:24
2020-09-01T18:11:24
287,018,361
0
0
null
null
null
null
UHC
C++
false
false
1,923
h
#pragma once #include "singletonBase.h" #include "image.h" class imageManager : public singletonBase<imageManager> { private: //map으로 만든 이e미지 목록 typedef map<string, image*> mapImageList; //map으로 만든 이미지 목록의 반복자 typedef map<string, image*>::iterator mapImageIter; private: mapImageList _mImageList; public: //이미지 매니저 초기화 HRESULT init(void); //이미지 매니저 해제 void release(); //빈 비트맵으로 초기화 image* addImage(string strKey, int width, int height); //이미지 파일로 초기화 image* addImage(string strKey, const char* fileName, int width, int height, BOOL isTrans = FALSE, COLORREF transColor = RGB(0, 0, 0)); image* addImage(string strKey, const char* fileName, float x, float y, int width, int height, BOOL isTrans = FALSE, COLORREF transColor = RGB(0, 0, 0)); //애니메이션(스프라이트 시트) 초기화 image * addFrameImage(string strKey, const char* fileName, int width, int height, int maxFrameX, int maxFrameY, BOOL isTrans = FALSE, COLORREF transColor = RGB(0, 0, 0)); image * addFrameImage(string strKey, const char* fileName, float x, float y, int width, int height, int maxFrameX, int maxFrameY, BOOL isTrans = FALSE, COLORREF transColor = RGB(0, 0, 0)); //이미지를 키값으로 찾기 image* findImage(string strKey); //이미지를 키값으로 삭제 BOOL deleteImage(string strKey); //이미지 전체 삭제 BOOL deleteAll(); //render void render(string strKey, HDC hdc); void render(string strKey, HDC hdc, int destX, int destY); void render(string strKey, HDC hdc, int destX, int destY, int sourceX, int sourceY, int sourceWidth, int sourceHeight); //alpha Render void alphaRender(string strKey, HDC hdc, BYTE alpha); void alphaRender(string strKey, HDC hdc, int destX, int destY, BYTE alpha); imageManager() {} ~imageManager() {} };
[ "duddn4646@gmail.com" ]
duddn4646@gmail.com
1414ec9f09abd4f5cb44db8fa7b766c6c3d3bc6b
92b6aaade5a3f323d7f8e7d02fb9fec09f4c2f50
/CP-Codes/Codes/Codechef/Aug Cook Off/aa.cpp
a585bb8160b19f4aa5f68a22e555603eebed1581
[]
no_license
suraj1611/Competitive_Programming
846dee00396e2f2b6d13e2ea8aaed444a34062af
82bd88081ac067ad4170553afedc6c479bb53753
refs/heads/master
2020-04-22T17:27:18.116585
2019-12-16T19:42:29
2019-12-16T19:42:29
170,541,477
1
0
null
null
null
null
UTF-8
C++
false
false
1,662
cpp
/* Code by : Suraj (@suraj1611) */ #include<bits/stdc++.h> #include <string> using namespace std; #define ll long long int #define rep(i,n) for(int i=0; i<n; i++) #define rep1(j,m) for(int j=1;j<m;j++) #define mx INT_MAX #define mn INT_MIN #define md 1000000007 #define pb push_back #define mp make_pair #define pf printf #define sc scanf #define maxsize 1100005 #define lb cout<<endl; #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); /*#define miter map <ll,ll> :: iterator it; for(it=m.begin();it!=m.end();it++) #define viter vector <ll> :: iterator it; for(it=v.begin();it!=v.end();it++) #define siter set <ll> :: iterator it; for(it=s.begin();it!=s.end();it++)*/ ll prime[maxsize]; ll gcd(ll a,ll b) { if(a==0) return b; else return(gcd(b%a,a)); } ll lcm(ll a,ll b) { return (a*b)/gcd(a,b); } void seive() { memset(prime,true,sizeof(prime)); prime[0]=false; prime[1]=true; for(ll i=2;i*i<=maxsize;i++) { if(prime[i]==true) { for(ll j=2*i;j<maxsize;j+=i) { prime[j]=false; } } } } int bs(ll a[],ll x,ll n) { ll l=0,h=n-1,mid; while(l<=h) { mid=(l+h)/2; if(x<a[mid]) h=mid-1; else if(x>a[mid]) l=mid+1; else return 1; } return 0; } ll cnt(ll n) { ll c=0; while(n!=0) { if(n%10==3) c++; n/=10; } return c; } int main() { IOS #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("in.txt", "r", stdin); // for writing output to output.txt freopen("out.txt", "w", stdout); #endif ll t; cin>>t; while(t--) { ll n; cin>>n; n++; while(cnt(n)<3) n++; cout<<n<<endl; } }
[ "surajsk1611@gmail.com" ]
surajsk1611@gmail.com
fccb5713fe51e3519d16cace10f376e84da9f663
f3a729d3588f6c31975d44b37f1b3a29c01db3cd
/113A.cpp
d543d29e8f0300c8dce42afa26d57bbc2990f57e
[]
no_license
yongwhan/codeforces
887e7cca0b47aa2ba65b1133300c63a808a15590
aa8fa27ca1a07fcb7f9dac5b1ce908b7bfcd49e2
refs/heads/master
2020-11-28T01:47:52.239077
2019-12-23T04:16:29
2019-12-23T04:16:29
229,671,486
0
0
null
2019-12-23T04:05:28
2019-12-23T03:43:38
C++
UTF-8
C++
false
false
1,054
cpp
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> ii; bool issuf(string s, string t) { reverse(s.begin(), s.end()); reverse(t.begin(), t.end()); if(s.size()<t.size()) return false; return (s.substr(0,t.size())==t); } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); string suf[]={"lios","liala","etr","etra","initis","inites"}, cur; vector<int> seq; while(cin>>cur) { bool ok=false; for (int i=0; i<6; i++) if(issuf(cur,suf[i])) seq.push_back(i), ok=true; if(!ok) { cout << "NO" << endl; return 0; } } int ct=0; for (auto x : seq) ct+=(x%2); if(0<ct&&ct<seq.size()) { cout << "NO" << endl; return 0; } int n=seq.size(); if(n==1) { cout << "YES" << endl; return 0; } for (int i=0; i<n; i++) seq[i]/=2; map<int,int> mp; for (auto x : seq) mp[x]++; if(mp[1]!=1) { cout << "NO" << endl; return 0; } for (int i=0; i<n-1; i++) if(seq[i]>seq[i+1]) { cout << "NO" << endl; return 0; } cout << "YES" << endl; return 0; }
[ "yongwhan@yongwhan-macbookpro.roam.corp.google.com" ]
yongwhan@yongwhan-macbookpro.roam.corp.google.com
a72ccd6c172b30caaf07e3431f3b04b7cda8f207
faae3c591fd6d8df7effb38544b5efb402c71bfa
/wray/wray/pathIntegrator.cpp
db49c7433e02642fc2abf8d9352a2fcb148b1242
[]
no_license
FLOWERCLOUD/virtualCamera
c9ba51fac6c3c7d680b3b25fb17aa24a1db59270
0c33e5aed7d878d1460f84821923476a0ff09eaa
refs/heads/master
2021-01-22T04:23:33.674217
2017-09-03T13:22:18
2017-09-03T13:22:18
102,265,513
1
1
null
null
null
null
WINDOWS-1252
C++
false
false
2,571
cpp
#include "StdAfx.h" #include "pathIntegrator.h" #include "Scene.h" WPathIntegrator::WPathIntegrator(WScene *scene, WAccelerator *tree, unsigned int ipathDepth, WSampler::WSamplerType samplerType,float imultiplier): WSurfaceIntegrator(scene,tree),Dlighting(scene,tree), multiplier(imultiplier), lightSamples(1),BSDFSamples(1) { pathMaxDepth=max(1,ipathDepth); if(samplerType==WSampler::SAMPLER_RANDOM) sampler=new WRandomSampler; else if(samplerType==WSampler::SAMPLER_STRATIFIED) sampler=new WStratifiedSampler; allocateSamples(); } WPathIntegrator::~WPathIntegrator() { clearSamples(); } void WPathIntegrator::setPathMaxDepth(unsigned int idepth) { pathMaxDepth=max(1,idepth); clearSamples(); allocateSamples(); } void WPathIntegrator::clearSamples() { BSDFSamples.clear(); lightSamples.clear(); } void WPathIntegrator::allocateSamples() { unsigned int nLightSamples=scene->getLightNum()*pathMaxDepth; unsigned int nBSDFSamples=pathMaxDepth*2; BSDFSamples.setSize(unsigned int(sqrt(float(nBSDFSamples))+1)); lightSamples.setSize(unsigned int(sqrt(float(nLightSamples))+1)); BSDFSamples.allocateSpace(); lightSamples.allocateSpace(); } void WPathIntegrator::computeSamples() { // sampler->setSeed(unsigned int(clock())); sampler->computeSamples(BSDFSamples); sampler->computeSamples(lightSamples); } WVector3 WPathIntegrator::integrate(WRay&camRay)//ÑÕÉ«¼ÆËã { // clearSamples(); // allocateSamples(); computeSamples(); // BSDFSamples.display(); // cout<<"begin"<<endl; WDifferentialGeometry DG; WVector3 pathThroughPut(1.0f); WVector3 totalLight(0),directLight; WVector3 ri,ro; float rayPDF; WBSDF*bsdf; WRay ray=camRay; // cout<<ray.tMin<<endl; // ray.tMin=1e-5f; int beginNode = -1, endNode = -1; for(unsigned int depth=0;depth<pathMaxDepth;depth++) { if(tree->intersect(ray,DG,&endNode,beginNode)) { if(depth==0) camRay.tMax=ray.tMax; WMaterial*mtl; scene->getNthMaterial(mtl,DG.mtlId); mtl->buildBSDF(DG,bsdf); ro=-1*ray.direction; directLight=Dlighting.sampleAllLights( bsdf,lightSamples,BSDFSamples,ro, &endNode); totalLight+=pathThroughPut*directLight; float bsdfU,bsdfV; BSDFSamples.get2D(bsdfU,bsdfV); bsdf->sampleRay(bsdfU,bsdfV,ri,ro,rayPDF); ray.point=DG.position; ray.direction=ri; ray.tMin = 0.01f; ray.tMax=M_INF_BIG; pathThroughPut*=bsdf->evaluateFCos(ri,ro)/rayPDF; delete bsdf; beginNode = endNode; } else { break; } } // totalLight.showCoords(); return totalLight; } void WPathIntegrator::displayTime() { timer.display(); }
[ "528450012@qq.com" ]
528450012@qq.com
50e5adbde423e1694e831c14c18578d801465e6c
319335bafac47077f243ee93514591b549e872d4
/sources/OperationsExpert.hpp
bf801133961a9a92b25e42a981455de20ab3efe9
[]
no_license
malikfade/Pandemic_b
dc65f159327609bf8317a0c80c4a4434ba6810e4
886756825e6a7ff9cf915ab269c1ae74b6fc2ed5
refs/heads/main
2023-05-01T07:44:51.002338
2021-05-23T14:13:18
2021-05-23T14:13:18
370,070,269
0
0
null
null
null
null
UTF-8
C++
false
false
312
hpp
#ifndef UNTITLED_OPERATIONSEXPERT_H #define UNTITLED_OPERATIONSEXPERT_H #include "Player.hpp" namespace pandemic { class OperationsExpert : public Player { public: OperationsExpert(Board& board, City city): Player(board, city){} void build(); std::string role(); }; } #endif
[ "noreply@github.com" ]
malikfade.noreply@github.com
19fc6f15b463bd5abfd5531fdb686ccf47f98885
430a0bc072e5bbdaf8b535e8589ee7bddedd60a1
/chrome/common/chrome_paths.cc
364a02d3b67a30dac2ce10f73e0150dad625e2ca
[ "BSD-3-Clause" ]
permissive
HyunwooCho/highweb-webcl-html5spec
4527f01a5ebb95db8e045e1b4012a3eac567f307
1e7b96fc871797139b927516e94b75d730ee50c2
refs/heads/highweb-20160310
2021-06-05T23:30:40.097589
2016-05-27T04:42:28
2016-05-27T04:42:28
70,441,565
0
0
null
2016-10-10T01:33:38
2016-10-10T01:33:36
null
UTF-8
C++
false
false
21,382
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/common/chrome_paths.h" #include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/mac/bundle_locations.h" #include "base/path_service.h" #include "base/strings/string_util.h" #include "base/sys_info.h" #include "base/threading/thread_restrictions.h" #include "base/version.h" #include "build/build_config.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths_internal.h" #if defined(OS_ANDROID) #include "base/android/path_utils.h" #include "base/base_paths_android.h" // ui/base must only be used on Android. See BUILD.gn for dependency info. #include "ui/base/ui_base_paths.h" // nogncheck #endif #if defined(OS_MACOSX) #include "base/mac/foundation_util.h" #endif #if defined(OS_WIN) #include "base/win/registry.h" #endif #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. namespace { // The Pepper Flash plugins are in a directory with this name. const base::FilePath::CharType kPepperFlashBaseDirectory[] = FILE_PATH_LITERAL("PepperFlash"); #if defined(OS_MACOSX) const base::FilePath::CharType kPepperFlashSystemBaseDirectory[] = FILE_PATH_LITERAL("Internet Plug-Ins/PepperFlashPlayer"); const base::FilePath::CharType kFlashSystemBaseDirectory[] = FILE_PATH_LITERAL("Internet Plug-Ins"); const base::FilePath::CharType kFlashSystemPluginName[] = FILE_PATH_LITERAL("Flash Player.plugin"); #endif const base::FilePath::CharType kInternalNaClPluginFileName[] = FILE_PATH_LITERAL("internal-nacl-plugin"); #if defined(OS_LINUX) // The path to the external extension <id>.json files. // /usr/share seems like a good choice, see: http://www.pathname.com/fhs/ const base::FilePath::CharType kFilepathSinglePrefExtensions[] = #if defined(GOOGLE_CHROME_BUILD) FILE_PATH_LITERAL("/usr/share/google-chrome/extensions"); #else FILE_PATH_LITERAL("/usr/share/chromium/extensions"); #endif // defined(GOOGLE_CHROME_BUILD) // The path to the hint file that tells the pepper plugin loader // where it can find the latest component updated flash. const base::FilePath::CharType kComponentUpdatedFlashHint[] = FILE_PATH_LITERAL("latest-component-updated-flash"); #endif // defined(OS_LINUX) static base::LazyInstance<base::FilePath> g_invalid_specified_user_data_dir = LAZY_INSTANCE_INITIALIZER; // Gets the path for internal plugins. bool GetInternalPluginsDirectory(base::FilePath* result) { #if defined(OS_MACOSX) // If called from Chrome, get internal plugins from a subdirectory of the // framework. if (base::mac::AmIBundled()) { *result = chrome::GetFrameworkBundlePath(); DCHECK(!result->empty()); *result = result->Append("Internet Plug-Ins"); return true; } // In tests, just look in the module directory (below). #endif // The rest of the world expects plugins in the module directory. return PathService::Get(base::DIR_MODULE, result); } #if defined(OS_WIN) // Gets the Flash path if installed on the system. |is_npapi| determines whether // to return the NPAPI of the PPAPI version of the system plugin. bool GetSystemFlashFilename(base::FilePath* out_path, bool is_npapi) { const wchar_t kNpapiFlashRegistryRoot[] = L"SOFTWARE\\Macromedia\\FlashPlayerPlugin"; const wchar_t kPepperFlashRegistryRoot[] = L"SOFTWARE\\Macromedia\\FlashPlayerPepper"; const wchar_t kFlashPlayerPathValueName[] = L"PlayerPath"; base::win::RegKey path_key( HKEY_LOCAL_MACHINE, is_npapi ? kNpapiFlashRegistryRoot : kPepperFlashRegistryRoot, KEY_READ); base::string16 path_str; if (FAILED(path_key.ReadValue(kFlashPlayerPathValueName, &path_str))) return false; *out_path = base::FilePath(path_str); return true; } #endif } // namespace namespace chrome { bool PathProvider(int key, base::FilePath* result) { // Some keys are just aliases... switch (key) { case chrome::DIR_APP: return PathService::Get(base::DIR_MODULE, result); case chrome::DIR_LOGS: #ifdef NDEBUG // Release builds write to the data dir return PathService::Get(chrome::DIR_USER_DATA, result); #else // Debug builds write next to the binary (in the build tree) #if defined(OS_MACOSX) if (!PathService::Get(base::DIR_EXE, result)) return false; if (base::mac::AmIBundled()) { // If we're called from chrome, dump it beside the app (outside the // app bundle), if we're called from a unittest, we'll already // outside the bundle so use the exe dir. // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium. *result = result->DirName(); *result = result->DirName(); *result = result->DirName(); } return true; #else return PathService::Get(base::DIR_EXE, result); #endif // defined(OS_MACOSX) #endif // NDEBUG case chrome::FILE_RESOURCE_MODULE: return PathService::Get(base::FILE_MODULE, result); } // Assume that we will not need to create the directory if it does not exist. // This flag can be set to true for the cases where we want to create it. bool create_dir = false; base::FilePath cur; switch (key) { case chrome::DIR_USER_DATA: if (!GetDefaultUserDataDirectory(&cur)) { NOTREACHED(); return false; } create_dir = true; break; case chrome::DIR_USER_DOCUMENTS: if (!GetUserDocumentsDirectory(&cur)) return false; create_dir = true; break; case chrome::DIR_USER_MUSIC: if (!GetUserMusicDirectory(&cur)) return false; break; case chrome::DIR_USER_PICTURES: if (!GetUserPicturesDirectory(&cur)) return false; break; case chrome::DIR_USER_VIDEOS: if (!GetUserVideosDirectory(&cur)) return false; break; case chrome::DIR_DEFAULT_DOWNLOADS_SAFE: #if defined(OS_WIN) || defined(OS_LINUX) if (!GetUserDownloadsDirectorySafe(&cur)) return false; break; #else // Fall through for all other platforms. #endif case chrome::DIR_DEFAULT_DOWNLOADS: #if defined(OS_ANDROID) if (!base::android::GetDownloadsDirectory(&cur)) return false; #else if (!GetUserDownloadsDirectory(&cur)) return false; // Do not create the download directory here, we have done it twice now // and annoyed a lot of users. #endif break; case chrome::DIR_CRASH_DUMPS: #if defined(OS_CHROMEOS) // ChromeOS uses a separate directory. See http://crosbug.com/25089 cur = base::FilePath("/var/log/chrome"); #elif defined(OS_ANDROID) if (!base::android::GetCacheDirectory(&cur)) return false; #else // The crash reports are always stored relative to the default user data // directory. This avoids the problem of having to re-initialize the // exception handler after parsing command line options, which may // override the location of the app's profile directory. // TODO(scottmg): Consider supporting --user-data-dir. See // https://crbug.com/565446. if (!GetDefaultUserDataDirectory(&cur)) return false; #endif #if defined(OS_MACOSX) || defined(OS_WIN) cur = cur.Append(FILE_PATH_LITERAL("Crashpad")); #else cur = cur.Append(FILE_PATH_LITERAL("Crash Reports")); #endif create_dir = true; break; #if defined(OS_WIN) case chrome::DIR_WATCHER_DATA: // The watcher data is always stored relative to the default user data // directory. This allows the watcher to be initialized before // command-line options have been parsed. if (!GetDefaultUserDataDirectory(&cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("Diagnostics")); break; #endif case chrome::DIR_RESOURCES: #if defined(OS_MACOSX) cur = base::mac::FrameworkBundlePath(); cur = cur.Append(FILE_PATH_LITERAL("Resources")); #else if (!PathService::Get(chrome::DIR_APP, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("resources")); #endif break; case chrome::DIR_INSPECTOR: if (!PathService::Get(chrome::DIR_RESOURCES, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("inspector")); break; case chrome::DIR_APP_DICTIONARIES: #if defined(OS_POSIX) // We can't write into the EXE dir on Linux, so keep dictionaries // alongside the safe browsing database in the user data dir. // And we don't want to write into the bundle on the Mac, so push // it to the user data dir there also. if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; #else if (!PathService::Get(base::DIR_EXE, &cur)) return false; #endif cur = cur.Append(FILE_PATH_LITERAL("Dictionaries")); create_dir = true; break; case chrome::DIR_INTERNAL_PLUGINS: if (!GetInternalPluginsDirectory(&cur)) return false; break; case chrome::DIR_PEPPER_FLASH_PLUGIN: if (!GetInternalPluginsDirectory(&cur)) return false; cur = cur.Append(kPepperFlashBaseDirectory); break; case chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(kPepperFlashBaseDirectory); break; case chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN: #if defined(OS_WIN) if (!GetSystemFlashFilename(&cur, false)) return false; #elif defined(OS_MACOSX) if (!GetLocalLibraryDirectory(&cur)) return false; cur = cur.Append(kPepperFlashSystemBaseDirectory); cur = cur.Append(chrome::kPepperFlashPluginFilename); #else // Chrome on iOS does not supports PPAPI binaries, return false. // TODO(wfh): If Adobe release PPAPI binaries for Linux, add support here. return false; #endif break; case chrome::FILE_FLASH_SYSTEM_PLUGIN: #if defined(OS_WIN) if (!GetSystemFlashFilename(&cur, true)) return false; #elif defined(OS_MACOSX) if (!GetLocalLibraryDirectory(&cur)) return false; cur = cur.Append(kFlashSystemBaseDirectory); cur = cur.Append(kFlashSystemPluginName); #else // Chrome on other platforms does not supports system NPAPI binaries. return false; #endif break; case chrome::FILE_LOCAL_STATE: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(chrome::kLocalStateFilename); break; case chrome::FILE_RECORDED_SCRIPT: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("script.log")); break; case chrome::FILE_PEPPER_FLASH_PLUGIN: if (!PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &cur)) return false; cur = cur.Append(chrome::kPepperFlashPluginFilename); break; // TODO(teravest): Remove this case once the internal NaCl plugin is gone. // We currently need a path here to look up whether the plugin is disabled // and what its permissions are. case chrome::FILE_NACL_PLUGIN: if (!GetInternalPluginsDirectory(&cur)) return false; cur = cur.Append(kInternalNaClPluginFileName); break; // PNaCl is currenly installable via the component updater or by being // simply built-in. DIR_PNACL_BASE is used as the base directory for // installation via component updater. DIR_PNACL_COMPONENT will be // the final location of pnacl, which is a subdir of DIR_PNACL_BASE. case chrome::DIR_PNACL_BASE: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("pnacl")); break; // Where PNaCl files are ultimately located. The default finds the files // inside the InternalPluginsDirectory / build directory, as if it // was shipped along with chrome. The value can be overridden // if it is installed via component updater. case chrome::DIR_PNACL_COMPONENT: #if defined(OS_MACOSX) // PNaCl really belongs in the InternalPluginsDirectory but actually // copying it there would result in the files also being shipped, which // we don't want yet. So for now, just find them in the directory where // they get built. if (!PathService::Get(base::DIR_EXE, &cur)) return false; if (base::mac::AmIBundled()) { // If we're called from chrome, it's beside the app (outside the // app bundle), if we're called from a unittest, we'll already be // outside the bundle so use the exe dir. // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium. cur = cur.DirName(); cur = cur.DirName(); cur = cur.DirName(); } #else if (!GetInternalPluginsDirectory(&cur)) return false; #endif cur = cur.Append(FILE_PATH_LITERAL("pnacl")); break; #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) #if defined(WIDEVINE_CDM_IS_COMPONENT) case chrome::DIR_COMPONENT_WIDEVINE_CDM: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("WidevineCDM")); break; #endif // defined(WIDEVINE_CDM_IS_COMPONENT) // TODO(xhwang): FILE_WIDEVINE_CDM_ADAPTER has different meanings. // In the component case, this is the source adapter. Otherwise, it is the // actual Pepper module that gets loaded. case chrome::FILE_WIDEVINE_CDM_ADAPTER: if (!GetInternalPluginsDirectory(&cur)) return false; cur = cur.AppendASCII(kWidevineCdmAdapterFileName); break; #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) case chrome::FILE_RESOURCES_PACK: #if defined(OS_MACOSX) if (base::mac::AmIBundled()) { cur = base::mac::FrameworkBundlePath(); cur = cur.Append(FILE_PATH_LITERAL("Resources")) .Append(FILE_PATH_LITERAL("resources.pak")); break; } #elif defined(OS_ANDROID) if (!PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &cur)) return false; #else // If we're not bundled on mac or Android, resources.pak should be next // to the binary (e.g., for unit tests). if (!PathService::Get(base::DIR_MODULE, &cur)) return false; #endif cur = cur.Append(FILE_PATH_LITERAL("resources.pak")); break; case chrome::DIR_RESOURCES_EXTENSION: if (!PathService::Get(base::DIR_MODULE, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("resources")) .Append(FILE_PATH_LITERAL("extension")); break; #if defined(OS_CHROMEOS) case chrome::DIR_CHROMEOS_WALLPAPERS: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("wallpapers")); break; case chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("wallpaper_thumbnails")); break; case chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("custom_wallpapers")); break; #endif #if defined(ENABLE_SUPERVISED_USERS) #if defined(OS_LINUX) case chrome::DIR_SUPERVISED_USERS_DEFAULT_APPS: if (!PathService::Get(chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("managed_users")); break; #endif case chrome::DIR_SUPERVISED_USER_INSTALLED_WHITELISTS: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("SupervisedUserInstalledWhitelists")); break; #endif // The following are only valid in the development environment, and // will fail if executed from an installed executable (because the // generated path won't exist). case chrome::DIR_GEN_TEST_DATA: #if defined(OS_ANDROID) // On Android, our tests don't have permission to write to DIR_MODULE. // gtest/test_runner.py pushes data to external storage. if (!PathService::Get(base::DIR_ANDROID_EXTERNAL_STORAGE, &cur)) return false; #else if (!PathService::Get(base::DIR_MODULE, &cur)) return false; #endif cur = cur.Append(FILE_PATH_LITERAL("test_data")); if (!base::PathExists(cur)) // We don't want to create this. return false; break; case chrome::DIR_TEST_DATA: if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("chrome")); cur = cur.Append(FILE_PATH_LITERAL("test")); cur = cur.Append(FILE_PATH_LITERAL("data")); if (!base::PathExists(cur)) // We don't want to create this. return false; break; case chrome::DIR_TEST_TOOLS: if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("chrome")); cur = cur.Append(FILE_PATH_LITERAL("tools")); cur = cur.Append(FILE_PATH_LITERAL("test")); if (!base::PathExists(cur)) // We don't want to create this return false; break; #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) case chrome::DIR_POLICY_FILES: { #if defined(GOOGLE_CHROME_BUILD) cur = base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); #else cur = base::FilePath(FILE_PATH_LITERAL("/etc/chromium/policies")); #endif break; } #endif #if defined(OS_CHROMEOS) || (defined(OS_LINUX) && defined(CHROMIUM_BUILD)) || \ defined(OS_MACOSX) case chrome::DIR_USER_EXTERNAL_EXTENSIONS: { if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("External Extensions")); break; } #endif #if defined(OS_LINUX) case chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS: { cur = base::FilePath(kFilepathSinglePrefExtensions); break; } #endif case chrome::DIR_EXTERNAL_EXTENSIONS: #if defined(OS_MACOSX) if (!chrome::GetGlobalApplicationSupportDirectory(&cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("Google")) .Append(FILE_PATH_LITERAL("Chrome")) .Append(FILE_PATH_LITERAL("External Extensions")); create_dir = false; #else if (!PathService::Get(base::DIR_MODULE, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("extensions")); create_dir = true; #endif break; case chrome::DIR_DEFAULT_APPS: #if defined(OS_MACOSX) cur = base::mac::FrameworkBundlePath(); cur = cur.Append(FILE_PATH_LITERAL("Default Apps")); #else if (!PathService::Get(chrome::DIR_APP, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("default_apps")); #endif break; #if defined(OS_LINUX) || defined(OS_MACOSX) case chrome::DIR_NATIVE_MESSAGING: #if defined(OS_MACOSX) #if defined(GOOGLE_CHROME_BUILD) cur = base::FilePath(FILE_PATH_LITERAL( "/Library/Google/Chrome/NativeMessagingHosts")); #else cur = base::FilePath(FILE_PATH_LITERAL( "/Library/Application Support/Chromium/NativeMessagingHosts")); #endif #else // defined(OS_MACOSX) #if defined(GOOGLE_CHROME_BUILD) cur = base::FilePath(FILE_PATH_LITERAL( "/etc/opt/chrome/native-messaging-hosts")); #else cur = base::FilePath(FILE_PATH_LITERAL( "/etc/chromium/native-messaging-hosts")); #endif #endif // !defined(OS_MACOSX) break; case chrome::DIR_USER_NATIVE_MESSAGING: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("NativeMessagingHosts")); break; #endif // defined(OS_LINUX) || defined(OS_MACOSX) #if !defined(OS_ANDROID) case chrome::DIR_GLOBAL_GCM_STORE: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) return false; cur = cur.Append(kGCMStoreDirname); break; #endif // !defined(OS_ANDROID) #if defined(OS_LINUX) case chrome::FILE_COMPONENT_FLASH_HINT: if (!PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, &cur)) { return false; } cur = cur.Append(kComponentUpdatedFlashHint); break; #endif // defined(OS_LINUX) default: return false; } // TODO(bauerb): http://crbug.com/259796 base::ThreadRestrictions::ScopedAllowIO allow_io; if (create_dir && !base::PathExists(cur) && !base::CreateDirectory(cur)) return false; *result = cur; return true; } // This cannot be done as a static initializer sadly since Visual Studio will // eliminate this object file if there is no direct entry point into it. void RegisterPathProvider() { PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); } void SetInvalidSpecifiedUserDataDir(const base::FilePath& user_data_dir) { g_invalid_specified_user_data_dir.Get() = user_data_dir; } const base::FilePath& GetInvalidSpecifiedUserDataDir() { return g_invalid_specified_user_data_dir.Get(); } } // namespace chrome
[ "kimdh@infrawareglobal.com" ]
kimdh@infrawareglobal.com
f060f1679e6504cfe6507d9881aae3a8c4f2ef3a
584ceb324994f2c5d053b65c15d0c5d60ce0429d
/daireselSiraliListe.cpp
f2abccc942127f0c4010d94135c803f49aa91162
[ "Apache-2.0" ]
permissive
musttafayildirim/veriYapilariUygulamalari
ffd33d02248c95fce91b7b9f44c1bf7b5d207c7e
87015f19e566f71c0e48c8a7e4c2fb01070d808d
refs/heads/master
2020-04-23T21:13:22.530263
2019-05-31T07:38:37
2019-05-31T07:38:37
171,463,312
0
0
null
null
null
null
UTF-8
C++
false
false
2,319
cpp
#include <cstdlib> #include <iostream> using namespace std; struct dairesel{ int data; dairesel * next; }; typedef dairesel node; void ekranaYazdir(node * root){ node * iter = root; cout << iter -> data << endl; //yazdırılırken dikkat edilmesi gereken iter-> next 'nin root'u görene kadar devam etmesi... iter = iter -> next; while(iter != root){ cout << iter -> data << endl; iter = iter -> next; } } node * daireselListeSiraliElemanEkle(node * root, int eklenecekYeniDeger){ if(root == NULL){ root = (node *)malloc(sizeof(node)); root -> next = root; root -> data = eklenecekYeniDeger; return root; } if(root -> data > eklenecekYeniDeger){ node * temp = (node *)malloc(sizeof(node)); temp -> data = eklenecekYeniDeger; temp -> next = root; node * iter = root; while(iter -> next != root){ iter = iter -> next; } iter -> next = temp; return temp; } node * iter = root; while(iter -> next != root && iter -> next -> data < eklenecekYeniDeger ){ iter = iter -> next; } node * temp = (node*)malloc(sizeof(node)); temp -> next = iter -> next; iter -> next = temp; temp -> data = eklenecekYeniDeger; return root; } node * daireselBagliListeSilme(node * root, int silinecekDeger){ node * temp; node * iter = root; if(root -> data == silinecekDeger){ while(iter -> next != root){ iter = iter -> next; } iter -> next = root -> next; free(root); return iter -> next; } while(iter -> next != root && iter -> next -> data < silinecekDeger){ iter = iter -> next; } if(iter -> next == root){ cout << "Aranan Sayi Bulunamadi..." << endl; return root; } temp = iter -> next; iter -> next = temp -> next; free(temp); return root; } int main(){ node * toor; toor = NULL; toor = daireselListeSiraliElemanEkle(toor, 450); toor = daireselListeSiraliElemanEkle(toor, 550); toor = daireselListeSiraliElemanEkle(toor, 150); toor = daireselListeSiraliElemanEkle(toor, 50); toor = daireselListeSiraliElemanEkle(toor, 1); toor = daireselListeSiraliElemanEkle(toor, 20); ekranaYazdir(toor); cout << "silme denemeleri" << endl; toor = daireselBagliListeSilme(toor, 450); toor = daireselBagliListeSilme(toor, 150); toor = daireselBagliListeSilme(toor, 1); toor = daireselBagliListeSilme(toor, 550); ekranaYazdir(toor); }
[ "musttafayildirim@gmail.com" ]
musttafayildirim@gmail.com
76b15a1da427d50a0a94961453d4dbd10c41d5c7
778fffa8b5c005c49e51af318cae4df1f4e3fe74
/insight3d/interface_sdl.cpp
08affa62ccc3b904580bf21f852029932b29e10c
[]
no_license
florath/insight3d
2777669c261bcb249a483f399cc131fefbfdd15d
60c61147275da4253cbd6b6f5a7b3e66c167c562
refs/heads/master
2021-01-16T23:14:54.867740
2016-07-08T20:20:43
2016-07-08T20:20:43
62,912,985
1
0
null
null
null
null
UTF-8
C++
false
false
2,804
cpp
/* insight3d - image based 3d modelling software Copyright (C) 2007-2008 Lukas Mach email: lukas.mach@gmail.com web: http://mach.matfyz.cz/ 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 2 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 GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "interface_sdl.h" // SDL initialization // note unused when using AgarGUI, but might be useful someday void sdl_initialize(int window_width, int window_height) { const SDL_VideoInfo * info = NULL; if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Video initialization failed: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); info = SDL_GetVideoInfo(); if (!info) { fprintf(stderr, "Video query failed: %s\n", SDL_GetError()); exit(1); } SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); int bpp = info->vfmt->BitsPerPixel; int flags = SDL_OPENGL;// | SDL_RESIZABLE; // debug if (SDL_SetVideoMode(window_width, window_height, bpp, flags) == 0) { fprintf(stderr, "Video mode set failed: %s\n", SDL_GetError()); exit(1); } SDL_WM_SetCaption("OpenGL window", NULL); } // reset keys status to false void sdl_clear_keys(Uint8 * keys, bool * clear_keys, size_t keys_length) { for (size_t i = 0; i < keys_length; i++) if (clear_keys[i]) keys[i] = 0; } // map rgb color defined as vector Uint32 sdl_map_rgb_vector(const SDL_PixelFormat * const format, const double color[3]) { return SDL_MapRGB(format, (Uint32)(255 * color[0]), (Uint32)(255 * color[1]), (Uint32)(255 * color[2])); } // button is mouse wheel bool sdl_wheel_button(int button) { return button == SDL_BUTTON_WHEELUP || button == SDL_BUTTON_MIDDLE || button == SDL_BUTTON_WHEELDOWN; } // get modifiers bool sdl_shift_pressed() { SDLMod mod = SDL_GetModState(); return (bool)(mod & KMOD_SHIFT); } bool sdl_ctrl_pressed() { SDLMod mod = SDL_GetModState(); return (bool)(mod & KMOD_CTRL); } bool sdl_alt_pressed() { SDLMod mod = SDL_GetModState(); return (bool)(mod & KMOD_ALT); }
[ "andreas@florath.net" ]
andreas@florath.net
8a41f5888fed8810bbd59949175e92422319dcfb
ffeca79160090eb24d88d2b49a7b40033552c4d5
/Time/time2.cpp
5cb4fafbad16e7e06b125d000b61acaf80c67716
[]
no_license
Reikenzan/Some-C
7ab86b8f1fb0a642b7a78fc59d7b5d42dcceb859
347d287fe89816f7177e12e2e5ac10406feda418
refs/heads/master
2020-04-01T12:09:27.256993
2018-10-16T16:24:45
2018-10-16T16:24:45
153,193,741
0
0
null
null
null
null
UTF-8
C++
false
false
295
cpp
#include <iostream> using namespace std; #include "ccc_time.h" int main() { Time now; Time day_end(23, 59, 59); long seconds_left = day_end.seconds_from(now); cout << "There are " << seconds_left << " seconds left in this day.\n"; return 0; }
[ "noreply@github.com" ]
Reikenzan.noreply@github.com
5a46f56d64523d33c624f3b5b1036a7b3db4ad63
7a36a0652fe0704b4b27f644653e7b0f7e72060f
/TianShan/Sentry/SentryImpl.h
8936a817f5ae52991d427d92bc3135a280c1cbd3
[]
no_license
darcyg/CXX
1ee13c1765f1987e293c15b9cbc51ae625ac3a2e
ef288ad0e1624ed0582839f2a5a0ef66073d415e
refs/heads/master
2020-04-06T04:27:11.940141
2016-12-29T03:49:56
2016-12-29T03:49:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,675
h
// =========================================================================== // Copyright (c) 2006 by // ZQ Interactive, Inc., Shanghai, PRC., // All Rights Reserved. Unpublished rights reserved under the copyright // laws of the United States. // // The software contained on this media is proprietary to and embodies the // confidential technology of ZQ Interactive, Inc. Possession, use, // duplication or dissemination of the software and media is authorized only // pursuant to a valid written license from ZQ Interactive, Inc. // // This software is furnished under a license and may be used and copied // only in accordance with the terms of such license and with the inclusion // of the above copyright notice. This software or any other copies thereof // may not be provided or otherwise made available to any other person. No // title to and ownership of the software is hereby transferred. // // The information in this software is subject to change without notice and // should not be construed as a commitment by ZQ Interactive, Inc. // // Ident : $Id: SessionImpl.h $ // Branch: $Name: $ // Author: Hui Shao // Desc : // // Revision History: // --------------------------------------------------------------------------- // $Log: /ZQProjs/TianShan/Sentry/SentryImpl.h $ // // 1 10-11-12 16:06 Admin // Created. // // 1 10-11-12 15:41 Admin // Created. // // 2 08-06-06 12:06 Xiaohui.chai // added getWebView() // // 1 07-05-21 11:14 Hui.shao // // 12 07-03-13 17:12 Hongquan.zhang // // 11 07-01-05 10:59 Hongquan.zhang // =========================================================================== #ifndef __ZQTianShan_SentryImpl_H__ #define __ZQTianShan_SentryImpl_H__ #include "../common/TianShanDefines.h" #include "../common/ZqSentryIce.h" #include "SentryEnv.h" namespace ZQTianShan { namespace Sentry { // ----------------------------- // loopback service AdapterCollectorImpl // ----------------------------- class AdapterCollectorImpl : public ::ZqSentryIce::AdapterCollector, public IceUtil::AbstractMutexReadI<IceUtil::RWRecMutex> { public: AdapterCollectorImpl(SentryEnv& env); virtual ~AdapterCollectorImpl(); public: // impls of AdapterCollector virtual ::Ice::Int updateAdapter(::Ice::Int processId, const ::std::string& adapterId, ::Ice::Long lastChange, const ::Ice::Identity& identAdapterCB, const ::Ice::Current& c); virtual ::std::string getRootUrl(const ::Ice::Current& c); protected: SentryEnv& _env; }; // ----------------------------- // public service SentryServiceImpl // ----------------------------- class SentryServiceImpl : public ::ZqSentryIce::SentryService, public IceUtil::AbstractMutexReadI<IceUtil::RWRecMutex> { public: SentryServiceImpl(SentryEnv& env); virtual ~SentryServiceImpl(); public: // impls of NodeService virtual ::std::string getAdminUri(const ::Ice::Current& c); virtual ::TianShanIce::State getState(const ::Ice::Current& c); virtual void getGroupAddress(::std::string& McastIp, ::Ice::Int& port, const ::Ice::Current& c); virtual void getProcessorInfo(::std::string& processor, ::Ice::Int& count, ::Ice::Long& frequencyMhz, const ::Ice::Current& c); virtual ::std::string getOSType(const ::Ice::Current& c); virtual ::std::string getRootUrl(const ::Ice::Current& c); virtual ::ZqSentryIce::ServiceInfos listServices(const ::Ice::Current& c); virtual ::Ice::Int stopDaemonByPid(::Ice::Int pid, bool restart, const ::Ice::Current& c); virtual ::ZqSentryIce::WebView getWebView(const ::Ice::Current& c); protected: SentryEnv& _env; }; }} // namespace #endif // __ZQTianShan_SentryImpl_H__
[ "jjz@example.com" ]
jjz@example.com
b9d2d8a5fc66a1b283e05b587403ead3c8692559
19907e496cfaf4d59030ff06a90dc7b14db939fc
/POC/oracle_dapp/node_modules/wrtc/third_party/webrtc/include/chromium/src/chrome/browser/signin/cross_device_promo.h
5990a948858df52873bc0ff7d722e09ef3579a04
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
ATMatrix/demo
c10734441f21e24b89054842871a31fec19158e4
e71a3421c75ccdeac14eafba38f31cf92d0b2354
refs/heads/master
2020-12-02T20:53:29.214857
2017-08-28T05:49:35
2017-08-28T05:49:35
96,223,899
8
4
null
2017-08-28T05:49:36
2017-07-04T13:59:26
JavaScript
UTF-8
C++
false
false
11,921
h
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_SIGNIN_CROSS_DEVICE_PROMO_H_ #define CHROME_BROWSER_SIGNIN_CROSS_DEVICE_PROMO_H_ #include "base/macros.h" #include "base/observer_list.h" #include "base/timer/timer.h" #include "components/keyed_service/core/keyed_service.h" #include "components/signin/core/browser/device_activity_fetcher.h" #include "components/signin/core/browser/gaia_cookie_manager_service.h" class PrefService; class SigninClient; class SigninManager; // The Cross Device Promo promotes Chrome Signin within a profile where there is // one GAIA account signed in to the content area for a long period of time // (indicating that this profile is used by only one user) and where that // account uses Chrome Sync on other devices but is not signed in here. // // This class determines whether the above criteria have been met and thus // whether the promo should be displayed. This class imposes additional criteria // such that the promo is only displayed if there is sufficiently recent // activity on another device, indicating the user is switching contexts but // continuing their browsing activity. This class's behavior is controlled by // the "CrossDevicePromo" field trial. // The UI is defined elsewhere. // // This class implements the preferences necessary to track whether a profile // meets the above criteria, and whether the user has permanently opted out of // the promo. // // The class relies on the GaiaCookieManagerService to determine if there has // been a single GAIA account signed in to the content area for a long period of // time, and relies on the DeviceActivityFetcher to determine if that account // uses Chrome Sync on other devices. class CrossDevicePromo : public KeyedService, public GaiaCookieManagerService::Observer, public DeviceActivityFetcher::Observer { public: class Observer { public: // Called when the profile moves from being ineligible to eligible for the // promo or vice versa; the new state is noted in the |eligible| parameter. virtual void OnPromoEligibilityChanged(bool eligible) = 0; }; // The following constants are the parameters for a particular experiment // within the field trial that controls this class's behaviors. static const char kCrossDevicePromoFieldTrial[]; // This field trial parameter specifies how often the device activity should // be fetched. static const char kParamHoursBetweenDeviceActivityChecks[]; // This field trial parameter defines for how long the profile's cookie must // contain exactly one GAIA account before the profile is considered // single-user. static const char kParamDaysToVerifySingleUserProfile[]; // This field trial parameter defines how much time must pass between calls // to MaybeBrowsingSessionStarted() before the code considers a new browsing // session to have started and re-evaluates if the promo should be shown. static const char kParamMinutesBetweenBrowsingSessions[]; // This field trial parameter defines how much time may pass between the last // observed device activity and the start of a new browsing session for the // promo to consider the new browsing session to be a context switch. static const char kParamMinutesMaxContextSwitchDuration[]; // This field trial parameter defines what percentage of all device activity // fetches should be not be executed, to throttle requests to the server. static const char kParamRPCThrottle[]; // Constructor takes non-null pointers to required services. This object does // not take ownership of any of the passed objects. This also calls Init(). explicit CrossDevicePromo(SigninManager* signin_manager, GaiaCookieManagerService* cookie_manager_service, SigninClient* signin_client, PrefService* pref_service); ~CrossDevicePromo() override; // KeyedService: // Ends observation of other services and records the length of any current // browsing session (see signin_metrics::LogBrowsingSessionDuration()). This // is called only during Chrome shutdown. void Shutdown() override; // GaiaCookieManagerService::Observer: // This supports monitoring whether the content area is signed into exactly // one GAIA account for a long period of time. This tracks the earliest time // |accounts| contained (and still contains) exactly one account, so that // other methods can use kParamDaysToVerifySingleUserProfile to verify if this // Profile is considered single-user. void OnGaiaAccountsInCookieUpdated( const std::vector<gaia::ListedAccount>& accounts, const GoogleServiceAuthError& error) override; // DeviceActivityFetcher::Observer: // OnFetchDeviceActivity* are called from |device_activity_fetcher_| which // was created in GetDevicesActivityForGAIAAccountInCookieJar(). Deletes // |device_activity_fetcher_| at the end of the method. // See DetermineEligibilityFromDeviceActivity() for details. void OnFetchDeviceActivitySuccess( const std::vector<DeviceActivityFetcher::DeviceActivity>& devices) override; void OnFetchDeviceActivityFailure() override; // Callable by third parties to register or unregister for callbacks when the // promo's eligibility-to-be-shown state changes. void AddObserver(CrossDevicePromo::Observer* observer); void RemoveObserver(CrossDevicePromo::Observer* observer); // Returns whether the profile has been marked as eligible to be shown the // promo. bool ShouldShowPromo() const; // Called when the user requests to opt out of the promo. This will set a pref // that forever marks the profile ineligible for the promo. void OptOut(); // Called whenever a browser becomes active. Notes the start of a new browsing // session if the last call to this method (noted in |previous_last_active|) // was more than |inactivity_between_browsing_sessions_| ago. For new browsing // sessions, will either determine if the promo is eligible to be shown, or // will use |device_activity_timer_| to schedule getting more information with // GetDevicesActivityForGAIAAccountInCookieJar(). void MaybeBrowsingSessionStarted(const base::Time& previous_last_active); // Called only in tests; calls Init() if not already initialized. See comments // on |initialized_| for details. bool CheckPromoEligibilityForTesting(); private: // Initializes configuration parameters from the "CrossDevicePromo" field // trial and registers for changes to the relevant GAIA cookie. In tests, this // may be called more than once; see |initialized_| for details. void Init(); // Called when the determination of whether to show the promo has been made. // This both stores that decision and notifies all registered observers of any // change. void MarkPromoShouldBeShown(); void MarkPromoShouldNotBeShown(); // Performs all checks to determine if this profile could be shown the promo // except for initiating a fetch for additional data. This will return false // if the data available locally indicates the profile should not be shown // the promo; returns true if the profile could be shown the promo (even if // additional checks are to be performed). bool CheckPromoEligibility(); // Called whenever new device activity is available. Checks that there is at // least one device that had activity within the past // kParamMinutesMaxContextSwitchDuration to determine if the promo should be // shown. Once determined, the MarkPromoShould[Not]BeShown() method is called. // Note that if the device is in a context switch, a followup call to // GetDevicesActivityForGAIAAccountInCookieJar() will be scheduled for when // the context switch would expire. void DetermineEligibilityFromDeviceActivity( const std::vector<DeviceActivityFetcher::DeviceActivity>& devices); // Helpers to get and set the time value stored in a pref. base::Time GetTimePref(const std::string& pref) const; void SetTimePref(const std::string& pref, const base::Time& value); // Performs checks if the promo is eligible to be displayed to this profile. // This will not write any prefs or initiate any checks that are otherwise // called in CheckPromoEligibility(). Records no metrics. Used for DCHECKs. bool VerifyPromoEligibleReadOnly() const; // Adds or removes |this| as an observer of |cookie_manager_service_|. // We observe the |cookie_manager_service_| for its lifetime. void RegisterForCookieChanges(); void UnregisterForCookieChanges(); // Creates a new DeviceActivityFetcher to get the list of devices, and the // details of the devices (see DeviceActivityFetcher.h) where the GAIA account // in this profile's cookie jar is signed in to Chrome Sync. // If a |device_activity_fetcher_| is already executing a fetch, this method // will not start a second fetch, as the results would be the same. void GetDevicesActivityForGAIAAccountInCookieJar(); // Set by Init() to indicate if the promo service has been successfully // initialized. Initialization will not occur if the user has previously opted // out of the promo. Also, successful initialization requires all necessary // parameters that control the promo to be read from the field trial. // In testing an initial call to Init() may fail and a future call may succeed // (see Init()); in non-test scenarios, however, failed initialization is // unrecoverable and future calls to other class methods should be no-ops. bool initialized_; // These four pointers are weak pointers; they are not owned by this object // and will outlive this object. SigninManager* signin_manager_; GaiaCookieManagerService* cookie_manager_service_; PrefService* prefs_; SigninClient* signin_client_; scoped_ptr<DeviceActivityFetcher> device_activity_fetcher_; base::ObserverList<CrossDevicePromo::Observer> observer_list_; // Initialized from the |kParamMinutesMaxContextSwitchDuration| field trial // parameter. See |kParamMinutesMaxContextSwitchDuration| for details. base::TimeDelta context_switch_duration_; // If the device activity has never been fetched, the delay until the check // will be a random duration between zero and // |kParamHoursBetweenDeviceActivityChecks|. For all other // fetches, the delay will be |kParamHoursBetweenDeviceActivityChecks|. See // |kParamHoursBetweenDeviceActivityChecks| for details. base::TimeDelta delay_until_next_device_activity_fetch_; // Initialized from the |kParamDaysToVerifySingleUserProfile| field trial // parameter. See |kParamDaysToVerifySingleUserProfile| for details. base::TimeDelta single_account_duration_threshold_; // Initialized from the |kParamMinutesBetweenBrowsingSessions| field trial // parameter. See |kParamMinutesBetweenBrowsingSessions| for details. base::TimeDelta inactivity_between_browsing_sessions_; // Randomly initialized from the |kParamRPCThrottle| field trial parameter. // See |kParamRPCThrottle| for details. If true, |device_activity_fetcher_| // should never be initialized. bool is_throttled_; // Metric to help us track how long a browsing session is. This is set in // MaybeBrowsingSessionStarted(), see that method for details. // Useful for configuring the field trial to manage our server quota. base::Time start_last_browsing_session_; // Used to delay the check of device activity. See // OnFetchDeviceActivitySuccess() or MaybeBrowsingSessionStarted(), as well as // |delay_until_next_device_activity_fetch_|, for details. base::OneShotTimer device_activity_timer_; DISALLOW_COPY_AND_ASSIGN(CrossDevicePromo); }; #endif // CHROME_BROWSER_SIGNIN_CROSS_DEVICE_PROMO_H_
[ "steven.jun.liu@qq.com" ]
steven.jun.liu@qq.com
da5dce1c8726e953091ae9c6518316ebad1a4951
aee4a398cdb812f58b2db15930cf001cea168bf3
/week6/problemSolving/src/Tree.cpp
c7b8246514a0e5e914aa8f7c6bd02ed17bcc169c
[]
no_license
nicoleyimessier/code2_BFADT
d79185129359e0f300deb675fe5b636a4f558130
6a265955a931304a5ce32e425a11741c7a4b5f90
refs/heads/master
2021-01-10T07:10:10.720243
2016-04-18T17:11:10
2016-04-18T17:11:10
50,304,535
2
0
null
null
null
null
UTF-8
C++
false
false
1,749
cpp
// // Tree.cpp // recursiveTreeObject // // Created by Nicole Messier on 2/24/16. // // #include "Tree.h" void Tree::seed1(float dotSize, float angle, float x, float y){ ofSetColor(255,0,0); ofFill(); //nested if statement if(dotSize > 1.0f){ float r = ofRandomuf(); // gives you a random number btwn 0 & 1 //first if statement will happen 98 of time if (r > 0.02f) { ofCircle(x, y, dotSize); float newX = x + cos(angle)*dotSize; float newY = y + sin(angle)*dotSize; seed1(dotSize*0.99f, angle - angleOffSetA, newX, newY); } else { ofCircle(x, y, dotSize); float newX = x + cos(angle); float newY = y + sin(angle); seed1(dotSize*0.99f, angle - angleOffSetA, newX, newY); seed2(dotSize*0.6f, angle + angleOffSetB, newX, newY); seed1(dotSize*0.5f, angle + angleOffSetB, newX, newY); } } } void Tree:: seed2(float dotSize, float angle, float x, float y){ ofColor(0, 0, 255); ofFill(); if(dotSize > 1.0f){ float r = ofRandomuf(); if(r > 0.05f){ ofCircle(x, y, dotSize); float newX = x + cos(angle)*dotSize; float newY = y + sin(angle)*dotSize; seed2(dotSize*0.99f, angle + angleOffSetA, newX, newY); } else { ofCircle(x, y, dotSize); float newX = x + cos(angle); float newY = y + sin(angle); seed2(dotSize*0.99f, angle - angleOffSetA, newX, newY); seed1(dotSize*0.6f, angle + angleOffSetB, newX, newY); seed2(dotSize*0.5f, angle - angleOffSetB, newX, newY); } } }
[ "nmessier88@gmail.com" ]
nmessier88@gmail.com
55cd96fef5e87442cfefc1b355a1f88c0fbdd287
0bb6111151418264c55098ed3acf7c9cae94a928
/src/Components/InputComponent.cpp
91b528a966aadc8541b4aebf7edd8d78e56f71cc
[]
no_license
gidabite/ScalableServerSystem
935cc2f87bcd5dbfee54d07804ef7bd4a3308d47
39edd5c334ace34ba281754a17d32da0de161b96
refs/heads/master
2021-01-12T17:32:22.455200
2017-05-27T22:36:23
2017-05-27T22:36:23
71,596,250
0
0
null
null
null
null
UTF-8
C++
false
false
845
cpp
/* * InputComponent.cpp * * Created on: 17.02.2017 * Author: gidabite */ #include "InputComponent.h" #include "iostream" bool InputComponent::isRun = true; InputComponent::InputComponent() { } void InputComponent::go() { m_thr = new thread(run); } InputComponent::~InputComponent() { } InputComponent& InputComponent::init(){ static InputComponent InpComp; return InpComp; } void InputComponent::join() { m_thr->join(); delete m_thr; } void InputComponent::run() { //ClientMeneger::init(INET, "192.168.43.215:45678"); //ClientMeneger cm(INET, "192.168.43.215:45678");//"192.168.1.45:45678"); cout << "Start Input Component" << endl; int i = 0; while (isRun) { //for (int i = 0; i < 15; i ++){ ClientMeneger::init()->Wait(); //} usleep(1000); } } void InputComponent::Cancel() { this->isRun = false; }
[ "pavel210995@gmail.com" ]
pavel210995@gmail.com
944c4ac87cea4130216ba9f59dcd4ef30cadcea8
3708d4d8c249d4dc17d24cfa602218025505010d
/9 Grading.cpp
25a226eccd9d8c8125a2161c5f5ead7c081feb47
[]
no_license
FarheenShakeel/DSA-Bootcamp-Assignment
4dfbdcb490e82ca8c090111982370650372a435a
dc9a4f75b6cb9e453911a7fc4795c9542607edf6
refs/heads/main
2023-07-18T04:21:44.258728
2021-09-04T14:01:52
2021-09-04T14:01:52
403,059,093
1
1
null
null
null
null
UTF-8
C++
false
false
455
cpp
#include <iostream> using namespace std; int main() { int n; int grade,x; //cout<<"Enter number of students (n) : "; cin>>n; //cout<<"Grades : "<<endl; for(int i=0; i<n; i++) { //cout<<"Student "<<i+1<<" : "; cin>>grade; if (grade>=38) { x = grade%5; if (x>= 3) grade+= 5-x; } //cout<<"Final Grade : "; cout<<grade<<endl; } return 0; }
[ "noreply@github.com" ]
FarheenShakeel.noreply@github.com
418669090a521b2d91c89503baae14ec61c426b2
96b671705ba09a3aedd9abc3377e5604a33ba542
/d3d9/IDirect3DIndexBuffer9.cpp
6a2c3ce3c0974a6a7d9e8ee6f28804fa826b213e
[ "Zlib" ]
permissive
AirwavesMan/dxwrapper
13b1701d727bc69713c3c9781f22f72bcdb482bf
b0ad9aea3855c98fa8cf930c8cb71dfd603be3a2
refs/heads/master
2020-11-29T23:47:20.027870
2019-12-16T03:50:06
2019-12-16T03:50:06
230,242,369
1
0
NOASSERTION
2019-12-26T10:14:31
2019-12-26T10:14:30
null
UTF-8
C++
false
false
3,885
cpp
/** * Copyright (C) 2019 Elisha Riedlinger * * This software is provided 'as-is', without any express or implied warranty. In no event will the * authors be held liable for any damages arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, including commercial * applications, and to alter it and redistribute it freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the * original software. If you use this software in a product, an acknowledgment in the product * documentation would be appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as * being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #include "d3d9.h" HRESULT m_IDirect3DIndexBuffer9::QueryInterface(THIS_ REFIID riid, void** ppvObj) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if ((riid == IID_IDirect3DIndexBuffer9 || riid == IID_IUnknown || riid == IID_IDirect3DResource9) && ppvObj) { AddRef(); *ppvObj = this; return D3D_OK; } HRESULT hr = ProxyInterface->QueryInterface(riid, ppvObj); if (SUCCEEDED(hr)) { D3d9Wrapper::genericQueryInterface(riid, ppvObj, m_pDeviceEx); } return hr; } ULONG m_IDirect3DIndexBuffer9::AddRef(THIS) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->AddRef(); } ULONG m_IDirect3DIndexBuffer9::Release(THIS) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->Release(); } HRESULT m_IDirect3DIndexBuffer9::GetDevice(THIS_ IDirect3DDevice9** ppDevice) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (!ppDevice) { return D3DERR_INVALIDCALL; } m_pDeviceEx->AddRef(); *ppDevice = m_pDeviceEx; return D3D_OK; } HRESULT m_IDirect3DIndexBuffer9::SetPrivateData(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->SetPrivateData(refguid, pData, SizeOfData, Flags); } HRESULT m_IDirect3DIndexBuffer9::GetPrivateData(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->GetPrivateData(refguid, pData, pSizeOfData); } HRESULT m_IDirect3DIndexBuffer9::FreePrivateData(THIS_ REFGUID refguid) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->FreePrivateData(refguid); } DWORD m_IDirect3DIndexBuffer9::SetPriority(THIS_ DWORD PriorityNew) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->SetPriority(PriorityNew); } DWORD m_IDirect3DIndexBuffer9::GetPriority(THIS) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->GetPriority(); } void m_IDirect3DIndexBuffer9::PreLoad(THIS) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->PreLoad(); } D3DRESOURCETYPE m_IDirect3DIndexBuffer9::GetType(THIS) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->GetType(); } HRESULT m_IDirect3DIndexBuffer9::Lock(THIS_ UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->Lock(OffsetToLock, SizeToLock, ppbData, Flags); } HRESULT m_IDirect3DIndexBuffer9::Unlock(THIS) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->Unlock(); } HRESULT m_IDirect3DIndexBuffer9::GetDesc(THIS_ D3DINDEXBUFFER_DESC *pDesc) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; return ProxyInterface->GetDesc(pDesc); }
[ "elisha@novicemail.com" ]
elisha@novicemail.com
26d4d8691ff1519978ef2624ba442e9b7aaeff19
19907e496cfaf4d59030ff06a90dc7b14db939fc
/POC/oracle_dapp/node_modules/wrtc/third_party/webrtc/include/chromium/src/third_party/WebKit/Source/web/tests/FakeWebPlugin.h
5b3f1c35c4feceecb430292406b654c1472528c6
[ "BSD-2-Clause" ]
permissive
ATMatrix/demo
c10734441f21e24b89054842871a31fec19158e4
e71a3421c75ccdeac14eafba38f31cf92d0b2354
refs/heads/master
2020-12-02T20:53:29.214857
2017-08-28T05:49:35
2017-08-28T05:49:35
96,223,899
8
4
null
2017-08-28T05:49:36
2017-07-04T13:59:26
JavaScript
UTF-8
C++
false
false
3,384
h
/* * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FakeWebPlugin_h #define FakeWebPlugin_h #include "public/web/WebPlugin.h" namespace blink { class WebDragData; class WebFrame; class WebInputEvent; class WebPluginContainer; class WebURL; class WebURLResponse; struct WebPluginParams; class FakeWebPlugin : public WebPlugin { public: FakeWebPlugin(WebFrame*, const WebPluginParams&); // WebPlugin methods: bool initialize(WebPluginContainer*) override; void destroy() override; NPObject* scriptableObject() override { return 0; } bool canProcessDrag() const override { return false; } void layoutIfNeeded() override { } void paint(WebCanvas*, const WebRect&) override { } void updateGeometry(const WebRect& clientRect, const WebRect& clipRect, const WebRect& windowClipRect, const WebVector<WebRect>& cutOutsRects, bool isVisible) override { } void updateFocus(bool, WebFocusType) override { } void updateVisibility(bool) override { } bool acceptsInputEvents() override { return true; } WebInputEventResult handleInputEvent(const WebInputEvent&, WebCursorInfo&) override { return WebInputEventResult::NotHandled; } bool handleDragStatusUpdate(WebDragStatus, const WebDragData&, WebDragOperationsMask, const WebPoint& position, const WebPoint& screenPosition) override { return false; } void didReceiveResponse(const WebURLResponse&) override { } void didReceiveData(const char* data, int dataLength) override { } void didFinishLoading() override { } void didFailLoading(const WebURLError&) override { } bool isPlaceholder() override { return false; } protected: virtual ~FakeWebPlugin(); WebPluginContainer* container() const { return m_container; } private: WebFrame* m_frame; WebPluginContainer* m_container; }; } // namespace blink #endif // FakeWebPlugin_h
[ "steven.jun.liu@qq.com" ]
steven.jun.liu@qq.com
b752b45b8e448ba83b5613972256f060776ab43f
3a1f357b1df490329856ea82b3293f8854bd419e
/src/blitter/factory.hpp
7d25823a61d851c21fce2dd23d69c32a34933cba
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
mk0x9/OpenTTD
fba2bd85b6b06d91cd7e52371e0f5d858ae14d14
fd7fca73cf61a2960e8df8fa221b179d23ae3ef0
refs/heads/master
2021-01-16T23:27:05.118882
2011-10-29T01:35:46
2011-10-29T01:35:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,950
hpp
/* $Id$ */ /* * This file is part of OpenTTD. * OpenTTD 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, version 2. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file factory.hpp Factory to 'query' all available blitters. */ #ifndef BLITTER_FACTORY_HPP #define BLITTER_FACTORY_HPP #include "base.hpp" #include "../debug.h" #include "../string_func.h" #include "../core/string_compare_type.hpp" #include <map> #if defined(WITH_COCOA) bool QZ_CanDisplay8bpp(); #endif /* defined(WITH_COCOA) */ /** * The base factory, keeping track of all blitters. */ class BlitterFactoryBase { private: const char *name; ///< The name of the blitter factory. typedef std::map<const char *, BlitterFactoryBase *, StringCompare> Blitters; ///< Map of blitter factories. /** * Get the map with currently known blitters. * @return The known blitters. */ static Blitters &GetBlitters() { static Blitters &s_blitters = *new Blitters(); return s_blitters; } /** * Get the currently active blitter. * @return The currently active blitter. */ static Blitter **GetActiveBlitter() { static Blitter *s_blitter = NULL; return &s_blitter; } protected: /** * Register a blitter internally, based on his name. * @param name the name of the blitter. * @note an assert() will be trigger if 2 blitters with the same name try to register. */ void RegisterBlitter(const char *name) { /* Don't register nameless Blitters */ if (name == NULL) return; this->name = strdup(name); std::pair<Blitters::iterator, bool> P = GetBlitters().insert(Blitters::value_type(name, this)); assert(P.second); } public: BlitterFactoryBase() : name(NULL) {} virtual ~BlitterFactoryBase() { if (this->name == NULL) return; GetBlitters().erase(this->name); if (GetBlitters().empty()) delete &GetBlitters(); free((void *)this->name); } /** * Find the requested blitter and return his class. * @param name the blitter to select. * @post Sets the blitter so GetCurrentBlitter() returns it too. */ static Blitter *SelectBlitter(const char *name) { #if defined(DEDICATED) const char *default_blitter = "null"; #else const char *default_blitter = "8bpp-optimized"; #if defined(WITH_COCOA) /* Some people reported lack of fullscreen support in 8 bpp mode. * While we prefer 8 bpp since it's faster, we will still have to test for support. */ if (!QZ_CanDisplay8bpp()) { /* The main display can't go to 8 bpp fullscreen mode. * We will have to switch to 32 bpp by default. */ default_blitter = "32bpp-anim"; } #endif /* defined(WITH_COCOA) */ #endif /* defined(DEDICATED) */ if (GetBlitters().size() == 0) return NULL; const char *bname = (StrEmpty(name)) ? default_blitter : name; Blitters::iterator it = GetBlitters().begin(); for (; it != GetBlitters().end(); it++) { BlitterFactoryBase *b = (*it).second; if (strcasecmp(bname, b->name) == 0) { Blitter *newb = b->CreateInstance(); delete *GetActiveBlitter(); *GetActiveBlitter() = newb; DEBUG(driver, 1, "Successfully %s blitter '%s'", StrEmpty(name) ? "probed" : "loaded", bname); return newb; } } return NULL; } /** * Get the current active blitter (always set by calling SelectBlitter). */ static Blitter *GetCurrentBlitter() { return *GetActiveBlitter(); } /** * Fill a buffer with information about the blitters. * @param p The buffer to fill. * @param last The last element of the buffer. * @return p The location till where we filled the buffer. */ static char *GetBlittersInfo(char *p, const char *last) { p += seprintf(p, last, "List of blitters:\n"); Blitters::iterator it = GetBlitters().begin(); for (; it != GetBlitters().end(); it++) { BlitterFactoryBase *b = (*it).second; p += seprintf(p, last, "%18s: %s\n", b->name, b->GetDescription()); } p += seprintf(p, last, "\n"); return p; } /** * Get a nice description of the blitter-class. */ virtual const char *GetDescription() = 0; /** * Create an instance of this Blitter-class. */ virtual Blitter *CreateInstance() = 0; }; /** * A template factory, so ->GetName() works correctly. This because else some compiler will complain. */ template <class T> class BlitterFactory: public BlitterFactoryBase { public: BlitterFactory() { this->RegisterBlitter(((T *)this)->GetName()); } /** * Get the long, human readable, name for the Blitter-class. */ const char *GetName(); }; extern char *_ini_blitter; #endif /* BLITTER_FACTORY_HPP */
[ "jnicholl@rim.com" ]
jnicholl@rim.com
2f2ec0fbcf93c3b80c044d42cbaf9046083e7ad8
08577251e95727c9a38dc53b9daa4525c81eb391
/SceneEngine/LightingParser.h
0e752ec5c7841cffe296d8241a5d21c0022ed266
[ "MIT" ]
permissive
hck509/XLE
0ee2354fb81defe738c4b43d9908e1c83f0181a7
e65efd74c86fda3e38155ad386eca9aac061f7ba
refs/heads/master
2021-01-17T10:42:36.437417
2015-03-02T08:28:38
2015-03-02T08:28:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,235
h
// Copyright 2015 XLGAMES Inc. // // Distributed under the MIT License (See // accompanying file "LICENSE" or the website // http://www.opensource.org/licenses/mit-license.php) #pragma once #include "../RenderCore/Metal/Forward.h" #include "../RenderCore/Metal/ShaderResource.h" #include "../BufferUploads/IBufferUploads_Forward.h" #include "../Math/Matrix.h" #include <functional> namespace RenderCore { namespace Techniques { class CameraDesc; } } namespace SceneEngine { class RenderingQualitySettings { public: UInt2 _dimensions; unsigned _samplingCount, _samplingQuality; RenderingQualitySettings(); RenderingQualitySettings( UInt2 dimensions, unsigned samplingCount = 1, unsigned samplingQuality = 0); }; class LightingParserContext; class SceneParseSettings; /// <summary>Execute rendering<summary> /// This is the main entry point for rendering a scene. /// The lighting parser will organize buffers, perform lighting resolve /// operations and call out to the scene parser when parts of the scene /// need to be rendered. Typically this is called once per frame (though /// perhaps there are times when multiple renders are required for a frame, /// maybe for reflections). /// /// Note that the lighting parser will write the final result to the render /// target that is currently bound to the given context! Often, this will /// be the main back buffer. Usually, the width and height in "qualitySettings" /// should be the same dimensions as this output buffer (but that doesn't /// always have to be the case). /// /// The "qualitySettings" parameter allows the caller to define the resolution /// and sampling quality for rendering the scene. Be careful to select valid /// settings for sampling quality. /// /// Basic usage: /// <code> /// auto renderDevice = RenderCore::CreateDevice(); /// auto presentationChain = renderDevice->CreatePresentationChain(...); /// LightingParserContext lightingParserContext(...); /// renderDevice->BeginFrame(presentationChain.get()); /// /// SceneEngine::RenderingQualitySettings qualitySettings; /// auto presChainDesc = presentationChain->GetDesc(); /// qualitySettings._width = presChainDesc._width; /// qualitySettings._height = presChainDesc._height; /// qualitySettings._samplingCount = 1; /// qualitySettings._samplingQuality = 0; /// /// auto context = RenderCore::Metal::DeviceContext::GetImmediateContext(renderDevice.get()); /// SceneEngine::LightingParser_Execute(context, lightingParserContext, qualitySettings); /// /// presentationChain->Present(); /// </code> void LightingParser_Execute( RenderCore::Metal::DeviceContext* context, LightingParserContext& parserContext, const RenderingQualitySettings& qualitySettings); void LightingParser_ExecuteOverlayPass( RenderCore::Metal::DeviceContext* context, LightingParserContext& parserContext, const RenderingQualitySettings& qualitySettings, const Float4x4& projectionMatrix, bool drawSky); /// <summary>Initialise basic states for scene rendering<summary> /// Some render operations don't want to use the full lighting parser structure. /// In these cases, you can use LightingParser_SetupScene() to initialise the /// global states that are normally managed by the lighting parser. /// Note -- don't call this if you're using LightingParser_Execute. /// <seealso cref="LightingParser_Execute"/> void LightingParser_SetupScene( RenderCore::Metal::DeviceContext* context, LightingParserContext& parserContext, const RenderCore::Techniques::CameraDesc& camera, const RenderingQualitySettings& qualitySettings); /// <summary>Set camera related states after camera changes<summary> /// Normally this is called automatically by the system. /// But in cases where you need to change the camera settings, you can /// manually force an update of the shader constants related to projection /// with this call. /// (for example, used by the vegetation spawn to temporarily reduce the /// far clip distance) /// <seealso cref="LightingParser_SetupScene"/> void LightingParser_SetGlobalTransform( RenderCore::Metal::DeviceContext* context, LightingParserContext& parserContext, const RenderCore::Techniques::CameraDesc& sceneCamera, unsigned viewportWidth, unsigned viewportHeight, const Float4x4* specialProjectionMatrix = nullptr); /////////////////////////////////////////////////////////////////////////// class MainTargetsBox; /// <summary>The LightingResolveContext is used by lighting operations during the gbuffer resolve step</summary> /// Don't confuse with LightingParserContext. This is a different context object, representing /// a sub-step during the larger lighting parser process. /// During the lighting resolve step, we take the complete gbuffer, and generate the "lighting buffer" /// There are typically a number of steps to perform, for effects like reflections, indirect /// lighting and atmosphere attenuation class LightingResolveContext { public: struct Pass { enum Enum { PerSample, PerPixel, Prepare }; }; Pass::Enum GetCurrentPass() const; bool UseMsaaSamplers() const; unsigned GetSamplingCount() const; MainTargetsBox& GetMainTargets() const; typedef void ResolveFn(RenderCore::Metal::DeviceContext*, LightingParserContext&, LightingResolveContext&); void AppendResolve(std::function<ResolveFn>&& fn); void SetPass(Pass::Enum newPass); // The following are bound resources used by the ambient resolve shader // In this way, we can do the resolve for all of these effects in one step // (rather than having to perform a bunch of separate passes) // But it means we need some special case handling for these resources. RenderCore::Metal::ShaderResourceView _tiledLightingResult; RenderCore::Metal::ShaderResourceView _ambientOcclusionResult; RenderCore::Metal::ShaderResourceView _screenSpaceReflectionsResult; std::vector<std::function<ResolveFn>> _queuedResolveFunctions; LightingResolveContext(MainTargetsBox& mainTargets); ~LightingResolveContext(); private: unsigned _samplingCount; bool _useMsaaSamplers; Pass::Enum _pass; MainTargetsBox* _mainTargets; }; /// <summary>Plug-in for the lighting parser</summary> /// This allows for some customization of the lighting parser operations. /// There are 2 important hooks for customization: /// <list> /// <item>OnPreScenePrepare -- this will be executed before the main rendering process begins. /// It is needed for preparing resources that will be used in later steps of the pipeline. /// <item>OnLightingResolvePrepare -- this will be executed before the lighting resolve step /// begins. There are two purposes to this: to prepare any resources that will be required /// during lighting resolve, and to queue operations that should happen during lighting /// resolve. To queue operations, use LightingResolveContext::AppendResolve /// </list> /// class ILightingParserPlugin { public: virtual void OnPreScenePrepare( RenderCore::Metal::DeviceContext*, LightingParserContext&) const = 0; virtual void OnLightingResolvePrepare( RenderCore::Metal::DeviceContext*, LightingParserContext&, LightingResolveContext&) const = 0; virtual void OnPostSceneRender( RenderCore::Metal::DeviceContext*, LightingParserContext&, const SceneParseSettings&, unsigned techniqueIndex) const = 0; }; }
[ "djewsbury@xlgames.com" ]
djewsbury@xlgames.com
e100299c8b749d42231b341f20354b75b364e1cd
6304fa5f0a3b2716fcbb4026748f66e3a1a53945
/dataManager/utilities/http_client.h
90407e578091df76cfac0a2ee8f8b0c4173bdfdd
[]
no_license
astroeng/DataManager
aa6e1181b08feeda08bf6805afdeafcf9b9787b7
b15d6a882eb8558c1fd9fde0210899da2c3bcdcb
refs/heads/master
2020-03-10T18:10:55.446379
2018-04-14T13:24:41
2018-04-14T13:24:41
129,519,271
0
0
null
null
null
null
UTF-8
C++
false
false
2,368
h
/* Derek Schacht * 2016 10 25 * License : Give me credit where it is due. * Disclaimer : I try and cite code that I find on the internet but I am not * perfect. If you find something that should be cited let me know * and I will update my code. * Warranty : Absolutely None * * This header also applies to all previous commits. But, I reserve the right * to modify this in the future. */ #ifndef HTTP_CLIENT_H #define HTTP_CLIENT_H #include <string> using namespace std; #include "tcp_client.h" /*! \file http_client.h \brief Provides an interface to basic HTTP message structures. */ /*! \enum HTTP_Send_Return_Type \brief Indicates the data send status. */ typedef enum { HTTP_Send_Success = 0, HTTP_Send_Fail } HTTP_Send_Return_Type; /*! \enum HTTP_Return_Type \brief Defines the possible HTTP_Response_Codes */ typedef enum { HTTP_Continue = 100, HTTP_Switching_Protocols = 101, HTTP_Processing = 102, HTTP_OK = 200, HTTP_Created = 201, HTTP_Accepted = 202, HTTP_NonAuthoritative_Information = 203, HTTP_No_Content = 204, HTTP_Reset_Content = 205, HTTP_Partial_Content = 206, HTTP_MultiStatus = 207, HTTP_Already_Reported = 208, HTTP_IM_Used = 226, HTTP_Multiple_Choices = 300, HTTP_Moved_Permanently = 301, HTTP_Found = 302, HTTP_See_Other = 303, HTTP_Not_Modified = 304, HTTP_Use_Proxy = 305, HTTP_Switch_Proxy = 306, HTTP_Temporary_Redirect = 307, HTTP_Permanent_Redirect = 308, HTTP_Bad_Request = 400, HTTP_Service_Unavailable = 503 //TODO: Finish this enumeration... } HTTP_Return_Type; class HTTP_Client: public TCP_Client { public: HTTP_Client(string server, string port, int timeout); HTTP_Send_Return_Type sendMessage(string& message); string getResponse(); int getResponseCode(); private: int responseCode; string response; }; #endif
[ "dschacht@BuildRoot.(none)" ]
dschacht@BuildRoot.(none)
efbb492f257293850f597ddbf33d9cad25bef68a
038df27dfb74a68f7b2fef2f63e5cc6bfe720962
/examples/0002.a+b/hex.cc
290a557603440f681fb7c0d9d088e0e04a1cb1b3
[ "MIT" ]
permissive
klmr/fast_io
6226db934bbda0b78ae1fac80d20c635106db2c1
1393ef01b82dffa87f3008ec0898431865870a1f
refs/heads/master
2022-07-28T12:34:10.173427
2020-05-25T11:25:38
2020-05-25T11:25:38
266,780,867
2
0
NOASSERTION
2020-05-25T13:03:19
2020-05-25T13:03:19
null
UTF-8
C++
false
false
173
cc
#include"../../include/fast_io.h" #include"../../include/fast_io_in.h" int main() { std::size_t a,b; scan(fast_io::hex(a),fast_io::hex(b)); println(fast_io::hex(a+b)); }
[ "unlvsur@live.com" ]
unlvsur@live.com
791863dab2878f480d218c22e4d155122807721f
1d9e9d4f416607453e7c91c9dc45205bd7cb9e14
/iqc5/instrument/SerialPortDecode/enzymeImmunoassay/zsdec_alisei_com/main.cpp
f11d7fa71adb2b8d172f7805e70ba069befdb952
[]
no_license
allan1234569/iqc5
5542f2efe3e6eae0a59110ec2863d9beeef8c1cf
8a026564db0128005f90d3f7ca56787a7bcbbad3
refs/heads/master
2020-03-29T09:17:13.715443
2018-09-21T10:56:01
2018-09-21T10:56:01
149,750,494
1
0
null
null
null
null
UTF-8
C++
false
false
455
cpp
#include "w_alisei_com.h" #include <QApplication> #include "common.h" #include "single_application.h" int main(int argc, char *argv[]) { SingleApplication a(argc, argv,"EnzymeImmunoassay_ALISEI-COM"); setting->setIniCodec("UTF-8"); if (a.isRunning()) { f_log("一个解码程序已经运行"); exit(1); } if (!f_init()) { exit(1); } W_Alisei_Com w; w.show(); return a.exec(); }
[ "allan1234569@163.com" ]
allan1234569@163.com
67e0a19583f194f8a825e2edc77362deab8c04b1
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function14260/function14260_schedule_8/function14260_schedule_8.cpp
730fe0fef59dc82ad6a4538cee8c2b0b69cac9a9
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
1,391
cpp
#include <tiramisu/tiramisu.h> using namespace tiramisu; int main(int argc, char **argv){ tiramisu::init("function14260_schedule_8"); constant c0("c0", 8192), c1("c1", 8192); var i0("i0", 0, c0), i1("i1", 0, c1), i01("i01"), i02("i02"), i03("i03"), i04("i04"); input input00("input00", {i1}, p_int32); input input01("input01", {i1}, p_int32); input input02("input02", {i1}, p_int32); input input03("input03", {i0}, p_int32); input input04("input04", {i1}, p_int32); computation comp0("comp0", {i0, i1}, input00(i1) + input01(i1) + input02(i1) * input03(i0) + input04(i1)); comp0.tile(i0, i1, 128, 128, i01, i02, i03, i04); comp0.parallelize(i01); buffer buf00("buf00", {8192}, p_int32, a_input); buffer buf01("buf01", {8192}, p_int32, a_input); buffer buf02("buf02", {8192}, p_int32, a_input); buffer buf03("buf03", {8192}, p_int32, a_input); buffer buf04("buf04", {8192}, p_int32, a_input); buffer buf0("buf0", {8192, 8192}, p_int32, a_output); input00.store_in(&buf00); input01.store_in(&buf01); input02.store_in(&buf02); input03.store_in(&buf03); input04.store_in(&buf04); comp0.store_in(&buf0); tiramisu::codegen({&buf00, &buf01, &buf02, &buf03, &buf04, &buf0}, "../data/programs/function14260/function14260_schedule_8/function14260_schedule_8.o"); return 0; }
[ "ei_mekki@esi.dz" ]
ei_mekki@esi.dz
4a38c81a360403fb88fc03e7f981fc70fa0cf0fa
38c10c01007624cd2056884f25e0d6ab85442194
/components/copresence/handlers/gcm_handler.h
206db819075c6c4bb81f621f17f6e07cddc0fc20
[ "BSD-3-Clause" ]
permissive
zenoalbisser/chromium
6ecf37b6c030c84f1b26282bc4ef95769c62a9b2
e71f21b9b4b9b839f5093301974a45545dad2691
refs/heads/master
2022-12-25T14:23:18.568575
2016-07-14T21:49:52
2016-07-23T08:02:51
63,980,627
0
2
BSD-3-Clause
2022-12-12T12:43:41
2016-07-22T20:14:04
null
UTF-8
C++
false
false
1,158
h
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_ #define COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_ #include <string> #include "base/callback_forward.h" namespace gcm { class GCMDriver; } namespace copresence { // A class to handle GCM messages from the Copresence server. As far as the // rest of the system is concerned, it simply provides the registered GCM ID. // The implementation will call other classes to enact the message contents. class GCMHandler { public: // Callback to report that registration has completed. // Returns an empty ID if registration failed. using RegistrationCallback = base::Callback<void(const std::string&)>; GCMHandler() {} virtual ~GCMHandler() {} // Request the GCM ID. It may be returned now or later, via the callback. virtual void GetGcmId(const RegistrationCallback& callback) = 0; private: DISALLOW_COPY_AND_ASSIGN(GCMHandler); }; } // namespace copresence #endif // COMPONENTS_COPRESENCE_HANDLERS_GCM_HANDLER_H_
[ "zeno.albisser@hemispherian.com" ]
zeno.albisser@hemispherian.com
e1b1dfde9a53c4071e32ce36076c92c1dde994f3
fc086c3b2a270a8c98f2e63c4f6eeaca4acda7e2
/CSCI3081W/project/src/large_bus.cc
da06a001c839391850e46d60f882bb043d75971f
[]
no_license
samsam55345/school-projects
93f570c0342578517e404cc1a3a7614708ec5305
e7857c11835ee32517fe6d2e32a82619a48b7a79
refs/heads/master
2022-10-07T05:49:03.042571
2020-06-07T20:36:46
2020-06-07T20:36:46
270,423,144
0
0
null
null
null
null
UTF-8
C++
false
false
1,203
cc
/** * @file large_bus.cc * * * @copyright 2020 Sami Frank, All rights reserved. */ #include "src/large_bus.h" // creates a bus with capacity 90. LargeBus::LargeBus(std::string name, Route * out, Route * in, int capacity, double speed) : Bus(name, out, in) { name_ = name; outgoing_route_ = out; incoming_route_ = in; passenger_max_capacity_ = 90; speed_ = speed; distance_remaining_ = 0; next_stop_ = out->GetDestinationStop(); unloader_ = new PassengerUnloader; loader_ = new PassengerLoader; } // reports bus data to terminal when requested void LargeBus::Report(std::ostream& out) { out << "Name: " << name_ << std::endl; out << "Total passengers: " << total_passenger << std::endl; out << "Speed: " << speed_ << std::endl; out << "Bus Type: large" << std::endl; out << "Max Capacity: " << passenger_max_capacity_ << std::endl; out << "Distance to next stop: " << distance_remaining_ << std::endl; out << "\tPassengers (" << passengers_.size() << "): " << std::endl; for (std::list<Passenger *>::iterator it = passengers_.begin(); it != passengers_.end(); it++) { (*it)->Report(out); } }
[ "sami.frank@merrillcorp.com" ]
sami.frank@merrillcorp.com
8241fc7444d5c77ab375bf9e4c3c8251bc6ab14a
d4112c60caf40833965547465532a59ede6adf71
/include/vnx/Task.h
7e5749d73b6b12bac8d4d2c53ff59c98947a1200
[]
no_license
automyinc/vnx-base
1ab72dba6dc21053bd492cfd495f3b658a27b47c
095c2f30fbfe3c8882c29851faf132adc5120928
refs/heads/master
2022-01-27T03:45:51.372036
2021-12-25T17:57:27
2021-12-25T17:57:27
141,748,820
4
1
null
null
null
null
UTF-8
C++
false
false
1,017
h
/************************************************************************* * * [2017] - [2018] Automy Inc. * All Rights Reserved. * * NOTICE: All information contained herein is, and remains * the property of Automy Incorporated and its suppliers, * if any. The intellectual and technical concepts contained * herein are proprietary to Automy Incorporated * and its suppliers and may be covered by U.S. and Foreign Patents, * patents in process, and are protected by trade secret or copyright law. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Automy Incorporated. */ #ifndef INCLUDE_VNX_TASK_H_ #define INCLUDE_VNX_TASK_H_ #include <vnx/Message.hxx> #include <functional> namespace vnx { class Task : public Message { public: std::function<void()> function; static std::shared_ptr<Task> create() { return std::make_shared<Task>(); } }; } // vnx #endif /* INCLUDE_VNX_TASK_H_ */
[ "wittal@neobotix.de" ]
wittal@neobotix.de
0c72d77c2dd8baca2e8899ac1506b00c57b3ca62
2277375bd4a554d23da334dddd091a36138f5cae
/ThirdParty/Havok/Source/Physics/ConstraintSolver/Solve/hkpSolverResults.h
8c718c090d5cedd413c6a394db5d24ad5c36b395
[]
no_license
kevinmore/Project-Nebula
9a0553ccf8bdc1b4bb5e2588fc94516d9e3532bc
f6d284d4879ae1ea1bd30c5775ef8733cfafa71d
refs/heads/master
2022-10-22T03:55:42.596618
2020-06-19T09:07:07
2020-06-19T09:07:07
25,372,691
6
5
null
null
null
null
UTF-8
C++
false
false
2,186
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2013 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HKP_SOLVER_RESULTS_H #define HKP_SOLVER_RESULTS_H /// Constraint solver results. This class is used internally by the system, however it may be used to query the results /// of the constraint solver for this constraint on the last solve() call. class hkpSolverResults { public: HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_CONSTRAINT_SOLVER, hkpSolverResults ); /// Get the impulse applied by the solver on the last time step. This structure may be returned prior to the application of the /// constraint solver. For the case of a contact constraint it is initialized to a very crude guess at the expected initial impulse. HK_FORCE_INLINE hkReal getImpulseApplied() const; // internal use only HK_FORCE_INLINE hkpSolverResults(); // internal use only HK_FORCE_INLINE void init(); public: // internal use only hkReal m_impulseApplied; // internal use only hkReal m_internalSolverData; }; #include <Physics/ConstraintSolver/Solve/hkpSolverResults.inl> #endif // HKP_SOLVER_RESULTS_H /* * Havok SDK - Base file, BUILD(#20130912) * * Confidential Information of Havok. (C) Copyright 1999-2013 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available from salesteam@havok.com. * */
[ "dingfengyu@gmail.com" ]
dingfengyu@gmail.com
f8de22e57873f5db84f19d987d619371d858cb9d
bf023c0652450ebce19999b94258289c7f89de76
/mysticlight4j_native/mysticlight4j_native/dllmain.cpp
bcf18527819931ec0e7529733da7cb1a9f8e0bfa
[ "MIT" ]
permissive
fischmat/mysticlight4j
700bb7ed313651d4d6e9889d7bf0fbe8a33ee74f
d3267ca3775e0eb2e05ddc8b9b7c7b589103bddc
refs/heads/develop
2023-06-27T16:02:17.006977
2021-06-15T19:24:47
2021-06-15T19:24:47
253,092,062
6
1
MIT
2023-06-14T22:44:10
2020-04-04T20:24:34
Java
UTF-8
C++
false
false
507
cpp
// dllmain.cpp : Definiert den Einstiegspunkt für die DLL-Anwendung. #include "pch.h" #include <iostream> BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: loadMysticLightLibrary(); break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }
[ "matthias-fisch@hotmail.de" ]
matthias-fisch@hotmail.de
306e9a86abb93089613c1ab1eea0ef0aaddcd9ca
bf85f0bbd6b4ec2021e0939580d0d292d571ac77
/HW1/3.cpp
5a904092f65207327eff3e188891a4e13cae1589
[]
no_license
KarthikJVN/IE531_ADA
6ed531143518be58b8365a198a5c4b3056c57bbd
fc7c68c7722b8ce49469c2c0662a29de010b2ed9
refs/heads/master
2020-03-26T15:34:08.600791
2018-08-18T01:24:37
2018-08-18T01:24:37
145,050,983
1
0
null
null
null
null
WINDOWS-1252
C++
false
false
226
cpp
#include <iostream > using name space std ; void print integer (int num) { put char ( num % 10 + ’A ’ ) ; if ( num / 10 ) print integer ( num / 10 ) ; } int main ( ) { print integer ( 1234 ) ; cout << endl ; }
[ "jvnkarthik94@gmail.com" ]
jvnkarthik94@gmail.com
1fc64f1e588b664c846f083638aa8270a9ff2b03
8b070593d4017c8c828872af304e9461478345b1
/source/SDL/Event.h
621f48f59f4b5a29e230abef0974e97744f52744
[ "MIT" ]
permissive
peteward44/raytracer
f2e74f7f9eed1ffd48bbd3d8d099afbc75e21a83
46b0ccd57bc3c38142d6876d80b98de6b8126a22
refs/heads/master
2023-03-31T19:45:30.129136
2023-03-26T23:16:16
2023-03-26T23:16:16
45,032,955
0
0
null
null
null
null
UTF-8
C++
false
false
4,881
h
#ifndef EVENT_H #define EVENT_H #include "SDLpp.h" #include <boost/shared_ptr.hpp> namespace SDL { class Event { private: int type; protected: Event(SDL_Event* event) : type(event->type) {} Event(int type) : type(type) {} public: virtual ~Event()=0; inline boost::uint8_t GetType() const { return type; } }; class UnknownEvent : public Event { private: public: UnknownEvent(SDL_Event* event) : Event(event) {} }; class KeyboardEvent : public Event { private: boost::uint8_t state; SDL_Scancode scanCode; SDL_Keycode key; boost::uint16_t modifiers; public: KeyboardEvent(SDL_Event* event) : Event(event), state(event->key.state), scanCode(event->key.keysym.scancode), key(event->key.keysym.sym), modifiers(event->key.keysym.mod) {} inline boost::uint8_t GetState() const { return state; } inline SDL_Scancode GetScanCode() const { return scanCode; } inline SDL_Keycode GetKey() const { return key; } inline boost::uint16_t GetModifiers() const { return modifiers; } }; class MouseMotionEvent : public Event { private: boost::uint8_t state; boost::uint16_t x, y; boost::int16_t xrel, yrel; public: MouseMotionEvent(SDL_Event* event) : Event(event), state(event->motion.state), x(event->motion.x), y(event->motion.y), xrel(event->motion.xrel), yrel(event->motion.yrel) {} inline boost::uint8_t GetState() const { return state; } inline boost::uint16_t GetX() const { return x; } inline boost::uint16_t GetY() const { return y; } inline boost::int16_t GetXRelative() const { return xrel; } inline boost::int16_t GetYRelative() const { return yrel; } }; class MouseButtonEvent : public Event { private: boost::uint8_t button, state; boost::uint16_t x, y; public: MouseButtonEvent(SDL_Event* event) : Event(event), button(event->button.button), state(event->button.state), x(event->button.x), y(event->button.y) {} inline boost::uint8_t GetState() const { return state; } inline boost::uint8_t GetButton() const { return button; } inline boost::uint16_t GetX() const { return x; } inline boost::uint16_t GetY() const { return y; } }; class JoystickAxisEvent : public Event { private: boost::uint8_t which, axis; boost::int16_t value; public: JoystickAxisEvent(SDL_Event* event) : Event(event), which(event->jaxis.which), axis(event->jaxis.axis), value(event->jaxis.value) {} inline boost::uint8_t GetWhich() const { return which; } inline boost::uint8_t GetAxis() const { return axis; } inline boost::int16_t GetValue() const { return value; } }; class JoystickBallEvent : public Event { private: boost::uint8_t which, ball; boost::int16_t xrel, yrel; public: JoystickBallEvent(SDL_Event* event) : Event(event), which(event->jball.which), ball(event->jball.ball), xrel(event->jball.xrel), yrel(event->jball.yrel) {} inline boost::uint8_t GetWhich() const { return which; } inline boost::uint8_t GetBall() const { return ball; } inline boost::int16_t GetXRelative() const { return xrel; } inline boost::int16_t GetYRelative() const { return yrel; } }; class JoystickHatEvent : public Event { private: boost::uint8_t which, hat, value; public: JoystickHatEvent(SDL_Event* event) : Event(event), which(event->jhat.which), hat(event->jhat.hat), value(event->jhat.value) {} inline boost::uint8_t GetWhich() const { return which; } inline boost::uint8_t GetHat() const { return hat; } inline boost::uint8_t GetValue() const { return value; } }; class JoystickButtonEvent : public Event { private: boost::uint8_t which, button, state; public: JoystickButtonEvent(SDL_Event* event) : Event(event), which(event->jbutton.which), button(event->jbutton.button), state(event->jbutton.state) {} inline boost::uint8_t GetWhich() const { return which; } inline boost::uint8_t GetButton() const { return button; } inline boost::uint8_t GetState() const { return state; } }; class QuitEvent : public Event { private: public: QuitEvent(SDL_Event* event) : Event(event) {} }; class SystemEvent : public Event { private: public: SystemEvent(SDL_Event* event) : Event(event) {} }; class UserEvent : public Event { private: boost::uint8_t code; void* data1, *data2; public: UserEvent(SDL_Event* event) : Event(event), code(event->user.code), data1(event->user.data1), data2(event->user.data2) {} UserEvent(boost::uint8_t type, boost::uint8_t code, void* data1, void* data2) : Event(type), code(code), data1(data1), data2(data2) {} inline boost::uint8_t GetCode() const { return code; } inline void* GetData1() const { return data1; } inline void* GetData2() const { return data2; } }; } #endif
[ "peteward44@gmail.com" ]
peteward44@gmail.com
2ac7535a33e3daea93d3456ba6ac82fa80220634
1c2433f9251f6dd378156fc945a2a12a5a3ce663
/src/core/movie/ffmpeg/AudioCodecFFmpeg.cpp
323289cfddeb3cc3f5d5c18964fe52d23da89a08
[ "LicenseRef-scancode-warranty-disclaimer", "Zlib", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "Libpng", "BSD-2-Clause-Views", "FTL", "Apache-2.0", "BSD-2-Clause" ]
permissive
lspgw/Kirikiroid2
789dce84e5914e177cd1f7a8c28ec0d86922fd11
c398eba89d9df660e100f8284d7d9251eb5d5fab
refs/heads/master
2023-07-11T18:15:43.919297
2023-06-22T03:44:12
2023-06-22T03:44:12
230,595,645
0
0
NOASSERTION
2019-12-28T10:38:20
2019-12-28T10:38:19
null
UTF-8
C++
false
false
10,342
cpp
#include "AudioCodecFFmpeg.h" #ifdef TARGET_POSIX #include "XMemUtils.h" #endif #include "StreamInfo.h" #include "Codecs.h" extern "C" { #include "libavutil/opt.h" } #if defined(TARGET_DARWIN) #include "cores/AudioEngine/Utils/AEUtil.h" #endif #include "Clock.h" #include "AEUtil.h" #include "AEAudioFormat.h" NS_KRMOVIE_BEGIN CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg(CProcessInfo &processInfo) : CDVDAudioCodec(processInfo) { m_pCodecContext = NULL; m_channels = 0; m_layout = 0; m_pFrame1 = NULL; m_iSampleFormat = AV_SAMPLE_FMT_NONE; m_gotFrame = 0; } CDVDAudioCodecFFmpeg::~CDVDAudioCodecFFmpeg() { Dispose(); } bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) { AVCodec* pCodec = NULL; bool allowdtshddecode = true; // set any special options for(std::vector<CDVDCodecOption>::iterator it = options.m_keys.begin(); it != options.m_keys.end(); ++it) if (it->m_name == "allowdtshddecode") allowdtshddecode = atoi(it->m_value.c_str()); if (hints.codec == AV_CODEC_ID_DTS && allowdtshddecode) pCodec = avcodec_find_decoder_by_name("dcadec"); if (!pCodec) pCodec = avcodec_find_decoder(hints.codec); if (!pCodec) { // CLog::Log(LOGDEBUG,"CDVDAudioCodecFFmpeg::Open() Unable to find codec %d", hints.codec); return false; } m_pCodecContext = avcodec_alloc_context3(pCodec); if (!m_pCodecContext) return false; m_pCodecContext->debug_mv = 0; m_pCodecContext->debug = 0; m_pCodecContext->workaround_bugs = 1; if (pCodec->capabilities & CODEC_CAP_TRUNCATED) m_pCodecContext->flags |= CODEC_FLAG_TRUNCATED; m_matrixEncoding = AV_MATRIX_ENCODING_NONE; m_channels = 0; m_pCodecContext->channels = hints.channels; m_pCodecContext->sample_rate = hints.samplerate; m_pCodecContext->block_align = hints.blockalign; m_pCodecContext->bit_rate = hints.bitrate; m_pCodecContext->bits_per_coded_sample = hints.bitspersample; if(m_pCodecContext->bits_per_coded_sample == 0) m_pCodecContext->bits_per_coded_sample = 16; if( hints.extradata && hints.extrasize > 0 ) { m_pCodecContext->extradata = (uint8_t*)av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); if(m_pCodecContext->extradata) { m_pCodecContext->extradata_size = hints.extrasize; memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize); } } // if (g_advancedSettings.m_audioApplyDrc >= 0.0) // av_opt_set_double(m_pCodecContext, "drc_scale", g_advancedSettings.m_audioApplyDrc, AV_OPT_SEARCH_CHILDREN); if (avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) { // CLog::Log(LOGDEBUG,"CDVDAudioCodecFFmpeg::Open() Unable to open codec"); Dispose(); return false; } m_pFrame1 = av_frame_alloc(); if (!m_pFrame1) { Dispose(); return false; } m_iSampleFormat = AV_SAMPLE_FMT_NONE; m_matrixEncoding = AV_MATRIX_ENCODING_NONE; m_processInfo.SetAudioDecoderName(m_pCodecContext->codec->name); return true; } void CDVDAudioCodecFFmpeg::Dispose() { av_frame_free(&m_pFrame1); avcodec_free_context(&m_pCodecContext); } int CDVDAudioCodecFFmpeg::Decode(uint8_t* pData, int iSize, double dts, double pts) { int iBytesUsed; if (!m_pCodecContext) return -1; AVPacket avpkt; av_init_packet(&avpkt); avpkt.data = pData; avpkt.size = iSize; avpkt.dts = (dts == DVD_NOPTS_VALUE) ? AV_NOPTS_VALUE : dts / DVD_TIME_BASE * AV_TIME_BASE; avpkt.pts = (pts == DVD_NOPTS_VALUE) ? AV_NOPTS_VALUE : pts / DVD_TIME_BASE * AV_TIME_BASE; iBytesUsed = avcodec_decode_audio4( m_pCodecContext , m_pFrame1 , &m_gotFrame , &avpkt); if (iBytesUsed < 0 || !m_gotFrame) { return iBytesUsed; } else if (m_pFrame1->channels == 0) { // fix channels issue m_pFrame1->channels = av_frame_get_channels(m_pFrame1); } /* some codecs will attempt to consume more data than what we gave */ if (iBytesUsed > iSize) { // CLog::Log(LOGWARNING, "CDVDAudioCodecFFmpeg::Decode - decoder attempted to consume more data than given"); iBytesUsed = iSize; } if (m_pFrame1->nb_side_data) { for (int i = 0; i < m_pFrame1->nb_side_data; i++) { AVFrameSideData *sd = m_pFrame1->side_data[i]; if (sd->data) { if (sd->type == AV_FRAME_DATA_MATRIXENCODING) { m_matrixEncoding = *(enum AVMatrixEncoding*)sd->data; } } } } m_format.m_dataFormat = GetDataFormat(); m_format.m_channelLayout = GetChannelMap(); m_format.m_sampleRate = GetSampleRate(); m_format.m_frameSize = m_format.m_channelLayout.Count() * CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3; return iBytesUsed; } void CDVDAudioCodecFFmpeg::GetData(DVDAudioFrame &frame) { frame.passthrough = false; frame.nb_frames = 0; frame.format.m_dataFormat = m_format.m_dataFormat; frame.format.m_channelLayout = m_format.m_channelLayout; frame.framesize = (CAEUtil::DataFormatToBits(frame.format.m_dataFormat) >> 3) * frame.format.m_channelLayout.Count(); if(frame.framesize == 0) return; frame.nb_frames = GetData(frame.data)/frame.framesize; frame.planes = AE_IS_PLANAR(frame.format.m_dataFormat) ? frame.format.m_channelLayout.Count() : 1; frame.bits_per_sample = CAEUtil::DataFormatToBits(frame.format.m_dataFormat); frame.format.m_sampleRate = m_format.m_sampleRate; frame.matrix_encoding = GetMatrixEncoding(); frame.audio_service_type = GetAudioServiceType(); frame.profile = GetProfile(); // compute duration. if (frame.format.m_sampleRate) frame.duration = ((double)frame.nb_frames * DVD_TIME_BASE) / frame.format.m_sampleRate; else frame.duration = 0.0; int64_t bpts = av_frame_get_best_effort_timestamp(m_pFrame1); if(bpts != AV_NOPTS_VALUE) frame.pts = (double)bpts * DVD_TIME_BASE / AV_TIME_BASE; else frame.pts = DVD_NOPTS_VALUE; } int CDVDAudioCodecFFmpeg::GetData(uint8_t** dst) { if(m_gotFrame) { int planes = av_sample_fmt_is_planar(m_pCodecContext->sample_fmt) ? m_pFrame1->channels : 1; for (int i=0; i<planes; i++) dst[i] = m_pFrame1->extended_data[i]; m_gotFrame = 0; return m_pFrame1->nb_samples * m_pFrame1->channels * av_get_bytes_per_sample(m_pCodecContext->sample_fmt); } return 0; } void CDVDAudioCodecFFmpeg::Reset() { if (m_pCodecContext) avcodec_flush_buffers(m_pCodecContext); m_gotFrame = 0; } int CDVDAudioCodecFFmpeg::GetChannels() { return m_pCodecContext->channels; } int CDVDAudioCodecFFmpeg::GetSampleRate() { if (m_pCodecContext) return m_pCodecContext->sample_rate; return 0; } enum AEDataFormat CDVDAudioCodecFFmpeg::GetDataFormat() { switch(m_pCodecContext->sample_fmt) { case AV_SAMPLE_FMT_U8 : return AE_FMT_U8; case AV_SAMPLE_FMT_U8P : return AE_FMT_U8P; case AV_SAMPLE_FMT_S16: return AE_FMT_S16NE; case AV_SAMPLE_FMT_S16P: return AE_FMT_S16NEP; case AV_SAMPLE_FMT_S32: return AE_FMT_S32NE; case AV_SAMPLE_FMT_S32P: return AE_FMT_S32NEP; case AV_SAMPLE_FMT_FLT: return AE_FMT_FLOAT; case AV_SAMPLE_FMT_FLTP: return AE_FMT_FLOATP; case AV_SAMPLE_FMT_DBL: return AE_FMT_DOUBLE; case AV_SAMPLE_FMT_DBLP: return AE_FMT_DOUBLEP; case AV_SAMPLE_FMT_NONE: default: // CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::GetDataFormat - invalid data format"); return AE_FMT_INVALID; } } int CDVDAudioCodecFFmpeg::GetBitRate() { if (m_pCodecContext) return m_pCodecContext->bit_rate; return 0; } enum AVMatrixEncoding CDVDAudioCodecFFmpeg::GetMatrixEncoding() { return m_matrixEncoding; } enum AVAudioServiceType CDVDAudioCodecFFmpeg::GetAudioServiceType() { if (m_pCodecContext) return m_pCodecContext->audio_service_type; return AV_AUDIO_SERVICE_TYPE_MAIN; } int CDVDAudioCodecFFmpeg::GetProfile() { if (m_pCodecContext) return m_pCodecContext->profile; return 0; } static unsigned count_bits(int64_t value) { unsigned bits = 0; for(;value;++bits) value &= value - 1; return bits; } void CDVDAudioCodecFFmpeg::BuildChannelMap() { if (m_channels == m_pCodecContext->channels && m_layout == m_pCodecContext->channel_layout) return; //nothing to do here m_channels = m_pCodecContext->channels; m_layout = m_pCodecContext->channel_layout; int64_t layout; int bits = count_bits(m_pCodecContext->channel_layout); if (bits == m_pCodecContext->channels) layout = m_pCodecContext->channel_layout; else { // CLog::Log(LOGINFO, "CDVDAudioCodecFFmpeg::GetChannelMap - FFmpeg reported %d channels, but the layout contains %d ignoring", m_pCodecContext->channels, bits); layout = av_get_default_channel_layout(m_pCodecContext->channels); } m_channelLayout.Reset(); if (layout & AV_CH_FRONT_LEFT ) m_channelLayout += AE_CH_FL ; if (layout & AV_CH_FRONT_RIGHT ) m_channelLayout += AE_CH_FR ; if (layout & AV_CH_FRONT_CENTER ) m_channelLayout += AE_CH_FC ; if (layout & AV_CH_LOW_FREQUENCY ) m_channelLayout += AE_CH_LFE ; if (layout & AV_CH_BACK_LEFT ) m_channelLayout += AE_CH_BL ; if (layout & AV_CH_BACK_RIGHT ) m_channelLayout += AE_CH_BR ; if (layout & AV_CH_FRONT_LEFT_OF_CENTER ) m_channelLayout += AE_CH_FLOC; if (layout & AV_CH_FRONT_RIGHT_OF_CENTER) m_channelLayout += AE_CH_FROC; if (layout & AV_CH_BACK_CENTER ) m_channelLayout += AE_CH_BC ; if (layout & AV_CH_SIDE_LEFT ) m_channelLayout += AE_CH_SL ; if (layout & AV_CH_SIDE_RIGHT ) m_channelLayout += AE_CH_SR ; if (layout & AV_CH_TOP_CENTER ) m_channelLayout += AE_CH_TC ; if (layout & AV_CH_TOP_FRONT_LEFT ) m_channelLayout += AE_CH_TFL ; if (layout & AV_CH_TOP_FRONT_CENTER ) m_channelLayout += AE_CH_TFC ; if (layout & AV_CH_TOP_FRONT_RIGHT ) m_channelLayout += AE_CH_TFR ; if (layout & AV_CH_TOP_BACK_LEFT ) m_channelLayout += AE_CH_BL ; if (layout & AV_CH_TOP_BACK_CENTER ) m_channelLayout += AE_CH_BC ; if (layout & AV_CH_TOP_BACK_RIGHT ) m_channelLayout += AE_CH_BR ; m_channels = m_pCodecContext->channels; } CAEChannelInfo CDVDAudioCodecFFmpeg::GetChannelMap() { BuildChannelMap(); return m_channelLayout; } NS_KRMOVIE_END
[ "zeas@qq.com" ]
zeas@qq.com
4738157562c4b4bdb9b7076030f2c67ac872bcf9
a5170a49114262292188b694ad6c977214ed1086
/src/qt/recentrequeststablemodel.h
f504c6b534b6e17321671519a7fb803af7af1a29
[ "MIT" ]
permissive
Fydcoin/FYDCoin
618463d4cf2ab4deff890bec08d47313cef851fa
9bac7ed9a57923438aa91ff76b83a7ba35e71813
refs/heads/master
2021-10-24T16:40:00.063321
2021-06-19T18:05:24
2021-06-19T18:05:24
194,573,552
10
5
MIT
2020-03-13T13:53:41
2019-07-01T00:14:15
C++
UTF-8
C++
false
false
3,408
h
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2017 The PIVX developers // Copyright (c) 2019 The FYD developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H #define BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H #include "walletmodel.h" #include <QAbstractTableModel> #include <QDateTime> #include <QStringList> class CWallet; class RecentRequestEntry { public: RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION), id(0) {} static const int CURRENT_VERSION = 1; int nVersion; int64_t id; QDateTime date; SendCoinsRecipient recipient; ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { unsigned int nDate = date.toTime_t(); READWRITE(this->nVersion); nVersion = this->nVersion; READWRITE(id); READWRITE(nDate); READWRITE(recipient); if (ser_action.ForRead()) date = QDateTime::fromTime_t(nDate); } }; class RecentRequestEntryLessThan { public: RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder) : column(nColumn), order(fOrder) {} bool operator()(RecentRequestEntry& left, RecentRequestEntry& right) const; private: int column; Qt::SortOrder order; }; /** Model for list of recently generated payment requests / fyd: URIs. * Part of wallet model. */ class RecentRequestsTableModel : public QAbstractTableModel { Q_OBJECT public: explicit RecentRequestsTableModel(CWallet* wallet, WalletModel* parent); ~RecentRequestsTableModel(); enum ColumnIndex { Date = 0, Label = 1, Address = 2, Message = 3, Amount = 4, NUMBER_OF_COLUMNS }; /** @name Methods overridden from QAbstractTableModel @{*/ int rowCount(const QModelIndex& parent) const; int columnCount(const QModelIndex& parent) const; QVariant data(const QModelIndex& index, int role) const; bool setData(const QModelIndex& index, const QVariant& value, int role); QVariant headerData(int section, Qt::Orientation orientation, int role) const; QModelIndex index(int row, int column, const QModelIndex& parent) const; bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()); Qt::ItemFlags flags(const QModelIndex& index) const; /*@}*/ const RecentRequestEntry& entry(int row) const { return list[row]; } void addNewRequest(const SendCoinsRecipient& recipient); void addNewRequest(const std::string& recipient); void addNewRequest(RecentRequestEntry& recipient); public slots: void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); void updateDisplayUnit(); private: WalletModel* walletModel; QStringList columns; QList<RecentRequestEntry> list; int64_t nReceiveRequestsMaxId; /** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */ void updateAmountColumnTitle(); /** Gets title for amount column including current display unit if optionsModel reference available. */ QString getAmountTitle(); }; #endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
[ "48912706+Fydcoin@users.noreply.github.com" ]
48912706+Fydcoin@users.noreply.github.com
99288f162bf14e5bbc8575c3844d1429697a0a40
d1f2fe6699a9eb9085ac5fbcce04e4d054493290
/C++ solution code/find_largest_and_smallest_number_method_2.cpp
a33dc2fbcf119f21c024d167c073a86f0dd56f56
[]
no_license
arifkhan1990/Basic_Top_50_programming-_problem_and_solution
79594d828029ce93243dad31e1b0302ae6333255
6b03322c759cafed22373f3bd20d3c93e7b32c6e
refs/heads/master
2020-06-26T12:22:11.803231
2019-08-23T04:09:47
2019-08-23T04:10:05
199,630,005
1
1
null
null
null
null
UTF-8
C++
false
false
349
cpp
#include<bits/stdc++.h> using namespace std; int main() { int n, m, largestNum = INT_MIN, smallestNum = INT_MAX; cin >> n; int ar[n+1]; for(int i = 0; i < n; i++) { cin >> ar[i]; } sort(ar,ar+n); cout << "Largest Number : " << ar[n-1] << endl; cout << "Smallest Number: " << ar[0] << endl; return 0; }
[ "arifkhanshubro@gmail.com" ]
arifkhanshubro@gmail.com
a8bc7738363d058d8dbe5e14e63cf677235c7ed9
95da45e333d762f8d8229fefec58d79facf3b15a
/TJU数学-1/G - 找新朋友.cpp
6f85b97ea8b046a9dc25eae0b00bb35ff4416896
[]
no_license
Xiao-Jian/ACM-Training
592552c84f031ea4bafd8b85bba063d8171f8548
5dec492cc86a349a0d7673fa022410a52bae1246
refs/heads/master
2016-09-05T19:26:24.824149
2015-11-29T06:24:45
2015-11-29T06:24:45
39,362,552
0
0
null
null
null
null
UTF-8
C++
false
false
494
cpp
#include <cstdio> #include <iostream> #define Max 1000001 int euler[Max]; void Init(){ euler[1] = 1; for( int i = 2; i < Max; i ++ ) euler[i] = i; for( int i = 2; i < Max; i ++ ) if( euler[i] == i ) for( int j = i; j < Max; j += i ) euler[j] = euler[j] / i * ( i - 1 ); } int main() { int t,n; scanf( "%d", &t); Init(); while( t -- ) { scanf( "%d", &n ); printf( "%d\n", euler[n] ); } return 0; }
[ "1215615213@qq.com" ]
1215615213@qq.com
b854e80844dca0889469cde6faa5b759e9e580ab
002e55cdf0750c5b9c6057b04ddd618bcd15af62
/kunwardeep_singh_Q5.cpp
3047900cd4ef7be9253603c082f0f4a94396fe14
[]
no_license
KunwardeepSingh3/C-code
4eb11268fecf7bc1090dd6c382fb237076fc857b
731d753b51cd233ab3f22c65df79bfb7d01e884b
refs/heads/master
2020-09-12T16:32:12.151356
2019-11-18T15:23:01
2019-11-18T15:23:01
222,479,934
0
0
null
null
null
null
UTF-8
C++
false
false
507
cpp
#include <iostream> #include <iomanip> #include <string> #include <cmath> using namespace std; double sqrt_Babylonian(double a){ double x[100]; int i; for (int i=1; i>0; i++){ x[0] = 1; x[i] = (x[i-1] + a/x[i-1])/2; cout <<"value of i is: " << i << ", value of x[i] is: " << x[i] << endl; if (abs(x[i]-x[i-1])<=pow(10, -4)) return x[i]; } return x[i]; } int main (){ double a = 23650953; double x[100]; cout << sqrt_Babylonian(a) << endl; return 0; }
[ "noreply@github.com" ]
KunwardeepSingh3.noreply@github.com
21db68e504dadd134d2958ab041059c917f7d04a
c76bca6811a24c4434209bcc0d5736118886e88c
/week3/lab/Game.cpp
c069734bbd49a1b8185e2212800704c1e67cef68
[]
no_license
Ellard24/CS162
bb2c161f844beef11d2306839144854679d2a481
8335e6b9c700f467763bf1b230102db3e9b57539
refs/heads/master
2021-01-10T17:13:29.458696
2016-03-17T17:20:07
2016-03-17T17:20:07
54,130,981
0
0
null
null
null
null
UTF-8
C++
false
false
5,509
cpp
#include <iostream> #include "Game.h" /*********************************************** *Function:Game Constructor *Description: Sets Score, rounds to 0 and sets fairness to False. *Parameters: None *Pre-Conditions: - *Post-Conditions:- ************************************************/ Game::Game() { scoreP1 = 0; scoreP2 = 0; round = 0; player1Fair = false; player2Fair = false; } /*********************************************** *Function:getScoreP1 *Description: Getter function for ScoreP1 *Parameters: None *Pre-Conditions: - *Post-Conditions:- ************************************************/ int Game::getScoreP1() { return scoreP1; } /*********************************************** *Function:setScoreP1 *Description: Increases the score for P1 by an increment of 1 *Parameters: None *Pre-Conditions: Score set to 0 by constructor or in middle of game *Post-Conditions:Score retrieved to check who wins ************************************************/ void Game::setScoreP1() { scoreP1++; } /*********************************************** *Function:getScoreP2() *Description: Getter function for ScoreP2 *Parameters: None *Pre-Conditions: - *Post-Conditions:- ************************************************/ int Game::getScoreP2() { return scoreP2; } /*********************************************** *Function:setScoreP2() *Description: Increases the score for P1 by an increment of 1 *Parameters: None *Pre-Conditions: - *Post-Conditions:- ************************************************/ void Game::setScoreP2() { scoreP2++; } /*********************************************** *Function:getRound() *Description: Getter function for data member Rounds *Parameters: None *Pre-Conditions: Rounds must be initiliazed *Post-Conditions: Round can be retrieved ************************************************/ int Game::getRound() { return round; } /*********************************************** *Function: setRound *Description: Sets the number of rounds to be played by the Game of War *Parameters: int rounds *Pre-Conditions: - *Post-Conditions: Rounds can be retrieved or increased ************************************************/ void Game::setRound(int rounds) { round = rounds; } /*********************************************** *Function:getFairnessP1() *Parameters: None *Description: Getter function for FairnessP1 *Pre-Conditions: FairnessP1 needs to be set to false or true *Post-Conditions:Determines the dice picked ************************************************/ bool Game::getFairnessP1() { return player1Fair; } /*********************************************** *Function:getFairnessP2() *Description: Getter function for FairnessP2 *Parameters: None *Pre-Conditions: FairnessP2 needs to be set to false or true *Post-Conditions:Determines the dice picked ************************************************/ bool Game::getFairnessP2() { return player2Fair; } /*********************************************** *Function:setFairnessP1() *Description: Sets the fairness for Player1 which will determine the dice picked *Parameters: None *Pre-Conditions: - *Post-Conditions: Fairness sets dice pick ************************************************/ void Game::setFairnessP1() { player1Fair = true; } /*********************************************** *Function:setFairnessP2() *Description: Sets the fairness for Player2 which will determine the dice picked *Parameters: None *Pre-Conditions: - *Post-Conditions: Fairness sets dice pick ************************************************/ void Game::setFairnessP2() { player2Fair = true; } /*********************************************** *Function:pickWinner *Description: Checks score and determines winner based on which player has highest score *Parameters: None *Pre-Conditions: Rounds must be finished looping *Post-Conditions: User is prompted to restart game ************************************************/ void Game::pickWinner() { if (scoreP1 > scoreP2) cout << "Player 1 wins" << endl; else if (scoreP1 == scoreP2) cout << "It is a tie" << endl; else cout << "Player 2 wins" << endl; } /*********************************************** *Function:setSides *Description: Sets the sides for die1 which is the normal dice. *Parameters: int sides *Pre-Conditions: - *Post-Conditions: Sides can be used to start roll function ************************************************/ void Game::setSides(int sides) { die1.set_sides(sides); } /*********************************************** *Function:setsides *Description: Sets the sides for die2 which is the loaded_dice *Parameters: int sides *Pre-Conditions: - *Post-Conditions: Sides can be used to start loaded roll function. ************************************************/ void Game::setsides(int sides) { die2.set_sides(sides); } /*********************************************** *Function:roll() *Description: Rolls the normal dice *Parameters: None *Pre-Conditions: Sides must be set *Post-Conditions: Score can be determined based on higher roll between two players ************************************************/ int Game::roll() { return die1.die_roll(); } /*********************************************** *Function:loadedRoll() *Description: Rolls the loaded dice *Parameters: None *Pre-Conditions: Sides must be set *Post-Conditions: Score can be determined based on higher roll between two players ************************************************/ int Game::loadedRoll() { return die2.loaded_roll(); }
[ "egvdh@comcast.net" ]
egvdh@comcast.net
4c41e31367d69697292e0dfae50aaf64bc679770
a577196b87544ad68f99edefd23a743c6b709868
/HmmAna_stats/Utils.h
4c4a23299b7f3c0983643c566598e9fba87cf91f
[]
no_license
vlimant/HmmAna
8d40c7a55c85f0d016c621c8824d077659a83e6c
bee2ed3d96daf89cba1703dd84bb13474f57ca27
refs/heads/master
2020-05-31T09:07:00.212599
2019-06-03T20:08:25
2019-06-03T20:08:25
190,205,617
0
0
null
2019-06-04T13:20:14
2019-06-04T13:20:13
null
UTF-8
C++
false
false
381
h
#ifndef _Utils_h_ #define _Utils_h_ #include "CommonHead.h" #include "RooFitHead.h" using namespace std; using namespace RooFit; namespace Utils{ vector<TString> SplitString(const TString& theOpt, const char separator ); void setDefaultMinimize(); float minimizeTest(RooNLLVar* nll,float neps); float minimizeMinosTest(RooNLLVar* nll,RooRealVar* poi,float neps); }; #endif
[ "nan.lu@cern.ch" ]
nan.lu@cern.ch
e877f8317727bbe8939de97b76a4f711b49795e0
29356ae61e47df6cb1c09fc971377ec2dcc25b4e
/HW01_17조/도재홍_2014104118/HW01_2014104118_도재홍.cpp
263986b1b8da005d85290fb3126b3f4216a4ac78
[]
no_license
seo14800/IoT-KNU-20162-Team17
f5dea513da6b5364c766ba35315b41df1a5ef2ba
30b2f1374dc390c4a80c874ab21fb129df96499f
refs/heads/master
2020-07-28T20:09:57.609980
2016-12-01T18:51:13
2016-12-01T18:51:13
67,352,187
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
449
cpp
#include "txtreader.h" void main() { headNode *fhead = createHead(); char split[] = "~!@#$%^&*()_+`-={}[]\\|;:'\"<>,./?\n\t "; char check=78;//N ASCII filereader(fhead, split);//ÆÄÀÏ Àбâ while(check==78||check==110){ search(fhead); while(true){ printf("\nwanna finish?(Y/N)"); fflush(stdin); check = getchar(); if (check == 78 || check == 89 || check == 121 || check == 110) break; } system("cls"); } }
[ "dojae_0813@naver.com" ]
dojae_0813@naver.com
25ec7f04e97046a356a4801e72ee6f6c83939304
66873135f86c300d4e362b33f5387b147d66c20f
/src/leapserial/test/AESStreamTest.cpp
a6ae39e15392579a30a8e14a30430bc56f602fb6
[ "Apache-2.0" ]
permissive
gabrielPeart/leapserial
2f0bf6ebb440788d1f8791700dd57a3c3c52330e
ae86dcc3057e409ff13a8e1ca3c399a8d109917c
refs/heads/master
2021-01-16T22:44:49.072808
2016-02-10T21:02:58
2016-02-10T21:02:58
52,526,282
2
0
null
2016-02-25T13:29:26
2016-02-25T13:29:25
null
UTF-8
C++
false
false
3,890
cpp
// Copyright (C) 2012-2015 Leap Motion, Inc. All rights reserved. #include "stdafx.h" #include "LeapSerial.h" #include "AESStream.h" #include "BufferedStream.h" #include "ForwardingStream.h" #include "MemoryStream.h" #include <gtest/gtest.h> #include <numeric> #include <vector> static const std::array<uint8_t, 32> sc_key{ {0x99, 0x84, 0x49, 0x28} }; class AESStreamTest: public testing::Test {}; namespace { struct SimpleStruct { std::string value; static leap::descriptor GetDescriptor(void) { return{ &SimpleStruct::value }; } }; } static SimpleStruct MakeSimpleStruct(void) { SimpleStruct val; val.value = "I thought what I'd do is I'd pretend I was one of those deaf-mutes"; // Reduplicate 2^4 times for (size_t i = 0; i < 4; i++) val.value += val.value; return val; } TEST_F(AESStreamTest, KnownValueRoundTrip) { std::vector<uint8_t> vec(0x100); std::iota(vec.begin(), vec.end(), 0); std::stringstream ss; { leap::AESEncryptionStream cs( leap::make_unique<leap::OutputStreamAdapter>(ss), sc_key ); cs.Write(vec.data(), vec.size()); } ss.seekg(0); leap::AESDecryptionStream ds{ leap::make_unique<leap::InputStreamAdapter>(ss), sc_key }; std::vector<uint8_t> read(vec.size()); ASSERT_EQ(vec.size(), ds.Read(read.data(), read.size())) << "Did not read expected number of bytes"; ASSERT_EQ(vec, read) << "Reconstructed vector was not read back intact"; } TEST_F(AESStreamTest, ExactSizeCheck) { std::vector<uint8_t> vec(45, 0); std::stringstream ss; leap::AESEncryptionStream cs( leap::make_unique<leap::OutputStreamAdapter>(ss), sc_key ); cs.Write(vec.data(), vec.size()); std::string str = ss.str(); ASSERT_EQ(vec.size(), str.size()) << "CFB-mode AES cipher should preserve the exact length of the input"; } TEST_F(AESStreamTest, RoundTrip) { auto val = MakeSimpleStruct(); std::stringstream ss; { leap::AESEncryptionStream cs{ leap::make_unique<leap::OutputStreamAdapter>(ss), sc_key }; leap::Serialize(cs, val); } SimpleStruct reacq; { leap::AESDecryptionStream ds{ leap::make_unique<leap::InputStreamAdapter>(ss), sc_key }; leap::Deserialize(ds, reacq); } ASSERT_EQ(val.value, reacq.value); } TEST_F(AESStreamTest, OverReadTest) { std::array<uint8_t, 32> key = { 0x99, 0x88 }; leap::MemoryStream ms; { leap::AESEncryptionStream enc{ std::unique_ptr<leap::IOutputStream> { new leap::ForwardingOutputStream{ ms } }, key }; enc.Write("abcd", 4); } leap::AESDecryptionStream dec{ std::unique_ptr<leap::IInputStream> { new leap::ForwardingInputStream{ ms } }, key }; char buf[25] = {}; std::streamsize n; ASSERT_NO_THROW(n = dec.Read(buf, sizeof(buf))); ASSERT_EQ(4, n); ASSERT_STREQ("abcd", buf); ASSERT_EQ(0, dec.Read(buf, sizeof(buf))); ASSERT_TRUE(dec.IsEof()); } TEST_F(AESStreamTest, EofCheck) { char buf[200]; leap::BufferedStream bs(buf, sizeof(buf)); leap::AESDecryptionStream aes{ leap::make_unique<leap::ForwardingInputStream>(bs), sc_key }; // EOF not initially set until a read is attempted ASSERT_FALSE(aes.IsEof()); ASSERT_EQ(0, aes.Read(buf, 1)); ASSERT_TRUE(aes.IsEof()); // Write, but EOF flag should be sticky ASSERT_TRUE(bs.Write("a", 1)); ASSERT_TRUE(aes.IsEof()); ASSERT_EQ(1, aes.Read(buf, 1)); ASSERT_FALSE(aes.IsEof()); // Write again and attempt to read more than is available--this should also set EOF bs.Write("abc", 3); ASSERT_EQ(3, aes.Read(buf, sizeof(buf))); ASSERT_TRUE(aes.IsEof()); } TEST_F(AESStreamTest, SkipBytes) { char buf[200]; leap::BufferedStream bs(buf, sizeof(buf), sizeof(buf)); leap::AESDecryptionStream aes{ leap::make_unique<leap::ForwardingInputStream>(bs), sc_key }; ASSERT_EQ(10, aes.Skip(10)); }
[ "cmercenary@gmail.com" ]
cmercenary@gmail.com
cec9a78c1cb7b225e06a0c7505d6e49240cf4428
4c41a7603e383cf6ffd7f4b98ee93dfc489ff600
/NuEvent.h
709fbffd9ebe9441a03bbf413b612af19851384d
[]
no_license
tjcarroll3/minos-class-test
40ffe0c66dbd97b104be3d875c388a1f8952a6f9
3ff38c0aa53aad5966b1d701682f3519f29b7dc7
refs/heads/master
2023-03-07T13:25:42.029154
2021-02-16T22:36:14
2021-02-16T22:36:14
339,408,619
0
0
null
null
null
null
UTF-8
C++
false
false
66,864
h
////////// ///////// ///////// //////// ///////// ///////// ///////// 72 //////////////////////////////////////////////////////////////////////// // Contact: Jeff Hartnell j.j.hartnell@rl.ac.uk //////////////////////////////////////////////////////////////////////// #ifndef NUEVENT_H #define NUEVENT_H #include <cassert> #include <string> #include <vector> #include "TObject.h" namespace minos{ class NuEvent : public TObject { public: NuEvent(); virtual ~NuEvent() {}; //non-const methods void Reset(); ////////////////////////////////////////////////////////////////// /// EVERYTIME A TRUTH VARIABLE IS ADDED TO THIS CLASS IT MUST /// ALSO BE ADDED TO NuMCEvent /////////////////////////////////////////////////////////////////// /// \name Book-keeping quantities //@{ Int_t index; ///< the n'th NuEvent object to be written to the tree Int_t entry; ///< the n'th snarl to be processed //@} /// \name Snarl/run based quantities //@{ Int_t run; ///< fHeader.fRun Int_t subRun; ///< fHeader.fSubRun Int_t runType; ///< fHeader.fRunType Int_t errorCode; ///< fHeader.fErrorCode Int_t snarl; ///< actual DAQ snarl number Int_t trigSrc; ///< fHeader.fTrigSrc Int_t timeFrame; ///< fHeader.fTimeFrame Int_t remoteSpillType; ///< fHeader.fRemoteSpillType Int_t detector; ///< fHeader.fVldContext.fDetector Int_t simFlag; ///< fHeader.fVldContext.fSimFlag Int_t timeSec; ///< fHeader.fVldContext.fTimeStamp.fSec Int_t timeNanoSec; ///< fHeader.fVldContext.fTimeStamp.fNanoSec Double_t timeSeconds; ///< VldTimeStamp.GetSeconds() sec+nanoSec/1e9 Double_t trigtime; ///< evthdr.trigtime Double_t medianTime; ///< the median time in event (with respect to timeFrame start) Double_t timeEvtMin; ///< earliest time in event (with respect to ///timeNanoSec). This comes from ///NtpSRStrip::time1 (or an average of time1 ///and time0 in the FD), which is a ///charge-weighted average of the times of the ///digits in the earliest strip. Double_t timeEvtMax; ///< latest time in event (with respect to timeNanoSec) Double_t crateT0; ///< Crate t0 Int_t sgate_10mhz; Int_t sgate_53mhz; Int_t rollover_53mhz; Int_t rollover_last_53mhz; Int_t timingFiducial; Int_t nearestSpillSec; ///< time of nearest spill (s) Int_t nearestSpillNanosec; ///< time of nearest spill (ns); Double_t timeToNearestSpill; ///< time to nearest spill (uses SpillTimeFinder) Int_t planeEvtHdrBeg; ///< evthdr.plane.beg (different than evt.plane.beg!) Int_t planeEvtHdrEnd; ///< evthdr.plane.end (different than evt.plane.end!) Double_t snarlPulseHeight; ///< evthdr.ph.sigcor //@} /// \name Data quality variables //@{ Bool_t isGoodDataQuality; ///< uses DataUtil::IsGoodData() Bool_t isGoodDataQualityRUN; ///< uses DataUtil::IsGoodDataRUN() Bool_t isGoodDataQualityCOIL; ///< uses DataUtil::IsGoodDataCOIL() Bool_t isGoodDataQualityHV; ///< uses DataUtil::IsGoodDataHV() Bool_t isGoodDataQualityGPS; ///< uses DataUtil::IsGoodDataGPS() Int_t numActiveCrates; ///< number of active readout crates ('cratemask') Int_t numTimeFrames; ///< number of timeframes, gives run duration Int_t numGoodSnarls; ///< number of 'good' snarls during run Float_t snarlRateMedian; ///< median snarl rate during run Float_t snarlRateMax; ///< maximum snarl rate during run Int_t deltaSecToSpillGPS; ///< time from trigger to nearest spill (s) Int_t deltaNanoSecToSpillGPS; ///< time from trigger to nearest spill (ns) Int_t gpsError; ///< GPS error (ns) Int_t gpsSpillType; ///< type of spill Bool_t coilIsOk; ///< CoilTools::IsOk(vldc); Bool_t coilIsReverse; ///< CoilTools::IsReverse(vldc); Float_t coilCurrent; ///< detector B field coil current (not always filled) Bool_t isLI; ///< LISieve::IsLI() Int_t litag; ///< CC analysis definition: reco.FDRCBoundary(nu); Double_t litime; ///< evthdr.litime (==-1 if not LI) //@} /// \name Reconstructed quantities /// These variables are here to add a level of indirection, they don't store /// information directly from the sntp files, but rather they can be set at /// analysis-time to what the user wants them to contain /// %e.g. \ref shwEn could be set to the deweighted, energy corrected, /// CC shower energy if the analysis selected the event as a CC event. /// Alternatively, if the analysis /// selected the event as %NC then \ref shwEn could be set to the linear %NC, /// no energy correction, %NC shower energy. /// Don't rely on the defaults, but they typically assume you /// have a CC event and want linear, energy corrected values of the energy //@{ /// \brief Best reconstructed energy. /// /// Always set to \ref energyCC by \ref NuReco::GetEvtEnergy. Unless /// \ref applyEnergyShifts is set in which case \ref NuReco::ApplyReweights /// sets it to \ref energyRw. Float_t energy; /// \brief Reconstructed energy assuming this is a CC event /// /// Always set to the sum of \ref trkEn and \ref shwEnCC by /// \ref NuReco::GetEvtEnergy. Float_t energyCC; /// \brief Reconstructed energy assuming this is an %NC event /// /// Always set to \ref shwEnNC by NuReco::GetEvtEnergy Float_t energyNC; /// \brief Reconstructed energy for RAF events /// /// Always set to \ref trkEn by NuReco::GetEvtEnergy Float_t energyRM; /// \brief Best reconstructed track energy /// /// Set in \ref NuReco::CalcTrkVariables. Zero if not \ref trkExists. /// Set to \ref trkEnRange if \ref usedRange, or \ref trkEnCurv if /// \ref usedCurv. These should never both be false. /// If \ref applyEnergyShifts then \ref NuReco::ApplyReweights sets this to /// \ref trkEnRw. Float_t trkEn; /// \brief Reconstructed track energy calculated from range /// /// Set by \ref NuReco::GetTrackEnergyFromRange. This applies energy /// corrections to \ref trkMomentumRange and then sums in the muon mass. Float_t trkEnRange; /// \brief Reconstructed track energy calculated from curvature /// /// Set by \ref NuReco::GetTrackEnergyFromCurv. This applies energy /// corrections to 1/\ref qp and then sums in the muon mass. Float_t trkEnCurv; /// \brief Best reconstructed shower energy /// /// Always set to \ref shwEnCC by \ref NuReco::CalcShwVariables. /// If \ref applyEnergyShifts then \ref NuReco::ApplyReweights sets this to /// \ref shwEnRw. Float_t shwEn; /// \brief Reconstructed shower energy assuming this is a CC event /// /// Calculated in \ref NuReco::GetShowerEnergyCC. Returns \ref shwEnkNN /// unless \ref hornIsReverse in which case it applies energy corrections /// to \ref shwEnLinCCNoCor Float_t shwEnCC; /// \brief Reconstructed shower energy assuming this is an %NC event /// /// Calculated in \ref NuReco::GetShowerEnergyNC. Applies energy corrections /// to \ref shwEnLinNCNoCor. Float_t shwEnNC; /// \brief Estimated energy resolution of this event in GeV /// /// Set by \ref NuReco::CalcResolution to the quadrature sum of /// \ref trkResolution and \ref shwResolution. Float_t resolution; //@} /// \name Convenience flags /// These 3 flags are just for convenience when playing with DSTs /// they are ABSOLUTELY NOT TO BE USED FOR ANALYSIS //@{ Bool_t isInFidVolCC; ///< Is the event in the CC 2010 fiducial volume Bool_t isGoodTrackReclamation; ///< Pass trkFitPass or ND reclamation Bool_t isNCClean; ///< Pass %NC cleaning (for all events, not just NCs) //@} /// \name Basic kinematics //@{ Float_t y; ///< reco'd y = (Enu-Emu)/Enu Float_t q2; ///< reco'd q2 = -q^{2} = 2 Enu Emu (1 - cos(theta_mu)) Float_t x; ///< reco'd x = Q2 / (2M* Ehad) {M=nucleon mass} Float_t w2; ///< reco'd w2 = M^{2} + q^{2} + 2M(Enu-Emu) Float_t dirCosNu; ///< reco'd direction cosine of track //@} /// \name Event info extracted from the ntuples //@{ Int_t evt; ///< reco'd event number, evt.index Int_t slc; ///< reco'd slice number, evt.slc Int_t nevt; ///< Number of reconstructed events in the snarl Int_t ndigitEvt; ///< evt.ndigit Int_t nstripEvt; ///< evt.nstrip Int_t nshw; ///< evt.nshower Int_t ntrk; ///< evt.ntrack Int_t primshw; ///< evt.primshw Int_t primtrk; ///< evt.primtrk Float_t rawPhEvt; ///< evt.ph.raw Float_t evtphsigcor; ///< evt.ph.sigcor Float_t evtphsigmap; ///< evt.ph.sigmap Int_t planeEvtN; ///< number of planes in event Int_t planeEvtNu; ///< evt.plane.nu Int_t planeEvtNv; ///< evt.plane.nv //@} //Information from Andy Blake's track vertex timing fix. This is //event-based information Bool_t vtxFitPassFail; //Does this event pass the fit? (This //basically requires there to be a track.) Double_t vtxFitTime; //The best fit vertex time. Double_t vtxFitTimeError; //The error in the reconstructed vertex time. Double_t vtxFitChi2DoF; //The chi2/DoF from the fit. /// \name RO PID variables /// These RO PID variables store the values obtained using the /// \ref NtpSREvent. Rustem's code defines which track to use by using /// the number of "active" planes //@{ Float_t roIDEvt; ///< RO's PID variable (got using the evt) Float_t knn01TrkActivePlanesEvt; ///< number of active planes in trk Float_t knn10TrkMeanPhEvt; ///< average ph per plane in trk Float_t knn20LowHighPhEvt; ///< average of low ph strips / average of high ph strips Float_t knn40TrkPhFracEvt; ///< fraction of ph in trk Float_t roIDNuMuBarEvt; ///< RO's PID NuMuBar selection (0 or 1) Float_t relativeAngleEvt; ///< RO's track angle relative to muon dir. //@} /// \name Jasmine Ma/Ratchford new PID variables (Event) //@{ Float_t jmIDEvt; Float_t jmTrackPlaneEvt; Float_t jmEndPhEvt; Float_t jmMeanPhEvt; Float_t jmScatteringUEvt; Float_t jmScatteringVEvt; Float_t jmScatteringUVEvt; Float_t jmEventknnIDEvt; Float_t jmEventknn208Evt; ///< Summed ph in path end Float_t jmEventknn207Evt; ///< Standard devation of ph in path end Float_t jmEventknn206Evt; ///< Mean ph in path Float_t jmEventknn205Evt; ///< "BVD" the value of the Dijkstra algorithm ///< (proportional to the probability that it is a track) Float_t jmEventknn204Evt; ///< Size of the path found by the Dijkstra algorithm //@} /// \name Event vertex and end //@{ Float_t xEvtVtx; ///< evt.vtx.x Float_t yEvtVtx; ///< evt.vtx.y Float_t zEvtVtx; ///< evt.vtx.z Float_t uEvtVtx; ///< evt.vtx.u Float_t vEvtVtx; ///< evt.vtx.v Float_t tEvtVtx; ///< evt.vtx.t Int_t planeEvtVtx; ///< evt.vtx.plane Int_t planeEvtBeg; ///< evt.plane.beg Int_t planeEvtBegu; ///< evt.plane.begu Int_t planeEvtBegv; ///< evt.plane.begv Float_t xEvtEnd; ///< evt.end.x Float_t yEvtEnd; ///< evt.end.y Float_t zEvtEnd; ///< evt.end.z Float_t uEvtEnd; ///< evt.end.u Float_t vEvtEnd; ///< evt.end.v Int_t planeEvtEnd; ///< evt.plane.end Int_t planeEvtEndu; ///< evt.plane.endu Int_t planeEvtEndv; ///< evt.plane.endv //@} /// \name Best track //@{ Bool_t trkExists; ///< simply state if track exists Int_t trkIndex; ///< trk.index, position in TClonesArray in sntp file Int_t ndigitTrk; ///< trk.ndigit Int_t nstripTrk; ///< trk.nstrip /// \brief Equivalent to \ref trkEnRange Float_t trkEnCorRange; /// \brief Equivalent to \ref trkEnCurv Float_t trkEnCorCurv; /// \brief Reconstructed shower energy within 1m of the track vertex /// /// Calculated by \ref NuReco::GetShowerEnergyNearTrack. This is the sum of /// \ref NtpSRShowerPulseHeight::linCCgev for all reconstructed showers with /// vertex within 1m of the track vertex (and times within -25ns,+75ns). Float_t trkShwEnNear; /// \brief Reconstructed deweighted shower energy within 1m of the track vertex /// /// As for \ref trkShwEnNear but using \ref NtpSRShowerPulseHeight::wtCCgev. /// -1 if there are no showers within 1m. Float_t trkShwEnNearDW; /// \brief Uncorrected track momentum from range /// /// Copied from the value in \ref NtpSRMomentum::range. Float_t trkMomentumRange; /// \brief Estimated resolution on the track energy in GeV /// /// Calculated in \ref EnergyResolution::MuonResolution based on \ref trkEn, /// \ref sigqp and \ref usedRange. Float_t trkResolution; Int_t containedTrk; ///< trk.contained Int_t trkfitpass; ///< trk.fit.pass Float_t trkvtxdcosz; ///< trk.vtx.dcosz Float_t trkvtxdcosy; ///< trk.vtx.dcosy Int_t trknplane; ///< trk.nplane Int_t charge; ///< +1 or -1: simply derived from qp (from track fit) Float_t qp; ///< track Q/P from fit (no EnCor) Float_t qp_rangebiased; ///< track Q/P from fit (with range bias) Float_t sigqp; ///< track sigma Q/P from fit Float_t qp_sigqp; ///< qp / sigqp Float_t chi2; ///< track chi2 of fit Float_t ndof; ///< track ndof of fit Float_t qpFraction; ///< trk.stpfitqp[i], npositive/nstrip Int_t trkVtxUVDiffPl; ///< trk.plane.begu-trk.plane.begv; Int_t trkLength; ///< abs(trk.plane.end-trk.plane.beg+1); Int_t planeTrkNu; ///< trk.plane.nu: number of u planes hit Int_t planeTrkNv; ///< trk.plane.nv: number of v planes hit Int_t ntrklike; ///< the number of trk-like planes Float_t trkphsigcor; ///< trk.ph.sigcor Float_t trkphsigmap; ///< trk.ph.sigmap Int_t trkIdMC; ///< true identity of the track Float_t trkds; ///< total track path length from vertex to end (m) trk.ds Int_t trkfitpassSA; ///< variables from the SA track fitter Float_t trkvtxdcoszSA; ///< fitsa.fit.dcosz Int_t chargeSA; ///< definition same as variable without SA postfix Float_t qpSA; ///< definition same as variable without SA postfix Float_t sigqpSA; ///< definition same as variable without SA postfix Float_t chi2SA; ///< definition same as variable without SA postfix Float_t ndofSA; ///< definition same as variable without SA postfix Float_t probSA; ///< definition same as variable without SA postfix Float_t xTrkVtxSA; ///< calculated from u&v Float_t yTrkVtxSA; ///< calculated from u&v Float_t zTrkVtxSA; ///< fitsa.fit.z Float_t uTrkVtxSA; ///< fitsa.fit.u Float_t vTrkVtxSA; ///< fitsa.fit.v Float_t jitter; ///< from MajCInfo Float_t jPID; ///< from MajCInfo Float_t majC; ///< from MajCInfo Float_t smoothMajC; ///< from MajCInfo //The best RO PID (roID) variables are located with the other PIDs //see below Float_t xTrkVtx; ///< trk.vtx.x Float_t yTrkVtx; ///< trk.vtx.y Float_t zTrkVtx; ///< trk.vtx.z Float_t uTrkVtx; ///< trk.vtx.u Float_t vTrkVtx; ///< trk.vtx.v Float_t tTrkVtx; Int_t planeTrkVtx; ///< trk.vtx.plane Int_t planeTrkBeg; ///< trk.plane.beg Int_t planeTrkBegu; ///< trk.plane.begu Int_t planeTrkBegv; ///< trk.plane.begv //Some track timing information from the NtpSRTrackTime object Float_t inverseBetaTrk; ///< trk.time.cdtds, which is 1/beta Double_t t0Trk; ///< trk.time.t0: the offset from time fit used to ///determine beta Float_t chi2TimeTrk; ///< trk.time.chi2: chi2 of fit done on track direction ///determination UShort_t ndigitTimeTrk; ///< trk.time.ndigit: number of digits used ///to determine the track direction from ///timing Double_t forwardRMSTrk; ///< trk.time.forwardRMS: RMS for forward ///time fit Int_t forwardNDOFTrk; ///< trk.time.forwardNDOF: Digits used for ///forward time fit /// \name Track strip geometry information //@{ Int_t stripTrkBeg; ///< Strip number of the first strip hit Int_t stripTrkBegu; ///< Strip number of the first strip hit in a u plane Int_t stripTrkBegv; ///< Strip number of the first strip hit in a v plane Short_t stripTrkEnd; ///< Strip number of the last strip hit Short_t stripTrkEndu; ///< Strip number of the last strip hit in a u plane Short_t stripTrkEndv; ///< Strip number of the last strip hit in a u plane Bool_t stripTrkBegIsu; ///< True if the first strip hit in this track was in a u plane Bool_t stripTrkEndIsu; ///< True if the last strip hit in this track was in a u plane //@} /// \name RAF (rock and anti-fiducial) variables //@{ /*! This is set to -2 if not at the far detector and set to -1 if there is no track. It is 0 for tracks with their vertex in the fiducial volume. For tracks with their vertex outside the fiducial volume, it is a number from 1-18 found by the sum of: 1 if the vertex is near the outside radial edge <br /> 2 if the vertex is near the coil hole 4 if the vertex is at the south end of supermodule 1 <br /> 8 if the vertex is at the north end of supermodule 1 <br /> 12 if the vertex is at the south end of supermodule 2 <br /> 16 if the vertex is at the north end of supermodule 2 <br /> */ Int_t regionTrkVtx; ///< The region of the detector the track vertex is in /*! This is calculated only for the far detector. If not in the far detector or there is no track, it's set to -1. Octants boundaries are at the corners. Counting starts with 0 at +x (west vertical edge) and goes counter-clockwise (looking south) around to to 7 (lower west diagonal edge). While this variable was intended for use only in the anti-fiducial volume near the edge, it is defined for all positions. Note that the detector is not a regular octagon and so the corners are not at exactly (n+0.5)*360/8 degrees. Because the scintillator boundary has a complex shape, the exact locations of the corners is arbitrary on the level of a few centimeters. In the 2010 CC analysis, only the parity of this value is used. i.e. if it is even, this is a horizontal/vertical edge and if it is odd, it is a diagonal edge. */ Char_t edgeRegionTrkVtx; ///< The octant of the detector that the track vertex is in Char_t edgeRegionTrkEnd; ///< Same as edgeRegionTrkVtx but for the track end /*! <strong>I don't think this is directly used in any analysis and is trivially calcuable with TMath::ATan2(yTrkVtx, xTrkVtx). Remove?</strong> */ Float_t phiTrkVtx; ///< Location of the track vertex in Phi = atan2(vtx.x / vtx.y) /*! <strong>I don't think this is directly used in any analysis and is trivially calcuable with TMath::ATan2(yTrkEnd, xTrkEnd). Remove?</strong> */ Float_t phiTrkEnd; ///< Location of the track end in Phi = atan2(vtx.x / vtx.y) /*! If there is no track, this is set to -999. If this is not the far detector, or the track vertex is not in one of the octants of the far detector defined by a diagonal edge, this is set to -10. While this is almost certainly only interesting for anti-fiducial events, it is set even if the track vertex is far from the edge so that it doesn't matter if the fiducial cut is moved. This gives the number of strips from the edge, not the raw strip number, so on any edge if the outermost strip is the first hit, this is set to 0. In the 2010 CC analysis, a track is considered rock-like if this is 0 or 1. */ Short_t parallelStripTrkVtx; ///< On a diagonal edge, the strip number of the first track hit /*! To account for alignment differences between the MC and reality, or to apply an alignment systematic, parallelStripTrkVtx may be modified from what the raw MC would give. As of the 2010 analysis, this is not done since it is unclear how to handle it. Instead an analysis strategy was used that doesn't depend strongly on the precise alignment. So this should always be equal to parallelStripTrkVtx at the moment. <strong>It seems unlikely that this will ever change and so probably this variable should be removed.</strong> */ Short_t parallelStripTrkVtxNoShift; ///< parallelStripTrkVtx without post-MC corrections Short_t parallelStripTrkEnd; ///< Same as parallelStripTrkVtx, but for the track end /*! If there is no track, this is not the far detector, or the track vertex is not in one of the octants of the far detector defined by a diagonal edge, this is set to -10. While this is almost certainly only interesting for anti-fiducial events, it is set even if the track vertex is far from the edge so that it doesn't matter if the fiducial cut is moved. If the first hit is on a strip that is perpendicular to the edge (these overhang the strips parallel to the edge), it is set to 1. It's set to 0 if this hit is on a parallel strip. This could be useful for rock/detector discrimination since the overhanging portion of the perpendicular strips are the farthest extent of scintillator on these edges. However, as the exact extent of these strips is not very clear, this was not used in the 2010 CC analysis. <strong>It seems unlikely that anyone will start using this variable, so should we remove it?</strong> */ Char_t stripTrkBegPerpFlag; ///< Whether the first hit on a diagonal edge is on a perpendicular (overhanging) strip Char_t stripTrkEndPerpFlag; ///< Same as stripTrkBegPerpFlag, but for the last hit in the track /*! If there is no track, this is not the far detector, or the track vertex is not in one of the octants of the far detector defined by a horizontal or vertical edge, this is set to -999. This number gives the distance from the edge in terms of strips found from looking at the first U and V hits in a track. It is defined so that the same number means the same distance on all four horizontal/vertical edges. It has an arbitrary offset. (On the bottom edge it is the U strip number plus the V strip number, except a +1 crept in somehow and was retained for consistency.) The definition is: On the west edge, 192 - U strip + V strip<br /> On the top edge, 383 - U strip - V strip<br /> On the east edge, 192 + U strip - V strip<br /> On the bottom edge, 1 + U strip + V strip The intent of this variable is to give a more reliable and/or easy-to-understand-the-systematics-of measure of distance from the edge that does not rely on the track fit. While this is almost certainly only interesting for anti-fiducial events, it is set even if the track vertex is far from the edge so that it doesn't matter if the fiducial cut is moved. In the 2010 CC analysis, a track was considered rock-like if stripHoveNumTrkVtx <= 57. */ Short_t stripHoveNumTrkVtx; ///< HOrizontal/VErtical strip number --- a measure of distance from the edge /*! stripHoveNumTrkVtx must be modified before analysis since alignment variation in the real detector isn't modeled in the daikon geometry. Essentially a smearing is added to account for the alignment variations; this smeared value is stored in stripHoveNumTrkVtx and the original value is stored here. */ Short_t stripHoveNumTrkVtxNoShift; ///< stripHoveNumTrkVtx without post-MC corrections Short_t stripHoveNumTrkEnd; ///< stripHoveNumTrkVtx but for the track end /*! <strong>This was considered for use in RAF analysis and then dropped. Remove?</strong> */ Float_t cosPrTrkVtx; ///< Cosine of angle between theta and radial momentum //@} /// \name More best track variables copied from the SNTP Float_t xTrkEnd; ///< trk.end.x Float_t yTrkEnd; ///< trk.end.y Float_t zTrkEnd; ///< trk.end.z Float_t uTrkEnd; ///< trk.end.u Float_t vTrkEnd; ///< trk.end.v Int_t planeTrkEnd; ///< trk.plane.end Int_t planeTrkEndu; ///< trk.plane.endu Int_t planeTrkEndv; ///< trk.plane.endv Float_t drTrkFidall; ///< trk.fidall.dr Float_t dzTrkFidall; ///< trk.fidall.dz Float_t drTrkFidvtx; ///< trk.fidbeg.dr Float_t dzTrkFidvtx; ///< trk.fidbeg.dz Float_t drTrkFidend; ///< trk.fidend.dr Float_t dzTrkFidend; ///< trk.fidend.dz Float_t traceTrkFidall; ///< trk.fidall.trace Float_t traceTrkFidvtx; ///< trk.fidvtx.trace Float_t traceTrkFidend; ///< trk.fidend.trace //@} /// \name Best shower //@{ Bool_t shwExists; ///< simply state if shower exists Int_t ndigitShw; ///< shw.ndigit Int_t nstripShw; ///< shw.nstrip Int_t nplaneShw; ///< shw.plane.n Float_t shwEnCor; ///< Equivalent to \ref shwEnLinCCCor Float_t shwEnNoCor; ///< Copied from \ref NtpSRShowerPulseHeight::linCCgev Float_t shwEnMip; ///< Copied from \ref NtpSRStripPulseHeight::mip Float_t shwEnLinCCNoCor; ///< shw.shwph.linCCgev /// \brief Calorimetric shower energy assuming a CC event /// /// Calculated in \ref NuReco::GetShowerEnergyCor. /// This is the shower energy to use if you don't want kNN energy Float_t shwEnLinCCCor; Float_t shwEnWtCCNoCor; ///< Copied from \ref NtpSRShowerPulseHeight::wtCCgev Float_t shwEnWtCCCor; ///< Deweighted shower energy with energy corrections Float_t shwEnLinNCNoCor; ///< Copied from \ref NtpSRShowerPulseHeight::linNCgev /// Shower energy with energy corrections assuming this is an %NC event Float_t shwEnLinNCCor; Float_t shwEnWtNCNoCor; ///< Copied from \ref NtpSRShowerPulseHeight::wtNCgev Float_t shwEnWtNCCor; ///< Deweighted %NC shower energy with corrections /// \brief Estimated resolution on the shower energy in GeV /// /// Calculated by \ref EnergyResolution::ShowerResolution based on /// \ref shwEnkNN. Float_t shwResolution; ///< Cambridge resolution, shower only /// \brief Shower energy as calculated by the kNN algorithm /// /// Includes corrections. Calculated in \ref NuReco::GetShowerEnergykNN. Float_t shwEnkNN; /// \brief Uncorrected shower energy as calculated by the kNN algorithm /// /// Calculated in \ref NuReco::GetShowerEnergykNN. Float_t shwEnkNNNoCor; /// \brief Shower energy resolution estimate from the kNN method /// /// Calculated in \ref NuReco::GetShowerEnergykNN as the standard-deviation /// of the true energies of the k nearest neighbours. Float_t shwEnReskNN; Int_t planeShwBeg; ///< shw.plane.beg Int_t planeShwEnd; ///< shw.plane.end Int_t planeShwMax; ///< Shower plane with maximum pulseheight Float_t xShwVtx; ///< shw.vtx.x Float_t yShwVtx; ///< shw.vtx.y Float_t zShwVtx; ///< shw.vtx.z //@} /// \brief MINOS+ kNN shower energy variables /// shwEnkNNPlus and shwEnkNNPlusNoCor are computed in NtupleUtils/NuReco.cxx /// shwRmsT, shwPctWidth, ..., planeAllShwMax are computed in NtupleUtils/NuExtraction.cxx /// junting@physics.utexas.edu //@{ Float_t shwEnkNNPlus; ///< kNN shower energy with a reselection of variables and mahalanobis metric (for MINOS+ only) Float_t shwEnkNNPlusNoCor; ///< non-corrected version of shwEnkNNPlus ///// topology variables for the best shower Float_t shwRmsT; ///< RMS of transverse distribution Float_t shwPctWidth; ///< sum of widths with 10%, 20%, ..., 90% containment Float_t shwPctLength; ///< sum of widths with 10%, 20%, ..., 90% containment Float_t shwSumHitLength; ///< sum of hit z position weighted by mip Float_t shwSumHitWidth; ///< sum of hit transverse position weighted by mip ///// kinematics variables for the best shower Float_t avgShwHitMip; ///< average hit mip Float_t maxShwPlaneMip; ///< max mip in a plane Float_t maxShwHitMip; ///< max mip of a hit ///// variables calculated from hits in all showers Float_t shwRmsTAllShws; ///< all-shower version of shwRmsT Float_t shwPctWidthAllShws; ///< all-shower version of shwPctWidth Float_t shwPctLengthAllShws; ///< all-shower version of shwPctLength Float_t avgShwHitMipAllShws; ///< all-shower version of avgShwHitMipAllShws Float_t shwSumHitLengthAllShws; ///< all-shower version of shwSumHitLengthAllShws Float_t shwSumHitWidthAllShws; ///< all-shower version of shwSumHitWidthAllShws Float_t maxShwPlaneMipAllShws; ///< all-shower version of maxShwPlaneMipAllShws Float_t maxShwHitMipAllShws; ///< all-shower version of maxShwHitMipAllShws Float_t nplaneAllShws; ///< all-shower version of nplaneShw Float_t planeAllShwMax; ///< all-shower version of planeShwMax //@} /// \name Primary track /// For documentation see the same variables without the suffix //@{ Bool_t trkExists1; Int_t trkIndex1; Int_t ndigitTrk1; Int_t nstripTrk1; Float_t trkEnCorRange1; Float_t trkEnCorCurv1; Float_t trkShwEnNear1; Float_t trkShwEnNearDW1; Float_t trkMomentumRange1; Int_t containedTrk1; Int_t trkfitpass1; Float_t trkvtxdcosz1; Float_t trkvtxdcosy1; Int_t trknplane1; Int_t charge1; Float_t qp1; Float_t qp_rangebiased1; Float_t sigqp1; Float_t qp_sigqp1; Float_t chi21; Float_t ndof1; Float_t qpFraction1; Int_t trkVtxUVDiffPl1; Int_t trkLength1; Int_t planeTrkNu1; Int_t planeTrkNv1; Int_t ntrklike1; Float_t trkphsigcor1; Float_t trkphsigmap1; Int_t trkIdMC1; Float_t trkds1; Int_t trkfitpassSA1; Float_t trkvtxdcoszSA1; Int_t chargeSA1; Float_t qpSA1; Float_t sigqpSA1; Float_t chi2SA1; Float_t ndofSA1; Float_t probSA1; Float_t xTrkVtxSA1; Float_t yTrkVtxSA1; Float_t zTrkVtxSA1; Float_t uTrkVtxSA1; Float_t vTrkVtxSA1; Float_t jitter1; Float_t jPID1; Float_t majC1; Float_t smoothMajC1; Float_t roID1; Float_t knn01TrkActivePlanes1; Float_t knn10TrkMeanPh1; Float_t knn20LowHighPh1; Float_t knn40TrkPhFrac1; Float_t roIDNuMuBar1; Float_t relativeAngle1; //---------------------------- // Jasmine Ma/Ratchford new PID variables (track1) //---------------------------- Float_t jmID1; Float_t jmTrackPlane1; Float_t jmEndPh1; Float_t jmMeanPh1; Float_t jmScatteringU1; Float_t jmScatteringV1; Float_t jmScatteringUV1; Float_t xTrkVtx1; Float_t yTrkVtx1; Float_t zTrkVtx1; Float_t uTrkVtx1; Float_t vTrkVtx1; Float_t tTrkVtx1; Int_t planeTrkVtx1; Int_t planeTrkBeg1; Int_t planeTrkBegu1; Int_t planeTrkBegv1; //Track timing information Float_t inverseBetaTrk1; Double_t t0Trk1; Float_t chi2TimeTrk1; UShort_t ndigitTimeTrk1; Double_t forwardRMSTrk1; Int_t forwardNDOFTrk1; // Strip geometry information Int_t stripTrkBeg1; Int_t stripTrkBegu1; Int_t stripTrkBegv1; Short_t stripTrkEnd1; Short_t stripTrkEndu1; Short_t stripTrkEndv1; Bool_t stripTrkBegIsu1; Bool_t stripTrkEndIsu1; Int_t regionTrkVtx1; Char_t edgeRegionTrkVtx1; Char_t edgeRegionTrkEnd1; Float_t phiTrkVtx1; Float_t phiTrkEnd1; // More, entirely derivative, geometry variables for the rock analysis Short_t parallelStripTrkVtx1; Short_t parallelStripTrkEnd1; Char_t stripTrkBegPerpFlag1; Char_t stripTrkEndPerpFlag1; Short_t stripHoveNumTrkVtx1; Short_t stripHoveNumTrkEnd1; Float_t xTrkEnd1; Float_t yTrkEnd1; Float_t zTrkEnd1; Float_t uTrkEnd1; Float_t vTrkEnd1; Int_t planeTrkEnd1; Int_t planeTrkEndu1; Int_t planeTrkEndv1; Float_t drTrkFidall1; Float_t dzTrkFidall1; Float_t drTrkFidvtx1; Float_t dzTrkFidvtx1; Float_t drTrkFidend1; Float_t dzTrkFidend1; Float_t traceTrkFidall1; Float_t traceTrkFidvtx1; Float_t traceTrkFidend1; Float_t cosPrTrkVtx1; //@} /// \name Primary shower /// For documentation see the same variables without the suffix //@{ Bool_t shwExists1; Int_t ndigitShw1; Int_t nstripShw1; Int_t nplaneShw1; Float_t shwEnCor1; Float_t shwEnNoCor1; Float_t shwEnLinCCNoCor1; Float_t shwEnLinCCCor1; Float_t shwEnWtCCNoCor1; Float_t shwEnWtCCCor1; Float_t shwEnLinNCNoCor1; Float_t shwEnLinNCCor1; Float_t shwEnWtNCNoCor1; Float_t shwEnWtNCCor1; Float_t shwEnMip1; Int_t planeShwBeg1; Int_t planeShwEnd1; Int_t planeShwMax1; Float_t xShwVtx1; Float_t yShwVtx1; Float_t zShwVtx1; //@} /// \name Second track /// For documentation see the same variables without the suffix //@{ Bool_t trkExists2; Int_t trkIndex2; Int_t ndigitTrk2; Int_t nstripTrk2; Float_t trkEnCorRange2; Float_t trkEnCorCurv2; Float_t trkShwEnNear2; Float_t trkShwEnNearDW2; Float_t trkMomentumRange2; Int_t containedTrk2; Int_t trkfitpass2; Float_t trkvtxdcosz2; Float_t trkvtxdcosy2; Int_t trknplane2; Int_t charge2; Float_t qp2; Float_t qp_rangebiased2; Float_t sigqp2; Float_t qp_sigqp2; Float_t chi22; Float_t ndof2; Float_t qpFraction2; Int_t trkVtxUVDiffPl2; Int_t trkLength2; Int_t planeTrkNu2; Int_t planeTrkNv2; Int_t ntrklike2; Float_t trkphsigcor2; Float_t trkphsigmap2; Int_t trkIdMC2; Float_t trkds2; Int_t trkfitpassSA2; Float_t trkvtxdcoszSA2; Int_t chargeSA2; Float_t qpSA2; Float_t sigqpSA2; Float_t chi2SA2; Float_t ndofSA2; Float_t probSA2; Float_t xTrkVtxSA2; Float_t yTrkVtxSA2; Float_t zTrkVtxSA2; Float_t uTrkVtxSA2; Float_t vTrkVtxSA2; Float_t jitter2; Float_t jPID2; Float_t majC2; Float_t smoothMajC2; Float_t roID2; Float_t knn01TrkActivePlanes2; Float_t knn10TrkMeanPh2; Float_t knn20LowHighPh2; Float_t knn40TrkPhFrac2; Float_t roIDNuMuBar2; Float_t relativeAngle2; //---------------------------- // Jasmine Ma/Ratchford new PID variables (track2) //---------------------------- Float_t jmID2; Float_t jmTrackPlane2; Float_t jmEndPh2; Float_t jmMeanPh2; Float_t jmScatteringU2; Float_t jmScatteringV2; Float_t jmScatteringUV2; Float_t xTrkVtx2; Float_t yTrkVtx2; Float_t zTrkVtx2; Float_t uTrkVtx2; Float_t vTrkVtx2; Float_t tTrkVtx2; Int_t planeTrkVtx2; Int_t planeTrkBeg2; Int_t planeTrkBegu2; Int_t planeTrkBegv2; //Track timing information Float_t inverseBetaTrk2; Double_t t0Trk2; Float_t chi2TimeTrk2; UShort_t ndigitTimeTrk2; Double_t forwardRMSTrk2; Int_t forwardNDOFTrk2; //Strip geometry information Int_t stripTrkBeg2; Int_t stripTrkBegu2; Int_t stripTrkBegv2; Short_t stripTrkEnd2; Short_t stripTrkEndu2; Short_t stripTrkEndv2; Bool_t stripTrkBegIsu2; Bool_t stripTrkEndIsu2; Int_t regionTrkVtx2; Char_t edgeRegionTrkVtx2; Char_t edgeRegionTrkEnd2; Float_t phiTrkVtx2; Float_t phiTrkEnd2; // More, entirely derivative, geometry variables for the rock analysis Short_t parallelStripTrkVtx2; Short_t parallelStripTrkEnd2; Char_t stripTrkBegPerpFlag2; Char_t stripTrkEndPerpFlag2; Short_t stripHoveNumTrkVtx2; Short_t stripHoveNumTrkEnd2; Float_t xTrkEnd2; Float_t yTrkEnd2; Float_t zTrkEnd2; Float_t uTrkEnd2; Float_t vTrkEnd2; Int_t planeTrkEnd2; Int_t planeTrkEndu2; Int_t planeTrkEndv2; Float_t drTrkFidall2; Float_t dzTrkFidall2; Float_t drTrkFidvtx2; Float_t dzTrkFidvtx2; Float_t drTrkFidend2; Float_t dzTrkFidend2; Float_t traceTrkFidall2; Float_t traceTrkFidvtx2; Float_t traceTrkFidend2; Float_t cosPrTrkVtx2; //@} /// \name Second shower /// For documentation see the same variables without the suffix //@{ Bool_t shwExists2; Int_t ndigitShw2; Int_t nstripShw2; Int_t nplaneShw2; Float_t shwEnCor2; Float_t shwEnNoCor2; Float_t shwEnLinCCNoCor2; Float_t shwEnLinCCCor2; Float_t shwEnWtCCNoCor2; Float_t shwEnWtCCCor2; Float_t shwEnLinNCNoCor2; Float_t shwEnLinNCCor2; Float_t shwEnWtNCNoCor2; Float_t shwEnWtNCCor2; Float_t shwEnMip2; Int_t planeShwBeg2; Int_t planeShwEnd2; Int_t planeShwMax2; Float_t xShwVtx2; Float_t yShwVtx2; Float_t zShwVtx2; //@} /// \name Third track /// For documentation see the same variables without the suffix //@{ Bool_t trkExists3; Int_t trkIndex3; Int_t ndigitTrk3; Int_t nstripTrk3; Float_t trkEnCorRange3; Float_t trkEnCorCurv3; Float_t trkShwEnNear3; Float_t trkShwEnNearDW3; Float_t trkMomentumRange3; Int_t containedTrk3; Int_t trkfitpass3; Float_t trkvtxdcosz3; Float_t trkvtxdcosy3; Int_t trknplane3; Int_t charge3; Float_t qp3; Float_t qp_rangebiased3; Float_t sigqp3; Float_t qp_sigqp3; Float_t chi23; Float_t ndof3; Float_t qpFraction3; Int_t trkVtxUVDiffPl3; Int_t trkLength3; Int_t planeTrkNu3; Int_t planeTrkNv3; Int_t ntrklike3; Float_t trkphsigcor3; Float_t trkphsigmap3; Int_t trkIdMC3; Float_t trkds3; Int_t trkfitpassSA3; Float_t trkvtxdcoszSA3; Int_t chargeSA3; Float_t qpSA3; Float_t sigqpSA3; Float_t chi2SA3; Float_t ndofSA3; Float_t probSA3; Float_t xTrkVtxSA3; Float_t yTrkVtxSA3; Float_t zTrkVtxSA3; Float_t uTrkVtxSA3; Float_t vTrkVtxSA3; Float_t jitter3; Float_t jPID3; Float_t majC3; Float_t smoothMajC3; Float_t roID3; Float_t knn01TrkActivePlanes3; Float_t knn10TrkMeanPh3; Float_t knn20LowHighPh3; Float_t knn40TrkPhFrac3; Float_t roIDNuMuBar3; Float_t relativeAngle3; //---------------------------- // Jasmine Ma/Ratchford new PID variables (track3) //---------------------------- Float_t jmID3; Float_t jmTrackPlane3; Float_t jmEndPh3; Float_t jmMeanPh3; Float_t jmScatteringU3; Float_t jmScatteringV3; Float_t jmScatteringUV3; Float_t xTrkVtx3; Float_t yTrkVtx3; Float_t zTrkVtx3; Float_t uTrkVtx3; Float_t vTrkVtx3; Float_t tTrkVtx3; Int_t planeTrkVtx3; Int_t planeTrkBeg3; Int_t planeTrkBegu3; Int_t planeTrkBegv3; //Track timing information Float_t inverseBetaTrk3; Double_t t0Trk3; Float_t chi2TimeTrk3; UShort_t ndigitTimeTrk3; Double_t forwardRMSTrk3; Int_t forwardNDOFTrk3; // Strip geometry Int_t stripTrkBeg3; Int_t stripTrkBegu3; Int_t stripTrkBegv3; Short_t stripTrkEnd3; Short_t stripTrkEndu3; Short_t stripTrkEndv3; Bool_t stripTrkBegIsu3; Bool_t stripTrkEndIsu3; Int_t regionTrkVtx3; Char_t edgeRegionTrkVtx3; Char_t edgeRegionTrkEnd3; Float_t phiTrkVtx3; Float_t phiTrkEnd3; // More, entirely derivative, geometry variables for the rock analysis Short_t parallelStripTrkVtx3; Short_t parallelStripTrkEnd3; Char_t stripTrkBegPerpFlag3; Char_t stripTrkEndPerpFlag3; Short_t stripHoveNumTrkVtx3; Short_t stripHoveNumTrkEnd3; Float_t xTrkEnd3; Float_t yTrkEnd3; Float_t zTrkEnd3; Float_t uTrkEnd3; Float_t vTrkEnd3; Int_t planeTrkEnd3; Int_t planeTrkEndu3; Int_t planeTrkEndv3; Float_t drTrkFidall3; Float_t dzTrkFidall3; Float_t drTrkFidvtx3; Float_t dzTrkFidvtx3; Float_t drTrkFidend3; Float_t dzTrkFidend3; Float_t traceTrkFidall3; Float_t traceTrkFidvtx3; Float_t traceTrkFidend3; Float_t cosPrTrkVtx3; //@ /// \name Third shower /// For documentation see the same variables without the suffix //@{ Bool_t shwExists3; Int_t ndigitShw3; Int_t nstripShw3; Int_t nplaneShw3; Float_t shwEnCor3; Float_t shwEnNoCor3; Float_t shwEnLinCCNoCor3; Float_t shwEnLinCCCor3; Float_t shwEnWtCCNoCor3; Float_t shwEnWtCCCor3; Float_t shwEnLinNCNoCor3; Float_t shwEnLinNCCor3; Float_t shwEnWtNCNoCor3; Float_t shwEnWtNCCor3; Float_t shwEnMip3; Int_t planeShwBeg3; Int_t planeShwEnd3; Int_t planeShwMax3; Float_t xShwVtx3; Float_t yShwVtx3; Float_t zShwVtx3; //@} /// \name Fourth shower /// For documentation see the same variables without the suffix //@{ Bool_t shwExists4; Int_t ndigitShw4; Int_t nstripShw4; Int_t nplaneShw4; Float_t shwEnCor4; Float_t shwEnNoCor4; Float_t shwEnLinCCNoCor4; Float_t shwEnLinCCCor4; Float_t shwEnWtCCNoCor4; Float_t shwEnWtCCCor4; Float_t shwEnLinNCNoCor4; Float_t shwEnLinNCCor4; Float_t shwEnWtNCNoCor4; Float_t shwEnWtNCCor4; Float_t shwEnMip4; Int_t planeShwBeg4; Int_t planeShwEnd4; Int_t planeShwMax4; Float_t xShwVtx4; Float_t yShwVtx4; Float_t zShwVtx4; //@} /// \name Fifth shower /// For documentation see the same variables without the suffix //@{ Bool_t shwExists5; Int_t ndigitShw5; Int_t nstripShw5; Int_t nplaneShw5; Float_t shwEnCor5; Float_t shwEnNoCor5; Float_t shwEnLinCCNoCor5; Float_t shwEnLinCCCor5; Float_t shwEnWtCCNoCor5; Float_t shwEnWtCCCor5; Float_t shwEnLinNCNoCor5; Float_t shwEnLinNCCor5; Float_t shwEnWtNCNoCor5; Float_t shwEnWtNCCor5; Float_t shwEnMip5; Int_t planeShwBeg5; Int_t planeShwEnd5; Int_t planeShwMax5; Float_t xShwVtx5; Float_t yShwVtx5; Float_t zShwVtx5; //@} /// \name Other info calculated //@{ Float_t rEvtVtx; ///< Distance of event vertex from (x,y) = (0,0) Float_t rEvtEnd; ///< Distance of event end from (x,y) = (0,0) Float_t distToEdgeEvtVtx; ///< event vertex distance to edge of scintillator Int_t evtVtxUVDiffPl; ///< Number of planes between first U plane of event and first V plane of event Float_t rTrkVtx; ///< Distance of track vertex from (x,y) = (0,0) Float_t rTrkEnd; ///< Distance of track end from (x,y) = (0,0) Float_t sigqp_qp; ///< best track sigma Q/P / Q/P from fit Float_t chi2PerNdof; ///< track's chi2/ndof of fit Float_t prob; ///< track's probability of fit Int_t containmentFlag; ///< containment flag to use Int_t containmentFlagCC0093Std; ///< CC 0.9e20 pot containment flag Int_t containmentFlagCC0250Std; ///< CC 2.5e20 pot containment flag Int_t containmentFlagPitt; ///< pitt specific flag: 1-4, up/down stop/exit Int_t usedRange; ///< 1=used range, 0=not Int_t usedCurv; ///< 1=used curvature, 0=not //@} /// \name Weights //@{ /*! This is the SKZP beam weight (beamWeight) plus a few other small corrections. By itself, it does <strong>not</strong> give a proper prediction of the far detector spectrum. */ Float_t rw; ///< The final weight applied to the event. Float_t fluxErr; ///< The error on the flux from SKZP. Float_t rwActual; ///< This is the weight as it leaves NuReco::ApplyReweights. Any later changes (i.e. systematics) only affect rw. Float_t generatorWeight; ///< weight factor from generator Float_t detectorWeight; ///< SKZP detector weight to use as default /*! Daikon mismodels the coil by using "coil material" for neutrino interactions, but steel and scintillator for particle propagation. As a good approximation, this can be fixed by weighting events in which the true neutrino interaction is in the coil by the raio of densities. This is set to 1 if the true neutrino interaction is not in the coil and that ratio if it is. This contributes to the total weight rw. */ Float_t coilCorrWeight; ///< weight to account for daikon coil mismodeling /*! Daikon uses an old cross section model. Newer models predict somewhat smaller cross sections for light elements relative to heavier elements. This weight applies a correction that roughly converts our monte carlo to the newer model. The correction grows as the element moves farther from iron. Since cross sections for detector events cancels near-to-far, this correction is only done for rock events and is set to 1 for detector events. This contributes to the total weight rw. */ Float_t rockxsecCorrWeight; ///< weight updating cross section model for rock /// \brief Weight applied to this event by the 2010 CC analysis /// /// This weight is intended for plot-making purposes only. /// It is not included in \ref rw /// /// The analysis weights can't be known at DST-making time, so this weight /// defaults to one. The files should be rewritten so this weight represents /// the weight applied to this event by the beam-matrix extrapolation. /// Including this weight along with \ref rw should give fully correct /// nominal Far Detector predictions. Best-fit systematics are more /// complicated and not included here. Float_t anaWeightCC2010; /*! Daikon04 and earlier: average POT weighted weights, e.g. (1.27*RunI + 1.23*RunII)/2.50 Daikon07 and later: Just the correct weights for this MC event */ Float_t trkEnWeight; ///< SKZP weight to apply to \ref trkEn Float_t shwEnWeight; ///< SKZP weight to apply to \ref shwEn Float_t beamWeight; ///< SKZP weight for beam (%e.g. hadron production) Float_t fluxErrHadProdAfterTune; ///< flux error, kHadProdAfterTune Float_t fluxErrTotalErrorPreTune; ///< flux error, kTotalErrorPreTune Float_t fluxErrTotalErrorAfterTune; ///< flux error kTotalErrorAfterTune Float_t detectorWeightNMB; ///< SKZP detector weight (%e.g. xsec) Float_t detectorWeightNM; ///< NuMu rather than NuMuBar above /// \brief Reconstructed energy with SKZP detector weights applied /// /// Set to the sum of \ref trkEnRw and \ref shwEnRw by /// \ref NuReco::ApplyReweights Float_t energyRw; /// \brief Reconstructed energy without detector weights /// /// Equivalent to \ref energy when \ref applyEnergyShifts is not set Float_t energyNoRw; /// \brief Reconstructed track energy with SKZP detector weights applied /// /// Set to \ref trkEnNoRw times \ref trkEnWeight by /// \ref NuReco::ApplyReweights Float_t trkEnRw; /// \brief Reconstructed track energy without detector weights /// /// Equivalent to \ref trkEn when \ref applyEnergyShifts is not set Float_t trkEnNoRw; /// \brief Reconstructed shower energy with SKZP detector weights applied /// /// Set to \ref shwEnNoRw times \ref shwEnWeight by /// \ref NuReco::ApplyReweights Float_t shwEnRw; /// \brief Reconstructed shower energy without detector weights /// /// Equivalent to \ref shwEn when \ref applyEnergyShifts is not set Float_t shwEnNoRw; //@} /// \name PIDs //@{ Float_t dpID; ///< DP's PID variable Float_t abID; ///< AB's PID variable Float_t roID; ///< RO's PID variable Float_t knn01TrkActivePlanes; ///< number of active planes in trk Float_t knn10TrkMeanPh; ///< average ph per plane in trk Float_t knn20LowHighPh; ///< av of low ph strips/av of high ph strips Float_t knn40TrkPhFrac; ///< fraction of ph in trk Float_t roIDNuMuBar; ///< RO's PID variable for NuMuBar selection (0 or 1) Float_t relativeAngle; ///< RO's track angle relative to muon dir. Float_t poID; ///< PO's PID variable Float_t poIDKin; ///< PO's PID variable (kinematics only) //@} /// \name MINOS+ PIDs /// junting@physics.utexas.edu //@{ Float_t roIDPlus; ///< RO's PID made with mahalanobis metric (for MINOS+ only) //@} /// \name Jasmine Ma/Ratchford variables //@{ Float_t jmID; Float_t jmTrackPlane; Float_t jmEndPh; Float_t jmMeanPh; Float_t jmScatteringU; Float_t jmScatteringV; Float_t jmScatteringUV; Float_t jmEventknnID; Float_t jmEventknn208; Float_t jmEventknn207; Float_t jmEventknn206; Float_t jmEventknn205; Float_t jmEventknn204; //@} /// \name NC variables /// Comments from %NC code //@{ // event Float_t closeTimeDeltaZ; ///< distance in z to event closest in time Int_t edgeActivityStrips; ///< number of strips in partially instrumented region in 40ns time window Float_t edgeActivityPH; ///< summed PH in partially instrumented region in 40ns time window Int_t oppEdgeStrips; ///< number of strips in opposite edge region in 40ns time window Float_t oppEdgePH; ///< summed PH in opposite edge region in 40ns time window Float_t vtxMetersToCoilEvt; ///< distance to the coil hole Float_t vtxMetersToCloseEdgeEvt; ///< distance to nearest edge (in XY)of partial plane outline in ND Double_t minTimeSeparation; ///< time difference to closest event in time Float_t slicePHFraction; Int_t maxConsecutivePlanes; // shower Float_t transverseRMSU; ///< rms of transverse strip positions in U Float_t transverseRMSV; ///< rms of transverse strip positions in V // track Float_t dtdz; ///< gradient of t(z) fit (with c_light=1) Float_t endMetersToCloseEdge; //distance to nearest edge (in XY) of full plane outline in ND Float_t vtxMetersToCloseEdgeTrk; ///< distance to nearest edge (in XY) of partial plane outline in ND Float_t vtxMetersToCoilTrk; ///< distance to the center of the coil hole Float_t traceEndZ; ///< delta in z from end to projected exit location //@} /// \name Beam variables //@{ Float_t pot; ///< pot in current spill Float_t potDB; ///< pot in current spill from database Float_t potSinceLastEvt; ///< includes pot count for spills with no events Float_t potSinceLastEvtGood; ///< as above but also good beam+det spills Float_t potSinceLastEvtBad; ///< as above but for bad beam+det spills Float_t potSinceLastEvtDB; ///< as above but with database version of pots Float_t potSinceLastEvtGoodDB; ///< as above but with database version of pots Float_t potSinceLastEvtBadDB; ///< as above but with database version of pots Int_t nBatch; std::vector<Double_t> potListSinceLastEvtGood;//A list of the //spill-by-spill PoT //since the last //event. Usually only //one entry (the //current spill), but //will contain more //than one if there //have been spills //with no events Int_t runPeriod; ///< Major analysis run period, e.g. "Run IV" == 4 Bool_t hornIsReverse; //Conventions/BeamType.h definition Int_t beamTypeDB; ///< From BeamMonSpill Int_t beamType; ///< From NuConfig Float_t intensity; ///< Only filled for MC events Float_t hornCur; ///< BeamMonSpill::fHornCur Bool_t goodBeam; ///< BMSpillAna.SelectSpill() Bool_t goodBeamSntp; ///< uses the beam data in the sntp file //@} /// \name Truth variables /// /// EVERYTIME %A TRUTH VARIABLE IS ADDED TO THIS CLASS IT MUST /// ALSO BE ADDED TO \ref NuMCEvent //@{ Bool_t isInFidVolCCMC; ///< Is the true vertex in the CC fiducial volume? /// \brief True energy in principle visible in the detector /// /// For CC events this is equivalent to \ref neuEnMC. /// For NC events a factor \ref yMC is multiplied to account for the /// unobservable energy carried away by the final-state neutrino. Float_t energyMC; /// \brief True neutrino energy /// /// The energy component of the neutrino 4-vector: p4neu[3] Float_t neuEnMC; Float_t neuPxMC; ///< p4neu[0]; Float_t neuPyMC; ///< p4neu[1]; Float_t neuPzMC; ///< p4neu[2]; Float_t mu1EnMC; ///< p4mu1[3]; Float_t mu1PxMC; ///< p4mu1[0]; Float_t mu1PyMC; ///< p4mu1[1]; Float_t mu1PzMC; ///< p4mu1[2]; Float_t tgtEnMC; ///< p4tgt[3] Float_t tgtPxMC; ///< p4tgt[0]; Float_t tgtPyMC; ///< p4tgt[1]; Float_t tgtPzMC; ///< p4tgt[2]; Int_t zMC; ///< z; Int_t aMC; ///< a; Int_t nucleusMC; ///< encoding from Mad of the nucleus type Int_t initialStateMC; ///< encoding from Mad of the initial state Int_t hadronicFinalStateMC; ///< encoding from Mad of the hadronic final state Int_t numPreInukeFSprotMC; ///< Number of final state protons (before inuke) Int_t numPreInukeFSneutMC; ///< Number of final state neutrons (before inuke) Float_t maxMomPreInukeFSprotMC; ///< The highest momentum final state proton (before inuke) Float_t maxMomPreInukeFSneutMC; ///< The highest momentum final state neutron (before inuke) Float_t yMC; ///< kinematic y value from sntp file (not y position) Float_t y2MC; ///< p4shw[3]/(fabs(p4mu1[3])+p4shw[3]) Float_t xMC; ///< kinematic x (not x position) Float_t q2MC; ///< q2 Float_t w2MC; ///< w2 /// \brief True energy of the muon. Signed according to true muon charge. /// /// The energy component of the muon 4-vector: p4mu1[3] Float_t trkEnMC; /// True leptonic energy: (1-y)*p4neu[3] Float_t trkEn2MC; /// \brief True energy of the shower /// /// The energy component of the shower 4-vector: p4shw[3] Float_t shwEnMC; /// True hadronic energy: y*p4neu[3]; Float_t shwEn2MC; Float_t trkEndEnMC; ///< NtpMCStdHep.dethit[1].pE, particle energy at last scint hit Float_t trkStartEnMC; ///< muon energy at first scintillator hit Bool_t trkContainmentMC; ///< Experimental: MC Containment of primary muon Float_t sigma; ///< mc.sigma=cross-section Int_t iaction; ///< CC=1, NC=0 Int_t iresonance; ///< QE=1001, RES=1002, DIS=1003, CPP=1004 Int_t inu; ///< PDG code of neutrino (positive = particles, negative = anti-particles) Int_t inunoosc; ///< PDG code id of neutrino at birth Int_t itg; ///< neutrino interaction target Float_t vtxxMC; ///< vtxx: x vertex of neutrino interaction Float_t vtxyMC; ///< vtxy: y vertex of neutrino interaction Float_t vtxzMC; ///< vtxz: z vertex of neutrino interaction Float_t vtxuMC; ///< vertex u, calculated from x&y Float_t vtxvMC; ///< vertex v, calculated from x&y Int_t planeTrkVtxMC; ///< calculated from z Float_t rTrkVtxMC; ///< calculated from x&y Int_t mc; ///< the index of the object to be used Int_t mcTrk; ///< track mc index Int_t mcShw; ///< shower mc index Int_t mcEvt; ///< event mc index Int_t mcTrk1; ///< 1st track mc index Int_t mcTrk2; ///< 2nd track mc index Int_t mcTrk3; ///< 3rd track mc index Int_t mcShw1; ///< 1st shower mc index Int_t mcShw2; ///< 2nd shower mc index Int_t mcShw3; ///< 3rd shower mc index Int_t mcShw4; ///< 4th shower mc index Int_t mcShw5; ///< 5th shower mc index /// \name Truth flux variables, copied from underlying flux files //@{ Float_t Npz; ///< Neutrino momentum (GeV/c) along the \f$z\f$-axis (beam axis) Float_t NdxdzNea; ///< Direction slopes for a neutrino forced towards the center of the near detecto Float_t NdydzNea; ///< Direction slopes for a neutrino forced towards the center of the near detecto Float_t NenergyN; ///< Energy for a neutrino forced towards the center of the near detector Float_t NWtNear; ///< Weight for a neutrino forced towards the center of the near detector Float_t NdxdzFar; ///< Direction slopes for a neutrino forced towards the center of the far detector Float_t NdydzFar; ///< Direction slopes for a neutrino forced towards the center of the far detector Float_t NenergyF; ///< Neutrino energy (GeV) for a decay forced to the center of the far detector Float_t NWtFar; ///< Neutrino weight for a decay forced to the center of the far detector Int_t Ndecay; ///< Decay process that produced the neutrino, see \tab{decays} Float_t Vx; ///< Neutrino production vertex (cm) Float_t Vy; ///< Neutrino production vertex (cm) Float_t Vz; ///< Neutrino production vertex (cm) Float_t pdPx; ///< Momentum (GeV/c) of the neutrino parent at the neutrino production vertex (parent decay point) Float_t pdPy; ///< Momentum (GeV/c) of the neutrino parent at the neutrino production vertex (parent decay point) Float_t pdPz; ///< Momentum (GeV/c) of the neutrino parent at the neutrino production vertex (parent decay point) Float_t ppdxdz; ///< Direction of the neutrino parent at its production point (which may be in the target) Float_t ppdydz; ///< Direction of the neutrino parent at its production point (which may be in the target) Float_t pppz; ///< z momentum (GeV/c) of the neutrino parent at its production point Float_t ppenergy; ///< Energy (GeV) of the neutrino parent at its production point Float_t ppmedium; ///< Code for the material the neutrino parent was produced in (see doc-6316) Float_t ppvx; ///< Production vertex (cm) of the neutrino parent Float_t ppvy; ///< Production vertex (cm) of the neutrino parent Float_t ppvz; ///< Production vertex (cm) of the neutrino parent (used to determine decay pipe events) Int_t ptype; ///< Neutrino parent species (GEANT codes) Float_t Necm; ///< Neutrino energy (GeV) in the center-of-mass frame Float_t Nimpwt; ///< Importance weight of the neutrino Float_t tvx; ///< Position (cm) of the neutrino ancestor as it exits target (possibly, but not necessarily, the direct neutrino parent) Float_t tvy; ///< Position (cm) of the neutrino ancestor as it exits target (possibly, but not necessarily, the direct neutrino parent) Float_t tvz; ///< Position (cm) of the neutrino ancestor as it exits target (possibly, but not necessarily, the direct neutrino parent) Float_t tpx; ///< Momentum (GeV/c) of the ancestor as it exits target Float_t tpy; ///< Momentum (GeV/c) of the ancestor as it exits target Float_t tpz; ///< Momentum (GeV/c) of the ancestor as it exits target Int_t tptype; ///< Species of the ancestor exiting the target (GEANT codes) Int_t tgen; ///< Neutrino parent generation in cascade. 1 = primary proton, 2 = particles produced by proton interaction, 3 = particles from //@} /// \name Truth Intranuke weighting (Jasmine ma) //@{ Int_t InukeNwts; Float_t InukePiCExchgP; ///< 0 Float_t InukePiCExchgN; ///< 1 Float_t InukePiEScatP; ///< 2 Float_t InukePiEScatN; ///< 3 Float_t InukePiInEScatP; ///< 4 Float_t InukePiInEScatN; ///< 5 Float_t InukePiAbsorbP; ///< 6 Float_t InukePiAbsorbN; ///< 7 Float_t InukePi2PiP; ///< 8 Float_t InukePi2PiN; ///< 9 Float_t InukeNknockP; ///< 10 Float_t InukeNknockN; ///< 11 Float_t InukeNNPiP; ///< 12 Float_t InukeNNPiN; ///< 13 Float_t InukeFormTP; ///< 14 Float_t InukeFormTN; ///< 15 Float_t InukePiXsecP; ///< 16 Float_t InukePiXsecN; ///< 17 Float_t InukeNXsecP; ///< 18 Float_t InukeNXsecN; ///< 19 Float_t InukeNucrad; Float_t InukeWrad; //@} ////////////////////////////////////////////////////////////////// //EVERYTIME A TRUTH VARIABLE IS ADDED TO THIS CLASS IT MUST //ALSO BE ADDED TO NuMCEvent /////////////////////////////////////////////////////////////////// /// \name Program control variables //@{ Int_t anaVersion; ///< different cuts etc Int_t releaseType; ///< Conventions/ReleaseType.h definition Int_t recoVersion; ///< Birch/Cedar Int_t mcVersion; ///< Carrot/Daikon, used to select pdfs in data case Int_t reweightVersion; ///< the beam reweighting to use Bool_t useGeneratorReweight; ///< switch to turn off generator reweighting std::string sGeneratorConfigName; ///< name of generator rw configuration Int_t generatorConfigNo; ///< number of generator rw configuration Bool_t useDBForDataQuality; ///< flag to use DB for data quality Bool_t useDBForSpillTiming; ///< flag to use DB for spill timing Bool_t useDBForBeamInfo; ///< flag to use DB for beam info Bool_t cutOnDataQuality; ///< flag to enable cut on data quality Bool_t cutOnSpillTiming; ///< flag to enable cut on spill timing Bool_t cutOnBeamInfo; ///< flag to enable cut on beam info Bool_t applyEnergyShifts; ///< Flag to use energy shifts Bool_t applyBeamWeight; ///< Flag to use beam weight Bool_t apply1SigmaWeight; ///< Flag to use +1-sigma SKZP error shift Bool_t applyDetectorWeight; ///< Flag to use detector weight, %e.g. xsec Bool_t applyGeneratorWeight; ///< Flag to use generator weight Bool_t calcMajCurv; ///< flag to run majorityCurv or not Bool_t calcRoID; ///< flag to run RoID or not Bool_t calcJmID; ///< flag to run JmID or not //@} ClassDef(NuEvent, 94); }; //// Accessor functions for the numbered track and shower variables: // //// This anonymous namespace prevents us from getting "multiple definition" //// linker errors. //namespace{ // //// For working out the return types. It seems like we should be able to use //// typeof(NuEvent::var) instead of typeof(dummy.var), but apparently not... //NuEvent dummy; // //#define TrkVarFunc(var) \ //typeof(dummy.var##1)& get_##var(NuEvent& nu, \ // int idx) \ //{ \ // switch(idx){ \ // case 1: return nu.var##1; \ // case 2: return nu.var##2; \ // case 3: return nu.var##3; \ // default: \ // assert(0 && "Track index out of range"); \ // } \ //} \ // \ //typeof(dummy.var##1) get_##var(const NuEvent& nu, \ // int idx) \ //{ \ // switch(idx){ \ // case 1: return nu.var##1; \ // case 2: return nu.var##2; \ // case 3: return nu.var##3; \ // default: \ // assert(0 && "Track index out of range"); \ // } \ //} \ // \ //typeof(dummy.var##1)& get_##var(NuEvent* nu, \ // int idx) \ //{ \ // switch(idx){ \ // case 1: return nu->var##1; \ // case 2: return nu->var##2; \ // case 3: return nu->var##3; \ // default: \ // assert(0 && "Track index out of range"); \ // } \ //} // //// eg this creates a function: Bool_t& get_trkExists(NuEvent& nu, int idx); //TrkVarFunc(trkExists) //TrkVarFunc(trkIndex) //TrkVarFunc(ndigitTrk) //TrkVarFunc(nstripTrk) //TrkVarFunc(trkEnCorRange) //TrkVarFunc(trkEnCorCurv) //TrkVarFunc(trkShwEnNear) //TrkVarFunc(trkShwEnNearDW) //TrkVarFunc(trkMomentumRange) //TrkVarFunc(containedTrk) //TrkVarFunc(trkfitpass) //TrkVarFunc(trkvtxdcosz) //TrkVarFunc(trkvtxdcosy) //TrkVarFunc(trknplane) //TrkVarFunc(charge) //TrkVarFunc(qp) //TrkVarFunc(qp_rangebiased) //TrkVarFunc(sigqp) //TrkVarFunc(qp_sigqp) //TrkVarFunc(chi2) //TrkVarFunc(ndof) //TrkVarFunc(qpFraction) //TrkVarFunc(trkVtxUVDiffPl) //TrkVarFunc(trkLength) //TrkVarFunc(planeTrkNu) //TrkVarFunc(planeTrkNv) //TrkVarFunc(ntrklike) //TrkVarFunc(trkphsigcor) //TrkVarFunc(trkphsigmap) //TrkVarFunc(trkIdMC) //TrkVarFunc(trkds) //TrkVarFunc(trkfitpassSA) //TrkVarFunc(trkvtxdcoszSA) //TrkVarFunc(chargeSA) //TrkVarFunc(qpSA) //TrkVarFunc(sigqpSA) //TrkVarFunc(chi2SA) //TrkVarFunc(ndofSA) //TrkVarFunc(probSA) //TrkVarFunc(xTrkVtxSA) //TrkVarFunc(yTrkVtxSA) //TrkVarFunc(zTrkVtxSA) //TrkVarFunc(uTrkVtxSA) //TrkVarFunc(vTrkVtxSA) //TrkVarFunc(jitter) //TrkVarFunc(jPID) //TrkVarFunc(majC) //TrkVarFunc(smoothMajC) //TrkVarFunc(roID) //TrkVarFunc(knn01TrkActivePlanes) //TrkVarFunc(knn10TrkMeanPh) //TrkVarFunc(knn20LowHighPh) //TrkVarFunc(knn40TrkPhFrac) //TrkVarFunc(roIDNuMuBar) //TrkVarFunc(relativeAngle) //TrkVarFunc(jmID) //TrkVarFunc(jmTrackPlane) //TrkVarFunc(jmEndPh) //TrkVarFunc(jmMeanPh) //TrkVarFunc(jmScatteringU) //TrkVarFunc(jmScatteringV) //TrkVarFunc(jmScatteringUV) //TrkVarFunc(xTrkVtx) //TrkVarFunc(yTrkVtx) //TrkVarFunc(zTrkVtx) //TrkVarFunc(uTrkVtx) //TrkVarFunc(vTrkVtx) //TrkVarFunc(tTrkVtx) //TrkVarFunc(planeTrkVtx) //TrkVarFunc(planeTrkBeg) //TrkVarFunc(planeTrkBegu) //TrkVarFunc(planeTrkBegv) //TrkVarFunc(inverseBetaTrk) //TrkVarFunc(t0Trk) //TrkVarFunc(chi2TimeTrk) //TrkVarFunc(ndigitTimeTrk) //TrkVarFunc(forwardRMSTrk) //TrkVarFunc(forwardNDOFTrk) //TrkVarFunc(stripTrkBeg) //TrkVarFunc(stripTrkBegu) //TrkVarFunc(stripTrkBegv) //TrkVarFunc(stripTrkEnd) //TrkVarFunc(stripTrkEndu) //TrkVarFunc(stripTrkEndv) //TrkVarFunc(stripTrkBegIsu) //TrkVarFunc(stripTrkEndIsu) //TrkVarFunc(regionTrkVtx) //TrkVarFunc(edgeRegionTrkVtx) //TrkVarFunc(edgeRegionTrkEnd) //TrkVarFunc(phiTrkVtx) //TrkVarFunc(phiTrkEnd) //TrkVarFunc(parallelStripTrkVtx) //TrkVarFunc(parallelStripTrkEnd) //TrkVarFunc(stripTrkBegPerpFlag) //TrkVarFunc(stripTrkEndPerpFlag) //TrkVarFunc(stripHoveNumTrkVtx) //TrkVarFunc(stripHoveNumTrkEnd) //TrkVarFunc(xTrkEnd) //TrkVarFunc(yTrkEnd) //TrkVarFunc(zTrkEnd) //TrkVarFunc(uTrkEnd) //TrkVarFunc(vTrkEnd) //TrkVarFunc(planeTrkEnd) //TrkVarFunc(planeTrkEndu) //TrkVarFunc(planeTrkEndv) //TrkVarFunc(drTrkFidall) //TrkVarFunc(dzTrkFidall) //TrkVarFunc(drTrkFidvtx) //TrkVarFunc(dzTrkFidvtx) //TrkVarFunc(drTrkFidend) //TrkVarFunc(dzTrkFidend) //TrkVarFunc(traceTrkFidall) //TrkVarFunc(traceTrkFidvtx) //TrkVarFunc(traceTrkFidend) //TrkVarFunc(cosPrTrkVtx) //TrkVarFunc(mcTrk) // //#undef TrkVarFunc // //#define ShwVarFunc(var) \ //typeof(dummy.var##1)& get_##var(NuEvent& nu, \ // int idx) \ //{ \ // switch(idx){ \ // case 1: return nu.var##1; \ // case 2: return nu.var##2; \ // case 3: return nu.var##3; \ // case 4: return nu.var##4; \ // case 5: return nu.var##5; \ // default: \ // assert(0 && "Shower index out of range"); \ // } \ //} \ // \ //typeof(dummy.var##1) get_##var(const NuEvent& nu, \ // int idx) \ //{ \ // switch(idx){ \ // case 1: return nu.var##1; \ // case 2: return nu.var##2; \ // case 3: return nu.var##3; \ // case 4: return nu.var##4; \ // case 5: return nu.var##5; \ // default: \ // assert(0 && "Shower index out of range"); \ // } \ //} \ // \ //typeof(dummy.var##1)& get_##var(NuEvent* nu, \ // int idx) \ //{ \ // switch(idx){ \ // case 1: return nu->var##1; \ // case 2: return nu->var##2; \ // case 3: return nu->var##3; \ // case 4: return nu->var##4; \ // case 5: return nu->var##5; \ // default: \ // assert(0 && "Shower index out of range"); \ // } \ //} // //ShwVarFunc(shwExists) //ShwVarFunc(ndigitShw) //ShwVarFunc(nstripShw) //ShwVarFunc(nplaneShw) //ShwVarFunc(shwEnCor) //ShwVarFunc(shwEnNoCor) //ShwVarFunc(shwEnLinCCNoCor) //ShwVarFunc(shwEnLinCCCor) //ShwVarFunc(shwEnWtCCNoCor) //ShwVarFunc(shwEnWtCCCor) //ShwVarFunc(shwEnLinNCNoCor) //ShwVarFunc(shwEnLinNCCor) //ShwVarFunc(shwEnWtNCNoCor) //ShwVarFunc(shwEnWtNCCor) //ShwVarFunc(shwEnMip) //ShwVarFunc(planeShwBeg) //ShwVarFunc(planeShwEnd) //ShwVarFunc(planeShwMax) //ShwVarFunc(xShwVtx) //ShwVarFunc(yShwVtx) //ShwVarFunc(zShwVtx) //ShwVarFunc(mcShw) // //#undef ShwVarFunc // //} // end namespace } // end minos namespace #endif //NUEVENT_H
[ "tom.carroll@wisc.edu" ]
tom.carroll@wisc.edu
e94b959dd94dfc7841b8c2d8a1542f3f5367ddb4
2517090959409e9a09f69fb82821d80a4811220f
/include/playerlogiccomponent.h
8c0767a98bd5662e34a2167ed801b58322c573dc
[ "MIT" ]
permissive
shawnhappy/dfs
4458ca19d5e35f4179028bdf21f93009ffe2ea3f
520063e5681de9471bb05543de10e4ce113f3f51
refs/heads/master
2021-01-13T03:46:38.386439
2015-08-14T20:48:16
2015-08-14T20:48:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
472
h
#ifndef PLAYERLOGICCOMPONENT_H #define PLAYERLOGICCOMPONENT_H #include "baselogiccomponent.h" #include <ncurses.h> class PlayerLogicComponent : public BaseLogicComponent { private: virtual void act(); //This will hold any input given by the setInput() function int input; public: PlayerLogicComponent(); //If there's any input that changes the state of the player, put it here. void setInput(int); double getInitiative(); }; #endif //PLAYERLOGICCOMPONENT_H
[ "morganfshirley@gmail.com" ]
morganfshirley@gmail.com
e8dd16c84b1fecf955fe8721e0b126a85c38fc84
4f0eff2337ee0234ff0719fbd3bcdfe9918f06bc
/aeron-driver/src/main/cpp/MediaDriverMain.cpp
7b423ada81fe9baec27405329b66ad39b18fc9fc
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
alperenyesil/Aeron
2ab6ba7d2007cab55029c1e2993b50609ac14ffb
78657a8b0538958618590e4ce1d3a20661b738c1
refs/heads/master
2021-01-21T01:49:46.479458
2016-02-09T18:53:25
2016-02-09T18:53:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,267
cpp
/* * Copyright 2014 - 2015 Real Logic 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 <cstdint> #include <cstdio> #include <signal.h> #include <util/CommandOptionParser.h> #include <thread> #include <array> #include "MediaDriver.h" using namespace aeron::util; using namespace aeron; std::atomic<bool> running (true); void sigIntHandler (int param) { running = false; } static const char optHelp = 'h'; static const char optPrefix = 'p'; struct Settings { std::string dirPrefix = ""; }; Settings parseCmdLine(CommandOptionParser& cp, int argc, char** argv) { cp.parse(argc, argv); if (cp.getOption(optHelp).isPresent()) { cp.displayOptionsHelp(std::cout); exit(0); } Settings s; s.dirPrefix = cp.getOption(optPrefix).getParam(0, s.dirPrefix); return s; } int main(int argc, char** argv) { CommandOptionParser cp; cp.addOption(CommandOption(optHelp, 0, 0, " Displays help information.")); cp.addOption(CommandOption(optPrefix, 1, 1, "dir Prefix directory for aeron driver.")); signal(SIGINT, sigIntHandler); try { Settings settings = parseCmdLine(cp, argc, argv); // if (settings.dirPrefix != "") // { // context.aeronDir(settings.dirPrefix); // } while (running) { } std::cout << "Shutting Down..." << std::endl; } catch (CommandOptionException& e) { std::cerr << "ERROR: " << e.what() << std::endl << std::endl; cp.displayOptionsHelp(std::cerr); return -1; } catch (std::exception& e) { std::cerr << "FAILED: " << e.what() << " : " << std::endl; return -1; } return 0; }
[ "tmont@nard.net" ]
tmont@nard.net
d84fa9d6bff3505b472ffd8580f89dc0dd393879
44cec87b41994351d75e266767d6bf2f3f3630a8
/src/HyperElasticityB.h
4298ff567ce8f529bd336df6a4f384e9e10f0c89
[]
no_license
Psywah/anisotropy-elasticity
cd4c024180ab002944711d69978e9b14f62bb430
f07c456a61a304d0ddee1fcd33e5eabbe21ef530
refs/heads/master
2021-01-12T05:40:41.776051
2019-03-17T00:51:38
2019-03-17T00:51:38
77,164,830
0
0
null
null
null
null
UTF-8
C++
false
false
146,551
h
// This code conforms with the UFC specification version 2017.1.0 // and was automatically generated by FFC version 2017.1.0. // // This code was generated with the option '-l dolfin' and // contains DOLFIN-specific wrappers that depend on DOLFIN. // // This code was generated with the following parameters: // // add_tabulate_tensor_timing: False // convert_exceptions_to_warnings: False // cpp_optimize: True // cpp_optimize_flags: '-O2' // epsilon: 1e-14 // error_control: False // form_postfix: True // format: 'dolfin' // generate_dummy_tabulate_tensor: False // max_signature_length: 0 // optimize: True // precision: None // quadrature_degree: 4 // quadrature_rule: None // representation: 'auto' // split: True #ifndef __HYPERELASTICITYB_H #define __HYPERELASTICITYB_H #include <algorithm> #include <cmath> #include <stdexcept> #include <ufc.h> class hyperelasticityb_finite_element_0: public ufc::finite_element { public: hyperelasticityb_finite_element_0(); ~hyperelasticityb_finite_element_0() override; const char * signature() const final override; ufc::shape cell_shape() const final override; std::size_t topological_dimension() const final override; std::size_t geometric_dimension() const final override; std::size_t space_dimension() const final override; std::size_t value_rank() const final override; std::size_t value_dimension(std::size_t i) const final override; std::size_t value_size() const final override; std::size_t reference_value_rank() const final override; std::size_t reference_value_dimension(std::size_t i) const final override; std::size_t reference_value_size() const final override; std::size_t degree() const final override; const char * family() const final override; static void _evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis(i, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_all(values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation); } double evaluate_dof(std::size_t i, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void evaluate_dofs(double * values, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void interpolate_vertex_values(double * vertex_values, const double * dof_values, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void tabulate_dof_coordinates(double * coordinates, const double * coordinate_dofs) const final override; std::size_t num_sub_elements() const final override; ufc::finite_element * create_sub_element(std::size_t i) const final override; ufc::finite_element * create() const final override; }; class hyperelasticityb_finite_element_1: public ufc::finite_element { public: hyperelasticityb_finite_element_1(); ~hyperelasticityb_finite_element_1() override; const char * signature() const final override; ufc::shape cell_shape() const final override; std::size_t topological_dimension() const final override; std::size_t geometric_dimension() const final override; std::size_t space_dimension() const final override; std::size_t value_rank() const final override; std::size_t value_dimension(std::size_t i) const final override; std::size_t value_size() const final override; std::size_t reference_value_rank() const final override; std::size_t reference_value_dimension(std::size_t i) const final override; std::size_t reference_value_size() const final override; std::size_t degree() const final override; const char * family() const final override; static void _evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis(i, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_all(values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation); } double evaluate_dof(std::size_t i, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void evaluate_dofs(double * values, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void interpolate_vertex_values(double * vertex_values, const double * dof_values, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void tabulate_dof_coordinates(double * coordinates, const double * coordinate_dofs) const final override; std::size_t num_sub_elements() const final override; ufc::finite_element * create_sub_element(std::size_t i) const final override; ufc::finite_element * create() const final override; }; class hyperelasticityb_finite_element_2: public ufc::finite_element { public: hyperelasticityb_finite_element_2(); ~hyperelasticityb_finite_element_2() override; const char * signature() const final override; ufc::shape cell_shape() const final override; std::size_t topological_dimension() const final override; std::size_t geometric_dimension() const final override; std::size_t space_dimension() const final override; std::size_t value_rank() const final override; std::size_t value_dimension(std::size_t i) const final override; std::size_t value_size() const final override; std::size_t reference_value_rank() const final override; std::size_t reference_value_dimension(std::size_t i) const final override; std::size_t reference_value_size() const final override; std::size_t degree() const final override; const char * family() const final override; static void _evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis(i, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_all(values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation); } double evaluate_dof(std::size_t i, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void evaluate_dofs(double * values, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void interpolate_vertex_values(double * vertex_values, const double * dof_values, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void tabulate_dof_coordinates(double * coordinates, const double * coordinate_dofs) const final override; std::size_t num_sub_elements() const final override; ufc::finite_element * create_sub_element(std::size_t i) const final override; ufc::finite_element * create() const final override; }; class hyperelasticityb_finite_element_3: public ufc::finite_element { public: hyperelasticityb_finite_element_3(); ~hyperelasticityb_finite_element_3() override; const char * signature() const final override; ufc::shape cell_shape() const final override; std::size_t topological_dimension() const final override; std::size_t geometric_dimension() const final override; std::size_t space_dimension() const final override; std::size_t value_rank() const final override; std::size_t value_dimension(std::size_t i) const final override; std::size_t value_size() const final override; std::size_t reference_value_rank() const final override; std::size_t reference_value_dimension(std::size_t i) const final override; std::size_t reference_value_size() const final override; std::size_t degree() const final override; const char * family() const final override; static void _evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis(i, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_all(values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation); } double evaluate_dof(std::size_t i, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void evaluate_dofs(double * values, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void interpolate_vertex_values(double * vertex_values, const double * dof_values, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void tabulate_dof_coordinates(double * coordinates, const double * coordinate_dofs) const final override; std::size_t num_sub_elements() const final override; ufc::finite_element * create_sub_element(std::size_t i) const final override; ufc::finite_element * create() const final override; }; class hyperelasticityb_finite_element_4: public ufc::finite_element { public: hyperelasticityb_finite_element_4(); ~hyperelasticityb_finite_element_4() override; const char * signature() const final override; ufc::shape cell_shape() const final override; std::size_t topological_dimension() const final override; std::size_t geometric_dimension() const final override; std::size_t space_dimension() const final override; std::size_t value_rank() const final override; std::size_t value_dimension(std::size_t i) const final override; std::size_t value_size() const final override; std::size_t reference_value_rank() const final override; std::size_t reference_value_dimension(std::size_t i) const final override; std::size_t reference_value_size() const final override; std::size_t degree() const final override; const char * family() const final override; static void _evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis(i, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_all(values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation); } double evaluate_dof(std::size_t i, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void evaluate_dofs(double * values, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void interpolate_vertex_values(double * vertex_values, const double * dof_values, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void tabulate_dof_coordinates(double * coordinates, const double * coordinate_dofs) const final override; std::size_t num_sub_elements() const final override; ufc::finite_element * create_sub_element(std::size_t i) const final override; ufc::finite_element * create() const final override; }; class hyperelasticityb_finite_element_5: public ufc::finite_element { public: hyperelasticityb_finite_element_5(); ~hyperelasticityb_finite_element_5() override; const char * signature() const final override; ufc::shape cell_shape() const final override; std::size_t topological_dimension() const final override; std::size_t geometric_dimension() const final override; std::size_t space_dimension() const final override; std::size_t value_rank() const final override; std::size_t value_dimension(std::size_t i) const final override; std::size_t value_size() const final override; std::size_t reference_value_rank() const final override; std::size_t reference_value_dimension(std::size_t i) const final override; std::size_t reference_value_size() const final override; std::size_t degree() const final override; const char * family() const final override; static void _evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis(i, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_all(values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation); } double evaluate_dof(std::size_t i, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void evaluate_dofs(double * values, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void interpolate_vertex_values(double * vertex_values, const double * dof_values, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void tabulate_dof_coordinates(double * coordinates, const double * coordinate_dofs) const final override; std::size_t num_sub_elements() const final override; ufc::finite_element * create_sub_element(std::size_t i) const final override; ufc::finite_element * create() const final override; }; class hyperelasticityb_finite_element_6: public ufc::finite_element { public: hyperelasticityb_finite_element_6(); ~hyperelasticityb_finite_element_6() override; const char * signature() const final override; ufc::shape cell_shape() const final override; std::size_t topological_dimension() const final override; std::size_t geometric_dimension() const final override; std::size_t space_dimension() const final override; std::size_t value_rank() const final override; std::size_t value_dimension(std::size_t i) const final override; std::size_t value_size() const final override; std::size_t reference_value_rank() const final override; std::size_t reference_value_dimension(std::size_t i) const final override; std::size_t reference_value_size() const final override; std::size_t degree() const final override; const char * family() const final override; static void _evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis(std::size_t i, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis(i, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_all(double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_all(values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives(std::size_t i, std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation); } static void _evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation); void evaluate_basis_derivatives_all(std::size_t n, double * values, const double * x, const double * coordinate_dofs, int cell_orientation) const final override { _evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation); } double evaluate_dof(std::size_t i, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void evaluate_dofs(double * values, const ufc::function& f, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void interpolate_vertex_values(double * vertex_values, const double * dof_values, const double * coordinate_dofs, int cell_orientation, const ufc::cell& c) const final override; void tabulate_dof_coordinates(double * coordinates, const double * coordinate_dofs) const final override; std::size_t num_sub_elements() const final override; ufc::finite_element * create_sub_element(std::size_t i) const final override; ufc::finite_element * create() const final override; }; class hyperelasticityb_dofmap_0: public ufc::dofmap { public: hyperelasticityb_dofmap_0(); ~hyperelasticityb_dofmap_0() override; const char * signature() const final override; bool needs_mesh_entities(std::size_t d) const final override; std::size_t topological_dimension() const final override; std::size_t global_dimension(const std::vector<std::size_t>& num_global_entities) const final override; std::size_t num_element_dofs() const final override; std::size_t num_facet_dofs() const final override; std::size_t num_entity_dofs(std::size_t d) const final override; std::size_t num_entity_closure_dofs(std::size_t d) const final override; void tabulate_dofs(std::size_t * dofs, const std::vector<std::size_t>& num_global_entities, const std::vector<std::vector<std::size_t>>& entity_indices) const final override; void tabulate_facet_dofs(std::size_t * dofs, std::size_t facet) const final override; void tabulate_entity_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; void tabulate_entity_closure_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; std::size_t num_sub_dofmaps() const final override; ufc::dofmap * create_sub_dofmap(std::size_t i) const final override; ufc::dofmap * create() const final override; }; class hyperelasticityb_dofmap_1: public ufc::dofmap { public: hyperelasticityb_dofmap_1(); ~hyperelasticityb_dofmap_1() override; const char * signature() const final override; bool needs_mesh_entities(std::size_t d) const final override; std::size_t topological_dimension() const final override; std::size_t global_dimension(const std::vector<std::size_t>& num_global_entities) const final override; std::size_t num_element_dofs() const final override; std::size_t num_facet_dofs() const final override; std::size_t num_entity_dofs(std::size_t d) const final override; std::size_t num_entity_closure_dofs(std::size_t d) const final override; void tabulate_dofs(std::size_t * dofs, const std::vector<std::size_t>& num_global_entities, const std::vector<std::vector<std::size_t>>& entity_indices) const final override; void tabulate_facet_dofs(std::size_t * dofs, std::size_t facet) const final override; void tabulate_entity_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; void tabulate_entity_closure_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; std::size_t num_sub_dofmaps() const final override; ufc::dofmap * create_sub_dofmap(std::size_t i) const final override; ufc::dofmap * create() const final override; }; class hyperelasticityb_dofmap_2: public ufc::dofmap { public: hyperelasticityb_dofmap_2(); ~hyperelasticityb_dofmap_2() override; const char * signature() const final override; bool needs_mesh_entities(std::size_t d) const final override; std::size_t topological_dimension() const final override; std::size_t global_dimension(const std::vector<std::size_t>& num_global_entities) const final override; std::size_t num_element_dofs() const final override; std::size_t num_facet_dofs() const final override; std::size_t num_entity_dofs(std::size_t d) const final override; std::size_t num_entity_closure_dofs(std::size_t d) const final override; void tabulate_dofs(std::size_t * dofs, const std::vector<std::size_t>& num_global_entities, const std::vector<std::vector<std::size_t>>& entity_indices) const final override; void tabulate_facet_dofs(std::size_t * dofs, std::size_t facet) const final override; void tabulate_entity_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; void tabulate_entity_closure_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; std::size_t num_sub_dofmaps() const final override; ufc::dofmap * create_sub_dofmap(std::size_t i) const final override; ufc::dofmap * create() const final override; }; class hyperelasticityb_dofmap_3: public ufc::dofmap { public: hyperelasticityb_dofmap_3(); ~hyperelasticityb_dofmap_3() override; const char * signature() const final override; bool needs_mesh_entities(std::size_t d) const final override; std::size_t topological_dimension() const final override; std::size_t global_dimension(const std::vector<std::size_t>& num_global_entities) const final override; std::size_t num_element_dofs() const final override; std::size_t num_facet_dofs() const final override; std::size_t num_entity_dofs(std::size_t d) const final override; std::size_t num_entity_closure_dofs(std::size_t d) const final override; void tabulate_dofs(std::size_t * dofs, const std::vector<std::size_t>& num_global_entities, const std::vector<std::vector<std::size_t>>& entity_indices) const final override; void tabulate_facet_dofs(std::size_t * dofs, std::size_t facet) const final override; void tabulate_entity_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; void tabulate_entity_closure_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; std::size_t num_sub_dofmaps() const final override; ufc::dofmap * create_sub_dofmap(std::size_t i) const final override; ufc::dofmap * create() const final override; }; class hyperelasticityb_dofmap_4: public ufc::dofmap { public: hyperelasticityb_dofmap_4(); ~hyperelasticityb_dofmap_4() override; const char * signature() const final override; bool needs_mesh_entities(std::size_t d) const final override; std::size_t topological_dimension() const final override; std::size_t global_dimension(const std::vector<std::size_t>& num_global_entities) const final override; std::size_t num_element_dofs() const final override; std::size_t num_facet_dofs() const final override; std::size_t num_entity_dofs(std::size_t d) const final override; std::size_t num_entity_closure_dofs(std::size_t d) const final override; void tabulate_dofs(std::size_t * dofs, const std::vector<std::size_t>& num_global_entities, const std::vector<std::vector<std::size_t>>& entity_indices) const final override; void tabulate_facet_dofs(std::size_t * dofs, std::size_t facet) const final override; void tabulate_entity_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; void tabulate_entity_closure_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; std::size_t num_sub_dofmaps() const final override; ufc::dofmap * create_sub_dofmap(std::size_t i) const final override; ufc::dofmap * create() const final override; }; class hyperelasticityb_dofmap_5: public ufc::dofmap { public: hyperelasticityb_dofmap_5(); ~hyperelasticityb_dofmap_5() override; const char * signature() const final override; bool needs_mesh_entities(std::size_t d) const final override; std::size_t topological_dimension() const final override; std::size_t global_dimension(const std::vector<std::size_t>& num_global_entities) const final override; std::size_t num_element_dofs() const final override; std::size_t num_facet_dofs() const final override; std::size_t num_entity_dofs(std::size_t d) const final override; std::size_t num_entity_closure_dofs(std::size_t d) const final override; void tabulate_dofs(std::size_t * dofs, const std::vector<std::size_t>& num_global_entities, const std::vector<std::vector<std::size_t>>& entity_indices) const final override; void tabulate_facet_dofs(std::size_t * dofs, std::size_t facet) const final override; void tabulate_entity_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; void tabulate_entity_closure_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; std::size_t num_sub_dofmaps() const final override; ufc::dofmap * create_sub_dofmap(std::size_t i) const final override; ufc::dofmap * create() const final override; }; class hyperelasticityb_dofmap_6: public ufc::dofmap { public: hyperelasticityb_dofmap_6(); ~hyperelasticityb_dofmap_6() override; const char * signature() const final override; bool needs_mesh_entities(std::size_t d) const final override; std::size_t topological_dimension() const final override; std::size_t global_dimension(const std::vector<std::size_t>& num_global_entities) const final override; std::size_t num_element_dofs() const final override; std::size_t num_facet_dofs() const final override; std::size_t num_entity_dofs(std::size_t d) const final override; std::size_t num_entity_closure_dofs(std::size_t d) const final override; void tabulate_dofs(std::size_t * dofs, const std::vector<std::size_t>& num_global_entities, const std::vector<std::vector<std::size_t>>& entity_indices) const final override; void tabulate_facet_dofs(std::size_t * dofs, std::size_t facet) const final override; void tabulate_entity_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; void tabulate_entity_closure_dofs(std::size_t * dofs, std::size_t d, std::size_t i) const final override; std::size_t num_sub_dofmaps() const final override; ufc::dofmap * create_sub_dofmap(std::size_t i) const final override; ufc::dofmap * create() const final override; }; class hyperelasticityb_cell_integral_0_1: public ufc::cell_integral { public: hyperelasticityb_cell_integral_0_1(); ~hyperelasticityb_cell_integral_0_1() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_0_2: public ufc::cell_integral { public: hyperelasticityb_cell_integral_0_2(); ~hyperelasticityb_cell_integral_0_2() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_0_3: public ufc::cell_integral { public: hyperelasticityb_cell_integral_0_3(); ~hyperelasticityb_cell_integral_0_3() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_0_4: public ufc::cell_integral { public: hyperelasticityb_cell_integral_0_4(); ~hyperelasticityb_cell_integral_0_4() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_0_otherwise: public ufc::cell_integral { public: hyperelasticityb_cell_integral_0_otherwise(); ~hyperelasticityb_cell_integral_0_otherwise() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_exterior_facet_integral_0_3: public ufc::exterior_facet_integral { public: hyperelasticityb_exterior_facet_integral_0_3(); ~hyperelasticityb_exterior_facet_integral_0_3() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, std::size_t facet, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_1_1: public ufc::cell_integral { public: hyperelasticityb_cell_integral_1_1(); ~hyperelasticityb_cell_integral_1_1() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_1_2: public ufc::cell_integral { public: hyperelasticityb_cell_integral_1_2(); ~hyperelasticityb_cell_integral_1_2() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_1_3: public ufc::cell_integral { public: hyperelasticityb_cell_integral_1_3(); ~hyperelasticityb_cell_integral_1_3() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_1_4: public ufc::cell_integral { public: hyperelasticityb_cell_integral_1_4(); ~hyperelasticityb_cell_integral_1_4() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_2_1: public ufc::cell_integral { public: hyperelasticityb_cell_integral_2_1(); ~hyperelasticityb_cell_integral_2_1() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_2_2: public ufc::cell_integral { public: hyperelasticityb_cell_integral_2_2(); ~hyperelasticityb_cell_integral_2_2() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_2_3: public ufc::cell_integral { public: hyperelasticityb_cell_integral_2_3(); ~hyperelasticityb_cell_integral_2_3() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_2_4: public ufc::cell_integral { public: hyperelasticityb_cell_integral_2_4(); ~hyperelasticityb_cell_integral_2_4() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_2_otherwise: public ufc::cell_integral { public: hyperelasticityb_cell_integral_2_otherwise(); ~hyperelasticityb_cell_integral_2_otherwise() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_exterior_facet_integral_2_3: public ufc::exterior_facet_integral { public: hyperelasticityb_exterior_facet_integral_2_3(); ~hyperelasticityb_exterior_facet_integral_2_3() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, std::size_t facet, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_3_otherwise: public ufc::cell_integral { public: hyperelasticityb_cell_integral_3_otherwise(); ~hyperelasticityb_cell_integral_3_otherwise() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_4_1: public ufc::cell_integral { public: hyperelasticityb_cell_integral_4_1(); ~hyperelasticityb_cell_integral_4_1() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_4_2: public ufc::cell_integral { public: hyperelasticityb_cell_integral_4_2(); ~hyperelasticityb_cell_integral_4_2() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_4_3: public ufc::cell_integral { public: hyperelasticityb_cell_integral_4_3(); ~hyperelasticityb_cell_integral_4_3() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_cell_integral_4_4: public ufc::cell_integral { public: hyperelasticityb_cell_integral_4_4(); ~hyperelasticityb_cell_integral_4_4() override; const std::vector<bool> & enabled_coefficients() const final override; void tabulate_tensor(double * A, const double * const * w, const double * coordinate_dofs, int cell_orientation) const final override; }; class hyperelasticityb_form_0: public ufc::form { public: hyperelasticityb_form_0(); ~hyperelasticityb_form_0() override; const char * signature() const final override; std::size_t rank() const final override; std::size_t num_coefficients() const final override; std::size_t original_coefficient_position(std::size_t i) const final override; ufc::finite_element * create_coordinate_finite_element() const final override; ufc::dofmap * create_coordinate_dofmap() const final override; ufc::coordinate_mapping * create_coordinate_mapping() const final override; ufc::finite_element * create_finite_element(std::size_t i) const final override; ufc::dofmap * create_dofmap(std::size_t i) const final override; std::size_t max_cell_subdomain_id() const final override; std::size_t max_exterior_facet_subdomain_id() const final override; std::size_t max_interior_facet_subdomain_id() const final override; std::size_t max_vertex_subdomain_id() const final override; std::size_t max_custom_subdomain_id() const final override; std::size_t max_cutcell_subdomain_id() const final override; std::size_t max_interface_subdomain_id() const final override; std::size_t max_overlap_subdomain_id() const final override; bool has_cell_integrals() const final override; bool has_exterior_facet_integrals() const final override; bool has_interior_facet_integrals() const final override; bool has_vertex_integrals() const final override; bool has_custom_integrals() const final override; bool has_cutcell_integrals() const final override; bool has_interface_integrals() const final override; bool has_overlap_integrals() const final override; ufc::cell_integral * create_cell_integral(std::size_t i) const final override; ufc::exterior_facet_integral * create_exterior_facet_integral(std::size_t i) const final override; ufc::interior_facet_integral * create_interior_facet_integral(std::size_t i) const final override; ufc::vertex_integral * create_vertex_integral(std::size_t i) const final override; ufc::custom_integral * create_custom_integral(std::size_t i) const final override; ufc::cutcell_integral * create_cutcell_integral(std::size_t i) const final override; ufc::interface_integral * create_interface_integral(std::size_t i) const final override; ufc::overlap_integral * create_overlap_integral(std::size_t i) const final override; ufc::cell_integral * create_default_cell_integral() const final override; ufc::exterior_facet_integral * create_default_exterior_facet_integral() const final override; ufc::interior_facet_integral * create_default_interior_facet_integral() const final override; ufc::vertex_integral * create_default_vertex_integral() const final override; ufc::custom_integral * create_default_custom_integral() const final override; ufc::cutcell_integral * create_default_cutcell_integral() const final override; ufc::interface_integral * create_default_interface_integral() const final override; ufc::overlap_integral * create_default_overlap_integral() const final override; }; class hyperelasticityb_form_1: public ufc::form { public: hyperelasticityb_form_1(); ~hyperelasticityb_form_1() override; const char * signature() const final override; std::size_t rank() const final override; std::size_t num_coefficients() const final override; std::size_t original_coefficient_position(std::size_t i) const final override; ufc::finite_element * create_coordinate_finite_element() const final override; ufc::dofmap * create_coordinate_dofmap() const final override; ufc::coordinate_mapping * create_coordinate_mapping() const final override; ufc::finite_element * create_finite_element(std::size_t i) const final override; ufc::dofmap * create_dofmap(std::size_t i) const final override; std::size_t max_cell_subdomain_id() const final override; std::size_t max_exterior_facet_subdomain_id() const final override; std::size_t max_interior_facet_subdomain_id() const final override; std::size_t max_vertex_subdomain_id() const final override; std::size_t max_custom_subdomain_id() const final override; std::size_t max_cutcell_subdomain_id() const final override; std::size_t max_interface_subdomain_id() const final override; std::size_t max_overlap_subdomain_id() const final override; bool has_cell_integrals() const final override; bool has_exterior_facet_integrals() const final override; bool has_interior_facet_integrals() const final override; bool has_vertex_integrals() const final override; bool has_custom_integrals() const final override; bool has_cutcell_integrals() const final override; bool has_interface_integrals() const final override; bool has_overlap_integrals() const final override; ufc::cell_integral * create_cell_integral(std::size_t i) const final override; ufc::exterior_facet_integral * create_exterior_facet_integral(std::size_t i) const final override; ufc::interior_facet_integral * create_interior_facet_integral(std::size_t i) const final override; ufc::vertex_integral * create_vertex_integral(std::size_t i) const final override; ufc::custom_integral * create_custom_integral(std::size_t i) const final override; ufc::cutcell_integral * create_cutcell_integral(std::size_t i) const final override; ufc::interface_integral * create_interface_integral(std::size_t i) const final override; ufc::overlap_integral * create_overlap_integral(std::size_t i) const final override; ufc::cell_integral * create_default_cell_integral() const final override; ufc::exterior_facet_integral * create_default_exterior_facet_integral() const final override; ufc::interior_facet_integral * create_default_interior_facet_integral() const final override; ufc::vertex_integral * create_default_vertex_integral() const final override; ufc::custom_integral * create_default_custom_integral() const final override; ufc::cutcell_integral * create_default_cutcell_integral() const final override; ufc::interface_integral * create_default_interface_integral() const final override; ufc::overlap_integral * create_default_overlap_integral() const final override; }; class hyperelasticityb_form_2: public ufc::form { public: hyperelasticityb_form_2(); ~hyperelasticityb_form_2() override; const char * signature() const final override; std::size_t rank() const final override; std::size_t num_coefficients() const final override; std::size_t original_coefficient_position(std::size_t i) const final override; ufc::finite_element * create_coordinate_finite_element() const final override; ufc::dofmap * create_coordinate_dofmap() const final override; ufc::coordinate_mapping * create_coordinate_mapping() const final override; ufc::finite_element * create_finite_element(std::size_t i) const final override; ufc::dofmap * create_dofmap(std::size_t i) const final override; std::size_t max_cell_subdomain_id() const final override; std::size_t max_exterior_facet_subdomain_id() const final override; std::size_t max_interior_facet_subdomain_id() const final override; std::size_t max_vertex_subdomain_id() const final override; std::size_t max_custom_subdomain_id() const final override; std::size_t max_cutcell_subdomain_id() const final override; std::size_t max_interface_subdomain_id() const final override; std::size_t max_overlap_subdomain_id() const final override; bool has_cell_integrals() const final override; bool has_exterior_facet_integrals() const final override; bool has_interior_facet_integrals() const final override; bool has_vertex_integrals() const final override; bool has_custom_integrals() const final override; bool has_cutcell_integrals() const final override; bool has_interface_integrals() const final override; bool has_overlap_integrals() const final override; ufc::cell_integral * create_cell_integral(std::size_t i) const final override; ufc::exterior_facet_integral * create_exterior_facet_integral(std::size_t i) const final override; ufc::interior_facet_integral * create_interior_facet_integral(std::size_t i) const final override; ufc::vertex_integral * create_vertex_integral(std::size_t i) const final override; ufc::custom_integral * create_custom_integral(std::size_t i) const final override; ufc::cutcell_integral * create_cutcell_integral(std::size_t i) const final override; ufc::interface_integral * create_interface_integral(std::size_t i) const final override; ufc::overlap_integral * create_overlap_integral(std::size_t i) const final override; ufc::cell_integral * create_default_cell_integral() const final override; ufc::exterior_facet_integral * create_default_exterior_facet_integral() const final override; ufc::interior_facet_integral * create_default_interior_facet_integral() const final override; ufc::vertex_integral * create_default_vertex_integral() const final override; ufc::custom_integral * create_default_custom_integral() const final override; ufc::cutcell_integral * create_default_cutcell_integral() const final override; ufc::interface_integral * create_default_interface_integral() const final override; ufc::overlap_integral * create_default_overlap_integral() const final override; }; class hyperelasticityb_form_3: public ufc::form { public: hyperelasticityb_form_3(); ~hyperelasticityb_form_3() override; const char * signature() const final override; std::size_t rank() const final override; std::size_t num_coefficients() const final override; std::size_t original_coefficient_position(std::size_t i) const final override; ufc::finite_element * create_coordinate_finite_element() const final override; ufc::dofmap * create_coordinate_dofmap() const final override; ufc::coordinate_mapping * create_coordinate_mapping() const final override; ufc::finite_element * create_finite_element(std::size_t i) const final override; ufc::dofmap * create_dofmap(std::size_t i) const final override; std::size_t max_cell_subdomain_id() const final override; std::size_t max_exterior_facet_subdomain_id() const final override; std::size_t max_interior_facet_subdomain_id() const final override; std::size_t max_vertex_subdomain_id() const final override; std::size_t max_custom_subdomain_id() const final override; std::size_t max_cutcell_subdomain_id() const final override; std::size_t max_interface_subdomain_id() const final override; std::size_t max_overlap_subdomain_id() const final override; bool has_cell_integrals() const final override; bool has_exterior_facet_integrals() const final override; bool has_interior_facet_integrals() const final override; bool has_vertex_integrals() const final override; bool has_custom_integrals() const final override; bool has_cutcell_integrals() const final override; bool has_interface_integrals() const final override; bool has_overlap_integrals() const final override; ufc::cell_integral * create_cell_integral(std::size_t i) const final override; ufc::exterior_facet_integral * create_exterior_facet_integral(std::size_t i) const final override; ufc::interior_facet_integral * create_interior_facet_integral(std::size_t i) const final override; ufc::vertex_integral * create_vertex_integral(std::size_t i) const final override; ufc::custom_integral * create_custom_integral(std::size_t i) const final override; ufc::cutcell_integral * create_cutcell_integral(std::size_t i) const final override; ufc::interface_integral * create_interface_integral(std::size_t i) const final override; ufc::overlap_integral * create_overlap_integral(std::size_t i) const final override; ufc::cell_integral * create_default_cell_integral() const final override; ufc::exterior_facet_integral * create_default_exterior_facet_integral() const final override; ufc::interior_facet_integral * create_default_interior_facet_integral() const final override; ufc::vertex_integral * create_default_vertex_integral() const final override; ufc::custom_integral * create_default_custom_integral() const final override; ufc::cutcell_integral * create_default_cutcell_integral() const final override; ufc::interface_integral * create_default_interface_integral() const final override; ufc::overlap_integral * create_default_overlap_integral() const final override; }; class hyperelasticityb_form_4: public ufc::form { public: hyperelasticityb_form_4(); ~hyperelasticityb_form_4() override; const char * signature() const final override; std::size_t rank() const final override; std::size_t num_coefficients() const final override; std::size_t original_coefficient_position(std::size_t i) const final override; ufc::finite_element * create_coordinate_finite_element() const final override; ufc::dofmap * create_coordinate_dofmap() const final override; ufc::coordinate_mapping * create_coordinate_mapping() const final override; ufc::finite_element * create_finite_element(std::size_t i) const final override; ufc::dofmap * create_dofmap(std::size_t i) const final override; std::size_t max_cell_subdomain_id() const final override; std::size_t max_exterior_facet_subdomain_id() const final override; std::size_t max_interior_facet_subdomain_id() const final override; std::size_t max_vertex_subdomain_id() const final override; std::size_t max_custom_subdomain_id() const final override; std::size_t max_cutcell_subdomain_id() const final override; std::size_t max_interface_subdomain_id() const final override; std::size_t max_overlap_subdomain_id() const final override; bool has_cell_integrals() const final override; bool has_exterior_facet_integrals() const final override; bool has_interior_facet_integrals() const final override; bool has_vertex_integrals() const final override; bool has_custom_integrals() const final override; bool has_cutcell_integrals() const final override; bool has_interface_integrals() const final override; bool has_overlap_integrals() const final override; ufc::cell_integral * create_cell_integral(std::size_t i) const final override; ufc::exterior_facet_integral * create_exterior_facet_integral(std::size_t i) const final override; ufc::interior_facet_integral * create_interior_facet_integral(std::size_t i) const final override; ufc::vertex_integral * create_vertex_integral(std::size_t i) const final override; ufc::custom_integral * create_custom_integral(std::size_t i) const final override; ufc::cutcell_integral * create_cutcell_integral(std::size_t i) const final override; ufc::interface_integral * create_interface_integral(std::size_t i) const final override; ufc::overlap_integral * create_overlap_integral(std::size_t i) const final override; ufc::cell_integral * create_default_cell_integral() const final override; ufc::exterior_facet_integral * create_default_exterior_facet_integral() const final override; ufc::interior_facet_integral * create_default_interior_facet_integral() const final override; ufc::vertex_integral * create_default_vertex_integral() const final override; ufc::custom_integral * create_default_custom_integral() const final override; ufc::cutcell_integral * create_default_cutcell_integral() const final override; ufc::interface_integral * create_default_interface_integral() const final override; ufc::overlap_integral * create_default_overlap_integral() const final override; }; // DOLFIN wrappers // Standard library includes #include <string> // DOLFIN includes #include <dolfin/common/NoDeleter.h> #include <dolfin/mesh/Mesh.h> #include <dolfin/mesh/MultiMesh.h> #include <dolfin/fem/FiniteElement.h> #include <dolfin/fem/DofMap.h> #include <dolfin/fem/Form.h> #include <dolfin/fem/MultiMeshForm.h> #include <dolfin/function/FunctionSpace.h> #include <dolfin/function/MultiMeshFunctionSpace.h> #include <dolfin/function/GenericFunction.h> #include <dolfin/function/CoefficientAssigner.h> #include <dolfin/function/MultiMeshCoefficientAssigner.h> #include <dolfin/adaptivity/ErrorControl.h> #include <dolfin/adaptivity/GoalFunctional.h> #include <dolfin/la/GenericVector.h> namespace HyperElasticityB { class CoefficientSpace_B: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_B(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_1>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_1>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_B(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_1>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_1>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_alpha5: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_alpha5(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_alpha5(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_beta1: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_beta1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_beta1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_c1: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_c1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_c1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_delta1: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_delta1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_delta1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_delta2: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_delta2(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_delta2(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_epsilon1: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_epsilon1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_epsilon1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_epsilon2: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_epsilon2(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_epsilon2(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_eta1: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_eta1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_eta1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_k1: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_k1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_k1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_k2: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_k2(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_k2(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_pressure: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_pressure(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_pressure(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_0>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_0>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_u: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_u(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_3>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_3>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_u(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_3>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_3>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_vec1: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_vec1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_1>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_1>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_vec1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_1>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_1>(), *mesh, constrained_domain)) { // Do nothing } }; class CoefficientSpace_vec2: public dolfin::FunctionSpace { public: // Constructor for standard function space CoefficientSpace_vec2(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_1>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_1>(), *mesh)) { // Do nothing } // Constructor for constrained function space CoefficientSpace_vec2(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_1>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_1>(), *mesh, constrained_domain)) { // Do nothing } }; typedef CoefficientSpace_u Form_Pi_FunctionSpace_0; typedef CoefficientSpace_B Form_Pi_FunctionSpace_1; typedef CoefficientSpace_vec1 Form_Pi_FunctionSpace_2; typedef CoefficientSpace_vec2 Form_Pi_FunctionSpace_3; typedef CoefficientSpace_c1 Form_Pi_FunctionSpace_4; typedef CoefficientSpace_epsilon1 Form_Pi_FunctionSpace_5; typedef CoefficientSpace_epsilon2 Form_Pi_FunctionSpace_6; typedef CoefficientSpace_alpha5 Form_Pi_FunctionSpace_7; typedef CoefficientSpace_k1 Form_Pi_FunctionSpace_8; typedef CoefficientSpace_k2 Form_Pi_FunctionSpace_9; typedef CoefficientSpace_beta1 Form_Pi_FunctionSpace_10; typedef CoefficientSpace_eta1 Form_Pi_FunctionSpace_11; typedef CoefficientSpace_delta1 Form_Pi_FunctionSpace_12; typedef CoefficientSpace_delta2 Form_Pi_FunctionSpace_13; typedef CoefficientSpace_pressure Form_Pi_FunctionSpace_14; class Form_Pi: public dolfin::Form { public: // Constructor Form_Pi(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::Form(0, 15), u(*this, 0), B(*this, 1), vec1(*this, 2), vec2(*this, 3), c1(*this, 4), epsilon1(*this, 5), epsilon2(*this, 6), alpha5(*this, 7), k1(*this, 8), k2(*this, 9), beta1(*this, 10), eta1(*this, 11), delta1(*this, 12), delta2(*this, 13), pressure(*this, 14) { _mesh = mesh; _ufc_form = std::make_shared<const hyperelasticityb_form_0>(); } // Constructor Form_Pi(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::GenericFunction> u, std::shared_ptr<const dolfin::GenericFunction> B, std::shared_ptr<const dolfin::GenericFunction> vec1, std::shared_ptr<const dolfin::GenericFunction> vec2, std::shared_ptr<const dolfin::GenericFunction> c1, std::shared_ptr<const dolfin::GenericFunction> epsilon1, std::shared_ptr<const dolfin::GenericFunction> epsilon2, std::shared_ptr<const dolfin::GenericFunction> alpha5, std::shared_ptr<const dolfin::GenericFunction> k1, std::shared_ptr<const dolfin::GenericFunction> k2, std::shared_ptr<const dolfin::GenericFunction> beta1, std::shared_ptr<const dolfin::GenericFunction> eta1, std::shared_ptr<const dolfin::GenericFunction> delta1, std::shared_ptr<const dolfin::GenericFunction> delta2, std::shared_ptr<const dolfin::GenericFunction> pressure): dolfin::Form(0, 15), u(*this, 0), B(*this, 1), vec1(*this, 2), vec2(*this, 3), c1(*this, 4), epsilon1(*this, 5), epsilon2(*this, 6), alpha5(*this, 7), k1(*this, 8), k2(*this, 9), beta1(*this, 10), eta1(*this, 11), delta1(*this, 12), delta2(*this, 13), pressure(*this, 14) { _mesh = mesh; this->u = u; this->B = B; this->vec1 = vec1; this->vec2 = vec2; this->c1 = c1; this->epsilon1 = epsilon1; this->epsilon2 = epsilon2; this->alpha5 = alpha5; this->k1 = k1; this->k2 = k2; this->beta1 = beta1; this->eta1 = eta1; this->delta1 = delta1; this->delta2 = delta2; this->pressure = pressure; _ufc_form = std::make_shared<const hyperelasticityb_form_0>(); } // Destructor ~Form_Pi() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { if (name == "u") return 0; else if (name == "B") return 1; else if (name == "vec1") return 2; else if (name == "vec2") return 3; else if (name == "c1") return 4; else if (name == "epsilon1") return 5; else if (name == "epsilon2") return 6; else if (name == "alpha5") return 7; else if (name == "k1") return 8; else if (name == "k2") return 9; else if (name == "beta1") return 10; else if (name == "eta1") return 11; else if (name == "delta1") return 12; else if (name == "delta2") return 13; else if (name == "pressure") return 14; dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { switch (i) { case 0: return "u"; case 1: return "B"; case 2: return "vec1"; case 3: return "vec2"; case 4: return "c1"; case 5: return "epsilon1"; case 6: return "epsilon2"; case 7: return "alpha5"; case 8: return "k1"; case 9: return "k2"; case 10: return "beta1"; case 11: return "eta1"; case 12: return "delta1"; case 13: return "delta2"; case 14: return "pressure"; } dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return "unnamed"; } // Typedefs typedef Form_Pi_FunctionSpace_0 CoefficientSpace_u; typedef Form_Pi_FunctionSpace_1 CoefficientSpace_B; typedef Form_Pi_FunctionSpace_2 CoefficientSpace_vec1; typedef Form_Pi_FunctionSpace_3 CoefficientSpace_vec2; typedef Form_Pi_FunctionSpace_4 CoefficientSpace_c1; typedef Form_Pi_FunctionSpace_5 CoefficientSpace_epsilon1; typedef Form_Pi_FunctionSpace_6 CoefficientSpace_epsilon2; typedef Form_Pi_FunctionSpace_7 CoefficientSpace_alpha5; typedef Form_Pi_FunctionSpace_8 CoefficientSpace_k1; typedef Form_Pi_FunctionSpace_9 CoefficientSpace_k2; typedef Form_Pi_FunctionSpace_10 CoefficientSpace_beta1; typedef Form_Pi_FunctionSpace_11 CoefficientSpace_eta1; typedef Form_Pi_FunctionSpace_12 CoefficientSpace_delta1; typedef Form_Pi_FunctionSpace_13 CoefficientSpace_delta2; typedef Form_Pi_FunctionSpace_14 CoefficientSpace_pressure; // Coefficients dolfin::CoefficientAssigner u; dolfin::CoefficientAssigner B; dolfin::CoefficientAssigner vec1; dolfin::CoefficientAssigner vec2; dolfin::CoefficientAssigner c1; dolfin::CoefficientAssigner epsilon1; dolfin::CoefficientAssigner epsilon2; dolfin::CoefficientAssigner alpha5; dolfin::CoefficientAssigner k1; dolfin::CoefficientAssigner k2; dolfin::CoefficientAssigner beta1; dolfin::CoefficientAssigner eta1; dolfin::CoefficientAssigner delta1; dolfin::CoefficientAssigner delta2; dolfin::CoefficientAssigner pressure; }; class MultiMeshForm_Pi: public dolfin::MultiMeshForm { public: // Constructor MultiMeshForm_Pi(std::shared_ptr<const dolfin::MultiMesh> mesh): dolfin::MultiMeshForm(mesh), u(*this, 0), B(*this, 1), vec1(*this, 2), vec2(*this, 3), c1(*this, 4), epsilon1(*this, 5), epsilon2(*this, 6), alpha5(*this, 7), k1(*this, 8), k2(*this, 9), beta1(*this, 10), eta1(*this, 11), delta1(*this, 12), delta2(*this, 13), pressure(*this, 14) { // Creating a form for each part of the mesh for (std::size_t i=0; i< mesh->num_parts(); i++) { std::shared_ptr<dolfin::Form> a(new Form_Pi(mesh->part(i))); add(a); } // Build multimesh form build(); /// Assign coefficients } // Constructor MultiMeshForm_Pi(std::shared_ptr<const dolfin::MultiMesh> mesh, std::shared_ptr<const dolfin::GenericFunction> u, std::shared_ptr<const dolfin::GenericFunction> B, std::shared_ptr<const dolfin::GenericFunction> vec1, std::shared_ptr<const dolfin::GenericFunction> vec2, std::shared_ptr<const dolfin::GenericFunction> c1, std::shared_ptr<const dolfin::GenericFunction> epsilon1, std::shared_ptr<const dolfin::GenericFunction> epsilon2, std::shared_ptr<const dolfin::GenericFunction> alpha5, std::shared_ptr<const dolfin::GenericFunction> k1, std::shared_ptr<const dolfin::GenericFunction> k2, std::shared_ptr<const dolfin::GenericFunction> beta1, std::shared_ptr<const dolfin::GenericFunction> eta1, std::shared_ptr<const dolfin::GenericFunction> delta1, std::shared_ptr<const dolfin::GenericFunction> delta2, std::shared_ptr<const dolfin::GenericFunction> pressure): dolfin::MultiMeshForm(mesh), u(*this, 0), B(*this, 1), vec1(*this, 2), vec2(*this, 3), c1(*this, 4), epsilon1(*this, 5), epsilon2(*this, 6), alpha5(*this, 7), k1(*this, 8), k2(*this, 9), beta1(*this, 10), eta1(*this, 11), delta1(*this, 12), delta2(*this, 13), pressure(*this, 14) { // Creating a form for each part of the mesh for (std::size_t i=0; i< mesh->num_parts(); i++) { std::shared_ptr<dolfin::Form> a(new Form_Pi(mesh->part(i))); add(a); } // Build multimesh form build(); /// Assign coefficients this->u = u; this->B = B; this->vec1 = vec1; this->vec2 = vec2; this->c1 = c1; this->epsilon1 = epsilon1; this->epsilon2 = epsilon2; this->alpha5 = alpha5; this->k1 = k1; this->k2 = k2; this->beta1 = beta1; this->eta1 = eta1; this->delta1 = delta1; this->delta2 = delta2; this->pressure = pressure; } // Destructor ~MultiMeshForm_Pi() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { if (name == "u") return 0; else if (name == "B") return 1; else if (name == "vec1") return 2; else if (name == "vec2") return 3; else if (name == "c1") return 4; else if (name == "epsilon1") return 5; else if (name == "epsilon2") return 6; else if (name == "alpha5") return 7; else if (name == "k1") return 8; else if (name == "k2") return 9; else if (name == "beta1") return 10; else if (name == "eta1") return 11; else if (name == "delta1") return 12; else if (name == "delta2") return 13; else if (name == "pressure") return 14; dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { switch (i) { case 0: return "u"; case 1: return "B"; case 2: return "vec1"; case 3: return "vec2"; case 4: return "c1"; case 5: return "epsilon1"; case 6: return "epsilon2"; case 7: return "alpha5"; case 8: return "k1"; case 9: return "k2"; case 10: return "beta1"; case 11: return "eta1"; case 12: return "delta1"; case 13: return "delta2"; case 14: return "pressure"; } dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return "unnamed"; } // Typedefs typedef Form_Pi_FunctionSpace_0 CoefficientSpace_u; typedef Form_Pi_FunctionSpace_1 CoefficientSpace_B; typedef Form_Pi_FunctionSpace_2 CoefficientSpace_vec1; typedef Form_Pi_FunctionSpace_3 CoefficientSpace_vec2; typedef Form_Pi_FunctionSpace_4 CoefficientSpace_c1; typedef Form_Pi_FunctionSpace_5 CoefficientSpace_epsilon1; typedef Form_Pi_FunctionSpace_6 CoefficientSpace_epsilon2; typedef Form_Pi_FunctionSpace_7 CoefficientSpace_alpha5; typedef Form_Pi_FunctionSpace_8 CoefficientSpace_k1; typedef Form_Pi_FunctionSpace_9 CoefficientSpace_k2; typedef Form_Pi_FunctionSpace_10 CoefficientSpace_beta1; typedef Form_Pi_FunctionSpace_11 CoefficientSpace_eta1; typedef Form_Pi_FunctionSpace_12 CoefficientSpace_delta1; typedef Form_Pi_FunctionSpace_13 CoefficientSpace_delta2; typedef Form_Pi_FunctionSpace_14 CoefficientSpace_pressure; // Coefficients dolfin::MultiMeshCoefficientAssigner u; dolfin::MultiMeshCoefficientAssigner B; dolfin::MultiMeshCoefficientAssigner vec1; dolfin::MultiMeshCoefficientAssigner vec2; dolfin::MultiMeshCoefficientAssigner c1; dolfin::MultiMeshCoefficientAssigner epsilon1; dolfin::MultiMeshCoefficientAssigner epsilon2; dolfin::MultiMeshCoefficientAssigner alpha5; dolfin::MultiMeshCoefficientAssigner k1; dolfin::MultiMeshCoefficientAssigner k2; dolfin::MultiMeshCoefficientAssigner beta1; dolfin::MultiMeshCoefficientAssigner eta1; dolfin::MultiMeshCoefficientAssigner delta1; dolfin::MultiMeshCoefficientAssigner delta2; dolfin::MultiMeshCoefficientAssigner pressure; }; class Form_Jac_FunctionSpace_0: public dolfin::FunctionSpace { public: // Constructor for standard function space Form_Jac_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_3>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_3>(), *mesh)) { // Do nothing } // Constructor for constrained function space Form_Jac_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_3>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_3>(), *mesh, constrained_domain)) { // Do nothing } }; class Form_Jac_FunctionSpace_1: public dolfin::FunctionSpace { public: // Constructor for standard function space Form_Jac_FunctionSpace_1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_3>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_3>(), *mesh)) { // Do nothing } // Constructor for constrained function space Form_Jac_FunctionSpace_1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_3>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_3>(), *mesh, constrained_domain)) { // Do nothing } }; class Form_Jac_MultiMeshFunctionSpace_0: public dolfin::MultiMeshFunctionSpace { public: // Constructor for multimesh function space Form_Jac_MultiMeshFunctionSpace_0(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh) { // Create and add standard function spaces for (std::size_t part = 0; part < multimesh->num_parts(); part++) { std::shared_ptr<const dolfin::FunctionSpace> V(new Form_Jac_FunctionSpace_0(multimesh->part(part))); add(V); } // Build multimesh function space build(); } }; class Form_Jac_MultiMeshFunctionSpace_1: public dolfin::MultiMeshFunctionSpace { public: // Constructor for multimesh function space Form_Jac_MultiMeshFunctionSpace_1(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh) { // Create and add standard function spaces for (std::size_t part = 0; part < multimesh->num_parts(); part++) { std::shared_ptr<const dolfin::FunctionSpace> V(new Form_Jac_FunctionSpace_1(multimesh->part(part))); add(V); } // Build multimesh function space build(); } }; typedef CoefficientSpace_u Form_Jac_FunctionSpace_2; typedef CoefficientSpace_vec1 Form_Jac_FunctionSpace_3; typedef CoefficientSpace_vec2 Form_Jac_FunctionSpace_4; typedef CoefficientSpace_c1 Form_Jac_FunctionSpace_5; typedef CoefficientSpace_epsilon1 Form_Jac_FunctionSpace_6; typedef CoefficientSpace_epsilon2 Form_Jac_FunctionSpace_7; typedef CoefficientSpace_alpha5 Form_Jac_FunctionSpace_8; typedef CoefficientSpace_k1 Form_Jac_FunctionSpace_9; typedef CoefficientSpace_k2 Form_Jac_FunctionSpace_10; typedef CoefficientSpace_beta1 Form_Jac_FunctionSpace_11; typedef CoefficientSpace_eta1 Form_Jac_FunctionSpace_12; typedef CoefficientSpace_delta1 Form_Jac_FunctionSpace_13; typedef CoefficientSpace_delta2 Form_Jac_FunctionSpace_14; class Form_Jac: public dolfin::Form { public: // Constructor Form_Jac(std::shared_ptr<const dolfin::FunctionSpace> V1, std::shared_ptr<const dolfin::FunctionSpace> V0): dolfin::Form(2, 13), u(*this, 0), vec1(*this, 1), vec2(*this, 2), c1(*this, 3), epsilon1(*this, 4), epsilon2(*this, 5), alpha5(*this, 6), k1(*this, 7), k2(*this, 8), beta1(*this, 9), eta1(*this, 10), delta1(*this, 11), delta2(*this, 12) { _function_spaces[0] = V0; _function_spaces[1] = V1; _ufc_form = std::make_shared<const hyperelasticityb_form_1>(); } // Constructor Form_Jac(std::shared_ptr<const dolfin::FunctionSpace> V1, std::shared_ptr<const dolfin::FunctionSpace> V0, std::shared_ptr<const dolfin::GenericFunction> u, std::shared_ptr<const dolfin::GenericFunction> vec1, std::shared_ptr<const dolfin::GenericFunction> vec2, std::shared_ptr<const dolfin::GenericFunction> c1, std::shared_ptr<const dolfin::GenericFunction> epsilon1, std::shared_ptr<const dolfin::GenericFunction> epsilon2, std::shared_ptr<const dolfin::GenericFunction> alpha5, std::shared_ptr<const dolfin::GenericFunction> k1, std::shared_ptr<const dolfin::GenericFunction> k2, std::shared_ptr<const dolfin::GenericFunction> beta1, std::shared_ptr<const dolfin::GenericFunction> eta1, std::shared_ptr<const dolfin::GenericFunction> delta1, std::shared_ptr<const dolfin::GenericFunction> delta2): dolfin::Form(2, 13), u(*this, 0), vec1(*this, 1), vec2(*this, 2), c1(*this, 3), epsilon1(*this, 4), epsilon2(*this, 5), alpha5(*this, 6), k1(*this, 7), k2(*this, 8), beta1(*this, 9), eta1(*this, 10), delta1(*this, 11), delta2(*this, 12) { _function_spaces[0] = V0; _function_spaces[1] = V1; this->u = u; this->vec1 = vec1; this->vec2 = vec2; this->c1 = c1; this->epsilon1 = epsilon1; this->epsilon2 = epsilon2; this->alpha5 = alpha5; this->k1 = k1; this->k2 = k2; this->beta1 = beta1; this->eta1 = eta1; this->delta1 = delta1; this->delta2 = delta2; _ufc_form = std::make_shared<const hyperelasticityb_form_1>(); } // Destructor ~Form_Jac() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { if (name == "u") return 0; else if (name == "vec1") return 1; else if (name == "vec2") return 2; else if (name == "c1") return 3; else if (name == "epsilon1") return 4; else if (name == "epsilon2") return 5; else if (name == "alpha5") return 6; else if (name == "k1") return 7; else if (name == "k2") return 8; else if (name == "beta1") return 9; else if (name == "eta1") return 10; else if (name == "delta1") return 11; else if (name == "delta2") return 12; dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { switch (i) { case 0: return "u"; case 1: return "vec1"; case 2: return "vec2"; case 3: return "c1"; case 4: return "epsilon1"; case 5: return "epsilon2"; case 6: return "alpha5"; case 7: return "k1"; case 8: return "k2"; case 9: return "beta1"; case 10: return "eta1"; case 11: return "delta1"; case 12: return "delta2"; } dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return "unnamed"; } // Typedefs typedef Form_Jac_FunctionSpace_0 TestSpace; typedef Form_Jac_FunctionSpace_1 TrialSpace; typedef Form_Jac_MultiMeshFunctionSpace_0 MultiMeshTestSpace; typedef Form_Jac_MultiMeshFunctionSpace_1 MultiMeshTrialSpace; typedef Form_Jac_FunctionSpace_2 CoefficientSpace_u; typedef Form_Jac_FunctionSpace_3 CoefficientSpace_vec1; typedef Form_Jac_FunctionSpace_4 CoefficientSpace_vec2; typedef Form_Jac_FunctionSpace_5 CoefficientSpace_c1; typedef Form_Jac_FunctionSpace_6 CoefficientSpace_epsilon1; typedef Form_Jac_FunctionSpace_7 CoefficientSpace_epsilon2; typedef Form_Jac_FunctionSpace_8 CoefficientSpace_alpha5; typedef Form_Jac_FunctionSpace_9 CoefficientSpace_k1; typedef Form_Jac_FunctionSpace_10 CoefficientSpace_k2; typedef Form_Jac_FunctionSpace_11 CoefficientSpace_beta1; typedef Form_Jac_FunctionSpace_12 CoefficientSpace_eta1; typedef Form_Jac_FunctionSpace_13 CoefficientSpace_delta1; typedef Form_Jac_FunctionSpace_14 CoefficientSpace_delta2; // Coefficients dolfin::CoefficientAssigner u; dolfin::CoefficientAssigner vec1; dolfin::CoefficientAssigner vec2; dolfin::CoefficientAssigner c1; dolfin::CoefficientAssigner epsilon1; dolfin::CoefficientAssigner epsilon2; dolfin::CoefficientAssigner alpha5; dolfin::CoefficientAssigner k1; dolfin::CoefficientAssigner k2; dolfin::CoefficientAssigner beta1; dolfin::CoefficientAssigner eta1; dolfin::CoefficientAssigner delta1; dolfin::CoefficientAssigner delta2; }; class MultiMeshForm_Jac: public dolfin::MultiMeshForm { public: // Constructor MultiMeshForm_Jac(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V1, std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0): dolfin::MultiMeshForm(V1, V0), u(*this, 0), vec1(*this, 1), vec2(*this, 2), c1(*this, 3), epsilon1(*this, 4), epsilon2(*this, 5), alpha5(*this, 6), k1(*this, 7), k2(*this, 8), beta1(*this, 9), eta1(*this, 10), delta1(*this, 11), delta2(*this, 12) { // Create and add standard forms std::size_t num_parts = V0->num_parts(); // assume all equal and pick first for (std::size_t part = 0; part < num_parts; part++) { std::shared_ptr<dolfin::Form> a(new Form_Jac(V1->part(part), V0->part(part))); add(a); } // Build multimesh form build(); /// Assign coefficients } // Constructor MultiMeshForm_Jac(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V1, std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0, std::shared_ptr<const dolfin::GenericFunction> u, std::shared_ptr<const dolfin::GenericFunction> vec1, std::shared_ptr<const dolfin::GenericFunction> vec2, std::shared_ptr<const dolfin::GenericFunction> c1, std::shared_ptr<const dolfin::GenericFunction> epsilon1, std::shared_ptr<const dolfin::GenericFunction> epsilon2, std::shared_ptr<const dolfin::GenericFunction> alpha5, std::shared_ptr<const dolfin::GenericFunction> k1, std::shared_ptr<const dolfin::GenericFunction> k2, std::shared_ptr<const dolfin::GenericFunction> beta1, std::shared_ptr<const dolfin::GenericFunction> eta1, std::shared_ptr<const dolfin::GenericFunction> delta1, std::shared_ptr<const dolfin::GenericFunction> delta2): dolfin::MultiMeshForm(V1, V0), u(*this, 0), vec1(*this, 1), vec2(*this, 2), c1(*this, 3), epsilon1(*this, 4), epsilon2(*this, 5), alpha5(*this, 6), k1(*this, 7), k2(*this, 8), beta1(*this, 9), eta1(*this, 10), delta1(*this, 11), delta2(*this, 12) { // Create and add standard forms std::size_t num_parts = V0->num_parts(); // assume all equal and pick first for (std::size_t part = 0; part < num_parts; part++) { std::shared_ptr<dolfin::Form> a(new Form_Jac(V1->part(part), V0->part(part))); add(a); } // Build multimesh form build(); /// Assign coefficients this->u = u; this->vec1 = vec1; this->vec2 = vec2; this->c1 = c1; this->epsilon1 = epsilon1; this->epsilon2 = epsilon2; this->alpha5 = alpha5; this->k1 = k1; this->k2 = k2; this->beta1 = beta1; this->eta1 = eta1; this->delta1 = delta1; this->delta2 = delta2; } // Destructor ~MultiMeshForm_Jac() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { if (name == "u") return 0; else if (name == "vec1") return 1; else if (name == "vec2") return 2; else if (name == "c1") return 3; else if (name == "epsilon1") return 4; else if (name == "epsilon2") return 5; else if (name == "alpha5") return 6; else if (name == "k1") return 7; else if (name == "k2") return 8; else if (name == "beta1") return 9; else if (name == "eta1") return 10; else if (name == "delta1") return 11; else if (name == "delta2") return 12; dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { switch (i) { case 0: return "u"; case 1: return "vec1"; case 2: return "vec2"; case 3: return "c1"; case 4: return "epsilon1"; case 5: return "epsilon2"; case 6: return "alpha5"; case 7: return "k1"; case 8: return "k2"; case 9: return "beta1"; case 10: return "eta1"; case 11: return "delta1"; case 12: return "delta2"; } dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return "unnamed"; } // Typedefs typedef Form_Jac_FunctionSpace_0 TestSpace; typedef Form_Jac_FunctionSpace_1 TrialSpace; typedef Form_Jac_MultiMeshFunctionSpace_0 MultiMeshTestSpace; typedef Form_Jac_MultiMeshFunctionSpace_1 MultiMeshTrialSpace; typedef Form_Jac_FunctionSpace_2 CoefficientSpace_u; typedef Form_Jac_FunctionSpace_3 CoefficientSpace_vec1; typedef Form_Jac_FunctionSpace_4 CoefficientSpace_vec2; typedef Form_Jac_FunctionSpace_5 CoefficientSpace_c1; typedef Form_Jac_FunctionSpace_6 CoefficientSpace_epsilon1; typedef Form_Jac_FunctionSpace_7 CoefficientSpace_epsilon2; typedef Form_Jac_FunctionSpace_8 CoefficientSpace_alpha5; typedef Form_Jac_FunctionSpace_9 CoefficientSpace_k1; typedef Form_Jac_FunctionSpace_10 CoefficientSpace_k2; typedef Form_Jac_FunctionSpace_11 CoefficientSpace_beta1; typedef Form_Jac_FunctionSpace_12 CoefficientSpace_eta1; typedef Form_Jac_FunctionSpace_13 CoefficientSpace_delta1; typedef Form_Jac_FunctionSpace_14 CoefficientSpace_delta2; // Coefficients dolfin::MultiMeshCoefficientAssigner u; dolfin::MultiMeshCoefficientAssigner vec1; dolfin::MultiMeshCoefficientAssigner vec2; dolfin::MultiMeshCoefficientAssigner c1; dolfin::MultiMeshCoefficientAssigner epsilon1; dolfin::MultiMeshCoefficientAssigner epsilon2; dolfin::MultiMeshCoefficientAssigner alpha5; dolfin::MultiMeshCoefficientAssigner k1; dolfin::MultiMeshCoefficientAssigner k2; dolfin::MultiMeshCoefficientAssigner beta1; dolfin::MultiMeshCoefficientAssigner eta1; dolfin::MultiMeshCoefficientAssigner delta1; dolfin::MultiMeshCoefficientAssigner delta2; }; class Form_Res_FunctionSpace_0: public dolfin::FunctionSpace { public: // Constructor for standard function space Form_Res_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_3>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_3>(), *mesh)) { // Do nothing } // Constructor for constrained function space Form_Res_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_3>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_3>(), *mesh, constrained_domain)) { // Do nothing } }; class Form_Res_MultiMeshFunctionSpace_0: public dolfin::MultiMeshFunctionSpace { public: // Constructor for multimesh function space Form_Res_MultiMeshFunctionSpace_0(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh) { // Create and add standard function spaces for (std::size_t part = 0; part < multimesh->num_parts(); part++) { std::shared_ptr<const dolfin::FunctionSpace> V(new Form_Res_FunctionSpace_0(multimesh->part(part))); add(V); } // Build multimesh function space build(); } }; typedef CoefficientSpace_u Form_Res_FunctionSpace_1; typedef CoefficientSpace_B Form_Res_FunctionSpace_2; typedef CoefficientSpace_vec1 Form_Res_FunctionSpace_3; typedef CoefficientSpace_vec2 Form_Res_FunctionSpace_4; typedef CoefficientSpace_c1 Form_Res_FunctionSpace_5; typedef CoefficientSpace_epsilon1 Form_Res_FunctionSpace_6; typedef CoefficientSpace_epsilon2 Form_Res_FunctionSpace_7; typedef CoefficientSpace_alpha5 Form_Res_FunctionSpace_8; typedef CoefficientSpace_k1 Form_Res_FunctionSpace_9; typedef CoefficientSpace_k2 Form_Res_FunctionSpace_10; typedef CoefficientSpace_beta1 Form_Res_FunctionSpace_11; typedef CoefficientSpace_eta1 Form_Res_FunctionSpace_12; typedef CoefficientSpace_delta1 Form_Res_FunctionSpace_13; typedef CoefficientSpace_delta2 Form_Res_FunctionSpace_14; typedef CoefficientSpace_pressure Form_Res_FunctionSpace_15; class Form_Res: public dolfin::Form { public: // Constructor Form_Res(std::shared_ptr<const dolfin::FunctionSpace> V0): dolfin::Form(1, 15), u(*this, 0), B(*this, 1), vec1(*this, 2), vec2(*this, 3), c1(*this, 4), epsilon1(*this, 5), epsilon2(*this, 6), alpha5(*this, 7), k1(*this, 8), k2(*this, 9), beta1(*this, 10), eta1(*this, 11), delta1(*this, 12), delta2(*this, 13), pressure(*this, 14) { _function_spaces[0] = V0; _ufc_form = std::make_shared<const hyperelasticityb_form_2>(); } // Constructor Form_Res(std::shared_ptr<const dolfin::FunctionSpace> V0, std::shared_ptr<const dolfin::GenericFunction> u, std::shared_ptr<const dolfin::GenericFunction> B, std::shared_ptr<const dolfin::GenericFunction> vec1, std::shared_ptr<const dolfin::GenericFunction> vec2, std::shared_ptr<const dolfin::GenericFunction> c1, std::shared_ptr<const dolfin::GenericFunction> epsilon1, std::shared_ptr<const dolfin::GenericFunction> epsilon2, std::shared_ptr<const dolfin::GenericFunction> alpha5, std::shared_ptr<const dolfin::GenericFunction> k1, std::shared_ptr<const dolfin::GenericFunction> k2, std::shared_ptr<const dolfin::GenericFunction> beta1, std::shared_ptr<const dolfin::GenericFunction> eta1, std::shared_ptr<const dolfin::GenericFunction> delta1, std::shared_ptr<const dolfin::GenericFunction> delta2, std::shared_ptr<const dolfin::GenericFunction> pressure): dolfin::Form(1, 15), u(*this, 0), B(*this, 1), vec1(*this, 2), vec2(*this, 3), c1(*this, 4), epsilon1(*this, 5), epsilon2(*this, 6), alpha5(*this, 7), k1(*this, 8), k2(*this, 9), beta1(*this, 10), eta1(*this, 11), delta1(*this, 12), delta2(*this, 13), pressure(*this, 14) { _function_spaces[0] = V0; this->u = u; this->B = B; this->vec1 = vec1; this->vec2 = vec2; this->c1 = c1; this->epsilon1 = epsilon1; this->epsilon2 = epsilon2; this->alpha5 = alpha5; this->k1 = k1; this->k2 = k2; this->beta1 = beta1; this->eta1 = eta1; this->delta1 = delta1; this->delta2 = delta2; this->pressure = pressure; _ufc_form = std::make_shared<const hyperelasticityb_form_2>(); } // Destructor ~Form_Res() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { if (name == "u") return 0; else if (name == "B") return 1; else if (name == "vec1") return 2; else if (name == "vec2") return 3; else if (name == "c1") return 4; else if (name == "epsilon1") return 5; else if (name == "epsilon2") return 6; else if (name == "alpha5") return 7; else if (name == "k1") return 8; else if (name == "k2") return 9; else if (name == "beta1") return 10; else if (name == "eta1") return 11; else if (name == "delta1") return 12; else if (name == "delta2") return 13; else if (name == "pressure") return 14; dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { switch (i) { case 0: return "u"; case 1: return "B"; case 2: return "vec1"; case 3: return "vec2"; case 4: return "c1"; case 5: return "epsilon1"; case 6: return "epsilon2"; case 7: return "alpha5"; case 8: return "k1"; case 9: return "k2"; case 10: return "beta1"; case 11: return "eta1"; case 12: return "delta1"; case 13: return "delta2"; case 14: return "pressure"; } dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return "unnamed"; } // Typedefs typedef Form_Res_FunctionSpace_0 TestSpace; typedef Form_Res_MultiMeshFunctionSpace_0 MultiMeshTestSpace; typedef Form_Res_FunctionSpace_1 CoefficientSpace_u; typedef Form_Res_FunctionSpace_2 CoefficientSpace_B; typedef Form_Res_FunctionSpace_3 CoefficientSpace_vec1; typedef Form_Res_FunctionSpace_4 CoefficientSpace_vec2; typedef Form_Res_FunctionSpace_5 CoefficientSpace_c1; typedef Form_Res_FunctionSpace_6 CoefficientSpace_epsilon1; typedef Form_Res_FunctionSpace_7 CoefficientSpace_epsilon2; typedef Form_Res_FunctionSpace_8 CoefficientSpace_alpha5; typedef Form_Res_FunctionSpace_9 CoefficientSpace_k1; typedef Form_Res_FunctionSpace_10 CoefficientSpace_k2; typedef Form_Res_FunctionSpace_11 CoefficientSpace_beta1; typedef Form_Res_FunctionSpace_12 CoefficientSpace_eta1; typedef Form_Res_FunctionSpace_13 CoefficientSpace_delta1; typedef Form_Res_FunctionSpace_14 CoefficientSpace_delta2; typedef Form_Res_FunctionSpace_15 CoefficientSpace_pressure; // Coefficients dolfin::CoefficientAssigner u; dolfin::CoefficientAssigner B; dolfin::CoefficientAssigner vec1; dolfin::CoefficientAssigner vec2; dolfin::CoefficientAssigner c1; dolfin::CoefficientAssigner epsilon1; dolfin::CoefficientAssigner epsilon2; dolfin::CoefficientAssigner alpha5; dolfin::CoefficientAssigner k1; dolfin::CoefficientAssigner k2; dolfin::CoefficientAssigner beta1; dolfin::CoefficientAssigner eta1; dolfin::CoefficientAssigner delta1; dolfin::CoefficientAssigner delta2; dolfin::CoefficientAssigner pressure; }; class MultiMeshForm_Res: public dolfin::MultiMeshForm { public: // Constructor MultiMeshForm_Res(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0): dolfin::MultiMeshForm(V0), u(*this, 0), B(*this, 1), vec1(*this, 2), vec2(*this, 3), c1(*this, 4), epsilon1(*this, 5), epsilon2(*this, 6), alpha5(*this, 7), k1(*this, 8), k2(*this, 9), beta1(*this, 10), eta1(*this, 11), delta1(*this, 12), delta2(*this, 13), pressure(*this, 14) { // Create and add standard forms std::size_t num_parts = V0->num_parts(); // assume all equal and pick first for (std::size_t part = 0; part < num_parts; part++) { std::shared_ptr<dolfin::Form> a(new Form_Res(V0->part(part))); add(a); } // Build multimesh form build(); /// Assign coefficients } // Constructor MultiMeshForm_Res(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0, std::shared_ptr<const dolfin::GenericFunction> u, std::shared_ptr<const dolfin::GenericFunction> B, std::shared_ptr<const dolfin::GenericFunction> vec1, std::shared_ptr<const dolfin::GenericFunction> vec2, std::shared_ptr<const dolfin::GenericFunction> c1, std::shared_ptr<const dolfin::GenericFunction> epsilon1, std::shared_ptr<const dolfin::GenericFunction> epsilon2, std::shared_ptr<const dolfin::GenericFunction> alpha5, std::shared_ptr<const dolfin::GenericFunction> k1, std::shared_ptr<const dolfin::GenericFunction> k2, std::shared_ptr<const dolfin::GenericFunction> beta1, std::shared_ptr<const dolfin::GenericFunction> eta1, std::shared_ptr<const dolfin::GenericFunction> delta1, std::shared_ptr<const dolfin::GenericFunction> delta2, std::shared_ptr<const dolfin::GenericFunction> pressure): dolfin::MultiMeshForm(V0), u(*this, 0), B(*this, 1), vec1(*this, 2), vec2(*this, 3), c1(*this, 4), epsilon1(*this, 5), epsilon2(*this, 6), alpha5(*this, 7), k1(*this, 8), k2(*this, 9), beta1(*this, 10), eta1(*this, 11), delta1(*this, 12), delta2(*this, 13), pressure(*this, 14) { // Create and add standard forms std::size_t num_parts = V0->num_parts(); // assume all equal and pick first for (std::size_t part = 0; part < num_parts; part++) { std::shared_ptr<dolfin::Form> a(new Form_Res(V0->part(part))); add(a); } // Build multimesh form build(); /// Assign coefficients this->u = u; this->B = B; this->vec1 = vec1; this->vec2 = vec2; this->c1 = c1; this->epsilon1 = epsilon1; this->epsilon2 = epsilon2; this->alpha5 = alpha5; this->k1 = k1; this->k2 = k2; this->beta1 = beta1; this->eta1 = eta1; this->delta1 = delta1; this->delta2 = delta2; this->pressure = pressure; } // Destructor ~MultiMeshForm_Res() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { if (name == "u") return 0; else if (name == "B") return 1; else if (name == "vec1") return 2; else if (name == "vec2") return 3; else if (name == "c1") return 4; else if (name == "epsilon1") return 5; else if (name == "epsilon2") return 6; else if (name == "alpha5") return 7; else if (name == "k1") return 8; else if (name == "k2") return 9; else if (name == "beta1") return 10; else if (name == "eta1") return 11; else if (name == "delta1") return 12; else if (name == "delta2") return 13; else if (name == "pressure") return 14; dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { switch (i) { case 0: return "u"; case 1: return "B"; case 2: return "vec1"; case 3: return "vec2"; case 4: return "c1"; case 5: return "epsilon1"; case 6: return "epsilon2"; case 7: return "alpha5"; case 8: return "k1"; case 9: return "k2"; case 10: return "beta1"; case 11: return "eta1"; case 12: return "delta1"; case 13: return "delta2"; case 14: return "pressure"; } dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return "unnamed"; } // Typedefs typedef Form_Res_FunctionSpace_0 TestSpace; typedef Form_Res_MultiMeshFunctionSpace_0 MultiMeshTestSpace; typedef Form_Res_FunctionSpace_1 CoefficientSpace_u; typedef Form_Res_FunctionSpace_2 CoefficientSpace_B; typedef Form_Res_FunctionSpace_3 CoefficientSpace_vec1; typedef Form_Res_FunctionSpace_4 CoefficientSpace_vec2; typedef Form_Res_FunctionSpace_5 CoefficientSpace_c1; typedef Form_Res_FunctionSpace_6 CoefficientSpace_epsilon1; typedef Form_Res_FunctionSpace_7 CoefficientSpace_epsilon2; typedef Form_Res_FunctionSpace_8 CoefficientSpace_alpha5; typedef Form_Res_FunctionSpace_9 CoefficientSpace_k1; typedef Form_Res_FunctionSpace_10 CoefficientSpace_k2; typedef Form_Res_FunctionSpace_11 CoefficientSpace_beta1; typedef Form_Res_FunctionSpace_12 CoefficientSpace_eta1; typedef Form_Res_FunctionSpace_13 CoefficientSpace_delta1; typedef Form_Res_FunctionSpace_14 CoefficientSpace_delta2; typedef Form_Res_FunctionSpace_15 CoefficientSpace_pressure; // Coefficients dolfin::MultiMeshCoefficientAssigner u; dolfin::MultiMeshCoefficientAssigner B; dolfin::MultiMeshCoefficientAssigner vec1; dolfin::MultiMeshCoefficientAssigner vec2; dolfin::MultiMeshCoefficientAssigner c1; dolfin::MultiMeshCoefficientAssigner epsilon1; dolfin::MultiMeshCoefficientAssigner epsilon2; dolfin::MultiMeshCoefficientAssigner alpha5; dolfin::MultiMeshCoefficientAssigner k1; dolfin::MultiMeshCoefficientAssigner k2; dolfin::MultiMeshCoefficientAssigner beta1; dolfin::MultiMeshCoefficientAssigner eta1; dolfin::MultiMeshCoefficientAssigner delta1; dolfin::MultiMeshCoefficientAssigner delta2; dolfin::MultiMeshCoefficientAssigner pressure; }; class Form_Mass_vms_FunctionSpace_0: public dolfin::FunctionSpace { public: // Constructor for standard function space Form_Mass_vms_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_6>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_6>(), *mesh)) { // Do nothing } // Constructor for constrained function space Form_Mass_vms_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_6>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_6>(), *mesh, constrained_domain)) { // Do nothing } }; class Form_Mass_vms_FunctionSpace_1: public dolfin::FunctionSpace { public: // Constructor for standard function space Form_Mass_vms_FunctionSpace_1(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_6>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_6>(), *mesh)) { // Do nothing } // Constructor for constrained function space Form_Mass_vms_FunctionSpace_1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_6>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_6>(), *mesh, constrained_domain)) { // Do nothing } }; class Form_Mass_vms_MultiMeshFunctionSpace_0: public dolfin::MultiMeshFunctionSpace { public: // Constructor for multimesh function space Form_Mass_vms_MultiMeshFunctionSpace_0(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh) { // Create and add standard function spaces for (std::size_t part = 0; part < multimesh->num_parts(); part++) { std::shared_ptr<const dolfin::FunctionSpace> V(new Form_Mass_vms_FunctionSpace_0(multimesh->part(part))); add(V); } // Build multimesh function space build(); } }; class Form_Mass_vms_MultiMeshFunctionSpace_1: public dolfin::MultiMeshFunctionSpace { public: // Constructor for multimesh function space Form_Mass_vms_MultiMeshFunctionSpace_1(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh) { // Create and add standard function spaces for (std::size_t part = 0; part < multimesh->num_parts(); part++) { std::shared_ptr<const dolfin::FunctionSpace> V(new Form_Mass_vms_FunctionSpace_1(multimesh->part(part))); add(V); } // Build multimesh function space build(); } }; class Form_Mass_vms: public dolfin::Form { public: // Constructor Form_Mass_vms(std::shared_ptr<const dolfin::FunctionSpace> V1, std::shared_ptr<const dolfin::FunctionSpace> V0): dolfin::Form(2, 0) { _function_spaces[0] = V0; _function_spaces[1] = V1; _ufc_form = std::make_shared<const hyperelasticityb_form_3>(); } // Destructor ~Form_Mass_vms() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { dolfin::dolfin_error("generated code for class Form", "access coefficient data", "There are no coefficients"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { dolfin::dolfin_error("generated code for class Form", "access coefficient data", "There are no coefficients"); return "unnamed"; } // Typedefs typedef Form_Mass_vms_FunctionSpace_0 TestSpace; typedef Form_Mass_vms_FunctionSpace_1 TrialSpace; typedef Form_Mass_vms_MultiMeshFunctionSpace_0 MultiMeshTestSpace; typedef Form_Mass_vms_MultiMeshFunctionSpace_1 MultiMeshTrialSpace; // Coefficients }; class MultiMeshForm_Mass_vms: public dolfin::MultiMeshForm { public: // Constructor MultiMeshForm_Mass_vms(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V1, std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0): dolfin::MultiMeshForm(V1, V0) { // Create and add standard forms std::size_t num_parts = V0->num_parts(); // assume all equal and pick first for (std::size_t part = 0; part < num_parts; part++) { std::shared_ptr<dolfin::Form> a(new Form_Mass_vms(V1->part(part), V0->part(part))); add(a); } // Build multimesh form build(); /// Assign coefficients } // Destructor ~MultiMeshForm_Mass_vms() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { dolfin::dolfin_error("generated code for class Form", "access coefficient data", "There are no coefficients"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { dolfin::dolfin_error("generated code for class Form", "access coefficient data", "There are no coefficients"); return "unnamed"; } // Typedefs typedef Form_Mass_vms_FunctionSpace_0 TestSpace; typedef Form_Mass_vms_FunctionSpace_1 TrialSpace; typedef Form_Mass_vms_MultiMeshFunctionSpace_0 MultiMeshTestSpace; typedef Form_Mass_vms_MultiMeshFunctionSpace_1 MultiMeshTrialSpace; // Coefficients }; class Form_L_vms_FunctionSpace_0: public dolfin::FunctionSpace { public: // Constructor for standard function space Form_L_vms_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_6>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_6>(), *mesh)) { // Do nothing } // Constructor for constrained function space Form_L_vms_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain): dolfin::FunctionSpace(mesh, std::make_shared<const dolfin::FiniteElement>(std::make_shared<hyperelasticityb_finite_element_6>()), std::make_shared<const dolfin::DofMap>(std::make_shared<hyperelasticityb_dofmap_6>(), *mesh, constrained_domain)) { // Do nothing } }; class Form_L_vms_MultiMeshFunctionSpace_0: public dolfin::MultiMeshFunctionSpace { public: // Constructor for multimesh function space Form_L_vms_MultiMeshFunctionSpace_0(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh) { // Create and add standard function spaces for (std::size_t part = 0; part < multimesh->num_parts(); part++) { std::shared_ptr<const dolfin::FunctionSpace> V(new Form_L_vms_FunctionSpace_0(multimesh->part(part))); add(V); } // Build multimesh function space build(); } }; typedef CoefficientSpace_u Form_L_vms_FunctionSpace_1; typedef CoefficientSpace_vec1 Form_L_vms_FunctionSpace_2; typedef CoefficientSpace_vec2 Form_L_vms_FunctionSpace_3; typedef CoefficientSpace_c1 Form_L_vms_FunctionSpace_4; typedef CoefficientSpace_epsilon1 Form_L_vms_FunctionSpace_5; typedef CoefficientSpace_epsilon2 Form_L_vms_FunctionSpace_6; typedef CoefficientSpace_alpha5 Form_L_vms_FunctionSpace_7; typedef CoefficientSpace_k1 Form_L_vms_FunctionSpace_8; typedef CoefficientSpace_k2 Form_L_vms_FunctionSpace_9; typedef CoefficientSpace_beta1 Form_L_vms_FunctionSpace_10; typedef CoefficientSpace_eta1 Form_L_vms_FunctionSpace_11; typedef CoefficientSpace_delta1 Form_L_vms_FunctionSpace_12; typedef CoefficientSpace_delta2 Form_L_vms_FunctionSpace_13; class Form_L_vms: public dolfin::Form { public: // Constructor Form_L_vms(std::shared_ptr<const dolfin::FunctionSpace> V0): dolfin::Form(1, 13), u(*this, 0), vec1(*this, 1), vec2(*this, 2), c1(*this, 3), epsilon1(*this, 4), epsilon2(*this, 5), alpha5(*this, 6), k1(*this, 7), k2(*this, 8), beta1(*this, 9), eta1(*this, 10), delta1(*this, 11), delta2(*this, 12) { _function_spaces[0] = V0; _ufc_form = std::make_shared<const hyperelasticityb_form_4>(); } // Constructor Form_L_vms(std::shared_ptr<const dolfin::FunctionSpace> V0, std::shared_ptr<const dolfin::GenericFunction> u, std::shared_ptr<const dolfin::GenericFunction> vec1, std::shared_ptr<const dolfin::GenericFunction> vec2, std::shared_ptr<const dolfin::GenericFunction> c1, std::shared_ptr<const dolfin::GenericFunction> epsilon1, std::shared_ptr<const dolfin::GenericFunction> epsilon2, std::shared_ptr<const dolfin::GenericFunction> alpha5, std::shared_ptr<const dolfin::GenericFunction> k1, std::shared_ptr<const dolfin::GenericFunction> k2, std::shared_ptr<const dolfin::GenericFunction> beta1, std::shared_ptr<const dolfin::GenericFunction> eta1, std::shared_ptr<const dolfin::GenericFunction> delta1, std::shared_ptr<const dolfin::GenericFunction> delta2): dolfin::Form(1, 13), u(*this, 0), vec1(*this, 1), vec2(*this, 2), c1(*this, 3), epsilon1(*this, 4), epsilon2(*this, 5), alpha5(*this, 6), k1(*this, 7), k2(*this, 8), beta1(*this, 9), eta1(*this, 10), delta1(*this, 11), delta2(*this, 12) { _function_spaces[0] = V0; this->u = u; this->vec1 = vec1; this->vec2 = vec2; this->c1 = c1; this->epsilon1 = epsilon1; this->epsilon2 = epsilon2; this->alpha5 = alpha5; this->k1 = k1; this->k2 = k2; this->beta1 = beta1; this->eta1 = eta1; this->delta1 = delta1; this->delta2 = delta2; _ufc_form = std::make_shared<const hyperelasticityb_form_4>(); } // Destructor ~Form_L_vms() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { if (name == "u") return 0; else if (name == "vec1") return 1; else if (name == "vec2") return 2; else if (name == "c1") return 3; else if (name == "epsilon1") return 4; else if (name == "epsilon2") return 5; else if (name == "alpha5") return 6; else if (name == "k1") return 7; else if (name == "k2") return 8; else if (name == "beta1") return 9; else if (name == "eta1") return 10; else if (name == "delta1") return 11; else if (name == "delta2") return 12; dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { switch (i) { case 0: return "u"; case 1: return "vec1"; case 2: return "vec2"; case 3: return "c1"; case 4: return "epsilon1"; case 5: return "epsilon2"; case 6: return "alpha5"; case 7: return "k1"; case 8: return "k2"; case 9: return "beta1"; case 10: return "eta1"; case 11: return "delta1"; case 12: return "delta2"; } dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return "unnamed"; } // Typedefs typedef Form_L_vms_FunctionSpace_0 TestSpace; typedef Form_L_vms_MultiMeshFunctionSpace_0 MultiMeshTestSpace; typedef Form_L_vms_FunctionSpace_1 CoefficientSpace_u; typedef Form_L_vms_FunctionSpace_2 CoefficientSpace_vec1; typedef Form_L_vms_FunctionSpace_3 CoefficientSpace_vec2; typedef Form_L_vms_FunctionSpace_4 CoefficientSpace_c1; typedef Form_L_vms_FunctionSpace_5 CoefficientSpace_epsilon1; typedef Form_L_vms_FunctionSpace_6 CoefficientSpace_epsilon2; typedef Form_L_vms_FunctionSpace_7 CoefficientSpace_alpha5; typedef Form_L_vms_FunctionSpace_8 CoefficientSpace_k1; typedef Form_L_vms_FunctionSpace_9 CoefficientSpace_k2; typedef Form_L_vms_FunctionSpace_10 CoefficientSpace_beta1; typedef Form_L_vms_FunctionSpace_11 CoefficientSpace_eta1; typedef Form_L_vms_FunctionSpace_12 CoefficientSpace_delta1; typedef Form_L_vms_FunctionSpace_13 CoefficientSpace_delta2; // Coefficients dolfin::CoefficientAssigner u; dolfin::CoefficientAssigner vec1; dolfin::CoefficientAssigner vec2; dolfin::CoefficientAssigner c1; dolfin::CoefficientAssigner epsilon1; dolfin::CoefficientAssigner epsilon2; dolfin::CoefficientAssigner alpha5; dolfin::CoefficientAssigner k1; dolfin::CoefficientAssigner k2; dolfin::CoefficientAssigner beta1; dolfin::CoefficientAssigner eta1; dolfin::CoefficientAssigner delta1; dolfin::CoefficientAssigner delta2; }; class MultiMeshForm_L_vms: public dolfin::MultiMeshForm { public: // Constructor MultiMeshForm_L_vms(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0): dolfin::MultiMeshForm(V0), u(*this, 0), vec1(*this, 1), vec2(*this, 2), c1(*this, 3), epsilon1(*this, 4), epsilon2(*this, 5), alpha5(*this, 6), k1(*this, 7), k2(*this, 8), beta1(*this, 9), eta1(*this, 10), delta1(*this, 11), delta2(*this, 12) { // Create and add standard forms std::size_t num_parts = V0->num_parts(); // assume all equal and pick first for (std::size_t part = 0; part < num_parts; part++) { std::shared_ptr<dolfin::Form> a(new Form_L_vms(V0->part(part))); add(a); } // Build multimesh form build(); /// Assign coefficients } // Constructor MultiMeshForm_L_vms(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0, std::shared_ptr<const dolfin::GenericFunction> u, std::shared_ptr<const dolfin::GenericFunction> vec1, std::shared_ptr<const dolfin::GenericFunction> vec2, std::shared_ptr<const dolfin::GenericFunction> c1, std::shared_ptr<const dolfin::GenericFunction> epsilon1, std::shared_ptr<const dolfin::GenericFunction> epsilon2, std::shared_ptr<const dolfin::GenericFunction> alpha5, std::shared_ptr<const dolfin::GenericFunction> k1, std::shared_ptr<const dolfin::GenericFunction> k2, std::shared_ptr<const dolfin::GenericFunction> beta1, std::shared_ptr<const dolfin::GenericFunction> eta1, std::shared_ptr<const dolfin::GenericFunction> delta1, std::shared_ptr<const dolfin::GenericFunction> delta2): dolfin::MultiMeshForm(V0), u(*this, 0), vec1(*this, 1), vec2(*this, 2), c1(*this, 3), epsilon1(*this, 4), epsilon2(*this, 5), alpha5(*this, 6), k1(*this, 7), k2(*this, 8), beta1(*this, 9), eta1(*this, 10), delta1(*this, 11), delta2(*this, 12) { // Create and add standard forms std::size_t num_parts = V0->num_parts(); // assume all equal and pick first for (std::size_t part = 0; part < num_parts; part++) { std::shared_ptr<dolfin::Form> a(new Form_L_vms(V0->part(part))); add(a); } // Build multimesh form build(); /// Assign coefficients this->u = u; this->vec1 = vec1; this->vec2 = vec2; this->c1 = c1; this->epsilon1 = epsilon1; this->epsilon2 = epsilon2; this->alpha5 = alpha5; this->k1 = k1; this->k2 = k2; this->beta1 = beta1; this->eta1 = eta1; this->delta1 = delta1; this->delta2 = delta2; } // Destructor ~MultiMeshForm_L_vms() {} /// Return the number of the coefficient with this name virtual std::size_t coefficient_number(const std::string& name) const { if (name == "u") return 0; else if (name == "vec1") return 1; else if (name == "vec2") return 2; else if (name == "c1") return 3; else if (name == "epsilon1") return 4; else if (name == "epsilon2") return 5; else if (name == "alpha5") return 6; else if (name == "k1") return 7; else if (name == "k2") return 8; else if (name == "beta1") return 9; else if (name == "eta1") return 10; else if (name == "delta1") return 11; else if (name == "delta2") return 12; dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return 0; } /// Return the name of the coefficient with this number virtual std::string coefficient_name(std::size_t i) const { switch (i) { case 0: return "u"; case 1: return "vec1"; case 2: return "vec2"; case 3: return "c1"; case 4: return "epsilon1"; case 5: return "epsilon2"; case 6: return "alpha5"; case 7: return "k1"; case 8: return "k2"; case 9: return "beta1"; case 10: return "eta1"; case 11: return "delta1"; case 12: return "delta2"; } dolfin::dolfin_error("generated code for class Form", "access coefficient data", "Invalid coefficient"); return "unnamed"; } // Typedefs typedef Form_L_vms_FunctionSpace_0 TestSpace; typedef Form_L_vms_MultiMeshFunctionSpace_0 MultiMeshTestSpace; typedef Form_L_vms_FunctionSpace_1 CoefficientSpace_u; typedef Form_L_vms_FunctionSpace_2 CoefficientSpace_vec1; typedef Form_L_vms_FunctionSpace_3 CoefficientSpace_vec2; typedef Form_L_vms_FunctionSpace_4 CoefficientSpace_c1; typedef Form_L_vms_FunctionSpace_5 CoefficientSpace_epsilon1; typedef Form_L_vms_FunctionSpace_6 CoefficientSpace_epsilon2; typedef Form_L_vms_FunctionSpace_7 CoefficientSpace_alpha5; typedef Form_L_vms_FunctionSpace_8 CoefficientSpace_k1; typedef Form_L_vms_FunctionSpace_9 CoefficientSpace_k2; typedef Form_L_vms_FunctionSpace_10 CoefficientSpace_beta1; typedef Form_L_vms_FunctionSpace_11 CoefficientSpace_eta1; typedef Form_L_vms_FunctionSpace_12 CoefficientSpace_delta1; typedef Form_L_vms_FunctionSpace_13 CoefficientSpace_delta2; // Coefficients dolfin::MultiMeshCoefficientAssigner u; dolfin::MultiMeshCoefficientAssigner vec1; dolfin::MultiMeshCoefficientAssigner vec2; dolfin::MultiMeshCoefficientAssigner c1; dolfin::MultiMeshCoefficientAssigner epsilon1; dolfin::MultiMeshCoefficientAssigner epsilon2; dolfin::MultiMeshCoefficientAssigner alpha5; dolfin::MultiMeshCoefficientAssigner k1; dolfin::MultiMeshCoefficientAssigner k2; dolfin::MultiMeshCoefficientAssigner beta1; dolfin::MultiMeshCoefficientAssigner eta1; dolfin::MultiMeshCoefficientAssigner delta1; dolfin::MultiMeshCoefficientAssigner delta2; }; // Class typedefs typedef Form_Pi Functional; typedef MultiMeshForm_Pi MultiMeshFunctional; } #endif
[ "psywah@gmail.com" ]
psywah@gmail.com
851c8506ce2975f0438978bd28ee3170bdfffe6c
a8c0359a158771e6193cf1b094d498fe6c895e76
/Unidad 1/Clase Caras/Contorno.cpp
9e3db3611a79330b30be0f74ae0cda7f7423b478
[]
no_license
AdrianAlzamora/Programacion_II_2020-2
d0bdbd3e94542d50a1756f61227fe14f04442751
4bd56297eb41d61c77e115507b529e007da467b3
refs/heads/master
2022-12-24T13:47:58.731363
2020-10-10T15:50:54
2020-10-10T15:50:54
302,401,929
1
0
null
null
null
null
UTF-8
C++
false
false
1,024
cpp
#include "Contorno.h" Contorno::Contorno() { forma = (char)219; } Contorno::~Contorno() {} void Contorno::setX(int _x) { x = _x; } void Contorno::setY(int _y) { y = _y; } void Contorno::setL(int _l) { l = _l; } void Contorno::setColor(int _color) { color = _color; } int Contorno::getX() { return x; } int Contorno::getY() { return y; } int Contorno::getL() { return l; } int Contorno::getColor() { return color; } void Contorno::Draw() { if (color == 1) Console::ForegroundColor = ConsoleColor::Blue; if (color == 2) Console::ForegroundColor = ConsoleColor::Red; if (color == 3) Console::ForegroundColor = ConsoleColor::Green; if (color == 4) Console::ForegroundColor = ConsoleColor::Yellow; for (int i = 0; i < l; i++) { Console::SetCursorPosition(x , ((y - 5)+i)); cout << forma; } for (int i = 0; i < l; i++) { Console::SetCursorPosition(x+1+ i, y); cout << forma; } } void Contorno::Borrar() { for (int i = 0; i < l; i++) { Console::SetCursorPosition(x + i, y); cout << ' '; } }
[ "alzamoraadrian757@gmail.com" ]
alzamoraadrian757@gmail.com
390ef6b18a4b7a4c3b7c566592dabde6983bbab0
04ac85e0f7d8a047298900148645a45fedd13764
/c++/cha5/Train3.cpp
830bea62b0d49ed43b6268fcde1f3011804f0f63
[]
no_license
CodeTraning/summer
867b4a228137f1be8bb9dea7557039c2e6112686
3e2ea939db94024ecd4062d4c3b867c2983366d6
refs/heads/master
2020-06-19T22:42:09.303618
2019-10-29T08:16:47
2019-10-29T08:16:47
196,901,991
0
0
null
null
null
null
UTF-8
C++
false
false
492
cpp
#include <iostream> #include <string> using namespace std; int main() { do { cout << "请输入两个字符串:" << endl; string s1, s2; cin >> s1 >> s2; if (s1.size() < s2.size()) cout << "长度较小的字符串是:" << s1 << endl; else if (s1.size() > s2.size()) cout << "长度较小的字符串是:" << s2 << endl; else cout << "两个字符串等长" << endl; } while (cin); return 0; }
[ "2530515974@qq.com" ]
2530515974@qq.com
e627bdcaf16de0201015947fa9f8828d68eb1045
c03e353513c48679610e70da6034e7258cc065b2
/Lab8/Domain/Shopping.h
5cb089f59b79cfe02af40062aaf10faa7e7a5a87
[]
no_license
LauraDiosan-CS/lab04-Adrian-Vasiliu
a7afe25aa32536076ebfc01a8260794ac23a4d04
8fdc804cc020d943122d7a47298cc191e07027ce
refs/heads/master
2021-03-25T13:50:00.204889
2020-04-13T06:51:15
2020-04-13T06:51:15
247,624,332
0
0
null
2020-03-16T06:08:45
2020-03-16T06:08:40
null
UTF-8
C++
false
false
445
h
#pragma once #include <iostream> #include "Order.h" using namespace std; class Shopping : public Order{ public: Shopping(); Shopping(const string &, const string &, const list<string> &, int); Shopping &operator=(const Shopping &); bool operator==(const Shopping &); bool operator<(const Shopping &); friend ostream &operator<<(ostream &os, const Shopping &s); friend istream &operator>>(istream &, Shopping &); };
[ "adrian.vasiliu.s@gmail.com" ]
adrian.vasiliu.s@gmail.com
6ab7b048cb35ab0bc0c7c7d923dcf1a51873bd9a
d9f0884408b993db4326560dda83a6482caf861e
/11382_Little_Jungmin/main.cpp
c55382502d35a53d84600424964aa34d8509293e
[]
no_license
skysaver00/C-Algorithm-2021
9feb0b9f73ac47f960d48e5e60db5e6a35e320e7
10e6f61b7c213a92ef5eecb43b1046ce3b2a277f
refs/heads/master
2023-09-03T00:17:08.755999
2021-11-11T08:18:41
2021-11-11T08:18:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
143
cpp
#include <iostream> int main() { long long a, b, c; std::cin >> a >> b >> c; std::cout << a + b + c << std::endl; return 0; }
[ "skysaver00@naver.com" ]
skysaver00@naver.com
7923c10945c0c4f98b119bee6023a4374ab94d36
0b7fd0e1314d442780395068305b511cf3f6d7ca
/src/vertical3d/brep/Face.h
2be7ec209f5e9a677705e8c286085cacfb9508ba
[]
no_license
sigsegv42/v3dlibs
b1baa4b07df46d5168ed169b5ae95a5c4c693085
2fad4d38b1700442f0b15a6b8db200f1925dd1e9
refs/heads/master
2020-06-02T10:54:47.188214
2014-12-24T21:40:07
2014-12-24T21:40:07
1,419,110
0
0
null
null
null
null
UTF-8
C++
false
false
533
h
#ifndef INCLUDED_V3D_BREP_FACE #define INCLUDED_V3D_BREP_FACE #include "../3dtypes/Vector3.h" namespace v3D { class Face { public: Face(); Face(const Vector3 & normal, unsigned int edge); ~Face(); /* bool selected(void) const; void selected(bool sel); */ Vector3 normal(void) const; void normal(const Vector3 & n); unsigned int edge(void) const; void edge(unsigned int e); private: Vector3 normal_; unsigned int edge_; }; }; // end namespace v3D #endif // INCLUDED_V3D_BREP_FACE
[ "j.wgasa@gmail.com" ]
j.wgasa@gmail.com
c5f33e918c3e0467cdd1f9b92e594acf89274316
65e18b2ee5a81d92491c60cca2052c037a5d10dd
/Proj3/Graph.h
c44a2ca17d1e7cbaa72f0f5c7ede7b1182ddb6c3
[]
no_license
dawsboss/COSC320
c123ef2b563f52ed2a22ffe1313466a3c2a4c3bd
f5b9a864870fd977a1cff24db5bf886bc2291327
refs/heads/master
2023-02-22T07:23:00.512438
2021-01-26T00:29:29
2021-01-26T00:29:29
240,574,649
0
1
null
null
null
null
UTF-8
C++
false
false
4,650
h
#ifndef GRAPH_H #define GRAPH_H #include <iostream> #include <map>//stdmap #include <vector>//std::vector #include <queue>//std::queue #include <algorithm>//std::sort #include <fstream>//read in File template<class T> class Graph{ private: bool dir=true;//T == Dirrected | F == UnDirrected bool DFSneeded=false;//If DFS saved it correct or not True == needs update/ False == all good int time1 = 0;//change time to vector if want more than 2 CPU TODO int time2 = 0;//driver int time;//BFS and DFS bool Acyclic=true; bool DAG; enum color_t{ WHITE, GREY, BLACK }; struct VertexStuff{ int id; //the index it is held at in the map T data; //data given to us by the user double cost; //cost in time give from user std::vector<int> vertices; //where this node points out ot list std::vector<int> verticesParent; //what points at this node list color_t color;//DFS: color for current node color_t colorBFS;//BFS: color for cuurent node / Probabily could just be color instead of a new variable... int distanceBFS=-1;//BFS: distance form start node int P;//used as parent index place holder for BFs and DFS int start;//DFS: holds time when started in DFS algorithm int finish;//DFS: holdstime when finished in DFS algorithm int tLevel; int bLevel; int ALAPLevel; bool isChecked=false;//Used to check to see if a node has already been added to the jobs map bool done=false;//Checks to see if a node has been scedueled already VertexStuff(T d, double c, int i){//constructor for new edges id = i; data = d; cost = c; vertices = std::vector<int>(); verticesParent = std::vector<int>(); color = WHITE; colorBFS=WHITE; P=-1; tLevel = 0; bLevel = 0; } VertexStuff(){//Needed for map RB_tree } }; struct CPUStruct{ int start=0; int finish=0; int IDdone=-1;// Holds the index to the node that this CPU/struct did CPUStruct(){//Needed for rbtree finish=0; start=0; IDdone=-1; } CPUStruct(int s, int f, int i){ start=s; finish=f; IDdone=i; } }; int ID = 1;//ID couinter that the add vertex uses int CP_Length; std::map<int, VertexStuff> v;//main map that holds all nodes with their meta data std::map<int,std::vector<int>> jobs;//Map of <BFSlevels, nodes in level> std::map<int, std::vector<CPUStruct>> CPUs;//List of every CPU and its jobs it will do at what times void PaddEdge(int,int);//Private addition of adding edge std::vector<std::pair<int, int>> reverseTopoSort(); // Returns a reverse topological ordering of the graph as a vector std::vector<std::pair<int, int>> topoSort(); // Returns a topological sort of the graph as a vector void computeTLevel(); // Computes the T level of the graph void computeBLevel(); // Computes the B level of the graph void computeALAP(); // Computes the As Late As Possible level of the graph int findMinTlvl(std::vector<int>);//Fins the smallest node tha tisn;t completed in a given vector/level std::vector<int>::iterator int NextCPU(); //Finds the next CPU that will finish the earliest // bool canBeDone(int);//Checks ot see if that all previous nodes to this have been done // int findMinTlvlV2(std::vector<int>, std::vector<int>);//This is for the driverV2 function. This will check both the current BFS level and the one below to see if there is something more efficient ot be doing public: void driver(int); // void driverV2(int); // void printAnaCPUV2(); void JobLevelBFS(); Graph();//This is the same as the Graph(bool) but it just doesn't init dir NOTE: This is extremely unsafe to use... if you do use it make sure you init bool dir void initDIR(bool);//This will init dir to give in bool Graph(bool);//T == Dirrected | F == UnDirrected void graphType(); std::vector<int> findStarts();//Finds all vertices that are starting points/dont have anything pointing to it, returns the index of all starts in a vector std::vector<int> findEnd(); //Finds the end of the jobs/where to stop, returns the index of all ends in a vector void addVertex(T,double); void addEdge(T,T); void print(); void DFS(); void DFS_Visit(int); void SCCDFS_Visit(int node); void SCC(); void printAnalytics(); // Prints the Analytics of the graph into a data table structure void printAnaCPU(); }; #include "Graph.cpp" #endif
[ "gdawson2018@gmail.com" ]
gdawson2018@gmail.com
f046d68284625b4d8fb87a452533c5391f098483
658e7b32e91c2a32c5fa0abd70d6f6c640a819aa
/d01/ex03/Zombie.class.cpp
eb7835ba1c6d2acb05c30bd10767c162f454cf2f
[]
no_license
Truphino/cpp
27b5adbbc61d23e8de2c87b686f6450ad18f0671
f22b72ca126d7a4e61fe958d55c2672d67780179
refs/heads/master
2021-01-22T19:09:40.181461
2018-04-25T09:33:16
2018-04-25T09:33:16
85,172,784
0
0
null
null
null
null
UTF-8
C++
false
false
2,272
cpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* zombie.class.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: trecomps <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/04/06 12:31:34 by trecomps #+# #+# */ /* Updated: 2018/04/06 15:16:33 by trecomps ### ########.fr */ /* */ /* ************************************************************************** */ #include "Zombie.class.hpp" const std::string Zombie::_name_table[5] = { "Eugene", "Abraham", "Roseta", "Paul", "Orphan" }; Zombie::Zombie(void) : _name(_name_table[rand() % 5]), _type("Walker") { //std::cout << "Default constructor called" << std::endl; return ; } Zombie::Zombie(std::string name, std::string type) : _name(name), _type(type) { //std::cout << "Parametric constructor called" << std::endl; return ; } Zombie::Zombie(Zombie const &src) { //std::cout << "Copy constructor called" << std::endl; *this = src; return ; } Zombie::~Zombie(void) { //std::cout << "Destructor called" << std::endl; std::cout << this->_name << " is dead, forever :(" << std::endl; return ; } std::string Zombie::get_name(void) const { return (this->_name); } std::string Zombie::get_type(void) const { return (this->_type); } Zombie &Zombie::operator=(Zombie const &rhs) { //std::cout << "Assignement operator called" << std::endl; if (this != &rhs) { this->_name = rhs.get_name(); this->_type = rhs.get_type(); } return (*this); } std::ostream &operator<<(std::ostream &o, Zombie const &i) { o << "Name :" << i.get_name(); return (o); } void Zombie::announce(void) const { std::cout << "<" << this->_name << " " << "(" << this->_type << ")" "> Braiiiinnnnnnsssss !!!" << std::endl; }
[ "trecomps@student.42.fr" ]
trecomps@student.42.fr
795da821defc44680c0496383c4ab4f641de938f
49c423b422f2e2feac785e7c9ac2aee31f3c9331
/object.cpp
a3ca9a5a72ac48d013cf14d0eb9e20b64c225c20
[]
no_license
avttrue/ogltest6
3399de9c4a35f0e22c7594543830326bbf984857
b0cd81855fef269f2e6c078c5431de217af41883
refs/heads/master
2020-06-10T19:06:42.953168
2019-06-25T13:44:51
2019-06-25T13:44:51
193,715,532
2
1
null
null
null
null
UTF-8
C++
false
false
3,411
cpp
#include "object.h" #include<QOpenGLTexture> #include<QOpenGLShaderProgram> #include<QOpenGLFunctions> Object::Object() : m_VertexBuffer(QOpenGLBuffer::VertexBuffer), // это значение по-умолчанию m_IndexBuffer(QOpenGLBuffer::IndexBuffer), m_Texture(nullptr) { m_Scale = 1.0f; } Object::Object(const QVector<VertexData> &vert, const QVector<GLuint> &ind, const QImage &img) : m_VertexBuffer(QOpenGLBuffer::VertexBuffer), // это значение по-умолчанию m_IndexBuffer(QOpenGLBuffer::IndexBuffer), m_Texture(nullptr) { m_Scale = 1.0f; init(vert, ind, img); } Object::~Object() { free(); } void Object::free() { if(m_VertexBuffer.isCreated()) m_VertexBuffer.destroy(); if(m_IndexBuffer.isCreated()) m_IndexBuffer.destroy(); if(m_Texture != nullptr && m_Texture->isCreated()) { delete m_Texture; m_Texture = nullptr; } } void Object::init(const QVector<VertexData> &vert, const QVector<GLuint> &ind, const QImage &img) { free(); m_VertexBuffer.create(); m_VertexBuffer.bind(); m_VertexBuffer.allocate(vert.constData(), vert.size() * static_cast<int>(sizeof(VertexData))); m_VertexBuffer.release();// temp m_IndexBuffer.create(); m_IndexBuffer.bind(); m_IndexBuffer.allocate(ind.constData(), ind.size() * static_cast<int>(sizeof(GLuint))); m_IndexBuffer.release();// temp m_Texture = new QOpenGLTexture(img.mirrored()); m_Texture->setMinificationFilter(QOpenGLTexture::Nearest); m_Texture->setMagnificationFilter(QOpenGLTexture::Linear); m_Texture->setWrapMode(QOpenGLTexture::Repeat); } void Object::draw(QOpenGLShaderProgram *program, QOpenGLFunctions *functions) { if(!m_VertexBuffer.isCreated() || !m_IndexBuffer.isCreated()) return; QMatrix4x4 modelMatrix; modelMatrix.setToIdentity(); modelMatrix.translate(m_Translate); // здесь важен порядок преобразований * modelMatrix.rotate(m_Rotate); // * modelMatrix.scale(m_Scale); // * modelMatrix = m_GlobalTransform * modelMatrix; m_Texture->bind(0); program->setUniformValue("u_texture", 0); program->setUniformValue("u_modelMatrix", modelMatrix); m_VertexBuffer.bind(); int offset = 0; int vertloc = program->attributeLocation("a_position"); program->enableAttributeArray(vertloc); program->setAttributeBuffer(vertloc, GL_FLOAT, offset, 3, sizeof(VertexData)); offset += sizeof(QVector3D); int texloc = program->attributeLocation("a_textcoord"); program->enableAttributeArray(texloc); program->setAttributeBuffer(texloc, GL_FLOAT, offset, 2, sizeof(VertexData)); offset += sizeof(QVector2D); int normloc = program->attributeLocation("a_normal"); program->enableAttributeArray(normloc); program->setAttributeBuffer(normloc, GL_FLOAT, offset, 3, sizeof(VertexData)); m_IndexBuffer.bind(); functions->glDrawElements(GL_TRIANGLES, m_IndexBuffer.size(), GL_UNSIGNED_INT, nullptr); m_VertexBuffer.release(); m_IndexBuffer.release(); m_Texture->release(); } void Object::rotate(const QQuaternion &r) { m_Rotate = r * m_Rotate; } void Object::translate(const QVector3D &t) { m_Translate += t; } void Object::scale(const float &s) { m_Scale *= s; } void Object::setGlobalTransform(const QMatrix4x4 &gt) { m_GlobalTransform = gt; }
[ "truetrifonov@yandex.ru" ]
truetrifonov@yandex.ru