blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
dd5a3f7f5f30d778882add63e5e6f5456d399c77
681dd06d092fb9af9639fdc2d9be897ffc260645
/Source/JCVoronoiPlugin/Private/JCVValueGenerator.cpp
83ee3f966e32942e4d7e89a0594724aa79286207
[ "MIT" ]
permissive
mengdada/JCVoronoiPlugin
5934675540a9307cbfc3f6613e231e9a00dd4839
25b309759160d52f44604f013e4551c6e597fa19
refs/heads/master
2020-05-15T23:07:18.883778
2019-04-03T22:15:20
2019-04-03T22:15:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,001
cpp
//////////////////////////////////////////////////////////////////////////////// // // MIT License // // Copyright (c) 2018-2019 Nuraga Wiswakarma // // 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 "JCVValueGenerator.h" #include "JCVDiagramAccessor.h" int32 FJCVValueGenerator::MarkFeature(FJCVDiagramMap& Map, TQueue<FJCVCell*>& cellQ, TSet<FJCVCell*>& ExclusionSet, FJCVCell& c, int32 i, const FJCVCellTraits& cond) { int32 count = 0; cellQ.Enqueue(&c); ExclusionSet.Emplace(&c); while (! cellQ.IsEmpty()) { FJCVCell* cell; cellQ.Dequeue(cell); FJCVEdge* g = cell->GetEdge(); check(g); if (cond.HasValidFeature(*cell)) { cell->SetType(cond.FeatureType, i); ++count; } else continue; do { FJCVCell* n = Map.GetCellNeighbour(g); if (! n) continue; if (ExclusionSet.Contains(n)) continue; if (cond.HasValidFeature(*n)) { ExclusionSet.Emplace(n); cellQ.Enqueue(n); } } while ((g = g->next) != nullptr); } return count; } void FJCVValueGenerator::AddRadialFill0(FJCVDiagramMap& Map, FRandomStream& Rand, FJCVCell& OriginCell, const FJCVRadialFill& FillParams) { check(Map.IsValidIndex(OriginCell.GetIndex())); float BaseValue = FillParams.Value; const float Radius = FillParams.Radius; const float Sharpness = FillParams.Sharpness; const bool bRadial = FillParams.bRadialDegrade; const bool bFilterBorder = FillParams.bFilterBorder; const bool bUseSharpness = Sharpness > KINDA_SMALL_NUMBER; TQueue<FJCVCell*> cellQ; TSet<FJCVCell*> ExclusionSet; OriginCell.Value = FMath::Min(OriginCell.Value+BaseValue, 1.f); ExclusionSet.Reserve(Map.Num()); ExclusionSet.Emplace(&OriginCell); cellQ.Enqueue(&OriginCell); while (! cellQ.IsEmpty() && BaseValue > .01f) { FJCVCell* cell; cellQ.Dequeue(cell); if (bRadial) { BaseValue = cell->Value; } BaseValue *= Radius; FJCVEdge* g = cell->GetEdge(); check(g); do { FJCVCell* n = Map.GetCellNeighbour(g); // Skip invalid or already visited cells if (! n || ExclusionSet.Contains(n)) { continue; } ExclusionSet.Emplace(n); cellQ.Enqueue(n); // Zero border cell values if required if (bFilterBorder && n->IsBorder()) { n->Value = 0.f; continue; } // Calculate new cell value float SharpnessModifier = 1.f; if (bUseSharpness) { SharpnessModifier = Rand.GetFraction() * Sharpness + 1.1f - Sharpness; } float CellValue = n->Value + BaseValue * SharpnessModifier; CellValue = FMath::Min(CellValue, 1.f); if (n->Value < CellValue) { n->Value = CellValue; } } while ((g = g->next) != nullptr); } } void FJCVValueGenerator::AddRadialFill(FJCVDiagramMap& Map, FRandomStream& Rand, FJCVCell& OriginCell, const FJCVRadialFill& FillParams) { if (FillParams.Radius < KINDA_SMALL_NUMBER) { return; } check(Map.IsValidIndex(OriginCell.GetIndex())); const FVector2D OriginPosition = OriginCell.ToVector2D(); const float Radius = FillParams.Radius; const float RadiusSq = Radius * Radius; const float InvRadius = 1.f / Radius; const bool bFilterBorder = FillParams.bFilterBorder; const UCurveFloat* ValueCurve = FillParams.ValueCurve; float BaseValue = FillParams.Value; // Cell queue and visited cell set TQueue<FJCVCell*> cellQ; TSet<FJCVCell*> cellS; // Assign base value to origin cell OriginCell.Value = BaseValue; cellS.Reserve(Map.Num()); cellS.Emplace(&OriginCell); cellQ.Enqueue(&OriginCell); while (! cellQ.IsEmpty()) { FJCVCell* cell; cellQ.Dequeue(cell); FJCVEdge* g = cell->GetEdge(); check(g); do { FJCVCell* n = Map.GetCellNeighbour(g); // Skip invalid or already visited cells if (! n || cellS.Contains(n)) { continue; } cellS.Emplace(n); float DistToOriginSq = (n->ToVector2D()-OriginPosition).SizeSquared(); // Skip cells outside of radius if (DistToOriginSq > RadiusSq) { continue; } cellQ.Enqueue(n); // Set border cell value to zero if filter is set if (bFilterBorder && n->IsBorder()) { n->Value = 0.f; continue; } // Calculate new cell value float ValueRatio = (1.f - FMath::Sqrt(DistToOriginSq) * InvRadius); if (ValueCurve) { ValueRatio = ValueCurve->GetFloatValue(ValueRatio); } n->Value = BaseValue * ValueRatio; } while ((g = g->next) != nullptr); } } void FJCVValueGenerator::MarkFeatures(FJCVDiagramMap& Map, const FJCVCellTraits& Cond, FJCVCellSet& ExclusionSet) { if (Map.IsEmpty()) { return; } TQueue<FJCVCell*> cellQ; const int32 cellN = Map.Num(); int32 f = 0; int32 n; do { FJCVCell* c = nullptr; n = 0; // Find single unmarked cell for (int32 i=0; i<cellN; ++i) if (Cond.HasUndefinedType(Map.GetCell(i))) c = &Map.GetCell(i); if (c) n = MarkFeature(Map, cellQ, ExclusionSet, *c, f++, Cond); } // Loop until there is no undefined cell left or no conversion made while (n > 0); } void FJCVValueGenerator::MarkFeatures(FJCVDiagramMap& Map, const FJCVSite& Seed, const FJCVCellTraits& Cond, int32 FeatureIndex, FJCVCellSet& ExclusionSet) { if (Map.IsEmpty()) { return; } const FJCVSite* s = &Seed; FJCVCell* c = Map.GetCell(s); if (c) { TQueue<FJCVCell*> cellQ; MarkFeature(Map, cellQ, ExclusionSet, *c, FeatureIndex, Cond); } } float FJCVValueGenerator::GetClosestDistanceFromCellSq( FJCVDiagramMap& Map, const FJCVCell& OriginCell, uint8 FeatureType, int32 FeatureIndex, bool bAgainstAnyType ) { check(Map.HasFeatureType(FeatureType)); check(Map.IsValidCell(&OriginCell)); const FVector2D Origin = OriginCell.ToVector2D(); float DistanceToFeatureSq = BIG_NUMBER; TFunctionRef<void(FJCVCell& Cell)> CellCallback( [&](FJCVCell& Cell) { const FVector2D CellPoint = Cell.ToVector2D(); const float CellDistSq = (CellPoint-Origin).SizeSquared(); if (CellDistSq < DistanceToFeatureSq) { DistanceToFeatureSq = CellDistSq; } } ); if (bAgainstAnyType) { Map.VisitCells(CellCallback, &OriginCell); } else { Map.VisitFeatureCells(CellCallback, FeatureType, FeatureIndex); } return DistanceToFeatureSq; } float FJCVValueGenerator::GetFurthestDistanceFromCellSq( FJCVDiagramMap& Map, const FJCVCell& OriginCell, uint8 FeatureType, int32 FeatureIndex, bool bAgainstAnyType ) { check(Map.HasFeatureType(FeatureType)); check(Map.IsValidCell(&OriginCell)); const FVector2D Origin = OriginCell.ToVector2D(); float DistanceToFeatureSq = TNumericLimits<float>::Min(); TFunctionRef<void(FJCVCell& Cell)> CellCallback( [&](FJCVCell& Cell) { const FVector2D CellPoint = Cell.ToVector2D(); const float CellDistSq = (CellPoint-Origin).SizeSquared(); if (CellDistSq > DistanceToFeatureSq) { DistanceToFeatureSq = CellDistSq; } } ); if (bAgainstAnyType) { Map.VisitCells(CellCallback, &OriginCell); } else { Map.VisitFeatureCells(CellCallback, FeatureType, FeatureIndex); } return DistanceToFeatureSq; } void FJCVValueGenerator::MapNormalizedDistanceFromCell( FJCVDiagramMap& Map, const FJCVCell& OriginCell, uint8 FeatureType, int32 FeatureIndex, bool bAgainstAnyType ) { check(Map.HasFeatureType(FeatureType)); check(Map.IsValidCell(&OriginCell)); const FVector2D Origin = OriginCell.ToVector2D(); const float FurthestDistanceFromCell = GetFurthestDistanceFromCell(Map, OriginCell, FeatureType, FeatureIndex, bAgainstAnyType); const float InvDistanceFromCell = 1.f / FMath::Max(FurthestDistanceFromCell, KINDA_SMALL_NUMBER); TFunctionRef<void(FJCVCell&)> CellCallback( [&](FJCVCell& Cell) { const FVector2D CellPoint = Cell.ToVector2D(); const float CellDist = (CellPoint-Origin).Size(); Cell.SetValue(CellDist * InvDistanceFromCell); } ); if (bAgainstAnyType) { Map.VisitCells(CellCallback, &OriginCell); } else { Map.VisitFeatureCells(CellCallback, FeatureType, FeatureIndex); } } void UJCVValueUtilityLibrary::SetCellValues(UJCVDiagramAccessor* Accessor, float Value) { if (! IsValid(Accessor)) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillAtPosition() ABORTED, INVALID ACCESSOR")); return; } if (! Accessor->HasValidMap()) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillAtPosition() ABORTED, INVALID ACCESOR MAP")); return; } FJCVDiagramMap& Map(Accessor->GetMap()); const int32 CellCount = Map.Num(); for (int32 i=0; i<CellCount; ++i) { Map.GetCell(i).SetValue(Value); } } void UJCVValueUtilityLibrary::AddRadialFillAtPosition(UJCVDiagramAccessor* Accessor, int32 Seed, const FVector2D& Position, FJCVRadialFill FillParams) { if (! IsValid(Accessor)) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillAtPosition() ABORTED, INVALID ACCESSOR")); return; } if (! Accessor->HasValidMap()) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillAtPosition() ABORTED, INVALID ACCESOR MAP")); return; } FJCVDiagramMap& Map(Accessor->GetMap()); FJCVCell* OriginCell = Map.GetCell(Map->Find(Position)); if (OriginCell) { FJCVValueGenerator::AddRadialFill(Map, Seed, *OriginCell, FillParams); } } void UJCVValueUtilityLibrary::AddRadialFillAtCell(UJCVDiagramAccessor* Accessor, int32 Seed, FJCVCellRef OriginCellRef, FJCVRadialFill FillParams) { if (! IsValid(Accessor)) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillAtCell() ABORTED, INVALID ACCESSOR")); return; } if (! Accessor->HasValidMap()) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillAtCell() ABORTED, INVALID ACCESOR MAP")); return; } if (! Accessor->IsValidCell(OriginCellRef)) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillAtCell() ABORTED, INVALID ORIGIN CELL")); return; } FJCVDiagramMap& Map(Accessor->GetMap()); FJCVCell& OriginCell(Map.GetCell(OriginCellRef.Data->GetIndex())); FJCVValueGenerator::AddRadialFill(Map, Seed, OriginCell, FillParams); } void UJCVValueUtilityLibrary::AddRadialFillByIndex(UJCVDiagramAccessor* Accessor, int32 Seed, int32 CellIndex, FJCVRadialFill FillParams) { if (! IsValid(Accessor)) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillByIndex() ABORTED, INVALID ACCESSOR")); return; } if (! Accessor->HasValidMap()) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillByIndex() ABORTED, INVALID ACCESOR MAP")); return; } FJCVDiagramMap& Map(Accessor->GetMap()); if (Map.IsValidIndex(CellIndex)) { FJCVCell& OriginCell(Map.GetCell(CellIndex)); FJCVValueGenerator::AddRadialFill(Map, Seed, OriginCell, FillParams); } } void UJCVValueUtilityLibrary::AddRadialFillNum(UJCVDiagramAccessor* Accessor, int32 Seed, int32 PointCount, FJCVRadialFill FillParams, float Padding, float ValueThreshold, int32 MaxPlacementTest) { if (! IsValid(Accessor)) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillNum() ABORTED, INVALID ACCESSOR")); return; } if (! Accessor->HasValidMap()) { UE_LOG(LogJCV,Error, TEXT("UJCVValueUtilityLibrary::AddRadialFillNum() ABORTED, INVALID ACCESOR MAP")); return; } if (PointCount < 1) { return; } FJCVDiagramMap& Map(Accessor->GetMap()); FRandomStream Rand(Seed); const float tMin = FMath::Clamp(ValueThreshold, 0.f, 1.f); const float tMax = 1.f-tMin; const int32 CellCount = Map.Num(); Padding = FMath::Clamp(Padding, 0.f, 1.f); FBox2D Bounds(Accessor->GetBounds()); FBox2D BoundsExpand(Bounds.Min*Padding, Bounds.Max*(1.f-Padding)); for (int32 it=0; it<PointCount; ++it) { for (int32 i=0; i<MaxPlacementTest; ++i) { int32 CellIdx = Rand.RandHelper(CellCount); FJCVCell& OriginCell(Map.GetCell(CellIdx)); if (OriginCell.Value < tMin && BoundsExpand.IsInside(OriginCell.ToVector2D())) { FillParams.Value *= tMax*Rand.GetFraction(); FillParams.Value += tMin; FJCVValueGenerator::AddRadialFill(Map, Rand, OriginCell, FillParams); break; } } } }
[ "kubis.padangpasir@gmail.com" ]
kubis.padangpasir@gmail.com
372cda4d3001bc77956d7874d8c9b11ca960ecc4
82886772b5b5a201979112790fe38b93755f810b
/src/Grid.cpp
918f1c06a83e19e9e4a3a18e9dd540ced8b1baa5
[]
no_license
wnguatem/Simple3DViewer
49fbcd8d2d1f749a06ea1db6c926b2863e9d72c1
87b2ff8fa357bc11272c50c9f9ccdeceb157b996
refs/heads/master
2021-01-18T22:33:33.447227
2016-02-04T16:54:38
2016-02-04T16:54:38
32,938,923
5
1
null
2016-06-01T17:50:14
2015-03-26T16:27:54
C++
UTF-8
C++
false
false
4,351
cpp
#include "Grid.h" #include "Game.h" #include "GameException.h" #include "Camera.h" #include "ColorHelper.h" #include "VectorHelper.h" #include "Utility.h" #include "VertexDeclarations.h" using namespace glm; namespace Library { //RTTI_DEFINITIONS(Grid) const GLuint Grid::DefaultSize = 50; const GLuint Grid::DefaultScale = 500; const vec4 Grid::DefaultColor = vec4(0.961f, 0.871f, 0.702f, 1.0f); Grid::Grid(Game& game, Camera& camera) : DrawableGameComponent(game), mVertexArrayObject(0), mVertexBuffer(0), mPosition(Vector3Helper::Zero), mSize(DefaultSize), mScale(DefaultScale), mColor(DefaultColor), mWorldMatrix(), mVertexCount(0), mContentFolder(game.getGameContentFolder()) { mCamera = &camera; } Grid::Grid(Game& game, Camera& camera, GLuint size, GLuint scale, const vec4& color) : DrawableGameComponent(game), mVertexArrayObject(0), mVertexBuffer(0), mPosition(Vector3Helper::Zero), mSize(size), mScale(scale), mColor(color), mWorldMatrix(), mContentFolder(game.getGameContentFolder()) { mCamera = &camera; } Grid::~Grid() { glDeleteBuffers(1, &mVertexBuffer); glDeleteVertexArrays(1, &mVertexArrayObject); } const vec3& Grid::Position() const { return mPosition; } const vec4& Grid::Color() const { return mColor; } const GLuint Grid::Size() const { return mSize; } const GLuint Grid::Scale() const { return mScale; } void Grid::SetPosition(const vec3& position) { mPosition = position; mWorldMatrix = translate(mat4(), mPosition); } void Grid::SetPosition(float x, float y, float z) { mPosition = vec3(x, y, z); mWorldMatrix = translate(mat4(), mPosition); } void Grid::SetColor(const vec4& color) { mColor = color; InitializeGrid(); } void Grid::SetSize(GLuint size) { mSize = size; InitializeGrid(); } void Grid::SetScale(GLuint scale) { mScale = scale; InitializeGrid(); } void Grid::Initialize() { //SetCurrentDirectory(Utility::ExecutableDirectory().c_str()); // Build the shader program std::vector<ShaderDefinition> shaders; shaders.push_back(ShaderDefinition(GL_VERTEX_SHADER, mContentFolder + "/BasicEffect.vert")); shaders.push_back(ShaderDefinition(GL_FRAGMENT_SHADER, mContentFolder + "/BasicEffect.frag")); mShaderProgram.BuildProgram(shaders); InitializeGrid(); // Create the vertex array object glGenVertexArrays(1, &mVertexArrayObject); mShaderProgram.Initialize(mVertexArrayObject); glBindVertexArray(0); } void Grid::Draw(const GameTime& gameTime) { glBindVertexArray(mVertexArrayObject); glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); mShaderProgram.Use(); mat4 wvp = mCamera->ViewProjectionMatrix() * mWorldMatrix; mShaderProgram.WorldViewProjection() << wvp; glLineWidth(4); glDrawArrays(GL_LINES, 0, mVertexCount); glBindVertexArray(0); } void Grid::InitializeGrid() { mVertexCount = (mSize + 1) * 4; //std::unique_ptr<VertexPositionColor> vertexData(new VertexPositionColor[mVertexCount]); //VertexPositionColor* vertices = vertexData.get(); //VertexPositionColor rrr[mVertexCount]; //VertexPositionColor *vertices = new VertexPositionColor(); //std::vector<VertexPositionColor> vertices(mVertexCount); std::vector<VertexPositionColor> vertices(mVertexCount); float adjustedScale = mScale * 0.1f; float maxPosition = mSize * adjustedScale / 2; for (unsigned int i = 0, j = 0; i < mSize + 1; i++, j = 4 * i) { float position = maxPosition - (i * adjustedScale); // Vertical line vertices[j] = VertexPositionColor(vec4(position, 0.0f, maxPosition, 1.0f), mColor); vertices[j + 1] = VertexPositionColor(vec4(position, 0.0f, -maxPosition, 1.0f), mColor); // Horizontal line vertices[j + 2] = VertexPositionColor(vec4(maxPosition, 0.0f, position, 1.0f), mColor); vertices[j + 3] = VertexPositionColor(vec4(-maxPosition, 0.0f, position, 1.0f), mColor); } glDeleteBuffers(1, &mVertexBuffer); mShaderProgram.CreateVertexBuffer(reinterpret_cast<VertexPositionColor*> (vertices.data()), mVertexCount, mVertexBuffer); // mShaderProgram.CreateVertexBuffer(vertices, mVertexCount, mVertexBuffer); // glDeleteBuffers(1, &mVertexBuffer);s //delete vertices; } }
[ "william.nguatem@googlemail.com" ]
william.nguatem@googlemail.com
bc1fd59320df8de2825bb16f58c4b2428e93270d
5e6637b14fa372049196b4fdbea0bd03ef6180cb
/oj题目/其他人/李春阳/P1058(S9789).cpp
22593aa107f91cdb768df60558a128a8085ee91f
[]
no_license
dangfugui/note-C
de1d9ad34b7ad5e804f41093a6fade408ac56ef5
0cfce2b3f06749312ef22e965bf29f6ed1783f0a
refs/heads/master
2020-06-23T13:41:00.370822
2016-09-10T14:24:26
2016-09-10T14:24:26
67,228,867
0
0
null
null
null
null
UTF-8
C++
false
false
606
cpp
#include"iostream" using namespace std; #include"cstring" int main () { int a,b; cin>>a>>b; string x[10002]; string y[1002]; for(int i=0;i<a;i++) { cin>>x[i]; } for(int j=0;j<b;j++) { cin>>y[j]; } for(int k=0;k<b;k++) { int q=0; for(int l=0;l<a;l++) { if(y[k]==x[l]) { cout<<"YES"<<endl; break; } else q++; if(q==a) cout<<"NO"<<endl; } } return 0; }
[ "dangfugui@163.com" ]
dangfugui@163.com
bb8402d568064b70e1536b152e54c902578f2699
d7c94f4a713aaf0fbb3dbb9b56c9f6945e0479c1
/URI Online Judge/uri2309.cpp
e78d5b4d834b7ec294a5f7027494c2e143a8f265
[]
no_license
fonte-nele/Competitive-Programming
2dabb4aab6ce2e6dc552885464fefdd485f9218c
faf0c6077ae0115f121968f7b70f4d68f9ce922b
refs/heads/master
2021-06-28T09:24:07.708562
2020-12-27T14:45:15
2020-12-27T14:45:15
193,268,717
3
0
null
null
null
null
UTF-8
C++
false
false
870
cpp
#include <cstdio> int getValue(int n) { switch (n) { case 4: return 0; case 5: return 1; case 6: return 2; case 7: return 3; case 12: return 4; case 11: return 5; case 13: return 6; case 1: return 7; case 2: return 8; case 3: return 9; } } bool wins(int a, int b) { return getValue(a) >= getValue(b); } int main() { int n; scanf("%d", &n); int a = 0; int b = 0; while (n--) { int _a = 0; int _b = 0; int p, q, r; int x, y, z; scanf("%d %d %d %d %d %d", &p, &q, &r, &x, &y, &z); if (wins(p, x)) _a++; else _b++; if (wins(q, y)) _a++; else _b++; if (wins(r, z)) _a++; else _b++; if (_a > _b) a++; else b++; } printf("%d %d\n", a, b); return 0; }
[ "felipephontinelly@hotmail.com" ]
felipephontinelly@hotmail.com
013e5d9fcf18c0d83a43c6e0b9c0e65ed2e0ea1f
9e6844d984c81fcd002c81452b5648585b90abaa
/tests/test.cpp
a5560119ab97c0066169990afc3d87d4bf7e9579
[]
no_license
siriusbetta/cpp_connector
5cc0edd8388dc74af9b48e4f7086ca1d54f9521d
ea13cfd9993b2d087ed443472af5c5355db760a1
refs/heads/master
2021-07-03T18:04:44.967981
2017-09-26T14:33:33
2017-09-26T14:33:33
104,113,909
0
0
null
null
null
null
UTF-8
C++
false
false
375
cpp
#define CATCH_CONFIG_MAIN #include <../include/Catch/include/catch.hpp> unsigned int Factorial( unsigned int number) { return number <= 1 ? number : Factorial(number - 1) * number; } TEST_CASE( "Factorial are computed", "[factorial]") { REQUIRE( Factorial(1) == 1 ); REQUIRE( Factorial(2) == 2 ); REQUIRE( Factorial(3) == 6 ); REQUIRE( Factorial(10) == 3628800); }
[ "conan85@inbox.ru" ]
conan85@inbox.ru
a8a67ec51302ad45b4f4eb4106a419e95b7cb259
220529721e151c6cc088ebecf4d3c19fd4716df3
/AtCoder/abc157/C.cpp
7f0a5afc11a610f215b9c0373fcd6b498f835b68
[ "MIT" ]
permissive
jahid-coder/competitive-programming
baa2311796e3ffad3ded4789e43f4f37b95673ef
e7878de2445019c916404238180959dc9308ed4a
refs/heads/master
2023-08-26T10:13:57.816451
2021-10-18T04:26:32
2021-10-18T04:26:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,307
cpp
/**************************************************** * Template for coding contests * * Author : Sanjeev Sharma * * Email : thedevelopersanjeev@gmail.com * *****************************************************/ #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("no-stack-protector,fast-math") #pragma GCC target ("sse4") #pragma comment(linker, "/stack:200000000") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define deb(x) cout << #x << " is " << x << "\n"; using namespace std; using namespace __gnu_pbds; const double PI = 2 * acos(0.0); const long long INF = 1e18L + 5; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, s, c; cin >> n >> m; vector<int> num(n, -1); while (m--) { cin >> s >> c; if (num[--s] != -1 && num[s] != c || n > 1 && !s && !c) { cout << -1 << '\n'; return 0; } num[s] = c; } for (int i = 0; i < n; ++i) cout << (num[i] == -1 ? (n > 1 && !i) : num[i]); cout << '\n'; return 0; }
[ "thedevelopersanjeev@gmail.com" ]
thedevelopersanjeev@gmail.com
cb1eb0501767f445c5a99cafa187d820ac86107c
9be246df43e02fba30ee2595c8cec14ac2b355d1
/public/inetgraph.h
50a5fd4c00f793ee08e615c4e9724d9d2e46509d
[]
no_license
Clepoy3/LeakNet
6bf4c5d5535b3824a350f32352f457d8be87d609
8866efcb9b0bf9290b80f7263e2ce2074302640a
refs/heads/master
2020-05-30T04:53:22.193725
2019-04-12T16:06:26
2019-04-12T16:06:26
189,544,338
18
5
null
2019-05-31T06:59:39
2019-05-31T06:59:39
null
UTF-8
C++
false
false
1,602
h
//======== (C) Copyright 1999, 2000 Valve, L.L.C. All rights reserved. ======== // // The copyright to the contents herein is the property of Valve, L.L.C. // The contents may be used and/or copied only with the written permission of // Valve, L.L.C., or in accordance with the terms and conditions stipulated in // the agreement/contract under which the contents have been supplied. // // Purpose: // // $Workfile: $ // $Date: $ // //----------------------------------------------------------------------------- // $Log: $ // // $NoKeywords: $ //============================================================================= #if !defined( INETGRAPH_H ) #define INETGRAPH_H #ifdef _WIN32 #pragma once #endif class INetGraph { public: virtual int GetOutgoingSequence( void ) = 0; virtual int GetIncomingSequence( void ) = 0; virtual int GetUpdateWindowSize( void ) = 0; virtual int GetUpdateWindowMask( void ) = 0; virtual bool IsFrameValid( int frame_number ) = 0; virtual float GetFrameReceivedTime( int frame_number ) = 0; virtual float GetFrameLatency( int frame_number ) = 0; virtual int GetFrameBytes( int frame_number, const char *fieldName ) = 0; virtual void GetAverageDataFlow( float *incoming, float *outgoing ) = 0; virtual float GetCommandInterpolationAmount( int command_number ) = 0; virtual bool GetCommandSent( int command_number ) = 0; virtual int GetCommandSize( int command_number ) = 0; }; extern INetGraph *netgraph; #define VNETGRAPH_INTERFACE_VERSION "VNETGRAPH001" #endif // INETGRAPH_H
[ "uavxp29@gmail.com" ]
uavxp29@gmail.com
c0ba5e02dbe26de3c9ba7dd4817d85064b84f00f
06bf3efc9b3b8f5968509e279ec0dd5285f19537
/test/utilities/testUtils.hpp
b57f2f54778971f5f4e5686033f37afcd5cdfece
[ "BSD-3-Clause" ]
permissive
jiridanek/Strongtalk
0a87c0eb5281702df6d8c3a927403dc2a7402f72
ee19957341abe4b2113378394806b18ed329bc07
refs/heads/master
2021-05-30T14:09:38.537071
2016-01-10T10:34:47
2016-01-10T10:34:47
42,392,327
2
1
null
null
null
null
UTF-8
C++
false
false
157
hpp
#define as_large_integer(value) \ byteArrayPrimitives::largeIntegerFromSmallInteger(as_smiOop(value), klassOop(Universe::find_global("LargeInteger")))
[ "steve@vimes.worldonline.co.uk" ]
steve@vimes.worldonline.co.uk
898dcd49d9c180ed6870b8798b7d8230765e71e9
42e6482f57a8d3506987621607b5e9d2719c903e
/bo2k/scr/commandloop.cpp
059fd317b2eaa3f6a8e3293e9bd28fdce003df58
[]
no_license
baiyfcu/BO2K
216ce061bea7cd2f5ad01e2eed3fb703adc5a3b4
c9df1bf1def0005640ccd879d1a7c720ac237bf2
refs/heads/master
2020-03-21T19:29:52.886208
2018-03-01T16:48:53
2018-03-01T16:48:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,965
cpp
/* Back Orifice 2000 - Remote Administration Suite Copyright (C) 1999, Cult Of The Dead Cow This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA The author of this program may be contacted at dildog@l0pht.com. */ #include<windows.h> #include<auth.h> #include<iohandler.h> #include<encryption.h> #include<bocomreg.h> #include<commnet.h> #include<commandloop.h> #include<config.h> // ---------------- Global variables ---------------- CIOHandler *g_pIOHandler; CEncryptionHandler *g_pEncryptionHandler; CAuthHandler *g_pAuthHandler; CAuthSocket *g_pCommSock[MAX_COMMAND_SOCKETS]; CAuthSocket *g_pConnSock[MAX_COMMAND_CONNECTIONS]; int g_nCommCount, g_nConnCount; #ifdef NDEBUG char g_szStartupOptions[]= "<**CFG**>Startup\0" "S[8]:Init Cmd Net Type=TCPIO\0\0\0\0" "S[48]:Init Cmd Bind Str=\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "S[8]:Init Cmd Encryption=XOR\0\0\0\0\0\0" "S[8]:Init Cmd Auth=NULLAUTH\0" "N[0,5000000]:Idle Timeout (ms)=60000\0\0"; #else char g_szStartupOptions[]= "<**CFG**>Startup\0" "S[8]:Init Cmd Net Type=TCPIO\0\0\0\0" "S[48]:Init Cmd Bind Str=54320\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "S[8]:Init Cmd Encryption=XOR\0\0\0\0\0\0" "S[8]:Init Cmd Auth=NULLAUTH\0" "N[0,5000000]:Idle Timeout (ms)=60000\0\0"; #endif BOOL g_bBO2KFinished; // Set this to -TRUE- when you want to exit BO2K // ---------------- Function implementations -------------------- BOOL StartupCommandHandlers(void) { char svParam[256]; // Initialize primary command socket g_nCommCount=0; g_nConnCount=0; svParam[0]='\0'; // Don't even start up unless user has configured a port to talk on. // This keeps the 31337 phenomena from happening. char *bindstr=GetCfgStr(g_szStartupOptions,"Init Cmd Bind Str"); if(bindstr==NULL) return FALSE; if(bindstr[0]=='\0') { return FALSE; } CAuthSocket *cas; do { cas=ListenAuthSocket(NULL,0,NULL, bindstr, GetCfgStr(g_szStartupOptions,"Init Cmd Net Type"), GetCfgStr(g_szStartupOptions,"Init Cmd Encryption"), GetCfgStr(g_szStartupOptions,"Init Cmd Auth")); if(cas!=NULL && cas!=(CAuthSocket *)0xFFFFFFFF) { g_pCommSock[g_nCommCount]=cas; g_nCommCount++; return TRUE; } Sleep(100); } while(cas!=NULL && cas!=(CAuthSocket *)0xFFFFFFFF); return FALSE; } void ShutdownCommandHandlers(void) { int i; // Close all connections for(i=0;i<g_nConnCount;i++) { g_pConnSock[i]->Close(); delete g_pConnSock[i]; } // Terminate all bound sockets for(i=0;i<g_nCommCount;i++) { g_pCommSock[i]->Close(); delete g_pCommSock[i]; } } void CommandHandlerLoop(void) { BYTE *buffer; int buflen,ret,i,j; DWORD dwLastTime,dwTimeout; BOOL bIdle; // Start the command handlers if(StartupCommandHandlers()==FALSE) return; // Lower Thread Priority SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_NORMAL); // Command handler loop g_bBO2KFinished=FALSE; dwLastTime=GetTickCount(); dwTimeout=GetCfgNum(g_szStartupOptions,"Idle Timeout (ms)"); bIdle=FALSE; while(!g_bBO2KFinished) { if(dwTimeout!=0) { if(!bIdle && ((GetTickCount()-dwLastTime)>dwTimeout)) { SetPriorityClass(GetCurrentProcess(),IDLE_PRIORITY_CLASS); SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_IDLE); bIdle=TRUE; } } // Sift through bound sockets looking for connections for(i=0; i<g_nCommCount; i++) { CAuthSocket *cas; cas=g_pCommSock[i]->Accept(); if(cas!=NULL) { if(g_nConnCount<MAX_COMMAND_CONNECTIONS) { dwLastTime=GetTickCount(); if(bIdle) { SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS); SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_NORMAL); bIdle=FALSE; } g_pConnSock[g_nConnCount]=cas; g_nConnCount++; } else { cas->Close(); delete cas; } } } // Sift through active connections pulling commands // and removing dead connections for(i=(g_nConnCount-1);i>=0;i--) { ret=g_pConnSock[i]->Recv(&buffer,&buflen); if(ret<0) { // Must be dead. Kill. g_pConnSock[i]->Close(); delete g_pConnSock[i]; for(j=i;j<(g_nConnCount-1);j++) { g_pConnSock[j]=g_pConnSock[j+1]; } g_pConnSock[j]=NULL; g_nConnCount--; } else if(ret==0) { // Nothing here, move along } else { dwLastTime=GetTickCount(); if(bIdle) { SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS); SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_LOWEST); bIdle=FALSE; } // Command received int cmdlen,command,comid,nArg1; char *svArg2,*svArg3; BreakDownCommand(buffer, &cmdlen, &command, &comid, &nArg1, &svArg2, &svArg3); if(cmdlen==buflen) { DispatchCommand(command, g_pConnSock[i],comid,nArg1,svArg2,svArg3); } // Free command memory g_pConnSock[i]->Free(buffer); } } Sleep(20); } // Terminate command handlers ShutdownCommandHandlers(); }
[ "jeremyngalloway@gmail.com" ]
jeremyngalloway@gmail.com
6e1dd40574260400141e45f94645e47eb64b3d86
d1f3fd80b11190ac54f0dbcb5366c05e855d2d61
/ameba_tools_macosx/tools/macosx/src/postbuild_img2_arduino_macosx.cpp
8a5a7dd8fa2f2e6725e583dbd2b081e5545f78c1
[]
no_license
DistyDevice/Arduino
14c5f1dfd03d096ad29f6f221776d00eca845c18
cf5a864ee9011da6c294bebbf38167b2ded6dc50
refs/heads/master
2022-04-06T06:38:53.801243
2020-03-03T03:42:24
2020-03-03T03:42:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,092
cpp
/* Compile command: g++ -o postbuild_img2_arduino_macosx tools/macosx/src/postbuild_img2_arduino_macosx.cpp */ #include <iostream> #include <sstream> #include <cstring> #include <cstdlib> #include <fstream> #include <unistd.h> #include <vector> using namespace std; int main(int argc, char *argv[]) { int ret = 0; stringstream cmdss; string cmd, line, msg; vector<string> lines; vector<string>::iterator iter; string path_tool; string path_arm_none_eabi_gcc; string path_symbol_black_list; string bksym; ifstream fin; bool has_sdram = false; string sram_start_st = "", sram_end_st = "", sdram_start_st = "", sdram_end_st = ""; unsigned int sram_start = 0, sram_end = 0, sdram_start = 0, sdram_end = 0; size_t pos; // 0. change work folder chdir(argv[1]); // 1. copy elf application.axf to current folder cmdss.clear(); cmdss << "cp " << argv[2] << " ./"; getline(cmdss, cmd); cout << cmd << endl; system(cmd.c_str()); // 2. remove previous files cmd = "rm -f application.map"; cout << cmd << endl; system(cmd.c_str()); cmd = "rm -f application.asm"; cout << cmd << endl; system(cmd.c_str()); cmd = "rm -f *.bin"; cout << cmd << endl; system(cmd.c_str()); // 3. generate information files path_arm_none_eabi_gcc.assign(argv[3]); cmdss.clear(); cmdss << path_arm_none_eabi_gcc << "arm-none-eabi-nm --numeric-sort application.axf > application.map"; getline(cmdss, cmd); cout << cmd << endl; system(cmd.c_str()); fin.open("application.map"); while( getline(fin, line) ) { lines.push_back(line); } fin.close(); cmdss.clear(); cmdss << path_arm_none_eabi_gcc << "arm-none-eabi-objdump -d application.axf > application.asm"; getline(cmdss, cmd); cout << cmd << endl; system(cmd.c_str()); // 3.1 check if any forbidden symbols path_symbol_black_list.assign(argv[4]); fin.open(path_symbol_black_list.c_str(), ifstream::in); cout << path_symbol_black_list << endl; ret = 0; if (fin) { while ( !fin.eof() && ret == 0) { fin >> bksym; getline(fin, msg); // check if this symbole appears in the map file for (iter = lines.begin(); iter != lines.end(); ++iter) { if ( (iter->find(bksym)) != string::npos ) { cerr << endl << "ERROR: " << msg << endl << endl; ret = -1; break; } } } } fin.close(); if (ret != 0) { return -1; } // 4. grep sram and sdram information for (iter = lines.begin(); iter != lines.end(); ++iter) { line = *iter; pos = line.find("__ram_image2_text_start__"); if ( pos != string::npos ) { sram_start_st = line.substr(0, pos-3); sram_start = strtol(sram_start_st.c_str(), NULL, 16); } pos = line.find("__ram_image2_text_end__"); if ( pos != string::npos ) { sram_end_st = line.substr(0, pos-3); sram_end = strtol(sram_end_st.c_str(), NULL, 16); } pos = line.find("__sdram_data_start__"); if ( pos != string::npos ) { sdram_start_st = line.substr(0, pos-3); sdram_start = strtol(sdram_start_st.c_str(), NULL, 16); } pos = line.find("__sdram_data_end__"); if ( pos != string::npos ) { sdram_end_st = line.substr(0, pos-3); sdram_end = strtol(sdram_end_st.c_str(), NULL, 16); } } if (sdram_start > 0 && sdram_end > 0) { has_sdram = true; } cout << "sram " << sram_start_st << " ~ " << sram_end_st << endl; if (has_sdram) { cout << "sdram " << sdram_start_st << " ~ " << sdram_end_st << endl; } // 5. generate image 2 and image 3 cmdss.clear(); cmdss << path_arm_none_eabi_gcc << "arm-none-eabi-objcopy -j .image2.start.table -j .ram_image2.text -j .ram.data -Obinary ./application.axf ./ram_2.bin"; getline(cmdss, cmd); cout << cmd << endl; system(cmd.c_str()); if (has_sdram) { cmdss.clear(); cmdss << path_arm_none_eabi_gcc << "arm-none-eabi-objcopy -j .image3 -j .sdr_data -Obinary ./application.axf ./sdram.bin"; getline(cmdss, cmd); cout << cmd << endl; system(cmd.c_str()); } // 6. fulfill header cmdss.clear(); cmdss << "./tools/macosx/pick " << sram_start << " " << sram_end << " ram_2.bin ram_2.p.bin body+reset_offset+sig"; getline(cmdss, cmd); cout << cmd << endl; system(cmd.c_str()); cmdss.clear(); cmdss << "./tools/macosx/pick " << sram_start << " " << sram_end << " ram_2.bin ram_2.ns.bin body+reset_offset"; getline(cmdss, cmd); cout << cmd << endl; system(cmd.c_str()); if (has_sdram) { cmdss.clear(); cmdss << "./tools/macosx/pick " << sdram_start << " " << sdram_end << " sdram.bin ram_3.p.bin body+reset_offset"; getline(cmdss, cmd); cout << cmd << endl; system(cmd.c_str()); } // 7. prepare image 1 cmd = "cp bsp/image/ram_1.p.bin ./"; cout << cmd << endl; system(cmd.c_str()); cmd = "./tools/macosx/padding 44k 0xFF ram_1.p.bin"; cout << cmd << endl; system(cmd.c_str()); // 8. generate ram_all.bin if (has_sdram) { cmd = "cat ram_1.p.bin ram_2.p.bin ram_3.p.bin > ram_all.bin"; cout << cmd << endl; system(cmd.c_str()); cmd = "cat ram_2.ns.bin ram_3.p.bin > ota.bin"; cout << cmd << endl; system(cmd.c_str()); } else { cmd = "cat ram_1.p.bin ram_2.p.bin > ram_all.bin"; cout << cmd << endl; system(cmd.c_str()); cmd = "cat ram_2.ns.bin > ota.bin"; cout << cmd << endl; system(cmd.c_str()); } // 9. add checksum cmd = "./tools/macosx/checksum ota.bin"; cout << cmd << endl; system(cmd.c_str()); return 0; }
[ "william_lai@realtek.com" ]
william_lai@realtek.com
9c10235056bb6e516ead4ea4784b251664b39ca4
19ad5c2df2a3950cc5dbe837df2e7be2e1d21081
/Warehouse.cpp
fac34f11842a7fcd77247e70fe8e97e8d87f5a34
[]
no_license
frederik1904/kattis
8cd593367b6e4f74c0c3530d643f9c75d6757863
a6846c5d7176e904b2e43d7f515c18f5abe7786c
refs/heads/master
2021-07-15T04:09:44.442471
2021-07-03T18:08:04
2021-07-03T18:08:04
195,087,312
0
0
null
null
null
null
UTF-8
C++
false
false
1,635
cpp
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct nameValue { int amount = 0; string name; } ; bool compareName(const nameValue &a, const nameValue &b) { if (a.amount == b.amount) { int minLen = a.name.length() < b.name.length() ? a.name.length() : b.name.length(); for (int i = 0; i < minLen; i++) { if (a.name.at(i) != b.name.at(i)) { return a.name.at(i) < b.name.at(i); } } return a.name.length() < b.name.length(); } else { return a.amount > b.amount; } } int main(int argc, char *argv[]) { int testCases, products, value; string str; cin >> testCases; for (int j = 0; j < testCases; j++) { vector<nameValue> names; cin >> products; for (int k = 0; k < products; k++) { cin >> str >> value; bool found = false; for (int i = 0; i < names.size(); i++) { if (names.at(i).name.compare(str) == 0) { names.at(i).amount += value; found = true; break; } } if (!found) { nameValue n; n.name = str; n.amount = value; names.push_back(n); } } sort(names.begin(), names.end(), compareName); cout << names.size() << endl; for (int i = 0; i < names.size(); i++) { cout << names.at(i).name << " " << names.at(i).amount << endl; } } }
[ "Frederik1904@gmail.com" ]
Frederik1904@gmail.com
288e65b6ec463dc190bbb58e70db91ada6ee9663
10587620d1875a32090a9145a9f4cf6ed83d54e2
/天气预报查询系统/WeatherQuery/keybutton.cpp
2eb1299a21790c9f62434d585849e598e64d86e4
[]
no_license
zhengzebin525/LINUX-Environmental-programming
2eab34cfdcc959e92224b2eda696d20907f68fef
18952913a36e73a3352b4af3dcf8494eac83029a
refs/heads/master
2020-04-16T04:08:35.759680
2019-07-07T14:20:00
2019-07-07T14:20:00
165,257,064
4
11
null
null
null
null
UTF-8
C++
false
false
721
cpp
#include "keybutton.h" #include <QApplication> #include <QKeyEvent> KeyButton::KeyButton(QWidget *parent):QPushButton(parent) { //当按下自己的时候,给自己发一个信号 ,至此自己类中的click_buton()函数 connect(this,SIGNAL(clicked(bool)),this,SLOT(click_button())); } void KeyButton::click_button() { //整个文件就算俺就本身,所以只要获取自身text,就算所在按钮的text QString str = this->text(); char keyvale = str.at(0).toLatin1(); //定义按钮事件 QKeyEvent *key = new QKeyEvent(QKeyEvent::KeyPress,keyvale,Qt::NoModifier,str); //发送事件 QApplication::postEvent(QApplication::focusWidget(),key); }
[ "noreply@github.com" ]
zhengzebin525.noreply@github.com
5c5cd8e873b497912a17077f1049a73930ace82a
898c4e7e2c2e4024f7376da729fec0c9aa694e02
/C_Algorithm/chapter01/Q18.cpp
25d52a990dbf25cb8ddb6510d2ee876c6fd319b8
[]
no_license
blue-monkey0/C
f847088563947ff305ce01736d85a385b8f1903f
8b859b26c0d5f7d68cc01eec18d17579fa4521a9
refs/heads/main
2023-02-23T16:27:01.242229
2021-01-29T00:29:16
2021-01-29T00:29:16
null
0
0
null
null
null
null
UHC
C++
false
false
402
cpp
#include <stdio.h> void nrpira(int n) { int i, j; for (i = 1; i <= n; i++) { for (j = 1; j <= i - 1; j++) putchar(' '); for (j = 1; j <= (n - i) * 2 + 1; j++) printf("%d", i % 10); putchar('\n'); } } int main(void) { int n; puts("n단의 숫자 피라미드를 출력하겠습니다."); do { printf("몇 단? : "); scanf_s("%d", &n); } while (n <= 0); nrpira(n); return 0; }
[ "geon0599@cu.ac.kr" ]
geon0599@cu.ac.kr
86ced8b916a05bfbe0a2505c10335a536190ea4b
2ba7eac6d92fd7a9ddfe29a66cf099b30a86b9c4
/Project2/P2-1/gtest.cpp
c776e6539dbc1be7fe764ed52fa696a3baed1eb6
[]
no_license
LiaoJJ/COP6726-Database-System-Implementation
746b82c7c8b3a3f9d8d530fab8fac05dbc1a7698
36770a6ab09cf924a98fb9ed393ddb0c5aaa82f2
refs/heads/main
2023-04-20T23:19:34.491291
2021-04-25T18:55:40
2021-04-25T18:55:40
332,445,285
6
7
null
null
null
null
UTF-8
C++
false
false
4,403
cpp
#include "gtest/gtest.h" #include <iostream> #include "Record.h" #include "DBFile.h" #include "DBFile.cc" #include "BigQ.h" #include "BigQ.cc" #include <stdlib.h> using namespace std; class BigQTest : public ::testing::Test { protected: BigQTest() { // You can do set-up work for each test here. } ~BigQTest() override { // You can do clean-up work that doesn't throw exceptions here. } void SetUp() override { // Code here will be called immediately after the constructor (right // before each test). // file.Open(1, "localTest/region.bin"); } void TearDown() override { // Code here will be called immediately after each test (right // before the destructor). // file.Close(); } // File file; char* regionFileName = "localTest/region.bin"; char* lineitemFileName = "localTest/lineitem.bin"; char* testFileName = "localTest/test.bin"; }; TEST_F(BigQTest, UpdateTopRecordForRunTest) { // RecordComparer* comparer = new RecordComparer(new OrderMaker); File file; file.Open(1, regionFileName); class Run* run = new class Run(&file, 0, 1); Page bufferPage; file.GetPage(&bufferPage, 0); Record tempRecord; bufferPage.GetFirst(&tempRecord); while (bufferPage.GetFirst(&tempRecord) == 1) { EXPECT_EQ(run->UpdateTopRecord(), 1); } EXPECT_EQ(run->UpdateTopRecord(), 0); file.Close(); } TEST_F(BigQTest, RecordComparerTest) { File file; file.Open(1, regionFileName); //Initiate the proority queue for recard comparer Schema* scheme = new Schema("catalog", "region"); OrderMaker* order = new OrderMaker(scheme); priority_queue<Record*, vector<Record*>, RecordComparer> recordQueue (order); ComparisonEngine comparisonEngine; //Puting records into comparer based priority queue Page bufferPage; file.GetPage(&bufferPage, 0); Record* readindRecord = new Record; while (bufferPage.GetFirst(readindRecord)) { recordQueue.push(readindRecord); readindRecord = new Record; } bufferPage.EmptyItOut(); file.GetPage(&bufferPage, 0); Record rec[2]; Record *last = NULL, *prev = NULL; int i = 0; while (bufferPage.GetFirst(&rec[i%2]) == 1) { prev = last; last = &rec[i%2]; if (prev && last) { EXPECT_EQ(comparisonEngine.Compare(prev, last, order), -1); } i++; } file.Close(); } TEST_F(BigQTest, RunComparerTest) { //Initiate the proority queue for recard comparer File file; file.Open(1, lineitemFileName); Schema* scheme = new Schema("catalog", "lineitem"); OrderMaker* order = new OrderMaker(scheme); priority_queue<class Run*, vector<class Run*>, RunComparer> runQueue (order); ComparisonEngine comparisonEngine; class Run* run1 = new class Run(&file, 0, 1); class Run* run2 = new class Run(&file, 1, 1); runQueue.push(run1); runQueue.push(run2); //Take top record from two different run Record one, two; one.Copy(runQueue.top()->topRecord); runQueue.pop(); two.Copy(runQueue.top()->topRecord); runQueue.pop(); EXPECT_EQ(comparisonEngine.Compare(&one, &two, order), -1); file.Close(); } TEST_F(BigQTest, recordToRunTest) { //Reading records from file to queue File file; file.Open(1, regionFileName); Schema* scheme = new Schema("catalog", "region"); OrderMaker* order = new OrderMaker(scheme); priority_queue<Record*, vector<Record*>, RecordComparer> recordQueue (order); ComparisonEngine comparisonEngine; Page bufferPage; file.GetPage(&bufferPage, 0); Record* readindRecord = new Record; while (bufferPage.GetFirst(readindRecord)) { recordQueue.push(readindRecord); readindRecord = new Record; } //Writing records from queue to run File testFile; testFile.Open(0, testFileName); Page testPage; //Initiate the proority queue for recard comparer int pageIndex = 0; priority_queue<class Run*, vector<class Run*>, RunComparer> runQueue (order); recordQueueToRun(recordQueue, runQueue, file, bufferPage, pageIndex); EXPECT_EQ(recordQueue.size(), 0); EXPECT_EQ(runQueue.size(), 1); file.Close(); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
[ "519312579@qq.com" ]
519312579@qq.com
0d8e2320247f371fe294586c45ef7084544ba93e
7eae27dba7482faa734cfaea2b566f40ee938e86
/PostMidsemLab_3/Black_White.cpp
4976366c2c07f252d8bd63261211a54fb7bb84f7
[]
no_license
anshumankr001/CS204
a4da12e984f61df5bba5bebb1c79db8714530ec5
efe611277e79fdd15daff1512b98dcff51f855af
refs/heads/master
2020-06-28T20:34:20.914439
2019-11-14T04:51:43
2019-11-14T04:51:43
200,335,114
3
3
null
null
null
null
UTF-8
C++
false
false
1,959
cpp
#include <bits/stdc++.h> #define f(i, a, b) for(int i=a; i<b; i++) using namespace std; int visited[10000][10000]; int input[10000][10000]; int COUNT; bool is_valid(int, int, int, int, int); void BFS(int, int, int, int, int, int); void reset_visited(int, int); void func(int, int); int main() { int n, m, k, a, b; cin>>n>>m>>k; while(k--) { cin>>a>>b; input[a-1][b-1] = 1; } func(n, m); return 0; } bool is_valid(int x, int y, int c, int n, int m) { if (x < n && y < m && x >= 0 && y >= 0) { if (visited[x][y] == false && input[x][y] == c) return true; else return false; } else return false; } void BFS(int x, int y, int i, int j, int n, int m) { if (x != y) return; visited[i][j] = 1; COUNT++; int x_move[] = { 0, 0, 1, -1 }; int y_move[] = { 1, -1, 0, 0 }; f(u, 0, 4) if (is_valid(i + y_move[u], j + x_move[u], x, n, m)) BFS(x, y, i + y_move[u], j + x_move[u], n, m); } void reset_visited(int n, int m) { f(i, 0, n) { f(j, 0, m) visited[i][j] = 0; } } void func(int n, int m) { int current_max = INT_MIN, x; f(i, 0, n) { f(j, 0, m) { if(input[i][j] == 1) { reset_visited(n, m); COUNT = 0; if (j + 1 < m) BFS(input[i][j], input[i][j + 1], i, j, n, m); if (COUNT >= current_max) { current_max = COUNT; x = input[i][j]; } reset_visited(n, m); COUNT = 0; if (i + 1 < n) BFS(input[i][j], input[i + 1][j], i, j, n, m); if (COUNT >= current_max) { current_max = COUNT; x = input[i][j]; } } } } if(current_max == 0) current_max++; cout<<current_max<<endl; }
[ "noreply@github.com" ]
anshumankr001.noreply@github.com
61b9d2a7d8ec3cc44a705922c59a4a5e05adfe49
050b2e7566af61eba7983e2a38a32c34c48b07bb
/balancer/service/center/src/handle/server/SyncServiceRsp.cc
ee65a35499c3935512e916a4dba2418003760d5a
[]
no_license
coolulu/balancer
2e4084f57ad57c9613e5bc96f3d550d84360d9be
2d214dcefb149ba60622b035e280b2ee7a2958bb
refs/heads/master
2021-06-26T20:43:30.713616
2019-02-13T13:49:20
2019-02-13T13:49:20
132,157,585
1
0
null
2018-07-22T02:40:28
2018-05-04T15:28:11
C++
UTF-8
C++
false
false
1,214
cc
#include "SyncServiceRsp.h" #include "log/Log.h" SyncServiceRsp::SyncServiceRsp(Proc& proc, const muduo::net::TcpConnectionPtr& conn, PacketPtr& packet_ptr, muduo::Timestamp time) : _proc(proc), _conn(conn), _packet_ptr(packet_ptr), _time(time) { } SyncServiceRsp::~SyncServiceRsp() { } void SyncServiceRsp::handle(const center::CenterMsg& msg) { const center::SyncServiceReq& req = msg.sync_service_req(); B_LOG_INFO << "conf_update_time=" << req.conf_update_time(); std::string conf_json; unsigned long long update_time = _proc._sc.get_config_derivative().update_time; if(update_time != req.conf_update_time()) { conf_json = _proc._sc.map_to_json(); B_LOG_INFO << "update update_time=" << update_time << ", conf_json=" << conf_json; } else { B_LOG_INFO << "not update conf_json"; } PacketPtr packet_ptr_rsp(new Packet(_packet_ptr->_from_service_id, 0, _packet_ptr->_app_id, _packet_ptr->_app_version, _packet_ptr->_conn_seq_id, _packet_ptr->_msg_seq_id)); CenterStack::SyncServiceRsp(packet_ptr_rsp->_body, common::SUCCESS, "", update_time, conf_json); _proc._tcp_server.send_msg(_conn, packet_ptr_rsp); }
[ "757533566@qq.com" ]
757533566@qq.com
8023c3c92b9261ac91719046e7ff43d1c456bd8c
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
/hackathon/hanchuan/sscope/FlyCapture2/src/FlyCapture2GUI/Format7DrawingArea.cpp
96b0a471f48323af694a71c83e972ababdde511d
[ "MIT" ]
permissive
Vaa3D/vaa3d_tools
edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9
e6974d5223ae70474efaa85e1253f5df1814fae8
refs/heads/master
2023-08-03T06:12:01.013752
2023-08-02T07:26:01
2023-08-02T07:26:01
50,527,925
107
86
MIT
2023-05-22T23:43:48
2016-01-27T18:19:17
C++
WINDOWS-1252
C++
false
false
18,920
cpp
//============================================================================= // Copyright © 2008 Point Grey Research, Inc. All Rights Reserved. // // This software is the confidential and proprietary information of Point // Grey Research, Inc. ("Confidential Information"). You shall not // disclose such Confidential Information and shall use it only in // accordance with the terms of the license agreement you entered into // with PGR. // // PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE // SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE LIABLE FOR ANY DAMAGES // SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING // THIS SOFTWARE OR ITS DERIVATIVES. //============================================================================= //============================================================================= // $Id: Format7DrawingArea.cpp,v 1.27 2010/08/05 22:16:18 soowei Exp $ //============================================================================= #include "Precompiled.h" #include "Format7DrawingArea.h" #include <vector> namespace FlyCapture2 { Format7DrawingArea::Format7DrawingArea( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& /*refGlade*/ ) : Gtk::DrawingArea(cobject), m_moveCursor( Gdk::FLEUR ) { Gdk::EventMask mask = Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::POINTER_MOTION_MASK; set_events( mask ); m_leftMBHeld = false; m_rightMBHeld = false; m_left = 0; m_top = 0; m_width = 0; m_height = 0; m_lastFiredLeft = 0; m_lastFiredTop = 0; m_lastFiredWidth = 0; m_lastFiredHeight = 0; m_maxWidth = 0; m_maxHeight = 0; m_offsetHStepSize = 0; m_offsetVStepSize = 0; m_imageHStepSize = 0; m_imageVStepSize = 0; m_startX = 0; m_startY = 0; m_offsetX = 0; m_offsetY = 0; m_currX = 0; m_currY = 0; m_imageSizeChanged = false; } Format7DrawingArea::~Format7DrawingArea() { } sigc::signal<void, unsigned int, unsigned int, unsigned int, unsigned int> Format7DrawingArea::signal_image_size_changed() { return m_signal_image_size_changed; } bool Format7DrawingArea::on_expose_event( GdkEventExpose* event ) { Glib::RefPtr<Gdk::Window> window = get_window(); if( window == NULL) { return true; } Cairo::RefPtr<Cairo::Context> refCairo = window->create_cairo_context(); // clip to the area indicated by the expose event so that we only redraw // the portion of the window that needs to be redrawn refCairo->rectangle( event->area.x, event->area.y, event->area.width, event->area.height); refCairo->clip(); // Get width / height of widget int width; int height; window->get_size( width, height ); // Figure out which scale to use (horizontal or vertical) const float horzScale = m_maxWidth / (float)width; const float vertScale = m_maxHeight / (float)height; m_previewScale = (horzScale < vertScale) ? vertScale : horzScale; Gtk::AspectFrame* pFrame = (Gtk::AspectFrame*)get_parent(); float fRatio = m_maxWidth / (float)m_maxHeight; if ( fRatio != pFrame->property_ratio()) { pFrame->set( 0.0, 0.0, fRatio, false ); } unsigned int scaledLeft = static_cast<unsigned int>(ToScaled( m_left )); unsigned int scaledTop = static_cast<unsigned int>(ToScaled( m_top )); unsigned int scaledWidth = static_cast<unsigned int>(ToScaled( m_width )); unsigned int scaledHeight = static_cast<unsigned int>(ToScaled( m_height )); // Fill the background with the PGR color FillBackground( refCairo, event->area.x, event->area.y, event->area.width, event->area.height); // Draw the data on top of the filled background DrawRectangle( refCairo, scaledLeft, scaledTop, scaledWidth, scaledHeight ); DrawDashedLines( refCairo, scaledLeft, scaledTop, scaledWidth, scaledHeight ); DrawImageDimensionsText( refCairo, m_left, m_top, m_width, m_height ); DrawCurrentCursorPositionText( refCairo, m_currX, m_currY ); if ( m_imageSizeChanged == true ) { if ( m_left != m_lastFiredLeft || m_top != m_lastFiredTop || m_width != m_lastFiredWidth || m_height != m_lastFiredHeight ) { m_signal_image_size_changed( m_left, m_top, m_width, m_height ); m_lastFiredLeft = m_left; m_lastFiredTop = m_top; m_lastFiredWidth = m_width; m_lastFiredHeight = m_height; } m_imageSizeChanged = false; } return true; } void Format7DrawingArea::FillBackground( Cairo::RefPtr<Cairo::Context> refCairo, unsigned int left, unsigned int top, unsigned int width, unsigned int height ) { refCairo->save(); refCairo->rectangle( left, top, width, height ); const double divisor = 255.0; const double red = 157.0 / divisor; const double green = 184.0 / divisor; const double blue = 210.0 / divisor; refCairo->set_source_rgb( red, green, blue ); refCairo->fill(); refCairo->restore(); } void Format7DrawingArea::DrawRectangle( Cairo::RefPtr<Cairo::Context> refCairo, unsigned int left, unsigned int top, unsigned int width, unsigned int height ) { refCairo->save(); // Set draw color refCairo->set_source_rgb(1.0, 0.0, 0.0); // Set line width refCairo->set_line_width(1.0); // Draw the image rectangle refCairo->rectangle( left, top, width, height ); refCairo->stroke(); refCairo->restore(); } void Format7DrawingArea::DrawDashedLines( Cairo::RefPtr<Cairo::Context> refCairo, unsigned int left, unsigned int top, unsigned int width, unsigned int height ) { refCairo->save(); // Get width / height of widget int windowWidth; int windowHeight; get_window()->get_size( windowWidth, windowHeight ); // Set the dash parameters std::vector<double> dash_vector(2); dash_vector[0] = 4.0; dash_vector[1] = 2.0; refCairo->set_dash( dash_vector, 0.0 ); // Set draw color refCairo->set_source_rgb(0.0, 0.0, 0.0); // Set line width refCairo->set_line_width(1.0); refCairo->move_to( left, top ); refCairo->line_to( left, 0 ); refCairo->move_to( left, top ); refCairo->line_to( 0, top ); refCairo->move_to( left + width, top + height ); refCairo->line_to( left + width, windowHeight ); refCairo->move_to( left + width, top + height ); refCairo->line_to( windowWidth, top + height ); refCairo->stroke(); refCairo->restore(); } void Format7DrawingArea::DrawImageDimensionsText( Cairo::RefPtr<Cairo::Context> refCairo, unsigned int left, unsigned int top, unsigned int width, unsigned int height ) { refCairo->save(); // Set the font parameters refCairo->select_font_face( "monospace", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD ); refCairo->set_font_size( 10 ); // Set draw color to black refCairo->set_source_rgb(0.0, 0.0, 0.0); // Get width / height of widget int widgetWidth = 0; int widgetHeight = 0; get_window()->get_size( widgetWidth, widgetHeight ); // Create text for image offset char imageOffsets[128]; sprintf( imageOffsets, "Start: (%d,%d) End: (%d,%d)", left, top, left + width, top + height ); Cairo::TextExtents offsetExtents; refCairo->get_text_extents(imageOffsets, offsetExtents); // Draw the offset text refCairo->move_to( (widgetWidth/2) - (offsetExtents.width/2), (widgetHeight/2) - offsetExtents.height - (offsetExtents.height/2)); refCairo->show_text( imageOffsets ); // Create text for image dimensions char imageDimensions[128]; sprintf( imageDimensions, "Dimensions: %d x %d", width, height); Cairo::TextExtents dimensionsExtents; refCairo->get_text_extents(imageDimensions, dimensionsExtents); // Draw the dimensions text refCairo->move_to( (widgetWidth/2) - (dimensionsExtents.width/2), (widgetHeight/2) + dimensionsExtents.height + (dimensionsExtents.height/2)); refCairo->show_text( imageDimensions ); refCairo->restore(); } void Format7DrawingArea::DrawCurrentCursorPositionText( Cairo::RefPtr<Cairo::Context> refCairo, unsigned int currX, unsigned int currY ) { refCairo->save(); // Set the font parameters refCairo->select_font_face( "monospace", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD ); refCairo->set_font_size( 10 ); // Set draw color to black refCairo->set_source_rgb(0.0, 0.0, 0.0); // Print current cursor position char cursorPosition[128]; sprintf( cursorPosition, "Cursor: (%d, %d)", currX, currY ); // Get width / height of widget int width; int height; get_window()->get_size( width, height ); Cairo::TextExtents textExtents; refCairo->get_text_extents( cursorPosition, textExtents ); refCairo->move_to( (width / 2) - (textExtents.width / 2), (height * 0.9) - (textExtents.height / 2) ); refCairo->show_text( cursorPosition ); refCairo->restore(); } bool Format7DrawingArea::on_button_press_event( GdkEventButton* event ) { gdouble startX = event->x; gdouble startY = event->y; ClipPoint( &startX, &startY ); unsigned int startXOrig = ToOriginal( (float)startX ); unsigned int startYOrig = ToOriginal( (float)startY ); switch ( event->button ) { case 1: // Store the start point m_startX = startXOrig; m_startY = startYOrig; m_leftMBHeld = true; break; case 3: get_window()->set_cursor( m_moveCursor ); // Store the difference between the start point and the left/top m_offsetX = m_left - startXOrig; m_offsetY = m_top - startYOrig; m_rightMBHeld = true; break; } return true; } bool Format7DrawingArea::on_button_release_event( GdkEventButton* event ) { gdouble endX = event->x; gdouble endY = event->y; ClipPoint( &endX, &endY ); const unsigned int endXOrig = ToOriginal( (float)endX ); const unsigned int endYOrig = ToOriginal( (float)endY ); switch ( event->button ) { case 1: m_left = std::min(m_startX, endXOrig); m_top = std::min(m_startY, endYOrig); m_width = std::max(m_startX, endXOrig) - m_left; m_height = std::max(m_startY, endYOrig) - m_top; ClampAllValues(); m_imageSizeChanged = true; m_leftMBHeld = false; break; case 3: get_window()->set_cursor(); m_rightMBHeld = false; break; } queue_draw(); return true; } bool Format7DrawingArea::on_motion_notify_event( GdkEventMotion* event ) { gdouble currX = event->x; gdouble currY = event->y; // This may actually be negative if the mouse is dragged to the // left or top of the image, so ints should be used instead of // unsigned ints to prevent overflow int currXOrig = 0; int currYOrig = 0; if ( m_leftMBHeld == true ) { ClipPoint( &currX, &currY ); currXOrig = ToOriginal( static_cast<float>(currX) ); currYOrig = ToOriginal( static_cast<float>(currY) ); if ( currXOrig <= static_cast<int>(m_startX) ) { m_left = currXOrig; m_width = m_startX - m_left; } else { m_left = m_startX; m_width = currXOrig - m_left; } if ( currYOrig <= static_cast<int>(m_startY) ) { m_top = currYOrig; m_height = m_startY - m_top; } else { m_top = m_startY; m_height = currYOrig - m_top; } ClampAllValues(); m_imageSizeChanged = true; } else if ( m_rightMBHeld == true ) { currXOrig = ToOriginal( static_cast<float>(currX) ); currYOrig = ToOriginal( static_cast<float>(currY) ); // Perform some initial calculations to make sure that the // left and top values are not overflowing if ( currXOrig + m_offsetX < 0 ) { m_left = 0; } else { m_left = currXOrig + m_offsetX; } if ( currYOrig + m_offsetY < 0 ) { m_top = 0; } else { m_top = currYOrig + m_offsetY; } ClampAllValues(); // Ensure we are still within the boundaries if ( m_left + m_width > m_maxWidth ) { m_left = m_maxWidth - m_width; } else if ( m_left + m_width < m_width ) { m_left = 0; } if ( m_top + m_height > m_maxHeight ) { m_top = m_maxHeight - m_height; } else if ( m_top + m_height < m_height ) { m_top = 0; } m_imageSizeChanged = true; } else { ClipPoint( &currX, &currY ); currXOrig = ToOriginal( static_cast<float>(currX) ); currYOrig = ToOriginal( static_cast<float>(currY) ); } // Store the current cursor coordinates m_currX = currXOrig; m_currY = currYOrig; queue_draw(); return true; } void Format7DrawingArea::UpdateSettings( Format7Info* pFmt7Info, Format7ImageSettings* pImageSettings ) { // Maximum resolution m_maxWidth = pFmt7Info->maxWidth; m_maxHeight = pFmt7Info->maxHeight; // Step sizes m_offsetHStepSize = pFmt7Info->offsetHStepSize; m_offsetVStepSize = pFmt7Info->offsetVStepSize; m_imageHStepSize = pFmt7Info->imageHStepSize; m_imageVStepSize = pFmt7Info->imageVStepSize; m_left = pImageSettings->offsetX; m_top = pImageSettings->offsetY; m_width = pImageSettings->width; m_height = pImageSettings->height; queue_draw(); } void Format7DrawingArea::UpdateSettings( GigEImageSettingsInfo* pImageInfo, GigEImageSettings* pImageSettings ) { // Maximum resolution m_maxWidth = pImageInfo->maxWidth; m_maxHeight = pImageInfo->maxHeight; // Step sizes m_offsetHStepSize = pImageInfo->offsetHStepSize; m_offsetVStepSize = pImageInfo->offsetVStepSize; m_imageHStepSize = pImageInfo->imageHStepSize; m_imageVStepSize = pImageInfo->imageVStepSize; m_left = pImageSettings->offsetX; m_top = pImageSettings->offsetY; m_width = pImageSettings->width; m_height = pImageSettings->height; queue_draw(); } unsigned int Format7DrawingArea::ClampValue( unsigned int inputVal, unsigned int stepSize ) { if ( inputVal % stepSize != 0 ) { return inputVal - (inputVal % stepSize); } else { return inputVal; } } void Format7DrawingArea::ClampAllValues() { m_left = ClampValue( m_left, m_offsetHStepSize ); m_top = ClampValue( m_top, m_offsetVStepSize ); m_width = ClampValue( m_width, m_imageHStepSize ); m_height = ClampValue( m_height, m_imageVStepSize ); } void Format7DrawingArea::ClipPoint( gdouble* x, gdouble* y ) { // Get window size int width; int height; get_window()->get_size( width, height ); if ( *x < 0 ) { *x = 0; } else if ( *x > width ) { *x = width; } if ( *y < 0 ) { *y = 0; } else if ( *y > height ) { *y = height; } } float Format7DrawingArea::ToScaled( int original ) { return original / m_previewScale; } int Format7DrawingArea::ToOriginal( float scaled ) { return static_cast<int>(scaled * m_previewScale); } }
[ "hanchuan.peng@gmail.com" ]
hanchuan.peng@gmail.com
7652f2ba92279e36fdf58beeedadbfc28dee8181
b77326e5dd7afd7ca08019958c924aee6bcba550
/iBeacon/iBeacon.ino
00c23bf876b72c7bebfb50fef22f0d468d862d4a
[]
no_license
tmatz/bean-experiments
950bfe218510214f609140e78cc8640316899993
5171b2294ff643d2ed2038b1c49ae348793d8db7
refs/heads/master
2021-01-17T15:46:56.502055
2016-10-10T08:09:40
2016-10-10T08:09:40
69,889,562
0
0
null
null
null
null
UTF-8
C++
false
false
212
ino
void setup() { Bean.enableConfigSave(false); Bean.setAdvertisingInterval(1000); Bean.setBeaconParameters(0xDEAD, 0xBEEF, 0xCAFE); Bean.setBeaconEnable(true); } void loop() { Bean.sleep(0xFFFFFFFF); }
[ "t.matsuda.1000@gmail.com" ]
t.matsuda.1000@gmail.com
ce78da355c11b0593d68e2259e3862ddc5809de6
5b70406792ce4203c6895a13948e282fb909d1d9
/SaveTheGoozesSolution/SaveTheGoozesLib/SaveTheGoozesLib.cpp
64d0eeb4a47dc13efc629e90fa997db624da6425
[]
no_license
Rivaus/Save-The-Goozes-Game
918f673c863f0495bab732cea0d3b76409a70de6
faaf4098fb728f46daa3b80fd0fbc120ef64eead
refs/heads/master
2020-05-30T12:14:31.010619
2019-07-02T21:54:27
2019-07-02T21:54:27
189,728,024
1
0
null
null
null
null
UTF-8
C++
false
false
836
cpp
// SaveTheGoozesLib.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include "pch.h" #include <iostream> int main() { std::cout << "Hello World!\n"; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
[ "quentin.tran25@orange.fr" ]
quentin.tran25@orange.fr
4e3f4b20ee8c0cda628457b83582e40577e02ee7
2962f164cecb440ecd905ab9f3cc569c03a01ad5
/RtspPlayer/assemblies/sunell/include/MultiTripWireAbility.h
107116e9f0e55f2c5bdb42e2db36d19be682d7f6
[]
no_license
paxan222/hello-world
5ef9bd04a5c4337c1403a04973e2c0c11665bb26
c55c60e0f72a04e1e2560dc19c2a6bbd7e8b430f
refs/heads/master
2020-12-11T21:09:30.200433
2017-05-04T08:39:53
2017-05-04T08:39:53
55,044,669
0
1
null
null
null
null
GB18030
C++
false
false
28,790
h
#ifndef _MULTITRIPWIREABILITY_H_ #define _MULTITRIPWIREABILITY_H_ #include "SNPlatOS.h" #include "DomainConst.h" #include <string> /**********************************************************************/ //此处用于控制文件编译字节对齐,拷贝时两行注释间内容需一起拷贝, //结束处的“#ifdef PRAGMA_PACK”部分也要一起拷贝,否则pragma pack入栈出栈不匹配 #if(PRAGMA_PACK_DEFINE != 10000) # error Not included "SNPlatOS.h". #endif #ifdef PRAGMA_PACK #ifdef WIN32 #pragma pack(push, PRAGMA_PACK_CHAR) #endif #ifndef WIN32 #ifndef _PACKED_1_ #define _PACKED_1_ __attribute__((packed, aligned(PRAGMA_PACK_CHAR))) // for gcc #endif #else #ifndef _PACKED_1_ #define _PACKED_1_ #endif #endif #else #ifndef _PACKED_1_ #define _PACKED_1_ #endif #endif /**********************************************************************/ class SN_DLL_API MultiTripWireAbility { public: MultiTripWireAbility(); ~MultiTripWireAbility(); MultiTripWireAbility& operator=(const MultiTripWireAbility& p_objMultiTripWireAbility); /*********************************************************************** * 概述:设置提供双绊线(MultiTripWire)功能的智能库的ID * 输入: * p_nLibId :智能库ID * 输出: * 无 * 返回值: * 无 * 功能正文: * 输入的智能库ID需要跟能力列表的库ID匹配,不然将视为非法的ID, * 功能无法正常启用。 ************************************************************************/ void setLibId(const int p_nLibId); /*********************************************************************** * 概述:获取提供双绊线(MultiTripWire)功能的智能库的ID * 输入: * 无 * 输出: * 无 * 返回值: * const int : 当前提供该功能的智能库ID * 功能正文: * 返回的库ID是当前设备提供该智能分析功能的库ID ************************************************************************/ const int getLibId() const; /*********************************************************************** * 概述:设置分析区域能力是否支持 * 输入: * p_bRegionEnable :是否支持该项能力 * 输出: * 无 * 返回值: * 无 * 功能正文: * 输入为true : 支持该项能力; * 输入为false : 不支持该项能力。 ************************************************************************/ void setRegionEnable(const bool p_bRegionEnable); /*********************************************************************** * 概述:获取分析区域能力是否支持 * 输入: * 无 * 输出: * 无 * 返回值: * bool : 如果启用,返回true; * 如果不启用,返回false。 * 功能正文: * 无 ************************************************************************/ const bool getRegionEnable() const; /*********************************************************************** * 概述:设置支持的分析区域个数 * 输入: * p_nEdgeNum :分析区域个数 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setEdgeNum(const int p_nEdgeNum); /*********************************************************************** * 概述:获取支持的分析区域个数 * 输入: * 无 * 输出: * 无 * 返回值: * int : 支持的分析区域个数 * 功能正文: * 无 ************************************************************************/ const int getEdgeNum() const; /*********************************************************************** * 概述:设置最多支持的分析区域个数 * 输入: * p_nMaxRegionNum :最多支持的分析区域个数 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setMaxRegionNum(const int p_nMaxRegionNum); /*********************************************************************** * 概述:获取最多支持的分析区域个数 * 输入: * 无 * 输出: * 无 * 返回值: * int : 最多支持的分析区域个数 * 功能正文: * 无 ************************************************************************/ const int getMaxRegionNum() const; /*********************************************************************** * 概述:设置是否获取详细信息的能力是否支持 * 输入: * p_bDetailGetEnable :是否支持该能力 * 输出: * 无 * 返回值: * 无 * 功能正文: * 输入true,支持; * 输入false,不支持。 ************************************************************************/ void setDetailGetEnable(const bool p_bDetailGetEnable); /*********************************************************************** * 概述:获取是否获取详细信息的能力的是否支持 * 输入: * 无 * 输出: * 无 * 返回值: * bool : 如果支持,返回true; * 如果不支持,返回false。 * 功能正文: * 无 ************************************************************************/ const bool getDetailGetEnable() const; /*********************************************************************** * 概述:设置双绊线(MultiTripWire)能力是否支持 * 输入: * p_bEnable :是否支持该项能力 * 输出: * 无 * 返回值: * 无 * 功能正文: * 输入为true : 支持该项能力; * 输入为false : 不支持该项能力。 ************************************************************************/ void setEnable(const bool p_bEnable); /*********************************************************************** * 概述:获取双绊线(MultiTripWire)能力是否支持 * 输入: * 无 * 输出: * 无 * 返回值: * bool : 如果支持,返回true; * 如果不支持,返回false。 * 功能正文: * 无 ************************************************************************/ const bool getEnable() const; /*********************************************************************** * 概述:设置是否支持目标最大尺寸 * 输入: * p_bMaxTargetSizeEnable :是否支持 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setMaxTargetSizeEnable(const bool p_bMaxTargetSizeEnable); /*********************************************************************** * 概述:获取是否支持目标最大尺寸 * 输入: * 无 * 输出: * 无 * 返回值: * bool :返回true,支持; * 返回false,不支持。 * 功能正文: * 无 ************************************************************************/ const bool getMaxTargetSizeEnable() const; /*********************************************************************** * 概述:设置目标最大尺寸的最大值 * 输入: * p_nMaxTargetSizeMax :目标最大尺寸的最大值 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setMaxTargetSizeMax(const int p_nMaxTargetSizeMax); /*********************************************************************** * 概述:获取目标最大尺寸的最大值 * 输入: * 无 * 输出: * 无 * 返回值: * int :目标最大尺寸的最大值 * 功能正文: * 无 ************************************************************************/ const int getMaxTargetSizeMax() const; /*********************************************************************** * 概述:设置目标最大尺寸的最小值 * 输入: * p_nMaxTargetSizeMin :目标最大尺寸的最小值 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setMaxTargetSizeMin(const int p_nMaxTargetSizeMin); /*********************************************************************** * 概述:获取目标最大尺寸的最小值 * 输入: * 无 * 输出: * 无 * 返回值: * int :目标最大尺寸的最小值 * 功能正文: * 无 ************************************************************************/ const int getMaxTargetSizeMin() const; /*********************************************************************** * 概述:设置目标最大尺寸的单位 * 输入: * p_pMaxTargetSizeUnit :目标最大尺寸的单位 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ bool setMaxTargetSizeUnit(const char* p_pMaxTargetSizeUnit); /*********************************************************************** * 概述:获取目标最大尺寸的单位 * 输入: * 无 * 输出: * 无 * 返回值: * string :目标最大尺寸的单位 * 功能正文: * 无 ************************************************************************/ const char* getMaxTargetSizeUnit() const; /*********************************************************************** * 概述:设置是否支持目标最小尺寸 * 输入: * p_bMinTargetSizeEnable :是否支持 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setMinTargetSizeEnable(const bool p_bMinTargetSizeEnable); /*********************************************************************** * 概述:获取是否支持目标最小尺寸 * 输入: * 无 * 输出: * 无 * 返回值: * bool :返回true,支持; * 返回false,不支持。 * 功能正文: * 无 ************************************************************************/ const bool getMinTargetSizeEnable() const; /*********************************************************************** * 概述:设置目标最小尺寸的最大值 * 输入: * p_nMinTargetSizeMax :目标最小尺寸的最大值 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setMinTargetSizeMax(const int p_nMinTargetSizeMax); /*********************************************************************** * 概述:获取目标最小尺寸的最大值 * 输入: * 无 * 输出: * 无 * 返回值: * int :目标最小尺寸的最大值 * 功能正文: * 无 ************************************************************************/ const int getMinTargetSizeMax() const; /*********************************************************************** * 概述:设置目标最小尺寸的最小值 * 输入: * p_nMinTargetSizeMin :目标最小尺寸的最小值 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setMinTargetSizeMin(const int p_nMinTargetSizeMin); /*********************************************************************** * 概述:获取目标最小尺寸的最小值 * 输入: * 无 * 输出: * 无 * 返回值: * int :目标最小尺寸的最小值 * 功能正文: * 无 ************************************************************************/ const int getMinTargetSizeMin() const; /*********************************************************************** * 概述:设置目标最小尺寸的单位 * 输入: * p_pMinTargetSizeUnit :目标最小尺寸的单位 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ bool setMinTargetSizeUnit(const char* p_pMinTargetSizeUnit); /*********************************************************************** * 概述:获取目标最小尺寸的单位 * 输入: * 无 * 输出: * 无 * 返回值: * string :目标最小尺寸的单位 * 功能正文: * 无 ************************************************************************/ const char* getMinTargetSizeUnit() const; /*********************************************************************** * 概述:设置是否限定目标大小的能力的支持与否 * 输入: * p_bTargetSizeConstrainEnable :是否支持该功能 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setTargetSizeConstrainEnable(const bool p_bTargetSizeConstrainEnable); /*********************************************************************** * 概述:获取是否限定目标大小的能力的支持与否 * 输入: * 无 * 输出: * 无 * 返回值: * bool : 支持,返回true; * 不支持,返回false。 * 功能正文: * 无 ************************************************************************/ const bool getTargetSizeConstrainEnable() const; /*********************************************************************** * 概述:设置限定目标大小的最大值 * 输入: * p_nTargetSizeConstrainMin :限定目标大小的最大值 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setTargetSizeConstrainMax(const int p_nTargetSizeConstrainMax); /*********************************************************************** * 概述:获取限定目标大小的最大值 * 输入: * 无 * 输出: * 无 * 返回值: * int : 限定目标大小的最大值 * 功能正文: * 无 ************************************************************************/ const int getTargetSizeConstrainMax() const; /*********************************************************************** * 概述:设置限定目标大小的最小值 * 输入: * p_nTargetSizeConstrainMin :限定目标大小的最小值 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setTargetSizeConstrainMin(const int p_nTargetSizeConstrainMin); /*********************************************************************** * 概述:获取限定目标大小的最小值 * 输入: * 无 * 输出: * 无 * 返回值: * int : 限定目标大小的最小值 * 功能正文: * 无 ************************************************************************/ const int getTargetSizeConstrainMin() const; /*********************************************************************** * 概述:设置限定目标大小的单位 * 输入: * p_nTargetSizeConstrainMin :限定目标大小的单位 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ bool setTargetSizeConstrainUnit(const char* p_pTargetSizeConstrainUnit); /*********************************************************************** * 概述:获取限定目标大小的单位 * 输入: * 无 * 输出: * 无 * 返回值: * string :限定目标大小的单位 * 功能正文: * 无 ************************************************************************/ const char* getTargetSizeConstrainUnit() const; /*********************************************************************** * 概述:设置限定目标类型的能力的支持与否 * 输入: * p_bTargetTypeConstrainEnable :是否支持该能力 * 输出: * 无 * 返回值: * 无 * 功能正文: * 目标类型指人、车等。 * 如果支持,表示只侦测设置的类型(如人、车等) ************************************************************************/ void setTargetTypeConstrainEnable(const bool p_bTargetTypeConstrainEnable); /*********************************************************************** * 概述:获取是否支持限定目标类型 * 输入: * 无 * 输出: * 无 * 返回值: * bool : 如果支持,返回true; * 如果不支持,返回false。 * 功能正文: * 目标类型指人、车等。 ************************************************************************/ const bool getTargetTypeConstrainEnable() const; /*********************************************************************** * 概述:设置目标类型的最大尺寸 * 输入: * p_nTargetTypeConstrainMin :目标类型的最大尺寸 * 输出: * 无 * 返回值: * 无 * 功能正文: * 目标类型指人、车等。 ************************************************************************/ void setTargetTypeConstrainMax(const int p_nTargetTypeConstrainMax); /*********************************************************************** * 概述:获取目标类型的最大尺寸 * 输入: * 无 * 输出: * 无 * 返回值: * int : 目标类型的最大尺寸 * 功能正文: * 目标类型指人、车等。 ************************************************************************/ const int getTargetTypeConstrainMax() const; /*********************************************************************** * 概述:设置目标类型的最小尺寸 * 输入: * p_nTargetTypeConstrainMin :目标类型的最小尺寸 * 输出: * 无 * 返回值: * 无 * 功能正文: * 目标类型指人、车等。 ************************************************************************/ void setTargetTypeConstrainMin(const int p_nTargetTypeConstrainMin); /*********************************************************************** * 概述:获取目标类型的最小尺寸 * 输入: * 无 * 输出: * 无 * 返回值: * int : 目标类型的最小尺寸 * 功能正文: * 目标类型指人、车等。 ************************************************************************/ const int getTargetTypeConstrainMin() const; /*********************************************************************** * 概述:设置目标类型尺寸的单位 * 输入: * p_pTargetTypeConstrainUnit :目标类型尺寸的单位 * 输出: * 无 * 返回值: * 无 * 功能正文: * 目标类型指人、车等。 ************************************************************************/ bool setTargetTypeConstrainUnit(const char* p_pTargetTypeConstrainUnit); /*********************************************************************** * 概述:设置目标类型尺寸的单位 * 输入: * 无 * 输出: * 无 * 返回值: * string : 目标类型尺寸的单位 * 功能正文: * 目标类型指人、车等。 ************************************************************************/ const char* getTargetTypeConstrainUnit() const; /*********************************************************************** * 概述:设置限定类型能力的支持与否 * 输入: * p_bTargetTypeEnable :是否支持限定类型能力 * 输出: * 无 * 返回值: * 无 * 功能正文: * 支持限定类型,表示支持限定人、车等类型的能力。 ************************************************************************/ void setTargetTypeEnable(const bool p_bTargetTypeEnable); /*********************************************************************** * 概述:获取限定类型能力的支持与否 * 输入: * 无 * 输出: * 无 * 返回值: * bool : 返回true,支持该能力; * 返回false,不支持。 * 功能正文: * 支持限定类型,表示支持限定人、车等类型的能力。 ************************************************************************/ const bool getTargetTypeEnable() const; /*********************************************************************** * 概述:设置限定类型的尺寸的最大值 * 输入: * p_nTargetTypeMax :限定类型的尺寸的最大值 * 输出: * 无 * 返回值: * 无 * 功能正文: * 支持限定类型,表示支持限定人、车等类型的能力。 ************************************************************************/ void setTargetTypeMax(const int p_nTargetTypeMax); /*********************************************************************** * 概述:获取限定类型的尺寸的最大值 * 输入: * 无 * 输出: * 无 * 返回值: * int : 限定类型的尺寸的最大值 * 功能正文: * 支持限定类型,表示支持限定人、车等类型的能力。 ************************************************************************/ const int getTargetTypeMax() const; /*********************************************************************** * 概述:设置限定类型的尺寸的最小值 * 输入: * p_nTargetTypeMin :限定类型的尺寸的最小值 * 输出: * 无 * 返回值: * 无 * 功能正文: * 支持限定类型,表示支持限定人、车等类型的能力。 ************************************************************************/ void setTargetTypeMin(const int p_nTargetTypeMin); /*********************************************************************** * 概述:获取限定类型的尺寸的最小值 * 输入: * 无 * 输出: * 无 * 返回值: * int : 限定类型的尺寸的最小值 * 功能正文: * 支持限定类型,表示支持限定人、车等类型的能力。 ************************************************************************/ const int getTargetTypeMin() const; /*********************************************************************** * 概述:设置限定类型的尺寸的单位 * 输入: * p_pTargetTypeUnit :限定类型的尺寸的单位 * 输出: * 无 * 返回值: * 无 * 功能正文: * 支持限定类型,表示支持限定人、车等类型的能力。 ************************************************************************/ bool setTargetTypeUnit(const char* p_pTargetTypeUnit); /*********************************************************************** * 概述:获取限定类型的尺寸的单位 * 输入: * 无 * 输出: * 无 * 返回值: * string : 限定类型的尺寸的单位 * 功能正文: * 支持限定类型,表示支持限定人、车等类型的能力。 ************************************************************************/ const char* getTargetTypeUnit() const; /*********************************************************************** * 概述:设置是否支持双绊线的时间间隔的功能 * 输入: * p_bTimeIntervalEnable :是否支持该项功能。 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setTimeIntervalEnable(const bool p_bTimeIntervalEnable); /*********************************************************************** * 概述:获取是否支持双绊线的时间间隔的功能 * 输入: * 无 * 输出: * 无 * 返回值: * bool : 返回true,支持; * 返回false,不支持。 * 功能正文: * 无 ************************************************************************/ const bool getTimeIntervalEnable() const; /*********************************************************************** * 概述:设置双绊线的时间间隔的最小值 * 输入: * p_nTimeIntervalMin :双绊线的时间间隔的最小值。 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setTimeIntervalMin(const int p_nTimeIntervalMin); /*********************************************************************** * 概述:获取双绊线的时间间隔的最小值 * 输入: * 无 * 输出: * 无 * 返回值: * int : 双绊线的时间间隔的最小值 * 功能正文: * 无 ************************************************************************/ const int getTimeIntervalMin() const; /*********************************************************************** * 概述:设置双绊线的时间间隔的最大值 * 输入: * p_nTimeIntervalMin :双绊线的时间间隔的最大值。 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setTimeIntervalMax(const int p_nTimeIntervalMax); /*********************************************************************** * 概述:获取双绊线的时间间隔的最大值 * 输入: * 无 * 输出: * 无 * 返回值: * int : 双绊线的时间间隔的最大值 * 功能正文: * 无 ************************************************************************/ const int getTimeIntervalMax() const; /*********************************************************************** * 概述:设置双绊线的时间间隔的单位 * 输入: * p_pTimeIntervalUnit :双绊线的时间间隔的单位。 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ bool setTimeIntervalUnit(const char* p_pTimeIntervalUnit); /*********************************************************************** * 概述:获取双绊线的时间间隔的单位 * 输入: * 无 * 输出: * 无 * 返回值: * string : 双绊线的时间间隔的单位 * 功能正文: * 无 ************************************************************************/ const char* getTimeIntervalUnit() const; /*********************************************************************** * 概述:设置是否支持双绊线的触发方向设置的功能 * 输入: * p_bTimeIntervalEnable :是否支持该项功能。 * 输出: * 无 * 返回值: * 无 * 功能正文: * 无 ************************************************************************/ void setTriggerDirectionEnable(const bool p_bTriggerDirectionEnable); /*********************************************************************** * 概述:获取是否支持双绊线的触发方向设置的功能 * 输入: * 无 * 输出: * 无 * 返回值: * bool : 返回true,支持; * 返回false,不支持。 * 功能正文: * 无 ************************************************************************/ const bool getTriggerDirectionEnable() const; private: int m_nLibId; bool m_bRegionEnable; int m_nEdgeNum; int m_nMaxRegionNum; bool m_bDetailGetEnable; bool m_bEnable; bool m_bMaxTargetSizeEnable; int m_nMaxTargetSizeMax; int m_nMaxTargetSizeMin; bool m_bMinTargetSizeEnable; int m_nMinTargetSizeMax; int m_nMinTargetSizeMin; bool m_bTargetSizeConstrainEnable; int m_nTargetSizeConstrainMax; int m_nTargetSizeConstrainMin; bool m_bTargetTypeConstrainEnable; int m_nTargetTypeConstrainMax; int m_nTargetTypeConstrainMin; bool m_bTargetTypeEnable; int m_nTargetTypeMax; int m_nTargetTypeMin; bool m_bTimeIntervalEnable; int m_nTimeIntervalMin; int m_nTimeIntervalMax; bool m_bTriggerDirectionEnable; char m_pMaxTargetSizeUnit[CONST_INTELLIGENCE_ANALYSE_UNIT_LEN + 1]; char m_pMinTargetSizeUnit[CONST_INTELLIGENCE_ANALYSE_UNIT_LEN + 1]; char m_pTargetSizeConstrainUnit[CONST_INTELLIGENCE_ANALYSE_UNIT_LEN + 1]; char m_pTargetTypeConstrainUnit[CONST_INTELLIGENCE_ANALYSE_UNIT_LEN + 1]; char m_pTargetTypeUnit[CONST_INTELLIGENCE_ANALYSE_UNIT_LEN + 1]; char m_pTimeIntervalUnit[CONST_INTELLIGENCE_ANALYSE_UNIT_LEN + 1]; }_PACKED_1_; /**********************************************************************/ #ifdef PRAGMA_PACK #ifdef WIN32 #pragma pack(pop) #endif #endif /**********************************************************************/ #endif //_MULTITRIPWIREABILITY_H_
[ "paxan222@yandex.ru" ]
paxan222@yandex.ru
dc877522d25d314a1da9c17db8cffa56a5988df4
77ee3feb0f82773760bffd9c287910c5865d5a80
/src/GM/TexCUBE.cpp
b94bbfc9e85ad5b2fee558ae22eb8dd07b5f894f
[]
no_license
cecilietlandersen/OpenGL
2fa8caf7dbfeb868c6098e4e88979da7b5ad8002
0223782c7241a36af3c9ee0ed6a05ef39b9a5a4d
refs/heads/master
2021-01-15T22:02:27.021912
2012-10-31T12:52:02
2012-10-31T12:52:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,911
cpp
#include "TexCUBE.h" using namespace GM; TexCUBE::TexCUBE(const TexCUBEParams &tex_params) : faces_set(6) { #ifdef GL_TEXTURE_CUBE_MAP_SEAMLESS glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); #endif glGenTextures(1, &handle); bind(); for(unsigned int i = 0; i < tex_params.params.size(); i++) { glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, tex_params.params[i].internal_format, tex_params.params[i].w, tex_params.params[i].h, 0, tex_params.params[i].format, tex_params.params[i].type, tex_params.params[i].data); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); } TexCUBE::TexCUBE() : faces_set(0) { #ifdef GL_TEXTURE_CUBE_MAP_SEAMLESS glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); #endif glGenTextures(1, &handle); bind(); } TexCUBE::~TexCUBE() { glDeleteTextures(1, &handle); } void TexCUBE::setFace(unsigned int side, const T2DTexParams &param) { glTexImage2D(side, 0, param.internal_format, param.w, param.h, 0, param.format, param.type, param.data); faces_set++; } void TexCUBE::finished() { if(faces_set != 6) return; glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); } void TexCUBE::bind() { glBindTexture(GL_TEXTURE_CUBE_MAP, handle); } void TexCUBE::unbind() { glBindTexture(GL_TEXTURE_CUBE_MAP, 0); }
[ "ann_ht3@hotmail.com" ]
ann_ht3@hotmail.com
1dd9effec90db8470018ad373bef8187e3c7d5f2
d37d17465820b6fbddac3d322e1cdbc4492a7a01
/URI 1009/Main.cpp
77e8e72fbcd7767826a5d7f10d781652d5ddb925
[]
no_license
nafis195/URI
97b0c590921c7d84b57ff560196db3134ac4a6e3
10f0470719d321b0a3eaee2675fa05aadb3fa948
refs/heads/master
2020-11-28T04:23:52.107445
2020-01-11T06:55:17
2020-01-11T06:55:17
229,702,347
1
0
null
null
null
null
UTF-8
C++
false
false
634
cpp
// Bismillahir Rahmanir Rahim // URI_1009 // Salary with bonus #include<iostream> #include<iomanip> #include<string> using namespace std; double totalSalary (string firstName, double salary, double salesValue) { double total; total = salary + (salesValue * .15); return total; } int main () { string firstName; double sellerSalary, salesTotal; cin >> firstName; cin >> sellerSalary; cin >> salesTotal; std::cout << std::fixed; std::cout << std::setprecision (2); cout << "TOTAL = R$ " << totalSalary (firstName, sellerSalary, salesTotal); cout << endl; system ("pause"); return 0; }
[ "noreply@github.com" ]
nafis195.noreply@github.com
043a3853907dc3f6acecf6f7952a034ca8eaff94
efd9e3980a2e8a131c1f1ab64a2f856b9d1bee6a
/libraries/ros_lib/diagnostic_msgs/KeyValue.h
3c9e64edb91ec9c770dddbbb01ecf4bba842385d
[]
no_license
limhyon/arduimu
b520688a7132c147eb403473566a42dac719db50
b6725463c98a77d3f912de3464921dd5483f8673
refs/heads/master
2021-01-19T06:06:33.769806
2012-07-24T06:40:21
2012-07-24T06:40:21
5,151,087
4
2
null
null
null
null
UTF-8
C++
false
false
1,736
h
#ifndef _ROS_diagnostic_msgs_KeyValue_h #define _ROS_diagnostic_msgs_KeyValue_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" namespace diagnostic_msgs { class KeyValue : public ros::Msg { public: char * key; char * value; virtual int serialize(unsigned char *outbuffer) const { int offset = 0; uint32_t * length_key = (uint32_t *)(outbuffer + offset); *length_key = strlen( (const char*) this->key); offset += 4; memcpy(outbuffer + offset, this->key, *length_key); offset += *length_key; uint32_t * length_value = (uint32_t *)(outbuffer + offset); *length_value = strlen( (const char*) this->value); offset += 4; memcpy(outbuffer + offset, this->value, *length_value); offset += *length_value; return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; uint32_t length_key = *(uint32_t *)(inbuffer + offset); offset += 4; for(unsigned int k= offset; k< offset+length_key; ++k){ inbuffer[k-1]=inbuffer[k]; } inbuffer[offset+length_key-1]=0; this->key = (char *)(inbuffer + offset-1); offset += length_key; uint32_t length_value = *(uint32_t *)(inbuffer + offset); offset += 4; for(unsigned int k= offset; k< offset+length_value; ++k){ inbuffer[k-1]=inbuffer[k]; } inbuffer[offset+length_value-1]=0; this->value = (char *)(inbuffer + offset-1); offset += length_value; return offset; } const char * getType(){ return "diagnostic_msgs/KeyValue"; }; const char * getMD5(){ return "cf57fdc6617a881a88c16e768132149c"; }; }; } #endif
[ "limhyon@gmail.com" ]
limhyon@gmail.com
20357a8d46bbc68fc3857cc400c07cb69f883b62
fbc4da93b078c320b064f413ee3721a3f24277af
/OfficeVol2/OptionDlgModule.cpp
72d42a5839251625842b4bb60ddea540ce5a9b5c
[]
no_license
wyrover/LazyVol
f97f696d12f7f2053a18a81c130afc9f8eee303c
925df4b1eb1a2405d570a0b59ec58aeb3c1d3c60
refs/heads/master
2021-01-20T08:00:16.257356
2013-04-24T06:59:35
2013-04-24T06:59:35
null
0
0
null
null
null
null
GB18030
C++
false
false
14,927
cpp
#include "MainHead.h" #include "OfficeVolModule.h" #include "OptionDlgModule.h" OptionDlgModule::OptionDlgModule(HWND parent_hwnd):mParentHwnd(parent_hwnd) { } OptionDlgModule::~OptionDlgModule(void) { } LPCTSTR OptionDlgModule::GetWindowClassName() const { return _T("ScanMainForm"); }; void OptionDlgModule::OnFinalMessage(HWND /*hWnd*/) { delete this; }; void OptionDlgModule::Init() { CKeyEditUI* tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_VOLUP"))); assert(tmpEdit); std::string configStr; OfficeVolModule::GetInstance()->GetConfigStr("OFF_VOLUP", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_VOLDOWN"))); assert(tmpEdit); OfficeVolModule::GetInstance()->GetConfigStr("OFF_VOLDOWN", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_VOLON"))); assert(tmpEdit); OfficeVolModule::GetInstance()->GetConfigStr("OFF_VOLON", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_VOLOFF"))); assert(tmpEdit); OfficeVolModule::GetInstance()->GetConfigStr("OFF_VOLOFF", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_VOLSELECT_MASTER"))); assert(tmpEdit); OfficeVolModule::GetInstance()->GetConfigStr("OFF_VOLSELECT_MASTER", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_VOLSELECT_WAVE"))); assert(tmpEdit); OfficeVolModule::GetInstance()->GetConfigStr("OFF_VOLSELECT_WAVE", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_VOLSELECT_MIC"))); assert(tmpEdit); OfficeVolModule::GetInstance()->GetConfigStr("OFF_VOLSELECT_MIC", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_OPTION"))); assert(tmpEdit); OfficeVolModule::GetInstance()->GetConfigStr("OFF_OPTION", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); tmpEdit = static_cast<CKeyEditUI*>(m_pm.FindControl(_T("OFF_QUIT"))); assert(tmpEdit); OfficeVolModule::GetInstance()->GetConfigStr("OFF_QUIT", configStr); tmpEdit->SetKey(configStr.c_str()); tmpEdit->SetText(configStr.c_str()); mKeyEditVec.push_back(tmpEdit); mWinStartOpt = static_cast<COptionUI*>(m_pm.FindControl(_T("OFF_WINSTART"))); assert(mWinStartOpt); OfficeVolModule::GetInstance()->GetConfigStr("OFF_WINSTART", configStr); if(configStr == "ON") { mWinStartOpt->Selected(true); } else { mWinStartOpt->Selected(false); } } void OptionDlgModule::Notify(TNotifyUI& msg) { if(msg.sType == _T("click")) { if( msg.pSender->GetName() == _T("cancelbtn") || msg.pSender->GetName() == _T("exitbtn")) { Close(); return; } if( msg.pSender->GetName() == _T("okBtn") ) { UpdateConfig(); Close(); return; } if( msg.pSender->GetName() == _T("applyBtn") ) { UpdateConfig(); return; } } else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0) { CTabLayoutUI* pTabControl = static_cast<CTabLayoutUI*>(m_pm.FindControl(kMainTabCtrl)); CTabLayoutUI* pGTabControl = static_cast<CTabLayoutUI*>(m_pm.FindControl(kGeneralTableCtrl)); if (_tcsicmp(msg.pSender->GetName(), kTabGeneral) == 0) { if (pTabControl && pTabControl->GetCurSel() != 0) { pTabControl->SelectItem(0); } } else if (_tcsicmp(msg.pSender->GetName(), kTabAbout) == 0) { if (pTabControl && pTabControl->GetCurSel() != 1) { pTabControl->SelectItem(1); } } else if (_tcsicmp(msg.pSender->GetName(), kGTabKeyboard) == 0) { if (pGTabControl && pGTabControl->GetCurSel() != 0) { pGTabControl->SelectItem(0); } } else if (_tcsicmp(msg.pSender->GetName(), kGTabCommon) == 0) { if (pGTabControl && pGTabControl->GetCurSel() != 1) { pGTabControl->SelectItem(1); } } } } LRESULT OptionDlgModule::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { //LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); //styleValue &= ~WS_CAPTION; //::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); m_pm.Init(m_hWnd); //m_pm.SetTransparent(100); CDialogBuilder builder; CControlUI* pRoot = builder.Create(_T("OpSkin.xml"), (UINT)0, this, &m_pm); ASSERT(pRoot && "Failed to parse XML"); m_pm.AttachDialog(pRoot); m_pm.AddNotifier(this); Init(); return 0; } LRESULT OptionDlgModule::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { bHandled = FALSE; return 0; } LRESULT OptionDlgModule::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if(mParentHwnd) ::PostMessage(mParentHwnd, MSG_DISMISS_OPTION, wParam, lParam); bHandled = FALSE; return 0; } LRESULT OptionDlgModule::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if( ::IsIconic(*this) ) bHandled = FALSE; return (wParam == 0) ? TRUE : FALSE; } LRESULT OptionDlgModule::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { return 0; } LRESULT OptionDlgModule::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { return 0; } LRESULT OptionDlgModule::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { #if 1 POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); ::ScreenToClient(*this, &pt); RECT rcClient; ::GetClientRect(*this, &rcClient); if( !::IsZoomed(*this) ) { RECT rcSizeBox = m_pm.GetSizeBox(); if( pt.y < rcClient.top + rcSizeBox.top ) { if( pt.x < rcClient.left + rcSizeBox.left ) return HTTOPLEFT; if( pt.x > rcClient.right - rcSizeBox.right ) return HTTOPRIGHT; return HTTOP; } else if( pt.y > rcClient.bottom - rcSizeBox.bottom ) { if( pt.x < rcClient.left + rcSizeBox.left ) return HTBOTTOMLEFT; if( pt.x > rcClient.right - rcSizeBox.right ) return HTBOTTOMRIGHT; return HTBOTTOM; } if( pt.x < rcClient.left + rcSizeBox.left ) return HTLEFT; if( pt.x > rcClient.right - rcSizeBox.right ) return HTRIGHT; } RECT rcCaption = m_pm.GetCaptionRect(); if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \ && pt.y >= rcCaption.top && pt.y < rcCaption.bottom ) { CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt)); if( pControl && _tcscmp(pControl->GetClass(), _T("ButtonUI")) != 0 && _tcscmp(pControl->GetClass(), _T("OptionUI")) != 0 && _tcscmp(pControl->GetClass(), _T("TextUI")) != 0 ) return HTCAPTION; } #endif return HTCLIENT; } LRESULT OptionDlgModule::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { SIZE szRoundCorner = m_pm.GetRoundCorner(); if( !::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0) ) { CDuiRect rcWnd; ::GetWindowRect(*this, &rcWnd); rcWnd.Offset(-rcWnd.left, -rcWnd.top); rcWnd.right++; rcWnd.bottom++; RECT rc = { rcWnd.left, rcWnd.top + szRoundCorner.cx, rcWnd.right, rcWnd.bottom }; HRGN hRgn1 = ::CreateRectRgnIndirect( &rc ); HRGN hRgn2 = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom - szRoundCorner.cx, szRoundCorner.cx, szRoundCorner.cy); ::CombineRgn( hRgn1, hRgn1, hRgn2, RGN_OR ); ::SetWindowRgn(*this, hRgn1, TRUE); ::DeleteObject(hRgn1); ::DeleteObject(hRgn2); } bHandled = FALSE; return 0; } LRESULT OptionDlgModule::OnMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { RECT rcWnd = { 0 }; ::GetWindowRect(m_hWnd, &rcWnd ); ::SetWindowPos(m_hWnd, HWND_TOPMOST, rcWnd.left, rcWnd.top, rcWnd.right -rcWnd.left, rcWnd.bottom -rcWnd.top, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); bHandled = FALSE; return 0; } LRESULT OptionDlgModule::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { #if 0 MONITORINFO oMonitor = {}; oMonitor.cbSize = sizeof(oMonitor); ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor); CDuiRect rcWork = oMonitor.rcWork; rcWork.Offset(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.top); LPMINMAXINFO lpMMI = (LPMINMAXINFO) lParam; lpMMI->ptMaxPosition.x = rcWork.left; lpMMI->ptMaxPosition.y = rcWork.top; lpMMI->ptMaxSize.x = rcWork.right; lpMMI->ptMaxSize.y = rcWork.bottom; bHandled = FALSE; #endif return 0; } LRESULT OptionDlgModule::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { #if 0 // 有时会在收到WM_NCDESTROY后收到wParam为SC_CLOSE的WM_SYSCOMMAND if( wParam == SC_CLOSE ) { ::PostQuitMessage(0L); bHandled = TRUE; return 0; } BOOL bZoomed = ::IsZoomed(*this); LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam); if( ::IsZoomed(*this) != bZoomed ) { if( !bZoomed ) { CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn"))); if( pControl ) pControl->SetVisible(false); pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn"))); if( pControl ) pControl->SetVisible(true); } else { CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn"))); if( pControl ) pControl->SetVisible(true); pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn"))); if( pControl ) pControl->SetVisible(false); } } return lRes; #endif return 0; } LRESULT OptionDlgModule::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; BOOL bHandled = TRUE; switch( uMsg ) { case WM_MOVE: Off_DegMsg("sdfsdfddddddddd"); break; case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break; case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break; case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break; //case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break; //case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break; //case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break; //case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break; case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break; //case WM_MOVE: lRes = OnMove(uMsg, wParam, lParam, bHandled); break; //case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break; case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break; default: bHandled = FALSE; } if( bHandled ) return lRes; if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes; return CWindowWnd::HandleMessage(uMsg, wParam, lParam); } CControlUI* OptionDlgModule::CreateControl(LPCTSTR pstrClass) { std::string strname(pstrClass); if(strname == "KEdit") return new CKeyEditUI; return NULL; } LRESULT OptionDlgModule::UpdateConfig() { std::vector<CKeyEditUI*>::iterator iter; LRESULT ret = 0; std::string old_config; for(iter=mKeyEditVec.begin(); iter != mKeyEditVec.end(); ++iter) { CKeyEditUI* tmpCtrl = *iter; assert(tmpCtrl); ret = OfficeVolModule::GetInstance()->GetConfigStr((LPCTSTR)tmpCtrl->GetName(), old_config); if(ret) { char str[1024] = {0}; _snprintf(str, 1024, "获取配置错误 %s", (LPCTSTR)tmpCtrl->GetName()); Off_Msg(str); } if(old_config != tmpCtrl->GetKey()) { ret = OfficeVolModule::GetInstance()->SetConfigStr(OFF_KEY_UPDATE, (LPCTSTR)tmpCtrl->GetName(), tmpCtrl->GetKey()); if(ret) { char str[1024] = {0}; _snprintf(str, 1024, "配置错误 %s:%s", (LPCTSTR)tmpCtrl->GetName(), tmpCtrl->GetKey().c_str()); Off_Msg(str); } } } ret = OfficeVolModule::GetInstance()->GetConfigStr((LPCTSTR)mWinStartOpt->GetName(), old_config); if(ret) { char str[1024] = {0}; _snprintf(str, 1024, "获取配置错误 %s", (LPCTSTR)mWinStartOpt->GetName()); Off_Msg(str); ReadConfig(); return OFF_ERROR; } if(old_config == "OFF" && mWinStartOpt->IsSelected()) { ret = OfficeVolModule::GetInstance()->SetConfigStr(OFF_WIN_START, (LPCTSTR)mWinStartOpt->GetName(), "ON"); if(ret) { char str[1024] = {0}; _snprintf(str, 1024, "配置错误 %s:%s", (LPCTSTR)mWinStartOpt->GetName(), "ON"); Off_Msg(str); } } else if(old_config == "ON" && !mWinStartOpt->IsSelected()) { ret = OfficeVolModule::GetInstance()->SetConfigStr(OFF_WIN_START, (LPCTSTR)mWinStartOpt->GetName(), "OFF"); if(ret) { char str[1024] = {0}; _snprintf(str, 1024, "配置错误 %s:%s", (LPCTSTR)mWinStartOpt->GetName(), "OFF"); Off_Msg(str); } } ReadConfig(); return 0; } LRESULT OptionDlgModule::ReadConfig() { std::vector<CKeyEditUI*>::iterator iter; LRESULT ret = 0; std::string configStr; for(iter=mKeyEditVec.begin(); iter != mKeyEditVec.end(); ++iter) { CKeyEditUI* tmpCtrl = *iter; assert(tmpCtrl); ret = OfficeVolModule::GetInstance()->GetConfigStr((LPCTSTR)tmpCtrl->GetName(), configStr); if(ret) { char str[1024] = {0}; _snprintf(str, 1024, "获取配置错误 %s", (LPCTSTR)tmpCtrl->GetName()); Off_Msg(str); } tmpCtrl->SetKey(configStr.c_str()); tmpCtrl->SetText(configStr.c_str()); } return 0; }
[ "guolisen@163.com" ]
guolisen@163.com
855909cedafd1b6249f8324f15b5ab4856ed4df8
27d32027fc88567ae7fce89cef561747acbe25ad
/hackerrank/Algorithms/Implementation/Angry Professor.cpp
663e2c418cf77f2a62a2c2ad6fd898baedfdd700
[]
no_license
jayantsurana/competitiveCoding
ff12aa9ef1cc59701609a400856c9b4f5ee416c6
e4d5ba5132f9f5a4dad4a2f87a831b845ed364de
refs/heads/master
2021-07-20T16:31:18.661792
2020-04-25T12:38:25
2020-04-25T12:38:25
144,750,103
0
0
null
2019-02-19T12:18:19
2018-08-14T17:11:07
C++
UTF-8
C++
false
false
1,920
cpp
#include <bits/stdc++.h> using namespace std; vector<string> split_string(string); // Complete the angryProfessor function below. string angryProfessor(int k, vector<int> a) { int earlyontime=0; string s; for(int i=0; i<a.size(); i++){ if(a[i]<=0) earlyontime++; } if(k<=earlyontime) s="NO"; else s="YES"; return s; }//By Jayant Surana. int main() { ofstream fout(getenv("OUTPUT_PATH")); int t; cin >> t; cin.ignore(numeric_limits<streamsize>::max(), '\n'); for (int t_itr = 0; t_itr < t; t_itr++) { string nk_temp; getline(cin, nk_temp); vector<string> nk = split_string(nk_temp); int n = stoi(nk[0]); int k = stoi(nk[1]); string a_temp_temp; getline(cin, a_temp_temp); vector<string> a_temp = split_string(a_temp_temp); vector<int> a(n); for (int i = 0; i < n; i++) { int a_item = stoi(a_temp[i]); a[i] = a_item; } string result = angryProfessor(k, a); fout << result << "\n"; } fout.close(); return 0; } vector<string> split_string(string input_string) { string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) { return x == y and x == ' '; }); input_string.erase(new_end, input_string.end()); while (input_string[input_string.length() - 1] == ' ') { input_string.pop_back(); } vector<string> splits; char delimiter = ' '; size_t i = 0; size_t pos = input_string.find(delimiter); while (pos != string::npos) { splits.push_back(input_string.substr(i, pos - i)); i = pos + 1; pos = input_string.find(delimiter, i); } splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1)); return splits; }
[ "jayantplb@gmail.com" ]
jayantplb@gmail.com
83d80275e20bba40aeba4e1eb06fbd4a3d048151
7975777cfd2500a845c0075ea12f7033596f2e38
/Minecraft/root_widget.h
c4a42a87a5965b5ed099eba656733d9c8b8efb70
[]
no_license
TracyCR7/-MineCraft
7c1d71b1d8388aec1afd5bfc2b4ea46165aa94ef
f97f66b63ded1b203c0a4e6acae4ac0aa006d984
refs/heads/master
2021-04-06T06:50:57.915649
2018-03-13T11:14:38
2018-03-13T11:14:38
124,719,439
0
0
null
null
null
null
UTF-8
C++
false
false
296
h
#pragma once #include <QWidget> #include <QResizeEvent> #include <QSize> #include "utils.h" class ROOT_WIDGET : public QWidget { Q_OBJECT public: ROOT_WIDGET(QWidget* parent); protected: void resizeEvent(QResizeEvent *event) override; signals: void change_size(QSize); };
[ "noreply@github.com" ]
TracyCR7.noreply@github.com
3b4e8279d5c5b7ae1ff1af1c32edca63a35d3869
c6062b3748f6f4aa8c088a181109cebfa4d99bf3
/Bots/BotAIController.h
b58a1394e7b71589f27d5f0687aec5ee353b9440
[]
no_license
qipa/UE4-RPG-Demo
c543c16e0813c29c0d7cb8151dbb88abdd4941ed
b0cc148bea228ffcc8c7d368e721a4e1a5239498
refs/heads/master
2021-05-29T21:08:37.036409
2015-11-08T08:41:44
2015-11-08T08:41:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
427
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "AIController.h" #include "BotAIController.generated.h" class UBehaviorTreeComponent; class UBlackboardComponent; UCLASS() class RPGDEMO_API ABotAIController : public AAIController { GENERATED_BODY() public: bool GetRandomPointInRadius(UNavigationSystem* navSys, FVector origin, float radius, FVector& location); };
[ "infamousjeezy@gmail.com" ]
infamousjeezy@gmail.com
6f75536e6246c3b93555f011b8d775dc85e1a6ca
4fc1e78d401305cb8bf91e58566e29d526a58cfe
/Josephus/JosephusUsingLinkedList.cpp
1f119929251190dfeaaa8d69d162777101ab9344
[]
no_license
peterloos/Cpp_Josephus
ab2224a8cdca11d2796119e7e2e82e764498a25a
e8f7769ae380d995d05fa136bb32ce0c21c62179
refs/heads/master
2021-01-20T19:42:29.669315
2016-06-14T19:44:30
2016-06-14T19:44:30
61,150,987
0
0
null
null
null
null
UTF-8
C++
false
false
2,519
cpp
#include <iostream> using namespace std; #include "Soldier.h" #include "Josephus.h" namespace SolutionUsingLinkedList { // c'tor(s), d'tor Josephus::Josephus() : m_count(41), m_alive(41), m_lastEliminated(0) { m_passby = Josephus::DefaultPassBy; CreateLinkedList(); } Josephus::Josephus(int count) : m_count(count), m_alive(count), m_lastEliminated(0) { m_passby = Josephus::DefaultPassBy; CreateLinkedList(); } Josephus::~Josephus() { Soldier* soldier = m_root; // delete each single element do { // store current node pointer Soldier* current = soldier; // advance to next node soldier = soldier -> m_next; // delete 'current' node pointer delete current; } while (soldier != m_root); } // public interface bool Josephus::EliminateNextSoldier() { // more than one soldier? if (m_alive == 1) return false; // locate next soldier for (int i = 0; i < m_passby - 1; i ++) m_current = m_current -> m_next; // remove soldier from list Soldier* node = m_current -> m_next; m_current -> m_next = node -> m_next; // take care, if root object is removed if (m_root == node) m_root = m_root -> m_next; m_lastEliminated = node -> m_number; delete node; m_alive --; return true; } void Josephus::EliminateAll() { while (EliminateNextSoldier()) ; } // private helper methods void Josephus::CreateLinkedList() { // create first soldier m_root = new Soldier(1); m_current = m_root; for (int i = 1; i < m_count; i ++) { Soldier* s = new Soldier(i + 1); // link previous Soldier with current one m_current -> m_next = s; m_current = s; } // link last soldier with first one m_current -> m_next = m_root; } // output ostream& operator<< (ostream& os, const Josephus& j) { os << '['; Soldier* tmp = j.m_root; do { os << *tmp; if (tmp -> m_next != j.m_root) os << ','; tmp = tmp -> m_next; } while (tmp != j.m_root); os << ']'; return os; } }
[ "peter.loos@gmx.de" ]
peter.loos@gmx.de
fb9500ab979c18b3d332614585aa4fafaa74ed60
ea99679b342d457b22832672e61eecb18512b25d
/src/core_write.cpp
8579ee84c9ffc42bc5b2eadd18107897fdac16bf
[ "MIT" ]
permissive
eletaNetwork/eletaNetwork
ab5cb586c8ce13380eba1eaa58327e3ecb9ec755
c589089d189215d83a34534c82878d39b7cdda96
refs/heads/master
2020-03-08T19:27:51.153812
2018-04-13T06:01:43
2018-04-13T06:01:43
128,353,833
0
0
null
null
null
null
UTF-8
C++
false
false
7,565
cpp
// Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "core_io.h" #include "base58.h" #include "primitives/transaction.h" #include "script/script.h" #include "script/standard.h" #include "serialize.h" #include "streams.h" #include <univalue.h> #include "util.h" #include "utilmoneystr.h" #include "utilstrencodings.h" #include <boost/assign/list_of.hpp> #include <boost/foreach.hpp> using namespace std; string FormatScript(const CScript& script) { string ret; CScript::const_iterator it = script.begin(); opcodetype op; while (it != script.end()) { CScript::const_iterator it2 = it; vector<unsigned char> vch; if (script.GetOp2(it, op, &vch)) { if (op == OP_0) { ret += "0 "; continue; } else if ((op >= OP_1 && op <= OP_16) || op == OP_1NEGATE) { ret += strprintf("%i ", op - OP_1NEGATE - 1); continue; } else if (op >= OP_NOP && op <= OP_NOP10) { string str(GetOpName(op)); if (str.substr(0, 3) == string("OP_")) { ret += str.substr(3, string::npos) + " "; continue; } } if (vch.size() > 0) { ret += strprintf("0x%x 0x%x ", HexStr(it2, it - vch.size()), HexStr(it - vch.size(), it)); } else { ret += strprintf("0x%x ", HexStr(it2, it)); } continue; } ret += strprintf("0x%x ", HexStr(it2, script.end())); break; } return ret.substr(0, ret.size() - 1); } const map<unsigned char, string> mapSigHashTypes = boost::assign::map_list_of (static_cast<unsigned char>(SIGHASH_ALL), string("ALL")) (static_cast<unsigned char>(SIGHASH_ALL|SIGHASH_ANYONECANPAY), string("ALL|ANYONECANPAY")) (static_cast<unsigned char>(SIGHASH_NONE), string("NONE")) (static_cast<unsigned char>(SIGHASH_NONE|SIGHASH_ANYONECANPAY), string("NONE|ANYONECANPAY")) (static_cast<unsigned char>(SIGHASH_SINGLE), string("SINGLE")) (static_cast<unsigned char>(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY), string("SINGLE|ANYONECANPAY")) ; /** * Create the assembly string representation of a CScript object. * @param[in] script CScript object to convert into the asm string representation. * @param[in] fAttemptSighashDecode Whether to attempt to decode sighash types on data within the script that matches the format * of a signature. Only pass true for scripts you believe could contain signatures. For example, * pass false, or omit the this argument (defaults to false), for scriptPubKeys. */ string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode) { string str; opcodetype opcode; vector<unsigned char> vch; CScript::const_iterator pc = script.begin(); while (pc < script.end()) { if (!str.empty()) { str += " "; } if (!script.GetOp(pc, opcode, vch)) { str += "[error]"; return str; } if (0 <= opcode && opcode <= OP_PUSHDATA4) { if (vch.size() <= static_cast<vector<unsigned char>::size_type>(4)) { str += strprintf("%d", CScriptNum(vch, false).getint()); } else { // the IsUnspendable check makes sure not to try to decode OP_RETURN data that may match the format of a signature if (fAttemptSighashDecode && !script.IsUnspendable()) { string strSigHashDecode; // goal: only attempt to decode a defined sighash type from data that looks like a signature within a scriptSig. // this won't decode correctly formatted public keys in Pubkey or Multisig scripts due to // the restrictions on the pubkey formats (see IsCompressedOrUncompressedPubKey) being incongruous with the // checks in CheckSignatureEncoding. if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, NULL)) { const unsigned char chSigHashType = vch.back(); if (mapSigHashTypes.count(chSigHashType)) { strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType)->second + "]"; vch.pop_back(); // remove the sighash type byte. it will be replaced by the decode. } } str += HexStr(vch) + strSigHashDecode; } else { str += HexStr(vch); } } } else { str += GetOpName(opcode); } } return str; } string EncodeHexTx(const CTransaction& tx) { CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << tx; return HexStr(ssTx.begin(), ssTx.end()); } void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex) { txnouttype type; vector<CTxDestination> addresses; int nRequired; out.pushKV("asm", ScriptToAsmStr(scriptPubKey)); if (fIncludeHex) out.pushKV("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end())); if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) { out.pushKV("type", GetTxnOutputType(type)); return; } out.pushKV("reqSigs", nRequired); out.pushKV("type", GetTxnOutputType(type)); UniValue a(UniValue::VARR); BOOST_FOREACH(const CTxDestination& addr, addresses) a.push_back(CEletaCoinAddress(addr).ToString()); out.pushKV("addresses", a); } void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry) { entry.pushKV("txid", tx.GetHash().GetHex()); entry.pushKV("version", tx.nVersion); entry.pushKV("locktime", (int64_t)tx.nLockTime); UniValue vin(UniValue::VARR); BOOST_FOREACH(const CTxIn& txin, tx.vin) { UniValue in(UniValue::VOBJ); if (tx.IsCoinBase()) in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); else { in.pushKV("txid", txin.prevout.hash.GetHex()); in.pushKV("vout", (int64_t)txin.prevout.n); UniValue o(UniValue::VOBJ); o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true)); o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); in.pushKV("scriptSig", o); } in.pushKV("sequence", (int64_t)txin.nSequence); vin.push_back(in); } entry.pushKV("vin", vin); UniValue vout(UniValue::VARR); for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut& txout = tx.vout[i]; UniValue out(UniValue::VOBJ); UniValue outValue(UniValue::VNUM, FormatMoney(txout.nValue)); out.pushKV("value", outValue); out.pushKV("n", (int64_t)i); UniValue o(UniValue::VOBJ); ScriptPubKeyToUniv(txout.scriptPubKey, o, true); out.pushKV("scriptPubKey", o); vout.push_back(out); } entry.pushKV("vout", vout); if (!hashBlock.IsNull()) entry.pushKV("blockhash", hashBlock.GetHex()); entry.pushKV("hex", EncodeHexTx(tx)); // the hex-encoded transaction. used the name "hex" to be consistent with the verbose output of "getrawtransaction". }
[ "38124337+eletaNetwork@users.noreply.github.com" ]
38124337+eletaNetwork@users.noreply.github.com
4e4c1614bd9650cdf9cff4d6a92716dffb2fb73b
01c029e89f2cec46f093e2766c3856339be022f2
/TSLS_Edit_Distance.cpp
52c5fce7144a010a01dfb0e2cf4f831f308b6e28
[]
no_license
XiaoXiaoLui/LeetCode
f16c6213aa88b0454fb919cdf460fec74bb8ba60
f0c3c2f654571655075a21e0b02465a02caf7cb3
refs/heads/master
2021-01-11T02:08:42.353447
2016-10-26T09:28:49
2016-10-26T09:28:49
70,828,096
0
0
null
null
null
null
UTF-8
C++
false
false
1,364
cpp
/****************************************************************************************** Edit Distance ******************************************************************************************/ #include <iostream> #include <cstdio> #include <vector> #include <set> #include <map> #include <algorithm> #include <string> #include <cmath> #include <cstring> #include <queue> #include <ctime> using namespace std; #define pii pair<int, int> #define mp make_pair typedef long long ll; class Solution { public: int minDistance(string word1, string word2) { dp.clear(); return solve(word1, word2, 0, 0); } int solve(const string &s1, const string &s2, int i, int j) { if (i >= s1.size()) { return s2.size() - j; } if (j >= s2.size()) { return s1.size() - i; } map<pii, int>::iterator iter; if ((iter = dp.find(mp(i, j))) != dp.end()) { return iter->second; } int res = 0; if (s1[i] == s2[j]) { res = solve(s1, s2, i + 1, j + 1); } else { res = solve(s1, s2, i + 1, j + 1) + 1; // modify res = min(res, solve(s1, s2, i, j + 1) + 1); // insert res = min(res, solve(s1, s2, i + 1, j) + 1); // erase } dp[mp(i, j)] = res; return res; } map<pii, int> dp; }; int main() { Solution S; return 0; }
[ "980821718@qq.com" ]
980821718@qq.com
dc3c3dbaaa7ce3efd8d3e50bca316d84ccbd7a33
3047545349bf224a182b2c33bf1f110aef1ce9b6
/Transims60/GridData/Write_Summary.cpp
9eed25f328727f3dde90b319e5bf9567f94864f1
[]
no_license
qingswu/Transim
585afe71d9666557cff53f6683cf54348294954c
f182d1639a4db612dd7b43a379a3fa344c2de9ea
refs/heads/master
2021-01-10T21:04:50.576267
2015-04-08T19:07:28
2015-04-08T19:07:28
35,232,171
1
1
null
null
null
null
UTF-8
C++
false
false
1,573
cpp
//********************************************************* // Write_Summary.cpp - Write the New Summary File //********************************************************* #include "GridData.hpp" //--------------------------------------------------------- // Write_Summary //--------------------------------------------------------- void GridData::Write_Summary () { int i, j, count; Summary_Itr sum_itr; Range_Array_Itr range_itr; Dbls_Itr dbls_itr; Dbl_Itr data_itr; count = 0; Show_Message (2, String ("Writing %s -- Record") % summary_file.File_Type ()); Set_Progress (); for (sum_itr = summary_array.begin (); sum_itr != summary_array.end (); sum_itr++) { Show_Progress (); summary_file.Put_Field (0, sum_itr->group); summary_file.Put_Field (1, sum_itr->field_name); dbls_itr = sum_itr->data_array.begin (); for (i=0, range_itr = sum_itr->select_values.begin (); range_itr != sum_itr->select_values.end (); range_itr++, dbls_itr++, i++) { summary_file.Put_Field (2, range_itr->Low ()); summary_file.Put_Field (3, range_itr->High ()); summary_file.Put_Field (4, sum_itr->grid_counts [i]); for (j=data_offset, data_itr = dbls_itr->begin (); data_itr != dbls_itr->end (); data_itr++, j++) { summary_file.Put_Field (j, *data_itr); } if (!summary_file.Write ()) { Error (String ("Writing %s") % summary_file.File_Type ()); } count++; } } End_Progress (); summary_file.Close (); Print (1); Write (1, "Number of Summary Records Written = ") << count; }
[ "davidroden@7728d46c-9721-0410-b1ea-f014b4b56054" ]
davidroden@7728d46c-9721-0410-b1ea-f014b4b56054
84d9589d708a257955fab86f2cd369d54fa8ce4f
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/c8/4c9d4860e87ead/main.cpp
f321f1de55152b95fdbf5c1b212e75d9f769aaa0
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
517
cpp
#include <iostream> #include <vector> #include <map> using namespace std; typedef vector<int> PrefList; typedef map<int, PrefList> PrefMap; typedef multimap<int, int> Matching; map<int, int> CHcapacity ={{1,1},{2,1},{3,1}}; PrefMap PrefCHLists = {{1,{5,4,6}},{2,{4,6,5}},{3,{4,5,6}}}; PrefMap PrefONLists = {{4,{2,1,3}},{5,{3,1,2}},{6,{1,3,2}}}; int main() { Matching match={{1,4},{2,5},{3,6}}; Matching final=RVV(match); } Matching RVV(Matching m){ Matching mT=m; map<int, int> S; return mT; }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df
3283b34a9cffd4258704a7e96dc41ae88fec5108
c444b63016a742bccc9515f5fc2d38f9a3c3c760
/Reco.h
31dd0e09ccda36ebf93c407e7b4f24f52fbd983e
[]
no_license
vbashkirov/DataFormat-v44
d38a4eeaa10924fc04b5285141813f3b0bbca8de
b583107f04b63aee64273fbee2c60fd0f5877184
refs/heads/master
2021-01-22T12:57:01.595679
2015-02-24T21:23:26
2015-02-24T21:23:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
36,413
h
// Andriy Zatserklyaniy, April 17, 2014: production release #ifndef Reco_h #define Reco_h #include "DataFormat.h" #include "Track.h" #include "Sensor.h" #include "Geometry.h" #include <iostream> #include <vector> #include <map> #include <list> using std::cout; using std::endl; ClassImp(Hit2D); ClassImp(SensorHit); ClassImp(CRay2D); //ClassImp(CRay); ClassImp(Track2D); //ClassImp(Track); ClassImp(SuperTrack2D); ClassImp(SuperTrack); class Reco { public: Bool_t debug_; Float_t deltaT_; const Geometry* geometry_; PCTSensors* pCTSensors_; const BeamSpot* beamSpotIn_; const BeamSpot* beamSpotOut_; const PCTEvent* pCTEvent_; Int_t event_; std::list<const Track2D*> tin_; std::list<const Track2D*> tout_; std::list<const Track2D*> vin_; std::list<const Track2D*> vout_; std::list<const SuperTrack2D*> vSuperTracks_; std::list<const SuperTrack2D*> tSuperTracks_; std::list<const SuperTrack*> superTracks_; static TClonesArray* poolTrack2D_; //-> static TClonesArray* poolSuperTrack2D_; //-> static TClonesArray* poolSuperTrack_; //-> // additional info Int_t nhitv_[4]; Int_t nhitt_[4]; std::list<const SensorHit*> firstHitv_; std::list<const SensorHit*> firstHitt_; public: Reco(const Geometry* geometry, PCTSensors* pCTSensors, const BeamSpot* beamSpotIn, const BeamSpot* beamSpotOut, const PCTEvent* pCTEvent, Int_t event, bool debug=kFALSE): debug_(debug) , geometry_(geometry), pCTSensors_(pCTSensors), beamSpotIn_(beamSpotIn), beamSpotOut_(beamSpotOut), pCTEvent_(pCTEvent) , event_(event) { //cout<< "Reco::Reco" <<endl; deltaT_ = pCTEvent_->deltaT; //cout<< "Reco::Reco: create pool" <<endl; //Sensor::CreateHitPool(); Sensor::ClearPool(); if (!poolTrack2D_) poolTrack2D_ = new TClonesArray("Track2D", 1024); if (!poolSuperTrack2D_) poolSuperTrack2D_ = new TClonesArray("SuperTrack2D", 128); if (!poolSuperTrack_) poolSuperTrack_ = new TClonesArray("SuperTrack", 16); //cout<< "Sensor::poolSensorHit_->GetLast()+1 = " << Sensor::poolSensorHit_->GetLast()+1 <<endl; //cout<< "poolTrack2D_->GetLast()+1 = " << poolTrack2D_->GetLast()+1 <<endl; //cout<< "poolSuperTrack2D_->GetLast()+1 = " << poolSuperTrack2D_->GetLast()+1 <<endl; //cout<< "poolSuperTrack_->GetLast()+1 = " << poolSuperTrack_->GetLast()+1 <<endl; //----------- pCTSensors_ = new PCTSensors(); pCTSensors_->clear(); for (int ilayer=0; ilayer<4; ++ilayer) { nhitv_[ilayer] = 0; nhitt_[ilayer] = 0; } // get hits for this event for (int iFPGA=0; iFPGA<12; ++iFPGA) { const TrackerFPGA& trackerFPGA = pCTEvent_->trackerFPGA[iFPGA]; for (unsigned int ichip=0; ichip<trackerFPGA.numChips; ++ichip) { TrackerChip* trackerChip = (TrackerChip*) trackerFPGA.chips->At(ichip); for (int icluster=0; icluster<trackerChip->numClust; ++icluster) { if (debug_) { Int_t strip = 64*trackerChip->address + (63-trackerChip->nfirst[icluster]); cout<< event_ << "\t iFPGA = " << std::setw(2) << iFPGA << " trackerChip->address = " << std::setw(2) << (unsigned) trackerChip->address << " nstrips[" << icluster << "] = " << (unsigned) trackerChip->nstrips[icluster] << " nfirst[" << icluster << "] = " << (unsigned) trackerChip->nfirst[icluster] << " strip = " << strip <<endl; // printf("%-8d iFPGA = %2d trackerChip->address = %2d nstrips[%d] = %d nfirst[%d] = %d strip = %d\n", // event,iFPGA,(unsigned) trackerChip->address,icluster,(unsigned) trackerChip->nstrips[icluster],icluster,(unsigned) trackerChip->nfirst[icluster],strip); } pCTSensors_->AddCluster(iFPGA, trackerChip->address, trackerChip->nfirst[icluster], trackerChip->nstrips[icluster]); } } } pCTSensors_->GetHits(); const SensorHit* first_v = 0; Int_t n_v_hits = 0; for (unsigned ilayer=0; ilayer<4; ++ilayer) { n_v_hits += pCTSensors_->v_hits[ilayer].size(); nhitv_[ilayer] += pCTSensors_->v_hits[ilayer].size(); if (!first_v && pCTSensors_->v_hits[ilayer].size() > 0) { first_v = pCTSensors_->v_hits[ilayer].front(); firstHitv_.push_back(first_v); } } const SensorHit* first_t = 0; Int_t n_t_hits = 0; for (unsigned ilayer=0; ilayer<4; ++ilayer) { n_t_hits += pCTSensors_->t_hits[ilayer].size(); nhitt_[ilayer] = pCTSensors_->t_hits[ilayer].size(); if (!first_t && pCTSensors_->t_hits[ilayer].size() > 0) { first_t = pCTSensors_->t_hits[ilayer].front(); firstHitt_.push_back(first_t); } } if (debug_) cout<< "n_v_hits = " << n_v_hits << " n_t_hits = " << n_t_hits <<endl; } ~Reco() { //cout<< "Reco::~Reco" <<endl; //for (std::list<const Track2D*>::const_iterator it=tin_.begin(); it!=tin_.end(); ++it) delete *it; //for (std::list<const Track2D*>::const_iterator it=tout_.begin(); it!=tout_.end(); ++it) delete *it; //for (std::list<const Track2D*>::const_iterator it=vin_.begin(); it!=vin_.end(); ++it) delete *it; //for (std::list<const Track2D*>::const_iterator it=vout_.begin(); it!=vout_.end(); ++it) delete *it; if (poolTrack2D_) poolTrack2D_->Clear(); if (poolTrack2D_) poolSuperTrack2D_->Clear(); if (poolTrack2D_) poolSuperTrack_->Clear(); //for (std::list<const SuperTrack2D*>::const_iterator it=vSuperTracks_.begin(); it!=vSuperTracks_.end(); ++it) delete *it; //for (std::list<const SuperTrack2D*>::const_iterator it=tSuperTracks_.begin(); it!=tSuperTracks_.end(); ++it) delete *it; //for (std::list<const SuperTrack*>::const_iterator it=superTracks_.begin(); it!=superTracks_.end(); ++it) delete *it; //------------ delete pCTSensors_; } void Tracking() { // sanity checks if (pCTSensors_->t_hits[0].size() + pCTSensors_->t_hits[1].size() == 0) return; if (pCTSensors_->t_hits[2].size() + pCTSensors_->t_hits[3].size() == 0) return; if (pCTSensors_->v_hits[0].size() + pCTSensors_->v_hits[1].size() == 0) return; if (pCTSensors_->v_hits[2].size() + pCTSensors_->v_hits[3].size() == 0) return; if (false || pCTSensors_->t_hits[0].size() > 3 || pCTSensors_->t_hits[1].size() > 3 || pCTSensors_->t_hits[2].size() > 3 || pCTSensors_->t_hits[3].size() > 3 || pCTSensors_->v_hits[0].size() > 3 || pCTSensors_->v_hits[1].size() > 3 || pCTSensors_->v_hits[2].size() > 3 || pCTSensors_->v_hits[3].size() > 3 ) return; GenerateTracks2D(); if (tin_.size() && tout_.size() && vin_.size() && vout_.size()) GenerateSuperTracks2D(); if (vSuperTracks_.size() && tSuperTracks_.size()) GenerateSuperTracks(); if (superTracks_.size() > 0) { Corrections(); return; // seems to be fine event } // try to recover gap hits Int_t n_t_hits[4]; // initial number of the hits before adding of the gap hits for (int ilayer=0; ilayer<4; ++ilayer) n_t_hits[ilayer] = pCTSensors_->t_hits[ilayer].size(); Int_t n_v_hits[4]; // initial number of the hits before adding of the gap hits for (int ilayer=0; ilayer<4; ++ilayer) n_v_hits[ilayer] = pCTSensors_->v_hits[ilayer].size(); // input telescope RecoverHits(0, beamSpotIn_); // output telescope RecoverHits(2, beamSpotOut_); // redo the track reconstruction GenerateTracks2D(); if (!tin_.size() || !tout_.size() || !vin_.size() || !vout_.size()) return; if (tin_.size() && tout_.size() && vin_.size() && vout_.size()) GenerateSuperTracks2D(); if (vSuperTracks_.size() && tSuperTracks_.size()) GenerateSuperTracks(); if (debug_) cout<< "Reco::Tracking: superTracks_.size() = " << superTracks_.size() <<endl; if (superTracks_.size() > 0) Corrections(); } void Corrections() { if (debug_) cout<< "Reco::Corrections: superTracks_.size() = " << superTracks_.size() <<endl; if (superTracks_.size() == 0) return; //-- Double_t tilt = 2.94e-3; // radians Double_t tilt = 2.50e-3; // radians // after Robert's corrections for (std::list<const SuperTrack*>::iterator it=superTracks_.begin(); it!=superTracks_.end(); ++it) { const SuperTrack* superTrack = *it; Track2D* otrack_t = const_cast<Track2D*>(superTrack->tTrack_->otrack2D_); Track2D* otrack_v = const_cast<Track2D*>(superTrack->vTrack_->otrack2D_); Double_t v0 = otrack_v->x_; Double_t t0 = otrack_t->x_; //--AZ-- otrack_t->x_ -= v0*tilt - 0.030; //--AZ-- otrack_v->x_ += (t0 - 150.)*tilt - 0.15; otrack_t->x_ -= (v0 - 12.)*tilt; otrack_v->x_ += t0*tilt; // otrack_t->x_ -= (v0 - 10.)*tilt; // otrack_v->x_ += (t0 - 170.)*tilt; } } void RecoverHits(Int_t layerToStart, const BeamSpot* beamSpot) { Int_t n_t_hits[4]; // initial number of the hits before adding of the gap hits for (int ilayer=0; ilayer<4; ++ilayer) n_t_hits[ilayer] = pCTSensors_->t_hits[ilayer].size(); Int_t n_v_hits[4]; // initial number of the hits before adding of the gap hits for (int ilayer=0; ilayer<4; ++ilayer) n_v_hits[ilayer] = pCTSensors_->v_hits[ilayer].size(); SensorHit vertexHit_t(0, 0, 0, beamSpot->u_, beamSpot->t_); // vertex hit for recovery of the t-hits SensorHit vertexHit_v(0, 0, 0, beamSpot->u_, beamSpot->v_); // vertex hit for recovery of the v-hits Int_t layer1 = layerToStart; Int_t layer2 = layer1 + 1; //-- Double_t distance_max = 1. + 5.*beamSpot->r_*(geometry_->ut_[1]-geometry_->ut_[0])/(geometry_->ut_[0] - beamSpot->u_); Double_t distance_max = 1. + 5.*beamSpot->r_*(geometry_->ut_[layer2]-geometry_->ut_[layer1])/(geometry_->ut_[layer1] - beamSpot->u_); for (int ilayer=layerToStart; ilayer<=layerToStart+1; ++ilayer) { for (int ihit=0; ihit<n_t_hits[ilayer]; ++ihit) // loop over "real" t-hits { const SensorHit* hit = pCTSensors_->t_hits[ilayer][ihit]; Track2D vertex_track(&vertexHit_t, hit); Int_t layerTo = (ilayer == layerToStart)? layerToStart+1: layerToStart; Double_t pos = vertex_track.at(geometry_->ut_[layerTo]); // position of the t-hit. Will be used for both t- and v-recovery // look at t-gaps for t-hits recovery for (int igap=0; igap<3; ++igap) { //------------- if (TMath::Abs(pos - pCTSensors_->gap_.tgap_[layerTo][igap]) < distance_max) if (TMath::Abs(pos - pCTSensors_->gap_.tgap_[layerTo][igap]) < pCTSensors_->gap_.width_) { // create a gap hit //----------------- // Double_t sigma_vertex = beamSpot->r_*(geometry_->ut_[layer2] - geometry_->ut_[layer1])/(geometry_->ut_[layerTo]-beamSpot->u_); // Double_t sigma_gap = 1./TMath::Sqrt(12.); // Double_t w_vertex = 1./(sigma_vertex*sigma_vertex); // Double_t w_gap = 1./(sigma_gap*sigma_gap); // Double_t pos_mean = (w_vertex*pos + w_gap*pCTSensors_->gap_.tgap_[layerTo][igap]) / (w_vertex + w_gap); Double_t pos_mean = pCTSensors_->gap_.tgap_[layerTo][igap]; //----------------- Int_t nstrips_gap = pCTSensors_->gap_.width_/geometry_->pitch_; Int_t sensorId = -(20 + layerTo); //-- SensorHit* gapHit = new ((*Sensor::poolSensorHit_)[Sensor::poolSensorHit_->GetLast()+1]) //-- SensorHit(sensorId, 0, nstrips_gap, geometry_->ut_[layerTo], pCTSensors_->gap_.tgap_[layerTo][igap]); SensorHit* gapHit = new ((*Sensor::poolSensorHit_)[Sensor::poolSensorHit_->GetLast()+1]) SensorHit(sensorId, 0, nstrips_gap, geometry_->ut_[layerTo], pos_mean); // add it to the common place pCTSensors_->t_hits[layerTo].push_back(gapHit); if (debug_) cout<< " added t hit " << *gapHit <<endl; } } // look at v-gaps for v-hits recovery for (int igap=0; igap<3; ++igap) { //------------ if (TMath::Abs(pos - pCTSensors_->gap_.vgap_[layerTo][igap]) < distance_max) if (TMath::Abs(pos - pCTSensors_->gap_.vgap_[layerTo][igap]) < pCTSensors_->gap_.width_) { // create a gap hit for V Int_t nstrips_gap = pCTSensors_->gap_.width_/geometry_->pitch_; // project all v-hits for (int ihit_v=0; ihit_v<n_v_hits[ilayer]; ++ihit_v) { const SensorHit* hit_v = pCTSensors_->v_hits[ilayer][ihit]; // current v-hit Track2D vertex_track_v(&vertexHit_v, hit_v); // vertex track for fcurrent v-hit Int_t sensorId = -(10 + layerTo); SensorHit* gapHit = new ((*Sensor::poolSensorHit_)[Sensor::poolSensorHit_->GetLast()+1]) SensorHit(sensorId, 0, nstrips_gap, geometry_->uv_[layerTo], vertex_track_v.at(geometry_->uv_[layerTo])); // create v-hit at projection of v vertex track // add it to the common place pCTSensors_->v_hits[layerTo].push_back(gapHit); if (debug_) cout<< " added v hit " << *gapHit <<endl; } } } } } } void GenerateTracks2D() { tin_.clear(); tout_.clear(); vin_.clear(); vout_.clear(); // T-sensors for (unsigned ihit1=0; ihit1<pCTSensors_->t_hits[0].size(); ++ihit1) { const SensorHit* hit1 = pCTSensors_->t_hits[0][ihit1]; if (debug_) cout<< "hit1: " << *hit1 <<endl; for (unsigned ihit2=0; ihit2<pCTSensors_->t_hits[1].size(); ++ihit2) { const SensorHit* hit2 = pCTSensors_->t_hits[1][ihit2]; if (debug_) cout<< "hit2: " << *hit2 <<endl; if (hit1->sensorId_ < 0 && hit2->sensorId_ < 0) continue; // at least one of the hits should be "real" Track2D* cRay2d = new ((*poolTrack2D_)[poolTrack2D_->GetLast()+1]) Track2D(hit1, hit2); tin_.push_back(cRay2d); } } for (unsigned ihit1=0; ihit1<pCTSensors_->t_hits[2].size(); ++ihit1) { const SensorHit* hit1 = pCTSensors_->t_hits[2][ihit1]; if (debug_) cout<< "hit1: " << *hit1 <<endl; for (unsigned ihit2=0; ihit2<pCTSensors_->t_hits[3].size(); ++ihit2) { const SensorHit* hit2 = pCTSensors_->t_hits[3][ihit2]; if (debug_) cout<< "hit2: " << *hit2 <<endl; if (hit1->sensorId_ < 0 && hit2->sensorId_ < 0) continue; // at least one of the hits should be "real" Track2D* cRay2d = new ((*poolTrack2D_)[poolTrack2D_->GetLast()+1]) Track2D(hit1, hit2); tout_.push_back(cRay2d); } } if (debug_) { cout<< "tin_" <<endl; for (std::list<const Track2D*>::const_iterator it=tin_.begin(); it!=tin_.end(); ++it) { cout<< "it->x_ = " << (*it)->x_ <<endl; } } if (debug_) { cout<< "tout_" <<endl; for (std::list<const Track2D*>::const_iterator it=tout_.begin(); it!=tout_.end(); ++it) { cout<< "it->x_ = " << (*it)->x_ <<endl; } } // V-sensors for (unsigned ihit1=0; ihit1<pCTSensors_->v_hits[0].size(); ++ihit1) { SensorHit* hit1 = pCTSensors_->v_hits[0][ihit1]; if (debug_) cout<< "hit1: " << *hit1 <<endl; for (unsigned ihit2=0; ihit2<pCTSensors_->v_hits[1].size(); ++ihit2) { SensorHit* hit2 = pCTSensors_->v_hits[1][ihit2]; if (debug_) cout<< "hit2: " << *hit2 <<endl; if (hit1->sensorId_ < 0 && hit2->sensorId_ < 0) continue; // at least one of the hits should be "real" Track2D* cRay2d = new ((*poolTrack2D_)[poolTrack2D_->GetLast()+1]) Track2D(hit1, hit2); vin_.push_back(cRay2d); } } for (unsigned ihit1=0; ihit1<pCTSensors_->v_hits[2].size(); ++ihit1) { SensorHit* hit1 = pCTSensors_->v_hits[2][ihit1]; if (debug_) cout<< "hit1: " << *hit1 <<endl; for (unsigned ihit2=0; ihit2<pCTSensors_->v_hits[3].size(); ++ihit2) { SensorHit* hit2 = pCTSensors_->v_hits[3][ihit2]; if (debug_) cout<< "hit2: " << *hit2 <<endl; if (hit1->sensorId_ < 0 && hit2->sensorId_ < 0) continue; // at least one of the hits should be "real" Track2D* cRay2d = new ((*poolTrack2D_)[poolTrack2D_->GetLast()+1]) Track2D(hit1, hit2); vout_.push_back(cRay2d); } } if (debug_) { cout<< "vin_" <<endl; for (std::list<const Track2D*>::const_iterator it=vin_.begin(); it!=vin_.end(); ++it) { cout<< "it->x_ = " << (*it)->x_ <<endl; } } if (debug_) { cout<< "vout_" <<endl; for (std::list<const Track2D*>::const_iterator it=vout_.begin(); it!=vout_.end(); ++it) { cout<< "it->x_ = " << (*it)->x_ <<endl; } } } void GenerateVSuperTracks2D(Double_t rmax=10.) { vSuperTracks_.clear(); // start from V-senosors: as a max we can reconstruct two tracks and only if they are from different V-sensors for (std::list<const Track2D*>::const_iterator it=vin_.begin(); it!=vin_.end(); ++it) { const Track2D* itrack = *it; for (std::list<const Track2D*>::const_iterator ot=vout_.begin(); ot!=vout_.end(); ++ot) { const Track2D* otrack = *ot; //-- SuperTrack2D* superTrack = new SuperTrack2D(itrack, otrack); SuperTrack2D* superTrack = new ((*poolSuperTrack2D_)[poolSuperTrack2D_->GetLast()+1]) SuperTrack2D(itrack, otrack); vSuperTracks_.push_back(superTrack); } } // apply filter on the distance between the hits in the plane u = 0 std::map<Double_t, const SuperTrack2D*> mapCloseTracks; // for the filter on the distance in the plane u = 0 for (std::list<const SuperTrack2D*>::const_iterator it=vSuperTracks_.begin(); it!=vSuperTracks_.end(); ++it) { const SuperTrack2D* superTrack = *it; mapCloseTracks[superTrack->Distance()] = superTrack; } if (debug_) cout<< "GenerateSuperTracks2D: vSuperTracks_.size() = " << vSuperTracks_.size() <<endl; if (debug_) { cout<< "resulting distance map from SuperTracks2D for V-board" <<endl; for (std::map<Double_t, const SuperTrack2D*>::const_iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end(); ++it) { Double_t distance = it->first; cout<< std::distance<std::map<Double_t, const SuperTrack2D*>::const_iterator>(mapCloseTracks.begin(), it) << "\t distance = " << distance <<endl; } } // 1) loop over map to remove the tracks with higher distance // 2) check for hits overlap in the (small number) of passed tracks if (debug_) cout<< "loop over the map to remove tracks with distance above the rmax = " << rmax <<endl; //--const-- for (std::map<Double_t, const SuperTrack2D*>::const_iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end();) for (std::map<Double_t, const SuperTrack2D*>::iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end();) { if (it->first < rmax) ++it; else { if (debug_) cout<< "remove track with distance " << it->first <<endl; vSuperTracks_.remove(it->second); //-- it = mapCloseTracks.erase(it); mapCloseTracks.erase(it++); } } if (debug_) cout<< "GenerateSuperTracks2D: vSuperTracks_.size() = " << vSuperTracks_.size() <<endl; // make sure that the rest of tracks do not share the same hits //--const-- for (std::map<Double_t, const SuperTrack2D*>::const_iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end(); ++it) for (std::map<Double_t, const SuperTrack2D*>::iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end(); ++it) { //--const-- std::map<Double_t, const SuperTrack2D*>::const_iterator next = it; std::map<Double_t, const SuperTrack2D*>::iterator next = it; ++next; while (next != mapCloseTracks.end()) { if (next->second->SharedHits(it->second)) { vSuperTracks_.remove(next->second); //-- next = mapCloseTracks.erase(next); mapCloseTracks.erase(next++); } else ++next; } } } void GenerateTSuperTracks2D(Double_t rmax=10.) { tSuperTracks_.clear(); for (std::list<const Track2D*>::const_iterator it=tin_.begin(); it!=tin_.end(); ++it) { const Track2D* itrack2D = *it; for (std::list<const Track2D*>::const_iterator ot=tout_.begin(); ot!=tout_.end(); ++ot) { const Track2D* otrack2D = *ot; //-- SuperTrack2D* superTrack2D = new SuperTrack2D(itrack2D, otrack2D); SuperTrack2D* superTrack2D = new ((*poolSuperTrack2D_)[poolSuperTrack2D_->GetLast()+1]) SuperTrack2D(itrack2D, otrack2D); tSuperTracks_.push_back(superTrack2D); } } // apply filter on the distance between the hits in the plane u = 0 std::map<Double_t, const SuperTrack2D*> mapCloseTracks; // for the filter on the distance in the plane u = 0 for (std::list<const SuperTrack2D*>::const_iterator it=tSuperTracks_.begin(); it!=tSuperTracks_.end(); ++it) { const SuperTrack2D* superTrack = *it; mapCloseTracks[superTrack->Distance()] = superTrack; } if (debug_) cout<< "GenerateSuperTracks2D: tSuperTracks_.size() = " << tSuperTracks_.size() <<endl; if (debug_) { cout<< "resulting distance map from SuperTracks2D for T-board" <<endl; for (std::map<Double_t, const SuperTrack2D*>::const_iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end(); ++it) { Double_t distance = it->first; cout<< std::distance<std::map<Double_t, const SuperTrack2D*>::const_iterator>(mapCloseTracks.begin(), it) << "\t distance = " << distance <<endl; } } // 1) loop over map to remove the tracks with higher distance // 2) check for hits overlap in the (small number) of passed tracks if (debug_) cout<< "loop over the map to remove tracks with distance above the rmax = " << rmax <<endl; //--const-- for (std::map<Double_t, const SuperTrack2D*>::const_iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end();) for (std::map<Double_t, const SuperTrack2D*>::iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end();) { if (it->first < rmax) ++it; else { if (debug_) cout<< "remove track with distance " << it->first <<endl; tSuperTracks_.remove(it->second); //-- it = mapCloseTracks.erase(it); mapCloseTracks.erase(it++); } } if (debug_) cout<< "GenerateSuperTracks2D: tSuperTracks_.size() = " << tSuperTracks_.size() <<endl; // make sure that the rest of tracks do not share the same hits //--const-- for (std::map<Double_t, const SuperTrack2D*>::const_iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end(); ++it) for (std::map<Double_t, const SuperTrack2D*>::iterator it=mapCloseTracks.begin(); it!=mapCloseTracks.end(); ++it) { //--const-- std::map<Double_t, const SuperTrack2D*>::const_iterator next = it; std::map<Double_t, const SuperTrack2D*>::iterator next = it; ++next; while (next != mapCloseTracks.end()) { if (next->second->SharedHits(it->second)) { tSuperTracks_.remove(next->second); //-- next = mapCloseTracks.erase(next); mapCloseTracks.erase(next++); } else ++next; } } } void GenerateSuperTracks2D(Double_t rmax=10.) { GenerateVSuperTracks2D(rmax); // if (vSuperTracks_.size() > 2) return; // else if (vSuperTracks_.size() == 2) { // // check halves // } GenerateTSuperTracks2D(rmax); } void GenerateSuperTracks() { superTracks_.clear(); if (debug_) cout<< "GenerateSuperTracks: vSuperTracks_.size() = " << vSuperTracks_.size() << " tSuperTracks_.size() = " << tSuperTracks_.size() <<endl; // inspect the number of T-super tracks 2D: maximum number is 2 if (tSuperTracks_.size() > 2) return; // inspect the number of V-super tracks 2D: maximum number is 2. // In case of 2 tracks they should be from different halves of the V-board (at least in one layer) if (vSuperTracks_.size() > 2) return; if (vSuperTracks_.size() == 2) { const SuperTrack2D* track1 = vSuperTracks_.front(); const SuperTrack2D* track2 = vSuperTracks_.back(); bool same = true && track1->itrack2D_->hit1_->sensorId_ == track2->itrack2D_->hit1_->sensorId_ && track1->itrack2D_->hit2_->sensorId_ == track2->itrack2D_->hit2_->sensorId_ && track1->otrack2D_->hit1_->sensorId_ == track2->otrack2D_->hit1_->sensorId_ && track1->otrack2D_->hit2_->sensorId_ == track2->otrack2D_->hit2_->sensorId_ ; if (same) { if (debug_) cout<< "GenerateSuperTracks: same = " << same <<endl; return; } } // at this point we have as max two t-superTracks and no more than v-superTracks // in principle, we should combine them to match V-board halves with the t-tracks // // leave that for future // if (vSuperTracks_.size() != 1) return; if (tSuperTracks_.size() != 1) return; // match the halves //-- SuperTrack* superTrack = new SuperTrack(vSuperTracks_.front(), tSuperTracks_.front()); SuperTrack* superTrack = new ((*poolSuperTrack_)[poolSuperTrack_->GetLast()+1]) SuperTrack(vSuperTracks_.front(), tSuperTracks_.front()); superTracks_.push_back(superTrack); } }; class RecoEvent: public TObject { public: Bool_t ok; // error flag Float_t deltaT; TClonesArray* track; //-> Int_t nt; // the number of super tracks Float_t a[5]; // Energy detector channels Float_t ped[5]; Float_t sample[5][16]; // to plot e.g. channel 1: r->Draw("sample[1][]:Iteration$","Entry$==0") Float_t wepl; // additional info Int_t nhit; Int_t nhitv[4]; Int_t nhitt[4]; Int_t nhit_reco; Int_t nhitv_reco[4]; Int_t nhitt_reco[4]; TClonesArray* firstHitv; //-> TClonesArray* firstHitt; //-> RecoEvent(): TObject(), ok(kTRUE), nt(0) { track = new TClonesArray("SuperTrack"); firstHitv = new TClonesArray("SensorHit", 1); firstHitt = new TClonesArray("SensorHit", 1); } ~RecoEvent() { delete track; delete firstHitv; delete firstHitt; } void clear() { deltaT = 0; track->Clear(); firstHitv->Clear(); firstHitt->Clear(); nt = 0; for (int i=0; i<5; ++i) { a[i] = 0; ped[i] = 0; } for (int ichan=0; ichan<5; ++ichan) for (int isample=0; isample<16; ++isample) sample[ichan][isample] = 0; wepl = -2000.; } Float_t SampleSum(Int_t chan, Int_t nfront, Int_t ntail, Double_t pedestal) const { if (chan < 0 || chan > 4) return 0; // find a position of the maximum Int_t imax = 0; // assumes that the number of samples is 16 Float_t sum = sample[chan][imax]; for (int isample=0; isample<16; ++isample) { sum += sample[chan][isample]; if (sample[chan][isample] > sample[chan][imax]) { imax = isample; } } if (sum == 0) return 0; // there are no samples in this event Int_t n1 = imax - nfront; if (n1 < 0) n1 = 0; Int_t n2 = imax + ntail; if (n2 > 15) n2 = 15; sum = 0; for (int isample=n1; isample<=n2; ++isample) sum += sample[chan][isample]; sum -= (n2 - n1 + 1)*pedestal; return sum; } void Extract(const Reco& reco) { clear(); nhit = 0; for (int ilayer=0; ilayer<4; ++ilayer) { nhitv[ilayer] = reco.nhitv_[ilayer]; nhitt[ilayer] = reco.nhitt_[ilayer]; nhit += (nhitv[ilayer] + nhitt[ilayer]); nhitv_reco[ilayer] = 0; nhitt_reco[ilayer] = 0; nhit_reco = 0; } for (std::list<const SensorHit*>::const_iterator it=reco.firstHitv_.begin(); it!=reco.firstHitv_.end(); ++it) { const SensorHit* hit = *it; new ((*firstHitv)[firstHitv->GetLast()+1]) SensorHit(*hit); } for (std::list<const SensorHit*>::const_iterator it=reco.firstHitt_.begin(); it!=reco.firstHitt_.end(); ++it) { const SensorHit* hit = *it; new ((*firstHitt)[firstHitt->GetLast()+1]) SensorHit(*hit); } deltaT = reco.deltaT_; for (std::list<const SuperTrack*>::const_iterator it=reco.superTracks_.begin(); it!=reco.superTracks_.end(); ++it) { const SuperTrack* superTrack = *it; new ((*track)[track->GetLast()+1]) SuperTrack(*superTrack); ++nt; if (superTrack->vTrack_->itrack2D_->hit1_->sensorId_ < 0) ++nhitv_reco[0]; if (superTrack->vTrack_->itrack2D_->hit2_->sensorId_ < 0) ++nhitv_reco[1]; if (superTrack->vTrack_->otrack2D_->hit1_->sensorId_ < 0) ++nhitv_reco[2]; if (superTrack->vTrack_->otrack2D_->hit2_->sensorId_ < 0) ++nhitv_reco[3]; if (superTrack->tTrack_->itrack2D_->hit1_->sensorId_ < 0) ++nhitt_reco[0]; if (superTrack->tTrack_->itrack2D_->hit2_->sensorId_ < 0) ++nhitt_reco[1]; if (superTrack->tTrack_->otrack2D_->hit1_->sensorId_ < 0) ++nhitt_reco[2]; if (superTrack->tTrack_->otrack2D_->hit2_->sensorId_ < 0) ++nhitt_reco[3]; } nhit_reco = 0; for (int ilayer=0; ilayer<4; ++ilayer) { nhit_reco += nhitv_reco[ilayer]; nhit_reco += nhitt_reco[ilayer]; } // Energy detector //a[0] = reco.pCTEvent_->energyBoard[0].pulse[0]; //a[1] = reco.pCTEvent_->energyBoard[0].pulse[1]; //a[2] = reco.pCTEvent_->energyBoard[0].pulse[2]; //a[3] = reco.pCTEvent_->energyBoard[1].pulse[0]; //a[4] = reco.pCTEvent_->energyBoard[1].pulse[1]; ///////////////////////////// int brd=0; ///// //--orig int enrgTag0= thisEvent->Event->Board[0].enrgTag; ///// //--orig int enrgTag1= thisEvent->Event->Board[1].enrgTag; ///// // if (enrgTag0 != enrgTag1) cout << "enrg tag mismatch: " << enrgTag0 << " vs " << enrgTag1; if (reco.pCTEvent_->energyBoard[brd].numChan>0 || reco.pCTEvent_->energyBoard[brd].numSamples>0) { ///// // if (thisEvent->Event->Board[brd].enrgTag != evtNum % 4) cout << "tag mismatch, energy tag=" << thisEvent->Event->Board[brd].enrgTag << "\n"; if (reco.pCTEvent_->energyBoard[brd].reduced) { a[0] = reco.pCTEvent_->energyBoard[brd].pulse[0]; ped[0] = reco.pCTEvent_->energyBoard[brd].pedestal[0]; a[1] = reco.pCTEvent_->energyBoard[brd].pulse[1]; ped[1] = reco.pCTEvent_->energyBoard[brd].pedestal[1]; a[2] = reco.pCTEvent_->energyBoard[brd].pulse[2]; ped[2] = reco.pCTEvent_->energyBoard[brd].pedestal[2]; } else { a[0] = 0.; a[1] = 0.; a[2] = 0.; /// enrgSamp *thisSamp = thisEvent->Event->Board[brd].firstSample; //EnergySample* energySample = (EnergySample*) reco.pCTEvent_->energyBoard[brd].samples->At(0); //if (thisSamp != 0) if (reco.pCTEvent_->energyBoard[brd].samples->GetLast()+1 > 0) { EnergySample* energySample0 = (EnergySample*) reco.pCTEvent_->energyBoard[brd].samples->At(0); sample[0][0] = energySample0->pulse[0]; // assign the first sample of the RecoEvent::sample for the first energy board sample[1][0] = energySample0->pulse[1]; sample[2][0] = energySample0->pulse[2]; int ped0 = energySample0->pulse[0]; ped[0] = ped0; int ped1 = energySample0->pulse[1]; ped[1] = ped1; int ped2 = energySample0->pulse[2]; ped[2] = ped2; //while (thisSamp != 0) for (int isample=1; isample<reco.pCTEvent_->energyBoard[brd].samples->GetLast()+1; ++isample) { EnergySample* energySample = (EnergySample*) reco.pCTEvent_->energyBoard[brd].samples->At(isample); sample[0][isample] = energySample->pulse[0]; // assign the rest of 16 samples of the RecoEvent::sample for the first energy board sample[1][isample] = energySample->pulse[1]; sample[2][isample] = energySample->pulse[2]; a[0] = a[0] + energySample->pulse[0] - ped0; a[1] = a[1] + energySample->pulse[1] - ped1; a[2] = a[2] + energySample->pulse[2] - ped2; } } } } else { a[0] = 0; ped[0] = 0; a[1] = 0; ped[1] = 0; a[2] = 0; ped[2] = 0; } brd=1; if (reco.pCTEvent_->energyBoard[brd].numChan>0 || reco.pCTEvent_->energyBoard[brd].numSamples>0) { ///// // if (thisEvent->Event->Board[brd].enrgTag != evtNum % 4) cout << "tag mismatch, energy tag=" << thisEvent->Event->Board[brd].enrgTag << "\n"; if (reco.pCTEvent_->energyBoard[brd].reduced) { a[3] = reco.pCTEvent_->energyBoard[brd].pulse[0]; ped[3] = reco.pCTEvent_->energyBoard[brd].pedestal[0]; a[4] = reco.pCTEvent_->energyBoard[brd].pulse[1]; ped[4] = reco.pCTEvent_->energyBoard[brd].pedestal[1]; //--no such channel-- PhCh5 = reco.pCTEvent_->energyBoard[brd].pulse[2]; } else { a[3] = 0.; a[4] = 0.; //--no such channel-- PhCh5 = 0.; int ped3 = 0; int ped4 = 0; int ped5 = 0; /// enrgSamp *thisSamp = thisEvent->Event->Board[brd].firstSample; //EnergySample* energySample = (EnergySample*) reco.pCTEvent_->energyBoard[brd].samples->At(0); //if (thisSamp != 0) if (reco.pCTEvent_->energyBoard[brd].samples->GetLast()+1 > 0) { EnergySample* energySample0 = (EnergySample*) reco.pCTEvent_->energyBoard[brd].samples->At(0); sample[3][0] = energySample0->pulse[0]; // assign the first sample of the RecoEvent::sample for the second energy board sample[4][0] = energySample0->pulse[1]; ped3 = energySample0->pulse[0]; ped[3] = ped3; ped4 = energySample0->pulse[1]; ped[4] = ped4; ped5 = energySample0->pulse[2]; //while (thisSamp != 0) for (int isample=1; isample<reco.pCTEvent_->energyBoard[brd].samples->GetLast()+1; ++isample) { EnergySample* energySample = (EnergySample*) reco.pCTEvent_->energyBoard[brd].samples->At(isample); sample[3][isample] = energySample->pulse[0]; // assign the rest of 16 samples of the RecoEvent::sample for the second energy board sample[4][isample] = energySample->pulse[1]; a[3] = a[3] + energySample->pulse[0] - ped3; a[4] = a[4] + energySample->pulse[1] - ped4; //--no such channel-- PhCh5 = PhCh5 + energySample->pulse[2] - ped5; } } } } else { a[3] = 0; ped[3] = 0; a[4] = 0; ped[4] = 0; //--no such channel-- PhCh5 = 0; } ///////////////////////////// } ClassDef(RecoEvent, 10); }; #ifdef __MAKECINT__ #pragma link C++ class RecoEvent; #endif #endif // Reco_h
[ "zatserkl@gmail.com" ]
zatserkl@gmail.com
f41d41885bab9a639e39fb8071eb7590fdef1d43
4d96f3f730ec960a13cccb231ee024b7ac0693bd
/printout.cpp
abf652b5dc9febe025e74901b1eb9a1fc075860d
[ "MIT" ]
permissive
daikai999/stairspeedtest-reborn
c21c7b2f44d40ed11697b8a65a7305e4c227542b
06fb03ddd68800a77515e8209de0f1f4bff76cac
refs/heads/master
2020-08-28T14:52:30.561834
2019-09-29T15:09:21
2019-09-29T15:09:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,479
cpp
#include <iostream> #include <fstream> #include "printout.h" #include "version.h" //define print-out messages struct LOOKUP_ITEM { int index; string info; }; LOOKUP_ITEM SPEEDTEST_MESSAGES[] = { {SPEEDTEST_MESSAGE_EOF, "\nSpeed Test done. Press any key to exit..."}, {SPEEDTEST_MESSAGE_WELCOME, "Welcome to Stair Speedtest " VERSION "!\nWhich stair do you want to test today? (Supports single Shadowsocks/ShadowsocksD/ShadowsocksR/V2Ray link and their subscribe links)\nIf you want to test more than one link, separate them with '|'.\nLink: "}, {SPEEDTEST_MESSAGE_MULTILINK, "Multiple link provided, parsing all nodes.\n\n"}, {SPEEDTEST_MESSAGE_FOUNDVMESS, "Found single V2Ray link.\n"}, {SPEEDTEST_MESSAGE_FOUNDSS, "Found single Shadowsocks link.\n"}, {SPEEDTEST_MESSAGE_FOUNDSSR, "Found single ShadowsocksR link.\n"}, {SPEEDTEST_MESSAGE_FOUNDSOCKS, "Found single Socks 5 link.\n"}, {SPEEDTEST_MESSAGE_FOUNDSUB, "Found subscribe link.\n"}, {SPEEDTEST_MESSAGE_FOUNDLOCAL, "Found local configure file.\n"}, {SPEEDTEST_MESSAGE_GROUP, "If you have imported an V2Ray subscribe link which doesn't contain a Group Name, you can specify a custom name below.\nIf you have imported an Shadowsocks/ShadowsocksR link which contains a Group Name, press Enter to skip.\nCustom Group Name: "}, {SPEEDTEST_MESSAGE_GOTSERVER, "\nCurrent Server Group: ?group? Remarks: ?remarks? Index: ?index?/?total?\n"}, {SPEEDTEST_MESSAGE_STARTPING, "Now performing TCP Ping...\n"}, {SPEEDTEST_MESSAGE_STARTGEOIP, "Now performing GeoIP parse...\n"}, {SPEEDTEST_MESSAGE_STARTGPING, "Now performing Google Ping...\n"}, {SPEEDTEST_MESSAGE_STARTSPEED, "Now performing Speed Test...\n"}, {SPEEDTEST_MESSAGE_STARTUPD, "Now performing Upload Test...\n"}, {SPEEDTEST_MESSAGE_GOTRESULT, "Result: DL.Speed: ?speed? Max.Speed: ?maxspeed? UL.Speed: ?ulspeed? Pk.Loss: ?pkloss? Avg.Ping: ?avgping? Google Ping: ?siteping?\n"}, {SPEEDTEST_MESSAGE_TRAFFIC, "Traffic used: ?traffic?\n"}, {SPEEDTEST_MESSAGE_PICSAVING, "Now exporting picture...\n"}, {SPEEDTEST_MESSAGE_PICSAVINGMULTI, "Now exporting picture for group ?id?...\n"}, {SPEEDTEST_MESSAGE_PICSAVED, "Result picture saved to \"?picpath?\".\n"}, {SPEEDTEST_MESSAGE_PICSAVEDMULTI, "Group ?id? result picture saved to \"?picpath?\".\n"}, {SPEEDTEST_MESSAGE_FETCHSUB, "Downloading subscription data...\n"}, {SPEEDTEST_MESSAGE_PARSING, "Parsing configuration file...\n"}, {SPEEDTEST_MESSAGE_BEGIN, "Speed Test will now begin.\n"}, {SPEEDTEST_MESSAGE_GOTGEOIP, "Parsed outbound server ISP: ?isp? Country Code: ?location?\n"}, {SPEEDTEST_ERROR_UNDEFINED, "Undefined error!\n"}, {SPEEDTEST_ERROR_WSAERR, "WSA Startup error!\n"}, {SPEEDTEST_ERROR_SOCKETERR, "Socket error!\n"}, {SPEEDTEST_ERROR_NORECOGLINK, "No valid link found. Please check your link.\n"}, {SPEEDTEST_ERROR_UNRECOGFILE, "This configure file is invalid. Please make sure this is an Shadowsocks/ShadowsocksR/v2rayN configuration file or a standard subscription file.\n"}, {SPEEDTEST_ERROR_NOCONNECTION, "Cannot connect to server.\n"}, {SPEEDTEST_ERROR_INVALIDSUB, "Nothing returned from subscribe link. Please check your subscribe link.\n"}, {SPEEDTEST_ERROR_NONODES, "No nodes found. Please check your subscribe link.\n"}, {SPEEDTEST_ERROR_NORESOLVE, "Cannot resolve server address.\n"}, {SPEEDTEST_ERROR_RETEST, "Speed Test returned no speed. Retesting...\n"}, {SPEEDTEST_ERROR_NOSPEED, "Speed Test returned no speed 2 times. Skipping...\n"}, {SPEEDTEST_ERROR_SUBFETCHERR, "Cannot fetch subscription data with direct connect. Trying with system proxy...\n"}, {SPEEDTEST_ERROR_GEOIPERR, "Cannot fetch GeoIP information. Skipping...\n"}, {-1, ""} }; LOOKUP_ITEM SPEEDTEST_MESSAGES_RPC[] = { {SPEEDTEST_MESSAGE_WELCOME, "{\"info\":\"started\"}\n"}, {SPEEDTEST_MESSAGE_EOF, "{\"info\":\"eof\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDVMESS, "{\"info\":\"foundvmess\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDSS, "{\"info\":\"foundss\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDSSR, "{\"info\":\"foundssr\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDSOCKS, "{\"info\":\"foundsocks\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDSUB, "{\"info\":\"foundsub\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDLOCAL, "{\"info\":\"foundlocal\"}\n"}, {SPEEDTEST_MESSAGE_FOUNDUPD, "{\"info\":\"foundupd\"}\n"}, {SPEEDTEST_MESSAGE_GOTSERVER, "{\"info\":\"gotserver\",\"id\":?id?,\"group\":\"?group?\",\"remarks\":\"?remarks?\"}\n"}, {SPEEDTEST_MESSAGE_STARTPING, "{\"info\":\"startping\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTPING, "{\"info\":\"gotping\",\"id\":?id?,\"ping\":\"?avgping?\",\"loss\":\"?pkloss?\"}\n"}, {SPEEDTEST_MESSAGE_STARTGEOIP, "{\"info\":\"startgeoip\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTGEOIP, "{\"info\":\"gotgeoip\",\"id\":?id?,\"isp\":\"?isp?\",\"location\":\"?location?\"}\n"}, {SPEEDTEST_MESSAGE_STARTSPEED, "{\"info\":\"startspeed\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTSPEED, "{\"info\":\"gotspeed\",\"id\":?id?,\"speed\":\"?speed?\",\"maxspeed\":\"?maxspeed?\"}\n"}, {SPEEDTEST_MESSAGE_STARTUPD, "{\"info\":\"startupd\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTUPD, "{\"info\":\"gotupd\",\"id\":?id?,\"ulspeed\":\"?ulspeed?\"}\n"}, {SPEEDTEST_MESSAGE_STARTGPING, "{\"info\":\"startgping\",\"id\":?id?}\n"}, {SPEEDTEST_MESSAGE_GOTGPING, "{\"info\":\"gotgping\",\"id\":?id?,\"ping\":\"?siteping?\"}\n"}, {SPEEDTEST_MESSAGE_TRAFFIC, "(\"info\":\"traffic\",\"size\":\"?traffic?\"}\n"}, {SPEEDTEST_MESSAGE_PICSAVING, "{\"info\":\"picsaving\"}\n"}, {SPEEDTEST_MESSAGE_PICSAVED, "{\"info\":\"picsaved\",\"path\":\"?picpath?\"}\n"}, {SPEEDTEST_MESSAGE_PICSAVEDMULTI, "{\"info\":\"picsaved\",\"path\":\"?picpath?\"}\n"}, {SPEEDTEST_MESSAGE_FETCHSUB, "{\"info\":\"fetchingsub\"}\n"}, {SPEEDTEST_MESSAGE_PARSING, "{\"info\":\"parsing\"}\n"}, {SPEEDTEST_MESSAGE_BEGIN, "{\"info\":\"begintest\"}\n"}, {SPEEDTEST_MESSAGE_PICDATA, "{\"info\":\"picdata\",\"data\":\"?data?\"}\n"}, {SPEEDTEST_ERROR_UNDEFINED, "{\"info\":\"error\",\"reason\":\"undef\"}\n"}, {SPEEDTEST_ERROR_WSAERR, "{\"info\":\"error\",\"reason\":\"wsaerr\"}\n"}, {SPEEDTEST_ERROR_SOCKETERR, "{\"info\":\"error\",\"reason\":\"socketerr\"}\n"}, {SPEEDTEST_ERROR_NORECOGLINK, "{\"info\":\"error\",\"reason\":\"norecoglink\"}\n"}, {SPEEDTEST_ERROR_UNRECOGFILE, "{\"info\":\"error\",\"reason\":\"unrecogfile\"}\n"}, {SPEEDTEST_ERROR_NOCONNECTION, "{\"info\":\"error\",\"reason\":\"noconnection\",\"id\":?id?}\n"}, {SPEEDTEST_ERROR_INVALIDSUB, "{\"info\":\"error\",\"reason\":\"invalidsub\"}\n"}, {SPEEDTEST_ERROR_NONODES, "{\"info\":\"error\",\"reason\":\"nonodes\"}\n"}, {SPEEDTEST_ERROR_NORESOLVE, "{\"info\":\"error\",\"reason\":\"noresolve\",\"id\":?id?}\n"}, {SPEEDTEST_ERROR_RETEST, "{\"info\":\"error\",\"reason\":\"retest\",\"id\":?id?}\n"}, {SPEEDTEST_ERROR_NOSPEED, "{\"info\":\"error\",\"reason\":\"nospeed\",\"id\":?id?}\n"}, {SPEEDTEST_ERROR_SUBFETCHERR, "{\"info\":\"error\",\"reason\":\"subfetcherr\"}\n"}, {SPEEDTEST_ERROR_GEOIPERR, "{\"info\":\"error\",\"reason\":\"geoiperr\",\"id\":?id?}\n"}, {-1, ""} }; string lookUp(int index, LOOKUP_ITEM *items) { int i = 0; while (0 <= items[i].index) { if (items[i].index == index) return items[i].info; i++; } return string(""); } string lookUp(int index, bool rpcmode) { if(rpcmode) { return lookUp(index, SPEEDTEST_MESSAGES_RPC); } else { return lookUp(index, SPEEDTEST_MESSAGES); } } void printMsg(int index, nodeInfo *node, bool rpcmode) { string printout; printout = lookUp(index, rpcmode); if(printout.size() == 0) { return; } printout = replace_all_distinct(printout, "?group?", trim(node->group)); printout = replace_all_distinct(printout, "?remarks?", trim(node->remarks)); printout = replace_all_distinct(printout, "?id?", to_string(node->id)); printout = replace_all_distinct(printout, "?avgping?", node->avgPing); printout = replace_all_distinct(printout, "?pkloss?", node->pkLoss); printout = replace_all_distinct(printout, "?siteping?", node->sitePing); printout = replace_all_distinct(printout, "?speed?", node->avgSpeed); printout = replace_all_distinct(printout, "?maxspeed?", node->maxSpeed); printout = replace_all_distinct(printout, "?ulspeed?", node->ulSpeed); printout = replace_all_distinct(printout, "?traffic?", node->traffic); if(rpcmode) printout = replace_all_distinct(printout, "\\", "\\\\"); cout<<printout; cout.clear(); cout.flush(); } void printMsgWithDict(int index, bool rpcmode, vector<string> dict, vector<string> trans) { string printout; printout = lookUp(index, rpcmode); if(printout.size() == 0) { return; } for(unsigned int i = 0; i < dict.size(); i++) { printout = replace_all_distinct(printout, dict[i], trans[i]); } if(rpcmode) printout = replace_all_distinct(printout, "\\", "\\\\"); cout<<printout; cout.clear(); cout.flush(); } void printMsgDirect(int index, bool rpcmode) { cout<<lookUp(index, rpcmode); cout.clear(); cout.flush(); }
[ "49061470+tindy2013@users.noreply.github.com" ]
49061470+tindy2013@users.noreply.github.com
0f49bdd721aa93feaf4cd2f6ebaf1ce787a1518a
e25b7bb3fd43f763f4e5dcb09cdda35b9a3f30a0
/net/third_party/quic/test_tools/crypto_test_utils_test.cc
ede4a833f74c10c53b6ef0f83a99a0062d8cf383
[ "BSD-3-Clause" ]
permissive
trustcrypto/chromium
281ff06e944b1ff7da7a5005e41173ccc78eb2cd
6e3be4ab657ddd91505753ab67801efcf8541367
refs/heads/master
2023-03-08T03:58:49.920358
2018-12-26T20:55:44
2018-12-26T20:55:44
163,217,833
1
0
NOASSERTION
2018-12-26T21:07:41
2018-12-26T21:07:40
null
UTF-8
C++
false
false
7,065
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/third_party/quic/test_tools/crypto_test_utils.h" #include "net/test/gtest_util.h" #include "net/third_party/quic/core/proto/crypto_server_config.pb.h" #include "net/third_party/quic/core/quic_utils.h" #include "net/third_party/quic/core/tls_server_handshaker.h" #include "net/third_party/quic/platform/api/quic_ptr_util.h" #include "net/third_party/quic/platform/api/quic_test.h" #include "net/third_party/quic/platform/api/quic_text_utils.h" #include "net/third_party/quic/test_tools/mock_clock.h" namespace quic { namespace test { class ShloVerifier { public: ShloVerifier( QuicCryptoServerConfig* crypto_config, QuicSocketAddress server_addr, QuicSocketAddress client_addr, const QuicClock* clock, QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config, QuicCompressedCertsCache* compressed_certs_cache) : crypto_config_(crypto_config), server_addr_(server_addr), client_addr_(client_addr), clock_(clock), signed_config_(signed_config), compressed_certs_cache_(compressed_certs_cache), params_(new QuicCryptoNegotiatedParameters) {} class ValidateClientHelloCallback : public ValidateClientHelloResultCallback { public: explicit ValidateClientHelloCallback(ShloVerifier* shlo_verifier) : shlo_verifier_(shlo_verifier) {} void Run(QuicReferenceCountedPointer< ValidateClientHelloResultCallback::Result> result, std::unique_ptr<ProofSource::Details> /* details */) override { shlo_verifier_->ValidateClientHelloDone(result); } private: ShloVerifier* shlo_verifier_; }; std::unique_ptr<ValidateClientHelloCallback> GetValidateClientHelloCallback() { return QuicMakeUnique<ValidateClientHelloCallback>(this); } private: void ValidateClientHelloDone( const QuicReferenceCountedPointer< ValidateClientHelloResultCallback::Result>& result) { result_ = result; crypto_config_->ProcessClientHello( result_, /*reject_only=*/false, /*connection_id=*/QuicConnectionIdFromUInt64(1), server_addr_, client_addr_, AllSupportedVersions().front(), AllSupportedVersions(), /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/EmptyQuicConnectionId(), clock_, QuicRandom::GetInstance(), compressed_certs_cache_, params_, signed_config_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, GetProcessClientHelloCallback()); } class ProcessClientHelloCallback : public ProcessClientHelloResultCallback { public: explicit ProcessClientHelloCallback(ShloVerifier* shlo_verifier) : shlo_verifier_(shlo_verifier) {} void Run( QuicErrorCode error, const QuicString& error_details, std::unique_ptr<CryptoHandshakeMessage> message, std::unique_ptr<DiversificationNonce> diversification_nonce, std::unique_ptr<ProofSource::Details> proof_source_details) override { shlo_verifier_->ProcessClientHelloDone(std::move(message)); } private: ShloVerifier* shlo_verifier_; }; std::unique_ptr<ProcessClientHelloCallback> GetProcessClientHelloCallback() { return QuicMakeUnique<ProcessClientHelloCallback>(this); } void ProcessClientHelloDone(std::unique_ptr<CryptoHandshakeMessage> message) { // Verify output is a SHLO. EXPECT_EQ(message->tag(), kSHLO) << "Fail to pass validation. Get " << message->DebugString(); } QuicCryptoServerConfig* crypto_config_; QuicSocketAddress server_addr_; QuicSocketAddress client_addr_; const QuicClock* clock_; QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_; QuicCompressedCertsCache* compressed_certs_cache_; QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_; QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result> result_; }; class CryptoTestUtilsTest : public QuicTest {}; TEST_F(CryptoTestUtilsTest, TestGenerateFullCHLO) { MockClock clock; QuicCryptoServerConfig crypto_config( QuicCryptoServerConfig::TESTING, QuicRandom::GetInstance(), crypto_test_utils::ProofSourceForTesting(), KeyExchangeSource::Default(), TlsServerHandshaker::CreateSslCtx()); QuicSocketAddress server_addr; QuicSocketAddress client_addr(QuicIpAddress::Loopback4(), 1); QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config( new QuicSignedServerConfig); QuicCompressedCertsCache compressed_certs_cache( QuicCompressedCertsCache::kQuicCompressedCertsCacheSize); CryptoHandshakeMessage full_chlo; QuicCryptoServerConfig::ConfigOptions old_config_options; old_config_options.id = "old-config-id"; delete crypto_config.AddDefaultConfig(QuicRandom::GetInstance(), &clock, old_config_options); QuicCryptoServerConfig::ConfigOptions new_config_options; std::unique_ptr<QuicServerConfigProtobuf> primary_config( crypto_config.GenerateConfig(QuicRandom::GetInstance(), &clock, new_config_options)); primary_config->set_primary_time(clock.WallNow().ToUNIXSeconds()); std::unique_ptr<CryptoHandshakeMessage> msg( crypto_config.AddConfig(std::move(primary_config), clock.WallNow())); QuicStringPiece orbit; ASSERT_TRUE(msg->GetStringPiece(kORBT, &orbit)); QuicString nonce; CryptoUtils::GenerateNonce( clock.WallNow(), QuicRandom::GetInstance(), QuicStringPiece(reinterpret_cast<const char*>(orbit.data()), sizeof(orbit.size())), &nonce); QuicString nonce_hex = "#" + QuicTextUtils::HexEncode(nonce); char public_value[32]; memset(public_value, 42, sizeof(public_value)); QuicString pub_hex = "#" + QuicTextUtils::HexEncode(public_value, sizeof(public_value)); QuicTransportVersion version(AllSupportedTransportVersions().front()); CryptoHandshakeMessage inchoate_chlo = crypto_test_utils::CreateCHLO( {{"PDMD", "X509"}, {"AEAD", "AESG"}, {"KEXS", "C255"}, {"COPT", "SREJ"}, {"PUBS", pub_hex}, {"NONC", nonce_hex}, {"VER\0", QuicVersionLabelToString(QuicVersionToQuicVersionLabel(version))}}, kClientHelloMinimumSize); crypto_test_utils::GenerateFullCHLO( inchoate_chlo, &crypto_config, server_addr, client_addr, version, &clock, signed_config, &compressed_certs_cache, &full_chlo); // Verify that full_chlo can pass crypto_config's verification. ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock, signed_config, &compressed_certs_cache); crypto_config.ValidateClientHello( full_chlo, client_addr.host(), server_addr, version, &clock, signed_config, shlo_verifier.GetValidateClientHelloCallback()); } } // namespace test } // namespace quic
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
8b620a29dcb24dbb05d38ad71a6517f2eb01d1ed
2851759f8e9b36197858e9ae5307ea6239da5e2e
/system/ulib/fbl/include/fbl/unique_fd.h
d9e5b771e1ad96121de7e9468d57fe79181b6a28
[ "BSD-3-Clause", "MIT" ]
permissive
Allegra42/zircon
a1a809f005c04d4cf2af672c47a2f13161848ca0
50d20f11275ecdd47faa393e3ff6465cee07a670
refs/heads/master
2020-04-05T08:02:40.558430
2018-12-29T00:28:46
2018-12-29T23:42:27
156,698,935
1
1
NOASSERTION
2018-11-08T11:48:25
2018-11-08T11:48:24
null
UTF-8
C++
false
false
1,936
h
// Copyright 2017 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #pragma once #include <stdlib.h> #include <unistd.h> #include <fbl/macros.h> #include <fbl/type_support.h> namespace fbl { // A scoped file descriptor that automatically closes when it goes // out of scope. class unique_fd { public: constexpr unique_fd() : fd_(InvalidValue()) {} explicit unique_fd(int fd) : fd_(fd) { } static constexpr int InvalidValue() { return -1; } ~unique_fd() { reset(); } unique_fd(unique_fd&& o) : fd_(o.release()) {} unique_fd& operator=(unique_fd&& o) { reset(o.release()); return *this; } // Comparison against raw file descriptors (of the form fd == unique_fd) bool operator==(int fd) const { return (fd_ == fd); } bool operator!=(int fd) const { return (fd_ != fd); } // Comparison against other unique_fd's. bool operator==(const unique_fd& o) const { return fd_ == o.fd_; } bool operator!=(const unique_fd& o) const { return fd_ != o.fd_; } // move semantics only DISALLOW_COPY_AND_ASSIGN_ALLOW_MOVE(unique_fd); fbl::unique_fd duplicate() { return fbl::unique_fd(dup(fd_)); } int release() { int t = fd_; fd_ = InvalidValue(); return t; } void reset(int t = InvalidValue()) { if (fd_ != InvalidValue()) { close(fd_); } fd_ = t; } void swap(unique_fd& other) { int t = fd_; fd_ = other.fd_; other.fd_ = t; } int get() const { return fd_; } bool is_valid() const { return fd_ != InvalidValue(); } explicit operator bool() const { return is_valid(); } explicit operator int() const { return fd_; } private: int fd_; }; } // namespace fbl
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
9c125f406393c4a12f5ca023356aaee03d52f126
56b65fbf1880a8323ab7dc15c9694d5975d2cd2c
/src/crypto/sha256.h
d5c89a6da03ec1759045af8679e45059f00a6d7d
[ "MIT" ]
permissive
btclambo/BitcoinLambo
3e4043e9486ea42401f7d38fc5d5ebbbb38b005e
fc823516765338f06bce5ad8c7e3a5d6fe90f22b
refs/heads/master
2020-03-06T18:31:07.897658
2018-03-27T15:34:49
2018-03-27T15:34:49
127,008,721
0
0
null
null
null
null
UTF-8
C++
false
false
836
h
// Copyright (c) 2014-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOINLAMBO_CRYPTO_SHA256_H #define BITCOINLAMBO_CRYPTO_SHA256_H #include <stdint.h> #include <stdlib.h> #include <string> /** A hasher class for SHA-256. */ class CSHA256 { private: uint32_t s[8]; unsigned char buf[64]; uint64_t bytes; public: static const size_t OUTPUT_SIZE = 32; CSHA256(); CSHA256& Write(const unsigned char* data, size_t len); void Finalize(unsigned char hash[OUTPUT_SIZE]); CSHA256& Reset(); }; /** Autodetect the best available SHA256 implementation. * Returns the name of the implementation. */ std::string SHA256AutoDetect(); #endif // BITCOINLAMBO_CRYPTO_SHA256_H
[ "alfa.alvaro.rodriguez@gmail.com" ]
alfa.alvaro.rodriguez@gmail.com
923877562aab22dd4dee8024f595fac6143df562
834abb946ce963e5922f1b683ac027fa4c6d9fe2
/Project2/JeffGrockowskiProject2.cpp
fab5df755ebf54a7bc1f244e5b30e66e669c13f1
[]
no_license
JeffGrock/BMI_calculator
1cb1f082bf41d7650258b4d7dd614e4ac17f8d4e
6e0b3a67d5c8c60d7fad2472611003732ce8fb35
refs/heads/main
2023-03-12T05:00:00.642667
2021-02-25T18:11:06
2021-02-25T18:11:06
342,336,090
0
0
null
null
null
null
UTF-8
C++
false
false
2,087
cpp
// Author: Jeff Grockowski // Date: 06/10/2019 // CSCI 121 project 2 // Program allows user to calculate BMI, and the amount chocolate they can eat. #include <iostream> #include <string> using namespace std; int main() { int const chocolateBarCal(230); int weight, height, age; double BMR, cBarsPerBMI; string gender("A"), repeat("Y"); while((repeat == "Y") || (repeat == "y")) // While loop for entire program, { // allows user to repeat program until user changes the "repeat" variable through input at the end of the program cout << "Welcome to my BMR calculator!\n"; cout << "Gender (M or F):"; cin >> gender; while ((gender != "F") && (gender != "M") && (gender != "m") && (gender != "f")) // loop to ensure user entry matches one of the two BMI equations { cout << "invalid gender.\n"; cout << "Gender (M or F):"; cin >> gender; } cout << "Age (In years):"; // this block obtains the rest of the variables for BMR equation, cin >> age; // this information pertains to both genders cout << "Weight (in pounds):"; cin >> weight; cout << "Height (In inches):"; cin >> height; cout << endl; if ((gender == "M") || (gender == "m")) // if else structure calculates the BMR and tells user the result based on gender input { // the else block is the female calculation BMR = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age); cBarsPerBMI = BMR / chocolateBarCal; cout << "He needs " << BMR << " calories to maintain his weight.\n"; } else { BMR = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age); cBarsPerBMI = BMR / chocolateBarCal; cout << "She needs " << BMR << " calories to maintain her weight.\n"; } cout << "that is about " << cBarsPerBMI << " Chocolate bar's calories!\n"; // this block tells user the chocolate bars worth of BMI cout << "would you like to do another calculation? (Y or N): "; // also confirms if user would like to recalculate. cin >> repeat; cout << endl; } cout << "Thanks for using my BMR calculator, Good Bye!\n"; return 0; }
[ "jeff.grockowski@protonmail.com" ]
jeff.grockowski@protonmail.com
bfb7ae2786f011cc2fd99384f16177aee94ff618
6ce4add532471bb49d199ea632ed4af377735e38
/blif_solve_lib/log.h
fa5bf5edd6cca5ca7459ce83e78115a458214950
[ "MIT" ]
permissive
appu226/FactorGraph
398688f188876eba27a67f327f97e8f0002f856d
b7cf6025339247b0d89740540a813097ca32774e
refs/heads/master
2023-08-17T15:07:21.512438
2023-06-18T17:22:11
2023-06-18T17:22:11
164,322,621
0
1
MIT
2023-02-12T21:49:24
2019-01-06T15:59:51
C++
UTF-8
C++
false
false
2,199
h
/* Copyright 2019 Parakram Majumdar 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. */ #pragma once #include <iostream> #include <ctime> namespace blif_solve { // Verbosity for logging enum Verbosity { QUIET, ERROR, WARNING, INFO, DEBUG }; Verbosity getVerbosity(); void setVerbosity(Verbosity verbosity); Verbosity parseVerbosity(const std::string & verbosity_string); #define blif_solve_log(verbosity, message) \ if (blif_solve::getVerbosity() >= blif_solve::verbosity) \ { \ std::cout << "[" << #verbosity << "] " << message << std::endl; \ } #define blif_solve_log_bdd(verbosity, message, ddm, bdd) \ if (blif_solve::getVerbosity() >= blif_solve::verbosity) \ { \ std::cout << "[" << #verbosity << "] " << message << std::endl; \ bdd_print_minterms(ddm, bdd); \ } // ****** Function ******* // duration // takes a start and end chrono time // and returns the duration in seconds as a double // *********************** template<typename T> double duration(T const & start) { return static_cast<double>(std::clock() - start)/CLOCKS_PER_SEC; } inline auto now() { return std::clock(); } } // end namespace blif_solve
[ "appu226@yahoo.co.in" ]
appu226@yahoo.co.in
501844de141de05c90c316318bcc0518f613db88
4122acc5bd9ee517fdfd1307bf8a04cc7c95599c
/mindspore/lite/src/ops/populate/common_populate.cc
8255473969877758af39d56eb1260e012a3b3039
[ "Apache-2.0", "MIT", "Libpng", "LicenseRef-scancode-proprietary-license", "LGPL-2.1-only", "AGPL-3.0-only", "MPL-2.0-no-copyleft-exception", "IJG", "Zlib", "MPL-1.1", "BSD-3-Clause", "BSD-3-Clause-Open-MPI", "MPL-1.0", "GPL-2.0-only", "MPL-2.0", "BSL-1.0", "LicenseRef-scancode-unknown-license-reference", "Unlicense", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
limberc/mindspore
655bb4fc582a85711e70c31e12f611cf1a0f422e
e294acdffc9246cb6d77ea18ea00d08244d30c59
refs/heads/master
2023-02-18T20:10:22.588348
2021-01-23T15:33:01
2021-01-23T15:33:01
322,821,027
0
0
Apache-2.0
2021-01-18T14:07:45
2020-12-19T10:27:43
null
UTF-8
C++
false
false
1,248
cc
/** * Copyright 2019-2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "src/ops/primitive_c.h" #include "src/ops/populate/populate_register.h" namespace mindspore { namespace lite { OpParameter *PopulateCommonParameter(const mindspore::lite::PrimitiveC *primitive) { auto *common_parameter = reinterpret_cast<OpParameter *>(malloc(sizeof(OpParameter))); if (common_parameter == nullptr) { MS_LOG(ERROR) << "malloc OpParameter failed."; return nullptr; } memset(common_parameter, 0, sizeof(OpParameter)); return common_parameter; } Registry ZerosLikeParameterRegistry(schema::PrimitiveType_ZerosLike, PopulateCommonParameter); } // namespace lite } // namespace mindspore
[ "yeyunpeng2020@huawei.com" ]
yeyunpeng2020@huawei.com
d20ba589794b48efbaef3d6c5034d2548ae2dee6
aead066f3cfa3491e1c3d4b6b4189a7e08868ff6
/src/socket/Connection.h
f92c747469761752a08cca5c9daccba19bb1a132
[]
no_license
thushear/AsyncWebServer
e0547954189d1911fd0f37c7a9bdd9a5ed507ebf
05f02f73fb45a85a83659515b8e78b602beef103
refs/heads/master
2021-01-18T23:52:48.480570
2015-06-02T08:51:42
2015-06-02T08:51:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,658
h
// // Created by plter on 5/21/15. // #pragma once #include <boost/asio/ip/tcp.hpp> #include "ConnectionManager.h" #include "Buffer.h" namespace aws { class ConnectionManager; class OnSocketListener; class Connection :public std::enable_shared_from_this<aws::Connection>{ friend class ServerSocket; friend class ConnectionManager; public: typedef std::shared_ptr<aws::Connection> ConnectionPtr; typedef std::function<void(ConnectionPtr socket,aws::InputBuffer & buffer,std::size_t bytes_transferred)> OnReceiveHandler; private: Connection(std::shared_ptr<boost::asio::ip::tcp::socket> asioSocket); static std::shared_ptr<aws::Connection> create(std::shared_ptr<boost::asio::ip::tcp::socket> asioSocket_); public: virtual ~Connection(); public: std::shared_ptr<boost::asio::ip::tcp::socket> getAsioSocket(); void start(); void close(); inline bool isClosed(){ return !running_; } public://set/get functions inline void setConnectionManager(std::shared_ptr<aws::ConnectionManager> manager){ connection_manager_ = manager; } inline std::shared_ptr<aws::ConnectionManager> getConnectionManager(){ return connection_manager_; } inline void setOnCloseHandler(std::function<void(std::shared_ptr<aws::Connection> socket)> handler){ onCloseHandler_ = handler; } inline std::function<void(std::shared_ptr<aws::Connection> socket)> getOnCloseHandler(){ return onCloseHandler_; } inline void setOnConnectHandler(std::function<void(std::shared_ptr<aws::Connection> socket)> handler){ onConnectHandler_ = handler; } inline std::function<void(std::shared_ptr<aws::Connection> socket)> getOnConnectHandler(){ return onConnectHandler_; } inline void setOnReceiveHandler(OnReceiveHandler handler){ onReceiveHandler_ = handler; } inline OnReceiveHandler getOnReceiveHandler(){ return onReceiveHandler_; } protected: void onClose(); void onConnect(); private: void do_receive(); private: std::shared_ptr<boost::asio::ip::tcp::socket> asioSocket_; aws::InputBuffer buffer_; std::shared_ptr<aws::ConnectionManager> connection_manager_; bool running_; std::function<void(ConnectionPtr socket)> onCloseHandler_; std::function<void(ConnectionPtr socket)> onConnectHandler_; OnReceiveHandler onReceiveHandler_; }; }
[ "xtiqin@163.com" ]
xtiqin@163.com
b0371dbaf93a6e2ff33dcb6900bc8b6073b20fed
8447d06d0d5da3db2b3aae926ec66409b38fb140
/3rdPartLib/g2o/g2o/examples/slam2d/main_window.cpp
0ad4e0d898354b1ea8b789f6efba1ee3a10d1379
[ "GPL-3.0-or-later", "LGPL-3.0-or-later", "BSD-3-Clause", "GPL-1.0-or-later", "BSD-2-Clause" ]
permissive
HKPolyU-UAV/FLVIS
60d0fecac6e10eb19a131d589a5c0ddf89198157
4ad31bbe5191ae2763c70a641c31337b1e06c9e2
refs/heads/master
2023-07-21T11:11:05.885918
2023-07-12T14:26:32
2023-07-12T14:26:32
197,144,164
145
37
BSD-2-Clause
2021-06-07T08:45:04
2019-07-16T07:33:55
C++
UTF-8
C++
false
false
3,766
cpp
// g2o - General Graph Optimization // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard // // This file is part of g2o. // // g2o 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. // // g2o 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 g2o. If not, see <http://www.gnu.org/licenses/>. #include "main_window.h" //#include "moc_main_window.cpp" #include "g2o/core/sparse_optimizer.h" #include "g2o/core/estimate_propagator.h" #include <QFileDialog> #include <fstream> #include <iostream> using namespace std; MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) { setupUi(this); } MainWindow::~MainWindow() { } void MainWindow::on_actionLoad_triggered(bool) { viewer->graph->clear(); QString filename = QFileDialog::getOpenFileName(this, "Load g2o file", "", "g2o files (*.g2o);;All Files (*)"); if (! filename.isNull()) { ifstream ifs(filename.toStdString().c_str()); viewer->graph->load(ifs); cerr << "Graph loaded with " << viewer->graph->vertices().size() << " vertices and " << viewer->graph->edges().size() << " measurments" << endl; } viewer->update(); fixGraph(); } void MainWindow::on_actionSave_triggered(bool) { QString filename = QFileDialog::getSaveFileName(this, "Save g2o file", "", "g2o files (*.g2o)"); if (! filename.isNull()) { ofstream fout(filename.toStdString().c_str()); viewer->graph->save(fout); if (fout.good()) cerr << "Saved " << filename.toStdString() << endl; else cerr << "Error while saving file" << endl; } } void MainWindow::on_actionQuit_triggered(bool) { close(); } void MainWindow::on_btnOptimize_clicked() { if (viewer->graph->vertices().size() == 0 || viewer->graph->edges().size() == 0) { cerr << "Graph has no vertices / egdes" << endl; return; } viewer->graph->initializeOptimization(); if (rbGauss->isChecked()) viewer->graph->setAlgorithm(solverGaussNewton); else if (rbLevenberg->isChecked()) viewer->graph->setAlgorithm(solverLevenberg); else viewer->graph->setAlgorithm(solverGaussNewton); int maxIterations = spIterations->value(); int iter = viewer->graph->optimize(maxIterations); if (maxIterations > 0 && !iter){ cerr << "Optimization failed, result might be invalid" << endl; } if (cbCovariances->isChecked()) { // TODO //viewer->graph->solver()->computeMarginals(); } viewer->drawCovariance = cbCovariances->isChecked(); viewer->update(); } void MainWindow::on_btnInitialGuess_clicked() { viewer->graph->computeInitialGuess(); viewer->drawCovariance = false; viewer->update(); } void MainWindow::fixGraph() { if (viewer->graph->vertices().size() == 0 || viewer->graph->edges().size() == 0) { return; } // check for vertices to fix to remove DoF bool gaugeFreedom = viewer->graph->gaugeFreedom(); g2o::OptimizableGraph::Vertex* gauge = viewer->graph->findGauge(); if (gaugeFreedom) { if (! gauge) { cerr << "cannot find a vertex to fix in this thing" << endl; return; } else { cerr << "graph is fixed by node " << gauge->id() << endl; gauge->setFixed(true); } } else { cerr << "graph is fixed by priors" << endl; } viewer->graph->setVerbose(true); viewer->graph->computeActiveErrors(); }
[ "chensy1991@gmail.com" ]
chensy1991@gmail.com
2c2c448a1761a7c240a35e6418b63c42d0432e29
556f83e394cd722ec5cc852e69adb12d2a0c78d1
/code/TimePredef.hpp
a937e3b194a031c85bb48b95452398a2cd876d61
[ "MIT" ]
permissive
BiEchi/Programming-Assignment-1
aee2b506483fe34c242ff3468af7a48d88705edc
1d340ee27d7177062215e60dc4666ee72cb91dd2
refs/heads/main
2023-04-26T02:14:54.398342
2021-05-27T10:58:33
2021-05-27T10:58:33
368,122,637
1
0
MIT
2021-05-17T09:07:25
2021-05-17T09:07:24
null
UTF-8
C++
false
false
266
hpp
// // TimePredef.hpp // code // // Created by Jack's Macbook Pro on 2021/3/25. // #ifndef TimePredef_hpp #define TimePredef_hpp #include <iostream> #include <cstring> #include <ctime> using namespace std; extern time_t startTime; #endif /* TimePredef_hpp */
[ "Haob.19@intl.zju.edu.cn" ]
Haob.19@intl.zju.edu.cn
da17ec3176d8e7c8124f6fcf644569f7dda673f1
a42195c736f18bec131f719288994d849d49593a
/packed_sphere.cpp
80e44f1d12d56014524ed03e4a17b280c9925370
[ "MIT" ]
permissive
rishus/fat-spaces-in-sphere-arrangement
20966c3bd01435d2b2a83853553ba91863d3d5bf
6ef5b6dc22fdcb724226bcb23a5c1649b39a6bdb
refs/heads/master
2021-08-18T19:58:25.737951
2017-11-23T18:36:32
2017-11-23T18:36:32
111,831,860
0
0
null
null
null
null
UTF-8
C++
false
false
374
cpp
#include <iostream> #include <math.h> using namespace std; int main() { int side = 4; for(int i = 0; i < side; ++i) { for(int j = 0; j < side; ++j) { for(int k = 0; k < side; ++k) { double x = 2 * i + j%2 + k%2; double y = sqrt(3.0) * (j + ((1.0/3.0) * (k%2))); double z = (2 * sqrt(6))/3.0 * k; cout<<x<<" "<<y<<" "<<z<<endl; } } } }
[ "rishus@vt.edu" ]
rishus@vt.edu
73bf4e0f6fbdf976be867badea6ddbefe469dacc
f69cec4bcba5618871d0eb21c94f62070e6208f1
/Exams/2021.2.09/C.cpp
526a6a18ab153d275821994e858a87b70d50a986
[]
no_license
accoder666/temp
10204075f7081b7e25bd858df3b9f7d258779d7b
b38dcb9a45282503541c5fdb79d2f066ce2736c1
refs/heads/main
2023-07-02T17:14:37.053741
2021-08-11T03:31:44
2021-08-11T03:31:44
394,850,718
0
0
null
null
null
null
UTF-8
C++
false
false
1,808
cpp
#include <cctype> #include <cstdio> #include <cstring> using namespace std; const int maxn = 1000010, sigma_size = 26; struct node { int len, link; int nxt[sigma_size]; }; node t[maxn << 1]; int cnt, last; int siz[maxn << 1]; struct edge { int to, nxt; }; edge G[maxn << 1]; int head[maxn << 1], Gcnt; long long dfs(const int&); int main() { freopen("sub.in", "r", stdin); freopen("sub.out", "w", stdout); t[0].len = 0, t[0].link = -1, last = 0; char ch = getchar(); while (!islower(ch)) ch = getchar(); int cur, u, v, c; while (islower(ch)) { t[cur = ++cnt].len = t[last].len + 1; siz[cur] = 1; u = last; while (u != -1 && !t[u].nxt[ch - 'a']) t[u].nxt[ch - 'a'] = cur, u = t[u].link; if (u == -1) t[cur].link = 0; else { v = t[u].nxt[ch - 'a']; if (t[u].len + 1 == t[v].len) t[cur].link = v; else { c = ++cnt; t[c].len = t[u].len + 1; t[c].link = t[v].link; memcpy(t[c].nxt, t[v].nxt, sizeof(t[c].nxt)); while (u != -1 && t[u].nxt[ch - 'a'] == v) t[u].nxt[ch - 'a'] = c, u = t[u].link; t[v].link = t[cur].link = c; } } last = cur; ch = getchar(); } for (int i = 1; i <= cnt; i++) G[++Gcnt] = { i, head[t[i].link] }, head[t[i].link] = Gcnt; printf("%lld\n", dfs(0)); return 0; } long long dfs(const int& u) { long long ret = 0, tmp; for (int i = head[u]; i; i = G[i].nxt) { if ((tmp = dfs(G[i].to)) > ret) ret = tmp; siz[u] += siz[G[i].to]; } if (siz[u] != 1 && ret < (long long)siz[u] * t[u].len) ret = (long long)siz[u] * t[u].len; return ret; }
[ "2201685475@qq.com" ]
2201685475@qq.com
5b0beb00db96cfd62ad6b017f92a9c5a0ee268d5
2de8f5ba729a846f8ad5630272dd5b1f3b7b6e44
/src/Core/Gpackets/SS/GCSkillToTileOK3.h
9a747d26de9e96edf4d3f383d9b0bb936842e1c3
[]
no_license
najosky/darkeden-v2-serverfiles
dc0f90381404953e3716bf71320a619eb10c3825
6e0015f5b8b658697228128543ea145a1fc4c559
refs/heads/master
2021-10-09T13:01:42.843224
2018-12-24T15:01:52
2018-12-24T15:01:52
null
0
0
null
null
null
null
UHC
C++
false
false
4,894
h
////////////////////////////////////////////////////////////////////// // // Filename : GCSkillToTileOK3.h // Written By : elca@ewestsoft.com // Description : 기술 사용자는 볼수 있고, 당한자는 볼 수 없는 패킷 // ////////////////////////////////////////////////////////////////////// #ifndef __GC_SKILL_TO_TILE_OK_3_H__ #define __GC_SKILL_TO_TILE_OK_3_H__ // include files #include "Types.h" #include "Exception.h" #include "Packet.h" #include "PacketFactory.h" ////////////////////////////////////////////////////////////////////// // // class GCSkillToTileOK3; // // 게임서버에서 클라이언트로 자신의 기술이 성공을 알려주기 위한 클래스 // ////////////////////////////////////////////////////////////////////// class GCSkillToTileOK3 : public Packet { public : // constructor GCSkillToTileOK3() throw(); // destructor ~GCSkillToTileOK3() throw(); public : // 입력스트림(버퍼)으로부터 데이타를 읽어서 패킷을 초기화한다. void read(SocketInputStream & iStream) throw(ProtocolException, Error); // 출력스트림(버퍼)으로 패킷의 바이너리 이미지를 보낸다. void write(SocketOutputStream & oStream) const throw(ProtocolException, Error); // execute packet's handler void execute(Player* pPlayer) throw(ProtocolException, Error); // get packet id PacketID_t getPacketID() const throw() { return PACKET_GC_SKILL_TO_TILE_OK_3; } // get packet's body size // 최적화시, 미리 계산된 정수를 사용한다. // PacketSize_t getPacketSize() const throw() { return szSkillType + szObjectID +(szCoord* 2) // + szDuration + szBYTE + szObjectID* m_CListNum; } PacketSize_t getPacketSize() const throw() { return szSkillType + szObjectID +(szCoord* 2) + szBYTE;} // get packet's name string getPacketName() const throw() { return "GCSkillToTileOK3"; } // get packet's debug string string toString() const throw(); // get / set ObjectID CEffectID_t getObjectID() const throw() { return m_ObjectID; } void setObjectID(ObjectID_t ObjectID) throw() { m_ObjectID = ObjectID; } // get / set SkillType SkillType_t getSkillType() const throw() { return m_SkillType; } void setSkillType(SkillType_t SkillType) throw() { m_SkillType = SkillType; } // get / set Duration // Duration_t getDuration() const throw() { return m_Duration; } // void setDuration(Duration_t Duration) throw() { m_Duration = Duration; } // get / set X, Y Coord_t getX() { return m_X; } void setX(Coord_t X) { m_X = X; } Coord_t getY() { return m_Y; } void setY(Coord_t Y) { m_Y = Y; } // get / set Creature List Number // BYTE getCListNum() const throw() { return m_CListNum; } // void setCListNum(BYTE CListNum) throw() { m_CListNum = CListNum; } // add / delete Creature List // void addCListElement(ObjectID_t ObjectID) throw(); // Clear CreatureList // void clearCList() throw() { m_CList.clear(); m_CListNum = 0; } // pop front Element in Status List // ObjectID_t popCListElement() throw() { ObjectID_t CreatureList = m_CList.front(); m_CList.pop_front(); return CreatureList; } BYTE getGrade() const { return m_Grade; } void setGrade( BYTE grade ) { m_Grade = grade; } private : // CEffectID ObjectID_t m_ObjectID; // SkillType SkillType_t m_SkillType; // Duration // Duration_t m_Duration; // X, Y Position Coord_t m_X; Coord_t m_Y; // CreatureList Element Number // BYTE m_CListNum; // Creature List // list<ObjectID_t> m_CList; BYTE m_Grade; }; ////////////////////////////////////////////////////////////////////// // // class GCSkillToTileOK3Factory; // // Factory for GCSkillToTileOK3 // ////////////////////////////////////////////////////////////////////// class GCSkillToTileOK3Factory : public PacketFactory { public : // constructor GCSkillToTileOK3Factory() throw() {} // destructor virtual ~GCSkillToTileOK3Factory() throw() {} public : // create packet Packet* createPacket() throw() { return new GCSkillToTileOK3(); } // get packet name string getPacketName() const throw() { return "GCSkillToTileOK3"; } // get packet id PacketID_t getPacketID() const throw() { return Packet::PACKET_GC_SKILL_TO_TILE_OK_3; } // get Packet Max Size // PacketSize_t getPacketMaxSize() const throw() { return szSkillType + szObjectID +(szCoord* 2) // + szDuration + szBYTE + szObjectID + 255; } // get Packet Max Size PacketSize_t getPacketMaxSize() const throw() { return szSkillType + szObjectID +(szCoord* 2) + szBYTE; } }; ////////////////////////////////////////////////////////////////////// // // class GCSkillToTileOK3Handler; // ////////////////////////////////////////////////////////////////////// class GCSkillToTileOK3Handler { public : // execute packet's handler static void execute(GCSkillToTileOK3* pGCSkillToTileOK3, Player* pPlayer) throw(Error); }; #endif
[ "paulomatew@gmail.com" ]
paulomatew@gmail.com
f1fad2bbbe0c6384744e3e4d8b6a39763f25265e
8352ca72d4f1e8e8ebbbb7d6b07a4e0963be7f41
/DataServer/DataServer_TIP/TA_BASE/transactive/app/dataserver/CFDServer/src/SyncMarketDataForCFD.h
9693e02c5a07a2cd8b5f126f5e638848b1dda5f0
[]
no_license
radtek/slin_code
114f61695fc1a23a018da727452c3c42f64ebe39
a0073e52d600839f7836c2b7673b45b4266259e2
refs/heads/master
2020-06-04T15:03:56.618177
2015-04-27T10:27:47
2015-04-27T10:27:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,429
h
#ifndef __CLASS_SYNC_MARKET_DATA_FOR_CFD_H__ #define __CLASS_SYNC_MARKET_DATA_FOR_CFD_H__ #include "CFDServerCommonData.h" #include "BarCalculator.h" #include "CFDRequest.h" NS_BEGIN(TA_Base_App) class CCFDServerUtilityFun; class CCFDInstrumentBarInfo; class CSyncMarketDataForCFD { public: enum enSynType { SynType_BEGIN, SynType_EQUAL, SynType_SMALL, SynType_BIGGER, SynType_END, }; enum enNextWorkType { NextWorkType_BEGIN, NextWorkType_UseNewFirst_UseNewSecond, NextWorkType_UseNewFirst_ReUseSecond, NextWorkType_ReUseFirst_UseNewSecond, NextWorkType_END, }; public: typedef std::list<CCFDInstrumentBarInfo*> LstCFDBarInfoT; typedef std::list<CCFDInstrumentBarInfo*>::iterator LstCFDBarInfoIterT; typedef std::list<MarketData*> LstBarInfoT; typedef std::list<MarketData*>::iterator LstBarInfoIterT; public: CSyncMarketDataForCFD(const CCFDRequest& cfdRequest); ~CSyncMarketDataForCFD(void); public: void setCFDRequest(const CCFDRequest& cfdRequest); int syncSingleCFDBarInfo( const MarketData& nBarInfoFirst, const MarketData& nBarInfoSecond, LstCFDBarInfoT& lstCFDbarInfo, enNextWorkType& nNextWorkType); int clearCFDBarInfoList(LstCFDBarInfoT& lstCFDbarInfo); private: int _SyncSingleBarInfo( const MarketData& nBarInfoFirst, const MarketData& nBarInfoSecond, LstBarInfoT& lstBarInfoFirst, LstBarInfoT& lstBarInfoSecond, enNextWorkType& nNextWorkType); int _ClearBarInfoList(LstBarInfoT& lstBarInfo); private: int _SyncLstCFDBarInfo(LstBarInfoT& lstBarInfoFirst, LstBarInfoT& lstBarInfoSecond, LstCFDBarInfoT& lstCFDBarInfo); int _SyncSingleBarInfoSynType( enSynType nSynType, const MarketData& nBarInfoFirst, const MarketData& nBarInfoSecond, LstBarInfoT& lstBarInfoFirst, LstBarInfoT& lstBarInfoSecond); int _SyncSingleBarInfoSynTypeEqual( enSynType nSynType, const MarketData& nBarInfoFirst, const MarketData& nBarInfoSecond, LstBarInfoT& lstBarInfoFirst, LstBarInfoT& lstBarInfoSecond); int _SyncSingleBarInfoSynTypeSmall( enSynType nSynType, const MarketData& nBarInfoFirst, const MarketData& nBarInfoSecond, LstBarInfoT& lstBarInfoFirst, LstBarInfoT& lstBarInfoSecond); private: CCFDServerUtilityFun* m_pUtilityFun; CCFDRequest m_CFDRequest; }; NS_END(TA_Base_App) #endif // __CLASS_SYNC_MARKET_DATA_FOR_CFD_H__
[ "shenglonglinapple@gmail.com" ]
shenglonglinapple@gmail.com
811f9d505b013c247c52a12ed78859c1477c84e1
d47bcf95da7cf618d826abbdafd55d15610d3bd9
/switch.cpp
65d1cabd4e4fa57bc0cdfca0fe6f9b927c149696
[]
no_license
gchacaltana/Sintaxis-C-CPP-A-Search-Algorithm
d6f03ac7421717dd52f7d40b71e7a5692aa7d818
a694538d0aa18d5ed0a16fe22b920dccfa12bd5f
refs/heads/master
2020-08-22T18:00:18.503785
2019-10-21T03:17:39
2019-10-21T03:17:39
216,453,034
0
0
null
null
null
null
UTF-8
C++
false
false
1,320
cpp
#include <iostream> #include <string> using namespace std; char mostrar_opciones(string, string, string); int main() { char r1, r2; r1 = mostrar_opciones("¿Cómo es la tasa de producción de lágrimas?","[R]educida","[N]ormal"); switch(r1) { case 'R': r2 = mostrar_opciones("¿Tiene astigmatismo?","[S]í","[N]o"); switch(r2) { case 'S': cout << "Tipo de lentes: suaves"; break; case 'N': cout << "Tipo de lentes: rígidos"; break; default: cout << "Fin"; } break; case 'N': cout << "Tipo de lentes: no requiere"; break; default: cout << "Fin"; } return 0; } char mostrar_opciones(string pregunta, string opcion_A, string opcion_B) { char respuesta; char r_a = opcion_A[1]; char r_b = opcion_B[1]; do{ cout << pregunta << endl; cout << opcion_A << endl; cout << opcion_B << endl; cout << "Salir [x]" << endl; cin >> respuesta; } while(respuesta != r_a && respuesta != r_b && respuesta != 'x'); return respuesta; }
[ "noreply@github.com" ]
gchacaltana.noreply@github.com
0f2cca11331527142c6a81af499eab6dc7be0635
776426915cb19273095dc9d8ad583d6847add5d4
/robot.cpp
aed800642b344117c1036f7ff20b3031aef98f1b
[]
no_license
imharsh94/ALGO-DS
28832c9f843ee5a22463557c3493976399ad33cc
b9c131a2248c86da10f8df23606fdaef509c2d10
refs/heads/master
2020-08-11T21:22:37.082594
2019-10-12T10:37:32
2019-10-12T10:37:32
214,629,394
0
0
null
null
null
null
UTF-8
C++
false
false
734
cpp
// codeforces educational round 53 #include<bits/stdc++.h> using namespace std; char s[200008]; int sx[200008],sy[200008]; int main() { int n,i,j,x,y,k; cin>>n; scanf("%s",s+1); cin>>x>>y; if(abs(x)+abs(y) > n ||(n+x+y)&1) { cout<<-1<<'\n'; return 0; } for(int i=1; i<=n; i++) { sx[i] = sx[i-1] + (s[i]=='L'?-1:(s[i]=='R'?1:0)); sy[i] = sy[i-1] + (s[i]=='D'?-1:(s[i]=='U'?1:0)); } int ans = 1<<30; for(int i=0,j=0; i<=n; i++) { while(j<=n && abs(sx[i]+sx[n]-sx[j]-x)+abs(sy[i]+sy[n]-sy[j]-y)>j-i) j++; if(j<=n) ans = min(ans,j-i); else break; } cout<<ans<<endl; return 0; }
[ "vardhan.harsh94@gmail.com" ]
vardhan.harsh94@gmail.com
1d5d9ed7db6942bd48206e99fe56c4dc4ad4c19d
e5f57aae37a480cf40180d0a5664aaab5a0c0341
/vaca/Component.cpp
a5ec932ebb891f3811b06b8dfed1d899b11ca0bc
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
TheLightWay/vaca
6ddabf0cd12a46583b03cddc99d2b13da87a4e41
95728e6a5c41d9fe2c731f7767b7334b623f41ed
refs/heads/master
2023-06-10T09:47:28.085286
2023-04-12T02:52:15
2023-04-12T02:52:15
149,952,301
0
0
MIT
2018-09-23T05:56:48
2018-09-23T05:56:48
null
UTF-8
C++
false
false
1,609
cpp
// Vaca - Visual Application Components Abstraction // Copyright (c) 2005-2010 David Capello // // This file is distributed under the terms of the MIT license, // please read LICENSE.txt for more information. #include "vaca/Component.h" #include "vaca/SharedPtr.h" #include "vaca/Property.h" #include "vaca/Debug.h" using namespace vaca; /** Creates a new component. With the debug version of the library, you will get in the @ref page_debug_log a line specifying when the component was created. */ Component::Component() { VACA_TRACE("new Component (%p)\n", this); } /** Destroys the component. With the debug version of the library, you will get in the @ref page_debug_log a line specifying when the component was destroyed. */ Component::~Component() { VACA_TRACE("delete Component (%p)\n", this); } PropertyPtr Component::getProperty(const String& name) { Properties::iterator it = m_properties.find(name); if (it != m_properties.end()) return it->second; else return PropertyPtr(); } void Component::setProperty(PropertyPtr property) { m_properties[property->getName()] = property; } bool Component::hasProperty(const String& name) { Properties::iterator it = m_properties.find(name); return it != m_properties.end(); } void Component::removeProperty(const String& name) { Properties::iterator it = m_properties.find(name); if (it != m_properties.end()) m_properties.erase(it); } const Component::Properties& Component::getProperties() const { return m_properties; }
[ "davidcapello@gmail.com" ]
davidcapello@gmail.com
8562389987847c12a04e6b03c90970f9e416eded
cfa83be88b6725d9c88d780e08b6392a346f2e15
/cs4290/lab2/memory.h
d1d3f0371b21e842b8d23fe36cdd3dcab1048860
[]
no_license
eugene-voronkov/architecture_projects
63a04babd711ecc4c5ce7eb7d79604282b162f3c
bb3d5c97ca93affdb471c4ac03509792ff3004c0
refs/heads/master
2021-01-21T08:09:06.740624
2016-01-05T17:06:34
2016-01-05T17:06:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,609
h
#ifndef MEMORY_H #define MEMORY_H #include<list> #include<queue> #include "knob.h" #include "all_knobs.h" typedef enum Mem_Req_State_enum { MEM_INV, MEM_NEW, MEM_DRAM_IN, MEM_DRAM_SCH, MEM_DRAM_DONE, MEM_DRAM_OUT, MEM_MAX_REQ_STATE, } Mem_Req_State; typedef enum Mem_Req_Type_enum { MRT_IFETCH, MRT_DFETCH, MRT_DSTORE, MRT_IPRF, MRT_DPRF, MRT_WB, MRT_SW_DPRF, MAX_MEM_REQ_TYPE, } Mem_Req_Type; typedef struct mem_req_s { Mem_Req_State m_state; /**< memory request state */ Mem_Req_Type m_type; /**< request type */ ADDRINT m_addr; /**< request address */ uint8_t m_size; /**< request size */ uint64_t m_rdy_cycle; /**< request ready cycle */ bool m_dirty; /**< wb request? */ bool m_done; /**< request done flag */ uint64_t m_id; /**< unique request id */ } mem_req_s; typedef struct m_mshr_entry_s { mem_req_s *m_mem_req; bool valid; UINT64 insert_time; list<Op*> req_ops; /* array to hold request ops */ }m_mshr_entry_s; typedef struct m_dram_s { int m_bank_num; int *m_row_id; int *m_rdy_cycle; }m_dram_s; class memory_c { public: list <m_mshr_entry_s *> m_mshr; // mshr is an array of mshr_entries list <m_mshr_entry_s *> m_mshr_free_list; // a collection of free mshr_entries int m_mshr_size; int m_dram_bank_num; int m_block_size; uint64_t m_unique_m_count; list <mem_req_s *> dram_in_queue; /* in to DRAM */ list <mem_req_s *> dram_out_queue; /*out from DRAM */ /* dram structure */ list <mem_req_s *>* dram_bank_sch_queue; /* scheduler buffer for each DRAM bank */ int *dram_bank_open_row; int *dram_bank_rdy_cycle; m_mshr_entry_s * allocate_new_mshr_entry(void); mem_req_s *get_new_mem_req(void); void run_a_cycle(void); void send_bus_in_queue(void); void dram_schedule(void); void push_dram_sch_queue(void); void send_bus_out_queue(void); void fill_queue(void); void init_mem(); bool insert_mshr(Op *op); void free_mshr_entry(m_mshr_entry_s *entry); m_mshr_entry_s *search_matching_mshr(ADDRINT addr); list<m_mshr_entry_s*>::iterator search_matching_mshr_itr(ADDRINT addr); bool check_piggyback(Op *op); bool store_load_forwarding(Op *op); void dprint_queues(void); void dprint_dram_banks(void); }; extern KnobsContainer *g_knobsContainer; /* < knob container > */ extern all_knobs_c *g_knobs; /* < all knob variables > */ #endif // MEMORY_H
[ "eugene.voronkov@gmail.com" ]
eugene.voronkov@gmail.com
d5fa083e493cb7915d62f1634c4714ae1d76e8a8
48070285a8c93a24b4e568c3a45eade50838e6d2
/Example/Lua/BindAbstract.cpp
9975360a71a909180dd2603519c656878b8a9059
[ "MIT" ]
permissive
ternence-li/LightInkLLM
8a3c54d4664e0cf64a454c7f8bd22fb4c434adff
b4387398b4ce45be0bc2d79ea38d93b81609f7c8
refs/heads/master
2021-09-21T23:23:09.357179
2018-09-02T17:27:49
2018-09-02T17:27:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,043
cpp
/* Copyright ChenDong(Wilbur), email <baisaichen@live.com>. 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 "LuaEngine/LuaEngine.h" class CppClassAbs { public: CppClassAbs() { LogMessage("new CppClassAbs"); } virtual ~CppClassAbs() { LogMessage("delete CppClassAbs"); } virtual void test_abstract() = 0; }; class CppClassAbsInherit : public CppClassAbs { public: CppClassAbsInherit() { LogMessage("new CppClassAbsInherit"); } virtual ~CppClassAbsInherit() { LogMessage("delete CppClassAbsInherit"); } virtual void test_abstract() { LogMessage("call --> virtual void CppClassAbsInherit.test_abstract()"); } static LightInk::SharedPtrTS<CppClassAbs>::type get_shared() { return LightInk::SharedPtrTS<CppClassAbs>::type(static_cast<CppClassAbs *>(new CppClassAbsInherit)); } static void check_shared(LightInk::SharedPtrTS<CppClassAbs>::type sp) { LogMessage("SharedPtrTS Use Count = {}", sp.use_count()); } static int show_class_name(lua_State * L) { LogMessage("ClassName = {}", LightInk::LuaEngine::get_class_name(L, 1)); return 0; } }; static void bind_cppclass(lua_State * lua) { LightInk::LuaModule(lua, "CppClassList") [ LightInk::LuaRegisterAbstract<CppClassAbs>(lua, "CppClassAbs") .def(&CppClassAbs::test_abstract, "test_abstract") ]; LightInk::LuaModule(lua, "CppClassList") [ LightInk::LuaRegister<CppClassAbsInherit, void()>(lua, "CppClassAbsInherit", LightInk::BaseClassStrategy<CppClassAbs>()) .def(CppClassAbsInherit::get_shared, "get_shared") .def(CppClassAbsInherit::check_shared, "check_shared") .def(CppClassAbsInherit::show_class_name, "show_class_name") ]; } void test_bind_abstract() { LogDebug("start...call...test_bind_abstract()"); LightInk::LuaEngine le; le.init(); le.register_module(bind_cppclass); le.add_package_path("../../Example/Lua/?.lua"); le.require_file("BindAbstract"); LogDebug("over...call...test_bind_abstract()"); }
[ "baisaichen@live.com" ]
baisaichen@live.com
b12965d715e6284202ba24cf0b677891f1f54dfc
12154201c2c4dc8968b690fa8237ebfe1932f60a
/SWEA/1232.cpp
2338641229460152f36e0dd2c7ef0b68a8baaa42
[]
no_license
heon24500/PS
9cc028de3d9b1a26543b5bd498cfd5134d3d6de4
df901f6fc71f8c9d659b4c5397d44de9a2031a9d
refs/heads/master
2023-02-20T17:06:30.065944
2021-01-25T12:43:48
2021-01-25T12:43:48
268,433,390
2
0
null
null
null
null
UHC
C++
false
false
1,359
cpp
/* 1232. [S/W 문제해결 기본] 9일차 - 사칙연산 */ #include <iostream> #include <string> #include <stack> using namespace std; const int N = 1001; int tree[N][2]; string ops[N]; stack<int> s; void init() { for (int i = 0; i < N; i++) { tree[i][0] = 0; tree[i][1] = 0; ops[i] = ""; } while (!s.empty()) { s.pop(); } } bool isOperator(string str) { char ch = str[0]; if (ch == '+' || ch == '-' || ch == '*' || ch == '/') return true; else return false; } int calc(string str) { char ch = str[0]; int b = s.top(); s.pop(); int a = s.top(); s.pop(); if (ch == '+') { return a + b; } else if (ch == '-') { return a - b; } else if (ch == '*') { return a * b; } else if (ch == '/') { return a / b; } } void postorder(int t) { if (t == 0) return; postorder(tree[t][0]); postorder(tree[t][1]); string str = ops[t]; int result; if (isOperator(str)) result = calc(str); else result = stoi(str); s.push(result); } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); for (int t = 1; t <= 10; t++) { int n; cin >> n; for (int i = 1; i <= n; i++) { int num; cin >> num; cin >> ops[num]; if (isOperator(ops[num])) { cin >> tree[num][0] >> tree[num][1]; } } postorder(1); cout << "#" << t << " " << s.top() << '\n'; init(); } return 0; }
[ "heon24500@naver.com" ]
heon24500@naver.com
19685e5b5a22d7397dc9a822a611b3ff326ebeaa
fa85329dbe03772df56547375154c5437ff2b076
/Zero_L/alfa/Mapa.h
fcb75d70277662fc2f59fdca83186436e309b06b
[ "Apache-2.0" ]
permissive
Ninefrm/Unsingned
9597f3c3cf1c422adbbcbf36a41d0b97aa71aa9a
cf051f6aa6c9d93f8582539b2d36c64a41447a58
refs/heads/master
2021-08-24T05:07:38.657326
2017-12-08T05:12:47
2017-12-08T05:12:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,119
h
#ifndef _MAPA_H_ #define _MAPA_H_ #include <vector> #include <random> #include <curses.h> #include <ctime> #include "Obj.h" #include "Wall.h" #include "Character.h" #include "Enemy.h" #include "Sword.h" class Mapa{ public: Mapa(); Mapa(Character* , std::vector<Wall>, int, int); bool wall_colision() const;//Verifica si el jugador colisiona con alguo de los muros bool wall_colision(int, int) const;//Verifica si la posicion (x, y) colisiona con alguno de los muros bool outside() const; bool enemys_colision(); bool enemys_colision(const Obj&, int); bool enemys_colision(const Sword espada); void generate_enemy(); void move_enemys(); void move_agresive(); void draw_walls();//Dibuja los muros void draw_enemys(); private: int rows; int cols; std::mt19937 motor; std::uniform_int_distribution<int> rand_x; std::uniform_int_distribution<int> rand_y; std::uniform_int_distribution<int> rand_mov; std::vector<Wall> walls; Character* player; Enemy enemys; bool inside; }; #endif
[ "luiszavala@live.com.mx" ]
luiszavala@live.com.mx
3f69c1177031469f39583381efe7b985bc198426
9f81d77e028503dcbb6d7d4c0c302391b8fdd50c
/google/cloud/retail/v2/internal/model_auth_decorator.h
8bf2a926c99f9d1b8275b51fab4742fd4cb0c5d1
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
googleapis/google-cloud-cpp
b96a6ee50c972371daa8b8067ddd803de95f54ba
178d6581b499242c52f9150817d91e6c95b773a5
refs/heads/main
2023-08-31T09:30:11.624568
2023-08-31T03:29:11
2023-08-31T03:29:11
111,860,063
450
351
Apache-2.0
2023-09-14T21:52:02
2017-11-24T00:19:31
C++
UTF-8
C++
false
false
3,784
h
// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://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. // Generated by the Codegen C++ plugin. // If you make any local changes, they will be lost. // source: google/cloud/retail/v2/model_service.proto #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_RETAIL_V2_INTERNAL_MODEL_AUTH_DECORATOR_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_RETAIL_V2_INTERNAL_MODEL_AUTH_DECORATOR_H #include "google/cloud/retail/v2/internal/model_stub.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include "google/cloud/version.h" #include <google/longrunning/operations.grpc.pb.h> #include <memory> #include <set> #include <string> namespace google { namespace cloud { namespace retail_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN class ModelServiceAuth : public ModelServiceStub { public: ~ModelServiceAuth() override = default; ModelServiceAuth( std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth, std::shared_ptr<ModelServiceStub> child); future<StatusOr<google::longrunning::Operation>> AsyncCreateModel( google::cloud::CompletionQueue& cq, std::shared_ptr<grpc::ClientContext> context, google::cloud::retail::v2::CreateModelRequest const& request) override; StatusOr<google::cloud::retail::v2::Model> GetModel( grpc::ClientContext& context, google::cloud::retail::v2::GetModelRequest const& request) override; StatusOr<google::cloud::retail::v2::Model> PauseModel( grpc::ClientContext& context, google::cloud::retail::v2::PauseModelRequest const& request) override; StatusOr<google::cloud::retail::v2::Model> ResumeModel( grpc::ClientContext& context, google::cloud::retail::v2::ResumeModelRequest const& request) override; Status DeleteModel( grpc::ClientContext& context, google::cloud::retail::v2::DeleteModelRequest const& request) override; StatusOr<google::cloud::retail::v2::ListModelsResponse> ListModels( grpc::ClientContext& context, google::cloud::retail::v2::ListModelsRequest const& request) override; StatusOr<google::cloud::retail::v2::Model> UpdateModel( grpc::ClientContext& context, google::cloud::retail::v2::UpdateModelRequest const& request) override; future<StatusOr<google::longrunning::Operation>> AsyncTuneModel( google::cloud::CompletionQueue& cq, std::shared_ptr<grpc::ClientContext> context, google::cloud::retail::v2::TuneModelRequest const& request) override; future<StatusOr<google::longrunning::Operation>> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr<grpc::ClientContext> context, google::longrunning::GetOperationRequest const& request) override; future<Status> AsyncCancelOperation( google::cloud::CompletionQueue& cq, std::shared_ptr<grpc::ClientContext> context, google::longrunning::CancelOperationRequest const& request) override; private: std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth_; std::shared_ptr<ModelServiceStub> child_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace retail_v2_internal } // namespace cloud } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_RETAIL_V2_INTERNAL_MODEL_AUTH_DECORATOR_H
[ "noreply@github.com" ]
googleapis.noreply@github.com
ec09caed19965ed57a38708dc834a6201362759b
492976adfdf031252c85de91a185bfd625738a0c
/src/Game/AI/Action/actionFreeMove.h
bdc2e801fa992746fe8831104b400403dea4acd7
[]
no_license
zeldaret/botw
50ccb72c6d3969c0b067168f6f9124665a7f7590
fd527f92164b8efdb746cffcf23c4f033fbffa76
refs/heads/master
2023-07-21T13:12:24.107437
2023-07-01T20:29:40
2023-07-01T20:29:40
288,736,599
1,350
117
null
2023-09-03T14:45:38
2020-08-19T13:16:30
C++
UTF-8
C++
false
false
1,059
h
#pragma once #include "KingSystem/ActorSystem/actAiAction.h" namespace uking::action { class FreeMove : public ksys::act::ai::Action { SEAD_RTTI_OVERRIDE(FreeMove, ksys::act::ai::Action) public: explicit FreeMove(const InitArg& arg); ~FreeMove() override; bool init_(sead::Heap* heap) override; void enter_(ksys::act::ai::InlineParamPack* params) override; void leave_() override; void loadParams_() override; protected: void calc_() override; // FIXME: remove this u8 pad_0x20[0x40]; // static_param at offset 0x60 const float* mSpeed_s{}; // static_param at offset 0x68 const float* mSpeedAddRate_s{}; // static_param at offset 0x70 const float* mAngleSpeed_s{}; // static_param at offset 0x78 const bool* mIsChangeable_s{}; // static_param at offset 0x80 const bool* mIsIgnoreSameAS_s{}; // static_param at offset 0x88 const bool* mAllowPitchRotation_s{}; // static_param at offset 0x90 sead::SafeString mASKeyName_s{}; }; } // namespace uking::action
[ "leo@leolam.fr" ]
leo@leolam.fr
cc5d35422b45c75f8146e02297f99e09fdcbddeb
82646fb7fe40db6dcdf238548128f7b633de94c0
/workspace/P65/src/32.cpp
9583afe2df05015dcd324b3057ed4780060bbe17
[]
no_license
jtahstu/iCode
a7873618fe98e502c1e0e2fd0769d71b3adac756
42d0899945dbc1bab98092d21a1d946137a1795e
refs/heads/master
2021-01-10T22:55:47.677615
2016-10-23T12:42:38
2016-10-23T12:42:38
70,316,051
1
0
null
null
null
null
GB18030
C++
false
false
582
cpp
/* * 32.cpp * Created on: 2015年4月4日 * Author: jtahstu */ //32列出真分数序列 //按递增顺序依次列出所有分母为40,分子小于40的最简分数。 // //*运行结果 //The fraction serials with demominator 40 is: //1/40 3/40 7/40 9/40 11/40 13/40 17/40 19/40 //21/40 23/40 27/40 29/40 31/40 33/40 37/40 39/40 #include<iostream> #include<cstdio> using namespace std; int gcd32(int a,int b){ return b==0?a:gcd32(b,a%b); } int main32() { for(int i=1;i<40;i++) {if(gcd32(40,i)==1) cout<<i<<"/40"<<" "; } return 0; }
[ "root@jtahstu.com" ]
root@jtahstu.com
cb3a5e079c958bd59ae282cd6932723fa1a3975e
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/shell/ext/timewarp/util.cpp
979e0bc3df4d8aa6f3a602d7b2a4ddb2afec932c
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
9,065
cpp
#include "precomp.hxx" #pragma hdrstop #include <winnlsp.h> // NORM_STOP_ON_NULL #include "resource.h" #include "timewarp.h" #include "util.h" DWORD FormatString(LPWSTR *ppszResult, HINSTANCE hInstance, LPCWSTR pszFormat, ...) { DWORD dwResult; va_list args; LPWSTR pszFormatAlloc = NULL; if (IS_INTRESOURCE(pszFormat)) { if (LoadStringAlloc(&pszFormatAlloc, hInstance, PtrToUlong(pszFormat))) { pszFormat = pszFormatAlloc; } else { return 0; } } va_start(args, pszFormat); dwResult = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING, pszFormat, 0, 0, (LPWSTR)ppszResult, 1, &args); va_end(args); LocalFree(pszFormatAlloc); return dwResult; } HRESULT FormatFriendlyDateName(LPWSTR *ppszResult, LPCWSTR pszName, const FILETIME UNALIGNED *pft, DWORD dwDateFlags) { WCHAR szDate[MAX_PATH]; SHFormatDateTime(pft, &dwDateFlags, szDate, ARRAYSIZE(szDate)); if (!FormatString(ppszResult, g_hInstance, MAKEINTRESOURCE(IDS_FOLDER_TITLE_FORMAT), pszName, szDate)) { DWORD dwErr = GetLastError(); return HRESULT_FROM_WIN32(dwErr); } return S_OK; } void EliminateGMTPathSegment(LPWSTR pszPath) { LPWSTR pszGMT = wcsstr(pszPath, SNAPSHOT_MARKER); if (pszGMT) { ASSERT(pszGMT >= pszPath && pszGMT < (pszPath + lstrlenW(pszPath))); // It's tempting to just say "pszGMT + SNAPSHOT_NAME_LENGTH" here, but // we might miss an intervening '\0' on a malformed path. LPWSTR pszSeparator = wcschr(pszGMT, L'\\'); if (pszSeparator) { ASSERT(pszSeparator == pszGMT + SNAPSHOT_NAME_LENGTH); ASSERT(pszSeparator < (pszGMT + lstrlenW(pszGMT))); pszSeparator++; // skip '\\' MoveMemory(pszGMT, pszSeparator, (lstrlenW(pszSeparator)+1)*sizeof(WCHAR)); } else { // Truncate here *pszGMT = L'\0'; // Remove the previous separator if we can PathRemoveBackslashW(pszPath); } } } void EliminatePathPrefix(LPWSTR pszPath) { // Note that sometimes the "\\?\" is not at the beginning of the // path. See CTimeWarpProp::_OnView in twprop.cpp. LPWSTR pszPrefix = wcsstr(pszPath, L"\\\\?\\"); if (pszPrefix) { LPWSTR pszDest; LPWSTR pszSrc; ASSERT(pszPrefix >= pszPath && pszPrefix < (pszPath + lstrlenW(pszPath))); if (CSTR_EQUAL == CompareStringW(LOCALE_SYSTEM_DEFAULT, SORT_STRINGSORT | NORM_IGNORECASE | NORM_STOP_ON_NULL, pszPrefix+4, 4, L"UNC\\", 4)) { // UNC case: preserve the 2 leading backslashes pszDest = pszPrefix + 2; pszSrc = pszPrefix + 8; } else { pszDest = pszPrefix; pszSrc = pszPrefix + 4; } ASSERT(pszDest >= pszPath && pszSrc > pszDest && pszSrc <= (pszPath + lstrlenW(pszPath))); MoveMemory(pszDest, pszSrc, (lstrlenW(pszSrc)+1)*sizeof(WCHAR)); } } HRESULT GetFSIDListFromTimeWarpPath(PIDLIST_ABSOLUTE *ppidlTarget, LPCWSTR pszPath, DWORD dwFileAttributes) { HRESULT hr; LPWSTR pszDup; hr = SHStrDup(pszPath, &pszDup); if (SUCCEEDED(hr)) { // Note that SHSimpleIDListFromPath (which is exported from shell32) // is not good enough here. It always uses 0 for attributes, but // we usually need FILE_ATTRIBUTE_DIRECTORY here. EliminateGMTPathSegment(pszDup); hr = SimpleIDListFromAttributes(pszDup, dwFileAttributes, ppidlTarget); LocalFree(pszDup); } return hr; } class CFileSysBindData : public IFileSystemBindData { public: CFileSysBindData(); // *** IUnknown methods *** STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); STDMETHODIMP_(ULONG) AddRef(void); STDMETHODIMP_(ULONG) Release(void); // IFileSystemBindData STDMETHODIMP SetFindData(const WIN32_FIND_DATAW *pfd); STDMETHODIMP GetFindData(WIN32_FIND_DATAW *pfd); private: ~CFileSysBindData(); LONG _cRef; WIN32_FIND_DATAW _fd; }; CFileSysBindData::CFileSysBindData() : _cRef(1) { ZeroMemory(&_fd, sizeof(_fd)); } CFileSysBindData::~CFileSysBindData() { } HRESULT CFileSysBindData::QueryInterface(REFIID riid, void **ppv) { static const QITAB qit[] = { QITABENT(CFileSysBindData, IFileSystemBindData), // IID_IFileSystemBindData { 0 }, }; return QISearch(this, qit, riid, ppv); } STDMETHODIMP_(ULONG) CFileSysBindData::AddRef(void) { return InterlockedIncrement(&_cRef); } STDMETHODIMP_(ULONG) CFileSysBindData::Release() { ASSERT( 0 != _cRef ); ULONG cRef = InterlockedDecrement(&_cRef); if ( 0 == cRef ) { delete this; } return cRef; } HRESULT CFileSysBindData::SetFindData(const WIN32_FIND_DATAW *pfd) { _fd = *pfd; return S_OK; } HRESULT CFileSysBindData::GetFindData(WIN32_FIND_DATAW *pfd) { *pfd = _fd; return S_OK; } STDAPI SHCreateFileSysBindCtx(const WIN32_FIND_DATAW *pfd, IBindCtx **ppbc) { HRESULT hres; IFileSystemBindData *pfsbd = new CFileSysBindData(); if (pfsbd) { if (pfd) { pfsbd->SetFindData(pfd); } hres = CreateBindCtx(0, ppbc); if (SUCCEEDED(hres)) { BIND_OPTS bo = {sizeof(bo)}; // Requires size filled in. bo.grfMode = STGM_CREATE; (*ppbc)->SetBindOptions(&bo); (*ppbc)->RegisterObjectParam(STR_FILE_SYS_BIND_DATA, pfsbd); } pfsbd->Release(); } else { *ppbc = NULL; hres = E_OUTOFMEMORY; } return hres; } STDAPI SHSimpleIDListFromFindData(LPCWSTR pszPath, const WIN32_FIND_DATAW *pfd, PIDLIST_ABSOLUTE *ppidl) { *ppidl = NULL; IBindCtx *pbc; HRESULT hr = SHCreateFileSysBindCtx(pfd, &pbc); if (SUCCEEDED(hr)) { hr = SHParseDisplayName(pszPath, pbc, ppidl, 0, NULL); pbc->Release(); } return hr; } STDAPI SimpleIDListFromAttributes(LPCWSTR pszPath, DWORD dwAttributes, PIDLIST_ABSOLUTE *ppidl) { WIN32_FIND_DATAW fd = {0}; fd.dwFileAttributes = dwAttributes; // SHCreateFSIDList(pszPath, &fd, ppidl); return SHSimpleIDListFromFindData(pszPath, &fd, ppidl); } //************************************************************* // // SizeofStringResource // // Purpose: Find the length (in chars) of a string resource // // Parameters: HINSTANCE hInstance - module containing the string // UINT idStr - ID of string // // // Return: UINT - # of chars in string, not including NULL // // Notes: Based on code from user32. // //************************************************************* UINT SizeofStringResource(HINSTANCE hInstance, UINT idStr) { UINT cch = 0; HRSRC hRes = FindResource(hInstance, (LPTSTR)((LONG_PTR)(((USHORT)idStr >> 4) + 1)), RT_STRING); if (NULL != hRes) { HGLOBAL hStringSeg = LoadResource(hInstance, hRes); if (NULL != hStringSeg) { LPWSTR psz = (LPWSTR)LockResource(hStringSeg); if (NULL != psz) { idStr &= 0x0F; while(true) { cch = *psz++; if (idStr-- == 0) break; psz += cch; } } } } return cch; } //************************************************************* // // LoadStringAlloc // // Purpose: Loads a string resource into an alloc'd buffer // // Parameters: ppszResult - string resource returned here // hInstance - module to load string from // idStr - string resource ID // // Return: same as LoadString // // Notes: On successful return, the caller must // LocalFree *ppszResult // //************************************************************* int LoadStringAlloc(LPWSTR *ppszResult, HINSTANCE hInstance, UINT idStr) { int nResult = 0; UINT cch = SizeofStringResource(hInstance, idStr); if (cch) { cch++; // for NULL *ppszResult = (LPWSTR)LocalAlloc(LPTR, cch * sizeof(WCHAR)); if (*ppszResult) nResult = LoadString(hInstance, idStr, *ppszResult, cch); } return nResult; }
[ "seta7D5@protonmail.com" ]
seta7D5@protonmail.com
d41cee16d53ba621cc3ee717d9856782a1494c4a
dc9c6f34e15ae60cdecd503117334f5db2276ecd
/065_LC_76_minimumWindowSubstring.cpp
1dc93d6013584627bd685f0e98f479aa08130792
[]
no_license
z2z23n0/Algorithm
43c669958972b73dab95adf8314bbf219690c4d2
6582688bd387b2bb04eb39bafa58e0180f665bb4
refs/heads/master
2022-06-09T22:43:25.914800
2020-05-07T16:27:03
2020-05-08T16:27:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,360
cpp
// // Created by Zeno on 2020/5/2. // class Solution { public: string minWindow(string s, string t) { int start = 0; // record the beginning of the minium substring int minLen = INT_MAX; int left = 0, right = 0; int match = 0; // record the match number between window and needs unordered_map<char, int> window; unordered_map<char, int> needs; for (char c : t) { needs[c]++; } // first, move right to very right // if match == needs.size(), move left to right until match < needs.size() while (right < s.size()) { char c1 = s[right]; if (needs.count(c1)) { window[c1]++; if (window[c1] == needs[c1]) { match++; } } right++; while (match == needs.size()) { if (right - left < minLen) { start = left; minLen = right - left; } char c2 = s[left]; if (needs.count(c2)) { window[c2]--; if (window[c2] < needs[c2]) match--; } left++; } } return minLen == INT_MAX ? "" : s.substr(start, minLen); } };
[ "zhangyuzechn@foxmail.com" ]
zhangyuzechn@foxmail.com
c40cec2855a8e1024a089444ba834a4497a6b87e
74fc7c5d39baa6c30aa929e629ff60bf40500c61
/test/unit-tests/mbr/abr_manager_mock.h
7d72e0e7df2540c2a133c41a74fcdd4bdfbd12c3
[ "BSD-3-Clause" ]
permissive
jhyunleehi/poseidonos
e472be680d0e85dc62f0e2c0d7356dbee74a3bd6
1d90e4320855d61742ff37af8c0148da579d95d4
refs/heads/develop
2023-07-13T03:37:29.754509
2021-08-23T15:26:08
2021-08-23T15:26:08
393,203,347
0
0
BSD-3-Clause
2021-08-20T00:04:14
2021-08-06T00:30:35
C
UTF-8
C++
false
false
754
h
#include <gmock/gmock.h> #include <list> #include <string> #include <vector> #include "src/mbr/abr_manager.h" namespace pos { class MockAbrManager : public AbrManager { public: using AbrManager::AbrManager; MOCK_METHOD(int, LoadAbr, (string arrayName, ArrayMeta& meta), (override)); MOCK_METHOD(int, SaveAbr, (string arrayName, ArrayMeta& meta), (override)); MOCK_METHOD(bool, GetMfsInit, (string arrayName), (override)); MOCK_METHOD(int, SetMfsInit, (string arrayName, bool value), (override)); MOCK_METHOD(int, CreateAbr, (string arrayName, ArrayMeta& meta), (override)); MOCK_METHOD(int, DeleteAbr, (string arrayName, ArrayMeta& meta), (override)); MOCK_METHOD(int, ResetMbr, (), (override)); }; } // namespace pos
[ "kyuho.son@samsung.com" ]
kyuho.son@samsung.com
2013508685c406f26f59797369c25eab0f2a0d9f
cae8f9912d24273fa747f4f791989f1f6f12f247
/sketch_apr02a.ino
fe5d5df7452a0f7ae5a8a29c13e258d9eb96c716
[]
no_license
vasudevgrover/Working-with-GSM-module-Arduino-
ae873f57e68d5b132fb093e64068f77b0f28b6e5
de6d2fbd860a8b16818449abe5d4b56ddd334f81
refs/heads/master
2020-12-24T20:42:52.744017
2016-04-12T16:32:15
2016-04-12T16:32:15
56,079,703
0
0
null
null
null
null
UTF-8
C++
false
false
999
ino
#include <SoftwareSerial.h> SoftwareSerial mySerial(9, 10); void setup() { mySerial.begin(9600); //baud rate of GSM Module Serial.begin(9600); //baud rate of Serial Monitor (Arduino) delay(100); } void loop() { if (Serial.available()>0) switch(Serial.read()) { case 's': SendMessage(); break; case 'r': RecieveMessage(); break; } if (mySerial.available()>0) Serial.write(mySerial.read()); } void SendMessage() { mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode delay(1000); // Delay of 1000 milli seconds or 1 second mySerial.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number delay(1000); mySerial.println("SMS from GSM Module");// The SMS text you want to send delay(100); mySerial.println((char)26);// ASCII code of CTRL+Z delay(1000); } void RecieveMessage() { mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS delay(1000); }
[ "vasudev.grover@gmail.com" ]
vasudev.grover@gmail.com
39b97ce9f5501590918e6b55e5e29616e6b88809
bbe7671fd0218f4f53082aa29eaf8d4137d1b505
/cpp/hello/main.cpp
bbce233c482568dafe9aa3a06261570c71b8c916
[]
no_license
b4rb4tron/projecten
da8650a694860b1e259fafd423eb249f7b2625cf
59f6a94a3b253ec1e9ac63d8ce31cbf493be887f
refs/heads/master
2021-07-06T07:22:11.864197
2018-10-25T09:51:43
2018-10-25T09:51:43
133,808,041
0
0
null
null
null
null
UTF-8
C++
false
false
144
cpp
#include <iostream> #include "test.h" using namespace std; int main() { cout << "Hello world!" << endl; test newtest; return 0; }
[ "roger@snoeivanhout.nl" ]
roger@snoeivanhout.nl
615641b86279bfc4c7533476181cb73ecfbd385a
f0b4ce0ba6972301435f182a6d4c02987ee17ab3
/whacAMole.cc
8ccc5d4730d71a60529367313bba7ad8cf98479c
[]
no_license
gs0622/leetcode
b64bf1ac8d52ea473cac98b057a5edd1c8ff3591
ef9388f875c375f6f3cd290b04e457b416d860dc
refs/heads/master
2021-06-02T00:54:32.332803
2020-05-19T01:13:51
2020-05-19T01:13:51
20,798,407
0
0
null
null
null
null
UTF-8
C++
false
false
1,489
cc
#include <bits/stdc++.h> using namespace std; class Solution { public: // O(n) sliding window int whatAMoleTwoMallets(vector<int>& A, int w) { int n=A.size(); vector<int> sum(n,0); for (int i=0; i<n; ++i) sum[i]=(i==0)? A[i]: A[i]+sum[i-1]; function<int(int,int)> getSum=[&](int i, int j) { return (i==0)? sum[j]: sum[j]-sum[i-1]; }; pair<int,int> ids={n-2*w,n-w}; int mainSumTwoSubArr = getSum(n-2*w,n-w-1)+getSum(n-w,n-1); pair<int,int> secSubArrMax={n-w,getSum(n-w,n-1)}; for (int i=n-2*w-1; i>=0; --i) { int cur = getSum(i+w,i+2*w-1); // 1st:[n-w-1,n-2] if (cur > secSubArrMax.second) secSubArrMax={i+w,cur}; cur = getSum(i,i+w-1) + secSubArrMax.second; if (cur>mainSumTwoSubArr) mainSumTwoSubArr=cur, ids={i,secSubArrMax.first}; } /* for (int i=ids.first; i<ids.first+w; ++i) cout << A[i]; cout << endl; for (int i=ids.second; i<ids.second+w; ++i) cout << A[i]; cout << endl; */ return mainSumTwoSubArr; } int whatAMole(vector<int>& A, int w) { int n=A.size(),res=0,cur=0; for (int i=0,j=0; i<n; ++i) { if (A[i]==1) ++cur; while ((i-j)>5) { cur-=A[j++]; } res=max(res,cur); } return res; } }; int main(){ Solution s; vector<int> A1{0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0}; cout << s.whatAMole(A1,5) << endl; vector<int> A2{0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0}; cout << s.whatAMoleTwoMallets(A2,5) << endl; }
[ "gs0622@gmail.com" ]
gs0622@gmail.com
9bd70c24d67b90e653467a6f72d5a3a7b0c226e6
651570891f9a418440f2611f3773e2498c6ce3be
/TRAC-IK package/baxter_sim_kinematics/src/arm_kinematics.cpp
6d13e7a0e60bbde7799b9220da56f008ef8b9d98
[]
no_license
MartinFk/ReMa
aa22bb32f0d5e47b7e812a01ae407ad5444ec6ea
2233e53994952ac36bbab766834f817c26d3bdf6
refs/heads/master
2021-05-06T05:59:18.865847
2018-01-06T18:45:05
2018-01-06T18:45:05
115,284,971
0
1
null
null
null
null
UTF-8
C++
false
false
18,653
cpp
/********************************************************************* # Copyright (c) 2013-2015, Rethink Robotics # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the Rethink Robotics nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ /** * \author Hariharasudan Malaichamee * \modified Martin Feick * \desc library that performs the calculations for the IK,FK and Gravity compensation using the KDL library */ #include <cstring> #include <ros/ros.h> #include <baxter_sim_kinematics/arm_kinematics.h> namespace arm_kinematics { Kinematics::Kinematics() : nh_private("~") { } bool Kinematics::init_grav() { std::string urdf_xml, full_urdf_xml; nh.param("urdf_xml", urdf_xml, std::string("robot_description")); nh.searchParam(urdf_xml, full_urdf_xml); ROS_DEBUG("Reading xml file from parameter server"); std::string result; if (!nh.getParam(full_urdf_xml, result)) { ROS_FATAL("Could not load the xml from parameter server: %s", urdf_xml.c_str()); return false; } if (!nh.getParam("root_name", root_name)) { ROS_FATAL("GenericIK: No tip name for gravity found on parameter server"); return false; } if (!nh.getParam("grav_right_name", grav_right_name)) { ROS_FATAL("GenericIK: No tip name for gravity found on parameter server"); return false; } if (!nh.getParam("grav_left_name", grav_left_name)) { ROS_FATAL("GenericIK: No tip name for gravity found on parameter server"); return false; } //Service client to set the gravity false for the limbs ros::ServiceClient get_lp_client = nh.serviceClient<gazebo_msgs::GetLinkProperties>("/gazebo/get_link_properties"); //Wait for service to become available get_lp_client.waitForExistence(); //Service client to set the gravity false for the limbs ros::ServiceClient set_lp_client = nh.serviceClient<gazebo_msgs::SetLinkProperties>("/gazebo/set_link_properties"); //Wait for service to become availablestd::find(vector.begin(), vector.end(), item)!=vector.end() set_lp_client.waitForExistence(); gazebo_msgs::SetLinkProperties setlinkproperties; gazebo_msgs::GetLinkProperties getlinkproperties; setlinkproperties.request.gravity_mode=0; //Load the right chain and copy them to Right specific variables tip_name = grav_right_name; if (!loadModel(result)) { ROS_FATAL("Could not load models!"); return false; } grav_chain_r = chain; right_joint.clear(); right_joint.reserve(chain.getNrOfSegments()); std::vector<std::string>::iterator idx; //Update the right_joint with the fixed joints from the URDF. Get each of the link's properties from GetLinkProperties service and //call the SetLinkProperties service with the same set of parameters except for the gravity_mode, which would be disabled. This is //to disable the gravity in the links, thereby to eliminate the need for gravity compensation for (int i = 0; i < chain.getNrOfSegments(); i++) { std::string seg_name = chain.getSegment(i).getName(); std::string joint_name = chain.getSegment(i).getJoint().getName(); idx = std::find(info.joint_names.begin(), info.joint_names.end(), joint_name); if (idx != info.joint_names.end()) { right_joint.push_back(*idx); } std::string link_name = chain.getSegment(i).getName(); getlinkproperties.request.link_name=link_name; setlinkproperties.request.link_name=link_name; get_lp_client.call(getlinkproperties); setlinkproperties.request.com = getlinkproperties.response.com; setlinkproperties.request.mass = getlinkproperties.response.mass; setlinkproperties.request.ixx = getlinkproperties.response.ixx; setlinkproperties.request.iyy = getlinkproperties.response.iyy; setlinkproperties.request.izz = getlinkproperties.response.izz; setlinkproperties.request.ixy = getlinkproperties.response.ixy; setlinkproperties.request.iyz = getlinkproperties.response.iyz; setlinkproperties.request.ixz = getlinkproperties.response.ixz; setlinkproperties.request.gravity_mode = false; set_lp_client.call(setlinkproperties); } //Create a gravity solver for the right chain gravity_solver_r = new KDL::ChainIdSolver_RNE(grav_chain_r, KDL::Vector(0.0, 0.0, -9.8)); //Load the left chain and copy them to Right specific variable tip_name = grav_left_name; if (!loadModel(result)) { ROS_FATAL("Could not load models!"); return false; } grav_chain_l = chain; left_joint.clear(); left_joint.reserve(chain.getNrOfSegments()); //Update the left_joint with the fixed joints from the URDF. Get each of the link's properties from GetLinkProperties service and //call the SetLinkProperties service with the same set of parameters except for the gravity_mode, which would be disabled. This is //to disable the gravity in the links, thereby to eliminate the need for gravity compensation for (int i = 0; i < chain.getNrOfSegments(); i++) { std::string seg_name = chain.getSegment(i).getName(); std::string joint_name = chain.getSegment(i).getJoint().getName(); idx = std::find(info.joint_names.begin(), info.joint_names.end(), joint_name); if (idx != info.joint_names.end()) { left_joint.push_back(*idx); } getlinkproperties.request.link_name=chain.getSegment(i).getName(); std::string link_name = chain.getSegment(i).getName(); getlinkproperties.request.link_name=link_name; setlinkproperties.request.link_name=link_name; get_lp_client.call(getlinkproperties); setlinkproperties.request.com = getlinkproperties.response.com; setlinkproperties.request.mass = getlinkproperties.response.mass; setlinkproperties.request.ixx = getlinkproperties.response.ixx; setlinkproperties.request.iyy = getlinkproperties.response.iyy; setlinkproperties.request.izz = getlinkproperties.response.izz; setlinkproperties.request.ixy = getlinkproperties.response.ixy; setlinkproperties.request.iyz = getlinkproperties.response.iyz; setlinkproperties.request.ixz = getlinkproperties.response.ixz; setlinkproperties.request.gravity_mode = false; set_lp_client.call(setlinkproperties); } //Create a gravity solver for the left chain gravity_solver_l = new KDL::ChainIdSolver_RNE(grav_chain_l, KDL::Vector(0.0, 0.0, -9.8)); return true; } /* Initializes the solvers and the other variables required * @returns true is successful */ bool Kinematics::init(std::string tip, int &no_jts) { // Get URDF XML std::string urdf_xml, full_urdf_xml; tip_name = tip; nh.param("urdf_xml", urdf_xml, std::string("robot_description")); nh.searchParam(urdf_xml, full_urdf_xml); ROS_DEBUG("Reading xml file from parameter server"); std::string result; if (!nh.getParam(full_urdf_xml, result)) { ROS_FATAL("Could not load the xml from parameter server: %s", urdf_xml.c_str()); return false; } // Get Root and Tip From Parameter Service if (!nh.getParam("root_name", root_name)) { ROS_FATAL("GenericIK: No root name found on parameter server"); return false; } // Load and Read Models if (!loadModel(result)) { ROS_FATAL("Could not load models!"); return false; } // Get Solver Parameters int maxIterations; double epsilon; //KDL::Vector grav; nh_private.param("maxIterations", maxIterations, 1000); nh_private.param("epsilon", epsilon, 1e-2); // Build Solvers fk_solver = new KDL::ChainFkSolverPos_recursive(chain); ik_solver_vel = new KDL::ChainIkSolverVel_pinv(chain); ik_solver_pos = new KDL::ChainIkSolverPos_NR_JL(chain, joint_min, joint_max, *fk_solver, *ik_solver_vel, maxIterations, epsilon); double eps = 1e-5; double timeout = 0.005; ik_solver = new TRAC_IK::TRAC_IK(chain, joint_min, joint_max, timeout, eps); no_jts=num_joints; return true; } /* Method to load all the values from the parameter server * @returns true is successful */ bool Kinematics::loadModel(const std::string xml) { urdf::Model robot_model; KDL::Tree tree; if (!robot_model.initString(xml)) { ROS_FATAL("Could not initialize robot model"); return -1; } if (!kdl_parser::treeFromString(xml, tree)) { ROS_ERROR("Could not initialize tree object"); return false; } if (!tree.getChain(root_name, tip_name, chain)) { ROS_ERROR("Could not initialize chain object for root_name %s and tip_name %s",root_name.c_str(), tip_name.c_str()); return false; } if (!readJoints(robot_model)) { ROS_FATAL("Could not read information about the joints"); return false; } return true; } /* Method to read the URDF model and extract the joints * @returns true is successful */ bool Kinematics::readJoints(urdf::Model &robot_model) { num_joints = 0; boost::shared_ptr<const urdf::Link> link = robot_model.getLink(tip_name); boost::shared_ptr<const urdf::Joint> joint; for (int i = 0; i < chain.getNrOfSegments(); i++) while (link && link->name != root_name) { if (!(link->parent_joint)) { break; } joint = robot_model.getJoint(link->parent_joint->name); if (!joint) { ROS_ERROR("Could not find joint: %s", link->parent_joint->name.c_str()); return false; } if (joint->type != urdf::Joint::UNKNOWN && joint->type != urdf::Joint::FIXED) { ROS_INFO("adding joint: [%s]", joint->name.c_str()); num_joints++; } link = robot_model.getLink(link->getParent()->name); } joint_min.resize(num_joints); joint_max.resize(num_joints); info.joint_names.resize(num_joints); info.link_names.resize(num_joints); link = robot_model.getLink(tip_name); unsigned int i = 0; while (link && i < num_joints) { joint = robot_model.getJoint(link->parent_joint->name); if (joint->type != urdf::Joint::UNKNOWN && joint->type != urdf::Joint::FIXED) { ROS_INFO("getting bounds for joint: [%s]", joint->name.c_str()); float lower, upper; int hasLimits; if (joint->type != urdf::Joint::CONTINUOUS) { lower = joint->limits->lower; upper = joint->limits->upper; hasLimits = 1; } else { lower = -M_PI; upper = M_PI; hasLimits = 0; } int index = num_joints - i - 1; joint_min.data[index] = lower; joint_max.data[index] = upper; info.joint_names[index] = joint->name; info.link_names[index] = link->name; i++; } link = robot_model.getLink(link->getParent()->name); } return true; } /* Method to calculate the torques required to apply at each of the joints for gravity compensation * @returns true is successful */ bool arm_kinematics::Kinematics::getGravityTorques( const sensor_msgs::JointState joint_configuration, baxter_core_msgs::SEAJointState &left_gravity, baxter_core_msgs::SEAJointState &right_gravity, bool isEnabled) { bool res; KDL::JntArray torques_l, torques_r; KDL::JntArray jntPosIn_l, jntPosIn_r; left_gravity.name = left_joint; right_gravity.name = right_joint; left_gravity.gravity_model_effort.resize(num_joints); right_gravity.gravity_model_effort.resize(num_joints); if (isEnabled) { torques_l.resize(num_joints); torques_r.resize(num_joints); jntPosIn_l.resize(num_joints); jntPosIn_r.resize(num_joints); // Copying the positions of the joints relative to its index in the KDL chain for (unsigned int j = 0; j < joint_configuration.name.size(); j++) { for (unsigned int i = 0; i < num_joints; i++) { if (joint_configuration.name[j] == left_joint.at(i)) { jntPosIn_l(i) = joint_configuration.position[j]; break; } else if (joint_configuration.name[j] == right_joint.at(i)) { jntPosIn_r(i) = joint_configuration.position[j]; break; } } } KDL::JntArray jntArrayNull(num_joints); KDL::Wrenches wrenchNull_l(grav_chain_l.getNrOfSegments(), KDL::Wrench::Zero()); int code_l = gravity_solver_l->CartToJnt(jntPosIn_l, jntArrayNull, jntArrayNull, wrenchNull_l, torques_l); KDL::Wrenches wrenchNull_r(grav_chain_r.getNrOfSegments(), KDL::Wrench::Zero()); int code_r = gravity_solver_r->CartToJnt(jntPosIn_r, jntArrayNull, jntArrayNull, wrenchNull_r, torques_r); //Check if the gravity was succesfully calculated by both the solvers if (code_l >= 0 && code_r >= 0) { for (unsigned int i = 0; i < num_joints; i++) { left_gravity.gravity_model_effort[i] = torques_l(i); right_gravity.gravity_model_effort[i] = torques_r(i); } return true; } else { ROS_ERROR_THROTTLE( 1.0, "KT: Failed to compute gravity torques from KDL return code for left and right arms %d %d", code_l, code_r); return false; } } else { for (unsigned int i = 0; i < num_joints; i++) { left_gravity.gravity_model_effort[i]=0; right_gravity.gravity_model_effort[i]=0; } } return true; } /* Method to calculate the Joint index of a particular joint from the KDL chain * @returns the index of the joint */ int Kinematics::getJointIndex(const std::string &name) { for (unsigned int i = 0; i < info.joint_names.size(); i++) { if (info.joint_names[i] == name) return i; } return -1; } /* Method to calculate the KDL segment index of a particular segment from the KDL chain * @returns the index of the segment */ int Kinematics::getKDLSegmentIndex(const std::string &name) { int i = 0; while (i < (int) chain.getNrOfSegments()) { if (chain.getSegment(i).getJoint().getName() == name) { return i + 1; } i++; } return -1; } /* Method to calculate the IK for the required end pose * @returns true if successful */ bool arm_kinematics::Kinematics::getPositionIK( const geometry_msgs::PoseStamped &pose_stamp, const sensor_msgs::JointState &seed, sensor_msgs::JointState *result) { geometry_msgs::PoseStamped pose_msg_in = pose_stamp; tf::Stamped<tf::Pose> transform; tf::Stamped<tf::Pose> transform_root; tf::poseStampedMsgToTF(pose_msg_in, transform); //Do the IK KDL::JntArray jnt_pos_in; KDL::JntArray jnt_pos_out; jnt_pos_in.resize(num_joints); // Copying the positions of the joints relative to its index in the KDL chain for (unsigned int i = 0; i < num_joints; i++) { int tmp_index = getJointIndex(seed.name[i]); if (tmp_index >= 0) { jnt_pos_in(tmp_index) = seed.position[i]; } else { ROS_ERROR("i: %d, No joint index for %s", i, seed.name[i].c_str()); } } //Convert F to our root_frame try { tf_listener.transformPose(root_name, transform, transform_root); } catch (...) { ROS_ERROR("Could not transform IK pose to frame: %s", root_name.c_str()); return false; } KDL::Frame F_dest; tf::transformTFToKDL(transform_root, F_dest); //int ik_valid = ik_solver_pos->CartToJnt(jnt_pos_in, F_dest, jnt_pos_out); int ik_valid=ik_solver->CartToJnt(jnt_pos_in, F_dest, jnt_pos_out); if (ik_valid >= 0) { result->name = info.joint_names; result->position.resize(num_joints); for (unsigned int i = 0; i < num_joints; i++) { result->position[i] = jnt_pos_out(i); ROS_DEBUG("IK Solution: %s %d: %f", result->name[i].c_str(), i, jnt_pos_out(i)); } return true; } else { ROS_DEBUG("An IK solution could not be found"); return false; } } /* Method to calculate the FK for the required joint configuration * @returns true if successful */ bool arm_kinematics::Kinematics::getPositionFK( std::string frame_id, const sensor_msgs::JointState &joint_configuration, geometry_msgs::PoseStamped &result) { KDL::Frame p_out; KDL::JntArray jnt_pos_in; tf::Stamped<tf::Pose> tf_pose; // Copying the positions of the joints relative to its index in the KDL chain jnt_pos_in.resize(num_joints); for (unsigned int i = 0; i < num_joints; i++) { int tmp_index = getJointIndex(joint_configuration.name[i]); if (tmp_index >= 0) jnt_pos_in(tmp_index) = joint_configuration.position[i]; } int num_segments = chain.getNrOfSegments(); ROS_DEBUG("Number of Segments in the KDL chain: %d", num_segments); if (fk_solver->JntToCart(jnt_pos_in, p_out, num_segments) >= 0) { tf_pose.frame_id_ = root_name; tf_pose.stamp_ = ros::Time(); tf::poseKDLToTF(p_out, tf_pose); try { tf_listener.transformPose(frame_id, tf_pose, tf_pose); } catch (...) { ROS_ERROR("Could not transform FK pose to frame: %s", frame_id.c_str()); return false; } tf::poseStampedTFToMsg(tf_pose, result); } else { ROS_ERROR("Could not compute FK for endpoint."); return false; } return true; } } //namespace
[ "martinfeick@yahoo.de" ]
martinfeick@yahoo.de
69c3bf5e4501e9b659ef06bc25505e9af4c9a44f
da726bce6d0f9ab1e63b9c04a2cb33976a0735a3
/lib/Transform/Mixed/DINodeRetriever.cpp
3cb1bfa7b68a68d6d30bd1e8b3b8fff30200fea7
[ "Apache-2.0", "NCSA" ]
permissive
dvm-system/tsar
c4017018a624100d50749004dc60e1f6b23fa99f
8ee33ff80702766d832e56aa37e82931aacd2ba3
refs/heads/master
2023-05-24T23:41:39.583393
2023-04-22T12:23:40
2023-04-22T12:24:17
212,194,441
19
20
Apache-2.0
2023-05-22T09:11:28
2019-10-01T20:35:07
C++
UTF-8
C++
false
false
7,908
cpp
//===- DIGlobalRetriever.cpp - Global Debug Info Retriever ------*- C++ -*-===// // // Traits Static Analyzer (SAPFOR) // // Copyright 2018 DVM System Group // // 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. // //===----------------------------------------------------------------------===// // // This file implements a pass which retrieves some debug information for // global values if it is not presented in LLVM IR. // //===----------------------------------------------------------------------===// #include "tsar/Analysis/KnownFunctionTraits.h" #include "tsar/Analysis/Memory/Utils.h" #include "tsar/Frontend/Clang/TransformationContext.h" #include "tsar/Support/MetadataUtils.h" #include "tsar/Support/Clang/Utils.h" #include "tsar/Transform/Mixed/Passes.h" #include <bcl/utility.h> #include <clang/Basic/LangOptions.h> #include <clang/AST/Decl.h> #include <llvm/IR/DebugInfo.h> #include <llvm/IR/DIBuilder.h> #include <llvm/IR/InstIterator.h> #include <llvm/IR/Module.h> #include <llvm/Pass.h> #include <llvm/Support/Path.h> #include <llvm/Support/FileSystem.h> using namespace clang; using namespace llvm; using namespace tsar; namespace { /// This retrieves some debug information for global values if it is not /// presented in LLVM IR ('sapfor.dbg' metadata will be attached to globals). class DINodeRetrieverPass : public ModulePass, private bcl::Uncopyable { public: static char ID; DINodeRetrieverPass() : ModulePass(ID) { initializeDINodeRetrieverPassPass(*PassRegistry::getPassRegistry()); } bool runOnModule(llvm::Module &M) override; void getAnalysisUsage(AnalysisUsage &AU) const override { AU.getPreservesAll(); } private: /// Insert artificial metadata for allocas. void insertDeclareIfNotExist(Function &F, DIFile *FileCU, DIBuilder &DIB) { for (auto &I : instructions(F)) if (auto *AI = dyn_cast<AllocaInst>(&I)) { auto &Ctx = AI->getContext(); auto AddrUses = FindDbgAddrUses(AI); if (!AddrUses.empty()) { for (auto *DbgInst : AddrUses) { // Artificial variables without name may produce the same // metdata-level locations for distinct lower level locations. // This leads to incorrect metadata-level alias tree. // So, replace this variable with the distinct one. if (auto DIVar = DbgInst->getVariable()) if (DIVar->getFlags() & DINode::FlagArtificial && DIVar->getName().empty()) { auto DistinctDIVar = DILocalVariable::getDistinct( Ctx, DIVar->getScope(), "sapfor.var", DIVar->getFile(), DIVar->getLine(), DIVar->getType(), DIVar->getArg(), DIVar->getFlags(), DIVar->getAlignInBits(), nullptr); DbgInst->setVariable(DistinctDIVar); } } continue; } auto *DITy = createStubType(*F.getParent(), AI->getType()->getAddressSpace(), DIB); auto *DISub = F.getSubprogram(); auto *DIVar = DILocalVariable::getDistinct( Ctx, DISub, "sapfor.var", FileCU, 0, DITy, 0, DINode::FlagArtificial, AI->getAlign().value(), nullptr); DIB.insertDeclare(AI, DIVar, DIExpression::get(Ctx, {}), DILocation::get(AI->getContext(), 0, 0, DISub), AI->getParent()); } } }; } // namespace char DINodeRetrieverPass::ID = 0; INITIALIZE_PASS(DINodeRetrieverPass, "di-node-retriever", "Debug Info Retriever", true, false) bool DINodeRetrieverPass::runOnModule(llvm::Module &M) { auto *TEP{getAnalysisIfAvailable<TransformationEnginePass>()}; auto &Ctx = M.getContext(); auto CUItr = M.debug_compile_units_begin(); assert(CUItr != M.debug_compile_units_end() && "At least one compile unit must be available!"); auto CU = std::distance(CUItr, M.debug_compile_units_end()) == 1 ? *CUItr : nullptr; SmallString<256> CWD; auto DirName = CU ? CUItr->getDirectory() : (llvm::sys::fs::current_path(CWD), StringRef(CWD)); auto *FileCU = CU ? CU->getFile() : nullptr; DIBuilder DIB(M); for (auto &GlobalVar : M.globals()) { SmallVector<DIMemoryLocation, 1> DILocs; if (findGlobalMetadata(&GlobalVar, DILocs)) continue; DIFile *File = FileCU; unsigned Line = 0; // A name should be specified for global variables, otherwise LLVM IR is // considered corrupted. StringRef Name = "sapfor.var"; if (TEP && *TEP) for (auto [CU, TfmCtxBase] : (*TEP)->contexts()) if (auto *TfmCtx{dyn_cast<ClangTransformationContext>(TfmCtxBase)}) if (auto D = TfmCtx->getDeclForMangledName(GlobalVar.getName())) { auto &SrcMgr = TfmCtx->getRewriter().getSourceMgr(); auto FName = SrcMgr.getFilename(SrcMgr.getExpansionLoc(D->getBeginLoc())); File = DIB.createFile(FName, CU->getDirectory()); Line = SrcMgr.getPresumedLineNumber( SrcMgr.getExpansionLoc(D->getBeginLoc())); if (auto ND = dyn_cast<NamedDecl>(D)) Name = ND->getName(); break; } auto *DITy = createStubType(M, GlobalVar.getType()->getAddressSpace(), DIB); auto *GV = DIGlobalVariable::getDistinct( Ctx, File, Name, GlobalVar.getName(), File, Line, DITy, GlobalVar.hasLocalLinkage(), !GlobalVar.isDeclaration(), nullptr, nullptr, 0, nullptr); auto *GVE = DIGlobalVariableExpression::get(Ctx, GV, DIExpression::get(Ctx, {})); GlobalVar.setMetadata("sapfor.dbg", GVE); } for (auto &F : M.functions()) { if (F.getSubprogram()) { insertDeclareIfNotExist(F, FileCU, DIB); continue; } if (F.isIntrinsic() && (isDbgInfoIntrinsic(F.getIntrinsicID()) || isMemoryMarkerIntrinsic(F.getIntrinsicID()))) continue; DIFile *File = FileCU; unsigned Line = 0; auto Flags = DINode::FlagZero; MDString *Name = nullptr; if (TEP && *TEP) for (auto [CU, TfmCtxBase] : (*TEP)->contexts()) if (auto *TfmCtx{dyn_cast<ClangTransformationContext>(TfmCtxBase)}) if (auto *D = TfmCtx->getDeclForMangledName(F.getName())) { auto &SrcMgr = TfmCtx->getRewriter().getSourceMgr(); auto FName = SrcMgr.getFilename(SrcMgr.getExpansionLoc(D->getBeginLoc())); File = DIB.createFile(FName, CU->getDirectory()); Line = SrcMgr.getPresumedLineNumber( SrcMgr.getExpansionLoc(D->getBeginLoc())); if (auto *FD = dyn_cast<FunctionDecl>(D)) { SmallString<64> ExtraName; Name = MDString::get(Ctx, getFunctionName(*FD, ExtraName)); if (FD->hasPrototype()) Flags |= DINode::FlagPrototyped; if (FD->isImplicit()) Flags |= DINode::FlagArtificial; } } auto SPFlags = DISubprogram::toSPFlags(F.hasLocalLinkage(), !F.isDeclaration(), false); auto *SP = DISubprogram::getDistinct(Ctx, File, Name, MDString::get(Ctx, F.getName()), File, Line, nullptr, Line, nullptr, 0, 0, Flags, SPFlags, !F.isDeclaration() ? CU : nullptr); F.setMetadata("sapfor.dbg", SP); insertDeclareIfNotExist(F, FileCU, DIB); } return true; } ModulePass *llvm::createDINodeRetrieverPass() { return new DINodeRetrieverPass(); }
[ "kaniandr@gmail.com" ]
kaniandr@gmail.com
b9b828d0818d1e36db7998a54d1ba8f7a219905b
a9d13a7251696bc70471792765a6e3b46af40490
/cpp/21.cpp
bc8d296e2e70f9104e0849ec2216a8347e15015f
[]
no_license
Yesol222/Algorithm
529e895eb0aa154633f85ae215d41cc74cd5b33e
a8d632935a5bc0413aa097b5ebac435fbf24486a
refs/heads/master
2023-03-24T23:58:39.799405
2021-03-23T06:59:56
2021-03-23T06:59:56
334,355,839
0
0
null
null
null
null
UTF-8
C++
false
false
694
cpp
#include <stdio.h> int main(){ freopen("input.txt.","rt",stdin); int i, A[10],B[10],as=0,bs=0,lw=0; for(i=0;i<10;i++){ scanf("%d",&A[i]); } for(i=0;i<10;i++){ scanf("%d",&B[i]); } for(i=0;i<10;i++){ if(A[i]>B[i]){ as+=3; lw=1; } else if(A[i]<B[i]){ bs+=3; lw=2; } else{ as+=1; bs+=1; } } printf("%d %d", as, bs); if(as==bs){ if(lw==0) printf("D\n"); else if(lw==1) printf("A\n"); else printf("B\n"); } else if(as>bs) printf("A\n"); else printf("B\n"); return 0; }
[ "744348@gmail.com" ]
744348@gmail.com
1476fd99cb70e74cee533d2ef3d0c0c40cce338e
309647935d0f8f507207ecf48d124102c1d7197f
/Utility/memory_parser/Password.h
1f4901f9aa1b7a159acdd5477f26e8dba5bfa642
[ "MIT" ]
permissive
ThomasChevalier/passwordWallet
6b59d8afd48c1bbdc89348798beebfa6ced87e7e
115dbde3e32f2be65071e6f298c4f03ddfe19b09
refs/heads/master
2021-03-27T20:00:34.594894
2020-04-19T17:03:49
2020-04-19T17:03:49
71,448,410
3
0
null
null
null
null
UTF-8
C++
false
false
318
h
#ifndef PASSWORD_HEADER_THOMAS_CHEVALIER #define PASSWORD_HEADER_THOMAS_CHEVALIER #include <cstdint> #include <string> struct Password { typedef uint8_t id_t; Password(); id_t id; uint16_t counter; std::string name; std::string password; std::string userName; }; #endif // PASSWORD_HEADER_THOMAS_CHEVALIER
[ "thomasom.chevalier@gmail.com" ]
thomasom.chevalier@gmail.com
58514e92995664918b86be20b589c90f7830c54f
cc7b87b6315b53d7682fd1d05481b929363014be
/C++/Volume C/P10042.cpp
964c6ece8fcd3684c2937d98e40627c7a3089872
[]
no_license
ptargino/uvaOnlineJudge
b6d02a3c8cc084547247686da82ea0977c55f4af
b8922626122b013d8e668c6521504fce85958a7b
refs/heads/master
2020-05-19T16:19:34.010520
2012-06-30T21:21:06
2012-06-30T21:21:06
2,787,653
0
0
null
null
null
null
UTF-8
C++
false
false
1,127
cpp
#include <math.h> #include <iostream> using namespace std; bool isPrime(long int n) { int root = (int) sqrt(n); for (int i = 3; i < root; i += 2) if (!(n % i)) return false; return true; } int sumDigits(long n) { int sum = 0; while (n) { sum += n % 10; n /= 10; } return sum; } int main() { long int n, root, i, j; const long SIZE = 100000; int MAX_ROOT = (int) sqrt(SIZE); bool *prime = new bool[SIZE]; memset(prime, true, SIZE); for (i = 3; i <= MAX_ROOT; i += 2) if (isPrime(i)) for (j = 2 * i; j < SIZE; j += i) prime[j] = false; int sumA, sumB; int t; scanf("%d", &t); for (; t; t--) { scanf("%ld", &n); n++; while (true) { long num = n; sumA = 0; sumB = sumDigits(n); while (num % 2 == 0) { sumA += 2; num /= 2; } i = 3; while (i <= num && num != 1) { if (prime[i]) while (num % i == 0) { sumA += sumDigits(i); num /= i; } i += 2; } printf("%ld\n", n); if (sumA == sumB) { printf("%ld\n", n); break; } else { n++; } } } }
[ "ptargino@gmail.com" ]
ptargino@gmail.com
7dd90e0a5fe64e6f0b097f48fea2d058e4492439
771a4e3846212eabbabf6b68bf73d4a326d0973e
/src/vswprinn.cpp
3f647373b1f94326e709d91a5f2ed7b5919456f5
[]
no_license
ganboing/crt.vc12
4e65b96bb5bd6c5b5be6a08d04c9b712b269461f
f1d47126bf13d1c9dccaa6c53b72217fd0474968
refs/heads/master
2021-01-13T08:48:12.365115
2016-09-24T20:16:46
2016-09-24T20:16:46
69,113,159
4
1
null
null
null
null
UTF-8
C++
false
false
4,238
cpp
/*** *vswprint.c - print formatted data into a string from var arg list * * Copyright (c) Microsoft Corporation. All rights reserved. * *Purpose: * defines vswprintf() and _vsnwprintf() - print formatted output to * a string, get the data from an argument ptr instead of explicit * arguments. * *******************************************************************************/ #ifdef CRTDLL /* * Suppress the inline definitions of iswalpha et al. Necessary to avoid * a conflict with the dllexport versions from _wctype.c in the DLL build. */ #define _WCTYPE_INLINE_DEFINED #endif /* CRTDLL */ #include <cruntime.h> /* This is prevent pulling in the inline versions of (v)swprintf */ #define _INC_SWPRINTF_INL_ #include <stdio.h> #include <wchar.h> #include <dbgint.h> #include <stdarg.h> #include <internal.h> #include <limits.h> #include <mtdll.h> #define MAXSTR INT_MAX /*** *int vswprintf(string, cnt, format, ap) - print formatted data to string from arg ptr * *Purpose: * Prints formatted data, but to a string and gets data from an argument * pointer. * Sets up a FILE so file i/o operations can be used, make string look * like a huge buffer to it, but _flsbuf will refuse to flush it if it * fills up. Appends '\0' to make it a true string. * * Allocate the 'fake' _iob[] entryit statically instead of on * the stack so that other routines can assume that _iob[] entries are in * are in DGROUP and, thus, are near. * * The vswprintf() flavor takes a count argument that is * the max number of bytes that should be written to the * user's buffer. * * Multi-thread: (1) Since there is no stream, this routine must never try * to get the stream lock (i.e., there is no stream lock either). (2) * Also, since there is only one staticly allocated 'fake' iob, we must * lock/unlock to prevent collisions. * *Entry: * wchar_t *string - place to put destination string * size_t count - max number of bytes to put in buffer * wchar_t *format - format string, describes format of data * va_list ap - varargs argument pointer * *Exit: * returns number of wide characters in string * *Exceptions: * *******************************************************************************/ int __cdecl _vswprintf_l ( wchar_t *string, size_t count, const wchar_t *format, _locale_t plocinfo, va_list ap ) { FILE str = { 0 }; FILE *outfile = &str; int retval; _ASSERTE(string != NULL); _ASSERTE(format != NULL); outfile->_flag = _IOWRT|_IOSTRG; outfile->_ptr = outfile->_base = (char *) string; if(count>(INT_MAX/sizeof(wchar_t))) { /* old-style functions allow any large value to mean unbounded */ outfile->_cnt = INT_MAX; } else { outfile->_cnt = (int)(count*sizeof(wchar_t)); } retval = _woutput_l(outfile,format,plocinfo,ap ); _putc_nolock('\0',outfile); /* no-lock version */ _putc_nolock('\0',outfile); /* 2nd byte for wide char version */ return(retval); } int __cdecl vswprintf ( wchar_t *string, size_t count, const wchar_t *format, va_list ap ) { return _vswprintf_l(string, count, format, NULL, ap); } #if defined (_NATIVE_WCHAR_T_DEFINED) int __cdecl _vswprintf_l ( unsigned short *string, size_t count, const unsigned short *format, _locale_t plocinfo, va_list ap ) { return _vswprintf_l(reinterpret_cast<wchar_t *>(string), count, reinterpret_cast<const wchar_t *>(format), plocinfo,ap); } int __cdecl vswprintf ( unsigned short *string, size_t count, const unsigned short *format, va_list ap ) { return _vswprintf_l(reinterpret_cast<wchar_t *>(string), count, reinterpret_cast<const wchar_t *>(format), NULL, ap); } #endif /* defined (_NATIVE_WCHAR_T_DEFINED) */
[ "gan.bo@columbia.edu" ]
gan.bo@columbia.edu
49622d2936de25439968c35b7af165f44568c76d
cccfb7be281ca89f8682c144eac0d5d5559b2deb
/ash/components/phonehub/fake_camera_roll_download_manager.h
4d531c34b167ddd565953dec22279be5f1610752
[ "BSD-3-Clause" ]
permissive
SREERAGI18/chromium
172b23d07568a4e3873983bf49b37adc92453dd0
fd8a8914ca0183f0add65ae55f04e287543c7d4a
refs/heads/master
2023-08-27T17:45:48.928019
2021-11-11T22:24:28
2021-11-11T22:24:28
428,659,250
1
0
BSD-3-Clause
2021-11-16T13:08:14
2021-11-16T13:08:14
null
UTF-8
C++
false
false
1,901
h
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ASH_COMPONENTS_PHONEHUB_FAKE_CAMERA_ROLL_DOWNLOAD_MANAGER_H_ #define ASH_COMPONENTS_PHONEHUB_FAKE_CAMERA_ROLL_DOWNLOAD_MANAGER_H_ #include <vector> #include "ash/components/phonehub/camera_roll_download_manager.h" #include "ash/components/phonehub/proto/phonehub_api.pb.h" #include "base/containers/flat_map.h" #include "chromeos/services/secure_channel/public/mojom/secure_channel_types.mojom.h" namespace chromeos { namespace phonehub { class FakeCameraRollDownloadManager : public CameraRollDownloadManager { public: FakeCameraRollDownloadManager(); ~FakeCameraRollDownloadManager() override; // CameraRollDownloadManager: void CreatePayloadFiles( int64_t payload_id, const chromeos::phonehub::proto::CameraRollItemMetadata& item_metadata, CreatePayloadFilesCallback payload_files_callback) override; void UpdateDownloadProgress( chromeos::secure_channel::mojom::FileTransferUpdatePtr update) override; void DeleteFile(int64_t payload_id) override; void set_should_create_payload_files_succeed( bool should_create_payload_files_succeed) { should_create_payload_files_succeed_ = should_create_payload_files_succeed; } const std::vector<chromeos::secure_channel::mojom::FileTransferUpdatePtr>& GetFileTransferUpdates(int64_t payload_id) const; private: bool should_create_payload_files_succeed_ = true; // A map from payload IDs to the list of FileTransferUpdate received for each // payload. base::flat_map< int64_t, std::vector<chromeos::secure_channel::mojom::FileTransferUpdatePtr>> payload_update_map_; }; } // namespace phonehub } // namespace chromeos #endif // ASH_COMPONENTS_PHONEHUB_FAKE_CAMERA_ROLL_DOWNLOAD_MANAGER_H_
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
f3460f675f5e2b569bfb2559b06024507bc95d79
67233ab008d07efb37e6ed33c6959fc6215e5048
/CodeTestZone/A1_Threadpool/CThreadUsingMsgLoop.h
8f8965c427a41a58caaa2efac5d085e184a3aa2b
[]
no_license
yinjingyu/LinuxDevelopment
0e9350ec985c40e2a29c9544297e5118a21192a3
5e5c57f3b233507c16cd5e56d4b9682c01a7bdbc
refs/heads/master
2021-01-22T05:15:27.000512
2013-12-03T09:28:29
2013-12-03T09:28:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
707
h
#ifndef CTHREADFORMSGLOOP_H #define CTHREADFORMSGLOOP_H #include "./include/CMsgObserver.h" #include <string> #include "./include/CStatus.h" class CThreadInitFinishedNotifier; class CThread; typedef struct { void * pContext; CThreadInitFinishedNotifier * pNotifier; }SInitialParameter; class CThreadUsingMsgLoop { public: CThreadUsingMsgLoop(const char * strThreadName, CMsgObserver * pMsgObserver); CThreadUsingMsgLoop(const char * strThreadNaem,CMsgObserver * pMsgObserver,bool bWaitForDeath); virtual ~CThreadUsingMsgLoop(); CStatus Run(void * pContext); const char * GetThreadName(); private: std::string m_sThreadName; CThread * m_pThread; bool m_bWaitForDeath; }; #endif
[ "yin_jingyu@126.com" ]
yin_jingyu@126.com
9bfcdbdbf8f938745730cec44cd6b9b2b078490d
5932c483784240c78a493cbc349d955c63d3ba9b
/SimpleTfIdfDocument.h
d304ec08a598e5c0f895acc42111f71830ed6a60
[ "MIT" ]
permissive
UCSB-CS32-F15/cs32-f15-lab07-start
cfb00b221f947271bf666335d84b454f477dc02b
bbb7ba5068329cfb0b5a102c4319ee96308f1821
refs/heads/master
2021-01-10T15:20:42.441640
2018-02-07T04:30:24
2018-02-07T04:30:24
46,363,265
0
0
null
null
null
null
UTF-8
C++
false
false
572
h
#ifndef SIMPLE_TFIDF_DOCUMENT_H #define SIMPLE_TFIDF_DOCUMENT_H #include "GenericTfIdfDocument.h" class SimpleTfIdfDocument: public GenericTfIdfDocument { public: SimpleTfIdfDocument(std::string id, std::string text, std::string metadata="") : id(id), text(text), metadata(metadata) {} std::string getId() { return this->id;} std::string getText() { return "stub";} // @@@ DO THE RIGHT THING std::string getMetadata() { return this->metadata;} private: std::string id; std::string text; std::string metadata; }; #endif
[ "pconrad@cs.ucsb.edu" ]
pconrad@cs.ucsb.edu
3c90a958fd46cd6c8c1ab273a6613ec5c435920b
8a45f1803d67e98aa59421981c95a5865d4dbf60
/cpp_16_classes/ch12_05_Friend_this.cpp
14f1a76f864b114d9f5003d1ee9965b5e323663f
[]
no_license
walter-cc/cpp
1a2e2f01692be15ad1224d6abe76c6b766d08fa4
36b5d184d7b4e69753750d5132e87754957f7d2a
refs/heads/master
2021-12-30T21:40:22.305507
2021-08-06T16:11:28
2021-08-06T16:13:21
162,880,321
0
0
null
null
null
null
UTF-8
C++
false
false
2,411
cpp
/* 新增編譯和執行步驟 : g++ hello.cpp -o hello ./hello =============================== # 此範例可以看到 : 「this」指標的宣告和使用方式。 「*this」代表目前這個物件的內容,「return *this;」代表傳回目前這個物件的內容。 =============================== # 在建立class物件時,會自動建立屬於該物件自己的指標,叫做「this」指標。 # 「this」指標指向物件自己本身,指向記憶體中儲存該物件的「位址」。 # 「this」指標代表了「目前這個物件」的指標,可以存取到該class的資料成員和成員函數。 this->資料成員; //第一種方式 (*this).資料成員; //第二種方式 */ #include <iostream> // 引入標準程式庫中相關的輸入、輸出程式 #include <cstdlib> using namespace std; // std : 標準程式庫的命名空間 class Square { // 宣告類別 private: //私用資料成員 int a; public: //公用資料成員 Square(); //宣告預設建構子(constructor) Square(int n); //宣告有參數的建構子(constructor) Square squ(Square b); void show_data(); }; // 記得加上 ";" #### 重要 Square::Square(int n) //constructor使用參數設定初始值 { a = n*n; } Square Square::squ(Square b) // 實作 { this->a = this->a + b.a; // this->a 為 n1*n1, b.a 為 n2*n2 return *this; // 透過this指標 傳回 class Square } void Square::show_data() { cout << "答案" << (*this).a << endl; } /* - argc : argument count(參數總和)的縮寫,代表包括指令本身的參數個數。 - argv : argument value 的縮寫。 一個陣列,它會分拆所帶的參數放到陣列內 */ int main(int argc, char *argv[]) { int n1, n2; cout << "輸入第一個數字 : " ; cin >> n1; cout << "輸入第二個數字 : " ; cin >> n2; Square first(n1), second(n2), third(0); //宣告 class Square 的物件 third = first.squ(second); // 此時進入squ後, this->a 表示的是first這個物件的a成員。b.a 則為second的a成員。 third.show_data(); /* cc@cpphome$g++ cpp_16_classes/ch12_05_Friend_this.cpp -o test cc@cpphome$./test 輸入第一個數字 : 10 輸入第二個數字 : 20 答案500 */ return 0; }
[ "imwalter8@gmail.com" ]
imwalter8@gmail.com
9cc7265b0b688e52232a58d0c883fa3a388cbe8a
77b28b71ff49842067732ef8f948d935a8f3e7a5
/my_Codes/test3.cpp
96cdb66ab676ea94b52eeb7a6decaaddb359d07e
[]
no_license
rahulSingh2995/Codes
ea21b49aabb63e8d55db58da2bc10e5c89b4ccfe
f90d7ad5c20523e5d9b76ce6f71305e9cdf7f37f
refs/heads/master
2021-06-12T17:01:52.723269
2020-05-15T04:55:57
2020-05-15T04:55:57
254,365,740
0
0
null
null
null
null
UTF-8
C++
false
false
141
cpp
#include<iostream> class Test { static void fun(int a) {} void fun() {} // compiler error }; int main() { getchar(); return 0; }
[ "rahulcdacacts@gmail.com" ]
rahulcdacacts@gmail.com
df1315040d5f57018b7be11b3886ec910c0d910e
22ab69eeeecd020fee3e7be74bd5f6f4959cf7e0
/rocsolver/library/src/auxiliary/rocauxiliary_larf.cpp
8753b11bd34bf0424be1149c0caecb572c854553
[ "BSD-2-Clause" ]
permissive
jcarzu/internalDevelop
4ca697dacd2cc5baa5e7a702466e101fb7715cb6
b874d42ce7db68234e4082c5a4e28446469d8460
refs/heads/master
2020-12-10T02:19:55.781116
2020-01-13T00:56:43
2020-01-13T00:56:43
233,480,387
0
0
null
2020-01-13T00:28:14
2020-01-13T00:28:13
null
UTF-8
C++
false
false
3,374
cpp
#include "rocauxiliary_larf.hpp" template <typename T> rocblas_status rocsolver_larf_impl(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, T* x, const rocblas_int incx, const T* alpha, T* A, const rocblas_int lda) { if(!handle) return rocblas_status_invalid_handle; //logging is missing ??? if(n < 0 || m < 0 || lda < m || !incx) return rocblas_status_invalid_size; if(!x || !A || !alpha) return rocblas_status_invalid_pointer; rocblas_int stridex = 0; rocblas_int stridea = 0; rocblas_int stridep = 0; rocblas_int batch_count = 1; return rocsolver_larf_template<T>(handle, side, m, n, x, 0, //vector shifted 0 entries incx, stridex, alpha, stridep, A, 0, //matrix shifted 0 entries lda, stridea, batch_count); } /* * =========================================================================== * C wrapper * =========================================================================== */ extern "C" { ROCSOLVER_EXPORT rocblas_status rocsolver_slarf(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, float* x, const rocblas_int incx, const float* alpha, float* A, const rocblas_int lda) { return rocsolver_larf_impl<float>(handle, side, m, n, x, incx, alpha, A, lda); } ROCSOLVER_EXPORT rocblas_status rocsolver_dlarf(rocblas_handle handle, const rocblas_side side, const rocblas_int m, const rocblas_int n, double* x, const rocblas_int incx, const double* alpha, double* A, const rocblas_int lda) { return rocsolver_larf_impl<double>(handle, side, m, n, x, incx, alpha, A, lda); } } //extern C
[ "juan.zuniga-anaya@amd.com" ]
juan.zuniga-anaya@amd.com
c679b3d22c8d58af9e9600143a5b66f577bb517d
363c0e6a653d4808640031f82b2c3ee62e13c640
/BlendDemo/Framework3/Math/SphericalHarmonics.cpp
b76d5236968a9016087bf1ef2a5e71a8bb851636
[ "MIT" ]
permissive
dtrebilco/PreMulAlpha
8d7e9a7209c2b2bda6c89e7e9a6daad73ec34ff0
4eaf2b0967a4440bbaf7a83a560ee84626015d3d
refs/heads/master
2021-01-10T12:24:21.105947
2018-03-12T13:00:17
2018-03-12T13:00:17
53,249,801
115
3
null
null
null
null
UTF-8
C++
false
false
23,989
cpp
/* * * * * * * * * * * * * Author's note * * * * * * * * * * * *\ * _ _ _ _ _ _ _ _ _ _ _ _ * * |_| |_| |_| |_| |_|_ _|_| |_| |_| _|_|_|_|_| * * |_|_ _ _|_| |_| |_| |_|_|_|_|_| |_| |_| |_|_ _ _ * * |_|_|_|_|_| |_| |_| |_| |_| |_| |_| |_| |_|_|_|_ * * |_| |_| |_|_ _ _|_| |_| |_| |_|_ _ _|_| _ _ _ _|_| * * |_| |_| |_|_|_| |_| |_| |_|_|_| |_|_|_|_| * * * * http://www.humus.name * * * * This file is a part of the work done by Humus. You are free to * * use the code in any way you like, modified, unmodified or copied * * into your own work. However, I expect you to respect these points: * * - If you use this file and its contents unmodified, or use a major * * part of this file, please credit the author and leave this note. * * - For use in anything commercial, please request my approval. * * - Share your work and ideas too as much as you can. * * * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "SphericalHarmonics.h" #define REDIST_FACTOR 1 //#define REDIST_FACTOR 1e-30f const double sqrt2 = 1.4142135623730950488016887242097; double rcp[MAX_BANDS]; double fTab[MAX_BANDS * (MAX_BANDS + 1)]; double kTab[MAX_BANDS * (MAX_BANDS + 1) / 2]; double getFactor(const int l, const int m){ /* double f = 1; for (int i = l - m + 1; i <= l + m; i++){ f *= i; } double pmm = 1; for (int i = 0; i <= m; i++){ pmm *= (1 - 2 * i); } double x = sqrt(pmm * pmm / f); */ double x = 1.0; int i = l - m + 1; int n = l + m; int k = 0; while (true){ bool b0 = (k <= m); bool b1 = (i <= n); if (!b0 && !b1) break; if ((x <= 1.0 && b0) || !b1){ int f = (1 - 2 * k); x *= (f * f); k++; } else { x /= i; i++; } } x = sqrt(x); if (m & 1) x = -x; return x; } void initSH(){ long double fact[2 * MAX_BANDS]; long double d = 1.0L; rcp[0] = 0; for (int i = 1; i < MAX_BANDS; i++){ rcp[i] = double(1.0L / (long double) i); } fact[0] = d; for (int i = 1; i < 2 * MAX_BANDS; i++){ d *= i; fact[i] = d; } double *dstF = fTab; double *dstK = kTab; for (int l = 0; l < MAX_BANDS; l++){ // double fct = 1; // double pmm = 1; for (int m = 0; m <= l; m++){ // pmm *= fct; // fct -= 2; if (l != m){ *dstF++ = double(2 * l - 1) / double(l - m); *dstF++ = double(l + m - 1) / double(l - m); } else { *dstF++ = 0; *dstF++ = 0; } // *dstK++ = (double) (pmm * sqrt((long double(2 * l + 1) * fact[l - m]) / (4.0L * 3.1415926535897932384626433832795L * fact[l + m])) / REDIST_FACTOR); *dstK++ = (double) (getFactor(l, m) * sqrt((double(2 * l + 1) / (4.0L * 3.1415926535897932384626433832795L))) / REDIST_FACTOR); } } } /* float K_list[] = { 0.28209478785f, 0.4886025051f, 0.34549414466f, 0.63078312173f, 0.2575161311f, 0.12875806555f, 0.7463526548f, 0.21545345308f, 0.068132364148f, 0.027814921189f, 0.84628436355f, 0.18923493652f, 0.044603102283f, 0.011920680509f, 0.0042145970123f, 0.93560256661f, 0.17081687686f, 0.032281355422f, 0.0065894040825f, 0.0015531374369f, 0.00049114518199f, 1.0171072221f, 0.15694305165f, 0.024814875307f, 0.0041358125511f, 0.00075509260929f, 0.00016098628522f, 4.6472737553e-005f, 1.0925484154f, 0.14599792317f, 0.019867800849f, 0.0028097313415f, 0.00042358293734f, 7.0597156223e-005f, 1.384524143e-005f, 3.7002964192e-006f, 1.1631066067f, 0.13707342814f, 0.01638340829f, 0.0020166581537f, 0.00026034944814f, 3.6103972493e-005f, 5.5709639026e-006f, 1.0171141988e-006f, 2.5427854971e-007f, 1.2296226727f, 0.12961361028f, 0.013816857281f, 0.0015075427227f, 0.00017069560029f, 2.0402026496e-005f, 2.6338902949e-006f, 3.801693177e-007f, 6.51985001e-008f, 1.5367433848e-008f, 1.2927207185f, 0.12325608434f, 0.011860322246f, 0.0011630002801f, 0.00011748076923f, 1.2383560401e-005f, 1.384524143e-006f, 1.678982142e-007f, 2.2848052974e-008f, 3.7064436234e-009f, 8.2878598968e-010f, 1.3528790761f, 0.11775300918f, 0.0103276221f, 0.00092005770282f, 8.3989393007e-005f, 7.9362516666e-006f, 7.8580600881e-007f, 8.2831226229e-008f, 9.5013932764e-009f, 1.2266245975e-009f, 1.8927228454e-010f, 4.0352986651e-011f, 1.4104739392f, 0.11292829394f, 0.0091000212546f, 0.00074301362407f, 6.1917802006e-005f, 5.3094077196e-006f, 4.7299963365e-007f, 4.4300474576e-008f, 4.4300474576e-009f, 4.8335780492e-010f, 5.9497232884e-011f, 8.7723884023e-012f, 1.7906562843e-012f, 1.4658075153f, 0.10865288191f, 0.0080985076633f, 0.00061044798366f, 4.6819223098e-005f, 3.6784655714e-006f, 2.9836295628e-007f, 2.5216272196e-008f, 2.2464440745e-009f, 2.1419003838e-010f, 2.2330855175e-011f, 2.6317165207e-012f, 3.7218091959e-013f, 7.2990683522e-014f, 1.5191269238f, 0.10482971704f, 0.0072686330764f, 0.00050890610675f, 3.6166382172e-005f, 2.6237851318e-006f, 1.9556539711e-007f, 1.5088197955e-008f, 1.2158416398e-009f, 1.0349931362e-010f, 9.4481514597e-012f, 9.4481514597e-013f, 1.0697924913e-013f, 1.4558031857e-014f, 2.7512094195e-015f, 1.5706373067f, 0.1013842022f, 0.0065717617374f, 0.00042960950433f, 2.8451584469e-005f, 1.9182054336e-006f, 1.3236875055e-007f, 9.40703748e-009f, 6.9349600383e-010f, 5.3504378288e-011f, 4.3686141937e-012f, 3.8315281119e-013f, 3.6868896447e-014f, 4.0227263989e-015f, 5.2820985382e-016f, 9.6437484011e-017f, 1.6205111811f, 0.098257923044f, 0.0059797867672f, 0.00036664425087f, 2.2738311173e-005f, 1.4323789666e-006f, 9.2076807318e-008f, 6.0713648798e-009f, 4.131040555e-010f, 2.9210867898e-011f, 2.1652535868e-012f, 1.7011838825e-013f, 1.4377627964e-014f, 1.3349292434e-015f, 1.4071389748e-016f, 1.7870682851e-017f, 3.159120257e-018f, 1.6688952713f, 0.095404392594f, 0.0054718171853f, 0.00031591551249f, 1.8424566844e-005f, 1.0894674765e-006f, 6.5578235786e-008f, 4.0360614093e-009f, 2.552629366e-010f, 1.668706019e-011f, 1.1354106326e-012f, 8.1100759469e-014f, 6.1482327086e-015f, 5.0200109853e-016f, 4.508102946e-017f, 4.6010633023e-018f, 5.6635174197e-019f, 9.7128522441e-020f, 1.7159156055f, 0.092786089356f, 0.0050320322108f, 0.00027451986316f, 1.5111821107e-005f, 8.4214886554e-007f, 4.7677290989e-008f, 2.7526496787e-009f, 1.6276758768e-010f, 9.9057199338e-012f, 6.2400170243e-013f, 4.0967718822e-014f, 2.8270411804e-015f, 2.0728871658e-016f, 1.6387611941e-017f, 1.4263585367e-018f, 1.4123054005e-019f, 1.6880278198e-020f, 2.8133796997e-021f, 1.7616813855f, 0.090372348238f, 0.0046482520257f, 0.00024035539025f, 1.2529390841e-005f, 6.6035687919e-007f, 3.5297559928e-008f, 1.9199341526e-009f, 1.0666300848e-010f, 6.0776889666e-012f, 3.5689418491e-013f, 2.1719888413e-014f, 1.3792142934e-015f, 9.2152631233e-017f, 6.5490023309e-018f, 5.0228554997e-019f, 4.2450876965e-020f, 4.0848375405e-021f, 4.7485271873e-022f, 7.7031282861e-023f, 1.8062879733f, 0.088137828247f, 0.0043109620947f, 0.00021187222805f, 1.0489238301e-005f, 5.2446191507e-007f, 2.6557161397e-008f, 1.3659529897e-009f, 7.1595390337e-011f, 3.8379157708e-012f, 2.1127030986e-013f, 1.1999347271e-014f, 7.0706831878e-016f, 4.3517046791e-017f, 2.8207911768e-018f, 1.9465308412e-019f, 1.4508584271e-020f, 1.1925982807e-021f, 1.1169706286e-022f, 1.2647201906e-023f, 1.9996982025e-024f, 1.8498192293f, 0.08606137925f, 0.0040126324977f, 0.00018790873322f, 8.8581026337e-006f, 4.2133697531e-007f, 2.0271584676e-008f, 9.8915204822e-010f, 4.9090791891e-011f, 2.4858088755e-012f, 1.2888318631e-013f, 6.8694969119e-015f, 3.7815335923e-016f, 2.1617588692e-017f, 1.2918980235e-018f, 8.1381925936e-020f, 5.4619972377e-021f, 3.9625492741e-022f, 3.1725784981e-023f, 2.8961546815e-024f, 3.1982678122e-025f, 4.935034375e-026f, 1.8923493652f, 0.084125190447f, 0.0037472338125f, 0.00016758139065f, 7.539843222e-006f, 3.4201423397e-007f, 1.5676196712e-008f, 7.2774916245e-010f, 3.4306424518e-011f, 1.6467610741e-012f, 8.0739104336e-014f, 4.0572926514e-015f, 2.0979760847e-016f, 1.1214153878e-017f, 6.2300854879e-019f, 3.6211636357e-020f, 2.2202778798e-021f, 1.4514410557e-022f, 1.026323813e-023f, 8.0142425394e-025f, 7.1396547136e-026f, 7.6988876748e-027f, 1.1606509873e-027f, 1.9339444301f, 0.082314141311f, 0.0035098867787f, 0.00015020928745f, 6.4639785415e-006f, 2.8024901181e-007f, 1.2266166018e-008f, 5.4315496068e-010f, 2.438837769e-011f, 1.1131720502e-012f, 5.1789450806e-014f, 2.4633729657e-015f, 1.2020029285e-016f, 6.0402919859e-018f, 3.1401982755e-019f, 1.6980247563e-020f, 9.6131721747e-022f, 5.7449692048e-023f, 3.6628585823e-024f, 2.5276125564e-025f, 1.927286506e-026f, 1.6774875866e-027f, 1.7682271734e-028f, 2.6071087338e-029f, 1.9746635149f, 0.080615300422f, 0.0032966047858f, 0.00013526133275f, 5.5780833482e-006f, 2.3161730416e-007f, 9.7013813075e-009f, 4.1069221938e-010f, 1.7608283638e-011f, 7.6630218528e-013f, 3.3932431105e-014f, 1.5329109834e-015f, 7.0858835275e-017f, 3.3628115035e-018f, 1.6448048712e-019f, 8.328793221e-021f, 4.3896594565e-022f, 2.4237839636e-023f, 1.4135795137e-024f, 8.8005616488e-026f, 5.9333374532e-027f, 4.4224486263e-028f, 3.7646382751e-029f, 3.8829279014e-030f, 5.6045236728e-031f, 2.0145597375f, 0.079017533944f, 0.0031041018936f, 0.00012231875022f, 4.842645695e-006f, 1.9293562265e-007f, 7.7484810674e-009f, 3.1424240259e-010f, 1.2893521955e-011f, 5.362998122e-013f, 2.2662803405e-014f, 9.7525177961e-016f, 4.2850103139e-017f, 1.9279172853e-018f, 8.9118008037e-020f, 4.2485343345e-021f, 2.0982015523e-022f, 1.0791984281e-023f, 5.8186479667e-025f, 3.3154823825e-026f, 2.0177383221e-027f, 1.33045725e-028f, 9.7033567732e-030f, 8.0861306443e-031f, 8.1682254459e-032f, 1.1551615206e-032f, 2.0536810547f, 0.077511196458f, 0.0029296478521f, 0.00011104801525f, 4.2275256908e-006f, 1.618803252e-007f, 6.2446691179e-009f, 2.4307341574e-010f, 9.5635956295e-012f, 3.8102277015e-013f, 1.5401932619e-014f, 6.3301553126e-016f, 2.6514102928e-017f, 1.1346988547e-018f, 4.9759836503e-020f, 2.24334668e-021f, 1.0436993321e-022f, 5.0331651141e-024f, 2.5292606351e-025f, 1.3330374005e-026f, 7.4287269985e-028f, 4.4237425515e-029f, 2.8555135383e-030f, 2.0396525274e-031f, 1.6653693149e-032f, 1.6489613353e-033f, 2.2866979406e-034f, 2.0920709389f, 0.076087884417f, 0.0027709573165f, 0.00010118105521f, 3.7094774603e-006f, 1.3673315326e-007f, 5.074643279e-009f, 1.8991375165e-010f, 7.178065106e-012f, 2.7446017901e-013f, 1.0635115913e-014f, 4.1843303907e-016f, 1.6750727509e-017f, 6.8384558696e-019f, 2.8543163317e-020f, 1.2215346231e-021f, 5.3775063301e-023f, 2.4443210591e-024f, 1.1522639975e-025f, 5.6630685934e-027f, 2.9205046332e-028f, 1.5932658987e-029f, 9.2921154198e-031f, 5.8768498016e-032f, 4.114617867e-033f, 3.2943308133e-034f, 3.1997369449e-035f, 4.3542904589e-036f, 2.1297689433f, 0.074740237775f, 0.0026261042693f, 9.2500577646e-005f, 3.2703892858e-006f, 1.1620822308e-007f, 4.1555975734e-009f, 1.4975734135e-010f, 5.4466218462e-012f, 2.0022180112e-013f, 7.4514838584e-015f, 2.8123813477e-016f, 1.0784990145e-017f, 4.2108312072e-019f, 1.6776353093e-020f, 6.8375310661e-022f, 2.8589153611e-023f, 1.2302812869e-024f, 5.4692674337e-026f, 2.5227849463e-027f, 1.2137754732e-028f, 6.1304919139e-030f, 3.2768857649e-031f, 1.8732709079e-032f, 1.1617532993e-033f, 7.9789544184e-035f, 6.26885864e-036f, 5.9771221905e-037f, 7.9872654985e-038f, 2.1668111802f, 0.073461779026f, 0.002493455253f, 8.4829070365e-005f, 2.896016712e-006f, 9.9332553731e-008f, 3.4272987126e-009f, 1.1910686381e-010f, 4.1746934161e-012f, 1.4778254497e-013f, 5.291463929e-015f, 1.9194157044e-016f, 7.0654668469e-018f, 2.6441845117e-019f, 1.0080858943e-020f, 3.9239690218e-022f, 1.563346679e-023f, 6.3929999849e-025f, 2.6919386093e-026f, 1.1715159077e-027f, 5.2923694051e-029f, 2.4948468632e-030f, 1.2351332459e-031f, 6.4738572649e-033f, 3.6303588837e-034f, 2.2093660583e-035f, 1.4895542926e-036f, 1.1492160865e-037f, 1.0763394811e-038f, 1.4133029781e-039f, 2.2032307254f, 0.072246781595f, 0.0023716167942f, 7.8020464477e-005f, 2.5750590401e-006f, 8.5362375968e-008f, 2.8454125323e-009f, 9.548579253e-011f, 3.229855112e-012f, 1.1026543544e-013f, 3.8045189691e-015f, 1.3285956544e-016f, 4.7031776345e-018f, 1.6905222907e-019f, 6.1811616677e-021f, 2.3035829448e-022f, 8.7695903955e-024f, 3.4187422745e-025f, 1.3685922219e-026f, 5.6439791979e-028f, 2.4066008162e-029f, 1.0656607532e-030f, 4.9260185742e-032f, 2.3922860994e-033f, 1.2304591974e-034f, 6.7734549537e-036f, 4.0479135724e-037f, 2.6807962526e-038f, 2.0323063943e-039f, 1.8708896824e-040f, 2.4153081942e-041f, 2.2390579644f, 0.071090161459f, 0.0022593936472f, 7.1953752141e-005f, 2.2984783003e-006f, 7.3723725857e-008f, 2.3769483209e-009f, 7.7118386915e-011f, 2.5206933316e-012f, 8.3104798115e-014f, 2.7670871021e-015f, 9.3172669241e-017f, 3.1771616508e-018f, 1.0988443339e-019f, 3.8609454325e-021f, 1.3806712679e-022f, 5.0347900687e-024f, 1.8763554744e-025f, 7.1639584907e-027f, 2.809935703e-028f, 1.1358491867e-029f, 4.7492240348e-031f, 2.0629310954e-032f, 9.3576454782e-034f, 4.4610824434e-035f, 2.2531868908e-036f, 1.2183839317e-037f, 7.1545967982e-039f, 4.6572458283e-040f, 3.4713060867e-041f, 3.142772863e-042f, 3.9913255273e-043f, };*/ inline float factorial(const int x){ float f = 1.0f; for (int i = 2; i <= x; i++){ f *= i; } return f; // return f[x]; } float P(const int l, const int m, const float x){ float pmm = 1.0f; if (m > 0){ float somx2 = sqrtf((1.0f - x) * (1.0f + x)); float fact = 1.0f; for (int i = 1; i <= m; i++){ pmm *= (-fact) * somx2; fact += 2.0f; } } if (l == m) return pmm; float pmmp1 = x * (2.0f * m + 1.0f) * pmm; if (l == m + 1) return pmmp1; float pll = 0.0f; for (int ll = m + 2; ll <= l; ll++){ pll = ((2.0f * ll - 1.0f) * x * pmmp1 - (ll + m - 1.0f) * pmm) / (ll - m); pmm = pmmp1; pmmp1 = pll; } return pll; } float Pm0(const int l, const float x){ if (l == 0) return 1.0f; if (l == 1) return x; float pmm = 1.0f; float pmmp1 = x; float pll; float f = 1.0f; for (float ll = 2; ll <= l; ll++){ f += 2.0f; pll = (f * x * pmmp1 - (ll - 1.0f) * pmm) / ll; pmm = pmmp1; pmmp1 = pll; } return pll; } float PmX(const int l, const int m, const float x, float pmm0){ if (l == m) return pmm0; float f = float(2 * m + 1); float pmmp1 = f * x * pmm0; if (l == m + 1) return pmmp1; float pll; float d = 2.0f; float f2 = float(2 * m); for (float ll = float(m + 2); ll <= l; ll++){ f += 2.0f; f2++; pll = (f * x * pmmp1 - f2 * pmm0) / d; pmm0 = pmmp1; pmmp1 = pll; d++; } return pll; } float P2(const int l, const int m, const float x){ float pmm = 1.0f; if (m > 0){ float somx2 = sqrtf(1.0f - x * x); float fact = -1.0f; for (int i = 1; i <= m; i++){ pmm *= fact * somx2; fact -= 2.0f; } /* for (int i = 1; i <= m; i++){ pmm *= somx2; } pmm *= f2[m]; */ //pmm *= powf(somx2, m); } if (l == m) return pmm; float pmmp1 = x * (2.0f * m + 1.0f) * pmm; if (l == m + 1) return pmmp1; float pll; for (int ll = m + 2; ll <= l; ll++){ pll = ((2.0f * ll - 1.0f) * x * pmmp1 - (ll + m - 1.0f) * pmm) / (ll - m); pmm = pmmp1; pmmp1 = pll; } return pll; } float K(const int l, const int m){ // renormalisation constant for SH function float temp = ((2.0f * l + 1.0f) * factorial(l - m)) / (4.0f * PI * factorial(l + m)); return sqrtf(temp); } inline float K2(const int l, const int m){ return (float) kTab[((l * (l + 1)) >> 1) + m]; } // return a point sample of a Spherical Harmonic basis function // l is the band, range [0..N] // m in the range [-l..l] // theta in the range [0..Pi] // phi in the range [0..2*Pi] float SH(const int l, const int m, const float theta, const float phi){ const float sqrt2 = sqrtf(2.0f); if (m == 0) return K(l, 0) * P(l, m, cosf(theta)); else if (m > 0) return sqrt2 * K(l, m) * cosf(m * phi) * P(l, m, cosf(theta)); else return sqrt2 * K(l, -m) * sinf(-m * phi) * P(l, -m, cosf(theta)); } float SH2(const int l, const int m, const float cosTheta, const float scPhi){ const int m2 = abs(m); float k = K2(l, m2) * P2(l, m2, cosTheta); if (m == 0) return k; return k * scPhi; } float SH(const int l, const int m, const float3 &pos){ float len = length(pos); float p = atan2f(pos.z, pos.x); // float t = PI / 2 - asinf(pos.y / len); float t = acosf(pos.y / len); return SH(l, m, t, p); } float SH_A(const int l, const int m, const float3 &pos){ float d = dot(pos, pos); float len = sqrtf(d); float p = atan2f(pos.z, pos.x); float t = acosf(pos.y / len); return SH(l, m, t, p) * powf(d, -1.5f); } float SH_A2_pos(const int l, const int m, const float3 &pos){ float dxz = pos.x * pos.x + pos.z * pos.z; // float d = dot(pos, pos); float d = dxz + pos.y * pos.y; float len = sqrtf(d); // float p = atan2f(pos.z, pos.x); float t = pos.y / len; // float cp = cosf(p); // float sp = sinf(p); float xzLenInv = 1.0f / sqrtf(dxz); float cp = pos.x * xzLenInv; float sp = pos.z * xzLenInv; float c = (float) sqrt2; float s = 0.0f; for (int i = 0; i < m; i++){ float ssp = s * sp; float csp = c * sp; c = c * cp - ssp; s = s * cp + csp; } float scPhi = c; // float scPhi = cosf(m * p); return SH2(l, m, t, scPhi) * powf(d, -1.5f); } float SH_A2_neg(const int l, const int m, const float3 &pos){ /* float d = dot(pos, pos); float len = sqrtf(d); float p = atan2f(pos.z, pos.x); float t = pos.y / len; */ float dxz = pos.x * pos.x + pos.z * pos.z; float d = dxz + pos.y * pos.y; float len = sqrtf(d); float t = pos.y / len; float xzLenInv = 1.0f / sqrtf(dxz); float cp = pos.x * xzLenInv; float sp = pos.z * xzLenInv; float c = (float) sqrt2; float s = 0.0f; for (int i = 0; i < m; i++){ float ssp = s * sp; float csp = c * sp; c = c * cp - ssp; s = s * cp + csp; } // float scPhi = sinf(m * p); float scPhi = s; return SH2(l, m, t, scPhi) * powf(d, -1.5f); } float SH_A2(const int l, const int m, const float3 &pos){ if (m >= 0) return SH_A2_pos(l, m, pos); else return SH_A2_neg(l, -m, pos); } template <typename FLOAT> bool cubemapToSH(FLOAT *dst, const Image &img, const int bands){ if (!img.isCube()) return false; FORMAT format = img.getFormat(); if (format < FORMAT_I32F || format > FORMAT_RGBA32F) return false; int size = img.getWidth(); int sliceSize = img.getSliceSize(); int nCoeffs = bands * bands; float *coeffs = new float[nCoeffs]; for (int i = 0; i < nCoeffs; i++){ dst[i] = 0; } float3 v; float *src = (float *) img.getPixels(); for (v.x = 1; v.x >= -1; v.x -= 2){ for (int y = 0; y < size; y++){ for (int z = 0; z < size; z++){ v.y = 1 - 2 * float(y + 0.5f) / size; v.z = (1 - 2 * float(z + 0.5f) / size) * v.x; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } for (v.y = 1; v.y >= -1; v.y -= 2){ for (int z = 0; z < size; z++){ for (int x = 0; x < size; x++){ v.x = 2 * float(x + 0.5f) / size - 1; v.z = (2 * float(z + 0.5f) / size - 1) * v.y; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } for (v.z = 1; v.z >= -1; v.z -= 2){ for (int y = 0; y < size; y++){ for (int x = 0; x < size; x++){ v.x = (2 * float(x + 0.5f) / size - 1) * v.z; v.y = 1 - 2 * float(y + 0.5f) / size; computeSHCoefficients(coeffs, bands, v, true); float v = *src++; for (int i = 0; i < nCoeffs; i++){ dst[i] += v * coeffs[i]; } } } } delete coeffs; float normFactor = 1.0f / (6 * size * size); for (int i = 0; i < nCoeffs; i++){ dst[i] *= normFactor; } return true; } template <typename FLOAT> bool shToCubemap(Image &img, const int size, const FLOAT *src, const int bands){ img.create(FORMAT_I32F, size, size, 0, 1); int sliceSize = img.getSliceSize(); // memset(img.getPixels(), 0, 6 * sliceSize); int nCoeffs = bands * bands; FLOAT *coeffs = new FLOAT[nCoeffs]; float *dst = (float *) (img.getPixels()); FLOAT scale = 1.0f; float3 v; for (v.x = 1; v.x >= -1; v.x -= 2){ for (int y = 0; y < size; y++){ for (int z = 0; z < size; z++){ v.y = 1 - 2 * float(y + 0.5f) / size; v.z = (1 - 2 * float(z + 0.5f) / size) * v.x; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } for (v.y = 1; v.y >= -1; v.y -= 2){ for (int z = 0; z < size; z++){ for (int x = 0; x < size; x++){ v.x = 2 * float(x + 0.5f) / size - 1; v.z = (2 * float(z + 0.5f) / size - 1) * v.y; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } for (v.z = 1; v.z >= -1; v.z -= 2){ for (int y = 0; y < size; y++){ for (int x = 0; x < size; x++){ v.x = (2 * float(x + 0.5f) / size - 1) * v.z; v.y = 1 - 2 * float(y + 0.5f) / size; computeSHCoefficients(coeffs, bands, v, false); FLOAT v = 0; for (int i = 0; i < nCoeffs; i++){ v += src[i] * coeffs[i]; } *dst++ = float(v * scale); } } } delete coeffs; return true; } template <typename FLOAT> void computeSHCoefficients(FLOAT *dest, const int bands, const float3 &pos, const bool fade){ FLOAT dxz = pos.x * pos.x + pos.z * pos.z; FLOAT dxyz = dxz + pos.y * pos.y; FLOAT xzLen = sqrt(dxz); FLOAT xyzLen = sqrt(dxyz); FLOAT xzLenInv = 1.0f / xzLen; FLOAT xyzLenInv = 1.0f / xyzLen; FLOAT ct = pos.y * xyzLenInv; FLOAT st = xzLen * xyzLenInv; FLOAT cp = pos.x * xzLenInv; FLOAT sp = pos.z * xzLenInv; // FLOAT a = powf(xyzLen, -3.0f); // FLOAT a = 1.0f / (dxyz * xyzLen); FLOAT a = fade? xyzLenInv * xyzLenInv * xyzLenInv : 1; if (bands > 0) dest[0] = FLOAT(kTab[0] * a * REDIST_FACTOR); if (bands > 1) dest[2] = FLOAT(kTab[1] * a * REDIST_FACTOR * ct); FLOAT pmm0 = FLOAT(1.0 * REDIST_FACTOR); FLOAT pmm1 = FLOAT(ct * REDIST_FACTOR); for (int l = 2; l < bands; l++){ int i = l * (l + 1); // FLOAT pll = ((2 * l - 1) * ct * pmm1 - (l - 1) * pmm0) * rcp[l]; FLOAT pll = FLOAT(ct * pmm1 * fTab[i] - pmm0 * fTab[i + 1]); pmm0 = pmm1; pmm1 = pll; dest[i] = FLOAT(kTab[i >> 1] * pll * a); } FLOAT c = FLOAT(sqrt2 * a); // Start with sqrtf(2) * a instead of 1.0 so that it's baked into sin & cos values below FLOAT s = 0; double pmm = double(1.0 * REDIST_FACTOR); // FLOAT fact = -1; for (int m = 1; m < bands; m++){ // Compute cos(m * phi) and sin(m * phi) iteratively from initial cos(phi) and sin(phi) FLOAT ssp = s * sp; FLOAT csp = c * sp; c = c * cp - ssp; s = s * cp + csp; pmm *= /*fact * */st; // fact -= 2; FLOAT pmm0 = (FLOAT) pmm; FLOAT f0 = FLOAT(2 * m + 1); FLOAT pmm1; FLOAT kp = FLOAT(kTab[((m * (m + 1)) >> 1) + m] * pmm0); dest[m * m ] = kp * s; dest[m * m + 2 * m] = kp * c; if (m + 1 < bands){ pmm1 = f0 * ct * pmm0; FLOAT kp = FLOAT(kTab[(m * m + 5 * m + 2) >> 1] * pmm1); dest[m * m + 2 * m + 2] = kp * s; dest[m * m + 4 * m + 2] = kp * c; } int index = 2; for (int l = m + 2; l < bands; l++){ // f0 += 2.0f; // f1++; // FLOAT pll = (f0 * ct * pmm1 - f1 * pmm0) * rcp[index++]; int it = l * (l + 1) + 2 * m; FLOAT pll = FLOAT(ct * pmm1 * fTab[it] - pmm0 * fTab[it + 1]); pmm0 = pmm1; pmm1 = pll; // pmm1 = (2 * m - 5) * ct * pmm1; // FLOAT pll = pmm1; int i = l * (l + 1); FLOAT kp = FLOAT(kTab[(i >> 1) + m] * pll); dest[i + m] = kp * c; dest[i - m] = kp * s; } } } template bool cubemapToSH(float *dst, const Image &img, const int bands); template bool shToCubemap(Image &img, const int size, const float *src, const int bands); template bool cubemapToSH(double *dst, const Image &img, const int bands); template bool shToCubemap(Image &img, const int size, const double *src, const int bands);
[ "dtrebilco@gmail.com" ]
dtrebilco@gmail.com
e803acdb2294fc1410d222ed47d8dcbe2ab78515
77222f794141f3018763c071d48e38dfd7252246
/src/soundbuffer.cpp
f6cf062f60732579b1222d0a20bca728b29b07aa
[ "Zlib", "BSD-3-Clause", "MIT", "FTL", "LicenseRef-scancode-happy-bunny", "LicenseRef-scancode-warranty-disclaimer", "BSL-1.0", "SGI-B-2.0", "LicenseRef-scancode-synthesis-toolkit", "LicenseRef-scancode-khronos" ]
permissive
dakodun/uair
c3101ee83d5f89b688feef8c5fe6b7ff67c78ab2
a2a6ed6c13e796937c06f2731146e85185680e69
refs/heads/master
2021-11-28T10:38:18.194923
2021-11-13T22:17:05
2021-11-13T22:17:05
18,681,066
0
0
null
null
null
null
UTF-8
C++
false
false
2,361
cpp
/* **************************************************************** ** ** Uair Engine ** Copyright (c) 2010 - 2017, Iain M. Crawford ** ** This software is provided 'as-is', without any express or ** implied warranty. In no event will the authors be held liable ** for any damages arising from the use of this software. ** ** Permission is granted to anyone to use this software for any ** purpose, including commercial applications, and to alter it ** and redistribute it freely, subject to the following ** restrictions: ** ** 1. The origin of this software must not be misrepresented; ** you must not claim that you wrote the original ** software. If you use this software in a product, an ** acknowledgment in the product documentation would be ** appreciated but is not required. ** ** 2. Altered source versions must be plainly marked as such, ** and must not be misrepresented as being the original ** software. ** ** 3. This notice may not be removed or altered from any ** source distribution. ** **************************************************************** */ #include "soundbuffer.hpp" namespace uair { SoundBuffer::SoundBuffer(SoundBuffer&& other) : SoundBuffer() { swap(*this, other); } SoundBuffer::~SoundBuffer() { } SoundBuffer& SoundBuffer::operator=(SoundBuffer other) { swap(*this, other); return *this; } void swap(SoundBuffer& first, SoundBuffer& second) { using std::swap; swap(first.mSampleData, second.mSampleData); swap(first.mNumChannels, second.mNumChannels); } void SoundBuffer::LoadFromFile(const std::string& filename) { using namespace std::placeholders; std::ifstream oggFile(filename.c_str(), std::ios::in | std::ios::binary); // open the ogg file on disk SoundLoaderOgg slo; slo.Decode(oggFile, std::bind(&SoundBuffer::DecoderCallback, this, _1, _2, _3, _4)); // decode the entire ogg file } unsigned int SoundBuffer::GetTypeID() { return static_cast<unsigned int>(Resources::SoundBuffer); } int SoundBuffer::DecoderCallback(const int& serial, const int& numChannels, const int& numSamples, std::vector<int>& samples) { mSampleData.insert(mSampleData.end(), samples.begin(), samples.end()); // add the samples into the array mNumChannels = numChannels; // set the number of channels return numSamples; // return the number of samples used (all of them) } }
[ "github@chikin.net" ]
github@chikin.net
4493f84051a862b7a4b6422ec4753feeb3476e6d
898d9b3afbb20aa1354873ef1314760732bfc7d0
/avenue/server_connection.cpp
8f0cdddcf596ae2cd7afd8a5bcb6c9055e40407b
[ "MIT" ]
permissive
Aiyowoo/im
cafc74b119f85f09a857e369fff8c6b371c7b86c
d510275d1cc83b2748cb675e99dacbbf04616fb5
refs/heads/master
2020-05-07T19:13:16.772434
2019-05-08T16:12:05
2019-05-08T16:12:05
180,802,881
0
0
null
null
null
null
GB18030
C++
false
false
1,557
cpp
// server_connection.cpp // Created by m8792 on 2019/4/24. // 2019/4/24 22:17 #include "server_connection.hpp" #include "details/log_helper.hpp" namespace asio = boost::asio; namespace ssl = boost::asio::ssl; namespace avenue { server_connection::server_connection(boost::asio::ip::tcp::socket &socket, boost::asio::ssl::context &ssl_context) : message_connection(socket, ssl_context) { } void server_connection::run() { INFO_LOG("start to run..."); set_running(true); stream().async_handshake(ssl::stream_base::handshake_type::server, [this, self = shared_from_base()](boost::system::error_code ec) { if (ec) { status s(ec.value(), fmt::format("failed to handshake with client due to error[{}]", ec.message())); handle_initialize_error(s); return; } initialize(); }); } std::shared_ptr<server_connection> server_connection::shared_from_base() { return std::dynamic_pointer_cast<server_connection>(shared_from_this()); } void server_connection::handle_initialize_error(const status& error) { // 已经不再运行了 set_running(false); // fixme: 是否需要关闭socket连接 on_initialized(error); } }
[ "m879224490@qq.com" ]
m879224490@qq.com
41c9e858b3f9a48f4d3b1ad829d66b9ef806a405
dfd960b9c39ab30680774f9e6204ef9c58054798
/CPP/复数类latest.cpp
760566d59208f4f49a90d826931d467f85a12510
[]
no_license
yuyuOWO/source-code
09e0025672169e72cbd493a13664b35a0d2480aa
d4972f4d807ddf8e17fd074c0568f2ec5aba2bfe
refs/heads/master
2021-06-15T22:32:08.325223
2017-05-04T05:44:36
2017-05-04T05:44:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,345
cpp
#include <iostream> using namespace std; class Complex { public: Complex(double a = 0, double b = 0): Real(a), Imag(b){} ~Complex(){} friend ostream & operator<<(ostream &os, const Complex t) { os << "(" << t.Real << "," << t.Imag << "!)"; return os; } friend istream & operator>>(istream &is, Complex &t) { is >> t.Real >> t.Imag; return is; } friend Complex operator+(Complex a, Complex b) { /**************************** Complex tmp; tmp.Real = a.Real + b.Real; tmp.Real = a.Imag + a.Imag; return tmp; *****************************/ return Complex(a.Real + b.Real, a.Imag + b.Imag); } friend Complex operator-(Complex a, Complex b) { /**************************** Complex tmp; tmp.Real = a.Real - b.Real; tmp.Real = a.Imag - a.Imag; return tmp; *****************************/ return Complex(a.Real - b.Real, a.Imag - b.Imag); } Complex operator=(Complex a) { return Complex(Real = a.Real, Imag = a.Imag); } private: double Real, Imag; }; int main(int argc, char const *argv[]) { Complex a, b, c; cin >> a >> b; c = a; cout << "a = " << a << " " << "b = " << b << endl; cout << "c = " << c << endl; cout << "a + b = " << a + b << endl; cout << "a + 23.32 = " << a + 23.32 << endl; cout << "200 + b = " << 200 + b << endl; cout << "a - b = " << a - b << endl; return 0; }
[ "xanarry@163.com" ]
xanarry@163.com
86c9a0c29e0a927b054f6f09bc2ff427d5c3d419
11e6ec185672c57bb5f80955f001f42731768c73
/Source/BuildingEscape/OpenDoor.h
ac9d413900a980835feec92212b6372c57d01e7e
[]
no_license
Zagorouiko/BuildingEscape
d122fd9d6beca6c1373764844a829107ad383f10
baef29a3bb6561c9d5e8c4e29c01e19e863397ee
refs/heads/master
2020-04-22T18:15:04.301177
2019-02-17T14:37:41
2019-02-17T14:37:41
170,570,823
0
0
null
null
null
null
UTF-8
C++
false
false
792
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "Components/ActorComponent.h" #include "Engine/TriggerVolume.h" #include "OpenDoor.generated.h" UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class BUILDINGESCAPE_API UOpenDoor : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UOpenDoor(); protected: // Called when the game starts virtual void BeginPlay() override; public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; private: UPROPERTY(VisibleAnywhere) float OpenAngle = 90.0f; UPROPERTY(EditAnywhere) ATriggerVolume* PressurePlate; };
[ "Zagorouiko@gmail.com" ]
Zagorouiko@gmail.com
d10bebe69c3a50eb40de190598629544bca6dd08
99ca9bb6ac36daf7ae528f971e94ad0daf8b03ca
/pi0/ERAlgoJeremyPi0.cxx
29845a6cdcee1977f8f12b378137efa65d960494
[]
no_license
jhewes15/ngamma
fc121295e2ee1366a901360fd2f57f51228efad6
f31b0a31c6464480e5d52d95b5ee917be57a18fb
refs/heads/master
2020-06-05T08:29:47.184869
2015-07-22T18:04:12
2015-07-22T18:04:12
39,088,036
0
0
null
null
null
null
UTF-8
C++
false
false
3,643
cxx
#ifndef ERTOOL_ERALGOJEREMYPI0_CXX #define ERTOOL_ERALGOJEREMYPI0_CXX #include "ERAlgoJeremyPi0.h" namespace ertool { ERAlgoJeremyPi0::ERAlgoJeremyPi0(const std::string& name) : AlgoBase(name) { _name = name; _nGamma = new NGammaBase(); } void ERAlgoJeremyPi0::Reset() {} void ERAlgoJeremyPi0::AcceptPSet(const ::fcllite::PSet& cfg) { // get external parameters if not training PDFs if (!_trainingMode) { auto ngamma_pset = cfg.get_pset(_name); _nGamma->AcceptPSet(ngamma_pset); } } void ERAlgoJeremyPi0::ProcessBegin() {} bool ERAlgoJeremyPi0::Reconstruct(const EventData &data, ParticleGraph& graph) { // first case: training pdfs! if (_trainingMode) { auto nodes = graph.GetParticleNodes(RecoType_t::kShower, 0, 22); if (nodes.size() == 2) { // get the two gamma shower particles auto particle1 = graph.GetParticle(nodes[0]); auto particle2 = graph.GetParticle(nodes[1]); // calculate angle between showers double angle = particle1.Momentum().Angle(particle2.Momentum()); // calculate invariant mass double invMass = sqrt(2 * particle1.Energy() * particle2.Energy() * (1 - cos(angle))); // make sure energies are above a certain threshold if (invMass < 300) { // add to PDF _nGamma->FillMassPdf(invMass); } } } // second case: using pdfs to make selection! else { // score all possible combinations of gammas CombinationScoreSet_t candidates = _nGamma->GammaComparison(graph, 2); // select the best candidates as pi0s CombinationScoreSet_t event = _nGamma->EventSelection(candidates, _cut); // add the pi0s to the particle graph, then check it worked properly AddPi0s(graph, event); } return true; } void ERAlgoJeremyPi0::ProcessEnd(TFile* fout) { // if in training mode, save the trained parameters for future use if (_trainingMode) { auto& params = OutputPSet(); params.add_pset(_nGamma->GetParams()); } } // ****************** // // **** ADD PI0S **** // // ****************** // void ERAlgoJeremyPi0::AddPi0s(ParticleGraph &graph, CombinationScoreSet_t particles) { // this comes in useful later: int pdg_pi0 = 111; // loop over each identified pi0 for (auto const& particle : particles) { // get ids of two gamma showers double gamma1_id = particle.first[0]; double gamma2_id = particle.first[1]; // get pointers to two gamma showers Particle *gamma1 = &(graph.GetParticle(gamma1_id)); Particle *gamma2 = &(graph.GetParticle(gamma2_id)); // identify them as siblings (which creates "parent" object if it doesn't exist already) graph.SetSiblings(gamma1_id, gamma2_id, particle.second); // get id of parent object double parent_id = gamma1->Parent(); // get a pointer to the parent object Particle *parent = &(graph.GetParticle(parent_id)); // figure out the pi0's information geoalgo::Vector X (( gamma1->Vertex()[0] + gamma2->Vertex()[0]) /2, (gamma1->Vertex()[1] + gamma2->Vertex()[1]) /2, (gamma1->Vertex()[2] + gamma2->Vertex()[2]) /2 ); geoalgo::Vector P ( gamma1->Momentum()[0] + gamma2->Momentum()[0], gamma1->Momentum()[1] + gamma2->Momentum()[1], gamma1->Momentum()[2] + gamma2->Momentum()[2] ); parent->SetParticleInfo(pdg_pi0, ParticleMass(pdg_pi0), X, P, particle.second); } } } #endif
[ "jeremy.hewes@manchester.ac.uk" ]
jeremy.hewes@manchester.ac.uk
c5ad784120061b33d38be0cfed15aff55f57f342
b367fe5f0c2c50846b002b59472c50453e1629bc
/xbox_leak_may_2020/xbox trunk/xbox/private/ui/xapp/cdda.cpp
e567984ba410e6154a688265aaabe095167bfeaa
[]
no_license
sgzwiz/xbox_leak_may_2020
11b441502a659c8da8a1aa199f89f6236dd59325
fd00b4b3b2abb1ea6ef9ac64b755419741a3af00
refs/heads/master
2022-12-23T16:14:54.706755
2020-09-27T18:24:48
2020-09-27T18:24:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,204
cpp
#include "std.h" #include "xapp.h" #include "cdda.h" //////////////////////////////////////////////////////////////////////////// CCDDAStreamer::CCDDAStreamer(CNtIoctlCdromService* pDrive, DWORD dwRetries) { ASSERT(pDrive != NULL); m_ibChunk = 0; m_pDrive = pDrive; m_dwRetries = dwRetries; m_dwCurFrame = 0; m_chunk = (BYTE *)XPhysicalAlloc(CDDA_BUFFER_SIZE, -1, 0, PAGE_READWRITE); } CCDDAStreamer::~CCDDAStreamer() { if (m_chunk) XPhysicalFree(m_chunk); } int CCDDAStreamer::ReadFrames(void* pvBuffer, DWORD nFrameCount) { #ifdef _DEBUG const DWORD dwStartTime = GetTickCount(); #endif DWORD nTotalFrames = m_pDrive->GetTrackFrame(m_pDrive->GetTrackCount()); nFrameCount = min(nFrameCount, nTotalFrames - m_dwCurFrame); ASSERT((int)nFrameCount > 0); HRESULT hr = m_pDrive->Read(m_dwCurFrame, nFrameCount, pvBuffer, m_dwRetries); if (FAILED(hr)) { ZeroMemory(pvBuffer, nFrameCount * CDAUDIO_BYTES_PER_FRAME); if (hr != HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER)) { return -1; } else { // REVIEW: we probably hit end of the disc but need better way to detect this return 0; } } #ifdef _DEBUG const DWORD dwEndTime = GetTickCount(); if(dwEndTime - dwStartTime >= nFrameCount * 1000 / CDAUDIO_FRAMES_PER_SECOND) { TRACE(_T("\001CCDDAStreamer: read of frames %lu through %lu took longer than real-time (%lu ms)\n"), m_dwCurFrame, m_dwCurFrame + nFrameCount - 1, dwEndTime - dwStartTime); } #endif m_dwCurFrame += nFrameCount; return nFrameCount * CDAUDIO_BYTES_PER_FRAME; } int CCDDAStreamer::Read(void* pvBuffer, int cbWanted) { BYTE *pbBuffer = (BYTE *)pvBuffer; int cbRead; if (!m_chunk) return -1; if (m_ibChunk) { cbRead = min(cbWanted, CDDA_BUFFER_SIZE - m_ibChunk); CopyMemory(pbBuffer, m_chunk + m_ibChunk, cbRead); m_ibChunk += cbRead; m_ibChunk %= CDDA_BUFFER_SIZE; cbWanted -= cbRead; pbBuffer += cbRead; } while (cbWanted >= CDDA_MAX_FRAMES_PER_READ * CDAUDIO_BYTES_PER_FRAME) { cbRead = ReadFrames(pbBuffer, CDDA_MAX_FRAMES_PER_READ); if (cbRead <= 0) return cbRead; cbWanted -= cbRead; pbBuffer += cbRead; } while (cbWanted >= CDDA_BUFFER_SIZE) { cbRead = ReadFrames(pbBuffer, CDDA_BUFFER_SIZE / CDAUDIO_BYTES_PER_FRAME); if (cbRead <= 0) return cbRead; cbWanted -= cbRead; pbBuffer += cbRead; } if (cbWanted) { cbRead = ReadFrames(m_chunk, CDDA_BUFFER_SIZE / CDAUDIO_BYTES_PER_FRAME); if (cbRead <= 0) return cbRead; if (cbRead < CDDA_BUFFER_SIZE) ZeroMemory(m_chunk + cbRead, CDDA_BUFFER_SIZE - cbRead); m_ibChunk = cbWanted; cbRead = min(cbRead, cbWanted); CopyMemory(pbBuffer, m_chunk, cbRead); cbWanted -= cbRead; pbBuffer += cbRead; } return pbBuffer - (LPBYTE)pvBuffer; }
[ "benjamin.barratt@icloud.com" ]
benjamin.barratt@icloud.com
8f7dde38a5c99c6afcfc4d3d26627c4b65a2d688
237af8f87b8fd71635ff57e9d1657a16e06dcb35
/KnightRiderScanBar.ino
cd4a5c116283a7a8e677c325a4781ccab8c791fa
[]
no_license
erichilarysmithsr/KnightRiderScanBar
814db6c16b6822115204b188b35829312e4cb6f1
72717aab55fd7a6d0b06ddac21aa65a6dadd4263
refs/heads/master
2021-01-21T02:49:40.808396
2014-08-11T15:29:06
2014-08-11T15:29:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,455
ino
#include "LPD8806.h" #include "SPI.h" // Knight Rider KITT and KARR scan bar (light chaser). // Uses a 1 metre Adafruit digital RGB LED strip with an LPD8806 chip. // http://www.adafruit.com/products/306 /*****************************************************************************/ // Number of RGB LEDs in strand: int nLEDs = 32; int dataPin = 2; int clockPin = 3; LPD8806 strip = LPD8806(nLEDs, dataPin, clockPin); void setup() { strip.begin(); // Update the strip, to start they are all 'off' strip.show(); } void scanBar(uint32_t (*getColor)(byte)) { int tail = 7; for(int i=0; i<(int)strip.numPixels()+tail; i++) { for(int j=0; j<=i; j++) { int diff = min(tail, abs(j-i)); int brightness = (128 >> diff) - 1; strip.setPixelColor(min(strip.numPixels()-1, j), getColor(brightness)); } strip.show(); delay(20); } for(int i=strip.numPixels()-1; i>=-tail; i--) { for(int j=strip.numPixels()-1; j>=i; j--) { int diff = min(tail, abs(j-i)); int brightness = (128 >> diff) - 1; strip.setPixelColor(max(0, j), getColor(brightness)); } strip.show(); delay(20); } } void loop() { for(int i = 0; i<3; i++) { scanBar(&kitt); } for(int i = 0; i<3; i++) { scanBar(&karr); } } uint32_t kitt(byte brightness) { return strip.Color(brightness, 0, 0); } uint32_t karr(byte brightness) { return strip.Color(brightness, brightness*0.4, 0); }
[ "rbirkby@gmail.com" ]
rbirkby@gmail.com
c502dd86625144c3753bcfca74e13a6eaa6a8977
5cf90b2be2f265e7f02144192dba4a26cef15756
/skia/tests/TessellatingPathRendererTests.cpp
9af45ee51e8d70b41d0fe0dc35cb4c618a578be3
[ "BSD-3-Clause", "MIT" ]
permissive
jiangkang/renderer-dog
b73f1d1d0d5d61ea9a5da81983eeb536d6d791da
8081732e2b4dbdb97c8d1f5e23f9e52c6362ff85
refs/heads/master
2021-07-07T21:49:57.293616
2020-09-13T16:31:34
2020-09-13T16:31:34
174,357,799
0
0
MIT
2020-09-13T11:08:16
2019-03-07T14:18:53
C++
UTF-8
C++
false
false
31,181
cpp
/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "Test.h" #include "GrClip.h" #include "GrContext.h" #include "GrContextPriv.h" #include "GrShape.h" #include "GrStyle.h" #include "SkGradientShader.h" #include "SkPath.h" #include "SkShaderBase.h" #include "effects/GrPorterDuffXferProcessor.h" #include "ops/GrTessellatingPathRenderer.h" /* * These tests pass by not crashing, hanging or asserting in Debug. */ // Tests active edges made inactive by splitting. // Also tests active edge list forced into an invalid ordering by // splitting (mopped up in cleanup_active_edges()). static SkPath create_path_0() { SkPath path; path.moveTo(229.127044677734375f, 67.34100341796875f); path.lineTo(187.8097381591796875f, -6.7729740142822265625f); path.lineTo(171.411407470703125f, 50.94266510009765625f); path.lineTo(245.5253753662109375f, 9.6253643035888671875f); path.moveTo(208.4683990478515625f, 30.284009933471679688f); path.lineTo(171.411407470703125f, 50.94266510009765625f); path.lineTo(187.8097381591796875f, -6.7729740142822265625f); return path; } // Intersections which fall exactly on the current vertex, and require // a restart of the intersection checking. static SkPath create_path_1() { SkPath path; path.moveTo(314.483551025390625f, 486.246002197265625f); path.lineTo(385.41949462890625f, 532.8087158203125f); path.lineTo(373.232879638671875f, 474.05938720703125f); path.lineTo(326.670166015625f, 544.995361328125f); path.moveTo(349.951507568359375f, 509.52734375f); path.lineTo(373.232879638671875f, 474.05938720703125f); path.lineTo(385.41949462890625f, 532.8087158203125f); return path; } // Tests active edges which are removed by splitting. static SkPath create_path_2() { SkPath path; path.moveTo(343.107391357421875f, 613.62176513671875f); path.lineTo(426.632415771484375f, 628.5740966796875f); path.lineTo(392.3460693359375f, 579.33544921875f); path.lineTo(377.39373779296875f, 662.86041259765625f); path.moveTo(384.869873046875f, 621.097900390625f); path.lineTo(392.3460693359375f, 579.33544921875f); path.lineTo(426.632415771484375f, 628.5740966796875f); return path; } // Collinear edges merged in set_top(). // Also, an intersection between left and right enclosing edges which // falls above the current vertex. static SkPath create_path_3() { SkPath path; path.moveTo(545.95751953125f, 791.69854736328125f); path.lineTo(612.05816650390625f, 738.494140625f); path.lineTo(552.4056396484375f, 732.0460205078125f); path.lineTo(605.61004638671875f, 798.14666748046875f); path.moveTo(579.00787353515625f, 765.0963134765625f); path.lineTo(552.4056396484375f, 732.0460205078125f); path.lineTo(612.05816650390625f, 738.494140625f); return path; } // Tests active edges which are made inactive by set_top(). static SkPath create_path_4() { SkPath path; path.moveTo(819.2725830078125f, 751.77447509765625f); path.lineTo(820.70904541015625f, 666.933837890625f); path.lineTo(777.57049560546875f, 708.63592529296875f); path.lineTo(862.4111328125f, 710.0723876953125f); path.moveTo(819.99078369140625f, 709.3541259765625f); path.lineTo(777.57049560546875f, 708.63592529296875f); path.lineTo(820.70904541015625f, 666.933837890625f); return path; } static SkPath create_path_5() { SkPath path; path.moveTo(823.33209228515625f, 749.052734375f); path.lineTo(823.494873046875f, 664.20013427734375f); path.lineTo(780.9871826171875f, 706.5450439453125f); path.lineTo(865.8397216796875f, 706.70782470703125f); path.moveTo(823.4134521484375f, 706.6263427734375f); path.lineTo(780.9871826171875f, 706.5450439453125f); path.lineTo(823.494873046875f, 664.20013427734375f); return path; } static SkPath create_path_6() { SkPath path; path.moveTo(954.862548828125f, 562.8349609375f); path.lineTo(899.32818603515625f, 498.679443359375f); path.lineTo(895.017578125f, 558.52435302734375f); path.lineTo(959.17315673828125f, 502.990081787109375f); path.moveTo(927.0953369140625f, 530.7572021484375f); path.lineTo(895.017578125f, 558.52435302734375f); path.lineTo(899.32818603515625f, 498.679443359375f); return path; } static SkPath create_path_7() { SkPath path; path.moveTo(958.5330810546875f, 547.35516357421875f); path.lineTo(899.93109130859375f, 485.989013671875f); path.lineTo(898.54901123046875f, 545.97308349609375f); path.lineTo(959.9151611328125f, 487.37109375f); path.moveTo(929.2320556640625f, 516.67205810546875f); path.lineTo(898.54901123046875f, 545.97308349609375f); path.lineTo(899.93109130859375f, 485.989013671875f); return path; } static SkPath create_path_8() { SkPath path; path.moveTo(389.8609619140625f, 369.326873779296875f); path.lineTo(470.6290283203125f, 395.33697509765625f); path.lineTo(443.250030517578125f, 341.9478759765625f); path.lineTo(417.239959716796875f, 422.7159423828125f); path.moveTo(430.244964599609375f, 382.3319091796875f); path.lineTo(443.250030517578125f, 341.9478759765625f); path.lineTo(470.6290283203125f, 395.33697509765625f); return path; } static SkPath create_path_9() { SkPath path; path.moveTo(20, 20); path.lineTo(50, 80); path.lineTo(20, 80); path.moveTo(80, 50); path.lineTo(50, 50); path.lineTo(20, 50); return path; } static SkPath create_path_10() { SkPath path; path.moveTo(257.19439697265625f, 320.876617431640625f); path.lineTo(190.113037109375f, 320.58978271484375f); path.lineTo(203.64404296875f, 293.8145751953125f); path.moveTo(203.357177734375f, 360.896026611328125f); path.lineTo(216.88824462890625f, 334.120819091796875f); path.lineTo(230.41925048828125f, 307.345611572265625f); return path; } // A degenerate segments case, where both upper and lower segments of // a split edge must remain active. static SkPath create_path_11() { SkPath path; path.moveTo(231.9331207275390625f, 306.2012939453125f); path.lineTo(191.4859161376953125f, 306.04547119140625f); path.lineTo(231.0659332275390625f, 300.2642822265625f); path.moveTo(189.946807861328125f, 302.072265625f); path.lineTo(179.79705810546875f, 294.859771728515625f); path.lineTo(191.0016021728515625f, 296.165679931640625f); path.moveTo(150.8942108154296875f, 304.900146484375f); path.lineTo(179.708892822265625f, 297.849029541015625f); path.lineTo(190.4742279052734375f, 299.11895751953125f); return path; } // Handle the case where edge.dist(edge.fTop) != 0.0. static SkPath create_path_12() { SkPath path; path.moveTo( 0.0f, 400.0f); path.lineTo( 138.0f, 202.0f); path.lineTo( 0.0f, 202.0f); path.moveTo( 12.62693023681640625f, 250.57464599609375f); path.lineTo( 8.13896942138671875f, 254.556884765625f); path.lineTo(-18.15641021728515625f, 220.40203857421875f); path.lineTo(-15.986493110656738281f, 219.6513519287109375f); path.moveTo( 36.931194305419921875f, 282.485504150390625f); path.lineTo( 15.617521286010742188f, 261.2901611328125f); path.lineTo( 10.3829498291015625f, 252.565765380859375f); path.lineTo(-16.165292739868164062f, 222.646026611328125f); return path; } // A degenerate segments case which exercises inactive edges being // made active by splitting. static SkPath create_path_13() { SkPath path; path.moveTo(690.62127685546875f, 509.25555419921875f); path.lineTo(99.336181640625f, 511.71405029296875f); path.lineTo(708.362548828125f, 512.4349365234375f); path.lineTo(729.9940185546875f, 516.3114013671875f); path.lineTo(738.708984375f, 518.76995849609375f); path.lineTo(678.3463134765625f, 510.0819091796875f); path.lineTo(681.21795654296875f, 504.81378173828125f); path.moveTo(758.52764892578125f, 521.55963134765625f); path.lineTo(719.1549072265625f, 514.50372314453125f); path.lineTo(689.59063720703125f, 512.0628662109375f); path.lineTo(679.78216552734375f, 507.447845458984375f); return path; } // Tests vertices which become "orphaned" (ie., no connected edges) // after simplification. static SkPath create_path_14() { SkPath path; path.moveTo(217.326019287109375f, 166.4752960205078125f); path.lineTo(226.279266357421875f, 170.929473876953125f); path.lineTo(234.3973388671875f, 177.0623626708984375f); path.lineTo(262.0921630859375f, 188.746124267578125f); path.moveTo(196.23638916015625f, 174.0722198486328125f); path.lineTo(416.15277099609375f, 180.138214111328125f); path.lineTo(192.651947021484375f, 304.0228271484375f); return path; } static SkPath create_path_15() { SkPath path; path.moveTo( 0.0f, 0.0f); path.lineTo(10000.0f, 0.0f); path.lineTo( 0.0f, -1.0f); path.lineTo(10000.0f, 0.000001f); path.lineTo( 0.0f, -30.0f); return path; } // Reduction of Nebraska-StateSeal.svg. Floating point error causes the // same edge to be added to more than one poly on the same side. static SkPath create_path_16() { SkPath path; path.moveTo(170.8199920654296875, 491.86700439453125); path.lineTo(173.7649993896484375, 489.7340087890625); path.lineTo(174.1450958251953125, 498.545989990234375); path.lineTo( 171.998992919921875, 500.88201904296875); path.moveTo(168.2922515869140625, 498.66265869140625); path.lineTo(169.8589935302734375, 497.94500732421875); path.lineTo( 172, 500.88299560546875); path.moveTo( 169.555267333984375, 490.70111083984375); path.lineTo(173.7649993896484375, 489.7340087890625); path.lineTo( 170.82000732421875, 491.86700439453125); return path; } // A simple concave path. Test this with a non-invertible matrix. static SkPath create_path_17() { SkPath path; path.moveTo(20, 20); path.lineTo(80, 20); path.lineTo(30, 30); path.lineTo(20, 80); return path; } // A shape with a vertex collinear to the right hand edge. // This messes up find_enclosing_edges. static SkPath create_path_18() { SkPath path; path.moveTo(80, 20); path.lineTo(80, 60); path.lineTo(20, 60); path.moveTo(80, 50); path.lineTo(80, 80); path.lineTo(20, 80); return path; } // Exercises the case where an edge becomes collinear with *two* of its // adjacent neighbour edges after splitting. // This is a reduction from // http://mooooo.ooo/chebyshev-sine-approximation/horner_ulp.svg static SkPath create_path_19() { SkPath path; path.moveTo( 351.99298095703125, 348.23046875); path.lineTo( 351.91876220703125, 347.33984375); path.lineTo( 351.91876220703125, 346.1953125); path.lineTo( 351.90313720703125, 347.734375); path.lineTo( 351.90313720703125, 346.1328125); path.lineTo( 351.87579345703125, 347.93359375); path.lineTo( 351.87579345703125, 345.484375); path.lineTo( 351.86407470703125, 347.7890625); path.lineTo( 351.86407470703125, 346.2109375); path.lineTo( 351.84844970703125, 347.63763427734375); path.lineTo( 351.84454345703125, 344.19232177734375); path.lineTo( 351.78204345703125, 346.9483642578125); path.lineTo( 351.758636474609375, 347.18310546875); path.lineTo( 351.75469970703125, 346.75); path.lineTo( 351.75469970703125, 345.46875); path.lineTo( 352.5546875, 345.46875); path.lineTo( 352.55078125, 347.01953125); path.lineTo( 351.75079345703125, 347.02313232421875); path.lineTo( 351.74688720703125, 346.15203857421875); path.lineTo( 351.74688720703125, 347.646148681640625); path.lineTo( 352.5390625, 346.94140625); path.lineTo( 351.73907470703125, 346.94268798828125); path.lineTo( 351.73516845703125, 344.48565673828125); path.lineTo( 352.484375, 346.73828125); path.lineTo( 351.68438720703125, 346.7401123046875); path.lineTo( 352.4765625, 346.546875); path.lineTo( 351.67657470703125, 346.54937744140625); path.lineTo( 352.47265625, 346.75390625); path.lineTo( 351.67266845703125, 346.756622314453125); path.lineTo( 351.66876220703125, 345.612091064453125); return path; } // An intersection above the first vertex in the mesh. // Reduction from http://crbug.com/730687 static SkPath create_path_20() { SkPath path; path.moveTo( 2822128.5, 235.026336669921875); path.lineTo( 2819349.25, 235.3623504638671875); path.lineTo( -340558688, 23.83478546142578125); path.lineTo( -340558752, 25.510419845581054688); path.lineTo( -340558720, 27.18605804443359375); return path; } // An intersection whose result is NaN (due to rounded-to-inf endpoint). static SkPath create_path_21() { SkPath path; path.moveTo(1.7889142061167663539e+38, 39338463358011572224.0); path.lineTo( 1647.4193115234375, -522.603515625); path.lineTo( 1677.74560546875, -529.0028076171875); path.lineTo( 1678.29541015625, -528.7847900390625); path.lineTo( 1637.5167236328125, -519.79266357421875); path.lineTo( 1647.4193115234375, -522.603515625); return path; } // A path which contains out-of-range colinear intersections. static SkPath create_path_23() { SkPath path; path.moveTo( 0, 63.39080047607421875); path.lineTo(-0.70804601907730102539, 63.14350128173828125); path.lineTo(-7.8608899287380243391e-17, 64.14080047607421875); path.moveTo( 0, 64.14080047607421875); path.lineTo(44.285900115966796875, 64.14080047607421875); path.lineTo( 0, 62.64080047607421875); path.moveTo(21.434900283813476562, -0.24732701480388641357); path.lineTo(-0.70804601907730102539, 63.14350128173828125); path.lineTo(0.70804601907730102539, 63.6381988525390625); return path; } // A path which results in infs and nans when conics are converted to quads. static SkPath create_path_24() { SkPath path; path.moveTo(-2.20883e+37f, -1.02892e+37f); path.conicTo(-2.00958e+38f, -9.36107e+37f, -1.7887e+38f, -8.33215e+37f, 0.707107f); path.conicTo(-1.56782e+38f, -7.30323e+37f, 2.20883e+37f, 1.02892e+37f, 0.707107f); path.conicTo(2.00958e+38f, 9.36107e+37f, 1.7887e+38f, 8.33215e+37f, 0.707107f); path.conicTo(1.56782e+38f, 7.30323e+37f, -2.20883e+37f, -1.02892e+37f, 0.707107f); return path; } // An edge collapse event which also collapses a neighbour, requiring // its event to be removed. static SkPath create_path_25() { SkPath path; path.moveTo( 43.44110107421875, 148.15106201171875); path.lineTo( 44.64471435546875, 148.16748046875); path.lineTo( 46.35009765625, 147.403076171875); path.lineTo( 46.45404052734375, 148.34906005859375); path.lineTo( 45.0400390625, 148.54205322265625); path.lineTo( 44.624053955078125, 148.9810791015625); path.lineTo( 44.59405517578125, 149.16107177734375); path.lineTo( 44.877044677734375, 149.62005615234375); path.lineTo(144.373016357421875, 68.8070068359375); return path; } // An edge collapse event causes an edge to become collinear, requiring // its event to be removed. static SkPath create_path_26() { SkPath path; path.moveTo( 43.44110107421875, 148.15106201171875); path.lineTo( 44.64471435546875, 148.16748046875); path.lineTo( 46.35009765625, 147.403076171875); path.lineTo( 46.45404052734375, 148.34906005859375); path.lineTo( 45.0400390625, 148.54205322265625); path.lineTo( 44.624053955078125, 148.9810791015625); path.lineTo( 44.59405517578125, 149.16107177734375); path.lineTo( 44.877044677734375, 149.62005615234375); path.lineTo(144.373016357421875, 68.8070068359375); return path; } // A path which results in non-finite points when stroked and bevelled for AA. static SkPath create_path_27() { SkPath path; path.moveTo(8.5027233009104409507e+37, 1.7503381025241130639e+37); path.lineTo(7.0923661737711584874e+37, 1.4600074517285415699e+37); path.lineTo(7.0848733446033294691e+37, 1.4584649744781838604e+37); path.lineTo(-2.0473916115129349496e+37, -4.2146796450364162012e+36); path.lineTo(2.0473912312177548811e+37, 4.2146815465123165435e+36); return path; } // AA stroking this path produces intersection failures on bevelling. // This should skip the point, but not assert. static SkPath create_path_28() { SkPath path; path.moveTo(-7.5952312625177475154e+21, -2.6819185100266674911e+24); path.lineTo( 1260.3787841796875, 1727.7947998046875); path.lineTo( 1260.5567626953125, 1728.0386962890625); path.lineTo(1.1482511310557754163e+21, 4.054538502765980051e+23); path.lineTo(-7.5952312625177475154e+21, -2.6819185100266674911e+24); return path; } // A quad which generates a huge number of points (>2B) when uniformly // linearized. This should not hang or OOM. static SkPath create_path_29() { SkPath path; path.moveTo(10, 0); path.lineTo(0, 0); path.quadTo(10, 0, 0, 8315084722602508288); return path; } // A path which hangs during simplification. It produces an edge which is // to the left of its own endpoints, which causes an infinte loop in the // right-enclosing-edge splitting. static SkPath create_path_30() { SkPath path; path.moveTo(0.75001740455627441406, 23.051967620849609375); path.lineTo(5.8471612930297851562, 22.731662750244140625); path.lineTo(10.749670028686523438, 22.253145217895507812); path.lineTo(13.115868568420410156, 22.180681228637695312); path.lineTo(15.418928146362304688, 22.340015411376953125); path.lineTo( 17.654022216796875, 22.82159423828125); path.lineTo(19.81632232666015625, 23.715869903564453125); path.lineTo(40, 0); path.lineTo(5.5635203441547955577e-15, 0); path.lineTo(5.5635203441547955577e-15, 47); path.lineTo(-1.4210854715202003717e-14, 21.713298797607421875); path.lineTo(0.75001740455627441406, 21.694292068481445312); path.lineTo(0.75001740455627441406, 23.051967620849609375); return path; } // A path with vertices which become infinite on AA stroking. Should not crash or assert. static SkPath create_path_31() { SkPath path; path.moveTo(2.0257809259190991347e+36, -1244080640); path.conicTo(2.0257809259190991347e+36, -1244080640, 2.0257809259190991347e+36, 0.10976474732160568237, 0.70710676908493041992); path.lineTo(-10036566016, -1954718402215936); path.conicTo(-1.1375507718551896064e+20, -1954721086570496, 10036566016, -1954721086570496, 0.70710676908493041992); return path; } // Reduction from skbug.com/7911 that causes a crash due to splitting a // zombie edge. static SkPath create_path_32() { SkPath path; path.moveTo( 0, 1.0927740941146660348e+24); path.lineTo(2.9333931225865729333e+32, 16476101); path.lineTo(1.0927731573659435417e+24, 1.0927740941146660348e+24); path.lineTo(1.0927740941146660348e+24, 3.7616281094287041715e-37); path.lineTo(1.0927740941146660348e+24, 1.0927740941146660348e+24); path.lineTo(1.3061803026169399536e-33, 1.0927740941146660348e+24); path.lineTo(4.7195362919941370727e-16, -8.4247545146051822591e+32); return path; } // From crbug.com/844873. Crashes trying to merge a zombie edge. static SkPath create_path_33() { SkPath path; path.moveTo( 316.000579833984375, -4338355948977389568); path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0); path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0); path.lineTo( 771.21014404296875, -4338355948977389568.0); path.lineTo( 316.000579833984375, -4338355948977389568.0); path.moveTo( 354.208984375, -4338355948977389568.0); path.lineTo( 773.00177001953125, -4338355948977389568.0); path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0); path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0); path.lineTo( 354.208984375, -4338355948977389568.0); return path; } // From crbug.com/844873. Hangs repeatedly splitting alternate vertices. static SkPath create_path_34() { SkPath path; path.moveTo(10, -1e+20f); path.lineTo(11, 25000); path.lineTo(10, 25000); path.lineTo(11, 25010); return path; } // Reduction from circular_arcs_stroke_and_fill_round GM which // repeatedly splits on the opposite edge from case 34 above. static SkPath create_path_35() { SkPath path; path.moveTo( 16.25, 26.495191574096679688); path.lineTo(32.420825958251953125, 37.377376556396484375); path.lineTo(25.176382064819335938, 39.31851959228515625); path.moveTo( 20, 20); path.lineTo(28.847436904907226562, 37.940830230712890625); path.lineTo(25.17638397216796875, 39.31851959228515625); return path; } // Reduction from crbug.com/843135 where an intersection is found // below the bottom of both intersected edges. static SkPath create_path_36() { SkPath path; path.moveTo(-2791476679359332352, 2608107002026524672); path.lineTo( 0, 11.95427703857421875); path.lineTo(-2781824066779086848, 2599088532777598976); path.lineTo( -7772.6875, 7274); return path; } // Reduction from crbug.com/843135. Exercises a case where an intersection is missed. // This causes bad ordering in the active edge list. static SkPath create_path_37() { SkPath path; path.moveTo(-1.0662557646016024569e+23, 9.9621425197286319718e+22); path.lineTo( -121806400, 113805032); path.lineTo( -120098872, 112209680); path.lineTo( 6.2832999862817380468e-36, 2.9885697364807128906); return path; } // Reduction from crbug.com/851914. static SkPath create_path_38() { SkPath path; path.moveTo(14.400531768798828125, 17.711114883422851562); path.lineTo(14.621990203857421875, 171563104293879808); path.lineTo(14.027951240539550781, 872585759381520384); path.lineTo( 14.0216827392578125, 872665817571917824); path.lineTo(7.699314117431640625, -3417320793833472); path.moveTo(11.606547355651855469, 17.40966796875); path.lineTo( 7642114886926860288, 21.08358001708984375); path.lineTo(11.606547355651855469, 21.08358001708984375); return path; } // Reduction from crbug.com/851409. Exercises collinear last vertex. static SkPath create_path_39() { SkPath path; path.moveTo(2072553216, 0); path.lineTo(2072553216, 1); path.lineTo(2072553472, -13.5); path.lineTo(2072553216, 0); path.lineTo(2072553472, -6.5); return path; } // Another reduction from crbug.com/851409. Exercises two sequential collinear edges. static SkPath create_path_40() { SkPath path; path.moveTo(2072553216, 0); path.lineTo(2072553216, 1); path.lineTo(2072553472, -13); path.lineTo(2072553216, 0); path.lineTo(2072553472, -6); path.lineTo(2072553472, -13); return path; } // Reduction from crbug.com/860453. Tests a case where a "missing" intersection // requires the active edge list to go out-of-order. static SkPath create_path_41() { SkPath path; path.moveTo(72154931603311689728.0, 330.95965576171875); path.lineTo(24053266013925408768.0, 78.11376953125); path.lineTo(1.2031099003292404941e+20, 387.168731689453125); path.lineTo(68859835992355373056.0, 346.55047607421875); path.lineTo(76451708695451009024.0, 337.780029296875); path.moveTo(-20815817797613387776.0, 18065700622522384384.0); path.lineTo(-72144121204987396096.0, 142.855804443359375); path.lineTo(72144121204987396096.0, 325.184783935546875); path.lineTo(1.2347242901040791552e+20, 18065700622522384384.0); return path; } // Reduction from crbug.com/860655. Cause is three collinear edges discovered during // sanitize_contours pass, before the vertices have been found coincident. static SkPath create_path_42() { SkPath path; path.moveTo( 32572426382475264, -3053391034974208); path.lineTo( 521289856, -48865776); path.lineTo( 130322464, -12215873); path.moveTo( 32572426382475264, -3053391034974208); path.lineTo( 521289856, -48865776); path.lineTo( 130322464, -12215873); path.moveTo( 32572426382475264, -3053391034974208); path.lineTo( 32114477642022912, -3010462031544320); path.lineTo( 32111784697528320, -3010209702215680); return path; } // Reduction from crbug.com/866319. Cause is edges that are collinear when tested from // one side, but non-collinear when tested from the other. static SkPath create_path_43() { SkPath path; path.moveTo( 307316821852160, -28808363114496); path.lineTo( 307165222928384, -28794154909696); path.lineTo( 307013691113472, -28779948802048); path.lineTo( 306862159298560, -28765744791552); path.lineTo( 306870313025536, -28766508154880); path.lineTo( 307049695019008, -28783327313920); path.lineTo( 307408660332544, -28816974020608); return path; } static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrContext* ctx) { SkPoint pts[2] = { {0, 0}, {1, 1} }; SkColor colors[2] = { SK_ColorGREEN, SK_ColorBLUE }; sk_sp<SkShader> shader = SkGradientShader::MakeLinear( pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode); GrColorSpaceInfo colorSpaceInfo(nullptr, kRGBA_8888_GrPixelConfig); GrFPArgs args(ctx, &SkMatrix::I(), SkFilterQuality::kLow_SkFilterQuality, &colorSpaceInfo); return as_SB(shader)->asFragmentProcessor(args); } using AATypeFlags = GrPathRenderer::AATypeFlags; static void test_path(GrContext* ctx, GrRenderTargetContext* renderTargetContext, const SkPath& path, const SkMatrix& matrix = SkMatrix::I(), AATypeFlags aaTypeFlags = AATypeFlags::kNone, std::unique_ptr<GrFragmentProcessor> fp = nullptr) { GrTessellatingPathRenderer tess; GrPaint paint; paint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); if (fp) { paint.addColorFragmentProcessor(std::move(fp)); } GrNoClip noClip; SkIRect clipConservativeBounds = SkIRect::MakeWH(renderTargetContext->width(), renderTargetContext->height()); GrStyle style(SkStrokeRec::kFill_InitStyle); GrShape shape(path, style); GrPathRenderer::DrawPathArgs args{ctx, std::move(paint), &GrUserStencilSettings::kUnused, renderTargetContext, &noClip, &clipConservativeBounds, &matrix, &shape, aaTypeFlags, false}; tess.drawPath(args); } DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { GrContext* ctx = ctxInfo.grContext(); const GrBackendFormat format = ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); sk_sp<GrRenderTargetContext> rtc(ctx->priv().makeDeferredRenderTargetContext( format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin)); if (!rtc) { return; } ctx->flush(); // Adding discard to appease vulkan validation warning about loading uninitialized data on draw rtc->discard(); test_path(ctx, rtc.get(), create_path_0()); test_path(ctx, rtc.get(), create_path_1()); test_path(ctx, rtc.get(), create_path_2()); test_path(ctx, rtc.get(), create_path_3()); test_path(ctx, rtc.get(), create_path_4()); test_path(ctx, rtc.get(), create_path_5()); test_path(ctx, rtc.get(), create_path_6()); test_path(ctx, rtc.get(), create_path_7()); test_path(ctx, rtc.get(), create_path_8()); test_path(ctx, rtc.get(), create_path_9()); test_path(ctx, rtc.get(), create_path_10()); test_path(ctx, rtc.get(), create_path_11()); test_path(ctx, rtc.get(), create_path_12()); test_path(ctx, rtc.get(), create_path_13()); test_path(ctx, rtc.get(), create_path_14()); test_path(ctx, rtc.get(), create_path_15()); test_path(ctx, rtc.get(), create_path_16()); SkMatrix nonInvertibleMatrix = SkMatrix::MakeScale(0, 0); std::unique_ptr<GrFragmentProcessor> fp(create_linear_gradient_processor(ctx)); test_path(ctx, rtc.get(), create_path_17(), nonInvertibleMatrix, AATypeFlags::kCoverage, std::move(fp)); test_path(ctx, rtc.get(), create_path_18()); test_path(ctx, rtc.get(), create_path_19()); test_path(ctx, rtc.get(), create_path_20(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_21(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_23()); test_path(ctx, rtc.get(), create_path_24()); test_path(ctx, rtc.get(), create_path_25(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_26(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_27(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_28(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_29()); test_path(ctx, rtc.get(), create_path_30()); test_path(ctx, rtc.get(), create_path_31(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_32()); test_path(ctx, rtc.get(), create_path_33()); test_path(ctx, rtc.get(), create_path_34()); test_path(ctx, rtc.get(), create_path_35()); test_path(ctx, rtc.get(), create_path_36()); test_path(ctx, rtc.get(), create_path_37()); test_path(ctx, rtc.get(), create_path_38(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_39()); test_path(ctx, rtc.get(), create_path_40()); test_path(ctx, rtc.get(), create_path_41(), SkMatrix(), AATypeFlags::kCoverage); test_path(ctx, rtc.get(), create_path_42()); test_path(ctx, rtc.get(), create_path_43(), SkMatrix(), AATypeFlags::kCoverage); }
[ "jiangkang0504@163.com" ]
jiangkang0504@163.com
4c157dec32a8c39e3d1c52fb29b8bd51631135c8
47b755444e700332877d8bb432e5739045ba2c8b
/wxWidgets/include/wx/generic/spinctlg.h
0f09abd5d7065c4b2aa2c67dd4b8d4c4bf59b4c3
[ "MIT" ]
permissive
andr3wmac/Torque6Editor
5b30e103f0b3a81ae7a189725e25d807093bf131
0f8536ce90064adb9918f004a45aaf8165b2a343
refs/heads/master
2021-01-15T15:32:54.537291
2016-06-09T20:45:49
2016-06-09T20:45:49
39,276,153
25
14
null
null
null
null
UTF-8
C++
false
false
14,361
h
///////////////////////////////////////////////////////////////////////////// // Name: wx/generic/spinctlg.h // Purpose: generic wxSpinCtrl class // Author: Vadim Zeitlin // Modified by: // Created: 28.10.99 // Copyright: (c) Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_GENERIC_SPINCTRL_H_ #define _WX_GENERIC_SPINCTRL_H_ // ---------------------------------------------------------------------------- // wxSpinCtrl is a combination of wxSpinButton and wxTextCtrl, so if // wxSpinButton is available, this is what we do - but if it isn't, we still // define wxSpinCtrl class which then has the same appearance as wxTextCtrl but // the different interface. This allows to write programs using wxSpinCtrl // without tons of #ifdefs. // ---------------------------------------------------------------------------- #if wxUSE_SPINBTN #include "wx/compositewin.h" class WXDLLIMPEXP_FWD_CORE wxSpinButton; class WXDLLIMPEXP_FWD_CORE wxTextCtrl; class wxSpinCtrlTextGeneric; // wxTextCtrl used for the wxSpinCtrlGenericBase // The !wxUSE_SPINBTN version's GetValue() function conflicts with the // wxTextCtrl's GetValue() and so you have to input a dummy int value. #define wxSPINCTRL_GETVALUE_FIX // ---------------------------------------------------------------------------- // wxSpinCtrlGeneric is a combination of wxTextCtrl and wxSpinButton // // This class manages a double valued generic spinctrl through the DoGet/SetXXX // functions that are made public as Get/SetXXX functions for int or double // for the wxSpinCtrl and wxSpinCtrlDouble classes respectively to avoid // function ambiguity. // ---------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxNavigationEnabled<wxCompositeWindow<wxSpinCtrlBase> > { public: wxSpinCtrlGenericBase() { Init(); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrl")); virtual ~wxSpinCtrlGenericBase(); // accessors // T GetValue() const // T GetMin() const // T GetMax() const // T GetIncrement() const virtual bool GetSnapToTicks() const { return m_snap_to_ticks; } // unsigned GetDigits() const - wxSpinCtrlDouble only // operations virtual void SetValue(const wxString& text); // void SetValue(T val) // void SetRange(T minVal, T maxVal) // void SetIncrement(T inc) virtual void SetSnapToTicks(bool snap_to_ticks); // void SetDigits(unsigned digits) - wxSpinCtrlDouble only // Select text in the textctrl void SetSelection(long from, long to); // implementation from now on // forward these functions to all subcontrols virtual bool Enable(bool enable = true); virtual bool Show(bool show = true); virtual bool SetBackgroundColour(const wxColour& colour); // get the subcontrols wxTextCtrl *GetText() const { return m_textCtrl; } wxSpinButton *GetSpinButton() const { return m_spinButton; } // forwarded events from children windows void OnSpinButton(wxSpinEvent& event); void OnTextLostFocus(wxFocusEvent& event); void OnTextChar(wxKeyEvent& event); // this window itself is used only as a container for its sub windows so it // shouldn't accept the focus at all and any attempts to explicitly set // focus to it should give focus to its text constol part virtual bool AcceptsFocus() const { return false; } virtual void SetFocus(); friend class wxSpinCtrlTextGeneric; protected: // override the base class virtuals involved into geometry calculations virtual wxSize DoGetBestSize() const; virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const; virtual void DoMoveWindow(int x, int y, int width, int height); #ifdef __WXMSW__ // and, for MSW, enabling this window itself virtual void DoEnable(bool enable); #endif // __WXMSW__ enum SendEvent { SendEvent_None, SendEvent_Text }; // generic double valued functions double DoGetValue() const { return m_value; } bool DoSetValue(double val, SendEvent sendEvent); void DoSetRange(double min_val, double max_val); void DoSetIncrement(double inc); // update our value to reflect the text control contents (if it has been // modified by user, do nothing otherwise) // // can also change the text control if its value is invalid // // return true if our value has changed bool SyncSpinToText(SendEvent sendEvent); // Send the correct event type virtual void DoSendEvent() = 0; // Convert the text to/from the corresponding value. virtual bool DoTextToValue(const wxString& text, double *val) = 0; virtual wxString DoValueToText(double val) = 0; // check if the value is in range bool InRange(double n) const { return (n >= m_min) && (n <= m_max); } // ensure that the value is in range wrapping it round if necessary double AdjustToFitInRange(double value) const; double m_value; double m_min; double m_max; double m_increment; bool m_snap_to_ticks; int m_spin_value; // the subcontrols wxTextCtrl *m_textCtrl; wxSpinButton *m_spinButton; private: // common part of all ctors void Init(); // Implement pure virtual function inherited from wxCompositeWindow. virtual wxWindowList GetCompositeWindowParts() const; wxDECLARE_EVENT_TABLE(); }; #else // !wxUSE_SPINBTN #define wxSPINCTRL_GETVALUE_FIX int = 1 // ---------------------------------------------------------------------------- // wxSpinCtrl is just a text control // ---------------------------------------------------------------------------- #include "wx/textctrl.h" class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxTextCtrl { public: wxSpinCtrlGenericBase() : m_value(0), m_min(0), m_max(100), m_increment(1), m_snap_to_ticks(false), m_format(wxT("%g")) { } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrl")) { m_min = min; m_max = max; m_value = initial; m_increment = inc; bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style, wxDefaultValidator, name); DoSetValue(initial, SendEvent_None); return ok; } // accessors // T GetValue() const // T GetMin() const // T GetMax() const // T GetIncrement() const virtual bool GetSnapToTicks() const { return m_snap_to_ticks; } // unsigned GetDigits() const - wxSpinCtrlDouble only // operations virtual void SetValue(const wxString& text) { wxTextCtrl::SetValue(text); } // void SetValue(T val) // void SetRange(T minVal, T maxVal) // void SetIncrement(T inc) virtual void SetSnapToTicks(bool snap_to_ticks) { m_snap_to_ticks = snap_to_ticks; } // void SetDigits(unsigned digits) - wxSpinCtrlDouble only // Select text in the textctrl //void SetSelection(long from, long to); protected: // generic double valued double DoGetValue() const { double n; if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%lf"), &n) != 1) ) n = INT_MIN; return n; } bool DoSetValue(double val, SendEvent sendEvent) { wxString str(wxString::Format(m_format, val)); switch ( sendEvent ) { case SendEvent_None: wxTextCtrl::ChangeValue(str); break; case SendEvent_Text: wxTextCtrl::SetValue(str); break; } return true; } void DoSetRange(double min_val, double max_val) { m_min = min_val; m_max = max_val; } void DoSetIncrement(double inc) { m_increment = inc; } // Note: unused double m_value; double m_min; double m_max; double m_increment; bool m_snap_to_ticks; wxString m_format; }; #endif // wxUSE_SPINBTN/!wxUSE_SPINBTN #if !defined(wxHAS_NATIVE_SPINCTRL) //----------------------------------------------------------------------------- // wxSpinCtrl //----------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGenericBase { public: wxSpinCtrl() { Init(); } wxSpinCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, const wxString& name = wxT("wxSpinCtrl")) { Init(); Create(parent, id, value, pos, size, style, min, max, initial, name); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, const wxString& name = wxT("wxSpinCtrl")) { return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, style, min, max, initial, 1, name); } // accessors int GetValue(wxSPINCTRL_GETVALUE_FIX) const { return int(DoGetValue()); } int GetMin() const { return int(m_min); } int GetMax() const { return int(m_max); } int GetIncrement() const { return int(m_increment); } // operations void SetValue(const wxString& value) { wxSpinCtrlGenericBase::SetValue(value); } void SetValue( int value ) { DoSetValue(value, SendEvent_None); } void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); } void SetIncrement(int inc) { DoSetIncrement(inc); } virtual int GetBase() const { return m_base; } virtual bool SetBase(int base); protected: virtual void DoSendEvent(); virtual bool DoTextToValue(const wxString& text, double *val); virtual wxString DoValueToText(double val); private: // Common part of all ctors. void Init() { m_base = 10; } int m_base; wxDECLARE_DYNAMIC_CLASS(wxSpinCtrl); }; #endif // wxHAS_NATIVE_SPINCTRL //----------------------------------------------------------------------------- // wxSpinCtrlDouble //----------------------------------------------------------------------------- class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGenericBase { public: wxSpinCtrlDouble() { Init(); } wxSpinCtrlDouble(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrlDouble")) { Init(); Create(parent, id, value, pos, size, style, min, max, initial, inc, name); } bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, double min = 0, double max = 100, double initial = 0, double inc = 1, const wxString& name = wxT("wxSpinCtrlDouble")) { return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, style, min, max, initial, inc, name); } // accessors double GetValue(wxSPINCTRL_GETVALUE_FIX) const { return DoGetValue(); } double GetMin() const { return m_min; } double GetMax() const { return m_max; } double GetIncrement() const { return m_increment; } unsigned GetDigits() const { return m_digits; } // operations void SetValue(const wxString& value) { wxSpinCtrlGenericBase::SetValue(value); } void SetValue(double value) { DoSetValue(value, SendEvent_None); } void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); } void SetIncrement(double inc) { DoSetIncrement(inc); } void SetDigits(unsigned digits); // We don't implement bases support for floating point numbers, this is not // very useful in practice. virtual int GetBase() const { return 10; } virtual bool SetBase(int WXUNUSED(base)) { return 0; } protected: virtual void DoSendEvent(); virtual bool DoTextToValue(const wxString& text, double *val); virtual wxString DoValueToText(double val); unsigned m_digits; private: // Common part of all ctors. void Init() { m_digits = 0; m_format = wxS("%g"); } wxString m_format; wxDECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble); }; #endif // _WX_GENERIC_SPINCTRL_H_
[ "andrewmac@gmail.com" ]
andrewmac@gmail.com
b5589fb337feef68645274585eb809249bd12867
ef91f0c61520391ad25692c6adebff4aebe8dd09
/ServerNet/Sources/VMIMEMessage.cpp
8d1b73eef7e85b122df90ba1f9b7731956adf56e
[]
no_license
StephaneH/core-XToolbox
77462b758dfae86f86aafb8a9c9e5b34215259c7
c166b76bbd1dfba27c7863f203b158212028222e
refs/heads/master
2021-01-19T06:52:37.703070
2014-11-17T13:35:24
2014-11-17T13:35:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,340
cpp
/* * This file is part of Wakanda software, licensed by 4D under * (i) the GNU General Public License version 3 (GNU GPL v3), or * (ii) the Affero General Public License version 3 (AGPL v3) or * (iii) a commercial license. * This file remains the exclusive property of 4D and/or its licensors * and is protected by national and international legislations. * In any event, Licensee's compliance with the terms and conditions * of the applicable license constitutes a prerequisite to any use of this file. * Except as otherwise expressly stated in the applicable license, * such license does not include any other license or rights on this file, * 4D's and/or its licensors' trademarks and/or other proprietary rights. * Consequently, no title, copyright or other proprietary rights * other than those specified in the applicable license is granted. */ #include "VServerNetPrecompiled.h" #include "VMIMEMessage.h" #include "VNameValueCollection.h" #include "VHTTPHeader.h" #include "HTTPTools.h" #include "VMIMEReader.h" BEGIN_TOOLBOX_NAMESPACE USING_TOOLBOX_NAMESPACE using namespace HTTPTools; //-------------------------------------------------------------------------------------------------- VMIMEMessage::VMIMEMessage() : fEncoding (CONST_MIME_MESSAGE_ENCODING_URL) { } VMIMEMessage::~VMIMEMessage() { Clear(); } void VMIMEMessage::Clear() { fMIMEParts.clear(); } void VMIMEMessage::_AddTextPart (const XBOX::VString& inName, bool inIsInline, const XBOX::VString& inContentType, const XBOX::VString& inContentID, XBOX::VPtrStream& inStream) { VMIMEMessagePart *partSource = new VMIMEMessagePart(); if (NULL != partSource) { partSource->SetName (inName); partSource->SetIsInline(inIsInline); partSource->SetMediaType (inContentType); partSource->SetContentID(inContentID); if (XBOX::VE_OK == inStream.OpenReading()) partSource->PutData (inStream.GetDataPtr(), inStream.GetDataSize()); inStream.CloseReading(); fMIMEParts.push_back (partSource); partSource->Release(); } } void VMIMEMessage::_AddFilePart (const XBOX::VString& inName, const XBOX::VString& inFileName, bool inIsInline, const XBOX::VString& inContentType, const XBOX::VString& inContentID, XBOX::VPtrStream& inStream) { VMIMEMessagePart *partSource = new VMIMEMessagePart(); if (NULL != partSource) { partSource->SetName (inName); partSource->SetFileName (inFileName); partSource->SetIsInline(inIsInline); partSource->SetMediaType (inContentType); partSource->SetContentID(inContentID); if (XBOX::VE_OK == inStream.OpenReading()) partSource->PutData (inStream.GetDataPtr(), inStream.GetDataSize()); inStream.CloseReading(); fMIMEParts.push_back (partSource); partSource->Release(); } } void VMIMEMessage::_AddValuePair (const XBOX::VString& inName, const XBOX::VString& inContentType, void *inData, const XBOX::VSize inDataSize) { VMIMEMessagePart *partSource = new VMIMEMessagePart(); if (NULL != partSource) { partSource->SetName (inName); partSource->SetMediaType (inContentType); partSource->PutData (inData, inDataSize); fMIMEParts.push_back (partSource); partSource->Release(); } } void VMIMEMessage::Load (bool inFromPOST, const XBOX::VString& inContentType, const XBOX::VString& inURLQuery, const XBOX::VStream& inStream) { Clear(); if (inFromPOST) { XBOX::VNameValueCollection params; VHTTPHeader::SplitParameters (inContentType, fEncoding, params); if (HTTPTools::EqualASCIIVString (fEncoding, CONST_MIME_MESSAGE_ENCODING_MULTIPART)) { fBoundary = params.Get (CONST_MIME_MESSAGE_BOUNDARY); _ReadMultipart (inStream); } else { _ReadUrl (inStream); } } else { _ReadUrl (inURLQuery); } } void VMIMEMessage::LoadMail (const VMIMEMailHeader *inHeader, VMemoryBufferStream &inStream) { xbox_assert(inHeader != NULL); if (inHeader->fIsMultiPart) { fBoundary = inHeader->fBoundary; _ReadMultiPartMail(inStream); } else _ReadSinglePartMail(inHeader, inStream); } void VMIMEMessage::_ReadUrl (const XBOX::VStream& inStream) { XBOX::VStream& stream = const_cast<XBOX::VStream&>(inStream); if (XBOX::VE_OK == stream.OpenReading()) { XBOX::VString urlString; XBOX::StErrorContextInstaller filter (XBOX::VE_STREAM_TEXT_CONVERSION_FAILURE, XBOX::VE_STREAM_EOF, XBOX::VE_OK); // YT 28-Mar-2013 - ACI0081219 if (XBOX::VE_OK == stream.GetText (urlString)) _ReadUrl (urlString); stream.CloseReading(); } } void VMIMEMessage::_ReadUrl (const XBOX::VString& inString) { if (!inString.IsEmpty()) { const UniChar *stringPtr = inString.GetCPointer(); UniChar ch = *stringPtr; while (ch != '\0') { XBOX::VString name; XBOX::VString value; while (ch != '\0' && ch != CHAR_EQUALS_SIGN && ch != CHAR_AMPERSAND) { if (ch == CHAR_PLUS_SIGN) ch = CHAR_SPACE; name.AppendUniChar (ch); ch = *(++stringPtr); } if (ch == CHAR_EQUALS_SIGN) { ch = *(++stringPtr); while (ch != '\0' && ch != CHAR_AMPERSAND) { if (ch == CHAR_PLUS_SIGN) ch = CHAR_SPACE; value.AppendUniChar (ch); ch = *(++stringPtr); } } XBOX::VString decodedName (name); XBOX::VString decodedValue (value); XBOX::VURL::Decode (decodedName); XBOX::VURL::Decode (decodedValue); XBOX::StStringConverter<char> buffer (decodedValue, XBOX::VTC_UTF_8); _AddValuePair (decodedName, CONST_TEXT_PLAIN_UTF_8, (void *)buffer.GetCPointer(), buffer.GetLength()); if (ch == CHAR_AMPERSAND) ch = *(++stringPtr); } } } void VMIMEMessage::_ReadMultipart (const XBOX::VStream& inStream) { XBOX::VStream& stream = const_cast<XBOX::VStream&>(inStream); VMIMEReader reader (fBoundary, stream); while (reader.HasNextPart()) { VHTTPMessage message; if (!reader.GetNextPart (message)) break; XBOX::VString dispositionValue; XBOX::VNameValueCollection params; if (message.GetHeaders().IsHeaderSet (STRING_HEADER_CONTENT_DISPOSITION)) { XBOX::VString contentDispositionHeaderValue; message.GetHeaders().GetHeaderValue (STRING_HEADER_CONTENT_DISPOSITION, contentDispositionHeaderValue); VHTTPHeader::SplitParameters (contentDispositionHeaderValue, dispositionValue, params, true); // YT 25-Jan-2012 - ACI0075142 } if (params.Has (CONST_MIME_PART_FILENAME)) { XBOX::VString fileName; XBOX::VString name; XBOX::VString contentType; XBOX::VString contentID; message.GetHeaders().GetHeaderValue (STRING_HEADER_CONTENT_TYPE, contentType); fileName = params.Get (CONST_MIME_PART_FILENAME); name = params.Get (CONST_MIME_PART_NAME); // Default as "attachment", not "inline". _AddFilePart (name, fileName, false, contentType, contentID, message.GetBody()); } else { XBOX::VString nameString = params.Get (CONST_MIME_PART_NAME); XBOX::VURL::Decode (nameString); _AddValuePair (nameString, CONST_TEXT_PLAIN, message.GetBody().GetDataPtr(), message.GetBody().GetDataSize()); } XBOX::VTask::Yield(); // YT 14-Oct-2013 - ACI0084474 } } void VMIMEMessage::_ReadMultiPartMail (const XBOX::VStream &inStream) { XBOX::VStream &stream = const_cast<XBOX::VStream&>(inStream); VMIMEReader reader(fBoundary, stream); while (reader.HasNextPart()) { XBOX::VHTTPMessage message; reader.GetNextPart(message); // Parse header of part. XBOX::VHTTPHeader header = message.GetHeaders(); const XBOX::VNameValueCollection &headerList = header.GetHeaderList(); XBOX::VNameValueCollection::ConstIterator it; XBOX::VString name, fileName, contentType, contentID; bool isInline, isBase64, isQuotedPrintable; isInline = isBase64 = isQuotedPrintable = false; for (it = headerList.begin(); it != headerList.end(); it++) { XBOX::VString value; XBOX::VNameValueCollection params; if (HTTPTools::EqualASCIIVString(it->first, "Content-Type", false)) { header.GetHeaderValue(it->first, contentType); VHTTPHeader::SplitParameters(contentType, value, params); if (params.Has("name")) { name = params.Get("name"); _UnQuote(&name, '"', '"'); } } else if (HTTPTools::EqualASCIIVString(it->first, "Content-Disposition", false)) { XBOX::VString disposition; header.GetHeaderValue(it->first, value); VHTTPHeader::SplitParameters(value, disposition, params); isInline = HTTPTools::EqualASCIIVString(disposition, "inline"); if (params.Has("filename")) { fileName = params.Get("filename"); _UnQuote(&fileName, '"', '"'); } } else if (HTTPTools::EqualASCIIVString(it->first, "Content-Transfer-Encoding", false)) { XBOX::VString encoding; header.GetHeaderValue(it->first, value); VHTTPHeader::SplitParameters(value, encoding, params); if (!(isBase64 = HTTPTools::EqualASCIIVString(encoding, "base64"))) isQuotedPrintable = HTTPTools::EqualASCIIVString(encoding, "quoted-printable"); } else if (HTTPTools::EqualASCIIVString(it->first, "Content-ID", false)) { header.GetHeaderValue(it->first, value); VHTTPHeader::SplitParameters(value, contentID, params); _UnQuote(&contentID, '<', '>'); } else { // Ignore unknown fields. } } // Get body of part, decode it if need. XBOX::VMemoryBuffer<> decodedData; XBOX::VPtrStream decodedBody; XBOX::VPtrStream *body = message.GetBodyPtr(); if (isBase64) { XBOX::Base64Coder::Decode(body->GetDataPtr(), body->GetDataSize(), decodedData); decodedBody.SetDataPtr(decodedData.GetDataPtr(), decodedData.GetDataSize()); decodedData.ForgetData(); body = &decodedBody; } else if (isQuotedPrintable) { VMIMEReader::DecodeQuotedPrintable (body->GetDataPtr(), body->GetDataSize(), &decodedData); decodedBody.SetDataPtr(decodedData.GetDataPtr(), decodedData.GetDataSize()); decodedData.ForgetData(); body = &decodedBody; } if (fileName.IsEmpty()) _AddTextPart(name, isInline, contentType, contentID, *body); else _AddFilePart(name, fileName, isInline, contentType, contentID, *body); decodedBody.Clear(); XBOX::VTask::Yield(); // YT 14-Oct-2013 - ACI0084474 } } void VMIMEMessage::_ReadSinglePartMail (const VMIMEMailHeader *inHeader, VStream &inStream) { xbox_assert(inHeader != NULL); // Read header information. XBOX::VString name, fileName, contentType, contentID; bool isInline, isBase64, isQuotedPrintable; isInline = isBase64 = isQuotedPrintable = false; XBOX::VString string; XBOX::VNameValueCollection params; if (!inHeader->fContentType.IsEmpty()) { contentType = inHeader->fContentType; VHTTPHeader::SplitParameters(inHeader->fContentType, string, params); if (params.Has("name")) { name = params.Get("name"); _UnQuote(&name, '"', '"'); } } if (!inHeader->fContentDisposition.IsEmpty()) { VHTTPHeader::SplitParameters(inHeader->fContentDisposition, string, params); isInline = HTTPTools::EqualASCIIVString(string, "inline"); if (params.Has("filename")) { fileName = params.Get("filename"); _UnQuote(&fileName, '"', '"'); } } if (!inHeader->fContentTransferEncoding.IsEmpty()) { VHTTPHeader::SplitParameters(inHeader->fContentTransferEncoding, string, params); if (!(isBase64 = HTTPTools::EqualASCIIVString(string, "base64"))) isQuotedPrintable = HTTPTools::EqualASCIIVString(string, "quoted-printable"); } // Read body (a single part). Must be bigger than 5 bytes because of the ending "\r\n.\r\n" sequence. XBOX::VError error; VSize size; if ((error = inStream.OpenReading()) != XBOX::VE_OK) XBOX::vThrowError(error); else if ((size = (VSize) inStream.GetSize()) > 5) { uBYTE *buffer; size -= 5; if ((buffer = new uBYTE[size]) == NULL) XBOX::vThrowError(XBOX::VE_MEMORY_FULL); else { XBOX::VMemoryBuffer<> decodedData; XBOX::VPtrStream decodedBody; inStream.GetData(buffer, size); if (isBase64) { XBOX::Base64Coder::Decode(buffer, size, decodedData); decodedBody.SetDataPtr(decodedData.GetDataPtr(), decodedData.GetDataSize()); decodedData.ForgetData(); } else if (isQuotedPrintable) { VMIMEReader::DecodeQuotedPrintable(buffer, size, &decodedData); decodedBody.SetDataPtr(decodedData.GetDataPtr(), decodedData.GetDataSize()); decodedData.ForgetData(); } else decodedBody.SetDataPtr(buffer, size); inStream.CloseReading(); if (fileName.IsEmpty()) _AddTextPart(name, isInline, contentType, contentID, decodedBody); else _AddFilePart(name, fileName, isInline, contentType, contentID, decodedBody); if (isBase64 || isQuotedPrintable) decodedBody.Clear(); else decodedBody.StealData(); // Prevent VPtrStream from freeing buffer. delete[] buffer; } } else inStream.CloseReading(); } XBOX::VError VMIMEMessage::ToStream (XBOX::VStream& outStream, sLONG inEncoding) const { XBOX::VError error = XBOX::VE_OK; if (XBOX::VE_OK == outStream.OpenWriting()) { outStream.SetCarriageReturnMode(eCRM_CRLF); if (!fMIMEParts.empty()) { XBOX::VString string; XBOX::VString charsetName; bool bEncodeBody; // Encode using base64. for (XBOX::VectorOfMIMEPart::const_iterator it = fMIMEParts.begin(); it != fMIMEParts.end(); ++it) { outStream.PutPrintf ("\r\n--%S\r\n", &fBoundary); string.FromCString ("Content-Type: "); string.AppendString ((*it)->GetMediaType()); if (!(*it)->GetFileName().IsEmpty()) { string.AppendCString ("; name=\""); if (!(*it)->GetName().IsEmpty()) string.AppendString ((*it)->GetName()); else string.AppendString ((*it)->GetFileName()); string.AppendCString("\"\r\nContent-Disposition: "); string.AppendCString((*it)->IsInline() ? "inline; " : "attachment; "); string.AppendCString("filename=\""); string.AppendString ((*it)->GetFileName()); string.AppendCString ("\"\r\n"); if (inEncoding == ENCODING_BINARY) { string.AppendCString ("Content-Transfer-Encoding: 8bit\r\n"); bEncodeBody = false; } else { if ((inEncoding == ENCODING_BINARY_ONLY) && ((*it)->GetMediaTypeKind() == MIMETYPE_TEXT)) { bEncodeBody = false; } else { string.AppendCString ("Content-Transfer-Encoding: base64\r\n"); bEncodeBody = true; } } } else { if ((*it)->GetMediaTypeCharSet() != XBOX::VTC_UNKNOWN) { string.AppendCString ("; charset=\""); XBOX::VTextConverters::Get()->GetNameFromCharSet ((*it)->GetMediaTypeCharSet(), charsetName); string.AppendString (charsetName); string.AppendCString ("\""); } if (!(*it)->GetName().IsEmpty()) { string.AppendCString("; name=\""); string.AppendString((*it)->GetName()); string.AppendCString("\""); } string.AppendCString ("\r\n"); if ((*it)->IsInline()) string.AppendCString("Content-Disposition: inline\r\n"); if (inEncoding == ENCODING_7BIT || ((inEncoding == ENCODING_BINARY_ONLY) && ((*it)->GetMediaTypeKind() != MIMETYPE_TEXT))) { string.AppendCString ("Content-Transfer-Encoding: base64\r\n"); bEncodeBody = true; } else { string.AppendCString("Content-Transfer-Encoding: 8bit\r\n"); bEncodeBody = false; } } if ((*it)->GetContentID().GetLength()) { string.AppendCString("Content-ID: <"); string.AppendString((*it)->GetContentID()); string.AppendCString(">\r\n"); } string.AppendCString ("\r\n"); outStream.PutText (string); if (bEncodeBody) { XBOX::VMemoryBuffer<> buffer; if (XBOX::Base64Coder::Encode ((*it)->GetData().GetDataPtr(), (*it)->GetData().GetDataSize(), buffer, kBASE64_QUADS_PER_LINE)) { outStream.PutData (buffer.GetDataPtr(), buffer.GetDataSize()); } } else { outStream.PutData ((*it)->GetData().GetDataPtr(), (*it)->GetData().GetDataSize()); } } outStream.PutPrintf ("\r\n--%S--\r\n", &fBoundary); } outStream.CloseWriting(); } return error; } void VMIMEMessage::_UnQuote (XBOX::VString *ioString, UniChar inStartQuote, UniChar inEndQuote) { xbox_assert(ioString != NULL); if (ioString->GetLength() >= 2 && ioString->GetUniChar(1) == inStartQuote && ioString->GetUniChar(ioString->GetLength()) == inEndQuote) ioString->SubString(2, ioString->GetLength() - 2); } END_TOOLBOX_NAMESPACE
[ "stephane.hamel@4d.com" ]
stephane.hamel@4d.com
ceb46a0de8c5b66f5e8fff49deeda7d1e9b98be6
e104892af303d85c5e661d099b500dc1e35b882d
/Sample4_12/app/src/main/cpp/bndev/MyVulkanManager.h
0a29bf3df0403a1e89773e0d81670d32418d2646
[ "Unlicense" ]
permissive
siwangqishiq/Vulkan_Develpment_Samples
624900dabaca75c9ad21ef5a1ee5af6709dcc9a8
409c973e0b37086c854cde07b1e620c3d8d9f15d
refs/heads/master
2023-08-16T04:13:54.777841
2021-10-14T06:53:11
2021-10-14T06:53:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,603
h
#ifndef VULKANEXBASE_MYVULKANMANAGER_H #define VULKANEXBASE_MYVULKANMANAGER_H #include <android_native_app_glue.h> #include <vector> #include <vulkan/vulkan.h> #include "../vksysutil/vulkan_wrapper.h" #include <vector> #include "mylog.h" #include "DrawableObjectCommon.h" #include "ShaderQueueSuit_Common.h" #include "Cube.h" #define FENCE_TIMEOUT 100000000 class MyVulkanManager { public: public: static android_app* Android_application; static bool loopDrawFlag; static std::vector<const char *> instanceExtensionNames; static VkInstance instance; static uint32_t gpuCount; static std::vector<VkPhysicalDevice> gpus; static uint32_t queueFamilyCount; static std::vector<VkQueueFamilyProperties> queueFamilyprops; static uint32_t queueGraphicsFamilyIndex; static VkQueue queueGraphics; static uint32_t queuePresentFamilyIndex; static std::vector<const char *> deviceExtensionNames; static VkDevice device; static VkCommandPool cmdPool; static VkCommandBuffer cmdBuffer; static VkCommandBufferBeginInfo cmd_buf_info; static VkCommandBuffer cmd_bufs[1]; static VkSubmitInfo submit_info[1]; static uint32_t screenWidth; static uint32_t screenHeight; static VkSurfaceKHR surface; static std::vector<VkFormat> formats; static VkSurfaceCapabilitiesKHR surfCapabilities; static uint32_t presentModeCount; static std::vector<VkPresentModeKHR> presentModes; static VkExtent2D swapchainExtent; static VkSwapchainKHR swapChain; static uint32_t swapchainImageCount; static std::vector<VkImage> swapchainImages; static std::vector<VkImageView> swapchainImageViews; static VkFormat depthFormat; static VkFormatProperties depthFormatProps; static VkImage depthImage; static VkPhysicalDeviceMemoryProperties memoryroperties; static VkDeviceMemory memDepth; static VkImageView depthImageView; static VkSemaphore imageAcquiredSemaphore; static uint32_t currentBuffer; static VkRenderPass renderPass; static VkClearValue clear_values[2]; static VkRenderPassBeginInfo rp_begin; static VkFence taskFinishFence; static VkPresentInfoKHR present; static VkFramebuffer* framebuffers; static ShaderQueueSuit_Common* sqsCL; //绘制用对象 static Cube* cube1ForDraw; static Cube* cube2ForDraw; //三角形旋转角度 static float zAngle; static float yAngle; //两种视角标志位 static int ProjectPara; static void init_vulkan_instance(); static void enumerate_vulkan_phy_devices(); static void create_vulkan_devices(); static void create_vulkan_CommandBuffer(); static void create_vulkan_swapChain(); static void create_vulkan_DepthBuffer(); static void create_render_pass(); static void init_queue(); static void create_frame_buffer(); static void createDrawableObject(); static void drawObject(); static void doVulkan(); static void initPipeline(); static void createFence(); static void initPresentInfo(); static void initMatrix(); static void flushUniformBuffer(); static void flushTexToDesSet(); static void destroyFence(); static void destroyPipeline(); static void destroyDrawableObject(); static void destroy_frame_buffer(); static void destroy_render_pass(); static void destroy_vulkan_DepthBuffer(); static void destroy_vulkan_swapChain(); static void destroy_vulkan_CommandBuffer(); static void destroy_vulkan_devices(); static void destroy_vulkan_instance(); }; #endif
[ "709165253@qq.com" ]
709165253@qq.com
96eac3462d7af7dbf335defbc10d3bfc4dfbf450
2dcd06afb36378652c851c713e323681d0679242
/Source/effectpattern.cpp
ac2b95d8b2278d66048612fe3e9278049416c403
[]
no_license
LightInMotion/NativeTest
186df26c808a5667434fe8c895bef1ae75ac9b5a
bc6957238a97d120840aa355012f40169811ab70
refs/heads/master
2021-01-10T19:55:50.110959
2016-09-08T23:03:30
2016-09-08T23:03:30
3,811,690
0
0
null
null
null
null
UTF-8
C++
false
false
5,460
cpp
/* Module Description: This module is an 'effect pattern', basically a shape scanned by the effect class. It knows how to load itself from a filename, or from an istream. Effect is a 'friend' because the actual coordinate pairs are fetched directly for speed. */ // Includes .................................................................. #include "EffectPattern.h" // Local Defines ............................................................. // effect file versions. const uint32 _EFFECT_FILE_VERSION_1_00 = 0x0100; // current version const uint32 _EFFECT_FILE_VERSION_CURRENT = _EFFECT_FILE_VERSION_1_00; // Local Data Types .......................................................... // Local Data ................................................................ // Public Interface .......................................................... /* A pattern is asked to load itself from disk here. */ /*---------------------------------------------------------------------------- EffectPattern::EffectPatLoad Load an individual pattern from a file Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::EffectPatLoad (String file) { bool result = false; ShowFile show (file); if (show.open()) { // If we got here, it is structured storage and // is supposed to be an EffectFile // Try to read the info and points if (VerifyVersion(show) == true) if (ReadInfo (show) == true) if (ReadPoints (show) == true) result = true; show.close(); } return result; } /*---------------------------------------------------------------------------- EffectPattern:EffectPatGetGuid Fetch the GUID for a pattern ----------------------------------------------------------------------------*/ void EffectPattern::EffectPatGetGuid (Uuid &guid ) // OUT: Guid to retrieve { guid = m_Guid; } /*---------------------------------------------------------------------------- EffectPattern:EffectPatGetName Fetch the Name for a pattern ----------------------------------------------------------------------------*/ String EffectPattern::EffectPatGetName () { return m_Name; } // Effect File Helpers ....................................................... /* This bundles up the structured storage stuff and version checking, etc. for effect files */ /*---------------------------------------------------------------------------- EffectPattern::VerifyVersion read the effect version from the structore storage file and verify that it is the correct version. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::VerifyVersion (ShowFile& show) { bool result = false; // Save Path String oldpath = show.getPath(); // open version stream if (show.setPath (oldpath + "EffectX1")) { // load effect file version uint32 fileVersion = 0; if (show.readDword (fileVersion)) { // verify the version. Currently we have only one effect file // version and we don't support any other version. // Should we change the file format in a later version then we // have to be able to load new and old versions. if (fileVersion == _EFFECT_FILE_VERSION_CURRENT) result = true; } } show.setPath (oldpath); return result; } /*---------------------------------------------------------------------------- EffectPattern::ReadInfo Get the GUID, name, and count from the effect file. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::ReadInfo (ShowFile& show) // Open file { bool result = false; // Save Path String oldpath = show.getPath(); // open info stream if (show.setPath (oldpath + "Info")) { do { // Load the GUID if (! show.readGuid(m_Guid)) break; // Load the Count if (! show.readShort(m_EffectPatCount) || m_EffectPatCount != EFFECT_PAT_MAX_POINT) break; // Read the name if (! show.readString (m_Name)) break; result = true; } while (0); } show.setPath (oldpath); return result; } /*---------------------------------------------------------------------------- EffectPattern::ReadPoints Get the data points from the effect file. Returns: true or false ----------------------------------------------------------------------------*/ bool EffectPattern::ReadPoints (ShowFile& show) // Open file { bool result = false; // Save Path String oldpath = show.getPath(); // open info stream if (show.setPath (oldpath + "Points")) { uint32 bread; // Load the Points int count = sizeof(EffectPoint) * m_EffectPatCount; if (show.readBytes ((uint8*)(&m_EffectPatData), count, bread) && bread == (uint32)count) result = true; } show.setPath (oldpath); return result; }
[ "jf@emisense.com" ]
jf@emisense.com
dc0cb618f84e622224d029448a048458734459cd
69b7d52bfcb7d25911829658f401e4cbf56ed8f8
/09/code/01.cpp
231dd0f026e3423b04b208951a3bac780c00d079
[]
no_license
jash-git/OpenCV-path-to-exploration
1c8699683cf47466975774b3a51e0e33bde7c6a4
e568f5689f65b341412244bfb968c2c9f5931e92
refs/heads/master
2020-06-19T22:52:11.057275
2019-07-15T06:15:11
2019-07-15T06:15:11
196,903,754
0
0
null
null
null
null
UTF-8
C++
false
false
1,145
cpp
#include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> #include <stdio.h> using namespace std; using namespace cv; int main() { Mat img, templ, result; img = imread("nba.jpg"); templ = imread("76.png"); int result_cols = img.cols - templ.cols + 1; int result_rows = img.rows - templ.rows + 1; result.create(result_cols, result_rows, CV_32FC1); matchTemplate(img, templ, result, CV_TM_SQDIFF_NORMED);//这里我们使用的匹配算法是标准平方差匹配 method=CV_TM_SQDIFF_NORMED,数值越小匹配度越好 normalize(result, result, 0, 1, NORM_MINMAX, -1, Mat()); double minVal = -1; double maxVal; Point minLoc; Point maxLoc; Point matchLoc; cout << "匹配度:" << minVal << endl; minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat()); cout << "匹配度:" << minVal << endl; matchLoc = minLoc; rectangle(img, matchLoc, Point(matchLoc.x + templ.cols, matchLoc.y + templ.rows), Scalar(0, 255, 0), 2, 8, 0); imshow("img", img); waitKey(0); return 0; }
[ "gitea@fake.local" ]
gitea@fake.local
cbf73f5b78d1b0c71b47d3e0f361cfcaaa9bd1b7
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_1674486_1/C++/jdh/pbA.cpp
400a8f6e181975e08b90206f73e5c46b413009e2
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
2,941
cpp
// g++ -std=c++0x #include <iostream> // cout, endl #include <iomanip> // setprecision #include <iterator> // ostream_iterator #include <vector> #include <algorithm> // sort #include <cstring> // memset #include <deque> using namespace std; typedef long long ll; typedef unsigned long long ull; struct Node { ll v,d; }; typedef vector<int> VI; typedef vector<double> VD; typedef vector<ll> VLL; typedef vector<vector<ll> > MLL; typedef vector<ull> VULL; typedef vector<vector<ull> > MULL; typedef vector<Node> VNode; typedef vector<vector<Node> > MNode; #define MAX(a,b) ((a)>(b)?(a):(b)) #define FOR(i,N) for(int i=0;i<(N);++i) #define FORLL(i,N) for(ll i=0;i<(N);++i) #define FORULL(i,N) for(ull i=0;i<(N);++i) #define FOR2(i,A,B) for(int i=(A);i<(B);++i) #define FORLL2(i,A,B) for(ll i=(A);i<(B);++i) #define FORULL2(i,A,B) for(ull i=(A);i<(B);++i) #define SORT(v) sort((v).begin(),(v).end()) #define PB push_back #define PF pop_front #define X first #define Y second #define MATRIX(m,T,size,init) vector<vector<T> > m(size,vector<T>(size,init)); #define FILE __FILE__ << " " #define LINE "line " << __LINE__ << " : " #define FUNC "(function " << __FUNCTION__ << ") " #define log cout<<endl<<FILE<<LINE<<FUNC; #define printL(l) for(auto it=l.begin();it!=l.end();++it) cout<<*it<<","; cout<<endl; #define printM(m) for(auto it=m.begin();it!=m.end();++it){ auto l=*it; for(auto it2=l.begin();it2!=l.end();++it2) cout<<*it2<<","; cout<<endl;} cout<<endl; #define printLNode(lNode) for(auto it=lNode.begin();it!=lNode.end();++it){ Node node=*it; printNode(node); } #define printNode(node) cout<<"("<<node.v<<","<<node.d<<")"<<", "; #define copy(v,T,s) copy((v).begin(),(v).end(),ostream_iterator<T>(cout,s)); cout << endl; #define copyn(v,T,s,n) copy((v).begin(),(v).begin()+n,ostream_iterator<T>(cout,s)); cout << endl; void getRet(ull n,MLL M) { FORLL2(i,1,n) { //cout<<endl<<i<<":"<<endl; VI visited(n,0); deque<ull> d; d.PB(i); while(d.size()>0) { //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; ull a=d.front(); d.PF(); //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; FORLL2(j,1,n) { if(j==i) continue; if(M[a][j]==1) { if(visited[j]==1) { cout<<"Yes"; return; } d.PB(j); //for(auto it=d.begin();it!=d.end();++it) cout<<*it<<","; cout<<endl; visited[j]=1; } } } } cout<<"No"; return; } int main() { int nbCase; cin>>nbCase; //cout<<nbCase<<endl; FOR(i,nbCase) { ull n; cin>>n; //cout<<n<<endl; MLL M(n+1,VLL(n+1,0)); FORLL2(j,1,n+1) { ll nj; cin>>nj; FORLL(k,nj) { ll tmp; cin>>tmp; M[j][tmp]=1; } } //printM(M); cout<<"Case #"<<i+1<<": "; getRet(n+1,M); cout<<endl; } }
[ "eewestman@gmail.com" ]
eewestman@gmail.com
835f58b4577711e00aa48932d1d287b67d08cc32
4c66e1d186ad4b32cd1677bb64d871e09b505ffc
/drivenet_ros/include/ace/config-sunos5.10.h
e4590571fa8e9b6be69d2dbd1796e15f4d5ee3dd
[ "Apache-2.0" ]
permissive
Bangglll/driveworks_ros
0ace6f4bee4cc585b4c9fd01054101c8c09c5186
9f08a8be336cf317bcb36ae058bb8d673d814660
refs/heads/main
2023-08-14T16:46:55.264875
2021-10-03T06:47:17
2021-10-03T06:47:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,866
h
/* -*- C++ -*- */ // $Id: config-sunos5.10.h 2793 2015-11-30 23:09:18Z mitza $ // The following configuration file is designed to work for SunOS 5.10 // (Solaris 10) platforms using the SunC++ 5.x (Sun Studio 8-10), or g++ // compilers. #ifndef ACE_CONFIG_H // ACE_CONFIG_H is defined by one of the following #included headers. // #include the SunOS 5.9 config, then add any SunOS 5.10 updates below. #include "ace/config-sunos5.9.h" // Solaris 10 can do sem_timedwait() (see ACE_OS::sema_wait). #define ACE_HAS_POSIX_SEM_TIMEOUT #define ACE_HAS_SCANDIR // Solaris 10 offers a useable alphasort() unlike previous Solaris versions. #if defined (ACE_LACKS_ALPHASORT) # undef ACE_LACKS_ALPHASORT #endif #undef ACE_LACKS_GETADDRINFO #undef ACE_LACKS_GETNAMEINFO // Solaris 10 offers a useable log2() unlike previous Solaris versions. #if defined (ACE_LACKS_LOG2) # undef ACE_LACKS_LOG2 #endif // Solaris 10 offers a useable isblank() unlike previous Solaris versions. #if defined (ACE_LACKS_ISBLANK) # undef ACE_LACKS_ISBLANK #endif // Solaris 10 delivers pthread_attr_setstack #if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK) # undef ACE_LACKS_PTHREAD_ATTR_SETSTACK #endif // Solaris 10 introduced printf() modifiers for [s]size_t types. #undef ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII #define ACE_SSIZE_T_FORMAT_SPECIFIER_ASCII "%zd" #undef ACE_SIZE_T_FORMAT_SPECIFIER_ASCII #define ACE_SIZE_T_FORMAT_SPECIFIER_ASCII "%zu" // Solaris 10 offers wcstoll() and wcstoull() #if defined (ACE_LACKS_WCSTOLL) # undef ACE_LACKS_WCSTOLL #endif /* ACE_LACKS_WCSTOLL */ #if defined (ACE_LACKS_WCSTOULL) # undef ACE_LACKS_WCSTOULL #endif /* ACE_LACKS_WCSTOULL */ #if defined (ACE_HAS_SCTP) && defined (ACE_HAS_LKSCTP) # define ACE_HAS_VOID_PTR_SCTP_GETLADDRS # define ACE_HAS_VOID_PTR_SCTP_GETPADDRS #endif #define ACE_HAS_SOLARIS_ATOMIC_LIB #endif /* ACE_CONFIG_H */
[ "763k357@naver.com" ]
763k357@naver.com
79f094cb51e708d142f6f5bcf9e3aae3cd0dac00
511f58bc46be60a0215eb46335a783585701c07a
/frq_b.cpp
c3303c414df1466eab2fcf96aabad31667337eff
[]
no_license
sagar-massand/spoj1
6ee6c7b93ba4873dd2a0b43c107f081a3fb69879
56ceac968afc318854ceec4c22267fa64d2c72a8
refs/heads/master
2016-09-06T09:41:04.540897
2013-11-29T12:38:20
2013-11-29T12:38:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,125
cpp
#include<iostream> #include<stdio.h> #include<stdlib.h> #include<algorithm> #include<string.h> #include<math.h> #include<queue> #include<vector> #include<stack> #include<set> using namespace std; #define FOR(i,n) for(i=0;i<n;i++) #define pi(n) printf("%d\n",n); #define pl(n) printf("%lld\n",n); #define ps(c) printf("%s\n",c); #define si(n) scanf("%d",&n); #define sl(n) scanf("%lld",&n); #define ss(n) scanf("%s",n); #define sf(n) scanf("%lf",&n); #define sc(n) scanf(" %c",&n); #define mod 1000000007 #define FORi(i,a,n) for(i=a;i<n;i++) int main() { long long a,b,c,n,t,i,j,k; long long *prime,*prim; prim=(long long *)malloc(1000001*sizeof(long long)); prime=(long long *)malloc(1000001*sizeof(long long)); for(i=3;i<1000000;i+=2) prim[i]=1; prime[0]=2; k=1; for(i=3;i<1000;i+=2) { if(prim[i]==1) { prime[k]=i; k++; for(j=i*i;j<1000000;j+=(2*i)) { prim[j]=0; } } } long long total; for(;i<1000000;i+=2) { if(prim[i]==1) { prime[k]=i; k++; } } total=k; sl(t) FOR(i,t) { long long ans=0,sum,num=k; sl(n) sl(k) for(a=3;a<=n;a++) { }
[ "sagar.massand@gmail.com" ]
sagar.massand@gmail.com
f978428f4f42016702f129d3cc175014e4e5c76b
3c9d8787d9dd84b5402097c1331add04bc7a7f94
/7.23 DP - Min Insertion or Deletion to convert 'a' to 'b'.cpp
db56c70d498ff465e07876dd4221319e86e8a863
[]
no_license
AbhishekPratik1810/my_cpp_dsa_practice
bfc6df01dc2412b39056b5d49791a0ccf105d19a
37e465cf15d162dfaf535fdcf780d5d5225a8575
refs/heads/master
2022-12-09T03:24:24.220974
2020-09-15T17:50:33
2020-09-15T17:50:33
295,805,408
0
0
null
null
null
null
UTF-8
C++
false
false
1,679
cpp
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define endl "\n" #define fo for(int i=0;i<n;i++) #define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n'); #define loopSolve int t; cin>>t; while(t--){solve();} //INT_MAX 2,147,483,647 <10^10 //U_INT_MAX 4,294,967,295 <10^10 //LONG_LONG_MAX 9,223,372,036,854,775,807 <10^18 //U_LONG_LONG_MAX 18,446,744,073,709,551,615 <10^18 /*ll power(int a, int b){ return (ll)(pow(a,b)+0.5); }*/ int getBits(ll num){ return (int)log2(num) + 1; } vector<int> gV(int n){ vector<int> v; int input; fo { cin>>input; v.pb(input); } return v; } int* gA(int n){ int* arr = new int[n]; fo cin>>arr[i]; return arr; } //https://practice.geeksforgeeks.org/problems/minimum-number-of-deletions-and-insertions/0 //x se LCS(x,y) pe pahuncho via x-LCS(x,y) deletion in x. Then LCS se y pe pahuncho by y-LCS(x,y) insertions. Total operations = x-LCS(x,y)+ y-LCS(x,y) = x+y - 2*LCS(x,y) void solve(){ int n,m; cin>>n>>m; string x,y; cin>>x>>y; static int dp[1001][1001]; for(int i=0;i<=1000;i++){ for(int j=0;j<=1000;j++) dp[i][j]=0; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(x[i-1]==y[j-1]) dp[i][j]=dp[i-1][j-1]+1; else dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } } cout<<n+m-(2*dp[n][m])<<endl; } int main() { ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); //solve(); loopSolve; return 0; }
[ "developerpratik18@gmail.com" ]
developerpratik18@gmail.com
8a45b92519f1edbaed47284a7cdb59bdeacd858d
95afc50eea3e69c5cfc150b1f0d031f0da95a1d0
/lib/ldcp_sdk/third_party/Asio/asio-1.18.0/src/tests/unit/ip/address_v6_range.cpp
a11eaf6dfa149c8560bcdaa4baefad326537a895
[ "Apache-2.0", "BSL-1.0" ]
permissive
LitraTech/ltme_node
09a04be74b132993210852c8e712984b678ffc9f
f6733085cfd94072764029f4b00171de969e8637
refs/heads/master
2023-07-19T13:00:39.556775
2023-07-13T04:42:25
2023-07-13T04:42:25
232,500,654
6
12
Apache-2.0
2022-08-10T10:52:00
2020-01-08T07:04:26
C++
UTF-8
C++
false
false
697
cpp
// // address_v6_range.cpp // ~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Disable autolinking for unit tests. #if !defined(BOOST_ALL_NO_LIB) #define BOOST_ALL_NO_LIB 1 #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. #include "asio/ip/address_v6_range.hpp" #include "../unit_test.hpp" //------------------------------------------------------------------------------ ASIO_TEST_SUITE ( "ip/address_v6_range", ASIO_TEST_CASE(null_test) )
[ "dnyang@litratech.com" ]
dnyang@litratech.com
3e5c001d463ce600cf58656641ad7314790e0892
5947865dc56dc2906951f21b780db5dc901848c5
/GeeksforGeeks/Palindrome numbers.cpp
c7fa510064a2cd021b74cfae8543eee738f687e3
[]
no_license
nishu112/Geek-Codes
6d9cad76291d7c56900bd988c0c123db6d900c36
f7eece428655c1f656e402b321260f234de62153
refs/heads/master
2021-10-07T09:31:13.379816
2018-12-04T16:36:54
2018-12-04T16:36:54
121,122,751
0
0
null
null
null
null
UTF-8
C++
false
false
456
cpp
#include<iostream> using namespace std; int main() { int t; cin>>t; while(t--) { long long n; cin>>n; long long num=n,len=0; while(num) { ++len; num=num>>1; } long long i=0,j=len-1; int flag=1; while(j>i) { if((!(n&(1<<i)))!=(!(n&(1<<j)))) { flag=0; break; } --j,++i; } cout<<flag<<'\n'; } return 0; }
[ "nishant.sharma112@gmail.com" ]
nishant.sharma112@gmail.com
e4fcf02029752af7b2304f0e104f0fc50cfc725c
5c0e1b164b1781ef7c1f16c50006a3c56562a451
/examples/ClientProject/SimpleFramework/appSetTime.ino
91beaaedc0099f61f44ccbc20ee08dd072e6f769
[ "MIT" ]
permissive
jakub-vesely/TTGO_TWatch_Library
f4094c352423e11c267d24218801c7edfe00d239
ecb146c25e3ee59da2ed806f95839f1130e7881a
refs/heads/master
2022-12-20T10:27:00.244787
2020-09-22T13:09:56
2020-09-22T13:09:56
297,645,028
0
0
MIT
2020-09-22T12:41:16
2020-09-22T12:41:15
null
UTF-8
C++
false
false
3,670
ino
// Set the time - no error checking, you might want to add it void appSetTime() { // Get the current info RTC_Date tnow = ttgo->rtc->getDateTime(); hh = tnow.hour; mm = tnow.minute; ss = tnow.second; dday = tnow.day; mmonth = tnow.month; yyear = tnow.year; //Set up the interface buttons ttgo->tft->fillScreen(TFT_BLACK); ttgo->tft->fillRect(0, 35, 80, 50, TFT_BLUE); ttgo->tft->fillRect(161, 35, 78, 50, TFT_BLUE); ttgo->tft->fillRect(81, 85, 80, 50, TFT_BLUE); ttgo->tft->fillRect(0, 135, 80, 50, TFT_BLUE); ttgo->tft->fillRect(161, 135, 78, 50, TFT_BLUE); ttgo->tft->fillRect(0, 185, 80, 50, TFT_BLUE); ttgo->tft->setTextColor(TFT_GREEN); ttgo->tft->drawNumber(1, 30, 40, 2); ttgo->tft->drawNumber(2, 110, 40, 2); ttgo->tft->drawNumber(3, 190, 40, 2); ttgo->tft->drawNumber(4, 30, 90, 2); ttgo->tft->drawNumber(5, 110, 90, 2); ttgo->tft->drawNumber(6, 190, 90, 2); ttgo->tft->drawNumber(7, 30, 140, 2); ttgo->tft->drawNumber(8, 110, 140, 2); ttgo->tft->drawNumber(9, 190, 140, 2); ttgo->tft->drawNumber(0, 30, 190, 2); ttgo->tft->fillRoundRect(120, 200, 119, 39, 6, TFT_WHITE); ttgo->tft->setTextSize(2); ttgo->tft->setCursor(0, 0); ttgo->tft->setCursor(155, 210); ttgo->tft->setTextColor(TFT_BLACK); ttgo->tft->print("DONE"); ttgo->tft->setTextColor(TFT_WHITE); int wl = 0; // Track the current number selected byte curnum = 1; // Track which digit we are on prtTime(curnum); // Display the time for the current digit while (wl != 13) { wl = getTnum(); if (wl != -1 && wl != 13) switch (curnum) { case 1: hh = wl * 10 + hh % 10; break; case 2: hh = int(hh / 10) * 10 + wl; break; case 3: mm = wl * 10 + mm % 10; break; case 4: mm = int(mm / 10) * 10 + wl; break; } while (getTnum() != -1) {} curnum += 1; if (curnum > 4) curnum = 1; prtTime(curnum); } } while (getTnum() != -1) {} ttgo->rtc->setDateTime(yyear, mmonth, dday, hh, mm, 0); ttgo->tft->fillScreen(TFT_BLACK); } // prtTime will display the current selected time and highlight // the current digit to be updated in yellow void prtTime(byte digit) { ttgo->tft->fillRect(0, 0, 100, 34, TFT_BLACK); if (digit == 1) ttgo->tft->setTextColor(TFT_YELLOW); else ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawNumber(int(hh / 10), 5, 5, 2); if (digit == 2) ttgo->tft->setTextColor(TFT_YELLOW); else ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawNumber(hh % 10, 25, 5, 2); ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawString(":", 45, 5, 2); if (digit == 3) ttgo->tft->setTextColor(TFT_YELLOW); else ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawNumber(int(mm / 10), 65 , 5, 2); if (digit == 4) ttgo->tft->setTextColor(TFT_YELLOW); else ttgo->tft->setTextColor(TFT_WHITE); ttgo->tft->drawNumber(mm % 10, 85, 5, 2); } // getTnum takes care of translating where we pressed into // a number that was pressed. Returns -1 for no press // and 13 for DONE int getTnum() { int16_t x, y; if (!ttgo->getTouch(x, y)) return - 1; if (y < 85) { if (x < 80) return 1; else if (x > 160) return 3; else return 2; } else if (y < 135) { if (x < 80) return 4; else if (x > 160) return 6; else return 5; } else if (y < 185) { if (x < 80) return 7; else if (x > 160) return 9; else return 8; } else if (x < 80) return 0; else return 13; }
[ "lewisxhe@outlook.com" ]
lewisxhe@outlook.com
395859f1272e37abd8c7b0093e037c35f8c1c1b3
4424eb0c6d2666a37bbe5b9d6b3550ca11d51729
/SerialPrograms/Source/NintendoSwitch/Programs/VirtualConsole.h
897ba33a6d65d445b642053b852997e6089d5346
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
ercdndrs/Arduino-Source
cd87e4036f0e36c3dd0180448293721be95cc654
c0490f0f06aaa38759aa8f11def9e1349e551679
refs/heads/main
2023-05-05T07:43:52.845481
2021-05-24T02:27:25
2021-05-24T02:27:25
369,910,477
0
0
MIT
2021-05-22T21:39:34
2021-05-22T21:39:33
null
UTF-8
C++
false
false
2,248
h
/* Virtual Game Console * * From: https://github.com/PokemonAutomation/Arduino-Source * */ #ifndef PokemonAutomation_VirtualConsole_H #define PokemonAutomation_VirtualConsole_H #include <QJsonObject> #include "Common/Qt/QtJsonTools.h" #include "CommonFramework/Panels/RightPanel.h" #include "CommonFramework/Windows/MainWindow.h" #include "NintendoSwitch/Framework/SwitchSystem.h" namespace PokemonAutomation{ namespace NintendoSwitch{ class VirtualConsoleUI; class VirtualConsole : public RightPanel{ public: VirtualConsole() : RightPanel( QColor(), "Virtual Console", "SerialPrograms/VirtualConsole.md", "Play your Switch from your computer. Device logging is logged to the output window." ) , m_switch( "Switch Settings", "Switch 0", PABotBaseLevel::NOT_PABOTBASE, FeedbackType::NONE ) {} VirtualConsole(const QJsonValue& json) : VirtualConsole() { m_switch.load_json(json.toObject().value(m_name)); } virtual QJsonValue to_json() const override{ return m_switch.to_json(); } virtual QWidget* make_ui(MainWindow& window) override; private: friend class VirtualConsoleUI; SwitchSystemFactory m_switch; }; class VirtualConsoleUI final : public RightPanelUI{ friend class VirtualConsole; private: VirtualConsoleUI(VirtualConsole& factory, MainWindow& window) : RightPanelUI(factory) , m_window(window) {} virtual void make_body(QWidget& parent, QVBoxLayout& layout) override{ VirtualConsole& factory = static_cast<VirtualConsole&>(m_factory); m_switch = (SwitchSystem*)factory.m_switch.make_ui(parent, m_window.output_window()); layout.addWidget(m_switch); // QLabel* controls = new QLabel("Controls", this); // layout.addWidget(controls); } private: MainWindow& m_window; SwitchSystem* m_switch; }; inline QWidget* VirtualConsole::make_ui(MainWindow& window){ VirtualConsoleUI* widget = new VirtualConsoleUI(*this, window); widget->construct(); return widget; } } } #endif
[ "a-yee@u.northwestern.edu" ]
a-yee@u.northwestern.edu
9244c0f202281ff985344b06fe77ae7f77e05ce6
847e5c2984a5d5d425e6a47565a9fb57d15dbe13
/Libraries/LibJS/Lexer.cpp
75ec759f3f9c56a742e6aa56e3a4932e0a2b88b0
[ "BSD-2-Clause" ]
permissive
rizzrackguy/serenity
7616511a187d22b64c65e19a6f5e6cb57e0dc64d
dd00175ae2d6f23b08cb803eb86fc0108c393971
refs/heads/master
2022-04-15T01:14:30.855454
2020-04-12T17:22:42
2020-04-12T17:23:39
255,151,103
0
0
BSD-2-Clause
2020-04-12T19:04:07
2020-04-12T19:04:07
null
UTF-8
C++
false
false
15,213
cpp
/* * Copyright (c) 2020, Stephan Unverwerth <s.unverwerth@gmx.de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "Lexer.h" #include <AK/HashMap.h> #include <AK/StringBuilder.h> #include <ctype.h> #include <stdio.h> namespace JS { HashMap<String, TokenType> Lexer::s_keywords; HashMap<String, TokenType> Lexer::s_three_char_tokens; HashMap<String, TokenType> Lexer::s_two_char_tokens; HashMap<char, TokenType> Lexer::s_single_char_tokens; Lexer::Lexer(StringView source) : m_source(source) , m_current_token(TokenType::Eof, StringView(nullptr), StringView(nullptr), 0, 0) { if (s_keywords.is_empty()) { s_keywords.set("await", TokenType::Await); s_keywords.set("break", TokenType::Break); s_keywords.set("case", TokenType::Case); s_keywords.set("catch", TokenType::Catch); s_keywords.set("class", TokenType::Class); s_keywords.set("const", TokenType::Const); s_keywords.set("continue", TokenType::Continue); s_keywords.set("default", TokenType::Default); s_keywords.set("delete", TokenType::Delete); s_keywords.set("do", TokenType::Do); s_keywords.set("else", TokenType::Else); s_keywords.set("false", TokenType::BoolLiteral); s_keywords.set("finally", TokenType::Finally); s_keywords.set("for", TokenType::For); s_keywords.set("function", TokenType::Function); s_keywords.set("if", TokenType::If); s_keywords.set("in", TokenType::In); s_keywords.set("instanceof", TokenType::Instanceof); s_keywords.set("interface", TokenType::Interface); s_keywords.set("let", TokenType::Let); s_keywords.set("new", TokenType::New); s_keywords.set("null", TokenType::NullLiteral); s_keywords.set("return", TokenType::Return); s_keywords.set("switch", TokenType::Switch); s_keywords.set("throw", TokenType::Throw); s_keywords.set("true", TokenType::BoolLiteral); s_keywords.set("try", TokenType::Try); s_keywords.set("typeof", TokenType::Typeof); s_keywords.set("var", TokenType::Var); s_keywords.set("void", TokenType::Void); s_keywords.set("while", TokenType::While); s_keywords.set("yield", TokenType::Yield); } if (s_three_char_tokens.is_empty()) { s_three_char_tokens.set("===", TokenType::EqualsEqualsEquals); s_three_char_tokens.set("!==", TokenType::ExclamationMarkEqualsEquals); s_three_char_tokens.set("**=", TokenType::AsteriskAsteriskEquals); s_three_char_tokens.set("<<=", TokenType::ShiftLeftEquals); s_three_char_tokens.set(">>=", TokenType::ShiftRightEquals); s_three_char_tokens.set(">>>", TokenType::UnsignedShiftRight); } if (s_two_char_tokens.is_empty()) { s_two_char_tokens.set("=>", TokenType::Arrow); s_two_char_tokens.set("+=", TokenType::PlusEquals); s_two_char_tokens.set("-=", TokenType::MinusEquals); s_two_char_tokens.set("*=", TokenType::AsteriskEquals); s_two_char_tokens.set("/=", TokenType::SlashEquals); s_two_char_tokens.set("%=", TokenType::PercentEquals); s_two_char_tokens.set("&=", TokenType::AmpersandEquals); s_two_char_tokens.set("|=", TokenType::PipeEquals); s_two_char_tokens.set("&&", TokenType::DoubleAmpersand); s_two_char_tokens.set("||", TokenType::DoublePipe); s_two_char_tokens.set("??", TokenType::DoubleQuestionMark); s_two_char_tokens.set("**", TokenType::DoubleAsterisk); s_two_char_tokens.set("==", TokenType::EqualsEquals); s_two_char_tokens.set("<=", TokenType::LessThanEquals); s_two_char_tokens.set(">=", TokenType::GreaterThanEquals); s_two_char_tokens.set("!=", TokenType::ExclamationMarkEquals); s_two_char_tokens.set("--", TokenType::MinusMinus); s_two_char_tokens.set("++", TokenType::PlusPlus); s_two_char_tokens.set("<<", TokenType::ShiftLeft); s_two_char_tokens.set(">>", TokenType::ShiftRight); s_two_char_tokens.set("?.", TokenType::QuestionMarkPeriod); } if (s_single_char_tokens.is_empty()) { s_single_char_tokens.set('&', TokenType::Ampersand); s_single_char_tokens.set('*', TokenType::Asterisk); s_single_char_tokens.set('[', TokenType::BracketOpen); s_single_char_tokens.set(']', TokenType::BracketClose); s_single_char_tokens.set('^', TokenType::Caret); s_single_char_tokens.set(':', TokenType::Colon); s_single_char_tokens.set(',', TokenType::Comma); s_single_char_tokens.set('{', TokenType::CurlyOpen); s_single_char_tokens.set('}', TokenType::CurlyClose); s_single_char_tokens.set('=', TokenType::Equals); s_single_char_tokens.set('!', TokenType::ExclamationMark); s_single_char_tokens.set('-', TokenType::Minus); s_single_char_tokens.set('(', TokenType::ParenOpen); s_single_char_tokens.set(')', TokenType::ParenClose); s_single_char_tokens.set('%', TokenType::Percent); s_single_char_tokens.set('.', TokenType::Period); s_single_char_tokens.set('|', TokenType::Pipe); s_single_char_tokens.set('+', TokenType::Plus); s_single_char_tokens.set('?', TokenType::QuestionMark); s_single_char_tokens.set(';', TokenType::Semicolon); s_single_char_tokens.set('/', TokenType::Slash); s_single_char_tokens.set('~', TokenType::Tilde); s_single_char_tokens.set('<', TokenType::LessThan); s_single_char_tokens.set('>', TokenType::GreaterThan); } consume(); } void Lexer::consume() { if (m_position >= m_source.length()) { m_position = m_source.length() + 1; m_current_char = EOF; return; } if (m_current_char == '\n') { m_line_number++; m_line_column = 1; } else { m_line_column++; } m_current_char = m_source[m_position++]; } void Lexer::consume_exponent() { consume(); if (m_current_char == '-' || m_current_char == '+') consume(); while (isdigit(m_current_char)) { consume(); } } bool Lexer::is_eof() const { return m_current_char == EOF; } bool Lexer::is_identifier_start() const { return isalpha(m_current_char) || m_current_char == '_' || m_current_char == '$'; } bool Lexer::is_identifier_middle() const { return is_identifier_start() || isdigit(m_current_char); } bool Lexer::is_line_comment_start() const { return m_current_char == '/' && m_position < m_source.length() && m_source[m_position] == '/'; } bool Lexer::is_block_comment_start() const { return m_current_char == '/' && m_position < m_source.length() && m_source[m_position] == '*'; } bool Lexer::is_block_comment_end() const { return m_current_char == '*' && m_position < m_source.length() && m_source[m_position] == '/'; } bool Lexer::is_numeric_literal_start() const { return isdigit(m_current_char) || (m_current_char == '.' && m_position < m_source.length() && isdigit(m_source[m_position])); } void Lexer::syntax_error(const char* msg) { m_has_errors = true; if (m_log_errors) fprintf(stderr, "Syntax Error: %s (line: %zu, column: %zu)\n", msg, m_line_number, m_line_column); } Token Lexer::next() { size_t trivia_start = m_position; // consume whitespace and comments while (true) { if (isspace(m_current_char)) { do { consume(); } while (isspace(m_current_char)); } else if (is_line_comment_start()) { consume(); do { consume(); } while (!is_eof() && m_current_char != '\n'); } else if (is_block_comment_start()) { consume(); do { consume(); } while (!is_eof() && !is_block_comment_end()); consume(); // consume * consume(); // consume / } else { break; } } size_t value_start = m_position; auto token_type = TokenType::Invalid; if (is_identifier_start()) { // identifier or keyword do { consume(); } while (is_identifier_middle()); StringView value = m_source.substring_view(value_start - 1, m_position - value_start); auto it = s_keywords.find(value); if (it == s_keywords.end()) { token_type = TokenType::Identifier; } else { token_type = it->value; } } else if (is_numeric_literal_start()) { if (m_current_char == '0') { consume(); if (m_current_char == '.') { // decimal consume(); while (isdigit(m_current_char)) { consume(); } if (m_current_char == 'e' || m_current_char == 'E') { consume_exponent(); } } else if (m_current_char == 'e' || m_current_char == 'E') { consume_exponent(); } else if (m_current_char == 'o' || m_current_char == 'O') { // octal consume(); while (m_current_char >= '0' && m_current_char <= '7') { consume(); } } else if (m_current_char == 'b' || m_current_char == 'B') { // binary consume(); while (m_current_char == '0' || m_current_char == '1') { consume(); } } else if (m_current_char == 'x' || m_current_char == 'X') { // hexadecimal consume(); while (isxdigit(m_current_char)) { consume(); } } else if (isdigit(m_current_char)) { // octal without 'O' prefix. Forbidden in 'strict mode' // FIXME: We need to make sure this produces a syntax error when in strict mode do { consume(); } while (isdigit(m_current_char)); } } else { // 1...9 or period while (isdigit(m_current_char)) { consume(); } if (m_current_char == '.') { consume(); while (isdigit(m_current_char)) { consume(); } } if (m_current_char == 'e' || m_current_char == 'E') { consume_exponent(); } } token_type = TokenType::NumericLiteral; } else if (m_current_char == '"' || m_current_char == '\'') { char stop_char = m_current_char; consume(); while (m_current_char != stop_char && m_current_char != '\n' && !is_eof()) { if (m_current_char == '\\') { consume(); } consume(); } if (m_current_char != stop_char) { syntax_error("unterminated string literal"); token_type = TokenType::UnterminatedStringLiteral; } else { consume(); token_type = TokenType::StringLiteral; } } else if (m_current_char == EOF) { token_type = TokenType::Eof; } else { // There is only one four-char operator: >>>= bool found_four_char_token = false; if (m_position + 2 < m_source.length()) { if (m_current_char == '>' && m_source[m_position] == '>' && m_source[m_position + 1] == '>' && m_source[m_position + 2] == '=') { found_four_char_token = true; consume(); consume(); consume(); consume(); token_type = TokenType::UnsignedShiftRightEquals; } } bool found_three_char_token = false; if (!found_four_char_token && m_position + 1 < m_source.length()) { char second_char = m_source[m_position]; char third_char = m_source[m_position + 1]; char three_chars[] { (char)m_current_char, second_char, third_char, 0 }; auto it = s_three_char_tokens.find(three_chars); if (it != s_three_char_tokens.end()) { found_three_char_token = true; consume(); consume(); consume(); token_type = it->value; } } bool found_two_char_token = false; if (!found_four_char_token && !found_three_char_token && m_position < m_source.length()) { char second_char = m_source[m_position]; char two_chars[] { (char)m_current_char, second_char, 0 }; auto it = s_two_char_tokens.find(two_chars); if (it != s_two_char_tokens.end()) { found_two_char_token = true; consume(); consume(); token_type = it->value; } } bool found_one_char_token = false; if (!found_four_char_token && !found_three_char_token && !found_two_char_token) { auto it = s_single_char_tokens.find(m_current_char); if (it != s_single_char_tokens.end()) { found_one_char_token = true; consume(); token_type = it->value; } } if (!found_four_char_token && !found_three_char_token && !found_two_char_token && !found_one_char_token) { consume(); token_type = TokenType::Invalid; } } m_current_token = Token( token_type, m_source.substring_view(trivia_start - 1, value_start - trivia_start), m_source.substring_view(value_start - 1, m_position - value_start), m_line_number, m_line_column - m_position + value_start); return m_current_token; } }
[ "kling@serenityos.org" ]
kling@serenityos.org
64b8312ae8205d8c02e9019d152c48a7a360f800
cf85f8ee951490dc13648ec5815e022e31bf6676
/src/CryptoNoteCore/CryptoNoteBasic.h
5480a93e1e35346a799d58e47479ab09cacea106
[]
no_license
rainmanp7/phfx
1c61ee112c22e9c942287536891a7bf94bb9a829
c00be01f89ceca09003f4f10bb42ab80a363c9b5
refs/heads/master
2020-03-28T03:04:06.843858
2018-09-07T02:50:01
2018-09-07T02:50:01
147,617,262
0
0
null
null
null
null
UTF-8
C++
false
false
1,377
h
// Copyright (c) 2011-2016 The Cryptonote developers // Copyright (c) 2017-2018 PHF-project developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #pragma once #include <boost/utility/value_init.hpp> #include <CryptoNote.h> namespace CryptoNote { const Crypto::Hash NULL_HASH = boost::value_initialized<Crypto::Hash>(); const Crypto::PublicKey NULL_PUBLIC_KEY = boost::value_initialized<Crypto::PublicKey>(); const Crypto::SecretKey NULL_SECRET_KEY = boost::value_initialized<Crypto::SecretKey>(); KeyPair generateKeyPair(); struct RootBlockSerializer { RootBlockSerializer(RootBlock& rootBlock, uint64_t& timestamp, uint32_t& nonce, bool hashingSerialization, bool headerOnly) : m_rootBlock(rootBlock), m_timestamp(timestamp), m_nonce(nonce), m_hashingSerialization(hashingSerialization), m_headerOnly(headerOnly) { } RootBlock& m_rootBlock; uint64_t& m_timestamp; uint32_t& m_nonce; bool m_hashingSerialization; bool m_headerOnly; }; inline RootBlockSerializer makeRootBlockSerializer(const Block& b, bool hashingSerialization, bool headerOnly) { Block& blockRef = const_cast<Block&>(b); return RootBlockSerializer(blockRef.rootBlock, blockRef.timestamp, blockRef.nonce, hashingSerialization, headerOnly); } }
[ "muslimsoap@gmail.com" ]
muslimsoap@gmail.com
9cef3c531e617dcf519ef5a53c362a7cff4f6206
0975c61a1485440b5d483dccec9bcd1c218be2e9
/Attribute_types.h
51c6c691204727a81c4b3a1bded946cba23fa2d1
[]
no_license
Lipovr/Starmap
71c4ce6cf58eebacc2d64ae82491fc7b83917867
7bc57cb6580fb491bc5c253e93a356da59423a9f
refs/heads/master
2022-10-01T11:48:52.702621
2020-05-26T18:38:02
2020-05-26T18:38:02
267,121,602
0
0
null
null
null
null
UTF-8
C++
false
false
1,481
h
#ifndef ATTRIBUTE_TYPES_H_INCLUDED #define ATTRIBUTE_TYPES_H_INCLUDED namespace ATTRIBUTES{ namespace ATTRIBUTES_TYPE{ enum TYPE{ ///ALL NAME=0, DESCRIPTION, END_TEXT, ///STAR STARCLASS, ECONOMY, //POP, END_LIST, ///WSROUTE //CONNECTED_NAME, UNDEFINED }; } namespace ATTRIBUTES_STAR{ namespace ECONOMY { enum ECONOMY_T{ EXTRACTION=0, REFINERY, INDUSTRIAL, TERRAFORMING, TOURISM, HIGHTECH, AGRICULTURE, END }; } namespace STARCLASS{ enum STARCLASS_T{ O=0, B, A, F, G, K, M, END }; } } } namespace LISTS { const std::vector<std::string> starclass={ "O", "B", "A", "F", "G", "K", "M" }; const std::vector<std::string> economy={ "Extraction", "Refinery", "Industrial", "Terraforming", "Tourism", "Hightech", "Agriculture" }; } #endif // ATTRIBUTE_TYPES_H_INCLUDED
[ "lipov.ra@phystech.edu" ]
lipov.ra@phystech.edu