blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
bbaaa05ac9f6d62faf63b0ac9913a505e68b4ef4
8dd704e6c87309800b0a7a795df181cd563c0bb7
/Source/MuthM/Private/UMGBase/MusicManagerUIBase.cpp
107daf557e0db02cb4f7bdbcc945325ba83c4703
[]
no_license
Jack-Myth/MuthM
2f2ec6da3f14e3039a82178dad23b5ce24f785d0
d3ebe7f9316fc44542c8330b073f8dba9a1a5d07
refs/heads/master
2020-04-03T10:22:54.841332
2019-05-12T15:25:59
2019-05-12T15:25:59
155,191,358
1
0
null
null
null
null
UTF-8
C++
false
false
1,877
cpp
MusicManagerUIBase.cpp
// Copyright (C) 2018 JackMyth. All Rights Reserved. #include "MusicManagerUIBase.h" #include "MuthMBPLib.h" #include "UIProvider.h" #include "MusicImportationUIBase.h" #include "MuthMGameInstance.h" #include "Kismet/GameplayStatics.h" #include "GameHAL.h" #define LOCTEXT_NAMESPACE "MuthM" TArray<FMusicInfo> UMusicManagerUIBase::GetLocalMusicInfo() const { return IMusicManager::Get(this)->GetLocalMusicList(); } void UMusicManagerUIBase::DeleteMusic(int ID) { IMusicManager::Get(this)->DeleteMusic(ID); } void UMusicManagerUIBase::ImportMusic() { TArray<FString> Filters; Filters.Add("MP3"); FGameHAL::Get().OpenFileDialog(LOCTEXT("Select Music", "Select Music").ToString(), "", Filters, false, FOnGetOpenFileName::CreateLambda([=](bool IsSuccessful,TArray<FString> SelectedFileName) { //Currently only support import one music at once. auto UIClass = UUIProvider::Get(this)->GetMusicImportationUI(); auto* UIInstance = Cast<UMusicImportationUIBase>(UUserWidget::CreateWidgetInstance(*GetWorld(), UIClass, NAME_None)); UIInstance->_MusicFileName = SelectedFileName[0]; UIInstance->InitMusicInfo(SelectedFileName[0], "", ""); UIInstance->OnMusicImportFinished.BindLambda([=]() { OnInitMusicList(); }); UIInstance->AddToViewport(102); })); } void UMusicManagerUIBase::UploadMusic(int ID, const FString& Title, const FString& Musician) { auto* GameInstance = Cast<UMuthMGameInstance>(UGameplayStatics::GetGameInstance(this)); auto pSaveGame = GameInstance->GetGlobalSaveGame(); auto* MusicInfo = pSaveGame->MusicInfoCollection.FindByPredicate([&](const FMusicInfo& a) {return a.ID == ID; }); if (MusicInfo) { MusicInfo->Title = Title; MusicInfo->Musician = Musician; } else return; GameInstance->SaveGlobalSaveGame(); IMusicManager::Get(this)->AddMusicUploadTask(ID, Title, Musician); } #undef LOCTEXT_NAMESPACE
8ec1ba7eee60f9979bbf054624465e6433595d55
06e4db0fd47b18c35ab4f7c0f3f8239f7bf086a8
/Contest/Topcoder/DIV1_easy/756_NewBanknote/main.cpp
29ecaf38b5257fb7d0d3d722a2be6f46cb20538a
[]
no_license
StevenMaMei/Competitive-Programming
4ad6dce42a67ff8077a1142d0cc5ef2b0ceafe96
463f9fe91e3e2d900f6def24920012a1b8ffa431
refs/heads/master
2022-12-04T17:38:30.012751
2020-08-25T00:20:52
2020-08-25T00:20:52
216,122,464
0
0
null
null
null
null
UTF-8
C++
false
false
1,705
cpp
main.cpp
#include <bits/stdc++.h> #define ff first #define ss second #define fore(i,a,b) for(int i=a,colchin=b;i<colchin;++i) #define pb push_back #define ALL(s) s.begin(),s.end() #define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define sz(s) int(s.size()) using namespace std; typedef long long ll; class NewBanknote{ int getCoin(int amount, vector<int> &coins){ for(int i=sz(coins)-1;i>=0;i--){ if(coins[i]<=amount)return coins[i]; } assert(false); }; int getAmountCoin(int amount,int newBanknote, vector<int> &coins){ ll mn = amount; for(int i = 0;i<=50000;i++){ ll currAmount = amount; if(i*ll(1)*newBanknote>amount)break; ll cant = 0; if(i != 0){ cant = i; currAmount-= newBanknote*cant; } while(currAmount){ int coin = getCoin(currAmount,coins); cant += currAmount/coin; currAmount %= coin; } mn = min(mn,cant); } return int(mn); } public: vector <int> fewestPieces(int newBanknote, vector <int> amountsToPay){ vector<int> cash= {1, 2, 5, 10, 20, 50, 100, 200 ,500, 1000, 2000, 5000, 10000, 20000, 50000}; sort(cash.begin(),cash.end()); vector<int> ans; fore(i,0,sz(amountsToPay)){ ans.pb(getAmountCoin(amountsToPay[i],newBanknote,cash)); } return ans; }; }; int main(){FIN; NewBanknote b; vector<int> cash = {53, 9400, 9401, 30000}; vector<int> ans=b.fewestPieces(4700,cash); fore(i,0,sz(ans)){ cout<<ans[i]<<" "; } return 0; }
4a1455c2bce09bfa20790c00b10919a9cc6593e0
4cb0f2cfb9ec3ec8c851f83ff3ea73ca5a62aa70
/democodebase/pt/d3d9/rendering/shading_program_fwd.h
e138fb1a2fb76fb6d4c18a2efffc92fe9890f9b2
[]
no_license
Codarki/Pyrotech_2016
99733bb543621d755dc0451cee86e3988021a1e2
5e7a71b9ec751061285f3f784e861ac8f2726ee1
refs/heads/main
2023-05-30T08:11:30.626406
2021-06-24T23:13:53
2021-06-24T23:13:53
380,065,207
0
0
null
null
null
null
UTF-8
C++
false
false
327
h
shading_program_fwd.h
#pragma once #ifndef PT_D3D9_RENDERING_SHADING_PROGRAM_FWD_H #define PT_D3D9_RENDERING_SHADING_PROGRAM_FWD_H #include "pt/std/memory.h" namespace pt { namespace d3d9 { namespace rendering { class shading_program; using shared_shading_program = std::shared_ptr<shading_program>; }}} // namespace pt::d3d9::rendering #endif
a97d2aa64286778d53f810932855a5dafbe5dc65
2fb8fb6cde8aeba59c585728af92fd334f0ae9c9
/tdt-project/src/helpers/AnimationHelper.cpp
7be735cedf3f8fc162acfa08abb3268918070ec1
[]
no_license
Dzejrou/tdt
dca548441fe8ef18c5a69c8cd7e5b1eae11fbe20
209bb5ac6c8c4adc63927719d1e29ac1233b69aa
refs/heads/master
2020-12-28T22:11:21.150592
2016-11-17T19:16:34
2016-11-17T19:16:34
37,917,717
5
2
null
null
null
null
UTF-8
C++
false
false
3,369
cpp
AnimationHelper.cpp
#include <map> #include <Components.hpp> #include <Cache.hpp> #include <systems/EntitySystem.hpp> #include <gui/gui.hpp> #include "AnimationHelper.hpp" #if CACHE_ALLOWED == 1 static tdt::cache::AnimationCache cache{Component::NO_ENTITY, nullptr}; #endif const std::string& AnimationHelper::get_animation_name(ANIMATION_TYPE::VAL animation) { static const std::map<int, std::string> ANIMATIONS{ {ANIMATION_TYPE::WALK, "walk"}, {ANIMATION_TYPE::IDLE, "idle"}, {ANIMATION_TYPE::HIT, "hit"}, {ANIMATION_TYPE::ACTIVATE, "activate"}, {ANIMATION_TYPE::DEACTIVATE, "deactivate"} }; static const std::string NO_ANIMATION{"hit"}; // Not looped and short. auto res = ANIMATIONS.find(animation); if(res != ANIMATIONS.end()) return res->second; else return NO_ANIMATION; } void AnimationHelper::play(EntitySystem& ents, tdt::uint id, ANIMATION_TYPE::VAL type, bool loop, bool stop) { AnimationComponent* animation{nullptr}; GET_COMPONENT(id, ents, animation, AnimationComponent); auto graphics = ents.get_component<GraphicsComponent>(id); if(animation && graphics && graphics->entity && animation->possible_animations.test(type)) { if(animation->current_animation) { animation->current_animation->setEnabled(false); animation->current_animation->setWeight(0.f); animation->current_animation = nullptr; } const auto& animation_name = get_animation_name(type); if(animation_name != "ERROR") { animation->current_animation = graphics->entity->getAnimationState(animation_name); if(animation->current_animation) { animation->current_animation->setWeight(1.f); animation->current_animation->setTimePosition(0.f); animation->current_animation->setEnabled(true); animation->current_animation->setLoop(loop); animation->stop_current_animation = stop; } } } } void AnimationHelper::stop(EntitySystem& ents, tdt::uint id) { AnimationComponent* comp{nullptr}; GET_COMPONENT(id, ents, comp, AnimationComponent); if(comp && comp->current_animation) { comp->current_animation->setWeight(0.f); comp->current_animation->setEnabled(false); comp->current_animation = nullptr; } } void AnimationHelper::add_possible(EntitySystem& ents, tdt::uint id, ANIMATION_TYPE::VAL type) { AnimationComponent* comp{nullptr}; GET_COMPONENT(id, ents, comp, AnimationComponent); if(comp) comp->possible_animations.set(type, true); } void AnimationHelper::delete_possible(EntitySystem& ents, tdt::uint id, ANIMATION_TYPE::VAL type) { AnimationComponent* comp{nullptr}; GET_COMPONENT(id, ents, comp, AnimationComponent); if(comp) comp->possible_animations.set(type, false); } bool AnimationHelper::is_possible(EntitySystem& ents, tdt::uint id, ANIMATION_TYPE::VAL type) { AnimationComponent* comp{nullptr}; GET_COMPONENT(id, ents, comp, AnimationComponent); if(comp) return comp->possible_animations.test(type); else return false; } void AnimationHelper::set_stop_current_animation(EntitySystem& ents, tdt::uint id, bool val) { AnimationComponent* comp; GET_COMPONENT(id, ents, comp, AnimationComponent); if(comp) comp->stop_current_animation = val; } bool AnimationHelper::get_stop_current_animation(EntitySystem& ents, tdt::uint id) { AnimationComponent* comp; GET_COMPONENT(id, ents, comp, AnimationComponent); if(comp) return comp->stop_current_animation; else return false; }
6a11ff77581c1aac6974e15a869c91d99a31b72b
4490e615a756d3f5f99ca7cad478040beeca9375
/Borland C++/Unidad III/A1103168.cpp
f45539fe9daa28ec85ac84a430ae3ceaf25382af
[]
no_license
misaeladame/programacion-estructurada-con-almacenamiento-persistente-de-los-datos
04162ae22a48909aa743bdd3992067cef98ef205
7e7016dd50d958406e17174d90715e4fc6bfc0a2
refs/heads/main
2023-06-11T00:44:16.261384
2021-07-02T00:39:07
2021-07-02T00:39:07
382,189,717
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,313
cpp
A1103168.cpp
// CENTRO DE BACHILLERATO TECNOLOGICO industrial y de servicios No 4 // MÓDULO 1 DE LA ESPECIALIDAD DE PRORGAMACIÓN // Archivo A1103168.CPP // PROGRAMA APLICACION DE PUNTEROS // Lenguaje C++ // Alumno: José Misael Adame Sandoval Gpo:11 NL:03 // Titular: Ing. Juan Antonio Yañez Palafox #include<iostream.h> #include<conio.h> main() { clrscr(); int num, r, val1, val2, val3, val4, val5; int n=1; num=n; int* puntero= &num; cout<<"\n\nIntroduce un valor a Val1 : "; cin>>val1; cout<<"Introduce un valor a Val2 : "; cin>>val2; cout<<"Introduce un valor a Val3 : "; cin>>val3; cout<<"Introduce un valor a Val4 : "; cin>>val4; cout<<"Introduce un valor a Val5 : "; cin>>val5; cout<<"\n\nValor de la variable: " <<val1 <<" Direccion es: " <<&val1; cout<<"\nValor de la variable: " <<val2 <<" Direccion es: " <<&val2; cout<<"\nValor de la variable: " <<val3 <<" Direccion es: " <<&val3; cout<<"\nValor de la variable: " <<val4 <<" Direccion es: " <<&val4; cout<<"\nValor de la variable: " <<val5 <<" Direccion es: " <<&val5; cout<<"\n\n\n\n"; for (r=1; r<=5; r++) cout<<"Variable A iteracion: " <<num++ <<" Direccion: " <<puntero <<endl; getch(); return 0; }
4fb019003480b5813f59e53e38295eae20553fbe
6b54e6130c580b5db35a3051adc7e3b78ebdab89
/c++/main.cpp
fd78628bcfa351b842bf610122ae5d32b7edb701
[]
no_license
healther/pynbody
b541a3d855bd1e2beb0a28cacab7c7425393cd91
7aa9f2e3def584ad6c02a0ab25faf5f68acd5695
refs/heads/master
2021-01-18T19:28:55.574604
2018-01-15T14:58:33
2018-01-15T14:58:33
16,617,242
0
1
null
null
null
null
UTF-8
C++
false
false
1,941
cpp
main.cpp
#include <iostream> #include <ctime> #include "system.h" int main(int argc, char const *argv[]) { std::cout.precision(17); int n = 5; System s1("../test.data"); std::clock_t begin = std::clock(); // System s1(n); int interactions_brute = s1.run(); std::clock_t end = std::clock(); double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; std::cout << elapsed_secs << std::endl; System s2("../test.data"); std::clock_t begin2 = std::clock(); // System s2(n); int interactions_tree = s2.run_tree(.7); std::clock_t end2 = std::clock(); double elapsed_secs2 = double(end2 - begin2) / CLOCKS_PER_SEC; std::cout << elapsed_secs2 << std::endl; System s3("../test.data"); std::clock_t begin3 = std::clock(); // System s3(n); int interactions_fmm = s3.run_fmm(.7); std::clock_t end3 = std::clock(); double elapsed_secs3 = double(end3 - begin3) / CLOCKS_PER_SEC; std::cout << elapsed_secs3 << std::endl; std::cout << interactions_brute << " " << interactions_tree << " " << interactions_fmm << std::endl; for (int i = 0; i < n; ++i) { // std::cout << s1.particles[i].a[0]-s3.particles[i].a[0] << "\t" << s1.particles[i].a[1]-s3.particles[i].a[1] << "\t" << s1.particles[i].a[2]-s3.particles[i].a[2] << std::endl; std::cout << s3.particles[i].a[0] << "\t" << s3.particles[i].a[1] << "\t" << s3.particles[i].a[2] << std::endl; } Vector3D da = Vector3D(0.,0.,0.); double daaver = 0.; double daaver2 = 0.; for (int i = 0; i < n; ++i) { da = s1.particles[i].a - s2.particles[i].a; daaver += (da*da) / (s1.particles[i].a*s1.particles[i].a) / (double)n; da = s1.particles[i].a - s3.particles[i].a; daaver2 += (da*da) / (s1.particles[i].a*s1.particles[i].a) / (double)n; } std::cout << daaver << std::endl; std::cout << daaver2 << std::endl; return 0; }
f1c1d7d06f459758959c9c8ad971a314adbbd014
39959a8d76e9eeaa3e56d62fe35a804776dafb80
/nsefocontract_reader.h
bfec8432b2fa45b7bba23611d951fb70a1f4f802
[]
no_license
Ankur-Chauhan/PortfolioGenerator
6f9344e6fe7066e415e328014a5211d58afbfdcb
9a21ece9fd4c3f1f4fd8c437d788e1d71d2e8077
refs/heads/master
2020-05-05T02:30:06.517091
2019-06-13T07:52:58
2019-06-13T07:52:58
179,640,220
0
0
null
null
null
null
UTF-8
C++
false
false
3,494
h
nsefocontract_reader.h
#ifndef _NSEFO_CONTRACT_READER_H_ #define _NSEFO_CONTRACT_READER_H_ #include <iostream> #include "filereader.h" #include "struct_char.h" class CNSEFOContractFileReader : public CFileReader { enum ENUM_NSEFO_COLUMN_ID : uint16_t { CONTRACT_TOKEN = 0, CONTRACT_ASSETTOKEN = 1, CONTRACT_INSTRUMENT_NAME = 2, CONTRACT_SYMBOL = 3, CONTRACT_SERIES = 4, CONTRACT_EXPIRY_DATE = 6, CONTRACT_STRIKE_PRICE = 7, CONTRACT_OPTION_TYPE = 8, CONTRACT_CA_LEVEL = 10, CONTRACT_PERMITTED_TO_TRADE = 12, CONTRACT_SECURITY_STATUS = 15, //NORMAL MKT CONTRACT_ELIGIBILITY = 15, CONTRACT_MIN_LOT_QTY = 30, CONTRACT_BROAD_LOT_QTY = 31, CONTRACT_TICK_SIZE = 32, CONTRACT_ISSUE_CAPITAL = 33, CONTRACT_FREEZE_QTY = 34, CONTRACT_LOW_PRICE_RANGE = 42, CONTRACT_HIGH_PRICE_RANGE = 43, CONTRACT_NAME = 53, CONTRACT_BASE_PRICE = 67, CONTRACT_DELETE_FLAG = 68, }; public: CNSEFOContractFileReader(const char* pcFullFileName, char chSeparator); ~CNSEFOContractFileReader(); bool GetNextRow(OMSScripInfo& stOMSScripInfo); }; class CIgnoreSymbolReader : public CFileReader { enum ENUM_NSEFO_COLUMN_ID : uint16_t { IGNORE_SYMBOL_NAME = 0, }; public: CIgnoreSymbolReader(const char* pcFullFileName, char chSeparator); ~CIgnoreSymbolReader(); bool GetNextRow(char* pcSymbol); }; class CSymbolFilterReader : public CFileReader { enum ENUM_NSEFO_COLUMN_ID : uint16_t { SYMBOL_FILTER_SYMBOL_NAME = 0, SYMBOL_FILTER_CURR_MONTH_LIST = 1, SYMBOL_FILTER_NEXT_MONTH_LIST = 2, SYMBOL_FILTER_FAR_MONTH_LIST = 3, SYMBOL_FILTER_X_MONTH_LIST = 4, }; public: CSymbolFilterReader(const char* pcFullFileName, char chSeparator); ~CSymbolFilterReader(); bool GetNextRow(tagIndividualSymbolDetails& stIndividualSymbolDetails, char* pcStrikePriceList1, char* pcStrikePriceList2, char* pcStrikePriceList3); }; class CNiftySymbolFilterReader : public CFileReader { enum ENUM_NIFTY_SP_FILTER_ID : uint16_t { SYMBOL_FILTER_SYMBOL_NAME = 0, NIFTY_SP_FILTER_1 = 1, NIFTY_SP_FILTER_2 = 2, NIFTY_SP_FILTER_3 = 3, NIFTY_SP_FILTER_4 = 4, NIFTY_SP_FILTER_5 = 5, NIFTY_SP_FILTER_6 = 6, NIFTY_SP_FILTER_7 = 7, NIFTY_SP_FILTER_8 = 8, NIFTY_SP_FILTER_9 = 9, NIFTY_SP_FILTER_10 = 10, NIFTY_SP_FILTER_11 = 11, NIFTY_SP_FILTER_12 = 12, }; public: CNiftySymbolFilterReader(const char* pcFullFileName, char chSeparator); ~CNiftySymbolFilterReader(); bool GetNextRow(tagSymbolRangeDetails& stSymbolRangeDetails); }; class CStrikePriceReader : public CFileReader { enum ENUM_NSEFO_COLUMN_ID : uint16_t { SYMBOL_FILTER_SYMBOL_NAME = 0, SYMBOL_FILTER_CURR_MONTH_LIST = 1, SYMBOL_FILTER_NEXT_MONTH_LIST = 2, SYMBOL_FILTER_FAR_MONTH_LIST = 3, }; public: CStrikePriceReader(const char* pcFullFileName, char chSeparator); ~CStrikePriceReader(); bool GetNextRow(std::vector<std::string>& szSplitStrings); }; #endif
86c043461989da45c95ea63aae6d68e5ff0029ad
a35b30a7c345a988e15d376a4ff5c389a6e8b23a
/boost/move/core.hpp
35fa24e76fb9c96409052140dccbfa45a736b893
[]
no_license
huahang/thirdparty
55d4cc1c8a34eff1805ba90fcbe6b99eb59a7f0b
07a5d64111a55dda631b7e8d34878ca5e5de05ab
refs/heads/master
2021-01-15T14:29:26.968553
2014-02-06T07:35:22
2014-02-06T07:35:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
55
hpp
core.hpp
#include "thirdparty/boost_1_55_0/boost/move/core.hpp"
5a157592d86fd7fe8ca9bab5c05b51b8500de868
5252a1403e08410272a39c781ebb1b2ebedf74a0
/src/Response.h
a38c27f76665530d189f0b0c1322e02d86d59f63
[]
no_license
kosiachenko/SimpleRPC
aa6a3976a06954455360ce380228c2f8d37a0b9b
d4a36ba1843719371eda47e49f0a3a4bf4db0f6f
refs/heads/master
2021-01-19T11:52:13.393963
2016-11-11T06:25:56
2016-11-11T06:25:56
69,771,606
0
0
null
null
null
null
UTF-8
C++
false
false
495
h
Response.h
#ifndef RESPONSE_H #define RESPONSE_H #include <stdint.h> #include "Point.h" class CartesianResponse { public: int32_t transactionId; int32_t resultCode; double distance; int readFromBuf(char buffer[]); int writeToBuf(char buffer[]); }; class MidpointResponse { public: int32_t transactionId; int32_t resultCode; Point midpoint; int readFromBuf(char buffer[]); int writeToBuf(char buffer[]); }; #endif
5a61288aae496d91ead9585ab31b312ad88eb115
9dd71b679d59f003884e45d96226c0827037647e
/src/MOGL/Rectangle.cpp
19115dd53119d275373e1e39b7c4fed3792c3958
[ "MIT" ]
permissive
llop/hummingbird-MOGL
1bb7cd333e217d303d26b70a354568c39b480db2
e2b723ec9a3762aac650c6335809f55972d9f91a
refs/heads/master
2021-01-22T01:58:26.846741
2016-04-20T13:27:06
2016-04-20T13:27:06
56,935,813
0
0
null
2016-04-23T18:58:58
2016-04-23T18:58:58
null
UTF-8
C++
false
false
1,941
cpp
Rectangle.cpp
#include "Rectangle.hpp" #include "MultimediaOGL.hpp" namespace mogl { Rectangle::Rectangle (double width, double height, const sf::Color& color): p_width(width), p_height(height), p_color(color) {} void Rectangle::init() { float vert[12] = { 0. , 0. , p_width , 0. , p_width , p_height , 0. , 0. , p_width , p_height , 0. , p_height }; glGenVertexArrays(1, &p_VAO); glBindVertexArray(p_VAO); glGenBuffers(1, &p_VBO); glBindBuffer(GL_ARRAY_BUFFER, p_VBO); glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(float), vert, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); setShaderProgram(actor().game().getPlugin<MultimediaOGL>()->shaderPrograms().get("_mogl_plain")); Drawable::init(); } void Rectangle::onDestroy() { Drawable::onDestroy(); glDeleteBuffers(1, &p_VBO); glDeleteVertexArrays(1, &p_VAO); } void Rectangle::setShaderProgram(ShaderProgram* shader_program) { Drawable::setShaderProgram(shader_program); glBindVertexArray(p_VAO); glBindBuffer(GL_ARRAY_BUFFER, p_VBO); p_position_loc = shaderProgram()->bindVertexAttribute("position", 2, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); } void Rectangle::setColor(const sf::Color& color) { p_color = color; } const sf::Color& Rectangle::getColor() const { return p_color; } void Rectangle::draw() { glBindVertexArray(p_VAO); shaderProgram()->setUniform4f("color", static_cast<float>(p_color.r)/255.0f, static_cast<float>(p_color.g)/255.0f, static_cast<float>(p_color.b)/255.0f, static_cast<float>(p_color.a)/255.0f); glEnableVertexAttribArray(p_position_loc); glDrawArrays(GL_TRIANGLES, 0, 6); } const char* Rectangle::behaviorName() { return "mogl::Rectangle"; } }
e225d75357995a0a149944b2e4bb8515263e7c27
967b53eb03404fe6efa9d2b23de297c3f4d1a821
/SNMPv3TestApp.cpp
6e0a9fab7bfe633aa1e2c098b507e83bab863c9b
[ "MIT" ]
permissive
paulorb/SNMP-Samples
154c301ae5663652661fa2774c89aa51f349636d
a733829cc65db7171c28e10cd2a31ffbd497bb06
refs/heads/master
2021-05-06T07:52:37.467873
2017-12-12T10:29:07
2017-12-12T10:29:07
113,974,813
0
0
null
null
null
null
UTF-8
C++
false
false
5,928
cpp
SNMPv3TestApp.cpp
// SNMPv3TestApp.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <net-snmp/net-snmp-config.h> #define HAVE_STRING_H 1 #define HAVE_WINSOCK_H 1 #define HAVE_STDINT_H 1 #define HAVE_STRTOUL 1 #define HAVE_STRTOL 1 #define HAVE_STRDUP 1 #define RETSIGTYPE void #ifdef VS2008 #undef HAVE_STDINT_H typedef unsigned char uint8_t; typedef char int8_t; typedef unsigned __int16 uint16_t; typedef __int16 int16_t; typedef unsigned __int32 uint32_t; typedef __int32 int32_t; typedef unsigned __int64 uint64_t; typedef __int64 int64_t; typedef unsigned __int64 uintmax_t; typedef __int64 intmax_t; #endif typedef int16_t mode_t; #include <net-snmp/net-snmp-includes.h> /* change the word "define" to "undef" to try the (insecure) SNMPv1 version */ #define DEMO_USE_SNMP_VERSION_3 #ifdef DEMO_USE_SNMP_VERSION_3 const char *our_v3_passphrase = "The Net-SNMP Demo Password"; #endif int main(int argc, char ** argv) { netsnmp_session session, *ss; netsnmp_pdu *pdu; netsnmp_pdu *response; oid anOID[MAX_OID_LEN]; size_t anOID_len; netsnmp_variable_list *vars; int status; int count = 1; /* * Initialize the SNMP library */ init_snmp("snmpdemoapp"); debug_register_tokens("all"); snmp_set_do_debugging(1); /* * Initialize a "session" that defines who we're going to talk to */ snmp_sess_init(&session); /* set up defaults */ //192.94.214.205 //test.net-snmp.org session.peername = strdup("192.94.214.205"); /* set up the authentication parameters for talking to the server */ #ifdef DEMO_USE_SNMP_VERSION_3 /* Use SNMPv3 to talk to the experimental server */ /* set the SNMP version number */ session.version = SNMP_VERSION_3; /* set the SNMPv3 user name */ session.securityName = strdup("MD5User"); session.securityNameLen = strlen(session.securityName); /* set the security level to authenticated, but not encrypted */ session.securityLevel = SNMP_SEC_LEVEL_AUTHNOPRIV; /* set the authentication method to MD5 */ session.securityAuthProto = usmHMACMD5AuthProtocol; session.securityAuthProtoLen = sizeof(usmHMACMD5AuthProtocol) / sizeof(oid); session.securityAuthKeyLen = USM_AUTH_KU_LEN; /* set the authentication key to a MD5 hashed version of our passphrase "The Net-SNMP Demo Password" (which must be at least 8 characters long) */ if (generate_Ku(session.securityAuthProto, session.securityAuthProtoLen, (u_char *)our_v3_passphrase, strlen(our_v3_passphrase), session.securityAuthKey, &session.securityAuthKeyLen) != SNMPERR_SUCCESS) { snmp_perror(argv[0]); snmp_log(LOG_ERR, "Error generating Ku from authentication pass phrase. \n"); exit(1); } //Privacy session.securityPrivProto = usmDESPrivProtocol; session.securityPrivProtoLen = sizeof(usmDESPrivProtocol) / sizeof(oid); session.securityPrivKeyLen = USM_PRIV_KU_LEN; if (generate_Ku(session.securityAuthProto, session.securityAuthProtoLen, (u_char *)our_v3_passphrase, strlen(our_v3_passphrase), session.securityPrivKey, &session.securityPrivKeyLen) != SNMPERR_SUCCESS) { exit(1); } #else /* we'll use the insecure (but simplier) SNMPv1 */ /* set the SNMP version number */ session.version = SNMP_VERSION_1; /* set the SNMPv1 community name used for authentication */ session.community = "demopublic"; session.community_len = strlen(session.community); #endif /* SNMPv1 */ /* * Open the session */ SOCK_STARTUP; // ss = snmp_open(&session); /* establish the session */ void * ssret = snmp_sess_open(&session); if (ssret == NULL) { snmp_sess_perror("ack", &session); SOCK_CLEANUP; exit(1); } /* * Create the PDU for the data for our request. * 1) We're going to GET the system.sysDescr.0 node. */ pdu = snmp_pdu_create(SNMP_MSG_GET); anOID_len = MAX_OID_LEN; if (!snmp_parse_oid(".1.3.6.1.2.1.1.1.0", anOID, &anOID_len)) { snmp_perror(".1.3.6.1.2.1.1.1.0"); SOCK_CLEANUP; exit(1); } #if OTHER_METHODS /* * These are alternatives to the 'snmp_parse_oid' call above, * e.g. specifying the OID by name rather than numerically. */ read_objid(".1.3.6.1.2.1.1.1.0", anOID, &anOID_len); get_node("sysDescr.0", anOID, &anOID_len); read_objid("system.sysDescr.0", anOID, &anOID_len); #endif snmp_add_null_var(pdu, anOID, anOID_len); /* * Send the Request out. */ //status = snmp_synch_response(ss, pdu, &response); status = snmp_sess_synch_response(ssret, pdu, &response); /* * Process the response. */ if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR) { /* * SUCCESS: Print the result variables */ for (vars = response->variables; vars; vars = vars->next_variable) print_variable(vars->name, vars->name_length, vars); /* manipuate the information ourselves */ for (vars = response->variables; vars; vars = vars->next_variable) { if (vars->type == ASN_OCTET_STR) { char *sp = (char *)malloc(1 + vars->val_len); memcpy(sp, vars->val.string, vars->val_len); sp[vars->val_len] = '\0'; printf("value #%d is a string: %s\n", count++, sp); free(sp); } else printf("value #%d is NOT a string! Ack!\n", count++); } } else { /* * FAILURE: print what went wrong! */ if (status == STAT_SUCCESS) fprintf(stderr, "Error in packet\nReason: %s\n", snmp_errstring(response->errstat)); else if (status == STAT_TIMEOUT) fprintf(stderr, "Timeout: No response from %s.\n", session.peername); else snmp_sess_perror("snmpdemoapp", ss); } /* * Clean up: * 1) free the response. * 2) close the session. */ if (response) snmp_free_pdu(response); snmp_close(ss); SOCK_CLEANUP; return (0); } /* main() */
9b60b7dda2b8cf51110f0a6d42c6cd1aba2a1b7a
06b5b0d8c7f33ced4ce5ed8589098fef0da73ad5
/POC_MSI_EXPLOIT_BY_HUOJI/global.h
25bdf30261c1a4fe780db485605b85c6e7142e01
[]
no_license
fengjixuchui/Heuristic_antivirus_engine_by_huoji
df0aec8f355fca913a0b2ae1b7e490a82b796b5a
fbd70441f44007c6e785db11bdab96208fcf8666
refs/heads/master
2023-02-03T02:41:43.079587
2020-12-23T07:00:48
2020-12-23T07:00:48
null
0
0
null
null
null
null
GB18030
C++
false
false
474
h
global.h
#pragma once #include "head.h" #include "pe_action.h" class globalvar { public: csh hanlde_capstone; uc_engine* uc_engine; uc_hook hook_code; uc_hook hook_mem; uc_hook hook_mem_unmap; uc_hook hook_mem_write; uc_hook hook_sys_call; std::vector<sim_process> process; //虚拟的进程列表 std::unordered_map<uint64_t, std::string> syscall_tables; }; extern globalvar* g_global; extern pe_action* g_pe; extern virtual_helper* g_virtual; extern ssdt_manager* g_ssdt;
8f17e9cdd75d5722729429a24b8019e45eae2b2f
2c1789716f89a6a4bcd2a572e4d49cbc0b4cdb76
/chaos_engine/include/Event.hpp
075c49a9cdd76e7f2fdb78c742f9ec4f1b395910
[]
no_license
stawrocek/chaos_engine
c2b2a57e9c4e3e8abf6ccf18b4f3f63a399777af
4632ada28b7bbe6f1993d48dc7371100c2712020
refs/heads/master
2020-05-22T06:58:00.765737
2017-12-05T21:23:59
2017-12-05T21:23:59
64,597,097
6
3
null
null
null
null
UTF-8
C++
false
false
3,120
hpp
Event.hpp
#ifndef EVENT_HPP #define EVENT_HPP namespace chaos{ struct CHAOS_EXPORT KeyboardEvent{ enum KeyCode{ Key1='1', Key2='2', Key3='3', Key4='4', Key5='5', Key6='6', Key7='7', Key8='8', Key9='9', KeyA='A', KeyB='B', KeyC='C', KeyD='D', KeyE='E', KeyF='F', KeyG='G', KeyH='H', KeyI='I', KeyJ='J', KeyK='K', KeyL='L', KeyM='M', KeyN='N', KeyO='O', KeyP='P', KeyQ='Q', KeyR='R', KeyS='S', KeyT='T', KeyU='U', KeyV='V', KeyW='W', KeyX='X', KeyY='Y', KeyZ='Z', Key0='0', KeyBackspace=8, KeyTab=9, KeyEnter=13, KeyLeftShift=14, KeyRightShift=15, KeyLeftControl=16, KeyRightControl=17, KeyPause=19, KeyCapsLock=20, KeyEscape=27, KeyPageUp=33, KeyPageDown=34, KeyEnd=35, KeyHome=36, KeyLeftArrow=37, KeyUpArrow=38, KeyRightArrow=39, KeyDownArrow=40, KeyInsert=45, KeyDelete=46, KeyLeftAlt=91, KeyRightAlt=92, KeySelect=93, KeyNum0=96, KeyNum1=97, KeyNum2=98, KeyNum3=99, KeyNum4=100, KeyNum5=101, KeyNum6=102, KeyNum7=103, KeyNum8=104, KeyNum9=105, KeyMultiply=106, KeyPlus=107, KeyMinus=109, KeyDecimalPoint=110, KeyNumDivide=111, KeyF1=112, KeyF2=113, KeyF3=114, KeyF4=115, KeyF5=116, KeyF6=117, KeyF7=118, KeyF8=119, KeyF9=120, KeyF10=121, KeyF11=122, KeyF12=123, KeyNumLock=144, KeyScrollLock=145, KeySemiColon=186, KeyEquals=187, KeyComma=188, KeyDash=189, KeyPeriod=190, KeyForwardSlash=191, KeyBackQuote=192, KeyLeftBracket=219, KeyBackSlash=220, KeyRightBraket=221, KeySingleQuote=222, KeyLeftSuper=223, KeyRightSuper=224 }; KeyCode keyCode; }; struct CHAOS_EXPORT TouchEvent{ enum ButtonCode{ ButtonLeft=0, ButtonMiddle=1, ButtonRight=2 }; ButtonCode buttonCode; GLint posX, posY; }; struct CHAOS_EXPORT MouseMoveEvent{ GLint posX, posY, relX, relY; }; struct CHAOS_EXPORT MouseWheelEvent{ GLint x, y; GLuint direction; }; struct CHAOS_EXPORT TextInputEvent{ char text[32]; }; struct CHAOS_EXPORT Event{ enum EventType{ None=0, KeyDown, KeyUp, TouchDown, TouchUp, MouseMotion, MouseWheel, TextInput }; union{ KeyboardEvent keyEvent; TouchEvent touchEvent; MouseMoveEvent motionEvent; MouseWheelEvent wheelEvent; TextInputEvent textInputEvent; }; EventType type; void* origEvent; }; } #endif // EVENT_HPP
0c29c86fd9eb225f2d9271b282fff447e9fc5d49
0a2e80252d1a359d30e042f0ea9a07621862b35c
/FixedIncomePricingLib/LIBOR.h
a0bce0493640edd523714f4fdb2c03af247a5090
[]
no_license
qli128/FixedIncomePricingLib
d942e6a00448221b6c0a2891b60f6364088bf183
51f86ea8cc41f3c2d3bfed48ea56d27654d09bc3
refs/heads/master
2022-04-22T17:39:10.877341
2020-04-26T18:48:46
2020-04-26T18:48:46
259,465,264
0
0
null
2020-04-27T21:53:36
2020-04-27T21:53:35
null
UTF-8
C++
false
false
1,081
h
LIBOR.h
// // LIBOR.h // AdvCMidTerm // // Created by YinManlin on 2020/4/17. // Copyright © 2020 YinManlin. All rights reserved. // #ifndef LIBOR_h #define LIBOR_h #include <vector> #include <string> #include "OIS.h" class LIBOR : public IDiscount { public: // read in data boost::gregorian::date today; std::vector<boost::gregorian::date> maturity; std::vector<std::string> dayCount; std::vector<std::string> source; std::vector<int> payFreq; std::vector<double> swapRates; // time, fwdrate std::vector<std::tuple<boost::gregorian::date, double>> curve; // zero rate to be implemented // 有点不会算 //std::vector<double> zeroRates; // paras are today's date, tenor, libor file, ois file LIBOR(const boost::gregorian::date &, const double&, const std::string &, OIS&); void Calibrate(const boost::gregorian::date &, const double&, OIS&); double DF(const boost::gregorian::date &T, const std::string &); double fwd(const boost::gregorian::date &T, const std::string &); }; #endif /* LIBOR_h */
985ed27ab8a1fda53efa6127e5d9ecb1e5777cdd
09ea547305ed8be9f8aa0dc6a9d74752d660d05d
/example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.cpp
d8d25b1c947558ca992b85d5f3001c247589e086
[]
no_license
SymbianSource/oss.FCL.sf.mw.socialmobilefw
3c49e1d1ae2db8703e7c6b79a4c951216c9c5019
7020b195cf8d1aad30732868c2ed177e5459b8a8
refs/heads/master
2021-01-13T13:17:24.426946
2010-10-12T09:53:52
2010-10-12T09:53:52
72,676,540
0
0
null
null
null
null
UTF-8
C++
false
false
27,265
cpp
lastfmplaylistserviceplugin.cpp
/** * Copyright (c) 2010 Sasken Communication Technologies Ltd. * All rights reserved. * This component and the accompanying materials are made available * under the terms of the "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html" * * Initial Contributors: * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution * * Contributors: * Sangeeta Prasad, Nalina Hariharan * * Description: * The Plugin that does music services related functionalities from last.fm site * */ // Include files #include <QtPlugin> #include <QDebug> #include <QCryptographicHash> #include <QTextStream> #include <QFile> #include <QMap> #include <QListIterator> #include <QSettings> #include <smfpluginutil.h> #include "lastfmplaylistserviceplugin.h" static int gPageNum = 0; static int gItemsPerPage = 0; //Payload data array QByteArray payload; /** * Destructor */ LastFmPlaylistServicePlugin::~LastFmPlaylistServicePlugin( ) { if(m_provider) delete m_provider; } /** * Method to interpret the key sets obtained from credential manager * @param aApiKey [out] The api key * @param aApiSecret [out] The api secret * @param aSessionKey [out] The session key * @param aToken [out] The session token * @param aName [out] The user name */ void LastFmPlaylistServicePlugin::fetchKeys( QString &aApiKey, QString &aApiSecret, QString &aToken, QString &aName ) { qDebug()<<"Reg Token = "<<m_provider->m_smfRegToken; qDebug()<<"Expiry Date as int = "<<m_provider->m_validity.toTime_t(); SmfAuthParams keys; SmfPluginUtil util; util.getAuthKeys(keys, m_provider->m_smfRegToken, m_provider->m_validity, m_provider->m_pluginId); QByteArray keyName; keyName.append("ApiKey"); aApiKey.append(keys.value(keyName)); keyName.clear(); keyName.append("ApiSecret"); aApiSecret.append(keys.value(keyName)); keyName.clear(); keyName.append("Token"); aToken.append(keys.value(keyName)); keyName.clear(); keyName.append("Name"); aName.append(keys.value(keyName)); qDebug()<<"Api Key = "<<aApiKey; qDebug()<<"Api Secret = "<<aApiSecret; qDebug()<<"Token = "<<aToken; qDebug()<<"Name = "<<aName; } /** * Method called by plugins to generate a signature string from a base string * @param aBaseString The base string * @return The md5 hash of the base string */ QString LastFmPlaylistServicePlugin::generateSignature(const QString aBaseString) { // Create md5 hash of the signature string QByteArray byteArray; byteArray.insert(0, aBaseString.toAscii()); QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex(); QString returnString (md5Hash); return returnString; } /** * Method to get the playlist * @param aRequest [out] The request data to be sent to network * @param aPageNum [in] The page to be extracted * @param aItemsPerPage [in] Number of items per page * @return Appropriate value of the enum SmfPluginError. * Plugin error if any, else SmfPluginErrNone for success */ SmfPluginError LastFmPlaylistServicePlugin::playlists( SmfPluginRequestData &aRequest, const int aPageNum, const int aItemsPerPage ) { qDebug()<<"Inside LastFmPlaylistServicePlugin::playlists()"; SmfPluginError error = SmfPluginErrInvalidArguments; // invalid arguments if( aPageNum < 0 || aItemsPerPage < 0 ) { qDebug()<<"Invalid arguments"; return error; } qDebug()<<"Valid arguments"; gPageNum = aPageNum; gItemsPerPage = aItemsPerPage; qDebug()<<"Pagenumber = "<<gPageNum; // Get the key sets from SMF Plugin Utility class. QString apiKey; QString apiSecret; QString token; QString userName; fetchKeys(apiKey, apiSecret, token, userName); // Create the API signature string QString baseString; baseString.append("api_key"+apiKey); baseString.append("methoduser.getPlaylists"); baseString.append("user"+userName); baseString.append(apiSecret); // Create the url QUrl url("http://ws.audioscrobbler.com/2.0/?"); url.addQueryItem("api_key", apiKey); url.addQueryItem("format", "json"); url.addQueryItem("method", "user.getPlaylists"); url.addQueryItem("user", userName); url.addQueryItem("api_sig", generateSignature(baseString)); // Create the request, set the url aRequest.iNetworkRequest.setUrl(url); aRequest.iRequestType = SmfMusicGetPlaylists; aRequest.iPostData = NULL; aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; error = SmfPluginErrNone; qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString(); return error; } /** * Method to get the playlist of a particular user * @param aRequest [out] The request data to be sent to network * @param aUser [in] The user whose playlists need to be fetched * @param aPageNum [in] The page to be extracted * @param aItemsPerPage [in] Number of items per page * @return Appropriate value of the enum SmfPluginError. * Plugin error if any, else SmfPluginErrNone for success */ SmfPluginError LastFmPlaylistServicePlugin::playlistsOf( SmfPluginRequestData &aRequest, const SmfContact &aUser, const int aPageNum, const int aItemsPerPage ) { qDebug()<<"Inside LastFmPlaylistServicePlugin::playlistsOf()"; SmfPluginError error = SmfPluginErrInvalidArguments; // invalid arguments if( aPageNum < 0 || aItemsPerPage < 0 || aUser.value("Name").value<QContactName>().firstName().isEmpty() ) { qDebug()<<"Invalid arguments"; return error; } qDebug()<<"Valid arguments"; gPageNum = aPageNum; gItemsPerPage = aItemsPerPage; // Get the key sets from SMF Plugin Utility class. QString apiKey; QString apiSecret; QString token; QString userName; fetchKeys(apiKey, apiSecret, token, userName); userName.clear(); userName = aUser.value("Name").value<QContactName>().firstName(); // Create the API signature string QString baseString; baseString.append("api_key"+apiKey); baseString.append("methoduser.getPlaylists"); baseString.append("user"+userName); baseString.append(apiSecret); // Create the url QUrl url("http://ws.audioscrobbler.com/2.0/?"); url.addQueryItem("api_key", apiKey); url.addQueryItem("format", "json"); url.addQueryItem("method", "user.getPlaylists"); url.addQueryItem("user", userName); url.addQueryItem("api_sig", generateSignature(baseString)); // Create the request, set the url aRequest.iNetworkRequest.setUrl(url); aRequest.iRequestType = SmfMusicGetPlaylistsOfUser; aRequest.iPostData = NULL; aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; error = SmfPluginErrNone; qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString(); return error; } /** * Method to add tracks to a playlist * @param aRequest [out] The request data to be sent to network * @param aPlaylist [in] The playlist where tracks should be added * @param aTracks [in] The tracks to be added to the playlist * @return Appropriate value of the enum SmfPluginError. * Plugin error if any, else SmfPluginErrNone for success */ SmfPluginError LastFmPlaylistServicePlugin::addToPlaylist( SmfPluginRequestData &aRequest, const SmfPlaylist &aPlaylist, const QList<SmfTrackInfo> &aTracks ) { qDebug()<<"Inside LastFmPlaylistServicePlugin::addToPlaylist()"; SmfPluginError error = SmfPluginErrInvalidArguments; // invalid arguments if( aPlaylist.id().isEmpty() || (0 == aTracks.count()) ) { qDebug()<<"Invalid arguments"; return error; } else if(aTracks.at(0).title().isEmpty() || aTracks.at(0).artists().names().at(0).isEmpty()) { qDebug()<<"Invalid arguments"; return error; } else qDebug()<<"Valid arguments"; // Get the key sets from SMF Plugin Utility class. QString apiKey; QString apiSecret; QString token; QString userName; fetchKeys(apiKey, apiSecret, token, userName); // Create the API signature string QString baseString; baseString.append("api_key"+apiKey); baseString.append("artist"+aTracks.at(0).artists().names().at(0)); baseString.append("methodplaylist.addTrack"); baseString.append("playlistID"+aPlaylist.id()); baseString.append("sk"+token); baseString.append("track"+aTracks.at(0).title()); baseString.append(apiSecret); QUrl postData; postData.addQueryItem("api_key", apiKey); postData.addQueryItem("artist", aTracks.at(0).artists().names().at(0)); postData.addQueryItem("format","json"); postData.addQueryItem("method", "playlist.addTrack"); postData.addQueryItem("playlistID",aPlaylist.id()); postData.addQueryItem("sk",token); postData.addQueryItem("track",aTracks.at(0).title()); postData.addQueryItem("api_sig", generateSignature(baseString)); QString data(postData.toString()); data.remove(0, 1); // Remove the first ? payload.clear(); payload.append(data.toAscii()); qDebug()<<"Data = "<<QString(payload); // Create the url QUrl url("http://ws.audioscrobbler.com/2.0/"); // Create the request, set the url aRequest.iNetworkRequest.setUrl(url); aRequest.iNetworkRequest.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); aRequest.iRequestType = SmfMusicAddToPlaylist; aRequest.iPostData = new QBuffer(&payload); aRequest.iHttpOperationType = QNetworkAccessManager::PostOperation; error = SmfPluginErrNone; qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString(); return error; } /** * Method to post the current playing playlist * @param aRequest [out] The request data to be sent to network * @param aPlaylist [in] The current playing playlist which should be posted * @return Appropriate value of the enum SmfPluginError. * Plugin error if any, else SmfPluginErrNone for success */ SmfPluginError LastFmPlaylistServicePlugin::postCurrentPlayingPlaylist( SmfPluginRequestData &aRequest, const SmfPlaylist &aPlaylist ) { qDebug()<<"Inside LastFmPlaylistServicePlugin::postCurrentPlayingPlaylist()"; SmfPluginError error = SmfPluginErrInvalidArguments; // invalid arguments /* if( aPlaylist.playListTitle().isEmpty() ) { qDebug()<<"Invalid arguments"; return error; }*/ qDebug()<<"Valid arguments"; // Get the key sets from SMF Plugin Utility class. QString apiKey; QString apiSecret; QString token; QString userName; fetchKeys(apiKey, apiSecret, token, userName); // Create the API signature string QString baseString; baseString.append("api_key"+apiKey); baseString.append("methodplaylist.create"); baseString.append("sk"+token); if( !aPlaylist.playListTitle().isEmpty()) //you can create a playlist without name also baseString.append("title"+aPlaylist.playListTitle()); baseString.append(apiSecret); QUrl postData; postData.addQueryItem("api_key", apiKey); postData.addQueryItem("format","json"); postData.addQueryItem("method", "playlist.create"); postData.addQueryItem("sk",token); if( !aPlaylist.playListTitle().isEmpty()) postData.addQueryItem("title",aPlaylist.playListTitle()); postData.addQueryItem("api_sig", generateSignature(baseString)); QString data(postData.toString()); data.remove(0, 1); payload.clear(); payload.append(data.toAscii()); qDebug()<<"Data = "<<QString(payload); // Create the url QUrl url("http://ws.audioscrobbler.com/2.0/"); // Create the request, set the url aRequest.iNetworkRequest.setUrl(url); aRequest.iNetworkRequest.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); aRequest.iRequestType = SmfMusicPostCurrentPlayingPlaylist; aRequest.iPostData = new QBuffer(&payload); aRequest.iHttpOperationType = QNetworkAccessManager::PostOperation; error = SmfPluginErrNone; qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString(); return error; } /** * Customised method for SmfPlaylistServicePlugin interface * @param aRequest [out] The request data to be sent to network * @param aOperation [in] The operation type (should be known between * the client interface and the plugin) * @param aData [in] The data required to form the request (The type * of data should be known between client and the plugin) * @return Appropriate value of the enum SmfPluginError. * Plugin error if any, else SmfPluginErrNone for success */ SmfPluginError LastFmPlaylistServicePlugin::customRequest( SmfPluginRequestData &aRequest, const int &aOperation, QByteArray *aData ) { Q_UNUSED(aRequest) Q_UNUSED(aOperation) Q_UNUSED(aData) qDebug()<<"Inside LastFmPlaylistServicePlugin::customRequest()"; SmfPluginError error = SmfPluginErrInvalidRequest; return error; } /** * The first method to be called in the plugin that implements this interface. * If this method is not called, plugin may not behave as expected. */ void LastFmPlaylistServicePlugin::initialize( ) { // Create an instance of LastFmMusicServiceProviderBase m_provider = new LastFmPlaylistServiceProviderBase; m_provider->initialize(); } /** * Method to get the provider information * @return Instance of SmfProviderBase */ SmfProviderBase* LastFmPlaylistServicePlugin::getProviderInfo( ) { return m_provider; } /** * Method to get the result for a network request. * @param aOperation The type of operation to be requested * @param aTransportResult The result of transport operation * @param aResponse The QByteArray instance containing the network response. * The plugins should delete this instance once they have read the * data from it. * @param aResult [out] An output parameter to the plugin manager.If the * return value is SmfSendRequestAgain, QVariant will be of type * SmfPluginRequestData. * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult * will be of type SmfMusicProfile. If last operation was searchArtist(), * aResult will be of type QList<SmfArtists>. If last operation was searchAlbum(), * aResult will be of type QList<SmfAlbum>. If last operation was searchEvents(), * aResult will be of type QList<SmfEvent>. If last operation was searchVenue(), * aResult will be of type QList<Smfocation>. If last operation was searchUser(), * aResult will be of type QList<SmfMusicProfile>. If last operation was * postCurrentPlaying() or postRating() or postComments(), aResult will be of * type bool. * @param aRetType [out] SmfPluginRetType * @param aPageResult [out] The SmfResultPage structure variable */ SmfPluginError LastFmPlaylistServicePlugin::responseAvailable( const SmfRequestTypeID aOperation, const SmfTransportResult &aTransportResult, QByteArray *aResponse, QVariant* aResult, SmfPluginRetType &aRetType, SmfResultPage &aPageResult ) { Q_UNUSED(aPageResult) qDebug()<<"Inside LastFmPlaylistServicePlugin::responseAvailable()"; SmfPluginError error = SmfPluginErrNetworkError; if( !aResponse || (0 == aResponse->size()) ) { qDebug()<<"Response is NULL or empty"; aRetType = SmfRequestError; return error; } QByteArray response(*aResponse); delete aResponse; QFile respFile("c://data//SmfMusicPlaylistPluginResponse.txt"); if(!respFile.open(QIODevice::WriteOnly)) qDebug()<<"File to write the response could not be opened"; else { respFile.write(response); respFile.close(); qDebug()<<"Writing FB response to a file named 'SmfMusicPlaylistPluginResponse.txt'"; } qDebug()<<"FB response size = "<<response.size(); if(SmfTransportOpNoError == aTransportResult) { qDebug()<<"No transport error"; // Get user's playlists if(SmfMusicGetPlaylists == aOperation) { qDebug()<<"Response for getting user's playlist"; QList<SmfPlaylist> list; QString errStr; errStr.clear(); bool ok; SmfPluginUtil util; QVariantMap result = util.parse(response, &ok).toMap(); if (!ok) { qDebug()<<"An error occurred during json parsing"; aRetType = SmfRequestError; return SmfPluginErrParsingFailed; } qDebug()<<"Json parsing complete"; if(response.contains(QByteArray("error"))) { errStr.append(result["message"].toString()); } else { QVariantMap map1 = result["playlists"].toMap(); QList<QVariant> list1 = map1["playlist"].toList(); QListIterator<QVariant> iter1(list1); bool ifList = false; while(iter1.hasNext()) { ifList = true; QVariantMap map2 = iter1.next().toMap(); SmfPlaylist playlist; playlist.setPlayListTitle(map2["title"].toString()); playlist.setId(map2["id"].toString()); playlist.setAuthor(map2["creator"].toString()); QUrl url(map2["url"].toString()); playlist.setInfo(url); playlist.setLocation(url); QList<QVariant> list2 = map2["image"].toList(); QListIterator<QVariant> iter2(list2); while(iter2.hasNext()) { QVariantMap map3 = iter2.next().toMap(); QUrl imageUrl(map3["#text"].toString()); playlist.setImage(imageUrl); } list.append((playlist)); if(gItemsPerPage == list.count()) break; } if(!ifList) { QVariantMap map2 = map1["playlist"].toMap(); SmfPlaylist playlist; playlist.setPlayListTitle(map2["title"].toString()); playlist.setId(map2["id"].toString()); playlist.setAuthor(map2["creator"].toString()); QUrl url(map2["url"].toString()); playlist.setInfo(url); playlist.setLocation(url); QList<QVariant> list2 = map2["image"].toList(); QListIterator<QVariant> iter2(list2); while(iter2.hasNext()) { QVariantMap map3 = iter2.next().toMap(); QUrl imageUrl(map3["#text"].toString()); playlist.setImage(imageUrl); } list.append((playlist)); } if(errStr.size()) { qDebug()<<"Response error found = "<<errStr; error = SmfPluginErrInvalidRequest; aRetType = SmfRequestError; aResult->setValue(errStr); } else { qDebug()<<"Count of user's recent tracks = "<<list.count(); aResult->setValue(list); aRetType = SmfRequestComplete; error = SmfPluginErrNone; } } } // Playlists of another user else if ( SmfMusicGetPlaylistsOfUser == aOperation ) { qDebug()<<"Response for getting another user's playlist"; QList<SmfPlaylist> list; QString errStr; errStr.clear(); bool ok; SmfPluginUtil util; QVariantMap result = util.parse(response, &ok).toMap(); if (!ok) { qDebug()<<"An error occurred during json parsing"; aRetType = SmfRequestError; return SmfPluginErrParsingFailed; } qDebug()<<"Json parsing complete"; if(response.contains(QByteArray("error"))) { errStr.append(result["message"].toString()); } else { QVariantMap map1 = result["playlists"].toMap(); QList<QVariant> list1 = map1["playlist"].toList(); QListIterator<QVariant> iter1(list1); bool ifList = false; while(iter1.hasNext()) { ifList = true; QVariantMap map2 = iter1.next().toMap(); SmfPlaylist playlist; playlist.setPlayListTitle(map2["title"].toString()); playlist.setId(map2["id"].toString()); playlist.setAuthor(map2["creator"].toString()); QUrl url(map2["url"].toString()); playlist.setInfo(url); playlist.setLocation(url); QList<QVariant> list2 = map2["image"].toList(); QListIterator<QVariant> iter2(list2); while(iter2.hasNext()) { QVariantMap map3 = iter2.next().toMap(); QUrl imageUrl(map3["#text"].toString()); playlist.setImage(imageUrl); } list.append((playlist)); if(gItemsPerPage == list.count()) break; } if(!ifList) { QVariantMap map2 = map1["playlist"].toMap(); SmfPlaylist playlist; playlist.setPlayListTitle(map2["title"].toString()); playlist.setId(map2["id"].toString()); playlist.setAuthor(map2["creator"].toString()); QUrl url(map2["url"].toString()); playlist.setInfo(url); playlist.setLocation(url); QList<QVariant> list2 = map2["image"].toList(); QListIterator<QVariant> iter2(list2); while(iter2.hasNext()) { QVariantMap map3 = iter2.next().toMap(); QUrl imageUrl(map3["#text"].toString()); playlist.setImage(imageUrl); } list.append((playlist)); } if(errStr.size()) { qDebug()<<"Response error found = "<<errStr; error = SmfPluginErrInvalidRequest; aRetType = SmfRequestError; aResult->setValue(errStr); } else { qDebug()<<"Count of friend's playlists = "<<list.count(); aResult->setValue(list); aRetType = SmfRequestComplete; error = SmfPluginErrNone; } } } // Adding track to playlist AND // Post current playing playlist else if ((SmfMusicAddToPlaylist == aOperation) || (SmfMusicPostCurrentPlayingPlaylist == aOperation)) { qDebug()<<"Response for adding track to playlist"; bool reqSuccess = false; QString errStr; errStr.clear(); bool ok; SmfPluginUtil util; QVariantMap result = util.parse(response, &ok).toMap(); if (!ok) { qDebug()<<"An error occurred during json parsing"; aRetType = SmfRequestError; return SmfPluginErrParsingFailed; } qDebug()<<"Json parsing complete"; if(response.contains(QByteArray("error"))) { errStr.append(result["message"].toString()); } else { reqSuccess = true; } if(errStr.size()) { qDebug()<<"Response error found = "<<errStr; error = SmfPluginErrInvalidRequest; aRetType = SmfRequestError; aResult->setValue(errStr); } else { qDebug()<<"Track added to playlist?? "<<reqSuccess; aResult->setValue(reqSuccess); aRetType = SmfRequestComplete; error = SmfPluginErrNone; } } // Other Service requests - NOT SUPPORTED else { qDebug()<<"Service unsupported!!!"; aRetType = SmfRequestError; error = SmfPluginErrServiceNotSupported; } } else if(SmfTransportOpOperationCanceledError == aTransportResult) { qDebug()<<"Operation Cancelled !!!"; error = SmfPluginErrCancelComplete; aRetType = SmfRequestComplete; } else { qDebug()<<"Transport Error !!!"; error = SmfPluginErrNetworkError; aRetType = SmfRequestError; } return error; } /** * Destructor */ LastFmPlaylistServiceProviderBase::~LastFmPlaylistServiceProviderBase( ) { } /** * Method to get the Localisable name of the service. * @return The Localisable name of the service. */ QString LastFmPlaylistServiceProviderBase::serviceName( ) const { return m_serviceName; } /** * Method to get the Logo of the service * @return The Logo of the service */ QImage LastFmPlaylistServiceProviderBase::serviceIcon( ) const { return m_serviceIcon; } /** * Method to get the Readable service description * @return The Readable service description */ QString LastFmPlaylistServiceProviderBase::description( ) const { return m_description; } /** * Method to get the Website of the service * @return The Website of the service */ QUrl LastFmPlaylistServiceProviderBase::serviceUrl( ) const { return m_serviceUrl; } /** * Method to get the URL of the Application providing this service * @return The URL of the Application providing this service */ QUrl LastFmPlaylistServiceProviderBase::applicationUrl( ) const { return m_applicationUrl; } /** * Method to get the Icon of the application * @return The Icon of the application */ QImage LastFmPlaylistServiceProviderBase::applicationIcon( ) const { return m_applicationIcon; } /** * Method to get the list of interfaces that this provider support * @return List of supported Interafces */ QList<QString> LastFmPlaylistServiceProviderBase::supportedInterfaces( ) const { return m_supportedInterfaces; } /** * Method to get the list of languages supported by this service provider * @return a QStringList of languages supported by this service * provider in 2 letter ISO 639-1 format. */ QStringList LastFmPlaylistServiceProviderBase::supportedLanguages( ) const { return m_supportedLangs; } /** * Method to get the Plugin specific ID * @return The Plugin specific ID */ QString LastFmPlaylistServiceProviderBase::pluginId( ) const { return m_pluginId; } /** * Method to get the ID of the authentication application * for this service * @param aProgram The authentication application name * @param aArguments List of arguments required for authentication app * @param aMode Strting mode for authentication application * @return The ID of the authentication application */ QString LastFmPlaylistServiceProviderBase::authenticationApp( QString &aProgram, QStringList & aArguments, QIODevice::OpenModeFlag aMode ) const { Q_UNUSED(aProgram) Q_UNUSED(aArguments) Q_UNUSED(aMode) return m_authAppId; } /** * Method to get the authentication application process name * @return The authentication application process name (eg: "FlickrAuthApp.exe") */ QString LastFmPlaylistServiceProviderBase::authenticationAppName( ) const { return m_authAppName; } /** * Method to get the unique registration ID provided by the * Smf for authorised plugins * @return The unique registration ID/token provided by the Smf for * authorised plugins */ QString LastFmPlaylistServiceProviderBase::smfRegistrationId( ) const { return m_smfRegToken; } /** * Method that initializes this class. This method should be called * from the initialize() method of the FBContactFetcherPlugin class */ void LastFmPlaylistServiceProviderBase::initialize() { m_serviceName = "last.fm"; m_description = "Last.fm music playlist plugin description"; m_serviceUrl = QUrl(QString("http://www.last.fm")); m_pluginId = "lastfmplaylistserviceplugin.qtplugin"; m_authAppId = "0xE1D8C7D8"; m_authAppName = "LastFm.exe"; m_supportedInterfaces.append("org.symbian.smf.plugin.music.playlist/v0.2"); QSettings iSettings; m_smfRegToken = iSettings.value("CMLastFmRegToken").toString(); m_validity = iSettings.value("LastFmExpiryTime").toDateTime(); } /* * Export Macro * plugin name : lastfmplaylistserviceplugin * plugin class : LastFmPlaylistServicePlugin */ Q_EXPORT_PLUGIN2( lastfmplaylistserviceplugin, LastFmPlaylistServicePlugin )
27916c89758091ff316f2dcfb66a9d46204cae4e
e7ea3bd5fe44237785968aabeb698fa240df5e77
/src/boomerang/frontend/ppc/PPCFrontEnd.h
b21b6d18ffd24bcc70a7c4ca90da3582d3c8fbaa
[ "BSD-3-Clause" ]
permissive
powerbf/boomerang
88ccc6823c5804773bfd29f18cfc7f7140365045
a56379e246dd509b9fda5d27f1bbf8b5a9e8741f
refs/heads/develop
2020-04-10T09:25:54.713694
2018-12-09T13:13:49
2018-12-09T13:13:49
160,936,028
0
0
NOASSERTION
2018-12-09T11:50:28
2018-12-08T12:16:18
C++
UTF-8
C++
false
false
1,075
h
PPCFrontEnd.h
#pragma region License /* * This file is part of the Boomerang Decompiler. * * See the file "LICENSE.TERMS" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL * WARRANTIES. */ #pragma endregion License #pragma once #include "boomerang/frontend/DefaultFrontEnd.h" /** * Contains routines to manage the decoding of PPC binaries. */ class PPCFrontEnd : public DefaultFrontEnd { public: /// \copydoc IFrontEnd::IFrontEnd PPCFrontEnd(BinaryFile *binaryFile, Prog *prog); PPCFrontEnd(const PPCFrontEnd &other) = delete; PPCFrontEnd(PPCFrontEnd &&other) = default; /// \copydoc IFrontEnd::~IFrontEnd virtual ~PPCFrontEnd() override = default; PPCFrontEnd &operator=(const PPCFrontEnd &other) = delete; PPCFrontEnd &operator=(PPCFrontEnd &&other) = default; public: /// \copydoc IFrontEnd::processProc virtual bool processProc(UserProc *proc, Address entryAddr) override; /// \copydoc IFrontEnd::getMainEntryPoint virtual Address findMainEntryPoint(bool &gotMain) override; };
2c211c2e2520c4d18e4cf52e6f2cd3cb5ff25362
89f50ef35094128902548859bce5dc2cd662b123
/src/Dragon.cpp
12ff601d5130fb02339eb78ec80f0f91f35e9f1a
[]
no_license
pmeade/dragons
67407bcaa1941e5892462ced6da2da253ac3ddd3
9f21a53736f4bc0dd058905487b16fda4b554864
refs/heads/master
2020-04-28T20:18:00.549372
2019-04-17T04:31:00
2019-04-17T04:31:00
175,539,898
0
0
null
null
null
null
UTF-8
C++
false
false
70
cpp
Dragon.cpp
// // Created by Patrick Meade on 2019-03-07. // #include "Dragon.h"
33d99471b9c245642a3f093ee8cff37024278da5
08fd6feb2638d85bb6adc493e1cc84a2783c7674
/sys/easynet_condition.cc
e397688fe252b49e6b8b15735b69d6b6794f766f
[]
no_license
garyluojian/easynet
ccf8cfb51ebe820ee5ce8c326a06020b842bf70a
9cebe750a220b8c8f6405455f6ec023b2063554a
refs/heads/master
2021-06-12T14:54:11.953280
2019-01-13T12:20:11
2019-01-13T12:20:11
96,901,504
0
0
null
null
null
null
UTF-8
C++
false
false
1,132
cc
easynet_condition.cc
#include "easynet_condition.h" #include "easynet_mutex.h" #include <time.h> #include <errno.h> namespace easynet { namespace sys { void easynet_condition::wait() { int rc = pthread_cond_wait(&_native_cond_handle, _mutex_handle.get_mutex_native_handle()); } void easynet_condition::notify() { int rc = pthread_cond_signal(&_native_cond_handle); } void easynet_condition::notify_all() { int rc = pthread_cond_broadcast(&_native_cond_handle); } bool easynet_condition::time_wait(uint64_t timeout) { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); uint64_t sec = timeout / 1000; uint64_t nsec = (timeout % 1000) * 1e6; ts.tv_sec += static_cast<time_t>(sec); ts.tv_nsec += static_cast<long>(nsec); int rc = pthread_cond_timedwait(&_native_cond_handle, _mutex_handle.get_mutex_native_handle(), &ts); return rc == ETIMEDOUT ? true : false; } } }
5d265ebc2eb8711d77d8c596dc8143b126308647
ed66f90f96d76c0beb7687acef130d69c61ae919
/swri_profiler/swri_profiler_tools/src/profiler_msg_adapter.cpp
ec243d95b142119fe674846e03bd41b94b9a4176
[ "BSD-3-Clause" ]
permissive
RLWBruins/boxcuttingrobot
2b32727aa9ffc27fc3387f3f48cadd1c2714cfb8
cfefe569150fd96944ad113996bcf569bdff932a
refs/heads/master
2020-11-27T14:00:20.855161
2019-12-21T19:24:28
2019-12-21T19:24:28
229,473,770
3
1
null
null
null
null
UTF-8
C++
false
false
2,853
cpp
profiler_msg_adapter.cpp
#include <swri_profiler_tools/profiler_msg_adapter.h> #include <swri_profiler_tools/util.h> namespace swri_profiler_tools { ProfilerMsgAdapter::ProfilerMsgAdapter() { } ProfilerMsgAdapter::~ProfilerMsgAdapter() { } void ProfilerMsgAdapter::processIndex(const swri_profiler_msgs::ProfileIndexArray &msg) { const QString ros_node_name = normalizeNodePath(QString::fromStdString(msg.header.frame_id)); // An index message contains the entire index table for the message, // so we wipe out any existing index to make sure we are completely // in sync. index_[ros_node_name].clear(); for (auto const &item : msg.data) { QString label = normalizeNodePath(QString::fromStdString(item.label)); // This is a special case to handle nodelets nicely, and it works // when users design their labels intelligently by wrapping each // ROS callback with a SWRI_PROFILE(getName()). If the // nodelet is run as part of a nodelet manager, the node name and // nodelet name will differ and we want to append the node name to // allow us to guage the relative runtimes of all the instrumented // nodelets in that manager. If the nodelet is run standalone, // then the nodelet name and node name will be the same and we // don't need to duplicate it. if (!label.startsWith(ros_node_name)) { label = ros_node_name + label; } index_[ros_node_name][item.key] = label; } } bool ProfilerMsgAdapter::processData( NewProfileDataVector &out_data, const swri_profiler_msgs::ProfileDataArray &msg) { const QString node_name(QString::fromStdString(msg.header.frame_id)); if (index_.count(node_name) == 0) { qWarning("No index for node '%s'. Dropping data update.", qPrintable(node_name)); return false; } int timestamp_sec = std::round(msg.header.stamp.toSec()); NewProfileDataVector out; out.reserve(msg.data.size()); for (auto const &item : msg.data) { if (index_[node_name].count(item.key) == 0) { qWarning("No index for block %d of %s. Dropping all data " "because index is probably invalid.", item.key, qPrintable(node_name)); return false; } out.emplace_back(); out.back().label = index_[node_name][item.key]; out.back().wall_stamp_sec = timestamp_sec; out.back().ros_stamp_ns = msg.rostime_stamp.toNSec(); out.back().cumulative_call_count = item.abs_call_count; out.back().cumulative_inclusive_duration_ns = item.abs_total_duration.toNSec(); out.back().incremental_inclusive_duration_ns = item.rel_total_duration.toNSec(); out.back().incremental_max_duration_ns = item.rel_max_duration.toNSec(); } out_data.insert(out_data.end(), out.begin(), out.end()); return true; } void ProfilerMsgAdapter::reset() { index_.clear(); } }; // namespace swri_profiler_tools
a69157a0fa6c03813aef6ec3df3ddbfedd112485
8e45543c50288165bc5c04640b97dc71c2f3daf7
/3B_Pulsador_tone/3B_Pulsador_tone.ino
71b7afe9cc0285822fcc0c08e61a05717a734c0a
[]
no_license
ingJE/CatedraRobotica
09a9828095d908e7f4e6d63519978eb8daaf1b0b
5f99b5db615cbe8583326dd03b9cf5bd1632a647
refs/heads/master
2020-09-12T06:31:13.710994
2019-11-18T15:38:50
2019-11-18T15:38:50
81,767,355
0
0
null
null
null
null
UTF-8
C++
false
false
919
ino
3B_Pulsador_tone.ino
/* Pulsador Zumbador Sistema para controlar un zumbador con un pulsador Hardware: Pulsador pin 2 Zumbador pin 12 */ // constantes que no cambian se usan para establecer los pines const int pulsadorPin = 2; // el numero del pin del pulsador const int buzzerPin = 12; // el numero de pin del zumbador // variables que cambian int estadoPulsador = 0; // variable para almacenar el estado del pulsador void setup() { pinMode(pulsadorPin, INPUT); // inicializa el pulsador como entrada } void loop() { estadoPulsador = digitalRead(pulsadorPin); // lee el estado del pulsador y lo //almacena en la variable if (estadoPulsador == HIGH) { // revisa si el pulsador esta presionado tone(buzzerPin, 523); // activa el zumbador C5: 523 delay(1000); noTone(buzzerPin); delay(1000); } }
6ff2b3769e51936c43536c555e9d069676b45571
f4202aca203ca63c8ee485954314bb9b7562e777
/src/Entitatmobil.h
4fa73e07dd8d727685e6767a60cee7bc54977b0e
[]
no_license
utrescu/Gol
adb7feae1f42c5b2866bd70aa45742fd1aae42ea
042226db30bb5e8ddc132397c41ec5909805c724
refs/heads/master
2021-05-09T19:37:19.271029
2019-06-03T13:48:17
2019-06-03T13:48:17
118,652,652
0
0
null
null
null
null
UTF-8
C++
false
false
3,037
h
Entitatmobil.h
/*************************************************************************** * Copyright (C) 2006 by Xavier Sala * * utrescu@xaviersala.net * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef ENTITATMOBIL_H #define ENTITATMOBIL_H #include "Entitat.h" /** @author Xavier Sala <utrescu@xaviersala.net> */ class EntitatMobil : public Entitat { public: protected: Punt3 LlocAnterior; Punt3 Velocitat; // Ens diu cap on va l'objecte o on vol anar Punt3 MirantA; // Diu cap on està mirant Punt3 m_vSide; //Perpendicular a on mirem double Forca; double Massa; // double Altura; double maximaVelocitat; double maximaForca; double maximaRotacio; public: EntitatMobil(double rad, Punt3 veloc, double maxveloc, Punt3 mirant, double massa, double maxgir, double maxforce); ~EntitatMobil(); double getVelocitatMaxima()const{return maximaVelocitat;} void setVelocitatMaxima(double speed){maximaVelocitat = speed;} double getForcaMaxima()const{return maximaForca;} void setForcaMaxima(double mf){maximaForca = mf;} // bool IsSpeedMaxedOut()const{return m_dMaxSpeed*m_dMaxSpeed >= m_vVelocity.LengthSq();} double getVelocitat()const{return Velocitat.Llargada();} Punt3 getVectorVelocitat() const { return Velocitat; } void setVelocitat(Punt3 vel) { Velocitat = vel; } // double SpeedSq()const{return m_vVelocity.LengthSq();} Punt3 getMirant()const{return MirantA;} void setMirant(Punt3 AraA); bool RodaCapA(Punt3 objectiu); void RodaCapASenseLimit(Punt3 objectiu); Punt3 getCostat() const { return m_vSide; } double getRotacioMaxima()const{return maximaRotacio;} void setRotacioMaxima(double val){maximaRotacio = val;} }; #endif
8467af5ee852e6b3d778bc052ea5ab0af4631c25
cecfda84e25466259d3ef091953c3ac7b44dc1fc
/UVa Online Judge/volume123/12366 King's Poker/program1.cpp
24ace3fe39d4f0f264c6f2d042f9b410b252d4a3
[]
no_license
metaphysis/Code
8e3c3610484a8b5ca0bb116bc499a064dda55966
d144f4026872aae45b38562457464497728ae0d6
refs/heads/master
2023-07-26T12:44:21.932839
2023-07-12T13:39:41
2023-07-12T13:39:41
53,327,611
231
57
null
null
null
null
UTF-8
C++
false
false
2,219
cpp
program1.cpp
// King's Poker // UVa ID: 12366 // Verdict: Accepted // Submission Date: 2021-12-09 // UVa Run Time: 0.000s // // 版权所有(C)2021,邱秋。metaphysis # yeah dot net #include <bits/stdc++.h> using namespace std; const int SET = 3, PAIR = 2, UNPAIR = 1; struct hand { int A, B, C; hand (int a = 0, int b = 0, int c = 0) { A = a, B = b, C = c; if (A > B) swap(A, B); if (B > C) swap(B, C); if (A > B) swap(A, B); } int getRank() const { if (A == B && B == C) return SET; if (A == B || B == C) return PAIR; return UNPAIR; } bool operator<(const hand& h) const { int r1 = getRank(), r2 = h.getRank(); if (r1 != r2) return r1 < r2; if (r1 == SET) return A < h.A; if (r1 == UNPAIR) { if (A != h.A) return A < h.A; if (B != h.B) return B < h.B; return C < h.C; } r1 = A == B ? A : B; r2 = h.A == h.B ? h.A : h.B; if (r1 != r2) return r1 < r2; r1 = A == B ? C : A; r2 = h.A == h.B ? h.C : h.A; return r1 < r2; } bool operator==(const hand &h) const { return A == h.A && B == h.B && C == h.C; } }; int main(int argc, char *argv[]) { cin.tie(0), cout.tie(0), ios::sync_with_stdio(false); vector<hand> hands; for (int i = 1; i <= 13; i++) for (int j = 1; j <= 13; j++) for (int k = 1; k <= 13; k++) hands.push_back(hand(i, j, k)); sort(hands.begin(), hands.end()); hands.erase(unique(hands.begin(), hands.end()), hands.end()); //for (int i = 0; i < hands.size(); i++) // cout << hands[i].A << ' ' << hands[i].B << ' ' << hands[i].C << '\n'; //return 0; int A, B, C; while (cin >> A >> B >> C) { if (A == 0) break; hand h = hand(A, B, C); if (h.getRank() == UNPAIR) cout << "1 1 2\n"; else { int k = upper_bound(hands.begin(), hands.end(), h) - hands.begin(); if (k >= hands.size()) cout << "*\n"; else cout << hands[k].A << ' ' << hands[k].B << ' ' << hands[k].C << '\n'; } } return 0; }
3347ee7e43363c689061bfd8596c5ff42e27b638
9186363f9f517857c565347238b52cd29e13e6bb
/SpringMassMesh.h
df977f9bb937d060ab7373908a363263f3171204
[ "MIT" ]
permissive
aWilson41/TetrahedralSpringMassSim
7616abe284423b85130f87bc3381a0bbdc0b7f8e
f37a56547c4d07d9b30e3da1ed9c3a1ca63bb981
refs/heads/master
2021-09-10T13:27:40.679223
2018-03-26T23:48:39
2018-03-26T23:48:39
125,916,498
2
0
null
null
null
null
UTF-8
C++
false
false
430
h
SpringMassMesh.h
#pragma once #include "Engine\MathHelper.h" #include "Engine\Polygon.h" #include "Spring.h" #include "Particle.h" class SpringMassMesh : public Poly { public: void setupSpringMesh(); void setupSpringMesh(GLuint* indices, int size); void update(GLfloat dt, GLfloat g); void calculateNormals(); protected: std::vector<Particle> particles; std::vector<Spring> springs; public: std::vector<std::vector<Face*>> neighbors; };
3e78d6db38a7477df76902eb66c132ea668b3f7c
4a92d9c414cfde2e89ab72b48ec775779846a668
/NinAtHome/HighFrame/HFCommon.h
5ea4f0d518ea6f47315b2c93a0a5820e36d1a1da
[]
no_license
HIBICUS-CAI/BowAndArrow
bc5e287c09873eb8565f954b5b9fccd5ca68f62b
d3face3a6b7c5ca613e19a43838e4edaaf864621
refs/heads/master
2023-08-23T11:21:51.804797
2021-10-11T02:30:25
2021-10-11T02:30:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,454
h
HFCommon.h
//--------------------------------------------------------------- // File: HFCommon.h // Proj: NinAtHome // Info: HighFrameに対して必要なヘッダーファイル // Date: 2021.06.09 // Mail: cai_genkan@outlook.com // Comt: NULL //--------------------------------------------------------------- #pragma once #include "main.h" #define APP_FPS (60) #define MAX_DELTA (float)((double)1 / (double)APP_FPS) #define SHOW_LOADING enum class STATUS { NEED_INIT, ACTIVE, PAUSE, NEED_DESTORY }; enum class OBJ_TYPE { ACTOR, UI, NULLTYPE }; enum class COMP_TYPE { ATRANSFORM, ATIMER, ASPRITE, ACOLLISION, AINPUT, AANIMATE, AINTERACT, UTRANSFORM, UINPUT, UTEXT, USPRITE, UBTNMAP, UINTERACT, NULLTYPE }; using ActorInputProcessFuncType = void(*)( class AInputComponent*, float); using ActorInterInitFuncType = void(*)( class AInteractionComponent*); using ActorInterUpdateFuncType = void(*)( class AInteractionComponent*, float); using ActorInterDestoryFuncType = void(*)( class AInteractionComponent*); using UiInputProcessFuncType = void(*)( class UInputComponent*, float); using UiInterInitFuncType = void(*)( class UInteractionComponent*); using UiInterUpdateFuncType = void(*)( class UInteractionComponent*, float); using UiInterDestoryFuncType = void(*)( class UInteractionComponent*); #define FUNC_NAME(funcName) #funcName
dc43993ef1bf88351e6024bf8e69d64679878a46
978d8cbca5d97bb8d463ac53720ffba77a548d71
/include/ouchilib/units/si.hpp
e6a66f84f4bc6dba06bf49d6744b0f7a88db1796
[ "MIT" ]
permissive
ouchiminh/ouchilib
b29a077d7e925a2e7e0630a9ac13be7b4f7d230b
de1bab0aa75c9e567ce06d76c95bc330dffbf52e
refs/heads/master
2021-06-24T19:00:39.614613
2020-11-13T15:55:15
2020-11-13T15:55:15
174,334,491
1
0
MIT
2020-07-27T08:33:48
2019-03-07T11:49:59
C++
UTF-8
C++
false
false
2,149
hpp
si.hpp
#pragma once #include "units.hpp" namespace ouchi::units::si { struct length {}; struct mass {}; struct time {}; struct intensity {}; struct thermodynamic_temperature {}; struct amount {}; struct luminous_intensity {}; using si = system_of_units<length, mass, time, intensity, thermodynamic_temperature, amount, luminous_intensity>; using dimensionless_t = si::dimensionless_t; using meter_t = typename si::template unit_t<length>; using gram_t = typename si::template unit_t<mass>; using kilogram_t = typename si::template unit_t<mass, 1, std::kilo>; using second_t = typename si::template unit_t<time>; using ampere_t = typename si::template unit_t<intensity>; using kelvin_t = typename si::template unit_t<thermodynamic_temperature>; using mole_t = typename si::template unit_t<amount>; using candela_t = typename si::template unit_t<luminous_intensity>; inline constexpr dimensionless_t dimensionless{}; inline constexpr meter_t meter{}; inline constexpr gram_t gram{}; inline constexpr kilogram_t kilogram{}; inline constexpr second_t second{}; inline constexpr ampere_t ampere{}; inline constexpr kelvin_t kelvin{}; inline constexpr mole_t mole{}; inline constexpr candela_t candela{}; inline constexpr auto hertz = dimensionless / second; inline constexpr auto newton = meter * kilogram / (second * second); inline constexpr auto pascal = newton / (meter * meter); inline constexpr auto joule = newton * meter; inline constexpr auto watt = joule / second; inline constexpr auto coulomb = second * ampere; inline constexpr auto volt = watt / ampere; inline constexpr auto farad = coulomb / volt; inline constexpr auto ohm = volt / ampere; inline constexpr auto siemens = ampere / volt; inline constexpr auto weber = volt * second; inline constexpr auto tesla = weber* second; inline constexpr auto henry = weber / ampere; inline constexpr auto lumen = candela / dimensionless; inline constexpr auto lux = lumen / (meter * meter); inline constexpr auto becquerel = dimensionless / second; inline constexpr auto gray = joule / kilogram; inline constexpr auto sievert = joule / kilogram; inline constexpr auto katal = mole / second; }
1b62e2af9d668734d804659445aa314a99374007
00d6a671ab47dd9d67f576322ca4616afba8162b
/lru_cache.h
6d3cbdd5dc0091afb438200cfe167fbe520c36a8
[]
no_license
poorvaja23/RPC-based-Proxy-Server-1
441cf67bb9b2d5f9973022c8aec10bd74f356c00
cd98b2f50b049ecdb44bd7be33603766ce524ade
refs/heads/master
2021-01-13T15:31:01.854430
2015-03-30T04:06:19
2015-03-30T04:06:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
918
h
lru_cache.h
#ifndef lru_cache_H #define lru_cache_H #ifndef CACHE_MAX_SIZE #define CACHE_MAX_SIZE 1048576 #endif #include <string> #include <map> #include "lru_queue.h" class lru_cache { int MAX_SIZE; int size; std::map<string, string> dictionary; queue lru_queue; std::map<string, queue_element*> queue_ptrs; public: lru_cache(); lru_cache(int max); void cache_set_max(int max); // Sets size of cache int cache_fetch(string url, string &value); // Returns 1 if found, sets value accordingly and moves to end of queue. Returns 0 if not present. int cache_insert(string url, string value); // Returns 1 if successful, 0 if not private: int cache_isFull(int data_size); // Returns 1 if not enough space for new item on cache, 0 otherwise int cache_find(string url); // Returns 1 if found, 0 if not int cache_remove(); // Returns 1 if successful. 0 if not }; #endif
e43f40542b8736991c3ef3f900746006450421a7
a071753a94d6d247bdfc8468661e99046a92e376
/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp
13a9f8a5ee8dabefc4f027ccd6e4fee4db723669
[ "MIT" ]
permissive
JacekDanecki/compute-runtime
dd17bd773dc5a97fee38259d35bf103eaa006176
156c55e6a61c84d78ea530970c3092c94f055ffc
refs/heads/master
2022-03-22T02:24:10.485771
2021-05-21T11:30:24
2021-05-21T11:37:22
119,974,462
1
6
MIT
2019-03-26T17:26:08
2018-02-02T11:37:53
C++
UTF-8
C++
false
false
14,826
cpp
test_zes_temperature.cpp
/* * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h" #include "level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/mock_sysfs_temperature.h" namespace L0 { namespace ult { std::string rootPciPathOfGpuDevice = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0"; constexpr uint32_t handleComponentCountForSubDevices = 10u; constexpr uint32_t handleComponentCountForNoSubDevices = 2u; constexpr uint32_t invalidMaxTemperature = 125; constexpr uint32_t invalidMinTemperature = 10; const std::map<std::string, uint64_t> deviceKeyOffsetMapTemperature = { {"PACKAGE_ENERGY", 0x420}, {"COMPUTE_TEMPERATURES", 0x68}, {"SOC_TEMPERATURES", 0x60}, {"CORE_TEMPERATURES", 0x6c}}; class SysmanMultiDeviceTemperatureFixture : public SysmanMultiDeviceFixture { protected: std::unique_ptr<PublicLinuxTemperatureImp> pPublicLinuxTemperatureImp; std::unique_ptr<Mock<TemperatureFsAccess>> pFsAccess; FsAccess *pFsAccessOriginal = nullptr; std::vector<ze_device_handle_t> deviceHandles; void SetUp() override { SysmanMultiDeviceFixture::SetUp(); pFsAccess = std::make_unique<NiceMock<Mock<TemperatureFsAccess>>>(); pFsAccessOriginal = pLinuxSysmanImp->pFsAccess; pLinuxSysmanImp->pFsAccess = pFsAccess.get(); ON_CALL(*pFsAccess.get(), listDirectory(_, _)) .WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::listDirectorySuccess)); ON_CALL(*pFsAccess.get(), getRealPath(_, _)) .WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::getRealPathSuccess)); uint32_t subDeviceCount = 0; Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr); if (subDeviceCount == 0) { deviceHandles.resize(1, device->toHandle()); } else { deviceHandles.resize(subDeviceCount, nullptr); Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data()); } for (auto &deviceHandle : deviceHandles) { ze_device_properties_t deviceProperties = {}; Device::fromHandle(deviceHandle)->getProperties(&deviceProperties); auto pPmt = new NiceMock<Mock<TemperaturePmt>>(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE, deviceProperties.subdeviceId); pPmt->mockedInit(pFsAccess.get()); pPmt->keyOffsetMap = deviceKeyOffsetMapTemperature; pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt); } pSysmanDeviceImp->pTempHandleContext->init(deviceHandles); } void TearDown() override { SysmanMultiDeviceFixture::TearDown(); pLinuxSysmanImp->pFsAccess = pFsAccessOriginal; } std::vector<zes_temp_handle_t> get_temp_handles(uint32_t count) { std::vector<zes_temp_handle_t> handles(count, nullptr); EXPECT_EQ(zesDeviceEnumTemperatureSensors(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS); return handles; } }; TEST_F(SysmanMultiDeviceTemperatureFixture, GivenComponentCountZeroWhenCallingZetSysmanTemperatureGetThenZeroCountIsReturnedAndVerifySysmanTemperatureGetCallSucceeds) { uint32_t count = 0; ze_result_t result = zesDeviceEnumTemperatureSensors(device->toHandle(), &count, NULL); EXPECT_EQ(ZE_RESULT_SUCCESS, result); EXPECT_EQ(count, handleComponentCountForSubDevices); uint32_t testcount = count + 1; result = zesDeviceEnumTemperatureSensors(device->toHandle(), &testcount, NULL); EXPECT_EQ(ZE_RESULT_SUCCESS, result); EXPECT_EQ(testcount, handleComponentCountForSubDevices); count = 0; std::vector<zes_temp_handle_t> handles(count, nullptr); EXPECT_EQ(zesDeviceEnumTemperatureSensors(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS); EXPECT_EQ(count, handleComponentCountForSubDevices); } TEST_F(SysmanMultiDeviceTemperatureFixture, GivenValidTempHandleWhenGettingTemperatureThenValidTemperatureReadingsRetrieved) { auto handles = get_temp_handles(handleComponentCountForSubDevices); for (auto handle : handles) { zes_temp_properties_t properties = {}; EXPECT_EQ(ZE_RESULT_SUCCESS, zesTemperatureGetProperties(handle, &properties)); double temperature; ASSERT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesTemperatureGetState(handle, &temperature)); } } TEST_F(SysmanMultiDeviceTemperatureFixture, GivenValidTempHandleWhenGettingTemperatureConfigThenUnsupportedIsReturned) { auto handles = get_temp_handles(handleComponentCountForSubDevices); for (auto handle : handles) { zes_temp_config_t config = {}; EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesTemperatureGetConfig(handle, &config)); } } TEST_F(SysmanMultiDeviceTemperatureFixture, GivenValidTempHandleWhenSettingTemperatureConfigThenUnsupportedIsReturned) { auto handles = get_temp_handles(handleComponentCountForSubDevices); for (auto handle : handles) { zes_temp_config_t config = {}; EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesTemperatureSetConfig(handle, &config)); } } TEST_F(SysmanMultiDeviceTemperatureFixture, GivenCreatePmtObjectsWhenRootTileIndexEnumeratesSuccessfulThenValidatePmtObjectsReceivedAndBranches) { std::map<uint32_t, L0::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject; PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject); uint32_t deviceHandlesIndex = 0; for (auto &subDeviceIdToPmtEntry : mapOfSubDeviceIdToPmtObject) { ze_device_properties_t deviceProperties = {}; Device::fromHandle(deviceHandles[deviceHandlesIndex++])->getProperties(&deviceProperties); EXPECT_NE(subDeviceIdToPmtEntry.second, nullptr); EXPECT_EQ(subDeviceIdToPmtEntry.first, deviceProperties.subdeviceId); delete subDeviceIdToPmtEntry.second; // delete memory to avoid mem leak here, as we finished our test validation just above. } } class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture { protected: std::unique_ptr<PublicLinuxTemperatureImp> pPublicLinuxTemperatureImp; std::unique_ptr<Mock<TemperatureFsAccess>> pFsAccess; FsAccess *pFsAccessOriginal = nullptr; std::vector<ze_device_handle_t> deviceHandles; void SetUp() override { SysmanDeviceFixture::SetUp(); pFsAccess = std::make_unique<NiceMock<Mock<TemperatureFsAccess>>>(); pFsAccessOriginal = pLinuxSysmanImp->pFsAccess; pLinuxSysmanImp->pFsAccess = pFsAccess.get(); ON_CALL(*pFsAccess.get(), listDirectory(_, _)) .WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::listDirectorySuccess)); ON_CALL(*pFsAccess.get(), getRealPath(_, _)) .WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::getRealPathSuccess)); uint32_t subDeviceCount = 0; Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr); if (subDeviceCount == 0) { deviceHandles.resize(1, device->toHandle()); } else { deviceHandles.resize(subDeviceCount, nullptr); Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data()); } for (auto &deviceHandle : deviceHandles) { ze_device_properties_t deviceProperties = {}; Device::fromHandle(deviceHandle)->getProperties(&deviceProperties); auto pPmt = new NiceMock<Mock<TemperaturePmt>>(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE, deviceProperties.subdeviceId); pPmt->mockedInit(pFsAccess.get()); pPmt->keyOffsetMap = deviceKeyOffsetMapTemperature; pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt); } pSysmanDeviceImp->pTempHandleContext->init(deviceHandles); } void TearDown() override { SysmanDeviceFixture::TearDown(); pLinuxSysmanImp->pFsAccess = pFsAccessOriginal; } std::vector<zes_temp_handle_t> get_temp_handles(uint32_t count) { std::vector<zes_temp_handle_t> handles(count, nullptr); EXPECT_EQ(zesDeviceEnumTemperatureSensors(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS); return handles; } }; TEST_F(SysmanDeviceTemperatureFixture, GivenValidTempHandleWhenGettingGPUAndGlobalTemperatureThenValidTemperatureReadingsRetrieved) { auto handles = get_temp_handles(handleComponentCountForNoSubDevices); for (auto &handle : handles) { zes_temp_properties_t properties = {}; EXPECT_EQ(ZE_RESULT_SUCCESS, zesTemperatureGetProperties(handle, &properties)); double temperature; ASSERT_EQ(ZE_RESULT_SUCCESS, zesTemperatureGetState(handle, &temperature)); if (properties.type == ZES_TEMP_SENSORS_GLOBAL) { uint8_t maxTemp = 0; for (uint64_t i = 0; i < sizeof(tempArrForNoSubDevices) / sizeof(uint8_t); i++) { if ((tempArrForNoSubDevices[i] > invalidMaxTemperature) || (tempArrForNoSubDevices[i] < invalidMinTemperature) || (maxTemp > tempArrForNoSubDevices[i])) { continue; } maxTemp = tempArrForNoSubDevices[i]; } EXPECT_EQ(temperature, static_cast<double>(maxTemp)); } if (properties.type == ZES_TEMP_SENSORS_GPU) { EXPECT_EQ(temperature, static_cast<double>(tempArrForNoSubDevices[computeIndexForNoSubDevices])); } } } TEST_F(SysmanDeviceTemperatureFixture, GivenValidTempHandleAndPmtReadValueFailsWhenGettingTemperatureThenFailureReturned) { // delete previously allocated pPmt objects for (auto &subDeviceIdToPmtEntry : pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject) { delete subDeviceIdToPmtEntry.second; } pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear(); // delete previously created temp handles for (auto &handle : pSysmanDeviceImp->pTempHandleContext->handleList) { delete handle; handle = nullptr; pSysmanDeviceImp->pTempHandleContext->handleList.pop_back(); } for (auto &deviceHandle : deviceHandles) { ze_device_properties_t deviceProperties = {}; Device::fromHandle(deviceHandle)->getProperties(&deviceProperties); auto pPmt = new NiceMock<Mock<TemperaturePmt>>(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE, deviceProperties.subdeviceId); pPmt->mockedInitWithoutMappedMemory(pFsAccess.get()); pPmt->keyOffsetMap = deviceKeyOffsetMapTemperature; pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt); } pSysmanDeviceImp->pTempHandleContext->init(deviceHandles); auto handles = get_temp_handles(handleComponentCountForNoSubDevices); for (auto &handle : handles) { double temperature; ASSERT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, zesTemperatureGetState(handle, &temperature)); } } TEST_F(SysmanDeviceTemperatureFixture, GivenValidTempHandleWhenGettingUnsupportedSensorsTemperatureThenUnsupportedReturned) { ze_device_properties_t deviceProperties = {}; Device::fromHandle(device->toHandle())->getProperties(&deviceProperties); auto pPublicLinuxTemperatureImp = std::make_unique<LinuxTemperatureImp>(pOsSysman, deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE, deviceProperties.subdeviceId); pPublicLinuxTemperatureImp->setSensorType(ZES_TEMP_SENSORS_MEMORY_MIN); double temperature; EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pPublicLinuxTemperatureImp->getSensorTemperature(&temperature)); } TEST_F(SysmanDeviceTemperatureFixture, GivenValidateEnumerateRootTelemIndexWhengetRealPathFailsThenFailureReturned) { ON_CALL(*pFsAccess.get(), getRealPath(_, _)) .WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::getRealPathFailure)); EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess.get(), rootPciPathOfGpuDevice)); ON_CALL(*pFsAccess.get(), listDirectory(_, _)) .WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::listDirectoryFailure)); EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess.get(), rootPciPathOfGpuDevice)); std::map<uint32_t, L0::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject; PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject); EXPECT_TRUE(mapOfSubDeviceIdToPmtObject.empty()); } TEST_F(SysmanDeviceTemperatureFixture, GivenValidatePmtReadValueWhenkeyOffsetMapIsNotThereThenFailureReturned) { auto pPmt = std::make_unique<NiceMock<Mock<TemperaturePmt>>>(pFsAccess.get(), 0, 0); pPmt->mockedInit(pFsAccess.get()); pPmt->keyOffsetMap = deviceKeyOffsetMapTemperature; uint32_t val = 0; EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pPmt->readValue("SOMETHING", val)); } TEST_F(SysmanDeviceTemperatureFixture, GivenCreatePmtObjectsWhenRootTileIndexEnumeratesSuccessfulThenValidatePmtObjectsReceivedAndBranches) { std::map<uint32_t, L0::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject1; PlatformMonitoringTech::create(deviceHandles, pFsAccess.get(), rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject1); for (auto &subDeviceIdToPmtEntry : mapOfSubDeviceIdToPmtObject1) { EXPECT_NE(subDeviceIdToPmtEntry.second, nullptr); EXPECT_EQ(subDeviceIdToPmtEntry.first, 0u); // We know that subdeviceID is zero as core device didnt have any subdevices delete subDeviceIdToPmtEntry.second; // delete memory to avoid mem leak here, as we finished our test validation just above. } std::map<uint32_t, L0::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject2; std::vector<ze_device_handle_t> testHandleVector; // If empty device handle vector is provided then empty map is retrieved PlatformMonitoringTech::create(testHandleVector, pFsAccess.get(), rootPciPathOfGpuDevice, mapOfSubDeviceIdToPmtObject2); EXPECT_TRUE(mapOfSubDeviceIdToPmtObject2.empty()); } } // namespace ult } // namespace L0
149df8dfe3aae5536afbffbb0b70530e71e1f34d
6457beb5e94adce53f145bf4389eb3169d47e266
/src/algorithms/insertion_sort.cpp
ff498a47b04faa6712fcb263f41b14e25bc29e26
[]
no_license
thevojacek/AlgorithmsVisualisation
7b72e32424093d6c8bb75ad130f2b013f276ee92
3ad222e34e2d6e8578565c0e841fb3b14b7e00c2
refs/heads/master
2023-04-02T14:01:49.884018
2021-04-16T13:46:26
2021-04-16T13:46:26
270,092,581
0
0
null
null
null
null
UTF-8
C++
false
false
564
cpp
insertion_sort.cpp
#include "insertion_sort.h" #include "../utils/thread/thread.h" AlgorithmFunction insertion_sort() { return [](vector<int>* array){ if (array == nullptr) return; thread_utils::sleep_thread(20); for (int i = 1; i < array->size(); i++) { int j = i; int tmp = array->at(j); while ((j > 0) && (array->at(j-1) > tmp)) { array->at(j) = array->at(j-1); j--; thread_utils::sleep_thread(20); } array->at(j) = tmp; } }; }
14c13ac70cf90c531fbb7f454e98d43c8becca19
efc129216f321f85720f6fdfd5663a5c344a67ab
/mpgame/Game_local.h
13cd6e0768c4fed2a179febc7f15927e5a822a53
[]
no_license
Stradex/q4-librecoop
70d27054d303d847a5016b14e3286d1c267618ea
cd0c47e5f1b499bf146b65ae7d3d1e84eb95eb1f
refs/heads/main
2023-03-14T01:17:59.154888
2021-02-25T06:36:48
2021-02-25T06:36:48
341,447,640
4
0
null
null
null
null
UTF-8
C++
false
false
62,212
h
Game_local.h
#ifndef __GAME_LOCAL_H__ #define __GAME_LOCAL_H__ // RAVEN BEGIN // jsinger: attempt to eliminate cross-DLL allocation issues #ifdef RV_UNIFIED_ALLOCATOR inline void *operator new( size_t s ) { return Memory::Allocate(s); } inline void operator delete( void *p ) { Memory::Free(p); } inline void *operator new[]( size_t s ) { return Memory::Allocate(s); } inline void operator delete[]( void *p ) { Memory::Free(p); } #endif // RAVEN END /* =============================================================================== Local implementation of the public game interface. =============================================================================== */ // if set to 1 the server sends the client PVS with snapshots and the client compares against what it sees #ifndef ASYNC_WRITE_PVS #define ASYNC_WRITE_PVS 0 #endif extern idRenderWorld * gameRenderWorld; // classes used by idGameLocal class idEntity; class idActor; class idPlayer; class idCamera; class idWorldspawn; class idTestModel; class idAAS; class idAI; // RAVEN BEGIN // bdube: not using id effects //class idSmokeParticles; //class idEntityFx; // bdube: client side entities class rvInstance; class rvClientEntity; class rvClientModel; class rvCTFAssaultPlayerStart; class idPlayerStart; // RAVEN END class idTypeInfo; class idProgram; class idThread; class idEditEntities; class idLocationEntity; // RAVEN BEGIN // dluetscher: reduced max clients for memory usage #ifdef _XENON #define MAX_CLIENTS 16 #else // RAVEN END #define MAX_CLIENTS 32 #endif #define GENTITYNUM_BITS 12 #define MAX_GENTITIES (1<<GENTITYNUM_BITS) #define ENTITYNUM_NONE (MAX_GENTITIES-1) #define ENTITYNUM_WORLD (MAX_GENTITIES-2) // RAVEN BEGIN // bdube: dummy entity for client side physics #define ENTITYNUM_CLIENT (MAX_GENTITIES-3) #define ENTITYNUM_MAX_NORMAL (MAX_GENTITIES-3) // RAVEN END // RAVEN BEGIN // bdube: client entities #define CENTITYNUM_BITS 12 #define MAX_CENTITIES (1<<CENTITYNUM_BITS) // shouchard: for ban lists and because I hate magic numbers #define CLIENT_GUID_LENGTH 12 // RAVEN END // RAVEN BEGIN // abahr: helper macros #define SAFE_DELETE_PTR(p) if(p) { delete (p); (p) = NULL; } #define SAFE_REMOVE(p) if(p) { (p)->PostEventMS(&EV_Remove, 0); (p) = NULL; } // RAVEN END //COOP INVASION TEST START #define INVASION_MAX_SPAWNPOINTS 256 #define INVASION_MAX_ALIVE 11 #define INVASION_SPAWN_DELAY 10000 //delay to spawn //COOP INVASION TEST END //============================================================================ void gameError( const char *fmt, ... ); //============================================================================ typedef enum { CHANNEL_DEST_NONE, CHANNEL_DEST_RELIABLE_SERVER, CHANNEL_DEST_RELIABLE_REPEATER, CHANNEL_DEST_COUNT } channelDestType_t; class idMessageSender { public: virtual channelDestType_t GetChannelType( void ) const = 0; virtual void Send( const idBitMsg &msg ) const = 0; }; class idNullMessageSender : public idMessageSender { public: virtual channelDestType_t GetChannelType( void ) const { return CHANNEL_DEST_NONE; } virtual void Send( const idBitMsg &msg ) const { return; }; }; class idServerReliableMessageSender : public idMessageSender { public: virtual channelDestType_t GetChannelType( void ) const { return CHANNEL_DEST_RELIABLE_SERVER; } virtual void Send( const idBitMsg &msg ) const { if ( excludeClient != -1 ) { networkSystem->ServerSendReliableMessageExcluding( excludeClient, msg, inhibitRepeater ); } else { networkSystem->ServerSendReliableMessage( clientNum, msg, inhibitRepeater ); } }; const idMessageSender &To( int _clientNum, bool _inhibitRepeater = false ) { clientNum = _clientNum; excludeClient = -1; inhibitRepeater = _inhibitRepeater; return *this; } const idMessageSender &NotTo( int _excludeClient, bool _inhibitRepeater = false ) { clientNum = -1; excludeClient = _excludeClient; inhibitRepeater = _inhibitRepeater; return *this; } private: int clientNum; int excludeClient; bool inhibitRepeater; }; class idRepeaterReliableMessageSender : public idMessageSender { public: virtual channelDestType_t GetChannelType( void ) const { return CHANNEL_DEST_RELIABLE_REPEATER; } virtual void Send( const idBitMsg &msg ) const { if ( excludeClient != -1 ) { networkSystem->RepeaterSendReliableMessageExcluding( excludeClient, msg, inhibitHeader, repeaterClient ); } else { networkSystem->RepeaterSendReliableMessage( repeaterClient, msg, inhibitHeader, clientNum ); } }; const idMessageSender &To( int _clientNum, int asClient = -1, bool _inhibitHeader = false ) { repeaterClient = _clientNum; clientNum = asClient; excludeClient = -1; inhibitHeader = _inhibitHeader; return *this; } const idMessageSender &ExcludingTo( int _excludeClient, int _clientNum, bool _inhibitHeader = false ) { repeaterClient = _clientNum; clientNum = -1; excludeClient = _excludeClient; inhibitHeader = _inhibitHeader; return *this; } private: int repeaterClient; // viewer number on repeater int clientNum; // clientNum of real player to address exclusively to int excludeClient; // clientNum of real player to exclude bool inhibitHeader; }; extern idNullMessageSender nullSender; extern idServerReliableMessageSender serverReliableSender; extern idRepeaterReliableMessageSender repeaterReliableSender; //============================================================================ #include "gamesys/Event.h" // RAVEN BEGIN // bdube: added #include "gamesys/State.h" // RAVEN END #include "gamesys/Class.h" #include "gamesys/SysCvar.h" #include "gamesys/SysCmds.h" #include "gamesys/SaveGame.h" #include "gamesys/DebugGraph.h" #include "script/Script_Program.h" #include "anim/Anim.h" #include "ai/AAS.h" #include "physics/Clip.h" #include "physics/Push.h" #include "Pvs.h" #include "Lagometer.h" //============================================================================ const int MAX_GAME_MESSAGE_SIZE = 8192; const int MAX_ENTITY_STATE_SIZE = 512; const int ENTITY_PVS_SIZE = ((MAX_GENTITIES+31)>>5); // RAVEN BEGIN // abahr: changed to NUM_PORTAL_ATTRIBUTES to take into account gravity const int NUM_RENDER_PORTAL_BITS = NUM_PORTAL_ATTRIBUTES; // RAVEN END typedef struct entityState_s { int entityNumber; idBitMsg state; byte stateBuf[MAX_ENTITY_STATE_SIZE]; struct entityState_s * next; } entityState_t; typedef struct snapshot_s { int sequence; entityState_t * firstEntityState; int pvs[ENTITY_PVS_SIZE]; struct snapshot_s * next; } snapshot_t; const int MAX_EVENT_PARAM_SIZE = 128; typedef struct entityNetEvent_s { int spawnId; int event; int time; int paramsSize; byte paramsBuf[MAX_EVENT_PARAM_SIZE]; struct entityNetEvent_s *next; struct entityNetEvent_s *prev; } entityNetEvent_t; enum { GAME_RELIABLE_MESSAGE_SPAWN_PLAYER, GAME_RELIABLE_MESSAGE_DELETE_ENT, GAME_RELIABLE_MESSAGE_CHAT, GAME_RELIABLE_MESSAGE_TCHAT, GAME_RELIABLE_MESSAGE_DB, GAME_RELIABLE_MESSAGE_KILL, GAME_RELIABLE_MESSAGE_DROPWEAPON, GAME_RELIABLE_MESSAGE_RESTART, GAME_RELIABLE_MESSAGE_SERVERINFO, GAME_RELIABLE_MESSAGE_CALLVOTE, GAME_RELIABLE_MESSAGE_CASTVOTE, GAME_RELIABLE_MESSAGE_STARTVOTE, GAME_RELIABLE_MESSAGE_UPDATEVOTE, GAME_RELIABLE_MESSAGE_PORTALSTATES, GAME_RELIABLE_MESSAGE_PORTAL, GAME_RELIABLE_MESSAGE_VCHAT, GAME_RELIABLE_MESSAGE_STARTSTATE, GAME_RELIABLE_MESSAGE_MENU, GAME_RELIABLE_MESSAGE_EVENT, GAME_RELIABLE_MESSAGE_ITEMACQUIRESOUND, GAME_RELIABLE_MESSAGE_DEATH, GAME_RELIABLE_MESSAGE_GAMESTATE, GAME_RELIABLE_MESSAGE_STAT, GAME_RELIABLE_MESSAGE_ALL_STATS, GAME_RELIABLE_MESSAGE_INGAMEAWARD, GAME_RELIABLE_MESSAGE_SET_INSTANCE, GAME_RELIABLE_MESSAGE_VOICECHAT_MUTING, GAME_RELIABLE_MESSAGE_SERVER_ADMIN, GAME_RELIABLE_MESSAGE_CALLPACKEDVOTE, GAME_RELIABLE_MESSAGE_STARTPACKEDVOTE, GAME_RELIABLE_MESSAGE_GETADMINBANLIST, GAME_RELIABLE_MESSAGE_PRINT, GAME_RELIABLE_MESSAGE_VOICEDATA_CLIENT, GAME_RELIABLE_MESSAGE_VOICEDATA_CLIENT_ECHO, GAME_RELIABLE_MESSAGE_VOICEDATA_CLIENT_TEST, GAME_RELIABLE_MESSAGE_VOICEDATA_CLIENT_ECHO_TEST, GAME_RELIABLE_MESSAGE_GETVOTEMAPS, // unreliable message sent over the reliable channel // used as a debug solution when making sure some missing things are not due to packet drop GAME_RELIABLE_MESSAGE_UNRELIABLE_MESSAGE, // server acknowledges events from client, in response to specific GAME_RELIABLE_MESSAGE_EVENT situations GAME_RELIABLE_MESSAGE_EVENT_ACK, //New messages added for coop GAME_RELIABLE_MESSAGE_ADDCHECKPOINT, GAME_RELIABLE_MESSAGE_GOTOCHECKPOINT, GAME_RELIABLE_MESSAGE_GLOBALCHECKPOINT, GAME_RELIABLE_MESSAGE_NOCLIP, GAME_RELIABLE_MESSAGE_FADE //For fadeTo, fadeIn, fadeOut FX in coop }; enum { GAME_UNRELIABLE_MESSAGE_EVENT, GAME_UNRELIABLE_MESSAGE_EFFECT, GAME_UNRELIABLE_MESSAGE_HITSCAN, GAME_UNRELIABLE_MESSAGE_VOICEDATA_SERVER }; enum { GAME_UNRELIABLE_RECORD_CLIENTNUM, GAME_UNRELIABLE_RECORD_AREAS, GAME_UNRELIABLE_RECORD_COUNT }; typedef enum { GAMESTATE_UNINITIALIZED, // prior to Init being called GAMESTATE_NOMAP, // no map loaded GAMESTATE_STARTUP, // inside InitFromNewMap(). spawning map entities. GAMESTATE_RESTART, // spawning map entities from an instance restart, but not fully restarting GAMESTATE_ACTIVE, // normal gameplay GAMESTATE_SHUTDOWN // inside MapShutdown(). clearing memory. } gameState_t; typedef struct { idPlayerStart *ent; int dist; } spawnSpot_t; typedef struct { bool connected; bool active; bool priv; bool nopvs; userOrigin_t origin; int pvsArea; idDict info; } viewer_t; //============================================================================ class idEventQueue { public: typedef enum { OUTOFORDER_IGNORE, OUTOFORDER_DROP, OUTOFORDER_SORT } outOfOrderBehaviour_t; idEventQueue() : start( NULL ), end( NULL ) {} entityNetEvent_t * Alloc(); void Free( entityNetEvent_t *event ); void Shutdown(); void Init(); void Enqueue( entityNetEvent_t* event, outOfOrderBehaviour_t oooBehaviour ); entityNetEvent_t * Dequeue( void ); entityNetEvent_t * RemoveLast( void ); entityNetEvent_t * Start( void ) { return start; } private: entityNetEvent_t * start; entityNetEvent_t * end; // RAVEN BEGIN // jnewquist: Mark memory tags for idBlockAlloc idBlockAlloc<entityNetEvent_t,32,MA_EVENT> eventAllocator; // RAVEN END }; //============================================================================ template< class type > class idEntityPtr { public: idEntityPtr(); // save games void Save( idSaveGame *savefile ) const; // archives object for save game file void Restore( idRestoreGame *savefile ); // unarchives object from save game file idEntityPtr<type> & operator=( type *ent ); // synchronize entity pointers over the network int GetSpawnId( void ) const { return spawnId; } bool SetSpawnId( int id ); bool UpdateSpawnId( void ); bool IsValid( void ) const; type * GetEntity( void ) const; int GetEntityNum( void ) const; // RAVEN BEGIN // bdube: overloaded operators idEntityPtr( type* ent ) { *this = ent; } idEntityPtr<type>& operator=( idEntityPtr<type>& ent ) { *this = ent.GetEntity(); return *this; } type * operator->( void ) const; operator type *( void ) const; // RAVEN END private: int spawnId; }; // RAVEN BEGIN // abahr: forward declaration class rvGravityArea; // RAVEN END //============================================================================ // ddynerman: moved MultiplayerGame.h down here, so it can use more stuff in Game_local (idEntityPtr) #include "MultiplayerGame.h" //============================================================================ class idGameLocal : public idGame { public: idDict serverInfo; // all the tunable parameters, like numclients, etc idDict repeaterInfo; // serverInfo + repeater specific stuff int numClients; // pulled from serverInfo and verified idDict userInfo[MAX_CLIENTS]; // client specific settings const usercmd_t *usercmds; // client input commands idDict persistentPlayerInfo[MAX_CLIENTS]; idEntity * entities[MAX_GENTITIES];// index to entities int spawnIds[MAX_GENTITIES];// for use in idEntityPtr int firstFreeIndex; // first free index in the entities array int minSpawnIndex; // when spawning multiple instances, so nothing pollutes in between the instances int num_entities; // current number <= MAX_GENTITIES idHashIndex entityHash; // hash table to quickly find entities by name idWorldspawn * world; // world entity idLinkList<idEntity> spawnedEntities; // all spawned entities idLinkList<idEntity> activeEntities; // all thinking entities (idEntity::thinkFlags != 0) int numEntitiesToDeactivate;// number of entities that became inactive in current frame bool sortPushers; // true if active lists needs to be reordered to place pushers at the front bool sortTeamMasters; // true if active lists needs to be reordered to place physics team masters before their slaves idDict persistentLevelInfo; // contains args that are kept around between levels int nextSpawnTime; // Used in invasion gamemode (test only in DM maps) // RAVEN BEGIN // bdube: client entities rvClientEntity * clientEntities[MAX_CENTITIES]; // index to client entities int clientSpawnIds[MAX_CENTITIES]; // for use in idClientEntityPtr idLinkList<rvClientEntity> clientSpawnedEntities; // all client side entities int num_clientEntities; // current number of client entities int firstFreeClientIndex; // first free index in the client entities array int entityRegisterTime; // RAVEN END int maxViewers; // currently allocated int maxViewer; // highest numbered active viewer + 1 viewer_t (*viewers); // can be used to automatically effect every material in the world that references globalParms float globalShaderParms[ MAX_GLOBAL_SHADER_PARMS ]; idRandom random; // random number generator used throughout the game idProgram program; // currently loaded script and data space idThread * frameCommandThread; idPush push; // geometric pushing idPVS pvs; // potential visible set pvsHandle_t clientsPVS[MAX_CLIENTS];// PVS of multiplayer clients updated every frame idTestModel * testmodel; // for development testing of models // RAVEN BEGIN // bdube: not using id effects // idEntityFx * testFx; // for development testing of fx // RAVEN END // only set when an end level is activated, which will take over camera positioning // and draw end-level guis, then idStr sessionCommand; // a target_sessionCommand can set this to return something to the session idMultiplayerGame mpGame; // handles rules for standard dm idEditEntities * editEntities; // in game editing int cinematicSkipTime; // don't allow skipping cinemetics until this time has passed so player doesn't skip out accidently from a firefight int cinematicStopTime; // cinematics have several camera changes, so keep track of when we stop them so that we don't reset cinematicSkipTime unnecessarily int cinematicMaxSkipTime; // time to end cinematic when skipping. there's a possibility of an infinite loop if the map isn't set up right. bool inCinematic; // game is playing cinematic (player controls frozen) bool skipCinematic; // are kept up to date with changes to serverInfo int framenum; int previousTime; // time in msec of last frame int time; // in msec int msec; // time since last update in milliseconds int mHz; // hertz int vacuumAreaNum; // -1 if level doesn't have any outside areas // RAVEN BEGIN // abahr: idList<rvGravityArea*> gravityInfo; // area num for each gravity zone idList< idEntityPtr<idEntity> > scriptObjectProxies; // RAVEN END gameType_t gameType; bool isMultiplayer; // set if the game is run in multiplayer mode bool isServer; // set if the game is run for a dedicated or listen server bool isClient; // set if the game is run for a client // discriminates between the RunFrame path and the ClientPrediction path // NOTE: on a listen server, isClient is false bool isRepeater; // set if the game is repeating bool isListenServer; bool isTVClient; int localClientNum; // number of the local client. MP: -1 on a dedicated, MAX_CLIENTS when playing a server demo idLinkList<idEntity> snapshotEntities; // entities from the last snapshot int realClientTime; // real client time bool isNewFrame; // true if this is a new game frame, not a rerun due to prediction int entityDefBits; // bits required to store an entity def number int clientAckSequence; // holds frame number updated through GAME_RELIABLE_MESSAGE_EVENT_ACK server->client messages static const char * sufaceTypeNames[ MAX_SURFACE_TYPES ]; // text names for surface types idEntityPtr<idEntity> lastGUIEnt; // last entity with a GUI, used by Cmd_NextGUI_f int lastGUI; // last GUI on the lastGUIEnt int editors; // Mirrored editors flags from common determine which editors are running bool isLastPredictFrame; // on an MP server or in SP game this means 'last catchup frame' rather than predict // RAVEN BEGIN // rjohnson: entity usage stats idStr mapFileNameStripped; // name of the map, empty string if no map loaded, with path and extension removed. If entity filter, that is appended idList<idDict> entityUsageList; // ddynerman: the entity currently thinking, used to play effects/etc only in the appropriate instance idEntity* currentThinkingEntity; const static int INITIAL_SPAWN_COUNT = 1; // RAVEN END int filterMod; idList<idStr> modList; int nextLagoCheck; // ---------------------- Public idGame Interface ------------------- idGameLocal(); // RAVEN BEGIN // jsinger: attempt to eliminate cross-DLL allocation issues #ifdef RV_UNIFIED_ALLOCATOR virtual void Init( void *(*allocator)( size_t size ), void (*deallocator)( void *ptr ), size_t (*msize)( void *ptr ) ); #else virtual void Init( void ); #endif // RAVEN END virtual void Shutdown( void ); virtual void SetLocalClient( int clientNum ); virtual void ThrottleUserInfo( void ); virtual const idDict * SetUserInfo( int clientNum, const idDict &userInfo, bool isClient ); virtual const idDict * GetUserInfo( int clientNum ); virtual bool IsClientActive( int clientNum ); virtual void SetServerInfo( const idDict &serverInfo ); virtual const idDict * RepeaterSetUserInfo( int clientNum, const idDict &userInfo ); virtual const idDict & GetPersistentPlayerInfo( int clientNum ); virtual void SetPersistentPlayerInfo( int clientNum, const idDict &playerInfo ); virtual void InitFromNewMap( const char *mapName, idRenderWorld *renderWorld, bool isServer, bool isClient, int randSeed ); virtual bool InitFromSaveGame( const char *mapName, idRenderWorld *renderWorld, idFile *saveGameFile ); // RAVEN BEGIN // mekberg: added saveTypes virtual void SaveGame( idFile *saveGameFile, saveType_t saveType = ST_REGULAR ); // RAVEN END virtual void MapShutdown( void ); virtual void CacheDictionaryMedia( const idDict *dict ); virtual void SpawnPlayer( int clientNum ); virtual gameReturn_t RunFrame( const usercmd_t *clientCmds, int activeEditors, bool lastCatchupFrame, int serverGameFrame ); virtual void MenuFrame( void ); virtual void RepeaterFrame( const userOrigin_t *clientOrigins, bool lastCatchupFrame, int serverGameFrame ); virtual bool Draw( int clientNum ); virtual escReply_t HandleESC( idUserInterface **gui ); virtual idUserInterface *StartMenu( void ); virtual const char * HandleGuiCommands( const char *menuCommand ); virtual void HandleMainMenuCommands( const char *menuCommand, idUserInterface *gui ); virtual allowReply_t ServerAllowClient( int clientId, int numClients, const char *IP, const char *guid, const char *password, const char *privatePassword, char reason[MAX_STRING_CHARS] ); virtual void ServerClientConnect( int clientNum, const char *guid ); virtual void ServerClientBegin( int clientNum ); virtual void ServerClientDisconnect( int clientNum ); virtual void ServerWriteInitialReliableMessages( int clientNum ); virtual allowReply_t RepeaterAllowClient( int clientId, int numClients, const char *IP, const char *guid, bool repeater, const char *password, const char *privatePassword, char reason[MAX_STRING_CHARS] ); virtual void RepeaterClientConnect( int clientNum ); virtual void RepeaterClientBegin( int clientNum ); virtual void RepeaterClientDisconnect( int clientNum ); virtual void RepeaterWriteInitialReliableMessages( int clientNum ); virtual void WriteSnapshot( snapshot_t *&clientSnapshot, entityState_t *entityStates[MAX_GENTITIES], int PVS[ENTITY_PVS_SIZE], idMsgQueue &unreliable, int sequence, idBitMsg &msg, int transmitEntity, int transmitEntity2, int instance, bool doPVS, const idBounds &pvs_bounds, int lastSnapshotFrame ); virtual void ServerWriteSnapshot( int clientNum, int sequence, idBitMsg &msg, dword *clientInPVS, int numPVSClients, int lastSnapshotFrame ); virtual bool ServerApplySnapshot( int clientNum, int sequence ); virtual void ServerProcessReliableMessage( int clientNum, const idBitMsg &msg ); virtual bool RepeaterApplySnapshot( int clientNum, int sequence ); virtual void RepeaterProcessReliableMessage( int clientNum, const idBitMsg &msg ); virtual void ClientReadSnapshot( int clientNum, int snapshotSequence, const int gameFrame, const int gameTime, const int dupeUsercmds, const int aheadOfServer, const idBitMsg &msg ); virtual bool ClientApplySnapshot( int clientNum, int sequence ); virtual void ClientProcessReliableMessage( int clientNum, const idBitMsg &msg ); virtual gameReturn_t ClientPrediction( int clientNum, const usercmd_t *clientCmds, bool lastPredictFrame = true, ClientStats_t *cs = NULL ); // RAVEN BEGIN // ddynerman: client game frame virtual void ClientRun( void ); virtual void ClientEndFrame( void ); // jshepard: rcon password check virtual void ProcessRconReturn( bool success ); virtual void ResetRconGuiStatus( void ); // RAVEN END virtual void GetClientStats( int clientNum, char *data, const int len ); virtual void SwitchTeam( int clientNum, int team ); virtual bool DownloadRequest( const char *IP, const char *guid, const char *paks, char urls[ MAX_STRING_CHARS ] ); virtual bool HTTPRequest( const char *IP, const char *file, bool isGamePak ); // RAVEN BEGIN // bdube: client hitscan virtual void ClientHitScan( const idBitMsg &msg ); // jscott: for effects system virtual void StartViewEffect( int type, float time, float scale ); virtual void GetPlayerView( idVec3 &origin, idMat3 &axis ); virtual void Translation( trace_t &trace, idVec3 &source, idVec3 &dest, idTraceModel *trm, int clipMask ); virtual void SpawnClientMoveable ( const char* name, int lifetime, const idVec3& origin, const idMat3& axis, const idVec3& velocity, const idVec3& angular_velocity ); // bdube: added debug methods virtual void DebugSetString ( const char* name, const char* value ); virtual void DebugSetFloat ( const char* name, float value ); virtual void DebugSetInt ( const char* name, int value ); virtual const char* DebugGetStatString ( const char* name ); virtual int DebugGetStatInt ( const char* name ); virtual float DebugGetStatFloat ( const char* name ); virtual bool IsDebugHudActive ( void ) const; // rjohnson: for new note taking mechanism virtual bool GetPlayerInfo( idVec3 &origin, idMat3 &axis, int PlayerNum = -1, idAngles *deltaViewAngles = NULL, int reqClientNum = -1 ); virtual void SetPlayerInfo( idVec3 &origin, idMat3 &axis, int PlayerNum = -1 ); virtual bool PlayerChatDisabled( int clientNum ); virtual void SetViewComments( const char *text = 0 ); // ddynerman: utility functions virtual void GetPlayerName( int clientNum, char* name ); virtual void GetPlayerClan( int clientNum, char* clan ); virtual void SetFriend( int clientNum, bool isFriend ); static void Cmd_PrintMapEntityNumbers_f( const idCmdArgs& args ); static void Cmd_PrintSpawnIds_f( const idCmdArgs& args ); // abahr: virtual int GetNumGravityAreas() const; virtual const rvGravityArea* GetGravityInfo( int index ) const; virtual void SetGravityInfo( int index, rvGravityArea* info ); virtual void AddUniqueGravityInfo( rvGravityArea* info ); virtual int GetCurrentGravityInfoIndex( const idVec3& origin ) const; virtual bool InGravityArea( idEntity* entity ) const; virtual int GetCurrentGravityInfoIndex( idEntity* entity ) const; virtual const idVec3 GetCurrentGravity( idEntity* entity ) const; virtual const idVec3 GetCurrentGravity( const idVec3& origin, const idMat3& axis ) const; virtual bool InGravityArea( rvClientEntity* entity ) const; virtual int GetCurrentGravityInfoIndex( rvClientEntity* entity ) const; virtual const idVec3 GetCurrentGravity( rvClientEntity* entity ) const; virtual idEntity* ReferenceScriptObjectProxy( const char* scriptObjectName ); virtual void ReleaseScriptObjectProxy( const char* proxyName ); // rjohnson: entity usage stats virtual void ListEntityStats( const idCmdArgs &args ); // RAVEN END virtual void SetDemoState( demoState_t state, bool serverDemo, bool timeDemo ); virtual void SetRepeaterState( bool isRepeater, bool serverIsRepeater ); virtual void WriteNetworkInfo( idFile* file, int clientNum ); virtual void ReadNetworkInfo( int gameTime, idFile* file, int clientNum ); virtual bool ValidateDemoProtocol( int minor_ref, int minor ); virtual void ServerWriteServerDemoSnapshot( int sequence, idBitMsg &msg, int lastSnapshotFrame ); virtual void ClientReadServerDemoSnapshot( int sequence, const int gameFrame, const int gameTime, const idBitMsg &msg ); virtual void RepeaterWriteSnapshot( int clientNum, int sequence, idBitMsg &msg, dword *clientInPVS, int numPVSClients, const userOrigin_t &pvs_origin, int lastSnapshotFrame ); virtual void RepeaterEndSnapshots( void ); virtual void ClientReadRepeaterSnapshot( int sequence, const int gameFrame, const int gameTime, const int aheadOfServer, const idBitMsg &msg ); virtual int GetDemoFollowClient( void ) { return IsServerDemoPlaying() ? followPlayer : -1; } virtual void GetBotInput( int clientNum, usercmd_t &userCmd ) { Error( "Bot input requested\n" ); }; virtual const char * GetLoadingGui( const char *mapDeclName ) { return NULL; } virtual void SetupLoadingGui( idUserInterface *gui ) {} // ---------------------- Public idGameLocal Interface ------------------- //COOP START void ServerWriteSnapshotCoop(int clientNum, int sequence, idBitMsg& msg, dword* clientInPVS, int numPVSClients, int lastSnapshotFrame); void ClientReadSnapshotCoop(int clientNum, int snapshotSequence, const int gameFrame, const int gameTime, const int dupeUsercmds, const int aheadOfServer, const idBitMsg& msg); //COOP END void Printf( const char *fmt, ... ) const; void DPrintf( const char *fmt, ... ) const; void Warning( const char *fmt, ... ) const; void DWarning( const char *fmt, ... ) const; void Error( const char *fmt, ... ) const; // Initializes all map variables common to both save games and spawned games void LoadMap( const char *mapName, int randseed ); void LocalMapRestart( int instance = -1 ); void MapRestart( int instance = -1 ); static void VerifyServerSettings_f( const idCmdArgs &args ); static void MapRestart_f( const idCmdArgs &args ); bool NextMap( void ); // returns wether serverinfo settings have been modified static void NextMap_f( const idCmdArgs &args ); idMapFile * GetLevelMap( void ); const char * GetMapName( void ) const; int NumAAS( void ) const; idAAS * GetAAS( int num ) const; idAAS * GetAAS( const char *name ) const; // RAVEN BEGIN // jscott: added accessor for memory tracking int GetNumAAS( void ) const { return( aasList.Num() ); } // RAVEN END void SetAASAreaState( const idBounds &bounds, const int areaContents, bool closed ); aasHandle_t AddAASObstacle( const idBounds &bounds ); void RemoveAASObstacle( const aasHandle_t handle ); void RemoveAllAASObstacles( void ); // RAVEN BEGIN // mwhitlock: added entity memory usage stuff. size_t GetEntityMemoryUsage ( void ) const; // RAVEN END bool CheatsOk( bool requirePlayer = true ); void SetSkill( int value ); gameState_t GameState( void ) const; void SetGameState( gameState_t newState ) { gamestate = newState; } idEntity * SpawnEntityType( const idTypeInfo &classdef, const idDict *args = NULL, bool bIsClientReadSnapshot = false ); bool SpawnEntityDef( const idDict &args, idEntity **ent = NULL, bool setDefaults = true ); bool SpawnClientEntityDef( const idDict &args, rvClientEntity **ent = NULL, bool setDefaults = true, const char* spawn = NULL ); // abahr: idEntity* SpawnEntityDef( const char* entityDefName, const idDict* additionalArgs = NULL ); template< class type > type* SpawnSafeEntityDef( const char* entityDefName, const idDict* additionalArgs = NULL ); int GetPreviousTime() const { return previousTime; } // RAVEN END int GetSpawnId( const idEntity *ent ) const; const idDeclEntityDef * FindEntityDef( const char *name, bool makeDefault = true ) const; const idDict * FindEntityDefDict( const char *name, bool makeDefault = true ) const; void RegisterEntity( idEntity *ent ); void UnregisterEntity( idEntity *ent ); // used to skip one when registering entities, leaving an empty entity in the array void SkipEntityIndex( void ); bool RequirementMet( idEntity *activator, const idStr &requires, int removeItem ); // RITUAL BEGIN // squirrel: accessor for si_weaponStay checks bool IsWeaponsStayOn( void ); // RITUAL END // RAVEN BEGIN // bdube: client entities void RegisterClientEntity( rvClientEntity *cent ); void UnregisterClientEntity( rvClientEntity *cent ); // RAVEN END void AlertAI( idEntity *ent ); // RAVEN BEGIN // bdube: added get alert actor idActor * GetAlertActor( void ); idEntity * GetAlertEntity( void ); // RAVEN END bool InCoopPlayersPVS(idEntity* ent) const; //added by Stradex for coop bool InPlayerPVS( idEntity *ent ) const; bool InPlayerConnectedArea( idEntity *ent ) const; void SetCamera( idCamera *cam ); idCamera * GetCamera( void ) const; bool SkipCinematic( void ); // RAVEN BEGIN // jscott: for portal skies idCamera *GetPortalSky( void ) const; void SetPortalSky( idCamera *cam ); // RAVEN END void CalcFov( float base_fov, float &fov_x, float &fov_y ) const; void AddEntityToHash( const char *name, idEntity *ent ); bool RemoveEntityFromHash( const char *name, idEntity *ent ); int GetTargets( const idDict &args, idList< idEntityPtr<idEntity> > &list, const char *ref ) const; // returns the master entity of a trace. for example, if the trace entity is the player's head, it will return the player. idEntity * GetTraceEntity( const trace_t &trace ) const; static void ArgCompletion_EntityName( const idCmdArgs &args, void(*callback)( const char *s ) ); idEntity * FindTraceEntity( idVec3 start, idVec3 end, const idTypeInfo &c, const idEntity *skip ) const; static void ArgCompletion_AIName( const idCmdArgs &args, void(*callback)( const char *s ) ); //RAVEN BEGIN // bgeisler: added, I don't want to have to do this work myself every single time I have an entityNumber idEntity * FindEntity( int entityNumber ) { return ((entityNumber >= 0 && entityNumber < MAX_GENTITIES) ? entities[entityNumber] : NULL); } //RAVEN BEGIN idEntity * FindEntity( const char *name ) const; idEntity * FindEntityUsingDef( idEntity *from, const char *match ) const; int EntitiesWithinRadius( const idVec3 org, float radius, idEntity **entityList, int maxCount ) const; void KillBox( idEntity *ent, bool catch_teleport = false ); void RadiusPush( const idVec3 &origin, const float radius, const float push, const idEntity *inflictor, const idEntity *ignore, float inflictorScale, const bool quake ); // RAVEN BEGIN // ddynerman: return number of people damaged void RadiusDamage( const idVec3 &origin, idEntity *inflictor, idEntity *attacker, idEntity *ignoreDamage, idEntity *ignorePush, const char *damageDefName, float dmgPower = 1.0f, int* hitCount = NULL ); // bdube: inflictor void RadiusPushClipModel( idEntity* inflictor, const idVec3 &origin, const float push, const idClipModel *clipModel ); // RAVEN END void ProjectDecal( const idVec3 &origin, const idVec3 &dir, float depth, bool parallel, float size, const char *material, float angle = 0 ); // RAVEN BEGIN // ddynerman: multiple collision worlds void BloodSplat( const idEntity* ent, const idVec3 &origin, const idVec3 &dir, float size, const char *material ); // RAVEN END void CallFrameCommand( idEntity *ent, const function_t *frameCommand ); // RAVEN BEGIN // bdube: added script object frame commands void CallFrameCommand( idScriptObject* obj, const function_t* frameCommand ); void CallFrameCommand( idEntity* ent, const char* frameCommand ); // RAVEN END void CallObjectFrameCommand( idEntity *ent, const char *frameCommand ); const idVec3 & GetGravity( void ) const; // added the following to assist licensees with merge issues int GetFrameNum() const { return framenum; } int GetTime() const { return time; } int GetMSec() const { return msec; } int GetMHz() const { return mHz; } int GetNextClientNum( int current ) const; idPlayer * GetClientByNum( int current ) const; idPlayer * GetClientByName( const char *name ) const; idPlayer * GetClientByCmdArgs( const idCmdArgs &args ) const; int GetClientNumByName( const char *name ) const; idPlayer * GetLocalPlayer() const; idPlayer* GetCoopPlayer() const; idEntity* GetCoopPlayerScriptHack() const; //added for Coop // RAVEN BEGIN // jshepard: update player data after main menu close void UpdatePlayerPostMainMenu(); // bdube: added int GetSpawnCount ( void ) const; void SetSpawnCount ( int newSpawnCount ) { spawnCount = newSpawnCount; } // ddynerman: team type bool IsTeamGame ( void ) const; // RAVEN END void SpreadLocations(); idLocationEntity * LocationForPoint( const idVec3 &point ); // May return NULL // RAVEN BEGIN // bdube: added idLocationEntity* AddLocation ( const idVec3& point, const char* name ); // ddynerman: new gametype specific spawn code bool SpotWouldTelefrag( idPlayer* player, idPlayerStart* spawn ); idEntity* SelectSpawnPoint( idPlayer* player ); void UpdateForwardSpawns( rvCTFAssaultPlayerStart* point, int team ); void ClearForwardSpawns( void ); // RAVEN END void SetPortalState( qhandle_t portal, int blockingBits ); void ServerSendChatMessage( int to, const char *name, const char *text, const char *parm = "" ); void SetGlobalMaterial( const idMaterial *mat ); const idMaterial * GetGlobalMaterial(); void SetGibTime( int _time ) { nextGibTime = _time; } int GetGibTime() { return nextGibTime; } // RITUAL BEGIN // squirrel: added DeadZone multiplayer mode void SetUnFreezeTime( int _time ) { unFreezeTime = _time; }; int GetUnFreezeTime() { return unFreezeTime; }; void SetIsFrozen( bool _isFrozen ) { isFrozen = _isFrozen; }; bool GetIsFrozen() { return isFrozen; }; // RITUAL END bool NeedRestart(); // RAVEN BEGIN // jshepard: update end of level on player hud void UpdateEndLevel(); // MCG: added whizz-by sound void CheckPlayerWhizzBy ( idVec3 start, idVec3 end, idEntity* hitEnt, idEntity *attacker ); // bdube: added hitscan // twhitaker: added additionalIgnore parameter idEntity* HitScan ( const idDict& hitscanDef, const idVec3& origin, const idVec3& dir, const idVec3& fxOrigin, idEntity* owner = NULL, bool noFX = false, float damageScale = 1.0f, idEntity * additionalIgnore = NULL, int *areas = NULL ); // bdube: added effect calls virtual rvClientEffect* PlayEffect ( const idDecl *effect, const idVec3& origin, const idMat3& axis, bool loop = false, const idVec3& endOrigin = vec3_origin, bool broadcast = false, bool predictedBit = false, effectCategory_t category = EC_IGNORE, const idVec4& effectTint = vec4_one ); rvClientEffect* PlayEffect ( const idDict& args, const char* effectName, const idVec3& origin, const idMat3& axis, bool loop = false, const idVec3& endOrigin = vec3_origin, bool broadcast = false, bool predictedBit = false, effectCategory_t category = EC_IGNORE, const idVec4& effectTint = vec4_one ); const idDecl *GetEffect ( const idDict& args, const char* effectName, const rvDeclMatType* materialType = NULL ); void UpdateRepeaterInfo( bool transmit = false ); idList<idEntity*> ambientLights; // lights that cast ambient // ddynerman: multiple collision world - game collision wrapper functions to // use the correct idClip // --------------------------------------------------------------- // These are wrapper functions around idClip collision detection // functions. They expose the collision detection engine to the // game code, but do collision world determination in one spot. // 'ent' refers to the entity we want collision information about bool Translation ( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity, const idEntity *passEntity2 = 0 ); bool Rotation ( const idEntity* ent, trace_t &results, const idVec3 &start, const idRotation &rotation, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity ); bool Motion ( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idRotation &rotation, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity ); int Contacts ( const idEntity* ent, contactInfo_t *contacts, const int maxContacts, const idVec3 &start, const idVec6 &dir, const float depth, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity ); int Contents ( const idEntity* ent, const idVec3 &start, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity, idEntity **touchedEntity = NULL ); // special case translations versus the rest of the world bool TracePoint ( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, int contentMask, const idEntity *passEntity ); bool TraceBounds ( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idBounds &bounds, int contentMask, const idEntity *passEntity ); // clip versus a specific model void TranslationModel( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, idCollisionModel *model, const idVec3 &modelOrigin, const idMat3 &modelAxis ); void RotationModel ( const idEntity* ent, trace_t &results, const idVec3 &start, const idRotation &rotation, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, idCollisionModel *model, const idVec3 &modelOrigin, const idMat3 &modelAxis ); int ContactsModel ( const idEntity* ent, contactInfo_t *contacts, const int maxContacts, const idVec3 &start, const idVec6 &dir, const float depth, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, idCollisionModel *model, const idVec3 &modelOrigin, const idMat3 &modelAxis ); int ContentsModel ( const idEntity* ent, const idVec3 &start, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, idCollisionModel *model, const idVec3 &modelOrigin, const idMat3 &modelAxis ); // clip versus all entities but not the world void TranslationEntities( const idEntity* ent, trace_t &results, const idVec3 &start, const idVec3 &end, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity, const idEntity *passEntity2 = 0 ); // get a contact feature bool GetModelContactFeature( const idEntity* ent, const contactInfo_t &contact, const idClipModel *clipModel, idFixedWinding &winding ) const; // get entities/clip models within or touching the given bounds int EntitiesTouchingBounds ( const idEntity* ent, const idBounds &bounds, int contentMask, idEntity **entityList, int maxCount ) const; int ClipModelsTouchingBounds( const idEntity* ent, const idBounds &bounds, int contentMask, idClipModel **clipModelList, int maxCount ) const; int PlayersTouchingBounds ( const idEntity* ent, const idBounds &bounds, int contentMask, idPlayer **entityList, int maxCount ) const; const idBounds & GetWorldBounds( const idEntity* ent ) const; void Link( idClipModel* clip, idEntity *ent, int newId, const idVec3 &newOrigin, const idMat3 &newAxis, int renderModelHandle = -1 ); idClip* GetEntityClipWorld( const idEntity* ent ); const idClip* GetEntityClipWorld( const idEntity* ent ) const; int GetNumMapEntities( void ) const; int AddClipWorld( int id ); void RemoveClipWorld( int id ); int AddInstance( int id = -1, bool deferPopulate = false ); void RemoveInstance( int id ); rvInstance* GetInstance( int id ); int GetNumInstances( void ); // ddynerman: multiple game instances void SpawnMapEntities( int instance = 0, unsigned short* entityNumIn = NULL, unsigned short* entityNumOut = NULL, int* startSpawnCount = NULL ); void InstanceClear( void ); // ddynerman: utility function virtual const char* GetLongGametypeName( const char* gametype ); virtual void ReceiveRemoteConsoleOutput( const char* output ); bool IsFlagGameType( void ) { return ( gameType == GAME_CTF || gameType == GAME_1F_CTF || gameType == GAME_ARENA_CTF || gameType == GAME_ARENA_1F_CTF ); } bool IsTeamGameType( void ) { return ( gameType == GAME_TDM || gameType == GAME_CTF || gameType == GAME_ARENA_CTF || gameType == GAME_DEADZONE ); } bool IsTeamPowerups( void ); int InvasionEnemiesCount(void); // twhitaker: needed this for difficulty settings float GetDifficultyModifier( void ) { const static float difficulty[] = { -0.3f, 0.0f, 0.4f, 0.8f }; return difficulty[ idMath::ClampInt( 0, 3, g_skill.GetInteger() ) ]; } bool IsMultiplayer( void ) { return isMultiplayer; } // mekberg: added bool InCinematic( void ) { return inCinematic; } // mekberg: so ban list can be populated outside of multiplayer game void PopulateBanList( idUserInterface* hud ); // RAVEN END // RAVEN BEGIN // mwhitlock: Dynamic memory consolidation #if defined(_RV_MEM_SYS_SUPPORT) virtual void FlushBeforelevelLoad( void ); #endif // RAVEN END void ServerSendInstanceReliableMessageExcluding( const idEntity* owner, int excludeClient, const idBitMsg& msg ); void ServerSendInstanceReliableMessage( const idEntity* owner, int clientNum, const idBitMsg& msg ); void SendUnreliableMessage( const idBitMsg &msg, const int clientNum ); // note: listen server client is always excluded void SendUnreliableMessagePVS( const idBitMsg &msg, const idEntity *instanceEnt, int area1 = -1, int area2 = -1 ); void RepeaterAppendUnreliableMessage( int icl, const idBitMsg &msg, const idBitMsg *header = NULL ); void RepeaterUnreliableMessage( const idBitMsg &msg, const int clientNum, const idBitMsg *header = NULL ); void RepeaterUnreliableMessagePVS( const idBitMsg &msg, const int *areas, int numAreas, const idBitMsg *header = NULL ); demoState_t GetDemoState( void ) const { return demoState; } bool IsServerDemoPlaying( void ) const { return (demoState == DEMO_PLAYING && serverDemo) || serverIsRepeater; } bool IsServerDemoRecording( void ) const { return demoState == DEMO_RECORDING && serverDemo; } bool IsRepeaterDemoPlaying( void ) const { return (demoState == DEMO_PLAYING && !serverDemo) && serverIsRepeater; } bool IsTimeDemo( void ) const { return timeDemo; } /* do not synchronize implicit decls over the network implicit decls are created when loading sounds and materials that don't have an explicit entry in the def files clients and server may load those in different orders in a same map, or even join in with different orders because of different map histories before this game in D3 we maintain remap tables, but it's much better to have tighter multiplayer assets so we have no need at all still, you want to catch when bad things happen, so indexes should ALL be read and written through these functions */ static void WriteDecl( idBitMsg &msg, const idDecl *decl ); static const idDecl* ReadDecl( const idBitMsg &msg, declType_t type ); static void WriteDecl( idBitMsgDelta &msg, const idDecl *decl ); static const idDecl* ReadDecl( const idBitMsgDelta &msg, declType_t type ); idPlayerStart *RandomSpawn( void ); int GetStartingIndexForInstance( int instanceID ); void ClientSetStartingIndex( int i ) { clientInstanceFirstFreeIndex = i; } void ServerSetMinSpawnIndex( void ); void ServerSetEntityIndexWatermark( int instanceID ); idLagometer lagometer; private: // RAVEN BEGIN // ddynerman: multiple instance for MP idList<idClip*> clip; // collision detection idList<rvInstance*> instances; // RAVEN END // keep watermarks on the high entity index // server transmits this to clients so they use the right entity layout idList<int> instancesEntityIndexWatermarks; int clientInstanceFirstFreeIndex; idStr mapFileName; // name of the map, empty string if no map loaded idMapFile * mapFile; // will be NULL during the game unless in-game editing is used bool mapCycleLoaded; int incompatibleMaps; int spawnCount; bool isMapEntity[ MAX_GENTITIES ]; // it's handy to know which entities are part of the map // RAVEN BEGIN // bdube: client entities int clientSpawnCount; // RAVEN END idLocationEntity ** locationEntities; // for location names, etc idCamera * camera; const idMaterial * globalMaterial; // for overriding everything // RAVEN BEGIN // jscott: for portal skies idCamera *portalSky; bool portalSkyVisible; // RAVEN END idList<idAAS *> aasList; // area system idStrList aasNames; // RAVEN BEGIN // bdube: GetAlertActor idEntityPtr<idActor> lastAIAlertActor; int lastAIAlertActorTime; idEntityPtr<idEntity> lastAIAlertEntity; int lastAIAlertEntityTime; // RAVEN END idDict spawnArgs; // spawn args used during entity spawning FIXME: shouldn't be necessary anymore // RAVEN BEGIN // nmckenzie: const idDeclEntityDef * spawnOverrides; // RAVEN END pvsHandle_t playerPVS; // merged pvs of all players bool freePlayerPVS; // tracks if playerPVS needs to be released pvsHandle_t playerConnectedAreas; // all areas connected to any player area idVec3 gravity; // global gravity vector gameState_t gamestate; // keeps track of whether we're spawning, shutting down, or normal gameplay bool influenceActive; // true when a phantasm is happening int nextGibTime; // RITUAL BEGIN // squirrel: added DeadZone multiplayer mode int unFreezeTime; // time at which players unfreeze and the match begins bool isFrozen; // true if the match is frozen (for buying, etc.) // RITUAL END entityState_t * clientEntityStates[MAX_CLIENTS+1][MAX_GENTITIES]; // MAX_CLIENTS slot is for server demo recordings int clientPVS[MAX_CLIENTS+1][ENTITY_PVS_SIZE]; snapshot_t * clientSnapshots[MAX_CLIENTS+1]; idList<int> privateViewerIds, nopvsViewerIds; entityState_t * (*viewerEntityStates)[MAX_GENTITIES]; // MAX_CLIENTS slot is for server demo recordings int (*viewerPVS)[ENTITY_PVS_SIZE]; snapshot_t * (*viewerSnapshots); idMsgQueue (*viewerUnreliableMessages); // RAVEN BEGIN // jnewquist: Mark memory tags for idBlockAlloc idBlockAlloc<entityState_t,256,MA_ENTITY> entityStateAllocator; idBlockAlloc<snapshot_t,64,MA_ENTITY> snapshotAllocator; // RAVEN END idEventQueue eventQueue; idList<idPlayerStart*> spawnSpots; // RAVEN BEGIN // ddynerman: two lists to hold team spawn points for team based games idList<idPlayerStart*> teamSpawnSpots[TEAM_MAX]; idList<idPlayerStart*> teamForwardSpawnSpots[TEAM_MAX]; // forward spawn positions, used in CTF // RAVEN END idDict newInfo; idStrList shakeSounds; idStrList invasionEnemies; idMsgQueue unreliableMessages[ MAX_CLIENTS+1 ]; // MAX_CLIENTS slot for server demo recording demoState_t demoState; bool serverDemo; bool timeDemo; bool serverIsRepeater; // demo interaction usercmds usercmd_t usercmd, oldUsercmd; int followPlayer; // free fly or spectate follow through local interaction during server demo replays int demo_protocol; // keep track of the protocol of the demo we're replaying private: void Clear( void ); // returns true if the entity shouldn't be spawned at all in this game type or difficulty level bool InhibitEntitySpawn( idDict &spawnArgs ); // spawn entities from the map file // commons used by init, shutdown, and restart void MapPopulate( int instance = -1 ); void MapClear( bool clearClients, int instance = -1 ); bool SetupPortalSkyPVS( idPlayer *player ); // RAVEN END void SetupPlayerPVS( void ); void FreePlayerPVS( void ); void UpdateGravity( void ); void SortActiveEntityList( void ); void ShowTargets( void ); void RunDebugInfo( void ); void InitScriptForMap( void ); void InitConsoleCommands( void ); void ShutdownConsoleCommands( void ); void InitAsyncNetwork( void ); void ShutdownAsyncNetwork( void ); void InitLocalClient( int clientNum ); void FreeSnapshotsOlderThanSequence( snapshot_t *&clientSnapshot, int sequence ); void FreeSnapshotsOlderThanSequence( int clientNum, int sequence ); bool ApplySnapshot( snapshot_t *&clientSnapshot, entityState_t *entityStates[MAX_GENTITIES], int PVS[ENTITY_PVS_SIZE], int sequence ); bool ApplySnapshot( int clientNum, int sequence ); void WriteGameStateToSnapshot( idBitMsgDelta &msg ) const; void ReadGameStateFromSnapshot( const idBitMsgDelta &msg ); void NetworkEventWarning( const entityNetEvent_t *event, const char *fmt, ... ) id_attribute((format(printf,3,4))); void ServerProcessEntityNetworkEventQueue( void ); void ClientProcessEntityNetworkEventQueue( void ); void ClientShowSnapshot( int clientNum ) const; void SetGameType( void ); // RAVEN BEGIN // ddynerman: gametype specific spawn code void InitializeSpawns( void ); idList<spawnSpot_t> WeightSpawnSpots( idPlayer* player ); // RAVEN END static int sortSpawnPoints( const void *ptr1, const void *ptr2 ); void DumpOggSounds( void ); void GetShakeSounds( const idDict *dict ); bool ValidateServerSettings( const char *map, const char *gametype ); void Tokenize( idStrList &out, const char *in ); // RAVEN BEGIN // ddynerman: multiple clip worlds void ShutdownInstances( void ); // shouchard: ban list support (lives in game_network.cpp) void ClientReadUnreliableMessages( const idBitMsg &msg ); void ProcessUnreliableMessage( const idBitMsg &msg ); void UpdateClientsPVS( void ); bool IsDemoReplayInAreas( const int areas[2], int numAreas ); void ReallocViewers( int newMaxViewers ); void BuildModList( void ); public: void LoadBanList(); void SaveBanList(); void FlushBanList(); bool IsPlayerBanned( const char *name ); bool IsGuidBanned( const char *guid ); void AddGuidToBanList( const char *guid ); void RemoveGuidFromBanList( const char *guid ); virtual void RegisterClientGuid( int clientNum, const char *guid ); int GetBanListCount(); const mpBanInfo_t* GetBanListEntry( int entry ); // returns client name const char* GetGuidByClientNum( int clientNum ); // returns GUID int GetClientNumByGuid( const char* ); // returns clientNum // mekberg: get and send ban list void ServerSendBanList( int clientNum ); // jscott: made public pvsHandle_t GetClientPVS( idPlayer *player, pvsType_t type ); int GetCurrentDemoProtocol( void ) { return demo_protocol; } private: char clientGuids[ MAX_CLIENTS ][ CLIENT_GUID_LENGTH ]; idList<mpBanInfo_t> banList; bool banListLoaded; bool banListChanged; // RAVEN END }; //============================================================================ extern idGameLocal gameLocal; // RAVEN BEGIN // jsinger: animationLib changed to a pointer to prevent it from allocating memory // before the unified allocator is initialized extern idAnimManager *animationLib; // RAVEN END //============================================================================ ID_INLINE void idGameLocal::WriteDecl( idBitMsg &msg, const idDecl *decl ) { assert( decl ); if ( decl->IsImplicit() ) { gameLocal.Error( "WriteDecl: %s decl %s ( index %d ) is implicit", declManager->GetDeclNameFromType( decl->GetType() ), decl->GetName(), decl->Index() ); } msg.WriteLong( decl->Index() ); } ID_INLINE const idDecl* idGameLocal::ReadDecl( const idBitMsg &msg, declType_t type ) { int index = msg.ReadLong(); const idDecl *decl = declManager->DeclByIndex( type, index ); if ( !decl ) { gameLocal.Error( "ReadDecl: NULL %s decl at index %d", declManager->GetDeclNameFromType( type ), index ); } if ( decl->IsImplicit() ) { gameLocal.Error( "ReadDecl: %s decl %s ( index %d ) is implicit", declManager->GetDeclNameFromType( type ), decl->GetName(), decl->Index() ); } return decl; } ID_INLINE void idGameLocal::WriteDecl( idBitMsgDelta &msg, const idDecl *decl ) { assert( decl ); if ( decl->IsImplicit() ) { gameLocal.Error( "WriteDecl: %s decl %s ( index %d ) is implicit", declManager->GetDeclNameFromType( decl->GetType() ), decl->GetName(), decl->Index() ); } msg.WriteLong( decl->Index() ); } ID_INLINE const idDecl* idGameLocal::ReadDecl( const idBitMsgDelta &msg, declType_t type ) { int index = msg.ReadLong(); const idDecl *decl = declManager->DeclByIndex( type, index ); if ( !decl ) { gameLocal.Error( "ReadDecl: NULL %s decl at index %d", declManager->GetDeclNameFromType( type ), index ); } if ( decl->IsImplicit() ) { gameLocal.Error( "ReadDecl: %s decl %s ( index %d ) is implicit", declManager->GetDeclNameFromType( type ), decl->GetName(), decl->Index() ); } return decl; } //============================================================================ class idGameError : public idException { public: idGameError( const char *text ) : idException( text ) {} }; //============================================================================ // content masks #define MASK_ALL (-1) #define MASK_SOLID (CONTENTS_SOLID) #define MASK_MONSTERSOLID (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_BODY) #define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY) #define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP) #define MASK_WATER (CONTENTS_WATER) #define MASK_OPAQUE (CONTENTS_OPAQUE|CONTENTS_SIGHTCLIP) #define MASK_SHOT_RENDERMODEL (CONTENTS_SOLID|CONTENTS_RENDERMODEL) #define MASK_SHOT_BOUNDINGBOX (CONTENTS_SOLID|CONTENTS_BODY) #define MASK_LARGESHOT_RENDERMODEL (CONTENTS_SOLID|CONTENTS_RENDERMODEL|CONTENTS_LARGESHOTCLIP) #define MASK_LARGESHOT_BOUNDINGBOX (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_LARGESHOTCLIP) #define MASK_DMGSOLID (CONTENTS_SOLID|CONTENTS_LARGESHOTCLIP) // RAVEN BEGIN // creed: added monster clip #define MASK_MONSTERCLIP (CONTENTS_SOLID|CONTENTS_MONSTERCLIP) // RAVEN END const float DEFAULT_GRAVITY = 1066.0f; const float DEFAULT_GRAVITY_MP = 800.0f; #define DEFAULT_GRAVITY_STRING "1066" #define DEFAULT_MP_GRAVITY_STRING "800" const idVec3 DEFAULT_GRAVITY_VEC3( 0, 0, -DEFAULT_GRAVITY ); const int CINEMATIC_SKIP_DELAY = SEC2MS( 2.0f ); //============================================================================ #include "physics/Force.h" #include "physics/Force_Constant.h" #include "physics/Force_Drag.h" #include "physics/Force_Field.h" #include "physics/Force_Spring.h" #include "physics/Physics.h" #include "physics/Physics_Static.h" #include "physics/Physics_StaticMulti.h" #include "physics/Physics_Base.h" #include "physics/Physics_Actor.h" #include "physics/Physics_Monster.h" #include "physics/Physics_Player.h" #include "physics/Physics_Parametric.h" #include "physics/Physics_RigidBody.h" #include "physics/Physics_AF.h" #include "physics/Physics_Particle.h" #include "physics/Physics_VehicleMonster.h" #include "vehicle/VehicleController.h" #include "Entity.h" #include "Game_Debug.h" #include "IconManager.h" #include "GameEdit.h" #include "AF.h" #include "IK.h" #include "AFEntity.h" #include "Misc.h" #include "Actor.h" // client entities #include "client/ClientEntity.h" #include "client/ClientEffect.h" #include "client/ClientMoveable.h" #include "client/ClientModel.h" #include "client/ClientAFEntity.h" #include "Weapon.h" #include "script/ScriptFuncUtility.h" #include "Light.h" #include "WorldSpawn.h" #include "Item.h" #include "PlayerView.h" // TTimo: moved AI.h up, can't do template instanciation on forward declared-classes #include "ai/AI.h" #include "Player.h" #include "Mover.h" // RAVEN BEGIN // abahr: #include "vehicle/VehicleParts.h" #include "vehicle/Vehicle.h" #include "SplineMover.h" #include "TramGate.h" #include "vehicle/VehicleDriver.h" // RAVEN END #include "Camera.h" #include "Moveable.h" #include "Target.h" #include "Trigger.h" #include "Sound.h" #include "SecurityCamera.h" #include "BrittleFracture.h" // RAVEN BEGIN // nmckenzie: Reduce dependencies. #include "mp/CTF.h" #include "mp/stats/StatManager.h" #include "mp/Tourney.h" #include "Instance.h" // RAVEN END #include "anim/Anim_Testmodel.h" // RAVEN BEGIN // jscott: for lip syncing #include "LipSync.h" // RAVEN END #include "script/Script_Compiler.h" #include "script/Script_Interpreter.h" #include "script/Script_Thread.h" #ifdef _XENON #define PACIFIER_UPDATE session->PacifierUpdate() #else #define PACIFIER_UPDATE #endif ID_INLINE rvClientEffect* idGameLocal::PlayEffect( const idDict& args, const char* effectName, const idVec3& origin, const idMat3& axis, bool loop, const idVec3& endOrigin, bool broadcast, bool predictBit, effectCategory_t category, const idVec4& effectTint ) { return PlayEffect( GetEffect( args, effectName ), origin, axis, loop, endOrigin, broadcast, predictBit, category, effectTint ); } ID_INLINE bool idGameLocal::IsTeamGame( void ) const { return ( isMultiplayer && ( gameType == GAME_CTF || gameType == GAME_TDM || gameType == GAME_1F_CTF || gameType == GAME_ARENA_CTF || gameType == GAME_DEADZONE ) ); } ID_INLINE int idGameLocal::GetNumMapEntities( void ) const { if ( mapFile == NULL ) { return -1; } else { return mapFile->GetNumEntities(); } } ID_INLINE rvInstance* idGameLocal::GetInstance( int id ) { return instances[ id ]; } ID_INLINE int idGameLocal::GetNumInstances( void ) { return instances.Num(); } ID_INLINE void idGameLocal::ReceiveRemoteConsoleOutput( const char* output ) { if( isMultiplayer ) { mpGame.ReceiveRemoteConsoleOutput( output ); } } template< class type > type* idGameLocal::SpawnSafeEntityDef( const char* entityDefName, const idDict* additionalArgs ) { idEntity* entity = SpawnEntityDef( entityDefName, additionalArgs ); if( !entity ) { return NULL; } if( !entity->IsType(type::GetClassType()) ) { entity->PostEventMS( &EV_Remove, 0 ); return NULL; } return static_cast<type*>( entity ); } template< class type > ID_INLINE idEntityPtr<type>::idEntityPtr() { spawnId = 0; } template< class type > ID_INLINE void idEntityPtr<type>::Save( idSaveGame *savefile ) const { savefile->WriteInt( spawnId ); } template< class type > ID_INLINE void idEntityPtr<type>::Restore( idRestoreGame *savefile ) { savefile->ReadInt( spawnId ); } template< class type > ID_INLINE idEntityPtr<type> &idEntityPtr<type>::operator=( type *ent ) { if ( ent == NULL ) { spawnId = 0; } else { spawnId = ( gameLocal.spawnIds[ent->entityNumber] << GENTITYNUM_BITS ) | ent->entityNumber; } return *this; } template< class type > ID_INLINE bool idEntityPtr<type>::SetSpawnId( int id ) { if ( ( id >> GENTITYNUM_BITS ) == gameLocal.spawnIds[ id & ( ( 1 << GENTITYNUM_BITS ) - 1 ) ] ) { spawnId = id; return true; } return false; } template< class type > ID_INLINE bool idEntityPtr<type>::IsValid( void ) const { return ( gameLocal.spawnIds[ spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ) ] == ( spawnId >> GENTITYNUM_BITS ) ); } template< class type > ID_INLINE type *idEntityPtr<type>::GetEntity( void ) const { int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ); if ( ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) ) { return static_cast<type *>( gameLocal.entities[ entityNum ] ); } return NULL; } template< class type > ID_INLINE int idEntityPtr<type>::GetEntityNum( void ) const { return ( spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 ) ); } // RAVEN BEGIN // bdube: overloaded operator template< class type > ID_INLINE type * idEntityPtr<type>::operator->( void ) const { return GetEntity ( ); } template< class type > ID_INLINE idEntityPtr<type>::operator type * ( void ) const { return GetEntity(); } // RAVEN END #include "../idlib/containers/ListGame.h" #endif /* !__GAME_LOCAL_H__ */
ce1ae1867fd1325500acbd0643963f326dd3e9f7
342695543c11684e3e312a69b5fb3c29cc434c28
/ui_alilogincircling.h
b86c94321dc9ba13ffb6393be2fe7806e975ca6b
[]
no_license
Mr-MoRL/-
8fd338365abe97f490c4f7daa05f6d6493dff6bc
77fd27a5c43c6e3e83bc9188bd4781da3fca3187
refs/heads/master
2022-04-17T21:11:31.990774
2020-04-10T12:59:35
2020-04-10T12:59:35
254,629,131
4
0
null
null
null
null
UTF-8
C++
false
false
2,933
h
ui_alilogincircling.h
/******************************************************************************** ** Form generated from reading UI file 'alilogincircling.ui' ** ** Created by: Qt User Interface Compiler version 5.8.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_ALILOGINCIRCLING_H #define UI_ALILOGINCIRCLING_H #include <QtCore/QVariant> #include <QtWidgets/QAction> #include <QtWidgets/QApplication> #include <QtWidgets/QButtonGroup> #include <QtWidgets/QHeaderView> #include <QtWidgets/QLabel> #include <QtWidgets/QWidget> #include <refreshcircle1.h> QT_BEGIN_NAMESPACE class Ui_aliLogincircling { public: QLabel *label; RefreshCicle1 *circle; QWidget *widget; QLabel *logo; void setupUi(QWidget *aliLogincircling) { if (aliLogincircling->objectName().isEmpty()) aliLogincircling->setObjectName(QStringLiteral("aliLogincircling")); aliLogincircling->resize(367, 501); label = new QLabel(aliLogincircling); label->setObjectName(QStringLiteral("label")); label->setGeometry(QRect(109, 280, 151, 41)); QFont font; font.setFamily(QStringLiteral("Adobe Pi Std")); font.setPointSize(16); font.setBold(true); font.setWeight(75); label->setFont(font); label->setAlignment(Qt::AlignCenter); circle = new RefreshCicle1(aliLogincircling); circle->setObjectName(QStringLiteral("circle")); circle->setGeometry(QRect(100, 83, 166, 166)); circle->setStyleSheet(QStringLiteral("QWidget{background-color: transparent;}")); widget = new QWidget(aliLogincircling); widget->setObjectName(QStringLiteral("widget")); widget->setGeometry(QRect(0, 0, 367, 501)); widget->setStyleSheet(QStringLiteral("QWidget{background-color: rgb(255, 255, 255)}")); logo = new QLabel(aliLogincircling); logo->setObjectName(QStringLiteral("logo")); logo->setGeometry(QRect(117, 100, 131, 131)); logo->setPixmap(QPixmap(QString::fromUtf8(":/Alilogo.PNG"))); logo->setAlignment(Qt::AlignCenter); widget->raise(); label->raise(); logo->raise(); circle->raise(); retranslateUi(aliLogincircling); QMetaObject::connectSlotsByName(aliLogincircling); } // setupUi void retranslateUi(QWidget *aliLogincircling) { aliLogincircling->setWindowTitle(QApplication::translate("aliLogincircling", "Form", Q_NULLPTR)); label->setText(QApplication::translate("aliLogincircling", "\346\255\243\345\234\250\346\216\210\346\235\203...", Q_NULLPTR)); logo->setText(QString()); } // retranslateUi }; namespace Ui { class aliLogincircling: public Ui_aliLogincircling {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_ALILOGINCIRCLING_H
9c693fa4782ff515b240ea8cb11cec5b5e648344
86acd48da71f0faa0642c99173b9cf31b51ca5e5
/examples/A. Modul IO Aktif High/04. Set Reset/O2_Set_Reset_Variabel/O2_Set_Reset_Variabel.ino
bd037b20165e43943c64df36ce0e96b97da1f64d
[]
no_license
dianartanto/PLCArduinoku
3b48af462f567247a768d72cf544f5637c12649d
968e515f429659de1d180aaea2cb3348b87d8893
refs/heads/master
2021-01-19T08:59:28.804031
2015-04-14T05:52:40
2015-04-14T05:52:40
33,913,346
0
0
null
null
null
null
UTF-8
C++
false
false
702
ino
O2_Set_Reset_Variabel.ino
/* 1.Rangkaian: Modul Input Output Aktif High. Kaki Input : X1, X2 (kaki A0 dan A1 Arduino) Kaki Output : Y1 (kaki D2 Arduino) Alat Input : Tombol 2x Alat Output : Relay 1x 2.Program: X1 Y1 1 ||-------] [--------------(S)-------|| || X2 Y1 || 2 ||-------] [--------------(R)-------|| Ketika tombol di X1 ditekan, maka Relay di Y1 hidup dan tetap hidup sekalipun tombol di X1 telah dilepas. Ketika tombol di X2 ditekan barulah Relay di Y1 mati. */ #include <PLCArduinoku.h> unsigned int R1; void setup() { setupku(); outLow(); } void loop() { if(in(X1)) R1=1; if(in(X2)) R1=0; in(R1); out(Y1); }
84cbdcdc41cd0622667545b7697245d61bfae8e5
d66458d42fc34b442e19970af4bdf0d4e143450f
/PTRecordFile.h
fe8fb07b0a01bccaa0c6c1aa3cb68998481a53d0
[]
no_license
KirillKomarov/CristallModel
0d04f8d1ddb0371472df5a1e0751c9e9228d9eaf
e5995a797f4addf14a71e7864017d954d40d2d60
refs/heads/master
2021-01-19T12:52:15.775250
2017-04-12T11:06:57
2017-04-12T11:06:57
88,054,174
0
0
null
null
null
null
UTF-8
C++
false
false
1,104
h
PTRecordFile.h
#pragma once #ifndef MYALGEBRA_H_ #define MYALGEBRA_H_ #include <iostream> #include <fstream> #include <vector> #include <string> #include <Eigen/Eigen> //#include "ProgramConstant.h" void recordVector(Eigen::VectorXd& vector, std::string adress, std::string name, std::string format); void recordCollection(std::vector<Eigen::Vector3d>& collection, std::string adress, std::string name, std::string format, int s); void recordCollection(std::vector<Eigen::VectorXd>& collection, std::string adress, std::string name, std::string format); void recordCollection(std::vector<Eigen::Vector3d>& collection, std::string adress, std::string name, std::string format); void recordVector(Eigen::VectorXd& vector, std::string adress, std::string name, std::string format, int s); void recordMatrix(Eigen::MatrixXd& matrix, std::string adress, std::string name, std::string format); void recordMatrix(Eigen::MatrixXd& matrix, std::string adress, std::string name, std::string format, int s); void recordVector(std::vector<double> vector, std::string adress, std::string name, std::string format); #endif
249cee22bb2e16c95a91595d9517aff5432eeaa8
e5ae1568208504221116057dadaa8fb23db39eb6
/kundendaten/src/window_neue_bank_anlegen_glade.hh
a00e594a11b7ae8634413e2a5a701fc94eff2110
[]
no_license
cpetig/manuproc
025dce0f63cc56db36e8b4e613154eda859094b8
1bbfb9e214792cd3537bf59e5e3a93dcab6f6d59
refs/heads/master
2021-05-31T06:23:51.799144
2007-01-11T14:18:16
2007-01-11T14:18:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,468
hh
window_neue_bank_anlegen_glade.hh
// generated 2005/6/24 11:37:58 CEST by christof@vesta.petig-baender.de // using glademm V2.6.0 // // DO NOT EDIT THIS FILE ! It was created using // glade-- kundendaten.glade // for gtk 2.7.0 and gtkmm 2.6.3 // // Please modify the corresponding derived classes in ./src/window_neue_bank_anlegen.hh and./src/window_neue_bank_anlegen.cc #ifndef _WINDOW_NEUE_BANK_ANLEGEN_GLADE_HH # define _WINDOW_NEUE_BANK_ANLEGEN_GLADE_HH #if !defined(GLADEMM_DATA) #define GLADEMM_DATA #include <gtkmm/accelgroup.h> class GlademmData { Glib::RefPtr<Gtk::AccelGroup> accgrp; public: GlademmData(Glib::RefPtr<Gtk::AccelGroup> ag) : accgrp(ag) { } Glib::RefPtr<Gtk::AccelGroup> getAccelGroup() { return accgrp; } }; #endif //GLADEMM_DATA #include <gtkmm/window.h> #include <gtkmm/entry.h> #include <gtkmm/label.h> class window_neue_bank_anlegen_glade : public Gtk::Window { GlademmData *gmm_data; protected: class Gtk::Entry * entry_bankname; class Gtk::Entry * entry_blz; class Gtk::Label * label_text; window_neue_bank_anlegen_glade(); ~window_neue_bank_anlegen_glade(); private: virtual void on_entry_bankname_activate() = 0; virtual void on_entry_blz_activate() = 0; virtual void on_button_uebernehmen_clicked() = 0; virtual void on_button_abbrechen_clicked() = 0; }; #endif
e11e1171a1f7974e6a866fd354c59e9a2ebdcfee
2bce17904e161a4bdaa2d65cefd25802bf81c85b
/codeforces/193/B/B.cc
5d333508c2d6c999f21f70540cbb448cd3600b77
[]
no_license
lichenk/AlgorithmContest
9c3e26ccbe66d56f27e574f5469e9cfa4c6a74a9
74f64554cb05dc173b5d44b8b67394a0b6bb3163
refs/heads/master
2020-03-24T12:52:13.437733
2018-08-26T01:41:13
2018-08-26T01:41:13
142,727,319
0
0
null
null
null
null
UTF-8
C++
false
false
1,925
cc
B.cc
#include "bits/stdc++.h" #include <assert.h> using namespace std; typedef long long ll; typedef long double ld; #define PB push_back #define MP make_pair const int MOD=1000000007; #define endl "\n" #define fst first #define snd second const int UNDEF = -1; const ll INF=1e18; template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; } template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; } typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi; #define DEBUG_CAT #ifdef DEBUG_CAT #define dbg(...) printf( __VA_ARGS__ ) #else #define dbg(...) /****nothing****/ #endif int rint();char rch();long long rlong(); const int mn=32; int tmp[mn]; int n,u,r; vi b, k, p; inline void do1(vi &a) { for (int x=0;x<n;x++) a[x]^=b[x]; } inline void do2(vi &a) { for (int x=0;x<n;x++) tmp[x]=a[p[x]]+r; for (int x=0;x<n;x++) a[x]=tmp[x]; } ll go(int t, int o, vi a) { if (t==0) { if (o&1) do1(a); ll ans=0; for (int x=0;x<n;x++) ans+=a[x]*k[x]; return ans; } else { ll ans=-(1LL<<62); if (o>0) { vi na=a; do1(na); do2(na); chkmax(ans,go(t-1,o-1,na)); } do2(a); chkmax(ans,go(t-1,o,a)); return ans; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); n=rint(),u=rint(),r=rint(); vi a; a.resize(n),b.resize(n),k.resize(n),p.resize(n); for (int x=0;x<n;x++) a[x]=rint(); for (int x=0;x<n;x++) b[x]=rint(); for (int x=0;x<n;x++) k[x]=rint(); for (int x=0;x<n;x++) p[x]=rint()-1; ll final=-(1LL<<62); for (int t=0;t<=u;t++) { int o=u-t; ll got=go(t,o,a); chkmax(final,got); } printf("%lld\n",final); } int rint() { int x; scanf("%d",&x); return x; } char rch() { char x; scanf("%c",&x); return x; } long long rlong() { long long x; scanf("%lld",&x); return x; }
7084bb363d6eaad5976d72974f4994267341a18f
1fe97875709e1c5e68ede59fbe6975ac52b306e3
/session-2/howtostart.cpp
1aeb23ab1b506fbe356e212966c5334173f42e29
[]
no_license
kronsi/howtogetanerd
2155bb6d220dd687ed0c70a2eb25bd7603b4427f
8a1f069a36b9bc4f34f0d1d0aeabe7a655cbbe0c
refs/heads/master
2023-06-03T17:10:03.554479
2021-06-25T11:36:58
2021-06-25T11:36:58
358,292,560
1
1
null
null
null
null
UTF-8
C++
false
false
319
cpp
howtostart.cpp
#include <iostream> using namespace std; int main() { int number1; int number2; cout << "Gib eine Zahl ein: "; cin >> number1; cout << "Gib eine zweite Zahl ein: "; cin >> number2; cout << "Summe: " << (number2 + number1) << endl; //cout << (number1 + number2) << endl; return 0; }
83c86937e7c55981bb1bfe6e6db99fe7c500c110
8d831f0e7bdf007b7ffd17059986a2bde1028ca4
/TEST.cpp
3ce5b8c1f1b8fda68f43a87e278f76155c6d8d87
[]
no_license
anushka7244/cpp
b3f33cb173fafacd1f20309a40a0988ba6dfaf2c
5d29052149fcce19ac4af05a92734301576b9475
refs/heads/master
2023-08-07T07:29:00.025797
2021-10-05T06:37:09
2021-10-05T06:37:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
177
cpp
TEST.cpp
#include <iostream> using namespace std; int main() { int input ; while( cin >> input && input != 42 ) cout << '\t' << input << '\n' ; while( cin >> input ) ; }
7f703c449ba3104427fca602e4ca62050f1c66f9
0fb5d0ed28894b4effc41fce1e783790dda61004
/cppcache/src/ClientMetadataService.hpp
ce6209df1a5586de7fd614a171fc35315806f88d
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-generic-cla", "LicenseRef-scancode-unknown" ]
permissive
mmartell/geode-native
9760e5b8cdd638dbca69e0919be602482518bee3
fa6edf5d3ad83c78431f0c5e2da163b7a0df5558
refs/heads/develop
2022-05-26T06:23:13.244763
2021-03-05T21:25:49
2021-03-05T21:25:49
81,501,967
0
0
Apache-2.0
2021-03-05T21:31:43
2017-02-09T22:37:58
C++
UTF-8
C++
false
false
8,161
hpp
ClientMetadataService.hpp
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ #pragma once #ifndef GEODE_CLIENTMETADATASERVICE_H_ #define GEODE_CLIENTMETADATASERVICE_H_ #include <unordered_map> #include <memory> #include <string> #include <ace/Task.h> #include <geode/CacheableKey.hpp> #include <geode/Serializable.hpp> #include <geode/Region.hpp> #include <geode/internal/functional.hpp> #include "ClientMetadata.hpp" #include "ServerLocation.hpp" #include "BucketServerLocation.hpp" #include "Queue.hpp" #include "DistributedSystemImpl.hpp" #include "NonCopyable.hpp" namespace apache { namespace geode { namespace client { class ClienMetadata; typedef std::map<std::string, std::shared_ptr<ClientMetadata>> RegionMetadataMapType; class BucketStatus { private: ACE_Time_Value m_lastTimeout; public: BucketStatus() : m_lastTimeout(ACE_Time_Value::zero) {} bool isTimedoutAndReset(std::chrono::milliseconds millis) { if (m_lastTimeout == ACE_Time_Value::zero) { return false; } else { ACE_Time_Value to(millis); to += m_lastTimeout; if (to > ACE_OS::gettimeofday()) { return true; // timeout as buckste not recovered yet } else { // reset to zero as we waited enough to recover bucket m_lastTimeout = ACE_Time_Value::zero; return false; } } } void setTimeout() { if (m_lastTimeout == ACE_Time_Value::zero) { m_lastTimeout = ACE_OS::gettimeofday(); // set once only for timeout } } }; class PRbuckets { private: BucketStatus* m_buckets; public: PRbuckets(int32_t nBuckets) { m_buckets = new BucketStatus[nBuckets]; } ~PRbuckets() { delete[] m_buckets; } bool isBucketTimedOut(int32_t bucketId, std::chrono::milliseconds millis) { return m_buckets[bucketId].isTimedoutAndReset(millis); } void setBucketTimeout(int32_t bucketId) { m_buckets[bucketId].setTimeout(); } }; class ClientMetadataService : public ACE_Task_Base, private NonCopyable, private NonAssignable { public: ~ClientMetadataService(); ClientMetadataService(Pool* pool); inline void start() { m_run = true; this->activate(); } inline void stop() { m_run = false; m_regionQueueSema.release(); this->wait(); } int svc(void); void getClientPRMetadata(const char* regionFullPath); void getBucketServerLocation( const std::shared_ptr<Region>& region, const std::shared_ptr<CacheableKey>& key, const std::shared_ptr<Cacheable>& value, const std::shared_ptr<Serializable>& aCallbackArgument, bool isPrimary, std::shared_ptr<BucketServerLocation>& serverLocation, int8_t& version); void removeBucketServerLocation(BucketServerLocation serverLocation); std::shared_ptr<ClientMetadata> getClientMetadata( const std::string& regionFullPath); void populateDummyServers(const char* regionName, std::shared_ptr<ClientMetadata> clientmetadata); void enqueueForMetadataRefresh(const std::string& regionFullPath, int8_t serverGroupFlag); typedef std::unordered_map< std::shared_ptr<BucketServerLocation>, std::shared_ptr<std::vector<std::shared_ptr<CacheableKey>>>, dereference_hash<std::shared_ptr<BucketServerLocation>>, dereference_equal_to<std::shared_ptr<BucketServerLocation>>> ServerToFilterMap; std::shared_ptr<ServerToFilterMap> getServerToFilterMap( const std::vector<std::shared_ptr<CacheableKey>>& keys, const std::shared_ptr<Region>& region, bool isPrimary); void markPrimaryBucketForTimeout( const std::shared_ptr<Region>& region, const std::shared_ptr<CacheableKey>& key, const std::shared_ptr<Cacheable>& value, const std::shared_ptr<Serializable>& aCallbackArgument, bool isPrimary, std::shared_ptr<BucketServerLocation>& serverLocation, int8_t& version); void markPrimaryBucketForTimeoutButLookSecondaryBucket( const std::shared_ptr<Region>& region, const std::shared_ptr<CacheableKey>& key, const std::shared_ptr<Cacheable>& value, const std::shared_ptr<Serializable>& aCallbackArgument, bool isPrimary, std::shared_ptr<BucketServerLocation>& serverLocation, int8_t& version); bool isBucketMarkedForTimeout(const char* regionFullPath, int32_t bucketid); typedef std::unordered_set<int32_t> BucketSet; typedef std::unordered_map< std::shared_ptr<BucketServerLocation>, std::shared_ptr<BucketSet>, dereference_hash<std::shared_ptr<BucketServerLocation>>, dereference_equal_to<std::shared_ptr<BucketServerLocation>>> ServerToBucketsMap; // bool AreBucketSetsEqual(const BucketSet& currentBucketSet, // const BucketSet& bucketSet); std::shared_ptr<BucketServerLocation> findNextServer( const ServerToBucketsMap& serverToBucketsMap, const BucketSet& currentBucketSet); typedef std::unordered_map<int32_t, std::shared_ptr<CacheableHashSet>> BucketToKeysMap; std::shared_ptr<BucketToKeysMap> groupByBucketOnClientSide( const std::shared_ptr<Region>& region, const std::shared_ptr<CacheableVector>& keySet, const std::shared_ptr<ClientMetadata>& metadata); typedef std::unordered_map< std::shared_ptr<BucketServerLocation>, std::shared_ptr<CacheableHashSet>, dereference_hash<std::shared_ptr<BucketServerLocation>>, dereference_equal_to<std::shared_ptr<BucketServerLocation>>> ServerToKeysMap; std::shared_ptr<ServerToKeysMap> getServerToFilterMapFESHOP( const std::shared_ptr<CacheableVector>& keySet, const std::shared_ptr<Region>& region, bool isPrimary); std::shared_ptr<ClientMetadataService::ServerToBucketsMap> groupByServerToAllBuckets(const std::shared_ptr<Region>& region, bool optimizeForWrite); std::shared_ptr<ClientMetadataService::ServerToBucketsMap> groupByServerToBuckets(const std::shared_ptr<ClientMetadata>& metadata, const BucketSet& bucketSet, bool optimizeForWrite); std::shared_ptr<ClientMetadataService::ServerToBucketsMap> pruneNodes( const std::shared_ptr<ClientMetadata>& metadata, const BucketSet& buckets); private: // const std::shared_ptr<PartitionResolver>& getResolver(const // std::shared_ptr<Region>& region, const std::shared_ptr<CacheableKey>& key, // const std::shared_ptr<Serializable>& aCallbackArgument); // BucketServerLocation getServerLocation(std::shared_ptr<ClientMetadata> // cptr, int bucketId, bool isPrimary); std::shared_ptr<ClientMetadata> SendClientPRMetadata( const char* regionPath, std::shared_ptr<ClientMetadata> cptr); std::shared_ptr<ClientMetadata> getClientMetadata(const std::shared_ptr<Region>& region); private: // ACE_Recursive_Thread_Mutex m_regionMetadataLock; ACE_RW_Thread_Mutex m_regionMetadataLock; ClientMetadataService(); ACE_Semaphore m_regionQueueSema; RegionMetadataMapType m_regionMetaDataMap; volatile bool m_run; Pool* m_pool; Queue<std::string>* m_regionQueue; ACE_RW_Thread_Mutex m_PRbucketStatusLock; std::map<std::string, PRbuckets*> m_bucketStatus; std::chrono::milliseconds m_bucketWaitTimeout; static const char* NC_CMDSvcThread; }; } // namespace client } // namespace geode } // namespace apache #endif // GEODE_CLIENTMETADATASERVICE_H_
1f7369e272eeeb69933d332918e710392e00145f
f0347b369c3f9b5b353b35048016bff76f22a5b9
/530/sol.cpp
63529e29fafb4a8fb1df93d90f022aca5ce0e473
[]
no_license
546Archie/Leetcode
a8224c6127a0afd270cb2397a667d148020c9492
366cfc6ffaff98fa4bf79209d9de7b60d5ed49b9
refs/heads/main
2023-06-08T21:50:48.440032
2021-06-26T03:48:44
2021-06-26T03:48:44
330,677,265
0
0
null
null
null
null
UTF-8
C++
false
false
804
cpp
sol.cpp
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: int diff = INT_MAX; TreeNode *pre = NULL; void dfs(TreeNode *root){ //go left as much as possible if(root->left){ dfs(root->left); } //if there is a node, update the diff between node if(pre) diff = min(diff, abs(pre->val - root->val)); //update pre node pre = root; //go right as much as possible if(root->right){ dfs(root->right); } } int getMinimumDifference(TreeNode *root) { dfs(root); return diff; } };
8e5cd012c9ae20d61acc40bcf8c051abede5109a
c0ff488af82adfb20d712d21e08414ef9998c4e3
/Src/Cust/Stm32/F429/Bsw/IoHwAb/IoHwAb_Cfg.cpp
b9dfaca828259628ec63e31303d206a196c1e2bb
[ "BSL-1.0" ]
permissive
einChi20/autosar-framework
9905381fff6f010985a423d566190e0ec29aad5b
abcf11970470c082b2137da16e9b1a460e72fd74
refs/heads/master
2021-05-28T20:40:26.477118
2015-03-13T09:25:02
2015-03-13T09:25:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
747
cpp
IoHwAb_Cfg.cpp
/////////////////////////////////////////////////////// // Copyright 2014 Stephan Hage. // Copyright 2014 Christopher Kormanyos. // Distributed under the Boost // Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt ) // #include <Bsw/IoHwAb/IoHwAb.h> #include <Bsw/Mcal/Mcal.h> Std_ReturnType IoHwAb_Set_Digital(IoHwAb_SignalType signal, IoHwAb_LevelType newValue, IoHwAb_StatusType* status) { static_cast<void>(status); Std_ReturnType io_result; switch(signal) { case 0: Dio_WriteChannel(DIO_CHANNEL_OPERATION, newValue); io_result = E_OK; break; default: io_result = E_NOT_OK; break; } return io_result; }
9edf4075bd88050b06db4335422a6ada9bc766d8
0bcd663651be17ffbdf9ab2ab5be4ae53a9b9e61
/lab3/B.cpp
910e2340367aa81b4690233cc71c7721cfdfa211
[]
no_license
VankaTaganai/Discrete_Math_ITMO
599ff71104c8794d4afbd6d678f1252041744c28
4f248fdbf052559b78a586aa9b115fcadb6a13f9
refs/heads/master
2021-02-11T04:32:07.250527
2020-05-23T08:21:51
2020-05-23T08:21:51
244,454,706
0
0
null
null
null
null
UTF-8
C++
false
false
939
cpp
B.cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; #define ff first #define ss second const double eps = 1e-6; const int inf = 1e9 + 7; const ll mod = 999999937; const int maxn = 400 + 7; int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #else freopen("gray.in", "r", stdin); freopen("gray.out", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<string> v = {"0", "1"}; for (int i = 0; i < n - 1; i++) { vector<string> res; for (int j = 0; j < v.size(); j++) { res.push_back("0" + v[j]); } for (int j = v.size() - 1; j >= 0; j--) { res.push_back("1" + v[j]); } v = res; } for (string i : v) { cout << i << "\n"; } return 0; }
ad645d5a8b1aaa969d68f0a66bc3ab8165c66716
d33b8d890b189253707df91687fce4a237c5cfe9
/dcc/dcc/dcc/io/file_reader.h
067ddc6eb7af296e2318fe28f4a7ea0cd9c96615
[]
no_license
bqqbarbhg/dcc
c38d504a42f0cdd3549b238de24ad5ad18c41587
09f91ed89ba2a22466a8067a50b7909af7fe97ce
refs/heads/master
2021-01-18T15:17:06.095813
2013-05-05T22:36:58
2013-05-05T22:36:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
742
h
file_reader.h
#ifndef _DCC_IO_FILE_READER_H #define _DCC_IO_FILE_READER_H #include <fstream> #include <dcc/file.h> namespace dcc { namespace io { class FileReader { public: FileReader(FileReader&& reader); FileReader(File& file); // Reads a sinlge character from the file // Updates the files newline indices // Returns 0 on EOF char get(); // Returns one read character back to the stream // Next call to `get` returns the last `get` result void unget(); // Returns the index of the current character in the file src_charpos_t get_char_index() const { return charpos; } private: File& file; std::ifstream in; src_charpos_t charpos, real_charpos; src_line_t linenum; std::string line; std::string::iterator line_it; }; } } #endif
f2fe6747492296cdbe070020f4ef794539efb5ae
92e67b30497ffd29d3400e88aa553bbd12518fe9
/assignment2/part6/Re=110/22.5/U
afd54659b9518b01128e95f36cb2a8f72db7695f
[]
no_license
henryrossiter/OpenFOAM
8b89de8feb4d4c7f9ad4894b2ef550508792ce5c
c54b80dbf0548b34760b4fdc0dc4fb2facfdf657
refs/heads/master
2022-11-18T10:05:15.963117
2020-06-28T15:24:54
2020-06-28T15:24:54
241,991,470
0
0
null
null
null
null
UTF-8
C++
false
false
62,403
U
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "22.5"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 2000 ( (0.00519035 0.0252535 3.03666e-22) (0.027049 0.0918325 0) (0.0611218 0.160778 0) (0.0920626 0.222507 4.53607e-22) (0.115878 0.2727 1.63218e-22) (0.131767 0.311075 2.26011e-22) (0.140867 0.339462 -2.89506e-22) (0.145016 0.360244 0) (0.145988 0.375517 0) (0.145312 0.386726 0) (0.0031004 0.017871 0) (0.0188571 0.0747626 6.34601e-22) (0.0477281 0.138706 -5.85083e-22) (0.0766827 0.200033 -5.3058e-22) (0.101435 0.253309 0) (0.119908 0.296473 5.17938e-22) (0.131978 0.329849 -4.81638e-22) (0.138658 0.354923 0) (0.141328 0.373481 2.87212e-21) (0.141594 0.387048 -6.03192e-21) (0.00194209 0.0113735 0) (0.012612 0.058301 -4.94789e-21) (0.0358688 0.115505 0) (0.0614663 0.174071 -1.75229e-21) (0.0856271 0.228442 0) (0.105671 0.27541 -8.78247e-22) (0.120436 0.313878 0) (0.12999 0.344154 3.96307e-21) (0.135033 0.367287 -3.71176e-21) (0.136938 0.384539 -4.77002e-21) (0.00150236 0.00593081 1.49238e-21) (0.00819188 0.0431787 2.52702e-21) (0.025952 0.0924536 9.25015e-22) (0.0472784 0.146022 1.23281e-21) (0.069339 0.198978 4.79835e-22) (0.0895114 0.247785 2.1175e-22) (0.106074 0.2904 6.1974e-22) (0.118297 0.326021 -8.20601e-22) (0.126094 0.354711 3.04462e-21) (0.130268 0.377098 4.75911e-21) (0.00153899 0.00163486 1.52203e-21) (0.00530428 0.0299313 1.76335e-21) (0.0181036 0.0707227 1.97904e-21) (0.034835 0.117558 -9.90014e-22) (0.0536681 0.166563 0) (0.0724649 0.21456 0) (0.089451 0.259235 -1.84933e-21) (0.103462 0.299106 -2.60586e-21) (0.113809 0.333362 2.46894e-21) (0.120296 0.361734 1.06686e-20) (0.00181162 -0.001511 -1.13244e-21) (0.0035703 0.0188619 -4.66095e-22) (0.0122029 0.0512152 3.29789e-21) (0.0245613 0.090303 -2.72121e-21) (0.0396345 0.133299 3.70659e-22) (0.0559031 0.177758 0) (0.0718853 0.221658 0) (0.0863474 0.263409 8.75124e-21) (0.0985016 0.301837 -1.09338e-20) (0.106311 0.335433 3.19051e-21) (0.00210906 -0.00357657 -8.282e-21) (0.00260873 0.0100651 0) (0.00798278 0.0345107 -4.40763e-21) (0.0165778 0.0655823 2.3202e-21) (0.02795 0.101312 0) (0.0411325 0.140026 6.79386e-22) (0.055066 0.180285 -2.29418e-21) (0.0687072 0.220813 -5.85608e-21) (0.0817944 0.260829 2.73884e-21) (0.0891199 0.296586 4.10822e-21) (0.00227502 -0.00468759 1.53396e-20) (0.00211362 0.00347793 1.17108e-21) (0.00516109 0.0209029 1.55733e-21) (0.0108181 0.0443365 2.31844e-21) (0.0189843 0.0724087 -9.76229e-23) (0.0291086 0.10406 -6.22904e-22) (0.0405414 0.138424 2.32634e-22) (0.0526348 0.174724 0) (0.065975 0.213171 0) (0.0713191 0.246863 -1.46271e-21) (0.00222575 -0.00500621 -7.05763e-21) (0.00191253 -0.00107084 4.54496e-21) (0.00355403 0.0104788 -2.73218e-21) (0.00719225 0.0271671 -2.69354e-21) (0.0128987 0.0479733 4.26671e-22) (0.020406 0.0722077 5.67153e-22) (0.0294202 0.0993758 9.36714e-22) (0.0398857 0.129184 0) (0.0531721 0.162743 0) (0.0568957 0.18936 1.95565e-22) (0.00195806 -0.00471865 7.06983e-22) (0.00199674 -0.00382504 -5.45772e-21) (0.00314548 0.00319555 8.40908e-22) (0.00572032 0.0144381 0) (0.00982904 0.0290325 0) (0.0153589 0.0464169 6.77578e-22) (0.022267 0.0661873 0) (0.0310548 0.0881974 -1.48413e-21) (0.0437983 0.113121 1.018e-21) (0.0507229 0.128706 3.5176e-22) (0.139277 0.404725 4.47486e-22) (0.121429 0.407676 -4.54983e-22) (0.102079 0.401885 -6.61502e-22) (0.0848886 0.394997 -7.7308e-22) (0.0665681 0.389221 -9.13538e-22) (0.0526367 0.38809 -6.49242e-24) (0.0347933 0.405054 4.63687e-22) (0.0263051 0.478987 1.52203e-21) (0.00432416 0.634666 0) (0.00719988 0.821569 -1.05196e-21) (0.136909 0.407922 9.9649e-22) (0.119037 0.412334 -2.28107e-21) (0.0999611 0.406955 4.20839e-21) (0.0830734 0.400247 7.74462e-22) (0.0650163 0.394183 1.6292e-21) (0.0512766 0.392539 2.68961e-21) (0.0338636 0.409079 -9.69564e-22) (0.0253889 0.482373 -1.01036e-21) (0.0044477 0.637334 1.93024e-21) (0.00680771 0.822833 1.04946e-21) (0.134865 0.410655 0) (0.117022 0.416954 -1.78618e-21) (0.0982179 0.412191 -1.25146e-21) (0.0815525 0.405631 0) (0.0636335 0.399128 -4.92234e-21) (0.0500221 0.396822 1.55064e-21) (0.0329458 0.412602 1.65977e-21) (0.0244594 0.484888 5.44629e-21) (0.00450997 0.639342 -1.92399e-21) (0.00643409 0.823762 3.75307e-21) (0.132711 0.412085 0) (0.115263 0.420933 1.80186e-21) (0.0967935 0.417235 0) (0.0802769 0.410949 5.67001e-21) (0.0624066 0.403997 -5.69809e-21) (0.0488789 0.40097 -3.30317e-21) (0.0320487 0.415671 -1.52668e-22) (0.0235431 0.486551 -5.26233e-21) (0.00454124 0.640481 -8.70827e-22) (0.00606216 0.824339 -4.62381e-21) (0.129641 0.410979 2.40019e-21) (0.113667 0.424648 -2.66219e-21) (0.0957993 0.42274 9.26403e-22) (0.0792636 0.41649 -4.64656e-21) (0.0613081 0.408886 0) (0.0477986 0.405004 -3.12419e-21) (0.0311095 0.418328 -1.05116e-22) (0.0225362 0.487508 6.64096e-21) (0.00442776 0.64107 8.36699e-22) (0.00566943 0.82459 -8.3973e-22) (0.12484 0.404881 -6.01128e-21) (0.111818 0.426028 5.76463e-21) (0.0949875 0.427352 4.33534e-21) (0.0784343 0.421605 -4.33087e-21) (0.0603989 0.413658 -2.60301e-21) (0.0468833 0.408985 0) (0.0302465 0.420662 -5.96288e-21) (0.0215674 0.487651 2.9574e-21) (0.00428886 0.640554 3.09239e-21) (0.00528419 0.824464 3.09591e-21) (0.117478 0.392684 -4.38079e-22) (0.109819 0.427534 0) (0.0946366 0.43319 0) (0.0777785 0.427221 0) (0.0595096 0.418551 -2.67216e-21) (0.0458887 0.412852 5.2657e-21) (0.0291957 0.422678 5.77598e-21) (0.0203096 0.487408 -8.65287e-21) (0.00385063 0.639974 1.4664e-21) (0.00481015 0.824064 -4.51846e-21) (0.107665 0.369359 1.56055e-21) (0.106524 0.422407 5.69047e-21) (0.0939421 0.435771 -5.63364e-21) (0.0773521 0.431602 8.99671e-21) (0.0590898 0.423277 -1.12272e-20) (0.0453711 0.416869 0) (0.0285479 0.424555 -2.57769e-21) (0.0193409 0.486106 1.68751e-22) (0.00350634 0.637615 -2.60397e-21) (0.00441174 0.823204 -2.69102e-21) (0.0961011 0.342906 -7.1475e-22) (0.103729 0.421873 0) (0.0935792 0.441607 -7.64362e-21) (0.0766239 0.437359 1.53207e-20) (0.0580608 0.428189 -6.0193e-21) (0.0440613 0.420482 -1.18491e-21) (0.0270478 0.426176 2.57218e-21) (0.017486 0.485459 8.03212e-23) (0.00251169 0.636586 3.79338e-21) (0.00376415 0.822223 3.90791e-21) (0.0829624 0.291076 -2.10024e-21) (0.0973913 0.402775 2.03539e-21) (0.0922535 0.438626 6.79292e-22) (0.0770712 0.440487 0) (0.0588822 0.433081 0) (0.0447881 0.425014 1.14538e-21) (0.0274743 0.427788 4.57148e-21) (0.0170459 0.482016 -4.46319e-21) (0.00209034 0.631598 -1.1165e-21) (0.00339424 0.820554 1.07552e-21) (0.0601526 0.24711 0) (0.0909343 0.401575 0) (0.0863607 0.451711 0) (0.0697721 0.455124 0) (0.0503707 0.443808 0) (0.0350911 0.431522 0) (0.0180067 0.431723 0) (0.00814387 0.484859 0) (-0.00282773 0.631633 0) (0.00112411 0.817369 0) (0.0430271 0.228993 0) (0.0723894 0.393796 0) (0.0686572 0.457756 0) (0.0572923 0.470952 0) (0.0438026 0.464793 0) (0.0316947 0.453994 0) (0.0151761 0.453216 0) (0.00210985 0.501259 0) (-0.00753134 0.639673 0) (-8.16931e-05 0.819829 0) (0.0341002 0.233089 0) (0.0533412 0.395674 0) (0.0480017 0.468249 0) (0.0343586 0.481457 0) (0.018964 0.472297 0) (0.00641954 0.460002 0) (-0.00839957 0.459905 0) (-0.0190912 0.505273 0) (-0.0223436 0.634407 0) (-0.00221599 0.808373 0) (0.0186037 0.23591 0) (0.0278698 0.38456 0) (0.030487 0.467706 0) (0.0284202 0.493805 0) (0.0192394 0.492025 0) (0.00609618 0.482085 0) (-0.0123462 0.480759 0) (-0.0280529 0.518553 0) (-0.0343714 0.631351 0) (-0.00592185 0.795928 0) (0.00615131 0.256736 0) (0.00766352 0.390821 0) (0.00238748 0.467311 0) (-0.000431409 0.492898 0) (-0.00804798 0.494226 0) (-0.0185191 0.489588 0) (-0.0339057 0.491483 0) (-0.0470082 0.523829 0) (-0.0512844 0.616566 0) (-0.0148886 0.762328 0) (-0.00939234 0.255225 0) (-0.00350599 0.383192 0) (0.00188443 0.469071 0) (0.00540241 0.503135 0) (-0.00155178 0.509676 0) (-0.0141284 0.507903 0) (-0.0321894 0.510405 0) (-0.0482292 0.53598 0) (-0.0557036 0.607311 0) (-0.0218562 0.725391 0) (-0.0142259 0.281705 0) (-0.0213125 0.384936 0) (-0.0227074 0.46262 0) (-0.019933 0.497 0) (-0.0206179 0.511462 0) (-0.025216 0.517333 0) (-0.0367263 0.522992 0) (-0.0483139 0.542866 0) (-0.0541127 0.593673 0) (-0.024842 0.679648 0) (-0.0110174 0.282972 0) (-0.00816309 0.384375 0) (0.00048327 0.470902 0) (-0.00435962 0.504078 0) (-0.0118331 0.517379 0) (-0.0183436 0.525853 0) (-0.0273208 0.535132 0) (-0.035464 0.552792 0) (-0.0401727 0.587974 0) (-0.0201338 0.644 0) (-0.00622572 0.311023 0) (-0.0320051 0.369829 0) (-0.0170689 0.456296 0) (-0.00890392 0.504128 0) (-0.0103445 0.522737 0) (-0.0148482 0.531473 0) (-0.0219229 0.539975 0) (-0.0273059 0.554631 0) (-0.0299366 0.580405 0) (-0.0152313 0.617769 0) (0.0359364 0.347314 0) (0.00665451 0.398138 0) (-0.000678972 0.456474 0) (0.00139868 0.500612 0) (0.000811237 0.524419 0) (-0.00126802 0.537721 0) (-0.00609521 0.548149 0) (-0.00994965 0.560738 0) (-0.013006 0.577442 0) (-0.00691522 0.597838 0) (0.0457418 0.0994531 -1.16471e-23) (0.0526445 0.128713 1.146e-23) (0.0517941 0.165558 -1.85174e-22) (0.0363947 0.189502 0) (0.0196693 0.217786 0) (0.003425 0.226749 -2.37491e-22) (0.000197551 0.258262 3.60382e-22) (0.00406813 0.2618 -3.53603e-22) (0.0169796 0.298208 4.05781e-23) (0.0420443 0.300974 -3.91332e-23) (0.0562915 0.0701356 -2.83763e-22) (0.0633629 0.112141 0) (0.0582816 0.154946 -1.69376e-21) (0.0408494 0.181692 4.08023e-21) (0.0226821 0.209232 -2.78435e-21) (0.00696416 0.220089 2.31028e-22) (0.00436972 0.250348 -2.93399e-22) (0.00897901 0.253441 -1.3096e-22) (0.021951 0.286749 1.16134e-22) (0.0414487 0.27522 2.269e-23) (0.0701149 0.0700632 3.92552e-25) (0.07545 0.11877 1.20055e-21) (0.0649193 0.159665 -1.18895e-21) (0.0448012 0.183741 2.39665e-21) (0.0255653 0.206839 -1.79876e-21) (0.0110766 0.216821 0) (0.0086632 0.242507 2.94084e-22) (0.0133395 0.243033 -1.90209e-23) (0.0242661 0.267983 -6.63697e-23) (0.0390633 0.24419 -5.73906e-23) (0.0860399 0.0877918 -5.24049e-24) (0.0867876 0.136642 0) (0.0706237 0.171107 0) (0.0479605 0.189669 0) (0.0280043 0.20639 -1.86143e-21) (0.0146166 0.213311 1.1803e-21) (0.0119634 0.231944 -1.06053e-22) (0.0159371 0.227709 5.33351e-23) (0.0240102 0.241761 -2.0928e-23) (0.035179 0.209068 -1.05751e-23) (0.103413 0.112685 -4.16472e-22) (0.0962558 0.155401 4.12393e-22) (0.0744618 0.181051 1.3193e-21) (0.0495822 0.192995 -1.31823e-21) (0.0292466 0.202883 6.72272e-22) (0.0166991 0.205409 0) (0.0134219 0.215748 3.44784e-22) (0.0160973 0.20551 -2.22305e-22) (0.0212127 0.208846 6.64539e-23) (0.0301633 0.171229 3.16964e-23) (0.119685 0.13559 1.79758e-21) (0.102805 0.167522 3.10945e-22) (0.0761049 0.183332 3.58964e-22) (0.0495537 0.188666 -1.51419e-21) (0.029114 0.192199 0) (0.0170672 0.189919 0) (0.0128038 0.192059 0) (0.0138498 0.176051 -1.9723e-22) (0.0164903 0.170843 0) (0.0245718 0.132274 0) (0.132119 0.149725 0) (0.105851 0.168567 -2.05565e-21) (0.0755827 0.174586 1.40366e-21) (0.0480807 0.174051 1.72838e-21) (0.0277199 0.172217 -1.7372e-21) (0.0157614 0.165528 -5.38752e-22) (0.0102631 0.160695 6.61576e-22) (0.00970506 0.140486 7.81692e-22) (0.0107441 0.129976 -5.28049e-23) (0.0189656 0.0938657 -2.3431e-24) (0.139037 0.151039 0) (0.105428 0.156937 6.5338e-22) (0.0732349 0.154169 4.8543e-22) (0.0454961 0.148994 0) (0.0252958 0.143011 -3.35156e-22) (0.013048 0.132897 1.15566e-21) (0.00627817 0.123081 -6.01781e-22) (0.00447009 0.101054 -4.89946e-23) (0.00488648 0.0886815 1.06618e-23) (0.0138383 0.0575053 3.77744e-24) (0.14023 0.13845 -3.7413e-22) (0.102093 0.133511 -9.28054e-22) (0.0696137 0.12361 1.90062e-22) (0.0421769 0.115238 -2.69997e-22) (0.0221503 0.106369 -4.55456e-22) (0.00937908 0.0941623 -5.45053e-22) (0.00156591 0.0817114 1.20904e-22) (-0.000982879 0.0604574 6.38629e-23) (-0.000348097 0.0491736 -1.06967e-23) (0.0095269 0.024329 -2.45444e-24) (0.136645 0.113689 1.94311e-22) (0.0966759 0.101024 -1.97324e-22) (0.0653097 0.0858098 2.61625e-22) (0.038491 0.0756244 2.69584e-22) (0.0186394 0.0650581 -2.15332e-22) (0.00530722 0.0522181 4.03836e-22) (-0.0032273 0.0394883 -1.68164e-22) (-0.00583587 0.0212844 -1.62802e-23) (-0.00452677 0.0130839 0) (0.00590436 -0.00501993 2.45259e-24) (0.129759 0.0803111 -2.08543e-22) (0.0901147 0.063089 2.11492e-22) (0.0607779 0.0441727 2.79389e-22) (0.0347754 0.0333277 2.83285e-22) (0.0151039 0.0221365 2.19589e-22) (0.00136166 0.0101069 -2.75371e-23) (-0.00744006 -0.00090458 -7.93895e-23) (-0.00949295 -0.0144763 -1.19946e-22) (-0.00733515 -0.0186494 0) (0.0035648 -0.0304595 3.24087e-24) (0.120939 0.0422882 0) (0.083308 0.0232699 1.06791e-21) (0.0562721 0.00193579 -1.91188e-21) (0.0313137 -0.00871808 -2.83699e-22) (0.011856 -0.0195602 -4.94176e-22) (-0.00189152 -0.0295749 -5.81838e-22) (-0.0104625 -0.0374414 1.28304e-22) (-0.0117299 -0.0456538 7.04624e-23) (-0.00868488 -0.0457887 -4.38245e-23) (0.00199137 -0.0524177 -3.23198e-24) (0.111201 0.0030819 0) (0.0767727 -0.0154716 9.86861e-22) (0.052069 -0.0382508 5.57536e-22) (0.0282886 -0.0481472 0) (0.0092279 -0.0578188 1.37062e-21) (-0.00408989 -0.0649764 -4.93879e-22) (-0.0120902 -0.0689344 -3.15696e-22) (-0.012581 -0.0719426 -4.9914e-22) (-0.00885936 -0.068705 4.36813e-23) (0.00102715 -0.0715482 -1.98201e-23) (0.101381 -0.0345876 0) (0.0707471 -0.0510249 -9.94995e-22) (0.0483789 -0.0744957 0) (0.0258726 -0.0833131 -2.04949e-21) (0.00747979 -0.0911787 2.06018e-21) (-0.00514557 -0.0951327 6.3609e-22) (-0.0123822 -0.095125 -1.21828e-22) (-0.0122618 -0.0937527 4.91537e-22) (-0.00824527 -0.0881608 8.5102e-23) (0.000517599 -0.0885501 3.58111e-23) (0.0920488 -0.0688037 -4.55059e-21) (0.0654223 -0.0822484 1.86708e-21) (0.0452207 -0.105675 -1.30611e-22) (0.0242285 -0.1134 2.06657e-21) (0.00668908 -0.119015 0) (-0.00508634 -0.119954 6.23501e-22) (-0.0115692 -0.116487 -2.22088e-22) (-0.0111158 -0.111932 -7.01037e-22) (-0.00718936 -0.105049 -1.79753e-23) (0.00029207 -0.104051 1.79714e-23) (0.083581 -0.0983534 1.30145e-21) (0.0609774 -0.108921 -3.47547e-21) (0.042596 -0.131351 -1.95334e-21) (0.0233749 -0.138343 1.95231e-21) (0.00680669 -0.141462 8.7638e-22) (-0.00413855 -0.140032 0) (-0.00998418 -0.133951 8.93619e-22) (-0.00950572 -0.127478 -4.85134e-22) (-0.00596211 -0.120191 -2.11701e-22) (0.000216996 -0.118553 -3.31737e-23) (0.0762342 -0.122701 2.92594e-22) (0.0574676 -0.131524 0) (0.0405334 -0.151662 0) (0.0232036 -0.158659 0) (0.00767225 -0.159213 6.72019e-22) (-0.00270931 -0.156351 -1.54676e-21) (-0.00796958 -0.148599 -8.87158e-22) (-0.00773276 -0.14131 9.84506e-22) (-0.00474498 -0.134239 -4.17991e-23) (0.000210507 -0.132426 7.42483e-23) (0.0699499 -0.141818 1.653e-23) (0.054812 -0.150982 -3.02393e-21) (0.0390553 -0.167189 2.99588e-21) (0.023562 -0.175199 -3.43148e-21) (0.0090751 -0.173238 4.20031e-21) (-0.000887219 -0.169997 0) (-0.00580344 -0.161452 4.72393e-22) (-0.00600216 -0.154149 -7.94118e-25) (-0.00363525 -0.14765 1.39694e-22) (0.000232722 -0.145928 3.9358e-23) (0.0638519 -0.155862 1.81966e-22) (0.0524034 -0.168421 0) (0.0379986 -0.178869 3.55982e-21) (0.024233 -0.188917 -6.40484e-21) (0.0109237 -0.184648 2.39838e-21) (0.00125111 -0.181923 3.16826e-22) (-0.00367144 -0.173221 -4.71317e-22) (-0.00439024 -0.166487 -7.46142e-23) (-0.0026517 -0.160721 -3.06919e-22) (0.000274803 -0.159233 -8.34636e-23) (0.0584865 -0.164703 1.02768e-21) (0.049568 -0.184963 -1.00053e-21) (0.0369911 -0.187984 -3.7709e-22) (0.0245314 -0.200749 0) (0.0128346 -0.194414 0) (0.00335783 -0.192822 -3.25937e-22) (-0.00155592 -0.184403 -7.67019e-22) (-0.0029053 -0.178617 7.52852e-22) (-0.00175541 -0.173622 4.76208e-23) (0.000324431 -0.172458 -4.66017e-23) (0.0623648 -0.172328 0) (0.0471721 -0.221759 0) (0.0360166 -0.20637 0) (0.0236075 -0.225997 0) (0.0150494 -0.21586 0) (0.00555848 -0.217799 0) (0.00155207 -0.210605 0) (-0.000627563 -0.207702 0) (-0.000128219 -0.204412 0) (0.000309448 -0.203868 0) (0.0439943 -0.233735 0) (0.0352286 -0.268445 0) (0.0301501 -0.253238 0) (0.0212782 -0.269053 0) (0.0170072 -0.260353 0) (0.00775582 -0.26554 0) (0.00612875 -0.259429 0) (0.00197849 -0.26015 0) (0.00185897 -0.257177 0) (9.12588e-05 -0.257836 0) (0.0403374 -0.283238 0) (0.0309179 -0.316148 0) (0.0272016 -0.300501 0) (0.0194871 -0.316611 0) (0.0155216 -0.309086 0) (0.00858786 -0.315787 0) (0.0069383 -0.310835 0) (0.00278831 -0.313446 0) (0.00250524 -0.310217 0) (-0.000150603 -0.311908 0) (0.0349905 -0.338087 0) (0.02717 -0.369707 0) (0.0237317 -0.352813 0) (0.0168991 -0.371464 0) (0.0138976 -0.362096 0) (0.00838854 -0.371757 0) (0.00674729 -0.365641 0) (0.00331142 -0.370089 0) (0.00237469 -0.365872 0) (-5.24818e-05 -0.368337 0) (0.0298142 -0.401384 0) (0.0229487 -0.433428 0) (0.0198261 -0.4151 0) (0.0144848 -0.435219 0) (0.0117296 -0.424159 0) (0.00771451 -0.436005 0) (0.00627991 -0.428117 0) (0.00356363 -0.434481 0) (0.0024277 -0.428052 0) (0.000127929 -0.431992 0) (0.0251691 -0.476806 0) (0.0188198 -0.509372 0) (0.0163792 -0.489902 0) (0.0119171 -0.511817 0) (0.010116 -0.498789 0) (0.00691079 -0.512808 0) (0.00591514 -0.503269 0) (0.00350406 -0.511175 0) (0.00229717 -0.503178 0) (0.000135932 -0.509042 0) (0.019798 -0.572166 0) (0.014915 -0.604018 0) (0.0130263 -0.585104 0) (0.00952835 -0.607839 0) (0.00816985 -0.594374 0) (0.00569301 -0.609982 0) (0.00484638 -0.599383 0) (0.00279642 -0.608881 0) (0.00177334 -0.599895 0) (3.68042e-05 -0.607564 0) (0.0150608 -0.691632 0) (0.0108291 -0.718819 0) (0.00928575 -0.704123 0) (0.00646662 -0.724309 0) (0.00563238 -0.713051 0) (0.00365514 -0.727715 0) (0.00300426 -0.718003 0) (0.00128929 -0.727531 0) (0.000707976 -0.719148 0) (-0.000226419 -0.727572 0) (0.00787136 -0.813603 0) (0.00533286 -0.829452 0) (0.00459493 -0.823865 0) (0.00319669 -0.836883 0) (0.00276783 -0.831501 0) (0.00150492 -0.840773 0) (0.000940765 -0.834741 0) (-0.00021275 -0.840794 0) (-0.000312613 -0.835159 0) (-0.00036887 -0.841203 0) (0.00143263 -0.888415 0) (0.00101431 -0.898384 0) (0.000980543 -0.899293 0) (0.00086941 -0.905425 0) (0.000678313 -0.90428 0) (0.000310094 -0.908026 0) (5.96389e-06 -0.905215 0) (-0.000349913 -0.907238 0) (-0.000343091 -0.904264 0) (-0.0001695 -0.906906 0) (0.0547462 -0.195625 1.52351e-21) (0.0438096 -0.252023 -1.49762e-21) (0.0416479 -0.301446 3.20033e-22) (0.0360899 -0.357728 0) (0.0317116 -0.420493 0) (0.0269072 -0.49609 5.98115e-22) (0.0215952 -0.590291 -2.91471e-21) (0.01604 -0.703916 2.90652e-21) (0.00978326 -0.818979 9.28773e-22) (0.00308719 -0.88533 -9.21784e-22) (0.0521417 -0.202847 -1.97011e-21) (0.0441484 -0.257905 0) (0.0421837 -0.306992 2.53892e-21) (0.0366392 -0.363482 -6.26276e-21) (0.0325997 -0.425944 4.44483e-21) (0.0276905 -0.501685 -5.39324e-22) (0.0224052 -0.595408 1.39542e-21) (0.0165201 -0.707426 3.16013e-21) (0.0106571 -0.819448 1.0148e-21) (0.00384385 -0.885245 1.02419e-21) (0.0502087 -0.209704 2.78699e-21) (0.0448669 -0.264191 -2.62232e-21) (0.0429568 -0.312466 2.59744e-21) (0.0374771 -0.36854 -3.92096e-21) (0.0337096 -0.430474 2.87459e-21) (0.0286219 -0.506123 0) (0.0232868 -0.599232 -1.39891e-21) (0.0171283 -0.709836 1.55232e-22) (0.0111991 -0.818862 -1.71251e-21) (0.00420114 -0.885506 -1.91686e-21) (0.0488388 -0.216359 -4.84687e-22) (0.0458454 -0.270564 0) (0.0440362 -0.318018 0) (0.0386605 -0.373597 0) (0.0350904 -0.434978 3.82943e-21) (0.029757 -0.510358 -2.58299e-21) (0.0243046 -0.602755 -4.81418e-23) (0.0178712 -0.711849 -1.95552e-21) (0.011511 -0.818288 -1.01685e-21) (0.00425405 -0.884687 -1.11839e-21) (0.0480127 -0.222648 1.98204e-22) (0.0470439 -0.276272 -1.79693e-21) (0.0454054 -0.322905 -1.88121e-21) (0.0401482 -0.378152 1.88005e-21) (0.036718 -0.439091 -1.22948e-21) (0.0310918 -0.514224 0) (0.0254796 -0.605944 -1.69737e-21) (0.0187423 -0.71358 4.02421e-21) (0.0118133 -0.81779 -2.09425e-21) (0.00422456 -0.88284 2.16073e-21) (0.0477749 -0.22849 -5.18598e-21) (0.048526 -0.281094 3.45731e-22) (0.0470895 -0.326729 -3.73848e-22) (0.0419097 -0.381716 2.03237e-21) (0.0385595 -0.442287 0) (0.0326014 -0.517253 0) (0.0267978 -0.608401 0) (0.0197351 -0.714776 2.22572e-21) (0.0122511 -0.817086 0) (0.00426202 -0.880445 0) (0.0481622 -0.2338 0) (0.0503816 -0.285054 2.59073e-21) (0.0491558 -0.329476 -1.77779e-21) (0.0439614 -0.38416 -2.69544e-21) (0.0406176 -0.44435 2.70951e-21) (0.0342822 -0.519169 1.89354e-21) (0.0282488 -0.609841 -1.85094e-21) (0.020839 -0.715195 -8.01193e-21) (0.0128471 -0.815966 5.6739e-22) (0.00439673 -0.877865 -2.10584e-21) (0.0492037 -0.238452 0) (0.0526862 -0.288142 -8.15351e-22) (0.0516657 -0.33118 -5.48332e-22) (0.0463384 -0.38551 0) (0.0429222 -0.445265 9.09202e-22) (0.0361592 -0.519911 -2.74083e-21) (0.0298471 -0.610162 3.28134e-21) (0.0220605 -0.714696 1.22504e-21) (0.0135856 -0.814296 -1.40798e-21) (0.00461976 -0.875178 2.77577e-21) (0.0509415 -0.242302 6.6189e-22) (0.0555038 -0.290289 1.00911e-21) (0.0546578 -0.331808 -1.77028e-22) (0.0490686 -0.385777 3.67306e-22) (0.0455045 -0.445061 8.34031e-22) (0.0382629 -0.519517 1.51253e-21) (0.0316162 -0.609404 -6.11108e-22) (0.0234022 -0.713321 -6.88363e-22) (0.0144211 -0.812104 1.41264e-21) (0.004889 -0.872364 7.98346e-22) (0.0534379 -0.245211 -2.0479e-22) (0.0588971 -0.29142 2.06522e-22) (0.0581553 -0.331287 -2.93635e-22) (0.0521695 -0.384926 -3.66862e-22) (0.0483887 -0.443702 5.04463e-22) (0.0406214 -0.51798 -1.03796e-21) (0.0335859 -0.607562 9.46242e-22) (0.0248936 -0.71105 3.51303e-22) (0.0153683 -0.809343 0) (0.00521446 -0.869309 -8.00094e-22) (0.0567705 -0.247053 2.1255e-22) (0.0629261 -0.291499 -2.14469e-22) (0.0621746 -0.329567 -3.37693e-22) (0.0556578 -0.382945 -4.22465e-22) (0.0515894 -0.441173 -5.41238e-22) (0.0432442 -0.515345 -6.13925e-23) (0.0357664 -0.604705 3.4286e-22) (0.026528 -0.708017 1.14868e-21) (0.0163943 -0.806128 0) (0.00556094 -0.866031 -9.10437e-22) (0.0610262 -0.247711 0) (0.0676429 -0.290525 -1.22022e-21) (0.0667225 -0.326671 2.29088e-21) (0.0595471 -0.379824 4.23213e-22) (0.0551259 -0.437437 1.10969e-21) (0.0461528 -0.511523 1.90583e-21) (0.0381878 -0.600724 -7.00908e-22) (0.028352 -0.704067 -7.86544e-22) (0.0175676 -0.802312 1.83394e-21) (0.00598393 -0.862429 9.08275e-22) (0.0662882 -0.247098 0) (0.0730781 -0.28856 -1.13309e-21) (0.0718136 -0.322682 -7.25447e-22) (0.0638586 -0.375565 0) (0.0590095 -0.432648 -3.59198e-21) (0.04934 -0.506637 1.19857e-21) (0.0408309 -0.595811 1.55897e-21) (0.030318 -0.699446 5.20798e-21) (0.0188099 -0.798122 -1.82801e-21) (0.00640911 -0.858633 4.09931e-21) (0.0726256 -0.245158 0) (0.0792439 -0.285676 1.14285e-21) (0.0774615 -0.317774 0) (0.0685919 -0.370152 4.43297e-21) (0.0632663 -0.426761 -4.45565e-21) (0.0528673 -0.500472 -3.06376e-21) (0.0437604 -0.589654 -1.06393e-22) (0.0325294 -0.693716 -5.42921e-21) (0.0202532 -0.793203 -8.99354e-22) (0.00695127 -0.854455 -5.09837e-21) (0.080072 -0.241901 5.80464e-21) (0.0861225 -0.282024 -2.19198e-21) (0.0837145 -0.312001 8.95573e-22) (0.0737885 -0.363625 -3.82286e-21) (0.0678958 -0.419914 0) (0.0567062 -0.493373 -3.26016e-21) (0.0468948 -0.582823 -4.12467e-22) (0.034837 -0.687594 7.45933e-21) (0.0216985 -0.788089 1.07773e-21) (0.00743594 -0.850164 -1.0816e-21) (0.0885372 -0.237303 -2.21119e-21) (0.0937526 -0.277389 5.17324e-21) (0.0906307 -0.305232 4.05372e-21) (0.079481 -0.35594 -4.05096e-21) (0.0729328 -0.411874 -2.84378e-21) (0.0609422 -0.48492 0) (0.0503929 -0.574502 -7.69689e-21) (0.0375148 -0.680014 3.84584e-21) (0.0234564 -0.78198 4.27066e-21) (0.0081215 -0.845348 4.77957e-21) (0.0980075 -0.23152 -6.13896e-22) (0.102092 -0.27206 0) (0.0981324 -0.297994 0) (0.0855943 -0.34777 0) (0.0782797 -0.40347 -3.50237e-21) (0.0654088 -0.476305 6.33464e-21) (0.0539881 -0.566306 7.91137e-21) (0.0401411 -0.672811 -1.27461e-20) (0.0250653 -0.776122 2.38515e-21) (0.00861526 -0.840592 -7.09654e-21) (0.108383 -0.22394 1.78966e-22) (0.11128 -0.264944 6.73815e-21) (0.106333 -0.289536 -6.67291e-21) (0.0923529 -0.338022 1.12944e-20) (0.0841857 -0.393236 -1.43539e-20) (0.0704792 -0.465455 0) (0.0582141 -0.555494 -4.20905e-21) (0.0434427 -0.663063 -2.4732e-22) (0.0272466 -0.768633 -5.03068e-21) (0.00950825 -0.835 -5.22064e-21) (0.119267 -0.217256 -5.67005e-22) (0.120705 -0.25922 0) (0.114664 -0.282554 -1.06041e-20) (0.0991186 -0.329868 2.13424e-20) (0.0900136 -0.384965 -8.56476e-21) (0.0753548 -0.456972 -1.93035e-21) (0.0620898 -0.547395 4.20017e-21) (0.0462356 -0.655797 -3.34972e-22) (0.0289121 -0.762472 7.26128e-21) (0.00990357 -0.829874 7.72189e-21) (0.131955 -0.202529 -3.59379e-21) (0.132462 -0.246791 3.50683e-21) (0.124839 -0.270756 1.04531e-21) (0.107697 -0.31634 0) (0.0973417 -0.371056 0) (0.0817657 -0.442302 1.86157e-21) (0.067501 -0.532888 9.06723e-21) (0.0505384 -0.643057 -8.79349e-21) (0.0317753 -0.753242 -2.53403e-21) (0.0111737 -0.823249 2.47699e-21) (0.161721 -0.210217 0) (0.161772 -0.250223 0) (0.146567 -0.269336 0) (0.122986 -0.312193 0) (0.110482 -0.365323 0) (0.0926128 -0.434262 0) (0.0760513 -0.522859 0) (0.0566952 -0.630729 0) (0.0353696 -0.739531 0) (0.0113419 -0.810345 0) (0.202397 -0.193278 0) (0.209248 -0.234786 0) (0.178791 -0.25094 0) (0.152448 -0.298 0) (0.139001 -0.353104 0) (0.116122 -0.421735 0) (0.0965268 -0.508662 0) (0.0726721 -0.613363 0) (0.0462058 -0.716752 0) (0.0171944 -0.781076 0) (0.247038 -0.173214 0) (0.253696 -0.204279 0) (0.208145 -0.218874 0) (0.189974 -0.27228 0) (0.168938 -0.328728 0) (0.142868 -0.393232 0) (0.118725 -0.478729 0) (0.0892604 -0.580155 0) (0.0557703 -0.681376 0) (0.0175088 -0.747783 0) (0.290177 -0.154115 0) (0.296544 -0.17324 0) (0.246523 -0.19434 0) (0.238091 -0.252531 0) (0.204757 -0.309543 0) (0.180813 -0.371525 0) (0.150368 -0.456182 0) (0.114824 -0.552188 0) (0.0733102 -0.644657 0) (0.0272235 -0.701044 0) (0.337057 -0.127382 0) (0.344247 -0.139587 0) (0.296294 -0.166023 0) (0.292054 -0.220675 0) (0.247707 -0.274633 0) (0.224714 -0.334684 0) (0.185244 -0.413754 0) (0.140288 -0.503839 0) (0.0879953 -0.591232 0) (0.0271017 -0.650084 0) (0.403391 -0.108331 0) (0.412993 -0.121402 0) (0.367872 -0.152798 0) (0.362555 -0.202598 0) (0.31214 -0.253763 0) (0.28488 -0.311643 0) (0.234839 -0.379791 0) (0.179005 -0.46107 0) (0.1146 -0.535619 0) (0.043376 -0.578409 0) (0.495673 -0.0775807 0) (0.501768 -0.09362 0) (0.455795 -0.121407 0) (0.443495 -0.163188 0) (0.386688 -0.20618 0) (0.347349 -0.256835 0) (0.284146 -0.311538 0) (0.213757 -0.384282 0) (0.132396 -0.451584 0) (0.0378509 -0.499615 0) (0.617274 -0.066136 0) (0.615218 -0.0833787 0) (0.570557 -0.107043 0) (0.546469 -0.140776 0) (0.485108 -0.174136 0) (0.432311 -0.215972 0) (0.356202 -0.258386 0) (0.268952 -0.318681 0) (0.170567 -0.36815 0) (0.0706458 -0.391803 0) (0.726816 -0.0295916 0) (0.712181 -0.0408019 0) (0.663773 -0.0553623 0) (0.626573 -0.0756509 0) (0.555735 -0.0953601 0) (0.489077 -0.121161 0) (0.394129 -0.145965 0) (0.287864 -0.1861 0) (0.163172 -0.225219 0) (0.0227458 -0.275421 0) (0.90571 -0.0185955 0) (0.885557 -0.0233468 0) (0.844638 -0.0291113 0) (0.802097 -0.0374889 0) (0.73642 -0.0459886 0) (0.664882 -0.0579953 0) (0.565934 -0.0709316 0) (0.447141 -0.0924672 0) (0.299706 -0.121438 0) (0.178846 -0.17445 0) (0.194605 -0.16818 1.00245e-21) (0.24395 -0.152818 -9.90434e-22) (0.290614 -0.137507 6.52144e-22) (0.333651 -0.121198 0) (0.382096 -0.0984897 0) (0.447949 -0.0813117 1.87617e-21) (0.538338 -0.0541378 -1.02491e-20) (0.649811 -0.0462079 1.0216e-20) (0.753295 -0.0170719 3.33106e-21) (0.922015 -0.0147214 -3.33927e-21) (0.204719 -0.149653 1.46742e-21) (0.254123 -0.134761 0) (0.300302 -0.122026 5.487e-21) (0.343985 -0.106874 -1.50175e-20) (0.393892 -0.0857397 1.14808e-20) (0.460818 -0.0693844 -1.70698e-21) (0.550776 -0.0439227 3.97409e-21) (0.659619 -0.0375002 9.93312e-21) (0.761175 -0.0115974 3.16322e-21) (0.926778 -0.0130289 3.02777e-21) (0.21197 -0.127902 -2.18028e-21) (0.261135 -0.114201 -3.07694e-21) (0.306082 -0.104553 3.04777e-21) (0.349998 -0.0908153 -8.87983e-21) (0.401051 -0.0714957 6.23771e-21) (0.469076 -0.0562649 0) (0.558569 -0.0329668 -3.98393e-21) (0.665128 -0.028532 -2.63831e-23) (0.765798 -0.00617839 -5.46413e-21) (0.929296 -0.011399 -5.93597e-21) (0.218353 -0.103639 3.25887e-22) (0.268473 -0.0913573 0) (0.313063 -0.0848347 0) (0.357126 -0.0726589 0) (0.408913 -0.0554661 8.27186e-21) (0.477284 -0.0418061 -5.76066e-21) (0.565788 -0.021187 -4.46187e-22) (0.669619 -0.019303 -5.22927e-21) (0.769298 -0.000874291 -2.83807e-21) (0.930963 -0.00984519 -3.01845e-21) (0.223144 -0.0776198 1.92794e-21) (0.275007 -0.0665241 4.05151e-22) (0.32006 -0.0629347 -2.72463e-21) (0.364767 -0.0523911 2.72303e-21) (0.417429 -0.0376281 -2.47464e-21) (0.485873 -0.0260103 0) (0.57305 -0.00859057 -3.96527e-21) (0.673935 -0.0097719 9.93882e-21) (0.7723 0.00437091 -5.1178e-21) (0.932246 -0.0083442 5.91399e-21) (0.226181 -0.0500241 2.1518e-21) (0.280073 -0.0398379 -1.68331e-21) (0.325673 -0.0389416 -1.37851e-21) (0.371309 -0.0301677 2.63276e-21) (0.425031 -0.0181714 0) (0.493554 -0.0090575 0) (0.579354 0.00467685 0) (0.677422 1.36407e-07 4.78505e-21) (0.774453 0.00956652 0) (0.932985 -0.00688515 0) (0.227866 -0.0208795 0) (0.28386 -0.0113917 1.56147e-21) (0.329575 -0.012928 -1.24775e-21) (0.376158 -0.00617117 -4.04554e-21) (0.430797 0.00268342 4.06668e-21) (0.499296 0.00882996 3.53208e-21) (0.583684 0.0184275 -3.15862e-21) (0.679185 0.00988469 -1.65567e-20) (0.77514 0.0146554 1.15557e-21) (0.932816 -0.00548213 -4.44138e-21) (0.228615 0.00977369 0) (0.286504 0.0186288 -3.17442e-22) (0.331809 0.014909 -5.10777e-22) (0.379304 0.0193427 0) (0.434517 0.024715 1.57014e-21) (0.502744 0.0274495 -4.45796e-21) (0.585572 0.0325006 6.17204e-21) (0.678718 0.0197536 2.61819e-21) (0.773929 0.0195629 -2.7586e-21) (0.931458 -0.00415153 5.89187e-21) (0.228693 0.0418346 -3.33333e-22) (0.287902 0.0498851 7.26985e-22) (0.33235 0.0441821 5.61872e-23) (0.380724 0.0459961 4.62339e-22) (0.43618 0.0476369 1.23421e-21) (0.503876 0.0465823 2.47966e-21) (0.584988 0.0467466 -1.04996e-21) (0.675945 0.0294972 -1.26541e-21) (0.77073 0.0242261 2.76772e-21) (0.928858 -0.0029113 1.50284e-21) (0.228161 0.0750729 -5.87573e-23) (0.287887 0.0818844 5.91833e-23) (0.331068 0.0743486 -2.79849e-22) (0.380293 0.0732992 -4.61775e-22) (0.43572 0.0710753 7.62135e-22) (0.502699 0.0659522 -1.61749e-21) (0.582037 0.0609934 1.63715e-21) (0.670954 0.0390151 6.74877e-22) (0.76563 0.028605 0) (0.925109 -0.00175776 -1.50609e-21) (0.226871 0.10908 9.76778e-23) (0.286365 0.113989 -9.8339e-23) (0.327861 0.104772 -3.63528e-22) (0.37793 0.10069 -5.45067e-22) (0.433085 0.0945873 -8.10264e-22) (0.499215 0.0852221 -1.30621e-22) (0.576849 0.0750251 5.41624e-22) (0.663896 0.0481833 1.98263e-21) (0.758829 0.0326466 0) (0.920399 -0.000703459 -1.57184e-21) (0.224723 0.143247 0) (0.283397 0.145457 -1.19481e-21) (0.322817 0.134777 2.40949e-21) (0.373701 0.127573 5.46028e-22) (0.42828 0.117712 1.60097e-21) (0.493465 0.104028 2.97445e-21) (0.569505 0.0886105 -1.15328e-21) (0.654827 0.0568871 -1.36395e-21) (0.750379 0.0363172 3.0931e-21) (0.914853 0.000269961 1.56814e-21) (0.221797 0.176765 0) (0.279084 0.175527 -1.17044e-21) (0.316204 0.163689 -8.44305e-22) (0.367766 0.153383 0) (0.42144 0.139984 -5.35523e-21) (0.485624 0.121992 1.75021e-21) (0.560141 0.101504 2.45433e-21) (0.643924 0.0649802 8.68339e-21) (0.740497 0.0395311 -3.0831e-21) (0.908605 0.00112104 6.62258e-21) (0.218162 0.208757 0) (0.273446 0.203534 1.1805e-21) (0.308249 0.190892 0) (0.360221 0.177623 6.43029e-21) (0.412701 0.160974 -6.46315e-21) (0.475809 0.138789 -4.8816e-21) (0.548782 0.113519 -2.39564e-22) (0.631209 0.0723944 -9.0551e-21) (0.729086 0.0423132 -1.50902e-21) (0.901659 0.00190308 -8.22699e-21) (0.213876 0.238417 8.23803e-21) (0.266575 0.228983 -3.03284e-21) (0.299244 0.215858 1.53857e-21) (0.351271 0.199864 -5.49272e-21) (0.402379 0.18027 0) (0.464333 0.154094 -5.20498e-21) (0.53572 0.124394 -7.60011e-22) (0.617137 0.078925 1.22139e-20) (0.716584 0.044541 1.69813e-21) (0.894162 0.00253594 -1.6969e-21) (0.208906 0.265133 -2.51903e-21) (0.258494 0.251592 8.07863e-21) (0.289322 0.238218 6.11447e-21) (0.340905 0.219831 -6.11039e-21) (0.39053 0.197615 -4.46488e-21) (0.451193 0.167782 0) (0.520891 0.134093 -1.23779e-20) (0.601528 0.0846937 6.28132e-21) (0.702457 0.0464433 6.79557e-21) (0.886102 0.00316419 7.16214e-21) (0.203593 0.28854 -1.7154e-21) (0.24968 0.271256 0) (0.279082 0.25771 0) (0.329788 0.237259 0) (0.377931 0.212652 -5.6874e-21) (0.437207 0.179483 1.0133e-20) (0.505168 0.142173 1.26753e-20) (0.585398 0.0892541 -2.03899e-20) (0.687901 0.0476559 3.60835e-21) (0.877799 0.00355535 -1.06543e-20) (0.197463 0.308622 -1.91162e-21) (0.239585 0.288169 1.1523e-20) (0.267901 0.274418 -1.14122e-20) (0.317094 0.252359 1.82765e-20) (0.363752 0.225692 -2.32573e-20) (0.4215 0.189701 0) (0.487648 0.149288 -6.72897e-21) (0.56753 0.0934434 -2.97852e-22) (0.671323 0.0488938 -7.54795e-21) (0.869124 0.0040529 -7.48645e-21) (0.192734 0.32528 -2.00957e-21) (0.230739 0.302225 0) (0.258496 0.287947 -1.80648e-20) (0.306048 0.264403 3.56746e-20) (0.351197 0.235641 -1.42263e-20) (0.407236 0.197026 -3.15769e-21) (0.471339 0.153754 6.71452e-21) (0.550697 0.0956171 -2.92633e-22) (0.655988 0.0489748 1.1118e-20) (0.860469 0.00411244 1.11153e-20) (0.18397 0.340762 -1.05753e-20) (0.217516 0.315525 1.02905e-20) (0.244729 0.300613 1.85854e-21) (0.290151 0.276303 0) (0.3342 0.246001 0) (0.388811 0.20538 3.06911e-21) (0.451214 0.159738 1.43621e-20) (0.530123 0.099411 -1.39826e-20) (0.637232 0.0501765 -3.67134e-21) (0.851462 0.0046151 3.51232e-21) (0.19871 0.343561 0) (0.219224 0.333503 0) (0.245323 0.309803 0) (0.284142 0.282468 0) (0.320428 0.247155 0) (0.366902 0.203006 0) (0.420511 0.153984 0) (0.494394 0.0938716 0) (0.604306 0.0459556 0) (0.8305 0.00384998 0) (0.185149 0.342069 0) (0.193395 0.330825 0) (0.22258 0.298518 0) (0.250629 0.269687 0) (0.280978 0.230004 0) (0.320084 0.184943 0) (0.36786 0.136044 0) (0.442066 0.0807748 0) (0.566318 0.0375852 0) (0.815863 0.00316186 0) (0.160798 0.335245 0) (0.160156 0.317761 0) (0.192249 0.282077 0) (0.206709 0.252045 0) (0.236733 0.20974 0) (0.268993 0.16638 0) (0.31446 0.119146 0) (0.389201 0.0697167 0) (0.522246 0.0318509 0) (0.787309 0.00276814 0) (0.135313 0.327326 0) (0.132288 0.304701 0) (0.162338 0.269182 0) (0.165157 0.237493 0) (0.197709 0.194819 0) (0.223315 0.154212 0) (0.270946 0.108655 0) (0.351239 0.0636837 0) (0.499436 0.0284711 0) (0.782599 0.00352789 0) (0.108702 0.32136 0) (0.105058 0.295781 0) (0.128478 0.262369 0) (0.124445 0.229739 0) (0.157156 0.189172 0) (0.175886 0.151179 0) (0.223599 0.108331 0) (0.304291 0.0671279 0) (0.457705 0.0320039 0) (0.749608 0.00495947 0) (0.0858845 0.31772 0) (0.0818398 0.29376 0) (0.0987385 0.262818 0) (0.093515 0.232331 0) (0.124064 0.195283 0) (0.140169 0.160381 0) (0.190891 0.120938 0) (0.276061 0.0817673 0) (0.439947 0.0424567 0) (0.742414 0.00974425 0) (0.0542257 0.323575 0) (0.0504188 0.306455 0) (0.0601663 0.275576 0) (0.05588 0.253706 0) (0.0791763 0.220427 0) (0.0936931 0.193258 0) (0.142129 0.159225 0) (0.22257 0.12249 0) (0.379935 0.0753107 0) (0.680258 0.0191849 0) (0.0445585 0.374721 0) (0.0431133 0.371279 0) (0.0493834 0.333579 0) (0.0507199 0.322682 0) (0.0689195 0.287776 0) (0.0858358 0.270466 0) (0.131953 0.237204 0) (0.206926 0.200552 0) (0.354932 0.137722 0) (0.642025 0.0414654 0) (0.00340546 0.54152 0) (-0.000611568 0.543819 0) (-6.74961e-05 0.51007 0) (0.000710904 0.509698 0) (0.00961904 0.479242 0) (0.0239644 0.470036 0) (0.0575482 0.430235 0) (0.116252 0.384879 0) (0.23347 0.282859 0) (0.477961 0.0838023 0) (0.0141777 0.784601 0) (0.0173166 0.784573 0) (0.0218954 0.769759 0) (0.0285471 0.768456 0) (0.0382708 0.749133 0) (0.0532372 0.734697 0) (0.0768538 0.690749 0) (0.114806 0.624593 0) (0.181917 0.472289 0) (0.325722 0.157849 0) (0.187458 0.373577 1.22877e-20) (0.168408 0.370184 -1.19846e-20) (0.144173 0.361539 2.24999e-21) (0.121004 0.35125 0) (0.0967577 0.343486 0) (0.076434 0.337026 3.07636e-21) (0.0488927 0.345596 -1.31968e-20) (0.0394922 0.402361 1.30463e-20) (0.00341184 0.567022 3.41935e-21) (0.0129619 0.794682 -3.4705e-21) (0.183373 0.376089 -9.50525e-21) (0.162058 0.372419 0) (0.137797 0.36479 1.54621e-20) (0.115454 0.35544 -3.70808e-20) (0.0919915 0.34842 2.46872e-20) (0.0726889 0.342608 -2.84575e-21) (0.0467535 0.352989 5.67733e-21) (0.0374346 0.412839 1.1876e-20) (0.00337579 0.576902 2.90839e-21) (0.0124032 0.798108 2.94884e-21) (0.17797 0.376393 1.16946e-20) (0.156106 0.371027 -1.43971e-20) (0.132258 0.364324 1.42682e-20) (0.110672 0.356441 -1.93159e-20) (0.0878666 0.350767 1.40682e-20) (0.0694692 0.346725 0) (0.0449165 0.359152 -5.69104e-21) (0.035619 0.422381 -2.12505e-22) (0.00331181 0.586011 -5.89458e-21) (0.0117534 0.80117 -6.02302e-21) (0.171887 0.379893 -2.21127e-21) (0.150316 0.373886 0) (0.127219 0.36707 0) (0.106407 0.359546 0) (0.084255 0.354361 1.49387e-20) (0.0666799 0.351522 -1.0104e-20) (0.0433167 0.365475 -2.21682e-22) (0.0340258 0.431556 -5.75263e-21) (0.00327869 0.594536 -2.84569e-21) (0.0110641 0.8044 -2.80271e-21) (0.165948 0.384145 3.49417e-21) (0.144807 0.379013 -7.28448e-21) (0.122429 0.37203 -7.9603e-21) (0.102363 0.364432 7.95773e-21) (0.080906 0.359201 -4.76994e-21) (0.0641343 0.357018 0) (0.0418447 0.372038 -5.32685e-21) (0.0325963 0.440391 1.09897e-20) (0.003319 0.602514 -5.43369e-21) (0.0103912 0.807705 5.71528e-21) (0.160244 0.387925 -1.60847e-20) (0.139783 0.384089 4.98527e-22) (0.118028 0.377182 -1.20338e-21) (0.0986037 0.369656 7.59865e-21) (0.0778085 0.364332 0) (0.0617711 0.362625 0) (0.0404507 0.378445 0) (0.0313033 0.448697 5.12877e-21) (0.00343995 0.60985 0) (0.00976003 0.810835 0) (0.154904 0.39129 0) (0.135241 0.388772 8.69944e-21) (0.114059 0.382059 -6.07829e-21) (0.0951881 0.374727 -8.14799e-21) (0.0749914 0.369376 8.19158e-21) (0.0595937 0.368117 4.70778e-21) (0.0391569 0.384456 -4.5332e-21) (0.0301497 0.456326 -1.75146e-20) (0.00361684 0.616455 1.24894e-21) (0.00917109 0.813632 -3.79054e-21) (0.150053 0.394602 0) (0.131147 0.393375 -2.63209e-21) (0.110513 0.386854 -1.56133e-21) (0.0921268 0.379691 0) (0.0724834 0.374331 2.23857e-21) (0.0575921 0.373461 -6.42828e-21) (0.0379424 0.390129 7.06613e-21) (0.0291215 0.463215 2.56832e-21) (0.00382075 0.622238 -2.3528e-21) (0.00861627 0.816063 5.10576e-21) (0.145797 0.397986 1.32874e-21) (0.127477 0.398106 2.72533e-21) (0.10735 0.391768 -4.52118e-22) (0.0894041 0.384696 8.60302e-22) (0.0702689 0.379275 1.99868e-21) (0.0557713 0.37857 3.18403e-21) (0.0368094 0.395514 -1.07411e-21) (0.0281624 0.469379 -1.12118e-21) (0.00401306 0.627183 2.36058e-21) (0.00809759 0.81817 1.16359e-21) (0.14221 0.40138 -4.81437e-22) (0.124237 0.402893 4.8903e-22) (0.104539 0.396787 -7.39179e-22) (0.0869948 0.389793 -8.5926e-22) (0.0683094 0.384237 9.61237e-22) (0.0541275 0.38344 -1.9973e-21) (0.035768 0.40052 1.60765e-21) (0.0272327 0.474656 5.8454e-22) (0.00418421 0.631268 0) (0.00762274 0.819998 -1.16614e-21) (0.00156231 -0.00403723 0) (0.00250954 -0.00506158 0) (0.0040972 -0.0010759 2.41278e-21) (0.00659334 0.00633273 0) (0.0100372 0.0163325 1.16117e-22) (0.014319 0.028338 -1.07602e-22) (0.0193664 0.0418356 0) (0.0253502 0.0562723 0) (0.0333293 0.0709609 -1.71395e-21) (0.0420134 0.0807127 2.91716e-21) (0.00122109 -0.00317035 0) (0.00371811 -0.00506004 2.85967e-21) (0.00670013 -0.00254918 6.18816e-22) (0.0101418 0.00282816 1.13633e-21) (0.0139689 0.0102502 3.16032e-22) (0.018018 0.0191034 -3.9402e-22) (0.0221636 0.0289137 0) (0.0263757 0.0393085 0) (0.0308955 0.0498168 0) (0.0360666 0.0579624 -5.17922e-22) (0.00117239 -0.00229011 0) (0.00595044 -0.00409423 7.2002e-22) (0.0112788 -0.00154282 -1.16835e-21) (0.0166786 0.00360515 -7.27871e-22) (0.0219762 0.0105254 1.20022e-22) (0.0269723 0.0185622 2.22813e-22) (0.0315593 0.0272684 3.10621e-22) (0.0357713 0.0363861 -2.79653e-22) (0.0397405 0.0453702 4.30329e-23) (0.0438001 0.0519715 5.75869e-23) (0.00167713 -0.00150601 6.49066e-22) (0.0095358 -0.00239988 -2.83485e-21) (0.0180898 0.00154667 -2.99564e-21) (0.0263417 0.00806156 1.65912e-21) (0.0340388 0.0162813 -6.46732e-22) (0.0409691 0.0254713 -2.99631e-23) (0.0470642 0.0351293 -2.77947e-22) (0.0524475 0.0449713 1.61327e-22) (0.0573273 0.0543824 -1.00081e-21) (0.0615988 0.0611407 5.56305e-22) (0.00296392 -0.000840278 5.98306e-22) (0.0147506 -0.000132173 -5.68443e-22) (0.0272493 0.00631655 0) (0.0390041 0.0154251 -1.47729e-21) (0.0496825 0.0262318 2.2189e-22) (0.0590641 0.0378867 7.38637e-23) (0.0671106 0.0497851 1.10437e-22) (0.0739771 0.0615601 9.12643e-22) (0.0799402 0.0726434 -3.96343e-23) (0.0846742 0.0809088 -2.04443e-21) (0.00519662 -0.000232691 0) (0.0217472 0.00266807 2.72611e-21) (0.0386888 0.01243 -7.39588e-22) (0.0542525 0.0248879 9.66655e-22) (0.0680278 0.0389078 -2.50239e-22) (0.0797922 0.053492 9.41739e-23) (0.0895468 0.0679255 1.40725e-22) (0.0974703 0.0817603 -8.72357e-22) (0.103881 0.0945386 2.14116e-21) (0.108665 0.104681 -2.62907e-21) (0.00846133 0.000450935 -4.21986e-22) (0.0305109 0.00608009 -1.92385e-21) (0.0521154 0.0196414 0) (0.071388 0.0356833 -1.00067e-21) (0.0878654 0.0528217 7.98768e-22) (0.101365 0.0699 2.43909e-22) (0.111979 0.0861307 -6.34146e-22) (0.119976 0.101054 0) (0.12573 0.114344 0) (0.129519 0.125461 0) (0.0127391 0.00139632 3.59973e-22) (0.0408342 0.0102549 6.53895e-22) (0.0669904 0.0277545 -6.1618e-22) (0.0894398 0.0470678 -5.64139e-22) (0.107742 0.066515 -3.57386e-22) (0.121852 0.0848236 -3.59856e-22) (0.132064 0.101232 0) (0.138846 0.115399 -1.28134e-21) (0.142733 0.127201 3.8699e-22) (0.144253 0.137138 0) (0.0178953 0.00279998 0) (0.0523012 0.0153354 -1.49062e-21) (0.082535 0.0365307 6.16018e-22) (0.107226 0.0582509 3.91366e-22) (0.126105 0.0785619 9.85439e-24) (0.139436 0.0962135 1.75906e-22) (0.147863 0.110644 -3.16331e-22) (0.152189 0.121804 0) (0.153214 0.129939 8.12973e-22) (0.1516 0.136114 1.25641e-21) (0.0237001 0.00482334 -6.06328e-23) (0.0643155 0.0213663 5.46244e-22) (0.0978019 0.0456024 1.90133e-23) (0.123502 0.0683696 -7.58642e-24) (0.141552 0.0876641 1.38936e-22) (0.15274 0.10251 0) (0.15823 0.112785 3.16255e-22) (0.159262 0.118923 0) (0.156958 0.121672 0) (0.152186 0.122277 0) (0.0298993 0.00755927 1.20202e-22) (0.0761887 0.0282354 0) (0.111816 0.0544587 0) (0.137177 0.0765828 1.40002e-22) (0.153101 0.0928776 -8.3654e-23) (0.161112 0.102974 -5.8862e-23) (0.163018 0.107434 1.71203e-22) (0.160538 0.107318 0) (0.155112 0.103882 0) (0.147877 0.0984669 0) (0.0361466 0.0110296 0) (0.0871971 0.035712 1.74372e-22) (0.12372 0.0625755 -1.60783e-22) (0.14751 0.0822979 -1.95749e-22) (0.160357 0.0938749 0) (0.164672 0.0978696 -3.83282e-22) (0.162934 0.0956894 3.56445e-22) (0.1573 0.0890473 0) (0.14945 0.079584 -1.53569e-21) (0.140655 0.0687392 1.46767e-21) (0.0419635 0.0151411 0) (0.0965621 0.0433977 -1.15226e-21) (0.13281 0.0694224 0) (0.154129 0.0852004 -3.28054e-22) (0.163449 0.0908942 0) (0.164087 0.0882058 9.51147e-22) (0.159123 0.0794029 0) (0.151031 0.0667293 -2.50409e-21) (0.141587 0.0520303 2.34544e-21) (0.131949 0.0367519 3.04424e-21) (0.0469206 0.0196909 4.4057e-22) (0.103696 0.0508177 5.75432e-22) (0.138729 0.0746151 1.45981e-22) (0.157101 0.0853458 1.97817e-22) (0.162915 0.0846407 1.20334e-22) (0.160291 0.0753763 -3.92977e-22) (0.152758 0.0605507 -5.19228e-22) (0.142965 0.042739 5.53163e-22) (0.13263 0.0238205 -2.07686e-21) (0.12262 0.00512628 -3.05984e-21) (0.050658 0.0243957 4.02775e-22) (0.108227 0.0575092 -2.76377e-25) (0.141425 0.0779652 -8.24886e-22) (0.156785 0.083065 1.61861e-22) (0.159463 0.0760107 0) (0.154203 0.0607393 0) (0.14481 0.0407774 1.2134e-21) (0.133967 0.018826 1.69001e-21) (0.123246 -0.0033132 -1.66457e-21) (0.113177 -0.0245023 3.28373e-21) (0.0529135 0.028926 4.89824e-24) (0.110009 0.0630759 4.00763e-22) (0.141084 0.0794523 -2.66009e-21) (0.153685 0.0788143 3.47623e-21) (0.153816 0.0658582 -4.47632e-22) (0.14662 0.0453851 0) (0.13601 0.0212497 0) (0.124617 -0.00387416 -4.60244e-21) (0.113844 -0.0283279 7.14963e-21) (0.103951 -0.0511745 6.27579e-21) (0.0535516 0.0329446 3.13215e-21) (0.109102 0.0672167 0) (0.138042 0.0791662 2.93622e-21) (0.148352 0.0730514 -2.99216e-21) (0.146631 0.054868 0) (0.138197 0.0300776 6.83856e-22) (0.126918 0.00269555 -2.06455e-21) (0.115332 -0.0247319 2.11943e-21) (0.104712 -0.050708 -9.51479e-22) (0.0951828 -0.0744523 -3.07953e-21) (0.052573 0.0361447 -9.28416e-21) (0.105733 0.0697315 -1.43722e-21) (0.132715 0.0772499 -4.07136e-21) (0.141317 0.0661671 -7.95698e-21) (0.138467 0.0435243 -2.12426e-21) (0.129468 0.0152739 -2.29153e-21) (0.118014 -0.0145184 -1.43496e-21) (0.106487 -0.0434967 0) (0.0961155 -0.0703384 0) (0.0870641 -0.094328 -1.99802e-21) (0.0501003 0.0382775 6.15236e-21) (0.100244 0.0705183 -8.79046e-21) (0.125549 0.0738686 4.87335e-21) (0.133047 0.0584597 1.20773e-20) (0.129763 0.0321237 -3.35869e-21) (0.120868 0.00117218 6.49886e-22) (0.109773 -0.0303175 7.89788e-22) (0.0986221 -0.0602014 0) (0.0886111 -0.0873726 0) (0.0800022 -0.111051 4.51454e-22) (0.0463652 0.0391774 -1.35458e-21) (0.093055 0.0695603 1.14084e-20) (0.116979 0.069198 -2.41253e-21) (0.123907 0.0501533 0) (0.120796 0.0208003 0) (0.112641 -0.012296 5.84262e-21) (0.102583 -0.0450292 0) (0.0925302 -0.0753743 -2.9258e-21) (0.0835834 -0.102404 1.00813e-21) (0.0756088 -0.125052 1.69391e-21) (0.0416731 0.0387797 0) (0.0846134 0.0669291 0) (0.107402 0.0634275 -1.30718e-20) (0.114161 0.0414481 0) (0.111635 0.00964321 4.69714e-21) (0.104641 -0.0253441 -4.35335e-21) (0.0961382 -0.0595688 0) (0.0878663 -0.0914001 0) (0.0807065 -0.120579 -3.47948e-21) (0.0737281 -0.146685 7.33233e-21) (0.0363463 0.0370844 0) (0.0753719 0.062764 -1.17239e-20) (0.0971873 0.0567757 -5.12951e-21) (0.104028 0.0325981 -1.36507e-20) (0.102249 -0.00102968 -6.60181e-21) (0.0964172 -0.037418 -1.54365e-20) (0.0892785 -0.0726698 0) (0.0823164 -0.105181 0) (0.0760538 -0.134512 0) (0.0693937 -0.159772 7.76378e-22) (0.030726 0.0341654 0) (0.065788 0.0572594 -5.79697e-21) (0.0867082 0.0494746 6.34681e-21) (0.0937664 0.023842 1.00661e-20) (0.092783 -0.0109557 -1.14601e-21) (0.0880179 -0.0481666 -1.12318e-21) (0.0820174 -0.0838356 9.79773e-21) (0.0760793 -0.116264 -8.28224e-21) (0.0705996 -0.144895 1.3267e-20) (0.0647622 -0.168957 -1.20265e-20) (0.0251654 0.0302106 -2.60052e-21) (0.0562951 0.0506764 1.25876e-20) (0.0763131 0.0417475 2.03107e-20) (0.0836523 0.0153487 -2.33025e-20) (0.0834918 -0.0200249 1.35637e-20) (0.0797425 -0.0575661 1.18942e-20) (0.0747881 -0.0932204 -4.43925e-21) (0.0698247 -0.125207 1.66927e-20) (0.0652407 -0.15299 3.28682e-22) (0.0604855 -0.176155 -7.13782e-21) (0.0199695 0.0254706 -2.61805e-21) (0.0472627 0.0433124 2.48789e-21) (0.0663055 0.0338046 0) (0.0739383 0.00723467 1.96908e-20) (0.0746256 -0.0282208 -3.65454e-21) (0.0718942 -0.0657378 -2.84779e-22) (0.0679778 -0.101156 -5.68566e-21) (0.0640104 -0.132632 -1.40881e-20) (0.0604004 -0.1597 7.10771e-22) (0.0567875 -0.182287 1.1691e-20) (0.0153707 0.0202284 0) (0.0389802 0.0354812 -1.44754e-20) (0.0569291 0.0258441 4.45761e-21) (0.0648279 -0.000414432 -1.21848e-20) (0.0663848 -0.0355626 3.72368e-21) (0.0647016 -0.0728154 9.40214e-23) (0.0618466 -0.107917 1.41764e-22) (0.058903 -0.138955 9.75407e-21) (0.0562916 -0.16551 -1.32626e-20) (0.0537957 -0.187754 1.27714e-20) (0.0115216 0.0147774 1.41833e-21) (0.0316484 0.0274992 9.64171e-21) (0.0483597 0.018054 0) (0.0564646 -0.00752758 1.21644e-20) (0.0589036 -0.0420715 -1.09197e-20) (0.0583096 -0.0788996 -3.16948e-21) (0.0565533 -0.113673 8.66779e-21) (0.0546562 -0.144387 0) (0.0530387 -0.170617 0) (0.0515991 -0.192675 0) (0.00849421 0.00940082 -1.31277e-21) (0.0253785 0.0196705 -3.35338e-21) (0.0407047 0.0106111 4.22385e-21) (0.0489343 -0.0140407 5.80607e-21) (0.0522573 -0.0477591 5.40967e-21) (0.0527975 -0.084047 3.10848e-21) (0.0521852 -0.118501 0) (0.0513595 -0.149002 5.03692e-21) (0.0507256 -0.175057 -2.40196e-21) (0.0502728 -0.197025 0) (0.00628553 0.00435457 0) (0.0201974 0.0122735 6.76941e-21) (0.0340087 0.00367862 -4.22278e-21) (0.0422733 -0.0198921 -3.85357e-21) (0.046474 -0.0526258 -3.15852e-23) (0.0481961 -0.088279 -1.56197e-21) (0.0487837 -0.122417 1.32679e-21) (0.049066 -0.152786 0) (0.0494192 -0.178777 -2.31506e-21) (0.0498931 -0.200713 -2.27136e-21) (0.00482847 -0.000146109 1.52371e-22) (0.0160584 0.0055474 -2.4294e-21) (0.0282639 -0.00260524 -2.35662e-22) (0.0364782 -0.0250336 7.23241e-24) (0.0415452 -0.0566707 -1.23692e-21) (0.0445009 -0.0915966 0) (0.0463584 -0.125393 -1.32632e-21) (0.0478066 -0.155673 0) (0.0491776 -0.181671 0) (0.0505438 -0.203608 0) (0.00400614 -0.00393485 -2.75684e-22) (0.0128546 -0.000319242 0) (0.0234209 -0.00814783 0) (0.0315223 -0.0294665 -1.09766e-21) (0.0374468 -0.0599433 3.44791e-22) (0.0416891 -0.0940465 -1.43507e-23) (0.0448976 -0.127436 -5.956e-22) (0.0475908 -0.157613 0) (0.0500449 -0.183638 0) (0.0523103 -0.20558 0) (0.00366491 -0.00692078 0) (0.0104254 -0.00520853 -8.38356e-22) (0.0193859 -0.0128757 7.73177e-22) (0.0273549 -0.0331747 1.48916e-21) (0.0341468 -0.0624572 0) (0.039737 -0.0956301 1.13345e-21) (0.0443897 -0.128504 -1.05403e-21) (0.0484257 -0.158512 0) (0.0520611 -0.184545 2.017e-21) (0.055284 -0.206478 -1.94645e-21) (0.00364106 -0.00906346 0) (0.00860011 -0.00904994 5.2918e-21) (0.0160649 -0.0167279 0) (0.0239317 -0.0361268 4.28465e-21) (0.0316188 -0.0642063 0) (0.0386205 -0.0963398 -3.45981e-21) (0.0448138 -0.128559 0) (0.0502982 -0.158286 3.57965e-21) (0.0552339 -0.184264 -3.35257e-21) (0.0595355 -0.206161 -3.51113e-21) (0.00377146 -0.0103674 -1.30743e-21) (0.00721078 -0.0118301 -2.86769e-21) (0.0133735 -0.0196857 -1.08974e-21) (0.0212253 -0.0383179 -2.40505e-21) (0.0298546 -0.0652015 -1.736e-21) (0.0383258 -0.0961824 1.91866e-21) (0.0461462 -0.127576 1.4329e-21) (0.0531759 -0.156863 -4.95568e-22) (0.0595167 -0.182671 2.81919e-21) (0.0650744 -0.204469 3.50601e-21) (0.00390743 -0.0108855 -1.05175e-21) (0.00610791 -0.0135903 -1.83747e-21) (0.0112475 -0.0217601 -2.72147e-21) (0.0192322 -0.0397486 1.48244e-21) (0.0288712 -0.0654465 0) (0.0388586 -0.0951594 0) (0.0483692 -0.125535 -2.21849e-21) (0.057023 -0.154187 -2.24831e-21) (0.0648367 -0.179665 2.06618e-21) (0.0717988 -0.201168 -3.93168e-21) (0.00392635 -0.0107079 7.3842e-22) (0.00518186 -0.0144247 6.06394e-22) (0.00965605 -0.0229836 -2.00948e-21) (0.0179811 -0.0404109 3.66101e-21) (0.0287138 -0.0649148 -8.20311e-22) (0.0402449 -0.0932402 0) (0.0514663 -0.122397 0) (0.0617889 -0.15019 7.15682e-21) (0.0711932 -0.175119 -9.21158e-21) (0.0796768 -0.196142 -7.95719e-21) (0.00374211 -0.00996197 2.83356e-21) (0.00437349 -0.0144623 0) (0.00861198 -0.0233926 3.61121e-21) (0.0175316 -0.0402652 -2.77301e-21) (0.029455 -0.0635319 0) (0.0425301 -0.0903488 4.01238e-22) (0.0554344 -0.118092 -2.65247e-22) (0.0674022 -0.144797 -3.79038e-21) (0.0784061 -0.168981 1.61316e-21) (0.0885537 -0.189413 3.8372e-21) (0.00332299 -0.00880194 -3.7584e-21) (0.00369071 -0.0138475 -2.81885e-22) (0.0081767 -0.0230217 5.79578e-22) (0.0179699 -0.0392491 1.12566e-21) (0.0311798 -0.0611834 5.36372e-22) (0.0457722 -0.0863559 1.64013e-21) (0.0602783 -0.112494 1.82789e-21) (0.073782 -0.137887 0) (0.0862361 -0.161114 0) (0.0980316 -0.180725 4.06188e-21) (0.00269277 -0.00738873 9.24756e-22) (0.00321365 -0.012732 1.06554e-21) (0.00845731 -0.0219 1.72326e-22) (0.0194061 -0.0372776 -2.87624e-21) (0.0339812 -0.0577009 1.19808e-21) (0.0500332 -0.0810536 3.46799e-22) (0.0660215 -0.105391 -5.02044e-22) (0.0809203 -0.129265 0) (0.0945712 -0.151366 0) (0.107771 -0.170148 -9.72939e-22) (0.0019328 -0.00587906 1.83523e-22) (0.00308857 -0.0112553 -1.68805e-21) (0.00959449 -0.0200432 5.7389e-22) (0.0219573 -0.0342496 0) (0.0379505 -0.0528878 0) (0.0553768 -0.0741736 -4.02646e-21) (0.0726756 -0.0964329 0) (0.0887322 -0.11837 3.3464e-21) (0.102932 -0.138649 -1.12256e-21) (0.116069 -0.155652 -1.93004e-21) (0.00117774 -0.00441047 0) (0.00351325 -0.00952745 0) (0.0117437 -0.0174532 5.04209e-21) (0.0257274 -0.0300685 0) (0.0431706 -0.0465667 -3.39735e-21) (0.0619436 -0.0654749 3.14843e-21) (0.0806288 -0.0853169 0) (0.0984411 -0.104803 0) (0.114936 -0.122922 3.18498e-21) (0.130554 -0.139835 -6.0728e-21) (0.000606114 -0.00308954 0) (0.00471172 -0.00761576 3.47107e-21) (0.015051 -0.014122 2.33333e-21) (0.0307588 -0.0246595 7.52962e-21) (0.0496296 -0.0386466 4.28468e-21) (0.0696939 -0.0549194 1.26669e-20) (0.089756 -0.0722542 0) (0.109332 -0.0895596 0) (0.128502 -0.106086 0) (0.146602 -0.123428 -5.71201e-22) (0.000429665 -0.00198147 0) (0.0068942 -0.00553527 2.2294e-21) (0.0196022 -0.0100191 -2.52606e-21) (0.0370263 -0.0180041 -5.7585e-21) (0.0571867 -0.0291406 9.87586e-22) (0.0783652 -0.0425416 1.02579e-21) (0.0995965 -0.0572306 -9.58672e-21) (0.12053 -0.0723552 8.7905e-21) (0.141186 -0.0875757 -1.37123e-20) (0.161147 -0.104076 1.09003e-20) (0.000865701 -0.00108921 4.97842e-22) (0.0102488 -0.00324073 -3.76237e-21) (0.0254203 -0.0051291 -8.56582e-21) (0.0444249 -0.0101494 1.38932e-20) (0.0656158 -0.0181354 -8.7239e-21) (0.0875936 -0.028447 -9.41427e-21) (0.109588 -0.0403117 4.70243e-21) (0.131274 -0.0530913 -1.76553e-20) (0.152428 -0.0666683 2.61794e-22) (0.172701 -0.0811203 7.05526e-21) (0.00209675 -0.000351202 6.21108e-22) (0.0149128 -0.000653789 -5.90164e-22) (0.0324787 0.000554384 0) (0.0527736 -0.00117364 -1.15637e-20) (0.074622 -0.0058135 2.34294e-21) (0.096973 -0.012912 -1.46608e-22) (0.119216 -0.0218509 5.09012e-21) (0.141017 -0.0321233 1.42081e-20) (0.161984 -0.0435952 -5.72106e-22) (0.181593 -0.0558008 -1.0174e-20) (0.0042577 0.000338838 0) (0.0209429 0.00234557 4.63825e-21) (0.0406785 0.00705333 -1.62949e-21) (0.0618512 0.00881578 7.06944e-21) (0.0838916 0.00758608 -2.34409e-21) (0.106115 0.0036986 1.36353e-22) (0.128051 -0.00232723 2.25055e-23) (0.149363 -0.010038 -9.54989e-21) (0.169608 -0.0191954 1.24415e-20) (0.188194 -0.0292392 -1.08901e-20) (0.00742585 0.00112794 -1.57935e-22) (0.0283037 0.0059134 -2.87139e-21) (0.0498633 0.0143975 0) (0.071422 0.0197125 -6.97496e-21) (0.0931417 0.0218332 7.00573e-21) (0.114721 0.0210481 2.6168e-21) (0.135825 0.0178371 -7.53696e-21) (0.156147 0.0126645 0) (0.175291 0.00590081 0) (0.192727 -0.00197698 0) (0.0116005 0.00219195 2.19246e-22) (0.0368814 0.0102198 1.00468e-21) (0.0598396 0.0226259 -1.61934e-21) (0.0812636 0.0314343 -3.0872e-21) (0.102158 0.0367512 -3.70267e-21) (0.122623 0.0388955 -2.20731e-21) (0.142467 0.0383659 0) (0.161453 0.0356845 -4.09224e-21) (0.179288 0.0313552 2.12097e-21) (0.195583 0.025732 0) (0.0166936 0.00371419 0) (0.0464856 0.0154316 -1.74916e-21) (0.0703893 0.0317835 1.61907e-21) (0.0911809 0.0439293 1.95493e-21) (0.110804 0.0522285 1.2872e-22) (0.129776 0.0571044 1.2225e-21) (0.148066 0.059124 -8.97851e-22) (0.165525 0.0588929 0) (0.18198 0.0570304 1.71156e-21) (0.197207 0.0537824 1.14418e-21) (0.02255 0.00586095 -1.8152e-24) (0.0568671 0.0216908 6.12166e-22) (0.0812827 0.0419109 1.19567e-22) (0.101009 0.0571683 3.9276e-23) (0.119004 0.0682025 7.35525e-22) (0.136219 0.07561 0) (0.152784 0.0800595 8.9765e-22) (0.168644 0.082243 0) (0.183731 0.0828628 0) (0.197959 0.0820911 0) (0.0290184 0.00876614 -4.42994e-24) (0.0677776 0.0291021 0) (0.092321 0.0530333 0) (0.110635 0.0711294 3.98491e-22) (0.126749 0.0846337 -1.86418e-22) (0.142048 0.0943726 -7.22741e-25) (0.156816 0.101133 2.98168e-22) (0.171075 0.105679 0) (0.184823 0.108757 0) (0.198062 0.11051 0) (0.0358637 0.0125262 0) (0.0789142 0.037726 2.23545e-22) (0.103279 0.0651391 -2.06189e-22) (0.119942 0.085769 -5.70355e-22) (0.13402 0.10147 0) (0.14733 0.113338 -4.00972e-22) (0.160294 0.122279 3.72881e-22) (0.172983 0.129098 0) (0.185419 0.134556 -2.56375e-23) (0.197628 0.138816 2.50109e-23) (0.0427373 0.0171781 0) (0.0898916 0.0475656 -1.59975e-21) (0.113898 0.07819 0) (0.128796 0.10103 -1.15104e-21) (0.140787 0.118642 0) (0.152112 0.13242 3.57293e-22) (0.163312 0.143371 0) (0.17448 0.152311 5.38757e-22) (0.185626 0.159996 -5.04577e-22) (0.19675 0.16664 -2.22312e-21) (0.0492969 0.0226795 2.41859e-22) (0.100326 0.0585368 9.87813e-22) (0.123929 0.092086 3.52404e-22) (0.13707 0.116809 8.09151e-22) (0.147013 0.136038 3.15821e-22) (0.156413 0.151477 -5.70089e-22) (0.165916 0.164219 1.97894e-22) (0.175619 0.175059 1.67288e-22) (0.185491 0.184728 1.66433e-21) (0.195468 0.193518 2.22531e-21) (0.0552105 0.0289113 2.04704e-22) (0.109844 0.070475 8.03074e-22) (0.133131 0.106673 8.71235e-22) (0.144641 0.132966 -3.89128e-22) (0.152651 0.153511 0) (0.160232 0.170337 0) (0.168127 0.184601 -2.20941e-21) (0.17643 0.197055 -2.94862e-21) (0.18505 0.208391 3.90334e-21) (0.193817 0.218987 -4.94672e-21) (0.0601616 0.0356773 -5.09808e-22) (0.118089 0.0831345 -4.35101e-22) (0.14127 0.121742 2.22008e-21) (0.151383 0.149323 1.4594e-22) (0.157645 0.170889 -1.79584e-22) (0.163541 0.188805 0) (0.169926 0.204285 0) (0.176883 0.21802 1.97053e-20) (0.184245 0.230658 -2.1997e-20) (0.191716 0.242658 -2.00928e-20) (0.0638691 0.0427109 -6.46042e-21) (0.12473 0.0961924 0) (0.148126 0.137031 -2.56183e-21) (0.157175 0.16567 4.84501e-23) (0.161931 0.187983 0) (0.166314 0.206693 3.15485e-21) (0.171313 0.223066 -1.08235e-20) (0.177022 0.237739 -1.88205e-20) (0.183197 0.251313 9.9174e-21) (0.189368 0.264296 1.24316e-20) (0.0661084 0.0496877 1.53828e-20) (0.12948 0.109257 1.3716e-21) (0.153502 0.152234 2.05866e-21) (0.161901 0.181773 7.16315e-23) (0.165448 0.204601 -2.50232e-21) (0.168508 0.223819 -4.27865e-21) (0.172232 0.24076 -1.35464e-21) (0.176727 0.256009 0) (0.181643 0.270149 0) (0.186332 0.283721 3.42128e-20) (0.0667294 0.0562449 -8.92268e-21) (0.132111 0.121881 9.77258e-21) (0.157222 0.166999 -3.21003e-21) (0.165458 0.197376 9.20459e-22) (0.168142 0.220547 -1.01344e-21) (0.170108 0.240032 3.63871e-21) (0.172731 0.257263 5.156e-21) (0.176207 0.272807 0) (0.180172 0.287277 0) (0.183817 0.301188 -1.6612e-20) (0.0656765 0.0620119 1.60772e-21) (0.132463 0.133577 -1.18047e-20) (0.159146 0.180945 1.87348e-21) (0.16776 0.212211 0) (0.169968 0.235633 0) (0.171083 0.255188 7.35549e-21) (0.172736 0.27244 0) (0.175181 0.287868 -1.52847e-20) (0.177851 0.302046 -3.24872e-21) (0.179533 0.31581 1.71056e-20) (0.0629948 0.0666491 0) (0.130452 0.143846 0) (0.159165 0.193661 6.67422e-21) (0.168729 0.225985 0) (0.170884 0.249664 3.17097e-21) (0.171419 0.269174 -2.93885e-21) (0.172277 0.286326 0) (0.173889 0.301678 0) (0.175941 0.316041 -1.85592e-20) (0.177828 0.331805 3.80846e-20) (0.0587513 0.0697859 0) (0.125995 0.152112 1.18229e-20) (0.1572 0.20472 3.61296e-21) (0.168292 0.23839 1.54165e-21) (0.170861 0.262457 -5.72251e-22) (0.171138 0.28189 -1.09569e-20) (0.171435 0.298842 0) (0.172441 0.314025 0) (0.174193 0.328083 0) (0.176326 0.342633 1.99876e-21) (0.0531368 0.0711128 0) (0.119229 0.157872 4.17732e-21) (0.1532 0.213611 -3.10987e-21) (0.166361 0.249096 -3.31106e-22) (0.16986 0.273812 4.38009e-22) (0.170221 0.293238 2.16197e-22) (0.170167 0.309917 1.16152e-20) (0.170652 0.324763 -1.48652e-20) (0.171869 0.33827 3.72833e-20) (0.173343 0.35122 -4.15181e-20) (0.0465071 0.0704645 2.72491e-21) (0.110359 0.160717 -1.23994e-20) (0.147123 0.219834 -1.18166e-20) (0.162888 0.25771 2.81638e-21) (0.167834 0.283507 5.98811e-22) (0.168642 0.303134 5.42973e-21) (0.168445 0.319565 -6.96578e-21) (0.168484 0.333971 3.1674e-20) (0.169135 0.346776 3.53419e-21) (0.169904 0.35837 -1.8814e-20) (0.0392733 0.0678211 2.55134e-21) (0.0996776 0.160269 -2.42382e-21) (0.139039 0.222962 0) (0.157817 0.263832 -3.04603e-21) (0.164729 0.291278 8.51763e-23) (0.166383 0.311474 1.31746e-21) (0.166286 0.327831 -4.4484e-21) (0.166003 0.34186 -2.35384e-20) (0.166122 0.354071 -2.08358e-21) (0.166434 0.364643 3.18035e-20) (0.0318745 0.0633065 0) (0.0876087 0.156318 1.19864e-20) (0.129059 0.222563 -3.27153e-21) (0.151083 0.26702 2.28777e-21) (0.160458 0.296804 -2.26061e-22) (0.163411 0.318088 -1.02814e-21) (0.163733 0.33469 -9.52636e-22) (0.163352 0.348493 1.50255e-20) (0.163143 0.360208 -2.59265e-20) (0.162992 0.370081 2.89533e-20) (0.0247453 0.0571841 -1.48269e-21) (0.0746852 0.14885 -8.43773e-21) (0.117362 0.218263 0) (0.142621 0.266781 -2.4212e-21) (0.154892 0.299671 -1.53208e-22) (0.159635 0.322724 -2.07375e-21) (0.16074 0.340042 7.05896e-21) (0.160464 0.353903 0) (0.159981 0.36529 0) (0.159355 0.374579 0) (0.018272 0.0498338 1.26571e-21) (0.0615224 0.138079 2.73893e-21) (0.104225 0.209815 -2.55519e-21) (0.132387 0.262602 -1.40148e-21) (0.14785 0.299354 7.27209e-22) (0.154882 0.324999 1.23437e-21) (0.157204 0.343689 0) (0.157307 0.35807 7.10946e-21) (0.15667 0.36948 -3.01379e-21) (0.155696 0.378497 0) (0.0127536 0.0417108 0) (0.0487805 0.124458 -5.7896e-21) (0.0900591 0.19717 2.55453e-21) (0.120398 0.254 1.15818e-21) (0.139112 0.295216 -3.12193e-22) (0.148893 0.324365 -9.37411e-22) (0.15295 0.345282 9.74873e-22) (0.153839 0.360849 0) (0.153298 0.372789 -3.64412e-21) (0.152149 0.381959 -4.48559e-21) (0.00837544 0.0333199 -1.64573e-22) (0.037108 0.108692 2.04063e-21) (0.0754432 0.180562 5.01383e-23) (0.106812 0.240599 -1.3357e-22) (0.128466 0.286509 -7.78101e-23) (0.141307 0.320011 0) (0.147655 0.344166 -9.74471e-22) (0.149868 0.361808 0) (0.149816 0.374964 0) (0.148727 0.384808 0) ) ; boundaryField { inlet { type uniformFixedValue; uniformValue constant (1 0 0); value uniform (1 0 0); } outlet { type pressureInletOutletVelocity; value nonuniform List<vector> 40 ( (0.0359364 0.347314 0) (0.00665451 0.398138 0) (-0.000678972 0.456474 0) (0.00139868 0.500612 0) (0.000811237 0.524419 0) (-0.00126802 0.537721 0) (-0.00609521 0.548149 0) (-0.00994965 0.560738 0) (-0.013006 0.577442 0) (-0.00691522 0.597838 0) (0.0420443 0.300974 -3.91332e-23) (0.0414487 0.27522 2.269e-23) (0.0390633 0.24419 -5.73906e-23) (0.035179 0.209068 -1.05751e-23) (0.0301633 0.171229 3.16964e-23) (0.0245718 0.132274 0) (0.0189656 0.0938657 -2.3431e-24) (0.0138383 0.0575053 3.77744e-24) (0.0095269 0.024329 -2.45444e-24) (0 -0.00501993 0) (0 -0.0304595 0) (0 -0.0524177 0) (0 -0.0715482 0) (0 -0.0885501 0) (0 -0.104051 0) (0 -0.118553 0) (0 -0.132426 0) (0 -0.145928 0) (0 -0.159233 0) (0 -0.172458 0) (0 -0.203868 0) (0 -0.257836 0) (0 -0.311908 0) (0 -0.368337 0) (0 -0.431992 0) (0 -0.509042 0) (0 -0.607564 0) (0 -0.727572 0) (0 -0.841203 0) (0 -0.906906 0) ) ; } cylinder { type fixedValue; value uniform (0 0 0); } top { type symmetryPlane; } bottom { type symmetryPlane; } defaultFaces { type empty; } } // ************************************************************************* //
fe833b16486826b49779d021ddb59ba8dd070dd1
1012ed7a2e231215c59ffc99acb68e7d2e5efe12
/src/SigPro.cc
f729fceabd8ffc3330097d09f917737e78c484a4
[]
no_license
jford22/sigpro
042385bdfc24e86249bb32636a358d4f9f25beab
4f6fa28b7a276780d440bd2d18ea357248e7ba20
refs/heads/master
2020-09-11T19:29:51.390196
2019-11-24T04:01:22
2019-11-24T04:01:22
222,168,022
0
0
null
null
null
null
UTF-8
C++
false
false
1,370
cc
SigPro.cc
#include <iostream> #include "SigPro.h" #include "TxRxMeta.h" #include "SigProTestInputGenerator.h" #include "Target.h" #include "TargetDecorator.h" #include "NoiseDecorator.h" #include "SignalDecorator.h" #include "SignalImpl.h" #include "Signal.h" #include "Channel.h" SigPro::SigPro(): signal(), control_set(), target_set() { signal = new TargetDecorator(new NoiseDecorator(new SignalDecorator(new SignalImpl(30)))); } SigPro::~SigPro() { } void SigPro::setupSignal() { std::cout << "SigPro SetupSignal() " << std::endl; SigProTestInputGenerator testgen; unsigned int set_selector = 0; control_set = testgen.generateControl(MAX_PULSES, set_selector); target_set = testgen.generateTargets(MAX_TARGETS, set_selector); signal->init(); } void SigPro::generateScene() { // Setup Config Data std::map<int,Channel> channel_set; for(auto control : control_set) { std::cout << "----------- PRI # " << control.first << " --------------" << std::endl; Channel& channel = channel_set[control.first]; // Create or Re-use pri Channel const TxRxMeta& txrx_config = control.second; // Setup Target Data Target tgt = target_set.at(0); // Run SigPro Class signal->setup(txrx_config, tgt); signal->stage(channel); signal->contribute(channel); } }
29aa8561141e046eb5bb391367d86aa6ced35613
79bd639c75da41ef50549141eb19ad1327026dd5
/gui/retracer.h
402e809da9d20e03218f9b8e61a5492d23040ae1
[ "MIT" ]
permissive
apitrace/apitrace
0ff067546af346aa623197491e54d4d0f80ca887
00706d1a395ab6570ab88136fffb3028a3ded3bd
refs/heads/master
2023-08-18T14:51:16.977789
2023-08-07T17:51:44
2023-08-11T08:18:20
1,611,530
2,097
452
MIT
2023-08-25T16:49:59
2011-04-13T21:37:46
C++
UTF-8
C++
false
false
2,677
h
retracer.h
#pragma once #include "trace_api.hpp" #include "apitrace.h" #include "apitracecall.h" #include <QThread> #include <QProcess> class ApiTraceState; namespace trace { struct Profile; } struct RetracerCallRange { qlonglong m_callStartNo{0}; qlonglong m_callEndNo{0}; }; class Retracer : public QThread { Q_OBJECT public: Retracer(QObject *parent=0); QString fileName() const; void setFileName(const QString &name); QString remoteTarget() const; void setRemoteTarget(const QString &host); void setAPI(trace::API api); bool isBenchmarking() const; void setBenchmarking(bool bench); bool isDoubleBuffered() const; void setDoubleBuffered(bool db); bool isSinglethread() const; void setSinglethread(bool singlethread); bool isCoreProfile() const; void setCoreProfile(bool coreprofile); bool isProfilingGpu() const; bool isProfilingCpu() const; bool isProfilingPixels() const; bool isProfiling() const; void setProfiling(bool gpu, bool cpu, bool pixels); bool isMsaaResolve() const; void setMsaaResolve(bool resolve); void setCaptureAtCallNumber(qlonglong num); qlonglong captureAtCallNumber() const; void setCallsToIgnore(const QList<RetracerCallRange>& callsToIgnore); bool captureState() const; void setCaptureState(bool enable); bool captureThumbnails() const; void setCaptureThumbnails(bool enable); void addThumbnailToCapture(qlonglong num); void resetThumbnailsToCapture(); QString thumbnailCallSet(); int queryHandling(); void setQueryHandling(int handling); int queryCheckReportThreshold(); void setQueryCheckReportThreshold(int value); signals: void finished(const QString &output); void foundState(ApiTraceState *state); void foundProfile(trace::Profile *profile); void foundThumbnails(const QList<QImage> &thumbnails); void foundThumbnails(const ImageHash &thumbnails); void error(const QString &msg); void retraceErrors(const QList<ApiTraceError> &errors); protected: virtual void run() override; private: QString m_fileName; QString m_remoteTarget; trace::API m_api; bool m_benchmarking; bool m_doubleBuffered; bool m_singlethread; bool m_useCoreProfile; bool m_msaaResolve; bool m_captureState; bool m_captureThumbnails; qlonglong m_captureCall; bool m_profileGpu; bool m_profileCpu; bool m_profilePixels; int m_queryHandling; int m_queryCheckThreshold; QProcessEnvironment m_processEnvironment; QList<qlonglong> m_thumbnailsToCapture; QList<RetracerCallRange> m_callsToIgnore; };
40b89c780c59f4c4def8aa01db88fb3130dab3f4
d447c6389c32d8e6f4003ea55c6ba1ceac26b28d
/FontDumy/Inc/LGTypeDef.h
2dc74cca8cbe797b553615ee8981d60797c6a68d
[]
no_license
aorura/fontLength
f1e06d5490e0efc61abdc8b793b75bb1caaf1ea9
09c9ef5ba79231f0ced4a0a070b944285d97d379
refs/heads/master
2021-01-10T13:56:05.394672
2015-12-29T11:50:50
2015-12-29T11:50:50
48,418,621
0
0
null
null
null
null
UHC
C++
false
false
9,905
h
LGTypeDef.h
// CARINFO3 Team. LABORATORY, LG ELECTRONICS INC., // Copyright(c) 2012 by LG Electronics Inc. // // All rights reserved. No part of this work may be reproduced, stored in a // retrieval system, or transmitted by any means without prior written // permission of LG Electronics Inc. // // \file LGTypeDef // // @brief Common Used Type Definitions. // //---------------------------------------------------------------------------- // Ver. Date name Edition history // ----- -------- ------------ -------------------------------------------- // 1.0.0 2012.7.7 Mason.Woo released #pragma once #ifdef IS_WINDOWS #pragma warning(disable:4996) #pragma warning(disable:4209) #pragma warning(disable:4786) #pragma warning(disable:4204) #endif #ifndef __LGTYPEDEF_H__ #define __LGTYPEDEF_H__ #ifdef WIN32 //#pragma comment(lib,"libagg.lib") //#pragma comment(lib,"libpng.lib") //#pragma comment(lib,"libz.lib") //#pragma comment(lib,"comctl32.lib") #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #include <string> #include <list> #include <vector> #ifndef _WCHAR_T_DEFINED # include <wchar.h> #endif using namespace std; #ifdef _UNICODE typedef wstring lgString; #else typedef string lgString; #endif //#define CALLBACK __stdcall ////////////////////////////////////////////////////////////////////////// //Type redefine. #ifdef WIN32 // unsigned number typedef unsigned char lgBYTE, *lgPBYTE; typedef unsigned short lgWORD, *lgPWORD; typedef unsigned long lgDWORD, *lgPDWORD; //typedef unsigned __int64 lgQWORD, *lgPQWORD; // signed number typedef short lgSHORT, *lgPSHORT; typedef long lgLONG, *lgPLONG; //typedef __int64 lgLLONG, *lgPLLONG; // normal number typedef int lgINT, *lgPINT; typedef unsigned int lgUINT, *lgPUINT; // size typedef size_t lgSIZET, *lgPSIZET; // float typedef float lgSINGLE, *lgPSINGLE; typedef double lgDOUBLE, *lgPDOUBLE; #ifdef M_FLOAT_SINGLE typedef lgSINGLE lgFLOAT, *lgPFLOAT; #else typedef lgDOUBLE lgFLOAT, *lgPFLOAT; #endif // void type typedef void lgVOID, *lgPVOID; // Gerneral pointer typedef lgVOID* lgPTR; typedef const lgVOID* lgCONSTPTR; // handle typedef lgVOID* lgHANDLE, *lgPHANDLE; // string typedef char lgACHAR; typedef lgACHAR* lgASTRING; typedef const lgACHAR* lgCONSTASTRING; typedef wchar_t lgWCHAR; typedef lgWCHAR* lgWSTRING; typedef const lgWCHAR* lgCONSTWSTRING; #else typedef unsigned char lgBYTE, *lgPBYTE; typedef unsigned short lgWORD, *lgPWORD; typedef unsigned long lgDWORD, *lgPDWORD; //typedef unsigned __int64 lgQWORD, *lgPQWORD; // signed number typedef short lgSHORT, *lgPSHORT; typedef long lgLONG, *lgPLONG; //typedef __int64 lgLLONG, *lgPLLONG; // normal number typedef int lgINT, *lgPINT; typedef unsigned int lgUINT, *lgPUINT; // size typedef size_t lgSIZET, *lgPSIZET; // float typedef float lgSINGLE, *lgPSINGLE; typedef double lgDOUBLE, *lgPDOUBLE; #ifdef M_FLOAT_SINGLE typedef lgSINGLE lgFLOAT, *lgPFLOAT; #else typedef lgDOUBLE lgFLOAT, *lgPFLOAT; #endif // void type typedef void lgVOID, *lgPVOID; // Gerneral pointer typedef lgVOID* lgPTR; typedef const lgVOID* lgCONSTPTR; // handle typedef lgVOID* lgHANDLE, *lgPHANDLE; // string typedef char lgACHAR; typedef lgACHAR* lgASTRING; typedef const lgACHAR* lgCONSTASTRING; typedef wchar_t lgWCHAR; typedef lgWCHAR* lgWSTRING; typedef const lgWCHAR* lgCONSTWSTRING; #endif // NULL VALUE #ifndef NULL #define NULL 0 #endif typedef unsigned char uint8; typedef signed char sint8; typedef unsigned short uint16; typedef signed short sint16; typedef unsigned int uint32; typedef signed int sint32; typedef unsigned long long uint64; typedef signed long long sint64; #if !WIN32 typedef unsigned int boolean; #else #endif #ifndef FALSE #define FALSE (0) #endif typedef char lgBOOL; #define lgTRUE 1 #define lgFALSE 0 #ifndef NULL #define NULL ((lgVOID *)0) #endif #ifndef _UNICODE typedef lgACHAR lgCHAR; #define LG_T(x) x #define STRLEN strlen #define STRCPY strcpy #define STRDUP strdup #define STRNCPY strncpy #define STRCAT strcat #define STRNCAT strncat #define STRCMP strcmp #define STRICMP stricmp #define STRNCMP strncmp #define STRNICMP strnicmp #define STRCHR strchr #define STRRCHR strrchr #define STRSTR strstr #define STRUPR strupr #define STRLWR strlwr #define STRTOK strtok #define ATOI atoi #define ATOF atof #define PRINTF printf #define SPRINTF sprintf #ifdef _MSC_VER #define VSPRINTF _vsnprintf #else #define VSPRINTF vsnprintf #endif #define SSCANF sscanf #define FOPEN fopen #define GETENV getenv #define FGETS fgets #else // _UNICODE typedef lgWCHAR lgCHAR; #define LG_T(x) L##x #define STRLEN wcslen #define STRCPY wcscpy #define STRNCPY wcsncpy #define STRDUP wcsdup #define STRCAT wcscat #define STRNCAT wcsncat #define STRCMP wcscmp #define STRICMP wcsicmp #define STRNCMP wcsncmp #define STRNICMP wcsnicmp #define STRCHR wcschr #define STRRCHR wcsrchr #define STRSTR wcsstr #define STRUPR wcsupr #define STRLWR wcslwr #define STRTOK wcstok #define ATOI _wtoi #define ATOF(x) wcstod(x,NULL) #define PRINTF wprintf #define SPRINTF swprintf #ifdef _MSC_VER #define VSPRINTF _vsnwprintf #else #define VSPRINTF vswprintf #endif // WIN32 #define SSCANF swscanf #define FOPEN _wfopen #define GETENV _wgetenv #define FGETS fgetws #endif // _UNICODE typedef lgCHAR* lgSTRING; typedef const lgCHAR* lgCONSTSTRING; //typedef struct st_id_name //{ // uint32 id; // uint8 name[252]; //}idname; #define UI8_0 (uint8)0 #define UI16_0 (uint16)0 #define UI32_0 (uint32)0 #define UI64_0 (uint64)0 #define SI8_0 (sint8)0 #define SI16_0 (sint16)0 #define SI32_0 (sint32)0 #define SI64_0 (sint64)0 #ifdef _MSC_VER #define LGFILE_SEPARATOR LG_T('\\') #else #define LGFILE_SEPARATOR LG_T('/') #endif ////////////////////////////////////////////////////////////////////////// // Common Macro Function. #define SAFE_NEW(x,y) {x=NULL;if(!x)x = new y;} #define SAFE_NEW1(x,y,z) {x=NULL;if(!x)x = new y[z];} #define SAFE_CREATE(x,y,z) {if(!x)x = new y;x->OnCreate(z);} #define SAFE_DESTROY(x) if (x) {x->OnDestroy(); delete x; x = NULL;} #define SAFE_DELETE(x) if (x) {delete x; x = NULL;} #define SAFE_DELETE1(x) if (x) {delete[] x; x = NULL;} #define MEMZERO(destin) memset (&destin, 0, sizeof (destin)); #define BMP_BUF_SIZE(w,h,b) ( ( ( ( w * b + b ) >> 2 ) << 2 ) * h ) #define BMP_LINE_SIZE(w,b) ( ( ( w * b + b ) >> 2 ) << 2 ) /////////////////////////////////////////////////////////////////////////////////////////////// // UNICODE<->ANSI CODE : Global UNICODE<>ANSI translation helpers //949: Korean code-Page. #define HELPER_A2W(psz, wsz, iOutLen) MultiByteToWideChar(CP_ACP, 0, psz, -1, wsz, iOutLen) #define HELPER_A2WEX(iCodePage, psz, wsz, iOutLen) MultiByteToWideChar(iCodePage, 0, psz, -1, wsz, iOutLen) #define HELPER_W2A(wsz, psz, iOutLen) WideCharToMultiByte(CP_ACP, 0, wsz, -1, psz, iOutLen, 0, 0) /////////////////////////////////////////////////////////////////////////////////////////////// // EVENT //#define ON_EVENT(instance,_this,callee,type,nScene){instance->RegisterHandler(_this,callee,type,nScene);} typedef lgBOOL (* NOTIFY_HANDLER)(lgVOID* pParam, lgVOID* pParam1,lgVOID* pParam2,lgVOID* pParam3); typedef lgBOOL (* DRAW_HANDLER)(lgVOID* pParam, lgVOID* pParam1,lgVOID* pParam2,lgVOID* pParam3); typedef lgBOOL (* EVENT_HANDLER)( lgUINT x, lgUINT y, lgINT nID, lgVOID* pParam, lgVOID* pParam1, lgVOID* pParam2, lgVOID* pParam3); /////////////////////////////////////////////////////////////////////////////////////////////// // Operation #define DIM( _x ) ( sizeof(_x) / sizeof( (_x)[0] ) ) /////////////////////////////////////////////////////////////////////////////////////////////// // Debug #ifdef _HMI_ENGINE_SIMULATOR_MFC extern lgVOID OuputMessageEmulator( char* message); #define lgdebug( ... ) ( printf(__VA_ARGS__) ) //#define dlgdebug( ... ) ( printf(__VA_ARGS__) ) #define dlgdebug( ... ) {char s[128];sprintf( s,__VA_ARGS__ );OuputMessageEmulator(s);} #define windebug( ... ) ( printf(__VA_ARGS__) ) #elif WIN32 #define lgdebug( ... ) ( printf(__VA_ARGS__) ) #define dlgdebug( ... ) ( printf(__VA_ARGS__) ) #define windebug( ... ) ( printf(__VA_ARGS__) ) #else #include "../../include/bscommon.h" #include "../../include/bslog.h" #include "../../include/bsipc.h" //#include "../../include/bslog_attr.h" //#include "../../include/bslog_attr_debug.h" //#include "../../include/bslog_logtrace.h" #define lgdebug( ... ) lg_print(eLGDP_GUI_TRACE, ##__VA_ARGS__) #define dlgdebug( ... ) lg_print(eLGDP_GUI_TRACE, ##__VA_ARGS__) #define windebug( ... ) #endif typedef struct tagCALANDER { lgINT year; ///< 현재일자 lgINT month; ///< 1(1월)-12 lgINT mday; ///< 월중일자, 1-31 } CALENDER, *PCALENDER; typedef struct tagCLOCK { lgINT hour; ///< 시 lgINT min; ///< 분 lgINT second; } CLOCK, *PCLOCK; //static char * ltoa( int val, int base ) //{ // static char buf[32] = {0,}; // int i =30; // for( ; val&i; --i, val/=base ) // buf[i] = "0123456789abcdef"[val%base]; // return &buf[i+1]; //} static wchar_t * ltowcs( int val, int base ) { static wchar_t buf[32] = {0,}; int i =30; for( ; val&i; --i, val/=base ) buf[i] = L"0123456789abcdef"[val%base]; return &buf[i+1]; } #endif //__LGTYPEDEF_H__
bd705b870b39767c1d9ef56a2bc288bd7054bb0b
ff26883d46d3af70ead32fdabd5f7a4187c835f7
/Practice_Level1_Cpp.cpp
45ac72bc4fd09acf258e94ba6939fd968e010b45
[]
no_license
soy567/Algorithm_practice
940f22120d6a11fd1d667fb8a8c07e3472672075
c343cbf8e485a01c662f94c6feadbd26fe690903
refs/heads/master
2020-11-27T12:07:54.710070
2020-02-22T05:08:23
2020-02-22T05:08:23
229,432,225
0
0
null
null
null
null
UTF-8
C++
false
false
10,740
cpp
Practice_Level1_Cpp.cpp
//문제 - 문자열 압축 #include <iostream> #include <string> #include <vector> using namespace std; int solution(string s) { int answer = 0; int min_sub = s.size(); for(int i = 1; i <= s.size()/2; i++){ //2중 반복 이용 각 길이별로 잘라 길이 구하기 string a, b, ans = ""; int sub_len = 1; a = s.substr(0, i); //기존 문자열 for(int j = i; j < s.size(); j += i) { b = s.substr(j, i); //다음 문자열 if(a == b) { //기존과 다음 문자열이 같을 경우 sub_len++; } else { if(sub_len == 1) ans = ans + a; else ans = ans + to_string(sub_len) + a; sub_len = 1; //문자열 길이 초기화 a = b; //비교위한 기존 문자열 다시설정 } if(i + j >= s.size()) { //비교 범위가 문자열 길이 초과했을경우(비교가 불가능 하므로 기존 카운트와 뒤의 문자열만 뒤에 추가) if(sub_len != 1){ ans = ans + to_string(sub_len) + b; break; }else{ ans = ans + s.substr(j); break; } } } //cout << ans << endl; min_sub = (min_sub > ans.size()) ? ans.size() : min_sub; //각 길이로 자른 문자열 중 가장 짧은 문자열 길이 저장 } answer = min_sub; return answer; } //문제 - 완주하지 못한 선수 #include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; string solution(vector<string> participant, vector<string> completion) { string answer = ""; vector<string>::iterator position1, position2; sort(participant.begin(), participant.end()); sort(completion.begin(), completion.end()); for(int i = 0; i < participant.size(); i++) if(participant[i] != completion[i]) { answer = participant[i]; return answer; } return answer; } //문제 - 모의고사 #include <string> #include <vector> #include <iostream> using namespace std; int arr1[5] = {1, 2, 3, 4, 5}; int arr2[8] = {2, 1, 2, 3, 2, 4, 2, 5}; int arr3[10] = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; int max(int a, int b){ return (a > b)? a : b; } vector<int> solution(vector<int> answers) { vector<int> answer, score(3); int max_score = 0; for(int i = 0; i < answers.size(); i++) { if(arr1[i % 5] == answers[i]) score[0]++; if(arr2[i % 8] == answers[i]) score[1]++; if(arr3[i % 10] == answers[i]) score[2]++; } max_score = max(max(score[0], score[1]), score[2]); for(int j = 0; j < score.size(); j++) { if(max_score == score[j]) answer.push_back(j+1); } return answer; } //문제 - K번째 수 #include <string> #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> solution(vector<int> array, vector<vector<int>> commands) { vector<int> answer; int i, j, k; for(int n = 0; n < commands.size(); n++) { vector<int> tmp; i = commands[n][0]; j = commands[n][1]; k = commands[n][2]; for(int a = i; a <= j; a++) { cout << array[a-1] << endl; tmp.push_back(array[a-1]); } sort(tmp.begin(), tmp.end()); answer.push_back(tmp[k-1]); } return answer; } //문제 - 가운데 글자 가져오기 #include <string> #include <vector> using namespace std; string solution(string s) { string answer = ""; int str_size = s.size(); int half_size = str_size/2; if(str_size < 1 || str_size > 100) return 0; if(str_size%2 == 0) { answer = s[half_size-1]; answer += s[half_size]; } else answer = s[half_size]; return answer; } //문제 - 같은 숫자는 싫어 #include <vector> #include <iostream> using namespace std; vector<int> solution(vector<int> arr) { int arr_size = arr.size(); vector<int> answer; answer.push_back(arr[0]); for(int i = 1; i < arr_size; i++) if(arr[i-1] != arr[i]) answer.push_back(arr[i]); return answer; } //문제 - 나누어 떨어지는 숫자 배열 #include <string> #include <vector> #include <algorithm> using namespace std; vector<int> solution(vector<int> arr, int divisor) { vector<int> answer; int arr_size = arr.size(); for(int i = 0; i < arr_size; i++) { if(arr[i] % divisor == 0) answer.push_back(arr[i]); } sort(answer.begin(), answer.end()); if(answer.empty()) answer.push_back(-1); return answer; } //문제 - 문자열 내 마음대로 정렬하기 #include <string> #include <vector> #include <algorithm> using namespace std; vector<string> solution(vector<string> strings, int n) { vector<string> answer; vector<char> index; vector<string>::iterator pos; int size = strings.size(); for(int i = 0; i < strings.size(); i++) index.push_back((char)strings[i][n]); sort(index.begin(), index.end()); sort(strings.begin(), strings.end()); //인덱스 같을경우 순서대로 출력하기위해 입력문자열도 정렬 for(int k = 0; k < index.size(); k++) { pos = strings.begin(); for(int j = 0; j < strings.size(); j++) if(index[k] == (char)strings[j][n]){ answer.push_back(strings[j]); strings.erase(pos+j); //들어간 문자열 삭제 break; } } return answer; } //문제 - 문자열 내 p와 y의 개수 #include <string> #include <iostream> using namespace std; bool solution(string s) { bool answer = true; int p = 0, y = 0; for(int i = 0; i < s.size(); i++) { if(s[i] == 'p' || s[i] == 'P') p++; else if(s[i] == 'y' || s[i] == 'Y') y++; } if(p != y) answer = false; return answer; } //문제 - 문자열 내림차순으로 배치하기 #include <string> #include <vector> #include <algorithm> using namespace std; bool desc(char a, char b) { return a > b; } string solution(string s) { string answer = ""; sort(s.begin(), s.end(), desc); answer = s; return answer; } //문제 - 소수 찾기 /* 시간초과 코드 #include <string> #include <vector> #include <iostream> using namespace std; int solution(int n) { int answer = 2; for(int i = 4; i <= n; i++) { int tmp = 0; for(int j = 2; j < i; j++) { if(i % j == 0) { tmp = 1; break; } } if(tmp == 0) answer++; } return answer; } */ //에라토스테네스이 체 이용 #include <string> #include <vector> #include <iostream> using namespace std; int solution(int n) { int answer = 0; int nums[1000000] = {0}; for(int i = 2; i <= n; i++) { if(nums[i] == 1) continue; for(int j = i*2; j <= n; j += i) //j+=i -> 해당 수의 배수 nums[j] = 1; } for(int i = 2; i <= n; i++) if(nums[i] == 0) answer++; return answer; } //문제 - 문자열을 정수로 바꾸기 #include <string> #include <vector> #include <iostream> using namespace std; int solution(int n) { int answer = 0; int nums[1000000] = {0}; for(int i = 2; i <= n; i++) { if(nums[i] == 1) continue; for(int j = i*2; j <= n; j += i) //j+=i -> 해당 수의 배수 nums[j] = 1; } for(int i = 2; i <= n; i++) if(nums[i] == 0) answer++; return answer; } //문제 - 시저 암호 #include <string> using namespace std; string solution(string s, int n){ string answer = ""; int len = s.length(); for( int i = 0 ; i < len; i++) { if(s[i] != ' ') { char sta = ('A' <= s[i] && s[i] <= 'Z') ? 'A' : 'a'; answer += (((s[i] - sta)+n)%26) + sta; continue; } answer += s[i]; } return answer; } //문제 - 정수 내림차순으로 배치하기 #include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; long long solution(long long n) { long long answer = 0; vector<int> nums; int i, j; while(n > 0) { cout << n%10 << endl; nums.push_back(n%10); n /= 10; } sort(nums.begin(), nums.end()); i = 0; j = 1; while(i < nums.size()) { answer += nums[i]*j; i++; j *= 10; } return answer; } //문제 - 최대공약수와 최소공배수 #include <string> #include <vector> using namespace std; void get_gcd_lcm(int a, int b, vector<int> &arr) { int tmp, n, ta = a, tb = b; if(ta > tb) { //a보다 b가 커야함 tmp = ta; ta = tb; tb = tmp; } while(tb != 0) { n = ta%tb; ta = tb; tb = n; } arr.push_back(ta); arr.push_back(a*b/ta); } vector<int> solution(int n, int m) { vector<int> answer; get_gcd_lcm(n, m, answer); return answer; } //문제 - 핸드폰 번호 가리기 #include <string> #include <vector> using namespace std; string solution(string phone_number) { string answer = ""; int size = phone_number.size(); for(int i = 0; i < size; i++) { if(i < size-4) answer += '*'; else answer += phone_number[i]; } return answer; } //문제 - 행렬의 덧셈 #include <string> #include <vector> using namespace std; vector<vector<int>> solution(vector<vector<int>> arr1, vector<vector<int>> arr2) { vector<vector<int>> answer; for(int i = 0; i < arr1.size(); i++) { answer.push_back(arr1[i]); //벡터 공간할당 for(int j = 0; j < arr1[i].size(); j++) answer[i][j] = arr1[i][j] + arr2[i][j]; } return answer; } //문제 - x만큼 간격이 있는 n개의 숫자 #include <string> #include <vector> #include <iostream> using namespace std; vector<long long> solution(int x, int n) { vector<long long> answer; int i = 0, j = 0; while(i < n) { j += x; answer.push_back(j); i++; } return answer; } //문제 - 예산 #include <iostream> #include <vector> #include <algorithm> using namespace std; int solution(vector<int> d, int budget) { int answer = 0; long sum = 0; sort(d.begin(), d.end()); for(int i = 0; i < d.size(); i++) { sum += d[i]; if(sum <= budget) answer++; else break; } return answer; }
2f39fd3e13da147ba87cff357d68c6c94a5df60c
4217ad2034022e63967f936f0bc2c375df62d110
/ABC13x/ABC139/A/ans.cpp
564c85f0f1e8888b0dd3ea899f9bdf04912dbf5e
[]
no_license
sealddr/MyAtCoder
53b734124d08e479885274f4fd576d99683b50c8
3b9914115fd93503c04477233c5404a5f44f1378
refs/heads/master
2022-07-04T01:02:19.690485
2022-05-28T13:55:47
2022-05-28T13:55:47
239,226,855
0
0
null
null
null
null
UTF-8
C++
false
false
320
cpp
ans.cpp
#include <iostream> #include <string> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); ++i) int main(void) { string s, t; cin >> s >> t; int cnt = 0; if(s[0] == t[0]) ++cnt; if(s[1] == t[1]) ++cnt; if(s[2] == t[2]) ++cnt; cout << cnt << endl; return 0; }
4785c7156341d1f39255ed7567540fdbbcb992e0
527a89c21076d4c61f81965ce04727067b6ebefe
/perlin.hpp
6060cd1c6d1472cea45a074ca3067e4490ce9f92
[]
no_license
daRoyalCacti/Raytracing
df35f15d2ead02053c1af58068391a6b11286ae0
7a13837a05e1f18fcc3cc87e878ba60d653b989a
refs/heads/master
2023-06-25T21:54:22.637310
2021-07-12T23:49:25
2021-07-12T23:49:25
316,123,241
0
0
null
null
null
null
UTF-8
C++
false
false
3,204
hpp
perlin.hpp
#pragma once #include "vec3.hpp" #include <algorithm> #include <numeric> class perlin { static constexpr unsigned point_count = 256; std::array<vec3, point_count> ranvec; //array to hold the noise //was original a double array, now vec3 to help with smoothing the noise const std::array<int, point_count> perm_x; //permutations for the x-direction const std::array<int, point_count> perm_y; const std::array<int, point_count> perm_z; static std::array<int, point_count> perlin_generate_perm() { //creates a permutation of the numbers from 0 to point_count std::array<int, point_count> p; std::iota(&p[0], &p[point_count], 0); permute(p, point_count); return p; } static void permute(std::array<int, point_count> p, const int n) { //creates a permutation of an integer array of length n for (int i = n-1; i>0; i--) { //switches p[i] with some p[n] for n<i const int target = random_int(0,i); std::swap(p[i], p[target]); } } static double perlin_interp(const vec3 c[2][2][2], const double u, const double v, const double w) { //first using a Hermite cubic to smooth the results const auto uu = u*u*(3-2*u); const auto vv = v*v*(3-2*v); const auto ww = w*w*(3-2*w); auto accum = 0.0; for (int i=0; i<2; i++) for (int j=0; j<2; j++) for (int k=0; k<2; k++) { const vec3 weight_v(u-i, v-j, w-k); accum +=(i*uu + (1-i)*(1-uu)) * //regal trilinear interpolation (j*vv + (1-j)*(1-vv)) * (k*ww + (1-k)*(1-ww)) * dot(c[i][j][k], weight_v); //with a slight modification } return accum; } public: perlin() : perm_x(perlin_generate_perm()), perm_y(perlin_generate_perm()), perm_z(perlin_generate_perm()){ for (int i = 0; i < point_count; i++) { ranvec[i] = unit_vector(random_vec3(-1,1)); } } ~perlin() = default; [[nodiscard]] double noise(const point3& p) const { //scrambling (using a hash) the random numbers (all point_count of them) to remove tiling auto u = p.x() - floor(p.x()); //the decimal part of p.x auto v = p.y() - floor(p.y()); auto w = p.z() - floor(p.z()); const auto i = static_cast<int>(floor(p.x())); //used in the scrambling const auto j = static_cast<int>(floor(p.y())); const auto k = static_cast<int>(floor(p.z())); vec3 c[2][2][2]; //smoothing out the result using linear interpolation for (int di=0; di<2; di++) { for (int dj=0; dj<2; dj++) { for (int dk=0; dk<2; dk++) { c[di][dj][dk] = ranvec[ //the scrambling for the current point and the a points 1 and 2 integer steps in each direction perm_x[(i+di)&255] ^ // - other points are required for the linear interpolation perm_y[(j+dj)&255] ^ perm_z[(k+dk)&255] ]; } } } return perlin_interp(c, u, v, w); //the actual linear interpolation } [[nodiscard]] double turb(const point3& p, const int depth=7) const { auto accum = 0.0; auto temp_p = p; auto weight = 1.0; for (int i = 0; i < depth; i++) { accum += weight * noise(temp_p); //the actual noise weight *= 0.5; //progressive additions of noise have less impact overall temp_p *= 2; //so the noise is not all at the same place } return fabs(accum); } };
5ca714fe39c9c37e8259df21d91e2d68a8a0a55a
e81d8f24860ece7d1ed987b2ef929b39df46642d
/Primero/1 Cuatrimestre/FP/Sesión 8/Ejercicios de clase/11_Tipo Conjunto.cpp
4433bbe91f3aa2595179132f5a50096f7fa51e96
[ "MIT" ]
permissive
Duckboy117/DGIIM
e338a6664d8e7ab62bca0974b52883de925fe4b8
b4044149b03b7d81f87d7994360646dddb109342
refs/heads/master
2023-01-28T02:21:36.339205
2020-12-07T23:50:59
2020-12-07T23:50:59
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
4,032
cpp
11_Tipo Conjunto.cpp
/* Programa para trabajar con conjuntos. Permite introducir elementos en un conjunto, calcular la unión y la intersección. Se asume que el usuario ha introducido previamente los datos iniciales */ // TENGO QUE CORREGIR LOS DOS ÚLTIMOS #include<iostream> using namespace std; struct TipoConjunto{ int num_elem; int elementos[1000]; }; int main(){ TipoConjunto ConjuntoA; TipoConjunto ConjuntoB; int elemento; bool pertenece; char opcion; char conjunto; int a_desplazar; int posicion; TipoConjunto ConjuntoUnion; int contador = 0; /* Asumimos que el usuario ha introducido los siguientes datos iniciales */ ConjuntoA.elementos [0] = 2; ConjuntoA.elementos [1] = 7; ConjuntoA.elementos [2] = 9; ConjuntoA.elementos [3] = 10; ConjuntoA.elementos [4] = 11; ConjuntoA.num_elem = 5; ConjuntoB.elementos [0] = 2; ConjuntoB.elementos [1] = 9; ConjuntoB.elementos [2] = 15; ConjuntoB.elementos [3] = 20; ConjuntoB.num_elem = 4; // Determinar si un elemento pertenece al conjunto do{ cout << "\nIntroduce un elemento para ver si pertenece a algún conjunto: "; cin >> elemento; pertenece = false; for(int i = 0; i != ConjuntoA.num_elem && !pertenece; i++) if(ConjuntoA.elementos[i] == elemento) pertenece = true; if(pertenece) cout << "\nEl elemento " << elemento << " pertenece al primer conjunto "; if(!pertenece) cout << "\nEl elemento " << elemento << " no pertenece al primer conjunto "; pertenece = false; for(int i = 0; i != ConjuntoB.num_elem && !pertenece; i++) if(ConjuntoB.elementos[i] == elemento) pertenece = true; if(pertenece) cout << "\nEl elemento " << elemento << " pertenece al segundo conjunto "; if(!pertenece) cout << "\nEl elemento " << elemento << " no pertenece al segundo conjunto "; cout << "\n\n¿Quieres analizar otro elemento (s/n)? "; cin >> opcion; }while(opcion == 's'); // Incorporar un nuevo elemento al conjunto cout << "\n\nIncorpore un nuevo elemento al conjunto "; do{ cout << "\nElige el conjunto al que añadir el elemento (A/B): "; cin >> conjunto; switch (conjunto){ case 'A': cout << "\nIntroduzca un elemento: "; cin >> ConjuntoA.elementos [ConjuntoA.num_elem]; ConjuntoA.num_elem++; a_desplazar = ConjuntoA.elementos [ConjuntoA.num_elem - 1]; for(int i = ConjuntoA.num_elem - 1; ConjuntoA.elementos [i] > a_desplazar; i--){ ConjuntoA.elementos [i+1] = ConjuntoA.elementos[i]; posicion = i; } ConjuntoA.elementos[posicion] = a_desplazar; cout << "\nEl conjunto A ahora es: " << "\n\n"; for(int z = 0; z != ConjuntoA.num_elem; z++) cout << ConjuntoA.elementos [z] << " "; break; case 'B': cout << "\nIntroduzca un elemento: "; cin >> ConjuntoB.elementos [ConjuntoB.num_elem]; ConjuntoB.num_elem++; a_desplazar = ConjuntoB.elementos [ConjuntoB.num_elem - 1]; for(int i = ConjuntoB.num_elem - 1; ConjuntoB.elementos [i] > a_desplazar; i--){ ConjuntoB.elementos [i+1] = ConjuntoB.elementos[i]; posicion = i; } ConjuntoB.elementos[posicion] = a_desplazar; cout << "\nEl conjunto B ahora es: " << "\n\n"; for(int z = 0; z != ConjuntoB.num_elem; z++) cout << ConjuntoB.elementos [z] << " " ; break; }; cout << "\n\n¿Quieres introducir más elementos(s/n)? "; cin >> opcion; }while(opcion == 's'); // Calcular la unión de los dos conjuntos cout << "\n\nLa unión de los dos conjuntos será: "; // Calcular la interseccion cout << "\n\nLa intersección será : " << "\n"; for(int i = 0; i != ConjuntoA.num_elem; i++){ for(int z = 0; z != ConjuntoA.num_elem; z++){ if(ConjuntoA.elementos[z] == ConjuntoB.elementos[contador]); cout << ConjuntoB.elementos[contador]; } contador++; } cout << "\n\n"; system ("pause"); }
8f25867d94960b6fe8fe9ff85067c597bc01f67d
81a79b2b835f885990641feff068c10601ac92a2
/TextStream.h
02a62694afd7cd0ba80021748f05666abe3abb7a
[]
no_license
Paulware/RoboticsLibrary
31339a2025b34ff69af0d7edf73a965eeee2ab1b
c4f4ada36665456d5e8b4213f9e1b7afbb89c11d
refs/heads/master
2021-01-21T16:35:00.941094
2018-09-02T04:07:53
2018-09-02T04:07:53
95,407,785
0
0
null
null
null
null
UTF-8
C++
false
false
1,090
h
TextStream.h
#ifndef TextStream_h #define TextStream_h #include <SoftwareSerial.h> class TextStream : public SoftwareSerial { public: TextStream (int pin) : SoftwareSerial (pin,20) { begin (9600); }; TextStream (int rxPin, int txPin) : SoftwareSerial (rxPin,txPin) { begin (9600); }; TextStream() : SoftwareSerial (20,20) { useSerial = true; } void update (void) { //bool debug = false; ch = 0; if (useSerial) { if (Serial.available()) { ch = Serial.read(); /* if (debug) { if (ch == 10) { Serial.println ( "Ch == LF"); } else if (ch == 13) { Serial.println ( "Ch == CR"); } else { Serial.print ( "Ch =" ); Serial.println (ch); } } */ } } else { if (available()) { ch = read(); } } }; char ch; private: bool useSerial = false; }; #endif
63735ff2042c30b49e50888303b6fc08e611b92f
d1cee40adee73afdbce5b3582bbe4761b595c4e1
/back/RtmpLivePushSDK/boost/boost/accumulators/statistics/weighted_tail_quantile.hpp
d7481f83f3ab16fbc0db30424d505e6031882043
[ "BSL-1.0" ]
permissive
RickyJun/live_plugin
de6fb4fa8ef9f76fffd51e2e51262fb63cea44cb
e4472570eac0d9f388ccac6ee513935488d9577e
refs/heads/master
2023-05-08T01:49:52.951207
2021-05-30T14:09:38
2021-05-30T14:09:38
345,919,594
2
0
null
null
null
null
UTF-8
C++
false
false
4,804
hpp
weighted_tail_quantile.hpp
/////////////////////////////////////////////////////////////////////////////// // weighted_tail_quantile.hpp // // Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_QUANTILE_HPP_DE_01_01_2006 #define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_QUANTILE_HPP_DE_01_01_2006 #include <vector> #include <limits> #include <functional> #include <sstream> #include <stdexcept> #include "throw_exception.hpp" #include "keyword.hpp" #include "placeholders.hpp" #include "if.hpp" #include "is_same.hpp" #include "functional.hpp" #include "depends_on.hpp" #include "accumulator_base.hpp" #include "extractor.hpp" #include "sample.hpp" #include "statistics_fwd.hpp" #include "tail.hpp" #include "tail_quantile.hpp" #include "quantile_probability.hpp" #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable: 4127) // conditional expression is constant #endif namespace boost { namespace accumulators { namespace impl { /////////////////////////////////////////////////////////////////////////////// // weighted_tail_quantile_impl // Tail quantile estimation based on order statistics of weighted samples /** @brief Tail quantile estimation based on order statistics of weighted samples (for both left and right tails) An estimator \f$\hat{q}\f$ of tail quantiles with level \f$\alpha\f$ based on order statistics \f$X_{1:n} \leq X_{2:n} \leq\dots\leq X_{n:n}\f$ of weighted samples are given by \f$X_{\lambda:n}\f$ (left tail) and \f$X_{\rho:n}\f$ (right tail), where \f[ \lambda = \inf\left\{ l \left| \frac{1}{\bar{w}_n}\sum_{i=1}^{l} w_i \geq \alpha \right. \right\} \f] and \f[ \rho = \sup\left\{ r \left| \frac{1}{\bar{w}_n}\sum_{i=r}^{n} w_i \geq (1 - \alpha) \right. \right\}, \f] \f$n\f$ being the number of samples and \f$\bar{w}_n\f$ the sum of all weights. @param quantile_probability */ template<typename Sample, typename Weight, typename LeftRight> struct weighted_tail_quantile_impl : accumulator_base { typedef typename numeric::functional::average<Weight, std::size_t>::result_type float_type; // for boost::result_of typedef Sample result_type; weighted_tail_quantile_impl(dont_care) {} template<typename Args> result_type result(Args const &args) const { float_type threshold = sum_of_weights(args) * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); std::size_t n = 0; Weight sum = Weight(0); while (sum < threshold) { if (n < static_cast<std::size_t>(tail_weights(args).size())) { sum += *(tail_weights(args).begin() + n); n++; } else { if (std::numeric_limits<result_type>::has_quiet_NaN) { return std::numeric_limits<result_type>::quiet_NaN(); } else { std::ostringstream msg; msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; boost::throw_exception(std::runtime_error(msg.str())); return Sample(0); } } } // Note that the cached samples of the left are sorted in ascending order, // whereas the samples of the right tail are sorted in descending order return *(boost::begin(tail(args)) + n - 1); } }; } // namespace impl /////////////////////////////////////////////////////////////////////////////// // tag::weighted_tail_quantile<> // namespace tag { template<typename LeftRight> struct weighted_tail_quantile : depends_on<sum_of_weights, tail_weights<LeftRight> > { /// INTERNAL ONLY typedef accumulators::impl::weighted_tail_quantile_impl<mpl::_1, mpl::_2, LeftRight> impl; }; } /////////////////////////////////////////////////////////////////////////////// // extract::weighted_tail_quantile // namespace extract { extractor<tag::quantile> const weighted_tail_quantile = {}; BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_tail_quantile) } using extract::weighted_tail_quantile; }} // namespace boost::accumulators #ifdef _MSC_VER # pragma warning(pop) #endif #endif
6e7e12f55b78a8d44efc9d881017dbbf17893ff7
26f6f9a290182e1ffa8f8554b2f9f498b17004f0
/LeetCode/0022.generate-parentheses/generate-parentheses.cpp
5dbbc618971021e863c759d9521e5486a148ea56
[]
no_license
ZhaoxiZhang/Algorithm
bb2d0f4a439def86de86de15f5cb91326e157fe0
6f09e662f4908f6198830ef1e11a20846ff3cacb
refs/heads/master
2021-01-01T19:42:02.668004
2019-09-07T14:55:14
2019-09-14T08:08:39
98,655,367
13
6
null
null
null
null
UTF-8
C++
false
false
1,103
cpp
generate-parentheses.cpp
class Solution { public: vector<string> generateParenthesis(int n) { vector<string>res; string str; generate(res, str, n, n, 2 * n); for (auto val : res) cout << val << endl; return res; } void generate(vector<string> &res, string str, int left, int right, int size){ if (str.size() == size){ if (valid(str, true)){ //cout << str << endl; res.push_back(str); } }else{ if (left > 0 && valid(str + '(', false)){ generate(res, str + "(", left - 1, right, size); } if (right > 0 && valid(str + ')', false)){ generate(res, str + ")", left, right - 1, size); } } } bool valid(string str, bool final){ int size = str.size(); int left = 0; for (int i = 0; i < size; i++){ if (str[i] == '(') left++; if (str[i] == ')') left--; if (left < 0) return false; } return final ? left == 0 : true;; } };
3724eee2afe18abfef660454bd5321c1f8370235
38efa38f256860e7a6e178bd32de7d169af0efe4
/Tests/VectorCopyBenchmark.cpp
5c3082e44f5a1588566181d424dd44856a33ee87
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
dmitriano/Awl
6231b654a6320b8707d340d30287bda5f1415339
2fff3dd60ca58b1f8e760ca3ee48e7bd46a2693d
refs/heads/master
2023-08-25T06:38:16.267534
2023-04-17T11:37:15
2023-04-17T11:37:15
72,160,204
6
1
null
null
null
null
UTF-8
C++
false
false
10,956
cpp
VectorCopyBenchmark.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Product: AWL (A Working Library) // Author: Dmitriano ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <iomanip> #include <vector> #include <memory> #include <future> #include <ranges> #include <span> #include <numeric> #include "Awl/StopWatch.h" #include "Awl/IntRange.h" #include "Awl/Testing/UnitTest.h" #include "Helpers/BenchmarkHelpers.h" using namespace awl::testing; namespace { struct ElementStruct { int i; double x; long double y; }; class ElementClass { public: ElementClass() : i(0), x(12.0), y(77.0) { } ElementClass(int val) : i(val), x(val * 12.0), y(val * 77.0) { } double ToReal() const { return static_cast<double>(i + x + y); } private: int i; double x; long double y; }; template <class T> void FromInt(T & val, int i) { val = static_cast<T>(i); } template <> void FromInt(ElementStruct & val, int i) { val.i = i; val.x = i * 10.0; val.y = i * 10.0; } template <class T> double ToReal(const T& val) { return static_cast<double>(val); } template <> double ToReal(const ElementStruct& val) { return static_cast<double>(val.i + val.x + val.y); } template <> double ToReal(const ElementClass& val) { return val.ToReal(); } template <class T> struct CopyVector { void operator()(const TestContext& context, const awl::Char* type_name) { AWT_ATTRIBUTE(size_t, vector_size, 1000000); AWT_ATTRIBUTE(size_t, iteration_count, 1); std::unique_ptr<T[]> p_buffer(new T[vector_size]); for (auto i : awl::make_count(static_cast<int>(vector_size))) { FromInt(p_buffer[i], i); } std::vector<T> v; v.reserve(vector_size); AWT_ASSERT_EQUAL(vector_size, v.capacity()); context.out << _T("std::vector<") << type_name << _T(">\t"); double ratio; { awl::StopWatch w; for (auto i : awl::make_count(iteration_count)) { static_cast<void>(i); std::copy(p_buffer.get(), p_buffer.get() + vector_size, std::back_inserter(v)); //Ensure the vector was not resized. AWT_ASSERT_EQUAL(vector_size, v.capacity()); AWT_ASSERT_EQUAL(vector_size, v.size()); v.resize(0); } context.out << _T("copy: "); ratio = helpers::ReportSpeed(context, w, vector_size * iteration_count * sizeof(T)); } { awl::StopWatch w; for (auto i : awl::make_count(iteration_count)) { static_cast<void>(i); v.insert(v.end(), p_buffer.get(), p_buffer.get() + vector_size); //Ensure the vector was not resized. AWT_ASSERT_EQUAL(vector_size, v.capacity()); AWT_ASSERT_EQUAL(vector_size, v.size()); v.resize(0); } context.out << _T("\tinsert: "); ratio = helpers::ReportSpeed(context, w, vector_size * iteration_count * sizeof(T)) / ratio; } context.out << _T("\t (") << ratio << _T(")"); context.out << _T("\tsizeof(") << type_name << _T("): ") << sizeof(T) << _T("\t") << std::endl; } }; template <class T> struct CopyVectorAsync { void operator()(const TestContext& context, const awl::Char* type_name) { AWT_ATTRIBUTE(size_t, vector_size, 1000000); AWT_ATTRIBUTE(size_t, iteration_count, 1); context.out << _T("std::vector<") << type_name << _T(">\t"); std::unique_ptr<T[]> p_buffer; std::vector<T> v; try { p_buffer = std::make_unique<T[]>(vector_size); v.resize(vector_size); } catch (const std::bad_alloc&) { context.out << "Too long vector. Can't allocate memory." << std::endl; return; } for (auto i : awl::make_count(static_cast<int>(vector_size))) { FromInt(p_buffer[i], i); } AWT_ASSERT_EQUAL(vector_size, v.size()); auto copy = [&](size_t begin, size_t end) { for (auto i : awl::make_count(iteration_count)) { static_cast<void>(i); std::copy(p_buffer.get() + begin, p_buffer.get() + end, v.begin() + begin); } }; double ratio; { awl::StopWatch w; std::vector<std::future<void>> futures; const size_t thread_count = std::thread::hardware_concurrency(); const size_t chunk_size = vector_size / thread_count; for (size_t i = 0; i < thread_count; ++i) { const size_t begin = i * chunk_size; const size_t end = begin + chunk_size; futures.push_back(std::async(std::launch::async, copy, begin, end)); } futures.push_back(std::async(std::launch::async, copy, chunk_size * thread_count, vector_size)); std::for_each(futures.begin(), futures.end(), [](std::future<void>& f) { f.get(); }); context.out << _T("async: "); ratio = helpers::ReportSpeed(context, w, vector_size * iteration_count * sizeof(T)); } { awl::StopWatch w; copy(0, vector_size); context.out << _T("\tsync: "); ratio = helpers::ReportSpeed(context, w, vector_size * iteration_count * sizeof(T)) / ratio; } context.out << _T("\t (") << ratio << _T(")"); context.out << _T("\tsizeof(") << type_name << _T("): ") << sizeof(T) << _T("\t") << std::endl; } }; template <class T> struct SumVector { void operator()(const TestContext& context, const awl::Char* type_name) { AWT_ATTRIBUTE(size_t, vector_size, 1000000); AWT_ATTRIBUTE(size_t, iteration_count, 1); AWT_ATTRIBUTE(size_t, thread_count, std::thread::hardware_concurrency()); AWT_FLAG(show_result); context.out << _T("std::vector<") << type_name << _T(">\t"); std::unique_ptr<T[]> p_buffer; try { p_buffer = std::make_unique<T[]>(vector_size); } catch (const std::bad_alloc&) { context.out << "Too long vector. Can't allocate memory." << std::endl; return; } for (auto i : awl::make_count(static_cast<int>(vector_size))) { FromInt(p_buffer[i], i); } auto sum = [&](size_t begin, size_t end) -> double { double result = 0.0; for (auto i : awl::make_count(iteration_count)) { static_cast<void>(i); std::span<T> span(p_buffer.get() + begin, p_buffer.get() + end); auto range = span | std::views::transform([](const T& val) -> double { return ToReal(val); }); result += std::accumulate(range.begin(), range.end(), 0.0); } return result; }; double ratio; { awl::StopWatch w; std::vector<std::future<double>> futures; const size_t chunk_size = vector_size / thread_count; for (size_t i = 0; i < thread_count; ++i) { const size_t begin = i * chunk_size; const size_t end = begin + chunk_size; futures.push_back(std::async(std::launch::async, sum, begin, end)); } futures.push_back(std::async(std::launch::async, sum, chunk_size * thread_count, vector_size)); auto range = futures | std::views::transform([](std::future<double>& f) -> double { return f.get(); }); const double result = std::accumulate(range.begin(), range.end(), 0.0); context.out << _T("\tasync: "); if (show_result) { context.out << _T("\tresult=" << result << ", "); } ratio = helpers::ReportSpeed(context, w, vector_size * iteration_count * sizeof(T)); } { awl::StopWatch w; const double result = sum(0, vector_size); context.out << _T("\tsync: "); if (show_result) { context.out << _T("\tresult=" << result << ", "); } ratio = helpers::ReportSpeed(context, w, vector_size * iteration_count * sizeof(T)) / ratio; } context.out << _T("\t (") << ratio << _T(")"); context.out << _T("\tsizeof(") << type_name << _T("): ") << sizeof(T) << _T("\t") << std::endl; } }; template <template <class> class copy> void CopyVectors(const TestContext& context) { copy<uint8_t>{}(context, _T("byte")); copy<short>{}(context, _T("short")); copy<int>{}(context, _T("int")); copy<long>{}(context, _T("long")); copy<long long>{}(context, _T("long long")); copy<float>{}(context, _T("float")); copy<double>{}(context, _T("double")); copy<long double>{}(context, _T("long double")); copy<long long>{}(context, _T("long long")); copy<ElementStruct>{}(context, _T("struct")); copy<ElementClass>{}(context, _T("class")); } } AWT_BENCHMARK(VectorCopy) { CopyVectors<CopyVector>(context); } AWT_BENCHMARK(VectorCopyAsync) { context.out << _T("hardware concurrency: ") << std::thread::hardware_concurrency() << std::endl; CopyVectors<CopyVectorAsync>(context); } AWT_BENCHMARK(VectorSum) { context.out << _T("hardware concurrency: ") << std::thread::hardware_concurrency() << std::endl; CopyVectors<SumVector>(context); }
85b4bbf32ffaa8cbbf439d030f698f791bd5b321
df7bda815b74bd40df4324c562336aa0742ba5ec
/include/utils.hpp
cc43a1b991040839506155c641f1d3a9e2feb212
[]
no_license
Phil25/boomer_bot
844647d3f698dee31aec031d6290fe6c4313e34d
4d1a567f36bfbd17f2ca9bdcf2b540773dd46988
refs/heads/master
2020-12-03T18:20:18.538873
2020-01-02T17:26:50
2020-01-02T17:26:50
231,427,700
0
0
null
2020-01-02T17:22:04
2020-01-02T17:22:04
null
UTF-8
C++
false
false
2,339
hpp
utils.hpp
#ifndef DUMB_REMINDER_BOT_UTILS_HPP #define DUMB_REMINDER_BOT_UTILS_HPP #include "types.hpp" #include <nlohmann/json.hpp> #include <cpr/cpr.h> #include <iostream> #include <fstream> namespace bot::util { inline static const std::string user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"; inline std::string get_api_url() { return "https://discordapp.com/api/v6"; } inline std::string get_ws_url(const std::string& token) { auto json = nlohmann::json::parse(cpr::Get( cpr::Url{ get_api_url() + "/gateway/bot" }, cpr::Header{ { "Authorization", "Bot " + token }, { "User-Agent", user_agent } }).text); std::cout << json << "\n"; try { return json["url"].get<std::string>(); } catch (...) { std::cout << "Error, invalid token.\n\n"; std::abort(); } } inline std::string get_identify_packet(const std::string& token) { return nlohmann::json{ { "op", 2 }, { "d", { { "token", token }, { "properties", { { "$os", "linux" }, { "$browser", "chrome" }, { "$device", "daknigs_bot" } } } } } }.dump(); } inline auto split(const std::string& s, const std::string& delimiter) { size_t pos_start = 0, pos_end, delim_len = delimiter.length(); std::vector<std::string> res; while ((pos_end = s.find(delimiter, pos_start)) != std::string::npos) { auto token = s.substr(pos_start, pos_end - pos_start); pos_start = pos_end + delim_len; res.emplace_back(token); } res.emplace_back(s.substr(pos_start)); return res; } inline void deserialize(std::vector<std::pair<std::string, types::snowflake>>& v) { std::ifstream in("../daily_reminder.txt"); std::string str; while (std::getline(in, str)) { auto item = split(str, ","); v.emplace_back(item[0], item[1]); } in.close(); } inline void serialize(const std::vector<std::pair<std::string, types::snowflake>>& v) { std::ofstream out("../daily_reminder.txt", std::ios::out | std::ios::trunc); for (const auto& [username, id] : v) { out << username << ',' << id << "\n"; } out.close(); } template <typename Ty> inline Ty get_from_json(const nlohmann::json& j, const char* key) { if (j.contains(key)) { return j[key].get<Ty>(); } return Ty{}; } } #endif //DUMB_REMINDER_BOT_UTILS_HPP
859240a0f61af10e903f5898add055d3e6552de4
d84508e288d340160fd26890497622c87a49a23f
/motor/position_control/motor_pins.ino
da1afe8d37f19cab944076bc55f9533ce0601f75
[]
no_license
kevin-roark/dartbot
9dd88081a13c9ee5ee959f9ad92ec35f11b70e11
f3815ac2bade6398dc486fe93a60845da5564afd
refs/heads/master
2021-01-21T07:48:01.126848
2015-05-10T15:55:38
2015-05-10T15:55:38
31,699,097
2
0
null
null
null
null
UTF-8
C++
false
false
1,659
ino
motor_pins.ino
// pin configuration #define motor1Enable_pin 2 // enable - turn on to go home -- green #define motor1Position_pin 3 // input a - low to go to position 1, high to go to position 2 -- white #define motor1Homing_pin 4 // input b - make HIGH to set home position -- purple #define motor2Enable_pin 5 // purple #define motor2Position_pin 6 // green #define motor2Homing_pin 7 // black /// API void setupMotorPins() { pinMode(motor1Homing_pin, OUTPUT); pinMode(motor1Enable_pin, OUTPUT); pinMode(motor1Position_pin, OUTPUT); pinMode(motor2Homing_pin, OUTPUT); pinMode(motor2Enable_pin, OUTPUT); pinMode(motor2Position_pin, OUTPUT); setEnabled(1, LOW); setEnabled(2, LOW); writePositionPins(LOW); writeHomingPins(LOW); } void writePositionPin(int motor, int value) { int pin = motor == 1 ? motor1Position_pin : motor2Position_pin; digitalWrite(pin, value); } void writePositionPins(int value) { digitalWrite(motor1Position_pin, value); digitalWrite(motor2Position_pin, value); } void writeHomingPins(int value) { digitalWrite(motor1Homing_pin, value); digitalWrite(motor2Homing_pin, value); } void setMotorPinHome(int motor, int value) { int pin = motor == 1 ? motor1Homing_pin : motor2Homing_pin; digitalWrite(pin, value); } void setEnabled(int motor, bool on) { int pin = -1; if (motor == 1) { pin = motor1Enable_pin; motor_1_enabled = on; Serial.print("MOTOR 1 "); } else if (motor == 2) { pin = motor2Enable_pin; motor_2_enabled = on; Serial.print("MOTOR 2 "); } if (pin < 0) { return; } digitalWrite(pin, on); Serial.print("SET ENABLED: "); printPinState(on); }
61f492d3a9ae857f64d37b0c92521556c1d9f315
3c3202165332fbbf8d8e4ed0b72c8a4c46481cdc
/SdlAnimatedSprite.h
2e97b51237c2beb650252484e95e23392e6c0ba7
[]
no_license
asdlei99/sdl-playground
1435e0dc5eb62bb74baf59780247a765f3900114
16067d84b886c1e84a34622dfb41c3ca32d39ae2
refs/heads/master
2020-09-15T02:33:07.754416
2017-12-28T06:14:48
2017-12-28T06:14:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
901
h
SdlAnimatedSprite.h
// // Created by victor on 12/24/17. // #ifndef SDL_PROY_SDLANIMATEDSPRITE_H #define SDL_PROY_SDLANIMATEDSPRITE_H #include <utility> #include <vector> #include <map> #include "SdlTexture.h" #include "SdlException.h" class SdlAnimatedSprite: public SdlTexture{ public: SdlAnimatedSprite(); ~SdlAnimatedSprite() override; void setFrames(const std::string &animation, std::vector<SdlRect> frs); void update() override; void render() override; SdlVector2 center() const; int getWidth() const override; int getHeight() const override; void selectAnimation(const std::string& name); private: std::map<std::string, std::vector<SdlRect>> animations; std::string current_animation; std::vector<SdlRect> frames; std::vector<SdlRect>::iterator current_frame; float scale; public: float getScale() const; void setScale(float scale); }; #endif //SDL_PROY_SDLANIMATEDSPRITE_H
32ec2e4faa431f61428bbad2bae281186a0e19b3
dd6147bf9433298a64bbceb7fdccaa4cc477fba6
/8382/Rocheva_Anna/lab5/loggers/Adapter.cpp
1d3a1697201b6281e343843cece8c1a49fb5c7a4
[]
no_license
moevm/oop
64a89677879341a3e8e91ba6d719ab598dcabb49
faffa7e14003b13c658ccf8853d6189b51ee30e6
refs/heads/master
2023-03-16T15:48:35.226647
2020-06-08T16:16:31
2020-06-08T16:16:31
85,785,460
42
304
null
2023-03-06T23:46:08
2017-03-22T04:37:01
C++
UTF-8
C++
false
false
423
cpp
Adapter.cpp
#include "Adapter.hpp" void Adapter::setLog(std::string logString) { if (!logger) return; logger->setLog(logString); std::string log = "\nField status:\nCells without units: " + std::to_string(field->getHeight()*field->getWidth() - field->getNumUnits()) + "\n"; logger->addLog(log); } void Adapter::addLog(std::string logString) { if (!logger) return; logger->addLog(logString); }
e94c5325977c6cb00714fd52648e343384a3af7d
af5f60eaa6f88161902f38945f3c03bab695e1b8
/asst1/easybj.h
2ee1c157385da4a18842932474147805812d12c5
[]
no_license
pbugash/EasyBlackjack
6e067e7a61ddc7eb38dcaceb7cc08c6d4c84b127
2b3f56dec817855516df17339b5268371a9f18a1
refs/heads/master
2022-06-23T13:06:59.577250
2022-03-24T02:45:13
2022-03-24T02:45:13
219,583,236
0
0
null
null
null
null
UTF-8
C++
false
false
7,464
h
easybj.h
/* * easybj.h * * Header files for Easy Blackjack. * * Note: change this file to implement Blackjack * * University of Toronto * Fall 2019 */ #ifndef EASYBJ_H #define EASYBJ_H #include <string> #include <iostream> #include <vector> #include <sstream> using namespace std; class Player; class Shoe; class Config; class Hand; class Hand { // the cards in THIS hand vector<char> cards; // total value of the hand int value = 0; // are there any aces in current hand bool ace = false; // bool for soft ace (11) vs hard ace (1)) bool soft = false; // is this the player's hand? bool playerHand = true; // is this hand DOUBLED? bool doubled = false; // is this hand SURRENDERED? bool surrender = false; // is the hand busted? bool bust = false; //is it the first turn of the hand bool firstTurn = false; //Move to be done on the hand (int because of ascii characters for switch case) int move; public: // constructor Hand() {} ~Hand() {} //friend class Blackjack; // calculate the total value // convert face cards into 10 // figure out when it's best to have a soft ace (11) vs hard ace (1) int calculate() { //reset flags before calculating ace = false; soft = false; value = 0; int numAces = 0; // check to see if cards vector is empty or not if (cards.empty()) { return value = 0; } // go through the cards // if there's an Ace, set ace flag to True // skip Ace (for now), continue adding all other values //check if it's a face or a ten for (unsigned i = 0; i < cards.size(); i++) { if (cards[i] == 'T' || cards[i] == 'J' || cards[i] == 'Q' \ || cards[i] == 'K') { value += 10; } else if (cards[i] == 'A') { ace = true; numAces ++; } else { //convert 2 to 9 chars to their int values value += cards[i] - 48; } } //if there were Aces, determine if they should be 11 or 1 if (ace) { // cannot have more than one Ace that equals 11 (will bust otherwise)) while (numAces > 1) { value += 1; numAces--; } // aim for high Ace if it doesn't bust the hand if (numAces == 1 && value + 11 <= 21) { value += 11; soft = true; } else value += 1; } //if the card value is greater than 21, then it is busted if (value > 21) bust = true; return value; } bool isEmpty() const { if (cards.empty()) return true; else return false; } // is there an Ace in this hand bool isAce() const { return ace; } // is this a soft or hard hand bool isSoft() const { return soft; } //if this is the dealer's hand, set playerHand to false void setDealerHand() { playerHand = false; } // is this hand one of the player's bool isPlayer() const { return playerHand; } // if hand is DOUBLED, set double to true void setDouble() { doubled = true; } // is this hand's bet been doubled bool isDouble() const { return doubled; } // if hand is SURRENDERED, set surrender to true void setSurrender() { surrender = true; } // if this hand surrendered? bool isSurrender() const { return surrender; } int getValue() const { return value; } void setBust() { bust = true; } // if this hand surrendered? bool isBust() const { return bust; } // set the move void setMove(char c) { move = c; } // get the move that is to be done char getMove() const { return move; } // get the cards vector<char> getCards() const { return cards; } void setCards(char c) { cards.push_back(c); } void deleteCard() { cards.erase(cards.end() - 1); } //Change so that it is not the first turn of the game void setFirstTurn() { if (firstTurn) firstTurn = false; else firstTurn = true; } // is it the first turn of the game? bool isFirstTurn() const { return firstTurn; } // void hit() { // this->cards.push_back(shoe->pop()); // } //output only the cards in the hand friend std::ostream & operator<<(std::ostream & ostr, const Hand & hand) { (void) hand; for (unsigned i = 0; i < hand.getCards().size(); ++i) { ostr << hand.getCards()[i] << " "; } //print out the total of the hand // first check if total is a bust or not if (hand.getValue() > 21) { ostr << "(bust)"; } //Case is if there is a blackjack on the first turn else if (hand.isFirstTurn() && hand.getValue() == 21) { ostr << "(blackjack)"; } else { ostr << "("; //check if ace if (hand.isAce()) { if (hand.isSoft()) { ostr << "soft "; } // else { // ostr << "hard "; // } } ostr << hand.getValue() << ")"; } // if hand has been doubled if (hand.isDouble()) { ostr << " DOUBLE\n"; } else if (hand.isSurrender()) { ostr << " SURRENDER\n"; } else { ostr << "\n"; } return ostr; } }; class Blackjack { Player * player; Shoe * shoe; Hand dealerHand; vector<Hand> userHands; int currentHandId = 0; int numHands = 1; double profit = 0; //bool firstTurn = true; public: Blackjack(Player * p, Shoe * s); ~Blackjack(); friend class Hand; /* * Start a game of Blackjack * * Returns first hand to be played, nullptr if either dealer or player's * initial hand is blackjack (or both) */ Hand * start(); /* * Returns dealer's hand */ const Hand * dealer_hand() const { return &dealerHand; } /* * Returns next hand to be played (may be the same hand) */ Hand * next(); /* * Call once next() returns nullptr */ void finish(); void setFirst(); bool isFirst(); void hit(Hand &hand); friend std::ostream & operator<<(std::ostream &, const Blackjack &); // TODO: you may add more functions as appropriate }; /* * Returns string representation of currency for v */ std::string to_currency(double v); #endif
e35fa3ebf3c420f947c2d8b00976dc2a7d24ce83
252f4523cd15409113fe89b7472fe9a4e6931e98
/Sources/Radio&Motor/ServerB1/ServerB1.ino
5267ca7064fbbb1419425887d2d0b07f9fd141bc
[]
no_license
TNUA-NMA-Graduate2018/logoutTaipei_part5
7bc9b65266f5f5ec91c2751aa02017e56e163d05
55fd6a4ed1568836b725bcff7e34cf12b6e4e5fa
refs/heads/master
2021-09-14T02:04:18.634720
2018-05-07T12:53:48
2018-05-07T12:53:48
116,146,164
0
0
null
2018-01-05T08:16:59
2018-01-03T14:29:52
Max
UTF-8
C++
false
false
3,958
ino
ServerB1.ino
#include <SPI.h> #include "RF24.h" #include <Servo.h> #include <Wire.h> #include <SoftwareSerial.h> boolean inputString = 1; boolean stringComplete = false; //SoftwareSerial mySerial(6, 5); // RX, TX Servo myservo; int Mode = 1; //輪椅模式 int ModeChanged = 1; //輪椅模式確認 1互控 //0自控 1互控 const int servoPin = 8; // the digital pin used for the servo RF24 rf24(9, 10); // CE腳, CSN腳 const byte addr[] = "1Node"; const int readSlider1 = A0; const int readSlider2 = A1; int ToOtherRight = 140; int ToOtherLeft = 140; void setup() { Serial.begin(115200); //mySerial.begin(57600); rf24.begin(); rf24.setChannel(83); // 設定頻道編號 rf24.openWritingPipe(addr); // 設定通道位址 rf24.setPALevel(RF24_PA_MAX); // 設定廣播功率 rf24.setDataRate(RF24_1MBPS); // 設定傳輸速率 rf24.stopListening(); // 停止偵聽;設定成發射模式 // pinMode(readSlider1, INPUT); pinMode(readSlider2, INPUT); pinMode(A3, INPUT); //調整輪椅模式 // // myservo.attach(servoPin); // attaches the servo on pin 9 to the servo object // myservo.write(nowDegree); delay(1000); } void loop() { //int readNum = 0; //mySerial.print("on"); //mySerialFunction(); /* if (readNum < 512) {//自控 ModeChanged = 0; } else if (readNum >= 512) { //互控 ModeChanged = 1; } */ //ModeChanged = inputString; // Serial.println(ModeChanged); // if (Mode == 0 && ModeChanged == 1) { // SendControlChange(ModeChanged); // Mode = 1; // } // if (Mode == 1 && ModeChanged == 0) { // SendControlChange(ModeChanged); // Mode = 0; // } if (Mode == 1) { ToOtherRight = slider(readSlider1); ToOtherLeft = slider(readSlider2); Serial.print("Left:\t"); Serial.print(ToOtherLeft); Serial.print("\tRight:\t"); Serial.println(ToOtherLeft); SendClient(ToOtherLeft, ToOtherRight); } // motor(); delay(50); // detectDegree(); } /* void mySerialFunction() { //Serial.println("Hi"); while (mySerial.available()) { Serial.println("here"); inputString = mySerial.read(); Serial.println(inputString); // add it to the inputString: } } */ void SendControlChange(int control) { char msg[16] = "0"; if (control == 0) { msg[0] = 'A'; } else { msg[0] = 'B'; } rf24.write(&msg, sizeof(msg)); // 傳送資料 //Serial.println(msg); delay(50); } void SendClient(int sendToOtherL, int sendToOtherR) { char msgTempA[16] = "0"; char msgTempB[16] = "0"; char msg[16] = "0"; int set = sendToOtherL; // FirstData int flag = 0, flagB = 0; if (set == 0)msgTempA[flag++] = '0'; while (set > 0) { msgTempA[flag] = char(set % 10) + '0'; set = set / 10; flag++; } for (int s = 0; s < flag; s++) { msg[s] = msgTempA[flag - s - 1]; } msg[flag++] = ' '; set = sendToOtherR; // SecondData flagB = 0; if (set == 0)msgTempA[flagB] = '0'; while (set > 0) { msgTempB[flagB] = char(set % 10) + '0'; set = set / 10; flagB++; } for (int s = 0; s < flagB; s++) { msg[s + flag] = msgTempB[flagB - s - 1]; } msg[flag + flagB] = ';'; //Serial.println(msg); //Serial.println(output); //Serial.println(msg); rf24.write(&msg, sizeof(msg)); // 傳送資料 delay(50); } int slider(int slider) { int sli = analogRead(slider); int value = int(map(sli, 0, 1024, 0, 255)); //Serial.println(value); //delay(100); return value ; } /* void motor() { / myservo.write((int)nowDegree); // move the servo to 180, max speed, wait until done angle += 5; //可以控制去程的時間(加的數字越大 轉的時間越短) nowDegree = 110 + (20 * sin(radians(angle)));//*sin前的那個數字 控制轉速 //nowDegree += (easDegree - nowDegree) * easing; delay(50);//控制回程時間,delay越短 轉的時間越短 甚至不回轉 但時間加長去程的時間也會加長 } */
97f156f3c7aa887afa2844f5cf5c466e98074d3c
e039afdf038bd09ba2c77db006e1ff937874c660
/common/task_queue.h
60b629241633289d7fac2d8cb357deb9f9921fa7
[ "BSD-3-Clause", "BSL-1.0", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
godmoves/HappyGo
f15e54321c887d1e7acc3d939d0c242a54221dbc
8c813d10315660626f18e3985bbcb87ea5c684a5
refs/heads/trt5
2021-06-26T11:55:09.515275
2019-03-10T09:27:18
2019-03-10T09:27:18
133,219,042
11
2
NOASSERTION
2019-03-10T09:27:19
2018-05-13T08:31:14
Python
UTF-8
C++
false
false
2,696
h
task_queue.h
/* * Tencent is pleased to support the open source community by making PhoenixGo * available. * * Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. * * Licensed under the BSD 3-Clause License (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://opensource.org/licenses/BSD-3-Clause * * 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. */ #pragma once #include <atomic> #include <chrono> #include <condition_variable> #include <deque> #include <mutex> template <class T> class TaskQueue { public: TaskQueue(int capacity = 0) : m_capacity(capacity), m_size(0), m_is_close(false) {} template <class U> void Push(U &&elem) { std::unique_lock<std::mutex> lock(m_mutex); if (m_capacity > 0) { m_push_cond.wait(lock, [this] { return m_queue.size() < m_capacity; }); } m_queue.push_back(std::forward<U>(elem)); m_size = m_queue.size(); lock.unlock(); m_pop_cond.notify_one(); } template <class U> void PushFront(U &&elem) { std::unique_lock<std::mutex> lock(m_mutex); m_queue.push_front(std::forward<U>(elem)); m_size = m_queue.size(); lock.unlock(); m_pop_cond.notify_one(); } bool Pop(T &elem, int64_t timeout_us = -1) { std::unique_lock<std::mutex> lock(m_mutex); if (timeout_us < 0) { m_pop_cond.wait(lock, [this] { return !m_queue.empty() || m_is_close; }); } else { if (!m_pop_cond.wait_for( lock, std::chrono::microseconds(timeout_us), [this] { return !m_queue.empty() || m_is_close; })) { return false; } } if (m_queue.empty()) { return false; } elem = std::move(m_queue.front()); m_queue.pop_front(); m_size = m_queue.size(); lock.unlock(); if (m_capacity > 0) { m_push_cond.notify_one(); } return true; } void Close() { { std::lock_guard<std::mutex> lock(m_mutex); m_is_close = true; } m_push_cond.notify_all(); m_pop_cond.notify_all(); } bool IsClose() const { return m_is_close; } int Size() const { return m_size; } private: std::deque<T> m_queue; int m_capacity; std::atomic<int> m_size; std::mutex m_mutex; std::condition_variable m_push_cond; std::condition_variable m_pop_cond; std::atomic<bool> m_is_close; };
e3ebe2a38fff263b50b57ef740047c071864362a
53c3c3ee9f51556f64375076a677ef892c6d3654
/fancy_core/Rendering/RenderPlatformObjectCache.h
d55ea8301089bebec51b8de53d2e1fecca561ba5
[]
no_license
domme/FANCY
75133d47bb6c349e8d6ce60cc7777fcd907a1bb2
f6451ead9a4758b16bee3f019e6fbff7487a5f70
refs/heads/master
2023-06-24T15:49:59.992434
2023-06-18T21:02:06
2023-06-18T21:02:06
7,263,701
29
1
null
null
null
null
UTF-8
C++
false
false
301
h
RenderPlatformObjectCache.h
#pragma once #include "EASTL/hash_map.h" namespace Fancy { template<class T> class RenderPlatformObjectCache { public: virtual ~RenderPlatformObjectCache() = default; virtual void Clear() = 0; protected: std::mutex myCacheMutex; eastl::hash_map<uint64, T> myCache; }; }
91e093f4604ead178018c5eb614be4fb885259bc
de5f745686f58902816385ba33937dc63f2cd53f
/js/spidermonkey-ios/include/jsval.h
d146d207e014b028d5ea1ee92ea72a16de9226bc
[ "MIT" ]
permissive
csdnnet/hiygame
cb70c41f46c00cf1c46b0158d7a1c7fbccb94973
4ffe66c7d17e3588bc54d30959079ea0f6f85714
refs/heads/master
2021-01-22T07:39:09.767963
2012-07-14T05:12:43
2012-07-14T05:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
27,956
h
jsval.h
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=4 sw=4 et tw=99 ft=cpp: * * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released * June 30, 2010 * * The Initial Developer of the Original Code is * the Mozilla Corporation. * * Contributor(s): * Luke Wagner <lw@mozilla.com> * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef jsvalimpl_h__ #define jsvalimpl_h__ /* * Implementation details for js::Value in jsapi.h. */ #include "js/Utility.h" JS_BEGIN_EXTERN_C /******************************************************************************/ /* To avoid a circular dependency, pull in the necessary pieces of jsnum.h. */ #define JSDOUBLE_SIGNBIT (((uint64_t) 1) << 63) #define JSDOUBLE_EXPMASK (((uint64_t) 0x7ff) << 52) #define JSDOUBLE_MANTMASK ((((uint64_t) 1) << 52) - 1) #define JSDOUBLE_HI32_SIGNBIT 0x80000000 static JS_ALWAYS_INLINE JSBool JSDOUBLE_IS_NEGZERO(double d) { union { struct { #if defined(IS_LITTLE_ENDIAN) && !defined(FPU_IS_ARM_FPA) uint32_t lo, hi; #else uint32_t hi, lo; #endif } s; double d; } x; if (d != 0) return JS_FALSE; x.d = d; return (x.s.hi & JSDOUBLE_HI32_SIGNBIT) != 0; } static JS_ALWAYS_INLINE JSBool JSDOUBLE_IS_INT32(double d, int32_t* pi) { if (JSDOUBLE_IS_NEGZERO(d)) return JS_FALSE; return d == (*pi = (int32_t)d); } /******************************************************************************/ /* * Try to get jsvals 64-bit aligned. We could almost assert that all values are * aligned, but MSVC and GCC occasionally break alignment. */ #if defined(__GNUC__) || defined(__xlc__) || defined(__xlC__) # define JSVAL_ALIGNMENT __attribute__((aligned (8))) #elif defined(_MSC_VER) /* * Structs can be aligned with MSVC, but not if they are used as parameters, * so we just don't try to align. */ # define JSVAL_ALIGNMENT #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) # define JSVAL_ALIGNMENT #elif defined(__HP_cc) || defined(__HP_aCC) # define JSVAL_ALIGNMENT #endif #if JS_BITS_PER_WORD == 64 # define JSVAL_TAG_SHIFT 47 #endif /* * We try to use enums so that printing a jsval_layout in the debugger shows * nice symbolic type tags, however we can only do this when we can force the * underlying type of the enum to be the desired size. */ #if defined(__cplusplus) && !defined(__SUNPRO_CC) && !defined(__xlC__) #if defined(_MSC_VER) # define JS_ENUM_HEADER(id, type) enum id : type # define JS_ENUM_MEMBER(id, type, value) id = (type)value, # define JS_LAST_ENUM_MEMBER(id, type, value) id = (type)value # define JS_ENUM_FOOTER(id) #else # define JS_ENUM_HEADER(id, type) enum id # define JS_ENUM_MEMBER(id, type, value) id = (type)value, # define JS_LAST_ENUM_MEMBER(id, type, value) id = (type)value # define JS_ENUM_FOOTER(id) __attribute__((packed)) #endif /* Remember to propagate changes to the C defines below. */ JS_ENUM_HEADER(JSValueType, uint8_t) { JSVAL_TYPE_DOUBLE = 0x00, JSVAL_TYPE_INT32 = 0x01, JSVAL_TYPE_UNDEFINED = 0x02, JSVAL_TYPE_BOOLEAN = 0x03, JSVAL_TYPE_MAGIC = 0x04, JSVAL_TYPE_STRING = 0x05, JSVAL_TYPE_NULL = 0x06, JSVAL_TYPE_OBJECT = 0x07, /* These never appear in a jsval; they are only provided as an out-of-band value. */ JSVAL_TYPE_UNKNOWN = 0x20, JSVAL_TYPE_MISSING = 0x21 } JS_ENUM_FOOTER(JSValueType); JS_STATIC_ASSERT(sizeof(JSValueType) == 1); #if JS_BITS_PER_WORD == 32 /* Remember to propagate changes to the C defines below. */ JS_ENUM_HEADER(JSValueTag, uint32_t) { JSVAL_TAG_CLEAR = 0xFFFFFF80, JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32, JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED, JSVAL_TAG_STRING = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING, JSVAL_TAG_BOOLEAN = JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN, JSVAL_TAG_MAGIC = JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC, JSVAL_TAG_NULL = JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL, JSVAL_TAG_OBJECT = JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT } JS_ENUM_FOOTER(JSValueTag); JS_STATIC_ASSERT(sizeof(JSValueTag) == 4); #elif JS_BITS_PER_WORD == 64 /* Remember to propagate changes to the C defines below. */ JS_ENUM_HEADER(JSValueTag, uint32_t) { JSVAL_TAG_MAX_DOUBLE = 0x1FFF0, JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32, JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED, JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING, JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN, JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC, JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL, JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT } JS_ENUM_FOOTER(JSValueTag); JS_STATIC_ASSERT(sizeof(JSValueTag) == sizeof(uint32_t)); JS_ENUM_HEADER(JSValueShiftedTag, uint64_t) { JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF), JSVAL_SHIFTED_TAG_INT32 = (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT), JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT), JSVAL_SHIFTED_TAG_STRING = (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT), JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT), JSVAL_SHIFTED_TAG_MAGIC = (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT), JSVAL_SHIFTED_TAG_NULL = (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT), JSVAL_SHIFTED_TAG_OBJECT = (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) } JS_ENUM_FOOTER(JSValueShiftedTag); JS_STATIC_ASSERT(sizeof(JSValueShiftedTag) == sizeof(uint64_t)); #endif #else /* defined(__cplusplus) */ typedef uint8_t JSValueType; #define JSVAL_TYPE_DOUBLE ((uint8_t)0x00) #define JSVAL_TYPE_INT32 ((uint8_t)0x01) #define JSVAL_TYPE_UNDEFINED ((uint8_t)0x02) #define JSVAL_TYPE_BOOLEAN ((uint8_t)0x03) #define JSVAL_TYPE_MAGIC ((uint8_t)0x04) #define JSVAL_TYPE_STRING ((uint8_t)0x05) #define JSVAL_TYPE_NULL ((uint8_t)0x06) #define JSVAL_TYPE_OBJECT ((uint8_t)0x07) #define JSVAL_TYPE_UNKNOWN ((uint8_t)0x20) #if JS_BITS_PER_WORD == 32 typedef uint32_t JSValueTag; #define JSVAL_TAG_CLEAR ((uint32_t)(0xFFFFFF80)) #define JSVAL_TAG_INT32 ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32)) #define JSVAL_TAG_UNDEFINED ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED)) #define JSVAL_TAG_STRING ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING)) #define JSVAL_TAG_BOOLEAN ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN)) #define JSVAL_TAG_MAGIC ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC)) #define JSVAL_TAG_NULL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL)) #define JSVAL_TAG_OBJECT ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT)) #elif JS_BITS_PER_WORD == 64 typedef uint32_t JSValueTag; #define JSVAL_TAG_MAX_DOUBLE ((uint32_t)(0x1FFF0)) #define JSVAL_TAG_INT32 (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) #define JSVAL_TAG_UNDEFINED (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED) #define JSVAL_TAG_STRING (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING) #define JSVAL_TAG_BOOLEAN (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) #define JSVAL_TAG_MAGIC (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC) #define JSVAL_TAG_NULL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL) #define JSVAL_TAG_OBJECT (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT) typedef uint64_t JSValueShiftedTag; #define JSVAL_SHIFTED_TAG_MAX_DOUBLE ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF) #define JSVAL_SHIFTED_TAG_INT32 (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT) #define JSVAL_SHIFTED_TAG_UNDEFINED (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT) #define JSVAL_SHIFTED_TAG_STRING (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT) #define JSVAL_SHIFTED_TAG_BOOLEAN (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT) #define JSVAL_SHIFTED_TAG_MAGIC (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT) #define JSVAL_SHIFTED_TAG_NULL (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT) #define JSVAL_SHIFTED_TAG_OBJECT (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) #endif /* JS_BITS_PER_WORD */ #endif /* defined(__cplusplus) && !defined(__SUNPRO_CC) */ #define JSVAL_LOWER_INCL_TYPE_OF_OBJ_OR_NULL_SET JSVAL_TYPE_NULL #define JSVAL_UPPER_EXCL_TYPE_OF_PRIMITIVE_SET JSVAL_TYPE_OBJECT #define JSVAL_UPPER_INCL_TYPE_OF_NUMBER_SET JSVAL_TYPE_INT32 #define JSVAL_LOWER_INCL_TYPE_OF_PTR_PAYLOAD_SET JSVAL_TYPE_MAGIC #if JS_BITS_PER_WORD == 32 #define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_CLEAR | (type))) #define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL #define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT #define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 #define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING #elif JS_BITS_PER_WORD == 64 #define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL #define JSVAL_TAG_MASK 0xFFFF800000000000LL #define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type))) #define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64_t)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT) #define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET JSVAL_SHIFTED_TAG_NULL #define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET JSVAL_SHIFTED_TAG_OBJECT #define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET JSVAL_SHIFTED_TAG_UNDEFINED #define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET JSVAL_SHIFTED_TAG_STRING #endif /* JS_BITS_PER_WORD */ typedef enum JSWhyMagic { JS_ARRAY_HOLE, /* a hole in a dense array */ JS_ARGS_HOLE, /* a hole in the args object's array */ JS_NATIVE_ENUMERATE, /* indicates that a custom enumerate hook forwarded * to JS_EnumerateState, which really means the object can be * enumerated like a native object. */ JS_NO_ITER_VALUE, /* there is not a pending iterator value */ JS_GENERATOR_CLOSING, /* exception value thrown when closing a generator */ JS_NO_CONSTANT, /* compiler sentinel value */ JS_THIS_POISON, /* used in debug builds to catch tracing errors */ JS_ARG_POISON, /* used in debug builds to catch tracing errors */ JS_SERIALIZE_NO_NODE, /* an empty subnode in the AST serializer */ JS_LAZY_ARGUMENTS, /* lazy arguments value on the stack */ JS_UNASSIGNED_ARGUMENTS, /* the initial value of callobj.arguments */ JS_IS_CONSTRUCTING, /* magic value passed to natives to indicate construction */ JS_GENERIC_MAGIC /* for local use */ } JSWhyMagic; #if defined(IS_LITTLE_ENDIAN) # if JS_BITS_PER_WORD == 32 typedef union jsval_layout { uint64_t asBits; struct { union { int32_t i32; uint32_t u32; JSBool boo; JSString *str; JSObject *obj; void *ptr; JSWhyMagic why; size_t word; } payload; JSValueTag tag; } s; double asDouble; void *asPtr; } JSVAL_ALIGNMENT jsval_layout; # elif JS_BITS_PER_WORD == 64 typedef union jsval_layout { uint64_t asBits; #if (!defined(_WIN64) && defined(__cplusplus)) /* MSVC does not pack these correctly :-( */ struct { uint64_t payload47 : 47; JSValueTag tag : 17; } debugView; #endif struct { union { int32_t i32; uint32_t u32; JSWhyMagic why; } payload; } s; double asDouble; void *asPtr; size_t asWord; } JSVAL_ALIGNMENT jsval_layout; # endif /* JS_BITS_PER_WORD */ #else /* defined(IS_LITTLE_ENDIAN) */ # if JS_BITS_PER_WORD == 32 typedef union jsval_layout { uint64_t asBits; struct { JSValueTag tag; union { int32_t i32; uint32_t u32; JSBool boo; JSString *str; JSObject *obj; void *ptr; JSWhyMagic why; size_t word; } payload; } s; double asDouble; void *asPtr; } JSVAL_ALIGNMENT jsval_layout; # elif JS_BITS_PER_WORD == 64 typedef union jsval_layout { uint64_t asBits; struct { JSValueTag tag : 17; uint64_t payload47 : 47; } debugView; struct { uint32_t padding; union { int32_t i32; uint32_t u32; JSWhyMagic why; } payload; } s; double asDouble; void *asPtr; size_t asWord; } JSVAL_ALIGNMENT jsval_layout; # endif /* JS_BITS_PER_WORD */ #endif /* defined(IS_LITTLE_ENDIAN) */ JS_STATIC_ASSERT(sizeof(jsval_layout) == 8); #if JS_BITS_PER_WORD == 32 /* * N.B. GCC, in some but not all cases, chooses to emit signed comparison of * JSValueTag even though its underlying type has been forced to be uint32_t. * Thus, all comparisons should explicitly cast operands to uint32_t. */ static JS_ALWAYS_INLINE jsval_layout BUILD_JSVAL(JSValueTag tag, uint32_t payload) { jsval_layout l; l.asBits = (((uint64_t)(uint32_t)tag) << 32) | payload; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_DOUBLE_IMPL(jsval_layout l) { return (uint32_t)l.s.tag <= (uint32_t)JSVAL_TAG_CLEAR; } static JS_ALWAYS_INLINE jsval_layout DOUBLE_TO_JSVAL_IMPL(double d) { jsval_layout l; l.asDouble = d; JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_INT32_IMPL(jsval_layout l) { return l.s.tag == JSVAL_TAG_INT32; } static JS_ALWAYS_INLINE int32_t JSVAL_TO_INT32_IMPL(jsval_layout l) { return l.s.payload.i32; } static JS_ALWAYS_INLINE jsval_layout INT32_TO_JSVAL_IMPL(int32_t i) { jsval_layout l; l.s.tag = JSVAL_TAG_INT32; l.s.payload.i32 = i; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_NUMBER_IMPL(jsval_layout l) { JSValueTag tag = l.s.tag; JS_ASSERT(tag != JSVAL_TAG_CLEAR); return (uint32_t)tag <= (uint32_t)JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_UNDEFINED_IMPL(jsval_layout l) { return l.s.tag == JSVAL_TAG_UNDEFINED; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_STRING_IMPL(jsval_layout l) { return l.s.tag == JSVAL_TAG_STRING; } static JS_ALWAYS_INLINE jsval_layout STRING_TO_JSVAL_IMPL(JSString *str) { jsval_layout l; JS_ASSERT(str); l.s.tag = JSVAL_TAG_STRING; l.s.payload.str = str; return l; } static JS_ALWAYS_INLINE JSString * JSVAL_TO_STRING_IMPL(jsval_layout l) { return l.s.payload.str; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_BOOLEAN_IMPL(jsval_layout l) { return l.s.tag == JSVAL_TAG_BOOLEAN; } static JS_ALWAYS_INLINE JSBool JSVAL_TO_BOOLEAN_IMPL(jsval_layout l) { return l.s.payload.boo; } static JS_ALWAYS_INLINE jsval_layout BOOLEAN_TO_JSVAL_IMPL(JSBool b) { jsval_layout l; JS_ASSERT(b == JS_TRUE || b == JS_FALSE); l.s.tag = JSVAL_TAG_BOOLEAN; l.s.payload.boo = b; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_MAGIC_IMPL(jsval_layout l) { return l.s.tag == JSVAL_TAG_MAGIC; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_OBJECT_IMPL(jsval_layout l) { return l.s.tag == JSVAL_TAG_OBJECT; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l) { return (uint32_t)l.s.tag < (uint32_t)JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_OBJECT_OR_NULL_IMPL(jsval_layout l) { JS_ASSERT((uint32_t)l.s.tag <= (uint32_t)JSVAL_TAG_OBJECT); return (uint32_t)l.s.tag >= (uint32_t)JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET; } static JS_ALWAYS_INLINE JSObject * JSVAL_TO_OBJECT_IMPL(jsval_layout l) { return l.s.payload.obj; } static JS_ALWAYS_INLINE jsval_layout OBJECT_TO_JSVAL_IMPL(JSObject *obj) { jsval_layout l; JS_ASSERT(obj); l.s.tag = JSVAL_TAG_OBJECT; l.s.payload.obj = obj; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_NULL_IMPL(jsval_layout l) { return l.s.tag == JSVAL_TAG_NULL; } static JS_ALWAYS_INLINE jsval_layout PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr) { jsval_layout l; JS_ASSERT(((uint32_t)ptr & 1) == 0); l.s.tag = (JSValueTag)0; l.s.payload.ptr = ptr; JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); return l; } static JS_ALWAYS_INLINE void * JSVAL_TO_PRIVATE_PTR_IMPL(jsval_layout l) { return l.s.payload.ptr; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_GCTHING_IMPL(jsval_layout l) { /* gcc sometimes generates signed < without explicit casts. */ return (uint32_t)l.s.tag >= (uint32_t)JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET; } static JS_ALWAYS_INLINE void * JSVAL_TO_GCTHING_IMPL(jsval_layout l) { return l.s.payload.ptr; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_TRACEABLE_IMPL(jsval_layout l) { return l.s.tag == JSVAL_TAG_STRING || l.s.tag == JSVAL_TAG_OBJECT; } static JS_ALWAYS_INLINE uint32_t JSVAL_TRACE_KIND_IMPL(jsval_layout l) { return (uint32_t)(JSBool)JSVAL_IS_STRING_IMPL(l); } static JS_ALWAYS_INLINE JSBool JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32_t i32) { return l.s.tag == JSVAL_TAG_INT32 && l.s.payload.i32 == i32; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, JSBool b) { return (l.s.tag == JSVAL_TAG_BOOLEAN) && (l.s.payload.boo == b); } static JS_ALWAYS_INLINE jsval_layout MAGIC_TO_JSVAL_IMPL(JSWhyMagic why) { jsval_layout l; l.s.tag = JSVAL_TAG_MAGIC; l.s.payload.why = why; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs) { JSValueTag ltag = lhs.s.tag, rtag = rhs.s.tag; return ltag == rtag || (ltag < JSVAL_TAG_CLEAR && rtag < JSVAL_TAG_CLEAR); } static JS_ALWAYS_INLINE jsval_layout PRIVATE_UINT32_TO_JSVAL_IMPL(uint32_t ui) { jsval_layout l; l.s.tag = (JSValueTag)0; l.s.payload.u32 = ui; JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); return l; } static JS_ALWAYS_INLINE uint32_t JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layout l) { return l.s.payload.u32; } static JS_ALWAYS_INLINE JSValueType JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l) { uint32_t type = l.s.tag & 0xF; JS_ASSERT(type > JSVAL_TYPE_DOUBLE); return (JSValueType)type; } #elif JS_BITS_PER_WORD == 64 static JS_ALWAYS_INLINE jsval_layout BUILD_JSVAL(JSValueTag tag, uint64_t payload) { jsval_layout l; l.asBits = (((uint64_t)(uint32_t)tag) << JSVAL_TAG_SHIFT) | payload; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_DOUBLE_IMPL(jsval_layout l) { return l.asBits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE; } static JS_ALWAYS_INLINE jsval_layout DOUBLE_TO_JSVAL_IMPL(double d) { jsval_layout l; l.asDouble = d; JS_ASSERT(l.asBits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE); return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_INT32_IMPL(jsval_layout l) { return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_INT32; } static JS_ALWAYS_INLINE int32_t JSVAL_TO_INT32_IMPL(jsval_layout l) { return (int32_t)l.asBits; } static JS_ALWAYS_INLINE jsval_layout INT32_TO_JSVAL_IMPL(int32_t i32) { jsval_layout l; l.asBits = ((uint64_t)(uint32_t)i32) | JSVAL_SHIFTED_TAG_INT32; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_NUMBER_IMPL(jsval_layout l) { return l.asBits < JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_UNDEFINED_IMPL(jsval_layout l) { return l.asBits == JSVAL_SHIFTED_TAG_UNDEFINED; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_STRING_IMPL(jsval_layout l) { return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_STRING; } static JS_ALWAYS_INLINE jsval_layout STRING_TO_JSVAL_IMPL(JSString *str) { jsval_layout l; uint64_t strBits = (uint64_t)str; JS_ASSERT(str); JS_ASSERT((strBits >> JSVAL_TAG_SHIFT) == 0); l.asBits = strBits | JSVAL_SHIFTED_TAG_STRING; return l; } static JS_ALWAYS_INLINE JSString * JSVAL_TO_STRING_IMPL(jsval_layout l) { return (JSString *)(l.asBits & JSVAL_PAYLOAD_MASK); } static JS_ALWAYS_INLINE JSBool JSVAL_IS_BOOLEAN_IMPL(jsval_layout l) { return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_BOOLEAN; } static JS_ALWAYS_INLINE JSBool JSVAL_TO_BOOLEAN_IMPL(jsval_layout l) { return (JSBool)l.asBits; } static JS_ALWAYS_INLINE jsval_layout BOOLEAN_TO_JSVAL_IMPL(JSBool b) { jsval_layout l; JS_ASSERT(b == JS_TRUE || b == JS_FALSE); l.asBits = ((uint64_t)(uint32_t)b) | JSVAL_SHIFTED_TAG_BOOLEAN; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_MAGIC_IMPL(jsval_layout l) { return (l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_MAGIC; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l) { return l.asBits < JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_OBJECT_IMPL(jsval_layout l) { JS_ASSERT((l.asBits >> JSVAL_TAG_SHIFT) <= JSVAL_SHIFTED_TAG_OBJECT); return l.asBits >= JSVAL_SHIFTED_TAG_OBJECT; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_OBJECT_OR_NULL_IMPL(jsval_layout l) { JS_ASSERT((l.asBits >> JSVAL_TAG_SHIFT) <= JSVAL_TAG_OBJECT); return l.asBits >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET; } static JS_ALWAYS_INLINE JSObject * JSVAL_TO_OBJECT_IMPL(jsval_layout l) { uint64_t ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; JS_ASSERT((ptrBits & 0x7) == 0); return (JSObject *)ptrBits; } static JS_ALWAYS_INLINE jsval_layout OBJECT_TO_JSVAL_IMPL(JSObject *obj) { jsval_layout l; uint64_t objBits = (uint64_t)obj; JS_ASSERT(obj); JS_ASSERT((objBits >> JSVAL_TAG_SHIFT) == 0); l.asBits = objBits | JSVAL_SHIFTED_TAG_OBJECT; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_NULL_IMPL(jsval_layout l) { return l.asBits == JSVAL_SHIFTED_TAG_NULL; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_GCTHING_IMPL(jsval_layout l) { return l.asBits >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET; } static JS_ALWAYS_INLINE void * JSVAL_TO_GCTHING_IMPL(jsval_layout l) { uint64_t ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; JS_ASSERT((ptrBits & 0x7) == 0); return (void *)ptrBits; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_TRACEABLE_IMPL(jsval_layout l) { return JSVAL_IS_GCTHING_IMPL(l) && !JSVAL_IS_NULL_IMPL(l); } static JS_ALWAYS_INLINE uint32_t JSVAL_TRACE_KIND_IMPL(jsval_layout l) { return (uint32_t)(JSBool)!(JSVAL_IS_OBJECT_IMPL(l)); } static JS_ALWAYS_INLINE jsval_layout PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr) { jsval_layout l; uint64_t ptrBits = (uint64_t)ptr; JS_ASSERT((ptrBits & 1) == 0); l.asBits = ptrBits >> 1; JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); return l; } static JS_ALWAYS_INLINE void * JSVAL_TO_PRIVATE_PTR_IMPL(jsval_layout l) { JS_ASSERT((l.asBits & 0x8000000000000000LL) == 0); return (void *)(l.asBits << 1); } static JS_ALWAYS_INLINE JSBool JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32_t i32) { return l.asBits == (((uint64_t)(uint32_t)i32) | JSVAL_SHIFTED_TAG_INT32); } static JS_ALWAYS_INLINE JSBool JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, JSBool b) { return l.asBits == (((uint64_t)(uint32_t)b) | JSVAL_SHIFTED_TAG_BOOLEAN); } static JS_ALWAYS_INLINE jsval_layout MAGIC_TO_JSVAL_IMPL(JSWhyMagic why) { jsval_layout l; l.asBits = ((uint64_t)(uint32_t)why) | JSVAL_SHIFTED_TAG_MAGIC; return l; } static JS_ALWAYS_INLINE JSBool JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs) { uint64_t lbits = lhs.asBits, rbits = rhs.asBits; return (lbits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE && rbits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE) || (((lbits ^ rbits) & 0xFFFF800000000000LL) == 0); } static JS_ALWAYS_INLINE jsval_layout PRIVATE_UINT32_TO_JSVAL_IMPL(uint32_t ui) { jsval_layout l; l.asBits = (uint64_t)ui; JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); return l; } static JS_ALWAYS_INLINE uint32_t JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layout l) { JS_ASSERT((l.asBits >> 32) == 0); return (uint32_t)l.asBits; } static JS_ALWAYS_INLINE JSValueType JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l) { uint64_t type = (l.asBits >> JSVAL_TAG_SHIFT) & 0xF; JS_ASSERT(type > JSVAL_TYPE_DOUBLE); return (JSValueType)type; } #endif /* JS_BITS_PER_WORD */ static JS_ALWAYS_INLINE double JS_CANONICALIZE_NAN(double d) { if (JS_UNLIKELY(d != d)) { jsval_layout l; l.asBits = 0x7FF8000000000000LL; return l.asDouble; } return d; } JS_END_EXTERN_C #ifdef __cplusplus static jsval_layout JSVAL_TO_IMPL(JS::Value); static JS::Value IMPL_TO_JSVAL(jsval_layout); #endif #endif /* jsvalimpl_h__ */
7b7c83f4e54702c3ce19a7ad6853f6defa4bfb59
8dde6b62ee37febc9dc0103d4f822ed1900991b3
/src/tree/Invocation.h
8fc0dbc5be5bdac6970f6941718504ca72791290
[]
no_license
mikhaylova-daria/Compiler
8523bb7457661868f4fec12a9bad31fa73c2f6f9
bde698a24b40dcf8e06781c8f461e09631e241d7
refs/heads/master
2020-12-24T06:51:30.483318
2016-05-25T13:36:56
2016-05-25T13:36:56
42,936,340
1
0
null
null
null
null
UTF-8
C++
false
false
1,663
h
Invocation.h
// // Created by nicolai on 20.10.15. // #ifndef MINIJAVACOMPILER_INVOCATION_H #define MINIJAVACOMPILER_INVOCATION_H #include "Expression.h" #include "Indentifier.h" // Arguments of function call class CExpressionList : public IToken { const std::string name = "CExpressionList"; public: CExpressionList(Location location, IExpression* expression, CExpressionList* expressionList) : IToken(location), Expression(expression), ExpressionList(expressionList) {} virtual ~CExpressionList() { delete Expression; delete ExpressionList; } void Accept(IVisitor* visitor) const { return visitor->Visit(this); } virtual const std::string& GetName() const { return name; } const IExpression* Expression; const CExpressionList* ExpressionList; }; //It's a dot. Rule Expression "." Identifier "(" ( Expression ( "," Expression )* )? class CInvocation : public IExpression { const std::string name = "CInvocation"; public: CInvocation(Location location, IExpression* expression, CIdentifier* identifier, CExpressionList* expressionList) : IExpression(location), Expression(expression), Identifier(identifier), ExpressionList(expressionList) {} virtual ~CInvocation() { delete Expression; delete Identifier; delete ExpressionList; } virtual void Accept(IVisitor* visitor) const { visitor->Visit(this); } virtual const std::string& GetName() const { return name; } IExpression* Expression; CIdentifier* Identifier; CExpressionList* ExpressionList; }; #endif //MINIJAVACOMPILER_INVOCATION_H
a2142a7fe806b587acd28720f988532136efd8c9
7ed7151f5523aba4d747a69920ebd193d6ac891b
/平成26年/其他图论/HDU5036 可达矩阵位图.cpp
aa65ebe6b4481abdf27ab56a15dfc72a8186fe5a
[ "LicenseRef-scancode-public-domain", "CC0-1.0" ]
permissive
zjkmxy/algo-problems
5965db9969855f208ae839d42a32a9b55781b590
7f2019a2ba650370e1e7af8ee96e6bfa5b4e3f87
refs/heads/master
2020-08-16T09:30:00.026431
2019-10-22T05:07:07
2019-10-22T05:07:07
215,485,779
0
0
null
null
null
null
GB18030
C++
false
false
1,801
cpp
HDU5036 可达矩阵位图.cpp
/* 考虑每一个点可以被它和他的所有直接和间接的父亲删除,假设这些点一共有k个,那么它就有1/k的概率被炸开。 加和即可。 */ #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<algorithm> #include<queue> using namespace std; #define MAXN 1005 #define MAXM 1000005 #define LOGN 32 typedef unsigned long DWORD; typedef DWORD MATRIX[MAXN][32]; MATRIX maparr; int N, lbn; int cnt[MAXN]; inline void setp(int p, int q) { maparr[p][q>>5] |= (1 << (q&0x1F)); } inline bool getp(int p, int q) { return (maparr[p][q>>5] & (1 << (q&0x1F))); } int bitcnt(DWORD x) { int res = 0, t, j; static int b[5] = {0x55555555, 0x33333333, 0x0f0f0f0f, 0x00ff00ff, 0x0000ffff}; for(t=1,j=0;j<5;j++,t<<=1) x = (x & b[j]) + ((x >> t) & b[j]); return x; } void Warshall() { int k, i, j; lbn = N >> 5; for(k=1;k<=N;k++) { for(i=1;i<=N;i++) { if(!getp(i, k)) continue; for(j=0;j<=lbn;j++) maparr[i][j] |= maparr[k][j]; } } for(i=1;i<=N;i++) { for(j=1;j<=N;j++) { if(getp(i, j)) cnt[j]++; } } } double domain() { int i, j, n, a; double ans = 0.0; scanf("%d",&N); memset(maparr, 0, sizeof(maparr)); for(i=1;i<=N;i++) { setp(i, i); cnt[i] = 0; scanf("%d",&n); while(n--) { scanf("%d",&a); setp(i, a); } } Warshall(); for(i=1;i<=N;i++) { ans += 1.0 / cnt[i]; } return ans; } int main() { int t, cas; scanf("%d",&t); for(cas=1;cas<=t;cas++) { printf("Case #%d: %.5lf\n",cas,domain()); } return 0; }
dae625ec2ccf8eb3c42551b9f7c23a816da76cfe
5b16adb0c7191950207eded95c6fa455b2e21775
/DirectX9Game/DirectX9Game/directx.cpp
7f6f3af1723d0a29f868831dee91f56089f2cad8
[]
no_license
makiOG/directx
eb43f1526ca2d492bb3ef7d2cae6002c580fec1e
0714c30e6a1d06a51f6d5d25343f3ca781733726
refs/heads/master
2022-04-25T01:52:01.269898
2020-04-16T20:24:45
2020-04-16T20:24:45
254,839,694
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,833
cpp
directx.cpp
#include <d3d9.h> //DirectXを使えるようにする #include"stdafx.h" #include"draw.h" //グローバル変数 LPDIRECT3D9 g_pD3D = NULL; //Direct3Dへのアクセス LPDIRECT3DDEVICE9 g_pD3DDev = NULL; //ビデオカードへのアクセス HRESULT InitD3D(HWND hwnd) { //Direct3Dを使えるようにする if (NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION))) { return E_FAIL; } //ディスプレイのモードを調べる D3DDISPLAYMODE d3ddm; if (FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) { return E_FAIL; } //Direct3Dデバイスを生成する D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp,sizeof(d3dpp)); //ほとんど0 d3dpp.Windowed = TRUE; //ウィンドウモード d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //画面切り替え方法(推奨されている値) d3dpp.BackBufferFormat = d3ddm.Format; if (FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp, &g_pD3DDev))) { return E_FAIL; } if (FAILED(Initialize(g_pD3DDev))) { //アプリケーションの初期化 return E_FAIL; } g_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); return S_OK; } //描画関数 VOID Render() { //背景を黒で塗りつぶす //g_pD3DDev->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0); g_pD3DDev->BeginScene();//描画の開始 Update(g_pD3DDev); //今度、関数の追加はここで行われる g_pD3DDev->EndScene();//描画の終了 //上で描画したものを実際にウィンドウに反映する g_pD3DDev->Present(NULL, NULL, NULL, NULL); } //後片付け #define SAFE_RELEASE(p) if(p){(p)->Release();(p)=NULL;} void Cleanup() { //アプリケーションの終了 Close(g_pD3DDev); SAFE_RELEASE(g_pD3DDev); SAFE_RELEASE(g_pD3D); }
b541418f8dec676b70c5b87281320414acccc2da
464367c7180487bba74097d6b229174b53246676
/riscv/src/VmasControlBlockRISCV.cc
e1a06fc07ffbb031aa45c79649da5b9d1c7a7bfa
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
openhwgroup/force-riscv
5ff99fd73456b9918a954ef1d29997da2c3f2df7
144fb52a99cde89e73552f88c872c05d2e90b603
refs/heads/master
2023-08-08T14:03:54.749423
2023-06-21T02:17:30
2023-06-21T02:17:30
271,641,901
190
53
NOASSERTION
2023-09-14T01:16:08
2020-06-11T20:36:00
C++
UTF-8
C++
false
false
18,403
cc
VmasControlBlockRISCV.cc
// // Copyright (C) [2020] Futurewei Technologies, Inc. // // FORCE-RISCV is 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 // // THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR // FIT FOR A PARTICULAR PURPOSE. // See the License for the specific language governing permissions and // limitations under the License. // #include "VmasControlBlockRISCV.h" #include <memory> #include <sstream> #include "Choices.h" #include "Config.h" #include "Constraint.h" #include "GenRequest.h" #include "Generator.h" #include "Log.h" #include "MemoryManager.h" #include "Page.h" #include "PageInfoRecord.h" #include "PageTable.h" #include "PagingChoicesAdapter.h" #include "PagingInfo.h" #include "PhysicalPageManager.h" #include "PteAttribute.h" #include "Random.h" #include "Register.h" #include "RegisterReload.h" #include "SetupRootPageTableRISCV.h" #include "UtilityFunctions.h" #include "UtilityFunctionsRISCV.h" #include "VmAddressSpace.h" #include "VmUtils.h" /*! \file VmasControlBlockRISCV.cc \brief Code to configure control block of address spaces. */ using namespace std; namespace Force { VmasControlBlockRISCV::VmasControlBlockRISCV(EPrivilegeLevelType privType, EMemBankType memType) : VmasControlBlock(privType, memType), mRegisterPrefix("m") { privilege_prefix(mRegisterPrefix, privType, false); } void VmasControlBlockRISCV::Setup(Generator* pGen) { //call base class setup (setup paging choices adapter/generator ptr) VmasControlBlock::Setup(pGen); VmContextParameter* context_param = nullptr; EVmContextParamType param_type; std::vector<std::string> status_param_names; //mstatus, sstatus, ustatus std::vector<std::string> atp_param_names; //satp, hgatp, vsatp switch (mPrivilegeLevel) { case EPrivilegeLevelType::M: status_param_names.push_back("MPRV"); //Modify Privilege - when enabled uses atp for privilege level in *PP register status_param_names.push_back("MXR"); //Make Executable Readable - loads to X=1 or R=1 allowed instead of just R=1 status_param_names.push_back("SUM"); //Supervisor User Memory - permits S access to pages marked as U=1 //status_param_names.push_back("MPP"); //Machine Previous Privilege - stores previous priv level while in M mode //status_param_names.push_back("MBE"); //Machine Big Endian - affects whether memory accesses are big endian, instr fetch always little status_param_names.push_back("TVM"); //Trap Virtual Memory - when 1 attempts to access satp CSR or execute SFENCE.VMA raise illegal instr exception break; case EPrivilegeLevelType::H: case EPrivilegeLevelType::S: status_param_names.push_back("MXR"); //Make Executable Readable - loads to X=1 or R=1 allowed instead of just R=1 status_param_names.push_back("SUM"); //Supervisor User Memory - permits S access to pages marked as U=1 //status_param_names.push_back("SPP"); //Supervisor Previous Privilege - stores previous priv level while in S mode //status_param_names.push_back("SBE"); //Supervisor Big Endian - affects whether memory accesses are big endian, instr fetch always little break; case EPrivilegeLevelType::U: //status_param_names.push_back("UBE"); break; } atp_param_names.push_back("MODE"); for (auto& name : status_param_names) { param_type = string_to_EVmContextParamType(name); context_param = new VmContextParameter(param_type, StatusRegisterName(), name); AddParameter(context_param); } for (auto& name : atp_param_names) { param_type = string_to_EVmContextParamType(name); context_param = new VmContextParameter(param_type, AtpRegisterName(), name); AddParameter(context_param); } } void VmasControlBlockRISCV::FillRegisterReload(RegisterReload* pRegContext) const { VmasControlBlock::FillRegisterReload(pRegContext); auto reg_file = mpGenerator->GetRegisterFile(); //Add register field updates for any context parameters not managed by mContextParams Register* satp_ptr = reg_file->RegisterLookup(AtpRegisterName()); pRegContext->AddRegisterFieldUpdate(satp_ptr, "PPN", (mpRootPageTable->TableBase() >> 12)); } void VmasControlBlockRISCV::InitializeMemoryAttributes() { } uint64 VmasControlBlockRISCV::GetMemoryAttributes() const { return 0; } bool VmasControlBlockRISCV::GetBigEndian() const { /*switch (mPrivilegeLevel) { case EPrivilegeLevelType::M: return (ContextParamValue(EVmContextParamType::MBE) == 1); break; case EPrivilegeLevelType::S: return (ContextParamValue(EVmContextParamType::SBE) == 1); break; case EPrivilegeLevelType::U: return (ContextParamValue(EVmContextParamType::UBE) == 1); break; }*/ return false; } EPageGranuleType VmasControlBlockRISCV::GetGranuleType() const { return EPageGranuleType::G4K; } bool VmasControlBlockRISCV::IsPaValid(uint64 PA, EMemBankType bank, std::string& rMsgStr) const { if (PA > mMaxPhysicalAddress) { rMsgStr += string_snprintf(128, "PA 0x%llx is larger than max physical address 0x%llx", PA, mMaxPhysicalAddress); return false; } return true; } //!< Return PTE shift based on paging mode... // uint32 VmasControlBlockRISCV::PteShift() const { uint32 pte_shift = 0; const PagingInfo* paging_info = mpGenerator->GetPagingInfo(); switch (paging_info->GetPagingMode()) { case EPagingMode::Sv32: pte_shift = 2; break; case EPagingMode::Sv39: case EPagingMode::Sv48: pte_shift = 3; break; default: LOG(fail) << "{VmasControlBlockRISCV::PteShift} Unknown paging mode " << EPagingMode_to_string(paging_info->GetPagingMode()) << endl; FAIL("unknown-paging-mode"); } return pte_shift; } uint64 VmasControlBlockRISCV::GetMaxPhysicalAddress() const { /*Uses all bits of PTE to store PPN[x] values - this causes some odd PA sizes after xlate since PPN fields in PTE start at 10, but the page offset is 12 we have extra bits in PTE allowing for first PPN to have more than the tablestep worth of bits.*/ //For now we are assuming Sv48 and are forcing a 48bit max PA for consistency. return Config::Instance()->LimitValue(ELimitType::PhysicalAddressLimit); } bool VmasControlBlockRISCV::GetWriteExecuteNever() const { return false; } uint32 VmasControlBlockRISCV::HighestVaBitCurrent(uint32 rangeNum) const { uint32 highest_va_bit = 0; const PagingInfo* paging_info = mpGenerator->GetPagingInfo(); switch (paging_info->GetPagingMode()) { case EPagingMode::Sv32: highest_va_bit = 31; break; case EPagingMode::Sv39: highest_va_bit = 38; break; case EPagingMode::Sv48: highest_va_bit = 47; break; default: LOG(fail) << "{VmasControlBlockRISCV::HighestVaBitCurrent} Unknown paging mode " << EPagingMode_to_string(paging_info->GetPagingMode()) << endl; FAIL("unknown-paging-mode"); } return highest_va_bit; } void VmasControlBlockRISCV::GetAddressErrorRanges(vector<TranslationRange>& rRanges) const { const PagingInfo* paging_info = mpGenerator->GetPagingInfo(); if (paging_info->GetPagingMode() == EPagingMode::Sv32) { // Sv32 has no address error ranges return; } TranslationRange addr_err_range; uint64 va_bits = mpRootPageTable->HighestLookUpBit(); uint64 error_start = 0x1ull << va_bits; uint64 error_end = sign_extend64((0x1ull << va_bits), va_bits+1) - 1; addr_err_range.SetBoundary(error_start, error_end); addr_err_range.SetMemoryBank(DefaultMemoryBank()); rRanges.push_back(addr_err_range); } bool VmasControlBlockRISCV::InitializeRootPageTable(VmAddressSpace* pVmas, RootPageTable* pRootTable) { mpRootPageTable = RootPageTableInstance(); if (nullptr == pRootTable) { SetupRootPageTable(mpRootPageTable, pVmas, mGranuleType, mPteIdentifierSuffix, AtpRegisterName()); } else { mpRootPageTable = pRootTable; uint64 root_addr = mpRootPageTable->TableBase(); uint32 tb_size = mpRootPageTable->RootTableSize(); pVmas->AddPhysicalRegion(new PhysicalRegion(root_addr, root_addr + (tb_size - 1), EPhysicalRegionType::PageTable, pRootTable->MemoryBank(), EMemDataType::Data)); pVmas->UpdatePageTableConstraint(root_addr, root_addr + (tb_size - 1)); mpRootPageTable->SignUp(pVmas); } return true; } void VmasControlBlockRISCV::SetupRootPageTable(RootPageTable* pRootTable, VmAddressSpace* pVmas, EPageGranuleType granType, const std::string& pteSuffix, const std::string& regName) { SetupRootPageTableRISCV SetupPagingObj; if (pRootTable == nullptr) { LOG(fail) << "{VmasControlBlockRISCV::InitializeRootPageTable} pRootTable is nullptr after initialize" << endl; FAIL("root_page_table_nullptr"); } uint32 pteSize = 0; uint32 tableStep = 0; uint32 maxTableLevel = 0; uint32 tableLowBit = 0; const PagingInfo* paging_info = mpGenerator->GetPagingInfo(); switch (paging_info->GetPagingMode()) { case EPagingMode::Sv32: pteSize = 2; tableStep = 10; maxTableLevel = 1; tableLowBit = 22; break; case EPagingMode::Sv39: pteSize = 3; tableStep = 9; maxTableLevel = 2; tableLowBit = 30; break; case EPagingMode::Sv48: pteSize = 3; tableStep = 9; maxTableLevel = 3; tableLowBit = 39; break; default: LOG(fail) << "{VmasControlBlockRISCV::SetupRootPageTable} Unknown paging mode " << EPagingMode_to_string(paging_info->GetPagingMode()) << endl; FAIL("unknown-paging-mode"); } pRootTable->Setup(tableStep, HighestVaBitCurrent(), tableLowBit, pteSuffix, pteSize, maxTableLevel); pRootTable->SetMemoryBank(DefaultMemoryBank()); auto reg_file = mpGenerator->GetRegisterFile(); auto mem_mgr = mpGenerator->GetMemoryManager(); uint32 tb_size = pRootTable->RootTableSize(); std::unique_ptr<ConstraintSet> usable_constr_ptr(GetPageTableUsableConstraint(mDefaultMemoryBank)); uint64 root_addr = SetupPagingObj.SetupRootPageTable(tb_size, mem_mgr, mDefaultMemoryBank, reg_file, regName, usable_constr_ptr.get()); pRootTable->SetTableBase(root_addr); pVmas->AddPhysicalRegion(new PhysicalRegion(root_addr, root_addr + (tb_size - 1), EPhysicalRegionType::PageTable, pRootTable->MemoryBank(), EMemDataType::Data)); pVmas->UpdatePageTableConstraint(root_addr, root_addr + (tb_size - 1)); pRootTable->SignUp(pVmas); } GenPageRequest* VmasControlBlockRISCV::PhysicalRegionPageRequest(const PhysicalRegion* pPhysRegion, bool& rRegionCompatible) const { EPhysicalRegionType phys_region_type = pPhysRegion->RegionType(); rRegionCompatible = true; auto set_system_pagereq_lambda = [=] (GenPageRequest* pPageReq, const PhysicalRegion* pPhysRegion) { pPageReq->SetGenBoolAttribute(EPageGenBoolAttrType::FlatMap, true); // use flat-map. pPageReq->SetPteAttribute(EPteAttributeType::SystemPage, 1); // Set the sw-configurable system page indicator to a 1 for system pages pPageReq->SetGenAttributeValue(EPageGenAttributeType::Invalid, 0); pPageReq->SetGenAttributeValue(EPageGenAttributeType::AddrSizeFault, 0); pPageReq->SetPrivilegeLevel(mPrivilegeLevel); pPageReq->SetBankType(pPhysRegion->MemoryBank()); }; bool is_instr = false; bool can_alias = false; EMemAccessType mem_access = EMemAccessType::Read; switch (phys_region_type) { case EPhysicalRegionType::HandlerMemory: case EPhysicalRegionType::ResetRegion: is_instr = true; break; case EPhysicalRegionType::AddressTable: case EPhysicalRegionType::BootRegion: is_instr = true; can_alias = true; break; case EPhysicalRegionType::PageTable: case EPhysicalRegionType::ExceptionStack: mem_access = EMemAccessType::ReadWrite; break; default: LOG(fail) << "{VmasControlBlockRISCV::PhysicalRegionPageRequest} not handled physical region type: " << EPhysicalRegionType_to_string(phys_region_type) << endl; FAIL("unhandled-physical-region-type"); } GenPageRequest* page_req = mpGenerator->GenPageRequestInstance(is_instr, mem_access); set_system_pagereq_lambda(page_req, pPhysRegion); uint32 user_access = (mPrivilegeLevel == EPrivilegeLevelType::U) ? 1 : 0; page_req->SetGenBoolAttribute(EPageGenBoolAttrType::CanAlias, can_alias); // Set a flag to allow aliasing to system page page_req->SetPteAttribute(EPteAttributeType::V, 1); page_req->SetPteAttribute(EPteAttributeType::U, user_access); if (is_instr) { page_req->SetGenBoolAttribute(EPageGenBoolAttrType::NoInstrPageFault, true); } else { page_req->SetGenBoolAttribute(EPageGenBoolAttrType::NoDataPageFault, true); } return page_req; } EMemBankType VmasControlBlockRISCV::NextLevelTableMemoryBank(const PageTable* parentTable, const GenPageRequest& rPageReq) const { return EMemBankType::Default; } EMemBankType VmasControlBlockRISCV::GetTargetMemoryBank(uint64 VA, GenPageRequest* pPageReq, const Page* pPage, const std::vector<ConstraintSet* >& rVmConstraints) { return EMemBankType::Default; } ConstraintSet* VmasControlBlockRISCV::GetPhysicalUsableConstraint() { ConstraintSet phys_limit_constr(0, MaxPhysicalAddress()); auto mem_manager = mpGenerator->GetMemoryManager(); auto mem_bank = mem_manager->GetMemoryBank(uint32(EMemBankType::Default)); auto usable_constr = mem_bank->Usable(); ConstraintSet* phys_usable = new ConstraintSet(*usable_constr); phys_usable->ApplyConstraintSet(phys_limit_constr); return phys_usable; } ConstraintSet* VmasControlBlockRISCV::InitialVirtualConstraint() const { //RISCV requires bits VA[63:va_max+1] to equal VA[va_max], logic below generates constraint accordingly. //Example: SV48 initial virtual is 0x0-0xFFF FFFF FFFF, 0xFFFF 8000 0000 0000-0xFFFF FFFF FFFF FFFF auto v_constr = new ConstraintSet(); uint64 va_bits = mpRootPageTable->HighestLookUpBit(); const PagingInfo* paging_info = mpGenerator->GetPagingInfo(); if (paging_info->GetPagingMode() == EPagingMode::Sv32) { uint64 va_end = (0x1ull << (va_bits + 1)) - 0x1ull; v_constr->AddRange(0, va_end); LOG(debug) << "{VmasControlBlockRISCV::InitialVirtualConstraint} For Sv32, va range: 0x0/0x" << std::hex << va_end << std::dec << std::endl; } else { uint64 va_end = (0x1ull << va_bits) - 0x1ull; v_constr->AddRange(0, va_end); LOG(debug) << "{VmasControlBlockRISCV::InitialVirtualConstraint} va_end: 0x0/0x" << std::hex << va_end << std::dec << std::endl; uint64 va_start = sign_extend64((0x1ull << va_bits), va_bits+1); v_constr->AddRange(va_start, ~0x0ull); LOG(debug) << "{VmasControlBlockRISCV::InitialVirtualConstraint} va_start: 0x0/0x" << std::hex << va_start << std::dec << std::endl; } if (v_constr->IsEmpty()) { LOG(fail) << "{VmasControlBlockRISCV::InitialVirtualConstraint} empty initial virtual constraint" << endl; FAIL("empty_initial_virtual_constraint"); } return v_constr; } ConstraintSet* VmasControlBlockRISCV::GetPageTableUsableConstraint(EMemBankType memBank) const { // Get the usable constraint specified in the variable.xml string var_name = EMemBankType_to_string(memBank) + " page table physical memory range"; auto page_table_var = mpGenerator->GetVariable(var_name, EVariableType::String); ConstraintSet* usable_constr = new ConstraintSet(page_table_var); // Apply the physical address limit size constraint. ConstraintSet phys_limit_constr(0, MaxPhysicalAddress()); usable_constr->ApplyConstraintSet(phys_limit_constr); return usable_constr; } ConstraintSet* VmasControlBlockRISCV::GetPageTableExcludeRegion(uint64 VA, EMemBankType memBank, const std::vector<ConstraintSet* >& rVmConstraints) { ConstraintSet* exclude_region = rVmConstraints[uint32(EVmConstraintType::Existing)]->Clone(); exclude_region->SubConstraintSet(*rVmConstraints[uint32(EVmConstraintType::FlatMap)]); exclude_region->MergeConstraintSet(*rVmConstraints[uint32(EVmConstraintType::PageTable)]); exclude_region->MergeConstraintSet(*rVmConstraints[uint32(EVmConstraintType::PageFault)]); exclude_region->AddValue(VA); return exclude_region; } void VmasControlBlockRISCV::CommitPageTable(uint64 VA, const PageTable* pParentTable, const TablePte* pTablePte, std::vector<ConstraintSet* >& rVmConstraints) { uint32 addr_size_fault = pTablePte->PageGenAttributeDefaultZero(EPageGenAttributeType::AddrSizeFault); uint32 invalid_desc = pTablePte->PageGenAttributeDefaultZero(EPageGenAttributeType::Invalid); uint64 mask = get_mask64(pParentTable->LowestLookUpBit()); uint64 va_range_low = VA & ~mask; uint64 va_range_hi = VA | mask; if (addr_size_fault || invalid_desc) { rVmConstraints[uint32(EVmConstraintType::PageFault)]->AddRange(va_range_low, va_range_hi); } rVmConstraints[uint32(EVmConstraintType::PageTable)]->AddRange(pTablePte->PhysicalLower(), pTablePte->PhysicalUpper()); } void VmasControlBlockRISCV::CommitPage(const Page* pPage, std::vector<ConstraintSet* >& rVmConstraints) { VmasControlBlock::CommitPage(pPage, rVmConstraints); uint32 addr_size_fault = pPage->PageGenAttributeDefaultZero(EPageGenAttributeType::AddrSizeFault); uint32 invalid_desc = pPage->PageGenAttributeDefaultZero(EPageGenAttributeType::Invalid); if (addr_size_fault || invalid_desc) { rVmConstraints[uint32(EVmConstraintType::PageFault)]->AddRange(pPage->Lower(), pPage->Upper()); } } }
bd9576ec912dda8bf803e051d67e814c400fcf8e
96d2e1697d7f7f84fccca4cc6830af5440f3e399
/链表/链表/单项链表.cpp
21841e9144b5b9e879df2ba1418a863a846f2692
[]
no_license
casen330/PAT-problem
556f74e677fa77dab095d103a8d5764ef7068102
08c08aeb2f71fd0abedcb15030328949e59ebef9
refs/heads/master
2021-01-19T19:01:42.361193
2017-07-20T07:18:00
2017-07-20T07:18:00
88,394,923
0
0
null
null
null
null
GB18030
C++
false
false
2,993
cpp
单项链表.cpp
#include<iostream> #include<vector> using namespace std; struct Node { int val; Node *pNext; }; //单向链表类 class LinkList{ public: LinkList(){ head = new Node; head->val = 0; head->pNext = NULL; } ~LinkList(){ delete head; } void CreateLinkList(int n); //创建链表 void InsertNode(int position, int d); //在指定位置插入节点 void TraverseLinkList(); //遍历 bool IsEmpty(); //判断是否为空 int GetLength(); //链表长度 void DeleteNode(int position); //删除节点 void DeleteLinkList(); //删除链表 private: Node *head; }; void LinkList::CreateLinkList(int n) { if (n < 0) { cout << "Error node count." << endl; exit(EXIT_FAILURE); } else { Node *pnew, *ptemp; ptemp = head; int i = n; while (n-->0) { pnew = new Node; cout << "输入第 " << i - n << " 个节点的值: "; cin >> pnew->val; pnew->pNext = NULL; ptemp->pNext = pnew; ptemp = pnew; } } } void LinkList::InsertNode(int position, int d) { if (position<0 || position>GetLength() + 1) { cout << "Location error" << endl; exit(EXIT_FAILURE); } else { Node *pnew, *ptemp; ptemp = head; pnew = new Node; pnew->pNext = NULL; pnew->val = d; while (position-->1) { ptemp = ptemp->pNext; } pnew->pNext = ptemp->pNext; ptemp->pNext = pnew; } } void LinkList::TraverseLinkList() { Node *ptemp = head->pNext; while (ptemp != NULL) { cout << ptemp->val << " "; ptemp = ptemp->pNext; } cout << endl; } bool LinkList::IsEmpty() { if (head->pNext == NULL) return true; else return false; } int LinkList::GetLength() { int length = 0; Node *ptemp = head; while (ptemp->pNext != NULL) { length++; ptemp = ptemp->pNext; } return length; } void LinkList::DeleteNode(int position) { if (position<0 || position>GetLength()) { cout << "Location error" << endl; exit(EXIT_FAILURE); } else { Node *ptemp, *pdelete; ptemp = head; while (position-- > 1) ptemp = ptemp->pNext; pdelete = ptemp->pNext; ptemp->pNext = pdelete->pNext; delete pdelete; pdelete = NULL; } } void LinkList::DeleteLinkList() { Node *pdelete=head->pNext, *ptemp; while (pdelete!=NULL) { ptemp = pdelete->pNext; head->pNext = ptemp; delete pdelete; pdelete = ptemp; } } int main(){ LinkList mylist; int position = 0, value = 0, n = 0; bool flag = false; cout << "输入需要创建单向链表的节点数:"; cin >> n; mylist.CreateLinkList(n); cout << "打印链表:"; mylist.TraverseLinkList(); cout << "输入插入节点的位置和值:"; cin >> position >> value; mylist.InsertNode(position, value); cout << "打印链表:"; mylist.TraverseLinkList(); cout << "输入要删除节点的位置:"; cin >> position; mylist.DeleteNode(position); cout << "打印链表:"; mylist.TraverseLinkList(); mylist.DeleteLinkList(); flag = mylist.IsEmpty(); if (flag) cout << "删除成功" << endl; else cout << "删除失败" << endl; return 0; }
b13d9cc0131d5f8ad074ab1dc89a623282f45104
9fa4e2dfb22a1aa901b5ee47a6a593bd7f70ee99
/DirectX12/01.Project/Engine/MRT.cpp
b679836bc3747433cb2b28de590cf7d0354cf25c
[]
no_license
Dahye11/TheIsland
1e6650723ace6d38f6bf17bf0949458834905f06
08fe44d305dc076897905523bbd8f95748b89d6e
refs/heads/master
2022-12-23T09:28:38.760857
2020-09-22T22:34:01
2020-09-22T22:34:01
298,494,711
0
0
null
2020-09-25T07:04:13
2020-09-25T07:04:12
null
UHC
C++
false
false
5,198
cpp
MRT.cpp
#include "stdafx.h" #include "MRT.h" #include "Device.h" #include "RenderMgr.h" CMRT::CMRT() : m_arrRT{} , m_tVP{} , m_tScissorRect{} { } CMRT::~CMRT() { } void CMRT::Create( UINT iCount, tRT * arrRT, Ptr<CTexture> pDSTex ) { // DepthStencilTexture 가 없다. assert( nullptr != pDSTex ); m_iRTCount = iCount; memcpy( m_arrRT, arrRT, sizeof( tRT ) * iCount ); m_pDSTex = pDSTex; // 복사받을 RTV 를 만들어둔다. D3D12_DESCRIPTOR_HEAP_DESC tDesc = {}; tDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; tDesc.NumDescriptors = m_iRTCount; tDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; tDesc.NodeMask = 0; DEVICE->CreateDescriptorHeap( &tDesc, IID_PPV_ARGS( &m_pRTV ) ); D3D12_CPU_DESCRIPTOR_HANDLE hRTVHeap = m_pRTV->GetCPUDescriptorHandleForHeapStart(); UINT iRTVSize = CRenderMgr::GetInst()->GetRTVHeapSize(); for ( UINT i = 0; i < m_iRTCount; ++i ) { UINT iDestRange = 1; UINT iSrcRange = 1; D3D12_CPU_DESCRIPTOR_HANDLE hDescHandle = m_pRTV->GetCPUDescriptorHandleForHeapStart(); hDescHandle.ptr += iRTVSize * i; ComPtr<ID3D12DescriptorHeap> pRTVHeap = m_arrRT[i].pTarget->GetRTV(); D3D12_CPU_DESCRIPTOR_HANDLE hSrcHandle = pRTVHeap->GetCPUDescriptorHandleForHeapStart(); DEVICE->CopyDescriptors( 1, &hDescHandle, &iDestRange , 1, &hSrcHandle, &iSrcRange, D3D12_DESCRIPTOR_HEAP_TYPE_RTV ); } for ( int i = 0; i < m_iRTCount; ++i ) { D3D12_RESOURCE_BARRIER barrier = {}; barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; barrier.Transition.pResource = m_arrRT[i].pTarget->GetTex2D().Get(); barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET; // 타겟에서 barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON; // 일반 리소스로 barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; m_TargetToRes[i] = barrier; barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON; // 리소스 barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET; // 렌더 타겟으로 barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; m_ResToTarget[i] = barrier; } m_tVP = D3D12_VIEWPORT{ 0.f, 0.f, m_arrRT[0].pTarget->Width() , m_arrRT[0].pTarget->Height(), 0.f, 1.f }; m_tScissorRect = D3D12_RECT{ 0, 0, (LONG)m_arrRT[0].pTarget->Width(), (LONG)m_arrRT[0].pTarget->Height() }; } void CMRT::OMSet( UINT iCount, UINT iOffset ) { UINT iRTVSize = CRenderMgr::GetInst()->GetRTVHeapSize(); D3D12_CPU_DESCRIPTOR_HANDLE hRTVHandle = m_pRTV->GetCPUDescriptorHandleForHeapStart(); hRTVHandle.ptr += iRTVSize * iOffset; D3D12_CPU_DESCRIPTOR_HANDLE hDSVHandle = m_pDSTex->GetDSV()->GetCPUDescriptorHandleForHeapStart(); // 뷰포트 설정 CMDLIST->RSSetViewports(1, &m_tVP); CMDLIST->RSSetScissorRects(1, &m_tScissorRect); // 타겟 지정 CMDLIST->OMSetRenderTargets( iCount, &hRTVHandle, FALSE, &hDSVHandle ); } void CMRT::OMSet() { // RenderTarget 과 DepthStencilView 를 연결 D3D12_CPU_DESCRIPTOR_HANDLE hRTVHandle = m_pRTV->GetCPUDescriptorHandleForHeapStart(); D3D12_CPU_DESCRIPTOR_HANDLE hDSVHandle = m_pDSTex->GetDSV()->GetCPUDescriptorHandleForHeapStart(); // 뷰포트 설정 CMDLIST->RSSetViewports(1, &m_tVP); CMDLIST->RSSetScissorRects(1, &m_tScissorRect); // 타겟 지정 CMDLIST->OMSetRenderTargets( m_iRTCount, &hRTVHandle, TRUE/*DescHeap 에 연속적으로 있다*/, &hDSVHandle ); } void CMRT::Clear() { ResToTargetBarrier(); // 타겟 클리어 UINT iRTVSize = CRenderMgr::GetInst()->GetRTVHeapSize(); for ( UINT i = 0; i < m_iRTCount; ++i ) { D3D12_CPU_DESCRIPTOR_HANDLE hRTVHandle = m_pRTV->GetCPUDescriptorHandleForHeapStart(); hRTVHandle.ptr += iRTVSize * i; float arrClearColor[4] = { m_arrRT[i].vClearColor.x, m_arrRT[i].vClearColor.y, m_arrRT[i].vClearColor.z, m_arrRT[i].vClearColor.w }; CMDLIST->ClearRenderTargetView( hRTVHandle, arrClearColor, 0, nullptr ); } if ( nullptr != m_pDSTex ) { D3D12_CPU_DESCRIPTOR_HANDLE hDSVHandle = m_pDSTex->GetDSV()->GetCPUDescriptorHandleForHeapStart(); CMDLIST->ClearDepthStencilView( hDSVHandle, D3D12_CLEAR_FLAG_DEPTH, 1.f, 0, 0, nullptr ); } } void CMRT::Clear( UINT iRTidx ) { // 타겟 클리어 UINT iRTVSize = CRenderMgr::GetInst()->GetRTVHeapSize(); D3D12_CPU_DESCRIPTOR_HANDLE hRTVHandle = m_pRTV->GetCPUDescriptorHandleForHeapStart(); hRTVHandle.ptr += iRTVSize * iRTidx; float arrClearColor[4] = { m_arrRT[iRTidx].vClearColor.x , m_arrRT[iRTidx].vClearColor.y , m_arrRT[iRTidx].vClearColor.z , m_arrRT[iRTidx].vClearColor.w }; CMDLIST->ClearRenderTargetView( hRTVHandle, arrClearColor, 0, nullptr ); if ( nullptr != m_pDSTex ) { D3D12_CPU_DESCRIPTOR_HANDLE hDSVHandle = m_pDSTex->GetDSV()->GetCPUDescriptorHandleForHeapStart(); CMDLIST->ClearDepthStencilView( hDSVHandle, D3D12_CLEAR_FLAG_DEPTH, 1.f, 0, 0, nullptr ); } } void CMRT::TargetToResBarrier() { CMDLIST->ResourceBarrier( m_iRTCount, m_TargetToRes ); } void CMRT::ResToTargetBarrier() { CMDLIST->ResourceBarrier( m_iRTCount, m_ResToTarget ); } Ptr<CTexture> CMRT::GetRTTex( UINT iIdx ) { return m_arrRT[iIdx].pTarget; } Ptr<CTexture> CMRT::GetDSTex() { return m_pDSTex; }
c8bd4b41263d305eb902296fb5c8f0f259d81c4f
7394b3ae6c77b5ca3cbf30961521c894d89902f6
/rotate-cube-new.cpp
e212a6d4950eb8c699b6c20d6f50fa8efa2a5a6a
[]
no_license
zhangbo0216/Computer-Graphic-Project
b83eeff70ef1ce49e014e0eaf231dae2928f01d9
1276ed2f139b87f4ee21dc64552ffde772e720bc
refs/heads/master
2020-12-25T13:07:30.061971
2016-05-19T02:58:33
2016-05-19T02:58:33
56,887,742
0
0
null
null
null
null
UTF-8
C++
false
false
44,038
cpp
rotate-cube-new.cpp
#include "Angel-yjc.h" typedef Angel::vec4 color4; typedef Angel::vec4 point4; std::string filename; GLuint Angel::InitShader(const char* vShaderFile, const char* fShaderFile); GLuint program,program2,programfire; /* shader program object id */ GLuint floor_buffer,shaded_floor_buffer; /* vertex buffer object id for floor */ GLuint coordinate_buffer; /* vertex buffer object id for coordinate */ GLuint sphere_buffer,flat_sphere_buffer,smooth_sphere_buffer; /* vertex buffer object id for sphere */ GLuint shadow_buffer; GLuint firework_buffer; // Projection transformation parameters GLfloat fovy = 53.0; // Field-of-view in Y direction angle (in degrees) GLfloat aspect; // Viewport aspect ratio GLfloat zNear = 0.1, zFar = 40; GLfloat angle = 0.0; // rotation angle in degrees vec3 move={0, 0, 0}; // vectpr for moving vec3 A={-4,1,4},B={-1,1,-4},C={3,1,5},AB=B-A,BC=C-B,CA=A-C,tw=AB; mat4 Mrotate= mat4( vec4(1,0,0,0), vec4(0,1,0,0), vec4(0,0,1,0), vec4(0,0,0,1)); //matrix to store rotation int zone=1,sum=0; vec4 init_eye(7.0, 3.0,-10.0, 1.0); // initial viewer position vec4 eye = init_eye; // current viewer position int animationFlag = 1; // 1: non-animation; 1: non-animation. Toggled by key 'a' or 'A' bool avaliable = false; int smoothFlag = 1; int shadowFlag=1; int WireFramFlag=0; int LightingFlag=1; int spotLightFlag=0; int fogFlag = 0; int textureFlag=1; int sphereTexFlag=0; int draw=0; int verticalFlag=1; int eyeSpaceFlag=0; int latticeFlag=0; int upLatticeFlag=1; int fireworkFlag=1; int blendingShadowFlag=1; int cubeFlag = 1; // 1: solid cube; 0: wireframe cube. Toggled by key 'c' or 'C' int floorFlag = 1; // 1: solid floor; 0: wireframe floor. Toggled by key 'f' or 'F' int startFlag = 1; // 1: dont't move; 0: start to roll. Toggled by key 'b' or 'B' int sphere_numVertices; /*firework*/ float time_Old = 0.0; float time_New = 0.0; float time_Sub = 0.0; float time_Max = 10000.0; /*--- Texture ---*/ #define checkerWidth 32 #define checkerHeight 32 GLubyte checkerImage[checkerHeight][checkerWidth][4]; #define stripeWidth 32 GLubyte stripeImage[4 * stripeWidth]; GLuint checkerTex; // Checkboard texture GLuint stripeTex; // Stripe texture vec2 texCoord[6] = { vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0), vec2(0.0, 0.0), }; point4 sphere_points[1024*3]; color4 sphere_color[1024*3]; vec3 flat_normals[1024*3]; vec3 smooth_normals[1024*3]; point4 shadow_points[1024*3]; point4 shadow_colors[1024*3]; point4 coordinate_point[9]; color4 coordinate_color[9]; const int floor_NumVertices = 6; point4 floor_points[floor_NumVertices]; // positions for all vertices color4 floor_colors[floor_NumVertices]; // colors for all vertices vec3 floor_normals[floor_NumVertices]; //---------------------------------------------------------------------------- std::string chooseFile() { printf("Enter: 1. sphere.8 2.sphere.128 3.sphere.256 4.sphere.1024\n"); int choose; std::cin >> choose; if (choose == 1) return "sphere.8"; else if (choose == 2) return "sphere.128"; else if (choose == 3) return "sphere.256"; else return "sphere.1024"; } //------------------------------------------------------------------------------ void Sphere(std::string filename) { std::ifstream f(filename, std::ios::in); int tem; f >> sphere_numVertices; for (int i=0;i<sphere_numVertices;i++) { f>>tem; float a,b,c; for (int j=0;j<tem;j++) { f>>a>>b>>c; sphere_points[i*3+j]=point4(a,b,c,1); sphere_color[i*3+j] = color4(1.0,0.84,0,1); } } sphere_numVertices*=3; for (int i = 0; i < sphere_numVertices; i += 3) { int a = i; int b = i + 1; int c = i + 2; vec4 u = sphere_points[b] - sphere_points[a]; vec4 v = sphere_points[c] - sphere_points[a]; vec3 normal = normalize(cross(u, v)); flat_normals[a] = normal; smooth_normals[a] = vec3(sphere_points[a].x, sphere_points[a].y, sphere_points[a].z); flat_normals[b] = normal; smooth_normals[b] = vec3(sphere_points[b].x, sphere_points[b].y, sphere_points[b].z); flat_normals[c] = normal; smooth_normals[c] = vec3(sphere_points[c].x, sphere_points[c].y, sphere_points[c].z); } } void setup_texture(void) { int i, j, c; for (i = 0; i < checkerHeight; i++) { for (j = 0; j < checkerWidth; j++) { c = (((i & 0x8) == 0) ^ ((j & 0x8) ==0)); /*-- c == 1: white, else brown --*/ checkerImage[i][j][0] = (GLubyte) ((c==1) ? 255 : 0); checkerImage[i][j][1] = (GLubyte) ((c==1) ? 255 : 150); checkerImage[i][j][2] = (GLubyte) ((c==1) ? 255 : 0); checkerImage[i][j][3] = (GLubyte) 255; } } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); /*--- Create stripe image ---*/ for (j = 0; j < stripeWidth; j++) { stripeImage[4 * j] = (GLubyte)255; stripeImage[4 * j + 1] = (GLubyte)((j>4) ? 255 : 0); stripeImage[4 * j + 2] = (GLubyte)0; stripeImage[4 * j + 3] = (GLubyte)255; } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } void coordinate() { coordinate_point[0] = point4(0,0,0,1); coordinate_color[0] = color4(1,0,0,1); coordinate_point[1] = point4(10,0,0,1); coordinate_color[1] = color4(1,0,0,1); coordinate_point[2] = point4(10,0,0,1); coordinate_color[2] = color4(1,0,0,1); coordinate_point[3] = point4(0,0,0,1); coordinate_color[3] = color4(1,0,1,1); coordinate_point[4] = point4(0,10,0,1); coordinate_color[4] = color4(1,0,1,1); coordinate_point[5] = point4(0,10,0,1); coordinate_color[5] = color4(1,0,1,1); coordinate_point[6] = point4(0,0,0,1); coordinate_color[6] = color4(0,0,1,1); coordinate_point[7] = point4(0,0,10,1); coordinate_color[7] = color4(0,0,1,1); coordinate_point[8] = point4(0,0,10,1); coordinate_color[8] = color4(0,0,1,1); } void shadow() { for (int i = 0;i < sphere_numVertices;i++) { //int x = sphere_points[i].x, y = sphere_points[i].y, z = sphere_points[i].z; //shadow_points[i]=point4(x,y,z,1); shadow_colors[i]=color4(0.25, 0.25, 0.25, 0.65); } } // generate 2 triangles: 6 vertices and 1 color void floor() { floor_colors[0] = color4(0,1,0,1); floor_points[0] = point4(5, 0, 8,1); floor_colors[1] = color4(0,1,0,1); floor_points[1] = point4(5, 0, -4,1); floor_colors[2] = color4(0,1,0,1); floor_points[2] = point4(-5, 0,-4,1); floor_colors[3] = color4(0,1,0,1); floor_points[3] = point4(5, 0, 8,1); floor_colors[4] = color4(0,1,0,1); floor_points[4] = point4(-5, 0, 8,1); floor_colors[5] = color4(0,1,0,1); floor_points[5] = point4(-5, 0,-4,1); vec4 u = point4( 5.0, 0.0, -4.0, 1.0) - point4( 5.0, 0.0, 8.0, 1.0); vec4 v = point4(-5.0, 0.0, 8.0, 1.0) - point4( 5.0, 0.0, 8.0, 1.0); vec3 normal = normalize(cross(u, v)); for (int i=0;i<6;i++) floor_normals[i]=normal; } const int N = 300; // number of particles in particle system point4 fireworks_points[N]; // position of each particle vec3 fireworks_velocities[N]; // velocities of particles color4 fireworks_colors[N]; // color of each particle void firework() { int i; for (i = 0; i < N; i++){ fireworks_points[i] = point4(0.0, 0.1, 0.0, 1.0); // Assigning random velocity to particles fireworks_velocities[i].x = 2.0 * ((rand() % 256) / 256.0 - 0.5); fireworks_velocities[i].y = 1.2 * 2.0 * (rand() % 256) / 256.0; fireworks_velocities[i].z = 2.0 * ((rand() % 256) / 256.0 - 0.5); // Assigning random color to particles fireworks_colors[i].x = (rand() % 256) / 256.0; fireworks_colors[i].y = (rand() % 256) / 256.0; fireworks_colors[i].z = (rand() % 256) / 256.0; fireworks_colors[i].w = 1.0; } } //---------------------------------------------------------------------------- // OpenGL initialization void init() { setup_texture(); // Checkerboard Texture glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &checkerTex); // Generate texture obj glActiveTexture(GL_TEXTURE0); // Set the active texture to be 0 glBindTexture(GL_TEXTURE_2D, checkerTex); // Bind texture to texture unit glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkerWidth, checkerHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkerImage); // Stripe Texture glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &stripeTex); // Generate texture obj glActiveTexture(GL_TEXTURE1); // Set the active texture to be 1 glBindTexture(GL_TEXTURE_1D, stripeTex); // Bind texture to texture unit glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, stripeWidth, 0, GL_RGBA, GL_UNSIGNED_BYTE, stripeImage); floor(); // Create and initialize a vertex buffer object for floor, to be used in display() glGenBuffers(1, &floor_buffer); glBindBuffer(GL_ARRAY_BUFFER, floor_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(floor_points) + sizeof(floor_colors), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(floor_points), floor_points); glBufferSubData(GL_ARRAY_BUFFER, sizeof(floor_points), sizeof(floor_colors), floor_colors); //buffer for shaded floor glGenBuffers(1, &shaded_floor_buffer); glBindBuffer(GL_ARRAY_BUFFER, shaded_floor_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(point4)* floor_NumVertices + sizeof(vec3)* floor_NumVertices+sizeof(texCoord), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(point4)* floor_NumVertices, floor_points); glBufferSubData(GL_ARRAY_BUFFER, sizeof(point4)* floor_NumVertices, sizeof(vec3)* floor_NumVertices, floor_normals); glBufferSubData(GL_ARRAY_BUFFER, sizeof(floor_points)+sizeof(floor_normals), sizeof(texCoord), texCoord); coordinate(); // buffer for coordinate glGenBuffers(1, &coordinate_buffer); glBindBuffer(GL_ARRAY_BUFFER, coordinate_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(coordinate_point) + sizeof(coordinate_color)+sizeof(texCoord), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(coordinate_point), coordinate_point); glBufferSubData(GL_ARRAY_BUFFER, sizeof(coordinate_point), sizeof(coordinate_color), coordinate_color); Sphere(filename); //buffer for shpere glGenBuffers(1, &sphere_buffer); glBindBuffer(GL_ARRAY_BUFFER, sphere_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(point4)* sphere_numVertices + sizeof(color4)* sphere_numVertices, NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(point4)* sphere_numVertices, sphere_points); glBufferSubData(GL_ARRAY_BUFFER, sizeof(point4)* sphere_numVertices, sizeof(color4)* sphere_numVertices, sphere_color); //buffer for flat_shpere glGenBuffers(1, &flat_sphere_buffer); glBindBuffer(GL_ARRAY_BUFFER, flat_sphere_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(point4)* sphere_numVertices + sizeof(vec3)* sphere_numVertices+sizeof(texCoord), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(point4)* sphere_numVertices, sphere_points); glBufferSubData(GL_ARRAY_BUFFER, sizeof(point4)* sphere_numVertices, sizeof(vec3)* sphere_numVertices, flat_normals); glBufferSubData(GL_ARRAY_BUFFER, sizeof(point4)* sphere_numVertices + sizeof(vec3)* sphere_numVertices, sizeof(texCoord), texCoord); //buffer for smooth_shpere glGenBuffers(1, &smooth_sphere_buffer); glBindBuffer(GL_ARRAY_BUFFER, smooth_sphere_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(point4)* sphere_numVertices + sizeof(vec3)* sphere_numVertices+sizeof(texCoord), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(point4)* sphere_numVertices, sphere_points); glBufferSubData(GL_ARRAY_BUFFER, sizeof(point4)* sphere_numVertices, sizeof(vec3)* sphere_numVertices, smooth_normals); glBufferSubData(GL_ARRAY_BUFFER, sizeof(point4)* sphere_numVertices + sizeof(vec3)* sphere_numVertices, sizeof(texCoord), texCoord); shadow(); //buffer for shadow glGenBuffers(1, &shadow_buffer); glBindBuffer(GL_ARRAY_BUFFER, shadow_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(point4) * sphere_numVertices + sizeof(color4) * sphere_numVertices, NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(point4) * sphere_numVertices, sphere_points); glBufferSubData(GL_ARRAY_BUFFER, sizeof(point4) * sphere_numVertices, sizeof(color4) * sphere_numVertices, shadow_colors); //buffer for firework firework(); glGenBuffers(1, &firework_buffer); glBindBuffer(GL_ARRAY_BUFFER, firework_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(fireworks_points)+sizeof(fireworks_colors)+sizeof(fireworks_velocities), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(fireworks_points), fireworks_points); glBufferSubData(GL_ARRAY_BUFFER, sizeof(fireworks_points), sizeof(fireworks_colors), fireworks_colors); glBufferSubData(GL_ARRAY_BUFFER, sizeof(fireworks_points)+sizeof(fireworks_colors), sizeof(fireworks_velocities), fireworks_velocities); // Load shaders and create a shader program (to be used in display()) program = InitShader("vshader42.glsl", "fshader53.glsl"); program2 = InitShader("vshader53.glsl", "fshader53.glsl"); programfire=InitShader("vfire.glsl", "ffire.glsl"); glEnable( GL_DEPTH_TEST ); glClearColor(0.529, 0.807, 0.92, 0.0); glLineWidth(2.0); } //---------------------------------------------------------------------------- // drawObj(buffer, num_vertices): // draw the object that is associated with the vertex buffer object "buffer" // and has "num_vertices" vertices. // void drawObj(GLuint buffer, int num_vertices) { //--- Activate the vertex buffer object to be drawn ---// glBindBuffer(GL_ARRAY_BUFFER, buffer); /*----- Set up vertex attribute arrays for each vertex attribute -----*/ GLuint vPosition = glGetAttribLocation(program, "vPosition"); glUniform1i(glGetUniformLocation(program, "fogFlag"), fogFlag); glUniform1i(glGetUniformLocation(program, "texture_2D"), 0); glUniform1i(glGetUniformLocation(program, "texture_1D"), 1); glUniform1i(glGetUniformLocation(program, "textureFlag"), textureFlag); glUniform1i(glGetUniformLocation(program, "draw"), draw); glUniform1i(glGetUniformLocation(program,"upLatticeFlag"),upLatticeFlag); glUniform1i(glGetUniformLocation(program,"latticeFlag"),latticeFlag); glEnableVertexAttribArray(vPosition); glVertexAttribPointer(vPosition, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) ); GLuint vColor = glGetAttribLocation(program, "vColor"); glEnableVertexAttribArray(vColor); glVertexAttribPointer(vColor, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(sizeof(point4) * num_vertices) ); // the offset is the (total) size of the previous vertex attribute array(s) //GLuint vTexCoord = glGetAttribLocation(program, "vTexCoord"); //glEnableVertexAttribArray(vTexCoord); //glVertexAttribPointer(vTexCoord, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(sizeof(point4)* num_vertices + sizeof(point4)* num_vertices)); /* Draw a sequence of geometric objs (triangles) from the vertex buffer (using the attributes specified in each enabled vertex attribute array) */ glDrawArrays(GL_TRIANGLES, 0, num_vertices); /*--- Disable each vertex attribute array being enabled ---*/ glDisableVertexAttribArray(vPosition); glDisableVertexAttribArray(vColor); } void drawObj2(GLuint buffer, int num_vertices) { //--- Activate the vertex buffer object to be drawn ---// glBindBuffer(GL_ARRAY_BUFFER, buffer); /*----- Set up vertex attribute arrays for each vertex attribute -----*/ GLuint vPosition = glGetAttribLocation( program2, "vPosition" ); glUniform1i(glGetUniformLocation(program2, "fogFlag"), fogFlag); glUniform1i(glGetUniformLocation(program2, "texture_2D"),0); glUniform1i(glGetUniformLocation(program2, "texture_1D"),1); glUniform1i(glGetUniformLocation(program2, "textureFlag"),textureFlag); glUniform1i(glGetUniformLocation(program2, "sphereTexFlag"),sphereTexFlag); glUniform1i(glGetUniformLocation(program2, "draw"),draw); glUniform1i(glGetUniformLocation(program2, "verticalFlag"),verticalFlag); glUniform1i(glGetUniformLocation(program2, "eyeSpaceFlag"),eyeSpaceFlag); glUniform1i(glGetUniformLocation(program2, "latticeFlag"),latticeFlag); glUniform1i(glGetUniformLocation(program2,"upLatticeFlag"),upLatticeFlag); glEnableVertexAttribArray( vPosition ); glVertexAttribPointer( vPosition, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) ); GLuint vNormal = glGetAttribLocation( program2, "vNormal" ); glEnableVertexAttribArray( vNormal ); glVertexAttribPointer( vNormal, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(sizeof(point4)*num_vertices)); // the offset is the (total) size of the previous vertex attribute array(s) GLuint vTexCoord = glGetAttribLocation(program2, "vTexCoord"); glEnableVertexAttribArray(vTexCoord); glVertexAttribPointer(vTexCoord, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(sizeof(point4)* num_vertices + sizeof(vec3)* num_vertices)); /* Draw a sequence of geometric objs (triangles) from the vertex buffer (using the attributes specified in each enabled vertex attribute array) */ glDrawArrays(GL_TRIANGLES, 0, num_vertices); /*--- Disable each vertex attribute array being enabled ---*/ glDisableVertexAttribArray(vPosition); glDisableVertexAttribArray(vNormal); glDisableVertexAttribArray(vTexCoord); } void drawFireworks(GLuint buffer, int num_vertices) { //--- Activate the vertex buffer object to be drawn ---// glBindBuffer(GL_ARRAY_BUFFER, buffer); glUniform1f(glGetUniformLocation(programfire, "t"), time_New); /*----- Set up vertex attribute arrays for each vertex attribute -----*/ GLuint vPosition = glGetAttribLocation(programfire, "vPosition"); glEnableVertexAttribArray(vPosition); glVertexAttribPointer(vPosition, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0)); GLuint vColor = glGetAttribLocation(programfire, "vColor"); glEnableVertexAttribArray(vColor); glVertexAttribPointer(vColor, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(sizeof(point4)* num_vertices)); GLuint vVelocity = glGetAttribLocation(programfire, "vVelocity"); glEnableVertexAttribArray(vVelocity); glVertexAttribPointer(vVelocity, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(sizeof(point4)* num_vertices * 2)); /* Draw a sequence of geometric objs (triangles) from the vertex buffer (using the attributes specified in each enabled vertex attribute array) */ glDrawArrays(GL_POINTS, 0, num_vertices); /*--- Disable each vertex attribute array being enabled ---*/ glDisableVertexAttribArray(vVelocity); glDisableVertexAttribArray(vPosition); glDisableVertexAttribArray(vColor); } //----------------------------------------------------------------------------- vec3 light_direction=vec3(0.1, 0.0, -1.0); color4 global_ambient(1.0,1.0,1.0,1.0); color4 light_ambient(0.0, 0.0, 0.0, 1.0); color4 light_diffuse(0.8, 0.8, 0.8, 1.0); color4 light_specular(0.2, 0.2, 0.2, 1.0); float material_shininess=125.0; color4 material_ambient( 0.2, 0.2, 0.2, 1.0); color4 material_diffuse( 1.0, 0.84, 0.0, 1.0 ); color4 material_specular(1.0, 0.84, 0.0, 1.0); color4 ambient_product = light_ambient* material_ambient; color4 diffuse_product = light_diffuse * material_diffuse; color4 specular_product = light_specular * material_specular; void setUp_sphere(mat4 mv) { glUniform3fv(glGetUniformLocation(program2, "SurfaceAmbient"), 1, material_ambient); glUniform3fv(glGetUniformLocation(program2, "LightDirection"), 1, light_direction); glUniform4fv(glGetUniformLocation(program2, "GlobalAmbient"), 1, global_ambient); glUniform4fv(glGetUniformLocation(program2, "AmbientProduct"), 1, ambient_product); glUniform4fv(glGetUniformLocation(program2, "DiffuseProduct"), 1, diffuse_product); glUniform4fv(glGetUniformLocation(program2, "SpecularProduct"),1, specular_product); glUniform1f(glGetUniformLocation(program2, "Shininess"), material_shininess); } color4 floor_diffuse(0.0, 1.0, 0.0, 1.0),floor_ambient(0.2, 0.2, 0.2, 1.0),floor_specular(0.0, 0.0, 0.0, 1.0); color4 floor_ambient_product = light_ambient* floor_ambient; color4 floor_diffuse_product = light_diffuse * floor_diffuse; color4 floor_specular_product = light_specular * floor_specular; void setUp_floor(mat4 mv) { glUniform3fv(glGetUniformLocation(program2, "SurfaceAmbient"), 1, floor_ambient); glUniform3fv(glGetUniformLocation(program2, "LightDirection"), 1, light_direction); glUniform4fv(glGetUniformLocation(program2, "GlobalAmbient"), 1, global_ambient); glUniform4fv(glGetUniformLocation(program2, "AmbientProduct"), 1, floor_ambient_product); glUniform4fv(glGetUniformLocation(program2, "DiffuseProduct"), 1, floor_diffuse_product); glUniform4fv(glGetUniformLocation(program2, "SpecularProduct"),1, floor_specular_product); glUniform1f(glGetUniformLocation(program2, "Shininess"), material_shininess); } //another light souce color4 light_diffuse2(1.0, 1.0, 1.0, 1.0), light_specular2(1.0, 1.0, 1.0, 1.0), light_ambient2(0.0, 0.0, 0.0, 1.0); vec4 light_source(-14.0, 12.0, -3.0, 1.0); float constant_attenuation=2.0, linear_attenuation=0.01, quadratic_attenuation=0.001; point4 light2_endpoint(-6.0, 0.0, -4.5, 1.0); float exponent = 15.0; float cutoff_angle = 20.0; color4 floor_ambient_product2 = light_ambient2* floor_ambient; color4 floor_diffuse_product2 = light_diffuse2 * floor_diffuse; color4 floor_specular_product2 = light_specular2 * floor_specular; void setUp_point_floor(mat4 mv) { vec4 point_position = mv * light_source; glUniform4fv(glGetUniformLocation(program2, "PointPosition"), 1, point_position); glUniform1i(glGetUniformLocation(program2, "Point_Source"), 1); glUniform4fv(glGetUniformLocation(program2, "PointAmbientProduct"), 1, floor_ambient_product2); glUniform4fv(glGetUniformLocation(program2, "PointDiffuseProduct"), 1, floor_diffuse_product2); glUniform4fv(glGetUniformLocation(program2, "PointSpecularProduct"), 1, floor_specular_product2); glUniform1f(glGetUniformLocation(program2, "Constant_Attenuation"), constant_attenuation); glUniform1f(glGetUniformLocation(program2, "Linear_Attenuation"), linear_attenuation); glUniform1f(glGetUniformLocation(program2, "Quadratic_Attenuation"), quadratic_attenuation); } void setUp_spot_floor(mat4 mv) { vec4 point_position = mv * light_source; vec4 point_end_position = mv * light2_endpoint; glUniform4fv(glGetUniformLocation(program2, "PointPosition"), 1, point_position); glUniform1f(glGetUniformLocation(program2, "Exponent"), exponent); glUniform1f(glGetUniformLocation(program2, "CutOff"), cutoff_angle); glUniform4fv(glGetUniformLocation(program2, "PointEndPosition"), 1, point_end_position); glUniform1i(glGetUniformLocation(program2, "Point_Source"), 0); glUniform4fv(glGetUniformLocation(program2, "PointAmbientProduct"), 1, floor_ambient_product2); glUniform4fv(glGetUniformLocation(program2, "PointDiffuseProduct"), 1, floor_diffuse_product2); glUniform4fv(glGetUniformLocation(program2, "PointSpecularProduct"), 1, floor_specular_product2); glUniform1f(glGetUniformLocation(program2, "Constant_Attenuation"), constant_attenuation); glUniform1f(glGetUniformLocation(program2, "Linear_Attenuation"), linear_attenuation); glUniform1f(glGetUniformLocation(program2, "Quadratic_Attenuation"), quadratic_attenuation); } color4 ambient_product2 = light_ambient2* material_ambient; color4 diffuse_product2 = light_diffuse2 * material_diffuse; color4 specular_product2 = light_specular2 * material_specular; void setUp_point_sphere(mat4 mv) { vec4 point_position = mv * light_source; glUniform4fv(glGetUniformLocation(program2, "PointPosition"), 1, point_position); glUniform1i(glGetUniformLocation(program2, "Point_Source"), 1); glUniform4fv(glGetUniformLocation(program2, "PointAmbientProduct"), 1, ambient_product2); glUniform4fv(glGetUniformLocation(program2, "PointDiffuseProduct"), 1, diffuse_product2); glUniform4fv(glGetUniformLocation(program2, "PointSpecularProduct"),1,specular_product2); glUniform1f(glGetUniformLocation(program2, "Constant_Attenuation"), constant_attenuation); glUniform1f(glGetUniformLocation(program2, "Linear_Attenuation"), linear_attenuation); glUniform1f(glGetUniformLocation(program2, "Quadratic_Attenuation"), quadratic_attenuation); } void setUp_spot_sphere(mat4 mv) { vec4 point_position = mv * light_source; vec4 point_end_position = mv * light2_endpoint; glUniform4fv(glGetUniformLocation(program2, "PointPosition"), 1, point_position); glUniform1f(glGetUniformLocation(program2, "Exponent"), exponent); glUniform1f(glGetUniformLocation(program2, "CutOff"), cutoff_angle); glUniform4fv(glGetUniformLocation(program2, "PointEndPosition"), 1, point_end_position); glUniform1i(glGetUniformLocation(program2, "Point_Source"), 0); glUniform4fv(glGetUniformLocation(program2, "PointAmbientProduct"), 1, ambient_product2); glUniform4fv(glGetUniformLocation(program2, "PointDiffuseProduct"), 1, diffuse_product2); glUniform4fv(glGetUniformLocation(program2, "PointSpecularProduct"), 1,specular_product2); glUniform1f(glGetUniformLocation(program2, "Constant_Attenuation"), constant_attenuation); glUniform1f(glGetUniformLocation(program2, "Linear_Attenuation"), linear_attenuation); glUniform1f(glGetUniformLocation(program2, "Quadratic_Attenuation"), quadratic_attenuation); } //---------------------------------------------------------------------------- void display( void ) { GLuint model_view,model_view2,model_view3; // model-view matrix uniform shader variable location GLuint projection,projection2,projection3; // projection matrix uniform shader variable location glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glUseProgram(program); // Use the shader program model_view = glGetUniformLocation(program, "model_view" ); projection = glGetUniformLocation(program, "projection" ); glUseProgram(program2);// Use the shader program2 model_view2 = glGetUniformLocation(program2, "model_view"); projection2 = glGetUniformLocation(program2, "projection"); glUseProgram(programfire); model_view3 = glGetUniformLocation(programfire, "model_view"); projection3 = glGetUniformLocation(programfire, "projection"); /*--- Set up and pass on Projection matrix to the shader ---*/ mat4 p = Perspective(fovy, aspect, zNear, zFar); glUseProgram(program); glUniformMatrix4fv(projection, 1, GL_TRUE, p); // GL_TRUE: matrix is row-major glUseProgram(program2); glUniformMatrix4fv(projection2, 1, GL_TRUE, p); glUseProgram(programfire); glUniformMatrix4fv(projection3, 1, GL_TRUE, p); /*--- Set up and pass on Model-View matrix to the shader ---*/ // eye is a global variable of vec4 set to init_eye and updated by keyboard() vec4 at(0.0, 0.0, 0.0, 1.0); vec4 up(0.0, 1.0, 0.0, 0.0); glUseProgram(program); mat4 mv = LookAt(eye, at, up); glUniformMatrix4fv(model_view, 1, GL_TRUE, mv); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); drawObj(coordinate_buffer, 9); mat3 normal_matrix; if (LightingFlag==0){ mv = LookAt(eye, at, up)*Translate(move+A)* Rotate(angle, tw.z, 0.0, -tw.x) * Mrotate; glUniformMatrix4fv(model_view, 1, GL_TRUE, mv); if (WireFramFlag==1) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); draw=2; drawObj(sphere_buffer, sphere_numVertices); draw=0; if (shadowFlag==0) { mv = LookAt(eye, at, up); glUniformMatrix4fv(model_view, 1, GL_TRUE, mv); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); draw=1; drawObj(floor_buffer, floor_NumVertices); draw=0; } else { glDepthMask(GL_FALSE); mv = LookAt(eye, at, up); glUniformMatrix4fv(model_view, 1, GL_TRUE, mv); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); draw=1; drawObj(floor_buffer, floor_NumVertices); draw=0; glDepthMask(GL_TRUE); mat4 shadow = mat4(vec4(12, 14, 0, 0), vec4(0, 0, 0, 0), vec4(0, 3, 12, 0), vec4(0, -1, 0, 12)); mv = LookAt(eye, at, up)*shadow*Translate(move+A)* Rotate(angle, tw.z, 0.0, -tw.x) * Mrotate; glUniformMatrix4fv(model_view, 1, GL_TRUE, mv); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); drawObj(shadow_buffer, sphere_numVertices);//draw the shadow glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); mv = LookAt(eye, at, up); glUniformMatrix4fv(model_view, 1, GL_TRUE, mv); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); draw=1; drawObj(floor_buffer, floor_NumVertices); draw=0; glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } }else { if (WireFramFlag==1) {mv = LookAt(eye, at, up)*Translate(move+A)* Rotate(angle, tw.z, 0.0, -tw.x) * Mrotate; glUniformMatrix4fv(model_view, 1, GL_TRUE, mv); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); drawObj(sphere_buffer, sphere_numVertices);} else {glUseProgram(program2); mv = LookAt(eye, at, up); setUp_sphere(mv); if(spotLightFlag==1) setUp_spot_sphere(mv); else setUp_point_sphere(mv); mv = LookAt(eye, at, up)*Translate(move+A)* Rotate(angle, tw.z, 0.0, -tw.x) * Mrotate; normal_matrix = NormalMatrix(mv, 1); glUniformMatrix3fv(glGetUniformLocation(program2, "Normal_Matrix"), 1, GL_TRUE, normal_matrix); glUniformMatrix4fv(model_view2, 1, GL_TRUE, mv); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (smoothFlag==1) { draw=2; drawObj2(smooth_sphere_buffer, sphere_numVertices); draw=0; } else { draw=2; drawObj2(flat_sphere_buffer, sphere_numVertices); draw=0; } } if (shadowFlag==1) { glUseProgram(program2); glDepthMask(GL_FALSE); mv = LookAt(eye, at, up); setUp_floor(mv); if(spotLightFlag==1) setUp_spot_sphere(mv); else setUp_point_floor(mv); normal_matrix = NormalMatrix(mv, 1); glUniformMatrix3fv(glGetUniformLocation(program2, "Normal_Matrix"), 1, GL_TRUE, normal_matrix); glUniformMatrix4fv(model_view2, 1, GL_TRUE, mv); // GL_TRUE: matrix is row-major if (floorFlag == 1) // Filled floor glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); else // Wireframe floor glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); draw=1; drawObj2(shaded_floor_buffer, floor_NumVertices); // draw the floor draw=0; glUseProgram(program); mat4 shadow = mat4(vec4(12, 14, 0, 0), vec4(0, 0, 0, 0), vec4(0, 3, 12, 0), vec4(0, -1, 0, 12)); mv = LookAt(eye, at, up)*shadow*Translate(move+A)* Rotate(angle, tw.z, 0.0, -tw.x) * Mrotate; glUniformMatrix4fv(model_view, 1, GL_TRUE, mv); if (WireFramFlag==1) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (blendingShadowFlag==1) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); draw=2; drawObj(shadow_buffer, sphere_numVertices);//draw the shadow draw=0; glDisable(GL_BLEND); glDepthMask(GL_TRUE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glUseProgram(program2); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); mv = LookAt(eye, at, up); setUp_floor(mv); if(spotLightFlag==1) setUp_spot_sphere(mv); else setUp_point_floor(mv); normal_matrix = NormalMatrix(mv, 1); glUniformMatrix3fv(glGetUniformLocation(program2, "Normal_Matrix"), 1, GL_TRUE, normal_matrix); glUniformMatrix4fv(model_view2, 1, GL_TRUE, mv); // GL_TRUE: matrix is row-major if (floorFlag == 1) // Filled floor glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); else // Wireframe floor glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); draw=1; drawObj2(shaded_floor_buffer, floor_NumVertices); // draw the floor draw=0; glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); }else { glUseProgram(program2); mv = LookAt(eye, at, up); setUp_floor(mv); if(spotLightFlag==1) setUp_spot_sphere(mv); else setUp_point_floor(mv); normal_matrix = NormalMatrix(mv, 1); glUniformMatrix3fv(glGetUniformLocation(program2, "Normal_Matrix"), 1, GL_TRUE, normal_matrix); glUniformMatrix4fv(model_view2, 1, GL_TRUE, mv); // GL_TRUE: matrix is row-major if (floorFlag == 1) // Filled floor glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); else // Wireframe floor glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); draw=1; drawObj2(shaded_floor_buffer, floor_NumVertices); // draw the floor draw=0; } } if (fireworkFlag==1) { mv = LookAt(eye, at, up); glUseProgram(programfire); glUniformMatrix4fv(model_view3, 1, GL_TRUE, mv); drawFireworks(firework_buffer, N); } glutSwapBuffers(); } //--------------------------------------------------------------------------- void idle (void) { AB=AB/sqrt(AB.x*AB.x+AB.y*AB.y+AB.z*AB.z); BC=BC/sqrt(BC.x*BC.x+BC.y*BC.y+BC.z*BC.z); CA=CA/sqrt(CA.x*CA.x+CA.y*CA.y+CA.z*CA.z); if (2*M_PI*sum/360<sqrt(9+64)) { if (zone==3) { Mrotate=Rotate(angle, tw.z, 0.0, -tw.x)*Mrotate; angle=0; } zone=1; tw=AB; move=move+(2*M_PI/360*AB);} else if (2*M_PI*sum/360<sqrt(16+81)+sqrt(9+64)) { if (zone==1) {Mrotate=Rotate(angle, tw.z, 0.0, -tw.x)*Mrotate; angle=0;} zone=2; tw=BC; move=move+(2*M_PI/360*BC);} else if (2*M_PI*sum/360<sqrt(16+81)+sqrt(49+1)+sqrt(9+64)) { if (zone==2) {Mrotate=Rotate(angle, tw.z, 0.0, -tw.x)*Mrotate; angle=0;} zone=3; tw=CA; move=move+(2*M_PI/360*CA);} else sum=sum-(sqrt(16+81)+sqrt(49+1)+sqrt(9+64))*360/(2*M_PI); //angle += 0.02; angle += 1.0; //YJC: change this value to adjust the cube rotation speed. sum +=1.0; time_Old = (float)glutGet(GLUT_ELAPSED_TIME); time_New = fmod(time_Old - time_Sub, time_Max); glutPostRedisplay(); } //---------------------------------------------------------------------------- void keyboard(unsigned char key, int x, int y) { switch(key) { case 033: // Escape Key case 'q': case 'Q': exit( EXIT_SUCCESS ); break; case 'X': eye[0] += 1.0; break; case 'x': eye[0] -= 1.0; break; case 'Y': eye[1] += 1.0; break; case 'y': eye[1] -= 1.0; break; case 'Z': eye[2] += 1.0; break; case 'z': eye[2] -= 1.0; break; case 'b': case 'B': // Toggle between animation and non-animation animationFlag = 1 - animationFlag; avaliable = true; if (animationFlag == 1) glutIdleFunc(NULL); else glutIdleFunc(idle); break; case 'c': case 'C': // Toggle between filled and wireframe cube cubeFlag = 1 - cubeFlag; break; case 'f': case 'F': // Toggle between filled and wireframe floor floorFlag = 1 - floorFlag; break; case ' ': // reset to initial viewer/eye position eye = init_eye; break; case 'v': case 'V': verticalFlag=1; break; case 's': case 'S': verticalFlag=0; break; case 'o': case 'O': eyeSpaceFlag=0; break; case 'e': case 'E': eyeSpaceFlag=1; break; case 'u': case 'U': upLatticeFlag=1; break; case 't': case 'T': upLatticeFlag=0; break; case 'l': case 'L': latticeFlag=1-latticeFlag; break; } glutPostRedisplay(); } //---------------------------------------------------------------------------- void menu(int id) { switch(id) { case 0: eye = init_eye; break; case 1: exit(0); break; } glutPostRedisplay(); } void wireframe_menu(int index) { WireFramFlag= (index == 1)?1:0; display(); } void shadow_menu(int index){ shadowFlag = (index == 1)?1:0; display(); }; /* shade menu handler 1) Flat shade 2) Smooth shade */ void shade_menu(int index){ smoothFlag = (index == 1)?1:0; display(); }; /* lighting menu handler 1) Turn on lighting effect 2) Turn off lighting effect */ void lighting_menu(int index){ LightingFlag = (index == 1)?1:0; display(); }; /* spotlight menu handler 1) Spotlight 2) Point light */ void spotlight_menu(int index){ spotLightFlag = (index == 1)?1:0; display(); }; void fog_menu(int index) { fogFlag=index; display(); } void blending_menu(int index) { blendingShadowFlag=index; display(); } void texture_menu(int index) { textureFlag=index; display(); } void sphere_texture_menu(int index) { sphereTexFlag=index; display(); } void firework_menu(int index) { switch (index) { case 0: fireworkFlag = 0; break; case 1: if (fireworkFlag == 0) { fireworkFlag = 1; time_Old = (float)glutGet(GLUT_ELAPSED_TIME); time_Sub = time_Old; time_New = 0.0f; } break; } display(); } //------------------------------------------------------------------ void addMenu(){ int shadow = glutCreateMenu(shadow_menu); glutAddMenuEntry("No", 0); glutAddMenuEntry("Yes", 1); int shade = glutCreateMenu(shade_menu); glutAddMenuEntry("flat shading", 0); glutAddMenuEntry("smooth shading", 1); int lighting = glutCreateMenu(lighting_menu); glutAddMenuEntry("No", 0); glutAddMenuEntry("Yes", 1); int spotlight = glutCreateMenu(spotlight_menu); glutAddMenuEntry("Spot light", 1); glutAddMenuEntry("Point light", 0); int wireframe=glutCreateMenu(wireframe_menu); glutAddMenuEntry("Yes", 1); glutAddMenuEntry("No", 0); int fog=glutCreateMenu(fog_menu); glutAddMenuEntry("no fog", 0); glutAddMenuEntry("linear", 1); glutAddMenuEntry("exponential", 2); glutAddMenuEntry("exponential square", 3); int blending= glutCreateMenu(blending_menu); glutAddMenuEntry("No", 0); glutAddMenuEntry("Yes", 1); int texture=glutCreateMenu(texture_menu); glutAddMenuEntry("No", 0); glutAddMenuEntry("Yes", 1); int sphereTex=glutCreateMenu(sphere_texture_menu); glutAddMenuEntry("No", 0); glutAddMenuEntry("Yes - Contour Lines", 1); glutAddMenuEntry("Yes - Checkerboard", 2); int firework=glutCreateMenu(firework_menu); glutAddMenuEntry("No", 0); glutAddMenuEntry("Yes", 1); glutCreateMenu(menu); glutAddMenuEntry("Default View Point", 0); glutAddMenuEntry("Quit", 1); glutAddSubMenu("Wire Frame Sphere", wireframe); glutAddSubMenu("Enable Lighting", lighting); glutAddSubMenu("Shadow",shadow); glutAddSubMenu("Shading", shade); glutAddSubMenu("Lighting", spotlight); glutAddSubMenu("Fog Options", fog); glutAddSubMenu("Blending Shadow", blending); glutAddSubMenu("Texture Mapped Ground", texture); glutAddSubMenu("Texture Mapped Sphere", sphereTex); glutAddSubMenu("Firework", firework); glutAttachMenu(GLUT_LEFT_BUTTON); } void myMouse(int button, int state, int x,int y) { if (button == GLUT_RIGHT_BUTTON&&state== GLUT_DOWN&&avaliable==true) animationFlag = 1 - animationFlag; if (animationFlag == 1) glutIdleFunc(NULL); else glutIdleFunc(idle); glutPostRedisplay(); } //---------------------------------------------------------------------------- void reshape(int width, int height) { glViewport(0, 0, width, height); aspect = (GLfloat) width / (GLfloat) height; glutPostRedisplay(); } //---------------------------------------------------------------------------- int main(int argc, char **argv) { int err; filename = chooseFile(); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(512, 512); // glutInitContextVersion(3, 2); // glutInitContextProfile(GLUT_CORE_PROFILE); glutCreateWindow("Assignment4"); /* Call glewInit() and error checking */ #ifndef __APPLE__ err = glewInit(); if (GLEW_OK != err) { printf("Error: glewInit failed: %s\n", (char*) glewGetErrorString(err)); exit(1); } #endif glutDisplayFunc(display); glutReshapeFunc(reshape); glutIdleFunc(NULL); glutKeyboardFunc(keyboard); glutMouseFunc(myMouse); addMenu(); init(); glutMainLoop(); return 0; }
921394c45803d11317b3d18be2aa2d708fa66cae
9f9dcb9b496bd729ad7dd5734ff2f008372adb4d
/main.cpp
0d1ef148baaae8aecaf0d3babad48df46aab2713
[]
no_license
kovach/ptimomtfvcfpsb
2688865c312f6f28a4d0bf6e100e88606adac38b
d080da13fa954542de1b4b8ae5dd71e58b7c821f
refs/heads/master
2016-09-14T06:14:52.619923
2016-05-21T18:27:07
2016-05-21T18:27:07
58,882,598
0
0
null
null
null
null
UTF-8
C++
false
false
22,307
cpp
main.cpp
#include <SFML/Graphics.hpp> #include <SFML/OpenGL.hpp> #include <SFML/System/Vector2.hpp> #include <iostream> #include <sstream> #include <cmath> using namespace std; int maxValuation = 4; string titleString = "PETER THIEL IS MADE OF MONEY\nA VC Fueled Post-Singularity Brawler\n\nPRESS A TO START"; sf::Color valuationColors[] = { sf::Color::Red, sf::Color(255,128,0,255), sf::Color(200,188,0,255), sf::Color::Yellow, sf::Color::Green }; vector<vector<string> > valuations; void initValuationNames() { for (int i = 0; i < maxValuation+1; i++) valuations.push_back(vector<string>()); valuations[0].push_back("ACQUIHIRED"); valuations[0].push_back("DREAMS CRUSHED"); valuations[0].push_back("FLATTENED BY INVISIBLE HAND"); valuations[0].push_back("\"AHEAD OF ITS TIME\""); valuations[1].push_back("REALITY SETS IN"); valuations[1].push_back("2-MONTH RUNWAY"); valuations[1].push_back("BURNOUT"); valuations[2].push_back("USELESS PRODUCT"); valuations[2].push_back("PIVOT"); valuations[2].push_back("REFUTED BY SCIENCE"); valuations[3].push_back("CTO LEFT"); valuations[3].push_back("SERIES A"); valuations[3].push_back("DOMAIN NAME TAKEN"); valuations[4].push_back("GREAT IDEA!"); valuations[4].push_back("BOUNDLESS OPTIMISM"); valuations[4].push_back("I'M GONNA LIVE FOREVER!"); } float strike(float t) { if (t < 0.25) return t/0.25; if (t < 0.5) return 1-(t-0.25)/0.5; return 0.5 - (t-.5)/(1-.5) * .5; } float sign(float x) { if (x > 0.f) return 1; return -1; } sf::Vector2f normalize(sf::Vector2f v) { float r = sqrt(v.x*v.x+v.y*v.y); if (r < 0.05f) return sf::Vector2f(0.f,0.f); return sf::Vector2f(v.x/r, v.y/r); } float clamp(float min, float max, float v) { if (v > max) return max; if (v < min) return min; return v; } float getJoyX(int id) { float v; v = sf::Joystick::getAxisPosition(id, sf::Joystick::X); v = sign(v) * fmax(0.f, fabs(v)-20.f) * 1.25f; return v/100.f; } float getJoyY(int id) { float v; v = sf::Joystick::getAxisPosition(id, sf::Joystick::Y); v = sign(v) * fmax(0.f, fabs(v)-20.f) * 1.25f; return v/100.f; } bool getJumpButton(int id) { return sf::Joystick::isButtonPressed(id, 2) || sf::Joystick::isButtonPressed(id, 3); } //bool getDodgeButton(int id) //{ // return sf::Joystick::isButtonPressed(id, 3); //} int getAttackButton(int id) { return sf::Joystick::isButtonPressed(id, 0); } int getStartButton(int id) { //return sf::Joystick::isButtonPressed(id, 7); return sf::Joystick::isButtonPressed(id, 0); } int getSelectButton(int id) { //return sf::Joystick::isButtonPressed(id, 6); return sf::Joystick::isButtonPressed(id, 0); } int getGrabButton(int id) { return sf::Joystick::isButtonPressed(id, 1); } enum Direction { None, Left, Right }; Direction getLungeButton(int id) { if (sf::Joystick::isButtonPressed(id, 4)) return Left; if (sf::Joystick::isButtonPressed(id, 5)) return Right; return None; } //string joystickState() //{ // bool connected = sf::Joystick::isConnected(0); // unsigned int buttons = sf::Joystick::getButtonCount(0); // bool hasX = sf::Joystick::hasAxis(0, sf::Joystick::X); // bool pressed = sf::Joystick::isButtonPressed(0, 2); // float position = sf::Joystick::getAxisPosition(0, sf::Joystick::Y); // std::ostringstream s; // // for (int c = 0; c < buttons; c++) { // s << "button " << c << " " << sf::Joystick::isButtonPressed(0, c) << endl; // } // s << "attack " << getAttackButton(id) << endl; // s << "grab " << getGrabButton(id) << endl; // return s.str(); //} string joystickPositions() { std::ostringstream s; s << "joystick: " << "position: " << sf::Joystick::getAxisPosition(0, sf::Joystick::X) << endl << "position: " << sf::Joystick::getAxisPosition(0, sf::Joystick::Y) << endl << "position: " << sf::Joystick::getAxisPosition(0, sf::Joystick::Z) << endl << "position: " << sf::Joystick::getAxisPosition(0, sf::Joystick::R) << endl << "position: " << sf::Joystick::getAxisPosition(0, sf::Joystick::U) << endl << "position: " << sf::Joystick::getAxisPosition(0, sf::Joystick::V) << endl; return s.str(); } enum JumpState { Ground, Crouching, Floating }; string JumpStates[] = { "Ground", "Crouching", "Floating" }; enum LungeState { Ready, Striking_Left, Striking_Right, Recovery }; string LungeStates[] = { "Ready", "Striking_Left", "Striking_Right", "Recovery" }; enum AttackState { AS_Ready, AS_Striking, AS_Grabbing }; string AttackStates[] = { "AS_Ready", "AS_Striking", "AS_Grabbing" }; enum MotionState { MS_Free, MS_Struck }; string MotionStates[] = { "MS_Free", "MS_Struck" }; enum GameState { GS_Starting, GS_Playing, GS_Ending }; string GameStates[] = { "GS_Starting", "GS_Playing", "GS_Ending" }; // todo needed? //enum JumpEdge { // StopJump, StartJump, NoEdge //}; const int fps = 60; const float groundLevel = 750.; class ControlState { public: int id; JumpState jump; LungeState lunge; AttackState attack; MotionState motion; // Main state sf::Vector2f p; sf::Vector2f v; float radius; int valuation; string valuationLabel; bool dead; bool hasHit; sf::Vector2f arm; sf::Vector2u windowDim; // State machine timing state int crouchDuration; int lungeDuration; int attackDuration; int struckDuration; sf::Vector2f attackStart; sf::Vector2f attackEnd; // State machine parameters const static float maxCrouch = fps/10; const static float maxLunge = fps/12; const static float maxRecovery = fps/6; const static float maxAttack = fps*5/6; const static float maxStruck = fps/4; // General Parameters const static float maxVertical = 2200; const static float maxHorizontal = 2200; const static float maxDodgeHorizontal = 7000; const static float gravity = 15000.f; const static float jumpForce = 250000.f; const static float attackRange = 1800.f; const static float strikeForce = 1820.f; ControlState(sf::Vector2u dim) { windowDim = dim; radius = 200.; reset(); } void reset() { jump = Floating; resetJump(); resetLunge(); resetAttack(); resetMotion(); dead = false; p.x = 0.f; p.y = 0.f; v.x = 0.f; v.y = 0.f; //valuation = 0; valuation = maxValuation; updateValuationLabel(); initX(windowDim.x); } void initX(int max) { if (id == 0) p.x = 100.f + radius; else p.x = max - 100.f - radius; } void resetJump() { jump = Ground; crouchDuration = 0; } void resetLunge() { lunge = Ready; lungeDuration = 0; } void resetAttack() { attack = AS_Ready; attackDuration = 0; } void resetMotion() { motion = MS_Free; struckDuration = 0; } void initiateAttack() { hasHit = false; sf::Vector2f vec(getJoyX(id), getJoyY(id)); float r = sqrt(vec.x*vec.x+vec.y*vec.y); attackStart = getCenter(); if (r < 0.05f) attackEnd = attackStart; else attackEnd = attackStart + vec / r * attackRange; } sf::Vector2f getCenter() { return p+sf::Vector2f(-18,120); } void stateUpdate() { // Update jump if (getJumpButton(id)) { if (jump == Ground || jump == Floating) { jump = Crouching; crouchDuration = 0; } if (jump == Crouching && crouchDuration > maxCrouch) { jump = Floating; } } else { if (jump == Crouching) jump = Floating; } crouchDuration++; // Update lunge Direction action = getLungeButton(id); switch (lunge) { case Ready: if (action == Left) lunge = Striking_Left; if (action == Right) lunge = Striking_Right; lungeDuration = 0; break; case Striking_Left: case Striking_Right: if (lungeDuration > maxLunge) lunge = Recovery; break; case Recovery: if (lungeDuration > maxRecovery) resetLunge(); break; } lungeDuration++; // Update attack switch (attack) { case AS_Ready: if (getAttackButton(id)) { attack = AS_Striking; } if (getGrabButton(id)) { attack = AS_Grabbing; } initiateAttack(); attackDuration = 0; arm = getCenter(); break; case AS_Striking: case AS_Grabbing: if (attackDuration > maxAttack) resetAttack(); else { float t = (float)attackDuration / maxAttack; float r = strike(t); sf::Vector2f p1 = attackStart * (1.f - r) + attackEnd * r; sf::Vector2f p2 = p1 * (1.f - t) + getCenter() * t; arm = p2; } break; } attackDuration++; switch (motion) { case MS_Free: struckDuration = 0; break; case MS_Struck: if (struckDuration++ > maxStruck) { resetMotion(); } break; } } void updateVelocity(float dt) { sf::Vector2f newV = v; // Horizontal joystick float dvx = getJoyX(id) * 500.f; if (jump == Crouching || jump == Floating) dvx /= 3; if (motion == MS_Struck) dvx /= 3; newV.x += dvx; if (motion == MS_Free) newV.x = clamp (-maxHorizontal, maxHorizontal, newV.x); if (motion == MS_Free) { switch(jump) { //case Ground: // if (lunge == Ready) { // //newV.x = getJoyX() * 2500; // facing = sign(newV.x); // } // //vy -= gravity * dt; // newV.y = 0.; // break; case Crouching: newV.y += jumpForce * dt; newV.y = clamp (-maxVertical, maxVertical, newV.y); break; } } newV = applyGravity(newV, dt); switch(lunge) { case Ready: break; case Striking_Left: if (motion == MS_Free) newV.x = -maxDodgeHorizontal * strike((float)lungeDuration/maxRecovery); break; case Striking_Right: if (motion == MS_Free) newV.x = maxDodgeHorizontal * strike((float)lungeDuration/maxRecovery); break; case Recovery: //vx = sign(vx) * maxHorizontal * strike(lungeDuration/maxRecovery); break; } switch (motion) { case MS_Free: v = newV; v.x *= 0.9; // todo break; case MS_Struck: v = newV; break; } } sf::Vector2f applyGravity(sf::Vector2f v, float dt) { if ((jump == Floating || jump == Ground) && motion == MS_Free) v.y -= gravity * dt; if (lunge == Striking_Right || lunge == Striking_Left) v.y = 0.; return v; } void update(float dt) { stateUpdate(); updateVelocity(dt); p.x += dt * v.x; p.y -= dt * v.y; if (p.y > groundLevel) { resetJump(); p.y = groundLevel; v.y = 0; } } string toString(float time) { std::ostringstream s; s << JumpStates[jump] << endl << LungeStates[lunge] << endl << AttackStates[attack] << endl << MotionStates[motion] << endl; return s.str(); } void updateValuationLabel() { valuationLabel = valuations[valuation][rand() % valuations[valuation].size()]; } void decrementValuationLabel() { valuation--; if (valuation < 0) { dead = true; valuation = 0; } updateValuationLabel(); } void doHit(ControlState &target) { if (hasHit) return; hasHit = true; //if (target.motion == MS_Struck) // return; sf::Vector2f v = arm - p; v = normalize(v) * strikeForce; v.y = -v.y; switch(attack) { case AS_Ready: return; case AS_Striking: v += sf::Vector2f(0, 1200.f); break; case AS_Grabbing: v = -v; break; } target.motion = MS_Struck; target.decrementValuationLabel(); target.v = v; } }; bool collision(ControlState &s1, ControlState &s2) { sf::Vector2f v; // P2 hits P1 v = s1.p - s2.arm; if (v.x*v.x + v.y*v.y < s1.radius*s1.radius) { s2.doHit(s1); } // P1 hits P2 v = s2.p - s1.arm; if (v.x*v.x + v.y*v.y < s2.radius*s2.radius) { s1.doHit(s2); } return false; } class Char : public sf::Drawable { public: sf::Vector2u windowDim; ControlState controller; sf::Font s_font; sf::Text m_text; sf::Shader m_shader; sf::Texture m_texture; sf::Sprite m_sprite; Char(int myid, sf::Vector2u dim, bool showText) : controller(dim) { controller.id = myid; if (!s_font.loadFromFile("noto.ttf")) exit(22); m_text.setFont(s_font); windowDim = dim; if (!m_texture.loadFromFile("pt-crop.jpg")) exit(23); m_sprite.setTexture(m_texture); m_sprite.setScale(0.5f, 0.5f); //m_sprite.setPosition(300, 300); // Load the shader if (!m_shader.loadFromFile("text.frag", sf::Shader::Fragment)) exit(22); m_shader.setParameter("texture", sf::Shader::CurrentTexture); reset(); } virtual ~Char() { } void reset() { m_text.setCharacterSize(60); m_text.setColor(sf::Color(0,255,0,255)); // Game state controller.reset(); } void update(float time) { float dt = 1.0/60; controller.update(dt); m_sprite.setPosition(controller.p.x-controller.radius, controller.p.y-controller.radius); m_text.setColor(valuationColors[controller.valuation]); m_text.setString(controller.valuationLabel); sf::FloatRect bounds = m_text.getLocalBounds(); float x; float offset = 120.f; if (controller.id == 0) x = offset; else x = windowDim.x - bounds.width - offset; m_text.setPosition(x, windowDim.y-150.f); std::ostringstream s; if (dt > 0.018f) { cout << dt << endl; exit(20); } s << 1./dt << endl // << joystickState() << endl << state() << endl << controller.toString(time) << endl; sf::Color mainColor = valuationColors[controller.valuation]; m_shader.setParameter("shading", mainColor.r/255.f, mainColor.g/255.f, mainColor.b/255.f); //m_text.setString(s.str()); } void drawArm(sf::RenderTarget& target, sf::RenderStates states) const { float x = controller.arm.x; float y = controller.arm.y; float r = 32.f; sf::CircleShape shape(r); sf::Text dollar; dollar.setString("$"); if (controller.attack == AS_Ready) shape.setFillColor(sf::Color(0,204,102,255)); else if (controller.attack == AS_Striking) shape.setFillColor(sf::Color(255,0,0,255)); else if (controller.attack == AS_Grabbing) shape.setFillColor(sf::Color(255,128,0,255)); shape.setPosition(x-r, y-r); target.draw(shape); dollar.setPosition(x-r+15, y-r-8); dollar.setCharacterSize(60); dollar.setColor(sf::Color::White); dollar.setFont(s_font); target.draw(dollar); } void drawStatus(sf::RenderTarget& target, sf::RenderStates states) const { } void draw(sf::RenderTarget& target, sf::RenderStates states) const { target.draw(m_text, states); states.shader = &m_shader; target.draw(m_sprite, states); states.shader = NULL; float x = controller.p.x; float y = controller.p.y; float r = controller.radius; sf::CircleShape shape(r); shape.setFillColor(sf::Color(0,222,0,128)); shape.setPosition(x-r, y-r); //target.draw(shape); drawArm(target, states); } string state() { std::ostringstream s; s << "x: " << controller.p.x << endl << "y: " << controller.p.y << endl << "vx: " << controller.v.x << endl << "vy: " << controller.v.y << endl; return s.str(); } //static const sf::Font* s_font; //static void setFont(const sf::Font& font) //{ // s_font = &font; //} }; class Game : public sf::Drawable { public: sf::Font s_font; sf::Text m_text; GameState state; Char thing1; Char thing2; int endDuration; int endRate; int dying; bool restartButtonDown; sf::Vector2u windowDim; Game(sf::Vector2u dim) : thing1(0, dim, true), thing2(1, dim, false) { windowDim = dim; // Graphics state if (!s_font.loadFromFile("noto.ttf")) exit(22); m_text.setFont(s_font); endRate = 60*10; resetGame(); } void resetGame() { // Title text m_text.setString(titleString); m_text.setCharacterSize(100); m_text.setColor(sf::Color(0,255,0,255)); sf::FloatRect bounds = m_text.getLocalBounds(); m_text.setPosition(windowDim.x/2 - bounds.width/2., windowDim.y/2-bounds.height/2); // Game transition state state = GS_Starting; dying = -1; endDuration = 0; restartButtonDown = true; // Char state thing1.reset(); thing2.reset(); } void checkDeath() { if (thing1.controller.dead) dying = 0; if (thing2.controller.dead) dying = 1; if (dying != -1) { state = GS_Ending; restartButtonDown = true; update(); } } void updatePixelation(float r) { // TODO } void update() { switch(state) { case GS_Starting: if (getStartButton(0) || getStartButton(1)) { if (!restartButtonDown) state = GS_Playing; } else restartButtonDown = false; break; case GS_Playing: thing1.update(0); thing2.update(0); collision(thing1.controller, thing2.controller); checkDeath(); break; case GS_Ending: endDuration++; float r = (float)endDuration / endRate; sf::Text *t = (dying == 0) ? &thing1.m_text : &thing2.m_text; m_text.setString(t->getString()); m_text.setColor(sf::Color(255,0,0,255)); m_text.setCharacterSize((1.-r) * 40 + r * 300); sf::FloatRect bounds = m_text.getLocalBounds(); sf::Vector2f targetPos(windowDim.x/2. - bounds.width/2., windowDim.y/2.-bounds.height/2.); sf::Vector2f p = 2*r*targetPos + (1.f-2.f*r) * t->getPosition(); updatePixelation(r); m_text.setPosition(p.x, p.y); if (getSelectButton(0) || getSelectButton(1)) { if (!restartButtonDown) resetGame(); } else restartButtonDown = false; break; } } void draw(sf::RenderTarget& target, sf::RenderStates states) const { switch(state) { case GS_Starting: target.draw(m_text); break; case GS_Playing: target.draw(thing1); target.draw(thing2); break; case GS_Ending: target.draw(m_text); break; } } }; void mainUpdate(Char &t1, Char &t2) { t1.update(0); t2.update(0); // updateoverlay collision(t1.controller, t2.controller); } int main() { srand(time(0)); sf::RenderWindow window(sf::VideoMode(2560, 1440), "lol"); glViewport(0, 0, 2560, 1440); window.setFramerateLimit(fps); initValuationNames(); sf::Vector2u dim = window.getSize(); //sf::RectangleShape ground; //ground.setSize(sf::Vector2f(dim.x, 22)); //ground.setPosition(0.,groundLevel); //ground.setFillColor(sf::Color(255,128,0,255)); Game game(dim); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { //std::cout << c++ << "!\n"; if (event.type == sf::Event::Closed) window.close(); } game.update(); window.clear(); window.draw(game); window.display(); // this tries to enforce the frame limit } window.close(); return 0; }
40f7aa95cdd7f748720d164114d8a6ddecf7a98a
e1dfab36813f54341e7c5418923b23c7a67e7992
/collision.cpp
85d08cbb332c39c7e8cb2a059d37ff7de5b3a350
[]
no_license
bennettliu/20questions
f3398d1ff5e2cdbe61a45b959db669a5e11a2c4b
4aeb59efccfb0d3db3bdb828f81cc14f61d28415
refs/heads/master
2020-04-11T07:06:43.908909
2018-12-13T07:37:22
2018-12-13T07:37:22
161,601,438
0
0
null
null
null
null
UTF-8
C++
false
false
2,519
cpp
collision.cpp
/* * Authored by Bennett Liu on October 22nd, 2018 * collisions.cpp checks for animals with the same characteristics in the data provided in Animals.csv */ #include <iostream> #include <cstdio> #include <vector> #include <algorithm> using namespace std; int main() { //Create and initialize all needed variables int n, curDiff, diff; cout << "How many animals are there? "; cin >> n; cout << "How many differences are you looking for? "; cin >> diff; string inputString, tmp; vector<string> characteristics = vector<string>(); vector<string> animal[n]; fill(animal, animal + n, vector<string>()); //Begin reading the CSV freopen("Animals.csv","r",stdin); //Read all characteristic names into characteristics getline(cin,inputString); for (int i = 1; i < inputString.length() - 1; i++) { if (inputString[i] == ',') { characteristics.push_back(tmp); tmp = ""; } else tmp += inputString[i]; } characteristics.push_back(tmp); //Read all characteristic questions into questions getline(cin,inputString); //Read all animals and their qualities into animal for (int i = 0; i < n; i++) { getline(cin,inputString); int j = 1; animal[i].push_back(""); if ('a' <= inputString[0]) animal[i][0] += char(inputString[0] + 'A' - 'a'); else animal[i][0] += inputString[0]; for (; j < inputString.length() - 1 && inputString[j] != ','; j++) { animal[i][0] += inputString[j]; } j++; for (int k = 0; k < characteristics.size(); k++, j+=2) { if (j < inputString.length() && (inputString[j] == 'Y' || inputString[j] == 'N' || inputString[j] == '?')) { animal[i].push_back(inputString.substr(j,1)); } else { cout << "Error at " << animal[i][0] << ": " << characteristics[k] << endl; } } } //Count differences for each pair and output pair if cur<=diff for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { curDiff = 0; for (int k = 1; k < characteristics.size(); k++) { if ((animal[i][k] == "Y" && animal[j][k] == "N") || (animal[i][k] == "N" && animal[j][k] == "Y")) curDiff++; } if (curDiff <= diff) { cout << curDiff << " Differences between " << animal[i][0] << " and " << animal[j][0] << endl; } } } return 0; }
4dc0aad00606328d20aad561b5760f3330fe5592
a3e1a101673c56e4ced1b5600612b25b145eb472
/beakjoon_algorithm/beakjoon_algorithm/CodingTestExam/String_tokenizer.cpp
2e237df8a1c9fbca4b3f80c7fa495df5ee3d2434
[]
no_license
gwanhyeon/algorithm_study
a95f3f2d559899f734b52d2d6e89d5f0125cebdf
f01af94919946e5adbdd7cb688cc2c1cf54cbbdc
refs/heads/master
2022-01-07T21:34:56.297147
2021-12-29T16:02:02
2021-12-29T16:02:02
162,471,977
0
0
null
null
null
null
UTF-8
C++
false
false
406
cpp
String_tokenizer.cpp
// // String_tokenizer.cpp // beakjoon_algorithm // // Created by kgh on 06/03/2019. // Copyright © 2019 kgh. All rights reserved. // // substr은 거기부터 시작해서 몇개인지 여부 #include <stdio.h> #include <iostream> #include <string> using namespace std; int main(void){ string str ="ABCDEFG"; cout << str.substr(2,1) << endl; return 0; }
af00fc3164ae97c48a2f469237ae01c4f96a79de
07ba7fde9da83edd3744557972b4b411af1b577d
/src/buzecommon/PresetManager.cpp
9c926b84507f6aa48235d1c00bd49ef78e964613
[]
no_license
clvn/buze
d10edad5b319ca62c1401e710acedc22897b9027
4d7d406e87bda3b57b7631149fe63f9bd2ac3eec
refs/heads/master
2021-09-16T01:39:40.697834
2018-01-06T15:45:28
2018-01-06T15:45:28
115,177,320
8
1
null
null
null
null
WINDOWS-1252
C++
false
false
3,650
cpp
PresetManager.cpp
/* This file is part of the Buzé base Buzz-library. Please refer to LICENSE.TXT for details regarding usage. */ #include <windows.h> #include <string> #include <vector> #include <cassert> #include "presetmanager.h" #include "FileReader.h" using namespace std; PresetManager::PresetManager() { } size_t PresetManager::getPresetCount() { return presets.size(); } PresetInfo& PresetManager::getPreset(size_t index) { assert(index < presets.size()); return presets[index]; } int PresetManager::findPreset(std::string name) { for (int i = 0; i < presets.size(); i++) if (presets[i].name == name) return i; return -1; } bool PresetManager::save(std::string fileName) { FileWriter writer; if (!writer.create(fileName.c_str())) return false; // NOTE: version 2 presets are buze-only. // buzz only supports version 1 and will refuse to load presets saved in buze. unsigned int version = 2; writer.write(version); writer.write((unsigned int)machineName.length()); writer.writeString(machineName); writer.write((unsigned int)presets.size()); for (size_t i=0; i<presets.size(); i++) { PresetInfo& preset = presets[i]; writer.write((unsigned int)preset.name.size()); writer.writeString(preset.name); writer.write(preset.tracks); writer.write(preset.parameters); for (int j = 0; j<preset.parameters; j++) { writer.write(preset.values[j]); } writer.write((unsigned int)preset.comment.size()); writer.writeString(preset.comment); if (version > 1) { unsigned int size = preset.savedata.size(); writer.write(size); if (size > 0) writer.writeBytes(&preset.savedata[0], size); } } writer.close(); presetFile = fileName; return true; } bool PresetManager::load(std::string fileName) { presets.clear(); FileReader reader; if (!reader.open(fileName.c_str())) return false; unsigned int version, len; reader.read(&version); if (!(version == 1 || version == 2)) { reader.close(); return false; } reader.read(&len); char* machineName=new char[len+1]; reader.readBytes(machineName, len); machineName[len]=0; this->machineName = machineName; delete[] machineName; unsigned int presetCount; reader.read(&presetCount); // parameters*4 ?? antall presets? for (size_t j=0; j<presetCount; j++) { reader.read(&len); char* presetName=new char[len+1]; reader.readBytes(presetName, len); presetName[len]=0; PresetInfo preset; memset(&preset, 0, sizeof(PresetInfo)); preset.name=presetName; delete[] presetName; reader.read(&preset.tracks); reader.read(&preset.parameters); if (preset.parameters>=1024) { #if defined(_WIN32) MessageBox(0, "Unexpected many preset parameters. Will now begin trashing memory", "Alert alert!", MB_OK); #else printf("Unexpected many preset parameters. Will now begin trashing memory\n"); #endif } int value; for (size_t i=0; i<preset.parameters; i++) { if (!reader.read(&value)) { reader.close(); return false; } if (i<1024) preset.values[i]=value; } // read preset comment reader.read(&len); presetName=new char[len+1]; reader.readBytes(presetName, len); presetName[len]=0; preset.comment = presetName; delete[] presetName; if (version > 1) { // read machine data unsigned int size; reader.read(&size); preset.savedata.resize(size); if (size > 0) reader.readBytes(&preset.savedata[0], size); } presets.push_back(preset); } reader.close(); presetFile = fileName; return true; } void PresetManager::add(PresetInfo pi) { presets.push_back(pi); } void PresetManager::remove(size_t index) { presets.erase(presets.begin() + index); }
6ee313a63505ce6a005d8ae04dfee0732fd917af
318359fab659766e7a7a2eb9595c42e079a098a2
/cliques/algorithms/neighbourhood.h
56aed4b32330216815bcfc3b9b1ca0e3d28e9fa8
[]
no_license
zenna/cliques
4bb74d9be36f6c66187f616ce71cb318deb98b11
e260394a6b1dd592d1de69b56b173a8d96c248c6
refs/heads/master
2021-03-24T09:14:15.916808
2014-11-25T09:45:25
2014-11-25T09:45:25
3,921,836
0
0
null
null
null
null
UTF-8
C++
false
false
3,423
h
neighbourhood.h
#pragma once namespace clq { /** @brief Find all (single node moveset) neighbours of a partition Finds neighbours of a partition where a neighbour is a partition which can be created by moving one node into an adjacent group or by isolating it into its own group. Basic algorithm: Iterate through edges, for each node u, v of edge: If moving the node (or isolation) would not break the partition: 1. Isolate it 2. If u and v are not in the same set, move u to v's set @param[in] all_partitons reference to unordered set of partitions @param[out] space output graph representing the space //TODO: This can return (and does) return the same partition as a neighbour * Needs to be fixed. This happens for example in a set of singletons, because * isolating a node would not break a partition */ template<typename G, typename P> std::unordered_set<P, clq::partition_hash, clq::partition_equal> find_neighbours( G const &graph, P const &partition, bool allow_disconnected = true) { typedef typename G::EdgeIt EdgeIt; typedef typename G::Node Node; std::unordered_set<P, clq::partition_hash, clq::partition_equal> neighbour_partitions; for (EdgeIt edge(graph); edge != lemon::INVALID; ++edge) { Node n1 = graph.u(edge); Node n2 = graph.v(edge); int n1_id = graph.id(n1); int n2_id = graph.id(n2); int set_of_n1 = partition.find_set(n1_id); int set_of_n2 = partition.find_set(n2_id); bool are_in_same_set = (set_of_n1 == set_of_n2); // Add partition with n1 isolated and in n2's set // Avoid using too much memory, destroy temp_partiton after use if (allow_disconnected || will_move_break_partition(graph, partition, n1) == false) { P temp_partition = partition; temp_partition.unassign_node(n1_id); temp_partition.normalise_ids(); neighbour_partitions.insert(temp_partition); if (!are_in_same_set) { P temp_partition = partition; temp_partition.add_node_to_set(n1_id, set_of_n2); temp_partition.normalise_ids(); neighbour_partitions.insert(temp_partition); } } if (allow_disconnected || will_move_break_partition(graph, partition, n2) == false) { P temp_partition = partition; temp_partition.unassign_node(n2_id); temp_partition.normalise_ids(); neighbour_partitions.insert(temp_partition); if (!are_in_same_set) { P temp_partition = partition; temp_partition.add_node_to_set(n2_id, set_of_n1); temp_partition.normalise_ids(); neighbour_partitions.insert(temp_partition); } } } return neighbour_partitions; } /** @brief Same as find_neighbours, but converts to stl vector */ template<typename G, typename P> std::vector<P> find_neighbours_vec( G const &graph, P const &partition) { typedef typename G::EdgeIt EdgeIt; typedef typename G::Node Node; auto neighbour_partitions = find_neighbours(graph, partition); // Convert to vector std::vector<P> neighbour_partitions_vec; for (P neighbour : neighbour_partitions) { neighbour_partitions_vec.push_back(neighbour); } return neighbour_partitions_vec; } }
73012812cfb570ff0295f9a2a7bfd789b73d7286
a9737652983dcb5b00af1cda699df8cb9780eef9
/assets/code/usaco/3-1-4.cpp
dcd88c55d51ada85562ffd06ae65dee516263d0b
[]
no_license
acshiryu/acshiryu.github.io
d46594717253b76937db5fd7a565ea060b1c1a30
766d463e2620554300f22546eaed35d0dde8e564
refs/heads/master
2020-03-28T18:54:44.704006
2019-12-07T08:50:48
2019-12-07T08:50:48
27,806,445
0
0
null
null
null
null
UTF-8
C++
false
false
1,214
cpp
3-1-4.cpp
/* ID:shiryuw1 PROG:rect1 LANG:C++ */ #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int ans[2505]={0}; struct prog{ int llx,lly,urx,ury,color; }rect[1005]; int area; void DFS(int lx,int ly,int rx,int ry,int t) { if(t==0) return ; if(rect[t].llx>=rx||rect[t].lly>=ry||rect[t].urx<=lx||rect[t].ury<=ly) { DFS(lx,ly,rx,ry,t-1); } else { int k1,k2,k3,k4; k1=max(lx,rect[t].llx); k2=min(rx,rect[t].urx); if(lx<k1) DFS(lx,ly,k1,ry,t-1); if(rx>k2) DFS(k2,ly,rx,ry,t-1); k3=max(ly,rect[t].lly); k4=min(ry,rect[t].ury); if(ly<k3) DFS(k1,ly,k2,k3,t-1); if(ry>k4) DFS(k1,k4,k2,ry,t-1); //cout<<k1<<' '<<k2<<' '<<k3<<' '<<k4<<endl; ans[rect[t].color]+=abs(k2-k1)*abs(k4-k3); area-=abs(k2-k1)*abs(k4-k3); } } int main() { freopen("rect1.in","r",stdin); freopen("rect1.out","w",stdout); int a,b,n; scanf("%d%d%d",&a,&b,&n); int i,j; memset(ans,0,sizeof(ans)); for(i=1;i<=n;i++) scanf("%d%d%d%d%d",&rect[i].llx,&rect[i].lly,&rect[i].urx,&rect[i].ury,&rect[i].color); area=a*b; DFS(0,0,a,b,n); ans[1]+=area; for(i=1;i<2505;i++) if(ans[i]) printf("%d %d\n",i,ans[i]); return 0; }
2d60a153388f45092313186dba57102d176a33e4
2d04881d317a358c9215b82e4744806d330ba40c
/.tutorials/zetcode.com_sources/05_Events_in_wxWidgets/01_A_simple_event_example_(Event_table)/button.cpp
1be2ed167a3351b0f0d02d489d4c76ab0c98b93f
[ "CC0-1.0" ]
permissive
Y2Kill/VSCode-wxWidgets-MinGW-W64-template
2035f935b3262b7f5c12053e9267cf41c64301f8
6263a547ddb54b6a2fd4fb0836c91b790f8980d7
refs/heads/main
2023-06-24T09:56:24.878103
2021-07-19T14:06:02
2021-07-19T14:06:02
386,356,736
0
0
null
null
null
null
UTF-8
C++
false
false
473
cpp
button.cpp
#include "button.h" MyButton::MyButton(const wxString& title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(270, 150)) { wxPanel *panel = new wxPanel(this, wxID_ANY); wxButton *button = new wxButton(panel, wxID_EXIT, wxT("Quit"), wxPoint(20, 20)); Centre(); } void MyButton::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(true); } BEGIN_EVENT_TABLE(MyButton, wxFrame) EVT_BUTTON(wxID_EXIT, MyButton::OnQuit) END_EVENT_TABLE()
ae3104c0f1a1e18be790e9d24fb3cf11ab290976
ece426c1b6def615feeec9dcfd4ec5611f7f49bd
/exercises/ex2/GameOfLife/GameOfLife/Effect3.h
994e3941edfaa693e104bfda2f9cab81552e078e
[]
no_license
fcin/JiPPP
3011e37a48da7b4500098121b68b635848d90777
05042b08da5b37193e4b62377255943177d45c45
refs/heads/master
2020-04-08T08:03:59.748708
2019-01-18T18:24:36
2019-01-18T18:24:36
159,163,627
0
0
null
null
null
null
UTF-8
C++
false
false
288
h
Effect3.h
#ifndef EFFECT3_H #define EFFECT3_H #include "Board.h" #include "Effect.h" #include <vector> class Effect3 : public Effect { public: Effect3(); virtual void apply(const Board** boards, unsigned int x, unsigned int y, unsigned int dx, unsigned int dy, int boardId) override; }; #endif
90c3d59c48d093c09458ff3996c059f45d4a37e0
114d28dda688013551be7f5632168ca293ab9d08
/contests/9/GreedyKnapsack/ReadWriter.h
b4ba9e30874f0dfd58ff2fea945dc011311ce95c
[]
no_license
zilzilok/sharaga_ads
4f342347f0fd706c77fbb5285159bd94fda7a67c
a5b3dadf186a5ae99ae88c9b011280ccc9de963e
refs/heads/master
2023-05-27T21:50:47.977763
2021-06-06T21:17:38
2021-06-06T21:17:38
244,006,512
5
1
null
null
null
null
UTF-8
C++
false
false
2,009
h
ReadWriter.h
#include <iostream> #include <fstream> #include <string> #include <vector> #include <algorithm> bool comp(std::pair<int, int>& left, std::pair<int, int>& right) { if (left.first != right.first) return left.first > right.first; return left.second > right.second; } class ReadWriter { private: std::fstream fin; std::fstream fout; public: ~ReadWriter() { fin.close(); fout.close(); } ReadWriter() { fin.open("input.txt", std::ios::in); fout.open("output.txt", std::ios::out); } // read 1 int value and empty line int readInt() { if (!fin.is_open()) throw std::ios_base::failure("file not open"); int n; fin >> n; //empty line read std::string s; std::getline(fin, s); return n; } //read data in arr, arr should be initialized before this method void readArr(std::pair<int, int>* arr, int n) { if (!fin.is_open()) throw std::ios_base::failure("file not open"); std::string s; //weight for (int i = 0; i < n; i++) fin >> arr[i].first; std::getline(fin, s); //read empty line //cost for (int i = 0; i < n; i++) fin >> arr[i].second; } //write vector<pair<int, int>> results void writeVector(std::vector<std::pair<int, int>>& res) { if (!fout.is_open()) throw std::ios_base::failure("file not open"); //sort vector to have the same answer std::sort(res.begin(), res.end(), comp); //write weight for (int i = 0; i < res.size(); i++) fout << res[i].first << " "; fout << "\n"; //write cost for (int i = 0; i < res.size(); i++) fout << res[i].second << " "; } void writeInt(int a) { if (!fout.is_open()) throw std::ios_base::failure("file not open"); fout << a << "\n"; } };
5ab491fc6b200eed2aae29776880039af5d4383b
f8d89506738959775ca8dbe3610b410621ddffe8
/Status.h
686c1ba97f52feb9daec66f6721b1c512adf0922
[]
no_license
quitesb/Projeto-INF112
13599704f98637bc28fb557bcc77bcbfbff49145
5a6d11a7b3e78ef10e9ecea78a6e0fdf5329b302
refs/heads/master
2023-06-12T10:46:34.976704
2021-07-08T14:01:37
2021-07-08T14:01:37
384,139,641
0
0
null
null
null
null
UTF-8
C++
false
false
369
h
Status.h
#ifndef TEAM_3_STATUS_H #define TEAM_3_STATUS_H #include <iostream> #include "Arquivo.h" #include <time.h> #include <chrono> #include <cstdlib> #include<ctype.h> #include <vector> class Status { private: public: int cadastrar(std::string id); static int gerar_status(); //ATUALIZAR DADOS NO ARQUIVO ESPECÍFICO static int atualizar(); }; #endif
1692f2a91da28ea046a4f5d6a6bad3ab7fc681cc
0ce683fe8f588ffe7239d849eabdcc704f10a2f1
/two-lanes-detection/computer_vision/include/computer_vision/getLanes.hpp
38672a6fbba59b1fde8d039270c6f3ef43738477
[]
no_license
g41903/PEV-MediaLab
fcc27bf49e6ed796812271eeed990e55ae8b720e
502fe99ba51c8bf6b721ce65557cd950d90b4bd9
refs/heads/master
2020-04-22T08:27:31.986244
2016-08-24T14:02:02
2016-08-24T14:02:02
66,322,192
0
0
null
null
null
null
UTF-8
C++
false
false
925
hpp
getLanes.hpp
#ifndef GETLANES_HPP_ #define GETLANES_HPP_ #include <opencv2/opencv.hpp> #include "misc.hpp" using namespace std; using namespace cv; // input image size extern int image_width; extern int image_height; // Hough transform extern int thres_num_points; // clustering of lines extern int thres_cluster_delta_angle; extern int thres_cluster_delta_rho; // if two lanes are parallel and of certain distance, then left and right lanes are both detected. Pick the left one extern int thres_parallel_delta_angle; extern int thres_parallel_delta_rho; // if two lanes are converging. Pick the right one extern int thres_converge_delta_angle; extern int thres_converge_delta_rho; // method for white pixel extraction extern int detect_method; extern int extract_method; extern int dilation_element, dilation_edge_size, dilation_white_size; vector<Vec2f> getLanes(cv::Mat input, bool isDebug = 1); #endif /* GETLANES_HPP_ */
02fa20ca96b7e333adfa6f5005b89603fd17fdb2
657f4307db3cbc4c8dc07eb8d6933aa78f442fc9
/examples/animated-shapes/animated-shapes-example.cpp
b4b8a390f870da6c034698445958e2f5f02fe2b9
[ "Apache-2.0" ]
permissive
vcebollada/dali-demo
391a3513e169b30fcbf4040f815dad72a346e073
7b49cad5a47b88c3cf74f1c27b25d46257ffeb48
refs/heads/master
2021-02-10T14:56:22.691896
2020-02-27T13:39:29
2020-04-14T21:55:22
244,391,645
0
0
Apache-2.0
2020-03-02T14:29:24
2020-03-02T14:29:23
null
UTF-8
C++
false
false
20,940
cpp
animated-shapes-example.cpp
/* * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include <dali/dali.h> #include <dali-toolkit/dali-toolkit.h> #include "shared/view.h" #include <sstream> using namespace Dali; using namespace Dali::Toolkit; namespace { const char* APPLICATION_TITLE("Animated Shapes"); const char* VERTEX_SHADER = DALI_COMPOSE_SHADER ( attribute mediump vec3 aCoefficient; uniform mediump mat4 uMvpMatrix; uniform mediump vec3 uPosition[MAX_POINT_COUNT]; varying lowp vec2 vCoefficient; void main() { int vertexId = int(aCoefficient.z); gl_Position = uMvpMatrix * vec4(uPosition[vertexId], 1.0); vCoefficient = aCoefficient.xy; } ); // Fragment shader. const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER ( uniform lowp vec4 uColor; varying lowp vec2 vCoefficient; void main() { lowp float C = (vCoefficient.x*vCoefficient.x-vCoefficient.y); lowp float Cdx = dFdx(C); lowp float Cdy = dFdy(C); lowp float distance = float(C / sqrt(Cdx*Cdx + Cdy*Cdy)); lowp float alpha = 0.5 - distance; gl_FragColor = vec4( uColor.rgb, uColor.a * alpha ); } ); Shader CreateShader( unsigned int pointCount ) { std::ostringstream vertexShader; vertexShader << "#define MAX_POINT_COUNT "<< pointCount << "\n"<<VERTEX_SHADER; std::ostringstream fragmentShader; fragmentShader << "#extension GL_OES_standard_derivatives : enable "<< "\n"<<FRAGMENT_SHADER; Shader shader = Shader::New( vertexShader.str(), fragmentShader.str() ); for( unsigned int i(0); i<pointCount; ++i ) { std::ostringstream propertyName; propertyName << "uPosition["<<i<<"]"; shader.RegisterProperty(propertyName.str(),Vector3(0.0f,0.0f,0.0f) ); } return shader; } } //unnamed namespace // This example shows resolution independent rendering and animation of curves using the gpu. // class AnimatedShapesExample : public ConnectionTracker { public: AnimatedShapesExample( Application& application ) : mApplication( application ) { // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &AnimatedShapesExample::Create ); } ~AnimatedShapesExample() { // Nothing to do here; } // The Init signal is received once (only) during the Application lifetime void Create( Application& application ) { // Hide the indicator bar application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); Stage stage = Stage::GetCurrent(); // Creates the background gradient Toolkit::Control background = Dali::Toolkit::Control::New(); background.SetAnchorPoint( Dali::AnchorPoint::CENTER ); background.SetParentOrigin( Dali::ParentOrigin::CENTER ); background.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); Dali::Property::Map map; map.Insert( Toolkit::Visual::Property::TYPE, Visual::GRADIENT ); Property::Array stopOffsets; stopOffsets.PushBack( 0.0f ); stopOffsets.PushBack( 1.0f ); map.Insert( GradientVisual::Property::STOP_OFFSET, stopOffsets ); Property::Array stopColors; stopColors.PushBack( Vector4( 0.0f,0.0f,1.0f,1.0f ) ); stopColors.PushBack( Vector4( 1.0f,1.0f,1.0f,1.0f ) ); map.Insert( GradientVisual::Property::STOP_COLOR, stopColors ); Vector2 halfStageSize = Stage::GetCurrent().GetSize()*0.5f; map.Insert( GradientVisual::Property::START_POSITION, Vector2(0.0f,-halfStageSize.y) ); map.Insert( GradientVisual::Property::END_POSITION, Vector2(0.0f,halfStageSize.y) ); map.Insert( GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE ); background.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map ); stage.Add( background ); // Create a TextLabel for the application title. Toolkit::TextLabel label = Toolkit::TextLabel::New( APPLICATION_TITLE ); label.SetAnchorPoint( AnchorPoint::TOP_CENTER ); label.SetParentOrigin( Vector3( 0.5f, 0.0f, 0.5f ) ); label.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); label.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); stage.Add( label ); CreateTriangleMorph(Vector3( stage.GetSize().x*0.5f, stage.GetSize().y*0.15f, 0.0f), 100.0f ); CreateCircleMorph( Vector3( stage.GetSize().x*0.5f, stage.GetSize().y*0.5f, 0.0f), 55.0f ); CreateQuadMorph( Vector3( stage.GetSize().x*0.5f, stage.GetSize().y*0.85f, 0.0f), 60.0f ); stage.KeyEventSignal().Connect( this, &AnimatedShapesExample::OnKeyEvent ); } void CreateTriangleMorph( Vector3 center, float side ) { float h = ( side *0.5f ) / 0.866f; Vector3 v0 = Vector3( -h, h, 0.0f ); Vector3 v1 = Vector3( 0.0f, -side * 0.366f, 0.0f ); Vector3 v2 = Vector3( h, h, 0.0f ); Vector3 v3 = v0 + ( ( v1 - v0 ) * 0.5f ); Vector3 v4 = v1 + ( ( v2 - v1 ) * 0.5f ); Vector3 v5 = v2 + ( ( v0 - v2 ) * 0.5f ); Shader shader = CreateShader( 12 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[0]"), v0 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[1]"), v3 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[2]"), v1 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[3]"), v1 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[4]"), v4 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[5]"), v2 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[6]"), v2 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[7]"), v5 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[8]"), v0 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[9]"), v0 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[10]"), v1 ); shader.SetProperty( shader.GetPropertyIndex( "uPosition[11]"), v2 ); //Create geometry static const Vector3 vertexData[] = { Dali::Vector3( 0.0f, 0.0f, 0.0f ), Dali::Vector3( 0.5f, 0.0f, 1.0f ), Dali::Vector3( 1.0f, 1.0f, 2.0f ), Dali::Vector3( 0.0f, 0.0f, 3.0f ), Dali::Vector3( 0.5f, 0.0f, 4.0f ), Dali::Vector3( 1.0f, 1.0f, 5.0f ), Dali::Vector3( 0.0f, 0.0f, 6.0f ), Dali::Vector3( 0.5f, 0.0f, 7.0f ), Dali::Vector3( 1.0f, 1.0f, 8.0f ), Dali::Vector3( 0.0f, 1.0f, 9.0f ), Dali::Vector3( 0.0f, 1.0f, 10.0f ), Dali::Vector3( 0.0f, 1.0f, 11.0f ) }; unsigned short indexData[] = { 0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10 }; //Create a vertex buffer for vertex positions and texture coordinates Dali::Property::Map vertexFormat; vertexFormat["aCoefficient"] = Dali::Property::VECTOR3; Dali::PropertyBuffer vertexBuffer = Dali::PropertyBuffer::New( vertexFormat ); vertexBuffer.SetData( vertexData, sizeof(vertexData)/sizeof(vertexData[0])); //Create the geometry Dali::Geometry geometry = Dali::Geometry::New(); geometry.AddVertexBuffer( vertexBuffer ); geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) ); Renderer renderer = Renderer::New( geometry, shader ); renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); Actor actor = Actor::New(); actor.SetSize( 400.0f, 400.0f ); actor.SetPosition( center ); actor.SetAnchorPoint( AnchorPoint::CENTER ); actor.SetColor(Vector4(1.0f,1.0f,0.0f,1.0f) ); actor.AddRenderer( renderer ); Stage stage = Stage::GetCurrent(); stage.Add( actor ); //Animation Animation animation = Animation::New(5.0f); KeyFrames k0 = KeyFrames::New(); k0.Add( 0.0f,v3 ); k0.Add( 0.5f, v3 + Vector3(-150.0f,-150.0f,0.0f)); k0.Add( 1.0f, v3 ); animation.AnimateBetween( Property(shader, "uPosition[1]"),k0, AlphaFunction::EASE_IN_OUT_SINE ); k0 = KeyFrames::New(); k0.Add( 0.0f,v4 ); k0.Add( 0.5f, v4 + Vector3(150.0f,-150.0f,0.0f)); k0.Add( 1.0f, v4 ); animation.AnimateBetween( Property(shader,"uPosition[4]"),k0, AlphaFunction::EASE_IN_OUT_SINE ); k0 = KeyFrames::New(); k0.Add( 0.0f,v5 ); k0.Add( 0.5f, v5 + Vector3(0.0,150.0f,0.0f)); k0.Add( 1.0f, v5 ); animation.AnimateBetween( Property(shader, "uPosition[7]"),k0, AlphaFunction::EASE_IN_OUT_SINE ); animation.SetLooping( true ); animation.Play(); } void CreateCircleMorph( Vector3 center, float radius ) { Shader shader = CreateShader( 16 ); shader.SetProperty( shader.GetPropertyIndex("uPosition[0]"), Vector3( -radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[1]"), Vector3( 0.0f, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[2]"), Vector3( radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[3]"), Vector3( radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[4]"), Vector3( radius, 0.0f, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[5]"), Vector3( radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[6]"), Vector3( radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[7]"), Vector3( 0.0f, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[8]"), Vector3( -radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[9]"), Vector3( -radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[10]"), Vector3( -radius, 0.0f, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[11]"), Vector3( -radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[12]"), Vector3( -radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[13]"), Vector3( radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[14]"), Vector3( radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[15]"), Vector3( -radius, radius, 0.0f ) ); //shader.SetProperty( shader.GetPropertyIndex("uLineWidth"), 2.0f ); static const Vector3 vertexData[] = { Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.5f, 0.0f, 1.0f ), Vector3( 1.0f, 1.0f, 2.0f ), Vector3( 0.0f, 0.0f, 3.0f ), Vector3( 0.5f, 0.0f, 4.0f ), Vector3( 1.0f, 1.0f, 5.0f ), Vector3( 0.0f, 0.0f, 6.0f ), Vector3( 0.5f, 0.0f, 7.0f ), Vector3( 1.0f, 1.0f, 8.0f ), Vector3( 0.0f, 0.0f, 9.0f ), Vector3( 0.5f, 0.0f, 10.0f ), Vector3( 1.0f, 1.0f, 11.0f ), Vector3( 0.0f, 1.0f, 12.0f ), Vector3( 0.0f, 1.0f, 13.0f ), Vector3( 0.0f, 1.0f, 14.0f ), Vector3( 0.0f, 1.0f, 15.0f )}; short unsigned int indexData[] = { 0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 13, 14, 12, 14, 15 }; //Create a vertex buffer for vertex positions and texture coordinates Dali::Property::Map vertexFormat; vertexFormat["aCoefficient"] = Dali::Property::VECTOR3; Dali::PropertyBuffer vertexBuffer = Dali::PropertyBuffer::New( vertexFormat ); vertexBuffer.SetData( vertexData, sizeof(vertexData)/sizeof(vertexData[0])); //Create the geometry Dali::Geometry geometry = Dali::Geometry::New(); geometry.AddVertexBuffer( vertexBuffer ); geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) ); Renderer renderer = Renderer::New( geometry, shader ); renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); Actor actor = Actor::New(); actor.SetSize( 400.0f, 400.0f ); actor.SetPosition( center ); actor.SetAnchorPoint( AnchorPoint::CENTER ); actor.AddRenderer( renderer ); Stage stage = Stage::GetCurrent(); stage.Add( actor ); //Animation Animation animation = Animation::New(5.0f); KeyFrames k0 = KeyFrames::New(); k0.Add( 0.0f, Vector3( 0.0f,-radius*1.85, 0.0f ) ); k0.Add( 0.5f, Vector3( -radius*1.85, -radius*3.0f, 0.0f ) ); k0.Add( 1.0f, Vector3( 0.0f,-radius*1.85, 0.0f ) ); animation.AnimateBetween( Property( shader, shader.GetPropertyIndex("uPosition[1]") ),k0, AlphaFunction::EASE_IN_OUT_SINE ); k0 = KeyFrames::New(); k0.Add( 0.0f, Vector3( radius*1.85, 0.0f, 0.0f ) ); k0.Add( 0.5f, Vector3( radius*3.0f,-radius*1.85, 0.0f ) ); k0.Add( 1.0f, Vector3( radius*1.85,0.0f, 0.0f ) ); animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[4]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); k0 = KeyFrames::New(); k0.Add( 0.0f, Vector3( 0.0f, radius*1.85, 0.0f ) ); k0.Add( 0.5f, Vector3( radius*1.85, radius*3.0f, 0.0f) ); k0.Add( 1.0f, Vector3( 0.0f, radius*1.85, 0.0f) ); animation.AnimateBetween( Property( shader, shader.GetPropertyIndex("uPosition[7]") ),k0, AlphaFunction::EASE_IN_OUT_SINE ); k0 = KeyFrames::New(); k0.Add( 0.0f, Vector3( -radius*1.85, 0.0f, 0.0f) ); k0.Add( 0.5f, Vector3(-radius*3.0f, radius*1.85, 0.0f) ); k0.Add( 1.0f, Vector3( -radius*1.85, 0.0f, 0.0f) ); animation.AnimateBetween( Property( shader, shader.GetPropertyIndex("uPosition[10]") ),k0, AlphaFunction::EASE_IN_OUT_SINE ); animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(-90.0f) ), Vector3::ZAXIS ) ); animation.SetLooping( true ); animation.Play(); } void CreateQuadMorph( Vector3 center, float radius ) { Shader shader = CreateShader( 16 ); shader.SetProperty( shader.GetPropertyIndex("uPosition[0]"), Vector3( -radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[1]"), Vector3( 0.0f, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[2]"), Vector3( radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[3]"), Vector3( radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[4]"), Vector3( radius, 0.0f, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[5]"), Vector3( radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[6]"), Vector3( radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[7]"), Vector3( 0.0f, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[8]"), Vector3( -radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[9]"), Vector3( -radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[10]"), Vector3( -radius, 0.0f, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[11]"), Vector3( -radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[12]"), Vector3( -radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[13]"), Vector3( radius, -radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[14]"), Vector3( radius, radius, 0.0f ) ); shader.SetProperty( shader.GetPropertyIndex("uPosition[15]"), Vector3( -radius, radius, 0.0f ) ); static const Vector3 vertexData[] = { Dali::Vector3( 0.0f, 0.0f, 0.0f ), Dali::Vector3( 0.5f, 0.0f, 1.0f ), Dali::Vector3( 1.0f, 1.0f, 2.0f ), Dali::Vector3( 0.0f, 0.0f, 3.0f ), Dali::Vector3( 0.5f, 0.0f, 4.0f ), Dali::Vector3( 1.0f, 1.0f, 5.0f ), Dali::Vector3( 0.0f, 0.0f, 6.0f ), Dali::Vector3( 0.5f, 0.0f, 7.0f ), Dali::Vector3( 1.0f, 1.0f, 8.0f ), Dali::Vector3( 0.0f, 0.0f, 9.0f ), Dali::Vector3( 0.5f, 0.0f, 10.0f ), Dali::Vector3( 1.0f, 1.0f, 11.0f ), Dali::Vector3( 0.0f, 1.0f, 12.0f ), Dali::Vector3( 0.0f, 1.0f, 13.0f ), Dali::Vector3( 0.0f, 1.0f, 14.0f ), Dali::Vector3( 0.0f, 1.0f, 15.0f ) }; short unsigned int indexData[] = { 0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 15, 14, 12, 14, 13 }; //Create a vertex buffer for vertex positions and texture coordinates Dali::Property::Map vertexFormat; vertexFormat["aCoefficient"] = Dali::Property::VECTOR3; Dali::PropertyBuffer vertexBuffer = Dali::PropertyBuffer::New( vertexFormat ); vertexBuffer.SetData( vertexData, sizeof(vertexData)/sizeof(vertexData[0])); //Create the geometry Dali::Geometry geometry = Dali::Geometry::New(); geometry.AddVertexBuffer( vertexBuffer ); geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) ); Renderer renderer = Renderer::New( geometry, shader ); renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); Actor actor = Actor::New(); actor.SetSize( 400.0f, 400.0f ); actor.SetPosition( center ); actor.SetAnchorPoint( AnchorPoint::CENTER ); actor.SetColor(Vector4(1.0f,0.0f,0.0f,1.0f) ); actor.AddRenderer( renderer ); Stage stage = Stage::GetCurrent(); stage.Add( actor ); //Animation Animation animation = Animation::New( 5.0f ); KeyFrames k0 = KeyFrames::New(); k0.Add( 0.0f, Vector3( 0.0f, -radius, 0.0f ) ); k0.Add( 0.5f, Vector3( 0.0f, -radius*4.0f, 0.0f ) ); k0.Add( 1.0f, Vector3( 0.0f, -radius, 0.0f ) ); animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[1]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); k0 = KeyFrames::New(); k0.Add( 0.0f, Vector3( radius, 0.0f, 0.0f ) ); k0.Add( 0.5f, Vector3( radius*4.0f, 0.0f, 0.0f ) ); k0.Add( 1.0f, Vector3( radius, 0.0f, 0.0f ) ); animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[4]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); k0 = KeyFrames::New(); k0.Add( 0.0f, Vector3( 0.0f, radius, 0.0f ) ); k0.Add( 0.5f, Vector3( 0.0f, radius*4.0f, 0.0f ) ); k0.Add( 1.0f, Vector3( 0.0f, radius, 0.0f ) ); animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[7]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); k0 = KeyFrames::New(); k0.Add( 0.0f, Vector3( -radius, 0.0f, 0.0f ) ); k0.Add( 0.5f, Vector3( -radius*4.0f,0.0f, 0.0f ) ); k0.Add( 1.0f, Vector3( -radius, 0.0f, 0.0f ) ); animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[10]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(90.0f) ), Vector3::ZAXIS ) ); animation.SetLooping( true ); animation.Play(); } /** * Main key event handler */ void OnKeyEvent(const KeyEvent& event) { if( event.state == KeyEvent::Down && (IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK )) ) { mApplication.Quit(); } } private: Application& mApplication; }; int DALI_EXPORT_API main( int argc, char **argv ) { Application application = Application::New( &argc, &argv ); AnimatedShapesExample test( application ); application.MainLoop(); return 0; }
a4f60ec29edec0db8e02fbf19aed11b5f9c4a451
e85cae6dba42a427ddfc1be49fe4155ed557de93
/HW2/HW3.cpp
2e94ac5050cfce01c647eb5d557da9ab60d939a3
[]
no_license
neilmmalu/ADSA
72a912382e9bd3063b25a43538e9dc80c7bf68ae
044fad17b2368a641a96880595e0a5e52a5f152e
refs/heads/master
2023-01-19T16:44:46.411418
2020-11-25T20:18:52
2020-11-25T20:18:52
292,622,908
0
0
null
null
null
null
UTF-8
C++
false
false
8,455
cpp
HW3.cpp
//HW3 Name: Neil Malu //SUID: 635692900 NetID: nemalu //HW3: Implement DFS and BFS as described in class. //Due: 11:50PM, Wednesday, September 23. //You should not add more functions. #include <iostream> #include <vector> #include <queue>//bfs, in-queue #include <stack>//dfs using namespace std; class pos { public: int y_coord; //y_coord goes from 1-8 char letter; //Letter goes from 'a' to 'h' bool visited = false; //true if a particular position is visited bool inQueue = false; //true if a particular position is already in the BFS queue pair<char, int> parent; //parent position of current position - used for printing path vector<int> x_add = { -1, -2, -2, -1, 1, 2, 2, 1 }; //Order of x-axis neighbor calculation vector<int> y_add = { -2, -1, 1, 2, 2, 1, -1, -2 }; //Order of y-axis neighbor calculation pos() { pos('a', 0); } //Overrided default constructor //x coord is the letter //y coord is the number pos(char x, int y) { this->letter = x; this->y_coord = y; } //Utility print function void print() { cout << "(" << letter << ", " << y_coord << ")"; } //Checks if pair of x, y values are valid position on the board bool isValid(char x, int y) { if (x < 'a' || x > 'h') return false; if (y < 1 || y > 8) return false; return true; } //Returns a list of all valid neighbors of a pos, sorted clockwise from bottom left to bottom right vector<pair<char, int>> allValidPos() { vector<pair<char, int>> result; for (int i = 0; i < x_add.size(); ++i) { char newX = letter + x_add[i]; int newY = y_coord + y_add[i]; if (isValid(newX, newY)) result.push_back(pair<char, int>(newX, newY)); } return result; } }; void BFS(vector<vector<pos>>& board, pair<char, int> start_pos, pair <char, int> end_pos); void DFS_r(vector<vector<pos>>& board, stack<pair<int, int>>& Stack_r, pair<char, int> start_pos, pair <char, int> end_pos); void DFS_nr(vector<vector<pos>>& board, pair<char, int> start_pos, pair <char, int> end_pos); int main() { vector<vector<pos>> board(8, vector<pos>(8));// pos b[8][8]; //initialize board as you see needed. //board[0][0] = pos "a8" for (int i = 0; i < board.size(); ++i) for (int j = 0; j < board.size(); ++j) board[i][j] = pos(j + 'a', 8 - i); pair<char, int> start_pos, end_pos; cout << "Enter start position -- x is in a ... h and y is in 1 ... 8" << endl; cin >> start_pos.first >> start_pos.second; cout << "Enter end position -- x is in a ... h and y is in 1 ... 8" << endl; cin >> end_pos.first >> end_pos.second; BFS(board, start_pos, end_pos); cout << endl; //reset board //board[0][0] = pos "a8" for (int i = 0; i < board.size(); ++i) for (int j = 0; j < board.size(); ++j) board[i][j] = pos(j + 'a', 8 - i); DFS_nr(board, start_pos, end_pos);//non-recursive DFS cout << endl; //reset board //board[0][0] = pos "a8" for (int i = 0; i < board.size(); ++i) for (int j = 0; j < board.size(); ++j) board[i][j] = pos(j + 'a', 8 - i); //Set up stuff for recursive DFS //Mark start pos as visited and add to stack stack<pair<int, int>> Stack_r; int x = start_pos.first - 'a'; int y = 8 - start_pos.second; board[y][x].visited = true; Stack_r.push(start_pos); DFS_r(board, Stack_r, start_pos, end_pos);//recursive DFS return 0; } void BFS(vector<vector<pos>>& board, pair<char, int> start_pos, pair <char, int> end_pos) { //Push the start position to the queue queue<pair<char, int>> Q; Q.push(start_pos); while (!Q.empty()) { auto p = Q.front(); Q.pop(); //Calculations to convert from pair to pos on board int x = p.first - 'a'; int y = 8 - p.second; //exit condition - if the end position is found if (p.first == end_pos.first && p.second == end_pos.second) { //Keep printing while x and y values don't correspond to the start position while (!(x == start_pos.first - 'a' && y == 8 - start_pos.second)) { board[y][x].print(); cout << " <-- "; int newX = board[y][x].parent.first - 'a'; int newY = 8 - board[y][x].parent.second; x = newX; y = newY; } board[y][x].print(); return; } //If the current position is not visited if (!board[y][x].visited) { //Mark the current position as visited board[y][x].visited = true; //find all the neighbors of the current position vector<pair<char, int>> neighbors = board[y][x].allValidPos(); for (auto n : neighbors) { int newX = n.first - 'a'; int newY = 8 - n.second; //If the neighbor is not in queue or not visited if (!board[newY][newX].visited && !board[newY][newX].inQueue) { //Add the neighbor to the queue board[newY][newX].inQueue = true; //Set the parent of the neigbor as the current position board[newY][newX].parent = p; Q.push(n); } } } } cout << "No path available!" << endl; } void DFS_r(vector<vector<pos>>& board, stack<pair<int, int>>& Stack_r, pair<char, int> start_pos, pair <char, int> end_pos) { //Initially, start position is already in the stack while (!Stack_r.empty()) { auto p = Stack_r.top(); //Calculations to convert from pair to pos on board int x = p.first - 'a'; int y = 8 - p.second; //exit condition - if the end position is found if (p.first == end_pos.first && p.second == end_pos.second) { //Keep printing while x and y values don't correspond to the start position while (!(x == start_pos.first - 'a' && y == 8 - start_pos.second)) { board[y][x].print(); cout << " <-- "; int newX = board[y][x].parent.first - 'a'; int newY = 8 - board[y][x].parent.second; x = newX; y = newY; } board[y][x].print(); Stack_r.pop(); return; } //find all the neighbors of the current position vector<pair<char, int>> neighbors = board[y][x].allValidPos(); for (auto n : neighbors) { int newX = n.first - 'a'; int newY = 8 - n.second; //If the neighbor is not visited if (!board[newY][newX].visited) { //Mark the neighbor as visited board[newY][newX].visited = true; //Set the parent of the neighbor as the current pos board[newY][newX].parent = p; //Push the neighbor to the stack Stack_r.push(n); //Recursively call DFS DFS_r(board, Stack_r, start_pos, end_pos); } } //Pop from the stack once pos is visited if(!Stack_r.empty())Stack_r.pop(); } int endX = end_pos.first - 'a'; int endY = 8 - end_pos.second; if(!board[endY][endX].visited) cout << "No path available!" << endl; } void DFS_nr(vector<vector<pos>>& board, pair<char, int> start_pos, pair <char, int> end_pos) { //Push the start position to the queue stack<pair<char, int>> S; S.push(start_pos); while (!S.empty()) { auto p = S.top(); S.pop(); //Calculations to convert from pair to pos on board int x = p.first - 'a'; int y = 8 - p.second; //exit condition - if the end position is found if (p.first == end_pos.first && p.second == end_pos.second) { //Keep printing while x and y values don't correspond to the start position while (!(x == start_pos.first - 'a' && y == 8 - start_pos.second)) { board[y][x].print(); cout << " <-- "; int newX = board[y][x].parent.first - 'a'; int newY = 8 - board[y][x].parent.second; x = newX; y = newY; } board[y][x].print(); return; } //If the current position is not visited if (!board[y][x].visited) { //Mark the current position as visited board[y][x].visited = true; vector<pair<char, int>> neighbors = board[y][x].allValidPos(); //Add the neigbors to the stack in reverse order, so next valid position is on top for (int i = neighbors.size() - 1; i >= 0; --i) { auto n = neighbors[i]; int newX = n.first - 'a'; int newY = 8 - n.second; //If the neighbor is not visited if (!board[newY][newX].visited) { //Set the parent of neighbor to the current pos board[newY][newX].parent = p; //Add the neighbor to the queue S.push(n); } } } } cout << "No path available!" << endl; } //The following might not represent a correct run. It shows the required output format. /* Enter start position -- x is in a ... h and y is in 1 ... 8 b 3 Enter end position -- x is in a ... h and y is in 1 ... 8 f 2 Target is reached! (f,2)<-(e,4)<-(d,2)<-(b,3) Target is reached! (f,2)<-(d,1)<-(c,3)<-(a,2)<-(b,4)<-(a,6)<-(c,7)<-(a,8)<-(b,6)<-(c,4)<-(e,5)<-(g,6)<-(f,8)<-(h,7)<-(f,6)<-(g,8)<-(h,6)<-(f,5)<-(d,4)<-(b,3) No path avaiable! */
9bbd604944a165930ae3d2d769254726a8df0989
1043a363946e9e5dcfb16ded06bca5f3dd8adc1d
/a.cpp
b8c62ff4e1dca314c4c1cfb401916004f9f24a2c
[]
no_license
yunfuliu/TestRepository
e5594dc89741e48c453fd5e7901b731ae7ce8780
e38a08e6e01fd195baccb23867a1b62d7f8ad1d0
refs/heads/master
2020-05-02T19:44:36.797458
2014-04-01T15:01:16
2014-04-01T15:01:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
96
cpp
a.cpp
void main(){ } void speedupfunction(){ } ======= this is type from master >>>>>>> master
56d057a6b85688b8cb1089d3deb9b50914e48a9c
eaa0e6c89f2ee0e5f3990edc0621e9d4caf92d97
/src/runtime_lib/infra_julienne/priority_queue_gapbs.h
85cbdcc81a5c289f60f22d1023b3296172c9a80b
[ "MIT" ]
permissive
ldhulipala/graphit
4fc4060c6de26caa559096681e2176e730ac647c
708cb2947518d6aebaa62407ebe97d08a9030f4d
refs/heads/master
2020-09-10T22:03:05.422041
2019-11-15T21:10:38
2019-11-15T21:10:38
221,845,762
0
0
NOASSERTION
2019-11-15T04:44:56
2019-11-15T04:44:55
null
UTF-8
C++
false
false
1,836
h
priority_queue_gapbs.h
#include <algorithm> #include <cinttypes> #include "platform_atomics.h" #include "bucket.h" /** * Phase-synchronous priority queue with dual representation * Representation 1: When using thread-local buckets, there is nothing stored in the data strucutre. It merely holds the current bucket index, next bucket index and other metadata. The real priority queue is distributed across threads. * Representation 2: When using lazy buckets, the priority queue actually stores all the nodes with their buckets (the buckets are not distributed) **/ typedef int64_t NodeID; template<typename PriorityT_> class PriorityQueue { public: explicit PriorityQueue(bool use_lazy_bucket, PriorityT_* priorities) { priorities_ = priorities; use_lazy_bucket_ = use_lazy_bucket; iter_ = 0; } // set up shared_indexes, iter and frontier_tails data structures void init_indexes_tails(){ shared_indexes[0] = 0; shared_indexes[1] = kMaxBin; frontier_tails[0] = 1; frontier_tails[1] = 0; iter_=0; } // get the prioirty of the current iteration (each iter has a priority) size_t get_current_priority(){ return shared_indexes[iter_&1]; } // increment the iteration number, which was used for computing the current priorty void increment_iter() { iter_++; } bool finished() { if (!use_lazy_bucket_){ return get_current_priority() != kMaxBin; } else { //not yet implemented return true; } } void updatePriorityMin(NodeID dst, PriorityT_ new_p, PriorityT_ old_p){ } PriorityT_* priorities_; const PriorityT_ kDistInf = numeric_limits<PriorityT_>::max()/2; const size_t kMaxBin = numeric_limits<size_t>::max()/2; size_t shared_indexes[2]; size_t frontier_tails[2]; size_t iter_;; bool use_lazy_bucket_; buckets<PriorityT_> };
74d602db51957d884d977073463b7ac5fb6923e7
4fe94c6c37eda3fcdff737c3db2b9e01dad5d89d
/red_belt/w1/deque_from_vectors.cpp
e1a0b51a52654bfe04732d0e799da92dbc10f498
[]
no_license
KushnirDmytro/cpp_belts_coursera
a2a3b070a6162b2dc96fb00a65f6f3074068aa26
7ada0052c19efbe2a1a6c8252e8816046b4a755c
refs/heads/master
2020-07-18T21:59:46.134029
2020-01-18T15:33:13
2020-01-18T15:33:13
206,320,214
0
0
null
null
null
null
UTF-8
C++
false
false
3,733
cpp
deque_from_vectors.cpp
// // Created by dkushn on 05.09.19. // #include <vector> //#include <exception> #include <stdexcept> //#include "test_runner.h" using namespace std; template <typename T> class Deque{ public: Deque() : front_vec{}, rear_vec{}{ } explicit Deque(const vector<T> &init_vector) : front_vec{}, rear_vec{init_vector}{ } bool Empty() const{ return front_vec.empty() && rear_vec.empty(); } size_t Size() const{ return front_vec.size() + rear_vec.size(); } T& operator[](size_t index){ int aligned_index = index - front_vec.size(); if (aligned_index < 0){ return front_vec[front_vec.size() - index - 1]; } else { return rear_vec[index - front_vec.size()]; } } const T& operator[](size_t index) const{ // cout << "Const access called" << endl; int aligned_index = index - front_vec.size(); if (aligned_index < 0){ return front_vec.at(front_vec.size() - index - 1); } else { return rear_vec.at(index - front_vec.size()); } } T& At(size_t index) const{ if (index >= Size()){ throw out_of_range(""); } else { return operator[](index); } } T& At(size_t index){ if (index >= Size()){ throw out_of_range(""); } else { return operator[](index); } } T& Front() { return operator[](0); } const T& Front() const{ return operator[](0); } T& Back(){ return operator[](Size() - 1); } const T& Back() const{ return operator[](Size() - 1); } void PushFront(const T &new_el){ front_vec.push_back(new_el); } void PushBack(const T &new_el){ rear_vec.push_back(new_el); } // константные и неконстантные версии методов Front и Back private: vector<T> front_vec; vector<T> rear_vec; }; void TestEmpty(){ Deque<int> d; ASSERT(d.Empty()); d.PushBack(1); ASSERT(!d.Empty()); Deque<int> d2; ASSERT(d2.Empty()); d2.PushFront(2); ASSERT(!d2.Empty()); } void TestSize(){ { Deque<int> d; ASSERT_EQUAL(d.Size(), 0); d.PushBack(1); ASSERT_EQUAL(d.At(0), 1); ASSERT_EQUAL(d.Size(), 1); d.PushBack(1); d.PushBack(1); ASSERT_EQUAL(d.Size(), 3); } { Deque<int> d; ASSERT_EQUAL(d.Size(), 0); d.PushFront(1); ASSERT_EQUAL(d.Size(), 1); ASSERT_EQUAL(d.At(0), 1); d.PushBack(1); d.PushBack(1); ASSERT_EQUAL(d.Size(), 3); } } void TestSqBraces(){ { const Deque<int> d {{1}}; ASSERT_EQUAL(d[0], 1); ASSERT_EQUAL(d.At(0), 1); } { Deque<int> d; d.PushBack(1); ASSERT_EQUAL(d[0], 1); d[0] = 2; ASSERT_EQUAL(d[0], 2); d.PushBack(3); ASSERT_EQUAL(d[1], 3); } { Deque<int> d; d.PushBack(1); ASSERT_EQUAL(d[0], 1); const int k = d[0]; } } void TestFronBack(){ { Deque<int> d; d.PushBack(1); ASSERT_EQUAL(d.Front(), 1); d.Front() = 2; ASSERT_EQUAL(d.Front(), 2); ASSERT_EQUAL(d.Back(), 2); } { const Deque<int> d {{1}}; // d.PushBack(1); ASSERT_EQUAL(d.Front(), 1); // d.Front() = 2; // ASSERT_EQUAL(d.Front(), 2); // ASSERT_EQUAL(d.Back(), 2); } } int main(){ TestRunner tr; RUN_TEST(tr, TestEmpty); RUN_TEST(tr, TestSize); RUN_TEST(tr, TestSqBraces); RUN_TEST(tr, TestFronBack); }
dad90262e5ca0b272de2a38369262e96b8aa5d4a
8f6ab66b5483b835c80a04397bd6b0d7a91656cb
/atcoder/abc139/d.cpp
9a14d3b1eaf5a628116a2e1788e36942813deb86
[]
no_license
shirobrak/procon
8121f877c55c215e5eb550d23890bac9823007a2
8f3c3ece3adcdee635eaf5f297c959c6e556542f
refs/heads/master
2020-12-09T05:45:57.776620
2020-01-11T08:55:36
2020-01-11T08:55:36
233,210,335
0
0
null
null
null
null
UTF-8
C++
false
false
379
cpp
d.cpp
#include<iostream> using namespace std; int N; int main() { cin >> N; long ans = 0; if(N > 1) { for (int i = 1; i < N+1; i++) { if (i == 1) { ans += 1; } else if (i == N) { ans += 0; } else { ans += (long)(i); } } } cout << (long)ans << endl; }
b1786cd2d2f589c515d3c232394a3f2989ebc062
23f6f2dad406ba576d4c97f7dbba1516a04583db
/CreationalPatterns/AbstractFactory/Product/ConcreteProductB1.h
b1cdfebadab5eb6c3c6c3c86d33bdb7e069dd142
[]
no_license
sacdar/CPP-Design-Patterns
7618b50aeb12d04e27f3d5fe75faf9823bd8e30c
84de7263d31c78a7eeede000d0604e953a4e0961
refs/heads/master
2021-01-10T20:10:06.588221
2015-02-13T08:23:49
2015-02-13T08:23:49
30,695,425
1
0
null
null
null
null
UTF-8
C++
false
false
237
h
ConcreteProductB1.h
#ifndef _CONCRETEPRODUCTB1_H_ #define _CONCRETEPRODUCTB1_H_ #include "AbstractProductB.h" // ConcreteProductB1 class ConcreteProductB1 : public AbstractProductB { public: void printProduct(); }; #endif /* _CONCRETEPRODUCTB1_H_ */
7db4e85009231c8c0e3b700a0c25f35004110dae
b33750e0f06dd220f5a8bc67a7e2dacd5194fb6a
/1__searching_countsort_on_29-7-17/problems_given/bond_fond.cpp
94bf94fb347fb5d0fc73b746b6d818d92efe3198
[]
no_license
dbads/CC_class_codes_mnnit
30a190916ec2d7ec8bed3d53c0acced6783682dc
723eb894d27e8c17600570101d9059e26d6f3626
refs/heads/master
2021-04-27T03:03:40.657076
2018-06-11T17:59:07
2018-06-11T17:59:07
122,708,464
4
0
null
null
null
null
UTF-8
C++
false
false
481
cpp
bond_fond.cpp
#include<bits/stdc++.h> using namespace std; #define lli long long int lli pow2(int x,int a); int main() { lli i,n,c,d; lli a,b,t; scanf("%lld",&t); while(t--){ scanf("%lld",&n); a=log2(n); b=a+1; c= pow2(2,a); d= pow2(2,b); if(abs(n-c) > abs(n-d)){ printf("%lld\n",abs(n-d)); }else{ printf("%lld\n",abs(n-c)); } } return 0; } lli pow2(int x,int a) { lli b=pow(x,a/2); if(a==0) return 1; else if(a%2==0) return b*b; else return b*b*x; }
1adb69ffed3b6e060aba6cdeeb06e18f32a5fa81
0a8588d8e9df1dfaec54224fe6d55cc5b8091257
/uva/11727-CostCutting.cpp
27f3b180cf827a4e7aa3c37ed13bb609916dc8af
[]
no_license
skalyanasundaram/BrainTuners
17e686e540bad3e809c78e0a9462e95fc12b5370
2605550e18750485b693804c3d83c3c97706362b
refs/heads/master
2021-01-06T20:41:45.395191
2019-02-04T08:45:36
2019-02-04T08:45:36
12,889,243
0
0
null
null
null
null
UTF-8
C++
false
false
755
cpp
11727-CostCutting.cpp
#include <iostream> using namespace std; int main() { int T, input[4], res, other; cin >> T; for(int i = 1; i <= T; i++) { cin >> input[0]; other = 0; res = input[0]; cin >> input[1]; if (input[1] > res) { res = input[1]; } else { other = 1; } cin >> input[2]; if (input[2] < res) { if (input[2] > input[other]) { res = input[2]; } else { res = input[other]; } } cout << "Case " << i << ": " << res << endl; } return 0; }
64368293c35743a1ee400cc51d2734905e8088f1
a0783ab314f2ca6ba564adc6aae35115c0c9dc67
/Progetto-03/Info e Slide/seiot1920/arduino/modulo-lab-4.1/test-esp-basic/test-esp-basic.ino
4d8abc49bc2a8e075734f9742486b20303dff64d
[]
no_license
VladMattiussi/IoT-project
a8052f377c324dd7b91f6720eafc224d4396975e
ad7821f9b6b670301c617ac3e944e9dd5c3cf533
refs/heads/master
2023-08-14T06:47:14.426164
2021-09-22T11:58:09
2021-09-22T11:58:09
409,186,005
0
0
null
null
null
null
UTF-8
C++
false
false
468
ino
test-esp-basic.ino
/* * Note about ESP * * - D2 <=> GPIO4 * - boud rate: 115200 */ #define LED_PIN 4 void setup() { pinMode(LED_PIN, OUTPUT); Serial.begin(115200); Serial.println("READY"); } void loop() { int value = analogRead(A0); Serial.println("Value: " + String(value)); digitalWrite(LED_PIN, HIGH); Serial.println("ON"); delay(500); digitalWrite(LED_PIN, LOW); Serial.println("OFF"); delay(500); }
2a3504c1df04474dbaeab4e63e8fc1635cdb7885
f5d5f5bcb94db0a28cd844d1bde598fc3eb166b7
/--Print last 10 lines.cpp
6f38cfec0bbf563f796c25182dd1b13fb55516ef
[]
no_license
rajan596/iCode-Competitive
991e0046f78eb0e8d09dc578541006413819e9a8
dbd95a65e04e19758f0bda8514da737d8225e1f5
refs/heads/master
2021-03-30T18:29:34.956817
2017-08-13T10:57:50
2017-08-13T10:57:50
54,173,529
0
0
null
null
null
null
UTF-8
C++
false
false
818
cpp
--Print last 10 lines.cpp
#include<bits/stdc++.h> using namespace std; void printLastLines(char *s,int n){ if(n<=0) { fprintf(stderr , " N must be >=0 "); return; } char *pos=strrchr(s,'\n'); int cnt=n; while(cnt--) { while(pos>s && *pos!='\n'){ pos--; } while(pos>s && *pos=='\n'){ pos--; } if(pos==s) break; } if(pos!=s) pos+=2; cout<<pos; } int main(){ char *str = "str1\nstr2\nstr3\nstr4\nstr5\nstr6\nstr7\nstr8\nstr9" "\nstr10\nstr11\nstr12\nstr13\nstr14\nstr15\nstr16\nstr17" "\nstr18\nstr19\nstr20\nstr21\nstr22\nstr23\nstr24\nstr25"; char *s2 = "str1\nstr2\nstr3\nstr4\nstr5\nstr6\nstr7"; printLastLines(str,10); printf("\n"); printLastLines(s2,10); return 0; }
3fa51ab88a83fb7e429a0d322e286bdc95720d99
ff9315e16393d34e42992aa6f2f942e4f851dd58
/DB/ApplicationPassword.h
de36ec9d841d5d2f31383ca084fe63390a9960de
[]
no_license
razeghi71/passman
c90e911aae2ade1a42b7fa1c398a70cb9e0048e8
5a9ef3e1a0cebb3f44115cabf86974d3cb2b4afe
refs/heads/master
2021-01-10T04:59:46.689412
2016-01-25T19:52:27
2016-01-25T19:52:27
49,785,147
1
0
null
null
null
null
UTF-8
C++
false
false
923
h
ApplicationPassword.h
#ifndef APPLICATION_PASSWORD_H #define APPLICATION_PASSWORD_H #include <string> #include <odb/core.hxx> #include "Application.h" #include <odb/nullable.hxx> #include <vector> using namespace std; #pragma db object class ApplicationPassword { friend class odb::access; ApplicationPassword () {} #pragma db id auto int passwordID; Application *app; odb::nullable<std::string> username; #pragma db type("BLOB") std::vector<unsigned char> password; public: ApplicationPassword(Application* app, odb::nullable<std::string> username, std::vector<unsigned char> password); Application *getApp() const; void setApp(Application *value); odb::nullable<std::string> getUsername() const; void setUsername(const odb::nullable<std::string> &value); int getPasswordID() const; std::vector<unsigned char> getPassword() const; void setPassword(const std::vector<unsigned char> &value); }; #endif
438a9b4d5d32b1ef402a32e5a648d6038b3b13dd
81172c6d4c116095d8f12821c45b46d0659efe62
/demo/echo_client.cc
29a28c6468a8e591d726d7ed6aabe8386bffcc56
[]
no_license
wumulun/grpc-etcd
ac21fa33ecc7ea42a8d978dd0cf824ec32038d90
7ae2280a9d3a7e7f4e89ec347aac8a1a4e633f97
refs/heads/master
2022-12-05T19:18:35.987765
2020-08-21T01:26:26
2020-08-21T01:26:26
276,841,965
7
1
null
null
null
null
UTF-8
C++
false
false
167
cc
echo_client.cc
#include"echo_client.h" int main(int argc, char** argv) { CClientServiceFind client_impl("localhost:2379"); client_impl.Run(); return 0; }
4bf8637c94e35936c6def78f20cde1854fe0945d
3ff1fe3888e34cd3576d91319bf0f08ca955940f
/tms/src/v20201229/model/Tag.cpp
2b55f311f852d0b00d717f71a2778e0001b467c5
[ "Apache-2.0" ]
permissive
TencentCloud/tencentcloud-sdk-cpp
9f5df8220eaaf72f7eaee07b2ede94f89313651f
42a76b812b81d1b52ec6a217fafc8faa135e06ca
refs/heads/master
2023-08-30T03:22:45.269556
2023-08-30T00:45:39
2023-08-30T00:45:39
188,991,963
55
37
Apache-2.0
2023-08-17T03:13:20
2019-05-28T08:56:08
C++
UTF-8
C++
false
false
3,739
cpp
Tag.cpp
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <tencentcloud/tms/v20201229/model/Tag.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Tms::V20201229::Model; using namespace std; Tag::Tag() : m_keywordHasBeenSet(false), m_subLabelHasBeenSet(false), m_scoreHasBeenSet(false) { } CoreInternalOutcome Tag::Deserialize(const rapidjson::Value &value) { string requestId = ""; if (value.HasMember("Keyword") && !value["Keyword"].IsNull()) { if (!value["Keyword"].IsString()) { return CoreInternalOutcome(Core::Error("response `Tag.Keyword` IsString=false incorrectly").SetRequestId(requestId)); } m_keyword = string(value["Keyword"].GetString()); m_keywordHasBeenSet = true; } if (value.HasMember("SubLabel") && !value["SubLabel"].IsNull()) { if (!value["SubLabel"].IsString()) { return CoreInternalOutcome(Core::Error("response `Tag.SubLabel` IsString=false incorrectly").SetRequestId(requestId)); } m_subLabel = string(value["SubLabel"].GetString()); m_subLabelHasBeenSet = true; } if (value.HasMember("Score") && !value["Score"].IsNull()) { if (!value["Score"].IsInt64()) { return CoreInternalOutcome(Core::Error("response `Tag.Score` IsInt64=false incorrectly").SetRequestId(requestId)); } m_score = value["Score"].GetInt64(); m_scoreHasBeenSet = true; } return CoreInternalOutcome(true); } void Tag::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const { if (m_keywordHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Keyword"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_keyword.c_str(), allocator).Move(), allocator); } if (m_subLabelHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "SubLabel"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_subLabel.c_str(), allocator).Move(), allocator); } if (m_scoreHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Score"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, m_score, allocator); } } string Tag::GetKeyword() const { return m_keyword; } void Tag::SetKeyword(const string& _keyword) { m_keyword = _keyword; m_keywordHasBeenSet = true; } bool Tag::KeywordHasBeenSet() const { return m_keywordHasBeenSet; } string Tag::GetSubLabel() const { return m_subLabel; } void Tag::SetSubLabel(const string& _subLabel) { m_subLabel = _subLabel; m_subLabelHasBeenSet = true; } bool Tag::SubLabelHasBeenSet() const { return m_subLabelHasBeenSet; } int64_t Tag::GetScore() const { return m_score; } void Tag::SetScore(const int64_t& _score) { m_score = _score; m_scoreHasBeenSet = true; } bool Tag::ScoreHasBeenSet() const { return m_scoreHasBeenSet; }
aad04da9c5cd53034b956ae6d92e0224d7d340c3
8432cf3674956449302109a412a91ac821dbd9d3
/src/Memory_DummyDeviceMethod.cpp
f9503ddc112466cb65faf77757757b1476973e28
[ "MIT" ]
permissive
hkduke/InternalHack_ImGui
74759108d67957f2e62d26a9deda18a217e86507
1c019987e9ebc2082ef97cd537c8a4eee5fe198c
refs/heads/master
2020-06-12T13:26:50.602251
2019-03-14T13:29:13
2019-03-14T13:29:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,892
cpp
Memory_DummyDeviceMethod.cpp
#include "Memory_DummyDeviceMethod.h" Memory_DummyDevice::Memory_DummyDevice() : d3d9(nullptr), d3d9Device(nullptr) { tempWindow = new Window("TempWindow"); LPDIRECT3D9 d3d9 = Direct3DCreate9(D3D_SDK_VERSION); if (!d3d9) throw ERROR; D3DDISPLAYMODE displayMode; if(FAILED(d3d9->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode))) { d3d9->Release(); throw ERROR; } D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = displayMode.Format; if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, tempWindow->windowHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_DISABLE_DRIVER_MANAGEMENT , &d3dpp, &d3d9Device))) { d3d9->Release(); throw ERROR; } } //bool Memory_DummyDevice::GetVTable(void** vTable) noexcept //{ // if (!vTable) // return false; // // IDirect3D9* pD3D; // pD3D = Direct3DCreate9(D3D_SDK_VERSION); // if (!pD3D) // return false; // // D3DPRESENT_PARAMETERS d3dpp; // ZeroMemory(&d3dpp, sizeof(d3dpp)); // d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // d3dpp.hDeviceWindow = GetForegroundWindow(); // d3dpp.Windowed = TRUE; // // IDirect3DDevice9* pDummyDevice = nullptr; // // HRESULT hr = pD3D->CreateDevice( // D3DADAPTER_DEFAULT, // D3DDEVTYPE_HAL, // d3dpp.hDeviceWindow, // D3DCREATE_HARDWARE_VERTEXPROCESSING, // &d3dpp, &pDummyDevice); // // vTable = *reinterpret_cast<void***>(pDummyDevice); // // return true; //} std::vector<UINT> Memory_DummyDevice::VTable() const { UINT vtbl[VTableElements]; memcpy( vtbl, *reinterpret_cast<UINT**>(d3d9Device), VTableElements * sizeof(UINT)); return std::vector<UINT>(vtbl, vtbl + sizeof(vtbl) / sizeof(vtbl[0])); } Memory_DummyDevice::~Memory_DummyDevice() { if (d3d9Device) d3d9Device->Release(); if (d3d9) d3d9->Release(); }
08214e79d69de62f697054d7d38b27c760e9d22c
1b3a2ad0690a78e6c2b0c3d742c25e0f4862d380
/ch11/copy.cpp
829cfc8d19a20efc4869bddcc1ba793701c5c055
[]
no_license
whytui/code4cpp
547c1b59b42b727ef66ae6640f40870fddce774d
0633ee657c6fe1f790ccafd17463c1a38f66977d
refs/heads/master
2023-08-22T23:46:33.579686
2021-09-25T13:07:38
2021-09-25T13:07:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
879
cpp
copy.cpp
/* * 作者:刘时明 * 时间:2020/6/14-22:18 * 作用: */ #include "ch11.h" void copyArray(); void copyVector(); void copyDemo() { copyVector(); } /** * 拷贝数组 */ void copyArray() { int arr1[] = {1, 2, 3, 4, 5}; int arr2[] = {0, 0, 0, 0, 0}; // 第一个不复制 copy(arr1 + 1, arr1 + 5, arr2 + 1); for (int i : arr2) { cout << i << endl; } } /** * 拷贝vector */ void copyVector() { auto *v1 = new vector<int>(); v1->push_back(1); v1->push_back(2); v1->push_back(3); auto *v2 = new vector<int>(); // v2初始化后大小为0,需要设定大小 v2->resize(5); // 把v1的所有元素复制到v2,从v2的第三个元素开始接收 copy(v1->data(), v1->data() + 3, v2->begin() + 2); for (int i : *v2) { cout << i << endl; } delete v1; delete v2; }
cd330025217104ac1d51f358197031d9e9424100
f8c0b8a0ae169b6a86c08b3e4dcfc9a69f4a77d1
/src/Scripting/LuaCpp/LuaCpp.hpp
3708b2bf5d56044ef425f937c6f231181ca76e23
[ "MIT" ]
permissive
lvseouren/Swift2
a25ca01b24dd77b162ece98a1374041fe70bb9f7
3dd898c0ca6f508fbf37f5e507c2998378de89e0
refs/heads/master
2021-01-21T05:36:14.638937
2015-01-19T02:46:05
2015-01-19T02:46:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
93
hpp
LuaCpp.hpp
#ifndef LUA_CPP_HPP #define LUA_CPP_HPP #include "Details/State.hpp" #endif // LUA_CPP_HPP
9247b9f8fce1baf9df477b05843feba6d504547d
c2c9e9bd2644d89e573e50e00993a2c07076d2e2
/Common/dslIniKey.cpp
64121433286e0ad80da2f5e168063e1aa8da5560
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "MIT", "BSL-1.0", "LicenseRef-scancode-public-domain" ]
permissive
TotteKarlsson/dsl
eeab84f4b6d0c951d73ff275b734b503ddb081c0
3807cbe5f90a3cd495979eafa8cf5485367b634c
refs/heads/master
2021-06-17T11:38:02.395605
2019-12-11T17:51:41
2019-12-11T17:51:41
166,859,372
0
0
NOASSERTION
2019-06-11T18:45:24
2019-01-21T18:17:04
Pascal
UTF-8
C++
false
false
1,078
cpp
dslIniKey.cpp
#pragma hdrstop #include "dslIniKey.h" //--------------------------------------------------------------------------- namespace dsl { IniKey::IniKey(const string& key) { setupKey(key); } IniKey::~IniKey() {} void IniKey::reKey(const string& key) { setupKey(key); } ostream& operator<<(ostream& stream, const IniKey& aKey) { stream << aKey.asString(); return stream; } string IniKey::asString(const char& delimiter) const { string tmp = mKey; tmp += " = "; tmp += mValue; return tmp; } int IniKey::asBool() const { return toBool(mValue); } int IniKey::asInt() const { return toInt(mValue); } double IniKey::asFloat() const { return toDouble(mValue); } void IniKey::setupKey(const string& key) { vector<string> recs = splitString(key, "="); if(recs.size() == 2) { mKey = recs[0]; mValue = recs[1]; mComment = gEmptyString; } else //We could throw { mKey = gEmptyString; mValue = gEmptyString; mComment = gEmptyString; } } }
e61f60b8ea6aafb1cc094954ecbe6acd53ea3e9f
52d7351122723fe21f28fff717908a506f545a74
/include/XmlFieldWrap.class.h
26b1aff7184fb59515a8032fbf550b0aa2c696ee
[]
no_license
shureg/xml_serialisation
dcd4a916272ebcf1dca7aa870140c3223cae3366
c37d9f876a232a28f079009f4ebdb07efd7f9fd1
refs/heads/master
2021-01-20T07:02:21.939889
2010-11-03T23:04:12
2010-11-03T23:04:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
966
h
XmlFieldWrap.class.h
// ===================================================================================== // // Filename: XmlFieldWrap.class.h // // Description: // // Version: 1.0 // Created: 09/10/2010 03:50:44 PM // Revision: none // Compiler: g++ // // Author: Alexander Kabanov (aak), alexander.kabanov@gmail.com // Company: // // ===================================================================================== #ifndef XMLFIELDWRAP_CLASS_INC #define XMLFIELDWRAP_CLASS_INC #include "xml_serialisation/XmlSerialisableObject.class.h" #include "xml_serialisation/XmlField.class.h" namespace XML_SERIALISATION { class XmlFieldWrap: public XmlSerialisableObject { public: explicit XmlFieldWrap(XmlField& xmlf); XmlField xml_description() const; protected: XmlField& xmlf; private: XmlFieldWrap(); }; } #endif // ----- #ifndef XMLFIELDWRAP_CLASS_INC -----
10542d1243253b74f2389b5e896af26e98d72b8a
a077943855cf1ac32ab4c2ff2311fb6966cbaee5
/ApCore/Events/POG/PogEvent.cpp
426d2b9868409fda327ef8caaa254df70e400277
[]
no_license
GeorgeKaraszi/Aphelion
58da7bae17872e0a54edafa4e9ed76e4dacf28c3
127a356155103383ac8a84deb7e52b5857eb0690
refs/heads/master
2023-04-28T12:09:16.870017
2021-05-02T22:32:14
2021-05-02T22:32:14
305,194,039
3
0
null
null
null
null
UTF-8
C++
false
false
5,037
cpp
PogEvent.cpp
#include "PogEvent.hpp" #include <ApInclude/fast_atio.hpp> #include <ApCore/Core/TeamManager.hpp> #include <ApData/Sql/Models/Event.hpp> #include <ApData/Sql/Models/Item.hpp> #include <ApData/Sql/Models/Loadout.hpp> #include <fmt/color.h> namespace ApCore::Events::POG { void PogEvent::Reset() { m_current_team = nullptr; } void PogEvent::_load_rules_impl() { m_rules = ApData::Sql::Query::PogQuery::GetPogRules(m_db); } std::vector<std::string> PogEvent::_trackable_event_names_impl() { return { DEATH_TRACK, FACILITY_CONTROL_TRACK }; } // { // "attacker_character_id": "5428010618015189713", // "attacker_fire_mode_id": "26103", // "attacker_loadout_id": "15", // "attacker_vehicle_id": "0", // "attacker_weapon_id": "26003", // "character_id": "5428168624838258657", // "character_loadout_id": "6", // "event_name": "Death", // "is_headshot": "1", // "timestamp": "1392056954", // "vehicle_id": "0", // "world_id": "1", // "zone_id": "2" // } bool PogEvent::_death_event_impl(const JSON &payload) { using namespace ApCore::Planetside; auto attacker_id = payload["attacker_character_id"].get<std::string>(); auto attacker_loadout_id = fast_atoi(payload["attacker_loadout_id"].get<std::string>()); auto attacker_weapon_id = fast_atoi(payload["attacker_weapon_id"].get<std::string>()); auto defender_id = payload["character_id"].get<std::string>(); auto defender_loadout_id = fast_atoi(payload["character_loadout_id"].get<std::string>()); bool headshot = payload["is_headshot"].get<std::string>()[0] == '1'; bool attacker_is_max = AP_VEC_MATCH_FOUND(m_rules.banned_profile_ids, attacker_loadout_id); bool defender_is_max = AP_VEC_MATCH_FOUND(m_rules.banned_profile_ids, defender_loadout_id); bool team_kill = false; bool suicide = false; Team::PLAYER_PTR attacker = nullptr; Team::PLAYER_PTR defender = nullptr; for(const auto &team : *m_team_manager) { if(BLANK_PTR(team)) continue; bool contains_attacker = team->ContainsPlayer(attacker_id); bool contains_defender = team->ContainsPlayer(defender_id); if(BLANK_PTR(attacker) && contains_attacker) { attacker = team->GetPlayer(attacker_id); } if(BLANK_PTR(defender) && contains_defender) { defender = team->GetPlayer(defender_id); } if(contains_attacker && contains_defender) { team_kill = attacker != defender; suicide = !team_kill; } } if(BLANK_PTR(attacker) || BLANK_PTR(defender) || attacker->benched || defender->benched) { return false; } auto item_db = ApData::Sql::Models::Item(m_db); auto loadout_db = ApData::Sql::Models::Loadout(m_db); auto weapon = item_db.FindByItemID(attacker_weapon_id); auto loadout = loadout_db.FetchByProfileID(attacker_loadout_id); fmt::print( fmt::emphasis::bold | fg(fmt::color::red), "[{}] {} killed [{}] {} - with: [{}] {} As: {}\n", attacker->team->Tag, attacker->player_name, defender->team->Tag, defender->player_name, weapon.id, weapon.name, loadout.empty() ? "Unknown" : loadout.front().name ); if(AP_VEC_MATCH_FOUND(m_rules.banned_item_ids, attacker_weapon_id)) { return true; } defender->AddDeath(); if(team_kill) { attacker->AddScore(attacker_is_max ? m_rules.max_team_kill : m_rules.team_kill); } else if(suicide) { attacker->AddScore(attacker_is_max ? m_rules.max_suicide : m_rules.suicide); } else { if(!attacker_is_max) { attacker->AddKill(headshot); attacker->AddScore(defender_is_max ? m_rules.max_kill : m_rules.kill); } defender->AddScore(m_rules.death); } return true; } // {"payload":{ // "duration_held":"2451", // "event_name":"FacilityControl", // "facility_id":"210001", // "new_faction_id":"2", // "old_faction_id":"2", // "outfit_id":"37577209674238761", // "timestamp":"1613248090", // "world_id":"13", // "zone_id":"6" // }, // "service":"event", // "type":"serviceMessage"} bool PogEvent::_base_capture_event_impl(const JSON &payload) { if(!payload.contains("outfit_id")) return false; auto outfit_id = payload["outfit_id"].get<std::string>(); auto team = m_team_manager->FindTeam(outfit_id); if(BLANK_PTR(team)) { return false; } else if(BLANK_PTR(m_current_team)) { team->AddTeamScore(m_rules.base_capture); // Base was captured for the first time in the round } else if(m_current_team->uuid != outfit_id) { team->AddTeamScore(m_rules.base_recapture); // Base was recaptured by the other team } m_current_team = team.get(); return true; } }