blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
de4c653c1ec4cf38237f6693ba042a3559a58c99
e8363cd45cf1fce7181d82f91df7ad3f8c9f7488
/1_ProceduralProg/Chap02/Exo05/SimpleMath.cpp
4630d308523096ee2a02bd48fa8e708c7675be84
[]
no_license
sovoessi/CPP
66b6cf11933e93515379014b5585f2cd5605177e
68be86e2199287380e40c1bdd040740008b471ef
refs/heads/master
2023-04-02T04:27:21.358862
2021-04-21T09:11:04
2021-04-21T09:11:04
343,209,933
0
0
null
null
null
null
UTF-8
C++
false
false
641
cpp
SimpleMath.cpp
#include <iostream> using std::cout; using std::cin; using std::endl; int main(int argc, char *argv[]){ long int fnum = 0LL, snum = 0LL; cout << "What is the first number? "; cin >> fnum; cout << "What is the second number? "; cin >> snum; cout << fnum << " + " << snum << " = " << (fnum + snum) <<endl; cout << fnum << " - " << snum << " = " << (fnum - snum) <<endl; cout << fnum << " * " << snum << " = " << (fnum * snum) <<endl; cout << fnum << " / " << snum << " = " << (fnum / snum) <<endl; return 0; }
da2d8ff703881532fbf1a61eb8b922ba2e6c6dcf
3f0d97b22c413493c2e914b7e4cbb8c704560e0e
/reverseinteger/test_reverseinteger.cpp
2150962bba89fb4783cdd9507ab25b3e15c93e04
[]
no_license
zhouliangyi/LeetcodeExercise
7b2618325f4656cdaa8e2862cd572b166fafe0b3
aff5fdcaa770840054ebb98fde4c28463c8b7e47
refs/heads/master
2020-03-28T12:32:09.938614
2018-10-21T11:22:35
2018-10-21T11:22:35
148,307,893
0
0
null
null
null
null
UTF-8
C++
false
false
416
cpp
test_reverseinteger.cpp
#include "reverseinteger/reverseinteger.h" #include "gtest/gtest.h" TEST(test_reverseinteger, Input_123) { int in=123; ReverseInteger r; EXPECT_EQ(r.reverse(in),321); } TEST(test_reverseinteger, Input_minus123) { int in=-123; ReverseInteger r; EXPECT_EQ(r.reverse(in),-321); } TEST(test_reverseinteger, Input_120) { int in=120; ReverseInteger r; EXPECT_EQ(r.reverse(in),21); }
c527b4c8683d693fcd23b0b636c655bc476fd53e
a075357e9b99cb6f6549c9b9bee8c34206ebd28a
/6304/Zapevalov_A/L5/src/main.cpp
63d7bf8a2e0e18ea5f3943930b63e37e2c66ce08
[]
no_license
Radiogag/oop
e35ab0de9f060b589f91321ec3665404cfbe58fa
43c9afe43920df4b2d44b7d15d01d0ec4cd1d1d8
refs/heads/master
2020-03-20T10:19:57.511464
2018-06-14T14:33:34
2018-06-14T14:33:34
137,279,206
0
0
null
2018-06-13T23:19:02
2018-06-13T22:41:53
C++
UTF-8
C++
false
false
1,690
cpp
main.cpp
// ConsoleApplication6.cpp: определяет точку входа для консольного приложения. // #include "shape.hpp" #include "Triangle.hpp" #include "Parallelogram.hpp" #include "Rhombus.hpp" #include "vector.hpp" #include "sharedptr.hpp" #define N 1000 using namespace std; bool otl() {}; void viborka() {}; int main() { srand(time(0)); stepik::vector<stepik::shared_ptr<Shape>> vect(N); for (size_t i = 0; i < 1000; i++) { stepik::shared_ptr<Shape> shape; switch (rand() % 3) { case 0: shape = stepik::shared_ptr<Shape>( new Triangle(GetRandomPoint(), GetRandomPoint(), GetRandomPoint()) ); vect(N).push_back(stepik::shared_ptr<Shape>(shape)); break; case 1: shape = stepik::shared_ptr<Shape>( Point a = getRandomPoint(); Point b = getRandomPoint(); Point c = getRandomPoint(); new Parallelogram(a, b, c, getFourthPoint(a, b, c)) ); vect(N).push_back(stepik::shared_ptr<Shape>(shape)); break; case 2: shape = stepik::shared_ptr<Shape>( Point a = getRandomPoint(); Point b = getRandomPoint(); Point c = getThirdPoint(a, b); new Rhombus(a, b, c, GetFourthPoint(a, b, c))); vect(N).push_back(stepik::shared_ptr<Shape>(shape)); break; } } cout << otl(vect(N), 500) << endl; out(vect(N)); system("PAUSE"); return 0; };
e2308a8f3d8727924f70577a02b6a5595370efdf
dd5e9e3fc2f6f8c36b1baa99b3ce30cee7e70773
/lab-5.cpp
6470177fb3c4f6a4859ea77443dec45c7c46568a
[]
no_license
programming-653501/LiskovetsB
b286df1e4db459b5fb3c07b4d86d3944463673ad
a9b8d28e0ee8b2c99006e91facf21f4b9daffceb
refs/heads/master
2021-06-17T03:16:38.954001
2017-05-22T16:47:02
2017-05-22T16:47:02
83,356,675
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,943
cpp
lab-5.cpp
#include<iostream> #include<conio.h> #include<stdio.h> #include<fstream> #include<stdlib.h> using namespace std; class Node { public: Node*next; Node*head; long long int value; bool hasNext() { return head != NULL; } Node() { head = NULL; next = head; } }; void add(int value, Node*&Stack) { Node* temp = new Node(); temp->value = value; temp->next = Stack->head; Stack->head = temp; } Node pop(Node*&Stack) { Node*node = new Node(); node = Stack->head; Stack->head = Stack->head->next; return *node; } void showElem(Node*&Stack) { Node*current = Stack->head; int index = 0; while (current != NULL) { cout <<++index<<" "<< current->value << "\n"; current = current->next; } } Node* merge(Node*&Stack1, Node*&Stack2, Node*&Result) { if ((!Stack1->hasNext()) && (!Stack2->hasNext())) { return Result; } Node* node1 = Stack1->head; Node* node2 = Stack2->head; if (node2 != NULL&&node1 != NULL) { if (node1->value > node2->value) { add(node1->value, Result); pop(Stack1); } else if (node1->value < node2->value) { add(node2->value, Result); pop(Stack2); } else { add(node1->value, Result); int value = node1->value; while (value == node2->value) { node2 = node2->next; pop(Stack2); if (node2 == NULL)break; } while (value == node1->value) { node1 = node1->next; pop(Stack1); if (node1 == NULL)break; } } } else if (node2 != NULL&&node1 == NULL) { int value = node2->value; while (value == node2->value&&node2->next!=NULL) { node2 = node2->next; pop(Stack2); } add(node2->value, Result); pop(Stack2); } else if (node1 != NULL&&node2 == NULL) { int value = node1->value; while (value == node1->value&&node1->next != NULL) { node1 = node1->next; pop(Stack1); } add(node1->value, Result); pop(Stack1); } return merge(Stack1, Stack2, Result); } int main(void) { Node*Stack1 = new Node(); Node*Stack2 = new Node(); cout << "Enter the values of the first stack: \n"; while (cin.peek()!='\n')//13 - код клавиши энтер { long long int n; cin >> n; Node* new_node = new Node(); new_node->next = Stack1->head; Stack1->head = new_node; Stack1->head->value = n; } showElem(Stack1); cout << "Enter the values of the second stack: \n"; cin.ignore(); cin.clear(); while (cin.peek() != '\n')//13 - код клавиши энтер { long long int n; cin >> n; Node* new_node = new Node(); new_node->next = Stack2->head; Stack2->head = new_node; Stack2->head->value = n; } showElem(Stack2); Node*ResultStack = new Node(); merge(Stack1, Stack2, ResultStack); cout << "\n\n---------------------------------------------------------------------------\n\nResulting Stack\n"; showElem(ResultStack); _getch(); return 0; }
e93b9fdc71c624649d2c584cecd741e607039a46
7b9c1769a70f43cb8f07ab9934e29899de75138d
/src/Problem 856. Score of Parentheses.cpp
d01911647fdcfc34af77a044112422b6c4b30fa4
[]
no_license
Lqlsoftware/LeetCode-OJ
7a8feba230d058a8f1e8d81e78e96bb5a4a3ac58
607e45d1fd089720f0123a05fe97c79689bf38de
refs/heads/master
2021-06-01T18:34:48.316392
2021-03-30T14:27:18
2021-03-30T14:27:18
110,775,772
4
1
null
null
null
null
UTF-8
C++
false
false
1,154
cpp
Problem 856. Score of Parentheses.cpp
// 856. Score of Parentheses #include <iostream> #include <string> #include <stack> using namespace std; // Stack class Solution { public: int scoreOfParentheses(string S) { stack<int> stk; stk.push(0); for (auto ch : S) { if (ch == '(') { stk.push(0); } else { int temp = max(stk.top() * 2, 1); stk.pop(); temp += stk.top(); stk.pop(); stk.push(temp); } } return stk.top(); } }; // Recurrsion class Solution { private: char *start, *end; int _scoreOfParentheses() { int ret = 0; while (start != end) { if (*start == '(') { start++; ret += _scoreOfParentheses(); } else if (*start == ')') { return max(2 * ret, 1); } start++; } return ret; } public: int scoreOfParentheses(string S) { start = const_cast<char *>(S.data()), end = const_cast<char *>(S.data() + S.length()); return _scoreOfParentheses(); } };
eb43f4580428d7500ed9a9c8c390ea8e954aef64
4ce4be841db791e621928cee0c87c7981830c925
/Camera.h
7ab9b6007a260d533277238d632bb20ddadf0491
[]
no_license
egemenkopuz/simple-ray-tracing
aefd48b0b6790a1e9ced62b276bef5b8328fa4f8
20c7f9b0a7a7b3d73aebeb728fb1275bba7cee0a
refs/heads/master
2022-12-16T02:14:38.081988
2020-09-01T12:48:32
2020-09-01T12:48:32
289,501,046
0
0
null
null
null
null
UTF-8
C++
false
false
429
h
Camera.h
#ifndef CAMERA_H_EK #define CAMERA_H_EK #include "Ray.h" class Camera { public: Vector3D position, direction, horizontalDirection, verticalDirection; double viewWidth, viewHeight; Camera() = default; Camera(const Point3D &position, const Vector3D &target, const Vector3D &verticalDirection,float fov, float aspecRatio); virtual Ray makeRay(Vector2D point) const; virtual Vector3D dir(Vector2D point) const; }; #endif
dd7fae64c9ee3c18053e96eadddc5fd285503d63
0e39eb38bebb47bdc4b4b7598a697514223fd0a5
/reader/my_reader_dataset_op.cc
8bcc5a9db7ecc4172e156319f97ae573f4fe03f0
[]
no_license
smallsunsun1/tensorflow2.0_CustomOpTest
4af5b5ddd36f1a439aed65032af8082a05dd4458
5c5af370f844d0088f0e1a008123b83e90b3a9ee
refs/heads/master
2020-11-27T10:11:54.539587
2019-12-21T08:10:28
2019-12-21T08:10:28
229,397,109
0
0
null
null
null
null
UTF-8
C++
false
false
8,903
cc
my_reader_dataset_op.cc
// // Created by 孙嘉禾 on 2019-08-09. // #include "tensorflow/core/framework/common_shape_fns.h" #include "tensorflow/core/framework/dataset.h" #include "tensorflow/core/framework/reader_op_kernel.h" #include "tensorflow/core/framework/reader_base.h" #include "tensorflow/core/common_runtime/metrics.h" #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/io/inputbuffer.h" #include "tensorflow/core/framework/op.h" #include "tensorflow/core/platform/env.h" #include "tensorflow/core/framework/variant_tensor_data.h" #include "tensorflow/core/framework/shape_inference.h" #include "fstream" using tensorflow::DT_STRING; using tensorflow::PartialTensorShape; using tensorflow::Status; class MyReaderDatasetOp : public tensorflow::data::DatasetOpKernel { public: explicit MyReaderDatasetOp(tensorflow::OpKernelConstruction *ctx) : DatasetOpKernel(ctx) { // Parse and validate any attrs that define the dataset using // `ctx->GetAttr()`, and store them in member variables. } void MakeDataset(tensorflow::OpKernelContext *ctx, tensorflow::data::DatasetBase **output) override { // Parse and validate any input tensors that define the dataset using // `ctx->input()` or the utility function // `ParseScalarArgument<T>(ctx, &arg)`. // Create the dataset object, passing any (already-validated) arguments from // attrs or input tensors. *output = new Dataset(ctx); } private: class Dataset : public tensorflow::DatasetBase { public: Dataset(tensorflow::OpKernelContext *ctx) : tensorflow::data::DatasetBase(tensorflow::DatasetContext(ctx)) {} std::unique_ptr<tensorflow::IteratorBase> MakeIteratorInternal(const std::string &prefix) const override { return std::unique_ptr<tensorflow::IteratorBase>(new Iterator( {this, tensorflow::strings::StrCat(prefix, "::MyReader")} )); } // Record structure: Each record is represented by a scalar string tensor. // // Dataset elements can have a fixed number of components of different // types and shapes; replace the following two methods to customize this // aspect of the dataset. const tensorflow::DataTypeVector &output_dtypes() const override { static auto *const dtypes = new tensorflow::DataTypeVector({DT_STRING}); return *dtypes; } const std::vector<PartialTensorShape> &output_shapes() const override { static std::vector<PartialTensorShape> *shapes = new std::vector<PartialTensorShape>({{}}); return *shapes; } std::string DebugString() const override { return "MyReaderDatasetOp::Dataset"; } protected: // Optional: Implementation of `GraphDef` serialization for this dataset. // // Implement this method if you want to be able to save and restore // instances of this dataset (and any iterators over it). Status AsGraphDefInternal(tensorflow::SerializationContext *ctx, DatasetGraphDefBuilder *b, tensorflow::Node **output) const override { // Construct nodes to represent any of the input tensors from this // object's member variables using `b->AddScalar()` and `b->AddVector()`. std::vector<tensorflow::Node *> input_tensors; TF_RETURN_IF_ERROR(b->AddDataset(this, input_tensors, output)); return Status::OK(); } private: class Iterator : public tensorflow::DatasetIterator<Dataset> { private: tensorflow::mutex mu_; tensorflow::int64 i_ GUARDED_BY(mu_); std::fstream fs; public: explicit Iterator(const Params &params) : DatasetIterator<Dataset>(params), i_(0) { } // Implementation of the reading logic. // // The example implementation in this file yields the string "MyReader!" // ten times. In general there are three cases: // // 1. If an element is successfully read, store it as one or more tensors // in `*out_tensors`, set `*end_of_sequence = false` and return // `Status::OK()`. // 2. If the end of input is reached, set `*end_of_sequence = true` and // return `Status::OK()`. // 3. If an error occurs, return an error status using one of the helper // functions from "tensorflow/core/lib/core/errors.h". Status GetNextInternal(tensorflow::IteratorContext *ctx, std::vector<tensorflow::Tensor> *out_tensors, bool *end_of_sequence) override { // NOTE: `GetNextInternal()` may be called concurrently, so it is // recommended that you protect the iterator state with a mutex. tensorflow::mutex_lock l(mu_); if (i_ < 10) { tensorflow::Tensor record_tensor(ctx->allocator({}), DT_STRING, {}); record_tensor.scalar<std::string>()() = "MyReader!"; out_tensors->emplace_back(std::move(record_tensor)); ++i_; *end_of_sequence = false; } else { *end_of_sequence = true; } return Status::OK(); } protected: // Optional: Implementation of iterator state serialization for this // iterator. // // Implement these two methods if you want to be able to save and restore // instances of this iterator. Status SaveInternal(tensorflow::IteratorStateWriter *writer) override { tensorflow::mutex_lock l(mu_); TF_RETURN_IF_ERROR(writer->WriteScalar(full_name("i"), i_)); return Status::OK(); } Status RestoreInternal(tensorflow::IteratorContext *ctx, tensorflow::IteratorStateReader *reader) override { tensorflow::mutex_lock l(mu_); TF_RETURN_IF_ERROR(reader->ReadScalar(full_name("i"), &i_)); return Status::OK(); } }; }; }; namespace tensorflow { class TextLineReader : public ReaderBase { private: enum { kBufferSize = 256 << 10 }; const int skip_header_lines_; Env *const env; int64 line_number_; std::unique_ptr<RandomAccessFile> file_; std::unique_ptr<io::InputBuffer> input_buffer_; public: TextLineReader(const string &node_name, int skip_header_lines, Env *env) : ReaderBase(strings::StrCat("TextLineReader '", node_name, "'")), skip_header_lines_(skip_header_lines), env(env), line_number_(0) {} Status OnWorkStartedLocked() override { line_number_ = 0; TF_RETURN_IF_ERROR(env->NewRandomAccessFile(current_work(), &file_)); input_buffer_.reset(new io::InputBuffer(file_.get(), kBufferSize)); for (; line_number_ < skip_header_lines_; ++line_number_) { string line_contents; Status status = input_buffer_->ReadLine(&line_contents); if (errors::IsOutOfRange(status)) { return Status::OK(); } TF_RETURN_IF_ERROR(status); } return Status::OK(); } Status OnWorkFinishedLocked() override { input_buffer_.reset(nullptr); return Status::OK(); } Status ReadLocked(string *key, string *value, bool *produced, bool *at_end) override { Status status = input_buffer_->ReadLine(value); ++line_number_; if (status.ok()) { *key = strings::StrCat(current_work(), ":", line_number_); *produced = true; return status; } if (errors::IsOutOfRange(status)) { *at_end = true; return Status::OK(); } else { return status; } } Status ResetLocked() override { line_number_ = 0; input_buffer_.reset(nullptr); return ReaderBase::ResetLocked(); } }; class TextLineReaderOp : public ReaderOpKernel { public: explicit TextLineReaderOp(OpKernelConstruction *context) : ReaderOpKernel(context) { int skip_header_lines = -1; OP_REQUIRES_OK(context, context->GetAttr("skip_header_lines", &skip_header_lines)); OP_REQUIRES(context, skip_header_lines >= 0, errors::InvalidArgument("skip_header_lines must be >= 0 not", skip_header_lines)); Env* env = context->env(); SetReaderFactory([this, skip_header_lines, env](){ return new TextLineReader(name(), skip_header_lines, env); }); } void Compute(OpKernelContext* ctx) override { } }; } REGISTER_OP("MyReaderDataset") .Output("handle: variant") .SetIsStateful() .SetShapeFn(tensorflow::shape_inference::ScalarShape); REGISTER_KERNEL_BUILDER(Name("MyReaderDataset").Device(tensorflow::DEVICE_CPU), MyReaderDatasetOp); //REGISTER_OP("TextLineReader") //.Output("handle: variant") //.SetIsStateful() //.SetShapeFn(tensorflow::shape_inference::ScalarShape); // //REGISTER_KERNEL_BUILDER(Name("TextLineReader").Device(tensorflow::DEVICE_CPU), // tensorflow::TextLineReaderOp);
182985f0fdd3273ba140d2f329fa2f3486c9ae46
0d809394e82f46247cc990efb71cd82686b0f519
/VivadoHls/tau_algo_unpacked/vivado_hls/src/algo_inputs_layer2_v3_tb.cpp
98ff65086b0e8396b345bb9b0357ced730b19ae3
[]
no_license
violatingcp/APx_Gen0_Algo
b863b5e640cdb8105dbecdccdadc6402e32bc82a
276b3489aafe165436dc66650be592fe96e567ef
refs/heads/master
2020-05-25T14:08:21.768415
2019-06-23T12:53:53
2019-06-23T12:53:53
187,837,672
0
2
null
2019-05-21T12:58:08
2019-05-21T12:58:08
null
UTF-8
C++
false
false
3,838
cpp
algo_inputs_layer2_v3_tb.cpp
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <unistd.h> #include <iostream> #include <fstream> #include <iomanip> #include <string> #include "ap_int.h" #include "algo_inputs_layer2_v3.h" using namespace std; typedef ap_int<64> tmpaxi_t; int main(int argc, char ** argv) { float dphi = 0.02; float deta = 0.02; float pt = 1.; float pterr = 0.1; tmpaxi_t chparts[DEPTH][NTRACK]; tmpaxi_t emparts[DEPTH][NEMCALO]; tmpaxi_t neparts[DEPTH][NCALO]; tmpaxi_t muparts[DEPTH][NMU]; for(int idepth = 0; idepth < DEPTH; idepth++) { int pEta = idepth % 4; int pPhi = idepth/3; for(int i0 = 0; i0 < NTRACK; i0++) { float pTEta = 0. + pEta*0.7+dphi*int(i0/2); float pTPhi = 0. + pPhi*0.7+deta*(1+int(i0/2)); tmpaxi_t pTmp; pTmp.range(15, 0) = pt*PT_SCALE; pTmp.range(24,16) = pTEta*ETAPHI_SCALE; pTmp.range(34,25) = pTPhi*ETAPHI_SCALE; pTmp.range(38,35) = 0; pTmp.range(48,39) = 0; chparts[idepth][i0] = pTmp; } for(int i0 = 0; i0 < NEMCALO; i0++) { float pTEta = 0. + pEta*0.7+dphi*(1+int(i0/2)); float pTPhi = 0. + pPhi*0.7+deta*(3+int(i0/2)); tmpaxi_t pTmp; pTmp.range(15, 0) = pt*PT_SCALE; pTmp.range(24,16) = pTEta*ETAPHI_SCALE; pTmp.range(34,25) = pTPhi*ETAPHI_SCALE; pTmp.range(38,35) = 2; pTmp.range(55,39) = pt*PT_SCALE; emparts[idepth][i0] = pTmp; } for(int i0 = 0; i0 < NSELCALO; i0++) { float pTEta = 0. + pEta*0.7+dphi*(2+int(i0/2)); float pTPhi = 0. + pPhi*0.7+deta*(6+int(i0/2)); tmpaxi_t pTmp; pTmp.range(15, 0) = pt*PT_SCALE; pTmp.range(24,16) = pTEta*ETAPHI_SCALE; pTmp.range(34,25) = pTPhi*ETAPHI_SCALE; pTmp.range(38,35) = 2; pTmp.range(55,39) = pt*PT_SCALE; neparts[idepth][i0] = pTmp; } for(int i0 = 0; i0 < NMU; i0++) { float pTEta = 0. + pEta*0.7+dphi*(5+int(i0/2)); float pTPhi = 0. + pPhi*0.7+deta*(1+int(i0/2)); tmpaxi_t pTmp; pTmp.range(15, 0) = pt*PT_SCALE; pTmp.range(24,16) = pTEta*ETAPHI_SCALE; pTmp.range(34,25) = pTPhi*ETAPHI_SCALE; pTmp.range(38,35) = 0; pTmp.range(48,39) = 0; muparts[idepth][i0] = pTmp; } } //void algo_inputs_layer2_v3( MP7DataWord input[DEPTH][MP7_NCHANN]; MP7DataWord output[DEPTH][MP7_NCHANN]; for(int idepth = 0; idepth < DEPTH; idepth++) { for(int i0 = 0; i0 < NTRACK; i0++) { input[idepth][i0*2+0] = chparts[idepth][i0].range(31,0); input[idepth][i0*2+1] = chparts[idepth][i0].range(63,32); } for(int i0 = 0; i0 < NEMCALO; i0++) { input[idepth][i0*2+0+EMOFFS] = emparts[idepth][i0].range(31,0); input[idepth][i0*2+1+EMOFFS] = emparts[idepth][i0].range(63,32); } for(int i0 = 0; i0 < NCALO; i0++) { input[idepth][i0*2+0+HAOFFS] = neparts[idepth][i0].range(31,0); input[idepth][i0*2+1+HAOFFS] = neparts[idepth][i0].range(63,32); } for(int i0 = 0; i0 < NMU; i0++) { input[idepth][i0*2+0+MUOFFS] = muparts[idepth][i0].range(31,0); input[idepth][i0*2+0+MUOFFS] = muparts[idepth][i0].range(63,32); } algo_inputs_layer2_v3(input[idepth],output[idepth]); } for(int idepth = 0; idepth < NTAU; idepth++) { for(int ipart = 0; ipart < DATA_SIZE; ipart++) { PFChargedObj pTmp; float pPt = output[idepth][ipart].range(15,0); pPt/=PT_SCALE; float pEta = output[idepth][ipart].range(31,16); pEta/=ETAPHI_SCALE; float pPhi = output[idepth][ipart].range(15,0); pPhi/=ETAPHI_SCALE; int pId = output[idepth][ipart].range(31,16); std::cout << "===> tau part " << idepth << " -- part " << ipart << " vector " << pPt << "-- " << pEta << " -- " << pPhi << " - Id - " << pId << std::endl; } } }
c10f4213c0e0f8238fb081fc13954ae40d3cd9dd
2441b892e99d5e5de3af51d9520c900639d95033
/SymbolicObjects/SymbolicMatrix.cpp
6b84b94c13a9f518d8fe7b1d63c78e06232e603c
[]
no_license
alinaT95/AutomaticCryptanalisis
2537d9780385b24e560dd559006bd75a51aece11
a79966aeac6f8b588f5628ed0b678f60b97d4f38
refs/heads/master
2021-06-06T11:48:22.477312
2016-10-06T15:23:39
2016-10-06T15:23:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
66
cpp
SymbolicMatrix.cpp
#include "SymbolicMatrix.h" SymbolicMatrix::SymbolicMatrix() { }
9a7c25d7143bb80c3f10e3ebe7d46326e0291b69
eb5fc6309b94c3e2056e4bc9d5cbd97e1550a29a
/2020_acm/DFS와 BFS/7576.cpp
6a47f75487511671a802960d24af88325d313ba8
[]
no_license
SuHyeonJeong/acm_study
8412bde37d2416e7182cc2bfa91d02f05370cd20
e2c579b19d0c0e6ba8441734aedefe8f00380e63
refs/heads/master
2022-06-05T21:55:28.514671
2022-04-05T06:40:38
2022-04-05T06:40:38
172,499,463
0
0
null
null
null
null
UTF-8
C++
false
false
1,097
cpp
7576.cpp
#include <iostream> #include <queue> #include <algorithm> using namespace std; const int dx[] = { 0, 0, -1, 1 }; const int dy[] = { -1, 1, 0, 0 }; int N, M; const int MAX = 1001; int map[MAX][MAX]; queue <pair<int, int>> q; int BFS() { if (q.empty()) { return -1; } while (!q.empty()) { int y = q.front().first; int x = q.front().second; q.pop(); for (int j = 0; j < 4; j++) { int next_y = y + dy[j]; int next_x = x + dx[j]; if (next_y >= 0 && next_y < N && next_x >= 0 && next_x < M && map[next_y][next_x] == 0) { map[next_y][next_x] = map[y][x] + 1; q.push(make_pair(next_y, next_x)); } } } int mx = -1; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (map[i][j] == 0) { return -1; } mx = max(mx, map[i][j]); } } return mx - 1; } int main() { ios_base::sync_with_stdio(false); cin >> M >> N; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cin >> map[i][j]; if (map[i][j] == 1) { q.push(make_pair(i,j)); } } } cout << BFS() << "\n"; return 0; }
99815a5d3ca94b5a68a87858d6b15bb08d32b1e9
7bde5822e540f07cdf94411318982de57b1317bc
/Projects/Tokenizer/main.cpp
7e899d83bfd406465a6ac09f49d117f7f5762ea5
[]
no_license
JaRoHe318/Cpp
434e440942b58f280f3f7c7bd5ebe65280411b38
a7af4ac1418fc900376a2e0e391a695baa0f078e
refs/heads/master
2021-08-31T23:21:55.837721
2017-12-23T12:22:23
2017-12-23T12:22:23
105,232,572
0
0
null
null
null
null
UTF-8
C++
false
false
276
cpp
main.cpp
#include <iostream> using namespace std; #include "jtoken.h" #include "double.h" #include "integer.h" #include "funct.h" #include "op.h" #include "tokenizer.h" int main(){ cout << "Tokenizer!" << endl; Tokenizer getToken; getToken.getEquation(); return 0; }
6e06a4fabc09f74e8e556530e9967d8a42e4afd8
1ef0afb6ba04e74cf59c38369f0341899d3635f7
/Cacades/AntiAliasingInfo.h
0f423ae98a2d0d7fc18af0dd5da83732538d40a2
[]
no_license
fabi092/Cascades-Shaderprogramming
57beb4d9b8bfa2d63c8311d3aff37775a4ae5f71
22630bd94b988c4212ab238c478d43685d42867c
refs/heads/main
2023-04-09T13:39:25.891657
2021-04-15T06:45:58
2021-04-15T06:45:58
358,103,787
0
0
null
null
null
null
UTF-8
C++
false
false
809
h
AntiAliasingInfo.h
#pragma once #include <sstream> #include <GL/glew.h> struct AntiAliasingInfo { GLsizei Samples = 8; GLsizei ActiveSamples = 8; GLsizei MaxSamples; GLuint ColorBuffer; GLuint DepthBuffer; void Init() { glGenRenderbuffers(1, &ColorBuffer); glGenRenderbuffers(1, &DepthBuffer); if (GLEW_NV_framebuffer_multisample_coverage) { int maxModes; glGetIntegerv(GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV, &maxModes); if (maxModes != 0) { int* modes = new int[2 * maxModes]; glGetIntegerv(GL_MULTISAMPLE_COVERAGE_MODES_NV, modes); MaxSamples = modes[2 * (maxModes - 1)]; return; } } MaxSamples = 16; } std::string ParseAAMode() const { if (Samples == 0) return "Deaktiviert"; std::stringstream ss; ss << ActiveSamples << "x MSAA"; return ss.str(); } };
6d21ecfe3c791d1774adc39bc9a7c0ad576feda8
64060871046acbecdfd8ee34a241bbcb9efee37e
/src/database/tds/tds_resultset_metadata.cpp
766b67eb0403f334ccd41521b6225cacfa168bbd
[]
no_license
mtangoo/wxDatabase
0fbc4c19b7272336d487947df53f28bffb0f30ad
8152e805f2fda92805e487ad0a85deaf6f2968bd
refs/heads/master
2021-12-13T06:27:23.944429
2021-12-02T06:56:19
2021-12-02T06:56:19
6,829,298
33
20
null
2021-09-17T19:23:01
2012-11-23T15:26:16
C++
UTF-8
C++
false
false
767
cpp
tds_resultset_metadata.cpp
#include "wx/database/wxprec.h" #if wxUSE_DATABASE_TDS #include "wx/arrimpl.cpp" WX_DEFINE_OBJARRAY(ArrayOfTdsColumns); // ctor wxTdsResultSetMetaData::wxTdsResultSetMetaData(TDSRESULTINFO* pInfo) { for (int i=0; i<pInfo->num_cols; i++) { wxTdsColumnData column(pInfo->columns[i]); m_Columns.push_back(column); } } int wxTdsResultSetMetaData::GetColumnType(int i) { return m_Columns[i-1].GetColumnType(); } int wxTdsResultSetMetaData::GetColumnSize(int i) { return m_Columns[i-1].GetColumnSize(); } wxString wxTdsResultSetMetaData::GetColumnName(int i) { return m_Columns[i-1].GetColumnName(); } int wxTdsResultSetMetaData::GetColumnCount() { return m_Columns.size(); } #endif//wxUSE_DATABASE_TDS
385fa72abafe51c5a14b8cd7c2944980b25166cd
d27941bf615cd93b5aeea660ddf919d331b7a1a8
/0215-Kth-Largest-Element-in-an-Array/C++/main.cpp
0ce00b99a9f79ce9858cfc0d14af7f38638c334c
[]
no_license
lsr3406/Leetcode-Exercise
de71348d7802351d410fd87ad3c0a85ddbd0b2ef
044de951f9f35225b40e76df5527711d17cbc492
refs/heads/master
2020-04-19T04:09:02.768064
2019-11-13T02:56:18
2019-11-13T02:56:18
167,954,959
0
0
null
null
null
null
UTF-8
C++
false
false
3,309
cpp
main.cpp
/** * encoding: utf-8 * @author: siru * @create on: 2019-01-29 21:16:01 * @update on: 2019-01-29 22:55:25 */ #include <iostream> #include <cassert> #include <vector> using namespace std; // 215. Kth Largest Element in an Array // https://leetcode.com/problems/kth-largest-element-in-an-array class Solution { public: /** * 在一个 vector 中找到第 k 大的元素 * @param nums 待搜索的 vector * @param k rank * @return 找到的第 k 大的元素 */ int findKthLargest(vector<int>& nums, int k) { // return findKthLargest1(nums, k); return findKthLargest2(nums, k); } /** * 方案一: 使用选择排序的思路, 相当于暴力破解, 依次找到最大的元素并放到末端 * 时间复杂度: O(nk) * 空间复杂度: O(1) */ int findKthLargest1(vector<int>& nums, int k) { assert(k >= 1 && k <= nums.size()); int n = nums.size(); // 大循环, 每次找出第 i 大的元素 for (int i = 1; i <= k; i ++) { int curMaxIndex = 0; for (int j = 0; j <= n - i; j ++) if (nums[j] > nums[curMaxIndex]) curMaxIndex = j; swap(nums[curMaxIndex], nums[n - i]); } return nums[n - k]; } /** * 方案二: 使用快速排序的思路, 不断向第 k 大的方向作 partition 操作. * 时间复杂度: O(n) * 空间复杂度: O(1) */ int findKthLargest2(vector<int>& nums, int k) { int n = nums.size(); int l = 0, r = n - 1; while (true) { // 接收标定点位置 int br = partition(nums, l, r); if (br + k > n) { r = br - 1; } else if (br + k < n) { l = br + 1; } else { // 找到了第 k 大的元素 return nums[br]; } } } /** * 方案三: 使用容量为 k 的优先队列(最小堆), 依次将 nums 中的元素放入, 最后取出堆顶元素 * 时间复杂度: O(nlogk) * 空间复杂度: O(1) */ int findKthLargest3(vector<int>& nums, int k) { // TODO 优先队列法 return 0; } private: /** * 在 nums 中 [l, r] 区间中对元素 nums[l] 作 partition 操作, 返回标定点最后移到的位置 */ int partition(vector<int>& nums, int l, int r) { assert(l <= r); int j = l; // nums[l+1, ..., j] < v, nums[j+1, ..., i-1] > v for (int i = l + 1; i <= r; i ++) { if (nums[i] < nums[l]) { j ++; swap(nums[j], nums[i]); } else { // nums[i] >= nums[l] // do nothing } } swap(nums[l], nums[j]); return j; } }; int main(int argc, char const *argv[]) { int arr1[] = {3, 2, 1, 5, 6, 4}, k1 = 2; int arr2[] = {3, 2, 3, 1, 2, 4, 5, 5, 6}, k2 = 4; vector<int> nums1(arr1, end(arr1)); vector<int> nums2(arr2, end(arr2)); int res1 = Solution().findKthLargest(nums1, k1); int res2 = Solution().findKthLargest(nums2, k2); cout << res1 << endl; cout << res2 << endl; return 0; }
19dbac427243a66d5996eaf1001b7da23671856b
ed9278ce7ba6e05166b7d65f995e1f0b2720b2d6
/src/log/TypeRegistry.cpp
c64d4db725cadf2c6f5cda8599def0d2c2863d90
[]
no_license
dwks/crystallizer
10858a923e6768ccf36eb23b601aa4714f5cd4fd
4a962c63bc55a952e3fbe1dfe2d8ce18f8cf154f
refs/heads/master
2021-03-12T21:49:22.114468
2011-07-17T23:13:47
2011-07-17T23:13:47
2,062,887
0
0
null
null
null
null
UTF-8
C++
false
false
1,267
cpp
TypeRegistry.cpp
#include "TypeRegistry.h" namespace Crystallizer { namespace Log { TypeRegistry TypeRegistry::instance; TypeRegistry::TypeRegistry() { addNextType(Subsystem::GLOBAL, "ERROR"); addNextType(Subsystem::GLOBAL, "WARNING"); addNextType(Subsystem::GLOBAL, "PROGRESS"); addNextType(Subsystem::NETWORK, "ERROR"); addNextType(Subsystem::NETWORK, "CONNECT"); addNextType(Subsystem::FRACTAL, "ERROR"); } void TypeRegistry::registerType(Subsystem subsystem, const std::string &type, int level) { type_list[subsystem.getSubsystem()][type] = level; } void TypeRegistry::addNextType(Subsystem subsystem, const std::string &type) { type_list_t &list = type_list[subsystem.getSubsystem()]; int level = static_cast<int>(list.size()); registerType(subsystem, type, level); } bool TypeRegistry::isValidType(Subsystem subsystem, const std::string &type) { type_list_t::iterator found = type_list[subsystem.getSubsystem()].find(type); return found != type_list[subsystem.getSubsystem()].end(); } int TypeRegistry::getLevelOfType(Subsystem subsystem, const std::string &type) { return type_list[subsystem.getSubsystem()][type]; } } // namespace Log } // namespace Crystallizer
cd138bf961cec446278ca3ceab2fb71b9aceb416
c7130ac6790860a83dfb85695379a8f1f7691652
/advanced level/1109/1109-cpp.cpp
134e83085fa3e39772d88a41aa75599acdefe530
[]
no_license
diaojibo/PAT-Code
e3421fc154ce2e31b959126fcf95200169b19816
f5ea6fb9a63ffc56bde002a32247921d3365455e
refs/heads/master
2020-05-21T17:47:02.429046
2017-12-09T01:42:19
2017-12-09T01:42:19
65,083,793
0
0
null
null
null
null
UTF-8
C++
false
false
1,473
cpp
1109-cpp.cpp
#include<iostream> #include<vector> #include<string> #include<stdio.h> #include<algorithm> using namespace std; struct person{ int height; string name; }; int n,k; vector<person> people; bool compstring(string a,string b){ int sizea,sizeb; sizea = a.length(); sizeb = b.length(); int msize = min(sizea,sizeb); for(int i=1;i<=msize;i++){ if(a[i-1]<b[i-1]) return true; if(a[i-1]>b[i-1]) return false; } return (sizea<sizeb); } bool comparebig(person a,person b){ if(a.height>b.height) return true; if(a.height<b.height) return false; return compstring(a.name,b.name); } string put_position(int begin,int end,vector<person>& people){ string formation = people[begin].name; bool put_left = true; for(int i=begin+1;i<=end;i++){ if(put_left){ formation = people[i].name+" "+formation; }else{ formation = formation + " " +people[i].name; } put_left = !put_left; } return formation; } int main(){ scanf("%d %d",&n,&k); for(int i=0;i<n;i++){ int th; person tperson; char temp[20]; scanf("%s %d",&temp,&th); tperson.height = th; tperson.name = string(temp); people.push_back(tperson); } sort(people.begin(),people.end(),comparebig); int row = 0; int row_number; int beg = 0; while(true){ row ++; if(row>k) break; if(row==1){ row_number = n/k + n%k; } else row_number = n/k; string thisrow = put_position(beg,beg+row_number-1,people); cout<<thisrow<<endl; beg += row_number; } return 0; }
48e3eda0a8ce2aea20ea9aea66d74fd45e1f4050
8436ccff8c4d0632030f74dcf26fedb09504326c
/08/String/UseString.cpp
657b9dac2561050a8039ee98b8c139178b11421f
[]
no_license
zoteva/oop-kn-5-2021
5e2166cf02494afc438bf003e5cf278b02a55454
80097a3acd688e9eac159933c9ea6f56dbe280e4
refs/heads/main
2023-05-30T19:13:45.742160
2021-06-19T08:19:16
2021-06-19T08:19:16
340,749,049
1
0
null
null
null
null
UTF-8
C++
false
false
363
cpp
UseString.cpp
#include "String.h" #include <iostream> int main() { String s; s = "abc"; std::cout << std::boolalpha << (s == ("abd")) << std::endl; std::cout << s[1] << std::endl; s[1] = 'D'; s += "new"; std::cout << "Source: " << s << std::endl; String subStr = s(3, 8); std::cout << "Substring: " << subStr << std::endl; return 0; }
29776899dc96e043491608dfd619a4eb5cde30dc
4394d4ebd19b8eff58586fbded3a416faf7fa0ab
/ast/src/View.cpp
9fb43244b76afa802a93af92393cad5037db31fc
[]
no_license
ivan-uskov/compiler
660ce11d0c988b72a74be41d99e15b69737eeca6
474c96895eef84f568f0343719ccfc1a76020e2d
refs/heads/master
2020-03-19T12:15:27.140901
2020-01-21T22:48:24
2020-01-21T22:48:24
136,506,565
1
0
null
null
null
null
UTF-8
C++
false
false
2,738
cpp
View.cpp
#include "../View.h" #include "../NumberBinaryOperatorAST.h" #include "../IntAST.h" #include "../ExpressionPairAST.h" #include "../VariableDeclarationAST.h" #include "../AssignmentAST.h" #include "../VariableAccessAST.h" #include "../FunctionCallAST.h" #include "../CompareBinaryOperatorAST.h" #include "../IfAST.h" #include "../WhileAST.h" #include "../StringAST.h" #include "../DoubleAST.h" #include "../ArrayAssignmentAST.h" #include "../ArrayAccessAST.h" #include "../BoolAST.h" using namespace AST; View::View(std::ostream & out) : mOut(out) {} void View::visit(NumberBinaryOperatorAST const& op) { mOut << "("; op.acceptLeft(*this); mOut << op.getType(); op.acceptRight(*this); mOut << ")"; } void View::visit(IntAST const& op) { mOut << op.getValue(); } void View::visit(ExpressionPairAST const &op) { op.acceptLeft(*this); mOut << ";" << std::endl; op.acceptRight(*this); } void View::visit(VariableDeclarationAST const &op) { mOut << op.getResultType() << " " << op.getId(); } void View::visit(AssignmentAST const &op) { mOut << op.getId() << " = "; op.acceptValue(*this); } void View::visit(VariableAccessAST const &op) { mOut << op.getId(); } void View::visit(FunctionCallAST const &op) { mOut << op.getName() << "("; if (op.getResultType() == ValueType::Void) { op.acceptArgument(*this); } mOut << ")"; } void View::visit(CompareBinaryOperatorAST const &op) { mOut << "("; op.acceptLeft(*this); mOut << op.getType(); op.acceptRight(*this); mOut << ")"; } void View::visit(IfAST const &op) { mOut << "if ("; op.acceptCond(*this); mOut << ")" << std::endl; mOut << "{" << std::endl << " "; op.acceptStmt(*this); mOut << std::endl << "}" << std::endl; //TODO: add spaces } void View::visit(WhileAST const &op) { mOut << "while ("; op.acceptCond(*this); mOut << ")" << std::endl; mOut << "{" << std::endl << " "; op.acceptStmt(*this); mOut << std::endl << "}" << std::endl; //TODO: add spaces } void View::visit(StringAST const &op) { mOut << "'" << op.getValue() << "'"; } void View::visit(DoubleAST const &op) { mOut << op.getValue(); } void View::visit(ArrayAssignmentAST const &op) { if (op.hasIndex()) { mOut << op.getId() << "["; op.acceptIndex(*this); mOut << "] = "; op.acceptValue(*this); } else { mOut << op.getId() << "[] = "; op.acceptValue(*this); } } void View::visit(ArrayAccessAST const &op) { mOut << op.getId() << "["; op.acceptIndex(*this); mOut << "]"; } void View::visit(BoolAST const &op) { mOut << (op.getValue() ? "true" : "false"); }
551e3ae368d66db120d71cd575df3f45f806a507
8247b94227a3e4169c2c8a2b572cf57dc24917a2
/src/beast/beast/http/curlReader.h
e58c07ab9690b065042abf7ce0945ec6bd9353cb
[ "MIT-Wu", "MIT", "ISC", "BSL-1.0" ]
permissive
StanChe/stellar-mobile
4e641dd27fa594e38971f549c57b218403e8522f
43a99d4da4369ecfe5b2a907f740dfd99056058e
refs/heads/master
2020-05-18T13:26:51.005312
2014-12-06T10:09:23
2014-12-06T10:09:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
209
h
curlReader.h
#ifndef BEAST_HTTP_CURLREADER_H_INCLUDED #define BEAST_HTTP_CURLREADER_H_INCLUDED namespace beast { class CurlReader { public: std::string performRequest(std::string url, std::string params); }; } #endif
76b0f095b86f1d5319bfa8e4674c8014290863eb
9008c69d81f91224e2dcb4faaa87a73af2923bdf
/TEST 20180329/TEST 20180329/LuckyPoker.cpp
9eaa5d26053c0f29e8ab26c07ca9cfd94ee8cb0e
[]
no_license
qwer87511/OOP-Homework
84c5d0b4ae9ca7beb7c6cf43ad49ce1289829254
b26e0c159735f27488e7abca25d46ce624188827
refs/heads/master
2020-03-19T01:18:12.701354
2018-06-02T14:52:39
2018-06-02T14:52:39
135,535,985
0
0
null
null
null
null
UTF-8
C++
false
false
1,140
cpp
LuckyPoker.cpp
#include "LuckyPoker.h" #include <random> #include <algorithm> #include <ctime> #include <iostream> using std::cout; using std::shuffle; using std::default_random_engine; LuckyPoker::LuckyPoker() { srand(time(NULL)); _cards.resize(52); for (int i = 0; i < 52; ++i) { _cards[i] = (i / 4) + 1; } } void LuckyPoker::Shuffle() { shuffle(_cards.begin(), _cards.end(), default_random_engine(time(NULL))); } void LuckyPoker::Deal() { int i = 0; for (int j = 0; j < OPPONENT_CARD_NUM; ++j) { _opponentCard[j] = _cards[i]; ++i; } for (int j = 0; j < PLAYER_CARD_NUM; ++j) { _playerCard[j] = _cards[i]; ++i; } } int LuckyPoker::GetResult() { int result = 0; for (int i = 0; i < OPPONENT_CARD_NUM; ++i) { /*cout << "opponent cards : " << _opponentCard[i] << '\n'; cout << "player cards" << '\n';*/ for (int j = 0; j < PLAYER_CARD_NUM; ++j) { /*cout << _playerCard[j] << '\n';*/ if (_playerCard[j] > _opponentCard[i]) result++; } } return result; }
bab891d62c2270dade247f129f1f3f1ba9e3e3fa
f6cb916c7e9db39728e786f89df8d59fe3dfec3d
/bugs/13152/src/bcd/fltk/Fl_Hor_Slider.cc
eadfb1965e61f5b3920fec12f67d60c02423b7a4
[]
no_license
CyberShadow/DBugTests
8e2b9935ab1e65e7c14638b4a63bc5fec8aee1a2
24a227d9b835c1bc72b6c469ab293e0c3bf9039f
refs/heads/master
2023-08-22T14:37:08.841829
2023-07-20T16:51:45
2023-07-20T16:51:45
23,382,869
4
0
null
null
null
null
UTF-8
C++
false
false
1,270
cc
Fl_Hor_Slider.cc
/* THIS FILE GENERATED BY bcd.gen */ #include <stdlib.h> #include <string.h> #include "../bind.h" #include "FL/Fl_Hor_Slider.H" extern "C" { void _BCD_delete_13Fl_Hor_Slider(Fl_Hor_Slider *This) { delete This; } Fl_Hor_Slider *_BCD_new__ZN13Fl_Hor_SliderC1EiiiiPKc(int X, int Y, int W, int H, char const * l) { return new Fl_Hor_Slider(X, Y, W, H, l); } } class Fl_Hor_Slider_R : Fl_Hor_Slider { public: void *__D_data; Fl_Hor_Slider_R(int X, int Y, int W, int H, char const * l) : Fl_Hor_Slider(X, Y, W, H, l) {} }; extern "C" { Fl_Hor_Slider_R *_BCD_new__ZN13Fl_Hor_SliderC1EiiiiPKc_R(int X, int Y, int W, int H, char const * l) { return new Fl_Hor_Slider_R(X, Y, W, H, l); } void _BCD_delete_13Fl_Hor_Slider__Fl_Hor_Slider_R(Fl_Hor_Slider_R *This) { delete This; } void _BCD_RI_13Fl_Hor_Slider(Fl_Hor_Slider_R *cd, void *dd) { cd->__D_data = dd; } typedef void (*_BCD_func__11)(Fl_Widget *, long int); typedef _BCD_func__11 _BCD__12_Fl_Callback1; typedef void (*_BCD_func__13)(Fl_Widget *); typedef _BCD_func__13 _BCD__14_Fl_Callback0; typedef void (*_BCD_func__17)(Fl_Widget *, void *); typedef _BCD_func__17 _BCD__18_Fl_Callback; typedef _BCD__18_Fl_Callback _BCD__16_Fl_Callback_p; typedef long unsigned int _BCD__58_ulong; typedef unsigned char _BCD__60_uchar; }
4bccf1a526f491ea7229cd2495f3f4fae3d5ee7b
2d71917f247ef84a93ada564bf79abc1bacc7208
/ex03/Ice.hpp
f6e35b1f6c74b7536b804aa42163110ea66d3327
[]
no_license
obellado/cxx.04
114bad561342c60b3a2696c3ce909d6207d30808
991f2e101ccad183a5d0a495e729553edd6888dd
refs/heads/master
2023-06-25T01:32:07.635868
2021-07-31T20:01:55
2021-07-31T20:01:55
389,726,777
0
0
null
null
null
null
UTF-8
C++
false
false
337
hpp
Ice.hpp
#pragma once # ifndef __ICE_H__ # define __ICE_H__ # include "ICharacter.hpp" # include "AMateria.hpp" class Ice : public AMateria { public: Ice( void ); virtual ~Ice( void ); Ice( Ice const & copy ); Ice & operator=(const Ice & copy); virtual AMateria* clone() const ; virtual void use(ICharacter & target); }; #endif
2e9226e4cccc7d683ca76c7b488307f913ef0fc5
1e5c488081e59040b484a2a56b93a2ea1d91ddf8
/src/src/ACE/src/componentres.cpp
0ab99a411b1186238909bfda4f8f5e81f212ab21
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
siconos/acef
54c38737f93d34e35c1f7d4b0d3fe7f39b71b260
200d1c4e0b2ba7e10c3393d93f60e156c3646154
refs/heads/master
2023-01-14T16:40:05.973224
2020-11-24T12:51:27
2020-11-24T12:51:27
315,632,330
0
0
null
null
null
null
UTF-8
C++
false
false
2,071
cpp
componentres.cpp
/* Siconos is a program dedicated to modeling, simulation and control * of non smooth dynamical systems. * * Copyright 2019 INRIA. * * 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. */ /*! \file componentres.cpp */ /************************************************************************ componentres.cpp **************************************************************************/ #include "componentres.h" #include "algo.h" componentRES::componentRES(dataRES *d) :componentLINEAR(){ if (!d) ACE_ERROR("componentRES::componentRES dataRES null"); mData = (*d); mNodePos=mData.nodePos; mNodeNeg=mData.nodeNeg; mName = mData.name; if (ACE_IS_NULL(mData.value)) ACE_ERROR("Resistor null"); mType = ACE_TYPE_RES; } /*stamp: U=Ri U=Vn-Vp <----------- ----|------->----|---> n i p | Vp | Vn | ___________________________ KCL(p) |-1/R | 1/R | ___________________________ KCL(n) |1/R | -1/R | */ void componentRES::stamp(){ //KCLs int vp,vn; //equationKCL *pk; vp=algo::spls->getIndexUnknown(ACE_TYPE_V,mData.nodePos); vn=algo::spls->getIndexUnknown(ACE_TYPE_V,mData.nodeNeg); //pk=; algo::spls->KCL(mData.nodePos)->mCoefs[vp]+=-1/mData.value; algo::spls->KCL(mData.nodePos)->mCoefs[vn]+=1/mData.value; algo::spls->KCL(mData.nodeNeg)->mCoefs[vp]+=1/mData.value; algo::spls->KCL(mData.nodeNeg)->mCoefs[vn]+=-1/mData.value; } void componentRES::print(){ componentLINEAR::print(); printf("\t value: %f\n",mData.value); } componentRES::~componentRES(){ }
9461a6659621ee0b8faaef9b95264deafac2fe04
7659d93d559e81e73c5d7dfc34ae84c28e180fec
/darkness-engine/shaders/ShaderTypes.h
760ebbe24c561bd058a9d0f6af80f6c26c492f74
[]
no_license
Karmiska/Darkness
d6905017025dd5b2cf591533ffcc21bd13a824ae
a9e35281307e8aa8843213f92804f6d74d145754
refs/heads/master
2023-07-23T10:19:41.900249
2023-07-09T11:00:33
2023-07-09T11:00:33
109,767,787
8
1
null
null
null
null
UTF-8
C++
false
false
9,134
h
ShaderTypes.h
#pragma once #include "tools/ByteRange.h" #include "engine/primitives/Matrix4.h" #include "engine/primitives/Vector4.h" #include "engine/primitives/Vector2.h" #include "engine/primitives/Vector3.h" #include "engine/graphics/CommonNoDep.h" #include "engine/graphics/Format.h" #include "shaders/ShaderPodTypes.h" #include <cstdint> #include "containers/memory.h" #include "containers/vector.h" #include "containers/string.h" namespace engine { namespace implementation { class PipelineImplDX12; class PipelineImplVulkan; class CommandListImplDX12; class CommandListImplVulkan; class DescriptorHeapImplDX12; class DescriptorHeapImplVulkan; class PipelineShadersDX12; class PipelineShadersVulkan; class PipelineRootSignatureDX12; class PipelineRootSignatureVulkan; } class ShaderBinary; class ShaderStorage; class Device; class Sampler; class TextureSRV; class TextureUAV; class Buffer; class BufferSRV; class BufferUAV; class BufferCBV; class RaytracingAccelerationStructure; class CommandList; class BufferCBVOwner; class BindlessTextureSRV; class BindlessTextureUAV; class BindlessBufferSRV; class BindlessBufferUAV; class RootConstant; namespace shaders { constexpr uint64_t FnvPrime = 1099511628211u; constexpr uint64_t FnvOffsetBasis = 14695981039346656037u; uint64_t fnv1aHash(uint64_t value, uint64_t hash = FnvOffsetBasis); constexpr uint64_t ResourceHashSeed = 1009; constexpr uint64_t ResourceHashFactor = 9176; struct ShaderInputParameter { engine::string name; engine::string semanticName; engine::string type; }; enum class BindingType { SRVTexture, SRVBuffer, UAVTexture, UAVBuffer, BindlessSRVTexture, BindlessSRVBuffer, BindlessUAVTexture, BindlessUAVBuffer, RaytracingAccelerationStructure }; struct Binding { BindingType type; uint32_t index; engine::ResourceDimension dimension; Format format; }; class Shader { public: virtual ~Shader() {}; protected: friend class implementation::PipelineImplDX12; friend class implementation::PipelineImplVulkan; friend class implementation::PipelineShadersDX12; friend class implementation::PipelineShadersVulkan; friend class implementation::PipelineRootSignatureDX12; friend class implementation::PipelineRootSignatureVulkan; friend class implementation::CommandListImplDX12; friend class implementation::CommandListImplVulkan; friend class implementation::DescriptorHeapImplDX12; friend class implementation::DescriptorHeapImplVulkan; friend class engine::CommandList; virtual engine::ResourceDimension textureDimension(const engine::string& name) const = 0; virtual size_t samplerCount() const = 0; virtual int currentPermutationId() const = 0; virtual engine::shared_ptr<const ShaderBinary> load(const Device& device, ShaderStorage& storage, GraphicsApi api) const = 0; virtual const engine::vector<TextureSRV>& texture_srvs() const = 0; virtual const engine::vector<TextureUAV>& texture_uavs() const = 0; virtual engine::vector<TextureSRV>& texture_srvs() = 0; virtual engine::vector<TextureUAV>& texture_uavs() = 0; virtual const engine::vector<unsigned char>& texture_srvs_is_cube() const = 0; virtual const engine::vector<unsigned char>& texture_uavs_is_cube() const = 0; virtual const engine::vector<Format>& texture_srvs_format() const = 0; virtual const engine::vector<Format>& texture_uavs_format() const = 0; virtual const engine::vector<BufferSRV>& buffer_srvs() const = 0; virtual const engine::vector<BufferUAV>& buffer_uavs() const = 0; virtual engine::vector<BufferSRV>& buffer_srvs() = 0; virtual engine::vector<BufferUAV>& buffer_uavs() = 0; virtual const engine::vector<RaytracingAccelerationStructure>& acceleration_structures() const = 0; virtual const engine::vector<unsigned char>& buffer_srvs_is_structured() const = 0; virtual const engine::vector<unsigned char>& buffer_uavs_is_structured() const = 0; virtual const engine::vector<Format>& buffer_srvs_format() const = 0; virtual const engine::vector<Format>& buffer_uavs_format() const = 0; virtual const engine::vector<const BindlessTextureSRV*>& bindless_texture_srvs() const = 0; virtual const engine::vector<const BindlessTextureUAV*>& bindless_texture_uavs() const = 0; virtual const engine::vector<const BindlessBufferSRV*>& bindless_buffer_srvs() const = 0; virtual const engine::vector<const BindlessBufferUAV*>& bindless_buffer_uavs() const = 0; virtual engine::vector<const BindlessTextureSRV*>& bindless_texture_srvs() = 0; virtual engine::vector<const BindlessTextureUAV*>& bindless_texture_uavs() = 0; virtual engine::vector<const BindlessBufferSRV*>& bindless_buffer_srvs() = 0; virtual engine::vector<const BindlessBufferUAV*>& bindless_buffer_uavs() = 0; virtual const engine::vector<const RootConstant*>& root_constants() const = 0; virtual const engine::vector<Binding>& srvBindings() const = 0; virtual const engine::vector<Binding>& uavBindings() const = 0; virtual void setDebugBuffer(BufferUAV debugOutputBuffer) = 0; virtual bool hasDebugBuffer() const = 0; virtual bool debugBufferIsSet() const = 0; struct ConstantRange { tools::ByteRange range; engine::shared_ptr<BufferCBVOwner> buffer; const char* name; }; virtual engine::vector<ConstantRange>& constants() = 0; virtual const engine::vector<Sampler>& samplers() const = 0; virtual const engine::vector<ShaderInputParameter>& inputParameters(int permutationIndex) const = 0; virtual engine::string shaderFilePath() const = 0; // returns the SET start index. virtual int setStartIndex() const = 0; virtual int setCount() const = 0; }; class VertexShader : public Shader {}; class PixelShader : public Shader {}; class GeometryShader : public Shader {}; class HullShader : public Shader {}; class DomainShader : public Shader {}; class ComputeShader : public Shader {}; class RaygenerationShader : public Shader {}; class IntersectionShader : public Shader {}; class MissShader : public Shader {}; class AnyHitShader : public Shader {}; class ClosestHitShader : public Shader {}; class AmplificationShader : public Shader {}; class MeshShader : public Shader {}; class PipelineConfiguration { public: virtual ~PipelineConfiguration() {}; virtual bool hasVertexShader() const = 0; virtual bool hasPixelShader() const = 0; virtual bool hasGeometryShader() const = 0; virtual bool hasHullShader() const = 0; virtual bool hasDomainShader() const = 0; virtual bool hasComputeShader() const = 0; virtual bool hasRaygenerationShader() const = 0; virtual bool hasIntersectionShader() const = 0; virtual bool hasMissShader() const = 0; virtual bool hasAnyHitShader() const = 0; virtual bool hasClosestHitShader() const = 0; virtual bool hasAmplificationShader() const = 0; virtual bool hasMeshShader() const = 0; virtual uint32_t descriptorCount() const = 0; virtual uint64_t hash(uint64_t hash = FnvOffsetBasis) const = 0; virtual const Shader* vertexShader() const = 0; virtual const Shader* pixelShader() const = 0; virtual const Shader* geometryShader() const = 0; virtual const Shader* hullShader() const = 0; virtual const Shader* domainShader() const = 0; virtual const Shader* computeShader() const = 0; virtual const Shader* raygenerationShader() const = 0; virtual const Shader* intersectionShader() const = 0; virtual const Shader* missShader() const = 0; virtual const Shader* anyHitShader() const = 0; virtual const Shader* closestHitShader() const = 0; virtual const Shader* amplificationShader() const = 0; virtual const Shader* meshShader() const = 0; virtual const char* pipelineName() const = 0; }; } Float4x4 fromMatrix(Matrix4f mat); }
af5461ef0515002b6c84995ea2f3828907b709ba
93343c49771b6e6f2952d03df7e62e6a4ea063bb
/HDOJ/1249_autoAC.cpp
7a1e853fd3fad6dbc65012251cadc1273684bf5a
[]
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
196
cpp
1249_autoAC.cpp
#include<stdio.h> int main() { int n,s=2,i,m; scanf("%d",&n); while(n--) { scanf("%d",&m); s+=6*(m-1); printf("%d\n",s); } return 0; }
d45ee50f5016ba36458782a8ea272b83ef6becd4
8f7b5b0efda15722f0c348734ad18aad7ff9565e
/Faceanomaly1Plugin/faceanomaly1plugin.cpp
ac63180bf8d791d9119c4599c5db47ab67119a6f
[]
no_license
charithwije/nooba-plugin-faceanomaly1
51675c3852f866b6ef1eda1023100db7c7d3924c
1cb12c2bca70b428171d68c7a32ff87cf1f07a67
refs/heads/master
2021-01-01T17:15:56.970277
2013-12-07T05:12:43
2013-12-07T05:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,883
cpp
faceanomaly1plugin.cpp
/*@file faceanomaly1plugin.cpp @author Charith Wijenayake <charithwije21@gmail.com> @section LICENSE Face Anomaly 1 API source file Copyright (C) 2013 Developed by Team Nooba This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "faceanomaly1plugin.h" #include <QtCore> #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/highgui/highgui.hpp> #include <QDebug> #include <QString> Faceanomaly1Plugin::Faceanomaly1Plugin() { } Faceanomaly1Plugin::~Faceanomaly1Plugin() { } bool Faceanomaly1Plugin::procFrame( const cv::Mat &in, cv::Mat &out, ProcParams &params ) { cv::cvtColor(in, out, CV_BGR2GRAY); return true; } bool Faceanomaly1Plugin::init() { faceThresholdParameter ="face threashold"; faceThresholdValue = "3"; threasholdFaceCount =3; createStringParam(faceThresholdParameter,faceThresholdValue,true); createFrameViewer("Output"); return true; } bool Faceanomaly1Plugin::release() { return true; } void Faceanomaly1Plugin::onStringParamChanged(const QString& varName, const QString& val){ if(varName.compare(faceThresholdParameter)==0){ threasholdFaceCount=val.split(" ")[0].toInt(); } } void Faceanomaly1Plugin::inputData(const QStringList& strList, QList<QImage> imageList){ int i; frameNum=strList.at(1); if (!strList.at(0).isEmpty()) i= strList.at(0).split(" ")[0].toInt(); if(!imageList.isEmpty()){ imageList.at(0); updateFrameViewer("Output",imageList.at(0).copy()); } if( i>=threasholdFaceCount){ debugMsg(QString("<FONT COLOR='#ff0000'>%1 faces detected on frame %2 ").arg(threasholdFaceCount).arg(frameNum)); generateAlert("Output","Too many people",nooba::RedAlert); } i=0; } PluginInfo Faceanomaly1Plugin::getPluginInfo() const { PluginInfo pluginInfo( "Faceanomaly1 Plugin", 0, 1, "Plugin Description goes here", "Plugin Creator"); return pluginInfo; } // see qt4 documentation for details on the macro (Qt Assistant app) // Mandatory macro for plugins in qt4. Made obsolete in qt5 #if QT_VERSION < 0x050000 Q_EXPORT_PLUGIN2(Faceanomaly1Plugin, Faceanomaly1Plugin); #endif
7103f93390aab018319b9f2ab2722cd8af80032f
77337f9ac278bfd6f5f885b53d9a6b345b120c44
/GRAPH/Bai047.cpp
ea18eef4fe041d6aa89c4febd60c7351c93caae3
[]
no_license
JackNguyen1209/ICPC_TryHard_
cd14a9f24e5d794978d827a665e9133e88fc47ff
a4d7a42266814189a27280dac6996809da0c5d64
refs/heads/main
2023-07-10T15:55:13.270627
2021-08-15T13:47:23
2021-08-15T13:47:23
367,665,016
0
0
null
null
null
null
UTF-8
C++
false
false
1,263
cpp
Bai047.cpp
/* Nguyen Duc Anh Phuc_Jacke */ #include "bits/stdc++.h" #include <unordered_set> #include <unordered_map> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<pll, ll>plll; const ll M = 1e9 + 7; class graph { private: vector<vector<ll>>g; ll n, m; public: ll sol() { //d(i,x): num of path to visit subset i finish at vertex u and start from 1 vector<vector<ll>>d((1LL << n) + 1, vector<ll>(n + 1, 0)); d[1][0] = 1; for (ll i = 0; i <= (1LL << n) - 1; i++) for (ll u = 0; u <= n - 1; u++) for (auto v : g[u]) { ll subset = i; if (((subset & (1LL << v)) == 0LL) && ((subset & (1LL << u)) != 0LL)) { d[subset | (1LL << v)][v] += d[subset][u]; d[subset | (1LL << v)][v] %= M; } } return d[(1LL << n) - 1][n - 1]; } void add(ll u, ll v) { g[u].push_back(v); } graph(ll nn, ll mm) { n = nn; m = mm; g.resize(n + 1); } }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n, m; cin >> n >> m; graph t(n, m); for (ll i = 1; i <= m; i++) { ll u, v; cin >> u >> v; u--; v--; t.add(u, v); } cout << t.sol(); return 0; }
4f115285ae43b7378ebf618edff1c2b6382f7882
6ecbf084f558b37f0cee51c7226c1e116b5aa7bf
/SIR/.SIR/build_openmp_sse/src/bi/netcdf/SMCNetCDFBuffer.cpp
3de9503f468e00e37b6c12cc04d56b62acedffd5
[]
no_license
reichlab/bayesian_non_parametric
364b12ad07b09e9a4386572bd47c709ad7629497
c8d7eb7493addb919b8f7159768dc732ce1a1f35
refs/heads/master
2021-01-01T06:43:10.176687
2018-03-25T14:33:32
2018-03-25T14:33:32
97,492,688
2
0
null
2018-01-02T15:23:21
2017-07-17T15:38:01
Python
UTF-8
C++
false
false
1,193
cpp
SMCNetCDFBuffer.cpp
/** * @file * * @author Pierre Jacob <jacob@ceremade.dauphine.fr> * $Rev $ * $Date$ */ #include "SMCNetCDFBuffer.hpp" #include <string> bi::SMCNetCDFBuffer::SMCNetCDFBuffer(const Model& m, const size_t P, const size_t T, const std::string& file, const FileMode mode, const SchemaMode schema) : MCMCNetCDFBuffer(m, P, T, file, mode, schema) { if (mode == NEW || mode == REPLACE) { create(); } else { map(); } } void bi::SMCNetCDFBuffer::create() { nc_redef(ncid); nc_put_att(ncid, "libbi_schema", "SMC"); nc_put_att(ncid, "libbi_schema_version", 1); nc_put_att(ncid, "libbi_version", PACKAGE_VERSION); lwVar = nc_def_var(ncid, "logweight", NC_REAL, npDim); nc_enddef(ncid); } void bi::SMCNetCDFBuffer::map() { std::vector<int> dimids; lwVar = nc_inq_varid(ncid, "logweight"); BI_ERROR_MSG(lwVar >= 0, "No variable logweight in file " << file); dimids = nc_inq_vardimid(ncid, lwVar); BI_ERROR_MSG(dimids.size() == 1, "Variable logweight has " << dimids.size() << " dimensions, should have 1, in file " << file); BI_ERROR_MSG(dimids[0] == npDim, "Only dimension of variable logweight should be np, in file " << file); }
8d76625de76c6e019a117af852b036f5bab0dde5
28f36227496f833f73951612e81d5d3d603e81fc
/GameEngine2D/src/Component/Transform/TransformPartialComponent.cpp
0110ae69d654a5043b041c3a643312fdd137edcb
[]
no_license
rishi-menon/Game-Engine-Udemy
65fef4e334114a4ea2114c1b7d259a109df63958
b707423c1164272ca776919b67223d0ea8cf120a
refs/heads/master
2022-10-11T10:40:33.730854
2020-06-11T04:22:10
2020-06-11T04:22:10
258,875,501
0
0
null
null
null
null
UTF-8
C++
false
false
3,260
cpp
TransformPartialComponent.cpp
#include "pch.h" #include "TransformPartialComponent.h" #include "Component/BoxColliderComponent.h" #include "Entity/Entity.h" #include "Collision/CollisionManager.h" TransformPartialComponent::TransformPartialComponent(const glm::vec2& pos, const glm::vec2& scale) : m_vPosition(pos), m_vScale(scale) { } TransformPartialComponent::~TransformPartialComponent() { } void TransformPartialComponent::GetRect(Engine::Rect& rect) const { rect.SetCenter(m_vPosition.x, m_vPosition.y, m_vScale.x, m_vScale.y); } Engine::Rect TransformPartialComponent::GetRect() const { Engine::Rect rect; GetRect(rect); return rect; } inline void TransformPartialComponent::AddToCollisionListHelper () { ASSERT(m_pEntityOwner); BoxColliderComponent* pBoxCollider = m_pEntityOwner->GetComponent<BoxColliderComponent>(); if (pBoxCollider) { Engine::CollisionManager::AddToCollisionList(pBoxCollider); } } void TransformPartialComponent::Translate(float dx, float dy) { m_vPosition.x += dx; m_vPosition.y += dy; AddToCollisionListHelper(); } void TransformPartialComponent::Translate(const glm::vec2& offset) { Translate (offset.x, offset.y); } void TransformPartialComponent::SetPosition(float x, float y) { m_vPosition.x = x; m_vPosition.y = y; AddToCollisionListHelper(); } void TransformPartialComponent::SetPosition(const glm::vec2& pos) { SetPosition(pos.x, pos.y); } void TransformPartialComponent::SetPositionWithoutCollision(float x, float y) { m_vPosition.x = x; m_vPosition.y = y; } void TransformPartialComponent::SetPositionWithoutCollision(const glm::vec2& pos) { SetPositionWithoutCollision(pos.x, pos.y); } void TransformPartialComponent::SetScale(float x, float y) { m_vScale.x = x; m_vScale.y = y; } void TransformPartialComponent::SetScale(const glm::vec2& pos) { SetScale(pos.x, pos.y); } bool TransformPartialComponent::SetValueTable(const sol::table& table) { if (!Component::SetValueTable(table)) { ASSERT(false); return false; } //Translation { sol::optional<sol::table> positionTable = table["Position"]; if (!positionTable) return false; sol::optional<float> posX = positionTable.value()["X"]; sol::optional<float> posY = positionTable.value()["Y"]; if (!posX || !posY) { return false; } m_vPosition.x = posX.value(); m_vPosition.y = posY.value(); } //Scale { sol::optional<sol::table> scaleTable = table["Scale"]; if (!scaleTable) return false; sol::optional<float> scaleX = scaleTable.value()["X"]; sol::optional<float> scaleY = scaleTable.value()["Y"]; if (!scaleX || !scaleY) { return false; } m_vScale.x = scaleX.value(); m_vScale.y = scaleY.value(); } return true; } std::string TransformPartialComponent::SaveComponentToLua(bool bAddMoreLines) const { std::string strLua; strLua.reserve(100); strLua += Component::SaveComponentToLua(); strLua += StringR::Format("\tPosition = { X = %.1f, Y = %.1f },\n", m_vPosition.x, m_vPosition.y); strLua += StringR::Format("\tScale = { X = %.1f, Y = %.1f }", m_vScale.x, m_vScale.y); if (bAddMoreLines) { strLua += ','; } strLua += '\n'; return strLua; }
01b47969c49234484d988fac1ce1dacd1f266993
207571a7c6f1e55f1f6a3f5cb5fd7f1da3777cfb
/src/Screen.cpp
4394760d191ad7a7d60d1712e5bc7684b0f3a80b
[]
no_license
likoms/Graph
a84c0fab9e6599e2d661ed4de68bd12ee67708c7
d3d588fe74cd6b0c122f5891a26c4f78612c85ed
refs/heads/master
2021-01-13T02:22:16.532443
2015-05-09T09:32:45
2015-05-09T09:32:45
34,457,392
0
0
null
null
null
null
UTF-8
C++
false
false
1,819
cpp
Screen.cpp
/* * Screen.cpp * * Created on: 23 kwi 2015 * Author: Piotr */ #include "Screen.h" Screen::Screen() { } Screen::~Screen() { } int Screen::displayFirstScreen(){ int choice=0; cout<<"_________ ________|"<<endl; cout<<"1. Tablica |"<<endl; cout<<"2. Lista |"<<endl; cout<<"3. Kopiec |"<<endl; cout<<"4. Zamknij program |"<<endl; cout<<"__________________________________|"<<endl << endl; cout<<"#Wybieram: "; cin>>choice; this->clearScreen(); return choice; } void Screen::clearScreen(){ #ifdef _WIN32 system("cls"); #else system("clear"); #endif } void Screen::wait(){ cin.get(); cin.get(); } int Screen::displaySecondScreen(){ int choice=0; cout<<"_____Wczytaj dane do struktury____|"<<endl; cout<<"1. Zbuduj |"<<endl; cout<<"2. Utworz losowo |"<<endl; cout<<"3. Powrot |"<<endl; cout<<"___________________________________|"<<endl << endl; cin>>choice; this->clearScreen(); return choice; } int Screen::displayThirdScreen(){ int choice=0; cout<<"______Operacje na strukturze______|"<<endl; cout<<"1.Dodaj element |"<<endl; cout<<"2.Usun element |"<<endl; cout<<"3.Wyszukaj element |"<<endl; cout<<"4.Wyswietl |"<<endl; cout<<"5.Powrot |"<<endl; cout<<"__________________________________|"<<endl << endl; cin>>choice; this->clearScreen(); return choice; } string Screen::askForFilename(){ string data; cout << "Podaj nazwe pliku: "; cin >> data; return data; }
514d9c85a02edae8643ab8d741b765d8ea16f1a1
b1fba55d02d3998d29185383019989d93d6c46a2
/src/NRRR_rcpp.cpp
4e9b1b42ff4b03b8e67e457f8f97cb84c16269be
[ "MIT" ]
permissive
xliu-stat/NRRR
ebb0ed1be0cf2304ab851b2aa06de721b765af2f
e51d9df7500b287f8c4daa8839f4cc1782525cef
refs/heads/master
2023-02-11T02:08:58.543146
2021-01-07T03:49:27
2021-01-07T03:49:27
320,651,801
0
0
null
null
null
null
UTF-8
C++
false
false
31,558
cpp
NRRR_rcpp.cpp
// [[Rcpp::depends(RcppArmadillo)]] #include <RcppArmadillo.h> #include <cmath> using namespace Rcpp; // [[Rcpp::export]] Rcpp::List pinv_my(arma::mat Bg){ /* the same as ginv() in R*/ arma::mat U; arma::vec s; arma::mat V; bool pinv_success = true; int p = Bg.n_cols; int q = Bg.n_rows; arma::mat inv_mat(p, q); int i; int l, r=0; double tol; //bool svd_success = svd(U, s, V, Bg, "std"); bool svd_success = svd(U, s, V, Bg); if (svd_success == false) { pinv_success = false; inv_mat.zeros(); } else { l = s.n_elem; arma::vec s1(l); tol = s(0)*1.490116e-08; for (i=0; i<l; i++){ if (s(i) > tol) { s1(i) = s(i); r = r + 1; } else { s1(i) = 0.0; } } inv_mat = V.head_cols(r) * diagmat(1/s1.head(r)) * U.head_cols(r).t(); } return Rcpp::List::create(pinv_success, inv_mat); } // [[Rcpp::export]] Rcpp::List rrr_my(arma::mat X, arma::mat Y, int r){ /* almost the same as RRR in R */ bool rrr_success = true; Rcpp::List inv_X0; inv_X0 = pinv_my(X.t()*X); bool inv_X0_err; inv_X0_err = inv_X0[0]; arma::mat Bl; arma::mat Al; arma::mat inv_X_mat; if (inv_X0_err == true){ arma::mat inv_X_mat0 = inv_X0[1]; inv_X_mat = inv_X_mat0; } else if (inv_X0_err == false) { int p = X.n_cols; Rcpp::List inv_X = pinv_my(X.t()*X + 0.1 * arma::eye(p, p)); arma::mat inv_X_mat0 = inv_X[1]; inv_X_mat = inv_X_mat0; } arma::mat fit_now = inv_X_mat * X.t() * Y; arma::mat proj_mat = X * fit_now; arma::mat U1; arma::vec s1; arma::mat V1; //svd(U1, s1, V1, proj_mat, "std"); bool svd_success = true; svd_success = svd(U1, s1, V1, proj_mat); if (svd_success == true){ Bl = fit_now * V1.cols(0, r-1); Al = V1.cols(0, r-1); } else { arma::mat SS = Y.t() * X * fit_now; SS = (SS + SS.t())/2.0; arma::vec eigval; arma::mat eigvec; rrr_success = eig_sym(eigval, eigvec, SS); arma::mat SS_r = eigvec.tail_cols(r); Bl = fit_now * SS_r; Al = SS_r; } return Rcpp::List::create(Bl, Al, rrr_success); } // [[Rcpp::export]] Rcpp::List BLCD(arma::mat X, arma::mat Y, arma::mat Xl0, arma::mat Yl0, arma::mat Ag0, arma::mat Bg0, arma::mat Al0, arma::mat Bl0, int n, int r, int d, int p, int rx, int ry, int jx, int jy, int maxiter, double conv ){ /* Notations: Ag -> U Bg -> V Bl0 -> A Bl0 -> B Xl, Xl0 -> X (I_jx \otimes V) Yl, Yl0 -> Y (I_jy \otimes U) */ arma::vec obj(maxiter+1); obj.fill(0.0); arma::vec err_flag(maxiter+1); err_flag.zeros(); double objnow; int iter = 0; int j, a1, a2, b1, b2; /* begin of Obj function */ arma::mat Bl(jx*p, r); // here Bl -> (I_jx \otimes V)*B arma::mat Al(jy*d, r); // here Al -> (I_jy \otimes U)*A arma::mat C(jx*p, jy*d); // here C -> Y=XC arma::mat XC(n, jy*d); arma::mat E(n, jy*d); double sse; if ( Bg0.n_rows != Bg0.n_cols ){ Bl = kron(arma::eye(jx, jx), Bg0) * Bl0; } else { Bl = Bl0; } if ( Ag0.n_rows != Ag0.n_cols ) { Al = kron(arma::eye(jy, jy), Ag0) * Al0; } else { Al = Al0; } C = Bl * Al.t(); XC = X * C; E = Y - XC; sse = accu(E % E); /* end of Obj function */ obj(0) = sse; objnow = sse + 10.0; arma::mat Ag1(d, ry); arma::mat Bg1(p, rx); arma::mat Al1(jy*ry, r); arma::mat Bl1(jx*rx, r); arma::mat Xg(n, jy*ry); arma::mat Yg0(d, ry); arma::vec yB(n*r); arma::mat XB(n * r, rx * p); arma::vec Bg1_vec(p*rx); //arma::mat fit_now(jx*rx, jy*ry); //arma::mat proj_mat(jy*ry, jy*ry); while ( (iter < maxiter) && (std::abs(obj(iter) - objnow) > conv) ) { /* update Ag (U) */ if ( d == ry ) { Ag1 = arma::eye(ry, ry); Yl0 = Y; } else { Xg = Xl0 * Bl0 * Al0.t(); Yg0.zeros(); for (j = 0; j < jy; j++) { a1 = d * (j + 1 - 1) + 1 - 1; b1 = d * (j + 1) - 1; a2 = ry * (j + 1 - 1) + 1 - 1; b2 = ry * (j + 1) - 1; Yg0 = Yg0 + Y.cols(a1,b1).t() * Xg.cols(a2,b2); } arma::mat U; arma::vec s; arma::mat V; bool svd_Ag = svd_econ( U, s, V, Yg0, "both", "std" ); if (svd_Ag == false) { err_flag(iter) = 1; break; } else { err_flag(iter) = 0; } Ag1 = U * V.t(); Yl0 = Y * kron(arma::eye(jy, jy), Ag1); } /* update Bg (V) */ if ( p == rx) { Bg1 = arma::eye(rx, rx); Xl0 = X; } else { yB = vectorise(Yl0 * Al0); XB.zeros(); for (j = 0; j < jx; j++) { a1 = rx * (j + 1 - 1) + 1 - 1; b1 = rx * (j + 1) - 1; a2 = p * (j + 1 - 1) + 1 - 1; b2 = p * (j + 1) - 1; XB = XB + kron( Bl0.rows(a1, b1).t(), X.cols(a2, b2)); } //Bg1_vec = pinv(XB.t()*XB + 0.0000001 * arma::eye(rx*p, rx*p), 1.490116e-08, "std") * XB.t() * yB; Rcpp::List inv_XB = pinv_my(XB.t()*XB + 0.0000001 * arma::eye(rx*p, rx*p)); bool inv_XB_err = inv_XB[0]; arma::mat inv_XB_mat = inv_XB[1]; if (inv_XB_err == false) { err_flag(iter) = 2; break; } Bg1_vec = inv_XB_mat * XB.t() * yB; Bg1 = reshape(Bg1_vec, p, rx); arma::mat Q; arma::mat R; bool svd_Bg = arma::qr_econ(Q, R, Bg1); if (svd_Bg == false) { err_flag(iter) = 3; break; } Bg1 = Q; Xl0 = X * kron(arma::eye(jx, jx), Bg1); } /* update Al (A) and Bl (B) */ /* RRR start */ Rcpp::List inv_X0 = pinv_my(Xl0.t()*Xl0); bool inv_X0_err = inv_X0[0]; if (inv_X0_err == true){ arma::mat inv_X_mat = inv_X0[1]; arma::mat fit_now = inv_X_mat * Xl0.t() * Yl0; arma::mat proj_mat = Xl0 * fit_now; arma::mat U2; arma::vec s2; arma::mat V2; bool svd_RRR = svd(U2, s2, V2, proj_mat, "std"); if (svd_RRR == false) { err_flag(iter) = 4; break; } Bl1 = fit_now * V2.cols(0, r-1); Al1 = V2.cols(0, r-1); } else if (inv_X0_err == false) { Rcpp::List inv_X = pinv_my(Xl0.t()*Xl0 + 0.1 * arma::eye(jx *rx, jx*rx)); arma::mat inv_X_mat = inv_X[1]; arma::mat fit_now = inv_X_mat * Xl0.t() * Yl0; arma::mat proj_mat = Xl0 * fit_now; arma::mat U2; arma::vec s2; arma::mat V2; bool svd_RRR = svd(U2, s2, V2, proj_mat, "std"); if (svd_RRR == false) { err_flag(iter) = 4; break; } Bl1 = fit_now * V2.cols(0, r-1); Al1 = V2.cols(0, r-1); } /* RRR end */ iter++; /* start of Obj function */ if ( Bg1.n_rows != Bg1.n_cols ){ Bl = kron(arma::eye(jx, jx), Bg1) * Bl1; } else { Bl = Bl1; } if ( Ag1.n_rows != Ag1.n_cols ) { Al = kron(arma::eye(jy, jy), Ag1) * Al1; } else { Al = Al1; } C = Bl * Al.t(); XC = X * C; E = Y - XC; sse = accu(E % E); /* end of Obj function */ obj(iter) = sse; objnow = obj(iter - 1); Al0 = Al1; Bl0 = Bl1; Ag0 = Ag1; Bg0 = Bg1; } if ((iter == maxiter) && (std::abs(obj(iter) - objnow) > conv)) { err_flag(iter) = 5; } //formulate output arma::vec output_obj = obj.subvec(0, iter); arma::vec output_err = err_flag; int output_iter = iter + 1; return Rcpp::List::create(Rcpp::Named("sse") = sse, Rcpp::Named("C") = C, Rcpp::Named("Ag1") = Ag1, Rcpp::Named("Bg1") = Bg1, Rcpp::Named("Al1") = Al0, Rcpp::Named("Bl1") = Bl0, Rcpp::Named("obj") = output_obj, Rcpp::Named("err") = output_err, Rcpp::Named("iter") = output_iter );} // [[Rcpp::export]] Rcpp::List nrrr_init_my( arma::mat Y, arma::mat X, int r, int rx, int ry, int jx, int jy, int p, int d, int n ){ Rcpp::List Cr_list = rrr_my(X, Y, r); arma::mat Cr1 = Cr_list[0]; arma::mat Cr2 = Cr_list[1]; arma::mat Crr = Cr1 * Cr2.t(); arma::mat Bghat; arma::mat Aghat; arma::mat Cbg(p, d*jy*jx); arma::mat Cag(d, p*jy*jx); int j, a1, b1, a2, b2; /* get V */ if ( p == rx ){ Bghat = arma::eye(rx, rx); } else { for (j=0; j<jx; j++){ a1 = d * jy * j; b1 = d * jy * (j + 1) - 1; a2 = p * j; b2 = p * (j + 1) - 1; Cbg.cols(a1, b1) = Crr.rows(a2, b2); } arma::mat U; arma::vec s; arma::mat V; //svd(U, s, V, Cbg, "std"); svd(U, s, V, Cbg); Bghat = U.cols(0, rx-1); } /* get U */ if ( d == ry ){ Aghat = arma::eye(ry, ry); } else { for (j=0; j<jy; j++){ a1 = p * jx * j; b1 = p * jx * (j + 1) - 1; a2 = d * j; b2 = d * (j + 1) - 1; Cag.cols(a1, b1) = Crr.cols(a2, b2).t(); } arma::mat U1; arma::vec s1; arma::mat V1; //svd(U1, s1, V1, Cag, "std"); svd(U1, s1, V1, Cag); Aghat = U1.cols(0, ry-1); } return Rcpp::List::create(Aghat, Bghat, Crr); } // [[Rcpp::export]] Rcpp::List nrrr_est_my( arma::mat Y, arma::mat X, int rini, int r, int rx, int ry, int jx, int jy, int p, int d, int n, int maxiter, double conv, int method, double lambda ){ /* method: 1-RRR, 2-RRS */ if ( ( method == 2 )&&( lambda > 0.0 ) ){ Y = join_cols(Y, arma::zeros(p*jx, d*jy)); X = join_cols(X, sqrt(lambda)*arma::eye(p*jx, p*jx)); n = n + p*jx; } arma::mat Ag0; arma::mat Bg0; //if ( (Ag0 == NULL) || (Bg0 == NULL) ){ Rcpp::List ini_res = nrrr_init_my(Y, X, rini, rx, ry, jx, jy, p, d, n); arma::mat ini_res_Ag0 = ini_res[0]; arma::mat ini_res_Bg0 = ini_res[1]; Ag0 = ini_res_Ag0; Bg0 = ini_res_Bg0; //} arma::mat Yl0; arma::mat Xl0; if (d == ry){ Yl0 = Y; } else { Yl0 = Y * kron(arma::eye(jy, jy), Ag0); } if (p == rx){ Xl0 = X; } else { Xl0 = X * kron(arma::eye(jx, jx), Bg0); } /* given U and V, compute Al, Bl */ arma::mat Bl0; arma::mat Al0; Rcpp::List fitRR = rrr_my(Xl0, Yl0, r); arma::mat fitRR_Bl0 = fitRR[0]; arma::mat fitRR_Al0 = fitRR[1]; Bl0 = fitRR_Bl0; Al0 = fitRR_Al0; /*---------------------- BLCD start ----------------------*/ arma::vec obj(maxiter+1); obj.fill(0.0); arma::vec err_flag(maxiter+1); err_flag.zeros(); int any_err = 0; double objnow; int iter = 0; int j, a1, a2, b1, b2; /*-------- begin of Obj function -------*/ arma::mat Bl(jx*p, r); // here Bl -> (I_jx \otimes V)*B arma::mat Al(jy*d, r); // here Al -> (I_jy \otimes U)*A arma::mat C(jx*p, jy*d); // here C -> Y=XC arma::mat XC(n, jy*d); arma::mat E(n, jy*d); double sse; if ( Bg0.n_rows != Bg0.n_cols ){ Bl = kron(arma::eye(jx, jx), Bg0) * Bl0; } else { Bl = Bl0; } if ( Ag0.n_rows != Ag0.n_cols ) { Al = kron(arma::eye(jy, jy), Ag0) * Al0; } else { Al = Al0; } C = Bl * Al.t(); XC = X * C; E = Y - XC; sse = accu(E % E); /* ------- end of Obj function ---------*/ obj(0) = sse; objnow = sse + 10.0; arma::mat Ag1(d, ry); arma::mat Bg1(p, rx); arma::mat Al1(jy*ry, r); arma::mat Bl1(jx*rx, r); arma::mat Xg(n, jy*ry); arma::mat Yg0(d, ry); arma::vec yB(n*r); arma::mat XB(n * r, rx * p); arma::vec Bg1_vec(p*rx); while ( (iter < maxiter) && (std::abs(obj(iter) - objnow) > conv) ) { /* update Ag (U) */ if ( d == ry ) { Ag1 = arma::eye(ry, ry); Yl0 = Y; } else { Xg = Xl0 * Bl0 * Al0.t(); Yg0.zeros(); for (j = 0; j < jy; j++) { a1 = d * j; b1 = d * (j + 1) - 1; a2 = ry * j; b2 = ry * (j + 1) - 1; Yg0 = Yg0 + Y.cols(a1,b1).t() * Xg.cols(a2,b2); } arma::mat U; arma::vec s; arma::mat V; //bool svd_Ag = svd_econ( U, s, V, Yg0, "both", "std" ); bool svd_Ag = svd_econ( U, s, V, Yg0, "both"); if (svd_Ag == false) { err_flag(iter) = 1; break; } else { err_flag(iter) = 0; } Ag1 = U * V.t(); Yl0 = Y * kron(arma::eye(jy, jy), Ag1); } /* update Bg (V) */ if ( p == rx) { Bg1 = arma::eye(rx, rx); Xl0 = X; } else { yB = vectorise(Yl0 * Al0); XB.zeros(); for (j = 0; j < jx; j++) { a1 = rx * j; b1 = rx * (j + 1) - 1; a2 = p * j; b2 = p * (j + 1) - 1; XB = XB + kron( Bl0.rows(a1, b1).t(), X.cols(a2, b2)); } Rcpp::List inv_XB = pinv_my(XB.t()*XB + 0.0000001 * arma::eye(rx*p, rx*p)); bool inv_XB_err = inv_XB[0]; arma::mat inv_XB_mat = inv_XB[1]; if (inv_XB_err == false) { err_flag(iter) = 2; break; } Bg1_vec = inv_XB_mat * XB.t() * yB; Bg1 = reshape(Bg1_vec, p, rx); arma::mat Q; arma::mat R; bool svd_Bg = arma::qr_econ(Q, R, Bg1); if (svd_Bg == false) { err_flag(iter) = 3; break; } Bg1 = Q; Xl0 = X * kron(arma::eye(jx, jx), Bg1); } /* update Al (A) and Bl (B) */ Rcpp::List fitRR = rrr_my(Xl0, Yl0, r); arma::mat fitRR_Bl1 = fitRR[0]; arma::mat fitRR_Al1 = fitRR[1]; bool fitRR_success = fitRR[2]; if (fitRR_success == false) { err_flag(iter) = 4; break; } Bl1 = fitRR_Bl1; Al1 = fitRR_Al1; /* --------- RRR start ---------- Rcpp::List inv_X0 = pinv_my(Xl0.t()*Xl0); bool inv_X0_err = inv_X0[0]; if (inv_X0_err == true){ arma::mat inv_X_mat = inv_X0[1]; arma::mat fit_now = inv_X_mat * Xl0.t() * Yl0; arma::mat proj_mat = Xl0 * fit_now; arma::mat U2; arma::vec s2; arma::mat V2; //bool svd_RRR = svd(U2, s2, V2, proj_mat, "std"); bool svd_RRR = svd(U2, s2, V2, proj_mat); if (svd_RRR == false) { err_flag(iter) = 4; break; } Bl1 = fit_now * V2.cols(0, r-1); Al1 = V2.cols(0, r-1); } else if (inv_X0_err == false) { Rcpp::List inv_X = pinv_my(Xl0.t()*Xl0 + 0.1 * arma::eye(jx *rx, jx*rx)); arma::mat inv_X_mat = inv_X[1]; arma::mat fit_now = inv_X_mat * Xl0.t() * Yl0; arma::mat proj_mat = Xl0 * fit_now; arma::mat U2; arma::vec s2; arma::mat V2; //bool svd_RRR = svd(U2, s2, V2, proj_mat, "std"); bool svd_RRR = svd(U2, s2, V2, proj_mat); if (svd_RRR == false) { err_flag(iter) = 4; break; } Bl1 = fit_now * V2.cols(0, r-1); Al1 = V2.cols(0, r-1); } -------- RRR end ---------*/ iter++; /*-------- start of Obj function --------*/ if ( Bg1.n_rows != Bg1.n_cols ){ Bl = kron(arma::eye(jx, jx), Bg1) * Bl1; } else { Bl = Bl1; } if ( Ag1.n_rows != Ag1.n_cols ) { Al = kron(arma::eye(jy, jy), Ag1) * Al1; } else { Al = Al1; } C = Bl * Al.t(); XC = X * C; E = Y - XC; sse = accu(E % E); /*-------- end of Obj function --------*/ obj(iter) = sse; objnow = obj(iter - 1); Al0 = Al1; Bl0 = Bl1; Ag0 = Ag1; Bg0 = Bg1; } if ( (iter == maxiter) && (std::abs(obj(iter) - objnow) > conv) ) { err_flag(iter) = 5; } /*---------------------- BLCD end ----------------------*/ int err_which = sum(err_flag); if ( err_which != 0 ) { any_err = 1; } double xr = arma::rank(X, 0.01); double df0; if (xr > jx*rx) { df0 = rx * (xr/jx - rx); } else { df0 = 0.0; } double df = df0 + ry * (d - ry) + (jy * ry + jx * rx - r) * r; if (sse < 0.1) { sse = 0.0; } if (method == 2) { sse = sse - lambda * accu(C % C); } arma::vec ic(4); ic(0) = log(sse) + log(d * jy * n) * df / (d * jy * n) ; ic(1) = log(sse) + 2 * log(d * jy * p * jx) * df / (d * jy * n); ic(2) = log(sse) + 2 * df / (d * jy * n); ic(3) = sse / (d * jy * n * (1 - df / (d * jy * n)) * (1 - df / (d * jy * n))); //formulate output arma::vec output_obj = obj.subvec(0, iter); int output_iter = iter + 1; return Rcpp::List::create(Rcpp::Named("Ag") = Ag1, Rcpp::Named("Bg") = Bg1, Rcpp::Named("Al") = Al1, Rcpp::Named("Bl") = Bl1, Rcpp::Named("C") = C, Rcpp::Named("df") = df, Rcpp::Named("err_flag") = any_err, Rcpp::Named("err_which") = err_which, Rcpp::Named("sse") = sse, Rcpp::Named("ic") = ic, Rcpp::Named("obj") = output_obj, Rcpp::Named("iter") = output_iter ); } // [[Rcpp::export]] Rcpp::List nrrr_select_my(arma::mat Y, arma::mat X, int xr, int rfit, int xrankfix, int yrankfix, int jx, int jy, int p, int d, int n, int ic, int maxiter, double conv, int method, double lambda, int dimred1, int dimred2, int dimred3 ){ /* ic: 0-BIC, 1-BICP, 2-AIC, 3-GCV */ /* method: 1-RRR, 2-RRS */ int rest = rfit; int i, j, l; int rxfit, ryfit; int rxest, ryest; int r_length = std::min(jx*p, jy*d); arma::uword min_ind; arma::vec rxErrseq(p); arma::vec ryErrseq(d); arma::vec rErrseq(r_length); /* select rx */ if ( dimred2 == 1 ){ arma::vec rxfitseq(p); arma::vec icseq_x(p); ryfit = d; for (i=0; i<p; i++){ rxfitseq(i) = i + 1; rxfit = i + 1; Rcpp::List fit1 = nrrr_est_my(Y,X,rfit,rfit,rxfit,ryfit,jx,jy,p, d,n,maxiter,conv, method,lambda); arma::vec fit1_ic = fit1[9]; icseq_x(i) = fit1_ic(ic); rxErrseq(i) = fit1[7]; } min_ind = index_min(icseq_x); rxest = rxfitseq(min_ind); } else { if (xrankfix == 0) { rxest = p; } else { rxest = xrankfix; } } rxfit = rxest; /* select ry */ if ( dimred3 == 1 ){ arma::vec ryfitseq(d); arma::vec icseq_y(d); for (i=0; i<d; i++){ ryfitseq(i) = i + 1; ryfit = i + 1; Rcpp::List fit1 = nrrr_est_my(Y,X,rfit,rfit,rxfit,ryfit,jx,jy,p, d,n,maxiter,conv, method,lambda); arma::vec fit1_ic = fit1[9]; icseq_y(i) = fit1_ic(ic); ryErrseq(i) = fit1[7]; } min_ind = index_min(icseq_y); ryest = ryfitseq(min_ind); } else { if (yrankfix == 0) { ryest = d; } else { ryest = yrankfix; } } ryfit = ryest; /* refine r */ if ( dimred1 == 1 ){ arma::vec r_range(4); r_range(0) = n; r_range(1) = p*jx; r_range(2) = d*jy; r_range(3) = rest + 5; int a = std::max(1, rest - 5); int b = arma::min(r_range); r_length = b - a + 1; arma::vec rfitseq(r_length); for (j=a; j< b + 1; j++){ rfitseq(j-a) = j; } arma::vec icseq_r(r_length); for (l=0; l< r_length; l++){ rfit = rfitseq(l); Rcpp::List fit1 = nrrr_est_my(Y,X,rfit,rfit,rxfit,ryfit,jx,jy,p, d,n,maxiter,conv, method,lambda); arma::vec fit1_ic = fit1[9]; icseq_r(l) = fit1_ic(ic); rErrseq(l) = fit1[7]; } min_ind = index_min(icseq_r); rest = rfitseq(min_ind); } Rcpp::List fit_final = nrrr_est_my(Y,X,rest,rest,rxfit,ryfit,jx,jy,p, d,n,maxiter,conv, method,lambda); arma::vec rErrseq_output = rErrseq.subvec(0, r_length-1); return Rcpp::List::create(Rcpp::Named("Ag") = fit_final[0], Rcpp::Named("Bg") = fit_final[1], Rcpp::Named("Al") = fit_final[2], Rcpp::Named("Bl") = fit_final[3], Rcpp::Named("C") = fit_final[4], Rcpp::Named("df") = fit_final[5], Rcpp::Named("sse") = fit_final[8], Rcpp::Named("ic") = fit_final[9], Rcpp::Named("obj") = fit_final[10], Rcpp::Named("rank") = rest, Rcpp::Named("rx") = rxest, Rcpp::Named("ry") = ryest, Rcpp::Named("rxErrseq") = rxErrseq, Rcpp::Named("ryErrseq") = ryErrseq, Rcpp::Named("rErrseq") = rErrseq_output ); } // [[Rcpp::export]] arma::mat del_rows(arma::mat X, arma::uvec e){ X.shed_rows(e); return X; } // [[Rcpp::export]] Rcpp::List nrrr_cv_my(arma::mat Y, arma::mat X, arma::uvec norder, int nfold, int xr, int rfit, int xrankfix, int yrankfix, int jx, int jy, int p, int d, int n, int maxiter, int method, int dimred1, int dimred2, int dimred3, double conv, double lambda ){ /* method: 1-RRR, 2-RRS */ /* xrankfix: 0-null, others-specified rx */ int rest; rest = rfit; int ndel; int f, i, nf; arma::uvec iddel; arma::mat Xf; arma::mat Xfdel; arma::mat Yf; arma::mat Yfdel; int rxfit, ryfit; int rxest, ryest; arma::mat rxErrmat(p,nfold); rxErrmat.zeros(); arma::mat ryErrmat(d,nfold); ryErrmat.zeros(); ndel = round(n/nfold); /* select rx */ arma::mat rx_path(p, nfold); rx_path.zeros(); if (p == 1) { rxest = p; } else { if (dimred2 == 1){ arma::vec rxfitseq(p); for (f=0; f<nfold; f++){ if (f != nfold - 1){ iddel = norder.subvec(ndel * f, ndel * (f + 1) - 1); } else { iddel = norder.subvec(ndel * f, n-1); } ndel = iddel.n_elem; nf = n - ndel; Xf = del_rows(X, iddel); Xfdel = X.rows(iddel); Yf = del_rows(Y, iddel); Yfdel = Y.rows(iddel); ryfit = d; for (i=0; i<p; i++){ rxfit = i + 1; rxfitseq(i) = i + 1; Rcpp::List fit1 = nrrr_est_my(Yf,Xf,rfit,rfit,rxfit,ryfit,jx,jy,p, d,nf,maxiter,conv, method,lambda); arma::mat C_est = fit1[4]; rx_path(i, f) = accu( arma::square(Yfdel - Xfdel * C_est) ); rxErrmat(i, f) = fit1[7]; } } arma::vec crerr = arma::sum(rx_path, 1); rxest = rxfitseq(index_min(crerr)); } else { if (xrankfix == 0) { rxest = p; } else { rxest = xrankfix; } } } rxfit = rxest; /* select ry */ arma::mat ry_path(d, nfold); ry_path.zeros(); if (d == 1) { ryest = d; } else { if (dimred3 == 1){ arma::vec ryfitseq(d); for (f=0; f<nfold; f++){ if (f != nfold - 1){ iddel = norder.subvec(ndel * f, ndel * (f + 1) - 1); } else { iddel = norder.subvec(ndel * f, n-1); } ndel = iddel.n_elem; nf = n - ndel; Xf = del_rows(X, iddel); Xfdel = X.rows(iddel); Yf = del_rows(Y, iddel); Yfdel = Y.rows(iddel); for (i=0; i<d; i++){ ryfit = i + 1; ryfitseq(i) = i + 1; Rcpp::List fit1 = nrrr_est_my(Yf,Xf,rfit,rfit,rxfit,ryfit,jx,jy,p, d,nf,maxiter,conv, method,lambda); arma::mat C_est = fit1[4]; ry_path(i, f) = accu( arma::square(Yfdel - Xfdel * C_est) ); ryErrmat(i, f) = fit1[7]; } } arma::vec crerr = arma::sum(ry_path, 1); ryest = ryfitseq(index_min(crerr)); } else { if (yrankfix == 0) { ryest = d; } else { ryest = yrankfix; } } } ryfit = ryest; /* refine r */ arma::vec r_range(4); r_range(0) = n; r_range(1) = p*jx; r_range(2) = d*jy; r_range(3) = rest + 5; int a = std::max(1, rest - 5); int b = arma::min(r_range); int r_length = b - a + 1; arma::vec rfitseq(r_length); arma::mat r_path(r_length, nfold); r_path.zeros(); arma::mat rErrmat(r_length, nfold); rErrmat.zeros(); if ( dimred1 == 1 ){ for (f=0; f<nfold; f++){ if (f != nfold - 1){ iddel = norder.subvec(ndel * f, ndel * (f + 1) - 1); } else { iddel = norder.subvec(ndel * f, n-1); } ndel = iddel.n_elem; nf = n - ndel; Xf = del_rows(X, iddel); Xfdel = X.rows(iddel); Yf = del_rows(Y, iddel); Yfdel = Y.rows(iddel); for (i=a; i<b+1; i++){ rfit = i; rfitseq(i-a) = i; Rcpp::List fit1 = nrrr_est_my(Yf,Xf,rfit,rfit,rxfit,ryfit,jx,jy,p, d,nf,maxiter,conv, method,lambda); arma::mat C_est = fit1[4]; r_path(i-a, f) = accu( arma::square(Yfdel - Xfdel * C_est) ); rErrmat(i-a, f) = fit1[7]; } } arma::vec crerr = arma::sum(r_path, 1); rest = rfitseq(index_min(crerr)); } Rcpp::List fit_final = nrrr_est_my(Y,X,rest,rest,rxfit,ryfit,jx,jy,p, d,n,maxiter,conv, method,lambda); return Rcpp::List::create(Rcpp::Named("Ag") = fit_final[0], Rcpp::Named("Bg") = fit_final[1], Rcpp::Named("Al") = fit_final[2], Rcpp::Named("Bl") = fit_final[3], Rcpp::Named("C") = fit_final[4], Rcpp::Named("df") = fit_final[5], Rcpp::Named("sse") = fit_final[8], Rcpp::Named("ic") = fit_final[9], Rcpp::Named("obj") = fit_final[10], Rcpp::Named("rx_path") = rx_path, Rcpp::Named("ry_path") = ry_path, Rcpp::Named("r_path") = r_path, Rcpp::Named("rank") = rest, Rcpp::Named("rx") = rxest, Rcpp::Named("ry") = ryest, Rcpp::Named("rxErrmat") = rxErrmat, Rcpp::Named("ryErrmat") = ryErrmat, Rcpp::Named("rErrmat") = rErrmat ); }
b2148cfd3efd17bdcf9ea9a3710d75a575eee741
5e566abb7e3bc36b1acea5a70e63c9f6a8434018
/Wallet_Francisco_Andrei/Wallet_Francisco_Andrei/Wallet.cpp
8e6228acbcab0ea18ccc4edb8b7e975870a00047
[]
no_license
flotazani/Wallet_Francisco_Andrei
70bc150f8e7c0a9f0a575aa50bd07bf6fcb6e55c
c0a8a49298c9dcfd18aa41cbbf3e1dba3a3a1a79
refs/heads/master
2021-01-01T03:53:27.873765
2016-04-14T22:47:35
2016-04-14T22:47:35
56,087,479
0
0
null
null
null
null
UTF-8
C++
false
false
2,815
cpp
Wallet.cpp
#include "Wallet.h" Wallet::Wallet() { //create a new pointer for all of them with default constructor ptr[0] = new Dollar; ptr[1] = new Euro; ptr[2] = new Franc; ptr[3] = new Hryvnia; ptr[4] = new Ruble; } //default Wallet::Wallet(int Curr, double num) { //depending on curr, call specific currency and use double constructor if (Curr == 0){ ptr[0] = new Dollar(num); ptr[1] = new Euro; ptr[2] = new Franc; ptr[3] = new Hryvnia; ptr[4] = new Ruble; } else if (Curr == 1) { ptr[0] = new Dollar; ptr[1] = new Euro(num); ptr[2] = new Franc; ptr[3] = new Hryvnia; ptr[4] = new Ruble; } else if (Curr == 2) { ptr[0] = new Dollar; ptr[1] = new Euro; ptr[2] = new Franc(num); ptr[3] = new Hryvnia; ptr[4] = new Ruble; } else if (Curr == 3) { ptr[0] = new Dollar; ptr[1] = new Euro; ptr[2] = new Franc; ptr[3] = new Hryvnia(num); ptr[4] = new Ruble; } else if (Curr == 4) { ptr[0] = new Dollar; ptr[1] = new Euro; ptr[2] = new Franc; ptr[3] = new Hryvnia; ptr[4] = new Ruble(num); } } Wallet::Wallet(int Curr, int wh, int fr) { //depending on curr, call specific currency and use Whole and Fraction constructor if (Curr == 0){ ptr[0] = new Dollar(wh,fr); ptr[1] = new Euro; ptr[2] = new Franc; ptr[3] = new Hryvnia; ptr[4] = new Ruble; } else if (Curr == 1) { ptr[0] = new Dollar; ptr[1] = new Euro(wh, fr); ptr[2] = new Franc; ptr[3] = new Hryvnia; ptr[4] = new Ruble; } else if (Curr == 2) { ptr[0] = new Dollar; ptr[1] = new Euro; ptr[2] = new Franc(wh, fr); ptr[3] = new Hryvnia; ptr[4] = new Ruble; } else if (Curr == 3) { ptr[0] = new Dollar; ptr[1] = new Euro; ptr[2] = new Franc; ptr[3] = new Hryvnia(wh, fr); ptr[4] = new Ruble; } else if (Curr == 4) { ptr[0] = new Dollar; ptr[1] = new Euro; ptr[2] = new Franc; ptr[3] = new Hryvnia; ptr[4] = new Ruble(wh, fr); } } ostream& operator<<(ostream& os, const Wallet* W) { // call name and value functions for all currencies os << W->ptr[0]->getWholeName() << " " << W->ptr[0]->getWhole() << " " << W->ptr[0]->getFracName() << " " << W->ptr[0]->getFrac() << endl << W->ptr[1]->getWholeName() << " " << W->ptr[1]->getWhole() << " " << W->ptr[1]->getFracName() << " " << W->ptr[1]->getFrac() << endl << W->ptr[2]->getWholeName() << " " << W->ptr[2]->getWhole() << " " << W->ptr[2]->getFracName() << " " << W->ptr[2]->getFrac() << endl << W->ptr[3]->getWholeName() << " " << W->ptr[3]->getWhole() << " " << W->ptr[3]->getFracName() << " " << W->ptr[3]->getFrac() << endl << W->ptr[4]->getWholeName() << " " << W->ptr[4]->getWhole() << " " << W->ptr[4]->getFracName() << " " << W->ptr[4]->getFrac() << endl; return os; } Wallet::~Wallet() { //delete temp memory for (int i = 0; i < 4; i++) { delete ptr[i]; } }
3c45d3ec072a61b9f3b886865fe844e8a17875ae
f3c56465c8db68e23a2c0a3e23d8e2ffe0619319
/semester2/hw3/task1/swap.cpp
0489b95415eeae313616cbc455c8dda8cc843459
[]
no_license
romankurbatov/homework
3665c4d0ab30ae408934dfe2b015637072da40b0
27a8f94f2e8d52f684f1a472598222fb9b806bdb
refs/heads/master
2021-03-12T20:23:15.268926
2013-05-26T16:22:16
2013-05-26T16:22:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
108
cpp
swap.cpp
void swap(int &a, int &b) { if (a == b) return; a = a ^ b; b = a ^ b; a = a ^ b; }
759619171c5f0ad00ed863e41255283d620d406c
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
/Engine/Source/Runtime/ClothingSystemRuntimeInterface/Private/ClothingSimulationFactoryInterface.cpp
5b5c7989f0d9141ea3b2c5ef7185893db05edfc4
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
windystrife/UnrealEngine_NVIDIAGameWorks
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
b50e6338a7c5b26374d66306ebc7807541ff815e
refs/heads/4.18-GameWorks
2023-03-11T02:50:08.471040
2022-01-13T20:50:29
2022-01-13T20:50:29
124,100,479
262
179
MIT
2022-12-16T05:36:38
2018-03-06T15:44:09
C++
UTF-8
C++
false
false
225
cpp
ClothingSimulationFactoryInterface.cpp
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #include "ClothingSimulationFactoryInterface.h" const FName IClothingSimulationFactoryClassProvider::FeatureName = TEXT("ClothingSimulationFactoryClassProvider");
909deeb32e817d3845614a120cc4074bc034a11b
658a1264bacaa521c0afaa91c364f995f28359f6
/tests/test_conversion_binding.cpp
5e42e629001ac3be29cd1c805bc3aff8b37fc07f
[ "MIT" ]
permissive
bergesenha/shadow
5986cbf81dbe1496de6e7939563ab3983134c593
d3bf5f54b541ede898b08fbfd53bc5badbf6420f
refs/heads/master
2022-12-13T19:16:29.243453
2017-11-15T11:19:38
2017-11-15T11:19:38
92,930,981
3
0
null
null
null
null
UTF-8
C++
false
false
820
cpp
test_conversion_binding.cpp
#include "catch.hpp" #include <string> #include <reflection_binding.hpp> struct explicitly_convertible { template <class T> explicit explicitly_convertible(T) { } }; TEST_CASE("test conversion bindings between anys of different types", "[generic_conversion_bind_point]") { auto int_to_float = &shadow::conversion_detail::generic_conversion_bind_point<float, int>; auto intptr_to_voidstar = &shadow::conversion_detail::generic_conversion_bind_point<void*, int*>; shadow::any anint = 23; int i = 300; int* iptr = &i; shadow::any anintptr = iptr; auto afloat = int_to_float(anint); auto avoidstar = intptr_to_voidstar(anintptr); REQUIRE(afloat.get<float>() == Approx(23.0f)); REQUIRE(*((int*)(avoidstar.get<void*>())) == 300); }
e82acf8ad0a5793026b6549b6ace9fdc26c14d48
7d90744d6b6ef7ef47bdd18654d60e64b7945aac
/day05/raw_socket.cpp
769e81a4e715cfb3fc14ecc37bc17930d3ded775
[]
no_license
OldFire/lxyfcode
2fcae2b9e85973bb3f9a7d746f772439ed6d00f7
d3a4835f116a09208d039824f4dbb363294e27e7
refs/heads/master
2020-06-27T06:53:55.098188
2018-01-22T09:11:29
2018-01-22T09:11:29
74,536,803
0
0
null
null
null
null
UTF-8
C++
false
false
7,721
cpp
raw_socket.cpp
/* ************************************************************************ * Filename: raw_socket.cpp * Description: * Version: 1.0 * Created: 11/04/2016 09:58:54 PM * Revision: none * Compiler: gcc * Author: YOUR NAME (), * Company: * ************************************************************************/ #include "../h.h" #include <linux/if_ether.h> #include <linux/if.h> #include <linux/sockios.h> #include <linux/if_packet.h> #include <linux/if_arp.h> typedef struct eth_frame { unsigned char dst[6]; unsigned char src[6]; unsigned short type; } eth_frame; typedef struct ip_frame { unsigned char head_len:4; // 已4个字节为单位 unsigned char version:4; unsigned char tos; // 服务类型 unsigned short total; // 总长度 unsigned short id; // 标识 unsigned short flag:3; unsigned short off:13; unsigned char ttl; // 生存时间 unsigned char protocol; // 协议:TCP/UDP unsigned short crc; // 校验和 unsigned int src_addr; unsigned int dst_addr; } ip_frame; typedef struct tcp_frame { unsigned short src_port; unsigned short dst_port; unsigned int seq; unsigned int ack_seq; #if 0 unsigned short head_len: 4; unsigned short reserve: 6; unsigned short URG:1; unsigned short ACK:1; unsigned short PSH:1; unsigned short RST:1; unsigned short SYN:1; unsigned short FIN:1; #endif unsigned short xxx; unsigned short window_size; unsigned short crc; unsigned short mpointer; } tcp_frame; void dump_eth_frame(eth_frame* frame) { if(ntohs(frame->type) != 0x0800) { return; } unsigned char* p = frame->dst; printf("dst is %02x:%02x:%02x:%02x:%02x:%02x\n", p[0], p[1], p[2], p[3], p[4], p[5]); p = frame->src; printf("src is %02x:%02x:%02x:%02x:%02x:%02x\n", p[0], p[1], p[2], p[3], p[4], p[5]); printf("frame type is 0x%x\n", ntohs(frame->type)); } void dump_ip_frame(ip_frame* frame) { printf("version is \t0x%x\n", frame->version); printf("headlen is \t0x%x\n", frame->head_len); printf("tos is \t0x%x\n", frame->tos); printf("total is \t0x%x\n", frame->total); printf("id is \t0x%x\n", frame->id); printf("flag is \t0x%x\n", frame->flag); printf("offset is \t0x%x\n", frame->off); printf("ttl is \t0x%x\n", frame->ttl); printf("protocol is \t0x%x\n", frame->protocol); printf("crc is \t0x%x\n", frame->crc); printf("src is \t0x%x\n", frame->src_addr); printf("dst is \t0x%x\n", frame->dst_addr); } int main() { // 运行原始套接字需要root权限 //int sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_IP|ETH_P_ARP|ETH_P_ALL)); int sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if(sock < 0) { perror("socket"); return 1; } // 得到网卡信息,配置网卡为混在模式 struct ifreq ifstruct; // 网卡信息 strcpy(ifstruct.ifr_name, "ens33"); // 指定网卡 // 调用ioctl获取网卡信息 int ret; ret = ioctl(sock, SIOCGIFINDEX, &ifstruct); if(ret < 0) { perror("ioctl SIOCGIFINDEX"); return 2; } printf("get if index = %d\n", ifstruct.ifr_ifru.ifru_ivalue); // 绑定地址, ll = low level struct sockaddr_ll addr; addr.sll_family = AF_PACKET; addr.sll_ifindex = ifstruct.ifr_ifru.ifru_ivalue; addr.sll_protocol = htons(ETH_P_ALL); addr.sll_hatype = ARPHRD_ETHER; #if 0 24 #define PACKET_HOST 0 /* To us */ 25 #define PACKET_BROADCAST 1 /* To all */ 26 #define PACKET_MULTICAST 2 /* To group */ 27 #define PACKET_OTHERHOST 3 /* To someone else */ 28 #define PACKET_OUTGOING 4 /* Outgoing of any type */ 29 /* These ones are invisible by user level */ #endif #if 0 177 struct ifreq { 178 #define IFHWADDRLEN 6 179 union 180 { 181 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 182 } ifr_ifrn; 183 184 union { 185 struct sockaddr ifru_addr; 186 struct sockaddr ifru_dstaddr; 187 struct sockaddr ifru_broadaddr; 188 struct sockaddr ifru_netmask; 189 struct sockaddr ifru_hwaddr; 190 short ifru_flags; 191 int ifru_ivalue; 192 int ifru_mtu; 193 struct ifmap ifru_map; 194 char ifru_slave[IFNAMSIZ]; /* Just fits the size */ 195 char ifru_newname[IFNAMSIZ]; 196 void * ifru_data; 197 struct if_settings ifru_settings; 198 } ifr_ifru; 199 }; #endif addr.sll_pkttype = PACKET_OTHERHOST; addr.sll_halen = ETH_ALEN; // 6 [0~5] addr.sll_addr[6] = 0; addr.sll_addr[7] = 0; // 只是打印一下本机的硬件地址,跟此程序无关 ret = ioctl(sock, SIOCGIFHWADDR, &ifstruct); if(ret < 0) { perror("get hwaddr"); return 4; } struct sockaddr* hwaddr = &ifstruct.ifr_ifru.ifru_hwaddr; const unsigned char* p =(unsigned char*) hwaddr->sa_data; printf("hw addr is %02x:%02x:%02x:%02x:%02x:%02x\n", p[0], p[1], p[2], p[3], p[4], p[5]); // 获取模式 ret = ioctl(sock, SIOCGIFFLAGS, &ifstruct); if(ret < 0) { perror("get flags"); return 5; } // 加上混杂功能 ifstruct.ifr_ifru.ifru_flags |= IFF_PROMISC; // 设置混杂模式 ret = ioctl(sock, SIOCSIFFLAGS, &ifstruct); if(ret < 0) { perror("set IFF_PROMISC"); return 6; } ret = bind(sock, (struct sockaddr*)&addr, sizeof(addr)); if(ret < 0) { perror("bind"); return 3; } char buf[2048]; while(1) { printf("reading eth frame ...\n"); ret = recv(sock, buf, sizeof(buf), 0); if(ret < 0) { perror("recv"); return 7; } printf("eth frame size: %d\n", ret); eth_frame* eth = (eth_frame*)buf; // dump_eth_frame(eth); // 如果不是ip报文,则不分析 if(ntohs(eth->type) != 0x0800) { continue; } // 通过偏移获得ip的报文首地址,并强制转换 ip_frame* ip = (ip_frame*)(buf + 14); // dump_ip_frame(ip); if(ip->protocol != 6) // TCP { continue; } tcp_frame* tcp = (tcp_frame*)(buf + 14 + ip->head_len*4); // printf("tcp head len=%d\n", tcp->head_len); unsigned short yyy = ntohs(tcp->xxx); unsigned int head_len = yyy & 0xf000; //1111000000000000 head_len >>= 12; printf("tcp head is %d\n", head_len); unsigned char* data =(unsigned char*) (buf+14+ip->head_len*4 + head_len*4); printf("%s\n", (char*)data); if(tcp->src_port == ntohs(9999) && tcp->dst_port == ntohs(9998)) { // unsigned char* data = (buf + 14 + ip->head_len * 4 + tcp->head_len * 4); // printf(""); } printf("******************************************************\n"); } return 0; }
ebad3b788e1413ffbe5f8dfd37deb9b41231f17a
eadef664ac828051c922ce140f4f9895aa9947ab
/mpi_test/mij2_1_1.cpp
37355b31cdf42f6eb133dd69269253f4488848cc
[]
no_license
Erikmkrtchyan82/MPI
9b141fa5619f0b864e0b8fc7add9b3968632bbf7
a8b83a29e43cd1a750b6465c3b8b2adbe3ccd005
refs/heads/master
2023-08-04T06:07:31.841375
2021-09-26T08:54:16
2021-09-26T08:54:16
410,500,264
0
0
null
null
null
null
UTF-8
C++
false
false
743
cpp
mij2_1_1.cpp
#include <iostream> #include "mpi.h" using namespace std; int main( int argc, char *argv[] ) { int rank, size; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Comm_size( MPI_COMM_WORLD, &size ); int a, position; double b; char buf[ 100 ]; if ( rank == 0 ) { cin >> a >> b; MPI_Pack( &a, 1, MPI_INT, buf, 100, &position, MPI_COMM_WORLD ); MPI_Pack( &b, 1, MPI_DOUBLE, buf, 100, &position, MPI_COMM_WORLD ); MPI_Bcast( buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD ); } else { position = 0; MPI_Unpack( buf, 100, &position, &a, 1, MPI_INT, MPI_COMM_WORLD ); MPI_Unpack( buf, 100, &position, &b, 1, MPI_DOUBLE, MPI_COMM_WORLD ); cout << rank << ": " << a << ", " << b << endl; } MPI_Finalize(); }
87833aba792cb66a4d2cfb5b8dc7b60cef1f6efb
05a21c24682e62dee5d1f5e27217059cb0bd2ffb
/ChASE-MPI/impl/chase_mpidla_mgpu.hpp
b09bf43374a131e6d319d57519518936a30459e2
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ChASE-library/ChASE
efb4c7b78ad5da3be1a65a58b93b61f008a57ac3
28934d8fe0a841876eb09d126aa82eb19d9f6096
refs/heads/master
2023-08-16T10:03:40.271769
2023-08-15T15:31:34
2023-08-15T15:31:34
349,075,288
7
4
null
null
null
null
UTF-8
C++
false
false
37,263
hpp
chase_mpidla_mgpu.hpp
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ // This file is a part of ChASE. // Copyright (c) 2015-2023, Simulation and Data Laboratory Quantum Materials, // Forschungszentrum Juelich GmbH, Germany. All rights reserved. // License is 3-clause BSD: // https://github.com/ChASE-library/ChASE #pragma once #include <assert.h> #include <complex> #include <cuComplex.h> #include <cublas_v2.h> #include <cuda.h> #include <cuda_profiler_api.h> #include <cuda_runtime.h> #include <curand_kernel.h> #include "ChASE-MPI/blas_cuda_wrapper.hpp" #include "ChASE-MPI/blas_templates.hpp" #include "ChASE-MPI/chase_mpi_properties.hpp" #include "ChASE-MPI/chase_mpidla_interface.hpp" /** @defgroup chase-cuda-utility Interface to the CUDA kernels functions used by * ChASE * @brief This module provides the calling for CUDA: * 1. generate random number in normal distribution on device * 2. shift the diagonal of a matrix on single GPU. * 3. shift the diagonal of a global matrix which has already distributed on * multiGPUs (both block-block and block-cyclic distributions) * @{ */ void residual_gpu(int m, int n, std::complex<double>* dA, int lda, std::complex<double>* dB, int ldb, double* d_ritzv, double* d_resids, bool is_sqrt, cudaStream_t stream_); void residual_gpu(int m, int n, std::complex<float>* dA, int lda, std::complex<float>* dB, int ldb, float* d_ritzv, float* d_resids, bool is_sqrt, cudaStream_t stream_); void residual_gpu(int m, int n, double* dA, int lda, double* dB, int ldb, double* d_ritzv, double* d_resids, bool is_sqrt, cudaStream_t stream_); void residual_gpu(int m, int n, float* dA, int lda, float* dB, int ldb, float* d_ritzv, float* d_resids, bool is_sqrt, cudaStream_t stream_); // currently, only full copy is support void t_lacpy_gpu(char uplo, int m, int n, float* dA, int ldda, float* dB, int lddb, cudaStream_t stream_); void t_lacpy_gpu(char uplo, int m, int n, double* dA, int ldda, double* dB, int lddb, cudaStream_t stream_); void t_lacpy_gpu(char uplo, int m, int n, std::complex<double>* ddA, int ldda, std::complex<double>* ddB, int lddb, cudaStream_t stream_); void t_lacpy_gpu(char uplo, int m, int n, std::complex<float>* ddA, int ldda, std::complex<float>* ddB, int lddb, cudaStream_t stream_); //! generate `n` random float numbers in normal distribution on each GPU device. //! //! @param[in] seed the seed of random number generator //! @param[in] states the states of the sequence of random number generator //! @param[in,out] v a pointer to the device memory to store the random //! generated numbers //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_rand_normal(unsigned long long seed, curandStatePhilox4_32_10_t* states, float* v, int n, cudaStream_t stream_); //! generate `n` random double numbers in normal distribution on each GPU //! device. //! //! @param[in] seed the seed of random number generator //! @param[in] states the states of the sequence of random number generator //! @param[in,out] v a pointer to the device memory to store the random //! generated numbers //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_rand_normal(unsigned long long seed, curandStatePhilox4_32_10_t* states, double* v, int n, cudaStream_t stream_); //! generate `n` random complex float numbers in normal distribution on each GPU //! device. The real part and the imaginary part of each individual random //! number are the same. //! //! @param[in] seed the seed of random number generator //! @param[in] states the states of the sequence of random number generator //! @param[in,out] v a pointer to the device memory to store the random //! generated numbers //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_rand_normal(unsigned long long seed, curandStatePhilox4_32_10_t* states, std::complex<float>* v, int n, cudaStream_t stream_); //! generate `n` random complex double numbers in normal distribution on each //! GPU device. The real part and the imaginary part of each individual random //! number are the same. //! //! @param[in] seed the seed of random number generator //! @param[in] states the states of the sequence of random number generator //! @param[in,out] v a pointer to the device memory to store the random //! generated numbers //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_rand_normal(unsigned long long seed, curandStatePhilox4_32_10_t* states, std::complex<double>* v, int n, cudaStream_t stream_); //! shift the diagonal of a `nxn` square matrix `A` in float real data type on a //! single GPU. //! //! @param[in,out] A a pointer to the matrix to be shifted //! @param[in] n the row and column of matrix `A` //! @param[in] shift the value for shifting the diagonal of matrix `A` //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_shift_matrix(float* A, int n, float shift, cudaStream_t* stream_); //! shift the diagonal of a `nxn` square matrix `A` in double real data type on //! a single GPU. //! //! @param[in,out] A a pointer to the matrix to be shifted //! @param[in] n the row and column of matrix `A` //! @param[in] shift the value for shifting the diagonal of matrix `A` //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_shift_matrix(double* A, int n, double shift, cudaStream_t* stream_); //! shift the diagonal of a `nxn` square matrix `A` in float complex data type //! on a single GPU. //! //! @param[in,out] A a pointer to the matrix to be shifted //! @param[in] n the row and column of matrix `A` //! @param[in] shift the value for shifting the diagonal of matrix `A` //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_shift_matrix(std::complex<float>* A, int n, float shift, cudaStream_t* stream_); //! shift the diagonal of a `nxn` square matrix `A` in double complex data type //! on a single GPU. //! //! @param[in,out] A a pointer to the matrix to be shifted //! @param[in] n the row and column of matrix `A` //! @param[in] shift the value for shifting the diagonal of matrix `A` //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_shift_matrix(std::complex<double>* A, int n, double shift, cudaStream_t* stream_); //! shift the diagonal of a `nxn` square matrix `A` in float real data type. //! which has been distributed on multi-GPUs in either block-block of //! block-cyclic faison. Each GPU may contains different number of diagonal part //! of the global matrix, espeically for the block-cyclic distribution On each //! GPU, it may contains multiple pieces of diagonal to be shifted, and each //! piece may be of different size. Hence each piece is determined by `off_m`, //! `off_n`, `offsize` within the local matrix on each GPU device. //! //! @param[in,out] A a pointer to the local piece of matrix to be shifted on //! each GPU //! @param[in] off_m the offset of the row of the first element each piece of //! diagonal to be shifted within the local matrix `A` //! @param[in] off_n the offset of the column of the first element each piece of //! diagonal to be shifted within the local matrix `A` //! @param[in] offsize number of elements to be shifted on each piece //! @param[in,out] ldh the leading dimension of local matrix to be shifted //! @param[in] shift the value for shifting the diagonal //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_shift_mgpu_matrix(float* A, std::size_t* off_m, std::size_t* off_n, std::size_t offsize, std::size_t ldH, float shift, cudaStream_t stream_); //! shift the diagonal of a `nxn` square matrix `A` in double real data type. //! which has been distributed on multi-GPUs in either block-block of //! block-cyclic faison. Each GPU may contains different number of diagonal part //! of the global matrix, espeically for the block-cyclic distribution On each //! GPU, it may contains multiple pieces of diagonal to be shifted, and each //! piece may be of different size. Hence each piece is determined by `off_m`, //! `off_n`, `offsize` within the local matrix on each GPU device. //! //! @param[in,out] A a pointer to the local piece of matrix to be shifted on //! each GPU //! @param[in] off_m the offset of the row of the first element each piece of //! diagonal to be shifted within the local matrix `A` //! @param[in] off_n the offset of the column of the first element each piece of //! diagonal to be shifted within the local matrix `A` //! @param[in] offsize number of elements to be shifted on each piece //! @param[in,out] ldh the leading dimension of local matrix to be shifted //! @param[in] shift the value for shifting the diagonal //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_shift_mgpu_matrix(double* A, std::size_t* off_m, std::size_t* off_n, std::size_t offsize, std::size_t ldH, double shift, cudaStream_t stream_); //! shift the diagonal of a `nxn` square matrix `A` in double complex data type. //! which has been distributed on multi-GPUs in either block-block of //! block-cyclic faison. Each GPU may contains different number of diagonal part //! of the global matrix, espeically for the block-cyclic distribution On each //! GPU, it may contains multiple pieces of diagonal to be shifted, and each //! piece may be of different size. Hence each piece is determined by `off_m`, //! `off_n`, `offsize` within the local matrix on each GPU device. //! //! @param[in,out] A a pointer to the local piece of matrix to be shifted on //! each GPU //! @param[in] off_m the offset of the row of the first element each piece of //! diagonal to be shifted within the local matrix `A` //! @param[in] off_n the offset of the column of the first element each piece of //! diagonal to be shifted within the local matrix `A` //! @param[in] offsize number of elements to be shifted on each piece //! @param[in,out] ldh the leading dimension of local matrix to be shifted //! @param[in] shift the value for shifting the diagonal //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_shift_mgpu_matrix(std::complex<double>* A, std::size_t* off_m, std::size_t* off_n, std::size_t offsize, std::size_t ldH, double shift, cudaStream_t stream_); //! shift the diagonal of a `nxn` square matrix `A` in float complex data type. //! which has been distributed on multi-GPUs in either block-block of //! block-cyclic faison. Each GPU may contains different number of diagonal part //! of the global matrix, espeically for the block-cyclic distribution On each //! GPU, it may contains multiple pieces of diagonal to be shifted, and each //! piece may be of different size. Hence each piece is determined by `off_m`, //! `off_n`, `offsize` within the local matrix on each GPU device. //! //! @param[in,out] A a pointer to the local piece of matrix to be shifted on //! each GPU //! @param[in] off_m the offset of the row of the first element each piece of //! diagonal to be shifted within the local matrix `A` //! @param[in] off_n the offset of the column of the first element each piece of //! diagonal to be shifted within the local matrix `A` //! @param[in] offsize number of elements to be shifted on each piece //! @param[in,out] ldh the leading dimension of local matrix to be shifted //! @param[in] shift the value for shifting the diagonal //! @param[in] stream_ an asynchronous CUDA stream which allows to run this //! function asynchronously void chase_shift_mgpu_matrix(std::complex<float>* A, std::size_t* off_m, std::size_t* off_n, std::size_t offsize, std::size_t ldH, float shift, cudaStream_t stream_); /** @} */ // end of chase-cuda-utility namespace chase { namespace mpi { // // This Class is meant to be used with MatrixFreeMPI // //! @brief A derived class of ChaseMpiDLAInterface which implements the //! inter-node computation for a multi-GPUs MPI-based implementation of ChASE. template <class T> class ChaseMpiDLAMultiGPU : public ChaseMpiDLAInterface<T> { public: //! A constructor of ChaseMpiDLABlaslapack. //! @param matrix_properties: it is an object of ChaseMpiProperties, which //! defines the MPI environment and data distribution scheme in ChASE-MPI. //! @param matrices: it is an instance of ChaseMpiMatrices, which //! allocates the required buffers in ChASE-MPI. ChaseMpiDLAMultiGPU(ChaseMpiProperties<T>* matrix_properties, T* H, std::size_t ldh, T* V1, Base<T>* ritzv) #if defined(CUDA_AWARE) : matrices_(std::move( matrix_properties->create_matrices(2, H, ldh, V1, ritzv))) #else : matrices_(std::move( matrix_properties->create_matrices(1, H, ldh, V1, ritzv))) #endif { #ifdef USE_NSIGHT nvtxRangePushA("ChaseMpiDLAMultiGPU: Init"); #endif n_ = matrix_properties->get_n(); m_ = matrix_properties->get_m(); N_ = matrix_properties->get_N(); nev_ = matrix_properties->GetNev(); nex_ = matrix_properties->GetNex(); H__ = matrices_.H(); C__ = matrices_.C(); C2__ = matrices_.C2(); A__ = matrices_.A(); B__ = matrices_.B(); B2__ = matrices_.B2(); Ritzv__ = matrices_.Ritzv(); Resid__ = matrices_.Resid(); vv__ = matrices_.vv(); off_ = matrix_properties->get_off(); matrix_properties->get_offs_lens(r_offs_, r_lens_, r_offs_l_, c_offs_, c_lens_, c_offs_l_); mb_ = matrix_properties->get_mb(); nb_ = matrix_properties->get_nb(); mblocks_ = matrix_properties->get_mblocks(); nblocks_ = matrix_properties->get_nblocks(); matrix_properties_ = matrix_properties; MPI_Comm row_comm = matrix_properties_->get_row_comm(); MPI_Comm col_comm = matrix_properties_->get_col_comm(); MPI_Comm_rank(row_comm, &mpi_row_rank); MPI_Comm_rank(col_comm, &mpi_col_rank); int num_devices; mpi_rank_ = matrix_properties_->get_my_rank(); cuda_exec(cudaGetDeviceCount(&num_devices)); std::size_t maxBlock = matrix_properties_->get_max_block(); cuda_exec(cudaMalloc((void**)&states_, sizeof(curandStatePhilox4_32_10_t) * (256 * 32))); cuda_exec(cudaMalloc((void**)&d_v_, sizeof(T) * m_)); cuda_exec(cudaMalloc((void**)&d_w_, sizeof(T) * n_)); cublasCreate(&cublasH_); cublasCreate(&cublasH2_); cusolverDnCreate(&cusolverH_); cublasSetPointerMode(cublasH2_, CUBLAS_POINTER_MODE_DEVICE); cuda_exec(cudaMalloc((void**)&devInfo_, sizeof(int))); int lwork_heevd = 0; cusolver_status_ = cusolverDnTheevd_bufferSize( cusolverH_, CUSOLVER_EIG_MODE_VECTOR, CUBLAS_FILL_MODE_LOWER, nev_ + nex_, A__.device(), nev_ + nex_, Ritzv__.device(), &lwork_heevd); assert(cusolver_status_ == CUSOLVER_STATUS_SUCCESS); if (lwork_heevd > lwork_) { lwork_ = lwork_heevd; } int lwork_potrf = 0; cusolver_status_ = cusolverDnTpotrf_bufferSize( cusolverH_, CUBLAS_FILL_MODE_UPPER, nev_ + nex_, A__.device(), nev_ + nex_, &lwork_potrf); assert(cusolver_status_ == CUSOLVER_STATUS_SUCCESS); if (lwork_potrf > lwork_) { lwork_ = lwork_potrf; } cuda_exec(cudaMalloc((void**)&d_work_, sizeof(T) * lwork_)); // for shifting matrix std::vector<std::size_t> off_m, off_n; for (std::size_t j = 0; j < nblocks_; j++) { for (std::size_t i = 0; i < mblocks_; i++) { for (std::size_t q = 0; q < c_lens_[j]; q++) { for (std::size_t p = 0; p < r_lens_[i]; p++) { if (q + c_offs_[j] == p + r_offs_[i]) { off_m.push_back(p + r_offs_l_[i]); off_n.push_back(q + c_offs_l_[j]); } } } } } diag_off_size_ = off_m.size(); cudaMalloc((void**)&(d_off_m_), diag_off_size_ * sizeof(std::size_t)); cudaMalloc((void**)&(d_off_n_), diag_off_size_ * sizeof(std::size_t)); cudaMemcpy(d_off_m_, off_m.data(), diag_off_size_ * sizeof(std::size_t), cudaMemcpyHostToDevice); cudaMemcpy(d_off_n_, off_n.data(), diag_off_size_ * sizeof(std::size_t), cudaMemcpyHostToDevice); cuda_exec(cudaStreamCreate(&stream1_)); cuda_exec(cudaStreamCreate(&stream2_)); #ifdef USE_NSIGHT nvtxRangePop(); #endif } //! Destructor. ~ChaseMpiDLAMultiGPU() { cudaStreamDestroy(stream1_); cudaStreamDestroy(stream2_); cublasDestroy(cublasH_); cusolverDnDestroy(cusolverH_); cuda_exec(cudaFree(d_work_)); cuda_exec(cudaFree(devInfo_)); cuda_exec(cudaFree(d_off_m_)); cuda_exec(cudaFree(d_off_n_)); cuda_exec(cudaFree(states_)); if (d_ritzVc_) { cuda_exec(cudaFree(d_ritzVc_)); } } //! - This function set initially the operation for apply() used in //! ChaseMpi::Lanczos() //! - This function also copies the local block of Symmetric/Hermtian matrix //! to GPU void initVecs() override { #if defined(CUDA_AWARE) cuda_exec(cudaMemcpy(C2__.device(), C__.device(), m_ * (nev_ + nex_) * sizeof(T), cudaMemcpyDeviceToDevice)); #else t_lacpy('A', m_, nev_ + nex_, C__.host(), m_, C2__.host(), m_); #endif H__.H2D(); next_ = NextOp::bAc; } //! This function generates the random values for each MPI proc using device //! API of cuRAND //! - each MPI proc with a same MPI rank among different column //! communicator //! same a same seed of RNG void initRndVecs() override { MPI_Comm col_comm = matrix_properties_->get_col_comm(); int mpi_col_rank; MPI_Comm_rank(col_comm, &mpi_col_rank); unsigned long long seed = 1337 + mpi_col_rank; chase_rand_normal(seed, states_, C__.device(), m_ * (nev_ + nex_), (cudaStream_t)0); #if !defined(CUDA_AWARE) C__.D2H(m_, nev_ + nex_); #endif } //! - This function set initially the operation for apply() in filter //! - it copies also `C_` to device buffer `d_C` void preApplication(T* V, std::size_t locked, std::size_t block) override { next_ = NextOp::bAc; #if !defined(CUDA_AWARE) if (locked > 0) { C__.H2D(m_, block, locked); } #endif } //! - This function performs the local computation of `GEMM` for //! ChaseMpiDLA::apply() //! - It is implemented based on `cuBLAS`'s `cublasXgemm`. void apply(T alpha, T beta, std::size_t offset, std::size_t block, std::size_t locked) override { // cudaStreamSynchronize(stream1_); T Zero = T(0.0); if (next_ == NextOp::bAc) { if (mpi_col_rank != 0) { beta = Zero; } #if !defined(CUDA_AWARE) C__.H2D(m_, block, offset + locked); #endif cublas_status_ = cublasTgemm(cublasH_, CUBLAS_OP_C, CUBLAS_OP_N, n_, block, m_, &alpha, H__.device(), H__.d_ld(), C__.device() + locked * m_ + offset * m_, m_, &beta, B__.device() + locked * n_ + offset * n_, n_); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); #if !defined(CUDA_AWARE) B__.D2H(n_, block, locked + offset); #else cudaDeviceSynchronize(); #endif next_ = NextOp::cAb; } else { if (mpi_row_rank != 0) { beta = Zero; } #if !defined(CUDA_AWARE) B__.H2D(n_, block, locked + offset); #endif cublas_status_ = cublasTgemm(cublasH_, CUBLAS_OP_N, CUBLAS_OP_N, m_, block, n_, &alpha, H__.device(), H__.d_ld(), B__.device() + locked * n_ + offset * n_, n_, &beta, C__.device() + locked * m_ + offset * m_, m_); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); #if !defined(CUDA_AWARE) C__.D2H(m_, block, offset + locked); #else cudaDeviceSynchronize(); #endif next_ = NextOp::bAc; } } //! This function performs the shift of diagonal of a global matrix //! - This global is already distributed on GPUs, so the shifting operation //! takes place on the local //! block of global matrix on each GPU. //! - This function is naturally in parallel among all MPI procs and also //! with each GPU. void shiftMatrix(T c, bool isunshift = false) override { chase_shift_mgpu_matrix(H__.device(), d_off_m_, d_off_n_, diag_off_size_, m_, std::real(c), (cudaStream_t)0); } //! - This function performs the local computation of `GEMM` for //! ChaseMpiDLA::asynCxHGatherC() //! - It is implemented based on `cuBLAS`'s `cublasXgemm`. void asynCxHGatherC(std::size_t locked, std::size_t block, bool isCcopied) override { T alpha = T(1.0); T beta = T(0.0); #if !defined(CUDA_AWARE) if (!isCcopied) { C__.H2D(m_, block, locked); } #endif cublas_status_ = cublasTgemm(cublasH_, CUBLAS_OP_C, CUBLAS_OP_N, n_, block, m_, &alpha, H__.device(), H__.d_ld(), C__.device() + locked * m_, m_, &beta, B__.device() + locked * n_, n_); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); #if !defined(CUDA_AWARE) B__.D2H(n_, block, locked); #endif } //! - All required operations for this function has been done in for //! ChaseMpiDLA::applyVec(). //! - This function contains nothing in this class. void applyVec(T* v, T* w) override { T alpha = T(1.0); T beta = T(0.0); cuda_exec(cudaMemcpy(d_v_, v, m_ * sizeof(T), cudaMemcpyHostToDevice)); cublas_status_ = cublasTgemv(cublasH_, CUBLAS_OP_C, m_, n_, &alpha, H__.device(), H__.d_ld(), d_v_, 1, &beta, d_w_, 1); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); cuda_exec(cudaMemcpy(w, d_w_, n_ * sizeof(T), cudaMemcpyDeviceToHost)); } int get_nprocs() const override { return matrix_properties_->get_nprocs(); } void Start() override {} void End() override { #if defined(CUDA_AWARE) C__.D2H(m_, nev_); #endif } Base<T>* get_Resids() override { return Resid__.host(); } Base<T>* get_Ritzv() override { return Ritzv__.host(); } //! It is an interface to BLAS `?axpy`. void axpy(std::size_t N, T* alpha, T* x, std::size_t incx, T* y, std::size_t incy) override { t_axpy(N, alpha, x, incx, y, incy); } //! It is an interface to BLAS `?scal`. void scal(std::size_t N, T* a, T* x, std::size_t incx) override { t_scal(N, a, x, incx); } //! It is an interface to BLAS `?nrm2`. Base<T> nrm2(std::size_t n, T* x, std::size_t incx) override { #if defined(CUDA_AWARE) Base<T> nrm; cublas_status_ = cublasTnrm2(cublasH_, n, x, incx, &nrm); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); return nrm; #else return t_nrm2(n, x, incx); #endif } //! It is an interface to BLAS `?dot`. T dot(std::size_t n, T* x, std::size_t incx, T* y, std::size_t incy) override { return t_dot(n, x, incx, y, incy); } //! - This function performs the local computation of `GEMM` for //! ChaseMpiDLA::RR() //! - It is implemented based on `cuBLAS`'s `cublasXgemm`. void RR(std::size_t block, std::size_t locked, Base<T>* ritzv) override { T One = T(1.0); T Zero = T(0.0); #if !defined(CUDA_AWARE) B__.H2D(n_, block, locked); B2__.H2D(n_, block, locked); #endif cublas_status_ = cublasTgemm( cublasH_, CUBLAS_OP_C, CUBLAS_OP_N, block, block, n_, &One, B2__.device() + locked * n_, n_, B__.device() + locked * n_, n_, &Zero, A__.device(), nev_ + nex_); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); #if !defined(CUDA_AWARE) A__.D2H(block, block); #endif } //! It is an interface to cuBLAS `cublasXsy(he)rk`. void syherk(char uplo, char trans, std::size_t n, std::size_t k, T* alpha, T* a, std::size_t lda, T* beta, T* c, std::size_t ldc, bool first) override { if (first) { C__.H2D(); } Base<T> One = Base<T>(1.0); Base<T> Zero = Base<T>(0.0); cublasOperation_t transa; if (sizeof(T) == sizeof(Base<T>)) { transa = CUBLAS_OP_T; } else { transa = CUBLAS_OP_C; } cublas_status_ = cublasTsyherk(cublasH_, CUBLAS_FILL_MODE_UPPER, transa, nev_ + nex_, m_, &One, C__.device(), m_, &Zero, A__.device(), nev_ + nex_); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); #if !defined(CUDA_AWARE) A__.D2H(nev_ + nex_, nev_ + nex_); #endif } //! It is an interface to cuSOLVER `cusolverXpotrf`. int potrf(char uplo, std::size_t n, T* a, std::size_t lda, bool isinfo = true) override { #if !defined(CUDA_AWARE) A__.H2D(nev_ + nex_, nev_ + nex_); #endif #ifdef USE_NSIGHT nvtxRangePushA("cusolverDnTpotrf"); #endif cusolver_status_ = cusolverDnTpotrf( cusolverH_, CUBLAS_FILL_MODE_UPPER, nev_ + nex_, A__.device(), nev_ + nex_, d_work_, lwork_, devInfo_); #ifdef USE_NSIGHT nvtxRangePop(); #endif assert(CUSOLVER_STATUS_SUCCESS == cusolver_status_); int info = 0; if(isinfo) { cuda_exec(cudaMemcpy(&info, devInfo_, 1 * sizeof(int), cudaMemcpyDeviceToHost)); } return info; } //! It is an interface to cuBLAS `cublasXtrsm`. void trsm(char side, char uplo, char trans, char diag, std::size_t m, std::size_t n, T* alpha, T* a, std::size_t lda, T* b, std::size_t ldb, bool first) override { cublas_status_ = cublasTtrsm(cublasH_, CUBLAS_SIDE_RIGHT, CUBLAS_FILL_MODE_UPPER, CUBLAS_OP_N, CUBLAS_DIAG_NON_UNIT, m_, nev_ + nex_, alpha, A__.device(), nev_ + nex_, C__.device(), m_); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); #if !defined(CUDA_AWARE) if (!first) { C__.D2H(m_, nev_ + nex_); } #endif } //! - This function performs the local computation of residuals for //! ChaseMpiDLA::Resd() //! - It is implemented based on `BLAS`'s `?axpy` and `?nrm2`. //! - This function computes only the residuals of local part of vectors on //! each MPI proc. //! - The final results are obtained in ChaseMpiDLA::Resd() with an //! MPI_Allreduce operation //! within the row communicator. void Resd(Base<T>* ritzv, Base<T>* resid, std::size_t locked, std::size_t unconverged) override { #if defined(CUDA_AWARE) residual_gpu(n_, unconverged, B__.device() + locked * n_, n_, B2__.device() + locked * n_, n_, Ritzv__.device(), Resid__.device() + locked, false, (cudaStream_t)0); #else for (auto i = 0; i < unconverged; i++) { T alpha = -ritzv[i]; t_axpy(n_, &alpha, B2__.host() + locked * n_ + i * n_, 1, B__.host() + locked * n_ + i * n_, 1); resid[i] = t_norm_p2(n_, B__.host() + locked * n_ + i * n_); } #endif } //! - This function performs the local computation for ChaseMpiDLA::heevd() //! - It is implemented based on `cuBLAS`'s `xgemm` and cuSOLVER's //! `cusolverXsy(he)evd`. void heevd(int matrix_layout, char jobz, char uplo, std::size_t n, T* a, std::size_t lda, Base<T>* w) override { T One = T(1.0); T Zero = T(0.0); std::size_t locked = nev_ + nex_ - n; #if !defined(CUDA_AWARE) A__.H2D(n, n); #endif #ifdef USE_NSIGHT nvtxRangePushA("cusolverDnTheevd"); #endif cusolver_status_ = cusolverDnTheevd( cusolverH_, CUSOLVER_EIG_MODE_VECTOR, CUBLAS_FILL_MODE_LOWER, n, A__.device(), nev_ + nex_, Ritzv__.device(), d_work_, lwork_, devInfo_); assert(cusolver_status_ == CUSOLVER_STATUS_SUCCESS); #ifdef USE_NSIGHT nvtxRangePop(); #endif cuda_exec(cudaMemcpy(w, Ritzv__.device(), n * sizeof(Base<T>), cudaMemcpyDeviceToHost)); #if !defined(CUDA_AWARE) C2__.H2D(m_, n, locked); #endif cublas_status_ = cublasTgemm(cublasH_, CUBLAS_OP_N, CUBLAS_OP_N, m_, n, n, &One, C2__.device() + locked * m_, m_, A__.device(), nev_ + nex_, &Zero, C__.device() + locked * m_, m_); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); #if !defined(CUDA_AWARE) C__.D2H(m_, n, locked); #endif } //! - All required operations for this function has been done in for //! ChaseMpiDLA::hhQR(). //! - This function contains nothing in this class. void hhQR(std::size_t locked) override {} //! - All required operations for this function has been done in for //! ChaseMpiDLA::cholQR(). //! - This function contains nothing in this class. void cholQR(std::size_t locked, Base<T> cond) override {} //! - All required operations for this function has been done in for //! ChaseMpiDLA::Swap(). //! - This function contains nothing in this class. void Swap(std::size_t i, std::size_t j) override {} //! - All required operations for this function has been done in for //! ChaseMpiDLA::LanczosDos(). //! - This function contains nothing in this class. void LanczosDos(std::size_t idx, std::size_t m, T* ritzVc) override { T alpha = T(1.0); T beta = T(0.0); #if defined(CUDA_AWARE) if (d_ritzVc_ == nullptr) { cuda_exec(cudaMalloc((void**)&(d_ritzVc_), m * idx * sizeof(T))); } cuda_exec(cudaMemcpy(d_ritzVc_, ritzVc, m * idx * sizeof(T), cudaMemcpyHostToDevice)); cublas_status_ = cublasTgemm(cublasH_, CUBLAS_OP_N, CUBLAS_OP_N, m_, idx, m, &alpha, C__.device(), m_, d_ritzVc_, m, &beta, C2__.device(), m_); assert(cublas_status_ == CUBLAS_STATUS_SUCCESS); cuda_exec(cudaMemcpy(C__.device(), C2__.device(), m_ * m * sizeof(T), cudaMemcpyDeviceToDevice)); #else t_gemm(CblasColMajor, CblasNoTrans, CblasNoTrans, m_, idx, m, &alpha, C__.host(), m_, ritzVc, m, &beta, C2__.host(), m_); std::memcpy(C__.host(), C2__.host(), m * m_ * sizeof(T)); #endif } void Lanczos(std::size_t M, int idx, Base<T>* d, Base<T>* e, Base<T>* r_beta) override { } void B2C(T* B, std::size_t off1, T* C, std::size_t off2, std::size_t block) override { } void lacpy(char uplo, std::size_t m, std::size_t n, T* a, std::size_t lda, T* b, std::size_t ldb) override { #if defined(CUDA_AWARE) t_lacpy_gpu(uplo, m, n, a, lda, b, ldb, NULL); #else t_lacpy(uplo, m, n, a, lda, b, ldb); #endif } void shiftMatrixForQR(T* A, std::size_t n, T shift) override { #if defined(CUDA_AWARE) chase_shift_matrix(A, n, std::real(shift), &stream1_); #else for (auto i = 0; i < n; i++) { A[i * n + i] += (T)shift; } #endif } ChaseMpiMatrices<T>* getChaseMatrices() override { return &matrices_; } private: enum NextOp { cAb, bAc }; NextOp next_; //!< it is to manage the switch of operation from `V2=H*V1` to //!< `V1=H'*V2` in filter std::size_t N_; //!< global dimension of the symmetric/Hermtian matrix std::size_t n_; //!< number of columns of local matrix of the //!< symmetric/Hermtian matrix std::size_t m_; //!< number of rows of local matrix of the symmetric/Hermtian matrix std::size_t* off_; //!< identical to ChaseMpiProperties::off_ std::size_t* r_offs_; //!< identical to ChaseMpiProperties::r_offs_ std::size_t* r_lens_; //!< identical to ChaseMpiProperties::r_lens_ std::size_t* r_offs_l_; //!< identical to ChaseMpiProperties::r_offs_l_ std::size_t* c_offs_; //!< identical to ChaseMpiProperties::c_offs_ std::size_t* c_lens_; //!< identical to ChaseMpiProperties::c_lens_ std::size_t* c_offs_l_; //!< identical to ChaseMpiProperties::c_offs_l_ std::size_t nb_; //!< identical to ChaseMpiProperties::nb_ std::size_t mb_; //!< identical to ChaseMpiProperties::mb_ std::size_t nblocks_; //!< identical to ChaseMpiProperties::nblocks_ std::size_t mblocks_; //!< identical to ChaseMpiProperties::mblocks_ std::size_t nev_; //!< number of required eigenpairs std::size_t nex_; //!< number of extral searching space int mpi_row_rank; //!< rank within each row communicator int mpi_col_rank; //!< rank within each column communicator // for shifting matrix H std::size_t* d_off_m_; //!< the offset of the row of the first element each piece of //!< diagonal to be shifted within the local matrix `A` std::size_t* d_off_n_; //!< the offset of the column of the first element each piece //!< of diagonal to be shifted within the local matrix `A` std::size_t diag_off_size_; //!< number of elements to be shifted on each piece int mpi_rank_; //!< the MPI rank within the working MPI communicator cublasHandle_t cublasH_; //!< `cuBLAS` handle cublasHandle_t cublasH2_; //!< `cuBLAS` handle cusolverDnHandle_t cusolverH_; //!< `cuSOLVER` handle cublasStatus_t cublas_status_ = CUBLAS_STATUS_SUCCESS; //!< `cuBLAS` status cusolverStatus_t cusolver_status_ = CUSOLVER_STATUS_SUCCESS; //!< `cuSOLVER` status cudaStream_t stream1_; //!< CUDA stream for asynchronous exectution of kernels cudaStream_t stream2_; //!< CUDA stream for asynchronous exectution of kernels // curandState* states_ = NULL; //!< a pointer of `curandState` for the // cuRAND curandStatePhilox4_32_10_t* states_ = NULL; T* d_work_ = NULL; //!< a pointer to a local buffer on GPU, which is reserved for the //!< extra buffer required for any cuSOLVER routines T* d_v_; T* d_w_; int* devInfo_ = NULL; //!< for the return of information from any cuSOLVER routines int lwork_ = 0; //!< size of required extra buffer by any cuSOLVER routines ChaseMpiProperties<T>* matrix_properties_; //!< an object of class ChaseMpiProperties ChaseMpiMatrices<T> matrices_; Matrix<T> H__; Matrix<T> C__; Matrix<T> C2__; Matrix<T> A__; Matrix<T> B__; Matrix<T> B2__; Matrix<Base<T>> Ritzv__; Matrix<Base<T>> Resid__; Matrix<T> vv__; T* d_ritzVc_ = nullptr; }; template <typename T> struct is_skewed_matrixfree<ChaseMpiDLAMultiGPU<T>> { static const bool value = true; }; } // namespace mpi } // namespace chase
34764d411582e7c02e131497a75f2fca73119be0
b3c163605f4198451874c28a039670d0e47d3ac4
/chapter01/question1-3.cpp
8fe0f5a399671e4160c774da02d640bf69e43e48
[]
no_license
kuroyam/cracking-the-coding-interview
fdb327e6302cc40833370bbd26baf04fb148c02e
08cdc6d6055ae7c9c5794be03f095146d2403836
refs/heads/master
2021-01-23T20:12:54.300458
2013-01-19T03:54:56
2013-01-19T03:54:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
898
cpp
question1-3.cpp
// 1.3 2つの文字列が与えられたとき、片方がもう片方の並び替えになっているかどうかを決定するメソッドを書いてください。 #include <iostream> #include <string.h> bool checkStringIsAnagram(const char* str1, const char* str2) { int length1 = strlen(str1); int length2 = strlen(str2); if (length1 != length2) { return false; } for (int i = 0; i < length1; i++) { char c = str1[i]; int counter1 = 0; int counter2 = 0; for (int j = 0; j < length1; j++) { if (c == str1[j]) { counter1++; } } for (int k = 0; k < length2; k++) { if (c == str2[k]) { counter2++; } } if (counter1 != counter2) { return false; } } return true; } int main (int argc, char* argv[]) { const char* str = (checkStringIsAnagram(argv[1], argv[2])) ? "true" : "false"; std::cout << str << std::endl; }
432d6e0efcef615b01860bde4b15dc33417a8ba3
4371a59ec2a50a1cdd757f602f3579c9b1b6a8da
/Code/v1.ino
b782390ff99ce92604217305979602008f3e257d
[]
no_license
wekeller/Borehole_Logger
2ae775493bb2f8d420f8011e1149fa367bec9023
77dc4a42c39d32a92da407f4e7e07eed0a5980e3
refs/heads/master
2021-04-06T20:17:21.260336
2018-03-15T19:01:31
2018-03-15T19:01:31
125,279,332
0
0
null
null
null
null
UTF-8
C++
false
false
4,622
ino
v1.ino
#include <LiquidCrystal.h> #include <EEPROM.h> #include <OneWire.h> #include <DallasTemperature.h> #include <SoftwareSerial.h> // --- EEPROM ADDRESS DEFINITIONS #define LCD_BACKLIGHT_ADDRESS 1 // EEPROM address for backlight setting #define BAUD_ADDRESS 2 // EEPROM address for Baud rate setting #define SPLASH_SCREEN_ADDRESS 3 // EEPROM address for splash screen on/off #define ROWS_ADDRESS 4 // EEPROM address for number of rows #define COLUMNS_ADDRESS 5 // EEPROM address for number of columns // --- SPECIAL COMMAND DEFINITIONS #define BACKLIGHT_COMMAND 128 // 0x80 #define SPECIAL_COMMAND 254 // 0xFE #define BAUD_COMMAND 129 // 0x81 // --- DATA PIN DEFINITION #define ONE_WIRE_BUS 10 OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire);// Pass our oneWire reference to Dallas Temperature. // --- ARDUINO PIN DEFINITIONS uint8_t RSPin = 2; uint8_t RWPin = 3; uint8_t ENPin = 4; uint8_t D4Pin = 5; uint8_t D5Pin = 6; uint8_t D6Pin = 7; uint8_t D7Pin = 8; uint8_t BLPin = 9; char inKey; // Character received from serial input uint8_t Cursor = 0; // Position of cursor, 0 is top left, (rows*columns)-1 is bottom right uint8_t LCDOnOff = 1; // 0 if LCD is off uint8_t blinky = 0; // Is 1 if blinky cursor is on uint8_t underline = 0; // Is 1 if underline cursor is on uint8_t splashScreenEnable = 1; // 1 means splash screen is enabled uint8_t rows = 2; // Number rows, will be either 2 or 4 uint8_t columns = 16; // Number of columns, will be 16 or 20 uint8_t characters; // rows * columns // initialize the LCD at pins defined above LiquidCrystal lcd(RSPin, RWPin, ENPin, D4Pin, D5Pin, D6Pin, D7Pin); void setup(){ sensors.begin(); delay(1000); while(Serial.available()); // If serial data is available do this Serial.begin(9600); //Begin serial communication setBaudRate(EEPROM.read(BAUD_ADDRESS)); // initialize the serial communications: rows = EEPROM.read(ROWS_ADDRESS); // Read rows and columns from EEPROM. Will default to 2x16, if not previously set if (rows != 4) rows = 2; columns = EEPROM.read(COLUMNS_ADDRESS); if (columns != 20) columns = 16; lcd.begin(columns, rows); // set up the LCD's number of rows and columns: pinMode(BLPin, OUTPUT);// Set up the backlight setBacklight(EEPROM.read(LCD_BACKLIGHT_ADDRESS)); splashScreenEnable = EEPROM.read(SPLASH_SCREEN_ADDRESS); // Do splashscreen if set if (splashScreenEnable!=0) { if (columns == 16) { } else { lcd.setCursor(0, 1); lcd.print(" Temp Probe "); lcd.setCursor(0, 2); lcd.print(" YNP Geology "); delay(2000); lcd.clear(); } } } void loop(){ //Report Temperature sensors.requestTemperatures(); lcd.setCursor(0, 0); lcd.print("Temperature C: "); lcd.setCursor(0, 1); lcd.print(" ");lcd.setCursor(0, 1); lcd.print(sensors.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire delay(1000); lcd.clear(); } void setBacklight(uint8_t backlightSetting){ analogWrite(BLPin, backlightSetting); EEPROM.write(LCD_BACKLIGHT_ADDRESS, backlightSetting); } /* ---------------------------------------------------------- setBaudRate() is called from SpecialCommands(). It receives a baud rate setting balue that should be between 0 and 10. The baud rate is then set accordingly, and the new value is written to EEPROM. If the EEPROM value hasn't been written before (255), this function will default to 9600. If the value is out of bounds 10<baud<255, no action is taken. ----------------------------------------------------------*/ void setBaudRate(uint8_t baudSetting){ // If EEPROM is unwritten (0xFF), set it to 9600 by default if (baudSetting==255) baudSetting = 4; switch(baudSetting) { case 0: Serial.begin(300); break; case 1: Serial.begin(1200); break; case 2: Serial.begin(2400); break; case 3: Serial.begin(4800); break; case 4: Serial.begin(9600); break; case 5: Serial.begin(14400); break; case 6: Serial.begin(19200); break; case 7: Serial.begin(28800); break; case 8: Serial.begin(38400); break; case 9: Serial.begin(57600); break; case 10: Serial.begin(115200); break; } if ((baudSetting>=0)&&(baudSetting<=10)) EEPROM.write(BAUD_ADDRESS, baudSetting); }
1a32eb47ef0f46dcde0b99b30ce183238afdbbd9
d88851690a7320df90c4a9314e5f9a2be1177376
/PA6/Background.cpp
d58d805202188ae7054f6ee024825cd4bb7e050a
[]
no_license
GabrielByram/CPT_S-223-Projects
37002d51fcf676d047d677da5510a14fb1b9e84f
c7b5ee386935599cc83fe540c4ee769115831a6d
refs/heads/main
2023-02-13T00:16:53.442159
2021-01-17T23:43:40
2021-01-17T23:43:40
330,508,280
0
0
null
null
null
null
UTF-8
C++
false
false
4,426
cpp
Background.cpp
#include "Background.h" Background::Background(){ if(!font.loadFromFile("CourierPrime-Regular.ttf")) std::cout << "Cannot open font"; if(!textureBackground1.loadFromFile("Pictures/Classroom.jpg")) std::cout << "Cannot open picture"; //Loads the classroom background background1.setTexture(textureBackground1); if(!textureBackground2.loadFromFile("Pictures/ZoomClassroom.png")) std::cout << "Cannot open picture"; //Loads the zoom classroom background background2.setTexture(textureBackground2); if(!textureBackground3.loadFromFile("Pictures/Andy.png")) std::cout << "Cannot open picture"; //Loads THE ANDY background background3.setTexture(textureBackground3); } //Prints the background options int Background::printBackgroundMenu(sf::RenderWindow &window) { //Prints the background for the menu window.clear(sf::Color::Blue); //Prints the text for the background menu text.setFont(font); text.setString("Select a background :)"); text.setCharacterSize(95); text.setFillColor(sf::Color::Magenta); text.setStyle(sf::Text::Bold); text.setPosition(sf::Vector2f(0, 0)); window.draw(text); printOptions(window); //Prints background options window.display(); bool chosenBackground = false; int choice = -1; //Runs until the background is chosen while(!chosenBackground){ choice = checkEvent(window); //Checks if user chose an option if(choice != -1) { chosenBackground = true; } } //returns chosen background return choice; } //Prints the background options void Background::printOptions(sf::RenderWindow& window) { //Loads and displays background option 1 background1.setScale(sf::Vector2f(0.11f, 0.11f)); background1.setPosition(sf::Vector2f(800, 200)); window.draw(background1); //Loads and displays background option 2 background2.setScale(sf::Vector2f(0.3f, 0.3f)); background2.setPosition(sf::Vector2f(200, 200)); window.draw(background2); //Loads and displays background option 3 background3.setScale(sf::Vector2f(0.1f, 0.1f)); background3.setPosition(sf::Vector2f(500, 400)); window.draw(background3); } //Checks the input of a user while background menu is open int Background::checkEvent(sf::RenderWindow& window){ sf::Event event; sf::Mouse mouse; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); if(event.type == sf::Event::MouseButtonPressed){ //Checks if the user clicked the zoom background if(mouse.getPosition(window).x >= 200 && mouse.getPosition(window).x < 600 && mouse.getPosition(window).y >= 200 && mouse.getPosition(window).y < 400){ return 2; } //Checks if the user clicked the background else if(mouse.getPosition(window).x >= 800 && mouse.getPosition(window).x < 1200 && mouse.getPosition(window).y >= 200 && mouse.getPosition(window).y < 400){ return 1; } //Checks if the user clicked the Andy background else if(mouse.getPosition(window).x >= 500 && mouse.getPosition(window).x < 900 && mouse.getPosition(window).y >= 400 && mouse.getPosition(window).y < 600){ return 3; } } } return -1; } //Draws the background void Background::printBackground(int choice, sf::RenderWindow& window){ window.draw(getBackground(choice)); } //Returns the background with the chosen background sf::Sprite Background::getBackground(int choice){ if(choice == 1){ //If the choice is classroom background1.setScale(sf::Vector2f(0.5f, 0.5f)); background1.setPosition(sf::Vector2f(0, 0)); return background1; } else if(choice == 2){ //If the choice is zoom background background2.setScale(sf::Vector2f(1.15f, 1.15f)); background2.setPosition(sf::Vector2f(0, 0)); return background2; } else if(choice == 3){ //If the choice is Andy background3.setScale(sf::Vector2f(0.35f, 0.35f)); background3.setPosition(sf::Vector2f(0, 0)); return background3; } else{ //Error std::cout << "Choice invalid\n"; return background1; } }
4c349b48f40f10f6953e62a2e6d5d5d5c7a0c976
1fa0e2c4b7ef9432cd50b2243e1d0cec330a2957
/MMC25.cpp
5265c62c7922129e97200ad0fd7d66b1913e44dd
[]
no_license
gw606/ITSA-OOP
86b006513ec1a317b7f52f15caa9f5ceb0c6be03
794500aead01b9b768492869df411ecb7da6b26f
refs/heads/master
2022-11-16T17:46:49.164345
2020-07-06T17:30:04
2020-07-06T17:30:04
277,600,214
0
0
null
null
null
null
UTF-8
C++
false
false
309
cpp
MMC25.cpp
#include <iostream> #include <cmath> using namespace std; int main(){ int a,i=0,num=0; while(cin>>a){ for(int i=0;i<=a;i++){ if((i%3)==0) num+=i; } //printf("%d\n",num ); cout<<num<<endl; num=0; } return 0; }
dd7d739e02ad018dd2ad5916199b8fda20d8e74b
74d91f18c37b103dc8d0d5eaa65586eadb1abbd4
/mysha.h
561fafbcceb98a17cbe2f2054e8b8c32de8ea88a
[]
no_license
QuentinGouchet/Cryptographic-Calculator
b3b0666248ea4759c615c1e152583340c34c17b0
8039989fd1d5b67be461a1d917aa164598ff831c
refs/heads/master
2021-01-21T12:23:21.843461
2014-05-28T12:24:15
2014-05-28T12:24:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
722
h
mysha.h
#ifndef MYSHA_H #define MYSHA_H #include <string.h> #include <stdlib.h> #include "gmp.h" #include <openssl/sha.h> typedef unsigned char u8; typedef unsigned long long int u16; class MySha { public: MySha(); int computeSha256(const char *, const char *); int computeSha512(const char *, const char *); int sha1(const char*, const char*); private: void print_hex(u8*,int,const char*); u16 string_size(char*); void compute_sha1(u8*,u8*,unsigned long long int); void H(u8*,u8*,u8*,u8*); void G(u8*,u8*,u8*,u8*); void F(u8*,u8*,u8*,u8*); void u8_xor(u8*,u8*,u8*); void shift_left(u8*,u8*,u8); void add(u8*,u8*,u8*); void u8_memcpy(u8*,u8*,u16); }; #endif // MYSHA_H
6973f338d41a321f6fa798216c6f42177f3e3e0c
776d5e2a3d9414e3ce83644326883a6b69e1b113
/GG/config/CfgExileCustomCode.hpp
dd1f27babffbfa77ae5a094d0151c6d66ba48974
[]
no_license
aussie-battler/ExileMod
da02f9e8c7e4a8aa5dd450175d4e7444940c28f3
6e91e65eada49a8c8b604e937657605e0af2d8fd
refs/heads/master
2020-03-10T16:16:16.743021
2016-11-10T12:55:10
2016-11-10T12:55:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,934
hpp
CfgExileCustomCode.hpp
class CfgExileCustomCode { ExileClient_action_hideBody_condition = "GG\custom\ExileClient_action_hideBody_condition.sqf"; ExileClient_construction_handleAbort = "GG\custom\ExileClient_construction_handleAbort.sqf"; ExileClient_construction_thread = "GG\custom\ExileClient_construction_thread.sqf"; ExileClient_gui_escape_suicide = "GG\custom\ExileClient_gui_escape_suicide.sqf"; ExileClient_gui_lockerDialog_show = "GG\custom\ExileClient_gui_lockerDialog_show.sqf"; ExileClient_gui_upgradeTerritoryDialog_event_onTerritoryDropDownSelectionChanged = "GG\custom\ExileClient_gui_upgradeTerritoryDialog_event_onTerritoryDropDownSelectionChanged.sqf"; ExileClient_gui_wasteDumpDialog_event_onSellButtonClick = "GG\custom\ExileClient_gui_wasteDumpDialog_event_onSellButtonClick.sqf"; ExileClient_gui_wasteDumpDialog_show = "GG\custom\ExileClient_gui_wasteDumpDialog_show.sqf"; ExileClient_gui_xm8_show = "GG\custom\ExileClient_gui_xm8_show.sqf"; ExileClient_gui_xm8_slide = "GG\custom\ExileClient_gui_xm8_slide.sqf"; ExileClient_gui_xm8_slide_territory_event_onTerritoryDropdownSelectionChanged = "GG\custom\ExileClient_gui_xm8_slide_territory_event_onTerritoryDropdownSelectionChanged.sqf"; ExileClient_object_item_construct = "GG\custom\ExileClient_object_item_construct.sqf"; ExileClient_object_player_event_onEnterSafezone = "GG\custom\ExileClient_object_player_event_onEnterSafezone.sqf"; ExileClient_object_player_event_onFired = "GG\custom\ExileClient_object_player_event_onFired.sqf"; ExileClient_object_player_event_onHandleDamage = "GG\custom\ExileClient_object_player_event_onHandleDamage.sqf"; ExileClient_object_player_event_onInventoryOpened = "GG\custom\ExileClient_object_player_event_onInventoryOpened.sqf"; ExileClient_object_player_event_onLeaveSafezone = "GG\custom\ExileClient_object_player_event_onLeaveSafezone.sqf"; ExileClient_object_player_network_createPlayerResponse = "GG\custom\ExileClient_object_player_network_createPlayerResponse.sqf"; ExileClient_system_locker_network_lockerResponse = "GG\custom\ExileClient_system_locker_network_lockerResponse.sqf"; ExileClient_system_trading_network_wasteDumpResponse = "GG\custom\ExileClient_system_trading_network_wasteDumpResponse.sqf"; ExileClient_util_gear_getCompatibleWeaponItems = "GG\custom\ExileClient_util_gear_getCompatibleWeaponItems.sqf"; ExileClient_util_item_getCompatibleWeaponItems = "GG\custom\ExileClient_util_item_getCompatibleWeaponItems.sqf"; ExileClient_util_playerEquipment_add = "GG\custom\ExileClient_util_playerEquipment_add.sqf"; ExileClient_gui_traderDialog_updateInventoryDropdown = "GG\custom\ExileClient_gui_traderDialog_updateInventoryDropdown.sqf"; ExileClient_gui_selectSpawnLocation_show = "GG\custom\ExileClient_gui_selectSpawnLocation_show.sqf"; ExileClient_gui_selectSpawnLocation_event_onListBoxSelectionChanged = "GG\custom\ExileClient_gui_selectSpawnLocation_event_onListBoxSelectionChanged.sqf"; };
15ed3a3537455c23d9762cf9de49efb3550b8960
943c074238dfd09df6da5207e3bd9e3019b0bbe8
/tests/shapes/testDigitalPlane.cpp
12ad0a53636fa06ff170fdf73d0d6e074d50115d
[]
no_license
fgrelard/MyDGtalContrib
452af03d5756477ab9f72abbf9e43a65e8747415
6fa32f4453672f411f54c67cfe28a146a2cc4312
refs/heads/master
2021-07-05T21:20:39.382846
2020-06-03T12:37:49
2020-06-03T12:37:49
74,741,006
1
0
null
2017-04-24T09:53:25
2016-11-25T08:48:25
C++
UTF-8
C++
false
false
3,398
cpp
testDigitalPlane.cpp
#include "shapes/DigitalPlane.h" #include "DGtal/base/Common.h" #include "DGtal/io/readers/GenericReader.h" #include "DGtal/io/writers/GenericWriter.h" #include "DGtal/kernel/BasicPointFunctors.h" #include "DGtal/images/ImageSelector.h" #include "DGtal/images/imagesSetsUtils/SetFromImage.h" #include "DGtal/io/viewers/Viewer3D.h" #include <QtGui/qapplication.h> using namespace std; using namespace DGtal; void testEquation() { trace.beginBlock("Test equation"); Z3i::RealVector normal(0.0486464, -0.750268, 0.659342); Z3i::Point center(159, 228, 170); DigitalPlane<Z3i::Space> plane2(center, normal, 6); int expectedD = (normal[0] * center[0] + normal[1] * center[1] + normal[2] * center[2]) * 1000; int expectedOmega = (std::abs(normal[0]) + std::abs(normal[1]) + std::abs(normal[2])) * 1000; if (plane2.getCenter() == center && plane2.getPlaneEquation().normal() == normal.getNormalized() && expectedD == (int)(plane2.getPlaneEquation().mu()*1000) && expectedOmega == (int)(plane2.getPlaneEquation().nu()*1000)) trace.info() << "Passed" << endl; else trace.info() << "Failed" << endl; trace.endBlock(); } void testContains() { trace.beginBlock("Test contains"); Z3i::RealVector normal(0.0486464, -0.750268, 0.659342); Z3i::Point center(159, 228, 170); DigitalPlane<Z3i::Space> plane2(center, normal, 6); Z3i::Point other(160,228,170); if (plane2.contains(center) && plane2.contains(other)) trace.info() << "Passed" << endl; else trace.info() << "Failed" << endl; trace.endBlock(); } void testPointAbove() { trace.beginBlock("Test point above"); Z3i::RealVector normal(0.0486464, -0.750268, 0.659342); Z3i::Point center(159, 228, 170); DigitalPlane<Z3i::Space> plane2(center, normal, 6); Z3i::Point other(158,227,169); if (plane2.isPointAbove(center) && plane2.isPointAbove(other)) trace.info() << "Passed" << endl; else trace.info() << "Failed" << endl; trace.endBlock(); } void testDigitalPlane(int argc, char** argv) { QApplication app(argc, argv); Viewer3D<> viewer; viewer.show(); Z3i::RealVector normal(0.0486464, -0.750268, 0.659342); typedef ImageSelector<Z3i::Domain, unsigned char>::Type Image; Image image = GenericReader<Image>::import("/home/florent/test_img/Pruning/Thinvox/bronche2_512_512_538.vol"); Z3i::DigitalSet setVolume(image.domain()); SetFromImage<Z3i::DigitalSet>::append<Image>(setVolume, image, 0, 255); Z3i::Point center(159, 228, 170); DigitalPlane<Z3i::Space> plane2(center, normal, 6); Z3i::DigitalSet planeSet2 = plane2.intersectionWithSetOneCC(setVolume); viewer << CustomColors3D(Color::Green, Color::Green) << center; viewer << CustomColors3D(Color::Red, Color::Red) <<planeSet2; viewer << CustomColors3D(Color(128,128,128,20), Color(128,128,128,20)) << setVolume; viewer << Viewer3D<>::updateDisplay; app.exec(); } int main(int argc, char** argv) { testEquation(); testContains(); testPointAbove(); testDigitalPlane(argc, argv); return 0; }
d87d7df6977c5dc90eb033376537ead649ef7a4c
f8c5682201f930a3bd7e102a36c3ee143f937b00
/include/Frame.h
c9ab0b7072c1872bded317569c4ed3c7ef47e522
[]
no_license
Roger-Chuh/EdgeDirectVO
c0cfb8b3544846addc831be0413ac4787954e308
5ff42dd402ed45b0dffddac5724d2822126c6603
refs/heads/master
2022-02-17T11:57:43.990356
2019-07-13T17:22:24
2019-07-13T17:22:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,884
h
Frame.h
#ifndef FRAME_H #define FRAME_H #include <opencv2/core/core.hpp> #include <Eigen/Core> #include <Eigen/Dense> #include <string> #include "Settings.h" #include <opencv2/ximgproc.hpp> //TODO make image pyramids, (Canny) edge pyramids, depth pyramids //TODO make derivative pyramids namespace EdgeVO{ class Sequence; class Frame{ public: Frame(); Frame(std::string imagePath, std::string depthPath, Sequence* seq); Frame(cv::Mat& image); Frame(cv::Mat& image, cv::Mat& depthMap); //Frame(const Frame& cp); ~Frame(); void printPaths(); //Frame& operator=(const Frame& rhs); //For cleanup void releaseAllVectors(); //For calculations cv::Mat getImage(int lvl) const; cv::Mat getDepthMap(int lvl) const; cv::Mat getMask(int lvl) const; cv::Mat getEdges(int lvl) const; cv::Mat getGradientX(int lvl) const; cv::Mat getGradientY(int lvl) const; void calcGX(cv::Mat &src); cv::Mat getGX(int lvl) const; cv::Mat getGY(int lvl) const; cv::Mat getImageVector(int lvl) const; void createPyramid(cv::Mat& src, std::vector<cv::Mat>& dst, int pyramidSize, int interpolationFlag); void calcGradientX(cv::Mat& src, cv::Mat& dst); void calcGradientY(cv::Mat& src, cv::Mat& dst); int getHeight(int lvl) const; int getWidth(int lvl) const; //For display purposes only cv::Mat& getImageForDisplayOnly(); cv::Mat& getEdgeForDisplayOnly(); cv::Mat& getDepthForDisplayOnly(); void makePyramids(); void createImageGradientPyramids(); // Canny Edges void createCannyEdgePyramids(); // LoG Edges void createLoGEdgePyramids(); // Sobel Edges void createSobelEdgePyramids(); // Structured Forests void createStructuredForestEdgePyramid(); // Extra Pyramid Layer with Full Image void createBasinPyramids(); void setDepthMap(cv::Mat& depthMap); bool hasDepthMap(); private: cv::Mat m_image; cv::Mat m_depthMap; cv::Mat m_edgeMap; std::vector<cv::Mat> m_pyramidImage; std::vector<cv::Mat> m_pyramidImageUINT; //std::vector<cv::Mat> m_pyramidImageFloat; std::vector<cv::Mat> m_pyramid_Idx; std::vector<cv::Mat> m_pyramid_Idy; std::vector<cv::Mat> m_pyramidEdge; std::vector<cv::Mat> m_pyramidDepth; std::vector<cv::Mat> m_pyramidMask; std::string m_imageName; std::string m_depthName; cv::Ptr<cv::ximgproc::StructuredEdgeDetection> m_sforestDetector; std::vector<cv::Mat> m_pyramidImageSF; Sequence* m_seq; Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic, Eigen::RowMajor> m_GX; }; } #endif //FRAME_H
52e005a1290f94ffcb290f1209d51e7c9b4ef7e9
0966b4619a2df70b3e0964af07bb5a724beee608
/source/http/http_response.hpp
4c5b4d46efb9481cccc5805038b40699c4cfcc3e
[]
no_license
puchninanastya/technopark-web-server
bc7bc9c92439773a9fab0ab5220075058642f216
c1947c3a7590eadfb4cf8ed35244c8812326a187
refs/heads/master
2020-03-27T23:09:21.256056
2018-11-19T16:14:38
2018-11-19T16:14:38
147,295,908
0
0
null
null
null
null
UTF-8
C++
false
false
1,000
hpp
http_response.hpp
#ifndef MONZZA_HTTP_RESPONSE_HPP #define MONZZA_HTTP_RESPONSE_HPP #include <string> #include <vector> #include "http_helpers.hpp" #include "http_request.hpp" namespace monzza { namespace http { class HttpResponse { public: HttpResponse(); ~HttpResponse(); int8_t getVersionMajor() const; int8_t getVersionMinor() const; int16_t getStatusCode() const; std::vector<HttpHeaderItem*>* getHeaders(); void setVersionMajor( int8_t versionMajor ); void setVersionMinor( int8_t versionMinor ); void setStatusCode( int16_t statusCode ); void addHeaderItem( std::string name, std::string value ); private: int8_t versionMajor_; int8_t versionMinor_; int16_t statusCode_; std::vector<HttpHeaderItem*> headers_; std::vector<uint8_t> content_; }; } } #endif // MONZZA_HTTP_RESPONSE_HPP
7182cccc4970c304bd8338cb45ee252730c340f8
b4f901dfe93a541214d967a389f93f83a5f21eec
/DefinesClearer/DefinesClearer.cpp
dd8cb487814bdb9218f8bb8e2d1ff54c30f91609
[]
no_license
tntultra/DefinesClearer
4dc4c64e29f711504f334ab0e244be62b138ccc9
cc42342babf8af23f52b8e8a09759cbe7f0e2297
refs/heads/master
2021-07-07T16:35:07.514665
2017-09-26T14:57:37
2017-09-26T14:57:37
104,764,484
0
0
null
null
null
null
UTF-8
C++
false
false
8,069
cpp
DefinesClearer.cpp
// DefinesClearer.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <vector> #include <set> #include <string> #include <unordered_map> #include <boost/filesystem.hpp> #include <boost/algorithm/string/find.hpp> #include <boost/algorithm/string/erase.hpp> #include <boost/algorithm/string/find.hpp> #include <boost/algorithm/string/trim.hpp> #include <regex> #include <cstdlib> using std::vector; using std::set; using std::string; using namespace boost::filesystem; string ProjectName; std::unordered_map<string, string> VPW_DEFINES; std::string get_env_var(std::string const & key) { auto val = getenv(key.c_str()); return val == nullptr ? std::string("") : std::string(val); } vector<path> get_all_files(path p) { vector<path> v; for (auto&& x : directory_iterator(p)) { auto path = x.path(); if (!is_directory(path) && path.extension() == ".cpp") v.push_back(path); } return v; } void get_vpw_defines(path p) { ifstream vpw_s{ p }; string entry, name, value; size_t pos; while (std::getline(vpw_s, entry)) { if ((pos = entry.find("<Set")) != string::npos) { auto namePos = entry.find("Name=\"", pos); auto cb = entry.find("\"", namePos + 6); auto len = cb - namePos - 6; name = entry.substr(namePos + 6, len); auto valuePos = entry.find("Value=", cb); char bracket = entry[valuePos + 6]; cb = entry.find(bracket, valuePos + 7); len = cb - valuePos - 7; value = entry.substr(valuePos + 7, len); if (bracket == '\"') { size_t prev = 0; string finalValue; while ((pos = value.find("%(", prev)) != string::npos) { finalValue += value.substr(prev, pos - prev); auto cb = value.find(")", pos); auto len = cb - pos - 2; auto macro = value.substr(pos + 2, len); auto it = VPW_DEFINES.find(macro); if (it == end(VPW_DEFINES)) { //get path variable macro = get_env_var(macro); } else {//alrdy exists macro = it->second; } finalValue += macro; prev = cb + 1; } finalValue += value.substr(prev); VPW_DEFINES[name] = finalValue; } else {//multiple defines } } } } set<string> get_defines_from_project_file(path p) { set<string> allDefines; ifstream ifs{ p }; string entry, previous; while (std::getline(ifs, entry)) { size_t namePos; if (entry.find("Defines=") != string::npos) { size_t currentDefinePos = 0; while ((currentDefinePos = entry.find("\"/D", currentDefinePos + 3)) != string::npos) { allDefines.insert(entry.substr(currentDefinePos + 3, entry.find('\"', currentDefinePos + 3)- currentDefinePos - 3)); } return allDefines; } else if ((namePos = entry.find("Name=\"")) != string::npos) { if (previous.find("<Config") != string::npos && !ProjectName.length()) { ProjectName = entry.substr(namePos + 6, entry.find('\"', namePos + 7) - namePos - 6); std::cout << ProjectName; } } previous = entry; } return allDefines; } bool simple_eval(const string& s, size_t open, size_t close, const set<string>& allDefines) { bool defined = (s[open - 1] != '!'); auto ob = s.find('(', open); auto cb = s.find(')', ob); auto macroName = s.substr(ob + 1, cb - ob - 1); return (defined && allDefines.find(macroName) != end(allDefines)) || (!defined && allDefines.find(macroName) == end(allDefines)); } bool full_eval_simple_line(const string& entry, bool removeRow, const set<string>& allDefines) { bool conjunction = (entry.find("&&") != string::npos); if ((conjunction && !removeRow) || (!conjunction && removeRow)) { //statement eval not determined yet size_t pos, cb = 0; while ((pos = entry.find("defined", cb)) != string::npos) { cb = entry.find(')', pos + 7); auto eval = simple_eval(entry, pos + 6, cb, allDefines); if (!conjunction && eval) { return false; } else if (conjunction && !eval) { return true; } } //if (pos == string::npos) { if (conjunction) { return false; } else { return true; } //} } } void convert_and_save_file(path f, const set<string>& allDefines) { ifstream ifs{ f }; auto filename = f.filename(); auto parentPath = f.parent_path(); auto outputFolder = parentPath.append(ProjectName); if (!exists(outputFolder)) { create_directory(outputFolder); } auto outputFileName = outputFolder.string() + "\\" + filename.string(); ofstream ofs{ outputFileName }; string entry; string macro; bool removeRow = false; size_t macroDepth = 0; size_t depthToRemove = 0; while (std::getline(ifs, entry)) { size_t pos, nameLen; //eval if ((pos = entry.find("#ifdef")) != string::npos) { ++macroDepth; if (macroDepth > 1 && removeRow) { continue; } pos += 7; for (nameLen = 0; pos + nameLen < entry.length() && !isspace(entry[pos+nameLen]); ++nameLen); auto macroName = entry.substr(pos, nameLen); if (macroName == "MAKE_RFR" && filename.string() == "hypertcf.cpp") { int a = removeRow + 10; ++a; if (a == 4) --a; } if (allDefines.find(macroName) == end(allDefines)) { macro = entry; removeRow = true; depthToRemove = macroDepth; } } else if ((pos = entry.find("#ifndef")) != string::npos) { ++macroDepth; if (macroDepth > 1 && removeRow) { continue; } pos += 8; for (nameLen = 0; pos + nameLen < entry.length() && !isspace(entry[pos + nameLen]); ++nameLen); auto macroName = entry.substr(pos, nameLen); if (allDefines.find(macroName) != end(allDefines)) { macro = entry; removeRow = true; depthToRemove = macroDepth; } } else if (entry.find("#if") != string::npos || entry.find("#elif") != string::npos) { ++macroDepth; if (macroDepth > 1 && removeRow) { continue; } //skip conditional defines if (entry.find(">") != string::npos || entry.find("<") != string::npos) { continue; } size_t pos = 0, open = 0, close = 0; //open = entry.find("(d"); close = entry.find("))", open); //process only "simple" evaluations if (close == string::npos) { //assuming only one logical sign in whole entry removeRow = full_eval_simple_line(entry, removeRow, allDefines); if (removeRow) { macro = entry; depthToRemove = macroDepth; } } } else if (entry.find("#else") != string::npos) { removeRow = !removeRow; } else if (entry.find("#endif") != string::npos) { if (macro == "#if defined(MAKE_SAMLIC) && defined(MAKE_FEP)") {//"conditional breakpoint" haha int a = removeRow + 10; ++a; if (a == 4) --a; } if (depthToRemove == macroDepth) { removeRow = false; depthToRemove = 0; } --macroDepth; if (macroDepth == 0) { removeRow = false; } } else if (entry.find ("//") == string::npos && //on commented line entry.find("@note") == string::npos && // on noted brief line entry.find("#error") == string::npos && // on error line (pos = entry.find("defined")) != string::npos) { if (entry[pos - 1] != '!' && !isspace(entry[pos - 1])) { //part of word/variable name continue; } boost::trim_left(entry); if (entry[0] == '*') { //part of brief continue; } //defines break from previous line removeRow = full_eval_simple_line(entry, removeRow, allDefines); if (removeRow) { macro = entry; depthToRemove = macroDepth; } } else { if (entry == " if (!IsRFRAllow())") {//another "conditional breakpoint" int a = removeRow+10; ++a; if (a == 4) --a; } if (!removeRow) { ofs << entry << std::endl; } } } } int main(int argc, char* argv[]) { if (argc > 1) { path VPJFile(argv[1]); path FolderToClear (argv[2]); if (exists(VPJFile) && is_regular_file(VPJFile) && exists(FolderToClear) && is_directory(FolderToClear)) { auto allDefines = get_defines_from_project_file(VPJFile); auto allFiles = get_all_files(FolderToClear); for (auto&& f : allFiles) { convert_and_save_file(f, allDefines); } } } return 0; }
8e414a17512df3a1f7cdf2ee5044df8c5d1f59bc
ba3e3936938d4b2a33c9315f0ade7f6ffcae453d
/Kernel/Stump.h
0024ded3131ab3c7d124ca74b51d819df531fa3a
[]
no_license
quipo/LibSVM--
7c1e2967a571c6df072c3568eee0aad047dd4bf4
03f763b153bce0a5058943537225b6206f1e3b8d
refs/heads/master
2021-01-04T14:21:32.765558
2010-08-30T21:40:59
2010-08-30T21:40:59
872,517
3
0
null
null
null
null
UTF-8
C++
false
false
604
h
Stump.h
/* * File: Stump.h * Author: Lorenzo Alberton * * Created on July 4, 2010, 4:54 PM */ #ifndef SVM_KERNEL_STUMP_H #define SVM_KERNEL_STUMP_H #include "../SVM_Kernel.h" class SVM_Kernel_Stump : public SVM_Kernel { public: SVM_Kernel_Stump(const SVM_Parameter & param) : SVM_Kernel(param) {}; SVM_Kernel_Stump(const node_matrix & x, const SVM_Parameter & param); ~SVM_Kernel_Stump(); Qfloat kernel(const std::vector<SVM_Node> & x, const std::vector<SVM_Node> & y, const SVM_Parameter & param) const; std::vector<double> get_diag(double c = 0) const; }; #endif /* SVM_KERNEL_STUMP_H */
b020292b1e2867e7727e3cf4ef2d74b20bc691f5
5e5aa48ccc669a16df83a73b179167b8a0945c8a
/libs/Utility.cpp
8ef3bafb0f9d4840188faba4e4e52750ca2ee8aa
[]
no_license
hoangtrongtin/qlnv_30thang12
6072fda6088cf659cdc8dba52e052fc6421085e0
9e33782cfc61101b118a644eabf87fe993290978
refs/heads/main
2023-02-09T07:00:56.218073
2020-12-31T02:15:56
2020-12-31T02:15:56
325,522,666
0
0
null
null
null
null
UTF-8
C++
false
false
799
cpp
Utility.cpp
#include "Utility.h" string Utility::SDecode(string s) { for(int i = 0; i < s.size(); i ++) if (s[i] == '$') s[i] = ' '; return s; } string Utility::SEncode(string s) { for(int i = 0; i < s.size(); i ++) if (s[i] == ' ') s[i] = '$'; return s; } string Utility::ToString(vector<string> vs) { string s = ""; for(string si: vs) s = s + SEncode(si) + " "; s[s.length()] = 0; // s.erase(s.length(), 1); return s; } vector<string> Utility::FromString(string s) { vector<string> vs; string stemp = ""; for(int i = 0; i < s.size(); i++){ if(s[i] != ' ') { stemp += s[i]; } else{ vs.push_back(SDecode(stemp)); stemp = ""; } } return vs; }
52583734a5a151bd5f349bd23108a2ffb1d1ab2a
6ec5dbb7837c9e73708fdbdd415d74263e785881
/433BaseballMainServer/433BaseballMainServer/GlobalManager.cpp
b0154c4ed66231192c861eb4dfc58e7b85704700
[]
no_license
433intern/433Baseball
e678fcbddc5b733029af1a3fd03c7c91807ce479
3d6ed384cdf8f488721a4d51fa804df6eb737737
refs/heads/master
2021-01-11T07:37:38.650726
2015-12-16T22:45:04
2015-12-16T22:45:04
46,963,522
1
1
null
null
null
null
UTF-8
C++
false
false
1,129
cpp
GlobalManager.cpp
#include "stdafx.h" CGlobalManager::CGlobalManager() { } CGlobalManager::~CGlobalManager() { } CGlobalManager &CGlobalManager::GetInstance() { static CGlobalManager globalManager; return globalManager; } bool CGlobalManager::Initializer(const std::string &dbServerIp, const unsigned short dbPort, const std::string &dbSchema, const std::string &dbStasticalTableName, const std::string &dbMatchRecordTableName, const std::string &dbOverloadRecordTableName, const std::string &dbUserName, const std::string &dbPassword, const unsigned short mainServerPort) { if (mainServerPort < 1024) { MYERRORPRINTF("You shouldn't use the well-known port numbers on clientPort."); return false; } this->mainServerPort = mainServerPort; this->dbSchemaName = dbSchema; this->dbServerIp = dbServerIp; this->dbUsername = dbUserName; this->dbPassword = dbPassword; this->dbStasticalTableName = dbStasticalTableName; this->dbMatchRecordTableName = dbMatchRecordTableName; this->dbStasticalTableName = dbStasticalTableName; this->dbOverloadRecordTableName = dbOverloadRecordTableName; this->dbPort = dbPort; return true; }
a82b19872323fb58085876879cdd14cf18f3852d
146a0bf67b99448b8a9f14ac77710fed2c64728e
/include/moonlight/generator.h
c49cb549956db12ef46ff5347a433074099a59a0
[ "MIT", "BSL-1.0", "LicenseRef-scancode-unknown-license-reference", "Zlib" ]
permissive
lainproliant/moonlight
552c27c5c4869508f5f7988a32e2810758085121
78ec2b99318636841af478d07f48c7481665c44a
refs/heads/main
2023-07-06T15:17:07.113556
2023-06-29T01:21:50
2023-06-29T01:21:50
159,224,136
3
0
null
null
null
null
UTF-8
C++
false
false
23,071
h
generator.h
/* * generator.h * * Author: Lain Musgrove (lain.proliant@gmail.com) * Date: Tuesday May 26, 2020 * * Distributed under terms of the MIT license. */ #ifndef __MOONLIGHT_GENERATOR_H #define __MOONLIGHT_GENERATOR_H #include <deque> #include <mutex> #include <condition_variable> #include <future> #include <optional> #include "moonlight/exceptions.h" #include "moonlight/variadic.h" namespace moonlight { namespace gen { template<class T> using Generator = std::function<std::optional<T>()>; /** * A template class allowing the results of a Generator lambda to be * wrapped in a standard library compatible iterator type and used with * constructs like algorithm templates and the ranged-for loop. * * Used as a building block for higher level composition abstractions, * such as gen::Stream. */ template<class T> class Iterator { public: typedef Generator<T> Closure; using iterator_category = std::input_iterator_tag; using difference_type = ptrdiff_t; using value_type = T; using pointer = const T*; using reference = const T&; Iterator() : _position(-1), _value({}) { } Iterator(const Closure& closure) : _closure(closure), _value(_closure()) { if (! _value.has_value()) { _position = -1; } } Iterator(const Iterator& iter) : _closure(iter._closure), _position(iter._position), _value(iter._value) { } Iterator<T>& operator++() { if (_value.has_value()) { auto new_value = _closure(); if (new_value.has_value()) { _value.emplace(new_value.value()); _position ++; } else { _value.reset(); _position = -1; } } return *this; } Iterator<T> operator++(int) { Iterator iter(*this); ++(*this); return iter; } Iterator<T> advance(const int distance) { auto iter = *this; for (int x = 0; x < distance && iter != gen::Iterator<T>(); x++, iter++); return iter; } bool operator==(const Iterator<T>& other) const { return (_position == -1 && other._position == -1) || (&_closure == &other._closure && _position == other._position); } bool operator==(Iterator<T>& other) const { return (_position == -1 && other._position == -1) || (&_closure == &other._closure && _position == other._position); } bool operator!=(const Iterator<T>& other) const { return !(*this == other); } bool operator!=(Iterator<T>& other) const { return !(*this == other); } int position() const { return _position; } const T& operator*() { if (_value.has_value()) { return *_value; } else { THROW(core::UsageError, "Attempted to dereference past the end of the sequence."); } } const T* operator->() { return &(operator*()); } private: Closure _closure; int _position = 0; std::optional<T> _value; }; /** * A queue template for asynchronously communicating the output * of a generator running in another thread with one or more * consumer threads. */ template<class T> class Queue { public: typedef std::future<std::optional<T>> Future; typedef std::function<void(const T&)> Handler; // Indicates that the generator has no more results to provide. void complete() { std::unique_lock<std::mutex> lock(_mutex); _completed = true; lock.unlock(); _cv.notify_all(); } // Called by the generator to yield a result into the queue. void yield(const T& value) { std::unique_lock<std::mutex> lock(_mutex); _yielded_items.push_back(value); lock.unlock(); _cv.notify_one(); } // Called by the consumer to get the next result from the queue. // Blocks until a result is provided, and may return an empty // optional if the generator completes after this method is // called on another thread and there are no more results to // consume. std::optional<T> next() { std::unique_lock<std::mutex> lock(_mutex); _cv.wait(lock, [&]{ return _yielded_items.empty() || _completed; }); if (_yielded_items.empty() && _completed) { return {}; } T value = _yielded_items.front(); _yielded_items.pop_front(); return value; } // See above, simply wraps the blocking behavior of `next()` // in an async future. Future async_next() { return std::async(std::launch::async, [&] { return this->next(); }); } // Block until all values from the generator have been consumed // and handled by the given handler callback. void process(Handler handler) { std::optional<T> value; while (value = this->next(), value) { handler(*value); } } // Wraps the above `process()` behavior in an async future. std::future<void> process_async(Handler handler) { return std::async(std::launch::async, [&] { std::optional<T> value; while (value = this->next(), value) { handler(*value); } }); } private: std::deque<T> _yielded_items; std::mutex _mutex; std::condition_variable _cv; bool _completed = false; }; /** * Type used to buffer stream results for look-ahead. */ template<class T> using Buffer = std::deque<T>; /** * Return the beginning of a virtual range representing the values * yielded by the given Generator lambda. */ template<class T> Iterator<T> begin(Generator<T> lambda) { return Iterator<T>(lambda); } /** * Return the end of any virtual range of the given type. */ template<class T> Iterator<T> end() { return Iterator<T>(); } /** * Creates a queue for processing the results of a Generator * asynchronously. * * @param factory A generator factory. * @param ... Subsequent parameters forwarded to the generator factory. * @return a shared_ptr to a newly created Queue object. */ template<class T, class... TD> std::shared_ptr<Queue<T>> async(std::function<std::optional<T>(TD...)> factory, TD... params) { std::shared_ptr<Queue<T>> queue = std::make_shared<Queue<T>>(); auto thread = std::async(std::launch::async, [&] { for (auto iter = begin(factory, std::forward(params)...); iter != end<T>(); iter++) { queue->yield(*iter); } queue->complete(); }); return queue; } /** * Wraps the given set of iterators as a range into a Generator. */ template<class I> std::function<std::optional<typename I::value_type>()> iterate(I begin, I end) { I current = begin; return [=]() mutable -> std::optional<typename I::value_type> { if (current == end) { return {}; } else { return *(current++); } }; } /** * Wraps the given set of iterators as a range into a Generator, * then returns the beginning of the virtual range wrapping that * Generator. Use this to reinterpret iterators of any type * as virtual Iterators. */ template<class I> Iterator<typename I::value_type> wrap(I begin_in, I end_in) { if (begin_in == end_in) { return Iterator<typename I::value_type>(); } return begin<typename I::value_type>(iterate(begin_in, end_in)); } /** * An iterator wrapper for functional composition over items in a virtual range. */ template<class T> class Stream { public: Stream() : _begin(gen::end<T>()) { } Stream(const gen::Iterator<T>& begin) : _begin(begin) { } Stream(const Generator<T>& generator) : _begin(generator) { } typedef T value_type; typedef std::function<Stream<T>()> Factory; /** * Lazily generates a stream from the given Factory function. */ static gen::Stream<T> lazy(const Factory& f); /** * Creates a stream consisting of one value. */ static gen::Stream<T> singleton(const T& value); /** * Creates a stream consisting of a single value result of a nullary * function call, which isn't evaluated until the stream is read. */ static gen::Stream<T> lazy_singleton(std::function<T()> f); /** * Creates an empty stream. */ static gen::Stream<T> empty(); /** * The beginning of the Stream's virtual range. */ gen::Iterator<T> begin() const { return _begin; } /** * The end of the Stream's virtual range. */ gen::Iterator<T> end() const { return gen::end<T>(); } /** * Concatenate two streams together into one. */ gen::Stream<T> operator+(const Stream<T>& other) const { gen::Iterator<T> iter = gen::end<T>(); int mode = 0; return gen::Stream<T>([=, this]() mutable -> std::optional<T> { while (iter == gen::end<T>() && mode < 2) { if (mode == 1) { iter = other.begin(); } else { iter = begin(); } mode++; } if (iter == gen::end<T>()) { return {}; } return *(iter ++); }); } gen::Stream<T>& operator+=(const Stream<T>& other) { auto combined = *(this) + other; _begin = combined._begin; return *this; } /** * Advance the stream forward n items, effectively skipping n items. */ gen::Stream<T> advance(int n) { return gen::Stream<T>(begin().advance(n)); } /** * Trim `left` items off of the left and `right` items off of the right * of the virtual range and stream the rest into a new Stream. * * NOTE: right trimming requires the use of a buffer the size of the right * trim amount, since virtual ranges are of unknown length. */ gen::Stream<T> trim(unsigned int left, unsigned int right); /** * Buffer the stream `bufsize` items forward. The resulting stream elements are all * references into the Buffer, with each step shifting the buffer forward one element. * * @param bufsize The size of the buffer. * @param squash Determines how to behave at the end of the scalar sequence. * If `true`, items are removed from the beginning of the buffer each step until * it is empty. The buffer is allowed to be smaller than `bufsize`. * If `false` (the default), the buffered sequence ends when the scalar sequence * ends. The buffer is not allowed to be smaller than `bufsize`, thus if the * scalar sequence is smaller than `bufsize`, the stream is empty. */ gen::Stream<std::reference_wrapper<Buffer<T>>> buffer(int bufsize, bool squash = false); /** * Scans to the last item of the stream and returns it. * If the stream is empty, nothing is returned. */ std::optional<T> last() { std::optional<T> last_item = {}; for (auto value : *this) { last_item = value; } return last_item; } /** * Streams only the first `n` elements of this stream. */ gen::Stream<T> limit(int n) { int offset = 0; auto iter = begin(); return gen::Stream<T>([=]() mutable -> std::optional<T> { if (offset < n && iter != gen::end<T>()) { offset++; return *iter++; } return {}; }); } /** * Sort all of the elements in ths stream, then stream from the resulting * sorted collection. */ gen::Stream<T> sorted() const { std::optional<std::deque<T>> lazy_sorted = {}; return gen::Stream<T>([=, this]() mutable -> std::optional<T> { if (! lazy_sorted.has_value()) { lazy_sorted = std::deque<T>(); std::copy(begin(), end(), std::back_inserter(*lazy_sorted)); std::sort(lazy_sorted->begin(), lazy_sorted->end()); } if (! lazy_sorted->empty()) { auto value = lazy_sorted->front(); lazy_sorted->pop_front(); return value; } else { return {}; } }); } /** * Streams a new stream of streams resulting from applying the function `f` to each * element in this stream, where `f` generates a stream of results for each element. */ template<class R> gen::Stream<gen::Stream<R>> transform_split(std::function<gen::Stream<R>(const T&)> f) const { Iterator<T> iter = begin(); return gen::Stream<gen::Stream<R>>([=, this]() mutable -> std::optional<gen::Stream<R>> { if (iter == end()) { return {}; } return f(*iter++); }); } /** * Streams a new stream of streams resulting from applying the function `f` to each * element in this stream, where `f` generates a stream of results for each element. */ gen::Stream<gen::Stream<T>> transform_split(std::function<gen::Stream<T>(const T&)> f) const { return transform_split<T>(f); } /** * Transform each element in the stream using the given function. * Items for which the function returns an empty optional are skipped. */ template<class R = T> gen::Stream<R> transform(std::function<std::optional<R>(const T&)> f) const { auto iter = begin(); std::optional<R> result; return gen::Stream<R>([=, this]() mutable -> std::optional<R> { while (iter != end()) { result = f(*iter); iter++; if (result.has_value()) { return result.value(); } } return {}; }); } /** * Call the given function for each element in the stream, or until * the given function returns `false` to indicate the loop should * be terminated early. */ void for_each(std::function<bool (const T&)> f) const { auto iter = begin(); for (auto iter = begin(); iter != end(); iter++) { if (! f(*iter)) { break; } } } /** * Call the given function for each element in the stream. */ void for_each(std::function<void (const T&)> f) const { for (auto iter = begin(); iter != end(); iter++) { f(*iter); } } /** * Transform each element in the stream using the given function. */ template<class R = T> gen::Stream<R> transform(std::function<R(const T&)> f) const { return transform<R>([=](const T& value) -> std::optional<T> { return f(value); }); } /** * Create a new stream containing only items in this stream which match * the predicate. */ gen::Stream<T> filter(std::function<bool(const T&)> predicate) const { return transform<T>([=](const T& value) -> std::optional<T> { if (predicate(value)) { return value; } return {}; }); } /** * Returns distinct items only once in the stream. */ gen::Stream<T> unique() const { std::set<T> sieve = {}; Iterator<T> iter = begin(); return gen::Stream<T>([=, this]() mutable -> std::optional<T> { while(iter != end() && sieve.find(*iter) != sieve.end()) { iter++; } if (iter == end()) { return {}; } sieve.insert(*iter); return *iter++; }); } /** * Collects all of the items in the stream into a new collection (std::vector by default). */ template<template<class, class> class C = std::vector, template<class> class A = std::allocator> C<T, A<T>> collect() const { C<T, A<T>> result; result.insert(result.begin(), begin(), end()); return result; } /** * Collects all of the pairs from a stream into a mapped collection. */ template<class M> M map_collect(std::function<std::pair<typename M::key_type, typename M::mapped_type>(const T& value)> f) const { M map; for (auto iter = begin(); iter != end(); iter++) { map.insert(f(*iter)); } return map; } template<class K, class V> std::unordered_map<K, V> map_collect(std::function<std::pair<K, V>(const T&)> f) const { return map_collect<std::unordered_map<K, V>>(f); } /** * Collects all of the items in the stream into an std::vector. */ std::vector<T> collect() const { return collect<std::vector>(); } /** * Determine if all of the items in the sequence match a predicate. */ bool all(std::function<bool(const T&)> f) const { for (auto iter = begin(); iter != end(); iter++) { if (! f(*iter)) { return false; } } return true; } /** * Determine if any of the items in the sequence match a predicate. */ bool any(std::function<bool(const T&)> f) const { for (auto iter = begin(); iter != end(); iter++) { if (f(*iter)) { return true; } } return false; } /** * Determine if none of the items in the sequence match a predicate. */ bool none(std::function<bool(const T&)> f) const { for (auto iter = begin(); iter != end(); iter++) { if (f(*iter)) { return false; } } return true; } /** * Reduce the items in the sequence to a single value. */ template<class R = T> R reduce(std::function<R(const R& acc, const T& value)> f, const R& init = R()) { R acc = init; for (auto iter = begin(); iter != end(); iter++) { acc = f(acc, *iter); } return acc; } /** * Produce the sum of all of the items in the sequence. */ template<class R = T> R sum() { return reduce<R>([](const R& acc, const T& value) { return acc + value; }); } /** * Joins all of the items in the stream, as strings, with the given separator. */ std::string join(const std::string& sep) { std::ostringstream sb; for (auto iter = begin(); iter != end(); iter++) { sb << *iter; if (std::next(iter) != end()) { sb << sep; } } return sb.str(); } /** * Determine if the stream is currently empty. */ bool is_empty() const { return _begin() == gen::end<T>(); } protected: void init(const gen::Iterator<T>& begin) { _begin = begin; } private: gen::Iterator<T> _begin; }; template<class T> class InitListStream : public Stream<T> { public: InitListStream(const std::initializer_list<T>& init_list) : Stream<T>(gen::end<T>()), _vec(init_list) { this->init(gen::iterate(_vec.begin(), _vec.end())); } private: std::vector<T> _vec; }; /** * Streams values from a mutable closure (i.e. generator). * Equivalent to `gen::begin`, but wraps the result in a stream. */ template<class T> gen::Stream<T> stream(Generator<T> lambda) { return gen::Stream<T>(gen::begin(lambda)); } /** * Stream the given iterable collection. */ template<class C> gen::Stream<typename C::value_type> stream(const C& coll) { return gen::stream<typename C::value_type>(gen::iterate(coll.begin(), coll.end())); } template<class T> gen::InitListStream<T> stream(std::initializer_list<T> init_list) { return InitListStream<T>(init_list); } template<class T> gen::Stream<T> one(const T& t) { return gen::Stream<T>::singleton(t); } template<class T> gen::Stream<T> nothing() { return gen::Stream<T>(); } template<class T> inline gen::Stream<T> gen::Stream<T>::lazy_singleton(std::function<T()> f) { bool yielded = false; return gen::Stream<T>([=]() mutable -> std::optional<T> { if (yielded == false) { yielded = true; return f(); } return {}; }); } /** * Yield a stream containing one value. */ template<class T> inline gen::Stream<T> gen::Stream<T>::singleton(const T& value) { bool yielded = false; return gen::Stream<T>([=]() mutable -> std::optional<T> { if (yielded == false) { yielded = true; return value; } return {}; }); } /** * Lazily evaluate a stream. */ template<class T> inline gen::Stream<T> gen::Stream<T>::lazy(const typename gen::Stream<T>::Factory& f) { return (Stream<Stream<T>>::empty() + Stream<Stream<T>>::lazy_singleton(f)).sum(); } /** * Yield an empty stream. */ template<class T> inline gen::Stream<T> gen::Stream<T>::empty() { return gen::Stream(end<T>()); } /** * Create a buffered stream that scrolls a buffered deque view of * items through the sequence with the given look-ahead. * * If squash is True, reaching the end of the sequence will pop items * off of the end of the deque until it is empty. Otherwise, * the buffered sequence will end after the end of the main * sequence is reached. */ template<class T> inline gen::Stream<std::reference_wrapper<Buffer<T>>> gen::Stream<T>::buffer(int bufsize, bool squash) { Buffer<T> buffer; auto iter = begin(); bool initialized = false; return gen::stream<std::reference_wrapper<Buffer<T>>>([=]() mutable -> std::optional<std::reference_wrapper<Buffer<T>>> { if (! initialized) { while (buffer.size() < bufsize && iter != gen::end<T>()) { buffer.push_back(*iter); iter++; } initialized = true; // If squash is false and we couldn't fill the buffer, return nothing. if (squash || buffer.size() == bufsize) { return buffer; } return {}; } if (iter != gen::end<T>()) { buffer.pop_front(); buffer.push_back(*iter); iter++; return buffer; } else if (squash) { buffer.pop_front(); if (! buffer.empty()) { return buffer; } return {}; } return {}; }); } /** * Trim the given number of elements from the beginning * and/or end of the stream. */ template<class T> gen::Stream<T> gen::Stream<T>::trim(unsigned int left, unsigned int right) { gen::Stream<T> stream = *this; if (right != 0) { stream = stream.buffer(right + 1).template transform<T>([](auto& buf) { return buf.get().front(); }); } if (left != 0) { stream = stream.advance(left); } return stream; } } } #endif /* !__MOONLIGHT_GENERATOR_H */
def8d289016b44b847211ccc68264e11660747ae
7c971e471772c53b848b62c9407dd0bf3625c4a3
/acm/2587/2587.cpp
534d8c8c97b0b2b92e818cd26bb60465ec5bbb2f
[]
no_license
kimmikimmi/Algopool
bdc40c3af90f8f453adbdd673d2c91f1af325ad3
cc88ec7bc8fac701309034f171a9b52408b532c2
refs/heads/master
2020-04-15T14:28:50.802255
2016-09-11T12:50:51
2016-09-11T12:50:51
52,717,356
0
0
null
null
null
null
UTF-8
C++
false
false
557
cpp
2587.cpp
#include <iostream> #include <vector> #include <algorithm> #include <list> #include <map> #include <cmath> #include <cstdio> #include <cstring> #include <stack> #include <tuple> #include <set> using namespace std; vector<int> my_vec(5); void input(std::istream& pin) { for(int i=0; i<5; i++) { int tmp; pin >> tmp; my_vec[i] = tmp; } } int method() { return 0; } int main() { input(cin); sort(my_vec.begin(), my_vec.end()); int sum = 0; for(auto& it : my_vec) { sum += it; } cout << sum/5 << endl <<my_vec[2] << endl; return 0; }
a7b68878937ea6522146a887daba717e3fe60493
1faa2601f5c5d05a8dfa851c06a0fc07317386e5
/test/unittests/t_polymorphic_construction.cc
762811eaa705d1cf257d626252c332fe92b8f397
[]
permissive
cvmfs/cvmfs
216aecc8921ac7fcd5cec5a8baf37870cdc42d0f
bb69086badd32d8f9566ed5dcedff1fd1b0ccc5e
refs/heads/devel
2023-08-24T09:17:29.248662
2023-08-15T09:08:27
2023-08-15T09:08:27
3,784,908
231
118
BSD-3-Clause
2023-09-13T10:50:09
2012-03-21T09:10:41
C++
UTF-8
C++
false
false
14,339
cc
t_polymorphic_construction.cc
/** * This file is part of the CernVM File System. */ #include <gtest/gtest.h> #include <cstdlib> #include <string> #include "testutil.h" #include "util/plugin.h" #include "util/prng.h" struct DecisionType { DecisionType() : type(-1), fail(false) {} int type; bool fail; }; struct IntrospectionType { IntrospectionType(const int type, const std::string &message) : message(message), type(type) {} std::string message; int type; }; class AbstractPolyCtorMock : public PolymorphicConstruction<AbstractPolyCtorMock, DecisionType, IntrospectionType> { public: static unsigned int constructor_calls; static unsigned int initialize_calls; static unsigned int initializes_failed; static unsigned int register_plugin_calls; static void Reset() { AbstractPolyCtorMock::constructor_calls = 0; AbstractPolyCtorMock::initialize_calls = 0; AbstractPolyCtorMock::initializes_failed = 0; AbstractPolyCtorMock::register_plugin_calls = 0; } static void ResetAll(); public: static void RegisterPlugins(); explicit AbstractPolyCtorMock(const DecisionType &param) : param_(param) { AbstractPolyCtorMock::constructor_calls++; } virtual bool Initialize() { AbstractPolyCtorMock::initialize_calls++; if (param_.fail) { AbstractPolyCtorMock::initializes_failed++; } return !param_.fail; } protected: const DecisionType param_; }; unsigned int AbstractPolyCtorMock::constructor_calls = 0; unsigned int AbstractPolyCtorMock::initialize_calls = 0; unsigned int AbstractPolyCtorMock::initializes_failed = 0; unsigned int AbstractPolyCtorMock::register_plugin_calls = 0; //------------------------------------------------------------------------------ class FirstPolyCtorMock : public AbstractPolyCtorMock { public: static const int type_id = 0; static const std::string message; static unsigned int constructor_calls; static void Reset() { FirstPolyCtorMock::constructor_calls = 0; } public: static bool WillHandle(const DecisionType &param) { return (param.type == FirstPolyCtorMock::type_id); } explicit FirstPolyCtorMock(const DecisionType &param) : AbstractPolyCtorMock(param) { FirstPolyCtorMock::constructor_calls++; } static IntrospectionType GetInfo() { return IntrospectionType(FirstPolyCtorMock::type_id, FirstPolyCtorMock::message); } }; unsigned int FirstPolyCtorMock::constructor_calls = 0; const std::string FirstPolyCtorMock::message = "Hello from First."; //------------------------------------------------------------------------------ class SecondPolyCtorMock : public AbstractPolyCtorMock { public: static const int type_id = 1; static const std::string message; static unsigned int constructor_calls; static void Reset() { SecondPolyCtorMock::constructor_calls = 0; } public: static bool WillHandle(const DecisionType &param) { return (param.type == SecondPolyCtorMock::type_id); } explicit SecondPolyCtorMock(const DecisionType &param) : AbstractPolyCtorMock(param) { SecondPolyCtorMock::constructor_calls++; } static IntrospectionType GetInfo() { return IntrospectionType(SecondPolyCtorMock::type_id, SecondPolyCtorMock::message); } }; unsigned int SecondPolyCtorMock::constructor_calls = 0; const std::string SecondPolyCtorMock::message = "Second calling!"; //------------------------------------------------------------------------------ class ThirdPolyCtorMock : public AbstractPolyCtorMock { public: static const int type_id = 2; static const std::string message; static unsigned int constructor_calls; static unsigned int initialize_calls; static void Reset() { ThirdPolyCtorMock::constructor_calls = 0; ThirdPolyCtorMock::initialize_calls = 0; } public: static bool WillHandle(const DecisionType &param) { return (param.type == ThirdPolyCtorMock::type_id); } explicit ThirdPolyCtorMock(const DecisionType &param) : AbstractPolyCtorMock(param) { ThirdPolyCtorMock::constructor_calls++; } static IntrospectionType GetInfo() { return IntrospectionType(ThirdPolyCtorMock::type_id, ThirdPolyCtorMock::message); } bool Initialize() { ThirdPolyCtorMock::initialize_calls++; return AbstractPolyCtorMock::Initialize(); } }; unsigned int ThirdPolyCtorMock::constructor_calls = 0; unsigned int ThirdPolyCtorMock::initialize_calls = 0; const std::string ThirdPolyCtorMock::message = "Third à l'appareil."; //------------------------------------------------------------------------------ void AbstractPolyCtorMock::RegisterPlugins() { AbstractPolyCtorMock::register_plugin_calls++; RegisterPlugin<FirstPolyCtorMock>(); RegisterPlugin<SecondPolyCtorMock>(); RegisterPlugin<ThirdPolyCtorMock>(); } void AbstractPolyCtorMock::ResetAll() { AbstractPolyCtorMock::Reset(); FirstPolyCtorMock::Reset(); SecondPolyCtorMock::Reset(); ThirdPolyCtorMock::Reset(); } typedef AbstractPolyCtorMock::IntrospectionData IntrospectionData; //------------------------------------------------------------------------------ class T_PolymorphicConstruction : public ::testing::Test { protected: void SetUp() { PolymorphicConstructionUnittestAdapter:: UnregisterAllPlugins<AbstractPolyCtorMock>(); AbstractPolyCtorMock::ResetAll(); } }; //------------------------------------------------------------------------------ TEST_F(T_PolymorphicConstruction, Noop) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); } TEST_F(T_PolymorphicConstruction, Introspect) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); IntrospectionData v = AbstractPolyCtorMock::Introspect(); EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); EXPECT_EQ(0u, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(0u, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(0u, FirstPolyCtorMock::constructor_calls); EXPECT_EQ(0u, SecondPolyCtorMock::constructor_calls); EXPECT_EQ(0u, ThirdPolyCtorMock::constructor_calls); EXPECT_EQ(3u, v.size()); bool found_1 = false; bool found_2 = false; bool found_3 = false; EXPECT_TRUE(!found_1 && !found_2 && !found_3); IntrospectionData::const_iterator i = v.begin(); IntrospectionData::const_iterator iend = v.end(); for (; i != iend; ++i) { if (i->type == FirstPolyCtorMock::type_id && i->message == FirstPolyCtorMock::message) { found_1 = true; } if (i->type == SecondPolyCtorMock::type_id && i->message == SecondPolyCtorMock::message) { found_2 = true; } if (i->type == ThirdPolyCtorMock::type_id && i->message == ThirdPolyCtorMock::message) { found_3 = true; } } EXPECT_TRUE(found_1 && found_2 && found_3); IntrospectionData w = AbstractPolyCtorMock::Introspect(); EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); } TEST_F(T_PolymorphicConstruction, CreateFirst) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); DecisionType t; t.type = 0; AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); EXPECT_NE(static_cast<AbstractPolyCtorMock*>(NULL), mock); EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(1u, FirstPolyCtorMock::constructor_calls); EXPECT_EQ(0u, SecondPolyCtorMock::constructor_calls); EXPECT_EQ(0u, ThirdPolyCtorMock::constructor_calls); delete mock; } TEST_F(T_PolymorphicConstruction, CreateSecond) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); DecisionType t; t.type = 1; AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); EXPECT_NE(static_cast<AbstractPolyCtorMock*>(NULL), mock); EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(0u, FirstPolyCtorMock::constructor_calls); EXPECT_EQ(1u, SecondPolyCtorMock::constructor_calls); EXPECT_EQ(0u, ThirdPolyCtorMock::constructor_calls); delete mock; } TEST_F(T_PolymorphicConstruction, CreateThird) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); DecisionType t; t.type = 2; AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); EXPECT_NE(static_cast<AbstractPolyCtorMock*>(NULL), mock); EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(0u, FirstPolyCtorMock::constructor_calls); EXPECT_EQ(0u, SecondPolyCtorMock::constructor_calls); EXPECT_EQ(1u, ThirdPolyCtorMock::constructor_calls); EXPECT_EQ(1u, ThirdPolyCtorMock::initialize_calls); delete mock; } TEST_F(T_PolymorphicConstruction, CreateUnknown) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); DecisionType t; t.type = -1; AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); EXPECT_EQ(static_cast<AbstractPolyCtorMock*>(NULL), mock); EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); EXPECT_EQ(0u, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(0u, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(0u, FirstPolyCtorMock::constructor_calls); EXPECT_EQ(0u, SecondPolyCtorMock::constructor_calls); EXPECT_EQ(0u, ThirdPolyCtorMock::constructor_calls); } TEST_F(T_PolymorphicConstruction, CreateAll) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); for (int i = 0; i < 3; ++i) { DecisionType t; t.type = i; AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); EXPECT_NE(static_cast<AbstractPolyCtorMock*>(NULL), mock); delete mock; } EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); EXPECT_EQ(3u, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(3u, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(1u, FirstPolyCtorMock::constructor_calls); EXPECT_EQ(1u, SecondPolyCtorMock::constructor_calls); EXPECT_EQ(1u, ThirdPolyCtorMock::constructor_calls); EXPECT_EQ(1u, ThirdPolyCtorMock::initialize_calls); } TEST_F(T_PolymorphicConstruction, CreateMany) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); const unsigned int runs = 100000; unsigned int ctors[] = { 0, 0, 0, 0 }; Prng prng; prng.InitLocaltime(); for (unsigned int i = 0; i < runs; ++i) { DecisionType t; t.type = prng.Next(4); AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); if (t.type == 3) { EXPECT_EQ(static_cast<AbstractPolyCtorMock*>(NULL), mock); } else { EXPECT_NE(static_cast<AbstractPolyCtorMock*>(NULL), mock); delete mock; } ++ctors[t.type]; } EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); const unsigned int all_ctors = ctors[0] + ctors[1] + ctors[2]; const unsigned int fails = runs - all_ctors; EXPECT_EQ(all_ctors, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(all_ctors, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(ctors[0], FirstPolyCtorMock::constructor_calls); EXPECT_EQ(ctors[1], SecondPolyCtorMock::constructor_calls); EXPECT_EQ(ctors[2], ThirdPolyCtorMock::constructor_calls); EXPECT_EQ(ctors[2], ThirdPolyCtorMock::initialize_calls); EXPECT_EQ(ctors[3], fails); } TEST_F(T_PolymorphicConstruction, FailedInitOfFirst) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); DecisionType t; t.type = 0; t.fail = true; AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); EXPECT_EQ(static_cast<AbstractPolyCtorMock*>(NULL), mock); EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(1u, FirstPolyCtorMock::constructor_calls); EXPECT_EQ(0u, SecondPolyCtorMock::constructor_calls); EXPECT_EQ(0u, ThirdPolyCtorMock::constructor_calls); } TEST_F(T_PolymorphicConstruction, FailedInitOfThird) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); DecisionType t; t.type = 2; t.fail = true; AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); EXPECT_EQ(static_cast<AbstractPolyCtorMock*>(NULL), mock); EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(1u, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(0u, FirstPolyCtorMock::constructor_calls); EXPECT_EQ(0u, SecondPolyCtorMock::constructor_calls); EXPECT_EQ(1u, ThirdPolyCtorMock::constructor_calls); EXPECT_EQ(1u, ThirdPolyCtorMock::initialize_calls); } TEST_F(T_PolymorphicConstruction, CreateManyWithFailures) { EXPECT_EQ(0u, AbstractPolyCtorMock::register_plugin_calls); const unsigned int runs = 100000; unsigned int ctors[] = { 0, 0, 0, 0 }; unsigned int fails = 0; Prng prng; prng.InitLocaltime(); for (unsigned int i = 0; i < runs; ++i) { DecisionType t; t.type = prng.Next(4); t.fail = (prng.Next(2) == 0); AbstractPolyCtorMock *mock = AbstractPolyCtorMock::Construct(t); if (t.fail && t.type < 3) { ++fails; } if (t.type == 3 || t.fail) { EXPECT_EQ(static_cast<AbstractPolyCtorMock*>(NULL), mock); } else { EXPECT_NE(static_cast<AbstractPolyCtorMock*>(NULL), mock); delete mock; } ++ctors[t.type]; } EXPECT_EQ(1u, AbstractPolyCtorMock::register_plugin_calls); const unsigned int all_ctors = ctors[0] + ctors[1] + ctors[2]; const unsigned int unknowns = runs - all_ctors; EXPECT_EQ(all_ctors, AbstractPolyCtorMock::constructor_calls); EXPECT_EQ(all_ctors, AbstractPolyCtorMock::initialize_calls); EXPECT_EQ(ctors[0], FirstPolyCtorMock::constructor_calls); EXPECT_EQ(ctors[1], SecondPolyCtorMock::constructor_calls); EXPECT_EQ(ctors[2], ThirdPolyCtorMock::constructor_calls); EXPECT_EQ(ctors[2], ThirdPolyCtorMock::initialize_calls); EXPECT_EQ(ctors[3], unknowns); EXPECT_EQ(fails, AbstractPolyCtorMock::initializes_failed); }
d4e5978073ffdeb421ece396549a1010ac4dd266
de59ed7818fe43cb85a52e88cf2524637775c465
/김혜준/백준 & 프로그래머스 문제/10월/1012/(20056번) 마법사 상어와 파이어볼.cpp
28dce9bc343e6935d8f7a3be91b9dd5996bc24e2
[]
no_license
Kim-Hye-Jun/Algorithm-1
2ffe00fa5213cc98961cfdc5c354d5282cf594aa
99f0973ec1288e8c40ea56d12121f5d73283bc17
refs/heads/main
2023-09-04T16:53:46.243635
2021-10-16T02:06:15
2021-10-16T02:06:15
398,989,785
0
0
null
2021-08-23T05:59:00
2021-08-23T05:58:59
null
UTF-8
C++
false
false
2,048
cpp
(20056번) 마법사 상어와 파이어볼.cpp
#include <iostream> #include <vector> using namespace std; int N,M,K; int dx[8]={-1,-1,0,1,1,1,0,-1}; int dy[8]={0,1,1,1,0,-1,-1,-1}; int num=0; typedef struct fireBall{ int x; int y; int m; int dir; int speed; bool live=true; }FB; vector<FB> arr[50][50]; vector<FB> fbV; void input(){ cin >> N >> M >> K; num=M; for(int i=0;i<M;i++){ int r,c,m,s,d; cin >> r >> c >> m >> s >> d; r-=1; c-=1; FB f; f.x=r; f.y=c; f.m=m; f.dir=d; f.speed=s; fbV.push_back(f); arr[r][c].push_back(f); } } bool check(int x,int y){ if(x>=0&&x<N&&y>=0&&y<N) return true; return false; } void move(){ for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ arr[i][j].clear(); } } for(int i=0;i<fbV.size();i++){ FB cur = fbV[i]; int x = cur.x; int y = cur.y; int dir = cur.dir; int sp = cur.speed; int nx = x+dx[dir]*sp; int ny = y+dy[dir]*sp; while(nx<0){ nx+=N; } while(ny<0){ ny+=N; } nx%=N; ny%=N; cur.x=nx; cur.y=ny; arr[nx][ny].push_back(cur); } } void sum(){ vector<FB> temp; for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ if(arr[i][j].size()==0) continue; else if(arr[i][j].size()==1) temp.push_back(arr[i][j][0]); else{ int m=0,s=0,odd=0,even=0; for(int k=0;k<arr[i][j].size();k++){ FB cur = arr[i][j][k]; m+=cur.m; s+=cur.speed; if(cur.dir%2==1) odd++; else even++; } m/=5; if(m==0) continue; s/=arr[i][j].size(); if(odd==0||even==0){ for(int q=0;q<4;q++){ temp.push_back({i,j,m,2*q,s}); } }else{ for(int q=0;q<4;q++){ temp.push_back({i,j,m,2*q+1,s}); } } } } } fbV=temp; } void solve(){ for(int i=0;i<K;i++){ move(); sum(); } int ret=0; for(auto w:fbV){ ret+=w.m; } cout << ret; } int main() { input(); solve(); }
9beae88e6e6e9feaeaf262ff6ceabf7d5353504d
175d783916d1c08e8eb05a964e85dc9f1ee689f7
/PointCloud/extracterType.h
0b2d746b1ce4c1e3d1c38ec56ec337d6849894fd
[]
no_license
Armida220/pointCloud
cfc146530690076591f7ea8bc615a4da56ffd7d1
9a6d4c277f7631ba75f4ae25f60ef2726f430312
refs/heads/master
2020-05-03T02:02:21.389697
2019-03-29T03:44:35
2019-03-29T03:44:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
392
h
extracterType.h
#pragma once #include <string> namespace feature { enum ExtracterType { SIFT = 1, SURF }; /** * @brief this function convert feature::ExtracterType to string */ std::string extracterTypeToString(ExtracterType extracterType); /** * @brief this function convert feature::ExtracterType to string */ ExtracterType stringToExtracterType(const std::string& extracterType); }
402a6969dc10decd3c2e10ad89ca7e645dc2d945
4973f3efd66cc7d29c5a69ab055ff14aff046afb
/src/phlib/pointer_iterator.hpp
bc93e81fab7270cbf09e831b6f3e216a4985fb24
[ "BSD-2-Clause" ]
permissive
andrey-nakin/phlib
b467d09d64015b7637c90fd879503e49f5335434
f3a23bd1ce39e3873c4289d26f626de2010415ae
refs/heads/master
2021-01-20T12:20:36.770354
2015-12-03T17:26:29
2015-12-03T17:26:29
4,891,546
0
0
null
null
null
null
UTF-8
C++
false
false
2,514
hpp
pointer_iterator.hpp
/* * pointer_iterator.hpp -- * * This file is part of phlib library. * * Copyright (c) 2012 Andrey V. Nakin <andrey.nakin@gmail.com> * All rights reserved. * * See the file "COPYING" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #ifndef POINTER_ITERATOR_HPP_ #define POINTER_ITERATOR_HPP_ #include <iterator> namespace phlib { /** * Class is used to iterate through containers of pointers */ template <class ValueType, class PointerType, class IteratorType> class PointerIterator : public std::iterator< std::bidirectional_iterator_tag, ValueType, ptrdiff_t, PointerType, typename IteratorType::reference> { IteratorType source; public: typedef typename IteratorType::difference_type difference_type; PointerIterator(IteratorType source) : source(source) {} PointerIterator(const PointerIterator& source) : source(source.source) {} inline PointerIterator& operator=(const PointerIterator i) { source = i.source; return *this; } inline PointerIterator& operator++() { ++source; return *this; } inline PointerIterator operator++(int) { PointerIterator tmp(*this); source++; return tmp; } inline PointerIterator& operator--() { --source; return *this; } inline PointerIterator operator--(int) { PointerIterator tmp(*this); source--; return tmp; } inline ValueType& operator*() { return **source; } inline ValueType& operator*() const { return **source; } inline PointerType operator->() { return *source; } inline PointerType operator->() const { return *source; } inline bool operator==(const PointerIterator i) const { return source == i.source; } inline bool operator!=(const PointerIterator i) const { return source != i.source; } template <class Distance> inline PointerIterator operator+(const Distance& d) const { return PointerIterator(source + d); } template <class Distance> inline PointerIterator operator-(const Distance& d) const { return PointerIterator(source - d); } inline PointerIterator operator+(const difference_type& n) const { return PointerIterator(source + n); } inline PointerIterator operator-(const difference_type& n) const { return PointerIterator(source - n); } }; } #endif /* POINTER_ITERATOR_HPP_ */
239844fcf10cb64f53620f61c3a039b8d0a8a242
6c395b91b034eb3bf28a17f4e475e2b08f2489ef
/src/Tmapping/src/global.cpp
0279208f44e6c05a0bbd4540b48f7aeb1b014967
[ "MIT" ]
permissive
Forrest-Z/gcy_tmap
4f69ef0116bbd76cffdca5f0bd6abe6d7ef41470
33661661ac27be3480146b46dca0d33d09bb9b96
refs/heads/master
2023-04-19T10:13:54.851806
2021-05-09T04:48:09
2021-05-09T04:48:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
35
cpp
global.cpp
#include "global.h" int id_num=-1;
9de0eae12b439f66b63b1b68f17efb920675f616
5e58e144abd98dd720e5bad1419ffbd5a201b90b
/Core/Src/disk.cpp
74913f3b1e2c0b8488c600f80b40966ffe6b9070
[]
no_license
DaveRichmond/stm32h743-usbmsc
db8e7aaddcd6c788e3cf62b9e02912336039ffa9
491c869a439595774f3cb13f2c409f47bc085120
refs/heads/main
2023-03-29T10:36:18.954058
2021-04-07T11:03:26
2021-04-07T11:03:26
355,512,873
0
1
null
null
null
null
UTF-8
C++
false
false
675
cpp
disk.cpp
/* * disk.cpp * * Created on: Apr 7, 2021 * Author: msn */ #include "disk.h" #include <stdio.h> #include "fatfs.h" bool usbd_disk_init(){ printf("USBD Disk Init\n"); if (BSP_SD_IsDetected() != SD_PRESENT){ printf("USBD Disk Missing!\n"); return 0; } if(f_mount(&SDFatFS, (const TCHAR *)&SDPath, 0) != FR_OK){ printf("USBD Disk Mount Failed!\n"); return 0; } printf("USBD Disk Mounted\n"); return 0; } bool usbd_disk_open(int disk){ return 0; } bool usbd_disk_ok(int disk){ return 0; } bool usbd_disk_write(int f, int offset, int len, char *buffer){ return 0; } bool usbd_disk_read(int f, int offset, int len, char *buffer){ return 0; }
915d1f4b12e5be40449636f9e628617688d33aa8
16a804ac3b3f4e67ad7cb90c453dfb194af4dae5
/Source/HeliumRainLoadingScreen/FlareLoadingScreen.cpp
4b7b8c230baa6e108e156ffeeb7e7176b2f44856
[ "BSD-3-Clause" ]
permissive
s-ariga/HeliumRain
d8f87c6bdf37dd35f2f4811f900caac9a6cd7139
fdca65f1e564477d5a84e3362317b6905ca860e4
refs/heads/master
2020-04-18T10:19:02.428114
2019-01-14T22:43:16
2019-01-14T22:43:16
167,463,864
2
0
BSD-3-Clause
2019-01-25T01:20:39
2019-01-25T01:20:39
null
UTF-8
C++
false
false
3,362
cpp
FlareLoadingScreen.cpp
#include "FlareLoadingScreen.h" #include "SlateBasics.h" #include "SlateExtras.h" #include "MoviePlayer.h" #include "SThrobber.h" #define LOCTEXT_NAMESPACE "FlareLoadingScreen" /*---------------------------------------------------- Dynamic brush ----------------------------------------------------*/ struct FFlareLoadingScreenBrush : public FSlateDynamicImageBrush, public FGCObject { FFlareLoadingScreenBrush( const FName InTextureName, const FVector2D& InImageSize ) : FSlateDynamicImageBrush( InTextureName, InImageSize ) { SetResourceObject(LoadObject<UObject>(NULL, *InTextureName.ToString())); } virtual void AddReferencedObjects(FReferenceCollector& Collector) { FSlateBrush::AddReferencedObjects(Collector); } }; /*---------------------------------------------------- Screen layout ----------------------------------------------------*/ class SFlareLoadingScreen : public SCompoundWidget { public: SLATE_BEGIN_ARGS(SFlareLoadingScreen){} SLATE_END_ARGS() void Construct(const FArguments& InArgs) { // Get brush data static const FName LoadingScreenName(TEXT("/Engine/EngineResources/Black.Black")); static const FName ThrobberImageName(TEXT("/Game/Slate/Images/TX_Image_LargeButtonInvertedBackground.TX_Image_LargeButtonInvertedBackground")); // Create textures LoadingScreenBrush = MakeShareable(new FFlareLoadingScreenBrush(LoadingScreenName, FVector2D(1920, 1080))); ThrobberBrush = MakeShareable(new FFlareLoadingScreenBrush(ThrobberImageName, FVector2D(64, 64))); // Structure ChildSlot [ SNew(SOverlay) // Background image + SOverlay::Slot() .HAlign(HAlign_Fill) .VAlign(VAlign_Fill) [ SNew(SImage) .Image(LoadingScreenBrush.Get()) ] // Data box + SOverlay::Slot() .HAlign(HAlign_Fill) .VAlign(VAlign_Fill) [ SNew(SVerticalBox) // Title + SVerticalBox::Slot() .VAlign(VAlign_Bottom) .HAlign(HAlign_Center) .Padding(FMargin(10.0f)) [ SNew(STextBlock) .Text(LOCTEXT("LoadingTitle", "HELIUM RAIN")) .Font(FSlateFontInfo(FPaths::ProjectContentDir() / TEXT("Slate/Fonts/Lato700.ttf"), 72)) ] // Throbber + SVerticalBox::Slot() .VAlign(VAlign_Top) .HAlign(HAlign_Center) .Padding(FMargin(10.0f)) [ SNew(SThrobber) .PieceImage(ThrobberBrush.Get()) .NumPieces(5) ] ] ]; } private: // Slate data TSharedPtr<FSlateDynamicImageBrush> ThrobberBrush; TSharedPtr<FSlateDynamicImageBrush> LoadingScreenBrush; }; /*---------------------------------------------------- Game submodule ----------------------------------------------------*/ class FFlareLoadingScreenModule : public IFlareLoadingScreenModule { public: virtual void StartupModule() override { if (IsMoviePlayerEnabled()) { CreateScreen(); } } virtual bool IsGameModule() const override { return true; } virtual void StartInGameLoadingScreen() override { CreateScreen(); GetMoviePlayer()->PlayMovie(); } virtual void CreateScreen() { FLoadingScreenAttributes LoadingScreen; LoadingScreen.bAutoCompleteWhenLoadingCompletes = true; LoadingScreen.WidgetLoadingScreen = SNew(SFlareLoadingScreen); GetMoviePlayer()->SetupLoadingScreen(LoadingScreen); } }; #undef LOCTEXT_NAMESPACE IMPLEMENT_GAME_MODULE(FFlareLoadingScreenModule, HeliumRainLoadingScreen);
005a4875689da7c22a952b823acbdc04e3841716
1182d217b410585654ab629b90b8f43c09a8766d
/libraries/Mitov/Mitov_WiFiShield.h
f7d2fe893998bcfd6f72a787166eca01a45f37cf
[]
no_license
alorimer/arduino-weather
4673499de208195aeb8dc2b104556967b9de227c
97a3ba010df7f5581a02291f0cc94644893cf858
refs/heads/master
2021-01-15T14:02:09.470839
2016-05-29T07:14:43
2016-05-29T07:14:43
55,577,926
1
0
null
null
null
null
UTF-8
C++
false
false
7,088
h
Mitov_WiFiShield.h
//////////////////////////////////////////////////////////////////////////////// // // // This software is supplied under the terms of a license agreement or // // nondisclosure agreement with Mitov Software and may not be copied // // or disclosed except in accordance with the terms of that agreement. // // Copyright(c) 2002-2016 Mitov Software. All Rights Reserved. // // // //////////////////////////////////////////////////////////////////////////////// #ifndef _MITOV_WIFI_SHIELD_h #define _MITOV_WIFI_SHIELD_h #include <Mitov.h> #include <Mitov_BasicEthernet.h> namespace Mitov { // class BasicEthernetSocket; //--------------------------------------------------------------------------- class WiFiRemoteAccessPoint { public: bool Enabled = true; String SSID; public: bool Connect() { if( ! Enabled ) return false; // if( SSID == "" ) // return ( WiFi.begin() == WL_CONNECTED ); return IntConnect(); } protected: virtual bool IntConnect() { return ( WiFi.begin( (char *)SSID.c_str() ) == WL_CONNECTED ); } }; //--------------------------------------------------------------------------- class WiFiRemoteAccessPointWPA : public WiFiRemoteAccessPoint { public: String Password; protected: virtual bool IntConnect() { return ( WiFi.begin( (char *)SSID.c_str(), (char *)Password.c_str() ) == WL_CONNECTED ); } }; //--------------------------------------------------------------------------- class WiFiRemoteAccessPointWEP : public WiFiRemoteAccessPoint { public: String Key; int KeyIndex = 0; protected: virtual bool IntConnect() { return ( WiFi.begin( (char *)SSID.c_str(), KeyIndex, (char *)Key.c_str() ) == WL_CONNECTED ); } }; //--------------------------------------------------------------------------- class WiFiShield : public Mitov::BasicEthernetShield { typedef Mitov::BasicEthernetShield inherited; public: OpenWire::SinkPin ScanNetworksInputPin; OpenWire::SourcePin FoundSignalStrengthOutputPin; OpenWire::SourcePin FoundSSIDOutputPin; OpenWire::SourcePin AddressOutputPin; OpenWire::SourcePin MACOutputPin; OpenWire::SourcePin SignalStrengthOutputPin; OpenWire::SourcePin BSSIDOutputPin; OpenWire::SourcePin GatewayIPOutputPin; OpenWire::SourcePin SubnetMaskIPOutputPin; OpenWire::SinkPin CheckSignalStrengthInputPin; public: ShieldIPDNS2Address IPAddress; public: Mitov::SimpleObjectList<WiFiRemoteAccessPoint*> AccessPoints; public: bool IsStarted = false; public: virtual bool GetIPFromHostName( String AHostName, ::IPAddress &AAdress ) { bool AResult = ( WiFi.hostByName( AHostName.c_str(), AAdress ) == 1 ); if( ! AResult ) AAdress = INADDR_NONE; return AResult; } protected: virtual void StartEthernet() { // int AIndex = ((int)Parity) * 2 * 4 + ( StopBits - 1 ) + ( DataBits - 5); // T_SERIAL->begin( Speed ); // Serial.println( "StartEthernet" ); for( int i = 0; i < AccessPoints.size(); ++i ) if( AccessPoints[ i ]->Connect() ) { IsStarted = true; if( IPAddress.Enabled ) { if( ! IPAddress.DNS.Enabled ) WiFi.config( IPAddress.IP ); else { if( ! IPAddress.DNS.Gateway.Enabled ) WiFi.config( IPAddress.IP, IPAddress.DNS.IP ); else { if( ! IPAddress.DNS.Gateway.Subnet.Enabled ) WiFi.config( IPAddress.IP, IPAddress.DNS.IP, IPAddress.DNS.Gateway.IP ); else WiFi.config( IPAddress.IP, IPAddress.DNS.IP, IPAddress.DNS.Gateway.IP, IPAddress.DNS.Gateway.Subnet.IP ); } if( IPAddress.DNS2.Enabled ) WiFi.setDNS( IPAddress.DNS.IP, IPAddress.DNS2.IP ); } } if( MACOutputPin.IsConnected() ) { uint8_t AMACAddress[6] = {0}; WiFi.macAddress( AMACAddress ); char AMACString[ 6 * 3 + 1 ]; sprintf( AMACString, "%02X-%02X-%02X-%02X-%02X-%02X", AMACString[ 0 ], AMACString[ 1 ], AMACString[ 2 ], AMACString[ 3 ], AMACString[ 4 ], AMACString[ 5 ] ); MACOutputPin.Notify( AMACString ); } if( AddressOutputPin.IsConnected() ) { String AIPString = IPAdressToString( WiFi.localIP()); AddressOutputPin.Notify( (void *)AIPString.c_str() ); } if( SignalStrengthOutputPin.IsConnected() ) { int32_t ASetrength = WiFi.RSSI(); SignalStrengthOutputPin.Notify( &ASetrength ); } if( BSSIDOutputPin.IsConnected() ) { uint8_t AMACAddress[6] = {0}; WiFi.BSSID( AMACAddress ); char AMACString[ 6 * 3 + 1 ]; sprintf( AMACString, "%02X-%02X-%02X-%02X-%02X-%02X", AMACString[ 0 ], AMACString[ 1 ], AMACString[ 2 ], AMACString[ 3 ], AMACString[ 4 ], AMACString[ 5 ] ); BSSIDOutputPin.Notify( AMACString ); } if( GatewayIPOutputPin.IsConnected() ) { String AIPString = IPAdressToString( WiFi.gatewayIP()); AddressOutputPin.Notify( (void *)AIPString.c_str() ); } if( SubnetMaskIPOutputPin.IsConnected() ) { String AIPString = IPAdressToString( WiFi.subnetMask()); SubnetMaskIPOutputPin.Notify( (void *)AIPString.c_str() ); } break; } } virtual void StopEthernet() { inherited::StopEthernet(); WiFi.disconnect(); IsStarted = false; } protected: void DoScanNetworks( void *_Data ) { int nearbyAccessPointCount = WiFi.scanNetworks(); for( int i = 0; i < nearbyAccessPointCount; i ++ ) { FoundSSIDOutputPin.Notify( WiFi.SSID( i )); int32_t ASetrength = WiFi.RSSI( i ); FoundSignalStrengthOutputPin.Notify( &ASetrength ); } } void DoCheckSignalStrength( void *_Data ) { if( IsStarted ) if( SignalStrengthOutputPin.IsConnected() ) { int32_t ASetrength = WiFi.RSSI(); SignalStrengthOutputPin.Notify( &ASetrength ); } } public: WiFiShield() { ScanNetworksInputPin.SetCallback( this, (OpenWire::TOnPinReceive)&WiFiShield::DoScanNetworks ); } WiFiShield( ::IPAddress local_ip) : WiFiShield() { IPAddress.Enabled = true; IPAddress.IP = local_ip; CheckSignalStrengthInputPin.SetCallback( this, (OpenWire::TOnPinReceive)&WiFiShield::DoCheckSignalStrength ); } WiFiShield( ::IPAddress local_ip, ::IPAddress dns_server) : WiFiShield( local_ip ) { IPAddress.DNS.Enabled = true; IPAddress.DNS.IP = dns_server; } WiFiShield( ::IPAddress local_ip, ::IPAddress dns_server, ::IPAddress gateway) : WiFiShield( local_ip, dns_server ) { IPAddress.DNS.Gateway.Enabled = true; IPAddress.DNS.Gateway.IP = gateway; } WiFiShield( ::IPAddress local_ip, ::IPAddress dns_server, ::IPAddress gateway, ::IPAddress subnet) : WiFiShield( local_ip, dns_server, gateway ) { IPAddress.DNS.Gateway.Subnet.Enabled = true; IPAddress.DNS.Gateway.Subnet.IP = subnet; } }; //--------------------------------------------------------------------------- } #endif
45d24d19544a248a1d66cf171c590b29353a324d
8289fb4b9f2242a2f0a1b92b391058f421788682
/Ros/Phase2/B2lly_Ws/build/turtlesim/rosidl_typesupport_opensplice_cpp/turtlesim/srv/dds_opensplice/SetPen_Dcps_impl.cpp
4b5774beaa99aa0d05a149c54081ccd2b1d47de0
[]
no_license
BawornsakS/XPrize
5fedf7c7f0838b1da5c0749ef846ed7b2135356d
e6e900c6c63f0cef5cb3717a5b6724ec9ae00b69
refs/heads/master
2021-07-20T06:28:09.666385
2020-09-04T06:39:13
2020-09-04T06:39:13
211,299,370
3
3
null
2019-11-13T08:07:18
2019-09-27T10:56:38
Makefile
UTF-8
C++
false
false
133,371
cpp
SetPen_Dcps_impl.cpp
#include "SetPen_Dcps_impl.h" #include "SetPen_SplDcps.h" // extern v_copyin_result __turtlesim_srv_dds__SetPen_Request___copyIn ( c_base base, const struct turtlesim::srv::dds_::SetPen_Request_ *from, struct _turtlesim_srv_dds__SetPen_Request_ *to); extern void __turtlesim_srv_dds__SetPen_Request___copyOut ( const void *_from, void *_to); // DDS turtlesim::srv::dds_::SetPen_Request_ TypeSupportMetaHolder Object Body turtlesim::srv::dds_::SetPen_Request_TypeSupportMetaHolder::SetPen_Request_TypeSupportMetaHolder () : DDS::OpenSplice::TypeSupportMetaHolder ("turtlesim::srv::dds_::SetPen_Request_", "", "") { copyIn = (DDS::OpenSplice::cxxCopyIn) __turtlesim_srv_dds__SetPen_Request___copyIn; copyOut = (DDS::OpenSplice::cxxCopyOut) __turtlesim_srv_dds__SetPen_Request___copyOut; metaDescriptorArrLength = 4; metaDescriptorLength = 369; const char *tmp[] = {"<MetaData version=\"1.0.0\"><Module name=\"turtlesim\"><Module name=\"srv\"><Module name=\"dds_\"><Struct name=\"SetPen_Request_\">", "<Member name=\"r_\"><Octet/></Member><Member name=\"g_\"><Octet/></Member><Member name=\"b_\"><Octet/>", "</Member><Member name=\"width_\"><Octet/></Member><Member name=\"off_\"><Octet/></Member></Struct></Module>", "</Module></Module></MetaData>"}; metaDescriptor = new const char*[metaDescriptorArrLength]; memcpy(metaDescriptor, tmp, sizeof(tmp)); } turtlesim::srv::dds_::SetPen_Request_TypeSupportMetaHolder::~SetPen_Request_TypeSupportMetaHolder () { // Rely on parent destructor. } ::DDS::OpenSplice::TypeSupportMetaHolder * turtlesim::srv::dds_::SetPen_Request_TypeSupportMetaHolder::clone() { return new turtlesim::srv::dds_::SetPen_Request_TypeSupportMetaHolder(); } ::DDS::OpenSplice::DataWriter * turtlesim::srv::dds_::SetPen_Request_TypeSupportMetaHolder::create_datawriter () { return new turtlesim::srv::dds_::SetPen_Request_DataWriter_impl(); } ::DDS::OpenSplice::DataReader * turtlesim::srv::dds_::SetPen_Request_TypeSupportMetaHolder::create_datareader () { return new turtlesim::srv::dds_::SetPen_Request_DataReader_impl(); } ::DDS::OpenSplice::DataReaderView * turtlesim::srv::dds_::SetPen_Request_TypeSupportMetaHolder::create_view () { return new turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl(); } // DDS turtlesim::srv::dds_::SetPen_Request_ TypeSupport Object Body turtlesim::srv::dds_::SetPen_Request_TypeSupport::SetPen_Request_TypeSupport () : DDS::OpenSplice::TypeSupport() { tsMetaHolder = new turtlesim::srv::dds_::SetPen_Request_TypeSupportMetaHolder(); } turtlesim::srv::dds_::SetPen_Request_TypeSupport::~SetPen_Request_TypeSupport () { DDS::release(tsMetaHolder); } // DDS turtlesim::srv::dds_::SetPen_Request_ DataWriter_impl Object Body turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::SetPen_Request_DataWriter_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::~SetPen_Request_DataWriter_impl () { // Parent destructor takes care of everything. } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::init ( DDS::OpenSplice::Publisher *publisher, DDS::OpenSplice::DomainParticipant *participant, const DDS::DataWriterQos &qos, DDS::OpenSplice::Topic *a_topic, const char *name, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut, u_writerCopy writerCopy, void *cdrMarshaler) { return DDS::OpenSplice::FooDataWriter_impl::nlReq_init( publisher, participant, qos, a_topic, name, copyIn, copyOut, writerCopy, cdrMarshaler); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::register_instance ( const turtlesim::srv::dds_::SetPen_Request_ & instance_data) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::register_instance(&instance_data); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::register_instance_w_timestamp ( const SetPen_Request_ & instance_data, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::register_instance_w_timestamp(&instance_data, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::unregister_instance ( const turtlesim::srv::dds_::SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::unregister_instance(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::unregister_instance_w_timestamp ( const SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::unregister_instance_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::write ( const turtlesim::srv::dds_::SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::write(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::write_w_timestamp ( const SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::write_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::dispose ( const turtlesim::srv::dds_::SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::dispose(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::dispose_w_timestamp ( const SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::dispose_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::writedispose ( const turtlesim::srv::dds_::SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::writedispose(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::writedispose_w_timestamp ( const SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::writedispose_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::get_key_value ( SetPen_Request_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Request_DataWriter_impl::lookup_instance ( const turtlesim::srv::dds_::SetPen_Request_ & instance_data) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::lookup_instance(&instance_data); } // DDS turtlesim::srv::dds_::SetPen_Request_ DataReader_impl Object Body turtlesim::srv::dds_::SetPen_Request_DataReader_impl::SetPen_Request_DataReader_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::SetPen_Request_DataReader_impl::~SetPen_Request_DataReader_impl () { // Parent destructor takes care of everything. } DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::init ( DDS::OpenSplice::Subscriber *subscriber, const DDS::DataReaderQos &qos, DDS::OpenSplice::TopicDescription *a_topic, const char *name, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut, DDS::OpenSplice::cxxReaderCopy readerCopy, void *cdrMarshaler) { return DDS::OpenSplice::FooDataReader_impl::nlReq_init( subscriber, qos, a_topic, name, copyIn, copyOut, readerCopy, cdrMarshaler, this->dataSeqAlloc, this->dataSeqLength, this->dataSeqGetBuffer, this->dataSeqCopyOut); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::read ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::take ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::read_w_condition ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::take_w_condition ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::read_next_sample ( turtlesim::srv::dds_::SetPen_Request_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::read_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::take_next_sample ( turtlesim::srv::dds_::SetPen_Request_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::take_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::read_instance ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::take_instance ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::read_next_instance ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::take_next_instance ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::read_next_instance_w_condition ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::take_next_instance_w_condition ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::return_loan ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t result = ::DDS::RETCODE_OK; result = this->write_lock (); if (result == DDS::RETCODE_OK) { if ( received_data.length() > 0 ) { if (received_data.length() == info_seq.length() && received_data.release() == info_seq.release() ) { if (!received_data.release()) { result = DDS::OpenSplice::FooDataReader_impl::wlReq_return_loan( received_data.get_buffer(), info_seq.get_buffer() ); if ( result == ::DDS::RETCODE_OK ) { if ( !received_data.release() ) { turtlesim::srv::dds_::SetPen_Request_Seq::freebuf( received_data.get_buffer(false) ); received_data.replace(0, 0, NULL, false); ::DDS::SampleInfoSeq::freebuf( info_seq.get_buffer(false) ); info_seq.replace(0, 0, NULL, false); } } } } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } this->unlock(); } return result; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::get_key_value ( turtlesim::srv::dds_::SetPen_Request_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::lookup_instance ( const turtlesim::srv::dds_::SetPen_Request_ & instance) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::lookup_instance(&instance); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples) { if ((max_samples < 0) && (max_samples != DDS::LENGTH_UNLIMITED)) { return DDS::RETCODE_BAD_PARAMETER; } /* Rule 1 : The values of len, max_len, and owns * for the two collections must be identical. */ if ((received_data.length() != info_seq.length()) || (received_data.maximum() != info_seq.maximum()) || (received_data.release() != info_seq.release())) { return DDS::RETCODE_PRECONDITION_NOT_MET; } /* Rule 4: If the input max_len>0 and the input owns==FALSE, * then the read operation will fail. */ if ((info_seq.maximum() > 0) && (info_seq.release() == false)) { return DDS::RETCODE_PRECONDITION_NOT_MET; } /* Rule 5: If input max_len>0 and the input owns==TRUE, * then the read operation will... */ if (info_seq.maximum() > 0) { /* owns is true, because of rule 4. */ /* Rule 5a: If max_samples = LENGTH_UNLIMITED, * then at most max_len values will be copied. * Rule 5b: If max_samples <= max_len, * then at most max_samples values will be copied. */ /* Rule 5c: If max_samples > max_len, * then the read operation will fail. */ if ((max_samples != DDS::LENGTH_UNLIMITED) && ((DDS::ULong)max_samples > info_seq.maximum())) { return DDS::RETCODE_PRECONDITION_NOT_MET; } } if ((max_samples == 0) || ((info_seq.maximum() == 0) && (info_seq.release()))) { return DDS::RETCODE_NO_DATA; } return DDS::RETCODE_OK; } void * turtlesim::srv::dds_::SetPen_Request_DataReader_impl::dataSeqAlloc ( void * received_data, DDS::ULong len) { turtlesim::srv::dds_::SetPen_Request_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::SetPen_Request_Seq *>(received_data); data_seq->replace(len, len, data_seq->allocbuf(len), false); return data_seq->get_buffer(); } void * turtlesim::srv::dds_::SetPen_Request_DataReader_impl::dataSeqGetBuffer ( void * received_data, DDS::ULong index) { turtlesim::srv::dds_::SetPen_Request_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::SetPen_Request_Seq *>(received_data); return &((*data_seq)[index]); } void turtlesim::srv::dds_::SetPen_Request_DataReader_impl::dataSeqLength ( void * received_data, DDS::ULong len) { turtlesim::srv::dds_::SetPen_Request_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::SetPen_Request_Seq *>(received_data); data_seq->length(len); } void turtlesim::srv::dds_::SetPen_Request_DataReader_impl::dataSeqCopyOut ( const void * from, void * to) { turtlesim::srv::dds_::SetPen_Request_ *data = reinterpret_cast<turtlesim::srv::dds_::SetPen_Request_ *>(to); __turtlesim_srv_dds__SetPen_Request___copyOut(from, data); } void turtlesim::srv::dds_::SetPen_Request_DataReader_impl::copyDataOut ( const void * from, void * to) { turtlesim::srv::dds_::SetPen_Request_ *data = reinterpret_cast<turtlesim::srv::dds_::SetPen_Request_ *>(to); __turtlesim_srv_dds__SetPen_Request___copyOut(from, data); } // DDS turtlesim::srv::dds_::SetPen_Request_ DataReaderView_impl Object Body turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::SetPen_Request_DataReaderView_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::~SetPen_Request_DataReaderView_impl () { // Parent destructor takes care of everything. } DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::init ( DDS::OpenSplice::DataReader *reader, const char *name, const DDS::DataReaderViewQos &qos, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut) { return DDS::OpenSplice::FooDataReaderView_impl::nlReq_init( reader, name, qos, copyIn, copyOut, turtlesim::srv::dds_::SetPen_Request_DataReader_impl::dataSeqAlloc, turtlesim::srv::dds_::SetPen_Request_DataReader_impl::dataSeqLength); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::read ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::take ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::read_w_condition ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::take_w_condition ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::read_next_sample ( turtlesim::srv::dds_::SetPen_Request_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::read_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::take_next_sample ( turtlesim::srv::dds_::SetPen_Request_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::take_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::read_instance ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::take_instance ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::read_next_instance ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::take_next_instance ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::read_next_instance_w_condition ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::take_next_instance_w_condition ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::return_loan ( turtlesim::srv::dds_::SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t result = ::DDS::RETCODE_OK; result = this->write_lock (); if (result == DDS::RETCODE_OK) { if ( received_data.length() > 0 ) { if (received_data.length() == info_seq.length() && received_data.release() == info_seq.release() ) { if (!received_data.release()) { result = DDS::OpenSplice::FooDataReaderView_impl::wlReq_return_loan( received_data.get_buffer(), info_seq.get_buffer() ); if ( result == ::DDS::RETCODE_OK ) { if ( !received_data.release() ) { turtlesim::srv::dds_::SetPen_Request_Seq::freebuf( received_data.get_buffer(false) ); received_data.replace(0, 0, NULL, false); ::DDS::SampleInfoSeq::freebuf( info_seq.get_buffer(false) ); info_seq.replace(0, 0, NULL, false); } } else if ( result == ::DDS::RETCODE_NO_DATA ) { if ( received_data.release() ) { result = ::DDS::RETCODE_OK; } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } } } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } this->unlock(); } return result; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::get_key_value ( turtlesim::srv::dds_::SetPen_Request_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Request_DataReaderView_impl::lookup_instance ( const turtlesim::srv::dds_::SetPen_Request_ & instance) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::lookup_instance(&instance); } extern v_copyin_result __turtlesim_srv_dds__SetPen_Response___copyIn ( c_base base, const struct turtlesim::srv::dds_::SetPen_Response_ *from, struct _turtlesim_srv_dds__SetPen_Response_ *to); extern void __turtlesim_srv_dds__SetPen_Response___copyOut ( const void *_from, void *_to); // DDS turtlesim::srv::dds_::SetPen_Response_ TypeSupportMetaHolder Object Body turtlesim::srv::dds_::SetPen_Response_TypeSupportMetaHolder::SetPen_Response_TypeSupportMetaHolder () : DDS::OpenSplice::TypeSupportMetaHolder ("turtlesim::srv::dds_::SetPen_Response_", "", "") { copyIn = (DDS::OpenSplice::cxxCopyIn) __turtlesim_srv_dds__SetPen_Response___copyIn; copyOut = (DDS::OpenSplice::cxxCopyOut) __turtlesim_srv_dds__SetPen_Response___copyOut; metaDescriptorArrLength = 3; metaDescriptorLength = 250; const char *tmp[] = {"<MetaData version=\"1.0.0\"><Module name=\"turtlesim\"><Module name=\"srv\"><Module name=\"dds_\"><Struct name=\"SetPen_Response_\">", "<Member name=\"structure_needs_at_least_one_member_\"><Octet/></Member></Struct></Module></Module></Module>", "</MetaData>"}; metaDescriptor = new const char*[metaDescriptorArrLength]; memcpy(metaDescriptor, tmp, sizeof(tmp)); } turtlesim::srv::dds_::SetPen_Response_TypeSupportMetaHolder::~SetPen_Response_TypeSupportMetaHolder () { // Rely on parent destructor. } ::DDS::OpenSplice::TypeSupportMetaHolder * turtlesim::srv::dds_::SetPen_Response_TypeSupportMetaHolder::clone() { return new turtlesim::srv::dds_::SetPen_Response_TypeSupportMetaHolder(); } ::DDS::OpenSplice::DataWriter * turtlesim::srv::dds_::SetPen_Response_TypeSupportMetaHolder::create_datawriter () { return new turtlesim::srv::dds_::SetPen_Response_DataWriter_impl(); } ::DDS::OpenSplice::DataReader * turtlesim::srv::dds_::SetPen_Response_TypeSupportMetaHolder::create_datareader () { return new turtlesim::srv::dds_::SetPen_Response_DataReader_impl(); } ::DDS::OpenSplice::DataReaderView * turtlesim::srv::dds_::SetPen_Response_TypeSupportMetaHolder::create_view () { return new turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl(); } // DDS turtlesim::srv::dds_::SetPen_Response_ TypeSupport Object Body turtlesim::srv::dds_::SetPen_Response_TypeSupport::SetPen_Response_TypeSupport () : DDS::OpenSplice::TypeSupport() { tsMetaHolder = new turtlesim::srv::dds_::SetPen_Response_TypeSupportMetaHolder(); } turtlesim::srv::dds_::SetPen_Response_TypeSupport::~SetPen_Response_TypeSupport () { DDS::release(tsMetaHolder); } // DDS turtlesim::srv::dds_::SetPen_Response_ DataWriter_impl Object Body turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::SetPen_Response_DataWriter_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::~SetPen_Response_DataWriter_impl () { // Parent destructor takes care of everything. } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::init ( DDS::OpenSplice::Publisher *publisher, DDS::OpenSplice::DomainParticipant *participant, const DDS::DataWriterQos &qos, DDS::OpenSplice::Topic *a_topic, const char *name, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut, u_writerCopy writerCopy, void *cdrMarshaler) { return DDS::OpenSplice::FooDataWriter_impl::nlReq_init( publisher, participant, qos, a_topic, name, copyIn, copyOut, writerCopy, cdrMarshaler); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::register_instance ( const turtlesim::srv::dds_::SetPen_Response_ & instance_data) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::register_instance(&instance_data); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::register_instance_w_timestamp ( const SetPen_Response_ & instance_data, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::register_instance_w_timestamp(&instance_data, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::unregister_instance ( const turtlesim::srv::dds_::SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::unregister_instance(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::unregister_instance_w_timestamp ( const SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::unregister_instance_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::write ( const turtlesim::srv::dds_::SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::write(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::write_w_timestamp ( const SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::write_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::dispose ( const turtlesim::srv::dds_::SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::dispose(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::dispose_w_timestamp ( const SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::dispose_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::writedispose ( const turtlesim::srv::dds_::SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::writedispose(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::writedispose_w_timestamp ( const SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::writedispose_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::get_key_value ( SetPen_Response_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Response_DataWriter_impl::lookup_instance ( const turtlesim::srv::dds_::SetPen_Response_ & instance_data) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::lookup_instance(&instance_data); } // DDS turtlesim::srv::dds_::SetPen_Response_ DataReader_impl Object Body turtlesim::srv::dds_::SetPen_Response_DataReader_impl::SetPen_Response_DataReader_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::SetPen_Response_DataReader_impl::~SetPen_Response_DataReader_impl () { // Parent destructor takes care of everything. } DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::init ( DDS::OpenSplice::Subscriber *subscriber, const DDS::DataReaderQos &qos, DDS::OpenSplice::TopicDescription *a_topic, const char *name, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut, DDS::OpenSplice::cxxReaderCopy readerCopy, void *cdrMarshaler) { return DDS::OpenSplice::FooDataReader_impl::nlReq_init( subscriber, qos, a_topic, name, copyIn, copyOut, readerCopy, cdrMarshaler, this->dataSeqAlloc, this->dataSeqLength, this->dataSeqGetBuffer, this->dataSeqCopyOut); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::read ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::take ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::read_w_condition ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::take_w_condition ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::read_next_sample ( turtlesim::srv::dds_::SetPen_Response_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::read_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::take_next_sample ( turtlesim::srv::dds_::SetPen_Response_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::take_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::read_instance ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::take_instance ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::read_next_instance ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::take_next_instance ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::read_next_instance_w_condition ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::take_next_instance_w_condition ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::return_loan ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t result = ::DDS::RETCODE_OK; result = this->write_lock (); if (result == DDS::RETCODE_OK) { if ( received_data.length() > 0 ) { if (received_data.length() == info_seq.length() && received_data.release() == info_seq.release() ) { if (!received_data.release()) { result = DDS::OpenSplice::FooDataReader_impl::wlReq_return_loan( received_data.get_buffer(), info_seq.get_buffer() ); if ( result == ::DDS::RETCODE_OK ) { if ( !received_data.release() ) { turtlesim::srv::dds_::SetPen_Response_Seq::freebuf( received_data.get_buffer(false) ); received_data.replace(0, 0, NULL, false); ::DDS::SampleInfoSeq::freebuf( info_seq.get_buffer(false) ); info_seq.replace(0, 0, NULL, false); } } } } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } this->unlock(); } return result; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::get_key_value ( turtlesim::srv::dds_::SetPen_Response_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::lookup_instance ( const turtlesim::srv::dds_::SetPen_Response_ & instance) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::lookup_instance(&instance); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples) { if ((max_samples < 0) && (max_samples != DDS::LENGTH_UNLIMITED)) { return DDS::RETCODE_BAD_PARAMETER; } /* Rule 1 : The values of len, max_len, and owns * for the two collections must be identical. */ if ((received_data.length() != info_seq.length()) || (received_data.maximum() != info_seq.maximum()) || (received_data.release() != info_seq.release())) { return DDS::RETCODE_PRECONDITION_NOT_MET; } /* Rule 4: If the input max_len>0 and the input owns==FALSE, * then the read operation will fail. */ if ((info_seq.maximum() > 0) && (info_seq.release() == false)) { return DDS::RETCODE_PRECONDITION_NOT_MET; } /* Rule 5: If input max_len>0 and the input owns==TRUE, * then the read operation will... */ if (info_seq.maximum() > 0) { /* owns is true, because of rule 4. */ /* Rule 5a: If max_samples = LENGTH_UNLIMITED, * then at most max_len values will be copied. * Rule 5b: If max_samples <= max_len, * then at most max_samples values will be copied. */ /* Rule 5c: If max_samples > max_len, * then the read operation will fail. */ if ((max_samples != DDS::LENGTH_UNLIMITED) && ((DDS::ULong)max_samples > info_seq.maximum())) { return DDS::RETCODE_PRECONDITION_NOT_MET; } } if ((max_samples == 0) || ((info_seq.maximum() == 0) && (info_seq.release()))) { return DDS::RETCODE_NO_DATA; } return DDS::RETCODE_OK; } void * turtlesim::srv::dds_::SetPen_Response_DataReader_impl::dataSeqAlloc ( void * received_data, DDS::ULong len) { turtlesim::srv::dds_::SetPen_Response_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::SetPen_Response_Seq *>(received_data); data_seq->replace(len, len, data_seq->allocbuf(len), false); return data_seq->get_buffer(); } void * turtlesim::srv::dds_::SetPen_Response_DataReader_impl::dataSeqGetBuffer ( void * received_data, DDS::ULong index) { turtlesim::srv::dds_::SetPen_Response_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::SetPen_Response_Seq *>(received_data); return &((*data_seq)[index]); } void turtlesim::srv::dds_::SetPen_Response_DataReader_impl::dataSeqLength ( void * received_data, DDS::ULong len) { turtlesim::srv::dds_::SetPen_Response_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::SetPen_Response_Seq *>(received_data); data_seq->length(len); } void turtlesim::srv::dds_::SetPen_Response_DataReader_impl::dataSeqCopyOut ( const void * from, void * to) { turtlesim::srv::dds_::SetPen_Response_ *data = reinterpret_cast<turtlesim::srv::dds_::SetPen_Response_ *>(to); __turtlesim_srv_dds__SetPen_Response___copyOut(from, data); } void turtlesim::srv::dds_::SetPen_Response_DataReader_impl::copyDataOut ( const void * from, void * to) { turtlesim::srv::dds_::SetPen_Response_ *data = reinterpret_cast<turtlesim::srv::dds_::SetPen_Response_ *>(to); __turtlesim_srv_dds__SetPen_Response___copyOut(from, data); } // DDS turtlesim::srv::dds_::SetPen_Response_ DataReaderView_impl Object Body turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::SetPen_Response_DataReaderView_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::~SetPen_Response_DataReaderView_impl () { // Parent destructor takes care of everything. } DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::init ( DDS::OpenSplice::DataReader *reader, const char *name, const DDS::DataReaderViewQos &qos, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut) { return DDS::OpenSplice::FooDataReaderView_impl::nlReq_init( reader, name, qos, copyIn, copyOut, turtlesim::srv::dds_::SetPen_Response_DataReader_impl::dataSeqAlloc, turtlesim::srv::dds_::SetPen_Response_DataReader_impl::dataSeqLength); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::read ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::take ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::read_w_condition ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::take_w_condition ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::read_next_sample ( turtlesim::srv::dds_::SetPen_Response_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::read_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::take_next_sample ( turtlesim::srv::dds_::SetPen_Response_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::take_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::read_instance ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::take_instance ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::read_next_instance ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::take_next_instance ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::read_next_instance_w_condition ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::take_next_instance_w_condition ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::return_loan ( turtlesim::srv::dds_::SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t result = ::DDS::RETCODE_OK; result = this->write_lock (); if (result == DDS::RETCODE_OK) { if ( received_data.length() > 0 ) { if (received_data.length() == info_seq.length() && received_data.release() == info_seq.release() ) { if (!received_data.release()) { result = DDS::OpenSplice::FooDataReaderView_impl::wlReq_return_loan( received_data.get_buffer(), info_seq.get_buffer() ); if ( result == ::DDS::RETCODE_OK ) { if ( !received_data.release() ) { turtlesim::srv::dds_::SetPen_Response_Seq::freebuf( received_data.get_buffer(false) ); received_data.replace(0, 0, NULL, false); ::DDS::SampleInfoSeq::freebuf( info_seq.get_buffer(false) ); info_seq.replace(0, 0, NULL, false); } } else if ( result == ::DDS::RETCODE_NO_DATA ) { if ( received_data.release() ) { result = ::DDS::RETCODE_OK; } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } } } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } this->unlock(); } return result; } ::DDS::ReturnCode_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::get_key_value ( turtlesim::srv::dds_::SetPen_Response_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::SetPen_Response_DataReaderView_impl::lookup_instance ( const turtlesim::srv::dds_::SetPen_Response_ & instance) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::lookup_instance(&instance); } extern v_copyin_result __turtlesim_srv_dds__Sample_SetPen_Request___copyIn ( c_base base, const struct turtlesim::srv::dds_::Sample_SetPen_Request_ *from, struct _turtlesim_srv_dds__Sample_SetPen_Request_ *to); extern void __turtlesim_srv_dds__Sample_SetPen_Request___copyOut ( const void *_from, void *_to); // DDS turtlesim::srv::dds_::Sample_SetPen_Request_ TypeSupportMetaHolder Object Body turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupportMetaHolder::Sample_SetPen_Request_TypeSupportMetaHolder () : DDS::OpenSplice::TypeSupportMetaHolder ("turtlesim::srv::dds_::Sample_SetPen_Request_", "", "") { copyIn = (DDS::OpenSplice::cxxCopyIn) __turtlesim_srv_dds__Sample_SetPen_Request___copyIn; copyOut = (DDS::OpenSplice::cxxCopyOut) __turtlesim_srv_dds__Sample_SetPen_Request___copyOut; metaDescriptorArrLength = 6; metaDescriptorLength = 645; const char *tmp[] = {"<MetaData version=\"1.0.0\"><Module name=\"turtlesim\"><Module name=\"srv\"><Module name=\"dds_\"><Struct name=\"SetPen_Request_\">", "<Member name=\"r_\"><Octet/></Member><Member name=\"g_\"><Octet/></Member><Member name=\"b_\"><Octet/>", "</Member><Member name=\"width_\"><Octet/></Member><Member name=\"off_\"><Octet/></Member></Struct><Struct name=\"Sample_SetPen_Request_\">", "<Member name=\"client_guid_0_\"><ULongLong/></Member><Member name=\"client_guid_1_\"><ULongLong/></Member>", "<Member name=\"sequence_number_\"><LongLong/></Member><Member name=\"request_\"><Type name=\"SetPen_Request_\"/>", "</Member></Struct></Module></Module></Module></MetaData>"}; metaDescriptor = new const char*[metaDescriptorArrLength]; memcpy(metaDescriptor, tmp, sizeof(tmp)); } turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupportMetaHolder::~Sample_SetPen_Request_TypeSupportMetaHolder () { // Rely on parent destructor. } ::DDS::OpenSplice::TypeSupportMetaHolder * turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupportMetaHolder::clone() { return new turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupportMetaHolder(); } ::DDS::OpenSplice::DataWriter * turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupportMetaHolder::create_datawriter () { return new turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl(); } ::DDS::OpenSplice::DataReader * turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupportMetaHolder::create_datareader () { return new turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl(); } ::DDS::OpenSplice::DataReaderView * turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupportMetaHolder::create_view () { return new turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl(); } // DDS turtlesim::srv::dds_::Sample_SetPen_Request_ TypeSupport Object Body turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupport::Sample_SetPen_Request_TypeSupport () : DDS::OpenSplice::TypeSupport() { tsMetaHolder = new turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupportMetaHolder(); } turtlesim::srv::dds_::Sample_SetPen_Request_TypeSupport::~Sample_SetPen_Request_TypeSupport () { DDS::release(tsMetaHolder); } // DDS turtlesim::srv::dds_::Sample_SetPen_Request_ DataWriter_impl Object Body turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::Sample_SetPen_Request_DataWriter_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::~Sample_SetPen_Request_DataWriter_impl () { // Parent destructor takes care of everything. } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::init ( DDS::OpenSplice::Publisher *publisher, DDS::OpenSplice::DomainParticipant *participant, const DDS::DataWriterQos &qos, DDS::OpenSplice::Topic *a_topic, const char *name, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut, u_writerCopy writerCopy, void *cdrMarshaler) { return DDS::OpenSplice::FooDataWriter_impl::nlReq_init( publisher, participant, qos, a_topic, name, copyIn, copyOut, writerCopy, cdrMarshaler); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::register_instance ( const turtlesim::srv::dds_::Sample_SetPen_Request_ & instance_data) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::register_instance(&instance_data); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::register_instance_w_timestamp ( const Sample_SetPen_Request_ & instance_data, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::register_instance_w_timestamp(&instance_data, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::unregister_instance ( const turtlesim::srv::dds_::Sample_SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::unregister_instance(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::unregister_instance_w_timestamp ( const Sample_SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::unregister_instance_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::write ( const turtlesim::srv::dds_::Sample_SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::write(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::write_w_timestamp ( const Sample_SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::write_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::dispose ( const turtlesim::srv::dds_::Sample_SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::dispose(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::dispose_w_timestamp ( const Sample_SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::dispose_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::writedispose ( const turtlesim::srv::dds_::Sample_SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::writedispose(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::writedispose_w_timestamp ( const Sample_SetPen_Request_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::writedispose_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::get_key_value ( Sample_SetPen_Request_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Request_DataWriter_impl::lookup_instance ( const turtlesim::srv::dds_::Sample_SetPen_Request_ & instance_data) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::lookup_instance(&instance_data); } // DDS turtlesim::srv::dds_::Sample_SetPen_Request_ DataReader_impl Object Body turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::Sample_SetPen_Request_DataReader_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::~Sample_SetPen_Request_DataReader_impl () { // Parent destructor takes care of everything. } DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::init ( DDS::OpenSplice::Subscriber *subscriber, const DDS::DataReaderQos &qos, DDS::OpenSplice::TopicDescription *a_topic, const char *name, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut, DDS::OpenSplice::cxxReaderCopy readerCopy, void *cdrMarshaler) { return DDS::OpenSplice::FooDataReader_impl::nlReq_init( subscriber, qos, a_topic, name, copyIn, copyOut, readerCopy, cdrMarshaler, this->dataSeqAlloc, this->dataSeqLength, this->dataSeqGetBuffer, this->dataSeqCopyOut); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::read ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::take ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::read_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::take_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::read_next_sample ( turtlesim::srv::dds_::Sample_SetPen_Request_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::read_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::take_next_sample ( turtlesim::srv::dds_::Sample_SetPen_Request_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::take_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::read_instance ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::take_instance ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::read_next_instance ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::take_next_instance ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::read_next_instance_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::take_next_instance_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::return_loan ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t result = ::DDS::RETCODE_OK; result = this->write_lock (); if (result == DDS::RETCODE_OK) { if ( received_data.length() > 0 ) { if (received_data.length() == info_seq.length() && received_data.release() == info_seq.release() ) { if (!received_data.release()) { result = DDS::OpenSplice::FooDataReader_impl::wlReq_return_loan( received_data.get_buffer(), info_seq.get_buffer() ); if ( result == ::DDS::RETCODE_OK ) { if ( !received_data.release() ) { turtlesim::srv::dds_::Sample_SetPen_Request_Seq::freebuf( received_data.get_buffer(false) ); received_data.replace(0, 0, NULL, false); ::DDS::SampleInfoSeq::freebuf( info_seq.get_buffer(false) ); info_seq.replace(0, 0, NULL, false); } } } } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } this->unlock(); } return result; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::get_key_value ( turtlesim::srv::dds_::Sample_SetPen_Request_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::lookup_instance ( const turtlesim::srv::dds_::Sample_SetPen_Request_ & instance) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::lookup_instance(&instance); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples) { if ((max_samples < 0) && (max_samples != DDS::LENGTH_UNLIMITED)) { return DDS::RETCODE_BAD_PARAMETER; } /* Rule 1 : The values of len, max_len, and owns * for the two collections must be identical. */ if ((received_data.length() != info_seq.length()) || (received_data.maximum() != info_seq.maximum()) || (received_data.release() != info_seq.release())) { return DDS::RETCODE_PRECONDITION_NOT_MET; } /* Rule 4: If the input max_len>0 and the input owns==FALSE, * then the read operation will fail. */ if ((info_seq.maximum() > 0) && (info_seq.release() == false)) { return DDS::RETCODE_PRECONDITION_NOT_MET; } /* Rule 5: If input max_len>0 and the input owns==TRUE, * then the read operation will... */ if (info_seq.maximum() > 0) { /* owns is true, because of rule 4. */ /* Rule 5a: If max_samples = LENGTH_UNLIMITED, * then at most max_len values will be copied. * Rule 5b: If max_samples <= max_len, * then at most max_samples values will be copied. */ /* Rule 5c: If max_samples > max_len, * then the read operation will fail. */ if ((max_samples != DDS::LENGTH_UNLIMITED) && ((DDS::ULong)max_samples > info_seq.maximum())) { return DDS::RETCODE_PRECONDITION_NOT_MET; } } if ((max_samples == 0) || ((info_seq.maximum() == 0) && (info_seq.release()))) { return DDS::RETCODE_NO_DATA; } return DDS::RETCODE_OK; } void * turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::dataSeqAlloc ( void * received_data, DDS::ULong len) { turtlesim::srv::dds_::Sample_SetPen_Request_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Request_Seq *>(received_data); data_seq->replace(len, len, data_seq->allocbuf(len), false); return data_seq->get_buffer(); } void * turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::dataSeqGetBuffer ( void * received_data, DDS::ULong index) { turtlesim::srv::dds_::Sample_SetPen_Request_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Request_Seq *>(received_data); return &((*data_seq)[index]); } void turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::dataSeqLength ( void * received_data, DDS::ULong len) { turtlesim::srv::dds_::Sample_SetPen_Request_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Request_Seq *>(received_data); data_seq->length(len); } void turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::dataSeqCopyOut ( const void * from, void * to) { turtlesim::srv::dds_::Sample_SetPen_Request_ *data = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Request_ *>(to); __turtlesim_srv_dds__Sample_SetPen_Request___copyOut(from, data); } void turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::copyDataOut ( const void * from, void * to) { turtlesim::srv::dds_::Sample_SetPen_Request_ *data = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Request_ *>(to); __turtlesim_srv_dds__Sample_SetPen_Request___copyOut(from, data); } // DDS turtlesim::srv::dds_::Sample_SetPen_Request_ DataReaderView_impl Object Body turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::Sample_SetPen_Request_DataReaderView_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::~Sample_SetPen_Request_DataReaderView_impl () { // Parent destructor takes care of everything. } DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::init ( DDS::OpenSplice::DataReader *reader, const char *name, const DDS::DataReaderViewQos &qos, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut) { return DDS::OpenSplice::FooDataReaderView_impl::nlReq_init( reader, name, qos, copyIn, copyOut, turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::dataSeqAlloc, turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::dataSeqLength); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::read ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::take ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::read_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::take_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::read_next_sample ( turtlesim::srv::dds_::Sample_SetPen_Request_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::read_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::take_next_sample ( turtlesim::srv::dds_::Sample_SetPen_Request_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::take_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::read_instance ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::take_instance ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::read_next_instance ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::take_next_instance ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::read_next_instance_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::take_next_instance_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Request_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::return_loan ( turtlesim::srv::dds_::Sample_SetPen_Request_Seq & received_data, ::DDS::SampleInfoSeq & info_seq) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t result = ::DDS::RETCODE_OK; result = this->write_lock (); if (result == DDS::RETCODE_OK) { if ( received_data.length() > 0 ) { if (received_data.length() == info_seq.length() && received_data.release() == info_seq.release() ) { if (!received_data.release()) { result = DDS::OpenSplice::FooDataReaderView_impl::wlReq_return_loan( received_data.get_buffer(), info_seq.get_buffer() ); if ( result == ::DDS::RETCODE_OK ) { if ( !received_data.release() ) { turtlesim::srv::dds_::Sample_SetPen_Request_Seq::freebuf( received_data.get_buffer(false) ); received_data.replace(0, 0, NULL, false); ::DDS::SampleInfoSeq::freebuf( info_seq.get_buffer(false) ); info_seq.replace(0, 0, NULL, false); } } else if ( result == ::DDS::RETCODE_NO_DATA ) { if ( received_data.release() ) { result = ::DDS::RETCODE_OK; } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } } } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } this->unlock(); } return result; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::get_key_value ( turtlesim::srv::dds_::Sample_SetPen_Request_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Request_DataReaderView_impl::lookup_instance ( const turtlesim::srv::dds_::Sample_SetPen_Request_ & instance) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::lookup_instance(&instance); } extern v_copyin_result __turtlesim_srv_dds__Sample_SetPen_Response___copyIn ( c_base base, const struct turtlesim::srv::dds_::Sample_SetPen_Response_ *from, struct _turtlesim_srv_dds__Sample_SetPen_Response_ *to); extern void __turtlesim_srv_dds__Sample_SetPen_Response___copyOut ( const void *_from, void *_to); // DDS turtlesim::srv::dds_::Sample_SetPen_Response_ TypeSupportMetaHolder Object Body turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupportMetaHolder::Sample_SetPen_Response_TypeSupportMetaHolder () : DDS::OpenSplice::TypeSupportMetaHolder ("turtlesim::srv::dds_::Sample_SetPen_Response_", "", "") { copyIn = (DDS::OpenSplice::cxxCopyIn) __turtlesim_srv_dds__Sample_SetPen_Response___copyIn; copyOut = (DDS::OpenSplice::cxxCopyOut) __turtlesim_srv_dds__Sample_SetPen_Response___copyOut; metaDescriptorArrLength = 5; metaDescriptorLength = 529; const char *tmp[] = {"<MetaData version=\"1.0.0\"><Module name=\"turtlesim\"><Module name=\"srv\"><Module name=\"dds_\"><Struct name=\"SetPen_Response_\">", "<Member name=\"structure_needs_at_least_one_member_\"><Octet/></Member></Struct><Struct name=\"Sample_SetPen_Response_\">", "<Member name=\"client_guid_0_\"><ULongLong/></Member><Member name=\"client_guid_1_\"><ULongLong/></Member>", "<Member name=\"sequence_number_\"><LongLong/></Member><Member name=\"response_\"><Type name=\"SetPen_Response_\"/>", "</Member></Struct></Module></Module></Module></MetaData>"}; metaDescriptor = new const char*[metaDescriptorArrLength]; memcpy(metaDescriptor, tmp, sizeof(tmp)); } turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupportMetaHolder::~Sample_SetPen_Response_TypeSupportMetaHolder () { // Rely on parent destructor. } ::DDS::OpenSplice::TypeSupportMetaHolder * turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupportMetaHolder::clone() { return new turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupportMetaHolder(); } ::DDS::OpenSplice::DataWriter * turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupportMetaHolder::create_datawriter () { return new turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl(); } ::DDS::OpenSplice::DataReader * turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupportMetaHolder::create_datareader () { return new turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl(); } ::DDS::OpenSplice::DataReaderView * turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupportMetaHolder::create_view () { return new turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl(); } // DDS turtlesim::srv::dds_::Sample_SetPen_Response_ TypeSupport Object Body turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupport::Sample_SetPen_Response_TypeSupport () : DDS::OpenSplice::TypeSupport() { tsMetaHolder = new turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupportMetaHolder(); } turtlesim::srv::dds_::Sample_SetPen_Response_TypeSupport::~Sample_SetPen_Response_TypeSupport () { DDS::release(tsMetaHolder); } // DDS turtlesim::srv::dds_::Sample_SetPen_Response_ DataWriter_impl Object Body turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::Sample_SetPen_Response_DataWriter_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::~Sample_SetPen_Response_DataWriter_impl () { // Parent destructor takes care of everything. } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::init ( DDS::OpenSplice::Publisher *publisher, DDS::OpenSplice::DomainParticipant *participant, const DDS::DataWriterQos &qos, DDS::OpenSplice::Topic *a_topic, const char *name, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut, u_writerCopy writerCopy, void *cdrMarshaler) { return DDS::OpenSplice::FooDataWriter_impl::nlReq_init( publisher, participant, qos, a_topic, name, copyIn, copyOut, writerCopy, cdrMarshaler); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::register_instance ( const turtlesim::srv::dds_::Sample_SetPen_Response_ & instance_data) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::register_instance(&instance_data); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::register_instance_w_timestamp ( const Sample_SetPen_Response_ & instance_data, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::register_instance_w_timestamp(&instance_data, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::unregister_instance ( const turtlesim::srv::dds_::Sample_SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::unregister_instance(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::unregister_instance_w_timestamp ( const Sample_SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::unregister_instance_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::write ( const turtlesim::srv::dds_::Sample_SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::write(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::write_w_timestamp ( const Sample_SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::write_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::dispose ( const turtlesim::srv::dds_::Sample_SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::dispose(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::dispose_w_timestamp ( const Sample_SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::dispose_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::writedispose ( const turtlesim::srv::dds_::Sample_SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::writedispose(&instance_data, handle); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::writedispose_w_timestamp ( const Sample_SetPen_Response_ & instance_data, ::DDS::InstanceHandle_t handle, const ::DDS::Time_t & source_timestamp) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::writedispose_w_timestamp(&instance_data, handle, source_timestamp); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::get_key_value ( Sample_SetPen_Response_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Response_DataWriter_impl::lookup_instance ( const turtlesim::srv::dds_::Sample_SetPen_Response_ & instance_data) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataWriter_impl::lookup_instance(&instance_data); } // DDS turtlesim::srv::dds_::Sample_SetPen_Response_ DataReader_impl Object Body turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::Sample_SetPen_Response_DataReader_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::~Sample_SetPen_Response_DataReader_impl () { // Parent destructor takes care of everything. } DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::init ( DDS::OpenSplice::Subscriber *subscriber, const DDS::DataReaderQos &qos, DDS::OpenSplice::TopicDescription *a_topic, const char *name, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut, DDS::OpenSplice::cxxReaderCopy readerCopy, void *cdrMarshaler) { return DDS::OpenSplice::FooDataReader_impl::nlReq_init( subscriber, qos, a_topic, name, copyIn, copyOut, readerCopy, cdrMarshaler, this->dataSeqAlloc, this->dataSeqLength, this->dataSeqGetBuffer, this->dataSeqCopyOut); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::read ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::take ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::read_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::take_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status = DDS::RETCODE_OK; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::read_next_sample ( turtlesim::srv::dds_::Sample_SetPen_Response_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::read_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::take_next_sample ( turtlesim::srv::dds_::Sample_SetPen_Response_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::take_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::read_instance ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::take_instance ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::read_next_instance ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::take_next_instance ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::read_next_instance_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::read_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::take_next_instance_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReader_impl::take_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::return_loan ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t result = ::DDS::RETCODE_OK; result = this->write_lock (); if (result == DDS::RETCODE_OK) { if ( received_data.length() > 0 ) { if (received_data.length() == info_seq.length() && received_data.release() == info_seq.release() ) { if (!received_data.release()) { result = DDS::OpenSplice::FooDataReader_impl::wlReq_return_loan( received_data.get_buffer(), info_seq.get_buffer() ); if ( result == ::DDS::RETCODE_OK ) { if ( !received_data.release() ) { turtlesim::srv::dds_::Sample_SetPen_Response_Seq::freebuf( received_data.get_buffer(false) ); received_data.replace(0, 0, NULL, false); ::DDS::SampleInfoSeq::freebuf( info_seq.get_buffer(false) ); info_seq.replace(0, 0, NULL, false); } } } } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } this->unlock(); } return result; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::get_key_value ( turtlesim::srv::dds_::Sample_SetPen_Response_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::lookup_instance ( const turtlesim::srv::dds_::Sample_SetPen_Response_ & instance) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReader_impl::lookup_instance(&instance); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples) { if ((max_samples < 0) && (max_samples != DDS::LENGTH_UNLIMITED)) { return DDS::RETCODE_BAD_PARAMETER; } /* Rule 1 : The values of len, max_len, and owns * for the two collections must be identical. */ if ((received_data.length() != info_seq.length()) || (received_data.maximum() != info_seq.maximum()) || (received_data.release() != info_seq.release())) { return DDS::RETCODE_PRECONDITION_NOT_MET; } /* Rule 4: If the input max_len>0 and the input owns==FALSE, * then the read operation will fail. */ if ((info_seq.maximum() > 0) && (info_seq.release() == false)) { return DDS::RETCODE_PRECONDITION_NOT_MET; } /* Rule 5: If input max_len>0 and the input owns==TRUE, * then the read operation will... */ if (info_seq.maximum() > 0) { /* owns is true, because of rule 4. */ /* Rule 5a: If max_samples = LENGTH_UNLIMITED, * then at most max_len values will be copied. * Rule 5b: If max_samples <= max_len, * then at most max_samples values will be copied. */ /* Rule 5c: If max_samples > max_len, * then the read operation will fail. */ if ((max_samples != DDS::LENGTH_UNLIMITED) && ((DDS::ULong)max_samples > info_seq.maximum())) { return DDS::RETCODE_PRECONDITION_NOT_MET; } } if ((max_samples == 0) || ((info_seq.maximum() == 0) && (info_seq.release()))) { return DDS::RETCODE_NO_DATA; } return DDS::RETCODE_OK; } void * turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::dataSeqAlloc ( void * received_data, DDS::ULong len) { turtlesim::srv::dds_::Sample_SetPen_Response_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Response_Seq *>(received_data); data_seq->replace(len, len, data_seq->allocbuf(len), false); return data_seq->get_buffer(); } void * turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::dataSeqGetBuffer ( void * received_data, DDS::ULong index) { turtlesim::srv::dds_::Sample_SetPen_Response_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Response_Seq *>(received_data); return &((*data_seq)[index]); } void turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::dataSeqLength ( void * received_data, DDS::ULong len) { turtlesim::srv::dds_::Sample_SetPen_Response_Seq *data_seq = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Response_Seq *>(received_data); data_seq->length(len); } void turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::dataSeqCopyOut ( const void * from, void * to) { turtlesim::srv::dds_::Sample_SetPen_Response_ *data = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Response_ *>(to); __turtlesim_srv_dds__Sample_SetPen_Response___copyOut(from, data); } void turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::copyDataOut ( const void * from, void * to) { turtlesim::srv::dds_::Sample_SetPen_Response_ *data = reinterpret_cast<turtlesim::srv::dds_::Sample_SetPen_Response_ *>(to); __turtlesim_srv_dds__Sample_SetPen_Response___copyOut(from, data); } // DDS turtlesim::srv::dds_::Sample_SetPen_Response_ DataReaderView_impl Object Body turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::Sample_SetPen_Response_DataReaderView_impl () { // Parent constructor takes care of everything. } turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::~Sample_SetPen_Response_DataReaderView_impl () { // Parent destructor takes care of everything. } DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::init ( DDS::OpenSplice::DataReader *reader, const char *name, const DDS::DataReaderViewQos &qos, DDS::OpenSplice::cxxCopyIn copyIn, DDS::OpenSplice::cxxCopyOut copyOut) { return DDS::OpenSplice::FooDataReaderView_impl::nlReq_init( reader, name, qos, copyIn, copyOut, turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::dataSeqAlloc, turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::dataSeqLength); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::read ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::take ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take(&received_data, info_seq, max_samples, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::read_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::take_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_w_condition(&received_data, info_seq, max_samples, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::read_next_sample ( turtlesim::srv::dds_::Sample_SetPen_Response_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::read_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::take_next_sample ( turtlesim::srv::dds_::Sample_SetPen_Response_ & received_data, ::DDS::SampleInfo & sample_info) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::take_next_sample(&received_data, sample_info); } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::read_instance ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::take_instance ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::read_next_instance ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::take_next_instance ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::SampleStateMask sample_states, ::DDS::ViewStateMask view_states, ::DDS::InstanceStateMask instance_states) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_next_instance(&received_data, info_seq, max_samples, a_handle, sample_states, view_states, instance_states); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::read_next_instance_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::read_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::take_next_instance_w_condition ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq, ::DDS::Long max_samples, ::DDS::InstanceHandle_t a_handle, ::DDS::ReadCondition_ptr a_condition) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t status; status = turtlesim::srv::dds_::Sample_SetPen_Response_DataReader_impl::check_preconditions(received_data, info_seq, max_samples); if ( status == ::DDS::RETCODE_OK ) { status = DDS::OpenSplice::FooDataReaderView_impl::take_next_instance_w_condition(&received_data, info_seq, max_samples, a_handle, a_condition); } return status; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::return_loan ( turtlesim::srv::dds_::Sample_SetPen_Response_Seq & received_data, ::DDS::SampleInfoSeq & info_seq) THROW_ORB_EXCEPTIONS { ::DDS::ReturnCode_t result = ::DDS::RETCODE_OK; result = this->write_lock (); if (result == DDS::RETCODE_OK) { if ( received_data.length() > 0 ) { if (received_data.length() == info_seq.length() && received_data.release() == info_seq.release() ) { if (!received_data.release()) { result = DDS::OpenSplice::FooDataReaderView_impl::wlReq_return_loan( received_data.get_buffer(), info_seq.get_buffer() ); if ( result == ::DDS::RETCODE_OK ) { if ( !received_data.release() ) { turtlesim::srv::dds_::Sample_SetPen_Response_Seq::freebuf( received_data.get_buffer(false) ); received_data.replace(0, 0, NULL, false); ::DDS::SampleInfoSeq::freebuf( info_seq.get_buffer(false) ); info_seq.replace(0, 0, NULL, false); } } else if ( result == ::DDS::RETCODE_NO_DATA ) { if ( received_data.release() ) { result = ::DDS::RETCODE_OK; } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } } } else { result = ::DDS::RETCODE_PRECONDITION_NOT_MET; } } this->unlock(); } return result; } ::DDS::ReturnCode_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::get_key_value ( turtlesim::srv::dds_::Sample_SetPen_Response_ & key_holder, ::DDS::InstanceHandle_t handle) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::get_key_value(&key_holder, handle); } ::DDS::InstanceHandle_t turtlesim::srv::dds_::Sample_SetPen_Response_DataReaderView_impl::lookup_instance ( const turtlesim::srv::dds_::Sample_SetPen_Response_ & instance) THROW_ORB_EXCEPTIONS { return DDS::OpenSplice::FooDataReaderView_impl::lookup_instance(&instance); }
7867aadd8255e6f5d542ce544898f7719b29d793
276353b28b188d44ad00fbe330e37912862995a6
/src/utils/memlog.cc
151c8bc489b8f69a8d2796978a28fb6fb29ea4dd
[]
no_license
septicmk/RING
4b72c02941f8e1280df5526e8b35e8b9b0c7126a
fcb8e9f2d55caeaa4b1ae35ac788a48c4e323ffc
refs/heads/master
2020-12-03T02:26:15.996846
2017-07-01T03:04:19
2017-07-01T03:04:19
95,938,414
2
0
null
null
null
null
UTF-8
C++
false
false
8,536
cc
memlog.cc
/* memlog.cc * * Copyright (c) 2016 Institute of Computing Technology. * All rights reserved. * * Author: Ke Meng <mengke@ncic.ac.cn> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Institute of Computing Technology, Chinese * Academy of Sciences 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 * INSTITUTE OF COMPUTING TECHNOLOGY AND CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ #include <iostream> #include <fstream> #include "memlog.h" #include "pgas/collective.h" #include "pgas/addressing.h" namespace Ring{ thread_local double msg_usage=0; thread_local double msg_usage_max=0; thread_local double msg_usage_min=2; thread_local int64_t msg_usage_cnt=0; thread_local int64_t context_swap_cnt=0; thread_local int64_t blocking_call_lantency=0; thread_local int64_t blocking_call_lantency_max=0; thread_local int64_t blocking_call_lantency_cnt=0; thread_local int64_t thread_comm_ticks=0; thread_local int64_t thread_work_ticks=0; thread_local int64_t task_created_cnt=0; thread_local int64_t heap_task_created_cnt=0; thread_local int64_t msg_enqueue_bytes=0; thread_local int64_t msg_local_bytes=0; thread_local int64_t msg_remote_bytes=0; thread_local int64_t enqueue_cas_cnt=0; thread_local int64_t verbs_rdma_batch_cnt=0; thread_local int64_t verbs_rdma_cnt=0; thread_local int64_t msg_1_cacheline = 0; thread_local int64_t msg_2_cacheline = 0; thread_local int64_t msg_3_cacheline = 0; thread_local int64_t msg_4_cacheline = 0; thread_local int64_t msg_x_cacheline = 0; thread_local int64_t msg_on_heap = 0; thread_local int64_t peer_msg_cnt=0; thread_local int64_t useful_peer_msg_cnt=0; thread_local int64_t flush_to_node_cnt=0; thread_local int64_t useful_flush_to_node_cnt=0; thread_local int64_t process_ring_buf_cnt=0; thread_local int64_t polling_cnt=0; thread_local int64_t blocking_call_cnt=0; thread_local int64_t async_call_cnt=0; thread_local int64_t sp_cnt=0; void mlog_dump(){ double msg_usage_ = reduce( msg_usage, collective_add ); double msg_usage_max_ = reduce( msg_usage_max, collective_max ); double msg_usage_min_ = reduce( msg_usage_min, collective_min ); if(msg_usage_min_ > 1) msg_usage_min_ = 0; int64_t msg_usage_cnt_ = reduce(msg_usage_cnt, collective_add); int64_t sp_cnt_ = reduce(sp_cnt, collective_add); int64_t context_swap_cnt_ = reduce(context_swap_cnt, collective_add); int64_t blocking_call_lantency_ = reduce(blocking_call_lantency, collective_add); int64_t blocking_call_lantency_cnt_ = reduce(blocking_call_lantency_cnt, collective_add); int64_t blocking_call_lantency_max_ = reduce(blocking_call_lantency_max, collective_max); int64_t thread_comm_ticks_ = reduce(thread_comm_ticks, collective_add); int64_t thread_work_ticks_ = reduce(thread_work_ticks, collective_add); int64_t task_created_cnt_ = reduce(task_created_cnt, collective_add); int64_t heap_task_created_cnt_ = reduce(heap_task_created_cnt, collective_add); int64_t msg_enqueue_bytes_ = reduce(msg_enqueue_bytes, collective_add); int64_t msg_local_bytes_ = reduce(msg_local_bytes, collective_add); int64_t msg_remote_bytes_ = reduce(msg_remote_bytes, collective_add); int64_t enqueue_cas_cnt_ = reduce(enqueue_cas_cnt, collective_add); int64_t verbs_rdma_batch_cnt_ = reduce(verbs_rdma_batch_cnt, collective_add); int64_t verbs_rdma_cnt_ = reduce(verbs_rdma_cnt, collective_add); int64_t msg_1_cacheline_ = reduce(msg_1_cacheline, collective_add); int64_t msg_2_cacheline_ = reduce(msg_2_cacheline, collective_add); int64_t msg_3_cacheline_ = reduce(msg_3_cacheline, collective_add); int64_t msg_4_cacheline_ = reduce(msg_4_cacheline, collective_add); int64_t msg_x_cacheline_ = reduce(msg_x_cacheline, collective_add); int64_t msg_on_heap_ = reduce(msg_on_heap, collective_add); int64_t peer_msg_cnt_ = reduce(peer_msg_cnt, collective_add); int64_t useful_peer_msg_cnt_ = reduce(useful_peer_msg_cnt, collective_add); int64_t flush_to_node_cnt_ = reduce(flush_to_node_cnt, collective_add); int64_t useful_flush_to_node_cnt_ = reduce(useful_flush_to_node_cnt, collective_add); int64_t process_ring_buf_cnt_ = reduce(process_ring_buf_cnt, collective_add); int64_t polling_cnt_ = reduce(polling_cnt, collective_add); int64_t blocking_call_cnt_ = reduce(blocking_call_cnt, collective_add); int64_t async_call_cnt_ = reduce(async_call_cnt, collective_add); std::ofstream fout("profiling.txt"); fout << "## Overview " << std::endl; fout << "┌ total thread communication ticks : " << thread_comm_ticks_ << " ticks" << std::endl; fout << "└ total thread task worker ticks : " << thread_work_ticks_ << " ticks" << std::endl; fout << "## Communicator behavior" << std::endl; fout << "─ message buffer usage (max, avg, min) : (" << msg_usage_max_*100 << "%, " << msg_usage_*100/msg_usage_cnt_ << "%, " << msg_usage_min_*100 << "%)" << std::endl; fout << "─ message enqueue CAS count : " << enqueue_cas_cnt_ << std::endl; fout << "─ verbs rdma batching proportion : " << ((double)verbs_rdma_batch_cnt_*100.0 / verbs_rdma_cnt_) << "% (" << verbs_rdma_batch_cnt_ << "/" << verbs_rdma_cnt_ << ")" << std::endl; fout << "┌ average blocking call lantency : " << ((double)blocking_call_lantency_) / blocking_call_lantency_cnt_ << " ticks" << std::endl; fout << "└ max blocking call lantency : " << blocking_call_lantency_max_ << " ticks" << std::endl; fout << "┌ total enqueue message bytes : " << msg_enqueue_bytes_ << " bytes" << std::endl; fout << "├ total send-to-local message bytes : " << msg_local_bytes_ << " bytes" << std::endl; fout << "└ total send-to-remote message bytes : " << msg_remote_bytes_ << " bytes" << std::endl; fout << "┌ total peer_msg_cnt : " << peer_msg_cnt_ << " ( useful : " << 100.0*useful_peer_msg_cnt_/peer_msg_cnt_ << "% )" << std::endl; fout << "├ total flush_to_node_cnt : " << flush_to_node_cnt_ << " ( useful : " << 100.0*useful_flush_to_node_cnt_ / flush_to_node_cnt_ << "% )" << std::endl; fout << "├ total process_ring_buf : " << process_ring_buf_cnt_ << std::endl; fout << "└ total polling_cnt :" << polling_cnt_ << std::endl; fout << "┌ message in 1 cacheline :" << msg_1_cacheline_ << std::endl; fout << "├ message in 2 cacheline :" << msg_2_cacheline_ << std::endl; fout << "├ message in 3 cacheline :" << msg_3_cacheline_ << std::endl; fout << "├ message in 4 cacheline :" << msg_4_cacheline_ << std::endl; fout << "├ message in x cacheline :" << msg_x_cacheline_ << std::endl; fout << "└ message in heap :" << msg_on_heap_ << std::endl; fout << "## Scheduler behavior" << std::endl; fout << "─ context swap count : " << context_swap_cnt_ << std::endl; fout << "┌ total creadted task count : " << task_created_cnt_ << std::endl; fout << "└ total creadted heap task count : " << heap_task_created_cnt_ << std::endl; fout << "┌ total blocking call count : " << blocking_call_cnt_ << std::endl; fout << "└ total async call count : " << async_call_cnt_ << std::endl; fout << "## Special count" << std::endl; fout << "sp cnt : " << sp_cnt_ << std::endl; fout.close(); } }//namespace Ring
db37490e01c5bd295dcaecf9a7fa4ea09f91e027
b115fdbac9e80d46de97fd2bda09ecb7a2541b82
/neo/idlib/containers/ListSTL.h
b68c9d9e68975890c91d9ec71a1877d4761e6ffa
[]
no_license
jmarshall23/Doom3
2cb78fe81624bce2b7c68af8bcf437973331621f
f12b34e6fbca8a49dc751f71960e1b609ed8d9cd
refs/heads/master
2023-05-25T14:30:49.193713
2023-05-18T19:33:27
2023-05-18T19:33:27
360,633,347
6
2
null
null
null
null
UTF-8
C++
false
false
20,067
h
ListSTL.h
/* =========================================================================== Doom 3 GPL Source Code Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). Doom 3 Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Doom 3 Source Code 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 Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. =========================================================================== */ #pragma once #ifdef _DEBUG #define STL_NODEBUG #endif #ifdef STL_NODEBUG #pragma optimize( "", on ) #endif #ifndef FLT_EPSILON #define FLT_EPSILON 1.19209290E-07F #endif #include <vector> #ifdef STL_NODEBUG #pragma optimize( "", off ) #endif /* =============================================================================== List template Does not allocate memory until the first item is added. =============================================================================== */ // jmarshall // idList does a lot of unnnessary memory reallocations that cause huge performance problems, // to fix that I've modified rvmListSTL to use std::vector as a backend which should help with performance. // jmarshall end /* ================ rvmListSTLSortCompare<type> ================ */ #ifdef __INTEL_COMPILER // the intel compiler doesn't do the right thing here template< class type > ID_INLINE int rvmListSTLSortCompare(const type *a, const type *b) { assert(0); return 0; } #else template< class type > ID_INLINE int rvmListSTLSortCompare(const type *a, const type *b) { return *a - *b; } #endif /* ================ rvmListSTLNewElement<type> ================ */ template< class type > ID_INLINE type *rvmListSTLNewElement(void) { return new type; } template< class type > class rvmListSTL { public: typedef int cmp_t(const type *, const type *); typedef type new_t(void); rvmListSTL(int newgranularity = 16); rvmListSTL(const rvmListSTL<type> &other); ~rvmListSTL<type>(void); void Clear(bool purge = false); // clear the list int Num(void) const; // returns number of elements in list int NumAllocated(void) const; // returns number of elements allocated for void SetGranularity(int newgranularity); // set new granularity int GetGranularity(void) const; // get the current granularity size_t Allocated(void) const; // returns total size of allocated memory size_t Size(void) const; // returns total size of allocated memory including size of list type size_t MemoryUsed(void) const; // returns size of the used elements in the list rvmListSTL<type> & operator=(const rvmListSTL<type> &other); const type & operator[](int index) const; type & operator[](int index); void Condense(void); // resizes list to exactly the number of elements it contains void Resize(int newsize); // resizes list to the given number of elements void Resize(int newsize, int newgranularity); // resizes list and sets new granularity void SetNum(int newnum, bool resize = true); // set number of elements in list and resize to exactly this number if necessary void AssureSize(int newSize); // assure list has given number of elements, but leave them uninitialized void AssureSize(int newSize, const type &initValue); // assure list has given number of elements and initialize any new elements void AssureSizeAlloc(int newSize, new_t *allocator); // assure the pointer list has the given number of elements and allocate any new elements type * Ptr(void); // returns a pointer to the list const type * Ptr(void) const; // returns a pointer to the list type & Alloc(void); // returns reference to a new data element at the end of the list int Append(const type & obj); // append element int Append(const rvmListSTL<type> &other); // append list int AddUnique(const type & obj); // add unique element int Insert(const type & obj, int index = 0); // insert the element at the given index int FindIndex(const type & obj) const; // find the index for the given element type * Find(type const & obj) const; // find pointer to the given element int FindNull(void) const; // find the index for the first NULL pointer in the list int IndexOf(const type *obj) const; // returns the index for the pointer to an element in the list bool RemoveIndex(int index); // remove the element at the given index bool Remove(const type & obj); // remove the element void Sort(cmp_t *compare = (cmp_t *)&rvmListSTLSortCompare<type>); void SortSubSection(int startIndex, int endIndex, cmp_t *compare = (cmp_t *)&rvmListSTLSortCompare<type>); void Swap(rvmListSTL<type> &other); // swap the contents of the lists void DeleteContents(bool clear); // delete the contents of the list private: std::vector<type> list; }; /* ================ rvmListSTL<type>::rvmListSTL( int ) ================ */ template< class type > ID_INLINE rvmListSTL<type>::rvmListSTL(int newgranularity) { assert(newgranularity > 0); Clear(); } /* ================ rvmListSTL<type>::rvmListSTL( const rvmListSTL<type> &other ) ================ */ template< class type > ID_INLINE rvmListSTL<type>::rvmListSTL(const rvmListSTL<type> &other) { *this = other; } /* ================ rvmListSTL<type>::~rvmListSTL<type> ================ */ template< class type > ID_INLINE rvmListSTL<type>::~rvmListSTL(void) { Clear(); } /* ================ rvmListSTL<type>::Clear Frees up the memory allocated by the list. Assumes that type automatically handles freeing up memory. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::Clear(bool purge) { list.clear(); if (purge) { list.shrink_to_fit(); } } /* ================ rvmListSTL<type>::DeleteContents Calls the destructor of all elements in the list. Conditionally frees up memory used by the list. Note that this only works on lists containing pointers to objects and will cause a compiler error if called with non-pointers. Since the list was not responsible for allocating the object, it has no information on whether the object still exists or not, so care must be taken to ensure that the pointers are still valid when this function is called. Function will set all pointers in the list to NULL. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::DeleteContents(bool clear) { int i; for (i = 0; i < list.size(); i++) { delete list[i]; list[i] = NULL; } Clear(clear); } /* ================ rvmListSTL<type>::Allocated return total memory allocated for the list in bytes, but doesn't take into account additional memory allocated by type ================ */ template< class type > ID_INLINE size_t rvmListSTL<type>::Allocated(void) const { return list.size() * sizeof(type); } /* ================ rvmListSTL<type>::Size return total size of list in bytes, but doesn't take into account additional memory allocated by type ================ */ template< class type > ID_INLINE size_t rvmListSTL<type>::Size(void) const { return sizeof(rvmListSTL<type>) + Allocated(); } /* ================ rvmListSTL<type>::MemoryUsed ================ */ template< class type > ID_INLINE size_t rvmListSTL<type>::MemoryUsed(void) const { return list.size() * sizeof(type); } /* ================ rvmListSTL<type>::Num Returns the number of elements currently contained in the list. Note that this is NOT an indication of the memory allocated. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::Num(void) const { return list.size(); } /* ================ rvmListSTL<type>::NumAllocated Returns the number of elements currently allocated for. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::NumAllocated(void) const { return list.capacity(); } /* ================ rvmListSTL<type>::SetNum Resize to the exact size specified irregardless of granularity ================ */ template< class type > ID_INLINE void rvmListSTL<type>::SetNum(int newnum, bool resize) { assert(newnum >= 0); if (newnum == 0) { Clear(false); return; } list.resize(newnum); } /* ================ rvmListSTL<type>::SetGranularity Sets the base size of the array and resizes the array to match. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::SetGranularity(int newgranularity) { } /* ================ rvmListSTL<type>::GetGranularity Get the current granularity. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::GetGranularity(void) const { return 1; } /* ================ rvmListSTL<type>::Condense Resizes the array to exactly the number of elements it contains or frees up memory if empty. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::Condense(void) { //if (list.size() > 0) { // if (num) { // Resize(num); // } // else { // Clear(); // } //} } /* ================ rvmListSTL<type>::Resize Allocates memory for the amount of elements requested while keeping the contents intact. Contents are copied using their = operator so that data is correnctly instantiated. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::Resize(int newsize) { list.reserve(newsize); } /* ================ rvmListSTL<type>::Resize Allocates memory for the amount of elements requested while keeping the contents intact. Contents are copied using their = operator so that data is correnctly instantiated. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::Resize(int newsize, int newgranularity) { list.reserve(newsize); } /* ================ rvmListSTL<type>::AssureSize Makes sure the list has at least the given number of elements. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::AssureSize(int newSize) { if (newSize == 0) { Clear(false); return; } list.resize(newSize); } /* ================ rvmListSTL<type>::AssureSize Makes sure the list has at least the given number of elements and initialize any elements not yet initialized. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::AssureSize(int newSize, const type &initValue) { if (newSize == 0) { Clear(false); return; } list.resize(newSize); } /* ================ rvmListSTL<type>::AssureSizeAlloc Makes sure the list has at least the given number of elements and allocates any elements using the allocator. NOTE: This function can only be called on lists containing pointers. Calling it on non-pointer lists will cause a compiler error. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::AssureSizeAlloc(int newSize, new_t *allocator) { int currentSize = list.size(); if (newSize > list.size()) { list.resize(newSize); for (int i = currentSize; i < newSize; i++) { list[i] = (*allocator)(); } } } /* ================ rvmListSTL<type>::operator= Copies the contents and size attributes of another list. ================ */ template< class type > ID_INLINE rvmListSTL<type> &rvmListSTL<type>::operator=(const rvmListSTL<type> &other) { int i; Clear(); // num = other.num; // size = other.size; //granularity = other.granularity; list.resize(other.list.size()); std::copy(other.list.begin(), other.list.end(), list.begin()); return *this; } /* ================ rvmListSTL<type>::operator[] const Access operator. Index must be within range or an assert will be issued in debug builds. Release builds do no range checking. ================ */ template< class type > ID_INLINE const type &rvmListSTL<type>::operator[](int index) const { assert(index >= 0); return list[index]; } /* ================ rvmListSTL<type>::operator[] Access operator. Index must be within range or an assert will be issued in debug builds. Release builds do no range checking. ================ */ template< class type > ID_INLINE type &rvmListSTL<type>::operator[](int index) { assert(index >= 0); return (type &)list[index]; } /* ================ rvmListSTL<type>::Ptr Returns a pointer to the begining of the array. Useful for iterating through the list in loops. Note: may return NULL if the list is empty. FIXME: Create an iterator template for this kind of thing. ================ */ template< class type > ID_INLINE type *rvmListSTL<type>::Ptr(void) { if (list.size() == 0) return nullptr; return (type *)&list[0]; } /* ================ rvmListSTL<type>::Ptr Returns a pointer to the begining of the array. Useful for iterating through the list in loops. Note: may return NULL if the list is empty. FIXME: Create an iterator template for this kind of thing. ================ */ template< class type > const ID_INLINE type *rvmListSTL<type>::Ptr(void) const { if (list.size() == 0) return nullptr; return (type *)&list[0]; } /* ================ rvmListSTL<type>::Alloc Returns a reference to a new data element at the end of the list. ================ */ template< class type > ID_INLINE type &rvmListSTL<type>::Alloc(void) { type new_obj; Append(new_obj); return list[list.size() - 1]; } /* ================ rvmListSTL<type>::Append Increases the size of the list by one element and copies the supplied data into it. Returns the index of the new element. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::Append(type const & obj) { list.push_back(obj); return list.size() - 1; } /* ================ rvmListSTL<type>::Insert Increases the size of the list by at leat one element if necessary and inserts the supplied data into it. Returns the index of the new element. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::Insert(type const & obj, int index) { list.insert(list.begin() + index, obj); return index; } /* ================ rvmListSTL<type>::Append adds the other list to this one Returns the size of the new combined list ================ */ template< class type > ID_INLINE int rvmListSTL<type>::Append(const rvmListSTL<type> &other) { int startIdx = list.size(); Resize(list.size() + other.Size()); int n = other.Num(); for (int i = startIdx; i < startIdx + n; i++) { Append(other[i]); } return Num(); } /* ================ rvmListSTL<type>::AddUnique Adds the data to the list if it doesn't already exist. Returns the index of the data in the list. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::AddUnique(type const & obj) { int index; index = FindIndex(obj); if (index < 0) { index = Append(obj); } return index; } /* ================ rvmListSTL<type>::FindIndex Searches for the specified data in the list and returns it's index. Returns -1 if the data is not found. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::FindIndex(type const & obj) const { int i; for (i = 0; i < list.size(); i++) { if (list[i] == obj) { return i; } } // Not found return -1; } /* ================ rvmListSTL<type>::Find Searches for the specified data in the list and returns it's address. Returns NULL if the data is not found. ================ */ template< class type > ID_INLINE type *rvmListSTL<type>::Find(type const & obj) const { int i; i = FindIndex(obj); if (i >= 0) { return (type *)&Ptr()[i]; } return NULL; } /* ================ rvmListSTL<type>::FindNull Searches for a NULL pointer in the list. Returns -1 if NULL is not found. NOTE: This function can only be called on lists containing pointers. Calling it on non-pointer lists will cause a compiler error. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::FindNull(void) const { int i; for (i = 0; i < list.size(); i++) { if (list[i] == NULL) { return i; } } // Not found return -1; } /* ================ rvmListSTL<type>::IndexOf Takes a pointer to an element in the list and returns the index of the element. This is NOT a guarantee that the object is really in the list. Function will assert in debug builds if pointer is outside the bounds of the list, but remains silent in release builds. ================ */ template< class type > ID_INLINE int rvmListSTL<type>::IndexOf(type const *objptr) const { int index; index = objptr - list; assert(index >= 0); // assert(index < num); return index; } /* ================ rvmListSTL<type>::RemoveIndex Removes the element at the specified index and moves all data following the element down to fill in the gap. The number of elements in the list is reduced by one. Returns false if the index is outside the bounds of the list. Note that the element is not destroyed, so any memory used by it may not be freed until the destruction of the list. ================ */ template< class type > ID_INLINE bool rvmListSTL<type>::RemoveIndex(int index) { int i; // assert( list != NULL ); assert(index >= 0); list.erase(list.begin() + index); return true; } /* ================ rvmListSTL<type>::Remove Removes the element if it is found within the list and moves all data following the element down to fill in the gap. The number of elements in the list is reduced by one. Returns false if the data is not found in the list. Note that the element is not destroyed, so any memory used by it may not be freed until the destruction of the list. ================ */ template< class type > ID_INLINE bool rvmListSTL<type>::Remove(type const & obj) { int index; index = FindIndex(obj); if (index >= 0) { return RemoveIndex(index); } return false; } /* ================ rvmListSTL<type>::Sort Performs a qsort on the list using the supplied comparison function. Note that the data is merely moved around the list, so any pointers to data within the list may no longer be valid. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::Sort(cmp_t *compare) { if (list.size() <= 0) { return; } typedef int cmp_c(const void *, const void *); cmp_c *vCompare = (cmp_c *)compare; qsort((void *)Ptr(), (size_t)list.size(), sizeof(type), vCompare); } /* ================ rvmListSTL<type>::SortSubSection Sorts a subsection of the list. ================ */ template< class type > ID_INLINE void rvmListSTL<type>::SortSubSection(int startIndex, int endIndex, cmp_t *compare) { if (list.size() <= 0) { return; } if (startIndex < 0) { startIndex = 0; } if (endIndex >= list.size()) { endIndex = list.size() - 1; } if (startIndex >= endIndex) { return; } typedef int cmp_c(const void *, const void *); cmp_c *vCompare = (cmp_c *)compare; qsort((void *)(Ptr()[startIndex]), (size_t)(endIndex - startIndex + 1), sizeof(type), vCompare); } /* ================ rvmListSTL<type>::Swap Swaps the contents of two lists ================ */ template< class type > ID_INLINE void rvmListSTL<type>::Swap(rvmListSTL<type> &other) { // idSwap( num, other.num ); // idSwap( size, other.size ); // idSwap( granularity, other.granularity ); idSwap(list, other.list); } #undef FLT_EPSILON
9f4fc426e5c2e41a4ae09e87210947945a078e9b
d2357e5ff603771df5dcb6db1f5f7bd5324d902d
/Colour.cpp
3fff968d3e222a637b323684230e33bb6704aba5
[ "BSD-3-Clause" ]
permissive
janLo/htw-computer-graphics-radiosity
4893489ad3475f09d344a12db04925f01d63a022
fb0589e8beb3af8c63c21f6eed855c3d82c2b8fd
refs/heads/master
2016-09-06T12:38:25.342540
2014-08-24T23:39:36
2014-08-24T23:39:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
44
cpp
Colour.cpp
#include "Colour.hpp" namespace radio { }
449765464074eeeafd89962fc96c9b4d82599b1c
44d4400b658c4184e81fa3d2f11a60ab15d74b0d
/examples/hookup_guide/hookup_guide.ino
5460fed704c38615a2836cf06b710721b880e294
[]
no_license
jpk73/CharacterDOGM
bd4de4fe56f68d1e96d004cfa5c270d1ddadb036
7543ec705b6f91664c91a27f879b12af0d287c82
refs/heads/master
2022-12-30T23:28:07.259141
2020-10-13T20:33:20
2020-10-13T20:33:20
266,580,423
0
0
null
null
null
null
UTF-8
C++
false
false
1,165
ino
hookup_guide.ino
#include <CharacterDOGM.h> /* DOGM204 pin connections: the bottom row of pins has 3 pins left and 3 pins right, these are pins 1-3 and 20-22: 01 +LED (for limiting resistors see data sheet) 02 +LED 03 +LED 20 -LED -> GND (solder all 6 top row pins also from above to the LED panel!) 21 -LED -> GND 22 -LED -> GND the top row of pins has 22 pins, these are pins 23-44, numbered from right to left: 23 1uF -> GND 24 1uF -> GND 25 1uF -> GND 26 1uF -> GND 27 1uF -> GND 28 1uF -> GND 29 -> 3V3 30 -> 3V3 31 -> 3V3, with 1uF -> GND 32 -> GND 33 -> D7 34 -> D6 35 -> D5 36 -> D4 37 -> 3V3 38 -> 3V3 39 -> 3V3 40 -> 3V3 41 -> EN 42 -> RW -> GND 43 -> RS 44 -> RESET (drive with something like an MCP100-315 or actively with an mcu pin, see data sheet) */ // display pins (all pins output only): #define lcd_rs 1 #define lcd_en 2 #define lcd_d4 8 #define lcd_d5 10 #define lcd_d6 9 #define lcd_d7 0 // this library does not poll the busy flag on d7 CharacterDOGM lcd(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7); // init library void setup() { lcd.print("hello world! DOGM204"); } void loop() { lcd.setCursor(0, 1); lcd.print(millis() / 1000); }
a9508db8cf1abeeb788c57b2b47c9fd2320da55c
83e81885d8de443c8453c2eaa1ef7e93e6bac69c
/src/wspc/type_description.hpp
ec95917401ad5a0c1af0fb31c5b332ffe28e41b5
[ "MIT" ]
permissive
k0zmo/wspc
769048450597603c5db708de26da4fbaec1cbd8a
b489e63768ec1b76c03f70101f80e35713cb2f6b
refs/heads/master
2020-12-25T15:17:44.005645
2017-04-09T13:24:20
2017-04-09T13:28:52
66,496,697
2
1
null
null
null
null
UTF-8
C++
false
false
5,329
hpp
type_description.hpp
/* * Copyright (c) 2016 Kajetan Swierk * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #ifndef WSPC_TYPE_DESCRIPTION_HPP_GUARD #define WSPC_TYPE_DESCRIPTION_HPP_GUARD #include <kl/ctti.hpp> #include <kl/enum_reflector.hpp> #include <kl/enum_traits.hpp> #include <kl/stream_join.hpp> #include <kl/index_sequence.hpp> #include <kl/tuple.hpp> #include <boost/type_index/ctti_type_index.hpp> #include <sstream> #include <type_traits> namespace wspc { template <typename T> std::string get_type_info(); template <typename T> void get_type_info(std::stringstream& strm); namespace detail { void sanitize_html(std::stringstream& strm, const char* in); template <typename T> void sanitize_html_typename(std::stringstream& strm); template <typename T> struct is_tuple : std::false_type {}; template <typename... Ts> struct is_tuple<std::tuple<Ts...>> : std::true_type {}; template <typename T> using is_reflectable_enum = kl::bool_constant<std::is_enum<T>::value && kl::enum_traits<T>::support_range>; template <typename T> using is_custom_type_info = kl::bool_constant<kl::is_reflectable<T>::value || is_tuple<T>::value || is_reflectable_enum<T>::value>; struct type_info_writer { template <typename T, kl::enable_if<kl::is_reflectable<T>> = 0> static void write(std::stringstream& strm) { sanitize_html_typename<T>(strm); strm << " { "; kl::ctti::reflect<T>(visitor{strm}); strm << " }"; } template <typename T, kl::enable_if<is_tuple<T>> = 0> static void write(std::stringstream& strm) { write_tuple<T>(strm, kl::make_tuple_indices<T>{}); } template <typename T, kl::enable_if<is_reflectable_enum<T>> = 0> static void write(std::stringstream& strm) { sanitize_html_typename<T>(strm); using enum_type = std::remove_cv_t<T>; using enum_reflector = kl::enum_reflector<enum_type>; using enum_traits = kl::enum_traits<enum_type>; strm << " ("; auto joiner = kl::make_outstream_joiner(strm, ", "); for (auto i = enum_traits::min_value(); i < enum_traits::max_value(); ++i) { if (const auto str = enum_reflector::to_string(static_cast<enum_type>(i))) { joiner = str; } } strm << ")"; } private: struct visitor { explicit visitor(std::stringstream& strm) : strm_{strm} {} template <typename FieldInfo> void operator()(FieldInfo f) { if (current_field_index_) strm_ << ", "; strm_ << " "; sanitize_html(strm_, f.name()); strm_ << " :: "; get_type_info<typename FieldInfo::type>(strm_); ++current_field_index_; } private: std::stringstream& strm_; std::size_t current_field_index_{0}; }; template <typename T, std::size_t... Is> static void write_tuple(std::stringstream& strm, kl::index_sequence<Is...>) { strm << "[ "; auto joiner = kl::make_outstream_joiner(strm, ", "); using swallow = std::initializer_list<int>; (void)swallow{ (joiner = get_type_info<std::tuple_element_t<Is, T>>(), 0)...}; strm << " ]"; } }; template <typename T> void sanitize_html_typename(std::stringstream& strm) { sanitize_html(strm, boost::typeindex::ctti_type_index::type_id_with_cvr<T>() .pretty_name() .c_str()); } template <typename T> void get_type_info_impl(std::stringstream& strm, std::true_type /*is_custom_type_info*/) { type_info_writer::write<T>(strm); } template <typename T> void get_type_info_impl(std::stringstream& strm, std::false_type /*is_custom_type_info*/) { sanitize_html_typename<T>(strm); } } // namespace detail template <typename T> void get_type_info(std::stringstream& strm) { detail::get_type_info_impl<T>(strm, detail::is_custom_type_info<T>{}); } template <typename T> std::string get_type_info() { std::stringstream strm; get_type_info<T>(strm); return strm.str(); } } // namespace wspc #endif
75502ae06b995a1ebc22133f485e105302c5f4a0
185aac857712226f43f732afa1788dc112555280
/srcs/utils/ft_utils.hpp
be350b4c9f484e35d2826093b2b72ca1a18beefb
[]
no_license
ServaneC/ft_containers
31318986925c0050cc7ba1a9799fc928492ca6e8
df229ed31ccbb0be571163eb46a7f6306f13b61e
refs/heads/main
2023-03-08T23:46:13.021526
2021-02-25T08:23:41
2021-02-25T08:23:41
326,990,211
0
0
null
null
null
null
UTF-8
C++
false
false
1,149
hpp
ft_utils.hpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_utils.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: schene <schene@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/02/05 13:59:37 by schene #+# #+# */ /* Updated: 2021/02/23 11:58:54 by schene ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_UTILS_HPP # define FT_UTILS_HPP # include <limits> namespace ft { template< bool condition, class T = void> struct enable_if{}; //nothing defined when not true. template<class T> struct enable_if<true, T> { typedef T type; }; } #endif
6e5048108688ec4943fa815204015835f2b560f6
4e721661263269d080fe4c5d19a633348282276f
/avahi.cpp
6ddeef8e75eca2278b581136e21861da31d215ab
[]
no_license
straccio/bonway
862221a1fb588585bdf734131b8ee4fb6131cb17
a77d3fb361a1713b257055ac47405764f250ccdb
refs/heads/master
2021-01-18T14:31:20.210754
2013-06-22T23:02:02
2013-06-22T23:02:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,185
cpp
avahi.cpp
#include <stdio.h> #include <stdexcept> #include <iostream> #include <time.h> #include <avahi-client/client.h> #include <avahi-client/publish.h> #include "avahi.h" #include "browser.h" #include "resolver.h" #include "service.h" #include "entrygroup.h" namespace Avahi { Avahi::Avahi() { this->browsers = std::list<Browser *>(); this->groups = std::list<EntryGroup *>(); this->terminated = false; this->last_commit = 0; this->poll = avahi_simple_poll_new(); if (this->poll == NULL) throw std::runtime_error("Could not create event loop."); this->client = avahi_client_new(avahi_simple_poll_get(this->poll), (AvahiClientFlags)0, client_callback, this, NULL); if (this->client == NULL) throw std::runtime_error("Could not contact Avahi daemon."); } Avahi::~Avahi() { while (this->browsers.size() > 0) { Browser *browser = *this->browsers.begin(); this->browsers.remove(browser); delete browser; } while (this->groups.size() > 0) { EntryGroup *group = *this->groups.begin(); this->groups.remove(group); delete group; } avahi_client_free(this->client); avahi_simple_poll_free(this->poll); } void Avahi::ClientCallback(AvahiClientState state) { if (state == AVAHI_CLIENT_FAILURE) { std::cout << "Client state failed for some reason." << std::endl; this->Terminate(); } } void Avahi::Commit() { std::list<EntryGroup *>::iterator it; for (it = this->groups.begin(); it != this->groups.end(); it++) { if ((*it)->isDirty() == true) (*it)->Commit(); } this->last_commit = time(NULL); } void Avahi::Terminate() { if (this->terminated == false) { this->terminated = true; avahi_simple_poll_quit(this->poll); } } int Avahi::Run(int timeout) { if ((time(NULL) - this->last_commit) > 5) Commit(); if (this->terminated) return 1; return avahi_simple_poll_iterate(this->poll, timeout); } Browser *Avahi::Browse(std::string service, std::string domain, void *userdata) { Browser *browser; browser = new Browser(this->client, AVAHI_IF_UNSPEC, service, domain, userdata); this->browsers.push_back(browser); return browser; } Resolver *Avahi::Resolve(AvahiIfIndex interface, AvahiProtocol protocol, std::string name, std::string type, std::string domain, void *userdata) { return new Resolver(this->client, interface, protocol, name, type, domain, userdata); } void Avahi::Publish(Service svc) { std::list<EntryGroup *>::iterator it; EntryGroup *group = NULL; for (it = this->groups.begin(); it != this->groups.end(); it++) { group = (*it); if (group->GetHostName() == svc.GetHostName()) { group->Publish(svc); return; } } // // No group found for this host name, create a new group. // group = new EntryGroup(this->client, svc.GetHostName(), svc.GetAddress()); this->groups.push_back(group); group->Publish(svc); } void Avahi::client_callback(AvahiClient *c, AvahiClientState state, void *userdata) { Avahi *avahi; if (c == NULL || userdata == NULL) return; avahi = (Avahi *)userdata; avahi->ClientCallback(state); } } /* namespace */
7a987d8a2f03fdffd8318fd516764dc03216fa69
8acaf1aa24404b86d77cf60761b111404b09cc8e
/variadic-templates/tests.cpp
0819155db383e4857ed4cb94408b87eada28423d
[]
no_license
infotraining/cpp-modern-2020-10-14
53312b2fdce2cc4cf55891b439944fe2a9ef074c
6e15376fe78c0ecf091aa15b9273d97b8bedeee3
refs/heads/main
2023-01-01T21:53:34.757983
2020-10-16T14:36:16
2020-10-16T14:36:16
303,329,899
0
1
null
null
null
null
UTF-8
C++
false
false
966
cpp
tests.cpp
#include "catch.hpp" #include <iostream> #include <string> #include <vector> using namespace std; using namespace Catch::Matchers; void print() { std::cout << "\n"; } template <typename Head, typename... Tail> void print(const Head& head, const Tail&... tail) { std::cout << head << " "; print(tail...); } namespace Cpp17 { template <typename Head, typename... Tail> void print(const Head& head, const Tail&... tail) { puts(__PRETTY_FUNCTION__); std::cout << head << "\n"; if constexpr(sizeof...(tail) > 0) print(tail...); else std::cout << "\n"; } } TEST_CASE("variadic function") { Cpp17::print(1, 3.14, 5.9f, "abc", 1, 3.14, "text", "abc"); print(1, 3.14); } template <typename... Args> struct ListType { constexpr static size_t size = sizeof...(Args); }; TEST_CASE("list of types") { static_assert(ListType<int, double>::size == 2, "Error"); }
ddff74bf6534db6fa4ef783d3531c7b219b7958e
bf007dec921b84d205bffd2527e376bb60424f4c
/Codeforces_Submissions/489C.cpp
233ba118f31c9366c84a07eb0739b26920522a30
[]
no_license
Suvrojyoti/APS-2020
257e4a94f52f5fe8adcac1ba4038cc66e81d9d26
d4de0ef098e7ce9bb40036ef55616fa1f159f7a5
refs/heads/master
2020-12-21T19:27:59.955338
2020-04-22T13:27:49
2020-04-22T13:27:49
236,534,218
0
0
null
null
null
null
UTF-8
C++
false
false
1,898
cpp
489C.cpp
#include <bits/stdc++.h> using namespace std; int main() { long long int m,s,n,i,t,m1; vector <long long int> v,v1; cin>>m>>s; t=s; m1=m; if(m==1 && s<10) cout<<s<<" "<<s; else if(s>9*m||s==0) cout<<"-1 -1"; /*else if(s<m) { while(m--) { if(s>m) { v.push_back(1); s--; } else v.push_back(0); } for(auto itr=v.begin();itr!=v.end();itr++) cout<<*itr; cout<<" "; m=m1; s=t; v.clear(); while(m--) { if(s>9) { v.push_back(9); s=s-9; } else { v.push_back(s); s=0; } } for(auto itr=v.begin();itr!=v.end();itr++) cout<<*itr; }*/ else { while(m--) { if(s>9) { v.push_back(9); s=s-9; } else { v.push_back(s); s=0; } } s=t; int flag=0; while(m1--) { if(s<=9*m1) { if(!flag) { v1.push_back(1); flag=1; s--; } else v1.push_back(0); } else { v1.push_back(s-9*m1); //cout<<s-9*m1<<" "; s=9*m1; } } //cout<<"\n"; for(auto itr=v1.begin();itr!=v1.end();itr++) cout<<*itr; cout<<" "; for(auto itr=v.begin();itr!=v.end();itr++) cout<<*itr; } return 0; }
a1b3ebb1733b23e7ff37f92ab497f69af11ac474
f21ebd3fa1298a425e31d01f9dade2e500bb9aed
/lua-binding/lua_cocos2dx_mapstringbuffer_auto.cpp
f4ec2eb33f5a936bb0fbcce3d02e94cac63ecc13
[]
no_license
gdsgtcz/mlua
6ef0cc1374add27c4abb87c111d5cc0f5970ddfa
ae95055afd57bc52f622bb0b3d834d12b82cb335
refs/heads/master
2021-01-10T11:20:14.625820
2016-01-08T07:23:25
2016-01-08T07:23:25
49,127,486
5
2
null
null
null
null
UTF-8
C++
false
false
13,073
cpp
lua_cocos2dx_mapstringbuffer_auto.cpp
#include "lua_cocos2dx_mapstringbuffer_auto.hpp" #include "MapStringBuffer.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" int lua_cocos2dx_mapstringbuffer_MapStringBuffer_insert(lua_State* tolua_S) { int argc = 0; MapStringBuffer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"MapStringBuffer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (MapStringBuffer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_insert'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; StringBuffer* arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0, "MapStringBuffer:insert"); ok &= luaval_to_object<StringBuffer>(tolua_S, 3, "StringBuffer",&arg1); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_insert'", nullptr); return 0; } cobj->insert(arg0, arg1); lua_settop(tolua_S, 1); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "MapStringBuffer:insert",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_insert'.",&tolua_err); #endif return 0; } int lua_cocos2dx_mapstringbuffer_MapStringBuffer_length(lua_State* tolua_S) { int argc = 0; MapStringBuffer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"MapStringBuffer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (MapStringBuffer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_length'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_length'", nullptr); return 0; } int ret = cobj->length(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "MapStringBuffer:length",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_length'.",&tolua_err); #endif return 0; } int lua_cocos2dx_mapstringbuffer_MapStringBuffer_remove(lua_State* tolua_S) { int argc = 0; MapStringBuffer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"MapStringBuffer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (MapStringBuffer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_remove'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0, "MapStringBuffer:remove"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_remove'", nullptr); return 0; } cobj->remove(arg0); lua_settop(tolua_S, 1); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "MapStringBuffer:remove",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_remove'.",&tolua_err); #endif return 0; } int lua_cocos2dx_mapstringbuffer_MapStringBuffer_getValue(lua_State* tolua_S) { int argc = 0; MapStringBuffer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"MapStringBuffer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (MapStringBuffer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_getValue'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0, "MapStringBuffer:getValue"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_getValue'", nullptr); return 0; } StringBuffer* ret = cobj->getValue(arg0); object_to_luaval<StringBuffer>(tolua_S, "StringBuffer",(StringBuffer*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "MapStringBuffer:getValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_getValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_mapstringbuffer_MapStringBuffer_removeAll(lua_State* tolua_S) { int argc = 0; MapStringBuffer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"MapStringBuffer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (MapStringBuffer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_removeAll'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_removeAll'", nullptr); return 0; } cobj->removeAll(); lua_settop(tolua_S, 1); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "MapStringBuffer:removeAll",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_removeAll'.",&tolua_err); #endif return 0; } int lua_cocos2dx_mapstringbuffer_MapStringBuffer_add(lua_State* tolua_S) { int argc = 0; MapStringBuffer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"MapStringBuffer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (MapStringBuffer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_add'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; int arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0, "MapStringBuffer:add"); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "MapStringBuffer:add"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_add'", nullptr); return 0; } cobj->add(arg0, arg1); lua_settop(tolua_S, 1); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "MapStringBuffer:add",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_add'.",&tolua_err); #endif return 0; } int lua_cocos2dx_mapstringbuffer_MapStringBuffer_destroy(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"MapStringBuffer",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_destroy'", nullptr); return 0; } MapStringBuffer::destroy(); lua_settop(tolua_S, 1); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "MapStringBuffer:destroy",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_destroy'.",&tolua_err); #endif return 0; } int lua_cocos2dx_mapstringbuffer_MapStringBuffer_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"MapStringBuffer",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_getInstance'", nullptr); return 0; } MapStringBuffer* ret = MapStringBuffer::getInstance(); object_to_luaval<MapStringBuffer>(tolua_S, "MapStringBuffer",(MapStringBuffer*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "MapStringBuffer:getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_getInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_mapstringbuffer_MapStringBuffer_constructor(lua_State* tolua_S) { int argc = 0; MapStringBuffer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_constructor'", nullptr); return 0; } cobj = new MapStringBuffer(); tolua_pushusertype(tolua_S,(void*)cobj,"MapStringBuffer"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "MapStringBuffer:MapStringBuffer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_mapstringbuffer_MapStringBuffer_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_mapstringbuffer_MapStringBuffer_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MapStringBuffer)"); return 0; } int lua_register_cocos2dx_mapstringbuffer_MapStringBuffer(lua_State* tolua_S) { tolua_usertype(tolua_S,"MapStringBuffer"); tolua_cclass(tolua_S,"MapStringBuffer","MapStringBuffer","cc.Object",nullptr); tolua_beginmodule(tolua_S,"MapStringBuffer"); tolua_function(tolua_S,"new",lua_cocos2dx_mapstringbuffer_MapStringBuffer_constructor); tolua_function(tolua_S,"insert",lua_cocos2dx_mapstringbuffer_MapStringBuffer_insert); tolua_function(tolua_S,"length",lua_cocos2dx_mapstringbuffer_MapStringBuffer_length); tolua_function(tolua_S,"remove",lua_cocos2dx_mapstringbuffer_MapStringBuffer_remove); tolua_function(tolua_S,"getValue",lua_cocos2dx_mapstringbuffer_MapStringBuffer_getValue); tolua_function(tolua_S,"removeAll",lua_cocos2dx_mapstringbuffer_MapStringBuffer_removeAll); tolua_function(tolua_S,"add",lua_cocos2dx_mapstringbuffer_MapStringBuffer_add); tolua_function(tolua_S,"destroy", lua_cocos2dx_mapstringbuffer_MapStringBuffer_destroy); tolua_function(tolua_S,"getInstance", lua_cocos2dx_mapstringbuffer_MapStringBuffer_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(MapStringBuffer).name(); g_luaType[typeName] = "MapStringBuffer"; g_typeCast["MapStringBuffer"] = "MapStringBuffer"; return 1; } TOLUA_API int register_all_cocos2dx_mapstringbuffer(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,"mLua",0); tolua_beginmodule(tolua_S,"mLua"); lua_register_cocos2dx_mapstringbuffer_MapStringBuffer(tolua_S); tolua_endmodule(tolua_S); return 1; }
9290a3feb16b0af15579d7f74c1c798af42e7223
51fd68fc0d7ebadadeb568950920621b58058af3
/C++/code/373.cpp
540151f61228eef5ab7c5bbdab5ec11938111fa4
[]
no_license
leafeonia/leetcode
7b0eded595ed7bf349472ea26fa1128c28ee3767
f6c0348d694a11011a0544027a720645a5577bad
refs/heads/master
2021-12-07T00:32:13.517169
2021-10-25T07:46:29
2021-10-25T07:46:29
194,399,032
0
0
null
null
null
null
UTF-8
C++
false
false
843
cpp
373.cpp
class Solution { public: vector<vector<int>> kSmallestPairs(vector<int>& nums1, vector<int>& nums2, int k) { vector<vector<int>> ans; int m = nums1.size(), n = nums2.size(); typedef pair<int, int> pi; auto compare = [&nums1, &nums2](pi a, pi b) {return nums1[a.first] + nums2[a.second] > nums1[b.first] + nums2[b.second];}; priority_queue<pi, vector<pi>, decltype(compare)> pq(compare); for (int i = 0; i < m; i++) { pq.push({i, 0}); } for (int i = 0; i < k; i++) { if (pq.empty()) break; auto top = pq.top(); pq.pop(); vector<int> v{nums1[top.first], nums2[top.second]}; if (top.second < n - 1) pq.push({top.first, top.second + 1}); ans.push_back(v); } return ans; } };
bc6d4c79d1edca94a7ff27b6a6136747952a8777
c9f48a3440bd6db4159eb32a6f29f463221e3248
/hashtable/Longest_subarray_ sum_divisible _k.cpp
49f6a138f7e2bfd1fcd33645379cdd9e8f39e53c
[]
no_license
llucifer97/Algorithms-Datastructure
0870bfa3e84907325f565c2104d5cfce8fe71126
72fd4f4ce652680b7bf7171876921aa1ca209e41
refs/heads/master
2023-09-02T10:18:14.961478
2021-11-06T16:27:02
2021-11-06T16:27:02
231,233,422
10
13
null
2020-10-06T03:35:25
2020-01-01T15:38:19
C++
UTF-8
C++
false
false
1,369
cpp
Longest_subarray_ sum_divisible _k.cpp
// C++ implementation to find the longest subarray // with sum divisible by k #include <bits/stdc++.h> using namespace std; int longSubarrWthSumDivByK(int arr[], int n, int k) { // unodered map 'um' implemented as // hash table unordered_map<int, int> um; // 'mod_arr[i]' stores (sum[0..i] % k) int mod_arr[n], max = 0; int curr_sum = 0; // traverse arr[] and build up the // array 'mod_arr[]' for (int i = 0; i < n; i++) { curr_sum += arr[i]; // as the sum can be negative, taking modulo twice mod_arr[i] = ((curr_sum % k) + k) % k; } for (int i = 0; i < n; i++) { // if true then sum(0..i) is divisible // by k if (mod_arr[i] == 0) // update 'max' max = i + 1; // if value 'mod_arr[i]' not present in 'um' // then store it in 'um' with index of its // first occurrence else if (um.find(mod_arr[i]) == um.end()) um[mod_arr[i]] = i; else // if true, then update 'max' if (max < (i - um[mod_arr[i]])) max = i - um[mod_arr[i]]; } // required length of longest subarray with // sum divisible by 'k' return max; } // Driver program to test above int main() { int arr[] = {2, 7, 6, 1, 4, 5}; int n = sizeof(arr) / sizeof(arr[0]); int k = 3; cout << "Length = " << longSubarrWthSumDivByK(arr, n, k); return 0; }
b0e88ccd3bf5363e325eefe641c279adde880c62
c095a028e5f5aa406658e3039d8fad7ed3011177
/WaveSynthFramework/Utility.hpp
6d97f86582e6f22d664d58708d1eabbe03c39806
[ "MIT" ]
permissive
EricGeorge/AUInstrument
a5fef5bb8316bcf68d67f89880944133436a8daf
da684aa6fe4cee3119317054df1dbab503358c9c
refs/heads/master
2022-03-12T17:23:47.795230
2017-12-29T18:20:05
2017-12-29T18:20:05
57,463,606
31
3
MIT
2022-03-03T01:52:11
2016-04-30T21:59:33
Objective-C
UTF-8
C++
false
false
289
hpp
Utility.hpp
// // Utility.hpp // AUInstrument // // Created by Eric on 4/30/16. // Copyright © 2016 Eric George. All rights reserved. // #ifndef Utility_h #define Utility_h static inline double noteToHz(int noteNumber) { return 440. * exp2((noteNumber - 69)/12.); } #endif /* Utility_h */
9b976ea248a68229779560414dd34b98ef4aa4aa
bd66a2e27dea9f096cee03e10bc9c75cb1bba04f
/src/ops/relu.hpp
3b696b83362243bda322572366132d7c0d31bdb1
[ "MIT" ]
permissive
fmitch/LPLANN
f7ba312ccb968b650f53b7a3efa17f6484910e92
c526113e583058c3b9f4ea5ef5ccc7d5a9d658d3
refs/heads/master
2021-10-08T13:10:20.402197
2018-12-12T16:26:06
2018-12-12T16:26:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
992
hpp
relu.hpp
#ifndef RELU_HPP #define RELU_HPP #include <vector> #include <algorithm> template <typename T> void relu(Matrix<T> * input, Matrix<T>* output){ int size = 1; for( int i = 0; i < input->dims.size(); i++){ size *= input->dims[i]; } for(int i = 0; i < size; i++){ output->arr[i] = std::max<T>(input->arr[i], 0); } } template <typename T> void leaky_relu(Matrix<T>* input, Matrix<T>* output, T a){ int size = 1; for( int i = 0; i < input->dims.size(); i++){ size *= input->dims[i]; } for(int i = 0; i < size; i++){ output->arr[i] = std::max(input->arr[i]/a, input->arr[i]); } } template <typename T> void relu(T* input, T* output, int size){ for(int i = 0; i < size; i++){ output[i] = std::max<T>(output[i], 0); } } template <typename T> void relu(T* input, T* output, int size, T a){ for(int i = 0; i < size; i++){ output->arr[i] = std::max(input->arr[i]/a, input->arr[i]); } } #endif
3931b375ef5e48c28c0719840dc5637032433c95
f7cdc5f5064280adf71af9a81088a51fcbe7ec43
/TriangleTest.cpp
061cc452af4cc66c45faec0ff5a7569d650252c1
[]
no_license
marston2yu/leetcode
e2321d70744a11875563c942091a65d7abbff6ee
7e25faee8ebc0d4556e30dcb0a21ab54e45e1eaa
refs/heads/master
2020-04-23T07:43:31.186280
2020-02-16T07:19:35
2020-02-16T07:19:35
171,013,987
1
0
null
null
null
null
UTF-8
C++
false
false
379
cpp
TriangleTest.cpp
#define CATCH_CONFIG_MAIN #include <catch2/catch.hpp> #include "Triangle.h" TEST_CASE("Test Triangle") { vector<vector<int>> v{{2}, {3, 4}, {6, 5, 7}, {4, 1, 8, 3}}; vector<vector<int>> v2{{-1}, {-2, -3}}; REQUIRE(minimumTotal(v2) == -4); REQUIRE(minimumTotal(v) == 11); }
f382ddd6bb3377eb01d8e0cfe20e6737ebef097b
c11da72ede8450aad6767eb5d9d6b00cace13042
/ViroRenderer/VROTexture.cpp
f021999379b2851f9cb771364146fbfee166702b
[ "MIT" ]
permissive
mendix/virocore
192d1e79f5b5d36d920a4608939843c3e808c2d4
fd3cf5ac4222bb48a5b3af984f0c428ea316d762
refs/heads/master
2023-02-17T17:25:58.449812
2021-01-06T17:23:28
2021-01-06T17:23:28
258,201,318
1
2
MIT
2021-01-06T17:28:07
2020-04-23T12:54:36
C++
UTF-8
C++
false
false
11,290
cpp
VROTexture.cpp
// // VROTexture.cpp // ViroRenderer // // Created by Raj Advani on 11/17/15. // Copyright © 2015 Viro Media. All rights reserved. // // 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. #include "VROTexture.h" #include "VROTextureSubstrate.h" #include "VRODriver.h" #include "VROTextureSubstrateMetal.h" #include "VROLog.h" #include "VROAllocationTracker.h" #include "VROData.h" #include "VROImage.h" #include "VROMaterialVisual.h" #include "VROFrameScheduler.h" #include "VROStringUtil.h" #include <atomic> static std::atomic_int sTextureId; VROTexture::VROTexture(VROTextureType type, VROTextureInternalFormat internalFormat, VROStereoMode stereoMode) : _textureId(sTextureId++), _type(type), _format(VROTextureFormat::RGBA8), _internalFormat(internalFormat), _stereoMode(stereoMode), // Note these parameters are irrelevant for this constructor, since they are used // to generate a substrate, and for this constructor the substrate is injected externally _sRGB(false), _wrapS(VROWrapMode::Clamp), _wrapT(VROWrapMode::Clamp), _minificationFilter(VROFilterMode::Linear), _magnificationFilter(VROFilterMode::Linear), _mipFilter(VROFilterMode::Linear) { setNumSubstrates(getNumSubstratesForFormat(internalFormat)); ALLOCATION_TRACKER_ADD(Textures, 1); } VROTexture::VROTexture(VROTextureType type, VROTextureInternalFormat internalFormat, std::unique_ptr<VROTextureSubstrate> substrate, VROStereoMode stereoState) : _textureId(sTextureId++), _type(type), _format(VROTextureFormat::RGBA8), _internalFormat(internalFormat), _stereoMode(stereoState), // Note these parameters are irrelevant for this constructor, since they are used // to generate a substrate, and for this constructor the substrate is already supplied _sRGB(false), _wrapS(VROWrapMode::Clamp), _wrapT(VROWrapMode::Clamp), _minificationFilter(VROFilterMode::Linear), _magnificationFilter(VROFilterMode::Linear), _mipFilter(VROFilterMode::Linear) { _substrates.push_back(std::move(substrate)); ALLOCATION_TRACKER_ADD(Textures, 1); } VROTexture::VROTexture(bool sRGB, VROMipmapMode mipmapMode, std::shared_ptr<VROImage> image, VROStereoMode stereoMode) : _textureId(sTextureId++), _type(VROTextureType::Texture2D), _images( {image} ), _format(image->getFormat()), _internalFormat(image->getInternalFormat()), _width(image->getWidth()), _height(image->getHeight()), _mipmapMode(mipmapMode), _sRGB(sRGB), _stereoMode(stereoMode), _wrapS(VROWrapMode::Clamp), _wrapT(VROWrapMode::Clamp), _minificationFilter(VROFilterMode::Linear), _magnificationFilter(VROFilterMode::Linear), _mipFilter(VROFilterMode::Linear) { setNumSubstrates(getNumSubstratesForFormat(_internalFormat)); ALLOCATION_TRACKER_ADD(Textures, 1); } VROTexture::VROTexture(bool sRGB, std::vector<std::shared_ptr<VROImage>> &images, VROStereoMode stereoMode) : _textureId(sTextureId++), _type(VROTextureType::TextureCube), _images(images), _format(images.front()->getFormat()), _internalFormat(images.front()->getInternalFormat()), _width(images.front()->getWidth()), _height(images.front()->getHeight()), _mipmapMode(VROMipmapMode::None), // No mipmapping for cube textures _sRGB(sRGB), _stereoMode(stereoMode), _wrapS(VROWrapMode::Clamp), _wrapT(VROWrapMode::Clamp), _minificationFilter(VROFilterMode::Linear), _magnificationFilter(VROFilterMode::Linear), _mipFilter(VROFilterMode::Linear) { setNumSubstrates(getNumSubstratesForFormat(_internalFormat)); ALLOCATION_TRACKER_ADD(Textures, 1); } VROTexture::VROTexture(VROTextureType type, VROTextureFormat format, VROTextureInternalFormat internalFormat, bool sRGB, VROMipmapMode mipmapMode, std::vector<std::shared_ptr<VROData>> &data, int width, int height, std::vector<uint32_t> mipSizes, VROStereoMode stereoMode) : _textureId(sTextureId++), _type(type), _data(data), _format(format), _internalFormat(internalFormat), _width(width), _height(height), _mipmapMode(mipmapMode), _mipSizes(mipSizes), _sRGB(sRGB), _stereoMode(stereoMode), _wrapS(VROWrapMode::Clamp), _wrapT(VROWrapMode::Clamp), _minificationFilter(VROFilterMode::Linear), _magnificationFilter(VROFilterMode::Linear), _mipFilter(VROFilterMode::Linear) { setNumSubstrates(getNumSubstratesForFormat(internalFormat)); ALLOCATION_TRACKER_ADD(Textures, 1); } VROTexture::~VROTexture() { ALLOCATION_TRACKER_SUB(Textures, 1); } int VROTexture::getNumSubstrates() const { return (int)_substrates.size(); } void VROTexture::hydrateAsync(std::function<void()> callback, std::shared_ptr<VRODriver> &driver) { if (isHydrated()) { return; } _hydrationCallbacks.push_back(callback); const std::shared_ptr<VROFrameScheduler> &scheduler = driver->getFrameScheduler(); std::string key = getHydrationTaskKey(); if (!scheduler->isTaskQueued(key)) { std::function<void()> hydrationTask = createHydrationTask(driver); scheduler->scheduleTask(key, hydrationTask); } } std::string VROTexture::getHydrationTaskKey() const { return "th_" + VROStringUtil::toString(_textureId); } std::function<void()> VROTexture::createHydrationTask(std::shared_ptr<VRODriver> &driver) { // Only hold weak pointers: we don't want queued hydration // to prolong the lifetime of these objects std::weak_ptr<VRODriver> driver_w = driver; std::weak_ptr<VROTexture> texture_w = shared_from_this(); std::function<void()> hydrationTask = [driver_w, texture_w]() { std::shared_ptr<VROTexture> texture_s = texture_w.lock(); std::shared_ptr<VRODriver> driver_s = driver_w.lock(); if (texture_s && driver_s) { texture_s->hydrate(driver_s); } }; return hydrationTask; } bool VROTexture::isHydrated() const { return _substrates[0] != nullptr; } VROTextureSubstrate *VROTexture::getSubstrate(int index, std::shared_ptr<VRODriver> &driver, bool immediate) { passert (index <= _substrates.size()); if (!_substrates[index]) { // Hydration only works for single-substrate textures. Multi-substrate // textures need to inject the substrates manually via setSubstrate(). passert (index == 0); if (immediate) { hydrate(driver); } else { std::string key = getHydrationTaskKey(); if (!driver->getFrameScheduler()->isTaskQueued(key)) { std::function<void()> hydrationTask = createHydrationTask(driver); driver->getFrameScheduler()->scheduleTask(key, hydrationTask); } } } return _substrates[index].get(); } void VROTexture::setNumSubstrates(int numSubstrates) { _substrates.resize(numSubstrates); } void VROTexture::setSubstrate(int index, std::unique_ptr<VROTextureSubstrate> substrate) { passert_msg(index < _substrates.size(), "Cannot set substrate %d, numSubstrates only %d", index, (int) _substrates.size()); _substrates[index] = std::move(substrate); } void VROTexture::prewarm(std::shared_ptr<VRODriver> driver) { hydrate(driver); } void VROTexture::hydrate(std::shared_ptr<VRODriver> &driver) { passert (_images.empty() || _data.empty()); if (!_images.empty()) { std::vector<std::shared_ptr<VROData>> data; for (std::shared_ptr<VROImage> &image : _images) { passert (image->getFormat() == _format); passert (image->getInternalFormat() == _internalFormat); image->lock(); { size_t length; void *bytes = image->getData(&length); data.push_back(std::make_shared<VROData>(bytes, length, VRODataOwnership::Wrap)); } image->unlock(); } std::vector<uint32_t> mipSizes; _substrates[0] = std::unique_ptr<VROTextureSubstrate>(driver->newTextureSubstrate(_type, _format, _internalFormat, _sRGB, _mipmapMode, data, _width, _height, _mipSizes, _wrapS, _wrapT, _minificationFilter, _magnificationFilter, _mipFilter)); _images.clear(); } else if (!_data.empty()) { _substrates[0] = std::unique_ptr<VROTextureSubstrate>(driver->newTextureSubstrate(_type, _format, _internalFormat, _sRGB, _mipmapMode, _data, _width, _height, _mipSizes, _wrapS, _wrapT, _minificationFilter, _magnificationFilter, _mipFilter)); _data.clear(); } for (auto &callback : _hydrationCallbacks) { callback(); } _hydrationCallbacks.clear(); } int VROTexture::getNumSubstratesForFormat(VROTextureInternalFormat format) const { if (format == VROTextureInternalFormat::YCBCR) { return 2; } else { return 1; } } bool VROTexture::hasAlpha() const { return _format != VROTextureFormat::RGB565 && _format != VROTextureFormat::RGB8; } void VROTexture::setWrapS(VROWrapMode wrapMode) { _wrapS = wrapMode; if (!isHydrated()) { return; } for (int i = 0; i < _substrates.size(); i++) { _substrates[i]->updateWrapMode(wrapMode, _wrapT); } } void VROTexture::setWrapT(VROWrapMode wrapMode) { _wrapT = wrapMode; if (!isHydrated()) { return; } for (int i = 0; i < _substrates.size(); i++) { _substrates[i]->updateWrapMode(_wrapS, wrapMode); } }
789e548980ff0503c3d9d25304dca484fd693a40
0fee103f9ed82978144d9741e46882c7df9eedb1
/Gym/gym-102538/E.cpp
82659083ee219176758b69b0ec778fc54483a3f9
[]
no_license
Flying2019/testgit
2776b6bc3a5839a005726ff108fb69d971065871
86a42bb1d4bfd65b5471373f03162270013da2af
refs/heads/main
2023-07-15T00:57:55.321869
2021-08-21T01:16:53
2021-08-21T01:16:53
302,891,112
0
0
null
null
null
null
UTF-8
C++
false
false
908
cpp
E.cpp
#include<iostream> #include<cstdio> #include<cstring> #define S(l,r) (a[(r)]^a[(l)]) using namespace std; const int N=1000010,M=20; int a[N],f[N][M],_k[M],_2[M]; int main() { int n; scanf("%d",&n); for(int i=1,x;i<=n;i++) scanf("%d",&x),a[x]^=1; for(int i=n;~i;i--) a[i]^=a[i+1]; _k[0]=(1<<M)-1;_2[0]=1; for(int i=1;i<M;i++) _k[i]=_k[i-1]^_2[i-1],_2[i]=_2[i-1]<<1; for(int i=n;~i;i--) for(int j=0;_2[j]<=n;j++) f[i][j]=f[i+_2[j+1]][j]^S(i+_2[j],i+_2[j+1]); for(int i=1;i<=n;i++) { bool z=true; for(int j=0;_2[j]<=i;j++) { int s=0; for(int l=0;l<=n;l+=(i+1)) { int m=min(l+i,n);int r=l+((m-l+1)&_k[j+1])+_2[j+1]; s^=f[l][j]^f[r][j]^S(max(m+1,r-_2[j]),r); } if(s){z=false;break;} } printf("%s ",z?"Bob":"Alice"); } return 0; }
7ce948521530ff473236125e808080c2fa0fb50e
63b780d4f90e6c7c051d516bf380f596809161a1
/FreeEarthSDK/src/FeUtils/TimeUtil.cpp
3c490b8c84788dfa63b1fb7791ac79b417802a43
[]
no_license
hewuhun/OSG
44f4a0665b4a20756303be21e71f0e026e384486
cfea9a84711ed29c0ca0d0bfec633ec41d8b8cec
refs/heads/master
2022-09-05T00:44:54.244525
2020-05-26T14:44:03
2020-05-26T14:44:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,802
cpp
TimeUtil.cpp
#include <sstream> #include <TimeUtil.h> namespace FeUtil { void GetLocalTimeYMDHMS( int& nYear, int& nMonth, int& nDay, int& nHours, int& nMinute, int& nSecond ) { time_t sysTime; time(&sysTime); tm* pLocalTime = localtime(&sysTime); if(pLocalTime) { nYear = pLocalTime->tm_year + 1900; nMonth = pLocalTime->tm_mon + 1; nDay = pLocalTime->tm_mday; nHours = pLocalTime->tm_hour; nMinute = pLocalTime->tm_min; nSecond = pLocalTime->tm_sec; } } void Convert2YMDHMS( time_t t, int& nYear, int& nMonth, int& nDay, int& nHours, int& nMinute, int& nSecond ) { tm* pLocalTime = localtime(&t); if(pLocalTime) { nYear = pLocalTime->tm_year + 1900; nMonth = pLocalTime->tm_mon + 1; nDay = pLocalTime->tm_mday; nHours = pLocalTime->tm_hour; nMinute = pLocalTime->tm_min; nSecond = pLocalTime->tm_sec; } } void GetLocalTimeYMD( int& nYear, int& nMonth, int& nDay ) { int nSecond; int nMinute; int nHours; GetLocalTimeYMDHMS(nYear, nMonth, nDay, nHours, nMinute, nSecond); } void GetLocalTimeHMS( int& nHours, int& nMinute, int& nSecond ) { int nYear; int nMonth; int nDay; GetLocalTimeYMDHMS(nYear, nMonth, nDay, nHours, nMinute, nSecond); } void GetUTCTimeYMDHMS( int& nYear, int& nMonth, int& nDay, int& nHours, int& nMinute, int& nSecond ) { time_t sysTime; time(&sysTime); tm* pLocalTime = gmtime(&sysTime); if(pLocalTime) { nYear = pLocalTime->tm_year; nMonth = pLocalTime->tm_mon; nDay = pLocalTime->tm_mday; nHours = pLocalTime->tm_hour; nMinute = pLocalTime->tm_min; nSecond = pLocalTime->tm_sec; } } void GetUTCTimeYMD( int& nYear, int& nMonth, int& nDay ) { int nSecond; int nMinute; int nHours; GetUTCTimeYMDHMS(nYear, nMonth, nDay, nHours, nMinute, nSecond); } void GetUTCTimeHMS( int& nHours, int& nMinute, int& nSecond ) { int nYear; int nMonth; int nDay; GetUTCTimeYMDHMS(nYear, nMonth, nDay, nHours, nMinute, nSecond); } tm GetLocalTime() { time_t sysTime; time(&sysTime); tm* pLocalTime = localtime(&sysTime); if(pLocalTime) { return *pLocalTime; } return tm(); } tm GetUTCTime() { time_t sysTime; time( &sysTime ); tm* pUTCTime = gmtime(&sysTime); if(pUTCTime) { return *pUTCTime; } return tm(); } tm Local2UTC( tm localTM ) { time_t sysTime = mktime(&localTM); tm* pUTCTime = ::gmtime( &sysTime ); if ( pUTCTime ) { return *pUTCTime; } return tm(); } tm UTC2Local( tm UTCTM ) { time_t sysTime = mktime(&UTCTM); tm* pLocalTime = ::localtime( &sysTime ); if ( pLocalTime ) { return *pLocalTime; } return tm(); } tm DataTime2UTC( int nYear, int nMonth, int nDay, int nHours ) { tm UTCTM = GetUTCTime(); UTCTM.tm_year = nYear; UTCTM.tm_mon = nMonth; UTCTM.tm_mday = nDay; UTCTM.tm_hour = nHours; return UTCTM; } void UTC2DataTime( tm& UTCMT, int& nYear, int& nMonth, int& nDay, int& nHours ) { nYear = UTCMT.tm_year; nMonth = UTCMT.tm_mon ; nDay = UTCMT.tm_mday; nHours = UTCMT.tm_hour; } bool IsAm( int nHours ) { if(nHours >= 0 && nHours < 12) { return true; } return false; } }
db4398d2341795c089d32d7631d08366ea966408
36ad63674e2623b9c4fa8b2b4c167557177ac411
/Headers/GroupClass.h
451057bd293df5b86ca41c914c7ded6b3da8e653
[]
no_license
Gregory06/TimeTableGenerator
791d01619fd0a852e981f98d15cb9952d52c0e7e
d285a97fae463795509b8669129be1a1ac2f4e8c
refs/heads/master
2020-05-19T06:57:29.169974
2019-05-22T19:41:46
2019-05-22T19:41:46
184,886,771
0
0
null
null
null
null
UTF-8
C++
false
false
2,066
h
GroupClass.h
// // Created by Gregory Postnikov on 2019-04-24. // #ifndef TIMETABLE_GROUPCLASS_H #define TIMETABLE_GROUPCLASS_H #include <fstream> #include "EventClass.h" #include "Constants.h" #include "ScheduleClass.h" // ################## // new class // ################## class Group { std::string name; size_t student_number; int64_t available_time; public: Group(std::string name_, size_t student_number_, int64_t current_available_time_, size_t days_in_week, size_t pairs_in_day); size_t GetStudentNumber() const; int64_t GetFeasibleTime() const; std::string GetName() const; void Print() const; void TakeTime(Time time); void ReleaseTime(Time time); }; Group::Group(std::string name_, size_t student_number_, int64_t available_time_, size_t days_in_week, size_t pairs_in_day) : name(name_), student_number(student_number_), available_time(available_time_) {} size_t Group::GetStudentNumber() const { return student_number; } int64_t Group::GetFeasibleTime() const { return available_time; } std::string Group::GetName() const { return name; } void Group::Print() const { std::cout << "##########" << std::endl; std::cout << "### Group " << name << std::endl; std::cout << "### with " << student_number << " students" << std::endl; std::cout << "### and feasible time " << std::bitset<sizeof(available_time) * CHAR_BIT>(available_time) << std::endl; std::cout << "##########" << std::endl; } void Group::TakeTime(const Time time){ size_t index = time.GetIndex(); available_time &= ~(1 << index); } void Group::ReleaseTime(const Time time) { size_t index = time.GetIndex(); available_time |= 1 << index; } bool GroupIntersection(std::vector<Group*> group1,std::vector<Group*> group2) { for (auto i = group1.begin(); i != group1.end(); i++) for (auto j = group2.begin(); j != group2.end(); j++) if ((*i)->GetName() == (*j)->GetName()) return true; return false; } #endif //TIMETABLE_GROUPCLASS_H
43b9575233a35732aaf242f35fca3a14fe4fcace
32e43c3cce09f4659035644e70a4e2e88b021c15
/aoj/grl/apsp.cpp
770748cc647d354cb4114429dfaed44c947df491
[]
no_license
sp4ghet/comp
22c7453bcd4aff56970f3ee465e0c66ca0ab697f
222911d45ab513c88d5450919d8c803cb0f7da1c
refs/heads/master
2020-12-04T15:59:34.368399
2020-09-19T15:00:31
2020-09-19T15:00:31
231,827,088
0
0
null
null
null
null
UTF-8
C++
false
false
1,766
cpp
apsp.cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for (int i = 0; i < n; ++i) #pragma region Debug template <typename T> void view(const std::vector<T> &v) { for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void view(const std::vector<std::vector<T>> &vv) { for (const auto &v : vv) { view(v); } } #pragma endregion #pragma region chminmax template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } #pragma endregion const ll INF = 2e9 + 5; int main() { int v, e; cin >> v >> e; vector<vector<ll>> dp(v, vector<ll>(v, INF)); rep(i, e) { int s, t, d; cin >> s >> t >> d; dp[s][t] = d; } rep(i, v) { dp[i][i] = 0; } // floyd warshall // ワーシャルフロイド rep(k, v) rep(i, v) rep(j, v) { if (dp[i][k] == INF || dp[k][j] == INF) { continue; } chmin(dp[i][j], dp[i][k] + dp[k][j]); } rep(i, v) { if (dp[i][i] < 0) { cout << "NEGATIVE CYCLE" << endl; return 0; } } rep(i, v) { rep(j, v) { if (j > 0) { cout << " "; } if (dp[i][j] == INF) { cout << "INF"; continue; } cout << dp[i][j]; } cout << endl; } return 0; }
2f45ec61b7d7d5ae7acad065370a3675d7b87964
48298469e7d828ab1aa54a419701c23afeeadce1
/Login/Packets/CLAskCharListHandler.cpp
d7410d50e92a5ccd5ded526b29ac13cce1c8fc49
[]
no_license
brock7/TianLong
c39fccb3fd2aa0ad42c9c4183d67a843ab2ce9c2
8142f9ccb118e76a5cd0a8b168bcf25e58e0be8b
refs/heads/master
2021-01-10T14:19:19.850859
2016-02-20T13:58:55
2016-02-20T13:58:55
52,155,393
5
3
null
null
null
null
GB18030
C++
false
false
4,885
cpp
CLAskCharListHandler.cpp
#include "stdafx.h" #include "CLAskCharList.h" #include "LoginPlayer.h" #include "ProcessPlayerManager.h" #include "DBLogicManager.h" #include "TimeManager.h" #include "LCRetCharList.h" #include "DBCharList.h" #include "PacketFactoryManager.h" #include "ProcessManager.h" #include "Log.h" #include "DBThreadManager.h" UINT CLAskCharListHandler::Execute(CLAskCharList* pPacket, Player* pPlayer ) { __ENTER_FUNCTION TID CurrentThreadID = MyGetCurrentThreadID(); //检查线程执行资源是否正确 if(CurrentThreadID == g_pProcessPlayerManager->m_ThreadID) { LoginPlayer* pLoginPlayer = static_cast<LoginPlayer*>(pPlayer); Assert(pLoginPlayer); if( !StrSafeCheck( pPacket->GetAccount(), MAX_ACCOUNT ) ) { Log::SaveLog(LOGIN_LOGFILE, "ERROR: CLAskCharListHandler Get IllegalString,acc = %s", pLoginPlayer->GetAccount()) ; return PACKET_EXE_ERROR; } //检查GUID 是否正确 if(strcmp(pLoginPlayer->GetAccount(),pPacket->GetAccount())!= 0) { Log::SaveLog(LOGIN_LOGFILE, "ERROR: CLAskCharListHandler Get Guid Errors,acc = %s,Packet acc = %s", pLoginPlayer->GetAccount(),pPacket->GetAccount()) ; return PACKET_EXE_ERROR; } UINT uTime = g_pTimeManager->CurrentTime(); if(uTime<pLoginPlayer->m_LastDBOpTime+DB_OPERATION_TIME) { LCRetCharList Msg; Msg.SetResult(ASKCHARLIST_OP_TIMES); pLoginPlayer->SendPacket(&Msg); return PACKET_EXE_CONTINUE; } if(pLoginPlayer->GetPlayerStatus()!=PS_LOGIN_NORMAL) { return PACKET_EXE_CONTINUE; } pPacket->SetPlayerID(pLoginPlayer->PlayerID()); //将玩家操作加入DB 队列 //并且设置最后操作时间 if(g_pDBThreadManager->SendPacket(pPacket,pLoginPlayer->PlayerID())) {//加入成功,将消息发送到DB处理 pLoginPlayer->m_LastDBOpTime = uTime; return PACKET_EXE_NOTREMOVE; } else {//DB 压力过大,让用户重新尝试 LCRetCharList Msg; Msg.SetResult(ASKCHARLIST_SERVER_BUSY); pLoginPlayer->SendPacket(&Msg); pLoginPlayer->m_LastDBOpTime = uTime; return PACKET_EXE_CONTINUE; } } else if(g_pDBThreadManager->IsPoolTID(CurrentThreadID)) { PlayerID_t PlayerID = pPacket->GetPlayerID(); LoginPlayer* pLoginPlayer = static_cast<LoginPlayer*>(pPlayer); Assert(pLoginPlayer); LCRetCharList* pMsg = (LCRetCharList*)g_pPacketFactoryManager->CreatePacket(PACKET_LC_RETCHARLIST) ; if(!pMsg) { //不能进行操作 AssertEx(FALSE,"创建 LCRetCharList 消息失败"); } if(pLoginPlayer->GetDBOperating() == TRUE||!g_pDBThreadManager->GetInterface(CurrentThreadID)->IsConnected()) { pMsg->SetAccount(pPacket->GetAccount()); pMsg->SetResult(ASKCHARLIST_SERVER_BUSY); pMsg->SetCharNumber(0); g_pProcessManager->SendPacket(pMsg,PlayerID); Log::SaveLog(LOGIN_LOGFILE, "CLAskCharListHandler::Execute()....数据库操作冲突 ,Acc = %s", pLoginPlayer->GetAccount()) ; return PACKET_EXE_CONTINUE; } //检查GUID 是否正确 if(strcmp(pLoginPlayer->GetAccount(),pPacket->GetAccount())!= 0) { //应该是一次错误操作 Log::SaveLog(LOGIN_LOGFILE, "ERROR: CLAskCharListHandler DBOperation Errors,acc = %s,Packet acc = %s", pLoginPlayer->GetAccount(),pPacket->GetAccount()) ; return PACKET_EXE_CONTINUE; } pLoginPlayer->SetDBOperating(TRUE); ODBCInterface* pInterface = g_pDBThreadManager->GetInterface(CurrentThreadID); Assert(pInterface); DBCharList CharListObject(pInterface); CharListObject.SetAccount(pPacket->GetAccount()); BOOL bLoadRet = CharListObject.Load(); if(!bLoadRet) { Log::SaveLog(LOGIN_LOGFILE,"CharListObject.Load() ... Get Errors: %s", CharListObject.GetErrorMessage()); pMsg->SetAccount(pPacket->GetAccount()); pMsg->SetResult(ASKCHARLIST_OP_FAILS); pMsg->SetCharNumber(0); g_pProcessManager->SendPacket(pMsg,PlayerID); Log::SaveLog( LOGIN_LOGFILE, "CLAskCharListHandler::Execute()....Fails!,code = ASKCHARLIST_OP_FAILS" ) ; pLoginPlayer->SetDBOperating(FALSE); return PACKET_EXE_CONTINUE; } //取结果 CharListObject.ParseResult(pMsg->GetCharBaseInfo()); //判断是否没有进入过场景 INT iCharNumber = CharListObject.GetCharNumber(); //把参数设置到pMsg pMsg->SetAccount(pPacket->GetAccount()); pMsg->SetResult(ASKCHARLIST_SUCCESS); pMsg->SetCharNumber(iCharNumber); pLoginPlayer->SetCharNumber(iCharNumber); for(INT i=0;i<pLoginPlayer->GetCharNumber();i++) { pLoginPlayer->SetCharGUID(pMsg->GetCharBaseInfo(i)->m_GUID,i); pLoginPlayer->SetPlayerCamp( pMsg->GetCharBaseInfo(i)->m_Camp ); } g_pProcessManager->SendPacket(pMsg,PlayerID); pLoginPlayer->SetDBOperating(FALSE); Log::SaveLog( LOGIN_LOGFILE, "CLAskCharListHandler::Execute()....OK! Acc=%s CharNum=%d", pPacket->GetAccount(), pLoginPlayer->GetCharNumber() ) ; } return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
8d69e46f3cfbc99470776724fd506a86f19b3546
881b7a5a479cfced664277127e4e064463504bd1
/base_nomes.cpp
2517b4a10e76fdb2841c14463dfbc50af0f412f5
[]
no_license
noc1243/TMAB_4
1470fc42c74a9dfdc8ff7359ea8eecef4886232a
fbb5538cb774a32353a08fb6a7a7900b1917c0c2
refs/heads/master
2021-08-26T06:40:14.247573
2017-11-21T22:56:28
2017-11-21T22:56:28
110,855,729
0
0
null
null
null
null
UTF-8
C++
false
false
3,152
cpp
base_nomes.cpp
#include "base_nomes.h" #include <string> using namespace std; const string NOMES[20] = {"Ana", "Arnaldo", "Bruno", "Carlos", "Diogo", "Felipe", "Guilherme", "Heraldo", "Julio", "Katia", "Leonardo", "Marcos", "Maria", "Oscar", "Pedro", "Renata", "Sergio", "Thiago", "Victor", "Wesley"}; const string SOBRENOMES[20] = {"da Silva", "Torres", "Gomes Pereira", "Machado", "Carvalho", "Costa", "Ferreira", "Lima", "Mello", "Miranda", "Santos", "do Valle", "Monteiro", "Nunes", "Teodosio", "Barros", "Ribeiro", "Rodrigues", "Teixeira", "Nascimento"}; const string AREA_DE_CONHECIMENTO[3] = {"Exatas", "Humanas", "Medicas"}; const string CURSOS_EXATAS[3] = {"Engenharia Mecanica", "Engenharia Eletronica", "Matematica"}; const string CURSOS_HUMANAS[3] = {"Direito", "Historia", "Belas Artes"}; const string CURSOS_MEDICAS[3] = {"Medicina", "Enfermagem", "Fisioterapia"}; const string LOCAL_NOMES[5] = {"H-221", "B-147", "D-114", "F-230", "I-146"}; const string DISCIPLINAS_OBRIGATORIAS_EXATAS[3] = {"Calculo III", "Fisica II", "Sistemas Projetivos"}; const string DISCIPLINAS_OBRIGATORIAS_HUMANAS[3] = {"Portugues", "Redacao Basica", "Literatura Basica"}; const string DISCIPLINAS_OBRIGATORIAS_MEDICAS[3] = {"Fisiologia I", "Anatomia II", "Biologia Molecular"}; const string DISCIPLINAS_OPTATIVAS_EXATAS[3] = {"Sistemas Nao-Lineares", "Ciencia dos Materias", "Economia Avancada"}; const string DISCIPLINAS_OPTATIVAS_HUMANAS[3] = {"Frances", "Redacao Avancada", "Literatura Avancada"}; const string DISCIPLINAS_OPTATIVAS_MEDICAS[3] = {"Ecografia I", "Estudo de Medicamentos", "Nutrologia Pediatrica"}; const string DISCIPLINAS_ELETIVAS_EXATAS[3] = {"Redes Neurais", "Motores II", "Quimica Biomolecular"}; const string DISCIPLINAS_ELETIVAS_HUMANAS[3] = {"Historia da Europa", "Desenho Avancado", "Geopolitica Universal"}; const string DISCIPLINAS_ELETIVAS_MEDICAS[3] = {"Oftalmologia Basica", "Cardiologia Basica", "Alergologia Basica"}; const string DISCIPLINAS_EMENTA[3] = {"Ementa: Topicos A B e C", "Ementa: Topicos D E e F", "Ementa: Topicos G H e I"}; const string DISCIPLINAS_BIBLIOGRAFIA[3] = {"LIVRO - BASE 1", "LIVRO - BASE 2", "LIVRO - BASE 3"}; const string DISCIPLINAS_CODIGOS[20] = {"EEL721", "ABF4598", "AJR8496", "JVL2547", "LAQ5647", "QPG5621", "LOP4596", "RTC5899", "QJU6588", "POY3214", "LOA8596", "RTY6852", "CVB5847", "HEF3264", "JNG6958", "KIL1234", "ASD4658", "QWE7981", "ZXC1236", "FGH5896"}; const string PROFESSOR_TITULO[5] = {"Graduado", "Pos-Graduado", "Mestrado", "Doutorado", "Pos_Doutorado"}; const string PROFESSOR_CLASSE[4] = {"Titular", "Associado", "Adjunto", "Assistente"}; const string PROFESSOR_SITE[4] = {"www.pads.ufrj.br/~", "www.smt.ufrj.br/~", "www.coep.ufrj.br/~", "www.labeca.ufrj.br/~"}; const string EXTENSAO[4] = {"Educacao", "Cultura", "Saude", "Tecnologia e Producao"}; const string NOME_TRABALHO[3] = {"Auxilio de Idosos em asilos", "Desenvolvimento de ferramentas para auxilio de recarga de Riocard", "Espanhol basico para criancas"}; const string OBRIGATORIEDADE [3] = {"Obrigatoria", "Optativa", "Eletiva"};
5e488273102d1a7c6bdeb76f08021ad7250c1edc
bfb9caeb27d216883724710f64a9d5f85248e1a2
/project/CHS/LRBHandler.h
12abd465841483cdcb73deff87864b5011d1c42a
[]
no_license
bback99/NFGame
2c0340aa4315ed80aedb85379c32a30d79a1cfcf
e94fb6412271f4f95c200ea4ecab774f506b3877
refs/heads/master
2020-07-02T09:52:24.393478
2016-11-21T01:02:36
2016-11-21T01:02:36
74,312,821
0
0
null
null
null
null
UHC
C++
false
false
6,380
h
LRBHandler.h
// LRBHANDLER.h // #ifndef LRBHANDLER_H #define LRBHANDLER_H #pragma once #include "Common.h" //#include "ADL/MsgLCSCommon2.h" #include "NF/ADL/MsgCHSNGS.h" #include <NF/ADL/MsgCHSNCS.h> #include <NF/ADL/MsgNASCli.h> #ifdef _CHSNLS #include <NLSManager.h> #endif enum { COMPARE_SSN = 1, COMPARE_CATEGORY, COMPARE_GCIID }; enum { ALLSERVER = 0, NCS_MULTI, NCS_ANY, NGS_ANY, BLS_ANY, IBB_ANY, RKS_MULTI, RKS_ANY, PCG_MULTI, MDS_MULTI, NAS_MULTI, NAS_ANY, MAX_ADDR_CNT = 12 }; enum E_REGISTER_MYADDR { CHS_UNI = 0, CHS_MUL, CHS_ANY, RRC_MUL, MDC_MUL, MAX_MYADDR_CNT }; class CLRBHandler : public XLRBHandlerBase { IMPLEMENT_TISAFEREFCNT(CLRBHandler) public: typedef XLRBHandlerBase TBase; public: CLRBHandler(void); virtual ~CLRBHandler(void); BOOL Init(); BOOL GetINIFileAddressInfo(); BOOL GetINIFileFixedRoom(); BOOL RunLRBHandler(); void StopLRBHandler(); BOOL TryServiceRegistToNCS(NSAP & nsapCHS); BOOL SendChannelIDListToNGS(); public: virtual void OnXLRBError(LONG lError); virtual void OnXLRBRegister(LONG lErrorCode, LRBAddress& addr); virtual void OnXLRBRcvMsg(const DWORD dwMID, const LRBAddress& src, const LRBAddress& dest, GBuf& buf, WORD wMessageType, WORD wProtocol); virtual void OnXLRBTerminateNtf(ListAddress& lstAddr); virtual void OnXLRBUnknownEvent(UINT pEvent, LONG lErrorCode, LPXBUF ppXBuf, LRBAddress& srcAddr, LRBAddress& destAddr); public: // src 를 보고 핸들러를 구분한다 void OnRcvNGSMsg(const PayloadInfo& dest, GBuf& buf, WORD wMessageType, WORD wProtocol); void OnRcvNCSMsg(const PayloadInfo& dest, GBuf& buf, WORD wMessageType, WORD wProtocol); void OnRcvIBBMsg(const PayloadInfo& dest, GBuf& buf, WORD wMessageType, WORD wProtocol); void OnRcvNASMsg(const PayloadInfo& dest, GBuf& buf, WORD wMessageType, WORD wProtocol); // send message void MakeAddress(LRBAddress & addr, DWORD dwCastType, DWORD dwCategory); BOOL CheckStartUp() { return m_bLRBStartup; } BOOL RegisterAddress(const LRBAddress& addr); protected: BOOL RegisterAddress(); void OnRcvNGS(const PayloadInfo& dest, GBuf& buf, WORD wMessageType, WORD wProtocol); //from GLS void OnRoomCreateNtf(PayloadNGSCHS & pld, const PayloadInfo & dest); void OnUserRoomLeaveNtf(PayloadNGSCHS & pld); void OnUserRoomJoinNtf(PayloadNGSCHS & pld, const PayloadInfo & dest); void OnRoomDeleteNtf(PayloadNGSCHS & pld) ; void OnRoomStatusChangeNtf(PayloadNGSCHS & pld); void OnUserInfoInRoomChangeNtf(PayloadNGSCHS & pld) ; void OnChangeRoomOptionNtf(PayloadNGSCHS & pld); void OnChangeGameOptionNtf(PayloadNGSCHS & pld); void OnGLSReconnectNtf(PayloadNGSCHS & pld, const PayloadInfo & dest); void OnChangeLoginStateNtf(PayloadNGSCHS & pld); void OnChannelIDListReq(PayloadNGSCHS & pld, const PayloadInfo & dest); void OnGameRoomListAns(PayloadNGSCHS & pld, const PayloadInfo & dest); void OnReqFreeRoomInfo(PayloadNGSCHS & pld, const PayloadInfo & dest); void OnNtfNFFriendAdd(PayloadNGSCHS& pld, const PayloadInfo& dest); void OnNtfNFFriendAccept(PayloadNGSCHS& pld, const PayloadInfo& dest); void OnNtfNFLetterReceive(PayloadNGSCHS& pld, const PayloadInfo& dest); //from NCS void OnRChannelListAns(MsgNCSCHS_RChannelListAns *pPld); void OnGLSInfoAns(MsgNCSCHS_NGSInfoAns *pPld); //void OnFRGLSInfoAns(MsgNCSCHS_FRGLSInfoAns *pPld); void OnRegisterServiceReq(MsgNCSCHS_RegisterServiceReq * pPld, const PayloadInfo & dest); void OnNtfNFFriendAdd(MsgNCSCHS_NtfNFFriendAdd* pPld); void OnNtfNFFriendAccept(MsgNCSCHS_NtfNFFriendAccept* pPld); void OnNtfNFLetterReceive(MsgNCSCHS_NtfNFLetterReceive* pPld); ////from LB NACK void OnRecvNCS_NACK(GBuf & buf); void OnNGSInfoReq_NACK(MsgCHSNCS_NGSInfoReq *pPld); //void OnFRNGSInfoReq_NACK(MsgCHSNCS_FRNGSInfoReq *pPld); void OnRChannelListReq_NACK(MsgCHSNCS_RChannelListReq *pPld); void OnRegisterServiceNtf_NACK(MsgCHSNCS_RegisterServiceNtf * pPld); // from IBB void OnRecvIBB_NACK(GBuf & buf); public: // Send void ConnectorSendTo(GBuf& buf, WORD wProtocol, LRBAddress& SrcAddr, const PayloadInfo& DestAddr); template <class PAYLOADT> BOOL AsyncSend(const PAYLOADT& pld, const LRBAddress* dest) { GBuf buf; if(!BStore(buf, pld)) { LOG(ERR_UK, __FUNCTION__, "Fail to BStore"); return FALSE; } ::XLRBConnectorAsyncSendTo(0, buf, PROTOCOL_LDTP, (LRBAddress*)&m_svrAddr, (LRBAddress*)dest); return TRUE; } // Send GLS void SendToNGS(const PayloadCHSNGS& pld, const PayloadInfo& dest); void SendToPCCNGS(const PayloadCHSNGS& pld, const PayloadInfo& dest); void SendToAllPCCNGS(const PayloadCHSNGS& pld); // Send ELB void SendToNCS(const PayloadCHSNCS& pld, const PayloadInfo& dest); void SendToNCS(const PayloadCHSNCS& pld); void SendToAllNCS(const PayloadCHSNCS& pld); // Send RealRanking void SendToRKS(const LRBAddress& src, const LRBAddress& dest, GBuf& buf); void SendToODBGW(const LRBAddress& dest, GBuf& buf); void SendToBMS(const LRBAddress& dest, GBuf& buf); // Send LCS void SendToNLS(const PayloadCLINLS& pld, const PayloadInfo& dest); void SendToNLS(const LRBAddress& src, const PayloadInfo& dest, PayloadCLINLS& pld); void SendToEchoMsg(); // Send NAS void SendToNAS(const PayloadCLINAS& pld, const PayloadInfo& dest); void SendToNAS(const PayloadCLINAS& pld); void SendToAllNAS(const PayloadCLINAS& pld); // LRBAddress & GetMyAddress() { return m_svrAddr; } /// for LCS const LRBAddress& GetNLSAddr() const { return m_NLSMulticastAddr; } void SetNLSAddr(const LRBAddress& addr) { TLock lo(this); m_NLSMulticastAddr = addr; } ///////////////////////////////////////////////////// private: BOOL m_bRegistered; DWORD m_dwServiceTypeID; // 자신이 지정해야 하는 서비스 타입 id LRBAddress m_svrAddr; // 서버 단위 주소 LRBAddress m_svcAddr[MAX_ADDR_CNT]; // send 대상, MULTI , ANYCAST 를 위한 주소 LRBAddress m_svcMyAddr[MAX_MYADDR_CNT]; // recv를 위해 LrB에 등록해야 할 Address BOOL m_bLRBStartup; BOOL m_bIsFixedRoom; // FixedRoom 체크하기 위한 값 /// for LCS LRBAddress m_NLSMulticastAddr; public: protected: LRBMessageCnt m_MsgCount; }; extern CLRBHandler theLRBHandler; #endif
5b1d33dbf197cb43bd3aac5c3f95d54fa44873a6
4d9196e969dfa33dcbd2f6d93e3ee03da1364717
/OOP (CSE165)/Lab 07/Object/Object/Object.h
794c945a03b7e5fc4eb9d63dac77bd9c593bbe8b
[]
no_license
Lyph/CSE
55515df96e7804c25bea8478e62ebff5dd692ece
e30a61872da31229de0f7083b3aa4f7869bf5939
refs/heads/master
2016-09-14T13:05:44.571808
2016-04-23T20:24:50
2016-04-23T20:24:50
56,939,107
0
2
null
null
null
null
UTF-8
C++
false
false
180
h
Object.h
#ifndef DEFAULT_H #define DEFAULT_H using namespace std; class Object { public: static int count; Object() { count++; } Object(const Object &i) { count++; } }; #endif
3b1eef8b75ad69b6ca2e2fad79f337e4eeb70c90
02b585fa38233f564ccf236e08c0c36e35c13050
/TP3ProgJeux/character.cpp
5ae5226aca5d6e8898bb3f6ff6c786262e1547e6
[]
no_license
titoine9912/TP3ProgJeux
ff2805fa7df08516f10e54a1eee0b9f95a54d440
3d01347a658e962052dcf644d94b980fdf8968a8
refs/heads/master
2021-08-31T11:08:37.418032
2017-12-21T07:50:30
2017-12-21T07:50:30
111,834,306
0
0
null
null
null
null
UTF-8
C++
false
false
107
cpp
character.cpp
#include "character.h" character::character(Vector2f position, float speed) :movable(position,speed) { }
412764d4948558fcfc811868a156e6dd0c3b0641
7d4e2934f8bcb873e1a9655450dc5f39fd736d5a
/Truss/GridParam.h
c8148fa4b0eb9b271463ee23bc50b9b87d9b2492
[]
no_license
mwck46/FEM_Basics
bb6b519a7ef34fed66948dcdbb49751cf896dff5
23cb8ae54baf3d4dbfae24657f92e483e5c4e97a
refs/heads/master
2022-03-29T21:29:06.919766
2019-12-29T06:00:29
2019-12-29T06:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
866
h
GridParam.h
#pragma once #include <boost/numeric/ublas/matrix.hpp> typedef boost::numeric::ublas::vector<double> vector_d; typedef boost::numeric::ublas::vector<int> vector_i; typedef boost::numeric::ublas::matrix<double> matrix_d; typedef boost::numeric::ublas::matrix<int> matrix_i; class GridParam { public: GridParam() : nnd(0), nel(0), nne(0), nodof(0), eldof(0), n(0) {} int nnd; // Number of nodes int nel; // Number of elements int nne; // Number of nodes per element int nodof; // Number of degrees of freedom per node matrix_d geom; // Nodes coord. (X,Y) matrix_i connec; // Element connectivity matrix_d prop; // Geometrical properties matrix_i nf; // Degree of freedom matrix_d load; // load at node int eldof; // Number of degrees of freedom per element (size of local stiffness matrix) int n; // Number of unknown in global stiffness matrix };
0e5847fb1e9675d6b59fa606bcf37f039c5b3a26
f5f30e0190341e3fb203e3daff053dd6d0014adc
/CEN425 Labs/Lab - 3/main_d.cpp
308fb4777418e6d7ced7724c1c9393819500ecaa
[]
no_license
janFrancoo/ARMmbed
53cc0fa5afeb9d4a941bade7e1b5c13f5241d3a2
c3e46fc40f444e19d27e4c11e5dfd20bb945c0a7
refs/heads/master
2020-12-05T16:06:17.249672
2020-02-22T06:22:25
2020-02-22T06:22:25
232,167,102
0
0
null
null
null
null
UTF-8
C++
false
false
291
cpp
main_d.cpp
#include "mbed.h" DigitalOut gled(PG_13); DigitalOut rled(PG_14); InterruptIn button(PA_0); Timeout chron; void chron_ISR() { rled = !rled; } void button_ISR() { chron.attach(&chron_ISR, 5); } int main(){ rled = 0; button.rise(&button_ISR); gled = 1; while(1); }
91592027cf97e720ff33dd66301b552f4a60c3f3
e8b06ddf3c7c23f5e80e56075b02de75b6506a44
/packages/Meshfree/test/tstDetailsCommunicationHelpers.cpp
64f79ba469d179661c13a00c2a82880575192f56
[ "BSD-3-Clause", "LicenseRef-scancode-free-unknown" ]
permissive
ORNL-CEES/DataTransferKit
e65e8b89bd68e400363d04ef8b3499451ed106ae
60a4cbd0a55505e0450f1ac979e1eef8966dc03f
refs/heads/master
2023-08-26T13:11:30.588519
2023-08-24T12:54:10
2023-08-24T12:54:10
25,265,743
54
27
BSD-3-Clause
2023-08-17T22:49:41
2014-10-15T17:35:07
C++
UTF-8
C++
false
false
10,124
cpp
tstDetailsCommunicationHelpers.cpp
/**************************************************************************** * Copyright (c) 2012-2020 by the DataTransferKit authors * * All rights reserved. * * * * This file is part of the DataTransferKit library. DataTransferKit is * * distributed under a BSD 3-clause license. For the licensing terms see * * the LICENSE file in the top-level directory. * * * * SPDX-License-Identifier: BSD-3-Clause * ****************************************************************************/ #include <ArborX.hpp> #include <DTK_DetailsNearestNeighborOperatorImpl.hpp> // fetch #include <Teuchos_Array.hpp> #include <Teuchos_UnitTestHarness.hpp> template < typename View, typename std::enable_if< std::is_same< typename View::traits::memory_space, typename View::traits::host_mirror_space::memory_space>::value, int>::type = 0> Teuchos::ArrayView<typename View::const_value_type> toArray( View const &v ) { return Teuchos::ArrayView<typename View::const_value_type>( v.data(), v.size() ); } template < typename View, typename std::enable_if< !std::is_same< typename View::traits::memory_space, typename View::traits::host_mirror_space::memory_space>::value, int>::type = 0> Teuchos::Array<typename View::non_const_value_type> toArray( View const &v ) { auto v_h = Kokkos::create_mirror_view( v ); Kokkos::deep_copy( v_h, v ); return Teuchos::Array<typename View::non_const_value_type>( Teuchos::ArrayView<typename View::const_value_type>( v_h.data(), v_h.size() ) ); } // NOTE Shameless hack to get DeviceType from test driver because I don't want // to deduce it template <typename DeviceType> struct Helper { template <typename View1, typename View2> static void checkSendAcrossNetwork( MPI_Comm comm, View1 const &ranks, View2 const &v_exp, View2 const &v_ref, bool &success, Teuchos::FancyOStream &out ) { ArborX::Details::Distributor<DeviceType> distributor( comm ); distributor.createFromSends( typename DeviceType::execution_space{}, ranks ); // NOTE here we assume that the reference solution is sized properly auto v_imp = Kokkos::create_mirror( typename View2::memory_space(), v_ref ); ArborX::Details::DistributedTreeImpl<DeviceType>::sendAcrossNetwork( typename DeviceType::execution_space{}, distributor, v_exp, v_imp ); // FIXME not sure why I need that guy but I do get a bus error when it // is not here... Kokkos::fence(); TEST_COMPARE_ARRAYS( toArray( v_imp ), toArray( v_ref ) ); } template <typename View1, typename View2> static void checkFetch( MPI_Comm comm, View1 const &ranks, View1 const &indices, View2 const &v_exp, View2 const &v_ref, bool &success, Teuchos::FancyOStream &out ) { auto v_imp = DataTransferKit::Details::NearestNeighborOperatorImpl< DeviceType>::fetch( comm, ranks, indices, v_exp ); TEST_COMPARE_ARRAYS( toArray( v_imp ), toArray( v_ref ) ); } }; TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( DetailsDistributedTreeImpl, send_across_network, DeviceType ) { using ExecutionSpace = typename DeviceType::execution_space; MPI_Comm comm = MPI_COMM_WORLD; int comm_rank; MPI_Comm_rank( comm, &comm_rank ); int comm_size; MPI_Comm_size( comm, &comm_size ); int const DIM = 3; // send 1 packet to rank k // receive comm_size packets Kokkos::View<int **, DeviceType> u_exp( "u_exp", comm_size, DIM ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size ), KOKKOS_LAMBDA( int i ) { for ( int j = 0; j < DIM; ++j ) u_exp( i, j ) = i + j * comm_rank; } ); Kokkos::fence(); Kokkos::View<int *, DeviceType> ranks_u( "", comm_size ); ArborX::iota( ExecutionSpace{}, ranks_u, 0 ); Kokkos::View<int **, DeviceType> u_ref( "u_ref", comm_size, DIM ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size ), KOKKOS_LAMBDA( int i ) { for ( int j = 0; j < DIM; ++j ) u_ref( i, j ) = comm_rank + i * j; } ); Kokkos::fence(); Helper<DeviceType>::checkSendAcrossNetwork( comm, ranks_u, u_exp, u_ref, success, out ); // send k packets to rank k // receive k*comm_size packets Kokkos::View<int *, DeviceType> tn( "tn", comm_size + 1 ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size + 1 ), KOKKOS_LAMBDA( int i ) { tn( i ) = ( i * ( i - 1 ) ) / 2; } ); Kokkos::fence(); Kokkos::View<int **, DeviceType> v_exp( "v_exp", ArborX::lastElement( tn ), DIM ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size ), KOKKOS_LAMBDA( int i ) { for ( int j = tn( i ); j < tn( i + 1 ); ++j ) for ( int k = 0; k < DIM; ++k ) v_exp( j, k ) = i * k; } ); Kokkos::fence(); Kokkos::View<int *, DeviceType> ranks_v( "", ArborX::lastElement( tn ) ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size ), KOKKOS_LAMBDA( int i ) { for ( int j = tn( i ); j < tn( i + 1 ); ++j ) ranks_v( j ) = i; } ); Kokkos::fence(); Kokkos::View<int **, DeviceType> v_ref( "v_ref", comm_size * comm_rank, DIM ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size * comm_rank ), KOKKOS_LAMBDA( int i ) { for ( int j = 0; j < DIM; ++j ) v_ref( i, j ) = j * comm_rank; } ); Kokkos::fence(); Helper<DeviceType>::checkSendAcrossNetwork( comm, ranks_v, v_exp, v_ref, success, out ); } TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( DetailsNearestNeighborOperatorImpl, fetch, DeviceType ) { using ExecutionSpace = typename DeviceType::execution_space; MPI_Comm comm = MPI_COMM_WORLD; int comm_rank; MPI_Comm_rank( comm, &comm_rank ); int comm_size; MPI_Comm_size( comm, &comm_size ); // make communicaton plan Kokkos::View<int *, DeviceType> indices( "indices", comm_size ); Kokkos::View<int *, DeviceType> ranks( "ranks", comm_size ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size ), KOKKOS_LAMBDA( int i ) { indices( i ) = ( comm_rank + i ) % comm_size; ranks( i ) = comm_size - 1 - comm_rank; } ); Kokkos::fence(); // v(i) <-- k*comm_size+i (index i, rank k) Kokkos::View<int *, DeviceType> v_exp( "v", comm_size ); ArborX::iota( ExecutionSpace{}, v_exp, comm_rank * comm_size ); Kokkos::View<int *, DeviceType> v_ref( "v_ref", comm_size ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size ), KOKKOS_LAMBDA( int i ) { v_ref( i ) = ranks( i ) * comm_size + indices( i ); } ); Kokkos::fence(); Helper<DeviceType>::checkFetch( comm, ranks, indices, v_exp, v_ref, success, out ); // w(i, j) <-- k*comm_size*DIM+i+j*comm_size (index i, index j, rank k) int const DIM = 2; Kokkos::View<int **, DeviceType> w_exp( "w", comm_size, DIM ); for ( int i = 0; i < DIM; ++i ) ArborX::iota( ExecutionSpace{}, Kokkos::subview( w_exp, Kokkos::ALL, i ), i * comm_size + comm_rank * comm_size * DIM ); Kokkos::View<int **, DeviceType> w_ref( "w_ref", comm_size, DIM ); Kokkos::parallel_for( Kokkos::RangePolicy<ExecutionSpace>( 0, comm_size ), KOKKOS_LAMBDA( int i ) { for ( int j = 0; j < DIM; ++j ) w_ref( i, j ) = ranks( i ) * comm_size * DIM + indices( i ) + j * comm_size; } ); Kokkos::fence(); Helper<DeviceType>::checkFetch( comm, ranks, indices, w_exp, w_ref, success, out ); } // Include the test macros. #include "DataTransferKit_ETIHelperMacros.h" // Create the test group #define UNIT_TEST_GROUP( NODE ) \ using DeviceType##NODE = typename NODE::device_type; \ TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \ DetailsDistributedTreeImpl, send_across_network, DeviceType##NODE ) \ TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DetailsNearestNeighborOperatorImpl, \ fetch, DeviceType##NODE ) // Demangle the types DTK_ETI_MANGLING_TYPEDEFS() // Instantiate the tests DTK_INSTANTIATE_N( UNIT_TEST_GROUP )
627cb8859cfe18f9ba6f4fc6d857f240ca412d38
c56d936079690d586366f8f3967c7b9bfb4b4f7d
/src/gridbuilder.h
5b8eaa8946c0bdd2af90472d4bfc19508be2ec02
[ "Apache-2.0" ]
permissive
jeanpierrethach/FreeFlow-Grid-Solver-
22746882b0f46050edc616f84939a6c1b1436c25
5cbfd8350c42e740a24fe7ce945edd391334c378
refs/heads/master
2021-01-11T02:30:31.787638
2016-12-17T03:57:26
2016-12-17T03:57:26
70,955,195
2
0
null
null
null
null
UTF-8
C++
false
false
1,253
h
gridbuilder.h
#ifndef GRIDBUILDER_H #define GRIDBUILDER_H #include "grid.h" //Used for random number generation #include <cstdlib> #include <iostream> #include <ctime> #include <QPoint> #include <QDebug> class GridBuilder { public: static Grid* buildGrid(int row, int col); GridBuilder(); static int getRandomNumberFrom0To(int max); private: static int currentColor; static Grid* buildGrid(Grid*, int, int); static void clearPaths(Grid*); static void destroyAdjacentPathMatrix(int**, int); static QPoint* getRandomFreeBlock(Grid*); static QPoint* findXAdjacentFreeBlocks(Grid*, int x, int** adjacentPathMatrix); static QPoint* findLoneBlock(Grid*, int** adjacentPathMatrix); static QPoint* findDeadEnd(Grid*, int** adjacentPathMatrix); static void buildPathStartingPoint(QPoint*, Grid*); static void buildPath(QPoint*, Grid*); static int numberOfFreeAdjacentPositions(QPoint*, Grid*); static QPoint* getRandomAdjacentFreeBlock(QPoint* pos, Grid* grid); static bool moveAdjacentEndPoint(QPoint* pos, Grid* grid); static QPoint* findPairOfLoneBlocks(Grid*, int** adjacentPathMatrix); static void fillAdjacentPathMatrix(Grid*, int** adjacentPathMatrix); }; #endif // GRIDBUILDER_H
8d443795717f9cf3d8c36afb691136240229726a
97528ffe2960a8bc122eca00016cde2056f37054
/preorder_iter.cpp
0b1187d232aaf9283615426e18a01b7622bf8a54
[]
no_license
aravind-kumar/Coding
f5875161a2129fb8e2528da9ace42438282ee81b
d71438058fd39fe4bc7d642bd4b5d11333bfe848
refs/heads/master
2021-10-26T02:47:14.293087
2019-04-09T23:56:28
2019-04-09T23:56:28
71,275,972
0
0
null
2018-05-18T06:18:35
2016-10-18T17:55:38
C++
UTF-8
C++
false
false
656
cpp
preorder_iter.cpp
class Solution { public: vector<int> preorderTraversal(TreeNode* root) { vector<int> result; stack<TreeNode*> stackNodes; while(root != nullptr || !stackNodes.empty()) { if(root != nullptr) { result.push_back(root->val); stackNodes.push(root); root = root->left; } else { while(root == nullptr && !stackNodes.empty()) { root = stackNodes.top(); stackNodes.pop(); } root = root->right; } } return result; } };
d5eedd3206e47360c141b8ca3d457e97748cc890
bd91a68c3ed8072ae292191b50bea3349b2f55bc
/ASTNodes/ForStatement.cpp
f3574cbe5d168b2e18d2244d237944d037912565
[ "MIT" ]
permissive
jonathan-beard/Raft
0e28d5ea72e840441b2f42f46b45ec2f5b08371e
6b2c250c915b5ce1db84277e6e5722977e8ebbba
refs/heads/master
2021-01-17T05:24:36.314552
2019-04-23T16:03:09
2019-04-23T16:03:09
8,226,622
6
1
null
null
null
null
UTF-8
C++
false
false
348
cpp
ForStatement.cpp
/** * ForStatement.cpp - * @author: Jonathan Beard * @version: Sat Feb 15 09:23:35 2014 */ #include "ForStatement.hpp" using namespace Node; ForStatement::ForStatement() : Statement( "ForStatement" ) { class_tree.addRelation( typeid( Node::Statement ).hash_code(), typeid( Node::ForStatement ).hash_code() ); }
c0425b47b143fa789da40831da65698c914e8e2b
745da8c56c393c962c8289e92b2ede875dcef7b0
/quickSort.h
e34561dc8a1ed6050946bc6f6c9cc27318bb3d05
[ "MIT" ]
permissive
chansiky/Cpp-Sorting
a7426458e1bcad3f8ec440850c6207614a825d75
76bbd4c06a8b069640dc20cecfdf20ef4255028b
refs/heads/master
2021-01-23T07:09:39.641228
2017-04-02T00:31:12
2017-04-02T00:31:12
86,415,974
0
0
null
null
null
null
UTF-8
C++
false
false
952
h
quickSort.h
#pragma once #include <vector> #include <random> #include <time.h> #include "swap.h" #include <queue> ///quickSort Wrapper template<typename _T> void quickSort(std::vector<_T> &v_T); ///quickSort Algorithm template<typename _T> void quickSortFull(std::vector<_T> &vT,typename std::vector<_T>::iterator indL,typename std::vector<_T>::iterator indR); ///quickSort partitioning template<typename _T> int partition(std::vector<_T> &vT,typename std::vector<_T>::iterator l, typename std::vector<_T>::iterator r); ///selects a random pivot int selectPivot(int L, int R); ///selects the median of three pivot template<typename _T> int selectPivot(std::vector<_T> &vT,typename std::vector<_T>::iterator l,typename std::vector<_T>::iterator r); ///subroutine for selecting pivot: check for finding out if a pivot is the lesser of the two; template<typename _T> bool checkIfMid(_T L, _T M, _T R); #include "quickSort.cpp"
5dde4fa568a1bc8e786fd6f0923c1ebea9961e5a
6389c1f38baf105b01ca1320b2cebae78c08b6a1
/Source Code/StdInfoPage.h
53e4587b6049d34220f852e06fa7ad40f7819b4c
[]
no_license
changpian8/Home-of-Dandelion-Management-Software
6d161bed22120a5dfc589aeff8d17fa3bad4a9d7
1908c43404b3abec342606b59fc77fcc603e28ad
refs/heads/master
2021-04-21T23:47:25.493962
2020-03-15T19:53:47
2020-03-15T19:53:47
249,828,058
0
1
null
2020-03-24T22:04:54
2020-03-24T22:04:54
null
GB18030
C++
false
false
41,399
h
StdInfoPage.h
#pragma once #include <Windows.h> #include "SharedParm.h" #include "Transcript.h" #include "AddNewGrade.h" #include "AddNewRecord.h" #include "ChangeRecordPage.h" namespace ManagementSoftware { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for StdInfoPage /// </summary> public ref class StdInfoPage : public System::Windows::Forms::Form { public: StdInfoPage(String^ InputStdId) { InitializeComponent(); // //TODO: Add the constructor code here // ID = InputStdId; Initialize(); } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~StdInfoPage() { if (components) { delete components; } } private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Button^ ChangeInfo; private: System::Windows::Forms::Splitter^ splitter1; private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::Label^ StdId; private: System::Windows::Forms::Label^ label4; private: System::Windows::Forms::Label^ StdName; private: System::Windows::Forms::Label^ label6; private: System::Windows::Forms::Label^ StdGender; private: System::Windows::Forms::Label^ label8; private: System::Windows::Forms::Label^ StdAttribution; private: System::Windows::Forms::Label^ label10; private: System::Windows::Forms::Label^ StdLeader; private: System::Windows::Forms::Label^ label12; private: System::Windows::Forms::Label^ StdLeaderPhone; private: System::Windows::Forms::Label^ label14; private: System::Windows::Forms::Label^ StdPhone; private: System::Windows::Forms::Label^ label16; private: System::Windows::Forms::Label^ StdAltPhone; private: System::Windows::Forms::Label^ label18; private: System::Windows::Forms::RichTextBox^ StdAddress; private: System::Windows::Forms::Button^ DeleteInfo; private: System::Windows::Forms::Button^ AddGrade; private: System::Windows::Forms::Button^ AddRecord; private: System::Windows::Forms::Label^ label3; private: System::Windows::Forms::Splitter^ splitter2; private: System::Windows::Forms::Label^ label5; private: System::Windows::Forms::DataGridView^ dataGridView1; private: System::Windows::Forms::Splitter^ splitter3; private: System::Windows::Forms::Label^ label7; private: System::Windows::Forms::DataGridView^ dataGridView2; private: System::Windows::Forms::Label^ label9; private: System::Windows::Forms::Label^ label11; private: System::Windows::Forms::Label^ label13; private: System::Windows::Forms::Label^ label15; private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::TextBox^ textBox2; private: System::Windows::Forms::TextBox^ textBox3; private: System::Windows::Forms::TextBox^ textBox4; private: System::Windows::Forms::TextBox^ textBox5; private: System::Windows::Forms::TextBox^ textBox6; private: System::Windows::Forms::TextBox^ textBox7; private: System::Windows::Forms::RichTextBox^ richTextBox1; private: System::Windows::Forms::Button^ AcceptButton; private: System::Windows::Forms::Button^ CancelButton; private: System::Windows::Forms::Label^ label17; private: System::Windows::Forms::Button^ DeleteAcceptButton; private: System::Windows::Forms::Button^ DeleteCancelButton; private: System::Windows::Forms::Label^ label19; private: System::Windows::Forms::Label^ StfName; private: System::Windows::Forms::TextBox^ InputStfName; private: System::Windows::Forms::TextBox^ InputStdId; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->label1 = (gcnew System::Windows::Forms::Label()); this->ChangeInfo = (gcnew System::Windows::Forms::Button()); this->splitter1 = (gcnew System::Windows::Forms::Splitter()); this->label2 = (gcnew System::Windows::Forms::Label()); this->StdId = (gcnew System::Windows::Forms::Label()); this->label4 = (gcnew System::Windows::Forms::Label()); this->StdName = (gcnew System::Windows::Forms::Label()); this->label6 = (gcnew System::Windows::Forms::Label()); this->StdGender = (gcnew System::Windows::Forms::Label()); this->label8 = (gcnew System::Windows::Forms::Label()); this->StdAttribution = (gcnew System::Windows::Forms::Label()); this->label10 = (gcnew System::Windows::Forms::Label()); this->StdLeader = (gcnew System::Windows::Forms::Label()); this->label12 = (gcnew System::Windows::Forms::Label()); this->StdLeaderPhone = (gcnew System::Windows::Forms::Label()); this->label14 = (gcnew System::Windows::Forms::Label()); this->StdPhone = (gcnew System::Windows::Forms::Label()); this->label16 = (gcnew System::Windows::Forms::Label()); this->StdAltPhone = (gcnew System::Windows::Forms::Label()); this->label18 = (gcnew System::Windows::Forms::Label()); this->StdAddress = (gcnew System::Windows::Forms::RichTextBox()); this->DeleteInfo = (gcnew System::Windows::Forms::Button()); this->AddGrade = (gcnew System::Windows::Forms::Button()); this->AddRecord = (gcnew System::Windows::Forms::Button()); this->label3 = (gcnew System::Windows::Forms::Label()); this->splitter2 = (gcnew System::Windows::Forms::Splitter()); this->label5 = (gcnew System::Windows::Forms::Label()); this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView()); this->splitter3 = (gcnew System::Windows::Forms::Splitter()); this->label7 = (gcnew System::Windows::Forms::Label()); this->dataGridView2 = (gcnew System::Windows::Forms::DataGridView()); this->label9 = (gcnew System::Windows::Forms::Label()); this->label11 = (gcnew System::Windows::Forms::Label()); this->label13 = (gcnew System::Windows::Forms::Label()); this->label15 = (gcnew System::Windows::Forms::Label()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->textBox2 = (gcnew System::Windows::Forms::TextBox()); this->textBox3 = (gcnew System::Windows::Forms::TextBox()); this->textBox4 = (gcnew System::Windows::Forms::TextBox()); this->textBox5 = (gcnew System::Windows::Forms::TextBox()); this->textBox6 = (gcnew System::Windows::Forms::TextBox()); this->textBox7 = (gcnew System::Windows::Forms::TextBox()); this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox()); this->AcceptButton = (gcnew System::Windows::Forms::Button()); this->CancelButton = (gcnew System::Windows::Forms::Button()); this->label17 = (gcnew System::Windows::Forms::Label()); this->DeleteAcceptButton = (gcnew System::Windows::Forms::Button()); this->DeleteCancelButton = (gcnew System::Windows::Forms::Button()); this->label19 = (gcnew System::Windows::Forms::Label()); this->StfName = (gcnew System::Windows::Forms::Label()); this->InputStfName = (gcnew System::Windows::Forms::TextBox()); this->InputStdId = (gcnew System::Windows::Forms::TextBox()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView2))->BeginInit(); this->SuspendLayout(); // // label1 // this->label1->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label1->AutoSize = true; this->label1->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label1->Font = (gcnew System::Drawing::Font(L"SimSun", 15, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label1->Location = System::Drawing::Point(425, 40); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(168, 25); this->label1->TabIndex = 0; this->label1->Text = L"学生信息详情"; // // ChangeInfo // this->ChangeInfo->Anchor = System::Windows::Forms::AnchorStyles::Top; this->ChangeInfo->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->ChangeInfo->Location = System::Drawing::Point(649, 261); this->ChangeInfo->Name = L"ChangeInfo"; this->ChangeInfo->Size = System::Drawing::Size(143, 42); this->ChangeInfo->TabIndex = 1; this->ChangeInfo->TabStop = false; this->ChangeInfo->Text = L"编辑个人信息"; this->ChangeInfo->UseVisualStyleBackColor = true; this->ChangeInfo->Click += gcnew System::EventHandler(this, &StdInfoPage::ChangeInfo_Click); // // splitter1 // this->splitter1->BackColor = System::Drawing::SystemColors::ActiveCaption; this->splitter1->Dock = System::Windows::Forms::DockStyle::Top; this->splitter1->Enabled = false; this->splitter1->Location = System::Drawing::Point(0, 0); this->splitter1->MinimumSize = System::Drawing::Size(0, 370); this->splitter1->Name = L"splitter1"; this->splitter1->Size = System::Drawing::Size(1031, 370); this->splitter1->TabIndex = 2; this->splitter1->TabStop = false; // // label2 // this->label2->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label2->AutoSize = true; this->label2->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label2->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label2->Location = System::Drawing::Point(645, 109); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(80, 17); this->label2->TabIndex = 3; this->label2->Text = L"学生编号"; // // StdId // this->StdId->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdId->AutoSize = true; this->StdId->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StdId->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdId->Location = System::Drawing::Point(766, 106); this->StdId->Name = L"StdId"; this->StdId->Size = System::Drawing::Size(20, 20); this->StdId->TabIndex = 4; this->StdId->Text = L"-"; // // label4 // this->label4->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label4->AutoSize = true; this->label4->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label4->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label4->Location = System::Drawing::Point(53, 108); this->label4->Name = L"label4"; this->label4->Size = System::Drawing::Size(44, 17); this->label4->TabIndex = 5; this->label4->Text = L"姓名"; // // StdName // this->StdName->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdName->AutoSize = true; this->StdName->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StdName->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdName->Location = System::Drawing::Point(156, 105); this->StdName->Name = L"StdName"; this->StdName->Size = System::Drawing::Size(20, 20); this->StdName->TabIndex = 6; this->StdName->Text = L"-"; // // label6 // this->label6->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label6->AutoSize = true; this->label6->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label6->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label6->Location = System::Drawing::Point(331, 108); this->label6->Name = L"label6"; this->label6->Size = System::Drawing::Size(44, 17); this->label6->TabIndex = 7; this->label6->Text = L"性别"; // // StdGender // this->StdGender->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdGender->AutoSize = true; this->StdGender->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StdGender->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdGender->Location = System::Drawing::Point(470, 105); this->StdGender->Name = L"StdGender"; this->StdGender->Size = System::Drawing::Size(20, 20); this->StdGender->TabIndex = 8; this->StdGender->Text = L"-"; // // label8 // this->label8->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label8->AutoSize = true; this->label8->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label8->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label8->Location = System::Drawing::Point(53, 159); this->label8->Name = L"label8"; this->label8->Size = System::Drawing::Size(80, 17); this->label8->TabIndex = 9; this->label8->Text = L"所属堂区"; // // StdAttribution // this->StdAttribution->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdAttribution->AutoSize = true; this->StdAttribution->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StdAttribution->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdAttribution->Location = System::Drawing::Point(156, 157); this->StdAttribution->Name = L"StdAttribution"; this->StdAttribution->Size = System::Drawing::Size(20, 20); this->StdAttribution->TabIndex = 10; this->StdAttribution->Text = L"-"; // // label10 // this->label10->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label10->AutoSize = true; this->label10->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label10->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label10->Location = System::Drawing::Point(331, 159); this->label10->Name = L"label10"; this->label10->Size = System::Drawing::Size(62, 17); this->label10->TabIndex = 11; this->label10->Text = L"负责人"; // // StdLeader // this->StdLeader->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdLeader->AutoSize = true; this->StdLeader->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StdLeader->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdLeader->Location = System::Drawing::Point(470, 159); this->StdLeader->Name = L"StdLeader"; this->StdLeader->Size = System::Drawing::Size(20, 20); this->StdLeader->TabIndex = 12; this->StdLeader->Text = L"-"; // // label12 // this->label12->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label12->AutoSize = true; this->label12->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label12->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label12->Location = System::Drawing::Point(645, 158); this->label12->Name = L"label12"; this->label12->Size = System::Drawing::Size(98, 17); this->label12->TabIndex = 13; this->label12->Text = L"负责人电话"; // // StdLeaderPhone // this->StdLeaderPhone->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdLeaderPhone->AutoSize = true; this->StdLeaderPhone->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StdLeaderPhone->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdLeaderPhone->Location = System::Drawing::Point(766, 160); this->StdLeaderPhone->Name = L"StdLeaderPhone"; this->StdLeaderPhone->Size = System::Drawing::Size(20, 20); this->StdLeaderPhone->TabIndex = 14; this->StdLeaderPhone->Text = L"-"; // // label14 // this->label14->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label14->AutoSize = true; this->label14->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label14->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label14->Location = System::Drawing::Point(53, 209); this->label14->Name = L"label14"; this->label14->Size = System::Drawing::Size(80, 17); this->label14->TabIndex = 15; this->label14->Text = L"联系方式"; // // StdPhone // this->StdPhone->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdPhone->AutoSize = true; this->StdPhone->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StdPhone->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdPhone->Location = System::Drawing::Point(156, 206); this->StdPhone->Name = L"StdPhone"; this->StdPhone->Size = System::Drawing::Size(20, 20); this->StdPhone->TabIndex = 16; this->StdPhone->Text = L"-"; // // label16 // this->label16->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label16->AutoSize = true; this->label16->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label16->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label16->Location = System::Drawing::Point(331, 209); this->label16->Name = L"label16"; this->label16->Size = System::Drawing::Size(116, 17); this->label16->TabIndex = 17; this->label16->Text = L"其他联系方式"; // // StdAltPhone // this->StdAltPhone->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdAltPhone->AutoSize = true; this->StdAltPhone->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StdAltPhone->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdAltPhone->Location = System::Drawing::Point(470, 207); this->StdAltPhone->Name = L"StdAltPhone"; this->StdAltPhone->Size = System::Drawing::Size(20, 20); this->StdAltPhone->TabIndex = 18; this->StdAltPhone->Text = L"-"; // // label18 // this->label18->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label18->AutoSize = true; this->label18->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label18->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label18->Location = System::Drawing::Point(53, 264); this->label18->Name = L"label18"; this->label18->Size = System::Drawing::Size(80, 17); this->label18->TabIndex = 19; this->label18->Text = L"家庭住址"; // // StdAddress // this->StdAddress->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StdAddress->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StdAddress->Location = System::Drawing::Point(160, 264); this->StdAddress->Name = L"StdAddress"; this->StdAddress->ReadOnly = true; this->StdAddress->Size = System::Drawing::Size(453, 88); this->StdAddress->TabIndex = 20; this->StdAddress->Text = L""; // // DeleteInfo // this->DeleteInfo->Anchor = System::Windows::Forms::AnchorStyles::Top; this->DeleteInfo->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->DeleteInfo->Location = System::Drawing::Point(821, 261); this->DeleteInfo->Name = L"DeleteInfo"; this->DeleteInfo->Size = System::Drawing::Size(143, 42); this->DeleteInfo->TabIndex = 21; this->DeleteInfo->TabStop = false; this->DeleteInfo->Text = L"删除学生档案"; this->DeleteInfo->UseVisualStyleBackColor = true; this->DeleteInfo->Click += gcnew System::EventHandler(this, &StdInfoPage::DeleteInfo_Click); // // AddGrade // this->AddGrade->Anchor = System::Windows::Forms::AnchorStyles::Top; this->AddGrade->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->AddGrade->Location = System::Drawing::Point(649, 309); this->AddGrade->Name = L"AddGrade"; this->AddGrade->Size = System::Drawing::Size(143, 43); this->AddGrade->TabIndex = 22; this->AddGrade->TabStop = false; this->AddGrade->Text = L"新增成绩信息"; this->AddGrade->UseVisualStyleBackColor = true; this->AddGrade->Click += gcnew System::EventHandler(this, &StdInfoPage::AddGrade_Click); // // AddRecord // this->AddRecord->Anchor = System::Windows::Forms::AnchorStyles::Top; this->AddRecord->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->AddRecord->Location = System::Drawing::Point(821, 309); this->AddRecord->Name = L"AddRecord"; this->AddRecord->Size = System::Drawing::Size(143, 43); this->AddRecord->TabIndex = 23; this->AddRecord->TabStop = false; this->AddRecord->Text = L"新增牧灵记录"; this->AddRecord->UseVisualStyleBackColor = true; this->AddRecord->Click += gcnew System::EventHandler(this, &StdInfoPage::AddRecord_Click); // // label3 // this->label3->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label3->AutoSize = true; this->label3->Font = (gcnew System::Drawing::Font(L"SimSun", 20, System::Drawing::FontStyle::Bold)); this->label3->ForeColor = System::Drawing::Color::Red; this->label3->Location = System::Drawing::Point(166, 287); this->label3->Name = L"label3"; this->label3->Size = System::Drawing::Size(330, 34); this->label3->TabIndex = 24; this->label3->Text = L"读取失败,错误码:"; this->label3->Visible = false; // // splitter2 // this->splitter2->BackColor = System::Drawing::SystemColors::GradientActiveCaption; this->splitter2->Dock = System::Windows::Forms::DockStyle::Top; this->splitter2->Enabled = false; this->splitter2->Location = System::Drawing::Point(0, 370); this->splitter2->MinimumSize = System::Drawing::Size(0, 50); this->splitter2->Name = L"splitter2"; this->splitter2->Size = System::Drawing::Size(1031, 50); this->splitter2->TabIndex = 25; this->splitter2->TabStop = false; // // label5 // this->label5->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label5->AutoSize = true; this->label5->BackColor = System::Drawing::SystemColors::GradientActiveCaption; this->label5->Font = (gcnew System::Drawing::Font(L"SimSun", 13, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label5->Location = System::Drawing::Point(447, 384); this->label5->Name = L"label5"; this->label5->Size = System::Drawing::Size(102, 22); this->label5->TabIndex = 26; this->label5->Text = L"成绩详情"; // // dataGridView1 // this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; this->dataGridView1->Dock = System::Windows::Forms::DockStyle::Top; this->dataGridView1->Location = System::Drawing::Point(0, 420); this->dataGridView1->Name = L"dataGridView1"; this->dataGridView1->RowHeadersWidth = 51; this->dataGridView1->RowTemplate->Height = 27; this->dataGridView1->Size = System::Drawing::Size(1031, 172); this->dataGridView1->TabIndex = 27; this->dataGridView1->CellDoubleClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &StdInfoPage::dataGridView1_CellDoubleClick); // // splitter3 // this->splitter3->BackColor = System::Drawing::SystemColors::GradientActiveCaption; this->splitter3->Dock = System::Windows::Forms::DockStyle::Top; this->splitter3->Enabled = false; this->splitter3->Location = System::Drawing::Point(0, 592); this->splitter3->MinimumSize = System::Drawing::Size(0, 50); this->splitter3->Name = L"splitter3"; this->splitter3->Size = System::Drawing::Size(1031, 50); this->splitter3->TabIndex = 28; this->splitter3->TabStop = false; // // label7 // this->label7->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label7->AutoSize = true; this->label7->BackColor = System::Drawing::SystemColors::GradientActiveCaption; this->label7->Font = (gcnew System::Drawing::Font(L"SimSun", 13, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label7->Location = System::Drawing::Point(426, 607); this->label7->Name = L"label7"; this->label7->Size = System::Drawing::Size(148, 22); this->label7->TabIndex = 29; this->label7->Text = L"中心牧灵记录"; // // dataGridView2 // this->dataGridView2->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; this->dataGridView2->Dock = System::Windows::Forms::DockStyle::Fill; this->dataGridView2->Location = System::Drawing::Point(0, 642); this->dataGridView2->Name = L"dataGridView2"; this->dataGridView2->RowHeadersWidth = 51; this->dataGridView2->RowTemplate->Height = 27; this->dataGridView2->Size = System::Drawing::Size(1031, 198); this->dataGridView2->TabIndex = 30; this->dataGridView2->CellDoubleClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &StdInfoPage::dataGridView2_CellDoubleClick); // // label9 // this->label9->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label9->AutoSize = true; this->label9->Font = (gcnew System::Drawing::Font(L"SimSun", 20, System::Drawing::FontStyle::Bold)); this->label9->ForeColor = System::Drawing::Color::Red; this->label9->Location = System::Drawing::Point(348, 486); this->label9->Name = L"label9"; this->label9->Size = System::Drawing::Size(330, 34); this->label9->TabIndex = 31; this->label9->Text = L"读取失败,错误码:"; this->label9->Visible = false; // // label11 // this->label11->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label11->AutoSize = true; this->label11->Font = (gcnew System::Drawing::Font(L"SimSun", 20, System::Drawing::FontStyle::Bold)); this->label11->ForeColor = System::Drawing::Color::Red; this->label11->Location = System::Drawing::Point(348, 721); this->label11->Name = L"label11"; this->label11->Size = System::Drawing::Size(330, 34); this->label11->TabIndex = 32; this->label11->Text = L"读取失败,错误码:"; this->label11->Visible = false; // // label13 // this->label13->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label13->AutoSize = true; this->label13->Font = (gcnew System::Drawing::Font(L"SimSun", 20, System::Drawing::FontStyle::Bold)); this->label13->ForeColor = System::Drawing::Color::Red; this->label13->Location = System::Drawing::Point(373, 537); this->label13->Name = L"label13"; this->label13->Size = System::Drawing::Size(260, 34); this->label13->TabIndex = 33; this->label13->Text = L"未找到匹配信息"; this->label13->Visible = false; // // label15 // this->label15->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label15->AutoSize = true; this->label15->Font = (gcnew System::Drawing::Font(L"SimSun", 20, System::Drawing::FontStyle::Bold)); this->label15->ForeColor = System::Drawing::Color::Red; this->label15->Location = System::Drawing::Point(373, 782); this->label15->Name = L"label15"; this->label15->Size = System::Drawing::Size(260, 34); this->label15->TabIndex = 34; this->label15->Text = L"未找到匹配信息"; this->label15->Visible = false; // // textBox1 // this->textBox1->Anchor = System::Windows::Forms::AnchorStyles::Top; this->textBox1->Location = System::Drawing::Point(160, 100); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(144, 25); this->textBox1->TabIndex = 35; this->textBox1->Visible = false; // // textBox2 // this->textBox2->Anchor = System::Windows::Forms::AnchorStyles::Top; this->textBox2->Location = System::Drawing::Point(474, 100); this->textBox2->Name = L"textBox2"; this->textBox2->Size = System::Drawing::Size(139, 25); this->textBox2->TabIndex = 36; this->textBox2->Visible = false; // // textBox3 // this->textBox3->Anchor = System::Windows::Forms::AnchorStyles::Top; this->textBox3->Location = System::Drawing::Point(160, 155); this->textBox3->Name = L"textBox3"; this->textBox3->Size = System::Drawing::Size(144, 25); this->textBox3->TabIndex = 37; this->textBox3->Visible = false; // // textBox4 // this->textBox4->Anchor = System::Windows::Forms::AnchorStyles::Top; this->textBox4->Location = System::Drawing::Point(474, 152); this->textBox4->Name = L"textBox4"; this->textBox4->Size = System::Drawing::Size(139, 25); this->textBox4->TabIndex = 38; this->textBox4->Visible = false; // // textBox5 // this->textBox5->Anchor = System::Windows::Forms::AnchorStyles::Top; this->textBox5->Location = System::Drawing::Point(770, 152); this->textBox5->Name = L"textBox5"; this->textBox5->Size = System::Drawing::Size(156, 25); this->textBox5->TabIndex = 39; this->textBox5->Visible = false; // // textBox6 // this->textBox6->Anchor = System::Windows::Forms::AnchorStyles::Top; this->textBox6->Location = System::Drawing::Point(160, 206); this->textBox6->Name = L"textBox6"; this->textBox6->Size = System::Drawing::Size(144, 25); this->textBox6->TabIndex = 40; this->textBox6->Visible = false; // // textBox7 // this->textBox7->Anchor = System::Windows::Forms::AnchorStyles::Top; this->textBox7->Location = System::Drawing::Point(474, 206); this->textBox7->Name = L"textBox7"; this->textBox7->Size = System::Drawing::Size(139, 25); this->textBox7->TabIndex = 41; this->textBox7->Visible = false; // // richTextBox1 // this->richTextBox1->Anchor = System::Windows::Forms::AnchorStyles::Top; this->richTextBox1->Location = System::Drawing::Point(160, 264); this->richTextBox1->Name = L"richTextBox1"; this->richTextBox1->Size = System::Drawing::Size(453, 88); this->richTextBox1->TabIndex = 42; this->richTextBox1->Text = L""; this->richTextBox1->Visible = false; // // AcceptButton // this->AcceptButton->Anchor = System::Windows::Forms::AnchorStyles::Top; this->AcceptButton->Font = (gcnew System::Drawing::Font(L"SimSun", 11, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->AcceptButton->Location = System::Drawing::Point(649, 261); this->AcceptButton->Name = L"AcceptButton"; this->AcceptButton->Size = System::Drawing::Size(144, 91); this->AcceptButton->TabIndex = 43; this->AcceptButton->Text = L"确认"; this->AcceptButton->UseVisualStyleBackColor = true; this->AcceptButton->Visible = false; this->AcceptButton->Click += gcnew System::EventHandler(this, &StdInfoPage::AcceptButton_Click); // // CancelButton // this->CancelButton->Anchor = System::Windows::Forms::AnchorStyles::Top; this->CancelButton->Font = (gcnew System::Drawing::Font(L"SimSun", 11, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->CancelButton->Location = System::Drawing::Point(821, 261); this->CancelButton->Name = L"CancelButton"; this->CancelButton->Size = System::Drawing::Size(143, 91); this->CancelButton->TabIndex = 44; this->CancelButton->Text = L"取消"; this->CancelButton->UseVisualStyleBackColor = true; this->CancelButton->Visible = false; this->CancelButton->Click += gcnew System::EventHandler(this, &StdInfoPage::CancelButton_Click); // // label17 // this->label17->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label17->AutoSize = true; this->label17->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label17->Font = (gcnew System::Drawing::Font(L"SimSun", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label17->ForeColor = System::Drawing::Color::Red; this->label17->Location = System::Drawing::Point(647, 237); this->label17->Name = L"label17"; this->label17->Size = System::Drawing::Size(70, 15); this->label17->TabIndex = 45; this->label17->Text = L"label17"; this->label17->Visible = false; // // DeleteAcceptButton // this->DeleteAcceptButton->Anchor = System::Windows::Forms::AnchorStyles::Top; this->DeleteAcceptButton->Font = (gcnew System::Drawing::Font(L"SimSun", 11, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->DeleteAcceptButton->ForeColor = System::Drawing::Color::Red; this->DeleteAcceptButton->Location = System::Drawing::Point(649, 261); this->DeleteAcceptButton->Name = L"DeleteAcceptButton"; this->DeleteAcceptButton->Size = System::Drawing::Size(144, 91); this->DeleteAcceptButton->TabIndex = 46; this->DeleteAcceptButton->Text = L"确认删除"; this->DeleteAcceptButton->UseVisualStyleBackColor = true; this->DeleteAcceptButton->Visible = false; this->DeleteAcceptButton->Click += gcnew System::EventHandler(this, &StdInfoPage::DeleteAcceptButton_Click); // // DeleteCancelButton // this->DeleteCancelButton->Anchor = System::Windows::Forms::AnchorStyles::Top; this->DeleteCancelButton->Font = (gcnew System::Drawing::Font(L"SimSun", 11, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->DeleteCancelButton->Location = System::Drawing::Point(821, 261); this->DeleteCancelButton->Name = L"DeleteCancelButton"; this->DeleteCancelButton->Size = System::Drawing::Size(143, 91); this->DeleteCancelButton->TabIndex = 47; this->DeleteCancelButton->Text = L"取消"; this->DeleteCancelButton->UseVisualStyleBackColor = true; this->DeleteCancelButton->Visible = false; this->DeleteCancelButton->Click += gcnew System::EventHandler(this, &StdInfoPage::DeleteCancelButton_Click); // // label19 // this->label19->Anchor = System::Windows::Forms::AnchorStyles::Top; this->label19->AutoSize = true; this->label19->BackColor = System::Drawing::SystemColors::ActiveCaption; this->label19->Font = (gcnew System::Drawing::Font(L"SimSun", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->label19->Location = System::Drawing::Point(645, 209); this->label19->Name = L"label19"; this->label19->Size = System::Drawing::Size(80, 17); this->label19->TabIndex = 48; this->label19->Text = L"负责员工"; // // StfName // this->StfName->Anchor = System::Windows::Forms::AnchorStyles::Top; this->StfName->AutoSize = true; this->StfName->BackColor = System::Drawing::SystemColors::ActiveCaption; this->StfName->Font = (gcnew System::Drawing::Font(L"SimSun", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(134))); this->StfName->Location = System::Drawing::Point(766, 206); this->StfName->Name = L"StfName"; this->StfName->Size = System::Drawing::Size(19, 20); this->StfName->TabIndex = 49; this->StfName->Text = L"-"; // // InputStfName // this->InputStfName->Anchor = System::Windows::Forms::AnchorStyles::Top; this->InputStfName->Location = System::Drawing::Point(770, 206); this->InputStfName->Name = L"InputStfName"; this->InputStfName->Size = System::Drawing::Size(156, 25); this->InputStfName->TabIndex = 50; this->InputStfName->Visible = false; // // InputStdId // this->InputStdId->Location = System::Drawing::Point(770, 100); this->InputStdId->Name = L"InputStdId"; this->InputStdId->Size = System::Drawing::Size(156, 25); this->InputStdId->TabIndex = 37; this->InputStdId->Visible = false; // // StdInfoPage // this->AutoScaleDimensions = System::Drawing::SizeF(8, 15); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(1031, 840); this->Controls->Add(this->InputStdId); this->Controls->Add(this->InputStfName); this->Controls->Add(this->StfName); this->Controls->Add(this->label19); this->Controls->Add(this->DeleteCancelButton); this->Controls->Add(this->DeleteAcceptButton); this->Controls->Add(this->label17); this->Controls->Add(this->CancelButton); this->Controls->Add(this->AcceptButton); this->Controls->Add(this->richTextBox1); this->Controls->Add(this->textBox7); this->Controls->Add(this->textBox6); this->Controls->Add(this->textBox5); this->Controls->Add(this->textBox4); this->Controls->Add(this->textBox3); this->Controls->Add(this->textBox2); this->Controls->Add(this->textBox1); this->Controls->Add(this->label11); this->Controls->Add(this->label15); this->Controls->Add(this->label13); this->Controls->Add(this->label9); this->Controls->Add(this->dataGridView2); this->Controls->Add(this->label7); this->Controls->Add(this->splitter3); this->Controls->Add(this->dataGridView1); this->Controls->Add(this->label5); this->Controls->Add(this->splitter2); this->Controls->Add(this->label3); this->Controls->Add(this->AddRecord); this->Controls->Add(this->AddGrade); this->Controls->Add(this->DeleteInfo); this->Controls->Add(this->StdAddress); this->Controls->Add(this->label18); this->Controls->Add(this->StdAltPhone); this->Controls->Add(this->label16); this->Controls->Add(this->StdPhone); this->Controls->Add(this->label14); this->Controls->Add(this->StdLeaderPhone); this->Controls->Add(this->label12); this->Controls->Add(this->StdLeader); this->Controls->Add(this->label10); this->Controls->Add(this->StdAttribution); this->Controls->Add(this->label8); this->Controls->Add(this->StdGender); this->Controls->Add(this->label6); this->Controls->Add(this->StdName); this->Controls->Add(this->label4); this->Controls->Add(this->StdId); this->Controls->Add(this->label2); this->Controls->Add(this->ChangeInfo); this->Controls->Add(this->label1); this->Controls->Add(this->splitter1); this->Name = L"StdInfoPage"; this->Text = L"学生信息详情"; (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView2))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: String^ ID; String^ STF_ID; Void Initialize(); Void UpdateInfo(); Void UpdateGrade(); Void UpdateRecord(); Void UpdateStaffName(); String^ CheckStaff(); Void ChangeInfo_Click(System::Object^ sender, System::EventArgs^ e); Void AcceptButton_Click(System::Object^ sender, System::EventArgs^ e); Void CancelButton_Click(System::Object^ sender, System::EventArgs^ e); Void DeleteInfo_Click(System::Object^ sender, System::EventArgs^ e); Void AddGrade_Click(System::Object^ sender, System::EventArgs^ e); Void AddRecord_Click(System::Object^ sender, System::EventArgs^ e); Void DeleteAcceptButton_Click(System::Object^ sender, System::EventArgs^ e); Void DeleteCancelButton_Click(System::Object^ sender, System::EventArgs^ e); Void dataGridView1_CellDoubleClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e); Void dataGridView2_CellDoubleClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e); }; }
81693a29fa1f307110bbe2fb0c192d8429369d01
46bac44cc58214aec9dc8880a00b542437ed382f
/algo_list/double_list_acces_rand_vs_linear.cpp
fa1c920d9b79a646fc4b91a4874aa9e14efe9c59
[ "MIT" ]
permissive
knupel/Algorithm-cpp
773b013137e3a198e48e1115ed541289344222f2
6a0801b5202ed0272b67f555f487841d7c2af14a
refs/heads/master
2023-01-07T21:26:37.209590
2020-11-02T13:59:24
2020-11-02T13:59:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,639
cpp
double_list_acces_rand_vs_linear.cpp
#include <iostream> #include <vector> #include <map> #include <random> #include <time.h> #include <chrono> void linear_loop_vector(std::vector<float> &list_a, std::vector<float> &list_b, int dist_max, bool pertinent); void random_loop_vector(std::vector<float> &list_a ,std::vector<float> &list_b, int dist_max, bool pertinent); void build_list_vec(std::vector<float> &list_a, std::vector<float> &list_b, std::default_random_engine &generator, int num, int min, int max); int main() { int num = 1000; int dist_max = 1; int pos_min = -100; int pos_max = 100; std::vector<float> list_vec_a; std::vector<float> list_vec_b; std::random_device seed; std::default_random_engine generator(seed()); build_list_vec(list_vec_a, list_vec_b, generator, num, pos_min, pos_max); std::cout << "\ncount all vector succes: " << std::endl; linear_loop_vector(list_vec_a, list_vec_b, dist_max, false); random_loop_vector(list_vec_a, list_vec_b, dist_max,false); std::cout << "\nstop at first vector success: " << std::endl; linear_loop_vector(list_vec_a, list_vec_b, dist_max, true); random_loop_vector(list_vec_a, list_vec_b, dist_max, true); } void build_list_vec(std::vector<float> &list_a, std::vector<float> &list_b, std::default_random_engine &generator, int num, int min, int max) { auto start = std::chrono::system_clock::now(); for(int i = 0 ; i < num ; i++) { std::uniform_real_distribution<float> gen_rand_float(min,max); float val_a = gen_rand_float(generator); float val_b = gen_rand_float(generator); list_a.push_back(val_a); list_b.push_back(val_b); } auto end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end-start; std::cout << "build vector list in: " << elapsed_seconds.count() << std::endl; } /** * vector loop */ void random_loop_vector(std::vector<float> &list_a ,std::vector<float> &list_b, int dist_max, bool pertinent) { int bingo = 0; int iteration = 0; int max_iter = list_a.size() * list_b.size(); auto start = std::chrono::system_clock::now(); std::random_device seed; std::default_random_engine generator(seed()); std::uniform_int_distribution<int> gen_rand_int(0,list_a.size() - 1); for(int i = 0 ; i < max_iter ; i++) { iteration++; int index_a = gen_rand_int(generator); int index_b = gen_rand_int(generator); float a = list_a.at(index_a); float b = list_b.at(index_b); float dist = abs(a - b); if(dist < dist_max) { bingo++; if(pertinent) { break; } } } auto end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end-start; std::cout << "random loop in: " << elapsed_seconds.count() << std::endl; std::cout << "bingo: " << bingo << std::endl; std::cout << "iteration: " << iteration << std::endl; } void linear_loop_vector(std::vector<float> &list_a, std::vector<float> &list_b, int dist_max, bool pertinent) { bool succes_is = false; int bingo = 0; int iteration = 0; auto start = std::chrono::system_clock::now(); for(int i = 0 ; i < list_a.size() ; i++) { iteration++; for(int k = 0 ; k < list_b.size() ; k++) { iteration++; float a = list_a.at(i); float b = list_b.at(k); float dist = abs(a - b); if(dist < dist_max) { succes_is = true; bingo++; if(pertinent) { break; } } } if(succes_is && pertinent) break; } auto end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end-start; std::cout << "linear loop in: " << elapsed_seconds.count() << std::endl; std::cout << "bingo: " << bingo << std::endl; std::cout << "iteration: " << iteration << std::endl; }
f986331a0853630a471838c3307d8997ab509c4a
012784e8de35581e1929306503439bb355be4c4f
/problems/77/p1.cc
7c32eedd097518a593a2097197c6e39b6ce2c68a
[]
no_license
silenke/my-leetcode
7502057c9394e41ddeb2e7fd6c1b8261661639e0
d24ef0970785c547709b1d3c7228e7d8b98b1f06
refs/heads/master
2023-06-05T02:05:48.674311
2021-07-01T16:18:29
2021-07-01T16:18:29
331,948,127
0
0
null
null
null
null
UTF-8
C++
false
false
685
cc
p1.cc
#include "..\..\leetcode.h" class Solution { public: vector<vector<int>> combine(int n, int k) { vector<int> c(k); vector<vector<int>> res; dfs(n, k, 0, 1, c, res); return res; } private: void dfs(int n, int k, int i, int j, vector<int>& c, vector<vector<int>>&res) { // 已经生成序列c,将要在位置i放置[j,n]中的数字 if (i == k) { res.emplace_back(c); return; } int max = n + 1 - k + i; // [m,n]可用的个数 >= 需要的个数k-i; for (int m = j; m <= max; m++) { c[i] = m; dfs(n, k, i + 1, m + 1, c, res); } } };
466f5d1f51cbbfb038c08eb45f8627eabe288f7d
4e38faaa2dc1d03375010fd90ad1d24322ed60a7
/include/RED4ext/Scripting/Natives/Generated/user/SettingsVarListFloat.hpp
330e669699765bfaa330d7e2459014dd24340c4c
[ "MIT" ]
permissive
WopsS/RED4ext.SDK
0a1caef8a4f957417ce8fb2fdbd821d24b3b9255
3a41c61f6d6f050545ab62681fb72f1efd276536
refs/heads/master
2023-08-31T08:21:07.310498
2023-08-18T20:51:18
2023-08-18T20:51:18
324,193,986
68
25
MIT
2023-08-18T20:51:20
2020-12-24T16:17:20
C++
UTF-8
C++
false
false
662
hpp
SettingsVarListFloat.hpp
#pragma once // clang-format off // This file is generated from the Game's Reflection data #include <cstdint> #include <RED4ext/Common.hpp> #include <RED4ext/Scripting/Natives/Generated/user/SettingsVar.hpp> namespace RED4ext { namespace user { struct SettingsVarListFloat : user::SettingsVar { static constexpr const char* NAME = "userSettingsVarListFloat"; static constexpr const char* ALIAS = "ConfigVarListFloat"; }; RED4EXT_ASSERT_SIZE(SettingsVarListFloat, 0x48); } // namespace user using userSettingsVarListFloat = user::SettingsVarListFloat; using ConfigVarListFloat = user::SettingsVarListFloat; } // namespace RED4ext // clang-format on
d72989f79ae9d9d3c84161fb8ad94dfd921fd04a
61b9402bc77ffd55a171398ea97e0a8fe2d45c82
/hannuota.cpp
cfbe6e90f59393bfba12506825f48ea6a7775d3c
[]
no_license
hiki-yukino/c-
0fcf9f42a4e4e86d2ddff0c901a19a4fb342ba74
67c5bdd78a4c8a6864787df9a5b2a446db441241
refs/heads/main
2023-03-12T23:42:15.845978
2021-03-02T02:56:42
2021-03-02T02:56:42
340,545,359
1
0
null
null
null
null
GB18030
C++
false
false
2,114
cpp
hannuota.cpp
#define CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> static int count = 0; void move(char getone, char putone) { count++; //盘子的移动次数 从getone 到 putone printf("%c-->%c\n", getone, putone); // 打印每次移动盘子的动作 } void hanoit(int n, char a, char b, char c) { if (n == 1) { move(a, c); //只需移动一次 } else { hanoit(n - 1, a, c, b); //始终让空柱子为最后的目标柱子 printf("count :%d\n", count); // 打印从n、n-1、n-2....2每次的移动次数 move(a, c); // 打印每次移动盘子的动作 hanoit(n - 1, b, a, c); //让下一级的三个柱子上依旧按顺序分布 2(剩下的一所有) 1/代表最上层的那个盘子 0/目标柱子 回到最初 } } int main() { int m; scanf_s("%d", &m); hanoit(m, 'A', 'B', 'C'); printf("count :%d", count); //system("pause"); return 0; } //void move(char getone, char putone) { // printf("%c-->%c\n", getone, putone); //} // //void hanoit(int n, char a, char b, char c) { // if (n == 1) { // move(a, c); // } // else { // hanoit(n - 1, a, c, b); // move(a, c); // hanoit(n - 1, b, a, c); // } // //} // //int main() { // int m; // // scanf_s("%d", &m); // hanoit(m, 'A', 'B', 'C'); // // system("pause"); // return 0; //} //int hannuota(int n) //{ // int count = 0; // int a = n; // int b = 0; // int c = 0; // int i = 0; // if (n==1) // { // // return 1; // } // else // { // for (i = n; i>=2; i--) // { // hannuota(n-1); // // // } // return hannuota(n); // } //} // // //int main() //{ //汉诺塔问题 递归求解 // n个盘子 3个柱子 // 最下层+n-1 // 1+1+n-2 // int n = 0; // int ret = 0; // scanf_s("%d", &n); // // ret=hannuota(n); // // printf("%d\n",ret); // // return 0; //}
e646a05529f0b6e7c9b1cc183e1b143e077c886a
da1500e0d3040497614d5327d2461a22e934b4d8
/cobalt/renderer/egl_and_gles.h
fdf1839138f3d625a7ec693056f2df58d0927d84
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
youtube/cobalt
34085fc93972ebe05b988b15410e99845efd1968
acefdaaadd3ef46f10f63d1acae2259e4024d383
refs/heads/main
2023-09-01T13:09:47.225174
2023-09-01T08:54:54
2023-09-01T08:54:54
50,049,789
169
80
BSD-3-Clause
2023-09-14T21:50:50
2016-01-20T18:11:34
null
UTF-8
C++
false
false
45,205
h
egl_and_gles.h
// Copyright 2019 The Cobalt 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. #ifndef COBALT_RENDERER_EGL_AND_GLES_H_ #define COBALT_RENDERER_EGL_AND_GLES_H_ #include "base/logging.h" #include "starboard/common/log.h" #include "starboard/configuration.h" #include "starboard/egl.h" #include "starboard/gles.h" #define EGL_CALL_PREFIX ::cobalt::renderer::CobaltGetEglInterface(). #define GL_CALL_PREFIX ::cobalt::renderer::CobaltGetGlesInterface(). #if SB_DCHECK_ENABLED #define EGL_DCHECK(x) \ do { \ const int32_t COBALT_EGL_ERRNO = (EGL_CALL_PREFIX eglGetError()); \ SB_DCHECK(COBALT_EGL_ERRNO == EGL_SUCCESS) \ << #x << " exited with code: " << COBALT_EGL_ERRNO; \ } while (false) #define GL_DCHECK(x) \ do { \ const int32_t COBALT_GL_ERRNO = (GL_CALL_PREFIX glGetError()); \ SB_DCHECK(COBALT_GL_ERRNO == GL_NO_ERROR) \ << #x << " exited with code: " << COBALT_GL_ERRNO; \ } while (false) #else #define EGL_DCHECK(x) #define GL_DCHECK(x) #endif // SB_DCHECK_ENABLED namespace cobalt { namespace renderer { inline const SbEglInterface& CobaltGetEglInterface() { static const SbEglInterface* egl_interface = SbGetEglInterface(); return *egl_interface; } inline const SbGlesInterface& CobaltGetGlesInterface() { static const SbGlesInterface* gles_interface = SbGetGlesInterface(); return *gles_interface; } } // namespace renderer } // namespace cobalt // The following *_CALL, *_CALL_SIMPLE macros provide a mechanism to // transparently use the Starboard OpenGL ES and EGL interfaces if available, // while also providing error-checking. The *_CALL macros should be used when // the return value of the function to invoke is not desired, otherwise use // *_CALL_SIMPLE to propagate the returned value. For example: // // eglMakeCurrent(...) becomes EGL_CALL(eglMakeCurrent(...)). // ... = eglGetError() becomes ... = EGL_CALL_SIMPLE(eglGetError()). #define EGL_CALL(x) \ do { \ EGL_CALL_PREFIX x; \ EGL_DCHECK(x); \ } while (false) #define GL_CALL(x) \ do { \ GL_CALL_PREFIX x; \ GL_DCHECK(x); \ } while (false) #define EGL_CALL_SIMPLE(x) (EGL_CALL_PREFIX x) #define GL_CALL_SIMPLE(x) (GL_CALL_PREFIX x) // EGL TYPES #define EGLint SbEglInt32 #define EGLNativeDisplayType SbEglNativeDisplayType #define EGLNativePixmapType SbEglNativePixmapType #define EGLNativeWindowType SbEglNativeWindowType #define __eglMustCastToProperFunctionPointerType \ SbEglCastsToProperFunctionPointerType #define EGLAttrib SbEglAttrib #define EGLBoolean SbEglBoolean #define EGLClientBuffer SbEglClientBuffer #define EGLConfig SbEglConfig #define EGLContext SbEglContext #define EGLDisplay SbEglDisplay #define EGLenum SbEglEnum #define EGLImage SbEglImage #define EGLSurface SbEglSurface #define EGLSync SbEglSync #define EGLTime SbEglTime // GL TYPES #define GLboolean SbGlBoolean #define GLbitfield SbGlBitfield #define GLchar SbGlChar #define GLclampf SbGlClampf #define GLenum SbGlEnum #define GLfixed SbGlFixed #define GLfloat SbGlFloat #define GLbyte SbGlByte #define GLshort SbGlInt16 #define GLfixed SbGlFixed #define GLint SbGlInt32 #define GLint64 SbGlInt64 #define GLintptr SbGlIntPtr #define GLsizei SbGlSizei #define GLsizeiptr SbGlSizeiPtr #define GLsync SbGlSync #define GLubyte SbGlUInt8 #define GLushort SbGlUInt16 #define GLuint SbGlUInt32 #define GLuint64 SbGlUInt64 #define GLvoid SbGlVoid #define GLhalf SbGlUInt16 // EGL_VERSION_1_0 #define EGL_ALPHA_SIZE SB_EGL_ALPHA_SIZE #define EGL_BAD_ACCESS SB_EGL_BAD_ACCESS #define EGL_BAD_ALLOC SB_EGL_BAD_ALLOC #define EGL_BAD_ATTRIBUTE SB_EGL_BAD_ATTRIBUTE #define EGL_BAD_CONFIG SB_EGL_BAD_CONFIG #define EGL_BAD_CONTEXT SB_EGL_BAD_CONTEXT #define EGL_BAD_CURRENT_SURFACE SB_EGL_BAD_CURRENT_SURFACE #define EGL_BAD_DISPLAY SB_EGL_BAD_DISPLAY #define EGL_BAD_MATCH SB_EGL_BAD_MATCH #define EGL_BAD_NATIVE_PIXMAP SB_EGL_BAD_NATIVE_PIXMAP #define EGL_BAD_NATIVE_WINDOW SB_EGL_BAD_NATIVE_WINDOW #define EGL_BAD_PARAMETER SB_EGL_BAD_PARAMETER #define EGL_BAD_SURFACE SB_EGL_BAD_SURFACE #define EGL_BLUE_SIZE SB_EGL_BLUE_SIZE #define EGL_BUFFER_SIZE SB_EGL_BUFFER_SIZE #define EGL_CONFIG_CAVEAT SB_EGL_CONFIG_CAVEAT #define EGL_CONFIG_ID SB_EGL_CONFIG_ID #define EGL_CORE_NATIVE_ENGINE SB_EGL_CORE_NATIVE_ENGINE #define EGL_DEPTH_SIZE SB_EGL_DEPTH_SIZE #define EGL_DONT_CARE SB_EGL_DONT_CARE #define EGL_DRAW SB_EGL_DRAW #define EGL_EXTENSIONS SB_EGL_EXTENSIONS #define EGL_FALSE SB_EGL_FALSE #define EGL_GREEN_SIZE SB_EGL_GREEN_SIZE #define EGL_HEIGHT SB_EGL_HEIGHT #define EGL_LARGEST_PBUFFER SB_EGL_LARGEST_PBUFFER #define EGL_LEVEL SB_EGL_LEVEL #define EGL_MAX_PBUFFER_HEIGHT SB_EGL_MAX_PBUFFER_HEIGHT #define EGL_MAX_PBUFFER_PIXELS SB_EGL_MAX_PBUFFER_PIXELS #define EGL_MAX_PBUFFER_WIDTH SB_EGL_MAX_PBUFFER_WIDTH #define EGL_NATIVE_RENDERABLE SB_EGL_NATIVE_RENDERABLE #define EGL_NATIVE_VISUAL_ID SB_EGL_NATIVE_VISUAL_ID #define EGL_NATIVE_VISUAL_TYPE SB_EGL_NATIVE_VISUAL_TYPE #define EGL_NONE SB_EGL_NONE #define EGL_NON_CONFORMANT_CONFIG SB_EGL_NON_CONFORMANT_CONFIG #define EGL_NOT_INITIALIZED SB_EGL_NOT_INITIALIZED #define EGL_NO_CONTEXT SB_EGL_NO_CONTEXT #define EGL_NO_DISPLAY SB_EGL_NO_DISPLAY #define EGL_NO_SURFACE SB_EGL_NO_SURFACE #define EGL_PBUFFER_BIT SB_EGL_PBUFFER_BIT #define EGL_PIXMAP_BIT SB_EGL_PIXMAP_BIT #define EGL_READ SB_EGL_READ #define EGL_RED_SIZE SB_EGL_RED_SIZE #define EGL_SAMPLES SB_EGL_SAMPLES #define EGL_SAMPLE_BUFFERS SB_EGL_SAMPLE_BUFFERS #define EGL_SLOW_CONFIG SB_EGL_SLOW_CONFIG #define EGL_STENCIL_SIZE SB_EGL_STENCIL_SIZE #define EGL_SUCCESS SB_EGL_SUCCESS #define EGL_SURFACE_TYPE SB_EGL_SURFACE_TYPE #define EGL_TRANSPARENT_BLUE_VALUE SB_EGL_TRANSPARENT_BLUE_VALUE #define EGL_TRANSPARENT_GREEN_VALUE SB_EGL_TRANSPARENT_GREEN_VALUE #define EGL_TRANSPARENT_RED_VALUE SB_EGL_TRANSPARENT_RED_VALUE #define EGL_TRANSPARENT_RGB SB_EGL_TRANSPARENT_RGB #define EGL_TRANSPARENT_TYPE SB_EGL_TRANSPARENT_TYPE #define EGL_TRUE SB_EGL_TRUE #define EGL_VENDOR SB_EGL_VENDOR #define EGL_VERSION SB_EGL_VERSION #define EGL_WIDTH SB_EGL_WIDTH #define EGL_WINDOW_BIT SB_EGL_WINDOW_BIT // EGL_VERSION_1_1 #define EGL_BACK_BUFFER SB_EGL_BACK_BUFFER #define EGL_BIND_TO_TEXTURE_RGB SB_EGL_BIND_TO_TEXTURE_RGB #define EGL_BIND_TO_TEXTURE_RGBA SB_EGL_BIND_TO_TEXTURE_RGBA #define EGL_CONTEXT_LOST SB_EGL_CONTEXT_LOST #define EGL_MIN_SWAP_INTERVAL SB_EGL_MIN_SWAP_INTERVAL #define EGL_MAX_SWAP_INTERVAL SB_EGL_MAX_SWAP_INTERVAL #define EGL_MIPMAP_TEXTURE SB_EGL_MIPMAP_TEXTURE #define EGL_MIPMAP_LEVEL SB_EGL_MIPMAP_LEVEL #define EGL_NO_TEXTURE SB_EGL_NO_TEXTURE #define EGL_TEXTURE_2D SB_EGL_TEXTURE_2D #define EGL_TEXTURE_FORMAT SB_EGL_TEXTURE_FORMAT #define EGL_TEXTURE_RGB SB_EGL_TEXTURE_RGB #define EGL_TEXTURE_RGBA SB_EGL_TEXTURE_RGBA #define EGL_TEXTURE_TARGET SB_EGL_TEXTURE_TARGET // EGL_VERSION_1_2 #define EGL_ALPHA_FORMAT SB_EGL_ALPHA_FORMAT #define EGL_ALPHA_FORMAT_NONPRE SB_EGL_ALPHA_FORMAT_NONPRE #define EGL_ALPHA_FORMAT_PRE SB_EGL_ALPHA_FORMAT_PRE #define EGL_ALPHA_MASK_SIZE SB_EGL_ALPHA_MASK_SIZE #define EGL_BUFFER_PRESERVED SB_EGL_BUFFER_PRESERVED #define EGL_BUFFER_DESTROYED SB_EGL_BUFFER_DESTROYED #define EGL_CLIENT_APIS SB_EGL_CLIENT_APIS #define EGL_COLORSPACE SB_EGL_COLORSPACE #define EGL_COLORSPACE_sRGB SB_EGL_COLORSPACE_sRGB #define EGL_COLORSPACE_LINEAR SB_EGL_COLORSPACE_LINEAR #define EGL_COLOR_BUFFER_TYPE SB_EGL_COLOR_BUFFER_TYPE #define EGL_CONTEXT_CLIENT_TYPE SB_EGL_CONTEXT_CLIENT_TYPE #define EGL_DISPLAY_SCALING SB_EGL_DISPLAY_SCALING #define EGL_HORIZONTAL_RESOLUTION SB_EGL_HORIZONTAL_RESOLUTION #define EGL_LUMINANCE_BUFFER SB_EGL_LUMINANCE_BUFFER #define EGL_LUMINANCE_SIZE SB_EGL_LUMINANCE_SIZE #define EGL_OPENGL_ES_BIT SB_EGL_OPENGL_ES_BIT #define EGL_OPENVG_BIT SB_EGL_OPENVG_BIT #define EGL_OPENGL_ES_API SB_EGL_OPENGL_ES_API #define EGL_OPENVG_API SB_EGL_OPENVG_API #define EGL_OPENVG_IMAGE SB_EGL_OPENVG_IMAGE #define EGL_PIXEL_ASPECT_RATIO SB_EGL_PIXEL_ASPECT_RATIO #define EGL_RENDERABLE_TYPE SB_EGL_RENDERABLE_TYPE #define EGL_RENDER_BUFFER SB_EGL_RENDER_BUFFER #define EGL_RGB_BUFFER SB_EGL_RGB_BUFFER #define EGL_SINGLE_BUFFER SB_EGL_SINGLE_BUFFER #define EGL_SWAP_BEHAVIOR SB_EGL_SWAP_BEHAVIOR #define EGL_UNKNOWN SB_EGL_UNKNOWN #define EGL_VERTICAL_RESOLUTION SB_EGL_VERTICAL_RESOLUTION // EGL_VERSION_1_3 #define EGL_CONFORMANT SB_EGL_CONFORMANT #define EGL_CONTEXT_CLIENT_VERSION SB_EGL_CONTEXT_CLIENT_VERSION #define EGL_MATCH_NATIVE_PIXMAP SB_EGL_MATCH_NATIVE_PIXMAP #define EGL_OPENGL_ES2_BIT SB_EGL_OPENGL_ES2_BIT #define EGL_VG_ALPHA_FORMAT SB_EGL_VG_ALPHA_FORMAT #define EGL_VG_ALPHA_FORMAT_NONPRE SB_EGL_VG_ALPHA_FORMAT_NONPRE #define EGL_VG_ALPHA_FORMAT_PRE SB_EGL_VG_ALPHA_FORMAT_PRE #define EGL_VG_ALPHA_FORMAT_PRE_BIT SB_EGL_VG_ALPHA_FORMAT_PRE_BIT #define EGL_VG_COLORSPACE SB_EGL_VG_COLORSPACE #define EGL_VG_COLORSPACE_sRGB SB_EGL_VG_COLORSPACE_sRGB #define EGL_VG_COLORSPACE_LINEAR SB_EGL_VG_COLORSPACE_LINEAR #define EGL_VG_COLORSPACE_LINEAR_BIT SB_EGL_VG_COLORSPACE_LINEAR_BIT // EGL_VERSION_1_4 #define EGL_DEFAULT_DISPLAY SB_EGL_DEFAULT_DISPLAY #define EGL_MULTISAMPLE_RESOLVE_BOX_BIT SB_EGL_MULTISAMPLE_RESOLVE_BOX_BIT #define EGL_MULTISAMPLE_RESOLVE SB_EGL_MULTISAMPLE_RESOLVE #define EGL_MULTISAMPLE_RESOLVE_DEFAULT SB_EGL_MULTISAMPLE_RESOLVE_DEFAULT #define EGL_MULTISAMPLE_RESOLVE_BOX SB_EGL_MULTISAMPLE_RESOLVE_BOX #define EGL_OPENGL_API SB_EGL_OPENGL_API #define EGL_OPENGL_BIT SB_EGL_OPENGL_BIT #define EGL_SWAP_BEHAVIOR_PRESERVED_BIT SB_EGL_SWAP_BEHAVIOR_PRESERVED_BIT // EGL_VERSION_1_5 #define EGL_CONTEXT_MAJOR_VERSION SB_EGL_CONTEXT_MAJOR_VERSION #define EGL_CONTEXT_MINOR_VERSION SB_EGL_CONTEXT_MINOR_VERSION #define EGL_CONTEXT_OPENGL_PROFILE_MASK SB_EGL_CONTEXT_OPENGL_PROFILE_MASK #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY \ SB_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY #define EGL_NO_RESET_NOTIFICATION SB_EGL_NO_RESET_NOTIFICATION #define EGL_LOSE_CONTEXT_ON_RESET SB_EGL_LOSE_CONTEXT_ON_RESET #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT \ SB_EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT \ SB_EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT #define EGL_CONTEXT_OPENGL_DEBUG SB_EGL_CONTEXT_OPENGL_DEBUG #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE \ SB_EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS SB_EGL_CONTEXT_OPENGL_ROBUST_ACCESS #define EGL_OPENGL_ES3_BIT SB_EGL_OPENGL_ES3_BIT #define EGL_CL_EVENT_HANDLE SB_EGL_CL_EVENT_HANDLE #define EGL_SYNC_CL_EVENT SB_EGL_SYNC_CL_EVENT #define EGL_SYNC_CL_EVENT_COMPLETE SB_EGL_SYNC_CL_EVENT_COMPLETE #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE SB_EGL_SYNC_PRIOR_COMMANDS_COMPLETE #define EGL_SYNC_TYPE SB_EGL_SYNC_TYPE #define EGL_SYNC_STATUS SB_EGL_SYNC_STATUS #define EGL_SYNC_CONDITION SB_EGL_SYNC_CONDITION #define EGL_SIGNALED SB_EGL_SIGNALED #define EGL_UNSIGNALED SB_EGL_UNSIGNALED #define EGL_SYNC_FLUSH_COMMANDS_BIT SB_EGL_SYNC_FLUSH_COMMANDS_BIT #define EGL_FOREVER SB_EGL_FOREVER #define EGL_TIMEOUT_EXPIRED SB_EGL_TIMEOUT_EXPIRED #define EGL_CONDITION_SATISFIED SB_EGL_CONDITION_SATISFIED #define EGL_NO_SYNC SB_EGL_NO_SYNC #define EGL_SYNC_FENCE SB_EGL_SYNC_FENCE #define EGL_GL_COLORSPACE SB_EGL_GL_COLORSPACE #define EGL_GL_COLORSPACE_SRGB SB_EGL_GL_COLORSPACE_SRGB #define EGL_GL_COLORSPACE_LINEAR SB_EGL_GL_COLORSPACE_LINEAR #define EGL_GL_RENDERBUFFER SB_EGL_GL_RENDERBUFFER #define EGL_GL_TEXTURE_2D SB_EGL_GL_TEXTURE_2D #define EGL_GL_TEXTURE_LEVEL SB_EGL_GL_TEXTURE_LEVEL #define EGL_GL_TEXTURE_3D SB_EGL_GL_TEXTURE_3D #define EGL_GL_TEXTURE_ZOFFSET SB_EGL_GL_TEXTURE_ZOFFSET #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X SB_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X SB_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y SB_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y SB_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z SB_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z SB_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z #define EGL_IMAGE_PRESERVED SB_EGL_IMAGE_PRESERVED #define EGL_NO_IMAGE SB_EGL_NO_IMAGE #define GL_DEPTH_BUFFER_BIT SB_GL_DEPTH_BUFFER_BIT #define GL_STENCIL_BUFFER_BIT SB_GL_STENCIL_BUFFER_BIT #define GL_COLOR_BUFFER_BIT SB_GL_COLOR_BUFFER_BIT #define GL_FALSE SB_GL_FALSE #define GL_TRUE SB_GL_TRUE #define GL_POINTS SB_GL_POINTS #define GL_LINES SB_GL_LINES #define GL_LINE_LOOP SB_GL_LINE_LOOP #define GL_LINE_STRIP SB_GL_LINE_STRIP #define GL_TRIANGLES SB_GL_TRIANGLES #define GL_TRIANGLE_STRIP SB_GL_TRIANGLE_STRIP #define GL_TRIANGLE_FAN SB_GL_TRIANGLE_FAN #define GL_ZERO SB_GL_ZERO #define GL_ONE SB_GL_ONE #define GL_SRC_COLOR SB_GL_SRC_COLOR #define GL_ONE_MINUS_SRC_COLOR SB_GL_ONE_MINUS_SRC_COLOR #define GL_SRC_ALPHA SB_GL_SRC_ALPHA #define GL_ONE_MINUS_SRC_ALPHA SB_GL_ONE_MINUS_SRC_ALPHA #define GL_DST_ALPHA SB_GL_DST_ALPHA #define GL_ONE_MINUS_DST_ALPHA SB_GL_ONE_MINUS_DST_ALPHA #define GL_DST_COLOR SB_GL_DST_COLOR #define GL_ONE_MINUS_DST_COLOR SB_GL_ONE_MINUS_DST_COLOR #define GL_SRC_ALPHA_SATURATE SB_GL_SRC_ALPHA_SATURATE #define GL_FUNC_ADD SB_GL_FUNC_ADD #define GL_BLEND_EQUATION SB_GL_BLEND_EQUATION #define GL_BLEND_EQUATION_RGB SB_GL_BLEND_EQUATION_RGB #define GL_BLEND_EQUATION_ALPHA SB_GL_BLEND_EQUATION_ALPHA #define GL_FUNC_SUBTRACT SB_GL_FUNC_SUBTRACT #define GL_FUNC_REVERSE_SUBTRACT SB_GL_FUNC_REVERSE_SUBTRACT #define GL_BLEND_DST_RGB SB_GL_BLEND_DST_RGB #define GL_BLEND_SRC_RGB SB_GL_BLEND_SRC_RGB #define GL_BLEND_DST_ALPHA SB_GL_BLEND_DST_ALPHA #define GL_BLEND_SRC_ALPHA SB_GL_BLEND_SRC_ALPHA #define GL_CONSTANT_COLOR SB_GL_CONSTANT_COLOR #define GL_ONE_MINUS_CONSTANT_COLOR SB_GL_ONE_MINUS_CONSTANT_COLOR #define GL_CONSTANT_ALPHA SB_GL_CONSTANT_ALPHA #define GL_ONE_MINUS_CONSTANT_ALPHA SB_GL_ONE_MINUS_CONSTANT_ALPHA #define GL_BLEND_COLOR SB_GL_BLEND_COLOR #define GL_ARRAY_BUFFER SB_GL_ARRAY_BUFFER #define GL_ELEMENT_ARRAY_BUFFER SB_GL_ELEMENT_ARRAY_BUFFER #define GL_ARRAY_BUFFER_BINDING SB_GL_ARRAY_BUFFER_BINDING #define GL_ELEMENT_ARRAY_BUFFER_BINDING SB_GL_ELEMENT_ARRAY_BUFFER_BINDING #define GL_STREAM_DRAW SB_GL_STREAM_DRAW #define GL_STATIC_DRAW SB_GL_STATIC_DRAW #define GL_DYNAMIC_DRAW SB_GL_DYNAMIC_DRAW #define GL_BUFFER_SIZE SB_GL_BUFFER_SIZE #define GL_BUFFER_USAGE SB_GL_BUFFER_USAGE #define GL_CURRENT_VERTEX_ATTRIB SB_GL_CURRENT_VERTEX_ATTRIB #define GL_FRONT SB_GL_FRONT #define GL_BACK SB_GL_BACK #define GL_FRONT_AND_BACK SB_GL_FRONT_AND_BACK #define GL_TEXTURE_2D SB_GL_TEXTURE_2D #define GL_CULL_FACE SB_GL_CULL_FACE #define GL_BLEND SB_GL_BLEND #define GL_DITHER SB_GL_DITHER #define GL_STENCIL_TEST SB_GL_STENCIL_TEST #define GL_DEPTH_TEST SB_GL_DEPTH_TEST #define GL_SCISSOR_TEST SB_GL_SCISSOR_TEST #define GL_POLYGON_OFFSET_FILL SB_GL_POLYGON_OFFSET_FILL #define GL_SAMPLE_ALPHA_TO_COVERAGE SB_GL_SAMPLE_ALPHA_TO_COVERAGE #define GL_SAMPLE_COVERAGE SB_GL_SAMPLE_COVERAGE #define GL_NO_ERROR SB_GL_NO_ERROR #define GL_INVALID_ENUM SB_GL_INVALID_ENUM #define GL_INVALID_VALUE SB_GL_INVALID_VALUE #define GL_INVALID_OPERATION SB_GL_INVALID_OPERATION #define GL_OUT_OF_MEMORY SB_GL_OUT_OF_MEMORY #define GL_CW SB_GL_CW #define GL_CCW SB_GL_CCW #define GL_LINE_WIDTH SB_GL_LINE_WIDTH #define GL_ALIASED_POINT_SIZE_RANGE SB_GL_ALIASED_POINT_SIZE_RANGE #define GL_ALIASED_LINE_WIDTH_RANGE SB_GL_ALIASED_LINE_WIDTH_RANGE #define GL_CULL_FACE_MODE SB_GL_CULL_FACE_MODE #define GL_FRONT_FACE SB_GL_FRONT_FACE #define GL_DEPTH_RANGE SB_GL_DEPTH_RANGE #define GL_DEPTH_WRITEMASK SB_GL_DEPTH_WRITEMASK #define GL_DEPTH_CLEAR_VALUE SB_GL_DEPTH_CLEAR_VALUE #define GL_DEPTH_FUNC SB_GL_DEPTH_FUNC #define GL_STENCIL_CLEAR_VALUE SB_GL_STENCIL_CLEAR_VALUE #define GL_STENCIL_FUNC SB_GL_STENCIL_FUNC #define GL_STENCIL_FAIL SB_GL_STENCIL_FAIL #define GL_STENCIL_PASS_DEPTH_FAIL SB_GL_STENCIL_PASS_DEPTH_FAIL #define GL_STENCIL_PASS_DEPTH_PASS SB_GL_STENCIL_PASS_DEPTH_PASS #define GL_STENCIL_REF SB_GL_STENCIL_REF #define GL_STENCIL_VALUE_MASK SB_GL_STENCIL_VALUE_MASK #define GL_STENCIL_WRITEMASK SB_GL_STENCIL_WRITEMASK #define GL_STENCIL_BACK_FUNC SB_GL_STENCIL_BACK_FUNC #define GL_STENCIL_BACK_FAIL SB_GL_STENCIL_BACK_FAIL #define GL_STENCIL_BACK_PASS_DEPTH_FAIL SB_GL_STENCIL_BACK_PASS_DEPTH_FAIL #define GL_STENCIL_BACK_PASS_DEPTH_PASS SB_GL_STENCIL_BACK_PASS_DEPTH_PASS #define GL_STENCIL_BACK_REF SB_GL_STENCIL_BACK_REF #define GL_STENCIL_BACK_VALUE_MASK SB_GL_STENCIL_BACK_VALUE_MASK #define GL_STENCIL_BACK_WRITEMASK SB_GL_STENCIL_BACK_WRITEMASK #define GL_VIEWPORT SB_GL_VIEWPORT #define GL_SCISSOR_BOX SB_GL_SCISSOR_BOX #define GL_COLOR_CLEAR_VALUE SB_GL_COLOR_CLEAR_VALUE #define GL_COLOR_WRITEMASK SB_GL_COLOR_WRITEMASK #define GL_UNPACK_ALIGNMENT SB_GL_UNPACK_ALIGNMENT #define GL_PACK_ALIGNMENT SB_GL_PACK_ALIGNMENT #define GL_MAX_TEXTURE_SIZE SB_GL_MAX_TEXTURE_SIZE #define GL_MAX_VIEWPORT_DIMS SB_GL_MAX_VIEWPORT_DIMS #define GL_SUBPIXEL_BITS SB_GL_SUBPIXEL_BITS #define GL_RED_BITS SB_GL_RED_BITS #define GL_GREEN_BITS SB_GL_GREEN_BITS #define GL_BLUE_BITS SB_GL_BLUE_BITS #define GL_ALPHA_BITS SB_GL_ALPHA_BITS #define GL_DEPTH_BITS SB_GL_DEPTH_BITS #define GL_STENCIL_BITS SB_GL_STENCIL_BITS #define GL_POLYGON_OFFSET_UNITS SB_GL_POLYGON_OFFSET_UNITS #define GL_POLYGON_OFFSET_FACTOR SB_GL_POLYGON_OFFSET_FACTOR #define GL_TEXTURE_BINDING_2D SB_GL_TEXTURE_BINDING_2D #define GL_SAMPLE_BUFFERS SB_GL_SAMPLE_BUFFERS #define GL_SAMPLES SB_GL_SAMPLES #define GL_SAMPLE_COVERAGE_VALUE SB_GL_SAMPLE_COVERAGE_VALUE #define GL_SAMPLE_COVERAGE_INVERT SB_GL_SAMPLE_COVERAGE_INVERT #define GL_NUM_COMPRESSED_TEXTURE_FORMATS SB_GL_NUM_COMPRESSED_TEXTURE_FORMATS #define GL_COMPRESSED_TEXTURE_FORMATS SB_GL_COMPRESSED_TEXTURE_FORMATS #define GL_DONT_CARE SB_GL_DONT_CARE #define GL_FASTEST SB_GL_FASTEST #define GL_NICEST SB_GL_NICEST #define GL_GENERATE_MIPMAP_HINT SB_GL_GENERATE_MIPMAP_HINT #define GL_BYTE SB_GL_BYTE #define GL_UNSIGNED_BYTE SB_GL_UNSIGNED_BYTE #define GL_SHORT SB_GL_SHORT #define GL_UNSIGNED_SHORT SB_GL_UNSIGNED_SHORT #define GL_INT SB_GL_INT #define GL_UNSIGNED_INT SB_GL_UNSIGNED_INT #define GL_FLOAT SB_GL_FLOAT #define GL_FIXED SB_GL_FIXED #define GL_DEPTH_COMPONENT SB_GL_DEPTH_COMPONENT #define GL_ALPHA SB_GL_ALPHA #define GL_RGB SB_GL_RGB #define GL_RGBA SB_GL_RGBA #define GL_LUMINANCE SB_GL_LUMINANCE #define GL_LUMINANCE_ALPHA SB_GL_LUMINANCE_ALPHA #define GL_UNSIGNED_SHORT_4_4_4_4 SB_GL_UNSIGNED_SHORT_4_4_4_4 #define GL_UNSIGNED_SHORT_5_5_5_1 SB_GL_UNSIGNED_SHORT_5_5_5_1 #define GL_UNSIGNED_SHORT_5_6_5 SB_GL_UNSIGNED_SHORT_5_6_5 #define GL_FRAGMENT_SHADER SB_GL_FRAGMENT_SHADER #define GL_VERTEX_SHADER SB_GL_VERTEX_SHADER #define GL_MAX_VERTEX_ATTRIBS SB_GL_MAX_VERTEX_ATTRIBS #define GL_MAX_VERTEX_UNIFORM_VECTORS SB_GL_MAX_VERTEX_UNIFORM_VECTORS #define GL_MAX_VARYING_VECTORS SB_GL_MAX_VARYING_VECTORS #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS \ SB_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS SB_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS #define GL_MAX_TEXTURE_IMAGE_UNITS SB_GL_MAX_TEXTURE_IMAGE_UNITS #define GL_MAX_FRAGMENT_UNIFORM_VECTORS SB_GL_MAX_FRAGMENT_UNIFORM_VECTORS #define GL_SHADER_TYPE SB_GL_SHADER_TYPE #define GL_DELETE_STATUS SB_GL_DELETE_STATUS #define GL_LINK_STATUS SB_GL_LINK_STATUS #define GL_VALIDATE_STATUS SB_GL_VALIDATE_STATUS #define GL_ATTACHED_SHADERS SB_GL_ATTACHED_SHADERS #define GL_ACTIVE_UNIFORMS SB_GL_ACTIVE_UNIFORMS #define GL_ACTIVE_UNIFORM_MAX_LENGTH SB_GL_ACTIVE_UNIFORM_MAX_LENGTH #define GL_ACTIVE_ATTRIBUTES SB_GL_ACTIVE_ATTRIBUTES #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH SB_GL_ACTIVE_ATTRIBUTE_MAX_LENGTH #define GL_SHADING_LANGUAGE_VERSION SB_GL_SHADING_LANGUAGE_VERSION #define GL_CURRENT_PROGRAM SB_GL_CURRENT_PROGRAM #define GL_NEVER SB_GL_NEVER #define GL_LESS SB_GL_LESS #define GL_EQUAL SB_GL_EQUAL #define GL_LEQUAL SB_GL_LEQUAL #define GL_GREATER SB_GL_GREATER #define GL_NOTEQUAL SB_GL_NOTEQUAL #define GL_GEQUAL SB_GL_GEQUAL #define GL_ALWAYS SB_GL_ALWAYS #define GL_KEEP SB_GL_KEEP #define GL_REPLACE SB_GL_REPLACE #define GL_INCR SB_GL_INCR #define GL_DECR SB_GL_DECR #define GL_INVERT SB_GL_INVERT #define GL_INCR_WRAP SB_GL_INCR_WRAP #define GL_DECR_WRAP SB_GL_DECR_WRAP #define GL_VENDOR SB_GL_VENDOR #define GL_RENDERER SB_GL_RENDERER #define GL_VERSION SB_GL_VERSION #define GL_EXTENSIONS SB_GL_EXTENSIONS #define GL_NEAREST SB_GL_NEAREST #define GL_LINEAR SB_GL_LINEAR #define GL_NEAREST_MIPMAP_NEAREST SB_GL_NEAREST_MIPMAP_NEAREST #define GL_LINEAR_MIPMAP_NEAREST SB_GL_LINEAR_MIPMAP_NEAREST #define GL_NEAREST_MIPMAP_LINEAR SB_GL_NEAREST_MIPMAP_LINEAR #define GL_LINEAR_MIPMAP_LINEAR SB_GL_LINEAR_MIPMAP_LINEAR #define GL_TEXTURE_MAG_FILTER SB_GL_TEXTURE_MAG_FILTER #define GL_TEXTURE_MIN_FILTER SB_GL_TEXTURE_MIN_FILTER #define GL_TEXTURE_WRAP_S SB_GL_TEXTURE_WRAP_S #define GL_TEXTURE_WRAP_T SB_GL_TEXTURE_WRAP_T #define GL_TEXTURE SB_GL_TEXTURE #define GL_TEXTURE_CUBE_MAP SB_GL_TEXTURE_CUBE_MAP #define GL_TEXTURE_BINDING_CUBE_MAP SB_GL_TEXTURE_BINDING_CUBE_MAP #define GL_TEXTURE_CUBE_MAP_POSITIVE_X SB_GL_TEXTURE_CUBE_MAP_POSITIVE_X #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X SB_GL_TEXTURE_CUBE_MAP_NEGATIVE_X #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y SB_GL_TEXTURE_CUBE_MAP_POSITIVE_Y #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y SB_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z SB_GL_TEXTURE_CUBE_MAP_POSITIVE_Z #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z SB_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z #define GL_MAX_CUBE_MAP_TEXTURE_SIZE SB_GL_MAX_CUBE_MAP_TEXTURE_SIZE #define GL_TEXTURE0 SB_GL_TEXTURE0 #define GL_TEXTURE1 SB_GL_TEXTURE1 #define GL_TEXTURE2 SB_GL_TEXTURE2 #define GL_TEXTURE3 SB_GL_TEXTURE3 #define GL_TEXTURE4 SB_GL_TEXTURE4 #define GL_TEXTURE5 SB_GL_TEXTURE5 #define GL_TEXTURE6 SB_GL_TEXTURE6 #define GL_TEXTURE7 SB_GL_TEXTURE7 #define GL_TEXTURE8 SB_GL_TEXTURE8 #define GL_TEXTURE9 SB_GL_TEXTURE9 #define GL_TEXTURE10 SB_GL_TEXTURE10 #define GL_TEXTURE11 SB_GL_TEXTURE11 #define GL_TEXTURE12 SB_GL_TEXTURE12 #define GL_TEXTURE13 SB_GL_TEXTURE13 #define GL_TEXTURE14 SB_GL_TEXTURE14 #define GL_TEXTURE15 SB_GL_TEXTURE15 #define GL_TEXTURE16 SB_GL_TEXTURE16 #define GL_TEXTURE17 SB_GL_TEXTURE17 #define GL_TEXTURE18 SB_GL_TEXTURE18 #define GL_TEXTURE19 SB_GL_TEXTURE19 #define GL_TEXTURE20 SB_GL_TEXTURE20 #define GL_TEXTURE21 SB_GL_TEXTURE21 #define GL_TEXTURE22 SB_GL_TEXTURE22 #define GL_TEXTURE23 SB_GL_TEXTURE23 #define GL_TEXTURE24 SB_GL_TEXTURE24 #define GL_TEXTURE25 SB_GL_TEXTURE25 #define GL_TEXTURE26 SB_GL_TEXTURE26 #define GL_TEXTURE27 SB_GL_TEXTURE27 #define GL_TEXTURE28 SB_GL_TEXTURE28 #define GL_TEXTURE29 SB_GL_TEXTURE29 #define GL_TEXTURE30 SB_GL_TEXTURE30 #define GL_TEXTURE31 SB_GL_TEXTURE31 #define GL_ACTIVE_TEXTURE SB_GL_ACTIVE_TEXTURE #define GL_REPEAT SB_GL_REPEAT #define GL_CLAMP_TO_EDGE SB_GL_CLAMP_TO_EDGE #define GL_MIRRORED_REPEAT SB_GL_MIRRORED_REPEAT #define GL_FLOAT_VEC2 SB_GL_FLOAT_VEC2 #define GL_FLOAT_VEC3 SB_GL_FLOAT_VEC3 #define GL_FLOAT_VEC4 SB_GL_FLOAT_VEC4 #define GL_INT_VEC2 SB_GL_INT_VEC2 #define GL_INT_VEC3 SB_GL_INT_VEC3 #define GL_INT_VEC4 SB_GL_INT_VEC4 #define GL_BOOL SB_GL_BOOL #define GL_BOOL_VEC2 SB_GL_BOOL_VEC2 #define GL_BOOL_VEC3 SB_GL_BOOL_VEC3 #define GL_BOOL_VEC4 SB_GL_BOOL_VEC4 #define GL_FLOAT_MAT2 SB_GL_FLOAT_MAT2 #define GL_FLOAT_MAT3 SB_GL_FLOAT_MAT3 #define GL_FLOAT_MAT4 SB_GL_FLOAT_MAT4 #define GL_SAMPLER_2D SB_GL_SAMPLER_2D #define GL_SAMPLER_CUBE SB_GL_SAMPLER_CUBE #define GL_VERTEX_ATTRIB_ARRAY_ENABLED SB_GL_VERTEX_ATTRIB_ARRAY_ENABLED #define GL_VERTEX_ATTRIB_ARRAY_SIZE SB_GL_VERTEX_ATTRIB_ARRAY_SIZE #define GL_VERTEX_ATTRIB_ARRAY_STRIDE SB_GL_VERTEX_ATTRIB_ARRAY_STRIDE #define GL_VERTEX_ATTRIB_ARRAY_TYPE SB_GL_VERTEX_ATTRIB_ARRAY_TYPE #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED SB_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED #define GL_VERTEX_ATTRIB_ARRAY_POINTER SB_GL_VERTEX_ATTRIB_ARRAY_POINTER #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING \ SB_GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING #define GL_IMPLEMENTATION_COLOR_READ_TYPE SB_GL_IMPLEMENTATION_COLOR_READ_TYPE #define GL_IMPLEMENTATION_COLOR_READ_FORMAT \ SB_GL_IMPLEMENTATION_COLOR_READ_FORMAT #define GL_COMPILE_STATUS SB_GL_COMPILE_STATUS #define GL_INFO_LOG_LENGTH SB_GL_INFO_LOG_LENGTH #define GL_SHADER_SOURCE_LENGTH SB_GL_SHADER_SOURCE_LENGTH #define GL_SHADER_COMPILER SB_GL_SHADER_COMPILER #define GL_SHADER_BINARY_FORMATS SB_GL_SHADER_BINARY_FORMATS #define GL_NUM_SHADER_BINARY_FORMATS SB_GL_NUM_SHADER_BINARY_FORMATS #define GL_LOW_FLOAT SB_GL_LOW_FLOAT #define GL_MEDIUM_FLOAT SB_GL_MEDIUM_FLOAT #define GL_HIGH_FLOAT SB_GL_HIGH_FLOAT #define GL_LOW_INT SB_GL_LOW_INT #define GL_MEDIUM_INT SB_GL_MEDIUM_INT #define GL_HIGH_INT SB_GL_HIGH_INT #define GL_FRAMEBUFFER SB_GL_FRAMEBUFFER #define GL_RENDERBUFFER SB_GL_RENDERBUFFER #define GL_RGBA4 SB_GL_RGBA4 #define GL_RGB5_A1 SB_GL_RGB5_A1 #define GL_RGB565 SB_GL_RGB565 #define GL_DEPTH_COMPONENT16 SB_GL_DEPTH_COMPONENT16 #define GL_STENCIL_INDEX8 SB_GL_STENCIL_INDEX8 #define GL_RENDERBUFFER_WIDTH SB_GL_RENDERBUFFER_WIDTH #define GL_RENDERBUFFER_HEIGHT SB_GL_RENDERBUFFER_HEIGHT #define GL_RENDERBUFFER_INTERNAL_FORMAT SB_GL_RENDERBUFFER_INTERNAL_FORMAT #define GL_RENDERBUFFER_RED_SIZE SB_GL_RENDERBUFFER_RED_SIZE #define GL_RENDERBUFFER_GREEN_SIZE SB_GL_RENDERBUFFER_GREEN_SIZE #define GL_RENDERBUFFER_BLUE_SIZE SB_GL_RENDERBUFFER_BLUE_SIZE #define GL_RENDERBUFFER_ALPHA_SIZE SB_GL_RENDERBUFFER_ALPHA_SIZE #define GL_RENDERBUFFER_DEPTH_SIZE SB_GL_RENDERBUFFER_DEPTH_SIZE #define GL_RENDERBUFFER_STENCIL_SIZE SB_GL_RENDERBUFFER_STENCIL_SIZE #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE \ SB_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME \ SB_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL \ SB_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE \ SB_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE #define GL_COLOR_ATTACHMENT0 SB_GL_COLOR_ATTACHMENT0 #define GL_DEPTH_ATTACHMENT SB_GL_DEPTH_ATTACHMENT #define GL_STENCIL_ATTACHMENT SB_GL_STENCIL_ATTACHMENT #define GL_NONE SB_GL_NONE #define GL_FRAMEBUFFER_COMPLETE SB_GL_FRAMEBUFFER_COMPLETE #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT \ SB_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT \ SB_GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS \ SB_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS #define GL_FRAMEBUFFER_UNSUPPORTED SB_GL_FRAMEBUFFER_UNSUPPORTED #define GL_FRAMEBUFFER_BINDING SB_GL_FRAMEBUFFER_BINDING #define GL_RENDERBUFFER_BINDING SB_GL_RENDERBUFFER_BINDING #define GL_MAX_RENDERBUFFER_SIZE SB_GL_MAX_RENDERBUFFER_SIZE #define GL_INVALID_FRAMEBUFFER_OPERATION SB_GL_INVALID_FRAMEBUFFER_OPERATION #include "cobalt/renderer/gles_ext.h" // Previously defined in // https://www.khronos.org/registry/OpenGL/api/GLES3/gl3.h. #define GL_READ_BUFFER SB_GL_READ_BUFFER #define GL_UNPACK_ROW_LENGTH SB_GL_UNPACK_ROW_LENGTH #define GL_UNPACK_SKIP_ROWS SB_GL_UNPACK_SKIP_ROWS #define GL_UNPACK_SKIP_PIXELS SB_GL_UNPACK_SKIP_PIXELS #define GL_PACK_ROW_LENGTH SB_GL_PACK_ROW_LENGTH #define GL_PACK_SKIP_ROWS SB_GL_PACK_SKIP_ROWS #define GL_PACK_SKIP_PIXELS SB_GL_PACK_SKIP_PIXELS #define GL_COLOR SB_GL_COLOR #define GL_DEPTH SB_GL_DEPTH #define GL_STENCIL SB_GL_STENCIL #define GL_RED SB_GL_RED #define GL_RGB8 SB_GL_RGB8 #define GL_RGBA8 SB_GL_RGBA8 #define GL_RGB10_A2 SB_GL_RGB10_A2 #define GL_TEXTURE_BINDING_3D SB_GL_TEXTURE_BINDING_3D #define GL_UNPACK_SKIP_IMAGES SB_GL_UNPACK_SKIP_IMAGES #define GL_UNPACK_IMAGE_HEIGHT SB_GL_UNPACK_IMAGE_HEIGHT #define GL_TEXTURE_3D SB_GL_TEXTURE_3D #define GL_TEXTURE_WRAP_R SB_GL_TEXTURE_WRAP_R #define GL_MAX_3D_TEXTURE_SIZE SB_GL_MAX_3D_TEXTURE_SIZE #define GL_UNSIGNED_INT_2_10_10_10_REV SB_GL_UNSIGNED_INT_2_10_10_10_REV #define GL_MAX_ELEMENTS_VERTICES SB_GL_MAX_ELEMENTS_VERTICES #define GL_MAX_ELEMENTS_INDICES SB_GL_MAX_ELEMENTS_INDICES #define GL_TEXTURE_MIN_LOD SB_GL_TEXTURE_MIN_LOD #define GL_TEXTURE_MAX_LOD SB_GL_TEXTURE_MAX_LOD #define GL_TEXTURE_BASE_LEVEL SB_GL_TEXTURE_BASE_LEVEL #define GL_TEXTURE_MAX_LEVEL SB_GL_TEXTURE_MAX_LEVEL #define GL_MIN SB_GL_MIN #define GL_MAX SB_GL_MAX #define GL_DEPTH_COMPONENT24 SB_GL_DEPTH_COMPONENT24 #define GL_MAX_TEXTURE_LOD_BIAS SB_GL_MAX_TEXTURE_LOD_BIAS #define GL_TEXTURE_COMPARE_MODE SB_GL_TEXTURE_COMPARE_MODE #define GL_TEXTURE_COMPARE_FUNC SB_GL_TEXTURE_COMPARE_FUNC #define GL_CURRENT_QUERY SB_GL_CURRENT_QUERY #define GL_QUERY_RESULT SB_GL_QUERY_RESULT #define GL_QUERY_RESULT_AVAILABLE SB_GL_QUERY_RESULT_AVAILABLE #define GL_BUFFER_MAPPED SB_GL_BUFFER_MAPPED #define GL_BUFFER_MAP_POINTER SB_GL_BUFFER_MAP_POINTER #define GL_STREAM_READ SB_GL_STREAM_READ #define GL_STREAM_COPY SB_GL_STREAM_COPY #define GL_STATIC_READ SB_GL_STATIC_READ #define GL_STATIC_COPY SB_GL_STATIC_COPY #define GL_DYNAMIC_READ SB_GL_DYNAMIC_READ #define GL_DYNAMIC_COPY SB_GL_DYNAMIC_COPY #define GL_MAX_DRAW_BUFFERS SB_GL_MAX_DRAW_BUFFERS #define GL_DRAW_BUFFER0 SB_GL_DRAW_BUFFER0 #define GL_DRAW_BUFFER1 SB_GL_DRAW_BUFFER1 #define GL_DRAW_BUFFER2 SB_GL_DRAW_BUFFER2 #define GL_DRAW_BUFFER3 SB_GL_DRAW_BUFFER3 #define GL_DRAW_BUFFER4 SB_GL_DRAW_BUFFER4 #define GL_DRAW_BUFFER5 SB_GL_DRAW_BUFFER5 #define GL_DRAW_BUFFER6 SB_GL_DRAW_BUFFER6 #define GL_DRAW_BUFFER7 SB_GL_DRAW_BUFFER7 #define GL_DRAW_BUFFER8 SB_GL_DRAW_BUFFER8 #define GL_DRAW_BUFFER9 SB_GL_DRAW_BUFFER9 #define GL_DRAW_BUFFER10 SB_GL_DRAW_BUFFER10 #define GL_DRAW_BUFFER11 SB_GL_DRAW_BUFFER11 #define GL_DRAW_BUFFER12 SB_GL_DRAW_BUFFER12 #define GL_DRAW_BUFFER13 SB_GL_DRAW_BUFFER13 #define GL_DRAW_BUFFER14 SB_GL_DRAW_BUFFER14 #define GL_DRAW_BUFFER15 SB_GL_DRAW_BUFFER15 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS SB_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS #define GL_MAX_VERTEX_UNIFORM_COMPONENTS SB_GL_MAX_VERTEX_UNIFORM_COMPONENTS #define GL_SAMPLER_3D SB_GL_SAMPLER_3D #define GL_SAMPLER_2D_SHADOW SB_GL_SAMPLER_2D_SHADOW #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT SB_GL_FRAGMENT_SHADER_DERIVATIVE_HINT #define GL_PIXEL_PACK_BUFFER SB_GL_PIXEL_PACK_BUFFER #define GL_PIXEL_UNPACK_BUFFER SB_GL_PIXEL_UNPACK_BUFFER #define GL_PIXEL_PACK_BUFFER_BINDING SB_GL_PIXEL_PACK_BUFFER_BINDING #define GL_PIXEL_UNPACK_BUFFER_BINDING SB_GL_PIXEL_UNPACK_BUFFER_BINDING #define GL_FLOAT_MAT2x3 SB_GL_FLOAT_MAT2x3 #define GL_FLOAT_MAT2x4 SB_GL_FLOAT_MAT2x4 #define GL_FLOAT_MAT3x2 SB_GL_FLOAT_MAT3x2 #define GL_FLOAT_MAT3x4 SB_GL_FLOAT_MAT3x4 #define GL_FLOAT_MAT4x2 SB_GL_FLOAT_MAT4x2 #define GL_FLOAT_MAT4x3 SB_GL_FLOAT_MAT4x3 #define GL_SRGB SB_GL_SRGB #define GL_SRGB8 SB_GL_SRGB8 #define GL_SRGB8_ALPHA8 SB_GL_SRGB8_ALPHA8 #define GL_COMPARE_REF_TO_TEXTURE SB_GL_COMPARE_REF_TO_TEXTURE #define GL_MAJOR_VERSION SB_GL_MAJOR_VERSION #define GL_MINOR_VERSION SB_GL_MINOR_VERSION #define GL_NUM_EXTENSIONS SB_GL_NUM_EXTENSIONS #define GL_RGBA32F SB_GL_RGBA32F #define GL_RGB32F SB_GL_RGB32F #define GL_RGBA16F SB_GL_RGBA16F #define GL_RGB16F SB_GL_RGB16F #define GL_VERTEX_ATTRIB_ARRAY_INTEGER SB_GL_VERTEX_ATTRIB_ARRAY_INTEGER #define GL_MAX_ARRAY_TEXTURE_LAYERS SB_GL_MAX_ARRAY_TEXTURE_LAYERS #define GL_MIN_PROGRAM_TEXEL_OFFSET SB_GL_MIN_PROGRAM_TEXEL_OFFSET #define GL_MAX_PROGRAM_TEXEL_OFFSET SB_GL_MAX_PROGRAM_TEXEL_OFFSET #define GL_MAX_VARYING_COMPONENTS SB_GL_MAX_VARYING_COMPONENTS #define GL_TEXTURE_2D_ARRAY SB_GL_TEXTURE_2D_ARRAY #define GL_TEXTURE_BINDING_2D_ARRAY SB_GL_TEXTURE_BINDING_2D_ARRAY #define GL_R11F_G11F_B10F SB_GL_R11F_G11F_B10F #define GL_UNSIGNED_INT_10F_11F_11F_REV SB_GL_UNSIGNED_INT_10F_11F_11F_REV #define GL_RGB9_E5 SB_GL_RGB9_E5 #define GL_UNSIGNED_INT_5_9_9_9_REV SB_GL_UNSIGNED_INT_5_9_9_9_REV #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH \ SB_GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE SB_GL_TRANSFORM_FEEDBACK_BUFFER_MODE #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS \ SB_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS #define GL_TRANSFORM_FEEDBACK_VARYINGS SB_GL_TRANSFORM_FEEDBACK_VARYINGS #define GL_TRANSFORM_FEEDBACK_BUFFER_START SB_GL_TRANSFORM_FEEDBACK_BUFFER_START #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE SB_GL_TRANSFORM_FEEDBACK_BUFFER_SIZE #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN \ SB_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN #define GL_RASTERIZER_DISCARD SB_GL_RASTERIZER_DISCARD #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS \ SB_GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS \ SB_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS #define GL_INTERLEAVED_ATTRIBS SB_GL_INTERLEAVED_ATTRIBS #define GL_SEPARATE_ATTRIBS SB_GL_SEPARATE_ATTRIBS #define GL_TRANSFORM_FEEDBACK_BUFFER SB_GL_TRANSFORM_FEEDBACK_BUFFER #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING \ SB_GL_TRANSFORM_FEEDBACK_BUFFER_BINDING #define GL_RGBA32UI SB_GL_RGBA32UI #define GL_RGB32UI SB_GL_RGB32UI #define GL_RGBA16UI SB_GL_RGBA16UI #define GL_RGB16UI SB_GL_RGB16UI #define GL_RGBA8UI SB_GL_RGBA8UI #define GL_RGB8UI SB_GL_RGB8UI #define GL_RGBA32I SB_GL_RGBA32I #define GL_RGB32I SB_GL_RGB32I #define GL_RGBA16I SB_GL_RGBA16I #define GL_RGB16I SB_GL_RGB16I #define GL_RGBA8I SB_GL_RGBA8I #define GL_RGB8I SB_GL_RGB8I #define GL_RED_INTEGER SB_GL_RED_INTEGER #define GL_RGB_INTEGER SB_GL_RGB_INTEGER #define GL_RGBA_INTEGER SB_GL_RGBA_INTEGER #define GL_SAMPLER_2D_ARRAY SB_GL_SAMPLER_2D_ARRAY #define GL_SAMPLER_2D_ARRAY_SHADOW SB_GL_SAMPLER_2D_ARRAY_SHADOW #define GL_SAMPLER_CUBE_SHADOW SB_GL_SAMPLER_CUBE_SHADOW #define GL_UNSIGNED_INT_VEC2 SB_GL_UNSIGNED_INT_VEC2 #define GL_UNSIGNED_INT_VEC3 SB_GL_UNSIGNED_INT_VEC3 #define GL_UNSIGNED_INT_VEC4 SB_GL_UNSIGNED_INT_VEC4 #define GL_INT_SAMPLER_2D SB_GL_INT_SAMPLER_2D #define GL_INT_SAMPLER_3D SB_GL_INT_SAMPLER_3D #define GL_INT_SAMPLER_CUBE SB_GL_INT_SAMPLER_CUBE #define GL_INT_SAMPLER_2D_ARRAY SB_GL_INT_SAMPLER_2D_ARRAY #define GL_UNSIGNED_INT_SAMPLER_2D SB_GL_UNSIGNED_INT_SAMPLER_2D #define GL_UNSIGNED_INT_SAMPLER_3D SB_GL_UNSIGNED_INT_SAMPLER_3D #define GL_UNSIGNED_INT_SAMPLER_CUBE SB_GL_UNSIGNED_INT_SAMPLER_CUBE #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY SB_GL_UNSIGNED_INT_SAMPLER_2D_ARRAY #define GL_BUFFER_ACCESS_FLAGS SB_GL_BUFFER_ACCESS_FLAGS #define GL_BUFFER_MAP_LENGTH SB_GL_BUFFER_MAP_LENGTH #define GL_BUFFER_MAP_OFFSET SB_GL_BUFFER_MAP_OFFSET #define GL_DEPTH_COMPONENT32F SB_GL_DEPTH_COMPONENT32F #define GL_DEPTH32F_STENCIL8 SB_GL_DEPTH32F_STENCIL8 #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV SB_GL_FLOAT_32_UNSIGNED_INT_24_8_REV #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING \ SB_GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE \ SB_GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE #define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE SB_GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE #define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE \ SB_GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE #define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE \ SB_GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE #define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE \ SB_GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE #define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE \ SB_GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE #define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE \ SB_GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE #define GL_FRAMEBUFFER_DEFAULT SB_GL_FRAMEBUFFER_DEFAULT #define GL_FRAMEBUFFER_UNDEFINED SB_GL_FRAMEBUFFER_UNDEFINED #define GL_DEPTH_STENCIL_ATTACHMENT SB_GL_DEPTH_STENCIL_ATTACHMENT #define GL_DEPTH_STENCIL SB_GL_DEPTH_STENCIL #define GL_UNSIGNED_INT_24_8 SB_GL_UNSIGNED_INT_24_8 #define GL_DEPTH24_STENCIL8 SB_GL_DEPTH24_STENCIL8 #define GL_UNSIGNED_NORMALIZED SB_GL_UNSIGNED_NORMALIZED #define GL_DRAW_FRAMEBUFFER_BINDING SB_GL_DRAW_FRAMEBUFFER_BINDING #define GL_READ_FRAMEBUFFER SB_GL_READ_FRAMEBUFFER #define GL_DRAW_FRAMEBUFFER SB_GL_DRAW_FRAMEBUFFER #define GL_READ_FRAMEBUFFER_BINDING SB_GL_READ_FRAMEBUFFER_BINDING #define GL_RENDERBUFFER_SAMPLES SB_GL_RENDERBUFFER_SAMPLES #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER \ SB_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER #define GL_MAX_COLOR_ATTACHMENTS SB_GL_MAX_COLOR_ATTACHMENTS #define GL_COLOR_ATTACHMENT1 SB_GL_COLOR_ATTACHMENT1 #define GL_COLOR_ATTACHMENT2 SB_GL_COLOR_ATTACHMENT2 #define GL_COLOR_ATTACHMENT3 SB_GL_COLOR_ATTACHMENT3 #define GL_COLOR_ATTACHMENT4 SB_GL_COLOR_ATTACHMENT4 #define GL_COLOR_ATTACHMENT5 SB_GL_COLOR_ATTACHMENT5 #define GL_COLOR_ATTACHMENT6 SB_GL_COLOR_ATTACHMENT6 #define GL_COLOR_ATTACHMENT7 SB_GL_COLOR_ATTACHMENT7 #define GL_COLOR_ATTACHMENT8 SB_GL_COLOR_ATTACHMENT8 #define GL_COLOR_ATTACHMENT9 SB_GL_COLOR_ATTACHMENT9 #define GL_COLOR_ATTACHMENT10 SB_GL_COLOR_ATTACHMENT10 #define GL_COLOR_ATTACHMENT11 SB_GL_COLOR_ATTACHMENT11 #define GL_COLOR_ATTACHMENT12 SB_GL_COLOR_ATTACHMENT12 #define GL_COLOR_ATTACHMENT13 SB_GL_COLOR_ATTACHMENT13 #define GL_COLOR_ATTACHMENT14 SB_GL_COLOR_ATTACHMENT14 #define GL_COLOR_ATTACHMENT15 SB_GL_COLOR_ATTACHMENT15 #define GL_COLOR_ATTACHMENT16 SB_GL_COLOR_ATTACHMENT16 #define GL_COLOR_ATTACHMENT17 SB_GL_COLOR_ATTACHMENT17 #define GL_COLOR_ATTACHMENT18 SB_GL_COLOR_ATTACHMENT18 #define GL_COLOR_ATTACHMENT19 SB_GL_COLOR_ATTACHMENT19 #define GL_COLOR_ATTACHMENT20 SB_GL_COLOR_ATTACHMENT20 #define GL_COLOR_ATTACHMENT21 SB_GL_COLOR_ATTACHMENT21 #define GL_COLOR_ATTACHMENT22 SB_GL_COLOR_ATTACHMENT22 #define GL_COLOR_ATTACHMENT23 SB_GL_COLOR_ATTACHMENT23 #define GL_COLOR_ATTACHMENT24 SB_GL_COLOR_ATTACHMENT24 #define GL_COLOR_ATTACHMENT25 SB_GL_COLOR_ATTACHMENT25 #define GL_COLOR_ATTACHMENT26 SB_GL_COLOR_ATTACHMENT26 #define GL_COLOR_ATTACHMENT27 SB_GL_COLOR_ATTACHMENT27 #define GL_COLOR_ATTACHMENT28 SB_GL_COLOR_ATTACHMENT28 #define GL_COLOR_ATTACHMENT29 SB_GL_COLOR_ATTACHMENT29 #define GL_COLOR_ATTACHMENT30 SB_GL_COLOR_ATTACHMENT30 #define GL_COLOR_ATTACHMENT31 SB_GL_COLOR_ATTACHMENT31 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE \ SB_GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE #define GL_MAX_SAMPLES SB_GL_MAX_SAMPLES #define GL_HALF_FLOAT SB_GL_HALF_FLOAT #define GL_MAP_READ_BIT SB_GL_MAP_READ_BIT #define GL_MAP_WRITE_BIT SB_GL_MAP_WRITE_BIT #define GL_MAP_INVALIDATE_RANGE_BIT SB_GL_MAP_INVALIDATE_RANGE_BIT #define GL_MAP_INVALIDATE_BUFFER_BIT SB_GL_MAP_INVALIDATE_BUFFER_BIT #define GL_MAP_FLUSH_EXPLICIT_BIT SB_GL_MAP_FLUSH_EXPLICIT_BIT #define GL_MAP_UNSYNCHRONIZED_BIT SB_GL_MAP_UNSYNCHRONIZED_BIT #define GL_RG SB_GL_RG #define GL_RG_INTEGER SB_GL_RG_INTEGER #define GL_R8 SB_GL_R8 #define GL_RG8 SB_GL_RG8 #define GL_R16F SB_GL_R16F #define GL_R32F SB_GL_R32F #define GL_RG16F SB_GL_RG16F #define GL_RG32F SB_GL_RG32F #define GL_R8I SB_GL_R8I #define GL_R8UI SB_GL_R8UI #define GL_R16I SB_GL_R16I #define GL_R16UI SB_GL_R16UI #define GL_R32I SB_GL_R32I #define GL_R32UI SB_GL_R32UI #define GL_RG8I SB_GL_RG8I #define GL_RG8UI SB_GL_RG8UI #define GL_RG16I SB_GL_RG16I #define GL_RG16UI SB_GL_RG16UI #define GL_RG32I SB_GL_RG32I #define GL_RG32UI SB_GL_RG32UI #define GL_VERTEX_ARRAY_BINDING SB_GL_VERTEX_ARRAY_BINDING #define GL_R8_SNORM SB_GL_R8_SNORM #define GL_RG8_SNORM SB_GL_RG8_SNORM #define GL_RGB8_SNORM SB_GL_RGB8_SNORM #define GL_RGBA8_SNORM SB_GL_RGBA8_SNORM #define GL_SIGNED_NORMALIZED SB_GL_SIGNED_NORMALIZED #define GL_PRIMITIVE_RESTART_FIXED_INDEX SB_GL_PRIMITIVE_RESTART_FIXED_INDEX #define GL_COPY_READ_BUFFER SB_GL_COPY_READ_BUFFER #define GL_COPY_WRITE_BUFFER SB_GL_COPY_WRITE_BUFFER #define GL_COPY_READ_BUFFER_BINDING SB_GL_COPY_READ_BUFFER_BINDING #define GL_COPY_WRITE_BUFFER_BINDING SB_GL_COPY_WRITE_BUFFER_BINDING #define GL_UNIFORM_BUFFER SB_GL_UNIFORM_BUFFER #define GL_UNIFORM_BUFFER_BINDING SB_GL_UNIFORM_BUFFER_BINDING #define GL_UNIFORM_BUFFER_START SB_GL_UNIFORM_BUFFER_START #define GL_UNIFORM_BUFFER_SIZE SB_GL_UNIFORM_BUFFER_SIZE #define GL_MAX_VERTEX_UNIFORM_BLOCKS SB_GL_MAX_VERTEX_UNIFORM_BLOCKS #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS SB_GL_MAX_FRAGMENT_UNIFORM_BLOCKS #define GL_MAX_COMBINED_UNIFORM_BLOCKS SB_GL_MAX_COMBINED_UNIFORM_BLOCKS #define GL_MAX_UNIFORM_BUFFER_BINDINGS SB_GL_MAX_UNIFORM_BUFFER_BINDINGS #define GL_MAX_UNIFORM_BLOCK_SIZE SB_GL_MAX_UNIFORM_BLOCK_SIZE #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS \ SB_GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS \ SB_GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT SB_GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH \ SB_GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH #define GL_ACTIVE_UNIFORM_BLOCKS SB_GL_ACTIVE_UNIFORM_BLOCKS #define GL_UNIFORM_TYPE SB_GL_UNIFORM_TYPE #define GL_UNIFORM_SIZE SB_GL_UNIFORM_SIZE #define GL_UNIFORM_NAME_LENGTH SB_GL_UNIFORM_NAME_LENGTH #define GL_UNIFORM_BLOCK_INDEX SB_GL_UNIFORM_BLOCK_INDEX #define GL_UNIFORM_OFFSET SB_GL_UNIFORM_OFFSET #define GL_UNIFORM_ARRAY_STRIDE SB_GL_UNIFORM_ARRAY_STRIDE #define GL_UNIFORM_MATRIX_STRIDE SB_GL_UNIFORM_MATRIX_STRIDE #define GL_UNIFORM_IS_ROW_MAJOR SB_GL_UNIFORM_IS_ROW_MAJOR #define GL_UNIFORM_BLOCK_BINDING SB_GL_UNIFORM_BLOCK_BINDING #define GL_UNIFORM_BLOCK_DATA_SIZE SB_GL_UNIFORM_BLOCK_DATA_SIZE #define GL_UNIFORM_BLOCK_NAME_LENGTH SB_GL_UNIFORM_BLOCK_NAME_LENGTH #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS SB_GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES \ SB_GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER \ SB_GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER \ SB_GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER #define GL_INVALID_INDEX SB_GL_INVALID_INDEX #define GL_MAX_VERTEX_OUTPUT_COMPONENTS SB_GL_MAX_VERTEX_OUTPUT_COMPONENTS #define GL_MAX_FRAGMENT_INPUT_COMPONENTS SB_GL_MAX_FRAGMENT_INPUT_COMPONENTS #define GL_MAX_SERVER_WAIT_TIMEOUT SB_GL_MAX_SERVER_WAIT_TIMEOUT #define GL_OBJECT_TYPE SB_GL_OBJECT_TYPE #define GL_SYNC_CONDITION SB_GL_SYNC_CONDITION #define GL_SYNC_STATUS SB_GL_SYNC_STATUS #define GL_SYNC_FLAGS SB_GL_SYNC_FLAGS #define GL_SYNC_FENCE SB_GL_SYNC_FENCE #define GL_SYNC_GPU_COMMANDS_COMPLETE SB_GL_SYNC_GPU_COMMANDS_COMPLETE #define GL_UNSIGNALED SB_GL_UNSIGNALED #define GL_SIGNALED SB_GL_SIGNALED #define GL_ALREADY_SIGNALED SB_GL_ALREADY_SIGNALED #define GL_TIMEOUT_EXPIRED SB_GL_TIMEOUT_EXPIRED #define GL_CONDITION_SATISFIED SB_GL_CONDITION_SATISFIED #define GL_WAIT_FAILED SB_GL_WAIT_FAILED #define GL_SYNC_FLUSH_COMMANDS_BIT SB_GL_SYNC_FLUSH_COMMANDS_BIT #define GL_TIMEOUT_IGNORED SB_GL_TIMEOUT_IGNORED #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR SB_GL_VERTEX_ATTRIB_ARRAY_DIVISOR #define GL_ANY_SAMPLES_PASSED SB_GL_ANY_SAMPLES_PASSED #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE SB_GL_ANY_SAMPLES_PASSED_CONSERVATIVE #define GL_SAMPLER_BINDING SB_GL_SAMPLER_BINDING #define GL_RGB10_A2UI SB_GL_RGB10_A2UI #define GL_TEXTURE_SWIZZLE_R SB_GL_TEXTURE_SWIZZLE_R #define GL_TEXTURE_SWIZZLE_G SB_GL_TEXTURE_SWIZZLE_G #define GL_TEXTURE_SWIZZLE_B SB_GL_TEXTURE_SWIZZLE_B #define GL_TEXTURE_SWIZZLE_A SB_GL_TEXTURE_SWIZZLE_A #define GL_GREEN SB_GL_GREEN #define GL_BLUE SB_GL_BLUE #define GL_INT_2_10_10_10_REV SB_GL_INT_2_10_10_10_REV #define GL_TRANSFORM_FEEDBACK SB_GL_TRANSFORM_FEEDBACK #define GL_TRANSFORM_FEEDBACK_PAUSED SB_GL_TRANSFORM_FEEDBACK_PAUSED #define GL_TRANSFORM_FEEDBACK_ACTIVE SB_GL_TRANSFORM_FEEDBACK_ACTIVE #define GL_TRANSFORM_FEEDBACK_BINDING SB_GL_TRANSFORM_FEEDBACK_BINDING #define GL_PROGRAM_BINARY_RETRIEVABLE_HINT SB_GL_PROGRAM_BINARY_RETRIEVABLE_HINT #define GL_PROGRAM_BINARY_LENGTH SB_GL_PROGRAM_BINARY_LENGTH #define GL_NUM_PROGRAM_BINARY_FORMATS SB_GL_NUM_PROGRAM_BINARY_FORMATS #define GL_PROGRAM_BINARY_FORMATS SB_GL_PROGRAM_BINARY_FORMATS #define GL_COMPRESSED_R11_EAC SB_GL_COMPRESSED_R11_EAC #define GL_COMPRESSED_SIGNED_R11_EAC SB_GL_COMPRESSED_SIGNED_R11_EAC #define GL_COMPRESSED_RG11_EAC SB_GL_COMPRESSED_RG11_EAC #define GL_COMPRESSED_SIGNED_RG11_EAC SB_GL_COMPRESSED_SIGNED_RG11_EAC #define GL_COMPRESSED_RGB8_ETC2 SB_GL_COMPRESSED_RGB8_ETC2 #define GL_COMPRESSED_SRGB8_ETC2 SB_GL_COMPRESSED_SRGB8_ETC2 #define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 \ SB_GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 #define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 \ SB_GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 #define GL_COMPRESSED_RGBA8_ETC2_EAC SB_GL_COMPRESSED_RGBA8_ETC2_EAC #define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC \ SB_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC #define GL_TEXTURE_IMMUTABLE_FORMAT SB_GL_TEXTURE_IMMUTABLE_FORMAT #define GL_MAX_ELEMENT_INDEX SB_GL_MAX_ELEMENT_INDEX #define GL_NUM_SAMPLE_COUNTS SB_GL_NUM_SAMPLE_COUNTS #define GL_TEXTURE_IMMUTABLE_LEVELS SB_GL_TEXTURE_IMMUTABLE_LEVELS #endif // COBALT_RENDERER_EGL_AND_GLES_H_