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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4125f00274076c92bf3ee475c0ab613fc31398b3 | 716 | cpp | C++ | uva/12100.cpp | cosmicray001/Online_judge_Solutions- | 5dc6f90d3848eb192e6edea8e8c731f41a1761dd | [
"MIT"
] | 3 | 2018-01-08T02:52:51.000Z | 2021-03-03T01:08:44.000Z | uva/12100.cpp | cosmicray001/Online_judge_Solutions- | 5dc6f90d3848eb192e6edea8e8c731f41a1761dd | [
"MIT"
] | null | null | null | uva/12100.cpp | cosmicray001/Online_judge_Solutions- | 5dc6f90d3848eb192e6edea8e8c731f41a1761dd | [
"MIT"
] | 1 | 2020-08-13T18:07:35.000Z | 2020-08-13T18:07:35.000Z | #include <bits/stdc++.h>
using namespace std;
int main(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int t, n, p, a;
for(scanf("%d", &t); t--; ){
priority_queue<int> pq;
queue<pair<int, int> > q;
scanf("%d %d", &n, &p);
for(int i = 0; i < n; i++){
scanf("%d", &a);
pq.push(a);
q.push(make_pair(a, i));
}
int co = 0;
while(true){
pair<int, int> ab = q.front();
a = pq.top();
if(a == ab.first){
co++;
if(ab.second == p) break;
else{
pq.pop();
q.pop();
}
}
else{
q.pop();
q.push(ab);
}
}
printf("%d\n", co);
}
return 0;
}
| 19.351351 | 37 | 0.417598 | cosmicray001 |
4129cff2db6483d1505edbdba302e552114b9dd1 | 8,775 | cpp | C++ | src/libamp_common/buckets/bucket_type_hash.cpp | AmpScm/AmpScm | a7cc2010a6d7d59c5b26f88154b38c6c8775d9d8 | [
"Apache-2.0"
] | null | null | null | src/libamp_common/buckets/bucket_type_hash.cpp | AmpScm/AmpScm | a7cc2010a6d7d59c5b26f88154b38c6c8775d9d8 | [
"Apache-2.0"
] | null | null | null | src/libamp_common/buckets/bucket_type_hash.cpp | AmpScm/AmpScm | a7cc2010a6d7d59c5b26f88154b38c6c8775d9d8 | [
"Apache-2.0"
] | 1 | 2022-02-01T13:05:25.000Z | 2022-02-01T13:05:25.000Z | #ifdef _WIN32
#include <Windows.h>
#include <bcrypt.h>
#else
// TODO: Add OPENSSL variant
#endif
#include <zlib.h>
#include "amp_buckets.hpp"
using namespace amp;
static amp::amp_bucket::amp_bucket_type hash_bucket_type("amp.hash");
amp_hash_result_t*
amp_hash_result_create(
amp_hash_algorithm_t algorithm,
amp_pool_t* result_pool)
{
size_t bytes;
switch (algorithm)
{
case amp_hash_algorithm_md5:
bytes = 16;
break;
case amp_hash_algorithm_sha1:
bytes = 20;
break;
case amp_hash_algorithm_sha256:
bytes = 32;
break;
case amp_hash_algorithm_adler32:
case amp_hash_algorithm_crc32:
bytes = (32 / 8);
break;
default:
AMP_ASSERT(algorithm && "is unsupported");
bytes = 64;
break;
}
amp_hash_result_t* res = (amp_hash_result_t*)amp_pcalloc(sizeof(amp_hash_result_t) + bytes, result_pool);
res->hash_algorithm = algorithm;
res->hash_bytes = bytes;
return res;
}
amp_bucket_hash::amp_bucket_hash(
amp_bucket_t* wrap_bucket,
amp_hash_result_t* fill_result,
const amp_hash_result_t* expect_result,
amp_allocator_t* allocator)
: amp_bucket(&hash_bucket_type, allocator)
{
AMP_ASSERT(wrap_bucket && (!fill_result ^ !expect_result)
&& (!fill_result || fill_result->hash_bytes >= 4)
&& (!expect_result || expect_result->hash_bytes >= 4)
);
wrapped = wrap_bucket;
algorithm = fill_result ? fill_result->hash_algorithm : expected_result->hash_algorithm;
new_result = fill_result;
expected_result = expect_result ? (amp_hash_result_t*)amp_allocator_pmemdup(expected_result, sizeof(*expected_result), allocator) : nullptr;
if (new_result)
memset(new_result->bytes, 0, new_result->hash_bytes);
p1 = p2 = p3 = nullptr;
hashed_bytes = 0;
setupHashing();
done = false;
}
void
amp_bucket_hash::destroy(amp_pool_t* scratch_pool)
{
finishHashing(false);
if (expected_result)
(*allocator)->free(expected_result);
(*wrapped)->destroy(scratch_pool);
amp_bucket::destroy(scratch_pool);
}
void amp_bucket_hash::setupHashing()
{
hashed_bytes = 0;
if (algorithm == amp_hash_algorithm_adler32 || algorithm == amp_hash_algorithm_crc32 || algorithm == amp_hash_algorithm_none)
{
p3 = amp_allocator_calloc<uLong>(allocator);
return;
}
#ifdef _WIN32
BCRYPT_ALG_HANDLE hAlg;
const wchar_t* alg;
switch (this->algorithm)
{
case amp_hash_algorithm_md5:
alg = BCRYPT_MD5_ALGORITHM;
break;
case amp_hash_algorithm_sha1:
alg = BCRYPT_SHA1_ALGORITHM;
break;
case amp_hash_algorithm_sha256:
alg = BCRYPT_SHA256_ALGORITHM;
break;
default:
AMP_ASSERT(0 && "bad algorithm value");
this->algorithm = amp_hash_algorithm_none;
return;
}
long st = BCryptOpenAlgorithmProvider(&hAlg, alg, nullptr, 0);
if (st < 0)
{
this->algorithm = amp_hash_algorithm_none;
return; // Failed
}
p1 = hAlg;
DWORD objectLength;
ULONG cbDataSet;
if (BCryptGetProperty(
hAlg,
BCRYPT_OBJECT_LENGTH,
(PBYTE)&objectLength,
sizeof(objectLength),
&cbDataSet,
0) < 0)
{
this->algorithm = amp_hash_algorithm_none;
return; // Failed
}
p3sz = objectLength;
p3 = (*allocator)->alloc(p3sz);
memset(p3, 0, p3sz);
if (BCryptCreateHash(hAlg, &p2, (PUCHAR)p3, p3sz, nullptr, 0, 0) < 0)
{
this->algorithm = amp_hash_algorithm_none;
return; // Failed
}
#endif
}
amp_err_t*
amp_bucket_hash::finishHashing(bool useResult)
{
if (algorithm == amp_hash_algorithm_none)
return amp_err_create(AMP_EGENERAL, nullptr, "Unable to setup hashing");
if (useResult && new_result)
new_result->original_size = hashed_bytes;
if (algorithm == amp_hash_algorithm_adler32 || algorithm == amp_hash_algorithm_crc32)
{
if (useResult)
{
uLong result = *reinterpret_cast<uLong*>(p3);
int r;
unsigned char* pResult = new_result ? new_result->bytes : (unsigned char*)&r;
pResult[0] = (result >> 24) & 0xFF;
pResult[1] = (result >> 16) & 0xFF;
pResult[2] = (result >> 8) & 0xFF;
pResult[3] = (result >> 0) & 0xFF;
if (expected_result && memcmp(expected_result->bytes, pResult, 4))
return amp_err_create(AMP_EGENERAL, nullptr, "Checksum mismatch");
}
if (p3)
{
(*allocator)->free(p3);
p3 = nullptr;
}
return AMP_NO_ERROR;
}
#ifdef _WIN32
if (useResult)
{
unsigned char dummyBuf[64];
size_t sz = new_result ? new_result->hash_bytes : expected_result->hash_bytes;
unsigned char* pResult = new_result ? new_result->bytes : dummyBuf;
AMP_ASSERT(sizeof(dummyBuf) >= sz);
if (BCryptFinishHash(p2, pResult, new_result ? new_result->hash_bytes : expected_result->hash_bytes, 0) < 0)
return amp_err_create(AMP_EGENERAL, nullptr, "Unable to finish hashing");
if (expected_result && memcmp(expected_result->bytes, pResult, sz))
return amp_err_create(AMP_EGENERAL, nullptr, "Checksum mismatch");
}
if (p2)
{
BCryptDestroyHash(p2);
p2 = nullptr;
}
if (p1)
{
BCryptCloseAlgorithmProvider(p1, 0);
p1 = nullptr;
}
#endif
if (p3)
{
(*allocator)->free(p3);
p3 = nullptr;
}
return AMP_NO_ERROR;
}
void
amp_bucket_hash::hashData(amp_span span)
{
hashed_bytes += span.size_bytes();
if (algorithm == amp_hash_algorithm_none)
return; // Already in error
else if ((algorithm == amp_hash_algorithm_adler32 || algorithm == amp_hash_algorithm_crc32))
{
uLong* pValue = reinterpret_cast<uLong*>(p3);
if (algorithm == amp_hash_algorithm_crc32)
*pValue = crc32(*pValue, (const Bytef*)span.data(), span.size_bytes());
else
*pValue = adler32(*pValue, (const Bytef*)span.data(), span.size_bytes());
return;
}
#ifdef _WIN32
if (!p2 || BCryptHashData(p2, (PUCHAR)span.data(), span.size_bytes(), 0) < 0)
{
algorithm = amp_hash_algorithm_none;
}
#else
#endif
}
amp_err_t*
amp_bucket_hash::read(
amp_span* data,
ptrdiff_t requested,
amp_pool_t* scratch_pool)
{
amp_err_t* err = amp_err_trace(
(*wrapped)->read(data, requested, scratch_pool));
if (!err)
hashData(*data);
else if (AMP_ERR_IS_EOF(err))
return amp_err_compose_create(
finishHashing(true),
err);
return err;
}
amp_err_t*
amp_bucket_hash::read_until_eol(
amp_span* data,
amp_newline_t* found,
amp_newline_t acceptable,
ptrdiff_t requested,
amp_pool_t* scratch_pool)
{
amp_err_t* err = amp_err_trace(
(*wrapped)->read_until_eol(data, found, acceptable,
requested, scratch_pool));
if (!err)
hashData(*data);
else if (AMP_ERR_IS_EOF(err))
return amp_err_compose_create(
finishHashing(true),
err);
return err;
}
amp_err_t*
amp_bucket_hash::peek(
amp_span* data,
bool no_poll,
amp_pool_t* scratch_pool)
{
return
amp_err_trace((*wrapped)->peek(data, no_poll, scratch_pool));
}
amp_err_t*
amp_bucket_hash::reset(
amp_pool_t* scratch_pool)
{
AMP_ERR((*wrapped)->reset(scratch_pool));
amp_err_clear(finishHashing(false));
setupHashing();
return AMP_NO_ERROR;
}
amp_err_t*
amp_bucket_hash::read_remaining_bytes(
amp_off_t* remaining,
amp_pool_t* scratch_pool)
{
return amp_err_trace((*wrapped)->read_remaining_bytes(remaining, scratch_pool));
}
amp_off_t
amp_bucket_hash::get_position()
{
return hashed_bytes;
}
amp_err_t*
amp_bucket_hash::duplicate(
amp_bucket_t** result,
bool for_reset,
amp_pool_t* scratch_pool)
{
amp_bucket_t* wr;
AMP_ERR((*wrapped)->duplicate(&wr, for_reset, scratch_pool));
if (expected_result)
{
*result = AMP_ALLOCATOR_NEW(amp_bucket_hash, allocator, wr, nullptr, expected_result, allocator);
return AMP_NO_ERROR;
}
else
{
// No need to hash if nobody can access the result
*result = wr;
return AMP_NO_ERROR;
}
}
amp_err_t*
amp_bucket_hash_create(
amp_bucket_t** new_bucket,
amp_hash_result_t** hash_result,
amp_bucket_t* wrapped_bucket,
amp_hash_algorithm_t algorithm,
const amp_hash_result_t* expected_result,
amp_allocator_t* allocator,
amp_pool_t* result_pool)
{
if (hash_result)
*hash_result = amp_hash_result_create(algorithm, result_pool);
*new_bucket = AMP_ALLOCATOR_NEW(amp_bucket_hash, allocator,
wrapped_bucket, hash_result ? *hash_result : nullptr,
expected_result, allocator);
return AMP_NO_ERROR;
}
const char*
amp_hash_result_to_cstring(
amp_hash_result_t* result,
amp_boolean_t for_display,
amp_pool_t* result_pool)
{
AMP_ASSERT(result);
if (!result)
return nullptr;
if (result->hash_algorithm == amp_hash_algorithm_none)
return "";
if (for_display)
{
bool all0 = true;
for (size_t i = 0; i < result->hash_bytes; i++)
{
if (result->bytes[i])
{
all0 = false;
break;
}
}
if (all0)
return "";
}
char* rs = amp_palloc_n<char>(result->hash_bytes * 2 + 1, result_pool);
for (size_t i = 0; i < result->hash_bytes; i++)
{
int b = result->bytes[i];
rs[2 * i] = "0123456789abcdef"[b >> 4];
rs[2 * i + 1] = "0123456789abcdef"[b & 0xF];
}
rs[result->hash_bytes * 2] = 0;
return rs;
}
| 21.774194 | 141 | 0.713048 | AmpScm |
412cfaa5912f3d6646070ae80db849ea33685966 | 2,763 | cpp | C++ | kmp.cpp | albertcheu/snippets | bba723b18c347e735bcdc72e61dcdf1c220f4885 | [
"MIT"
] | null | null | null | kmp.cpp | albertcheu/snippets | bba723b18c347e735bcdc72e61dcdf1c220f4885 | [
"MIT"
] | null | null | null | kmp.cpp | albertcheu/snippets | bba723b18c347e735bcdc72e61dcdf1c220f4885 | [
"MIT"
] | 1 | 2022-03-17T17:32:48.000Z | 2022-03-17T17:32:48.000Z | /*Knuth-Morris-Pratt*/
//Fast DFA-based string matching
//"border" = prefix which is also a proper suffix
//len[i] = length of longest border of pattern up to but not including ith char
//len has size pattern.size+1
void kmp_build(const string& pattern, vi& len){
for (int i = 2; i <= pattern.size(); i++) {
int j = len[i-1];
while (true) {
//if this character matches (the biggest border)+1,
//we don't have to look any further
if (pattern[j] == pattern[i-1]) { len[i] = j+1; break;}
//if the biggest border is empty, this char can't be a prefix
else if (j == 0) { break; }
//shift what we consider to be the biggest border
else { j = len[j]; }
}
}
}
//here, len has not been filled yet
int shortestPeriod(const string& pattern, vi& len){
int size = pattern.size();
int ans = size;
for (int i = 2; i <= size; i++) {
int j = len[i-1];
while (true) {
bool a = (i != size);
bool b = (size%(size-j-1) == 0);
//if this character matches (the biggest border)+1,
//we don't have to look any further
if (pattern[j] == pattern[i-1] && (a || b)) {
len[i] = j+1;
//we're at the last spot & it satisfies the x^k condition
if (!a && b) { ans = size-j-1; }
break;
}
//if the biggest border is empty, this char can't be a prefix
else if (j == 0) { break; }
//shift what we consider to be the biggest border
else { j = len[j]; }
}
}
return ans;
}
//returns state (match if equal to pattern size)
int kmp_compare(const string& text, const string& pattern, const vi& len){
int state = 0;
for (int i = 0; i < text.size(); i++) {
while (true) {
//match = move along DFA
if (text[i] == pattern[state]) { state++; break; }
//restarted DFA
else if (state == 0) { break; }
//smart restart
state = len[state];
}
//in the accept state
if (state == pattern.size()) { break; }
}
return state;
}
//assume pattern ends with a unique token (not present in pattern or text)
//fills vector with indices in text that start instances of the pattern
//returns number of occurrences (vector's size)
int fillOccurrences(const string& text, const string& pattern, const vi& len,
vi& occurrences){
int counter = 0;
int trueSize = pattern.size()-1;
int state = 0;
for (int i = 0; i < text.size(); i++) {
while (true) {
//match = move along DFA
if (text[i] == pattern[state]) { state++; break; }
//restarted DFA
else if (state == 0) { break; }
//smart restart
state = len[state];
}
if (state == trueSize) {
counter++;
occurrences.push_back(i-trueSize+1);
}
}
return counter;
}
| 23.218487 | 79 | 0.578719 | albertcheu |
41343ba0e0e71ba9e52b5436e81bd97952965791 | 8,026 | cpp | C++ | 5/Code/Sandbox/Main.cpp | Zakhar-V/Prototypes | 413a7ce9fdb2a6f3ba97a041f798c71351efc855 | [
"MIT"
] | null | null | null | 5/Code/Sandbox/Main.cpp | Zakhar-V/Prototypes | 413a7ce9fdb2a6f3ba97a041f798c71351efc855 | [
"MIT"
] | null | null | null | 5/Code/Sandbox/Main.cpp | Zakhar-V/Prototypes | 413a7ce9fdb2a6f3ba97a041f798c71351efc855 | [
"MIT"
] | null | null | null | #include "Sandbox.hpp"
#include <SDL2\include\SDL.h>
#include <Windows.h>
#include <io.h>
#include <sys/stat.h>
#ifdef _MSC_VER
# include <direct.h>
#else
# include <dirent.h>
#endif
#include <zlib\zlib.h>
#include <zlib\unzip.h>
using namespace Engine;
#define PRINT_SIZEOF(T) printf("sizeof(%s) = %d\n", #T, sizeof(T))
namespace Engine
{
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
const char* _FileExt(const char* _fname, int _length = -1)
{
if (_length < 0)
_length = (int)strlen(_fname);
const char* _end = _fname + _length;
while (_end-- > _fname)
{
if (*_end == '.')
return _end + 1;
if (*_end == '/' || *_end == '\\')
break;
}
return "";
}
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
enum ResourceState : uint
{
RS_Unloaded,
RS_Queued,
RS_Loading,
RS_Loaded,
};
typedef Ptr<class Resource> ResourcePtr;
class Resource : public RefCounted
{
public:
CLASSNAME(Resource);
Resource(void);
~Resource(void);
bool IsPending(void) { return m_state == RS_Queued || m_state == RS_Loading; }
bool IsLoaded(void) { return m_state == RS_Loaded; }
bool IsUnloaded(void) { return m_state == RS_Unloaded; }
void Load(bool _wait = true);
protected:
friend class ResourceManager;
virtual void _Load(void) { }
bool _ChangeState(ResourceState _expected, ResourceState _newState)
{
if (_expected != _newState)
{
}
return m_state.CompareExchange(_expected, _newState);
return false;
}
void _DeleteThis(void) override;
ResourceManager* m_manager;
uint m_id;
String m_name;
Atomic<ResourceState> m_state;
private:
friend class ResourceCache;
Resource* m_qprev;
Resource* m_qnext;
};
//----------------------------------------------------------------------------//
// ResourceManager
//----------------------------------------------------------------------------//
class ResourceManager
{
public:
protected:
friend class Resource;
virtual ResourcePtr _Factory(void) = 0;
void _RemoveRefs(Resource* _r)
{
SCOPE_LOCK(m_mutex);
m_resources.erase(_r->m_id);
}
Mutex m_mutex;
HashMap<uint, ResourcePtr> m_cache;
HashMap<uint, Resource*> m_resources;
String m_className;
NameHash m_classId;
};
//----------------------------------------------------------------------------//
// ResourceCache
//----------------------------------------------------------------------------//
#define gResourceCache Engine::ResourceCache::Get()
class ResourceCache : public Singleton<ResourceCache>
{
public:
protected:
friend class Resource;
void _Queue(Resource* _r)
{
SCOPE_LOCK(m_qlock);
_r->AddRef();
_r->m_qnext = m_qstart;
if (m_qstart)
m_qstart->m_qprev = _r;
else
m_qend = _r;
m_qstart = _r;
}
void _Unqueue(Resource* _r)
{
SCOPE_LOCK(m_qlock);
if (_r->m_qnext)
_r->m_qnext->m_qprev = _r->m_qprev;
else
m_qend = _r->m_qprev;
if (_r->m_qprev)
_r->m_qprev->m_qnext = _r->m_qnext;
else
m_qstart = _r->m_qnext;
_r->m_qprev = nullptr;
_r->m_qnext = nullptr;
_r->Release();
}
void _Wait(Resource* _r)
{
while (_r->IsPending())
{
m_resourceLoaded.Wait(1);
}
}
Mutex m_qlock;
Resource* m_qstart;
Resource* m_qend;
Condition m_resourceLoaded;
HashMap<uint, ResourceManager*> m_managers;
};
//----------------------------------------------------------------------------//
// Resource
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
Resource::Resource(void) :
m_manager(nullptr),
m_id(0),
m_state(RS_Unloaded),
m_qprev(nullptr),
m_qnext(nullptr)
{
}
//----------------------------------------------------------------------------//
Resource::~Resource(void)
{
}
//----------------------------------------------------------------------------//
void Resource::Load(bool _wait)
{
if (!_wait) // load async
{
if (m_state.CompareExchange(RS_Unloaded, RS_Queued)) // queue this resource
{
gResourceCache->_Queue(this);
}
}
else if(m_state != RS_Loaded) // resource is not loaded
{
ResourcePtr _addref(this);
if (m_state.CompareExchange(RS_Queued, RS_Loading)) // unqueue it and load now
{
gResourceCache->_Unqueue(this);
_Load();
m_state = RS_Loaded;
}
else if (m_state.CompareExchange(RS_Unloaded, RS_Loading)) // load now
{
_Load();
m_state = RS_Loaded;
}
else // wait loading
{
ASSERT(m_state != RS_Unloaded);
gResourceCache->_Wait(this);
}
}
}
//----------------------------------------------------------------------------//
void Resource::_DeleteThis(void)
{
if (m_manager)
m_manager->_RemoveRefs(this);
RefCounted::_DeleteThis();
}
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
extern int numUpdates;
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
/*
Actor _a, _b, _c
*/
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
}
struct ThreadArg
{
ThreadArg(void) { }
ThreadArg(const ThreadArg& _arg) : v(_arg.v) { printf("copy\n"); }
ThreadArg(ThreadArg&& _arg) : v(_arg.v) { printf("move\n"); _arg.v = -1; }
int v = 0;
};
void ThreadFunc()
{
printf("func()\n");
}
struct ThreadClass
{
void ThreadFunc()
{
printf("method()\n");
}
};
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
typedef Ptr<class ThreadTask> ThreadTaskPtr;
class ThreadTask : public RefCounted
{
public:
virtual void Exec(void) = 0;
};
class ThreadPool : public Singleton<ThreadPool>
{
public:
protected:
List<ThreadTaskPtr> m_queue;
};
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//
int main(void)
{
try
{
system("pause");
return 0;
}
catch (std::exception _e)
{
printf("unhandled exception: %s\n", _e.what());
system("pause");
return -1;
}
catch (...)
{
printf("unhandled exception");
system("pause");
return -1;
}
} | 21.459893 | 82 | 0.387989 | Zakhar-V |
413470d4462f8ea91c9a2652577649d59aa18795 | 4,875 | cpp | C++ | Library/Sources/Stroika/Frameworks/WebServer/Request.cpp | SophistSolutions/Stroika | f4e5d84767903a054fba0a6b9c7c4bd1aaefd105 | [
"MIT"
] | 28 | 2015-09-22T21:43:32.000Z | 2022-02-28T01:35:01.000Z | Library/Sources/Stroika/Frameworks/WebServer/Request.cpp | SophistSolutions/Stroika | f4e5d84767903a054fba0a6b9c7c4bd1aaefd105 | [
"MIT"
] | 98 | 2015-01-22T03:21:27.000Z | 2022-03-02T01:47:00.000Z | Library/Sources/Stroika/Frameworks/WebServer/Request.cpp | SophistSolutions/Stroika | f4e5d84767903a054fba0a6b9c7c4bd1aaefd105 | [
"MIT"
] | 4 | 2019-02-21T16:45:25.000Z | 2022-02-18T13:40:04.000Z | /*
* Copyright(c) Sophist Solutions, Inc. 1990-2021. All rights reserved
*/
#include "../StroikaPreComp.h"
#include <algorithm>
#include <cstdlib>
#include "../../Foundation/Characters/StringBuilder.h"
#include "../../Foundation/Characters/ToString.h"
#include "../../Foundation/Containers/Common.h"
#include "../../Foundation/Debug/Assertions.h"
#include "../../Foundation/Debug/Trace.h"
#include "../../Foundation/Execution/Throw.h"
#include "../../Foundation/IO/Network/HTTP/Headers.h"
#include "../../Foundation/IO/Network/HTTP/Versions.h"
#include "../../Foundation/Streams/InputSubStream.h"
#include "../../Foundation/Streams/MemoryStream.h"
#include "Request.h"
using std::byte;
using namespace Stroika::Foundation;
using namespace Stroika::Foundation::Characters;
using namespace Stroika::Foundation::Containers;
using namespace Stroika::Foundation::Memory;
using namespace Stroika::Foundation::Streams;
using namespace Stroika::Frameworks;
using namespace Stroika::Frameworks::WebServer;
// Comment this in to turn on aggressive noisy DbgTrace in this module
//#define USE_NOISY_TRACE_IN_THIS_MODULE_ 1
/*
********************************************************************************
*************************** WebServer::Request *********************************
********************************************************************************
*/
Request::Request (Request&& src)
: Request{src.fInputStream_}
{
fBodyInputStream_ = move (src.fBodyInputStream_);
fBody_ = move (src.fBody_);
}
Request::Request (const Streams::InputStream<byte>::Ptr& inStream)
: keepAliveRequested{[qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]] const auto* property) {
const Request* thisObj = qStroika_Foundation_Common_Property_OuterObjPtr (property, &Request::keepAliveRequested);
shared_lock<const AssertExternallySynchronizedLock> critSec{*thisObj};
using ConnectionValue = IO::Network::HTTP::Headers::ConnectionValue;
if (thisObj->httpVersion == IO::Network::HTTP::Versions::kOnePointZero) {
return thisObj->headers ().connection ().value_or (ConnectionValue::eClose) == ConnectionValue::eKeepAlive;
}
if (thisObj->httpVersion == IO::Network::HTTP::Versions::kOnePointOne) {
return thisObj->headers ().connection ().value_or (ConnectionValue::eKeepAlive) == ConnectionValue::eKeepAlive;
}
return true; // for HTTP 2.0 and later, keep alive is always assumed (double check/reference?)
}}
, fInputStream_{inStream}
{
}
Memory::BLOB Request::GetBody ()
{
#if USE_NOISY_TRACE_IN_THIS_MODULE_
Debug::TraceContextBumper ctx{L"Request::GetBody"};
#endif
lock_guard<const AssertExternallySynchronizedLock> critSec{*this};
if (not fBody_.has_value ()) {
fBody_ = GetBodyStream ().ReadAll ();
}
return *fBody_;
}
Streams::InputStream<byte>::Ptr Request::GetBodyStream ()
{
#if USE_NOISY_TRACE_IN_THIS_MODULE_
Debug::TraceContextBumper ctx{L"Request::GetBodyStream"};
#endif
lock_guard<const AssertExternallySynchronizedLock> critSec{*this};
if (fBodyInputStream_ == nullptr) {
/*
* According to https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html:
* The presence of a message-body in a request is signaled by the inclusion of
* a Content-Length or Transfer-Encoding header field in the request's message-headers
*/
// if we have a content-length, read that many bytes.
if (optional<uint64_t> cl = headers ().contentLength ()) {
fBodyInputStream_ = InputSubStream<byte>::New (fInputStream_, {}, fInputStream_.GetOffset () + static_cast<size_t> (*cl));
}
else {
/*
* @todo FIX - WRONG!!!! - MUST SUPPORT TRANSFER ENCODING IN THIS CASE OR NOTHING
*
* https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
* The rules for when a message-body is allowed in a message differ for requests and responses.
*
* The presence of a message-body in a request is signaled by the inclusion of a Content-Length
* or Transfer-Encoding header field in the request's message-headers/
*
* For now - EMPTY is a better failure mode than reading everything and hanging...
*/
fBodyInputStream_ = MemoryStream<byte>::New ();
}
}
return fBodyInputStream_;
}
String Request::ToString () const
{
shared_lock<const AssertExternallySynchronizedLock> critSec{*this};
StringBuilder sb = inherited::ToString ().SubString (0, -1); // strip trialing '{'
// @todo add stuff about body
sb += L"}";
return sb.str ();
}
| 40.966387 | 159 | 0.636718 | SophistSolutions |
41387832924404c6034ba2e77fe0246bca5752bd | 2,493 | cpp | C++ | LudensVR_Project_01/Source/LudensVR_Project_01/Private/VR_Template/TP_PlayerMovableArea.cpp | kruore/VRGame_LudensVR | 93c236a01dc767228f1ded59922d4ea3d53cc6ee | [
"BSD-3-Clause"
] | null | null | null | LudensVR_Project_01/Source/LudensVR_Project_01/Private/VR_Template/TP_PlayerMovableArea.cpp | kruore/VRGame_LudensVR | 93c236a01dc767228f1ded59922d4ea3d53cc6ee | [
"BSD-3-Clause"
] | null | null | null | LudensVR_Project_01/Source/LudensVR_Project_01/Private/VR_Template/TP_PlayerMovableArea.cpp | kruore/VRGame_LudensVR | 93c236a01dc767228f1ded59922d4ea3d53cc6ee | [
"BSD-3-Clause"
] | null | null | null | //=======================================================================================================================================
// The named class sources like 'TP_...' are the Unreal Engine 4.20 full C++ VR template sources written by Sang-bin, Jeon (Ludens VR) |
// This VR Template Copyright (C) 2018, Sang-bin, Jeon, All Rights Reserved. |
// This Project Copyright (C) 2018, Ludens VR, All Rights Reserved. |
//=======================================================================================================================================
#include "TP_PlayerMovableArea.h"
#include "Components/BoxComponent.h"
#include "Kismet/GameplayStatics.h"
#include "TP_VirtualRealityPawn_Motion.h"
#include "Runtime/Engine/Classes/Engine/Engine.h"
// Sets default values
ATP_PlayerMovableArea::ATP_PlayerMovableArea()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
OverlapVolume = CreateDefaultSubobject<UBoxComponent>(TEXT("OverlapVolume"));
RootComponent = OverlapVolume;
OverlapVolume->SetCollisionProfileName(TEXT("PlayerMovableArea"));
OverlapVolume->SetGenerateOverlapEvents(true);
OverlapVolume->OnComponentBeginOverlap.AddUniqueDynamic(this, &ATP_PlayerMovableArea::AreaBeginsOverlap);
OverlapVolume->OnComponentEndOverlap.AddUniqueDynamic(this, &ATP_PlayerMovableArea::AreaEndsOverlap);
}
// Called when the game starts or when spawned
void ATP_PlayerMovableArea::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ATP_PlayerMovableArea::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ATP_PlayerMovableArea::AreaBeginsOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
APawn* MyCharacter = UGameplayStatics::GetPlayerPawn(this, 0);
if (OtherActor == (AActor*)MyCharacter)
{
Cast<ATP_VirtualRealityPawn_Motion>(OtherActor)->SetPlayerMovability(true, this->GetActorLocation());
}
}
void ATP_PlayerMovableArea::AreaEndsOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
APawn* MyCharacter = UGameplayStatics::GetPlayerPawn(this, 0);
if (OtherActor == (AActor*)MyCharacter)
{
Cast<ATP_VirtualRealityPawn_Motion>(OtherActor)->SetPlayerMovability(false, this->GetActorLocation());
}
}
| 40.868852 | 210 | 0.694344 | kruore |
4140ad20511d23f3843525847d500bed977022ec | 681 | cpp | C++ | implementation/others/kmp.cpp | Layomiiety/Algorithmic-thinking | fc280717db051a26d19a583f3206402215d05c0a | [
"CC0-1.0"
] | null | null | null | implementation/others/kmp.cpp | Layomiiety/Algorithmic-thinking | fc280717db051a26d19a583f3206402215d05c0a | [
"CC0-1.0"
] | null | null | null | implementation/others/kmp.cpp | Layomiiety/Algorithmic-thinking | fc280717db051a26d19a583f3206402215d05c0a | [
"CC0-1.0"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define il inline
#define re register
const int maxn=1e6+5;
char a[maxn],b[maxn];
int bor[maxn],sa,sb,cur=0;
int main(){
scanf("%s%s",a+1,b+1);
sa=strlen(a+1);
sb=strlen(b+1);
for(re int i=2,j=0;i<=sb;i++){
while(j&&b[j+1]!=b[i])j=bor[j];
if(b[j+1]==b[i])j++;
bor[i]=j;
}
for(re int i=1,j=0;i<=sa;i++){
while(j&&b[j+1]!=a[i])j=bor[j];
if(b[j+1]==a[i])j++;
if(j==sb){
printf("%d\n",i-sb+1);
j=bor[j];
}
}
for(int i=1;i<=sb;i++)printf("%d ",bor[i]);
return 0;
} | 23.482759 | 47 | 0.480176 | Layomiiety |
414b9771ac50dda3de6a514687ffc28eb58737c6 | 778 | cpp | C++ | src/main.cpp | cod-sushi/QCodScreenShot | 9dbedc61fa71dc0e62bb48b012685bdf04a05844 | [
"MIT"
] | 3 | 2019-06-15T14:55:37.000Z | 2021-12-21T10:47:23.000Z | src/main.cpp | cod-sushi/QCodScreenShot | 9dbedc61fa71dc0e62bb48b012685bdf04a05844 | [
"MIT"
] | null | null | null | src/main.cpp | cod-sushi/QCodScreenShot | 9dbedc61fa71dc0e62bb48b012685bdf04a05844 | [
"MIT"
] | null | null | null | #include "mainwindow.h"
#include "settings.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// translate
QTranslator translator;
QString lang = Settings::value(Settings::Language);
translator.load(QString("translate/qcss_") + lang);
a.installTranslator(&translator);
MainWindow w;
w.initialize();
// get screen that shows this app window
QRect screen = QApplication::desktop()->availableGeometry(&w);
QRect geometry = w.geometry();
// Show at bottom-right of screen
int margin = 10;
w.move(screen.right() - geometry.width() - margin,
screen.bottom() - geometry.height() - margin);
w.show();
return a.exec();
}
| 24.3125 | 65 | 0.660668 | cod-sushi |
414dbb731e16bdbeda7ffe290ecb33ff6d11346c | 3,757 | cpp | C++ | export/release/windows/obj/src/openfl/events/ActivityEvent.cpp | bobisdabbing/Vs-The-United-Lands-stable | 0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5 | [
"MIT"
] | null | null | null | export/release/windows/obj/src/openfl/events/ActivityEvent.cpp | bobisdabbing/Vs-The-United-Lands-stable | 0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5 | [
"MIT"
] | null | null | null | export/release/windows/obj/src/openfl/events/ActivityEvent.cpp | bobisdabbing/Vs-The-United-Lands-stable | 0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5 | [
"MIT"
] | null | null | null | // Generated by Haxe 4.1.5
#include <hxcpp.h>
#ifndef INCLUDED_openfl_events_ActivityEvent
#include <openfl/events/ActivityEvent.h>
#endif
#ifndef INCLUDED_openfl_events_Event
#include <openfl/events/Event.h>
#endif
HX_DEFINE_STACK_FRAME(_hx_pos_07ba67a8dcdbfa28_63_new,"openfl.events.ActivityEvent","new",0x259c5826,"openfl.events.ActivityEvent.new","openfl/events/ActivityEvent.hx",63,0x98f9202a)
namespace openfl{
namespace events{
void ActivityEvent_obj::__construct(::String type,::hx::Null< bool > __o_bubbles,::hx::Null< bool > __o_cancelable,::hx::Null< bool > __o_activating){
bool bubbles = __o_bubbles.Default(false);
bool cancelable = __o_cancelable.Default(false);
bool activating = __o_activating.Default(false);
HX_STACKFRAME(&_hx_pos_07ba67a8dcdbfa28_63_new)
HXLINE( 64) super::__construct(type,bubbles,cancelable);
HXLINE( 66) this->activating = activating;
}
Dynamic ActivityEvent_obj::__CreateEmpty() { return new ActivityEvent_obj; }
void *ActivityEvent_obj::_hx_vtable = 0;
Dynamic ActivityEvent_obj::__Create(::hx::DynamicArray inArgs)
{
::hx::ObjectPtr< ActivityEvent_obj > _hx_result = new ActivityEvent_obj();
_hx_result->__construct(inArgs[0],inArgs[1],inArgs[2],inArgs[3]);
return _hx_result;
}
bool ActivityEvent_obj::_hx_isInstanceOf(int inClassId) {
if (inClassId<=(int)0x08ec4c31) {
return inClassId==(int)0x00000001 || inClassId==(int)0x08ec4c31;
} else {
return inClassId==(int)0x11188ee2;
}
}
ActivityEvent_obj::ActivityEvent_obj()
{
}
::hx::Val ActivityEvent_obj::__Field(const ::String &inName,::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 10:
if (HX_FIELD_EQ(inName,"activating") ) { return ::hx::Val( activating ); }
}
return super::__Field(inName,inCallProp);
}
::hx::Val ActivityEvent_obj::__SetField(const ::String &inName,const ::hx::Val &inValue,::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 10:
if (HX_FIELD_EQ(inName,"activating") ) { activating=inValue.Cast< bool >(); return inValue; }
}
return super::__SetField(inName,inValue,inCallProp);
}
void ActivityEvent_obj::__GetFields(Array< ::String> &outFields)
{
outFields->push(HX_("activating",b0,17,b4,bd));
super::__GetFields(outFields);
};
#ifdef HXCPP_SCRIPTABLE
static ::hx::StorageInfo ActivityEvent_obj_sMemberStorageInfo[] = {
{::hx::fsBool,(int)offsetof(ActivityEvent_obj,activating),HX_("activating",b0,17,b4,bd)},
{ ::hx::fsUnknown, 0, null()}
};
static ::hx::StaticInfo *ActivityEvent_obj_sStaticStorageInfo = 0;
#endif
static ::String ActivityEvent_obj_sMemberFields[] = {
HX_("activating",b0,17,b4,bd),
::String(null()) };
::hx::Class ActivityEvent_obj::__mClass;
void ActivityEvent_obj::__register()
{
ActivityEvent_obj _hx_dummy;
ActivityEvent_obj::_hx_vtable = *(void **)&_hx_dummy;
::hx::Static(__mClass) = new ::hx::Class_obj();
__mClass->mName = HX_("openfl.events.ActivityEvent",34,0d,80,a0);
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &::hx::Class_obj::GetNoStaticField;
__mClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
__mClass->mStatics = ::hx::Class_obj::dupFunctions(0 /* sStaticFields */);
__mClass->mMembers = ::hx::Class_obj::dupFunctions(ActivityEvent_obj_sMemberFields);
__mClass->mCanCast = ::hx::TCanCast< ActivityEvent_obj >;
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = ActivityEvent_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = ActivityEvent_obj_sStaticStorageInfo;
#endif
::hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
} // end namespace openfl
} // end namespace events
| 33.846847 | 182 | 0.745275 | bobisdabbing |
a991a8de3f49a29e83eeaf761abe371e1d7450cc | 1,013 | cpp | C++ | PRATICA3/FigGeometricasSemPolimorfismo/ImpPerimArea.cpp | JP-Clemente/INF213_UFV | 8d6b3afd02212a0ba58ddaec04df5bb87aef9f5d | [
"MIT"
] | 2 | 2020-11-29T08:06:31.000Z | 2020-12-04T13:35:17.000Z | PRATICA3/FigGeometricasSemPolimorfismo/ImpPerimArea.cpp | JP-Clemente/INF213_UFV | 8d6b3afd02212a0ba58ddaec04df5bb87aef9f5d | [
"MIT"
] | null | null | null | PRATICA3/FigGeometricasSemPolimorfismo/ImpPerimArea.cpp | JP-Clemente/INF213_UFV | 8d6b3afd02212a0ba58ddaec04df5bb87aef9f5d | [
"MIT"
] | null | null | null | #include <iostream>
#include <typeinfo>
using namespace std;
#include "FigBase.h"
#include "Retangulo.h"
#include "Circulo.h"
#include "Segmento.h"
int main() {
Retangulo r(13, 7, 2, 4, 1, 1, 1);
Circulo c(5, 2, 4, 2, 2, 2);
Segmento s(3, 7, 8, 5, 3, 3, 3);
FigBase *p[5];
p[0] = &r;
p[1] = &c;
p[2] = &s;
int i;
for (i=0; i < 3; i++) {
cout << "Objeto " << i+1 << " eh do tipo " << typeid( *p[ i ] ).name() << endl;
cout << "Perimetro = " << p[i]->perimetro() << endl;
cout << "Area = " << p[i]->area() << endl;
cout << endl;
}
return 0;
} // fim de main
/* ----------------------------------------------------------
RESULTADO ESPERADO
Objeto 1
Perimetro = 12
Area = 8
Objeto 2
Perimetro = 25.1327
Area = 50.2655
Objeto 3
Perimetro = 5.38516
Area = 0
---------------------------------------------------------------
*/
| 19.113208 | 89 | 0.394867 | JP-Clemente |
a9960bc71672ba9ec3b0054870bf2b5f194b1571 | 3,342 | cpp | C++ | src/tests/InterpreterTypesTests.cpp | gtirloni/procdraw | 34ddb1b96f0f47af7304914e938f53d10ca5478d | [
"Apache-2.0"
] | null | null | null | src/tests/InterpreterTypesTests.cpp | gtirloni/procdraw | 34ddb1b96f0f47af7304914e938f53d10ca5478d | [
"Apache-2.0"
] | null | null | null | src/tests/InterpreterTypesTests.cpp | gtirloni/procdraw | 34ddb1b96f0f47af7304914e938f53d10ca5478d | [
"Apache-2.0"
] | null | null | null | // Copyright 2020 Simon Bates
//
// 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 "../lib/InterpreterTypes.h"
#include <catch.hpp>
#include <functional>
using namespace Procdraw;
TEST_CASE("Interpreter Types")
{
Object trueObj{true};
Object falseObj{false};
Object cfunctionHandleObj = Object::MakeCFunctionHandle(10);
Object integerObj{42};
Object listPtrObj = Object::EmptyList();
Object noneObj = Object::None();
Object symbolHandleObj = Object::MakeSymbolHandle(20);
auto allTypesObjs = {
trueObj,
cfunctionHandleObj,
integerObj,
listPtrObj,
noneObj,
symbolHandleObj};
auto forAllTypesExcept = [allTypesObjs](
ObjectType type,
const std::function<void(Object)>& callback) {
for (const auto& obj : allTypesObjs) {
if (obj.Type() != type) {
callback(obj);
}
}
};
SECTION("Boolean")
{
REQUIRE(trueObj.Type() == ObjectType::Boolean);
REQUIRE(trueObj.GetBoolean());
REQUIRE(falseObj.Type() == ObjectType::Boolean);
REQUIRE_FALSE(falseObj.GetBoolean());
forAllTypesExcept(ObjectType::Boolean, [](const Object& obj) {
REQUIRE_THROWS_AS(obj.GetBoolean(), BadObjectAccess);
});
}
SECTION("CFunctionHandle")
{
REQUIRE(cfunctionHandleObj.Type() == ObjectType::CFunctionHandle);
REQUIRE(cfunctionHandleObj.GetCFunctionHandle() == 10);
forAllTypesExcept(ObjectType::CFunctionHandle, [](const Object& obj) {
REQUIRE_THROWS_AS(obj.GetCFunctionHandle(), BadObjectAccess);
});
}
SECTION("Integer")
{
REQUIRE(integerObj.Type() == ObjectType::Integer);
REQUIRE(integerObj.GetInteger() == 42);
forAllTypesExcept(ObjectType::Integer, [](const Object& obj) {
REQUIRE_THROWS_AS(obj.GetInteger(), BadObjectAccess);
});
}
SECTION("ListPtr")
{
REQUIRE(listPtrObj.Type() == ObjectType::ListPtr);
REQUIRE(listPtrObj.GetListPtr() == nullptr);
forAllTypesExcept(ObjectType::ListPtr, [](const Object& obj) {
REQUIRE_THROWS_AS(obj.GetListPtr(), BadObjectAccess);
});
}
SECTION("None")
{
REQUIRE(noneObj.Type() == ObjectType::None);
}
SECTION("SymbolHandle")
{
REQUIRE(symbolHandleObj.Type() == ObjectType::SymbolHandle);
REQUIRE(symbolHandleObj.GetSymbolHandle() == 20);
forAllTypesExcept(ObjectType::SymbolHandle, [](const Object& obj) {
REQUIRE_THROWS_AS(obj.GetSymbolHandle(), BadObjectAccess);
});
}
}
| 31.233645 | 80 | 0.608019 | gtirloni |
a996da30dbb9f3932e0418a3cd2e9b5ec9bafd19 | 1,313 | hpp | C++ | irohad/ametsuchi/tx_presence_cache_utils.hpp | akshatkarani/iroha | 5acef9dd74720c6185360d951e9b11be4ef73260 | [
"Apache-2.0"
] | 1,467 | 2016-10-25T12:27:19.000Z | 2022-03-28T04:32:05.000Z | irohad/ametsuchi/tx_presence_cache_utils.hpp | akshatkarani/iroha | 5acef9dd74720c6185360d951e9b11be4ef73260 | [
"Apache-2.0"
] | 2,366 | 2016-10-25T10:07:57.000Z | 2022-03-31T22:03:24.000Z | irohad/ametsuchi/tx_presence_cache_utils.hpp | akshatkarani/iroha | 5acef9dd74720c6185360d951e9b11be4ef73260 | [
"Apache-2.0"
] | 662 | 2016-10-26T04:41:22.000Z | 2022-03-31T04:15:02.000Z | /**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef IROHA_TX_PRESENCE_CACHE_UTILS_HPP
#define IROHA_TX_PRESENCE_CACHE_UTILS_HPP
#include "ametsuchi/tx_cache_response.hpp"
#include "common/visitor.hpp"
namespace iroha {
namespace ametsuchi {
/**
* Determine if transaction was already processed by its status
* @param tx_status - status obtained from transaction cache
* @return true if transaction was committed or rejected
*/
inline bool isAlreadyProcessed(
const TxCacheStatusType &tx_status) noexcept {
return std::visit(
make_visitor(
[](const ametsuchi::tx_cache_status_responses::Missing &) {
return false;
},
[](const auto &) { return true; }),
tx_status);
}
/**
* Retrieve hash from status
* @param status - transaction status obtained from cache
* @return hash of the transaction
*/
inline tx_cache_response_details::HashType getHash(
const TxCacheStatusType &status) noexcept {
return std::visit(
make_visitor([](const auto &status) { return status.hash; }), status);
}
} // namespace ametsuchi
} // namespace iroha
#endif // IROHA_TX_PRESENCE_CACHE_HPP
| 29.840909 | 80 | 0.657273 | akshatkarani |
a9997731f37d60997320cd13eef36124e0da00f6 | 5,206 | cpp | C++ | src/TravelingSalesman/TravelingSalesmanGui.cpp | Person-93/aima-cpp | 08d062dcb971edeaddb9a10083cf6da5a1b869f7 | [
"MIT"
] | null | null | null | src/TravelingSalesman/TravelingSalesmanGui.cpp | Person-93/aima-cpp | 08d062dcb971edeaddb9a10083cf6da5a1b869f7 | [
"MIT"
] | null | null | null | src/TravelingSalesman/TravelingSalesmanGui.cpp | Person-93/aima-cpp | 08d062dcb971edeaddb9a10083cf6da5a1b869f7 | [
"MIT"
] | null | null | null | #include "TravelingSalesmanGui.hpp"
#include <sstream>
#include "util/AssetManager.hpp"
#include "util/random_string.hpp"
#include "util/define_logger.hpp"
#include "core/Exception.hpp"
#include "IterativeLengtheningAgent.hpp"
#include "util/parseTitle.hpp"
using namespace aima::traveling_salesman;
DEFINE_LOGGER( TravelingSalesmanGui )
TravelingSalesmanGui::TravelingSalesmanGui( std::string_view title, bool* open, std::string_view str_id ) :
GraphicViewer( [] { return AssetHandles{}; }, title, open, str_id ),
childWindowConfig{
.str_id = util::random_string( 5 ),
.size = { 800, 600 },
.border = true,
.flags = ImGuiWindowFlags_NoResize,
} {}
void TravelingSalesmanGui::renderDisplay( aima::gui::ImGuiWrapper& imGuiWrapper,
std::shared_ptr<aima::core::Environment>& environment ) {
if ( !environment ) {
ImGui::TextUnformatted( "The environment has not been set" );
return;
}
auto env = std::dynamic_pointer_cast<TravelingSalesmanEnvironment>( environment );
if ( !env ) {
using namespace aima::core::exception;
AIMA_THROW_EXCEPTION( Exception{} << Because{ "Received environment of unrecognized type" } );
}
renderInfo( imGuiWrapper, *env );
auto region = ImGui::GetContentRegionAvail();
float xScale = region.x / 800;
float yScale = region.y / 600;
float scale = std::min( xScale, yScale );
childWindowConfig.size = { 800 * scale, 600 * scale };
imGuiWrapper.childWindow( childWindowConfig, [ & ] {
renderLocations( imGuiWrapper, *env, scale );
renderPlan( imGuiWrapper, *env, scale );
} );
}
void TravelingSalesmanGui::renderInfo( gui::ImGuiWrapper& imGuiWrapper, const TravelingSalesmanEnvironment& env ) {
for ( const core::Agent& agent: env.getAgents()) {
const auto& travelingSalesAgent = dynamic_cast<const IterativeLengtheningAgent&>(agent);
const auto& status = travelingSalesAgent.getStatus();
static const ImColor color{ 0, 100, 255 };
std::string visitedText;
if ( const auto& plan = travelingSalesAgent.getPlan()) {
std::ostringstream ss;
for ( size_t i : plan->visited ) {
ss << env.getLocations()[ i ] << ", ";
}
visitedText = ss.str();
visitedText.erase( visitedText.end() - 1, visitedText.end());
}
ImGui::TextColored( color, "%s:", util::parseTitle( agent ).data());
ImGui::Text( " Nodes in memory: %zu", status.nodesInMemory );
ImGui::Text( " Max nodes in memory: %zu", status.maxNodesInMemory );
ImGui::Text( " Nodes generated: %zu", status.nodesGenerated );
ImGui::Text( " Path length: %.0f", status.pathLength );
ImGui::Text( " Time spent thinking: %zu", status.timeSpent );
ImGui::Text( " Locations visited: %s", visitedText.data());
}
}
void TravelingSalesmanGui::renderLocations( gui::ImGuiWrapper& imGuiWrapper,
const TravelingSalesmanEnvironment& env,
float scale ) {
static const ImColor color{ 100, 225, 0 };
static const ImColor startColor{ 0, 100, 225 };
auto cursor = ImGui::GetCursorScreenPos();
auto drawList = ImGui::GetWindowDrawList();
const auto & locations = env.getLocations();
for ( const auto& location: locations ) {
drawList->AddCircleFilled( { ( location.x + 50 ) * scale + cursor.x, ( location.y + 50 ) * scale + cursor.y },
3 * scale,
color );
}
const auto & start = locations.front();
drawList->AddCircleFilled( { ( start.x + 50 ) * scale + cursor.x, ( start.y + 50 ) * scale + cursor.y },
3 * scale,
startColor );
}
void TravelingSalesmanGui::renderPlan( gui::ImGuiWrapper& imGuiWrapper,
const TravelingSalesmanEnvironment& env,
float scale ) {
static const ImColor color{ 100, 0, 225 };
auto cursor = ImGui::GetCursorScreenPos();
auto drawList = ImGui::GetWindowDrawList();
for ( const core::Agent& agent : env.getAgents()) {
const auto plan = dynamic_cast<const IterativeLengtheningAgent&>(agent).getPlan();
if ( !plan ) continue;
const auto& visited = plan->visited;
for ( size_t i = 0; i < visited.size() - 1; ++i ) {
const auto& locationA = env.getLocations()[ visited[ i ]];
const auto& locationB = env.getLocations()[ visited[ i + 1 ]];
drawList->AddLine( { ( locationA.x + 50 ) * scale + cursor.x, ( locationA.y + 50 ) * scale + cursor.y },
{ ( locationB.x + 50 ) * scale + cursor.x, ( locationB.y + 50 ) * scale + cursor.y },
color,
scale );
}
}
}
| 44.87931 | 118 | 0.567806 | Person-93 |
a999d1650cbc88f3fea1f2a06d03cbb505c9b939 | 1,746 | cpp | C++ | libs/core---stm32/platform.cpp | xmeow/pxt-common-packages | 2139799ac3a233addf27798825d3e3dc8c593993 | [
"MIT"
] | null | null | null | libs/core---stm32/platform.cpp | xmeow/pxt-common-packages | 2139799ac3a233addf27798825d3e3dc8c593993 | [
"MIT"
] | null | null | null | libs/core---stm32/platform.cpp | xmeow/pxt-common-packages | 2139799ac3a233addf27798825d3e3dc8c593993 | [
"MIT"
] | null | null | null | #include "pxt.h"
#include "STMLowLevelTimer.h"
#include "Accelerometer.h"
namespace pxt {
STMLowLevelTimer tim5(TIM5, TIM5_IRQn);
CODAL_TIMER devTimer(tim5);
void initAccelRandom();
static void initRandomSeed() {
if (getConfig(CFG_ACCELEROMETER_TYPE, -1) != -1) {
initAccelRandom();
}
}
void platformSendSerial(const char *data, int len) {
/*
if (!serial) {
serial = new codal::_mbed::Serial(USBTX, NC);
serial->baud(9600);
}
serial->send((uint8_t*)data, len);
*/
}
void platform_init() {
initRandomSeed();
setSendToUART(platformSendSerial);
/*
if (*HF2_DBG_MAGIC_PTR == HF2_DBG_MAGIC_START) {
*HF2_DBG_MAGIC_PTR = 0;
// this will cause alignment fault at the first breakpoint
globals[0] = (TValue)1;
}
*/
}
int *getBootloaderConfigData() {
auto config_data = (uint32_t)(UF2_BINFO->configValues);
if (config_data && (config_data & 3) == 0) {
auto p = (uint32_t *)config_data - 4;
if (p[0] == CFG_MAGIC0 && p[1] == CFG_MAGIC1)
return (int *)p + 4;
}
return NULL;
}
#define STM32_UUID ((uint32_t *)0x1FFF7A10)
static void writeHex(char *buf, uint32_t n) {
int i = 0;
int sh = 28;
while (sh >= 0) {
int d = (n >> sh) & 0xf;
buf[i++] = d > 9 ? 'A' + d - 10 : '0' + d;
sh -= 4;
}
buf[i] = 0;
}
void platform_usb_init() {
#if CONFIG_ENABLED(DEVICE_USB)
static char serial_number[25];
writeHex(serial_number, STM32_UUID[0]);
writeHex(serial_number + 8, STM32_UUID[1]);
writeHex(serial_number + 16, STM32_UUID[2]);
usb.stringDescriptors[2] = serial_number;
#endif
}
} // namespace pxt
void cpu_clock_init() {}
| 21.825 | 70 | 0.596793 | xmeow |
a99c2f0094db2c6470a5cf8f2190000e2c45e7be | 1,505 | cpp | C++ | Hubie/src/Hubie/Core/OS/MemoryManager.cpp | realjf/hubie | f4701eea2696e21f975103707ed1b1bf698f9cf2 | [
"Apache-2.0"
] | 1 | 2021-10-03T09:38:36.000Z | 2021-10-03T09:38:36.000Z | Hubie/src/Hubie/Core/OS/MemoryManager.cpp | realjf/hubie | f4701eea2696e21f975103707ed1b1bf698f9cf2 | [
"Apache-2.0"
] | null | null | null | Hubie/src/Hubie/Core/OS/MemoryManager.cpp | realjf/hubie | f4701eea2696e21f975103707ed1b1bf698f9cf2 | [
"Apache-2.0"
] | null | null | null | #include "hbpch.h"
#include "MemoryManager.h"
#include <iomanip>
namespace Hubie
{
MemoryManager* MemoryManager::s_Instance = nullptr;
MemoryManager::MemoryManager()
{
}
void MemoryManager::OnInit()
{
}
void MemoryManager::OnShutdown()
{
if (s_Instance)
delete s_Instance;
}
MemoryManager* MemoryManager::Get()
{
if (s_Instance == nullptr)
{
s_Instance = new MemoryManager();
}
return s_Instance;
}
std::string MemoryManager::BytesToString(int64_t bytes)
{
static const float gb = 1024 * 1024 * 1024;
static const float mb = 1024 * 1024;
static const float kb = 1024;
std::stringstream result;
if (bytes > gb)
result << std::fixed << std::setprecision(2) << (float)bytes / gb << " gb";
else if (bytes > mb)
result << std::fixed << std::setprecision(2) << (float)bytes / mb << " mb";
else if (bytes > kb)
result << std::fixed << std::setprecision(2) << (float)bytes / kb << " kb";
else
result << std::fixed << std::setprecision(2) << (float)bytes << " bytes";
return result.str();
}
void SystemMemoryInfo::Log()
{
std::string apm, tpm, avm, tvm;
apm = MemoryManager::BytesToString(availablePhysicalMemory);
tpm = MemoryManager::BytesToString(totalPhysicalMemory);
avm = MemoryManager::BytesToString(availableVirtualMemory);
tvm = MemoryManager::BytesToString(totalVirtualMemory);
HB_INFO("Memory Info:");
HB_INFO("\tPhysical Memory : {0} / {1}", apm, tpm);
HB_INFO("\tVirtual Memory : {0} / {1}: ", avm, tvm);
}
}
| 23.153846 | 78 | 0.660465 | realjf |
a9a06d6bc46edb45f71efd7a6970cfcb59eb061f | 1,966 | hpp | C++ | engine/magic/include/BeamShapeProcessor.hpp | prolog/shadow-of-the-wyrm | a1312c3e9bb74473f73c4e7639e8bd537f10b488 | [
"MIT"
] | 60 | 2019-08-21T04:08:41.000Z | 2022-03-10T13:48:04.000Z | engine/magic/include/BeamShapeProcessor.hpp | prolog/shadow-of-the-wyrm | a1312c3e9bb74473f73c4e7639e8bd537f10b488 | [
"MIT"
] | 3 | 2021-03-18T15:11:14.000Z | 2021-10-20T12:13:07.000Z | engine/magic/include/BeamShapeProcessor.hpp | prolog/shadow-of-the-wyrm | a1312c3e9bb74473f73c4e7639e8bd537f10b488 | [
"MIT"
] | 8 | 2019-11-16T06:29:05.000Z | 2022-01-23T17:33:43.000Z | #pragma once
#include <map>
#include <vector>
#include "SpellShapeProcessor.hpp"
// A class for processing beam-type spells.
class BeamShapeProcessor : public SpellShapeProcessor
{
public:
BeamShapeProcessor();
protected:
virtual std::pair<std::vector<std::pair<Coordinate, TilePtr>>, Animation> get_affected_tiles_and_animation_for_spell(MapPtr map, const Coordinate& caster_coord, const Direction d, const Spell& spell) override;
virtual bool should_beam_reflect() const;
virtual std::pair<std::vector<std::pair<Coordinate, TilePtr>>, MovementPath> create_beam(MapPtr map, const Spell& spell, const Coordinate& cur_coord, const Coordinate& caster_coord, const Direction d);
virtual std::pair<std::vector<std::pair<Coordinate, TilePtr>>, MovementPath> create_multi_beam(const std::vector<std::vector<std::pair<Coordinate, TilePtr>>>& per_beam_affected_tiles, const std::vector<MovementPath>& per_beam_movement_paths, const size_t largest_at, const size_t largest_mp);
virtual std::pair<Direction, Coordinate> get_new_beam_direction_after_impact(const Direction old_direction, const Coordinate& current_coord, MapPtr map, const Spell& spell);
std::pair<Direction, Coordinate> get_ne_reflection(const Coordinate& current_coord, MapPtr map, const Spell& spell);
std::pair<Direction, Coordinate> get_nw_reflection(const Coordinate& current_coord, MapPtr map, const Spell& spell);
std::pair<Direction, Coordinate> get_se_reflection(const Coordinate& current_coord, MapPtr map, const Spell& spell);
std::pair<Direction, Coordinate> get_sw_reflection(const Coordinate& current_coord, MapPtr map, const Spell& spell);
void initialize_reflection_maps();
void initialize_cardinal_reflection_map();
static std::map<Direction, Direction> cardinal_reflection_map;
};
using ReflectionMapIterator = std::map<Direction, Direction>::iterator;
using ReflectionMapCIterator = std::map<Direction, Direction>::const_iterator;
| 57.823529 | 296 | 0.788911 | prolog |
a9a29d3146c3ecccba5b43b432a880b39461c87f | 363 | hpp | C++ | testing_utilities/actions.hpp | tnuvoletta/Principia | 25cf2fb70c512cf86a842ed525f6ab10e57f937c | [
"MIT"
] | 2 | 2015-02-23T19:32:16.000Z | 2015-04-07T03:55:53.000Z | testing_utilities/actions.hpp | tnuvoletta/Principia | 25cf2fb70c512cf86a842ed525f6ab10e57f937c | [
"MIT"
] | null | null | null | testing_utilities/actions.hpp | tnuvoletta/Principia | 25cf2fb70c512cf86a842ed525f6ab10e57f937c | [
"MIT"
] | null | null | null | #pragma once
#include "gmock/gmock.h"
namespace principia {
namespace testing_utilities {
ACTION_TEMPLATE(FillUniquePtr,
// Note the comma between int and k:
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(ptr)) {
std::get<k>(args)->reset(ptr);
}
} // namespace testing_utilities
} // namespace principia
| 21.352941 | 52 | 0.647383 | tnuvoletta |
a9aa909e724c86ce177eaf1a0c1d27af97f54cb9 | 31,608 | cpp | C++ | pass/semantic/tests/lnast_semantic_test.cpp | pbonh/livehd | 7aba179a03ebe5f2705e0071c3247fe0a9c5c031 | [
"BSD-3-Clause"
] | 115 | 2019-09-28T13:39:41.000Z | 2022-03-24T11:08:53.000Z | pass/semantic/tests/lnast_semantic_test.cpp | pbonh/livehd | 7aba179a03ebe5f2705e0071c3247fe0a9c5c031 | [
"BSD-3-Clause"
] | 120 | 2018-05-16T23:11:09.000Z | 2019-09-25T18:52:49.000Z | pass/semantic/tests/lnast_semantic_test.cpp | pbonh/livehd | 7aba179a03ebe5f2705e0071c3247fe0a9c5c031 | [
"BSD-3-Clause"
] | 44 | 2019-09-28T07:53:21.000Z | 2022-02-13T23:21:12.000Z |
#include <cstdlib>
#include <iostream>
#include "fmt/color.h"
#include "fmt/core.h"
#include "fmt/format.h"
#include "fmt/printf.h"
#include "lnast.hpp"
#include "semantic_check.hpp"
int main(void) {
int line_num = 33;
int pos1 = 103;
int pos2 = 130;
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("\nAssign Operations Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
auto node_stmts = Lnast_node::create_stmts("stmts0", line_num, pos1, pos2);
auto node_assign = Lnast_node::create_assign("assign", line_num, pos1, pos2);
auto node_target = Lnast_node::create_ref("val", line_num, pos1, pos2);
auto node_const = Lnast_node::create_const("0d1023", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts = lnast->add_child(lnast->get_root(), node_stmts);
auto idx_assign = lnast->add_child(idx_stmts, node_assign);
lnast->add_child(idx_assign, node_target);
lnast->add_child(idx_assign, node_const);
// Warning: val
s.do_check(lnast);
fmt::print("End of Assign Operations Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("N-ary and U-nary Operations Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
auto node_stmts = Lnast_node::create_stmts("stmts", line_num, pos1, pos2);
auto node_minus = Lnast_node::create_minus("minus", line_num, pos1, pos2);
auto node_lhs1 = Lnast_node::create_ref("___a", line_num, pos1, pos2);
auto node_op1 = Lnast_node::create_ref("x", line_num, pos1, pos2);
auto node_op2 = Lnast_node::create_const("0d1", line_num, pos1, pos2);
auto node_plus = Lnast_node::create_plus("plus", line_num, pos1, pos2);
auto node_lhs2 = Lnast_node::create_ref("___b", line_num, pos1, pos2);
auto node_op3 = Lnast_node::create_ref("___a", line_num, pos1, pos2);
auto node_op4 = Lnast_node::create_const("0d3", line_num, pos1, pos2);
auto node_op5 = Lnast_node::create_const("0d2", line_num, pos1, pos2);
auto node_dpa = Lnast_node::create_dp_assign("dp_assign", line_num, pos1, pos2);
auto node_lhs3 = Lnast_node::create_ref("total", line_num, pos1, pos2);
auto node_op6 = Lnast_node::create_ref("___b", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts = lnast->add_child(lnast->get_root(), node_stmts);
auto idx_minus = lnast->add_child(idx_stmts, node_minus);
lnast->add_child(idx_minus, node_lhs1);
lnast->add_child(idx_minus, node_op1);
lnast->add_child(idx_minus, node_op2);
auto idx_plus = lnast->add_child(idx_stmts, node_plus);
lnast->add_child(idx_plus, node_lhs2);
lnast->add_child(idx_plus, node_op3);
lnast->add_child(idx_plus, node_op4);
lnast->add_child(idx_plus, node_op5);
auto idx_assign = lnast->add_child(idx_stmts, node_dpa);
lnast->add_child(idx_assign, node_lhs3);
lnast->add_child(idx_assign, node_op6);
// Warning: total
s.do_check(lnast);
fmt::print("End of N-ary and U-nary Operations Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("If Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_if = lnast->add_child(idx_stmts0, Lnast_node::create_if("if", line_num, pos1, pos2));
auto idx_gt = lnast->add_child(idx_if, Lnast_node::create_gt("gt", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_ref("___a", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_const("0d3", line_num, pos1, pos2));
lnast->add_child(idx_if, Lnast_node::create_const("true", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_if, Lnast_node::create_stmts("stmts1", line_num, pos1, pos2));
auto idx_plus = lnast->add_child(idx_stmts1, Lnast_node::create_plus("plus", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_ref("___b", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_const("0d1", line_num, pos1, pos2));
auto idx_assign = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_assign, Lnast_node::create_ref("___b", line_num, pos1, pos2));
// No Warnings
s.do_check(lnast);
fmt::print("End of If Operation Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("If Operation (inefficient)\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_if = lnast->add_child(idx_stmts0, Lnast_node::create_if("if", line_num, pos1, pos2));
auto idx_gt = lnast->add_child(idx_if, Lnast_node::create_gt("gt", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_ref("foo", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_const("0d3", line_num, pos1, pos2));
lnast->add_child(idx_if, Lnast_node::create_ref("a", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_if, Lnast_node::create_stmts("stmts1", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("b", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_const("0d1", line_num, pos1, pos2));
auto idx_assign2 = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("c", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("b", line_num, pos1, pos2));
auto idx_assign3 = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("c", line_num, pos1, pos2));
// Warning: c
s.do_check(lnast);
fmt::print("End of If Operation (inefficient)\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("If Operation (complex)\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_if = lnast->add_child(idx_stmts0, Lnast_node::create_if("if", line_num, pos1, pos2));
auto idx_gt = lnast->add_child(idx_if, Lnast_node::create_gt("gt", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_ref("___a", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_const("0d10", line_num, pos1, pos2));
lnast->add_child(idx_if, Lnast_node::create_ref("___a", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_if, Lnast_node::create_stmts("stmts1", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("b", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_const("0d3", line_num, pos1, pos2));
auto idx_lt = lnast->add_child(idx_if, Lnast_node::create_lt("lt", line_num, pos1, pos2));
lnast->add_child(idx_lt, Lnast_node::create_ref("___b", line_num, pos1, pos2));
lnast->add_child(idx_lt, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_lt, Lnast_node::create_const("0d1", line_num, pos1, pos2));
lnast->add_child(idx_if, Lnast_node::create_ref("___b", line_num, pos1, pos2));
auto idx_stmts2 = lnast->add_child(idx_if, Lnast_node::create_stmts("stmts2", line_num, pos1, pos2));
auto idx_assign2 = lnast->add_child(idx_stmts2, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("b", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_const("0d2", line_num, pos1, pos2));
auto idx_stmts3 = lnast->add_child(idx_if, Lnast_node::create_stmts("stmts3", line_num, pos1, pos2));
auto idx_assign3 = lnast->add_child(idx_stmts3, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("b", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_const("0d3", line_num, pos1, pos2));
// Warning: b
s.do_check(lnast);
fmt::print("End of If Operation (complex)\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("For Loop Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_tup = lnast->add_child(idx_stmts0, Lnast_node::create_tuple("tuple", line_num, pos1, pos2));
lnast->add_child(idx_tup, Lnast_node::create_ref("___b", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("___range_begin", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_const("0d0", line_num, pos1, pos2));
auto idx_assign2 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("___range_end", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_const("0d3", line_num, pos1, pos2));
auto idx_for = lnast->add_child(idx_stmts0, Lnast_node::create_for("for", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_for, Lnast_node::create_stmts("stmts1", line_num, pos1, pos2));
lnast->add_child(idx_for, Lnast_node::create_ref("i", line_num, pos1, pos2));
lnast->add_child(idx_for, Lnast_node::create_ref("___b", line_num, pos1, pos2));
auto idx_minus = lnast->add_child(idx_stmts1, Lnast_node::create_minus("minus", line_num, pos1, pos2));
lnast->add_child(idx_minus, Lnast_node::create_ref("___g", line_num, pos1, pos2));
lnast->add_child(idx_minus, Lnast_node::create_const("0d3", line_num, pos1, pos2));
lnast->add_child(idx_minus, Lnast_node::create_ref("i", line_num, pos1, pos2));
auto idx_select2 = lnast->add_child(idx_stmts1, Lnast_node::create_tuple_get("tup_get", line_num, pos1, pos2));
lnast->add_child(idx_select2, Lnast_node::create_ref("___f", line_num, pos1, pos2));
lnast->add_child(idx_select2, Lnast_node::create_ref("tup_bar", line_num, pos1, pos2));
lnast->add_child(idx_select2, Lnast_node::create_ref("___g", line_num, pos1, pos2));
auto idx_select1 = lnast->add_child(idx_stmts1, Lnast_node::create_tuple_add("tup_add", line_num, pos1, pos2));
lnast->add_child(idx_select1, Lnast_node::create_ref("tup_foo", line_num, pos1, pos2));
lnast->add_child(idx_select1, Lnast_node::create_ref("i", line_num, pos1, pos2));
lnast->add_child(idx_select1, Lnast_node::create_ref("___f", line_num, pos1, pos2));
// Warning: ___range_begin, ___range_end
s.do_check(lnast);
fmt::print("End of For Loop Operation Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("While Loop Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_while = lnast->add_child(idx_stmts0, Lnast_node::create_while("while", line_num, pos1, pos2));
lnast->add_child(idx_while, Lnast_node::create_ref("___a", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_while, Lnast_node::create_stmts("stmts", line_num, pos1, pos2));
auto idx_minus = lnast->add_child(idx_stmts1, Lnast_node::create_minus("minus", line_num, pos1, pos2));
lnast->add_child(idx_minus, Lnast_node::create_ref("___b", line_num, pos1, pos2));
lnast->add_child(idx_minus, Lnast_node::create_const("0d3", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("total", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("___b", line_num, pos1, pos2));
// Warning: total
s.do_check(lnast);
fmt::print("End of While Loop Operation Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("Func Def Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_func = lnast->add_child(idx_stmts0, Lnast_node::create_func_def("func_def", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("func_xor", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("condition", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_func, Lnast_node::create_stmts("stmts", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$a", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$b", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("%out", line_num, pos1, pos2));
auto idx_xor = lnast->add_child(idx_stmts1, Lnast_node::create_bit_xor("xor", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("___b", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("$a", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("$b", line_num, pos1, pos2));
auto idx_assign = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign, Lnast_node::create_ref("%out", line_num, pos1, pos2));
lnast->add_child(idx_assign, Lnast_node::create_ref("___b", line_num, pos1, pos2));
// Warning: func_xor
s.do_check(lnast);
fmt::print("End of Func Def Operation Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("Conditional Func Def Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_func = lnast->add_child(idx_stmts0, Lnast_node::create_func_def("stmts0", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("func_xor", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$valid", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_func, Lnast_node::create_stmts("stmts1", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$a", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$b", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("___a", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("%out", line_num, pos1, pos2));
auto idx_gt = lnast->add_child(idx_stmts1, Lnast_node::create_gt("gt", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_ref("___a", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_gt, Lnast_node::create_const("0d3", line_num, pos1, pos2));
auto idx_xor = lnast->add_child(idx_stmts1, Lnast_node::create_bit_xor("xor", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("___b", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("$a", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("$b", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("%out", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("___b", line_num, pos1, pos2));
// Warning: func_xor
s.do_check(lnast);
fmt::print("End of Conditional Func Def Operation Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("Implicit Func Call Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_func = lnast->add_child(idx_stmts0, Lnast_node::create_func_def("func_def", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("func_xor", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_const("true", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_func, Lnast_node::create_stmts("stmts1", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$a", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$b", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("%out", line_num, pos1, pos2));
auto idx_xor = lnast->add_child(idx_stmts1, Lnast_node::create_bit_xor("xor", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("___b", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("$a", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("$b", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign1", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("%out", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("___b", line_num, pos1, pos2));
auto idx_assign2 = lnast->add_child(idx_stmts0, Lnast_node::create_assign("assign2", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("func_xor", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("___a", line_num, pos1, pos2));
auto idx_tup = lnast->add_child(idx_stmts0, Lnast_node::create_tuple("tuple", line_num, pos1, pos2));
lnast->add_child(idx_tup, Lnast_node::create_ref("___d", line_num, pos1, pos2));
auto idx_assign3 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign3", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("null", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("$foo", line_num, pos1, pos2));
auto idx_assign4 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign4", line_num, pos1, pos2));
lnast->add_child(idx_assign4, Lnast_node::create_ref("null", line_num, pos1, pos2));
lnast->add_child(idx_assign4, Lnast_node::create_ref("$bar", line_num, pos1, pos2));
auto idx_fcall = lnast->add_child(idx_stmts0, Lnast_node::create_func_call("func_call", line_num, pos1, pos2));
lnast->add_child(idx_fcall, Lnast_node::create_ref("my_xor", line_num, pos1, pos2));
lnast->add_child(idx_fcall, Lnast_node::create_ref("func_xor", line_num, pos1, pos2));
lnast->add_child(idx_fcall, Lnast_node::create_ref("___d", line_num, pos1, pos2));
auto idx_dot = lnast->add_child(idx_stmts0, Lnast_node::create_tuple_get("dot", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_ref("%out", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_ref("my_xor", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_ref("out", line_num, pos1, pos2));
// Warning: None
s.do_check(lnast);
fmt::print("End of Implicit Func Call Operation Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("Explicit Func Call Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_func = lnast->add_child(idx_stmts0, Lnast_node::create_func_def("func_def", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("func_xor", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_const("true", line_num, pos1, pos2));
auto idx_stmts1 = lnast->add_child(idx_func, Lnast_node::create_stmts("stmts1", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$a", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("$b", line_num, pos1, pos2));
lnast->add_child(idx_func, Lnast_node::create_ref("%out", line_num, pos1, pos2));
auto idx_xor = lnast->add_child(idx_stmts1, Lnast_node::create_bit_xor("xor", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("___b", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("$a", line_num, pos1, pos2));
lnast->add_child(idx_xor, Lnast_node::create_ref("$b", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_stmts1, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("%out", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("___b", line_num, pos1, pos2));
auto idx_assign2 = lnast->add_child(idx_stmts0, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("func_xor", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("___a", line_num, pos1, pos2));
auto idx_tup = lnast->add_child(idx_stmts0, Lnast_node::create_tuple("tuple", line_num, pos1, pos2));
lnast->add_child(idx_tup, Lnast_node::create_ref("___d", line_num, pos1, pos2));
auto idx_assign3 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("a", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("$foo", line_num, pos1, pos2));
auto idx_assign4 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign4, Lnast_node::create_ref("b", line_num, pos1, pos2));
lnast->add_child(idx_assign4, Lnast_node::create_ref("$bar", line_num, pos1, pos2));
auto idx_fcall = lnast->add_child(idx_stmts0, Lnast_node::create_func_call("func_call", line_num, pos1, pos2));
lnast->add_child(idx_fcall, Lnast_node::create_ref("my_xor", line_num, pos1, pos2));
lnast->add_child(idx_fcall, Lnast_node::create_ref("func_xor", line_num, pos1, pos2));
lnast->add_child(idx_fcall, Lnast_node::create_ref("___d", line_num, pos1, pos2));
auto idx_dot = lnast->add_child(idx_stmts0, Lnast_node::create_tuple_get("dot", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_ref("%out", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_ref("my_xor", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_ref("out", line_num, pos1, pos2));
// Warning: a, b
s.do_check(lnast);
fmt::print("End of Implicit Func Call Operation Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("Tuple Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_plus = lnast->add_child(idx_stmts0, Lnast_node::create_plus("plus", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_ref("___d", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_ref("cat", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_const("0d2", line_num, pos1, pos2));
auto idx_tup = lnast->add_child(idx_stmts0, Lnast_node::create_tuple("tuple", line_num, pos1, pos2));
lnast->add_child(idx_tup, Lnast_node::create_ref("tup", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign1", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("foo", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_const("0d1", line_num, pos1, pos2));
auto idx_assign2 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign2", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("bar", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("___d", line_num, pos1, pos2));
// Warning: tup, foo, bar
s.do_check(lnast);
fmt::print("End of Tuple Operation Test\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("Tuple Concat Operation\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts0 = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_plus = lnast->add_child(idx_stmts0, Lnast_node::create_plus("plus", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_ref("___d", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_ref("cat", line_num, pos1, pos2));
lnast->add_child(idx_plus, Lnast_node::create_const("0d2", line_num, pos1, pos2));
auto idx_tup1 = lnast->add_child(idx_stmts0, Lnast_node::create_tuple("tup1", line_num, pos1, pos2));
lnast->add_child(idx_tup1, Lnast_node::create_ref("tup", line_num, pos1, pos2));
auto idx_assign1 = lnast->add_child(idx_tup1, Lnast_node::create_assign("assign1", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_ref("foo", line_num, pos1, pos2));
lnast->add_child(idx_assign1, Lnast_node::create_const("0d1", line_num, pos1, pos2));
auto idx_assign2 = lnast->add_child(idx_tup1, Lnast_node::create_assign("assign2", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("bar", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("___d", line_num, pos1, pos2));
auto idx_tup2 = lnast->add_child(idx_stmts0, Lnast_node::create_tuple("tup2", line_num, pos1, pos2));
lnast->add_child(idx_tup2, Lnast_node::create_ref("___f", line_num, pos1, pos2));
auto idx_assign3 = lnast->add_child(idx_tup2, Lnast_node::create_assign("assign3", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("null", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_const("0d4", line_num, pos1, pos2));
auto idx_assign4 = lnast->add_child(idx_tup2, Lnast_node::create_assign("assign4", line_num, pos1, pos2));
lnast->add_child(idx_assign4, Lnast_node::create_ref("null", line_num, pos1, pos2));
lnast->add_child(idx_assign4, Lnast_node::create_ref("dog", line_num, pos1, pos2));
auto idx_tconcat = lnast->add_child(idx_stmts0, Lnast_node::create_tuple_concat("tconcat", line_num, pos1, pos2));
lnast->add_child(idx_tconcat, Lnast_node::create_ref("___e", line_num, pos1, pos2));
lnast->add_child(idx_tconcat, Lnast_node::create_ref("tup", line_num, pos1, pos2));
lnast->add_child(idx_tconcat, Lnast_node::create_ref("___f", line_num, pos1, pos2));
auto idx_assign5 = lnast->add_child(idx_stmts0, Lnast_node::create_assign("assign5", line_num, pos1, pos2));
lnast->add_child(idx_assign5, Lnast_node::create_ref("tup", line_num, pos1, pos2));
lnast->add_child(idx_assign5, Lnast_node::create_ref("___e", line_num, pos1, pos2));
// Warning: foo, bar
s.do_check(lnast);
fmt::print("End of Tuple Concat Operation\n\n");
delete lnast;
}
{
Lnast* lnast = new Lnast();
Semantic_check s;
fmt::print("Attribute Operation Test\n\n");
auto idx_root = Lnast_node::create_top("top", line_num, pos1, pos2);
lnast->set_root(idx_root);
auto idx_stmts = lnast->add_child(lnast->get_root(), Lnast_node::create_stmts("stmts0", line_num, pos1, pos2));
auto idx_dot = lnast->add_child(idx_stmts, Lnast_node::create_tuple_add("stmts0", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_ref("foo", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_const("__bits", line_num, pos1, pos2));
lnast->add_child(idx_dot, Lnast_node::create_const("0d3", line_num, pos1, pos2));
auto idx_assign2 = lnast->add_child(idx_stmts, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_ref("foo", line_num, pos1, pos2));
lnast->add_child(idx_assign2, Lnast_node::create_const("0d7", line_num, pos1, pos2));
auto idx_tup = lnast->add_child(idx_stmts, Lnast_node::create_tuple("tuple", line_num, pos1, pos2));
lnast->add_child(idx_tup, Lnast_node::create_ref("___b", line_num, pos1, pos2));
auto idx_assign3 = lnast->add_child(idx_tup, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_ref("__bits", line_num, pos1, pos2));
lnast->add_child(idx_assign3, Lnast_node::create_const("0d10", line_num, pos1, pos2));
auto idx_as = lnast->add_child(idx_stmts, Lnast_node::create_assign("=", line_num, pos1, pos2));
lnast->add_child(idx_as, Lnast_node::create_ref("bar", line_num, pos1, pos2));
lnast->add_child(idx_as, Lnast_node::create_ref("___b", line_num, pos1, pos2));
auto idx_assign4 = lnast->add_child(idx_stmts, Lnast_node::create_assign("assign", line_num, pos1, pos2));
lnast->add_child(idx_assign4, Lnast_node::create_ref("bar", line_num, pos1, pos2));
lnast->add_child(idx_assign4, Lnast_node::create_const("0d123", line_num, pos1, pos2));
// Warning: bar
s.do_check(lnast);
fmt::print("End of Attribute Operation Test\n\n");
delete lnast;
}
return 0;
} | 52.244628 | 118 | 0.705834 | pbonh |
a9ac2c51d3b38ceed06eda19a04b8fa0fedd25e9 | 943 | cpp | C++ | levelRecord.cpp | nflorez89/MushroomGame | 717293dee8a9ba5ac71f3b604f17a78d72ddce1d | [
"CC-BY-3.0"
] | null | null | null | levelRecord.cpp | nflorez89/MushroomGame | 717293dee8a9ba5ac71f3b604f17a78d72ddce1d | [
"CC-BY-3.0"
] | null | null | null | levelRecord.cpp | nflorez89/MushroomGame | 717293dee8a9ba5ac71f3b604f17a78d72ddce1d | [
"CC-BY-3.0"
] | null | null | null | #include "levelRecord.h"
//=============================================================================
// constructor
//=============================================================================
LevelRecord::LevelRecord(float l_unitHp, float l_unitAccuracy, float l_unitEvasion, float l_unitDamage, int l_unitMvmtRange, int l_unitAtkRange, int l_spreadRadius, int l_psnEffectiveness, int l_upgradeCost, int l_spawnCost)
{
unitHp = l_unitHp;
unitAccuracy = l_unitAccuracy;
unitEvasion = l_unitEvasion;
unitDamage = l_unitDamage;
unitMvmtRange = l_unitMvmtRange;
unitAtkRange = l_unitAtkRange;
spreadRadius = l_spreadRadius;
psnEffectiveness = l_psnEffectiveness;
upgradeCost = l_upgradeCost;
spawnCost = l_spawnCost;
}
//=============================================================================
// destructor
//=============================================================================
LevelRecord::~LevelRecord()
{
}
| 33.678571 | 224 | 0.528102 | nflorez89 |
a9ad6de45db08c78be5a44b41d8857a7ffad7248 | 2,085 | cpp | C++ | codeforces/F - Guess Divisors Count/Accepted.cpp | kzvd4729/Problem-Solving | 13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab | [
"MIT"
] | 1 | 2022-02-11T16:55:36.000Z | 2022-02-11T16:55:36.000Z | codeforces/F - Guess Divisors Count/Accepted.cpp | kzvd4729/Problem-Solving | 13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab | [
"MIT"
] | null | null | null | codeforces/F - Guess Divisors Count/Accepted.cpp | kzvd4729/Problem-Solving | 13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab | [
"MIT"
] | null | null | null | /****************************************************************************************
* @author: kzvd4729 created: May/17/2020 12:25
* solution_verdict: Accepted language: GNU C++14
* run_time: 187 ms memory_used: 4800 KB
* problem: https://codeforces.com/contest/1355/problem/F
****************************************************************************************/
#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>
#define long long long
using namespace std;
const long N=1e5;
long vs[N+2];vector<long>pr;
void seive()
{
for(long i=2;i<=N;i++)
{
if(vs[i])continue;pr.push_back(i);
for(long j=i;j<=N;j+=i)vs[j]=1;
}
}
const long R=1e18;
bool isSafe(long a,long b)
{
return R/a>=b;
}
long mx(long p)
{
long ret=1;
while(ret*p<=1e9)ret*=p;
return ret;
}
int main()
{
//ios_base::sync_with_stdio(0);cin.tie(0);
seive();int t;cin>>t;
while(t--)
{
long q=22-5,pt=0;vector<long>ok;
while(q--)
{
long ask=1;
while(isSafe(ask,pr[pt]))ask*=pr[pt++];
cout<<"? "<<ask<<endl;
long gcd;cin>>gcd;
for(auto x:pr)if(gcd%x==0)ok.push_back(x);
}
long d=1;
for(int i=1;i<ok.size();i+=2)
{
long ask=1;
ask*=mx(ok[i-1]);ask*=mx(ok[i]);
cout<<"? "<<ask<<endl;
long gcd;cin>>gcd;long cnt=0;
while(gcd%ok[i-1]==0)gcd/=ok[i-1],cnt++;
d*=(cnt+1);cnt=0;
while(gcd%ok[i]==0)gcd/=ok[i],cnt++;
d*=(cnt+1);
}
if(ok.size()%2)
{
long ask=1;
ask*=mx(ok.back());
cout<<"? "<<ask<<endl;
long gcd;cin>>gcd;long cnt=0;
while(gcd%ok.back()==0)gcd/=ok.back(),cnt++;
d*=(cnt+1);
}
cout<<"! "<<max(d*2,8LL)<<endl;
}
return 0;
} | 25.120482 | 111 | 0.469065 | kzvd4729 |
a9ade8d0947a81467183f9cac761079280ea6cc9 | 7,680 | cpp | C++ | uebung_8/AStarPlanner.cpp | jWeb94/kit_robotics_1_ws1819 | 8400cb3484e38092cf87b42945e85bdfa3a3a3db | [
"WTFPL"
] | null | null | null | uebung_8/AStarPlanner.cpp | jWeb94/kit_robotics_1_ws1819 | 8400cb3484e38092cf87b42945e85bdfa3a3a3db | [
"WTFPL"
] | null | null | null | uebung_8/AStarPlanner.cpp | jWeb94/kit_robotics_1_ws1819 | 8400cb3484e38092cf87b42945e85bdfa3a3a3db | [
"WTFPL"
] | null | null | null | #include "AStarPlanner.h"
using namespace std;
AStarPlanner::AStarPlanner(VirtualRobot::RobotPtr robot, VirtualRobot::SceneObjectSetPtr obstacles, float cellSize)
: Planner2D(robot, obstacles), cellSize(cellSize)
{
// Standart-Konstruktor
}
void AStarPlanner::createUniformGrid()
{
//+1 for explicit rounding up
size_t cols = (sceneBoundsMax.x() - sceneBoundsMin.x()) / cellSize + 1;
size_t rows = (sceneBoundsMax.y() - sceneBoundsMin.y()) / cellSize + 1;
// build objects in grid
for (size_t r = 0; r < rows; r++) {
grid.push_back(std::vector<NodePtr>(cols));
for (size_t c = 0; c < cols; c++) {
Eigen::Vector2f pos;
pos.x() = sceneBoundsMin.x() + c * cellSize + cellSize / 2;
pos.y() = sceneBoundsMin.y() + r * cellSize + cellSize / 2;
grid[r][c] = NodePtr(new Node(pos));
}
}
//init valid successors
for (size_t r = 0; r < rows; r++) {
for (size_t c = 0; c < cols; c++) {
NodePtr candidate = grid[r][c];
if (!fulfillsConstraints(candidate)) continue;
//add the valid node as successor to all its neighbors
for (int nR = -1; nR <= 1; nR++) {
for (int nC = -1; nC <= 1; nC++) {
const int neighborIndexX = c + nC;
const int neighborIndexY = r + nR;
if (neighborIndexX < 0 || neighborIndexY < 0 || (nR == 0 && nC == 0)) continue;
grid[neighborIndexY][neighborIndexX]->successors.push_back(candidate);
}
}
}
}
}
bool AStarPlanner::fulfillsConstraints(NodePtr n)
{
if (!obstacles) return true;
robotCollisionModel->setGlobalPose(positionToMatrix4f(n->position));
// check for collisions
if (!obstacles) return true;
robotCollisionModel->setGlobalPose(positionToMatrix4f(n->position));
Eigen::Vector3f P1, P2;
int id1, id2;
for (size_t i = 0; i < obstacles->getSize(); i++) {
float dist = VirtualRobot::CollisionChecker::getGlobalCollisionChecker()->calculateDistance(robotCollisionModel, obstacles->getSceneObject(i)->getCollisionModel(), P1, P2, &id1, &id2);
if (dist <= cellSize / 2) return false;
}
return n->position.x() >= sceneBoundsMin.x() && n->position.x() <= sceneBoundsMax.x() &&
n->position.y() >= sceneBoundsMin.y() && n->position.y() <= sceneBoundsMax.y();
}
NodePtr AStarPlanner::closestNode(Eigen::Vector2f v)
{
size_t r = (v.y() - cellSize / 2 - sceneBoundsMin.y()) / cellSize;
size_t c = (v.x() - cellSize / 2 - sceneBoundsMin.x()) / cellSize;
return grid[r][c];
}
float AStarPlanner::heuristic(NodePtr n1, NodePtr n2)
{
return (n1->position - n2->position).norm();
}
std::vector<Eigen::Vector2f> AStarPlanner::plan(Eigen::Vector2f start, Eigen::Vector2f goal)
{
grid.clear();
std::vector<Eigen::Vector2f> result;
if (!robot || !robot->hasRobotNode(robotColModelName) || !robot->getRobotNode(robotColModelName)->getCollisionModel())
{
cout << "No collision model with name " << robotColModelName << " found..." << endl;
return result;
}
robotCollisionModel = robot->getRobotNode(robotColModelName)->getCollisionModel()->clone();
createUniformGrid();
NodePtr v_start = closestNode(start); // Finde den naechsten Knoten zur Startposition des Roboters, da der Graph des Problemgebiets fuer A-Star vorgegeben ist
NodePtr v_goal = closestNode(goal); // Analog beim Zielknoten
// Deklarationen (ohne Initialisierung) -> Datentypen sind fuer die Beispielimplementierung vorgegeben
// Open set O: nodes to visit
std::set<NodePtr> openSet;
// Closed set C: nodes which have been expanded/visited
std::set<NodePtr> closedSet;
// Accumulated costs g(v)
std::map<NodePtr, float> g; // std::map ist vergleichbar mit Python Dict -> Assoziative Datenstruktur nach Key, Value
// Key = NodePtr, Value = float
// Heuristic h(v)
std::map<NodePtr, float> h;
// Expected cost f(v) = g(v) + h(v)
///////////////////////////////////////////////
// TODO: INSERT CODE HERE
// Pseudo Code A-Star:
/*
O = {v_start}
C = {}
g(v_i) = INF, 1 <= i <= x
g(v_start) = 0
while (O != {}):
{
Finde Knoten v_i zum expandieren:
argmin v_i in O (f(v_i) = g(v_i) + h(v_i))
if v_i == v_goal
{
done
}
o.remove(v_i)
C.add(v_i)
Update alle Nachfolger v_j von v_i
{
if v_j in C:
naechstes v_j
else:
o.add(v_j)
if Weg zu v_j ist ueber v_i kleiner als bisher ( g(v_i) + cost(v_i, v_j) < g(v_j) ):
Update g(v_j) = g(v_i) + cost(v_i, v_j)
h(v_j) = heuristic(v_j, v_goal)
pred(v_j) = v_i setze neuen kuerzesten vorgaenger von v_j ueber v_i
}
}
*/
openSet.insert(v_start)
// closedSet ist ohnehin leer initialisiert, da ich nichts zur Initialisierung verwendet habe und nur der Konstruktor aufgerufen wurde
// g wird leer gelassen und bei Verwendung der Werte beschrieben. Das ist effizienter
g[v_start] = 0; // Kosten zum Startknoten sind 0
h[v_start] = heuristic(v_start, v_goal); // Berechne Kosten bis zum Ziel des Startknotens. Damit ist der Wert einmal geschrieben und muss spaeter nicht innerhalb einer Schleife bestimmt werden
while ( !openSet.empty() )
{
// Finde den naechsten Knoten zum expandieren.
// Dazu muessen wir das minimale f[v_i] finden
// Das koennte man effizienter umsetzen, wenn man mit Pointern/Datenstrukturen auf dem Heap arbeitet
NodePtr v_i;
float min_f = FLT_MAX;
for ( NodePtr v : openSet )
{
float f = g[v] + h[v];
if ( f < min_f )
{
min_f = f;
v_i = v;
}
}
if ( v_i == v_goal )
{
break; // Brich (innere) Schleife ab
}
openSet.erease(v_i);
closedSet.insert(v_i);
for ( NodePtr v_j : v_i->successors )
{
// NodePtr ist ein Iterator-Objekt
// Der Klasse von v_i hat alle Nachfolgeknoten in der Membervariable succuessors.
// -> ist der C++ Zugriff auf Klassenmember mit einem Pointer-Objekt
if ( closedSet.count(v_j) ) // count zaehlt, wie viele Eintraege es in der Map gibt
{
// Wenn schon ein Eintrag fuer v_j existiert, wird die Berechnung uebersprungen
continue; // naechste Schleifeniteration
}
openSet.insert(v_j);
// Ueberpruefe, ob es einen kuerzeren Pfad zu v_j gibt:
float g_new = g[v_i] + heuristic(v_i, v_j); // Heuristik: Euklidische Distanz
float g_old = g.count(v_j) ? g[v_j] : FLT_MAX; // ? bedeutet: Nimm den ersten Eintrag hinter dem ?, wenn vor dem ? True entsteht, ansonsten den Eintag hinter dem ?
if ( g_new < g_old )
{
g[v_j] = g_new;
h[v_j] = heuristic(v_j, v_goal); // Um nicht immer neu berechnen zu muessen
v_j->predecessor = v_i;
}
}
}
///////////////////////////////////////////////
//found solution, now retrieve path from goal to start
if (v_goal)
result = v_goal->traversePredecessors();
//since the graph was traversed from goal to start, we have to reverse the order
std::reverse(result.begin(), result.end());
return result;
}
| 36.571429 | 199 | 0.582552 | jWeb94 |
a9aff25e65c9977c6ba5a96d517b0ee81d144ffb | 1,350 | cc | C++ | src/mesytec-mvlc/util/protected.test.cc | flueke/mesytec-mvlc | 48086db8f7b63fd8adb6215a5d3fdbeaa56d567d | [
"BSL-1.0"
] | null | null | null | src/mesytec-mvlc/util/protected.test.cc | flueke/mesytec-mvlc | 48086db8f7b63fd8adb6215a5d3fdbeaa56d567d | [
"BSL-1.0"
] | 3 | 2021-07-15T10:10:19.000Z | 2021-08-05T13:47:36.000Z | src/mesytec-mvlc/util/protected.test.cc | flueke/mesytec-mvlc | 48086db8f7b63fd8adb6215a5d3fdbeaa56d567d | [
"BSL-1.0"
] | 5 | 2020-09-22T10:21:25.000Z | 2022-02-17T15:06:14.000Z | #include "gtest/gtest.h"
#include <chrono>
#include <future>
#include <thread>
#include "mesytec-mvlc/util/protected.h"
using namespace mesytec::mvlc;
struct Object
{
int value = 0u;
};
TEST(util_protected, ProtectedWaitableNotify)
{
// unlimited wait, immedate async modification of the object
{
WaitableProtected<Object> wo({});
auto f = std::async(
std::launch::async,
[&wo] ()
{
wo.access()->value = 42;
});
auto oa = wo.wait([] (const Object &o) { return o.value != 0u; });
ASSERT_EQ(oa->value, 42u);
}
{
WaitableProtected<Object> wo({});
// limited wait, delayed modification of the object
auto f = std::async(
std::launch::async,
[&wo] ()
{
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
wo.access()->value = 42;
});
{
auto oa = wo.wait_for(
std::chrono::milliseconds(100),
[] (const Object &o) { return o.value != 0u; });
ASSERT_EQ(oa->value, 0u);
}
// unlimited wait
{
auto oa = wo.wait([] (const Object &o) { return o.value != 0u; });
ASSERT_EQ(oa->value, 42u);
}
}
}
| 22.131148 | 78 | 0.491852 | flueke |
a9b7f18d49684be41eac28923e1d68882bd391dc | 1,724 | cpp | C++ | ERP/inventorycontent.cpp | DSP-Automation/ERP | 90626c3f13af2b49884f500568dc909a31fe3751 | [
"Apache-2.0"
] | null | null | null | ERP/inventorycontent.cpp | DSP-Automation/ERP | 90626c3f13af2b49884f500568dc909a31fe3751 | [
"Apache-2.0"
] | null | null | null | ERP/inventorycontent.cpp | DSP-Automation/ERP | 90626c3f13af2b49884f500568dc909a31fe3751 | [
"Apache-2.0"
] | null | null | null | #include "inventorycontent.h"
inventoryContent::inventoryContent(QWidget *parent) : QWidget(parent)
{
}
inventoryContent::~inventoryContent()
{
}
int inventoryContent::readItemsFromDatabase(QString server, QString username, QString password, QString database)
{
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName(server);
db.setDatabaseName(database);
db.setUserName(username);
db.setPassword(password);
databaseConnectionOpen = db.open();
if(!databaseConnectionOpen)
{
dh.writeDebugMessageWithLocation("problem opening databaseconnection please check the connection info");
return -1;
}
int i = 0;
QSqlQuery query;
query.prepare("GET * FROM items");
query.exec();
while(query.next())
{
int j=0;
QSqlQuery query1;
QVector<inventorySupplier * > tempVector;
query1.prepare("GET lsi.id, s.name, lsi.amount, sli.price_buy, sli.price_sell FROM link_supplier_item as lsi LEFT JOIN suppliers as s on lsi.id = s.id WHERE lsi.id = :id");
query1.bindValue(":id", query.value(0));
query.exec();
while(query1.next())
{
inventorySupplier *temp = new inventorySupplier(query1.value(0).toInt(),query1.value(1).toString(),query1.value(2).toInt(), query1.value(3).toFloat(),query1.value(4).toFloat());
tempVector.push_back(temp);
j++;
}
inventoryItem *tempItem = new inventoryItem(query.value(0).toInt(), query.value(1).toString(), query.value(2).toString(),query.value(3).toString(),query.value(4).toString(),query.value(5).toString(),query.value(6).toString(),tempVector);
itemVector.push_back(tempItem);
i++;
}
}
| 34.48 | 246 | 0.662413 | DSP-Automation |
a9b8f0dd1244cd7717a0ae2194cb5cbbc5a1005e | 6,523 | cc | C++ | lang_id/common/flatbuffers/model-utils.cc | yangzhigang1999/libtextclassifier | 4c965f1c12b3c7a37f6126cef737a8fe33f4677c | [
"Apache-2.0"
] | null | null | null | lang_id/common/flatbuffers/model-utils.cc | yangzhigang1999/libtextclassifier | 4c965f1c12b3c7a37f6126cef737a8fe33f4677c | [
"Apache-2.0"
] | null | null | null | lang_id/common/flatbuffers/model-utils.cc | yangzhigang1999/libtextclassifier | 4c965f1c12b3c7a37f6126cef737a8fe33f4677c | [
"Apache-2.0"
] | 1 | 2021-03-20T03:40:21.000Z | 2021-03-20T03:40:21.000Z | // Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "lang_id/common/flatbuffers/model-utils.h"
#include <string.h>
#include <string>
#include "lang_id/common/lite_base/logging.h"
#include "lang_id/common/math/checksum.h"
namespace libtextclassifier3 {
namespace saft_fbs {
bool ClearlyFailsChecksum(const Model &model) {
if (!flatbuffers::IsFieldPresent(&model, Model::VT_CRC32)) {
SAFTM_LOG(WARNING)
<< "No CRC32, most likely an old model; skip CRC32 check";
return false;
}
const mobile::uint32 expected_crc32 = model.crc32();
const mobile::uint32 actual_crc32 = ComputeCrc2Checksum(&model);
if (actual_crc32 != expected_crc32) {
SAFTM_LOG(ERROR) << "Corrupt model: different CRC32: " << actual_crc32
<< " vs " << expected_crc32;
return true;
}
SAFTM_DLOG(INFO) << "Successfully checked CRC32 " << actual_crc32;
return false;
}
const Model *GetVerifiedModelFromBytes(const char *data, size_t num_bytes) {
if ((data == nullptr) || (num_bytes == 0)) {
SAFTM_LOG(ERROR) << "GetModel called on an empty sequence of bytes";
return nullptr;
}
const uint8_t *start = reinterpret_cast<const uint8_t *>(data);
flatbuffers::Verifier verifier(start, num_bytes);
if (!VerifyModelBuffer(verifier)) {
SAFTM_LOG(ERROR) << "Not a valid Model flatbuffer";
return nullptr;
}
const Model *model = GetModel(start);
if (model == nullptr) {
return nullptr;
}
if (ClearlyFailsChecksum(*model)) {
return nullptr;
}
return model;
}
const ModelInput *GetInputByName(const Model *model, const std::string &name) {
if (model == nullptr) {
SAFTM_LOG(ERROR) << "GetInputByName called with model == nullptr";
return nullptr;
}
const auto *inputs = model->inputs();
if (inputs == nullptr) {
// We should always have a list of inputs; maybe an empty one, if no inputs,
// but the list should be there.
SAFTM_LOG(ERROR) << "null inputs";
return nullptr;
}
for (const ModelInput *input : *inputs) {
if (input != nullptr) {
const flatbuffers::String *input_name = input->name();
if (input_name && input_name->str() == name) {
return input;
}
}
}
return nullptr;
}
mobile::StringPiece GetInputBytes(const ModelInput *input) {
if ((input == nullptr) || (input->data() == nullptr)) {
SAFTM_LOG(ERROR) << "ModelInput has no content";
return mobile::StringPiece(nullptr, 0);
}
const flatbuffers::Vector<uint8_t> *input_data = input->data();
if (input_data == nullptr) {
SAFTM_LOG(ERROR) << "null input data";
return mobile::StringPiece(nullptr, 0);
}
return mobile::StringPiece(reinterpret_cast<const char *>(input_data->data()),
input_data->size());
}
bool FillParameters(const Model &model, mobile::TaskContext *context) {
if (context == nullptr) {
SAFTM_LOG(ERROR) << "null context";
return false;
}
const auto *parameters = model.parameters();
if (parameters == nullptr) {
// We should always have a list of parameters; maybe an empty one, if no
// parameters, but the list should be there.
SAFTM_LOG(ERROR) << "null list of parameters";
return false;
}
for (const ModelParameter *p : *parameters) {
if (p == nullptr) {
SAFTM_LOG(ERROR) << "null parameter";
return false;
}
if (p->name() == nullptr) {
SAFTM_LOG(ERROR) << "null parameter name";
return false;
}
const std::string name = p->name()->str();
if (name.empty()) {
SAFTM_LOG(ERROR) << "empty parameter name";
return false;
}
if (p->value() == nullptr) {
SAFTM_LOG(ERROR) << "null parameter name";
return false;
}
context->SetParameter(name, p->value()->str());
}
return true;
}
namespace {
// Updates |*crc| with the information from |s|. Auxiliary for
// ComputeCrc2Checksum.
//
// The bytes from |info| are also used to update the CRC32 checksum. |info|
// should be a brief tag that indicates what |s| represents. The idea is to add
// some structure to the information that goes into the CRC32 computation.
template <typename T>
void UpdateCrc(mobile::Crc32 *crc, const flatbuffers::Vector<T> *s,
mobile::StringPiece info) {
crc->Update("|");
crc->Update(info.data(), info.size());
crc->Update(":");
if (s == nullptr) {
crc->Update("empty");
} else {
crc->Update(reinterpret_cast<const char *>(s->data()),
s->size() * sizeof(T));
}
}
} // namespace
mobile::uint32 ComputeCrc2Checksum(const Model *model) {
// Implementation note: originally, I (salcianu@) thought we can just compute
// a CRC32 checksum of the model bytes. Unfortunately, the expected checksum
// is there too (and because we don't control the flatbuffer format, we can't
// "arrange" for it to be placed at the head / tail of those bytes). Instead,
// we traverse |model| and feed into the CRC32 computation those parts we are
// interested in (which excludes the crc32 field).
//
// Note: storing the checksum outside the Model would be too disruptive for
// the way we currently ship our models.
mobile::Crc32 crc;
if (model == nullptr) {
return crc.Get();
}
crc.Update("|Parameters:");
const auto *parameters = model->parameters();
if (parameters != nullptr) {
for (const ModelParameter *p : *parameters) {
if (p != nullptr) {
UpdateCrc(&crc, p->name(), "name");
UpdateCrc(&crc, p->value(), "value");
}
}
}
crc.Update("|Inputs:");
const auto *inputs = model->inputs();
if (inputs != nullptr) {
for (const ModelInput *input : *inputs) {
if (input != nullptr) {
UpdateCrc(&crc, input->name(), "name");
UpdateCrc(&crc, input->type(), "type");
UpdateCrc(&crc, input->sub_type(), "sub-type");
UpdateCrc(&crc, input->data(), "data");
}
}
}
return crc.Get();
}
} // namespace saft_fbs
} // namespace nlp_saft
| 32.452736 | 80 | 0.649394 | yangzhigang1999 |
a9bce2b9aa4174df1695768a22fe3c3b51b2547b | 15,058 | cpp | C++ | Source/ComponentCollider.cpp | Project-3-UPC-DDV-BCN/Project3 | 3fb345ce49485ccbc7d03fb320623df6114b210c | [
"MIT"
] | 10 | 2018-01-16T16:18:42.000Z | 2019-02-19T19:51:45.000Z | Source/ComponentCollider.cpp | Project-3-UPC-DDV-BCN/Project3 | 3fb345ce49485ccbc7d03fb320623df6114b210c | [
"MIT"
] | 136 | 2018-05-10T08:47:58.000Z | 2018-06-15T09:38:10.000Z | Source/ComponentCollider.cpp | Project-3-UPC-DDV-BCN/Project3 | 3fb345ce49485ccbc7d03fb320623df6114b210c | [
"MIT"
] | 1 | 2018-06-04T17:18:40.000Z | 2018-06-04T17:18:40.000Z | #include "ComponentCollider.h"
#include "GameObject.h"
#include "ComponentRigidBody.h"
#include "Application.h"
#include "ModulePhysics.h"
#include "ComponentMeshRenderer.h"
#include "MathGeoLib/AABB.h"
#include "Mesh.h"
#include "MathGeoLib/Quat.h"
#include "PhysicsMaterial.h"
#include "ModuleResources.h"
#include "ComponentTransform.h"
ComponentCollider::ComponentCollider(GameObject* attached_gameobject, ColliderType type)
{
SetGameObject(attached_gameobject);
collider_type = type;
std::string name;
capsule_direction = CapsuleDirection::XAxis;
collider_shape = nullptr;
convex_mesh = nullptr;
triangle_mesh = nullptr;
geo_triangle_mesh = nullptr;
geo_convex_mesh = nullptr;
is_convex = false;
phys_material = nullptr;
rb_is_released = false;
rigidbody = nullptr;
rigidbody = (ComponentRigidBody*)attached_gameobject->GetComponent(Component::CompRigidBody);
ComponentMeshRenderer* mesh_renderer = (ComponentMeshRenderer*)attached_gameobject->GetComponent(Component::CompMeshRenderer);
ComponentTransform* transform = (ComponentTransform*)attached_gameobject->GetComponent(Component::CompTransform);
AABB box;
box.SetFromCenterAndSize({ 0,0,0 }, { 1,1,1 });
if (mesh_renderer != nullptr)
{
box = mesh_renderer->bounding_box;
}
if (rigidbody != nullptr)
{
collider_material = App->physics->CreateMaterial(0.6, 0.6, 0);
switch (type)
{
case ComponentCollider::BoxCollider:
{
physx::PxBoxGeometry geo_box(box.HalfSize().x, box.HalfSize().y, box.HalfSize().z);
collider_shape = App->physics->CreateShape(*rigidbody->GetRigidBody(), geo_box, *collider_material);
SetColliderCenter(float3::zero);
SetType(ComponentType::CompBoxCollider);
name += "Box_";
}
break;
case ComponentCollider::SphereCollider:
{
physx::PxSphereGeometry geo_sphere(box.MinimalEnclosingSphere().r);
collider_shape = App->physics->CreateShape(*rigidbody->GetRigidBody(), geo_sphere, *collider_material);
SetColliderCenter(float3::zero);
SetType(ComponentType::CompSphereCollider);
name += "Sphere_";
}
break;
case ComponentCollider::CapsuleCollider:
{
physx::PxCapsuleGeometry geo_capsule(box.MinimalEnclosingSphere().r, box.HalfSize().y);
collider_shape = App->physics->CreateShape(*rigidbody->GetRigidBody(), geo_capsule, *collider_material);
SetColliderCenter(float3::zero);
SetType(ComponentType::CompCapsuleCollider);
name += "Capsule_";
}
break;
case ComponentCollider::MeshCollider:
{
rigidbody->SetKinematic(true);
Mesh* collider_mesh = mesh_renderer->GetMesh();
triangle_mesh = App->physics->CreateTriangleMesh(collider_mesh);
geo_triangle_mesh = new physx::PxTriangleMeshGeometry(triangle_mesh);
convex_mesh = App->physics->CreateConvexMesh(collider_mesh);
geo_convex_mesh = new physx::PxConvexMeshGeometry(convex_mesh);
geo_convex_mesh->meshFlags.set(physx::PxConvexMeshGeometryFlag::eTIGHT_BOUNDS);
ChangeMeshToConvex(false);
SetType(ComponentType::CompMeshCollider);
name += "Mesh_";
float3 global = transform->GetGlobalPosition();
if (!attached_gameobject->IsRoot())
{
ComponentTransform* parent_transform = (ComponentTransform*)attached_gameobject->GetParent()->GetComponent(Component::CompTransform);
if (parent_transform)
{
float3 final_pos = parent_transform->GetGlobalPosition() - global;
global += final_pos;
rigidbody->SetPosition(global);
}
}
else
{
rigidbody->SetPosition(global);
}
collider_shape = App->physics->CreateShape(*rigidbody->GetRigidBody(), *geo_triangle_mesh, *collider_material);
}
break;
case ComponentCollider::TerrainCollider:
{
name += "Terrain_";
}
break;
default:
break;
}
name += "Collider ";
SetName(name);
}
SetTrigger(false);
if (collider_shape != nullptr)
{
collider_shape->userData = this;
//rigidbody->GetRigidBody()->setActorFlag(physx::PxActorFlag::eDISABLE_SIMULATION, true);
}
SetActive(true);
}
ComponentCollider::~ComponentCollider()
{
/*if (triangle_mesh)
{
triangle_mesh->release();
}
if (convex_mesh)
{
convex_mesh->release();
}*/
//collider_material->release();
//collider_shape->release();
if (rigidbody != nullptr && !rb_is_released)
{
rigidbody->RemoveShape(*GetColliderShape());
}
else
{
rigidbody = nullptr;
}
RELEASE(phys_material);
RELEASE(geo_triangle_mesh);
RELEASE(geo_convex_mesh);
}
ComponentCollider::ColliderType ComponentCollider::GetColliderType() const
{
return collider_type;
}
void ComponentCollider::SetColliderMaterial(PhysicsMaterial * mat)
{
collider_material->setStaticFriction(mat->GetStaticFriction());
collider_material->setDynamicFriction(mat->GetDynamicFriction());
collider_material->setRestitution(mat->GetRestitution());
collider_material->setFrictionCombineMode((physx::PxCombineMode::Enum)mat->GetFrictionMode());
collider_material->setRestitutionCombineMode((physx::PxCombineMode::Enum)mat->GetRestitutionMode());
phys_material = mat;
}
PhysicsMaterial * ComponentCollider::GetColliderMaterial() const
{
return phys_material;
}
void ComponentCollider::SetColliderShape(physx::PxShape * shape)
{
collider_shape = shape;
}
physx::PxShape * ComponentCollider::GetColliderShape() const
{
return collider_shape;
}
void ComponentCollider::SetTrigger(bool trigger)
{
bool can_change = true;
if (trigger)
{
if (collider_shape != nullptr && IsActive() && collider_shape->getGeometryType() == physx::PxGeometryType::eTRIANGLEMESH)
{
can_change = false;
CONSOLE_ERROR("Non-Convex mesh collider can't be trigger. If you need to set it as trigger, set it convex");
}
}
if (can_change)
{
is_trigger = trigger;
if (is_trigger)
{
if (collider_shape != nullptr && collider_shape->getFlags().isSet(physx::PxShapeFlag::eSIMULATION_SHAPE))
{
collider_shape->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE, !trigger);
collider_shape->setFlag(physx::PxShapeFlag::eTRIGGER_SHAPE, trigger);
}
}
else
{
if (collider_shape != nullptr && collider_shape->getFlags().isSet(physx::PxShapeFlag::eTRIGGER_SHAPE))
{
collider_shape->setFlag(physx::PxShapeFlag::eTRIGGER_SHAPE, trigger);
collider_shape->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE, !trigger);
}
}
}
}
bool ComponentCollider::IsTrigger() const
{
return is_trigger;
}
void ComponentCollider::SetColliderCenter(float3 center)
{
if (collider_shape != nullptr)
{
physx::PxTransform transform = collider_shape->getLocalPose();
transform.p.x = center.x;
transform.p.y = center.y;
transform.p.z = center.z;
collider_shape->setLocalPose(transform);
}
}
float3 ComponentCollider::GetColliderCenter() const
{
if (collider_shape != nullptr)
{
physx::PxTransform transform = collider_shape->getLocalPose();
float3 pos(transform.p.x, transform.p.y, transform.p.z);
return pos;
}
else
return float3::zero;
}
void ComponentCollider::SetBoxSize(float3 size)
{
if (collider_shape != nullptr)
{
if (collider_type == ColliderType::BoxCollider)
{
physx::PxBoxGeometry geo_box;
if (collider_shape->getBoxGeometry(geo_box))
{
geo_box.halfExtents.x = size.x * 0.5f;
geo_box.halfExtents.y = size.y * 0.5f;
geo_box.halfExtents.z = size.z * 0.5f;
collider_shape->setGeometry(geo_box);
}
}
}
}
float3 ComponentCollider::GetBoxSize() const
{
if (collider_shape != nullptr)
{
float3 ret;
if (collider_type == ColliderType::BoxCollider)
{
physx::PxBoxGeometry geo_box;
if (collider_shape->getBoxGeometry(geo_box))
{
ret.x = geo_box.halfExtents.x * 2;
ret.y = geo_box.halfExtents.y * 2;
ret.z = geo_box.halfExtents.z * 2;
}
}
return ret;
}
else
return float3::zero;
}
void ComponentCollider::SetSphereRadius(float radius)
{
if (collider_shape != nullptr)
{
if (collider_type == ColliderType::SphereCollider)
{
physx::PxSphereGeometry geo_sphere;
if (collider_shape->getSphereGeometry(geo_sphere))
{
geo_sphere.radius = radius;
collider_shape->setGeometry(geo_sphere);
}
}
}
}
float ComponentCollider::GetSphereRadius() const
{
if (collider_shape != nullptr)
{
float ret;
if (collider_type == ColliderType::SphereCollider)
{
physx::PxSphereGeometry geo_sphere;
if (collider_shape->getSphereGeometry(geo_sphere))
{
ret = geo_sphere.radius;
}
}
return ret;
}
else
return 0;
}
void ComponentCollider::SetCapsuleRadius(float radius)
{
if (collider_shape != nullptr)
{
if (collider_type == ColliderType::CapsuleCollider)
{
physx::PxCapsuleGeometry geo_capsule;
if (collider_shape->getCapsuleGeometry(geo_capsule))
{
geo_capsule.radius = radius;
collider_shape->setGeometry(geo_capsule);
}
}
}
}
float ComponentCollider::GetCapsuleRadius() const
{
if (collider_shape != nullptr)
{
float ret;
if (collider_type == ColliderType::CapsuleCollider)
{
physx::PxCapsuleGeometry geo_capsule;
if (collider_shape->getCapsuleGeometry(geo_capsule))
{
ret = geo_capsule.radius;
}
}
return ret;
}
else
return 0;
}
void ComponentCollider::SetCapsuleHeight(float height)
{
if (collider_shape != nullptr)
{
if (collider_type == ColliderType::CapsuleCollider)
{
physx::PxCapsuleGeometry geo_capsule;
if (collider_shape->getCapsuleGeometry(geo_capsule))
{
geo_capsule.halfHeight = height * 0.5f;
collider_shape->setGeometry(geo_capsule);
}
}
}
}
float ComponentCollider::GetCapsuleHeight() const
{
if (collider_shape != nullptr)
{
float ret;
if (collider_type == ColliderType::CapsuleCollider)
{
physx::PxCapsuleGeometry geo_capsule;
if (collider_shape->getCapsuleGeometry(geo_capsule))
{
ret = geo_capsule.halfHeight * 2;
}
}
return ret;
}
else
return 0;
}
void ComponentCollider::SetColliderActive(bool active)
{
if (collider_shape != nullptr)
{
SetActive(active);
ComponentRigidBody* rigidbody = (ComponentRigidBody*)GetGameObject()->GetComponent(Component::CompRigidBody);
if (rigidbody)
{
if (active)
{
rigidbody->GetRigidBody()->attachShape(*collider_shape);
}
else
{
rigidbody->GetRigidBody()->detachShape(*collider_shape);
}
}
}
}
void ComponentCollider::SetCapsuleDirection(CapsuleDirection direction)
{
float3 axis_direction;
switch (direction)
{
case 0:
{
axis_direction.x = 0;
axis_direction.y = 0;
axis_direction.z = 0;
}
break;
case 1:
{
axis_direction.x = 0;
axis_direction.y = 0;
axis_direction.z = 90;
}
break;
case 2:
{
axis_direction.x = 0;
axis_direction.y = 90;
axis_direction.z = 0;
}
break;
default:
break;
}
if (collider_shape != nullptr)
{
physx::PxTransform t = collider_shape->getLocalPose();
Quat rotation = Quat::FromEulerXYZ(axis_direction.x * DEGTORAD, axis_direction.y * DEGTORAD, axis_direction.z * DEGTORAD);
physx::PxQuat q(rotation.x, rotation.y, rotation.z, rotation.w);
t.q = q;
collider_shape->setLocalPose(t);
capsule_direction = direction;
}
}
ComponentCollider::CapsuleDirection ComponentCollider::GetCapsuleDirection() const
{
return capsule_direction;
}
void ComponentCollider::ChangeMeshToConvex(bool set_convex)
{
if (collider_shape != nullptr)
{
if (collider_type != MeshCollider) return;
ComponentRigidBody* rigidbody = (ComponentRigidBody*)GetGameObject()->GetComponent(Component::CompRigidBody);
if (rigidbody)
{
if (set_convex)
{
if (collider_shape)
{
rigidbody->RemoveShape(*collider_shape);
}
collider_shape = App->physics->CreateShape(*rigidbody->GetRigidBody(), *geo_convex_mesh, *collider_material);
if (collider_shape != nullptr)
{
collider_shape->userData = this;
}
}
else
{
if (collider_shape)
{
rigidbody->RemoveShape(*collider_shape);
}
rigidbody->SetKinematic(true);
collider_shape = App->physics->CreateShape(*rigidbody->GetRigidBody(), *geo_triangle_mesh, *collider_material);
if (collider_shape != nullptr)
{
collider_shape->userData = this;
SetTrigger(false);
}
}
}
is_convex = set_convex;
}
}
bool ComponentCollider::IsConvex() const
{
return is_convex;
}
void ComponentCollider::Save(Data & data) const
{
data.AddInt("Type", GetType());
data.AddBool("Active", IsActive());
data.AddUInt("UUID", GetUID());
data.AddBool("IsConvex", is_convex);
data.AddBool("IsTrigger", is_trigger);
data.AddInt("CapsuleDir", capsule_direction);
if (phys_material)
{
data.AddBool("HaveMaterial", true);
data.CreateSection("PhysMaterial");
data.AddInt("UUID", phys_material->GetUID());
data.CloseSection();
}
else
{
data.AddBool("HaveMaterial", false);
}
data.AddVector3("ColliderCenter", GetColliderCenter());
switch (collider_type)
{
case ComponentCollider::BoxCollider:
data.CreateSection("Box");
data.AddVector3("BoxSize", GetBoxSize());
data.CloseSection();
break;
case ComponentCollider::SphereCollider:
data.CreateSection("Sphere");
data.AddFloat("SphereRadius", GetSphereRadius());
data.CloseSection();
break;
case ComponentCollider::CapsuleCollider:
data.CreateSection("Capsule");
data.AddFloat("CapsuleRadius", GetCapsuleRadius());
data.AddFloat("CapsuleHeight", GetCapsuleHeight());
data.CloseSection();
break;
default:
break;
}
}
void ComponentCollider::Load(Data & data)
{
SetType((ComponentType)data.GetInt("Type"));
SetActive(data.GetBool("Active"));
SetUID(data.GetUInt("UUID"));
ChangeMeshToConvex(data.GetBool("IsConvex"));
SetTrigger(data.GetBool("IsTrigger"));
SetCapsuleDirection((CapsuleDirection)data.GetInt("CapsuleDir"));
if (data.GetBool("HaveMaterial"))
{
data.EnterSection("PhysMaterial");
uint mat_id = data.GetUInt("UUID");
phys_material = App->resources->GetPhysMaterial(mat_id);
data.LeaveSection();
}
SetColliderCenter(data.GetVector3("ColliderCenter"));
if (data.EnterSection("Box"))
{
SetBoxSize(data.GetVector3("BoxSize"));
data.LeaveSection();
}
if (data.EnterSection("Sphere"))
{
SetSphereRadius(data.GetFloat("SphereRadius"));
data.LeaveSection();
}
if (data.EnterSection("Capsule"))
{
SetCapsuleRadius(data.GetFloat("CapsuleRadius"));
SetCapsuleHeight(data.GetFloat("CapsuleHeight"));
data.LeaveSection();
}
}
ComponentRigidBody * ComponentCollider::GetRigidBody() const
{
return rigidbody;
}
void ComponentCollider::OnEnable()
{
BROFILER_CATEGORY("Component - Collider - OnEnable", Profiler::Color::Beige);
if (collider_shape)
{
if (!IsTrigger())
{
collider_shape->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE, true);
}
collider_shape->setFlag(physx::PxShapeFlag::eSCENE_QUERY_SHAPE, true);
collider_shape->setFlag(physx::PxShapeFlag::eVISUALIZATION, true);
}
}
void ComponentCollider::OnDisable()
{
BROFILER_CATEGORY("Component - Collider - OnDisable", Profiler::Color::Beige);
if (collider_shape)
{
collider_shape->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE, false);
collider_shape->setFlag(physx::PxShapeFlag::eSCENE_QUERY_SHAPE, false);
collider_shape->setFlag(physx::PxShapeFlag::eVISUALIZATION, false);
}
}
| 24.564437 | 137 | 0.724001 | Project-3-UPC-DDV-BCN |
a9bd7f6a88642fb8751375cca71e3d3ffb1a960d | 14,807 | cpp | C++ | edge_impulse/ingestion-sdk-platform/sony-spresense/ei_sony_spresense_fs_commands.cpp | AnshumanFauzdar/firmware-sony-spresense | 2ccd58a8285b7e8d410fcde144a42237f4c214e1 | [
"Apache-2.0"
] | 1 | 2021-11-18T08:04:16.000Z | 2021-11-18T08:04:16.000Z | edge_impulse/ingestion-sdk-platform/sony-spresense/ei_sony_spresense_fs_commands.cpp | AnshumanFauzdar/firmware-sony-spresense | 2ccd58a8285b7e8d410fcde144a42237f4c214e1 | [
"Apache-2.0"
] | 1 | 2022-01-11T15:56:56.000Z | 2022-01-11T15:56:56.000Z | edge_impulse/ingestion-sdk-platform/sony-spresense/ei_sony_spresense_fs_commands.cpp | AnshumanFauzdar/firmware-sony-spresense | 2ccd58a8285b7e8d410fcde144a42237f4c214e1 | [
"Apache-2.0"
] | 1 | 2021-12-30T13:07:44.000Z | 2021-12-30T13:07:44.000Z |
/* Include ----------------------------------------------------------------- */
#include "ei_sony_spresense_fs_commands.h"
#include "ei_device_sony_spresense.h"
#define SERIAL_FLASH 0
#define MICRO_SD 1
#define RAM 2
#define SAMPLE_MEMORY MICRO_SD
#define SIZE_RAM_BUFFER 0x10000//(0x20000)
#define RAM_BLOCK_SIZE 1024
#define RAM_N_BLOCKS (SIZE_RAM_BUFFER / RAM_BLOCK_SIZE)
#define FILE_NAME_CONFIG "config.bin"
#define FILE_NAME_SAMPLE "sample.bin"
#define FILE_MAX_SIZE 0x200000
#define FILE_BLOCK_SIZE 1024
#define FILE_N_BLOCKS (FILE_MAX_SIZE / FILE_BLOCK_SIZE)
/* Private function prototypes --------------------------------------------- */
#if (SAMPLE_MEMORY == SERIAL_FLASH)
static uint32_t flash_write(uint32_t address, const uint8_t *buffer, uint32_t bufferSize);
static uint32_t flash_erase_sectors(uint32_t startAddress, uint32_t nSectors);
static uint32_t flash_wait_while_busy(void);
static void flash_write_enable(void);
static uint8_t flash_status_register(void);
static void flash_erase_sector(uint32_t byteAddress);
static void flash_erase_block(uint32_t byteAddress);
static void flash_program_page(uint32_t byteAddress, uint8_t *page, uint32_t pageBytes);
static uint32_t flash_read_data(uint32_t byteAddress, uint8_t *buffer, uint32_t readBytes);
#endif
extern "C" bool spresense_openFile(const char *name, bool write);
extern "C" bool spresense_closeFile(const char *name);
extern "C" bool spresense_writeToFile(const char *name, const uint8_t *buf, uint32_t length);
extern "C" uint32_t spresense_readFromFile(const char *name, uint8_t *buf, uint32_t length);
/* Private variables ------------------------------------------------------- */
static bool sd_card_inserted = true;
#if (SAMPLE_MEMORY == RAM)
static uint8_t ram_memory[SIZE_RAM_BUFFER];
#endif
/** 32-bit align write buffer size */
#define WORD_ALIGN(a) ((a & 0x3) ? (a & ~0x3) + 0x4 : a)
/**
* @brief Copy configuration data to config pointer
*
* @param config Destination pointer for config
* @param[in] config_size Size of configuration in bytes
*
* @return ei_sony_spresense_ret_t enum
*/
int ei_sony_spresense_fs_load_config(uint32_t *config, uint32_t config_size)
{
int retVal = SONY_SPRESENSE_FS_CMD_OK;
if (config == NULL) {
return SONY_SPRESENSE_FS_CMD_NULL_POINTER;
}
#if (SAMPLE_MEMORY == RAM)
return retVal;
#elif (SAMPLE_MEMORY == SERIAL_FLASH)
if (flash_wait_while_busy() == 0) {
retVal = SONY_SPRESENSE_FS_CMD_READ_ERROR;
}
else {
if (flash_read_data(0, (uint8_t *)config, config_size) != 0) {
retVal = SONY_SPRESENSE_FS_CMD_READ_ERROR;
}
}
return retVal;
#elif (SAMPLE_MEMORY == MICRO_SD)
if(spresense_openFile((const char *)FILE_NAME_CONFIG, false) == false) {
/* Try to create and write to the config file */
if(spresense_openFile((const char *)FILE_NAME_CONFIG, true) == false) {
/* Missing SD card, return OK so default config can be loaded */
ei_printf("File cannot open %s is the SD card inserted?\r\n", FILE_NAME_CONFIG);
sd_card_inserted = false;
}
else {
spresense_writeToFile((const char *)FILE_NAME_CONFIG, (const uint8_t *)config, config_size);
spresense_closeFile((const char *)FILE_NAME_CONFIG);
}
return SONY_SPRESENSE_FS_CMD_OK;
}
if(spresense_readFromFile(FILE_NAME_CONFIG, (uint8_t *)config, config_size) < 0) {
retVal = SONY_SPRESENSE_FS_CMD_READ_ERROR;
}
else if(spresense_closeFile((const char *)FILE_NAME_CONFIG) == false) {
retVal = SONY_SPRESENSE_FS_CMD_FILE_ERROR;
}
return retVal;
#endif
}
/**
* @brief Write config to Flash
*
* @param[in] config Pointer to configuration data
* @param[in] config_size Size of configuration in bytes
*
* @return ei_sony_spresense_ret_t enum
*/
int ei_sony_spresense_fs_save_config(const uint32_t *config, uint32_t config_size)
{
int retVal = SONY_SPRESENSE_FS_CMD_OK;
if (config == NULL) {
return SONY_SPRESENSE_FS_CMD_NULL_POINTER;
}
#if (SAMPLE_MEMORY == RAM)
return retVal;
#elif (SAMPLE_MEMORY == SERIAL_FLASH)
retVal = flash_erase_sectors(0, 1);
return (retVal == SONY_SPRESENSE_FS_CMD_OK) ? flash_write(0, (const uint8_t *)config, config_size)
: retVal;
#elif (SAMPLE_MEMORY == MICRO_SD)
if(sd_card_inserted == false) {
retVal = SONY_SPRESENSE_FS_CMD_OK;
}
else if(spresense_openFile((const char *)FILE_NAME_CONFIG, true) == false) {
retVal = SONY_SPRESENSE_FS_CMD_FILE_ERROR;
}
else if(spresense_writeToFile((const char *)FILE_NAME_CONFIG, (const uint8_t *)config, config_size) == false) {
retVal = SONY_SPRESENSE_FS_CMD_WRITE_ERROR;
}
else if(spresense_closeFile((const char *)FILE_NAME_CONFIG) == false) {
retVal = SONY_SPRESENSE_FS_CMD_FILE_ERROR;
}
return retVal;
#endif
}
/**
* @brief Erase blocks in sample data space
*
* @param[in] start_block The start block
* @param[in] end_address The end address
*
* @return ei_sony_spresense_ret_t
*/
int ei_sony_spresense_fs_erase_sampledata(uint32_t start_block, uint32_t end_address)
{
#if (SAMPLE_MEMORY == RAM)
return SONY_SPRESENSE_FS_CMD_OK;
#elif (SAMPLE_MEMORY == SERIAL_FLASH)
return flash_erase_sectors(MX25R_BLOCK64_SIZE, end_address / MX25R_SECTOR_SIZE);
#elif (SAMPLE_MEMORY == MICRO_SD)
return (int)!spresense_openFile((const char *)FILE_NAME_SAMPLE, true);
#endif
}
/**
* @brief Write sample data
*
* @param[in] sample_buffer The sample buffer
* @param[in] address_offset The address offset
* @param[in] n_samples The n samples
*
* @return ei_sony_spresense_ret_t
*/
int ei_sony_spresense_fs_write_samples(const void *sample_buffer, uint32_t address_offset, uint32_t n_samples)
{
#if (SAMPLE_MEMORY == RAM)
uint32_t n_word_samples = WORD_ALIGN(n_samples);
if ((address_offset + n_word_samples) > SIZE_RAM_BUFFER) {
return SONY_SPRESENSE_FS_CMD_WRITE_ERROR;
}
else if (sample_buffer == 0) {
return SONY_SPRESENSE_FS_CMD_NULL_POINTER;
}
for (int i = 0; i < n_word_samples; i++) {
ram_memory[address_offset + i] = *((char *)sample_buffer + i);
}
return SONY_SPRESENSE_FS_CMD_OK;
#elif (SAMPLE_MEMORY == SERIAL_FLASH)
uint32_t n_word_samples = WORD_ALIGN(n_samples);
return flash_write(
MX25R_BLOCK64_SIZE + address_offset,
(const uint8_t *)sample_buffer,
n_word_samples);
#elif (SAMPLE_MEMORY == MICRO_SD)
if(spresense_writeToFile((const char *)FILE_NAME_CONFIG, (const uint8_t *)sample_buffer, n_samples) == true) {
return SONY_SPRESENSE_FS_CMD_OK;
}
else {
return SONY_SPRESENSE_FS_CMD_WRITE_ERROR;
}
#endif
}
/**
* @brief Read sample data
*
* @param sample_buffer The sample buffer
* @param[in] address_offset The address offset
* @param[in] n_read_bytes The n read bytes
*
* @return ei_sony_spresense_ret_t
*/
int ei_sony_spresense_fs_read_sample_data(void *sample_buffer, uint32_t address_offset, uint32_t n_read_bytes)
{
#if (SAMPLE_MEMORY == RAM)
if ((address_offset + n_read_bytes) > SIZE_RAM_BUFFER) {
return SONY_SPRESENSE_FS_CMD_READ_ERROR;
}
else if (sample_buffer == 0) {
return SONY_SPRESENSE_FS_CMD_NULL_POINTER;
}
for (int i = 0; i < n_read_bytes; i++) {
*((char *)sample_buffer + i) = ram_memory[address_offset + i];
}
return SONY_SPRESENSE_FS_CMD_OK;
#elif (SAMPLE_MEMORY == SERIAL_FLASH)
int retVal = SONY_SPRESENSE_FS_CMD_OK;
if (flash_wait_while_busy() == 0) {
retVal = SONY_SPRESENSE_FS_CMD_READ_ERROR;
}
else {
if (flash_read_data(
MX25R_BLOCK64_SIZE + address_offset,
(uint8_t *)sample_buffer,
n_read_bytes) != 0) {
retVal = SONY_SPRESENSE_FS_CMD_READ_ERROR;
}
}
return retVal;
#elif (SAMPLE_MEMORY == MICRO_SD)
int retVal = SONY_SPRESENSE_FS_CMD_OK;
if(address_offset == 0) {
if(spresense_openFile((const char *)FILE_NAME_SAMPLE, true) == false) {
retVal = SONY_SPRESENSE_FS_CMD_FILE_ERROR;
}
}
if(spresense_readFromFile(FILE_NAME_SAMPLE, (uint8_t *)sample_buffer, n_read_bytes) < 0) {
retVal = SONY_SPRESENSE_FS_CMD_READ_ERROR;
}
return retVal;
#endif
}
/**
* @brief Close file on SD card
*
*/
void ei_sony_spresense_fs_close_sample_file(void)
{
#if (SAMPLE_MEMORY == MICRO_SD)
spresense_closeFile((const char *)FILE_NAME_SAMPLE);
#endif
}
/**
* @brief Get block size (Smallest erasble block).
*
* @return Length of 1 block
*/
uint32_t ei_sony_spresense_fs_get_block_size(void)
{
#if (SAMPLE_MEMORY == RAM)
return RAM_BLOCK_SIZE;
#elif (SAMPLE_MEMORY == SERIAL_FLASH)
return MX25R_SECTOR_SIZE;
#elif (SAMPLE_MEMORY == MICRO_SD)
if(sd_card_inserted == false) {
return 0;
}
else {
return FILE_BLOCK_SIZE;
}
#endif
}
/**
* @brief Get available sample blocks
*
* @return Sample memory size / block size
*/
uint32_t ei_sony_spresense_fs_get_n_available_sample_blocks(void)
{
#if (SAMPLE_MEMORY == RAM)
return RAM_N_BLOCKS;
#elif (SAMPLE_MEMORY == SERIAL_FLASH)
return (MX25R_CHIP_SIZE - MX25R_BLOCK64_SIZE) / MX25R_SECTOR_SIZE;
#elif (SAMPLE_MEMORY == MICRO_SD)
return FILE_N_BLOCKS;
#endif
}
#if (SAMPLE_MEMORY == SERIAL_FLASH)
/**
* @brief Write a buffer to memory @ address
*
* @param[in] address The address
* @param[in] buffer The buffer
* @param[in] bufferSize The buffer size in bytes
*
* @return ei_sony_spresense_ret_t
*/
static uint32_t flash_write(uint32_t address, const uint8_t *buffer, uint32_t bufferSize)
{
int stat;
int retry = MX25R_RETRY;
int offset = 0;
if (flash_wait_while_busy() == 0)
return SONY_SPRESENSE_FS_CMD_WRITE_ERROR;
do {
uint32_t n_bytes;
retry = MX25R_RETRY;
do {
flash_write_enable();
stat = flash_status_register();
} while (!(stat & MX25R_STAT_WEL) && --retry);
if (!retry) {
return SONY_SPRESENSE_FS_CMD_WRITE_ERROR;
}
if (bufferSize > MX25R_PAGE_SIZE) {
n_bytes = MX25R_PAGE_SIZE;
bufferSize -= MX25R_PAGE_SIZE;
}
else {
n_bytes = bufferSize;
bufferSize = 0;
}
/* If write overflows page, split up in 2 writes */
if ((((address + offset) & 0xFF) + n_bytes) > MX25R_PAGE_SIZE) {
int diff = MX25R_PAGE_SIZE - ((address + offset) & 0xFF);
flash_program_page(address + offset, ((uint8_t *)buffer + offset), diff);
if (flash_wait_while_busy() == 0)
return SONY_SPRESENSE_FS_CMD_WRITE_ERROR;
// retry = MX25R_RETRY;
// do {
// flash_write_enable();
// stat = flash_status_register();
// }while(!(stat & MX25R_STAT_WEL) && --retry);
// if(!retry) {
// return SONY_SPRESENSE_FS_CMD_WRITE_ERROR;
// }
/* Update index pointers */
n_bytes -= diff;
offset += diff;
bufferSize += n_bytes;
}
else {
flash_program_page(address + offset, ((uint8_t *)buffer + offset), n_bytes);
offset += n_bytes;
}
// flash_program_page(address + offset, ((uint8_t *)buffer + offset), n_bytes);
if (flash_wait_while_busy() == 0)
return SONY_SPRESENSE_FS_CMD_WRITE_ERROR;
// offset += MX25R_PAGE_SIZE;
} while (bufferSize);
return SONY_SPRESENSE_FS_CMD_OK;
}
/**
* @brief Erase mulitple flash sectors
*
* @param[in] startAddress The start address
* @param[in] nSectors The sectors
*
* @return ei_sony_spresense_ret_t
*/
static uint32_t flash_erase_sectors(uint32_t startAddress, uint32_t nSectors)
{
int stat;
int retry = MX25R_RETRY;
uint32_t curSector = 0;
do {
if (flash_wait_while_busy() == 0) {
return SONY_SPRESENSE_FS_CMD_ERASE_ERROR;
}
do {
flash_write_enable();
stat = flash_status_register();
} while (!(stat & MX25R_STAT_WEL) && --retry);
flash_erase_sector(startAddress + (MX25R_SECTOR_SIZE * curSector));
} while (++curSector < nSectors);
return SONY_SPRESENSE_FS_CMD_OK;
}
/**
* @brief Read status register and check WIP (write in progress)
* @return n retries, if 0 device is hanging
*/
static uint32_t flash_wait_while_busy(void)
{
uint32_t stat;
uint32_t retry = MX25R_RETRY;
stat = flash_status_register();
while ((stat & MX25R_STAT_WIP) && --retry) {
stat = flash_status_register();
}
return retry;
}
/**
* @brief Send the write enable command over SPI
*/
static void flash_write_enable(void)
{
//uint8_t spiTransfer[1];
//spiTransfer[0] = MX25R_WREN;
//Sony_SpresenseCspSpiTransferPoll(
// SONY_SPRESENSE_SPI_NUM,
// &spiTransfer[0],
// 1,
// &spiTransfer[0],
// 0,
// SONY_SPRESENSE_BSP_SPIFLASH_CS_NUM,
// eSpiSequenceFirstLast);
}
/**
* @brief Send a read status register frame over SPI
*
* @return Chip status register
*/
static uint8_t flash_status_register(void)
{
uint8_t spiTransfer[2];
// TODO
return spiTransfer[0];
}
/**
* @brief Send a sector erase frame with start address
*
* @param[in] byteAddress The byte address
*/
static void flash_erase_sector(uint32_t byteAddress)
{
uint8_t spiTransfer[4];
//TODO
}
/**
* @brief Send a block erase frame with start address
*
* @param[in] byteAddress The byte address
*/
static void flash_erase_block(uint32_t byteAddress)
{
uint8_t spiTransfer[4];
//TODO
}
/**
* @brief Send program page command and send data over SPI
*
* @param[in] byteAddress The byte address
* @param page The page
* @param[in] pageBytes The page bytes
*/
static void flash_program_page(uint32_t byteAddress, uint8_t *page, uint32_t pageBytes)
{
uint8_t spiTransfer[4];
//TODO
}
/**
* @brief Send read command and get data over SPI
*
* @param[in] byteAddress The byte address
* @param buffer The buffer
* @param[in] readBytes The read bytes
*
* @return Sony_Spresense status
*/
static uint32_t flash_read_data(uint32_t byteAddress, uint8_t *buffer, uint32_t readBytes)
{
uint8_t spiTransfer[4];
//TODO
return 0;
}
#endif
| 26.921818 | 115 | 0.654893 | AnshumanFauzdar |
a9bff1a24c524cf7e9ae2d5e927e3948a36b24fd | 9,755 | cpp | C++ | CMSIS/DSP/Testing/Source/Tests/ComplexTestsQ15.cpp | mintisan/CMSIS_5 | 2df723647a1f629b7be1394bfc13c9ea9119a8f8 | [
"Apache-2.0"
] | null | null | null | CMSIS/DSP/Testing/Source/Tests/ComplexTestsQ15.cpp | mintisan/CMSIS_5 | 2df723647a1f629b7be1394bfc13c9ea9119a8f8 | [
"Apache-2.0"
] | null | null | null | CMSIS/DSP/Testing/Source/Tests/ComplexTestsQ15.cpp | mintisan/CMSIS_5 | 2df723647a1f629b7be1394bfc13c9ea9119a8f8 | [
"Apache-2.0"
] | null | null | null | #include "ComplexTestsQ15.h"
#include "Error.h"
#define SNR_THRESHOLD 25
/*
Reference patterns are generated with
a double precision computation.
*/
#define ABS_ERROR_Q15 ((q15_t)20)
#define ABS_ERROR_Q31 ((q31_t)(1<<15))
void ComplexTestsQ15::test_cmplx_conj_q15()
{
const q15_t *inp1=input1.ptr();
q15_t *refp=ref.ptr();
q15_t *outp=output.ptr();
arm_cmplx_conj_q15(inp1,outp,input1.nbSamples() >> 1 );
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
}
void ComplexTestsQ15::test_cmplx_dot_prod_q15()
{
q31_t re,im;
const q15_t *inp1=input1.ptr();
const q15_t *inp2=input2.ptr();
q31_t *outp=dotOutput.ptr();
arm_cmplx_dot_prod_q15(inp1,inp2,input1.nbSamples() >> 1 ,&re,&im);
outp[0] = re;
outp[1] = im;
ASSERT_SNR(dotOutput,dotRef,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(dotOutput,dotRef,ABS_ERROR_Q31);
ASSERT_EMPTY_TAIL(dotOutput);
}
void ComplexTestsQ15::test_cmplx_mag_q15()
{
const q15_t *inp1=input1.ptr();
q15_t *refp=ref.ptr();
q15_t *outp=output.ptr();
arm_cmplx_mag_q15(inp1,outp,input1.nbSamples() >> 1 );
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
}
void ComplexTestsQ15::test_cmplx_mag_squared_q15()
{
const q15_t *inp1=input1.ptr();
q15_t *refp=ref.ptr();
q15_t *outp=output.ptr();
arm_cmplx_mag_squared_q15(inp1,outp,input1.nbSamples() >> 1 );
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
}
void ComplexTestsQ15::test_cmplx_mult_cmplx_q15()
{
const q15_t *inp1=input1.ptr();
const q15_t *inp2=input2.ptr();
q15_t *refp=ref.ptr();
q15_t *outp=output.ptr();
arm_cmplx_mult_cmplx_q15(inp1,inp2,outp,input1.nbSamples() >> 1 );
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
}
void ComplexTestsQ15::test_cmplx_mult_real_q15()
{
const q15_t *inp1=input1.ptr();
const q15_t *inp2=input2.ptr();
q15_t *refp=ref.ptr();
q15_t *outp=output.ptr();
arm_cmplx_mult_real_q15(inp1,inp2,outp,input1.nbSamples() >> 1 );
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
}
void ComplexTestsQ15::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
{
Testing::nbSamples_t nb=MAX_NB_SAMPLES;
switch(id)
{
case ComplexTestsQ15::TEST_CMPLX_CONJ_Q15_1:
nb = 7;
ref.reload(ComplexTestsQ15::REF_CONJ_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_CONJ_Q15_2:
nb = 16;
ref.reload(ComplexTestsQ15::REF_CONJ_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_CONJ_Q15_3:
nb = 23;
ref.reload(ComplexTestsQ15::REF_CONJ_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_DOT_PROD_Q15_4:
nb = 7;
dotRef.reload(ComplexTestsQ15::REF_DOT_PROD_3_Q15_ID,mgr);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT2_Q15_ID,mgr,nb << 1);
dotOutput.create(dotRef.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_DOT_PROD_Q15_5:
nb = 16;
dotRef.reload(ComplexTestsQ15::REF_DOT_PROD_4N_Q15_ID,mgr);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT2_Q15_ID,mgr,nb << 1);
dotOutput.create(dotRef.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_DOT_PROD_Q15_6:
nb = 23;
dotRef.reload(ComplexTestsQ15::REF_DOT_PROD_4N1_Q15_ID,mgr);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT2_Q15_ID,mgr,nb << 1);
dotOutput.create(dotRef.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MAG_Q15_7:
nb = 7;
ref.reload(ComplexTestsQ15::REF_MAG_Q15_ID,mgr,nb);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MAG_Q15_8:
nb = 16;
ref.reload(ComplexTestsQ15::REF_MAG_Q15_ID,mgr,nb);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MAG_Q15_9:
nb = 23;
ref.reload(ComplexTestsQ15::REF_MAG_Q15_ID,mgr,nb);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MAG_SQUARED_Q15_10:
nb = 7;
ref.reload(ComplexTestsQ15::REF_MAG_SQUARED_Q15_ID,mgr,nb);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MAG_SQUARED_Q15_11:
nb = 16;
ref.reload(ComplexTestsQ15::REF_MAG_SQUARED_Q15_ID,mgr,nb);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MAG_SQUARED_Q15_12:
nb = 23;
ref.reload(ComplexTestsQ15::REF_MAG_SQUARED_Q15_ID,mgr,nb);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MULT_CMPLX_Q15_13:
nb = 7;
ref.reload(ComplexTestsQ15::REF_CMPLX_MULT_CMPLX_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT2_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MULT_CMPLX_Q15_14:
nb = 16;
ref.reload(ComplexTestsQ15::REF_CMPLX_MULT_CMPLX_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT2_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MULT_CMPLX_Q15_15:
nb = 23;
ref.reload(ComplexTestsQ15::REF_CMPLX_MULT_CMPLX_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT2_Q15_ID,mgr,nb << 1);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MULT_REAL_Q15_16:
nb = 7;
ref.reload(ComplexTestsQ15::REF_CMPLX_MULT_REAL_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT3_Q15_ID,mgr,nb);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MULT_REAL_Q15_17:
nb = 16;
ref.reload(ComplexTestsQ15::REF_CMPLX_MULT_REAL_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT3_Q15_ID,mgr,nb);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
case ComplexTestsQ15::TEST_CMPLX_MULT_REAL_Q15_18:
nb = 23;
ref.reload(ComplexTestsQ15::REF_CMPLX_MULT_REAL_Q15_ID,mgr,nb << 1);
input1.reload(ComplexTestsQ15::INPUT1_Q15_ID,mgr,nb << 1);
input2.reload(ComplexTestsQ15::INPUT3_Q15_ID,mgr,nb);
output.create(ref.nbSamples(),ComplexTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
break;
}
}
void ComplexTestsQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
{
switch(id)
{
case ComplexTestsQ15::TEST_CMPLX_DOT_PROD_Q15_4:
case ComplexTestsQ15::TEST_CMPLX_DOT_PROD_Q15_5:
case ComplexTestsQ15::TEST_CMPLX_DOT_PROD_Q15_6:
dotOutput.dump(mgr);
break;
default:
output.dump(mgr);
}
}
| 33.637931 | 115 | 0.64654 | mintisan |
a9c2dbeffba422bae27765a8ac362bdc7ac49552 | 4,101 | cpp | C++ | ui/CxRunCtrl/BitmapView.cpp | johnzcdGitHub/SuperCxHMI | e897b7bdf30cfe3bfeb5b8738e10c7205ebcd665 | [
"MIT"
] | 118 | 2015-05-19T09:19:01.000Z | 2022-02-24T15:18:51.000Z | ui/CxRunCtrl/BitmapView.cpp | PythonYanshenguan/SuperCxHMI | 19f681583fca56c528b51b5821fe842c80bcae24 | [
"MIT"
] | 1 | 2016-10-24T02:48:03.000Z | 2020-04-20T01:53:31.000Z | ui/CxRunCtrl/BitmapView.cpp | PythonYanshenguan/SuperCxHMI | 19f681583fca56c528b51b5821fe842c80bcae24 | [
"MIT"
] | 98 | 2015-02-11T07:16:47.000Z | 2022-02-24T02:15:27.000Z | // BitmapView.cpp: implementation of the CBitmapView class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "RunInc.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CBitmapView, CPrintView)
BEGIN_MESSAGE_MAP(CBitmapView, CPrintView)
//{{AFX_MSG_MAP(CBitmapView)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
ON_COMMAND(ID_FILE_PRINT, CPrintView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CPrintView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CPrintView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBitmapView construction/destruction
CBitmapView::CBitmapView()
{
}
CBitmapView::~CBitmapView()
{
}
/////////////////////////////////////////////////////////////////////////////
// CBitmapView diagnostics
#ifdef _DEBUG
void CBitmapView::AssertValid() const
{
CPrintView::AssertValid();
}
void CBitmapView::Dump(CDumpContext& dc) const
{
CPrintView::Dump(dc);
}
CBitmapDoc* CBitmapView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBitmapDoc)));
return (CBitmapDoc *)m_pDocument;
}
#endif //_DEBUG
BOOL CBitmapView::PreCreateWindow(CREATESTRUCT& cs)
{
return CPrintView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CBitmapView drawing
void CBitmapView::OnDraw(CDC* pDC)
{
CBitmapDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
BITMAP bm;
pDoc->m_bitmap.GetBitmap(&bm);
CPoint pt;
CRect rectMargin;
CRect rectPage;
pDC->Escape(GETPRINTINGOFFSET, 0, NULL, &pt);
rectMargin.left = pt.x;
rectMargin.top = pt.y;
pDC->Escape(GETPHYSPAGESIZE, 0, NULL, &pt);
rectPage.SetRect(0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES));
rectMargin.right = pt.x // total paper width
- pDC->GetDeviceCaps(HORZRES) // printable width
- rectMargin.left; // left unprtable margin
rectMargin.bottom = pt.y // total paper height
- pDC->GetDeviceCaps(VERTRES) // printable ht
- rectMargin.top; // rt unprtable margin
pt.x = pDC->GetDeviceCaps(LOGPIXELSX); // dpi in X direction
pt.y = pDC->GetDeviceCaps(LOGPIXELSY); // dpi in Y direction
rectMargin.left = MulDiv(pDoc->m_rcMargin.left, pt.x, 1440)
- rectMargin.left;
rectMargin.top = MulDiv(pDoc->m_rcMargin.top, pt.y, 1440)
- rectMargin.top;
rectMargin.right = MulDiv(pDoc->m_rcMargin.right, pt.x, 1440)
- rectMargin.right;
rectMargin.bottom = MulDiv(pDoc->m_rcMargin.bottom, pt.y, 1440)
- rectMargin.bottom;
rectPage.InflateRect(-rectMargin.left, -rectMargin.top, -rectMargin.right, -rectMargin.bottom);
float fXScale;
float fYScale;
float fScale;
if (pDoc->m_fHorizontalScale == 0.0f || pDoc->m_fVerticalScale == 0.0f)
{
fXScale = (float)rectPage.Width() / bm.bmWidth;
fYScale = (float)rectPage.Height() / bm.bmHeight;
fScale = min(fXScale, fYScale); // max(min(nXScale, nYScale), 1);
if (pDoc->m_bMultipleScale)
fScale = float(int(fScale));
fXScale = fScale;
fYScale = fScale;
}
else
{
fXScale = pDoc->m_fHorizontalScale;
fYScale = pDoc->m_fVerticalScale;
}
int cxBlt = int(bm.bmWidth * fXScale);
int cyBlt = int(bm.bmHeight * fYScale);
int xOff = (rectPage.left + rectPage.right) / 2 - cxBlt / 2;
int yOff = (rectPage.top + rectPage.bottom) / 2 - cyBlt / 2;
CDC dc;
if (dc.CreateCompatibleDC(pDC))
{
// Paint the image.
CBitmap* pOldBitmap = dc.SelectObject(&pDoc->m_bitmap);
pDC->StretchBlt(xOff, yOff, cxBlt, cyBlt, &dc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
dc.SelectObject(pOldBitmap);
}
}
void CBitmapView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CPrintView::OnPrepareDC(pDC, pInfo);
}
/////////////////////////////////////////////////////////////////////////////
// CBitmapView printing
BOOL CBitmapView::OnPreparePrinting(CPrintInfo* pInfo)
{
return DoPreparePrinting(pInfo);
}
| 26.803922 | 96 | 0.622775 | johnzcdGitHub |
a9c3809241ea0374b49ef2735cceff0a8d1644ef | 10,473 | cpp | C++ | piwiktracker.cpp | Waqar144/qt-piwik-tracker | d8fa34593f493d9e4045f7be811ad5bafe0d3a10 | [
"MIT"
] | null | null | null | piwiktracker.cpp | Waqar144/qt-piwik-tracker | d8fa34593f493d9e4045f7be811ad5bafe0d3a10 | [
"MIT"
] | null | null | null | piwiktracker.cpp | Waqar144/qt-piwik-tracker | d8fa34593f493d9e4045f7be811ad5bafe0d3a10 | [
"MIT"
] | null | null | null | /**
* Copyright (c) 2014-2021 Patrizio Bekerle -- <patrizio@bekerle.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* 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.
*
*
* To build PiwikTracker with a QtQuick application (QGuiApplication) instead
* of Desktop, define PIWIK_TRACKER_QTQUICK in your .pro file like this:
* `DEFINES += PIWIK_TRACKER_QTQUICK`
* or in a cmake project:
* `add_definitions(-DPIWIK_TRACKER_QTQUICK)`
*
* To enable debugging messages, `#define PIWIK_TRACKER_DEBUG 1` before
* including the header file
*/
#include "piwiktracker.h"
#include <QSettings>
#include <QUrlQuery>
#include <QUuid>
#include <utility>
#if defined(PIWIK_TRACKER_QTQUICK)
#include <QGuiApplication>
#include <QScreen>
#else
#ifdef QT_GUI_LIB
#include <QGuiApplication>
#include <QScreen>
#endif
#endif
#ifndef PIWIK_TRACKER_DEBUG
#define PIWIK_TRACKER_DEBUG 0
#endif
PiwikTracker::PiwikTracker(QCoreApplication* parent, QUrl trackerUrl,
int siteId, QString clientId)
: QObject(parent),
_networkAccessManager(this),
_trackerUrl(std::move(trackerUrl)),
_siteId(siteId),
_clientId(std::move(clientId)) {
connect(&_networkAccessManager, SIGNAL(finished(QNetworkReply*)), this,
SLOT(replyFinished(QNetworkReply*)));
if (parent) {
_appName = parent->applicationName();
}
// if no client id was set let's search in the settings
if (!_clientId.size()) {
QSettings settings;
// create a client id if none was in the settings
if (!settings.contains("PiwikClientId")) {
QByteArray ba;
ba.append(QUuid::createUuid().toString());
// generate a random md5 hash
QString md5Hash = QString(
QCryptographicHash::hash(ba, QCryptographicHash::Md5).toHex());
// the client id has to be a 16 character hex code
_clientId = md5Hash.left(16);
// store the client id
settings.setValue("PiwikClientId", _clientId);
} else {
// load the client id from the settings
_clientId = settings.value("PiwikClientId").toString();
}
}
// get the screen resolution for gui apps
#if defined(PIWIK_TRACKER_QTQUICK)
QScreen *primaryScreen = qApp->primaryScreen();
#else
#ifdef QT_GUI_LIB
QScreen *primaryScreen = QGuiApplication::primaryScreen();
#endif
#endif
#if defined(PIWIK_TRACKER_QTQUICK) || defined(QT_GUI_LIB)
if (primaryScreen != nullptr) {
_screenResolution = QString::number(primaryScreen->geometry().width()) +
"x" + QString::number(primaryScreen->geometry().height());
}
#endif
// try to get the operating system
QString operatingSystem = "Other";
#ifdef Q_OS_LINUX
operatingSystem = "Linux";
#endif
#ifdef Q_OS_MAC
operatingSystem = "Macintosh";
#endif
#ifdef Q_OS_WIN32
operatingSystem = "Windows";
#endif
// for QT >= 5.4 we can use QSysInfo
// Piwik doesn't recognize that on macOS very well
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
#ifdef Q_OS_MAC
operatingSystem = "Macintosh " + QSysInfo::prettyProductName();
#else
operatingSystem = QSysInfo::prettyProductName() + ", " +
QSysInfo::currentCpuArchitecture();
#endif
#endif
// get the locale
QString locale = QLocale::system().name().toLower().replace("_", "-");
// set the user agent
_userAgent = "Mozilla/5.0 (" + operatingSystem + "; " + locale +
") "
"PiwikTracker/0.1 (Qt/" QT_VERSION_STR " )";
// set the user language
_userLanguage = locale;
}
/**
* Prepares the common query items for the tracking request
*/
QUrlQuery PiwikTracker::prepareUrlQuery(const QString& path) {
QUrlQuery q;
q.addQueryItem("idsite", QString::number(_siteId));
q.addQueryItem("_id", _clientId);
q.addQueryItem("cid", _clientId);
q.addQueryItem("url", "http://" + _appName + "/" + path);
// to record the request
q.addQueryItem("rec", "1");
// api version
q.addQueryItem("apiv", "1");
if (!_screenResolution.isEmpty()) {
q.addQueryItem("res", _screenResolution);
}
if (!_userAgent.isEmpty()) {
q.addQueryItem("ua", _userAgent);
}
if (!_userLanguage.isEmpty()) {
q.addQueryItem("lang", _userLanguage);
}
if (_customDimensions.count() > 0) {
QHash<int, QString>::iterator i;
for (i = _customDimensions.begin(); i != _customDimensions.end(); ++i) {
q.addQueryItem("dimension" + QString::number(i.key()), i.value());
}
}
return q;
}
QString PiwikTracker::getVisitVariables() {
QString varString;
/**
* See spec at https://github.com/piwik/piwik/issues/2165
* Need to pass in format {"1":["key1","value1"],"2":["key2","value2"]}
*/
if (_visitVariables.count() > 0) {
QHash<QString, QString>::iterator i;
varString.append("{");
int num = 0;
for (i = _visitVariables.begin(); i != _visitVariables.end(); ++i) {
if (num != 0) {
varString.append(",");
}
QString thisvar = QString(R"("%1":["%2","%3"])")
.arg(num + 1)
.arg(i.key())
.arg(i.value());
varString.append(thisvar);
num++;
}
varString.append("}");
}
return varString;
}
/**
* Sends a visit request with visit variables
*/
void PiwikTracker::sendVisit(const QString& path, const QString& actionName) {
QUrl url(_trackerUrl.toString() + "/piwik.php");
QUrlQuery q = prepareUrlQuery(path);
QString visitVars = getVisitVariables();
if (visitVars.size() != 0) {
q.addQueryItem("_cvar", visitVars);
}
if (!actionName.isEmpty()) {
q.addQueryItem("action_name", actionName);
}
url.setQuery(q);
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
// try to ensure the network is accessible
_networkAccessManager.setNetworkAccessible(
QNetworkAccessManager::Accessible);
#endif
QNetworkReply* reply = _networkAccessManager.get(QNetworkRequest(url));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
SLOT(replyError(QNetworkReply::NetworkError)));
// ignoring SSL errors
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply,
SLOT(ignoreSslErrors()));
#if PIWIK_TRACKER_DEBUG
qDebug() << __func__ << " - 'url': " << url;
#endif
}
/**
* Sends a ping request
*/
void PiwikTracker::sendPing() {
QUrl url(_trackerUrl.toString() + "/piwik.php");
QUrlQuery q = prepareUrlQuery("");
q.addQueryItem("ping", "1");
url.setQuery(q);
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
// try to ensure the network is accessible
_networkAccessManager.setNetworkAccessible(
QNetworkAccessManager::Accessible);
#endif
QNetworkReply* reply = _networkAccessManager.get(QNetworkRequest(url));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
SLOT(replyError(QNetworkReply::NetworkError)));
// ignoring SSL errors
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply,
SLOT(ignoreSslErrors()));
#if PIWIK_TRACKER_DEBUG
qDebug() << __func__ << " - 'url': " << url;
#endif
}
/**
* Sends an event request
*/
void PiwikTracker::sendEvent(const QString& path, const QString& eventCategory,
const QString& eventAction,
const QString& eventName, int eventValue) {
QUrl url(_trackerUrl.toString() + "/piwik.php");
QUrlQuery q = prepareUrlQuery(path);
if (!eventCategory.isEmpty()) {
q.addQueryItem("e_c", eventCategory);
}
if (!eventAction.isEmpty()) {
q.addQueryItem("e_a", eventAction);
}
if (!eventName.isEmpty()) {
q.addQueryItem("e_n", eventName);
}
q.addQueryItem("e_v", QString::number(eventValue));
url.setQuery(q);
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
// try to ensure the network is accessible
_networkAccessManager.setNetworkAccessible(
QNetworkAccessManager::Accessible);
#endif
QNetworkReply* reply = _networkAccessManager.get(QNetworkRequest(url));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
SLOT(replyError(QNetworkReply::NetworkError)));
// ignoring SSL errors
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply,
SLOT(ignoreSslErrors()));
#if PIWIK_TRACKER_DEBUG
qDebug() << __func__ << " - 'url': " << url;
#endif
}
/**
* Sets a custom dimension
*/
void PiwikTracker::setCustomDimension(int id, QString value) {
_customDimensions[id] = std::move(value);
}
/**
* @brief PiwikTracker::setCustomVisitVariables
* @param name The name of the custom variable to set (key)
* @param value The value to set for this custom variable
*/
void PiwikTracker::setCustomVisitVariables(const QString& name, QString value) {
_visitVariables[name] = std::move(value);
}
void PiwikTracker::replyFinished(QNetworkReply* reply) {
#if PIWIK_TRACKER_DEBUG
qDebug() << "Reply from " << reply->url().path();
#else
Q_UNUSED(reply);
#endif
}
void PiwikTracker::replyError(QNetworkReply::NetworkError code) {
#if PIWIK_TRACKER_DEBUG
qDebug() << "Network error code: " << code;
#else
Q_UNUSED(code);
#endif
}
| 29.837607 | 80 | 0.647379 | Waqar144 |
a9c3a032b172e50801357ec4061872aa0edb0f41 | 2,484 | hpp | C++ | src/core/integrators/pf_multiplexed_mlt/PfMultiplexedMltTracer.hpp | libingzeng/tungsten | 8d3e08f6fe825ee90da9ab3e8008b45821ba3c67 | [
"Apache-2.0",
"Unlicense"
] | 1 | 2018-11-10T19:59:44.000Z | 2018-11-10T19:59:44.000Z | src/core/integrators/pf_multiplexed_mlt/PfMultiplexedMltTracer.hpp | libingzeng/tungsten | 8d3e08f6fe825ee90da9ab3e8008b45821ba3c67 | [
"Apache-2.0",
"Unlicense"
] | null | null | null | src/core/integrators/pf_multiplexed_mlt/PfMultiplexedMltTracer.hpp | libingzeng/tungsten | 8d3e08f6fe825ee90da9ab3e8008b45821ba3c67 | [
"Apache-2.0",
"Unlicense"
] | null | null | null | #ifndef PFMULTIPLEXEDMLTTRACER_HPP_
#define PFMULTIPLEXEDMLTTRACER_HPP_
#include "PfMultiplexedMltSettings.hpp"
#include "PfMultiplexedStats.hpp"
#include "PfLargeStepTracker.hpp"
#include "integrators/bidirectional_path_tracer/ImagePyramid.hpp"
#include "integrators/bidirectional_path_tracer/LightPath.hpp"
#include "integrators/kelemen_mlt/MetropolisSampler.hpp"
#include "integrators/kelemen_mlt/SplatQueue.hpp"
#include "integrators/TraceBase.hpp"
#include "sampling/UniformPathSampler.hpp"
namespace Tungsten {
class AtomicFramebuffer;
class PfMultiplexedMltTracer : public TraceBase
{
private:
struct MarkovChain
{
std::unique_ptr<MetropolisSampler> cameraSampler;
std::unique_ptr<MetropolisSampler> emitterSampler;
std::unique_ptr<LightPath> cameraPath;
std::unique_ptr<LightPath> emitterPath;
std::unique_ptr<SplatQueue> currentSplats;
std::unique_ptr<SplatQueue> proposedSplats;
int currentS;
};
PfMultiplexedMltSettings _settings;
UniformSampler _sampler;
UniformPathSampler _cameraSampler;
UniformPathSampler _emitterSampler;
std::unique_ptr<MarkovChain[]> _chains;
float _lightSplatScale;
ImagePyramid *_pyramid;
void tracePaths(LightPath & cameraPath, PathSampleGenerator & cameraSampler,
LightPath &emitterPath, PathSampleGenerator &emitterSampler,
int s = -1, int t = -1);
int evalSample(LightPath & cameraPath, PathSampleGenerator & cameraSampler,
LightPath &emitterPath, PathSampleGenerator &emitterSampler,
int length, SplatQueue &queue);
public:
PfMultiplexedMltTracer(TraceableScene *scene, const PfMultiplexedMltSettings &settings, uint32 threadId,
UniformSampler &sampler, ImagePyramid *pyramid);
void traceCandidatePath(LightPath &cameraPath, LightPath &emitterPath,
SplatQueue &queue, const std::function<void(Vec3f, int, int)> &addCandidate);
void startSampleChain(int s, int t, float luminance, UniformSampler &cameraReplaySampler,
UniformSampler &emitterReplaySampler);
PfLargeStepTracker runSampleChain(int pathLength, int chainLength, PfMultiplexedStats &stats, float luminanceScale);
UniformPathSampler &cameraSampler()
{
return _cameraSampler;
}
UniformPathSampler &emitterSampler()
{
return _emitterSampler;
}
};
}
#endif /* PFMULTIPLEXEDMLTTRACER_HPP_ */
| 32.25974 | 120 | 0.737118 | libingzeng |
a9c3bbe1107f5b83be82e3daf87488cdebb995f4 | 8,674 | cpp | C++ | ManuvrOS/Transports/StandardIO/StandardIO.cpp | Manuvr/ManuvrOS | e3a812c9b609ad69670ff2f8050a07bd423ebc78 | [
"Apache-2.0"
] | 5 | 2015-03-26T22:58:58.000Z | 2021-06-15T05:36:57.000Z | ManuvrOS/Transports/StandardIO/StandardIO.cpp | Manuvr/ManuvrOS | e3a812c9b609ad69670ff2f8050a07bd423ebc78 | [
"Apache-2.0"
] | 2 | 2016-09-26T09:25:58.000Z | 2017-08-03T05:27:24.000Z | ManuvrOS/Transports/StandardIO/StandardIO.cpp | Manuvr/ManuvrOS | e3a812c9b609ad69670ff2f8050a07bd423ebc78 | [
"Apache-2.0"
] | 2 | 2016-04-29T07:43:32.000Z | 2020-02-07T06:43:01.000Z | /*
File: StandardIO.cpp
Author: J. Ian Lindsay
Date: 2016.07.23
Copyright 2016 Manuvr, 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.
StandardIO is the transport driver for wrapping POSIX-style STDIN/STDOUT/STDERR.
*/
#include "StandardIO.h"
#include <XenoSession/XenoSession.h>
#include <XenoSession/Console/ManuvrConsole.h>
#include <Kernel.h>
#include <Platform/Platform.h>
// Threaded platforms will need this to compensate for a loss of ISR.
extern void* xport_read_handler(void* active_xport);
/*******************************************************************************
* ___ _ ___ _ _ _ _
* / __| |__ _ ______ | _ ) ___(_) |___ _ _ _ __| |__ _| |_ ___
* | (__| / _` (_-<_-< | _ \/ _ \ | / -_) '_| '_ \ / _` | _/ -_)
* \___|_\__,_/__/__/ |___/\___/_|_\___|_| | .__/_\__,_|\__\___|
* |_|
* Constructors/destructors, class initialization functions and so-forth...
*******************************************************************************/
/**
* Constructor.
*/
StandardIO::StandardIO() : ManuvrXport("StandardIO") {
// Build some pre-formed Events.
read_abort_event.repurpose(MANUVR_MSG_XPORT_QUEUE_RDY, (EventReceiver*) this);
read_abort_event.incRefs();
read_abort_event.specific_target = (EventReceiver*) this;
read_abort_event.priority(5);
_bp_set_flag(BPIPE_FLAG_PIPE_PACKETIZED, true);
_xport_mtu = 255;
connected(true);
}
/**
* Destructor
*/
StandardIO::~StandardIO() {
}
/*******************************************************************************
* _ _ _ _
* |_) _|_ _|_ _ ._ |_) o ._ _
* |_) |_| | | (/_ | | | |_) (/_
* |
* Overrides and addendums to BufferPipe.
*******************************************************************************/
/**
* Log has reached the end of its journey. This class will render it to the user.
*
* @param buf A pointer to the buffer.
* @param mm A declaration of memory-management responsibility.
* @return A declaration of memory-management responsibility.
*/
int8_t StandardIO::toCounterparty(StringBuilder* buf, int8_t mm) {
if (connected()) {
char* working_chunk = nullptr;
while (buf->count()) {
working_chunk = buf->position(0);
printf("%s", (const char*) working_chunk);
bytes_sent += strlen(working_chunk);
buf->drop_position(0);
}
// TODO: This prompt ought to be in the console session.
printf("\n%c[36m%s> %c[39m", 0x1B, FIRMWARE_NAME, 0x1B);
fflush(stdout);
return MEM_MGMT_RESPONSIBLE_BEARER;
}
return MEM_MGMT_RESPONSIBLE_ERROR;
}
/*******************************************************************************
* ___________ __
* \__ ___/___________ ____ ____________ ____________/ |_
* | | \_ __ \__ \ / \ / ___/\____ \ / _ \_ __ \ __\
* | | | | \// __ \| | \\___ \ | |_> > <_> ) | \/| |
* |____| |__| (____ /___| /____ >| __/ \____/|__| |__|
* \/ \/ \/ |__|
* These members are particular to the transport driver and any implicit
* protocol it might contain.
*******************************************************************************/
int8_t StandardIO::connect() {
// StandardIO, if instantiated, is ALWAYS connected.
connected(true);
return 0;
}
int8_t StandardIO::disconnect() {
// Perhaps this makes sense in some context. But I cannot imagine it.
//ManuvrXport::disconnect();
return 0;
}
int8_t StandardIO::listen() {
// StandardIO, if instantiated, is ALWAYS listening.
listening(true);
return 0;
}
// TODO: Perhaps reset the terminal?
int8_t StandardIO::reset() {
#if defined(MANUVR_DEBUG)
if (getVerbosity() > 5) local_log.concatf("StandardIO initialized.\n");
#endif
initialized(true);
listen();
connect();
flushLocalLog();
return 0;
}
/**
* Read input from local keyboard.
*/
int8_t StandardIO::read_port() {
char *input_text = (char*) alloca(getMTU()); // Buffer to hold user-input.
int read_len = 0;
if (connected()) {
bzero(input_text, getMTU());
if (nullptr == fgets(input_text, getMTU()-1, stdin)) {
return 0;
}
read_len = strlen(input_text);
// NOTE: This should suffice to be binary-safe.
//read_len = fread(input_text, 1, getMTU(), stdin);
if (read_len > 0) {
bytes_received += read_len;
BufferPipe::fromCounterparty((uint8_t*) input_text, read_len, MEM_MGMT_RESPONSIBLE_BEARER);
}
}
flushLocalLog();
return read_len;
}
/*******************************************************************************
* ######## ## ## ######## ## ## ######## ######
* ## ## ## ## ### ## ## ## ##
* ## ## ## ## #### ## ## ##
* ###### ## ## ###### ## ## ## ## ######
* ## ## ## ## ## #### ## ##
* ## ## ## ## ## ### ## ## ##
* ######## ### ######## ## ## ## ######
*
* These are overrides from EventReceiver interface...
*******************************************************************************/
/**
* This is called when the kernel attaches the module.
* This is the first time the class can be expected to have kernel access.
*
* @return 0 on no action, 1 on action, -1 on failure.
*/
int8_t StandardIO::attached() {
if (EventReceiver::attached()) {
// Tolerate 30ms of latency on the line before flushing the buffer.
read_abort_event.alterSchedulePeriod(30);
read_abort_event.autoClear(false);
reset();
#if !defined (__BUILD_HAS_THREADS)
read_abort_event.enableSchedule(true);
read_abort_event.alterScheduleRecurrence(-1);
platform.kernel()->addSchedule(&read_abort_event);
#else
read_abort_event.enableSchedule(false);
read_abort_event.alterScheduleRecurrence(0);
createThread(&_thread_id, nullptr, xport_read_handler, (void*) this, nullptr);
#endif
return 1;
}
return 0;
}
/**
* Debug support method. This fxn is only present in debug builds.
*
* @param StringBuilder* The buffer into which this fxn should write its output.
*/
void StandardIO::printDebug(StringBuilder *temp) {
if (temp == nullptr) return;
ManuvrXport::printDebug(temp);
temp->concatf("-- Class size %d\n", sizeof(StandardIO));
}
/**
* If we find ourselves in this fxn, it means an event that this class built (the argument)
* has been serviced and we are now getting the chance to see the results. The argument
* to this fxn will never be NULL.
*
* Depending on class implementations, we might choose to handle the completed Event differently. We
* might add values to event's Argument chain and return RECYCLE. We may also free() the event
* ourselves and return DROP. By default, we will return REAP to instruct the Kernel
* to either free() the event or return it to it's preallocate queue, as appropriate. If the event
* was crafted to not be in the heap in its own allocation, we will return DROP instead.
*
* @param event The event for which service has been completed.
* @return A callback return code.
*/
int8_t StandardIO::callback_proc(ManuvrMsg* event) {
/* Setup the default return code. If the event was marked as mem_managed, we return a DROP code.
Otherwise, we will return a REAP code. Downstream of this assignment, we might choose differently. */
int8_t return_value = (0 == event->refCount()) ? EVENT_CALLBACK_RETURN_REAP : EVENT_CALLBACK_RETURN_DROP;
/* Some class-specific set of conditionals below this line. */
switch (event->eventCode()) {
case MANUVR_MSG_XPORT_SEND:
event->clearArgs();
break;
default:
break;
}
return return_value;
}
int8_t StandardIO::notify(ManuvrMsg* active_event) {
int8_t return_value = 0;
switch (active_event->eventCode()) {
case MANUVR_MSG_XPORT_RECEIVE:
case MANUVR_MSG_XPORT_QUEUE_RDY:
read_port();
return_value++;
break;
default:
return_value += ManuvrXport::notify(active_event);
break;
}
flushLocalLog();
return return_value;
}
| 32.125926 | 107 | 0.587042 | Manuvr |
a9c3ca19b3280c73838a2ba9f4bb49861fa436cf | 6,015 | cpp | C++ | external/Winamp SDK/enc_flac/main.cpp | jamesdsmith/gen_discordrpc | fb1ea7f281857448cb93f4bdbd95abd983c7c43d | [
"MIT"
] | null | null | null | external/Winamp SDK/enc_flac/main.cpp | jamesdsmith/gen_discordrpc | fb1ea7f281857448cb93f4bdbd95abd983c7c43d | [
"MIT"
] | null | null | null | external/Winamp SDK/enc_flac/main.cpp | jamesdsmith/gen_discordrpc | fb1ea7f281857448cb93f4bdbd95abd983c7c43d | [
"MIT"
] | null | null | null | /**
* Flake encoder for Winamp
* Copyright (c) 2006 Will Fisher
* The Flake library is Copyright (c) 2006 Justin Ruggles,
* see flake.h for more details
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "AudioCoderFlake.h"
// wasabi based services for localisation support
#include <api/service/waServiceFactory.h>
#include "../Agave/Language/api_language.h"
#include "../winamp/wa_ipc.h"
#include <strsafe.h>
HWND winampwnd = 0;
api_service *WASABI_API_SVC = 0;
api_language *WASABI_API_LNG = 0;
HINSTANCE WASABI_API_LNG_HINST = 0, WASABI_API_ORIG_HINST = 0;
typedef struct
{
configtype cfg;
char configfile[MAX_PATH];
}
configwndrec;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
return TRUE;
}
void readconfig(char *configfile, configtype *cfg)
{
cfg->compression = 8;
if (configfile) GetPrivateProfileStruct("audio_flake", "conf", cfg, sizeof(configtype), configfile);
}
void writeconfig(char *configfile, configtype *cfg)
{
if (configfile) WritePrivateProfileStruct("audio_flake", "conf", cfg, sizeof(configtype), configfile);
}
static HINSTANCE GetMyInstance()
{
MEMORY_BASIC_INFORMATION mbi = {0};
if(VirtualQuery(GetMyInstance, &mbi, sizeof(mbi)))
return (HINSTANCE)mbi.AllocationBase;
return NULL;
}
void GetLocalisationApiService(void)
{
if(!WASABI_API_LNG)
{
// loader so that we can get the localisation service api for use
if(!WASABI_API_SVC)
{
WASABI_API_SVC = (api_service*)SendMessage(winampwnd, WM_WA_IPC, 0, IPC_GET_API_SERVICE);
if (WASABI_API_SVC == (api_service*)1)
{
WASABI_API_SVC = NULL;
return;
}
}
if(!WASABI_API_LNG)
{
waServiceFactory *sf;
sf = WASABI_API_SVC->service_getServiceByGuid(languageApiGUID);
if (sf) WASABI_API_LNG = reinterpret_cast<api_language*>(sf->getInterface());
}
// need to have this initialised before we try to do anything with localisation features
WASABI_API_START_LANG(GetMyInstance(),EncFlakeLangGUID);
}
}
extern "C"
{
unsigned int __declspec(dllexport) GetAudioTypes3(int idx, char *desc)
{
if (idx == 0)
{
GetLocalisationApiService();
StringCchPrintf(desc, 1024, WASABI_API_LNGSTRING(IDS_ENC_FLAC_DESC), FLAKE_IDENT);
return mmioFOURCC('F', 'L', 'A', 'k');
}
return 0;
}
AudioCoder __declspec(dllexport) *CreateAudio3(int nch, int srate, int bps, unsigned int srct, unsigned int *outt, char *configfile)
{
if (srct == mmioFOURCC('P', 'C', 'M', ' ') && *outt == mmioFOURCC('F', 'L', 'A', 'k'))
{
configtype cfg;
readconfig(configfile, &cfg);
*outt = mmioFOURCC('F', 'L', 'A', 'k');
AudioCoderFlake *t=0;
t = new AudioCoderFlake(nch, srate, bps, &cfg);
if (t->GetLastError())
{
delete t;
return NULL;
}
return t;
}
return NULL;
}
void __declspec(dllexport) FinishAudio3(const char *filename, AudioCoder *coder)
{
((AudioCoderFlake*)coder)->FinishAudio(filename);
}
void __declspec(dllexport) FinishAudio3W(const wchar_t *filename, AudioCoder *coder)
{
((AudioCoderFlake*)coder)->FinishAudio(filename);
}
void __declspec(dllexport) PrepareToFinish(const char *filename, AudioCoder *coder)
{
((AudioCoderFlake*)coder)->PrepareToFinish();
}
void __declspec(dllexport) PrepareToFinishW(const wchar_t *filename, AudioCoder *coder)
{
((AudioCoderFlake*)coder)->PrepareToFinish();
}
BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static configwndrec *wr;
switch(uMsg)
{
case WM_INITDIALOG:
wr = (configwndrec *)lParam;
SendMessage(GetDlgItem(hwndDlg,IDC_COMPRESSIONSLIDER),TBM_SETRANGE,TRUE,MAKELONG(0,12));
SendMessage(GetDlgItem(hwndDlg,IDC_COMPRESSIONSLIDER),TBM_SETPOS,TRUE,wr->cfg.compression);
break;
case WM_NOTIFY:
if(wParam == IDC_COMPRESSIONSLIDER)
{
LPNMHDR l = (LPNMHDR)lParam;
if(l->idFrom == IDC_COMPRESSIONSLIDER)
wr->cfg.compression = SendMessage(GetDlgItem(hwndDlg,IDC_COMPRESSIONSLIDER),TBM_GETPOS,0,0);
}
break;
case WM_DESTROY:
writeconfig(wr->configfile,&wr->cfg);
free(wr); wr=NULL;
break;
}
return 0;
}
HWND __declspec(dllexport) ConfigAudio3(HWND hwndParent, HINSTANCE hinst, unsigned int outt, char *configfile)
{
if (outt == mmioFOURCC('F', 'L', 'A', 'k'))
{
configwndrec *wr = (configwndrec*)malloc(sizeof(configwndrec));
if (configfile) lstrcpyn(wr->configfile, configfile, MAX_PATH);
else wr->configfile[0] = 0;
readconfig(configfile, &wr->cfg);
GetLocalisationApiService();
return WASABI_API_CREATEDIALOGPARAM(IDD_CONFIG, hwndParent, DlgProc, (LPARAM)wr);
}
return NULL;
}
int __declspec(dllexport) SetConfigItem(unsigned int outt, char *item, char *data, char *configfile)
{
// nothing yet
return 0;
}
int __declspec(dllexport) GetConfigItem(unsigned int outt, char *item, char *data, int len, char *configfile)
{
if (outt == mmioFOURCC('F', 'L', 'A', 'k'))
{
configtype cfg;
readconfig(configfile, &cfg);
if (!lstrcmpi(item, "bitrate")) lstrcpynA(data,"755",len); // FUCKO: this is ment to be an estimate for approximations of output filesize (used by ml_pmp). Improve this.
else if (!lstrcmpi(item,"extension")) lstrcpynA(data,"flac",len);
return 1;
}
return 0;
}
void __declspec(dllexport) SetWinampHWND(HWND hwnd)
{
winampwnd = hwnd;
}
};
| 28.372642 | 173 | 0.713383 | jamesdsmith |
a9c68917f2e22a46ddeab26c26c545a13cc0b623 | 199 | cc | C++ | CalibCalorimetry/EcalLaserCorrection/plugins/SealModule.cc | knash/cmssw | d4f63ec2b2c322e3be4c4d78ce20ebddbcd88ca7 | [
"Apache-2.0"
] | 1 | 2018-07-25T03:57:34.000Z | 2018-07-25T03:57:34.000Z | CalibCalorimetry/EcalLaserCorrection/plugins/SealModule.cc | knash/cmssw | d4f63ec2b2c322e3be4c4d78ce20ebddbcd88ca7 | [
"Apache-2.0"
] | 1 | 2021-06-28T14:25:47.000Z | 2021-06-30T10:12:29.000Z | CalibCalorimetry/EcalLaserCorrection/plugins/SealModule.cc | knash/cmssw | d4f63ec2b2c322e3be4c4d78ce20ebddbcd88ca7 | [
"Apache-2.0"
] | null | null | null | #include "FWCore/PluginManager/interface/ModuleDef.h"
#include "CalibCalorimetry/EcalLaserCorrection/plugins/EcalLaserCorrectionService.h"
DEFINE_FWK_EVENTSETUP_MODULE(EcalLaserCorrectionService);
| 33.166667 | 84 | 0.879397 | knash |
a9c8c6444667959625ef6a132362c188ae943a4b | 4,610 | cpp | C++ | source/backend/arm82/Arm82Moments.cpp | foreverlms/MNN | 8f9d3e3331fb54382bb61ac3a2087637a161fec5 | [
"Apache-2.0"
] | 6,958 | 2019-05-06T02:38:02.000Z | 2022-03-31T18:08:48.000Z | source/backend/arm82/Arm82Moments.cpp | foreverlms/MNN | 8f9d3e3331fb54382bb61ac3a2087637a161fec5 | [
"Apache-2.0"
] | 1,775 | 2019-05-06T04:40:19.000Z | 2022-03-30T15:39:24.000Z | source/backend/arm82/Arm82Moments.cpp | foreverlms/MNN | 8f9d3e3331fb54382bb61ac3a2087637a161fec5 | [
"Apache-2.0"
] | 1,511 | 2019-05-06T02:38:05.000Z | 2022-03-31T16:59:39.000Z | //
// Arm82Moments.cpp
// MNN
//
// Created by MNN on 2019/02/28.
// Copyright © 2018, Alibaba Group Holding Limited
//
#if defined(__ANDROID__) || defined(__aarch64__)
#include "Arm82Moments.hpp"
#include "Arm82Backend.hpp"
#include "Arm82Vec.hpp"
#include "core/Concurrency.h"
#include <MNN/MNNDefine.h>
#include "core/Macro.h"
#include "core/TensorUtils.hpp"
#ifdef MNN_USE_NEON
#include <arm_neon.h>
#endif
using Vec = MNN::Math::Vec<FLOAT16, 8>;
namespace MNN {
Arm82Moments::Arm82Moments(Backend *backend, const MNN::Op *op) : Execution(backend) {
auto momentsParam = op->main_as_MomentsParam();
if (momentsParam->dim()) {
for (int i = 0; i < momentsParam->dim()->size(); ++i) {
mAxis.push_back(momentsParam->dim()->data()[i]);
}
}
mKeepDims = momentsParam->keepDims();
MNN_ASSERT(DataType_DT_FLOAT == momentsParam->dType());
}
ErrorCode Arm82Moments::onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) {
return NO_ERROR;
}
void Arm82Moments::calculateMean(const FLOAT16 *src, FLOAT16 *mean, int channelBlock, int planeNumber) {
const int numberThread = ((Arm82Backend*)backend())->numberThread();
MNN_CONCURRENCY_BEGIN(tId, numberThread) {
int step = UP_DIV(channelBlock, numberThread), start = tId * step, end = ALIMIN(start + step, channelBlock);
for (int z = start; z < end; ++z) {
const FLOAT16* srcZ = src + z * planeNumber * 8;
FLOAT16* meanZ = mean + z * 8;
Vec sum(0);
for (int i = 0; i < planeNumber; ++i) {
sum = sum + Vec::load(srcZ + i * 8);
}
Vec result = sum / (float)planeNumber;
Vec::save(meanZ, result);
}
} MNN_CONCURRENCY_END();
}
void Arm82Moments::calculateVariance(const FLOAT16 *src, const FLOAT16 *mean, FLOAT16* var, int channelBlock, int planeNumber) {
const int numberThread = ((Arm82Backend*)backend())->numberThread();
MNN_CONCURRENCY_BEGIN(tId, numberThread) {
int step = UP_DIV(channelBlock, numberThread), start = tId * step, end = ALIMIN(start + step, channelBlock);
for (int z = start; z < end; ++z) {
const FLOAT16* srcZ = src + z * planeNumber * 8, *meanZ = mean + z * 8;
FLOAT16* varZ = var + z * 8;
Vec sum(0), meanVal = Vec::load(meanZ);
for (int i = 0; i < planeNumber; ++i) {
Vec diff = Vec::load(srcZ + i * 8) - meanVal;
sum = sum + diff * diff;
}
Vec result = sum / (float)planeNumber;
Vec::save(varZ, result);
}
} MNN_CONCURRENCY_END();
}
ErrorCode Arm82Moments::onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) {
MNN_ASSERT(1 == inputs.size());
MNN_ASSERT(2 == outputs.size());
auto input = inputs[0], mean = outputs[0], variance = outputs[1];
// the layout of Moments is NC4HW4, now only support for calculating Moments along height and width
MNN_ASSERT(MNN_DATA_FORMAT_NC4HW4 == TensorUtils::getDescribe(input)->dimensionFormat);
MNN_ASSERT(mKeepDims);
MNN_ASSERT(mAxis.size() == 2 && mAxis[0] == 2 && mAxis[1] == 3);
const int batch = input->batch(), channelBlock = UP_DIV(mean->channel(), 8);
const int inBatchStride = ARM82TensorStrideHelper(input, 0), outBatchStride = ARM82TensorStrideHelper(mean, 0);
const int planeNumber = ARM82TensorStrideHelper(input, 1);
// mean
for (int b = 0; b < batch; ++b) {
const FLOAT16* srcPtr = input->host<FLOAT16>() + b * inBatchStride;
FLOAT16* meanPtr = mean->host<FLOAT16>() + b * outBatchStride;
calculateMean(srcPtr, meanPtr, channelBlock, planeNumber);
}
// variance
for (int b = 0; b < batch; ++b) {
const FLOAT16* srcPtr = input->host<FLOAT16>() + b * inBatchStride;
const FLOAT16* meanPtr = mean->host<FLOAT16>() + b * outBatchStride;
FLOAT16* variancePtr = variance->host<FLOAT16>() + b * outBatchStride;
calculateVariance(srcPtr, meanPtr, variancePtr, channelBlock, planeNumber);
}
return NO_ERROR;
}
class Arm82MomentsCreator : public Arm82Backend::Arm82Creator {
public:
virtual Execution *onCreate(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs,
const MNN::Op *op, Backend *backend) const override {
return new Arm82Moments(backend, op);
}
};
REGISTER_ARM82_OP_CREATOR(OpType_Moments, Arm82MomentsCreator);
} // namespace MNN
#endif
| 38.099174 | 128 | 0.624729 | foreverlms |
a9ccb939d310f8a86e60ffd5b8fd81cc8949b52c | 7,616 | cpp | C++ | examples/demo1.cpp | openlab-vn-ua/ImageRotation | 2210d5cd846148aa705e53df658d62a034680b73 | [
"Unlicense"
] | 4 | 2018-10-05T07:09:57.000Z | 2022-03-05T12:03:11.000Z | examples/demo1.cpp | openlab-vn-ua/ImageRotation | 2210d5cd846148aa705e53df658d62a034680b73 | [
"Unlicense"
] | null | null | null | examples/demo1.cpp | openlab-vn-ua/ImageRotation | 2210d5cd846148aa705e53df658d62a034680b73 | [
"Unlicense"
] | 3 | 2020-01-28T03:03:16.000Z | 2021-07-30T01:38:33.000Z | /* **************************************************************
** NAME: Fast Bitmap Rotation and Scaling
** AUTHOR: Steven M Mortimer
** COMPILER: Visual C++ V6.0 Enterprise SP3
** Target Platform: Win32
** RIGHTS: Stevem Mortimer
** Date: 18th Jan 2000
************************************************************** */
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include "cdib.h"
#include "../src/rotate.h"
/////////////////////////////////////////////////////////////////
// defines
#define _MINSCALE 0.4f
#define _MAXSCALE 5.0f
#define SZIMAGE "test_64x64.bmp"
/////////////////////////////////////////////////////////////////
// Globals
CDIB* gDibSrc = NULL;
CDIB* gDibDst = NULL;
float gdScale = _MAXSCALE;
float gdAngle = 0.0f;
float gdScaleDir = 0.1f;
double gdTicksPerSec = 0.0;
bool gbTimeFunction = false;
/////////////////////////////////////////////////////////////////
// Function Prototypes
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
/////////////////////////////////////////////////////////////////
// WinMain
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
// Register the window class
WNDCLASS wndclass;
ZeroMemory(&wndclass, sizeof(WNDCLASS));
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.hInstance = hInstance;
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.lpszClassName = __FILE__;
RegisterClass(&wndclass);
// Check if we can use the high performace counter
// for timing the rotation function
LARGE_INTEGER perfreq;
if(QueryPerformanceFrequency(&perfreq))
{
gdTicksPerSec = (double)perfreq.LowPart;
gbTimeFunction = true;
}
else
{
MessageBox(NULL,
"High resolution timer not available",
"Warning", MB_OK);
}
// Create our source and destination DIB`s
gDibSrc = new CDIB();
gDibDst = new CDIB();
if(gDibSrc && gDibDst)
{
// Create Window
hwnd = CreateWindow(
__FILE__, "Fast Bitmap Rotation", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 400, 400,
NULL, NULL, hInstance, NULL);
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
// cleanup DIB`s
delete gDibSrc;
delete gDibDst;
}
return msg.wParam;
}
/////////////////////////////////////////////////////////////////
double GetTimer()
{
if(gbTimeFunction)
{
LARGE_INTEGER time;
QueryPerformanceCounter(&time);
return (double)time.QuadPart / gdTicksPerSec;
}
return 0.0;
}
/////////////////////////////////////////////////////////////////
void Update(HDC hdc)
{
// ZeroMemory(gDibDst->m_pSrcBits, gDibDst->m_iHeight * gDibDst->m_iSWidth); // clear
double dStartT = GetTimer();
// Call RotateWrapFill routine, using center of the window and the
// center of the source image as the points to rotate around
// RotateDrawClip(
RotateDrawFill(
static_cast<RotatePixel_t*>(gDibDst->m_pSrcBits), gDibDst->m_iWidth,
gDibDst->m_iHeight, gDibDst->m_iSWidth,
static_cast<RotatePixel_t*>(gDibSrc->m_pSrcBits), gDibSrc->m_iWidth,
gDibSrc->m_iHeight, gDibSrc->m_iSWidth,
(float)gDibDst->m_iWidth/2, (float)gDibDst->m_iHeight/2,
(float)gDibSrc->m_iWidth/2, (float)gDibSrc->m_iHeight/2,
gdAngle, gdScale);
// Change direction of the scale
if(gdScale <= _MINSCALE || gdScale >= _MAXSCALE)
{
gdScaleDir *= -1.0;
}
// Update angle and scale
gdScale += gdScaleDir;
gdAngle += 0.02f;
double dUpdateT = GetTimer();
// Copy our rotated image to the screen
BitBlt(hdc, 0, 0, gDibDst->m_iWidth, gDibDst->m_iHeight,
gDibDst->m_hdc, 0, 0, SRCCOPY);
double dRenderT = GetTimer();
// Print function timing satistics
if(gbTimeFunction)
{
char szBuffer[256];
TextOut(hdc, 5, 5, szBuffer,
sprintf(szBuffer, "Update took %3.6f (~%3.2ffps)",
dUpdateT-dStartT, 1.0 / (dUpdateT-dStartT)));
TextOut(hdc, 5, 20, szBuffer,
sprintf(szBuffer, "Render took %3.6f (~%3.2ffps)",
dRenderT-dUpdateT, 1.0 / (dRenderT-dUpdateT)));
}
}
////////////////////////////////////////////////////////////////
BOOL OnCreate(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct)
{
BOOL bSuccess = FALSE;
// Load test bitmap
HBITMAP hbm = (HBITMAP)LoadImage(NULL, SZIMAGE, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE);
if(hbm)
{
// Map the bitmap into a dc
HDC hdc = CreateCompatibleDC(NULL);
HBITMAP hbmOld = (HBITMAP)SelectObject(hdc, hbm);
// Get info about this bitmap
BITMAP bm;
if(GetObject(hbm, sizeof(BITMAP), &bm) != 0)
{
// Convert the bitmap into DIB of known colour depth
if(gDibSrc->Create(hdc, 0, 0, bm.bmWidth, bm.bmHeight, sizeof(RotatePixel_t)))
{
// Start the update timer
SetTimer(hwnd, 0, 100, NULL);
bSuccess = TRUE;
}
// cleanup hdc
SelectObject(hdc, hbmOld);
DeleteDC(hdc);
}
// delete the loaded image
DeleteObject(hbm);
}
else
{
char szError[512];
wsprintf(szError, "Error loading image %s", SZIMAGE);
MessageBox(hwnd, szError, "oops", MB_OK);
}
return bSuccess;
}
/////////////////////////////////////////////////////////////////
void OnSize(HWND hwnd, UINT state, int x, int y)
{
// Recreate the window DIB to match the size of the window
gDibDst->Create(NULL, 0, 0, x, y, sizeof(RotatePixel_t));
}
/////////////////////////////////////////////////////////////////
BOOL OnEraseBkGnd(HWND hwnd, HDC hdc)
{
// clearing the bk results in tears.
return TRUE;
}
/////////////////////////////////////////////////////////////////
void OnPaint(HWND hwnd)
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint (hwnd, &ps);
Update(hdc);
EndPaint (hwnd, &ps) ;
}
/////////////////////////////////////////////////////////////////
BOOL OnTimer(HWND hwnd, UINT id)
{
HDC hdc = GetDC(hwnd);
Update(hdc);
ReleaseDC(hwnd, hdc);
return TRUE;
}
/////////////////////////////////////////////////////////////////
void OnDestroy(HWND hwnd)
{
PostQuitMessage(0);
}
/////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg,
WPARAM wParam, LPARAM lParam)
{
switch (iMsg)
{
HANDLE_MSG( hwnd, WM_CREATE, OnCreate );
HANDLE_MSG( hwnd, WM_SIZE, OnSize );
HANDLE_MSG( hwnd, WM_PAINT, OnPaint );
HANDLE_MSG( hwnd, WM_ERASEBKGND, OnEraseBkGnd );
HANDLE_MSG( hwnd, WM_TIMER, OnTimer );
HANDLE_MSG( hwnd, WM_DESTROY, OnDestroy );
}
return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
/////////////////////////////////////////////////////////////////
//End of File
| 29.984252 | 90 | 0.50302 | openlab-vn-ua |
a9cd60e6da7bc487a5ad11c502a692c1b5f47efb | 1,515 | cpp | C++ | problem2.cpp | paolaguarasci/domJudge | 830f5ca3f271732668930a2a8d3be98d96661691 | [
"MIT"
] | null | null | null | problem2.cpp | paolaguarasci/domJudge | 830f5ca3f271732668930a2a8d3be98d96661691 | [
"MIT"
] | null | null | null | problem2.cpp | paolaguarasci/domJudge | 830f5ca3f271732668930a2a8d3be98d96661691 | [
"MIT"
] | null | null | null | /*
NOTA! Va fatto usando array di char e non oggetti stringa. Perchè? Sto cercando di capire...
*/
#include <iostream>
#include <cstring>
using namespace std;
const int LIMITE = 100;
int main() {
// Prendo i dati da input
// key, numero stringhe, stringhe
char key[LIMITE];
cin >> key;
unsigned n;
cin >> n;
char lista[LIMITE][21];
for(unsigned i = 0; i < n; i++) {
cin >> lista[i];
}
// Salvo il numero delle occorrenze della key in ogni stringa
int occ[LIMITE] = {0};
for (unsigned i = 0; i < n; i++) {
for(unsigned j = 0; j < strlen(lista[i]); j++) {
char tmp[LIMITE];
for (unsigned k = 0; k < strlen(key); k++) {
tmp[k] = lista[i][j+k];
}
tmp[strlen(key)] = '\0';
if(strcmp(tmp, key) == 0) {
// cout << tmp << endl;
occ[i]++;
}
/*
if (lista[i].substr(j, key.length()) == key) {
occ[i]++;
}
*/
}
}
// Stampo la lista delle occorrenze per ogni stringa
/*for(unsigned i = 0; i < n; i++) {
cout << lista[i] << " " << occ[i] << endl;
}*/
// Mi procuro (l'indice de) la stringa con il numero massimo di occorrenze
// a parità di valore prendo la prima che incontro
int max = 0;
for (unsigned i = 0; i < n; i++) {
if(occ[i] > occ[max]) {
max = i;
}
}
// Stampo la prima stringa con il num maggiore di occorrenze della key
cout << lista[max];
return 0;
}
| 23.671875 | 92 | 0.509571 | paolaguarasci |
a9de1564bfc9ea7e8aef90d4e70ad4b36a8c4718 | 11,832 | cpp | C++ | frontends/shared/os_win32debug.cpp | pixeljetstream/luxinia1 | 5d69b2d47d5ed4501dc155cfef999475f2fdfe2a | [
"Unlicense",
"MIT"
] | 31 | 2015-01-05T18:22:15.000Z | 2020-12-07T03:21:50.000Z | frontends/shared/os_win32debug.cpp | pixeljetstream/luxinia1 | 5d69b2d47d5ed4501dc155cfef999475f2fdfe2a | [
"Unlicense",
"MIT"
] | null | null | null | frontends/shared/os_win32debug.cpp | pixeljetstream/luxinia1 | 5d69b2d47d5ed4501dc155cfef999475f2fdfe2a | [
"Unlicense",
"MIT"
] | 12 | 2015-01-05T19:17:44.000Z | 2021-01-15T08:56:06.000Z | // Copyright (C) 2004-2009 Christoph Kubisch & Eike Decker
// This file is part of the "Luxinia Engine".
// For conditions of distribution and use, see luxinia.h
#include "os.h"
#ifndef LUX_PLATFORM_WINDOWS
#error "Wrong Platform"
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef LUX_COMPILER_MSC
#define OS_DEBUG_USE_MINIDUMP
#endif
//////////////////////////////////////////////////////////////////////////
static char l_crashReportFileName[MAX_PATH] = {"luxcrash.dmp"};
static osErrorPostReport_fn *l_postWriteReport = NULL;
#ifdef OS_DEBUG_USE_MINIDUMP
#include <dbghelp.h>
#include <shellapi.h>
#include <shlobj.h>
#include <tchar.h>
#include <strsafe.h>
#include <crtdbg.h>
// based on article:
// http://www.debuginfo.com/articles/effminidumps2.html
BOOL CALLBACK MyMiniDumpCallback(
PVOID pParam,
const PMINIDUMP_CALLBACK_INPUT pInput,
PMINIDUMP_CALLBACK_OUTPUT pOutput
)
{
BOOL bRet = LUX_FALSE;
// Check parameters
if( pInput == 0 )
return LUX_FALSE;
if( pOutput == 0 )
return LUX_FALSE;
// Process the callbacks
switch( pInput->CallbackType )
{
case IncludeModuleCallback:
{
// Include the module into the dump
bRet = LUX_TRUE;
}
break;
case IncludeThreadCallback:
{
// Include the thread into the dump
bRet = LUX_TRUE;
}
break;
case ModuleCallback:
{
// Does the module have ModuleReferencedByMemory flag set ?
if( !(pOutput->ModuleWriteFlags & ModuleReferencedByMemory) )
{
// No, it does not - exclude it
_tprintf( _T("Excluding module: %s \n"), pInput->Module.FullPath );
pOutput->ModuleWriteFlags &= (~ModuleWriteModule);
}
bRet = LUX_TRUE;
}
break;
case ThreadCallback:
{
// Include all thread information into the minidump
bRet = LUX_TRUE;
}
break;
case ThreadExCallback:
{
// Include this information
bRet = LUX_TRUE;
}
break;
case MemoryCallback:
{
// We do not include any information here -> return FALSE
bRet = LUX_FALSE;
}
break;
// case CancelCallback:
// break;
}
return bRet;
}
LONG osErrorHandlerMiniDump(PEXCEPTION_POINTERS pEp)
{
HANDLE hFile = CreateFileA( l_crashReportFileName, GENERIC_READ | GENERIC_WRITE,
0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( ( hFile != NULL ) && ( hFile != INVALID_HANDLE_VALUE ) )
{
// Create the minidump
MINIDUMP_EXCEPTION_INFORMATION mdei;
mdei.ThreadId = GetCurrentThreadId();
mdei.ExceptionPointers = pEp;
mdei.ClientPointers = LUX_FALSE;
MINIDUMP_CALLBACK_INFORMATION mci;
mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE)MyMiniDumpCallback;
mci.CallbackParam = 0;
/*
MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithPrivateReadWriteMemory |
MiniDumpWithDataSegs |
MiniDumpWithHandleData |
//MiniDumpWithFullMemoryInfo |
//MiniDumpWithThreadInfo |
MiniDumpWithUnloadedModules
);
*/
MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory);
BOOL rv = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(),
hFile, mdt, (pEp != 0) ? &mdei : 0, 0, &mci );
if( !rv )
_tprintf( _T("MiniDumpWriteDump failed. Error: %u \n"), GetLastError() );
else {
_tprintf( _T("Minidump created.\n") );
}
// Close the file
CloseHandle( hFile );
if( !rv ){
hFile = NULL;
}
}
else
{
_tprintf( _T("CreateFile failed. Error: %u \n"), GetLastError() );
}
if (l_postWriteReport != NULL){
l_postWriteReport(hFile != NULL ? l_crashReportFileName : NULL);
}
/*
BOOL bMiniDumpSuccessful;
TCHAR szPath[MAX_PATH];
TCHAR szFileName[MAX_PATH];
TCHAR* szAppName = _T("AppName");
TCHAR* szVersion = _T("v1.0");
DWORD dwBufferSize = MAX_PATH;
HANDLE hDumpFile;
SYSTEMTIME stLocalTime;
MINIDUMP_EXCEPTION_INFORMATION ExpParam;
GetLocalTime( &stLocalTime );
//GetTempPath( dwBufferSize, szPath );
szPath[0] = 0;
StringCchPrintf( szFileName, MAX_PATH, _T("%s%s"), szPath, szAppName );
CreateDirectory( szFileName, NULL );
StringCchPrintf( szFileName, MAX_PATH, _T("%s%s\\%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp"),
szPath, szAppName, szVersion,
stLocalTime.wYear, stLocalTime.wMonth, stLocalTime.wDay,
stLocalTime.wHour, stLocalTime.wMinute, stLocalTime.wSecond,
GetCurrentProcessId(), GetCurrentThreadId());
hDumpFile = CreateFile(szFileName, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_WRITE|FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
_tprintf(szFileName);
ExpParam.ThreadId = GetCurrentThreadId();
ExpParam.ExceptionPointers = pExceptionPointers;
ExpParam.ClientPointers = TRUE;
bMiniDumpSuccessful = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
hDumpFile, MiniDumpWithDataSegs, &ExpParam, NULL, NULL);
*/
return EXCEPTION_EXECUTE_HANDLER;
}
//////////////////////////////////////////////////////////////////////////
#else
void osErrorDumpStackFile(FILE *logfile,void* erroraddress, void* pEntry)
{
#ifndef LUX_ARCH_X86
return;
#else
char *eNextBP = pEntry;
char *p, *pBP;
uint i, x, BpPassed;
static int running = 0;
if(running)
{
fprintf(logfile, "\n***\n*** Recursive Stack Dump skipped\n***\n");
return;
}
running = LUX_TRUE;
fprintf(logfile, "****************************************************\n");
fprintf(logfile, "*** CallStack:\n");
fprintf(logfile, "****************************************************\n");
/* ====================================================================== */
/* */
/* BP +x ... -> == SP (current top of stack) */
/* ... -> Local data of current function */
/* BP +4 0xabcd -> 32 address of calling function */
/* +<==BP 0xabcd -> Stack address of next stack frame (0, if end) */
/* | BP -1 ... -> Aruments of function call */
/* Y */
/* | BP -x ... -> Local data of calling function */
/* | */
/* Y (BP)+4 0xabcd -> 32 address of calling function */
/* +==>BP) 0xabcd -> Stack address of next stack frame (0, if end) */
/* ... */
/* ====================================================================== */
BpPassed = (eNextBP != NULL);
if(! eNextBP)
{
#if defined(LUX_COMPILER_MSC)
__asm mov eNextBP, eBp;
#elif defined(LUX_COMPILER_GCC)
asm ("mov %ebp, %;"
:"=r"(eNextBP));
#else
#error "compiler unknown"
#endif
}
else
fprintf(logfile, "\n Fault Occured At $ADDRESS:%08LX\n", (size_t)erroraddress);
// prevent infinite loops
for(i = 0; eNextBP && i < 100; i++)
{
pBP = eNextBP; // keep current BasePointer
eNextBP = *(char **)pBP; // dereference next BP
p = pBP + 8;
// Write 20 Bytes of potential arguments
fprintf(logfile, " with ");
for(x = 0; p < eNextBP && x < 20; p++, x++)
fprintf(logfile, "%02X ", *(uchar *)p);
fprintf(logfile, "\n\n");
//if(i == 1 && ! BpPassed)
// fprintf(logfile, "****************************************************\n"
// " Fault Occured Here:\n");
// Write the backjump address
fprintf(logfile, "*** %2d called from $ADDRESS:%08X\n", i, *(char **)(pBP + 4));
if(*(char **)(pBP + 4) == NULL)
break;
}
fprintf(logfile, "************************************************************\n");
fprintf(logfile, "\n\n");
fflush(logfile);
running = LUX_FALSE;
#endif
}
// Implemention based on work by Stefan Woerthmueller
// http://www.ddj.com/development-tools/185300443
LONG osErrorHandlerStackPrint(struct _EXCEPTION_POINTERS * ExInfo)
{ char* errortext = "";
uint errorid = ExInfo->ExceptionRecord->ExceptionCode;
void* erroraddress = ExInfo->ExceptionRecord->ExceptionAddress;
FILE* logfile = l_crashReportFileName[0] ? fopen(l_crashReportFileName, "w") : NULL;
switch(ExInfo->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION : errortext = "ACCESS VIOLATION" ; break;
case EXCEPTION_DATATYPE_MISALIGNMENT : errortext = "DATATYPE MISALIGNMENT" ; break;
case EXCEPTION_BREAKPOINT : errortext = "BREAKPOINT" ; break;
case EXCEPTION_SINGLE_STEP : errortext = "SINGLE STEP" ; break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED : errortext = "ARRAY BOUNDS EXCEEDED" ; break;
case EXCEPTION_FLT_DENORMAL_OPERAND : errortext = "FLT DENORMAL OPERAND" ; break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO : errortext = "FLT DIVIDE BY ZERO" ; break;
case EXCEPTION_FLT_INEXACT_RESULT : errortext = "FLT INEXACT RESULT" ; break;
case EXCEPTION_FLT_INVALID_OPERATION : errortext = "FLT INVALID OPERATION" ; break;
case EXCEPTION_FLT_OVERFLOW : errortext = "FLT OVERFLOW" ; break;
case EXCEPTION_FLT_STACK_CHECK : errortext = "FLT STACK CHECK" ; break;
case EXCEPTION_FLT_UNDERFLOW : errortext = "FLT UNDERFLOW" ; break;
case EXCEPTION_INT_DIVIDE_BY_ZERO : errortext = "INT DIVIDE BY ZERO" ; break;
case EXCEPTION_INT_OVERFLOW : errortext = "INT OVERFLOW" ; break;
case EXCEPTION_PRIV_INSTRUCTION : errortext = "PRIV INSTRUCTION" ; break;
case EXCEPTION_IN_PAGE_ERROR : errortext = "IN PAGE ERROR" ; break;
case EXCEPTION_ILLEGAL_INSTRUCTION : errortext = "ILLEGAL INSTRUCTION" ; break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION : errortext = "NONCONTINUABLE EXCEPTION" ; break;
case EXCEPTION_STACK_OVERFLOW : errortext = "STACK OVERFLOW" ; break;
case EXCEPTION_INVALID_DISPOSITION : errortext = "INVALID DISPOSITION" ; break;
case EXCEPTION_GUARD_PAGE : errortext = "GUARD PAGE" ; break;
default: errortext = "(unknown)"; break;
}
if(logfile != NULL)
{
fprintf(logfile, "****************************************************\n");
fprintf(logfile, "*** A Programm Fault occured:\n");
fprintf(logfile, "*** Error code %08X: %s\n", errorid, errortext);
fprintf(logfile, "****************************************************\n");
fprintf(logfile, "*** Address: %08X\n", (size_t)erroraddress);
fprintf(logfile, "*** Flags: %08X\n", ExInfo->ExceptionRecord->ExceptionFlags);
osErrorDumpStackFile(logfile,erroraddress,(void*)ExInfo->ContextRecord->Ebp);
fclose(logfile);
//system("pause");
}
if (l_postWriteReport != NULL){
l_postWriteReport(logfile != NULL ? l_crashReportFileName : NULL);
}
return EXCEPTION_EXECUTE_HANDLER;
}
#endif
//////////////////////////////////////////////////////////////////////////
void osErrorEnableHandler(const char *reportfilename,osErrorPostReport_fn *func)
{
l_postWriteReport = func;
strncpy(l_crashReportFileName,reportfilename,sizeof(char)*MAX_PATH);
if (reportfilename || func){
#ifdef OS_DEBUG_USE_MINIDUMP
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)osErrorHandlerMiniDump);
#else
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)osErrorHandlerStackPrint);
#endif
}
}
| 31.806452 | 107 | 0.585869 | pixeljetstream |
a9e0af65e275279e68e570698efcdda02ac24cae | 1,390 | cpp | C++ | DSA/Trees/sum-tree.cpp | abhisheknaiidu/dsa | fe3f54df6802d2520142992b541602ce5ee24f26 | [
"MIT"
] | 54 | 2020-07-31T14:50:23.000Z | 2022-03-14T11:03:02.000Z | DSA/Trees/sum-tree.cpp | abhisheknaiidu/NOOB | fe3f54df6802d2520142992b541602ce5ee24f26 | [
"MIT"
] | null | null | null | DSA/Trees/sum-tree.cpp | abhisheknaiidu/NOOB | fe3f54df6802d2520142992b541602ce5ee24f26 | [
"MIT"
] | 30 | 2020-08-15T17:39:02.000Z | 2022-03-10T06:50:18.000Z | #pragma GCC optimize("Ofast")
#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <iterator>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
void abhisheknaiidu()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
struct Node {
int data;
Node* left;
Node* right;
};
// utility fxn
Node* newNode(int n) {
Node* temp = new Node;
temp->data = n;
temp->left = temp->right = NULL;
return(temp);
}
// T.C - O(N)
int sum(Node* root) {
if(root == NULL) return 0;
return sum(root->left) + root->data + sum(root->right);
}
int checkSum(Node* root) {
if((root->left == NULL && root->right == NULL) || (root == NULL)) return 1;
int left = sum(root->left);
int right = sum(root->right);
cout << "left " << left << " " << "right " << right << endl;
if((root->data == left + right) && checkSum(root->left) && checkSum(root-left)) {
return 1;
}
return 0;
}
int main(int argc, char* argv[]) {
abhisheknaiidu();
Node* root = newNode(10);
root->left = newNode(20);
root->right = newNode(30);
root->left->left = newNode(10);
// root->left->right = newNode(10);
cout << checkSum(root) << endl;
return 0;
} | 19.857143 | 82 | 0.631655 | abhisheknaiidu |
a9e3dc0052a901ba8a921eeb248fefda6d85f291 | 3,291 | cpp | C++ | src/objective_functions/loss_functions/geom_negloglike.cpp | andy-yoo/lbann-andy | 237c45c392e7a5548796ac29537ab0a374e7e825 | [
"Apache-2.0"
] | null | null | null | src/objective_functions/loss_functions/geom_negloglike.cpp | andy-yoo/lbann-andy | 237c45c392e7a5548796ac29537ab0a374e7e825 | [
"Apache-2.0"
] | null | null | null | src/objective_functions/loss_functions/geom_negloglike.cpp | andy-yoo/lbann-andy | 237c45c392e7a5548796ac29537ab0a374e7e825 | [
"Apache-2.0"
] | null | null | null | ////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014-2016, Lawrence Livermore National Security, LLC.
// Produced at the Lawrence Livermore National Laboratory.
// Written by the LBANN Research Team (B. Van Essen, et al.) listed in
// the CONTRIBUTORS file. <lbann-dev@llnl.gov>
//
// LLNL-CODE-697807.
// All rights reserved.
//
// This file is part of LBANN: Livermore Big Artificial Neural Network
// Toolkit. For details, see http://software.llnl.gov/LBANN or
// https://github.com/LLNL/LBANN.
//
// Licensed under the Apache License, Version 2.0 (the "Licensee"); 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 "lbann/objective_functions/loss_functions/geom_negloglike.hpp"
namespace lbann {
EvalType geom_negloglike::finish_evaluate_compute(
const AbsDistMat& predictions, const AbsDistMat& ground_truth) {
// Local matrices
const Mat& predictions_local = predictions.LockedMatrix();
const Mat& ground_truth_local = ground_truth.LockedMatrix();
// Matrix parameters
const int width = predictions.Width();
const int local_height = predictions_local.Height();
const int local_width = predictions_local.Width();
// Compute sum of terms
EvalType sum = EvalType(0);
#pragma omp parallel for reduction(+:sum) collapse(2)
for (int col = 0; col < local_width; ++col) {
for (int row = 0; row < local_height; ++row) {
const EvalType true_val = ground_truth_local(row, col);
const EvalType pred_val = predictions_local(row, col);
sum += (- true_val * std::log(EvalType(1) - pred_val)
- std::log(pred_val));
}
}
// Compute mean objective function value across mini-batch
return get_comm().allreduce(sum / width, predictions.DistComm());
}
void geom_negloglike::differentiate_compute(const AbsDistMat& predictions,
const AbsDistMat& ground_truth,
AbsDistMat& gradient) {
// Local matrices
const Mat& predictions_local = predictions.LockedMatrix();
const Mat& ground_truth_local = ground_truth.LockedMatrix();
Mat& gradient_local = gradient.Matrix();
// Matrix parameters
const El::Int local_height = gradient_local.Height();
const El::Int local_width = gradient_local.Width();
// Compute gradient
#pragma omp parallel for collapse(2)
for (El::Int col = 0; col < local_width; ++col) {
for (El::Int row = 0; row < local_height; ++row) {
const DataType true_val = ground_truth_local(row, col);
const DataType pred_val = predictions_local(row, col);
gradient_local(row, col) = (true_val / (DataType(1) - pred_val)
- DataType(1) / pred_val);
}
}
}
} // namespace lbann
| 37.827586 | 80 | 0.656943 | andy-yoo |
a9e9bcb0ab1eaac83b2854a63b809565ca734f93 | 2,118 | cpp | C++ | algorithms/contiguous-data/longest-common-substr/main.cpp | dubzzz/various-algorithms | 16af4c05acfcb23d199df0851402b0da3ebba91c | [
"MIT"
] | 1 | 2017-04-17T18:32:46.000Z | 2017-04-17T18:32:46.000Z | algorithms/contiguous-data/longest-common-substr/main.cpp | dubzzz/various-algorithms | 16af4c05acfcb23d199df0851402b0da3ebba91c | [
"MIT"
] | 10 | 2016-12-25T04:42:56.000Z | 2017-03-30T20:42:25.000Z | algorithms/contiguous-data/longest-common-substr/main.cpp | dubzzz/various-algorithms | 16af4c05acfcb23d199df0851402b0da3ebba91c | [
"MIT"
] | 1 | 2022-03-25T17:39:05.000Z | 2022-03-25T17:39:05.000Z | #include "gtest/gtest.h"
#include <rapidcheck/gtest.h>
#include <algorithm>
#include <string>
#include SPECIFIC_HEADER
// Running tests
TEST(TEST_NAME, SameStrings)
{
ASSERT_EQ(6, longest_common_substr("AZERTY", "AZERTY").first);
}
TEST(TEST_NAME, CommonPartAtTheBeginning)
{
ASSERT_EQ(6, longest_common_substr("AZERTY123", "AZERTY456789").first);
}
TEST(TEST_NAME, CommonPartAtTheEnd)
{
ASSERT_EQ(6, longest_common_substr("123AZERTY", "456789AZERTY").first);
}
TEST(TEST_NAME, NoCommonPart)
{
ASSERT_EQ(0, longest_common_substr("AZERTY", "UIO").first);
}
TEST(TEST_NAME, OnlyOneContiguousPartInCommon)
{
ASSERT_EQ(3, longest_common_substr("AZERTYUIOP", "WNBERTX").first);
}
TEST(TEST_NAME, MultipleCommonSubstrings)
{
ASSERT_EQ(3, longest_common_substr("AZERTY", "123RTY1AZ9ER5TYTREZA4").first);
}
RC_GTEST_PROP(TEST_NAME, FindLongest, ())
{
auto gen = rc::gen::container<std::string>(rc::gen::inRange('A', (char)('Z' +1)));
std::string s1 = *gen;
std::string s2 = *gen;
std::string s3 = *gen;
std::string s4 = *gen;
std::string common = *gen;
RC_ASSERT(longest_common_substr(s1+common+s2, s3+common+s4).first >= common.size());
}
RC_GTEST_PROP(TEST_NAME, LongestIsAtMostTheMinOfInputs, ())
{
auto gen = rc::gen::container<std::string>(rc::gen::inRange('A', (char)('Z' +1)));
std::string s1 = *gen;
std::string s2 = *gen;
RC_ASSERT(longest_common_substr(s1, s2).first <= std::min(s1.size(), s2.size()));
}
RC_GTEST_PROP(TEST_NAME, CommonPartStartsAtStartPoints, ())
{
auto gen = rc::gen::container<std::string>(rc::gen::inRange('A', (char)('Z' +1)));
std::string s1 = *gen;
std::string s2 = *gen;
auto answer = longest_common_substr(s1, s2);
RC_ASSERT(answer.first + answer.second.first <= s1.size());
RC_ASSERT(answer.first + answer.second.second <= s2.size());
std::string common1 = s1.substr(answer.second.first, answer.first);
std::string common2 = s2.substr(answer.second.second, answer.first);
RC_ASSERT(common1 == common2);
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
int ret { RUN_ALL_TESTS() };
return ret;
}
| 29.013699 | 86 | 0.701605 | dubzzz |
a9ed2d800155b314c569e7a0b50f0bb482c07f22 | 354 | cpp | C++ | C++Tut/Arrays_30.cpp | dedhun/Ded_CP | 593abfbf703199f748633600041c251c39d76cfe | [
"MIT"
] | 1 | 2020-06-25T00:32:20.000Z | 2020-06-25T00:32:20.000Z | C++Tut/Arrays_30.cpp | dedhun/Ded_CP | 593abfbf703199f748633600041c251c39d76cfe | [
"MIT"
] | null | null | null | C++Tut/Arrays_30.cpp | dedhun/Ded_CP | 593abfbf703199f748633600041c251c39d76cfe | [
"MIT"
] | null | null | null | //
// Created by Jihun on 6/24/2020.
//
#include <iostream>
using namespace std;
int main() {
// this array can store 5 integers
// An array initializer list --> {}
// Elements are inside the array.
int jihun[5] = {66, 75, 2, 43, 99};
// Computer programs always start from 0. (index 0)
cout << jihun[2] << endl;
} | 23.6 | 56 | 0.579096 | dedhun |
a9edebb05d85d0f3150b0ff01bd3e51aac17dbc7 | 5,515 | cpp | C++ | test/test_selection.cpp | pandaant/libmcts | 51cc8c690ddbdf8933c7928d64c70982bde674eb | [
"MIT"
] | 2 | 2019-09-07T09:37:53.000Z | 2019-12-29T19:12:50.000Z | test/test_selection.cpp | pandaant/libmcts | 51cc8c690ddbdf8933c7928d64c70982bde674eb | [
"MIT"
] | null | null | null | test/test_selection.cpp | pandaant/libmcts | 51cc8c690ddbdf8933c7928d64c70982bde674eb | [
"MIT"
] | 1 | 2020-06-23T15:23:27.000Z | 2020-06-23T15:23:27.000Z | #include <map>
#include <iostream>
#include <UnitTest++.h>
#include <max_value_selector.hpp>
#include <sampling_selector.hpp>
#include <sampling_to_function_selector.hpp>
#include <min_sample_selector.hpp>
#include <uct_selector.hpp>
#include <root_node.hpp>
#include "rock_paper_scissors.hpp"
#include "rps_node.hpp"
#include "rps_config.hpp"
SUITE(SelectionTests) {
using namespace mcts;
typedef typename INode<RockPaperScissors, RPSConfig>::node_t node_t;
typedef typename ISelectionStrategy<RockPaperScissors, RPSConfig>::sstrategy_t
sstrategy_t;
struct Setup {
Player p1, p2;
RPSConfig *conf;
RockPaperScissors context;
ActionType::Enum p1a, p2a;
sstrategy_t *select_strat;
sstrategy_t *move_select_strat;
IBackpropagationStrategy *bp_strat;
RootNode<RockPaperScissors, RPSConfig,
RPSNode<RockPaperScissors, RPSConfig>> *root;
Setup() {
context = RockPaperScissors(Player("mark"), Player("simon"),
ActionType::PAPER, ActionType::ROCK, 1);
bp_strat = new AvgBackpropagationStrategy();
select_strat = new MaxValueSelector<RockPaperScissors, RPSConfig>();
move_select_strat = new MaxValueSelector<RockPaperScissors, RPSConfig>();
conf = new RPSConfig(bp_strat, select_strat, move_select_strat, false);
root = new RootNode<RockPaperScissors, RPSConfig,
RPSNode<RockPaperScissors, RPSConfig>>(context, conf);
root->expand();
}
~Setup() {
delete conf;
delete root;
delete move_select_strat;
delete bp_strat;
delete select_strat;
}
};
TEST_FIXTURE(Setup, TestMaxValueSelector) {
MaxValueSelector<RockPaperScissors, RPSConfig> selector =
MaxValueSelector<RockPaperScissors, RPSConfig>();
CHECK_EQUAL(9, root->children().size());
// backpropagate some values
root->children()[0]->backpropagate(7);
root->children()[1]->backpropagate(3);
root->children()[2]->backpropagate(2);
CHECK_EQUAL(root->children()[0], selector.select(root));
root->children()[3]->backpropagate(12);
root->children()[4]->backpropagate(17);
root->children()[5]->backpropagate(18);
CHECK_EQUAL(root->children()[5], selector.select(root));
root->children()[4]->backpropagate(9);
root->children()[4]->backpropagate(30);
CHECK_EQUAL(root->children()[4], selector.select(root));
root->children()[7]->backpropagate(60);
root->children()[8]->backpropagate(60);
// first max element
CHECK_EQUAL(root->children()[7], selector.select(root));
}
TEST_FIXTURE(Setup, TestSamplingSelector) {
SamplingSelector<RockPaperScissors, RPSConfig> selector =
SamplingSelector<RockPaperScissors, RPSConfig>();
std::map<node_t *, int> counts;
for (int i = 0; i < 200; ++i) {
// std::cout << (*root->config()->nb_gen())() << std::endl;
++counts[selector.select(root)];
}
CHECK_EQUAL(9, counts.size());
std::for_each(counts.begin(), counts.end(),
[](std::pair<node_t *, int> d) { CHECK(d.second > 10); });
}
TEST_FIXTURE(Setup, TestSamplingToFunctionSelector) {
MaxValueSelector<RockPaperScissors, RPSConfig> *s =
new MaxValueSelector<RockPaperScissors, RPSConfig>();
SamplingToFunctionSelector<RockPaperScissors, RPSConfig> selector(200, s);
std::map<node_t *, int> counts;
node_t *n;
for (int i = 0; i < 200; ++i) {
n = selector.select(root);
++counts[n];
n->backpropagate(i);
}
CHECK_EQUAL(9, counts.size());
// maxvalueselector should be active now
for (int i = 0; i < 1000; ++i) {
n = selector.select(root);
++counts[n];
n->backpropagate(i);
}
CHECK_EQUAL(root->children()[0], selector.select(root));
CHECK(root->children()[0]->nb_samples() > 800);
delete s;
}
TEST_FIXTURE(Setup, TestMinSampleSelector) {
MinSampleSelector<RockPaperScissors, RPSConfig> selector;
std::map<node_t *, int> counts;
node_t *n;
for (int i = 0; i < 9; ++i) {
n = selector.select(root);
++counts[n];
n->backpropagate(i);
}
CHECK_EQUAL(9, counts.size());
std::for_each(counts.begin(), counts.end(),
[](std::pair<node_t *, int> d) { CHECK_EQUAL(1, d.second); });
}
TEST_FIXTURE(Setup, TestUCTSelector) {
// big factor
UCTSelector<RockPaperScissors, RPSConfig> selector(10000);
vector<node_t *> children = root->children();
for (int i = 0; i < 9; ++i) {
children[i]->backpropagate(i);
}
std::map<node_t *, int> counts;
node_t *n;
for (int i = 0; i < 1000; ++i) {
n = selector.select(root);
++counts[n];
n->backpropagate(0);
}
//*
// because of the big factor in UCT constructor, nodes will be selected
// broader.
std::for_each(counts.begin(), counts.end(),
[](std::pair<node_t *, int> d) { CHECK(d.second > 100); });
selector = UCTSelector<RockPaperScissors, RPSConfig>(0);
for (int i = 0; i < 1000; ++i) {
n = selector.select(root);
++counts[n];
n->backpropagate(0);
}
std::for_each(counts.begin(), counts.end(),
[](std::pair<node_t *, int> d) { CHECK(d.second > 100); });
//*
// because of the small factor in UCT constructor,
// after value rather than samples. only the node with highest value is
// choosen.
CHECK_EQUAL(children[8], selector.select(root));
}
}
| 29.972826 | 80 | 0.632457 | pandaant |
a9f0b02d8ad3dbe165349d340464e899be0d8982 | 6,658 | cpp | C++ | build/moc/moc_ScreenToolsController.cpp | UNIST-ESCL/UNIST_GCS | f61f0c12bbb028869e4494f507ea8ab52c8c79c2 | [
"Apache-2.0"
] | 1 | 2018-11-07T06:10:53.000Z | 2018-11-07T06:10:53.000Z | build/moc/moc_ScreenToolsController.cpp | UNIST-ESCL/UNIST_GCS | f61f0c12bbb028869e4494f507ea8ab52c8c79c2 | [
"Apache-2.0"
] | null | null | null | build/moc/moc_ScreenToolsController.cpp | UNIST-ESCL/UNIST_GCS | f61f0c12bbb028869e4494f507ea8ab52c8c79c2 | [
"Apache-2.0"
] | 1 | 2018-11-07T06:10:47.000Z | 2018-11-07T06:10:47.000Z | /****************************************************************************
** Meta object code from reading C++ file 'ScreenToolsController.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.3)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../src/QmlControls/ScreenToolsController.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'ScreenToolsController.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.9.3. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_ScreenToolsController_t {
QByteArrayData data[14];
char stringdata0[134];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_ScreenToolsController_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_ScreenToolsController_t qt_meta_stringdata_ScreenToolsController = {
{
QT_MOC_LITERAL(0, 0, 21), // "ScreenToolsController"
QT_MOC_LITERAL(1, 22, 6), // "mouseX"
QT_MOC_LITERAL(2, 29, 0), // ""
QT_MOC_LITERAL(3, 30, 6), // "mouseY"
QT_MOC_LITERAL(4, 37, 9), // "isAndroid"
QT_MOC_LITERAL(5, 47, 5), // "isiOS"
QT_MOC_LITERAL(6, 53, 8), // "isMobile"
QT_MOC_LITERAL(7, 62, 11), // "testHighDPI"
QT_MOC_LITERAL(8, 74, 7), // "isDebug"
QT_MOC_LITERAL(9, 82, 7), // "isMacOS"
QT_MOC_LITERAL(10, 90, 7), // "isLinux"
QT_MOC_LITERAL(11, 98, 9), // "isWindows"
QT_MOC_LITERAL(12, 108, 9), // "iOSDevice"
QT_MOC_LITERAL(13, 118, 15) // "fixedFontFamily"
},
"ScreenToolsController\0mouseX\0\0mouseY\0"
"isAndroid\0isiOS\0isMobile\0testHighDPI\0"
"isDebug\0isMacOS\0isLinux\0isWindows\0"
"iOSDevice\0fixedFontFamily"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_ScreenToolsController[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
10, 26, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// methods: name, argc, parameters, tag, flags
1, 0, 24, 2, 0x02 /* Public */,
3, 0, 25, 2, 0x02 /* Public */,
// methods: parameters
QMetaType::Int,
QMetaType::Int,
// properties: name, type, flags
4, QMetaType::Bool, 0x00095401,
5, QMetaType::Bool, 0x00095401,
6, QMetaType::Bool, 0x00095401,
7, QMetaType::Bool, 0x00095401,
8, QMetaType::Bool, 0x00095401,
9, QMetaType::Bool, 0x00095401,
10, QMetaType::Bool, 0x00095401,
11, QMetaType::Bool, 0x00095401,
12, QMetaType::QString, 0x00095401,
13, QMetaType::QString, 0x00095401,
0 // eod
};
void ScreenToolsController::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
ScreenToolsController *_t = static_cast<ScreenToolsController *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: { int _r = _t->mouseX();
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = std::move(_r); } break;
case 1: { int _r = _t->mouseY();
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = std::move(_r); } break;
default: ;
}
}
#ifndef QT_NO_PROPERTIES
else if (_c == QMetaObject::ReadProperty) {
ScreenToolsController *_t = static_cast<ScreenToolsController *>(_o);
Q_UNUSED(_t)
void *_v = _a[0];
switch (_id) {
case 0: *reinterpret_cast< bool*>(_v) = _t->isAndroid(); break;
case 1: *reinterpret_cast< bool*>(_v) = _t->isiOS(); break;
case 2: *reinterpret_cast< bool*>(_v) = _t->isMobile(); break;
case 3: *reinterpret_cast< bool*>(_v) = _t->testHighDPI(); break;
case 4: *reinterpret_cast< bool*>(_v) = _t->isDebug(); break;
case 5: *reinterpret_cast< bool*>(_v) = _t->isMacOS(); break;
case 6: *reinterpret_cast< bool*>(_v) = _t->isLinux(); break;
case 7: *reinterpret_cast< bool*>(_v) = _t->isWindows(); break;
case 8: *reinterpret_cast< QString*>(_v) = _t->iOSDevice(); break;
case 9: *reinterpret_cast< QString*>(_v) = _t->fixedFontFamily(); break;
default: break;
}
} else if (_c == QMetaObject::WriteProperty) {
} else if (_c == QMetaObject::ResetProperty) {
}
#endif // QT_NO_PROPERTIES
}
const QMetaObject ScreenToolsController::staticMetaObject = {
{ &QQuickItem::staticMetaObject, qt_meta_stringdata_ScreenToolsController.data,
qt_meta_data_ScreenToolsController, qt_static_metacall, nullptr, nullptr}
};
const QMetaObject *ScreenToolsController::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *ScreenToolsController::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_ScreenToolsController.stringdata0))
return static_cast<void*>(this);
return QQuickItem::qt_metacast(_clname);
}
int ScreenToolsController::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QQuickItem::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 2)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 2;
}
#ifndef QT_NO_PROPERTIES
else if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty
|| _c == QMetaObject::ResetProperty || _c == QMetaObject::RegisterPropertyMetaType) {
qt_static_metacall(this, _c, _id, _a);
_id -= 10;
} else if (_c == QMetaObject::QueryPropertyDesignable) {
_id -= 10;
} else if (_c == QMetaObject::QueryPropertyScriptable) {
_id -= 10;
} else if (_c == QMetaObject::QueryPropertyStored) {
_id -= 10;
} else if (_c == QMetaObject::QueryPropertyEditable) {
_id -= 10;
} else if (_c == QMetaObject::QueryPropertyUser) {
_id -= 10;
}
#endif // QT_NO_PROPERTIES
return _id;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
| 36.184783 | 101 | 0.629468 | UNIST-ESCL |
a9f18cf393c21c0e0d121378475200aed236dc6a | 902 | cpp | C++ | algorithms/cpp/dijkstra_quadratic.cpp | felipegnunes/programming-challenges | 452ed1f0f39da11d95b0a5327c76ae94dc74c64a | [
"MIT"
] | null | null | null | algorithms/cpp/dijkstra_quadratic.cpp | felipegnunes/programming-challenges | 452ed1f0f39da11d95b0a5327c76ae94dc74c64a | [
"MIT"
] | null | null | null | algorithms/cpp/dijkstra_quadratic.cpp | felipegnunes/programming-challenges | 452ed1f0f39da11d95b0a5327c76ae94dc74c64a | [
"MIT"
] | null | null | null | #include <iostream>
#include <limits.h>
using namespace std;
int find_nearest_vertex(int V, int dist[], bool in_tree[])
{
int min_index, min_dist = INT_MAX;
for (int u = 0; u < V; u++)
{
if (!in_tree[u] && dist[u] < min_dist)
{
min_index = u;
min_dist = dist[u];
}
}
return min_index;
}
void dijkstra(int V, int E, int source, int **adj, int dist[])
{
bool in_tree[V];
for (int i = 0; i < V; i++)
{
dist[i] = INT_MAX;
in_tree[i] = false;
}
dist[source] = 0;
for (int i = 0; i < V - 1; i++)
{
int u = find_nearest_vertex(V, dist, in_tree);
in_tree[u] = true;
for (int v = 0; v < V; v++)
{
if (adj[u][v] && !in_tree[v] && dist[u] != INT_MAX && dist[v] > dist[u] + adj[u][v])
dist[v] = dist[u] + adj[u][v];
}
}
} | 20.044444 | 96 | 0.462306 | felipegnunes |
a9fc400c15d9e596b9228ae842b86c7a46662cca | 25,301 | hpp | C++ | source/modes/GenerateContentFile.hpp | SilvioWeging/kASA | 65740ee0f885693cd86bc3a1ea74c67ca7174130 | [
"BSL-1.0"
] | 19 | 2019-07-25T13:31:58.000Z | 2021-09-23T11:19:22.000Z | source/modes/GenerateContentFile.hpp | SilvioWeging/kASA | 65740ee0f885693cd86bc3a1ea74c67ca7174130 | [
"BSL-1.0"
] | 7 | 2019-04-04T13:20:58.000Z | 2021-04-20T18:51:21.000Z | source/modes/GenerateContentFile.hpp | SilvioWeging/kASA | 65740ee0f885693cd86bc3a1ea74c67ca7174130 | [
"BSL-1.0"
] | 4 | 2019-08-20T00:52:25.000Z | 2021-04-20T18:43:38.000Z | /***************************************************************************
* Part of kASA: https://github.com/SilvioWeging/kASA
*
* Copyright (C) 2020 Silvio Weging <silvio.weging@gmail.com>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#pragma once
#include "../kASA.hpp"
namespace kASA {
class ContentFile : public kASA {
public:
ContentFile(const InputParameters& cParams) : kASA(cParams) {}
ContentFile(const kASA& obj) : kASA(obj) {}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Generate temporary content file(s) in case not enough memory is available to hold the unordered_maps
inline void generateTemporaryContentFile(const string& sTempCFilePath, const string& sTaxonomyPath, string sTaxonomicLevel, const bool& bTaxIdsAsStrings, const string& sAccToTaxFiles, pair<uint32_t, uint32_t> poolAndNames, unordered_map<string, bool>& vAccessions, unordered_map<string, uint32_t>& vEntriesWithoutAccNr, unordered_map<string, string>& vNamesFromFasta) {
if (_bVerbose) {
cout << "OUT: Generating temporary content file: " << sTempCFilePath << endl;
}
debugBarrier
ofstream contentFile = Utilities::createFileAndGetIt(sTempCFilePath);
size_t iIdentifiedCounter = 0;
unordered_map<string, unordered_set<string>> taxWithAccNrs;
unordered_map<string, string> taxToNames;
bool bNotAllFound = true;
if (_bVerbose) {
cout << "OUT: Assigning taxids... " << endl;
}
if (sTaxonomicLevel == "lowest") {
iIdentifiedCounter = 1;
for (auto& entry : vAccessions) {
auto elem = taxWithAccNrs.insert(make_pair(to_string(iIdentifiedCounter), unordered_set<string>()));
if (elem.second) {
elem.first->second.insert(entry.first);
entry.second = true;
taxToNames.insert(make_pair(to_string(iIdentifiedCounter), vNamesFromFasta.at(entry.first)));
++iIdentifiedCounter;
}
else {
throw runtime_error("AccTaxPair could not be added");
}
}
bNotAllFound = false;
debugBarrier
}
else {
auto files = Utilities::gatherFilesFromPath(sAccToTaxFiles).first;
////////////////////
for (const auto& file : files) {
string sDummy = "";
size_t iIdxForAccession = 1, iIdxForTaxID = 2; // true = 4 columns, false = 2 columns
bool isGzipped = file.second;
ifstream acc2Tax;
igzstream acc2TaxGZ;
if (isGzipped) {
acc2TaxGZ.open(file.first.c_str());
getline(acc2TaxGZ, sDummy);
const auto& columns = Utilities::split(sDummy, '\t');
if (columns.size() == 2) {
iIdxForAccession = 0;
iIdxForTaxID = 1;
}
acc2TaxGZ.seekg(0);
}
else {
acc2Tax.open(file.first);
getline(acc2Tax, sDummy);
const auto& columns = Utilities::split(sDummy, '\t');
if (columns.size() == 2) {
iIdxForAccession = 0;
iIdxForTaxID = 1;
}
acc2Tax.seekg(0);
}
debugBarrier
while (((isGzipped) ? getline(acc2TaxGZ, sDummy) : getline(acc2Tax, sDummy)) && bNotAllFound) {
const auto& columns = Utilities::split(sDummy, '\t');
auto res1 = vAccessions.find(columns[iIdxForAccession]);
if (res1 != vAccessions.end()) {
auto res2 = taxWithAccNrs.find(columns[iIdxForTaxID]);
if (res2 != taxWithAccNrs.end()) {
res2->second.insert(res1->first);
}
else {
auto res3 = taxWithAccNrs.insert(make_pair(columns[iIdxForTaxID], unordered_set<string>()));
if (res3.second) {
res3.first->second.insert(res1->first);
}
else {
throw runtime_error("AccTaxPair could not be added");
}
}
res1->second = true;
++iIdentifiedCounter;
if (iIdentifiedCounter == vAccessions.size()) {
bNotAllFound = false;
}
}
}
debugBarrier
}
}
vNamesFromFasta.clear();
debugBarrier
////////////////////
if (_bVerbose && bNotAllFound) {
cout << "OUT: The accession numbers without a taxid will be written to " + _sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_accessionsWithoutTaxid.txt" << endl;
ofstream noIDFile(_sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_accessionsWithoutTaxid.txt", ios::app);
for (const auto& entry : vAccessions) {
if (entry.second == false) {
vEntriesWithoutAccNr.insert(make_pair(entry.first, 0));
if (_bVerbose) {
noIDFile << entry.first << endl;
}
}
}
}
else {
for (const auto& entry : vAccessions) {
if (entry.second == false) {
vEntriesWithoutAccNr.insert(make_pair(entry.first, 0));
}
}
}
vAccessions.clear();
debugBarrier
////////////////////
if (_bVerbose) {
cout << "OUT: Providing dummy taxid(s) if needed..." << endl;
}
uint32_t pool = poolAndNames.first;
if (vEntriesWithoutAccNr.size() > pool) {
throw runtime_error("Too many dummys, I can't handle this!");
}
for (auto& entry : vEntriesWithoutAccNr) {
entry.second = pool;
--pool;
}
debugBarrier
////////////////////
if (_bVerbose) {
cout << "OUT: Fetching name(s)..." << endl;
}
//taxToNames
if (taxToNames.empty()) {
ifstream names(sTaxonomyPath + "names.dmp");
string sDummy = "";
while (getline(names, sDummy)) {
const auto& line = Utilities::split(sDummy, '|');
if (line[3] == "\tscientific name\t") {
taxToNames.insert(make_pair(Utilities::rstrip(line[0]), Utilities::lstrip(Utilities::rstrip(line[1]))));
}
}
}
debugBarrier
////////////////////
if (_bVerbose) {
cout << "OUT: Creating dictionary to map taxid(s) to your specified tax. level..." << endl;
}
unordered_map<string, pair<string, string>> taxToNodes;
{
ifstream nodes(sTaxonomyPath + "nodes.dmp");
string sDummy = "";
while (getline(nodes, sDummy)) {
const auto& line = Utilities::split(sDummy, '|');
taxToNodes.insert(make_pair(Utilities::rstrip(line[0]), make_pair(Utilities::lstrip(Utilities::rstrip(line[1])), Utilities::lstrip(Utilities::rstrip(line[2])))));
}
}
debugBarrier
////////////////////
if (_bVerbose) {
cout << "OUT: Linking to your specified tax. level..." << endl;
}
auto sortingFuncToContentFile = [&bTaxIdsAsStrings](const string& a, const string& b) { if (bTaxIdsAsStrings) { return a < b; } else { return stoull(a) < stoull(b); } };
map<string, pair<unordered_set<string>, unordered_set<string>>, decltype(sortingFuncToContentFile)> taxToTaxWAccs(sortingFuncToContentFile);
{
std::transform(sTaxonomicLevel.begin(), sTaxonomicLevel.end(), sTaxonomicLevel.begin(), ::tolower);
if (!(sTaxonomicLevel == "lowest" ||
sTaxonomicLevel == "subspecies" ||
sTaxonomicLevel == "species" ||
sTaxonomicLevel == "genus" ||
sTaxonomicLevel == "family" ||
sTaxonomicLevel == "order" ||
sTaxonomicLevel == "class" ||
sTaxonomicLevel == "phylum" ||
sTaxonomicLevel == "kingdom" ||
sTaxonomicLevel == "superkingdom" ||
sTaxonomicLevel == "domain"
)) {
cerr << "WARNING: No known tax. level specified. I'll just go with species..." << endl;
sTaxonomicLevel = "species";
}
string upperTax = "";
pair<string, string> entry;
for (const auto& elem : taxWithAccNrs) {
upperTax = elem.first;
if (sTaxonomicLevel != "lowest") {
auto res1 = taxToNodes.find(upperTax);
if (res1 != taxToNodes.end()) {
entry = res1->second;
}
else {
entry = make_pair("1", "");
}
while (entry.second != sTaxonomicLevel && entry.first != "1") {
upperTax = entry.first;
entry = taxToNodes.at(upperTax);
}
if (entry.first == "1") {
upperTax = elem.first;
}
}
auto res2 = taxToTaxWAccs.find(upperTax);
if (res2 != taxToTaxWAccs.end()) {
res2->second.first.insert(elem.first);
res2->second.second.insert(elem.second.begin(), elem.second.end());
}
else {
auto it = taxToTaxWAccs.insert(make_pair(upperTax, make_pair(unordered_set<string>(), unordered_set<string>())));
it.first->second.first.insert(elem.first);
it.first->second.second.insert(elem.second.begin(), elem.second.end());
}
}
taxWithAccNrs.clear();
}
debugBarrier
////////////////////
if (_bVerbose) {
cout << "OUT: Writing to temporary content file..." << endl;
}
uint32_t iUnnamedCounter = 0;
uint64_t iLineCounter = 1;
for (const auto& elem : taxToTaxWAccs) {
string taxa = "", accnrs = "";
for (const auto& tax : elem.second.first) {
taxa += tax + ";";
}
if (taxa != "") {
taxa.erase(taxa.end() - 1);
}
for (const auto& accs : elem.second.second) {
accnrs += accs + ";";
}
if (accnrs != "") {
accnrs.erase(accnrs.end() - 1);
}
const auto res = taxToNames.find(elem.first);
if (res != taxToNames.end()) {
contentFile << Utilities::removeCharFromString(res->second, ',') << "\t" << elem.first << "\t" << taxa << "\t" << accnrs << ((bTaxIdsAsStrings) ? ("\t" + to_string(iLineCounter++)) : "") << "\n";
}
else {
contentFile << "unnamed_" << iUnnamedCounter++ << "\t" << elem.first << "\t" << taxa << "\t" << accnrs << ((bTaxIdsAsStrings) ? ("\t" + to_string(iLineCounter++)) : "") << "\n";
}
}
iUnnamedCounter = poolAndNames.second;
for (const auto& elem : vEntriesWithoutAccNr) {
contentFile << "EWAN_" << iUnnamedCounter++ << "\t" << elem.second << "\t" << elem.second << "\t" << elem.first << ((bTaxIdsAsStrings) ? ("\t" + to_string(iLineCounter++)) : "") << "\n";
}
vEntriesWithoutAccNr.clear();
if (_bVerbose) {
cout << "OUT: Finished generating temporary content file, either resuming with gathering accessions or writing to final content file... " << endl;
}
debugBarrier
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// C++ version of the python script that creates the content file
inline void generateContentFile(const InputParameters& cParams, const string& sContentFile, pair<uint32_t, uint32_t> poolAndNames = make_pair(numeric_limits<uint32_t>::max() - 1, 0UL)) {
try {
if (cParams.sTaxLevel != "lowest") {
if (!ifstream(cParams.sTaxonomyPath + "names.dmp") || !ifstream(cParams.sTaxonomyPath + "nodes.dmp")) {
throw runtime_error("The taxonomy files couldn't be found");
}
}
debugBarrier
Utilities::checkIfFileCanBeCreated(sContentFile);
auto files = Utilities::gatherFilesFromPath(cParams.sInput).first;
if (_bVerbose) {
cout << "OUT: Going through fasta(s), gathering accession number(s)..." << endl;
}
////////////////////
unordered_map<string, bool> vAccessions;
unordered_map<string, uint32_t> vEntriesWithoutAccNr;
unordered_map<string, string> vNamesFromFasta;
size_t iNumOfLegitAccessions = 0, iNumOfDummys = 0;
uint32_t iTemporaryCounter = 0;
uint64_t iMemoryAllocated = sizeof(unordered_map<string, bool>)
+ sizeof(unordered_map<string, uint32_t>)
+ 2 * sizeof(unordered_map<string, string>)
+ sizeof(unordered_map<string, unordered_set<string>>); // all unordered_maps that are memory critical
debugBarrier
for (const auto& file : files) {
ifstream fastaFile;
igzstream fastaFileGZ;
if (file.second) {
fastaFileGZ.open(file.first.c_str());
}
else {
fastaFile.open(file.first);
}
debugBarrier
string sDummy = "";
while ((file.second) ? getline(fastaFileGZ, sDummy) : getline(fastaFile, sDummy)) {
if (sDummy != "") {
if (sDummy.front() == '>') {
sDummy.erase(sDummy.begin());
const auto& sNumbers = Utilities::split(Utilities::split(sDummy, ' ').at(0), '|');
string acc = "";
for (const auto& entry : sNumbers) {
if (entry.find('.') != string::npos) {
acc = entry;
break;
}
}
if (acc != "") {
vAccessions.insert(make_pair(acc, false));
iMemoryAllocated += sizeof(pair<string, bool>) + sizeof(char) * acc.length();
if (cParams.sTaxLevel == "lowest") {
vNamesFromFasta.insert(make_pair(acc, Utilities::replaceCharacter(sDummy, ',', ' ')));
iMemoryAllocated += sizeof(pair<string, string>) + sizeof(char) * 2 * acc.length();
}
}
else {
vEntriesWithoutAccNr.insert(make_pair(sDummy, 0));
iMemoryAllocated += sizeof(pair<string, uint32_t>) + sizeof(char) * sDummy.length();
}
iMemoryAllocated += sizeof(pair<string, unordered_set<string>>) + sizeof(char) * acc.length() + sizeof(char) * 9
+ sizeof(pair<string, string>) + sizeof(char) * 30; // numbers are rough approximations of maximum string lengths for iIdentifiedCounter and length of species name
}
if (iMemoryAllocated > static_cast<uint64_t>(cParams.iMemorySizeAvail)) {
iNumOfLegitAccessions += vAccessions.size();
iNumOfDummys += vEntriesWithoutAccNr.size();
debugBarrier
generateTemporaryContentFile(_sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_" + Utilities::itostr(iTemporaryCounter) + ".txt", cParams.sTaxonomyPath, cParams.sTaxLevel, cParams.bTaxIdsAsStrings, cParams.sAccToTaxFiles, poolAndNames, vAccessions, vEntriesWithoutAccNr, vNamesFromFasta);
++iTemporaryCounter;
iMemoryAllocated = 0;
debugBarrier
}
}
}
}
debugBarrier
iNumOfLegitAccessions += vAccessions.size();
iNumOfDummys += vEntriesWithoutAccNr.size();
if (iTemporaryCounter == 0) {
if (_bVerbose) {
cout << "OUT: " << iNumOfLegitAccessions << " legit accession number(s) found in " << files.size() << " file(s)." << endl
<< "OUT: " << iNumOfDummys << " entr(y/ies) will get a dummy ID." << endl
<< "OUT: Creating content file..." << endl;
}
debugBarrier
generateTemporaryContentFile(sContentFile, cParams.sTaxonomyPath, cParams.sTaxLevel, cParams.bTaxIdsAsStrings, cParams.sAccToTaxFiles, poolAndNames, vAccessions, vEntriesWithoutAccNr, vNamesFromFasta);
}
else {
if (vAccessions.size()) {
debugBarrier
generateTemporaryContentFile(_sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_" + Utilities::itostr(iTemporaryCounter) + ".txt", cParams.sTaxonomyPath, cParams.sTaxLevel, cParams.bTaxIdsAsStrings, cParams.sAccToTaxFiles, poolAndNames, vAccessions, vEntriesWithoutAccNr, vNamesFromFasta);
++iTemporaryCounter;
}
if (_bVerbose) {
cout << "OUT: " << iNumOfLegitAccessions << " legit accession number(s) found in " << files.size() << " file(s)." << endl
<< "OUT: " << iNumOfDummys << " entr(y/ies) got a dummy ID." << endl
<< "OUT: Merging temporary content files..." << endl;
}
debugBarrier
string sTempFinal1 = _sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_final1.txt";
string sTempFinal2 = _sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_final2.txt";
mergeContentFiles(_sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_0.txt", _sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_1.txt", false, sTempFinal1);
remove((_sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_0.txt").c_str());
remove((_sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_1.txt").c_str());
debugBarrier
for (uint32_t iTemporaryCFilesIdx = 2; iTemporaryCFilesIdx < iTemporaryCounter; ++iTemporaryCFilesIdx) {
string currentFile = _sTemporaryPath + "content_" + Utilities::itostr(_iNumOfCall) + "_" + Utilities::itostr(iTemporaryCFilesIdx) + ".txt";
mergeContentFiles(sTempFinal1, currentFile, false, sTempFinal2);
swap(sTempFinal1, sTempFinal2);
remove(currentFile.c_str());
}
debugBarrier
Utilities::moveFile(sTempFinal1, sContentFile);
remove(sTempFinal2.c_str());
}
debugBarrier
}
catch (...) {
cerr << "ERROR: in: " << __PRETTY_FUNCTION__ << endl; throw;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Merge two content files
inline pair<unordered_map<uint32_t, uint32_t>, unordered_map<uint32_t, uint32_t>> mergeContentFiles(const string& contentFile, const string& contentFile2, const bool& bMergeExistingIndices, const string& contentOut) {
try {
auto mergeEntries = [](const string& sTempLineSpecIDs, const string& sCurrLineSpecIDs, const string& sTempLineAccNrs, const string& sCurrLineAccNrs) {
unordered_set<string> sSpecIDs, sAccNrs;
// concatenate non-redundant species IDs
const auto& newSpecIDs = Utilities::split(sTempLineSpecIDs, ';'); // tempLineContent[2]
const auto& currentSpecIDs = Utilities::split(sCurrLineSpecIDs, ';'); // get<1>(entry->second)
sSpecIDs.insert(newSpecIDs.cbegin(), newSpecIDs.cend());
sSpecIDs.insert(currentSpecIDs.cbegin(), currentSpecIDs.cend());
string sNewSpecIDs = "";
for (const auto& elem : sSpecIDs) {
sNewSpecIDs += elem + ";";
}
sNewSpecIDs.pop_back();
// concatenate non-redundant accession numbers
const auto& newAccNrs = Utilities::split(sTempLineAccNrs, ';'); // tempLineContent[3]
const auto& currentAccNrs = Utilities::split(sCurrLineAccNrs, ';'); // get<2>(entry->second)
sAccNrs.insert(newAccNrs.cbegin(), newAccNrs.cend());
sAccNrs.insert(currentAccNrs.cbegin(), currentAccNrs.cend());
string sNewAccNrs = "";
for (const auto& elem : sAccNrs) {
sNewAccNrs += elem + ";";
}
sNewAccNrs.pop_back();
return make_pair(sNewSpecIDs, sNewAccNrs);
};
debugBarrier
pair<uint32_t, uint32_t> pool(numeric_limits<uint32_t>::max(), 0); // first component counts downwards from the highest possible number to distinguish it from valid taxIDs, the second component gives the entry a name ID
vector<string> vListOfDummys;
unordered_map<uint32_t, uint32_t> mapOfOldDummyToNewDummy1;
unordered_map<uint32_t, uint32_t> mapOfOldDummyToNewDummy2;
ifstream fContent, fContent2;
ofstream fContentOut;
bool bTaxIdsAsStrings = false;
//fContent.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fContent.open(contentFile);
if (!fContent) {
throw runtime_error("First content file couldn't be read!");
}
fContent2.open(contentFile2);
if (!fContent2) {
throw runtime_error("Second content file couldn't be read!");
}
fContentOut.open(contentOut);
if (!fContentOut) {
throw runtime_error("Resulting content file couldn't be opened for writing!");
}
uint64_t iLargestLineIndex = 1;
// The following algorithm assumes that the content files are sorted regarding the taxID.
string currLine1 = "", currLine2 = "";
getline(fContent, currLine1);
getline(fContent2, currLine2);
if (currLine1 == "" || currLine2 == "") {
cerr << "ERROR: One of the two content files has a leading empty line. This should not happen. Please look into both files and confirm that they are valid." << endl;
throw runtime_error("Invalid content files!");
}
if ((Utilities::split(currLine1, '\t')).size() >= 5 && !bTaxIdsAsStrings) {
bTaxIdsAsStrings = true;
}
auto compareFunc = [&bTaxIdsAsStrings](const string& a, const string& b) { if (bTaxIdsAsStrings) { return a < b; } else { return stoull(a) < stoull(b); } };
debugBarrier
while (fContent && fContent2) {
const auto& currLine1Split = Utilities::split(currLine1, '\t');
const auto& currLine2Split = Utilities::split(currLine2, '\t');
if (currLine1Split[0].find("EWAN") != string::npos) {
if (bMergeExistingIndices) {
const auto& ewanTaxID = stoul(currLine1Split[1]);
mapOfOldDummyToNewDummy1.insert(make_pair(ewanTaxID,pool.first)); // get current dummy taxID and map to new one
pool.first--;
}
vListOfDummys.push_back(currLine1Split[3]);
getline(fContent, currLine1);
continue;
}
if (currLine2Split[0].find("EWAN") != string::npos) {
if (bMergeExistingIndices) {
const auto& ewanTaxID = stoul(currLine2Split[1]);
mapOfOldDummyToNewDummy2.insert(make_pair(ewanTaxID, pool.first)); // get current dummy taxID and map to new one
pool.first--;
}
vListOfDummys.push_back(currLine2Split[3]);
getline(fContent2, currLine2);
continue;
}
// <
if (compareFunc(currLine1Split[1], currLine2Split[1])) {
fContentOut << currLine1Split[0] << "\t" << currLine1Split[1] << "\t" << currLine1Split[2] << "\t" << currLine1Split[3] << ((bTaxIdsAsStrings) ? ("\t" + Utilities::itostr(iLargestLineIndex++)) : "") << "\n";
getline(fContent, currLine1);
}
else {
// ==
if (!compareFunc(currLine2Split[1], currLine1Split[1])) {
const auto& res = mergeEntries(currLine1Split[2], currLine2Split[2], currLine1Split[3], currLine2Split[3]);
fContentOut << currLine2Split[0] << "\t" << currLine2Split[1] << "\t" << res.first << "\t" << res.second << ((bTaxIdsAsStrings) ? ("\t" + Utilities::itostr(iLargestLineIndex++)) : "") << "\n";
getline(fContent, currLine1);
getline(fContent2, currLine2);
}
// >
else {
fContentOut << currLine2Split[0] << "\t" << currLine2Split[1] << "\t" << currLine2Split[2] << "\t" << currLine2Split[3] << ((bTaxIdsAsStrings) ? ("\t" + Utilities::itostr(iLargestLineIndex++)) : "") << "\n";
getline(fContent2, currLine2);
}
}
}
debugBarrier
while (fContent) {
const auto& currLine1Split = Utilities::split(currLine1, '\t');
if (currLine1Split[0].find("EWAN") != string::npos) {
if (bMergeExistingIndices) {
const auto& ewanTaxID = stoul(currLine1Split[1]);
mapOfOldDummyToNewDummy1.insert(make_pair(ewanTaxID, pool.first)); // get current dummy taxID and map to new one
pool.first--;
}
vListOfDummys.push_back(currLine1Split[3]);
}
else {
fContentOut << currLine1Split[0] << "\t" << currLine1Split[1] << "\t" << currLine1Split[2] << "\t" << currLine1Split[3] << ((bTaxIdsAsStrings) ? ("\t" + Utilities::itostr(iLargestLineIndex++)) : "") << "\n";
}
getline(fContent, currLine1);
}
debugBarrier
while (fContent2) {
const auto& currLine2Split = Utilities::split(currLine2, '\t');
if (currLine2Split[0].find("EWAN") != string::npos) {
if (bMergeExistingIndices) {
const auto& ewanTaxID = stoul(currLine2Split[1]);
mapOfOldDummyToNewDummy2.insert(make_pair(ewanTaxID, pool.first)); // get current dummy taxID and map to new one
pool.first--;
}
vListOfDummys.push_back(currLine2Split[3]);
}
else {
fContentOut << currLine2Split[0] << "\t" << currLine2Split[1] << "\t" << currLine2Split[2] << "\t" << currLine2Split[3] << ((bTaxIdsAsStrings) ? ("\t" + Utilities::itostr(iLargestLineIndex++)) : "") << "\n";
}
getline(fContent2, currLine2);
}
debugBarrier
uint32_t iDummyID = numeric_limits<uint32_t>::max();
for (const auto& entry : vListOfDummys) {
const auto& IDStr = to_string(iDummyID--);
const auto& nameStr = "EWAN_" + to_string(pool.second++);
fContentOut << nameStr << "\t" << IDStr << "\t" << IDStr << "\t" << entry << ((bTaxIdsAsStrings) ? ("\t" + Utilities::itostr(iLargestLineIndex++)) : "") << "\n";
}
return make_pair(mapOfOldDummyToNewDummy1, mapOfOldDummyToNewDummy2);
}
catch (...) {
cerr << "ERROR: in: " << __PRETTY_FUNCTION__ << endl; throw;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add new stuff to an existing content file
inline pair<unordered_map<uint32_t, uint32_t>, unordered_map<uint32_t, uint32_t>> addToContentFile(const InputParameters& cParams, const string& sContentFileOut) {
// Warning: taxonomic levels must not change in an update
const string& temporaryContentFile = _sTemporaryPath + Utilities::itostr(_iNumOfCall) + "_tempContent.txt";
const string& temporaryContentOutFile = _sTemporaryPath + Utilities::itostr(_iNumOfCall) + "_tempContentOut.txt";
if (_bVerbose) {
cout << "OUT: Generating temporary content file from new data..." << endl;
}
debugBarrier
generateContentFile(cParams, temporaryContentFile);
if (_bVerbose) {
cout << "OUT: Merging content file from new data with the existing one..." << endl;
}
debugBarrier
const auto& result = mergeContentFiles(cParams.contentFileIn, temporaryContentFile, true, temporaryContentOutFile);
remove(temporaryContentFile.c_str());
remove(sContentFileOut.c_str());
Utilities::moveFile(temporaryContentOutFile, sContentFileOut);
return result;
}
};
} | 40.096672 | 371 | 0.624679 | SilvioWeging |
a9fecbd3d3d3ef84a22a5a4b22e1ebf870b587d3 | 83,384 | inl | C++ | lumino/LuminoEngine/src/Rendering/Resource/ShadowCaster.lcfx.inl | GameDevery/Lumino | abce2ddca4b7678b04dbfd0ae5348e196c3c9379 | [
"MIT"
] | 113 | 2020-03-05T01:27:59.000Z | 2022-03-28T13:20:51.000Z | lumino/LuminoEngine/src/Rendering/Resource/ShadowCaster.lcfx.inl | GameDevery/Lumino | abce2ddca4b7678b04dbfd0ae5348e196c3c9379 | [
"MIT"
] | 13 | 2020-03-23T20:36:44.000Z | 2022-02-28T11:07:32.000Z | lumino/LuminoEngine/src/Rendering/Resource/ShadowCaster.lcfx.inl | GameDevery/Lumino | abce2ddca4b7678b04dbfd0ae5348e196c3c9379 | [
"MIT"
] | 12 | 2020-12-21T12:03:59.000Z | 2021-12-15T02:07:49.000Z | 0x6c, 0x75, 0x66, 0x78, 0x05, 0x00, 0x00, 0x00, 0x6c, 0x75, 0x66, 0x78, 0x2e, 0x63, 0x2e, 0x2e,
0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x56, 0x53, 0x5f, 0x53, 0x68, 0x61, 0x64, 0x6f,
0x77, 0x43, 0x61, 0x73, 0x74, 0x65, 0x72, 0x02, 0x03, 0x00, 0x00, 0x00, 0x73, 0x70, 0x76, 0x6e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x16, 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00,
0x00, 0x01, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47,
0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0a, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x53, 0x5f, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77,
0x43, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x48,
0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05,
0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x53, 0x5f, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77,
0x43, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x05, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x56,
0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x06, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x50, 0x6f, 0x73, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x56,
0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x0b,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x76, 0x50, 0x6f, 0x73, 0x00, 0x00, 0x00, 0x06,
0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x6f, 0x73, 0x00, 0x05,
0x00, 0x0c, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x40, 0x56, 0x53, 0x5f, 0x53, 0x68, 0x61, 0x64, 0x6f,
0x77, 0x43, 0x61, 0x73, 0x74, 0x65, 0x72, 0x28, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2d, 0x56,
0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x2d, 0x76, 0x66, 0x33, 0x31, 0x3b, 0x00, 0x00, 0x00, 0x05,
0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x05,
0x00, 0x08, 0x00, 0x12, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x49, 0x6e, 0x66, 0x6f,
0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05,
0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x00, 0x05, 0x00, 0x08, 0x00, 0x1a,
0x00, 0x00, 0x00, 0x4c, 0x4e, 0x52, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65,
0x6e, 0x74, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x1a,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x00,
0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x49, 0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x00, 0x1a,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x56,
0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x06,
0x00, 0x07, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f,
0x72, 0x6c, 0x64, 0x56, 0x69, 0x65, 0x77, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x1a,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x56,
0x69, 0x65, 0x77, 0x49, 0x54, 0x00, 0x00, 0x06, 0x00, 0x0b, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x42, 0x6f, 0x6e, 0x65, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72,
0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x72, 0x6f, 0x63, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x00,
0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x4d, 0x6f, 0x72, 0x70, 0x68, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00, 0x06,
0x00, 0x06, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x6f, 0x62,
0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x00, 0x05, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62,
0x61, 0x6c, 0x00, 0x06, 0x00, 0x0a, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x5f, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x2c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x32, 0x00, 0x00, 0x00, 0x6f,
0x75, 0x74, 0x70, 0x75, 0x74, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x69,
0x6e, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x69,
0x6e, 0x70, 0x75, 0x74, 0x2e, 0x50, 0x6f, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x40,
0x00, 0x00, 0x00, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x00, 0x05,
0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05,
0x00, 0x08, 0x00, 0x45, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69,
0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x73, 0x76, 0x50, 0x6f, 0x73, 0x00, 0x05,
0x00, 0x08, 0x00, 0x48, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69,
0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x50, 0x6f, 0x73, 0x00, 0x00, 0x00, 0x05,
0x00, 0x07, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x52, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x56,
0x69, 0x65, 0x77, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x56, 0x69, 0x65, 0x77, 0x00, 0x06,
0x00, 0x07, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x50, 0x72,
0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x49, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x5f, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74,
0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x06, 0x00, 0x07, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e,
0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x43, 0x61, 0x6d, 0x65, 0x72, 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
0x5f, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x43, 0x61, 0x6d, 0x65, 0x72, 0x61, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x5f, 0x00, 0x06, 0x00, 0x07, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x41, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x06,
0x00, 0x08, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x41, 0x6d,
0x62, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x6b, 0x79, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x06,
0x00, 0x09, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x41, 0x6d,
0x62, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x5f,
0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6f, 0x6c, 0x6f,
0x72, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x5f,
0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x50, 0x6f, 0x73, 0x00,
0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x5f,
0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x44, 0x69, 0x72, 0x00,
0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
0x00, 0x08, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x50, 0x42, 0x52, 0x4d, 0x61, 0x74, 0x65,
0x72, 0x69, 0x61, 0x6c, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x00, 0x00, 0x06,
0x00, 0x08, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61,
0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x08, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61,
0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x45, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x76, 0x65, 0x00, 0x06,
0x00, 0x09, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61,
0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x52, 0x6f, 0x75, 0x67, 0x68, 0x6e, 0x65, 0x73, 0x73, 0x00,
0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x4d, 0x65, 0x74, 0x61, 0x6c, 0x6c,
0x69, 0x63, 0x00, 0x05, 0x00, 0x03, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
0x00, 0x07, 0x00, 0x51, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x45, 0x66, 0x66, 0x65, 0x63, 0x74, 0x43,
0x6f, 0x6c, 0x6f, 0x72, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x00, 0x06, 0x00, 0x07, 0x00, 0x51,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x53,
0x63, 0x61, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x51, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x42, 0x6c, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x51, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x54, 0x6f, 0x6e, 0x65, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05,
0x00, 0x03, 0x00, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x57,
0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x65,
0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, 0x58, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x4d, 0x65, 0x74, 0x61, 0x6c, 0x6c, 0x69, 0x63, 0x52, 0x6f, 0x75, 0x67, 0x68, 0x6e,
0x65, 0x73, 0x73, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x05, 0x00, 0x07, 0x00, 0x59,
0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4f, 0x63, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x54,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x4c,
0x4e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x53, 0x68, 0x61, 0x64, 0x69, 0x6e,
0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x07, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x46, 0x6f,
0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x00, 0x5a,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x46, 0x6f, 0x67, 0x43, 0x6f, 0x6c,
0x6f, 0x72, 0x41, 0x6e, 0x64, 0x44, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x00, 0x00, 0x00, 0x06,
0x00, 0x09, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61,
0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x6e, 0x65, 0x61, 0x72, 0x43, 0x6c, 0x69, 0x70, 0x00, 0x06, 0x00, 0x06, 0x00, 0x5a,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x66, 0x61, 0x72, 0x43, 0x6c, 0x69,
0x70, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
0x00, 0x07, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65,
0x72, 0x73, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, 0x5e,
0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4c, 0x69, 0x67, 0x68,
0x74, 0x49, 0x6e, 0x66, 0x6f, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x00, 0x05,
0x00, 0x09, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x4c,
0x69, 0x67, 0x68, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00,
0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x60, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x53, 0x68, 0x61,
0x64, 0x6f, 0x77, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x00, 0x00, 0x06,
0x00, 0x0b, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x6d, 0x61,
0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70,
0x52, 0x65, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x08, 0x00, 0x60,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77,
0x44, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x62,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x63, 0x00, 0x00, 0x00, 0x6c,
0x6e, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x53, 0x68, 0x61, 0x64, 0x6f,
0x77, 0x4d, 0x61, 0x70, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48,
0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x40,
0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48,
0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x40,
0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x1a,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x22,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x21,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x2a,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x47,
0x00, 0x03, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2c,
0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2c,
0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3d,
0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x45,
0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x48,
0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10,
0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x50,
0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x0b,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x70, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x47,
0x00, 0x03, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4d,
0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4d,
0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x4e,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x50, 0x00, 0x00, 0x00, 0x22,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x50, 0x00, 0x00, 0x00, 0x21,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x51, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x51,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x51, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20,
0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x51, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x53, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x53, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x58, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x59, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x59, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x59, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x5a,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x30,
0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47,
0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48,
0x00, 0x05, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x60, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x62, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x62, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x06,
0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20,
0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20,
0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x17,
0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e,
0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x21,
0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x17,
0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20,
0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b,
0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x2b,
0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x42, 0x2c,
0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x14,
0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0a,
0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x1e, 0x00, 0x0a, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0a,
0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1b,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1b,
0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x19,
0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1e,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x21,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06,
0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x1e, 0x00, 0x03, 0x00, 0x2a,
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2c,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x31, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x33,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x3d,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x00, 0x45,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x00, 0x48,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x0f, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x18,
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0a,
0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a,
0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a,
0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4b,
0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x1e, 0x00, 0x06, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a,
0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4f,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4f,
0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x05, 0x00, 0x51,
0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20,
0x00, 0x04, 0x00, 0x52, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x04, 0x00, 0x52, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x19,
0x00, 0x09, 0x00, 0x54, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x55, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x20,
0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e,
0x00, 0x07, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x5b,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5b,
0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56,
0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56,
0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56,
0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0x60,
0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x61,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x61,
0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56,
0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8,
0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x31, 0x00, 0x00, 0x00, 0x40,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x41,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x12, 0x00, 0x00, 0x00, 0x15,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3d,
0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x21, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3e,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x41, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x39,
0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x41,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x40, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x41,
0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x1d,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x46,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x45, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x41,
0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x33,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x49,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0xfd,
0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x09,
0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b,
0x00, 0x04, 0x00, 0x31, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x41,
0x00, 0x05, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1d,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1f,
0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x21, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x0d,
0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x23,
0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x25,
0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06,
0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51,
0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x25,
0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x91,
0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x41,
0x00, 0x05, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x1d,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x2d,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x17,
0x00, 0x00, 0x00, 0x91, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x2e,
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x30,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x17,
0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x32,
0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x35, 0x00, 0x00, 0x00, 0x34,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x17,
0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x32,
0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x37, 0x00, 0x00, 0x00, 0x36,
0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x32,
0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x04,
0x00, 0x00, 0x00, 0x68, 0x6c, 0x73, 0x6c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94,
0x06, 0x00, 0x00, 0x44, 0x58, 0x42, 0x43, 0x3b, 0xe1, 0xd0, 0x85, 0xbb, 0x5e, 0x8d, 0x88, 0x44,
0x3e, 0x80, 0x4c, 0x64, 0x56, 0xd2, 0xc4, 0x01, 0x00, 0x00, 0x00, 0x94, 0x06, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xb4, 0x03, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x40,
0x04, 0x00, 0x00, 0xf8, 0x05, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x78, 0x03, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x05, 0xfe, 0xff, 0x08, 0x11, 0x00, 0x00, 0x50, 0x03, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c,
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24,
0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62,
0x61, 0x6c, 0x73, 0x00, 0x4c, 0x4e, 0x52, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d,
0x65, 0x6e, 0x74, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x00, 0xab, 0x7c, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3c, 0x01, 0x00, 0x00, 0x70,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x30, 0x00, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x34, 0x78, 0x34, 0x00, 0xab, 0xab, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x01, 0x00, 0x00, 0x7c, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x85, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x02, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0xa6, 0x02, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xb3, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0xc2, 0x02, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xe8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x50,
0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x1c, 0x03, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f,
0x72, 0x6c, 0x64, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x49, 0x00, 0x6c, 0x6e,
0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x56, 0x69, 0x65,
0x77, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x56, 0x69, 0x65, 0x77, 0x49, 0x54,
0x00, 0x6c, 0x6e, 0x5f, 0x42, 0x6f, 0x6e, 0x65, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x52,
0x65, 0x63, 0x69, 0x70, 0x72, 0x6f, 0x63, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x34, 0x00, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdf, 0x02, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x6f,
0x72, 0x70, 0x68, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00, 0x6c, 0x6e, 0x5f, 0x6f, 0x62,
0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x00, 0x69, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x03, 0x00, 0x00, 0x4d,
0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53,
0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65,
0x72, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x50,
0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x50,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f,
0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00,
0xab, 0xab, 0xab, 0x53, 0x48, 0x45, 0x58, 0xb0, 0x01, 0x00, 0x00, 0x50, 0x00, 0x01, 0x00, 0x6c,
0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x01,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68,
0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32,
0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46,
0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x01,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x01,
0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x01,
0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32,
0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46,
0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36,
0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46,
0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94,
0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x50, 0x53, 0x5f, 0x53, 0x68,
0x61, 0x64, 0x6f, 0x77, 0x43, 0x61, 0x73, 0x74, 0x65, 0x72, 0x02, 0x03, 0x00, 0x00, 0x00, 0x73,
0x70, 0x76, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x14, 0x00, 0x00, 0x03, 0x02,
0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00,
0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00,
0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00,
0x0a, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0x53, 0x5f, 0x53, 0x68, 0x61,
0x64, 0x6f, 0x77, 0x43, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x27, 0x00, 0x00, 0x00, 0x2b, 0x00,
0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00,
0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0x53, 0x5f, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43,
0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x05, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x53,
0x49, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x06, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x73, 0x76, 0x50, 0x6f, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, 0x08, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x6f, 0x73, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x0c, 0x00,
0x00, 0x00, 0x40, 0x50, 0x53, 0x5f, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x61, 0x73, 0x74,
0x65, 0x72, 0x28, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2d, 0x50, 0x53, 0x49, 0x6e, 0x70, 0x75,
0x74, 0x2d, 0x76, 0x66, 0x34, 0x2d, 0x76, 0x66, 0x34, 0x31, 0x3b, 0x00, 0x00, 0x00, 0x05, 0x00,
0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00,
0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x54,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00,
0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00,
0x05, 0x00, 0x27, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x73, 0x76, 0x50, 0x6f,
0x73, 0x00, 0x05, 0x00, 0x05, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e,
0x50, 0x6f, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x40, 0x65,
0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x00,
0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00,
0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x34, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x52, 0x65, 0x6e, 0x64,
0x65, 0x72, 0x56, 0x69, 0x65, 0x77, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x00, 0x00, 0x06, 0x00,
0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x56, 0x69, 0x65,
0x77, 0x00, 0x06, 0x00, 0x07, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x06, 0x00,
0x07, 0x00, 0x34, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x50, 0x72, 0x6f,
0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x34, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x5f, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69,
0x67, 0x68, 0x74, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x06, 0x00, 0x07, 0x00, 0x34, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x75, 0x74,
0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x34, 0x00, 0x00, 0x00, 0x05, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x43, 0x61, 0x6d, 0x65, 0x72, 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74,
0x69, 0x6f, 0x6e, 0x5f, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x34, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x43, 0x61, 0x6d, 0x65, 0x72, 0x61, 0x44, 0x69, 0x72, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x00, 0x06, 0x00, 0x07, 0x00, 0x34, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x41, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f,
0x72, 0x00, 0x06, 0x00, 0x08, 0x00, 0x34, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x41, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x6b, 0x79, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x00, 0x00, 0x06, 0x00, 0x09, 0x00, 0x34, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x41, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x6f,
0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0a, 0x00,
0x00, 0x00, 0x5f, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43,
0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0b, 0x00,
0x00, 0x00, 0x5f, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x50,
0x6f, 0x73, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0c, 0x00,
0x00, 0x00, 0x5f, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x44,
0x69, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x37, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x52, 0x65, 0x6e, 0x64,
0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x00,
0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x37, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x49, 0x00,
0x00, 0x00, 0x06, 0x00, 0x09, 0x00, 0x37, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x37, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x56, 0x69, 0x65, 0x77, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x37, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x56, 0x69, 0x65, 0x77, 0x49, 0x54, 0x00, 0x00, 0x06, 0x00,
0x0b, 0x00, 0x37, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x42, 0x6f, 0x6e,
0x65, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x72, 0x6f, 0x63,
0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x37, 0x00,
0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x6f, 0x72, 0x70, 0x68, 0x57, 0x65,
0x69, 0x67, 0x68, 0x74, 0x73, 0x00, 0x06, 0x00, 0x06, 0x00, 0x37, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x00, 0x05, 0x00,
0x03, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x3a, 0x00,
0x00, 0x00, 0x4c, 0x4e, 0x50, 0x42, 0x52, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x50,
0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x3a, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61,
0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x3a, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61,
0x6c, 0x45, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x76, 0x65, 0x00, 0x06, 0x00, 0x09, 0x00, 0x3a, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61,
0x6c, 0x52, 0x6f, 0x75, 0x67, 0x68, 0x6e, 0x65, 0x73, 0x73, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
0x08, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x74,
0x65, 0x72, 0x69, 0x61, 0x6c, 0x4d, 0x65, 0x74, 0x61, 0x6c, 0x6c, 0x69, 0x63, 0x00, 0x05, 0x00,
0x03, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x3d, 0x00,
0x00, 0x00, 0x4c, 0x4e, 0x45, 0x66, 0x66, 0x65, 0x63, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x42,
0x75, 0x66, 0x66, 0x65, 0x72, 0x00, 0x06, 0x00, 0x07, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x00,
0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x42, 0x6c, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x06, 0x00,
0x07, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x54, 0x6f, 0x6e,
0x65, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x3f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x43, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x00, 0x00, 0x05, 0x00, 0x09, 0x00, 0x44, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x65, 0x74,
0x61, 0x6c, 0x6c, 0x69, 0x63, 0x52, 0x6f, 0x75, 0x67, 0x68, 0x6e, 0x65, 0x73, 0x73, 0x54, 0x65,
0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x05, 0x00, 0x07, 0x00, 0x45, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x4f, 0x63, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72,
0x65, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x47, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x43, 0x6c, 0x75, 0x73,
0x74, 0x65, 0x72, 0x65, 0x64, 0x53, 0x68, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x72, 0x61,
0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x47, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x46, 0x6f, 0x67, 0x50, 0x61, 0x72, 0x61,
0x6d, 0x73, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x00, 0x47, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x46, 0x6f, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x41, 0x6e, 0x64,
0x44, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x00, 0x00, 0x00, 0x06, 0x00, 0x09, 0x00, 0x47, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x4d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67,
0x68, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x06, 0x00,
0x06, 0x00, 0x47, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x6e, 0x65, 0x61,
0x72, 0x43, 0x6c, 0x69, 0x70, 0x00, 0x06, 0x00, 0x06, 0x00, 0x47, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x66, 0x61, 0x72, 0x43, 0x6c, 0x69, 0x70, 0x00, 0x00, 0x05, 0x00,
0x03, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x4a, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x73, 0x54, 0x65, 0x78,
0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x49, 0x6e, 0x66, 0x6f,
0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x09, 0x00, 0x4c, 0x00,
0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x49,
0x6e, 0x66, 0x6f, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00,
0x04, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00,
0x0a, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x56, 0x69, 0x65,
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4c, 0x69, 0x67, 0x68,
0x74, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x50, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x53, 0x68, 0x61, 0x64,
0x6f, 0x77, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x00, 0x00, 0x06, 0x00,
0x0b, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x6d, 0x61, 0x69,
0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x52,
0x65, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x08, 0x00, 0x50, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x44,
0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x52, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x53, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77,
0x4d, 0x61, 0x70, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x0b, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x1e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x1e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00,
0x04, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x40, 0x00,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x34, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00,
0x04, 0x00, 0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0xc0, 0x00,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x01,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x23, 0x00,
0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x08, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00,
0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x60, 0x01,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x23, 0x00,
0x00, 0x00, 0x70, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0c, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x34, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x36, 0x00, 0x00, 0x00, 0x22, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x36, 0x00, 0x00, 0x00, 0x21, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00,
0x04, 0x00, 0x37, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x40, 0x00,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x37, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00,
0x04, 0x00, 0x37, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0xc0, 0x00,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x37, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x40, 0x01,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x23, 0x00,
0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x37, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x37, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x39, 0x00, 0x00, 0x00, 0x22, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x39, 0x00, 0x00, 0x00, 0x21, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x3a, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x00,
0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x3d, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x47, 0x00,
0x03, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3f, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3f, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x43, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x43, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x43, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x44, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x44, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x44, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x45, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x45, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x45, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x47, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x47, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x47, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00,
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x47, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x47, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x47, 0x00,
0x03, 0x00, 0x47, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x49, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x49, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4b, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4b, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4b, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4c, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4c, 0x00,
0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4c, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x4d, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x4d, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00,
0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00,
0x04, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00,
0x05, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x50, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x52, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x52, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x53, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x53, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x53, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00,
0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00,
0x00, 0x00, 0x21, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x09, 0x00,
0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00,
0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x42, 0x2c, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x11, 0x00,
0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x20, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x15, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x1b, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x25, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x27, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x2b, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x2f, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x33, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x0f, 0x00, 0x34, 0x00, 0x00, 0x00, 0x33, 0x00,
0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00,
0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x0a, 0x00, 0x37, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00,
0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x38, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x38, 0x00,
0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x06, 0x00, 0x3a, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00,
0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x05, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3f, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x40, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x41, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x43, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x44, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x45, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x07, 0x00, 0x47, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00,
0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x20, 0x00,
0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x3b, 0x00,
0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00,
0x04, 0x00, 0x50, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00,
0x04, 0x00, 0x51, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x3b, 0x00,
0x04, 0x00, 0x51, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3b, 0x00,
0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00,
0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x09, 0x00,
0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x09, 0x00,
0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x10, 0x00,
0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2a, 0x00,
0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x2a, 0x00,
0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2c, 0x00,
0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2d, 0x00,
0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x2d, 0x00,
0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x31, 0x00,
0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x30, 0x00, 0x00, 0x00, 0x31, 0x00,
0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x0c, 0x00,
0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x32, 0x00,
0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, 0x07, 0x00,
0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x37, 0x00,
0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0d, 0x00,
0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x18, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x0b, 0x00,
0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00,
0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x18, 0x00,
0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x1b, 0x00,
0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1a, 0x00,
0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x21, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00,
0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x21, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x04, 0x00,
0x00, 0x00, 0x68, 0x6c, 0x73, 0x6c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x02,
0x00, 0x00, 0x44, 0x58, 0x42, 0x43, 0xb1, 0xa2, 0x2e, 0x81, 0xcf, 0x49, 0x27, 0xcb, 0x8e, 0x42,
0x7d, 0x55, 0x3b, 0xba, 0x88, 0x9c, 0x01, 0x00, 0x00, 0x00, 0x34, 0x02, 0x00, 0x00, 0x05, 0x00,
0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x2c, 0x01,
0x00, 0x00, 0x98, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x05,
0xff, 0xff, 0x08, 0x11, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, 0x00,
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00,
0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73,
0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61,
0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e,
0x31, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00,
0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0c,
0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45,
0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48,
0x45, 0x58, 0x64, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x6a, 0x08,
0x00, 0x01, 0x62, 0x10, 0x00, 0x03, 0xc2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00,
0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x07, 0x12, 0x20,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x10,
0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08, 0xe2, 0x20, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x75, 0x66, 0x78, 0x2e, 0x74, 0x2e, 0x2e, 0x01, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x4d, 0x61, 0x69, 0x6e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6c, 0x75, 0x66, 0x78, 0x2e, 0x70, 0x2e,
0x2e, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43,
0x61, 0x73, 0x74, 0x65, 0x72, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x4c, 0x4e, 0x52, 0x65, 0x6e,
0x64, 0x65, 0x72, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72,
0x01, 0x00, 0x64, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6c, 0x6e,
0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00,
0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x01, 0x01, 0x40,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x6c, 0x6e, 0x5f, 0x56, 0x69,
0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4c, 0x69, 0x67,
0x68, 0x74, 0x30, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, | 97.983549 | 97 | 0.653075 | GameDevery |
e70293e62b09aa76134835a4e24f6e8ca31738cf | 814 | hpp | C++ | packrat/lib/x86_64-pc-linux-gnu/3.2.5/RcppArmadillo/include/armadillo_bits/newarp_DenseGenMatProd_bones.hpp | Chicago-R-User-Group/2017-n3-Meetup-RStudio | 71a3204412c7573af2d233208147780d313430af | [
"MIT"
] | 70 | 2016-11-06T15:17:22.000Z | 2022-03-01T14:50:59.000Z | packrat/lib/x86_64-pc-linux-gnu/3.2.5/RcppArmadillo/include/armadillo_bits/newarp_DenseGenMatProd_bones.hpp | Chicago-R-User-Group/2017-n3-Meetup-RStudio | 71a3204412c7573af2d233208147780d313430af | [
"MIT"
] | 5 | 2016-08-15T03:02:03.000Z | 2017-05-12T21:59:19.000Z | packrat/lib/x86_64-pc-linux-gnu/3.2.5/RcppArmadillo/include/armadillo_bits/newarp_DenseGenMatProd_bones.hpp | Chicago-R-User-Group/2017-n3-Meetup-RStudio | 71a3204412c7573af2d233208147780d313430af | [
"MIT"
] | 9 | 2019-06-08T06:59:33.000Z | 2021-09-11T06:41:27.000Z | // Copyright (C) 2016 National ICT Australia (NICTA)
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// -------------------------------------------------------------------
//
// Written by Yixuan Qiu
namespace newarp
{
//! Define matrix operations on existing matrix objects
template<typename eT>
class DenseGenMatProd
{
private:
const Mat<eT>& op_mat;
public:
const uword n_rows; // number of rows of the underlying matrix
const uword n_cols; // number of columns of the underlying matrix
inline DenseGenMatProd(const Mat<eT>& mat_obj);
inline void perform_op(eT* x_in, eT* y_out) const;
};
} // namespace newarp
| 22.611111 | 70 | 0.640049 | Chicago-R-User-Group |
e70758bad5fecb8423001161174bf2dbc7a2f6b2 | 4,332 | cpp | C++ | src/logchangepathentriesmodel.cpp | anrichter/qsvn | d048023ddcf7c23540cdde47096c2187b19e3710 | [
"MIT"
] | 22 | 2015-02-12T07:38:09.000Z | 2021-11-03T07:42:39.000Z | src/logchangepathentriesmodel.cpp | anrichter/qsvn | d048023ddcf7c23540cdde47096c2187b19e3710 | [
"MIT"
] | null | null | null | src/logchangepathentriesmodel.cpp | anrichter/qsvn | d048023ddcf7c23540cdde47096c2187b19e3710 | [
"MIT"
] | 17 | 2015-01-26T01:11:51.000Z | 2020-10-29T10:00:28.000Z | /********************************************************************************
* This file is part of QSvn Project http://www.anrichter.net/projects/qsvn *
* Copyright (c) 2004-2010 Andreas Richter <ar@anrichter.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License Version 2 *
* as published by the Free Software Foundation. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*******************************************************************************/
//QSvn
#include "logchangepathentriesmodel.h"
#include "logchangepathentriesmodel.moc"
//SvnQt
#include "svnqt/client.hpp"
#include "svnqt/log_entry.hpp"
//Qt
#include <QtCore>
#include <QColor>
LogChangePathEntriesModel::LogChangePathEntriesModel(QObject *parent, const QString path)
: QAbstractTableModel(parent)
{
m_logChangePathEntries = svn::LogChangePathEntries();
m_path = path;
}
void LogChangePathEntriesModel::setChangePathEntries(svn::LogChangePathEntries logChangePathEntries)
{
m_logChangePathEntries = logChangePathEntries;
emit layoutChanged();
}
int LogChangePathEntriesModel::rowCount(const QModelIndex &parent) const
{
return m_logChangePathEntries.count();
}
int LogChangePathEntriesModel::columnCount(const QModelIndex &parent) const
{
return 4;
}
QVariant LogChangePathEntriesModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
switch (section)
{
case 0:
return QString(tr("Action"));
break;
case 1:
return QString(tr("Path"));
break;
case 2:
return QString(tr("Copy from path"));
break;
case 3:
return QString(tr("Copy from Revision"));
break;
}
}
return QVariant();
}
QVariant LogChangePathEntriesModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
svn::LogChangePathEntry logChangePathEntry = m_logChangePathEntries.at(index.row());
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case 0:
return QChar(logChangePathEntry.action);
break;
case 1:
return logChangePathEntry.path;
break;
case 2:
return logChangePathEntry.copyFromPath;
break;
case 3:
if (SVN_IS_VALID_REVNUM(logChangePathEntry.copyFromRevision))
return int(logChangePathEntry.copyFromRevision);
else
return QVariant();
break;
default:
return QVariant();
break;
}
}
else if (role == Qt::ForegroundRole)
{
if (logChangePathEntry.path.contains(m_path) )
return QColor(Qt::black);
else
return QColor(Qt::gray);
}
else
return QVariant();
}
svn::LogChangePathEntry LogChangePathEntriesModel::getLogChangePathEntry(const QModelIndex &index)
{
return m_logChangePathEntries.at(index.row());
}
| 34.110236 | 104 | 0.520545 | anrichter |
e7136bbdeff7e91dd43b8d4b94c45d09c13b7034 | 3,409 | cpp | C++ | Testing/Marlin-2.0.x/Marlin/src/HAL/LINUX/hardware/Timer.cpp | qisback/Geeetech-i3-B-pro-configs | a2c309923c4e68103addda677fda190238a1abe0 | [
"CC-BY-4.0"
] | 5 | 2020-05-17T21:16:41.000Z | 2021-06-11T04:46:31.000Z | Testing/Marlin-2.0.x/Marlin/src/HAL/LINUX/hardware/Timer.cpp | qisback/Geeetech-i3-B-pro-configs | a2c309923c4e68103addda677fda190238a1abe0 | [
"CC-BY-4.0"
] | 1 | 2020-09-27T14:53:34.000Z | 2020-09-27T14:53:34.000Z | src/HAL/HAL_LINUX/hardware/Timer.cpp | Sundancer78/Marlin-2.0.4_SKR_14_turbo_ender3 | d9dbef52e6fb4e110908a6d09d0af00fc0ac9b20 | [
"MIT"
] | 2 | 2020-10-05T15:08:13.000Z | 2020-10-20T06:21:59.000Z | /**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef __PLAT_LINUX__
#include "Timer.h"
#include <stdio.h>
Timer::Timer() {
active = false;
compare = 0;
frequency = 0;
overruns = 0;
timerid = 0;
cbfn = nullptr;
period = 0;
start_time = 0;
avg_error = 0;
}
Timer::~Timer() {
timer_delete(timerid);
}
void Timer::init(uint32_t sig_id, uint32_t sim_freq, callback_fn* fn) {
struct sigaction sa;
struct sigevent sev;
frequency = sim_freq;
cbfn = fn;
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = Timer::handler;
sigemptyset(&sa.sa_mask);
if (sigaction(SIGRTMIN, &sa, nullptr) == -1) {
return; // todo: handle error
}
sigemptyset(&mask);
sigaddset(&mask, SIGRTMIN);
disable();
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = SIGRTMIN;
sev.sigev_value.sival_ptr = (void*)this;
if (timer_create(CLOCK_REALTIME, &sev, &timerid) == -1) {
return; // todo: handle error
}
}
void Timer::start(uint32_t frequency) {
setCompare(this->frequency / frequency);
//printf("timer(%ld) started\n", getID());
}
void Timer::enable() {
if (sigprocmask(SIG_UNBLOCK, &mask, nullptr) == -1) {
return; // todo: handle error
}
active = true;
//printf("timer(%ld) enabled\n", getID());
}
void Timer::disable() {
if (sigprocmask(SIG_SETMASK, &mask, nullptr) == -1) {
return; // todo: handle error
}
active = false;
}
void Timer::setCompare(uint32_t compare) {
uint32_t nsec_offset = 0;
if (active) {
nsec_offset = Clock::nanos() - this->start_time; // calculate how long the timer would have been running for
nsec_offset = nsec_offset < 1000 ? nsec_offset : 0; // constrain, this shouldn't be needed but apparently Marlin enables interrupts on the stepper timer before initialising it, todo: investigate ?bug?
}
this->compare = compare;
uint64_t ns = Clock::ticksToNanos(compare, frequency) - nsec_offset;
struct itimerspec its;
its.it_value.tv_sec = ns / 1000000000;
its.it_value.tv_nsec = ns % 1000000000;
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
if (timer_settime(timerid, 0, &its, nullptr) == -1) {
printf("timer(%ld) failed, compare: %d(%ld)\n", getID(), compare, its.it_value.tv_nsec);
return; // todo: handle error
}
//printf("timer(%ld) started, compare: %d(%d)\n", getID(), compare, its.it_value.tv_nsec);
this->period = its.it_value.tv_nsec;
this->start_time = Clock::nanos();
}
uint32_t Timer::getCount() {
return Clock::nanosToTicks(Clock::nanos() - this->start_time, frequency);
}
#endif // __PLAT_LINUX__
| 28.647059 | 204 | 0.688472 | qisback |
e713b02d7b884f1e4a453a20d75ae326e09d2214 | 46,093 | cc | C++ | libshaderc_spvc/src/spvc.cc | johnzupin/shaderc | d8eca133b4b18e4fb8b2ab9b9f04dc53d5ce2537 | [
"Apache-2.0"
] | null | null | null | libshaderc_spvc/src/spvc.cc | johnzupin/shaderc | d8eca133b4b18e4fb8b2ab9b9f04dc53d5ce2537 | [
"Apache-2.0"
] | null | null | null | libshaderc_spvc/src/spvc.cc | johnzupin/shaderc | d8eca133b4b18e4fb8b2ab9b9f04dc53d5ce2537 | [
"Apache-2.0"
] | null | null | null | // Copyright 2018 The Shaderc Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <spvc/spvc.hpp>
#include "spvc_log.h"
#include "spvc_private.h"
// MSVC 2013 doesn't define __func__
#ifndef __func__
#define __func__ __FUNCTION__
#endif
#define CHECK_CONTEXT(context) \
do { \
if (!context) { \
shaderc_spvc::ErrorLog(nullptr) \
<< "Invoked " << __func__ << " without an initialized context"; \
return shaderc_spvc_status_missing_context_error; \
} \
} while (0)
#define CHECK_CROSS_COMPILER(context, cross_compiler) \
do { \
if (!cross_compiler) { \
shaderc_spvc::ErrorLog(context) \
<< "Invoked " << __func__ \
<< " without an initialized cross compiler"; \
return shaderc_spvc_status_uninitialized_compiler_error; \
} \
} while (0)
#define CHECK_OPTIONS(context, options) \
do { \
if (!options) { \
shaderc_spvc::ErrorLog(context) \
<< "Invoked " << __func__ << " without an initialized options"; \
return shaderc_spvc_status_missing_options_error; \
} \
} while (0)
#define CHECK_RESULT(context, result) \
do { \
if (!result) { \
shaderc_spvc::ErrorLog(context) \
<< "Invoked " << __func__ << " without an initialized result"; \
return shaderc_spvc_status_missing_result_error; \
} \
} while (0)
#define CHECK_OUT_PARAM(context, param, param_str) \
do { \
if (!param) { \
shaderc_spvc::ErrorLog(context) \
<< "Invoked " << __func__ << " with invalid out param, " \
<< param_str; \
return shaderc_spvc_status_invalid_out_param; \
} \
} while (0)
#define CHECK_IN_PARAM(context, param, param_str) \
do { \
if (!param) { \
shaderc_spvc::ErrorLog(context) \
<< "Invoked " << __func__ << " with invalid in param, " \
<< param_str; \
return shaderc_spvc_status_invalid_in_param; \
} \
} while (0)
namespace {
spv::ExecutionModel spvc_model_to_spv_model(
shaderc_spvc_execution_model model) {
switch (model) {
case shaderc_spvc_execution_model_vertex:
return spv::ExecutionModel::ExecutionModelVertex;
case shaderc_spvc_execution_model_fragment:
return spv::ExecutionModel::ExecutionModelFragment;
case shaderc_spvc_execution_model_glcompute:
return spv::ExecutionModel::ExecutionModelGLCompute;
case shaderc_spvc_execution_model_invalid:
return spv::ExecutionModel::ExecutionModelMax;
}
// Older gcc doesn't recognize that all of the possible cases are covered
// above.
assert(false);
return spv::ExecutionModel::ExecutionModelMax;
}
shaderc_spvc_execution_model spv_model_to_spvc_model(
spv::ExecutionModel model) {
switch (model) {
case spv::ExecutionModel::ExecutionModelVertex:
return shaderc_spvc_execution_model_vertex;
case spv::ExecutionModel::ExecutionModelFragment:
return shaderc_spvc_execution_model_fragment;
case spv::ExecutionModel::ExecutionModelGLCompute:
return shaderc_spvc_execution_model_glcompute;
default:
return shaderc_spvc_execution_model_invalid;
}
}
const spirv_cross::SmallVector<spirv_cross::Resource>* get_shader_resources(
const spirv_cross::ShaderResources& resources,
shaderc_spvc_shader_resource resource) {
switch (resource) {
case shaderc_spvc_shader_resource_uniform_buffers:
return &(resources.uniform_buffers);
case shaderc_spvc_shader_resource_separate_images:
return &(resources.separate_images);
case shaderc_spvc_shader_resource_separate_samplers:
return &(resources.separate_samplers);
case shaderc_spvc_shader_resource_storage_buffers:
return &(resources.storage_buffers);
case shaderc_spvc_shader_resource_storage_images:
return &(resources.storage_images);
}
// Older gcc doesn't recognize that all of the possible cases are covered
// above.
assert(false);
return nullptr;
}
shaderc_spvc_texture_view_dimension spirv_dim_to_texture_view_dimension(
spv::Dim dim, bool arrayed) {
switch (dim) {
case spv::Dim::Dim1D:
return shaderc_spvc_texture_view_dimension_e1D;
case spv::Dim::Dim2D:
if (arrayed) {
return shaderc_spvc_texture_view_dimension_e2D_array;
} else {
return shaderc_spvc_texture_view_dimension_e2D;
}
case spv::Dim::Dim3D:
return shaderc_spvc_texture_view_dimension_e3D;
case spv::Dim::DimCube:
if (arrayed) {
return shaderc_spvc_texture_view_dimension_cube_array;
} else {
return shaderc_spvc_texture_view_dimension_cube;
}
default:
return shaderc_spvc_texture_view_dimension_undefined;
}
}
shaderc_spvc_texture_format_type spirv_cross_base_type_to_texture_format_type(
spirv_cross::SPIRType::BaseType type) {
switch (type) {
case spirv_cross::SPIRType::Float:
return shaderc_spvc_texture_format_type_float;
case spirv_cross::SPIRType::Int:
return shaderc_spvc_texture_format_type_sint;
case spirv_cross::SPIRType::UInt:
return shaderc_spvc_texture_format_type_uint;
default:
return shaderc_spvc_texture_format_type_other;
}
}
shaderc_spvc_storage_texture_format spv_image_format_to_storage_texture_format(
spv::ImageFormat format) {
switch (format) {
case spv::ImageFormatR8:
return shaderc_spvc_storage_texture_format_r8unorm;
case spv::ImageFormatR8Snorm:
return shaderc_spvc_storage_texture_format_r8snorm;
case spv::ImageFormatR8ui:
return shaderc_spvc_storage_texture_format_r8uint;
case spv::ImageFormatR8i:
return shaderc_spvc_storage_texture_format_r8sint;
case spv::ImageFormatR16ui:
return shaderc_spvc_storage_texture_format_r16uint;
case spv::ImageFormatR16i:
return shaderc_spvc_storage_texture_format_r16sint;
case spv::ImageFormatR16f:
return shaderc_spvc_storage_texture_format_r16float;
case spv::ImageFormatRg8:
return shaderc_spvc_storage_texture_format_rg8unorm;
case spv::ImageFormatRg8Snorm:
return shaderc_spvc_storage_texture_format_rg8snorm;
case spv::ImageFormatRg8ui:
return shaderc_spvc_storage_texture_format_rg8uint;
case spv::ImageFormatRg8i:
return shaderc_spvc_storage_texture_format_rg8sint;
case spv::ImageFormatR32f:
return shaderc_spvc_storage_texture_format_r32float;
case spv::ImageFormatR32ui:
return shaderc_spvc_storage_texture_format_r32uint;
case spv::ImageFormatR32i:
return shaderc_spvc_storage_texture_format_r32sint;
case spv::ImageFormatRg16ui:
return shaderc_spvc_storage_texture_format_rg16uint;
case spv::ImageFormatRg16i:
return shaderc_spvc_storage_texture_format_rg16sint;
case spv::ImageFormatRg16f:
return shaderc_spvc_storage_texture_format_rg16float;
case spv::ImageFormatRgba8:
return shaderc_spvc_storage_texture_format_rgba8unorm;
case spv::ImageFormatRgba8Snorm:
return shaderc_spvc_storage_texture_format_rgba8snorm;
case spv::ImageFormatRgba8ui:
return shaderc_spvc_storage_texture_format_rgba8uint;
case spv::ImageFormatRgba8i:
return shaderc_spvc_storage_texture_format_rgba8sint;
case spv::ImageFormatRgb10A2:
return shaderc_spvc_storage_texture_format_rgb10a2unorm;
case spv::ImageFormatR11fG11fB10f:
return shaderc_spvc_storage_texture_format_rg11b10float;
case spv::ImageFormatRg32f:
return shaderc_spvc_storage_texture_format_rg32float;
case spv::ImageFormatRg32ui:
return shaderc_spvc_storage_texture_format_rg32uint;
case spv::ImageFormatRg32i:
return shaderc_spvc_storage_texture_format_rg32sint;
case spv::ImageFormatRgba16ui:
return shaderc_spvc_storage_texture_format_rgba16uint;
case spv::ImageFormatRgba16i:
return shaderc_spvc_storage_texture_format_rgba16sint;
case spv::ImageFormatRgba16f:
return shaderc_spvc_storage_texture_format_rgba16float;
case spv::ImageFormatRgba32f:
return shaderc_spvc_storage_texture_format_rgba32float;
case spv::ImageFormatRgba32ui:
return shaderc_spvc_storage_texture_format_rgba32uint;
case spv::ImageFormatRgba32i:
return shaderc_spvc_storage_texture_format_rgba32sint;
default:
return shaderc_spvc_storage_texture_format_undefined;
}
}
spv_target_env shaderc_spvc_spv_env_to_spv_target_env(
shaderc_spvc_spv_env env) {
switch (env) {
case shaderc_spvc_spv_env_universal_1_0:
return SPV_ENV_UNIVERSAL_1_0;
case shaderc_spvc_spv_env_vulkan_1_0:
return SPV_ENV_VULKAN_1_0;
case shaderc_spvc_spv_env_universal_1_1:
return SPV_ENV_UNIVERSAL_1_1;
case shaderc_spvc_spv_env_opencl_2_1:
return SPV_ENV_OPENCL_2_1;
case shaderc_spvc_spv_env_opencl_2_2:
return SPV_ENV_OPENCL_2_2;
case shaderc_spvc_spv_env_opengl_4_0:
return SPV_ENV_OPENGL_4_0;
case shaderc_spvc_spv_env_opengl_4_1:
return SPV_ENV_OPENGL_4_1;
case shaderc_spvc_spv_env_opengl_4_2:
return SPV_ENV_OPENGL_4_2;
case shaderc_spvc_spv_env_opengl_4_3:
return SPV_ENV_OPENGL_4_3;
case shaderc_spvc_spv_env_opengl_4_5:
return SPV_ENV_OPENGL_4_5;
case shaderc_spvc_spv_env_universal_1_2:
return SPV_ENV_UNIVERSAL_1_2;
case shaderc_spvc_spv_env_opencl_1_2:
return SPV_ENV_OPENCL_1_2;
case shaderc_spvc_spv_env_opencl_embedded_1_2:
return SPV_ENV_OPENCL_EMBEDDED_1_2;
case shaderc_spvc_spv_env_opencl_2_0:
return SPV_ENV_OPENCL_2_0;
case shaderc_spvc_spv_env_opencl_embedded_2_0:
return SPV_ENV_OPENCL_EMBEDDED_2_0;
case shaderc_spvc_spv_env_opencl_embedded_2_1:
return SPV_ENV_OPENCL_EMBEDDED_2_1;
case shaderc_spvc_spv_env_opencl_embedded_2_2:
return SPV_ENV_OPENCL_EMBEDDED_2_2;
case shaderc_spvc_spv_env_universal_1_3:
return SPV_ENV_UNIVERSAL_1_3;
case shaderc_spvc_spv_env_vulkan_1_1:
return SPV_ENV_VULKAN_1_1;
case shaderc_spvc_spv_env_webgpu_0:
return SPV_ENV_WEBGPU_0;
case shaderc_spvc_spv_env_universal_1_4:
return SPV_ENV_UNIVERSAL_1_4;
case shaderc_spvc_spv_env_vulkan_1_1_spirv_1_4:
return SPV_ENV_VULKAN_1_1_SPIRV_1_4;
case shaderc_spvc_spv_env_universal_1_5:
return SPV_ENV_UNIVERSAL_1_5;
case shaderc_spvc_spv_env_vulkan_1_2:
return SPV_ENV_VULKAN_1_2;
}
shaderc_spvc::ErrorLog(nullptr)
<< "Attempted to convert unknown shaderc_spvc_spv_env value, " << env;
assert(false);
return SPV_ENV_UNIVERSAL_1_0;
}
shaderc_spvc_status get_location_info_impl(
spirv_cross::Compiler* compiler,
const spirv_cross::SmallVector<spirv_cross::Resource>& resources,
shaderc_spvc_resource_location_info* locations, size_t* location_count) {
*location_count = resources.size();
if (!locations) return shaderc_spvc_status_success;
for (const auto& resource : resources) {
if (!compiler->get_decoration_bitset(resource.id)
.get(spv::DecorationLocation)) {
return shaderc_spvc_status_internal_error;
}
locations->id = resource.id;
if (compiler->get_decoration_bitset(resource.id)
.get(spv::DecorationLocation)) {
locations->location =
compiler->get_decoration(resource.id, spv::DecorationLocation);
locations->has_location = true;
} else {
locations->has_location = false;
}
locations++;
}
return shaderc_spvc_status_success;
}
} // namespace
shaderc_spvc_context_t shaderc_spvc_context_create() {
return new (std::nothrow) shaderc_spvc_context;
}
void shaderc_spvc_context_destroy(shaderc_spvc_context_t context) {
if (context) delete context;
}
const char* shaderc_spvc_context_get_messages(
const shaderc_spvc_context_t context) {
for (const auto& message : context->messages) {
context->messages_string += message;
}
context->messages.clear();
return context->messages_string.c_str();
}
shaderc_spvc_status shaderc_spvc_context_get_compiler(
const shaderc_spvc_context_t context, void** compiler) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, compiler, "compiler");
*compiler = context->cross_compiler.get();
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_context_set_use_spvc_parser(
shaderc_spvc_context_t context, bool b) {
CHECK_CONTEXT(context);
context->use_spvc_parser = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_compile_options_t shaderc_spvc_compile_options_create(
shaderc_spvc_spv_env source_env, shaderc_spvc_spv_env target_env) {
shaderc_spvc_compile_options_t options =
new (std::nothrow) shaderc_spvc_compile_options;
if (options) {
options->glsl.version = 0;
options->source_env = shaderc_spvc_spv_env_to_spv_target_env(source_env);
options->target_env = shaderc_spvc_spv_env_to_spv_target_env(target_env);
}
return options;
}
shaderc_spvc_compile_options_t shaderc_spvc_compile_options_clone(
shaderc_spvc_compile_options_t options) {
if (options) return new (std::nothrow) shaderc_spvc_compile_options(*options);
return nullptr;
}
void shaderc_spvc_compile_options_destroy(
shaderc_spvc_compile_options_t options) {
if (options) delete options;
}
// DEPRECATED
shaderc_spvc_status shaderc_spvc_compile_options_set_source_env(
shaderc_spvc_compile_options_t options, shaderc_target_env env,
shaderc_env_version version) {
CHECK_OPTIONS(nullptr, options);
options->source_env = spvc_private::get_spv_target_env(env, version);
return shaderc_spvc_status_success;
}
// DEPRECATED
shaderc_spvc_status shaderc_spvc_compile_options_set_target_env(
shaderc_spvc_compile_options_t options, shaderc_target_env env,
shaderc_env_version version) {
CHECK_OPTIONS(nullptr, options);
options->target_env = spvc_private::get_spv_target_env(env, version);
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_entry_point(
shaderc_spvc_compile_options_t options, const char* entry_point) {
CHECK_OPTIONS(nullptr, options);
CHECK_IN_PARAM(nullptr, entry_point, "entry_point");
options->entry_point = entry_point;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_remove_unused_variables(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->remove_unused_variables = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_robust_buffer_access_pass(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->robust_buffer_access_pass = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_emit_line_directives(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->glsl.emit_line_directives = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_vulkan_semantics(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->glsl.vulkan_semantics = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_separate_shader_objects(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->glsl.separate_shader_objects = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_flatten_ubo(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->flatten_ubo = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_glsl_language_version(
shaderc_spvc_compile_options_t options, uint32_t version) {
CHECK_OPTIONS(nullptr, options);
options->glsl.version = version;
return shaderc_spvc_status_success;
}
shaderc_spvc_status
shaderc_spvc_compile_options_set_flatten_multidimensional_arrays(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->glsl.flatten_multidimensional_arrays = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status
shaderc_spvc_compile_options_set_force_zero_initialized_variables(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->glsl.force_zero_initialized_variables = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_es(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->forced_es_setting = b;
options->force_es = true;
return shaderc_spvc_status_success;
}
shaderc_spvc_status
shaderc_spvc_compile_options_set_glsl_emit_push_constant_as_ubo(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->glsl.emit_push_constant_as_uniform_buffer = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_msl_language_version(
shaderc_spvc_compile_options_t options, uint32_t version) {
CHECK_OPTIONS(nullptr, options);
options->msl.msl_version = version;
return shaderc_spvc_status_success;
}
shaderc_spvc_status
shaderc_spvc_compile_options_set_msl_swizzle_texture_samples(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->msl.swizzle_texture_samples = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_msl_platform(
shaderc_spvc_compile_options_t options,
shaderc_spvc_msl_platform platform) {
CHECK_OPTIONS(nullptr, options);
switch (platform) {
case shaderc_spvc_msl_platform_ios:
options->msl.platform = spirv_cross::CompilerMSL::Options::iOS;
break;
case shaderc_spvc_msl_platform_macos:
options->msl.platform = spirv_cross::CompilerMSL::Options::macOS;
break;
}
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_msl_pad_fragment_output(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->msl.pad_fragment_output_components = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_msl_capture(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->msl.capture_output_to_buffer = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_msl_domain_lower_left(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->msl.tess_domain_origin_lower_left = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_msl_argument_buffers(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->msl.argument_buffers = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status
shaderc_spvc_compile_options_set_msl_discrete_descriptor_sets(
shaderc_spvc_compile_options_t options, const uint32_t* descriptors,
size_t num_descriptors) {
CHECK_OPTIONS(nullptr, options);
options->msl_discrete_descriptor_sets.resize(num_descriptors);
std::copy_n(descriptors, num_descriptors,
options->msl_discrete_descriptor_sets.begin());
return shaderc_spvc_status_success;
}
shaderc_spvc_status
shaderc_spvc_compile_options_set_msl_enable_point_size_builtin(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->msl.enable_point_size_builtin = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status
shaderc_spvc_compile_options_set_msl_buffer_size_buffer_index(
shaderc_spvc_compile_options_t options, uint32_t index) {
CHECK_OPTIONS(nullptr, options);
options->msl.buffer_size_buffer_index = index;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_hlsl_shader_model(
shaderc_spvc_compile_options_t options, uint32_t model) {
CHECK_OPTIONS(nullptr, options);
options->hlsl.shader_model = model;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_hlsl_point_size_compat(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->hlsl.point_size_compat = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_hlsl_point_coord_compat(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->hlsl.point_coord_compat = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status
shaderc_spvc_compile_options_set_hlsl_nonwritable_uav_texture_as_srv(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->hlsl.nonwritable_uav_texture_as_srv = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_set_hlsl_force_storage_buffer_as_uav(
const shaderc_spvc_context_t context, uint32_t desc_set, uint32_t binding) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
auto* hlsl_compiler = reinterpret_cast<spirv_cross::CompilerHLSL*>(
context->cross_compiler.get());
hlsl_compiler->set_hlsl_force_storage_buffer_as_uav(desc_set, binding);
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_fixup_clipspace(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->glsl.vertex.fixup_clipspace = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_flip_vert_y(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->glsl.vertex.flip_vert_y = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_validate(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->validate = b;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_compile_options_set_optimize(
shaderc_spvc_compile_options_t options, bool b) {
CHECK_OPTIONS(nullptr, options);
options->optimize = b;
return shaderc_spvc_status_success;
}
size_t shaderc_spvc_compile_options_set_for_fuzzing(
shaderc_spvc_compile_options_t options, const uint8_t* data, size_t size) {
if (!options || !data || size < sizeof(*options)) return 0;
memcpy(static_cast<void*>(options), data, sizeof(*options));
return sizeof(*options);
}
shaderc_spvc_status shaderc_spvc_initialize_impl(
const shaderc_spvc_context_t context, const uint32_t* source,
size_t source_len, shaderc_spvc_compile_options_t options,
shaderc_spvc_status (*generator)(const shaderc_spvc_context_t,
const uint32_t*, size_t,
shaderc_spvc_compile_options_t)) {
shaderc_spvc_status status = spvc_private::validate_and_translate_spirv(
context, source, source_len, options, &context->intermediate_shader);
if (status != shaderc_spvc_status_success) return status;
status = generator(context, context->intermediate_shader.data(),
context->intermediate_shader.size(), options);
if (status != shaderc_spvc_status_success) return status;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_initialize_for_glsl(
const shaderc_spvc_context_t context, const uint32_t* source,
size_t source_len, shaderc_spvc_compile_options_t options) {
CHECK_CONTEXT(context);
CHECK_OPTIONS(context, options);
CHECK_IN_PARAM(context, source, "source");
context->target_lang = SPVC_TARGET_LANG_GLSL;
return shaderc_spvc_initialize_impl(context, source, source_len, options,
spvc_private::generate_glsl_compiler);
}
shaderc_spvc_status shaderc_spvc_initialize_for_hlsl(
const shaderc_spvc_context_t context, const uint32_t* source,
size_t source_len, shaderc_spvc_compile_options_t options) {
CHECK_CONTEXT(context);
CHECK_OPTIONS(context, options);
CHECK_IN_PARAM(context, source, "source");
context->target_lang = SPVC_TARGET_LANG_HLSL;
return shaderc_spvc_initialize_impl(context, source, source_len, options,
spvc_private::generate_hlsl_compiler);
}
shaderc_spvc_status shaderc_spvc_initialize_for_msl(
const shaderc_spvc_context_t context, const uint32_t* source,
size_t source_len, shaderc_spvc_compile_options_t options) {
CHECK_CONTEXT(context);
CHECK_OPTIONS(context, options);
CHECK_IN_PARAM(context, source, "source");
context->target_lang = SPVC_TARGET_LANG_MSL;
return shaderc_spvc_initialize_impl(context, source, source_len, options,
spvc_private::generate_msl_compiler);
}
shaderc_spvc_status shaderc_spvc_initialize_for_vulkan(
const shaderc_spvc_context_t context, const uint32_t* source,
size_t source_len, shaderc_spvc_compile_options_t options) {
CHECK_CONTEXT(context);
CHECK_OPTIONS(context, options);
CHECK_IN_PARAM(context, source, "source");
context->target_lang = SPVC_TARGET_LANG_VULKAN;
return shaderc_spvc_initialize_impl(context, source, source_len, options,
spvc_private::generate_vulkan_compiler);
}
shaderc_spvc_status shaderc_spvc_compile_shader(
const shaderc_spvc_context_t context,
shaderc_spvc_compilation_result_t result) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
if (context->target_lang == SPVC_TARGET_LANG_UNKNOWN) {
shaderc_spvc::ErrorLog(context)
<< "Invoked compile_shader with unknown language";
return shaderc_spvc_status_configuration_error;
}
if (context->target_lang == SPVC_TARGET_LANG_VULKAN) {
// No actual cross compilation is needed, since the intermediate shader is
// already in Vulkan SPIR->V.
result->binary_output = context->intermediate_shader;
return shaderc_spvc_status_success;
} else {
shaderc_spvc_status status =
spvc_private::generate_shader(context->cross_compiler.get(), result);
if (status != shaderc_spvc_status_success) {
shaderc_spvc::ErrorLog(context) << "Compilation failed. Partial source:";
if (context->target_lang == SPVC_TARGET_LANG_GLSL) {
spirv_cross::CompilerGLSL* cast_compiler =
reinterpret_cast<spirv_cross::CompilerGLSL*>(
context->cross_compiler.get());
shaderc_spvc::ErrorLog(context) << cast_compiler->get_partial_source();
} else if (context->target_lang == SPVC_TARGET_LANG_HLSL) {
spirv_cross::CompilerHLSL* cast_compiler =
reinterpret_cast<spirv_cross::CompilerHLSL*>(
context->cross_compiler.get());
shaderc_spvc::ErrorLog(context) << cast_compiler->get_partial_source();
} else if (context->target_lang == SPVC_TARGET_LANG_MSL) {
spirv_cross::CompilerMSL* cast_compiler =
reinterpret_cast<spirv_cross::CompilerMSL*>(
context->cross_compiler.get());
shaderc_spvc::ErrorLog(context) << cast_compiler->get_partial_source();
} else {
shaderc_spvc::ErrorLog(context)
<< "Unexpected target language in context";
}
context->cross_compiler.reset();
}
return status;
}
}
shaderc_spvc_status shaderc_spvc_set_decoration(
const shaderc_spvc_context_t context, uint32_t id,
shaderc_spvc_decoration decoration, uint32_t argument) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
spv::Decoration spirv_cross_decoration;
shaderc_spvc_status status =
spvc_private::shaderc_spvc_decoration_to_spirv_cross_decoration(
decoration, &spirv_cross_decoration);
if (status == shaderc_spvc_status_success) {
context->cross_compiler->set_decoration(static_cast<spirv_cross::ID>(id),
spirv_cross_decoration, argument);
} else {
shaderc_spvc::ErrorLog(context) << "Decoration Conversion failed. "
"shaderc_spvc_decoration not supported.";
}
return status;
}
shaderc_spvc_status shaderc_spvc_get_decoration(
const shaderc_spvc_context_t context, uint32_t id,
shaderc_spvc_decoration decoration, uint32_t* value) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, value, "value");
spv::Decoration spirv_cross_decoration;
shaderc_spvc_status status =
spvc_private::shaderc_spvc_decoration_to_spirv_cross_decoration(
decoration, &spirv_cross_decoration);
if (status != shaderc_spvc_status_success) {
shaderc_spvc::ErrorLog(context) << "Decoration conversion failed. "
"shaderc_spvc_decoration not supported.";
return status;
}
*value = context->cross_compiler->get_decoration(
static_cast<spirv_cross::ID>(id), spirv_cross_decoration);
if (*value == 0) {
shaderc_spvc::ErrorLog(context)
<< "Getting decoration failed. id not found.";
return shaderc_spvc_status_compilation_error;
}
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_unset_decoration(
const shaderc_spvc_context_t context, uint32_t id,
shaderc_spvc_decoration decoration) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
spv::Decoration spirv_cross_decoration;
shaderc_spvc_status status =
spvc_private::shaderc_spvc_decoration_to_spirv_cross_decoration(
decoration, &spirv_cross_decoration);
if (status == shaderc_spvc_status_success) {
context->cross_compiler->unset_decoration(static_cast<spirv_cross::ID>(id),
spirv_cross_decoration);
} else {
shaderc_spvc::ErrorLog(context) << "Decoration conversion failed. "
"shaderc_spvc_decoration not supported.";
}
return status;
}
shaderc_spvc_status shaderc_spvc_get_combined_image_samplers(
const shaderc_spvc_context_t context,
shaderc_spvc_combined_image_sampler* samplers, size_t* num_samplers) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, num_samplers, "num_samplers");
*num_samplers = context->cross_compiler->get_combined_image_samplers().size();
if (!samplers) return shaderc_spvc_status_success;
for (const auto& combined :
context->cross_compiler->get_combined_image_samplers()) {
samplers->combined_id = combined.combined_id;
samplers->image_id = combined.image_id;
samplers->sampler_id = combined.sampler_id;
samplers++;
}
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_set_name(const shaderc_spvc_context_t context,
uint32_t id, const char* name) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_IN_PARAM(context, name, "name");
context->cross_compiler->set_name(id, name);
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_add_msl_resource_binding(
const shaderc_spvc_context_t context,
const shaderc_spvc_msl_resource_binding binding) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
if (context->target_lang != SPVC_TARGET_LANG_MSL) {
shaderc_spvc::ErrorLog(context)
<< "Invoked add_msl_resource_binding when target language was not MSL";
return shaderc_spvc_status_configuration_error;
}
spirv_cross::MSLResourceBinding cross_binding;
cross_binding.stage = spvc_model_to_spv_model(binding.stage);
cross_binding.binding = binding.binding;
cross_binding.desc_set = binding.desc_set;
cross_binding.msl_buffer = binding.msl_buffer;
cross_binding.msl_texture = binding.msl_texture;
cross_binding.msl_sampler = binding.msl_sampler;
reinterpret_cast<spirv_cross::CompilerMSL*>(context->cross_compiler.get())
->add_msl_resource_binding(cross_binding);
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_get_workgroup_size(
const shaderc_spvc_context_t context, const char* function_name,
shaderc_spvc_execution_model execution_model,
shaderc_spvc_workgroup_size* workgroup_size) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_IN_PARAM(context, function_name, "function_name");
CHECK_OUT_PARAM(context, workgroup_size, "workgroup_size");
const auto& cross_size =
context->cross_compiler
->get_entry_point(function_name,
spvc_model_to_spv_model(execution_model))
.workgroup_size;
workgroup_size->x = cross_size.x;
workgroup_size->y = cross_size.y;
workgroup_size->z = cross_size.z;
workgroup_size->constant = cross_size.constant;
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_needs_buffer_size_buffer(
const shaderc_spvc_context_t context, bool* b) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, b, "b");
if (context->target_lang != SPVC_TARGET_LANG_MSL) {
shaderc_spvc::ErrorLog(context)
<< "Invoked needs_buffer_size_buffer when target language was not MSL";
return shaderc_spvc_status_configuration_error;
}
*b =
reinterpret_cast<spirv_cross::CompilerMSL*>(context->cross_compiler.get())
->needs_buffer_size_buffer();
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_build_combined_image_samplers(
const shaderc_spvc_context_t context) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
context->cross_compiler->build_combined_image_samplers();
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_get_execution_model(
const shaderc_spvc_context_t context,
shaderc_spvc_execution_model* execution_model) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, execution_model, "execution_model");
auto spirv_model = context->cross_compiler->get_execution_model();
*execution_model = spv_model_to_spvc_model(spirv_model);
if (*execution_model == shaderc_spvc_execution_model_invalid) {
shaderc_spvc::ErrorLog(context)
<< "Shader execution model appears to be of an unsupported type";
return shaderc_spvc_status_internal_error;
}
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_get_push_constant_buffer_count(
const shaderc_spvc_context_t context, size_t* count) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, count, "count");
*count = context->cross_compiler->get_shader_resources()
.push_constant_buffers.size();
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_get_binding_info(
const shaderc_spvc_context_t context, shaderc_spvc_shader_resource resource,
shaderc_spvc_binding_type binding_type, shaderc_spvc_binding_info* bindings,
size_t* binding_count) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, binding_count, "binding_count");
auto* compiler = context->cross_compiler.get();
const auto& resources = compiler->get_shader_resources();
const auto* shader_resources = get_shader_resources(resources, resource);
*binding_count = shader_resources->size();
if (!bindings) return shaderc_spvc_status_success;
for (const auto& shader_resource : *shader_resources) {
bindings->texture_dimension = shaderc_spvc_texture_view_dimension_undefined;
bindings->texture_component_type = shaderc_spvc_texture_format_type_float;
if (!compiler->get_decoration_bitset(shader_resource.id)
.get(spv::DecorationBinding)) {
shaderc_spvc::ErrorLog(context)
<< "Unable to get binding decoration for shader resource";
return shaderc_spvc_status_internal_error;
}
uint32_t binding_decoration =
compiler->get_decoration(shader_resource.id, spv::DecorationBinding);
bindings->binding = binding_decoration;
if (!compiler->get_decoration_bitset(shader_resource.id)
.get(spv::DecorationDescriptorSet)) {
shaderc_spvc::ErrorLog(context)
<< "Unable to get descriptor set decoration for shader resource";
return shaderc_spvc_status_internal_error;
}
uint32_t descriptor_set_decoration = compiler->get_decoration(
shader_resource.id, spv::DecorationDescriptorSet);
bindings->set = descriptor_set_decoration;
bindings->id = shader_resource.id;
bindings->base_type_id = shader_resource.base_type_id;
switch (binding_type) {
case shaderc_spvc_binding_type_sampled_texture: {
spirv_cross::SPIRType::ImageType imageType =
compiler->get_type(bindings->base_type_id).image;
spirv_cross::SPIRType::BaseType textureComponentType =
compiler->get_type(imageType.type).basetype;
bindings->multisampled = imageType.ms;
bindings->texture_dimension = spirv_dim_to_texture_view_dimension(
imageType.dim, imageType.arrayed);
bindings->texture_component_type =
spirv_cross_base_type_to_texture_format_type(textureComponentType);
bindings->binding_type = binding_type;
} break;
case shaderc_spvc_binding_type_storage_buffer: {
// Differentiate between readonly storage bindings and writable ones
// based on the NonWritable decoration
spirv_cross::Bitset flags =
compiler->get_buffer_block_flags(shader_resource.id);
if (flags.get(spv::DecorationNonWritable)) {
bindings->binding_type =
shaderc_spvc_binding_type_readonly_storage_buffer;
} else {
bindings->binding_type = shaderc_spvc_binding_type_storage_buffer;
}
} break;
case shaderc_spvc_binding_type_storage_texture: {
spirv_cross::Bitset flags = compiler->get_decoration_bitset(shader_resource.id);
if (flags.get(spv::DecorationNonReadable)) {
bindings->binding_type = shaderc_spvc_binding_type_writeonly_storage_texture;
} else if (flags.get(spv::DecorationNonWritable)) {
bindings->binding_type = shaderc_spvc_binding_type_readonly_storage_texture;
} else {
bindings->binding_type = shaderc_spvc_binding_type_storage_texture;
}
spirv_cross::SPIRType::ImageType imageType =
compiler->get_type(bindings->base_type_id).image;
bindings->storage_texture_format =
spv_image_format_to_storage_texture_format(imageType.format);
bindings->texture_dimension = spirv_dim_to_texture_view_dimension(
imageType.dim, imageType.arrayed);
bindings->multisampled = imageType.ms;
} break;
case shaderc_spvc_binding_type_sampler: {
// The inheritance hierarchy here is odd, it goes
// Compiler->CompilerGLSL->CompilerHLSL/MSL/Reflection.
// CompilerGLSL is an intermediate super class for all of the other leaf
// classes. The method we need is defined on CompilerGLSL, not Compiler.
// This cast is safe, since we only should ever have a
// CompilerGLSL/HLSL/MSL/Reflection in |cross_compiler|.
auto* glsl_compiler = reinterpret_cast<spirv_cross::CompilerGLSL*>(
context->cross_compiler.get());
if (glsl_compiler->variable_is_depth_or_compare(shader_resource.id)) {
bindings->binding_type = shaderc_spvc_binding_type_comparison_sampler;
} else {
bindings->binding_type = shaderc_spvc_binding_type_sampler;
}
} break;
default:
bindings->binding_type = binding_type;
}
bindings++;
}
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_get_input_stage_location_info(
const shaderc_spvc_context_t context,
shaderc_spvc_resource_location_info* locations, size_t* location_count) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, location_count, "location_count");
auto* compiler = context->cross_compiler.get();
shaderc_spvc_status status = get_location_info_impl(
compiler, compiler->get_shader_resources().stage_inputs, locations,
location_count);
if (status != shaderc_spvc_status_success) {
shaderc_spvc::ErrorLog(context)
<< "Unable to get location decoration for stage input";
}
return status;
}
shaderc_spvc_status shaderc_spvc_get_output_stage_location_info(
const shaderc_spvc_context_t context,
shaderc_spvc_resource_location_info* locations, size_t* location_count) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, location_count, "location_count");
auto* compiler = context->cross_compiler.get();
shaderc_spvc_status status = get_location_info_impl(
compiler, compiler->get_shader_resources().stage_outputs, locations,
location_count);
if (status != shaderc_spvc_status_success) {
shaderc_spvc::ErrorLog(context)
<< "Unable to get location decoration for stage output";
}
return status;
}
shaderc_spvc_status shaderc_spvc_get_output_stage_type_info(
const shaderc_spvc_context_t context,
shaderc_spvc_resource_type_info* types, size_t* type_count) {
CHECK_CONTEXT(context);
CHECK_CROSS_COMPILER(context, context->cross_compiler);
CHECK_OUT_PARAM(context, type_count, "type_count");
auto* compiler = context->cross_compiler.get();
const auto& resources = compiler->get_shader_resources().stage_outputs;
*type_count = resources.size();
if (!types) return shaderc_spvc_status_success;
for (const auto& resource : resources) {
if (!compiler->get_decoration_bitset(resource.id)
.get(spv::DecorationLocation)) {
shaderc_spvc::ErrorLog(context)
<< "Unable to get location decoration for stage output";
return shaderc_spvc_status_internal_error;
}
types->location =
compiler->get_decoration(resource.id, spv::DecorationLocation);
spirv_cross::SPIRType::BaseType base_type =
compiler->get_type(resource.base_type_id).basetype;
types->type = spirv_cross_base_type_to_texture_format_type(base_type);
types++;
}
return shaderc_spvc_status_success;
}
shaderc_spvc_compilation_result_t shaderc_spvc_result_create() {
return new (std::nothrow) shaderc_spvc_compilation_result;
}
void shaderc_spvc_result_destroy(shaderc_spvc_compilation_result_t result) {
if (result) delete result;
}
shaderc_spvc_status shaderc_spvc_result_get_string_output(
const shaderc_spvc_compilation_result_t result, const char** str) {
CHECK_RESULT(nullptr, result);
CHECK_OUT_PARAM(nullptr, str, "str");
*str = result->string_output.c_str();
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_result_get_binary_output(
const shaderc_spvc_compilation_result_t result,
const uint32_t** binary_output) {
CHECK_RESULT(nullptr, result);
CHECK_OUT_PARAM(nullptr, binary_output, "binary_output");
*binary_output = result->binary_output.data();
return shaderc_spvc_status_success;
}
shaderc_spvc_status shaderc_spvc_result_get_binary_length(
const shaderc_spvc_compilation_result_t result, uint32_t* len) {
CHECK_RESULT(nullptr, result);
CHECK_OUT_PARAM(nullptr, len, "len");
*len = result->binary_output.size();
return shaderc_spvc_status_success;
}
| 37.843186 | 88 | 0.738333 | johnzupin |
e715fdd1d88dd79ec1f8d7f4f7b362cf769ef32c | 37,177 | cc | C++ | Plugins/MediaPipe/Source/MediaPipe/Private/mediapipe/framework/formats/annotation/locus.pb.cc | sixtolink/ue4-mediapipe-plugin | f9423faa38fedc614499b2b97ec145711cac55e8 | [
"Apache-2.0"
] | 86 | 2021-07-16T05:01:59.000Z | 2022-03-25T17:20:09.000Z | Plugins/MediaPipe/Source/MediaPipe/Private/mediapipe/framework/formats/annotation/locus.pb.cc | dpredie/ue4-mediapipe-plugin | 3481e312bad0faa15c31e1581e8ee56d2711145a | [
"Apache-2.0"
] | 31 | 2021-07-18T07:11:06.000Z | 2022-03-30T07:02:10.000Z | Plugins/MediaPipe/Source/MediaPipe/Private/mediapipe/framework/formats/annotation/locus.pb.cc | dpredie/ue4-mediapipe-plugin | 3481e312bad0faa15c31e1581e8ee56d2711145a | [
"Apache-2.0"
] | 32 | 2021-07-18T10:29:17.000Z | 2022-03-30T12:16:02.000Z | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: mediapipe/framework/formats/annotation/locus.proto
#include "mediapipe/framework/formats/annotation/locus.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
extern PROTOBUF_INTERNAL_EXPORT_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_BoundingBox_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_Locus_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_mediapipe_2fframework_2fformats_2fannotation_2frasterization_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Rasterization_mediapipe_2fframework_2fformats_2fannotation_2frasterization_2eproto;
namespace mediapipe {
class LocusDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Locus> _instance;
} _Locus_default_instance_;
class BoundingBoxDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<BoundingBox> _instance;
} _BoundingBox_default_instance_;
} // namespace mediapipe
static void InitDefaultsscc_info_BoundingBox_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::mediapipe::_BoundingBox_default_instance_;
new (ptr) ::mediapipe::BoundingBox();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::mediapipe::BoundingBox::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_BoundingBox_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_BoundingBox_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto}, {}};
static void InitDefaultsscc_info_Locus_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::mediapipe::_Locus_default_instance_;
new (ptr) ::mediapipe::Locus();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::mediapipe::Locus::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_Locus_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_Locus_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto}, {
&scc_info_BoundingBox_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto.base,
&scc_info_Rasterization_mediapipe_2fframework_2fformats_2fannotation_2frasterization_2eproto.base,}};
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto[2];
static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto[1];
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto = nullptr;
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, _has_bits_),
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, locus_type_),
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, locus_id_),
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, locus_id_seed_),
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, concatenatable_),
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, bounding_box_),
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, timestamp_),
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, region_),
PROTOBUF_FIELD_OFFSET(::mediapipe::Locus, component_locus_),
5,
2,
3,
6,
0,
4,
1,
~0u,
PROTOBUF_FIELD_OFFSET(::mediapipe::BoundingBox, _has_bits_),
PROTOBUF_FIELD_OFFSET(::mediapipe::BoundingBox, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::mediapipe::BoundingBox, left_x_),
PROTOBUF_FIELD_OFFSET(::mediapipe::BoundingBox, upper_y_),
PROTOBUF_FIELD_OFFSET(::mediapipe::BoundingBox, right_x_),
PROTOBUF_FIELD_OFFSET(::mediapipe::BoundingBox, lower_y_),
0,
1,
2,
3,
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 13, sizeof(::mediapipe::Locus)},
{ 21, 30, sizeof(::mediapipe::BoundingBox)},
};
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::mediapipe::_Locus_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::mediapipe::_BoundingBox_default_instance_),
};
const char descriptor_table_protodef_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n2mediapipe/framework/formats/annotation"
"/locus.proto\022\tmediapipe\032:mediapipe/frame"
"work/formats/annotation/rasterization.pr"
"oto\"\337\002\n\005Locus\022.\n\nlocus_type\030\001 \001(\0162\032.medi"
"apipe.Locus.LocusType\022\020\n\010locus_id\030\002 \001(\006\022"
"\025\n\rlocus_id_seed\030\006 \001(\006\022\034\n\016concatenatable"
"\030\005 \001(\010:\004true\022,\n\014bounding_box\030\003 \001(\0132\026.med"
"iapipe.BoundingBox\022\025\n\ttimestamp\030\007 \001(\005:\002-"
"1\022(\n\006region\030\004 \001(\0132\030.mediapipe.Rasterizat"
"ion\022)\n\017component_locus\030\010 \003(\0132\020.mediapipe"
".Locus\"E\n\tLocusType\022\n\n\006GLOBAL\020\001\022\020\n\014BOUND"
"ING_BOX\020\002\022\n\n\006REGION\020\003\022\016\n\nVIDEO_TUBE\020\004\"P\n"
"\013BoundingBox\022\016\n\006left_x\030\001 \001(\005\022\017\n\007upper_y\030"
"\002 \001(\005\022\017\n\007right_x\030\003 \001(\005\022\017\n\007lower_y\030\004 \001(\005"
;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto_deps[1] = {
&::descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2frasterization_2eproto,
};
static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto_sccs[2] = {
&scc_info_BoundingBox_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto.base,
&scc_info_Locus_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto.base,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto_once;
static bool descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto_initialized = false;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto = {
&descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto_initialized, descriptor_table_protodef_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto, "mediapipe/framework/formats/annotation/locus.proto", 559,
&descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto_once, descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto_sccs, descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto_deps, 2, 1,
schemas, file_default_instances, TableStruct_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto::offsets,
file_level_metadata_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto, 2, file_level_enum_descriptors_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto, file_level_service_descriptors_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto,
};
// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto = ( ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto), true);
namespace mediapipe {
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Locus_LocusType_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto);
return file_level_enum_descriptors_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto[0];
}
bool Locus_LocusType_IsValid(int value) {
switch (value) {
case 1:
case 2:
case 3:
case 4:
return true;
default:
return false;
}
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900)
constexpr Locus_LocusType Locus::GLOBAL;
constexpr Locus_LocusType Locus::BOUNDING_BOX;
constexpr Locus_LocusType Locus::REGION;
constexpr Locus_LocusType Locus::VIDEO_TUBE;
constexpr Locus_LocusType Locus::LocusType_MIN;
constexpr Locus_LocusType Locus::LocusType_MAX;
constexpr int Locus::LocusType_ARRAYSIZE;
#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900)
// ===================================================================
void Locus::InitAsDefaultInstance() {
::mediapipe::_Locus_default_instance_._instance.get_mutable()->bounding_box_ = const_cast< ::mediapipe::BoundingBox*>(
::mediapipe::BoundingBox::internal_default_instance());
::mediapipe::_Locus_default_instance_._instance.get_mutable()->region_ = const_cast< ::mediapipe::Rasterization*>(
::mediapipe::Rasterization::internal_default_instance());
}
class Locus::_Internal {
public:
using HasBits = decltype(std::declval<Locus>()._has_bits_);
static void set_has_locus_type(HasBits* has_bits) {
(*has_bits)[0] |= 32u;
}
static void set_has_locus_id(HasBits* has_bits) {
(*has_bits)[0] |= 4u;
}
static void set_has_locus_id_seed(HasBits* has_bits) {
(*has_bits)[0] |= 8u;
}
static void set_has_concatenatable(HasBits* has_bits) {
(*has_bits)[0] |= 64u;
}
static const ::mediapipe::BoundingBox& bounding_box(const Locus* msg);
static void set_has_bounding_box(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
static void set_has_timestamp(HasBits* has_bits) {
(*has_bits)[0] |= 16u;
}
static const ::mediapipe::Rasterization& region(const Locus* msg);
static void set_has_region(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
};
const ::mediapipe::BoundingBox&
Locus::_Internal::bounding_box(const Locus* msg) {
return *msg->bounding_box_;
}
const ::mediapipe::Rasterization&
Locus::_Internal::region(const Locus* msg) {
return *msg->region_;
}
void Locus::clear_region() {
if (region_ != nullptr) region_->Clear();
_has_bits_[0] &= ~0x00000002u;
}
Locus::Locus()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:mediapipe.Locus)
}
Locus::Locus(const Locus& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
_has_bits_(from._has_bits_),
component_locus_(from.component_locus_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
if (from._internal_has_bounding_box()) {
bounding_box_ = new ::mediapipe::BoundingBox(*from.bounding_box_);
} else {
bounding_box_ = nullptr;
}
if (from._internal_has_region()) {
region_ = new ::mediapipe::Rasterization(*from.region_);
} else {
region_ = nullptr;
}
::memcpy(&locus_id_, &from.locus_id_,
static_cast<size_t>(reinterpret_cast<char*>(&concatenatable_) -
reinterpret_cast<char*>(&locus_id_)) + sizeof(concatenatable_));
// @@protoc_insertion_point(copy_constructor:mediapipe.Locus)
}
void Locus::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Locus_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto.base);
::memset(&bounding_box_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&locus_id_seed_) -
reinterpret_cast<char*>(&bounding_box_)) + sizeof(locus_id_seed_));
timestamp_ = -1;
locus_type_ = 1;
concatenatable_ = true;
}
Locus::~Locus() {
// @@protoc_insertion_point(destructor:mediapipe.Locus)
SharedDtor();
}
void Locus::SharedDtor() {
if (this != internal_default_instance()) delete bounding_box_;
if (this != internal_default_instance()) delete region_;
}
void Locus::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const Locus& Locus::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Locus_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto.base);
return *internal_default_instance();
}
void Locus::Clear() {
// @@protoc_insertion_point(message_clear_start:mediapipe.Locus)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
component_locus_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(bounding_box_ != nullptr);
bounding_box_->Clear();
}
if (cached_has_bits & 0x00000002u) {
GOOGLE_DCHECK(region_ != nullptr);
region_->Clear();
}
}
if (cached_has_bits & 0x0000007cu) {
::memset(&locus_id_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&locus_id_seed_) -
reinterpret_cast<char*>(&locus_id_)) + sizeof(locus_id_seed_));
timestamp_ = -1;
locus_type_ = 1;
concatenatable_ = true;
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
const char* Locus::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// optional .mediapipe.Locus.LocusType locus_type = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
if (PROTOBUF_PREDICT_TRUE(::mediapipe::Locus_LocusType_IsValid(val))) {
_internal_set_locus_type(static_cast<::mediapipe::Locus_LocusType>(val));
} else {
::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields());
}
} else goto handle_unusual;
continue;
// optional fixed64 locus_id = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 17)) {
_Internal::set_has_locus_id(&has_bits);
locus_id_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint64>(ptr);
ptr += sizeof(::PROTOBUF_NAMESPACE_ID::uint64);
} else goto handle_unusual;
continue;
// optional .mediapipe.BoundingBox bounding_box = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
ptr = ctx->ParseMessage(_internal_mutable_bounding_box(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional .mediapipe.Rasterization region = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) {
ptr = ctx->ParseMessage(_internal_mutable_region(), ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional bool concatenatable = 5 [default = true];
case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
_Internal::set_has_concatenatable(&has_bits);
concatenatable_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional fixed64 locus_id_seed = 6;
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 49)) {
_Internal::set_has_locus_id_seed(&has_bits);
locus_id_seed_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint64>(ptr);
ptr += sizeof(::PROTOBUF_NAMESPACE_ID::uint64);
} else goto handle_unusual;
continue;
// optional int32 timestamp = 7 [default = -1];
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
_Internal::set_has_timestamp(&has_bits);
timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// repeated .mediapipe.Locus component_locus = 8;
case 8:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_component_locus(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<66>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* Locus::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:mediapipe.Locus)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional .mediapipe.Locus.LocusType locus_type = 1;
if (cached_has_bits & 0x00000020u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
1, this->_internal_locus_type(), target);
}
// optional fixed64 locus_id = 2;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFixed64ToArray(2, this->_internal_locus_id(), target);
}
// optional .mediapipe.BoundingBox bounding_box = 3;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
3, _Internal::bounding_box(this), target, stream);
}
// optional .mediapipe.Rasterization region = 4;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
4, _Internal::region(this), target, stream);
}
// optional bool concatenatable = 5 [default = true];
if (cached_has_bits & 0x00000040u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_concatenatable(), target);
}
// optional fixed64 locus_id_seed = 6;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFixed64ToArray(6, this->_internal_locus_id_seed(), target);
}
// optional int32 timestamp = 7 [default = -1];
if (cached_has_bits & 0x00000010u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_timestamp(), target);
}
// repeated .mediapipe.Locus component_locus = 8;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_component_locus_size()); i < n; i++) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(8, this->_internal_component_locus(i), target, stream);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:mediapipe.Locus)
return target;
}
size_t Locus::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:mediapipe.Locus)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .mediapipe.Locus component_locus = 8;
total_size += 1UL * this->_internal_component_locus_size();
for (const auto& msg : this->component_locus_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x0000007fu) {
// optional .mediapipe.BoundingBox bounding_box = 3;
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*bounding_box_);
}
// optional .mediapipe.Rasterization region = 4;
if (cached_has_bits & 0x00000002u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
*region_);
}
// optional fixed64 locus_id = 2;
if (cached_has_bits & 0x00000004u) {
total_size += 1 + 8;
}
// optional fixed64 locus_id_seed = 6;
if (cached_has_bits & 0x00000008u) {
total_size += 1 + 8;
}
// optional int32 timestamp = 7 [default = -1];
if (cached_has_bits & 0x00000010u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
this->_internal_timestamp());
}
// optional .mediapipe.Locus.LocusType locus_type = 1;
if (cached_has_bits & 0x00000020u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_locus_type());
}
// optional bool concatenatable = 5 [default = true];
if (cached_has_bits & 0x00000040u) {
total_size += 1 + 1;
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void Locus::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:mediapipe.Locus)
GOOGLE_DCHECK_NE(&from, this);
const Locus* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Locus>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:mediapipe.Locus)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:mediapipe.Locus)
MergeFrom(*source);
}
}
void Locus::MergeFrom(const Locus& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:mediapipe.Locus)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
component_locus_.MergeFrom(from.component_locus_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x0000007fu) {
if (cached_has_bits & 0x00000001u) {
_internal_mutable_bounding_box()->::mediapipe::BoundingBox::MergeFrom(from._internal_bounding_box());
}
if (cached_has_bits & 0x00000002u) {
_internal_mutable_region()->::mediapipe::Rasterization::MergeFrom(from._internal_region());
}
if (cached_has_bits & 0x00000004u) {
locus_id_ = from.locus_id_;
}
if (cached_has_bits & 0x00000008u) {
locus_id_seed_ = from.locus_id_seed_;
}
if (cached_has_bits & 0x00000010u) {
timestamp_ = from.timestamp_;
}
if (cached_has_bits & 0x00000020u) {
locus_type_ = from.locus_type_;
}
if (cached_has_bits & 0x00000040u) {
concatenatable_ = from.concatenatable_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void Locus::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:mediapipe.Locus)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Locus::CopyFrom(const Locus& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:mediapipe.Locus)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Locus::IsInitialized() const {
if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(component_locus_)) return false;
if (_internal_has_region()) {
if (!region_->IsInitialized()) return false;
}
return true;
}
void Locus::InternalSwap(Locus* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
component_locus_.InternalSwap(&other->component_locus_);
swap(bounding_box_, other->bounding_box_);
swap(region_, other->region_);
swap(locus_id_, other->locus_id_);
swap(locus_id_seed_, other->locus_id_seed_);
swap(timestamp_, other->timestamp_);
swap(locus_type_, other->locus_type_);
swap(concatenatable_, other->concatenatable_);
}
::PROTOBUF_NAMESPACE_ID::Metadata Locus::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
void BoundingBox::InitAsDefaultInstance() {
}
class BoundingBox::_Internal {
public:
using HasBits = decltype(std::declval<BoundingBox>()._has_bits_);
static void set_has_left_x(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
static void set_has_upper_y(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
static void set_has_right_x(HasBits* has_bits) {
(*has_bits)[0] |= 4u;
}
static void set_has_lower_y(HasBits* has_bits) {
(*has_bits)[0] |= 8u;
}
};
BoundingBox::BoundingBox()
: ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:mediapipe.BoundingBox)
}
BoundingBox::BoundingBox(const BoundingBox& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_internal_metadata_(nullptr),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
::memcpy(&left_x_, &from.left_x_,
static_cast<size_t>(reinterpret_cast<char*>(&lower_y_) -
reinterpret_cast<char*>(&left_x_)) + sizeof(lower_y_));
// @@protoc_insertion_point(copy_constructor:mediapipe.BoundingBox)
}
void BoundingBox::SharedCtor() {
::memset(&left_x_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&lower_y_) -
reinterpret_cast<char*>(&left_x_)) + sizeof(lower_y_));
}
BoundingBox::~BoundingBox() {
// @@protoc_insertion_point(destructor:mediapipe.BoundingBox)
SharedDtor();
}
void BoundingBox::SharedDtor() {
}
void BoundingBox::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const BoundingBox& BoundingBox::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BoundingBox_mediapipe_2fframework_2fformats_2fannotation_2flocus_2eproto.base);
return *internal_default_instance();
}
void BoundingBox::Clear() {
// @@protoc_insertion_point(message_clear_start:mediapipe.BoundingBox)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
::memset(&left_x_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&lower_y_) -
reinterpret_cast<char*>(&left_x_)) + sizeof(lower_y_));
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
const char* BoundingBox::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// optional int32 left_x = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
_Internal::set_has_left_x(&has_bits);
left_x_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional int32 upper_y = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
_Internal::set_has_upper_y(&has_bits);
upper_y_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional int32 right_x = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
_Internal::set_has_right_x(&has_bits);
right_x_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
// optional int32 lower_y = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
_Internal::set_has_lower_y(&has_bits);
lower_y_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* BoundingBox::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:mediapipe.BoundingBox)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional int32 left_x = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_left_x(), target);
}
// optional int32 upper_y = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_upper_y(), target);
}
// optional int32 right_x = 3;
if (cached_has_bits & 0x00000004u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_right_x(), target);
}
// optional int32 lower_y = 4;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_lower_y(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:mediapipe.BoundingBox)
return target;
}
size_t BoundingBox::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:mediapipe.BoundingBox)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
// optional int32 left_x = 1;
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
this->_internal_left_x());
}
// optional int32 upper_y = 2;
if (cached_has_bits & 0x00000002u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
this->_internal_upper_y());
}
// optional int32 right_x = 3;
if (cached_has_bits & 0x00000004u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
this->_internal_right_x());
}
// optional int32 lower_y = 4;
if (cached_has_bits & 0x00000008u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
this->_internal_lower_y());
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void BoundingBox::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:mediapipe.BoundingBox)
GOOGLE_DCHECK_NE(&from, this);
const BoundingBox* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<BoundingBox>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:mediapipe.BoundingBox)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:mediapipe.BoundingBox)
MergeFrom(*source);
}
}
void BoundingBox::MergeFrom(const BoundingBox& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:mediapipe.BoundingBox)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) {
left_x_ = from.left_x_;
}
if (cached_has_bits & 0x00000002u) {
upper_y_ = from.upper_y_;
}
if (cached_has_bits & 0x00000004u) {
right_x_ = from.right_x_;
}
if (cached_has_bits & 0x00000008u) {
lower_y_ = from.lower_y_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void BoundingBox::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:mediapipe.BoundingBox)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void BoundingBox::CopyFrom(const BoundingBox& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:mediapipe.BoundingBox)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool BoundingBox::IsInitialized() const {
return true;
}
void BoundingBox::InternalSwap(BoundingBox* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
swap(left_x_, other->left_x_);
swap(upper_y_, other->upper_y_);
swap(right_x_, other->right_x_);
swap(lower_y_, other->lower_y_);
}
::PROTOBUF_NAMESPACE_ID::Metadata BoundingBox::GetMetadata() const {
return GetMetadataStatic();
}
// @@protoc_insertion_point(namespace_scope)
} // namespace mediapipe
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::mediapipe::Locus* Arena::CreateMaybeMessage< ::mediapipe::Locus >(Arena* arena) {
return Arena::CreateInternal< ::mediapipe::Locus >(arena);
}
template<> PROTOBUF_NOINLINE ::mediapipe::BoundingBox* Arena::CreateMaybeMessage< ::mediapipe::BoundingBox >(Arena* arena) {
return Arena::CreateInternal< ::mediapipe::BoundingBox >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 39.382415 | 269 | 0.731716 | sixtolink |
e719bb765839ae88fa78f5ef6ac8d4c27406c9d0 | 667 | cpp | C++ | Train/summer 2017/CF_contest/431-440/435/A.cpp | mohamedGamalAbuGalala/Practice | 2a5fa3bdaf995d0c304f04231e1a69e6960f72c8 | [
"MIT"
] | 1 | 2019-12-19T06:51:20.000Z | 2019-12-19T06:51:20.000Z | Train/summer 2017/CF_contest/431-440/435/A.cpp | mohamedGamalAbuGalala/Practice | 2a5fa3bdaf995d0c304f04231e1a69e6960f72c8 | [
"MIT"
] | null | null | null | Train/summer 2017/CF_contest/431-440/435/A.cpp | mohamedGamalAbuGalala/Practice | 2a5fa3bdaf995d0c304f04231e1a69e6960f72c8 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
void fl() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
// freopen("ot.txt", "w", stdout);
#else
// freopen("jumping.in", "r", stdin); // HERE
#endif
}
////////////////////////////////////////////////////////////////////////////////////////////////
// snippet :: dinp , dhelp , dvec , lli , dfor , dcons , dbit
#define forr(i,j, n) for(int i = j;i < n;i++)
int main() { // dfil
fl(); //TODO
int n, x, a[111], ans = 0;
cin >> n >> x;
forr(i, 0, n and cin>>(a[i]));
sort(a, a + n);
int ii = 0;
forr(i,0,x)
if (a[ii] != i)
ans++;
else
ii++;
if (a[ii] == x)
ans++;
cout << ans;
return 0;
}
| 20.212121 | 96 | 0.445277 | mohamedGamalAbuGalala |
e71d536120d59ca8fed5334be4cbe3136f791f14 | 4,769 | cpp | C++ | examples/quick/main.cpp | dark-richie/framelesshelper | bca1a0d91bbbe5f2898f01a2a7b1ac6ec0f419f9 | [
"MIT"
] | 2 | 2020-02-19T14:24:01.000Z | 2020-04-20T12:08:36.000Z | examples/quick/main.cpp | jaredtao/framelesshelper | 3b171b3ea9e0723e642653d8fb6a012fd1c036d7 | [
"MIT"
] | null | null | null | examples/quick/main.cpp | jaredtao/framelesshelper | 3b171b3ea9e0723e642653d8fb6a012fd1c036d7 | [
"MIT"
] | 1 | 2019-12-05T19:58:15.000Z | 2019-12-05T19:58:15.000Z | /*
* MIT License
*
* Copyright (C) 2021 by wangwenx190 (Yuhang Zhao)
*
* 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 "../../utilities.h"
#include "../../framelessquickhelper.h"
#include <QtGui/qguiapplication.h>
#include <QtQml/qqmlapplicationengine.h>
#include <QtQuickControls2/qquickstyle.h>
FRAMELESSHELPER_USE_NAMESPACE
static constexpr const char qtquicknamespace[] = "wangwenx190.Utils";
class UtilFunctions : public QObject
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(UtilFunctions)
Q_PROPERTY(bool isWindowsHost READ isWindowsHost CONSTANT)
Q_PROPERTY(bool isWindows10OrGreater READ isWindows10OrGreater CONSTANT)
Q_PROPERTY(bool isWindows11OrGreater READ isWindows11OrGreater CONSTANT)
Q_PROPERTY(QColor activeFrameBorderColor READ activeFrameBorderColor CONSTANT)
Q_PROPERTY(QColor inactiveFrameBorderColor READ inactiveFrameBorderColor CONSTANT)
Q_PROPERTY(qreal frameBorderThickness READ frameBorderThickness CONSTANT)
public:
explicit UtilFunctions(QObject *parent = nullptr) : QObject(parent) {}
~UtilFunctions() override = default;
inline bool isWindowsHost() const {
#ifdef Q_OS_WINDOWS
return true;
#else
return false;
#endif
}
inline bool isWindows10OrGreater() const {
#ifdef Q_OS_WINDOWS
return Utilities::isWin10OrGreater();
#else
return false;
#endif
}
inline bool isWindows11OrGreater() const {
#ifdef Q_OS_WINDOWS
return Utilities::isWin11OrGreater();
#else
return false;
#endif
}
inline QColor activeFrameBorderColor() const {
const ColorizationArea area = Utilities::getColorizationArea();
const bool colorizedBorder = ((area == ColorizationArea::TitleBar_WindowBorder)
|| (area == ColorizationArea::All));
return (colorizedBorder ? Utilities::getColorizationColor() : Qt::black);
}
inline QColor inactiveFrameBorderColor() const {
return Qt::darkGray;
}
inline qreal frameBorderThickness() const {
return 1.0;
}
};
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
#endif
QGuiApplication application(argc, argv);
QQmlApplicationEngine engine;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QQuickStyle::setStyle(QStringLiteral("Basic"));
#else
QQuickStyle::setStyle(QStringLiteral("Default"));
#endif
qmlRegisterSingletonType<UtilFunctions>(qtquicknamespace, 1, 0, "Utils", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);
return new UtilFunctions();
});
qmlRegisterType<FramelessQuickHelper>(qtquicknamespace, 1, 0, "FramelessHelper");
const QUrl mainQmlUrl(QStringLiteral("qrc:///qml/main.qml"));
const QMetaObject::Connection connection = QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreated,
&application,
[&mainQmlUrl, &connection](QObject *object, const QUrl &url) {
if (url != mainQmlUrl) {
return;
}
if (!object) {
QGuiApplication::exit(-1);
} else {
QObject::disconnect(connection);
}
},
Qt::QueuedConnection);
engine.load(mainQmlUrl);
return QGuiApplication::exec();
}
#include "main.moc"
| 33.822695 | 139 | 0.708954 | dark-richie |
e724697aef5050e03fd92a44ad8a5aaa0229846d | 725 | cpp | C++ | FastMath/fast_math.cpp | JiuKim04/J-Drive | 3e0e86854800e6be5d03ae57ddb102deff5fed31 | [
"MIT"
] | 9 | 2020-08-25T10:57:57.000Z | 2021-09-03T13:07:57.000Z | FastMath/fast_math.cpp | jwkim04/J-Drive | d0f84098e73e7f731cb00cbc4d384b8ab88578d9 | [
"MIT"
] | null | null | null | FastMath/fast_math.cpp | jwkim04/J-Drive | d0f84098e73e7f731cb00cbc4d384b8ab88578d9 | [
"MIT"
] | 8 | 2020-08-29T07:26:27.000Z | 2021-09-08T22:22:28.000Z | #include "fast_math.hpp"
#include <cstdint>
float sineTable[FAST_MATH_TABLE_SIZE];
void FastMathInit()
{
double x = 0.0f;
for (uint32_t i = 0; i < FAST_MATH_TABLE_SIZE; i++)
{
sineTable[i] = (float) sin(x);
x += (M_PI * 2.0) / (double) FAST_MATH_TABLE_SIZE;
}
}
float FastSin(float x)
{
x -= (float) (M_PI * 2.0) * (float) ((int32_t) (x / (float) (M_PI * 2.0)));
uint32_t idx = (uint32_t) (x * ((double) FAST_MATH_TABLE_SIZE / (M_PI * 2.0)));
return sineTable[idx];
}
float FastCos(float x)
{
x += (float) M_PI / 2.0f;
x -= (float) (M_PI * 2.0) * (float) ((int32_t) (x / (float) (M_PI * 2.0)));
uint32_t idx = (uint32_t) (x * ((double) FAST_MATH_TABLE_SIZE / (M_PI * 2.0)));
return sineTable[idx];
}
| 20.138889 | 80 | 0.608276 | JiuKim04 |
e7283c21381007a77d375069d886b7b2496ecac0 | 4,474 | cpp | C++ | cpp/src/playout-impl.cpp | peurpdapeurp/ndnrtc | 59552bff9398ee2e49636f32cac020cc8027ae04 | [
"BSD-2-Clause"
] | null | null | null | cpp/src/playout-impl.cpp | peurpdapeurp/ndnrtc | 59552bff9398ee2e49636f32cac020cc8027ae04 | [
"BSD-2-Clause"
] | null | null | null | cpp/src/playout-impl.cpp | peurpdapeurp/ndnrtc | 59552bff9398ee2e49636f32cac020cc8027ae04 | [
"BSD-2-Clause"
] | null | null | null | //
// playout-impl.cpp
//
// Created by Peter Gusev on 03 August 2016.
// Copyright 2013-2016 Regents of the University of California
//
#include "playout-impl.hpp"
#include "playout.hpp"
#include "jitter-timing.hpp"
#include "simple-log.hpp"
#include "frame-buffer.hpp"
#include "frame-data.hpp"
#include "clock.hpp"
using namespace ndnrtc;
using namespace std;
using namespace ndnrtc::statistics;
PlayoutImpl::PlayoutImpl(boost::asio::io_service& io,
const std::shared_ptr<IPlaybackQueue>& queue,
const std::shared_ptr<statistics::StatisticsStorage> statStorage):
isRunning_(false),
jitterTiming_(io),
pqueue_(queue),
StatObject(statStorage),
lastTimestamp_(-1),
lastDelay_(-1),
delayAdjustment_(0)
{
setDescription("playout");
}
PlayoutImpl::~PlayoutImpl()
{
if (isRunning_)
stop();
}
void
PlayoutImpl::start(unsigned int fastForwardMs)
{
if (isRunning_)
throw std::runtime_error("Playout has started already");
jitterTiming_.flush();
lastTimestamp_ = -1;
lastDelay_ = -1;
delayAdjustment_ = -(int)fastForwardMs;
isRunning_ = true;
LogInfoC << "started (ffwd ‣‣" << fastForwardMs << "ms)" << std::endl;
extractSample();
}
void
PlayoutImpl::stop()
{
if (isRunning_)
{
isRunning_ = false;
jitterTiming_.stop();
LogInfoC << "stopped" << std::endl;
}
}
void
PlayoutImpl::setLogger(std::shared_ptr<ndnlog::new_api::Logger> logger)
{
ILoggingObject::setLogger(logger);
jitterTiming_.setLogger(logger);
}
void
PlayoutImpl::setDescription(const std::string &desc)
{
ILoggingObject::setDescription(desc);
jitterTiming_.setDescription(getDescription()+"-timing");
}
void
PlayoutImpl::attach(IPlayoutObserver* o)
{
if (o)
{
boost::lock_guard<boost::recursive_mutex> scopedLock(mutex_);
observers_.push_back(o);
}
}
void
PlayoutImpl::detach(IPlayoutObserver* o)
{
boost::lock_guard<boost::recursive_mutex> scopedLock(mutex_);
observers_.erase(std::find(observers_.begin(), observers_.end(), o));
}
#pragma mark - private
void PlayoutImpl::extractSample()
{
if (!isRunning_) return;
stringstream debugStr;
int64_t sampleDelay = (int64_t)round(pqueue_->samplePeriod());
bool validForPlayback = false;
jitterTiming_.startFramePlayout();
if (pqueue_->size())
{
pqueue_->pop([this, &sampleDelay, &debugStr, &validForPlayback](const std::shared_ptr<const BufferSlot>& slot, double playTimeMs){
validForPlayback = processSample(slot);
correctAdjustment(slot->getHeader().publishTimestampMs_);
lastTimestamp_ = slot->getHeader().publishTimestampMs_;
sampleDelay = playTimeMs;
debugStr << slot->dump();
(*statStorage_)[Indicator::LatencyEstimated] = (clock::unixTimestamp() - slot->getHeader().publishUnixTimestamp_);
});
LogTraceC << ". packet delay " << sampleDelay << " ts " << lastTimestamp_ << std::endl;
}
else
{
lastTimestamp_ += sampleDelay;
LogWarnC << "playback queue is empty" << std::endl;
{
boost::lock_guard<boost::recursive_mutex> scopedLock(mutex_);
for (auto o:observers_) o->onQueueEmpty();
}
}
lastDelay_ = sampleDelay;
int64_t actualDelay = adjustDelay(sampleDelay);
if (validForPlayback)
LogDebugC << "●-- play frame " << debugStr.str() << actualDelay << "ms" << std::endl;
std::shared_ptr<PlayoutImpl> me = std::dynamic_pointer_cast<PlayoutImpl>(shared_from_this());
jitterTiming_.updatePlayoutTime(actualDelay);
jitterTiming_.run(std::bind(&PlayoutImpl::extractSample, me));
}
void PlayoutImpl::correctAdjustment(int64_t newSampleTimestamp)
{
if (lastDelay_ >= 0)
{
int64_t prevDelay = newSampleTimestamp-lastTimestamp_;
LogTraceC << ". prev delay hard " << prevDelay
<< " offset " << prevDelay - lastDelay_ << std::endl;
delayAdjustment_ += (prevDelay - lastDelay_);
}
}
int64_t PlayoutImpl::adjustDelay(int64_t delay)
{
int64_t adj = 0;
if (delayAdjustment_ < 0 &&
abs(delayAdjustment_) > delay)
{
delayAdjustment_ += delay;
adj = -delay;
}
else
{
adj = delayAdjustment_;
delayAdjustment_ = 0;
}
LogTraceC << ". total adj " << delayAdjustment_ << " delay "
<< (delay+adj) << std::endl;
return (delay+adj);
}
| 25.276836 | 138 | 0.653554 | peurpdapeurp |
e7331ce00d32c758c39c4de961a980cef31fcd58 | 6,595 | cpp | C++ | IM Porject/IM/imdal.cpp | jie65535/IM | a85f497bbe467b8fdc9cb2b18175f397768ae653 | [
"MIT"
] | 1 | 2021-08-24T12:36:48.000Z | 2021-08-24T12:36:48.000Z | IM Porject/IM/imdal.cpp | jie65535/IM | a85f497bbe467b8fdc9cb2b18175f397768ae653 | [
"MIT"
] | 1 | 2021-03-11T19:38:32.000Z | 2021-03-15T15:40:16.000Z | IM Porject/IM/imdal.cpp | jie65535/IM | a85f497bbe467b8fdc9cb2b18175f397768ae653 | [
"MIT"
] | null | null | null | #include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QVector>
#include <QString>
#include <QDebug>
#include "imdal.h"
#include "immessage.h"
IMDAL *IMDAL::instance()
{
static IMDAL imDAL;
return &imDAL;
}
void IMDAL::initDatabase(QString name)
{
//打印Qt支持的数据库驱动
qDebug()<<QSqlDatabase::drivers();
QSqlDatabase database;
// 检测默认连接是否已经存在
if (QSqlDatabase::contains(QSqlDatabase::defaultConnection))
{
// 存在就直接用
database = QSqlDatabase::database(QSqlDatabase::defaultConnection);
}
else
{
// 不存在就添加一个数据库驱动引擎SQLite
database = QSqlDatabase::addDatabase("QSQLITE");
// 然后打开指定用户的数据库文件
database.setDatabaseName(QString("./msgsave_%1.db").arg(name));
// database.setUserName("root");
// database.setPassword("123456");
}
//打开数据库
if(!database.open())
{
// 如果打开失败 退出程序
qDebug()<<database.lastError();
qFatal("failed to connect.");
}
else
{
qDebug() << "Open database success!";
QStringList tables = database.tables(); //获取数据库中的表
qDebug() << QString("表的个数: %1").arg(tables.count()); //打印表的个数
// 如果表的数量小于3,说明这是一个新用户登录
if (tables.count() < 3)
{
/*
SQL语句:
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR NOT NULL
UNIQUE
);
INSERT INTO user (
name
)
VALUES (
'xxx'
);
CREATE TABLE message (
id INTEGER PRIMARY KEY AUTOINCREMENT,
fromID INTEGER NOT NULL
REFERENCES user ( id ) ON DELETE CASCADE
ON UPDATE CASCADE,
content TEXT NOT NULL,
time DATETIME NOT NULL
DEFAULT ( datetime( 'now', 'localtime' ) ),
io CHAR NOT NULL
);
io这个字段代表是发送还是接受:i收到消息 o发出消息 g群聊消息
*/
database.transaction();
QSqlQuery query;
// 创建表并将用户昵称插入表中作为第一条数据存在,id为1
query.exec("CREATE TABLE user ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name VARCHAR NOT NULL UNIQUE);");
query.exec(QString("INSERT INTO user(name) values('%1');").arg(name));
query.exec("CREATE TABLE message ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"fromID INTEGER NOT NULL REFERENCES user(id) ON DELETE CASCADE ON UPDATE CASCADE,"
"content TEXT NOT NULL,"
"time DATETIME NOT NULL DEFAULT(datetime('now','localtime')),"
"io CHAR NOT NULL);");
if (!database.commit())
qDebug()<<database.lastError();
}
}
}
void IMDAL::addPrivateMessage(QString name, IMMessage msg)
{
if (!QSqlDatabase::database().isOpen())
return;
// 获得用户ID
int userID = getUserID(name);
if (userID == 0)
return;
// 插入这条私聊消息
QSqlQuery query;
query.prepare("INSERT INTO message(fromID, content, time, io) "
"VALUES(?, ?, ?, ?)");
query.addBindValue(userID);
query.addBindValue(msg.content);
query.addBindValue(msg.time);
query.addBindValue(msg.fromName);
if (!query.exec())
qDebug()<<query.lastError();
}
void IMDAL::addGroupMessage(IMMessage msg)
{
if (!QSqlDatabase::database().isOpen())
return;
// 获取用户ID
int userID = getUserID(msg.fromName);
if (userID == 0)
return;
// 插入这条群聊消息
QSqlQuery query;
query.prepare("INSERT INTO message(fromID, content, time, io) "
"VALUES(?, ?, ?, 'g')");
query.addBindValue(userID);
query.addBindValue(msg.content);
query.addBindValue(msg.time);
if (!query.exec())
qDebug()<<query.lastError();
}
QVector<IMMessage> IMDAL::getPrivateMessage(QString name)
{
QVector<IMMessage> msgList;
int userID = 0;
if (!QSqlDatabase::database().isOpen())
return msgList;
QSqlQuery query;
query.prepare("SELECT id FROM user WHERE name = ?");
query.addBindValue(name);
if(!query.exec())
{
qDebug()<<query.lastError();
return msgList;
}
// 获取这个昵称的id
while(query.next())
userID = query.value(0).toInt();
// 如果没有这个人的记录,直接返回空
if (userID == 0)
return msgList;
// 否则查找这个用户的消息
query.prepare("SELECT io, content, time FROM message WHERE fromID = ? AND io != 'g'");
query.addBindValue(userID);
if(!query.exec())
{
qDebug()<<query.lastError();
return msgList;
}
// 将所有消息添加到列表中
while(query.next())
msgList.append(IMMessage(query.value(0).toString(), query.value(1).toString(), query.value(2).toDateTime()));
return msgList;
}
QVector<IMMessage> IMDAL::getGroupMessage()
{
QVector<IMMessage> msgList;
if (!QSqlDatabase::database().isOpen())
return msgList;
QSqlQuery query;
if(!query.exec("SELECT name, content, time FROM message,user WHERE io == 'g' AND user.id = fromID"))
{
qDebug()<<query.lastError();
return msgList;
}
// 将所有消息添加到列表中
while(query.next())
msgList.append(IMMessage(query.value(0).toString(), query.value(1).toString(), query.value(2).toDateTime()));
return msgList;
}
QVector<QString> IMDAL::getUserList()
{
qDebug() << "getUserList()";
QVector<QString> names;
if (!QSqlDatabase::database().isOpen())
return names;
QSqlQuery query;
if (!query.exec("SELECT name FROM user"))
{
qDebug()<<query.lastError();
}
else
{
while (query.next())
names.append(query.value(0).toString());
}
qDebug() << names;
return names;
}
int IMDAL::getUserID(QString name)
{
QSqlQuery query;
int userID = 0;
query.prepare("SELECT id FROM user WHERE name = ?");
query.addBindValue(name);
if(!query.exec())
{
qDebug()<<query.lastError();
return 0;
}
// 获取这个昵称的id
while(query.next())
userID = query.value(0).toInt();
if (userID)
return userID;
// 如果没有这个人的记录,那么就创建这个人的ID
query.prepare("INSERT INTO user(name) VALUES(?)");
query.addBindValue(name);
if(!query.exec())
{
qDebug()<<query.lastError();
return 0;
}
return query.lastInsertId().toInt();
}
| 27.252066 | 118 | 0.556027 | jie65535 |
e73adc48e5902be43ca1dc63ec53fc5d81e5a549 | 21,005 | ipp | C++ | esp/logging/logginglib/modularlogagent.ipp | jeclrsg/HPCC-Platform | c1daafb6060f0c47c95bce98e5431fedc33c592d | [
"Apache-2.0"
] | 286 | 2015-01-03T12:45:17.000Z | 2022-03-25T18:12:57.000Z | esp/logging/logginglib/modularlogagent.ipp | jeclrsg/HPCC-Platform | c1daafb6060f0c47c95bce98e5431fedc33c592d | [
"Apache-2.0"
] | 9,034 | 2015-01-02T08:49:19.000Z | 2022-03-31T20:34:44.000Z | esp/logging/logginglib/modularlogagent.ipp | jeclrsg/HPCC-Platform | c1daafb6060f0c47c95bce98e5431fedc33c592d | [
"Apache-2.0"
] | 208 | 2015-01-02T03:27:28.000Z | 2022-02-11T05:54:52.000Z | /*##############################################################################
HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
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 _MODULARLOGAGENT_IPP_
#define _MODULARLOGAGENT_IPP_
#include "modularlogagent.hpp"
#include "tokenserialization.hpp"
#include "xpathprocessor.hpp"
namespace ModularLogAgent
{
class LOGGINGCOMMON_API CModule
{
public:
constexpr static const char* propDisabled = "@disabled";
constexpr static const char* propName = "@name";
constexpr static const char* propTracePriorityLimit = "@trace-priority-limit";
public:
virtual LogMsgDetail tracePriorityLimit(const LogMsgCategory& category) const;
virtual const char* traceId() const;
virtual void traceOutput(const LogMsgCategory& category, const char* format, va_list& arguments) const __attribute__((format(printf, 3, 0)));;
virtual bool configure(const IPTree& configuration, const CModuleFactory& factory);
virtual bool isEnabled() const;
virtual StringBuffer& toString(StringBuffer& str) const;
protected:
mutable ReadWriteLock m_rwLock;
private:
template <typename container_t> friend class TModule;
const ITraceLoggingComponent* m_self = nullptr;
StringBuffer m_traceId;
bool m_disabled = false;
bool m_inheritTracePriorityLimit = true;
LogMsgDetail m_tracePriorityLimit = TraceLoggingPriority::Major;
protected:
virtual bool appendProperties(StringBuffer& str) const;
template <typename value_t>
bool extract(const char* xpath, const IPTree& configuration, value_t& value, bool optional = true)
{
const char* property = configuration.queryProp(xpath);
if (isEmptyString(property) && !optional)
{
if (m_self)
m_self->uerrlog(TraceLoggingPriority::Major, "missing required configuration property '%s'", xpath);
return false;
}
DeserializationResult dr = TokenDeserializer().deserialize(property, value);
switch (dr)
{
case Deserialization_SUCCESS:
return true;
default:
return false;
}
}
};
template <typename container_t>
class TModule : extends CModule
{
public:
virtual bool configure(const IPTree& configuration, const CModuleFactory& factory) override
{
const char* containerPrefix = m_container.traceId();
if (!isEmptyString(containerPrefix))
m_traceId.setf("%s.", containerPrefix);
return CModule::configure(configuration, factory);
}
virtual LogMsgDetail tracePriorityLimit(const LogMsgCategory& category) const override
{
return (m_inheritTracePriorityLimit ? m_container.tracePriorityLimit(category) : CModule::tracePriorityLimit(category));
}
protected:
using Container = container_t;
const Container& m_container;
public:
TModule(const Container& container) : m_container(container) {}
protected:
const Container& queryContainer() const { return m_container; }
/**
* Provides for the creation and initialization of a delegate module. Delegates are not, by
* default, required to be configured. An optional delegate omitted from the configuration
* is acceptable, but the existence of a delegate configuration requires the configuration
* to be valid even when the delegate is optional.
*/
template <typename child_t, typename registrants_t, typename parent_t>
bool createAndConfigure(const IPTree& configuration, const char* xpath, const CModuleFactory& factory, const registrants_t& registrants, Owned<child_t>& child, const parent_t& parent, bool optional = true) const
{
const IPTree* node = configuration.queryBranch(xpath);
if (!node)
{
if (optional)
{
return true;
}
else
{
if (m_self)
m_self->uerrlog(TraceLoggingPriority::Major, "required configuration node '%s' not found", xpath);
}
}
else
{
return createAndConfigure(*node, factory, registrants, child, parent);
}
return false;
}
template <typename child_t, typename registrants_t, typename parent_t>
bool createAndConfigure(const IPTree& node, const CModuleFactory& factory, const registrants_t& registrants, Owned<child_t>& child, const parent_t& parent) const
{
if (!registrants.create(child, &node, parent))
{
// create() has already reported the failure
}
else if (!child)
{
// should never happen, but just in case...
if (m_self)
m_self->ierrlog(TraceLoggingPriority::Major, "factory creation of '%s' reported success but created no instance", node.queryName());
}
else if (!child->configure(node, factory))
{
// configure() has already reported the failure
child.clear();
}
else
{
return true;
}
return false;
}
};
class LOGGINGCOMMON_API CMockAgent : extends CSimpleInterfaceOf<IAgent>, extends TModule<CEspLogAgent>
{
public:
using Base = TModule<CEspLogAgent>;
IMPLEMENT_ITRACELOGGINGCOMPONENT_WITH(Base);
virtual bool configure(const IPTree& configuration, const CModuleFactory& factory) override;
virtual bool isEnabled() const override { return true; }
virtual StringBuffer& toString(StringBuffer& str) const override { return Base::toString(str); }
virtual bool getTransactionSeed(IEspGetTransactionSeedRequest& request, IEspGetTransactionSeedResponse& response) override;
virtual void getTransactionID(StringAttrMapping* fields, StringBuffer& id) override;
virtual void updateLog(IEspUpdateLogRequestWrap& request, IEspUpdateLogResponse& response) override;
virtual bool hasService(LOGServiceType type) const override;
protected:
Owned<IEspGetTransactionSeedResponse> m_gtsResponse;
Owned<String> m_gtiResponse;
Owned<IEspUpdateLogResponse> m_ulResponse;
public:
using Base::Base;
};
class LOGGINGCOMMON_API CDelegatingAgent : extends CSimpleInterfaceOf<IDelegatingAgent>, extends TModule<CEspLogAgent>
{
public:
constexpr static const char* moduleUpdateLog = "UpdateLog";
constexpr static const char* propUpdateLog = "@UpdateLog";
public:
using Base = TModule<CEspLogAgent>;
IMPLEMENT_ITRACELOGGINGCOMPONENT_WITH(Base);
virtual bool configure(const IPTree& configuration, const CModuleFactory& factory) override;
virtual bool isEnabled() const override { return true; }
virtual StringBuffer& toString(StringBuffer& str) const override { return Base::toString(str); }
virtual bool getTransactionSeed(IEspGetTransactionSeedRequest& request, IEspGetTransactionSeedResponse& response) override;
virtual void getTransactionID(StringAttrMapping* fields, StringBuffer& id) override;
virtual void updateLog(IEspUpdateLogRequestWrap& request, IEspUpdateLogResponse& response) override;
virtual bool hasService(LOGServiceType type) const override;
virtual IUpdateLog* queryUpdateLog() const override { return m_updateLog; }
protected:
virtual bool configureUpdateLog(const IPTree& configuration, const CModuleFactory& factory);
virtual bool appendProperties(StringBuffer& str) const override;
protected:
friend class CService;
Owned<IUpdateLog> m_updateLog;
public:
using Base::Base;
};
using CServiceDelegate = TModule<IDelegatingAgent>;
class LOGGINGCOMMON_API CDelegatingUpdateLog : extends CSimpleInterfaceOf<IDelegatingUpdateLog>, extends CServiceDelegate
{
public:
constexpr static const char* moduleTarget = "Target";
public:
using Base = CServiceDelegate;
IMPLEMENT_ITRACELOGGINGCOMPONENT_WITH(Base);
virtual bool configure(const IPTree& configuration, const CModuleFactory& factory) override;
virtual bool isEnabled() const override { return Base::isEnabled(); }
virtual StringBuffer& toString(StringBuffer& str) const override { return Base::toString(str); }
virtual void updateLog(const char* updateLogRequest, IEspUpdateLogResponse& response) override;
protected:
virtual bool appendProperties(StringBuffer& str) const override;
protected:
Owned<IContentTarget> m_target;
public:
using Base::Base;
};
using CUpdateLogDelegate = TModule<IDelegatingUpdateLog>;
class LOGGINGCOMMON_API CContentTarget : extends CSimpleInterfaceOf<IContentTarget>, extends CUpdateLogDelegate
{
public:
using Base = CUpdateLogDelegate;
IMPLEMENT_ITRACELOGGINGCOMPONENT_WITH(Base);
virtual bool configure(const IPTree& configuration, const CModuleFactory& factory) override { return Base::configure(configuration, factory); }
virtual bool isEnabled() const override { return Base::isEnabled(); }
virtual StringBuffer& toString(StringBuffer& str) const override { return Base::toString(str); }
virtual void updateTarget(IEsdlScriptContext& scriptContext, IXpathContext& originalContent, IXpathContext* intermediateContent, const char* finalContent, IEspUpdateLogResponse& response) const override;
public:
using Base::Base;
};
/**
* Concrete implementation of IContentTarget used to write text content to a file.
*
* By default, the third content form is written when not empty. The first content form is used
* in this case to identify variable values that may be used to to construct a target filepath.
* Enabling the optional debug mode writes all provided content forms to the file.
*
* The majority of file management code focuses on variable substitution. With XPath evaulation
* readily available, it's natural to question why it isn't being used.
*
* Variable substitution in this module is a two step process. All variables except the creation
* timestamp are substituted in step one. This yields a key pattern used to identify an already
* open file that can accept the transaction data. If a new file is needed, the creation time-
* stamp is substituted in the key pattern to yield a new filepath. XPath evaluation expects to
* replace all values at once.
*
* Most variables are simple name-value substitutions, which XPath evaluation handles well. The
* creation timestamp, however, is more complex. And it is more complex to satisfy internal
* business requirements.
*/
class LOGGINGCOMMON_API CFileTarget : public CContentTarget
{
public:
using Variables = std::map<std::string, std::string>;
class Pattern : public CInterface
{
private:
interface IFragment : extends IInterface
{
virtual bool matches(const char* name, const char* option) const = 0;
virtual bool resolvedBy(const Variables& variables) const = 0;
virtual StringBuffer& toString(StringBuffer& pattern, const Variables* variables) const = 0;
virtual IFragment* clone(const Pattern& pattern) const = 0;
};
struct Fragment : extends CSimpleInterfaceOf<IFragment>
{
protected:
const Pattern& m_pattern;
Fragment(const Pattern& pattern) : m_pattern(pattern) {};
};
struct TextFragment : extends Fragment
{
size32_t startOffset = 0;
size32_t endOffset = 0;
bool matches(const char* name, const char* option) const override { return false; }
bool resolvedBy(const Variables& variables) const override { return startOffset < endOffset; }
StringBuffer& toString(StringBuffer& pattern, const Variables* variables) const override { return pattern.append(endOffset - startOffset, m_pattern.m_textCache.str() + startOffset); }
TextFragment* clone(const Pattern& pattern) const override { return nullptr; }
TextFragment(const Pattern& pattern) : Fragment(pattern) {};
};
struct VariableFragment : extends Fragment
{
std::string m_name;
std::string m_option;
bool m_withOption = false;
bool matches(const char* name, const char* option) const override;
bool resolvedBy(const Variables& variables) const override;
StringBuffer& toString(StringBuffer& pattern, const Variables* variables) const override;
VariableFragment* clone(const Pattern& pattern) const override;
VariableFragment(const Pattern& pattern) : Fragment(pattern) {}
};
using Fragments = std::vector<Owned<IFragment> >;
const CFileTarget& m_target;
StringBuffer m_textCache;
Fragments m_fragments;
public:
Pattern(const CFileTarget& target) : m_target(target) {}
bool contains(const char* name, const char* option) const;
void appendText(const char* begin, const char* end);
bool setPattern(const char* pattern);
Pattern* resolve(const Variables& variables) const;
StringBuffer& toString(StringBuffer& output, const Variables* variables) const;
inline StringBuffer& toString(StringBuffer& output) const { return toString(output, nullptr); }
};
protected:
enum RolloverInterval
{
NoRollover,
DailyRollover,
UnknownRollover,
};
/**
* Definition of an output file's data.
*/
struct File : public CInterface
{
CDateTime m_lastWrite; // time of last write to file
StringBuffer m_filePath; // full path to file
Owned<IFileIO> m_io; // open file IO instance, ovtained from an untracked IFile
};
constexpr static const char* xpathHeader = "@header-text";
constexpr static const char* xpathCreationDateFormat = "@format-creation-date";
constexpr static const char* defaultCreationDateFormat = "%Y_%m_%d";
constexpr static const char* xpathCreationTimeFormat = "@format-creation-time";
constexpr static const char* defaultCreationTimeFormat = "%H_%M_%S";
constexpr static const char* xpathCreationDateTimeFormat = "@format-creation-datetime";
constexpr static const char* defaultCreationDateTimeFormat = "%Y_%m_%d_%H_%M_%S";
constexpr static const char* xpathRolloverInterval = "@rollover-interval";
constexpr static const char* rolloverInterval_None = "none";
constexpr static const char* rolloverInterval_Daily = "daily";
constexpr static const char* defaultRolloverInterval = rolloverInterval_Daily;
constexpr static const char* xpathRolloverSize = "@rollover-size";
constexpr static const char* rolloverSize_None = "0";
constexpr static const char* defaultRolloverSize = rolloverSize_None;
constexpr static const char* xpathConcurrentFiles = "@concurrent-files";
constexpr static const char* concurrentFiles_None = "1";
constexpr static const char* defaultConcurrentFiles = concurrentFiles_None;
constexpr static const char* xpathFilePathPattern = "@filepath";
constexpr static const char* xpathDebug = "@debug";
/**
* File creation timestamp tokens. The variable name is defined by creationVarName. The format
* string is defined, either directly or indirectly, by options:
* - creationVarDateOption: use m_creationDateFormat
* - creationVarTimeOption: use m_creationTimeFormat
* - creationVarDateTimeOption: use m_creationDateTimeFormat
* - creationVarCustomOption: use the variable value as a format string
* - any other value: use the option text as a format string
*/
constexpr static const char* creationVarName = "creation";
constexpr static const char* creationVarDateOption = "date";
constexpr static const char* creationVarTimeOption = "time";
constexpr static const char* creationVarDateTimeOption = "datetime";
constexpr static const char* creationVarCustomOption = "custom";
constexpr static const char* creationVarDefaultOption = creationVarDateTimeOption;
constexpr static const char* bindingVarName = "binding";
constexpr static const char* processVarName = "process";
constexpr static const char* portVarName = "port";
constexpr static const char* esdlServiceVarName = "esdl-service";
constexpr static const char* esdlMethodVarName = "esdl-method";
constexpr static const char* serviceVarName = "service";
public:
virtual bool configure(const IPTree& configuration, const CModuleFactory& factory) override;
virtual void updateTarget(IEsdlScriptContext& scriptContext, IXpathContext& originalContent, IXpathContext* intermediateContent, const char* finalContent, IEspUpdateLogResponse& response) const override;
protected:
virtual bool appendProperties(StringBuffer& str) const override;
protected:
using TargetMap = std::map<std::string, Owned<File> >;
Owned<Pattern> m_pattern;
StringBuffer m_header;
RolloverInterval m_rolloverInterval = DailyRollover;
offset_t m_rolloverSize = 0;
StringBuffer m_creationDateFormat;
StringBuffer m_creationTimeFormat;
StringBuffer m_creationDateTimeFormat;
uint8_t m_concurrentFiles = 1;
bool m_debugMode = false;
mutable TargetMap m_targets;
public:
using CContentTarget::CContentTarget;
protected:
virtual bool configureHeader(const IPTree& configuration);
virtual bool configureCreationFormat(const IPTree& configuration, const char* xpath, const char* defaultValue, bool checkDate, bool checkTime, StringBuffer& format);
virtual bool configureFileHandling(const IPTree& configuration);
virtual bool configurePattern(const IPTree& configuration);
virtual bool configureDebugMode(const IPTree& configuration);
virtual void updateFile(const char* content, const Variables& variables, IEspUpdateLogResponse& response) const;
virtual void readPatternVariables(IEsdlScriptContext& scriptContext, IXpathContext& originalContent, IXpathContext* intermediateContent, Variables& variables) const;
virtual bool validateVariable(const char* name, const char* option) const;
virtual void resolveVariable(const char* name, const char* option, const char* value, StringBuffer& output) const;
virtual File* getFile(const char* key) const;
virtual bool needNewFile(size_t contentLength, const File& file, const Pattern& pattern, Variables& variables) const;
virtual bool haveFile(const File& file) const;
virtual bool createNewFile(File& file, const Pattern& pattern, Variables& variables) const;
virtual bool writeChunk(File& file, offset_t pos, size32_t len, const char* data) const;
};
} // namespace ModularLogAgent
#endif // _MODULARLOGAGENT_IPP_
| 49.893112 | 220 | 0.656796 | jeclrsg |
8d476c531f556d8ca7935214fbd5964f6bc8d77e | 4,205 | cpp | C++ | motion_library_layer/motion_sideward/src/sidewardTest.cpp | AUV-IITK/motion_library | c37f7109ba28de1ea39911eeac61a8d3b183f77d | [
"BSD-3-Clause"
] | 9 | 2016-05-01T22:37:09.000Z | 2017-02-19T20:48:30.000Z | motion_library_layer/motion_sideward/src/sidewardTest.cpp | shibhansh/AUV | b68a801902366a550464feed36b0d5665db92598 | [
"BSD-3-Clause"
] | 84 | 2016-05-03T03:26:24.000Z | 2016-12-01T13:40:41.000Z | motion_library_layer/motion_sideward/src/sidewardTest.cpp | shibhansh/AUV | b68a801902366a550464feed36b0d5665db92598 | [
"BSD-3-Clause"
] | 21 | 2016-05-01T22:16:45.000Z | 2017-04-23T17:49:14.000Z | // Copyright 2016 AUV-IITK
#include <ros/ros.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Float64.h>
#include <std_msgs/Bool.h>
#include <std_msgs/Float64MultiArray.h>
#include <motion_commons/SidewardAction.h>
#include <motion_commons/SidewardActionFeedback.h>
#include <motion_commons/SidewardActionResult.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <dynamic_reconfigure/server.h>
#include <motion_sideward/sidewardConfig.h>
typedef actionlib::SimpleActionClient<motion_commons::SidewardAction> Client; // defining the Client type
Client *clientPointer; // pointer for sharing client across threads
motion_commons::SidewardGoal goal; // new goal object to send to action server
ros::Publisher ip_data_pub;
ros::Publisher ip_switch;
bool moving = false;
bool success = false;
// New thread for recieving result, called from dynamic reconfig callback
// Result recieved, start next motion or if motion unsuccessful then do error
// handling
void spinThread()
{
Client &temp = *clientPointer;
temp.waitForResult();
success = (*(temp.getResult())).Result;
if (success)
{
ROS_INFO("%s motion successful", ros::this_node::getName().c_str());
}
else
ROS_INFO("%s motion unsuccessful", ros::this_node::getName().c_str());
}
// dynamic reconfig; Our primary way of debugging
// Send new goal or cancel goal depending on input from GUI
void callback(motion_sideward::sidewardConfig &config, double level)
{
ROS_INFO("%s Reconfigure Request: %f %s %d", ros::this_node::getName().c_str(), config.double_param,
config.bool_param ? "True" : "False", config.loop);
Client &can = *clientPointer;
if (!config.bool_param)
{
if (moving)
{
moving = false;
can.cancelGoal();
ROS_INFO("%s Goal Cancelled", ros::this_node::getName().c_str());
}
// stoping ip
std_msgs::Bool msg;
msg.data = true;
ip_switch.publish(msg);
}
else
{
if (moving)
{
Client &can = *clientPointer;
can.cancelGoal();
ROS_INFO("%s Goal Cancelled", ros::this_node::getName().c_str());
}
// starting ip
std_msgs::Bool msg;
msg.data = false;
ip_switch.publish(msg);
goal.Goal = config.double_param;
goal.loop = config.loop;
can.sendGoal(goal);
boost::thread spin_thread(&spinThread);
ROS_INFO("%s Goal Send %f loop: %d", ros::this_node::getName().c_str(), goal.Goal, goal.loop);
moving = true;
}
}
void ip_data_callback(std_msgs::Float64MultiArray array)
{
std_msgs::Float64 data_sideward;
data_sideward.data = array.data[1];
ip_data_pub.publish(data_sideward);
}
// Callback for Feedback from Action Server
void sidewardCb(motion_commons::SidewardActionFeedback msg)
{
ROS_INFO("%s feedback recieved %fsec remaining ", ros::this_node::getName().c_str(), msg.feedback.DistanceRemaining);
}
int main(int argc, char **argv)
{
// Initializing the node
ros::init(argc, argv, "testSidewardMotion");
ros::NodeHandle nh;
// Subscribing to feedback from ActionServer
ros::Subscriber sub_ = nh.subscribe<motion_commons::SidewardActionFeedback>("/sideward/feedback", 1000, &sidewardCb);
ros::Subscriber ip_data_sub = nh.subscribe<std_msgs::Float64MultiArray>("/varun/ip/buoy", 1000, &ip_data_callback);
ip_data_pub = nh.advertise<std_msgs::Float64>("/varun/motion/y_distance", 1000);
ip_switch = nh.advertise<std_msgs::Bool>("buoy_detection_switch", 1000);
// Declaring a new ActionClient
Client sidewardTestClient("sideward");
// Saving pointer to use across threads
clientPointer = &sidewardTestClient;
// Waiting for action server to start
ROS_INFO("%s Waiting for action server to start.", ros::this_node::getName().c_str());
sidewardTestClient.waitForServer();
// register dynamic reconfig server.
dynamic_reconfigure::Server<motion_sideward::sidewardConfig> server;
dynamic_reconfigure::Server<motion_sideward::sidewardConfig>::CallbackType f;
f = boost::bind(&callback, _1, _2);
server.setCallback(f);
motion_sideward::sidewardConfig config;
config.bool_param = false;
callback(config, 0);
// waiting for goal
ros::spin();
return 0;
}
| 32.596899 | 119 | 0.719382 | AUV-IITK |
8d47aa6e2f313e50d47040e2cf10d6f0741c9a11 | 2,192 | hpp | C++ | modules/core/trigonometric/include/nt2/trigonometric/functions/rem_2pi.hpp | feelpp/nt2 | 4d121e2c7450f24b735d6cff03720f07b4b2146c | [
"BSL-1.0"
] | 34 | 2017-05-19T18:10:17.000Z | 2022-01-04T02:18:13.000Z | modules/core/trigonometric/include/nt2/trigonometric/functions/rem_2pi.hpp | feelpp/nt2 | 4d121e2c7450f24b735d6cff03720f07b4b2146c | [
"BSL-1.0"
] | null | null | null | modules/core/trigonometric/include/nt2/trigonometric/functions/rem_2pi.hpp | feelpp/nt2 | 4d121e2c7450f24b735d6cff03720f07b4b2146c | [
"BSL-1.0"
] | 7 | 2017-12-02T12:59:17.000Z | 2021-07-31T12:46:14.000Z | //==============================================================================
// Copyright 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II
// Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#ifndef NT2_TRIGONOMETRIC_FUNCTIONS_REM_2PI_HPP_INCLUDED
#define NT2_TRIGONOMETRIC_FUNCTIONS_REM_2PI_HPP_INCLUDED
#include <nt2/include/functor.hpp>
namespace nt2 { namespace tag
{
/*!
@brief rem_2pi generic tag
Represents the rem_2pi function in generic contexts.
@par Models:
Hierarchy
**/
struct rem_2pi_ : ext::elementwise_<rem_2pi_> { typedef ext::elementwise_<rem_2pi_> parent; template<class... Args> static BOOST_FORCEINLINE BOOST_AUTO_DECLTYPE dispatch(Args&&... args) BOOST_AUTO_DECLTYPE_BODY( dispatching_rem_2pi_( ext::adl_helper(), static_cast<Args&&>(args)... ) ) };
}
namespace ext
{
template<class Site>
BOOST_FORCEINLINE generic_dispatcher<tag::rem_2pi_, Site> dispatching_rem_2pi_(adl_helper, boost::dispatch::meta::unknown_<Site>, ...)
{
return generic_dispatcher<tag::rem_2pi_, Site>();
}
template<class... Args>
struct impl_rem_2pi_;
}
/*!
compute the remainder modulo \f$2\pi\f$.
the result is in \f$[-\pi, \pi]\f$. If the input
is near \f$\pi\f$ the output can be \f$\pi\f$ or \f$-\pi\f$
depending
on register disponibility if extended arithmetic is used.
@par Semantic:
For every parameter of floating type T0
@code
T0 r = rem_2pi(x);
@endcode
is similar to:
@code
T0 r = remainder(x, _2_pi<T0>();
@endcode
@see @funcref{rem_pio2}, @funcref{rem_pio2_straight},@funcref{rem_pio2_cephes}, @funcref{rem_pio2_medium},
@param a0
@return a value of the same type as the parameter
**/
NT2_FUNCTION_IMPLEMENTATION(tag::rem_2pi_, rem_2pi,1)
NT2_FUNCTION_IMPLEMENTATION(tag::rem_2pi_, rem_2pi,2)
}
#endif
| 30.873239 | 298 | 0.627737 | feelpp |
8d4b72771ab0351f2683b9404a42887be7c077c4 | 769 | cpp | C++ | flightlib/src/common/command.cpp | evan-palmer/flightmare | 5f4c905910551386adfddaf5da59da41ce44b6cd | [
"MIT"
] | null | null | null | flightlib/src/common/command.cpp | evan-palmer/flightmare | 5f4c905910551386adfddaf5da59da41ce44b6cd | [
"MIT"
] | null | null | null | flightlib/src/common/command.cpp | evan-palmer/flightmare | 5f4c905910551386adfddaf5da59da41ce44b6cd | [
"MIT"
] | null | null | null | #include "flightlib/common/command.hpp"
namespace flightlib
{
Command::Command() { }
Command::Command(const Scalar t, const Scalar thrust, const Vector<3>& omega) : t(t), collective_thrust(thrust), omega(omega) { }
Command::Command(const Scalar t, const Vector<4>& thrusts) : t(t), thrusts(thrusts) { }
bool Command::valid() const
{
return std::isfinite(t) && ((std::isfinite(collective_thrust) && omega.allFinite()) ^ thrusts.allFinite());
}
bool Command::isSingleRotorThrusts() const
{
return std::isfinite(t) && thrusts.allFinite();
}
bool Command::isRatesThrust() const
{
return std::isfinite(t) && std::isfinite(collective_thrust) && omega.allFinite();
}
} // namespace flightlib | 28.481481 | 133 | 0.642393 | evan-palmer |
8d4c37b519fd0e4d78a43ce88db4c0f1abc7e714 | 3,363 | hpp | C++ | rest-server/src/controller/controller.hpp | OS-WASABI/CADG | b214edff82d4238e51569a42a6bdfab6806d768f | [
"BSD-3-Clause"
] | null | null | null | rest-server/src/controller/controller.hpp | OS-WASABI/CADG | b214edff82d4238e51569a42a6bdfab6806d768f | [
"BSD-3-Clause"
] | 22 | 2018-10-26T17:30:24.000Z | 2019-04-15T23:38:18.000Z | rest-server/src/controller/controller.hpp | OS-WASABI/CADG | b214edff82d4238e51569a42a6bdfab6806d768f | [
"BSD-3-Clause"
] | 1 | 2019-03-23T16:02:17.000Z | 2019-03-23T16:02:17.000Z | /// A REST endpoint controller abstract class.
/**
* Controller is a base class for REST controller classes,
* it has some common methods defined and leaves methods that
* need to be defined by parent classes undefined. A controller
* has an endpoint, can be started with Accept and ended with
* Shutdown. The default supported http verbs are GET, PUT, POST,
* and DELETE.
*
* Copyright 2018 Vaniya Agrawal, Ross Arcemont, Kristofer Hoadley,
* Shawn Hulce, Michael McCulley
*
* @file controller.hpp
* @authors { Kristofer Hoadley }
* @date November, 2018
*/
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <map>
#include <string>
#include <vector>
#include <cpprest/http_listener.h>
#include <cpprest/http_msg.h>
#include <pplx/pplxtasks.h>
#include "logger_interface.hpp"
#include "logger.hpp"
using namespace web;
using namespace http;
using namespace http::experimental::listener;
namespace cadg_rest {
/// A REST endpoint controller abstract class.
/**
* Controller is a base class for REST controller classes,
* it has some common methods defined and leaves methods that
* need to be defined by parent classes undefined. A controller
* has an endpoint, can be started with Accept and ended with
* Shutdown. The default supported http verbs are GET, PUT, POST,
* and DELETE.
* Uses a Logger with LogNetworkActivity for logging.
*/
class Controller {
public:
/// Takes in a Logger object reference that adheres to the Logger interface.
Controller() : logger__(Logger::Instance()) { }
~Controller() { }
void endpoint(const std::string& endpoint);
std::string endpoint() const;
///Starts the controller
/**
* Starts the controller listening at it's endpoint.
* The endpoint should be set first.
*/
pplx::task<void> Accept();
/// Stops the controller from listening at it's endoint.
pplx::task<void> Shutdown();
/// PathSegments parses the provided path string of a URL path.
/**
* The paths are parsed with '/' delimiting segments
*
* @param path_string The path string to be parsed.
* @return A <string> vector of path segment names.
*/
static std::vector<std::string> PathSegments(const std::string& path_string);
/// Queries parses the provided query string of a URL path.
/**
* The queries are parsed with '&' delimiting queries
* and with '=' delimiting values from keys.
*
* @param query_string The path query string to be parsed.
* @return A <string, string> map of query name as keys and variable as value.
*/
static std::map<std::string, std::string> Queries(const std::string& query_string);
///Initializes listeners and binds methods to proper handlers.
/**
* Binds supported methods to the functions that handle them.
*/
virtual void InitHandlers() = 0;
virtual void HandleGet(http_request message) = 0;
virtual void HandlePut(http_request message) = 0;
virtual void HandlePost(http_request message) = 0;
virtual void HandleDelete(http_request message) = 0;
protected:
http_listener listener__;
LoggerInterface& logger__;
/// The default response to return if the http verb is not implemented.
static json::value ResponseNotImpl(const http::method& method);
};
}
#endif // CONTROLLER_H
| 36.16129 | 87 | 0.697591 | OS-WASABI |
8d4c6e601ee133aff69415616fb5649b6d42863f | 2,099 | cpp | C++ | Genetic Algorithm/ConsoleController.cpp | henry9836/Genetic-Algorithm | 02841beb56991b3e95ebde642fac6f19e352726a | [
"MIT"
] | null | null | null | Genetic Algorithm/ConsoleController.cpp | henry9836/Genetic-Algorithm | 02841beb56991b3e95ebde642fac6f19e352726a | [
"MIT"
] | null | null | null | Genetic Algorithm/ConsoleController.cpp | henry9836/Genetic-Algorithm | 02841beb56991b3e95ebde642fac6f19e352726a | [
"MIT"
] | null | null | null | #include "ConsoleController.h"
void Console_gotoXY(int x, int y) //Move Console Cursor to XY
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void Console_Resize(int x, int y) { //Resize Console Window
RECT m_rect;
HWND m_console = GetConsoleWindow();
GetWindowRect(m_console, &m_rect); //stores the console's current dimensions
MoveWindow(m_console, m_rect.left, m_rect.top, x, y, TRUE);
}
void Console_Clear() { //Clear console window
system("cls");
Console_gotoXY(0, 0);
}
void Console_FontSize(int x, int y) {
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx = new CONSOLE_FONT_INFOEX();
lpConsoleCurrentFontEx->cbSize = sizeof(CONSOLE_FONT_INFOEX);
GetCurrentConsoleFontEx(out, 0, lpConsoleCurrentFontEx);
lpConsoleCurrentFontEx->dwFontSize.X = x;
lpConsoleCurrentFontEx->dwFontSize.Y = y;
SetCurrentConsoleFontEx(out, 0, lpConsoleCurrentFontEx);
}
/*
COLOR CODES:
RANGE: 0-254
0 - BLACK
1 - DARK BLUE
2 - DARK GREEN
3 - DARK AQUA
4 - DARK RED
5 - DARK PINK
6 - DARK YELLOW
7 - LIGHT GREY
8 - GREY
9 - BLUE
10 - GREEN
11 - AQUA
12 - RED
13 - PINK
14 - YELLOW
15 - WHITE
0-15 BLACK BACK
16-31 DARK BLUE BACK
32-47 DARK GREEN BACK
48-63 DARK AQUA BACK
64-79 DARK RED BACK
80-95 DARK PINK BACK
96-111 DARK YELLOW BACK
112-127 LIGHT GREY BACK
128-143 GREY BACK
144-159 BLUE BACK
160-175 GREEN BACK
176-191 AQUA BACK
192-207 RED BACK
208-223 PINK BACK
224-239 YELLOW BACK
240-254 WHITE BACK
*/
void Console_ColoredTEXT(string m_word, int m_color) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), m_color);
cout << m_word;
}
void Console_ColoredTEXTChar(char m_word, int m_color) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), m_color);
cout << m_word;
}
void Console_RainbowWrite(std::string m_word) {
srand((unsigned int)time(NULL));
for (size_t i = 0; i < m_word.length(); i++)
{
Console_ColoredTEXTChar(m_word[i], rand() % 15 + 1);
}
}
| 22.329787 | 78 | 0.711291 | henry9836 |
8d4e644be168bbfadf75c6c3742cfeb7ef9a7298 | 4,453 | cpp | C++ | Code en C++ de Mage War Online/PhantomBall.cpp | Drakandes/Portfolio_NicolasPaulBonneau | c8115d5ecd6c284113766d64d0f907c074315cff | [
"MIT"
] | null | null | null | Code en C++ de Mage War Online/PhantomBall.cpp | Drakandes/Portfolio_NicolasPaulBonneau | c8115d5ecd6c284113766d64d0f907c074315cff | [
"MIT"
] | null | null | null | Code en C++ de Mage War Online/PhantomBall.cpp | Drakandes/Portfolio_NicolasPaulBonneau | c8115d5ecd6c284113766d64d0f907c074315cff | [
"MIT"
] | null | null | null | #include "stdafx.h"
#include "PhantomBall.h"
PhantomBall::PhantomBall()
{
if (!texture_projectile.loadFromFile("PhantomBall.png"))
{
std::cout << "Error while loading PhantomBall texture" << std::endl;
}
if (!shadow_texture.loadFromFile("PhantomBallShadow.png"))
{
std::cout << "Error while loading PhantomBall projectile shadow texture" << std::endl;
}
shadow = GlobalFunction::CreateSprite(sf::Vector2f(0, 0), shadow_size, shadow_texture);
}
PhantomBall::~PhantomBall()
{
}
void PhantomBall::Init(sf::Vector2f &position_caster, float damage_received, float speed_received,float angle, int id_caster)
{
rotation_projectile = angle;
damage = damage_received;
position_origin = position_caster;
projectile = GlobalFunction::CreateSprite(position_caster, size_projectile, texture_projectile);
projectile.setTextureRect(sf::IntRect(0, 0, size_projectile.x, size_projectile.y));
projectile.setRotation(angle);
speed_initial = speed_received;
speed_projectile = speed_received;
id_projectile = id_caster;
}
void PhantomBall::Update(float DELTATIME, sf::Vector2f player_position)
{
Movement_of_fireball(player_position, DELTATIME);
}
void PhantomBall::Movement_of_fireball(sf::Vector2f position_player, float DELTATIME)
{
sf::Vector2f position_projectile = GetCurrentPosition();
if (coming_back)
{
float distance = GlobalFunction::GetDistanceBetweenTwoPositions(position_origin, position_projectile);
if (distance < 10)
{
is_to_delete = true;
}
rotation_projectile = GlobalFunction::GetRotationBetweenTwoPositions(position_origin, GetCurrentPosition());
/*speed_projectile = speed_initial;
float speed_modification = ((1 - (distance / range_projectile)) - 0.1) * speed_projectile;
if (speed_modification > 0)
{
speed_projectile -= speed_modification;
}*/
}
else
{
/*float distance = GlobalFunction::GetDistanceBetweenTwoPositions(position_origin, position_projectile);
speed_projectile = speed_initial;
float speed_modification = ((distance / range_projectile) - 0.1) * speed_projectile;
if (speed_modification > 0)
{
speed_projectile -= speed_modification;
}*/
}
projectile.move((cos(rotation_projectile * PI / 180))*speed_projectile*DELTATIME, (sin(rotation_projectile * PI / 180))*speed_projectile*DELTATIME);
if (!coming_back)
{
sf::Vector2f position_2 = GetCurrentPosition();
if (GlobalFunction::GetDistanceBetweenTwoPositions(position_2, position_origin) >= range_projectile)
{
coming_back = true;
}
}
}
sf::Vector2f PhantomBall::GetCurrentPosition()
{
return projectile.getPosition();
}
sf::Vector2f PhantomBall::GetSize()
{
return size_projectile;
}
int PhantomBall::GetRayon()
{
return rayon;
}
float PhantomBall::GetDamage()
{
is_to_delete = true;
return damage;
}
bool PhantomBall::IsNeedToDelete()
{
return is_to_delete;
}
void PhantomBall::Draw(sf::RenderWindow &window)
{
window.draw(projectile);
}
void PhantomBall::DrawShadow(sf::RenderWindow &window)
{
shadow.setPosition(projectile.getPosition() + sf::Vector2f(0, shadow_size.y));
window.draw(shadow);
}
sf::Vector2f PhantomBall::GetCurrentPositionShadow()
{
return shadow.getPosition() + sf::Vector2f(0, -size_projectile.y/2);
}
bool PhantomBall::CanAffectPlayer() { return true; }
void PhantomBall::DealWithCollision(std::shared_ptr<CollisionalObject> object_collided)
{
int id_object = object_collided->GetId();
int type_object = object_collided->GetTypeCollisionalObject();
sf::Vector2f position_self = GetCurrentPosition();
sf::Vector2f position_objet = object_collided->GetCurrentPosition();
sf::Vector2f size_object = object_collided->GetSize();
if (type_object == Player_E)
{
if (CanAffectPlayer())
{
is_to_delete = true;
float damage_dealt = object_collided->GotDamaged(GetDamage(), id_projectile, 0);
}
}
if (type_object == NatureObject_E)
{
if (!object_collided->CheckIfProjectileDisable())
{
is_to_delete = true;
}
}
}
void PhantomBall::PutItBackInQuadtree()
{
need_to_be_put_in_quadtree = true;
}
bool PhantomBall::CheckIfNeedGoBackQuadtree()
{
bool holder = need_to_be_put_in_quadtree;
need_to_be_put_in_quadtree = false;
return holder;
}
void PhantomBall::GiveParentPosition(sf::Vector2f position)
{
if (coming_back)
{
position_origin = position;
}
} | 26.349112 | 150 | 0.72962 | Drakandes |
8d50881ed4dc471c64cea1a3e4cebb4a01dd0720 | 681 | hpp | C++ | headers.hpp | polmes/thermo-sim | aa22b1265d8e1ac140f498c1f8c94944ecd8a50f | [
"MIT"
] | 1 | 2020-02-05T08:46:07.000Z | 2020-02-05T08:46:07.000Z | headers.hpp | polmes/thermo-sim | aa22b1265d8e1ac140f498c1f8c94944ecd8a50f | [
"MIT"
] | null | null | null | headers.hpp | polmes/thermo-sim | aa22b1265d8e1ac140f498c1f8c94944ecd8a50f | [
"MIT"
] | 1 | 2018-09-21T13:53:27.000Z | 2018-09-21T13:53:27.000Z | // Standard libraries
#ifndef INCLUDE_STL
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <thread>
#include <stdexcept>
#define INCLUDE_STL
#endif
/*
// My libraries
#ifndef INCLUDE_MESH
#include "mesh.hpp"
#define INCLUDE_MESH
#endif
#ifndef INCLUDE_VOLUME
#include "volume.hpp"
#define INCLUDE_VOLUME
#endif
#ifndef INCLUDE_MATERIAL
#include "material.hpp"
#define INCLUDE_MATERIAL
#endif
#ifndef INCLUDE_CONDITION
#include "condition.hpp"
#define INCLUDE_CONDITION
#endif
#ifndef INCLUDE_UTIL
#include "util.hpp"
#define INCLUDE_UTIL
#endif
*/
| 17.461538 | 26 | 0.756241 | polmes |
8d525a0c19d7849b62b0ea764d31e536a97f426b | 1,830 | hpp | C++ | C64/src/Emulator/Logic/Keyboard.hpp | vividos/OldStuff | dbfcce086d1101b576d99d25ef051efbd8dd117c | [
"BSD-2-Clause"
] | 1 | 2015-03-26T02:35:13.000Z | 2015-03-26T02:35:13.000Z | C64/src/Emulator/Logic/Keyboard.hpp | vividos/OldStuff | dbfcce086d1101b576d99d25ef051efbd8dd117c | [
"BSD-2-Clause"
] | null | null | null | C64/src/Emulator/Logic/Keyboard.hpp | vividos/OldStuff | dbfcce086d1101b576d99d25ef051efbd8dd117c | [
"BSD-2-Clause"
] | null | null | null | //
// Emulator - Simple C64 emulator
// Copyright (C) 2003-2016 Michael Fink
//
/// \file Keyboard.hpp C64 keyboard implementation
//
#pragma once
// includes
#include "ICIAPortHandler.hpp"
namespace C64
{
/// Implementation of the C64 keyboard
/// \note the keyboard is wired to the CIA 2 of the original C64
class Keyboard: public ICIAPortHandler
{
public:
/// ctor
Keyboard();
/// dtor
~Keyboard() throw()
{
}
/// enables or disables port 2 joystick numpad/right-ctrl emulation
void SetJoystickNumPadEmulation(bool enable) throw()
{
m_joystickNumPadEmulation = enable;
}
/// sets state for a key
void SetKeyState(BYTE keyCode, bool keyState, bool shiftState);
private:
/// sets joystick state
void SetJoystickState(BYTE keyCode, bool keyState);
/// calculates joystick port 2 mask for num pad emulation
BYTE CalcJoystickPort2NumPadMask() const;
/// calculates port A and port B bit indices from virtual key code and shift state
static bool CalcPortBitIndices(BYTE keyCode, bool shiftState, BYTE& pa, BYTE& pb);
// virtual methods from ICIAPortHandler
void SetDataPort(BYTE portNumber, BYTE value) throw() override;
void ReadDataPort(BYTE portNumber, BYTE& value) const throw() override;
private:
/// current key matrix (all set bits are currently pressed keys)
BYTE m_keyMatrix[8];
/// value that was written to port A (0 bits are the "interested bits")
BYTE m_currentPortA;
/// value that was written to port B (0 bits are the "interested bits")
BYTE m_currentPortB;
/// indicates if port 2 joystick numpad/right-ctrl emulation is active
bool m_joystickNumPadEmulation;
/// joystick state for numpad emulation, with right-ctrl and numpad1..9 key states
bool m_numPadJoystickState[10 + 1];
};
} // namespace C64
| 26.521739 | 85 | 0.715847 | vividos |
8d555b362b4d10f157657190b237b672fc2da26f | 8,809 | cpp | C++ | Engine/source/Assets/CKLBPropertyBag.cpp | lampardwade/tetris_lua_playgroundOSS | 29373294cfa66f2324ac984e5d4102854696fcc0 | [
"DOC",
"Apache-2.0"
] | 175 | 2015-01-07T08:38:31.000Z | 2022-02-28T20:40:47.000Z | Engine/source/Assets/CKLBPropertyBag.cpp | lampardwade/tetris_lua_playgroundOSS | 29373294cfa66f2324ac984e5d4102854696fcc0 | [
"DOC",
"Apache-2.0"
] | 1 | 2020-09-10T09:45:48.000Z | 2020-09-11T10:10:52.000Z | Engine/source/Assets/CKLBPropertyBag.cpp | lampardwade/tetris_lua_playgroundOSS | 29373294cfa66f2324ac984e5d4102854696fcc0 | [
"DOC",
"Apache-2.0"
] | 46 | 2015-03-14T16:11:18.000Z | 2022-02-28T20:40:49.000Z | /*
Copyright 2013 KLab 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 "CKLBPropertyBag.h"
#include <string.h>
/*
u32 CKLBPropertyBag::propAlloc = 0;
u32 CKLBPropertyBag::bagAlloc = 0;
u32 CKLBPropertyBag::stringAlloc = 0;
bool CKLBPropertyBag::deletionFlag = false;
//
// Global Array
//
CKLBPropertyBag CKLBPropertyBag::bags [MAX_PROPERTYBAG_COUNT];
CKLBPropertyBag::_v CKLBPropertyBag::properties [MAX_PROP_BUFFER_COUNT];
u8 CKLBPropertyBag::propertyTypes [MAX_PROP_BUFFER_COUNT];
char CKLBPropertyBag::strings [STRING_BUFFER_SIZE];
*/
CKLBPropertyBag * CKLBPropertyBag::ms_begin = 0;
CKLBPropertyBag * CKLBPropertyBag::ms_end = 0;
enum E_TYPE {
UNDEFINED_TYPE = 0,
INT_TYPE = 1,
BOOL_TYPE = 2,
FLOAT_TYPE = 3,
STRING_TYPE = 4,
};
/*static*/ CKLBPropertyBag* CKLBPropertyBag::getPropertyBag() {
return KLBNEW(CKLBPropertyBag);
/*
// 1. Perform compaction
compact();
// 2. Allocate
for (u32 n=0; n < bagAlloc; n++) {
if (bags[n].m_free) {
return &bags[n];
}
}
// 3. Not found : Extend...
if (bagAlloc < MAX_PROPERTYBAG_COUNT) {
// ok
bags[bagAlloc].m_free = true;
return &bags[bagAlloc++];
} else {
// Reach full end.
klb_assertAlways("Property Bag Pool fully used.");
return NULL;
}
*/
}
/*static*/ void CKLBPropertyBag::releasePropertyBag(CKLBPropertyBag* pBag) {
KLBDELETE(pBag);
/*
pBag->m_free = true;
deletionFlag = true;
*/
}
CKLBPropertyBag::CKLBPropertyBag()
: m_prev (NULL)
, m_next (NULL)
, m_propertyValues (NULL)
, m_propertyTypes (NULL)
, m_propertyCount (0)
, m_propertyMax (0)
{
m_prev = ms_end;
if(m_prev) {
m_prev->m_next = this;
} else {
ms_begin = this;
}
ms_end = this;
}
CKLBPropertyBag::~CKLBPropertyBag() {
// プロパティの持つ名前(およびstringと一体になっている)を破棄
for(int i = 0; i < m_propertyCount; i++) {
KLBDELETEA(m_propertyValues[i].name);
}
KLBDELETEA(m_propertyValues);
KLBDELETEA(m_propertyTypes);
// 自身をリンクから切り離す
if(m_prev) {
m_prev->m_next = m_next;
} else {
ms_begin = m_next;
}
if(m_next) {
m_next->m_prev = m_prev;
} else {
ms_end = m_prev;
}
}
bool CKLBPropertyBag::init() {
return true;
/*
bool res = true;
this->m_propertyValues = &properties [propAlloc];
this->m_propertyTypes = &propertyTypes [propAlloc];
this->m_propertyCount = 0;
this->m_free = !res;
return res;
*/
}
const char* CKLBPropertyBag::allocateName(const char* originalName, int addlen) {
u32 len = strlen(originalName) + 1;
char * buf = KLBNEWA(char, len + addlen);
memcpy(buf, originalName, len);
return (const char *)buf;
}
/*static*/
void CKLBPropertyBag::compact() {
/*
//
// Do NOT compact PropertyBag array itself -> Pointer will change !
//
if (deletionFlag) {
deletionFlag = false;
_v* packProp = properties;
u8* packPropType = propertyTypes;
char* packString = strings;
for (u32 n=0; n < bagAlloc; n++) {
if (bags[n].m_free == false) {
CKLBPropertyBag* pBag = &bags[n];
//
// Move properties.
//
if (pBag->m_propertyValues != packProp) {
memcpy(packProp, pBag->m_propertyValues, sizeof(_v) * pBag->m_propertyCount);
memcpy(packPropType, pBag->m_propertyTypes, sizeof(u8) * pBag->m_propertyCount);
pBag->m_propertyValues = packProp;
pBag->m_propertyTypes = packPropType;
}
packProp += pBag->m_propertyCount;
packPropType += pBag->m_propertyCount;
//
// Move String name / value
//
for (u32 m=0; m < pBag->m_propertyCount; m++) {
const char* str = pBag->m_propertyValues[m].name;
u32 len = strlen(str) + 1;
if (str != packString)
{
memcpy(packString, str, len);
pBag->m_propertyValues[m].name = packString;
}
packString += len;
if (pBag->m_propertyTypes[m] == STRING_TYPE) {
str = pBag->m_propertyValues[m].v.s;
len = strlen(str) + 1;
if (pBag->m_propertyValues[m].name != packString)
{
memcpy(packString, str, len);
pBag->m_propertyValues[m].v.s = packString;
}
packString += len;
}
}
}
}
// Compact string allocator.
stringAlloc = packString - strings;
// Compact prop allocator;
propAlloc = packProp - properties;
}
*/
}
void
CKLBPropertyBag::appendProperty()
{
int cnt = m_propertyCount + 1;
if(cnt <= m_propertyMax) { return; }
cnt = m_propertyMax + PROPERTY_BLOCK_COUNT;
_v * tmpValues = KLBNEWA(_v, cnt);
u8 * tmpTypes = KLBNEWA(u8, cnt);
if(m_propertyValues) {
memcpy(tmpValues, m_propertyValues, sizeof(_v) * m_propertyCount);
memcpy(tmpTypes , m_propertyTypes, sizeof(u8) * m_propertyCount);
KLBDELETEA(m_propertyValues);
KLBDELETEA(m_propertyTypes);
}
m_propertyValues= tmpValues;
m_propertyTypes = tmpTypes;
m_propertyMax = cnt;
}
void CKLBPropertyBag::setPropertyInt(const char* name, s32 value) {
// klb_assert(propAlloc < MAX_PROP_BUFFER_COUNT, "No more space for properties");
appendProperty();
m_propertyValues[m_propertyCount].name = allocateName(name);
m_propertyValues[m_propertyCount].v.i = value;
m_propertyTypes[m_propertyCount] = INT_TYPE;
m_propertyCount++;
}
void CKLBPropertyBag::setPropertyBool(const char* name, bool value) {
//klb_assert(propAlloc < MAX_PROP_BUFFER_COUNT, "No more space for properties");
appendProperty();
m_propertyValues[m_propertyCount].name = allocateName(name);
m_propertyValues[m_propertyCount].v.b = value;
m_propertyTypes[m_propertyCount] = BOOL_TYPE;
m_propertyCount++;
}
void CKLBPropertyBag::setPropertyFloat(const char* name, float value) {
//klb_assert(propAlloc < MAX_PROP_BUFFER_COUNT, "No more space for properties");
appendProperty();
m_propertyValues[m_propertyCount].name = allocateName(name);
m_propertyValues[m_propertyCount].v.f = value;
m_propertyTypes[m_propertyCount] = FLOAT_TYPE;
m_propertyCount++;
}
void CKLBPropertyBag::setPropertyString(const char* name, const char* value) {
//klb_assert(propAlloc < MAX_PROP_BUFFER_COUNT, "No more space for properties");
appendProperty();
int namelen = strlen(name) + 1;
int valuelen = strlen(value) + 1;
const char * vname = allocateName(name, valuelen);
char * vstring = (char *)vname + namelen;
strcpy(vstring, value);
m_propertyValues[m_propertyCount].name = vname;
m_propertyValues[m_propertyCount].v.s = vstring;
m_propertyTypes[m_propertyCount] = STRING_TYPE;
m_propertyCount++;
}
s32 CKLBPropertyBag::getIndex(const char* name) {
for(u32 n = 0; n < m_propertyCount; n++) {
if (strcmp(name, m_propertyValues[n].name) == 0) {
return n;
}
}
return -1;
}
u32 CKLBPropertyBag::getFieldType(const char* name) {
s32 idx = getIndex(name);
if (idx != -1) {
return m_propertyTypes[idx];
} else {
return UNDEFINED_TYPE;
}
}
s32 CKLBPropertyBag::getPropertyInt(const char* name) {
s32 idx = getIndex(name);
if ((idx != -1) && (m_propertyTypes[idx] == INT_TYPE)) {
return m_propertyValues[idx].v.i;
} else {
klb_assertAlways("Unknown property or non matching type %s", name);
return 0;
}
}
bool CKLBPropertyBag::getPropertyBool(const char* name) {
s32 idx = getIndex(name);
if (idx != -1) {
if (m_propertyTypes[idx] == BOOL_TYPE) {
return m_propertyValues[idx].v.b;
} else if (m_propertyTypes[idx] == INT_TYPE) {
return m_propertyValues[idx].v.i ? true : false;
}
}
klb_assertAlways("Unknown property or non matching type %s", name);
return false;
}
float CKLBPropertyBag::getPropertyFloat(const char* name) {
s32 idx = getIndex(name);
if ((idx != -1) && (m_propertyTypes[idx] == BOOL_TYPE)) {
return m_propertyValues[idx].v.f;
} else {
klb_assertAlways("Unknown property or non matching type %s", name);
return 0.0f;
}
}
const char* CKLBPropertyBag::getPropertyString(const char* name) {
s32 idx = getIndex(name);
if ((idx != -1) && (m_propertyTypes[idx] == STRING_TYPE)) {
return m_propertyValues[idx].v.s;
} else {
klb_assertAlways("Unknown property or non matching type %s", name);
return NULL;
}
}
| 26.613293 | 86 | 0.662277 | lampardwade |
8d55d40b324f4d341dd0f4bb8c30be85486c8853 | 3,272 | cpp | C++ | SRM605/AlienAndSetDiv2.cpp | CanoeFZH/SRM | 02e3eeaa6044b14640e450725f68684e392009cb | [
"MIT"
] | null | null | null | SRM605/AlienAndSetDiv2.cpp | CanoeFZH/SRM | 02e3eeaa6044b14640e450725f68684e392009cb | [
"MIT"
] | null | null | null | SRM605/AlienAndSetDiv2.cpp | CanoeFZH/SRM | 02e3eeaa6044b14640e450725f68684e392009cb | [
"MIT"
] | null | null | null | // BEGIN CUT HERE
// END CUT HERE
#line 5 "AlienAndSetDiv2.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
const int MOD = 1000000007;
const int N = 110;
#define gSet set <int, greater <int> >
map <gSet, long> dp[N];
class AlienAndSetDiv2
{
public:
int K;
long gao (int n, gSet unmatched) {
auto q = dp[n].find(unmatched);
long ret = 0;
if (q == dp[n].end()) {
if (n == 0) {
if (unmatched.size() == 0) {
ret = 1;
}
} else {
if (unmatched.size() == 0) {
ret = 2 * gao(n - 1, {n});
} else {
int maxUnmatched = *unmatched.begin();
gSet newSet = unmatched;
newSet.erase(newSet.begin());
ret += gao(n - 1, newSet);
if (n + K != maxUnmatched) {
gSet newSet = unmatched;
newSet.insert(n);
ret += gao(n - 1, newSet);
}
}
ret %= MOD;
}
dp[n][unmatched] = ret;
} else {
ret = q->second;
}
return ret;
}
int getNumber(int N, int K) {
this-> K = K;
return gao(2 * N, {});
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arg0 = 2; int Arg1 = 1; int Arg2 = 4; verify_case(0, Arg2, getNumber(Arg0, Arg1)); }
void test_case_1() { int Arg0 = 3; int Arg1 = 1; int Arg2 = 8; verify_case(1, Arg2, getNumber(Arg0, Arg1)); }
void test_case_2() { int Arg0 = 4; int Arg1 = 2; int Arg2 = 44; verify_case(2, Arg2, getNumber(Arg0, Arg1)); }
void test_case_3() { int Arg0 = 10; int Arg1 = 10; int Arg2 = 184756; verify_case(3, Arg2, getNumber(Arg0, Arg1)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main() {
AlienAndSetDiv2 ___test;
___test.run_test(-1);
return 0;
}
| 33.731959 | 308 | 0.498472 | CanoeFZH |
8d5d0c91a05cc67d08918b845a1dfba5574168e5 | 1,694 | cpp | C++ | SDK/ARKSurvivalEvolved_Xeno_WebExplosionEmitter_Corrupt_functions.cpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 10 | 2020-02-17T19:08:46.000Z | 2021-07-31T11:07:19.000Z | SDK/ARKSurvivalEvolved_Xeno_WebExplosionEmitter_Corrupt_functions.cpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 9 | 2020-02-17T18:15:41.000Z | 2021-06-06T19:17:34.000Z | SDK/ARKSurvivalEvolved_Xeno_WebExplosionEmitter_Corrupt_functions.cpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 3 | 2020-07-22T17:42:07.000Z | 2021-06-19T17:16:13.000Z | // ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_Xeno_WebExplosionEmitter_Corrupt_parameters.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function Xeno_WebExplosionEmitter_Corrupt.Xeno_WebExplosionEmitter_Corrupt_C.UserConstructionScript
// ()
void AXeno_WebExplosionEmitter_Corrupt_C::UserConstructionScript()
{
static auto fn = UObject::FindObject<UFunction>("Function Xeno_WebExplosionEmitter_Corrupt.Xeno_WebExplosionEmitter_Corrupt_C.UserConstructionScript");
AXeno_WebExplosionEmitter_Corrupt_C_UserConstructionScript_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function Xeno_WebExplosionEmitter_Corrupt.Xeno_WebExplosionEmitter_Corrupt_C.ExecuteUbergraph_Xeno_WebExplosionEmitter_Corrupt
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void AXeno_WebExplosionEmitter_Corrupt_C::ExecuteUbergraph_Xeno_WebExplosionEmitter_Corrupt(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function Xeno_WebExplosionEmitter_Corrupt.Xeno_WebExplosionEmitter_Corrupt_C.ExecuteUbergraph_Xeno_WebExplosionEmitter_Corrupt");
AXeno_WebExplosionEmitter_Corrupt_C_ExecuteUbergraph_Xeno_WebExplosionEmitter_Corrupt_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 29.719298 | 179 | 0.739669 | 2bite |
8d690fad20734bfc391c66d12f38cc7abbc892a0 | 83 | cpp | C++ | examples/with-deps/packages/b/src/b.cpp | berenm/CMakeBuildPackage | 035cc0d68b0bc33fde1a4af70696ad3805259e6d | [
"Unlicense"
] | 22 | 2017-01-09T17:29:06.000Z | 2021-01-23T07:16:44.000Z | examples/with-deps/packages/b/src/b.cpp | berenm/CMakeBuildPackage | 035cc0d68b0bc33fde1a4af70696ad3805259e6d | [
"Unlicense"
] | 4 | 2016-01-29T16:51:26.000Z | 2016-10-17T10:22:12.000Z | examples/with-deps/packages/b/src/b.cpp | berenm/CMakeBuildPackage | 035cc0d68b0bc33fde1a4af70696ad3805259e6d | [
"Unlicense"
] | null | null | null | #include "b.hpp"
#include "a.hpp"
namespace b {
void hello() { a::hello(); }
}
| 10.375 | 30 | 0.566265 | berenm |
8d6aedccd0decea60fb3402398ba9f75387305e9 | 1,057 | hh | C++ | Sources/AGEngine/Render/ProgramResources/Types/ProgramResourcesType.hh | Another-Game-Engine/AGE | d5d9e98235198fe580a43007914f515437635830 | [
"MIT"
] | 47 | 2015-03-29T09:44:25.000Z | 2020-11-30T10:05:56.000Z | Sources/AGEngine/Render/ProgramResources/Types/ProgramResourcesType.hh | Another-Game-Engine/AGE | d5d9e98235198fe580a43007914f515437635830 | [
"MIT"
] | 313 | 2015-01-01T18:16:30.000Z | 2015-11-30T07:54:07.000Z | Sources/AGEngine/Render/ProgramResources/Types/ProgramResourcesType.hh | Another-Game-Engine/AGE | d5d9e98235198fe580a43007914f515437635830 | [
"MIT"
] | 9 | 2015-06-07T13:21:54.000Z | 2020-08-25T09:50:07.000Z | #pragma once
# include <array>
# include <unordered_map>
# include <glm/glm.hpp>
# include <iostream>
# include <string>
#include <Utils/OpenGL.hh>
static size_t const nbr_resources = 21;
extern const std::array<GLenum, nbr_resources> available_resources;
struct GlType
{
uint8_t nbr_component;
GLenum type;
GLenum type_component;
size_t size;
std::string name;
GlType(){}
GlType(GLenum type, GLenum typeComponent, size_t size, uint8_t nbrComponent, std::string &&name) :
nbr_component(nbrComponent),
type(type),
type_component(typeComponent),
size(size),
name(std::move(name))
{}
GlType(GlType const ©) :
nbr_component(copy.nbr_component),
type(copy.type),
type_component(copy.type_component),
size(copy.size),
name(copy.name)
{}
bool operator==(GLenum t) const
{
if (type == t) {
return (true);
}
return (false);
}
bool operator!=(GLenum t) const
{
return (!(*this == t));
}
void print() const
{
std::cout << name << std::endl;
}
};
extern std::unordered_map<GLenum, GlType> available_types; | 18.875 | 99 | 0.693472 | Another-Game-Engine |
8d6c5fa415fcb8cee20df69a59e159b27ee1cb7a | 504 | hpp | C++ | src/main/include/Autons.hpp | TEAM1771/Black-Widdow-2022-Update | 799dd9caa8171a1f2c40cdf5cd62f45478ba02c4 | [
"BSD-3-Clause"
] | 2 | 2022-01-11T13:09:02.000Z | 2022-02-10T02:37:14.000Z | src/main/include/Autons.hpp | TEAM1771/Black-Widdow-2022-Update | 799dd9caa8171a1f2c40cdf5cd62f45478ba02c4 | [
"BSD-3-Clause"
] | 1 | 2022-02-10T16:06:18.000Z | 2022-02-17T18:15:26.000Z | src/main/include/Autons.hpp | TEAM1771/Black-Widow-2022-Update | 799dd9caa8171a1f2c40cdf5cd62f45478ba02c4 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include "Autons/30Degree.hpp"
#include "Autons/Complex.hpp"
#include "Autons/LShape.hpp"
#include "Autons/PickupBalls.hpp"
#include "Autons/TShape.hpp"
#include <map>
#include <functional>
// All autonomous programs are stored as lambdas to be called
using namespace Autons;
inline std::map<std::string, std::function<void()>> autons{
{"Default - LShape", lShape},
{"30 Degree", thirtyDegree},
{"TShape", tShape},
{"Pickup Balls", pickupBalls},
{"Complex", complex}}; | 26.526316 | 61 | 0.700397 | TEAM1771 |
8d6d23cbcc31df952c86f0cf647508bf3e5beb30 | 110 | cpp | C++ | src/robot/main.cpp | markushedvall/toy-robot | 3b219f713e5df13ab1376eff2255734029c4ce18 | [
"MIT"
] | null | null | null | src/robot/main.cpp | markushedvall/toy-robot | 3b219f713e5df13ab1376eff2255734029c4ce18 | [
"MIT"
] | 1 | 2021-03-27T13:15:13.000Z | 2021-03-27T13:15:13.000Z | src/robot/main.cpp | markushedvall/toy-robot | 3b219f713e5df13ab1376eff2255734029c4ce18 | [
"MIT"
] | null | null | null | #include <robot/hello.h>
#include <iostream>
int main() {
std::cout << robot::say_hello() << std::endl;
}
| 13.75 | 47 | 0.618182 | markushedvall |
8d721138d37797ce559eece6ce68fd4addc2a474 | 1,928 | cpp | C++ | PortableGraphicsToolkit/src/pgt/graphics/plattform/opengl/font/GlFont.cpp | chris-b-h/PortableGraphicsToolkit | 85862a6c5444cf9689821ff23952b56a01ff5835 | [
"Zlib"
] | 3 | 2017-07-12T20:18:51.000Z | 2017-07-20T15:02:58.000Z | PortableGraphicsToolkit/src/pgt/graphics/plattform/opengl/font/GlFont.cpp | chris-b-h/PortableGraphicsToolkit | 85862a6c5444cf9689821ff23952b56a01ff5835 | [
"Zlib"
] | null | null | null | PortableGraphicsToolkit/src/pgt/graphics/plattform/opengl/font/GlFont.cpp | chris-b-h/PortableGraphicsToolkit | 85862a6c5444cf9689821ff23952b56a01ff5835 | [
"Zlib"
] | 1 | 2019-04-03T01:19:42.000Z | 2019-04-03T01:19:42.000Z | #include "GlFont.h"
#include <pgt/window/engine.h>
#include <pgt/window/plattform/interface/IAPP.h>
#include <pgt/graphics/plattform/interface/IRenderingContext.h>
#include <pgt/io/logger/logger.h>
#include "GlFontInternal.h"
namespace pgt {
namespace plattform {
GlFont::GlFont(const std::string& name, size_t size, IStreamReader& sr)
{
_font_internal = new GlFontInternal(name, size, sr);
}
GlFont::GlFont(const std::string& name, size_t size)
{
_font_internal =
((GlFontManager&)engine::getRenderingContextCurrent()
.getFontManager())
.getFont(name, size);
PGT_ASSERT(_font_internal, "Font doesnt exist");
}
GlFont::GlFont(GlFontInternal& f)
{
_font_internal = &f;
}
GlFont::~GlFont()
{
if (_font_internal->isManaged() == false) delete _font_internal;
}
GlFontInternal& GlFont::getInternalFont()
{
return *_font_internal;
}
const std::string& GlFont::getName() const
{
return _font_internal->getName();
}
size_t GlFont::getSize() const
{
return _font_internal->getSize();
}
int GlFont::getAscender() const
{
return _font_internal->getAscender();
}
int GlFont::getDescender() const
{
return _font_internal->getDescender();
}
int GlFont::getBaselineOffset() const
{
return _font_internal->getBaselineOffset();
}
int GlFont::getYOffsetMax() const
{
return _font_internal->getYOffsetMax();
}
pgt::vec3i GlFont::measureString(const std::string& text) const
{
return _font_internal->measureString(text);
}
}
}
| 25.706667 | 79 | 0.553942 | chris-b-h |
8d73818c421eaebb7dd018f75c2399740f1be2ed | 7,076 | cpp | C++ | java/cpp/com_automatak_dnp3_impl_MasterImpl.cpp | sidhoda/dnp3 | 0469f308cb3321e8f5b57ccc2e26a34eb430941c | [
"Apache-2.0"
] | null | null | null | java/cpp/com_automatak_dnp3_impl_MasterImpl.cpp | sidhoda/dnp3 | 0469f308cb3321e8f5b57ccc2e26a34eb430941c | [
"Apache-2.0"
] | null | null | null | java/cpp/com_automatak_dnp3_impl_MasterImpl.cpp | sidhoda/dnp3 | 0469f308cb3321e8f5b57ccc2e26a34eb430941c | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2013-2016 Automatak, LLC
*
* Licensed to Automatak, LLC (www.automatak.com) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. Automatak, LLC
* licenses this file to you under the Apache License Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.html
*
* 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 "com_automatak_dnp3_impl_MasterImpl.h"
#include "jni/JCache.h"
#include "adapters/GlobalRef.h"
#include "adapters/Conversions.h"
#include "asiodnp3/IMaster.h"
#include "opendnp3/master/CommandSet.h"
#include <memory>
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_set_1log_1level_1native
(JNIEnv* env, jobject, jlong native, jint levels)
{
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
(*master)->SetLogFilters(levels);
}
JNIEXPORT jobject JNICALL Java_com_automatak_dnp3_impl_MasterImpl_get_1statistics_1native
(JNIEnv* env, jobject, jlong native)
{
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
auto stats = (*master)->GetStackStatistics();
return env->NewGlobalRef(Conversions::ConvertStackStatistics(env, stats));
}
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_enable_1native
(JNIEnv* env, jobject, jlong native)
{
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
(*master)->Enable();
}
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_disable_1native
(JNIEnv* env, jobject, jlong native)
{
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
(*master)->Disable();
}
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_shutdown_1native
(JNIEnv* env, jobject, jlong native)
{
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
(*master)->Shutdown();
}
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_destroy_1native
(JNIEnv *, jobject, jlong native)
{
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
delete master;
}
template <class Fun>
void operate(JNIEnv* env, jlong native, jlong nativeCommandSet, jobject future, const Fun& operate)
{
auto& set = *(opendnp3::CommandSet*) nativeCommandSet;
auto sharedf = std::make_shared<GlobalRef>(future);
auto callback = [sharedf](const opendnp3::ICommandTaskResult& result)
{
const auto env = JNI::GetEnv();
const auto jsummary = jni::JCache::TaskCompletion.fromType(env, static_cast<jint>(result.summary));
const auto jlist = jni::JCache::ArrayList.init1(env, static_cast<jint>(result.Count()));
auto addToJList = [&](const opendnp3::CommandPointResult& cpr) {
const auto jstate = jni::JCache::CommandPointState.fromType(env, static_cast<jint>(cpr.state));
const auto jstatus = jni::JCache::CommandStatus.fromType(env, static_cast<jint>(cpr.status));
const auto jres = jni::JCache::CommandPointResult.init4(env, cpr.headerIndex, cpr.index, jstate, jstatus);
jni::JCache::ArrayList.add(env, jlist, jres);
};
result.ForeachItem(addToJList);
const auto jtaskresult = jni::JCache::CommandTaskResult.init2(env, jsummary, jlist);
jni::JCache::CompletableFuture.complete(env, *sharedf, jtaskresult); // invoke the future
};
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
operate(**master, set, callback);
}
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_select_1and_1operate_1native
(JNIEnv* env, jobject, jlong native, jlong nativeCommandSet, jobject future)
{
auto sbo = [](asiodnp3::IMaster& master, opendnp3::CommandSet& commandset, const opendnp3::CommandCallbackT& callback) -> void
{
master.SelectAndOperate(std::move(commandset), callback);
};
operate(env, native, nativeCommandSet, future, sbo);
}
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_direct_1operate_1native
(JNIEnv* env, jobject, jlong native, jlong nativeCommandSet, jobject future)
{
auto directOp = [](asiodnp3::IMaster& master, opendnp3::CommandSet& commandset, const opendnp3::CommandCallbackT& callback) -> void
{
master.DirectOperate(std::move(commandset), callback);
};
operate(env, native, nativeCommandSet, future, directOp);
}
bool ConvertJHeader(JNIEnv* env, jobject jheader, opendnp3::Header& header)
{
const auto group = jni::JCache::Header.getgroup(env, jheader);
const auto var = jni::JCache::Header.getvariation(env, jheader);
const auto qualifier = opendnp3::QualifierCodeFromType(static_cast<uint8_t>(jni::JCache::QualifierCode.toType(env, jni::JCache::Header.getqualifier(env, jheader))));
const auto count = jni::JCache::Header.getcount(env, jheader);
const auto start = jni::JCache::Header.getstart(env, jheader);
const auto stop = jni::JCache::Header.getstop(env, jheader);
switch (qualifier)
{
case(opendnp3::QualifierCode::ALL_OBJECTS):
header = opendnp3::Header::AllObjects(group, var);
return true;
case(opendnp3::QualifierCode::UINT8_CNT):
header = opendnp3::Header::Count8(group, var, static_cast<uint8_t>(count));
return true;
case(opendnp3::QualifierCode::UINT16_CNT):
header = opendnp3::Header::Count16(group, var, static_cast<uint16_t>(count));
return true;
case(opendnp3::QualifierCode::UINT8_START_STOP):
header = opendnp3::Header::Range8(group, var, static_cast<uint8_t>(start), static_cast<uint8_t>(stop));
return true;
case(opendnp3::QualifierCode::UINT16_START_STOP):
header = opendnp3::Header::Range16(group, var, static_cast<uint16_t>(start), static_cast<uint16_t>(stop));
return true;
default:
return false;
}
}
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_scan_1native
(JNIEnv* env, jobject, jlong native, jobject jheaders)
{
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
std::vector<opendnp3::Header> headers;
auto process = [&](LocalRef<jobject> jheader) {
opendnp3::Header header;
if (ConvertJHeader(env, jheader, header))
{
headers.push_back(header);
}
};
JNI::Iterate(env, jheaders, process);
(*master)->Scan(headers);
}
JNIEXPORT void JNICALL Java_com_automatak_dnp3_impl_MasterImpl_add_1periodic_1scan_1native
(JNIEnv* env, jobject, jlong native, jobject jduration, jobject jheaders)
{
const auto master = (std::shared_ptr<asiodnp3::IMaster>*) native;
std::vector<opendnp3::Header> headers;
auto process = [&](LocalRef<jobject> jheader) {
opendnp3::Header header;
if (ConvertJHeader(env, jheader, header))
{
headers.push_back(header);
}
};
JNI::Iterate(env, jheaders, process);
auto period = openpal::TimeDuration::Milliseconds(jni::JCache::Duration.toMillis(env, jduration));
(*master)->AddScan(period, headers);
} | 35.20398 | 166 | 0.758338 | sidhoda |
8d73dcff626558e9d0bf5293e2151fc4e855f720 | 2,313 | hh | C++ | src/include/meadow/brassica/common.hh | cagelight/meadow | 9638ce5a1f18be3da3ace157b937e41cd65c6ec1 | [
"MIT"
] | null | null | null | src/include/meadow/brassica/common.hh | cagelight/meadow | 9638ce5a1f18be3da3ace157b937e41cd65c6ec1 | [
"MIT"
] | null | null | null | src/include/meadow/brassica/common.hh | cagelight/meadow | 9638ce5a1f18be3da3ace157b937e41cd65c6ec1 | [
"MIT"
] | null | null | null | #pragma once
#include <array>
#include <cstdint>
#include <cmath>
#include <random>
namespace meadow::brassica {
template <typename T> inline constexpr T pi = static_cast<T>( 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145649L );
template <typename T> [[nodiscard]] inline consteval T pi_m(T mult) { return mult * pi<T>; }
template <typename T> [[nodiscard]] inline constexpr T radians(T const & v) { return v * pi<T> / static_cast<T>(180); }
template <typename T> [[nodiscard]] inline constexpr T degrees(T const & v) { return v / pi<T> * static_cast<T>(180); }
template <typename T> [[nodiscard]] inline constexpr T const & min(T const & A, T const & B) { return A < B ? A : B; }
template <typename T> [[nodiscard]] inline constexpr T const & max(T const & A, T const & B) { return A > B ? A : B; }
template <typename T> [[nodiscard]] inline constexpr T & min(T & A, T & B) { return A < B ? A : B; }
template <typename T> [[nodiscard]] inline constexpr T & max(T & A, T & B) { return A > B ? A : B; }
template <typename T> [[nodiscard]] inline constexpr T const & clamped(T const & value, T const & min, T const & max) { return (value < min) ? min : (value > max) ? max : value; }
template <typename T> inline constexpr T & clamp(T & value, T const & min, T const & max) { value = clamped<T>(value, min, max); return value; }
template <typename T, typename L> inline constexpr T lerp(T const & A, T const & B, L const & v) {
return static_cast<T>((static_cast<L>(1) - v) * A) + static_cast<T>(v * B);
}
template <typename T, typename F = double> [[nodiscard]] static T square_up(F in) {
return static_cast<T>(2) << static_cast<T>(std::floor(std::log2(in - static_cast<F>(1))));
}
[[nodiscard]] inline constexpr size_t hash_combine(size_t A, size_t B) {
return A + 0x9e3779b9 + (B << 6) + (B >> 2);
}
template <typename T> struct vec2;
template <typename T> struct vec3;
template <typename T> struct vec4;
template <typename T> struct mat3;
template <typename T> struct mat4;
template <typename T> struct quat;
// geometry.hh
template <typename T> struct plane;
}
| 50.282609 | 324 | 0.693904 | cagelight |
8d74c205be935844db79a870e0b23711764c2458 | 2,754 | cpp | C++ | test/cppdj_test.cpp | HenryBullingham/cppdj | 43db035102378c6982b66d405c7ba20f7f90b463 | [
"MIT"
] | null | null | null | test/cppdj_test.cpp | HenryBullingham/cppdj | 43db035102378c6982b66d405c7ba20f7f90b463 | [
"MIT"
] | null | null | null | test/cppdj_test.cpp | HenryBullingham/cppdj | 43db035102378c6982b66d405c7ba20f7f90b463 | [
"MIT"
] | null | null | null | // Copyright(C) 2020 Henry Bullingham
// This file is subject to the license terms in the LICENSE file
// found in the top - level directory of this distribution.
#include "catch.hpp"
#include "cppdj/cppdj.hpp"
class test_service
{
public:
bool return_true()
{
return true;
}
};
struct interface_base
{
virtual int return_val() = 0;
};
class interface_derived_a : public interface_base
{
virtual int return_val() override
{
return 5;
}
};
class interface_derived_b : public interface_base
{
virtual int return_val() override
{
return -7;
}
};
class test_service_injected
{
private:
cppdj::dep<test_service> m_service;
public:
bool return_true_and_service()
{
return true && m_service->return_true();
}
};
TEST_CASE("CPPDI", "[CPPDI]")
{
SECTION("Registration")
{
REQUIRE(cppdj::register_dep<test_service>());
REQUIRE_FALSE(cppdj::register_dep<test_service>()); // second registration should fail
REQUIRE(cppdj::unregister_dep<test_service>());
}
SECTION("Registration Base class")
{
REQUIRE(cppdj::register_dep<interface_base, interface_derived_a>());
REQUIRE_FALSE(cppdj::register_dep<interface_base, interface_derived_b>());
REQUIRE(cppdj::unregister_dep<interface_base>());
}
SECTION("Register and get dependency")
{
REQUIRE(cppdj::register_dep<test_service>());
cppdj::dep<test_service> service;
REQUIRE(&(*service) != nullptr);
REQUIRE(service->return_true());
REQUIRE(cppdj::unregister_dep<test_service>());
}
SECTION("Register base a and get dependency")
{
REQUIRE(cppdj::register_dep<interface_base, interface_derived_a>());
cppdj::dep<interface_base> service;
REQUIRE(&(*service) != nullptr);
REQUIRE(service->return_val() == 5);
REQUIRE(cppdj::unregister_dep<interface_base>());
}
SECTION("Register base b and get dependency")
{
REQUIRE(cppdj::register_dep<interface_base, interface_derived_b>());
cppdj::dep<interface_base> service;
REQUIRE(&(*service) != nullptr);
REQUIRE(service->return_val() == -7);
REQUIRE(cppdj::unregister_dep<interface_base>());
}
SECTION("Register two and inject")
{
REQUIRE(cppdj::register_dep<test_service>());
REQUIRE(cppdj::register_dep<test_service_injected>());
cppdj::dep<test_service_injected> injected;
REQUIRE(&(*injected) != nullptr);
REQUIRE(injected->return_true_and_service());
REQUIRE(cppdj::unregister_dep<test_service>());
REQUIRE(cppdj::unregister_dep<test_service_injected>());
}
} | 23.142857 | 94 | 0.648148 | HenryBullingham |
8d75124c7bb88e166a1d7c523c34c372e627d2f4 | 4,039 | cpp | C++ | Data Structures/Queues/ReversingQueueUsingStack.cpp | anjali9811/Programming-in-Cpp | 02e80e045a7fb20f8970fcdae68c08bdf27f95b8 | [
"Apache-2.0"
] | null | null | null | Data Structures/Queues/ReversingQueueUsingStack.cpp | anjali9811/Programming-in-Cpp | 02e80e045a7fb20f8970fcdae68c08bdf27f95b8 | [
"Apache-2.0"
] | null | null | null | Data Structures/Queues/ReversingQueueUsingStack.cpp | anjali9811/Programming-in-Cpp | 02e80e045a7fb20f8970fcdae68c08bdf27f95b8 | [
"Apache-2.0"
] | null | null | null | #include<iostream>
#include<stack>
using namespace std; //assigning std namespace to global namesapce
//a node has 2 fields -data and a pointer next -points or stores mem address of next node in list
struct Node {
int data;
Node *next;
};
class Queue {
public :
Node *front,*rear;
//front to store the address of first node, rear will store the address of last node
//constructor is called each time a object of class is build
Queue() {
front=rear=NULL;//initially both pointer null
}
void Enqueue(int n) ;
int Dequeue();
void display();
void ReverseQueue();
void showFront();
void showLast();
bool isEmpty();
void sortQueue();
};
void Queue::showFront() {
if(isEmpty()) {
cout<<"Queue is empty"<<endl;
}
else {
cout<<"First :"<<front->data<<endl;
}
}
void Queue::showLast() {
if(isEmpty()) {
cout<<"queue is empty"<<endl;
}
else {
cout<<"Last :"<<rear->data<<endl;
}
}
void Queue::Enqueue(int n) {
Node *temp = new Node(); //making a temp node
// cout<<"Enter data in queue"<<endl;
// cin>>n;
temp->data = n;
temp->next=NULL; //initiall temp is not connected to any node
if(isEmpty()){
//connect front and rear to temp if queue is empty
front=rear=temp;
}
//if not empty
//insert from rear end
rear->next=temp;
rear=temp;
}
int Queue::Dequeue()
{
Node *temp=front;//initially temp node points to front of queue-i.e first element
//if queue is empty
if(front == NULL) {
cout<<"Queue is Empty\n";
return 0;
cout<<endl;
}
//SPECIAL CASE-if queue has only one element-then front==rear
else if(front == rear) {
front = rear = NULL;//now queue is empty , so both as NULL
}
//delete node from front end
else {
front=front->next; //front now points to its next immediate node
}
//cout<<"deleted element from front is : "<<temp->data<<endl;
return(temp->data);
//deallocating memory to the temp node
delete(temp);
}
bool Queue::isEmpty() {
if(front==NULL && rear==NULL) {
return true;
}
else {
return false;
}
}
void Queue::display() {
Node *temp=front; //starting from front
//if empty
if(isEmpty()) cout<<"ERROR, Queue is empty"<<endl;
//until temp is not NULL
while(temp != NULL) {
cout<<temp->data<<"\t";
temp=temp->next; //increment temp
}
cout<<"\n";
}
//we will use a stack to Reverse a Queue-
void Queue::ReverseQueue() {
stack<int>s;
//until Queue is not empty-Push dequeued elements from Queue to stack
if(isEmpty()) {
cout<<"Queue is Empty,cannot reverse "<<endl;
return;
}
while(!isEmpty()) {
//PUSH to STACK
s.push(Dequeue());
}
//Now Until Stack is not empty, Enqueue the popped elements from top of Stack to Queue
while(!s.empty()) {
//calling Enqueue function with top of stack as argument
Enqueue(s.top()); //inserting top element of stack to queue
s.pop();//deleting from top of stack
}
cout<<"Reversed the queue--:"<<endl;
//The queue now has elemens in reversed order
}
void Queue::sortQueue() {
Node *temp=front;
Node *sort=NULL;
while(temp!=NULL) {
if(temp->data <= temp->next->data) {
sort=temp;
temp=sort->next;
cout<<temp->data<<"\t";
}
else {
cout<<temp->data<<"\t";
temp=temp->next;
}
}
}
int main() {
Queue q; //object to access and use stack operation methods
int choice;
int data;
while(1) {
cout<<"\n1)Insert\n2)Delete\n3)Display\n4)Reverse Queue\n5)Show Front\n6)Show last\n7)Sort Queue\n8)Exit\n"<<endl;
cin>>choice;
switch(choice) {
case 1:
cin>>data;
q.Enqueue(data);
break;
case 2:
cout<<q.Dequeue()<<endl;;
break;
case 3:
q.display();
break;
case 4:
q.ReverseQueue();
break;
case 5:
q.showFront();
break;
case 6:
q.showLast();
break;
case 7:
q.sortQueue();
break;
default:
exit(0);//to exit the entire program
break;
}
} //end while
return 0;
}
| 17.637555 | 116 | 0.611538 | anjali9811 |
8d786704c1b56c4f292afd9057fe817f75ac5c6d | 2,572 | hpp | C++ | src/Globals.hpp | jakobkilian/unfolding-space | 1ba03e156680e1b455b4164d12177fae52c68356 | [
"MIT"
] | 5 | 2020-10-28T05:51:27.000Z | 2022-02-28T07:48:38.000Z | src/Globals.hpp | jakobkilian/unfolding-space | 1ba03e156680e1b455b4164d12177fae52c68356 | [
"MIT"
] | null | null | null | src/Globals.hpp | jakobkilian/unfolding-space | 1ba03e156680e1b455b4164d12177fae52c68356 | [
"MIT"
] | null | null | null | #pragma once
#include <boost/asio.hpp>
#include <mutex>
#include <opencv2/opencv.hpp>
#include <royale.hpp>
#include "Camera.hpp"
#include "i2c/I2C.hpp"
#include "i2c/Imu.hpp"
#include "MotorBoard.hpp"
#include "TimeLogger.hpp"
#include "UdpServer.hpp"
#include "Led.hpp"
struct Base {
std::mutex mut;
};
// camera status
struct RoyalStatus {
std::atomic<bool> a_isConnected{false};
std::atomic<bool> a_isCapturing{false};
std::atomic<bool> a_isCalibrated{false};
std::atomic<bool> a_isCalibRunning{false};
std::atomic<int> a_libraryCrashCounter{0};
};
struct Modes {
std::atomic<int> a_identifier{0}; //set by cmd line option. Identifier for udp server
std::atomic<bool> a_muted;
std::atomic<bool> a_testMode;
std::atomic<bool> a_isInActivePos{true};
std::atomic<bool> a_doLog{
true}; // gobal flag that activates TimeLogger.cpp functions – currently
// always on because of dependencies of msSinceEntry
std::atomic<bool> a_doLogPrint{false}; // printf all TimeLogger values –
std::atomic<unsigned int> a_cameraUseCase{3};
};
struct Motors : Base {
unsigned char testTiles[9];
unsigned char tiles[9]; // 9 tiles | motor valsˇ
};
struct Logger : Base {
TimeLogger newDataLog;
TimeLogger mainLogger;
TimeLogger motorSendLog;
TimeLogger pauseLog;
TimeLogger imuLog;
};
struct CvDepthImg : Base {
cv::Mat mat; // full depth image (one byte p. pixel)
};
struct RoyalDepthData : Base {
royale::DepthData dat;
};
struct ThreadNotification : Base {
std::condition_variable cond;
bool flag{false};
};
struct Counters {
std::atomic<long> frameCounter;
};
// Everything goes in the namespace "Glob"
namespace Glob {
// protection needed?
extern std::mutex udpServMux;
extern boost::asio::io_service udpService;
extern UdpServer udpServer;
extern std::mutex motorBoardMux;
extern MotorBoard motorBoard;
extern std::mutex i2cMux;
extern I2C i2c;
extern std::mutex imuMux;
extern Imu imu;
extern Led led1;
extern Led led2;
// Counts when there is onNewData() while the previous wasn't finished yet.
// We don't want this -> royal library gets unstable
extern std::atomic<int> a_lockFailCounter;
extern std::atomic<bool> a_restartUnfoldingFlag;
// INIT ALL STRUCTS
extern RoyalStatus royalStats;
extern Modes modes;
extern Motors motors;
extern Logger logger;
extern CvDepthImg cvDepthImg;
extern RoyalDepthData royalDepthData;
extern ThreadNotification notifyProcess;
extern ThreadNotification notifySend;
extern Counters counters;
void printBinary(uint8_t a, bool lineBreak);
} // namespace Glob
| 23.814815 | 87 | 0.744168 | jakobkilian |
8d786c975419b9a32a3b1112ce146e5295f043e1 | 1,292 | cpp | C++ | AbsoluteTouch/AbsoluteTouchCallback.cpp | honguyenminh/AbsoluteTouch | f90a1cda9d148c34b0febb2e39b7440e55ecf7a9 | [
"MIT"
] | 32 | 2016-07-18T16:05:52.000Z | 2021-07-13T08:04:24.000Z | AbsoluteTouch/AbsoluteTouchCallback.cpp | honguyenminh/AbsoluteTouch | f90a1cda9d148c34b0febb2e39b7440e55ecf7a9 | [
"MIT"
] | 8 | 2016-08-02T03:21:35.000Z | 2018-11-25T18:12:00.000Z | AbsoluteTouch/AbsoluteTouchCallback.cpp | honguyenminh/AbsoluteTouch | f90a1cda9d148c34b0febb2e39b7440e55ecf7a9 | [
"MIT"
] | 12 | 2017-03-19T03:56:43.000Z | 2022-03-22T00:46:52.000Z | #include "AbsoluteTouchCallback.h"
#include "Containers.h"
#include "CoordinateMapper.h"
#include "InputHelper.h"
#include "TouchProcessor.h"
#include "TouchpadManager.h"
void AbsoluteTouchCallback::SetTouchpadRect(Rect<long> touchpadRect)
{
m_coordMapper.SetTouchpadRect(touchpadRect);
}
void AbsoluteTouchCallback::SetScreenRect(Rect<long> screenRect)
{
m_coordMapper.SetScreenRect(screenRect);
}
void AbsoluteTouchCallback::SetSmoothingWeight(int weight)
{
m_touchProcessor.SetWeight(weight);
}
void AbsoluteTouchCallback::SetSendClick(bool sendClick)
{
m_sendClick = sendClick;
}
void AbsoluteTouchCallback::OnTouchStarted(Point<long> touchPt)
{
Point<long> screenPt = TouchToScreen(touchPt);
if (m_sendClick) {
SendLeftDown(screenPt);
} else {
MoveCursor(screenPt);
}
}
void AbsoluteTouchCallback::OnTouchMoved(Point<long> touchPt)
{
MoveCursor(TouchToScreen(touchPt));
}
void AbsoluteTouchCallback::OnTouchEnded()
{
if (m_sendClick) {
SendLeftUp();
}
m_touchProcessor.TouchEnded();
}
Point<long> AbsoluteTouchCallback::TouchToScreen(Point<long> touchPt)
{
Point<long> avgPt = m_touchProcessor.Update(touchPt);
Point<long> screenPt = m_coordMapper.TouchToScreenCoords(avgPt);
return screenPt;
}
| 22.666667 | 69 | 0.747678 | honguyenminh |
8d7d640b0545c43163c0970ad22ba6db9881e55c | 3,334 | cpp | C++ | test/backend-test.cpp | UCLA-IRL/Mnemosyne | a5818955fae76f6ca496fd6158c9da52c9440a95 | [
"Apache-2.0"
] | 2 | 2021-12-21T01:14:44.000Z | 2022-01-01T22:01:27.000Z | test/backend-test.cpp | UCLA-IRL/Mnemosyne | a5818955fae76f6ca496fd6158c9da52c9440a95 | [
"Apache-2.0"
] | null | null | null | test/backend-test.cpp | UCLA-IRL/Mnemosyne | a5818955fae76f6ca496fd6158c9da52c9440a95 | [
"Apache-2.0"
] | 1 | 2021-11-22T01:50:32.000Z | 2021-11-22T01:50:32.000Z | #include "mnemosyne/backend.hpp"
#include <ndn-cxx/name.hpp>
#include <iostream>
#include <ndn-cxx/security/signature-sha256-with-rsa.hpp>
using namespace mnemosyne;
std::shared_ptr<ndn::Data>
makeData(const std::string& name, const std::string& content)
{
using namespace ndn;
using namespace std;
auto data = make_shared<Data>(ndn::Name(name));
data->setContent((const uint8_t*)content.c_str(), content.size());
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::encoding::makeEmptyBlock(tlv::SignatureValue));
data->setSignature(fakeSignature);
data->wireEncode();
return data;
}
bool
testBackEnd()
{
Backend backend("/tmp/test.leveldb");
for (const auto &name : backend.listRecord("")) {
backend.deleteRecord(name);
}
auto data = makeData("/mnemosyne/12345", "content is 12345");
auto fullName = data->getFullName();
backend.putRecord(data);
auto anotherRecord = backend.getRecord(fullName);
if (data == nullptr || anotherRecord == nullptr) {
return false;
}
return backend.listRecord(Name("/mnemosyne")).size() == 1 && data->wireEncode() == anotherRecord->wireEncode();
}
bool
testBackEndList() {
Backend backend("/tmp/test-List.leveldb");
for (const auto &name : backend.listRecord("")) {
backend.deleteRecord(name);
}
for (int i = 0; i < 10; i++) {
backend.putRecord(makeData("/mnemosyne/a/" + std::to_string(i), "content is " + std::to_string(i)));
backend.putRecord(makeData("/mnemosyne/ab/" + std::to_string(i), "content is " + std::to_string(i)));
backend.putRecord(makeData("/mnemosyne/b/" + std::to_string(i), "content is " + std::to_string(i)));
}
backend.putRecord(makeData("/mnemosyne/a", "content is "));
backend.putRecord(makeData("/mnemosyne/ab", "content is "));
backend.putRecord(makeData("/mnemosyne/b", "content is "));
assert(backend.listRecord(Name("/mnemosyne")).size() == 33);
assert(backend.listRecord(Name("/mnemosyne/a")).size() == 11);
assert(backend.listRecord(Name("/mnemosyne/ab")).size() == 11);
assert(backend.listRecord(Name("/mnemosyne/b")).size() == 11);
assert(backend.listRecord(Name("/mnemosyne/a/5")).size() == 1);
assert(backend.listRecord(Name("/mnemosyne/ab/5")).size() == 1);
assert(backend.listRecord(Name("/mnemosyne/b/5")).size() == 1);
assert(backend.listRecord(Name("/mnemosyne/a/55")).empty());
assert(backend.listRecord(Name("/mnemosyne/ab/55")).empty());
assert(backend.listRecord(Name("/mnemosyne/b/55")).empty());
return true;
}
bool
testNameGet()
{
std::string name1 = "name1";
ndn::Name name2("/mnemosyne/name1/123");
if (name2.get(-2).toUri() == name1) {
return true;
}
return false;
}
int
main(int argc, char** argv)
{
auto success = testBackEnd();
if (!success) {
std::cout << "testBackEnd failed" << std::endl;
}
else {
std::cout << "testBackEnd with no errors" << std::endl;
}
success = testBackEndList();
if (!success) {
std::cout << "testBackEndList failed" << std::endl;
}
else {
std::cout << "testBackEndList with no errors" << std::endl;
}
success = testNameGet();
if (!success) {
std::cout << "testNameGet failed" << std::endl;
}
else {
std::cout << "testNameGet with no errors" << std::endl;
}
return 0;
} | 31.45283 | 113 | 0.65087 | UCLA-IRL |
8d7df5f90a9fcb27caabee9e57a6ed6c2b121e9d | 3,418 | cpp | C++ | lib/ome/files/module.cpp | rleigh-dundee/bioformats-cpp | e8e3c03cab4d00edb96f40aa2b86bc7c99d6588c | [
"BSD-2-Clause"
] | 5 | 2017-12-11T16:23:16.000Z | 2019-08-13T18:32:27.000Z | lib/ome/files/module.cpp | rleigh-dundee/bioformats-cpp | e8e3c03cab4d00edb96f40aa2b86bc7c99d6588c | [
"BSD-2-Clause"
] | 83 | 2016-02-28T19:29:11.000Z | 2019-02-21T08:52:37.000Z | lib/ome/files/module.cpp | rleigh-dundee/bioformats-cpp | e8e3c03cab4d00edb96f40aa2b86bc7c99d6588c | [
"BSD-2-Clause"
] | 13 | 2016-02-26T17:18:15.000Z | 2020-04-22T00:40:59.000Z | /*
* #%L
* OME-FILES C++ library for image IO.
* %%
* Copyright © 2016 Open Microscopy Environment:
* - Massachusetts Institute of Technology
* - National Institutes of Health
* - University of Dundee
* - Board of Regents of the University of Wisconsin-Madison
* - Glencoe Software, Inc.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of any organization.
* #L%
*/
#include <ome/files/config-internal.h>
#define OME_COMMON_MODULE_INTROSPECTION 1
#include <ome/common/module.h>
#include <ome/xml/module.h>
#include <ome/files/module.h>
namespace
{
using ome::common::RegisterModule;
void register_paths()
{
// OME-Files package-specific paths.
static RegisterModule ome_files_data
("ome-files-data",
"OME_FILES_PKGDATADIR",
"OME_FILES_HOME",
"OME_HOME",
OME_FILES_INSTALL_FULL_PKGDATADIR,
OME_FILES_INSTALL_PKGDATADIR,
OME_FILES_INSTALL_PREFIX,
OME_FILES_SHLIBDIR,
module_path);
// OME-Files package-specific paths.
static RegisterModule ome_files_doc
("ome-files-doc",
"OME_FILES_DOCDIR",
"OME_FILES_HOME",
"OME_HOME",
OME_FILES_INSTALL_FULL_DOCDIR,
OME_FILES_INSTALL_DOCDIR,
OME_FILES_INSTALL_PREFIX,
OME_FILES_SHLIBDIR,
module_path);
static RegisterModule ome_files_libexec
("ome-files-libexec",
"OME_FILES_PKGLIBEXECDIR",
"OME_FILES_HOME",
"OME_HOME",
OME_FILES_INSTALL_FULL_PKGLIBEXECDIR,
OME_FILES_INSTALL_PKGLIBEXECDIR,
OME_FILES_INSTALL_PREFIX,
OME_FILES_SHLIBDIR,
module_path);
}
struct AutoRegister
{
AutoRegister()
{
register_paths();
}
};
AutoRegister path_register;
}
namespace ome
{
namespace files
{
void
register_module_paths()
{
ome::common::register_module_paths();
ome::xml::register_module_paths();
register_paths();
}
}
}
| 29.721739 | 79 | 0.713868 | rleigh-dundee |
8d806b206dedb85c507b42078be02247ff693d3a | 1,030 | cpp | C++ | libs/sge_renderer/src/sge_renderer/renderer/renderer.cpp | Alekssasho/sge_source | 2db4ae08f7b3434d32dd9767fe1136234cb70b83 | [
"MIT"
] | null | null | null | libs/sge_renderer/src/sge_renderer/renderer/renderer.cpp | Alekssasho/sge_source | 2db4ae08f7b3434d32dd9767fe1136234cb70b83 | [
"MIT"
] | null | null | null | libs/sge_renderer/src/sge_renderer/renderer/renderer.cpp | Alekssasho/sge_source | 2db4ae08f7b3434d32dd9767fe1136234cb70b83 | [
"MIT"
] | null | null | null | #include "renderer.h"
namespace sge {
#if 0
template<typename T>
T* SGEDevice::requestResource()
{
sgeAssert(false);
return nullptr;
}
#endif
#define SGE_Impl_request_resource(T, RT) \
template <> \
T* SGEDevice::requestResource<T>() { \
return static_cast<T*>(requestResource(RT)); \
}
SGE_Impl_request_resource(Buffer, ResourceType::Buffer);
SGE_Impl_request_resource(Texture, ResourceType::Texture);
SGE_Impl_request_resource(FrameTarget, ResourceType::FrameTarget);
SGE_Impl_request_resource(Shader, ResourceType::Shader);
SGE_Impl_request_resource(ShadingProgram, ResourceType::ShadingProgram);
SGE_Impl_request_resource(RasterizerState, ResourceType::RasterizerState);
SGE_Impl_request_resource(DepthStencilState, ResourceType::DepthStencilState);
SGE_Impl_request_resource(BlendState, ResourceType::BlendState);
SGE_Impl_request_resource(SamplerState, ResourceType::Sampler);
SGE_Impl_request_resource(Query, ResourceType::Query);
} // namespace sge
| 32.1875 | 78 | 0.767961 | Alekssasho |
8d86cfb4ad2ef883d5b0324eb54eb1689cb3439a | 9,568 | cpp | C++ | NOLF/ClientShellDLL/IpMgr.cpp | haekb/nolf1-modernizer | 25bac3d43c40a83b8e90201a70a14ef63b4240e7 | [
"Unlicense"
] | 38 | 2019-09-16T14:46:42.000Z | 2022-03-10T20:28:10.000Z | NOLF/ClientShellDLL/IpMgr.cpp | haekb/nolf1-modernizer | 25bac3d43c40a83b8e90201a70a14ef63b4240e7 | [
"Unlicense"
] | 39 | 2019-08-12T01:35:33.000Z | 2022-02-28T16:48:16.000Z | NOLF/ClientShellDLL/IpMgr.cpp | haekb/nolf1-modernizer | 25bac3d43c40a83b8e90201a70a14ef63b4240e7 | [
"Unlicense"
] | 6 | 2019-09-17T12:49:18.000Z | 2022-03-10T20:28:12.000Z | /****************************************************************************
;
; MODULE: IPMGR (.CPP)
;
; PURPOSE: IP Manager Classes
;
; HISTORY: 11/09/98 [blg] This file was created
;
; COMMENT: Copyright (c) 1998, Monolith Productions Inc.
;
****************************************************************************/
// Includes...
#include "stdafx.h"
#include "iltclient.h"
#include "IpMgr.h"
// Functions...
/* *********************************************************************** */
/* CIp */
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIp::Init
//
// PURPOSE: Initialization
//
// ----------------------------------------------------------------------- //
BOOL CIp::Init(char* sIp)
{
// Sanity checks...
if (!sIp) return(FALSE);
if (sIp[0] == '\0') return(FALSE);
// Set simple members...
strncpy(m_sIp, sIp, IPM_MAX_ADDRESS);
// All done...
return(TRUE);
}
/* *********************************************************************** */
/* CIpMgr */
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::Init
//
// PURPOSE: Initialization
//
// ----------------------------------------------------------------------- //
BOOL CIpMgr::Init(ILTClient* pClientDE)
{
// Sanity checks...
if (!pClientDE) return(FALSE);
// Set simple members...
Clear();
m_pClientDE = pClientDE;
// All done...
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::Term
//
// PURPOSE: Termination
//
// ----------------------------------------------------------------------- //
void CIpMgr::Term()
{
// Delete all the ips...
for (int i = 0; i < m_cIps; i++)
{
CIp* pIp = GetIp(i);
if (pIp)
{
debug_delete(pIp);
}
}
Clear();
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::ExistIp
//
// PURPOSE: Determines if the given ip exists
//
// ----------------------------------------------------------------------- //
BOOL CIpMgr::ExistIp(char* sIp)
{
// Sanity checks...
if (!sIp) return(FALSE);
// Loop through each ip...
for (int i = 0; i < m_cIps; i++)
{
CIp* pIp = GetIp(i);
if (pIp)
{
if (strcmp(sIp, pIp->GetAddress()) == 0)
{
return(TRUE);
}
}
}
// If we get here, the ip doesn't exist...
return(FALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::AddIp
//
// PURPOSE: Adds the given ip
//
// ----------------------------------------------------------------------- //
BOOL CIpMgr::AddIp(char* sIp)
{
// Sanity checks...
if (!sIp) return(FALSE);
// Make sure this ip doesn't already exist...
if (ExistIp(sIp)) return(TRUE);
// Make sure there is room to add this ip...
if (m_cIps >= IPM_MAX_IPS) return(FALSE);
// Create a new ip...
CIp* pIp = debug_new(CIp);
if (!pIp) return(FALSE);
if (!pIp->Init(sIp))
{
debug_delete(pIp);
return(FALSE);
}
// Add this ip...
m_aIps[m_cIps++] = pIp;
// All done...
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::RemoveIp
//
// PURPOSE: Removes the given ip
//
// ----------------------------------------------------------------------- //
BOOL CIpMgr::RemoveIp(char* sIp)
{
// Sanity checks...
if (!sIp) return(FALSE);
// Loop through each ip...
for (int i = 0; i < m_cIps; i++)
{
CIp* pIp = GetIp(i);
if (pIp)
{
if (strcmp(sIp, pIp->GetAddress()) == 0)
{
// Delete this ip...
debug_delete(pIp);
// Shift the array...
for (int j = i + 1; j < m_cIps; j++)
{
m_aIps[j-1] = m_aIps[j];
}
m_cIps--;
// All done removing the ip...
return(TRUE);
}
}
}
// If we get here, the ip doesn't exist so we can't remove it...
return(FALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::GetAllIpString
//
// PURPOSE: Returns a big huge string with all the ip addresses
// sperated by semi-colons.
//
// ----------------------------------------------------------------------- //
BOOL CIpMgr::GetAllIpString(char* sBuf, int nBufSize)
{
// Sanity checks...
if (!sBuf) return(FALSE);
if (nBufSize <= 0) return(FALSE);
// Start building the string, making sure we don't over-run the buffer...
int nTotalSize = 0;
strcpy(sBuf, "");
for (int i = 0; i < m_cIps; i++)
{
CIp* pIp = GetIp(i);
if (pIp)
{
char* sIp = pIp->GetAddress();
if (sIp)
{
int nLen = strlen(sIp);
if (nTotalSize + nLen + 2 < nBufSize)
{
if (nTotalSize > 0) strcat(sBuf, ";");
strcat(sBuf, sIp);
nTotalSize = strlen(sBuf);
}
}
}
}
// All done...
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::FillListBox
//
// PURPOSE: Fills the given list box with all the ips
//
// ----------------------------------------------------------------------- //
int CIpMgr::FillListBox(HWND hList)
{
// Sanity checks...
if (!hList) return(0);
// Empty the list box...
SendMessage(hList, LB_RESETCONTENT, 0, 0);
// Add each ip...
SendMessage(hList, WM_SETREDRAW, 0, 0);
int cIps = 0;
for (int i = 0; i < m_cIps; i++)
{
CIp* pIp = GetIp(i);
if (pIp)
{
int nRet = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)pIp->GetAddress());
if (nRet != LB_ERR) cIps++;
}
}
SendMessage(hList, WM_SETREDRAW, 1, 0);
InvalidateRect(hList, NULL, FALSE);
UpdateWindow(hList);
// All done...
return(cIps);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::AddIpFromEditControl
//
// PURPOSE: Adds a new ip from the given edit control
//
// COMMENT: This function will update a list box if one is given
//
// ----------------------------------------------------------------------- //
BOOL CIpMgr::AddIpFromEditControl(HWND hEdit, HWND hList)
{
// Sanity checks...
if (!hEdit) return(FALSE);
// Get the text from the edit control...
char sIp[IPM_MAX_ADDRESS + 2];
int nLen = GetWindowText(hEdit, sIp, IPM_MAX_ADDRESS);
if (nLen <= 0) return(FALSE);
// Add the ip...
if (!AddIp(sIp))
{
return(FALSE);
}
// Empty the edit control...
SetWindowText(hEdit, "");
// Fill the list box if one was specified...
FillListBox(hList);
// All done...
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::RemoveSelectedIpFromListBox
//
// PURPOSE: Removes the currently selected ip from the given list box
//
// ----------------------------------------------------------------------- //
BOOL CIpMgr::RemoveSelectedIpFromListBox(HWND hList)
{
// Sanity checks...
if (!hList) return(FALSE);
// Get the currently selected ip text from the list box...
int iSel = SendMessage(hList, LB_GETCURSEL, 0, 0);
if (iSel == LB_ERR) return(FALSE);
char sIp[IPM_MAX_ADDRESS + 2];
int nRet = SendMessage(hList, LB_GETTEXT, iSel, (LPARAM)sIp);
if (nRet == LB_ERR) return(FALSE);
// Remove the ip from our array...
RemoveIp(sIp);
// Remove the ip from the list box...
SendMessage(hList, LB_DELETESTRING, iSel, 0);
// All done...
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::RemoveAll
//
// PURPOSE: Removes all of the ips
//
// ----------------------------------------------------------------------- //
void CIpMgr::RemoveAll()
{
// Delete all the ips...
for (int i = 0; i < m_cIps; i++)
{
CIp* pIp = GetIp(i);
if (pIp)
{
debug_delete(pIp);
}
}
Clear(FALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::WriteIps
//
// PURPOSE: Writes the ip addresses to the config file
//
// ----------------------------------------------------------------------- //
int CIpMgr::WriteIps()
{
// Sanity checks...
if (!m_pClientDE) return(0);
// Write each ip address...
char sKey[64];
char sTemp[512];
int cIps = 0;
for (int i = 0; i < m_cIps; i++)
{
CIp* pIp = GetIp(i);
if (pIp)
{
wsprintf(sKey, "Ip%i", i);
wsprintf(sTemp, "+%s %s", sKey, pIp->GetAddress());
m_pClientDE->RunConsoleString(sTemp);
cIps++;
}
}
// Write out the count...
wsprintf(sTemp, "+IpCount %i", cIps);
m_pClientDE->RunConsoleString(sTemp);
// All done...
return(cIps);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CIpMgr::ReadIps
//
// PURPOSE: Reads the ip addresses from the config file
//
// ----------------------------------------------------------------------- //
int CIpMgr::ReadIps()
{
// Sanity checks...
if (!m_pClientDE) return(0);
// Read the ip address count value...
int cIps = 0;
HCONSOLEVAR hVar = m_pClientDE->GetConsoleVar("IpCount");
if (hVar)
{
cIps = (int)m_pClientDE->GetVarValueFloat(hVar);
}
if (cIps <= 0) return(0);
// Read each ip address...
char sKey[64];
int count = 0;
for (int i = 0; i < cIps; i++)
{
wsprintf(sKey, "Ip%i", i);
HCONSOLEVAR hVar = m_pClientDE->GetConsoleVar(sKey);
if (hVar)
{
char* sValue = m_pClientDE->GetVarValueString(hVar);
if (sValue)
{
if (AddIp(sValue)) count++;
}
}
}
// All done...
return(count);
}
| 17.055258 | 80 | 0.443562 | haekb |
8d9134d27d6d664ccd8d3ca612a8363ec57bfe5f | 45 | cpp | C++ | src/geometry.cpp | MDkil/basketball-game-opengl | 4b32bf1943a15de8bab353728868befd38975b84 | [
"MIT"
] | null | null | null | src/geometry.cpp | MDkil/basketball-game-opengl | 4b32bf1943a15de8bab353728868befd38975b84 | [
"MIT"
] | null | null | null | src/geometry.cpp | MDkil/basketball-game-opengl | 4b32bf1943a15de8bab353728868befd38975b84 | [
"MIT"
] | null | null | null | #include <cmath>
#include "geometry.h"
| 9 | 22 | 0.622222 | MDkil |
8d91dcf6c28fa8f3f45f3d7c9363c92543f17821 | 11,908 | cpp | C++ | Src/lunaui/launcher/elements/buttons/pixbutton.cpp | ericblade/luna-sysmgr | 82d5d7ced4ba21d3802eb2c8ae063236b6562331 | [
"Apache-2.0"
] | 3 | 2018-11-16T14:51:17.000Z | 2019-11-21T10:55:24.000Z | Src/lunaui/launcher/elements/buttons/pixbutton.cpp | penk/luna-sysmgr | 60c7056a734cdb55a718507f3a739839c9d74edf | [
"Apache-2.0"
] | 1 | 2021-02-20T13:12:15.000Z | 2021-02-20T13:12:15.000Z | Src/lunaui/launcher/elements/buttons/pixbutton.cpp | ericblade/luna-sysmgr | 82d5d7ced4ba21d3802eb2c8ae063236b6562331 | [
"Apache-2.0"
] | null | null | null | /* @@@LICENSE
*
* Copyright (c) 2011-2012 Hewlett-Packard Development Company, L.P.
*
* 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.
*
* LICENSE@@@ */
#include "dimensionsglobal.h"
#include "pixbutton.h"
#include "pixmapobject.h"
#include "layoutsettings.h"
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include <QString>
#include <QDebug>
#include <QTextOption>
#include <QEvent>
#include <QGesture>
#include <QGestureEvent>
#ifdef TARGET_DEVICE
#include <FlickGesture.h>
#include <SysMgrDefs.h>
#else
#include <FlickGesture.h>
#endif
#include "Settings.h"
QFont PixButton::s_standardButtonFont = QFont();
QFont PixButton::staticLabelFontForButtons()
{
//TODO: specify a proper font
static bool fontInitialized = false;
if (!fontInitialized)
{
s_standardButtonFont = QFont(QString::fromStdString(Settings::LunaSettings()->fontQuicklaunch));
quint32 fontSize = qBound((quint32)2,LayoutSettings::settings()->doneButtonFontSizePx,(quint32)100);
s_standardButtonFont.setPixelSize(fontSize);
s_standardButtonFont.setBold(LayoutSettings::settings()->doneButtonFontEmbolden);
}
return s_standardButtonFont;
}
PixButton::PixButton(const QRectF& buttonGeometry)
: ThingPaintable(buttonGeometry)
, m_trackingTouch(false)
, m_touchCount(0)
, m_labelVerticalAdjust(0)
{
setAcceptTouchEvents(true);
grabGesture(Qt::TapGesture);
}
//virtual
PixButton::~PixButton()
{
}
//virtual
bool PixButton::resize(const QSize& s)
{
//TODO: IMPLEMENT
return true;
}
//virtual
bool PixButton::resize(quint32 newWidth,quint32 newHeight)
{
return resize(QSize(newWidth,newHeight));
}
//virtual
void PixButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
{
}
//virtual
void PixButton::paintOffscreen(QPainter * painter)
{
}
//virtual
bool PixButton::valid()
{
return false;
}
//virtual
void PixButton::setLabel(const QString& v)
{
m_label = v;
m_textFont = PixButton::staticLabelFontForButtons();
m_selectedColor = LayoutSettings::settings()->tabBarSelectedTabFontColor;
m_unselectedColor = LayoutSettings::settings()->doneButtonFontColor;
recalculateLabelBoundsForCurrentGeom();
redoLabelTextLayout();
recalculateLabelPosition();
update();
}
//virtual
void PixButton::setLabel(const QString& v,quint32 fontSizePx)
{
m_label = v;
m_textFont = PixButton::staticLabelFontForButtons();
quint32 fontSize = qBound((quint32)2,fontSizePx,(quint32)100);
s_standardButtonFont.setPixelSize(fontSize);
m_selectedColor = LayoutSettings::settings()->tabBarSelectedTabFontColor;
m_unselectedColor = LayoutSettings::settings()->doneButtonFontColor;
recalculateLabelBoundsForCurrentGeom();
redoLabelTextLayout();
recalculateLabelPosition();
update();
}
//virtual
void PixButton::setLabelVerticalAdjust(qint32 adjustPx)
{
m_labelVerticalAdjust = adjustPx;
m_textFont = PixButton::staticLabelFontForButtons();
m_selectedColor = LayoutSettings::settings()->tabBarSelectedTabFontColor;
m_unselectedColor = LayoutSettings::settings()->doneButtonFontColor;
recalculateLabelBoundsForCurrentGeom();
redoLabelTextLayout();
recalculateLabelPosition();
update();
}
//protected Q_SLOTS:
//virtual
void PixButton::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
event->accept(); //prevent leakage to others
}
//virtual
void PixButton::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
}
//virtual
void PixButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
}
//protected:
//virtual
bool PixButton::sceneEvent(QEvent * event)
{
if (event->type() == QEvent::GestureOverride) {
QGestureEvent* ge = static_cast<QGestureEvent*>(event);
ge->accept();
return true;
}
else if (event->type() == QEvent::Gesture) {
QGestureEvent* ge = static_cast<QGestureEvent*>(event);
QGesture * g = 0;
g = ge->gesture(Qt::TapGesture);
if (g) {
QTapGesture* tap = static_cast<QTapGesture*>(g);
if (tap->state() == Qt::GestureFinished) {
tapGesture(tap);
}
return true;
}
g = ge->gesture(Qt::TapAndHoldGesture);
if (g) {
QTapAndHoldGesture* hold = static_cast<QTapAndHoldGesture*>(g);
if (hold->state() == Qt::GestureFinished) {
tapAndHoldGesture(hold);
}
return true;
}
}
else if (event->type() == QEvent::TouchBegin)
{
return touchStartEvent(static_cast<QTouchEvent *>(event));
}
else if (event->type() == QEvent::TouchUpdate)
{
return touchUpdateEvent(static_cast<QTouchEvent *>(event));
}
else if (event->type() == QEvent::TouchEnd)
{
return touchEndEvent(static_cast<QTouchEvent *>(event));
}
return QGraphicsObject::sceneEvent(event);
}
//virtual
bool PixButton::touchStartEvent(QTouchEvent *event)
{
// ++m_touchCount;
// if (m_touchCount == 1)
// {
// Q_EMIT signalFirstContact();
// }
// else
// {
// Q_EMIT signalContact();
// }
// return true;
event->accept();
if (m_trackingTouch)
{
//already tracking a touch point.
//consume and ignore
return true;
}
m_trackingTouch = true;
Q_EMIT signalFirstContact();
m_trackingTouchId = event->touchPoints().first().id();
return true;
}
//virtual
bool PixButton::touchUpdateEvent(QTouchEvent *event)
{
if (!m_trackingTouch)
{
return true;
}
//dig out the tracked point
QList<QTouchEvent::TouchPoint> tlist = event->touchPoints();
for (QList<QTouchEvent::TouchPoint>::const_iterator it = tlist.constBegin();
it != tlist.constEnd();++it)
{
if (it->id() == m_trackingTouchId)
{
//check the position. if it's left the button bounds, cancel it all
if (!boundingRect().contains(it->pos()))
{
m_trackingTouch = false;
Q_EMIT signalCancel();
return true;
}
}
}
return true;
}
//virtual
bool PixButton::touchEndEvent(QTouchEvent *event)
{
// --m_touchCount;
// if (m_touchCount <= 0)
// {
// m_touchCount = 0;
// Q_EMIT signalLastRelease();
// }
// else
// {
// Q_EMIT signalRelease();
// }
// return true;
if (!m_trackingTouch)
{
return true;
}
//dig out the tracked point
QList<QTouchEvent::TouchPoint> tlist = event->touchPoints();
for (QList<QTouchEvent::TouchPoint>::const_iterator it = tlist.constBegin();
it != tlist.constEnd();++it)
{
if (it->id() == m_trackingTouchId)
{
//check the position. if it's left the button bounds, don't send release
if (boundingRect().contains(it->pos()))
{
//send release
Q_EMIT signalLastRelease();
}
else
{
//send cancel
Q_EMIT signalCancel();
}
m_trackingTouch = false;
return true;
}
}
return true;
}
//virtual
bool PixButton::tapAndHoldGesture(QTapAndHoldGesture *tapHoldEvent)
{
if (!m_trackingTouch)
{
return true;
}
Q_EMIT signalContact();
Q_EMIT signalActivated();
return true;
}
//virtual
bool PixButton::tapGesture(QTapGesture *tapEvent)
{
if (!m_trackingTouch)
{
return true;
}
Q_EMIT signalContact();
Q_EMIT signalActivated();
return true;
}
//virtual
bool PixButton::customGesture(QGesture *customGesture)
{
return true;
}
//virtual
void PixButton::recalculateLabelBoundsForCurrentGeom()
{
//the label geom is the next smallest even integer in height and width from m_geom.
// if that int is 0 in either case, then it's == m_geom's w or h
quint32 gw = DimensionsGlobal::roundDown(m_geom.width());
quint32 gh = DimensionsGlobal::roundDown(m_geom.height());
QSize s = QSize(
( gw < 2 ? gw : ( gw - (gw % 2))),
( gh < 2 ? gh : ( gh - (gh % 2))));
m_labelMaxGeom = DimensionsGlobal::realRectAroundRealPoint(s).toRect();
}
//virtual
void PixButton::redoLabelTextLayout()
{
//TODO: somewhat wasteful. If there is no label, should just exit early and leave a layout that will be left unrendered by paint()
m_textLayoutObject.clearLayout();
m_textLayoutObject.setText(m_label);
m_textLayoutObject.setFont(m_textFont);
QTextOption textOpts;
textOpts.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
textOpts.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
m_textLayoutObject.setTextOption(textOpts);
QFontMetrics textFontMetrics(m_textFont);
int leading = textFontMetrics.leading();
int rise = textFontMetrics.ascent();
qreal height = 0;
m_textLayoutObject.beginLayout();
while (height < m_labelMaxGeom.height()) {
QTextLine line = m_textLayoutObject.createLine();
if (!line.isValid())
break;
line.setLineWidth(m_labelMaxGeom.width());
if (m_textLayoutObject.lineCount() > 1)
{
height += leading;
}
line.setPosition(QPointF(0, height));
height += line.height();
}
height = qMin((quint32)DimensionsGlobal::roundUp(height),(quint32)m_labelMaxGeom.height());
height = DimensionsGlobal::roundDown(height) - (DimensionsGlobal::roundDown(height) % 2); //force to an even #
m_textLayoutObject.endLayout();
//TODO: PIXEL-ALIGN
m_labelGeom = DimensionsGlobal::realRectAroundRealPoint(QSizeF(m_textLayoutObject.boundingRect().width(),height)).toAlignedRect();
}
//virtual
void PixButton::recalculateLabelPosition()
{
//TODO: MYSTERY! don't know why it needs the 2.0 bump in Y. investigate the geom creation in redoLabelTextLayout()
m_labelPosICS = QPointF(0,2.0+(qreal)(m_labelVerticalAdjust));
m_labelPosPntCS = (m_labelGeom.topLeft() + m_labelPosICS).toPoint();
}
///////////////////////////////// PixButtonExtraHitArea ///////////////////////////////////////////////////////////////
PixButtonExtraHitArea::PixButtonExtraHitArea(PixButton& ownerButton,const QSize& area)
: m_savedOwnerSize(ownerButton.geometry().size())
, m_qp_ownerButton(&ownerButton)
{
setFlag(ItemHasNoContents,true);
QSize effArea = QSize(qMax(area.width(),ownerButton.geometry().size().toSize().width()),
qMax(area.height(),ownerButton.geometry().size().toSize().height()));
m_boundingRect = DimensionsGlobal::realRectAroundRealPoint(effArea);
setParentItem(&ownerButton);
}
//virtual
PixButtonExtraHitArea::~PixButtonExtraHitArea()
{
}
//virtual
void PixButtonExtraHitArea::commonCtor()
{
if (m_qp_ownerButton)
{
connect(m_qp_ownerButton,SIGNAL(destroyed(QObject *)),
this,SLOT(slotOwnerDestroyed(QObject *)));
connect(m_qp_ownerButton,SIGNAL(signalThingGeometryChanged(const QRectF&)),
this,SLOT(slotOwnerGeometryChanged(const QRectF&)));
}
}
//virtual
QRectF PixButtonExtraHitArea::boundingRect() const
{
return m_boundingRect;
}
//virtual
void PixButtonExtraHitArea::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
{
}
//public Q_SLOTS:
void PixButtonExtraHitArea::slotActivate()
{
//not really "visible" since there isn't any paint but it will make it visible to the event system to get mouse events!
setVisible(true);
}
void PixButtonExtraHitArea::slotDeactivate()
{
setVisible(false);
}
void PixButtonExtraHitArea::slotResize(quint32 w,quint32 h)
{
QSize effArea = QSize(qMax(w,(quint32)m_savedOwnerSize.toSize().width()),
qMax(h,(quint32)m_savedOwnerSize.toSize().height()));
m_boundingRect = DimensionsGlobal::realRectAroundRealPoint(effArea);
}
void PixButtonExtraHitArea::slotOwnerGeometryChanged(const QRectF& newGeom)
{
//try and maintain the proportional size of the hit area to the old geom
qreal xp = m_boundingRect.width() / m_savedOwnerSize.width();
qreal yp = m_boundingRect.height() / m_savedOwnerSize.height();
m_boundingRect = DimensionsGlobal::realRectAroundRealPoint(QSizeF(newGeom.width()*xp,newGeom.height()*yp));
m_savedOwnerSize = newGeom.size();
}
void PixButtonExtraHitArea::slotOwnerDestroyed(QObject * p)
{
if (p == m_qp_ownerButton)
{
deleteLater(); //commit suicide...later =)
}
}
| 24.964361 | 131 | 0.730685 | ericblade |
8d92d8fffc3470695b9e4494e7219396485782eb | 1,731 | hpp | C++ | src/PointwiseFunctions/Xcts/LongitudinalOperator.hpp | nilsvu/spectre | 1455b9a8d7e92db8ad600c66f54795c29c3052ee | [
"MIT"
] | 117 | 2017-04-08T22:52:48.000Z | 2022-03-25T07:23:36.000Z | src/PointwiseFunctions/Xcts/LongitudinalOperator.hpp | GitHimanshuc/spectre | 4de4033ba36547113293fe4dbdd77591485a4aee | [
"MIT"
] | 3,177 | 2017-04-07T21:10:18.000Z | 2022-03-31T23:55:59.000Z | src/PointwiseFunctions/Xcts/LongitudinalOperator.hpp | geoffrey4444/spectre | 9350d61830b360e2d5b273fdd176dcc841dbefb0 | [
"MIT"
] | 85 | 2017-04-07T19:36:13.000Z | 2022-03-01T10:21:00.000Z | // Distributed under the MIT License.
// See LICENSE.txt for details.
#pragma once
#include <cstddef>
#include "DataStructures/Tensor/Tensor.hpp"
#include "Utilities/Gsl.hpp"
namespace Xcts {
/*!
* \brief The longitudinal operator, or vector gradient, \f$(L\beta)^{ij}\f$
*
* Computes the longitudinal operator
*
* \f{equation}
* (L\beta)^{ij} = \nabla^i \beta^j + \nabla^j \beta^i -
* \frac{2}{3}\gamma^{ij}\nabla_k\beta^k
* \f}
*
* of a vector field \f$\beta^i\f$, where \f$\nabla\f$ denotes the covariant
* derivative w.r.t. the metric \f$\gamma\f$ (see e.g. Eq. (3.50) in
* \cite BaumgarteShapiro). Note that in the XCTS equations the longitudinal
* operator is typically applied to conformal quantities and w.r.t. the
* conformal metric \f$\bar{\gamma}\f$.
*
* In terms of the symmetric "strain" quantity
* \f$B_{ij}=\nabla_{(i}\gamma_{j)k}\beta^k\f$ the longitudinal operator is:
*
* \f{equation}
* (L\beta)^{ij} = 2\left(\gamma^{ik}\gamma^{jl} -
* \frac{1}{3} \gamma^{ij}\gamma^{kl}\right) B_{kl}
* \f}
*
* Note that the strain can be computed with `Elasticity::strain`.
*/
template <typename DataType>
void longitudinal_operator(gsl::not_null<tnsr::II<DataType, 3>*> result,
const tnsr::ii<DataType, 3>& strain,
const tnsr::II<DataType, 3>& inv_metric);
/*!
* \brief The conformal longitudinal operator \f$(L\beta)^{ij}\f$ on a flat
* conformal metric in Cartesian coordinates \f$\gamma_{ij}=\delta_{ij}\f$
*
* \see `Xcts::longitudinal_operator`
*/
template <typename DataType>
void longitudinal_operator_flat_cartesian(
gsl::not_null<tnsr::II<DataType, 3>*> result,
const tnsr::ii<DataType, 3>& strain);
} // namespace Xcts
| 32.055556 | 76 | 0.658001 | nilsvu |
8d952902bbe215359c95ad445840c3e4f619f906 | 9,204 | cpp | C++ | C++/assign5.cpp | Susmita-18/Hacktoberfest-Codes | 91504c2c557a8ef5999d903a132fa2fe3847abc9 | [
"MIT"
] | 6 | 2019-10-01T06:23:59.000Z | 2020-10-11T13:57:34.000Z | C++/assign5.cpp | Susmita-18/Hacktoberfest-Codes | 91504c2c557a8ef5999d903a132fa2fe3847abc9 | [
"MIT"
] | null | null | null | C++/assign5.cpp | Susmita-18/Hacktoberfest-Codes | 91504c2c557a8ef5999d903a132fa2fe3847abc9 | [
"MIT"
] | 23 | 2019-09-30T16:52:53.000Z | 2020-10-14T06:52:46.000Z | /*
Name - Avik Ghosh
ID - 181001001039
Batch - BCS3A
*/
//Triangle drawing using Bresenham line drawing algorithm and also interior colouring using Flood Fill algorithm.
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int n=0,size;
int x1,y1,x2,y2,x3,y3;
int *pixels=NULL;
static int m=0;
void ExportPixels()
{
FILE *fp = fopen("1039_Pixels.txt", "w");
for(int i=0; i<n; i++)
{
if(i>0)
{
fprintf(fp, "%d, %d\n", pixels[2*i+0], pixels[2*i+1]);
}
else if(i==0)
{
fprintf(fp,"Coordinate A ( %d, %d)\n", x1,y1);
fprintf(fp,"Coordinate B ( %d, %d)\n", x2,y2);
fprintf(fp,"Coordinate C ( %d, %d)\n", x3,y3);
fprintf(fp,"Coordinate of Centroid ( %d, %d)\n", (x1+x2+x3)/3,(y1+y2+y3)/3);
fprintf(fp,"Number of pixels : %d\n",n);
fprintf(fp, "Coordinates(Including A,B and C also) : \nX, Y\n%d, %d\n",x1,y1);
}
}
fclose(fp);
printf("Number of pixels : %d\n",n);
printf("1039_Pixels.txt created successfully!\n");
}
void Export2SVG(int width, int height)
{
int scale = 10;
int margin = 100;
int i;
int a1 = pixels[0], a2 = pixels[0];
int b1 = pixels[1], b2 = pixels[1];
for(i=1; i<n; i++)
{
if(a1>pixels[2*i+0])
{
a1=pixels[2*i+0];
}
if(a2<pixels[2*i+0])
{
a2=pixels[2*i+0];
}
if(b1>pixels[2*i+1])
{
b1=pixels[2*i+1];
}
if(b2<pixels[2*i+1])
{
b2=pixels[2*i+1];
}
}
a1 *=scale; a2 *=scale;
b1 *=scale; b2 *=scale;
FILE *fp = fopen("1039.svg", "w");
fprintf(fp, "<svg width=\"%d\" height=\"%d\" viewBox=\"0 0 %d %d\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">",width,height,width,height);
for(i=0; i<n; i++)
{
if(pixels[2*i+0]==x1 && pixels[2*i+1]==y1)
{
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:red;stroke:black;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*pixels[2*i+0]-a1+100, scale*pixels[2*i+1]-b1+100, scale, scale);
}
else if(pixels[2*i+0]==x2 && pixels[2*i+1]==y2)
{
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:blue;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*pixels[2*i+0]-a1+100, scale*pixels[2*i+1]-b1+100, scale, scale);
}
else if(pixels[2*i+0]==x3 && pixels[2*i+1]==y3)
{
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:green;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*pixels[2*i+0]-a1+100, scale*pixels[2*i+1]-b1+100, scale, scale);
}
else
{
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#FFD700;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*pixels[2*i+0]-a1+100, scale*pixels[2*i+1]-b1+100, scale, scale);
}
}
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:red;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*((x1+x2+x3)/3)-a1+100, scale*((y1+y2+y3)/3)-b1+100, scale, scale);
fclose(fp);
printf("1039.svg created successfully!\n");
}
void Export2HTML(int width, int height)
{
int scale = 10;
int margin = 100;
int i;
int a1 = pixels[0], a2 = pixels[0];
int b1 = pixels[1], b2 = pixels[1];
for(i=1; i<n; i++)
{
if(a1>pixels[2*i+0])
{
a1=pixels[2*i+0];
}
if(a2<pixels[2*i+0])
{
a2=pixels[2*i+0];
}
if(b1>pixels[2*i+1])
{
b1=pixels[2*i+1];
}
if(b2<pixels[2*i+1])
{
b2=pixels[2*i+1];
}
}
a1 *=scale; a2 *=scale;
b1 *=scale; b2 *=scale;
FILE *fp = fopen("1039.html", "w");
fprintf(fp, "<!DOCTYPE html>\n<html>\n<body>\n");
fprintf(fp, "<svg width=\"%d\" height=\"%d\" viewBox=\"0 0 %d %d\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">",width,height,width,height);
for(i=0; i<n; i++)
{
if(pixels[2*i+0]==x1 && pixels[2*i+1]==y1)
{
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:red;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*pixels[2*i+0]-a1+100, scale*pixels[2*i+1]-b1+100, scale, scale);
}
else if(pixels[2*i+0]==x2 && pixels[2*i+1]==y2)
{
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:blue;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*pixels[2*i+0]-a1+100, scale*pixels[2*i+1]-b1+100, scale, scale);
}
else if(pixels[2*i+0]==x3 && pixels[2*i+1]==y3)
{
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:green;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*pixels[2*i+0]-a1+100, scale*pixels[2*i+1]-b1+100, scale, scale);
}
else
{
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:#FFD700;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*pixels[2*i+0]-a1+100, scale*pixels[2*i+1]-b1+100, scale, scale);
}
}
fprintf(fp,"\n<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" style=\"fill:red;stroke:#FFD700;stroke-width:.30;fill-opacity:0.76;stroke-opacity:0.90\"/>", scale*((x1+x2+x3)/3)-a1+100, scale*((y1+y2+y3)/3)-b1+100, scale, scale);
fprintf(fp, "\n </svg>\n");
fprintf(fp, "\n</body>\n</html>\n");
fclose(fp);
printf("1039.html created successfully!\n");
}
void flood(int x, int y, int new_col, int old_col)
{
if (getpixel(x, y) == old_col)
{
putpixel(x, y, new_col);
flood(x + 1, y, new_col, old_col);
flood(x - 1, y, new_col, old_col);
flood(x, y + 1, new_col, old_col);
flood(x, y - 1, new_col, old_col);
}
}
void lineBres(int xa, int ya, int xb, int yb)
{
int k,twoDx,twoDy,twoDyMinusDx,dx,dy,p,slope;
if(xa<xb)
{
dx = xb - xa;
if(ya<yb)
{
dy = yb - ya;
}
else
{
dy=ya-yb;
}
}
else
{
dx = xa - xb;
if(ya<yb)
{
dy = yb - ya;
}
else
{
dy=ya-yb;
}
}
slope=dy/dx;
if(slope>=1)
{
p = 2 * dx - dy;
}
else
{
p = 2 * dy - dx;
}
twoDx = 2 * dx;
twoDy = 2 * dy;
twoDyMinusDx = 2*dy-2*dx;
int x, y;
if (xa > xb)
{
x = xb;
y = yb;
xb = xa;
}
else
{
x = xa;
y = ya;
}
if(m==0)
{
pixels = (int*)malloc(10*(size+1)*sizeof(int));
}
pixels[2*m+0]=x;
pixels[2*m+1]=y;
m++;
if(slope<1)
{
for (k = 0; k <= dx-1; k++)
{
x++;
if (p < 0)
p = p + twoDy;
else
{
y++;
p = p + twoDyMinusDx;
}
pixels[2*m+0]=x;
pixels[2*m+1]=y;
m++;
}
}
else
{
for (k = 0; k <= dy-1; k++)
{
y++;
if (p < 0)
p = p + twoDx;
else
{
x++;
p = p + twoDyMinusDx;
}
pixels[2*m+0]=x;
pixels[2*m+1]=y;
m++;
}
}
n=m;
printf("\nNumber of pixels = %d\n", n);
}
void display()
{
for(int i=0;i<n;i++)
{
if(pixels[2*i+0]==x1 && pixels[2*i+1]==y1)
{
putpixel(pixels[2*i+0],pixels[2*i+1],4);
}
else if(pixels[2*i+0]==x2 && pixels[2*i+1]==y2)
{
putpixel(pixels[2*i+0],pixels[2*i+1],1);
}
else if(pixels[2*i+0]==x3 && pixels[2*i+1]==y3)
{
putpixel(pixels[2*i+0],pixels[2*i+1],2);
}
else
{
putpixel(pixels[2*i+0],pixels[2*i+1],14);
}
}
putpixel((x1+x2+x3)/3,(y1+y2+y3)/3,4);
printf("Done...\n");
}
int makepositive(int x)
{
if(x<0)
{
x=x*(-1);
}
return x;
}
int main()
{
int gd=DETECT,gm;
printf("Enter the A coordinates: ");
scanf("%d%d",&x1,&y1);
printf("Enter the B coordinates: ");
scanf("%d%d",&x2,&y2);
printf("Enter the C coordinates: ");
scanf("%d%d",&x3,&y3);
int a1,b1,c1,a2,b2,c2;
a1=x2-x1;
b1=x3-x2;
c1=x3-x1;
a2=y2-y1;
b2=y3-y2;
c2=y3-y1;
a1=makepositive(a1);
b1=makepositive(b1);
c1=makepositive(c1);
a2=makepositive(a2);
b2=makepositive(b2);
c2=makepositive(c2);
if(a1>=a2 && b1>=b2 && c1>=c2)
{
if(x1>x2 && x2>x3)
{
size=x3;
}
else if(x2>x1 && x2>x3)
{
size=x2;
}
else
{
size=x3;
}
initgraph(&gd,&gm,NULL);
lineBres(x1,y1,x2,y2);
lineBres(x2,y2,x3,y3);
lineBres(x1,y1,x3,y3);
ExportPixels();
Export2HTML(5000,5000);
Export2SVG(5000,5000);
display();
flood(((x1+x2+x3)/3)+1,((y1+y2+y3)/3)+1,3,0);
getch();
}
else
{
printf("Wrong coordinates.");
}
return 0;
}
| 26 | 242 | 0.488918 | Susmita-18 |
8d9534020f2b50d211a0e26d85cd9e9a3d14c9bc | 1,368 | cpp | C++ | unit-test/server/PushImp.cpp | cSingleboy/TarsCpp | 17b228b660d540baa1a93215fc007c5131a2fc68 | [
"BSD-3-Clause"
] | 386 | 2018-09-11T06:17:10.000Z | 2022-03-31T05:59:41.000Z | unit-test/server/PushImp.cpp | cSingleboy/TarsCpp | 17b228b660d540baa1a93215fc007c5131a2fc68 | [
"BSD-3-Clause"
] | 128 | 2018-09-12T03:43:33.000Z | 2022-03-24T10:03:54.000Z | unit-test/server/PushImp.cpp | cSingleboy/TarsCpp | 17b228b660d540baa1a93215fc007c5131a2fc68 | [
"BSD-3-Clause"
] | 259 | 2018-09-19T08:50:37.000Z | 2022-03-11T07:17:56.000Z | #include "PushImp.h"
#include "servant/Application.h"
#include "PushThread.h"
using namespace std;
//////////////////////////////////////////////////////
void PushImp::initialize()
{
//initialize servant here:
//...
}
//////////////////////////////////////////////////////
void PushImp::destroy()
{
//destroy servant here:
//...
}
int PushImp::doRequest(tars::CurrentPtr current, vector<char>& response)
{
// LOG_CONSOLE_DEBUG << endl;
//保存客户端的信息,以便对客户端进行push消息
(PushUser::mapMutex).lock();
map<string, CurrentPtr>::iterator it = PushUser::pushUser.find(current->getIp());
if(it == PushUser::pushUser.end())
{
PushUser::pushUser.insert(map<string, CurrentPtr>::value_type(current->getIp(), current));
LOG->debug() << "connect ip: " << current->getIp() << endl;
}
(PushUser::mapMutex).unlock();
//返回给客户端它自己请求的数据包,即原包返回(4字节长度+4字节requestid+buffer)
const vector<char>& request = current->getRequestBuffer();
response = request;
return 0;
}
//客户端关闭到服务端的连接,或者服务端发现客户端长时间未发送包过来,然后超过60s就关闭连接
//调用的方法
int PushImp::doClose(CurrentPtr current)
{
(PushUser::mapMutex).lock();
map<string, CurrentPtr>::iterator it = PushUser::pushUser.find(current->getIp());
if(it != PushUser::pushUser.end())
{
PushUser::pushUser.erase(it);
LOG->debug() << "close ip: " << current->getIp() << endl;
}
(PushUser::mapMutex).unlock();
return 0;
}
| 24 | 92 | 0.630848 | cSingleboy |
8d9f3471534ef8055e0e483b379536953a11da77 | 12,918 | cpp | C++ | cpp/godot-cpp/src/gen/Image.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/Image.cpp | GDNative-Gradle/proof-of-concept | 162f467430760cf959f68f1638adc663fd05c5fd | [
"MIT"
] | null | null | null | cpp/godot-cpp/src/gen/Image.cpp | GDNative-Gradle/proof-of-concept | 162f467430760cf959f68f1638adc663fd05c5fd | [
"MIT"
] | null | null | null | #include "Image.hpp"
#include <core/GodotGlobal.hpp>
#include <core/CoreTypes.hpp>
#include <core/Ref.hpp>
#include <core/Godot.hpp>
#include "__icalls.hpp"
#include "Image.hpp"
namespace godot {
Image::___method_bindings Image::___mb = {};
void Image::___init_method_bindings() {
___mb.mb__get_data = godot::api->godot_method_bind_get_method("Image", "_get_data");
___mb.mb__set_data = godot::api->godot_method_bind_get_method("Image", "_set_data");
___mb.mb_blend_rect = godot::api->godot_method_bind_get_method("Image", "blend_rect");
___mb.mb_blend_rect_mask = godot::api->godot_method_bind_get_method("Image", "blend_rect_mask");
___mb.mb_blit_rect = godot::api->godot_method_bind_get_method("Image", "blit_rect");
___mb.mb_blit_rect_mask = godot::api->godot_method_bind_get_method("Image", "blit_rect_mask");
___mb.mb_bumpmap_to_normalmap = godot::api->godot_method_bind_get_method("Image", "bumpmap_to_normalmap");
___mb.mb_clear_mipmaps = godot::api->godot_method_bind_get_method("Image", "clear_mipmaps");
___mb.mb_compress = godot::api->godot_method_bind_get_method("Image", "compress");
___mb.mb_convert = godot::api->godot_method_bind_get_method("Image", "convert");
___mb.mb_copy_from = godot::api->godot_method_bind_get_method("Image", "copy_from");
___mb.mb_create = godot::api->godot_method_bind_get_method("Image", "create");
___mb.mb_create_from_data = godot::api->godot_method_bind_get_method("Image", "create_from_data");
___mb.mb_crop = godot::api->godot_method_bind_get_method("Image", "crop");
___mb.mb_decompress = godot::api->godot_method_bind_get_method("Image", "decompress");
___mb.mb_detect_alpha = godot::api->godot_method_bind_get_method("Image", "detect_alpha");
___mb.mb_expand_x2_hq2x = godot::api->godot_method_bind_get_method("Image", "expand_x2_hq2x");
___mb.mb_fill = godot::api->godot_method_bind_get_method("Image", "fill");
___mb.mb_fix_alpha_edges = godot::api->godot_method_bind_get_method("Image", "fix_alpha_edges");
___mb.mb_flip_x = godot::api->godot_method_bind_get_method("Image", "flip_x");
___mb.mb_flip_y = godot::api->godot_method_bind_get_method("Image", "flip_y");
___mb.mb_generate_mipmaps = godot::api->godot_method_bind_get_method("Image", "generate_mipmaps");
___mb.mb_get_data = godot::api->godot_method_bind_get_method("Image", "get_data");
___mb.mb_get_format = godot::api->godot_method_bind_get_method("Image", "get_format");
___mb.mb_get_height = godot::api->godot_method_bind_get_method("Image", "get_height");
___mb.mb_get_mipmap_offset = godot::api->godot_method_bind_get_method("Image", "get_mipmap_offset");
___mb.mb_get_pixel = godot::api->godot_method_bind_get_method("Image", "get_pixel");
___mb.mb_get_pixelv = godot::api->godot_method_bind_get_method("Image", "get_pixelv");
___mb.mb_get_rect = godot::api->godot_method_bind_get_method("Image", "get_rect");
___mb.mb_get_size = godot::api->godot_method_bind_get_method("Image", "get_size");
___mb.mb_get_used_rect = godot::api->godot_method_bind_get_method("Image", "get_used_rect");
___mb.mb_get_width = godot::api->godot_method_bind_get_method("Image", "get_width");
___mb.mb_has_mipmaps = godot::api->godot_method_bind_get_method("Image", "has_mipmaps");
___mb.mb_is_compressed = godot::api->godot_method_bind_get_method("Image", "is_compressed");
___mb.mb_is_empty = godot::api->godot_method_bind_get_method("Image", "is_empty");
___mb.mb_is_invisible = godot::api->godot_method_bind_get_method("Image", "is_invisible");
___mb.mb_load = godot::api->godot_method_bind_get_method("Image", "load");
___mb.mb_load_jpg_from_buffer = godot::api->godot_method_bind_get_method("Image", "load_jpg_from_buffer");
___mb.mb_load_png_from_buffer = godot::api->godot_method_bind_get_method("Image", "load_png_from_buffer");
___mb.mb_load_webp_from_buffer = godot::api->godot_method_bind_get_method("Image", "load_webp_from_buffer");
___mb.mb_lock = godot::api->godot_method_bind_get_method("Image", "lock");
___mb.mb_normalmap_to_xy = godot::api->godot_method_bind_get_method("Image", "normalmap_to_xy");
___mb.mb_premultiply_alpha = godot::api->godot_method_bind_get_method("Image", "premultiply_alpha");
___mb.mb_resize = godot::api->godot_method_bind_get_method("Image", "resize");
___mb.mb_resize_to_po2 = godot::api->godot_method_bind_get_method("Image", "resize_to_po2");
___mb.mb_rgbe_to_srgb = godot::api->godot_method_bind_get_method("Image", "rgbe_to_srgb");
___mb.mb_save_exr = godot::api->godot_method_bind_get_method("Image", "save_exr");
___mb.mb_save_png = godot::api->godot_method_bind_get_method("Image", "save_png");
___mb.mb_set_pixel = godot::api->godot_method_bind_get_method("Image", "set_pixel");
___mb.mb_set_pixelv = godot::api->godot_method_bind_get_method("Image", "set_pixelv");
___mb.mb_shrink_x2 = godot::api->godot_method_bind_get_method("Image", "shrink_x2");
___mb.mb_srgb_to_linear = godot::api->godot_method_bind_get_method("Image", "srgb_to_linear");
___mb.mb_unlock = godot::api->godot_method_bind_get_method("Image", "unlock");
}
Image *Image::_new()
{
return (Image *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, godot::api->godot_get_class_constructor((char *)"Image")());
}
Dictionary Image::_get_data() const {
return ___godot_icall_Dictionary(___mb.mb__get_data, (const Object *) this);
}
void Image::_set_data(const Dictionary data) {
___godot_icall_void_Dictionary(___mb.mb__set_data, (const Object *) this, data);
}
void Image::blend_rect(const Ref<Image> src, const Rect2 src_rect, const Vector2 dst) {
___godot_icall_void_Object_Rect2_Vector2(___mb.mb_blend_rect, (const Object *) this, src.ptr(), src_rect, dst);
}
void Image::blend_rect_mask(const Ref<Image> src, const Ref<Image> mask, const Rect2 src_rect, const Vector2 dst) {
___godot_icall_void_Object_Object_Rect2_Vector2(___mb.mb_blend_rect_mask, (const Object *) this, src.ptr(), mask.ptr(), src_rect, dst);
}
void Image::blit_rect(const Ref<Image> src, const Rect2 src_rect, const Vector2 dst) {
___godot_icall_void_Object_Rect2_Vector2(___mb.mb_blit_rect, (const Object *) this, src.ptr(), src_rect, dst);
}
void Image::blit_rect_mask(const Ref<Image> src, const Ref<Image> mask, const Rect2 src_rect, const Vector2 dst) {
___godot_icall_void_Object_Object_Rect2_Vector2(___mb.mb_blit_rect_mask, (const Object *) this, src.ptr(), mask.ptr(), src_rect, dst);
}
void Image::bumpmap_to_normalmap(const real_t bump_scale) {
___godot_icall_void_float(___mb.mb_bumpmap_to_normalmap, (const Object *) this, bump_scale);
}
void Image::clear_mipmaps() {
___godot_icall_void(___mb.mb_clear_mipmaps, (const Object *) this);
}
Error Image::compress(const int64_t mode, const int64_t source, const real_t lossy_quality) {
return (Error) ___godot_icall_int_int_int_float(___mb.mb_compress, (const Object *) this, mode, source, lossy_quality);
}
void Image::convert(const int64_t format) {
___godot_icall_void_int(___mb.mb_convert, (const Object *) this, format);
}
void Image::copy_from(const Ref<Image> src) {
___godot_icall_void_Object(___mb.mb_copy_from, (const Object *) this, src.ptr());
}
void Image::create(const int64_t width, const int64_t height, const bool use_mipmaps, const int64_t format) {
___godot_icall_void_int_int_bool_int(___mb.mb_create, (const Object *) this, width, height, use_mipmaps, format);
}
void Image::create_from_data(const int64_t width, const int64_t height, const bool use_mipmaps, const int64_t format, const PoolByteArray data) {
___godot_icall_void_int_int_bool_int_PoolByteArray(___mb.mb_create_from_data, (const Object *) this, width, height, use_mipmaps, format, data);
}
void Image::crop(const int64_t width, const int64_t height) {
___godot_icall_void_int_int(___mb.mb_crop, (const Object *) this, width, height);
}
Error Image::decompress() {
return (Error) ___godot_icall_int(___mb.mb_decompress, (const Object *) this);
}
Image::AlphaMode Image::detect_alpha() const {
return (Image::AlphaMode) ___godot_icall_int(___mb.mb_detect_alpha, (const Object *) this);
}
void Image::expand_x2_hq2x() {
___godot_icall_void(___mb.mb_expand_x2_hq2x, (const Object *) this);
}
void Image::fill(const Color color) {
___godot_icall_void_Color(___mb.mb_fill, (const Object *) this, color);
}
void Image::fix_alpha_edges() {
___godot_icall_void(___mb.mb_fix_alpha_edges, (const Object *) this);
}
void Image::flip_x() {
___godot_icall_void(___mb.mb_flip_x, (const Object *) this);
}
void Image::flip_y() {
___godot_icall_void(___mb.mb_flip_y, (const Object *) this);
}
Error Image::generate_mipmaps(const bool renormalize) {
return (Error) ___godot_icall_int_bool(___mb.mb_generate_mipmaps, (const Object *) this, renormalize);
}
PoolByteArray Image::get_data() const {
return ___godot_icall_PoolByteArray(___mb.mb_get_data, (const Object *) this);
}
Image::Format Image::get_format() const {
return (Image::Format) ___godot_icall_int(___mb.mb_get_format, (const Object *) this);
}
int64_t Image::get_height() const {
return ___godot_icall_int(___mb.mb_get_height, (const Object *) this);
}
int64_t Image::get_mipmap_offset(const int64_t mipmap) const {
return ___godot_icall_int_int(___mb.mb_get_mipmap_offset, (const Object *) this, mipmap);
}
Color Image::get_pixel(const int64_t x, const int64_t y) const {
return ___godot_icall_Color_int_int(___mb.mb_get_pixel, (const Object *) this, x, y);
}
Color Image::get_pixelv(const Vector2 src) const {
return ___godot_icall_Color_Vector2(___mb.mb_get_pixelv, (const Object *) this, src);
}
Ref<Image> Image::get_rect(const Rect2 rect) const {
return Ref<Image>::__internal_constructor(___godot_icall_Object_Rect2(___mb.mb_get_rect, (const Object *) this, rect));
}
Vector2 Image::get_size() const {
return ___godot_icall_Vector2(___mb.mb_get_size, (const Object *) this);
}
Rect2 Image::get_used_rect() const {
return ___godot_icall_Rect2(___mb.mb_get_used_rect, (const Object *) this);
}
int64_t Image::get_width() const {
return ___godot_icall_int(___mb.mb_get_width, (const Object *) this);
}
bool Image::has_mipmaps() const {
return ___godot_icall_bool(___mb.mb_has_mipmaps, (const Object *) this);
}
bool Image::is_compressed() const {
return ___godot_icall_bool(___mb.mb_is_compressed, (const Object *) this);
}
bool Image::is_empty() const {
return ___godot_icall_bool(___mb.mb_is_empty, (const Object *) this);
}
bool Image::is_invisible() const {
return ___godot_icall_bool(___mb.mb_is_invisible, (const Object *) this);
}
Error Image::load(const String path) {
return (Error) ___godot_icall_int_String(___mb.mb_load, (const Object *) this, path);
}
Error Image::load_jpg_from_buffer(const PoolByteArray buffer) {
return (Error) ___godot_icall_int_PoolByteArray(___mb.mb_load_jpg_from_buffer, (const Object *) this, buffer);
}
Error Image::load_png_from_buffer(const PoolByteArray buffer) {
return (Error) ___godot_icall_int_PoolByteArray(___mb.mb_load_png_from_buffer, (const Object *) this, buffer);
}
Error Image::load_webp_from_buffer(const PoolByteArray buffer) {
return (Error) ___godot_icall_int_PoolByteArray(___mb.mb_load_webp_from_buffer, (const Object *) this, buffer);
}
void Image::lock() {
___godot_icall_void(___mb.mb_lock, (const Object *) this);
}
void Image::normalmap_to_xy() {
___godot_icall_void(___mb.mb_normalmap_to_xy, (const Object *) this);
}
void Image::premultiply_alpha() {
___godot_icall_void(___mb.mb_premultiply_alpha, (const Object *) this);
}
void Image::resize(const int64_t width, const int64_t height, const int64_t interpolation) {
___godot_icall_void_int_int_int(___mb.mb_resize, (const Object *) this, width, height, interpolation);
}
void Image::resize_to_po2(const bool square) {
___godot_icall_void_bool(___mb.mb_resize_to_po2, (const Object *) this, square);
}
Ref<Image> Image::rgbe_to_srgb() {
return Ref<Image>::__internal_constructor(___godot_icall_Object(___mb.mb_rgbe_to_srgb, (const Object *) this));
}
Error Image::save_exr(const String path, const bool grayscale) const {
return (Error) ___godot_icall_int_String_bool(___mb.mb_save_exr, (const Object *) this, path, grayscale);
}
Error Image::save_png(const String path) const {
return (Error) ___godot_icall_int_String(___mb.mb_save_png, (const Object *) this, path);
}
void Image::set_pixel(const int64_t x, const int64_t y, const Color color) {
___godot_icall_void_int_int_Color(___mb.mb_set_pixel, (const Object *) this, x, y, color);
}
void Image::set_pixelv(const Vector2 dst, const Color color) {
___godot_icall_void_Vector2_Color(___mb.mb_set_pixelv, (const Object *) this, dst, color);
}
void Image::shrink_x2() {
___godot_icall_void(___mb.mb_shrink_x2, (const Object *) this);
}
void Image::srgb_to_linear() {
___godot_icall_void(___mb.mb_srgb_to_linear, (const Object *) this);
}
void Image::unlock() {
___godot_icall_void(___mb.mb_unlock, (const Object *) this);
}
} | 44.239726 | 191 | 0.777675 | GDNative-Gradle |
8da0089fb86c3056043f83b8f3d3d1d172208068 | 5,408 | cc | C++ | plugins/experimental/inliner/ats-inliner.cc | garfieldonly/ats_git | 940ff5c56bebabb96130a55c2a17212c5c518138 | [
"Apache-2.0"
] | 1 | 2016-06-12T02:01:06.000Z | 2016-06-12T02:01:06.000Z | plugins/experimental/inliner/ats-inliner.cc | mingzym/trafficserver | a01c3a357b4ff9193f2e2a8aee48e3751ef2177a | [
"Apache-2.0"
] | null | null | null | plugins/experimental/inliner/ats-inliner.cc | mingzym/trafficserver | a01c3a357b4ff9193f2e2a8aee48e3751ef2177a | [
"Apache-2.0"
] | null | null | null | /** @file
Inlines base64 images from the ATS cache
@section license License
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <assert.h>
#include <cstring>
#include <dlfcn.h>
#include <inttypes.h>
#include <limits>
#include <stdio.h>
#include <unistd.h>
#include "inliner-handler.h"
#include "ts.h"
#ifndef PLUGIN_TAG
#error Please define a PLUGIN_TAG before including this file.
#endif
// disable timeout for now
const size_t timeout = 0;
struct MyData {
ats::inliner::Handler handler;
MyData(const TSIOBufferReader r, const TSVConn v)
: handler(r, ats::io::IOSink::Create(TSTransformOutputVConnGet(v), TSContMutexGet(v), timeout))
{
assert(r != NULL);
assert(v != NULL);
}
};
void
handle_transform(const TSCont c)
{
const TSVIO vio = TSVConnWriteVIOGet(c);
MyData *const data = static_cast<MyData *>(TSContDataGet(c));
if (!TSVIOBufferGet(vio)) {
TSVConnShutdown(c, 1, 0);
TSContDataSet(c, NULL);
delete data;
return;
}
auto todo = TSVIONTodoGet(vio);
if (todo > 0) {
const TSIOBufferReader reader = TSVIOReaderGet(vio);
todo = std::min(todo, TSIOBufferReaderAvail(reader));
if (todo > 0) {
if (!data) {
const_cast<MyData *&>(data) = new MyData(TSVIOReaderGet(vio), c);
TSContDataSet(c, data);
}
data->handler.parse();
TSIOBufferReaderConsume(reader, todo);
TSVIONDoneSet(vio, TSVIONDoneGet(vio) + todo);
}
}
if (TSVIONTodoGet(vio) > 0) {
if (todo > 0) {
TSContCall(TSVIOContGet(vio), TS_EVENT_VCONN_WRITE_READY, vio);
}
} else {
TSContCall(TSVIOContGet(vio), TS_EVENT_VCONN_WRITE_COMPLETE, vio);
TSVConnShutdown(c, 1, 0);
TSContDataSet(c, NULL);
delete data;
}
}
int
null_transform(TSCont c, TSEvent e, void *)
{
if (TSVConnClosedGet(c)) {
TSDebug(PLUGIN_TAG, "connection closed");
MyData *const data = static_cast<MyData *>(TSContDataGet(c));
if (data != NULL) {
TSContDataSet(c, NULL);
data->handler.abort();
delete data;
}
TSContDestroy(c);
} else {
switch (e) {
case TS_EVENT_ERROR: {
const TSVIO vio = TSVConnWriteVIOGet(c);
assert(vio != NULL);
TSContCall(TSVIOContGet(vio), TS_EVENT_ERROR, vio);
} break;
case TS_EVENT_IMMEDIATE:
handle_transform(c);
break;
default:
TSError("[" PLUGIN_TAG "] Unknown event: %i", e);
assert(false); // UNREACHABLE
}
}
return 0;
}
bool
transformable(TSHttpTxn txnp)
{
bool returnValue;
TSMBuffer buffer;
TSMLoc location;
CHECK(TSHttpTxnServerRespGet(txnp, &buffer, &location));
assert(buffer != NULL);
assert(location != NULL);
returnValue = TSHttpHdrStatusGet(buffer, location) == TS_HTTP_STATUS_OK;
if (returnValue) {
returnValue = false;
const TSMLoc field = TSMimeHdrFieldFind(buffer, location, TS_MIME_FIELD_CONTENT_TYPE, TS_MIME_LEN_CONTENT_TYPE);
if (field != TS_NULL_MLOC) {
int length = 0;
const char *const content = TSMimeHdrFieldValueStringGet(buffer, location, field, 0, &length);
if (content != NULL && length > 0) {
returnValue = strncasecmp(content, "text/html", 9) == 0;
}
TSHandleMLocRelease(buffer, location, field);
}
}
CHECK(TSHandleMLocRelease(buffer, TS_NULL_MLOC, location));
returnValue &= TSHttpTxnIsInternal(txnp) != TS_SUCCESS;
return returnValue;
}
void
transform_add(const TSHttpTxn t)
{
assert(t != NULL);
const TSVConn vconnection = TSTransformCreate(null_transform, t);
assert(vconnection != NULL);
TSHttpTxnHookAdd(t, TS_HTTP_RESPONSE_TRANSFORM_HOOK, vconnection);
}
int
transform_plugin(TSCont, TSEvent e, void *d)
{
assert(TS_EVENT_HTTP_READ_RESPONSE_HDR == e);
assert(d != NULL);
const TSHttpTxn transaction = static_cast<TSHttpTxn>(d);
switch (e) {
case TS_EVENT_HTTP_READ_RESPONSE_HDR:
if (transformable(transaction)) {
transform_add(transaction);
}
TSHttpTxnReenable(transaction, TS_EVENT_HTTP_CONTINUE);
break;
default:
assert(false); // UNRECHEABLE
break;
}
return TS_SUCCESS;
}
void
TSPluginInit(int, const char **)
{
TSPluginRegistrationInfo info;
info.plugin_name = const_cast<char *>(PLUGIN_TAG);
info.vendor_name = const_cast<char *>("MyCompany");
info.support_email = const_cast<char *>("ts-api-support@MyCompany.com");
if (TSPluginRegister(&info) != TS_SUCCESS) {
TSError("[" PLUGIN_TAG "] Plugin registration failed.\n");
goto error;
}
TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(transform_plugin, NULL));
return;
error:
TSError("[null-tranform] Unable to initialize plugin (disabled).\n");
}
| 24.807339 | 116 | 0.689349 | garfieldonly |
8da6a7f8fec506fe510e405714677f7d04af4b88 | 4,067 | cpp | C++ | simple/rtimer-impl.cpp | fabricetriboix/asio-tutorial | 06f1a9074343b2ac4a774abbfcae1fb3a39eba25 | [
"Unlicense"
] | null | null | null | simple/rtimer-impl.cpp | fabricetriboix/asio-tutorial | 06f1a9074343b2ac4a774abbfcae1fb3a39eba25 | [
"Unlicense"
] | null | null | null | simple/rtimer-impl.cpp | fabricetriboix/asio-tutorial | 06f1a9074343b2ac4a774abbfcae1fb3a39eba25 | [
"Unlicense"
] | null | null | null | #include "rtimer-impl.hpp"
#include <cstring>
#include <cerrno>
#include <stdexcept>
#include <boost/assert.hpp>
#include <boost/log/trivial.hpp>
#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
namespace rtimer {
void rtimer_handler(union sigval arg)
{
rtimer_impl_t* impl = static_cast<rtimer_impl_t*>(arg.sival_ptr);
BOOST_LOG_TRIVIAL(info) << "-> rtimer_impl_t[" << impl << "]::" << __func__
<< "(" << arg.sival_ptr << ")";
impl->callback_();
BOOST_LOG_TRIVIAL(info) << "<- rtimer_impl_t[" << impl << "]::" << __func__
<< "(" << arg.sival_ptr << ")";
}
rtimer_impl_t::rtimer_impl_t() : initialised_(false), callback_(nullptr)
{
BOOST_LOG_TRIVIAL(info) << "-> rtimer_impl_t[" << this << "]::" << __func__
<< "()";
BOOST_LOG_TRIVIAL(info) << "<- rtimer_impl_t[" << this << "]::" << __func__
<< "()";
}
rtimer_impl_t::~rtimer_impl_t()
{
BOOST_LOG_TRIVIAL(info) << "-> rtimer_impl_t[" << this << "]::" << __func__
<< "()";
BOOST_ASSERT(!initialised_);
BOOST_LOG_TRIVIAL(info) << "<- rtimer_impl_t[" << this << "]::" << __func__
<< "()";
}
void rtimer_impl_t::make()
{
BOOST_LOG_TRIVIAL(info) << "-> rtimer_impl_t[" << this << "]::" << __func__
<< "()";
BOOST_ASSERT(!initialised_);
// Create the POSIX timer
::sigevent sigev;
std::memset(&sigev, 0, sizeof(sigev));
sigev.sigev_notify = SIGEV_THREAD;
sigev.sigev_notify_function = rtimer_handler;
sigev.sigev_value.sival_ptr = static_cast<void*>(this);
int ret = ::timer_create(CLOCK_MONOTONIC, &sigev, &timer_);
if (ret < 0) {
boost::system::system_error e(boost::system::error_code(errno,
boost::system::get_system_category()),
"timer_create() failed");
throw e;
}
initialised_ = true;
BOOST_LOG_TRIVIAL(info) << "<- rtimer_impl_t[" << this << "]::" << __func__
<< "()";
}
void rtimer_impl_t::unmake()
{
BOOST_LOG_TRIVIAL(info) << "-> rtimer_impl_t[" << this << "]::" << __func__
<< "()";
BOOST_ASSERT(initialised_);
// Delete the POSIX timer
(void)::timer_delete(timer_);
initialised_ = false;
BOOST_LOG_TRIVIAL(info) << "<- rtimer_impl_t[" << this << "]::" << __func__
<< "()";
}
void rtimer_impl_t::enable(std::chrono::nanoseconds ns, callback_t callback)
{
BOOST_LOG_TRIVIAL(info) << "-> rtimer_impl_t[" << this << "]::" << __func__
<< "(" << ns.count() << ")";
BOOST_ASSERT(initialised_);
if (callback == nullptr) {
throw std::invalid_argument("Callback must not be null");
}
callback_ = callback;
// Enable the POSIX timer
::itimerspec its;
std::memset(&its, 0, sizeof(its));
its.it_value.tv_sec = ns.count() / 1000000000;
its.it_value.tv_nsec = ns.count() % 1000000000;
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
int ret = ::timer_settime(timer_, 0, &its, nullptr);
if (ret < 0) {
callback_ = nullptr;
boost::system::system_error e(boost::system::error_code(errno,
boost::system::get_system_category()),
"timer_settime() failed");
throw e;
}
BOOST_LOG_TRIVIAL(info) << "<- rtimer_impl_t[" << this << "]::" << __func__
<< "(" << ns.count() << ")";
}
void rtimer_impl_t::disable()
{
BOOST_LOG_TRIVIAL(info) << "-> rtimer_impl_t[" << this << "]::" << __func__
<< "()";
// Disable the POSIX timer
::itimerspec its;
std::memset(&its, 0, sizeof(its));
int ret = ::timer_settime(timer_, 0, &its, nullptr);
if (ret < 0) {
callback_ = nullptr;
boost::system::system_error e(boost::system::error_code(errno,
boost::system::get_system_category()),
"timer_settime() failed");
throw e;
}
callback_ = nullptr;
BOOST_LOG_TRIVIAL(info) << "<- rtimer_impl_t[" << this << "]::" << __func__
<< "()";
}
} // namespace rtimer
| 31.045802 | 79 | 0.582493 | fabricetriboix |
8daa7c7e00602cff306443d48ac0bac6e1abf7eb | 800 | cpp | C++ | tests/partial_sum.cpp | davidhunter22/ranges | 86d594ed4b2ac0f8659ca16816e514450e9ab8b0 | [
"CC0-1.0"
] | 48 | 2021-04-07T11:50:32.000Z | 2022-03-12T00:49:56.000Z | tests/partial_sum.cpp | davidhunter22/ranges | 86d594ed4b2ac0f8659ca16816e514450e9ab8b0 | [
"CC0-1.0"
] | 18 | 2021-05-14T17:13:41.000Z | 2022-02-05T04:06:11.000Z | tests/partial_sum.cpp | davidhunter22/ranges | 86d594ed4b2ac0f8659ca16816e514450e9ab8b0 | [
"CC0-1.0"
] | 6 | 2021-05-19T14:35:06.000Z | 2022-03-12T00:49:58.000Z | #include "tl/partial_sum.hpp"
#include "tl/zip.hpp"
#include <catch2/catch.hpp>
#include <vector>
TEST_CASE("partial sum") {
std::vector<int> v{ 0,1,2,3,4 };
std::vector<int> res{
0, 1, 3, 6, 10
};
for (auto&& [a, b] : tl::views::zip(tl::views::partial_sum(v, std::plus{}), res)) {
REQUIRE(a == b);
}
}
TEST_CASE("partial sum pipe") {
std::vector<int> v{ 0,1,2,3,4 };
std::vector<int> res{
0, 1, 3, 6, 10
};
for (auto&& [a, b] : tl::views::zip(v | tl::views::partial_sum(), res)) {
REQUIRE(a == b);
}
}
TEST_CASE("partial multiply") {
std::vector<int> v{ 1,2,3,4 };
std::vector<int> res{
1, 2, 6, 24
};
for (auto&& [a, b] : tl::views::zip(tl::views::partial_sum(v, std::multiplies{}), res)) {
REQUIRE(a == b);
}
} | 21.621622 | 92 | 0.52875 | davidhunter22 |
8db47ea0d84c274ce2853bd303b72fbae609647c | 3,175 | cpp | C++ | src/CursATE/Screen/detail/Marks.ut.cpp | qiagen/LogATE | aa43595c89bf3bcaa302d8406e5ad789efc0e035 | [
"BSD-2-Clause"
] | null | null | null | src/CursATE/Screen/detail/Marks.ut.cpp | qiagen/LogATE | aa43595c89bf3bcaa302d8406e5ad789efc0e035 | [
"BSD-2-Clause"
] | null | null | null | src/CursATE/Screen/detail/Marks.ut.cpp | qiagen/LogATE | aa43595c89bf3bcaa302d8406e5ad789efc0e035 | [
"BSD-2-Clause"
] | 3 | 2021-01-12T18:52:49.000Z | 2021-01-19T17:48:50.000Z | #include <doctest/doctest.h>
#include "CursATE/Screen/detail/Marks.hpp"
#include "LogATE/Tree/Filter/AcceptAll.hpp"
#include "LogATE/TestHelpers.ut.hpp"
using CursATE::Screen::detail::Marks;
using LogATE::makeKey;
namespace
{
TEST_SUITE("CursATE::Screen::detail::Marks")
{
struct Fixture
{
auto makeNode() const
{
using LogATE::Tree::Filter::AcceptAll;
return But::makeSharedNN<AcceptAll>(workers_, AcceptAll::Name{"united states of whatever"});
}
const LogATE::Utils::WorkerThreadsShPtr workers_{ But::makeSharedNN<LogATE::Utils::WorkerThreads>() };
Marks m_;
};
TEST_CASE_FIXTURE(Fixture, "empy by default")
{
CHECK( m_.size() == 0u );
CHECK_FALSE( m_.find('x') );
}
TEST_CASE_FIXTURE(Fixture, "caching and getting")
{
const auto key1 = makeKey();
const auto node1 = makeNode();
m_.insert( 'a', Marks::Entry{key1, node1} );
{
const auto e = m_.find('a');
REQUIRE(static_cast<bool>(e) == true);
CHECK( e->key_ == key1 );
const auto node = e->node_.lock();
CHECK( node.get() == node1.get() );
}
{
const auto e = m_.find('b');
REQUIRE(static_cast<bool>(e) == false);
}
const auto key2 = makeKey();
const auto node2 = makeNode();
m_.insert( 'b', Marks::Entry{key2, node2} );
{
const auto e = m_.find('a');
REQUIRE(static_cast<bool>(e) == true);
CHECK( e->key_ == key1 );
const auto node = e->node_.lock();
CHECK( node.get() == node1.get() );
}
{
const auto e = m_.find('b');
REQUIRE( static_cast<bool>(e) == true);
CHECK( e->key_ == key2 );
const auto node = e->node_.lock();
CHECK( node.get() == node2.get() );
}
}
TEST_CASE_FIXTURE(Fixture, "insertiuon for existing key overrides")
{
const auto key1 = makeKey();
const auto node1 = makeNode();
m_.insert( 'a', Marks::Entry{key1, node1} );
const auto key2 = makeKey();
const auto node2 = makeNode();
m_.insert( 'a', Marks::Entry{key2, node2} );
const auto e = m_.find('a');
REQUIRE(static_cast<bool>(e) == true);
CHECK( e->key_ == key2 );
const auto node = e->node_.lock();
CHECK( node.get() == node2.get() );
}
TEST_CASE_FIXTURE(Fixture, "getting invalidated entry")
{
auto key1 = makeKey();
auto node1 = makeNode().underlyingPointer();
m_.insert( 'a', Marks::Entry{key1, node1} );
node1.reset();
const auto e = m_.find('a');
REQUIRE(static_cast<bool>(e) == true);
CHECK( e->key_ == key1 );
const auto node = e->node_.lock();
CHECK( node.get() == nullptr );
}
TEST_CASE_FIXTURE(Fixture, "prunning removes invalidated entries")
{
auto key1 = makeKey();
auto node1 = makeNode().underlyingPointer();
m_.insert( 'a', Marks::Entry{key1, node1} );
auto key2 = makeKey();
auto node2 = makeNode();
m_.insert( 'x', Marks::Entry{key2, node2} );
CHECK( m_.size() == 2u );
node1.reset();
CHECK( m_.size() == 2u );
m_.prune();
CHECK( m_.size() == 1u );
{
const auto e = m_.find('a');
CHECK(static_cast<bool>(e) == false);
}
{
const auto e = m_.find('x');
REQUIRE(static_cast<bool>(e) == true);
CHECK( e->key_ == key2 );
const auto node = e->node_.lock();
CHECK( node.get() == node2.get() );
}
}
}
}
| 23.345588 | 104 | 0.615433 | qiagen |
8db4917ed6d49eebc5c5d7deb6ae513bd5820801 | 14,824 | hpp | C++ | boost/numeric/ublasx/operation/min.hpp | comcon1/boost-ublasx | 290b92b643a944825df99bece3468a4f81518056 | [
"BSL-1.0"
] | null | null | null | boost/numeric/ublasx/operation/min.hpp | comcon1/boost-ublasx | 290b92b643a944825df99bece3468a4f81518056 | [
"BSL-1.0"
] | null | null | null | boost/numeric/ublasx/operation/min.hpp | comcon1/boost-ublasx | 290b92b643a944825df99bece3468a4f81518056 | [
"BSL-1.0"
] | null | null | null | /**
* \file boost/numeric/ublasx/operation/min.hpp
*
* \brief The \c min operation.
*
* <hr/>
*
* Copyright (c) 2010-2011, Marco Guazzone
*
* 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)
*
* \author Marco Guazzone, marco.guazzone@gmail.com
*/
#ifndef BOOST_NUMERIC_UBLASX_OPERATION_MIN_HPP
#define BOOST_NUMERIC_UBLASX_OPERATION_MIN_HPP
#include <boost/numeric/ublas/detail/config.hpp>
#include <boost/numeric/ublas/expression_types.hpp>
#include <boost/numeric/ublasx/detail/debug.hpp>
#include <boost/numeric/ublasx/operation/num_columns.hpp>
#include <boost/numeric/ublasx/operation/num_rows.hpp>
#include <boost/numeric/ublasx/operation/size.hpp>
#include <boost/numeric/ublas/traits.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <complex>
#include <cstddef>
#include <limits>
namespace boost { namespace numeric { namespace ublasx {
using namespace ::boost::numeric::ublas;
//@{ Declarations
/**
* \brief Find the minimum element of the given vector expression.
* \tparam VectorExprT The type of the vector expression.
* \param ve The vector expression over which to iterate for finding the minimum
* element.
* \return The minimum element in the vector expression.
*
* \author Marco Guazzone, <marco.guazzone@gmail.com>
*/
template <typename VectorExprT>
typename vector_traits<VectorExprT>::value_type min(vector_expression<VectorExprT> const& ve);
/**
* \brief Find the minimum element of the given matrix expression.
* \tparam MatrixExprT The type of the matrix expression.
* \param me The matrix expression over which to iterate for finding the minimum
* element.
* \return The minimum element in the matrix expression.
*
* \author Marco Guazzone, <marco.guazzone@gmail.com>
*/
template <typename MatrixExprT>
typename matrix_traits<MatrixExprT>::value_type min(matrix_expression<MatrixExprT> const& me);
/**
* \brief Find the minimum element of each row in the given matrix expression.
* \tparam MatrixExprT The type of the matrix expression.
* \param me The matrix expression over which to iterate for finding the minimum
* element of each row.
* \return A vector containing the minimum element for each row in the given
* matrix expression.
*
* \author Marco Guazzone, <marco.guazzone@gmail.com>
*/
template <typename MatrixExprT>
vector<typename matrix_traits<MatrixExprT>::value_type> min_rows(matrix_expression<MatrixExprT> const& me);
/**
* \brief Find the minimum element of each column in the given matrix
* expression.
* \tparam MatrixExprT The type of the matrix expression.
* \param me The matrix expression over which to iterate for finding the minimum
* element of each column.
* \return A vector containing the minimum element for each column in the given
* matrix expression.
*
* \author Marco Guazzone, <marco.guazzone@gmail.com>
*/
template <typename MatrixExprT>
vector<typename matrix_traits<MatrixExprT>::value_type> min_columns(matrix_expression<MatrixExprT> const& me);
/**
* \brief Find the minimum element of the given vector expression.
* \tparam Dim The dimension number (for vector, only dimension 1 is valid).
* \tparam MatrixExprT The type of the vectovector expression.
* \param ve The vector expression over which to iterate for finding the minimum
* element over the given dimension.
* \return A vector of size 1 containing the minimum element of the given vector
* expression.
*
* This function is provided for the sake of usability, in order to make to make
* the call to \c size<1>(vec) a valid call.
* For the same reason, the return type is a vector instead of a simple scalar.
*
* \author Marco Guazzone, <marco.guazzone@gmail.com>
*/
template <size_t Dim, typename VectorExprT>
vector<typename vector_traits<VectorExprT>::value_type> min(vector_expression<VectorExprT> const& ve);
/**
* \brief Find the minimum elements over the given dimension of the given matrix
* expression.
* \tparam Dim The dimension number (starting from 1).
* \tparam MatrixExprT The type of the matrix expression.
* \param me The matrix expression over which to iterate for finding the minimum
* element over the given dimension.
* \return A vector containing the minimum elements over the given dimension in
* the given matrix expression.
*
* \author Marco Guazzone, <marco.guazzone@gmail.com>
*/
template <size_t Dim, typename MatrixExprT>
vector<typename matrix_traits<MatrixExprT>::value_type> min(matrix_expression<MatrixExprT> const& me);
/**
* \brief Find the minimum elements over the given dimension tag of the given
* matrix expression.
* \tparam TagT The dimension tag type (e.g., tag::major).
* \tparam MatrixExprT The type of the matrix expression.
* \param me The matrix expression over which to iterate for finding the minimum
* element over the given dimension.
* \return A vector containing the minimum elements over the given dimension in
* the given matrix expression.
*
* \author Marco Guazzone, <marco.guazzone@gmail.com>
*/
template <typename TagT, typename MatrixExprT>
vector<typename matrix_traits<MatrixExprT>::value_type> min_by_tag(matrix_expression<MatrixExprT> const& me);
//@} Declarations
namespace detail { namespace /*<unnamed>*/ {
//@{ Declarations
/// Helper function for implementing the 'less-than' relational operator over
/// generic types.
template <typename T>
bool less_than_impl(T a, T b);
/// Helper function for implementing the 'less-than' relational operator over
/// complex types.
template <typename T>
bool less_than_impl(::std::complex<T> const& a, ::std::complex<T> const& b);
/**
* \brief Helper class for real/complex infinity
*
* See Wolfram MathWorld (http://mathworld.wolfram.com/ComplexInfinity.html)
* for a definition of complex infinity.
*/
template <typename T>
struct infinity;
/**
* \brief Auxiliary class for computing the minimum elements over the given
* dimension for a container of the given category.
* \tparam Dim The dimension number (starting from 1).
* \tparam CategoryT The category type (e.g., vector_tag).
*/
template <std::size_t Dim, typename CategoryT>
struct min_by_dim_impl;
/**
* \brief Auxiliary class for computing the minimum elements over the given
* dimension tag for a container of the given category.
* \tparam TagT The dimension tag type (e.g., tag::major).
* \tparam CategoryT The category type (e.g., vector_tag).
* \tparam OrientationT The orientation category type (e.g., row_major_tag).
*/
template <typename TagT, typename CategoryT, typename OrientationT>
struct min_by_tag_impl;
//@} Declarations
//@{ Definitions
template <typename T>
BOOST_UBLAS_INLINE
bool less_than_impl(T a, T b)
{
return a < b;
}
template <typename T>
BOOST_UBLAS_INLINE
bool less_than_impl(::std::complex<T> const& a, ::std::complex<T> const& b)
{
// For complex numbers compare modulus and phase angle
// Use the same logic used by MATLAB for the 'min' function:
// "For complex input A, min returns the complex number with the smallest
// complex modulus (magnitude), computed with min(abs(A)). Then
// computes the smallest phase angle with min(angle(x)), if necessary"
const T ax(::std::abs(a));
const T bx(::std::abs(b));
return ax < bx
|| (ax == bx && ::std::arg(a) < ::std::arg(b));
}
template <typename T>
struct infinity
{
static const T value;
};
template <typename T>
const T infinity<T>::value = ::std::numeric_limits<T>::has_infinity ? ::std::numeric_limits<T>::infinity() : ::std::numeric_limits<T>::max();
template <typename T>
struct infinity< ::std::complex<T> >
{
static const ::std::complex<T> value;
};
template <typename T>
const ::std::complex<T> infinity< ::std::complex<T> >::value = ::std::complex<T>(infinity<T>::value,::std::numeric_limits<T>::quiet_NaN());
template <>
struct min_by_dim_impl<1, vector_tag>
{
template <typename VectorExprT>
BOOST_UBLAS_INLINE
static vector<typename vector_traits<VectorExprT>::value_type> apply(vector_expression<VectorExprT> const& ve)
{
typedef typename vector_traits<VectorExprT>::value_type value_type;
vector<value_type> res(1);
res(0) = min(ve);
return res;
}
};
template <>
struct min_by_dim_impl<1, matrix_tag>
{
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
static vector<typename matrix_traits<MatrixExprT>::value_type> apply(matrix_expression<MatrixExprT> const& me)
{
return min_rows(me);
}
};
template <>
struct min_by_dim_impl<2, matrix_tag>
{
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
static vector<typename matrix_traits<MatrixExprT>::value_type> apply(matrix_expression<MatrixExprT> const& me)
{
return min_columns(me);
}
};
template <>
struct min_by_tag_impl<tag::major, matrix_tag, row_major_tag>
{
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
static vector<typename matrix_traits<MatrixExprT>::value_type> apply(matrix_expression<MatrixExprT> const& me)
{
return min_rows(me);
}
};
template <>
struct min_by_tag_impl<tag::minor, matrix_tag, row_major_tag>
{
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
static vector<typename matrix_traits<MatrixExprT>::value_type> apply(matrix_expression<MatrixExprT> const& me)
{
return min_columns(me);
}
};
template <>
struct min_by_tag_impl<tag::leading, matrix_tag, row_major_tag>
{
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
static vector<typename matrix_traits<MatrixExprT>::value_type> apply(matrix_expression<MatrixExprT> const& me)
{
return min_columns(me);
}
};
template <>
struct min_by_tag_impl<tag::major, matrix_tag, column_major_tag>
{
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
static vector<typename matrix_traits<MatrixExprT>::value_type> apply(matrix_expression<MatrixExprT> const& me)
{
return min_columns(me);
}
};
template <>
struct min_by_tag_impl<tag::minor, matrix_tag, column_major_tag>
{
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
static vector<typename matrix_traits<MatrixExprT>::value_type> apply(matrix_expression<MatrixExprT> const& me)
{
return min_rows(me);
}
};
template <>
struct min_by_tag_impl<tag::leading, matrix_tag, column_major_tag>
{
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
static vector<typename matrix_traits<MatrixExprT>::value_type> apply(matrix_expression<MatrixExprT> const& me)
{
return min_rows(me);
}
};
template <typename TagT>
struct min_by_tag_impl<TagT, matrix_tag, unknown_orientation_tag>: min_by_tag_impl<TagT, matrix_tag, row_major_tag>
{
// Empty
};
//@} Definitions
}} // Namespace detail::<unnamed>
//@{ Definitions
template <typename VectorExprT>
BOOST_UBLAS_INLINE
typename vector_traits<VectorExprT>::value_type min(vector_expression<VectorExprT> const& ve)
{
typedef typename vector_traits<VectorExprT>::size_type size_type;
typedef typename vector_traits<VectorExprT>::value_type value_type;
size_type n = size(ve);
/*
value_type m = ::std::numeric_limits<value_type>::has_infinity
? ::std::numeric_limits<value_type>::infinity()
: ::std::numeric_limits<value_type>::max();
*/
value_type m = detail::infinity<value_type>::value;
for (size_type i = 0; i < n; ++i)
{
// if (ve()(i) < m)
if (detail::less_than_impl(ve()(i), m))
{
m = ve()(i);
}
}
return m;
}
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
typename matrix_traits<MatrixExprT>::value_type min(matrix_expression<MatrixExprT> const& me)
{
typedef typename matrix_traits<MatrixExprT>::size_type size_type;
typedef typename matrix_traits<MatrixExprT>::value_type value_type;
size_type nr = num_rows(me);
size_type nc = num_columns(me);
// value_type m = ::std::numeric_limits<value_type>::has_infinity
// ? ::std::numeric_limits<value_type>::infinity()
// : ::std::numeric_limits<value_type>::max();
value_type m = detail::infinity<value_type>::value;
for (size_type r = 0; r < nr; ++r)
{
for (size_type c = 0; c < nc; ++c)
{
// if (me()(r,c) < m)
if (detail::less_than_impl(me()(r,c), m))
{
m = me()(r,c);
}
}
}
return m;
}
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
vector<typename matrix_traits<MatrixExprT>::value_type> min_rows(matrix_expression<MatrixExprT> const& me)
{
typedef typename matrix_traits<MatrixExprT>::size_type size_type;
typedef typename matrix_traits<MatrixExprT>::value_type value_type;
size_type nr = num_rows(me);
size_type nc = num_columns(me);
vector<value_type> res(nr);
size_type j = 0;
for (size_type r = 0; r < nr; ++r)
{
// value_type m = ::std::numeric_limits<value_type>::has_infinity
// ? ::std::numeric_limits<value_type>::infinity()
// : ::std::numeric_limits<value_type>::max();
value_type m = detail::infinity<value_type>::value;
for (size_type c = 0; c < nc; ++c)
{
// if (me()(r,c) < m)
if (detail::less_than_impl(me()(r,c), m))
{
m = me()(r,c);
}
}
res(j++) = m;
}
return res;
}
template <typename MatrixExprT>
BOOST_UBLAS_INLINE
vector<typename matrix_traits<MatrixExprT>::value_type> min_columns(matrix_expression<MatrixExprT> const& me)
{
typedef typename matrix_traits<MatrixExprT>::size_type size_type;
typedef typename matrix_traits<MatrixExprT>::value_type value_type;
size_type nr = num_rows(me);
size_type nc = num_columns(me);
vector<value_type> res(nc);
size_type j = 0;
for (size_type c = 0; c < nc; ++c)
{
// value_type m = ::std::numeric_limits<value_type>::has_infinity
// ? ::std::numeric_limits<value_type>::infinity()
// : ::std::numeric_limits<value_type>::max();
value_type m = detail::infinity<value_type>::value;
for (size_type r = 0; r < nr; ++r)
{
// if (me()(r,c) < m)
if (detail::less_than_impl(me()(r,c), m))
{
m = me()(r,c);
}
}
res(j++) = m;
}
return res;
}
template <size_t Dim, typename VectorExprT>
BOOST_UBLAS_INLINE
vector<typename vector_traits<VectorExprT>::value_type> min(vector_expression<VectorExprT> const& ve)
{
return detail::min_by_dim_impl<Dim, vector_tag>::template apply(ve);
}
template <size_t Dim, typename MatrixExprT>
BOOST_UBLAS_INLINE
vector<typename matrix_traits<MatrixExprT>::value_type> min(matrix_expression<MatrixExprT> const& me)
{
return detail::min_by_dim_impl<Dim, matrix_tag>::template apply(me);
}
template <typename TagT, typename MatrixExprT>
//template <typename MatrixExprT, typename TagT>
BOOST_UBLAS_INLINE
vector<typename matrix_traits<MatrixExprT>::value_type> min_by_tag(matrix_expression<MatrixExprT> const& me)
{
return detail::min_by_tag_impl<TagT, matrix_tag, typename matrix_traits<MatrixExprT>::orientation_category>::template apply(me);
}
//@} Definitions
}}} // Namespace boost::numeric::ublasx
#endif // BOOST_NUMERIC_UBLASX_OPERATION_MIN_HPP
| 28.617761 | 141 | 0.7386 | comcon1 |
8db55372d7fc7443e71fd2ccb5aa44aa4cdba025 | 3,091 | cpp | C++ | src/Graniastoslup.cpp | HPytkiewicz/Dron2 | 1c959a63022b05fa1ee9eb32179891bfd59996b6 | [
"MIT"
] | null | null | null | src/Graniastoslup.cpp | HPytkiewicz/Dron2 | 1c959a63022b05fa1ee9eb32179891bfd59996b6 | [
"MIT"
] | null | null | null | src/Graniastoslup.cpp | HPytkiewicz/Dron2 | 1c959a63022b05fa1ee9eb32179891bfd59996b6 | [
"MIT"
] | null | null | null | #include "Graniastoslup.hh"
void Graniastoslup::rysuj()
{
this->usun();
(*this).ustaw_globalnie();
this->id = this->lacze->draw_polyhedron(wierzcholki_globalnie, kolor);
}
void Graniastoslup::usun()
{
this->lacze->erase_shape(this->id);
}
void Graniastoslup::ustaw_globalnie()
{
this->wierzcholki_globalnie = {
{
Point3D((*this).wierzcholki_lokalnie[0][0]+srodek[0], (*this).wierzcholki_lokalnie[0][1]+srodek[1], (*this).wierzcholki_lokalnie[0][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[1][0]+srodek[0], (*this).wierzcholki_lokalnie[1][1]+srodek[1], (*this).wierzcholki_lokalnie[1][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[2][0]+srodek[0], (*this).wierzcholki_lokalnie[2][1]+srodek[1], (*this).wierzcholki_lokalnie[2][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[3][0]+srodek[0], (*this).wierzcholki_lokalnie[3][1]+srodek[1], (*this).wierzcholki_lokalnie[3][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[4][0]+srodek[0], (*this).wierzcholki_lokalnie[4][1]+srodek[1], (*this).wierzcholki_lokalnie[4][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[5][0]+srodek[0], (*this).wierzcholki_lokalnie[5][1]+srodek[1], (*this).wierzcholki_lokalnie[5][2]+srodek[2]),
},
{
Point3D((*this).wierzcholki_lokalnie[6][0]+srodek[0], (*this).wierzcholki_lokalnie[6][1]+srodek[1], (*this).wierzcholki_lokalnie[6][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[7][0]+srodek[0], (*this).wierzcholki_lokalnie[7][1]+srodek[1], (*this).wierzcholki_lokalnie[7][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[8][0]+srodek[0], (*this).wierzcholki_lokalnie[8][1]+srodek[1], (*this).wierzcholki_lokalnie[8][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[9][0]+srodek[0], (*this).wierzcholki_lokalnie[9][1]+srodek[1], (*this).wierzcholki_lokalnie[9][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[10][0]+srodek[0], (*this).wierzcholki_lokalnie[10][1]+srodek[1], (*this).wierzcholki_lokalnie[10][2]+srodek[2]),
Point3D((*this).wierzcholki_lokalnie[11][0]+srodek[0], (*this).wierzcholki_lokalnie[11][1]+srodek[1], (*this).wierzcholki_lokalnie[11][2]+srodek[2]),
}};
}
void Graniastoslup::zeruj_lokalne()
{
for(int i=0; i<12; i++)
this->wierzcholki_lokalnie[i] = this->zapasowe_lokalne[i];
}
void Graniastoslup::skrec()
{
(*this).zeruj_lokalne();
(*this).zeruj_orientacje();
auto rot = MacierzObrotu::Z(katZ)*MacierzObrotu::Y(katY)*MacierzObrotu::X(katX);
this->orientacja = this->orientacja * rot;
for (int i = 0; i < 12; i++)
{
(*this).wierzcholki_lokalnie[i] = orientacja * (*this).wierzcholki_lokalnie[i];
}
}
void Graniastoslup::naprzod(double odleglosc, double katpom)
{
this->dodaj_katX(katpom);
Wektor3D pomoc = {0,odleglosc,0};
pomoc = this->orientacja * pomoc;
this->srodek=this->srodek + pomoc;
}
void Graniastoslup::ustaw_srodek(Wektor3D nowy_srodek)
{
this->srodek = nowy_srodek;
} | 47.553846 | 161 | 0.657716 | HPytkiewicz |
8db7c98b75ce33640e5ebd96fc9dd5e6b6b5d27a | 6,553 | cpp | C++ | test/common/binaryreader.cpp | seedhartha/revan | b9a98007ca2f510b42894ecd09fb623571b433dc | [
"MIT"
] | 37 | 2020-06-27T18:50:48.000Z | 2020-08-02T14:13:51.000Z | test/common/binaryreader.cpp | seedhartha/revan | b9a98007ca2f510b42894ecd09fb623571b433dc | [
"MIT"
] | null | null | null | test/common/binaryreader.cpp | seedhartha/revan | b9a98007ca2f510b42894ecd09fb623571b433dc | [
"MIT"
] | 1 | 2020-07-14T13:32:15.000Z | 2020-07-14T13:32:15.000Z | /*
* Copyright (c) 2020-2022 The reone project contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <boost/test/unit_test.hpp>
#include "../../src/common/binaryreader.h"
#include "../../src/common/stream/bytearrayinput.h"
#include "../../src/common/stringbuilder.h"
#include "../checkutil.h"
using namespace std;
using namespace reone;
BOOST_AUTO_TEST_SUITE(binary_reader)
BOOST_AUTO_TEST_CASE(should_seek_ignore_and_tell_in_little_endian_stream) {
// given
auto input = ByteArray("Hello, world!\x00", 13);
auto stream = ByteArrayInputStream(input);
auto reader = BinaryReader(stream, boost::endian::order::little);
auto expectedPos = 7ll;
// when
reader.seek(5);
reader.ignore(2);
auto actualPos = reader.tell();
// then
BOOST_CHECK_EQUAL(expectedPos, actualPos);
}
BOOST_AUTO_TEST_CASE(should_read_from_little_endian_stream) {
// given
auto input = StringBuilder()
.append("\xff", 1)
.append("\x01\xff", 2)
.append("\x02\xff\xff\xff", 4)
.append("\x03\xff\xff\xff\xff\xff\xff\xff", 8)
.append("\x01\xff", 2)
.append("\x02\xff\xff\xff", 4)
.append("\x03\xff\xff\xff\xff\xff\xff\xff", 8)
.append("\x00\x00\x80\x3f", 4)
.append("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8)
.append("Hello, world!")
.append("Hello, world!\x00", 14)
.append("\x48\x00\x65\x00\x6c\x00\x6c\x00\x6f\x00\x2c\x00\x20\x00\x77\x00\x6f\x00\x72\x00\x6c\x00\x64\x00\x21\x00\x00\x00", 28)
.append("\x01\x02\x03\x04", 4)
.build();
auto inputBytes = ByteArray();
inputBytes.resize(input.size());
inputBytes.insert(inputBytes.begin(), input.begin(), input.end());
auto stream = ByteArrayInputStream(inputBytes);
auto reader = BinaryReader(stream, boost::endian::order::little);
auto expectedByte = 255u;
auto expectedUint16 = 65281u;
auto expectedUint32 = 4294967042u;
auto expectedUint64 = 18446744073709551363u;
auto expectedInt16 = -255;
auto expectedInt32 = -254;
auto expectedInt64 = -253;
auto expectedFloat = 1.0f;
auto expectedDouble = 1.0;
auto expectedStr = string("Hello, world!");
auto expectedCStr = string("Hello, world!");
auto expectedU16CStr = u16string(u"Hello, world!");
auto expectedBytes = ByteArray({0x01, 0x02, 0x03, 0x04});
// when
auto actualByte = reader.getByte();
auto actualUint16 = reader.getUint16();
auto actualUint32 = reader.getUint32();
auto actualUint64 = reader.getUint64();
auto actualInt16 = reader.getInt16();
auto actualInt32 = reader.getInt32();
auto actualInt64 = reader.getInt64();
auto actualFloat = reader.getFloat();
auto actualDouble = reader.getDouble();
auto actualStr = reader.getString(13);
auto actualCStr = reader.getNullTerminatedString();
auto actualU16CStr = reader.getNullTerminatedStringUTF16();
auto actualBytes = reader.getBytes(4);
// then
BOOST_CHECK_EQUAL(expectedByte, actualByte);
BOOST_CHECK_EQUAL(expectedUint16, actualUint16);
BOOST_CHECK_EQUAL(expectedUint32, actualUint32);
BOOST_CHECK_EQUAL(expectedUint64, actualUint64);
BOOST_CHECK_EQUAL(expectedInt16, actualInt16);
BOOST_CHECK_EQUAL(expectedInt32, actualInt32);
BOOST_CHECK_EQUAL(expectedInt64, actualInt64);
BOOST_CHECK_EQUAL(expectedFloat, actualFloat);
BOOST_CHECK_EQUAL(expectedDouble, actualDouble);
BOOST_TEST((expectedStr == actualStr), notEqualMessage(expectedStr, actualStr));
BOOST_TEST((expectedCStr == actualCStr), notEqualMessage(expectedCStr, actualCStr));
BOOST_TEST((expectedU16CStr == actualU16CStr), notEqualMessage(expectedU16CStr, actualU16CStr));
BOOST_TEST((expectedBytes == actualBytes), notEqualMessage(expectedBytes, actualBytes));
}
BOOST_AUTO_TEST_CASE(should_read_from_big_endian_stream) {
// given
auto input = StringBuilder()
.append("\xff\x01", 2)
.append("\xff\xff\xff\x02", 4)
.append("\xff\xff\xff\xff\xff\xff\xff\x03", 8)
.append("\xff\x01", 2)
.append("\xff\xff\xff\x02", 4)
.append("\xff\xff\xff\xff\xff\xff\xff\x03", 8)
.append("\x3f\x80\x00\x00", 4)
.append("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8)
.build();
auto inputBytes = ByteArray();
inputBytes.resize(input.size());
inputBytes.insert(inputBytes.begin(), input.begin(), input.end());
auto stream = ByteArrayInputStream(inputBytes);
auto reader = BinaryReader(stream, boost::endian::order::big);
auto expectedUint16 = 65281u;
auto expectedUint32 = 4294967042u;
auto expectedUint64 = 18446744073709551363u;
auto expectedInt16 = -255;
auto expectedInt32 = -254;
auto expectedInt64 = -253;
auto expectedFloat = 1.0f;
auto expectedDouble = 1.0;
// when
auto actualUint16 = reader.getUint16();
auto actualUint32 = reader.getUint32();
auto actualUint64 = reader.getUint64();
auto actualInt16 = reader.getInt16();
auto actualInt32 = reader.getInt32();
auto actualInt64 = reader.getInt64();
auto actualFloat = reader.getFloat();
auto actualDouble = reader.getDouble();
// then
BOOST_CHECK_EQUAL(expectedUint16, actualUint16);
BOOST_CHECK_EQUAL(expectedUint32, actualUint32);
BOOST_CHECK_EQUAL(expectedUint64, actualUint64);
BOOST_CHECK_EQUAL(expectedInt16, actualInt16);
BOOST_CHECK_EQUAL(expectedInt32, actualInt32);
BOOST_CHECK_EQUAL(expectedInt64, actualInt64);
BOOST_CHECK_EQUAL(expectedFloat, actualFloat);
BOOST_CHECK_EQUAL(expectedDouble, actualDouble);
}
BOOST_AUTO_TEST_SUITE_END()
| 39.957317 | 148 | 0.664123 | seedhartha |
8db90828360bf22dba8e8fdb0f4859b2f5b28d9a | 519 | cpp | C++ | judges/codeforces/exercises/bus_to_udayland.cpp | eduardonunes2525/competitive-programming | 0f6bdc573b4d03d1ed20a2b77ec5388dca1ee47b | [
"MIT"
] | null | null | null | judges/codeforces/exercises/bus_to_udayland.cpp | eduardonunes2525/competitive-programming | 0f6bdc573b4d03d1ed20a2b77ec5388dca1ee47b | [
"MIT"
] | 1 | 2018-10-17T11:53:02.000Z | 2018-10-17T11:54:42.000Z | judges/codeforces/exercises/bus_to_udayland.cpp | eduardonunes2525/competitive-programming | 0f6bdc573b4d03d1ed20a2b77ec5388dca1ee47b | [
"MIT"
] | 1 | 2018-10-17T12:14:04.000Z | 2018-10-17T12:14:04.000Z | #include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
vector<string> v;
string s;
bool b = false;
for(int i = 0; i < n; i++){
cin >> s; v.push_back(s);
if(s[0]=='O' and s[1]=='O' and !b) { b=true; v[i][0]='+'; v[i][1]='+'; }
else if(s[3]=='O' and s[4]=='O' and !b) { b=true; v[i][3]='+'; v[i][4]='+'; }
}
if(b) {
cout << "YES" << endl;
for(auto ss : v) cout << ss << endl;
}
else cout << "NO" << endl;
return 0;
}
| 21.625 | 85 | 0.414258 | eduardonunes2525 |
8db9369e9e20744cda77780c510e28c8bfa976de | 532 | hpp | C++ | 3rdparty/diy/include/diy/mpi/request.hpp | wgq-iapcm/Parvoro- | 9459e1081ff948628358c59207d5fcd8ce60ef8f | [
"BSD-3-Clause"
] | 43 | 2016-10-23T14:52:59.000Z | 2022-03-18T20:47:06.000Z | 3rdparty/diy/include/diy/mpi/request.hpp | wgq-iapcm/Parvoro- | 9459e1081ff948628358c59207d5fcd8ce60ef8f | [
"BSD-3-Clause"
] | 39 | 2016-11-25T22:14:09.000Z | 2022-01-13T21:44:51.000Z | 3rdparty/diy/include/diy/mpi/request.hpp | wgq-iapcm/Parvoro- | 9459e1081ff948628358c59207d5fcd8ce60ef8f | [
"BSD-3-Clause"
] | 21 | 2016-11-28T22:08:36.000Z | 2022-03-16T10:31:32.000Z | #ifndef DIY_MPI_REQUEST_HPP
#define DIY_MPI_REQUEST_HPP
#include "config.hpp"
#include "status.hpp"
#include "optional.hpp"
namespace diy
{
namespace mpi
{
struct request
{
DIY_MPI_EXPORT_FUNCTION request();
DIY_MPI_EXPORT_FUNCTION status wait();
DIY_MPI_EXPORT_FUNCTION optional<status> test();
DIY_MPI_EXPORT_FUNCTION void cancel();
DIY_MPI_Request handle;
};
}
} // diy::mpi
#ifndef DIY_MPI_AS_LIB
#include "request.cpp"
#endif
#endif // DIY_MPI_REQUEST_HPP
| 17.733333 | 55 | 0.68985 | wgq-iapcm |
8dbf701ab66298d8b13da5828d6cceab6aa8ad8c | 23,720 | cpp | C++ | dss_town/src/sys/msys_glext.cpp | mudlord/demos | 359bada56a27ddbd4fcb846c0ff34bc474cb7f05 | [
"Unlicense"
] | 20 | 2017-12-12T16:37:25.000Z | 2022-02-19T10:35:46.000Z | dss_town/src/sys/msys_glext.cpp | mudlord/demos | 359bada56a27ddbd4fcb846c0ff34bc474cb7f05 | [
"Unlicense"
] | null | null | null | dss_town/src/sys/msys_glext.cpp | mudlord/demos | 359bada56a27ddbd4fcb846c0ff34bc474cb7f05 | [
"Unlicense"
] | 7 | 2017-12-29T23:19:18.000Z | 2021-08-17T09:53:15.000Z | #define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include <windows.h>
#include <GL/gl.h>
#include <gl/GLU.h>
#include "glext.h"
#include <string.h>
#include "ddraw.h"
#include "msys_texgen.h"
#include "msys.h"
//--- d a t a ---------------------------------------------------------------
#include "msys_glext.h"
static char *funciones = {
// multitexture
"glActiveTextureARB\x0"
"glClientActiveTextureARB\x0"
"glMultiTexCoord4fvARB\x0"
// programs
"glDeleteProgramsARB\x0"
"glBindProgramARB\x0"
"glProgramStringARB\x0"
"glProgramLocalParameter4fvARB\x0"
"glProgramEnvParameter4fvARB\x0"
// textures 3d
"glTexImage3D\x0"
// vbo-ibo
"glBindBufferARB\x0"
"glBufferDataARB\x0"
"glBufferSubDataARB\x0"
"glDeleteBuffersARB\x0"
// shader
"glCreateProgram\x0"
"glCreateShader\x0"
"glShaderSource\x0"
"glCompileShader\x0"
"glAttachShader\x0"
"glLinkProgram\x0"
"glUseProgram\x0"
"glUniform4fv\x0"
"glUniform1i\x0"
"glGetUniformLocationARB\x0"
"glGetObjectParameterivARB\x0"
"glGetInfoLogARB\x0"
"glLoadTransposeMatrixf\x0"
"glBindRenderbufferEXT\x0"
"glDeleteRenderbuffersEXT\x0"
"glRenderbufferStorageEXT\x0"
"glBindFramebufferEXT\x0"
"glDeleteFramebuffersEXT\x0"
"glCheckFramebufferStatusEXT\x0"
"glFramebufferTexture1DEXT\x0"
"glFramebufferTexture2DEXT\x0"
"glFramebufferTexture3DEXT\x0"
"glFramebufferRenderbufferEXT\x0"
"glGenerateMipmapEXT\x0"
"glCompressedTexImage2DARB\x0"
"wglSwapIntervalEXT\x0"
"glGenFramebuffersEXT\x0"
"glGenRenderbuffersEXT\x0"
};
void *msys_oglfunc[NUMFUNCIONES];
//--- c o d e ---------------------------------------------------------------
int msys_glextInit( void )
{
char *str = funciones;
for( int i=0; i<NUMFUNCIONES; i++ )
{
msys_oglfunc[i] = wglGetProcAddress( str );
str += 1+strlen( str );
if( !msys_oglfunc[i] )
return( 0 );
}
return( 1 );
}
// Sets an orthographic projection. x: 0..width, y: 0..height
void BeginOrtho2D(float width, float height, bool flip_y)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
if (!flip_y)
{
gluOrtho2D(0, width, 0, height);
}
else
{
glOrtho(0, width, height, 0, -1, 1);
}
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}
// Sets an orthographic projection. x: x1..x2, y: y1..y2
void BeginOrtho2D(float x1, float y1, float x2, float y2)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(x1, x2, y1, y2);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}
void draw_sprite(sprite spr, int xres, int yres, bool flip_y)
{
float zPos = 0.0;
float tX=spr.xsize/2.0f;
float tY=spr.ysize/2.0f;
if (flip_y)BeginOrtho2D(xres,yres,true);
else
BeginOrtho2D(xres,yres);
glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D,spr.texture);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glPushMatrix(); // Save modelview matrix
glTranslatef(spr.x,spr.y,0.0f); // Position sprite
glBegin(GL_QUADS); // Draw sprite
glTexCoord2f(0.0f,0.0f); glVertex3i(-tX, tY,zPos);
glTexCoord2f(0.0f,1.0f); glVertex3i(-tX,-tY,zPos);
glTexCoord2f(1.0f,1.0f); glVertex3i( tX,-tY,zPos);
glTexCoord2f(1.0f,0.0f); glVertex3i( tX, tY,zPos);
glEnd();
glPopMatrix(); // Restore modelview matrix
glBindTexture(GL_TEXTURE_2D,0);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
EndProjection();
}
//draw fullscreen quad
//useful for postproc
void DrawFullScreenQuad( int iWidth, int iHeight )
{
glBegin(GL_QUADS);
// Display the top left point of the 2D image
glTexCoord2f(0.0f, 1.0f); glVertex2f(0, 0);
// Display the bottom left point of the 2D image
//glTexCoord2f(0.0f, 0.0f); glVertex2f(0, SCREEN_HEIGHT);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0, iHeight);
// Display the bottom right point of the 2D image
//glTexCoord2f(1.0f, 0.0f); glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
glTexCoord2f(1.0f, 0.0f); glVertex2f(iWidth, iHeight);
// Display the top right point of the 2D image
//glTexCoord2f(1.0f, 1.0f); glVertex2f(SCREEN_WIDTH, 0);
glTexCoord2f(1.0f, 1.0f); glVertex2f(iWidth, 0);
// Stop drawing
glEnd();
}
// Sets a perspective projection with a different field-of-view
void BeginPerspective(float fovy, float xratio)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPerspective(fovy, xratio, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}
// Restore the previous projection
void EndProjection()
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
void DrawStaticBG()
{
BeginOrtho2D(1, 1);
glDepthMask(GL_FALSE);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f);
glEnd();
glDepthMask(GL_TRUE);
EndProjection();
}
void DrawShaky()
{
BeginOrtho2D(1, 1);
glDepthMask(GL_FALSE);
float x = (rand()%10)/100.0f;
float y = (rand()%10)/100.0f;
glTranslatef(-x, -y, 0);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(1.2f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(1.2f, 1.2f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.2f);
glEnd();
glDepthMask(GL_TRUE);
EndProjection();
}
// Draws a background with a rotating cube viewed at a
// very high field-of-view
void DrawRot(float time)
{
BeginPerspective(140, 1.33f);
glDepthMask(GL_FALSE);
glRotatef(time*32, 1, 0, 0);
glRotatef(time*67, 0, 1, 0);
glBegin(GL_QUADS);
// Front
glNormal3f(0, 0, 1);
glTexCoord2f(0, 0); glVertex3f(-1, -1, -1);
glTexCoord2f(1, 0); glVertex3f( 1, -1, -1);
glTexCoord2f(1, 1); glVertex3f( 1, 1, -1);
glTexCoord2f(0, 1); glVertex3f(-1, 1, -1);
// Left
glNormal3f(1, 0, 0);
glTexCoord2f(0, 0); glVertex3f(-1, -1, 1);
glTexCoord2f(1, 0); glVertex3f(-1, -1, -1);
glTexCoord2f(1, 1); glVertex3f(-1, 1, -1);
glTexCoord2f(0, 1); glVertex3f(-1, 1, 1);
// Bottom
glNormal3f(0, 1, 0);
glTexCoord2f(0, 0); glVertex3f(-1, -1, 1);
glTexCoord2f(1, 0); glVertex3f( 1, -1, 1);
glTexCoord2f(1, 1); glVertex3f( 1, -1, -1);
glTexCoord2f(0, 1); glVertex3f(-1, -1, -1);
// Back
glNormal3f(0, 0, -10);
glTexCoord2f(0, 0); glVertex3f( 1, -1, 1);
glTexCoord2f(1, 0); glVertex3f(-1, -1, 1);
glTexCoord2f(1, 1); glVertex3f(-1, 1, 1);
glTexCoord2f(0, 1); glVertex3f( 1, 1, 1);
// Right
glNormal3f(0, -1, 0);
glTexCoord2f(0, 0); glVertex3f( 1, -1, -1);
glTexCoord2f(1, 0); glVertex3f( 1, -1, 1);
glTexCoord2f(1, 1); glVertex3f( 1, 1, 1);
glTexCoord2f(0, 1); glVertex3f( 1, 1, -1);
// Top
glNormal3f(0, -1, 0);
glTexCoord2f(0, 0); glVertex3f(-1, 1, 1);
glTexCoord2f(1, 0); glVertex3f( 1, 1, 1);
glTexCoord2f(1, 1); glVertex3f( 1, 1, -1);
glTexCoord2f(0, 1); glVertex3f(-1, 1, -1);
glEnd();
glDepthMask(GL_TRUE);
EndProjection();
}
// Draws a background rotating around its center
void DrawRotateTile(float rot)
{
BeginOrtho2D(-1, -1, 1, 1);
glDepthMask(GL_FALSE);
glRotatef(rot, 0, 0, 1);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(-1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(-1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(-1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(-1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, -1.0f);
glEnd();
glDepthMask(GL_TRUE);
EndProjection();
}
// Draw a sine distorted background
void DrawDistort(float time)
{
BeginOrtho2D(-1, -1, 1, 1);
glScalef(1.2f, 1.2f, 1.0f);
glDepthMask(GL_FALSE);
//time *= ;
float step = 0.05f;
float kx = 0.04f;
float ky = 0.03f;
float ax = 14.3f;
float bx = 7.2f;
float cx = 9.12f;
float dx = 21.7f;
for(float a = -1; a < 1; a += step)
{
glBegin(GL_TRIANGLE_STRIP);
for(float b = -1; b <= 1.01f; b += step)
{
glTexCoord2f(b*0.5f+0.5f, a*0.5f+0.5f);
glVertex2f(b + sinf(b*dx+time*bx) * kx, a + sinf(a*ax+time*0.7f*cx) * ky);
glTexCoord2f(b*0.5f+0.5f, (a+step)*0.5f+0.5f);
glVertex2f(b + sinf(b*dx+time*bx) * kx, a + step + sinf((a+step)*ax+time*0.7f*cx) * ky);
}
glEnd();
}
glDepthMask(GL_TRUE);
EndProjection();
}
// Draw a waving background
void DrawWaving(float time)
{
BeginOrtho2D(-1, -1, 1, 1);
glScalef(1.2f, 1.2f, 1.0f);
glDepthMask(GL_FALSE);
time *= 0.5f;
float step = 0.05f;
float k = 0.2f;
for(float a = -1; a < 1; a += step)
{
glBegin(GL_TRIANGLE_STRIP);
for(float b = -1; b <= 1.01f; b += step)
{
glTexCoord2f(b*0.5f+0.5f, a*0.5f+0.5f);
glVertex2f(b + sinf(a+time) * k * (sqrtf(2) - sqrtf(a*a+b*b)), a + sinf(b+time*0.7f) * k * (sqrtf(2) - sqrtf(a*a+b*b)));
glTexCoord2f(b*0.5f+0.5f, (a+step)*0.5f+0.5f);
glVertex2f(b + sinf(a+step+time) * k * (sqrtf(2) - sqrtf((a+step)*(a+step)+b*b)), a + step + sinf(b+time*0.7f) * k * (sqrtf(2) - sqrtf((a+step)*(a+step)+b*b)));
}
glEnd();
}
glDepthMask(GL_TRUE);
EndProjection();
}
// And finally the zooming background
void DrawZooming(float time)
{
BeginOrtho2D(1, 1);
glDepthMask(GL_FALSE);
time *= 0.5f;
glBegin(GL_QUADS);
glTexCoord2f(0.0f+time, 0.0f+time); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f-time, 0.0f+time); glVertex2f(1.0f, 0.0f);
glTexCoord2f(1.0f-time, 1.0f-time); glVertex2f(1.0f, 1.0f);
glTexCoord2f(0.0f+time, 1.0f-time); glVertex2f(0.0f, 1.0f);
glEnd();
glDepthMask(GL_TRUE);
EndProjection();
}
void Resize(int x, int y)
{
// Prevent div by zero
y = y ? y : 1;
// Resize viewport
glViewport(0, 0, x, y);
// Recalc perspective
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f, static_cast<float>(x)/static_cast<float>(y), 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
struct DDS_IMAGE_DATA
{
GLsizei width;
GLsizei height;
GLint components;
GLenum format;
int numMipMaps;
GLubyte *pixels;
};
GLuint loadTexGenTexMemory(unsigned char *data,int size, int width, int height)
{
GLuint texture;
RGBA *image = (RGBA*)calloc(width*height, sizeof(RGBA));
TextureGenerator *tg=getTextureGenerator();
tg->tex2mem(&image, data,size, width, height, true);
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, 4, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, image );
free(image);
return texture;
}
GLuint loadTexGenTex(char* tex_filename, int width, int height)
{
GLuint texture;
RGBA *image = (RGBA*)calloc(width*height, sizeof(RGBA));
TextureGenerator *tg=getTextureGenerator();
tg->tex2mem(&image, tex_filename, width, height, true);
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, 4, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, image );
free(image);
return texture;
}
typedef struct
{
GLubyte Header[12]; // TGA File Header
} TGAHeader;
typedef struct
{
GLubyte header[6]; // First 6 Useful Bytes From The Header
GLuint bytesPerPixel; // Holds Number Of Bytes Per Pixel Used In The TGA File
GLuint imageSize; // Used To Store The Image Size When Setting Aside Ram
GLuint temp; // Temporary Variable
GLuint type;
GLuint Height; //Height of Image
GLuint Width; //Width ofImage
GLuint Bpp; // Bits Per Pixel
} TGA;
TGAHeader tgaheader; // TGA header
TGA tga; // TGA image data
GLubyte uTGAcompare[12] = {0,0,2, 0,0,0,0,0,0,0,0,0}; // Uncompressed TGA Header
GLubyte cTGAcompare[12] = {0,0,10,0,0,0,0,0,0,0,0,0}; // Compressed TGA Header
GLuint loadTGATextureMemory(unsigned char* data, int size, bool blur)
{
GLuint texture;
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, blur?GL_LINEAR:GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,blur?GL_LINEAR:GL_NEAREST );
BUF *fTGA = bufopen(data, size);
bufread((void*)&tgaheader,sizeof(TGAHeader),1,fTGA);
if(memcmp(uTGAcompare, &tgaheader, sizeof(tgaheader)) == 0) // See if header matches the predefined header of
{
bufread(tga.header, sizeof(tga.header), 1, fTGA);
int width = tga.header[1] * 256 + tga.header[0]; // Determine The TGA Width (highbyte*256+lowbyte)
int height = tga.header[3] * 256 + tga.header[2]; // Determine The TGA Height (highbyte*256+lowbyte)
int bpp = tga.header[4]; // Determine the bits per pixel
int textype;
if(bpp == 24) // If the BPP of the image is 24...
textype = GL_RGB; // Set Image type to GL_RGB
else // Else if its 32 BPP
textype = GL_RGBA;
int bytesperpixel = (bpp / 8); // Compute the number of BYTES per pixel
int imagesize = (bytesperpixel * width * height); // Compute the total amout ofmemory needed to store data
unsigned char* imagedata = (GLubyte *)malloc(imagesize);
bufread(imagedata, 1, imagesize, fTGA);
for(GLuint cswap = 0; cswap < (int)imagesize; cswap += bytesperpixel)
{
imagedata[cswap] ^= imagedata[cswap+2] ^=
imagedata[cswap] ^= imagedata[cswap+2];
}
glTexImage2D(GL_TEXTURE_2D, 0, textype, width, height, 0, textype, GL_UNSIGNED_BYTE, imagedata);
free(imagedata);
return texture;
}
bufclose(fTGA);
return NULL;
}
GLuint loadDDSTextureMemory(unsigned char* data, int size, bool blur)
{
GLuint texture;
DDS_IMAGE_DATA *pDDSImageData;
DDSURFACEDESC2 ddsd;
char filecode[4] = {0};
int factor;
int bufferSize;
unsigned char* dataptr = data;
memcpy(filecode,dataptr,4);
dataptr+=4;
if( strncmp( filecode, "DDS ", 4 ) != 0 )
{
char str[255];
sprintf( str, "%s","The file doesn't appear to be a valid .dds file!");
MessageBox( NULL, str, "ERROR", MB_OK|MB_ICONEXCLAMATION );
return NULL;
}
memcpy( &ddsd,dataptr, sizeof(ddsd));
dataptr+=sizeof(ddsd);
pDDSImageData = (DDS_IMAGE_DATA*) malloc(sizeof(DDS_IMAGE_DATA));
memset( pDDSImageData, 0, sizeof(DDS_IMAGE_DATA) );
switch( ddsd.ddpfPixelFormat.dwFourCC )
{
case FOURCC_DXT1:
// DXT1's compression ratio is 8:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
factor = 2;
break;
case FOURCC_DXT3:
// DXT3's compression ratio is 4:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
factor = 4;
break;
case FOURCC_DXT5:
// DXT5's compression ratio is 4:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
factor = 4;
break;
default:
char str[255];
sprintf( str, "%s","The file doesn't appear to be compressed using DXT1, DXT3, or DXT5!");
MessageBox( NULL, str, "ERROR", MB_OK|MB_ICONEXCLAMATION );
return NULL;
}
//
// How big will the buffer need to be to load all of the pixel data
// including mip-maps?
//
if( ddsd.dwLinearSize == 0 )
{
MessageBox( NULL, "dwLinearSize is 0!","ERROR",
MB_OK|MB_ICONEXCLAMATION);
}
if( ddsd.dwMipMapCount > 1 )
bufferSize = ddsd.dwLinearSize * factor;
else
bufferSize = ddsd.dwLinearSize;
pDDSImageData->pixels = (unsigned char*)malloc(bufferSize * sizeof(unsigned char));
memcpy(pDDSImageData->pixels,dataptr,bufferSize);
pDDSImageData->width = ddsd.dwWidth;
pDDSImageData->height = ddsd.dwHeight;
pDDSImageData->numMipMaps = ddsd.dwMipMapCount;
if( ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1 )
pDDSImageData->components = 3;
else
pDDSImageData->components = 4;
if( pDDSImageData != NULL )
{
int nHeight = pDDSImageData->height;
int nWidth = pDDSImageData->width;
int nNumMipMaps = pDDSImageData->numMipMaps;
int nBlockSize;
if( pDDSImageData->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT )
nBlockSize = 8;
else
nBlockSize = 16;
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, blur?GL_LINEAR:GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, blur?GL_LINEAR:GL_NEAREST );
int nSize;
int nOffset = 0;
if (nNumMipMaps == 0)
{
if( nWidth == 0 ) nWidth = 1;
if( nHeight == 0 ) nHeight = 1;
nSize = ((nWidth+3)/4) * ((nHeight+3)/4) * nBlockSize;
glCompressedTexImage2DARB( GL_TEXTURE_2D,
0,
pDDSImageData->format,
nWidth,
nHeight,
0,
nSize,
pDDSImageData->pixels + nOffset );
nOffset += nSize;
}
else
{
for( int i = 0; i < nNumMipMaps; ++i )
{
if( nWidth == 0 ) nWidth = 1;
if( nHeight == 0 ) nHeight = 1;
nSize = ((nWidth+3)/4) * ((nHeight+3)/4) * nBlockSize;
glCompressedTexImage2DARB( GL_TEXTURE_2D,
i,
pDDSImageData->format,
nWidth,
nHeight,
0,
nSize,
pDDSImageData->pixels + nOffset );
nOffset += nSize;
// Half the image size for the next mip-map level...
nWidth = (nWidth / 2);
nHeight = (nHeight / 2);
}
}
}
if( pDDSImageData != NULL )
{
if( pDDSImageData->pixels != NULL )
free( pDDSImageData->pixels );
free( pDDSImageData );
}
return texture;
}
GLuint loadDDSTextureFile( const char *filename, bool blur )
{
GLuint texture = 0;
DDS_IMAGE_DATA *pDDSImageData = NULL;
DDSURFACEDESC2 ddsd;
char filecode[4] = {0};
FILE *pFile = NULL;
int factor = 0;
int bufferSize = 0;
int nSize = 0;
int nOffset = 0;
// Open the file
ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
pFile = fopen( filename, "rb" );
if( pFile == NULL )
{
char str[255];
sprintf( str, "loadDDSTextureFile couldn't find, or failed to load \"%s\"", filename );
MessageBox( NULL, str, "ERROR", MB_OK|MB_ICONEXCLAMATION );
return NULL;
}
// Verify the file is a true .dds file
fread( filecode, 1, 4, pFile );
if( strncmp( filecode, "DDS ", 4 ) != 0 )
{
char str[255];
sprintf( str, "The file \"%s\" doesn't appear to be a valid .dds file!", filename );
MessageBox( NULL, str, "ERROR", MB_OK|MB_ICONEXCLAMATION );
fclose( pFile );
return NULL;
}
// Get the surface descriptor
fread( &ddsd, sizeof(ddsd), 1, pFile );
pDDSImageData = (DDS_IMAGE_DATA*) malloc(sizeof(DDS_IMAGE_DATA));
memset( pDDSImageData, 0, sizeof(DDS_IMAGE_DATA) );
switch( ddsd.ddpfPixelFormat.dwFourCC )
{
case FOURCC_DXT1:
// DXT1's compression ratio is 8:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
factor = 2;
break;
case FOURCC_DXT3:
// DXT3's compression ratio is 4:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
factor = 4;
break;
case FOURCC_DXT5:
// DXT5's compression ratio is 4:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
factor = 4;
break;
default:
char str[255];
sprintf( str, "The file \"%s\" doesn't appear to be compressed "
"using DXT1, DXT3, or DXT5!", filename );
MessageBox( NULL, str, "ERROR", MB_OK|MB_ICONEXCLAMATION );
return NULL;
}
//
// How big will the buffer need to be to load all of the pixel data
// including mip-maps?
//
if( ddsd.dwLinearSize == 0 )
{
MessageBox( NULL, "dwLinearSize is 0!","ERROR",
MB_OK|MB_ICONEXCLAMATION);
}
if( ddsd.dwMipMapCount > 1 )
bufferSize = ddsd.dwLinearSize * factor;
else
bufferSize = ddsd.dwLinearSize;
pDDSImageData->pixels = (unsigned char*)malloc(bufferSize * sizeof(unsigned char));
fread( pDDSImageData->pixels, 1, bufferSize, pFile );
// Close the file
fclose( pFile );
pDDSImageData->width = ddsd.dwWidth;
pDDSImageData->height = ddsd.dwHeight;
pDDSImageData->numMipMaps = ddsd.dwMipMapCount;
if( ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1 )
pDDSImageData->components = 3;
else
pDDSImageData->components = 4;
if( pDDSImageData != NULL )
{
int nHeight = pDDSImageData->height;
int nWidth = pDDSImageData->width;
int nNumMipMaps = pDDSImageData->numMipMaps;
int nBlockSize;
if( pDDSImageData->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT )
nBlockSize = 8;
else
nBlockSize = 16;
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, blur?GL_LINEAR:GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,blur?GL_LINEAR:GL_NEAREST );
if (nNumMipMaps == 0)
{
if( nWidth == 0 ) nWidth = 1;
if( nHeight == 0 ) nHeight = 1;
nSize = ((nWidth+3)/4) * ((nHeight+3)/4) * nBlockSize;
glCompressedTexImage2DARB( GL_TEXTURE_2D,
0,
pDDSImageData->format,
nWidth,
nHeight,
0,
nSize,
pDDSImageData->pixels + nOffset );
nOffset += nSize;
}
else
{
for( int i = 0; i < nNumMipMaps; ++i )
{
if( nWidth == 0 ) nWidth = 1;
if( nHeight == 0 ) nHeight = 1;
nSize = ((nWidth+3)/4) * ((nHeight+3)/4) * nBlockSize;
glCompressedTexImage2DARB( GL_TEXTURE_2D,
i,
pDDSImageData->format,
nWidth,
nHeight,
0,
nSize,
pDDSImageData->pixels + nOffset );
nOffset += nSize;
// Half the image size for the next mip-map level...
nWidth = (nWidth / 2);
nHeight = (nHeight / 2);
}
}
}
if( pDDSImageData != NULL )
{
if( pDDSImageData->pixels != NULL )
free( pDDSImageData->pixels );
free( pDDSImageData );
}
return texture;
}
#ifdef _DEBUG
#include <sys/stat.h>
unsigned char *readShaderFile( const char *fileName )
{
FILE *file = fopen( fileName, "r" );
if( file == NULL )
{
MessageBox( NULL, "Cannot open shader file!", "ERROR",
MB_OK | MB_ICONEXCLAMATION );
return 0;
}
struct _stat fileStats;
if( _stat( fileName, &fileStats ) != 0 )
{
MessageBox( NULL, "Cannot get file stats for shader file!", "ERROR",
MB_OK | MB_ICONEXCLAMATION );
return 0;
}
unsigned char *buffer = new unsigned char[fileStats.st_size];
int bytes = fread( buffer, 1, fileStats.st_size, file );
buffer[bytes] = 0;
fclose( file );
return buffer;
}
#endif
void initShader( int *pid, const char *vs, const char *fs )
{
pid[0] = oglCreateProgram();
const int vsId = oglCreateShader( GL_VERTEX_SHADER );
const int fsId = oglCreateShader( GL_FRAGMENT_SHADER );
oglShaderSource( vsId, 1, &vs, 0 );
oglShaderSource( fsId, 1, &fs, 0 );
oglCompileShader( vsId );
oglCompileShader( fsId );
oglAttachShader( pid[0], fsId );
oglAttachShader( pid[0], vsId );
oglLinkProgram( pid[0] );
#ifdef DEBUG
int result;
char info[1536];
oglGetObjectParameteriv( vsId, GL_OBJECT_COMPILE_STATUS_ARB, &result ); oglGetInfoLog( vsId, 1024, NULL, (char *)info ); if( !result ) DebugBreak();
oglGetObjectParameteriv( fsId, GL_OBJECT_COMPILE_STATUS_ARB, &result ); oglGetInfoLog( fsId, 1024, NULL, (char *)info ); if( !result ) DebugBreak();
oglGetObjectParameteriv( pid[0], GL_OBJECT_LINK_STATUS_ARB, &result ); oglGetInfoLog( pid[0], 1024, NULL, (char*)info ); if( !result ) DebugBreak();
#endif
} | 26.181015 | 164 | 0.665556 | mudlord |
8dbf97d5370f1cdffbfad39243fcfd0cefb30720 | 9,645 | cc | C++ | src/generators/net_caffe_convnet.cc | quadeare/deepdetect | eaf04210642fa22696d1b1fa0af1e7b9e9d25c2f | [
"Apache-2.0"
] | 2 | 2018-08-11T20:56:47.000Z | 2021-08-25T05:11:46.000Z | src/generators/net_caffe_convnet.cc | quadeare/deepdetect | eaf04210642fa22696d1b1fa0af1e7b9e9d25c2f | [
"Apache-2.0"
] | null | null | null | src/generators/net_caffe_convnet.cc | quadeare/deepdetect | eaf04210642fa22696d1b1fa0af1e7b9e9d25c2f | [
"Apache-2.0"
] | null | null | null | /**
* DeepDetect
* Copyright (c) 2014-2017 Emmanuel Benazera
* Author: Emmanuel Benazera <beniz@droidnik.fr>
*
* This file is part of deepdetect.
*
* deepdetect is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* deepdetect is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with deepdetect. If not, see <http://www.gnu.org/licenses/>.
*/
#include "net_caffe_convnet.h"
#include "imginputfileconn.h"
#include "mllibstrategy.h"
namespace dd
{
/*- NetLayersCaffeConvnet -*/
void NetLayersCaffeConvnet::parse_conv_layers(const std::vector<std::string> &layers,
std::vector<ConvBlock> &cr_layers,
std::vector<int> &fc_layers)
{
const std::string cr_str = "CR";
const std::string d_str = "DR";
const std::string u_str = "UR";
for (auto s: layers)
{
size_t pos = 0;
if ((pos=s.find(cr_str))!=std::string::npos)
{
std::string ncr = s.substr(0,pos);
std::string crs = s.substr(pos+cr_str.size());
cr_layers.push_back(ConvBlock(cr_str,std::atoi(ncr.c_str()),std::atoi(crs.c_str())));
}
else if ((pos=s.find(d_str))!=std::string::npos)
{
std::string crs = s.substr(pos+cr_str.size());
cr_layers.push_back(ConvBlock(d_str,1,std::atoi(crs.c_str())));
}
else if ((pos=s.find(u_str))!=std::string::npos)
{
std::string crs = s.substr(pos+cr_str.size());
cr_layers.push_back(ConvBlock(u_str,1,std::atoi(crs.c_str())));
}
else
{
try
{
fc_layers.push_back(std::atoi(s.c_str()));
}
catch(std::exception &e)
{
//TODO
throw MLLibBadParamException("convnet template requires fully connected layers size to be specified as a string");
}
}
}
}
std::string NetLayersCaffeConvnet::add_basic_block(caffe::NetParameter *net_param,
const std::string &bottom,
const std::string &top,
const int &nconv,
const int &num_output,
const int &kernel_size,
const int &pad,
const int &stride,
const std::string &activation,
const double &dropout_ratio,
const bool &bn,
const int &pl_kernel_size,
const int &pl_stride,
const std::string &pl_type,
const int &kernel_w,
const int &kernel_h,
const int &pl_kernel_w,
const int &pl_kernel_h,
const int &pl_stride_w,
const int &pl_stride_h)
{
std::string top_conv;
std::string bottom_conv = bottom;
for (int c=0;c<nconv;c++)
{
top_conv = top + "_conv_" + std::to_string(c);
add_conv(net_param,bottom_conv,top_conv,num_output,kernel_size,pad,stride,kernel_w,kernel_h,0,0,top_conv);
if (bn)
{
add_bn(net_param,top_conv);
if (activation != "none")
add_act(net_param,top_conv,activation);
}
else if (dropout_ratio > 0.0) // though in general, no dropout between convolutions
{
if (activation != "none")
add_act(net_param,top_conv,activation);
if (c != nconv-1)
add_dropout(net_param,top_conv,dropout_ratio);
}
else if (activation != "none")
add_act(net_param,top_conv,activation);
bottom_conv = top_conv;
}
// pooling
if (pl_type != "NONE")
add_pooling(net_param,top_conv,top,pl_kernel_size,pl_stride,pl_type,pl_kernel_w,pl_kernel_h,pl_stride_w,pl_stride_h);
/*if (dropout_ratio > 0.0 && !bn)
add_dropout(net_param,top,dropout_ratio);*/
return top_conv;
}
void NetLayersCaffeConvnet::configure_net(const APIData &ad_mllib)
{
int nclasses = -1;
if (ad_mllib.has("nclasses"))
nclasses = ad_mllib.get("nclasses").get<int>();
int ntargets = -1;
if (ad_mllib.has("ntargets"))
ntargets = ad_mllib.get("ntargets").get<int>();
bool regression = false;
if (ad_mllib.has("regression"))
regression = ad_mllib.get("regression").get<bool>();
bool autoencoder = false;
if (ad_mllib.has("autoencoder"))
autoencoder = ad_mllib.get("autoencoder").get<bool>();
bool flat1dconv = false;
if (ad_mllib.has("flat1dconv"))
flat1dconv = ad_mllib.get("flat1dconv").get<bool>();
std::vector<std::string> layers;
std::string activation = CaffeCommon::set_activation(ad_mllib);
double dropout = 0.5;
if (ad_mllib.has("layers"))
layers = ad_mllib.get("layers").get<std::vector<std::string>>();
//TODO: else raise exception
std::vector<ConvBlock> cr_layers;
std::vector<int> fc_layers;
parse_conv_layers(layers,cr_layers,fc_layers);
if (ad_mllib.has("dropout"))
dropout = ad_mllib.get("dropout").get<double>();
bool bn = false;
if (ad_mllib.has("bn"))
bn = ad_mllib.get("bn").get<bool>();
int conv_kernel_size = 3;
int conv1d_early_kernel_size = 7;
std::string bottom = "data";
bool has_deconv = false;
int width = -1;
int height = -1;
if (flat1dconv)
width = this->_net_params->mutable_layer(1)->mutable_memory_data_param()->width();
if (autoencoder)
{
width = ad_mllib.get("width").get<int>();
height = ad_mllib.get("height").get<int>();
}
std::string top_conv;
//TODO: support for embed layer in inputs
for (size_t l=0;l<cr_layers.size();l++)
{
std::string top = "ip" + std::to_string(l);
if (cr_layers.at(l)._layer == "CR")
{
if (!flat1dconv)
{
int conv_pad = 0;
if (has_deconv)
conv_pad = 1;
if (has_deconv && l == cr_layers.size()-1)
{
top_conv = add_basic_block(this->_net_params,bottom,top,cr_layers.at(l)._nconv,cr_layers.at(l)._num_output,
conv_kernel_size,conv_pad,1,"none",0.0,bn,1,1,"NONE");
top_conv = add_basic_block(this->_dnet_params,bottom,top,cr_layers.at(l)._nconv,cr_layers.at(l)._num_output,
conv_kernel_size,conv_pad,1,"none",0.0,bn,1,1,"NONE");
}
else
{
top_conv = add_basic_block(this->_net_params,bottom,top,cr_layers.at(l)._nconv,cr_layers.at(l)._num_output,
conv_kernel_size,conv_pad,1,activation,0.0,bn,2,2,has_deconv?"NONE":"MAX");
top_conv = add_basic_block(this->_dnet_params,bottom,top,cr_layers.at(l)._nconv,cr_layers.at(l)._num_output,
conv_kernel_size,conv_pad,1,activation,0.0,bn,2,2,has_deconv?"NONE":"MAX");
}
}
else
{
top_conv = add_basic_block(this->_net_params,bottom,top,cr_layers.at(l)._nconv,cr_layers.at(l)._num_output,
0,0,1,activation,0.0,bn,0,0,"MAX",bottom=="data"?width:1,l<2?conv1d_early_kernel_size:conv_kernel_size,1,3,1,3);
top_conv = add_basic_block(this->_dnet_params,bottom,top,cr_layers.at(l)._nconv,cr_layers.at(l)._num_output,
0,0,1,activation,0.0,bn,0,0,"MAX",bottom=="data"?width:1,l<2?conv1d_early_kernel_size:conv_kernel_size,1,3,1,3);
}
}
else if (cr_layers.at(l)._layer == "DR")
{
add_deconv(this->_net_params,top_conv,top,cr_layers.at(l)._num_output,2,0,2);
add_act(this->_net_params,top,activation);
add_deconv(this->_dnet_params,top_conv,top,cr_layers.at(l)._num_output,2,0,2);
add_act(this->_dnet_params,top,activation);
has_deconv = true;
}
//TODO: upsampling UR
bottom = top;
}
if (flat1dconv)
{
std::string top = "reshape0";
caffe::ReshapeParameter r_param;
r_param.mutable_shape()->add_dim(0);
r_param.mutable_shape()->add_dim(-1);
add_reshape(this->_net_params,bottom,top,r_param);
add_reshape(this->_dnet_params,bottom,top,r_param);
bottom = top;
}
bottom = top_conv;
int l = 0;
for (auto fc: fc_layers)
{
std::string top = "fc" + std::to_string(fc) + "_" + std::to_string(l);
NetLayersCaffeMLP::add_basic_block(this->_net_params,bottom,top,fc,activation,dropout,bn,false);
NetLayersCaffeMLP::add_basic_block(this->_dnet_params,bottom,top,fc,activation,0.0,bn,false);
bottom = top;
++l;
}
if (regression)
{
add_euclidean_loss(this->_net_params,bottom,"label","losst",ntargets);
add_euclidean_loss(this->_net_params,bottom,"","loss",ntargets,true);
}
else if (autoencoder)
{
std::string data = "data";
if (this->_net_params->mutable_layer(0)->top_size() == 3)
data = "orig_data";
add_interp(this->_net_params,bottom,"final_interp",width,height);
add_sigmoid_crossentropy_loss(this->_net_params,"final_interp",data,"losst",ntargets,false,false);
add_interp(this->_dnet_params,bottom,"final_interp",width,height);
add_conv(this->_dnet_params,"final_interp","conv_prob",ntargets,1,0,1);
add_flatten(this->_dnet_params,"conv_prob","conv_flatten");
add_act(this->_dnet_params,"conv_flatten","Sigmoid");
}
else
{
add_softmax(this->_net_params,bottom,"label","losst",nclasses > 0 ? nclasses : ntargets);
add_softmax(this->_dnet_params,bottom,"","loss",nclasses > 0 ? nclasses : ntargets,true);
}
}
template class NetCaffe<NetInputCaffe<ImgCaffeInputFileConn>,NetLayersCaffeConvnet,NetLossCaffe>;
template class NetCaffe<NetInputCaffe<CSVCaffeInputFileConn>,NetLayersCaffeConvnet,NetLossCaffe>;
template class NetCaffe<NetInputCaffe<TxtCaffeInputFileConn>,NetLayersCaffeConvnet,NetLossCaffe>;
template class NetCaffe<NetInputCaffe<SVMCaffeInputFileConn>,NetLayersCaffeConvnet,NetLossCaffe>;
}
| 36.534091 | 123 | 0.668533 | quadeare |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.