hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
7c4dacd300713e0332e3d0e768aba3ac88a59819
5,628
cpp
C++
src/specifics/playfield/AIController.cpp
LukerMaster/Grzybki-Gloniki-Bateryjki
60432acdf3c1a03561022bdb2a7f4c1f39cae4fb
[ "Apache-2.0" ]
null
null
null
src/specifics/playfield/AIController.cpp
LukerMaster/Grzybki-Gloniki-Bateryjki
60432acdf3c1a03561022bdb2a7f4c1f39cae4fb
[ "Apache-2.0" ]
null
null
null
src/specifics/playfield/AIController.cpp
LukerMaster/Grzybki-Gloniki-Bateryjki
60432acdf3c1a03561022bdb2a7f4c1f39cae4fb
[ "Apache-2.0" ]
null
null
null
#include "AIController.h" void AIController::AlgaeAI(sf::Vector2i pawn_pos, Playfield& env) { std::shared_ptr<Algae> pawn = env.GetAlgae(pawn_pos); pawn->AI_done = true; // For other classes to know that AI is done for this round. if (pawn->current_food > pawn->max_food * 0.8f && rand()%2) // DIVISION { sf::Vector2i spawn_point = env.CheckAroundFor(pawn_pos, eObjType::EmptySpace); if (spawn_point != pawn_pos) { env.AddGerm(eObjType::Algae, pawn_pos, spawn_point, pawn->max_age - 1 + (rand() % 3), 100, 100, pawn->current_health / 2, pawn->current_food / 2); pawn->current_health /= 2; pawn->current_food /= 2; } } else if (pawn->current_food < pawn->max_food) // PHOTOSYNTHESIS { pawn->current_food += 35; } if (pawn->current_health < pawn->max_health && pawn->current_food > pawn->max_food * 0.5f) // SELF-HEALING { pawn->current_food -= 2; pawn->current_health += 1; } pawn->UpdateStats(1); } void AIController::BacteriaAI(sf::Vector2i pawn_pos, Playfield& env) { std::shared_ptr<Bacteria> pawn = env.GetBacteria(pawn_pos); pawn->AI_done = true; if (pawn->current_food > pawn->max_food * 0.8f && rand() % 2) // DIVISION { sf::Vector2i spawn_point = env.CheckAroundFor(pawn_pos, eObjType::EmptySpace); if (spawn_point != pawn_pos) { env.AddGerm(eObjType::Bacteria, pawn_pos, spawn_point, pawn->max_age - 2 + (rand() % 5), 100, 100, pawn->current_health / 2, pawn->current_food / 2); pawn->current_health /= 2; pawn->current_food /= 2; } } if (pawn->current_health < pawn->max_health && pawn->current_food > pawn->max_food * 0.25f && rand()%4 > 2) // SELF-HEALING { pawn->current_food -= 4; pawn->current_health += 1; } else { sf::Vector2i food_pos = env.CheckAroundFor(pawn_pos, eObjType::Algae); if (food_pos != pawn_pos) { if (rand() % 11 > 6) { pawn->current_food += env.GetGerm(food_pos)->current_food; env.ForceMove(pawn_pos, food_pos); pawn = env.GetBacteria(food_pos); } else { sf::Vector2i new_pos = env.CheckAroundFor(pawn_pos, eObjType::EmptySpace); if (env.Move(pawn_pos, new_pos)) pawn = env.GetBacteria(new_pos); } } else { food_pos = env.CheckAroundFor(pawn_pos, eObjType::Bacteria); if (food_pos != pawn_pos) { if (rand() % 11 > 7) { pawn->current_food += env.GetGerm(food_pos)->current_food; env.ForceMove(pawn_pos, food_pos); pawn = env.GetBacteria(food_pos); } } else { sf::Vector2i new_pos = env.CheckAroundFor(pawn_pos, eObjType::EmptySpace); if (env.Move(pawn_pos, new_pos)) pawn = env.GetBacteria(new_pos); } } } pawn->UpdateStats(1); } void AIController::ShroomAI(sf::Vector2i pawn_pos, Playfield& env) { std::shared_ptr<Shroom> pawn = env.GetShroom(pawn_pos); pawn->AI_done = true; if (pawn->current_health < pawn->max_health && pawn->current_food > pawn->max_food * 0.8f && rand() % 4 > 2) // SELF-HEALING { pawn->current_food -= 1; pawn->current_health += 2; } if (pawn->current_food > pawn->max_food * 0.8f && rand() % 2) // DIVISION { sf::Vector2i spawn_point = env.CheckAroundFor(pawn_pos, eObjType::EmptySpace); if (spawn_point != pawn_pos) { env.AddGerm(eObjType::Shroom, pawn_pos, spawn_point, pawn->max_age - 10 + (rand() % 21), 100, 100, pawn->current_health / 2, pawn->current_food / 2); pawn->current_health /= 2; pawn->current_food /= 2; } } else { sf::Vector2i food_pos = env.CheckAroundFor(pawn_pos, eObjType::Food); if (pawn_pos != food_pos) { if (rand() % 2) { pawn->current_food += env.GetFood(food_pos)->food_value; env.ForceMove(pawn_pos, food_pos); pawn = env.GetShroom(food_pos); } } else { sf::Vector2i new_pos = env.CheckAroundFor(pawn_pos, eObjType::EmptySpace); if (env.Move(pawn_pos, new_pos)) pawn = env.GetShroom(new_pos); } } pawn->UpdateStats(1); } void AIController::Decide(sf::Vector2i pawn_pos, Playfield& env) { if (!env.GetObj(pawn_pos)->AI_done) { if (env.GetObj(pawn_pos)->type == eObjType::Algae) AlgaeAI(pawn_pos, env); if (env.GetObj(pawn_pos)->type == eObjType::Bacteria) BacteriaAI(pawn_pos, env); if (env.GetObj(pawn_pos)->type == eObjType::Shroom) ShroomAI(pawn_pos, env); } } void AIController::EnableAI(Playfield& env) { for (int x = 0; x < env.GetSize(); x++) { for (int y = 0; y < env.GetSize(); y++) { env.GetObj(x, y)->AI_done = false; } } } void AIController::ResetAnimPositions(Playfield& env) { for (int x = 0; x < env.GetSize(); x++) { for (int y = 0; y < env.GetSize(); y++) { env.GetObj(x, y)->start_pos = env.GetObj(x, y)->end_pos; } } } void AIController::CheckForDead(Playfield& env) { for (int x = 0; x < env.GetSize(); x++) { for (int y = 0; y < env.GetSize(); y++) { if (env.GetObj(x, y)->type == eObjType::Algae || env.GetObj(x, y)->type == eObjType::Shroom || env.GetObj(x, y)->type == eObjType::Bacteria) { if (env.GetGerm(x, y)->current_health <= 0) { if (env.GetGerm(x, y)->current_food <= 0) { env.events.AddDeath(eDeathType::starved, env.GetGerm(x, y)); } else if (env.GetGerm(x, y)->current_age > env.GetGerm(x, y)->max_age) { env.events.AddDeath(eDeathType::old_age, env.GetGerm(x, y)); } float food_val = env.GetGerm(x, y)->current_food + 50; int tex_rect = (food_val / 25) - 2; if (tex_rect > 3) tex_rect = 3; env.Delete({ x, y }); env.AddFood({ x, y }, { x ,y }, food_val, tex_rect); } } } } }
24.363636
143
0.625444
LukerMaster
7c51f9a98a225b38af987d847be9264ebfb0018e
220
cpp
C++
src/CglModule.cpp
seanisom/flightsimlib
490c2db824edd5302fd39d4ab020759b2e01d282
[ "MIT" ]
3
2020-06-21T00:03:14.000Z
2021-09-19T15:20:48.000Z
src/CglModule.cpp
seanisom/flightsimlib
490c2db824edd5302fd39d4ab020759b2e01d282
[ "MIT" ]
1
2021-08-21T22:53:01.000Z
2021-08-24T02:13:59.000Z
src/CglModule.cpp
seanisom/flightsimlib
490c2db824edd5302fd39d4ab020759b2e01d282
[ "MIT" ]
null
null
null
#include "CglModule.h" #include "VectorTile.h" namespace flightsimlib::cgl { IVectorTile* CCglModuleV1::CreateVectorTile() const { // Simple factory - worry about wrapping another day return new VectorTile(); } }
13.75
53
0.740909
seanisom
7c619138e9e5b0fac8f438d7f503f67648034743
1,580
hpp
C++
source/gloperate/include/gloperate/resources/ResourceManager.hpp
apopiak/gloperate
b4194a1c3b2dc4ea1102a2c5ae3ff3b5540f31cd
[ "MIT" ]
null
null
null
source/gloperate/include/gloperate/resources/ResourceManager.hpp
apopiak/gloperate
b4194a1c3b2dc4ea1102a2c5ae3ff3b5540f31cd
[ "MIT" ]
null
null
null
source/gloperate/include/gloperate/resources/ResourceManager.hpp
apopiak/gloperate
b4194a1c3b2dc4ea1102a2c5ae3ff3b5540f31cd
[ "MIT" ]
null
null
null
#pragma once #include <gloperate/resources/ResourceManager.h> #include <gloperate/resources/Loader.h> #include <gloperate/resources/Storer.h> namespace gloperate { /** * @brief * Load resource from file */ template <typename T> T * ResourceManager::load(const std::string & filename) const { // Get file extension std::string ext = getFileExtension(filename); // Find suitable loader for (AbstractLoader * loader : m_loaders) { // Check loader type Loader<T> * concreteLoader = dynamic_cast<Loader<T> *>(loader); if (concreteLoader) { // Check if filetype is supported if (concreteLoader->canLoad(ext)) { // Use loader return concreteLoader->load(filename); } } } // No suitable loader found return nullptr; } /** * @brief * Store resource to file */ template <typename T> bool ResourceManager::store(const std::string & filename, T * resource) const { // Get file extension std::string ext = getFileExtension(filename); // Find suitable storer for (AbstractStorer * storer : m_storers) { // Check storer type Storer<T> * concreteStorer = dynamic_cast<Storer<T> *>(storer); if (concreteStorer) { // Check if filetype is supported if (concreteStorer->canStore(ext)) { // Use store return concreteStorer->store(filename, resource); } } } // No suitable loader found return false; } } // namespace gloperate
23.58209
77
0.607595
apopiak
7c61a037641f1c83d2af657e8db25257e29820a3
51,182
cpp
C++
roo_material_icons/round/48/search.cpp
dejwk/roo_material_icons
f559ce25b6ee2fdf67ed4f8b0bedfce2aaefb885
[ "MIT" ]
null
null
null
roo_material_icons/round/48/search.cpp
dejwk/roo_material_icons
f559ce25b6ee2fdf67ed4f8b0bedfce2aaefb885
[ "MIT" ]
null
null
null
roo_material_icons/round/48/search.cpp
dejwk/roo_material_icons
f559ce25b6ee2fdf67ed4f8b0bedfce2aaefb885
[ "MIT" ]
null
null
null
#include "search.h" using namespace roo_display; // Image file ic_round_48_search_bathroom 48x48, 4-bit Alpha, RLE, 280 bytes. static const uint8_t ic_round_48_search_bathroom_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x19, 0xCF, 0xFF, 0xFC, 0x81, 0xC8, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0D, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0x87, 0x10, 0xE8, 0x0C, 0x2F, 0x0C, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xFF, 0xA8, 0x6B, 0x63, 0x11, 0x36, 0xBF, 0xFA, 0x71, 0xFF, 0x0A, 0x02, 0x71, 0x03, 0x0B, 0xFF, 0x71, 0xFE, 0x07, 0x75, 0x08, 0xFE, 0x71, 0xFD, 0x07, 0x77, 0x08, 0xFD, 0x71, 0xFC, 0x0A, 0x77, 0x20, 0xBF, 0xC7, 0x1F, 0xC0, 0x17, 0x72, 0x03, 0xFC, 0x71, 0xFB, 0x09, 0x77, 0x40, 0xBF, 0xB7, 0x1F, 0xB0, 0x47, 0x74, 0x06, 0xFB, 0x71, 0xFB, 0x01, 0x77, 0x40, 0x3F, 0xB7, 0x1F, 0xB7, 0x75, 0x01, 0xFB, 0x71, 0xFB, 0x01, 0x77, 0x40, 0x3F, 0xB7, 0x1F, 0xB0, 0xA0, 0x17, 0x72, 0x02, 0x0B, 0xFB, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xFD, 0x82, 0xB3, 0x4C, 0xA8, 0x2B, 0x34, 0xCA, 0x82, 0xB3, 0x4C, 0xFD, 0x71, 0xFD, 0x02, 0x20, 0x4A, 0x02, 0x20, 0x4A, 0x02, 0x20, 0x4F, 0xD7, 0x1F, 0xD0, 0x12, 0x03, 0xA0, 0x12, 0x03, 0xA0, 0x12, 0x03, 0xFD, 0x71, 0xFD, 0x82, 0xA1, 0x2B, 0xA8, 0x2A, 0x12, 0xBA, 0x82, 0xA1, 0x2B, 0xFD, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xFD, 0x82, 0xB3, 0x4C, 0xA8, 0x2B, 0x34, 0xCA, 0x82, 0xB3, 0x4C, 0xFD, 0x71, 0xFD, 0x02, 0x20, 0x4A, 0x02, 0x20, 0x4A, 0x02, 0x20, 0x4F, 0xD7, 0x1F, 0xD0, 0x12, 0x03, 0xA0, 0x12, 0x03, 0xA0, 0x12, 0x03, 0xFD, 0x71, 0xFD, 0x82, 0xA1, 0x2B, 0xA8, 0x2A, 0x12, 0xBA, 0x82, 0xA1, 0x2B, 0xFD, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x0E, 0x80, 0xC2, 0xF0, 0xD7, 0x10, 0xB8, 0x0C, 0x2F, 0x09, 0x71, 0x02, 0x80, 0xC1, 0xF0, 0xE0, 0x17, 0x28, 0x12, 0xBE, 0xFF, 0xFF, 0xC8, 0x1E, 0xA1, 0x80, 0xB8, 0x10, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_bathroom() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_bathroom_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_bed 48x48, 4-bit Alpha, RLE, 179 bytes. static const uint8_t ic_round_48_search_bed_data[] PROGMEM = { 0x80, 0xFC, 0x50, 0x81, 0x6C, 0xEF, 0x98, 0x1E, 0xC6, 0x28, 0x16, 0xCE, 0xF9, 0x81, 0xEC, 0x67, 0x72, 0x01, 0x0C, 0xFF, 0x00, 0xCF, 0xF0, 0xC0, 0x17, 0x70, 0xCF, 0xFF, 0xFC, 0x0C, 0x76, 0x06, 0xFF, 0xFF, 0xE0, 0x67, 0x50, 0xCB, 0x0B, 0x01, 0x71, 0x01, 0x0B, 0xC0, 0xB0, 0x17, 0x10, 0x10, 0xBB, 0x0C, 0x75, 0x0E, 0xB0, 0x17, 0x30, 0x1C, 0x01, 0x73, 0x01, 0xB0, 0xE7, 0x5C, 0x75, 0xC7, 0x5C, 0x75, 0xC7, 0x5C, 0x75, 0xC7, 0x5C, 0x75, 0xC7, 0x5C, 0x75, 0xC7, 0x5C, 0x75, 0xC7, 0x58, 0x0C, 0x0F, 0x74, 0x01, 0x80, 0xC0, 0xF0, 0x17, 0x30, 0xC8, 0x0C, 0x0F, 0x0C, 0x72, 0x06, 0x80, 0xC2, 0xF0, 0x67, 0x10, 0xCB, 0x0B, 0x01, 0x77, 0x77, 0x01, 0x0B, 0xB0, 0xC7, 0x10, 0xEB, 0x01, 0x77, 0x77, 0x20, 0x1B, 0x0E, 0x71, 0xC7, 0x77, 0x74, 0xC7, 0x1C, 0x77, 0x77, 0x4C, 0x71, 0xC7, 0x77, 0x74, 0xC7, 0x1C, 0x77, 0x77, 0x4C, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xC7, 0x77, 0x74, 0xC7, 0x1C, 0x77, 0x77, 0x4C, 0x71, 0x0D, 0xA0, 0xD7, 0x77, 0x74, 0x0D, 0xA0, 0xD7, 0x18, 0x24, 0xDD, 0x47, 0x77, 0x74, 0x82, 0x4D, 0xD4, 0x80, 0xFC, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_bed() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_bed_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_bedroom_baby 48x48, 4-bit Alpha, RLE, 275 bytes. static const uint8_t ic_round_48_search_bedroom_baby_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x1F, 0xA0, 0xFD, 0x0E, 0xFF, 0xFE, 0x71, 0xF9, 0x06, 0x60, 0x7F, 0xFF, 0xB7, 0x1F, 0xA0, 0x96, 0x0C, 0xFF, 0xFA, 0x71, 0xF9, 0x0E, 0x02, 0x60, 0x3F, 0xFF, 0xA7, 0x1F, 0x90, 0x47, 0x10, 0xAF, 0xFF, 0x97, 0x1F, 0x0A, 0x72, 0x02, 0xFF, 0xF9, 0x71, 0xF0, 0xB2, 0x01, 0x0A, 0x60, 0x7F, 0xFF, 0x71, 0xF9, 0x81, 0x98, 0xE9, 0x77, 0x30, 0x3F, 0xB7, 0x1F, 0xD7, 0x73, 0x04, 0xFB, 0x71, 0xFD, 0x77, 0x2F, 0xD7, 0x1F, 0xD7, 0x72, 0xFD, 0x71, 0xFD, 0x77, 0x2F, 0xD7, 0x1F, 0xD7, 0x72, 0xFD, 0x71, 0xFD, 0x77, 0x2F, 0xD7, 0x1F, 0xC0, 0xA7, 0x72, 0x0A, 0xFC, 0x71, 0xF0, 0xC0, 0xAA, 0x02, 0x20, 0x04, 0x71, 0x04, 0x03, 0x20, 0x2A, 0x0B, 0x0C, 0xF7, 0x1E, 0x0D, 0x20, 0x40, 0x72, 0x89, 0x01, 0xEF, 0xEB, 0xA9, 0x9A, 0xBA, 0x0E, 0x30, 0x70, 0x42, 0x0D, 0xE7, 0x1E, 0x0B, 0x60, 0x9F, 0xD0, 0x86, 0x0B, 0xE7, 0x1F, 0x08, 0x50, 0xAF, 0xD0, 0x95, 0x07, 0xF7, 0x1F, 0x90, 0xC0, 0x24, 0x83, 0x15, 0x9C, 0xDA, 0x83, 0xDC, 0x95, 0x14, 0x02, 0x0C, 0xF9, 0x71, 0xFA, 0x81, 0xE7, 0x17, 0x72, 0x81, 0x17, 0xEF, 0xA7, 0x1F, 0xC8, 0x1E, 0x82, 0x75, 0x81, 0x28, 0xEF, 0xC7, 0x1F, 0xF8, 0x92, 0xD9, 0x53, 0x21, 0x12, 0x35, 0x9D, 0xFF, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x0D, 0x80, 0xC2, 0xF0, 0xD7, 0x10, 0xA8, 0x0C, 0x2F, 0x0A, 0x71, 0x01, 0x0E, 0x80, 0xC0, 0xF0, 0xE0, 0x17, 0x28, 0x11, 0xAD, 0xFF, 0xFF, 0xC8, 0x1D, 0xA1, 0x80, 0xB8, 0x10, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_bedroom_baby() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_bedroom_baby_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_bedroom_child 48x48, 4-bit Alpha, RLE, 232 bytes. static const uint8_t ic_round_48_search_bedroom_child_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xFD, 0x81, 0xD5, 0x17, 0x38, 0x11, 0x5D, 0xFD, 0x71, 0xFC, 0x0D, 0x01, 0x77, 0x01, 0x0D, 0xFC, 0x71, 0xFC, 0x05, 0x77, 0x20, 0x5F, 0xC7, 0x1F, 0xC0, 0x12, 0xFD, 0x20, 0x1F, 0xC7, 0x1F, 0xC3, 0xFD, 0x3F, 0xC7, 0x1F, 0xC3, 0xFD, 0x3F, 0xC7, 0x1F, 0xC3, 0xFD, 0x3F, 0xC7, 0x1F, 0xB0, 0x97, 0x74, 0x09, 0xFB, 0x71, 0xFA, 0x05, 0x77, 0x60, 0x5F, 0xA7, 0x1F, 0x90, 0x97, 0x77, 0x10, 0x9F, 0x97, 0x1F, 0x90, 0x32, 0x06, 0x0E, 0xFF, 0x0E, 0x06, 0x20, 0x3F, 0x97, 0x1F, 0x93, 0x0E, 0xFF, 0xA0, 0xE3, 0xF9, 0x71, 0xF9, 0x3F, 0xFC, 0x3F, 0x97, 0x1F, 0x93, 0xFF, 0xC3, 0xF9, 0x71, 0xF9, 0x77, 0x73, 0xF9, 0x71, 0xF9, 0x77, 0x73, 0xF9, 0x71, 0xF9, 0x77, 0x73, 0xF9, 0x71, 0xF9, 0x3F, 0xFC, 0x3F, 0x97, 0x1F, 0x93, 0xFF, 0xC3, 0xF9, 0x71, 0xF9, 0x81, 0x70, 0x7F, 0xFC, 0x81, 0x70, 0x7F, 0x97, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x72, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x18, 0x0B, 0x81, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_bedroom_child() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_bedroom_child_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_bedroom_parent 48x48, 4-bit Alpha, RLE, 245 bytes. static const uint8_t ic_round_48_search_bedroom_parent_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xFA, 0x07, 0x02, 0x78, 0x21, 0x66, 0x17, 0x02, 0x07, 0xFA, 0x71, 0xF9, 0x04, 0x77, 0x71, 0x04, 0xF9, 0x71, 0xF0, 0xA7, 0x77, 0x30, 0xAF, 0x71, 0xF0, 0x62, 0x07, 0xF0, 0x72, 0x07, 0xF0, 0x72, 0x06, 0xF7, 0x1F, 0x04, 0x20, 0x7F, 0x07, 0x20, 0x7F, 0x07, 0x20, 0x4F, 0x71, 0xF0, 0x42, 0x07, 0xF0, 0x72, 0x07, 0xF0, 0x72, 0x04, 0xF7, 0x1F, 0x04, 0x20, 0x7F, 0x07, 0x20, 0x7F, 0x07, 0x20, 0x4F, 0x71, 0xF0, 0x47, 0x77, 0x30, 0x4F, 0x71, 0xF0, 0x47, 0x77, 0x30, 0x4F, 0x71, 0xE0, 0xD7, 0x77, 0x50, 0xDE, 0x71, 0xE0, 0x52, 0x04, 0x0D, 0xFF, 0xC0, 0xD0, 0x42, 0x05, 0xE7, 0x1E, 0x01, 0x20, 0xDF, 0xFE, 0x0D, 0x20, 0x1E, 0x71, 0xE3, 0xFF, 0xF9, 0x3E, 0x71, 0xE3, 0xFF, 0xF9, 0x3E, 0x71, 0xE7, 0x77, 0x7E, 0x71, 0xE7, 0x77, 0x7E, 0x71, 0xE7, 0x77, 0x7E, 0x71, 0xE3, 0xFF, 0xF9, 0x3E, 0x71, 0xE3, 0xFF, 0xF9, 0x3E, 0x71, 0xE8, 0x17, 0x07, 0xFF, 0xF9, 0x81, 0x70, 0x7E, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x0D, 0x80, 0xC2, 0xF0, 0xD7, 0x10, 0xA8, 0x0C, 0x2F, 0x0A, 0x71, 0x01, 0x0E, 0x80, 0xC0, 0xF0, 0xE0, 0x17, 0x28, 0x11, 0xAD, 0xFF, 0xFF, 0xC8, 0x1D, 0xA1, 0x80, 0xB8, 0x10, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_bedroom_parent() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_bedroom_parent_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_blender 48x48, 4-bit Alpha, RLE, 292 bytes. static const uint8_t ic_round_48_search_blender_data[] PROGMEM = { 0x80, 0xBA, 0x00, 0x04, 0x0D, 0xC0, 0xD0, 0x48, 0x0C, 0x40, 0x0D, 0xE0, 0xD7, 0x77, 0x68, 0x11, 0xAD, 0xFF, 0xFB, 0x0B, 0x01, 0x77, 0x40, 0x10, 0xEF, 0xFF, 0xE0, 0x87, 0x74, 0x0A, 0xFF, 0xFF, 0x09, 0x77, 0x40, 0xDF, 0xFF, 0xF0, 0x77, 0x74, 0xC2, 0x04, 0xB0, 0xB7, 0x70, 0xBB, 0x04, 0x77, 0x4C, 0x20, 0x2B, 0x0D, 0x77, 0x0D, 0xB0, 0x27, 0x74, 0xC3, 0xC7, 0x7C, 0x77, 0x5C, 0x30, 0xCB, 0x03, 0x75, 0x03, 0xB0, 0xD7, 0x75, 0xC3, 0x0A, 0xB0, 0x57, 0x50, 0x5B, 0x0A, 0x77, 0x5C, 0x30, 0x8B, 0x07, 0x75, 0x07, 0xB0, 0x87, 0x75, 0xC3, 0x05, 0xB0, 0xA7, 0x50, 0xAB, 0x05, 0x77, 0x5C, 0x30, 0x3B, 0x0C, 0x75, 0x0C, 0xB0, 0x37, 0x75, 0x0D, 0xFB, 0x0E, 0x75, 0x0E, 0xB0, 0x17, 0x75, 0x0A, 0xFC, 0x01, 0x73, 0x01, 0xB0, 0xE7, 0x76, 0x01, 0x0E, 0xFB, 0x04, 0x73, 0x04, 0xB0, 0xB7, 0x77, 0x81, 0x1A, 0xDF, 0x90, 0x67, 0x30, 0x6B, 0x09, 0x77, 0x77, 0x07, 0xB0, 0x97, 0x30, 0x8B, 0x07, 0x77, 0x77, 0x04, 0xB0, 0xB7, 0x30, 0xBB, 0x04, 0x77, 0x77, 0x02, 0xB0, 0xD7, 0x30, 0xDB, 0x02, 0x77, 0x77, 0x1C, 0x73, 0xC7, 0x77, 0x72, 0x0D, 0xB0, 0x37, 0x10, 0x2B, 0x0C, 0x77, 0x77, 0x20, 0xAB, 0x05, 0x71, 0x05, 0xB0, 0xA7, 0x77, 0x72, 0x08, 0xFF, 0xA0, 0x87, 0x77, 0x72, 0x05, 0xFF, 0xA0, 0x57, 0x77, 0x72, 0x08, 0xFF, 0xA0, 0x87, 0x77, 0x71, 0x07, 0xFF, 0xC0, 0x77, 0x77, 0x60, 0x3F, 0xFE, 0x03, 0x77, 0x75, 0x0D, 0xFF, 0xE0, 0xD7, 0x77, 0x40, 0x4F, 0xA8, 0x2B, 0x11, 0xBF, 0xA0, 0x47, 0x77, 0x30, 0x9F, 0xA0, 0x12, 0x01, 0xFA, 0x09, 0x77, 0x73, 0x0C, 0xFA, 0x01, 0x20, 0x1F, 0xA0, 0xC7, 0x77, 0x30, 0xEF, 0xA8, 0x2B, 0x11, 0xBF, 0xA0, 0xE7, 0x77, 0x3F, 0xFF, 0xB7, 0x77, 0x3F, 0xFF, 0xB7, 0x77, 0x30, 0xDF, 0xFF, 0x90, 0xD7, 0x77, 0x30, 0xAF, 0xFF, 0x90, 0xA7, 0x77, 0x30, 0x10, 0xEF, 0xFE, 0x0E, 0x01, 0x77, 0x74, 0x81, 0x1A, 0xDF, 0xFA, 0x81, 0xDA, 0x18, 0x0B, 0x91, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_blender() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_blender_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_camera_indoor 48x48, 4-bit Alpha, RLE, 219 bytes. static const uint8_t ic_round_48_search_camera_indoor_data[] PROGMEM = { 0x80, 0xCE, 0x20, 0x82, 0x26, 0x62, 0x80, 0xC7, 0x00, 0x9C, 0x09, 0x80, 0xC4, 0x00, 0x20, 0xCE, 0x0C, 0x02, 0x80, 0xC1, 0x00, 0x50, 0xEF, 0x90, 0xE0, 0x57, 0x77, 0x77, 0x09, 0xFD, 0x09, 0x77, 0x77, 0x40, 0x20, 0xCF, 0xF0, 0xC0, 0x27, 0x77, 0x71, 0x05, 0x0E, 0xFF, 0xA0, 0xE0, 0x57, 0x77, 0x60, 0x9F, 0xFE, 0x09, 0x77, 0x73, 0x02, 0x0C, 0xFF, 0xF9, 0x0C, 0x02, 0x77, 0x70, 0x50, 0xEF, 0xFF, 0xB0, 0xE0, 0x57, 0x75, 0x09, 0xFF, 0xFF, 0x09, 0x77, 0x30, 0x6F, 0xFF, 0xFA, 0x06, 0x77, 0x20, 0xDF, 0xFF, 0xFA, 0x0D, 0x77, 0x2F, 0xFF, 0xFC, 0x77, 0x2F, 0xFF, 0xFC, 0x77, 0x2F, 0xFF, 0xFC, 0x77, 0x2F, 0x90, 0xB0, 0x17, 0x10, 0x10, 0xBF, 0xD7, 0x72, 0xF9, 0x01, 0x73, 0x01, 0xFD, 0x77, 0x2F, 0x97, 0x5A, 0x00, 0xBF, 0x97, 0x72, 0xF9, 0x75, 0x0B, 0x03, 0x2F, 0x97, 0x72, 0xF9, 0x77, 0x2F, 0x97, 0x72, 0xF9, 0x77, 0x2F, 0x97, 0x72, 0xF9, 0x77, 0x2F, 0x97, 0x72, 0xF9, 0x77, 0x2F, 0x97, 0x72, 0xF9, 0x75, 0x0B, 0x03, 0x2F, 0x97, 0x72, 0xF9, 0x75, 0xA0, 0x0B, 0xF9, 0x77, 0x2F, 0x90, 0x17, 0x30, 0x1F, 0xD7, 0x72, 0xF9, 0x0B, 0x01, 0x71, 0x01, 0x0B, 0xFD, 0x77, 0x2F, 0xFF, 0xFC, 0x77, 0x2F, 0xFF, 0xFC, 0x77, 0x2F, 0xFF, 0xFC, 0x77, 0x2F, 0xFF, 0xFC, 0x77, 0x20, 0xCF, 0xFF, 0xFA, 0x0C, 0x77, 0x20, 0x5F, 0xFF, 0xFA, 0x05, 0x77, 0x30, 0x8F, 0xFF, 0xF0, 0x87, 0x75, 0x02, 0x06, 0x80, 0xA4, 0x70, 0x60, 0x28, 0x0C, 0xC6, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_camera_indoor() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_camera_indoor_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_camera_outdoor 48x48, 4-bit Alpha, RLE, 243 bytes. static const uint8_t ic_round_48_search_camera_outdoor_data[] PROGMEM = { 0x80, 0xDC, 0x10, 0x84, 0x2A, 0xEE, 0xA2, 0x80, 0xC5, 0x00, 0x50, 0xEC, 0x0E, 0x05, 0x80, 0xC3, 0x00, 0x9F, 0x90, 0x98, 0x0C, 0x00, 0x02, 0x0C, 0xFB, 0x0C, 0x02, 0x77, 0x77, 0x50, 0x50, 0xEC, 0x82, 0xE5, 0x5E, 0xC0, 0xE0, 0x57, 0x77, 0x73, 0x09, 0xD0, 0xC0, 0x22, 0x02, 0x0C, 0xD0, 0x97, 0x77, 0x70, 0x20, 0xCD, 0x09, 0x60, 0x9D, 0x0C, 0x02, 0x77, 0x74, 0x05, 0x0E, 0xC0, 0xE0, 0x57, 0x10, 0x50, 0xEC, 0x0E, 0x05, 0x77, 0x72, 0x09, 0xD0, 0xC0, 0x27, 0x30, 0x20, 0xCD, 0x09, 0x77, 0x60, 0x20, 0xCD, 0x09, 0x77, 0x09, 0xD0, 0xC0, 0x27, 0x73, 0x02, 0x0E, 0xC0, 0xE0, 0x57, 0x72, 0x05, 0x0E, 0xC0, 0xE0, 0x27, 0x72, 0x0A, 0xC0, 0xC0, 0x27, 0x74, 0x02, 0x0C, 0xC0, 0xA7, 0x72, 0x0E, 0xB0, 0x97, 0x77, 0x10, 0x9B, 0x0E, 0x77, 0x2C, 0x77, 0x73, 0xC7, 0x72, 0xC7, 0x77, 0x3C, 0x77, 0x2C, 0x80, 0xD0, 0x0C, 0x80, 0xD0, 0x0C, 0x75, 0x04, 0x0D, 0xF9, 0x0D, 0x04, 0x77, 0x6C, 0x75, 0x0D, 0xFB, 0x0D, 0x77, 0x6C, 0x75, 0xFD, 0x20, 0x04, 0x77, 0x2C, 0x75, 0xFD, 0x82, 0x4C, 0xFE, 0x77, 0x2C, 0x75, 0xFF, 0xA7, 0x72, 0xC7, 0x5F, 0xFA, 0x77, 0x2C, 0x75, 0xFF, 0xA7, 0x72, 0xC7, 0x5F, 0xFA, 0x77, 0x2C, 0x75, 0xFD, 0x82, 0x4C, 0xFE, 0x77, 0x2C, 0x75, 0xFD, 0x20, 0x04, 0x77, 0x2C, 0x75, 0x0D, 0xFB, 0x0D, 0x77, 0x6C, 0x75, 0x04, 0x0D, 0xF9, 0x0D, 0x04, 0x77, 0x6C, 0x80, 0xD0, 0x0C, 0x80, 0xD0, 0x00, 0xDF, 0xFF, 0xF9, 0x0D, 0x04, 0x77, 0x20, 0xAF, 0xFF, 0xFA, 0x0D, 0x77, 0x20, 0x10, 0xEF, 0xFF, 0xF9, 0x0D, 0x77, 0x38, 0x11, 0xAD, 0xFF, 0xFD, 0x0D, 0x04, 0x80, 0xCC, 0x40, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_camera_outdoor() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_camera_outdoor_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_chair_alt 48x48, 4-bit Alpha, RLE, 189 bytes. static const uint8_t ic_round_48_search_chair_alt_data[] PROGMEM = { 0x80, 0xCC, 0x70, 0x81, 0x1A, 0xDF, 0xFE, 0x81, 0xDA, 0x17, 0x77, 0x01, 0x0E, 0xFF, 0xFB, 0x0E, 0x01, 0x77, 0x60, 0xAF, 0xFF, 0xD0, 0xA7, 0x76, 0x0D, 0xFF, 0xFD, 0x0D, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x60, 0xDF, 0xFF, 0xD0, 0xD7, 0x76, 0x0A, 0xFF, 0xFD, 0x0A, 0x77, 0x60, 0x10, 0xEF, 0xFF, 0xB0, 0xE0, 0x17, 0x77, 0x81, 0x1A, 0xDF, 0xFE, 0x81, 0xDA, 0x17, 0x77, 0x6C, 0x71, 0xC7, 0x77, 0x74, 0xC7, 0x1C, 0x77, 0x77, 0x4C, 0x71, 0xC7, 0x77, 0x74, 0xC7, 0x1C, 0x77, 0x76, 0x81, 0x1A, 0xDF, 0xFE, 0x81, 0xDA, 0x17, 0x77, 0x01, 0x0E, 0xFF, 0xFB, 0x0E, 0x01, 0x77, 0x60, 0xAF, 0xFF, 0xD0, 0xA7, 0x76, 0x0D, 0xFF, 0xFD, 0x0D, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x6C, 0x77, 0x60, 0xDA, 0x0D, 0x77, 0x60, 0xDA, 0x0D, 0x77, 0x68, 0x24, 0xDD, 0x47, 0x76, 0x82, 0x4D, 0xD4, 0x80, 0xCC, 0x60, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_chair_alt() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_chair_alt_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_chair 48x48, 4-bit Alpha, RLE, 228 bytes. static const uint8_t ic_round_48_search_chair_data[] PROGMEM = { 0x80, 0xCC, 0x70, 0x81, 0x6B, 0xDF, 0xFE, 0x81, 0xC9, 0x47, 0x76, 0x01, 0x0C, 0xFF, 0xFD, 0x09, 0x77, 0x50, 0xBF, 0xFF, 0xF0, 0xB7, 0x73, 0x06, 0xFF, 0xFF, 0xA0, 0x57, 0x72, 0x0B, 0xFF, 0xFF, 0xA0, 0xA7, 0x72, 0x0E, 0xFF, 0xFF, 0xA0, 0xD7, 0x72, 0xFF, 0xFF, 0xC7, 0x72, 0xFF, 0xFF, 0xC7, 0x72, 0x08, 0x0E, 0xFF, 0xFF, 0x0E, 0x08, 0x77, 0x40, 0x8F, 0xFF, 0xD0, 0x77, 0x77, 0x06, 0xFF, 0xFB, 0x05, 0x77, 0x72, 0x08, 0xFF, 0xF9, 0x06, 0x77, 0x18, 0x41, 0x9C, 0xC8, 0x14, 0x0E, 0xFF, 0xE0, 0xC4, 0x84, 0x19, 0xCC, 0x81, 0x50, 0x10, 0xEC, 0x0D, 0x01, 0x30, 0x7F, 0xFE, 0x05, 0x30, 0x10, 0xEC, 0x0D, 0x01, 0x40, 0xAE, 0x08, 0x30, 0x3F, 0xFE, 0x01, 0x30, 0xAE, 0x08, 0x40, 0xEE, 0x0C, 0x30, 0x1F, 0xFE, 0x40, 0xEE, 0x0C, 0x4F, 0x94, 0xFF, 0xE4, 0xF9, 0x4F, 0x94, 0xFF, 0xE4, 0xF9, 0x4F, 0x94, 0xFF, 0xE4, 0xF9, 0x4F, 0x94, 0xFF, 0xE4, 0xF9, 0x4F, 0x97, 0x77, 0x7F, 0x94, 0xF9, 0x77, 0x77, 0xF9, 0x4F, 0x97, 0x77, 0x7F, 0x94, 0xF9, 0x77, 0x77, 0xF9, 0x48, 0x0D, 0x0F, 0x48, 0x0D, 0x0F, 0x48, 0x0C, 0x7F, 0x0D, 0x40, 0xD8, 0x0C, 0x6F, 0x09, 0x40, 0x78, 0x0C, 0x6F, 0x05, 0x40, 0x10, 0xD8, 0x0C, 0x4F, 0x0A, 0x60, 0x20, 0xC8, 0x0C, 0x2F, 0x0C, 0x01, 0x71, 0x81, 0x7B, 0xEF, 0xFF, 0xFD, 0x0C, 0x07, 0x76, 0xC7, 0x77, 0x3C, 0x77, 0x2C, 0x77, 0x73, 0xC7, 0x72, 0x0D, 0xA0, 0xB7, 0x77, 0x30, 0xDA, 0x0B, 0x77, 0x28, 0x24, 0xDC, 0x37, 0x77, 0x38, 0x24, 0xDC, 0x38, 0x0C, 0xC4, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_chair() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_chair_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_coffee_maker 48x48, 4-bit Alpha, RLE, 228 bytes. static const uint8_t ic_round_48_search_coffee_maker_data[] PROGMEM = { 0x80, 0xB8, 0x50, 0x81, 0x1A, 0xDF, 0xFF, 0xD0, 0xD0, 0x47, 0x72, 0x01, 0x0E, 0xFF, 0xFF, 0x90, 0xD7, 0x72, 0x0A, 0xFF, 0xFF, 0xA0, 0xD7, 0x72, 0x0D, 0xFF, 0xFF, 0x90, 0xD0, 0x47, 0x72, 0xC4, 0xFF, 0xE7, 0x76, 0xC4, 0xFF, 0xE7, 0x76, 0xC4, 0xFF, 0xE7, 0x76, 0xC4, 0xFF, 0xE7, 0x76, 0xC4, 0x0D, 0xFF, 0xC0, 0xD7, 0x76, 0xC4, 0x04, 0x0D, 0xFF, 0xA0, 0xD0, 0x47, 0x76, 0xC8, 0x0D, 0x00, 0xC8, 0x0D, 0x00, 0xC7, 0x58, 0x24, 0xDD, 0x47, 0x77, 0x7C, 0x75, 0x0D, 0xA0, 0xD7, 0x77, 0x7C, 0x75, 0x0D, 0xA0, 0xD7, 0x77, 0x7C, 0x75, 0x82, 0x4D, 0xD4, 0x77, 0x77, 0xC8, 0x0D, 0x00, 0xC8, 0x0D, 0x00, 0xC5, 0x81, 0x1A, 0xDF, 0xD8, 0x1D, 0xA1, 0x77, 0x7C, 0x40, 0x10, 0xEF, 0xFA, 0x0E, 0x01, 0x77, 0x6C, 0x40, 0xAF, 0xFC, 0x0A, 0x77, 0x6C, 0x40, 0xDF, 0xFC, 0x0D, 0x77, 0x6C, 0x4F, 0xFE, 0x77, 0x6C, 0x4F, 0xFE, 0x77, 0x6C, 0x4F, 0xFE, 0x77, 0x6C, 0x4F, 0xFE, 0x77, 0x6C, 0x4F, 0xFE, 0x77, 0x6C, 0x4F, 0xFE, 0x77, 0x6C, 0x40, 0xEF, 0xFC, 0x0E, 0x77, 0x6C, 0x40, 0xCF, 0xFC, 0x0C, 0x77, 0x6C, 0x40, 0x9F, 0xFC, 0x0A, 0x77, 0x6C, 0x40, 0x4F, 0xFC, 0x04, 0x77, 0x6C, 0x50, 0xDF, 0xFA, 0x0D, 0x77, 0x7C, 0x50, 0x3F, 0xFA, 0x03, 0x77, 0x7C, 0x60, 0x7F, 0xF0, 0x77, 0x77, 0x1C, 0x70, 0x7F, 0xD0, 0x77, 0x77, 0x20, 0xDF, 0xFF, 0xF9, 0x0D, 0x04, 0x77, 0x20, 0xAF, 0xFF, 0xFA, 0x0D, 0x77, 0x20, 0x10, 0xEF, 0xFF, 0xF9, 0x0D, 0x77, 0x38, 0x11, 0xAD, 0xFF, 0xFD, 0x0D, 0x04, 0x80, 0xB8, 0x40, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_coffee_maker() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_coffee_maker_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_coffee 48x48, 4-bit Alpha, RLE, 222 bytes. static const uint8_t ic_round_48_search_coffee_data[] PROGMEM = { 0x80, 0xCC, 0x50, 0x81, 0x1A, 0xDF, 0xFF, 0xC8, 0x2E, 0xC7, 0x17, 0x71, 0x01, 0x0E, 0xFF, 0xFF, 0xA0, 0xE0, 0x57, 0x70, 0xAF, 0xFF, 0xFD, 0x05, 0x76, 0x0D, 0xFF, 0xFF, 0xD0, 0xE0, 0x17, 0x5C, 0x77, 0x6C, 0x10, 0x10, 0x7C, 0x07, 0x75, 0xC7, 0x76, 0xC3, 0x07, 0xB0, 0xC7, 0x5C, 0x77, 0x6C, 0x30, 0x1B, 0x0E, 0x75, 0xC7, 0x76, 0xC3, 0x01, 0xB0, 0xE7, 0x5C, 0x77, 0x6C, 0x30, 0x7B, 0x0C, 0x75, 0xC7, 0x76, 0xC1, 0x01, 0x07, 0xC0, 0x77, 0x5F, 0xFF, 0xFE, 0x0E, 0x01, 0x75, 0xFF, 0xFF, 0xE0, 0x57, 0x6F, 0xFF, 0xFC, 0x0E, 0x05, 0x77, 0xFF, 0xFF, 0x98, 0x2E, 0xC7, 0x17, 0x71, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0x0D, 0xFF, 0xFD, 0x0E, 0x77, 0x60, 0xCF, 0xFF, 0xD0, 0xD7, 0x76, 0x0A, 0xFF, 0xFD, 0x0B, 0x77, 0x60, 0x5F, 0xFF, 0xD0, 0x77, 0x76, 0x01, 0xFF, 0xFD, 0x02, 0x77, 0x70, 0xAF, 0xFF, 0xB0, 0xD7, 0x77, 0x10, 0x2F, 0xFF, 0xB0, 0x57, 0x77, 0x20, 0x9F, 0xFF, 0x90, 0xB7, 0x77, 0x40, 0xCF, 0xFE, 0x0E, 0x02, 0x77, 0x74, 0x02, 0x0E, 0xFF, 0xD0, 0x37, 0x77, 0x60, 0x20, 0xDF, 0xFA, 0x0E, 0x04, 0x77, 0x77, 0x10, 0x10, 0xAF, 0xF0, 0xC0, 0x17, 0x77, 0x74, 0x04, 0x0C, 0xFB, 0x0C, 0x05, 0x80, 0xC0, 0x08, 0x90, 0x28, 0xBD, 0xFE, 0xDB, 0x73, 0x80, 0x9F, 0x10, 0x04, 0x0D, 0xFF, 0xFF, 0x0D, 0x04, 0x77, 0x20, 0xDF, 0xFF, 0xFA, 0x0D, 0x77, 0x20, 0xDF, 0xFF, 0xFA, 0x0D, 0x77, 0x20, 0x40, 0xDF, 0xFF, 0xF0, 0xD0, 0x48, 0x0C, 0xC4, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_coffee() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_coffee_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_dining 48x48, 4-bit Alpha, RLE, 278 bytes. static const uint8_t ic_round_48_search_dining_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xFA, 0x87, 0x33, 0xFA, 0x0A, 0xF3, 0x3D, 0x83, 0x92, 0x02, 0x9F, 0xD7, 0x1F, 0xA2, 0x98, 0x17, 0x07, 0x92, 0xC0, 0x65, 0x06, 0xFC, 0x71, 0xFA, 0x29, 0x81, 0x70, 0x79, 0x2B, 0x0A, 0x70, 0xAF, 0xB7, 0x1F, 0xA2, 0x98, 0x17, 0x07, 0x92, 0xB0, 0x27, 0x02, 0xFB, 0x71, 0xFA, 0x29, 0x81, 0x70, 0x79, 0x2A, 0x0C, 0x72, 0x0C, 0xFA, 0x71, 0xFA, 0x29, 0x81, 0x70, 0x79, 0x2A, 0x09, 0x72, 0x09, 0xFA, 0x71, 0xFA, 0x72, 0xA0, 0x87, 0x20, 0x8F, 0xA7, 0x1F, 0xA7, 0x2A, 0x09, 0x72, 0x09, 0xFA, 0x71, 0xFA, 0x72, 0xA0, 0xA7, 0x20, 0xAF, 0xA7, 0x1F, 0xA0, 0x27, 0x02, 0xA0, 0xE7, 0x20, 0xEF, 0xA7, 0x1F, 0xA0, 0x87, 0x08, 0xB0, 0x57, 0x05, 0xFB, 0x71, 0xFB, 0x05, 0x50, 0x5C, 0x0E, 0x01, 0x50, 0x10, 0xDF, 0xB7, 0x1F, 0xC0, 0xB3, 0x0B, 0xE0, 0xC0, 0x23, 0x01, 0x0C, 0xFC, 0x71, 0xFD, 0x3F, 0x90, 0xE3, 0x0E, 0xFD, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x3F, 0xA3, 0xFE, 0x71, 0xFD, 0x81, 0x70, 0x7F, 0xA8, 0x17, 0x07, 0xFE, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x0D, 0x80, 0xC2, 0xF0, 0xD7, 0x10, 0xA8, 0x0C, 0x2F, 0x0A, 0x71, 0x01, 0x0E, 0x80, 0xC0, 0xF0, 0xE0, 0x17, 0x28, 0x11, 0xAD, 0xFF, 0xFF, 0xC8, 0x1D, 0xA1, 0x80, 0xB8, 0x10, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_dining() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_dining_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_door_back 48x48, 4-bit Alpha, RLE, 169 bytes. static const uint8_t ic_round_48_search_door_back_data[] PROGMEM = { 0x80, 0xCC, 0x70, 0x81, 0x1A, 0xDF, 0xFE, 0x81, 0xDA, 0x17, 0x77, 0x01, 0x0E, 0xFF, 0xFB, 0x0E, 0x01, 0x77, 0x60, 0xAF, 0xFF, 0xD0, 0xA7, 0x76, 0x0D, 0xFF, 0xFD, 0x0D, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0x98, 0x2B, 0x11, 0xBF, 0xFA, 0x77, 0x6F, 0x90, 0x12, 0x01, 0xFF, 0xA7, 0x76, 0xF9, 0x01, 0x20, 0x1F, 0xFA, 0x77, 0x6F, 0x98, 0x2B, 0x11, 0xBF, 0xFA, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x20, 0x40, 0xDF, 0xFF, 0xFC, 0x0D, 0x04, 0x75, 0x0D, 0xFF, 0xFF, 0xE0, 0xD7, 0x50, 0xDF, 0xFF, 0xFE, 0x0D, 0x75, 0x04, 0x0D, 0xFF, 0xFF, 0xC0, 0xD0, 0x48, 0x0C, 0xC2, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_door_back() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_door_back_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_doorbell 48x48, 4-bit Alpha, RLE, 225 bytes. static const uint8_t ic_round_48_search_doorbell_data[] PROGMEM = { 0x80, 0xDC, 0x10, 0x84, 0x19, 0xDD, 0x81, 0x80, 0xC5, 0x00, 0x50, 0xEC, 0x0E, 0x04, 0x80, 0xC3, 0x00, 0x9F, 0x90, 0x78, 0x0C, 0x00, 0x02, 0x0C, 0xFB, 0x0B, 0x01, 0x77, 0x77, 0x50, 0x50, 0xEF, 0xD0, 0xE0, 0x47, 0x77, 0x73, 0x09, 0xFF, 0xA0, 0x77, 0x77, 0x70, 0x20, 0xCF, 0xFC, 0x0B, 0x01, 0x77, 0x74, 0x05, 0x0E, 0xFF, 0xE0, 0xE0, 0x47, 0x77, 0x20, 0x9F, 0xFF, 0xB0, 0x77, 0x76, 0x02, 0x0C, 0xFF, 0xFD, 0x0B, 0x01, 0x77, 0x30, 0x10, 0xEF, 0xD8, 0x2D, 0x34, 0xEF, 0xD0, 0xC7, 0x73, 0x0A, 0xFE, 0x08, 0x20, 0x9F, 0xE0, 0x87, 0x72, 0x0E, 0xFC, 0x81, 0xE7, 0x12, 0x81, 0x17, 0xEF, 0xC0, 0xC7, 0x72, 0xFC, 0x0D, 0x01, 0x60, 0x20, 0xEF, 0xC7, 0x72, 0xFC, 0x01, 0x71, 0x02, 0xFC, 0x77, 0x2F, 0xB0, 0x87, 0x30, 0xAF, 0xB7, 0x72, 0xFB, 0x02, 0x73, 0x04, 0xFB, 0x77, 0x2F, 0xB7, 0x40, 0x2F, 0xB7, 0x72, 0xFB, 0x75, 0xFB, 0x77, 0x2F, 0xB7, 0x5F, 0xB7, 0x72, 0xFB, 0x75, 0xFB, 0x77, 0x2F, 0xB7, 0x5F, 0xB7, 0x72, 0xFB, 0x75, 0xFB, 0x77, 0x2F, 0x90, 0x87, 0x70, 0x8F, 0x97, 0x72, 0xF9, 0x06, 0x77, 0x06, 0xF9, 0x77, 0x2F, 0xFF, 0xFC, 0x77, 0x2F, 0xF0, 0x12, 0x03, 0xFF, 0x77, 0x2F, 0xF8, 0x2A, 0x12, 0xBF, 0xF7, 0x72, 0xFF, 0xFF, 0xC7, 0x72, 0xFF, 0xFF, 0xC7, 0x72, 0xFF, 0xFF, 0xC7, 0x72, 0x0E, 0xFF, 0xFF, 0xA0, 0xD7, 0x72, 0x0B, 0xFF, 0xFF, 0xA0, 0x97, 0x72, 0x02, 0xFF, 0xFF, 0x90, 0xE0, 0x17, 0x73, 0x81, 0x2B, 0xEF, 0xFF, 0xB8, 0x1E, 0xA1, 0x80, 0xCC, 0x50, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_doorbell() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_doorbell_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_door_front 48x48, 4-bit Alpha, RLE, 169 bytes. static const uint8_t ic_round_48_search_door_front_data[] PROGMEM = { 0x80, 0xCC, 0x70, 0x81, 0x19, 0xCF, 0xFE, 0x81, 0xC8, 0x17, 0x77, 0x01, 0x0E, 0xFF, 0xFB, 0x0D, 0x01, 0x77, 0x60, 0xAF, 0xFF, 0xD0, 0x87, 0x76, 0x0E, 0xFF, 0xFD, 0x0C, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFA, 0x82, 0xB3, 0x4C, 0xF9, 0x77, 0x6F, 0xFA, 0x02, 0x20, 0x4F, 0x97, 0x76, 0xFF, 0xA0, 0x12, 0x03, 0xF9, 0x77, 0x6F, 0xFA, 0x82, 0xA1, 0x2B, 0xF9, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0xFF, 0xFF, 0x77, 0x20, 0x30, 0xBF, 0xFF, 0xFC, 0x0A, 0x02, 0x75, 0x0C, 0xFF, 0xFF, 0xE0, 0xA7, 0x50, 0xDF, 0xFF, 0xFE, 0x0B, 0x75, 0x04, 0x0D, 0xFF, 0xFF, 0xC0, 0xC0, 0x38, 0x0C, 0xC2, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_door_front() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_door_front_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_door_sliding 48x48, 4-bit Alpha, RLE, 262 bytes. static const uint8_t ic_round_48_search_door_sliding_data[] PROGMEM = { 0x80, 0xCC, 0x50, 0x81, 0x1A, 0xDF, 0xB0, 0x72, 0x07, 0xFB, 0x81, 0xDA, 0x17, 0x73, 0x01, 0x0E, 0xFD, 0x07, 0x20, 0x7F, 0xD0, 0xE0, 0x17, 0x72, 0x0A, 0xFE, 0x07, 0x20, 0x7F, 0xE0, 0xA7, 0x72, 0x0D, 0xFE, 0x07, 0x20, 0x7F, 0xE0, 0xD7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xF9, 0x82, 0xB1, 0x1B, 0xA0, 0x72, 0x07, 0xA8, 0x2B, 0x11, 0xBF, 0x97, 0x72, 0xF9, 0x01, 0x20, 0x1A, 0x07, 0x20, 0x7A, 0x01, 0x20, 0x1F, 0x97, 0x72, 0xF9, 0x01, 0x20, 0x1A, 0x07, 0x20, 0x7A, 0x01, 0x20, 0x1F, 0x97, 0x72, 0xF9, 0x82, 0xB1, 0x1B, 0xA0, 0x72, 0x07, 0xA8, 0x2B, 0x11, 0xBF, 0x97, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x72, 0xFF, 0x07, 0x20, 0x7F, 0xF7, 0x70, 0x40, 0xDF, 0xFF, 0xFC, 0x0D, 0x04, 0x75, 0x0D, 0xFF, 0xFF, 0xE0, 0xD7, 0x50, 0xDF, 0xFF, 0xFE, 0x0D, 0x75, 0x04, 0x0D, 0xFF, 0xFF, 0xC0, 0xD0, 0x48, 0x0C, 0xC2, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_door_sliding() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_door_sliding_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_feed 48x48, 4-bit Alpha, RLE, 221 bytes. static const uint8_t ic_round_48_search_feed_data[] PROGMEM = { 0x80, 0xCC, 0x30, 0x81, 0x1A, 0xDF, 0xFF, 0x90, 0x77, 0x77, 0x01, 0x0E, 0xFF, 0xFC, 0x07, 0x77, 0x60, 0xAF, 0xFF, 0xE0, 0x77, 0x75, 0x0D, 0xFF, 0xFF, 0x07, 0x77, 0x4F, 0xFF, 0xB0, 0x7D, 0x07, 0x77, 0x3F, 0xFF, 0xB1, 0x07, 0xD0, 0x77, 0x72, 0xFF, 0xFB, 0x20, 0x7D, 0x07, 0x77, 0x1F, 0xFF, 0xB3, 0x07, 0xD0, 0x77, 0x7F, 0x90, 0xB0, 0x16, 0x01, 0x0B, 0xE4, 0x07, 0xD0, 0x77, 0x6F, 0x90, 0x17, 0x10, 0x1E, 0x50, 0x7D, 0x07, 0x75, 0xF9, 0x01, 0x71, 0x01, 0xE0, 0x15, 0x07, 0xD7, 0x5F, 0x90, 0xB0, 0x16, 0x01, 0x0B, 0xE0, 0xB0, 0x15, 0x07, 0xC7, 0x58, 0x0C, 0x0F, 0x75, 0x80, 0xC0, 0xF7, 0x58, 0x0C, 0x0F, 0x75, 0x80, 0xC0, 0xF7, 0x5F, 0x90, 0xB0, 0x17, 0x72, 0x01, 0x0B, 0xF9, 0x75, 0xF9, 0x01, 0x77, 0x40, 0x1F, 0x97, 0x5F, 0x90, 0x17, 0x74, 0x01, 0xF9, 0x75, 0xF9, 0x0B, 0x01, 0x77, 0x20, 0x10, 0xBF, 0x97, 0x58, 0x0C, 0x0F, 0x75, 0x80, 0xC0, 0xF7, 0x58, 0x0C, 0x0F, 0x75, 0x80, 0xC0, 0xF7, 0x5F, 0x90, 0xB0, 0x17, 0x72, 0x01, 0x0B, 0xF9, 0x75, 0xF9, 0x01, 0x77, 0x40, 0x1F, 0x97, 0x5F, 0x90, 0x17, 0x74, 0x01, 0xF9, 0x75, 0xF9, 0x0B, 0x01, 0x77, 0x20, 0x10, 0xBF, 0x97, 0x58, 0x0C, 0x0F, 0x75, 0x80, 0xC0, 0xF7, 0x58, 0x0C, 0x0F, 0x75, 0x80, 0xC0, 0xF7, 0x50, 0xDF, 0xFF, 0xFE, 0x0D, 0x75, 0x0A, 0xFF, 0xFF, 0xE0, 0xA7, 0x50, 0x10, 0xEF, 0xFF, 0xFC, 0x0E, 0x01, 0x76, 0x81, 0x1A, 0xDF, 0xFF, 0xF8, 0x1D, 0xA1, 0x80, 0xCC, 0x30, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_feed() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_feed_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_flatware 48x48, 4-bit Alpha, RLE, 290 bytes. static const uint8_t ic_round_48_search_flatware_data[] PROGMEM = { 0x80, 0xCC, 0x20, 0x89, 0x28, 0xE6, 0x01, 0xDD, 0x10, 0x6E, 0x85, 0x84, 0x3A, 0xEE, 0xB3, 0x58, 0x21, 0x89, 0x37, 0x72, 0xA8, 0x1D, 0x06, 0xA8, 0x16, 0x0D, 0xA4, 0x06, 0xE0, 0x64, 0x0B, 0xB0, 0xA0, 0x17, 0x7A, 0x81, 0xD0, 0x6A, 0x81, 0x60, 0xDA, 0x30, 0x4F, 0x90, 0x43, 0xD0, 0xC7, 0x7A, 0x81, 0xD0, 0x6A, 0x81, 0x60, 0xDA, 0x30, 0xDF, 0x90, 0xD3, 0xE0, 0x97, 0x6A, 0x81, 0xD0, 0x6A, 0x81, 0x60, 0xDA, 0x20, 0x5F, 0xB0, 0x52, 0xF0, 0x37, 0x5A, 0x81, 0xD0, 0x6A, 0x81, 0x60, 0xDA, 0x20, 0x9F, 0xB0, 0xA2, 0xF0, 0x97, 0x5A, 0x81, 0xD0, 0x6A, 0x81, 0x60, 0xDA, 0x20, 0xDF, 0xB0, 0xD2, 0xF0, 0xC7, 0x5A, 0x81, 0xD0, 0x6A, 0x81, 0x60, 0xDA, 0x20, 0xEF, 0xB0, 0xE2, 0xF0, 0xE7, 0x5F, 0xD2, 0x0E, 0xFB, 0x0E, 0x2F, 0x97, 0x5F, 0xD2, 0x0D, 0xFB, 0x0D, 0x2F, 0x97, 0x5F, 0xD2, 0x0B, 0xFB, 0x0B, 0x2F, 0x97, 0x5F, 0xD2, 0x06, 0xFB, 0x06, 0x2F, 0x97, 0x50, 0xDF, 0xB0, 0xD3, 0x0E, 0xF9, 0x0E, 0x3F, 0x97, 0x50, 0xAF, 0xB0, 0xA3, 0x06, 0xF9, 0x06, 0x3F, 0x97, 0x50, 0x10, 0xEF, 0x90, 0xE0, 0x14, 0x0A, 0xE0, 0xA4, 0xF9, 0x76, 0x81, 0x1A, 0xDC, 0x81, 0xDA, 0x16, 0x06, 0xC0, 0x65, 0xF9, 0x77, 0x2C, 0x73, 0xC6, 0xF9, 0x77, 0x2C, 0x73, 0xC6, 0xF9, 0x77, 0x2C, 0x73, 0xC6, 0xF0, 0xD7, 0x72, 0xC7, 0x3C, 0x6E, 0x0D, 0x04, 0x77, 0x2C, 0x73, 0xC6, 0xC7, 0x76, 0xC7, 0x3C, 0x6C, 0x77, 0x6C, 0x73, 0xC6, 0xC7, 0x76, 0xC7, 0x3C, 0x6C, 0x77, 0x6C, 0x73, 0xC6, 0xC7, 0x76, 0xC7, 0x3C, 0x6C, 0x77, 0x6C, 0x73, 0xC6, 0xC7, 0x76, 0xC7, 0x3C, 0x6C, 0x77, 0x6C, 0x73, 0xC6, 0xC7, 0x76, 0xC7, 0x3C, 0x6C, 0x77, 0x6C, 0x73, 0xC6, 0xC7, 0x76, 0xC7, 0x3C, 0x6C, 0x77, 0x6C, 0x73, 0xC6, 0xC7, 0x76, 0xC7, 0x3C, 0x6C, 0x77, 0x60, 0xDA, 0x0D, 0x73, 0x0D, 0xA0, 0xD6, 0x0D, 0xA0, 0xD7, 0x76, 0x82, 0x4D, 0xD4, 0x73, 0x82, 0x4D, 0xD4, 0x68, 0x24, 0xDD, 0x48, 0x0C, 0xC6, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_flatware() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_flatware_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_garage 48x48, 4-bit Alpha, RLE, 249 bytes. static const uint8_t ic_round_48_search_garage_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x1F, 0xA0, 0xE0, 0x57, 0x74, 0x04, 0x0E, 0xFA, 0x71, 0xFA, 0x05, 0x77, 0x60, 0x5F, 0xA7, 0x1F, 0x90, 0xE7, 0x77, 0x10, 0xEF, 0x97, 0x1F, 0x90, 0x97, 0x77, 0x10, 0x9F, 0x97, 0x1F, 0x90, 0x43, 0x07, 0xFF, 0x07, 0x30, 0x4F, 0x97, 0x1F, 0x0E, 0x40, 0xCF, 0xF0, 0xC4, 0x0E, 0xF7, 0x1F, 0x09, 0x30, 0x2F, 0xFA, 0x02, 0x30, 0x9F, 0x71, 0xF0, 0x43, 0x07, 0xFF, 0xA0, 0x73, 0x04, 0xF7, 0x1E, 0x0E, 0x77, 0x75, 0x0E, 0xE7, 0x1E, 0x09, 0x77, 0x75, 0x09, 0xE7, 0x1E, 0x04, 0x77, 0x75, 0x04, 0xE7, 0x1E, 0x77, 0x77, 0xE7, 0x1E, 0x77, 0x77, 0xE7, 0x1E, 0x68, 0x24, 0xDD, 0x47, 0x18, 0x24, 0xDD, 0x46, 0xE7, 0x1E, 0x60, 0xDA, 0x0D, 0x71, 0x0D, 0xA0, 0xD6, 0xE7, 0x1E, 0x60, 0xDA, 0x0D, 0x71, 0x0D, 0xA0, 0xD6, 0xE7, 0x1E, 0x68, 0x24, 0xDD, 0x47, 0x18, 0x24, 0xDD, 0x46, 0xE7, 0x1E, 0x77, 0x77, 0xE7, 0x1E, 0x77, 0x77, 0xE7, 0x1E, 0x77, 0x77, 0xE7, 0x1E, 0x77, 0x77, 0xE7, 0x1E, 0x77, 0x77, 0xE7, 0x1E, 0x4F, 0xFE, 0x4E, 0x71, 0xE4, 0xFF, 0xE4, 0xE7, 0x1E, 0x4F, 0xFE, 0x4E, 0x71, 0xE0, 0x82, 0x08, 0xFF, 0xE0, 0x72, 0x08, 0xE7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x0D, 0x80, 0xC2, 0xF0, 0xD7, 0x10, 0xA8, 0x0C, 0x2F, 0x0A, 0x71, 0x01, 0x0E, 0x80, 0xC0, 0xF0, 0xE0, 0x17, 0x28, 0x11, 0xAD, 0xFF, 0xFF, 0xC8, 0x1D, 0xA1, 0x80, 0xB8, 0x10, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_garage() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_garage_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_light 48x48, 4-bit Alpha, RLE, 252 bytes. static const uint8_t ic_round_48_search_light_data[] PROGMEM = { 0x80, 0xCE, 0x20, 0x82, 0x4D, 0xD4, 0x80, 0xD0, 0x00, 0xDA, 0x0D, 0x80, 0xD0, 0x0C, 0x80, 0xD0, 0x0C, 0x80, 0xD0, 0x0C, 0x80, 0xD0, 0x0C, 0x80, 0xC4, 0x08, 0x21, 0x58, 0xCC, 0x82, 0xC8, 0x51, 0x77, 0x77, 0x60, 0x40, 0xAF, 0xD0, 0xA0, 0x47, 0x77, 0x72, 0x03, 0x0C, 0xFF, 0xA0, 0xC0, 0x37, 0x77, 0x60, 0x8F, 0xFE, 0x08, 0x77, 0x74, 0x0B, 0xE8, 0x2C, 0x74, 0x22, 0x82, 0x24, 0x7C, 0xE0, 0xB7, 0x77, 0x10, 0x10, 0xCD, 0x0A, 0x02, 0x73, 0x02, 0x0A, 0xD0, 0xC0, 0x17, 0x76, 0x0B, 0xC0, 0xD0, 0x37, 0x70, 0x30, 0xDC, 0x0B, 0x77, 0x50, 0x8C, 0x0B, 0x01, 0x77, 0x20, 0x10, 0xBC, 0x08, 0x77, 0x30, 0x4C, 0x0B, 0x77, 0x60, 0xBC, 0x04, 0x77, 0x20, 0xCB, 0x0D, 0x01, 0x77, 0x60, 0x10, 0xDB, 0x0C, 0x77, 0x10, 0x4C, 0x03, 0x77, 0x71, 0x03, 0xC0, 0x47, 0x70, 0xBB, 0x0A, 0x77, 0x73, 0x0A, 0xB0, 0xB7, 0x60, 0x1C, 0x02, 0x77, 0x73, 0x02, 0xC0, 0x17, 0x50, 0x5B, 0x0C, 0x77, 0x75, 0x0C, 0xB0, 0x57, 0x50, 0x9B, 0x07, 0x77, 0x75, 0x07, 0xB0, 0x97, 0x50, 0xBB, 0x03, 0x77, 0x75, 0x03, 0xB0, 0xB7, 0x50, 0xDB, 0x02, 0x77, 0x75, 0x02, 0xB0, 0xD7, 0x50, 0xEB, 0x77, 0x77, 0xB0, 0xE7, 0x50, 0xDF, 0xFF, 0xFE, 0x0D, 0x75, 0x09, 0xFF, 0xFF, 0xE0, 0x97, 0x50, 0x10, 0xEF, 0xFF, 0xFC, 0x0E, 0x01, 0x76, 0x81, 0x19, 0xDF, 0xFF, 0xF8, 0x1D, 0x91, 0x77, 0x72, 0x0E, 0xFF, 0x0E, 0x77, 0x77, 0x40, 0xCF, 0xF0, 0xC7, 0x77, 0x74, 0x08, 0xFF, 0x08, 0x77, 0x77, 0x40, 0x2F, 0xF0, 0x27, 0x77, 0x75, 0x09, 0xFD, 0x09, 0x77, 0x77, 0x70, 0xBF, 0xB0, 0xB8, 0x0C, 0x10, 0x09, 0xF9, 0x09, 0x80, 0xC3, 0x08, 0x62, 0x8C, 0xEE, 0xC8, 0x28, 0x0C, 0xE0, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_light() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_light_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_living 48x48, 4-bit Alpha, RLE, 285 bytes. static const uint8_t ic_round_48_search_living_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xFC, 0x81, 0xC5, 0x17, 0x58, 0x11, 0x5C, 0xFC, 0x71, 0xFB, 0x08, 0x77, 0x40, 0x8F, 0xB7, 0x1F, 0xA0, 0xA7, 0x76, 0x0A, 0xFA, 0x71, 0xFA, 0x01, 0x20, 0x30, 0xBF, 0xD0, 0xB0, 0x32, 0x01, 0xFA, 0x71, 0xF9, 0x0B, 0x20, 0x10, 0xEF, 0xF0, 0xE0, 0x12, 0x0B, 0xF9, 0x71, 0xF9, 0x08, 0x20, 0x6F, 0xFA, 0x06, 0x20, 0x8F, 0x97, 0x1F, 0x90, 0x72, 0x07, 0xFF, 0xA0, 0x72, 0x07, 0xF9, 0x71, 0xF9, 0x07, 0x20, 0x7F, 0xFA, 0x07, 0x20, 0x7F, 0x97, 0x1F, 0x90, 0x62, 0x81, 0x15, 0xBF, 0xD8, 0x1B, 0x51, 0x20, 0x6F, 0x97, 0x1F, 0x08, 0x60, 0x8F, 0xB0, 0x86, 0x08, 0xF7, 0x1E, 0x0B, 0x71, 0x0B, 0xF9, 0x0B, 0x71, 0x0B, 0xE7, 0x1E, 0x04, 0x28, 0x24, 0xDD, 0x42, 0x04, 0xF9, 0x04, 0x28, 0x24, 0xDD, 0x42, 0x04, 0xE7, 0x1E, 0x01, 0x20, 0xDA, 0x0D, 0x20, 0x1F, 0x90, 0x12, 0x0D, 0xA0, 0xD2, 0x01, 0xE7, 0x1E, 0x3C, 0x3F, 0x93, 0xC3, 0xE7, 0x1E, 0x3C, 0x77, 0xC3, 0xE7, 0x1E, 0x3C, 0x77, 0xC3, 0xE7, 0x1E, 0x3C, 0x77, 0xC3, 0xE7, 0x1E, 0x3F, 0xFF, 0x93, 0xE7, 0x1E, 0x3F, 0xFF, 0x93, 0xE7, 0x1E, 0x3F, 0xFF, 0x93, 0xE7, 0x1E, 0x01, 0x20, 0xBF, 0xFE, 0x0B, 0x20, 0x1E, 0x71, 0xE0, 0x57, 0x77, 0x50, 0x5E, 0x71, 0xE0, 0xD0, 0x17, 0x77, 0x30, 0x10, 0xDE, 0x71, 0xF8, 0x1D, 0x51, 0x77, 0x68, 0x11, 0x5D, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x72, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x18, 0x0B, 0x81, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_living() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_living_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_manage_search 48x48, 4-bit Alpha, RLE, 234 bytes. static const uint8_t ic_round_48_search_manage_search_data[] PROGMEM = { 0x80, 0x99, 0xA4, 0x08, 0x65, 0x9C, 0xFD, 0xDA, 0x58, 0x0C, 0x20, 0x04, 0x0D, 0xF9, 0x0D, 0x05, 0x77, 0x40, 0x40, 0xDE, 0x0D, 0x04, 0x70, 0x8F, 0xD0, 0x97, 0x73, 0x0D, 0xF9, 0x0D, 0x60, 0x8F, 0xF0, 0x97, 0x72, 0x0D, 0xF9, 0x0D, 0x50, 0x4D, 0x08, 0x03, 0x20, 0x30, 0x8D, 0x05, 0x77, 0x10, 0x40, 0xDE, 0x0D, 0x04, 0x50, 0xDB, 0x0D, 0x03, 0x60, 0x30, 0xDB, 0x0D, 0x77, 0x77, 0x10, 0x5C, 0x03, 0x71, 0x03, 0xC0, 0x57, 0x77, 0x70, 0x9B, 0x08, 0x73, 0x08, 0xB0, 0xA7, 0x77, 0x70, 0xDB, 0x03, 0x73, 0x03, 0xB0, 0xC7, 0x77, 0x70, 0xEB, 0x75, 0xB0, 0xE7, 0x77, 0x70, 0xEB, 0x75, 0xB0, 0xE7, 0x77, 0x70, 0xDB, 0x03, 0x73, 0x03, 0xB0, 0xD7, 0x70, 0x40, 0xDE, 0x0D, 0x04, 0x40, 0xAB, 0x08, 0x73, 0x08, 0xB0, 0x97, 0x70, 0xDF, 0x90, 0xD4, 0x05, 0xC0, 0x37, 0x10, 0x3C, 0x05, 0x77, 0x0D, 0xF9, 0x0D, 0x50, 0xDB, 0x0D, 0x03, 0x60, 0x30, 0xDB, 0x0D, 0x77, 0x10, 0x40, 0xDE, 0x0D, 0x04, 0x50, 0x4D, 0x08, 0x03, 0x20, 0x30, 0x8D, 0x08, 0x77, 0x77, 0x30, 0x8F, 0xFA, 0x05, 0x77, 0x77, 0x30, 0x8F, 0xFA, 0x05, 0x77, 0x77, 0x30, 0x40, 0xDF, 0x90, 0xD0, 0x8D, 0x05, 0x77, 0x77, 0x48, 0x14, 0x9C, 0xA8, 0x1D, 0xA5, 0x20, 0x5D, 0x05, 0x80, 0xC6, 0x00, 0x5D, 0x05, 0x80, 0xC6, 0x00, 0x5D, 0x05, 0x72, 0x04, 0x0D, 0xFF, 0xA0, 0xD0, 0x47, 0x60, 0x5C, 0x0E, 0x72, 0x0D, 0xFF, 0xC0, 0xD7, 0x70, 0x5C, 0x01, 0x71, 0x0D, 0xFF, 0xC0, 0xD7, 0x71, 0x82, 0x5E, 0xF9, 0x72, 0x04, 0x0D, 0xFF, 0xA0, 0xD0, 0x47, 0x73, 0x01, 0x80, 0xFC, 0x20, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_manage_search() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_manage_search_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_podcasts 48x48, 4-bit Alpha, RLE, 441 bytes. static const uint8_t ic_round_48_search_podcasts_data[] PROGMEM = { 0x80, 0xB9, 0x60, 0x83, 0x36, 0x9C, 0xDA, 0x83, 0xDC, 0xA7, 0x37, 0x77, 0x75, 0x81, 0x17, 0xDF, 0xD8, 0x1D, 0x71, 0x77, 0x77, 0x10, 0x8F, 0xFC, 0x08, 0x01, 0x77, 0x74, 0x04, 0x0D, 0xFF, 0xE0, 0xE0, 0x57, 0x77, 0x20, 0x7E, 0x83, 0xEA, 0x63, 0x12, 0x83, 0x13, 0x6A, 0xEE, 0x08, 0x77, 0x70, 0xAD, 0x0D, 0x06, 0x75, 0x06, 0x0D, 0xD0, 0xB7, 0x75, 0x0A, 0xD0, 0x77, 0x72, 0x07, 0xD0, 0xB7, 0x73, 0x07, 0xC0, 0xD0, 0x27, 0x74, 0x03, 0x0D, 0xC0, 0x87, 0x71, 0x04, 0xC0, 0xC0, 0x15, 0x89, 0x01, 0x7B, 0xCE, 0xEC, 0xA6, 0x15, 0x01, 0x0C, 0xC0, 0x57, 0x70, 0xDB, 0x0D, 0x01, 0x40, 0x10, 0xAF, 0xB0, 0x90, 0x14, 0x01, 0x0D, 0xB0, 0xE0, 0x17, 0x50, 0x8C, 0x02, 0x40, 0x50, 0xEF, 0xD0, 0xE0, 0x54, 0x02, 0xC0, 0x87, 0x40, 0x1C, 0x07, 0x40, 0x7F, 0xFA, 0x05, 0x40, 0x7C, 0x01, 0x73, 0x07, 0xB0, 0xD4, 0x05, 0xD8, 0x6D, 0x73, 0x11, 0x37, 0xCD, 0x05, 0x40, 0xDB, 0x07, 0x73, 0x0D, 0xB0, 0x63, 0x01, 0x0E, 0xC0, 0x77, 0x10, 0x6C, 0x0E, 0x01, 0x30, 0x6B, 0x0D, 0x72, 0x03, 0xB0, 0xE4, 0x0A, 0xC0, 0x37, 0x30, 0x4C, 0x09, 0x40, 0xEB, 0x03, 0x71, 0x06, 0xB0, 0xA3, 0x02, 0xC0, 0x67, 0x50, 0x6C, 0x01, 0x30, 0xAB, 0x07, 0x71, 0x09, 0xB0, 0x63, 0x07, 0xB0, 0xD4, 0x84, 0x1A, 0xDD, 0xA1, 0x40, 0xCB, 0x06, 0x30, 0x6B, 0x0A, 0x71, 0x0C, 0xB0, 0x33, 0x0B, 0xB0, 0x63, 0x01, 0x0E, 0xC0, 0xE0, 0x13, 0x06, 0xB0, 0xA3, 0x03, 0xB0, 0xC7, 0x10, 0xEB, 0x01, 0x30, 0xDB, 0x02, 0x30, 0xAE, 0x0A, 0x30, 0x2B, 0x0C, 0x30, 0x1B, 0x0E, 0x71, 0xC4, 0x0E, 0xB4, 0x0D, 0xE0, 0xD4, 0xB0, 0xE4, 0xC7, 0x1C, 0x40, 0xEB, 0x40, 0xEE, 0x0E, 0x4B, 0x0E, 0x4B, 0x0E, 0x71, 0x0E, 0xB0, 0x13, 0x0D, 0xB0, 0x23, 0x0A, 0xE0, 0xA3, 0x02, 0xB0, 0xD3, 0x02, 0xB0, 0xD7, 0x10, 0xCB, 0x03, 0x30, 0xBB, 0x06, 0x30, 0x20, 0xEC, 0x0E, 0x02, 0x30, 0x6B, 0x0A, 0x30, 0x3B, 0x0B, 0x71, 0x0A, 0xB0, 0x63, 0x06, 0xB0, 0xC4, 0x01, 0xC0, 0x14, 0x0C, 0xB0, 0x63, 0x06, 0xB0, 0xA7, 0x10, 0x7B, 0x0A, 0x30, 0x1C, 0x06, 0x4C, 0x40, 0x6C, 0x01, 0x30, 0xBB, 0x06, 0x71, 0x03, 0xB0, 0xE4, 0x09, 0xB0, 0xD4, 0xC4, 0x0D, 0xB0, 0x94, 0x0E, 0xB0, 0x27, 0x20, 0xDB, 0x06, 0x30, 0x10, 0xEA, 0x0C, 0x4C, 0x40, 0xCA, 0x0E, 0x01, 0x30, 0x7B, 0x0D, 0x73, 0x08, 0xB0, 0xD4, 0x82, 0x4D, 0xC3, 0x4C, 0x48, 0x22, 0xBC, 0x34, 0x0D, 0xB0, 0x77, 0x30, 0x1C, 0x07, 0x74, 0xC7, 0x40, 0x7B, 0x0E, 0x01, 0x74, 0x09, 0xC0, 0x37, 0x3C, 0x73, 0x03, 0xC0, 0x87, 0x50, 0x10, 0xEB, 0x0D, 0x73, 0xC7, 0x30, 0xDB, 0x0D, 0x01, 0x76, 0x05, 0xC0, 0x37, 0x2C, 0x72, 0x03, 0xC0, 0x47, 0x71, 0x08, 0xA0, 0xE0, 0x17, 0x2C, 0x72, 0x01, 0x0E, 0xA0, 0x87, 0x73, 0x81, 0x69, 0x27, 0x3C, 0x73, 0x81, 0x28, 0x67, 0x77, 0x73, 0xC8, 0x0D, 0x00, 0xC8, 0x0D, 0x00, 0xC8, 0x0D, 0x00, 0xC8, 0x0D, 0x00, 0x0D, 0xA0, 0xD8, 0x0D, 0x00, 0x82, 0x4D, 0xD4, 0x80, 0xBA, 0x20, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_podcasts() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_podcasts_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_shower 48x48, 4-bit Alpha, RLE, 224 bytes. static const uint8_t ic_round_48_search_shower_data[] PROGMEM = { 0x80, 0xCE, 0x20, 0x82, 0x4D, 0xD4, 0x80, 0xD0, 0x00, 0xDA, 0x0D, 0x80, 0xD0, 0x0C, 0x80, 0xD0, 0x0C, 0x80, 0xC5, 0x08, 0x13, 0x7B, 0xC8, 0x1B, 0x73, 0x80, 0xC0, 0x00, 0x50, 0xCF, 0xB0, 0xC0, 0x57, 0x77, 0x74, 0x01, 0x0B, 0xFF, 0x0B, 0x01, 0x77, 0x77, 0x10, 0x30, 0xEF, 0xFA, 0x0E, 0x03, 0x77, 0x76, 0x04, 0x0E, 0xFF, 0xC0, 0xE0, 0x47, 0x77, 0x40, 0x10, 0xEF, 0xFE, 0x0E, 0x01, 0x77, 0x73, 0x0B, 0xFF, 0xF9, 0x0B, 0x77, 0x72, 0x05, 0xFF, 0xFB, 0x05, 0x77, 0x71, 0x0C, 0xFF, 0xFB, 0x0C, 0x77, 0x70, 0x3F, 0xFF, 0xD0, 0x37, 0x76, 0x07, 0xFF, 0xFD, 0x07, 0x77, 0x60, 0xBF, 0xFF, 0xD0, 0xB7, 0x76, 0x0D, 0xFF, 0xFD, 0x0D, 0x77, 0x60, 0xEF, 0xFF, 0xD0, 0xE7, 0x76, 0xFF, 0xFF, 0x77, 0x6F, 0xFF, 0xF7, 0x76, 0x0D, 0xFF, 0xFD, 0x0D, 0x77, 0x60, 0x40, 0xDF, 0xFF, 0xB0, 0xD0, 0x48, 0x0B, 0xA4, 0x08, 0x24, 0xDD, 0x44, 0x82, 0x4D, 0xD4, 0x48, 0x24, 0xDD, 0x47, 0x77, 0x70, 0xDA, 0x0D, 0x40, 0xDA, 0x0D, 0x40, 0xDA, 0x0D, 0x77, 0x77, 0x0D, 0xA0, 0xD4, 0x0D, 0xA0, 0xD4, 0x0D, 0xA0, 0xD7, 0x77, 0x78, 0x24, 0xDD, 0x44, 0x82, 0x4D, 0xD4, 0x48, 0x24, 0xDD, 0x48, 0x09, 0xF0, 0x08, 0x24, 0xDD, 0x44, 0x82, 0x4D, 0xD4, 0x48, 0x24, 0xDD, 0x47, 0x77, 0x70, 0xDA, 0x0D, 0x40, 0xDA, 0x0D, 0x40, 0xDA, 0x0D, 0x77, 0x77, 0x0D, 0xA0, 0xD4, 0x0D, 0xA0, 0xD4, 0x0D, 0xA0, 0xD7, 0x77, 0x78, 0x24, 0xDD, 0x44, 0x82, 0x4D, 0xD4, 0x48, 0x24, 0xDD, 0x48, 0x0C, 0xD2, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_shower() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_shower_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_window 48x48, 4-bit Alpha, RLE, 199 bytes. static const uint8_t ic_round_48_search_window_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0xC7, 0x7C, 0x77, 0xC7, 0x1C, 0x77, 0xC7, 0x7C, 0x71, 0x0D, 0x80, 0xC2, 0xF0, 0xD7, 0x10, 0xA8, 0x0C, 0x2F, 0x0A, 0x71, 0x01, 0x0E, 0x80, 0xC0, 0xF0, 0xE0, 0x17, 0x28, 0x11, 0xAD, 0xFF, 0xFF, 0xC8, 0x1D, 0xA1, 0x80, 0xB8, 0x10, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_window() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_window_data, Alpha4(color::Black)); return value; } // Image file ic_round_48_search_yard 48x48, 4-bit Alpha, RLE, 318 bytes. static const uint8_t ic_round_48_search_yard_data[] PROGMEM = { 0x80, 0xB8, 0x10, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x17, 0x20, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x80, 0xC4, 0xF7, 0x18, 0x0C, 0x4F, 0x71, 0xFF, 0xC8, 0x2E, 0x99, 0xEF, 0xFC, 0x71, 0xFF, 0xB0, 0xB0, 0x12, 0x01, 0x0B, 0xFF, 0xB7, 0x1F, 0xFB, 0x02, 0x40, 0x2F, 0xFB, 0x71, 0xFE, 0x82, 0xC6, 0x69, 0x68, 0x29, 0x66, 0xCF, 0xE7, 0x1F, 0xD0, 0xB7, 0x70, 0xBF, 0xD7, 0x1F, 0xD0, 0x37, 0x70, 0x3F, 0xD7, 0x1F, 0xD6, 0x82, 0x6C, 0xC6, 0x6F, 0xD7, 0x1F, 0xD0, 0x34, 0x08, 0xC0, 0x84, 0x03, 0xFD, 0x71, 0xFD, 0x0C, 0x40, 0xEC, 0x0E, 0x40, 0xCF, 0xD7, 0x1F, 0xE0, 0x53, 0xE3, 0x05, 0xFE, 0x71, 0xFD, 0x07, 0x40, 0xCC, 0x0C, 0x40, 0x7F, 0xD7, 0x1F, 0xD0, 0x14, 0x02, 0x0D, 0xA0, 0xD0, 0x24, 0x01, 0xFD, 0x71, 0xFD, 0x01, 0x60, 0x04, 0x60, 0x1F, 0xD7, 0x1F, 0xD0, 0x67, 0x70, 0x6F, 0xD7, 0x1F, 0xD0, 0xE0, 0x52, 0x02, 0x60, 0x22, 0x05, 0x0E, 0xFD, 0x71, 0xFF, 0x0E, 0x0D, 0x96, 0x90, 0xD0, 0xEF, 0xF7, 0x1F, 0xA8, 0x27, 0x58, 0xDC, 0x06, 0x40, 0x6C, 0x82, 0xD8, 0x57, 0xFA, 0x71, 0xF9, 0x07, 0x40, 0x50, 0xDB, 0x82, 0x71, 0x17, 0xB0, 0xD0, 0x54, 0x07, 0xF9, 0x71, 0xF9, 0x05, 0x60, 0xAF, 0x90, 0xA6, 0x05, 0xF9, 0x71, 0xF9, 0x08, 0x70, 0x9E, 0x09, 0x70, 0x8F, 0x97, 0x1F, 0x90, 0xD7, 0x10, 0xAC, 0x0A, 0x71, 0x0D, 0xF9, 0x71, 0xFA, 0x05, 0x70, 0x10, 0xDA, 0x0D, 0x01, 0x70, 0x5F, 0xA7, 0x1F, 0xA0, 0xD7, 0x10, 0x5A, 0x05, 0x71, 0x0D, 0xFA, 0x71, 0xFB, 0x0A, 0x71, 0x00, 0xD7, 0x10, 0xAF, 0xB7, 0x1F, 0xC0, 0x97, 0x00, 0x87, 0x09, 0xFC, 0x71, 0xFD, 0x0A, 0x01, 0x50, 0x04, 0x50, 0x10, 0xAF, 0xD7, 0x1F, 0xE0, 0xD0, 0x54, 0x00, 0x24, 0x05, 0x0D, 0xFE, 0x71, 0xFF, 0x98, 0x90, 0xD8, 0x41, 0x11, 0x14, 0x8D, 0xFF, 0x97, 0x18, 0x0C, 0x4F, 0x71, 0x80, 0xC4, 0xF7, 0x10, 0xD8, 0x0C, 0x2F, 0x0D, 0x71, 0x0A, 0x80, 0xC2, 0xF0, 0xA7, 0x10, 0x10, 0xE8, 0x0C, 0x0F, 0x0E, 0x01, 0x72, 0x81, 0x1A, 0xDF, 0xFF, 0xFC, 0x81, 0xDA, 0x18, 0x0B, 0x81, 0x00, }; const RleImage4bppxBiased<Alpha4, PrgMemResource>& ic_round_48_search_yard() { static RleImage4bppxBiased<Alpha4, PrgMemResource> value( 48, 48, ic_round_48_search_yard_data, Alpha4(color::Black)); return value; }
75.601182
97
0.680493
dejwk
7c6b59f4376fd496e1f524b887f429a489899c19
2,585
hpp
C++
src/ObjectExplorer.hpp
muhopensores/RE2-Mod-Framework
0def991b598a83a488c0be1bcf78df81e265b8b6
[ "MIT" ]
1
2020-07-17T23:16:56.000Z
2020-07-17T23:16:56.000Z
src/ObjectExplorer.hpp
muhopensores/RE2-Mod-Framework
0def991b598a83a488c0be1bcf78df81e265b8b6
[ "MIT" ]
null
null
null
src/ObjectExplorer.hpp
muhopensores/RE2-Mod-Framework
0def991b598a83a488c0be1bcf78df81e265b8b6
[ "MIT" ]
null
null
null
#pragma once #include <unordered_set> #include <imgui/imgui.h> #include "utility/Address.hpp" #include "Mod.hpp" class ObjectExplorer : public Mod { public: ObjectExplorer(); std::string_view getName() const override { return "ObjectExplorer"; }; void onDrawUI() override; private: void handleAddress(Address address, int32_t offset = -1, Address parent = nullptr); void handleGameObject(REGameObject* gameObject); void handleComponent(REComponent* component); void handleTransform(RETransform* transform); void handleType(REManagedObject* obj, REType* t); void displayEnumValue(std::string_view name, int64_t value); void displayMethods(REManagedObject* obj, REType* typeInfo); void displayFields(REManagedObject* obj, REType* typeInfo); void attemptDisplayField(REManagedObject* obj, VariableDescriptor* desc); int32_t getFieldOffset(REManagedObject* obj, VariableDescriptor* desc); bool widgetWithContext(void* address, std::function<bool()> widget); void contextMenu(void* address); void makeSameLineText(std::string_view text, const ImVec4& color); void makeTreeOffset(REManagedObject* object, uint32_t offset, std::string_view name); bool isManagedObject(Address address) const; void populateClasses(); void populateEnums(); std::string getEnumValueName(std::string_view enumName, int64_t value); REType* getType(std::string_view typeName); template <typename T, typename... Args> bool stretchedTreeNode(T id, Args... args) { auto& style = ImGui::GetStyle(); auto styleBak = ImGui::GetStyle(); style.ItemSpacing.x *= 100; bool madeNode = ImGui::TreeNode(id, args...); style.ItemSpacing.x = styleBak.ItemSpacing.x; return madeNode; } inline static const ImVec4 VARIABLE_COLOR{ 100.0f / 255.0f, 149.0f / 255.0f, 237.0f / 255.0f, 255 / 255.0f }; inline static const ImVec4 VARIABLE_COLOR_HIGHLIGHT{ 1.0f, 1.0f, 1.0f, 1.0f }; std::string m_typeName{ "via.typeinfo.TypeInfo" }; std::string m_objectAddress{ "0" }; std::chrono::system_clock::time_point m_nextRefresh; std::unordered_map<VariableDescriptor*, int32_t> m_offsetMap; struct EnumDescriptor { std::string name; int64_t value; }; std::unordered_multimap<std::string, EnumDescriptor> m_enums; std::unordered_map<std::string, REType*> m_types; std::vector<std::string> m_sortedTypes; // Types currently being displayed std::vector<REType*> m_displayedTypes; bool m_doInit{ true }; };
32.3125
113
0.706383
muhopensores
7c6f334af91369d7b421b1fef1ea6797a34c49b1
2,901
cpp
C++
dbms/src/Common/formatReadable.cpp
solotzg/tiflash
66f45c76692e941bc845c01349ea89de0f2cc210
[ "Apache-2.0" ]
85
2022-03-25T09:03:16.000Z
2022-03-25T09:45:03.000Z
dbms/src/Common/formatReadable.cpp
solotzg/tiflash
66f45c76692e941bc845c01349ea89de0f2cc210
[ "Apache-2.0" ]
7
2022-03-25T08:59:10.000Z
2022-03-25T09:40:13.000Z
dbms/src/Common/formatReadable.cpp
solotzg/tiflash
66f45c76692e941bc845c01349ea89de0f2cc210
[ "Apache-2.0" ]
11
2022-03-25T09:15:36.000Z
2022-03-25T09:45:07.000Z
// Copyright 2022 PingCAP, Ltd. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <Common/formatReadable.h> #include <IO/DoubleConverter.h> #include <IO/WriteBufferFromString.h> #include <IO/WriteHelpers.h> #include <cmath> #include <iomanip> #include <sstream> static void formatReadable(double size, DB::WriteBuffer & out, int precision, const char ** units, size_t units_size, double delimiter) { size_t i = 0; for (; i + 1 < units_size && fabs(size) >= delimiter; ++i) size /= delimiter; DB::DoubleConverter<false>::BufferType buffer; double_conversion::StringBuilder builder{buffer, sizeof(buffer)}; const auto result = DB::DoubleConverter<false>::instance().ToFixed(size, precision, &builder); if (!result) throw DB::Exception("Cannot print float or double number", DB::ErrorCodes::CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER); out.write(buffer, builder.position()); writeCString(units[i], out); } void formatReadableSizeWithBinarySuffix(double value, DB::WriteBuffer & out, int precision) { const char * units[] = {" B", " KiB", " MiB", " GiB", " TiB", " PiB", " EiB", " ZiB", " YiB"}; formatReadable(value, out, precision, units, sizeof(units) / sizeof(units[0]), 1024); } std::string formatReadableSizeWithBinarySuffix(double value, int precision) { DB::WriteBufferFromOwnString out; formatReadableSizeWithBinarySuffix(value, out, precision); return out.str(); } void formatReadableSizeWithDecimalSuffix(double value, DB::WriteBuffer & out, int precision) { const char * units[] = {" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"}; formatReadable(value, out, precision, units, sizeof(units) / sizeof(units[0]), 1000); } std::string formatReadableSizeWithDecimalSuffix(double value, int precision) { DB::WriteBufferFromOwnString out; formatReadableSizeWithDecimalSuffix(value, out, precision); return out.str(); } void formatReadableQuantity(double value, DB::WriteBuffer & out, int precision) { const char * units[] = {"", " thousand", " million", " billion", " trillion", " quadrillion"}; formatReadable(value, out, precision, units, sizeof(units) / sizeof(units[0]), 1000); } std::string formatReadableQuantity(double value, int precision) { DB::WriteBufferFromOwnString out; formatReadableQuantity(value, out, precision); return out.str(); }
34.535714
135
0.705963
solotzg
7c7134b8c7349d5c887c889aed88a20a339efc19
8,800
cpp
C++
setsmgeo.cpp
khsa1/SETSM
c97389d04f4876e503251ad58129d9905f6cfc84
[ "Apache-2.0" ]
48
2017-02-24T15:30:08.000Z
2022-03-22T06:43:56.000Z
setsmgeo.cpp
khsa1/SETSM
c97389d04f4876e503251ad58129d9905f6cfc84
[ "Apache-2.0" ]
7
2018-01-30T18:09:34.000Z
2022-03-11T16:00:14.000Z
setsmgeo.cpp
khsa1/SETSM
c97389d04f4876e503251ad58129d9905f6cfc84
[ "Apache-2.0" ]
22
2017-03-03T02:52:40.000Z
2022-03-22T06:44:01.000Z
#include "setsmgeo.hpp" #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include "math.h" #include <cmath> #define FLOAT 4 #define UCHAR 1 #define UINT16 12 #define N(a) (sizeof(a) / sizeof(a[0])) #define GDAL_NODATA 42113 static const TIFFFieldInfo xtiffFieldInfo[] = { { GDAL_NODATA, -1, -1, TIFF_ASCII, FIELD_CUSTOM, 1, 0, (char*)"GDAL_NODATA" } }; #define STRIP_SIZE_DEFAULT 8192 #define max(a, b) (((a) > (b)) ? (a) : (b)) int WriteGeotiff(char *filename, void *buffer, size_t width, size_t height, double scale, double minX, double maxY, int projection, int zone, int NS_hemisphere, int data_type) { TIFF *tif; /* TIFF-level descriptor */ GTIF *gtif; /* GeoKey-level descriptor */ size_t bytes = 0; /* Size of data type for computing buffer offset */ switch (data_type) { case FLOAT: bytes = sizeof(float); break; case UCHAR: bytes = sizeof(unsigned char); break; case UINT16: bytes = sizeof(uint16); break; default: printf("unrecognized data type: %d\n", data_type); break; } if (bytes == 0) { // Unknown data type return -1; } long int int_mem = (long)(bytes*height*width); double tif_mem = (double)(int_mem/1024.0/1024.0/1024.0); printf("tif mem %f\n",tif_mem); tif = XTIFFOpen(filename, "w8"); if (!tif) { printf("WriteGeotiff failed in XTIFFOpen\n"); return -1; } gtif = GTIFNew(tif); if (!gtif) { printf("WriteGeotiff failed in GTIFNew\n"); XTIFFClose(tif); return -1; } SetUpTIFFDirectory(tif, width, height, scale, minX, maxY, data_type); SetUpGeoKeys(gtif, projection, zone, NS_hemisphere); for (int row=0; row<height; row++) { if (TIFFWriteScanline(tif, ((char *)buffer) + (bytes * row * width), row, 0) == -1) // TODO: TIFFWriteScanline may return -1 on failure: { TIFFError("WriteGeotiff_DEM","failure in WriteScanline on row %d\n", row); } } GTIFWriteKeys(gtif); GTIFFree(gtif); XTIFFClose(tif); return 0; } uint8 ReadGeotiff_bits(char *filename) { TIFF *tif; uint8 bits; tif = XTIFFOpen(filename, "r"); if (tif) { size_t value = 0; TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &value); if(value == 16) bits = 12; else bits = value; XTIFFClose(tif); } return bits; } CSize ReadGeotiff_info(const char *filename, double *minX, double *maxY, double *grid_size) { TIFF *tif; CSize image_size; tif = XTIFFOpen(filename, "r"); if (tif) { uint16 count = 0; double *data = 0; TIFFGetField(tif, TIFFTAG_GEOTIEPOINTS, &count, &data); if (minX != NULL) *minX = data[3]; if (maxY != NULL) *maxY = data[4]; TIFFGetField(tif, TIFFTAG_GEOPIXELSCALE, &count, &data); if (grid_size != NULL) *grid_size = data[0]; size_t value = 0; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &value); image_size.width = value; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &value); image_size.height = value; TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &value); if(value == 16) value = 12; XTIFFClose(tif); } return image_size; } CSize ReadGeotiff_info_dxy(char *filename, double *minX, double *maxY, double *grid_size_dx, double *grid_size_dy) { TIFF *tif; CSize image_size; tif = XTIFFOpen(filename, "r"); if (tif) { uint16 count = 0; double *data = 0; TIFFGetField(tif, TIFFTAG_GEOTIEPOINTS, &count, &data); if (minX != NULL) *minX = data[3]; if (maxY != NULL) *maxY = data[4]; TIFFGetField(tif, TIFFTAG_GEOPIXELSCALE, &count, &data); if (grid_size_dx != NULL) *grid_size_dx = data[0]; if (grid_size_dy != NULL) *grid_size_dy = data[1]; size_t value = 0; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &value); image_size.width = value; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &value); image_size.height = value; XTIFFClose(tif); } return image_size; } void SetUpTIFFDirectory(TIFF *tif, size_t width, size_t height, double scale, double minX, double maxY, int data_type) { double tiepoints[6] = {0}; double pixscale[3] = {0}; tiepoints[3] = minX; tiepoints[4] = maxY; pixscale[0] = scale; pixscale[1] = scale; TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height); TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_GEOTIEPOINTS, 6,tiepoints); TIFFSetField(tif, TIFFTAG_GEOPIXELSCALE, 3,pixscale); TIFFSetField(tif, TIFFTAG_PREDICTOR, 1); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); //TIFFSetField(tif, TIFFTAG_TILEWIDTH, 256); //TIFFSetField(tif, TIFFTAG_TILELENGTH, 256); switch (data_type) { case FLOAT: TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32); TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo)); TIFFSetField(tif, GDAL_NODATA, "-9999"); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, max(1, (STRIP_SIZE_DEFAULT * 8) / (width * 32))); break; case UCHAR: TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 2); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, max(1, (STRIP_SIZE_DEFAULT * 8) / (width * 8))); break; case UINT16: TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, max(1, (STRIP_SIZE_DEFAULT * 8) / (width * 16))); break; default: break; } } void SetUpGeoKeys(GTIF *gtif, int projection, int zone, int NS_hemisphere) { GTIFKeySet(gtif, GTModelTypeGeoKey, TYPE_SHORT, 1, ModelProjected); GTIFKeySet(gtif, GTRasterTypeGeoKey, TYPE_SHORT, 1, RasterPixelIsArea); GTIFKeySet(gtif, GeogCitationGeoKey, TYPE_ASCII, 0, "WGS 84"); GTIFKeySet(gtif, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, Angular_Degree); GTIFKeySet(gtif, ProjLinearUnitsGeoKey, TYPE_SHORT, 1, Linear_Meter); if (projection == 1) // Polar Stereographic { GTIFKeySet(gtif, GTCitationGeoKey, TYPE_ASCII, 0, "unnamed"); GTIFKeySet(gtif, GeographicTypeGeoKey, TYPE_SHORT, 1, GCS_WGS_84); GTIFKeySet(gtif, GeogSemiMajorAxisGeoKey, TYPE_DOUBLE, 1, 6378137.0); GTIFKeySet(gtif, GeogInvFlatteningGeoKey, TYPE_DOUBLE, 1, 298.257223563); GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1, 32767); // user-defined GTIFKeySet(gtif, ProjectionGeoKey, TYPE_SHORT, 1, 32767); // user-defined GTIFKeySet(gtif, ProjCoordTransGeoKey, TYPE_SHORT, 1, CT_PolarStereographic); GTIFKeySet(gtif, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, 0.0); GTIFKeySet(gtif, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, 0.0); GTIFKeySet(gtif, ProjScaleAtNatOriginGeoKey, TYPE_DOUBLE, 1, 1.0); if (NS_hemisphere != 0) { GTIFKeySet(gtif, ProjNatOriginLatGeoKey, TYPE_DOUBLE, 1, 70.0); GTIFKeySet(gtif, ProjStraightVertPoleLongGeoKey, TYPE_DOUBLE, 1, -45.0); } else { GTIFKeySet(gtif, ProjNatOriginLatGeoKey, TYPE_DOUBLE, 1, -71.0); GTIFKeySet(gtif, ProjStraightVertPoleLongGeoKey, TYPE_DOUBLE, 1, 0.0); } } else // UTM { char GeoKeyStr[500]; if (NS_hemisphere != 0) { sprintf(GeoKeyStr, "UTM Zone %d, Northern Hemisphere", zone); GTIFKeySet(gtif, GTCitationGeoKey, TYPE_ASCII, 0, GeoKeyStr); GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1, PCS_WGS84_UTM_zone_1N - 1 + zone); printf("%s\n",GeoKeyStr); } else { sprintf(GeoKeyStr, "UTM Zone %d, Southern Hemisphere", zone); GTIFKeySet(gtif, GTCitationGeoKey, TYPE_ASCII, 0, GeoKeyStr); GTIFKeySet(gtif, ProjectedCSTypeGeoKey, TYPE_SHORT, 1, PCS_WGS84_UTM_zone_1S - 1 + zone); printf("%s\n",GeoKeyStr); } } }
32.835821
175
0.6175
khsa1
7c7590c3ea0025e22e22424fcbb91e0a6e3c337c
1,064
hpp
C++
include/conf.hpp
kaiyuhou/nprint-wlan
d8ded24a1f08087b8484f652215354f0202227f3
[ "Apache-2.0" ]
null
null
null
include/conf.hpp
kaiyuhou/nprint-wlan
d8ded24a1f08087b8484f652215354f0202227f3
[ "Apache-2.0" ]
null
null
null
include/conf.hpp
kaiyuhou/nprint-wlan
d8ded24a1f08087b8484f652215354f0202227f3
[ "Apache-2.0" ]
null
null
null
/* * Copyright nPrint 2020 * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at https://www.apache.org/licenses/LICENSE-2.0 */ #ifndef CONF #define CONF #include <cstddef> #include <stdint.h> /* * Config class is a container to hold command line arguments */ class Config { public: Config(); /* Protocol flags */ uint8_t wlan; // kaiyu: TODO: Do we need the radiotap flag? uint8_t eth; uint8_t ipv4; uint8_t ipv6; uint8_t tcp; uint8_t udp; uint8_t icmp; uint32_t payload; uint8_t relative_timestamps; /* Output modification */ uint8_t live_capture; uint8_t verbose; uint8_t csv; uint8_t pcap; uint8_t nprint; int8_t fill_with; uint64_t num_packets; char *filter; char *infile; char *outfile; char *ip_file; char *device; }; #endif
21.714286
78
0.601504
kaiyuhou
7c77c47fb95575942b84fb542f0969c9d79bb757
4,110
cpp
C++
test/stdgpu/contract.cpp
stotko/stdgpu
e10f6f3ccc9902d693af4380c3bcd188ec34a2e6
[ "Apache-2.0" ]
686
2019-08-18T19:31:30.000Z
2022-03-29T07:17:43.000Z
test/stdgpu/contract.cpp
intel-isl/stdgpu
0091cee675bf64eddf61523108e2e53a985e51ec
[ "Apache-2.0" ]
188
2019-10-29T09:50:38.000Z
2021-07-26T14:12:13.000Z
test/stdgpu/contract.cpp
intel-isl/stdgpu
0091cee675bf64eddf61523108e2e53a985e51ec
[ "Apache-2.0" ]
41
2019-10-29T09:56:30.000Z
2022-03-31T08:38:50.000Z
/* * Copyright 2020 Patrick Stotko * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <gtest/gtest.h> #include <type_traits> #include <stdgpu/config.h> #include <stdgpu/contract.h> class stdgpu_contract : public ::testing::Test { protected: // Called before each test void SetUp() override { } // Called after each test void TearDown() override { } }; TEST_F(stdgpu_contract, expects_host_value) { #if STDGPU_ENABLE_CONTRACT_CHECKS volatile bool true_value = true; STDGPU_EXPECTS(true_value); volatile bool false_value = false; EXPECT_DEATH(STDGPU_EXPECTS(false_value), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto) #endif } TEST_F(stdgpu_contract, expects_host_expression) { #if STDGPU_ENABLE_CONTRACT_CHECKS volatile int value_1 = 42; volatile int value_2 = 24; STDGPU_EXPECTS(value_1 == 42 && value_2 > 0); EXPECT_DEATH(STDGPU_EXPECTS(value_1 != 42 || value_2 <= 0), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto) #endif } TEST_F(stdgpu_contract, expects_host_comma_expression) { #if STDGPU_ENABLE_CONTRACT_CHECKS STDGPU_EXPECTS(std::is_same<int, int>::value); //NOLINT(hicpp-static-assert,misc-static-assert) EXPECT_DEATH(STDGPU_EXPECTS(std::is_same<int, float>::value), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto,hicpp-static-assert,misc-static-assert) #endif } TEST_F(stdgpu_contract, ensures_host_value) { #if STDGPU_ENABLE_CONTRACT_CHECKS volatile bool true_value = true; STDGPU_ENSURES(true_value); volatile bool false_value = false; EXPECT_DEATH(STDGPU_ENSURES(false_value), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto) #endif } TEST_F(stdgpu_contract, ensures_host_expression) { #if STDGPU_ENABLE_CONTRACT_CHECKS volatile int value_1 = 42; volatile int value_2 = 24; STDGPU_ENSURES(value_1 == 42 && value_2 > 0); EXPECT_DEATH(STDGPU_ENSURES(value_1 != 42 || value_2 <= 0), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto) #endif } TEST_F(stdgpu_contract, ensures_host_comma_expression) { #if STDGPU_ENABLE_CONTRACT_CHECKS STDGPU_ENSURES(std::is_same<int, int>::value); //NOLINT(hicpp-static-assert,misc-static-assert) EXPECT_DEATH(STDGPU_ENSURES(std::is_same<int, float>::value), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto,hicpp-static-assert,misc-static-assert) #endif } TEST_F(stdgpu_contract, assert_host_value) { #if STDGPU_ENABLE_CONTRACT_CHECKS volatile bool true_value = true; STDGPU_ASSERT(true_value); volatile bool false_value = false; EXPECT_DEATH(STDGPU_ASSERT(false_value), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto) #endif } TEST_F(stdgpu_contract, assert_host_expression) { #if STDGPU_ENABLE_CONTRACT_CHECKS volatile int value_1 = 42; volatile int value_2 = 24; STDGPU_ASSERT(value_1 == 42 && value_2 > 0); EXPECT_DEATH(STDGPU_ASSERT(value_1 != 42 || value_2 <= 0), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto) #endif } TEST_F(stdgpu_contract, assert_host_comma_expression) { #if STDGPU_ENABLE_CONTRACT_CHECKS STDGPU_ASSERT(std::is_same<int, int>::value); //NOLINT(hicpp-static-assert,misc-static-assert) EXPECT_DEATH(STDGPU_ASSERT(std::is_same<int, float>::value), ""); //NOLINT(hicpp-no-array-decay,hicpp-avoid-goto,hicpp-static-assert,misc-static-assert) #endif }
26.688312
161
0.691971
stotko
75af4e8d4f1164c9d0b35ea1d1101e80fcc652eb
10,086
cpp
C++
src/generator/snippetfactory.cpp
ikitayama/cobi
e9bc4a5675ead1874ad9ffa953de8edb3a763479
[ "BSD-3-Clause" ]
null
null
null
src/generator/snippetfactory.cpp
ikitayama/cobi
e9bc4a5675ead1874ad9ffa953de8edb3a763479
[ "BSD-3-Clause" ]
null
null
null
src/generator/snippetfactory.cpp
ikitayama/cobi
e9bc4a5675ead1874ad9ffa953de8edb3a763479
[ "BSD-3-Clause" ]
1
2018-12-14T02:45:41.000Z
2018-12-14T02:45:41.000Z
/***************************************************************************** ** Cobi http://www.scalasca.org/ ** ***************************************************************************** ** Copyright (c) 2009-2010 ** ** Forschungszentrum Juelich, Juelich Supercomputing Centre ** ** ** ** See the file COPYRIGHT in the base directory for details ** *****************************************************************************/ /** * @file snippetfactory.cpp * @author Jan Mussler * @brief Different SnippetFactory implementations * * Snippetfactorys transform the Boost::Spirit AST to either IExpression AST or * print the tree to the console */ #include "snippetfactories.h" #include <sstream> using namespace gi::generator; using namespace gi::generator::parser; std::string ISnippetFactory::getValueOfNode(tree_node<node_val_data<> >* node) { return std::string(node->value.begin(), node->value.end()); } /** * Translate escaped string from specification to unescaped string * * @param s * @return string with all escaped chars \n \t \\ replaced by the appropriate string */ std::string translateEscape(std::string s) { size_t si; size_t tab; size_t nl; size_t bs; int nr = 0; string r = ""; nl = s.find("\\n"); bs = s.find("\\\\"); tab = s.find("\\t"); /** * select the next escaped sequence and then translate it */ if (nl != s.npos && (nl < bs || bs == s.npos) && (nl < tab || tab == s.npos)) { nr = 2; r = "\n"; si = nl; } else if (bs != s.npos && (bs < nl || nl == s.npos) && (bs < tab || tab == s.npos)) { nr = 2; r = "\\"; si = bs; } else if (tab != s.npos && (tab < nl || nl == s.npos) && (tab < bs || bs == s.npos)) { nr = 2; r = "\t"; si = tab; } else { si = s.npos; } while (si != s.npos) { s.replace(si, nr, r); if(bs==si) si++; // move ahead of inserted "\" to not parse it again nl = s.find("\\n", si); bs = s.find("\\\\", si); tab = s.find("\\t", si); if (nl != s.npos && (nl < bs || bs == s.npos) && (nl < tab || tab == s.npos)) { nr = 2; r = "\n"; si = nl; } else if (bs != s.npos && (bs < nl || nl == s.npos) && (bs < tab || tab == s.npos)) { nr = 2; r = "\\"; si = bs; } else if (tab != s.npos && (tab < nl || nl == s.npos) && (tab < bs || bs == s.npos)) { nr = 2; r = "\t"; si = tab; } else { si = s.npos; } } return s; } /** * generate readable output on std::out of ast tree generated by spirit * @return NullOp() */ IExpression* DemoSnippetFactory::evaluateNode(tree_node<node_val_data<> >* node) { for (int i = level; i > 0; --i) { std::cout << "\t"; } std::cout << CodeParser::getRuleNameToID(node->value.id()); if (node->value.id() == g.identifierID) { std::cout << " \"" << std::string(node->value.begin(), node->value.end()) << "\""; } else if (node->value.id() == g.stringLiteralID || node->value.id() == g.intLiteralID) { std::string s = std::string(node->value.begin(), node->value.end()); s = s.substr(1,s.size()-2); std::cout << " " << translateEscape(s); } else if (node->value.id() == g.intLiteralID) { std::string s = std::string(node->value.begin(), node->value.end()); std::cout << " " << translateEscape(s); } else if (node->value.id() == g.funcParID || node->value.id() == g.contextVarID) { std::cout << " " << std::string(node->value.begin(), node->value.end()); } else if (node->value.id() == g.boolExpressionID) { std::cout << " " << std::string(node->value.begin(), node->value.end()); } else if (node->value.id() == g.termID) { std::cout << " " << std::string(node->value.begin(), node->value.end()); } std::cout << "\n"; if (node->children.size() != 0) { ++level; for (unsigned int i = 0; i < node->children.size(); ++i) { evaluateNode(&(node->children[i])); } --level; } return new NullOp(); } DemoSnippetFactory::DemoSnippetFactory(codegrammar &g) : g(g), level(0) { } DemoSnippetFactory::~DemoSnippetFactory() { } Constant* SnippetFactory::evaluateConstantNode(tree_node<node_val_data<> >* node) { if (node->value.id() == g.stringLiteralID) { std::string s = getValueOfNode(node); s = s.substr(1,s.size()-2); return Constant::createConstant(translateEscape(s)); } else if (node->value.id() == g.contextVarID) { return new ContextConstant(getValueOfNode(node)); } else if (node->value.id() == g.concatConstStrID) { assert(node->children.size() == 2); Constant* leftOp = evaluateConstantNode(&node->children[0]); Constant* rightOp = evaluateConstantNode(&node->children[1]); return new ConcatConstants(leftOp, rightOp); } else { throw ex::GeneratorException(); } } IBoolExpression* SnippetFactory::evaluateBoolExpressionNode(tree_node<node_val_data<> >* node) { assert(node->value.id() == g.boolExpressionID); assert(node->children.size() == 2); IExpression* leftOp = evaluateNode(&node->children[0]); IExpression* rightOp = evaluateNode(&node->children[1]); return new BoolExpression(getValueOfNode(node), leftOp, rightOp); } /** * Transform AST from parser to GI internal AST */ IExpression* SnippetFactory::evaluateNode(tree_node<node_val_data<> >* node) { /** * Function Node * 1. child: identifier node of function to be called * 2. child: parameter list node */ if (node->value.id() == g.functionID) { FunctionCall* f = new FunctionCall(getValueOfNode(&node->children[0])); if (node->children.size() == 2 && node->children[1].value.id() == g.paramlisteID) { for (unsigned int i = 0; i < node->children[1].children.size(); i += 2) { f->addParameter(evaluateNode(&node->children[1].children[i])); } } return f; }/** * StringLiteral */ else if (node->value.id() == g.stringLiteralID) { std::string s = getValueOfNode(node); s = s.substr(1,s.size()-2); s = translateEscape(s); return Constant::createConstant(s); }/** * Integer Literal */ else if (node->value.id() == g.intLiteralID) { std::stringstream ss; ss << getValueOfNode(node); int i = 0; ss >> i; return Constant::createConstant(i); }/** * variable */ else if (node->value.id() == g.identifierID) { return new Variable(getValueOfNode(node)); }/** * context variable */ else if (node->value.id() == g.contextVarID) { return new Variable(getValueOfNode(node)); }/** * function parameter access */ else if (node->value.id() == g.funcParID) { return new FunctionParam(getValueOfNode(node)); }/** * assignment operation */ else if (node->value.id() == g.assignmentID) { return new Assignment(evaluateNode(&node->children[0]), evaluateNode(&node->children[1])); }/** * program node -> sequence */ else if (node->value.id() == g.programID) { if (node->children.size() == 0) { return new NullOp(); } else { Sequence* seq = new Sequence(); for (unsigned int i = 0; i < node->children.size(); ++i) { seq->addStatement(evaluateNode(&node->children[i])); } return seq; } } else if (node->value.id() == g.conditionalID) { assert(node->children.size() == 2 || node->children.size() == 3); string relOp = getValueOfNode(&node->children[0]); IBoolExpression* boolExp = evaluateBoolExpressionNode(&node->children[0]); // evaluateNode(&node->children[0]); // IExpression* leftOp = evaluateNode(&node->children[0].children[0]); // IExpression* rightOp = evaluateNode(&node->children[0].children[1]); // expression if boolExp==true IExpression* tCode = evaluateNode(&node->children[1]); // check whether else {} is set if (node->children.size() == 3) { return new Conditional(boolExp, tCode, 0); } else { // expression if false IExpression* fCode = evaluateNode(&node->children[2]); return new Conditional(boolExp, tCode, fCode); } } else if (node->value.id() == g.termID) { assert(node->children.size() == 2); string op = getValueOfNode(node); IExpression* leftOp = evaluateNode(&node->children[0]); IExpression* rightOp = evaluateNode(&node->children[1]); return new Term(op, leftOp, rightOp); } else if (node->value.id() == g.concatConstStrID) { assert(node->children.size() == 2); Constant* leftOp = evaluateConstantNode(&node->children[0]); Constant* rightOp = evaluateConstantNode(&node->children[1]); return new ConcatConstants(leftOp, rightOp); } else if (node->value.id() == g.boolExpressionID) { // dublicated code from evaluateBoolExpression() which is necessary to deliver the BPatch_boolExp assert(node->children.size() == 2); IExpression* leftOp = evaluateNode(&node->children[0]); IExpression* rightOp = evaluateNode(&node->children[1]); return new BoolExpression(getValueOfNode(node), leftOp, rightOp); } return new NullOp(); } SnippetFactory::SnippetFactory(codegrammar & g) : g(g) { } SnippetFactory::~SnippetFactory() { }
32.019048
119
0.530835
ikitayama
75b18bb321bc5d7cf9a2f30758f70c1cc65f3d41
2,251
cpp
C++
cpp/godot-cpp/src/gen/PrimitiveMesh.cpp
GDNative-Gradle/proof-of-concept
162f467430760cf959f68f1638adc663fd05c5fd
[ "MIT" ]
1
2021-03-16T09:51:00.000Z
2021-03-16T09:51:00.000Z
cpp/godot-cpp/src/gen/PrimitiveMesh.cpp
GDNative-Gradle/proof-of-concept
162f467430760cf959f68f1638adc663fd05c5fd
[ "MIT" ]
null
null
null
cpp/godot-cpp/src/gen/PrimitiveMesh.cpp
GDNative-Gradle/proof-of-concept
162f467430760cf959f68f1638adc663fd05c5fd
[ "MIT" ]
null
null
null
#include "PrimitiveMesh.hpp" #include <core/GodotGlobal.hpp> #include <core/CoreTypes.hpp> #include <core/Ref.hpp> #include <core/Godot.hpp> #include "__icalls.hpp" #include "Material.hpp" namespace godot { PrimitiveMesh::___method_bindings PrimitiveMesh::___mb = {}; void PrimitiveMesh::___init_method_bindings() { ___mb.mb__update = godot::api->godot_method_bind_get_method("PrimitiveMesh", "_update"); ___mb.mb_get_custom_aabb = godot::api->godot_method_bind_get_method("PrimitiveMesh", "get_custom_aabb"); ___mb.mb_get_flip_faces = godot::api->godot_method_bind_get_method("PrimitiveMesh", "get_flip_faces"); ___mb.mb_get_material = godot::api->godot_method_bind_get_method("PrimitiveMesh", "get_material"); ___mb.mb_get_mesh_arrays = godot::api->godot_method_bind_get_method("PrimitiveMesh", "get_mesh_arrays"); ___mb.mb_set_custom_aabb = godot::api->godot_method_bind_get_method("PrimitiveMesh", "set_custom_aabb"); ___mb.mb_set_flip_faces = godot::api->godot_method_bind_get_method("PrimitiveMesh", "set_flip_faces"); ___mb.mb_set_material = godot::api->godot_method_bind_get_method("PrimitiveMesh", "set_material"); } void PrimitiveMesh::_update() const { ___godot_icall_void(___mb.mb__update, (const Object *) this); } AABB PrimitiveMesh::get_custom_aabb() const { return ___godot_icall_AABB(___mb.mb_get_custom_aabb, (const Object *) this); } bool PrimitiveMesh::get_flip_faces() const { return ___godot_icall_bool(___mb.mb_get_flip_faces, (const Object *) this); } Ref<Material> PrimitiveMesh::get_material() const { return Ref<Material>::__internal_constructor(___godot_icall_Object(___mb.mb_get_material, (const Object *) this)); } Array PrimitiveMesh::get_mesh_arrays() const { return ___godot_icall_Array(___mb.mb_get_mesh_arrays, (const Object *) this); } void PrimitiveMesh::set_custom_aabb(const AABB aabb) { ___godot_icall_void_AABB(___mb.mb_set_custom_aabb, (const Object *) this, aabb); } void PrimitiveMesh::set_flip_faces(const bool flip_faces) { ___godot_icall_void_bool(___mb.mb_set_flip_faces, (const Object *) this, flip_faces); } void PrimitiveMesh::set_material(const Ref<Material> material) { ___godot_icall_void_Object(___mb.mb_set_material, (const Object *) this, material.ptr()); } }
35.730159
115
0.791204
GDNative-Gradle
75b20b34e46ab9073ba9da9da3f6f7be5256eb99
1,165
cpp
C++
graph/src/pos.cpp
Kei18/grid-pathfinding
f444df84459258d7b4d8ceffdbbf2e201b042a68
[ "MIT" ]
2
2021-08-16T08:13:35.000Z
2022-03-11T05:52:27.000Z
graph/src/pos.cpp
Kei18/grid-pathfinding
f444df84459258d7b4d8ceffdbbf2e201b042a68
[ "MIT" ]
null
null
null
graph/src/pos.cpp
Kei18/grid-pathfinding
f444df84459258d7b4d8ceffdbbf2e201b042a68
[ "MIT" ]
null
null
null
#include "../include/pos.hpp" #include <cmath> #include <iomanip> #include <iostream> Pos::Pos(int _x, int _y) : x(_x), y(_y) {} Pos::~Pos() {} void Pos::print() const { std::cout << "(" << std::right << std::setw(3) << x << ", " << std::right << std::setw(3) << y << ")"; } void Pos::println() const { print(); std::cout << std::endl; } int Pos::manhattanDist(const Pos& pos) const { return std::abs(x - pos.x) + std::abs(y - pos.y); } float Pos::euclideanDist(const Pos& pos) const { float dx = x - pos.x; float dy = y - pos.y; return std::sqrt(dx * dx + dy * dy); } bool Pos::operator==(const Pos& other) const { return x == other.x && y == other.y; } Pos Pos::operator+(const Pos& other) const { return Pos(x + other.x, y + other.y); } Pos Pos::operator-(const Pos& other) const { return Pos(x - other.x, y - other.y); } Pos Pos::operator*(const int i) const { return Pos(x * i, y * i); } void Pos::operator+=(const Pos& other) { x = x + other.x; y = y + other.y; } void Pos::operator-=(const Pos& other) { x = x - other.x; y = y - other.y; } void Pos::operator*=(const int i) { x = x * i; y = y * i; }
16.884058
75
0.559657
Kei18
75b3bb26b4830acd89ab68090c6bee29c2b8f80d
2,097
hpp
C++
fw/include/pin.hpp
cednik/one-wire_sniffer
bfa8e38e6310c8a20ac48eaa711be53b3454806b
[ "MIT" ]
null
null
null
fw/include/pin.hpp
cednik/one-wire_sniffer
bfa8e38e6310c8a20ac48eaa711be53b3454806b
[ "MIT" ]
null
null
null
fw/include/pin.hpp
cednik/one-wire_sniffer
bfa8e38e6310c8a20ac48eaa711be53b3454806b
[ "MIT" ]
null
null
null
#pragma once #include "callback.hpp" #include "Arduino.h" #ifndef CPUS_COUNT #define CPUS_COUNT 2 #endif class Pin { public: typedef uint8_t pin_num_t; typedef uint8_t pin_mode_t; typedef int intr_mode_t; typedef uint8_t Trigger; static constexpr pin_mode_t KEEP_CURRENT = 255; static constexpr pin_num_t DUMMY_PIN = 40; public: Pin(pin_num_t pin, pin_mode_t mode = KEEP_CURRENT, pin_mode_t value = KEEP_CURRENT, bool inverted = false); Pin(const Pin& pin); ~Pin(); void INTR_ATTR setHigh(); void INTR_ATTR setLow(); void INTR_ATTR setValue(bool value); void setOutput(); void setInput(bool pullup = false); void setOpenDrain(bool pullup = false); bool INTR_ATTR read() const; void attachInterrupt(Callback::callback_t callback, Callback::callback_arg_t arg, Trigger mode); void detachInterrupt(); void INTR_ATTR interruptTrigger(Trigger trigger); void INTR_ATTR clearInterruptFlag(); pin_num_t pin() const; static void initInterrupts(); static void printInterrupts(); private: typedef uint8_t interruptIndex_t; static constexpr interruptIndex_t NONE_INTERRUPT = 255; static constexpr uint8_t ISR_SLOTS = GPIO_PIN_COUNT; struct InterruptHandler { uint64_t pinMask; Callback callback; }; struct InterruptRecord { uint8_t cpu; interruptIndex_t index; InterruptRecord(uint8_t cpu, interruptIndex_t index); }; static void _printInterruptSlots(uint8_t cpu, uint8_t first = 0, uint8_t last = ISR_SLOTS); static void _printPinsInterruptSettings(uint8_t first = 0, uint8_t last = GPIO_PIN_COUNT); void _enableInterruptOnCpu(bool en, uint8_t cpu); const pin_num_t m_pin; const bool m_inverted; portMUX_TYPE m_lock; InterruptRecord m_interruptRecord; static void INTR_ATTR ISR(void* args); static void initWorker(void* args); static portMUX_TYPE s_lock; static InterruptHandler s_interruptHandler[CPUS_COUNT][ISR_SLOTS]; static intr_handle_t s_interruptHandle[CPUS_COUNT]; };
25.573171
111
0.721984
cednik
75b3c8b3de8a618f3818cd8ce9b5a58c897875ee
270
cpp
C++
node_modules/lzz-gyp/lzz-source/basl_HasTokenSameLexeme.cpp
SuperDizor/dizornator
9f57dbb3f6af80283b4d977612c95190a3d47900
[ "ISC" ]
3
2019-09-18T16:44:33.000Z
2021-03-29T13:45:27.000Z
node_modules/lzz-gyp/lzz-source/basl_HasTokenSameLexeme.cpp
SuperDizor/dizornator
9f57dbb3f6af80283b4d977612c95190a3d47900
[ "ISC" ]
null
null
null
node_modules/lzz-gyp/lzz-source/basl_HasTokenSameLexeme.cpp
SuperDizor/dizornator
9f57dbb3f6af80283b4d977612c95190a3d47900
[ "ISC" ]
2
2019-03-29T01:06:38.000Z
2019-09-18T16:44:34.000Z
// basl_HasTokenSameLexeme.cpp // #include "basl_HasTokenSameLexeme.h" #ifndef LZZ_ENABLE_INLINE #include "basl_HasTokenSameLexeme.inl" #endif #define LZZ_INLINE inline namespace basl { HasTokenSameLexeme::~ HasTokenSameLexeme () {} } #undef LZZ_INLINE
18
45
0.755556
SuperDizor
75b7b9c71e4f39df31ec65ad52140fb0666cccd2
73,086
cpp
C++
tests/das_tests/license_tests.cpp
powerchain-ltd/greenpower-blockchain
ff04c37f2de11677c3a34889fdede1256a3e5e02
[ "MIT" ]
1
2021-07-26T02:42:01.000Z
2021-07-26T02:42:01.000Z
tests/das_tests/license_tests.cpp
green-powerchain-ltd/greenpower-blockchain
ff04c37f2de11677c3a34889fdede1256a3e5e02
[ "MIT" ]
null
null
null
tests/das_tests/license_tests.cpp
green-powerchain-ltd/greenpower-blockchain
ff04c37f2de11677c3a34889fdede1256a3e5e02
[ "MIT" ]
null
null
null
/* * MIT License * * Copyright (c) 2018 Tech Solutions Malta LTD * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <boost/test/unit_test.hpp> #include <graphene/chain/protocol/license.hpp> #include <graphene/chain/database.hpp> #include <graphene/chain/exceptions.hpp> #include <graphene/chain/account_object.hpp> #include <graphene/chain/frequency_history_record_object.hpp> #include <graphene/chain/license_objects.hpp> #include <graphene/chain/upgrade_event_object.hpp> #include "../common/database_fixture.hpp" using namespace graphene::chain; using namespace graphene::chain::test; BOOST_FIXTURE_TEST_SUITE( dascoin_tests, database_fixture ) BOOST_FIXTURE_TEST_SUITE( license_tests, database_fixture ) BOOST_AUTO_TEST_CASE( regression_test_license_information_index ) { try { db.create<license_information_object>([&](license_information_object& lio){}); db.create<license_information_object>([&](license_information_object& lio){}); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( charter_license_type_value_test ) { try { auto lic = *(_dal.get_license_type("standard_charter")); BOOST_CHECK_EQUAL( lic.amount.value, DASCOIN_BASE_STANDARD_CYCLES ); lic = *(_dal.get_license_type("manager_charter")); BOOST_CHECK_EQUAL( lic.amount.value, DASCOIN_BASE_MANAGER_CYCLES ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( license_information_unit_test ) { try { VAULT_ACTOR(vault); auto standard_charter = *(_dal.get_license_type("standard_charter")); const share_type bonus_percent = 50; const share_type frequency_lock = 200; const time_point_sec issue_time = db.head_block_time(); const uint32_t amount = DASCOIN_BASE_STANDARD_CYCLES + (50 * DASCOIN_BASE_STANDARD_CYCLES) / 100; do_op(issue_license_operation(get_license_issuer_id(), vault_id, standard_charter.id, bonus_percent, frequency_lock, issue_time)); BOOST_CHECK( vault.license_information.valid() ); const auto& license_information_obj = (*vault.license_information)(db); BOOST_CHECK( license_information_obj.account == vault_id ); const auto& license_history = license_information_obj.history; BOOST_CHECK_EQUAL( license_history.size(), 1 ); const auto& license_record = license_history[0]; BOOST_CHECK( license_record.license == standard_charter.id ); BOOST_CHECK_EQUAL( license_record.amount.value, amount ); BOOST_CHECK_EQUAL( license_record.base_amount.value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( license_record.bonus_percent.value, 50 ); BOOST_CHECK_EQUAL( license_record.frequency_lock.value, 200 ); BOOST_CHECK( license_record.activated_at == issue_time ); BOOST_CHECK( license_record.issued_on_blockchain == issue_time ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( get_license_types_unit_test ) { try { auto lic_vec = _dal.get_license_types(); // Number of kinds (regular, chartered, locked, utility, package) times number of types (standard, manager, pro, executive, vise president, president + 1: BOOST_CHECK_EQUAL( lic_vec.size(), 31 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( get_license_type_names_ids_unit_test ) { try { auto lic_vec = _dal.get_license_types(); auto names_ids = _dal.get_license_type_names_ids(); BOOST_CHECK_EQUAL( lic_vec.size(), names_ids.size() ); for (size_t i = 0; i < names_ids.size(); ++i) { BOOST_CHECK_EQUAL( names_ids[i].first, lic_vec[i].name ); BOOST_CHECK( names_ids[i].second == lic_vec[i].id ); } } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( edit_license_type_test ) { try { const auto& lic = _dal.get_license_type("standard"); BOOST_CHECK(lic.valid()); const auto& lic_id = lic->id; // Try to set license's name to a name which is longer than 64 chars: GRAPHENE_REQUIRE_THROW( do_op(edit_license_type_operation(get_license_administrator_id(), lic_id, "0123456789012345678901234567890123456789012345678901234567890123456789", 200, 10)), fc::exception ); // Try to set license's name to an empty string: GRAPHENE_REQUIRE_THROW( do_op(edit_license_type_operation(get_license_administrator_id(), lic_id, "", 200, 10)), fc::exception ); // Try to set license's amount to 0: GRAPHENE_REQUIRE_THROW( do_op(edit_license_type_operation(get_license_administrator_id(), lic_id, "x", 0, 10)), fc::exception ); // Try to set license's eur limit to 0: GRAPHENE_REQUIRE_THROW( do_op(edit_license_type_operation(get_license_administrator_id(), lic_id, "x", 200, 0)), fc::exception ); // Set name to 'standard_plus', amount to 200 and euro limit to 10: do_op(edit_license_type_operation(get_license_administrator_id(), lic_id, "standard_plus", 200, 10)); const auto& lic_plus = _dal.get_license_type("standard_plus"); BOOST_CHECK(lic_plus.valid()); BOOST_CHECK_EQUAL( lic_plus->amount.value, 200 ); BOOST_CHECK_EQUAL( lic_plus->eur_limit.value, 10 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( frequency_record_index_test ) { try { db.create<frequency_history_record_object>([&](frequency_history_record_object& fhro){}); db.create<frequency_history_record_object>([&](frequency_history_record_object& fhro){}); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( update_global_frequency_unit_test ) { try { // Try to update global frequency using the wrong authority: GRAPHENE_REQUIRE_THROW( do_op(update_global_frequency_operation(get_license_administrator_id(), 450, "TEST")), fc::exception ); // Try to update global frequency to zero: GRAPHENE_REQUIRE_THROW( do_op(update_global_frequency_operation(get_license_issuer_id(), 0, "TEST")), fc::exception ); // Try to update global frequency with too long comment: GRAPHENE_REQUIRE_THROW( do_op(update_global_frequency_operation(get_license_issuer_id(), 0, "0123456789012345678901234567890123456789012345678901234567890123456789")), fc::exception ); do_op(update_global_frequency_operation(get_license_issuer_id(), 450, "TEST")); auto frequency = db.get_dynamic_global_properties().frequency; BOOST_CHECK_EQUAL( frequency.value, 450 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( get_frequency_history_unit_test ) { try { do_op(update_global_frequency_operation(get_license_issuer_id(), 450, "TEST")); const auto& fhistory = _dal.get_frequency_history(); // Here we have object in the history: BOOST_CHECK_EQUAL( fhistory.size(), 1 ); BOOST_CHECK_EQUAL( fhistory[0].frequency.value, 450 ); BOOST_CHECK_EQUAL( fhistory[0].comment, "TEST" ); do_op(update_global_frequency_operation(get_license_issuer_id(), 350, "TEST2")); const auto& fhistory2 = _dal.get_frequency_history(); // After second update, there should be two objects in the history: BOOST_CHECK_EQUAL( fhistory2.size(), 2 ); BOOST_CHECK_EQUAL( fhistory2[0].frequency.value, 450 ); BOOST_CHECK_EQUAL( fhistory2[0].comment, "TEST" ); BOOST_CHECK_EQUAL( fhistory2[1].frequency.value, 350 ); BOOST_CHECK_EQUAL( fhistory2[1].comment, "TEST2" ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( get_frequency_history_by_page_unit_test ) { try { for (int i = 0; i < 105; ++i) do_op(update_global_frequency_operation(get_license_issuer_id(), 100 + i , "TEST")); // This ought to fall, cannot retrieve more than 100 elements: GRAPHENE_REQUIRE_THROW( _dal.get_frequency_history_by_page(0, 102), fc::exception ); // Get first 90 elements: const auto& fhistory = _dal.get_frequency_history_by_page(0, 90); BOOST_CHECK_EQUAL( fhistory.size(), 90 ); // 69th element should have frequency set to 169: BOOST_CHECK_EQUAL( fhistory[69].frequency.value, 169 ); // Get 10 elements, starting from 50: const auto& fhistory2 = _dal.get_frequency_history_by_page(50, 10); BOOST_CHECK_EQUAL( fhistory2.size(), 10 ); // First element should have frequency set to 150: BOOST_CHECK_EQUAL( fhistory2[0].frequency.value, 150 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( locked_license_unit_test ) { try { VAULT_ACTOR(vault); auto locked = *(_dal.get_license_type("standard_locked")); const share_type bonus_percent = 50; share_type frequency_lock = 0; const time_point_sec issue_time = db.head_block_time(); const uint32_t amount = DASCOIN_BASE_STANDARD_CYCLES + (50 * DASCOIN_BASE_STANDARD_CYCLES) / 100; // This will fail, frequency cannot be zero: GRAPHENE_REQUIRE_THROW( do_op(issue_license_operation(get_license_issuer_id(), vault_id, locked.id, bonus_percent, frequency_lock, issue_time)), fc::exception ); frequency_lock = 200; // Frequency is now valid, this ought to work: do_op(issue_license_operation(get_license_issuer_id(), vault_id, locked.id, bonus_percent, frequency_lock, issue_time)); BOOST_CHECK( vault.license_information.valid() ); const auto& license_information_obj = (*vault.license_information)(db); BOOST_CHECK( license_information_obj.account == vault_id ); const auto& license_history = license_information_obj.history; BOOST_CHECK_EQUAL( license_history.size(), 1 ); const auto& license_record = license_history[0]; BOOST_CHECK( license_record.license == locked.id ); BOOST_CHECK_EQUAL( license_record.amount.value, amount ); BOOST_CHECK_EQUAL( license_record.base_amount.value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( license_record.bonus_percent.value, 50 ); BOOST_CHECK_EQUAL( license_record.frequency_lock.value, 200 ); BOOST_CHECK( license_record.activated_at == issue_time ); BOOST_CHECK( license_record.issued_on_blockchain == issue_time ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( different_license_kinds_unit_test ) { try { VAULT_ACTOR(vault); auto standard_locked = *(_dal.get_license_type("standard_locked")); auto executive_locked = *(_dal.get_license_type("executive_locked")); auto standard = *(_dal.get_license_type("standard")); const share_type bonus_percent = 50; share_type frequency_lock = 20; const time_point_sec issue_time = db.head_block_time(); // Issue standard locked license: do_op(issue_license_operation(get_license_issuer_id(), vault_id, standard_locked.id, bonus_percent, frequency_lock, issue_time)); // This should work, the same license kind: do_op(issue_license_operation(get_license_issuer_id(), vault_id, executive_locked.id, bonus_percent, frequency_lock, issue_time)); // This should fail, different license kind: GRAPHENE_REQUIRE_THROW( do_op(issue_license_operation(get_license_issuer_id(), vault_id, standard.id, bonus_percent, frequency_lock, issue_time)), fc::exception ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_event_index_test ) { try { db.create<upgrade_event_object>([&](upgrade_event_object& lio){}); db.create<upgrade_event_object>([&](upgrade_event_object& lio){}); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( create_upgrade_event_test ) { try { auto license_administrator_id = db.get_global_properties().authorities.license_administrator; auto license_issuer_id = db.get_global_properties().authorities.license_issuer; const auto hbt = db.head_block_time(); const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); const auto get_upgrade_events = [this](vector<upgrade_event_object> &upgrades) { const auto& idx = db.get_index_type<upgrade_event_index>().indices().get<by_id>(); for ( auto it = idx.begin(); it != idx.end(); ++it ) upgrades.emplace_back(*it); }; // This should fail, wrong authority: GRAPHENE_REQUIRE_THROW( do_op(create_upgrade_event_operation(license_issuer_id, hbt, {}, {}, "")), fc::exception ); // Should also fail, event's execution time is not a multiply of maintenance interval: GRAPHENE_REQUIRE_THROW( do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time - fc::seconds(1), {}, {}, "")), fc::exception ); // Should also fail, event is scheduled in the past: GRAPHENE_REQUIRE_THROW( do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time - 2 * gpo.parameters.maintenance_interval, {}, {}, "")), fc::exception ); // Should also fail, subsequent event is scheduled in the past: GRAPHENE_REQUIRE_THROW( do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time, hbt + 60, {dgpo.next_maintenance_time - 2 * gpo.parameters.maintenance_interval}, "")), fc::exception ); // Should also fail, subsequent event is scheduled before the main execution time: GRAPHENE_REQUIRE_THROW( do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval, hbt + 60, {dgpo.next_maintenance_time + gpo.parameters.maintenance_interval}, "")), fc::exception ); // This ought to work, execute time in future, no cutoff, no subsequent events: do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time, {}, {}, "foo")); vector<upgrade_event_object> upgrades; get_upgrade_events(upgrades); FC_ASSERT( upgrades.size() == 1 ); FC_ASSERT( !upgrades[0].executed() ); FC_ASSERT( upgrades[0].comment.compare("foo") == 0 ); FC_ASSERT( upgrades[0].execution_time == dgpo.next_maintenance_time ); FC_ASSERT( *(upgrades[0].cutoff_time) == upgrades[0].execution_time ); // Fails, cannot create upgrade event at the same time as the previously created event: GRAPHENE_REQUIRE_THROW( do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time, {}, {}, "")), fc::exception ); // This ought to work, execute time in future, cutoff in the future, no subsequent events: do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time + gpo.parameters.maintenance_interval, hbt + 60, {}, "bar")); upgrades.clear(); get_upgrade_events(upgrades); FC_ASSERT( upgrades.size() == 2 ); FC_ASSERT( !upgrades[1].executed() ); FC_ASSERT( upgrades[1].comment.compare("bar") == 0 ); FC_ASSERT( upgrades[1].execution_time == dgpo.next_maintenance_time + gpo.parameters.maintenance_interval ); // This ought to work, execute time in future, cutoff in the future, subsequent event in the future: do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval, hbt + 60, {dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval}, "foobar")); upgrades.clear(); get_upgrade_events(upgrades); FC_ASSERT( upgrades.size() == 3 ); FC_ASSERT( !upgrades[2].executed() ); FC_ASSERT( upgrades[2].comment.compare("foobar") == 0 ); FC_ASSERT( upgrades[2].execution_time == dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval ); FC_ASSERT( upgrades[2].subsequent_execution_times.size() == 1 ); FC_ASSERT( upgrades[2].subsequent_execution_times[0] == dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval ); // This fails, second subsequent event is not in the future: GRAPHENE_REQUIRE_THROW( do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval, hbt + 60, {dgpo.next_maintenance_time + 4 * gpo.parameters.maintenance_interval, dgpo.next_maintenance_time - 4 * gpo.parameters.maintenance_interval}, "")), fc::exception ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_event_executed_test ) { try { const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); const auto get_upgrade_events = [this](vector<upgrade_event_object> &upgrades) { const auto& idx = db.get_index_type<upgrade_event_index>().indices().get<by_id>(); for ( auto it = idx.begin(); it != idx.end(); ++it ) upgrades.emplace_back(*it); }; do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, {}, {}, "foo")); // Wait for the next maintenance interval: generate_blocks(dgpo.next_maintenance_time); vector<upgrade_event_object> upgrades; get_upgrade_events(upgrades); FC_ASSERT( upgrades[0].executed() ); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval, {}, {}, "bar")); // Wait for the next maintenance interval: generate_blocks(dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval); upgrades.clear(); get_upgrade_events(upgrades); // At this point, the second upgrade event has been marked as executed: FC_ASSERT( upgrades[1].executed() ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( update_upgrade_event_test ) { try { auto license_administrator_id = db.get_global_properties().authorities.license_administrator; auto license_issuer_id = db.get_global_properties().authorities.license_issuer; const auto hbt = db.head_block_time(); const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); const auto get_upgrade_events = [this](vector<upgrade_event_object> &upgrades) { const auto& idx = db.get_index_type<upgrade_event_index>().indices().get<by_id>(); for ( auto it = idx.begin(); it != idx.end(); ++it ) upgrades.emplace_back(*it); }; do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time, {}, {}, "foo")); vector<upgrade_event_object> upgrades; get_upgrade_events(upgrades); FC_ASSERT( upgrades.size() == 1 ); // Fails because of invalid authority: GRAPHENE_REQUIRE_THROW( do_op(update_upgrade_event_operation(license_issuer_id, upgrades[0].id, hbt, {}, {}, "bar")), fc::exception ); // Fails because execution time is in the past: GRAPHENE_REQUIRE_THROW( do_op(update_upgrade_event_operation(license_administrator_id, upgrades[0].id, dgpo.next_maintenance_time - 4 * gpo.parameters.maintenance_interval, {}, {}, "bar")), fc::exception ); // Fails because cutoff time is in the past: GRAPHENE_REQUIRE_THROW( do_op(update_upgrade_event_operation(license_administrator_id, upgrades[0].id, dgpo.next_maintenance_time, hbt, {}, "bar")), fc::exception ); // Fails because subsequent execution time is in the past: GRAPHENE_REQUIRE_THROW( do_op(update_upgrade_event_operation(license_administrator_id, upgrades[0].id, dgpo.next_maintenance_time, hbt + 60, vector<time_point_sec>{dgpo.next_maintenance_time - 4 * gpo.parameters.maintenance_interval}, "bar")), fc::exception ); // This should succeed: do_op(update_upgrade_event_operation(license_administrator_id, upgrades[0].id, dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval, hbt + 120, vector<time_point_sec>{dgpo.next_maintenance_time + 4 * gpo.parameters.maintenance_interval}, "bar")); upgrades.clear(); get_upgrade_events(upgrades); // There's still one upgrade event: FC_ASSERT( upgrades.size() == 1 ); // But updated accordingly: FC_ASSERT( upgrades[0].execution_time == dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval ); FC_ASSERT( upgrades[0].cutoff_time == hbt + 120 ); FC_ASSERT( upgrades[0].subsequent_execution_times.size() == 1 ); FC_ASSERT( upgrades[0].subsequent_execution_times[0] == dgpo.next_maintenance_time + 4 * gpo.parameters.maintenance_interval ); FC_ASSERT( upgrades[0].comment.compare("bar") == 0 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( delete_upgrade_event_test ) { try { auto license_administrator_id = db.get_global_properties().authorities.license_administrator; auto license_issuer_id = db.get_global_properties().authorities.license_issuer; const auto& dgpo = db.get_dynamic_global_properties(); const auto get_upgrade_events = [this](vector<upgrade_event_object> &upgrades) { const auto& idx = db.get_index_type<upgrade_event_index>().indices().get<by_id>(); for ( auto it = idx.begin(); it != idx.end(); ++it ) upgrades.emplace_back(*it); }; do_op(create_upgrade_event_operation(license_administrator_id, dgpo.next_maintenance_time, {}, {}, "foo")); vector<upgrade_event_object> upgrades; get_upgrade_events(upgrades); FC_ASSERT( upgrades.size() == 1 ); // Fails because of invalid authority: GRAPHENE_REQUIRE_THROW( do_op(delete_upgrade_event_operation(license_issuer_id, upgrades[0].id)), fc::exception ); auto id = upgrades[0].id; ++id; // Fails because of invalid id: GRAPHENE_REQUIRE_THROW( do_op(delete_upgrade_event_operation(license_administrator_id, id)), fc::exception ); do_op(delete_upgrade_event_operation(license_administrator_id, upgrades[0].id)); upgrades.clear(); get_upgrade_events(upgrades); // No active upgrade events at this point: FC_ASSERT( upgrades.empty() ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_cycles_test ) { try { VAULT_ACTOR(foo); VAULT_ACTOR(bar); VAULT_ACTOR(foobar); VAULT_ACTOR(alice); auto standard_locked = *(_dal.get_license_type("standard_locked")); auto executive_locked = *(_dal.get_license_type("executive_locked")); auto vice_president_locked = *(_dal.get_license_type("vice_president_locked")); auto president_locked = *(_dal.get_license_type("president_locked")); const share_type bonus_percent = 0; const share_type frequency_lock = 100; const time_point_sec issue_time = db.head_block_time(); const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); do_op(issue_license_operation(get_license_issuer_id(), foo_id, standard_locked.id, bonus_percent, frequency_lock, issue_time)); do_op(issue_license_operation(get_license_issuer_id(), bar_id, executive_locked.id, bonus_percent, frequency_lock, issue_time)); do_op(issue_license_operation(get_license_issuer_id(), foobar_id, president_locked.id, bonus_percent, frequency_lock, issue_time)); do_op(issue_license_operation(get_license_issuer_id(), alice_id, executive_locked.id, bonus_percent, frequency_lock, issue_time)); do_op(issue_license_operation(get_license_issuer_id(), alice_id, vice_president_locked.id, bonus_percent, frequency_lock, issue_time)); // generate_blocks(db.head_block_time() + fc::hours(24)); // No upgrade happened yet! // BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().total_upgrade_events, 0 ); // Alice is spender: do_op(submit_cycles_to_queue_by_license_operation(alice_id, 1000, executive_locked.id, 100, "TEST")); do_op(submit_cycles_to_queue_by_license_operation(alice_id, 2000, vice_president_locked.id, 100, "TEST")); // FooBar wasted its balance: do_op(submit_cycles_to_queue_by_license_operation(foobar_id, DASCOIN_BASE_PRESIDENT_CYCLES, president_locked.id, 100, "TEST")); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, {}, {}, "foo")); // Wait for the next maintenance interval: generate_blocks(dgpo.next_maintenance_time); // One upgrade event has happened: // BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().total_upgrade_events, 1 ); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 2 * DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, 2 * DASCOIN_BASE_EXECUTIVE_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, DASCOIN_BASE_PRESIDENT_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(alice_id).value, 2 * (DASCOIN_BASE_EXECUTIVE_CYCLES - 1000) + 2 * (DASCOIN_BASE_VICE_PRESIDENT_CYCLES - 2000) ); const auto& license_information_obj = (*alice.license_information)(db); const auto& license_history = license_information_obj.history; const auto& executive_license_record = license_history[0]; const auto& vice_president_license_record = license_history[1]; const uint32_t executive_remaining_cycles = 2 * (DASCOIN_BASE_EXECUTIVE_CYCLES - 1000); const uint32_t vice_president_remaining_cycles = 2 * (DASCOIN_BASE_VICE_PRESIDENT_CYCLES - 2000); BOOST_CHECK_EQUAL( executive_license_record.amount.value, executive_remaining_cycles ); BOOST_CHECK_EQUAL( vice_president_license_record.amount.value, vice_president_remaining_cycles ); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval, {}, {}, "foo")); generate_blocks(dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval); // Second upgrade event has happened: // BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().total_upgrade_events, 2 ); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 2 * DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, 4 * DASCOIN_BASE_EXECUTIVE_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, 3 * DASCOIN_BASE_PRESIDENT_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(alice_id).value, 4 * (DASCOIN_BASE_EXECUTIVE_CYCLES - 1000) + 4 * (DASCOIN_BASE_VICE_PRESIDENT_CYCLES - 2000) ); // Wait for the maintenance interval to trigger: // generate_blocks(db.head_block_time() + fc::days(120)); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval, {}, {}, "foo")); generate_blocks(dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval); // Third upgrade event has happened: // BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().total_upgrade_events, 3 ); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 2 * DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, 4 * DASCOIN_BASE_EXECUTIVE_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, 7 * DASCOIN_BASE_PRESIDENT_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(alice_id).value, 4 * (DASCOIN_BASE_EXECUTIVE_CYCLES - 1000) + 4 * (DASCOIN_BASE_VICE_PRESIDENT_CYCLES - 2000) ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_president_cycles_test ) { try { VAULT_ACTOR(foo); auto president_locked = *(_dal.get_license_type("president_locked")); const share_type bonus_percent = 0; const share_type frequency_lock = 100; const time_point_sec issue_time = db.head_block_time(); const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); do_op(issue_license_operation(get_license_issuer_id(), foo_id, president_locked.id, bonus_percent, frequency_lock, issue_time)); generate_blocks(db.head_block_time() + fc::hours(24)); // Submit 1000 cycles, these cannot be upgraded because they are spent: do_op(submit_cycles_to_queue_by_license_operation(foo_id, 1000, president_locked.id, 100, "TEST")); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, {}, {}, "foo")); // Wait for the next maintenance interval: generate_blocks(dgpo.next_maintenance_time); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 2 * DASCOIN_BASE_PRESIDENT_CYCLES - 1000 ); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval, {}, {}, "foo")); // Submit 2000 cycles: do_op(submit_cycles_to_queue_by_license_operation(foo_id, 2000, president_locked.id, 100, "TEST")); // Wait for the next maintenance interval and subsequent upgrade: generate_blocks(dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 4 * DASCOIN_BASE_PRESIDENT_CYCLES - 3000 ); // Submit 3000 cycles: do_op(submit_cycles_to_queue_by_license_operation(foo_id, 3000, president_locked.id, 100, "TEST")); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval, {}, {}, "foo")); // Wait for the next maintenance interval and subsequent upgrade: generate_blocks(dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 8 * DASCOIN_BASE_PRESIDENT_CYCLES - 6000 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_charter_license_test ) { try { VAULT_ACTOR(foo); VAULT_ACTOR(bar); VAULT_ACTOR(foobar); auto standard_charter = *(_dal.get_license_type("standard_charter")); auto executive_charter = *(_dal.get_license_type("executive_charter")); auto president_charter = *(_dal.get_license_type("president_charter")); const share_type bonus_percent = 0; const share_type frequency_lock = 100; const time_point_sec issue_time = db.head_block_time(); const auto &dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); do_op(issue_license_operation(get_license_issuer_id(), foo_id, standard_charter.id, bonus_percent, frequency_lock, issue_time)); do_op(issue_license_operation(get_license_issuer_id(), foobar_id, executive_charter.id, bonus_percent, frequency_lock, issue_time)); do_op(issue_license_operation(get_license_issuer_id(), bar_id, president_charter.id, bonus_percent, frequency_lock, issue_time)); generate_blocks(db.head_block_time() + fc::hours(24)); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, {}, {}, "foo")); // Wait for the next maintenance interval: generate_blocks(dgpo.next_maintenance_time); auto result_vec = *_dal.get_queue_submissions_with_pos(foo_id).result; BOOST_CHECK_EQUAL( result_vec.size(), 2 ); auto rqo = result_vec[1].submission; BOOST_CHECK_EQUAL( rqo.origin, "reserve_cycles" ); BOOST_CHECK_EQUAL( rqo.comment, "Licence Standard Upgrade 1/1" ); BOOST_CHECK_EQUAL( rqo.amount.value, DASCOIN_BASE_STANDARD_CYCLES ); auto result_vec2 = *_dal.get_queue_submissions_with_pos(bar_id).result; BOOST_CHECK_EQUAL( result_vec2.size(), 2 ); auto rqo2 = result_vec2[1].submission; BOOST_CHECK_EQUAL( rqo2.origin, "reserve_cycles" ); BOOST_CHECK_EQUAL( rqo2.comment, "Licence President Upgrade 1/3" ); BOOST_CHECK_EQUAL( rqo2.amount.value, DASCOIN_BASE_PRESIDENT_CYCLES ); const auto& license_information_obj = (*bar.license_information)(db); const auto& license_history = license_information_obj.history; BOOST_CHECK_EQUAL( license_history.size(), 1 ); const auto& license_record = license_history[0]; auto res = _dal.get_vault_info(bar_id); BOOST_CHECK_EQUAL( license_record.amount.value, DASCOIN_BASE_PRESIDENT_CYCLES ); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval, {}, {}, "foo")); // Wait for the next maintenance interval: generate_blocks(dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval); auto result_vec3 = *_dal.get_queue_submissions_with_pos(foobar_id).result; BOOST_CHECK_EQUAL( result_vec3.size(), 3 ); auto rqo3 = result_vec3[1].submission; BOOST_CHECK_EQUAL( rqo3.origin, "reserve_cycles" ); BOOST_CHECK_EQUAL( rqo3.comment, "Licence Executive Upgrade 1/2" ); BOOST_CHECK_EQUAL( rqo3.amount.value, DASCOIN_BASE_EXECUTIVE_CYCLES ); auto rqo4 = result_vec3[2].submission; BOOST_CHECK_EQUAL( rqo4.origin, "reserve_cycles" ); BOOST_CHECK_EQUAL( rqo4.comment, "Licence Executive Upgrade 2/2" ); BOOST_CHECK_EQUAL( rqo4.amount.value, 2 * DASCOIN_BASE_EXECUTIVE_CYCLES ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_not_executed_test ) { try { VAULT_ACTOR(foo); auto standard_locked = *(_dal.get_license_type("standard_locked")); const share_type bonus_percent = 0; const share_type frequency_lock = 100; const time_point_sec activated_time = db.head_block_time(); const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); do_op(issue_license_operation(get_license_issuer_id(), foo_id, standard_locked.id, bonus_percent, frequency_lock, dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval)); // This will not upgrade foo, because the execution time is before license's activation time: do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + gpo.parameters.maintenance_interval, {}, {}, "upgrade1")); // Will not upgrade foo, because cutoff time is before license's activation time: do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval, activated_time + 60, {}, "upgrade2")); // Will not upgrade foo even in subsequent executions: do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval, {activated_time + 60}, {{dgpo.next_maintenance_time + 4 * gpo.parameters.maintenance_interval}}, "upgrade3")); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 4 * gpo.parameters.maintenance_interval, activated_time - 60, {}, "foo")); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time + 5 * gpo.parameters.maintenance_interval, activated_time - 60, {}, "foo")); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_executed_test ) { try { VAULT_ACTOR(foo); VAULT_ACTOR(bar); VAULT_ACTOR(foobar); VAULT_ACTOR(barfoo); VAULT_ACTOR(foofoobar); VAULT_ACTOR(barbarfoo); auto standard_locked = *(_dal.get_license_type("standard_locked")); auto manager_locked = *(_dal.get_license_type("manager_locked")); auto pro_locked = *(_dal.get_license_type("pro_locked")); auto executive_locked = *(_dal.get_license_type("executive_locked")); auto vp_locked = *(_dal.get_license_type("vice_president_locked")); auto p_locked = *(_dal.get_license_type("president_locked")); const share_type bonus_percent = 0; const share_type frequency_lock = 100; const time_point_sec activated_time = db.head_block_time(); const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); // License activated before upgrade event, so it should be upgraded: do_op(issue_license_operation(get_license_issuer_id(), foo_id, standard_locked.id, bonus_percent, frequency_lock, activated_time)); // License activated before cutoff time, so it should be upgraded too: do_op(issue_license_operation(get_license_issuer_id(), bar_id, manager_locked.id, bonus_percent, frequency_lock, activated_time + fc::hours(26))); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, activated_time + fc::hours(72), {{dgpo.next_maintenance_time + 4 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 7 * gpo.parameters.maintenance_interval}}, "foo_upgrade")); // Issue 200 cycles to foo, those should not be upgraded: do_op(issue_cycles_to_license_operation(get_cycle_issuer_id(), foo_id, standard_locked.id, 200, "foo", "bar")); generate_blocks(dgpo.next_maintenance_time); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 2 * DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, 2 * DASCOIN_BASE_MANAGER_CYCLES ); // License created after the first execution of upgrade event, but activated before cutoff time, so it should be upgraded too: do_op(issue_license_operation(get_license_issuer_id(), foobar_id, pro_locked.id, bonus_percent, frequency_lock, activated_time + fc::hours(28))); generate_blocks(dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval); // Balance for the first two should remain the same: BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 2 * DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, 2 * DASCOIN_BASE_MANAGER_CYCLES ); // Upgrade is executed for foobar: BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, 2 * DASCOIN_BASE_PRO_CYCLES ); // License created after cutoff time, but activated before upgrade execution time, so it should be upgraded in encore event: do_op(issue_license_operation(get_license_issuer_id(), barfoo_id, executive_locked.id, bonus_percent, frequency_lock, activated_time)); // License created after cutoff time, but activated before cutoff time, so it should be upgraded in encore event: do_op(issue_license_operation(get_license_issuer_id(), foofoobar_id, vp_locked.id, bonus_percent, frequency_lock, activated_time + fc::hours(48))); generate_blocks(dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval); // Balance for the first three should remain the same: BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, 2 * DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, 2 * DASCOIN_BASE_MANAGER_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, 2 * DASCOIN_BASE_PRO_CYCLES ); // barfoo should be upgraded now: BOOST_CHECK_EQUAL( get_cycle_balance(barfoo_id).value, 2 * DASCOIN_BASE_EXECUTIVE_CYCLES ); // foofoobar also: BOOST_CHECK_EQUAL( get_cycle_balance(foofoobar_id).value, 2 * DASCOIN_BASE_VICE_PRESIDENT_CYCLES ); // License activated after cutoff time, should not be upgraded even in encore: do_op(issue_license_operation(get_license_issuer_id(), barbarfoo_id, p_locked.id, bonus_percent, frequency_lock, activated_time + fc::hours(78))); generate_blocks(db.head_block_time() + fc::hours(25)); // Cycles remain: BOOST_CHECK_EQUAL( get_cycle_balance(barbarfoo_id).value, DASCOIN_BASE_PRESIDENT_CYCLES ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( update_license_unit_test ) { try { VAULT_ACTOR(vault); auto standard_locked = *(_dal.get_license_type("standard_locked")); const share_type bonus_percent = 50; share_type frequency_lock = 20; const time_point_sec issue_time = db.head_block_time(); const uint32_t amount_after = DASCOIN_BASE_STANDARD_CYCLES + (55 * DASCOIN_BASE_STANDARD_CYCLES) / 100; // Issue standard locked license: do_op(issue_license_operation(get_license_issuer_id(), vault_id, standard_locked.id, bonus_percent, frequency_lock, issue_time)); do_op(update_license_operation(get_license_issuer_id(), vault_id, standard_locked.id, 55, 10, issue_time + 3600)); const auto& license_information_obj = (*vault.license_information)(db); BOOST_CHECK( license_information_obj.account == vault_id ); const auto& license_history = license_information_obj.history; BOOST_CHECK_EQUAL( license_history.size(), 1 ); const auto& license_record = license_history[0]; auto res = _dal.get_vault_info(vault_id); BOOST_CHECK( license_record.license == standard_locked.id ); BOOST_CHECK_EQUAL( license_record.amount.value, amount_after ); BOOST_CHECK_EQUAL( license_record.base_amount.value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( license_record.bonus_percent.value, 55 ); BOOST_CHECK_EQUAL( license_record.frequency_lock.value, 10 ); BOOST_CHECK( license_record.activated_at == issue_time + 3600 ); BOOST_CHECK_EQUAL( res->free_cycle_balance.value, amount_after ); auto executive_locked = *(_dal.get_license_type("executive_locked")); // This ought to fail, this license has not been issued to the vault: GRAPHENE_REQUIRE_THROW( do_op(update_license_operation(get_license_issuer_id(), vault_id, executive_locked.id, 40, 10, issue_time + 3600)), fc::exception ); // This ought to fail, frequency lock cannot be zero: GRAPHENE_REQUIRE_THROW( do_op(update_license_operation(get_license_issuer_id(), vault_id, standard_locked.id, 40, 0, issue_time + 3600)), fc::exception ); // This ought to fail, bonus percentage cannot be decreased: GRAPHENE_REQUIRE_THROW( do_op(update_license_operation(get_license_issuer_id(), vault_id, standard_locked.id, 30, 10, issue_time + 3600)), fc::exception ); // Now submit 1000 cycles: do_op(submit_cycles_to_queue_by_license_operation(vault_id, 1000, standard_locked.id, 10, "TEST")); do_op(update_license_operation(get_license_issuer_id(), vault_id, standard_locked.id, 60, 20, {})); auto res2 = _dal.get_vault_info(vault_id); // Now we should have 55 cycles extra, but 1000 is spent: BOOST_CHECK_EQUAL( res2->free_cycle_balance.value, amount_after + 55 - 1000 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( utility_license_unit_test ) { try { VAULT_ACTOR(vault); auto utility = *(_dal.get_license_type("standard_utility")); const share_type bonus_percent = 50; share_type frequency_lock = 0; const time_point_sec issue_time = db.head_block_time(); const uint32_t amount = DASCOIN_BASE_STANDARD_CYCLES; // This will fail, frequency cannot be zero: GRAPHENE_REQUIRE_THROW( do_op(issue_license_operation(get_license_issuer_id(), vault_id, utility.id, bonus_percent, frequency_lock, issue_time)), fc::exception ); frequency_lock = 200; // Frequency is now valid, this ought to work: do_op(issue_license_operation(get_license_issuer_id(), vault_id, utility.id, bonus_percent, frequency_lock, issue_time)); BOOST_CHECK( vault.license_information.valid() ); const auto& license_information_obj = (*vault.license_information)(db); BOOST_CHECK( license_information_obj.account == vault_id ); const auto& license_history = license_information_obj.history; BOOST_CHECK_EQUAL( license_history.size(), 1 ); const auto& license_record = license_history[0]; BOOST_CHECK( license_record.license == utility.id ); BOOST_CHECK_EQUAL( license_record.amount.value, amount ); BOOST_CHECK_EQUAL( license_record.base_amount.value, amount ); BOOST_CHECK_EQUAL( license_record.bonus_percent.value, 50 ); BOOST_CHECK_EQUAL( license_record.frequency_lock.value, 200 ); BOOST_CHECK( license_record.activated_at == issue_time ); BOOST_CHECK( license_record.issued_on_blockchain == issue_time ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_executed_with_ultility_licences_test ) { try { VAULT_ACTOR(foo); VAULT_ACTOR(bar); VAULT_ACTOR(foobar); VAULT_ACTOR(barfoo); VAULT_ACTOR(foofoobar); VAULT_ACTOR(barbarfoo); auto standard_utility = *(_dal.get_license_type("standard_utility")); auto manager_utility = *(_dal.get_license_type("manager_utility")); auto pro_utility = *(_dal.get_license_type("pro_utility")); auto executive_utility = *(_dal.get_license_type("executive_utility")); auto vp_utility = *(_dal.get_license_type("vice_president_utility")); auto p_utility = *(_dal.get_license_type("president_utility")); const share_type bonus_percent = 10; const share_type frequency_lock = 100; const time_point_sec activated_time = db.head_block_time(); const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); // License activated before upgrade event, so it should be upgraded: do_op(issue_license_operation(get_license_issuer_id(), foo_id, standard_utility.id, bonus_percent, frequency_lock, activated_time)); // License activated before cutoff time, so it should be upgraded too: do_op(issue_license_operation(get_license_issuer_id(), bar_id, manager_utility.id, bonus_percent, frequency_lock, activated_time + fc::hours(26))); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, activated_time + fc::hours(72), {{dgpo.next_maintenance_time + 4 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 7 * gpo.parameters.maintenance_interval}}, "foo_upgrade")); // Issue 200 cycles to foo, those should not be upgraded: do_op(issue_cycles_to_license_operation(get_cycle_issuer_id(), foo_id, standard_utility.id, 200, "foo", "bar")); generate_blocks(dgpo.next_maintenance_time); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, DASCOIN_BASE_MANAGER_CYCLES ); // License created after the first execution of upgrade event, but activated before cutoff time, so it should be upgraded too: do_op(issue_license_operation(get_license_issuer_id(), foobar_id, pro_utility.id, bonus_percent, frequency_lock, activated_time + fc::hours(28))); generate_blocks(dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval); // Balance for the first two should remain the same: BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, DASCOIN_BASE_MANAGER_CYCLES ); // Upgrade is executed for foobar: BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, DASCOIN_BASE_PRO_CYCLES ); // License created after cutoff time, but activated before upgrade execution time, so it should be upgraded in encore event: do_op(issue_license_operation(get_license_issuer_id(), barfoo_id, executive_utility.id, bonus_percent, frequency_lock, activated_time)); // License created after cutoff time, but activated before cutoff time, so it should be upgraded in encore event: do_op(issue_license_operation(get_license_issuer_id(), foofoobar_id, vp_utility.id, bonus_percent, frequency_lock, activated_time + fc::hours(48))); generate_blocks(dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval); // Balance for the first three should remain the same: BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, DASCOIN_BASE_MANAGER_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, DASCOIN_BASE_PRO_CYCLES ); // barfoo should be upgraded now: BOOST_CHECK_EQUAL( get_cycle_balance(barfoo_id).value, DASCOIN_BASE_EXECUTIVE_CYCLES_NEW_VALUE ); // foofoobar also: BOOST_CHECK_EQUAL( get_cycle_balance(foofoobar_id).value, DASCOIN_BASE_VICE_PRESIDENT_CYCLES_NEW_VALUE ); // License activated after cutoff time, should not be upgraded even in encore: do_op(issue_license_operation(get_license_issuer_id(), barbarfoo_id, p_utility.id, bonus_percent, frequency_lock, activated_time + fc::hours(78))); generate_blocks(db.head_block_time() + fc::hours(25)); // Cycles remain: BOOST_CHECK_EQUAL( get_cycle_balance(barbarfoo_id).value, DASCOIN_BASE_PRESIDENT_CYCLES ); auto queue = _dal.get_reward_queue(); BOOST_CHECK_EQUAL(queue[0].amount.value, bonus_percent.value * DASCOIN_BASE_STANDARD_CYCLES / 100); BOOST_CHECK_EQUAL(queue[1].amount.value, bonus_percent.value * DASCOIN_BASE_MANAGER_CYCLES / 100); BOOST_CHECK_EQUAL(queue[2].amount.value, DASCOIN_BASE_MANAGER_CYCLES ); BOOST_CHECK_EQUAL(queue[3].amount.value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL(queue[4].amount.value, bonus_percent.value * DASCOIN_BASE_PRO_CYCLES / 100); BOOST_CHECK_EQUAL(queue[5].amount.value, DASCOIN_BASE_PRO_CYCLES); BOOST_CHECK_EQUAL(queue[6].amount.value, bonus_percent.value * DASCOIN_BASE_EXECUTIVE_CYCLES_NEW_VALUE / 100); BOOST_CHECK_EQUAL(queue[7].amount.value, bonus_percent.value * DASCOIN_BASE_VICE_PRESIDENT_CYCLES_NEW_VALUE / 100); BOOST_CHECK_EQUAL(queue[8].amount.value, DASCOIN_BASE_EXECUTIVE_CYCLES_NEW_VALUE ); BOOST_CHECK_EQUAL(queue[9].amount.value, DASCOIN_BASE_VICE_PRESIDENT_CYCLES_NEW_VALUE ); BOOST_CHECK_EQUAL(queue[10].amount.value, bonus_percent.value * DASCOIN_BASE_PRESIDENT_CYCLES / 100 ); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, db.head_block_time() + fc::hours(72), {{dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval}}, "foo1_upgrade")); generate_blocks(dgpo.next_maintenance_time); auto queue1 = _dal.get_reward_queue(); BOOST_CHECK_EQUAL(queue1[11].amount.value, DASCOIN_BASE_MANAGER_CYCLES * 2); BOOST_CHECK_EQUAL(queue1[12].amount.value, DASCOIN_BASE_PRESIDENT_CYCLES); BOOST_CHECK_EQUAL(queue1[13].amount.value, 2 * DASCOIN_BASE_EXECUTIVE_CYCLES_NEW_VALUE); generate_blocks(dgpo.next_maintenance_time + 7 * gpo.parameters.maintenance_interval); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, db.head_block_time() + fc::hours(72), {{dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval}}, "foo2_upgrade")); generate_blocks(dgpo.next_maintenance_time); auto queue2 = _dal.get_reward_queue(); BOOST_CHECK_EQUAL(queue2[14].amount.value, 2 * DASCOIN_BASE_STANDARD_CYCLES); generate_blocks(dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, db.head_block_time() + fc::hours(72), {{dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval}}, "foo3_upgrae")); generate_blocks(dgpo.next_maintenance_time); auto queue3 = _dal.get_reward_queue(); BOOST_CHECK_EQUAL(queue3[15].amount.value, 2 * DASCOIN_BASE_PRO_CYCLES); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( submit_cycles_to_queue_from_charter_license_test ) { try { VAULT_ACTOR(foo); auto standard_charter = *(_dal.get_license_type("standard_charter")); const share_type bonus_percent = 0; const share_type frequency_lock = 100; const time_point_sec issue_time = db.head_block_time(); do_op(issue_license_operation(get_license_issuer_id(), foo_id, standard_charter.id, bonus_percent, frequency_lock, issue_time)); // This fails - cannot submit cycles from a charter license: GRAPHENE_REQUIRE_THROW( do_op(submit_cycles_to_queue_by_license_operation(foo_id, 1000, standard_charter.id, 100, "TEST")), fc::exception ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_executed_with_package_licences_test ) { try { VAULT_ACTOR(foo); VAULT_ACTOR(bar); VAULT_ACTOR(foobar); VAULT_ACTOR(barfoo); VAULT_ACTOR(foofoobar); VAULT_ACTOR(barbarfoo); auto starter_package = *(_dal.get_license_type("starter_package")); auto basic_package = *(_dal.get_license_type("basic_package")); auto power_package = *(_dal.get_license_type("power_package")); auto prime_package = *(_dal.get_license_type("prime_package")); auto superior_package = *(_dal.get_license_type("superior_package")); auto ultimate_package = *(_dal.get_license_type("ultimate_package")); const share_type bonus_percent = 10; const share_type frequency_lock = 100; const time_point_sec activated_time = db.head_block_time(); const auto& dgpo = db.get_dynamic_global_properties(); const auto& gpo = db.get_global_properties(); // License activated before upgrade event, so it should be upgraded: do_op(issue_license_operation(get_license_issuer_id(), foo_id, starter_package.id, bonus_percent, frequency_lock, activated_time)); // License activated before cutoff time, so it should be upgraded too: do_op(issue_license_operation(get_license_issuer_id(), bar_id, basic_package.id, bonus_percent, frequency_lock, activated_time + fc::hours(26))); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, activated_time + fc::hours(72), {{dgpo.next_maintenance_time + 4 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 7 * gpo.parameters.maintenance_interval}}, "foo_upgrade")); // Issue 200 cycles to foo, those should not be upgraded: do_op(issue_cycles_to_license_operation(get_cycle_issuer_id(), foo_id, starter_package.id, 200, "foo", "bar")); generate_blocks(dgpo.next_maintenance_time); BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, DASCOIN_BASE_MANAGER_CYCLES ); // License created after the first execution of upgrade event, but activated before cutoff time, so it should be upgraded too: do_op(issue_license_operation(get_license_issuer_id(), foobar_id, power_package.id, bonus_percent, frequency_lock, activated_time + fc::hours(28))); generate_blocks(dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval); // Balance for the first two should remain the same: BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, DASCOIN_BASE_MANAGER_CYCLES ); // Upgrade is executed for foobar: BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, DASCOIN_BASE_PRO_CYCLES ); // License created after cutoff time, but activated before upgrade execution time, so it should be upgraded in encore event: do_op(issue_license_operation(get_license_issuer_id(), barfoo_id, prime_package.id, bonus_percent, frequency_lock, activated_time)); // License created after cutoff time, but activated before cutoff time, so it should be upgraded in encore event: do_op(issue_license_operation(get_license_issuer_id(), foofoobar_id, superior_package.id, bonus_percent, frequency_lock, activated_time + fc::hours(48))); generate_blocks(dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval); // Balance for the first three should remain the same: BOOST_CHECK_EQUAL( get_cycle_balance(foo_id).value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(bar_id).value, DASCOIN_BASE_MANAGER_CYCLES ); BOOST_CHECK_EQUAL( get_cycle_balance(foobar_id).value, DASCOIN_BASE_PRO_CYCLES ); // barfoo should be upgraded now: BOOST_CHECK_EQUAL( get_cycle_balance(barfoo_id).value, DASCOIN_BASE_EXECUTIVE_CYCLES_NEW_VALUE ); // foofoobar also: BOOST_CHECK_EQUAL( get_cycle_balance(foofoobar_id).value, DASCOIN_BASE_VICE_PRESIDENT_CYCLES_NEW_VALUE ); // License activated after cutoff time, should not be upgraded even in encore: do_op(issue_license_operation(get_license_issuer_id(), barbarfoo_id, ultimate_package.id, bonus_percent, frequency_lock, activated_time + fc::hours(78))); generate_blocks(db.head_block_time() + fc::hours(25)); // Cycles remain: BOOST_CHECK_EQUAL( get_cycle_balance(barbarfoo_id).value, DASCOIN_BASE_PRESIDENT_CYCLES ); auto queue = _dal.get_reward_queue(); BOOST_CHECK_EQUAL(queue[0].amount.value, bonus_percent.value * DASCOIN_BASE_STANDARD_CYCLES / 100); BOOST_CHECK_EQUAL(queue[1].amount.value, bonus_percent.value * DASCOIN_BASE_MANAGER_CYCLES / 100); BOOST_CHECK_EQUAL(queue[2].amount.value, DASCOIN_BASE_MANAGER_CYCLES ); BOOST_CHECK_EQUAL(queue[3].amount.value, DASCOIN_BASE_STANDARD_CYCLES ); BOOST_CHECK_EQUAL(queue[4].amount.value, bonus_percent.value * DASCOIN_BASE_PRO_CYCLES / 100); BOOST_CHECK_EQUAL(queue[5].amount.value, DASCOIN_BASE_PRO_CYCLES); BOOST_CHECK_EQUAL(queue[6].amount.value, bonus_percent.value * DASCOIN_BASE_EXECUTIVE_CYCLES_NEW_VALUE / 100); BOOST_CHECK_EQUAL(queue[7].amount.value, bonus_percent.value * DASCOIN_BASE_VICE_PRESIDENT_CYCLES_NEW_VALUE / 100); BOOST_CHECK_EQUAL(queue[8].amount.value, DASCOIN_BASE_EXECUTIVE_CYCLES_NEW_VALUE ); BOOST_CHECK_EQUAL(queue[9].amount.value, DASCOIN_BASE_VICE_PRESIDENT_CYCLES_NEW_VALUE ); BOOST_CHECK_EQUAL(queue[10].amount.value, bonus_percent.value * DASCOIN_BASE_PRESIDENT_CYCLES / 100 ); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, db.head_block_time() + fc::hours(72), {{dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval}}, "foo1_upgrade")); generate_blocks(dgpo.next_maintenance_time); auto queue1 = _dal.get_reward_queue(); BOOST_CHECK_EQUAL(queue1[11].amount.value, DASCOIN_BASE_MANAGER_CYCLES * 2); BOOST_CHECK_EQUAL(queue1[12].amount.value, DASCOIN_BASE_PRESIDENT_CYCLES); BOOST_CHECK_EQUAL(queue1[13].amount.value, 2 * DASCOIN_BASE_EXECUTIVE_CYCLES_NEW_VALUE); generate_blocks(dgpo.next_maintenance_time + 7 * gpo.parameters.maintenance_interval); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, db.head_block_time() + fc::hours(72), {{dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval}}, "foo2_upgrade")); generate_blocks(dgpo.next_maintenance_time); auto queue2 = _dal.get_reward_queue(); BOOST_CHECK_EQUAL(queue2[14].amount.value, 2 * DASCOIN_BASE_STANDARD_CYCLES); generate_blocks(dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval); do_op(create_upgrade_event_operation(get_license_administrator_id(), dgpo.next_maintenance_time, db.head_block_time() + fc::hours(72), {{dgpo.next_maintenance_time + 2 * gpo.parameters.maintenance_interval}, {dgpo.next_maintenance_time + 3 * gpo.parameters.maintenance_interval}}, "foo3_upgrae")); generate_blocks(dgpo.next_maintenance_time); auto queue3 = _dal.get_reward_queue(); BOOST_CHECK_EQUAL(queue3[15].amount.value, 2 * DASCOIN_BASE_PRO_CYCLES); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END() /*BOOST_FIXTURE_TEST_SUITE( dascoin_tests, database_fixture ) BOOST_FIXTURE_TEST_SUITE( license_tests, database_fixture ) BOOST_AUTO_TEST_CASE( issue_single_license_test ) { try { VAULT_ACTOR(vault); const auto pro_id = get_license_type("pro").id; issue_license_to_vault_account(vault_id, pro_id, 0, 0); generate_blocks_until_license_approved(); BOOST_CHECK( vault.license_info.max_license() == pro_id ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( issue_license_with_bonus_cycles ) { try { const frequency_type frequency_lock = 200; VAULT_ACTOR(v100); VAULT_ACTOR(v150); VAULT_ACTOR(v50); VAULT_ACTOR(vzero); VAULT_ACTOR(vneg) vector<license_request_object> requests; const auto& get_pending_request = [&](const account_object& account) -> const license_request_object& { return (*account.license_info.pending).request(db); }; issue_license_to_vault_account(v100, "standard_charter", 0, frequency_lock); issue_license_to_vault_account(v150, "standard_charter", 50, frequency_lock); issue_license_to_vault_account(v50, "standard_charter", -50, frequency_lock); GRAPHENE_CHECK_THROW( issue_license_to_vault_account(vzero, "standard_charter", -100, frequency_lock), fc::exception ); GRAPHENE_CHECK_THROW( issue_license_to_vault_account(vneg, "standard_charter", -200, frequency_lock), fc::exception ); BOOST_CHECK_EQUAL( get_pending_request(v100).amount.value, 100 ); BOOST_CHECK_EQUAL( get_pending_request(v150).amount.value, 150 ); BOOST_CHECK_EQUAL( get_pending_request(v50).amount.value, 50 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( license_type_integrity_test ) { try { // TODO: test for every type of license there is. auto lic_obj = get_license_type("standard"); BOOST_CHECK_EQUAL( lic_obj.name, "standard" ); BOOST_CHECK_EQUAL( lic_obj.amount.value, 100 ); BOOST_CHECK_EQUAL( lic_obj.kind, license_kind::regular ); BOOST_CHECK( lic_obj.balance_upgrade == upgrade_type({2}) ); BOOST_CHECK( lic_obj.requeue_upgrade == upgrade_type() ); BOOST_CHECK( lic_obj.return_upgrade == upgrade_type() ); lic_obj = get_license_type("standard_charter"); BOOST_CHECK_EQUAL( lic_obj.name, "standard_charter" ); BOOST_CHECK_EQUAL( lic_obj.amount.value, 100 ); BOOST_CHECK_EQUAL( lic_obj.kind, license_kind::chartered ); BOOST_CHECK( lic_obj.balance_upgrade == upgrade_type() ); BOOST_CHECK( lic_obj.requeue_upgrade == upgrade_type({1}) ); BOOST_CHECK( lic_obj.return_upgrade == upgrade_type() ); lic_obj = get_license_type("standard-promo"); BOOST_CHECK_EQUAL( lic_obj.name, "standard-promo" ); BOOST_CHECK_EQUAL( lic_obj.amount.value, 100 ); BOOST_CHECK_EQUAL( lic_obj.kind, license_kind::promo ); BOOST_CHECK( lic_obj.balance_upgrade == upgrade_type() ); BOOST_CHECK( lic_obj.requeue_upgrade == upgrade_type() ); BOOST_CHECK( lic_obj.return_upgrade == upgrade_type({1}) ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( check_issue_frequency_lock_not_zero ) { try { VAULT_ACTOR(vault); // Regular license can have a frequency lock of 0: issue_license_to_vault_account(vault_id, get_license_type("pro").id, 0, 0); // Charter license CANNOT have a frequency lock of 0: GRAPHENE_REQUIRE_THROW( issue_license_to_vault_account(vault_id, get_license_type("pro_charter").id, 0, 0), fc::exception ); // Promo license CANNOT have a frequency lock of 0: GRAPHENE_REQUIRE_THROW( issue_license_to_vault_account(vault_id, get_license_type("pro-promo").id, 0, 0), fc::exception ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_type_test ) { try { upgrade_type test_pres_charter_upgrade({1,2,2}); share_type x = 1000; // 1000 x1 = 1000 x = test_pres_charter_upgrade(x); BOOST_CHECK_EQUAL( x.value, 1000 ); // 1000 x2 = 2000 x = test_pres_charter_upgrade(x); BOOST_CHECK_EQUAL( x.value, 2000 ); // 2000 x2 = 4000 x = test_pres_charter_upgrade(x); BOOST_CHECK_EQUAL( x.value, 4000 ); // After this it stays the same: x = test_pres_charter_upgrade(x); BOOST_CHECK_EQUAL( x.value, 4000 ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( issue_license_test ) { try { ACTOR(wallet); VAULT_ACTOR(stan); VAULT_ACTOR(allguy); const auto& check_pending = [&](const account_object& acc, const string& lic_name) { auto lic = get_license_type(lic_name); auto pending = *(acc.license_info.pending); BOOST_CHECK( lic.id == pending.license ); }; // Rejected: cannot issue to a vault account. GRAPHENE_REQUIRE_THROW( issue_license_to_vault_account(wallet, "standard"), fc::exception ); // Issue standard license to our old pal Stan, and Allguy: issue_license_to_vault_account(stan, "standard"); check_pending(stan, "standard"); issue_license_to_vault_account(allguy, "standard"); check_pending(allguy, "standard"); // Try and issue another license to stan: GRAPHENE_REQUIRE_THROW( issue_license_to_vault_account(stan, "manager_charter", 0, 200), fc::exception ); generate_blocks_until_license_approved(); // Check if Stan has 100 cycles: BOOST_CHECK_EQUAL( get_cycle_balance(stan_id).value, 100 ); // Now we try the Allguy: // Allguy should get all the licenses in order: license_information lic_info; issue_license_to_vault_account(allguy, "manager"); generate_blocks_until_license_approved(); BOOST_CHECK_EQUAL( get_cycle_balance(allguy_id).value, 600 ); lic_info = allguy_id(db).license_info; BOOST_CHECK( lic_info.balance_upgrade == upgrade_type({2}) ); issue_license_to_vault_account(allguy, "pro"); generate_blocks_until_license_approved(); BOOST_CHECK_EQUAL( get_cycle_balance(allguy_id).value, 2600 ); lic_info = allguy_id(db).license_info; BOOST_CHECK( lic_info.balance_upgrade == upgrade_type({2}) ); issue_license_to_vault_account(allguy, "executive"); generate_blocks_until_license_approved(); BOOST_CHECK_EQUAL( get_cycle_balance(allguy_id).value, 7600 ); lic_info = allguy_id(db).license_info; BOOST_CHECK( lic_info.balance_upgrade == upgrade_type({2,2}) ); issue_license_to_vault_account(allguy, "president"); generate_blocks_until_license_approved(); BOOST_CHECK_EQUAL( get_cycle_balance(allguy_id).value, 32600 ); lic_info = allguy_id(db).license_info; BOOST_CHECK( lic_info.balance_upgrade == upgrade_type({2,2,2}) ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( upgrade_cycles_test ) { try { VAULT_ACTOR(stan); generate_block(); VAULT_ACTOR(richguy); generate_block(); ACTOR(wallet); generate_block(); issue_license_to_vault_account(stan, "standard"); // 100 cycles. issue_license_to_vault_account(richguy, "president"); // 25000 cycles. adjust_cycles(wallet_id, 2000); // Wallet has no license, but has floating cycles. // Wait for time to elapse: // TODO: fetch the time parameter. generate_blocks(db.head_block_time() + fc::hours(24)); // Check balances on accounts: BOOST_CHECK_EQUAL( get_cycle_balance(stan_id).value, 100 ); // 100 BOOST_CHECK_EQUAL( get_cycle_balance(richguy_id).value, 25000 ); // 25000 BOOST_CHECK_EQUAL( get_cycle_balance(wallet_id).value, 2000 ); // 2000 (no license) // No upgrade happened yet! BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().total_upgrade_events, 0 ); // Wait for the maintenace interval to trigger: generate_blocks(db.head_block_time() + fc::days(120)); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); // Just in case, on the maintenance int. // One upgrade event has happened: BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().total_upgrade_events, 1 ); BOOST_CHECK_EQUAL( get_cycle_balance(stan_id).value, 200 ); // 100 -> 200 BOOST_CHECK_EQUAL( get_cycle_balance(richguy_id).value, 50000 ); // 25000 -> 50000 BOOST_CHECK_EQUAL( get_cycle_balance(wallet_id).value, 2000 ); // Wallet should get no increase. // Wait for the maintenace interval to trigger: generate_blocks(db.head_block_time() + fc::days(120)); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); // Second upgrade event has happened: BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().total_upgrade_events, 2 ); BOOST_CHECK_EQUAL( get_cycle_balance(stan_id).value, 200 ); BOOST_CHECK_EQUAL( get_cycle_balance(richguy_id).value, 100000 ); // 50000 -> 100000 BOOST_CHECK_EQUAL( get_cycle_balance(wallet_id).value, 2000 ); // No increase. // Wait for the maintenace interval to trigger: generate_blocks(db.head_block_time() + fc::days(120)); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); // Second upgrade event has happened: BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().total_upgrade_events, 3 ); BOOST_CHECK_EQUAL( get_cycle_balance(stan_id).value, 200 ); BOOST_CHECK_EQUAL( get_cycle_balance(richguy_id).value, 200000 ); // 100000 -> 200000 BOOST_CHECK_EQUAL( get_cycle_balance(wallet_id).value, 2000 ); // No increase. } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()*/
47.489279
182
0.718017
powerchain-ltd
75c102afad795ec901a63a091ad77763c4f54e5a
1,121
cpp
C++
Graphics/FacesDescription.cpp
SamirAroudj/BaseProject
50ede52bd6fa7b20d6ecb8a11bc1193ef841d91d
[ "BSD-3-Clause" ]
null
null
null
Graphics/FacesDescription.cpp
SamirAroudj/BaseProject
50ede52bd6fa7b20d6ecb8a11bc1193ef841d91d
[ "BSD-3-Clause" ]
1
2019-06-19T15:55:25.000Z
2019-06-27T07:47:27.000Z
Graphics/FacesDescription.cpp
SamirAroudj/BaseProject
50ede52bd6fa7b20d6ecb8a11bc1193ef841d91d
[ "BSD-3-Clause" ]
1
2019-07-07T04:37:56.000Z
2019-07-07T04:37:56.000Z
/* * Copyright (C) 2017 by Author: Aroudj, Samir, born in Suhl, Thueringen, Germany * All rights reserved. * * This software may be modified and distributed under the terms * of the BSD 3-Clause license. See the License.txt file for details. */ #include <cassert> #include "Graphics/FacesDescription.h" #include "Platform/FailureHandling/GraphicsException.h" using namespace std; using namespace FailureHandling; using namespace Graphics; const char *const FacesDescription::SEMANTIC_IDENTIFIERS[FacesDescription::SEMANTICS_COUNT] = { "vertex_indices", "flags", "unknown", "invalid" }; FacesDescription::FacesDescription(const Encoding encoding, const uint32 faceCount) : ElementsDescription(encoding, faceCount) { } void FacesDescription::add(const TYPES type, const SEMANTICS semantic) { mListSizeTypes.push_back(ElementsDescription::TYPE_INVALID); ElementsDescription::add(type, semantic); } void FacesDescription::add(const TYPES listSizeType, const TYPES listElementType, const SEMANTICS semantic) { mListSizeTypes.push_back(listSizeType); ElementsDescription::add(listElementType, semantic); }
27.341463
107
0.789474
SamirAroudj
75c59110479330941d68685696e94f44ea3fcbe3
18,135
cpp
C++
projects/qt_camera_visualizer/lib/MathMorph.cpp
givorra/TFGacel
bde9a2f296ca5ead52e45c2c01021898a54e2ed0
[ "CC0-1.0" ]
null
null
null
projects/qt_camera_visualizer/lib/MathMorph.cpp
givorra/TFGacel
bde9a2f296ca5ead52e45c2c01021898a54e2ed0
[ "CC0-1.0" ]
null
null
null
projects/qt_camera_visualizer/lib/MathMorph.cpp
givorra/TFGacel
bde9a2f296ca5ead52e45c2c01021898a54e2ed0
[ "CC0-1.0" ]
null
null
null
#include "MathMorph.h" MathMorph::MathMorph() {} /* MY_POINT_CLOUD::Ptr MathMorph::camera_dilate(MY_POINT_CLOUD::Ptr cloud_ptr, double size) { //pcl::search::KdTree<MY_POINT_TYPE>::Ptr tree (new pcl::search::KdTree<MY_POINT_TYPE> ()); MY_POINT_CLOUD::Ptr cloud_out(new MY_POINT_CLOUD(*cloud_ptr)); MY_POINT_CLOUD::Ptr cloud_out2(new MY_POINT_CLOUD()); // MY_POINT_CLOUD::Ptr cloud(new MY_POINT_CLOUD(*currentPointCloud)); //MY_POINT_TYPE point; //cout << "Dilate size: " << size << "\n"; pcl::PointCloud<pcl::Normal>::Ptr cloud_normals = computeNormals(cloud_out); // Dilate the figure //if(false) for (int i=0; i<cloud_ptr->size(); i++) { cout << "Punto original: x=" << cloud_out->points[i].x << ", y=" << cloud_out->points[i].y << ", z=" << cloud_out->points[i].z << endl; cout << "Normal: x=" << cloud_normals->points[i].normal[0] << ", y=" << cloud_normals->points[i].normal[1] << ", z=" << cloud_normals->points[i].normal[2] << endl; cloud_out->points[i].x = cloud_out->points[i].x + size*cloud_normals->points[i].normal[0]; cloud_out->points[i].y = cloud_out->points[i].y + size*cloud_normals->points[i].normal[1]; cloud_out->points[i].z = cloud_out->points[i].z + size*cloud_normals->points[i].normal[2]; //cout << "A punto x=" << cloud_out->points[i].x << ", y="<<cloud_out->points[i].y<<", z="<<cloud_out->points[i].z<<endl; } //cloud_out = removeNan(cloud_out); pcl::KdTreeFLANN<MY_POINT_TYPE> kdtree; kdtree.setInputCloud(cloud_ptr); int removedPoints = 0; MY_POINT_CLOUD::iterator itCloud; cout << "Revisando puntos sobrantes de la dilatacion...\n"; //for(int i = 0; i < cloud_out->points.size(); i++) for(itCloud = cloud_out->points.begin(); itCloud != cloud_out->points.end(); ++itCloud) { int K = 1; // Dont modify, the function only contemplated K=1 std::vector<int> pointIdxNKNSearch(1); std::vector<float> pointNKNSquaredDistance(1); //cout << "punto x=" << cloud_out->points[i].x << ", y="<<cloud_out->points[i].y<<", z="<<cloud_out->points[i].z<<endl; //cout << "punto x=" << itCloud->x << ", y="<<itCloud->y<<", z="<<itCloud->z<<endl; double maxDistance = 0; if (//itCloud->x == std::numeric_limits<float>::quiet_NaN() //|| itCloud->y == std::numeric_limits<float>::quiet_NaN() //|| itCloud->z == std::numeric_limits<float>::quiet_NaN() //pcl_isfinite(itCloud->x) //|| pcl_isfinite(itCloud->y) //|| pcl_isfinite(itCloud->z) itCloud->x == itCloud->x && itCloud->y == itCloud->y && itCloud->z == itCloud->z) //&& kdtree.nearestKSearch(*itCloud, K, pointIdxNKNSearch, pointNKNSquaredDistance) > 0 && pointNKNSquaredDistance[0] >= size) { if(kdtree.nearestKSearch(*itCloud, K, pointIdxNKNSearch, pointNKNSquaredDistance) > 0) { if(pointNKNSquaredDistance[0] > maxDistance) maxDistance = pointNKNSquaredDistance[0]; cout << "Distancia minima a figura original: " << pointNKNSquaredDistance[0] << endl; cout << "Punto origen: x=" << itCloud->x << ", y=" << itCloud->y << ", z=" << itCloud->z << endl; cout << "Punto vecino: x=" << cloud_ptr->points[pointIdxNKNSearch[0]].x << ", y=" << cloud_ptr->points[pointIdxNKNSearch[0]].y << ", z=" << cloud_ptr->points[pointIdxNKNSearch[0]].z << endl; } cout << "Max distance: " << maxDistance << endl; MY_POINT_TYPE point(*itCloud); /*point.x=itCloud->x; point.y=itCloud->y; point.z=itCloud->z; point.r=itCloud->r; point.g=itCloud->g; point.b=itCloud->b; cloud_out2->points.push_back(point); //cloud_out->erase(itCloud); } //cout << "vecino1\n"; } cout << "Puntos cloud_out: " << cloud_out->size() << "\n"; cout << "Puntos cloud_out2: " << cloud_out2->size() << "\n"; return cloud_out2; } */ MY_POINT_CLOUD::Ptr removeOutliers(MY_POINT_CLOUD::Ptr cloud_ptr) { MY_POINT_CLOUD::Ptr cloud_out(new MY_POINT_CLOUD()); pcl::RadiusOutlierRemoval<MY_POINT_TYPE> outrem; // build the filter outrem.setInputCloud(cloud_ptr); outrem.setRadiusSearch(0.8); outrem.setMinNeighborsInRadius (2); // apply filter outrem.filter (*cloud_out); return cloud_out; } MY_POINT_CLOUD::Ptr MathMorph::camera_dilate(MY_POINT_CLOUD::Ptr cloud_ptr, double size) { cout << "Puntos cloud_ptr: " << cloud_ptr->size() << "\n"; /* if(cloud_ptr->isOrganized()) { cloud_ptr = fastBilateralFilter(cloud_ptr); } cloud_out->width = cloud_ptr->width; cloud_out->height = cloud_ptr->height; cloud_out->is_dense = cloud_ptr->is_dense; */ MY_POINT_CLOUD::Ptr cloud_out(new MY_POINT_CLOUD()); const float nan_point = std::numeric_limits<float>::quiet_NaN(); cout << "Cloud width = " << cloud_ptr->width << ", height = " << cloud_ptr->height << "\n"; float epsilon = 0.1; // Error de desplazamiento pcl::PointCloud<pcl::Normal>::Ptr cloud_normals = computeNormals(cloud_ptr); cout << "Computed normals" << cloud_ptr->size() << "\n"; pcl::KdTreeFLANN<MY_POINT_TYPE> kdtree; kdtree.setInputCloud(cloud_ptr); cout << "KdTree with input cloud" << cloud_ptr->size() << "\n"; int K = 1; // Dont modify, the function only contemplated K=1 // Dilate the figure for (int i=0; i<cloud_ptr->size(); i++) { MY_POINT_TYPE dilatedPoint(cloud_ptr->points[i]); std::vector<int> pointIdxNKNSearch(1); std::vector<float> pointNKNSquaredDistance(1); //cout << "Punto original: x=" << cloud_out->points[i].x << ", y=" << cloud_out->points[i].y << ", z=" << cloud_out->points[i].z << endl; //cout << "Normal: x=" << cloud_normals->points[i].normal[0] << ", y=" << cloud_normals->points[i].normal[1] << ", z=" << cloud_normals->points[i].normal[2] << endl; dilatedPoint.x += size*cloud_normals->points[i].normal[0]; dilatedPoint.y += size*cloud_normals->points[i].normal[1]; dilatedPoint.z += size*cloud_normals->points[i].normal[2]; if (pcl_isfinite (dilatedPoint.x) && pcl_isfinite (dilatedPoint.y) && pcl_isfinite (dilatedPoint.z)) { if(kdtree.nearestKSearch(dilatedPoint, K, pointIdxNKNSearch, pointNKNSquaredDistance) > 0) { float euclideanDilatedDistance = sqrt(pow(dilatedPoint.x - cloud_ptr->points[i].x, 2) + pow(dilatedPoint.y - cloud_ptr->points[i].y, 2) + pow(dilatedPoint.z - cloud_ptr->points[i].z, 2)); if(euclideanDilatedDistance > (pointNKNSquaredDistance[0] - epsilon * euclideanDilatedDistance)) { /* if(cloud_out->points.size() % 10 == 0) { MY_POINT_TYPE dilatedPoint2(cloud_ptr->points[i]); dilatedPoint2.x -= 0.001; cloud_out->points.push_back(dilatedPoint2); }*/ cloud_out->points.push_back(dilatedPoint); } else { dilatedPoint.x = dilatedPoint.y = dilatedPoint.z = nan_point; cloud_out->points.push_back(dilatedPoint); } //cout << "Distancia minima a figura original: " << pointNKNSquaredDistance[0] << endl; //cout << "Punto origen: x=" << itCloud->x << ", y=" << itCloud->y << ", z=" << itCloud->z << endl; //cout << "Punto vecino: x=" << cloud_ptr->points[pointIdxNKNSearch[0]].x << ", y=" << cloud_ptr->points[pointIdxNKNSearch[0]].y << ", z=" << cloud_ptr->points[pointIdxNKNSearch[0]].z << endl; } else { dilatedPoint.x = dilatedPoint.y = dilatedPoint.z = nan_point; cloud_out->points.push_back(dilatedPoint); } } else { cloud_out->points.push_back(dilatedPoint); } } cout << "Dilated cloud\n"; /* cout << "Puntos cloud_ptr: " << cloud_ptr->size() << "\n"; cout << "Puntos cloud_out: " << cloud_out->size() << "\n"; cloud_out = statisticalRemoveOutliers(cloud_out); cout << "Puntos cloud_out inliers: " << cloud_out->size() << "\n"; int size_cloud_ptr = cloud_ptr->points.size(); int size_cloud_out = cloud_out->points.size(); int numberCreatePoints = (size_cloud_ptr - size_cloud_out) * 0.8; for(int i = 0; i < numberCreatePoints; i++) { MY_POINT_TYPE pointToAdd(cloud_out->points[size_cloud_out/numberCreatePoints]); pointToAdd.x -= 0.001; cloud_out->points.push_back(pointToAdd); } cout << "Puntos cloud_out rellenada: " << cloud_out->size() << "\n"; if(cloud_out->isOrganized()) { cloud_out = fastBilateralFilter(cloud_out); }*/ cout << "Puntos cloud_out: " << cloud_out->size() << "\n"; return cloud_out; } MY_POINT_CLOUD::Ptr MathMorph::removeNan(MY_POINT_CLOUD::Ptr cloud) { MY_POINT_CLOUD::Ptr cloud_out(new MY_POINT_CLOUD(*cloud)); std::vector<int> indices; pcl::removeNaNFromPointCloud(*cloud, *cloud_out, indices); cout << "Puntos cloud: " << cloud->size() << "\n"; cout << "Puntos cloud_out: " << cloud_out->size() << "\n"; return cloud_out; } MY_POINT_CLOUD::Ptr MathMorph::camera_erode(MY_POINT_CLOUD::Ptr cloud_ptr, double size) { MY_POINT_CLOUD::Ptr cloud_out(new MY_POINT_CLOUD()); float epsilon = 0.05; // Error de desplazamiento pcl::PointCloud<pcl::Normal>::Ptr cloud_normals = computeNormals(cloud_ptr); pcl::KdTreeFLANN<MY_POINT_TYPE> kdtree; kdtree.setInputCloud(cloud_ptr); int K = 1; // Dont modify, the function only contemplated K=1 // Dilate the figure for (int i=0; i<cloud_ptr->size(); i++) { MY_POINT_TYPE dilatedPoint(cloud_ptr->points[i]); std::vector<int> pointIdxNKNSearch(1); std::vector<float> pointNKNSquaredDistance(1); //cout << "Punto original: x=" << cloud_out->points[i].x << ", y=" << cloud_out->points[i].y << ", z=" << cloud_out->points[i].z << endl; //cout << "Normal: x=" << cloud_normals->points[i].normal[0] << ", y=" << cloud_normals->points[i].normal[1] << ", z=" << cloud_normals->points[i].normal[2] << endl; dilatedPoint.x -= size*cloud_normals->points[i].normal[0]; dilatedPoint.y -= size*cloud_normals->points[i].normal[1]; dilatedPoint.z -= size*cloud_normals->points[i].normal[2]; if (dilatedPoint.x == dilatedPoint.x && dilatedPoint.y == dilatedPoint.y && dilatedPoint.z == dilatedPoint.z) { if(kdtree.nearestKSearch(dilatedPoint, K, pointIdxNKNSearch, pointNKNSquaredDistance) > 0) { float euclideanDilatedDistance = sqrt(pow(dilatedPoint.x - cloud_ptr->points[i].x, 2) + pow(dilatedPoint.y - cloud_ptr->points[i].y, 2) + pow(dilatedPoint.z - cloud_ptr->points[i].z, 2)); if(euclideanDilatedDistance > (pointNKNSquaredDistance[0] - epsilon * euclideanDilatedDistance)) cloud_out->points.push_back(dilatedPoint); //cout << "Distancia minima a figura original: " << pointNKNSquaredDistance[0] << endl; //cout << "Punto origen: x=" << itCloud->x << ", y=" << itCloud->y << ", z=" << itCloud->z << endl; //cout << "Punto vecino: x=" << cloud_ptr->points[pointIdxNKNSearch[0]].x << ", y=" << cloud_ptr->points[pointIdxNKNSearch[0]].y << ", z=" << cloud_ptr->points[pointIdxNKNSearch[0]].z << endl; } } } cout << "Puntos cloud_ptr: " << cloud_ptr->size() << "\n"; cout << "Puntos cloud_out: " << cloud_out->size() << "\n"; cloud_out = statisticalRemoveOutliers(cloud_out); cout << "Puntos cloud_out inliers: " << cloud_out->size() << "\n"; return cloud_out; } bool MathMorph::isInRange (MY_POINT_TYPE point, MY_POINT_TYPE searchPoint) { return (fabs(point.x-searchPoint.x)<=leafSize/2 && fabs(point.y-searchPoint.y)<=leafSize/2 && fabs(point.z-searchPoint.z)<=leafSize/2); } MY_POINT_CLOUD::Ptr MathMorph::dilate (MY_POINT_CLOUD::Ptr cloud_ptr) { MY_POINT_CLOUD::Ptr cloud_out (new MY_POINT_CLOUD); pcl::KdTreeFLANN<MY_POINT_TYPE> kdtree; MY_POINT_TYPE point, minPt, maxPt, searchPoint; double cosine; int xRange, yRange, zRange, cont=0, cont2=0; bool found; std::vector<int> pointIdxRadiusSearch; std::vector<float> pointRadiusSquaredDistance; Eigen::Vector4f p, q; // Compute normals to dilate pcl::PointCloud<pcl::Normal>::Ptr cloud_normals = computeNormals(cloud_ptr); // Calculate the bounding box (the size of the structured element is added) pcl::getMinMax3D (*cloud_ptr, minPt, maxPt); xRange = (maxPt.x+2*size-minPt.x)/leafSize; yRange = (maxPt.y+2*size-minPt.y)/leafSize; zRange = (maxPt.z+2*size-minPt.z)/leafSize; kdtree.setInputCloud (cloud_ptr); for (int x=0; x<=xRange; x++) { // Beginning with the lowest X and the leafside/2 is necessary to center the point in the voxel searchPoint.x=x*leafSize+(minPt.x-size)+leafSize/2; for (int y=0; y<=yRange+1; y++) { searchPoint.y=y*leafSize+(minPt.y-size)+leafSize/2; for (int z=0; z<=zRange+1; z++) { searchPoint.z=z*leafSize+(minPt.z-size)+leafSize/2; if (kdtree.radiusSearch (searchPoint, size+2*leafSize, pointIdxRadiusSearch, pointRadiusSquaredDistance) > 0) { for (int i = 0; i < pointIdxRadiusSearch.size(); i++) { MY_POINT_TYPE point; point.x=cloud_ptr->points[pointIdxRadiusSearch[i]].x - size*cloud_normals->points[pointIdxRadiusSearch[i]].normal[0]; point.y=cloud_ptr->points[pointIdxRadiusSearch[i]].y - size*cloud_normals->points[pointIdxRadiusSearch[i]].normal[1]; point.z=cloud_ptr->points[pointIdxRadiusSearch[i]].z - size*cloud_normals->points[pointIdxRadiusSearch[i]].normal[2]; if (isInRange(point, searchPoint)) { found=false; cont2++; for (int j=0; j<pointIdxRadiusSearch.size(); j++) { if (j==i) continue; p = cloud_normals->points[pointIdxRadiusSearch[j]].getNormalVector4fMap (); q = cloud_normals->points[pointIdxRadiusSearch[i]].getNormalVector4fMap (); cosine = p.dot(q); if (cosine<0) { cont++; //cout << "cosine=" << cosine << " " <<p << endl << " " << q << endl; } } if (!found) { point.x=searchPoint.x; point.y=searchPoint.y; point.z=searchPoint.z; cloud_out->points.push_back(point); break; } } } } } } } cerr << cont << " " << cont2 <<endl; return cloud_out; } pcl::PointCloud<pcl::Normal>::Ptr MathMorph::computeNormals(MY_POINT_CLOUD::Ptr cloud_ptr) { pcl::search::KdTree<MY_POINT_TYPE>::Ptr tree(new pcl::search::KdTree<MY_POINT_TYPE> ()); pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>); pcl::NormalEstimation<MY_POINT_TYPE, pcl::Normal> normal_estimation; double centroid_x=0.0, centroid_y=0.0, centroid_z=0.0; // Compute normals #if CAMERA_MODE != 1 // Calculate centroid. This is made because normals must be calculated from inside the object. With // a RGBD camera, it is not necessary // TODO: with pcl methods for (int i=0; i<cloud_ptr->size(); i++) { centroid_x += cloud_ptr->points[i].x; centroid_y += cloud_ptr->points[i].y; centroid_z += cloud_ptr->points[i].z; } centroid_x /= cloud_ptr->size(); centroid_y /= cloud_ptr->size(); centroid_z /= cloud_ptr->size(); normal_estimation.setViewPoint(centroid_x, centroid_y, centroid_z); #endif // Compute normals normal_estimation.setInputCloud (cloud_ptr); normal_estimation.setSearchMethod (tree); normal_estimation.setRadiusSearch (NORMAL_RADIUS_SEARCH); normal_estimation.compute(*cloud_normals); return cloud_normals; } /* pcl::PointCloud<pcl::Normal>::Ptr MathMorph::findNormals (MY_POINT_CLOUD::Ptr cloud_ptr) { pcl::NormalEstimation<MY_POINT_TYPE, pcl::Normal> normal_estimation; pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>); pcl::search::KdTree<MY_POINT_TYPE>::Ptr tree (new pcl::search::KdTree<MY_POINT_TYPE> ()); // Compute normals normal_estimation.setInputCloud(cloud_ptr); normal_estimation.setSearchMethod(tree); normal_estimation.setRadiusSearch(NORMAL_RADIUS_SEARCH); normal_estimation.compute(*cloud_normals); return cloud_normals; } MY_POINT_CLOUD::Ptr MathMorph::dilateRGB (MY_POINT_CLOUD::Ptr cloud_ptr) { pcl::NormalEstimation<MY_POINT_TYPE, pcl::Normal> ne; pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>); MY_POINT_CLOUD::Ptr cloud_out (new MY_POINT_CLOUD); // normals Compute normal_estimation.useSensorOriginAsViewPoint (); normal_estimation.setInputCloud (cloud_ptr); normal_estimation.setSearchMethod (tree); normal_estimation.setRadiusSearch (0.005); normal_estimation.compute (*cloud_normals); }*/
45.451128
208
0.5941
givorra
75c7f3a0c39058035a4eb5f0aa3e0c896d12f8a6
1,261
hpp
C++
include/boost/simd/function/cotd.hpp
yaeldarmon/boost.simd
561316cc54bdc6353ca78f3b6d7e9120acd11144
[ "BSL-1.0" ]
null
null
null
include/boost/simd/function/cotd.hpp
yaeldarmon/boost.simd
561316cc54bdc6353ca78f3b6d7e9120acd11144
[ "BSL-1.0" ]
null
null
null
include/boost/simd/function/cotd.hpp
yaeldarmon/boost.simd
561316cc54bdc6353ca78f3b6d7e9120acd11144
[ "BSL-1.0" ]
null
null
null
//================================================================================================== /*! @file @copyright 2016 NumScale SAS @copyright 2016 J.T. Lapreste Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ //================================================================================================== #ifndef BOOST_SIMD_FUNCTION_COTD_HPP_INCLUDED #define BOOST_SIMD_FUNCTION_COTD_HPP_INCLUDED #if defined(DOXYGEN_ONLY) namespace boost { namespace simd { /*! @ingroup group-trigonometric Function object implementing cotd capabilities cotangent of input in degree. @par Semantic: For every parameter of floating type T @code T r = cotd(x); @endcode is similar to: @code T r = cot(inrad(x)); @endcode As most other trigonometric function cotd can be called with a second optional parameter which is a tag on speed and accuracy (see @ref cos for further details) @see cos, sin, tan, cot, cotpi **/ const boost::dispatch::functor<tag::cotd_> cotd = {}; } } #endif #include <boost/simd/function/scalar/cotd.hpp> #include <boost/simd/function/simd/cotd.hpp> #endif
23.351852
100
0.593973
yaeldarmon
75c8be2e1c6af6eb50c8dcd7b49ea443a8e0554e
2,027
hh
C++
utilmm/plugin/abstract_factory.hh
annaborn/utilmm
701f0fe8312471d20dd06e567b988de2e5a67d1a
[ "CECILL-B" ]
null
null
null
utilmm/plugin/abstract_factory.hh
annaborn/utilmm
701f0fe8312471d20dd06e567b988de2e5a67d1a
[ "CECILL-B" ]
3
2015-12-22T16:59:15.000Z
2020-03-11T12:10:19.000Z
utilmm/plugin/abstract_factory.hh
annaborn/utilmm
701f0fe8312471d20dd06e567b988de2e5a67d1a
[ "CECILL-B" ]
2
2015-12-22T14:26:35.000Z
2020-02-28T10:33:29.000Z
// Copyright Vladimir Prus 2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_ABSTRACT_FACTORY_VP_2004_08_25 #define BOOST_ABSTRACT_FACTORY_VP_2004_08_25 #include <boost/mpl/inherit_linearly.hpp> #include <boost/mpl/list.hpp> #include <boost/shared_ptr.hpp> #include <utilmm/plugin/virtual_constructors.hh> namespace utilmm { namespace plugin { struct empty_abstract_factory_item { void create(int*******); }; /** A template class, which is given the base type of plugin and a set of constructor parameter types and defines the appropriate virtual 'create' function. */ template<class BasePlugin, class Parameters> struct abstract_factory_item_N { }; template<class BasePlugin> struct abstract_factory_item_N<BasePlugin, boost::mpl::list<> > { virtual BasePlugin* create(dll_handle dll) = 0; }; template<class BasePlugin, class A1> struct abstract_factory_item_N<BasePlugin, boost::mpl::list<A1> > { virtual BasePlugin* create(dll_handle dll, A1 a1) = 0; }; template<class BasePlugin, class A1, class A2> struct abstract_factory_item_N<BasePlugin, boost::mpl::list<A1, A2> > { virtual BasePlugin* create(dll_handle dll, A1 a1, A2 a2) = 0; }; template<class BasePlugin, class Base, class Parameters> struct abstract_factory_item : public Base, public abstract_factory_item_N<BasePlugin, Parameters> { using Base::create; using abstract_factory_item_N<BasePlugin, Parameters>::create; }; using namespace boost::mpl::placeholders; template<class BasePlugin> struct abstract_factory : public boost::mpl::inherit_linearly< typename virtual_constructors<BasePlugin>::type, abstract_factory_item<BasePlugin, _, _>, empty_abstract_factory_item>::type { }; }} #endif
29.808824
75
0.695609
annaborn
75cbfe87549a68f7fb8a2aa6fe31c6621ce6d9cd
3,970
cpp
C++
Source/Clang-Tools/AutoBinder/AutoBinder.cpp
1vanK/Dviglo
468a61e6d9a87cf7d998312c1261aaa83b37ff3c
[ "MIT" ]
null
null
null
Source/Clang-Tools/AutoBinder/AutoBinder.cpp
1vanK/Dviglo
468a61e6d9a87cf7d998312c1261aaa83b37ff3c
[ "MIT" ]
1
2021-04-17T22:38:25.000Z
2021-04-18T00:43:15.000Z
Source/Clang-Tools/AutoBinder/AutoBinder.cpp
1vanK/Dviglo
468a61e6d9a87cf7d998312c1261aaa83b37ff3c
[ "MIT" ]
null
null
null
// Copyright (c) 2008-2021 the Urho3D project // Copyright (c) 2021 проект Dviglo // Лицензия: MIT #include <clang/ASTMatchers/ASTMatchFinder.h> #include <clang/Driver/Options.h> #include <clang/Tooling/CommonOptionsParser.h> #include <clang/Tooling/Tooling.h> #include <Mustache/mustache.hpp> #include <unordered_set> using namespace clang; using namespace clang::ast_matchers; using namespace clang::driver; using namespace clang::tooling; using namespace llvm; static cl::extrahelp commonHelp(CommonOptionsParser::HelpMessage); static cl::extrahelp moreHelp( "\tFor example, to run AutoBinder on all files in a subtree of the\n" "\tsource tree, use:\n" "\n" "\t find path/in/substree -name '*.cpp'|xargs AutoBinder -p build/path \\\n" "\t -t template/path -o output/path -s script0 -s script1\n" "\n" "\tNote, that path/in/subtree and current directory should follow the\n" "\trules described above.\n" "\n" "Most probably you want to invoke 'autobinder' built-in target instead of invoking this tool\n" "directly. The 'autobinder' target invokes this tool in a right context prepared by build system.\n" "\n" ); static cl::OptionCategory autobinderCategory("AutoBinder options"); static std::unique_ptr<opt::OptTable> options(createDriverOptTable()); static cl::opt<std::string> templatePath("t", cl::desc("Template path"), cl::cat(autobinderCategory)); static cl::opt<std::string> outputPath("o", cl::desc("Output path"), cl::cat(autobinderCategory)); static cl::list<std::string> scripts("s", cl::desc("Script subsystems"), cl::cat(autobinderCategory)); struct Data { std::unordered_set<std::string> symbols_; }; static const std::string categories_[] = {"class", "enum"}; static std::unordered_map<std::string, Data> categoryData_; class ExtractCallback : public MatchFinder::MatchCallback { public : virtual void run(const MatchFinder::MatchResult& result) { for (auto& i: categories_) { auto symbol = result.Nodes.getNodeAs<StringLiteral>(i); if (symbol) categoryData_[i].symbols_.insert(symbol->getString()); } } virtual void onStartOfTranslationUnit() { static unsigned count = sizeof("Extracting") / sizeof(char) - 1; outs() << '.' << (++count % 100 ? "" : "\n"); // Sending a heart beat } }; static int BindingGenerator() { // TODO: WIP return EXIT_SUCCESS; } int main(int argc, const char** argv) { // Parse the arguments and pass them to the the internal sub-tools CommonOptionsParser optionsParser(argc, argv, autobinderCategory); ClangTool bindingExtractor(optionsParser.getCompilations(), optionsParser.getSourcePathList()); // Setup finder to match against AST nodes from Urho3D library source files ExtractCallback extractCallback; MatchFinder bindingFinder; // Find exported class declarations with Urho3D namespace bindingFinder.addMatcher( recordDecl( unless(hasAttr(attr::Annotate)), #ifndef _MSC_VER hasAttr(attr::Visibility), #else hasAttr(attr::DLLExport), #endif matchesName("^::Dviglo::")).bind("class"), &extractCallback); // Find enum declarations with Urho3D namespace bindingFinder.addMatcher( enumDecl( unless(hasAttr(attr::Annotate)), matchesName("^::Dviglo::")).bind("enum"), &extractCallback); // Unbuffered stdout stream to keep the Travis-CI's log flowing and thus prevent it from killing a potentially long running job outs().SetUnbuffered(); // Success when both sub-tools are run successfully return (outs() << "Extracting", true) && bindingExtractor.run(newFrontendActionFactory(&bindingFinder).get()) == EXIT_SUCCESS && (outs() << "\nBinding", true) && BindingGenerator() == EXIT_SUCCESS && (outs() << "\n", true) ? EXIT_SUCCESS : EXIT_FAILURE; }
35.446429
131
0.680353
1vanK
75cc941279d3c25e49c3182b3e967c97116a23dc
940
cpp
C++
src/draw_sprite.cpp
pabloariasal/chip8emulator
4877915967e48f807a490b396490e6424081f027
[ "MIT" ]
null
null
null
src/draw_sprite.cpp
pabloariasal/chip8emulator
4877915967e48f807a490b396490e6424081f027
[ "MIT" ]
null
null
null
src/draw_sprite.cpp
pabloariasal/chip8emulator
4877915967e48f807a490b396490e6424081f027
[ "MIT" ]
null
null
null
#include "draw_sprite.h" #include <array> namespace { bool isPixelSet(int index, uint8_t row) { row >>= 7 - index; return (row & 0x01u) == 1; } bool invertColor(Color& color) { if (color == Color::BLACK) { color = Color::WHITE; return true; } color = Color::BLACK; return false; } } // namespace bool drawSprite(int row, int col, const std::vector<uint8_t>& sprite, PixelBuffer<Color>& display) { // wrap coordinates row = row % display.height(); col = col % display.width(); auto num_sprite_rows = static_cast<int>(sprite.size()); auto flipped = false; for (int sr = 0, x = row; sr < num_sprite_rows && x < display.height(); sr++, ++x) { for (int sc = 0, y = col; sc < 8 && y < display.width(); sc++, ++y) { if (isPixelSet(sc, sprite.at(sr))) { if (invertColor(display.get(x, y))) { flipped = true; } } } } return flipped; }
21.363636
73
0.571277
pabloariasal
75cd507f7cab2ea546c93e23e8415e01ed070181
9,528
cpp
C++
src/strategy/actions/CheckMountStateAction.cpp
htc16/mod-playerbots
2307e3f980035a244bfb4fedefda5bc55903d470
[ "MIT" ]
12
2022-03-23T05:14:53.000Z
2022-03-30T12:12:58.000Z
src/strategy/actions/CheckMountStateAction.cpp
htc16/mod-playerbots
2307e3f980035a244bfb4fedefda5bc55903d470
[ "MIT" ]
24
2022-03-23T13:56:37.000Z
2022-03-31T18:23:32.000Z
src/strategy/actions/CheckMountStateAction.cpp
htc16/mod-playerbots
2307e3f980035a244bfb4fedefda5bc55903d470
[ "MIT" ]
3
2022-03-24T21:47:10.000Z
2022-03-31T06:21:46.000Z
/* * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CheckMountStateAction.h" #include "BattlegroundWS.h" #include "Event.h" #include "Playerbots.h" #include "ServerFacade.h" #include "SpellAuraEffects.h" bool CheckMountStateAction::Execute(Event event) { bool noattackers = AI_VALUE2(bool, "combat", "self target") ? (AI_VALUE(uint8, "attacker count") > 0 ? false : true) : true; bool enemy = AI_VALUE(Unit*, "enemy player target"); bool dps = (AI_VALUE(Unit*, "dps target") || AI_VALUE(Unit*, "grind target")); bool fartarget = (enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) || (dps && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), 50.0f)); bool attackdistance = false; bool chasedistance = false; float attack_distance = 35.0f; switch (bot->getClass()) { case CLASS_WARRIOR: case CLASS_PALADIN: attack_distance = 10.0f; break; case CLASS_ROGUE: attack_distance = 40.0f; break; } if (enemy) attack_distance /= 2; if (dps || enemy) { attackdistance = (enemy || dps) && sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "current target"), attack_distance); chasedistance = enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) && AI_VALUE2(bool, "moving", "enemy player target"); } Player* master = GetMaster(); if (master != nullptr && !bot->InBattleground()) { if (!bot->GetGroup() || bot->GetGroup()->GetLeaderGUID() != master->GetGUID()) return false; bool farFromMaster = sServerFacade->GetDistance2d(bot, master) > sPlayerbotAIConfig->sightDistance; if (master->IsMounted() && !bot->IsMounted() && noattackers) { return Mount(); } if (!bot->IsMounted() && (chasedistance || (farFromMaster && botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))) && !bot->IsInCombat() && !dps) return Mount(); if (!bot->IsFlying() && ((!farFromMaster && !master->IsMounted()) || attackdistance) && bot->IsMounted()) { WorldPacket emptyPacket; bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket); return true; } return false; } if (bot->InBattleground() && !attackdistance && (noattackers || fartarget) && !bot->IsInCombat() && !bot->IsMounted()) { if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS) { BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); if (bot->HasAura(23333) || bot->HasAura(23335)) { return false; } } return Mount(); } if (!bot->InBattleground()) { if (AI_VALUE(GuidPosition, "rpg target")) { if (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "rpg target"), sPlayerbotAIConfig->farDistance) && noattackers && !dps && !enemy) return Mount(); } if (((!AI_VALUE(GuidVector, "possible rpg targets").empty()) && noattackers && !dps && !enemy) && urand(0, 100) > 50) return Mount(); } if (!bot->IsMounted() && !attackdistance && (fartarget || chasedistance)) return Mount(); if (!bot->IsFlying() && attackdistance && bot->IsMounted() && (enemy || dps || (!noattackers && bot->IsInCombat()))) { WorldPacket emptyPacket; bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket); return true; } return false; } bool CheckMountStateAction::isUseful() { // do not use on vehicle if (botAI->IsInVehicle()) return false; if (bot->isDead()) return false; bool isOutdoor = bot->IsOutdoors(); if (!isOutdoor) return false; if (bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) return false; if (bot->InArena()) return false; if (!GET_PLAYERBOT_AI(bot)->HasStrategy("mount", BOT_STATE_NON_COMBAT) && !bot->IsMounted()) return false; bool firstmount = bot->getLevel() >= 20; if (!firstmount) return false; // Do not use with BG Flags if (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976)) { return false; } // Only mount if BG starts in less than 30 sec if (bot->InBattleground()) { if (Battleground* bg = bot->GetBattleground()) if (bg->GetStatus() == STATUS_WAIT_JOIN) { if (bg->GetStartDelayTime() > BG_START_DELAY_30S) return false; } } return true; } bool CheckMountStateAction::Mount() { uint32 secondmount = 40; if (bot->isMoving()) { bot->StopMoving(); bot->GetMotionMaster()->Clear(); bot->GetMotionMaster()->MoveIdle(); } Player* master = GetMaster(); botAI->RemoveShapeshift(); int32 masterSpeed = 59; SpellInfo const* masterSpell = nullptr; if (master && !master->GetAuraEffectsByType(SPELL_AURA_MOUNTED).empty() && !bot->InBattleground()) { masterSpell = master->GetAuraEffectsByType(SPELL_AURA_MOUNTED).front()->GetSpellInfo(); masterSpeed = std::max(masterSpell->Effects[1].BasePoints, masterSpell->Effects[2].BasePoints); } else { masterSpeed = 59; for (PlayerSpellMap::iterator itr = bot->GetSpellMap().begin(); itr != bot->GetSpellMap().end(); ++itr) { uint32 spellId = itr->first; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo || spellInfo->Effects[0].ApplyAuraName != SPELL_AURA_MOUNTED) continue; if (itr->second->State == PLAYERSPELL_REMOVED || !itr->second->Active || spellInfo->IsPassive()) continue; int32 effect = std::max(spellInfo->Effects[1].BasePoints, spellInfo->Effects[2].BasePoints); if (effect > masterSpeed) masterSpeed = effect; } } if (bot->GetPureSkillValue(SKILL_RIDING) <= 75 && bot->getLevel() < secondmount) masterSpeed = 59; if (bot->InBattleground() && masterSpeed > 99) masterSpeed = 99; bool hasSwiftMount = false; //std::map<int32, std::vector<uint32> > spells; std::map<uint32, std::map<int32, std::vector<uint32>>> allSpells; for (PlayerSpellMap::iterator itr = bot->GetSpellMap().begin(); itr != bot->GetSpellMap().end(); ++itr) { uint32 spellId = itr->first; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo || spellInfo->Effects[0].ApplyAuraName != SPELL_AURA_MOUNTED) continue; if (itr->second->State == PLAYERSPELL_REMOVED || !itr->second->Active || spellInfo->IsPassive()) continue; int32 effect = std::max(spellInfo->Effects[1].BasePoints, spellInfo->Effects[2].BasePoints); //if (effect < masterSpeed) //continue; uint32 index = (spellInfo->Effects[1].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED || spellInfo->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) ? 1 : 0; if (index == 0 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 59) hasSwiftMount = true; if (index == 1 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 149) hasSwiftMount = true; allSpells[index][effect].push_back(spellId); } int32 masterMountType = 0; if (masterSpell) { masterMountType = (masterSpell->Effects[1].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED || masterSpell->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) ? 1 : 0; } std::map<int32, std::vector<uint32>>& spells = allSpells[masterMountType]; if (hasSwiftMount) { for (auto i : spells) { std::vector<uint32> ids = i.second; for (auto itr : ids) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr); if (!spellInfo) continue; if (masterMountType == 0 && masterSpeed > 59 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 99) spells[59].clear(); if (masterMountType == 1 && masterSpeed > 149 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 279) spells[149].clear(); } } } for (std::map<int32, std::vector<uint32>>::iterator i = spells.begin(); i != spells.end(); ++i) { std::vector<uint32>& ids = i->second; uint32 index = urand(0, ids.size() - 1); if (index >= ids.size()) continue; botAI->CastSpell(ids[index], bot); return true; } std::vector<Item*> items = AI_VALUE2(std::vector<Item*>, "inventory items", "mount"); if (!items.empty()) return UseItemAuto(*items.begin()); return false; }
34.647273
205
0.599076
htc16
75cdb3d1bb14ee3edb3b6075340d332f3525bd9f
5,199
cpp
C++
SerialGraphicLCDTouchScreen/lib/src/touchscreen.cpp
scottmccain/serial_tft
964da5120d7b10b00c52c3a46a0ac4878363da39
[ "MIT" ]
null
null
null
SerialGraphicLCDTouchScreen/lib/src/touchscreen.cpp
scottmccain/serial_tft
964da5120d7b10b00c52c3a46a0ac4878363da39
[ "MIT" ]
null
null
null
SerialGraphicLCDTouchScreen/lib/src/touchscreen.cpp
scottmccain/serial_tft
964da5120d7b10b00c52c3a46a0ac4878363da39
[ "MIT" ]
null
null
null
/* The MIT License (MIT) Copyright (c) 2016 Scott McCain Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************************************************* * Filename: touchscreen.cpp * Created: 6/14/2016 5:23:41 PM * Author: Scott McCain ******************************************************************************************************************* * */ #include <avr/io.h> #include "touchscreen.h" //----------------------------------------- #define DDR_XP DDRC #define PORT_XP PORTC #define XP_BIT 0x08 #define XP_OUTPUT {DDR_XP|=XP_BIT;} #define XP_INPUT {DDR_XP&=~XP_BIT;} #define XP_HIZ {DDR_XP&=~XP_BIT;PORT_XP&=~XP_BIT;} #define XP_HIGH {PORT_XP|=XP_BIT;} #define XP_LOW {PORT_XP&=~XP_BIT;} #define XP_RISING {PORT_XP|=XP_BIT;PORT_XP&=~XP_BIT;} //----------------------------------------- #define DDR_XM DDRC #define PORT_XM PORTC #define XM_BIT 0x02 #define XM_OUTPUT {DDR_XM|=XM_BIT;} #define XM_INPUT {DDR_XM&=~XM_BIT;} #define XM_HIZ {DDR_XM&=~XM_BIT;PORT_XM&=~XM_BIT;} #define XM_HIGH {PORT_XM|=XM_BIT;} #define XM_LOW {PORT_XM&=~XM_BIT;} #define XM_RISING {PORT_XM|=XM_BIT;PORT_XM&=~XM_BIT;} //----------------------------------------- #define DDR_YP DDRC #define PORT_YP PORTC #define YP_BIT 0x04 #define YP_OUTPUT {DDR_YP|=YP_BIT;} #define YP_INPUT {DDR_YP&=~YP_BIT;} #define YP_HIZ {DDR_YP&=~YP_BIT;PORT_YP&=~YP_BIT;} #define YP_HIGH {PORT_YP|=YP_BIT;} #define YP_LOW {PORT_YP&=~YP_BIT;} #define YP_RISING {PORT_YP|=YP_BIT;PORT_YP&=~YP_BIT;} //----------------------------------------- #define DDR_YM DDRC #define PORT_YM PORTC #define YM_BIT 0x01 #define YM_OUTPUT {DDR_YM|=YM_BIT;} #define YM_INPUT {DDR_YM&=~YM_BIT;} #define YM_HIZ {DDR_YM&=~YM_BIT;PORT_YM&=~YM_BIT;} #define YM_HIGH {PORT_YM|=YM_BIT;} #define YM_LOW {PORT_YM&=~YM_BIT;} #define YM_RISING {PORT_YM|=YM_BIT;PORT_YM&=~YM_BIT;} #define TS_MINX 140 #define TS_MAXX 900 #define TS_MINY 120 #define TS_MAXY 940 inline uint16_t read_adc(uint8_t channel); long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } void TouchScreen_init() { ADCSRA |= ((1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0)); //16Mhz/128 = 125Khz the ADC reference clock ADMUX |= (1<<REFS0); //Voltage reference from Avcc (5v) ADCSRA |= (1<<ADEN); //Turn on ADC ADCSRA |= (1<<ADSC); //Do an initial conversion because this one is the slowest and to ensure that everything is up and running } #define NUMSAMPLES 2 TSPoint TouchScreen_getPoint(void) { int x, y, z; int samples[NUMSAMPLES]; uint8_t i, valid; uint16_t _rxplate = 300; valid = 1; YP_HIZ YM_HIZ XP_OUTPUT XP_HIGH XM_OUTPUT XM_LOW for (i=0; i<NUMSAMPLES; i++) { samples[i] = read_adc(0x02); } #if NUMSAMPLES == 2 if (samples[0] != samples[1]) { valid = 0; } #endif x = (1023-samples[NUMSAMPLES/2]); XP_HIZ XM_HIZ YP_OUTPUT YP_HIGH YM_OUTPUT YM_LOW for (i=0; i<NUMSAMPLES; i++) { samples[i] = read_adc(0x01); } #if NUMSAMPLES == 2 if (samples[0] != samples[1]) { valid = 0; } #endif y = (1023-samples[NUMSAMPLES/2]); // Set X+ to ground XP_OUTPUT XP_LOW // Set Y- to VCC YM_HIGH // Hi-Z X- and Y+ YP_HIZ int z1 = read_adc(0x01); int z2 = read_adc(0x02); if (_rxplate != 0) { // now read the x float rtouch; rtouch = z2; rtouch /= z1; rtouch -= 1; rtouch *= x; rtouch *= _rxplate; rtouch /= 1024; z = rtouch; } else { z = (1023-(z2-z1)); } if (! valid) { z = 0; } return TSPoint(map(x, TS_MINX, TS_MAXX, 240, 0), map(y, TS_MINY, TS_MAXY, 320, 0), z); } inline uint16_t read_adc(uint8_t channel) { ADMUX &= 0xF0; //Clear the older channel that was read ADMUX |= channel; //Defines the new ADC channel to be read ADCSRA |= (1<<ADSC); //Starts a new conversion while(ADCSRA & (1<<ADSC)); //Wait until the conversion is done return ADCW; //Returns the ADC value of the chosen channel }
26.937824
143
0.620504
scottmccain
75d80b4be17142909ea94e127db032dcd9e9b6ee
11,554
cpp
C++
src/Ops.cpp
omi-lab/tp_caffe2_utils
8874aca09c3aeaa3a1e7544798089fe8cf85866f
[ "MIT" ]
null
null
null
src/Ops.cpp
omi-lab/tp_caffe2_utils
8874aca09c3aeaa3a1e7544798089fe8cf85866f
[ "MIT" ]
null
null
null
src/Ops.cpp
omi-lab/tp_caffe2_utils
8874aca09c3aeaa3a1e7544798089fe8cf85866f
[ "MIT" ]
null
null
null
#include "tp_caffe2_utils/Ops.h" #include "tp_caffe2_utils/FillOps.h" #include "tp_caffe2_utils/ArgUtils.h" #include "tp_caffe2_utils/ModelDetails.h" namespace tp_caffe2_utils { //################################################################################################## caffe2::OperatorDef* addActivationOp(caffe2::NetDef& net, const std::string& inName, const std::string& name, const std::string& function) { auto op = net.add_op(); op->set_type(function); op->add_input(inName); op->add_output(name); return op; } //################################################################################################## caffe2::OperatorDef* addWeightedSumOP(caffe2::NetDef& net, const std::string& aName, const std::string& aWeightName, const std::string& bName, const std::string& bWeightName, const std::string& name) { auto op = net.add_op(); op->set_type("WeightedSum"); op->add_input(aName); op->add_input(aWeightName); op->add_input(bName); op->add_input(bWeightName); op->add_output(name); return op; } //################################################################################################## void addConv2DOp(ModelDetails& model, const std::string& inName, const std::string& name, int64_t inChannels, int64_t outChannels, int64_t stride, int64_t pad, int64_t kernelSize) { auto op = model.predictNet.add_op(); model.gradientOps.push_back(op); op->set_type("Conv2D"); op->add_input(inName); op->add_input(name + "_filter"); op->add_input(name + "_bias"); op->add_output(name); addIntArg (op, "stride", stride); addIntArg (op, "pad" , pad); addIntArg (op, "kernel", kernelSize); addStringArg(op, "order" , "NCHW"); addXavierFillOp (model.initPredictNet, {outChannels, inChannels, kernelSize, kernelSize}, name + "_filter"); //addConstantFillOp(model.initPredictNet, {outChannels}, 0.0f, name + "_bias"); addGaussianFillOp(model.initPredictNet, {outChannels}, 0.0f, 0.2f, name + "_bias"); model.learntBlobNames.push_back(name + "_filter"); model.learntBlobNames.push_back(name + "_bias"); } //################################################################################################## void addConv2DOp(ModelDetails& model, const std::string& inName, const std::string& name, int64_t inChannels, int64_t outChannels, int64_t strideW, int64_t strideH, int64_t padT, int64_t padL, int64_t padB, int64_t padR, int64_t kernelW, int64_t kernelH) { auto op = model.predictNet.add_op(); model.gradientOps.push_back(op); op->set_type("Conv2D"); op->add_input(inName); op->add_input(name + "_filter"); op->add_input(name + "_bias"); op->add_output(name); addIntArg (op, "stride_w", strideW); addIntArg (op, "stride_h", strideH); addIntArg (op, "pad_t" , padT); addIntArg (op, "pad_l" , padL); addIntArg (op, "pad_b" , padB); addIntArg (op, "pad_r" , padR); addIntArg (op, "kernel_w" , kernelW); addIntArg (op, "kernel_h" , kernelH); addStringArg(op, "order" , "NCHW"); addXavierFillOp (model.initPredictNet, {outChannels, inChannels, kernelH, kernelW}, name + "_filter"); addConstantFillOp(model.initPredictNet, {outChannels}, 0.0f, name + "_bias"); //addGaussianFillOp(model.initPredictNet, {outChannels}, 0.0f, 0.2f, name + "_bias"); model.learntBlobNames.push_back(name + "_filter"); model.learntBlobNames.push_back(name + "_bias"); } //################################################################################################## void addConv2DActivationOps(ModelDetails& model, const std::string& inName, const std::string& outName, int64_t inChannels, int64_t outChannels, int64_t stride, int64_t pad, int64_t kernelSize, const std::string& function) { auto convName = outName+"_conv"; addConv2DOp(model, inName, convName, inChannels, outChannels, stride, pad, kernelSize); model.gradientOps.push_back(tp_caffe2_utils::addActivationOp(model.predictNet, convName, outName, function)); } //################################################################################################## void addConv2DActivationOps(ModelDetails& model, const std::string& inName, const std::string& outName, int64_t inChannels, int64_t outChannels, int64_t strideW, int64_t strideH, int64_t padT, int64_t padL, int64_t padB, int64_t padR, int64_t kernelW, int64_t kernelH, const std::string& function) { auto convName = outName+"_conv"; addConv2DOp(model, inName, convName, inChannels, outChannels, strideW, strideH, padT, padL, padB, padR, kernelW, kernelH); model.gradientOps.push_back(tp_caffe2_utils::addActivationOp(model.predictNet, convName, outName, function)); } //################################################################################################## void addAveragePool2DOp(ModelDetails& model, const std::string& inName, const std::string& name, int64_t strideW, int64_t strideH, int64_t padT, int64_t padL, int64_t padB, int64_t padR, int64_t kernelW, int64_t kernelH) { auto op = model.predictNet.add_op(); model.gradientOps.push_back(op); op->set_type("AveragePool2D"); op->add_input(inName); op->add_output(name); addIntArg (op, "stride_w", strideW); addIntArg (op, "stride_h", strideH); addIntArg (op, "pad_t" , padT); addIntArg (op, "pad_l" , padL); addIntArg (op, "pad_b" , padB); addIntArg (op, "pad_r" , padR); addIntArg (op, "kernel_w" , kernelW); addIntArg (op, "kernel_h" , kernelH); addStringArg(op, "order" , "NCHW"); } //################################################################################################## caffe2::OperatorDef* addConcatOp(caffe2::NetDef& net, const std::vector<std::string>& inNames, const std::string& name, const std::string& splitInfoName, int64_t axis) { auto op = net.add_op(); op->set_type("Concat"); addIntArg(op, "axis", axis); for(const auto& inName : inNames) op->add_input(inName); op->add_output(name); op->add_output(splitInfoName); return op; } //################################################################################################## caffe2::OperatorDef* addSliceOp(caffe2::NetDef& net, const std::string& inName, const std::string& name, const std::vector<int64_t>& starts, const std::vector<int64_t>& ends) { auto op = net.add_op(); op->set_type("Slice"); op->add_input(inName); op->add_output(name); addIntsArg(op, "starts", starts); addIntsArg(op, "ends", ends); return op; } //################################################################################################## caffe2::OperatorDef* addClipOp(caffe2::NetDef& net, const std::string& inName, const std::string& name, float min, float max) { auto op = net.add_op(); op->set_type("Clip"); tp_caffe2_utils::addFloatArg(op, "min", min); tp_caffe2_utils::addFloatArg(op, "max", max); op->add_input(inName); op->add_output(name); return op; } //################################################################################################## caffe2::OperatorDef* addMathOp(caffe2::NetDef& net, const std::string& aName, const std::string& bName, const std::string& name, const std::string& function) { auto op = net.add_op(); op->set_type(function); op->add_input(aName); op->add_input(bName); op->add_output(name); return op; } //################################################################################################## caffe2::OperatorDef* addFCOp(ModelDetails& model, const std::string inName, const std::string outName, int64_t inSize, int64_t outSize) { auto op = model.predictNet.add_op(); op->set_type("FC"); op->add_input(inName); op->add_input(outName+"_weights"); op->add_input(outName+"_bias"); op->add_output(outName); tp_caffe2_utils::addXavierFillOp (model.initPredictNet, {outSize, inSize}, outName+"_weights"); // {outFloats, inFloats} tp_caffe2_utils::addConstantFillOp(model.initPredictNet, {outSize}, 0.0f, outName+"_bias" ); // {outFloats}, initialValue model.learntBlobNames.push_back(outName+"_weights"); model.learntBlobNames.push_back(outName+"_bias"); return op; } //################################################################################################## void addFCActivationOps(ModelDetails& model, std::vector<caffe2::OperatorDef*>& gradientOps, const std::string inName, const std::string outName, int64_t inSize, int64_t outSize, const std::string& function) { auto fcName = outName+"_fc"; gradientOps.push_back(addFCOp(model, inName, fcName, inSize, outSize)); gradientOps.push_back(tp_caffe2_utils::addActivationOp(model.predictNet, fcName, outName, function)); } //################################################################################################## caffe2::OperatorDef* addDropoutOp(ModelDetails& model, const std::string inName, const std::string outName, float ratio, bool dropout) { auto op = model.predictNet.add_op(); op->set_type("Dropout"); tp_caffe2_utils::addFloatArg(op, "ratio", ratio); tp_caffe2_utils::addIntArg(op, "is_test", dropout?0:1); op->add_input(inName); op->add_output(outName); op->add_output(outName + "_mask"); return op; } }
37.391586
127
0.478968
omi-lab
75e28760017aaede95f352577641cf4f6e42e44c
1,813
cc
C++
src/calcfn.cc
HardGraphite/SimpleCalculator
e72e7ec0177379638ff90adeff574ae4b9a073f7
[ "MIT" ]
null
null
null
src/calcfn.cc
HardGraphite/SimpleCalculator
e72e7ec0177379638ff90adeff574ae4b9a073f7
[ "MIT" ]
null
null
null
src/calcfn.cc
HardGraphite/SimpleCalculator
e72e7ec0177379638ff90adeff574ae4b9a073f7
[ "MIT" ]
null
null
null
#include <calcfn.h> using namespace hgl::calc; double _calc_add(CalcFn::OprdList oprds); double _calc_sub(CalcFn::OprdList oprds); double _calc_mul(CalcFn::OprdList oprds); double _calc_div(CalcFn::OprdList oprds); double _calc_neg(CalcFn::OprdList oprds); double _calc_log10(CalcFn::OprdList oprds); double _calc_log2(CalcFn::OprdList oprds); double _calc_ln(CalcFn::OprdList oprds); double _calc_log(CalcFn::OprdList oprds); double _calc_exp(CalcFn::OprdList oprds); double _calc_exp2(CalcFn::OprdList oprds); double _calc_pow(CalcFn::OprdList oprds); double _calc_sqrt(CalcFn::OprdList oprds); double _calc_cbrt(CalcFn::OprdList oprds); double _calc_sin(CalcFn::OprdList oprds); double _calc_cos(CalcFn::OprdList oprds); double _calc_tan(CalcFn::OprdList oprds); double _calc_asin(CalcFn::OprdList oprds); double _calc_acos(CalcFn::OprdList oprds); double _calc_atan(CalcFn::OprdList oprds); const CalcFnPool hgl::calc::BuiltinCalcFnPool = { {"+", {_calc_add, 2}}, {"-", {_calc_sub, 2}}, {"*", {_calc_mul, 2}}, {"/", {_calc_div, 2}}, {"^", {_calc_pow, 2}}, {"~", {_calc_neg, 1}}, {"add", {_calc_add, 2}}, {"sub", {_calc_sub, 2}}, {"mul", {_calc_mul, 2}}, {"div", {_calc_div, 2}}, {"pow", {_calc_pow, 2}}, {"neg", {_calc_neg, 1}}, {"log10", {_calc_log10, 1}}, {"log2", {_calc_log2, 1}}, {"ln", {_calc_ln, 1}}, {"log", {_calc_log, 2}}, {"exp", {_calc_exp, 1}}, {"exp2", {_calc_exp2, 1}}, {"sqrt", {_calc_sqrt, 1}}, {"cbrt", {_calc_cbrt, 1}}, {"sin", {_calc_sin, 1}}, {"cos", {_calc_cos, 1}}, {"tan", {_calc_tan, 1}}, {"asin", {_calc_asin, 1}}, {"acos", {_calc_acos, 1}}, {"atan", {_calc_atan, 1}}, };
28.328125
49
0.605626
HardGraphite
75e4a5b8086f2886170c7912f8a0841f3e06a489
2,335
hh
C++
src/core/wakeup_detector.hh
nugulinux/nugu-linux
c166d61b2037247d4574b7f791c31ba79ceb575e
[ "Apache-2.0" ]
null
null
null
src/core/wakeup_detector.hh
nugulinux/nugu-linux
c166d61b2037247d4574b7f791c31ba79ceb575e
[ "Apache-2.0" ]
null
null
null
src/core/wakeup_detector.hh
nugulinux/nugu-linux
c166d61b2037247d4574b7f791c31ba79ceb575e
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2019 SK Telecom Co., 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. */ #ifndef __NUGU_WAKEUP_DETECTOR_H__ #define __NUGU_WAKEUP_DETECTOR_H__ #include "audio_input_processor.hh" #define WAKEUP_NET_MODEL_FILE "nugu_model_wakeup_net.raw" #define WAKEUP_SEARCH_MODEL_FILE "nugu_model_wakeup_search.raw" #define POWER_SPEECH_PERIOD 7 // (140ms * 10 = 1400 ms) / 200ms #define POWER_NOISE_PERIOD 35 // (140ms * 50 = 70000 ms) / 200ms namespace NuguCore { enum class WakeupState { FAIL, DETECTING, DETECTED, DONE }; class IWakeupDetectorListener { public: virtual ~IWakeupDetectorListener() = default; /* The callback is invoked in the main context. */ virtual void onWakeupState(WakeupState state, const std::string& id, float noise = 0, float speech = 0) = 0; }; class WakeupDetector : public AudioInputProcessor { public: using Attribute = struct { std::string sample; std::string format; std::string channel; std::string model_path; }; public: WakeupDetector(); WakeupDetector(Attribute&& attribute); virtual ~WakeupDetector(); void setListener(IWakeupDetectorListener* listener); bool startWakeup(const std::string& id); void stopWakeup(); private: void initialize(Attribute&& attribute); void loop() override; void sendWakeupEvent(WakeupState state, const std::string& id, float noise = 0, float speech = 0); void setPower(float power); void getPower(float& noise, float& speech); IWakeupDetectorListener* listener = nullptr; // attribute std::string model_path = ""; float power_speech[POWER_SPEECH_PERIOD]; float power_noise[POWER_NOISE_PERIOD]; int power_index = 0; }; } // NuguCore #endif /* __NUGU_WAKEUP_DETECTOR_H__ */
28.47561
112
0.716916
nugulinux
75ed90694863749a3bafa7c306951d08d446a6d4
3,545
cpp
C++
src/URDriver_receiver-component.cpp
AliRoshanbin/URDriver-1
7ed462ff86e242de1e8d148a13a489340cbe6a3e
[ "MIT" ]
3
2016-03-09T10:06:10.000Z
2021-11-10T16:26:40.000Z
src/URDriver_receiver-component.cpp
AliRoshanbin/URDriver-1
7ed462ff86e242de1e8d148a13a489340cbe6a3e
[ "MIT" ]
null
null
null
src/URDriver_receiver-component.cpp
AliRoshanbin/URDriver-1
7ed462ff86e242de1e8d148a13a489340cbe6a3e
[ "MIT" ]
4
2017-02-09T11:00:16.000Z
2021-04-01T13:34:43.000Z
#include "URDriver_receiver-component.hpp" #include <rtt/Component.hpp> #include <iostream> using namespace RTT; URDriver_receiver::URDriver_receiver(std::string const& name) : TaskContext(name,PreOperational) , port_number(30002) // ali: it was 30002 , prop_address("192.168.1.102") , v6(6,0.0) { addProperty("port_number",port_number); addProperty("robot_address",prop_address); /// robot_mode_value this->provides("robot_mode_value")->doc("Ports giving access to the state of the robot."); this->provides("robot_mode_value")->addPort("isProgramRunning",isProgramRunning); this->provides("robot_mode_value")->addPort("isProgramPaused",isProgramPaused); this->provides("robot_mode_value")->addPort("IsEmergencyStopped",IsEmergencyStopped); addPort("bytes_outport",bytes_outport); data_pointer=URdata::Ptr(new URdataV31()); //q_qctual_outport.setDataSample(v6); act = new RTT::extras::FileDescriptorActivity(os::HighestPriority); this->setActivity(act); act = dynamic_cast<RTT::extras::FileDescriptorActivity*>(this->getActivity()); } bool URDriver_receiver::configureHook(){ sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0){ Logger::In in(this->getName()); log(Error)<<this->getName()<<": not able to open the socket..." << endlog(); return false; } bzero((char *) &serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_port=htons(port_number); //Convert from presentation format to an Internet number if(inet_pton(AF_INET, prop_address.c_str(), &serv_addr.sin_addr)<=0) { Logger::In in(this->getName()); log(Error)<<this->getName()<<":the string "<<prop_address <<" is not a good formatted string for address ( like 127.0.0.1)" << endlog(); ///add log from other file return false; } return true; } bool URDriver_receiver::startHook(){ Logger::In in(this->getName()); if( connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { log(Error)<<this->getName()<<": Connection failed!"<< endlog(); return false; } log(Info)<<this->getName()<<": Connection OK!"<< endlog(); act->watch(sockfd); act->setTimeout(2000); return true; } void URDriver_receiver::updateHook(){ if(act->hasError()){ Logger::In in(this->getName()); log(Error) <<this->getName()<<" socket error - unwatching all sockets. restart the component" << endlog(); act->clearAllWatches(); close(sockfd); this->stop(); this->cleanup(); } else if (act->hasTimeout()){ Logger::In in(this->getName()); log(Error) <<this->getName()<<" socket timeout" << endlog(); } else{ if(act->isUpdated(sockfd)){ int bytes_read= data_pointer->readURdata(sockfd); bytes_outport.write(bytes_read); bool ret; if (data_pointer->getIsProgramRunning(ret)) isProgramRunning.write(ret); if (data_pointer->getIsProgramPaused(ret)) isProgramPaused.write(ret); if (data_pointer->getIsEmergencyStopped(ret)) IsEmergencyStopped.write(ret); } } } void URDriver_receiver::stopHook() { act->clearAllWatches(); close(sockfd); } void URDriver_receiver::cleanupHook() { } /* * Using this macro, only one component may live * in one library *and* you may *not* link this library * with another component library. Use * ORO_CREATE_COMPONENT_TYPE() * ORO_LIST_COMPONENT_TYPE(URDriver_receiver) * In case you want to link with another library that * already contains components. * * If you have put your component class * in a namespace, don't forget to add it here too: */ ORO_CREATE_COMPONENT(URDriver_receiver)
28.36
109
0.711425
AliRoshanbin
75edb62133bc2df4c8124505999a61191d189a78
449
cpp
C++
01-Question_after_WangDao/Chapter_02/2.3/T03.cpp
ysl970629/kaoyan_data_structure
d0a469bf0e9e7040de21eca38dc19961aa7e9a53
[ "MIT" ]
2
2021-03-24T03:29:16.000Z
2022-03-29T16:34:30.000Z
01-Question_after_WangDao/Chapter_02/2.3/T03.cpp
ysl2/kaoyan-data-structure
d0a469bf0e9e7040de21eca38dc19961aa7e9a53
[ "MIT" ]
null
null
null
01-Question_after_WangDao/Chapter_02/2.3/T03.cpp
ysl2/kaoyan-data-structure
d0a469bf0e9e7040de21eca38dc19961aa7e9a53
[ "MIT" ]
null
null
null
// 2020-10-06 #include <iostream> using namespace std; typedef int ElemType; typedef struct LinkNode { ElemType data; struct LinkNode *next; } LinkNode, *LinkList; void printList(LinkList L) { if (L == NULL) return; printList(L->next); cout << L->data << " "; } // ------------------------------------------------------ void recur(LinkList L) { if (L == NULL) return ; recur(L->next); visit(L); }
17.269231
57
0.512249
ysl970629
75f318d301b96a725a04117946d4ccb556f1e250
722
cpp
C++
10-regular-expression-matching/10-regular-expression-matching.cpp
SouvikChan/-Leetcode_Souvik
cc4b72cb4a14a1c6b8be8bd8390de047443fe008
[ "MIT" ]
null
null
null
10-regular-expression-matching/10-regular-expression-matching.cpp
SouvikChan/-Leetcode_Souvik
cc4b72cb4a14a1c6b8be8bd8390de047443fe008
[ "MIT" ]
null
null
null
10-regular-expression-matching/10-regular-expression-matching.cpp
SouvikChan/-Leetcode_Souvik
cc4b72cb4a14a1c6b8be8bd8390de047443fe008
[ "MIT" ]
null
null
null
class Solution { public: bool isMatch(string s, string p) { vector<vector<int>> dp(s.length()+1,vector<int>(p.length()+1,0)); dp[s.length()][p.length()]=1; for(int i=s.length();i>=0;i--) { for(int j=p.length()-1;j>=0;j--) { bool first_match=(i<s.length() && (p[j]==s[i]|| p[j]=='.')); if(j+1<p.length() && p[j+1]=='*') { dp[i][j]=dp[i][j+2] || (first_match && dp[i+1][j]); } else { dp[i][j]=first_match && dp[i+1][j+1]; } } } return dp[0][0]; } };
28.88
76
0.33518
SouvikChan
75f4b354b893e8deb3a0a69f8a37ee920203c5cc
422
hpp
C++
asyncio/loop/future.hpp
zhanglix/asyncio
6415e1510bf582b915e74a0b9ba0b66905da250d
[ "MIT" ]
36
2017-07-22T06:08:38.000Z
2022-03-23T10:04:31.000Z
asyncio/loop/future.hpp
zhanglix/asyncio
6415e1510bf582b915e74a0b9ba0b66905da250d
[ "MIT" ]
1
2021-01-17T08:41:50.000Z
2021-01-20T19:58:02.000Z
asyncio/loop/future.hpp
zhanglix/asyncio
6415e1510bf582b915e74a0b9ba0b66905da250d
[ "MIT" ]
8
2017-07-28T13:26:12.000Z
2021-01-20T06:45:39.000Z
#pragma once #include <asyncio/common.hpp> #include <functional> #include "handle_base.hpp" BEGIN_ASYNCIO_NAMESPACE; class FutureBase : public BasicHandle { public: virtual void release() = 0; using DoneCallback = std::function<void(FutureBase *)>; virtual void setDoneCallback(DoneCallback) = 0; }; template <class R> class Future : public FutureBase { public: virtual R get() = 0; }; END_ASYNCIO_NAMESPACE;
19.181818
57
0.739336
zhanglix
75f69b2661f8576081c31aa2bc7a13c51bc88073
1,352
hpp
C++
include/networkit/community/OverlappingCommunityDetectionAlgorithm.hpp
angriman/network
3a4c5fd32eb2be8d5b34eaee17f8fe4e6e141894
[ "MIT" ]
366
2019-06-27T18:48:18.000Z
2022-03-29T08:36:49.000Z
include/networkit/community/OverlappingCommunityDetectionAlgorithm.hpp
angriman/network
3a4c5fd32eb2be8d5b34eaee17f8fe4e6e141894
[ "MIT" ]
387
2019-06-24T11:30:39.000Z
2022-03-31T10:37:28.000Z
include/networkit/community/OverlappingCommunityDetectionAlgorithm.hpp
angriman/network
3a4c5fd32eb2be8d5b34eaee17f8fe4e6e141894
[ "MIT" ]
131
2019-07-04T15:40:13.000Z
2022-03-29T12:34:23.000Z
/* * OverlappingCommunityDetectionAlgorithm.hpp * * Created on: 14.12.2020 * Author: John Gelhausen */ #ifndef NETWORKIT_COMMUNITY_OVERLAPPING_COMMUNITY_DETECTION_ALGORITHM_HPP_ #define NETWORKIT_COMMUNITY_OVERLAPPING_COMMUNITY_DETECTION_ALGORITHM_HPP_ #include <networkit/base/Algorithm.hpp> #include <networkit/graph/Graph.hpp> #include <networkit/structures/Cover.hpp> namespace NetworKit { /** * @ingroup community * Abstract base class for overlapping community detection/graph clustering algorithms. */ class OverlappingCommunityDetectionAlgorithm : public Algorithm { public: /** * An overlapping community detection algorithm operates on a graph, so the constructor expects * a graph. * * @param[in] G input graph */ OverlappingCommunityDetectionAlgorithm(const Graph &G); /** Default destructor */ ~OverlappingCommunityDetectionAlgorithm() override = default; /** * Apply algorithm to graph */ void run() override = 0; /** * Returns the result of the run method or throws an error, if the algorithm hasn't run yet. * @return cover of the node set */ const Cover &getCover() const; protected: const Graph *G; Cover result; }; } /* namespace NetworKit */ #endif // NETWORKIT_COMMUNITY_OVERLAPPING_COMMUNITY_DETECTION_ALGORITHM_HPP_
26
99
0.727071
angriman
75ffdaa1b2a817749cdd23bc8795114f24a269e1
2,085
cpp
C++
src/main.cpp
jasonwnorris/QuadTree
6ddca00e047d05badd3143804a79652b20db599d
[ "MIT" ]
null
null
null
src/main.cpp
jasonwnorris/QuadTree
6ddca00e047d05badd3143804a79652b20db599d
[ "MIT" ]
null
null
null
src/main.cpp
jasonwnorris/QuadTree
6ddca00e047d05badd3143804a79652b20db599d
[ "MIT" ]
null
null
null
// main.cpp #include <SDL2\SDL.h> #include <iostream> #include <time.h> #include "QuadTree.hpp" int main(int argc, char** argv) { srand(static_cast<unsigned int>(time(nullptr))); SDL_Init(SDL_INIT_EVERYTHING); SDL_Window* window = SDL_CreateWindow("QuadTree", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WindowFlags::SDL_WINDOW_SHOWN); SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RendererFlags::SDL_RENDERER_ACCELERATED); const float qtWidth = 800.0f; const float qtHeight = 600.0f; const float qtRange = 25.0f; const int count = 50; Object objs[count]; Rectangle rects[count]; for (int i = 0; i < count; ++i) { int value = rand() % 100; float left = (rand() % 1000) / 1000.0f * (qtWidth - qtRange); float top = (rand() % 1000) / 1000.0f * (qtHeight - qtRange); float width = (rand() % 1000) / 1000.0f * (qtWidth - left); float height = (rand() % 1000) / 1000.0f * (qtHeight - top); objs[i] = Object(value); rects[i] = Rectangle(left, top, left + width, top + height); } QuadTree quadtree(Rectangle(0.0f, qtHeight, 0.0f, qtWidth)); for (int i = 0; i < count; ++i) { if (!quadtree.Insert(&rects[i], &objs[i])) { std::cout << "Rectangle[" << i << "] was too large to fit into the QuadTree." << std::endl; } } bool isRunning = true; while (isRunning) { SDL_Event e; while (SDL_PollEvent(&e)) { switch (e.type) { case SDL_QUIT: isRunning = false; break; case SDL_KEYDOWN: switch (e.key.keysym.sym) { case SDLK_ESCAPE: isRunning = true; break; default: break; } break; case SDL_KEYUP: switch (e.key.keysym.sym) { case SDLK_ESCAPE: isRunning = true; break; default: break; } break; default: break; } } SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); SDL_RenderClear(renderer); quadtree.Render(renderer); SDL_RenderPresent(renderer); } SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); SDL_Quit(); return 0; }
21.494845
144
0.630216
jasonwnorris
2f007aca3a6857d2c0c414c3c9583d1a3bf14ad2
1,891
hpp
C++
src/objects/Pokemon.hpp
MrtnNmck/Pokemon-3D
50451f91999fe9168e8f520748e39b7e9099624a
[ "Apache-2.0" ]
4
2017-08-25T10:55:44.000Z
2018-05-30T06:39:23.000Z
src/objects/Pokemon.hpp
MrtnNmck/Pokemon-3D
50451f91999fe9168e8f520748e39b7e9099624a
[ "Apache-2.0" ]
1
2021-09-14T10:52:03.000Z
2021-09-14T10:52:03.000Z
src/objects/Pokemon.hpp
MrtnNmck/Pokemon-3D
50451f91999fe9168e8f520748e39b7e9099624a
[ "Apache-2.0" ]
null
null
null
// // Created by Martin on 30. 11. 2015. // #ifndef POKEMON3D_POKEMON_HPP #define POKEMON3D_POKEMON_HPP #include <random> #include "src/objects/MainCharacter.h" #include "src/objects/Attack.hpp" #include "src/animations/Animation.hpp" class Pokemon : public MainCharacter { protected: // TODO: v MainCharacter zmenit funkciu checkInput() na virtualnu a vytvorit novu class Player pre hlavnu postavu void checkInputs(); void generateAttacks(int count, Scene &scene); AttackPtr attackObj; float attackDelay = 0.0f; bool canAttack = true; bool wasAttacked = false; public: unsigned short id; Pokemon(unsigned short id, LoaderPtr loader, const std::string &, const std::string &, glm::vec3 position, float rotX, float rotY, float rotZ, float scale, InputManager *inputManager, const std::string &attack_obj_file, const std::string &attack_image_name, bool canAttackAtStart); Pokemon(unsigned short id, LoaderPtr loader, const std::string &, const std::string &, glm::vec3 position, float rotX, float rotY, float rotZ, float scale, float reflectivity, float shineDamper, InputManager *inputManager, const std::string &attack_obj_file, const std::string &attack_image_name, bool canAttackAtStart); Pokemon(unsigned short id, LoaderPtr loader, MeshPtr, glm::vec3 position, float rotX, float rotY, float rotZ, float scale, float reflectivity, float shineDamper, InputManager *inputManager, const std::string &attack_obj_file, const std::string &attack_image_name, bool canAttackAtStart); SceneType animate(Scene &scene, float delta) override; void attack(Scene &scene); int maxHp = 1; int currentHp = 1; glm::vec3 startingPos; AnimationPtr animation; ~Pokemon(){} }; typedef std::shared_ptr<Pokemon> PokemonPtr; #endif //POKEMON3D_POKEMON_HPP
36.365385
122
0.720783
MrtnNmck
2f07e3a0ae955df41c302afc414f072f60c30670
41,398
cpp
C++
src/ssGUI/Extensions/Dockable.cpp
Neko-Box-Coder/ssGUI
25e218fd79fea105a30737a63381cf8d0be943f6
[ "Apache-2.0" ]
15
2022-01-21T10:48:04.000Z
2022-03-27T17:55:11.000Z
src/ssGUI/Extensions/Dockable.cpp
Neko-Box-Coder/ssGUI
25e218fd79fea105a30737a63381cf8d0be943f6
[ "Apache-2.0" ]
null
null
null
src/ssGUI/Extensions/Dockable.cpp
Neko-Box-Coder/ssGUI
25e218fd79fea105a30737a63381cf8d0be943f6
[ "Apache-2.0" ]
4
2022-01-21T10:48:05.000Z
2022-01-22T15:42:34.000Z
#include "ssGUI/Extensions/Dockable.hpp" #include "ssGUI/ssGUITags.hpp" #include "ssGUI/Extensions/AdvancedPosition.hpp" #include "ssGUI/Extensions/AdvancedSize.hpp" #include "ssGUI/Extensions/Layout.hpp" #include "ssGUI/Extensions/Docker.hpp" #include "ssGUI/EventCallbacks/WindowDragStateChangedEventCallback.hpp" namespace ssGUI::Extensions { bool Dockable::GlobalDockMode = false; ssGUI::MainWindow* Dockable::MainWindowUnderDocking = nullptr; ssGUI::GUIObject* Dockable::DockingTopLevelParent = nullptr; ssGUI::GUIObject* Dockable::TargetDockObject = nullptr; Dockable::DockSide Dockable::TargetDockSide = Dockable::DockSide::NONE; Dockable::Dockable() : Container(nullptr), Enabled(true), TopLevelParent(-1), CurrentObjectsReferences(), UseTriggerPercentage(true), TriggerPercentage(0.25f), TriggerPixel(15), TriggerAreaColor(glm::u8vec4(87, 207, 255, 127)), DockPreviewColor(glm::u8vec4(255, 255, 255, 127)), OriginalParent(nullptr), ContainerIsDocking(false), DockPreivewTop(nullptr), DockPreivewRight(nullptr), DockPreivewBottom(nullptr), DockPreivewLeft(nullptr), DockTriggerTop(nullptr), DockTriggerRight(nullptr), DockTriggerBottom(nullptr), DockTriggerLeft(nullptr) {} Dockable::~Dockable() { if(Container != nullptr && Container->IsEventCallbackExist(ssGUI::EventCallbacks::WindowDragStateChangedEventCallback::EVENT_NAME)) { Container->GetEventCallback(ssGUI::EventCallbacks::WindowDragStateChangedEventCallback::EVENT_NAME)-> RemoveEventListener(EXTENSION_NAME); if(Container->GetEventCallback(ssGUI::EventCallbacks::WindowDragStateChangedEventCallback::EVENT_NAME)-> GetEventListenerCount() == 0) { Container->RemoveEventCallback(ssGUI::EventCallbacks::WindowDragStateChangedEventCallback::EVENT_NAME); } } DiscardTriggerAreas(); DiscardLeftPreview(); DiscardRightPreview(); DiscardTopPreview(); DiscardBottomPreview(); CurrentObjectsReferences.CleanUp(); } Dockable::Dockable(Dockable const& other) { Container = nullptr; Enabled = other.IsEnabled(); TopLevelParent = other.TopLevelParent; CurrentObjectsReferences = other.CurrentObjectsReferences; UseTriggerPercentage = other.IsUseTriggerPercentage(); TriggerPercentage = other.GetTriggerPercentage(); TriggerPixel = other.GetTriggerPixel(); TriggerAreaColor = other.GetTriggerAreaColor(); DockPreviewColor = other.GetDockPreviewColor(); OriginalParent = nullptr; ContainerIsDocking = false; DockPreivewTop = nullptr; DockPreivewRight = nullptr; DockPreivewBottom = nullptr; DockPreivewLeft = nullptr; DockTriggerTop = nullptr; DockTriggerRight = nullptr; DockTriggerBottom = nullptr; DockTriggerLeft = nullptr; } void Dockable::ConstructRenderInfo() {} void Dockable::ConstructRenderInfo(ssGUI::Backend::BackendDrawingInterface* drawingInterface, ssGUI::GUIObject* mainWindow, glm::vec2 mainWindowPositionOffset) {} void Dockable::CreateWidgetIfNotPresent(ssGUI::GUIObject** widget, glm::u8vec4 color) { FUNC_DEBUG_ENTRY(); //If widget is not present, create it if((*widget) == nullptr) { (*widget) = new ssGUI::Widget(); (*widget)->SetUserCreated(false); (*widget)->SetHeapAllocated(true); static_cast<ssGUI::Widget*>((*widget))->SetInteractable(false); static_cast<ssGUI::Widget*>((*widget))->SetBlockInput(false); auto ap = ssGUI::Factory::Create<ssGUI::Extensions::AdvancedPosition>(); auto as = ssGUI::Factory::Create<ssGUI::Extensions::AdvancedSize>(); (*widget)->AddExtension(ap); (*widget)->AddExtension(as); (*widget)->AddTag(ssGUI::Tags::OVERLAY); (*widget)->SetBackgroundColor(color); } if((*widget)->GetParent() != Container) (*widget)->SetParent(Container); FUNC_DEBUG_EXIT(); } void Dockable::DrawLeftPreview() { FUNC_DEBUG_ENTRY(); CreateWidgetIfNotPresent(&DockPreivewLeft, GetDockPreviewColor()); //Set the correct position and size ssGUI::Extensions::AdvancedPosition* ap = static_cast<ssGUI::Extensions::AdvancedPosition*>(DockPreivewLeft->GetExtension(ssGUI::Extensions::AdvancedPosition::EXTENSION_NAME)); ssGUI::Extensions::AdvancedSize* as = static_cast<ssGUI::Extensions::AdvancedSize*>(DockPreivewLeft->GetExtension(ssGUI::Extensions::AdvancedSize::EXTENSION_NAME)); ap->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::LEFT); ap->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::CENTER); as->SetHorizontalUsePercentage(true); as->SetVerticalUsePercentage(true); as->SetHorizontalPercentage(0.5); as->SetVerticalPercentage(1); FUNC_DEBUG_EXIT(); } void Dockable::DrawTopPreview() { FUNC_DEBUG_ENTRY(); CreateWidgetIfNotPresent(&DockPreivewTop, GetDockPreviewColor()); //Set the correct position and size ssGUI::Extensions::AdvancedPosition* ap = static_cast<ssGUI::Extensions::AdvancedPosition*>(DockPreivewTop->GetExtension(ssGUI::Extensions::AdvancedPosition::EXTENSION_NAME)); ssGUI::Extensions::AdvancedSize* as = static_cast<ssGUI::Extensions::AdvancedSize*>(DockPreivewTop->GetExtension(ssGUI::Extensions::AdvancedSize::EXTENSION_NAME)); ap->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::CENTER); ap->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::TOP); as->SetHorizontalUsePercentage(true); as->SetVerticalUsePercentage(true); as->SetHorizontalPercentage(1); as->SetVerticalPercentage(0.5); FUNC_DEBUG_EXIT(); } void Dockable::DrawRightPreview() { FUNC_DEBUG_ENTRY(); CreateWidgetIfNotPresent(&DockPreivewRight, GetDockPreviewColor()); //Set the correct position and size ssGUI::Extensions::AdvancedPosition* ap = static_cast<ssGUI::Extensions::AdvancedPosition*>(DockPreivewRight->GetExtension(ssGUI::Extensions::AdvancedPosition::EXTENSION_NAME)); ssGUI::Extensions::AdvancedSize* as = static_cast<ssGUI::Extensions::AdvancedSize*>(DockPreivewRight->GetExtension(ssGUI::Extensions::AdvancedSize::EXTENSION_NAME)); ap->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::RIGHT); ap->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::CENTER); as->SetHorizontalUsePercentage(true); as->SetVerticalUsePercentage(true); as->SetHorizontalPercentage(0.5); as->SetVerticalPercentage(1); FUNC_DEBUG_EXIT(); } void Dockable::DrawBottomPreview() { FUNC_DEBUG_ENTRY(); CreateWidgetIfNotPresent(&DockPreivewBottom, GetDockPreviewColor()); //Set the correct position and size ssGUI::Extensions::AdvancedPosition* ap = static_cast<ssGUI::Extensions::AdvancedPosition*>(DockPreivewBottom->GetExtension(ssGUI::Extensions::AdvancedPosition::EXTENSION_NAME)); ssGUI::Extensions::AdvancedSize* as = static_cast<ssGUI::Extensions::AdvancedSize*>(DockPreivewBottom->GetExtension(ssGUI::Extensions::AdvancedSize::EXTENSION_NAME)); ap->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::CENTER); ap->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::BOTTOM); as->SetHorizontalUsePercentage(true); as->SetVerticalUsePercentage(true); as->SetHorizontalPercentage(1); as->SetVerticalPercentage(0.5); FUNC_DEBUG_EXIT(); } void Dockable::DiscardLeftPreview() { if(DockPreivewLeft != nullptr) { DockPreivewLeft->Delete(); DockPreivewLeft = nullptr; } } void Dockable::DiscardTopPreview() { if(DockPreivewTop != nullptr) { DockPreivewTop->Delete(); DockPreivewTop = nullptr; } } void Dockable::DiscardRightPreview() { if(DockPreivewRight != nullptr) { DockPreivewRight->Delete(); DockPreivewRight = nullptr; } } void Dockable::DiscardBottomPreview() { if(DockPreivewBottom != nullptr) { DockPreivewBottom->Delete(); DockPreivewBottom = nullptr; } } void Dockable::DrawTriggerAreas() { //return; FUNC_DEBUG_ENTRY(); CreateWidgetIfNotPresent(&DockTriggerTop, GetTriggerAreaColor()); CreateWidgetIfNotPresent(&DockTriggerRight, GetTriggerAreaColor()); CreateWidgetIfNotPresent(&DockTriggerBottom, GetTriggerAreaColor()); CreateWidgetIfNotPresent(&DockTriggerLeft, GetTriggerAreaColor()); //Set the correct position and size ssGUI::Extensions::AdvancedPosition* apTop = static_cast<ssGUI::Extensions::AdvancedPosition*>(DockTriggerTop->GetExtension(ssGUI::Extensions::AdvancedPosition::EXTENSION_NAME)); ssGUI::Extensions::AdvancedSize* asTop = static_cast<ssGUI::Extensions::AdvancedSize*>(DockTriggerTop->GetExtension(ssGUI::Extensions::AdvancedSize::EXTENSION_NAME)); ssGUI::Extensions::AdvancedPosition* apRight = static_cast<ssGUI::Extensions::AdvancedPosition*>(DockTriggerRight->GetExtension(ssGUI::Extensions::AdvancedPosition::EXTENSION_NAME)); ssGUI::Extensions::AdvancedSize* asRight = static_cast<ssGUI::Extensions::AdvancedSize*>(DockTriggerRight->GetExtension(ssGUI::Extensions::AdvancedSize::EXTENSION_NAME)); ssGUI::Extensions::AdvancedPosition* apBottom = static_cast<ssGUI::Extensions::AdvancedPosition*>(DockTriggerBottom->GetExtension(ssGUI::Extensions::AdvancedPosition::EXTENSION_NAME)); ssGUI::Extensions::AdvancedSize* asBottom = static_cast<ssGUI::Extensions::AdvancedSize*>(DockTriggerBottom->GetExtension(ssGUI::Extensions::AdvancedSize::EXTENSION_NAME)); ssGUI::Extensions::AdvancedPosition* apLeft = static_cast<ssGUI::Extensions::AdvancedPosition*>(DockTriggerLeft->GetExtension(ssGUI::Extensions::AdvancedPosition::EXTENSION_NAME)); ssGUI::Extensions::AdvancedSize* asLeft = static_cast<ssGUI::Extensions::AdvancedSize*>(DockTriggerLeft->GetExtension(ssGUI::Extensions::AdvancedSize::EXTENSION_NAME)); asTop->SetHorizontalUsePercentage(UseTriggerPercentage); asTop->SetVerticalUsePercentage(UseTriggerPercentage); asRight->SetHorizontalUsePercentage(UseTriggerPercentage); asRight->SetVerticalUsePercentage(UseTriggerPercentage); asBottom->SetHorizontalUsePercentage(UseTriggerPercentage); asBottom->SetVerticalUsePercentage(UseTriggerPercentage); asLeft->SetHorizontalUsePercentage(UseTriggerPercentage); asLeft->SetVerticalUsePercentage(UseTriggerPercentage); if(UseTriggerPercentage) { apTop->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::CENTER); apTop->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::TOP); asTop->SetHorizontalPercentage(1 - GetTriggerPercentage() * 2); asTop->SetVerticalPercentage(GetTriggerPercentage()); apRight->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::RIGHT); apRight->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::CENTER); asRight->SetHorizontalPercentage(GetTriggerPercentage()); asRight->SetVerticalPercentage(1 - GetTriggerPercentage() * 2); apBottom->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::CENTER); apBottom->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::BOTTOM); asBottom->SetHorizontalPercentage(1 - GetTriggerPercentage() * 2); asBottom->SetVerticalPercentage(GetTriggerPercentage()); apLeft->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::LEFT); apLeft->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::CENTER); asLeft->SetHorizontalPercentage(GetTriggerPercentage()); asLeft->SetVerticalPercentage(1 - GetTriggerPercentage() * 2); } else { apTop->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::CENTER); apTop->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::TOP); asTop->SetHorizontalPixel(Container->GetSize().x - GetTriggerPixel() * 2); asTop->SetVerticalPixel(GetTriggerPixel()); apRight->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::RIGHT); apRight->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::CENTER); asRight->SetHorizontalPixel(GetTriggerPixel()); asRight->SetVerticalPixel(Container->GetSize().y - GetTriggerPixel() * 2); apBottom->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::CENTER); apBottom->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::BOTTOM); asBottom->SetHorizontalPixel(Container->GetSize().x - GetTriggerPixel() * 2); asBottom->SetVerticalPixel(GetTriggerPercentage()); apLeft->SetHorizontalAnchor(ssGUI::Extensions::AdvancedPosition::HorizontalAnchor::LEFT); apLeft->SetVerticalAnchor(ssGUI::Extensions::AdvancedPosition::VerticalAnchor::CENTER); asLeft->SetHorizontalPixel(GetTriggerPixel()); asLeft->SetVerticalPixel(Container->GetSize().y - GetTriggerPixel() * 2); } FUNC_DEBUG_EXIT(); } //TODO : Add mutex for multi-threading support void Dockable::OnWindowDragStarted() { FUNC_DEBUG_ENTRY(); ContainerIsDocking = true; GlobalDockMode = true; //Find the Main Window ssGUI::GUIObject* curParent = TopLevelParent == -1 || CurrentObjectsReferences.GetObjectReference(TopLevelParent) == nullptr ? Container->GetParent() : CurrentObjectsReferences.GetObjectReference(TopLevelParent); while (curParent->GetType() != ssGUI::Enums::GUIObjectType::MAIN_WINDOW && curParent != nullptr) { curParent = curParent->GetParent(); } //If this has no parent. Docking is disabled if(curParent == nullptr) { ContainerIsDocking = false; GlobalDockMode = false; OriginalParent = nullptr; MainWindowUnderDocking = nullptr; DockingTopLevelParent = nullptr; FUNC_DEBUG_EXIT(); return; } MainWindowUnderDocking = static_cast<ssGUI::MainWindow*>(curParent); Container->AddTag(ssGUI::Tags::FLOATING); ssGUI::GUIObject* containerParent = Container->GetParent(); //Docking mechanism //Check if container is docked under docker. If so, set the size for the child after container to fill the gap if(containerParent->IsExtensionExist(ssGUI::Extensions::Layout::EXTENSION_NAME) && containerParent->GetChildrenCount() > 1) { containerParent->StashChildrenIterator(); containerParent->FindChild(Container); if(!containerParent->IsChildrenIteratorLast()) { containerParent->MoveChildrenIteratorNext(); glm::vec2 childSize = containerParent->GetCurrentChild()->GetSize(); if(static_cast<ssGUI::Extensions::Layout*>(containerParent->GetExtension(ssGUI::Extensions::Layout::EXTENSION_NAME))->IsHorizontalLayout()) containerParent->GetCurrentChild()->SetSize(glm::vec2(childSize.x + Container->GetSize().x, childSize.y)); else containerParent->GetCurrentChild()->SetSize(glm::vec2(childSize.x, childSize.y + Container->GetSize().y)); } containerParent->PopChildrenIterator(); } //Parent the container to the MainWindow. OriginalParent = Container->GetParent(); if(TopLevelParent == -1 || CurrentObjectsReferences.GetObjectReference(TopLevelParent) == nullptr) { Container->SetParent(MainWindowUnderDocking); DockingTopLevelParent = MainWindowUnderDocking; } else { Container->SetParent(CurrentObjectsReferences.GetObjectReference(TopLevelParent)); DockingTopLevelParent = CurrentObjectsReferences.GetObjectReference(TopLevelParent); } FUNC_DEBUG_EXIT(); } void Dockable::FindDockLayout(ssGUI::Extensions::Layout*& dockLayout) { FUNC_DEBUG_ENTRY(); ssGUI::Extensions::Layout* parentLayout = static_cast<ssGUI::Extensions::Layout*>(TargetDockObject->GetParent()->GetExtension(ssGUI::Extensions::Layout::EXTENSION_NAME)); if(TargetDockObject->GetParent()->GetChildrenCount() > 1) { if(parentLayout->IsHorizontalLayout() && (TargetDockSide == DockSide::LEFT || TargetDockSide == DockSide::RIGHT)) dockLayout = parentLayout; else if(!parentLayout->IsHorizontalLayout() && (TargetDockSide == DockSide::TOP || TargetDockSide == DockSide::BOTTOM)) dockLayout = parentLayout; } else { if(TargetDockSide == DockSide::LEFT || TargetDockSide == DockSide::RIGHT) parentLayout->SetHorizontalLayout(true); else parentLayout->SetHorizontalLayout(false); dockLayout = parentLayout; } FUNC_DEBUG_EXIT(); } void Dockable::CreateEmptyParentForDocking(ssGUI::Extensions::Layout*& dockLayout) { FUNC_DEBUG_ENTRY(); ssGUI::Window* newParent = nullptr; if(ssGUI::Extensions::Docker::GetDefaultGeneratedDockerWindow() == nullptr) newParent = new ssGUI::Window(); else newParent = static_cast<ssGUI::Window*>(ssGUI::Extensions::Docker::GetDefaultGeneratedDockerWindow()->Clone(true)); newParent->SetUserCreated(false); newParent->SetHeapAllocated(true); newParent->SetSize(TargetDockObject->GetSize()); newParent->SetAnchorType(TargetDockObject->GetAnchorType()); newParent->SetPosition(TargetDockObject->GetPosition()); newParent->SetParent(TargetDockObject->GetParent()); //The docker will automatically create docker & layout extension if not exist if(!newParent->IsExtensionExist(ssGUI::Extensions::Docker::EXTENSION_NAME)) { newParent->AddExtension(ssGUI::Factory::Create<ssGUI::Extensions::Docker>()); dockLayout = static_cast<ssGUI::Extensions::Layout*>(newParent->GetExtension(ssGUI::Extensions::Layout::EXTENSION_NAME)); } if(!newParent->IsExtensionExist(ssGUI::Extensions::Layout::EXTENSION_NAME)) newParent->AddExtension(ssGUI::Factory::Create<ssGUI::Extensions::Layout>()); //Check if the generated docker does not use parent docker & layout or not. if(newParent->GetParent()->IsExtensionExist(ssGUI::Extensions::Docker::EXTENSION_NAME) && static_cast<ssGUI::Extensions::Docker*>(newParent->GetParent()->GetExtension(ssGUI::Extensions::Docker::EXTENSION_NAME))->IsChildrenDockerUseThisSettings() && static_cast<ssGUI::Extensions::Docker*>(newParent->GetParent()->GetExtension(ssGUI::Extensions::Docker::EXTENSION_NAME))->IsEnabled()) { auto parentDocker = static_cast<ssGUI::Extensions::Docker*>(newParent->GetParent()->GetExtension(ssGUI::Extensions::Docker::EXTENSION_NAME)); newParent->GetExtension(ssGUI::Extensions::Docker::EXTENSION_NAME)->Copy(parentDocker); if(newParent->GetParent()->IsExtensionExist(ssGUI::Extensions::Layout::EXTENSION_NAME) && static_cast<ssGUI::Extensions::Docker*>(newParent->GetParent()->GetExtension(ssGUI::Extensions::Layout::EXTENSION_NAME))->IsEnabled()) { auto parentLayout = static_cast<ssGUI::Extensions::Docker*>(newParent->GetParent()->GetExtension(ssGUI::Extensions::Layout::EXTENSION_NAME)); newParent->GetExtension(ssGUI::Extensions::Layout::EXTENSION_NAME)->Copy(parentLayout); } } //Then change the Layout orientation to the same as the docking orientation if(TargetDockSide == DockSide::LEFT || TargetDockSide == DockSide::RIGHT) dockLayout->SetHorizontalLayout(true); else dockLayout->SetHorizontalLayout(false); //If not floating, turn window to invisible if(TargetDockObject->GetParent()->IsExtensionExist(ssGUI::Extensions::Docker::EXTENSION_NAME) && TargetDockObject->GetParent()->GetExtension(ssGUI::Extensions::Docker::EXTENSION_NAME)->IsEnabled()) { newParent->SetTitlebar(false); auto newBGColor = newParent->GetBackgroundColor(); newBGColor.a = 0; newParent->SetBackgroundColor(newBGColor); newParent->SetResizeType(ssGUI::Enums::ResizeType::NONE); //Disable all extensions except docker, assuming all extensions are enabled by default (When default is not overriden) if(ssGUI::Extensions::Docker::GetDefaultGeneratedDockerWindow() == nullptr) { auto allExtensions = newParent->GetListOfExtensions(); for(auto extension : allExtensions) { if(extension->GetExtensionName() == ssGUI::Extensions::Docker::EXTENSION_NAME || extension->GetExtensionName() == ssGUI::Extensions::Layout::EXTENSION_NAME) { continue; } extension->SetEnabled(false); } // newParent->RemoveExtension(ssGUI::Extensions::Border::EXTENSION_NAME); } //Set all the children to be not visible since it is not floating newParent->StashChildrenIterator(); newParent->MoveChildrenIteratorToFirst(); while(!newParent->IsChildrenIteratorEnd()) { newParent->GetCurrentChild()->SetVisible(false); newParent->MoveChildrenIteratorNext(); } newParent->PopChildrenIterator(); } //Restore order TargetDockObject->GetParent()->StashChildrenIterator(); TargetDockObject->GetParent()->FindChild(TargetDockObject); std::list<ssGUIObjectIndex>::iterator dockObjectIt = TargetDockObject->GetParent()->GetCurrentChildReferenceIterator(); TargetDockObject->GetParent()->MoveChildrenIteratorToLast(); std::list<ssGUIObjectIndex>::iterator lastIt = TargetDockObject->GetParent()->GetCurrentChildReferenceIterator(); TargetDockObject->GetParent()->ChangeChildOrderToBeforePosition(lastIt, dockObjectIt); TargetDockObject->SetParent(newParent); //Setting a new parent from the dock will causes it to revert to original size. //Therefore will need to set the size to match the new parent again. TargetDockObject->SetSize(newParent->GetSize()); TargetDockObject->GetParent()->PopChildrenIterator(); FUNC_DEBUG_EXIT(); } //TODO: Check top level parent for up coming docking via code feature void Dockable::OnWindowDragFinished() { FUNC_DEBUG_ENTRY(); //Remove the floating tag to allow docking Container->RemoveTag(ssGUI::Tags::FLOATING); //Docking mechanism for dockable window if(TargetDockObject != nullptr && TargetDockObject->GetParent() != nullptr && TargetDockSide != DockSide::NONE) { //If it is just docker, just need to add it as a child if(TargetDockObject->IsExtensionExist(ssGUI::Extensions::Docker::EXTENSION_NAME)) { Container->SetParent(TargetDockObject); goto reset; } //Otherwise dock as normal ssGUI::Extensions::Layout* dockLayout = nullptr; //Check if the parent of the targetDockObject has the Docker extension if(TargetDockObject->GetParent()->IsExtensionExist(ssGUI::Extensions::Layout::EXTENSION_NAME) && TargetDockObject->GetParent()->IsExtensionExist(ssGUI::Extensions::Docker::EXTENSION_NAME)) FindDockLayout(dockLayout); //Create an empty parent and add Layout extension if dock layout isn't found if(dockLayout == nullptr) CreateEmptyParentForDocking(dockLayout); //This inserts the container to the end. Halfing the size for TargetDockObject and Container so they fit the original space TargetDockObject->SetSize(glm::vec2(TargetDockObject->GetSize().x * 0.5, TargetDockObject->GetSize().y * 0.5)); glm::vec2 newContainerSize = TargetDockObject->GetSize(); Container->SetParent(TargetDockObject->GetParent()); Container->SetSize(newContainerSize); //Insert the Container after/before it TargetDockObject->GetParent()->StashChildrenIterator(); TargetDockObject->GetParent()->FindChild(TargetDockObject); std::list<ssGUIObjectIndex>::iterator dockObjectIt = TargetDockObject->GetParent()->GetCurrentChildReferenceIterator(); TargetDockObject->GetParent()->MoveChildrenIteratorToLast(); std::list<ssGUIObjectIndex>::iterator lastIt = TargetDockObject->GetParent()->GetCurrentChildReferenceIterator(); TargetDockObject->GetParent()->PopChildrenIterator(); if(!dockLayout->IsReverseOrder()) { //Before if(TargetDockSide == DockSide::LEFT || TargetDockSide == DockSide::TOP) TargetDockObject->GetParent()->ChangeChildOrderToBeforePosition(lastIt, dockObjectIt); //After else TargetDockObject->GetParent()->ChangeChildOrderToAfterPosition(lastIt, dockObjectIt); } else { //Before if(TargetDockSide == DockSide::RIGHT || TargetDockSide == DockSide::BOTTOM) TargetDockObject->GetParent()->ChangeChildOrderToBeforePosition(lastIt, dockObjectIt); //After else TargetDockObject->GetParent()->ChangeChildOrderToAfterPosition(lastIt, dockObjectIt); } } reset: //Reset docking variables OriginalParent = nullptr; ContainerIsDocking = false; GlobalDockMode = false; MainWindowUnderDocking = nullptr; DockingTopLevelParent = nullptr; TargetDockObject = nullptr; TargetDockSide = DockSide::NONE; FUNC_DEBUG_EXIT(); } void Dockable::DiscardTriggerAreas() { if(DockTriggerTop != nullptr) { DockTriggerTop->Delete(); DockTriggerTop = nullptr; } if(DockTriggerRight != nullptr) { DockTriggerRight->Delete(); DockTriggerRight = nullptr; } if(DockTriggerBottom != nullptr) { DockTriggerBottom->Delete(); DockTriggerBottom = nullptr; } if(DockTriggerLeft != nullptr) { DockTriggerLeft->Delete(); DockTriggerLeft = nullptr; } } const std::string Dockable::EXTENSION_NAME = "Dockable"; void Dockable::SetTriggerPercentage(float percentage) { TriggerPercentage = percentage; } float Dockable::GetTriggerPercentage() const { return TriggerPercentage; } void Dockable::SetTriggerPixel(int pixel) { TriggerPixel = pixel; } int Dockable::GetTriggerPixel() const { return TriggerPixel; } void Dockable::SetUseTriggerPercentage(bool usePercentage) { UseTriggerPercentage = usePercentage; } bool Dockable::IsUseTriggerPercentage() const { return UseTriggerPercentage; } void Dockable::SetTriggerAreaColor(glm::u8vec4 color) { TriggerAreaColor = color; } glm::u8vec4 Dockable::GetTriggerAreaColor() const { return TriggerAreaColor; } void Dockable::SetDockPreviewColor(glm::u8vec4 color) { DockPreviewColor = color; } glm::u8vec4 Dockable::GetDockPreviewColor() const { return DockPreviewColor; } void Dockable::SetTopLevelParent(ssGUI::GUIObject* parent) { if(parent != nullptr) { if(TopLevelParent != -1 && CurrentObjectsReferences.GetObjectReference(TopLevelParent) != nullptr) CurrentObjectsReferences.SetObjectReference(TopLevelParent, parent); else TopLevelParent = CurrentObjectsReferences.AddObjectReference(parent); } else TopLevelParent = -1; } ssGUI::GUIObject* Dockable::GetTopLevelParent() const { if(TopLevelParent != -1 && CurrentObjectsReferences.GetObjectReference(TopLevelParent) != nullptr) return nullptr; else return CurrentObjectsReferences.GetObjectReference(TopLevelParent); } void Dockable::SetEnabled(bool enabled) { Enabled = enabled; } bool Dockable::IsEnabled() const { return Enabled; } void Dockable::Internal_Update(bool isPreUpdate, ssGUI::Backend::BackendSystemInputInterface* inputInterface, ssGUI::InputStatus& globalInputStatus, ssGUI::InputStatus& windowInputStatus, ssGUI::GUIObject* mainWindow) { FUNC_DEBUG_ENTRY(); if(!isPreUpdate || Container == nullptr || !Enabled) { FUNC_DEBUG_EXIT(); return; } //If global dock mode is true, check topLevelParent first, then check the cursor against the trigger area if(GlobalDockMode && !ContainerIsDocking && !globalInputStatus.DockingBlocked) { ssGUI::GUIObject* curParent = Container; while (curParent->GetType() != ssGUI::Enums::GUIObjectType::MAIN_WINDOW && curParent != nullptr && curParent != DockingTopLevelParent) { curParent = curParent->GetParent(); } //If this is not the same parent as the one which is being docked, exit if((DockingTopLevelParent == MainWindowUnderDocking && curParent != MainWindowUnderDocking) || curParent != DockingTopLevelParent) { DiscardLeftPreview(); DiscardTopPreview(); DiscardRightPreview(); DiscardBottomPreview(); DiscardTriggerAreas(); FUNC_DEBUG_EXIT(); return; } glm::vec2 containerPos = Container->GetGlobalPosition(); glm::vec2 containerSize = Container->GetSize(); int titleBarOffset = Container->GetType() == ssGUI::Enums::GUIObjectType::WINDOW && Container->GetType() != ssGUI::Enums::GUIObjectType::MAIN_WINDOW ? static_cast<ssGUI::Window*>(Container)->GetTitlebarHeight() : 0; glm::vec2 windowContentSize = Container->GetSize(); windowContentSize.y -= titleBarOffset; glm::vec2 triggerSize = IsUseTriggerPercentage() ? glm::vec2(glm::vec2(windowContentSize) * GetTriggerPercentage()) : glm::vec2(GetTriggerPixel(), GetTriggerPixel()); bool previewDrawn = false; //Left if(inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x >= containerPos.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x <= containerPos.x + triggerSize.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y >= containerPos.y + titleBarOffset + triggerSize.y && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y <= containerPos.y + titleBarOffset + windowContentSize.y - triggerSize.y) { DiscardTopPreview(); DiscardRightPreview(); DiscardBottomPreview(); DrawLeftPreview(); previewDrawn = true; TargetDockSide = DockSide::LEFT; } //Top else if(inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x >= containerPos.x + triggerSize.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x <= containerPos.x + windowContentSize.x - triggerSize.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y >= containerPos.y + titleBarOffset && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y <= containerPos.y + titleBarOffset + triggerSize.y) { DiscardLeftPreview(); DiscardRightPreview(); DiscardBottomPreview(); DrawTopPreview(); previewDrawn = true; TargetDockSide = DockSide::TOP; } //Right else if(inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x >= containerPos.x + windowContentSize.x - triggerSize.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x <= containerPos.x + windowContentSize.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y >= containerPos.y + titleBarOffset + triggerSize.y && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y <= containerPos.y + titleBarOffset + windowContentSize.y - triggerSize.y) { DiscardLeftPreview(); DiscardTopPreview(); DiscardBottomPreview(); DrawRightPreview(); previewDrawn = true; TargetDockSide = DockSide::RIGHT; } //Bottom else if(inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x >= containerPos.x + triggerSize.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x <= containerPos.x + windowContentSize.x - triggerSize.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y >= containerPos.y + containerSize.y - triggerSize.y && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y <= containerPos.y + containerSize.y) { DiscardLeftPreview(); DiscardTopPreview(); DiscardRightPreview(); DrawBottomPreview(); previewDrawn = true; TargetDockSide = DockSide::BOTTOM; } else { DiscardLeftPreview(); DiscardTopPreview(); DiscardRightPreview(); DiscardBottomPreview(); } //Check if the cursor is inside the window if(inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x >= containerPos.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).x <= containerPos.x + windowContentSize.x && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y >= containerPos.y + titleBarOffset && inputInterface->GetCurrentMousePosition(dynamic_cast<ssGUI::MainWindow*>(mainWindow)).y <= containerPos.y + containerSize.y) { if(!previewDrawn) { TargetDockSide = DockSide::NONE; DrawTriggerAreas(); } else DiscardTriggerAreas(); globalInputStatus.DockingBlocked = true; windowInputStatus.DockingBlocked = true; TargetDockObject = Container; } else { TargetDockSide = DockSide::NONE; DiscardTriggerAreas(); } } else { DiscardLeftPreview(); DiscardTopPreview(); DiscardRightPreview(); DiscardBottomPreview(); DiscardTriggerAreas(); } FUNC_DEBUG_EXIT(); } void Dockable::Internal_Draw(bool isPreRender, ssGUI::Backend::BackendDrawingInterface* drawingInterface, ssGUI::GUIObject* mainWindow, glm::vec2 mainWindowPositionOffset) {} std::string Dockable::GetExtensionName() { return EXTENSION_NAME; } void Dockable::BindToObject(ssGUI::GUIObject* bindObj) { FUNC_DEBUG_ENTRY(); Container = bindObj; ssGUI::EventCallbacks::EventCallback* event = nullptr; if(Container->IsEventCallbackExist(ssGUI::EventCallbacks::WindowDragStateChangedEventCallback::EVENT_NAME)) event = Container->GetEventCallback(ssGUI::EventCallbacks::WindowDragStateChangedEventCallback::EVENT_NAME); else { event = ssGUI::Factory::Create<ssGUI::EventCallbacks::WindowDragStateChangedEventCallback>(); Container->AddEventCallback(event); } if(Container->GetType() == ssGUI::Enums::GUIObjectType::WINDOW) { event->AddEventListener ( EXTENSION_NAME, [](ssGUI::GUIObject* src, ssGUI::GUIObject* container, ssGUI::ObjectsReferences* refs) { if(!container->IsExtensionExist(ssGUI::Extensions::Dockable::EXTENSION_NAME)) { DEBUG_LINE("Failed to find Dockable extension. Probably something wrong with cloning"); DEBUG_EXIT_PROGRAM(); return; } ssGUI::Extensions::Dockable* containerDockable = static_cast<ssGUI::Extensions::Dockable*> (container->GetExtension(ssGUI::Extensions::Dockable::EXTENSION_NAME)); //When the current window started being dragged if(static_cast<ssGUI::Window*>(src)->GetWindowDragState() == ssGUI::Enums::WindowDragState::STARTED) { containerDockable->OnWindowDragStarted(); } //When the current window finished being dragged else if(static_cast<ssGUI::Window*>(src)->GetWindowDragState() == ssGUI::Enums::WindowDragState::ENDED) { containerDockable->OnWindowDragFinished(); } } ); } FUNC_DEBUG_EXIT(); } void Dockable::Copy(ssGUI::Extensions::Extension* extension) { if(extension->GetExtensionName() != EXTENSION_NAME) return; ssGUI::Extensions::Dockable* dockable = static_cast<ssGUI::Extensions::Dockable*>(extension); Enabled = dockable->IsEnabled(); TopLevelParent = dockable->TopLevelParent; CurrentObjectsReferences = dockable->CurrentObjectsReferences; UseTriggerPercentage = dockable->IsUseTriggerPercentage(); TriggerPixel = dockable->GetTriggerPixel(); TriggerAreaColor = dockable->GetTriggerAreaColor(); DockPreviewColor = dockable->GetDockPreviewColor(); } ObjectsReferences* Dockable::Internal_GetObjectsReferences() { return &CurrentObjectsReferences; } Dockable* Dockable::Clone(ssGUI::GUIObject* newContainer) { Dockable* temp = new Dockable(*this); if(newContainer != nullptr) newContainer->AddExtension(temp); return temp; } }
45.194323
221
0.639089
Neko-Box-Coder
2f0bc0be826246498f44a6c70dde094c30512d9a
1,169
cpp
C++
state/state.cpp
iceylala/design-pattern
62865dd8ede485be874556233b0d9469139fdc85
[ "MIT" ]
null
null
null
state/state.cpp
iceylala/design-pattern
62865dd8ede485be874556233b0d9469139fdc85
[ "MIT" ]
null
null
null
state/state.cpp
iceylala/design-pattern
62865dd8ede485be874556233b0d9469139fdc85
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; class Work; class State { public: virtual void change(Work* w)=0; }; class TwoSite:public State { public: void change(Work *w); }; class Work { private: State* sit; string element; public: Work(); void set(const string &temp){ element = temp; } string& get(){ return element; } void setState(State* s){ sit = s; } void change(){ sit->change(this); } }; class OneSite:public State { public: void change(Work* w){ if(w->get() == "one"){ cout<<"it is me one"<<endl; } else if(w->get() == "two"){ cout<<"change"<<endl; w->setState(new TwoSite()); w->change(); delete this; } else{ cout<<"No match"<<endl; } } }; void TwoSite::change(Work *w){ if(w->get() == "two"){ cout<<"it is me two"<<endl; } else if(w->get() == "one"){ cout<<"change"<<endl; w->setState(new OneSite()); w->change(); delete this; } else{ cout<<"No match"<<endl; } } Work::Work(){ sit = new OneSite(); } int main() { Work* test = new Work(); test->set("one"); test->change(); test->set("two"); test->change(); delete test; return 0; }
12.706522
33
0.558597
iceylala
2f0dc06bf74d53c2241e925133b4488d8bb05f4a
18,977
cpp
C++
JustinGXEngine/JustinGXEngine.cpp
jdsilv17/Custom-Engine
823f021aa2efceb80aa426f3f3eae9da2769ccef
[ "MIT" ]
null
null
null
JustinGXEngine/JustinGXEngine.cpp
jdsilv17/Custom-Engine
823f021aa2efceb80aa426f3f3eae9da2769ccef
[ "MIT" ]
null
null
null
JustinGXEngine/JustinGXEngine.cpp
jdsilv17/Custom-Engine
823f021aa2efceb80aa426f3f3eae9da2769ccef
[ "MIT" ]
null
null
null
#include "JustinGXEngine.h" bool Engine::Initialize(HINSTANCE hInstance, int nCmdShow) { // Initialize global strings LoadStringW(hInstance, IDS_APP_TITLE, this->szTitle, MAX_LOADSTRING); LoadStringW(hInstance, IDC_JUSTINGXENGINE, this->szWindowClass, MAX_LOADSTRING); this->MyRegisterClass(hInstance); // Perform application initialization: if (!this->InitInstance(hInstance, nCmdShow)) return false; if (!this->GFX.Initialize(this->hWnd)) return false; this->Timer.Start(); return true; } void Engine::Update() { Timer.GetElapsedMilliseconds(); // causes view matrix to swap rows Timer.Restart(); float dt = ((float)Timer.deltaTime / 1000.0f); CatchInput(); if (false /*!DrawGrid*/) end::MakeColorGrid(20.0f, 24, dt * 0.5f); // creates grid that changes color overtime //this->SortedPoolParticle(dt); this->FreeListParticle(dt); //// Create the Target, LookAt, and TurnTo this->GFX.Gizmos //this->GFX.Gizmos[1].SetLookAt(this->GFX.Gizmos[1].GetPositionVector(), this->GFX.Gizmos[0].GetPositionVector(), this->GFX.Gizmos[1].UP); //this->GFX.Gizmos[2].SetTurnTo(this->GFX.Gizmos[2].GetWorldMatrix(), this->GFX.Gizmos[0].GetPositionVector(), dt * 0.5f); //// Draw this->GFX.Gizmos //size_t gizmo_count = this->GFX.Gizmos.size(); //for (size_t i = 0; i < gizmo_count; ++i) //{ // XMVECTOR x = this->GFX.Gizmos[i].GetWorldMatrix().r[0] + this->GFX.Gizmos[i].GetPositionVector(); // XMVECTOR y = this->GFX.Gizmos[i].GetWorldMatrix().r[1] + this->GFX.Gizmos[i].GetPositionVector(); // XMVECTOR z = this->GFX.Gizmos[i].GetWorldMatrix().r[2] + this->GFX.Gizmos[i].GetPositionVector(); // XMFLOAT4 xAxis; // XMStoreFloat4(&xAxis, x); // XMFLOAT4 yAxis; // XMStoreFloat4(&yAxis, y); // XMFLOAT4 zAxis; // XMStoreFloat4(&zAxis, z); // // x-axis // end::debug_renderer::add_line(this->GFX.Gizmos[i].GetPositionFloat4(), xAxis, { 1.0f, 0.0f, 0.0f, 1.0f }); // // y-axis // end::debug_renderer::add_line(this->GFX.Gizmos[i].GetPositionFloat4(), yAxis, { 0.0f, 1.0f, 0.0f, 1.0f }); // // z-axis // end::debug_renderer::add_line(this->GFX.Gizmos[i].GetPositionFloat4(), zAxis, { 0.0f, 0.0f, 1.0f, 1.0f }); //} // Draw Joints in a Keyframe const Animation::Keyframe* frame = nullptr; if (this->GFX.run_anim.IsPlaying()) frame = this->GFX.run_anim.Playback(); else frame = this->GFX.run_anim.GetCurrentKeyframe(); size_t joint_count = frame->joints.size(); for (size_t i = 0; i < joint_count; ++i) { XMVECTOR x = frame->joints[i].jointObject.GetWorldMatrix().r[0] * 0.2f + frame->joints[i].jointObject.GetPositionVector(); XMVECTOR y = frame->joints[i].jointObject.GetWorldMatrix().r[1] * 0.2f + frame->joints[i].jointObject.GetPositionVector(); XMVECTOR z = frame->joints[i].jointObject.GetWorldMatrix().r[2] * 0.2f + frame->joints[i].jointObject.GetPositionVector(); XMFLOAT4 xAxis; XMStoreFloat4(&xAxis, x); XMFLOAT4 yAxis; XMStoreFloat4(&yAxis, y); XMFLOAT4 zAxis; XMStoreFloat4(&zAxis, z); // x-axis end::debug_renderer::add_line(frame->joints[i].jointObject.GetPositionFloat4(), xAxis, { 1.0f, 0.0f, 0.0f, 1.0f }); // y-axis end::debug_renderer::add_line(frame->joints[i].jointObject.GetPositionFloat4(), yAxis, { 0.0f, 1.0f, 0.0f, 1.0f }); // z-axis end::debug_renderer::add_line(frame->joints[i].jointObject.GetPositionFloat4(), zAxis, { 0.0f, 0.0f, 1.0f, 1.0f }); } // draw Bones for (size_t j = 0; j < joint_count; j++) { const Animation::Joint* child = &frame->joints[j]; if (child->parent_index != -1) { const Animation::Joint* parent = &frame->joints[child->parent_index]; end::debug_renderer::add_line(child->jointObject.GetPositionFloat4(), parent->jointObject.GetPositionFloat4(), XMFLOAT4(Colors::HotPink), XMFLOAT4(Colors::White)); } } if (this->GFX.run_anim.IsPlaying()) delete frame; #pragma region FRUSTUM CULLING //// Create View Frustum //end::frustum_t frustum; //end::calculate_frustum(frustum, this->GFX.Gizmos[0].GetWorldMatrix(), aspectRatio); // //end::debug_renderer::add_line(frustum.corners[0], frustum.corners[1], XMFLOAT4(Colors::Fuchsia)); // FTL, FTR //end::debug_renderer::add_line(frustum.corners[1], frustum.corners[3], XMFLOAT4(Colors::Fuchsia)); // FTR, FBR //end::debug_renderer::add_line(frustum.corners[3], frustum.corners[2], XMFLOAT4(Colors::Fuchsia)); // FBR, FBL //end::debug_renderer::add_line(frustum.corners[2], frustum.corners[0], XMFLOAT4(Colors::Fuchsia)); // FBL, FTL //end::debug_renderer::add_line(frustum.corners[4], frustum.corners[5], XMFLOAT4(Colors::Fuchsia)); // NTL, NTR //end::debug_renderer::add_line(frustum.corners[5], frustum.corners[7], XMFLOAT4(Colors::Fuchsia)); // NTR, NBR //end::debug_renderer::add_line(frustum.corners[7], frustum.corners[6], XMFLOAT4(Colors::Fuchsia)); // NBR, NBL //end::debug_renderer::add_line(frustum.corners[6], frustum.corners[4], XMFLOAT4(Colors::Fuchsia)); // NBL, NTL //end::debug_renderer::add_line(frustum.corners[4], frustum.corners[0], XMFLOAT4(Colors::Fuchsia)); // NTL, FTL //end::debug_renderer::add_line(frustum.corners[6], frustum.corners[2], XMFLOAT4(Colors::Fuchsia)); // NBL, FBL //end::debug_renderer::add_line(frustum.corners[5], frustum.corners[1], XMFLOAT4(Colors::Fuchsia)); // NTR, FTR //end::debug_renderer::add_line(frustum.corners[7], frustum.corners[3], XMFLOAT4(Colors::Fuchsia)); // NBR, FBR //XMVECTOR planeAvg_V[6] = {}; ////LEFT PLANE 0246 //planeAvg_V[0] = (XMLoadFloat4(&frustum.corners[0]) + XMLoadFloat4(&frustum.corners[2]) + XMLoadFloat4(&frustum.corners[4]) + XMLoadFloat4(&frustum.corners[6])) / 4.0f; ////RIGHT PLANE 1357 //planeAvg_V[1] = (XMLoadFloat4(&frustum.corners[1]) + XMLoadFloat4(&frustum.corners[3]) + XMLoadFloat4(&frustum.corners[5]) + XMLoadFloat4(&frustum.corners[7])) / 4.0f; ////NEAR PLANE 4567 //planeAvg_V[2] = (XMLoadFloat4(&frustum.corners[4]) + XMLoadFloat4(&frustum.corners[5]) + XMLoadFloat4(&frustum.corners[5]) + XMLoadFloat4(&frustum.corners[6])) / 4.0f; ////FAR PLANE 0123 //planeAvg_V[3] = (XMLoadFloat4(&frustum.corners[0]) + XMLoadFloat4(&frustum.corners[1]) + XMLoadFloat4(&frustum.corners[2]) + XMLoadFloat4(&frustum.corners[3])) / 4.0f; ////TOP PLANE 0145 //planeAvg_V[4] = (XMLoadFloat4(&frustum.corners[0]) + XMLoadFloat4(&frustum.corners[1]) + XMLoadFloat4(&frustum.corners[4]) + XMLoadFloat4(&frustum.corners[5])) / 4.0f; ////BOTTOM PLANE 2367 //planeAvg_V[5] = (XMLoadFloat4(&frustum.corners[2]) + XMLoadFloat4(&frustum.corners[3]) + XMLoadFloat4(&frustum.corners[6]) + XMLoadFloat4(&frustum.corners[7])) / 4.0f; // //XMFLOAT4 planeAvg_F[6] = {}; //for (size_t i = 0; i < 6; ++i) //{ // XMStoreFloat4(&planeAvg_F[i], planeAvg_V[i]); // XMFLOAT4 normal = { 0.0f, 0.0f, 0.0f, 1.0f }; // normal.x = planeAvg_F[i].x + frustum.planes[i].normal.x; // normal.y = planeAvg_F[i].y + frustum.planes[i].normal.y; // normal.z = planeAvg_F[i].z + frustum.planes[i].normal.z; // // Draw plane normals // end::debug_renderer::add_line(planeAvg_F[i], normal, { 1.0f, 0.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }); //} //// Create AABBs //for (size_t i = 0; i < ARRAYSIZE(aabbs); ++i) //{ // XMFLOAT4 color = XMFLOAT4(Colors::Cyan); // if (end::aabb_to_frustum(aabbs[i], frustum)) // color = XMFLOAT4(Colors::Orange); // Create_AABB(aabbs[i], color); //} #pragma endregion //end::aabb_t player_aabb; //XMVECTOR extents = { 1.0f, 2.0f, 1.0f }/*Gizmo[0].GetWorldMatrix().r[0] + Gizmo[0].GetWorldMatrix().r[1] + Gizmo[0].GetWorldMatrix().r[2]*/; //XMStoreFloat3(&player_aabb.center, this->GFX.Gizmos[0].GetPositionVector()); //XMStoreFloat3(&player_aabb.extents, extents); //Create_AABB(player_aabb, XMFLOAT4(Colors::Blue)); //Create_AABB(AABB_Bounds_from_Triangle(terrain_tri_indices[0]), XMFLOAT4(Colors::Red)); //size_t size = terrain_triangles.size(); //for (size_t i = 0; i < size; ++i) //{ // end::debug_renderer::add_line(terrain_triangles[i][0].pos, terrain_triangles[i][1].pos, XMFLOAT4(Colors::White)); // end::debug_renderer::add_line(terrain_triangles[i][1].pos, terrain_triangles[i][2].pos, XMFLOAT4(Colors::White)); // end::debug_renderer::add_line(terrain_triangles[i][2].pos, terrain_triangles[i][0].pos, XMFLOAT4(Colors::White)); //} #pragma region BVH // Build BVH //std::mt19937_64 g(rand()); //std::shuffle(terrain_tri_indices.begin(), terrain_tri_indices.end(), g); //end::bvh_node_t root(AABB_Bounds_from_Triangle(terrain_tri_indices[0]), NULL); ////end::bvh_node_t root(nullptr); //BVH.push_back(root); //size_t size = terrain_triangles.size(); //for (size_t i = 1; i < size; ++i) //{ // //BVH[i];n // size_t tri_index = terrain_tri_indices[i]; // end::bvh_node_t leaf_N(AABB_Bounds_from_Triangle(tri_index), tri_index); // //end::bvh_node_t curr(&root, tri_index - 1, tri_index + 1); // end::bvh_node_t curr(BVH[i - 1]); // while (!curr.is_leaf()) // is a root/branch // { // // Expand current bounds to include N // //XMVECTOR a_max = XMLoadFloat3(&curr.get_aabb().max); // //XMVECTOR b_max = XMLoadFloat3(&leaf_N.get_aabb().max); // //XMVECTOR a_min = XMLoadFloat3(&curr.get_aabb().min); // //XMVECTOR b_min = XMLoadFloat3(&leaf_N.get_aabb().min); // //XMVECTOR Max = XMVectorMax(a_max, b_max); // //XMVECTOR Min = XMVectorMin(a_min, b_min); // //end::aabb_bounds_t new_aabb = AABB_Bounds(Max, Min); // ////Create_AABB(new_aabb); // temp // //end::bvh_node_t new_node(new_aabb, i); // // // Determine which child of CurrentNode has best cost // current = cost(N, left) < cost(N, right) ? left : right // end::bvh_node_t left(AABB_Bounds_from_Triangle(curr.get_left()), i); // end::bvh_node_t right(AABB_Bounds_from_Triangle(curr.get_right()), i); // float left_cost = ManhattanDistance(terrain_centroids[tri_index], terrain_centroids[curr.get_left()]); // float right_cost = ManhattanDistance(terrain_centroids[tri_index], terrain_centroids[curr.get_right()]); // curr = (left_cost > right_cost) ? left : right; // } // // Create a new internal node as parent of CurrentNode and inserting leaf // XMVECTOR a_max = XMLoadFloat3(&curr.get_aabb().max); // XMVECTOR b_max = XMLoadFloat3(&leaf_N.get_aabb().max); // XMVECTOR a_min = XMLoadFloat3(&curr.get_aabb().min); // XMVECTOR b_min = XMLoadFloat3(&leaf_N.get_aabb().min); // XMVECTOR Max = XMVectorMax(a_max, b_max); // XMVECTOR Min = XMVectorMin(a_min, b_min); // end::aabb_bounds_t new_aabb = AABB_Bounds(Max, Min); // end::bvh_node_t new_node(new_aabb, i); // auto& p = new_node.get_parent(); // p = i; // end::bvh_node_t parent_node(&new_node, curr.get_element_id(), leaf_N.get_element_id()); // BVH.push_back(parent_node); // //root(parent_node); //} //BVH.shrink_to_fit(); #pragma endregion } void Engine::RenderFrame() { this->GFX.RenderFrame(); } void Engine::CleanUp() { this->Timer.Stop(); this->GFX.CleanUp(); } /// <summary> /// Catches the keyboard and mouse input /// </summary> void Engine::CatchInput() { static Time uTimer; uTimer.GetElapsedMilliseconds(); uTimer.Restart(); const float cameraSpeed = 0.002f; #pragma region OLD CAMERA ROTATION //POINT curr_point = { 0,0 }; //POINT delta_point = { 0,0 }; // //GetCursorPos(&curr_point); // grab the curr every frame // //static POINT prev_point = curr_point; // initialize once // //// calc delta of mouse pos with the pos of the previous frame //delta_point.x = curr_point.x - prev_point.x; //delta_point.y = curr_point.y - prev_point.y; // //prev_point = curr_point; // keep the current pos of the current frame to use in the next frame // //if (GetAsyncKeyState(VK_RBUTTON) & 0x8000) // Right mouse button //{ // cam.UpdateRotation(static_cast<float>(delta_point.y) * 0.005f, static_cast<float>(delta_point.x) * 0.005f, 0.0f); //} #pragma endregion if (this->GFX.bits[0]) // up arrow { this->GFX.Gizmos[0].UpdatePosition(this->GFX.Gizmos[0].GetWorldMatrix().r[2] * 0.002f * (float)uTimer.deltaTime); this->GFX.pntLight.UpdatePosition(0.0f, 0.002f * (float)uTimer.deltaTime, 0.0f); } if (this->GFX.bits[1]) // down arrow { this->GFX.Gizmos[0].UpdatePosition(-this->GFX.Gizmos[0].GetWorldMatrix().r[2] * 0.002f * (float)uTimer.deltaTime); this->GFX.pntLight.UpdatePosition(0.0f, -0.002f * (float)uTimer.deltaTime, 0.0f); } if (this->GFX.bits[2]) // left arrow { this->GFX.Gizmos[0].UpdateRotation(0.0f, -XM_PI * 0.02f, 0.0f * (float)uTimer.deltaTime); this->GFX.pntLight.UpdatePosition(-0.002f * (float)uTimer.deltaTime, 0.0f, 0.0f); } if (this->GFX.bits[3]) // right arrow { this->GFX.Gizmos[0].UpdateRotation(0.0f, XM_PI * 0.02f, 0.0f * (float)uTimer.deltaTime); this->GFX.pntLight.UpdatePosition(0.002f * (float)uTimer.deltaTime, 0.0f, 0.0f); } if (this->GFX.bits[4]) // W { this->GFX.cam.UpdatePosition(this->GFX.cam.GetForwardVector() * cameraSpeed * (float)uTimer.deltaTime); } if (this->GFX.bits[5]) // A { this->GFX.cam.UpdatePosition(this->GFX.cam.GetLeftVector() * cameraSpeed * (float)uTimer.deltaTime); } if (this->GFX.bits[6]) // S { this->GFX.cam.UpdatePosition(this->GFX.cam.GetBackwardVector() * cameraSpeed * (float)uTimer.deltaTime); } if (this->GFX.bits[7]) // D { this->GFX.cam.UpdatePosition(this->GFX.cam.GetRightVector() * cameraSpeed * (float)uTimer.deltaTime); } if (this->GFX.bits[8]) // SPACE { this->GFX.cam.UpdatePosition(this->GFX.cam.UP * cameraSpeed * (float)uTimer.deltaTime); } if (this->GFX.bits[9]) // X { this->GFX.cam.UpdatePosition(this->GFX.cam.UP * -cameraSpeed * (float)uTimer.deltaTime); } if (this->GFX.bits[10] || GetAsyncKeyState('Q') & 0x0001) { this->GFX.DrawQuad = !this->GFX.DrawQuad; } if (this->GFX.bits[11] || GetAsyncKeyState('G') & 0x0001) { this->GFX.DrawGrid = !this->GFX.DrawGrid; } //if (this->GFX.bits[12]) // < (,) //{ // run_anim.FrameStepBack(); //} //if (this->GFX.bits[13]) // > (.) //{ // run_anim.FrameStepForward(); //} if (this->GFX.bits[14]) // R { if (this->GFX.run_anim.IsPlaying()) this->GFX.run_anim.StopPlayback(); this->GFX.run_anim.ResetCurrentFrame(); } } void Engine::SortedPoolParticle(float dt) { // Sorted Pool Algo // every 0.02 secs activate a particle float t = (std::ceilf(dt / 0.01f)); if (t == 2.0f) { this->GFX.sortEmitter.indices.alloc(); this->GFX.sortPool.alloc(); } for (uint16_t i = 0; i < this->GFX.sortEmitter.indices.size(); ++i) // for every active particle, update it { this->GFX.sortPool[i].prev_pos = this->GFX.sortPool[i].Pos; this->GFX.sortPool[i].Velocity += this->GFX.sortPool[i].Gravity * dt; // apply gravity XMVECTOR pos = XMLoadFloat4(&this->GFX.sortPool[i].Pos); pos += this->GFX.sortPool[i].Velocity * dt; XMStoreFloat4(&this->GFX.sortPool[i].Pos, pos); // move particle this->GFX.sortPool[i].Lifetime -= dt; // kill it, but slowly if (this->GFX.sortPool[i].Lifetime > 0.0f) // if particle is dead end::debug_renderer::add_line(this->GFX.sortPool[i].prev_pos, this->GFX.sortPool[i].Pos, { 1.0f, 0.0f, 0.0f, 1.0f }, this->GFX.sortEmitter.Spawn_Color); else { this->GFX.sortPool.free(i); // free it this->GFX.sortEmitter.indices.free(i); int16_t index = (uint16_t)this->GFX.sortPool.size(); this->GFX.sortPool[index].Pos = this->GFX.sortEmitter.GetSpawnPositionFloat4(); this->GFX.sortPool[index].Velocity = { RAND_FLT(-3.0f, 3.0f), 15.0f, RAND_FLT(-3.0f, 3.0f), 0.0f }; this->GFX.sortPool[index].Lifetime = 3.0f; } } } void Engine::FreeListParticle(float dt) { // Free List Algo float t = (std::ceilf(dt / 0.01f)); for (size_t emt = 0; emt < ARRAYSIZE(this->GFX.emitters); ++emt) { int16_t emtIndex = 0; int16_t poolIndex = 0; // allocate space for a particle // every 0.02 secs if (t == 2.0f) { emtIndex = this->GFX.emitters[emt].indices.alloc(); poolIndex = this->GFX.sharedPool.alloc(); // alloc particle so is it ready for use if (poolIndex == -1) { this->GFX.sharedPool.free(poolIndex); break; } // Initialize the particle this->GFX.emitters[emt].indices[emtIndex - 1] = poolIndex; // store the indices of the ready particles const XMVECTOR gravity = { 0.0f, -9.8f, 0.0f }; this->GFX.sharedPool[poolIndex].Pos = this->GFX.emitters[emt].GetSpawnPositionFloat4(); this->GFX.sharedPool[poolIndex].Velocity = { RAND_FLT(-3.0f, 3.0f), 15.0f, RAND_FLT(-3.0f, 3.0f), 0.0f }; this->GFX.sharedPool[poolIndex].Gravity = gravity; this->GFX.sharedPool[poolIndex].Lifetime = 3.0f; } for (uint16_t i = 0; i < this->GFX.emitters[emt].indices.size(); ++i) // for every active particle, update it { int16_t index = this->GFX.emitters[emt].indices[i]; this->GFX.sharedPool[index].prev_pos = this->GFX.sharedPool[index].Pos; this->GFX.sharedPool[index].Velocity += this->GFX.sharedPool[index].Gravity * dt; // apply gravity // am i nothing to you XMVECTOR pos = XMLoadFloat4(&this->GFX.sharedPool[index].Pos); pos += this->GFX.sharedPool[index].Velocity * dt; XMStoreFloat4(&this->GFX.sharedPool[index].Pos, pos); // move particle this->GFX.sharedPool[index].Lifetime -= dt; // kill it, but slowly end::debug_renderer::add_line(this->GFX.sharedPool[index].prev_pos, this->GFX.sharedPool[index].Pos, this->GFX.emitters[emt].Spawn_Color); if (this->GFX.sharedPool[index].Lifetime <= 0.0f) // if particle is dead { // deallocate this->GFX.emitters[emt].indices.free(i); this->GFX.sharedPool.free(index); } } } }
44.235431
173
0.622965
jdsilv17
2f2203c7f3b0c62eabf2ab4d256b23140f6fa9f9
705
cpp
C++
Anagram_or_Not.cpp
UndefeatedSunny/C-Interview-Problems
5eb4d3c52cb7ffe4bc97380d13f62e23bc7d1e2f
[ "MIT" ]
4
2020-02-25T19:02:46.000Z
2021-04-17T09:13:51.000Z
Anagram_or_Not.cpp
UndefeatedSunny/C-Interview-Problems
5eb4d3c52cb7ffe4bc97380d13f62e23bc7d1e2f
[ "MIT" ]
null
null
null
Anagram_or_Not.cpp
UndefeatedSunny/C-Interview-Problems
5eb4d3c52cb7ffe4bc97380d13f62e23bc7d1e2f
[ "MIT" ]
2
2021-01-08T07:25:35.000Z
2021-04-17T09:14:57.000Z
#include<bits/stdc++.h> using namespace std; int main() { char str1[20],str2[20]; int len,len1,len2,found=0,not_found=0; cout<<"Enter first string :"; cin>>str1; cout<<"Enter second string :"; cin>>str2; len1=strlen(str1); len2=strlen(str2); if(len1==len2) { len=len1; for(int i=0;i<len;i++) { found=0; for(int j=0;j<len;j++) { if(str1[i]==str2[j]) { found=1; break; } } if(found==0) { not_found=1; break; } } if(not_found==1) { cout<<"Strings are not Anagram to each other"; } else { cout<<"Strings are Anagram"; } } else { cout<<"Two string must have same number of character to be Anagram"; } return 0; }
14.6875
70
0.567376
UndefeatedSunny
2f255f3cf7d7bf0b6f7124b69a0159fc9eab240c
2,835
cpp
C++
cpp/stl_vector.cpp
BigDataAnalyticsGroup/rewiring
5ab07812a8c95a5a2e6450f359d158765e8e0ac3
[ "Apache-2.0" ]
3
2020-10-29T09:12:17.000Z
2022-03-07T07:25:25.000Z
cpp/stl_vector.cpp
FMSchuhknecht/rewiring
5ab07812a8c95a5a2e6450f359d158765e8e0ac3
[ "Apache-2.0" ]
null
null
null
cpp/stl_vector.cpp
FMSchuhknecht/rewiring
5ab07812a8c95a5a2e6450f359d158765e8e0ac3
[ "Apache-2.0" ]
2
2019-06-14T13:23:01.000Z
2020-12-02T11:43:57.000Z
/* * Copyright 2016 Information Systems Group, Saarland University 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. */ /* * stl_vector.c * * Created on: Mar 10, 2015 * Author: Felix Martin Schuhknecht, Pankaj Khanchandani */ #include "stl_vector.h" stlVec_pt stlvGetNewVector(const size_t initCapacity) { std::vector<entry_t>* vec = new std::vector<entry_t>; vec->reserve(initCapacity); return (stlVec_pt) vec; } void stlvPushBack(stlVec_pt const v, const entry_t* const entry) { std::vector<entry_t>* vec = (std::vector<entry_t>*) v; vec->push_back(*entry); } void stlvPushBackArray(stlVec_pt const v, const entry_t* const entries, const size_t size, double** diffs) { std::vector<entry_t>* vec = (std::vector<entry_t>*) v; if(diffs) { // detailed time measurement timespec_t start, end; *diffs = (double*) malloc(sizeof(**diffs) * size); size_t elem = 0; for(size_t i = 0; i < size / DETAILED_GRANULARITY; ++i) { clock_gettime(CLOCK_REALTIME, &start); for(size_t g = 0; g < DETAILED_GRANULARITY; ++g) { vec->push_back(entries[elem]); ++elem; } clock_gettime(CLOCK_REALTIME, &end); (*diffs)[i] = ((end.tv_sec - start.tv_sec) * 1000000000 + (end.tv_nsec - start.tv_nsec)); (*diffs)[i] /= 1000; } } else { // standard time measurement for(size_t i = 0; i < size; ++i) { vec->push_back(entries[i]); } } } void stlvInsertPage(stlVec_pt const v, const entry_t* const entries, const size_t size, const size_t insertPosition) { std::vector<entry_t>* vec = (std::vector<entry_t>*) v; assert(size % HUGE_PAGE_SIZE == 0); assert(insertPosition % HUGE_PAGE_SIZE == 0); vec->insert(vec->begin() + insertPosition, entries, entries + size); } void stlvClear(stlVec_pt const v) { std::vector<entry_t>* vec = (std::vector<entry_t>*) v; vec->clear(); } void stlvReserve(stlVec_pt const v, const size_t size) { std::vector<entry_t>* vec = (std::vector<entry_t>*) v; vec->reserve(size); } entry_t* stlvGetMem(const stlVec_pt v, size_t* numEntries) { std::vector<entry_t>* vec = (std::vector<entry_t>*) v; if(numEntries) *numEntries = vec->size(); return vec->data(); } void stlvFreeVector(stlVec_pt const v) { std::vector<entry_t>* vec = (std::vector<entry_t>*) v; if(vec) { delete vec; vec = NULL; } }
26.009174
92
0.67866
BigDataAnalyticsGroup
2f2763fe8a6430ea69494b5c660b0774856c6cb2
1,636
cpp
C++
code/1073.cpp
Nightwish-cn/my_leetcode
40f206e346f3f734fb28f52b9cde0e0041436973
[ "MIT" ]
23
2020-03-30T05:44:56.000Z
2021-09-04T16:00:57.000Z
code/1073.cpp
Nightwish-cn/my_leetcode
40f206e346f3f734fb28f52b9cde0e0041436973
[ "MIT" ]
1
2020-05-10T15:04:05.000Z
2020-06-14T01:21:44.000Z
code/1073.cpp
Nightwish-cn/my_leetcode
40f206e346f3f734fb28f52b9cde0e0041436973
[ "MIT" ]
6
2020-03-30T05:45:04.000Z
2020-08-13T10:01:39.000Z
#include <bits/stdc++.h> #define INF 2000000000 using namespace std; typedef long long ll; int read(){ int f = 1, x = 0; char c = getchar(); while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();} while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar(); return f * x; } struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; bool isLeaf(TreeNode* root) { return root->left == NULL && root->right == NULL; } struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; class Solution { public: vector<int> addNegabinary(vector<int>& arr1, vector<int>& arr2) { int n = arr1.size(), m = arr2.size(), r = max(n, m); vector<int> arr(r + 2, 0); for (int i = 0; i < r; ++i){ if (i < n) arr[i] += arr1[n - i - 1]; if (i < m) arr[i] += arr2[m - i - 1]; if (arr[i] == 2 || arr[i] == 3){ if (arr[i + 1]) --arr[i + 1]; else ++arr[i + 1], ++arr[i + 2]; arr[i] -= 2; }else if (arr[i] == 4) ++arr[i + 2], arr[i] = 0; } if (arr[r] == 2){ if (arr[r + 1] == 1) arr[r] -= 2, --arr[r + 1]; else ++arr[r + 1], arr.push_back(1); } while (arr.size() > 1 && arr[arr.size() - 1] == 0) arr.pop_back(); reverse(arr.begin(), arr.end()); return arr; } }; Solution sol; void init(){ } void solve(){ // sol.convert(); } int main(){ init(); solve(); return 0; }
24.41791
69
0.441932
Nightwish-cn
2f27b899e809dba06ded9f4f410b2ad126cbf2ed
9,788
cpp
C++
Source/HeliumRain/Game/FlareFleet.cpp
eaglesquads/HeliumRain
74e70482f8d93158ab819406086a513452eee555
[ "BSD-3-Clause" ]
1
2020-02-21T20:11:06.000Z
2020-02-21T20:11:06.000Z
Source/HeliumRain/Game/FlareFleet.cpp
eaglesquads/HeliumRain
74e70482f8d93158ab819406086a513452eee555
[ "BSD-3-Clause" ]
null
null
null
Source/HeliumRain/Game/FlareFleet.cpp
eaglesquads/HeliumRain
74e70482f8d93158ab819406086a513452eee555
[ "BSD-3-Clause" ]
null
null
null
#include "../Flare.h" #include "FlareFleet.h" #include "FlareCompany.h" #include "FlareGame.h" #include "../Player/FlarePlayerController.h" #include "FlareSimulatedSector.h" #define LOCTEXT_NAMESPACE "FlareFleet" /*---------------------------------------------------- Constructor ----------------------------------------------------*/ UFlareFleet::UFlareFleet(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { } void UFlareFleet::Load(const FFlareFleetSave& Data) { FleetCompany = Cast<UFlareCompany>(GetOuter()); Game = FleetCompany->GetGame(); FleetData = Data; IsShipListLoaded = false; } FFlareFleetSave* UFlareFleet::Save() { return &FleetData; } /*---------------------------------------------------- Gameplay ----------------------------------------------------*/ FText UFlareFleet::GetName() { if (GetShips().Num() > 0) { return FText::FromString(GetShips()[0]->GetImmatriculation().ToString());// TODO Clean with GetFleetName } else { return GetFleetName(); } } FText UFlareFleet::GetFleetName() const { if(Game->GetPC()->GetPlayerFleet() == this) { return LOCTEXT("PlayerFleetName", "Player Fleet"); } return FleetData.Name; } bool UFlareFleet::IsTraveling() const { return CurrentTravel != NULL; } bool UFlareFleet::IsTrading() const { return GetTradingShipCount() > 0; } bool UFlareFleet::CanTravel() { if (IsTraveling() && !GetCurrentTravel()->CanChangeDestination()) { return false; } if (GetImmobilizedShipCount() == FleetShips.Num()) { // All ship are immobilized return false; } if(Game->GetPC()->GetPlayerFleet() == this && Game->GetPC()->GetPlayerShip()->GetDamageSystem()->IsStranded()) { // The player ship is stranded return false; } return true; } bool UFlareFleet::CanTravel(FText& OutInfo) { if (IsTraveling() && !GetCurrentTravel()->CanChangeDestination()) { OutInfo = LOCTEXT("TravellingFormat", "Can't change destination"); return false; } if (GetImmobilizedShipCount() == FleetShips.Num()) { OutInfo = LOCTEXT("Travelling", "Trading, stranded or intercepted"); return false; } if(Game->GetPC()->GetPlayerFleet() == this && Game->GetPC()->GetPlayerShip()->GetDamageSystem()->IsStranded()) { OutInfo = LOCTEXT("PlayerShipStranded", "The ship you are piloting is stranded"); return false; } return true; } uint32 UFlareFleet::GetImmobilizedShipCount() { uint32 ImmobilizedShip = 0; for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++) { if (!FleetShips[ShipIndex]->CanTravel()) { ImmobilizedShip++; } } return ImmobilizedShip; } uint32 UFlareFleet::GetTradingShipCount() const { uint32 TradingShip = 0; for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++) { if (FleetShips[ShipIndex]->IsTrading()) { TradingShip++; } } return TradingShip; } uint32 UFlareFleet::GetShipCount() const { return FleetShips.Num(); } uint32 UFlareFleet::GetMilitaryShipCountBySize(EFlarePartSize::Type Size) const { uint32 Count = 0; for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++) { if (FleetShips[ShipIndex]->GetDescription()->Size == Size && FleetShips[ShipIndex]->IsMilitary()) { Count++; } } return Count; } uint32 UFlareFleet::GetMaxShipCount() { return 20; } FText UFlareFleet::GetStatusInfo() const { if (IsTraveling()) { int64 RemainingDuration = CurrentTravel->GetRemainingTravelDuration(); return FText::Format(LOCTEXT("TravelTextFormat", "Travelling to {0} ({1} left)"), CurrentTravel->GetDestinationSector()->GetSectorName(), FText::FromString(*UFlareGameTools::FormatDate(RemainingDuration, 1))); //FString needed here } else if (IsTrading()) { if(GetTradingShipCount() == GetShipCount()) { return FText::Format(LOCTEXT("FleetTrading", "Trading in {0}"), GetCurrentSector()->GetSectorName()); } else { return FText::Format(LOCTEXT("FleetPartialTrading", "{0} of {1} ships are trading in {2}"), FText::AsNumber(GetTradingShipCount()), FText::AsNumber(GetShipCount()), GetCurrentSector()->GetSectorName()); } } else { return FText::Format(LOCTEXT("FleetIdle", "Idle in {0}"), GetCurrentSector()->GetSectorName()); } return FText(); } int32 UFlareFleet::GetFleetCapacity() const { int32 FreeCargoSpace = 0; for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++) { FreeCargoSpace += FleetShips[ShipIndex]->GetCargoBay()->GetCapacity(); } return FreeCargoSpace; } int32 UFlareFleet::GetFleetFreeCargoSpace() const { int32 FreeCargoSpace = 0; for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++) { FreeCargoSpace += FleetShips[ShipIndex]->GetCargoBay()->GetFreeCargoSpace(); } return FreeCargoSpace; } void UFlareFleet::RemoveImmobilizedShips() { TArray<UFlareSimulatedSpacecraft*> ShipToRemove; for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++) { if (!FleetShips[ShipIndex]->CanTravel()) { ShipToRemove.Add(FleetShips[ShipIndex]); } } for (int ShipIndex = 0; ShipIndex < ShipToRemove.Num(); ShipIndex++) { RemoveShip(ShipToRemove[ShipIndex]); } } int32 UFlareFleet::InterceptShips() { // Intercept half of ships at maximum and min 1 int32 MaxInterseptedShipCount = FMath::Max(1,FleetShips.Num() / 2); int32 InterseptedShipCount = 0; for (UFlareSimulatedSpacecraft* Ship : FleetShips) { if(InterseptedShipCount >=MaxInterseptedShipCount) { break; } if (Ship == Game->GetPC()->GetPlayerShip()) { // Never intercept the player ship continue; } if(FMath::FRand() < 0.1) { Ship->SetIntercepted(true); InterseptedShipCount++; } } return InterseptedShipCount; } void UFlareFleet::AddShip(UFlareSimulatedSpacecraft* Ship) { if (IsTraveling()) { FLOGV("Fleet Disband fail: '%s' is travelling", *GetFleetName().ToString()); return; } if (GetCurrentSector() != Ship->GetCurrentSector()) { FLOGV("Fleet Merge fail: '%s' is the sector '%s' but '%s' is the sector '%s'", *GetFleetName().ToString(), *GetCurrentSector()->GetSectorName().ToString(), *Ship->GetImmatriculation().ToString(), *Ship->GetCurrentSector()->GetSectorName().ToString()); return; } UFlareFleet* OldFleet = Ship->GetCurrentFleet(); if (OldFleet) { OldFleet->RemoveShip(Ship); } FleetData.ShipImmatriculations.Add(Ship->GetImmatriculation()); FleetShips.AddUnique(Ship); Ship->SetCurrentFleet(this); } void UFlareFleet::RemoveShip(UFlareSimulatedSpacecraft* Ship, bool destroyed) { if (IsTraveling()) { FLOGV("Fleet RemoveShip fail: '%s' is travelling", *GetFleetName().ToString()); return; } FleetData.ShipImmatriculations.Remove(Ship->GetImmatriculation()); FleetShips.Remove(Ship); Ship->SetCurrentFleet(NULL); if (!destroyed) { Ship->GetCompany()->CreateAutomaticFleet(Ship); } if(FleetShips.Num() == 0) { Disband(); } } /** Remove all ship from the fleet and delete it. Not possible during travel */ void UFlareFleet::Disband() { if (IsTraveling()) { FLOGV("Fleet Disband fail: '%s' is travelling", *GetFleetName().ToString()); return; } for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++) { FleetShips[ShipIndex]->SetCurrentFleet(NULL); } if (GetCurrentTradeRoute()) { GetCurrentTradeRoute()->RemoveFleet(this); } GetCurrentSector()->DisbandFleet(this); FleetCompany->RemoveFleet(this); } bool UFlareFleet::CanMerge(UFlareFleet* Fleet, FText& OutInfo) { if (GetShipCount() + Fleet->GetShipCount() > GetMaxShipCount()) { OutInfo = LOCTEXT("MergeFleetMaxShips", "Can't add, max ships reached"); return false; } if (IsTraveling()) { OutInfo = LOCTEXT("MergeFleetTravel", "Can't add during travel"); return false; } if (Fleet->IsTraveling()) { OutInfo = LOCTEXT("MergeOtherFleetTravel", "Can't add travelling ships"); return false; } if (GetCurrentSector() != Fleet->GetCurrentSector()) { OutInfo = LOCTEXT("MergeFleetDifferenSector", "Can't add from a different sector"); return false; } return true; } void UFlareFleet::Merge(UFlareFleet* Fleet) { FText Unused; if (!CanMerge(Fleet, Unused)) { FLOGV("Fleet Merge fail: '%s' is not mergeable", *Fleet->GetFleetName().ToString()); return; } TArray<UFlareSimulatedSpacecraft*> Ships = Fleet->GetShips(); Fleet->Disband(); for (int ShipIndex = 0; ShipIndex < Ships.Num(); ShipIndex++) { AddShip(Ships[ShipIndex]); } } void UFlareFleet::SetCurrentSector(UFlareSimulatedSector* Sector) { CurrentSector = Sector; if(!Sector->IsTravelSector()) { CurrentTravel = NULL; } InitShipList(); } void UFlareFleet::SetCurrentTravel(UFlareTravel* Travel) { CurrentSector = Travel->GetTravelSector(); CurrentTravel = Travel; InitShipList(); for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++) { FleetShips[ShipIndex]->SetSpawnMode(EFlareSpawnMode::Travel); } } void UFlareFleet::InitShipList() { if (!IsShipListLoaded) { IsShipListLoaded = true; FleetShips.Empty(); for (int ShipIndex = 0; ShipIndex < FleetData.ShipImmatriculations.Num(); ShipIndex++) { UFlareSimulatedSpacecraft* Ship = FleetCompany->FindSpacecraft(FleetData.ShipImmatriculations[ShipIndex]); if (!Ship) { FLOGV("WARNING: Fail to find ship with id %s in company %s for fleet %s (%d ships)", *FleetData.ShipImmatriculations[ShipIndex].ToString(), *FleetCompany->GetCompanyName().ToString(), *GetFleetName().ToString(), FleetData.ShipImmatriculations.Num()); continue; } Ship->SetCurrentFleet(this); FleetShips.Add(Ship); } } } /*---------------------------------------------------- Getters ----------------------------------------------------*/ TArray<UFlareSimulatedSpacecraft*>& UFlareFleet::GetShips() { InitShipList(); return FleetShips; } #undef LOCTEXT_NAMESPACE
21.995506
205
0.678075
eaglesquads
2f2a375aefbdd9e9c8fc035a4e34818f164495cd
8,026
cpp
C++
PhotonChat/LoadBalancing-cpp/src/Player.cpp
anhtrangg/PhotonChat
4bd5788fe4ec89dab83ae01d7f372b6e9bd5ebc9
[ "MIT" ]
null
null
null
PhotonChat/LoadBalancing-cpp/src/Player.cpp
anhtrangg/PhotonChat
4bd5788fe4ec89dab83ae01d7f372b6e9bd5ebc9
[ "MIT" ]
null
null
null
PhotonChat/LoadBalancing-cpp/src/Player.cpp
anhtrangg/PhotonChat
4bd5788fe4ec89dab83ae01d7f372b6e9bd5ebc9
[ "MIT" ]
null
null
null
/* Exit Games Photon LoadBalancing - C++ Client Lib * Copyright (C) 2004-2020 by Exit Games GmbH. All rights reserved. * http://www.photonengine.com * mailto:developer@photonengine.com */ #include "LoadBalancing-cpp/inc/Player.h" #include "LoadBalancing-cpp/inc/MutableRoom.h" #include "LoadBalancing-cpp/inc/Internal/Utils.h" #include "LoadBalancing-cpp/inc/Internal/Enums/Properties/Player.h" /** @file inc/Player.h */ namespace ExitGames { namespace LoadBalancing { using namespace Common; using namespace Internal; /** @class Player Each client inside a MutableRoom is represented by an instance of this class. Player instances are only valid in the context of the MutableRoom() instance from which they have been retrieved. @sa MutablePlayer, MutableRoom, MutableRoom::getPlayers(), MutableRoom::getPlayerForNumber() */ Player::Player(void) : mNumber(-1) , mpRoom(NULL) , mIsInactive(false) { } Player::Player(int number, const Hashtable& properties, const MutableRoom* const pRoom) : mNumber(number) , mpRoom(pRoom) , mIsInactive(false) { cacheProperties(properties); } /** Destructor. */ Player::~Player(void) { } /** Copy-Constructor: Creates a new instance that is a deep copy of the argument instance. @param toCopy The instance to copy. */ Player::Player(const Player& toCopy) { *this = toCopy; } /** operator=. Makes a deep copy of its right operand into its left operand. This overwrites old data in the left operand. */ Player& Player::operator=(const Player& toCopy) { return assign(toCopy); } bool Player::getIsMutable(void) const { return false; } Player& Player::assign(const Player& toCopy) { mNumber = toCopy.mNumber; mName = toCopy.mName; mUserID = toCopy.mUserID; mCustomProperties = toCopy.mCustomProperties; mpRoom = toCopy.mpRoom; return *this; } /** @returns the player number @details The player number serves as a the unique identifier of a player inside the current room. It is assigned per room and only valid in the context of that room. A player number is never re-used for another player inside the same room. If a player leaves a room entirely (either explicitly through a call to Client::opLeaveRoom() without passing 'true' for parameter 'willComeBack' or implicitly because his playerTtl runs out (see RoomOptions::setPlayerTtl())) and joins it again afterwards, then he is treated as an entirely new player and gets assigned a new player number. If a player becomes inactive (either explicitly through a call to Client::opLeaveRoom() with passing 'true' for parameter 'willComeBack' or implicitly by by getting disconnected) and then rejoins the same room before his playerTtl runs out, then he is treated as the same player an keeps his previously assigned player number. */ int Player::getNumber(void) const { return mNumber; } /** @returns the non-unique nickname of this player @details A player might change his own name. Such a change is synced automatically with the server and other clients in the same room. */ const JString& Player::getName(void) const { return mName; } /** @returns the unique user ID of this player @details This value is only available when the room got created with RoomOptions::setPublishUserId(true). Otherwise it will be an empty string. Useful for Client::opFindFriends() and and for blocking slots in a room for expected users (see MutableRoom::getExpectedUsers()). @sa AuthenticationValues */ const JString& Player::getUserID(void) const { return mUserID; } /** @returns the custom properties of this player @details Read-only cache for the custom properties of a player. A client can change the custom properties of his local player instance through class MutablePlayer. The Custom Properties of remote players are automatically updated when they change. */ const Hashtable& Player::getCustomProperties(void) const { return mCustomProperties; } void Player::setMutableRoomPointer(const MutableRoom* pRoom) { mpRoom = pRoom; } /** @returns 'true' if a player is inactive, 'false' otherwise. @details Inactive players keep their spot in a room but otherwise behave as if offline (no matter what their actual connection status is). The room needs a PlayerTtl != 0 (see RoomOptions::setPlayerTtl()) for players to be able to become inactive. If a player is inactive for longer than the PlayerTtl, then the server will remove this player from the room. */ bool Player::getIsInactive(void) const { return mIsInactive; } void Player::setIsInactive(bool isInActive) { mIsInactive = isInActive; } /** @returns 'true' if this player is the Master Client of the current room, 'false' otherwise. @details There is always exactly one master client. The creator of a room gets assigned the role of master client on room creation. When the current master client leaves the room or becomes inactive and there is at least one active player inside the room, then the role of master client gets reassigned by the server to an active client. As soon as one client becomes active again in a room with only inactive clients, the role of master client will be assigned to this active client. Whenever the role of master client gets assigned to a different client, all active clients inside the same room get informed about it by a call to Listener::onMasterClientChanged(). You can use the master client when you want one client to be an authoritative instance. @sa MutableRoom::getMasterClientID(), Listener::onMasterClientChanged(), DirectMode::MASTER_TO_ALL */ bool Player::getIsMasterClient(void) const { return mpRoom?mNumber==mpRoom->getMasterClientID():false; } void Player::cacheProperties(const Hashtable& properties) { if(properties.contains(Properties::Player::PLAYERNAME)) mName = ValueObject<JString>(properties.getValue(Properties::Player::PLAYERNAME)).getDataCopy(); if(properties.contains(Properties::Player::IS_INACTIVE)) mIsInactive = ValueObject<bool>(properties.getValue(Properties::Player::IS_INACTIVE)).getDataCopy(); if(properties.contains(Properties::Player::USER_ID)) mUserID = ValueObject<JString>(properties.getValue(Properties::Player::USER_ID)).getDataCopy(); mCustomProperties.put(Utils::stripToCustomProperties(properties)); mCustomProperties = Utils::stripKeysWithNullValues(mCustomProperties); } /** operator==. @returns true, if both operands are equal, false otherwise. @details Two Player instances are considered equal, if getNumber() returns equal values for both of them. */ bool Player::operator==(const Player& player) const { return getNumber() == player.getNumber(); } JString& Player::toString(JString& retStr, bool withTypes) const { return retStr += toString(withTypes, false); } /** @overload @param withTypes set to true, to include type information in the generated string @param withCustomProperties set to true, to include the custom properties in the generated string */ JString Player::toString(bool withTypes, bool withCustomProperties) const { return JString() + mNumber + L"={" + payloadToString(withTypes, withCustomProperties) + L"}"; } JString Player::payloadToString(bool withTypes, bool withCustomProperties) const { JString res = JString(L"num: ") + mNumber + L" name: " + mName + L" userID: " + mUserID; if(withCustomProperties && mCustomProperties.getSize()) res += L" props: " + mCustomProperties.toString(withTypes); return res; } } }
37.680751
254
0.704585
anhtrangg
2f2d19d613585ae90d9f868483c6d5e4c5517f44
2,157
hpp
C++
hdbitset-examples/Lottery/HybridOpenMpAndMPI/LotteryMPI.hpp
FinalLabsOrg/HdBitset
9ba2ad36f9bfc7c3f56233cc19d7a8d7fc613196
[ "MIT" ]
null
null
null
hdbitset-examples/Lottery/HybridOpenMpAndMPI/LotteryMPI.hpp
FinalLabsOrg/HdBitset
9ba2ad36f9bfc7c3f56233cc19d7a8d7fc613196
[ "MIT" ]
null
null
null
hdbitset-examples/Lottery/HybridOpenMpAndMPI/LotteryMPI.hpp
FinalLabsOrg/HdBitset
9ba2ad36f9bfc7c3f56233cc19d7a8d7fc613196
[ "MIT" ]
null
null
null
#pragma once #include <memory> #include <mpi.h> #include "hd.h" using namespace std; using namespace hyperdimensional; class LotteryMPI { public: template<unsigned uSize> static void decode(unsigned char* pTransfer, shared_ptr < hdbitset<uSize> > pTarget); template<unsigned uSize> static shared_ptr < hdbitset<uSize> > distribute(shared_ptr < hdbitset<uSize> > pOrigin); template<unsigned uSize> static void encode(unsigned char* pTransfer, shared_ptr < hdbitset<uSize> > pOrigin); static int getMyRank(); static bool isRoot(); static void test(); }; template<unsigned uSize> inline shared_ptr<hdbitset<uSize>> LotteryMPI::distribute(shared_ptr<hdbitset<uSize>> pOrigin) { unsigned char aTransfer[uHd10048]; if (isRoot()) { encode(aTransfer, pOrigin); } MPI_Bcast(&aTransfer, uHd10048, MPI_UNSIGNED_CHAR, ciHeadNode, MPI_COMM_WORLD); if (!isRoot()) { shared_ptr<hdbitset<uSize>> pTarget = hdfactory<uSize>::zero(); decode(aTransfer, pTarget); return pTarget; } else { return pOrigin; } } template<unsigned uSize> inline void LotteryMPI::decode(unsigned char* pTransfer, shared_ptr<hdbitset<uSize>> pTarget) { for (unsigned u = 0; u < uSize; u++) { pTarget->operator[](u) = pTransfer[u]; } } template<unsigned uSize> inline void LotteryMPI::encode(unsigned char* pTransfer, shared_ptr<hdbitset<uSize>> pOrigin) { for (unsigned u = 0; u < uSize; u++) { pTransfer[u] = pOrigin->operator[](u); } } inline int LotteryMPI::getMyRank() { int iMyRank; MPI_Comm_rank(MPI_COMM_WORLD, &iMyRank); return iMyRank; } inline bool LotteryMPI::isRoot() { return getMyRank() == ciHeadNode; } void LotteryMPI::test() { unsigned char aTransfer[uHd10048]; shared_ptr<hdbitset<uHd10048>> pSource = hdfactory<uHd10048>::random(); shared_ptr<hdbitset<uHd10048>> pTarget = hdfactory<uHd10048>::zero(); LotteryMPI::encode(aTransfer, pSource); LotteryMPI::decode(aTransfer, pTarget); if (!hdops<uHd10048>::eq(pSource, pTarget)) { cout << "MPI data transfer test failed." << endl; exit(0); } }
24.793103
94
0.683357
FinalLabsOrg
2f2ee8bf840e08ee139cb83907aac4df2503553c
220
cpp
C++
nekoichi/SDK/spi.cpp
ecilasun/riscvtool
82a6184f2187044c6be81576d00cacb95a518cbc
[ "MIT" ]
1
2021-10-05T20:30:50.000Z
2021-10-05T20:30:50.000Z
nekoichi/SDK/spi.cpp
ecilasun/riscvtool
82a6184f2187044c6be81576d00cacb95a518cbc
[ "MIT" ]
null
null
null
nekoichi/SDK/spi.cpp
ecilasun/riscvtool
82a6184f2187044c6be81576d00cacb95a518cbc
[ "MIT" ]
1
2021-04-02T22:24:04.000Z
2021-04-02T22:24:04.000Z
#include "spi.h" volatile uint8_t *IO_SPIOutput = (volatile uint8_t* )0x80000014; // SPU send data (write) volatile uint8_t *IO_SPIInput = (volatile uint8_t* )0x80000010; // SPI receive data (read)
44
101
0.672727
ecilasun
2f2f363a4ec7d828617dd49cb8ab40ba7164e0f6
95
cpp
C++
tast/main.cpp
lymslive/fast-cpp-csv-parser
d090446dd9185498c386cf04a5e54e6fa0d5a62e
[ "BSD-3-Clause" ]
null
null
null
tast/main.cpp
lymslive/fast-cpp-csv-parser
d090446dd9185498c386cf04a5e54e6fa0d5a62e
[ "BSD-3-Clause" ]
null
null
null
tast/main.cpp
lymslive/fast-cpp-csv-parser
d090446dd9185498c386cf04a5e54e6fa0d5a62e
[ "BSD-3-Clause" ]
null
null
null
#include "tinytast.hpp" int main(int argc, char* argv[]) { return RUN_TAST(argc, argv); }
13.571429
32
0.652632
lymslive
2f3350442104652be8d1ccf6f421c76a40935adf
1,598
cpp
C++
PRATICA2/TesteFiguras2.cpp
JP-Clemente/INF213_UFV
8d6b3afd02212a0ba58ddaec04df5bb87aef9f5d
[ "MIT" ]
2
2020-11-29T08:06:31.000Z
2020-12-04T13:35:17.000Z
PRATICA2/TesteFiguras2.cpp
JP-Clemente/INF213_UFV
8d6b3afd02212a0ba58ddaec04df5bb87aef9f5d
[ "MIT" ]
null
null
null
PRATICA2/TesteFiguras2.cpp
JP-Clemente/INF213_UFV
8d6b3afd02212a0ba58ddaec04df5bb87aef9f5d
[ "MIT" ]
null
null
null
/* --------------- Arquivo|: TestaFiguras3.cpp ----------------- Testa as classes Retangulo, Circulo e Segemento usando heranca. Criado por Marcus V. A. Andrade - 21/05/2014 Atualizado por Marcus V. A. Andrade - 21/03/2016 */ #include <cstdlib> #include <iostream> #include "Circulo.h" #include "Retangulo.h" #include "Segmento.h" using namespace std; int main(int argc, char *argv[]) { Circulo c1(100, 120, 30, 3, 2, 1); c1.imprime(); Retangulo r1(40, 50, 80, 30, 1, 2, 3); r1.imprime(); Circulo c2 = c1; c2.setX(25); c2.setY(17); c2.setRaio(25); c2.setEspessura(9); // utiliza um valor invalido c2.imprime(); Segmento s(11.34, 45.19, 13.24, 52.17, 2, 2, 1); s.imprime(); return 0; } /* --------------- RESULTADO ESPERADO ----------------------- --- [Circulo] --- Atributos da linha: Espessura = 3 Cor = 2 Tipo = 1 x = 100 y = 120 raio=30 area = 2827.43 perimetro = 188.496 --- [Retangulo] --- Atributos da linha: Espessura = 1 Cor = 2 Tipo = 3 x = 40 y = 50 largura=80 altura=30 area = 2400 perimetro = 220 --- [Circulo] --- Atributos da linha: Espessura = 1 Cor = 2 Tipo = 1 x = 25 y = 17 raio=25 area = 1963.5 perimetro = 157.08 --- [Segmento] --- Atributos da linha: Espessura = 2 Cor = 2 Tipo = 1 x = 11.34 y = 45.19 x2 = 13.24 Y2 = 52.17 area = 0 perimetro = 7.23398 -------------------------------------------------------------*/
21.306667
65
0.496871
JP-Clemente
2f351b4bb20eaa74d5d140443ef68bd82368e304
1,019
hh
C++
src/services/IClock.hh
Jamiras/RAIntegration
ccf3dea24d81aefdcf51535f073889d03272b259
[ "MIT" ]
71
2018-04-15T13:02:43.000Z
2022-03-26T11:19:18.000Z
src/services/IClock.hh
Jamiras/RAIntegration
ccf3dea24d81aefdcf51535f073889d03272b259
[ "MIT" ]
309
2018-04-15T12:10:59.000Z
2022-01-22T20:13:04.000Z
src/services/IClock.hh
Jamiras/RAIntegration
ccf3dea24d81aefdcf51535f073889d03272b259
[ "MIT" ]
17
2018-04-17T16:09:31.000Z
2022-03-04T08:49:03.000Z
#ifndef RA_SERVICES_ICLOCK_HH #define RA_SERVICES_ICLOCK_HH #pragma once namespace ra { namespace services { class IClock { public: virtual ~IClock() noexcept = default; IClock(const IClock&) noexcept = delete; IClock& operator=(const IClock&) noexcept = delete; IClock(IClock&&) noexcept = delete; IClock& operator=(IClock&&) noexcept = delete; /// <summary> /// Gets the current system time. /// </summary> /// <remarks>May change if the user adjusts their clock or the system does (daylight savings).</remarks> virtual std::chrono::system_clock::time_point Now() const = 0; /// <summary> /// Gets a <c>time_point</c> that represents how long the system has been running. /// </summary> /// <remarks>Is not affected by the user adjusting their clock.</remarks> virtual std::chrono::steady_clock::time_point UpTime() const = 0; protected: IClock() noexcept = default; }; } // namespace services } // namespace ra #endif // !RA_SERVICES_ILOGGER_HH
27.540541
108
0.683023
Jamiras
2f3ca2f463d421cf97c7bdc62b05ab686f70895f
1,082
cc
C++
utils/file_loader.cc
stryku/cougar
5352860e89261a6dadd45a2b7b2c6ae421322c0c
[ "Apache-2.0" ]
null
null
null
utils/file_loader.cc
stryku/cougar
5352860e89261a6dadd45a2b7b2c6ae421322c0c
[ "Apache-2.0" ]
4
2021-05-02T08:27:25.000Z
2021-05-15T08:37:26.000Z
utils/file_loader.cc
stryku/cougar
5352860e89261a6dadd45a2b7b2c6ae421322c0c
[ "Apache-2.0" ]
1
2021-04-24T20:20:58.000Z
2021-04-24T20:20:58.000Z
#include "file_loader.hh" #include <fmt/core.h> #include <cerrno> #include <cstdio> #include <stdexcept> namespace Cougar::Utils { static constexpr std::size_t CHUNK_SIZE = 1000 * 1024; void FileLoader::load(const std::string &path) { clear(); FILE *f = std::fopen(path.c_str(), "r"); if (!f) { throw std::runtime_error(fmt::format("Error opening file '{}' : {}", path, std::strerror(errno))); } while (true) { chunk next = std::make_unique<std::byte[]>(CHUNK_SIZE); std::size_t r = std::fread(next.get(), 1, CHUNK_SIZE, f); if (r == 0) break; mSize += r; mChunks.push_back(std::move(next)); } std::fclose(f); } void FileLoader::clear() { mChunks.clear(); mSize = 0; } void FileLoader::copyTo(std::byte *out) const { std::size_t size = mSize; auto it = mChunks.begin(); while (size > 0) { auto chunkSize = std::min(size, CHUNK_SIZE); std::memcpy(out, it->get(), chunkSize); out += chunkSize; size -= chunkSize; ++it; } } } // namespace Cougar::Utils
19.321429
78
0.585952
stryku
2f3ca9a186b1b3c23b8b397365a41f6c879fe4d8
1,717
cpp
C++
source/POSIX/XMutex.cpp
MultiSight/multisight-xsdk
02268e1aeb1313cfb2f9515d08d131a4389e49f2
[ "BSL-1.0" ]
null
null
null
source/POSIX/XMutex.cpp
MultiSight/multisight-xsdk
02268e1aeb1313cfb2f9515d08d131a4389e49f2
[ "BSL-1.0" ]
null
null
null
source/POSIX/XMutex.cpp
MultiSight/multisight-xsdk
02268e1aeb1313cfb2f9515d08d131a4389e49f2
[ "BSL-1.0" ]
null
null
null
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // XSDK // Copyright (c) 2015 Schneider Electric // // Use, modification, and distribution is subject to the Boost Software License, // Version 1.0 (See accompanying file LICENSE). // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #include "XSDK/XMutex.h" #include "XSDK/Errors.h" #include "XSDK/OS.h" #include <errno.h> using namespace XSDK; XMutex::XMutex() : _lok() { pthread_mutexattr_t mutexAttributes; int err = pthread_mutexattr_init( &mutexAttributes ); if( err < 0 ) X_THROW(( "Unable to allocate mutex attributes: %s", GetErrorMsg(err).c_str() )); err = pthread_mutexattr_settype( &mutexAttributes, PTHREAD_MUTEX_RECURSIVE ); if( err < 0 ) X_THROW(( "Unable to specify recursive mutex: %s", GetErrorMsg(err).c_str() )); err = pthread_mutex_init( &_lok, &mutexAttributes ); if( err < 0 ) X_THROW(( "Unable to allocate a mutex: %s", GetErrorMsg(err).c_str() )); } XMutex::~XMutex() throw() { pthread_mutex_destroy( &_lok ); } void XMutex::Acquire() { int err = pthread_mutex_lock( &_lok ); if( err != 0 ) X_THROW(( "pthread_mutex_lock() failed: %s", GetErrorMsg(err).c_str() )); } void XMutex::Release() { int err = pthread_mutex_unlock( &_lok ); if( err != 0 ) X_THROW(( "pthread_mutex_unlock() failed: %s", GetErrorMsg(err).c_str() )); } bool XMutex::TryAcquire() { int err = pthread_mutex_trylock( &_lok ); if( err == 0 ) return true; if( err == EBUSY ) return false; X_THROW(( "pthread_mutex_trylock() failed: %s", GetErrorMsg(err).c_str() )); }
24.183099
89
0.57484
MultiSight
2f496817196fe59b0899d0260cd12eebb9812356
366
hpp
C++
liblava/util.hpp
liblava/liblava
0e99beb14b9fb32e9bbfa851903cee3110e5c605
[ "MIT" ]
471
2019-09-22T19:12:55.000Z
2022-03-24T23:25:23.000Z
liblava/util.hpp
Cons-Cat/liblava
d6551232320f45df231f444441716b772a48a612
[ "MIT" ]
68
2019-10-25T15:22:00.000Z
2022-03-24T08:52:16.000Z
liblava/util.hpp
Cons-Cat/liblava
d6551232320f45df231f444441716b772a48a612
[ "MIT" ]
31
2019-10-25T12:22:21.000Z
2022-03-28T15:49:11.000Z
/** * @file liblava/util.hpp * @brief Util module * @author Lava Block OÜ and contributors * @copyright Copyright (c) 2018-present, MIT License */ #pragma once #include <liblava/util/log.hpp> #include <liblava/util/random.hpp> #include <liblava/util/telegram.hpp> #include <liblava/util/thread.hpp> #include <liblava/util/utility.hpp>
24.4
56
0.68306
liblava
2f4ea30ffc57199857cf483cf9fbf937aa94aa36
1,172
cpp
C++
Marx/include/Marx/Renderer/Renderer.cpp
TecStylos/Marx
e4903ec6463ceb30614d046db145db2a4fd70133
[ "Apache-2.0" ]
null
null
null
Marx/include/Marx/Renderer/Renderer.cpp
TecStylos/Marx
e4903ec6463ceb30614d046db145db2a4fd70133
[ "Apache-2.0" ]
null
null
null
Marx/include/Marx/Renderer/Renderer.cpp
TecStylos/Marx
e4903ec6463ceb30614d046db145db2a4fd70133
[ "Apache-2.0" ]
1
2021-01-06T20:23:41.000Z
2021-01-06T20:23:41.000Z
#include "mxpch.h" #include "Renderer.h" namespace Marx { Renderer::SceneData* Renderer::s_sceneData = new Renderer::SceneData; void Renderer::init() { RenderCommand::init(); } void Renderer::beginScene(const OrthographicCamera& camera) { s_sceneData->viewProjectionMatrix = glm::transpose(camera.getViewProjectionMatrix()); } void Renderer::beginScene(const PerspectiveCamera& camera) { s_sceneData->viewProjectionMatrix = glm::transpose(camera.getViewProjectionMatrix()); } void Renderer::endScene() { } void Renderer::onWindowResize(uint32_t width, uint32_t height) { RenderCommand::setViewport(0, 0, width, height); } void Renderer::submit(const Reference<Shader>& shader, const Reference<VertexArray>& vertexArray, glm::mat4 transform, const Reference<Texture2D> texture) { transform = glm::transpose(transform); shader->updateUniform("c_viewProjection", &s_sceneData->viewProjectionMatrix, Marx::ShaderDataType::Mat4); shader->updateUniform("c_modelTransform", &transform, Marx::ShaderDataType::Mat4); shader->bind(); vertexArray->bind(); if (texture) texture->bind(); RenderCommand::drawIndexed(vertexArray); } }
26.044444
155
0.74744
TecStylos
2f508a584876ff1d3d6bbf308c715523958b1f7a
26,962
cpp
C++
lib/Ntreev.Windows.Forms.Grid/NativeClasses.cpp
NtreevSoft/GridControl
decb1169d9b230ce93be1f0e96305161f2a8d655
[ "MIT" ]
2
2018-04-30T06:25:37.000Z
2018-05-12T20:29:10.000Z
lib/Ntreev.Windows.Forms.Grid/NativeClasses.cpp
NtreevSoft/GridControl
decb1169d9b230ce93be1f0e96305161f2a8d655
[ "MIT" ]
null
null
null
lib/Ntreev.Windows.Forms.Grid/NativeClasses.cpp
NtreevSoft/GridControl
decb1169d9b230ce93be1f0e96305161f2a8d655
[ "MIT" ]
null
null
null
//===================================================================================================================== // Ntreev Grid for .Net 2.0.5190.32793 // https://github.com/NtreevSoft/GridControl // // Released under the MIT License. // // Copyright (c) 2010 Ntreev Soft co., Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the // Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. //===================================================================================================================== #include "StdAfx.h" #include "NativeClasses.h" #include "GrDCCreator.h" #include "NativeUtilities.h" #include "Resources.h" #include "Cell.h" #include "Row.h" #include "Tooltip.h" #include "TypeEditorForm.h" #include "CaptionRow.h" #include "FromNative.h" #include "RowCollection.h" #ifdef _DEBUG //#define _PRINT_INVALIDATE_RECT #endif namespace Ntreev { namespace Windows { namespace Forms { namespace Grid { namespace Native { /*GrFont* WinFormFontManager::FromManagedFont(System::Drawing::Font^ font) { if(font == nullptr) return nullptr; return GrFontCreator::Create(font->ToHfont().ToPointer()); } System::Drawing::Font^ WinFormFontManager::ToManagedFont(GrFont* pFont) { if(pFont == nullptr) return nullptr; if(pFont == m_pDefaultfont) return System::Windows::Forms::Control::DefaultFont; System::Drawing::Font^ font = pFont->ManagedRef; if(font == nullptr) { System::IntPtr ptr(GrFontCreator::GetFontHandle(pFont)); font = System::Drawing::Font::FromHfont(ptr); font = gcnew System::Drawing::Font(font->FontFamily, font->SizeInPoints, font->Style, System::Windows::Forms::Control::DefaultFont->Unit, font->GdiCharSet); pFont->ManagedRef = font; } return font; }*/ WinFormInvalidator::WinFormInvalidator(gcroot<Ntreev::Windows::Forms::Grid::GridControl^> gridControl) : m_gridControl(gridControl) { m_rectType = RectType_Empty; m_lockRef = 0; } void WinFormInvalidator::Invalidate() { if(m_rectType == RectType_Full) return; if(m_lockRef == 0) { #ifdef _PRINT_INVALIDATE_RECT System::Console::Write("full : "); #endif m_gridControl->Invalidate(false); } m_rectType = RectType_Full; } void WinFormInvalidator::Invalidate(int x, int y, int width, int height) { switch(m_rectType) { case RectType_Full: return; case RectType_Custom: { m_rect.left = std::min(x, m_rect.left); m_rect.top = std::min(y, m_rect.top); m_rect.right = std::max(x + width, m_rect.right); m_rect.bottom = std::max(y + height, m_rect.bottom); } break; case RectType_Empty: { m_rect = GrRect(GrPoint(x, y), GrSize(width, height)); } break; } if(m_lockRef == 0) { #ifdef _PRINT_INVALIDATE_RECT System::Console::Write("custom : "); #endif m_gridControl->Invalidate(m_rect, false); } m_rectType = RectType_Custom; } void WinFormInvalidator::Lock() { m_lockRef++; } void WinFormInvalidator::Unlock() { m_lockRef--; if(m_lockRef < 0) throw gcnew System::Exception("Invalidator의 잠금해제 횟수가 잠금 횟수보다 큽니다."); if(m_rectType == RectType_Custom) { #ifdef _PRINT_INVALIDATE_RECT System::Console::Write("custom by unlock {0} : ", c++); #endif m_gridControl->Invalidate(m_rect, false); } else if(m_rectType == RectType_Full) { #ifdef _PRINT_INVALIDATE_RECT System::Console::Write("full by unlock : {0}", w++); #endif m_gridControl->Invalidate(false); } m_rectType = RectType_Empty; } void WinFormInvalidator::Reset() { if(m_lockRef == 0) m_rectType = RectType_Empty; } bool WinFormInvalidator::IsInvalidated() const { return m_rectType != RectType_Empty; } WinFormScroll::WinFormScroll(gcroot<Ntreev::Windows::Forms::Grid::GridControl^> gridControl, int type) : m_gridControl(gridControl) { m_type = type; m_min = 0; m_max = 100; m_value = 0; m_smallChange = 1; m_largeChange = 10; } WinFormScroll::~WinFormScroll() { } int WinFormScroll::GetValue() const { return m_value; } void WinFormScroll::SetValue(int value) { using namespace System::Windows::Forms; int oldValue = m_value; if(this->SetValueCore(value) == false) return; ScrollEventArgs se(ScrollEventType::ThumbPosition, oldValue, m_value, (ScrollOrientation)m_type); m_gridControl->InvokeScroll(%se); } int WinFormScroll::GetSmallChange() const { return m_smallChange; } void WinFormScroll::SetSmallChange(int value) { m_smallChange = value; } int WinFormScroll::GetLargeChange() const { return m_largeChange; } void WinFormScroll::SetLargeChange(int value) { m_largeChange = value; Native::Methods::SetScrollPage(m_gridControl->Handle, m_type, m_largeChange); } int WinFormScroll::GetMaximum() const { return m_max; } void WinFormScroll::SetMaximum(int value) { m_max = value; Native::Methods::SetScrollRange(m_gridControl->Handle, m_type, m_min, m_max); } int WinFormScroll::GetMinimum() const { return m_min; } void WinFormScroll::SetMinimum(int value) { m_min = value; Native::Methods::SetScrollRange(m_gridControl->Handle, m_type, m_min, m_max); } bool WinFormScroll::GetVisible() const { return m_visible; } void WinFormScroll::SetVisible(bool value) { if(m_type == 0 && m_gridControl->HScrollInternal == false) value = false; else if(m_type == 1 && m_gridControl->VScrollInternal == false) value = false; m_visible = value; Native::Methods::SetScrollVisible(m_gridControl->Handle, m_type, m_visible); } void WinFormScroll::WndProc(System::IntPtr handle, System::IntPtr wParam) { using namespace System::Windows::Forms; int nValue = m_value; ScrollEventType ScrollType; switch(Native::Methods::LoWord(wParam)) { case SB_ENDSCROLL: { ScrollType = ScrollEventType::EndScroll; } break; case SB_LEFT: { nValue = m_min; ScrollType = ScrollEventType::First; } break; case SB_RIGHT: { nValue = m_max; ScrollType = ScrollEventType::Last; } break; case SB_LINELEFT: { nValue -= m_smallChange; ScrollType = ScrollEventType::SmallDecrement; } break; case SB_LINERIGHT: { nValue += m_smallChange; ScrollType = ScrollEventType::SmallIncrement; } break; case SB_PAGELEFT: { nValue -= m_largeChange; ScrollType = ScrollEventType::LargeDecrement; } break; case SB_PAGERIGHT: { nValue += m_largeChange; ScrollType = ScrollEventType::LargeIncrement; } break; case SB_THUMBTRACK: { if(Native::Methods::GetScrollTrackPosition(handle, m_type, &nValue) == false) return; ScrollType = ScrollEventType::ThumbTrack; } break; default: return; } SetValue(nValue, (int)ScrollType); } void WinFormScroll::SetValue(int value, int scrollEventType) { using namespace System::Windows::Forms; int oldValue = m_value; if(this->SetValueCore(value) == false) return; ScrollEventArgs se((ScrollEventType)scrollEventType, oldValue, m_value, (ScrollOrientation)m_type); m_gridControl->InvokeScroll(%se); } bool WinFormScroll::SetValueCore(int value) { int oldValue = m_value; int newValue = this->ValidateValue(value); if(oldValue == newValue) return false; m_value = newValue; Native::Methods::SetScrollValue(m_gridControl->Handle, m_type, newValue); return true; } WinFormTimer::Timer::Timer(WinFormTimer* winformTimer, Ntreev::Windows::Forms::Grid::GridControl^ gridControl) : m_winformTimer(winformTimer) { BeginInit(); Enabled = false; SynchronizingObject = gridControl; AutoReset = true; EndInit(); this->Elapsed += gcnew System::Timers::ElapsedEventHandler(this, &Timer::elapsed); } void WinFormTimer::Timer::elapsed(System::Object^ /*sender*/, System::Timers::ElapsedEventArgs^ e) { m_winformTimer->Invoke(e->SignalTime.Millisecond); } WinFormTimer::WinFormTimer(gcroot<Ntreev::Windows::Forms::Grid::GridControl^> gridControl) : m_gridControl(gridControl) { m_timer = gcnew Timer(this, m_gridControl); m_timer->AutoReset = true; } void WinFormTimer::Start() { m_timer->Start(); } void WinFormTimer::Stop() { m_timer->Stop(); } void WinFormTimer::SetInterval(time_t interval) { m_timer->Interval = (double)interval; } void WinFormTimer::Invoke(time_t signalTime) { InvokeElapsed(signalTime); } WinFormWindow::WinFormWindow(gcroot<Ntreev::Windows::Forms::Grid::GridControl^> gridControl) : m_gridControl(gridControl), m_horzScroll(m_gridControl, 0), m_vertScroll(m_gridControl, 1), m_invalidator(m_gridControl) { m_pGridPainter = CreateGridPainterDC(m_gridControl->Handle.ToPointer()); System::IO::Stream^ stream; stream = Ntreev::Windows::Forms::Grid::GridControl::typeid->Assembly->GetManifestResourceStream("Ntreev.Windows.Forms.Grid.Cursors.Movable.cur"); m_cursorMove = gcnew System::Windows::Forms::Cursor(stream); delete stream; stream = Ntreev::Windows::Forms::Grid::GridControl::typeid->Assembly->GetManifestResourceStream("Ntreev.Windows.Forms.Grid.Cursors.Add.cur"); m_cursorAdd = gcnew System::Windows::Forms::Cursor(stream); delete stream; stream = Ntreev::Windows::Forms::Grid::GridControl::typeid->Assembly->GetManifestResourceStream("Ntreev.Windows.Forms.Grid.Cursors.Remove.cur"); m_cursorRemove = gcnew System::Windows::Forms::Cursor(stream); delete stream; //m_pFont = WinFormFontManager::FromManagedFont(m_gridControl->Font); } GrRect WinFormWindow::GetSrceenRect() const { return System::Windows::Forms::Screen::PrimaryScreen->Bounds; } GrPoint WinFormWindow::ClientToScreen(const GrPoint& location) const { return m_gridControl->PointToScreen(location); } int WinFormWindow::GetMouseWheelScrollLines() const { return System::Windows::Forms::SystemInformation::MouseWheelScrollLines; } int WinFormWindow::GetMouseWheelScrollDelta() const { return System::Windows::Forms::SystemInformation::MouseWheelScrollDelta; } GrSize WinFormWindow::GetDragSize() const { return System::Windows::Forms::SystemInformation::DragSize; } bool WinFormWindow::GetMouseDragEventSupported() const { return false; } bool WinFormWindow::SetCursor(int cursor) { using namespace System::Windows::Forms; Cursor^ temp; switch(cursor) { case GrCursor_No: temp = Cursors::No; break; case GrCursor_Wait: temp = Cursors::WaitCursor; break; case GrCursor_Add: temp = m_cursorAdd; break; case GrCursor_Remove: temp = m_cursorRemove; break; case GrCursor_Move: temp = m_cursorMove; break; case GrCursor_HSplit: temp = Cursors::HSplit; break; case GrCursor_VSplit: temp = Cursors::VSplit; break; case GrCursor_SizeWE: temp = Cursors::SizeWE; break; case GrCursor_SizeNS: temp = Cursors::SizeNS; break; default: temp = Cursors::Default; break; } //if(m_gridControl->Site != nullptr) //{ // m_gridControl->Cursor = temp; // //m_gridControl->CaptionRow->Text = temp->ToString(); // //return System::Windows::Forms::Cursor::Current != System::Windows::Forms::Cursors::Default; // return true; //} if(m_gridControl->Cursor != temp) { m_gridControl->Cursor = temp; #ifdef _DEBUG System::Diagnostics::Trace::WriteLine(temp); #endif if(m_gridControl->Site != nullptr) { System::Windows::Forms::Cursor::Current = temp; } return true; } return false; } GrKeys WinFormWindow::GetModifierKeys() const { using namespace System::Windows::Forms; int modifierKeys = 0; if((Control::ModifierKeys & Keys::Control) == Keys::Control) modifierKeys |= GrKeys_Control; if((Control::ModifierKeys & Keys::Shift) == Keys::Shift) modifierKeys |= GrKeys_Shift; if((Control::ModifierKeys & Keys::Alt) == Keys::Alt) modifierKeys |= GrKeys_Alt; return (GrKeys)modifierKeys; } void WinFormWindow::OnEditValue(GrEditEventArgs* e) { using namespace System::Windows::Forms; using namespace Ntreev::Windows::Forms::Grid::Design; GrEditingReason reason = e->GetReason(); Ntreev::Windows::Forms::Grid::Cell^ cell = FromNative::Get(e->GetItem()); Ntreev::Windows::Forms::Grid::Row^ row = cell->Row; if(m_gridControl->InvokeEditBegun(cell) == false) return; //m_gridControl->Refresh(); TypeEditorForm^ form = gcnew TypeEditorForm(m_gridControl, cell, EditingReason(reason)); m_gridControl->Update(); try { System::Object^ newValue = cell->Column->EditValueInternal(form, cell, cell->Value); if(form->DialogResult != DialogResult::Cancel && newValue != nullptr) { if(row != m_gridControl->InsertionRow && cell->Row->Index < 0) throw gcnew System::Exception("행이 삭제 되었을수도 있습니다."); if(System::Object::Equals(newValue, cell->Value) == false) { cell->Value = newValue; e->SetHandled(true); } m_gridControl->Refresh(); } } catch(System::Exception^ e1) { m_gridControl->ShowMessage(e1->Message, "Error", MessageBoxButtons::OK, MessageBoxIcon::Error); //cell->CancelEdit(); } finally { delete form; } CellEventArgs ee(cell); m_gridControl->InvokeEditEnded(%ee); } GrScroll* WinFormWindow::GetHorzScroll() const { return const_cast<WinFormScroll*>(&m_horzScroll); } GrScroll* WinFormWindow::GetVertScroll() const { return const_cast<WinFormScroll*>(&m_vertScroll); } GrInvalidator* WinFormWindow::GetInvalidator() const { return const_cast<WinFormInvalidator*>(&m_invalidator); } GrGridPainter* WinFormWindow::GetGridPainter() const { return m_pGridPainter; } GrTimer* WinFormWindow::CreateTimer() { return new WinFormTimer(m_gridControl); } void WinFormWindow::DestroyTimer(GrTimer* pTimer) { delete pTimer; } bool WinFormWindow::CanEdit(GrItem* pItem, GrEditingReason reason) { Ntreev::Windows::Forms::Grid::Cell^ cell = FromNative::Get(pItem); //if(GrGridWindow::CanEdit(pItem, reason) == false) return cell->Column->CanEditInternal(cell, Ntreev::Windows::Forms::Grid::EditingReason(reason)); } WinFormGridCore::WinFormGridCore(gcroot<Ntreev::Windows::Forms::Grid::GridControl^> gridControl, GrGridWindow* pGridWindow) : GrGridCore(pGridWindow), m_gridControl(gridControl) { GrColumnList* pColumnList = GetColumnList(); pColumnList->ColumnMouseDown.Add(this, &WinFormGridCore::columnList_ColumnMouseDown); pColumnList->ColumnMouseEnter.Add(this, &WinFormGridCore::columnList_ColumnMouseEnter); pColumnList->ColumnMouseLeave.Add(this, &WinFormGridCore::columnList_ColumnMouseLeave); pColumnList->ColumnMouseMove.Add(this, &WinFormGridCore::columnList_ColumnMouseMove); pColumnList->ColumnMouseUp.Add(this, &WinFormGridCore::columnList_ColumnMouseUp); pColumnList->ColumnWidthChanged.Add(this,&WinFormGridCore::columnList_ColumnWidthChanged); pColumnList->ColumnFrozenChanged.Add(this,&WinFormGridCore::columnList_ColumnFrozenChanged); pColumnList->ColumnVisibleIndexChanged.Add(this,&WinFormGridCore::columnList_ColumnVisibleIndexChanged); GrFocuser* pFocuser = GetFocuser(); pFocuser->FocusChanging.Add(this, &WinFormGridCore::focuser_FocusChanging); pFocuser->FocusChanged.Add(this, &WinFormGridCore::focuser_FocusChanged); GrItemSelector* pItemSelector = GetItemSelector(); pItemSelector->SelectedRowsChanged.Add(this, &WinFormGridCore::itemSelector_SelectedRowsChanged); pItemSelector->SelectedColumnsChanged.Add(this, &WinFormGridCore::itemSelector_SelectedColumnsChanged); pItemSelector->SelectionChanged.Add(this, &WinFormGridCore::itemSelector_SelectionChanged); GrCaption* pCaption = GetCaptionRow(); pCaption->HeightChanged.Add(this, &WinFormGridCore::caption_HeightChanged); GrDataRowList* pDataRowList = GetDataRowList(); pDataRowList->DataRowMoved.Add(this, &WinFormGridCore::dataRowList_DataRowMoved); } void WinFormGridCore::OnItemMouseMove(GrItemMouseEventArgs* e) { GrGridCore::OnItemMouseMove(e); if(m_gridControl->InvokeCellMouseMove(FromNative::Get(e->GetItem()), e->GetLocation()) == true) { e->SetHandled(true); } } void WinFormGridCore::OnItemMouseClick(GrItemMouseEventArgs* e) { GrGridCore::OnItemMouseClick(e); m_gridControl->InvokeCellClick(FromNative::Get(e->GetItem())); } void WinFormGridCore::OnItemMouseDoubleClick(GrItemMouseEventArgs* e) { GrGridCore::OnItemMouseDoubleClick(e); m_gridControl->InvokeCellDoubleClick(FromNative::Get(e->GetItem())); } void WinFormGridCore::OnItemMouseEnter(GrItemMouseEventArgs* e) { GrGridCore::OnItemMouseEnter(e); m_gridControl->InvokeCellMouseEnter(FromNative::Get(e->GetItem())); } void WinFormGridCore::OnItemMouseLeave(GrItemMouseEventArgs* e) { GrGridCore::OnItemMouseLeave(e); m_gridControl->InvokeCellMouseLeave(FromNative::Get(e->GetItem())); } void WinFormGridCore::OnRowMouseEnter(GrRowMouseEventArgs* e) { GrGridCore::OnRowMouseEnter(e); GrDataRow* pDataRow = dynamic_cast<GrDataRow*>(e->GetRow()); if(pDataRow == nullptr) return; try { Ntreev::Windows::Forms::Grid::Row^ row = FromNative::Get(pDataRow); if(row != nullptr && row->ErrorDescription != System::String::Empty) m_gridControl->ToolTip->Show(row->ErrorDescription); } catch(System::Exception^) { } } void WinFormGridCore::OnRowMouseMove(GrRowMouseEventArgs* /*e*/) { } void WinFormGridCore::OnRowMouseLeave(GrRowMouseEventArgs* e) { GrGridCore::OnRowMouseLeave(e); m_gridControl->ToolTip->Hide(); } void WinFormGridCore::PostPaint(GrGridPainter* pPainter, const GrRect& clipRect) const { System::Drawing::Graphics^ graphics = System::Drawing::Graphics::FromHdc(System::IntPtr(pPainter->GetDevice())); m_gridControl->PostPaint(graphics, clipRect); delete graphics; GrGridCore::PostPaint(pPainter, clipRect); } void WinFormGridCore::columnList_ColumnMouseDown(GrObject* /*pSender*/, GrColumnMouseEventArgs* e) { Column^ column = FromNative::Get(e->GetColumn()); if(m_gridControl->Site == nullptr) { bool handled = m_gridControl->InvokeColumnMouseDown(column, e->GetLocation()); e->SetHandled(handled); return; } using namespace System::ComponentModel::Design; ISelectionService^ selectionService = (ISelectionService^)m_gridControl->GetInternalService(ISelectionService::typeid); cli::array<System::Object^>^ components = gcnew cli::array<System::Object^>(1) { column, }; selectionService->SetSelectedComponents(components); e->SetHandled(true); } void WinFormGridCore::columnList_ColumnMouseUp(GrObject* /*pSender*/, GrColumnMouseEventArgs* e) { Column^ column = FromNative::Get(e->GetColumn()); bool handled = m_gridControl->InvokeColumnMouseUp(column, e->GetLocation()); e->SetHandled(handled); } void WinFormGridCore::columnList_ColumnMouseEnter(GrObject* /*pSender*/, GrColumnMouseEventArgs* e) { Column^ column = FromNative::Get(e->GetColumn()); m_gridControl->InvokeColumnMouseEnter(column, e->GetLocation()); } void WinFormGridCore::columnList_ColumnMouseLeave(GrObject* /*pSender*/, GrColumnMouseEventArgs* e) { Column^ column = FromNative::Get(e->GetColumn()); m_gridControl->InvokeColumnMouseLeave(column); } void WinFormGridCore::columnList_ColumnMouseMove(GrObject* /*pSender*/, GrColumnMouseEventArgs* e) { Column^ column = FromNative::Get(e->GetColumn()); if(m_gridControl->InvokeColumnMouseMove(column, e->GetLocation()) == true) { e->SetHandled(true); } } void WinFormGridCore::columnList_ColumnWidthChanged(GrObject* /*pSender*/, GrColumnEventArgs* e) { Column^ column = FromNative::Get(e->GetColumn()); m_gridControl->InvokeColumnWidthChanged(column); } void WinFormGridCore::columnList_ColumnFrozenChanged(GrObject* /*pSender*/, GrColumnEventArgs* e) { Column^ column = FromNative::Get(e->GetColumn()); m_gridControl->InvokeColumnFrozenChanged(column); } void WinFormGridCore::columnList_ColumnVisibleIndexChanged(GrObject* /*pSender*/, GrColumnEventArgs* e) { Column^ column = FromNative::Get(e->GetColumn()); m_gridControl->InvokeColumnVisibleIndexChanged(column); } void WinFormGridCore::focuser_FocusChanging(GrObject* /*pSender*/, GrFocusChangeArgs* /*e*/) { m_gridControl->InvokeFocusChanging(); } void WinFormGridCore::focuser_FocusChanged(GrObject* /*pSender*/, GrFocusChangeArgs* /*e*/) { m_gridControl->InvokeFocusChanged(); } void WinFormGridCore::itemSelector_SelectedRowsChanged(GrObject* /*pSender*/, GrEventArgs* /*e*/) { m_gridControl->InvokeSelectedRowsChanged(); } void WinFormGridCore::itemSelector_SelectedColumnsChanged(GrObject* /*pSender*/, GrEventArgs* /*e*/) { m_gridControl->InvokeSelectedColumnsChanged(); } void WinFormGridCore::itemSelector_SelectionChanged(GrObject* /*pSender*/, GrEventArgs* /*e*/) { m_gridControl->InvokeSelectionChanged(); } void WinFormGridCore::caption_HeightChanged(GrObject* /*pSender*/, GrEventArgs* /*e*/) { if(m_gridControl->Site == nullptr) return; using namespace System::ComponentModel; using namespace System::ComponentModel::Design; IComponentChangeService^ service = dynamic_cast<IComponentChangeService^>(m_gridControl->GetInternalService(IComponentChangeService::typeid)); PropertyDescriptor^ propertyDescriptor = TypeDescriptor::GetProperties(m_gridControl)["Caption"]; service->OnComponentChanging(m_gridControl, propertyDescriptor); service->OnComponentChanged(m_gridControl, propertyDescriptor, nullptr, nullptr); } void WinFormGridCore::dataRowList_DataRowMoved(GrObject* /*pSender*/, GrDataRowEventArgs* e) { Row^ row = FromNative::Get(e->GetDataRow()); m_gridControl->InvokeRowMoved(row); } } /*namespace Native*/ } /*namespace Grid*/ } /*namespace Forms*/ } /*namespace Windows*/ } /*namespace Ntreev*/
33.245376
169
0.605296
NtreevSoft
0174fd08d5828c39dc60ea261595bee6764a9344
1,686
cpp
C++
Introductory Problems/grid_paths.cpp
vjerin/CSES-Problem-Set
68070812fa1d27e4653f58dcdabed56188a45110
[ "Apache-2.0" ]
null
null
null
Introductory Problems/grid_paths.cpp
vjerin/CSES-Problem-Set
68070812fa1d27e4653f58dcdabed56188a45110
[ "Apache-2.0" ]
10
2020-10-02T10:28:22.000Z
2020-10-09T18:30:56.000Z
Introductory Problems/grid_paths.cpp
vjerin/CSES-Problem-Set
68070812fa1d27e4653f58dcdabed56188a45110
[ "Apache-2.0" ]
10
2020-10-02T11:16:32.000Z
2020-10-08T18:31:18.000Z
#include <bits/stdc++.h> #define int long long #define MOD 1000000007 using namespace std; int res = 0; bool empty(bool grid[7][7], int r, int c) { if(r < 0 || r >= 7 || c < 0 || c >= 7) { return false; } if(grid[r][c]) { return false; } return true; } void get_paths(bool grid[7][7], string& s, int r, int c, int idx) { // cout << r << " " << c << " " << idx << " " << res << endl; if(r == 6 && c == 0) { if(idx == 48) { res++; } return; } grid[r][c] = true; if(s[idx] == '?' || s[idx] == 'U') { if(empty(grid, r - 1, c) && !(!empty(grid, r - 2, c) && empty(grid, r - 1, c - 1) && empty(grid, r - 1, c + 1))) get_paths(grid, s, r - 1, c, idx + 1); } if(s[idx] == '?' || s[idx] == 'D') { if(empty(grid, r + 1, c) && !(!empty(grid, r + 2, c) && empty(grid, r + 1, c - 1) && empty(grid, r + 1, c + 1))) get_paths(grid, s, r + 1, c, idx + 1); } if(s[idx] == '?' || s[idx] == 'L') { if(empty(grid, r, c - 1) && !(!empty(grid, r, c - 2) && empty(grid, r - 1, c - 1) && empty(grid, r + 1, c - 1))) get_paths(grid, s, r, c - 1, idx + 1); } if(s[idx] == '?' || s[idx] == 'R') { if(empty(grid, r, c + 1) && !(!empty(grid, r, c + 2) && empty(grid, r - 1, c + 1) && empty(grid, r + 1, c + 1))) get_paths(grid, s, r, c + 1, idx + 1); } grid[r][c] = false; } void solve() { string s; cin >> s; bool grid[7][7] = {0}; get_paths(grid, s, 0, 0, 0); cout << res << endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
24.794118
120
0.422301
vjerin
01803520c752c9207288e4addc2ed994433faed9
1,473
cpp
C++
extra/news/src/apk/htxn/axfd/axfd/axfd-document.cpp
scignscape/PGVM
e24f46cdf657a8bdb990c7883c6bd3d0a0c9cff0
[ "BSL-1.0" ]
null
null
null
extra/news/src/apk/htxn/axfd/axfd/axfd-document.cpp
scignscape/PGVM
e24f46cdf657a8bdb990c7883c6bd3d0a0c9cff0
[ "BSL-1.0" ]
null
null
null
extra/news/src/apk/htxn/axfd/axfd/axfd-document.cpp
scignscape/PGVM
e24f46cdf657a8bdb990c7883c6bd3d0a0c9cff0
[ "BSL-1.0" ]
null
null
null
// Copyright Nathaniel Christen 2019. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include "axfd-document.h" #include "axfd-tile-scope.h" USING_KANS(AXFD) AXFD_Document::AXFD_Document() : stash_count_(2) { } QPair<AXFD_Tile_Scope*, u4> AXFD_Document::add_tile_scope_from_text(QString text) { QPair<QString*, u4> pr = stash_string(text); QPair<AXFD_Tile_Scope*, u4> result = stash_scope(); result.first->push_back({pr.second, 2}); // 2 == string stash id return result; //AXFD_Tile_Scope* result = } QString AXFD_Document::tile_scope_to_string(AXFD_Tile_Scope* ats) { return ats->to_sieved_string(*this); } QString AXFD_Document::get_string_from_layer( const AXFD_Tile_Code& atc, void* layer) { return {}; } QString AXFD_Document::get_string_from_stash(u4 code, u2 stash_id) { if(stash_id == 2) return *string_stash_.value(code - 1); return {}; } QPair<QString*, u4> AXFD_Document::stash_string(QString text) { QString* result = new QString(text); string_stash_.push_back(result); return {result, string_stash_.size() + stash_count_ + 2}; // 2 == string stash id } QPair<AXFD_Tile_Scope*, u4> AXFD_Document::stash_scope() { AXFD_Tile_Scope* result = new AXFD_Tile_Scope; scope_stash_.push_back(result); return {result, scope_stash_.size() + stash_count_ + 3}; // 3 == scope stash id }
21.661765
81
0.715547
scignscape
018188d65127b42feddb814bccbe94816bad407c
315
cc
C++
below2.1/magictrick.cc
danzel-py/Kattis-Problem-Archive
bce1929d654b1bceb104f96d68c74349273dd1ff
[ "Apache-2.0" ]
null
null
null
below2.1/magictrick.cc
danzel-py/Kattis-Problem-Archive
bce1929d654b1bceb104f96d68c74349273dd1ff
[ "Apache-2.0" ]
null
null
null
below2.1/magictrick.cc
danzel-py/Kattis-Problem-Archive
bce1929d654b1bceb104f96d68c74349273dd1ff
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <map> using namespace std; int main(){ string str; cin>>str; map<char,int> gtc; for (int i = 0; i < str.length(); i++) { if(gtc[str[i]]!=0){ cout<<0; return 0; } gtc[str[i]]++; } cout<<1; return 0; }
15
42
0.434921
danzel-py
0181b1a7e39a58bd7134d70dcc9a3accf02f9ad7
3,853
cpp
C++
Corpos Space/src/game/menu/Menu.cpp
Tomislaw/corpos
bf971cba98a92b8de68547d4f77252f645c9ef28
[ "MIT" ]
null
null
null
Corpos Space/src/game/menu/Menu.cpp
Tomislaw/corpos
bf971cba98a92b8de68547d4f77252f645c9ef28
[ "MIT" ]
null
null
null
Corpos Space/src/game/menu/Menu.cpp
Tomislaw/corpos
bf971cba98a92b8de68547d4f77252f645c9ef28
[ "MIT" ]
null
null
null
#include "Menu.hpp" #include "game/main/Game.hpp" using namespace corpos; void Menu::init() { menuList.setOptimalHeight(300); std::shared_ptr <MenuLabel> labelStart = std::make_shared<MenuLabel>(); labelStart->getLabel().setString("Start game"); labelStart->setOnClikAction([&]() { GameAssetsManager::loadTextures("bin/graphics/textures/texture_definition.txt"); GameAssetsManager::loadSprites("bin/graphics/sprite/sprite_definitions.txt"); game.mainGame.init("bin/map/map.json"); game.showGame(); }); menuList.addItem(labelStart); std::shared_ptr <MenuLabel> labelModules = std::make_shared<MenuLabel>(); labelModules->getLabel().setString("Modules"); labelModules->setOnClikAction([this]() {showMainMenu(false); showModules(true); showOptionss(false); }); menuList.addItem(labelModules); std::shared_ptr <MenuLabel> labelOptions = std::make_shared<MenuLabel>(); labelOptions->getLabel().setString("About"); labelOptions->setOnClikAction([this]() {showMainMenu(false); showModules(false); showOptionss(true); }); menuList.addItem(labelOptions); std::shared_ptr <MenuLabel> labelExit = std::make_shared<MenuLabel>(); labelExit->getLabel().setString("Exit"); labelExit->setOnClikAction([&]() {game.exit(); }); menuList.addItem(labelExit); menuList.setPosition(sf::Vector2f(100, 100)); sf::Texture & texture = *GameAssetsManager::getTexture("mainmenu"); sf::Vector2u size = texture.getSize(); background.setTexture(texture); } void Menu::drawModules(sf::RenderWindow & target) { ImGui::Begin("Modules", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar); auto windowSize = target.getSize(); auto margin = sf::Vector2u(100, windowSize.y / 10); auto size = windowSize - (margin + margin); ImGui::SetWindowPos(margin); ImGui::SetWindowSize(size); ImGui::Text("Modules"); static int listbox_item_current = 0; ImGui::ListBox("Choose module to play", &listbox_item_current, [](void* vec, int idx, const char** out_text) { auto& vector = *static_cast<std::vector<std::string>*>(vec); if (idx < 0 || idx >= static_cast<int>(vector.size())) { return false; } *out_text = vector.at(idx).c_str(); return true; }, reinterpret_cast<void*>(&chooser.modules), chooser.modules.size(), size.y / 20); ImGui::SetCursorPos(sf::Vector2u(15, size.y - 55)); if (ImGui::Button("Play", sf::Vector2i(80, 40))) { auto moduleLocation = chooser.modules.at(listbox_item_current); GameAssetsManager::loadTextures(moduleLocation + "/graphics/textures/texture_definition.txt"); GameAssetsManager::loadSprites(moduleLocation + "/graphics/sprite/sprite_definitions.txt"); game.mainGame.init(moduleLocation + "/map/map.txt"); game.showGame(); } ImGui::SetCursorPos(size - sf::Vector2u(95, 55)); if (ImGui::Button("Back", sf::Vector2i(80, 40))) { showMainMenu(true); showModules(false); showOptionss(false); } ImGui::End(); // end window } void Menu::drawOptions(sf::RenderWindow & target) { ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar); auto windowSize = target.getSize(); auto margin = sf::Vector2u(100, windowSize.y / 10); auto size = windowSize - (margin + margin); ImGui::SetWindowPos(margin); ImGui::SetWindowSize(size); ImGui::Text("Controls"); ImGui::Text(" "); ImGui::Text("W - jump"); ImGui::Text("A - walk left"); ImGui::Text("D - walk right"); ImGui::Text("LMB - shoot"); ImGui::Text(" "); ImGui::Text(" "); ImGui::Text("About"); ImGui::Text(" "); ImGui::Text("Created by Tomasz Staniewski"); ImGui::SetCursorPos(size - sf::Vector2u(95, 55)); if (ImGui::Button("Back", sf::Vector2i(80, 40))) { showMainMenu(true); showModules(false); showOptionss(false); } ImGui::End(); // end window }
36.695238
148
0.717623
Tomislaw
0183801b730cc225e2dd9d50d57ff6f1487bf607
278
cpp
C++
SRGB/src/main.cpp
danimtz/RendererGoBrrr
89b179ec048f751c9078f267cd989d1bcc041d8b
[ "MIT" ]
null
null
null
SRGB/src/main.cpp
danimtz/RendererGoBrrr
89b179ec048f751c9078f267cd989d1bcc041d8b
[ "MIT" ]
null
null
null
SRGB/src/main.cpp
danimtz/RendererGoBrrr
89b179ec048f751c9078f267cd989d1bcc041d8b
[ "MIT" ]
null
null
null
#include <iostream> #include "Application.h" #include "Mesh.h" #include "OBJLoader.h" int main(int argc, char* args[]) { Application *app = new Application(); app->run(); delete app; //Mesh *aaa = OBJLoader::loadMesh("assets\\cube2.obj"); return 0; }
9.266667
56
0.622302
danimtz
0185f3f01de403e5233afb7de70bdffe63e9d348
1,258
hpp
C++
sdk/core/perf/inc/azure/perf/program.hpp
chidozieononiwu/azure-sdk-for-cpp
7d9032fcc815523231d6ff3e1d96d6212e94b079
[ "MIT" ]
null
null
null
sdk/core/perf/inc/azure/perf/program.hpp
chidozieononiwu/azure-sdk-for-cpp
7d9032fcc815523231d6ff3e1d96d6212e94b079
[ "MIT" ]
null
null
null
sdk/core/perf/inc/azure/perf/program.hpp
chidozieononiwu/azure-sdk-for-cpp
7d9032fcc815523231d6ff3e1d96d6212e94b079
[ "MIT" ]
null
null
null
// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT /** * @file * @brief Define the main performance framewoek program. * */ #pragma once #include "azure/perf/argagg.hpp" #include "azure/perf/test_metadata.hpp" #include <vector> namespace Azure { namespace Perf { /** * @brief Define a performance application. * */ class Program { private: class ArgParser { public: static argagg::parser_results Parse( int argc, char** argv, std::vector<Azure::Perf::TestOption> const& testOptions); static Azure::Perf::GlobalTestOptions Parse(argagg::parser_results const& parsedArgs); }; public: /** * @brief Start the performance application. * * @param context The strategy for cancelling the test execution. * @param tests The list of tests that the application can run. * @param argc The number of command line arguments. * @param argv The reference to the first null terminated command line argument. */ static void Run( Azure::Core::Context const& context, std::vector<Azure::Perf::TestMetadata> const& tests, int argc, char** argv); }; }} // namespace Azure::Perf
25.16
92
0.652623
chidozieononiwu
019213789bcdbd7b30c67d8c97c2afdd0050756d
3,735
cpp
C++
Builder/Builder/src/postprocesses_main.cpp
sglab/OpenIRT
1a1522ed82f6bb26f1d40dc93024487869045ab2
[ "BSD-2-Clause" ]
2
2015-09-28T12:59:25.000Z
2020-03-28T22:28:03.000Z
Builder/Builder/src/postprocesses_main.cpp
sglab/OpenIRT
1a1522ed82f6bb26f1d40dc93024487869045ab2
[ "BSD-2-Clause" ]
2
2018-10-26T12:17:53.000Z
2018-11-09T07:04:17.000Z
Builder/Builder/src/postprocesses_main.cpp
sglab/OpenIRT
1a1522ed82f6bb26f1d40dc93024487869045ab2
[ "BSD-2-Clause" ]
null
null
null
// compress_main.cpp : Defines the entry point for the console application. // #include <iostream> #include <stdio.h> #include "DirectTriIndex.h" #include "RearrangeVoxels.h" #include "ExtractBB.h" #include "MergeGeometry.h" #include "HCCMesh.h" #include "GeometryConverter.h" #include "Voxelize.h" #include "MTLGenerator.h" #include "OptionManager.h" #define REMOVE_INDEX 0x1 #define HCCMESH 0x2 #define MTL 0x4 #define ASVO 0x8 #define GPU 0x10 using namespace std; int main(int argc, char ** argv) { char fileName[255]; char filePath[255]; char outputPath[255]; printf ("Usage: %s file \"REMOVE_INDEX | HCCMESH | MTL | ASVO | GPU\" ASVO_options\n", argv [0]); sprintf(outputPath, "."); if (argc >= 2) { strcpy(fileName, argv[1]); } else sprintf(fileName, "test.ply"); OptionManager *opt = OptionManager::getSingletonPtr(); //const char *baseDirName = opt->getOption("global", "scenePath", ""); char tempFileName[MAX_PATH]; int pos = 0; for(int i=strlen(fileName)-1;i>=0;i--) { if(fileName[i] == '/' || fileName[i] == '\\') { pos = i+1; break; } } strcpy(tempFileName, &fileName[pos]); sprintf(filePath, "%s\\%s.ooc", outputPath, tempFileName); printf("filePath = %s\n", filePath); unsigned int flag = REMOVE_INDEX | GPU; if(argc >= 3) { flag = atoi(argv[2]); if(flag == 0) { if(strstr(argv[2], "REMOVE_INDEX")) flag |= REMOVE_INDEX; if(strstr(argv[2], "HCCMESH")) flag |= HCCMESH; if(strstr(argv[2], "MTL")) flag |= MTL; if(strstr(argv[2], "ASVO")) flag |= ASVO; if(strstr(argv[2], "GPU")) flag |= GPU; } printf("Process "); if((flag & REMOVE_INDEX) == REMOVE_INDEX) printf("Removing indices, "); if((flag & HCCMESH) == HCCMESH) printf("HCCMesh generation, "); if((flag & MTL) == MTL) printf("MTL generation, "); if((flag & ASVO) == ASVO) printf("ASVO generation, "); if((flag & GPU) == GPU) printf("GPU conversion, "); printf("\n"); } if((flag & REMOVE_INDEX) == REMOVE_INDEX) { cout << "Remove unnecessary indirected triangle indices." << endl; DirectTriIndex *dti = new DirectTriIndex(); dti->Do(filePath); //dti->DoMulti(filePath); delete dti; } /* cout << "Make HCCMesh2 representation." << endl; HCCMesh *hm = new HCCMesh(); hm->convertHCCMesh2(fileName); delete hm; */ if((flag & HCCMESH) == HCCMESH) { cout << "Make HCCMesh representation." << endl; HCCMesh *hm = new HCCMesh(); hm->generateTemplates(); hm->convertHCCMesh(filePath); delete hm; } if((flag & MTL) == MTL) { cout << "Generate MTL file." << endl; MTLGenerator *mtl = new MTLGenerator(); mtl->Do(filePath); delete mtl; } if((flag & ASVO) == ASVO) { cout << "Generating ASVO..." << endl; Voxelize *voxelize = new Voxelize(); if(argc >= 5) { if(argc >= 6) voxelize->Do(filePath, atoi(argv[3]), atoi(argv[4]), atoi(argv[5])); else voxelize->Do(filePath, atoi(argv[3]), atoi(argv[4])); } else voxelize->Do(filePath); delete voxelize; } if((flag & GPU) == GPU) { cout << "Convert triangle and vertex files into files that suitable for GPU." << endl; GeometryConverter *gc = new GeometryConverter(); //gc->convertCluster(filePath); gc->convert(filePath); //gc->convert(filePath, GeometryConverter::NEW_OOC, GeometryConverter::SIMP); delete gc; } /* cout << "Rearrange voxels into sequential order." << endl; RearrangeVoxels *rav = new RearrangeVoxels(); rav->Do(filePath); delete rav; cout << "Extract bounding box of each voxel." << endl; ExtractBB *ebb = new ExtractBB(); ebb->Do(filePath); delete ebb; cout << "Merge geometry data into single voxel." << endl; MergeGeometry *mg = new MergeGeometry(); mg->Do(filePath); delete mg; */ return 0; }
23.055556
98
0.642035
sglab
01a8355b87c487d6dbfd441788d509b7c248f69d
953
cpp
C++
Source/Core/Utility/Value.cpp
CCSEPBVR/KVS
f6153b3f52aa38904cc96d38d5cd609c5dccfc59
[ "BSD-3-Clause" ]
null
null
null
Source/Core/Utility/Value.cpp
CCSEPBVR/KVS
f6153b3f52aa38904cc96d38d5cd609c5dccfc59
[ "BSD-3-Clause" ]
null
null
null
Source/Core/Utility/Value.cpp
CCSEPBVR/KVS
f6153b3f52aa38904cc96d38d5cd609c5dccfc59
[ "BSD-3-Clause" ]
null
null
null
/****************************************************************************/ /** * @file Value.cpp */ /*---------------------------------------------------------------------------- * * Copyright (c) Visualization Laboratory, Kyoto University. * All rights reserved. * See http://www.viz.media.kyoto-u.ac.jp/kvs/copyright/ for details. * * $Id: Value.cpp 631 2010-10-10 02:15:35Z naohisa.sakamoto $ */ /****************************************************************************/ #include "Value.h" #include <kvs/Type> namespace kvs { // Template specialization. template class Value<kvs::Int8>; template class Value<kvs::UInt8>; template class Value<kvs::Int16>; template class Value<kvs::UInt16>; template class Value<kvs::Int32>; template class Value<kvs::UInt32>; template class Value<kvs::Int64>; template class Value<kvs::UInt64>; template class Value<kvs::Real32>; template class Value<kvs::Real64>; } // end of namespace kvs
28.029412
78
0.537251
CCSEPBVR
01add52005565d3321e5156ee799c67cb32aacf7
3,589
cpp
C++
src/plugins/azoth/plugins/abbrev/abbrevsmanager.cpp
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
120
2015-01-22T14:10:39.000Z
2021-11-25T12:57:16.000Z
src/plugins/azoth/plugins/abbrev/abbrevsmanager.cpp
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
8
2015-02-07T19:38:19.000Z
2017-11-30T20:18:28.000Z
src/plugins/azoth/plugins/abbrev/abbrevsmanager.cpp
Maledictus/leechcraft
79ec64824de11780b8e8bdfd5d8a2f3514158b12
[ "BSL-1.0" ]
33
2015-02-07T16:59:55.000Z
2021-10-12T00:36:40.000Z
/********************************************************************** * LeechCraft - modular cross-platform feature rich internet client. * Copyright (C) 2006-2014 Georg Rudoy * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt) **********************************************************************/ #include "abbrevsmanager.h" #include <QSettings> #include <QCoreApplication> #include <interfaces/azoth/iprovidecommands.h> namespace LC::Azoth::Abbrev { AbbrevsManager::AbbrevsManager (QObject *parent) : QObject { parent } { Load (); } void AbbrevsManager::Add (const Abbreviation& abbrev) { if (std::any_of (Abbrevs_.begin (), Abbrevs_.end (), [&abbrev] (const Abbreviation& other) { return other.Pattern_ == abbrev.Pattern_; })) throw CommandException { tr ("Abbreviation with this pattern already exists.") }; if (abbrev.Pattern_.isEmpty ()) throw CommandException { tr ("Abbeviation pattern is empty.") }; if (abbrev.Expansion_.isEmpty ()) throw CommandException { tr ("Abbeviation expansion is empty.") }; const auto pos = std::lower_bound (Abbrevs_.begin (), Abbrevs_.end (), abbrev, [] (const Abbreviation& left, const Abbreviation& right) { return left.Pattern_.size () > right.Pattern_.size (); }); Abbrevs_.insert (pos, abbrev); Save (); } const QList<Abbreviation>& AbbrevsManager::List () const { return Abbrevs_; } void AbbrevsManager::Remove (int index) { if (index < 0 || index >= Abbrevs_.size ()) return; Abbrevs_.removeAt (index); Save (); } namespace { bool IsBadChar (QChar c) { return c.isLetter (); } bool TryExpand (QString& result, const Abbreviation& abbrev) { if (!result.contains (abbrev.Pattern_)) return false; bool changed = false; auto pos = 0; while ((pos = result.indexOf (abbrev.Pattern_, pos)) != -1) { const auto afterAbbrevPos = pos + abbrev.Pattern_.size (); if ((!pos || !IsBadChar (result.at (pos - 1))) && (afterAbbrevPos >= result.size () || !IsBadChar (result.at (afterAbbrevPos)))) { result.replace (pos, abbrev.Pattern_.size (), abbrev.Expansion_); pos += abbrev.Expansion_.size (); changed = true; } else pos += abbrev.Pattern_.size (); } return changed; } } QString AbbrevsManager::Process (QString text) const { int cyclesCount = 0; while (true) { bool changed = false; for (const auto& abbrev : Abbrevs_) if (TryExpand (text, abbrev)) changed = true; if (!changed) break; const auto expansionsLimit = 1024; if (++cyclesCount >= expansionsLimit) throw CommandException { tr ("Too many expansions during abbreviations application. Check your rules.") }; } return text; } namespace Keys { const QString Group = QStringLiteral ("Abbrevs"); const QString Abbreviations = QStringLiteral ("Abbreviations"); } void AbbrevsManager::Load () { QSettings settings { QCoreApplication::organizationName (), QCoreApplication::applicationName () + "_Azoth_Abbrev" }; settings.beginGroup (Keys::Group); Abbrevs_ = settings.value (Keys::Abbreviations).value<decltype (Abbrevs_)> (); settings.endGroup (); } void AbbrevsManager::Save () const { QSettings settings { QCoreApplication::organizationName (), QCoreApplication::applicationName () + "_Azoth_Abbrev" }; settings.beginGroup (Keys::Group); settings.setValue (Keys::Abbreviations, QVariant::fromValue (Abbrevs_)); settings.endGroup (); } }
26.585185
110
0.648091
Maledictus
01b8800d83d55d8f7d6be054567dcc49d26ced73
390
cpp
C++
labs/5/Practice_12/solutions/task4.cpp
triffon/oop-2019-20
db199631d59ddefdcc0c8eb3d689de0095618f92
[ "MIT" ]
19
2020-02-21T16:46:50.000Z
2022-01-26T19:59:49.000Z
labs/5/Practice_12/solutions/task4.cpp
triffon/oop-2019-20
db199631d59ddefdcc0c8eb3d689de0095618f92
[ "MIT" ]
1
2020-03-14T08:09:45.000Z
2020-03-14T08:09:45.000Z
labs/5/Practice_12/solutions/task4.cpp
triffon/oop-2019-20
db199631d59ddefdcc0c8eb3d689de0095618f92
[ "MIT" ]
11
2020-02-23T12:29:58.000Z
2021-04-11T08:30:12.000Z
#include <iostream> using namespace std; int main() { string text; cin >> text; for(int i=0; i<text.length(); i++) { if (text[i] == text[i+1]) { int k = 0; while(text[i] == text[i + k + 1]) { k++; } text.erase(i, k); } } cout << text << endl; return 0; }
15.6
48
0.364103
triffon
01b92bfb14a277e032868d3db5e9840f2caaf5f3
1,487
cpp
C++
src/Scenes/save.cpp
SPC-Some-Polish-Coders/PopHead
2bce21b1a6b3d16a2ccecf0d15faeebf6a486c81
[ "MIT" ]
117
2019-03-18T20:09:54.000Z
2022-03-27T22:40:52.000Z
src/Scenes/save.cpp
SPC-Some-Polish-Coders/PopHead
2bce21b1a6b3d16a2ccecf0d15faeebf6a486c81
[ "MIT" ]
443
2019-04-07T19:59:56.000Z
2020-05-23T12:25:28.000Z
src/Scenes/save.cpp
SPC-Some-Polish-Coders/PopHead
2bce21b1a6b3d16a2ccecf0d15faeebf6a486c81
[ "MIT" ]
19
2019-03-20T19:57:34.000Z
2020-11-21T15:35:02.000Z
#include "pch.hpp" #include "save.hpp" #include "ECS/entityUtil.hpp" #include "ECS/Components/charactersComponents.hpp" #include "ECS/Components/physicsComponents.hpp" #include "ECS/Components/objectsComponents.hpp" #include "ECS/Components/graphicsComponents.hpp" namespace ph { struct GameSaveBlob { Vec2 savePointPos; Vec2 playerPos; int playerHealth; u8 playerZ; }; using namespace component; void saveGame(entt::registry* registry, Vec2 savePointPos) { // TODO: Handle file opening fail GameSaveBlob blob; blob.savePointPos = savePointPos; registry->view<Player, BodyRect, RenderQuad, Health>().each([&] (auto, auto body, const auto& renderQuad, auto health) { blob.playerPos = body.pos; blob.playerHealth = health.healthPoints; blob.playerZ = renderQuad.z; }); FILE* file = fopen("save", "wb"); fwrite(&blob, sizeof(GameSaveBlob), 1, file); fclose(file); } void loadGameSave(entt::registry* registry) { // TODO: Handle file opening fail GameSaveBlob blob; FILE* file = fopen("save", "rb"); fread(&blob, sizeof(GameSaveBlob), 1, file); fclose(file); registry->view<Player, BodyRect, RenderQuad, Health>().each([&] (auto, auto& body, auto& renderQuad, auto& health) { body.pos = blob.playerPos; health.healthPoints = blob.playerHealth; renderQuad.z = blob.playerZ; }); registry->view<SavePoint, BodyRect>().each([&] (auto& savePoint, auto body) { if(body.pos == blob.savePointPos) savePoint.isIntersectingPlayer = true; }); } }
22.530303
64
0.718897
SPC-Some-Polish-Coders
01bc1fce2e1986d4474d872f47806d6812fd6924
155
cpp
C++
src/state/LC.cpp
UmbrellaSampler/carnd-term3-1_path_planning
5d3828753b0ecde20aa4a7ba7d0ef16e21acdea7
[ "MIT" ]
null
null
null
src/state/LC.cpp
UmbrellaSampler/carnd-term3-1_path_planning
5d3828753b0ecde20aa4a7ba7d0ef16e21acdea7
[ "MIT" ]
null
null
null
src/state/LC.cpp
UmbrellaSampler/carnd-term3-1_path_planning
5d3828753b0ecde20aa4a7ba7d0ef16e21acdea7
[ "MIT" ]
null
null
null
// // Created by uwe_e on 03.02.2020. // #include "LC.h" double LC::Cost() const { // Lane change gets always executed return -1; }
11.923077
40
0.554839
UmbrellaSampler
01bd85278a2cee18317d3094364b016789eb2e17
752
hpp
C++
include/sprout/range/algorithm/replace_copy.hpp
thinkoid/Sprout
a5a5944bb1779d3bb685087c58c20a4e18df2f39
[ "BSL-1.0" ]
4
2021-12-29T22:17:40.000Z
2022-03-23T11:53:44.000Z
dsp/lib/sprout/sprout/range/algorithm/replace_copy.hpp
TheSlowGrowth/TapeLooper
ee8d8dccc27e39a6f6f6f435847e4d5e1b97c264
[ "MIT" ]
16
2021-10-31T21:41:09.000Z
2022-01-22T10:51:34.000Z
include/sprout/range/algorithm/replace_copy.hpp
thinkoid/Sprout
a5a5944bb1779d3bb685087c58c20a4e18df2f39
[ "BSL-1.0" ]
null
null
null
/*============================================================================= Copyright (c) 2011-2019 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_RANGE_ALGORITHM_REPLACE_COPY_HPP #define SPROUT_RANGE_ALGORITHM_REPLACE_COPY_HPP #include <sprout/config.hpp> #include <sprout/range/algorithm/fixed/replace_copy.hpp> #include <sprout/range/algorithm/fit/replace_copy.hpp> #include <sprout/range/algorithm/cxx14/replace_copy.hpp> #endif // #ifndef SPROUT_RANGE_ALGORITHM_REPLACE_COPY_HPP
44.235294
79
0.644947
thinkoid
01c5c4fd251b6084e184943fd6b499de1d275b54
103
cpp
C++
3/TCPClient/main.cpp
ulyanyunakh/operating-systems
edb195c5ff72138f9d3f7b940d7acce507cb69d3
[ "MIT" ]
null
null
null
3/TCPClient/main.cpp
ulyanyunakh/operating-systems
edb195c5ff72138f9d3f7b940d7acce507cb69d3
[ "MIT" ]
null
null
null
3/TCPClient/main.cpp
ulyanyunakh/operating-systems
edb195c5ff72138f9d3f7b940d7acce507cb69d3
[ "MIT" ]
null
null
null
#include <iostream> #include "TCPClient.cpp" int main() { TCPClient client; client.start(); }
14.714286
24
0.650485
ulyanyunakh
01cf388e8b6a6a56f14aa9701057e419e02c0c58
5,880
cpp
C++
sources/core/system.cpp
alexandrerodrigopinheiro/libyetzirah
5fdf6dfd4e903cc10addbed67f2e66a4cdbae617
[ "Apache-2.0" ]
null
null
null
sources/core/system.cpp
alexandrerodrigopinheiro/libyetzirah
5fdf6dfd4e903cc10addbed67f2e66a4cdbae617
[ "Apache-2.0" ]
null
null
null
sources/core/system.cpp
alexandrerodrigopinheiro/libyetzirah
5fdf6dfd4e903cc10addbed67f2e66a4cdbae617
[ "Apache-2.0" ]
null
null
null
#include "core/system.h" ygl::core::system::system() : _hud(false), _window(nullptr), _double_window(nullptr), _render(nullptr), _camera(nullptr), _double_scene(nullptr), _event(nullptr), _handler(nullptr), _hertz(nullptr), _info(nullptr) { } ygl::core::system::~system() { this->destroy(); } bool ygl::core::system::initialize(const std::string& caption, const ygl::math::pointd& position, const ygl::math::sized& size, std::size_t fps, bool fullscreen, bool hud) { SDL_Init(SDL_INIT_EVERYTHING); TTF_Init(); if (!SDL_WasInit(SDL_INIT_VIDEO)) { throw ygl::error::exception("Could not initialize system system, failed"); return false; } if (!TTF_WasInit()) { throw ygl::error::exception("Could not initialize system system, failed"); return false; } this->_window = new ygl::device::window(); if (!this->_window->initialize(caption, position, size, fullscreen, hud)) { throw ygl::error::exception("Could not initialize window, failed"); return false; } this->_camera = new ygl::core::camera(); if (!this->_camera->initialize("main", position, size)) { throw ygl::error::exception("Could not initialize camera, failed"); return false; } this->_render = new ygl::core::render(); if (!this->_render->initialize()) { throw ygl::error::exception("Could not initialize render, failed"); return false; } #if 0 const int AUDIO_FREQUENCY = 22050; const int AUDIO_CHANNELS = 2; const int AUDIO_CHUNK_SIZE = 4096; #endif const int AUDIO_FREQUENCY = 44100; const int AUDIO_CHANNELS = 2; const int AUDIO_CHUNK_SIZE = 2048; Mix_OpenAudio(AUDIO_FREQUENCY, MIX_DEFAULT_FORMAT, AUDIO_CHANNELS, AUDIO_CHUNK_SIZE); this->_event = new ygl::device::event(); if (!this->_event->initialize()) { throw ygl::error::exception("Could not initialize event, failed"); return false; } this->_hud = hud; this->_handler = new ygl::core::handler(); this->_hertz = new ygl::clock::hertz(); this->_hertz->initialize(fps); this->_hertz->fps(); this->_info = new ygl::gui::hud("assets/extra/system.ttf", 10, ygl::math::sized(65, 15, 0)); this->_info->position(10.0, 10.0, 0.0); this->_info->access_data()->align(ygl::graphic::align::ALIGN_LEFT); this->_info->access_data()->position_x(this->_info->access_data()->position().x() + 3); return true; } bool ygl::core::system::double_window(const std::string& caption, const ygl::math::pointd& position, const ygl::math::sized& size, bool fullscreen) { if (!SDL_WasInit(SDL_INIT_VIDEO)) { throw ygl::error::exception("Could not initialize core system, failed"); return false; } if (!TTF_WasInit()) { throw ygl::error::exception("Could not initialize core system, failed"); return false; } SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); this->_double_window = new ygl::device::window(); if (!this->_double_window->initialize(caption, position, size, fullscreen)) { throw ygl::error::exception("Could not initialize Double Screen, failed"); return false; } return true; } void ygl::core::system::destroy() { if (SDL_WasInit(SDL_INIT_EVERYTHING)) { delete this->_window; delete this->_double_window; delete this->_double_scene; delete this->_render; delete this->_camera; delete this->_event; delete this->_handler; delete this->_hertz; delete this->_info; this->_window = nullptr; this->_double_window = nullptr; this->_render = nullptr; this->_camera = nullptr; this->_double_scene = nullptr; this->_event = nullptr; this->_handler = nullptr; this->_hertz = nullptr; this->_info = nullptr; SDL_Quit(); TTF_Quit(); Mix_CloseAudio(); } } bool ygl::core::system::scene(const std::string& name, ygl::scene::scene* scene) { this->_handler->attach(name, scene); return true; } bool ygl::core::system::double_scene(ygl::scene::scene* scene) { this->_double_scene = scene; return true; } void ygl::core::system::running() { this->_handler->loading(); this->_camera->renderize(); this->_render->renderize(); while(this->_event->opened()) { this->defines(); this->_event->listener(); if (this->_double_window != nullptr) { this->_double_scene->keyboard(this->_event->keyoard()); this->_double_scene->mouse(this->_event->mouse()); this->_double_scene->touch(this->_event->touch()); this->_double_scene->update(); this->_camera->renderize(); this->_render->renderize(); this->_double_window->renderize(); this->_double_scene->render(); this->_render->refresh(); this->_double_window->refresh(); this->_double_scene->clear(); } this->_handler->keyboard(this->_event->keyoard()); this->_handler->mouse(this->_event->mouse()); this->_handler->touch(this->_event->touch()); this->_handler->update(); this->_camera->renderize(); this->_render->renderize(); this->_window->renderize(); this->_handler->render(); this->_event->render(); this->hud(); this->_render->refresh(); this->_window->refresh(); this->synchronize(); this->_handler->clear(); this->_event->clear(); if (this->_handler->scene() == false) { break; } } this->destroy(); } void ygl::core::system::defines() { switch (this->_event->keyoard().button()) { case ygl::device::button::BUTTON_DEBUG_FULLSCREEN: { this->_window->fullscreen((this->_window->fullscreen() ? false : true)); break; } case ygl::device::button::BUTTON_DEBUG_INFO: { this->_hud = this->_hud ? false : true; this->_event->verbose(this->_hud); break; } case ygl::device::button::BUTTON_DEBUG_RULER: { this->_window->hud((this->_window->hud() ? false : true)); break; } default: break; } } void ygl::core::system::synchronize() { this->_hertz->synchronize(); } void ygl::core::system::hud() { if (this->_hud) { this->_info->draw("FPS: " + ygl::basic::to_string(this->_hertz->frequency())); } }
21.459854
171
0.67466
alexandrerodrigopinheiro
01d2df441a67e7f683484b52ed949de4472b8502
7,567
cpp
C++
src/Tokenstream.cpp
UtopiaLang/src
be8904f978f3ea0d92afb72895cc2bb052cf4107
[ "Unlicense" ]
7
2021-03-01T17:24:45.000Z
2021-10-01T02:28:25.000Z
src/Tokenstream.cpp
UtopiaLang/Utopia
be8904f978f3ea0d92afb72895cc2bb052cf4107
[ "Unlicense" ]
6
2021-02-27T18:25:45.000Z
2021-09-10T21:27:39.000Z
src/Tokenstream.cpp
UtopiaLang/src
be8904f978f3ea0d92afb72895cc2bb052cf4107
[ "Unlicense" ]
null
null
null
#include "Tokenstream.hpp" #include <optional> #include "is_whitespace.hpp" #include "Profiling.hpp" #include "ParseError.hpp" #include "TokenAssignment.hpp" #include "TokenBlock.hpp" #include "TokenBool.hpp" #include "TokenConcat.hpp" #include "TokenDivide.hpp" #include "TokenEquals.hpp" #include "TokenFunction.hpp" #include "TokenInt.hpp" #include "TokenLiteral.hpp" #include "TokenMinus.hpp" #include "TokenMultiply.hpp" #include "TokenPlus.hpp" #include "TokenString.hpp" #include "TokenUnequal.hpp" namespace Utopia { struct LiteralBuffer { SourceLocation loc; std::string data; LiteralBuffer(const SourceLocation& loc, char c) : loc(loc), data(1, c) { } }; struct InternalExceptionEndParsing { }; static void finishLiteralToken(std::vector<std::unique_ptr<Token>>& tokens, std::optional<LiteralBuffer>& literal_buffer) { if (!literal_buffer.has_value()) { return; } if (literal_buffer.value().data == "=") { tokens.emplace_back(std::make_unique<TokenAssignment>(literal_buffer.value().loc)); } else if (literal_buffer.value().data == "true") { tokens.emplace_back(std::make_unique<TokenBool>(literal_buffer.value().loc, true)); } else if (literal_buffer.value().data == "false") { tokens.emplace_back(std::make_unique<TokenBool>(literal_buffer.value().loc, false)); } else if (literal_buffer.value().data == "_end_parsing") { throw InternalExceptionEndParsing(); } else { try { long long value = std::stoll(literal_buffer.value().data); tokens.emplace_back(std::make_unique<TokenInt>(literal_buffer.value().loc, value)); } catch (const std::invalid_argument&) { tokens.emplace_back(std::make_unique<TokenLiteral>(literal_buffer.value().loc, std::move(literal_buffer.value().data))); } } literal_buffer.reset(); } void Tokenstream::populate(SourceLocation loc, const std::string& code) { Profiling::startSection("Tokenization"); { std::optional<LiteralBuffer> literal_buffer = std::nullopt; try { auto i = code.begin(); while (i != code.end()) { char c = *i++; switch (c) { case '=': if (literal_buffer.has_value()) { if (literal_buffer.value().data == "=") { literal_buffer.reset(); tokens.emplace_back(std::make_unique<TokenEquals>(loc)); loc.character++; break; } if (literal_buffer.value().data == "!") { literal_buffer.reset(); tokens.emplace_back(std::make_unique<TokenUnequal>(loc)); loc.character++; break; } } [[fallthrough]]; default: if (literal_buffer.has_value()) { literal_buffer.value().data.append(1, c); } else { literal_buffer.emplace(loc, c); } [[fallthrough]]; case '\r': loc.character++; break; case '\n': finishLiteralToken(tokens, literal_buffer); loc.newline(); break; case ' ': case '\t': case ';': case '.': finishLiteralToken(tokens, literal_buffer); loc.character++; break; case '"': finishLiteralToken(tokens, literal_buffer); { auto str = std::make_unique<TokenString>(loc); while (i != code.end()) { loc.character++; c = *i++; if (c == '\n') { loc.throwHere<ParseError>("Unexpected new line while reading double-quoted string"); } if (c == '"') { break; } str->value.append(1, c); } tokens.emplace_back(std::move(str)); } loc.character++; break; case '+': finishLiteralToken(tokens, literal_buffer); tokens.emplace_back(std::make_unique<TokenPlus>(loc)); loc.character++; break; case '-': finishLiteralToken(tokens, literal_buffer); tokens.emplace_back(std::make_unique<TokenMinus>(loc)); loc.character++; break; case '*': finishLiteralToken(tokens, literal_buffer); tokens.emplace_back(std::make_unique<TokenMultiply>(loc)); loc.character++; break; case '/': switch (i == code.end() ? 0 : *i) { case '/': i++; while (i != code.end() && *i++ != '\n'); loc.newline(); break; case '*': i++; loc.character += 2; { bool star = true; while (i != code.end()) { loc.character++; c = *i++; if (c == '*') { star = true; continue; } if (star && c == '/') { break; } star = false; if (c == '\n') { loc.newline(); continue; } } } break; default: finishLiteralToken(tokens, literal_buffer); tokens.emplace_back(std::make_unique<TokenDivide>(loc)); loc.character++; } break; case '#': while (i != code.end() && *i++ != '\n'); loc.newline(); break; case '|': finishLiteralToken(tokens, literal_buffer); if (tokens.empty()) { _unexpected_pipe: loc.throwHere<ParseError>("Unexpected |"); } { auto prev_token_i = tokens.end() - 1; Token* const prev_token = prev_token_i->get(); if (prev_token->type != TOKEN_LITERAL) { goto _unexpected_pipe; } const char* line_ending = nullptr; if (((TokenLiteral*)prev_token)->literal == "CRLF") { line_ending = "\r\n"; } else if (((TokenLiteral*)prev_token)->literal == "LF") { line_ending = "\n"; } else if (((TokenLiteral*)prev_token)->literal == "CR") { line_ending = "\r"; } if (line_ending == nullptr) { goto _unexpected_pipe; } auto str = std::make_unique<TokenString>(loc); while (i != code.end()) { loc.character++; c = *i++; if (c == '\r') { continue; } if (c == '\n') { loc.newline(); auto j = i; while (j != code.end()) { loc.character++; c = *j++; if (c == '|') { i = j; str->value.append(line_ending); break; } if (!is_whitespace(c)) { loc.character = 1; goto _pipe_string_ends; } } continue; } str->value.append(1, c); } _pipe_string_ends: *prev_token_i = std::move(str); } break; case '{': { SourceLocation start_loc(loc); auto block = std::make_unique<TokenBlock>(loc); int depth = 1; while (i != code.end()) { loc.character++; c = *i++; if (c == '}') { if (--depth == 0) { goto _finish_block; } } else if (c == '{') { depth++; } else if (c == '\n') { loc.newline(); } block->contents.append(1, c); } start_loc.throwHere<ParseError>("Found end of file before closing } for the block"); _finish_block: tokens.emplace_back(std::move(block)); } break; } } finishLiteralToken(tokens, literal_buffer); } catch (const InternalExceptionEndParsing&) { } } Profiling::endSection("Tokenization"); } }
22.454006
124
0.525572
UtopiaLang
01d3206744019dbb5d121703f75aecc78a60d57e
10,778
cpp
C++
src/cbag/schematic/cellview_info.cpp
growly/cbag
468bf580223490a8ce0769471e25abf936b56a4e
[ "Apache-2.0", "BSD-3-Clause" ]
7
2020-02-13T21:51:04.000Z
2021-12-11T10:01:45.000Z
src/cbag/schematic/cellview_info.cpp
growly/cbag
468bf580223490a8ce0769471e25abf936b56a4e
[ "Apache-2.0", "BSD-3-Clause" ]
2
2019-06-03T19:05:14.000Z
2020-03-17T22:59:36.000Z
src/cbag/schematic/cellview_info.cpp
growly/cbag
468bf580223490a8ce0769471e25abf936b56a4e
[ "Apache-2.0", "BSD-3-Clause" ]
5
2019-06-03T17:02:46.000Z
2020-09-01T23:03:01.000Z
// SPDX-License-Identifier: BSD-3-Clause AND Apache-2.0 /* Copyright (c) 2018, Regents of the University of California All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright 2019 Blue Cheetah Analog Design Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <fmt/core.h> #include <cbag/logging/logging.h> #include <cbag/schematic/cellview.h> #include <cbag/schematic/cellview_info.h> #include <cbag/spirit/ast.h> #include <cbag/util/io.h> #include <cbag/util/name_convert.h> #include <cbag/util/overload.h> #include <cbag/yaml/cellviews.h> namespace cbag { namespace sch { cellview_info::cellview_info() = default; cellview_info::cellview_info(const std::string &file_name) { auto node = YAML::LoadFile(file_name); YAML::convert<cellview_info>::decode(node, *this); } cellview_info::cellview_info(std::string lib_name, std::string cell_name, bool is_prim) : lib_name(std::move(lib_name)), cell_name(std::move(cell_name)), is_prim(is_prim) {} void cellview_info::to_file(const std::string &file_name) const { auto node = YAML::convert<cellview_info>::encode(*this); auto out = YAML::Emitter(); out << node; auto stream = util::open_file_write(file_name); stream << out.c_str() << '\n'; stream.close(); } const cellview_info &get_cv_info(const netlist_map_t &info_map, const std::string &lib_name, const std::string &cell_name) { auto libmap_iter = info_map.find(lib_name); if (libmap_iter == info_map.end()) { auto logger = cbag::get_cbag_logger(); auto msg = fmt::format("Cannot find library {} in netlist map for cell {}.", lib_name, cell_name); logger->error(msg); throw std::invalid_argument(msg); } auto cellmap_iter = libmap_iter->second.find(cell_name); if (cellmap_iter == libmap_iter->second.end()) { auto logger = cbag::get_cbag_logger(); auto msg = fmt::format("Cannot find cell {}__{} in netlist map.", lib_name, cell_name); logger->error(msg); throw std::invalid_argument(msg); } return cellmap_iter->second; } void record_cv_info(netlist_map_t &info_map, std::string &&cell_name, cellview_info &&info) { auto lib_map_iter = info_map.find(info.lib_name); if (lib_map_iter == info_map.end()) { sch::lib_map_t new_lib_map; auto lib_name_copy = info.lib_name; new_lib_map.emplace(std::move(cell_name), std::move(info)); info_map.emplace(lib_name_copy, std::move(new_lib_map)); } else { lib_map_iter->second.insert_or_assign(std::move(cell_name), std::move(info)); } } using nu_range_map_t = cbag::util::sorted_map<std::string, std::array<cnt_t, 2>>; const attr_map_t *get_attrs(const util::sorted_map<std::string, attr_map_t> &table, const std::string &base_name) { auto iter = table.find(base_name); if (iter == table.end()) return nullptr; return &iter->second; } void register_unique_name_units(const spirit::ast::name_unit &ast, const attr_map_t *attr_ptr, nu_range_map_t &net_range_map, const nu_range_map_t &term_range_map, util::sorted_map<std::string, attr_map_t> &attr_map) { // check that we do not have a conflict in net attribute if (attr_ptr) { auto attr_ptr_ref = get_attrs(attr_map, ast.base); if (attr_ptr_ref) { if (*attr_ptr_ref != *attr_ptr) { auto msg = fmt::format("Terminal/net {} has conflicting attribute.", ast.base); auto logger = cbag::get_cbag_logger(); logger->error(msg); throw std::runtime_error(msg); } } else { // update attribute table attr_map.emplace(ast.base, *attr_ptr); } } auto net_bounds = ast.idx_range.bounds(); auto term_iter = term_range_map.find(ast.base); if (term_iter != term_range_map.end()) { // this net is connected to a terminal // check that net range does not go out of bounds of terminal range auto & [ term_start, term_stop ] = term_iter->second; auto term_scalar = (term_start == term_stop); auto net_scalar = (net_bounds[0] == net_bounds[1]); if ((term_scalar != net_scalar) || (!term_scalar && (net_bounds[0] < term_start || net_bounds[1] > term_stop))) { auto logger = cbag::get_cbag_logger(); auto msg = fmt::format("Schematic cannot contain net {} because a terminal with the same base " "name and difference bounds exist.", ast.to_string(spirit::namespace_cdba{})); logger->error(msg); throw std::runtime_error(msg); } } else { // register net auto net_iter = net_range_map.find(ast.base); if (net_iter == net_range_map.end()) { net_range_map.emplace(ast.base, net_bounds); } else { auto &cur_bnds = net_iter->second; cur_bnds[0] = std::min(cur_bnds[0], net_bounds[0]); cur_bnds[1] = std::max(cur_bnds[1], net_bounds[1]); } } } void register_unique_name_units(const spirit::ast::name &ast, const attr_map_t *attr_ptr, nu_range_map_t &net_range_map, const nu_range_map_t &term_range_map, util::sorted_map<std::string, attr_map_t> &attr_map); void register_unique_name_units(const spirit::ast::name_rep &ast, const attr_map_t *attr_ptr, nu_range_map_t &net_range_map, const nu_range_map_t &term_range_map, util::sorted_map<std::string, attr_map_t> &attr_map) { std::visit( overload{ [&attr_ptr, &net_range_map, &term_range_map, &attr_map](const spirit::ast::name_unit &arg) { register_unique_name_units(arg, attr_ptr, net_range_map, term_range_map, attr_map); }, [&attr_ptr, &net_range_map, &term_range_map, &attr_map](const spirit::ast::name &arg) { register_unique_name_units(arg, attr_ptr, net_range_map, term_range_map, attr_map); }, }, ast.data); } void register_unique_name_units(const spirit::ast::name &ast, const attr_map_t *attr_ptr, nu_range_map_t &net_range_map, const nu_range_map_t &term_range_map, util::sorted_map<std::string, attr_map_t> &attr_map) { for (const auto &nr : ast.rep_list) { register_unique_name_units(nr, attr_ptr, net_range_map, term_range_map, attr_map); } } cellview_info get_cv_netlist_info(const cellview &cv, const std::string &cell_name, const netlist_map_t &info_map, bool compute_net_attrs) { cellview_info ans(cv.lib_name, cell_name, false); ans.cv_ptr = &cv; nu_range_map_t term_range_map, net_range_map; // process terminals for (auto const & [ term_name, term_fig ] : cv.terminals) { switch (term_fig.ttype) { case term_type::input: ans.in_terms.push_back(term_name); break; case term_type::output: ans.out_terms.push_back(term_name); break; default: // this cellview is validated, term_type guaranteed to be supported ans.io_terms.push_back(term_name); break; } // record terminal bus range auto ast = util::parse_cdba_name_unit(term_name); term_range_map.emplace(ast.base, ast.idx_range.bounds()); // record terminal attribute if (!term_fig.attrs.empty()) ans.term_net_attrs.emplace(ast.base, term_fig.attrs); } // get all the nets for (auto const & [ inst_name, inst_ptr ] : cv.instances) { auto inst_cv_info_ptr = (compute_net_attrs) ? &get_cv_info(info_map, inst_ptr->lib_name, inst_ptr->cell_name) : nullptr; for (auto const & [ inst_term, net ] : inst_ptr->connections) { auto term_ast = util::parse_cdba_name_unit(inst_term); auto net_ast = util::parse_cdba_name(net); auto attr_ptr = (inst_cv_info_ptr) ? get_attrs(inst_cv_info_ptr->term_net_attrs, term_ast.base) : nullptr; register_unique_name_units(net_ast, attr_ptr, net_range_map, term_range_map, ans.term_net_attrs); } } // save all nets to netlist for (auto const & [ net_name, net_bnds ] : net_range_map) { ans.nets.push_back(spirit::ast::to_string(net_name, net_bnds, spirit::namespace_cdba{})); } return ans; } } // namespace sch } // namespace cbag
41.6139
100
0.650677
growly
01d3dea0466abde0d50963a8ab1120522bb71411
14,396
cpp
C++
Game/Source/Enemy.cpp
Ar-Ess/Split_Duty_NoNameBros
7c723fa2f4a1d08954b11e3d81c767e226f3f186
[ "MIT" ]
null
null
null
Game/Source/Enemy.cpp
Ar-Ess/Split_Duty_NoNameBros
7c723fa2f4a1d08954b11e3d81c767e226f3f186
[ "MIT" ]
1
2021-02-25T11:10:21.000Z
2021-02-25T11:10:21.000Z
Game/Source/Enemy.cpp
Ar-Ess/Split_Duty_NoNameBros
7c723fa2f4a1d08954b11e3d81c767e226f3f186
[ "MIT" ]
null
null
null
#define _CRT_SECURE_NO_WARNINGS #include "App.h" #include "Scene.h" #include "Combat.h" #include "Enemy.h" #include "Pathfinding.h" #include "Log.h" #define DEFAULT_PATH_LENGTH 50 Enemy::Enemy() : Entity(EntityType::ENEMY) { //PathFinding::GetInstance()->CreatePath(*path, iPoint(0, 0), iPoint(0, 0)); } Enemy::Enemy (EnemyClass enClass) : Entity(EntityType::ENEMY) { //PathFinding::GetInstance()->CreatePath(*path, iPoint(0, 0), iPoint(0, 0)); lvlText = (GuiString*)app->guiManager->CreateGuiControl(GuiControlType::TEXT); lvlText->bounds = { 0, 0, 40, 50 }; lvlText->SetTextFont(app->fontTTF->defaultFont3); //Load enemies textures //wolf enemyClass = enClass; awakeAnim.loop = true; awakeAnim.speed = 0.1f; idleAnim.loop = true; idleAnim.speed = 0.06f; moveAnim.loop = true; moveAnim.speed = 0.1f; switch (enClass) { case(EnemyClass::SMALL_WOLF): idleAnim.PushBack({ 197, 0, 63, 34}); idleAnim.PushBack({ 262, 0, 63, 34 }); idleAnim.speed = 0.06f; awakeAnim.PushBack({ 68,0,63,34 }); awakeAnim.PushBack({ 133 ,0,63,34 }); awakeAnim.PushBack({ 197 ,0,63,34 }); awakeAnim.PushBack({ 262,0,63,34 }); moveAnim.PushBack({ 0,132,67,34 }); moveAnim.PushBack({ 65,132,67,34 }); moveAnim.PushBack({ 65*2,132,67,34 }); moveAnim.PushBack({ 65*3,132,67,34 }); moveAnim.PushBack({ 65*4,132,67,34 }); moveAnim.speed = 0.14f; break; case(EnemyClass::BIRD): idleAnim.PushBack({ 32,0,32,32 }); idleAnim.PushBack({ 32 * 2,0,32,32 }); idleAnim.PushBack({ 32 * 3,0,32,32 }); moveAnim.PushBack({ 32,32*3,32,32 }); moveAnim.PushBack({ 32 * 2,32*3,32,32 }); moveAnim.PushBack({ 32 * 3,32*3,32,32 }); moveAnim.speed = idleAnim.speed * 2; break; case(EnemyClass::MANTIS): idleAnim.PushBack({ 0,0,28,31 }); idleAnim.PushBack({ 28,0,35,31 }); idleAnim.PushBack({ 63,0,37,31 }); idleAnim.speed = 0.045f; idleAnim.pingpong = true; moveAnim.PushBack({ 0,70,34,34 }); moveAnim.PushBack({ 31,70,34,34 }); moveAnim.PushBack({ 31*2,70,34,34 }); for (int i = 0; i < 7; i++) { bulletMantis.PushBack({ 31 * i, 32,32 , 32 }); } break; } } Enemy::~Enemy() { for (int i = 0; i < 5; i++) { if (bullet[i].bulletSpritesheet != nullptr) app->tex->UnLoad(bullet[i].bulletSpritesheet); } lvlText->UnLoadTextTexture(); lvlText->text.Clear(); } void Enemy::SetUp( SDL_Rect combatCollider, SDL_Rect worldCollider, int xlvl, int xexp, int xhealth, int xstrength, int xdefense, int xvelocity) { colliderCombat = combatCollider; colliderWorld = worldCollider; colliderRect = {worldCollider.x, worldCollider.y + worldCollider.h - 28, worldCollider.w, 28}; originalPosition = { colliderRect.x, colliderRect.y }; dangerRadius.SetCircle(colliderWorld.x + (colliderWorld.w / 2), colliderWorld.y + (colliderWorld.h / 2), 300); lvl = xlvl; exp = xexp; health = xhealth; maxHealth = xhealth; strength = xstrength; defense = xdefense; velocity = xvelocity; char str[20] = {}; sprintf(str, "LVL. %d", xlvl); lvlText->SetString(str); } void Enemy::Jump() { if (jumpTime < 28) { colliderCombat.y -= 14; colliderCombat.y += jumpTime; jumpTime++; } else { colliderCombat.y = SMALLWOLF_C_Y; jumpTime = 0; } } void Enemy::HighJump() { if (jumpTime < 34) { colliderCombat.y -= 17; colliderCombat.y += jumpTime; jumpTime++; } else { colliderCombat.y = MANTIS_C_Y; jumpTime = 0; } } void Enemy::SmallWolfAttack(unsigned short int typeOfAttack) { if (typeOfAttack == 1) { colliderCombat.x -= 8; smallWolfTimeAttack1++; if (colliderCombat.x + colliderCombat.w < 0) colliderCombat.x = 1280; } else if (typeOfAttack == 2) { if (smallWolfTimeAttack2 < 29) { Jump(); } else if (smallWolfTimeAttack2 < 50) { int a = 0; } else if (smallWolfTimeAttack2 < 220) { if (app->scene->combatScene->steps == 0) { colliderCombat.x -= 8; if (colliderCombat.x + colliderCombat.w < 0) colliderCombat.x = 1280; if (smallWolfTimeAttack2 > 135 && smallWolfTimeAttack2 < 165) Jump(); } else if (app->scene->combatScene->steps == 1) { colliderCombat.x -= 8; if (colliderCombat.x + colliderCombat.w < 0) colliderCombat.x = 1280; if (smallWolfTimeAttack2 > 113 && smallWolfTimeAttack2 < 143) Jump(); } else if (app->scene->combatScene->steps == 2) { colliderCombat.x -= 8; if (colliderCombat.x + colliderCombat.w < 0) colliderCombat.x = 1280; if (smallWolfTimeAttack2 > 90 && smallWolfTimeAttack2 < 120) Jump(); } else if (app->scene->combatScene->steps == 3) { colliderCombat.x -= 8; if (colliderCombat.x + colliderCombat.w < 0) colliderCombat.x = 1280; if (smallWolfTimeAttack2 > 68 && smallWolfTimeAttack2 < 98) Jump(); } } } } void Enemy::BirdAttack(unsigned short int typeOfAttack) { if (typeOfAttack == 1) { if (app->scene->combatScene->steps == 0) { if (birdTimeAttack1 < 95) { colliderCombat.x -= 8; } else if (birdTimeAttack1 < 120) // \* { colliderCombat.x -= 5; colliderCombat.y -= 5; } else if (birdTimeAttack1 < 155) // /* { colliderCombat.x += 9; colliderCombat.y -= 2; } else if (birdTimeAttack1 < 180) // \_ { colliderCombat.x += 5; colliderCombat.y += 5; if (birdTimeAttack1 == 179) app->scene->combatScene->playerHitAble = true; } else if (birdTimeAttack1 < 215) // _/ { colliderCombat.x -= 9; colliderCombat.y += 4; } else if (birdTimeAttack1 < 248) { colliderCombat.x -= 9; colliderCombat.y -= 4; } else if (birdTimeAttack1 < 280) { colliderCombat.x -= 8; } } if (app->scene->combatScene->steps == 1) { if (birdTimeAttack1 < 75) { colliderCombat.x -= 8; } else if (birdTimeAttack1 < 100) // \* { colliderCombat.x -= 5; colliderCombat.y -= 5; } else if (birdTimeAttack1 < 135) // /* { colliderCombat.x += 9; colliderCombat.y -= 2; } else if (birdTimeAttack1 < 160) // \_ { colliderCombat.x += 5; colliderCombat.y += 5; if (birdTimeAttack1 == 160) app->scene->combatScene->playerHitAble = true; } else if (birdTimeAttack1 < 195) // _/ { colliderCombat.x -= 9; colliderCombat.y += 4; } else if (birdTimeAttack1 < 228) { colliderCombat.x -= 9; colliderCombat.y -= 4; } else if (birdTimeAttack1 < 280) { colliderCombat.x -= 8; } } if (app->scene->combatScene->steps == 2) { if (birdTimeAttack1 < 51) { colliderCombat.x -= 8; } else if (birdTimeAttack1 < 76) // \* { colliderCombat.x -= 5; colliderCombat.y -= 5; } else if (birdTimeAttack1 < 111) // /* { colliderCombat.x += 9; colliderCombat.y -= 2; } else if (birdTimeAttack1 < 136) // \_ { colliderCombat.x += 5; colliderCombat.y += 5; if (birdTimeAttack1 == 135) app->scene->combatScene->playerHitAble = true; } else if (birdTimeAttack1 < 171) // _/ { colliderCombat.x -= 9; colliderCombat.y += 4; } else if (birdTimeAttack1 < 204) { colliderCombat.x -= 9; colliderCombat.y -= 4; } else if (birdTimeAttack1 < 280) { colliderCombat.x -= 8; } } if (app->scene->combatScene->steps == 3) { if (birdTimeAttack1 < 31) { colliderCombat.x -= 8; } else if (birdTimeAttack1 < 56) // \* { colliderCombat.x -= 5; colliderCombat.y -= 5; } else if (birdTimeAttack1 < 91) // /* { colliderCombat.x += 9; colliderCombat.y -= 2; } else if (birdTimeAttack1 < 116) // \_ { colliderCombat.x += 5; colliderCombat.y += 5; if (birdTimeAttack1 == 115) app->scene->combatScene->playerHitAble = true; } else if (birdTimeAttack1 < 151) // _/ { colliderCombat.x -= 9; colliderCombat.y += 4; } else if (birdTimeAttack1 < 184) { colliderCombat.x -= 9; colliderCombat.y -= 4; } else if (birdTimeAttack1 < 280) { colliderCombat.x -= 8; } } birdTimeAttack1++; if (colliderCombat.x + colliderCombat.w < 0) { colliderCombat.x = 1280; colliderCombat.y = BIRD_C_Y; } } else if (typeOfAttack == 2) { if (birdTimeAttack2 < 30) { colliderCombat.x += 3; } else if (birdTimeAttack2 < 50) { colliderCombat.x += 0; } else if (birdTimeAttack2 < 75) { colliderCombat.x -= 12; colliderCombat.y += 3; } else if (birdTimeAttack2 < 150) { colliderCombat.x -= 12; if (birdTimeAttack2 == 149) { app->scene->combatScene->playerResponseAble = true; app->scene->combatScene->playerHitAble = true; } } else if (birdTimeAttack2 < 168) { colliderCombat.y--; colliderCombat.x -= 12; } else if (birdTimeAttack2 < 280) { colliderCombat.x -= 12; } birdTimeAttack2++; if (colliderCombat.x + colliderCombat.w < 0) { colliderCombat.x = 1280; colliderCombat.y = BIRD_C_Y; } } } void Enemy::MantisAttack(unsigned short int typeOfAttack) { if (typeOfAttack == 1) { if (mantisTimeAttack1 == 0) for (int i = 0; i < 5; i++) bullet[i].BulletReset(); if (mantisTimeAttack1 < 35) { MantisAttack1Logic(35); } else if (mantisTimeAttack1 < 70) { MantisAttack1Logic(70); } else if (mantisTimeAttack1 < 105) { MantisAttack1Logic(105); } else if (mantisTimeAttack1 < 140) { MantisAttack1Logic(140); } else if (mantisTimeAttack1 < 175) { MantisAttack1Logic(175); } else if (mantisTimeAttack1 < 280) { if (mantisTimeAttack1 == 279) for (int i = 0; i < 5; i++) bullet[i].BulletReset(); } //DRAW & UPDATE OF BULLETS for (int i = 0; i < 5; i++) bullet[i].Update(); } else if (typeOfAttack == 2) { if (mantisTimeAttack2 < 92) { colliderCombat.x += 3; } else if (mantisTimeAttack2 > 140 && mantisTimeAttack2 < 202) { colliderCombat.x -= 22; } else if (mantisTimeAttack2 >= 202 && mantisTimeAttack2 < 220) { colliderCombat.x = 325; colliderCombat.y = -75; app->scene->combatScene->playerHitAble = true; } else if (mantisTimeAttack2 >= 220 && mantisTimeAttack2 < 242) { colliderCombat.x += 24; colliderCombat.y += 22; } else if (mantisTimeAttack2 == 242) { colliderCombat.y = MANTIS_C_Y; colliderCombat.x += 22; } else if (mantisTimeAttack2 > 242 && mantisTimeAttack2 < 270) { int move = (20 - ((mantisTimeAttack2 - 242) * 2)); if (move <= 0) move = 2; colliderCombat.x += move; } else if (mantisTimeAttack2 == 270) colliderCombat.x = MANTIS_C_X; } else if (typeOfAttack == 3) { if (mantisTimeAttack3 < 5) { colliderCombat.x -= 2; } else if (mantisTimeAttack3 < 10) { colliderCombat.x += 2; } else if (mantisTimeAttack3 < 15) { colliderCombat.x -= 2; } else if (mantisTimeAttack3 < 20) { colliderCombat.x += 2; } } } void Enemy::MantisAttack1Logic(unsigned short int timer) { if (mantisTimeAttack1 == (timer - 35)) { int random = rand() % 2; jumping = bool(random); } if (mantisTimeAttack1 == (timer - 25)) { int i = (timer / 35) - 1; bullet[i].active = true; if (jumping) bullet[i].bulletRect.y = 338; } if (jumping) HighJump(); else if (jumping) jumpTime = 0; } void Enemy::Refill() { health = maxHealth; }
26.908411
144
0.48055
Ar-Ess
01d62e3204e1e18448aaa4abce554e8a673de006
1,411
cpp
C++
src/base/session/extension/MessagingExtension.cpp
mark-online/sne
92190c78a1710778acf16dd3a83af064db5c269b
[ "MIT" ]
null
null
null
src/base/session/extension/MessagingExtension.cpp
mark-online/sne
92190c78a1710778acf16dd3a83af064db5c269b
[ "MIT" ]
null
null
null
src/base/session/extension/MessagingExtension.cpp
mark-online/sne
92190c78a1710778acf16dd3a83af064db5c269b
[ "MIT" ]
null
null
null
#include "BasePCH.h" #include <sne/base/session/extension/MessagingExtension.h> #include <sne/base/session/impl/SessionImpl.h> #include <sne/base/memory/MemoryBlock.h> #include <sne/base/utility/Logger.h> #include <sne/core/Exception.h> namespace sne { namespace base { MessagingExtension::~MessagingExtension() { for (auto& value : messageCallbackMap_) { boost::checked_delete(value.second.message_); } } void MessagingExtension::sendMessage(Message& message) { MemoryBlock* mblock = getSessionImpl().serialize(message); if (mblock != nullptr) { getSessionImpl().sendMessage(*mblock, message.getMessageType()); } } bool MessagingExtension::handleMessage(MessageType messageType, MemoryBlock& mblock) { const MessageCallbackMap::iterator pos = messageCallbackMap_.find(messageType); if (pos == messageCallbackMap_.end()) { return false; } MessageCallback& callback = (*pos).second; core::IStream& istream = getSessionImpl().deserialize(mblock); try { callback.message_->serialize(istream); } catch (const core::Exception& e) { SNE_LOG_DEBUG("MessagingExtension::handleMessage() FAILED(%s).", e.what()); mblock.release(); getSessionImpl().disconnect(); return false; } callback.func_(*callback.message_); return true; } }} // namespace sne { namespace base {
26.622642
83
0.683203
mark-online
01de575d81a9366ebfad229d41a4902d4711e94e
2,822
cpp
C++
POO/exemploPOO.cpp
geovani-moc/Algoritmos-basico
d2d838c158da62a94946a7af29b24ca7396af34e
[ "Apache-2.0" ]
null
null
null
POO/exemploPOO.cpp
geovani-moc/Algoritmos-basico
d2d838c158da62a94946a7af29b24ca7396af34e
[ "Apache-2.0" ]
null
null
null
POO/exemploPOO.cpp
geovani-moc/Algoritmos-basico
d2d838c158da62a94946a7af29b24ca7396af34e
[ "Apache-2.0" ]
null
null
null
#include <iostream> // PROGRAMADOR: GEOVANI PEREIRA DOS SANTOS // EXEMPLO DE POO EM C++, POLIMORFISMO, CLASSES, HERANCA using namespace std; // inicio questao 1 class Animal { private: string nome; int idade; public: Animal(){} ~Animal(){} virtual void emitirSom(){} virtual void movimento(){} }; class Cachorro:Animal { public: Cachorro(){} void emitirSom() { cout << "Som de cachooroooooo ain ain ain rau" << endl; } void movimento() { cout << "Correr" << endl; } }; class Cavalo:Animal { public: Cavalo(){} ~Cavalo(){} void emitirSom() { cout << "som de cavalo" << endl; } void movimento() { cout << "Correr" << endl; } }; class Preguica:Animal { public: Preguica(){} ~Preguica(){} void emitirSom() { cout << "Som de preguica, meu som heuhuehueh " << endl; } void movimento() { cout << "Subir em arvore" << endl; } }; // fim questao 1 // faz parte da quetao 3 inicio class Veterinario { public: Veterinario(){} ~Veterinario(){} void examinar(Animal* animal) { animal->emitirSom(); } }; // faz parte da quetao 3 fim // faz parte da quetao 4 inicio class Zoologico { private: Animal* jaula[10]; public: Zoologico(){} ~Zoologico(){} void baguncinha() { for (int i = 0; i < 10; i++) { jaula[i]->movimento(); } } void adicionarAnimaisNaJaula(Animal* animal, int posicao) { jaula[posicao] = animal; } }; // faz parte da quetao 4 fim int main() { // inicio questao 2 Cavalo cavalo; Preguica preguica; Cachorro cao; cavalo.emitirSom(); cavalo.movimento(); cao.emitirSom(); cao.movimento(); preguica.movimento(); preguica.emitirSom(); // fim questao 2 // inicio questao 3 Veterinario veterinario; Animal* animalCachorro = (Animal*)&cao; Animal* animalCavalo = (Animal*) &cavalo; Animal* animalPreguica = (Animal*) &preguica; veterinario.examinar(animalCachorro); veterinario.examinar(animalCavalo); veterinario.examinar(animalPreguica); // fim questao 3 // inicio questao 4 Zoologico zoologico; Animal* animais[10]; animais[0] = (Animal*)&cao; animais[1] = (Animal*) &cavalo; animais[2] = (Animal*) &preguica; animais[3] = (Animal*)&cao; animais[4] = (Animal*) &cavalo; animais[5] = (Animal*) &preguica; animais[6] = (Animal*)&cao; animais[7] = (Animal*) &cavalo; animais[8] = (Animal*) &preguica; animais[9] = (Animal*)&cao; for (int i = 0; i < 10; i++) { zoologico.adicionarAnimaisNaJaula(animais[i],i); } zoologico.baguncinha(); // fim questao 4 return 0; }
18.565789
63
0.573352
geovani-moc
01dfa40a33f2215a67b857be1d57adb07ebc8184
1,060
cpp
C++
bob/bob.cpp
akilram/exercism-cpp-answers
88d1247beb6ad003640efd5af87a05ad1a0d3a88
[ "MIT" ]
null
null
null
bob/bob.cpp
akilram/exercism-cpp-answers
88d1247beb6ad003640efd5af87a05ad1a0d3a88
[ "MIT" ]
null
null
null
bob/bob.cpp
akilram/exercism-cpp-answers
88d1247beb6ad003640efd5af87a05ad1a0d3a88
[ "MIT" ]
null
null
null
#include "bob.h" using namespace std; using namespace boost; namespace bob { string hey(const string message) { const string message_trimmed = trim_copy(message); // Guard empty strings / Check if message is empty if (message_trimmed.empty()) return REPLY_FINE; // Check if message is all caps const string message_alpha_only = scan_alpha_only(message_trimmed); if (message_alpha_only.length() > 0 /* short-circuit guards */ && equals(message_alpha_only, to_upper_copy(message_alpha_only))) return REPLY_CHILL_OUT; // Check if end of message is '?' character if (message_trimmed.back() == '?') return REPLY_SURE; return REPLY_WHATEVER; } string scan_alpha_only(const string strArg) { ostringstream scan_buffer; for (auto itr = strArg.cbegin(); itr != strArg.cend(); ++itr) { const char& current = *itr; if (current >= 'a' && current <= 'z' || current >= 'A' && current <= 'Z') scan_buffer << current; } return scan_buffer.str(); } }
21.632653
70
0.646226
akilram
01e21b7fb1fd1848e3d1bcc8b8af524b9a9d432e
2,303
cpp
C++
engine/kotek.core.containers.multithreading/src/main_core_containers_multithreading_dll.cpp
wh1t3lord/kotek
1e3eb61569974538661ad121ed8eb28c9e608ae6
[ "Apache-2.0" ]
null
null
null
engine/kotek.core.containers.multithreading/src/main_core_containers_multithreading_dll.cpp
wh1t3lord/kotek
1e3eb61569974538661ad121ed8eb28c9e608ae6
[ "Apache-2.0" ]
null
null
null
engine/kotek.core.containers.multithreading/src/main_core_containers_multithreading_dll.cpp
wh1t3lord/kotek
1e3eb61569974538661ad121ed8eb28c9e608ae6
[ "Apache-2.0" ]
null
null
null
#include "../include/kotek_core_containers_multithreading.h" namespace Kotek { namespace Core { bool InitializeModule_Core_Containers_MultiThreading( ktkMainManager* p_manager) { InitializeModule_Core_Containers_MultiThreading_Atomic(p_manager); InitializeModule_Core_Containers_MultiThreading_Mutex(p_manager); InitializeModule_Core_Containers_MultiThreading_Semaphore( p_manager); InitializeModule_Core_Containers_MultiThreading_Shared_Mutex( p_manager); InitializeModule_Core_Containers_MultiThreading_TBB(p_manager); InitializeModule_Core_Containers_MultiThreading_Thread(p_manager); return true; } bool ShutdownModule_Core_Containers_MultiThreading( ktkMainManager* p_manager) { ShutdownModule_Core_Containers_MultiThreading_Atomic(p_manager); ShutdownModule_Core_Containers_MultiThreading_Mutex(p_manager); ShutdownModule_Core_Containers_MultiThreading_Semaphore(p_manager); ShutdownModule_Core_Containers_MultiThreading_Shared_Mutex( p_manager); ShutdownModule_Core_Containers_MultiThreading_TBB(p_manager); ShutdownModule_Core_Containers_MultiThreading_Thread(p_manager); return true; } bool SerializeModule_Core_Containers_MultiThreading( ktkMainManager* p_manager) { SerializeModule_Core_Containers_MultiThreading_Atomic(p_manager); SerializeModule_Core_Containers_MultiThreading_Mutex(p_manager); SerializeModule_Core_Containers_MultiThreading_Semaphore(p_manager); SerializeModule_Core_Containers_MultiThreading_Shared_Mutex( p_manager); SerializeModule_Core_Containers_MultiThreading_TBB(p_manager); SerializeModule_Core_Containers_MultiThreading_Thread(p_manager); return true; } bool DeserializeModule_Core_Containers_MultiThreading( ktkMainManager* p_manager) { DeserializeModule_Core_Containers_MultiThreading_Atomic(p_manager); DeserializeModule_Core_Containers_MultiThreading_Mutex(p_manager); DeserializeModule_Core_Containers_MultiThreading_Semaphore( p_manager); DeserializeModule_Core_Containers_MultiThreading_Shared_Mutex( p_manager); DeserializeModule_Core_Containers_MultiThreading_TBB(p_manager); DeserializeModule_Core_Containers_MultiThreading_Thread(p_manager); return true; } } // namespace Core } // namespace Kotek
35.430769
71
0.85063
wh1t3lord
01e23a1b9fe93d2962f63b2e407eedd149433f6e
201
cpp
C++
Labs/Lab6/main.cpp
Xeltide/Comp3512
ec1aff98d4b2fda6446d60afca571940a3701e29
[ "MIT" ]
null
null
null
Labs/Lab6/main.cpp
Xeltide/Comp3512
ec1aff98d4b2fda6446d60afca571940a3701e29
[ "MIT" ]
null
null
null
Labs/Lab6/main.cpp
Xeltide/Comp3512
ec1aff98d4b2fda6446d60afca571940a3701e29
[ "MIT" ]
null
null
null
#include "FixedVector.h" #include <iostream> int main() { lab6::FixedVector<int, 10> numbers; numbers.Add(1); numbers.Add(2); std::cout << numbers[0] << std::endl; system("pause"); return 0; }
14.357143
38
0.646766
Xeltide
01e24a552a21603e3ab827ddaa6d5bee45318fec
3,124
cpp
C++
Ejercicios/TAREA #6-Punto-de-Venta-parte/productos.cpp
AngelaC02/cpp
89464b01bc79b91e2229340481e5f9db0621d00c
[ "MIT" ]
null
null
null
Ejercicios/TAREA #6-Punto-de-Venta-parte/productos.cpp
AngelaC02/cpp
89464b01bc79b91e2229340481e5f9db0621d00c
[ "MIT" ]
null
null
null
Ejercicios/TAREA #6-Punto-de-Venta-parte/productos.cpp
AngelaC02/cpp
89464b01bc79b91e2229340481e5f9db0621d00c
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; extern void agregarProducto(string descripcion, int cantidad, double precio); void productos(int opcion) { system("cls"); int opcionProducto = 0; switch (opcion) { case 1: { cout<< "BEBIDAS CALIENTES"<< endl; cout<< "*****************"<<endl; cout<< "1 - Capuccino"<<endl; cout<< "2 - Expresso"<<endl; cout<< "3 - Cafe Mocha"<<endl; cout<< endl; cout<< "Ingrese una opcion: "; cin >> opcionProducto; switch (opcionProducto) { case 1: agregarProducto("1 Capuccino L 40.00", 1, 40); break; case 2: agregarProducto("1 Expresso L 30.00", 1, 30); break; case 3: agregarProducto("1 Cafe Mocha L 25.00", 1, 25); break; default: { cout<< "opcion no valida"; return; break; } } cout<< endl; cout<< "Producto agregado" << endl << endl; system("pause"); break; } case 2: { cout<< "BEBIDAS FRIAS"<< endl; cout<< "*************"<<endl; cout<< "1 - Mochaccino" <<endl; cout<< "2 - Pina Colada Granita" <<endl; cout<< "3 - Caramel Granita" <<endl; cout<< endl; cout<< "Ingrese una opcion: "; cin >> opcionProducto; switch (opcionProducto) { case 1: agregarProducto("1 Mochaccino L 56.00", 1, 56); break; case 2: agregarProducto("1 Pina Colada Granita L 52.00", 1, 52); break; case 3: agregarProducto("1 Caramel Granita L 55.00", 1, 55); break; default: { cout<< "opcion no valida"; return; break; } } cout<< endl; cout<< "Producto agregado" << endl << endl; system("pause"); break; } case 3: { cout<< "REPOSTERIA"<< endl; cout<< "**********"<<endl; cout<< "1 - Chilena Cookie" << endl; cout<< "2 - Quequito de Elote" << endl; cout<< "3 - Cheese Cake" << endl; cout<< "Ingrese una opcion: "; cin >> opcionProducto; switch (opcionProducto) { case 1: agregarProducto("1 Chilena Cookie L 32.00", 1, 32); break; case 2: agregarProducto("1 Quequito de Elote L 25.00", 1, 25); break; case 3: agregarProducto("1 Cheese Cake L 60.00", 1, 60); break; default: { cout<< "opcion no valida"; return; break; } } cout<< endl; cout<< "Producto agregado" << endl << endl; system("pause"); break; } default: break; } }
22.970588
78
0.422215
AngelaC02
01e5dd225456b00ddf680c9f290272a4767aa4aa
3,868
cpp
C++
vent_control_settings.cpp
jim-sokoloff/emergency-field-ventilator-timer-relay
c6fb63cf889a6cba79d06053890e494960ecd4d9
[ "Apache-2.0" ]
null
null
null
vent_control_settings.cpp
jim-sokoloff/emergency-field-ventilator-timer-relay
c6fb63cf889a6cba79d06053890e494960ecd4d9
[ "Apache-2.0" ]
null
null
null
vent_control_settings.cpp
jim-sokoloff/emergency-field-ventilator-timer-relay
c6fb63cf889a6cba79d06053890e494960ecd4d9
[ "Apache-2.0" ]
null
null
null
/* Copyright 2020, Jim Sokoloff Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "vent_control_settings.h" #include "vent_control_EEPROM.h" const IERatio g_IESteps[] = { {10, 50, 1667}, {10, 45, 1806}, {10, 41, 1944}, {10, 38, 2083}, {10, 35, 2222}, {10, 32, 2361}, {10, 30, 2500}, {10, 28, 2639}, {10, 26, 2778}, {10, 24, 2917}, {10, 23, 3056}, {10, 21, 3194}, {10, 20, 3333}, {10, 19, 3472}, {10, 18, 3611}, {10, 17, 3750}, {10, 16, 3889}, {10, 15, 4028}, {10, 14, 4167}, {10, 13, 4306}, {10, 13, 4444}, {10, 12, 4583}, {10, 11, 4722}, {10, 11, 4861}, {10, 10, 5000}, {11, 10, 5139}, {11, 10, 5278}, {12, 10, 5417}, {13, 10, 5556}, {13, 10, 5694}, {14, 10, 5833}, {15, 10, 5972}, {16, 10, 6111}, {17, 10, 6250}, {18, 10, 6389}, {19, 10, 6528}, {20, 10, 6667}, {21, 10, 6806}, {23, 10, 6944}, {24, 10, 7083}, {26, 10, 7222}, {28, 10, 7361}, {30, 10, 7500}, {32, 10, 7639}, {35, 10, 7778}, {38, 10, 7917}, {41, 10, 8056}, {45, 10, 8194}, {50, 10, 8333} }; const byte k_numIESteps = sizeof(g_IESteps)/sizeof(g_IESteps[0]); long g_serialSpeed = 115200; IERatio::IERatio(byte i, byte e, int inhale_percentage_in_bpp) : i(i), e(e), inhale_percentage_in_bpp(inhale_percentage_in_bpp) { } VentControlSettings::VentControlSettings() { breathInTenthsPerMinute = 200; ieRatioIndex = k_numIESteps / 4; enabled = 1; this->checkSettings(); } void VentControlSettings::selectIndex(byte index) { ieRatioIndex = index; ieRatio = g_IESteps[index]; } void VentControlSettings::setBPM10ths(int breathInTenthsPerMinute) { this->breathInTenthsPerMinute = breathInTenthsPerMinute; } void VentControlSettings::setEnabled(byte enabled) { this->enabled = enabled; } void VentControlSettings::checkSettings() { ieRatioIndex = constrain(ieRatioIndex, 0, k_numIESteps-1); selectIndex(ieRatioIndex); breathInTenthsPerMinute = breathInTenthsPerMinute / 5 * 5; breathInTenthsPerMinute = constrain(breathInTenthsPerMinute, 100, 300); } VentControlSettings g_settings[8]; void checkSettings(int patient) { g_settings[patient].checkSettings(); } const VentControlSettings *getSettings(int patient) { return &g_settings[patient]; } void VentControlSettings::incrementIERatioIndex(int offset) { selectIndex(ieRatioIndex + offset); scheduleEEPROMUpdate( 5UL * 1000UL); } void VentControlSettings::incrementBPM(int offset) { breathInTenthsPerMinute += offset * 5; scheduleEEPROMUpdate( 5UL * 1000UL); } byte getEnabled(int patient) { return g_settings[patient].enabled; } unsigned long VentControlSettings::getTotalDurationInMS(void) { unsigned long duration = 600000 / breathInTenthsPerMinute; return duration; } unsigned long VentControlSettings::getInhaleDurationInMS(void) { unsigned long duration = getTotalDurationInMS(); duration = duration * ( ieRatio.inhale_percentage_in_bpp) / 10000UL; return duration; } unsigned long VentControlSettings::getExhaleDurationInMS(void) { unsigned long duration = getTotalDurationInMS(); duration = duration * (10000 - ieRatio.inhale_percentage_in_bpp) / 10000UL; return duration; }
36.838095
129
0.657446
jim-sokoloff
01e61fc26ed94a0be13c45cbeddbcfe2b12162d1
876
hpp
C++
src/mctsnode.hpp
andrewsng/checkers_bot
9d98df021cd236b27ef36702a6e98e613fad3911
[ "MIT" ]
null
null
null
src/mctsnode.hpp
andrewsng/checkers_bot
9d98df021cd236b27ef36702a6e98e613fad3911
[ "MIT" ]
null
null
null
src/mctsnode.hpp
andrewsng/checkers_bot
9d98df021cd236b27ef36702a6e98e613fad3911
[ "MIT" ]
null
null
null
#ifndef MCTSNODE_HPP #define MCTSNODE_HPP #include "board.hpp" #include "move.hpp" #include "checkersgame.hpp" #include "movegen.hpp" #include <vector> #include <memory> #include <optional> #include <utility> class MCTSNode { public: MCTSNode(Board board, int player, std::optional<Move> move = {}); std::pair<MCTSNode *, bool> selectLeaf(); MCTSNode *expandLeaf(); void propagateResult(GameResult result); GameResult rollout() const; Move moveWithMostRollouts() const; int countNodes() const; private: double UCTValue(int player) const; Board _board{}; int _player{}; Move _prevMove{}; double _winPoints{0.0}; int _numRollouts{0}; std::vector<Move> _unvisited{generateMoves(_board, _player)}; std::vector<std::shared_ptr<MCTSNode>> _children{}; MCTSNode *_parent{nullptr}; }; #endif // MCTSNODE_HPP
20.372093
69
0.690639
andrewsng
543a03dda8300e9b85cbaa3f227d199ea28c9210
70
cpp
C++
darknet-master/build/modules/video/opencv_perf_video_pch.cpp
mcyy23633/ship_YOLOv4
2eb53e578546fce663a2f3fa153481ce4f82c588
[ "MIT" ]
null
null
null
darknet-master/build/modules/video/opencv_perf_video_pch.cpp
mcyy23633/ship_YOLOv4
2eb53e578546fce663a2f3fa153481ce4f82c588
[ "MIT" ]
null
null
null
darknet-master/build/modules/video/opencv_perf_video_pch.cpp
mcyy23633/ship_YOLOv4
2eb53e578546fce663a2f3fa153481ce4f82c588
[ "MIT" ]
null
null
null
#include "C:/opencv/opencv-4.5.1/modules/video/perf/perf_precomp.hpp"
35
69
0.771429
mcyy23633
543bb049ab3219a5e951858c153bb97a4ef4dbc2
154
cpp
C++
Source/VRInteractables/VRInteractablesGameModeBase.cpp
calben/UE4-VRInteractables
61dcf4f091540cacb15d6d4790972159387d9b1b
[ "MIT" ]
null
null
null
Source/VRInteractables/VRInteractablesGameModeBase.cpp
calben/UE4-VRInteractables
61dcf4f091540cacb15d6d4790972159387d9b1b
[ "MIT" ]
null
null
null
Source/VRInteractables/VRInteractablesGameModeBase.cpp
calben/UE4-VRInteractables
61dcf4f091540cacb15d6d4790972159387d9b1b
[ "MIT" ]
null
null
null
// Fill out your copyright notice in the Description page of Project Settings. #include "VRInteractables.h" #include "VRInteractablesGameModeBase.h"
17.111111
78
0.785714
calben
543c91e1504073763275497bd8044116f3ae455d
1,717
cpp
C++
src/homework/03_iteration/dna.cpp
acc-cosc-1337-spring-2020/acc-cosc-1337-spring-2020-ChelliBean
9e2f45a1d9682f5c9391a594e1284c6beffd9f58
[ "MIT" ]
null
null
null
src/homework/03_iteration/dna.cpp
acc-cosc-1337-spring-2020/acc-cosc-1337-spring-2020-ChelliBean
9e2f45a1d9682f5c9391a594e1284c6beffd9f58
[ "MIT" ]
null
null
null
src/homework/03_iteration/dna.cpp
acc-cosc-1337-spring-2020/acc-cosc-1337-spring-2020-ChelliBean
9e2f45a1d9682f5c9391a594e1284c6beffd9f58
[ "MIT" ]
null
null
null
#include "dna.h" #include<iostream> using std::string; /* Write code for function get_gc_content that accepts a const reference string parameter and returns a double. Calculate GC content: Iterate string count Gs and Cs, divide count by string length. Return quotient. */ double get_gc_content(const std::string & dna1) { double count1 = 0; double count2 = 0; for (int i = 0; i <= dna1.length(); ++i) { if (dna1[i] == 'C' || dna1[i] == 'G') { count1 = count1 + 1; } else if (dna1[i] == 'A' || dna1[i] == 'T') { count2 = count2 + 1; } } int total = count1 + count2; double gc = count1 / total; return gc; } /* Write code for function get_reverse_string that accepts a string parameter and returns a string reversed. */ string get_reverse_string(std::string dna2) { string flipdna; flipdna = ""; for(auto i=dna2.length(); i!=0; i--) { flipdna.push_back(dna2[i-1]); } return flipdna; } /* Write prototype for function get_dna_complement that accepts a string dna and returns a string. Calculate dna complement: a. call function get_reverse_string(dna), save results to a local string variable b. iterate local string variable and replace A with T, T with A, C with G and G with C c. return string */ string get_dna_complement(std::string dna2) { string complement; complement = get_reverse_string(dna2); for (auto i = 0; i < complement.length(); ++i) { if(complement[i]=='A') { complement[i] = 'T'; } else if(complement[i] == 'C') { complement[i] = 'G'; } else if(complement[i] == 'G') { complement[i] = 'C'; } else if(complement[i] == 'T') { complement[i] = 'A'; } else { return 0; } } return complement; }
16.669903
81
0.645312
acc-cosc-1337-spring-2020
544185533b55c01b0fdd57f4c4f463e146128426
916
cpp
C++
ViAn/Project/Test/bookmarktest.cpp
NFCSKL/NFC-ViAn
ce04b78b4c9695374d71198f57d4236a5cad1525
[ "MIT" ]
1
2019-12-08T03:53:03.000Z
2019-12-08T03:53:03.000Z
ViAn/Project/Test/bookmarktest.cpp
NFCSKL/NFC-ViAn
ce04b78b4c9695374d71198f57d4236a5cad1525
[ "MIT" ]
182
2018-02-08T11:03:26.000Z
2019-06-27T15:27:47.000Z
ViAn/Project/Test/bookmarktest.cpp
NFCSKL/NFC-ViAn
ce04b78b4c9695374d71198f57d4236a5cad1525
[ "MIT" ]
null
null
null
#include "bookmarktest.h" #include <QTest> void BookmarkTest::initTestCase(){ m_temp_dir.setAutoRemove(true); QVERIFY(m_temp_dir.isValid()); } void BookmarkTest::cleanupTestCase(){ } void BookmarkTest::init() { qDebug() << "Creating new bookmark"; m_bookmark = std::unique_ptr<Bookmark>(new Bookmark); m_bookmark->m_unsaved_changes = false; // Force saved status } void BookmarkTest::cleanup() { } void BookmarkTest::test_saved_status() { m_bookmark->reset_root_dir(m_temp_dir.path()); QVERIFY(!m_bookmark->is_saved()); m_bookmark->m_unsaved_changes = false; m_bookmark->set_description("DESCRIPTION_TEST"); QVERIFY(!m_bookmark->is_saved()); m_bookmark->m_unsaved_changes = false; m_bookmark->set_container(0, 0); //m_bookmark->add_container("CONTAINER_TEST", 0); // fix QVERIFY(!m_bookmark->is_saved()); m_bookmark->m_unsaved_changes = false; }
24.105263
64
0.708515
NFCSKL
544276e6bdbff93e21c4f34fb50c81c69fc6d78d
553
hpp
C++
src/Planet.hpp
bethang/corona3d_2020
868dcea42dbcc04c49b8fbe3635f2a2fbd8c9d6f
[ "MIT" ]
null
null
null
src/Planet.hpp
bethang/corona3d_2020
868dcea42dbcc04c49b8fbe3635f2a2fbd8c9d6f
[ "MIT" ]
null
null
null
src/Planet.hpp
bethang/corona3d_2020
868dcea42dbcc04c49b8fbe3635f2a2fbd8c9d6f
[ "MIT" ]
2
2021-05-26T18:22:15.000Z
2022-01-27T17:31:00.000Z
/* * Planet.hpp * * Created on: May 29, 2020 * Author: rodney */ #ifndef PLANET_HPP_ #define PLANET_HPP_ #include "Common_Functions.hpp" class Planet { public: Planet(); virtual ~Planet(); void init(); // initialize with defaults (Venus mass/radius) void init(double m, double r); double get_mass(); double get_radius(); double get_k_g(); private: double mass; // [g] mass of planet double radius; // [cm] radius of planet double k_g; // [cm^3/s^2] planet's gravitational constant (-G*mass) }; #endif /* PLANET_HPP_ */
18.433333
72
0.661844
bethang
5446dc70b3d692c6716a556d36038b7dc0de1d28
1,638
hpp
C++
source/Kai/Function.hpp
ioquatix/kai
4f8d00cd05b4123b6389f8dc3187ec1421b4f2da
[ "Unlicense", "MIT" ]
4
2016-07-19T08:53:09.000Z
2021-08-03T10:06:41.000Z
source/Kai/Function.hpp
ioquatix/kai
4f8d00cd05b4123b6389f8dc3187ec1421b4f2da
[ "Unlicense", "MIT" ]
null
null
null
source/Kai/Function.hpp
ioquatix/kai
4f8d00cd05b4123b6389f8dc3187ec1421b4f2da
[ "Unlicense", "MIT" ]
null
null
null
// // Function.h // This file is part of the "Kai" project, and is released under the MIT license. // // Created by Samuel Williams on 13/04/10. // Copyright 2010 Samuel Williams. All rights reserved. // // #ifndef _KFUNCTION_H #define _KFUNCTION_H #include "Object.hpp" #define KAI_BUILTIN_FUNCTION(function) (builtin_function<&function>(#function)) namespace Kai { typedef Object * (*EvaluateFunctionT)(Frame *); template <Ref<Object> (*FunctionT)(Frame *)> class BuiltinFunction : public Object { protected: const char * _name; public: static const char * const NAME; BuiltinFunction(const char * name) : _name(name) { } virtual Ref<Object> evaluate (Frame * frame) { return FunctionT(frame); } virtual void to_code(Frame * frame, StringStreamT & buffer, MarkedT & marks, std::size_t indentation) const { buffer << "(builtin-function " << _name << ")"; } }; template <Ref<Object> (*FunctionT)(Frame *)> const char * const BuiltinFunction<FunctionT>::NAME = "BuiltinFunction"; template <Ref<Object> (*FunctionT)(Frame *)> BuiltinFunction<FunctionT> * builtin_function(const char * name) { static BuiltinFunction<FunctionT> instance(name); return &instance; } class DynamicFunction : public Object { protected: EvaluateFunctionT _evaluate_function; public: static const char * const NAME; DynamicFunction(EvaluateFunctionT evaluate_function); virtual ~DynamicFunction(); virtual Ref<Object> evaluate(Frame * frame); virtual void to_code(Frame * frame, StringStreamT & buffer, MarkedT & marks, std::size_t indentation) const; }; } #endif
24.088235
111
0.704518
ioquatix
544acb2c6342d07a708ea1d87af4006afd274bc0
2,388
cpp
C++
Ansel/src/source/entities/Camera.cpp
maxortner01/ansel
cf9930c921ca439968daa29b242a1b532030088a
[ "BSD-2-Clause" ]
2
2019-04-04T07:26:54.000Z
2019-07-07T20:48:30.000Z
Ansel/src/source/entities/Camera.cpp
maxortner01/ansel
cf9930c921ca439968daa29b242a1b532030088a
[ "BSD-2-Clause" ]
null
null
null
Ansel/src/source/entities/Camera.cpp
maxortner01/ansel
cf9930c921ca439968daa29b242a1b532030088a
[ "BSD-2-Clause" ]
null
null
null
#include "../../headers/entities/camera.h" #include "../../headers/event/Keyboard.h" #include "../../headers/Engine.h" namespace Ansel { Camera::Camera() { location = { 0, 0, 0 }; rotation = { 0, 0, 0 }; } void Camera::pollEvents() { float s = speed * (Engine::getTime() - last_time); if (Keyboard::isKeyPressed(KEY::L_SHIFT)) s *= 2; if (Keyboard::isKeyPressed(KEY::W)) move(Camera::FORWARDS, s); if (Keyboard::isKeyPressed(KEY::S)) move(Camera::BACKWARDS, s); if (Keyboard::isKeyPressed(KEY::D)) move(Camera::RIGHT, s); if (Keyboard::isKeyPressed(KEY::A)) move(Camera::LEFT, s); if (Keyboard::isKeyPressed(KEY::SPACE)) translate(0, s, 0); if (Keyboard::isKeyPressed(KEY::L_CTRL)) translate(0, -s, 0); last_time = Engine::getTime(); } void Camera::setSpeed(float s) { speed = s; } void Camera::move(DIRECTION direction, float speed) { switch (direction) { case FORWARDS: translate(speed * cosf(rotation.y + 3.14159f / 2.f), 0, speed * sinf(rotation.y + 3.14159f / 2.f)); break; case BACKWARDS: translate(-speed * cosf(rotation.y + 3.14159f / 2.f), 0, -speed * sinf(rotation.y + 3.14159f / 2.f)); break; case LEFT: translate(-speed * cosf(rotation.y), 0, -speed * sinf(rotation.y)); break; case RIGHT: translate(speed * cosf(rotation.y), 0, speed * sinf(rotation.y)); break; default: return; }; } void Camera::translate(vec3f vTranslate) { location = { location.x + vTranslate.x, location.y + vTranslate.y, location.z + vTranslate.z }; } void Camera::translate(float x, float y, float z) { translate({ x, y, z }); } void Camera::rotate(vec3f vRotate) { rotation = { rotation.x + vRotate.x, rotation.y + vRotate.y, rotation.z + vRotate.z }; } void Camera::rotate(float x, float y, float z) { rotate({ x, y, z }); } mat4x4 Camera::getView() { mat4x4 view; view.setIdentity(); view = view * mat4x4::makeTranslation(-location.x, -location.y, -location.z) * mat4x4::makeRotation(rotation.x, rotation.y, rotation.z); return view; } vec3f Camera::getLocation() { return { location.x, location.y, location.z }; } void Camera::setLocation(vec3f loc) { location = loc; } void Camera::addLocation(vec3f loc) { location += loc; } void Camera::addLocation(float x, float y, float z) { addLocation({ x, y, z }); } }
20.947368
138
0.628141
maxortner01
5451def9790860b6ee396c0f6cd6265fee3e337c
829
hpp
C++
include/RED4ext/Scripting/Natives/Generated/game/AudioSyncs.hpp
jackhumbert/RED4ext.SDK
2c55eccb83beabbbe02abae7945af8efce638fca
[ "MIT" ]
42
2020-12-25T08:33:00.000Z
2022-03-22T14:47:07.000Z
include/RED4ext/Scripting/Natives/Generated/game/AudioSyncs.hpp
jackhumbert/RED4ext.SDK
2c55eccb83beabbbe02abae7945af8efce638fca
[ "MIT" ]
38
2020-12-28T22:36:06.000Z
2022-02-16T11:25:47.000Z
include/RED4ext/Scripting/Natives/Generated/game/AudioSyncs.hpp
jackhumbert/RED4ext.SDK
2c55eccb83beabbbe02abae7945af8efce638fca
[ "MIT" ]
20
2020-12-28T22:17:38.000Z
2022-03-22T17:19:01.000Z
#pragma once // This file is generated from the Game's Reflection data #include <cstdint> #include <RED4ext/Common.hpp> #include <RED4ext/DynArray.hpp> #include <RED4ext/Scripting/Natives/Generated/audio/AudEventStruct.hpp> #include <RED4ext/Scripting/Natives/Generated/audio/AudParameter.hpp> #include <RED4ext/Scripting/Natives/Generated/audio/AudSwitch.hpp> namespace RED4ext { namespace game { struct AudioSyncs { static constexpr const char* NAME = "gameAudioSyncs"; static constexpr const char* ALIAS = NAME; DynArray<audio::AudSwitch> switchEvents; // 00 DynArray<audio::AudEventStruct> playEvents; // 10 DynArray<audio::AudEventStruct> stopEvents; // 20 DynArray<audio::AudParameter> parameterEvents; // 30 }; RED4EXT_ASSERT_SIZE(AudioSyncs, 0x40); } // namespace game } // namespace RED4ext
29.607143
71
0.761158
jackhumbert
5457cc9f57740136fedbea641e81d64d14fdcc95
459
cpp
C++
Baekjoon/10844.cpp
Twinparadox/AlgorithmProblem
0190d17555306600cfd439ad5d02a77e663c9a4e
[ "MIT" ]
null
null
null
Baekjoon/10844.cpp
Twinparadox/AlgorithmProblem
0190d17555306600cfd439ad5d02a77e663c9a4e
[ "MIT" ]
null
null
null
Baekjoon/10844.cpp
Twinparadox/AlgorithmProblem
0190d17555306600cfd439ad5d02a77e663c9a4e
[ "MIT" ]
null
null
null
#include <iostream> #include <vector> using namespace std; int main(void) { int N, mod = 1000000000; long long dp[101][10] = { 0, }, ans = 0; cin >> N; for (int i = 1; i < 10; i++) dp[1][i] = 1; for (int i = 2; i <= N; i++) { dp[i][0] = dp[i - 1][1]; dp[i][9] = dp[i - 1][8]; for (int j = 1; j < 9; j++) dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1]) % mod; } for (int i = 0; i < 10; i++) ans = (ans + dp[N][i]) % mod; cout << ans; }
19.956522
58
0.446623
Twinparadox
5458e9ab04b23d7b38aad366e9673cbd8a1fe37b
451
cpp
C++
src/task/rejected.cpp
SameAsMuli/todo
75b6380b2e8c9a0696f97f43b103de7d12fbd840
[ "MIT" ]
null
null
null
src/task/rejected.cpp
SameAsMuli/todo
75b6380b2e8c9a0696f97f43b103de7d12fbd840
[ "MIT" ]
null
null
null
src/task/rejected.cpp
SameAsMuli/todo
75b6380b2e8c9a0696f97f43b103de7d12fbd840
[ "MIT" ]
null
null
null
#include <sstream> // std::stringstream #include "task/rejected.hpp" #include "util/ansi.hpp" namespace todo { namespace task { Rejected::Rejected() : CompleteAbstract("rejected", '/') {} std::string Rejected::format(const Task &task) { std::stringstream ss; ss << util::ansi::foreground_red << task.getPrefix() << " " << task.getDescription() << util::ansi::reset; return ss.str(); } } // namespace task } // namespace todo
20.5
63
0.649667
SameAsMuli
5462edc1ff6b2feb8267261303d8966957f32c96
2,055
cpp
C++
codeforces/D - Om Nom and Necklace/Accepted.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
1
2022-02-11T16:55:36.000Z
2022-02-11T16:55:36.000Z
codeforces/D - Om Nom and Necklace/Accepted.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
null
null
null
codeforces/D - Om Nom and Necklace/Accepted.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
null
null
null
/**************************************************************************************** * @author: kzvd4729# created: Jun/18/2020 12:32 * solution_verdict: Accepted language: GNU C++14 * run_time: 171 ms memory_used: 176300 KB * problem: https://codeforces.com/contest/526/problem/D ****************************************************************************************/ #include<iostream> #include<vector> #include<cstring> #include<map> #include<bitset> #include<assert.h> #include<algorithm> #include<iomanip> #include<cmath> #include<set> #include<queue> #include<unordered_map> #include<random> #include<chrono> #include<stack> #include<deque> #define long long long using namespace std; const long N=3e6; vector<long> z_function(string s) { long n = (long) s.length(); vector<long> z(n); for (long i = 1, l = 0, r = 0; i < n; ++i) { if (i <= r) z[i] = min (r - i + 1, z[i - l]); while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i]; if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1; } return z; } long ln[N+2],ad[N+2]; int main() { ios_base::sync_with_stdio(0);cin.tie(0); long n,k;cin>>n>>k;string s;cin>>s; if(k>n) { for(long i=1;i<=n;i++)cout<<0; cout<<endl,exit(0); } vector<long>z=z_function(s); for(long i=1;i<=2*N;i++)z.push_back(0); //for(long i=0;i<n;i++)cout<<z[i]<<" ";cout<<endl; for(long l=1;l<=n;l++) { if(l*k>n)continue;ln[l]=1; for(long i=l;i<k*l;i+=l) { if(z[i]<l)ln[l]=0; } if(ln[l]==0)continue; ad[k*l-1]++,ad[k*l]--;long mn=0; if(k*l<n)mn=min(l,z[k*l]); ad[k*l]++; if(k*l+mn<n)ad[k*l+mn]--; } for(long i=0;i<n;i++) { if(i)ad[i]+=ad[i-1];if(ad[i]<0)exit(0); cout<<(bool)ad[i]; } cout<<endl; //for(long i=1;i<=n;i++)cout<<ln[i]<<" ";cout<<endl; return 0; }
28.150685
111
0.442822
kzvd4729
54647a479195d2a60f1e9cde641741077b1267e2
593
hpp
C++
characters/Medusa.hpp
sonamdkindy/fantasycombat
1203d336db2c2f2a8815a449ee881a5f54b2a641
[ "MIT" ]
null
null
null
characters/Medusa.hpp
sonamdkindy/fantasycombat
1203d336db2c2f2a8815a449ee881a5f54b2a641
[ "MIT" ]
null
null
null
characters/Medusa.hpp
sonamdkindy/fantasycombat
1203d336db2c2f2a8815a449ee881a5f54b2a641
[ "MIT" ]
null
null
null
/********************************************************************* ** Program name: Medusa.hpp ** Author: Sonam D. Kindy ** Date: 11/11/17 ** Description: This file is the Medusa subclass specification/interface. *********************************************************************/ #ifndef MEDUSA_HPP #define MEDUSA_HPP #include "Character.hpp" class Medusa : public Character { public: // declare constructors Medusa(std::string); // declare member functions, set/get void defense(int); virtual int attack(); ~Medusa(); }; #endif
23.72
73
0.494098
sonamdkindy
5468ce1778fecd1114ac1c6967b9734dcf757220
11,022
cpp
C++
tools/source_maker/source_templates/wxwidgets.cpp
wxphp/wxphp
a691f72e66162fabf4408abe9545d2f4cccb15fa
[ "PHP-3.01" ]
269
2015-01-01T08:03:31.000Z
2022-01-23T04:13:53.000Z
tools/source_maker/source_templates/wxwidgets.cpp
wxphp/wxphp
a691f72e66162fabf4408abe9545d2f4cccb15fa
[ "PHP-3.01" ]
92
2015-01-01T13:03:06.000Z
2020-11-23T02:43:58.000Z
tools/source_maker/source_templates/wxwidgets.cpp
wxphp/wxphp
a691f72e66162fabf4408abe9545d2f4cccb15fa
[ "PHP-3.01" ]
54
2015-01-10T17:28:26.000Z
2021-06-10T22:57:19.000Z
/* * @author Mário Soares * @contributors Jefferson González * @contributors René Vögeli / Rangee GmbH * * @license * This file is part of wxPHP check the LICENSE file for information. * * @description * Main start point for the wxWidgets php extension * * @note * Some parts of this file are auto-generated by the wxPHP source maker */ #include "php_wxwidgets.h" #include "app.h" #include "functions.h" #ifdef __WXMSW__ #include <wx/msw/private.h> #include <wx/msw/winundef.h> #include <wx/msw/msvcrt.h> #endif /** * To enable inclusion of class methods tables entries code * on the generated headers */ #define WXPHP_INCLUDE_METHOD_TABLES /** * Space reserved for the zend_class_entry declaration of each class * as the resource id and its include files */ <?php print $entries ?> /** * Predefined handcoded class entry and object handler for wxApp */ zend_class_entry *php_wxApp_entry; zend_object_handlers wxphp_wxApp_object_handlers; /** * Custom function to register global objects as constants */ BEGIN_EXTERN_C() void wxphp_register_object_constant(const char *name, zval object, int flags, int module_number) { zend_constant c; c.name = zend_string_init(name, strlen(name), flags & CONST_PERSISTENT); ZVAL_COPY(&c.value, &object); #if PHP_VERSION_ID < 70300 c.flags = flags; c.module_number = module_number; #else ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number); #endif zend_register_constant(&c); } END_EXTERN_C() /** * Custom zend_method_call function to call methods with more than 2 parameters */ BEGIN_EXTERN_C() int wxphp_call_method(zval *object_p, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, int function_name_len, zval *retval_ptr, int param_count, zval** params) { /*First check the method is callable*/ zval method_to_call; zend_fcall_info_cache fcc; int is_callable = SUCCESS; if(!*fn_proxy) { array_init(&method_to_call); add_next_index_zval(&method_to_call, object_p); add_next_index_stringl(&method_to_call, (char*) function_name, function_name_len); if(!zend_is_callable_ex(&method_to_call, NULL, 0, NULL, &fcc, NULL)) { is_callable = FAILURE; } if(is_callable == FAILURE) return FAILURE; } int result; zend_fcall_info fci; zval z_fname; zval *retval; HashTable *function_table; fci.size = sizeof(fci); fci.object = object_p ? Z_OBJ_P(object_p) : NULL; fci.function_name = z_fname; fci.retval = retval_ptr ? retval_ptr : retval; fci.param_count = param_count; fci.params = *params; fci.no_separation = 1; if (!fn_proxy && !obj_ce) { /* no interest in caching and no information already present that is * needed later inside zend_call_function. */ ZVAL_STRINGL(&z_fname, function_name, function_name_len); result = zend_call_function(&fci, NULL); } else { zend_fcall_info_cache fcic = fcc; #if PHP_VERSION_ID < 70300 fcic.initialized = 1; #endif if (!obj_ce) { obj_ce = object_p ? Z_OBJCE_P(object_p) : NULL; } if (!fn_proxy || !*fn_proxy) { if (fn_proxy) { *fn_proxy = fcic.function_handler; } } else { fcic.function_handler = *fn_proxy; } fcic.calling_scope = obj_ce; if (object_p) { fcic.called_scope = Z_OBJCE_P(object_p); } else if (obj_ce) { fcic.called_scope = obj_ce; } fcic.object = object_p ? Z_OBJ_P(object_p) : NULL; result = zend_call_function(&fci, &fcic); } if (result == FAILURE) { /* error at c-level */ if (!obj_ce) { obj_ce = object_p ? Z_OBJCE_P(object_p) : NULL; } if (!EG(exception)) { zend_error(E_CORE_ERROR, "Couldn't execute method %s%s%s", obj_ce ? obj_ce->name : (zend_string*) "", obj_ce ? "::" : "", function_name); } } if (!retval_ptr) { if (retval) { zval_ptr_dtor(retval); } return FAILURE; } return SUCCESS; } END_EXTERN_C() /** * Code that enables correct functioning of comctl32.dll and 6.0 new * controls look. (Thanks to Robin Dunn from wxPython) */ #ifdef __WXMSW__ //---------------------------------------------------------------------- // Use an ActivationContext to ensure that the new (themed) version of // the comctl32 DLL is loaded. //---------------------------------------------------------------------- // Note that the use of the ISOLATION_AWARE_ENABLED define replaces the // activation context APIs with wrappers that dynamically load the API // pointers from the kernel32 DLL so we don't have to do that ourselves. // Using ISOLATION_AWARE_ENABLED also causes the manifest resource to be put // in slot #2 as expected for DLLs. (See wx/msw/wx.rc) #ifdef ISOLATION_AWARE_ENABLED static ULONG_PTR wxPHPSetActivationContext() { OSVERSIONINFO info; wxZeroMemory(info); info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&info); if (info.dwMajorVersion < 5) return 0; ULONG_PTR cookie = 0; HANDLE h; ACTCTX actctx; TCHAR modulename[MAX_PATH]; GetModuleFileName(wxGetInstance(), modulename, MAX_PATH); wxZeroMemory(actctx); actctx.cbSize = sizeof(actctx); actctx.lpSource = modulename; actctx.lpResourceName = MAKEINTRESOURCE(2); actctx.hModule = wxGetInstance(); actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID; h = CreateActCtx(&actctx); if (h == INVALID_HANDLE_VALUE) { wxLogLastError(wxT("CreateActCtx")); return 0; } if (! ActivateActCtx(h, &cookie)) wxLogLastError(wxT("ActivateActCtx")); return cookie; } static void wxPHPClearActivationContext(ULONG_PTR cookie) { if (! DeactivateActCtx(0, cookie)) wxLogLastError(wxT("DeactivateActCtx")); } #endif //---------------------------------------------------------------------- // This gets run when the DLL is loaded. We just need to save a handle. //---------------------------------------------------------------------- extern "C" BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to DLL module DWORD fdwReason, // reason for calling function LPVOID lpvReserved // reserved ) { // If wxPHP is embedded in another wxWidgets app then // the instance has already been set. if (! wxGetInstance()) wxSetInstance(hinstDLL); return TRUE; } #endif // Prevent expansion of wxLog* macros #undef wxLogError #undef wxLogFatalError #undef wxLogGeneric #undef wxLogMessage #undef wxLogStatus #undef wxLogSysError #undef wxLogVerbose #undef wxLogWarning /** * Global functions table entry used on the module initialization code */ static zend_function_entry php_wxWidgets_functions[] = { PHP_FALIAS(wxExecute, php_wxExecute, NULL) PHP_FALIAS(wxEntry, php_wxEntry, NULL) PHP_FALIAS(wxC2D, php_wxC2D, NULL) PHP_FALIAS(wxLogError, php_wxLogError, NULL) PHP_FALIAS(wxLogFatalError, php_wxLogFatalError, NULL) PHP_FALIAS(wxLogGeneric, php_wxLogGeneric, NULL) PHP_FALIAS(wxLogMessage, php_wxLogMessage, NULL) PHP_FALIAS(wxLogStatus, php_wxLogStatus, NULL) PHP_FALIAS(wxLogSysError, php_wxLogSysError, NULL) PHP_FALIAS(wxLogVerbose, php_wxLogVerbose, NULL) PHP_FALIAS(wxLogWarning, php_wxLogWarning, NULL) /** * Space reserved for the addition to functions table of * autogenerated functions */ <?php print $functions_table ?> PHP_FE_END //Equivalent to { NULL, NULL, NULL, 0, 0 } at time of writing on PHP 5.4 }; /** * Initialize global objects and wxWidgets resources */ PHP_RINIT_FUNCTION(php_wxWidgets) { static int objects_intialized = 0; /** * Space reserved for the initialization of global object * constants, since the php engine doesnt initializes the object * store prior to calling extensions MINIT function. * * Note: * * Predefined fonts, pens brushes, colors and cursos are initilized * by 'wxStockGDI::instance().Get*(item)' functions and it needs * wxInitilize call in order to work (learned this the hard way) */ if(objects_intialized < 1) { wxInitialize(); <?php print $object_constants ?> objects_intialized = 1; } return SUCCESS; } PHP_MINIT_FUNCTION(php_wxWidgets) { #ifdef ISOLATION_AWARE_ENABLED wxPHPSetActivationContext(); #endif /** * Define some version constants. */ REGISTER_STRING_CONSTANT( "WXWIDGETS_EXTENSION_VERSION", (char*) PHP_WXWIDGETS_VERSION, CONST_CS | CONST_PERSISTENT ); REGISTER_STRING_CONSTANT( "WXWIDGETS_LIBRARY_VERSION", (char*) WXWIDGETS_LIBRARY_VERSION, CONST_CS | CONST_PERSISTENT ); zend_class_entry ce; /* Temporary variable used to initialize class entries */ /** * Predefined Initialization of wxApp class */ char PHP_wxApp_name[] = "wxApp"; INIT_CLASS_ENTRY(ce, PHP_wxApp_name, php_wxApp_functions); php_wxApp_entry = zend_register_internal_class(&ce); php_wxApp_entry->create_object = php_wxApp_new; wxPHP_PREPARE_OBJECT_HANDLERS(wxApp) /** * Space reserved for the initialization of autogenerated classes, * class enumerations and global constants */ <?php print $classes ?> return SUCCESS; } /** * UnInitialize wxWidgets resources */ PHP_MSHUTDOWN_FUNCTION(php_wxWidgets) { wxUninitialize(); return SUCCESS; } /** * TODO: Automate the process of updating versions number * Show version information to phpinfo() */ PHP_MINFO_FUNCTION(php_wxWidgets) { php_info_print_table_start(); php_info_print_table_header(2, "wxWidgets", "enabled"); php_info_print_table_row(2, "Extension Version", PHP_WXWIDGETS_VERSION); php_info_print_table_row(2, "Library Version", WXWIDGETS_LIBRARY_VERSION); php_info_print_table_end(); } /** * Declaration of wxWidgets module */ zend_module_entry wxWidgets_module_entry = { STANDARD_MODULE_HEADER, PHP_WXWIDGETS_EXTNAME, php_wxWidgets_functions, /* Functions (module functions) */ PHP_MINIT(php_wxWidgets), /* MINIT (module initialization function) */ PHP_MSHUTDOWN(php_wxWidgets), /* MSHUTDOWN (module shutdown function) */ PHP_RINIT(php_wxWidgets), /* RINIT (request initialization function) */ NULL, /* RSHUTDOWN (request shutdown function) */ PHP_MINFO(php_wxWidgets), /* MINFO (module information function) */ PHP_WXWIDGETS_VERSION, STANDARD_MODULE_PROPERTIES }; /** * Insertion of wxWidgets module to the PHP runtime */ #ifdef COMPILE_DL_WXWIDGETS BEGIN_EXTERN_C() #ifdef ZTS ZEND_TSRMLS_CACHE_DEFINE() #endif ZEND_GET_MODULE(wxWidgets) END_EXTERN_C() #endif
27.693467
189
0.664671
wxphp
546eb21252dda258eb26665bf591b7d2c2b6884e
6,072
cpp
C++
BVH Builder/main2.cpp
FirowMD/Luna-Engine
4011a43df48ca85f6d8f8657709471da02bd8301
[ "MIT" ]
2
2021-07-28T23:08:29.000Z
2021-09-14T19:32:36.000Z
BVH Builder/main2.cpp
FirowMD/Luna-Engine
4011a43df48ca85f6d8f8657709471da02bd8301
[ "MIT" ]
null
null
null
BVH Builder/main2.cpp
FirowMD/Luna-Engine
4011a43df48ca85f6d8f8657709471da02bd8301
[ "MIT" ]
null
null
null
#include "Defines.h" #include "Engine Includes/MainInclude.h" #include "HighLevel/DirectX/HighLevel.h" #include "HighLevel/DirectX/Utlities.h" #include "Engine/Model/Mesh.h" HighLevel gHighLevel; Model mModel; Texture DefaultTexture; Camera *cPlayer; NewMesh<3> mNewMesh; bool _DirectX::FrameFunction() { //ScopedRangeProfiler s0(__FUNCTION__); // Resize event Resize(); { ScopedRangeProfiler s1(L"Clear"); // Bind and clear RTV gContext->OMSetRenderTargets(1, &gRTV, gDSV); float Clear[4] = { .2f, .2f, .2f, 1.f }; // RGBA float Clear0[4] = { 0.f, 0.f, 0.f, 1.f }; // RGBA black gContext->ClearRenderTargetView(gRTV, Clear0); gContext->ClearDepthStencilView(gDSV, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 0.f, 0); // Default is 1 ^^^ } // //shRenderAVC.Bind(); cPlayer->BuildProj(); cPlayer->BuildView(); cPlayer->BuildConstantBuffer(); cPlayer->BindBuffer(Shader::Geometry, 0); // Render //gContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); //vb.BindVertex(); //gContext->Draw(vb.GetNumber(), 0); // End of frame gSwapchain->Present(1, 0); return false; } bool bLookMouse = true; float fSpeed = 37.f, fRotSpeed = 100.f, fSensetivityX = 2.f, fSensetivityY = 3.f; float fDir = 0.f, fPitch = 0.f; void _DirectX::Tick(float fDeltaTime) { const WindowConfig& winCFG = gWindow->GetCFG(); // Update camera float3 f3Move(0.f, 0.f, 0.f); // Movement vector static float2 pLastPos = { 0, 0 }; // Last mouse pos // Camera if( gKeyboard->IsDown(VK_W) ) f3Move.x = +fSpeed * fDeltaTime; // Forward / Backward if( gKeyboard->IsDown(VK_S) ) f3Move.x = -fSpeed * fDeltaTime; if( gKeyboard->IsDown(VK_D) ) f3Move.z = +fSpeed * fDeltaTime; // Strafe if( gKeyboard->IsDown(VK_A) ) f3Move.z = -fSpeed * fDeltaTime; bLookMouse ^= gKeyboard->IsPressed(VK_F2); // Toggle release mouse if( !bLookMouse ) { return; } float dx = 0.f, dy = 0.f; #if USE_GAMEPADS // Use gamepad if we can and it's connected if( gGamepad[0]->IsConnected() ) { // Move around if( !gGamepad[0]->IsDeadZoneL() ) { f3Move.x = gGamepad[0]->LeftY() * fSpeed * fDeltaTime; f3Move.z = gGamepad[0]->LeftX() * fSpeed * fDeltaTime; } // Look around if( !gGamepad[0]->IsDeadZoneR() ) { dx = gGamepad[0]->RightX() * 100.f * fSensetivityX * fDeltaTime; dy = gGamepad[0]->RightY() * 50.f * fSensetivityY * fDeltaTime; fDir += dx; fPitch -= dy; } } //else #endif { // Use mouse bool b = false; if( abs(dx) <= .1 ) { fDir += (float(gMouse->GetX() - winCFG.CurrentWidth * .5f) * fSensetivityX * fDeltaTime); b = true; } if( abs(dy) <= .1 ) { fPitch += (float(gMouse->GetY() - winCFG.CurrentHeight * .5f) * fSensetivityY * fDeltaTime); b = true; //std::cout << winCFG.CurrentHeight2 * .5f << " " << gMouse->GetY() << std::endl; } if( b ) gMouse->SetAt(int(winCFG.CurrentWidth * .5f), int(winCFG.CurrentHeight * .5f)); } if( gKeyboard->IsDown(VK_LEFT) ) fDir -= fRotSpeed * fDeltaTime; // Right / Left if( gKeyboard->IsDown(VK_RIGHT) ) fDir += fRotSpeed * fDeltaTime; // I got used to KSP and other avia/space sims // So i flipped them if( gKeyboard->IsDown(VK_UP) ) fPitch -= fRotSpeed * fDeltaTime; // Look Up / Down if( gKeyboard->IsDown(VK_DOWN) ) fPitch += fRotSpeed * fDeltaTime; // Limit pitch fPitch = std::min(std::max(fPitch, -84.f), 84.f); // Look around cPlayer->TranslateLookAt(f3Move); cPlayer->RotateAbs(DirectX::XMFLOAT3(fPitch, fDir, 0.)); } void _DirectX::Resize() { gHighLevel.DefaultResize(); } void _DirectX::Load() { DefaultTexture.Load("../Textures/TileInverse.png", false, false); Model::SetDefaultTexture(&DefaultTexture); mModel.EnableDefaultTexture(); mModel.LoadModel<Vertex_PNT>("../Models/Cube.obj"); // VertexBuffer vbs[3]; mNewMesh.SetVertexBuffers(&vbs[0]); //mNewMesh.SetIndexBuffer(); // Load shaders cPlayer = new Camera(); CameraConfig C_config; C_config.fAspect = cfg.Width / cfg.Height; C_config.fNear = .1f; C_config.fFar = 1000.f; C_config.FOV = 90.f; C_config.Ortho = false; cPlayer->SetParams(C_config); } void _DirectX::Unload() { mModel.Release(); DefaultTexture.Release(); SAFE_DELETE(cPlayer); } int main() { // Window config WindowConfig winCFG; winCFG.Borderless = false; winCFG.Windowed = true; winCFG.ShowConsole = true; winCFG.Width = 1024; winCFG.Height = 540; winCFG.Title = L"Luna Engine"; winCFG.Icon = L"Engine/Assets/Engine.ico"; // Create window gWindow = gHighLevel.InitWindow(winCFG); // Get input devices gInput = gHighLevel.InitInput(); gKeyboard = gInput->GetKeyboard(); gMouse = gInput->GetMouse(); #if USE_GAMEPADS for( int i = 0; i < NUM_GAMEPAD; i++ ) gGamepad[i] = gInput->GetGamepad(i); #endif // Audio device config AudioDeviceConfig adCFG = { 0 }; // Create audio device gAudioDevice = gHighLevel.InitAudio(adCFG); // DirectX config DirectXConfig dxCFG; dxCFG.BufferCount = 2; dxCFG.Width = winCFG.CurrentWidth; dxCFG.Height = winCFG.CurrentHeight2; dxCFG.m_hwnd = gWindow->GetHWND(); dxCFG.RefreshRate = 60; dxCFG.UseHDR = true; dxCFG.DeferredContext = false; dxCFG.Windowed = winCFG.Windowed; dxCFG.Ansel = USE_ANSEL; // Init DirectX gDirectX = gHighLevel.InitDirectX(dxCFG); // Main Loop gHighLevel.AppLoop(); // //SAFE_DELETE(gHighLevel); SAFE_DELETE(gWindow); SAFE_DELETE(gDirectX); SAFE_DELETE_N(gGamepad, NUM_GAMEPAD); SAFE_DELETE(gInput); SAFE_RELEASE(gAudioDevice); }
26.172414
104
0.610343
FirowMD
546f806fe4d620ca3eb7756b1571ce8cff7beddd
5,871
cpp
C++
target.cpp
marionette-of-u/kp19pp
61a80859774e4c391b9a6e2b2e98387bacb92410
[ "BSD-2-Clause-FreeBSD" ]
4
2015-12-16T05:33:11.000Z
2018-06-06T14:18:31.000Z
target.cpp
marionette-of-u/kp19pp
61a80859774e4c391b9a6e2b2e98387bacb92410
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
target.cpp
marionette-of-u/kp19pp
61a80859774e4c391b9a6e2b2e98387bacb92410
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
#include "target.hpp" namespace kp19pp{ namespace target{ term_type epsilon_functor::operator ()() const{ return 0; } term_type end_of_seq_functor::operator ()() const{ return (std::numeric_limits<int>::max)(); } semantic_type::semantic_type() : action(nullptr), pre_action(nullptr), type(nullptr), argindex_to_symbol_map(nullptr) {} semantic_type::semantic_type(const semantic_type &other) : action(other.action), pre_action(other.pre_action), type(other.type), argindex_to_symbol_map(other.argindex_to_symbol_map) {} semantic_type::semantic_type(semantic_type &&other) : action(std::move(other.action)), pre_action(std::move(other.pre_action)), type(std::move(other.type)), argindex_to_symbol_map(std::move(other.argindex_to_symbol_map)) {} target_type::target_type() : base_type(){} target_type::target_type(const target_type &other) : base_type(other){} target_type::target_type(target_type &&other) : base_type(other){} bool target_type::make_parsing_table( const scanner::scanner_type &scanner, const commandline_options_type &commandline_options ){ expression_type expression_start_prime; expression_start_prime.lhs = -1; { expression_type::rhs_type rhs_seq; rhs_seq.push_back(-2); expression_start_prime.rhs.insert(rhs_seq); } add_expression(expression_start_prime); for( auto iter = scanner.nonterminal_symbol_map.begin(), end = scanner.nonterminal_symbol_map.end(); iter != end; ++iter ){ auto &lhs(iter->first); auto &data(iter->second); expression_type e; e.lhs = lhs.value.term; for( auto rhs_set_iter = data.rhs.begin(), rhs_set_end = data.rhs.end(); rhs_set_iter != rhs_set_end; ++rhs_set_iter ){ auto &rhs(*rhs_set_iter); expression_type::rhs_type rhs_seq; rhs_seq.resize(rhs.size()); std::size_t i = 0; for(auto rhs_iter = rhs.begin(), rhs_end = rhs.end(); rhs_iter != rhs_end; ++rhs_iter, ++i){ auto &rhs_elem(*rhs_iter); rhs_seq[i] = rhs_elem.first.value.term; } if(!rhs.tag.value.is_epsilon()){ rhs_seq.set_attribute(0, rhs.tag.term); } rhs_seq.semantic.type = &data.type.value; rhs_seq.semantic.action = &rhs.semantic_action.value; rhs_seq.semantic.argindex_to_symbol_map = &rhs.argindex_to_symbol_map; e.rhs.insert(rhs_seq); } add_expression(e); } add_terminal_symbol(epsilon_functor()(), symbol_data_type()); add_terminal_symbol(end_of_seq_functor()(), symbol_data_type()); for( auto iter = scanner.terminal_symbol_map.begin(), end = scanner.terminal_symbol_map.end(); iter != end; ++iter ){ auto &data(iter->second); symbol_data_type symbol_data; symbol_data.linkdir = data.linkdir; symbol_data.priority = data.priority; add_terminal_symbol(iter->first.value.term, symbol_data); } make_parsing_table_options_type options; options.avoid_conflict = true; options.disambiguating = true; options.put_time = commandline_options.time(); options.put_alltime = commandline_options.alltime(); options.put_log = commandline_options.log(); bool result = base_type::make_parsing_table( expression_start_prime, (std::numeric_limits<term_type>::max)() - 1, options, [](const expression_set_type&, term_type term) -> bool{ return term < 0; }, [&](term_type term) -> std::string{ if(term == expression_start_prime.lhs){ return "S'"; }else if(term == end_of_seq_functor()()){ return "$"; }else{ auto find_ret = scanner.term_to_token_map.find(term); return find_ret->second.value.to_string(); } } ); if(!result){ return false; } std::ofstream ofile(commandline_options.ofile_path()); if(!ofile){ std::cerr << "ファイルの生成に失敗しました.\n"; return false; } std::map< commandline_options_type::language_enum, void(target_type::*)(std::ostream&, const commandline_options_type&, const scanner::scanner_type&) > function_map; function_map[commandline_options_type::language_cpp] = &target_type::generate_cpp; function_map[commandline_options_type::language_haskell] = &target_type::generate_haskell; function_map[commandline_options_type::language_vimscript] = &target_type::generate_vimscript; auto find_result = function_map.find(commandline_options.language()); if(find_result != function_map.end()){ (this->*(find_result->second))(ofile, commandline_options, scanner); } return true; } } }
43.488889
134
0.539431
marionette-of-u
5471c23e8b00e040c3e9d1455c0f115e7c5311ed
1,863
cpp
C++
tests/message-mgmt/mssg.cpp
sahilg-xilinx/XRT
e0825c342c73e11c585d8ac15fc57486f1d8aa3e
[ "Apache-2.0" ]
359
2018-10-05T03:05:08.000Z
2022-03-31T06:28:16.000Z
tests/message-mgmt/mssg.cpp
sahilg-xilinx/XRT
e0825c342c73e11c585d8ac15fc57486f1d8aa3e
[ "Apache-2.0" ]
5,832
2018-10-02T22:43:29.000Z
2022-03-31T22:28:05.000Z
tests/message-mgmt/mssg.cpp
sahilg-xilinx/XRT
e0825c342c73e11c585d8ac15fc57486f1d8aa3e
[ "Apache-2.0" ]
442
2018-10-02T23:06:29.000Z
2022-03-21T08:34:44.000Z
#include <iostream> #include <string> #include <getopt.h> #include <thread> // host_src includes #include "xclhal2.h" #include "xclbin.h" void foo(int num, xclDeviceHandle handle) { xclLogMsg(handle, XRT_NOTICE, "XRT", "(5) Running Thread number %d", num); } int main(int argc, char** argv) { xclDeviceInfo2 deviceInfo; unsigned devIndex = 0; char *bitFile = NULL; xclDeviceHandle handle; bool debug_flag = false; int c; while ((c = getopt(argc, argv, "k:d:v")) != -1) { switch (c) { case 'k': bitFile = optarg; break; case 'd': devIndex = std::atoi(optarg); break; case 'v': debug_flag = true; break; default: exit(EXIT_FAILURE); } } handle = xclOpen(devIndex, "", XCL_INFO); if(!handle) xclLogMsg(handle, XRT_EMERGENCY, "XRT", "(0) Unable to open device %d", devIndex); xclLogMsg(handle, XRT_INFO, "XRT", "(6) %s was passed in as an argument", bitFile); if(debug_flag) xclLogMsg(handle, XRT_DEBUG, "XRT","(7) Debug flag was set"); if(xclGetDeviceInfo2(handle, &deviceInfo)) xclLogMsg(handle, XRT_ALERT,"XRT", "(1) Unable to obtain device information"); const xclBin *blob =(const xclBin *) new char [1]; if(xclLoadXclBin(handle, blob)) xclLogMsg(handle, XRT_CRITICAL, "XRT", "(2) Unable to load xclbin"); std::cout << "~~~Multi threading~~~" << std::endl; std:: thread t1(foo, 1, handle); std::thread t2(foo, 2, handle); t1.join(); t2.join(); std::cout << "~~~~~~~~~~~~~~~~~~~~~" << std:: endl; std::cout << "Other messages: \n"; xclLogMsg(handle, XRT_ERROR,"XRT", "(3) Display when verbosity 3"); xclLogMsg(handle, XRT_WARNING, "XRT", "(4) Display when verbosity 2"); return 0; }
27.80597
90
0.577026
sahilg-xilinx
54763fcc90137468e020fa4b6bffd32a3e614e70
1,102
cc
C++
src/workers/close.cc
bengotow/better-sqlite3
2606eef344cdf22f23ec8bd403f4aeb305f644cb
[ "MIT" ]
2
2017-10-10T06:24:35.000Z
2021-06-15T15:01:39.000Z
src/workers/close.cc
bengotow/better-sqlite3
2606eef344cdf22f23ec8bd403f4aeb305f644cb
[ "MIT" ]
null
null
null
src/workers/close.cc
bengotow/better-sqlite3
2606eef344cdf22f23ec8bd403f4aeb305f644cb
[ "MIT" ]
2
2017-03-15T06:34:50.000Z
2017-05-05T02:47:03.000Z
#include <sqlite3.h> #include <nan.h> #include "close.h" #include "../objects/database/database.h" #include "../util/macros.h" CloseWorker::CloseWorker(Database* db, bool still_connecting) : Nan::AsyncWorker(NULL), db(db), still_connecting(still_connecting) {} void CloseWorker::Execute() { if (!still_connecting) { db->CloseChildHandles(); if (db->CloseHandles() != SQLITE_OK) { SetErrorMessage("Failed to successfully close the database connection."); } } } void CloseWorker::HandleOKCallback() { Nan::HandleScope scope; v8::Local<v8::Object> database = db->handle(); if (--db->workers == 0) {db->Unref();} v8::Local<v8::Value> args[2] = { NEW_INTERNAL_STRING_FAST("close"), Nan::Null() }; EMIT_EVENT(database, 2, args); } void CloseWorker::HandleErrorCallback() { Nan::HandleScope scope; v8::Local<v8::Object> database = db->handle(); if (--db->workers == 0) {db->Unref();} CONCAT2(message, "SQLite: ", ErrorMessage()); v8::Local<v8::Value> args[2] = { NEW_INTERNAL_STRING_FAST("close"), Nan::Error(message.c_str()) }; EMIT_EVENT(database, 2, args); }
24.488889
87
0.674229
bengotow
54777c1b03848acdd180ab1c2bf048f45a0add81
1,050
cpp
C++
test/test_tbsr.cpp
watagashi0619/TFHE
392c06812edd3ccfa56099fbacb8428fbc1fc277
[ "MIT" ]
3
2021-08-11T05:36:05.000Z
2021-12-29T06:26:30.000Z
test/test_tbsr.cpp
watagashi0619/TFHE
392c06812edd3ccfa56099fbacb8428fbc1fc277
[ "MIT" ]
1
2021-09-13T12:53:43.000Z
2021-09-19T04:12:41.000Z
test/test_tbsr.cpp
watagashi0619/TFHE
392c06812edd3ccfa56099fbacb8428fbc1fc277
[ "MIT" ]
null
null
null
#include <array> #include <cassert> #include <iostream> #include <random> #include "key.hpp" #include "params.hpp" #include "tbsr.hpp" #include "tlwe.hpp" #include "trgsw.hpp" #include "trlwe.hpp" #include "util.hpp" using namespace TFHE; void test_tbsr_add() { // secret key secret_key skey; // generate integer a and b std::uniform_int_distribution<int> dist(0, (1 << (params::tbsr_width - 1))); int a = dist(rng); int b = dist(rng); std::cout << a << " + " << b << " = " << std::flush; // encrypt integer a,b to trgsw_set trgsw_set_a,trgsw_set_b std::array<trgsw, params::tbsr_width> trgsw_set_a = tbsr::gen_trgsw_set(skey, a); std::array<trgsw, params::tbsr_width> trgsw_set_b = tbsr::gen_trgsw_set(skey, b); // add tbsr res = tbsr::add(skey, trgsw_set_a, trgsw_set_b); // decrypt res int ans = res.decrypt_tbsr(skey); // answer std::cout << ans << std::endl; // judgement assert(a + b == ans); std::cout << "pass" << std::endl; } int main() { test_tbsr_add(); }
26.25
85
0.625714
watagashi0619
547a9a9ccd2100f6f258cd586fc509b27f1a18cc
3,861
cpp
C++
PROJECT_KART/minigame1.cpp
keithmulqueen/Project-KART
6e170ec754b728581bbfcad8c2329ebf26da83ac
[ "Unlicense" ]
null
null
null
PROJECT_KART/minigame1.cpp
keithmulqueen/Project-KART
6e170ec754b728581bbfcad8c2329ebf26da83ac
[ "Unlicense" ]
null
null
null
PROJECT_KART/minigame1.cpp
keithmulqueen/Project-KART
6e170ec754b728581bbfcad8c2329ebf26da83ac
[ "Unlicense" ]
null
null
null
#include "minigame1.h" #include "ui_minigame1.h" MiniGame1::MiniGame1(QWidget *parent) : QDialog(parent), ui(new Ui::MiniGame1) { ui->setupUi(this); buttons.push_back(ui->pushButton); buttons.push_back(ui->pushButton_2); buttons.push_back(ui->pushButton_3); buttons.push_back(ui->pushButton_4); buttons.push_back(ui->pushButton_5); buttons.push_back(ui->pushButton_6); buttons.push_back(ui->pushButton_7); buttons.push_back(ui->pushButton_8); buttons.push_back(ui->pushButton_9); buttons.push_back(ui->pushButton_10); buttons.push_back(ui->pushButton_11); buttons.push_back(ui->pushButton_12); buttons.push_back(ui->pushButton_13); buttons.push_back(ui->pushButton_14); buttons.push_back(ui->pushButton_15); buttons.push_back(ui->pushButton_16); done = false; QMessageBox::information(NULL, "Instructions", "Use the scroll bars to move yourself to the Exit. You are allowed to teleport between the boxes, but try to avoid them."); } MiniGame1::~MiniGame1() { delete ui; } void MiniGame1::on_horizontalScrollBar_2_rangeChanged(int min, int max) { } void MiniGame1::on_horizontalScroll_valueChanged(int value) { } void MiniGame1::on_horizontalScroll_sliderMoved(int position) { if(!checkAllColisions(position,ui->me->y())) { QRect anew = ui->me->geometry(); anew.moveTo(position,anew.y()); ui->me->setGeometry(anew); if(checkFinish()) { QMessageBox::information(NULL, "Congratulations!", "You successfully finished the mini game. you may proceed now."); done = true; this->close(); } } } void MiniGame1::on_verticalScroll_sliderMoved(int position) { if(!checkAllColisions(ui->me->x(),position)) { QRect anew = ui->me->geometry(); anew.moveTo(anew.x(),position); ui->me->setGeometry(anew); if(checkFinish()) { QMessageBox::information(NULL, "Congratulations!", "You successfully finished the mini game. you may proceed now."); done = true; this->close(); } } } bool MiniGame1::checkCollision(int r1x1,int r1x2,int r1y1,int r1y2,int r2x1,int r2x2,int r2y1,int r2y2) { // box1_x2 > box2_x1 and box1_x1 < box2_x2 and box1_y2 > box2_y1 and box1_y1 < box2_y2 if (r1x2 > r2x1 && r1x1 < r2x2 && r1y2 > r2y1 && r1y1 < r2y2) // r1x1 < r2x2 && r1x2 > r2x1 && r1y1 < r2y2 && r1y2 > r2y1) return true; else return false; } bool MiniGame1::checkAllColisions(int intentionX,int intentionY){ bool output = false; int r1x1,r1x2,r1y1,r1y2,r2x1,r2x2,r2y1,r2y2; r1x1 = intentionX; r1x2 = ui->me->geometry().width() + intentionX; r1y1 = intentionY; r1y2 = ui->me->geometry().height() + intentionY; for(int i=0;i < buttons.size();i++) { r2x1 = buttons[i]->geometry().x(); r2x2 = buttons[i]->geometry().x() + buttons[i]->geometry().width(); r2y1 = buttons[i]->geometry().y(); r2y2 = buttons[i]->geometry().y() + buttons[i]->geometry().height(); output = output|checkCollision(r1x1,r1x2,r1y1,r1y2,r2x1,r2x2,r2y1,r2y2); } return output; } bool MiniGame1::checkFinish(){ int r1x1,r1x2,r1y1,r1y2,r2x1,r2x2,r2y1,r2y2; r1x1 = ui->me->geometry().x() ; r1x2 = ui->me->geometry().x() + ui->me->geometry().width() ; r1y1 = ui->me->geometry().y() ; r1y2 = ui->me->geometry().y() + ui->me->geometry().height(); r2x1 = ui->exit->geometry().x(); r2x2 = ui->exit->geometry().x() + ui->exit->geometry().width(); r2y1 = ui->exit->geometry().y(); r2y2 = ui->exit->geometry().y() + ui->exit->geometry().height(); if(checkCollision(r1x1,r1x2,r1y1,r1y2,r2x1,r2x2,r2y1,r2y2)) return true; else return false; }
32.445378
174
0.62704
keithmulqueen
5486638402411922cc15fe751c923fa95862153a
2,876
cpp
C++
software/tests/pid_learner.cpp
Mateck/Eirbot1A_2018
730ddb85fc40b9b8f5eef05142ad609fffb004ce
[ "MIT" ]
3
2018-01-26T18:08:18.000Z
2018-03-03T19:08:37.000Z
software/tests/pid_learner.cpp
Mateck/Eirbot1A_2018
730ddb85fc40b9b8f5eef05142ad609fffb004ce
[ "MIT" ]
null
null
null
software/tests/pid_learner.cpp
Mateck/Eirbot1A_2018
730ddb85fc40b9b8f5eef05142ad609fffb004ce
[ "MIT" ]
1
2018-02-08T16:44:44.000Z
2018-02-08T16:44:44.000Z
// DO NOT USE // MOTORS DIRECTION BLINK WHEN ROBOT IS STOPPED0P #include "mbed.h" #include "errors.h" #include "robot1.h" #include "qei.h" #include "pid.h" #include "motors.h" int err = 0; Timer tim; // Serial PC Serial pc(USBTX, USBRX); // Left Qei TIM_Encoder_InitTypeDef* p_encoder_left = new TIM_Encoder_InitTypeDef; TIM_HandleTypeDef* p_htim_left = new TIM_HandleTypeDef; TIM_TypeDef* p_TIMx_left = ENCODER_TIM_LEFT; Qei qei_left(p_encoder_left, p_htim_left, p_TIMx_left, &err); //Right Qei TIM_Encoder_InitTypeDef* p_encoder_right = new TIM_Encoder_InitTypeDef; TIM_HandleTypeDef* p_htim_right = new TIM_HandleTypeDef; TIM_TypeDef* p_TIMx_right = ENCODER_TIM_RIGHT; Qei qei_right(p_encoder_right, p_htim_right, p_TIMx_right, &err); // Left motor speed PID Timer* p_timer_pid_left = new Timer; Pid pid_left(PID_LEFT_KP, PID_LEFT_KI, PID_LEFT_KD, p_timer_pid_left); // Right motor speed PID Timer* p_timer_pid_right = new Timer; Pid pid_right(PID_RIGHT_KP, PID_RIGHT_KI, PID_RIGHT_KD, p_timer_pid_right); // Left Motor PwmOut* p_pwm_left = new PwmOut(PIN_PWM_LEFT); DigitalOut* p_direction_0_left = new DigitalOut(PIN_DIR_LEFT1); DigitalOut* p_direction_1_left = new DigitalOut(PIN_DIR_LEFT2); Ticker* p_ticker_motor_left = new Ticker; Motor motor_left(p_pwm_left, p_direction_0_left, p_direction_1_left, &qei_left, &pid_left, p_ticker_motor_left); // Right Motor PwmOut* p_pwm_right = new PwmOut(PIN_PWM_RIGHT); DigitalOut* p_direction_0_right = new DigitalOut(PIN_DIR_RIGHT1); DigitalOut* p_direction_1_right = new DigitalOut(PIN_DIR_RIGHT2); Ticker* p_ticker_motor_right = new Ticker; Motor motor_right(p_pwm_right, p_direction_0_right, p_direction_1_right, &qei_right, &pid_right, p_ticker_motor_right); float min(float a, float b) { return (a<b ? a:b); } void LearnKp() { float speed = 0; float kpl = 1.0f/4096.0f; float kpr = 1.0f/4096.0f; pc.printf("SPEED : %f\t\tkpl : %f\t\t kpr : %f\n\r", speed, kpl, kpr); float speedl; float speedr; float rl; float rr; while (speed < 8192) { speed += 256; motor_left.SetSpeed(speed); motor_right.SetSpeed(speed); wait(0.5); speedl = motor_left.GetSpeed(); speedr = motor_right.GetSpeed(); rl = speed/speedl; rr = speed/speedr; while ((rl<0.93 || rl>0.97) || (rr<0.93 || rr>0.97)) { kpl *= min(rl, 1.3); kpr *= min(rr, 1.3); pid_left.SetPid(kpl, 0.0f, 0.0f); pid_right.SetPid(kpr, 0.0f, 0.0f); wait(0.5); pc.printf("SPEED %f\tDUTYL %f\t DUTYR %f\tkpl %f\tkpr %f\r", speed, p_pwm_left->read(), p_pwm_right->read(), kpl, kpr); } pc.printf("\n\rSPEED : %f\t\tkpl : %f\t\t kpr : %f\n\r", speed, kpl, kpr); } pc.printf("FINALS : kpl : %f\t\t kpr : %f\n\r", kpl, kpr); } int main() { pc.printf("\n\n\rStarting 2 : error %d\n\r", err); wait(1); LearnKp(); }
30.273684
76
0.695063
Mateck
54866b75e625593f783f66a1a8d3e1cfa136219e
1,487
cpp
C++
oadrtest/oadrtest/helper/HttpDelegate.cpp
AnalyticsFire/OpenADR-VEN-Library
621e410370c3b3b91a5973d1fc19094278eeff75
[ "Apache-2.0" ]
null
null
null
oadrtest/oadrtest/helper/HttpDelegate.cpp
AnalyticsFire/OpenADR-VEN-Library
621e410370c3b3b91a5973d1fc19094278eeff75
[ "Apache-2.0" ]
3
2021-01-20T13:02:54.000Z
2021-02-19T14:05:34.000Z
oadrtest/oadrtest/helper/HttpDelegate.cpp
AnalyticsFire/OpenADR-VEN-Library
621e410370c3b3b91a5973d1fc19094278eeff75
[ "Apache-2.0" ]
null
null
null
/* * HttpDelegate.cpp * * Created on: May 20, 2021 * Author: Michal Kowalczyk */ #include "HttpDelegate.h" HttpDelegate::HttpDelegate(IHttp &http) : m_http(http) { } bool HttpDelegate::post(std::string url, std::string content) { return m_http.post(url, content); } void HttpDelegate::setParameters(std::string clientCertificatePath, std::string clientPrivateKeyPath, std::string certificateAuthorityBundlePath, bool verifyCertificate, std::string sslCipherList, long sslVersion) { return m_http.setParameters(clientCertificatePath, clientPrivateKeyPath, certificateAuthorityBundlePath, verifyCertificate, sslCipherList, sslVersion); } std::string &HttpDelegate::getRequestBody() { return m_http.getRequestBody(); } std::string &HttpDelegate::getResponseBody() { return m_http.getResponseBody(); } std::string &HttpDelegate::getResponseCode() { return m_http.getResponseCode(); } std::string &HttpDelegate::getResponseMessage() { return m_http.getResponseMessage(); } time_t HttpDelegate::getResponseTime() { return m_http.getResponseTime(); } std::string &HttpDelegate::getServerDate() { return m_http.getServerDate(); } void HttpDelegate::setTimeouts(long connectTimeout, long requestTimeout) { m_http.setTimeouts(connectTimeout, requestTimeout); }
21.550725
72
0.66846
AnalyticsFire
5487315f43d40a1a0b383121ec90a0f3b1968e1a
3,673
cpp
C++
Morphs/Importers/CoreUtils/Shared/CanvasTex/cpp/Source/Android-Mac/TextureCompression.cpp
bghgary/BabylonPolymorph
32ff708abb0d1c0b7f613b18ac7803be95f0cb31
[ "MIT" ]
null
null
null
Morphs/Importers/CoreUtils/Shared/CanvasTex/cpp/Source/Android-Mac/TextureCompression.cpp
bghgary/BabylonPolymorph
32ff708abb0d1c0b7f613b18ac7803be95f0cb31
[ "MIT" ]
null
null
null
Morphs/Importers/CoreUtils/Shared/CanvasTex/cpp/Source/Android-Mac/TextureCompression.cpp
bghgary/BabylonPolymorph
32ff708abb0d1c0b7f613b18ac7803be95f0cb31
[ "MIT" ]
null
null
null
// // Copyright (C) Microsoft. All rights reserved. // #include "TextureCompression.h" #include "ScratchImage.h" #include <CanvasTex/Image.h> #include <gli/core/bc.hpp> #include <gli/convert.hpp> namespace { //--------------------------------------------------------------------------------------------------------------------- // TODO: Can we infer the BlockType from the DecompressFunction (which takes a BlockType* as argument)? template <class BlockType, typename DecompressFunction> gli::texture2d DecompressBcxUnorm(const CanvasTex::ConstImage& cImage, const gli::extent2d& blockExtent, DecompressFunction decompressFunction) { auto impl = cImage.CGetImplementation(); gli::texture2d outputTexture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::extent2d(cImage.GetWidth(), cImage.GetHeight()), 1); // TextureMetadataImplementation doesn't have miplevels? const BlockType* sourceDataAsBlock = reinterpret_cast<const BlockType*>(cImage.GetPixels()); gli::extent2d TexelCoord; gli::extent2d BlockCoord; gli::extent2d LevelExtent(impl.width, impl.height); gli::extent2d LevelExtentInBlocks = glm::max(gli::extent2d(1, 1), LevelExtent / blockExtent); for(BlockCoord.y = 0, TexelCoord.y = 0; BlockCoord.y < LevelExtentInBlocks.y; ++BlockCoord.y, TexelCoord.y += blockExtent.y) { for(BlockCoord.x = 0, TexelCoord.x = 0; BlockCoord.x < LevelExtentInBlocks.x; ++BlockCoord.x, TexelCoord.x += blockExtent.x) { const BlockType *block = sourceDataAsBlock + (BlockCoord.y * LevelExtentInBlocks.x + BlockCoord.x); const gli::detail::texel_block4x4 DecompressedBlock = decompressFunction(*block); gli::extent2d DecompressedBlockCoord; for(DecompressedBlockCoord.y = 0; DecompressedBlockCoord.y < glm::min(4, LevelExtent.y); ++DecompressedBlockCoord.y) { for(DecompressedBlockCoord.x = 0; DecompressedBlockCoord.x < glm::min(4, LevelExtent.x); ++DecompressedBlockCoord.x) { outputTexture.store(TexelCoord + DecompressedBlockCoord, 0, glm::u8vec4(glm::round(DecompressedBlock.Texel[DecompressedBlockCoord.y][DecompressedBlockCoord.x] * 255.0f))); } } } } return outputTexture; } } // namespace namespace CanvasTex { //--------------------------------------------------------------------------------------------------------------------- gli::texture2d DecompressBc1Unorm(const ConstImage& cImage) { gli::extent3d tempExtent = gli::block_extent(gli::FORMAT_RGBA_DXT1_UNORM_BLOCK8); gli::extent2d blockExtent(tempExtent.x, tempExtent.y); return DecompressBcxUnorm<gli::detail::bc1_block>(cImage, blockExtent, gli::detail::decompress_bc1_block); } //--------------------------------------------------------------------------------------------------------------------- gli::texture2d DecompressBc2Unorm(const ConstImage& cImage) { gli::extent3d tempExtent = gli::block_extent(gli::FORMAT_RGBA_DXT3_UNORM_BLOCK16); gli::extent2d blockExtent(tempExtent.x, tempExtent.y); return DecompressBcxUnorm<gli::detail::bc2_block>(cImage, blockExtent, gli::detail::decompress_bc2_block); } //--------------------------------------------------------------------------------------------------------------------- gli::texture2d DecompressBc3Unorm(const ConstImage& cImage) { gli::extent3d tempExtent = gli::block_extent(gli::FORMAT_RGBA_DXT5_UNORM_BLOCK16); gli::extent2d blockExtent(tempExtent.x, tempExtent.y); return DecompressBcxUnorm<gli::detail::bc3_block>(cImage, blockExtent, gli::detail::decompress_bc3_block); } } // namespace CanvasTex
42.709302
191
0.630003
bghgary
548792b7132622efbd8a29a0c76bfecb8a71f82b
820
hpp
C++
src/test/C/GaussianDerivates/GaussianDerivatesIncludes.hpp
dikujepsen/OpenTran
af9654fcf55e394e7bece38e59bbdc3dd343f092
[ "MIT" ]
1
2015-02-09T12:56:07.000Z
2015-02-09T12:56:07.000Z
v3.0/test/C/old_version_of_same_code/GaussianDerivates/GaussianDerivatesIncludes.hpp
dikujepsen/OpenTran
af9654fcf55e394e7bece38e59bbdc3dd343f092
[ "MIT" ]
null
null
null
v3.0/test/C/old_version_of_same_code/GaussianDerivates/GaussianDerivatesIncludes.hpp
dikujepsen/OpenTran
af9654fcf55e394e7bece38e59bbdc3dd343f092
[ "MIT" ]
null
null
null
float He(const int n, const float x) { float v; switch(n) { case 0: v = 1; break; case 1: v = x; break; case 2: v = x*x-1; break; case 3: v = pow(x,3)-3*x; break; case 4: v = pow(x,4)-6*x*x+3; break; case 5: v = pow(x,5)-10*pow(x,3)+15*x; break; default: ; } return v; } float DaKs(int da[3], float xmy[3], float r, float ks) { float z[3]; float sum_da = 0.0; for (int k = 0; k < 3; k++) { z[k] = sqrt(2.0f)/r*xmy[k]; sum_da += da[k]; } float res; res = pow(-sqrt(2.0f)/r, sum_da)*He(da[0],z[0])*He(da[1],z[1])*He(da[2],z[2])*ks; return res; } float gamma(float xmy[3], float r2, float sw2) { float dot1 = 0.0; for (int k = 0; k < 3; k++) { dot1 += xmy[k] * xmy[k]; } return 1.0f/sw2*exp(dot1/r2); }
15.185185
83
0.482927
dikujepsen