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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a51a7a5740e9b4cb74c8fb96d17cb12e8f0828e1 | e3897a46fe664015a2556a6eb5b89b49c1503124 | /Programni Ezici/oblak1Avtomobili.cpp | 991eb22a1fd757ce62da3e9061e7c36e10fb4894 | [] | no_license | martinesco/TechUni | c04142af76e3ca37893e6d43355d3063c46a07a0 | 59c7f08111ee28a26d7eaa67432422727cc6aabb | refs/heads/master | 2023-06-14T20:40:45.552099 | 2021-01-09T21:48:46 | 2021-01-09T21:48:46 | 255,327,935 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,156 | cpp | oblak1Avtomobili.cpp | /*
Даден е базов абстрактен клас Auto, който съдържа полетата тип на автомобила (лек, товарен).
Съдържа символен низ със съответната дума - марка на автомобила и година на производство.
Инициализиращия конструктор да задава стойност на тези полета чрез параметри.
Реализирайте абстрактен метод за извеждане на съдържанието на обекта в символен низ.
Даден е производен клас на класа Auto - лек автомобил - Car с полета наследени от Auto и
максимална скорост.
Демонстрирайте работата на класовете със създаване на колекция от различен тип автомобили и
извеждане на информация за всички леки автомобили, които са произведени преди 2000 година.
*/
|
9767aeef9b9a3e4d91719db6eaff89ee8c53d596 | 84c1035316183bf1a79d1359145c0e34f5cd62bc | /SubSystems/MusicSubSystem/MusicSubSystem.cpp | d7807c752bbb2358a1655f7364cfbd2c335e2fd5 | [] | no_license | OpenEngineDK/extensions-LuaScriptSystem | 3dd90e2edae27bf56832e7dafbcf8a5bd8d13c22 | f979ed8349282f36b791b5f12d8d62cd2e3e1191 | refs/heads/master | 2016-09-13T10:19:14.876359 | 2009-11-14T16:09:46 | 2009-11-14T16:09:46 | 58,073,116 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,117 | cpp | MusicSubSystem.cpp |
#include "MusicSubSystem.h"
#include "../../ScriptSystem.h"
string ScriptISound::classname = "ISound";
CPPToLuaBinder<ScriptISound>::RegType ScriptISound::Register[] = {
{"IsStereoSound", &ScriptISound::IsStereoSound},
{"IsMonoSound", &ScriptISound::IsMonoSound},
{"IsPlaying", &ScriptISound::IsPlaying},
{"Play", &ScriptISound::Play},
{"Stop", &ScriptISound::Stop},
{"Pause", &ScriptISound::Pause},
{"SetLooping", &ScriptISound::SetLooping},
{"GetLooping", &ScriptISound::GetLooping},
{"SetGain", &ScriptISound::SetGain},
{"GetGain", &ScriptISound::GetGain},
{"GetLengthInSamples", &ScriptISound::GetLengthInSamples},
{"GetLength", &ScriptISound::GetLength},
{"SetElapsedSamples", &ScriptISound::SetElapsedSamples},
{"GetElapsedSamples", &ScriptISound::GetElapsedSamples},
{"SetElapsedTime", &ScriptISound::SetElapsedTime},
{"GetElapsedTime", &ScriptISound::GetElapsedTime},
{"GetTimeLeft", &ScriptISound::GetTimeLeft},
{"IsAtEnd", &ScriptISound::IsAtEnd}
};
string ScriptIMonoSound::classname = "IMonoSound";
CPPToLuaBinder<ScriptIMonoSound>::RegType ScriptIMonoSound::Register[] = {
{"IsStereoSound", &ScriptIMonoSound::IsStereoSound},
{"IsMonoSound", &ScriptIMonoSound::IsMonoSound},
{"SetMaxDistance", &ScriptIMonoSound::SetMaxDistance},
{"GetMaxDistance", &ScriptIMonoSound::GetMaxDistance},
{"IsPlaying", &ScriptIMonoSound::IsPlaying},
{"Play", &ScriptIMonoSound::Play},
{"Stop", &ScriptIMonoSound::Stop},
{"Pause", &ScriptIMonoSound::Pause},
{"SetLooping", &ScriptIMonoSound::SetLooping},
{"GetLooping", &ScriptIMonoSound::GetLooping},
{"SetGain", &ScriptIMonoSound::SetGain},
{"GetGain", &ScriptIMonoSound::GetGain},
{"GetLengthInSamples", &ScriptIMonoSound::GetLengthInSamples},
{"GetLength", &ScriptIMonoSound::GetLength},
{"SetElapsedSamples", &ScriptIMonoSound::SetElapsedSamples},
{"GetElapsedSamples", &ScriptIMonoSound::GetElapsedSamples},
{"SetElapsedTime", &ScriptIMonoSound::SetElapsedTime},
{"GetElapsedTime", &ScriptIMonoSound::GetElapsedTime},
{"SetVelocity", &ScriptIMonoSound::SetVelocity},
{"GetVelocity", &ScriptIMonoSound::GetVelocity},
{"GetPosition", &ScriptIMonoSound::GetPosition},
{"SetPosition", &ScriptIMonoSound::SetPosition},
{"SetRelativePosition", &ScriptIMonoSound::SetRelativePosition},
{"GetResource", &ScriptIMonoSound::GetResource},
{"GetTimeLeft", &ScriptIMonoSound::GetTimeLeft},
{"IsAtEnd", &ScriptIMonoSound::IsAtEnd}
};
string ScriptIStereoSound::classname = "IStereoSound";
CPPToLuaBinder<ScriptIStereoSound>::RegType ScriptIStereoSound::Register[] = {
{"GetLeft", &ScriptIStereoSound::GetLeft},
{"GetRight", &ScriptIStereoSound::GetRight},
{"IsStereoSound", &ScriptIStereoSound::IsStereoSound},
{"IsMonoSound", &ScriptIStereoSound::IsMonoSound}
};
string ScriptISoundSystem::classname = "ISoundSystem";
CPPToLuaBinder<ScriptISoundSystem>::RegType ScriptISoundSystem::Register[] = {
{"CreateSound", &ScriptISoundSystem::CreateSound},
{"SetRoot", &ScriptISoundSystem::SetRoot},
{"SetMasterGain", &ScriptISoundSystem::SetMasterGain},
{"GetMasterGain", &ScriptISoundSystem::GetMasterGain}
};
string ScriptOpenALSoundSystem::classname = "OpenALSoundSystem";
CPPToLuaBinder<ScriptOpenALSoundSystem>::RegType ScriptOpenALSoundSystem::Register[] = {
{"CreateSound", &ScriptOpenALSoundSystem::CreateSound},
{"SetRoot", &ScriptOpenALSoundSystem::SetRoot},
{"SetMasterGain", &ScriptOpenALSoundSystem::SetMasterGain},
{"GetMasterGain", &ScriptOpenALSoundSystem::GetMasterGain},
{"GetOpenALSoundSystem", &ScriptOpenALSoundSystem::GetOpenALSoundSystem}
};
string ScriptITransitionMode::classname = "ITransitionMode";
CPPToLuaBinder<ScriptITransitionMode>::RegType ScriptITransitionMode::Register[] = {
{"InitFade", &ScriptITransitionMode::InitFade},
{"GetInTime", &ScriptITransitionMode::GetInTime},
{"GetOutTime", &ScriptITransitionMode::GetOutTime},
{"Process", &ScriptITransitionMode::Process},
{"IsDone", &ScriptITransitionMode::IsDone},
{"Start", &ScriptITransitionMode::Start}
};
string ScriptBruteTransitionMode::classname = "BruteTransitionMode";
CPPToLuaBinder<ScriptBruteTransitionMode>::RegType ScriptBruteTransitionMode::Register[] = {
{"InitFade", &ScriptBruteTransitionMode::InitFade},
{"GetInTime", &ScriptBruteTransitionMode::GetInTime},
{"GetOutTime", &ScriptBruteTransitionMode::GetOutTime},
{"Process", &ScriptBruteTransitionMode::Process},
{"IsDone", &ScriptBruteTransitionMode::IsDone},
{"Start", &ScriptBruteTransitionMode::Start}
};
string ScriptMusicPlayer::classname = "MusicPlayer";
CPPToLuaBinder<ScriptMusicPlayer>::RegType ScriptMusicPlayer::Register[] = {
{"AddSound", &ScriptMusicPlayer::AddSound},
{"Previous", &ScriptMusicPlayer::Previous},
{"Next", &ScriptMusicPlayer::Next},
{"SwitchTo", &ScriptMusicPlayer::SwitchTo},
{"NumberOfTracks", &ScriptMusicPlayer::NumberOfTracks},
{"Play", &ScriptMusicPlayer::Play},
{"Stop", &ScriptMusicPlayer::Stop},
{"Pause", &ScriptMusicPlayer::Pause},
{"Shuffle", &ScriptMusicPlayer::Shuffle},
{"SetTransitionMode", &ScriptMusicPlayer::SetTransitionMode},
{"SetGain", &ScriptMusicPlayer::SetGain},
{"GetGain", &ScriptMusicPlayer::GetGain},
{"GetMusicPlayer", &ScriptMusicPlayer::GetMusicPlayer}
};
int ActivateMusicSubSystem(lua_State* L) {
if (ScriptSystem::CheckStackSize(L, "ActivateMusicSubSystem", 0))
return 0;
//IMPORTANT NOTE TO THOSE WONDERING ABOUT THE STACK COUNT
//IN THE CHECKS IN ALL THESE FILES. IT IS ONE HIGHER THAN
//ONE SHOULD THINK AND THAT IS BECAUSE THE TABLE RESPRESENTING
//THE CLASS IS ALSO ON THE STACK AT INDEX 0 (BOTTOM)
ScriptSystem::RegisterClass<ScriptISound>();
ScriptSystem::RegisterClass<ScriptIStereoSound>();
ScriptSystem::RegisterClass<ScriptIMonoSound>();
ScriptSystem::RegisterClass<ScriptISoundSystem>();
ScriptSystem::RegisterClass<ScriptOpenALSoundSystem>();
ScriptSystem::RegisterClass<ScriptITransitionMode>();
ScriptSystem::RegisterClass<ScriptBruteTransitionMode>();
ScriptSystem::RegisterClass<ScriptMusicPlayer>();
return 0;
}
|
f8e968bdcd9f5d86855961df4031c641a0ab6c3c | 8e7f8cc3761d213add1abd55941a6681abdc8e0c | /src/io/console/msgstream.h | d39c97d8bb65d9c8a9c68d5e9360f8cfa2ee0286 | [
"MIT"
] | permissive | szynka12/deiimos | 7fb6d338ef3845812cae4920b66f4703b8cf9753 | 9cab00bc869d9d672cbd24271812ae7643317377 | refs/heads/master | 2020-12-27T21:11:22.572284 | 2020-04-03T16:14:14 | 2020-04-03T16:14:14 | 238,057,007 | 0 | 0 | MIT | 2020-04-03T16:14:15 | 2020-02-03T20:37:09 | C++ | UTF-8 | C++ | false | false | 1,808 | h | msgstream.h | #ifndef SRC_IO_CONSOLE_MSGSTREAM_H
#define SRC_IO_CONSOLE_MSGSTREAM_H
#include <iostream>
#include <memory>
#include <utility>
namespace deiimos
{
class MsgObject
{
public:
// verbosity
enum v_level
{
SILENT = 0,
INFO1 = 1,
INFO2 = 2,
INFO3 = 3
};
private:
// buffers
class NullBuffer : public std::streambuf
{
public:
int overflow( int c ) { return c; }
};
NullBuffer null_buffer_;
// streams
std::ostream standard_ostream_;
std::ostream null_ostream_;
std::ostream error_ostream_;
std::ostream warning_ostream_;
// global verbosity
v_level out_level_ = INFO1;
bool warning_enabled_ = true;
public:
MsgObject( );
std::ostream& standard( );
std::ostream& warning( );
std::ostream& null( );
std::ostream& error( );
std::ostream& msg( v_level l );
void set_verbosity( v_level l );
void set_warning( bool flag );
};
namespace INTERNAL
{
extern MsgObject msg_;
}
inline void set_verbosity( MsgObject::v_level l )
{
INTERNAL::msg_.set_verbosity( l );
}
inline void set_verbosity( int l )
{
INTERNAL::msg_.set_verbosity(
static_cast< deiimos::MsgObject::v_level >( l ) );
}
inline void set_warning( bool flag ) { INTERNAL::msg_.set_warning( flag ); }
inline std::ostream& msg( MsgObject::v_level l = MsgObject::INFO1 )
{
return INTERNAL::msg_.msg( l );
}
inline std::ostream& msg( int l )
{
return msg( static_cast< deiimos::MsgObject::v_level >( l ) );
}
inline std::ostream& err( )
{
return INTERNAL::msg_.error( ) << "*** Fatal error! ***\n";
}
inline std::ostream& warn( )
{
return INTERNAL::msg_.warning( ) << "--- Warning ---\n";
}
} // namespace deiimos
#endif // SRC_IO_CONSOLE_MSGSTREAM_H
|
c956cfa5796d80f7293ab0626052c05ecdf9cc35 | 4466dd4070921a82abb124c3f3ac5cf6f993b727 | /insearch.cpp | 63361c6022adc0e968aedb191f9b4f9211a85699 | [] | no_license | vasanth9/codeforces | a9e058e7f90b152dd94268d2187f69a5dcdb4941 | 316920e6a3d3f27508adebfe827fa77b2e528ef6 | refs/heads/master | 2021-05-18T02:50:53.980491 | 2020-12-08T12:48:37 | 2020-12-08T12:48:37 | 251,072,114 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 152 | cpp | insearch.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int n;string s="EASY";
cin>>n;int b;
while(n--)
{
cin>>b;
if(b==1)
s="HARD";
}
cout<<s;
} |
a7d5f32bba570d2ba75db6f35335406612800678 | 0ae071be2636ffc1135096ec7aaffac725b5fe65 | /EOD_SUIT/Config.cpp | 4cf26b8a5bac42b71685f1ed3783cfd82a679080 | [] | no_license | kennychr/ied_test | a86b45334de602b8cd9eae566a2680b71d5049c7 | ca03f51f4775f1f659c8e86f888027de86732273 | refs/heads/master | 2020-03-22T20:11:12.964162 | 2018-07-15T01:26:27 | 2018-07-15T01:26:27 | 140,579,371 | 1 | 2 | null | 2018-07-12T21:41:47 | 2018-07-11T13:30:38 | C++ | UTF-8 | C++ | false | false | 39,087 | cpp | Config.cpp | class DefaultEventhandlers;
class CfgPatches
{
class EOD_SUIT
{
units[]={};
author="Mr Ewok, NorX Aengell,Burnes15th";
weapons[]={"EOD9_HELMET","EOD_SUIT_vest","EOD_Uniform"};
requiredVersion=0.1;
requiredAddons[]={};
};
};
class Extended_PostInit_EventHandlers
{
EOD_SUIT_Init="if (hasInterface) then {[] execVM '\EOD_SUIT\XENO_Init_Script_EOD_SUIT.sqf'}";
};
class EODS_SoundRegulation_settings
{
// #include "\userconfig\EODS\EODS_config.hpp"
};
class CfgSounds
{
class Redbreather2_resp_Low
{
name="Redbreather2_resp_Low";
sound[]=
{
"EOD_SUIT\Sound\Redbreather2_resp_Low_1shot.wss", // "EOD_SUIT\Sound\Redbreather2_resp_Low.wss",
4,
1,
1
};
titles[]={};
};
class Redbreather3_resp_High
{
name="Redbreather3_resp_High";
sound[]=
{
"EOD_SUIT\Sound\Redbreather3_resp_High_1shot.wss", //"EOD_SUIT\Sound\Redbreather3_resp_High.wss",
4,
1,
1
};
titles[]={};
};
};
class CfgVehicleClasses
{
class EWK_veh_class
{
displayName = "$STR_EODS_EOD_units";
};
};
class UniformSlotInfo;
class CfgVehicles
{
class Man;
class CAManBase: Man
{
class HitPoints
{
class HitHead;
class HitBody;
class HitHands;
class HitLegs;
};
};
class SoldierWB: CAManBase
{
threat[] = {1, 0.1, 0.1};
};
class B_Soldier_base_F: SoldierWB
{
};
class B_engineer_F: B_Soldier_base_F
{
};
class EOD_engineer: B_engineer_F
{
scope= 2;
author = "MrEwok";
displayName= "$STR_EOD_engineer";
vehicleClass= "EWK_veh_class";
engineer = 1;
attendant = 0;
uniformAccessories[]= {};
nakedUniform = "U_BasicBody";
uniformClass= "EOD_Uniform";
model= "\EOD_SUIT\Models\EOD_Uniform.p3d";
hiddenSelections[]={"insignia"};
hiddenSelectionsTextures[]={};
weapons[]= {"Throw","Put"};
respawnWeapons[]= {"Throw","Put"};
Items[]= {"FirstAidKit"};
RespawnItems[]= {"FirstAidKit"};
magazines[]= {};
respawnMagazines[]= {};
linkedItems[] = {"EOD9_HELMET","EOD_SUIT_vest","ItemMap","ItemCompass","ItemWatch","ItemRadio"};
respawnLinkedItems[] = {"EOD9_HELMET","EOD_SUIT_vest","ItemMap","ItemCompass","ItemWatch","ItemRadio"};
backpack = "";
// class Eventhandlers
// {
// init= "_this call EOD_Suit_fnc_Check_Helmet";
// };
class Wounds
{
tex[] = {};
mat[] = {
"eod_suit\textureswip\green_tex2.rvmat", /// what material is changed
"eod_suit\textureswip\Green_Tex_wound.rvmat", /// how does the material look like in damage 0.5 and more
"eod_suit\textureswip\Green_Tex_wound.rvmat", /// how does the material look like while the part has damage 1
"A3\Characters_F\Heads\Data\hl_white_bald_muscular.rvmat", /// next materials are used through personality of the soldier
"A3\Characters_F\Heads\Data\hl_white_bald_muscular_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_white_bald_muscular_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_black_bald_muscular.rvmat",
"A3\Characters_F\Heads\Data\hl_black_bald_muscular_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_black_bald_muscular_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_white_hairy_muscular.rvmat",
"A3\Characters_F\Heads\Data\hl_white_hairy_muscular_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_white_hairy_muscular_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_white_old.rvmat",
"A3\Characters_F\Heads\Data\hl_white_old_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_white_old_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_asian_bald_muscular.rvmat",
"A3\Characters_F\Heads\Data\hl_asian_bald_muscular_injury.rvmat",
"A3\Characters_F\Heads\Data\hl_asian_bald_muscular_injury.rvmat"
};
};
};
class LandVehicle;
class Car: LandVehicle
{
class NewTurret;
};
class Car_F: Car
{
class AnimationSources;
class Turrets
{
class MainTurret: NewTurret{};
};
class HitPoints
{
class HitLFWheel;
class HitLF2Wheel;
class HitRFWheel;
class HitRF2Wheel;
class HitGlass1;
class HitGlass2;
class HitGlass3;
class HitGlass4;
class HitGlass5;
class HitGlass6;
};
};
class EOD9_HELMET_Lights_VEH_base: Car_F
{
class SpeechVariants
{
class Default
{
speechSingular[]=
{
"veh_vehicle_armedcar_s"
};
speechPlural[]=
{
"veh_vehicle_armedcar_p"
};
};
};
textSingular = "$STR_A3_nameSound_veh_vehicle_armedcar_s";
textPlural = "$STR_A3_nameSound_veh_vehicle_armedcar_p";
nameSound = "veh_vehicle_armedcar_s";
author = "MrEwok";
_generalMacro = "EOD9_HELMET_Lights_VEH_base";
model = "\EOD_SUIT\Models\EOD9_HELMET_Lights_VEH.p3d";
Picture="";
Icon="";
mapSize = 6;
displayName = "EOD9_HELMET_Lights_VEH_base";
scope = 1;
faction = BLU_F;
side = 1;
vehicleClass = "Car";
crew = "B_Soldier_F";
typicalCargo[]=
{
"B_Soldier_F"
};
//accuracy=0.3;
//water resistance and effects on vehicle (this may need to be raised to avoid the engine be destructed by water)
WaterLeakiness = 10; // 0 for no water dammage
maxFordingDepth = 0.5; // 100 so it's able to go about 100m under the sea level
waterResistance = 1; // 100 for heavy water resistance
//
wheelCircumference=2.8340001;
antiRollbarForceCoef=12;
antiRollbarForceLimit=10;
antiRollbarSpeedMin=20;
antiRollbarSpeedMax=50;
crewVulnerable=1; // can the crew be killed? 1= yes, 0 = no
crewCrashProtection=0.15000001;
weapons[]= //we can give a horn by defining it as a weapon and add it here (this is the vehicle weapon not the turret one )
{
};
magazines[]={};
damperSize=0.2;
damperForce=1;
damperDamping=1;
armor=80;
damageResistance=0.00562;
turnCoef=2.5;
steerAheadPlan=0.2;
steerAheadSimul=0.40000001;
predictTurnPlan=0.89999998;
predictTurnSimul=0.5;
brakeDistance=1;
terrainCoef=1.5;
wheelDamageThreshold=0.69999999;
wheelDestroyThreshold=0.99000001;
wheelDamageRadiusCoef=0.94999999;
wheelDestroyRadiusCoef=0.44999999;
cost=200000;
precision=15;
armorGlass=0.5;
armorWheels=0.1;
soundServo[]=
{
"A3\sounds_f\dummysound",
0.0099999998,
1,
10
};
soundEnviron[]=
{
"",
0.56234133,
1
};
transportMaxBackpacks=0;
transportSoldier=0;
class Library
{
libTextDesc = "EOD9_HELMET_Lights_VEH_base";
};
castDriverShadow="false";
driverAction = "passenger_injured_medevac_truck01"; // rtm related to driver
cargoAction[] =
{
// "passenger_injured_medevac_truck01" // Medical HEMTT anim
};
threat[] = {0.8,0.6,0.3};
// this part define the driver animations related to model.cfg an p3d named selection
driverLeftHandAnimName = "drivewheel";
driverRightHandAnimName = "";
driverLeftLegAnimName = "";
driverRightLegAnimName = "pedal_thrust";
//
class TransportMagazines
{
};
class TransportItems
{
};
class TransportWeapons
{
};
//PhysX Part.....
idleRpm = 800;
redRpm = 4500;
brakeIdleSpeed = 1.78;
fuelCapacity = 250;
class complexGearbox
{
GearboxRatios[]=
{
"R1",
-5.75,
"N",
0,
"D1",
4.3000002,
"D2",
2.3,
"D3",
1.5,
"D4",
1,
"D5",
0.73000002
};
TransmissionRatios[]=
{
"High",
6.7589998
};
gearBoxMode="auto";
moveOffGear=1;
driveString="D";
neutralString="N";
reverseString="R";
};
simulation="carx";
dampersBumpCoef=6;
differentialType="all_limited";
frontRearSplit=0.5;
frontBias=1.3;
rearBias=1.3;
centreBias=1.3;
clutchStrength=20;
enginePower=276;
maxOmega=471;
peakTorque=1253;
dampingRateFullThrottle=0.079999998;
dampingRateZeroThrottleClutchEngaged=2;
dampingRateZeroThrottleClutchDisengaged=0.34999999;
torqueCurve[]=
{
{0,0},
{0.278,0.5},
{0.34999999,0.75},
{0.461,1},
{0.60000002,0.94999999},
{0.69999999,0.85000002},
{0.80000001,0.75},
{1,0.5}
};
changeGearMinEffectivity[]={0.94999999,0.15000001,0.94999999,0.94999999,0.94999999,0.94999999,0.94999999};
switchTime=0.31;
latency=1;
class Wheels
{
class LF
{
boneName="wheel_1_1_damper";
steering=1;
side="left";
center="wheel_1_1_axis";
boundary="wheel_1_1_bound";
width="0.126";
mass=30;
MOI=12.8;
dampingRate=0.1;
maxBrakeTorque=10000;
maxHandBrakeTorque=0;
suspTravelDirection[]={0,-1,0};
suspForceAppPointOffset="wheel_1_1_axis";
tireForceAppPointOffset="wheel_1_1_axis";
maxCompression=0.050000001;
mMaxDroop=0.1;
sprungMass=825;
springStrength=51625; //default = 51625
springDamperRate=8920; //default = 8920
longitudinalStiffnessPerUnitGravity=10000;
latStiffX=25;
latStiffY=180;
frictionVsSlipGraph[]=
{
{0,1},
{0.5,1},
{1,1}
};
};
class LR: LF
{
boneName="wheel_1_2_damper";
steering=0;
center="wheel_1_2_axis";
boundary="wheel_1_2_bound";
suspForceAppPointOffset="wheel_1_2_axis";
tireForceAppPointOffset="wheel_1_2_axis";
maxHandBrakeTorque=3500;
};
class RF: LF
{
boneName="wheel_2_1_damper";
center="wheel_2_1_axis";
boundary="wheel_2_1_bound";
suspForceAppPointOffset="wheel_2_1_axis";
tireForceAppPointOffset="wheel_2_1_axis";
steering=1;
side="right";
};
class RR: RF
{
boneName="wheel_2_2_damper";
steering=0;
center="wheel_2_2_axis";
boundary="wheel_2_2_bound";
suspForceAppPointOffset="wheel_2_2_axis";
tireForceAppPointOffset="wheel_2_2_axis";
maxHandBrakeTorque=3500;
};
};
attenuationEffectType="CarAttenuation"; //external sound occlusion when inside
/*To remove the unneeded sounds just leave a empty array like that:
soundGetIn[]=
{
};
*/
soundGetIn[]=
{
};
soundGetOut[]=
{
};
soundDammage[]=
{
};
soundEngineOnInt[]=
{
};
soundEngineOnExt[]=
{
};
soundEngineOffInt[]=
{
};
soundEngineOffExt[]=
{
};
buildCrash0[]=
{
};
buildCrash1[]=
{
};
buildCrash2[]=
{
};
buildCrash3[]=
{
};
soundBuildingCrash[]=
{
};
WoodCrash0[]=
{
};
WoodCrash1[]=
{
};
WoodCrash2[]=
{
};
WoodCrash3[]=
{
};
WoodCrash4[]=
{
};
WoodCrash5[]=
{
};
soundWoodCrash[]=
{
};
ArmorCrash0[]=
{
};
ArmorCrash1[]=
{
};
ArmorCrash2[]=
{
};
ArmorCrash3[]=
{
};
soundArmorCrash[]=
{
};
class Sounds
{
class Idle_ext // This is the idle sound hearable from outside (when not in cargo)
{
sound[]=
{
};
frequency="0.95 + ((rpm/ 4500) factor[(800/ 4500),(1400/ 4500)])*0.15";
volume="engineOn*camPos*(((rpm/ 4500) factor[(600/ 4500),(1100/ 4500)]) * ((rpm/ 4500) factor[(1800/ 4500),(1300/ 4500)]))";
};
class Engine
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(1400/ 4500),(2100/ 4500)])*0.2";
volume="engineOn*camPos*(((rpm/ 4500) factor[(1400/ 4500),(1800/ 4500)]) * ((rpm/ 4500) factor[(2300/ 4500),(2000/ 4500)]))";
};
class Engine1_ext
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(2100/ 4500),(2800/ 4500)])*0.2";
volume="engineOn*camPos*(((rpm/ 4500) factor[(1900/ 4500),(2300/ 4500)]) * ((rpm/ 4500) factor[(3000/ 4500),(2500/ 4500)]))";
};
class Engine2_ext
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(2800/ 4500),(3600/ 4500)])*0.2";
volume="engineOn*camPos*(((rpm/ 4500) factor[(2500/ 4500),(3100/ 4500)]) * ((rpm/ 4500) factor[(4500/ 4500),(3700/ 4500)]))";
};
class Engine3_ext
{
sound[]=
{
};
frequency="0.95 + ((rpm/ 4500) factor[(3600/ 4500),(4500/ 4500)])*0.1";
volume="engineOn*camPos*((rpm/ 4500) factor[(3800/ 4500),(4500/ 4500)])";
};
class IdleThrust
{
sound[]=
{
};
frequency="0.95 + ((rpm/ 4500) factor[(800/ 4500),(1400/ 4500)])*0.15";
volume="engineOn*camPos*(0.4+(0.6*(thrust factor[0.1,1])))*(((rpm/ 4500) factor[(600/ 4500),(1100/ 4500)]) * ((rpm/ 4500) factor[(1800/ 4500),(1300/ 4500)]))";
};
class EngineThrust
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(1400/ 4500),(2100/ 4500)])*0.2";
volume="engineOn*camPos*(0.4+(0.6*(thrust factor[0.1,1])))*(((rpm/ 4500) factor[(1400/ 4500),(1800/ 4500)]) * ((rpm/ 4500) factor[(2300/ 4500),(2000/ 4500)]))";
};
class Engine1_Thrust_ext
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(2100/ 4500),(2800/ 4500)])*0.2";
volume="engineOn*camPos*(0.4+(0.6*(thrust factor[0.1,1])))*(((rpm/ 4500) factor[(1900/ 4500),(2300/ 4500)]) * ((rpm/ 4500) factor[(3000/ 4500),(2500/ 4500)]))";
};
class Engine2_Thrust_ext
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(2800/ 4500),(3600/ 4500)])*0.2";
volume="engineOn*camPos*(0.4+(0.6*(thrust factor[0.1,1])))*(((rpm/ 4500) factor[(2500/ 4500),(3100/ 4500)]) * ((rpm/ 4500) factor[(4500/ 4500),(3700/ 4500)]))";
};
class Engine3_Thrust_ext
{
sound[]=
{
};
frequency="0.95 + ((rpm/ 4500) factor[(3600/ 4500),(4500/ 4500)])*0.1";
volume="engineOn*camPos*(0.4+(0.6*(thrust factor[0.1,1])))*((rpm/ 4500) factor[(3800/ 4500),(4500/ 4500)])";
};
class Idle_int // This is the idle sound hearable from inside (when in cargo)
{
sound[]=
{
};
frequency="0.95 + ((rpm/ 4500) factor[(800/ 4500),(1400/ 4500)])*0.15";
volume="engineOn*(1-camPos)*(((rpm/ 4500) factor[(600/ 4500),(1100/ 4500)]) * ((rpm/ 4500) factor[(1800/ 4500),(1300/ 4500)]))";
};
class Engine_int
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(1400/ 4500),(2100/ 4500)])*0.2";
volume="engineOn*(1-camPos)*(((rpm/ 4500) factor[(1400/ 4500),(1800/ 4500)]) * ((rpm/ 4500) factor[(2300/ 4500),(2000/ 4500)]))";
};
class Engine1_int
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(2100/ 4500),(2800/ 4500)])*0.2";
volume="engineOn*(1-camPos)*(((rpm/ 4500) factor[(1900/ 4500),(2300/ 4500)]) * ((rpm/ 4500) factor[(3000/ 4500),(2500/ 4500)]))";
};
class Engine2_int
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(2800/ 4500),(3600/ 4500)])*0.2";
volume="engineOn*(1-camPos)*(((rpm/ 4500) factor[(2500/ 4500),(3100/ 4500)]) * ((rpm/ 4500) factor[(4500/ 4500),(3700/ 4500)]))";
};
class Engine3_int
{
sound[]=
{
};
frequency="0.95 + ((rpm/ 4500) factor[(3600/ 4500),(4500/ 4500)])*0.1";
volume="engineOn*(1-camPos)*((rpm/ 4500) factor[(3800/ 4500),(4500/ 4500)])";
};
class IdleThrust_int
{
sound[]=
{
};
frequency="0.95 + ((rpm/ 4500) factor[(800/ 4500),(1400/ 4500)])*0.15";
volume="engineOn*(1-camPos)*(0.4+(0.6*(thrust factor[0.1,1])))*(((rpm/ 4500) factor[(600/ 4500),(1100/ 4500)]) * ((rpm/ 4500) factor[(1800/ 4500),(1300/ 4500)]))";
};
class EngineThrust_int
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(1400/ 4500),(2100/ 4500)])*0.2";
volume="engineOn*(1-camPos)*(0.4+(0.6*(thrust factor[0.1,1])))*(((rpm/ 4500) factor[(1400/ 4500),(1800/ 4500)]) * ((rpm/ 4500) factor[(2300/ 4500),(2000/ 4500)]))";
};
class Engine1_Thrust_int
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(2100/ 4500),(2800/ 4500)])*0.2";
volume="engineOn*(1-camPos)*(0.4+(0.6*(thrust factor[0.1,1])))*(((rpm/ 4500) factor[(1900/ 4500),(2300/ 4500)]) * ((rpm/ 4500) factor[(3000/ 4500),(2500/ 4500)]))";
};
class Engine2_Thrust_int
{
sound[]=
{
};
frequency="0.9 + ((rpm/ 4500) factor[(2800/ 4500),(3600/ 4500)])*0.2";
volume="engineOn*(1-camPos)*(0.4+(0.6*(thrust factor[0.1,1])))*(((rpm/ 4500) factor[(2500/ 4500),(3100/ 4500)]) * ((rpm/ 4500) factor[(4500/ 4500),(3700/ 4500)]))";
};
class Engine3_Thrust_int
{
sound[]=
{
};
frequency="0.95 + ((rpm/ 4500) factor[(3600/ 4500),(4500/ 4500)])*0.1";
volume="engineOn*(1-camPos)*(0.4+(0.6*(thrust factor[0.1,1])))*((rpm/ 4500) factor[(3800/ 4500),(4500/ 4500)])";
};
class TiresRockOut
{
};
class TiresSandOut
{
};
class TiresGrassOut
{
};
class TiresMudOut
{
};
class TiresGravelOut
{
};
class TiresAsphaltOut
{
};
class NoiseOut
{
sound[]=
{
};
frequency="1";
volume="camPos*(damper0 max 0.02)*(speed factor[0, 8])";
};
class TiresRockIn
{
};
class TiresSandIn
{
};
class TiresGrassIn
{
};
class TiresMudIn
{
};
class TiresGravelIn
{
};
class TiresAsphaltIn
{
};
class NoiseIn
{
sound[]=
{
};
frequency="1";
volume="(damper0 max 0.1)*(speed factor[0, 8])*(1-camPos)";
};
class breaking_ext_road
{
};
class acceleration_ext_road
{
};
class turn_left_ext_road
{
};
class turn_right_ext_road
{
};
class breaking_ext_dirt
{
};
class acceleration_ext_dirt
{
};
class turn_left_ext_dirt
{
};
class turn_right_ext_dirt
{
};
class breaking_int_road
{
};
class acceleration_int_road
{
};
class turn_left_int_road
{
};
class turn_right_int_road
{
};
class breaking_int_dirt
{
};
class acceleration_int_dirt
{
};
class turn_left_int_dirt
{
};
class turn_right_int_dirt
{
};
};
class Turrets: Turrets
{
class MainTurret: MainTurret
{
/* body="mainTurret";
gun="mainGun";
hasGunner=1;
weapons[]=
{
"HMG_M2"
};
magazines[]=
{
"100Rnd_127x99_mag_Tracer_Red",
"100Rnd_127x99_mag_Tracer_Red",
"100Rnd_127x99_mag_Tracer_Red",
"100Rnd_127x99_mag_Tracer_Red",
"100Rnd_127x99_mag_Tracer_Red",
"100Rnd_127x99_mag_Tracer_Red",
"100Rnd_127x99_mag_Tracer_Red",
"100Rnd_127x99_mag_Tracer_Red"
};
soundServo[]=
{
"A3\sounds_f\dummysound",
0.0099999998,
1,
10
};
minElev=-25;
maxElev=60;
gunnerAction="HMMWV_Gunner01";
viewGunnerInExternal="true";
castGunnerShadow=1;
stabilizedInAxes="StabilizedInAxesNone";
gunnerRightHandAnimName="OtocHlaven_shake";
gunnerLeftHandAnimName="OtocHlaven_shake";*/
};
};
class HitPoints: HitPoints
{
class HitGlass1: HitGlass1
{
armor=0.1;
};
class HitGlass2: HitGlass2
{
armor=0.1;
};
class HitGlass3: HitGlass3
{
armor=0.1;
};
class HitGlass4: HitGlass4
{
armor=0.1;
};
class HitLFWheel: HitLFWheel
{
armor=0.38;
};
class HitLBWheel: HitLF2Wheel
{
armor=0.38;
};
class HitRFWheel: HitRFWheel
{
armor=0.38;
};
class HitRBWheel: HitRF2Wheel
{
armor=0.38;
};
class HitFuel
{
armor=1.4;
material=-1;
name="palivo";
visual="";
passThrough=1;
};
};
class Damage
{
tex[]={};
mat[]={
/* Here you define the rvmats for destruction
"", //original material applied
"", // material applied at 0.5 dammage
"" // material applied at 1 dammage */
};
};
class Reflectors
{
class Left
{
/* color[]={1900,1300,950};
ambient[]={5,5,5};
position="flash_L";
direction="flash_L_dir";
hitpoint="flash_L";
selection="flash_L";
size=1;
innerAngle=100;
outerAngle=179;
coneFadeCoef=10;
intensity=1;
useFlare=0;
dayLight=0;
flareSize=1;
class Attenuation
{
start=1;
constant=0;
linear=0;
quadratic=0.25;
hardLimitStart=30;
hardLimitEnd=60;
*/
color[] = {180,156,120};
ambient[] = {0.9,0.78,0.6};
intensity = 20;
size = 1;
innerAngle = 20;
outerAngle = 80;
coneFadeCoef = 5;
position = "flash";
direction = "flash dir";
selection="flash_L";
hitpoint="flash_L";
useFlare = 1;
flareSize = 1.4;
flareMaxDistance = "100.0f";
dayLight = 0;
class Attenuation
{
start = 0.5;
constant = 0;
linear = 0;
quadratic = 1.1;
hardLimitStart = 20;
hardLimitEnd = 30;
};
};
/* class Right: Left
{
position="flash_R";
direction="flash_R_dir";
hitpoint="flash_R";
selection="flash_R";
};*/
/* class Right2: Right
{
useFlare=1;
position="P svetlo";
};
class Left2: Left
{
useFlare=1;
position="L svetlo";
};*/
};
aggregateReflectors[]=
{
{
"Left"//,
//"Right",
// "Left2",
// "Right2"
}
};
class RenderTargets //PIP
{
/* class LeftMirror
{
renderTarget="rendertarget0";
class CameraView1
{
pointPosition="PIP0_pos";
pointDirection="PIP0_dir";
renderQuality=2;
renderVisionMode=4;
fov=0.69999999;
};
};
class RightMirror
{
renderTarget="rendertarget1";
class CameraView1
{
pointPosition="PIP1_pos";
pointDirection="PIP1_dir";
renderQuality=2;
renderVisionMode=4;
fov=0.69999999;
};
};
*/
};
};
class EOD9_HELMET_Lights_VEH: EOD9_HELMET_Lights_VEH_base
{
scope = 2;
faction = BLU_F;
side = 1;
vehicleClass = "Car";
model = "\EOD_SUIT\Models\EOD9_HELMET_Lights_VEH.p3d";
displayname = "EOD9_HELMET_Lights_VEH";
hasGunner = 0;
transportSoldier=0;
cargoAction[] =
{
//"passenger_injured_medevac_truck01" // define the cargo action here
};
threat[]={0,0,0};
driverLeftHandAnimName="drivewheel";
driverRightHandAnimName="";
driverLeftLegAnimName = "";
driverRightLegAnimName = "pedal_thrust";
armor=120;
damageResistance=0.030990001;
Picture = "";
icon = "";
//attendant=0; //this is the basic can heal variable from a3
/*class Eventhandlers
{
};*/
class Library
{
libTextDesc = "EOD9_HELMET_Lights_VEH";
};
class Turrets: Turrets
{
};
class AnimationSources: AnimationSources
{
};
class UserActions
{
};
class TransportWeapons
{
};
class TransportItems
{
};
class Damage
{
tex[] = {};
mat[] =
{
//once again dammage rvmat applied
};
};
HiddenSelections[] =
{
/*
//Related to named selection in model.
"camo",
"camo1",
"camo2",
"camo3"*/
};
HiddenSelectionsTextures[] =
{
/*Path to textures applied to the related hiddenselection*/
};
};
};
class cfgWeapons
{
class InventoryItem_Base_F;
class ItemCore;
class UniformItem: InventoryItem_Base_F
{
type=801;
};
class VestItem: InventoryItem_Base_F
{
type=701;
uniformType="Default";
hiddenSelections[]={};
armor=0;
passThrough=1;
hitpointName="HitBody";
};
class HeadgearItem: InventoryItem_Base_F
{
allowedSlots[]={901,605};
type=605;
hiddenSelections[]={};
armor=0;
passThrough=1;
hitpointName="HitHead";
};
class EOD9_HELMET_Base: ItemCore
{
scope=2;
weaponPoolAvailable=1;
displayName="EOD9_HELMET_Base";
picture="\EOD_SUIT\UI\EOD9_Helmet_Icon_ca.paa";
model="\EOD_SUIT\Models\EOD9_HELMET.p3d";
hiddenSelections[]=
{
"camo"
};
hiddenSelectionsTextures[]={};
class ItemInfo: HeadgearItem
{
mass=40;
uniformModel="\EOD_SUIT\Models\EOD9_HELMET.p3d";
modelSides[]={6};
armor=4;
passThrough=0.5;
hiddenSelections[]=
{
};
};
};
class EOD9_HELMET: EOD9_HELMET_Base
{
displayName="$STR_EOD9_HELMET";
model="\EOD_SUIT\Models\EOD9_HELMET.p3d";
hiddenSelections[]=
{
};
hiddenSelectionsTextures[]=
{
};
class ItemInfo: HeadgearItem
{
mass=800;
uniformModel="\EOD_SUIT\Models\EOD9_HELMET.p3d";
modelSides[]={6};
armor=10000;
passThrough=0.0;
hiddenSelections[]=
{
};
};
};
class Uniform_EOD_Base: ItemCore
{
scope=0;
allowedSlots[]={901};
class ItemInfo: UniformItem
{
uniformModel="\EOD_SUIT\Models\EOD_Uniform.p3d";
uniformClass="EOD_engineer";
containerClass="Supply20";
mass=0;
};
};
class EOD_Uniform: Uniform_EOD_Base
{
scope=2;
displayName="$STR_EOD_Uniform";
picture="\EOD_SUIT\UI\EOD9_Uniform_Icon_ca.paa";
model="\A3\Characters_F\Common\Suitpacks\suitpack_universal_F.p3d";
hiddenSelections[] = {"camo"};
hiddenSelectionsTextures[] = {"\EOD_SUIT\TexturesWIP\suitpack_EOD_Suit_co.paa"};
class ItemInfo: UniformItem
{
uniformModel="-";
uniformClass="EOD_engineer";
containerClass="Supply20";
mass=80;
};
};
class EOD_SUIT_vest_base: ItemCore
{
scope=0;
weaponPoolAvailable=1;
allowedSlots[]={901};
picture="\EOD_SUIT\UI\EOD9_Vest_Icon_ca.paa";
model="\EOD_SUIT\Models\EOD_SUIT_vest.p3d";
hiddenSelections[]={};
class ItemInfo: VestItem
{
uniformmodel="\EOD_SUIT\Models\EOD_SUIT_vest.p3d";
hiddenSelections[]={};
containerClass="Supply0";
mass=0;
armor=0;
passThrough=1;
};
};
class EOD_SUIT_vest: EOD_SUIT_vest_Base
{
scope=2;
displayName="$STR_Vest_EOD";
picture="\EOD_SUIT\UI\EOD9_Vest_Icon_ca.paa";
model="\EOD_SUIT\Models\EOD_SUIT_vest.p3d";
class ItemInfo: ItemInfo
{
uniformmodel="\EOD_SUIT\Models\EOD_SUIT_vest.p3d";
containerClass="Supply40";
mass=1000;
armor=100000;
passThrough=0.000001;
class HitpointsProtectionInfo
{
class Neck
{
hitpointName = "HitNeck"; // reference to the hit point class defined in the man base class
armor = 8000; // addition to armor of referenced hitpoint
passThrough = 0.0005; // multiplier of base passThrough defined in referenced hitpoint
};
class Arms
{
hitpointName = "HitArms";
armor = 8000;
passThrough = 0.0005;
};
class Chest
{
hitpointName = "HitChest";
armor = 8000;
passThrough = 0.0001;
};
class Diaphragm
{
hitpointName = "HitDiaphragm";
armor = 8000;
passThrough = 0.0001;
};
class Abdomen
{
hitpointName = "HitAbdomen";
armor = 80000;
passThrough = 0.0001;
};
class Body
{
hitpointName = "HitBody";
passThrough = 0.0001;
};
};
};
};
};
class RscTitles
{
class Default
{
idd = -1;
fadein = 0;
fadeout = 0;
duration = 0;
};
class RscPicture
{
access = 0;
idc = -1;
type = 0;
style = 48;
colorBackground[] = {0,0,0,0};
colorText[] = {1,1,1,1};
font = "puristaMedium";
sizeEx = 0;
lineSpacing = 0;
fixedWidth = 0;
shadow = 0;
text = "";
x = "safezoneX";
y = "safezoneY";
w = "safezoneW";
h = "safezoneH";
};
class RscEOD_Helmet_BaseTitle
{
idd = -1;
text = "EOD_SUIT\UI\EODS_EOD_SUIT_OVERLAY2_ca.paa";
// onLoad = "uiNamespace setVariable ['EOD_Helmet_Display', _this select 0]";
// onUnload = "uiNamespace setVariable ['EOD_Helmet_Display', displayNull]";
fadeIn = 0.5;
fadeOut = 0.5;
movingEnable = "false";
duration = 1e+011;
name = "RscEOD_Helmet_BaseTitle";
class controls;
};
class RscEOD_Helmet: RscEOD_Helmet_BaseTitle
{
idd = 1044;
name = "RscEOD_Helmet";
class controls
{
class EOD_HelmetImage: RscPicture
{
text = "EOD_SUIT\UI\EODS_EOD_SUIT_OVERLAY2_ca.paa";
idc = 10650;
};
};
};
class RscEOD_Helmet_Cracked: RscEOD_Helmet_BaseTitle
{
idd = 1045;
name = "RscEOD_Helmet_Cracked";
class controls
{
class EOD_CrackedHelmetImage: RscPicture
{
text = "EOD_SUIT\UI\EODS_EOD_SUIT_OVERLAY2_cracked_ca.paa";
idc = 10651;
};
};
};
class RscEOD_Interface: RscEOD_Helmet_BaseTitle
{
idd = 1046;
name = "RscEOD_Helmet_Cracked";
class controls
{
class EOD_CrackedHelmetImage: RscPicture
{
text = "EOD_SUIT\UI\EOD_Suit_HandControl.paa";
idc = 10652;
};
};
};
};
class RscBackPicture
{
access = 0;
type = 0;
idc = -1;
style = 48;
colorBackground[] =
{
0,
0,
0,
0
};
colorText[] =
{
1,
1,
1,
1
};
font = "TahomaB";
sizeEx = 0;
lineSpacing = 0;
text = "";
fixedWidth = 0;
shadow = 0;
x = 0;
y = 0;
w = 0.2;
h = 0.15;
};
class HiddenButton
{
access = 0;
type = 1;
text = "";
colorText[] = {
0, 0, 0, 1
};
colorDisabled[] = {
0, 0, 0, 0
};
colorBackground[] = {
0, 0, 0, 0
};
colorBackgroundDisabled[] = {
0, 0, 0, 0
};
colorBackgroundActive[] = {
0, 0, 0, 0
};
colorFocused[] = {
0, 0, 0, 0
};
colorShadow[] = {
0, 0, 0, 0
};
colorBorder[] = {
0, 0, 0, 0
};
soundEnter[] =
{
"\A3\ui_f\data\sound\RscButton\soundEnter",
0.09,
1
};
soundPush[] =
{
"\A3\ui_f\data\sound\RscButton\soundPush",
0.5,
1
};
soundClick[] =
{
"\A3\ui_f\data\sound\RscButton\soundClick",
0.5,
1
};
soundEscape[] =
{
"\A3\ui_f\data\sound\RscButton\soundEscape",
0.09,
1
};
style = 2;
x = 0;
y = 0;
w = 0.095589;
h = 0.039216;
shadow = 2;
font = "PuristaMedium";
sizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
offsetX = 0.003;
offsetY = 0.003;
offsetPressedX = 0.002;
offsetPressedY = 0.002;
borderSize = 0;
};
/* For Dialog Editor please do not delete....
$
[1.063,["EOD_helmet_GUI",[[0,0,1,1],0.025,0.04,"GUI_GRID"],0,0,0],
[1200,"eod_overlay",[1,"\EOD_SUIT\UI\EODS_EOD_SUIT_OVERLAY2_ca.paa",["-0.0245075 * safezoneW + safezoneX","-0.00507435 * safezoneH + safezoneY","1.05214 * safezoneW","1.012 * safezoneH"],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],"","-1"],[]]
]
*/
/* For Dialog Editor please do not delete....
$
[1.063,["EOD_Suit_HandControl_Dialog",[[0,0,1,1],0.025,0.04,"GUI_GRID"],0,0,0],
[1200,"EOD_Suit_HandControl_PIC",[1,"EOD_SUIT\UI\EOD_Suit_HandControl.paa",["-0.000281591 * safezoneW + safezoneX","-0.00125921 * safezoneH + safezoneY","1.00407 * safezoneW","1.00169 * safezoneH"],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],"","-1"],[]],
[1600,"EOD_Suit_HandControl_B1",[1,"",["0.243016 * safezoneW + safezoneX","0.599815 * safezoneH + safezoneY","0.0273986 * safezoneW","0.0321852 * safezoneH"],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],"Redbreather","-1"],[]],
[1601,"EOD_Suit_HandControl_B2",[1,"",["0.244775 * safezoneW + safezoneX","0.651223 * safezoneH + safezoneY","0.0251202 * safezoneW","0.0309259 * safezoneH"],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],"Sound system","-1"],[]],
[1602,"EOD_Suit_HandControl_B3",[1,"",["0.326254 * safezoneW + safezoneX","0.592519 * safezoneH + safezoneY","0.0282441 * safezoneW","0.0364815 * safezoneH"],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],"Redbreather (External system)","-1"],[]],
[1603,"EOD_Suit_HandControl_B5",[1,"",["0.326775 * safezoneW + safezoneX","0.644741 * safezoneH + safezoneY","0.0266822 * safezoneW","0.0346297 * safezoneH"],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],"Heat regulation system","-1"],[]],
[1604,"EOD_Suit_HandControl_B4",[1,"",["0.244254 * safezoneW + safezoneX","0.701593 * safezoneH + safezoneY","0.0256409 * safezoneW","0.0337038 * safezoneH"],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],"Lights","-1"],[]],
[1605,"EOD_Suit_HandControl_B_ON",[1,"",["0.16022 * safezoneW + safezoneX","0.542149 * safezoneH + safezoneY","0.0277234 * safezoneW","0.0540742 * safezoneH"],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],"Power","-1"],[]]
]
*/
#define IDD_BACKGROUND 67676
#define IDC_EOD_Suit_HandControl_PIC IDD_BACKGROUND
#define IDD_EOD_Suit_HandControl_Dialog 160791
#define IDD_REDBREATHER_LED 67677
#define IDC_EOD_Suit_REDBREATHER_LED IDD_REDBREATHER_LED
#define IDD_POWER_LED 67678
#define IDC_EOD_Suit_Power_LED IDD_POWER_LED
#define IDD_SOUND_LED 67679
#define IDC_EOD_Suit_Sound_LED IDD_SOUND_LED
#define IDD_LIGHT_LED 67680
#define IDC_EOD_Suit_Light_LED IDD_LIGHT_LED
#define IDD_ENERGY_LED 67681
#define IDC_EOD_Suit_Energy_LED IDD_ENERGY_LED
////////////////////////////////////////////////////////////////////////////////Led Rouges ///////////////////////////////////////////////////////////////////
#define IDD_SOUND_LED_R 67682
#define IDC_EOD_Suit_Sound_LED_R IDD_SOUND_LED_R
#define IDD_LIGHT_LED_R 67683
#define IDC_EOD_Suit_Light_LED_R IDD_LIGHT_LED_R
#define IDD_REDBREATHER_LED_R 67684
#define IDC_EOD_Suit_REDBREATHER_LED_R IDD_REDBREATHER_LED_R
//#define IDD_ENERGY_LED_R 67685 Decommente Ici si tu veut utiliser la led Rouge pour l'energie
//#define IDC_EOD_Suit_Energy_LED_R IDD_ENERGY_LED_R Decommente Ici si tu veut utiliser la led Rouge pour l'energie
////////////////////////////////////////////////////////////////////////////////Led Rouges Fin ///////////////////////////////////////////////////////////////////
class EOD_Suit_HandControl_Dialog
{
idd=IDD_EOD_Suit_HandControl_Dialog;
// movingEnable = 1;
enableSimulation = true ;
controlsBackground[] = { };
objects[] = { };
onLoad = "if(sunOrMoon < 0.2)then{((_this select 0) displayCtrl 67676) ctrlSetText '\EOD_SUIT\UI\EOD_Suit_HandControl_n.paa';};";
controls[]=
{
background,
REDBREATHER_LED,
POWER_LED,
SOUND_LED,
LIGHT_LED,
ENERGY_LED,
////////////////////////////////////////////////////////////////////////////////Led Rouges ///////////////////////////////////////////////////////////////////
SOUND_LED_R,
LIGHT_LED_R,
REDBREATHER_LED_R,
//ENERGY_LED_R, Decommente Ici si tu veut utiliser la led Rouge pour l'energie
////////////////////////////////////////////////////////////////////////////////Led Rouges Fin///////////////////////////////////////////////////////////////////
EOD_Suit_HandControl_B1,
EOD_Suit_HandControl_B2,
EOD_Suit_HandControl_B3,
EOD_Suit_HandControl_B4,
EOD_Suit_HandControl_B5,
EOD_Suit_HandControl_B_ON
};
////////////////////////////////////////////////////////
// GUI EDITOR OUTPUT START (by MrEwok, v1.063, #Gydory)
////////////////////////////////////////////////////////
class background: RscBackPicture
{
idc = IDC_EOD_Suit_HandControl_PIC;
text = "EOD_SUIT\UI\EOD_Suit_HandControl.paa";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
};
class REDBREATHER_LED: RscBackPicture
{
idc = IDC_EOD_Suit_REDBREATHER_LED;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_RedbreatherLED.paa";
onLoad = "ctrlShow [67677, False]; [] spawn Script_EOD_SUIT_Ouverture_Interface;";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
};
class POWER_LED: RscBackPicture
{
idc = IDC_EOD_Suit_Power_LED;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_PowerLED.paa";
onLoad = "ctrlShow [67678, False]; [] spawn Script_EOD_SUIT_Ouverture_Interface;";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
};
class SOUND_LED: RscBackPicture
{
idc = IDC_EOD_Suit_Sound_LED;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_SoundLED.paa";
onLoad = "ctrlShow [67679, False]; [] spawn Script_EOD_SUIT_Ouverture_Interface;";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
};
class LIGHT_LED: RscBackPicture
{
idc = IDC_EOD_Suit_Light_LED;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_LightLED.paa";
onLoad = "ctrlShow [67680, False]; [] spawn Script_EOD_SUIT_Ouverture_Interface;";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
};
class ENERGY_LED: RscBackPicture
{
idc = IDC_EOD_Suit_Energy_LED;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_EnergyLED.paa";
onLoad = "ctrlShow [67681, False]; [] spawn Script_EOD_SUIT_Ouverture_Interface;";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
};
////////////////////////////////////////////////////////////////////////////////Led Rouges ///////////////////////////////////////////////////////////////////
class SOUND_LED_R: RscBackPicture
{
idc = IDC_EOD_Suit_Sound_LED_R;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_SoundLED_R.paa";
onLoad = "ctrlShow [67682, False];";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
// moving = 1;
};
class LIGHT_LED_R: RscBackPicture
{
idc = IDC_EOD_Suit_Light_LED_R;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_LightLED_R.paa";
onLoad = "ctrlShow [67683, False];";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
// moving = 1;
};
class REDBREATHER_LED_R: RscBackPicture
{
idc = IDC_EOD_Suit_REDBREATHER_LED_R;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_RedbreatherLED_R.paa";
onLoad = "ctrlShow [67684, False];";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
// moving = 1;
};
/* Decommente Ici si tu veut utiliser la led Rouge pour l'energie
class ENERGY_LED_R: RscBackPicture
{
idc = IDC_EOD_Suit_Energy_LED_R;
text = "EOD_SUIT\UI\EOD_Suit_HandControl_EnergyLED_R.paa";
onLoad = "ctrlShow [67685, False] ;";
x = -0.000281591 * safezoneW + safezoneX;
y = -0.00125921 * safezoneH + safezoneY;
w = 1.00407 * safezoneW;
h = 1.00169 * safezoneH;
// moving = 1;
};
*/
////////////////////////////////////////////////////////////////////////////////Led Rouges Fin ///////////////////////////////////////////////////////////////////
class EOD_Suit_HandControl_B1: HiddenButton
{
idc = IDC_EOD_Suit_HandControl_B1;
x = 0.243016 * safezoneW + safezoneX;
y = 0.599815 * safezoneH + safezoneY;
w = 0.0273986 * safezoneW;
h = 0.0321852 * safezoneH;
tooltip = "$STR_Rebreather";
action = "[""Respirateur""] spawn Script_EOD_SUIT_Action_Bouton;";
};
class EOD_Suit_HandControl_B2: HiddenButton
{
idc = IDC_EOD_Suit_HandControl_B2;
x = 0.244775 * safezoneW + safezoneX;
y = 0.651223 * safezoneH + safezoneY;
w = 0.0251202 * safezoneW;
h = 0.0309259 * safezoneH;
tooltip = "$STR_Sound_System";
action = "[""Système sonore""] spawn Script_EOD_SUIT_Action_Bouton;";
};
class EOD_Suit_HandControl_B3: HiddenButton
{
idc = IDC_EOD_Suit_HandControl_B3;
x = 0.326254 * safezoneW + safezoneX;
y = 0.592519 * safezoneH + safezoneY;
w = 0.0282441 * safezoneW;
h = 0.0364815 * safezoneH;
tooltip = "$STR_Rebreather_External_System";
action = "[""Respirateur externe""] spawn Script_EOD_SUIT_Action_Bouton;";
};
class EOD_Suit_HandControl_B4: HiddenButton
{
idc = IDC_EOD_Suit_HandControl_B4;
x = 0.244254 * safezoneW + safezoneX;
y = 0.701593 * safezoneH + safezoneY;
w = 0.0256409 * safezoneW;
h = 0.0337038 * safezoneH;
tooltip = "$STR_Lights";
action = "[""Lumières""] spawn Script_EOD_SUIT_Action_Bouton;";
};
class EOD_Suit_HandControl_B5: HiddenButton
{
idc = IDC_EOD_Suit_HandControl_B5;
x = 0.326775 * safezoneW + safezoneX;
y = 0.644741 * safezoneH + safezoneY;
w = 0.0266822 * safezoneW;
h = 0.0346297 * safezoneH;
tooltip = "$STR_Heat_Regulation_System";
action = "[""Ventilation""] spawn Script_EOD_SUIT_Action_Bouton;";
};
class EOD_Suit_HandControl_B_ON: HiddenButton
{
idc = IDC_EOD_Suit_HandControl_B_ON;
x = 0.16022 * safezoneW + safezoneX;
y = 0.542149 * safezoneH + safezoneY;
w = 0.0277234 * safezoneW;
h = 0.0540742 * safezoneH;
tooltip = "$STR_Power";
action = "[""Alimentation""] spawn Script_EOD_SUIT_Action_Bouton;";
};
}; |
13aa14617c76569bb448e066cc53a69832672d36 | 54c4a6f4c05ac93257f65a571171287a3d9ad5f4 | /Depth_First_Search/11724/main.cpp | 982706e89dad632220b29389f7c9afef44259de0 | [] | no_license | DaeHwanGi/BAEKJOON_solution | 747d202117d642268d2a80932a763544d879266e | bdf823d196d336ca509931638e843fd36716f0bf | refs/heads/master | 2020-04-26T08:29:34.725920 | 2019-03-11T13:02:07 | 2019-03-11T13:02:07 | 173,424,591 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 654 | cpp | main.cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<int>> adj;
vector<bool> visited;
int dfs(int pos) {
visited[pos] = true;
for (int next : adj[pos]) {
if (!visited[next]) dfs(next);
}
return 0;
}
int main() {
int N, M;
cin >> N >> M;
adj.resize(N);
visited.resize(N);
fill(visited.begin(), visited.end(), false);
for (int i = 0; i < M; i++) {
int u, v;
cin >> u >> v;
u = u - 1;
v = v - 1;
adj[u].push_back(v);
adj[v].push_back(u);
}
int component = 0;
for (int i = 0; i < N; i++) {
if (!visited[i]) {
component++;
dfs(i);
}
}
cout << component << endl;
return 0;
} |
f617900a8706617cf9c5bc4684769d5f44558022 | a5a7c59b04a1a64fe34653c7970c3cf173f9c1df | /externals/numeric_bindings/boost/numeric/bindings/lapack/computational/potrf.hpp | f64a511b5578c36e8dd5b98adaa9e1ac240bcc3f | [
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | siconos/siconos | a7afdba41a2bc1192ad8dcd93ac7266fa281f4cf | 82a8d1338bfc1be0d36b5e8a9f40c1ad5384a641 | refs/heads/master | 2023-08-21T22:22:55.625941 | 2023-07-17T13:07:32 | 2023-07-17T13:07:32 | 37,709,357 | 166 | 33 | Apache-2.0 | 2023-07-17T12:31:16 | 2015-06-19T07:55:53 | C | UTF-8 | C++ | false | false | 7,285 | hpp | potrf.hpp | //
// Copyright (c) 2002--2010
// Toon Knapen, Karl Meerbergen, Kresimir Fresl,
// Thomas Klimpel and Rutger ter Borg
//
// 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)
//
// THIS FILE IS AUTOMATICALLY GENERATED
// PLEASE DO NOT EDIT!
//
#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_COMPUTATIONAL_POTRF_HPP
#define BOOST_NUMERIC_BINDINGS_LAPACK_COMPUTATIONAL_POTRF_HPP
#include <boost/assert.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/data_order.hpp>
#include <boost/numeric/bindings/is_mutable.hpp>
#include <boost/numeric/bindings/remove_imaginary.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/stride.hpp>
#include <boost/numeric/bindings/uplo_tag.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
//
// The LAPACK-backend for potrf is selected by defining a pre-processor
// variable, which can be one of
// * for ATLAS's CLAPACK, define BOOST_NUMERIC_BINDINGS_LAPACK_CLAPACK
// * netlib-compatible LAPACK is the default
//
#if defined BOOST_NUMERIC_BINDINGS_LAPACK_CLAPACK
#include <boost/numeric/bindings/lapack/detail/clapack.h>
#include <boost/numeric/bindings/lapack/detail/clapack_option.hpp>
#else
#include <boost/numeric/bindings/lapack/detail/lapack.h>
#include <boost/numeric/bindings/lapack/detail/lapack_option.hpp>
#endif
namespace boost {
namespace numeric {
namespace bindings {
namespace lapack {
//
// The detail namespace contains value-type-overloaded functions that
// dispatch to the appropriate back-end LAPACK-routine.
//
namespace detail {
#if defined BOOST_NUMERIC_BINDINGS_LAPACK_CLAPACK
//
// Overloaded function for dispatching to
// * ATLAS's CLAPACK backend, and
// * float value-type.
//
template< typename Order, typename UpLo >
inline std::ptrdiff_t potrf( Order, const UpLo, const int n, float* a,
const int lda ) {
return clapack_spotrf( clapack_option< Order >::value, clapack_option<
UpLo >::value, n, a, lda );
}
//
// Overloaded function for dispatching to
// * ATLAS's CLAPACK backend, and
// * double value-type.
//
template< typename Order, typename UpLo >
inline std::ptrdiff_t potrf( Order, const UpLo, const int n, double* a,
const int lda ) {
return clapack_dpotrf( clapack_option< Order >::value, clapack_option<
UpLo >::value, n, a, lda );
}
//
// Overloaded function for dispatching to
// * ATLAS's CLAPACK backend, and
// * complex<float> value-type.
//
template< typename Order, typename UpLo >
inline std::ptrdiff_t potrf( Order, const UpLo, const int n,
std::complex<float>* a, const int lda ) {
return clapack_cpotrf( clapack_option< Order >::value, clapack_option<
UpLo >::value, n, a, lda );
}
//
// Overloaded function for dispatching to
// * ATLAS's CLAPACK backend, and
// * complex<double> value-type.
//
template< typename Order, typename UpLo >
inline std::ptrdiff_t potrf( Order, const UpLo, const int n,
std::complex<double>* a, const int lda ) {
return clapack_zpotrf( clapack_option< Order >::value, clapack_option<
UpLo >::value, n, a, lda );
}
#else
//
// Overloaded function for dispatching to
// * netlib-compatible LAPACK backend (the default), and
// * float value-type.
//
template< typename Order, typename UpLo >
inline std::ptrdiff_t potrf( Order, const UpLo, const fortran_int_t n,
float* a, const fortran_int_t lda ) {
BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );
fortran_int_t info(0);
LAPACK_SPOTRF( &lapack_option< UpLo >::value, &n, a, &lda, &info );
return info;
}
//
// Overloaded function for dispatching to
// * netlib-compatible LAPACK backend (the default), and
// * double value-type.
//
template< typename Order, typename UpLo >
inline std::ptrdiff_t potrf( Order, const UpLo, const fortran_int_t n,
double* a, const fortran_int_t lda ) {
BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );
fortran_int_t info(0);
LAPACK_DPOTRF( &lapack_option< UpLo >::value, &n, a, &lda, &info );
return info;
}
//
// Overloaded function for dispatching to
// * netlib-compatible LAPACK backend (the default), and
// * complex<float> value-type.
//
template< typename Order, typename UpLo >
inline std::ptrdiff_t potrf( Order, const UpLo, const fortran_int_t n,
std::complex<float>* a, const fortran_int_t lda ) {
BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );
fortran_int_t info(0);
LAPACK_CPOTRF( &lapack_option< UpLo >::value, &n, a, &lda, &info );
return info;
}
//
// Overloaded function for dispatching to
// * netlib-compatible LAPACK backend (the default), and
// * complex<double> value-type.
//
template< typename Order, typename UpLo >
inline std::ptrdiff_t potrf( Order, const UpLo, const fortran_int_t n,
std::complex<double>* a, const fortran_int_t lda ) {
BOOST_STATIC_ASSERT( (is_same<Order, tag::column_major>::value) );
fortran_int_t info(0);
LAPACK_ZPOTRF( &lapack_option< UpLo >::value, &n, a, &lda, &info );
return info;
}
#endif
} // namespace detail
//
// Value-type based template class. Use this class if you need a type
// for dispatching to potrf.
//
template< typename Value >
struct potrf_impl {
typedef Value value_type;
typedef typename remove_imaginary< Value >::type real_type;
//
// Static member function, that
// * Deduces the required arguments for dispatching to LAPACK, and
// * Asserts that most arguments make sense.
//
template< typename MatrixA >
static std::ptrdiff_t invoke( MatrixA& a ) {
namespace bindings = ::boost::numeric::bindings;
typedef typename result_of::data_order< MatrixA >::type order;
typedef typename result_of::uplo_tag< MatrixA >::type uplo;
BOOST_STATIC_ASSERT( (bindings::is_mutable< MatrixA >::value) );
BOOST_ASSERT( bindings::size_column(a) >= 0 );
BOOST_ASSERT( bindings::size_minor(a) == 1 ||
bindings::stride_minor(a) == 1 );
BOOST_ASSERT( bindings::stride_major(a) >= std::max< std::ptrdiff_t >(1,
bindings::size_column(a)) );
return detail::potrf( order(), uplo(), bindings::size_column(a),
bindings::begin_value(a), bindings::stride_major(a) );
}
};
//
// Functions for direct use. These functions are overloaded for temporaries,
// so that wrapped types can still be passed and used for write-access. In
// addition, if applicable, they are overloaded for user-defined workspaces.
// Calls to these functions are passed to the potrf_impl classes. In the
// documentation, most overloads are collapsed to avoid a large number of
// prototypes which are very similar.
//
//
// Overloaded function for potrf. Its overload differs for
//
template< typename MatrixA >
inline std::ptrdiff_t potrf( MatrixA& a ) {
return potrf_impl< typename bindings::value_type<
MatrixA >::type >::invoke( a );
}
} // namespace lapack
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif
|
980e5cb11ccc5bc907807f858d0cb2cdbf34d4f7 | c2c00be02ed71f5d3bc172f48a5f07e62e4171e3 | /CasseTete/View/piecep.h | d8721fb6492be29312abd55355cd86ba8539f0bb | [] | no_license | PierreGranier/CasseTete | 243074be4da11a995a06ac92cf5a7aba21912c89 | 9a921669ff66476c87890266dc38e1a4db35f043 | refs/heads/master | 2021-09-06T22:04:14.833341 | 2018-02-12T10:28:29 | 2018-02-12T10:28:29 | 103,412,947 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 155 | h | piecep.h | #ifndef PIECEP_H
#define PIECEP_H
#include "pieceView.h"
class PieceP : public PieceView {
public:
PieceP();
void show();
};
#endif // PIECEP_H
|
29741cee7c7e7449b5523614e75755e8ff72e5e6 | 95014609f589edb735b7ed85eb3c29c233e1bc0b | /Day106(Identical_BT).cpp | 1daaefcbf7497e6a4194cd62944ede6e8d6e5a71 | [] | no_license | RohiniRG/Daily-Coding | ea1ad3132e1699907b6eaa7a7a3f217aa62ffd61 | c0ef846670d62acd829d2f5f4920364f7895a269 | refs/heads/main | 2023-08-25T02:54:54.086587 | 2021-09-30T13:20:12 | 2021-09-30T13:20:12 | 335,008,278 | 11 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 361 | cpp | Day106(Identical_BT).cpp | /*
Two trees are identical when they have same data and arrangement of data is also same.
*/
bool isIdentical(Node *r1, Node *r2)
{
if (r1 == NULL && r2 == NULL) return 1;
if (r1 == NULL || r2 == NULL) return 0;
return
(
(r1->data == r2->data) && isIdentical(r1->left, r2->left) && isIdentical(r1->right, r2->right)
);
}
|
e497c114494dded0ec5a05f0418ec5fd4e3f2215 | 98455cb378a00b23c33facf97d0e9a00a19dc575 | /1.secuenciales-y-estructuras-de-control/e-55.cpp | d778395e9afab245639cbb59f84c74280aa9ddb9 | [] | no_license | Shair17/exercises-university | ea10e5ac42cdecc549a7c0dd1949dd29d72d1d82 | 541a5538d6a745d34c03e6ddd58af03385264d33 | refs/heads/master | 2022-12-05T03:09:01.813661 | 2020-08-21T05:07:05 | 2020-08-21T05:07:05 | 282,010,780 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 995 | cpp | e-55.cpp | /**
* Al cerrar un expendio de naranjas, 15 clientes que aun no han pagado recibirán
* un 15% de descuento si compran más de 10 kilos. Determinar cuanto pagará cada
* cliente y cuanto percibirá la tienda por esas compras.
*/
#include <iostream>
using namespace std;
int main() {
int index = 1;
float totalP = 0, costoKilo, kilosComprados, subtotal, descuento, total;
cout << "Ingrese el valor de costo por kilo: ";
cin >> costoKilo;
while (index <= 15) {
cout << "Ingrese el valor de kilos comprados: ";
cin >> kilosComprados;
subtotal = kilosComprados * costoKilo;
if (kilosComprados > 10) {
descuento = subtotal * .1;
} else {
descuento = 0;
}
total = subtotal - descuento;
totalP += total;
cout << "Valor de descuento: " << descuento << endl;
cout << "Valor de subtotal: " << subtotal << endl;
cout << "Valor de total: " << total << endl;
}
cout << "Valor de total percibido: " << totalP;
return 0;
}
|
e1aeb0a84a77df70920b5840ba48e49b9e16de9c | cf9fbc6e502cff2888f67faf0981c163a19742d7 | /resources/testUnits/mainTrain.cpp | 1fed5cabbcf5f1b5f09b6b3968d81cfd3f9c0224 | [] | no_license | noacoh/colmanProject | 9877f981b35ada0c6d250cd0a74447084c7df56b | fbc7a50b1b146312d3f06992365d7573f062927d | refs/heads/master | 2023-01-03T08:47:40.475931 | 2019-08-21T06:46:22 | 2019-08-21T06:46:22 | 188,271,354 | 0 | 0 | null | 2022-12-22T11:15:10 | 2019-05-23T16:36:19 | JavaScript | UTF-8 | C++ | false | false | 2,758 | cpp | mainTrain.cpp | #include <iostream>
#include "Polynomial.h"
static const std::string computationResults[] =
{
"8x^4+7x^3+5x^2+4x-1",
"40x^5-21x^4-24x^3-15x^2-33x+7",
"200x^5-105x^4-120x^3-75x^2-165x+35",
"200x^5-105x^4-120x^3-75x^2-165x+35",
"0",
"400x^5-210x^4-240x^3-150x^2-330x+70",
"200x^5-105x^4-120x^3-75x^2-165x+42",
"200x^5-105x^4-120x^3-75x^2-165x+33",
"-200x^5+105x^4+120x^3+75x^2+165x-44"
};
static bool comparePolynomialResult(const Polynomial& p, unsigned index)
{
char* s = p.getStringRepresentation();
std::string str(s);
delete[] s;
return str == computationResults[index];
}
using std::cout;
using std::endl;
int main(void)
{
Polynomial p1, p2;
unsigned resultIndex = 0;
p1 >> "5x^2-5x+5+7x^3+9x+8x^4-6";
p1.sort();
if (!comparePolynomialResult(p1, resultIndex++))
cout<<"Error in >> operator"<<endl;
if (p1[4] != 8)
cout<<"Error in operator []"<<endl;
if (p1[10] != 0)
cout<<"Error in operator []"<<endl;
p2 >> "5x-7";
p1 *= p2;
p1.sort();
if (!comparePolynomialResult(p1, resultIndex++))
cout<<"Error in *= operator"<<endl;
const Polynomial fiveTimesP1 = 5 * p1;
if (!comparePolynomialResult(fiveTimesP1, resultIndex++))
cout<<"Error in * (Mon*Pol) operator"<<endl;
const Polynomial p1TimesFive = p1 * 5;
if (!comparePolynomialResult(p1TimesFive, resultIndex++))
cout<<"Error in * (Pol*Mon) operator"<<endl;
if (!comparePolynomialResult(fiveTimesP1 - p1TimesFive, resultIndex++))
cout<<"Error in - (Pol-Pol) operator"<<endl;
Polynomial* p = new Polynomial(p1TimesFive);
Polynomial* pp = new Polynomial(fiveTimesP1);
{
Polynomial temp = *p;
temp = fiveTimesP1 + p1TimesFive;
if (!comparePolynomialResult(temp, resultIndex++))
cout<<"Error in + (Pol+Pol) operator\n";
}
{
const Polynomial temp = *p;
if (temp.maxExp() != 5)
cout<<"Error in maxExp\n";
Monomial x1(200, 5); Monomial x2(-105,4);
Polynomial y = fiveTimesP1 - x1 - x2;
if (y.maxExp() != 3)
cout<<"Error in maxExp\n";
}
*p += 7;
if (!comparePolynomialResult(*p, resultIndex++))
cout<<"Error in += (Pol+Mon) operator"<<endl;
*pp -= 2;
if (!comparePolynomialResult(*pp, resultIndex++))
cout<<"Error in -= (Pol-Mon) operator"<<endl;
Polynomial poly = -2 - *p;
poly.sort();
if (!comparePolynomialResult(poly, resultIndex++))
cout<<"Error in - (Mon-Pol) operator"<<endl;
delete p;
delete pp;
cout<<"done\n";
return 0;
}
|
f39f75c72cfc8d3291cad3caa76b950df7bafabc | e6317162fd2ac60acf13090eec30c6e577f5bcb1 | /SourceCode/_person.cpp | f2d3b32b4e42105d5620431e9ffa1606d32fef01 | [
"Apache-2.0"
] | permissive | CainHsu/ProgramStudy-leetcode | 024a9fb093a0ce9cdaab6b8ece82ba94ede5b5c2 | 23653e8927902aed64ba13a23a1d6c983b7ea5d5 | refs/heads/master | 2021-06-26T10:35:34.447660 | 2021-05-16T12:47:04 | 2021-05-16T12:47:04 | 226,617,577 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 644 | cpp | _person.cpp | //
// Created by xuche on 2019/12/25.
//
#include "person.hpp"
person person::operator-(int year){
this->age -= year;
return *this;
}
person person::operator-(){
this->age = -this->age;
return *this;
}
person operator-(int year, person & man){
return (-man + year);
}
using std::cout;
using std::endl;
void person::show_all(){
cout << "This is person.";
/*
cout << "Name is: " << name << endl;
cout << "Age is: " << age << endl;
cout << "Height is: " << height << endl;
*/
}
person::operator int() const{
return int(height + 0.5);
}
person::operator double() const{
return height;
}
|
4b42cb30495b70da1e1469d900808d177c7609f4 | 1606ddbf3cfd40df03384d248fb2beeb19b2a496 | /Knowledge_Work/C++/Copy_Constructor/copy_constructor.cpp | 5e592208a4b6e5f0d8ada206db6bb0ee324a1d91 | [] | no_license | Monojit7/Linux_Programming | 2106c13f85ebeae9cb6ec52963092695083686c1 | 4aa19bcfe7019af8ed42792ca2deae413b5ab788 | refs/heads/master | 2022-05-29T15:12:59.955553 | 2022-03-26T10:34:39 | 2022-03-26T10:34:39 | 88,253,138 | 0 | 0 | null | 2017-04-17T13:58:05 | 2017-04-14T09:17:30 | C | UTF-8 | C++ | false | false | 1,110 | cpp | copy_constructor.cpp | #include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <cstring>
using namespace std;
class String
{
public:
char* str;
int size;
String(const char* str = '\0')
{
cout << "constructor : String" << endl;
size = strlen(str);
this->str = new char[size + 1];
strcpy(this->str, str);
}
void print()
{
cout << "The string is : " << this->str << endl;
}
void change (const char* str)
{
cout << "Changing the string from: " << this->str << " to" << str << endl;
delete [] (this->str);
size = strlen(str);
this->str = new char[size + 1];
strcpy(this->str, str);
}
String( const String& old_obj)
{
cout << "copying :" << old_obj.str << "object to the new object " << endl;
size = strlen(old_obj.str);
this->str = new char[size +1 ];
strcpy( this->str, old_obj.str);
}
};
int main()
{
String S1 ("Monojit");
String S2 = S1;
S1.print();
S2.print();
S2.change("Mark Zuckerburg");
S1.print();// without copy constructor this will print "Mark Zuckerburg" ideally it should print "Monojit" Since S2.change() happened and it should
// not reflect S1.
S2.print();
return 0;
}
|
7c24c59c110921594c74df9c756b00ea16c7dc73 | f0de0d4d8e6e392175d4df4d69d5dafe60a4a7f7 | /ExceptionHandlingTest/src/CleanClass.cpp | ef649ef2d9fab3f2a812c4ec4df88db075008118 | [] | no_license | FHV-ITM13/C-CPP | fa59c1783f748b9809645cb37e1bd79e69a69376 | 18d8d053348e30af591053d5d188d09d3b1d5120 | refs/heads/master | 2020-05-20T11:37:41.093389 | 2014-01-30T16:38:59 | 2014-01-30T16:38:59 | 15,846,948 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 446 | cpp | CleanClass.cpp | /*
* CleanClass.cpp
*
* Created on: 18.01.2014
* Author: Stefan
*/
#include <string>
#include <iostream>
#include "CleanClass.h"
using namespace std;
CleanClass::CleanClass() {
name = new string("Clean");
}
CleanClass::~CleanClass() {
cout << "Clean class destructor call";
delete name;
}
string* CleanClass::GetName() {
return name;
}
void CleanClass::ThrowException() {
throw "Clean Exception";
}
|
71e013fd1b5b25847d6655d898c0fc99896ae661 | 81c05a185292d9af9b591d35cda533c7ab9a69a3 | /textrender.hpp | 4031a39cf829941087c017c416464472908f00ff | [] | no_license | JYP2011/cyclimb | 9f74d75e8281c2cff51057a945f7f3692508cec8 | 993f4736af9abf4eb4089da8c3f14e3b39e925a7 | refs/heads/master | 2022-06-02T18:43:24.002065 | 2020-04-06T07:16:08 | 2020-04-06T07:16:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 643 | hpp | textrender.hpp | #include <map>
#include <string>
#include <gl/glew.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <d3d11.h>
#include "util.hpp"
struct Character {
GLuint textureID;
glm::ivec2 size, bearing;
GLuint advance;
};
struct Character_D3D11 {
ID3D11Texture2D *texture;
ID3D11ShaderResourceView *srv;
glm::ivec2 size, bearing;
GLuint advance;
};
void InitTextRender();
void InitTextRender_D3D11();
void RenderText(GraphicsAPI api, std::wstring text, GLfloat x, GLfloat y, GLfloat scale, glm::vec3 color, glm::mat4 transform);
void MeasureTextWidth(std::wstring text, float *w);
|
07307c19c8bfb4127fb1d197a86287d7a841b9a6 | 435a32fff97a829d82e3cdafa13604929a8aa33c | /Plugins/D3D11/D3D11GraphicFactory.cpp | 65ada1079bc4ccf5f79c4283244c332ea9e0ceda | [
"BSD-2-Clause-Views"
] | permissive | DarkMagicCK/UKN | b2d264183a5788ef8a01d29dc34a9ec37c6863fc | 2e48607d7bb2a660371296223ea6a48b8a328af1 | refs/heads/master | 2021-01-23T21:01:43.595581 | 2013-08-27T19:19:19 | 2013-08-27T19:19:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,888 | cpp | D3D11GraphicFactory.cpp | #include "D3D11GraphicFactory.h"
#include "D3D11GraphicDevice.h"
#include "D3D11FrameBuffer.h"
#include "D3D11RenderBuffer.h"
#include "D3D11GraphicBuffer.h"
#include "D3D11Shader.h"
#include "D3D11Texture.h"
#include "D3D11RenderView.h"
#include "D3D11BlendStateObject.h"
#include "D3D11SamplerStateObject.h"
#include "D3D11RasterizerStateObject.h"
#include "D3D11DepthStencilStateObject.h"
#include "CgShader.h"
#include "UKN/RenderView.h"
#include "UKN/SpriteBatch.h"
#include "UKN/RenderBuffer.h"
namespace ukn {
class D3D11GraphicFactory: public GraphicFactory {
public:
D3D11GraphicFactory();
virtual ~D3D11GraphicFactory();
GraphicDevice& getGraphicDevice() const;
// SpriteBatchPtr createSpriteBatch() const;
GraphicBufferPtr createVertexBuffer(GraphicBuffer::Access,
GraphicBuffer::Usage,
uint32 count,
const void* initialData,
const vertex_elements_type& format) const;
GraphicBufferPtr createIndexBuffer(GraphicBuffer::Access,
GraphicBuffer::Usage,
uint32 count,
const void* initialData) const;
RenderBufferPtr createRenderBuffer() const;
RenderViewPtr createRenderView(const TexturePtr& texture) const;
RenderViewPtr createDepthStencilView(const TexturePtr& texture) const;
RenderViewPtr createDepthStencilView(uint32 width,
uint32 height,
ElementFormat format,
uint32 sampleCount,
uint32 sampleQuality) const override;
FrameBufferPtr createFrameBuffer() const;
TexturePtr create2DTexture(uint32 width,
uint32 height,
uint32 numMipmaps,
ElementFormat format,
const uint8* initialData,
uint32 flag) const;
TexturePtr load2DTexture(const ResourcePtr& rsrc, bool generateMipmaps=false) const;
EffectPtr createEffect() const;
BlendStatePtr createBlendStateObject(const BlendStateDesc& desc) const;
SamplerStatePtr createSamplerStateObject(const SamplerStateDesc& desc) const;
RasterizerStatePtr createRasterizerStateObject(const RasterizerStateDesc& desc) const;
DepthStencilStatePtr createDepthStencilStateObject(const DepthStencilStateDesc& desc) const;
private:
GraphicDevicePtr mGraphicDevice;
};
extern "C" {
UKN_D3D11_API void CreateGraphicFactory(GraphicFactoryPtr& ptr) {
static GraphicFactoryPtr static_ptr = MakeSharedPtr<D3D11GraphicFactory>();
ptr = static_ptr;
}
}
D3D11GraphicFactory::D3D11GraphicFactory() {
try {
mGraphicDevice = new D3D11GraphicDevice();
} catch(Exception& exp) {
MessageBoxW(0, exp.what(), L"Fatal Error", MB_OK | MB_ICONERROR);
}
}
D3D11GraphicFactory::~D3D11GraphicFactory() {
}
GraphicDevice& D3D11GraphicFactory::getGraphicDevice() const {
return *mGraphicDevice;
}
// SpriteBatchPtr D3D11GraphicFactory::createSpriteBatch() const {
//return SpriteBatchPtr(new SpriteBatch());
//return SpriteBatchPtr();
//}
GraphicBufferPtr D3D11GraphicFactory::createVertexBuffer(GraphicBuffer::Access access,
GraphicBuffer::Usage usage,
uint32 count,
const void* initialData,
const vertex_elements_type& format) const {
return MakeSharedPtr<D3D11VertexBuffer>(access, usage, count, initialData, format, (D3D11GraphicDevice*)mGraphicDevice.get());
}
GraphicBufferPtr D3D11GraphicFactory::createIndexBuffer(GraphicBuffer::Access access,
GraphicBuffer::Usage usage,
uint32 count,
const void* initialData) const {
return MakeSharedPtr<D3D11IndexBuffer>(access, usage, count, initialData, (D3D11GraphicDevice*)mGraphicDevice.get());
}
RenderBufferPtr D3D11GraphicFactory::createRenderBuffer() const {
return MakeSharedPtr<D3D11RenderBuffer>((D3D11GraphicDevice*)mGraphicDevice.get());
}
RenderViewPtr D3D11GraphicFactory::createRenderView(const TexturePtr& texture) const {
if(texture->type() == TT_Texture2D)
return MakeSharedPtr<D3D11Texture2DRenderView>(texture, (D3D11GraphicDevice*)mGraphicDevice.get());
return RenderViewPtr();
}
RenderViewPtr D3D11GraphicFactory::createDepthStencilView(const TexturePtr& texture) const {
return MakeSharedPtr<D3D11DepthStencilRenderView>(texture, (D3D11GraphicDevice*)mGraphicDevice.get());
}
RenderViewPtr D3D11GraphicFactory::createDepthStencilView(uint32 width,
uint32 height,
ElementFormat format,
uint32 sampleCount,
uint32 sampleQuality) const {
return MakeSharedPtr<D3D11DepthStencilRenderView>(width, height, format, sampleCount, sampleQuality, (D3D11GraphicDevice*)mGraphicDevice.get());
}
FrameBufferPtr D3D11GraphicFactory::createFrameBuffer() const {
return FrameBufferPtr(new D3D11FrameBuffer(true, (D3D11GraphicDevice*)mGraphicDevice.get()));
}
TexturePtr D3D11GraphicFactory::create2DTexture(uint32 width,
uint32 height,
uint32 numMipmaps,
ElementFormat format,
const uint8* initialData,
uint32 flag) const {
SharedPtr<D3D11Texture2D> texture = MakeSharedPtr<D3D11Texture2D>((D3D11GraphicDevice*)mGraphicDevice.get());
if(texture &&
texture->create(width, height, numMipmaps, format, initialData, flag)) {
return texture;
}
return SharedPtr<D3D11Texture2D>();
}
TexturePtr D3D11GraphicFactory::load2DTexture(const ResourcePtr& rsrc, bool generateMipmaps) const {
SharedPtr<D3D11Texture2D> texture = MakeSharedPtr<D3D11Texture2D>((D3D11GraphicDevice*)mGraphicDevice.get());
if(texture &&
texture->load(rsrc, generateMipmaps)) {
return texture;
}
return SharedPtr<D3D11Texture2D>();
}
EffectPtr D3D11GraphicFactory::createEffect() const {
CgDxEffect* effect = new CgDxEffect((D3D11GraphicDevice*)mGraphicDevice.get());
if(effect) {
return EffectPtr(effect);
}
return EffectPtr();
}
BlendStatePtr D3D11GraphicFactory::createBlendStateObject(const BlendStateDesc& desc) const {
return MakeSharedPtr<D3D11BlendStateObject>(desc, ((D3D11GraphicDevice*)mGraphicDevice.get()));
}
SamplerStatePtr D3D11GraphicFactory::createSamplerStateObject(const SamplerStateDesc& desc) const {
return MakeSharedPtr<D3D11SamplerStateObject>(desc, ((D3D11GraphicDevice*)mGraphicDevice.get()));
}
RasterizerStatePtr D3D11GraphicFactory::createRasterizerStateObject(const RasterizerStateDesc& desc) const {
return MakeSharedPtr<D3D11RasterizerStateObject>(desc, ((D3D11GraphicDevice*)mGraphicDevice.get()));
}
DepthStencilStatePtr D3D11GraphicFactory::createDepthStencilStateObject(const DepthStencilStateDesc& desc) const {
return MakeSharedPtr<D3D11DepthStencilStateObject>(desc, ((D3D11GraphicDevice*)mGraphicDevice.get()));
}
} // namespace ukn |
0219eb596e4daba40bea96d2b30495e4c0798f4b | a4d36e56c9d6532534526a659763433eadead7e1 | /src/ca/libs/libca/taskinfo.cpp | 8e5051f4dfb3cf704ab716078e7d45e4fda5fa45 | [] | no_license | cooljeanius/CodeAnalyst-3_4_18_0413-Public | d7d837e746901590a0ba4112ecf97194748615de | 610306a675712baf108b468c48658184b546ebb2 | refs/heads/master | 2021-10-09T22:30:40.273174 | 2021-09-29T11:12:38 | 2021-09-29T11:12:38 | 8,549,327 | 0 | 1 | null | 2023-09-04T10:52:45 | 2013-03-04T06:06:50 | C++ | UTF-8 | C++ | false | false | 19,504 | cpp | taskinfo.cpp | //$Id: taskinfo.cpp,v 1.3 2006/08/28 21:00:32 ssuthiku Exp $
/*
// CodeAnalyst for Open Source
// Copyright 2002 . 2005 Advanced Micro Devices, Inc.
// You may redistribute this program and/or modify this program 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 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.
*/
#include <qdir.h>
#include <qstring.h>
#include "taskinfo.h"
const int _MAX_PATH = 256;
#ifndef __x86_64__
const unsigned long KERNEL_START_RANGE = 0xc0100000;
#else
const unsigned long KERNEL_START_RANGE = 0xffffffff80100000;
//Kernel usually starts at ffffffff80100000
#endif
CTaskInfo::CTaskInfo()
{
m_TIReader = NULL;
m_jnc_counter = 0;
}
CTaskInfo::~CTaskInfo()
{
if (NULL != m_TIReader) {
delete m_TIReader;
m_TIReader = NULL;
}
JNCLIST_MAP::iterator it = m_tiJncMap.begin();
JNCLIST_MAP::iterator itend = m_tiJncMap.begin();
#ifdef _DEBUG_
qDebug("in CTaskInfo destructor");
#endif
for (;it != itend; it++) {
if (it != NULL) {
(*it)->clear();
delete *it;
}
}
m_tiJncMap.clear();
}
bool CTaskInfo::ReadTaskInfoFile(string filename)
{
bool ret = false;
// todo Remove this
m_TIFileName = filename;
m_TIReader = new cTaskInfoReader(m_TIFileName.c_str());
m_TIReader->openTIFile();
if (NULL != m_TIReader) {
if ((ret = m_TIReader->readHeader(m_TIHeader))) {
ret = m_TIReader->readTIFile(m_TIVector);
} else {
#ifdef _DEBUG_
qDebug("failed to read TI headr\n");
#endif
}
}
return ret;
}
void CTaskInfo::OnProcessStart(task_info_record & record)
{
// ModuleKey key(record.pid, record.start_addr + record.offset, record.time_stamp);
// ModuleValue value;
//
// value.moduleBaseAddr = record.start_addr;
// value.moduleSize = record.module_len;
// value.moduleUnloadTime = 0;
// value.moduleName = record.module_name;
// value.bNameConverted = false;
// value.bJitModule = false;
//
// m_tiModMap.insert(ModuleMap::value_type(key, value));
}
void CTaskInfo::OnModuleMap(task_info_record & record)
{
// ModuleKey key(record.pid, record.start_addr + record.offset, record.time_stamp);
// ModuleValue value;
//
// value.moduleBaseAddr = record.start_addr;
// value.moduleSize = record.module_len;
// value.moduleUnloadTime = 0;
// value.moduleName = record.module_name;
// value.bNameConverted = false;
// value.bJitModule = false;
//
// m_tiModMap.insert(ModuleMap::value_type(key, value));
}
void CTaskInfo::OnProcessEnd(task_info_record & record)
{
// ModuleKey key(record.pid, record.start_addr, record.time_stamp);
// ModuleMap::iterator it = m_tiModMap.find(key);
// ModuleMap::const_iterator itEnd = m_tiModMap.end();
//
//
// if (it != itEnd) {
// for (; (it != itEnd) && (record.pid == (*it).first.processId); it++)
// {
// (*it).second.moduleUnloadTime = record.time_stamp;
// }
// }
}
void CTaskInfo::AddkernelModule(bfd_vma start_addr, bfd_vma size, QString & name)
{
// Kernel PID = 0, loadTime = 0
ModuleKey key(0, start_addr, 0);
ModuleValue value;
value.moduleBaseAddr = start_addr;
value.moduleSize = size;
value.moduleUnloadTime = m_TIHeader.stop_time;
value.moduleName = string(name.data());
value.bNameConverted = false;
value.bJitModule = false;
m_tiModMap.insert(ModuleMap::value_type(key, value));
}
bool CTaskInfo::ReadJitInformation(const char * directory)
{
bool ret = true;
//for each process id directory in the given directory
QDir search_dir (directory);
const QFileInfoList *di_list = search_dir.entryInfoList();
QFileInfoListIterator d_it( *di_list );
QFileInfo *di;
search_dir.setFilter( QDir::Dirs );
//while there are directories left,
for (; ((di = d_it.current()) != 0 ); ++d_it) {
#ifdef _DEBUG_
qDebug("ReadJitInformation: processing dir %s", di->dirPath().data());
#endif
unsigned long pid = di->fileName().toULong();
if (0 == pid) {
continue;
}
JNC_LIST * jnc_list = new JNC_LIST();
if (NULL == jnc_list) {
ret = false;
break;
}
JIT_Load_ELEMENT jit_block;
char java_app[_MAX_PATH];
ModuleKey t_modKey(pid, 0, 0);
ModuleValue t_modValue;
QString jcl_file = directory + QString ("/") + di->fileName();
jcl_file += "/" + di->fileName();
jcl_file += ".jcl";
//read the jcl file
#ifdef _DEBUG_
qDebug("Before reading jcl file");
#endif
JCLReader jcl_reader (jcl_file.data());
JIT_RECORDS jit_record_type;
#ifdef _DEBUG_
qDebug("After reading jcl file");
#endif
//for each function in the jcl, add jnc data to the list
jnc_list->setAutoDelete (true);
if (!jcl_reader.readHeader(java_app)) {
#ifdef _DEBUG_
qDebug("readHeader %s failed", jcl_file.data());
#endif
continue;
}
t_modValue.moduleName = java_app;
#ifdef _DEBUG_
qDebug("readind java_app %s", java_app);
#endif
t_modValue.bJitModule = true;
m_tiModMap.insert (ModuleMap::value_type(t_modKey, t_modValue));
while (jcl_reader.readNextRecordType (&jit_record_type)) {
#ifdef _DEBUG_
qDebug("reading next jcl record");
#endif
if (JIT_LOAD == jit_record_type) {
if (!jcl_reader.readLoadRecord (&jit_block)) {
break;
}
JNC_VALUE * temp_jnc = new JNC_VALUE();
temp_jnc->blockEndAddr = jit_block.blockEndAddr;
temp_jnc->blockStartAddr = jit_block.blockStartAddr;
temp_jnc->loadTimestamp = jit_block.loadTimestamp;
temp_jnc->threadID = jit_block.threadID;
temp_jnc->jncFile = jit_block.jncFileName.c_str();
temp_jnc->functionName = jit_block.classFunctionName.c_str();
temp_jnc->javaSrcFile = jit_block.javaSrcFileName.c_str();
jnc_list->append(temp_jnc);
} else {
JIT_Unload_ELEMENT jit_unload_block;
if (!jcl_reader.readUnLoadRecord (&jit_unload_block))
break;
//find old record module, and alter unload time.
JNC_LIST::iterator it = jnc_list->begin();
for (;it != jnc_list->end(); ++it) {
#ifdef _DEBUG_
qDebug("looping the jnc_list");
#endif
JNC_VALUE * itv = *it;
if (jit_unload_block.blockStartAddr != itv->blockStartAddr)
continue;
if (itv->loadTimestamp >= jit_unload_block.unloadTimestamp)
continue;
itv->unloadTimestamp = jit_unload_block.unloadTimestamp;
}
}
}
//add to map
m_tiJncMap[pid] = jnc_list;
}
PrintJITMap();
return ret;
}
void CTaskInfo::PrintJITMap()
{
#ifdef _DEBUG_
JNCLIST_MAP::iterator it = m_tiJncMap.begin();
JNCLIST_MAP::iterator it_end = m_tiJncMap.end();
for (;it != it_end; it++)
{
JNC_LIST * list = it.data();
JNC_VALUE * value = list->first();
if (value == NULL)
qDebug("value is NULL");
for (value = list->first(); value; value = list->next())
{
qDebug("jit function %s", value->functionName.data());
}
}
#endif
}
void CTaskInfo::ProcessTaskInfoVector()
{
TIVector::iterator it = m_TIVector.begin();
for(; it != m_TIVector.end(); it++) {
task_info_record & record = *it;
switch(record.record_type) {
case PROCESS_START:
OnProcessStart(record);
break;
case PROCESS_EXIT:
OnProcessEnd(record);
break;
case MODULE_MAP:
OnModuleMap(record);
break;
case MODULE_UNMAP:
/*
* According to Reeja, the driver does not
* receive this event.
*/
default:
break;
}
}
AdjustModuleUnloadTime();
}
// If a module is still loaded by the time the profile session
// ends, it would unload time being 0. Need to adjust for the
// module lookup to work.
void CTaskInfo::AdjustModuleUnloadTime()
{
ModuleMap::iterator it = m_tiModMap.begin();
ModuleMap::const_iterator itEnd = m_tiModMap.end();
if (it != itEnd) {
for (; (it != itEnd); it++)
{
if (0 == (*it).second.moduleUnloadTime)
(*it).second.moduleUnloadTime = m_TIHeader.stop_time;
}
}
}
bool CTaskInfo::GetModuleInfo(TI_MODULE_INFO * mod_info,
unsigned int novmlinux)
{
#ifdef _DEBUG_
if (mod_info->sampleAddr < KERNEL_START_RANGE) {
qDebug("--------");
qDebug("prd has processID %d", mod_info->processID);
qDebug("prd has addr %llx", mod_info->sampleAddr);
qDebug("prd has time stamp %llx", mod_info->timestamp);
}
ModuleMap::iterator j;
for (j = m_tiModMap.begin(); j != m_tiModMap.end(); ++j) {
ModuleMap::value_type &item = *j;
qDebug("module is %s pid is %d", item.second.moduleName.c_str(),
item.first.processId);
}
#endif
bool ret = false;
// check map status
if (0 == m_tiModMap.size()) {
#ifdef _DEBUG_
qDebug("mod map empty");
#endif
return ret;
}
// Kernel range sample
// If user does not specify the path to vmlinux
// Set the modulename to no-vmlinux by default.
if (mod_info->sampleAddr > KERNEL_START_RANGE )
{
mod_info->processID = 0;
if (1 == novmlinux) {
strcpy(mod_info->pModulename, "Anonymous Samples");
mod_info->ModuleStartAddr = KERNEL_START_RANGE;
return true;
}
}
ModuleMap::iterator i;
for (i = m_tiModMap.lower_bound(ModuleKey(mod_info->processID, 0, 0)); i != m_tiModMap.end(); ++i)
{
ModuleMap::value_type &item = *i;
/*
* Note: The map structure is identical to what we do on Windows.
* The only differences are:
* 1. We use TSC instead of system time on Linux. No time conversion is needed here.
* 2. We don't distinguish between kernel/user modules in Linux.
* 3. There is no need to convert the name.
*/
if (!item.second.bJitModule) {
// different process
if (item.first.processId != mod_info->processID)
break;
#ifdef _DEBUG_
qDebug("module pid %d", item.first.processId);
qDebug("module load addr %llx", item.first.moduleLoadAddr);
qDebug("module unloadload addr %llx", item.first.moduleLoadAddr + item.second.moduleSize);
qDebug("module addr is %llx", mod_info->sampleAddr);
qDebug("module load time %llx", item.first.moduleLoadTime);
qDebug("module unload time %llx", item.second.moduleUnloadTime);
qDebug("module time is %llx", mod_info->timestamp);
#endif
// since the module map is sorted by the process id, module address and time.
// if module load address is greater than sample address, we don't need
// go farther.
if (item.first.moduleLoadAddr > mod_info->sampleAddr) {
break;
}
// if module upper boundary is less than the sample address, try next module.
if (item.first.moduleLoadAddr + item.second.moduleSize <= mod_info->sampleAddr) {
continue;
}
// if load time is not in module load frame, try next module
if (item.first.moduleLoadTime >= mod_info->timestamp) {
continue;
}
// if load time is not in module load frame, try next module
if (item.second.moduleUnloadTime < mod_info->timestamp) {
continue;
}
mod_info->ModuleStartAddr = item.first.moduleLoadAddr;
} else {
#ifdef _DEBUG_
qDebug("searching for JIT module");
qDebug("module pid %d", item.first.processId);
qDebug("module load addr %llx", item.first.moduleLoadAddr);
qDebug("module load time %llx", item.first.moduleLoadTime);
qDebug("module unload time %llx", item.second.moduleUnloadTime);
#endif
//check functions for pid.
JNC_VALUE * jncIt = NULL;
//check jit area map
JNCLIST_MAP::Iterator jnc_list = m_tiJncMap.find (mod_info->processID);
if (m_tiJncMap.end() == jnc_list)
break;
for (jncIt = jnc_list.data()->first(); jncIt; jncIt = jnc_list.data()->next()) {
if (jncIt->blockStartAddr > mod_info->sampleAddr) {
#ifdef _DEBUG_
qDebug("blockStartAddr %llx > sample Addr %llx",
jncIt->blockStartAddr, mod_info->sampleAddr);
#endif
continue;
}
if (jncIt->blockEndAddr < mod_info->sampleAddr) {
#ifdef _DEBUG_
qDebug("blockStartAddr %llx < sample Addr %llx",
jncIt->blockStartAddr, mod_info->sampleAddr);
#endif
continue;
}
if ((jncIt->loadTimestamp > mod_info->timestamp) ||
(jncIt->unloadTimestamp < mod_info->timestamp)) {
#ifdef _DEBUG_
qDebug("incorrect loadtime/unloadtime");
if (jncIt->loadTimestamp > mod_info->timestamp)
qDebug("smaple has timestamp earlier than JIT load time");
if (jncIt->unloadTimestamp < mod_info->timestamp)
qDebug("sample has timestampe later than JIT unload time");
qDebug("jncIt has load time %llx, mod_info has time %llx",
jncIt->loadTimestamp, mod_info->timestamp);
qDebug("jncIt has unload time %llx, mod_info has time %llx",
jncIt->unloadTimestamp, mod_info->timestamp);
#endif
continue;
}
//translate jnc name here...
if ( jncIt->translatedJncFile.isEmpty())
jncIt->translatedJncFile.sprintf ("jnc_%d.jnc",m_jnc_counter++);
break;
}
//if it wasn't in the recorded jit areas for the module, keep going
if (! jncIt)
continue;
mod_info->funSize = jncIt->functionName.length();
strncpy (mod_info->pFunctionName, jncIt->functionName.data(), mod_info->funSize);
mod_info->FunStartAddr = jncIt->blockStartAddr;
mod_info->ModuleStartAddr = jncIt->blockStartAddr;
mod_info->jncSize = jncIt->translatedJncFile.length();
strncpy (mod_info->pJncName, jncIt->translatedJncFile.data(), mod_info->jncSize);
strncpy(mod_info->pJavaSrcName, jncIt->javaSrcFile.data(),
jncIt->javaSrcFile.length());
}
// Here, we found the module.
mod_info->JitModule = item.second.bJitModule;
mod_info->Modulesize = item.second.moduleSize;
// todo: verify that there is no need to convert the map
// if the module name is not converted yet, convert it and update it in the map.
/*
if (!item.second.bJitModule) {
if (!item.second.bNameConverted) {
item.second.moduleName = ConvertName(item.second.moduleName.c_str());
item.second.bNameConverted = TRUE;
}
} else {
item.second.bNameConverted = TRUE;
}
*/
item.second.bNameConverted = TRUE;
if (item.second.moduleName.size() < mod_info->namesize)
{
#ifdef _DEBUG_
qDebug("Found in JNC");
#endif
strcpy(mod_info->pModulename, item.second.moduleName.c_str());
ret = true;
}
else
{
#ifdef _DEBUG_
qDebug("Found in JNC");
#endif
ret = true;
}
break;
}
#ifdef _DEBUG_
qDebug("GetModuleInfo PID %d returns %d\n", mod_info->processID, ret);
#endif
return ret;
}
void CTaskInfo::PrintTIVector()
{
#ifdef _DEBUG_
TIVector::iterator it = m_TIVector.begin();
printf("size of TIVector is %d\n", m_TIVector.size());
for(; it != m_TIVector.end(); it++) {
task_info_record & record = *it;
printf("/***********************/\n");
printf("pid: %d\n", record.pid);
printf("tgid: %d\n", record.tgid);
printf("start_addr: %llx\n", record.start_addr);
printf("module len: %d\n", record.module_len);
printf("offset: %d\n", record.offset);
//printf("time_stamp: %d\n", record.time_stamp);
printf("module name len: %d\n", record.module_name_len);
cout << "modulenaem: " << record.module_name << endl;
//printf("modulename: %s\n", record.module_name);
printf("record type: %d\n\n", record.record_type);
}
#endif
}
bool CTaskInfo::copyJNCFile(QString & sessionDir, QString & jncPath)
{
bool ret = true;
JNCLIST_MAP::Iterator map_it = m_tiJncMap.begin();
JNCLIST_MAP::Iterator map_it_end = m_tiJncMap.end();
for (; map_it != map_it_end; map_it++)
{
JNC_VALUE * temp;
JNC_LIST * jnc_list = map_it.data();
//check jit area map
for (temp = jnc_list->first(); temp; temp = jnc_list->next()) {
//translate jnc name here...
if (!temp->translatedJncFile.isEmpty()) {
//copy from temp->jncFile to temp->translatedJncFile
QString new_jnc;
new_jnc.sprintf ("%s/%s",sessionDir.data(), temp->translatedJncFile.data());
QString old_file_name = temp->jncFile;
if (!temp->jncFile.contains(jncPath)) {
/*
* If the jitted block does not contain the jnc path,
* this must be a import session. We must rename the file
* to be copied from
*/
QString java = "/Java/";
int index = temp->jncFile.find(java) + java.length();
old_file_name = jncPath +
temp->jncFile.right(temp->jncFile.length() - index);
}
QFile new_file (new_jnc);
QFile old_file (old_file_name);
if (!old_file.open(QIODevice::ReadOnly)) {
#ifdef _DEBUG_
qDebug("failed to open old file %s", temp->jncFile.data());
#endif
return false;
}
if (!new_file.open (QIODevice::WriteOnly ))
return false;
const QByteArray temp_buffer = old_file.readAll();
new_file.writeBlock (temp_buffer);
old_file.close();
new_file.close();
}
}
}
}
/*
HRESULT CTaskInfo::WriteJncFiles (const char * directory)
{
HRESULT hr = S_OK;
JNCLIST_MAP::Iterator map_it;
for ( map_it = m_tiJncMap.begin(); map_it != m_tiJncMap.end(); ++map_it ) {
JNC_VALUE *temp;
JNC_LIST *jnc_list = map_it.data();
//check jit area map
for ( temp = jnc_list->first(); temp; temp = jnc_list->next() ) {
//translate jnc name here...
if (!temp->translatedJncFile.isEmpty()) {
//copy from temp->jncFile to temp->translatedJncFile
QString new_jnc;
new_jnc.sprintf ("%s\\%s",directory, temp->translatedJncFile.data());
QFile new_file (new_jnc);
QFile old_file (temp->jncFile);
if (!old_file.open(IO_ReadOnly))
return E_FAIL;
if (!new_file.open (IO_WriteOnly ))
return E_FAIL;
const QByteArray temp_buffer = old_file.readAll();
new_file.writeBlock (temp_buffer);
old_file.close();
new_file.close();
}
}
}
return hr;
}
*/
/*
int main()
{
CTaskInfo ti;
ti.ReadTaskInfoFile("ca_profile.ti");
ti.PrintTIVector();
ti.ProcessTaskInfoVector();
return 0;
}
*/
|
7655ca664ceb0f4e3fc119016231114923a947e6 | 2f10f807d3307b83293a521da600c02623cdda82 | /deps/boost/win/debug/include/boost/fusion/include/move.hpp | 4383d8d858eb7820c7e59760f5dd113084815e7f | [] | no_license | xpierrohk/dpt-rp1-cpp | 2ca4e377628363c3e9d41f88c8cbccc0fc2f1a1e | 643d053983fce3e6b099e2d3c9ab8387d0ea5a75 | refs/heads/master | 2021-05-23T08:19:48.823198 | 2019-07-26T17:35:28 | 2019-07-26T17:35:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 128 | hpp | move.hpp | version https://git-lfs.github.com/spec/v1
oid sha256:329109fb34f8da1dc3c81275f6179f6aa1ed1634ad1458400b0c3ade15f2e946
size 527
|
ef6f98f0b85832a9503b25128e09b3678bc131f9 | 65381e87330fa20b70cfc7ee2a1ef2cf891078d0 | /PrisonCellsAfterNDays.cpp | ffb902c7ce9eb48746dfa986f749cff93696d150 | [] | no_license | mittaldivya01/LeetcodeJulyChallenge | 9354d4a904113e6e2202a09cab0a620a0bbc9581 | 8331c9eb5d8d60076b98600a0690c9f9f4620de6 | refs/heads/master | 2022-11-26T01:13:48.907764 | 2020-08-04T04:28:42 | 2020-08-04T04:28:42 | 276,438,471 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 525 | cpp | PrisonCellsAfterNDays.cpp | class Solution {
public:
vector<int> prisonAfterNDays(vector<int>& cells, int N) {
if(N==0)
return cells;
if(N%14 ==0)
N=14;
else
N=N%14;
for(int i=0;i<N;i++)
{
vector<int> tmp(8,0);
for(int j=1;j<7;j++)
{
if(cells[j-1]==cells[j+1])
tmp[j]=1;
else
tmp[j]=0;
}
cells=tmp;
}
return cells;
}
};
|
3b92a50bfb591fbefed7c77f30d0546fbbca9947 | 8f35d04da185bbc681534394c030013228340982 | /scene/SceneStack.h | 34c0cf09e4c1d87cc8299f009c78ebd4573f86ea | [] | no_license | larryaubstore/force-brute | ff1b744fb61f666724d0c62ffff7e7a66eb060b0 | 01267991f0615482b5c68383b9c3a1799b7c7457 | refs/heads/master | 2021-01-19T01:44:13.238716 | 2013-12-17T03:21:41 | 2013-12-17T03:21:41 | 4,174,721 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 890 | h | SceneStack.h | /**
* @file SceneStack.h
* @brief
* @author Laurence Morin-Daoust
* @version 1.0
* @date 2013-06-06
*/
#ifndef SCENE_STACK_H
#define SCENE_STACK_H
#include <vector>
#include <string>
#include <sstream>
#include "ISceneStack.h"
#include "Animation.h"
#include "../TypeDefEngine.h"
class SceneStack : public ISceneStack
{
private:
std::vector<AnimationPtr> m_AnimationList;
std::vector<AnimationPtr> m_AnimationListForRendering;
public:
/**
* @brief Default constructor.
*/
SceneStack();
/**
* @brief Destructor.
*/
~SceneStack();
void Push(std::string a_name,
int a_startFrame,
int a_endFrame,
bool a_isPermanent,
int a_xPos,
int a_yPos,
int a_currentFrame);
std::vector<AnimationPtr> GetAnimationList();
void GetAnimationForRendering();
void NextPosition();
};
#endif
|
4fe76f07645314bc02fbc5ef57e5db742bfb9e2e | 7a71449197d4db9bf545b161e047af3c06f8b870 | /NiirdPad/QScriptEditWindow.cpp | de0e508c81c672a7c5995d1bf8abe60f0ca2cde6 | [] | no_license | TheEclectus/NiirdPad | ff2d29a6b65e5f4b695577a1c33bd0dbbda23a82 | c75bc14e85646e12e67cb65139124cda0579734c | refs/heads/master | 2022-11-21T05:58:33.436283 | 2020-07-27T04:27:46 | 2020-07-27T04:27:46 | 282,791,453 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,818 | cpp | QScriptEditWindow.cpp | #include "QScriptEditWindow.h"
#include <QMessageBox>
#include <QTextBlock>
#include <QTextDocument>
#include <strtk.hpp>
#include "Node.h"
#include <thread>
// Consider further retooling, pertaining to the proper fade-in of the window when it's reopened.
QScriptEditWindow::QScriptEditWindow(QWidget *parent, ScriptEngine &Engine, bool bHideVisConditions) :
QDialog(parent),
_scriptEngine(Engine),
_option(nullptr),
_dialogue(nullptr)
{
ui.setupUi(this);
// ORDER IS IMPORTANT.
// DIALOGUE EDIT SETUP
ui.txtVisibility->setEnabled(false);
ui.txtVisibility->hide();
ui.lblVisErrors->setEnabled(false);
ui.lblVisErrors->hide();
ui.splitter->handle(1)->setEnabled(false);
ui.splitter->handle(1)->setVisible(false);
_DefaultSizeDialogues = ui.splitter->saveState();
// OPION EDIT SETUP
ui.txtVisibility->setEnabled(true);
ui.txtVisibility->show();
ui.lblVisErrors->setEnabled(true);
ui.lblVisErrors->show();
ui.splitter->handle(1)->setEnabled(true);
ui.splitter->handle(1)->setVisible(true);
_DefaultSizeOptions = ui.splitter->saveState();
//this->setWindowFlags(Qt::Dialog | Qt::Desktop);
//ui.splitter->setCollapsible(0, true);
//ui.splitter->child
if (bHideVisConditions)
{
ui.txtVisibility->setEnabled(false);
ui.txtVisibility->hide();
ui.lblVisErrors->setEnabled(false);
ui.lblVisErrors->hide();
ui.splitter->handle(1)->setEnabled(false);
ui.splitter->handle(1)->setVisible(false);
}
connect(this, &QDialog::accepted, this, &QScriptEditWindow::FormAccepted);
connect(ui.btnAccept, &QPushButton::clicked, [this]()
{
accept();
});
connect(ui.btnCancel, &QPushButton::clicked, this, &QScriptEditWindow::Close);
connect(ui.txtScripts, &QTextEdit::textChanged, this, &QScriptEditWindow::ResetTimer);
connect(ui.txtScripts, &QTextEdit::textChanged, [this]() {
if (this->isVisible())
{
if (!_bChangesMade)
setWindowTitle(windowTitle().append("*"));
_bChangesMade = true;
}
});
connect(ui.txtVisibility, &QTextEdit::textChanged, this, &QScriptEditWindow::ResetTimer);
connect(ui.txtVisibility, &QTextEdit::textChanged, [this]() {
if (this->isVisible())
{
if (!_bChangesMade)
setWindowTitle(windowTitle().append("*"));
_bChangesMade = true;
}
});
connect(&_updateTimer, &QTimer::timeout, this, &QScriptEditWindow::ValidateScripts);
connect(&_updateTimer, &QTimer::timeout, this, &QScriptEditWindow::ValidateVisConditions);
ValidateScripts();
ValidateVisConditions();
}
QScriptEditWindow::~QScriptEditWindow()
{
}
//int QScriptEditWindow::EditDialogueFragment(QWidget *Parent, ScriptEngine &Engine, NodeDialogue &Dialogue)
//{
// QScriptEditWindow ScriptEdit(Parent, Engine, true);
//
// /*
// 1. Dialogue text needs to have "<br>"s replaced with newlines.
// 2. txtText populated with
// 3. txtScripts populated with FunctionLines
// 4. txtVisibility populated with VisibilityLines
// */
// std::string FormattedDialogue = Dialogue.GetDialogue();
// size_t Pos = FormattedDialogue.find("<br>");
// while (Pos != std::string::npos)
// {
// FormattedDialogue.replace(Pos, 4, "\n");
// Pos = FormattedDialogue.find("<br>");
// }
// ScriptEdit.ui.txtText->setPlainText(FormattedDialogue.c_str());
//
// ScriptEdit.ui.txtVisibility->clear();
// for (auto &CurVisLine : Dialogue.GetFunctionLines())
// {
// ScriptEdit.ui.txtVisibility->append(CurVisLine.c_str());
// }
//
// ScriptEdit.ui.txtScripts->clear();
// for (auto &CurFuncLine : Dialogue.GetFunctionLines())
// {
// ScriptEdit.ui.txtScripts->append(CurFuncLine.c_str());
// }
// //ScriptEdit.ui.txtScripts->document()->setPlainText()
//
// int Res = ScriptEdit.exec();
// if (Res == QDialog::DialogCode::Accepted)
// {
// QTextDocument &QtDoc = *ScriptEdit.ui.txtScripts->document();
// std::vector<std::string> FunctionLines = {};
// for (QTextBlock CurLine = QtDoc.begin(); CurLine != QtDoc.end(); CurLine = CurLine.next())
// {
// FunctionLines.push_back(CurLine.text().toStdString());
// }
// strtk::remove_empty_strings(FunctionLines);
//
// std::string DialogueText = ScriptEdit.ui.txtText->toPlainText().toStdString();
//
// // TODO: remove trailing newlines?
// size_t Pos = DialogueText.find('\n');
// while (Pos != std::string::npos)
// {
// DialogueText.replace(Pos, 1, "<br>");
// Pos = DialogueText.find('\n');
// }
// Dialogue.SetAll(FunctionLines, DialogueText);
// }
//
// return Res;
//}
int QScriptEditWindow::EditOptionFragment(QWidget *Parent, ScriptEngine &Engine, NodeOption &Option)
{
QScriptEditWindow ScriptEdit(Parent, Engine, false);
int Res = ScriptEdit.exec();
if (Res == QDialog::Accepted)
{
QTextDocument &QtDoc = *ScriptEdit.ui.txtVisibility->document();
std::vector<std::string> VisLines = {};
for (QTextBlock CurLine = QtDoc.begin(); CurLine != QtDoc.end(); CurLine = CurLine.next())
{
VisLines.push_back(CurLine.text().toStdString());
}
strtk::remove_empty_strings(VisLines);
QTextDocument &QtDocScripts = *ScriptEdit.ui.txtScripts->document();
std::vector<std::string> ScriptLines = {};
for (QTextBlock CurLine = QtDocScripts.begin(); CurLine != QtDocScripts.end(); CurLine = CurLine.next())
{
ScriptLines.push_back(CurLine.text().toStdString());
}
strtk::remove_empty_strings(ScriptLines);
std::string OptionText = ScriptEdit.ui.txtText->toPlainText().toStdString();
// TODO: remove trailing newlines?
size_t Pos = OptionText.find('\n');
while (Pos != std::string::npos)
{
OptionText.replace(Pos, 1, "<br>");
Pos = OptionText.find('\n');
}
Option.SetAll(VisLines, ScriptLines, OptionText);
}
return Res;
}
void QScriptEditWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
Close();
}
void QScriptEditWindow::dialogueFragment(NodeDialogue *Dialogue)
{
if (!Dialogue)
return;
_dialogue = Dialogue;
this->setWindowTitle("Edit Dialogue Fragment");
ui.txtVisibility->setEnabled(false);
ui.txtVisibility->hide();
ui.lblVisErrors->setEnabled(false);
ui.lblVisErrors->hide();
ui.splitter->handle(1)->setEnabled(false);
ui.splitter->handle(1)->setVisible(false);
//TODO: save this to the NodeDialogue state
//int blorp = ui.splitter->saveState();
auto WindowState = Dialogue->GetWindowState();
if (WindowState.size() > 0)
ui.splitter->restoreState(WindowState);
else
ui.splitter->restoreState(_DefaultSizeDialogues);
/*
1. Dialogue text needs to have "<br>"s replaced with newlines.
2. txtText populated with
3. txtScripts populated with FunctionLines
4. txtVisibility populated with VisibilityLines
*/
std::string FormattedDialogue = _dialogue->GetDialogue();
size_t Pos = FormattedDialogue.find("<br>");
while (Pos != std::string::npos)
{
FormattedDialogue.replace(Pos, 4, "\n");
Pos = FormattedDialogue.find("<br>");
}
this->ui.txtText->setPlainText(FormattedDialogue.c_str());
/*this->ui.txtVisibility->clear();
for (auto &CurVisLine : _dialogue->GetFunctionLines())
{
this->ui.txtVisibility->append(CurVisLine.c_str());
}*/
this->ui.txtScripts->clear();
for (auto &CurFuncLine : _dialogue->GetFunctionLines())
{
this->ui.txtScripts->append(CurFuncLine.c_str());
}
//this->activateWindow();
this->show();
}
void QScriptEditWindow::optionFragment(NodeOption *Option)
{
if (!Option)
return;
_option = Option;
this->setWindowTitle("Edit Option Fragment");
ui.txtVisibility->setEnabled(true);
ui.txtVisibility->show();
ui.lblVisErrors->setEnabled(true);
ui.lblVisErrors->show();
ui.splitter->handle(1)->setEnabled(true);
ui.splitter->handle(1)->setVisible(true);
auto WindowState = Option->GetWindowState();
if (WindowState.size() > 0)
ui.splitter->restoreState(WindowState);
else
ui.splitter->restoreState(_DefaultSizeOptions);
/*
1. Dialogue text needs to have "<br>"s replaced with newlines.
2. txtText populated with
3. txtScripts populated with FunctionLines
4. txtVisibility populated with VisibilityLines
*/
std::string FormattedOption = _option->GetOption();
size_t Pos = FormattedOption.find("<br>");
while (Pos != std::string::npos)
{
FormattedOption.replace(Pos, 4, "\n");
Pos = FormattedOption.find("<br>");
}
this->ui.txtText->setPlainText(FormattedOption.c_str());
this->ui.txtVisibility->clear();
for (auto &CurVisLine : _option->GetVisibilityScriptLines())
{
this->ui.txtVisibility->append(CurVisLine.c_str());
}
this->ui.txtScripts->clear();
for (auto &CurFuncLine : _option->GetFunctionLines())
{
this->ui.txtScripts->append(CurFuncLine.c_str());
}
this->show();
}
void QScriptEditWindow::ResetTimer()
{
_updateTimer.start(UPDATE_DELAY_MS);
}
void QScriptEditWindow::ValidateScripts()
{
//ui.txtErrors->clear();
//_keys.clear();
QTextDocument &QtDoc = *ui.txtScripts->document();
std::vector<std::string> Lines = {};
for (QTextBlock CurLine = QtDoc.begin(); CurLine != QtDoc.end(); CurLine = CurLine.next())
{
Lines.push_back(CurLine.text().toStdString());
}
bool bEncounteredError = false;
bool bHasIndexModifyingFunction = false;
for (auto Line = Lines.begin(); Line != Lines.end(); Line++)
{
//std::string LineMinusWhitespace
if (Line->length() == 0) continue;
std::vector<std::string> Keys = {};
std::string Err = "";
if (!_scriptEngine.bScriptIsValid(*Line, Keys, Err))
{
//ui.lblScriptErrors->setText(Err.c_str());
ScriptsMakeError(Err);
bEncounteredError = true;
break;
}
if (Keys.size() > 0)
{
if (!bHasIndexModifyingFunction)
bHasIndexModifyingFunction = true;
else
{
ScriptsMakeError("Multiple index-modifying functions defined.");
bEncounteredError = true;
break;
}
}
}
if(!bEncounteredError)
ScriptsMakeClean();
//ui.txtErrors->insertPlainText(">blap\n");
_updateTimer.stop();
}
void QScriptEditWindow::ScriptsMakeClean()
{
ui.lblScriptErrors->setText("No errors found.");
QPalette Pal = ui.lblScriptErrors->palette();
Pal.setColor(ui.lblScriptErrors->foregroundRole(), Qt::darkGreen);
ui.lblScriptErrors->setPalette(Pal);
}
void QScriptEditWindow::ScriptsMakeError(const std::string &Message)
{
ui.lblScriptErrors->setText(Message.c_str());
QPalette Pal = ui.lblScriptErrors->palette();
Pal.setColor(ui.lblScriptErrors->foregroundRole(), Qt::red);
ui.lblScriptErrors->setPalette(Pal);
}
void QScriptEditWindow::ValidateVisConditions()
{
QTextDocument &QtDoc = *ui.txtVisibility->document();
std::vector<std::string> Lines = {};
for (QTextBlock CurLine = QtDoc.begin(); CurLine != QtDoc.end(); CurLine = CurLine.next())
{
Lines.push_back(CurLine.text().toStdString());
}
bool bEncounteredError = false;
bool bHasIndexModifyingFunction = false;
for (auto Line = Lines.begin(); Line != Lines.end(); Line++)
{
//std::string LineMinusWhitespace
if (Line->length() == 0) continue;
std::string Err = "";
if (!_scriptEngine.bVisConditionIsValid(*Line, Err))
{
//ui.lblScriptErrors->setText(Err.c_str());
VisMakeError(Err);
bEncounteredError = true;
break;
}
}
if (!bEncounteredError)
VisMakeClean();
//ui.txtErrors->insertPlainText(">blap\n");
_updateTimer.stop();
}
void QScriptEditWindow::VisMakeClean()
{
ui.lblVisErrors->setText("No errors found.");
QPalette Pal = ui.lblVisErrors->palette();
Pal.setColor(ui.lblVisErrors->foregroundRole(), Qt::darkGreen);
ui.lblVisErrors->setPalette(Pal);
}
void QScriptEditWindow::VisMakeError(const std::string &Message)
{
ui.lblVisErrors->setText(Message.c_str());
QPalette Pal = ui.lblVisErrors->palette();
Pal.setColor(ui.lblVisErrors->foregroundRole(), Qt::red);
ui.lblVisErrors->setPalette(Pal);
}
void QScriptEditWindow::Close()
{
if (_bChangesMade && QMessageBox::warning(this, "Unsaved Changes", "Any changes will be discarded.\nContinue?", QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Cancel) == QMessageBox::StandardButton::Cancel)
return;
reject();
ResetForm();
}
void QScriptEditWindow::ResetForm()
{
ui.txtScripts->clear();
ui.txtText->clear();
ui.txtVisibility->clear();
//_keys.clear();
this->_dialogue = nullptr;
this->_option = nullptr;
_bChangesMade = false;
VisMakeClean();
ScriptsMakeClean();
}
void QScriptEditWindow::FormAccepted()
{
if (!_dialogue && !_option)
return;
if (_dialogue)
{
QTextDocument &QtDoc = *this->ui.txtScripts->document();
std::vector<std::string> FunctionLines = {};
for (QTextBlock CurLine = QtDoc.begin(); CurLine != QtDoc.end(); CurLine = CurLine.next())
{
FunctionLines.push_back(CurLine.text().toStdString());
}
strtk::remove_empty_strings(FunctionLines);
_dialogue->GetWindowState() = ui.splitter->saveState();
std::string DialogueText = this->ui.txtText->toPlainText().toStdString();
// TODO: remove trailing newlines?
_dialogue->SetAll(FunctionLines, DialogueText);
_dialogue = nullptr;
}
else if (_option)
{
QTextDocument &QtDoc = *this->ui.txtScripts->document();
std::vector<std::string> FunctionLines = {};
for (QTextBlock CurLine = QtDoc.begin(); CurLine != QtDoc.end(); CurLine = CurLine.next())
{
FunctionLines.push_back(CurLine.text().toStdString());
}
strtk::remove_empty_strings(FunctionLines);
QTextDocument &VisDoc = *this->ui.txtVisibility->document();
std::vector<std::string> VisLines = {};
for (QTextBlock CurLine = VisDoc.begin(); CurLine != VisDoc.end(); CurLine = CurLine.next())
{
VisLines.push_back(CurLine.text().toStdString());
}
strtk::remove_empty_strings(VisLines);
_option->GetWindowState() = ui.splitter->saveState();
std::string OptionText = this->ui.txtText->toPlainText().toStdString();
// TODO: remove trailing newlines?
size_t Pos = OptionText.find('\n');
while (Pos != std::string::npos)
{
OptionText.replace(Pos, 1, "<br>");
Pos = OptionText.find('\n');
}
_option->SetAll(VisLines, FunctionLines, OptionText);
_option = nullptr;
}
ResetForm();
this->hide();
} |
6756ff2314836ccf6264e1c3bb0ff7ea6c76a0e9 | bd91a68c3ed8072ae292191b50bea3349b2f55bc | /ASTNodes/ClassImplements.hpp | 06479ed97a6c5b4f31606374b684708a2d16f6b6 | [
"MIT"
] | permissive | jonathan-beard/Raft | 0e28d5ea72e840441b2f42f46b45ec2f5b08371e | 6b2c250c915b5ce1db84277e6e5722977e8ebbba | refs/heads/master | 2021-01-17T05:24:36.314552 | 2019-04-23T16:03:09 | 2019-04-23T16:03:09 | 8,226,622 | 6 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 387 | hpp | ClassImplements.hpp | /**
* ClassImplements.hpp -
* @author: Jonathan Beard
* @version: Sun Jan 19 08:24:19 2014
*/
#ifndef _CLASSIMPLEMENTS_HPP_
#define _CLASSIMPLEMENTS_HPP_ 1
#include <string>
#include "ClassInherit.hpp"
namespace Node {
class ClassImplements : public ClassInherit {
public:
ClassImplements();
virtual ~ClassImplements() = default;
};
}
#endif /* END _CLASSIMPLEMENTS_HPP_ */
|
de38ffdecfd4c2a6f2ee25ba7473b69a5f76f11c | 2de766db3b23b1ae845396fbb30615c01cc1604e | /codeforces/176/1/B.cpp | 4c8b0dfc44f7fc8774f45dfbc62f42826cbd1a5a | [] | no_license | delta4d/AlgoSolution | 313c5d0ff72673927ad3862ee7b8fb432943b346 | 5f6f89578d5aa37247a99b2d289d638f76c71281 | refs/heads/master | 2020-04-21T01:28:35.690529 | 2015-01-29T13:38:54 | 2015-01-29T13:38:54 | 8,221,423 | 1 | 0 | null | 2013-04-09T15:10:20 | 2013-02-15T16:09:33 | C++ | UTF-8 | C++ | false | false | 531 | cpp | B.cpp | #include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 1000000 + 86;
int x[MAXN<<1], n;
inline int nxt(const int x, const int k) { return x % k == 0 ? x - k : x / k * k; }
int main() {
scanf("%d", &n);
for (int i=0; i<n; ++i) x[i] = i + 1;
for (int k=2; k<=n; ++k) for (int i=n,j; i>0; i=j) x[i+k-2] = x[(j=nxt(i, k))+k-2];
for (int i=0; i<n; ++i) printf("%d%s", x[i+n-1], i==n-1?"\n":" ");
return 0;
}
// 3399791 Mar 24, 2013 3:28:20 PM delta_4d 286B - Shifting GNU C++ Accepted 515 ms 7800 KB
|
e675974edf806d34410c679db2587037a3cead77 | 30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a | /Codes/AC/3468.cpp | 72605d60e544c5def982a058291eb01e36576f97 | [] | no_license | thegamer1907/Code_Analysis | 0a2bb97a9fb5faf01d983c223d9715eb419b7519 | 48079e399321b585efc8a2c6a84c25e2e7a22a61 | refs/heads/master | 2020-05-27T01:20:55.921937 | 2019-11-20T11:15:11 | 2019-11-20T11:15:11 | 188,403,594 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,107 | cpp | 3468.cpp | #include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<stdio.h>
#include<math.h>
#include<cstdlib>
#include<set>
#include<map>
#include<ctime>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#define ll long long int
#define INF 0x7fffffff
#define LIT 0x3f3f3f3f
#define mod 1000000007
#define me(a,b) memset(a,b,sizeof(a))
#define PI acos(-1.0)
//size_t npos=-1;
//ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
const int N=1e4+5;
const int MXN=1e9;
//const ll N=1e18;
bool jug(ll x,ll n)
{
ll sum=0;
ll q=n;
while(q){
if(q<x){
x=q;
q=0;
}
else
q-=x;
sum+=x;
q=q-q/10;
}
if(sum*2>=n)
return true;
return false;
}
int main()
{
jug(2,68);
ll n;
cin>>n;
ll l=1,r=n,mid;
while(l<r){
mid=(l+r)>>1;
if(jug(mid,n))
r=mid;
else
l=mid+1;
}
cout<<r<<endl;
}
|
ec069e871874a7a8c0f37710387a2469d32176e6 | afee7d79003616df7e215715aad78a8ec01657e2 | /UVA/624 - CD.cpp | ec429317c6883790a1e7fcd35ba259f59a8334f5 | [] | no_license | elgharib94/Problem-Solving-Solution | d8c7eb0cac4f555bb7cba84687bc8fa0fca64fd6 | e9ae560bddcafa6f91c7d586e40ff22ad18fe92e | refs/heads/master | 2023-01-04T17:35:41.741788 | 2020-10-29T13:09:21 | 2020-10-29T13:09:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 502 | cpp | 624 - CD.cpp | #include <bits/stdc++.h>
using namespace std;
#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
using namespace std;
int main() {
long long n, m, x, c = 0;
set<long long> a;
while (cin >> n >> m && (n != 0 || m != 0)) {
c = 0;
for (int i = 0; i < n; ++i) {
cin >> x;
a.insert(x);
}
for (int i = 0; i < m; ++i) {
cin >> x;
if (a.find(x) != a.end()) {
c++;
}
}
a.clear();
cout << c << endl;
}
return 0;
}
|
b57e322d87df4202268d8674fb3c4c5a4766b5b7 | 4e74645771b2b3457906a52958fd0a2f5931b72c | /Chapter-15/TextQuery/query.cc | 9b3548d47292c658046c799f89ac2ae0dc603b02 | [] | no_license | chushu10/cpp-primer | 750b09a058ab45a8b629312a55f2ac43acd981f7 | 1bd1c90ab46bc02cf0bd039672e489c5cd91bef8 | refs/heads/master | 2022-02-23T00:59:03.861091 | 2019-09-10T13:49:33 | 2019-09-10T13:49:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,889 | cc | query.cc | #include "query.h"
Query::Query(const std::string& s): q(new WordQuery(s)), use(new std::size_t(1))
{
std::cout << "[Query] Created a Query with " + s + " and " + std::to_string(*use) << std::endl;
}
void Query::decr_use()
{
if (--*use == 0) {
delete q;
delete use;
std::cout << "[Query] Deleted a Query" << std::endl;
}
}
std::set<TextQuery::line_no>
OrQuery::eval(const TextQuery& file) const
{
// virtual calls through the Query handle to get result sets for the operands
std::set<line_no> right = rhs.eval(file),
ret_lines = lhs.eval(file); // destination to hold results
// inserts the lines from right that aren't already in ret_lines
ret_lines.insert(right.begin(), right.end());
return ret_lines;
}
std::set<TextQuery::line_no>
AndQuery::eval(const TextQuery& file) const
{
// virtual calls through the Query handle to get result sets for the operands
std::set<line_no> left = lhs.eval(file),
right = rhs.eval(file);
std::set<line_no> ret_lines; // destination to hold results
// writes intersection of two ranges to a destination iterator
// destination iterator in this call adds elements to ret
set_intersection(left.begin(), left.end(),
right.begin(), right.end(),
inserter(ret_lines, ret_lines.begin()));
return ret_lines;
}
std::set<TextQuery::line_no>
NotQuery::eval(const TextQuery& file) const
{
// virtual call through the Query handle to eval
std::set<TextQuery::line_no> has_val = query.eval(file);
std::set<line_no> ret_lines;
// for each line in the input file, check whether that line is in has_val
// if not, add that line number to ret_lines
for (TextQuery::line_no n = 0; n != file.size(); ++n)
if (has_val.find(n) == has_val.end())
ret_lines.insert(n);
return ret_lines;
} |
696578edb6799c9210cab65f5fbfdd0b8da461b9 | ff3c1cfaf467867e79b44cbcd1469c6f21154ded | /system/videobox/IPU/G1JDEC/G1JDEC.cpp | 56bf3f3ddaa897f96da0a15dfe30c0cd801fc522 | [] | no_license | trigrass2/buildroot-ltc | 6d493323c2b624727f26d9d38f21c02f78d661a9 | 31cf5593a5bb4de4608425886e93f4be628f87f4 | refs/heads/master | 2021-08-29T21:55:10.393171 | 2017-12-15T04:29:22 | 2017-12-15T04:29:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,910 | cpp | G1JDEC.cpp | /*
* Copyright (c) 2016~2021 ShangHai InfoTM Ltd 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.
*
* Description: Jpeg HardWare Decode
*
* Author:
* devin.zhu <devin.zhu@infotm.com>
*
* Revision History:
* -----------------
* 1.1 09/21/2017 init
*/
#include <System.h>
#include <qsdk/videobox.h>
#include "G1JDEC.h"
#define ALLOCBUFSIZE 0x80000
static char s_ps8FrBufName[32];
//#define DUMP
DYNAMIC_IPU(IPU_G1JDEC, "g1jdec");
IPU_G1JDEC::IPU_G1JDEC(std::string name, Json *js)
{
Name = name;
Mode = IPU_G1JDEC::Auto;
const char *pu8String = NULL;
if (NULL != js)
{
pu8String = js->GetString("mode");
if (pu8String != NULL && strncmp(pu8String, "trigger", 8) == 0)
{
Mode = IPU_G1JDEC::Trigger;
}
else
{
Mode = IPU_G1JDEC::Auto;
}
}
pIn = CreatePort("stream", Port::In);
pIn->SetPixelFormat(Pixel::Format::MJPEG);
pOut = CreatePort("frame", Port::Out);
pOut->SetRuntimePolicy(Port::RPType_Resolution, Port::RPolicy_Forbidden);
pOut->SetResolution(1920, 1088);
pOut->SetBufferType(FRBuffer::Type::FIXED, 3);
pOut->SetPixelFormat(Pixel::Format::NV12);
pOut->Export();
}
void IPU_G1JDEC::Prepare()
{
if (GetPort("stream")->GetPixelFormat() != Pixel::Format::MJPEG)
{
LOGE("stream Port Pixel Format Params Error Not Support\n");
throw VBERR_BADPARAM;
}
s32LumSize = 0;
s32ChromaSize = 0;
s32ResChange = 0;
s64FrameCount = 0;
bDecodeFinish = false;
bTrigger = false;
bPPEnble = false;
memset(&stJpegDecIn, 0, sizeof(JpegDecInput));
memset(&stJpegDecOut, 0, sizeof(JpegDecOutput));
memset(&stImageInfo, 0, sizeof(JpegDecImageInfo));
memset(&stJDecInBuffer, 0, sizeof(Buffer));
pJpegDecInst = NULL;
pPPInst = NULL;
stJDecInFRBuf = NULL;
stJDecOutFRBuf = NULL;
if (!pIn->IsBind())
{
sprintf(s_ps8FrBufName, "%s-stream", Name.c_str());
if (stJDecInFRBuf == NULL)
{
LOGE("alloc stJDecInFRBuf %s\n",s_ps8FrBufName);
stJDecInFRBuf = new FRBuffer(s_ps8FrBufName, FRBuffer::Type::FIXED_NODROP, 3, ALLOCBUFSIZE);
if (stJDecInFRBuf == NULL)
{
LOGE("Allocate jpeg decoder buffer (%s) fail!\n",s_ps8FrBufName);
return;
}
}
}
}
IPU_G1JDEC::~IPU_G1JDEC()
{
}
void IPU_G1JDEC::Unprepare()
{
if (pIn && pIn->IsEnabled())
{
pIn->FreeVirtualResource();
}
if (pOut && pOut->IsEnabled())
{
pOut->FreeVirtualResource();
}
if (pPPInst)
{
PPRelease(pPPInst);
pPPInst = NULL;
}
if (pJpegDecInst)
{
JpegDecRelease(pJpegDecInst);
pJpegDecInst = NULL;
}
if (stJDecInFRBuf)
{
delete stJDecInFRBuf;
stJDecInFRBuf = NULL;
}
}
void IPU_G1JDEC::WorkLoop()
{
while (IsInState(ST::Running))
{
bDecodeFinish = false;
if (Mode == IPU_G1JDEC::Trigger)
{
if (!bTrigger)
{
usleep(10 * 1000);
continue;
}
}
try
{
if (pIn->IsBind())
{
stBufferIn = pIn->GetBuffer(&stBufferIn);
}
else
{
stBufferIn = stJDecInFRBuf->GetReferenceBuffer(&stBufferIn);
}
}
catch(const char *ps8Error)
{
usleep(10 * 1000);
continue;
}
LOGD("FrameCount:%lld\n", s64FrameCount);
/*Hardware decoding*/
StartJpegDecode();
s64FrameCount++;
if (enJpegDecRet != JPEGDEC_OK)
{
LOGE("Jpeg decode fail! Ret(%d)\n",enJpegDecRet);
}
bDecodeFinish = true;
if (pIn->IsBind())
{
pIn->PutBuffer(&stBufferIn);
}
else
{
stJDecInFRBuf->PutReferenceBuffer(&stBufferIn);
}
bTrigger = false;
if (Mode == IPU_G1JDEC::Trigger)
{
LOGE("End trigger!\n");
}
}
}
JpegDecRet IPU_G1JDEC::StartJpegDecode()
{
int s32CombinedFlag = 0;
stBufferOut.fr_buf.virt_addr = NULL;
enJpegDecRet = JpegDecInit(&pJpegDecInst, NULL, 0);
if (enJpegDecRet != JPEGDEC_OK)
{
LOGE("Jpeg decoder init fail! %d\n",enJpegDecRet);
enJpegDecRet = JPEGDEC_ERROR;
goto error;
}
/*feed mjpeg data to decoder*/
stJDecInBuffer.virt_addr = stBufferIn.fr_buf.virt_addr;
stJDecInBuffer.phys_addr = stBufferIn.fr_buf.phys_addr;
stJDecInBuffer.size = stBufferIn.fr_buf.size;
stJpegDecIn.streamBuffer.pVirtualAddress = (u32 *)stJDecInBuffer.virt_addr;
stJpegDecIn.streamBuffer.busAddress = stJDecInBuffer.phys_addr;
stJpegDecIn.streamLength = stJDecInBuffer.size;
stJpegDecIn.bufferSize = 0;
/*get jpeg base info*/
enJpegDecRet = JpegDecGetImageInfo(pJpegDecInst, &stJpegDecIn, &stImageInfo);
if (enJpegDecRet == JPEGDEC_OK)
{
CalcSize();
LOGD("outImgW:%d outImgH:%d format:0x%x disImgW:%d disImgH:%d\n",
stImageInfo.outputWidth, stImageInfo.outputHeight, stImageInfo.outputFormat, stImageInfo.displayWidth, stImageInfo.displayHeight);
}
else
{
LOGE("Get Image Info fail!(%d)\n",enJpegDecRet);
enJpegDecRet = JPEGDEC_ERROR;
goto error;
}
stParamsIn.s32Width = stImageInfo.outputWidth;
stParamsIn.s32Height = stImageInfo.outputHeight;
stParamsIn.s32Format = stImageInfo.outputFormat;
switch(stParamsIn.s32Format)
{
case JPEGDEC_YCbCr422_SEMIPLANAR:
stParamsIn.s32Format = PP_PIX_FMT_YCBCR_4_2_2_SEMIPLANAR;
break;
case JPEGDEC_YCbCr420_SEMIPLANAR:
stParamsIn.s32Format = PP_PIX_FMT_YCBCR_4_2_0_SEMIPLANAR;
break;
default:
LOGE("format change need add\n");
//other format need support,here just support nv12 and yuv422
break;
}
stParamsOut.s32Width = pOut->GetWidth();
stParamsOut.s32Height = pOut->GetHeight();
stParamsOut.s32Format = pOut->GetPixelFormat();
switch(stParamsOut.s32Format)
{
case Pixel::Format::NV12:
stParamsOut.s32Format = PP_PIX_FMT_YCBCR_4_2_0_SEMIPLANAR;
break;
case Pixel::Format::YUV422SP:
stParamsOut.s32Format = PP_PIX_FMT_YCBCR_4_2_2_SEMIPLANAR;
break;
default:
LOGE("output format not support(%d)!\n", stParamsOut.s32Format);
enJpegDecRet = JPEGDEC_ERROR;
goto error;
}
if ((stParamsIn.s32Width != stParamsOut.s32Width ||
stParamsIn.s32Height != stParamsOut.s32Height ||
stParamsIn.s32Format != stParamsOut.s32Format) &&
stParamsOut.s32Width > 0 &&
stParamsOut.s32Height > 0)
{
bPPEnble = true;
}
else
{
bPPEnble = false;
}
if (bPPEnble)
{
switch(stParamsOut.s32Format)
{
case PP_PIX_FMT_YCBCR_4_2_0_SEMIPLANAR:
stParamsOut.s32LumSize = stParamsOut.s32Width*stParamsOut.s32Height;
stParamsOut.s32YUVSize = stParamsOut.s32LumSize*3/2;
break;
case PP_PIX_FMT_YCBCR_4_2_2_SEMIPLANAR:
stParamsOut.s32LumSize = stParamsOut.s32Width*stParamsOut.s32Height;
stParamsOut.s32YUVSize = stParamsOut.s32LumSize*2;
break;
default:
LOGE("output format not support(%d)!\n", stParamsOut.s32Format);
enJpegDecRet = JPEGDEC_ERROR;
goto error;
}
}
/* Decode Full Image */
stJpegDecIn.decImageType = JPEGDEC_IMAGE;
stJpegDecIn.sliceMbSet = 0;
stBufferOut = pOut->GetBuffer();
stBufferOut.SyncStamp(&stBufferIn);
/*pp pipeline*/
if (bPPEnble)
{
enPPDecRet = PPDecInit(&pPPInst);
if (enPPDecRet != PP_OK)
{
LOGE("PP init fail!(%d)\n",enPPDecRet);
enJpegDecRet = JPEGDEC_ERROR;
goto error;
}
enPPDecRet = PPDecCombinedModeEnable(pPPInst, pJpegDecInst, PP_PIPELINED_DEC_TYPE_JPEG);
if (enPPDecRet != PP_OK)
{
LOGE("Failed to enable PP-DEC pipeline: %d\n",enPPDecRet);
enJpegDecRet = JPEGDEC_ERROR;
goto error;
}
else
{
s32CombinedFlag = 1;
}
enPPDecRet = PPDecUpdateConfig();
if (enPPDecRet != PP_OK)
{
LOGE("PP update config fail!\n");
enJpegDecRet = JPEGDEC_ERROR;
goto error;
}
}
/*when jdec + pp pipeline disable,decoder will output*/
if (!bPPEnble)
{
stJpegDecIn.pictureBufferY.busAddress= stBufferOut.fr_buf.phys_addr;
stJpegDecIn.pictureBufferY.pVirtualAddress = (u32 *)(stBufferOut.fr_buf.virt_addr);
stJpegDecIn.pictureBufferCbCr.busAddress = stBufferOut.fr_buf.phys_addr + s32LumSize;
stJpegDecIn.pictureBufferCbCr.pVirtualAddress = (u32 *)((char *)stBufferOut.fr_buf.virt_addr + s32LumSize);
}
do
{
LOGD("start decode!\n");
enJpegDecRet = JpegDecDecode(pJpegDecInst, &stJpegDecIn, &stJpegDecOut);
LOGD("end decode!\n");
switch(enJpegDecRet)
{
case JPEGDEC_STRM_PROCESSED:
LOGD("Jdec stream processed!\n");
break;
case JPEGDEC_FRAME_READY:
LOGD("Jdec frame ready!\n");
break;
case JPEGDEC_SLICE_READY:
LOGD("Jdec slice ready!\n");
break;
case JPEGDEC_SCAN_PROCESSED:
LOGD("Jdec scan processed!\n");
break;
default:
LOGE("Jdec fail:%d\n",enJpegDecRet);
enJpegDecRet = JPEGDEC_ERROR;
goto error;
}
} while(enJpegDecRet != JPEGDEC_FRAME_READY);
enJpegDecRet = JPEGDEC_OK;
LOGD("YAdr:0x%x CbCrAdr:0x%x\n",stJpegDecOut.outputPictureY.pVirtualAddress, stJpegDecOut.outputPictureCbCr.pVirtualAddress);
if (bPPEnble)
{
enPPDecRet = PPGetResult(pPPInst);
if (enPPDecRet != PP_OK)
{
LOGE("pp process fail!(%d)\n",enPPDecRet);
}
#ifdef DUMP
WriteFile(stBufferOut.fr_buf.virt_addr, stParamsOut.s32YUVSize,"/mnt/sd0/G1Jdec_%d_%d_%lld.yuv",
pPPConf.ppOutImg.width, pPPConf.ppOutImg.height, s64FrameCount);
#endif
stBufferOut.fr_buf.size = stParamsOut.s32YUVSize;
stBufferOut.fr_buf.priv = 0;
}
else
{
stBufferOut.fr_buf.size = s32LumSize + s32ChromaSize;
stBufferOut.fr_buf.priv = 0;
}
if (s32ResChange)
{
stBufferOut.fr_buf.priv = VIDEO_FRAME_DUMMY;
stBufferOut.fr_buf.stAttr.s32Width = stImageInfo.outputWidth;
stBufferOut.fr_buf.stAttr.s32Height = stImageInfo.outputHeight;
}
else
{
stBufferOut.fr_buf.priv = 0;
}
error:
if (stBufferOut.fr_buf.virt_addr)
{
pOut->PutBuffer(&stBufferOut);
}
if (s32CombinedFlag)
{
enPPDecRet = PPDecCombinedModeDisable(pPPInst, pJpegDecInst);
}
if (pPPInst)
{
PPRelease(pPPInst);
pPPInst = NULL;
}
if (pJpegDecInst)
{
JpegDecRelease(pJpegDecInst);
pJpegDecInst = NULL;
}
return enJpegDecRet;
}
void IPU_G1JDEC::CalcSize()
{
int s32Size = 0;
s32Size = s32LumSize;
s32LumSize = (stImageInfo.outputWidth * stImageInfo.outputHeight);
LOGD("info.w:%d info.h:%d\n",stImageInfo.outputWidth, stImageInfo.outputHeight);
if (s32Size != s32LumSize)
{
LOGE("Jpeg size change!\n");
s32ResChange = 1;
}
else
{
s32ResChange = 0;
return;
}
if (stImageInfo.outputFormat!= JPEGDEC_YCbCr400)
{
if (stImageInfo.outputFormat == JPEGDEC_YCbCr420_SEMIPLANAR ||
stImageInfo.outputFormat == JPEGDEC_YCbCr411_SEMIPLANAR)
{
s32ChromaSize = (s32LumSize / 2);
}
else if (stImageInfo.outputFormat == JPEGDEC_YCbCr444_SEMIPLANAR)
{
s32ChromaSize = s32LumSize * 2;
}
else
{
s32ChromaSize = s32LumSize;
}
}
}
bool IPU_G1JDEC::DecodePhoto(bool* bEnable)
{
LOGE("Begin to decode:%d\n", *bEnable);
bTrigger = *bEnable;
return true;
}
bool IPU_G1JDEC::DecodeFinish(bool* bFinish)
{
*bFinish = bDecodeFinish;
if (bDecodeFinish)
{
bDecodeFinish = false;
}
return true;
}
PPResult IPU_G1JDEC::PPDecInit(PPInst *pPPInst)
{
if (pPPInst == NULL)
{
return PP_PARAM_ERROR;
}
enPPDecRet = PPInit(pPPInst, 0);
if (enPPDecRet != PP_OK)
{
LOGE("Failed to init the PP: %d\n",enPPDecRet);
*pPPInst = NULL;
return enPPDecRet;
}
return PP_OK;
}
PPResult IPU_G1JDEC::PPDecUpdateConfig()
{
enPPDecRet = PPGetConfig(pPPInst, &pPPConf);
if (enPPDecRet != PP_OK)
{
LOGE("Get pp config fail!\n");
return enPPDecRet;
}
pPPConf.ppInImg.width = stParamsIn.s32Width;
pPPConf.ppInImg.height = stParamsIn.s32Height;
pPPConf.ppInImg.pixFormat = stParamsIn.s32Format;
pPPConf.ppInImg.videoRange = 1;
pPPConf.ppOutImg.width = stParamsOut.s32Width;
pPPConf.ppOutImg.height = stParamsOut.s32Height;
pPPConf.ppOutImg.pixFormat = stParamsOut.s32Format;
pPPConf.ppOutImg.bufferBusAddr = stBufferOut.fr_buf.phys_addr;
pPPConf.ppOutImg.bufferChromaBusAddr = stBufferOut.fr_buf.phys_addr + stParamsOut.s32LumSize;
LOGD("pPPConf.ppInImg.width:%d pPPConf.ppInImg.height:%d pPPConf.ppInImg.pixFormat:0x%x\n",
pPPConf.ppInImg.width, pPPConf.ppInImg.height, pPPConf.ppInImg.pixFormat);
LOGD("pPPConf.ppOutImg.width:%d pPPConf.ppOutImg.height:%d pPPConf.ppOutImg.pixFormat:0x%x\n",
pPPConf.ppOutImg.width, pPPConf.ppOutImg.height, pPPConf.ppOutImg.pixFormat);
enPPDecRet = PPSetConfig(pPPInst, &pPPConf);
if (enPPDecRet != PP_OK)
{
LOGE("PPSetConfig failed while process an image :%d\n", enPPDecRet);
return enPPDecRet;
}
return PP_OK;
}
|
f86d90686603985e21be65d6f248eeb8f4a56d11 | ff9efbebfbd4e4bdb1ab0ff4033aa785d5bfe853 | /d04/ex03/AMateria.hpp | 647fedb97db1c9805025a71e4f12a9079090dd45 | [] | no_license | ViictorD/42-piscine_cpp | df4bbf9f3f7f81f31bc66498b0d95ed89dd69695 | 3c69ccd0b6f43c2316b6abfe4c59293b22d45d4f | refs/heads/master | 2022-11-28T22:52:15.780639 | 2019-05-13T15:40:59 | 2019-05-13T15:40:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 496 | hpp | AMateria.hpp | #ifndef AMATERIA_H
# define AMATERIA_H
# include <string>
# include <iostream>
# include "ICharacter.hpp"
class AMateria
{
private:
std::string _type;
unsigned int xp_;
AMateria(void);
public:
AMateria(std::string const & type);
AMateria(AMateria const &src);
virtual ~AMateria();
AMateria &operator=(AMateria const &rhs);
std::string const & getType() const;
unsigned int getXP() const;
virtual AMateria* clone() const = 0;
virtual void use(ICharacter &target);
};
#endif
|
cc8f0b93326c9374ff844475e7e9ef6867ac43fe | 580547141fea058c70e2069828bb43d4e98018e6 | /fenetreprincipal.h | 6c6b23b21f9472f9bacd80b51e043d778012dc52 | [] | no_license | MohamedHalim-A/GUI_QuestionAnswer | e8a94568bbe916fa013ef8144a8719bd736cc23d | c235f20b433ad1c18b2c74adc9acc31d3784b2d6 | refs/heads/master | 2022-11-08T17:01:25.483619 | 2020-06-15T01:13:53 | 2020-06-15T01:13:53 | 272,312,517 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 276 | h | fenetreprincipal.h | #ifndef FENETREPRINCIPAL_H
#define FENETREPRINCIPAL_H
#include <QMainWindow>
#include "modelgeneral.h"
class fenetrePrincipal : public QMainWindow
{
Q_OBJECT
public:
explicit fenetrePrincipal(QWidget *parent = nullptr);
signals:
};
#endif // FENETREPRINCIPAL_H
|
fc6f8dcb62d5b1db1d2a971f65c6ab4d7a80829f | 8862c89bb5d575653a6d07f27f1b29bd118cb22c | /src/modules/DepositionPointCharge/DepositionPointChargeModule.cpp | 2c1cdd6307c86aa3d3ace7567e5b794182ec959a | [
"CC-BY-4.0",
"MIT",
"BSD-3-Clause",
"BSL-1.0"
] | permissive | simonspa/allpix-squared | c1e475e2ba9d6de83a5006a1e526ea6403fd5ca2 | 62242b5c5b39a418309b7d2efb6336ff47d1b4d2 | refs/heads/master | 2021-06-05T16:01:31.969564 | 2020-02-28T11:40:57 | 2020-02-28T11:40:57 | 104,188,159 | 7 | 4 | MIT | 2021-12-03T03:31:33 | 2017-09-20T08:30:26 | C++ | UTF-8 | C++ | false | false | 10,999 | cpp | DepositionPointChargeModule.cpp | /**
* @file
* @brief Implementation of a module to deposit charges at a specific point
* @copyright Copyright (c) 2017-2020 CERN and the Allpix Squared authors.
* This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md".
* In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an
* Intergovernmental Organization or submit itself to any jurisdiction.
*/
#include "DepositionPointChargeModule.hpp"
#include <cmath>
#include <string>
#include <utility>
#include "core/messenger/Messenger.hpp"
#include "core/utils/log.h"
#include "objects/DepositedCharge.hpp"
#include "objects/MCParticle.hpp"
using namespace allpix;
DepositionPointChargeModule::DepositionPointChargeModule(Configuration& config,
Messenger* messenger,
std::shared_ptr<Detector> detector)
: Module(config, detector), detector_(std::move(detector)), messenger_(messenger) {
// Seed the random generator with the global seed
random_generator_.seed(getRandomSeed());
// Set default value for the number of charges deposited
config_.setDefault("number_of_charges", 1);
config_.setDefault("number_of_steps", 100);
config_.setDefault("position", ROOT::Math::XYZPoint(0., 0., 0.));
config_.setDefault("source_type", "point");
config_.setDefault("model", "fixed");
// Read type:
auto type = config_.get<std::string>("source_type");
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
if(type == "point") {
type_ = SourceType::POINT;
} else if(type == "mip") {
type_ = SourceType::MIP;
} else {
throw InvalidValueError(config_, "source_type", "Invalid deposition type, only 'point' and 'mip' are supported.");
}
// Read model
auto model = config_.get<std::string>("model");
std::transform(model.begin(), model.end(), model.begin(), ::tolower);
if(model == "fixed") {
model_ = DepositionModel::FIXED;
} else if(model == "scan") {
model_ = DepositionModel::SCAN;
} else if(model == "spot") {
model_ = DepositionModel::SPOT;
spot_size_ = config.get<double>("spot_size");
} else {
throw InvalidValueError(
config_, "model", "Invalid deposition model, only 'fixed', 'scan' and 'spot' are supported.");
}
}
void DepositionPointChargeModule::init() {
auto model = detector_->getModel();
// Set up the different source types
if(type_ == SourceType::MIP) {
// Calculate voxel size:
auto granularity = config_.get<unsigned int>("number_of_steps");
voxel_ = ROOT::Math::XYZVector(0, 0, model->getSensorSize().z() / granularity);
// We should deposit the equivalent of about 80 e/h pairs per micro meter (80`000 per mm):
carriers_ = static_cast<unsigned int>(80000 * voxel_.z());
LOG(INFO) << "Step size for MIP energy deposition: " << Units::display(voxel_.z(), {"um", "mm"}) << ", depositing "
<< carriers_ << " e/h pairs per step";
} else {
carriers_ = config_.get<unsigned int>("number_of_charges");
}
// Set up the different scan methods
if(model_ == DepositionModel::SCAN) {
// Get the config manager and retrieve total number of events:
ConfigManager* conf_manager = getConfigManager();
auto events = conf_manager->getGlobalConfiguration().get<unsigned int>("number_of_events");
// Scan with points required 3D scanning, scan with MIPs only 2D:
if(type_ == SourceType::MIP) {
root_ = static_cast<unsigned int>(std::round(std::sqrt(events)));
if(events != root_ * root_) {
LOG(WARNING) << "Number of events is not a square, pixel cell volume cannot fully be covered in scan. "
<< "Closest square is " << root_ * root_;
}
// Calculate voxel size:
voxel_ = ROOT::Math::XYZVector(
model->getPixelSize().x() / root_, model->getPixelSize().y() / root_, model->getSensorSize().z());
} else {
root_ = static_cast<unsigned int>(std::round(std::cbrt(events)));
if(events != root_ * root_ * root_) {
LOG(WARNING) << "Number of events is not a cube, pixel cell volume cannot fully be covered in scan. "
<< "Closest cube is " << root_ * root_ * root_;
}
// Calculate voxel size:
voxel_ = ROOT::Math::XYZVector(
model->getPixelSize().x() / root_, model->getPixelSize().y() / root_, model->getSensorSize().z() / root_);
}
LOG(INFO) << "Voxel size for scan of pixel volume: " << Units::display(voxel_, {"um", "mm"});
}
}
void DepositionPointChargeModule::run(unsigned int event) {
ROOT::Math::XYZPoint position;
auto model = detector_->getModel();
auto get_position = [&]() {
if(config_.getArray<double>("position").size() == 2) {
auto tmp_pos = config_.get<ROOT::Math::XYPoint>("position");
return ROOT::Math::XYZPoint(tmp_pos.x(), tmp_pos.y(), 0);
} else {
return config_.get<ROOT::Math::XYZPoint>("position");
}
};
if(model_ == DepositionModel::FIXED) {
// Fixed position as read from the configuration:
position = get_position();
} else if(model_ == DepositionModel::SCAN) {
// Center the volume to be scanned in the center of the sensor,
// reference point is lower left corner of one pixel volume
auto ref =
model->getGridSize() / 2.0 -
ROOT::Math::XYZVector(model->getPixelSize().x(), model->getPixelSize().y(), model->getSensorSize().z() / 2.0);
LOG(DEBUG) << "Reference: " << ref;
position = ROOT::Math::XYZPoint(voxel_.x() * ((event - 1) % root_),
voxel_.y() * (((event - 1) / root_) % root_),
voxel_.z() * (((event - 1) / root_ / root_) % root_)) +
ref;
} else {
// Calculate random offset from configured position
auto shift = [&](auto size) {
double dx = std::normal_distribution<double>(0, size)(random_generator_);
double dy = std::normal_distribution<double>(0, size)(random_generator_);
double dz = std::normal_distribution<double>(0, size)(random_generator_);
return ROOT::Math::XYZVector(dx, dy, dz);
};
// Spot around the configured position
position = get_position() + shift(config_.get<double>("spot_size"));
}
// Create charge carriers at requested position
if(type_ == SourceType::MIP) {
DepositLine(position);
} else {
DepositPoint(position);
}
}
void DepositionPointChargeModule::DepositPoint(const ROOT::Math::XYZPoint& position) {
// Vector of deposited charges and their "MCParticle"
std::vector<DepositedCharge> charges;
std::vector<MCParticle> mcparticles;
LOG(DEBUG) << "Position (local coordinates): " << Units::display(position, {"um", "mm"});
// Cross-check calculated position to be within sensor:
if(!detector_->isWithinSensor(position)) {
LOG(DEBUG) << "Requested position is outside active sensor volume.";
return;
}
auto position_global = detector_->getGlobalPosition(position);
// Start and stop position is the same for the MCParticle
mcparticles.emplace_back(position, position_global, position, position_global, -1, 0.);
LOG(DEBUG) << "Generated MCParticle at global position " << Units::display(position_global, {"um", "mm"})
<< " in detector " << detector_->getName();
charges.emplace_back(position, position_global, CarrierType::ELECTRON, carriers_, 0., &(mcparticles.back()));
charges.emplace_back(position, position_global, CarrierType::HOLE, carriers_, 0., &(mcparticles.back()));
LOG(DEBUG) << "Deposited " << carriers_ << " charge carriers of both types at global position "
<< Units::display(position_global, {"um", "mm"}) << " in detector " << detector_->getName();
// Dispatch the messages to the framework
auto deposit_message = std::make_shared<DepositedChargeMessage>(std::move(charges), detector_);
auto mcparticle_message = std::make_shared<MCParticleMessage>(std::move(mcparticles), detector_);
messenger_->dispatchMessage(this, deposit_message);
messenger_->dispatchMessage(this, mcparticle_message);
}
void DepositionPointChargeModule::DepositLine(const ROOT::Math::XYZPoint& position) {
auto model = detector_->getModel();
// Vector of deposited charges and their "MCParticle"
std::vector<DepositedCharge> charges;
std::vector<MCParticle> mcparticles;
// Cross-check calculated position to be within sensor:
if(!detector_->isWithinSensor(ROOT::Math::XYZPoint(position.x(), position.y(), 0))) {
LOG(DEBUG) << "Requested position is outside active sensor volume.";
return;
}
// Start and end position of MCParticle:
auto start_local = ROOT::Math::XYZPoint(position.x(), position.y(), -model->getSensorSize().z() / 2.0);
auto end_local = ROOT::Math::XYZPoint(position.x(), position.y(), model->getSensorSize().z() / 2.0);
auto start_global = detector_->getGlobalPosition(start_local);
auto end_global = detector_->getGlobalPosition(end_local);
// Create MCParticle:
mcparticles.emplace_back(start_local, start_global, end_local, end_global, -1, 0.);
LOG(DEBUG) << "Generated MCParticle with start " << Units::display(start_global, {"um", "mm"}) << " and end "
<< Units::display(end_global, {"um", "mm"}) << " in detector " << detector_->getName();
// Deposit the charge carriers:
auto position_local = start_local;
while(position_local.z() < model->getSensorSize().z() / 2.0) {
position_local += voxel_;
auto position_global = detector_->getGlobalPosition(position_local);
charges.emplace_back(position_local, position_global, CarrierType::ELECTRON, carriers_, 0., &(mcparticles.back()));
charges.emplace_back(position_local, position_global, CarrierType::HOLE, carriers_, 0., &(mcparticles.back()));
LOG(TRACE) << "Deposited " << carriers_ << " charge carriers of both types at global position "
<< Units::display(position_global, {"um", "mm"}) << " in detector " << detector_->getName();
}
// Dispatch the messages to the framework
auto deposit_message = std::make_shared<DepositedChargeMessage>(std::move(charges), detector_);
auto mcparticle_message = std::make_shared<MCParticleMessage>(std::move(mcparticles), detector_);
messenger_->dispatchMessage(this, deposit_message);
messenger_->dispatchMessage(this, mcparticle_message);
}
|
db40e2de3abf2154aea7dbf05a1e396460fd0eea | d7085a2924fb839285146f88518c69c567e77968 | /KS/SRC/ks/dxt1_codebook.h | 3f650176d66744c9a3707c01515e83bda9bc3b5e | [] | no_license | historicalsource/kelly-slaters-pro-surfer | 540f8f39c07e881e9ecebc764954c3579903ad85 | 7c3ade041cc03409a3114ce3ba4a70053c6e4e3b | refs/heads/main | 2023-07-04T09:34:09.267099 | 2021-07-29T19:35:13 | 2021-07-29T19:35:13 | 390,831,183 | 40 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,324 | h | dxt1_codebook.h |
#ifndef INCLUDED_DXT1_CODEBOOK_H
#define INCLUDED_DXT1_CODEBOOK_H
#include "global.h"
#include "dxt1_table.h"
class cbVector
{
private:
unsigned char pData[4];
public:
cbVector() {;}
~cbVector() {;}
inline unsigned char *GetPtr(void) {return pData;}
inline unsigned char &operator[](int i) {return pData[i];}
cbVector &operator=(const cbVector & Vect) {*(int *)pData = *(int *)Vect.pData; return *this;}
int operator==(cbVector &Vect) {return *(int *)pData == *(int *)Vect.pData;}
int DiffMag(const cbVector & Vect) const; // Magnitude of the difference between this and Vect (Dist ^ 2)
friend class CodeBook;
};
class CodeBook
{
private:
Table<cbVector> VectList;
Table<int> usageCount;
public:
virtual ~CodeBook() {;}
void AddVector(cbVector &Vect);
inline void SetSize(int Size) {VectList.Resize(Size); usageCount.Resize(Size);}
inline void SetCount(int Count) {VectList.SetCount(Count); usageCount.SetCount(Count);}
int FindVectorSlow(const cbVector &Vect);
int UsageCount(const int i) { return usageCount[i]; }
inline int GetNumCodes(void) const { return VectList.Count(); }
cbVector &operator[](const int i) { return VectList[i]; }
//const cbVector & operator[](const int i) { return VectList[i]; }
};
#endif INCLUDED_DXT1_CODEBOOK_H |
809f57c63107535e3a9fcad1f8d866abd4c9e5d0 | a6376e1ada58384cdc0065ce5a4a96728e84f04f | /SDK/include/modules/base/processors/utility/metadataextractor.cpp | 9721e50cee871fc6242fc019d8c6c2f8a867a7e4 | [] | no_license | widVE/Voreen | be02bac44896e869a6af083c61729d5e154c28f1 | c8a5c66f15d31f8177eeceefa19358f905870441 | refs/heads/master | 2021-08-17T23:46:19.556383 | 2020-06-22T20:21:11 | 2020-06-22T20:21:11 | 196,454,037 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,598 | cpp | metadataextractor.cpp | /***********************************************************************************
* *
* Voreen - The Volume Rendering Engine *
* *
* Copyright (C) 2005-2013 University of Muenster, Germany. *
* Visualization and Computer Graphics Group <http://viscg.uni-muenster.de> *
* For a list of authors please refer to the file "CREDITS.txt". *
* *
* This file is part of the Voreen software package. Voreen is free software: *
* you can redistribute it and/or modify it under the terms of the GNU General *
* Public License version 2 as published by the Free Software Foundation. *
* *
* Voreen 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 in the file *
* "LICENSE.txt" along with this file. If not, see <http://www.gnu.org/licenses/>. *
* *
* For non-commercial academic use see the license exception specified in the file *
* "LICENSE-academic.txt". To get information about commercial licensing please *
* contact the authors. *
* *
***********************************************************************************/
#include "metadataextractor.h"
#include "voreen/core/utils/stringutils.h"
using std::string;
using std::vector;
namespace voreen {
const std::string MetaDataExtractor::loggerCat_("voreen.base.MetaDataExtractor");
MetaDataExtractor::MetaDataExtractor()
: Processor(),
inport_(Port::INPORT, "volume.inport", "Volume Input"),
outport_(Port::OUTPORT, "text", "Text Output", false),
expressionProperty_("expression", "Expression"),
dumpButtonProperty_("dumpButton", "Dump to Console", VALID),
updateButtonProperty_("updateButton", "Update Meta Data List", VALID)
{
addPort(inport_);
addPort(outport_);
addProperty(expressionProperty_);
dumpButtonProperty_.onChange(CallMemberAction<MetaDataExtractor>(this,&MetaDataExtractor::dumpToConsole));
addProperty(dumpButtonProperty_);
updateButtonProperty_.onChange(CallMemberAction<MetaDataExtractor>(this,&MetaDataExtractor::updateMetaDataList));
addProperty(updateButtonProperty_);
}
Processor* MetaDataExtractor::create() const {
return new MetaDataExtractor();
}
bool MetaDataExtractor::isReady() const {
if (!isInitialized())
return false;
return true;
}
void MetaDataExtractor::process() {
std::stringstream output;
updateMetaDataList();
if (inport_.isReady())
output << replaceMetaDataAndGetString();
//this is a workaround for graphics problems when rendering empty lines...
vector<string> lines = strSplit(output.str(),'\n');
vector<string>::iterator iter;
for (iter = lines.begin(); iter != lines.end(); ++iter) {
if (*iter == "")
iter->append(" ");
}
string result = strJoin(lines, "\n");
if (outport_.isReady())
outport_.setData(result);
}
void MetaDataExtractor::dumpToConsole() {
if (inport_.isReady()) {
LINFO("Console Dump:\n" + replaceMetaDataAndGetString());
}
else
LWARNING("Cannot dump to console: volume.inport not ready!");
}
void MetaDataExtractor::updateMetaDataList() {
//erase the items of the StringExpressionProperty
expressionProperty_.eraseItems();
if (inport_.isReady()) {
//add some data contained in the volume
//bits per voxel
expressionProperty_.addPlaceHolder("Bits per Voxel", expressionProperty_.makePlaceHolder("volBitsPerVoxel"));
//dimensions
expressionProperty_.addPlaceHolder("Volume Dimensions", expressionProperty_.makePlaceHolder("volDimensions"));
//memory size
expressionProperty_.addPlaceHolder("Volume Memory Size", expressionProperty_.makePlaceHolder("volMemSize"));
//number of voxels
expressionProperty_.addPlaceHolder("Number of Voxels", expressionProperty_.makePlaceHolder("volNumVoxels"));
//path to the volume
expressionProperty_.addPlaceHolder("Path to Volume", expressionProperty_.makePlaceHolder("volPath"));
//get all Meta Data keys and add corresponding items to the StringExpressionProptery
vector<string> keys = inport_.getData()->getMetaDataKeys();
vector<string>::const_iterator iter;
for (iter = keys.begin(); iter != keys.end(); ++iter) {
expressionProperty_.addPlaceHolder(*iter, expressionProperty_.makePlaceHolder(*iter));
}
}
}
std::string MetaDataExtractor::replaceMetaDataAndGetString() const {
std::stringstream output;
//get the Meta Data keys to be replaced
std::set<string> placeholders = expressionProperty_.getPlaceholdersInText();
//construct replacement map for these keys
std::map<string, string> replacements;
//add the volume information not contained in meta data
std::stringstream dim;
dim << inport_.getData()->getDimensions();
replacements.insert(std::make_pair("volDimensions", dim.str()));
replacements.insert(std::make_pair("volBitsPerVoxel", itos(inport_.getData()->getBytesPerVoxel() * 8)));
replacements.insert(std::make_pair("volNumVoxels", itos(inport_.getData()->getNumVoxels())));
replacements.insert(std::make_pair("volPath", inport_.getData()->getOrigin().getPath()));
replacements.insert(std::make_pair("volFilename", inport_.getData()->getOrigin().getFilename()));
replacements.insert(std::make_pair("volBasename", tgt::FileSystem::baseName(inport_.getData()->getOrigin().getPath())));
//memory size
std::stringstream memSize;
size_t bytes = inport_.getData()->getBytesPerVoxel()*inport_.getData()->getNumVoxels();
float mb = tgt::round(bytes/104857.6f) / 10.f; //calculate mb with 0.1f precision
float kb = tgt::round(bytes/102.4f) / 10.f;
if (mb >= 0.5f) {
memSize << mb << " MB";
}
else if (kb >= 0.5f) {
memSize << kb << " kB";
}
else {
memSize << bytes << " bytes";
}
replacements.insert(std::make_pair("volMemSize", memSize.str()));
//iterate over placeholders to add relevant meta data to the map
std::set<string>::const_iterator i;
for (i = placeholders.begin(); i != placeholders.end(); ++i) {
//check if dot operator is used
if (i->find(".") == string::npos) {
const MetaDataBase* m = inport_.getData()->getMetaData(*i);
if (m) {
//found MetaData -> add std::string representation to map
replacements.insert(std::make_pair(*i, trim(m->toString())));
}
}
else {
//use of dot operator: split the string, get the MetaData and call component-wise toString-method
size_t position = i->find(".");
const MetaDataBase* m = inport_.getData()->getMetaData(i->substr(0,position));
if (m) {
//found MetaData -> add std::string representation with component argument to map
replacements.insert(std::make_pair(*i, trim(m->toString(i->substr(position+1)))));
}
//check for Volume Dimensions (not MetaData, but may be queried component-wise
if (i->substr(0,position) == "volDimensions") {
if (i->substr(position+1) == "x")
replacements.insert(std::make_pair(*i, itos(inport_.getData()->getDimensions().x)));
else if (i->substr(position+1) == "y")
replacements.insert(std::make_pair(*i, itos(inport_.getData()->getDimensions().y)));
else if (i->substr(position+1) == "z")
replacements.insert(std::make_pair(*i, itos(inport_.getData()->getDimensions().z)));
else
replacements.insert(std::make_pair(*i, dim.str()));
}
//check for Memory Size
if (i->substr(0,position) == "volMemSize") {
if (i->substr(position+1) == "B")
replacements.insert(std::make_pair(*i, itos(bytes)));
else if (i->substr(position+1) == "kB")
replacements.insert(std::make_pair(*i, ftos(kb)));
else if (i->substr(position+1) == "MB")
replacements.insert(std::make_pair(*i, ftos(mb)));
else
replacements.insert(std::make_pair(*i, memSize.str()));
}
}
}
output << expressionProperty_.replacePlaceHoldersInText(replacements);
return output.str();
}
} // namespace
|
3489fedd0c2c1303a8b8e3d82ceadd9c46b6f3a2 | 805fb697a151db0da2c84990972377eb1ea8fbc3 | /Ulam_Week_3/code/.gen/include/Ue_10188Stretchy10.tcc | 0cca508129348f1f226bd555ac5c8f3dd70f23bf | [] | no_license | bmatthews1/Ulam_Development | fc3a6e0ae7fdce3b1eb8338e323dc2dd005837ef | 3b22496159fc55075cfc7ef147bd801bf863a4fc | refs/heads/master | 2021-01-20T09:45:11.906552 | 2017-10-02T02:39:11 | 2017-10-02T02:39:11 | 101,605,409 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 22,018 | tcc | Ue_10188Stretchy10.tcc | /** -*- mode:C++ -*- */
//Include other classes: //gcnl:SymbolTableOfClasses.cpp:556
#include "Uq_10106UrSelf10.h"
#include "Uq_10109211EventWindow10.h"
#include "Ue_10105Empty10.h"
#include "Uq_1010919AtomUtils10.h"
namespace MFM{
template<class EC>
Ue_10188Stretchy10<EC>::Ue_10188Stretchy10() : UlamElement<EC>(MFM_UUID_FOR("Ue10188Stretchy10", 0))
{
//XXXX Element<EC>::SetAtomicSymbol("S"); // figure this out later
Element<EC>::SetName("Stretchy"); //gcnl:NodeBlockClass.cpp:1728
}
template<class EC>
Ue_10188Stretchy10<EC>::~Ue_10188Stretchy10(){} //gcnl:NodeBlockClass.cpp:1743
//! Stretchy.ulam:15: Void behave() {
template<class EC>
void Ue_10188Stretchy10<EC>::Uf_6behave(const UlamContext<EC>& uc, UlamRef<EC>& ur)
{
//! Stretchy.ulam:16: Byte neighbors = 0;
const u32 Uh_5tlreg3755 = 0; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3756 = _Int32ToUnsigned32(Uh_5tlreg3755, 2, 8); //gcnl:NodeCast.cpp:748
Ui_Ut_10181u<EC> Uv_919neighbors(Uh_5tlreg3756); //gcnl:NodeVarDecl.cpp:1081
//! Stretchy.ulam:17: Byte adjacent = 0;
const u32 Uh_5tlreg3757 = 0; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3758 = _Int32ToUnsigned32(Uh_5tlreg3757, 2, 8); //gcnl:NodeCast.cpp:748
Ui_Ut_10181u<EC> Uv_8adjacent(Uh_5tlreg3758); //gcnl:NodeVarDecl.cpp:1081
//! Stretchy.ulam:18: Byte tempAdjacent = 0;
const u32 Uh_5tlreg3759 = 0; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3760 = _Int32ToUnsigned32(Uh_5tlreg3759, 2, 8); //gcnl:NodeCast.cpp:748
Ui_Ut_10181u<EC> Uv_9212tempAdjacent(Uh_5tlreg3760); //gcnl:NodeVarDecl.cpp:1081
//! Stretchy.ulam:20: for (SiteNumber i = 1; i < 41; i++){
{
//! Stretchy.ulam:20: for (SiteNumber i = 1; i < 41; i++){
const u32 Uh_5tlreg3761 = 1; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3762 = _Int32ToUnsigned32(Uh_5tlreg3761, 2, 6); //gcnl:NodeCast.cpp:748
Ui_Ut_10161u<EC> Uv_1i(Uh_5tlreg3762); //gcnl:NodeVarDecl.cpp:1081
//! Stretchy.ulam:20: for (SiteNumber i = 1; i < 41; i++){
while(true)
{
const u32 Uh_5tlreg3763 = 41; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3765 = Uv_1i.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3766 = _Unsigned32ToInt32(Uh_5tlreg3765, 6, 7); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3767 = _BinOpCompareLessThanInt32(Uh_5tlreg3766, Uh_5tlreg3763, 7); //gcnl:NodeBinaryOpCompare.cpp:441
if(!_Bool32ToCbool(Uh_5tlreg3767, 1))
break; //gcnl:NodeControlWhile.cpp:135
//! Stretchy.ulam:20: for (SiteNumber i = 1; i < 41; i++){
{
//! Stretchy.ulam:21: if (ew[i] is Stretchy){
{
//! Stretchy.ulam:21: if (ew[i] is Stretchy){
UlamRef<EC> Uh_3tur3769(ur, 0u, 0u, &Uq_10109211EventWindow10<EC>::THE_INSTANCE, UlamRef<EC>::CLASSIC); //gcnl:NodeFunctionCall.cpp:960
const u32 Uh_5tlreg3771 = Uv_1i.read(); //gcnl:Node.cpp:698
Ui_Ut_10161u<EC> Uh_5tlval3772(Uh_5tlreg3771); //gcnl:Node.cpp:1142
Ui_Ut_r102961a<EC> Uh_5tuval3774 = Uq_10109211EventWindow10<EC>::THE_INSTANCE.Uf_4aref(uc, Uh_3tur3769, Uh_5tlval3772); //gcnl:NodeFunctionCall.cpp:1043
const u32 Uh_5tlreg3775 = Ue_10188Stretchy10<EC>::THE_INSTANCE.internalCMethodImplementingIs(Uh_5tuval3774.read()); //gcnl:NodeConditionalIs.cpp:285
if(_Bool32ToCbool(Uh_5tlreg3775, 1)) //gcnl:NodeControl.cpp:213
{
{
//! Stretchy.ulam:22: neighbors++;
const u32 Uh_5tlreg3776 = 1; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3777 = _Int32ToUnsigned32(Uh_5tlreg3776, 32, 8); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3779 = Uv_919neighbors.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3780 = _BinOpAddUnsigned32(Uh_5tlreg3779, Uh_5tlreg3777, 8); //gcnl:NodeBinaryOpEqualArithPostIncr.cpp:196
Uv_919neighbors.write(Uh_5tlreg3780); //gcnl:Node.cpp:892
}
} // end if
}
}
//! Stretchy.ulam:20: for (SiteNumber i = 1; i < 41; i++){
Ul_214endcontrolloop12:
__attribute__((__unused__)); //gcnl:NodeLabel.cpp:68
//! Stretchy.ulam:20: for (SiteNumber i = 1; i < 41; i++){
const u32 Uh_5tlreg3781 = 1; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3782 = _Int32ToUnsigned32(Uh_5tlreg3781, 32, 6); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3784 = Uv_1i.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3785 = _BinOpAddUnsigned32(Uh_5tlreg3784, Uh_5tlreg3782, 6); //gcnl:NodeBinaryOpEqualArithPostIncr.cpp:196
Uv_1i.write(Uh_5tlreg3785); //gcnl:Node.cpp:892
} // end while //gcnl:NodeControlWhile.cpp:145
}
//! Stretchy.ulam:26: for (SiteNumber i = 0; i < 16; i++){
{
//! Stretchy.ulam:26: for (SiteNumber i = 0; i < 16; i++){
const u32 Uh_5tlreg3786 = 0; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3787 = _Int32ToUnsigned32(Uh_5tlreg3786, 2, 6); //gcnl:NodeCast.cpp:748
Ui_Ut_10161u<EC> Uv_1i(Uh_5tlreg3787); //gcnl:NodeVarDecl.cpp:1081
//! Stretchy.ulam:26: for (SiteNumber i = 0; i < 16; i++){
while(true)
{
const u32 Uh_5tlreg3788 = 16; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3789 = _Int32ToInt32(Uh_5tlreg3788, 6, 7); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3791 = Uv_1i.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3792 = _Unsigned32ToInt32(Uh_5tlreg3791, 6, 7); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3793 = _BinOpCompareLessThanInt32(Uh_5tlreg3792, Uh_5tlreg3789, 7); //gcnl:NodeBinaryOpCompare.cpp:441
if(!_Bool32ToCbool(Uh_5tlreg3793, 1))
break; //gcnl:NodeControlWhile.cpp:135
//! Stretchy.ulam:26: for (SiteNumber i = 0; i < 16; i++){
{
//! Stretchy.ulam:27: if (ew[(SiteNumber)((i%8u) + 1u)] is Stretchy){
{
//! Stretchy.ulam:27: if (ew[(SiteNumber)((i%8u) + 1u)] is Stretchy){
UlamRef<EC> Uh_3tur3795(ur, 0u, 0u, &Uq_10109211EventWindow10<EC>::THE_INSTANCE, UlamRef<EC>::CLASSIC); //gcnl:NodeFunctionCall.cpp:960
const u32 Uh_5tlreg3796 = 1u; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3797 = _Unsigned32ToUnsigned32(Uh_5tlreg3796, 1, 7); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3798 = 8u; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3799 = _Unsigned32ToUnsigned32(Uh_5tlreg3798, 4, 6); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3801 = Uv_1i.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3802 = _BinOpModUnsigned32(Uh_5tlreg3801, Uh_5tlreg3799, 6); //gcnl:NodeBinaryOp.cpp:805
const u32 Uh_5tlreg3803 = _Unsigned32ToUnsigned32(Uh_5tlreg3802, 6, 4); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3804 = _Unsigned32ToUnsigned32(Uh_5tlreg3803, 4, 7); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3805 = _BinOpAddUnsigned32(Uh_5tlreg3804, Uh_5tlreg3797, 7); //gcnl:NodeBinaryOp.cpp:805
const u32 Uh_5tlreg3806 = _Unsigned32ToUnsigned32(Uh_5tlreg3805, 7, 6); //gcnl:NodeCast.cpp:748
Ui_Ut_10161u<EC> Uh_5tlval3807(Uh_5tlreg3806); //gcnl:Node.cpp:1142
Ui_Ut_r102961a<EC> Uh_5tuval3809 = Uq_10109211EventWindow10<EC>::THE_INSTANCE.Uf_4aref(uc, Uh_3tur3795, Uh_5tlval3807); //gcnl:NodeFunctionCall.cpp:1043
const u32 Uh_5tlreg3810 = Ue_10188Stretchy10<EC>::THE_INSTANCE.internalCMethodImplementingIs(Uh_5tuval3809.read()); //gcnl:NodeConditionalIs.cpp:285
if(_Bool32ToCbool(Uh_5tlreg3810, 1)) //gcnl:NodeControl.cpp:213
{
{
//! Stretchy.ulam:28: tempAdjacent++;
const u32 Uh_5tlreg3811 = 1; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3812 = _Int32ToUnsigned32(Uh_5tlreg3811, 32, 8); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3814 = Uv_9212tempAdjacent.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3815 = _BinOpAddUnsigned32(Uh_5tlreg3814, Uh_5tlreg3812, 8); //gcnl:NodeBinaryOpEqualArithPostIncr.cpp:196
Uv_9212tempAdjacent.write(Uh_5tlreg3815); //gcnl:Node.cpp:892
}
} // end if
else
{
{
//! Stretchy.ulam:31: if (tempAdjacent > adjacent) adjacent = tempAdjacent;
{
//! Stretchy.ulam:31: if (tempAdjacent > adjacent) adjacent = tempAdjacent;
const u32 Uh_5tlreg3817 = Uv_8adjacent.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3819 = Uv_9212tempAdjacent.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3820 = _BinOpCompareGreaterThanUnsigned32(Uh_5tlreg3819, Uh_5tlreg3817, 8); //gcnl:NodeBinaryOpCompare.cpp:441
if(_Bool32ToCbool(Uh_5tlreg3820, 1)) //gcnl:NodeControl.cpp:213
{
//! Stretchy.ulam:31: if (tempAdjacent > adjacent) adjacent = tempAdjacent;
const u32 Uh_5tlreg3822 = Uv_9212tempAdjacent.read(); //gcnl:Node.cpp:698
Uv_8adjacent.write(Uh_5tlreg3822); //gcnl:Node.cpp:892
} // end if
}
//! Stretchy.ulam:32: tempAdjacent = 0;
const u32 Uh_5tlreg3824 = 0; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3825 = _Int32ToUnsigned32(Uh_5tlreg3824, 2, 8); //gcnl:NodeCast.cpp:748
Uv_9212tempAdjacent.write(Uh_5tlreg3825); //gcnl:Node.cpp:892
}
} //end else
}
}
//! Stretchy.ulam:26: for (SiteNumber i = 0; i < 16; i++){
Ul_214endcontrolloop13:
__attribute__((__unused__)); //gcnl:NodeLabel.cpp:68
//! Stretchy.ulam:26: for (SiteNumber i = 0; i < 16; i++){
const u32 Uh_5tlreg3827 = 1; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3828 = _Int32ToUnsigned32(Uh_5tlreg3827, 32, 6); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3830 = Uv_1i.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3831 = _BinOpAddUnsigned32(Uh_5tlreg3830, Uh_5tlreg3828, 6); //gcnl:NodeBinaryOpEqualArithPostIncr.cpp:196
Uv_1i.write(Uh_5tlreg3831); //gcnl:Node.cpp:892
} // end while //gcnl:NodeControlWhile.cpp:145
}
//! Stretchy.ulam:36: if (adjacent < 3 || adjacent > 5) return;
{
//! Stretchy.ulam:36: if (adjacent < 3 || adjacent > 5) return;
u32 Uh_5tlreg3832 = false; //gcnl:NodeBinaryOpLogicalOr.cpp:113
const u32 Uh_5tlreg3833 = 3; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3834 = _Int32ToInt32(Uh_5tlreg3833, 3, 9); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3836 = Uv_8adjacent.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3837 = _Unsigned32ToInt32(Uh_5tlreg3836, 8, 9); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3838 = _BinOpCompareLessThanInt32(Uh_5tlreg3837, Uh_5tlreg3834, 9); //gcnl:NodeBinaryOpCompare.cpp:441
if(!_Bool32ToCbool(Uh_5tlreg3838, 1)) //gcnl:NodeBinaryOpLogicalOr.cpp:132
{
const u32 Uh_5tlreg3839 = 5; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3840 = _Int32ToInt32(Uh_5tlreg3839, 4, 9); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3842 = Uv_8adjacent.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3843 = _Unsigned32ToInt32(Uh_5tlreg3842, 8, 9); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3844 = _BinOpCompareGreaterThanInt32(Uh_5tlreg3843, Uh_5tlreg3840, 9); //gcnl:NodeBinaryOpCompare.cpp:441
Uh_5tlreg3832 = Uh_5tlreg3844; //gcnl:NodeBinaryOpLogicalOr.cpp:146
}
else
{
Uh_5tlreg3832 = Uh_5tlreg3838; //gcnl:NodeBinaryOpLogicalOr.cpp:163
}
if(_Bool32ToCbool(Uh_5tlreg3832, 1)) //gcnl:NodeControl.cpp:213
{
//! Stretchy.ulam:36: if (adjacent < 3 || adjacent > 5) return;
return; //gcnl:NodeReturnStatement.cpp:348
} // end if
}
//! Stretchy.ulam:38: if (neighbors < max){
{
//! Stretchy.ulam:38: if (neighbors < max){
const u32 Uh_5tlreg3846 = UlamRef<EC>(ur, 0u, 8u, NULL, UlamRef<EC>::PRIMITIVE).Read(); //gcnl:Node.cpp:664
const u32 Uh_5tlreg3848 = Uv_919neighbors.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3849 = _BinOpCompareLessThanUnsigned32(Uh_5tlreg3848, Uh_5tlreg3846, 8); //gcnl:NodeBinaryOpCompare.cpp:441
if(_Bool32ToCbool(Uh_5tlreg3849, 1)) //gcnl:NodeControl.cpp:213
{
{
//! Stretchy.ulam:39: for (SiteNumber i = 1; i < 5; i++){
{
//! Stretchy.ulam:39: for (SiteNumber i = 1; i < 5; i++){
const u32 Uh_5tlreg3850 = 1; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3851 = _Int32ToUnsigned32(Uh_5tlreg3850, 2, 6); //gcnl:NodeCast.cpp:748
Ui_Ut_10161u<EC> Uv_1i(Uh_5tlreg3851); //gcnl:NodeVarDecl.cpp:1081
//! Stretchy.ulam:39: for (SiteNumber i = 1; i < 5; i++){
while(true)
{
const u32 Uh_5tlreg3852 = 5; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3853 = _Int32ToInt32(Uh_5tlreg3852, 4, 7); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3855 = Uv_1i.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3856 = _Unsigned32ToInt32(Uh_5tlreg3855, 6, 7); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3857 = _BinOpCompareLessThanInt32(Uh_5tlreg3856, Uh_5tlreg3853, 7); //gcnl:NodeBinaryOpCompare.cpp:441
if(!_Bool32ToCbool(Uh_5tlreg3857, 1))
break; //gcnl:NodeControlWhile.cpp:135
//! Stretchy.ulam:39: for (SiteNumber i = 1; i < 5; i++){
{
//! Stretchy.ulam:40: if (ew[i] is Empty){
{
//! Stretchy.ulam:40: if (ew[i] is Empty){
UlamRef<EC> Uh_3tur3859(ur, 0u, 0u, &Uq_10109211EventWindow10<EC>::THE_INSTANCE, UlamRef<EC>::CLASSIC); //gcnl:NodeFunctionCall.cpp:960
const u32 Uh_5tlreg3861 = Uv_1i.read(); //gcnl:Node.cpp:698
Ui_Ut_10161u<EC> Uh_5tlval3862(Uh_5tlreg3861); //gcnl:Node.cpp:1142
Ui_Ut_r102961a<EC> Uh_5tuval3864 = Uq_10109211EventWindow10<EC>::THE_INSTANCE.Uf_4aref(uc, Uh_3tur3859, Uh_5tlval3862); //gcnl:NodeFunctionCall.cpp:1043
const u32 Uh_5tlreg3865 = Ue_10105Empty10<EC>::THE_INSTANCE.internalCMethodImplementingIs(Uh_5tuval3864.read()); //gcnl:NodeConditionalIs.cpp:285
if(_Bool32ToCbool(Uh_5tlreg3865, 1)) //gcnl:NodeControl.cpp:213
{
{
//! Stretchy.ulam:41: ew[i] = Stretchy.instanceof;
Ui_Ue_10188Stretchy10<EC> Uh_5tuval3866; //gcnl:NodeInstanceof.cpp:113
UlamRef<EC> Uh_3tur3868(ur, 0u, 0u, &Uq_10109211EventWindow10<EC>::THE_INSTANCE, UlamRef<EC>::CLASSIC); //gcnl:NodeFunctionCall.cpp:960
const u32 Uh_5tlreg3870 = Uv_1i.read(); //gcnl:Node.cpp:698
Ui_Ut_10161u<EC> Uh_5tlval3871(Uh_5tlreg3870); //gcnl:Node.cpp:1142
Ui_Ut_r102961a<EC> Uh_5tuval3873 = Uq_10109211EventWindow10<EC>::THE_INSTANCE.Uf_4aref(uc, Uh_3tur3868, Uh_5tlval3871); //gcnl:NodeFunctionCall.cpp:1043
Uh_5tuval3873.WriteAtom(Uh_5tuval3866.read()); //write into atomof ref //gcnl:Node.cpp:992
//! Stretchy.ulam:42: break;
break; //out of nearest loop //gcnl:NodeBreakStatement.cpp:69
}
} // end if
}
}
//! Stretchy.ulam:39: for (SiteNumber i = 1; i < 5; i++){
Ul_214endcontrolloop14:
__attribute__((__unused__)); //gcnl:NodeLabel.cpp:68
//! Stretchy.ulam:39: for (SiteNumber i = 1; i < 5; i++){
const u32 Uh_5tlreg3874 = 1; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3875 = _Int32ToUnsigned32(Uh_5tlreg3874, 32, 6); //gcnl:NodeCast.cpp:748
const u32 Uh_5tlreg3877 = Uv_1i.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3878 = _BinOpAddUnsigned32(Uh_5tlreg3877, Uh_5tlreg3875, 6); //gcnl:NodeBinaryOpEqualArithPostIncr.cpp:196
Uv_1i.write(Uh_5tlreg3878); //gcnl:Node.cpp:892
} // end while //gcnl:NodeControlWhile.cpp:145
}
}
} // end if
}
//! Stretchy.ulam:47: if (neighbors >= max){
{
//! Stretchy.ulam:47: if (neighbors >= max){
const u32 Uh_5tlreg3880 = UlamRef<EC>(ur, 0u, 8u, NULL, UlamRef<EC>::PRIMITIVE).Read(); //gcnl:Node.cpp:664
const u32 Uh_5tlreg3882 = Uv_919neighbors.read(); //gcnl:Node.cpp:698
const u32 Uh_5tlreg3883 = _BinOpCompareGreaterEqualUnsigned32(Uh_5tlreg3882, Uh_5tlreg3880, 8); //gcnl:NodeBinaryOpCompare.cpp:441
if(_Bool32ToCbool(Uh_5tlreg3883, 1)) //gcnl:NodeControl.cpp:213
{
{
//! Stretchy.ulam:48: ew[0] = Empty.instanceof;
Ui_Ue_10105Empty10<EC> Uh_5tuval3884; //gcnl:NodeInstanceof.cpp:113
UlamRef<EC> Uh_3tur3886(ur, 0u, 0u, &Uq_10109211EventWindow10<EC>::THE_INSTANCE, UlamRef<EC>::CLASSIC); //gcnl:NodeFunctionCall.cpp:960
const u32 Uh_5tlreg3887 = 0; //gcnl:NodeTerminal.cpp:690
const u32 Uh_5tlreg3888 = _Int32ToUnsigned32(Uh_5tlreg3887, 2, 6); //gcnl:NodeCast.cpp:748
Ui_Ut_10161u<EC> Uh_5tlval3889(Uh_5tlreg3888); //gcnl:Node.cpp:1142
Ui_Ut_r102961a<EC> Uh_5tuval3891 = Uq_10109211EventWindow10<EC>::THE_INSTANCE.Uf_4aref(uc, Uh_3tur3886, Uh_5tlval3889); //gcnl:NodeFunctionCall.cpp:1043
Uh_5tuval3891.WriteAtom(Uh_5tuval3884.read()); //write into atomof ref //gcnl:Node.cpp:992
}
} // end if
}
} // Uf_6behave
//BUILT-IN FUNCTIONS:
template<class EC>
const UlamClassDataMemberInfo & Ue_10188Stretchy10<EC>::GetDataMemberInfo(u32 dataMemberNumber) const
{
switch (dataMemberNumber)
{
case 0: { static UlamClassDataMemberInfo i("Uq_10109211EventWindow10", "ew", 0u); return i; } //gcnl:NodeVarDeclDM.cpp:1131
case 1: { static UlamClassDataMemberInfo i("Uq_1010919AtomUtils10", "au", 0u); return i; } //gcnl:NodeVarDeclDM.cpp:1131
case 2: { static UlamClassDataMemberInfo i("Ut_10181u", "max", 0u); return i; } //gcnl:NodeVarDeclDM.cpp:1131
}; //end switch //gcnl:NodeBlockClass.cpp:2652
FAIL(ILLEGAL_ARGUMENT); //gcnl:NodeBlockClass.cpp:2655
} //GetDataMemberInfo
template<class EC>
s32 Ue_10188Stretchy10<EC>::GetDataMemberCount() const
{
return 3; //gcnl:NodeBlockClass.cpp:2719
} //GetDataMemberCount
template<class EC>
const char * Ue_10188Stretchy10<EC>::GetMangledClassName() const
{
return "Ue_10188Stretchy10"; //gcnl:NodeBlockClass.cpp:2770
} //GetMangledClassName
template<class EC>
u32 Ue_10188Stretchy10<EC>::GetClassLength( ) const
{
return 8; //gcnl:NodeBlockClass.cpp:2019
} //getClassLength
template<class EC>
const unsigned char * Ue_10188Stretchy10<EC>::GetString(u32 sidx) const
{
const u32 USERSTRINGPOOLSIZE = 1; //gcnl:NodeBlockClass.cpp:2537
static unsigned char UserStringPool[USERSTRINGPOOLSIZE + 1] =
"\000"
; //gcnl:StringPoolUser.cpp:127
if(sidx == 0)
FAIL(UNINITIALIZED_VALUE); //gcnl:NodeBlockClass.cpp:2546
if(sidx >= USERSTRINGPOOLSIZE)
FAIL(ARRAY_INDEX_OUT_OF_BOUNDS); //gcnl:NodeBlockClass.cpp:2555
return UserStringPool + sidx + 1; //gcnl:NodeBlockClass.cpp:2561
} //GetString
template<class EC>
u32 Ue_10188Stretchy10<EC>::GetStringLength(u32 sidx) const
{
return *(GetString(sidx) - 1); //gcnl:NodeBlockClass.cpp:2602
} //GetStringLength
template<class EC>
typename EC::ATOM_CONFIG::ATOM_TYPE Ue_10188Stretchy10<EC>::BuildDefaultAtom( ) const
{
AtomBitStorage<EC> da(Element<EC>::BuildDefaultAtom()); //gcnl:NodeBlockClass.cpp:2072
// Initialize any data members:
static const u32 vales[(96 + 31)/32] = { 0xa, 0x0, 0x0 }; //gcnl:CompilerState.cpp:1395
static BitVector<96> initBV; //gcnl:CompilerState.cpp:1401
static bool initdone;
if(!initdone)
{
initdone = true;
initBV.FromArray(vales); //gcnl:CompilerState.cpp:1417
//correct runtime regnum for strings
} //gcnl:CompilerState.cpp:1439
initBV.Write(0u, T::ATOM_FIRST_STATE_BIT, da.Read(0u, T::ATOM_FIRST_STATE_BIT)); //gcnl:NodeBlockClass.cpp:2087
da.WriteBV(0u, initBV); //gcnl:NodeBlockClass.cpp:2089
return (da.ReadAtom()); //gcnl:NodeBlockClass.cpp:2095
} //BuildDefaultAtom
template<class EC>
VfuncPtr Ue_10188Stretchy10<EC>::m_vtable[2] = {
(VfuncPtr) ((typename Ue_10188Stretchy10<EC>::Uf_6behave10) &Ue_10188Stretchy10<EC>::Uf_6behave),
(VfuncPtr) ((typename Uq_10106UrSelf10<EC>::Uf_8getColor11102321u) &Uq_10106UrSelf10<EC>::Uf_8getColor)
}; //VTABLE Definition //gcnl:NodeBlockClass.cpp:2341
template<class EC>
VfuncPtr Ue_10188Stretchy10<EC>::getVTableEntry(u32 idx) const
{
if(idx >= 2) FAIL(ARRAY_INDEX_OUT_OF_BOUNDS); //gcnl:NodeBlockClass.cpp:2361
return m_vtable[idx]; //gcnl:NodeBlockClass.cpp:2364
}
template<class EC>
bool Ue_10188Stretchy10<EC>::internalCMethodImplementingIs(const UlamClass<EC> * cptrarg) const
{
if(cptrarg == &Uq_10106UrSelf10<EC>::THE_INSTANCE) return(true); //inherited class, or self (last) //gcnl:NodeBlockClass.cpp:1981
if(cptrarg == &Ue_10188Stretchy10<EC>::THE_INSTANCE) return(true); //inherited class, or self (last) //gcnl:NodeBlockClass.cpp:1981
return (false); //not found //gcnl:NodeBlockClass.cpp:1959
} //is-related
template<class EC>
bool Ue_10188Stretchy10<EC>::internalCMethodImplementingIs(const T& targ) const
{
return (THE_INSTANCE.GetType() == targ.GetType()); //gcnl:NodeBlockClass.cpp:2403
} //isMethod
template<class EC>
const u32 Ue_10188Stretchy10<EC>::ReadTypeField(const BV bv)
{
return BFTYP::Read(bv); //gcnl:NodeBlockClass.cpp:2441
} //ReadTypeField
template<class EC>
void Ue_10188Stretchy10<EC>::WriteTypeField(BV& bv, const u32 v)
{
BFTYP::Write(bv, v); //gcnl:NodeBlockClass.cpp:2463
} //WriteTypeField
} //MFM
|
a8694f55757518c5056c7b35ca031e1d858a5524 | 705683d98811159f33d71ff5f55c26ddbb541034 | /transaction.hh | a14873f03eb6ce9114cc0636faca7a22d0522941 | [] | no_license | KReload/proj-paradise | 700b4a0cb16464d6990eca16d5b2ab68b5fb3b73 | a2a78374d4720e2506b6ee846621e64be2ad8348 | refs/heads/master | 2021-09-04T22:25:05.912405 | 2018-01-22T17:42:53 | 2018-01-22T17:42:53 | 115,535,803 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 404 | hh | transaction.hh | #pragma once
#include <string>
#include "lieux.hh"
#include "nom.hh"
class Transaction
{
public:
Transaction();
Transaction(std::string nom, int montant, std::string lieux, float preussite);
virtual std::string toString() = 0;
virtual int evaluate() = 0;
virtual int montant() =0;
protected:
std::string _nom;
int _montant;
std::string _lieux;
float _preussite;
};
|
7f9151a4d4690e91e561dfee0d0a871de0de9e4a | 59dc69a22f1e2ea41074d2a9d32f461518eb13e2 | /src/a2d/math/vector.hpp | a8081db59c0662f07b0d6fc6b2d95bdac113b04b | [
"MIT"
] | permissive | mowenli/A2D | 4956140152e64fa402bad816fbe0ba36e6017352 | 278b8e40be74c0f0257b1062f009995462f983fa | refs/heads/master | 2022-01-19T20:53:48.286678 | 2019-05-30T23:42:05 | 2019-05-30T23:58:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,743 | hpp | vector.hpp | //
// Created by selya on 26.10.2018.
//
#ifndef A2D_VECTOR_HPP
#define A2D_VECTOR_HPP
#include <a2d/math/math_defines.hpp>
#include <a2d/utils/utils.hpp>
namespace a2d {
// Vector base template
template<int L, class T>
class Vector;
typedef Vector<2, float> Vector2f;
typedef Vector<3, float> Vector3f;
typedef Vector<4, float> Vector4f;
typedef Vector<2, double> Vector2d;
typedef Vector<3, double> Vector3d;
typedef Vector<4, double> Vector4d;
typedef Vector<2, int> Vector2i;
typedef Vector<3, int> Vector3i;
typedef Vector<4, int> Vector4i;
typedef Vector<2, unsigned int> Vector2ui;
typedef Vector<3, unsigned int> Vector3ui;
typedef Vector<4, unsigned int> Vector4ui;
template<class T>
class Vector<2, T> {
public:
T x, y;
Vector();
Vector(T scalar);
Vector(T x, T y);
Vector(const Vector<2, T> &other);
//
// Const member functions
//
// Unsafe for integer vectors
T Length() const;
T Distance(T x, T y) const;
T Distance(const Vector<2, T> &other) const;
T Dot(T x, T y) const;
T Dot(const Vector<2, T> &other) const;
T Determinant(T x, T y) const;
T Determinant(const Vector<2, T> &other) const;
T Angle(T x, T y) const;
T Angle(const Vector<2, T> &other) const;
Vector<2, T> Normalized() const;
T LengthSquared() const;
T DistanceSquared(T x, T y) const;
T DistanceSquared(const Vector<2, T> &other) const;
Vector<2, T> Perpendicular() const;
Vector<2, T> Min(T x, T y) const;
Vector<2, T> Min(const Vector<2, T> &other) const;
Vector<2, T> Max(T x, T y) const;
Vector<2, T> Max(const Vector<2, T> &other) const;
Vector<2, T> Lerp(T x, T y, double t) const;
Vector<2, T> Lerp(const Vector<2, T> &other, double t) const;
Vector<2, T> operator+(const Vector<2, T> &other) const;
Vector<2, T> operator-(const Vector<2, T> &other) const;
Vector<2, T> operator*(const Vector<2, T> &other) const;
Vector<2, T> operator/(const Vector<2, T> &other) const;
Vector<2, T> operator+(T scalar) const;
Vector<2, T> operator-(T scalar) const;
Vector<2, T> operator*(T scalar) const;
Vector<2, T> operator/(T scalar) const;
bool operator==(const Vector<2, T> &other) const;
bool operator==(T scalar) const;
//
// Non-const member functions
//
// Unsafe for integer vectors
Vector<2, T> &Normalize();
Vector<2, T> &Floor();
Vector<2, T> &Ceil();
Vector<2, T> &Round();
Vector<2, T> &Zero();
Vector<2, T> &Set(T x, T y);
Vector<2, T> &Set(const Vector<2, T> &other);
Vector<2, T> &Set(T scalar);
Vector<2, T> &operator-();
Vector<2, T> &operator=(const Vector<2, T> &other);
Vector<2, T> &operator+=(const Vector<2, T> &other);
Vector<2, T> &operator-=(const Vector<2, T> &other);
Vector<2, T> &operator*=(const Vector<2, T> &other);
Vector<2, T> &operator/=(const Vector<2, T> &other);
Vector<2, T> &operator=(T scalar);
Vector<2, T> &operator+=(T scalar);
Vector<2, T> &operator-=(T scalar);
Vector<2, T> &operator*=(T scalar);
Vector<2, T> &operator/=(T scalar);
};
template<class T>
class Vector<3, T> {
public:
T x, y, z;
Vector();
Vector(T scalar);
Vector(T x, T y, T z);
Vector(const Vector<3, T> &other);
Vector(const Vector<2, T> &v2, T z);
//
// Const member functions
//
// Unsafe for integer vectors
T Length() const;
T Distance(const Vector<3, T> &other) const;
T Distance(T x, T y, T z) const;
T Dot(const Vector<3, T> &other) const;
T AngleCos(const Vector<3, T> &other) const;
T Angle(const Vector<3, T> &other) const;
Vector<3, T> Normalized() const;
T LengthSquared() const;
T DistanceSquared(const Vector<3, T> &other) const;
Vector<3, T> Cross(const Vector<3, T> &other) const;
Vector<3, T> Min(const Vector<3, T> &other) const;
Vector<3, T> Max(const Vector<3, T> &other) const;
Vector<3, T> Lerp(const Vector<3, T> &other, double t) const;
Vector<3, T> operator+(const Vector<3, T> &other) const;
Vector<3, T> operator-(const Vector<3, T> &other) const;
Vector<3, T> operator*(const Vector<3, T> &other) const;
Vector<3, T> operator/(const Vector<3, T> &other) const;
Vector<3, T> operator+(T scalar) const;
Vector<3, T> operator-(T scalar) const;
Vector<3, T> operator*(T scalar) const;
Vector<3, T> operator/(T scalar) const;
bool operator==(const Vector<3, T> &other) const;
bool operator==(T scalar) const;
//
// Non-const member functions
//
// Unsafe for integer vectors
Vector<3, T> &Normalize();
Vector<3, T> &Floor();
Vector<3, T> &Ceil();
Vector<3, T> &Round();
Vector<3, T> &Zero();
Vector<3, T> &Set(T x, T y, T z);
Vector<3, T> &Set(const a2d::Vector<3, T> &other);
Vector<3, T> &Set(const a2d::Vector<2, T> &other, T z);
Vector<3, T> &Set(T scalar);
Vector<3, T> &operator-();
Vector<3, T> &operator=(const Vector<3, T> &other);
Vector<3, T> &operator+=(const Vector<3, T> &other);
Vector<3, T> &operator-=(const Vector<3, T> &other);
Vector<3, T> &operator*=(const Vector<3, T> &other);
Vector<3, T> &operator/=(const Vector<3, T> &other);
Vector<3, T> &operator=(T scalar);
Vector<3, T> &operator+=(T scalar);
Vector<3, T> &operator-=(T scalar);
Vector<3, T> &operator*=(T scalar);
Vector<3, T> &operator/=(T scalar);
};
template<class T>
class Vector<4, T> {
public:
T x, y, z, w;
Vector();
Vector(T scalar);
Vector(T x, T y, T z, T w);
Vector(const Vector<4, T> &other);
Vector(const Vector<3, T> &v3, T w);
Vector(const Vector<2, T> &v2, T z, T w);
//
// Const member functions
//
// Unsafe for integer vectors
T Length() const;
T Distance(const Vector<4, T> &other) const;
T AngleCos(const Vector<4, T> &other) const;
T Angle(const Vector<4, T> &other) const;
Vector<4, T> Normalized() const;
T LengthSquared() const;
T DistanceSquared(const Vector<4, T> &other) const;
T Dot(const Vector<4, T> &other) const;
Vector<4, T> Min(const Vector<4, T> &other) const;
Vector<4, T> Max(const Vector<4, T> &other) const;
Vector<4, T> Lerp(const Vector<4, T> &other, double t) const;
Vector<4, T> operator+(const Vector<4, T> &other) const;
Vector<4, T> operator-(const Vector<4, T> &other) const;
Vector<4, T> operator*(const Vector<4, T> &other) const;
Vector<4, T> operator/(const Vector<4, T> &other) const;
Vector<4, T> operator+(T scalar) const;
Vector<4, T> operator-(T scalar) const;
Vector<4, T> operator*(T scalar) const;
Vector<4, T> operator/(T scalar) const;
bool operator==(const Vector<4, T> &other) const;
bool operator==(T scalar) const;
//
// Non-const member functions
//
// Unsafe for integer vectors
Vector<4, T> &Normalize();
Vector<4, T> &Floor();
Vector<4, T> &Ceil();
Vector<4, T> &Round();
Vector<4, T> &Zero();
Vector<4, T> &Set(T x, T y, T z, T w);
Vector<4, T> &Set(const a2d::Vector<4, T> &other);
Vector<4, T> &Set(const a2d::Vector<3, T> &other, T w);
Vector<4, T> &Set(const a2d::Vector<2, T> &other, T z, T w);
Vector<4, T> &Set(T scalar);
Vector<4, T> &operator-();
Vector<4, T> &operator=(const Vector<4, T> &other);
Vector<4, T> &operator+=(const Vector<4, T> &other);
Vector<4, T> &operator-=(const Vector<4, T> &other);
Vector<4, T> &operator*=(const Vector<4, T> &other);
Vector<4, T> &operator/=(const Vector<4, T> &other);
Vector<4, T> &operator=(T scalar);
Vector<4, T> &operator+=(T scalar);
Vector<4, T> &operator-=(T scalar);
Vector<4, T> &operator*=(T scalar);
Vector<4, T> &operator/=(T scalar);
};
} //namespace a2d
namespace std {
template<class K>
struct hash<a2d::Vector<2, K>> {
size_t operator()(const a2d::Vector<2, K> &v) const {
std::hash<K> hasher;
size_t hash_ = hasher(v.x);
a2d::utils::hash_combine(hash_, v.y);
return hash_;
}
};
template<class K>
struct hash<a2d::Vector<3, K>> {
size_t operator()(const a2d::Vector<3, K> &v) const {
std::hash<K> hasher;
size_t hash_ = hasher(v.x);
a2d::utils::hash_combine(hash_, v.y);
a2d::utils::hash_combine(hash_, v.z);
return hash_;
}
};
template<class K>
struct hash<a2d::Vector<4, K>> {
size_t operator()(const a2d::Vector<4, K> &v) const {
std::hash<K> hasher;
size_t hash_ = hasher(v.x);
a2d::utils::hash_combine(hash_, v.y);
a2d::utils::hash_combine(hash_, v.z);
a2d::utils::hash_combine(hash_, v.w);
return hash_;
}
};
}
#endif //A2D_VECTOR_HPP
|
979e6c412d6e6b515ad99947cab58b9d7c533d54 | 6b57df76567fc391ba3f7e9f741a742d792b606b | /DataStructures/23-AdvBST/programs/BSTDiam.cpp | b165673247bcb7d8d40e7a35917adfb598ee5169 | [] | no_license | nolan-downey/SchoolCodingWork | 66393a9839c807a1a7ba5f1de6fe4a4fe8562da0 | 4592791d67a7191b9bfc2cb78232fef230b36c39 | refs/heads/master | 2022-04-13T12:30:24.494405 | 2020-04-06T00:22:30 | 2020-04-06T00:22:30 | 253,351,666 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,337 | cpp | BSTDiam.cpp | #include "../classes/BST.h"
#include <iostream>
#include <string>
void testExample(){
BST<int> theTree;
theTree.Insert(12);
theTree.Insert(10);
theTree.Insert(8);
theTree.Insert(11);
theTree.Insert(14);
theTree.Insert(13);
theTree.Insert(16);
theTree.Insert(15);
theTree.Insert(17);
theTree.Insert(7);
theTree.Insert(9);
theTree.Insert(6);
DynArr< int > intHeight = theTree.heightPrint();
std::cout << "The height of the example tree is " << intHeight.length();
std::cout << ", and is " << intHeight << std::endl;
DynArr< int > intDiameter = theTree.diameterPrint();
std::cout << "The Diameter of the int tree is " << intDiameter.length();
std::cout << ", and is " << intDiameter << std::endl;
std::cout << "------------------------" << std::endl;
}
void testChar(){
BST< char > theTree;
theTree.Insert('M');
theTree.Insert('F');
theTree.Insert('T');
theTree.Insert('A');
theTree.Insert('H');
theTree.Insert('O');
theTree.Insert('Z');
theTree.Insert('m');
theTree.Insert('f');
theTree.Insert('t');
theTree.Insert('a');
theTree.Insert('h');
theTree.Insert('o');
theTree.Insert('z');
DynArr< char > charHeight = theTree.heightPrint();
std::cout << "The Height of the char tree is " << charHeight.length();
std::cout << ", and is " << charHeight << std::endl;
DynArr< char > charDiameter = theTree.diameterPrint();
std::cout << "The Diameter of the char tree is " << charDiameter.length();
std::cout << ", and is " << charDiameter << std::endl;
std::cout << "------------------------" << std::endl;
}
void testWorst(){
BST< char > theTree;
for(unsigned int ascii = 65; ascii <= 90; ascii++){
theTree.Insert( (char)ascii );
}
DynArr< char > theHeight = theTree.heightPrint();
std::cout << "The Height of the worst-case tree is " << theHeight.length();
std::cout << ", and is " << theHeight << std::endl;
DynArr< char > theDiameter = theTree.diameterPrint();
std::cout << "The Diameter of the worst-case tree is " << theDiameter.length();
std::cout << ", and is " << theDiameter << std::endl;
std::cout << "------------------------" << std::endl;
}
int main(){
testExample();
testChar();
testWorst();
return 0;
} |
00eed2528b08d0c269f8212f46130c3c565e1f91 | af424ed127cb0fcdc729b1417f2884c4839adc03 | /SkyBox.cpp | 523b034daa1c95b397edfdd2a2b7be502ffb35d8 | [] | no_license | ComputerGraphicsLesson/Computer-Graphic-Project | caf16375cd5c2295f1dbbd6bd438e827916986ca | cc8bfd9785f2ba9b89cf45337ef38b1f303fdea4 | refs/heads/master | 2021-01-21T17:06:16.839299 | 2017-05-14T08:38:42 | 2017-05-14T08:38:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 923 | cpp | SkyBox.cpp | //
// Created by hao on 4/26/17.
//
#include "SkyBox.h"
SkyBox::SkyBox(Camera* camera, Model *model, const vector<string> texturesPath) : cubemapTex(texturesPath) {
this->camera = camera;
this->model = model;
}
void SkyBox::Render(Shader &shader) {
glDepthMask(GL_FALSE);
shader.Use();
mat4 view = glm::mat4(glm::mat3(camera->GetViewMatrix()));
mat4 projection = glm::perspective(camera->Zoom, (float)WIDTH/(float)WIDTH, NEAR, FAR);
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "view"), 1, GL_FALSE, glm::value_ptr(view));
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
// Bind Texture
glActiveTexture(GL_TEXTURE0);
glUniform1i(glGetUniformLocation(shader.Program, "skybox"), 0);
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTex.id);
model->Draw(shader);
glDepthMask(GL_TRUE);
} |
bbabd7ed8f1dcc2537593770671bea08c2e0b3ff | 8026b467f625c3a0e219fdab70e6ed3f2547dd5d | /src/dconnectedcompdistance.cpp | f182d555b5f275cc526a8582bc7b16b4b0cccd15 | [] | no_license | herobd/handwriting | 4151d0957827e43b3393da51743629b8545cdeff | aa4a5d9eb851e54735536e367847482c7851f196 | refs/heads/master | 2021-01-01T06:45:32.863209 | 2014-09-11T23:29:57 | 2014-09-11T23:29:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,557 | cpp | dconnectedcompdistance.cpp | #include "dconnectedcompdistance.h"
///for now, this just calls getCCDistAndNearestCC_() and discards imgNearestCC
void DConnectedComponentDistance::getCCDist_(DImage &imgCCDist,
const DImage &imgCCs){
DImage imgTmp;
getCCDistAndNearestCC_(imgCCDist, imgTmp, imgCCs);
}
///for now, this just calls getCCDistAndNearestCC_() and discards imgCCDist
void DConnectedComponentDistance::getNearestCC_(DImage &imgNearestCC,
const DImage &imgCCs){
DImage imgTmp;
getCCDistAndNearestCC_(imgTmp, imgNearestCC, imgCCs);
}
///determine distance to (and ID of) nearest CC to each pixel
/**This function uses a two-pass algorithm to determine the manhattan
distance (diagonals are ignored) from any given pixel to the
connected component "nearest" to it, as well as the CC label of the
connected component that it is "nearest" to. This may not actually
be the nearest component due to the fact that diagonal directions
are ignored, the pixels are always checked in the same order of
directions, and distance/CClabel are only updated if the distance
from the direction being checked is LESS THAN the distance reorded
so far. So this is a pretty good approximation, but not
necessarily completely accurate. The input image (imgCCs) should
be a connected component map image (of type DImage_u32) with CC
label 0 being the background pixels that are ignored by this
algorithm.
*/
void DConnectedComponentDistance::getCCDistAndNearestCC_(DImage &imgCCDist,
DImage &imgNearestCC,
const DImage &imgCCs){
D_uint32 *pCCs; // source connected component map image
D_uint32 *pCCDist;
D_uint32 *pNearestCC;
int w, h; // image width and height
int wm1, hm1; // width minus 1 and height minus 1
if(imgCCs.getImageType() != DImage::DImage_u32){
fprintf(stderr, "DConnectedComponentDistance::getCCDistAndNearestCC_() "
"expects imgCCs to be a CC map (type DImage_u32 with "
"0=background\n");
abort();
}
w = imgCCs.width();
h = imgCCs.height();
wm1 = w - 1;
hm1 = h - 1;
imgCCDist.create(w, h, DImage::DImage_u32);
imgNearestCC.create(w, h, DImage::DImage_u32);
pCCs = imgCCs.dataPointer_u32();
pCCDist = imgCCDist.dataPointer_u32();
pNearestCC = imgNearestCC.dataPointer_u32();
// STEP 1:
// scan from top-left and record the shorter distance N,W along with the
// ID of the component from that direction
for(int y = 0, idx=0; y < h; ++y){
for(int x = 0; x < w; ++x, ++idx){
if(0 != pCCs[idx]){
pCCDist[idx] = 0;
pNearestCC[idx] = pCCs[idx];
}
else{
pCCDist[idx] = 0xfffffffe;//(we need to add 1 without wrapping to 0)
pNearestCC[idx] = 0;
}
// West
if((x>0) && ((pCCDist[idx-1]+1) < pCCDist[idx])){
pCCDist[idx] = pCCDist[idx-1]+1;
pNearestCC[idx] = pNearestCC[idx-1];
}
// North
if((y>0) && ((pCCDist[idx-w]+1) < pCCDist[idx])){
pCCDist[idx] = pCCDist[idx-w]+1;
pNearestCC[idx] = pNearestCC[idx-w];
}
}
}
// STEP 2:
// scan from bottom right and update for S,E along with the
// ID of the component from that shortest direction if shorter than current
for(int y = hm1, idx=w*h-1; y >= 0; --y){
for(int x = wm1; x >= 0; --x, --idx){
// East
if((x<wm1) && ((pCCDist[idx+1]+1) < pCCDist[idx])){
pCCDist[idx] = pCCDist[idx+1]+1;
pNearestCC[idx] = pNearestCC[idx+1];
}
// South
if((y<hm1) && ((pCCDist[idx+w]+1) < pCCDist[idx])){
pCCDist[idx] = pCCDist[idx+w]+1;
pNearestCC[idx] = pNearestCC[idx+w];
}
}
}
}
|
57c823fd74bdb0fecfb7b66399d13a8a0f2816f2 | 8f902f218d5bd66327d08816458071962fb2df86 | /test3/monthly_care_plan.hpp | fb9746058d251f2bbc6a7abc89bb062bcca64e89 | [] | no_license | kumagi/qttry | 665a6039ed0b893b45af00ca78f437089fe7e1b3 | 8a89035e22266efba5a0bb617d60cd9b9c22b0c4 | refs/heads/master | 2020-04-05T22:48:31.271629 | 2010-12-22T17:22:42 | 2010-12-22T17:22:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,584 | hpp | monthly_care_plan.hpp | #ifndef MONTHLY_CARE_PLAN_HPP
#define MONTHLY_CARE_PLAN_HPP
#include <iostream>
#include <QWidget>
#include <QBoxLayout>
#include <QLabel>
#include <QListWidget>
#include <QApplication>
#include <QSplitter>
#include "one_human.hpp"
class monthly_care_plan :public QWidget{
public:
QWidget *verticalLayoutWidget;
QVBoxLayout *verticalLayout;
QLabel *care_plan_label;
QListWidget *human_list;
one_human *human_widget;
public:
monthly_care_plan(QWidget* parent):QWidget(parent){
if (parent->objectName().isEmpty()){
parent->setObjectName(QString::fromUtf8("monthly_care_plan"));
}
parent->resize(800, 480);
QSplitter splitter(Qt::Horizontal);
verticalLayoutWidget = new QWidget(parent);
verticalLayoutWidget->setObjectName(QString::fromUtf8("verticalLayoutWidget"));
verticalLayoutWidget->setGeometry(QRect(0, 0, 160, 480));
verticalLayoutWidget->setMinimumSize(160,480);
verticalLayout = new QVBoxLayout(verticalLayoutWidget);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
care_plan_label = new QLabel(verticalLayoutWidget);
care_plan_label->setObjectName(QString::fromUtf8("care_plan_label"));
QFont font;
font.setPointSize(14);
care_plan_label->setFont(font);
care_plan_label->setAlignment(Qt::AlignCenter);
verticalLayout->addWidget(care_plan_label);
human_list = new QListWidget(verticalLayoutWidget);
human_list->setObjectName(QString::fromUtf8("human_list"));
human_list->setMinimumSize(161,440);
human_list->setMouseTracking(false);
human_list->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
verticalLayout->addWidget(human_list);
human_widget = new one_human(this);
human_widget->setGeometry(161, 0, 800-160, 480);
this->retranslateUi(parent);
QMetaObject::connectSlotsByName(parent);
this->setMinimumSize(300,480);
}
protected:
virtual void resizeEvent(QResizeEvent*){
std::cout << "resized\n";
const int extraWidth = width() - verticalLayoutWidget->width();
const int newHeight = height();
verticalLayout->setGeometry(QRect(0,0,160,newHeight));
human_widget->setGeometry(161,0,extraWidth, newHeight);
}
public:
void retranslateUi(QWidget *monthly_care_plan)
{
monthly_care_plan->setWindowTitle(QApplication::translate("monthly_care_plan", "Form", 0, QApplication::UnicodeUTF8));
care_plan_label->setText(QApplication::translate("monthly_care_plan", "\346\234\210\351\226\223\343\202\261\343\202\242\343\203\227\343\203\251\343\203\263", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
#endif
|
401623671a7d9d0b10505ce582ca232e183f4625 | ac1c9fbc1f1019efb19d0a8f3a088e8889f1e83c | /out/release/gen/third_party/blink/public/mojom/native_file_system/native_file_system_directory_handle.mojom-shared-internal.h | 90adc9f148b805b207713748ddc6cc7361735cbd | [
"BSD-3-Clause"
] | permissive | xueqiya/chromium_src | 5d20b4d3a2a0251c063a7fb9952195cda6d29e34 | d4aa7a8f0e07cfaa448fcad8c12b29242a615103 | refs/heads/main | 2022-07-30T03:15:14.818330 | 2021-01-16T16:47:22 | 2021-01-16T16:47:22 | 330,115,551 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,895 | h | native_file_system_directory_handle.mojom-shared-internal.h | // third_party/blink/public/mojom/native_file_system/native_file_system_directory_handle.mojom-shared-internal.h is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_MOJOM_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_DIRECTORY_HANDLE_MOJOM_SHARED_INTERNAL_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_DIRECTORY_HANDLE_MOJOM_SHARED_INTERNAL_H_
#include "mojo/public/cpp/bindings/lib/array_internal.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/map_data_internal.h"
#include "mojo/public/cpp/bindings/lib/buffer.h"
#include "third_party/blink/public/mojom/native_file_system/native_file_system_file_handle.mojom-shared-internal.h"
#include "third_party/blink/public/mojom/native_file_system/native_file_system_error.mojom-shared-internal.h"
#include "third_party/blink/public/mojom/native_file_system/native_file_system_transfer_token.mojom-shared-internal.h"
#include "third_party/blink/public/mojom/permissions/permission_status.mojom-shared-internal.h"
#include "mojo/public/cpp/bindings/lib/native_enum_data.h"
#include "mojo/public/interfaces/bindings/native_struct.mojom-shared-internal.h"
#include "base/component_export.h"
namespace mojo {
namespace internal {
class ValidationContext;
}
}
namespace blink {
namespace mojom {
namespace internal {
class NativeFileSystemEntry_Data;
class NativeFileSystemHandle_Data;
#pragma pack(push, 1)
class COMPONENT_EXPORT(MOJOM_SHARED_BLINK_COMMON_EXPORT) NativeFileSystemHandle_Data {
public:
// Used to identify Mojom Union Data Classes.
typedef void MojomUnionDataType;
NativeFileSystemHandle_Data() {}
// Do nothing in the destructor since it won't be called when it is a
// non-inlined union.
~NativeFileSystemHandle_Data() {}
class BufferWriter {
public:
BufferWriter() = default;
void Allocate(mojo::internal::Buffer* serialization_buffer) {
serialization_buffer_ = serialization_buffer;
index_ = serialization_buffer_->Allocate(sizeof(NativeFileSystemHandle_Data));
new (data()) NativeFileSystemHandle_Data();
}
void AllocateInline(mojo::internal::Buffer* serialization_buffer,
void* ptr) {
const char* start = static_cast<const char*>(
serialization_buffer->data());
const char* slot = static_cast<const char*>(ptr);
DCHECK_GT(slot, start);
serialization_buffer_ = serialization_buffer;
index_ = slot - start;
new (data()) NativeFileSystemHandle_Data();
}
bool is_null() const { return !serialization_buffer_; }
NativeFileSystemHandle_Data* data() {
DCHECK(!is_null());
return serialization_buffer_->Get<NativeFileSystemHandle_Data>(index_);
}
NativeFileSystemHandle_Data* operator->() { return data(); }
private:
mojo::internal::Buffer* serialization_buffer_ = nullptr;
size_t index_ = 0;
};
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context,
bool inlined);
bool is_null() const { return size == 0; }
void set_null() {
size = 0U;
tag = static_cast<NativeFileSystemHandle_Tag>(0);
data.unknown = 0U;
}
enum class NativeFileSystemHandle_Tag : uint32_t {
FILE,
DIRECTORY,
};
// A note on layout:
// "Each non-static data member is allocated as if it were the sole member of
// a struct." - Section 9.5.2 ISO/IEC 14882:2011 (The C++ Spec)
union MOJO_ALIGNAS(8) Union_ {
Union_() : unknown(0) {}
mojo::internal::Interface_Data f_file;
mojo::internal::Interface_Data f_directory;
uint64_t unknown;
};
uint32_t size;
NativeFileSystemHandle_Tag tag;
Union_ data;
};
static_assert(sizeof(NativeFileSystemHandle_Data) == mojo::internal::kUnionDataSize,
"Bad sizeof(NativeFileSystemHandle_Data)");
class COMPONENT_EXPORT(MOJOM_SHARED_BLINK_COMMON_EXPORT) NativeFileSystemEntry_Data {
public:
class BufferWriter {
public:
BufferWriter() = default;
void Allocate(mojo::internal::Buffer* serialization_buffer) {
serialization_buffer_ = serialization_buffer;
index_ = serialization_buffer_->Allocate(sizeof(NativeFileSystemEntry_Data));
new (data()) NativeFileSystemEntry_Data();
}
bool is_null() const { return !serialization_buffer_; }
NativeFileSystemEntry_Data* data() {
DCHECK(!is_null());
return serialization_buffer_->Get<NativeFileSystemEntry_Data>(index_);
}
NativeFileSystemEntry_Data* operator->() { return data(); }
private:
mojo::internal::Buffer* serialization_buffer_ = nullptr;
size_t index_ = 0;
DISALLOW_COPY_AND_ASSIGN(BufferWriter);
};
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
mojo::internal::StructHeader header_;
internal::NativeFileSystemHandle_Data entry_handle;
mojo::internal::Pointer<mojo::internal::String_Data> name;
private:
NativeFileSystemEntry_Data();
~NativeFileSystemEntry_Data() = delete;
};
static_assert(sizeof(NativeFileSystemEntry_Data) == 32,
"Bad sizeof(NativeFileSystemEntry_Data)");
// Used by NativeFileSystemEntry::WrapAsMessage to lazily serialize the struct.
template <typename UserType, typename DataView>
struct NativeFileSystemEntry_UnserializedMessageContext
: public mojo::internal::UnserializedMessageContext {
public:
static const mojo::internal::UnserializedMessageContext::Tag kMessageTag;
NativeFileSystemEntry_UnserializedMessageContext(
uint32_t message_name,
uint32_t message_flags,
UserType input)
: mojo::internal::UnserializedMessageContext(&kMessageTag, message_name, message_flags)
, user_data_(std::move(input)) {}
~NativeFileSystemEntry_UnserializedMessageContext() override = default;
UserType TakeData() {
return std::move(user_data_);
}
private:
// mojo::internal::UnserializedMessageContext:
void Serialize(mojo::internal::SerializationContext* context,
mojo::internal::Buffer* buffer) override {
NativeFileSystemEntry_Data::BufferWriter writer;
mojo::internal::Serialize<DataView>(user_data_, buffer, &writer, context);
}
UserType user_data_;
};
template <typename UserType, typename DataView>
const mojo::internal::UnserializedMessageContext::Tag
NativeFileSystemEntry_UnserializedMessageContext<UserType, DataView>::kMessageTag = {};
#pragma pack(pop)
} // namespace internal
} // namespace mojom
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_MOJOM_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_DIRECTORY_HANDLE_MOJOM_SHARED_INTERNAL_H_ |
de043ed3743ff3787efb101acb7fa406290d77ec | 389126d9baf09ce8b9c6fd642026b9221cbbd149 | /EACRipper/Dialog.h | df167faee60c16de5401f4e5ab70231557dbe381 | [] | no_license | nitric1/EACRipper | c4e559586d011766251fea139902e90eeda9350a | ffb778887455062f060cb241cd7abcf462e8b3ff | refs/heads/master | 2021-01-18T01:41:00.146200 | 2012-09-02T04:48:38 | 2012-09-02T04:48:38 | 1,365,535 | 8 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 547 | h | Dialog.h | #pragma once
#include "Window.h"
namespace EACRipper
{
class Dialog : public Window
{
private:
enum { WM_APP_ENDDIALOG = WM_APP + 100 };
private:
std::vector<uint8_t> dlgData;
bool isDialogEnded;
intptr_t endDialogResult;
protected:
explicit Dialog(HWND = nullptr);
virtual ~Dialog() = 0;
protected:
virtual const wchar_t *getDialogName() = 0;
virtual const void *getDialogTemplateWithSystemFont();
virtual HWND getItemWindow(int32_t);
intptr_t showModal(DLGPROC, int = SW_SHOW);
bool endDialog(intptr_t);
};
};
|
51d331dcae6a51014289027395b4feab4726c30f | 529d508ab420872fd34f95fe680e2b61e75d55e4 | /dbms/src/Formats/BlockOutputStreamFromRowOutputStream.cpp | d2542d96c76a2251ead792b59560b52d26eb654f | [
"Apache-2.0"
] | permissive | filimonov/ClickHouse | 55c78adf722a9df45b19be3bc171810eb44b37df | c036cb103ba5fa9cd85dc377fff5182627cd7afa | refs/heads/master | 2023-09-03T16:46:23.889293 | 2018-12-10T12:54:48 | 2018-12-10T12:54:48 | 114,752,158 | 4 | 2 | Apache-2.0 | 2019-06-21T12:46:04 | 2017-12-19T10:33:51 | C++ | UTF-8 | C++ | false | false | 1,440 | cpp | BlockOutputStreamFromRowOutputStream.cpp | #include <Core/Block.h>
#include <Formats/BlockOutputStreamFromRowOutputStream.h>
namespace DB
{
BlockOutputStreamFromRowOutputStream::BlockOutputStreamFromRowOutputStream(RowOutputStreamPtr row_output_, const Block & header_)
: row_output(row_output_), header(header_) {}
void BlockOutputStreamFromRowOutputStream::write(const Block & block)
{
size_t rows = block.rows();
size_t columns = block.columns();
for (size_t i = 0; i < rows; ++i)
{
if (!first_row)
row_output->writeRowBetweenDelimiter();
first_row = false;
row_output->writeRowStartDelimiter();
for (size_t j = 0; j < columns; ++j)
{
if (j != 0)
row_output->writeFieldDelimiter();
auto & col = block.getByPosition(j);
row_output->writeField(*col.column, *col.type, i);
}
row_output->writeRowEndDelimiter();
}
}
void BlockOutputStreamFromRowOutputStream::setRowsBeforeLimit(size_t rows_before_limit)
{
row_output->setRowsBeforeLimit(rows_before_limit);
}
void BlockOutputStreamFromRowOutputStream::setTotals(const Block & totals)
{
row_output->setTotals(totals);
}
void BlockOutputStreamFromRowOutputStream::setExtremes(const Block & extremes)
{
row_output->setExtremes(extremes);
}
void BlockOutputStreamFromRowOutputStream::onProgress(const Progress & progress)
{
row_output->onProgress(progress);
}
}
|
5d806b2d628827110bec14bc173aae39f9838304 | aaeeb54ded4fa3829bfe5da8e50f44822ed2d1ab | /The Problem 6(structures).cpp | 0cb0b45c0700d667636a7b9ada963462663e5f63 | [] | no_license | PPPPParadise/IntroductionToCoding | b32b3e54f4d0f92ce23fc27f43a251307320735d | c1a0b9195b71923683bd59e74a35aaae6947ed93 | refs/heads/master | 2021-07-11T02:26:31.994843 | 2017-10-13T22:40:58 | 2017-10-13T22:40:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 693 | cpp | The Problem 6(structures).cpp | #include <string>
#include <iostream>
using namespace std;
struct class1
{int ID;
string name;
int points;};
int main()
{ int i,n,maximum;
cout<<"Please input the size of the class"<<endl;
cin>>n;
class1 student[n];
for(i=0;i<n;i++)
{
cout<<"student "<<i<<"'s "<<"ID ";
cin>>student[i].ID;
cout<<"student "<<i<<"'s "<<"name ";
cin>>student[i].name;
cout<<"student "<<i<<"'s "<<"points ";
cin>>student[i].points;
cout<<endl;
}
maximum=student[0].points;
for(i=0;i<n-1;i++)
{
if (student[i].points<=student[i+1].points)
maximum=student[i+1].points;
}
cout<<"The maximum point is "<<maximum<<endl;
return 0;
}
|
d07bbee143fd19df441630d9ffaeec733275f57c | 5669216e2725494f5af6f8093a536eb2e1945cd2 | /Arduino Code/Voice/speechRecognition/speechRecognition.ino | 4f70a563773b1ddd30693bd6be3c043730173758 | [] | no_license | benjofisch/inch | 623d7d4f40058e66927836a6276a7061e8a9c814 | fc8593644da8bc57d4e49962c5e4b2a82962681e | refs/heads/master | 2021-01-19T23:06:18.302247 | 2017-04-21T02:24:07 | 2017-04-21T02:24:07 | 88,921,221 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,476 | ino | speechRecognition.ino |
#include "Arduino.h"
#include <Wire.h>
#include "SoftwareSerial.h"
// Shield Jumper on SW (using pins 12/13 or 8/9 as RX/TX)
SoftwareSerial port(12, 13);
#define pcSerial SERIAL_PORT_MONITOR
#define ADDRESS 13
#define DEBUG 1
#include "EasyVR.h"
EasyVR easyvr(port);
int group;
int idx;
int word1, word2, word3;
int x, y;
double scale;
int8_t lang = 0;
int command[4];
int x_joy = 128, y_joy = 128;
void setup() {
pcSerial.begin(9600);
port.begin(9600);
Wire.begin(ADDRESS);
Wire.onRequest(requestEvent);
TWAR = (MY_ADDRESS << 1) | 1;
// run normally
pcSerial.println(F("---"));
pcSerial.println(F("Bridge not started!"));
while (!easyvr.detect())
{
pcSerial.println(F("EasyVR not detected!"));
delay(1000);
}
easyvr.setPinOutput(EasyVR::IO1, LOW);
pcSerial.print(F("EasyVR detected, version "));
pcSerial.println(easyvr.getID());
easyvr.setTimeout(1);
lang = EasyVR::ENGLISH;
easyvr.setLanguage(lang);
const char* ws0[] =
{
"ROBOT",
};
const char* ws1[] =
{
"ACTION",
"MOVE",
"TURN",
"RUN",
"LOOK",
"ATTACK",
"STOP",
"HELLO",
};
const char* ws2[] =
{
"LEFT",
"RIGHT",
"UP",
"DOWN",
"FORWARD",
"BACKWARD",
};
const char* ws3[] =
{
"ZERO",
"ONE",
"TWO",
"THREE",
"FOUR",
"FIVE",
"SIX",
"SEVEN",
"EIGHT",
"NINE",
"TEN",
};
const char** ws[] = { ws0, ws1, ws2, ws3 };
easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)
pcSerial.println("Waiting for activation");
idx = -1;
while (idx != 0) {
easyvr.recognizeWord(0);
while (!easyvr.hasFinished());
idx = easyvr.getWord();
}
pcSerial.println(idx);
idx = -1;
while (idx != 0) {
easyvr.recognizeWord(1);
while (!easyvr.hasFinished());
idx = easyvr.getWord();
}
pcSerial.println("VR on and ready");
scale = .5;
}
void loop() {
easyvr.recognizeWord(1);
while (!easyvr.hasFinished());
word1 = easyvr.getWord();
if(word1 == 1){
Serial.print("move ");
}
if(word1 == 2){
Serial.print("turn ");
}
if(word1 == 3){
Serial.print("run ");
}
if(word1 == 6){
Serial.print("stop ");
}
switch (word1) { //First word
case 1: //Move
easyvr.recognizeWord(2);
while (!easyvr.hasFinished());
word2 = easyvr.getWord();
// Serial.println(word2);
switch (word2) {
case 4: //Forward
x = 0;
y = 128;
Serial.println("moveForward");
break;
case 5: //Backward
x = 0;
y = -128;
Serial.println("moveBackward");
break;
}
break;
// action(x,y,scale);
case 2: //Turn
easyvr.recognizeWord(2);
while (!easyvr.hasFinished());
word2 = easyvr.getWord();
// Serial.println(word2);
switch (word2) {
case 0: //Left
x = -128;
y = 0;
Serial.println("turnLeft");
break;
case 1: //Right
x = 127;
y = 0;
Serial.println("turnRight");
break;
}
break;
// action(x,y,scale);
case 3:
easyvr.recognizeWord(3);
while (!easyvr.hasFinished());
word2 = easyvr.getWord();
Serial.println(word2);
switch (word2) {
case 0:
scale = 0;
break;
case 1:
scale = .1;
break;
case 2:
scale = .2;
break;
case 3:
scale = 0.3;
break;
case 4:
scale = 0.4;
break;
case 5:
scale = 0.5;
break;
case 6:
scale = 0.6;
break;
case 7:
scale = 0.7;
break;
case 8:
scale = 0.8;
break;
case 9:
scale = 0.9;
break;
case 10:
scale = 1;
break;
}
// action(x,y,scale);
break;
case 6:
// action(0,0,scale);
break;
}
}
//void action(int x, int y, double scale) {
// int x_joy = 128 + x * scale;
// int y_joy = 128 + y * scale;
// Wire.write(x_joy);
// Wire.write(y_joy);
//}
void requestEvent(){
x_joy = 128 + x * scale;
y_joy = 128 + y * scale;
Wire.write(x_joy);
Wire.write(y_joy);
}
|
6614776eb11c7a1e9f7612e5f2ccf2b5a2906a2a | 52377fae2f8155f68594fa7675a5c9bbc60e09ae | /ardynia/src/entities/sword.cpp | 20ad685b591a796d7757ccd733884447a8e3eb7f | [
"MIT"
] | permissive | Pharap/ardynia | 862cf40f3ed2db1181f7fd77db97fc1f8e869a9e | e07fafd1d076481c6fe3c0f85695c98e2dc976d6 | refs/heads/master | 2023-04-27T10:57:37.313871 | 2021-05-13T15:35:17 | 2021-05-13T15:35:17 | 367,087,560 | 1 | 0 | NOASSERTION | 2021-05-13T15:12:18 | 2021-05-13T15:12:18 | null | UTF-8 | C++ | false | false | 938 | cpp | sword.cpp | #include "sword.h"
#include "../util.h"
EntityType Sword::update(Entity* me, Entity& player, uint8_t frame) {
int16_t px = player.x;
int8_t py = player.y;
switch (player.dir) {
case LEFT:
me->x = px - 18;
me->y = py - 4;
me->currentFrame = 0;
me->mirror = 0;
break;
case RIGHT:
me->x = px + 11;
me->y = py - 4;
me->currentFrame = 0;
me->mirror = MIRROR_HORIZONTAL;
break;
case UP:
me->x = px - 5;
me->y = py - 22;
me->currentFrame = 1;
me->mirror = MIRROR_VERTICAL;
break;
case DOWN:
me->x = px - 1;
me->y = py + 6;
me->currentFrame = 1;
me->mirror = 0;
break;
}
if (--me->duration == 0) {
me->type = UNSET;
}
return UNSET;
}
|
d1a8bc440bccd43c4629fc98e5c1bf858d7e4adb | 011c66eaeb32f1855022810a897d6de96140828b | /src/RemoteGyro.h | 5150e329ed1367ebabb1941d22698047c4adc7c3 | [] | no_license | Bearbotics-2358/Smokey-VIII | d7b5a42bd4c0143a06d37be8f67f889686431dea | 27e113a1fd8aceb3a4f26021f9b8645743372fe5 | refs/heads/master | 2021-01-21T21:39:16.282840 | 2016-03-10T00:51:45 | 2016-03-10T00:51:45 | 29,067,824 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 322 | h | RemoteGyro.h | #ifndef _REMOTE_GYRO_H_
#define _REMOTE_GYRO_H_
#include <atomic>
#include <thread>
class RemoteGyro {
public:
RemoteGyro();
~RemoteGyro();
double GetAngle();
private:
void Run();
// ZeroMQ data
void *_ctx;
void *_sub;
std::atomic<double> _angle;
std::thread _thread;
};
#endif // _REMOTE_GYRO_H_
|
dcb0db619d8d9c08e395269c527d43258b6c9ee5 | d61bef1c247c2d454612f37055ef2555802f1ca2 | /139.cc | 365ebe73f36c67602611c2e393f8b70aeaded137 | [] | no_license | li-chunyu/leetcode | 14abb171c70981445ec2c47aafc8940610227cc3 | b7156943519f13542986b5da0baabde6a3bb120c | refs/heads/master | 2021-07-23T11:46:59.921027 | 2021-05-28T05:02:28 | 2021-05-28T05:02:28 | 69,959,598 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 494 | cc | 139.cc | class Solution {
public:
bool wordBreak(string s, vector<string>& wordDict) {
s = " " + s;
vector<bool> dp(s.size(), false);
dp[0] = true;
for (int i = 1; i < dp.size(); ++i) {
for (auto w : wordDict) {
if (w.size() <= i && s.substr(i-w.size()+1, w.size()) == w){
dp[i] = dp[i-w.size()];
if (dp[i]) break;
}
}
}
return dp[dp.size() - 1];
}
}; |
39fd3b5cacc8ef62bbc065bbc4b4b7ce74c39a10 | 8ee0be0b14ec99858712a5c37df4116a52cb9801 | /Client/Sfx/SFXManager.h | c559d54529da09942cf8b31f862b333c673a227f | [] | no_license | eRose-DatabaseCleaning/Sources-non-evo | 47968c0a4fd773d6ff8c9eb509ad19caf3f48d59 | 2b152f5dba3bce3c135d98504ebb7be5a6c0660e | refs/heads/master | 2021-01-13T14:31:36.871082 | 2019-05-24T14:46:41 | 2019-05-24T14:46:41 | 72,851,710 | 6 | 3 | null | 2016-11-14T23:30:24 | 2016-11-04T13:47:51 | C++ | UTF-8 | C++ | false | false | 1,266 | h | SFXManager.h | #ifndef _SFX_MANAGER_
#define _SFX_MANAGER_
#include <list>
#include "../Util/JSingleton.h"
class ISFX;
//-------------------------------------------------------------------------------------------
///
/// class CSFXManager
/// @brief manager of sfx in game.
///
//-------------------------------------------------------------------------------------------
class CSFXManager : public CJSingleton< CSFXManager >
{
private:
std::list< ISFX* > m_SFXList;
public:
CSFXManager(void);
~CSFXManager(void);
//-----------------------------------------------------------------------------------------
/// General purpose..
//-----------------------------------------------------------------------------------------
void Update();
void Draw();
void Clear();
ISFX* AddSFX( ISFX* pSFX );
bool DeleteSFX( ISFX* pSFX );
ISFX* FindSFXWithType( int iSFXType );
//-----------------------------------------------------------------------------------------
/// Specific special effect
//-----------------------------------------------------------------------------------------
bool StartWideScreenEffect();
void StopWideScreenEffect();
};
#endif //_SFX_MANAGER_ |
a60aeb14dec5c925f6cf94f8b1a98feb83d47267 | 60359e93b6a33aefe6c1222a7bc09c84085ae07c | /sdk/System/PiProcess.h | c00c6da0d2086a2c28dbc81a94943c2224a745a5 | [] | no_license | 15831944/ncdb | 6d57eb9adc5eb4100ebde71e1421eb2e97ee39d9 | 5dabeaa0692af9bede5a4878bf5307cda667538f | refs/heads/master | 2021-07-05T11:03:47.811347 | 2017-09-29T09:23:47 | 2017-09-29T09:23:47 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 526 | h | PiProcess.h | #pragma once
#include "PiTypeDef.h"
#include "PiProcessDef.h"
Pi_NameSpace_Begin
class CPiProcess
{
public:
CPiProcess(void);
~CPiProcess(void);
public:
static bool IsProcessNameExist( tcpchar szProcessName );
static bool IsExistModule( tcpchar szModulePath );
//枚举获取进程ID
static bool EnumProcess(LST_HANDLE& pLstHandle);
static bool KillProcess( tcpchar szProcessName, bool bKillAll );
static bool IsProcessExistHandle( HANDLE hProcess , DWORD* pExitCode = NULL);
};
Pi_NameSpace_End
|
f2f0a61e8119469217e6d25eec5da1c5145124ac | 8f9737c22dd7fa4d18401cc20dcffa0cad4b13a2 | /src/Gibbs.hpp | 1825561aebf541f19c270f23b6a867182fdadbc0 | [] | no_license | JunwenBai/PIAFD | 7c7f0d6cb29ab4b25e8ca8f8bd8f297c3f45003f | 1c066bb8d11c6c2cf362c2c69511a61dd972082b | refs/heads/master | 2022-05-22T08:58:38.605313 | 2020-04-26T03:29:14 | 2020-04-26T03:29:14 | 258,930,270 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 514 | hpp | Gibbs.hpp | #pragma once
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <armadillo>
#include <queue>
// #include "Projection.hpp"
#include "KMax.hpp"
using namespace arma;
using namespace std;
class Gibbs
{
public:
static void relax(std::vector<mat> &H, int Q, int K, int N, int M, double epsilon, mat &Comp);
static void enforce(std::vector<mat> &H, int Q, int K, int N, int M, double epsilon, mat &Comp, double prop, bool hard = false);
};
|
ee69d50a70dfdc2211edc8e5b38fee4c05e94896 | 9c6850880976b0882236e2368a8120b955302abe | /AllJoyn/aj_sw_crypto.cpp | c3fdb8532b8620e5b9c11fe37fb2245f61d14dcf | [
"ISC"
] | permissive | neptcloud/Triton | 44ef3b6eb1efea5732f648f39df422d82ddfa161 | 9faeebe479db4fffb0d3f208d41388401696f651 | refs/heads/master | 2021-01-13T02:28:00.174382 | 2014-11-06T16:14:38 | 2014-11-06T16:14:38 | 24,129,185 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 11,220 | cpp | aj_sw_crypto.cpp | /**
* @file
*/
/******************************************************************************
* Copyright (c) 2013, AllSeen Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************************/
#include "aj_target.h"
#include "aj_crypto.h"
#define MAX_SCHEDULE_LEN 48
typedef struct {
uint32_t fkey[MAX_SCHEDULE_LEN];
} AES_CTX;
static AES_CTX aes_context;
#define ROTL8(x) ((((uint32_t)(x)) << 8) | (((uint32_t)(x)) >> 24))
#define ROTL16(x) ((((uint32_t)(x)) << 16) | (((uint32_t)(x)) >> 16))
#define ROTL24(x) ((((uint32_t)(x)) << 24) | (((uint32_t)(x)) >> 8))
#define SHFL8(x) (((uint32_t)(x)) << 8)
#define SHFL16(x) (((uint32_t)(x)) << 16)
#define SHFL24(x) (((uint32_t)(x)) << 24)
#define ROW_0(x) (uint8_t)(x)
#define ROW_1(x) (uint8_t)((x) >> 8)
#define ROW_2(x) (uint8_t)((x) >> 16)
#define ROW_3(x) (uint8_t)((x) >> 24)
/* The Rijndael S-box matrix */
static const uint8_t sbox[256] = {
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
};
static const uint32_t ftable[256] = {
0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6, 0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591,
0x50303060, 0x03010102, 0xa96767ce, 0x7d2b2b56, 0x19fefee7, 0x62d7d7b5, 0xe6abab4d, 0x9a7676ec,
0x45caca8f, 0x9d82821f, 0x40c9c989, 0x877d7dfa, 0x15fafaef, 0xeb5959b2, 0xc947478e, 0x0bf0f0fb,
0xecadad41, 0x67d4d4b3, 0xfda2a25f, 0xeaafaf45, 0xbf9c9c23, 0xf7a4a453, 0x967272e4, 0x5bc0c09b,
0xc2b7b775, 0x1cfdfde1, 0xae93933d, 0x6a26264c, 0x5a36366c, 0x413f3f7e, 0x02f7f7f5, 0x4fcccc83,
0x5c343468, 0xf4a5a551, 0x34e5e5d1, 0x08f1f1f9, 0x937171e2, 0x73d8d8ab, 0x53313162, 0x3f15152a,
0x0c040408, 0x52c7c795, 0x65232346, 0x5ec3c39d, 0x28181830, 0xa1969637, 0x0f05050a, 0xb59a9a2f,
0x0907070e, 0x36121224, 0x9b80801b, 0x3de2e2df, 0x26ebebcd, 0x6927274e, 0xcdb2b27f, 0x9f7575ea,
0x1b090912, 0x9e83831d, 0x742c2c58, 0x2e1a1a34, 0x2d1b1b36, 0xb26e6edc, 0xee5a5ab4, 0xfba0a05b,
0xf65252a4, 0x4d3b3b76, 0x61d6d6b7, 0xceb3b37d, 0x7b292952, 0x3ee3e3dd, 0x712f2f5e, 0x97848413,
0xf55353a6, 0x68d1d1b9, 0x00000000, 0x2cededc1, 0x60202040, 0x1ffcfce3, 0xc8b1b179, 0xed5b5bb6,
0xbe6a6ad4, 0x46cbcb8d, 0xd9bebe67, 0x4b393972, 0xde4a4a94, 0xd44c4c98, 0xe85858b0, 0x4acfcf85,
0x6bd0d0bb, 0x2aefefc5, 0xe5aaaa4f, 0x16fbfbed, 0xc5434386, 0xd74d4d9a, 0x55333366, 0x94858511,
0xcf45458a, 0x10f9f9e9, 0x06020204, 0x817f7ffe, 0xf05050a0, 0x443c3c78, 0xba9f9f25, 0xe3a8a84b,
0xf35151a2, 0xfea3a35d, 0xc0404080, 0x8a8f8f05, 0xad92923f, 0xbc9d9d21, 0x48383870, 0x04f5f5f1,
0xdfbcbc63, 0xc1b6b677, 0x75dadaaf, 0x63212142, 0x30101020, 0x1affffe5, 0x0ef3f3fd, 0x6dd2d2bf,
0x4ccdcd81, 0x140c0c18, 0x35131326, 0x2fececc3, 0xe15f5fbe, 0xa2979735, 0xcc444488, 0x3917172e,
0x57c4c493, 0xf2a7a755, 0x827e7efc, 0x473d3d7a, 0xac6464c8, 0xe75d5dba, 0x2b191932, 0x957373e6,
0xa06060c0, 0x98818119, 0xd14f4f9e, 0x7fdcdca3, 0x66222244, 0x7e2a2a54, 0xab90903b, 0x8388880b,
0xca46468c, 0x29eeeec7, 0xd3b8b86b, 0x3c141428, 0x79dedea7, 0xe25e5ebc, 0x1d0b0b16, 0x76dbdbad,
0x3be0e0db, 0x56323264, 0x4e3a3a74, 0x1e0a0a14, 0xdb494992, 0x0a06060c, 0x6c242448, 0xe45c5cb8,
0x5dc2c29f, 0x6ed3d3bd, 0xefacac43, 0xa66262c4, 0xa8919139, 0xa4959531, 0x37e4e4d3, 0x8b7979f2,
0x32e7e7d5, 0x43c8c88b, 0x5937376e, 0xb76d6dda, 0x8c8d8d01, 0x64d5d5b1, 0xd24e4e9c, 0xe0a9a949,
0xb46c6cd8, 0xfa5656ac, 0x07f4f4f3, 0x25eaeacf, 0xaf6565ca, 0x8e7a7af4, 0xe9aeae47, 0x18080810,
0xd5baba6f, 0x887878f0, 0x6f25254a, 0x722e2e5c, 0x241c1c38, 0xf1a6a657, 0xc7b4b473, 0x51c6c697,
0x23e8e8cb, 0x7cdddda1, 0x9c7474e8, 0x211f1f3e, 0xdd4b4b96, 0xdcbdbd61, 0x868b8b0d, 0x858a8a0f,
0x907070e0, 0x423e3e7c, 0xc4b5b571, 0xaa6666cc, 0xd8484890, 0x05030306, 0x01f6f6f7, 0x120e0e1c,
0xa36161c2, 0x5f35356a, 0xf95757ae, 0xd0b9b969, 0x91868617, 0x58c1c199, 0x271d1d3a, 0xb99e9e27,
0x38e1e1d9, 0x13f8f8eb, 0xb398982b, 0x33111122, 0xbb6969d2, 0x70d9d9a9, 0x898e8e07, 0xa7949433,
0xb69b9b2d, 0x221e1e3c, 0x92878715, 0x20e9e9c9, 0x49cece87, 0xff5555aa, 0x78282850, 0x7adfdfa5,
0x8f8c8c03, 0xf8a1a159, 0x80898909, 0x170d0d1a, 0xdabfbf65, 0x31e6e6d7, 0xc6424284, 0xb86868d0,
0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e, 0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c
};
static const uint32_t Rconst[12] =
{
0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8
};
#define round_column(x0, x1, x2, x3) \
ftable[ROW_0(x0)] ^ ROTL8(ftable[ROW_1(x1)]) ^ ROTL16(ftable[ROW_2(x2)]) ^ ROTL24(ftable[ROW_3(x3)])
/*
* yn are inputs xn are outputs
*/
#define round(y0, y1, y2, y3, x0, x1, x2, x3, key) \
y0 = round_column(x0, x1, x2, x3) ^ *key++; \
y1 = round_column(x1, x2, x3, x0) ^ *key++; \
y2 = round_column(x2, x3, x0, x1) ^ *key++; \
y3 = round_column(x3, x0, x1, x2) ^ *key++;
#define lastround_column(x0, x1, x2, x3) \
(uint32_t)sbox[ROW_0(x0)] ^ SHFL8(sbox[ROW_1(x1)]) ^ SHFL16(sbox[ROW_2(x2)]) ^ SHFL24(sbox[ROW_3(x3)])
/*
* yn are inputs xn are outputs
*/
#define lastround(y0, y1, y2, y3, x0, x1, x2, x3, key) \
y0 = lastround_column(x0, x1, x2, x3) ^ *key++; \
y1 = lastround_column(x1, x2, x3, x0) ^ *key++; \
y2 = lastround_column(x2, x3, x0, x1) ^ *key++; \
y3 = lastround_column(x3, x0, x1, x2) ^ *key++;
static void Pack32(uint32_t* u32, const uint8_t* u8)
{
#if HOST_IS_LITTLE_ENDIAN
memcpy(u32, u8, 16);
#else
int i;
for (i = 0; i < 4; ++i, ++u32, u8 += 4) {
*u32 = (uint32_t)u8[0] | (u8[1] << 8) | (u8[2] << 16) | (u8[3] << 24);
}
#endif
}
static void Unpack32(uint8_t* u8, const uint32_t* u32)
{
#if HOST_IS_LITTLE_ENDIAN
memcpy(u8, u32, 16);
#else
int i;
for (i = 0; i < 4; ++i, ++u32) {
*u8++ = (uint8_t)(*u32);
*u8++ = (uint8_t)(*u32 >> 8);
*u8++ = (uint8_t)(*u32 >> 16);
*u8++ = (uint8_t)(*u32 >> 24);
}
#endif
}
static uint32_t SubBytes(uint32_t a)
{
return (uint32_t)sbox[(uint8_t)(a)] | (sbox[(uint8_t)(a >> 8)] << 8) | (sbox[(uint8_t)(a >> 16)] << 16) | (sbox[(uint8_t)(a >> 24)] << 24);
}
#define ROUNDS 10
static void EncryptRounds(uint32_t* out, uint32_t* in, uint32_t* key)
{
int i;
uint32_t x0 = in[0];
uint32_t x1 = in[1];
uint32_t x2 = in[2];
uint32_t x3 = in[3];
uint32_t y0;
uint32_t y1;
uint32_t y2;
uint32_t y3;
for (i = 0; i < 4; i++) {
round(y0, y1, y2, y3, x0, x1, x2, x3, key);
round(x0, x1, x2, x3, y0, y1, y2, y3, key);
}
round(y0, y1, y2, y3, x0, x1, x2, x3, key);
lastround(x0, x1, x2, x3, y0, y1, y2, y3, key);
out[0] = x0;
out[1] = x1;
out[2] = x2;
out[3] = x3;
}
void AJ_AES_Enable(const uint8_t* key)
{
int i;
uint32_t* fkey = aes_context.fkey;
Pack32(fkey, key);
for (i = 0; i <= ROUNDS; ++i, fkey += 4) {
fkey[4] = fkey[0] ^ SubBytes(ROTL24(fkey[3])) ^ Rconst[i];
fkey[5] = fkey[1] ^ fkey[4];
fkey[6] = fkey[2] ^ fkey[5];
fkey[7] = fkey[3] ^ fkey[6];
}
}
void AJ_AES_Disable(void)
{
memset(&aes_context, 0, sizeof(aes_context));
}
void AJ_AES_CTR_128(const uint8_t* key, const uint8_t* in, uint8_t* out, uint32_t len, uint8_t* ctr)
{
uint32_t counter[4];
Pack32(counter, ctr);
while (len) {
uint32_t tmp[4];
uint32_t i;
uint32_t n = min(len, 16);
uint8_t* p = (uint8_t*)tmp;
for (i = 0; i < 4; ++i) {
tmp[i] = counter[i] ^ aes_context.fkey[i];
}
EncryptRounds(tmp, tmp, &aes_context.fkey[4]);
len -= n;
while (n--) {
*out++ = *p++ ^ *in++;
}
/*
* The counter field is big-endian (dumb idea given everything else is processed little endian)
*/
#if HOST_IS_LITTLE_ENDIAN
/*
* A big-endian increment of a 32 bit counter on a little-endian CPU.
* Only supports counter values up to 2^16 because that is all we need
*/
if (counter[3] == 0xFF000000) {
counter[3] += 0x00010000;
}
counter[3] += 0x01000000;
#else
counter[3] += 1;
#endif
}
Unpack32(ctr, counter);
}
void AJ_AES_CBC_128_ENCRYPT(const uint8_t* key, const uint8_t* in, uint8_t* out, uint32_t len, uint8_t* iv)
{
uint32_t xorbuf[4];
uint32_t ivt[4];
AJ_ASSERT((len % 16) == 0);
Pack32(ivt, iv);
while (len) {
int i;
Pack32(xorbuf, in);
for (i = 0; i < 4; ++i) {
xorbuf[i] ^= ivt[i] ^ aes_context.fkey[i];
}
EncryptRounds(ivt, xorbuf, &aes_context.fkey[4]);
Unpack32(out, ivt);
out += 16;
in += 16;
len -= 16;
}
Unpack32(iv, ivt);
}
void AJ_AES_ECB_128_ENCRYPT(const uint8_t* key, const uint8_t* in, uint8_t* out)
{
uint32_t in32[4];
uint32_t out32[4];
Pack32(in32, in);
EncryptRounds(out32, in32, &aes_context.fkey[4]);
Unpack32(out, out32);
}
|
faf92c22fea79606697a3afef9b80f6542a3f072 | 57a13f246da599958b39d9ea51922f2567b8ef7b | /function/function9.cpp | 055c9ac98aa6511fad79f3bd24ee4f3a349cb3a1 | [] | no_license | itsss/SASA_ComputingBasics | 01a580c403089c2fe54c77921626f8f1ced3e8f4 | d0c03b4aff86d0e323e956361952ceb13d72f643 | refs/heads/master | 2021-01-23T00:39:26.480897 | 2017-07-14T03:05:46 | 2017-07-14T03:05:46 | 92,827,072 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 322 | cpp | function9.cpp | #include <stdio.h>
void func01(void)
{
printf("func01\n");
}
void func02(int a)
{
printf("+_+: %d\n", a);
}
int func03(void)
{
return 2015;
}
int func04(int a, int b)
{
return a > b ? a - b : b - a;
}
int main(void)
{
func01();
func02(5);
printf("%d\n", func03());
printf("%d\n", func04(5, 10));
return 0;
}
|
ba8653b4a67221434ac2459f0ef4ecf445d0da01 | d75aebb3f082f445f1689d6a140320642dc62ef1 | /server/session_map.h | 35b6e2952657f9908afbc51effa8ee7ac47a2b47 | [
"MIT"
] | permissive | zhangjiexhx/niba2.0 | cee2df0fcdfef9508809b02963e50401b64bfc08 | 8421b2f5d3155d33723c2e85bfd92c2f1b63db4c | refs/heads/master | 2022-12-02T06:51:42.798389 | 2020-08-12T02:51:20 | 2020-08-12T02:51:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,292 | h | session_map.h | #pragma once
#include "logger.h"
#include <memory>
#include <shared_mutex>
#include <string>
#include <unordered_map>
namespace nibaserver {
class server_session;
// A map of user_id -> session ptr
// Needs to be thread safe
// forward declare as server_session also need a session_map
class session_map {
public:
using session_wptr = std::weak_ptr<server_session>;
session_map() = default;
session_map(const session_map &) = delete;
session_map &operator=(const session_map &) = delete;
// Write to session of given name, returns whether person is online
// (eg. session exists and not yet destroyed)
bool write(const std::string &name, std::string &&data);
// Clean up, remove empty weak_ptrs, need a timer to run this periodically
// not a huge concern for now
void cleanup();
// Register, session
// Once user logs in properly, add to map_
// if a valid entry exists, then deny the login
bool register_session(const std::string &name, session_wptr wptr);
// Attempt to remove a session, usually the session itself on destruction
void remove(const std::string& name);
private:
std::shared_mutex mutex_;
std::unordered_map<std::string, session_wptr> map_;
logger logger_;
};
} // namespace nibaserver |
a810eb58c3a30f435049d5d37d2ce1ac4ec93ab9 | 88741a823cd49b5667d7ea6a374cb722e316ef6c | /cipher.cpp | 1cb1dfeb4b2dc5d63f0fdf0619eb132302dd2522 | [] | no_license | t-joseph/systemC_CPU | 45a8ae1fdc164249bea5d2efb894995faa369b97 | cdbd76b4b5b56daf3a0220bd75bf1b90596920d3 | refs/heads/master | 2020-03-18T14:54:57.782076 | 2018-06-12T22:14:22 | 2018-06-12T22:14:22 | 134,874,885 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 559 | cpp | cipher.cpp | #include "key.h"
#include "controller.h"
#ifndef FIFO_LEN
#define FIFO_LEN 64
#endif
void MOD_NAME::Cipher_main(void) // Scoping operator(::) means that the thread Cipher_main belongs to Module Cipher
{
char var;
char result;
while(1){
wait(cipher_security_event);
wait(500, SC_MS);
for(int i=0; i<=FIFO_LEN; i++)
{
decipher_tdo.read(var);
if(decipher_tdo.num_available() == 0)
break;
result = char((int(var)+key2-32)%96+32);
dbg_o->write(result);
}
cipher_security_return_event.notify();
}
}
|
319f7638b70e96482f74a4b5a1f894f73deee845 | 2194cf0946da4bc571b125a28eccfc3dad430b20 | /bipartite_graph.cpp | ddd894ade86073b8a9589d9a215f1f6d3ab2585d | [] | no_license | 1779296311/luogu | a25801492aa79d29c24aa35bf4500883ac3557b8 | 3d75cdafd021aab31583629e86d777dcd5c16273 | refs/heads/master | 2023-03-04T18:52:13.827891 | 2021-02-13T19:13:11 | 2021-02-13T19:13:11 | 330,155,681 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,989 | cpp | bipartite_graph.cpp | /*********************************************
* ------------------------
* ------------------------
* file name: bipartite_graph.cpp
* author : @ JY
* date : 2021--01--16
**********************************************/
#include <bits/stdc++.h>
namespace p1963{
const int N = 1e5 + 12;
int head[N], ne[N << 4], to[ N << 4 ];
int vi[N], match[N];
int n, idx;
void _add(int x, int y){
to[++idx] = y;
ne[idx] = head[x];
head[x] = idx;
}
bool _dfs(int x, int id){
for(int i=head[x]; i; i=ne[i]){
int y = to[i];
if(vi[y] == id)continue;
vi[y] = id;
if(match[y]==-1 || _dfs(match[y], id)){
match[y] = x;
return true;
}
}
return false;
}
void _deal(){
std::cin >> n;
for(int i=0, k; i<n; ++i){
std::cin >> k;
int a = (i + k + n) % n, b = (i - k + n) % n;
if(a > b)std::swap(a, b);
_add(i, a), _add(i, b);
}
std::fill(match, match + 3*n, -1);
for(int i=n-1, id=1; i>=0; --i, ++id){
if(!_dfs(i, id)){
std::cout << "No Answer" << std::endl;
return ;
}
}
std::memset(vi, 0, sizeof vi);
for(int i=0; i<n; ++i){
if(match[i+n]!=-1)vi[match[i+n]] = i;
}
for(int i=0; i<n; ++i)std::cout << vi[i] << " ";
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p1129{
const int N = 512;
int g[N][N];
int vi[N], match[N];
int n, t;
void _init(){
std::memset(vi, 0, sizeof vi);
std::memset(g, 0, sizeof g);
std::memset(match, 0, sizeof match);
}
bool _dfs(int x, int id) {
for(int y=1; y<=n; ++y){
if(vi[y] == id || !g[x][y])continue;
vi[y] = id;
if(!match[y] || _dfs(match[y], id)){
match[y] = x;
return true;
}
}
return false;
}
void _read(){
std::cin >> n;
for(int i=1; i<=n; ++i){
for(int j=1; j<=n; ++j){
std::cin >> g[i][j];
}
}
}
bool _clac(){
for(int i=1,id=1; i<=n; ++i, ++id){
if(!_dfs(i, id))return false;
}
return true;
}
void _deal(){
std::cin >> t;
while(t--){
_init();
_read();
if(_clac()){
std::cout << "Yes" << std::endl;
}else{
std::cout << "No" << std::endl;
}
}
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p2149{
using pii = std::pair<int, int>;
const int N = 2048 << 1, INF = 1000010000;
int head[N], to[N << 12], ne[N << 12], cost[N << 12];
int d[4][N], vi[N], ok[N << 12], in[N];
int g[N], v[N];
int s1, t1, s2, t2;
int n, m, idx;
void _add(int x, int y, int v){
to[++idx] = y;
cost[idx] = v;
ne[idx] = head[x];
head[x] = idx;
}
void _dijkstra(int s, int k){
std::memset(d[k], 0x3f, sizeof d[k]);
std::memset(vi, 0, sizeof vi);
d[k][s] = 0;
std::priority_queue<pii,
std::vector<pii>, std::greater<pii>> q;
q.emplace(0, s);
while(q.size()){
int x = q.top().second;q.pop();
if(vi[x])continue;
vi[x] = 1;
for(int i=head[x]; i; i=ne[i]){
int y = to[i];
if(d[k][y] > d[k][x] + cost[i]){
d[k][y] = d[k][x] + cost[i];
q.emplace(d[k][y], y);
}
}
}
}
void _read(){
std::cin >> n >> m >> s1 >> t1 >> s2 >> t2;
for(int i=1, x, y, v; i<=m; ++i){
std::cin >> x >> y >> v;
_add(x, y, v), _add(y, x, v);
}
}
void _deal(){
_read();
_dijkstra(s1, 0), _dijkstra(t1, 1);
_dijkstra(s2, 2), _dijkstra(t2, 3);
for(int x=1; x<=n; ++x){
for(int i=head[x]; i; i=ne[i]){
int y = to[i];
if(d[0][x] + cost[i] + d[1][y] == d[0][t1]){
ok[i] = 1;
++in[y];
}
}
}
int ans = 0;
std::queue<int> q;
q.emplace(s1);
while(q.size()){
int x = q.front();q.pop();
ans = std::max({ans, g[x], v[x]});
for(int i=head[x]; i; i=ne[i]){
if(!ok[i])continue;
int y = to[i];
if(d[2][x] + cost[i] + d[3][y]==
d[2][t2]){
g[y] = std::max(g[y], g[x] + cost[i]);
}
if(d[3][x] + cost[i] + d[2][y]==
d[2][t2]){
v[y] = std::max(v[y], v[x] + cost[i]);
}
if(!--in[y])q.emplace(y);
}
}
std::cout << ans << std::endl;
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p2526{
using pii = std::pair<int, int>;
const int N = 1024;
int head[N], to[N << 4], ne[N << 4];
int vi[N << 4], match[ N << 4 ];
int n, m, idx;
pii p1[N], p2[N];
void _add(int x, int y){
to[++idx] = y;
ne[idx] = head[x];
head[x] = idx;
}
double _dis(const pii &i1, const pii &i2){
auto [x1, y1] = i1;
auto [x2, y2] = i2;
return sqrt( (x1-x2)*(x1-x2) +
(y1-y2)*(y1-y2) );
}
void _read(){
std::cin >> n >> m;
for(int i=1; i<=n; ++i){
std::cin >> p1[i].first >> p1[i].second;
}
for(int i=1; i<=m; ++i){
std::cin >> p2[i].first >> p2[i].second;
}
for(int i=1; i<n; ++i){
double d = _dis(p1[i], p1[i+1]);
for(int j=1; j<=m; ++j){
double d1 = _dis(p1[i], p2[j]) +
_dis(p1[i+1], p2[j]);
if(d * 2 < d1)continue;
_add(i, j + n);
}
}
}
bool _dfs(int x, int id) {
for(int i=head[x]; i; i=ne[i]){
int y = to[i];
if(vi[y] == id)continue;
vi[y] = id;
if(!match[y] || _dfs(match[y], id)){
match[y] = x;
return true;
}
}
return false;
}
void _deal(){
_read();
int ans = 0;
for(int i=1, id=1; i<=n; ++i, ++id){
ans += _dfs(i, id);
}
std::cout << ans + n << std::endl;
std::memset(vi, 0, sizeof vi);
for(int i=1; i<=m; ++i){
if(match[i+n])vi[match[i+n]] = i;
}
for(int i=1; i<=n; ++i){
std::cout << p1[i].first << " " << p1[i].second;
if(vi[i])std::cout << " " << p2[vi[i]].first << " " << p2[vi[i]].second;
std::cout << " ";
}
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p1640{
const int N = 1e6;
int head[N], ne[N << 3], to[N << 3];
int vi[N << 3], match[ N << 3 ];
int n, idx;
void _add(int x, int y){
to[++idx] = y;
ne[idx] = head[x];
head[x] = idx;
}
bool _dfs(int x, int id){
for(int i=head[x]; i; i=ne[i]){
int y = to[i];
if(!(vi[y] - id))continue;
vi[y] = id;
if(!match[y] || _dfs(match[y], id)){
match[y] = x;
return true;
}
}
return false;
}
void _deal(){
std::cin >> n;
for(int i=1, x, y; i<=n; ++i){
std::cin >> x >> y;
_add(x, i), _add(y, i);
}
int ans = 0;
for(int i=1,id=1; i<=10000; ++i, ++id){
if(!_dfs(i, id))break;
++ans;
}
std::cout << ans << std::endl;
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p2055{
const int N = 64;
int t, n;
int sc[N], hm[N], e[N][N];
int vi[N], match[N];
void _read(){
std::cin >> n;
for(int i=1; i<=n; ++i)std::cin >> sc[i];
for(int i=1; i<=n; ++i)std::cin >> hm[i];
for(int i=1; i<=n; ++i){
if(!sc[i])hm[i] = 0;
for(int j=1; j<=n; ++j){
std::cin >> e[i][j];
}
if(sc[i])e[i][i] = 1;
}
}
bool _dfs(int x){
for(int y=1; y<=n; ++y){
if(vi[y] || !e[x][y] || !sc[y])continue;
vi[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
return true;
}
}
return false;
}
void _init(){
std::memset(match, 0, sizeof match);
std::memset(e, 0, sizeof e);
}
bool _calc(){
for(int i=1; i<=n; ++i){
std::memset(vi, 0, sizeof vi);
if(!hm[i] && !_dfs(i))return false;
}
return true;
}
void _deal(){
std::cin >> t;
while(t--){
_init();
_read();
if(_calc()){
puts("^_^");
}else{
puts("T_T");
}
}
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p2071{
const int N = 2048 << 2;
int head[N], ne[N << 4], to[N << 4];
int match[N << 4], vi[ N << 4 ];
int n, idx;
bool _dfs(int x){
for(int i=head[x]; i; i=ne[i]){
int y = to[i];
if(vi[y])continue;
vi[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
return true;
}
}
return false;
}
void _add(int x, int y){
to[++idx] = y;
ne[idx] = head[x];
head[x] = idx;
}
void _deal(){
std::cin >> n;
for(int i=1, x, y; i<=n*2; ++i){
std::cin >> x >> y;
_add(i, x), _add(i, x + n);
_add(i, y), _add(i, y + n);
}
int ans = 0;
for(int i=1; i<=2*n; ++i){
std::memset(vi, 0, sizeof vi);
ans += _dfs(i);
}
std::cout << ans << std::endl;
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p1155{
const int N = 1024;
int head[N], ne[N << 4], to[N << 4];
int n, idx;
int color[N], nums[N];
void _add(int x, int y){
to[++idx] = y;
ne[idx] = head[x];
head[x] = idx;
}
bool _dfs(int x, int co){
color[x] = co;
for(int i=head[x], y; i; i=ne[i]){
y = to[i];
if(color[y] == color[x])return false;
if(!color[y] && !_dfs(y, 3-co))return false;
}
return true;
}
void _deal(){
int now = 1, min_ = INT_MAX;
std::cin >> n;
for(int i=1; i<=n; ++i)std::cin >> nums[i];
for(int i=1; i<n-1; ++i){
min_ = nums[n];
for(int j=n-1; j>i; --j){
if(nums[i] < nums[j] && min_ < nums[i]){
_add(i, j), _add(j, i);
}
min_ = std::min(min_, nums[j]);
}
}
for(int i=1; i<=n; ++i){
if(!color[i] && !_dfs(i, 1)){
std::cout << 0 << std::endl;
return ;
}
}
std::stack<int> s1, s2;
for(int i=1; i<=n+1; ++i){
if(color[i] == 1)std::cout << "a ", s1.push(nums[i]);
if(color[i] == 2)std::cout << "c ", s2.push(nums[i]);
int case1 = s1.size() && s1.top() == now;
int case2 = s2.size() && s2.top() == now;
while(case1 || case2){
if(case1)std::cout << "b ", s1.pop();
if(case2){
if(color[i+1] == 1)std::cout << "a ", s1.push(nums[++i]);
std::cout << "d ", s2.pop();
}
++now;
case1 = s1.size() && s1.top() == now;
case2 = s2.size() && s2.top() == now;
}
}
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p1263{
using pii = std::pair<int,int>;
const int N = 256 << 6;
int n, m, idx, code1, code2;
int head[N], ne[N << 10], to[N << 10];
int match[N << 10], vi[N << 10];
int e[N][N], mp1[N][N], mp2[N][N];
pii mp[N][N];
void _add(int x, int y){
to[++idx] = y;
ne[idx] = head[x];
head[x] = idx;
}
bool _dfs(int x){
for(int i=head[x], y; i; i=ne[i]){
y = to[i];
if(vi[y])continue;
vi[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
return true;
}
}
return false;
}
void _read(){
std::cin >> n >> m;
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j){
std::cin >> e[i][j];
}
}
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j){
if(e[i][j]==2)continue;
if(mp1[i][j-1]){
mp1[i][j] = mp1[i][j-1];
}else{
mp1[i][j] = ++code1;
}
if(mp2[i-1][j]){
mp2[i][j] = mp2[i-1][j];
}else{
mp2[i][j] = ++code2;
}
}
}
}
void _deal(){
_read();
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j){
if(e[i][j])continue;
_add(mp1[i][j], mp2[i][j]);
mp[mp1[i][j]][mp2[i][j]] = {i, j};
}
}
int ans = 0;
for(int i=1; i<=code1; ++i){
std::memset(vi, 0, sizeof vi);
ans += _dfs(i);
}
std::cout << ans << std::endl;
for(int i=1; i<=code2; ++i){
if(!match[i])continue;
auto [x, y] = mp[match[i]][i];
std::cout << x << " " << y <<std::endl;
if(!ans--)break;
}
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p1263_fuck{
using pii = std::pair<int, int>;
const int N = 256;
int n, m, code, code1, code2;
int e[N][N], g[N][N], mp1[N][N], mp2[N][N];
int vi[N << 5], match[N << 5];
pii mp[N][N];
bool _dfs(int x){
for(int y=1; y<=code; ++y){
if(vi[y] || !g[x][y])continue;
vi[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
return true;
}
}
return false;
}
void _read(){
std::cin >> n >> m;
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j){
std::cin >> e[i][j];
}
}
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j){
if(e[i][j] == 2)continue;
if(mp1[i][j-1]){
mp1[i][j] = mp1[i][j-1];
}else{
mp1[i][j] = ++code1;
}
if(mp2[i-1][j]){
mp2[i][j] = mp2[i-1][j];
}else{
mp2[i][j] = ++code2;
}
}
}
code = std::max(code1, code2);
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j){
if(e[i][j])continue;
int c1 = mp1[i][j], c2 = mp2[i][j];
g[c1][c2] = 1;
mp[c1][c2] = {i, j};
}
}
}
void _deal(){
_read();
int ans = 0;
for(int i=1; i<=code; ++i){
std::memset(vi, 0, sizeof vi);
ans += _dfs(i);
}
std::cout << ans << std::endl;
for(int i=1; i<=code; ++i){
if(!match[i])continue;
auto [x,y] = mp[match[i]][i];
std::cout << x << " " << y << std::endl;
if(!ans--)break;
}
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p4014{
const int N = 128;
int e[N][N], match[N], va[N], vb[N];
int la[N], lb[N], upd[N];
int n;
bool _dfs(int x){
va[x] = 1;
for(int y=1; y<=n; ++y){
if(vb[y])continue;
if(la[x] + lb[y] == e[x][y]){
vb[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
return true;
}
}else{
upd[y] = std::min(upd[y], la[x]+lb[y]-e[x][y]);
}
}
return false;
}
int _km(){
for(int i=1; i<=n; ++i){
la[i] = -(1 << 30);
match[i] = lb[i] = 0;
for(int j=1; j<=n; ++j){
la[i] = std::max(la[i], e[i][j]);
}
}
for(int i=1; i<=n; ++i){
while(true){
std::memset(va, 0, sizeof va);
std::memset(vb, 0, sizeof vb);
for(int j=1; j<=n; ++j)upd[j] = INT_MAX;
if(_dfs(i))break;
int delta = INT_MAX;
for(int j=1; j<=n; ++j){
if(!vb[j])delta = std::min(delta, upd[j]);
}
for(int j=1; j<=n; ++j){
if(va[j])la[j] -= delta;
if(vb[j])lb[j] += delta;
}
}
}
int ans = 0;
for(int i=1; i<=n; ++i)ans += e[match[i]][i];
return ans;
}
void _deal(){
int ans1, ans2;
std::cin >> n;
for(int i=1; i<=n; ++i){
for(int j=1; j<=n; ++j){
std::cin >> e[i][j];
}
}
ans2 = _km();
for(int i=1; i<=n; ++i){
for(int j=1; j<=n; ++j){
e[i][j] *= -1;
}
}
ans1 = -_km();
std::cout << ans1 << std::endl;
std::cout << ans2 << std::endl;
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p2319{
const int N = 1024;
int head[N], to[N << 11] , ne[N << 11];
int n, m, idx;
int match[N << 11], vi[N << 11], res[N << 11];
void _add(int x, int y){
to[++idx] = y;
ne[idx] = head[x];
head[x] = idx;
}
bool _dfs(int x){
for(int i=head[x], y; i; i=ne[i]){
y = to[i];
if(vi[y])continue;
vi[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
res[x] = y;
return true;
}
}
return false;
}
void _deal(){
std::cin >> n >> m;
for(int i=1, x, y; i<=m; ++i){
std::cin >> x >> y;
_add(i, ++x), _add(i, ++y);
}
int ans = 0;
for(int i=1; i<=m; ++i){
std::memset(vi, 0, sizeof vi);
if(!_dfs(i))break;
++ans;
}
std::cout << ans << std::endl;
for(int i=1; i<=ans; ++i){
std::cout << res[i]-1 << std::endl;
}
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p2756{
#include <bits/stdc++.h>
const int N = 128 << 1;
int n, m;
int e[N][N], vi[N << 2], match[N << 2];
bool _dfs(int x){
for(int y=m+1; y<=n; ++y){
if(vi[y] || !e[x][y])continue;
vi[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
return true;
}
}
return false;
}
void _deal(){
std::cin >> m >> n;
for(int x, y ; ;){
std::cin >> x >> y;
if(x==-1 || y==-1)break;
e[x][y] = 1;
}
int ans = 0;
for(int i=1; i<=m; ++i){
std::memset(vi, 0, sizeof vi);
ans += _dfs(i);
}
std::cout << ans << std::endl;
for(int i=m+1; i<=n; ++i){
if(!match[i])continue;
std::cout << match[i] << " " << i << std::endl;
}
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p3386{
const int N = 512;
int head[N << 2], ne[N << 4], to[N << 4];
int n, m, e, idx;
int vi[N << 2], match[N << 2];
void _add(int x, int y){
to[++idx] = y;
ne[idx] = head[x];
head[x] = idx;
}
bool _dfs(int x){
for(int i=head[x]; i; i=ne[i]){
int y = to[i];
if(vi[y])continue;
vi[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
return true;
}
}
return false;
}
void _deal(){
std::cin >> n >> m >> e;
for(int i=0, x, y; i<e; ++i){
std::cin >> x >> y;
if(x>n || y>m)continue;
_add(x, y+n);
}
int ans = 0;
for(int i=1; i<=n; ++i){
std::memset(vi, 0, sizeof vi);
ans += _dfs(i);
}
std::cout << ans << std::endl;
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
namespace p2764{
const int N = 256;
int n, m;
int e[N][N], vi[N], match[N], ed[N];
std::vector<int> pa[N];
int _dfs(int x){
for(int y=1; y<=n; ++y){
if(!e[x][y] || vi[y])continue;
vi[y] = 1;
if(!match[y] || _dfs(match[y])){
match[y] = x;
return true;
}
}
return false;
}
void _deal(){
std::cin >> n >> m;
for(int i=0, x, y; i<m; ++i){
std::cin >> x >> y;
e[x][y] = 1;
}
int ans = n;
for(int i=1; i<=n; ++i){
std::memset(vi, 0, sizeof vi);
ans -= _dfs(i);
}
std::memset(vi, 0, sizeof vi);
for(int i=1; i<=n; ++i)vi[match[i]] = 1;
for(int i=1, k=0; i<=n; ++i){
if(!vi[i])ed[++k] = i;
}
for(int i=1; i<=ans; ++i){
pa[i].push_back(ed[i]);
while(match[ed[i]]){
ed[i] = match[ed[i]];
pa[i].push_back(ed[i]);
}
}
for(int i=1; i<=ans; ++i){
for(int j=pa[i].size()-1; j>=0; --j){
std::cout << pa[i][j] << " ";
}
std::cout << std::endl;
}
std::cout << ans << std::endl;
}
int main(int argc,const char *argv[]){
_deal();
return 0;
}
};
|
0bb48a6a7832465c60e20940672a1a3820ac3cfc | 22a5d5b013e856b714b526f1b166881c38253a98 | /Tests/EnemyTankTest.cpp | 60663937714c149c713d73ca1aa0d22b48ea51df | [] | no_license | teo3fl/Battle-City | 8e3ba7f0b5c51c5b6237fa1792de23bc27c8fda9 | 921f51a9a2d3648394bdfc0528f3ad4efd272a04 | refs/heads/main | 2023-07-10T09:49:48.172968 | 2020-01-21T13:03:29 | 2020-01-21T13:03:29 | 399,222,430 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 603 | cpp | EnemyTankTest.cpp | #include "pch.h"
#include "CppUnitTest.h"
#include "ArmorTank.h"
#include "BasicTank.h"
#include "FastTank.h"
#include "PowerTank.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace Tests
{
TEST_CLASS(EnemyTankTest)
{
public:
TEST_METHOD(BasicTankType)
{
BasicTank basicTank;
Assert::IsTrue(basicTank.GetType() == "BasicTank");
}
TEST_METHOD(FastTankSpeed)
{
FastTank fastTank;
Assert::IsTrue(fastTank.GetMovement() == 150.f);
}
TEST_METHOD(PowerTankPoints)
{
PowerTank powerTank;
Assert::IsTrue(powerTank.GetPoints() == 300);
}
};
}
|
abbf9e40cfbf7c2829b02ec2f5aa227dab1383b2 | 5857ccbf6ddc65e80ae0284df70b47653bd36c22 | /cses1196.cpp | 1b3ae2c8159f99175ca056422beb7d86cf431e8d | [] | no_license | ernest-lu/cses | cc771d6d88fbf5fdf4c8bff292eacd6a79379ce1 | 601713607379e6042c04aba0187922938cfb0627 | refs/heads/master | 2022-12-13T23:20:46.951099 | 2020-09-11T19:22:56 | 2020-09-11T19:22:56 | 269,250,929 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,115 | cpp | cses1196.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
typedef pair<LL, pii> ppi;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second
//var
LL n, k, m, t1, t2, t3;
vector<pii> e[100005];
LL dis[100005][15];
priority_queue<ppi, vector<ppi>, greater<ppi>> dij;
bool v[100005][15];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
FOR(i, m){
cin >> t1 >> t2 >> t3;
e[t1].pb(mp(t3, t2));
}
dij.push(mp(0, mp(1,1)));
while(!dij.empty()){
ppi tt = dij.top();
dij.pop();
for(int i = tt.s.s; i<=k; i++){
if(v[tt.s.f][i]) continue;
tt.s.s = i;
break;
}
if(v[tt.s.f][tt.s.s]) continue;
//cout << tt.s.f << " " << tt.s.s << " " << tt.f << endl;
v[tt.s.f][tt.s.s] = 1; dis[tt.s.f][tt.s.s] = tt.f;
for(auto u : e[tt.s.f]){
FOR(i, k){
if(v[u.s][i]) continue;
dij.push(mp(tt.f + u.f, mp(u.s,i)));
break;
}
}
}
FOR(i, k)
cout << dis[n][i] << " ";
cout << endl;
cout.flush();
return 0;
} |
95d435e45411e9bee8b2317976f2fd7e6584304a | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/httpd/gumtree/httpd_old_log_2141.cpp | 49cc42f91bb96e8de56a70aec4cc13771f62f595 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 103 | cpp | httpd_old_log_2141.cpp | printf("Server loaded: APR %s, APR-Util %s\n",
apr_version_string(), apu_version_string()); |
7af223699876f92bbd5d997dd853fca8e3e73152 | d96ebf4dac46404a46253afba5ba5fc985d5f6fc | /third_party/libwebrtc/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.cc | d91c6c9aec875ce5004c0275f72a0b6109aa5fde | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | marco-c/gecko-dev-wordified-and-comments-removed | f9de100d716661bd67a3e7e3d4578df48c87733d | 74cb3d31740be3ea5aba5cb7b3f91244977ea350 | refs/heads/master | 2023-08-04T23:19:13.836981 | 2023-08-01T00:33:54 | 2023-08-01T00:33:54 | 211,297,165 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,011 | cc | cord_rep_consume.cc | #
include
"
absl
/
strings
/
internal
/
cord_rep_consume
.
h
"
#
include
<
array
>
#
include
<
utility
>
#
include
"
absl
/
container
/
inlined_vector
.
h
"
#
include
"
absl
/
functional
/
function_ref
.
h
"
#
include
"
absl
/
strings
/
internal
/
cord_internal
.
h
"
namespace
absl
{
ABSL_NAMESPACE_BEGIN
namespace
cord_internal
{
namespace
{
CordRep
*
ClipSubstring
(
CordRepSubstring
*
substring
)
{
CordRep
*
child
=
substring
-
>
child
;
if
(
substring
-
>
refcount
.
IsOne
(
)
)
{
delete
substring
;
}
else
{
CordRep
:
:
Ref
(
child
)
;
CordRep
:
:
Unref
(
substring
)
;
}
return
child
;
}
}
void
Consume
(
CordRep
*
rep
ConsumeFn
consume_fn
)
{
size_t
offset
=
0
;
size_t
length
=
rep
-
>
length
;
if
(
rep
-
>
tag
=
=
SUBSTRING
)
{
offset
+
=
rep
-
>
substring
(
)
-
>
start
;
rep
=
ClipSubstring
(
rep
-
>
substring
(
)
)
;
}
consume_fn
(
rep
offset
length
)
;
}
void
ReverseConsume
(
CordRep
*
rep
ConsumeFn
consume_fn
)
{
return
Consume
(
rep
std
:
:
move
(
consume_fn
)
)
;
}
}
ABSL_NAMESPACE_END
}
|
cb8b86d3e16607bf1b6e7c6a1e8daa126670db20 | db507912e598b291811a5a73db5f8ba33c8be2f9 | /client/win/Utility.cpp | 568e67a88b58bb0a3c05503987f9a8bc60559eef | [] | no_license | biniyu/k-line-print | ab3ee023876adaa9de8dd98b14dbd362a0b2810a | d1e033f79044d6ae62f86e6116cc902b6a7eeb83 | refs/heads/master | 2016-09-06T14:19:55.887544 | 2013-08-25T14:59:21 | 2013-08-25T14:59:21 | 40,391,671 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 12,470 | cpp | Utility.cpp | #include "StdAfx.h"
#include "KLinePrint.h"
#include "Utility.h"
#include "direct.h"
#include "io.h"
#include <fstream>
#include <sstream>
using namespace std;
Utility::Utility(void)
{
}
Utility::~Utility(void)
{
}
int CStringToInt(const CString& str)
{
int ip = atoi((LPCTSTR)str);
return ip;
}
string CStringTostring(const CString& str)
{
return string(LPCTSTR(str));
}
CString IntToCString(int nInt)
{
CString str;
str.Format(_T("%d"), nInt);
return str;
}
int GetFileSize(string dir, string filename)
{
vector<string> vecFiles;
if(_chdir(dir.c_str())) return 0;
else
{
long hFile;
_finddata_t fileinfo;
if((hFile = _findfirst(filename.c_str(), &fileinfo))!= -1)
{
_findclose(hFile);
return fileinfo.size;
}
return 0;
}
}
vector<string> GetFiles(string dir, string filter, bool bDir)
{
vector<string> vecFiles;
if(_chdir(dir.c_str())) return vecFiles;
else
{
long hFile;
_finddata_t fileinfo;
if((hFile = _findfirst(filter.c_str(), &fileinfo))!= -1)
{
do
{
if(!strcmp(".", fileinfo.name)) continue;
if(!strcmp("..", fileinfo.name)) continue;
if((bDir && (fileinfo.attrib & _A_SUBDIR))
|| (!bDir && !(fileinfo.attrib & _A_SUBDIR)))
{
vecFiles.push_back(string(fileinfo.name));
}
} while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
return vecFiles;
}
string Utility::GetProgramPath()
{
char szPath[MAX_PATH];
GetModuleFileNameA(NULL, szPath, MAX_PATH);
string PathName(szPath);
size_t npos = PathName.find_last_of('\\');
return PathName.substr(0, npos + 1);
}
void Utility::GetInfoByPath(string path, string& rootdir,
string& market, string& contract, int& date)
{
size_t posDot = path.find_last_of('.');
size_t posBackSlash = path.find_last_of('\\');
string filename = path.substr(posBackSlash+1, posDot - posBackSlash - 1);
string sub1 = path.substr(0, posBackSlash);
posBackSlash = sub1.find_last_of('\\');
string sub2 = sub1.substr(0, posBackSlash);
posBackSlash = sub2.find_last_of('\\');
string sub3 = sub2.substr(0, posBackSlash);
posBackSlash = sub3.find_last_of('\\');
market = sub3.substr(sub3.size()-2, 2);
rootdir = sub3.substr(0, posBackSlash);
size_t posUnderScore = filename.find_last_of('_');
string dateTmp = filename.substr(posUnderScore + 1);
date = atoi(dateTmp.c_str());
contract = filename.substr(0, posUnderScore);
}
vector<string> Utility::GetAllContractPath(string path)
{
int date;
char buf[512];
vector<string> contracts;
string rootdir, contract, var, market, final;
GetInfoByPath(path, rootdir, market, contract, date);
// 合约最后两位是月份
var = contract.substr(0, contract.size() - 2);
// 处理跨年合约
if(var[var.size() - 1] == 'X'
|| var[var.size() - 1] == 'Y')
{
var = var.substr(0, var.size() - 1);
}
// 在该目录搜索最大的文件(需要过滤掉MI,PI,VI文件)
vector<string> vecFiles;
sprintf(buf, "%s\\%s\\%s%d\\%d\\",
rootdir.c_str(),
market.c_str(),
market.c_str(),
date/100,
date);
string dir = buf;
sprintf(buf, "%s*_%d.csv",
var.c_str(),
date);
vecFiles = GetFiles(dir, buf, false);
for(int i = 0; i < vecFiles.size(); i++)
{
// 过滤PI/MI/VI文件
if((vecFiles[i].find("PI_") != string::npos)
|| (vecFiles[i].find("MI_") != string::npos)
|| (vecFiles[i].find("VI_") != string::npos)) continue;
contracts.push_back(dir + vecFiles[i]);
}
return contracts;
}
string Utility::GetMajorContractPath(string path)
{
int date;
char buf[512];
string rootdir, contract, var, market, final;
GetInfoByPath(path, rootdir, market, contract, date);
// 合约最后两位是月份
var = contract.substr(0, contract.size() - 2);
// 处理跨年合约
if(var[var.size() - 1] == 'X'
|| var[var.size() - 1] == 'Y')
{
var = var.substr(0, var.size() - 1);
}
// 在该目录搜索最大的文件(需要过滤掉MI,PI,VI文件)
vector<string> vecFiles;
sprintf(buf, "%s\\%s\\%s%d\\%d\\",
rootdir.c_str(),
market.c_str(),
market.c_str(),
date/100,
date);
string dir = buf;
sprintf(buf, "%s*_%d.csv",
var.c_str(),
date);
vecFiles = GetFiles(dir, buf, false);
int nMaxFileSize = 0;
int nMaxFileIndex = -1;
for(int i = 0; i < vecFiles.size(); i++)
{
// 过滤PI/MI/VI文件
if((vecFiles[i].find("PI_") != string::npos)
|| (vecFiles[i].find("MI_") != string::npos)
|| (vecFiles[i].find("VI_") != string::npos)) continue;
int nFileSize = GetFileSize(dir, vecFiles[i]);
if(nFileSize > nMaxFileSize)
{
nMaxFileSize = nFileSize;
nMaxFileIndex = i;
}
}
if(nMaxFileIndex == -1) return "";
else return dir + vecFiles[nMaxFileIndex];
}
string Utility::GetDayLinePath(string path)
{
int date;
char buf[512];
string rootdir, contract, market;
GetInfoByPath(path, rootdir, market, contract, date);
sprintf(buf, "%s\\DAY\\%s%s.TXT",
rootdir.c_str(),
market.c_str(),
contract.c_str());
return string(buf);
}
int Utility::GetDateByPath(string path)
{
int date;
string rootdir, contract, market;
if(!path.size()) return -1;
GetInfoByPath(path, rootdir, market, contract, date);
return date;
}
string Utility::GetPathByDate(string org_path, int date)
{
char buf[512];
int tmp;
string rootdir, contract, market;
GetInfoByPath(org_path, rootdir, market, contract, tmp);
sprintf(buf, "%s\\%s\\%s%d\\%d\\%s_%d.csv",
rootdir.c_str(),
market.c_str(),
market.c_str(),
date/100,
date,
contract.c_str(),
date);
return string(buf);
}
string Utility::GetNeighborCsvFile(string path, bool bPrev, bool bZhuLi)
{
int date;
char buf[512];
string rootdir, contract, market;
Utility::GetInfoByPath(path, rootdir, market, contract, date);
int nNeighDate;
if(bPrev)
nNeighDate = CALENDAR.GetPrev(date);
else
nNeighDate = CALENDAR.GetNext(date);
if(nNeighDate < 0) return "";
sprintf(buf, "%s\\%s\\%s%d\\%d\\%s_%d.csv",
rootdir.c_str(),
market.c_str(),
market.c_str(),
nNeighDate/100,
nNeighDate,
contract.c_str(),
nNeighDate);
if(bZhuLi) /* 搜索主力合约 */
{
return Utility::GetMajorContractPath(buf);
}
else
{
return string(buf);
}
}
int Utility::ConvDispTimeToContTime(int disp)
{
int tmphour, tmpmin, tmpsec;
tmphour = disp / 10000;
tmpmin = disp % 10000 / 100;
tmpsec = disp % 10000 % 100;
return tmphour * 3600 + tmpmin * 60 + tmpsec;
}
int Utility::ConvContTimeToDispTime(int cont)
{
int tmphour, tmpmin, tmpsec;
tmphour = cont / 3600;
tmpmin = cont % 3600 / 60;
tmpsec = cont % 3600 % 60;
return tmphour * 10000 + tmpmin * 100 + tmpsec;
}
int Utility::GetWeekDayByDate(int nDate)
{
// w=y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1
int c = nDate / 1000000;
int y = nDate % 1000000 / 10000;
int m = nDate % 1000000 % 10000 / 100;
int d = nDate % 1000000 % 10000 % 100;
if(m <= 2)
{
m += 12;
y -= 1;
}
int weekday = (y + y/4 + c/4 - 2*c + 26*(m+1)/10 + d-1) % 7;
if(weekday < 0)
{
weekday += 7;
}
return weekday;
}
#define CONFIG_FILE ((Utility::GetProgramPath() + "klinep.ini").c_str())
void WritePrivateProfileIntA(LPCSTR lpAppName, LPCSTR lpKeyName, INT nDefault, LPCSTR lpFileName)
{
char buf[64];
sprintf(buf, "%d", nDefault);
WritePrivateProfileStringA(lpAppName, lpKeyName, buf, lpFileName);
}
int Utility::ReadBalance()
{
return GetPrivateProfileIntA("Exchange","Balance", 50000, CONFIG_FILE);
}
void Utility::WriteBalance(int nBalance)
{
WritePrivateProfileIntA("Exchange","Balance", nBalance, CONFIG_FILE);
}
// 读入交易参数
TradeParam Utility::ReadExchangeConfig()
{
TradeParam tp;
tp.nFee = GetPrivateProfileIntA("Exchange","Fee", 10, CONFIG_FILE);
tp.nMarginRate = GetPrivateProfileIntA("Exchange","Margin", 12, CONFIG_FILE);
tp.nUnitsPerSlot = GetPrivateProfileIntA("Exchange","UnitsPerSlot", 5, CONFIG_FILE);
tp.nDefaultSlots = GetPrivateProfileIntA("Exchange","DefaultSlots", 1, CONFIG_FILE);
tp.nMaxLossStop = GetPrivateProfileIntA("Trade","MaxLoss", 200, CONFIG_FILE);
tp.nMaxProfitStop = GetPrivateProfileIntA("Trade","MaxProfit", 200, CONFIG_FILE);
tp.nTimeStop = GetPrivateProfileIntA("Trade","TimeStop", 120, CONFIG_FILE);
tp.nMaxOpenTimes = GetPrivateProfileIntA("Trade","MaxOpenTimes", 3, CONFIG_FILE);
tp.nMaxLossPerDay = GetPrivateProfileIntA("Trade","MaxLossPerDay", 1000, CONFIG_FILE);
tp.bForceCloseOnBreak = GetPrivateProfileIntA("Trade","CloseOnBreak", 1, CONFIG_FILE);
return tp;
}
void Utility::WriteExchangeConfig(TradeParam tp)
{
WritePrivateProfileIntA("Exchange","Fee", tp.nFee, CONFIG_FILE);
WritePrivateProfileIntA("Exchange","Margin", tp.nMarginRate, CONFIG_FILE);
WritePrivateProfileIntA("Exchange","UnitsPerSlot", tp.nUnitsPerSlot, CONFIG_FILE);
WritePrivateProfileIntA("Exchange","DefaultSlots", tp.nDefaultSlots, CONFIG_FILE);
WritePrivateProfileIntA("Trade","MaxLoss", tp.nMaxLossStop, CONFIG_FILE);
WritePrivateProfileIntA("Trade","MaxProfit", tp.nMaxProfitStop, CONFIG_FILE);
WritePrivateProfileIntA("Trade","TimeStop", tp.nTimeStop, CONFIG_FILE);
WritePrivateProfileIntA("Trade","MaxOpenTimes", tp.nMaxOpenTimes, CONFIG_FILE);
WritePrivateProfileIntA("Trade","MaxLossPerDay", tp.nMaxLossPerDay, CONFIG_FILE);
WritePrivateProfileIntA("Trade","CloseOnBreak", tp.bForceCloseOnBreak, CONFIG_FILE);
}
// 读入回放配置
PlaybackConfig Utility::ReadPlaybackConfig()
{
PlaybackConfig pc;
pc.nStartDate = GetPrivateProfileIntA("Playback","StartDate", 0, CONFIG_FILE);
pc.nEndDate = GetPrivateProfileIntA("Playback","EndDate", 0, CONFIG_FILE);
pc.nStartTime = GetPrivateProfileIntA("Playback","StartTime", 0, CONFIG_FILE);
pc.nEndTime = GetPrivateProfileIntA("Playback","EndTime", 0, CONFIG_FILE);
pc.bDayOfWeek[1] = GetPrivateProfileIntA("Playback","Monday", 0, CONFIG_FILE);
pc.bDayOfWeek[2] = GetPrivateProfileIntA("Playback","Tuesday", 0, CONFIG_FILE);
pc.bDayOfWeek[3] = GetPrivateProfileIntA("Playback","Wednesday", 0, CONFIG_FILE);
pc.bDayOfWeek[4] = GetPrivateProfileIntA("Playback","Thursday", 0, CONFIG_FILE);
pc.bDayOfWeek[5] = GetPrivateProfileIntA("Playback","Friday", 0, CONFIG_FILE);
pc.bRealTime = GetPrivateProfileIntA("Playback","RealTime", 1, CONFIG_FILE);
pc.nPlaySpeed = GetPrivateProfileIntA("Playback","Speed", 1, CONFIG_FILE);
return pc;
}
// 保存回放配置
void Utility::SavePlaybackConfig(PlaybackConfig pc)
{
WritePrivateProfileIntA("Playback","RealTime", pc.bRealTime, CONFIG_FILE);
WritePrivateProfileIntA("Playback","Speed", pc.nPlaySpeed, CONFIG_FILE);
WritePrivateProfileIntA("Playback","StartDate", pc.nStartDate, CONFIG_FILE);
WritePrivateProfileIntA("Playback","EndDate", pc.nEndDate, CONFIG_FILE);
WritePrivateProfileIntA("Playback","StartTime", pc.nStartTime, CONFIG_FILE);
WritePrivateProfileIntA("Playback","EndTime", pc.nEndTime, CONFIG_FILE);
WritePrivateProfileIntA("Playback","Monday", (int)pc.bDayOfWeek[1], CONFIG_FILE);
WritePrivateProfileIntA("Playback","Tuesday", (int)pc.bDayOfWeek[2], CONFIG_FILE);
WritePrivateProfileIntA("Playback","Wednesday", (int)pc.bDayOfWeek[3], CONFIG_FILE);
WritePrivateProfileIntA("Playback","Thursday", (int)pc.bDayOfWeek[4], CONFIG_FILE);
WritePrivateProfileIntA("Playback","Friday", (int)pc.bDayOfWeek[5], CONFIG_FILE);
}
void Utility::WriteLog(string path, TradeRecord tr)
{
ofstream outfile;
outfile.open(path.c_str(),ios::app);
outfile << tr.nRealDate << " " << tr.nRealTime << " " << tr.sFileName << " "
<< tr.nSimuTime << " " << tr.nPrice << " "
<< tr.bBuy << " " << tr.bOpen << " " << tr.nSlot << " "
<< tr.nFee << " " << tr.nProfit << endl;
outfile.close();
}
void Utility::ReadLog(string path, vector<TradeRecord>& trs)
{
#define SZ 1024
ifstream in;
char buf[SZ];
TradeRecord tr(TRADE_CODE_SUCCESS);
in.open(path.c_str());
while(in.getline(buf,SZ))
{
stringstream ss(buf);
ss >> tr.nRealDate >> tr.nRealTime >> tr.sFileName
>> tr.nSimuTime >> tr.nPrice >> tr.bBuy >> tr.bOpen
>> tr.nSlot >> tr.nFee >> tr.nProfit;
trs.push_back(tr);
}
}
|
7491979fdc6b3fd6667069e726d43b1d449eb3e2 | 72742d4ee57fb66cfe3f10290ccb596dcde1e59e | /HackerRank/weekly/w12/c.cpp | b08e658a578e2f2f828b8c385a3f3c6a63d477e0 | [] | no_license | mertsaner/Algorithms | cd5cf84548ea10aafb13b4a3df07c67c1a007aef | f7aecb7e8aadff1e9cf49cc279530bc956d54260 | refs/heads/master | 2023-03-18T03:18:26.122361 | 2016-02-14T22:48:31 | 2016-02-14T22:48:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 748 | cpp | c.cpp | #include <iostream>
#include <vector>
#include <set>
using namespace std;
vector<int> edges[1000001];
set<int> noin;
bool found[1000001];
int ind[1000001];
int main()
{
int n,k,t,l,node;
cin >> n;
for(int i=0;i<n;i++)
{
cin >> k;
for(int j=0;j<k;j++)
{
cin >> t;
if(j>0)
{
ind[t]++;
edges[l].push_back(t);
}
l=t;
found[t]=true;
}
}
for(int i=0;i<1000001;i++)
if(found[i] && !ind[i])
noin.insert(i);
set<int>::iterator it;
while(!noin.empty())
{
it = noin.begin();
node = *it;
noin.erase(it);
cout << node << ' ';
for(int i=0;i<edges[node].size();i++)
{
ind[edges[node][i]]--;
if(ind[edges[node][i]]==0)
noin.insert(edges[node][i]);
}
}
cout << endl;
return 0;
}
|
5d19eed649f76bc1af710b3b955125ad22985036 | ac4bc337b1007723f3eb2a248e7649df8807a6af | /deleteElements.cpp | fd5a738b9fdf388f27cd361da3efaf0e38cbf5d1 | [] | no_license | pickou/leetcode | 9d1357a783b35be14abcfef942616f7b54b90fbf | 8f00d225fcd296655c4c4d008f72a2f697c85238 | refs/heads/master | 2021-05-12T05:40:35.753985 | 2018-08-02T09:37:46 | 2018-08-02T09:37:46 | 117,200,598 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,011 | cpp | deleteElements.cpp | /*
Remove all elements from a linked list of integers that have value val.
Example
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
Return: 1 --> 2 --> 3 --> 4 --> 5
*/
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
if(head==NULL) return NULL;
ListNode *node=head, *throwNode;
while(head->val==val) {
throwNode = head;
head = head->next;
delete throwNode;
if(head==NULL) return NULL;
}
node = head;
while(node!=NULL&&node->next!=NULL) {
if(node->next->val == val)// delete node
{
throwNode = node->next;
node->next = node->next->next;
delete throwNode;
}
else node = node->next;
}
return head;
}
};
|
1f85488962f15abb8cb3a8590b86bb7b98dc2ac8 | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /third_party/skia/include/views/SkOSWindow_Unix.h | 9d1b8e0392964a0c6e7039bbb95c366f334fd55b | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 1,998 | h | SkOSWindow_Unix.h | /*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkOSWindow_Unix_DEFINED
#define SkOSWindow_Unix_DEFINED
#include <GL/glx.h>
#include <X11/Xlib.h>
#include "SkWindow.h"
class SkEvent;
struct SkUnixWindow {
Display* fDisplay;
Window fWin;
size_t fOSWin;
GC fGc;
GLXContext fGLContext;
};
class SkOSWindow : public SkWindow {
public:
SkOSWindow(void*);
~SkOSWindow();
void* getHWND() const { return (void*)fUnixWindow.fWin; }
void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
void* getUnixWindow() const { return (void*)&fUnixWindow; }
void loop();
enum SkBackEndTypes {
kNone_BackEndType,
kNativeGL_BackEndType,
#if SK_ANGLE
kANGLE_BackEndType,
#endif // SK_ANGLE
};
bool attach(SkBackEndTypes attachType, int msaaSampleCount, bool deepColor, AttachmentInfo*);
void release();
void present();
int getMSAASampleCount() const { return fMSAASampleCount; }
//static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
bool makeFullscreen();
void setVsync(bool);
void closeWindow();
protected:
// Overridden from from SkWindow:
void onSetTitle(const char title[]) override;
private:
enum NextXEventResult {
kContinue_NextXEventResult,
kQuitRequest_NextXEventResult,
kPaintRequest_NextXEventResult
};
NextXEventResult nextXEvent();
void doPaint();
void mapWindowAndWait();
// Forcefully closes the window. If a graceful shutdown is desired then call the public
// closeWindow method
void internalCloseWindow();
void initWindow(int newMSAASampleCount, AttachmentInfo* info);
SkUnixWindow fUnixWindow;
// Needed for GL
XVisualInfo* fVi;
// we recreate the underlying xwindow if this changes
int fMSAASampleCount;
typedef SkWindow INHERITED;
};
#endif
|
c760e402317de13d66d572a4145726fd3fea28f5 | c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64 | /Engine/Source/ThirdParty/PhysX/PhysX_3.4/Source/PhysXExtensions/src/ExtFixedJoint.h | 1ba8778c67fef1395eea1b950ae4dc679e625cd8 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | windystrife/UnrealEngine_NVIDIAGameWorks | c3c7863083653caf1bc67d3ef104fb4b9f302e2a | b50e6338a7c5b26374d66306ebc7807541ff815e | refs/heads/4.18-GameWorks | 2023-03-11T02:50:08.471040 | 2022-01-13T20:50:29 | 2022-01-13T20:50:29 | 124,100,479 | 262 | 179 | MIT | 2022-12-16T05:36:38 | 2018-03-06T15:44:09 | C++ | UTF-8 | C++ | false | false | 5,508 | h | ExtFixedJoint.h | // This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef NP_FIXEDJOINTCONSTRAINT_H
#define NP_FIXEDJOINTCONSTRAINT_H
#include "ExtJoint.h"
#include "PxFixedJoint.h"
#include "CmUtils.h"
namespace physx
{
struct PxFixedJointGeneratedValues;
namespace Ext
{
struct FixedJointData : public JointData
{
//= ATTENTION! =====================================================================================
// Changing the data layout of this class breaks the binary serialization format. See comments for
// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
// accordingly.
//==================================================================================================
PxReal projectionLinearTolerance;
PxReal projectionAngularTolerance;
};
typedef Joint<PxFixedJoint, PxFixedJointGeneratedValues> FixedJointT;
class FixedJoint : public FixedJointT
{
//= ATTENTION! =====================================================================================
// Changing the data layout of this class breaks the binary serialization format. See comments for
// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
// accordingly.
//==================================================================================================
public:
// PX_SERIALIZATION
FixedJoint(PxBaseFlags baseFlags) : FixedJointT(baseFlags) {}
virtual void exportExtraData(PxSerializationContext& context) const;
void importExtraData(PxDeserializationContext& context);
void resolveReferences(PxDeserializationContext& context);
static FixedJoint* createObject(PxU8*& address, PxDeserializationContext& context);
static void getBinaryMetaData(PxOutputStream& stream);
//~PX_SERIALIZATION
virtual ~FixedJoint()
{
if(getBaseFlags()&PxBaseFlag::eOWNS_MEMORY)
PX_FREE(mData);
}
PxReal getProjectionLinearTolerance() const;
void setProjectionLinearTolerance(PxReal tolerance);
PxReal getProjectionAngularTolerance() const;
void setProjectionAngularTolerance(PxReal tolerance);
FixedJoint(const PxTolerancesScale& /*scale*/,
PxRigidActor* actor0, const PxTransform& localFrame0,
PxRigidActor* actor1, const PxTransform& localFrame1)
: FixedJointT(PxJointConcreteType::eFIXED, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE)
{
FixedJointData* data = reinterpret_cast<FixedJointData*>(PX_ALLOC(sizeof(FixedJointData), "FixedJointData"));
Cm::markSerializedMem(data, sizeof(FixedJointData));
mData = data;
data->projectionLinearTolerance = 1e10f;
data->projectionAngularTolerance = PxPi;
initCommonData(*data, actor0, localFrame0, actor1, localFrame1);
}
bool attach(PxPhysics &physics, PxRigidActor* actor0, PxRigidActor* actor1);
static const PxConstraintShaderTable& getConstraintShaderTable() { return sShaders; }
virtual PxConstraintSolverPrep getPrep() const { return sShaders.solverPrep; }
private:
static PxConstraintShaderTable sShaders;
PX_FORCE_INLINE FixedJointData& data() const
{
return *static_cast<FixedJointData*>(mData);
}
};
} // namespace Ext
namespace Ext
{
extern "C" PxU32 FixedJointSolverPrep(Px1DConstraint* constraints,
PxVec3& body0WorldOffset,
PxU32 maxConstraints,
PxConstraintInvMassScale& invMassScale,
const void* constantBlock,
const PxTransform& bA2w,
const PxTransform& bB2w);
// global function to share the joint shaders with API capture
extern "C" const PxConstraintShaderTable* GetFixedJointShaderTable();
}
}
#endif
|
cb1917c722743cdaa5531e729e9f256d7c5ad419 | 475897accc433baa4ab4b681b40193fa80276d6f | /Queue/Source.cpp | 9217f1e2910f6322af8aa0516af27f0d1e2df6e8 | [] | no_license | DangNguyen146/WeCode | aa1a136408df33510a4f3c677bbce629d557048a | 08f8fbe03f046aa3af29477af81a42a295dde557 | refs/heads/master | 2022-11-18T22:15:51.598818 | 2020-07-07T17:32:12 | 2020-07-07T17:32:12 | 277,856,916 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 661 | cpp | Source.cpp | #include<iostream>
using namespace std;
struct node
{
int key;
node* pNext;
};
struct Queue
{
node* pHead;
node* pTail;
};
void CreateQueue(Queue& q)
{
q.pHead = q.pTail = NULL;
}
node* GetNode(int x)
{
node* p = new node;
if (p == NULL)
exit(-1);
p->key = x;
p->pNext = NULL;
return p;
}
void EnQueue(Queue& q, node* p)
{
if (q.pHead == NULL)
{
q.pHead = q.pTail = p;
}
else
{
q.pTail->pNext = p;
q.pTail = p;
}
}
int DeQueue(Queue& q)
{
if (q.pHead != NULL)
{
node* p = q.pHead;
q.pHead = q.pHead->pNext;
int x = p->key;
delete p;
if (q.pHead == NULL)
q.pHead = q.pTail = NULL;
return x;
}
}
int main()
{
return 0;
} |
8c6764be4c96b6231bd6fe2e56a01552b44e4d86 | cfc920c6f428a0bb92b430448df4af38cd7bc971 | /GOF/抽象工厂AbstractFactory/cpp/maze/wall.h | 14491f56c9e1c00b5b4aa67c836a624d60726748 | [] | no_license | whywhywhywhygo/Design-Patterns | 386af210fdce40462bbbd967bd2a8487caac4a89 | 8d89569890277df6955569258be4d1dce5ef52af | refs/heads/master | 2020-04-28T14:44:19.315438 | 2019-04-02T01:12:53 | 2019-04-02T01:12:53 | 175,347,250 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 194 | h | wall.h | //
// Created by gaojian on 19-2-27.
//
#ifndef CPP_WALL_H
#define CPP_WALL_H
#include "mapsite.h"
class Wall : public MapSite {
public:
~Wall() override = default;
};
#endif //CPP_WALL_H
|
2df68ba142d088f9aca573d68e9be8d7404cb1a4 | 0679e995ea3ed3015359ddaea64901d82ca6a187 | /src/is_class.cpp | c773b8ae5c32e0487ae7e820245ffbffc0035d2e | [] | no_license | pangsanjin/practice_interation_gtest | 467ac8ed0d257d800b2154be30e0afffb364b13c | 853a51af7796dd96c7094084c373b56e3d4bf4be | refs/heads/master | 2020-07-06T22:55:52.658887 | 2019-08-19T12:22:21 | 2019-08-19T12:22:21 | 203,164,430 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,209 | cpp | is_class.cpp | //
// Created by xxx on 2019/8/19.
//
#include <iostream>
#include "../deps/googletest/googletest/include/gtest/gtest.h"
using namespace std;
template<typename T>
class IsClassT {
private:
typedef char One;
typedef struct { char a[2]; } Two;
template<typename C> static One test(int C::*);
template<typename C> static Two test(...);
public:
enum { Yes = sizeof(test<T>(0)) == 1 };
enum { No = !Yes };
};
class MyClass {
};
struct MyStruct {
};
union MyUnion {
};
void myfunc()
{
}
enum E { e1 } e;
// check by passing type as template argument
template <typename T>
void check()
{
if (IsClassT<T>::Yes) {
std::cout << " IsClassT " << std::endl;
}
else {
std::cout << " !IsClassT " << std::endl;
}
}
// check by passing type as function call argument
template <typename T>
void checkT(T)
{
check<T>();
}
TEST(is_class, t1)
{
std::cout << "int: ";
check<int>();
std::cout << "MyClass: ";
check<MyClass>();
std::cout << "MyStruct:";
MyStruct s;
checkT(s);
std::cout << "MyUnion: ";
check<MyUnion>();
std::cout << "enum: ";
checkT(e);
std::cout << "myfunc():";
checkT(myfunc);
} |
865e6bd736ed2c4832be0b4f4ce9aab5f001f486 | 70886f0e37bf919c8b17b5c58dd6764057166809 | /youtubeC++/vectorOne.cpp | 325ebec6fe200a0cee2a48769001bc1fd6f3e790 | [] | no_license | pritamSarkar123/linux_c- | eeb97d2467fbdc06880b21588f7a4d208ae80df1 | 3c5bffd9e6ce45db2e58140cec363ca407d60d76 | refs/heads/master | 2022-11-01T17:10:48.249517 | 2020-06-11T16:17:46 | 2020-06-11T16:17:46 | 268,751,417 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 708 | cpp | vectorOne.cpp | #include<iostream>
#include<vector>
using std::cout;
using std::cin;
using std::vector;
using std::endl;
void print_vectorVal(vector<int> data){
data.push_back(12);
for(int i=0;i<data.size();i++){
cout<<data[i]<<"\t";
}
cout<<endl;
}
void print_vectorRef(vector<int> &data){
data.push_back(12);
for(int i=0;i<data.size();i++){
cout<<data[i]<<"\t";
}
cout<<endl;
}
int main(){
vector<int> dataOne={1,2,3};
vector<int> dataTwo={4,5,6};
int count=0;
while(count<4){
cout<<"Function One"<<endl;
print_vectorVal(dataOne);
cout<<"Function Two"<<endl;
print_vectorRef(dataTwo);
count++;
}
return 0;
} |
d0d46cd2a970f78d013c2326cce63fbf847ff0b5 | ef5fe6b55f3d9a697392a252617e1dc79b184222 | /AtCoder/ABC164/D.cpp | 558b66a946136c864536fd830540ba8990fc4012 | [] | no_license | kunichan9292/Programing-contest | 15110f1dbf00a9957d524c6163cd165b3828803f | 9126d5c63b80f170de8108ca74c7ae7a2bf9c921 | refs/heads/master | 2022-06-18T04:40:45.662188 | 2020-05-12T19:49:16 | 2020-05-12T19:49:16 | 263,432,210 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 459 | cpp | D.cpp | #include<iostream>
#include<algorithm>
using namespace std;
int main(){
string S;
cin >> S;
if(S.size()==1 || S.size()==2 || S.size()==3){
cout << 0 << endl;
}
else{
int count=0;
for(int i=4;i<=S.size();i++){
for(int j=0;j<S.size()-(i-1);j++){
string A;
for(int k=j;k<i+j;k++){
A += S.at(k);
}
long long B=stoi(A);
if(B%2019==0){
count++;
}
}
}
}
}
|
6db471f21a9e6155dd4a9d2d2cccaa83f5a5170c | 602310e1e4c2380d6982e71e758b038b618f79a1 | /UIUC_ICPC_FA_16_ADV_SEP_26/C.cpp | 7cbafc48e452393a929544aaef0f181c065dd868 | [] | no_license | 15joeybloom/ICPC | f8f35cbade6ce124927f37590ccbb16c846e9d19 | e83a7cadb7feecb6f8639f7fe917f8f52c5b00be | refs/heads/master | 2021-01-13T01:11:10.605516 | 2018-11-13T22:11:00 | 2019-01-20T11:55:37 | 52,038,228 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 597 | cpp | C.cpp | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <queue>
#include <cstring>
#include <iterator>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
int main()
{
int H;
char path[50];
memset(path, 0, sizeof(path));
scanf("%d %s", &H, path);
int depth = strlen(path);
LL x = 1;
for(int i = 0; i < depth; i++)
{
x <<= 1;
if(path[i] == 'R')
x++;
}
printf("%d\n", (1<<(H+1))-x);
}
|
6d302d43463c0d1107ba2ade6dea4e7449237c66 | d60e722dee815d123d757fe2bd77e10758379166 | /CPP/OOP/1102/1102/Creatures.cpp | e2cf821a23ff0f508774894c42fd42a94be1bfd8 | [] | no_license | LJP-TW/NTUST | 54998e3869ca5f5dd05a1601bd1c90179f39f519 | 02063b7e5c589949ca7ae16481812c811bbcbec2 | refs/heads/master | 2021-04-26T22:55:03.861434 | 2019-10-27T09:03:12 | 2019-10-27T09:03:12 | 123,893,438 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 793 | cpp | Creatures.cpp | // Name: ±i®Ñ»Ê B10615025
// Date: 2018/5/19
// Last Update: 2018/5/19
// Problem statement: Creatures
#include "Creatures.h"
Creature::Creature() : strength(10), hitpoints(10)
{
}
Creature::Creature(int newStrength, int newHit) : strength(newStrength), hitpoints(newHit)
{
}
int Creature::getDamage()
{
int damage;
// All creatures inflict damage which is a
// random number up to their strength
damage = (rand() % strength) + 1;
return damage;
}
string Creature::getSpecies()
{
return string("Unknown");
}
void Creature::setStrength(int strength)
{
this->strength = strength;
}
void Creature::setHitpoints(int hitpoints)
{
this->hitpoints = hitpoints;
}
int Creature::getStrength() const
{
return strength;
}
int Creature::getHitpoints() const
{
return hitpoints;
}
|
e31aefabec5ab5635ef91c9d58a338963778a8a9 | 0dcafdeb5f3b039b0db1718a5801885ff168f242 | /main.cpp | b172861e4262d58d684fdc86cfa15d056ec8080f | [] | no_license | rimever/first_sdl | 08b02101a18308ff85a7d80fab3d9c10b12fe03a | a51b2b7ee19310952a8536d742b2c533885a035b | refs/heads/main | 2023-02-26T12:53:31.152173 | 2021-02-02T12:48:21 | 2021-02-02T12:48:21 | 335,283,919 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 721 | cpp | main.cpp | #include <SDL.h>
// http://nyaocat.hatenablog.jp/entry/2014/01/27/153145
int main(int, char ** const)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("Hello SDL",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,640,480,0);
SDL_Renderer* render = SDL_CreateRenderer(window, -1, 0);
SDL_Event ev;
while(true){
SDL_SetRenderDrawColor(render, 0, 0, 0, 255);
SDL_RenderClear(render);
while(SDL_PollEvent(&ev))
{
if (ev.type == SDL_QUIT)
return 0;
}
SDL_SetRenderDrawColor(render, 255, 255, 255, 255);
SDL_RenderDrawLine(render,10, 10, 400, 400);
SDL_RenderPresent(render);
}
return 0;
} |
331e84991654220f0c30fe129b5b04d9b005d537 | 9732ad51b09956a1770ba827d32e35c03e9deade | /305_Lab11_Q1/Queue.h | c0b612b6244187c1f323449f374c403e9225fdec | [] | no_license | shihabawal/JavaLabs | dd1ae3f04cfdaaf4405bf92cc1cb2992e8475a89 | d09ce12db46860d3a48d306d76fa303d8017dce6 | refs/heads/master | 2021-01-22T17:52:49.916508 | 2017-03-15T07:44:58 | 2017-03-15T07:44:58 | 85,040,339 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 379 | h | Queue.h | #ifndef Queue_H
#define Queue_H
class FullQueue {
};
class EmptyQueue {
};
template<class ItemType>
struct NodeType;
template<class ItemType>
class Queue {
public:
Queue();
~Queue();
void MakeEmpty();
void Enqueue(ItemType);
void Dequeue(ItemType&);
bool IsEmpty() const;
bool IsFull() const;
private:
NodeType<ItemType>* front;
NodeType<ItemType>* rear;
};
#endif
|
4bfb387b2f9029d6f8b9eb28cc11171c1f04a144 | e1890fed44c38a4b6fc6e9de734e48e2cb2b400d | /ramiLukata_Assignment8/Sketche/Curve.cpp | 1a71d22f157c10b6b0ef765d5846d681fd0aace7 | [] | no_license | rlukata/IS375 | 45126a10a8299151d939b05e3710586e3feeeb1b | d52f855755c5198658204a918e68917ba3b5d3d7 | refs/heads/master | 2021-04-26T22:14:30.989451 | 2018-03-06T09:10:16 | 2018-03-06T09:10:16 | 124,048,255 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,291 | cpp | Curve.cpp | #include "stdafx.h"
#include "Curve.h"
#include <algorithm>
IMPLEMENT_SERIAL(CCurve, CElement, VERSION_NUMBER)
CCurve::CCurve()
{
}
CCurve::~CCurve()
{
}
// Constructor for a curve object
CCurve::CCurve(const CPoint& first, const CPoint& second, COLORREF color) :
CElement(first, color)
{
// Store the second point in the vector
m_Points.push_back(second);
m_EnclosingRect = CRect(
(std::min)(first.x, second.x), (std::min)(first.y, second.y),
(std::max)(first.x, second.x), (std::max)(first.y, second.y));
m_EnclosingRect.InflateRect(m_PenWidth, m_PenWidth);
}
// Draw a curve
void CCurve::Draw(CDC* pDC, std::shared_ptr<CElement> pElement)
{
// Create a pen for this object and initialize it
CPen aPen;
CreatePen(aPen);
CPen* pOldPen = pDC->SelectObject(&aPen); // Select the pen
// Now draw the curve
pDC->MoveTo(m_StartPoint);
for (auto& point : m_Points)
pDC->LineTo(point);
pDC->SelectObject(pOldPen); // Restore the old pen
}
// Add a segment to the curve
void CCurve::AddSegment(const CPoint& point)
{
m_Points.push_back(point); // Add the point to the end
// Modify the enclosing rectangle for the new point
m_EnclosingRect.DeflateRect(m_PenWidth, m_PenWidth);
m_EnclosingRect = CRect((std::min)(point.x, m_EnclosingRect.left),
(std::min)(point.y, m_EnclosingRect.top),
(std::max)(point.x, m_EnclosingRect.right),
(std::max)(point.y, m_EnclosingRect.bottom));
m_EnclosingRect.InflateRect(m_PenWidth, m_PenWidth);
}
void CCurve::Move(const CSize& aSize)
{
m_EnclosingRect += aSize; // Move the rectangle
m_StartPoint += aSize; // Move the start point
// Now move all the other points
for (auto& p : m_Points)
p += aSize;
}
void CCurve::Serialize(CArchive& ar)
{
CElement::Serialize(ar); // Call the base class function
// Serialize the vector of points
if (ar.IsStoring())
{
ar << m_Points.size(); // Store the point count
// Now store the points
for (size_t i = 0; i< m_Points.size(); ++i)
ar << m_Points[i];
}
else
{
size_t nPoints(0); // Stores number of points
ar >> nPoints; // Retrieve the number of points
// Now retrieve the points
CPoint point;
for (size_t i = 0; i < nPoints; ++i)
{
ar >> point;
m_Points.push_back(point);
}
}
} |
aff6dc2778aa8d4e6d21f302fe2cbc87eba25e9b | def5627f3cafb100cb4f5e617f27e1c06cf24820 | /src/myengine/MeshRenderer.h | b6c91f51e3ab91c12eda4f7113762a0c0397c761 | [] | no_license | HiddenRealm/myengine | 716bca574369f8abf51d257918601f6c93cde14c | 341c5a6ddd8ddaed637185811bab80b8334852d9 | refs/heads/master | 2020-03-30T03:59:12.647412 | 2018-11-26T12:12:22 | 2018-11-26T12:12:22 | 150,718,474 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 941 | h | MeshRenderer.h | #ifndef MESHRENDERER_H
#define MESHRENDERER_H
#include "Component.h"
#include "VertexBuffer.h"
#include "VertexArray.h"
#include "ShaderProgram.h"
#include "Texture.h"
#include <SDL2/SDL.h>
#include <GL/glew.h>
#include <glm/ext.hpp>
#include <iostream>
#include <string>
#include <memory>
namespace myengine
{
class MeshRenderer : public Component
{
public:
MeshRenderer();
void initialize(std::string shp, std::string tex, glm::vec3 pos);
void update();
void wrap();
void setup(std::string shp, std::string tex);
void setScale(glm::vec3 scl) { scale = scl; }
void setPos(glm::vec3 nw) { pos += nw; }
int getX() { return pos.x; }
int getZ() { return pos.z; }
int getY() { return pos.y; }
void setY(int nPos) { pos.y = nPos; }
private:
void display();
VertexArray *shape;
Texture *texture;
ShaderProgram *shader;
glm::vec3 camera;
glm::vec3 scale;
glm::vec3 pos;
glm::mat4 model;
};
}
#endif
|
e453cd9ce3eac9f1ea7c991ae63c06db1a9642be | daecca13678e4f602cf1db483d1325bd8875614a | /Code/Code/HTSConsts.hpp | 18f9eab582e9e6868981ae6528d9b922299e26fb | [] | no_license | sudarshan-shinde/HTS | 85c7a98fd12bf1d338bcac202857a8da3a28257a | c511c44c0b2e1f7a80dc6e116832ce2e50d1f043 | refs/heads/master | 2021-03-12T23:17:12.503215 | 2016-01-31T08:52:13 | 2016-01-31T08:52:13 | 35,410,701 | 2 | 1 | null | 2015-11-18T10:15:18 | 2015-05-11T08:12:10 | TeX | UTF-8 | C++ | false | false | 2,571 | hpp | HTSConsts.hpp | #ifndef _HTS_CONSTS_HPP_
#define _HTS_CONSTS_HPP_
#define HTS_OK (0)
#define HTS_NOT_OK (1)
#define HTS_TRUE (1)
#define HTS_FALSE (0)
#define THREAD_REQUEST_BUFFER_SIZE (512)
#define REQ_QUEUE_SIZE (1024)
#define REQ_QUEUE_SIZE_MASK (0x03FF)
#define OCL_REQ_QUEUE_SIZE (4096)
#define OCL_NODE_POOL_SIZE (1048576)
//#define OCL_HASH_TABLE_SIZE (1024)
//#define OCL_HASH_TABLE_MASK (0x3FF)
#define OCL_HASH_TABLE_SIZE (2)
#define OCL_HASH_TABLE_MASK (0x01)
#define OCL_WG_SIZE (256)
#define EMPTY_KEY (0)
#define PRINCIPAL_THREAD (0)
#define FBIT (0X04)
#define RBIT (0X02)
#define DBIT (0X01)
#define SET_FLAG(f,b) ((f) | (b))
#define RESET_FLAG(f,b) ((f) & ~(b))
#define GET_FLAG(f,b) ((f) & (b))
#define GET_PTR(f) ((f) >> 3)
#define SET_PTR(f) ((f) << 3)
#define GET_BITS(f) ((f) & (0x07))
#define SET_BITS(f,b) ((f) | (b))
#define RESET_BITS(f,b) ((f) | ~(b))
#define CHECK_BIT(f,b) ((f) | (b))
#define SET_MPTR(f,b) (((f)<< 3) | (b))
// for Reset-bit
#define GET_FBIT(f) ((f) & (0x04))
#define SET_FBIT(f) ((f) | (0x04))
#define RESET_FBIT(f) ((f) & (~0x04))
// for Retain-bit
#define GET_RBIT(f) ((f) & (0x02))
#define SET_RBIT(f) ((f) | (0x02))
#define RESET_RBIT(f) ((f) & (~0x02))
// for Deletion-bit
#define GET_DBIT(f) ((f) & (0x01))
#define SET_DBIT(f) ((f) | (0x01))
#define RESET_DBIT(f) ((f) & (~0x01))
enum eReqFlags
{
HTS_REQ_FULL = 0x01,
HTS_REQ_QUEUED = 0x02,
HTS_REQ_SUBMITTED = 0x04,
HTS_REQ_COMPLETED = 0x08,
HTS_REQ_ABORTED = 0x10,
HTS_REQ_BLOCKING = 0x20
};
enum eReqType
{
HTS_REQ_TYPE_FIND = 0x01,
HTS_REQ_TYPE_ADD = 0x02,
HTS_REQ_TYPE_REMOVE = 0x04
};
enum eRetVals
{
HTS_SUCCESS = 0,
HTS_FAILURE = 1,
HTS_FATAL_ERROR = 2,
HTS_ATTEMPT_FAILED = 3
};
#endif
|
4266b0a3ea2303fb74fd03eda3922821fc0ef959 | 5784bbe9280b84c2c58d373da65c52ad763f59ad | /trackpagehandler.cpp | 1354b0450d1a89250db1cefd7a10d477fcc26529 | [] | no_license | erewalk/eva-UAV | 0bd890e24bd38c700abc2dce0c9b0177275f5adb | 094dabb4a04cd6b2c2a71ceb7a275083db5b90fa | refs/heads/master | 2021-01-18T14:58:55.898224 | 2015-07-14T01:53:59 | 2015-07-14T01:53:59 | 39,063,918 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 74 | cpp | trackpagehandler.cpp | #include "trackpagehandler.h"
TrackPageHandler::TrackPageHandler()
{
}
|
2ad109b84ea45380de682e615f2249658630be3e | f7ec5cbc4c628a595b8a0c074d353332c8b52055 | /PixeltrackSD/src/VideoOutput.cpp | c511acc46dc24fbe3dbcf44bff8d945e19d0f58e | [] | no_license | sonnysk76/modules | ba6cef9dabc3afcac9cd86dd7ca51dded382c742 | 62339f4b0aa0fef1ae9e696daea3d6e555243744 | refs/heads/master | 2020-06-05T08:39:26.912796 | 2018-07-26T07:40:34 | 2018-07-26T07:40:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,455 | cpp | VideoOutput.cpp | /*
Copyright (C) 2013 Stefan Duffner, LIRIS, INSA de Lyon, France
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "VideoOutput.h"
namespace TLInOut
{
VideoOutput::VideoOutput(std::string filename, int width, int height, float fps/*=25*/)
{
mVWriter=NULL;
mfFPS=fps;
miWidth=width;
miHeight=height;
mVWriter = new cv::VideoWriter(filename.c_str(), CV_FOURCC('D','I','V','X'), mfFPS, cvSize(miWidth, miHeight), true);
if (mVWriter==NULL)
{
MESSAGE(0, "Could not open video file out.avi.");
}
}
VideoOutput::~VideoOutput()
{
if (mVWriter)
delete mVWriter;
}
void VideoOutput::addFrame(TLImageProc::Image8U* img)
{
ASSERT(img->width()==miWidth && img->height()==miHeight, "Image and video dimensions do not match in VideoOutput::addFrame().");
cv::Mat mat(miHeight, miWidth, CV_8UC3, img->data(), img->widthStep());
mVWriter->write(mat);
}
}
|
01e4abc019201f4225419504e2cddb91f3aff8c6 | 2ad3d9bc7ed0752575a86ac65d53f5535ccf762a | /player.h | 1dab05e20a953c19d610a836fa5f3c8174078b7b | [] | no_license | maashok/othelloAI | c1e02f1f9fbe9f86fd18defa6c2c97296921ec8f | 45b5fbb09cf7164216d96f8d6677295cec9df86e | refs/heads/master | 2021-01-10T07:46:46.929456 | 2016-03-15T05:33:15 | 2016-03-15T05:33:15 | 52,929,979 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 471 | h | player.h | #ifndef __PLAYER_H__
#define __PLAYER_H__
#include <iostream>
#include "common.h"
#include <limits>
#include "board.h"
using namespace std;
class Player {
Side me;
Side opp;
Board *board;
public:
Player(Side side);
~Player();
bool haveTime;
int depth;
void setBoard(Board *newBoard);
Move *doMove(Move *opponentsMove, int msLeft);
// Flag to tell if the player is running within the test_minimax context
bool testingMinimax;
};
#endif
|
2f80576506824213a0713ae95a69f1a45bb76951 | 1cfe775850da34579e8cbc739a897da79855469b | /include/objpipe/reader.h | 36bdc777c07bdbf1e170f01a51330b509565e760 | [
"BSD-2-Clause"
] | permissive | nahratzah/objpipe | 722fcde9cf5ed8abe50bfc324ab131f99fdf8587 | 677bc14faef2c0301b7fca919efbbdc3e8160763 | refs/heads/master | 2021-05-25T10:22:09.419047 | 2020-04-04T00:59:40 | 2020-04-04T00:59:40 | 127,082,498 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 619 | h | reader.h | #ifndef OBJPIPE_READER_H
#define OBJPIPE_READER_H
///\file
///\ingroup objpipe
#include <objpipe/detail/fwd.h>
#include <objpipe/detail/virtual.h>
namespace objpipe {
/**
* \brief An object pipe reader.
* \ingroup objpipe
*
* \tparam T The type of objects emitted by the object pipe.
*/
template<typename T>
class reader
: public detail::adapter_t<detail::virtual_pipe<T>>
{
public:
using detail::adapter_t<detail::virtual_pipe<T>>::adapter_t;
using detail::adapter_t<detail::virtual_pipe<T>>::operator=;
};
} /* namespace objpipe */
#include <objpipe/detail/adapter.h>
#endif /* OBJPIPE_READER_H */
|
a972fd5b2164610bdd64fc690ec7a124044597d1 | 2d3d4bc4b3fa577801e80bcc58d60e92bf355892 | /Ch15_drills/Main.cpp | 57ca64ea2160f1931b331f2a64388e15e59db997 | [] | no_license | VassZsolt/Prog1 | 529f31e329efa5d7083b37d0851ef8ad5bb842a9 | 90ff7f9c502ca7d957705d0f804065f13d8e9116 | refs/heads/main | 2023-05-04T01:28:45.539258 | 2021-05-27T12:33:51 | 2021-05-27T12:33:51 | 335,318,846 | 0 | 0 | null | 2021-05-27T12:33:52 | 2021-02-02T14:37:16 | C++ | UTF-8 | C++ | false | false | 1,579 | cpp | Main.cpp | #include "Simple_window.h"
double one(double x) { return 1; }
double slope(double x) { return x / 2; }
double square(double x) { return x * x; }
//double cos(double x) { return cos(x); }
double sloping_cos(double x) { return cos(x) + slope(x); }
int main()
{
int xmax = 600;
int ymax = 600;
int x_orig = xmax / 2;
int y_orig = ymax / 2;
int rmin = -10;
int rmax = 11;
int n_points = 400;
Simple_window win(Point(100, 100), xmax, ymax, "Function graphs");
Point origo{ x_orig,y_orig };
int xlength = xmax - 200;
int ylength = ymax - 200;
int xscale = 20, yscale = 20;
Axis x{ Axis::x, Point{100,y_orig}, xlength, xlength / xscale, "x" };
Axis y{ Axis::y, Point{x_orig,ylength + 100}, ylength, ylength / yscale, "y" };
Graph_lib::Function s(one, rmin, rmax, origo, n_points, xscale, yscale);
Graph_lib::Function s2(slope, rmin, rmax, origo, n_points, xscale, yscale);
Text s2_label{ Point{140,400},"x/2" };
Graph_lib::Function s3(square, rmin, rmax, origo, n_points, xscale, yscale);
//Graph_lib::Function s4(cos, rmin, rmax, origo, n_points, xscale, yscale);
Graph_lib::Function s5(sloping_cos, rmin, rmax, origo, n_points, xscale, yscale);
x.set_color(Color::red);
y.set_color(Color::red);
s.set_color(Color::black);
s2.set_color(Color::green);
s2_label.set_color(Color::green);
s3.set_color(Color::dark_green);
//s4.set_color(Color::blue);
s5.set_color(Color::yellow);
win.attach(x);
win.attach(y);
win.attach(s);
win.attach(s2);
win.attach(s2_label);
win.attach(s3);
//win.attach(s4);
win.attach(s5);
win.wait_for_button();
} |
0617120841b0159d0602ea57a0c4d4a15a1c424d | 195c78931b7920146baf087aa323321f045620f4 | /task2/codeforces/nextround.cpp | 91113646513a3084170db83789cb845d69f000b9 | [] | no_license | kasthuri28/amfoss-tasks | afc5dd2987b71d875680a04fb1fefa1cc67dfa57 | 2d47e5060fe4cd9a6a7b17e570340439e9529d83 | refs/heads/master | 2020-06-26T15:09:53.663047 | 2019-11-03T18:39:31 | 2019-11-03T18:39:31 | 199,669,001 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 235 | cpp | nextround.cpp | #include <iostream>
using namespace std;
int main()
{
int p,f;
int s=0;
int a[10];
cin>>p>>f;
for(int i=0;i<p;i++)
cin>>a[i];
for(int j=0;j<p;j++)
{
if(a[f]>=a[j])
s++;
}
cout<<s;
return 0;
}
|
27c8fb38d7a78659cf9399e515b29ca3bc1dc24e | af80f56928b5f006e31e5fb76523848e9e1b1fda | /counting_components/distcount.h | 685575310a352b128b1c09fcf822ee866a2285cc | [] | no_license | jeremy-murphy/gensearch | 86387a247f148671aa27ea66ae06cbeb6973e3b1 | 80a0113fca0945b0e8b971d4adde2bb6493f4e79 | refs/heads/master | 2021-01-20T11:41:27.979953 | 2016-09-03T08:56:36 | 2016-09-03T08:56:36 | 53,176,766 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,879 | h | distcount.h | /*
Defines class distance_counter<RandomAccessIterator, Distance,
Counting>, for use in measuring the performance of certain STL generic
algorithms. Objects of this class behave like those of type Distance
(which should be a type capable of representing the difference between
iterators of type RandomAccessIterator) but the class also keeps
counts of all Distance operations, using values of type Counting.
Type RandomAccessIterator is used as the result type of certain
addition and subtraction operators, with the assumption that Distance
is its distance type.
*/
#include <utility>
#include <fstream>
#include <memory>
#ifndef DISTCOUNT_H
#define DISTCOUNT_H
/*
* Copyright (c) 1997 Rensselaer Polytechnic Institute
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Rensselaer Polytechnic Institute makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
template <class RandomAccessIterator, class Distance, class Counting>
class distance_counter {
typedef distance_counter<RandomAccessIterator, Distance, Counting>
self;
friend bool operator==(const self& x, const self& y);
friend bool operator==(const self& x, const Distance& y);
friend bool operator<(const self& x, const self& y);
friend bool operator<(const self& x, const Distance& y);
friend bool operator<(const Distance& x, const self& y);
friend self operator+(const Distance& n, const self& x);
friend self operator*(const Distance& n, const self& x);
friend RandomAccessIterator
operator+(RandomAccessIterator i, const self& x);
friend RandomAccessIterator
operator+=(RandomAccessIterator& i, const self& x);
friend RandomAccessIterator
operator-(RandomAccessIterator i, const self& x);
friend RandomAccessIterator
operator-=(RandomAccessIterator& i, const self& x);
protected:
Distance current;
Counting generation;
public:
static Counting constructions;
static Counting copy_constructions;
static Counting conversions;
static Counting assignments;
static Counting increments;
static Counting additions;
static Counting subtractions;
static Counting multiplications;
static Counting divisions;
static Counting equality_comparisons;
static Counting less_comparisons;
static Counting max_generation;
static void reset() {
constructions = 0;
copy_constructions = 0;
conversions = 0;
assignments = 0;
increments = 0;
additions = 0;
subtractions = 0;
multiplications = 0;
divisions = 0;
equality_comparisons = 0;
less_comparisons = 0;
max_generation = 0;
}
static Counting total() {
return constructions + copy_constructions + conversions
+ assignments + increments
+ additions + subtractions
+ multiplications + divisions
+ equality_comparisons + less_comparisons;
}
static void report(std::ostream& o) {
o << "Distance stats: \n"
<< " Constructions: " << constructions << "\n"
<< " Copies: " << copy_constructions << "\n"
<< " Conversions: " << conversions << "\n"
<< " Assignments: " << assignments << "\n"
<< " Increments: " << increments << "\n"
<< " Additions: " << additions << "\n"
<< " Subtractions: " << subtractions << "\n"
<< " Multiplications: " << multiplications << "\n"
<< " Divisions: " << divisions << "\n"
<< " Equality comps: " << equality_comparisons << "\n"
<< " Less comps: " << less_comparisons << "\n"
<< " TOTAL: " << total() << "\n";
o << " Maximum generation: " << max_generation << "\n";
}
distance_counter() : generation(0) { ++constructions; }
distance_counter(const Distance& x) : current(x), generation(0) {
++conversions;
}
operator int() const { ++conversions; return current; }
distance_counter(const self& c) : current(c.current),
generation(c.generation + 1) {
++copy_constructions;
if (generation > max_generation) {
max_generation = generation;
}
}
Distance base() const {return current; }
self& operator=(const self& x) {
++assignments;
current = x.current;
return *this;
}
self& operator++() {
++increments;
++current;
return *this;
}
self operator++(int) {
self tmp = *this;
++increments;
++current;
return tmp;
}
self& operator--() {
++increments;
--current;
return *this;
}
self operator--(int) {
self tmp = *this;
++increments;
--current;
return tmp;
}
self operator+(const self& n) const {
self tmp = *this;
return tmp += n;
}
self operator+(const Distance& n) const {
self tmp = *this;
return tmp += n;
}
self& operator+=(const self& n) {
++additions;
current += n.current;
return *this;
}
self& operator+=(const Distance& n) {
++additions;
current += n;
return *this;
}
self operator-(const self& n) const {
self tmp = *this;
return tmp -= n;
}
self operator-(const Distance& n) const {
self tmp = *this;
return tmp -= n;
}
self& operator-=(const self& n) {
++subtractions;
current -= n.current;
return *this;
}
self& operator-=(const Distance& n) {
++subtractions;
current -= n;
return *this;
}
self operator*(const self& n) const {
self tmp = *this;
return tmp *= n;
}
self operator*(const Distance& n) const {
self tmp = *this;
return tmp *= n;
}
self& operator*=(const self& n) {
++multiplications;
current *= n.current;
return *this;
}
self& operator*=(const Distance& n) {
++multiplications;
current *= n;
return *this;
}
self operator/(const self& n) const {
self tmp = *this;
return tmp /= n;
}
self operator/(const Distance& n) const {
self tmp = *this;
return tmp /= n;
}
self& operator/=(const self& n) {
++divisions;
current /= n.current;
return *this;
}
self& operator/=(const Distance& n) {
++divisions;
current /= n;
return *this;
}
};
template <class RandomAccessIterator, class Distance, class Counting>
inline bool
operator==(const
distance_counter<RandomAccessIterator, Distance, Counting>& x,
const
distance_counter<RandomAccessIterator, Distance, Counting>& y) {
++distance_counter<RandomAccessIterator, Distance,
Counting>::equality_comparisons;
return x.current == y.current;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline bool
operator==(const
distance_counter<RandomAccessIterator, Distance, Counting>& x,
const Distance& y) {
++distance_counter<RandomAccessIterator, Distance,
Counting>::equality_comparisons;
return x.current == y;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline bool
operator<(const
distance_counter<RandomAccessIterator, Distance, Counting>& x,
const
distance_counter<RandomAccessIterator, Distance, Counting>& y) {
++distance_counter<RandomAccessIterator, Distance,
Counting>::less_comparisons;
return x.current < y.current;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline bool
operator<(const
distance_counter<RandomAccessIterator, Distance, Counting>& x,
const Distance& y) {
++distance_counter<RandomAccessIterator, Distance,
Counting>::less_comparisons;
return x.current < y;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline bool
operator<(const Distance& x,
const distance_counter<RandomAccessIterator, Distance, Counting>& y) {
++distance_counter<RandomAccessIterator, Distance,
Counting>::less_comparisons;
return x < y.current;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline RandomAccessIterator
operator+(RandomAccessIterator i,
const
distance_counter<RandomAccessIterator, Distance, Counting>& x) {
return i + x.current;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline RandomAccessIterator
operator+=(RandomAccessIterator& i,
const
distance_counter<RandomAccessIterator, Distance, Counting>& x) {
return i += x.current;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline RandomAccessIterator
operator-(RandomAccessIterator i,
const
distance_counter<RandomAccessIterator, Distance, Counting>& x) {
return i - x.current;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline RandomAccessIterator
operator-=(RandomAccessIterator &i,
const
distance_counter<RandomAccessIterator, Distance, Counting>& x) {
return i -= x.current;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline distance_counter<RandomAccessIterator, Distance, Counting>
operator-(const
distance_counter<RandomAccessIterator, Distance, Counting>& x,
const
distance_counter<RandomAccessIterator, Distance, Counting>& y) {
++distance_counter<RandomAccessIterator, Distance,
Counting>::subtractions;
return distance_counter<RandomAccessIterator, Distance,
Counting>(x.current - y.current);
}
template <class RandomAccessIterator, class Distance, class Counting>
inline distance_counter<RandomAccessIterator, Distance, Counting>
operator+(const Distance& n,
const
distance_counter<RandomAccessIterator, Distance, Counting>& x) {
++distance_counter<RandomAccessIterator, Distance, Counting>::additions;
return x + n;
}
template <class RandomAccessIterator, class Distance, class Counting>
inline distance_counter<RandomAccessIterator, Distance, Counting>
operator*(const Distance& n,
const
distance_counter<RandomAccessIterator, Distance, Counting>& x) {
++distance_counter<RandomAccessIterator, Distance,
Counting>::multiplications;
return x * n;
}
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
constructions = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
copy_constructions = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
conversions = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
assignments = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
increments = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
additions = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
subtractions = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
multiplications = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
divisions = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
equality_comparisons = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
less_comparisons = 0;
template <class RandomAccessIterator, class Distance, class Counting>
Counting distance_counter<RandomAccessIterator, Distance, Counting>::
max_generation = 0;
/* The purpose of the following version of get_temporarary_buffer is to
enable the STL stable_sort generic algorithms to work with
distance_counter objects. */
template <class T, class RandomAccessIterator, class Distance, class Counting>
std::pair<T*,distance_counter<RandomAccessIterator, Distance, Counting> >
get_temporary_buffer(distance_counter<RandomAccessIterator, Distance,
Counting> len, T* p) {
std::pair<T*, int> tmp = get_temporary_buffer((int)len, p);
return std::pair<T*, distance_counter<RandomAccessIterator, Distance,
Counting> >(tmp.first,
distance_counter<RandomAccessIterator,
Distance, Counting>(tmp.second));
}
#endif
|
9bd8e140c16862c89d78fadde54bde0eb0e459de | f353c743a163023ec23e2e80c6f38cf80da6a76e | /Piece.cpp | eba448666040c1390b9898b814ab7e76f7acb0ea | [] | no_license | vdogmr25/chess | 898189f8d5d57d7fbf3f9ab7f0f9dc85b8adf2c5 | dc6c1b66c3a666dc5e0c83bff8cd1d12cc0e4288 | refs/heads/master | 2021-01-23T06:35:23.756917 | 2014-08-26T18:17:25 | 2014-08-26T18:17:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,811 | cpp | Piece.cpp | //
// Piece.cpp
// Chess
//
// Created by Christian Bodnar on 3/18/13.
// Copyright (c) 2013 George Fox University. All rights reserved.
//
#include "Piece.h"
#include "Player.h"
Piece::Piece(std::string color, bool white) : _color(color), _white(white) {}
bool Piece::moveTo (Player& byPlayer, Square& to)
{
//Start with false
bool attempt = false;
Piece* capture = NULL;
Square* current = location();
//If the end location is unoccupied or occupied by a different colored piece
if ((!to.occupied() || to.occupiedBy()->isWhite() != isWhite())
//And the player moving the piece owns the piece and the piece can move to the
//square
&& (isWhite() == byPlayer.isWhite() && canMoveTo(to)))
{
//If the square is occupied..
if (to.occupied())
{
//..capture the piece
capture = to.occupiedBy();
capture->setLocation(NULL);
}
else if (Board::squareAt(to.getX(), this->location()->getY())->occupied()
&& Board::squareAt(to.getX(), this->location()->getY())->occupiedBy()->isWhite() != isWhite()
&& Board::squareAt(to.getX(), this->location()->getY())->occupiedBy()->value() == 1)
{
capture = Board::squareAt(to.getX(), this->location()->getY())->occupiedBy();
capture->setLocation(NULL);
}
//Set the old location's occupant to NULL
location()->setOccupier(NULL);
//Set the new square's occupant to this piece
to.setOccupier(this);
//set the current location to the new square.
setLocation(&to);
//set to true for successful move.
attempt = true;
}
//If the player is in check
if (byPlayer.checkForCheck())
{
//Signal for bad move
attempt = false;
//Revert pieces to old locations
setLocation(current);
current->setOccupier(this);
//revert capture.
if (capture)
{
to.setOccupier(capture);
capture->setLocation(&to);
}
}
//If the player isn't in check and there's a piece to capture
else if(capture)
{
//capture
byPlayer.capture(*capture);
}
//return the result.
return attempt;
}
std::string Piece::color () const
{
// reuturns the piece's color
return _color;
}
void Piece::setLocation (Square* square)
{
// sets the square the piece occupies
_occupies = square;
}
bool Piece::isOnSquare () const
{
bool onSquare = false;
if (location())
{
onSquare = true;
}
return onSquare;
}
bool Piece::isWhite() const
{
return _white;
}
Square* Piece::location () const
{
//returns the piece's location.
return _occupies;
} |
a57b5c984b0b3d6df54f10194f42c1e14b1ec91d | 1ae05cf29c69a2fce84f1f3e285cc618b84143d9 | /Bridge/Report.h | a7af91881dfc9df753fe0d6d30e1c79042e7a1e5 | [] | no_license | Bylinka/Bridge | 7a66b579b7df6c2249b418bf1862a9d63960dbf3 | 771f9453d4d882b8dbd3df8fd97a4b5ccd81e858 | refs/heads/master | 2020-03-26T02:03:55.013626 | 2018-08-11T17:06:21 | 2018-08-11T17:06:21 | 144,395,536 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,407 | h | Report.h | #pragma once
class ITool {
public:
virtual void printLine(const char* str) = 0;
virtual void printHeader(const char* str) = 0;
virtual ~ITool() {}
};
class IPDFTool : public ITool {};
class PDFTool : public IPDFTool {
public:
void printLine(const char* str) {
cout << "PDF Line: " << str << endl;
};
void printHeader(const char* str) {
cout << "PDF Header: " << str << endl;
};
};
class IDOCTool : public ITool {};
class DOCTool : public IDOCTool {
public:
void printLine(const char* str) {
cout << "DOC Line method "<< method() << ": " << str << endl;
};
void printHeader(const char* str) {
cout << "DOC Header: " << str << endl;
};
virtual int method() { return 0; }
};
class DOCToolMethod1 : public DOCTool {
public:
int method() { return 1; }
};
class DOCToolMethod2 : public DOCTool {
public:
int method() { return 2; }
};
class IReport {
protected:
ITool * tool = nullptr;
public:
virtual void print() = 0;
virtual ~IReport() {
cout << "deleting: " << typeid(this).name()
<< " and " << typeid(tool).name() << endl;
if (tool)delete tool;
}
};
class WeeklyReport : public IReport {
public:
WeeklyReport(ITool* tool) {
this->tool = tool;
}
void print() {
tool->printHeader("Weekly report");
tool->printLine("Some weekly report line.");
}
};
class DaylyReport : public IReport {
public:
DaylyReport(ITool* tool) {
this->tool = tool;
}
void print() {
tool->printHeader("Dayly report");
tool->printLine("Some dayly report line.");
}
};
class ProxyDOCTool : public IDOCTool {
public:
void printLine(const char* str) {
cout << "ProxyDOCTool action -> ";
DOCTool().printLine(str);
};
void printHeader(const char* str) {
cout << "ProxyDOCTool action -> ";
DOCTool().printHeader(str);
};
};
class ProxyPDFTool : public IPDFTool {
public:
void printLine(const char* str) {
cout << "ProxyPDFTool action -> ";
PDFTool().printLine(str);
};
void printHeader(const char* str) {
cout << "ProxyPDFTool action -> ";
PDFTool().printHeader(str);
};
};
class Decorator : public ITool {
ITool* next;
public:
Decorator(ITool* next) :next(next) {}
~Decorator() {
cout << "deleting " << typeid(next).name() << endl;
if (next)delete next;
}
void printLine(const char* str) {
cout << "Decorator action -> ";
next->printLine(str);
};
void printHeader(const char* str) {
cout << "Decorator action -> ";
next->printHeader(str);
};
}; |
6df5215e27886b4aa718aa972145ea15ca7db29f | c6b1309a7d1ab5af0c6338634ef7f9e886afb8a8 | /seekur_12.04/packages/CAMERA_STEREO/mobile_ranger/include/mobile_ranger/libfrdev/FrStereoRectMap.h | fba680820cc38d49262d141ff0ce01f96420bc52 | [] | no_license | wserrantola/SeekurJr | bd6aa1c075508b091e65cbdecb67f42b583a1b3d | d7d6f83b4050ec2dbace13c50fac105ef7066e51 | refs/heads/master | 2020-06-23T17:19:42.173959 | 2019-06-24T19:17:41 | 2019-06-24T19:17:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,265 | h | FrStereoRectMap.h | /****************************************************************************
* Copyright (c) 2006-2008 by Focus Robotics.
*
* All rights reserved. No part of this design may be reproduced stored
* in a retrieval system, or transmitted, in any form or by any means,
* electronic, mechanical, photocopying, recording, or otherwise, without
* prior written permission of Focus Robotics, Inc.
*
* Proprietary and Confidential
*
* Created By : Andrew Worcester
* Creation_Date: Fri Dec 19 2006
*
* Brief Description:
*
* Functionality:
*
* Issues:
* The name of this class doesn't seem just right. It contains all stereo camera
* parameters, but it's more then that. It also can create rectification maps,
* or even just read maps without camera parameters. It supports rectification,
* but doesn't actually do rectification, that's the rectifier class. This class
* could also produce a transform which doesn't rectify at all. It doesn't calc
* the transform to rectify, just creates the maps from the distortion params
* and rect transform matrices.
*
* Could call it:
* FrCalibMap -- that's what's used in the sample programs
* FrRectMap -- maybe more accurate
* EagleCalibMap -- what it used to be called, but I'm prepending everything with Fr now
* FrStereoCameraParameters -- OK, but ignores map generation and is long
* FrStereoCameraParams -- shorter is better, still ignores maps
* FrStereoRectMap <--- I'll use this one because it is a rect map for both images in a stereo pair
* FrStereoCameraRectMap
*
* I may actually want to have another class which holds more camera param
* information like the fundamental or essential matrix, or arrays or corresponding
* points, or parameters for different camera models. Maybe that is untimately the
* StereoCameraParameters and this RectMap class holds one of those--or not...
* It's weird because the rect map needs some of the stereo camera params, but
* not all of them.
*
* How do I program the maps in hardware consistantly for different programming
* interfaces--like between eagle and fr3 drivers? Probably by returning the map
* and letting the higher layer program it instead of actually programming it
* in this code. But how does that work? Always create a new map and pass the
* RectMap class to the StereoCamera class, via the initCalib method. Inside the
* initCalib method, the code retrieves the pointer to the int array and copies
* that into the hardware, either via writeMEM or ioctl. Maybe initCalib tries to
* do something smart if it's passed a null pointer instead of a RectMap, like
* making it's own RectMap and using default calib file locations, or from the
* environment or command line.
*
* The FrStereoRectProc class actually performs the rectification transfer, or
* works as an interface for hardware that performs the transfer. Eventually,
* the RectMap and RectProc classes could merge into the RectProc. This would
* also mirror intended hardware changes where the hardware starts generating
* maps it's self.
*
* Limitations:
*
* Testing:
*
******************************************************************************/
/* Started as: EagleCalibMap.h
* This class started out as just converting params to a hw map and loading that
* map into hardware. It seems to be transforming into all stereo params so
* perhaps it should be renamed to StereoCameraParameters.
* In addition to holding stereo camera parameters, it also creates the map used
* to convert raw images into rectified images, which seems like the more
* important function.
* Currently, it holds intrinsics and distortion for each camera in the stereo
* pair as well as the transform to rectify the cameras and the effective
* intrinsics of the rectified stereo camera, and it's baseline.
*/
#ifndef FRSTEREORECTMAP_H
#define FRSTEREORECTMAP_H
#include "FrImage.h"
#include "FrMatF.h"
enum RectMapType {right_x, right_y, left_x, left_y, right_xy, left_xy, full};
/// Encapsulates stereo camera params and read and writes them in various formats.
class FrStereoRectMap {
public:
// ***************************************************************************
// Constructors and Destructors
// Default constructor should take no arguments and automagically find the
// calib file... but it needs to know the image sensor id number in order to
// do that. Does it need to know anything else? Currently I find the
// appropriate calib file using the sensor id number and some env variables
// in the eagleStereoSmartCam class, but I would like to push that to this
// class. I just need a way to pass in a unique identifier, I think.
//FrStereoRectMap(int uid);
// Map defaults to identity mapping with no distortion
// FIXME: probably don't need these args to have defaults.
// loadCalibParameters and readCalibMap should reset width and height based
// on values in those files
FrStereoRectMap(int width, int height);
// It might be useful to have a constructor which just gets the filename for
// a calib or map file. How does it determine which type it has?
// Probably add optional type parameter to this constructor
FrStereoRectMap(const char* filename);
// Copy Constructor
// What should be copied over? Filename? Params? Coord LUT?
FrStereoRectMap(const FrStereoRectMap &map);
// Initialization/assignment Constructor
//FrStereoRectMap& operator=(const FrStereoRectMap &rhs);
~FrStereoRectMap();
// ***************************************************************************
// *** Set and Get and Load and Save camera parameters and transforms ***
// Some values are camera parameters, some are rectification parameters; should names reflect that?
// *** Set functions
void setIdentityParams();
void setCameraParams(float *A0, float *k0, float *T0,
float *A1, float *k1, float *T1,
float *Anew, float Base);
// allow setting individual params, need enum for side and params, also allow setting from FrMatF
void setCameraParam(int side, int param, float value); // generic version not yet implemented
void setCameraParam(int side, int param, FrMatF *value); // generic version not yet implemented
// *** Get functions
float getCameraParam(int side, int param); // generic version not yet implemented
float getCameraBaseline() {return B;}
float getCameraFocalLength() {return An[0];}
FrMatF* getCameraParamIntrnsMat(int cam);
FrMatF* getCameraParamDistCoeff(int cam);
FrMatF* getCameraParamTrnsfmMat(int cam);
// *** Load, save, and print
// Format options for load and save: fmt=-1 means autoselect for load
// fmt=1 is the new FR calib params file, fmt=0 is the old opencv calib params file, other values reserved
int loadCameraParams(const char* filename, int fmt=-1); // may fail if file doesn't exist or isn't readable
int saveCameraParams(const char* filename, int fmt=1); // may fail if file isn't writable or params aren't set
// just for debug
void printCameraParams();
// ***************************************************************************
// *** Creating, Loading, Saving Maps ***
// Convert camera parameters into a map
// It's an error if calib parameters aren't set when this is called
// maybe this should be protected as well and just called automatically when params are changed
void createMaps();
protected:
// This is the implementation of createMaps
void createMap(FrMatF *xMap, FrMatF *yMap, float *A, float *k, float *T);
public:
// New functions to read/write maps in different formats. May be called up to
// four times for formats that store map data in multiple files. Each part of
// the data and separate file gets it's own fmt number.
// Need to define formats; keep map and param file formats in one namespace so a
// constructor can take one fmt arg to read any type of file.
// FIXME: anything that directly sets the map should set params invalid
int readMapFile(const char *mapFile, int fmt);
int writeMapFile(const char *mapFile, int fmt);
// setMap and getMap would round out the set
// Data is always stored as 4 separate map matrices, but may be passed in as
// any of the mtype types.
// Define types: right_x, right_y, left_x, left_y, right_xy, left_xy, full(4 chan mat)
FrMatF* getMap(RectMapType mtype);
void setMap(FrMatF *newmap, RectMapType mtype);
// ***************************************************************************
// *** Misc
// make operator= copy all params and maps over
void operator=(const FrStereoRectMap& src);
// ***************************************************************************
// *** Dealing with HW format maps ***
// Return the map for a particular hardware platform. Different calls will
// support different required hardware formats as they are created.
int* getFr3RemapStruct();
int getFr3RemapStructLen();
// ***************************************************************************
protected:
void fixTileSize();
// ***************************************************************************
private:
int width;
int height;
// Tiles stuff is only used to format to Fr3 hardware usable map
int widthTiles; // width in 128 pixel wide tiles--may be larger then actual image
int widthSubTiles; // 4*widthTiles
int heightTiles; // height in 16 pixel high tiles--may be larger then actual image
// Parameters for each raw camera in the stereo pair
// NOTE: 0 is right, 1 is left
// CONSIDER: should I convert internal structures to FrMatf?
float Ar[9];
float Al[9];
float kr[4]; //dist_coeff0;
float kl[4]; //dist_coeff1;
float Tr[9]; //rect_coeff0; Rect transform, don't confuse with T translation vec
float Tl[9]; //rect_coeff1;
// Add parameters for the stereo camera, and each rectified camera in the pair
float An[9]; // New intrinsics, maybe Arect?
float B;
public:
// These maps are single channel float maps, the size of the image.
FrMatF *rightXMap;
FrMatF *rightYMap;
FrMatF *leftXMap;
FrMatF *leftYMap;
// This map is data formatted to load directly into fr3 memory
unsigned int* hw_remap_coords;
bool paramsValid;
bool mapsValid;
};
#endif
|
db78242132a0e14c633814cce9c77035786b9691 | c33e840f5503365b39ad0118ce12200bc79dd428 | /Implementacao/Fila.hpp | c1edb82a25ded302539e11d91391b07db695f4b1 | [] | no_license | gabrielissantos/JvTron-3.0 | 24d0a823f83e3e13471cd3983f5089b05b9edd89 | d2523f078372d721c4f2f73df2913054bb542435 | refs/heads/master | 2020-12-25T19:03:12.534108 | 2017-07-15T19:55:55 | 2017-07-15T19:55:55 | 94,019,172 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,351 | hpp | Fila.hpp | /*
JvAsteroids: Trabalho 3
Departamento de Computação
UFSCar Universidade Federal de São Carlos
Disciplina: Estrutura de Dados
Professor: Roberto Ferrari
Aluno(a): RA:
João Gabriel Melo Barbirato 726546
Leonardo de Oliveira Peralta 726556
Gabrieli Santos 726523
Controle de Versão: https://github.com/gabrielissantos/JvTron-3.0
*/
#include <iostream>
template <class Gen> struct NodeFila{
Gen Info;
NodeFila<Gen> *Next;
};
template <class Gen>
class Fila
{
public:
Fila(); //ok
virtual ~Fila(); //ok
void Insere(const Gen & X, bool & DeuCerto); //ok
void Retira(Gen & X, bool & DeuCerto);
bool Vazia(); //ok
bool Cheia(); //ok
Gen getPrimeiro(); //ok
Gen getUltimo(); //ok
private:
NodeFila<Gen> * F_Primeiro;
NodeFila<Gen> * F_Ultimo;
};
template <class Gen>
Fila<Gen>::Fila()
{
F_Primeiro = NULL;
F_Ultimo = NULL;
}
template <class Gen>
Fila<Gen>::~Fila()
{
Gen X;
bool DeuCerto;
while(!Vazia()){
DeuCerto = true;
Retira(X, DeuCerto);
}
}
template <class Gen>
void Fila<Gen>::Insere(const Gen & X, bool & DeuCerto){
NodeFila<Gen> * F_Aux;
if(Cheia())
DeuCerto = false;
else{
DeuCerto = true;
F_Aux = new NodeFila<Gen>;
F_Aux->Info = X;
F_Aux->Next = NULL;
if(Vazia())
F_Primeiro = F_Aux;
else
F_Ultimo->Next = F_Aux;
F_Ultimo = F_Aux;
}
}
template <class Gen>
void Fila<Gen>::Retira(Gen & X, bool & DeuCerto){
NodeFila<Gen> * F_Aux;
if(Vazia()==true)
DeuCerto = false;
else{
DeuCerto = true;
X = F_Primeiro->Info;
F_Aux = F_Primeiro;
F_Primeiro = F_Primeiro->Next;
if(F_Primeiro == NULL)
F_Ultimo == NULL;
delete(F_Aux);
}
}
template <class Gen>
bool Fila<Gen>::Cheia(){
return false;
}
template <class Gen>
bool Fila<Gen>::Vazia(){
if(F_Primeiro == NULL || F_Ultimo == NULL)
return true;
else
return false;
}
template <class Gen>
Gen Fila<Gen>::getPrimeiro(){
return F_Primeiro->Info;
}
template <class Gen>
Gen Fila<Gen>::getUltimo(){
return F_Ultimo->Info;
} |
51edc9da65cb58abc3d0979d0b89b81e054e7e14 | 65daad5f59caa2336888fa71d31502e8abbb6721 | /Client/NodeInterface_Shape.h | 9ebad34c8e01ef643b49aa33de1ee564ea4b710a | [] | no_license | Naeferith/CPP-Client | d9f98f7bf0505a243eef7468586c4abe07c441a3 | 81b127f94e5f4b1443e0c32bef0fe45e63a7756b | refs/heads/master | 2020-03-31T14:57:36.640181 | 2019-01-24T19:07:54 | 2019-01-24T19:07:54 | 152,317,383 | 0 | 4 | null | 2019-01-25T13:00:38 | 2018-10-09T20:34:16 | C++ | ISO-8859-1 | C++ | false | false | 414 | h | NodeInterface_Shape.h | #pragma once
#include "NodeInterface.h"
/** @brief L'expert de Forme de la COR*/
class NodeInterface_Shape : public NodeInterface {
public:
/** @brief Le constructeur par défaut. */
NodeInterface_Shape(NodeInterface* ni);
/** @brief Le destructeur. */
virtual ~NodeInterface_Shape();
/** @see NodeInterface.executeRequest(tinyxml2::XMLDocument& xml) */
void executeRequest(XMLDocument& xml) override;
}; |
ca8707ef272a69fbdb64d8320392c8b65d874874 | 5f4d46c8034f71657cb02b474ec4b6fad3d49012 | /C++/try/学籍成绩管理/学籍成绩管理/SearchDlg.h | e8c6c1b8e296ca40db9f6c33d78bc238a66f8823 | [] | no_license | GaryCao97/CodeWarehouse | 516c3da660070a574be40e34e290345c54fef692 | d6290d0f115c8dd350844bfe697abc07998a9f4c | refs/heads/master | 2020-03-31T19:52:02.786213 | 2018-10-12T08:29:46 | 2018-10-12T08:29:46 | 152,515,319 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 1,031 | h | SearchDlg.h | #pragma once
#include "afxcmn.h"
// CSearchDlg 对话框
class CSearchDlg : public CDialogEx
{
DECLARE_DYNAMIC(CSearchDlg)
public:
CSearchDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~CSearchDlg();
// 对话框数据
enum { IDD = IDD_Search };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedsearchReturn();
virtual BOOL OnInitDialog();
CListCtrl search_list;
void PaintListItem(void);
afx_msg void OnBnClickedsearchname();
afx_msg void OnBnClickedsearchnumber();
afx_msg void OnBnClickedsearchschool();
afx_msg void OnBnClickedsearchclass();
afx_msg void OnBnClickedsearchteacher();
afx_msg void OnBnClickedsearchlesson1();
afx_msg void OnBnClickedsearchlesson2();
afx_msg void OnBnClickedsearchlesson3();
afx_msg void OnBnClickedsearchlesson4();
afx_msg void OnBnClickedsearchlesson5();
afx_msg void OnBnClickedsearchlessonsum();
afx_msg void OnBnClickedsearchlessonaver();
CString search_edit;
};
|
1d2c01f94d8554591b6fd1b6dc676313e5252542 | 504920274f287ac89b344d1292a6299771829b08 | /ptr_fun_dx/main.cpp | 588b562ad683bf401b8d7307f513b0d7681981a6 | [] | no_license | sakishum/My_STL | 0d732bc948e9e519010b6eb8b25a98a3caa9211a | 7ae399c57b4f4fbf0a3eebb7fae16ebed4bbe0ff | refs/heads/master | 2021-01-13T05:13:05.507907 | 2017-02-08T00:17:19 | 2017-02-08T00:33:29 | 81,268,601 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 693 | cpp | main.cpp | #include <iostream>
#include <cstdlib>
#include <algorithm>
#include <functional>
int sum(int arg1, int arg2) {
std::cout << "arg1 = " << arg1 << std::endl;
std::cout << "arg2 = " << arg2 << std::endl;
int sum = arg1 + arg2;
std::cout << "sum = " << sum << std::endl;
return sum;
}
int main(void) {
// ptr_fun 将普通函数(两个参数,如果有多个参数,要改成 boost::bind)适配成
// bind1st 或 bind2nd 能够使用的 functior, 否则对 bind1st 或 bind2nd 直接绑
// 定普通函数,编译出错。
std::bind1st(std::ptr_fun(sum), 1)(2); // the same as sum(1, 2)
std::bind2nd(std::ptr_fun(sum), 1)(2); // the same as sum(2, 1)
return EXIT_SUCCESS;
}
|
82c67288046b00803673a59dfd29ed19a315b3d2 | 27a0328fdf0ae552a0f1d2f799e6e8846dc8f0e4 | /src/ngraph/runtime/gpu/gpu_memory_manager.hpp | d7fad23c52c5648e6a2b62db9e28d21ee05ab09f | [
"Apache-2.0"
] | permissive | darchr/ngraph | d58698ee62d4d6dac1ba3394a36f3c1ec618f4d0 | 7c540e5230f8143ecb6926685c7b49305f0f988a | refs/heads/master | 2021-07-10T03:58:12.711797 | 2019-08-29T18:31:40 | 2019-08-29T18:31:40 | 171,505,991 | 1 | 0 | Apache-2.0 | 2019-08-29T17:35:24 | 2019-02-19T16:10:45 | C++ | UTF-8 | C++ | false | false | 2,993 | hpp | gpu_memory_manager.hpp | //*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// 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.
//*****************************************************************************
#pragma once
#include <list>
#include <memory>
#include <stack>
#include <vector>
#include "ngraph/pass/memory_layout.hpp"
namespace ngraph
{
namespace runtime
{
namespace gpu
{
class GPUPrimitiveEmitter;
class GPUMemoryManager;
class GPUAllocator
{
public:
GPUAllocator() = delete;
GPUAllocator(GPUMemoryManager* mgr);
GPUAllocator(const GPUAllocator& g);
~GPUAllocator();
template <typename T>
size_t reserve_argspace(const T& container)
{
return reserve_argspace(container.data(),
container.size() * sizeof(typename T::value_type));
}
size_t reserve_argspace(const void* data, size_t size);
size_t reserve_workspace(size_t size, bool zero_initialize = true);
void close();
private:
GPUMemoryManager* m_manager;
std::stack<size_t> m_active;
};
class GPUMemoryManager
{
friend class GPUPrimitiveEmitter;
friend class GPUAllocator;
public:
~GPUMemoryManager();
void allocate();
size_t get_allocation_size() const;
GPUAllocator build_allocator() { return GPUAllocator(this); }
private:
GPUMemoryManager(GPUPrimitiveEmitter* emitter);
size_t queue_for_transfer(const void* data, size_t size);
size_t m_buffer_offset;
std::vector<uint8_t> m_buffered_mem;
std::unique_ptr<ngraph::pass::MemoryManager> m_workspace_manager;
static constexpr const uint16_t alignment = 8;
struct allocation
{
void* ptr;
size_t size;
};
std::list<allocation> m_argspace_mem;
std::list<allocation> m_workspace_mem;
GPUPrimitiveEmitter* m_primitive_emitter;
};
}
}
}
|
af8db77ba38817755d24c3756d84fea34ca3ab44 | 450757ee3d890672bb3f6af42f01430ca3dea34c | /revreaddyC/include/ReactionEvent.h | 7ab02aacf44e694a983c08a7a5f07826d3aca51e | [] | no_license | chrisfroe/revreaddy | f173035c2d2e6aef6da7a69ef73187a743689208 | 66b8e7d003f94e969dc1f202937a699ae4604585 | refs/heads/master | 2020-05-21T22:59:29.498375 | 2016-11-10T18:59:47 | 2016-11-10T18:59:47 | 26,339,851 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 690 | h | ReactionEvent.h | /* ReactionEvent.h
* This small structure describes a particle or a pair of
* particles, which is a candidate for a certain reaction. */
#ifndef __REACTIONEVENT_H_INCLUDED__
#define __REACTIONEVENT_H_INCLUDED__
#include <vector>
struct ReactionEvent
{
ReactionEvent(
unsigned int inReactionId,
bool inForwardOrBackward,
std::vector<unsigned long long> inParticipants);
/* position in reactions vector*/
unsigned reactionId;
/* true = forward, false = backward */
bool forwardOrBackward;
/* This vector has either one or two elements.
* Stored here are the uniqueIds of particles. */
std::vector<unsigned long long> participants;
};
#endif //__REACTIONEVENT_H_INCLUDED__ |
fcf4b996f6c4a846f6a9db1504f092396754aca1 | 7008d4e39c15ea01d9dcc59c37c7ed517ee67d7c | /NeWS/ice/Fontobj.cc | 375e9b923600bbae2320e7c6d76e0e4572d2f1ff | [] | no_license | LegalizeAdulthood/OpenLookCDROM | d99b829a446cfa281947c449c8496943f944fd2a | 2aa032ddc0a737bb420463c0a508a0f4867c1667 | refs/heads/master | 2023-03-19T12:02:53.777816 | 2021-03-11T14:36:41 | 2021-03-11T14:36:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 595 | cc | Fontobj.cc | /*
* Copyright (c) 1990 by Columbia University.
*/
#include "Fontobj.h"
extern "C" {
char * strcpy(char *, char *);
int strlen(char *);
}
Fontobj::Fontobj()
{
fontname= (char *) 0;
}
Fontobj::Fontobj(Dlnk **objhd, char *f)
{
if (objhd == (Dlnk **) 0)
;
else if (*objhd == (Dlnk *) 0)
*objhd= (Dlnk *) this;
else
link(*objhd, DLNK_TAIL);
if (f == (char *) 0)
fontname= (char *) 0;
else if (strlen(f) == 0)
fontname= (char *) 0;
else {
if ((fontname= new char[strlen(f)+1]) != (char *) 0)
(void) strcpy(fontname, f);
}
}
Fontobj::~Fontobj()
{
delete fontname;
}
|
94d0f91652c9f3cf3e686aa438bee58f8d2c0d3c | ee026a2b32db9679245c7203151b54c8b81ab587 | /EmgApp/MainWindow.cpp | d3e9d5c24bd5bda6d88bab815e707415039640fd | [] | no_license | liyi6/EmgApp | c6fe23095a575a45f7095d8399b73bdc17118c46 | 3d2f8becdf199855a43a8b5827afd3a90b48758c | refs/heads/master | 2020-04-07T12:35:55.915854 | 2018-11-22T02:26:30 | 2018-11-22T02:26:30 | 158,373,655 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,460 | cpp | MainWindow.cpp | #include "MainWindow.h"
#include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
updateUi();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::updateUi()
{
setWindowIcon(QIcon("res/logo.ico"));
setWindowTitle("EMG Demo");
for (int i=0; i<POINT_SHOW; i++) {
m_xAxisValue.append(i);
}
for (int channel=0; channel<CHANNEL_SIZE; channel++) {
// set data container
QVector<double>* dataList = new QVector<double>();
m_dataContainer.insert(channel, dataList);
// set plot
QString plotControlName = "channel" + QString::number(channel);
QCustomPlot* plot = this->findChild<QCustomPlot*>(plotControlName);
if (!plot) {
qWarning() << "Find plot error: can't find~~~ " << plotControlName;
continue;
}
plot->yAxis->setTickLabels(false);
connect(plot->yAxis2, SIGNAL(rangeChanged(QCPRange)), plot->yAxis, SLOT(setRange(QCPRange))); // left axis only mirrors inner right axis
plot->axisRect()->addAxis(QCPAxis::atRight);
plot->axisRect()->axis(QCPAxis::atRight, 0)->setPadding(30); // add some padding to have space for tags
// create graphs:
QPointer<QCPGraph> graph = plot->addGraph(plot->xAxis, plot->axisRect()->axis(QCPAxis::atRight, 0));
graph->setPen(QPen(QColor(250, 120, 0)));
m_graphList.append(graph);
}
connect(&m_dataTimer, SIGNAL(timeout()), this, SLOT(onDrawData3()));
m_dataTimer.start(INTERVAL_SHOW);
}
void MainWindow::on_btnFsc_clicked()
{
}
void MainWindow::on_btnStart_clicked()
{
NetConnectHelper::instance()->sendStartCmd();
}
void MainWindow::on_btnStop_clicked()
{
NetConnectHelper::instance()->sendStopCmd();
}
void MainWindow::onDrawData()
{
NetConnectHelper::instance()->getDataContainer(m_dataContainer);
for (int channel=0; channel<CHANNEL_SIZE; channel++) {
// set plot
QString plotControlName = "channel" + QString::number(channel);
QCustomPlot* plot = this->findChild<QCustomPlot*>(plotControlName);
if (!plot) {
qWarning() << "Find plot error: can't find--- " << plotControlName;
}
QPointer<QCPGraph> graph = m_graphList.at(channel);
QVector<double>* dataList = m_dataContainer.value(channel);
if (dataList) {
if (dataList->size() > 0) {
while (dataList->size() > 0) {
graph->addData(graph->dataCount(), dataList->takeFirst());
}
plot->xAxis->rescale();
graph->rescaleValueAxis(false, true);
plot->xAxis->setRange(plot->xAxis->range().upper, POINT_SHOW, Qt::AlignRight);
plot->replot();
}
} else {
qWarning() << "Channel" << channel << "'s dataList is null.";
}
}
}
void MainWindow::onDrawData3()
{
NetConnectHelper::instance()->getDataContainer(m_dataContainer);
for (int channel=0; channel<CHANNEL_SIZE; channel++) {
// set plot
QString plotControlName = "channel" + QString::number(channel);
QCustomPlot* plot = this->findChild<QCustomPlot*>(plotControlName);
if (!plot) {
qWarning() << "Find plot error: can't find--- " << plotControlName;
}
QPointer<QCPGraph> graph = m_graphList.at(channel);
QVector<double>* dataList = m_dataContainer.value(channel);
if (dataList) {
if (dataList->size() > 0) {
if (dataList->size() > POINT_SHOW) {
dataList->remove(0, dataList->size()-POINT_SHOW);
}
graph->setData(m_xAxisValue, *dataList);
//dataList->clear();
plot->xAxis->rescale();
graph->rescaleValueAxis(false, true);
plot->xAxis->setRange(plot->xAxis->range().upper, POINT_SHOW, Qt::AlignRight);
plot->replot();
}
} else {
qWarning() << "Channel" << channel << "'s dataList is null.";
}
}
}
//void MainWindow::onDrawData2()
//{
// NetConnectHelper::instance()->getDataContainer(m_dataContainer);
// static QTime time(QTime::currentTime());
// // calculate two new data points:
// double key = time.elapsed()/1000.0; // time elapsed since start of demo, in seconds
// for (int channel=0; channel<CHANNEL_SIZE; channel++) {
// // set plot
// QString plotControlName = "channel" + QString::number(channel);
// QCustomPlot* plot = this->findChild<QCustomPlot*>(plotControlName);
// if (!plot) {
// qWarning() << "Find plot error: can't find--- " << plotControlName;
// }
// QPointer<QCPGraph> graph = m_graphList.at(channel);
// QVector<double>* dataList = m_dataContainer.value(channel);
// if (dataList) {
// if (dataList->size() > 0) {
// graph->addData(key, dataList->takeFirst());
// dataList->clear();
// plot->xAxis->rescale();
// graph->rescaleValueAxis(false, true);
// plot->xAxis->setRange(key, 8, Qt::AlignRight);
// plot->replot();
// }
// } else {
// qWarning() << "Channel" << channel << "'s dataList is null.";
// }
// }
//}
|
96761562ce67f8b2f5a6e9c19b925609545cefbe | 717b46277594cb7d3cd38dc0870fb61f8e64b5c5 | /Rearrange/main.cpp | 64d4bddd53d5a081406f905fbfbc8fe65f8296dc | [
"MIT"
] | permissive | colorhistory/data-structure-and-algorithm | bda642732e31e03083b5cff992e739724dd82d98 | 402d1ab29e627ebd471632080e5b7194fe892a78 | refs/heads/master | 2020-05-30T12:54:12.846239 | 2019-07-04T22:46:06 | 2019-07-04T22:46:06 | 183,998,674 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 368 | cpp | main.cpp | #include <iostream>
using namespace std;
template <typename T>
void Rearrange(T a[], int n, int r[]) {
T *u = new T[n + 1];
// move elements
for (int i = 1; i != n; ++i) {
u[r[i]] = a[i];
}
for (int i = 1; i != n; ++i) {
a[i] = u[i];
}
delete[] u;
}
int main() {
cout << "Hello World!" << endl;
return 0;
}
|
5d1cb99f11e053fb8a021931aa2460633fc57116 | e45e32605372dbcea6aedc6b751660f0132ea48b | /1ShootingGame/Effect.h | ba537955a277a4ec096bb4c608e53a471171ddcb | [] | no_license | taehwan642/THFramework | 6beb7af823c723fdb62651f73e7f709facf0c874 | 31dd426df383cc71a13e75eda9b0d312fec160c3 | refs/heads/main | 2023-09-05T14:21:48.408068 | 2021-10-05T05:34:23 | 2021-10-05T05:34:23 | 330,841,582 | 10 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 331 | h | Effect.h | #pragma once
#include "Singleton.h"
#include "Sprite.h"
class Effect :
public Sprite
{
public:
Effect();
void Update() override;
};
class EffectManager :
public Singleton<EffectManager>
{
public:
vector<Effect*> effects;
void CreateEffect();
void SpawnEffect(Vec2 pos);
void DeleteEffect();
}; |
f276b50f106fd716143169e1275fdd2b51f6f8d0 | 1bf8b46afad5402fe6fa74293b464e1ca5ee5fd7 | /SDK/ST_CutsceneReplaceActorInfo_structs.h | 87e82b50921a91585162b6795a49192ee3df979e | [] | no_license | LemonHaze420/ShenmueIIISDK | a4857eebefc7e66dba9f667efa43301c5efcdb62 | 47a433b5e94f171bbf5256e3ff4471dcec2c7d7e | refs/heads/master | 2021-06-30T17:33:06.034662 | 2021-01-19T20:33:33 | 2021-01-19T20:33:33 | 214,824,713 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,375 | h | ST_CutsceneReplaceActorInfo_structs.h | #pragma once
// Name: Shenmue3SDK, Version: 1.4.1
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Script Structs
//---------------------------------------------------------------------------
// UserDefinedStruct ST_CutsceneReplaceActorInfo.ST_CutsceneReplaceActorInfo
// 0x0020
struct FST_CutsceneReplaceActorInfo
{
class AActor* SourceActor_2_BD8A801F4914C5626E382994CC1A2D85; // 0x0000(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnTemplate, IsPlainOldData)
struct FName SocketName_6_528DB2754B227DDB739048B4FCB66903; // 0x0008(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
float RotZOffset_8_7912E2534400DBBE95EB50A7213E831E; // 0x0010(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x4]; // 0x0014(0x0004) MISSED OFFSET
struct FName CharaName_11_B4FB5C1747B883BCFD6ADE999C516E74; // 0x0018(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
cf9ebb0bd4f0b7ae528c16058b9b2f281cb07e55 | d07da6c4924b053a9bbc2d434015bbbd5a31905b | /Ghost XpressView.h | e32e80b9e700328b2be911cea8d7626a5994a9c2 | [
"MIT"
] | permissive | theghostofc/Ghost-Xpress | d4b519581c50d1bfedd9528d34ef093e76eeba08 | d0e476f4d854d4c19a0ac61a093cb07fbc7ee1f5 | refs/heads/master | 2021-08-23T02:56:39.190994 | 2017-12-02T18:53:23 | 2017-12-02T18:53:23 | 112,861,629 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,292 | h | Ghost XpressView.h | // Ghost XpressView.h : interface of the CGhostXpressView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_GHOSTXPRESSVIEW_H__7CBB600E_B7F7_11D9_B539_FF062122A253__INCLUDED_)
#define AFX_GHOSTXPRESSVIEW_H__7CBB600E_B7F7_11D9_B539_FF062122A253__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "catalog.h"
class CGhostXpressView : public CListView
{
protected: // create from serialization only
CGhostXpressView();
DECLARE_DYNCREATE(CGhostXpressView)
// Attributes
public:
CGhostXpressDoc* GetDocument();
CGhostXpressApp *m_pApp;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGhostXpressView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
//}}AFX_VIRTUAL
// Implementation
public:
void Select(CString name);
void Refresh(CString strPathName);
virtual ~CGhostXpressView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
void GetAttribString(DWORD attrib, char buff[]);
//void AddItem(Catalog fd, int index=-1);
void AddItem(FileData fd, int index=-1);
// Generated message map functions
protected:
CString GetFileName(CString pathName, int style=0);
//{{AFX_MSG(CGhostXpressView)
afx_msg void OnViewRefresh();
afx_msg void OnEditFind();
afx_msg void OnDblclk(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct);
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in Ghost XpressView.cpp
inline CGhostXpressDoc* CGhostXpressView::GetDocument()
{ return (CGhostXpressDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GHOSTXPRESSVIEW_H__7CBB600E_B7F7_11D9_B539_FF062122A253__INCLUDED_)
|
666ab069d5f0b7837e8b46886848acf0bb06acec | 96f3e2fc82536e5963bda2445035f8f4fb71aabc | /win-client/src/Modules/UserList/IUserListModule.cpp | cac99c05a756f61fd12ae231b29d9076e17d265f | [
"BSD-2-Clause",
"Apache-2.0"
] | permissive | jdtsg/TeamTalk | 5266083f9fcfc901aec287235969d7a9b99e97ff | 69fe6ac5a64f0679f61b81f8c77e01aca8716155 | refs/heads/master | 2020-03-21T12:25:03.406263 | 2018-06-25T09:04:04 | 2018-06-25T09:04:04 | 138,551,294 | 1 | 0 | Apache-2.0 | 2018-06-25T06:16:41 | 2018-06-25T06:16:41 | null | UTF-8 | C++ | false | false | 1,987 | cpp | IUserListModule.cpp | /*******************************************************************************
* @file IUserListModule.cpp 2014\8\26 16:36:25 $
* @author 快刀<kuaidao@mogujie.com>
* @brief
******************************************************************************/
#include "stdafx.h"
#include "Modules/IUserListModule.h"
#include "Modules/ITcpClientModule.h"
/******************************************************************************/
NAMESPACE_BEGIN(module)
CString UserInfoEntity::getRealName()const
{
if (!csNickName.IsEmpty())
{
return csNickName;
}
else if (!csName.IsEmpty())
{
return csName;
}
else
{
return util::stringToCString(sId);
}
}
std::string UserInfoEntity::getAvatarPath()const
{
//获取当前登录状态
UInt8 netState = module::getTcpClientModule()->getTcpClientNetState();
std::string path;
if (module::TCPCLIENT_STATE_OK == netState
&& IM::BaseDefine::USER_STATUS_OFFLINE != onlineState)
{
path = avatarLocalPath;
if (path.empty())
{
std::string sDataPath = util::cStringToString(module::getMiscModule()->getDefaultAvatar());
path = sDataPath + "default.png";
}
}
else
{
path = avatarGrayLocalPath;
if (path.empty())
{
std::string sDataPath = util::cStringToString(module::getMiscModule()->getDefaultAvatar());
path = sDataPath + "gray_default.png";
}
}
return path;
}
std::string UserInfoEntity::getAvatarPathWithoutOnlineState()const
{
std::string path = avatarLocalPath;
if (path.empty())
{
std::string sDataPath = util::cStringToString(module::getMiscModule()->getDefaultAvatar());
path = sDataPath + "default.png";
}
return path;
}
BOOL UserInfoEntity::isOnlne() const
{
UInt8 netState = module::getTcpClientModule()->getTcpClientNetState();
return (IM::BaseDefine::USER_STATUS_ONLINE == onlineState && module::TCPCLIENT_STATE_OK == netState) ? TRUE : FALSE;
}
NAMESPACE_END(module)
/******************************************************************************/ |
7b504e968f3d0736004c6e64f92beb6df494aa1f | dcda4f97fbe3e42c72b516dc22e0bf115e536d5f | /src/core/runtime/ipc_signal.cpp | 485a5c915a7c584750034f2d653757cfc09e9088 | [
"LicenseRef-scancode-unknown-license-reference",
"NCSA"
] | permissive | maxmckone7/ROCR-Runtime | ec9f200cf3af301475afa371366d17783aafe72b | f114e4d4153f89c1e712f679b307b83ce099240d | refs/heads/master | 2023-06-30T21:51:43.392886 | 2021-07-30T22:10:20 | 2021-07-30T22:10:20 | 393,473,813 | 1 | 1 | NOASSERTION | 2021-08-06T18:56:33 | 2021-08-06T18:56:00 | null | UTF-8 | C++ | false | false | 3,818 | cpp | ipc_signal.cpp | ////////////////////////////////////////////////////////////////////////////////
//
// The University of Illinois/NCSA
// Open Source License (NCSA)
//
// Copyright (c) 2014-2020, Advanced Micro Devices, Inc. All rights reserved.
//
// Developed by:
//
// AMD Research and AMD HSA Software Development
//
// Advanced Micro Devices, Inc.
//
// www.amd.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal with the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimers.
// - Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimers in
// the documentation and/or other materials provided with the distribution.
// - Neither the names of Advanced Micro Devices, Inc,
// nor the names of its contributors may be used to endorse or promote
// products derived from this Software without specific prior written
// permission.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS WITH THE SOFTWARE.
//
////////////////////////////////////////////////////////////////////////////////
#include "core/inc/ipc_signal.h"
#include <utility>
#include "core/inc/runtime.h"
#include "core/inc/exceptions.h"
namespace rocr {
namespace core {
int IPCSignal::rtti_id_ = 0;
KernelMutex IPCSignal::lock_;
SharedMemory::SharedMemory(const hsa_amd_ipc_memory_t* handle, size_t len) {
hsa_status_t err = Runtime::runtime_singleton_->IPCAttach(handle, len, 0, NULL, &ptr_);
if (err != HSA_STATUS_SUCCESS) throw AMD::hsa_exception(err, "IPC memory attach failed.");
}
SharedMemory::SharedMemory(SharedMemory&& rhs) {
ptr_ = rhs.ptr_;
rhs.ptr_ = nullptr;
}
SharedMemory::~SharedMemory() {
if (ptr_ == nullptr) return;
auto err = Runtime::runtime_singleton_->IPCDetach(ptr_);
assert(err == HSA_STATUS_SUCCESS && "IPC detach failed.");
}
void IPCSignal::CreateHandle(Signal* signal, hsa_amd_ipc_signal_t* ipc_handle) {
if (!signal->isIPC())
throw AMD::hsa_exception(HSA_STATUS_ERROR_INVALID_ARGUMENT, "Signal must be IPC enabled.");
SharedSignal* shared = SharedSignal::Convert(Convert(signal));
hsa_status_t err = Runtime::runtime_singleton_->IPCCreate(shared, 4096, ipc_handle);
if (err != HSA_STATUS_SUCCESS) throw AMD::hsa_exception(err, "IPC memory create failed.");
}
Signal* IPCSignal::Attach(const hsa_amd_ipc_signal_t* ipc_signal_handle) {
SharedMemorySignal shared(ipc_signal_handle);
if (!(shared.signal()->IsIPC()))
throw AMD::hsa_exception(HSA_STATUS_ERROR_INVALID_ARGUMENT,
"IPC memory does not contain an IPC signal abi block.");
hsa_signal_t handle = SharedSignal::Convert(shared.signal());
ScopedAcquire<KernelMutex> lock(&lock_);
Signal* ret = core::Signal::DuplicateHandle(handle);
if (ret == nullptr) ret = new IPCSignal(std::move(shared));
return ret;
}
} // namespace core
} // namespace rocr
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.