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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9ffaec0614573805d3d7129634bb5aa45c0e43ab
| 2,217
|
cpp
|
C++
|
GeeksForGeeks/C Plus Plus/Clone_a_linked_list_with_next_and_random_pointer.cpp
|
ankit-sr/Competitive-Programming
|
3397b313b80a32a47cfe224426a6e9c7cf05dec2
|
[
"MIT"
] | 4
|
2021-06-19T14:15:34.000Z
|
2021-06-21T13:53:53.000Z
|
GeeksForGeeks/C Plus Plus/Clone_a_linked_list_with_next_and_random_pointer.cpp
|
ankit-sr/Competitive-Programming
|
3397b313b80a32a47cfe224426a6e9c7cf05dec2
|
[
"MIT"
] | 2
|
2021-07-02T12:41:06.000Z
|
2021-07-12T09:37:50.000Z
|
GeeksForGeeks/C Plus Plus/Clone_a_linked_list_with_next_and_random_pointer.cpp
|
ankit-sr/Competitive-Programming
|
3397b313b80a32a47cfe224426a6e9c7cf05dec2
|
[
"MIT"
] | 3
|
2021-06-19T15:19:20.000Z
|
2021-07-02T17:24:51.000Z
|
/*
Problem Statement:
-----------------
You are given a special linked list with N nodes where each node has a next pointer pointing to its next node. You are also given M random pointers ,
where you will be given M number of pairs denoting two nodes a and b i.e. a->arb = b.
Example 1:
---------
Input:
N = 4, M = 2
value = {1,2,3,4}
pairs = {{1,2},{2,4}}
Output: 1
Explanation: In this test case, there re 4 nodes in linked list. Among these 4 nodes, 2 nodes have arbit pointer set, rest two nodes have arbit pointer
as NULL. Second line tells us the value of four nodes. The third line gives the information about arbitrary pointers. The first node arbit pointer is set to
node 2. The second node arbit pointer is set to node 4.
Example 2:
---------
Input:
N = 4, M = 2
value[] = {1,3,5,9}
pairs[] = {{1,1},{3,4}}
Output: 1
Explanation: In the given testcase, applying the method as stated in the above example, the output will be 1.
Your Task: The task is to complete the function copyList() which takes one argument the head of the linked list to be cloned and should return the head of the cloned linked list.
NOTE : If their is any node whose arbitrary pointer is not given then its by default null.
Expected Time Complexity : O(n)
Expected Auxilliary Space : O(1)
*/
// Link --> https://practice.geeksforgeeks.org/problems/clone-a-linked-list-with-next-and-random-pointer/1#
// Code:
Node *copyList(Node *head)
{
Node *current = head;
Node *temp;
while(current != NULL)
{
temp = current->next;
current->next = new Node(current->data);
current->next->next = temp;
current = temp;
}
current = head;
while(current != NULL)
{
current->next->arb = current->arb ? current->arb->next : current->arb;
current = current->next->next;
}
Node *originalHead = head;
Node *copyHead = head->next;
temp = copyHead;
while(originalHead and copyHead)
{
originalHead->next = originalHead->next->next;
copyHead->next = copyHead->next ? copyHead->next->next : copyHead->next;
originalHead = originalHead->next;
copyHead = copyHead->next;
}
return temp;
}
| 30.791667
| 178
| 0.657194
|
ankit-sr
|
9ffaecc6c4ea86e1a20329fec4048fea56651658
| 2,286
|
cpp
|
C++
|
Source/SmallFileCache.cpp
|
sawickiap/RegEngine
|
613c31fd60558a75c5b8902529acfa425fc97b2a
|
[
"MIT"
] | 11
|
2022-01-02T22:50:42.000Z
|
2022-02-15T09:10:25.000Z
|
Source/SmallFileCache.cpp
|
sawickiap/RegEngine
|
613c31fd60558a75c5b8902529acfa425fc97b2a
|
[
"MIT"
] | null | null | null |
Source/SmallFileCache.cpp
|
sawickiap/RegEngine
|
613c31fd60558a75c5b8902529acfa425fc97b2a
|
[
"MIT"
] | null | null | null |
#include "BaseUtils.hpp"
#include "SmallFileCache.hpp"
#include "Streams.hpp"
#include <unordered_map>
constexpr size_t MAX_CACHED_FILE_SIZE = 128llu * 1024;
SmallFileCache* g_SmallFileCache;
class SmallFileCachePimpl
{
public:
struct Entry
{
std::filesystem::file_time_type m_LastWriteTime;
std::vector<char> m_Contents;
};
// Key is file path converted to absolute-cannonical-uppercase
using MapType = std::unordered_map<wstring, Entry>;
MapType m_Entries;
};
SmallFileCache::SmallFileCache() :
m_Pimpl{std::make_unique<SmallFileCachePimpl>()}
{
}
SmallFileCache::~SmallFileCache()
{
}
void SmallFileCache::Clear()
{
m_Pimpl->m_Entries.clear();
}
std::vector<char> SmallFileCache::LoadFile(const wstr_view& path)
{
ERR_TRY;
std::filesystem::path pathP = StrToPath(path);
std::filesystem::file_time_type lastWriteTime;
if(!GetFileLastWriteTime(lastWriteTime, pathP))
FAIL(L"File doesn't exist.");
wstring key = std::filesystem::canonical(pathP);
ToUpperCase(key);
const auto it = m_Pimpl->m_Entries.find(key);
// Found in cache.
if(it != m_Pimpl->m_Entries.end())
{
// Last write time matches: Just return copy of the data.
if(it->second.m_LastWriteTime == lastWriteTime)
return it->second.m_Contents;
// Last write time doesn't match: Really load the file, update cache entry.
std::vector<char> contents = ::LoadFile(path);
if(contents.size() <= MAX_CACHED_FILE_SIZE)
{
it->second.m_LastWriteTime = lastWriteTime;
it->second.m_Contents = contents;
}
else
m_Pimpl->m_Entries.erase(it);
return contents;
}
// Not found in cache: Really load the file, create cache entry.
std::vector<char> contents = ::LoadFile(path);
if(contents.size() <= MAX_CACHED_FILE_SIZE)
{
m_Pimpl->m_Entries.insert(std::make_pair(std::move(key), SmallFileCachePimpl::Entry{
.m_LastWriteTime = lastWriteTime,
.m_Contents = contents}));
}
return contents;
ERR_CATCH_MSG(std::format(L"Small file cache couldn't load file \"{}\".", path));
}
| 28.222222
| 93
| 0.636045
|
sawickiap
|
9ffc6e16ab71d34af19ff24340ae85f67bed6e2f
| 6,516
|
cpp
|
C++
|
src/Pipe.cpp
|
JesseMaurais/SGe
|
f73bd03d30074a54642847b05f82151128481371
|
[
"MIT"
] | 1
|
2017-04-20T06:27:36.000Z
|
2017-04-20T06:27:36.000Z
|
src/Pipe.cpp
|
JesseMaurais/SGe
|
f73bd03d30074a54642847b05f82151128481371
|
[
"MIT"
] | null | null | null |
src/Pipe.cpp
|
JesseMaurais/SGe
|
f73bd03d30074a54642847b05f82151128481371
|
[
"MIT"
] | null | null | null |
#include <SDL2/SDL_config.h>
#include <cstdio>
#include "Pipe.hpp"
#include "System.hpp"
#include "SDL.hpp"
namespace
{
constexpr int R = 0, W = 1;
auto & dataR(SDL_RWops *ops)
{
return ops->hidden.unknown.data1;
}
auto & dataW(SDL_RWops *ops)
{
return ops->hidden.unknown.data2;
}
SDL_RWops *Rops(SDL_RWops *ops)
{
return (SDL_RWops*) dataR(ops);
}
SDL_RWops *Wops(SDL_RWops *ops)
{
return (SDL_RWops*) dataW(ops);
}
std::FILE *fileR(SDL_RWops *ops)
{
assert(SDL_RWOPS_STDFILE == ops->type);
return Rops(ops)->hidden.stdio.fp;
}
std::FILE *fileW(SDL_RWops *ops)
{
assert(SDL_RWOPS_STDFILE == ops->type);
return Wops(ops)->hidden.stdio.fp;
}
Sint64 Size(SDL_RWops *ops)
{
SDL::SetError(std::errc::not_supported);
return -1;
}
Sint64 Seek(SDL_RWops *ops, Sint64 off, int whence)
{
SDL::SetError(std::errc::not_supported);
return -1;
}
std::size_t Read(SDL_RWops *ops, void *ptr, std::size_t size, std::size_t maxnum)
{
return SDL_RWread(Rops(ops), ptr, size, maxnum);
}
std::size_t Write(SDL_RWops *ops, const void *ptr, std::size_t size, std::size_t num)
{
return SDL_RWwrite(Wops(ops), ptr, size, num);
}
int Close(SDL_RWops *ops)
{
int error = 0;
if (not Rops(ops) or SDL_RWclose(Rops(ops)))
{
SDL::LogError("SDL_RWclose(R)");
error = -1;
}
if (not Wops(ops) or SDL_RWclose(Wops(ops)))
{
SDL::LogError("SDL_RWclose(W)");
error = -1;
}
return error;
}
SDL_RWops *AllocRW()
{
SDL_RWops *ops = SDL_AllocRW();
if (not ops)
{
SDL::SetError(std::errc::not_enough_memory);
return nullptr;
}
ops->type = SDL_RWOPS_UNKNOWN;
ops->size = Size;
ops->seek = Seek;
ops->read = Read;
ops->write = Write;
ops->close = Close;
return ops;
}
SDL_RWops *FromFP(std::FILE* fp)
{
SDL_RWops *ops = SDL_RWFromFP(fp, SDL_TRUE);
if (not ops)
{
SDL::LogError("SDL_RWFromFP");
if (std::fclose(fp))
{
SDL::perror("fclose");
}
}
return ops;
}
SDL_RWops *FromFD(int fd, bool readMode)
{
auto const mode = readMode ? "r" : "w";
std::FILE *fp;
if constexpr (POSIX)
{
fp = fdopen(fd, mode);
if (not fp)
{
SDL::perror("fdopen");
if (close(fd))
{
SDL::perror("close");
}
return nullptr;
}
}
else
if constexpr (WIN32)
{
fp = _fdopen(fd, mode);
if (not fp)
{
SDL::perror("_fdopen");
if (_close(fd))
{
SDL::perror("_close");
}
return nullptr;
}
}
return FromFP(fp);
}
#ifdef __WIN32__
SDL_RWops *FromHandle(HANDLE h, bool readMode)
{
int fd = _open_osfhandle((intptr_t) h, readMode ? _O_RDONLY : _O_WRONLY);
if (-1 == fd)
{
if (not CloseHandle(h[p]))
{
Win32::LogLastError("CloseHandle");
}
return nullptr
}
return FromFD(fd, readMode);
}
HANDLE ToHandle(SDL_RWops *ops)
{
assert(SDL_RWOPS_STDFILE == ops->type);
int fd = _fileno(ops->hidden.stdio.fp);
if (-1 == fd)
{
SDL::perror("_fileno");
return nullptr;
}
HANDLE h = (HANDLE) _get_osfhandle(fd);
if (INVALID_HANDLE_VALUE == h)
{
SDL::perror("_gets_osfhandle");
return nullptr;
}
return h;
}
#endif // __WIN32__
}
namespace SDL
{
RWops::RWops(SDL_RWops *ops) : ops(std::make_shared(ops, SDL_FreeRW))
{}
SDL_RWops *Pipe()
{
RWops ops = AllocRW();
if (not ops)
{
return nullptr;
}
RWops rw[2];
if constexpr (POSIX)
{
int fd[2];
if (pipe(fd))
{
SDL::perror("pipe");
return nullptr;
}
bool ok = true;
for (int p : {R, W})
{
rw[p] = FromFD(fd[p], R == p);
if (not rw[p])
{
ok = false;
continue;
}
}
if (not ok)
return nullptr;
}
else
if constexpr (WIN32)
{
SECURITY_ATTRIBUTES attr;
attr.nLength = sizeof(attr);
attr.bInheritHandle = TRUE;
attr.lpSecurityDescriptor = NULL;
HANDLE h[2];
if (not CreatePipe(h + R, h + W, &attr, 0))
{
Win32::LogLastError("CreatePipe");
return nullptr;
}
bool ok = true;
for (int p : {R, W})
{
if (not SetHandleInformation(h[p], HANDLE_FLAG_INHERIT, 0))
{
ok = false;
}
rw[p] = FromHandle(h[p], R == p);
if (not rw[p])
{
ok = false;
continue;
}
}
if (not ok)
return nullptr;
}
// Release to caller
dataR(ops) = rw[R].Release();
dataW(ops) = rw[W].Release();
return ops.Release();
}
SDL_RWops *Process(std::vector<std::string> const &args)
{
RWops ops = AllocRW();
if (not ops)
{
return nullptr;
}
RWops rw[2];
bool ok = true;
for (int p : {R, W})
{
rw[p] = Pipe();
if (not rw[p])
{
ok = false;
continue;
}
}
if (not ok)
return nullptr;
if constexpr (POSIX)
{
pid_t pid = fork();
if (-1 == pid)
{
SDL::perror("fork");
return nullptr;
}
else
if (0 == pid) // child
{
if (-1 == dup2(fileno(fileR(rw[R])), STDIN_FILENO))
{
SDL::perror("dup2(R)");
std::exit(std::errno):
}
if (-1 == dup2(fileno(fileW(rw[W])), STDOUT_FILENO))
{
SDL::perror("dup2(W)");
std::exit(std::errno);
}
for (int p : {R, W}) rw[p].Reset();
if (execl(command, command))
{
SDL::perror("execv");
std::exit(std::errno);
}
}
}
else
if constexpr (WIN32)
{
STARTUPINFO init;
ZeroMemory(&init, sizeof(init));
init.cb = sizeof(init);
init.hStdInput = ToHandle(Rops(rw[R]));
init.hStdOutput = ToHandle(Wops(rw[W]));
init.hStdError = GetStdHandle(STD_ERROR_HANDLE);
PROCESS_INFORMATION info;
BOOL const ok = CreateProcess
(
NULL, // no application name
command, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
FALSE, // handles are not inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&init, // startup information (in)
&info // process information (out)
);
if (not ok)
{
Win32::LogLastError("CreateProcess");
return nullptr;
}
if (not CloseHandle(info.hProcess))
{
Win32::LogLastError("CloseHandle(hProcess)");
}
if (not CloseHandle(info.hThread))
{
Win32::LogLastError("CloseHandle(hThread)");
}
}
SDL_RWops *raw[2];
for (int p : {R, W}) raw[p] = rw[p].Release();
// Delete with RAII
rw[R] = Rops(raw[R]);
rw[W] = Wops(raw[W]);
// Release to caller
dataR(ops) = dataR(raw[W]);
dataW(ops) = dataW(raw[R]);
return ops.Release();
}
}
| 17.658537
| 86
| 0.581185
|
JesseMaurais
|
b002b1e42cf40a9c28a3ed67dd7c308d6a190e04
| 12,087
|
cpp
|
C++
|
utl/tests/testinc_opts.cpp
|
mathiasrw/ptarmigan
|
69b26470310daa24f95cb83eefde8e539eff6d96
|
[
"Apache-2.0"
] | 143
|
2017-07-22T12:12:00.000Z
|
2022-02-09T09:46:26.000Z
|
utl/tests/testinc_opts.cpp
|
mathiasrw/ptarmigan
|
69b26470310daa24f95cb83eefde8e539eff6d96
|
[
"Apache-2.0"
] | 534
|
2017-09-02T13:45:32.000Z
|
2020-06-15T09:26:33.000Z
|
utl/tests/testinc_opts.cpp
|
mathiasrw/ptarmigan
|
69b26470310daa24f95cb83eefde8e539eff6d96
|
[
"Apache-2.0"
] | 31
|
2017-09-29T00:11:33.000Z
|
2021-06-17T08:24:37.000Z
|
////////////////////////////////////////////////////////////////////////
//FAKE関数
//FAKE_VALUE_FUNC(int, external_function, int);
////////////////////////////////////////////////////////////////////////
class opts: public testing::Test {
protected:
virtual void SetUp() {
//RESET_FAKE(external_function)
utl_dbg_malloc_cnt_reset();
}
virtual void TearDown() {
ASSERT_EQ(0, utl_dbg_malloc_cnt());
}
public:
static void DumpBin(const uint8_t *pData, uint16_t Len)
{
for (uint16_t lp = 0; lp < Len; lp++) {
printf("%02x", pData[lp]);
}
printf("\n");
}
};
////////////////////////////////////////////////////////////////////////
/*typedef struct {
const char *name; ///< name(required, but set NULL in the watchdog entry)
const char *arg; ///< arg(optional, if set, display name=<arg>)
const char *param_default; ///< param_default(optional)
const char *help; ///< help(optional)
char *param; ///< param
bool is_set; ///< is_set
} utl_opt_t;*/
TEST_F(opts, parse0)
{
// argv[0]: program -- skip
// argv[1]: -option0
// argv[2]: -option1
utl_opt_t opts[] = {
{"-name0", "arg0", "param_default0", "help0", NULL, false},
{"-name1", "arg1", "param_default1", "help1", NULL, false},
{"-name2", "arg2", "param_default2", "help2", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
const char *argv[] = {
"program",
"-name0=arg0",
"-name1=arg1",
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
utl_opts_free(opts);
}
TEST_F(opts, parse1)
{
// argv[0]: program -- skip
// argv[1]: command
// argv[2]: -option0
// argv[3]: -option1
utl_opt_t opts[] = {
{"-name0", "arg0", "param_default0", "help0", NULL, false},
{"-name1", "arg1", "param_default1", "help1", NULL, false},
{"-name2", "arg2", "param_default2", "help2", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
const char *argv[] = {
"program",
"command",
"-name0=arg0",
"-name1=arg1",
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
utl_opts_free(opts);
}
TEST_F(opts, parse2)
{
// argv[0]: program -- skip
// argv[1]: command
// argv[2]: -option0
// argv[3]: -option1
// argv[4]: command_param0 -- skip
// argv[5]: command_param1 -- skip
utl_opt_t opts[] = {
{"-name0", "arg0", "param_default0", "help0", NULL, false},
{"-name1", "arg1", "param_default1", "help1", NULL, false},
{"-name2", "arg2", "param_default2", "help2", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
const char *argv[] = {
"program",
"command",
"-name0=arg0",
"-name1=arg1",
"command_param0",
"command_param1",
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
utl_opts_free(opts);
}
TEST_F(opts, parse_invalid0)
{
utl_opt_t opts[] = {
//arg == NULL && param_default == "param_default0" -> invalid
{"-name0", NULL, "param_default0", "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
const char *argv[] = {
"program",
"-name0=arg0",
"-name1=arg1",
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
TEST_F(opts, parse_invalid1)
{
utl_opt_t opts[] = {
//is_set == true -> invalid
{"-name0", "arg0", "param_default0", "help0", NULL, true},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
const char *argv[] = {
"program",
"-name0=arg0",
"-name1=arg1",
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
TEST_F(opts, parse_invalid2)
{
char param0[] = {'p', 'a', 'r', 'a', 'm', '0', '\0'};
utl_opt_t opts[] = {
//param == "param0" -> invalid
{"-name0", "arg0", "param_default0", "help0", param0, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
const char *argv[] = {
"program",
"-name0=arg0",
"-name1=arg1",
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
TEST_F(opts, option_with_no_arg)
{
utl_opt_t opts[] = {
{"-name0", NULL, NULL, "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
{
const char *argv[] = {
"program",
//empty
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_FALSE(utl_opts_is_set(opts, "-name0"));
ASSERT_EQ(utl_opts_get_string(opts, "-name0"), NULL);
utl_opts_free(opts);
}
{
const char *argv[] = {
"program",
"-name0",
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_EQ(utl_opts_get_string(opts, "-name0"), NULL);
utl_opts_free(opts);
}
}
TEST_F(opts, option_with_no_arg_invalid)
{
utl_opt_t opts[] = {
{"-name0", NULL, NULL, "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
{
const char *argv[] = {
"program",
"-name0=param0", //invalid
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
{
const char *argv[] = {
"program",
"-name1", //invalid
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
}
TEST_F(opts, option_with_arg)
{
utl_opt_t opts[] = {
{"-name0", "arg0", NULL, "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
{
const char *argv[] = {
"program",
//empty
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_FALSE(utl_opts_is_set(opts, "-name0"));
ASSERT_EQ(utl_opts_get_string(opts, "-name0"), NULL);
utl_opts_free(opts);
}
{
const char *argv[] = {
"program",
"-name0=param0",
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_STREQ(utl_opts_get_string(opts, "-name0"), "param0");
utl_opts_free(opts);
}
}
TEST_F(opts, option_with_arg_invalid)
{
utl_opt_t opts[] = {
{"-name0", "arg0", NULL, "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
{
const char *argv[] = {
"program",
"-name0", //invalid
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
{
const char *argv[] = {
"program",
"-name1=param1", //invalid
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
}
TEST_F(opts, option_with_arg_and_param_default) {
utl_opt_t opts[] = {
{"-name0", "arg0", "param_default0", "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
{
const char *argv[] = {
"program",
//empty
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_STREQ(utl_opts_get_string(opts, "-name0"), "param_default0");
utl_opts_free(opts);
}
{
const char *argv[] = {
"program",
"-name0=param0",
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_STREQ(utl_opts_get_string(opts, "-name0"), "param0");
utl_opts_free(opts);
}
}
TEST_F(opts, option_with_arg_and_param_default_invalid)
{
utl_opt_t opts[] = {
{"-name0", "arg0", "param_default0", "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
{
const char *argv[] = {
"program",
"-name0", //invalid
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
{
const char *argv[] = {
"program",
"-name1=param1", //invalid
};
ASSERT_FALSE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
}
}
TEST_F(opts, arg_type)
{
utl_opt_t opts[] = {
{"-name0", "arg0", NULL, "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
{
const char *argv[] = {
"program",
"-name0=1234567890"
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_STREQ(utl_opts_get_string(opts, "-name0"), "1234567890");
uint32_t n;
ASSERT_TRUE(utl_opts_get_u32(opts, &n, "-name0"));
ASSERT_EQ(n, 1234567890);
utl_opts_free(opts);
}
{
const char *argv[] = {
"program",
"-name0=12345"
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_STREQ(utl_opts_get_string(opts, "-name0"), "12345");
uint16_t n;
ASSERT_TRUE(utl_opts_get_u16(opts, &n, "-name0"));
ASSERT_EQ(n, 12345);
utl_opts_free(opts);
}
}
TEST_F(opts, arg_type_u32)
{
utl_opt_t opts[] = {
{"-name0", "arg0", NULL, "help0", NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
{
const char *argv[] = {
"program",
"-name0=param0"
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_STREQ(utl_opts_get_string(opts, "-name0"), "param0");
uint32_t n;
ASSERT_FALSE(utl_opts_get_u32(opts, &n, "-name0"));
utl_opts_free(opts);
}
{
const char *argv[] = {
"program",
"-name0=param0"
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_STREQ(utl_opts_get_string(opts, "-name0"), "param0");
uint16_t n;
ASSERT_FALSE(utl_opts_get_u16(opts, &n, "-name0"));
utl_opts_free(opts);
}
{
const char *argv[] = {
"program",
"-name0=123456"
};
ASSERT_TRUE(utl_opts_parse(opts, ARRAY_SIZE(argv), argv));
ASSERT_TRUE(utl_opts_is_set(opts, "-name0"));
ASSERT_STREQ(utl_opts_get_string(opts, "-name0"), "123456");
uint16_t n;
ASSERT_FALSE(utl_opts_get_u16(opts, &n, "-name0"));
utl_opts_free(opts);
}
}
TEST_F(opts, help_messages)
{
utl_opt_t opts[] = {
{"-name0", NULL, NULL, "help0", NULL, false},
{"-name1", "arg1", NULL, "help1", NULL, false},
{"-name2", "arg2", "param_default2", "help2", NULL, false},
{"-name3", NULL, NULL, NULL, NULL, false},
{"-name4", "arg4", NULL, NULL, NULL, false},
{"-name5", "arg5", "param_default5", NULL, NULL, false},
{NULL, NULL, NULL, NULL, NULL, false}, //watchdog
};
utl_str_t x;
utl_str_init(&x);
ASSERT_TRUE(utl_opts_get_help_messages(opts, &x));
const char *p = utl_str_get(&x);
ASSERT_NE(p, NULL);
ASSERT_STREQ(p,
" -name0\n"
" help0\n"
"\n"
" -name1=<arg1>\n"
" help1\n"
"\n"
" -name2=<arg2>\n"
" help2 (default: param_default2)\n"
"\n"
" -name3\n"
"\n"
" -name4=<arg4>\n"
"\n"
" -name5=<arg5>\n"
" (default: param_default5)\n"
"\n"
);
utl_str_free(&x);
utl_opts_free(opts);
}
| 27.85023
| 91
| 0.519815
|
mathiasrw
|
b0066e9e5b7323234ae0883608eea07b4a4a4a19
| 3,911
|
cpp
|
C++
|
Framework/Source/Raytracing/RtRenderContext.cpp
|
zhaijialong/Falcor
|
afdd9125283c90374694ed35875144fde81e9312
|
[
"BSD-3-Clause"
] | null | null | null |
Framework/Source/Raytracing/RtRenderContext.cpp
|
zhaijialong/Falcor
|
afdd9125283c90374694ed35875144fde81e9312
|
[
"BSD-3-Clause"
] | null | null | null |
Framework/Source/Raytracing/RtRenderContext.cpp
|
zhaijialong/Falcor
|
afdd9125283c90374694ed35875144fde81e9312
|
[
"BSD-3-Clause"
] | null | null | null |
/***************************************************************************
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
#pragma once
#include "Framework.h"
#include "RtProgramVars.h"
#include "RtState.h"
namespace Falcor
{
void RenderContext::raytrace(RtProgramVars::SharedPtr pVars, RtState::SharedPtr pState, uint32_t width, uint32_t height)
{
resourceBarrier(pVars->getShaderTable().get(), Resource::State::NonPixelShader);
Buffer* pShaderTable = pVars->getShaderTable().get();
uint32_t recordSize = pVars->getRecordSize();
D3D12_GPU_VIRTUAL_ADDRESS startAddress = pShaderTable->getGpuAddress();
D3D12_DISPATCH_RAYS_DESC raytraceDesc = {};
raytraceDesc.Width = width;
raytraceDesc.Height = height;
// RayGen is the first entry in the shader-table
raytraceDesc.RayGenerationShaderRecord.StartAddress = startAddress + pVars->getRayGenRecordIndex() * recordSize;
raytraceDesc.RayGenerationShaderRecord.SizeInBytes = recordSize;
// Miss is the second entry in the shader-table
raytraceDesc.MissShaderTable.StartAddress = startAddress + pVars->getFirstMissRecordIndex() * recordSize;
raytraceDesc.MissShaderTable.StrideInBytes = recordSize;
raytraceDesc.MissShaderTable.SizeInBytes = recordSize * pVars->getMissProgramsCount();
raytraceDesc.HitGroupTable.StartAddress = startAddress + pVars->getFirstHitRecordIndex() * recordSize;
raytraceDesc.HitGroupTable.StrideInBytes = recordSize;
raytraceDesc.HitGroupTable.SizeInBytes = pVars->getShaderTable()->getSize() - (pVars->getFirstHitRecordIndex() * recordSize);
// Currently, we need to set an empty root-signature. Some wizardry is required to make sure we restore the state
const auto& pComputeVars = getComputeVars();
setComputeVars(nullptr);
ID3D12GraphicsCommandListPtr pCmdList = getLowLevelData()->getCommandList();
pCmdList->SetComputeRootSignature(pVars->getGlobalVars()->getRootSignature()->getApiHandle().GetInterfacePtr());
// Dispatch
ID3D12CommandListRaytracingPrototypePtr pRtCmdList = pCmdList;
pRtCmdList->DispatchRays(pState->getRtso()->getApiHandle().GetInterfacePtr(), &raytraceDesc);
// Restore the vars
setComputeVars(pComputeVars);
}
}
| 52.851351
| 133
| 0.719509
|
zhaijialong
|
b009757e8a15058298b9b5577687040de0f2071e
| 652
|
hpp
|
C++
|
source/ui/scene/gameScene.hpp
|
Stephouuu/Epitech-Bomberman
|
8650071a6a21ba2e0606e4d8e38794de37bdf39f
|
[
"Unlicense"
] | null | null | null |
source/ui/scene/gameScene.hpp
|
Stephouuu/Epitech-Bomberman
|
8650071a6a21ba2e0606e4d8e38794de37bdf39f
|
[
"Unlicense"
] | null | null | null |
source/ui/scene/gameScene.hpp
|
Stephouuu/Epitech-Bomberman
|
8650071a6a21ba2e0606e4d8e38794de37bdf39f
|
[
"Unlicense"
] | null | null | null |
/*
** gameScene.hpp for ui in /home/escoba_j/Downloads/irrlicht-1.8.3/ui/scene
**
** Made by Joffrey Escobar
** Login <escoba_j@epitech.net>
**
** Started on Mon May 30 17:40:41 2016 Joffrey Escobar
*/
#ifndef GAMESCENE_HPP
#define GAMESCENE_HPP
#include "ASubLayout.hpp"
class gameScene : public ASubLayout
{
public:
gameScene(ui& ui);
~gameScene(void);
void loadScene(void);
void updateRuntime(void);
void manageEvent(bbman::InputListener &listener);
void loadRessources(void);
void displayScore(int id, int value);
void displayTimerGlobal(int value);
void displayTimerTimeout(int value);
};
#endif // ifndef GAMESCENE_HPP
| 20.375
| 75
| 0.731595
|
Stephouuu
|
b00ac45f3e1226074714987a920916ae6433e5a1
| 15,615
|
cpp
|
C++
|
FlyEngine/Source/ResourceManager.cpp
|
rogerta97/FlyEngine
|
33abd70c5b4307cd552e2b6269b401772b4327ba
|
[
"MIT"
] | null | null | null |
FlyEngine/Source/ResourceManager.cpp
|
rogerta97/FlyEngine
|
33abd70c5b4307cd552e2b6269b401772b4327ba
|
[
"MIT"
] | null | null | null |
FlyEngine/Source/ResourceManager.cpp
|
rogerta97/FlyEngine
|
33abd70c5b4307cd552e2b6269b401772b4327ba
|
[
"MIT"
] | null | null | null |
#include "ResourceManager.h"
#include "Texture.h"
#include "ImageImporter.h"
#include "MyFileSystem.h"
#include "AudioClip.h"
#include "MusicTrack.h"
#include "AudioImporter.h"
#include "FontImporter.h"
#include "imgui.h"
#include "Font.h"
#include <string>
#include "mmgr.h"
#include <assert.h>
ResourceManager* ResourceManager::instance = 0;
ResourceManager::ResourceManager()
{
}
ResourceManager* ResourceManager::getInstance()
{
if (instance == nullptr)
instance = new ResourceManager();
return instance;
}
ResourceManager::~ResourceManager()
{
}
bool ResourceManager::AddResource(Resource* newResource, std::string name)
{
if(newResource != nullptr)
{
newResource->SetName(name);
instance->resourceList.push_back(newResource);
return true;
}
return false;
}
ResourceType ResourceManager::GetResourceTypeFromExtension(FileExtension ext)
{
switch (ext)
{
case FILE_WAV:
return ResourceType::RESOURCE_SFX;
case FILE_OTF:
return ResourceType::RESOURCE_FONT;
case FILE_TTF:
return ResourceType::RESOURCE_FONT;
case FILE_MP3:
return ResourceType::RESOURCE_MUSIC;
case FILE_PNG:
return ResourceType::RESOURCE_TEXTURE;
case FILE_JPG:
return ResourceType::RESOURCE_TEXTURE;
}
return ResourceType::RESOURCE_null;
}
Resource* ResourceManager::GetResource(std::string _resourceName, ResourceType type)
{
for (auto& it : instance->resourceList)
{
string resourceName = MyFileSystem::getInstance()->DeleteFileExtension((it)->GetName());
if (resourceName == _resourceName)
{
if (type != RESOURCE_null)
{
if ((it)->GetType() == type)
return (it);
else
continue;
}
return (it);
}
}
return nullptr;
}
Resource* ResourceManager::GetResource(UID resourceUID, ResourceType type)
{
for (auto& it : instance->resourceList)
{
if ((it)->GetUID() == resourceUID)
{
if (type == RESOURCE_null)
return (it);
else
{
if ((it)->GetType() == type)
return (it);
else
continue;
}
}
}
FLY_ERROR("No resource with UID %d found", resourceUID);
return nullptr;
}
vector<Resource*> ResourceManager::GetResources(ResourceType type)
{
vector<Resource*> retList = vector<Resource*>();
for (auto& currentResource : instance->resourceList)
{
if (currentResource->GetType() == type)
retList.push_back(currentResource);
}
return retList;
}
list<Resource*>& ResourceManager::GetResourceList()
{
return instance->resourceList;
}
Resource* ResourceManager::GetResourceByPath(std::string resourcePath)
{
for (auto& it : instance->resourceList)
if ((it)->GetPath() == resourcePath)
return (it);
FLY_ERROR("No resource with path '%s' found", resourcePath.c_str());
return nullptr;
}
Texture* ResourceManager::GetTexture(string resourceName)
{
return (Texture*)GetResource(resourceName, RESOURCE_TEXTURE);
}
Font* ResourceManager::GetFont(string resourceName)
{
return (Font*)GetResource(resourceName, RESOURCE_FONT);
}
AudioClip* ResourceManager::GetAudioClip(string resourceName)
{
return (AudioClip*)GetResource(resourceName, RESOURCE_SFX);
}
MusicTrack* ResourceManager::GetMusicTrack(string resourceName)
{
return (MusicTrack*)GetResource(resourceName, RESOURCE_MUSIC);
}
bool ResourceManager::ExistResource(Resource* checkResource)
{
return ExistResourceUID(checkResource->GetUID());
}
bool ResourceManager::ExistResourceUID(UID resourceUID)
{
for (auto& it: instance->resourceList)
{
if (it->GetUID() == resourceUID)
return true;
}
return false;
}
bool ResourceManager::ExistResourcePath(std::string resourcePath)
{
for (auto& it : instance->resourceList)
{
if (it->GetPath() == resourcePath)
return true;
}
return false;
}
Resource* ResourceManager::PrintImagesSelectionPopup()
{
if (ImGui::BeginPopup("print_image_selection_popup"))
{
ImGui::Spacing();
// Search Bar ---------------
static char searchImageBuffer[256];
ImGui::InputTextWithHint("##SearchTool", "Search...", searchImageBuffer, IM_ARRAYSIZE(searchImageBuffer));
ImGui::SameLine();
Texture* filterIcon = (Texture*)ResourceManager::getInstance()->GetResource("FilterIcon");
ImGui::Image((ImTextureID)filterIcon->GetTextureID(), ImVec2(22, 22));
ImGui::Spacing();
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.12f, 0.14f, 0.17f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(2.0f, 2.0f));
ImGui::BeginChild("##4ShowImage", ImVec2(ImGui::GetContentRegionAvailWidth(), 150));
for (auto& currentResource : instance->resourceList)
{
if (currentResource->GetType() != ResourceType::RESOURCE_TEXTURE)
continue;
Texture* imageIcon = (Texture*)currentResource;
ImGui::Image((ImTextureID)imageIcon->GetTextureID(), ImVec2(30, 30));
ImGui::SameLine();
if (ImGui::Selectable(currentResource->GetName().c_str(), false, 0, ImVec2(ImGui::GetContentRegionAvail().x, 25)))
{
ImGui::EndChild();
ImGui::PopStyleColor();
ImGui::PopStyleVar();
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
return currentResource;
}
}
ImGui::EndChild();
ImGui::PopStyleColor();
ImGui::PopStyleVar();
ImGui::EndPopup();
}
return nullptr;
}
Resource* ResourceManager::PrintSoundsSelectionPopup()
{
if (ImGui::BeginPopup("print_sound_selection_popup"))
{
static char searchSoundBuffer[256];
ImGui::InputTextWithHint("##SearchSound", "Search...", searchSoundBuffer, IM_ARRAYSIZE(searchSoundBuffer));
ImGui::Separator();
for (auto& currentResource : instance->resourceList)
{
if (currentResource->GetType() != ResourceType::RESOURCE_SFX)
continue;
Texture* speakerIcon = (Texture*)ResourceManager::getInstance()->GetResource("SpeakerIcon");
ImGui::Image((ImTextureID)speakerIcon->GetTextureID(), ImVec2(20, 20));
ImGui::SameLine();
if (ImGui::Selectable(currentResource->GetName().c_str()))
{
ImGui::EndPopup();
return currentResource;
}
}
ImGui::EndPopup();
}
return nullptr;
}
Resource* ResourceManager::PrintSoundsSelectionPopup2()
{
if (ImGui::BeginPopup("print_sound_selection_popup2"))
{
static char searchSoundBuffer[256];
ImGui::InputTextWithHint("##SearchSound", "Search...", searchSoundBuffer, IM_ARRAYSIZE(searchSoundBuffer));
ImGui::Separator();
for (auto& currentResource : instance->resourceList)
{
if (currentResource->GetType() != ResourceType::RESOURCE_SFX)
continue;
Texture* speakerIcon = (Texture*)ResourceManager::getInstance()->GetResource("SpeakerIcon");
ImGui::Image((ImTextureID)speakerIcon->GetTextureID(), ImVec2(20, 20));
ImGui::SameLine();
if (ImGui::Selectable(currentResource->GetName().c_str()))
{
ImGui::EndPopup();
return currentResource;
}
}
ImGui::EndPopup();
}
return nullptr;
}
Resource* ResourceManager::PrintSoundsSelectionPopup3()
{
if (ImGui::BeginPopup("print_sound_selection_popup3"))
{
static char searchSoundBuffer[256];
ImGui::InputTextWithHint("##SearchSound", "Search...", searchSoundBuffer, IM_ARRAYSIZE(searchSoundBuffer));
ImGui::Separator();
for (auto& currentResource : instance->resourceList)
{
if (currentResource->GetType() != ResourceType::RESOURCE_SFX)
continue;
Texture* speakerIcon = (Texture*)ResourceManager::getInstance()->GetResource("SpeakerIcon");
ImGui::Image((ImTextureID)speakerIcon->GetTextureID(), ImVec2(20, 20));
ImGui::SameLine();
if (ImGui::Selectable(currentResource->GetName().c_str()))
{
ImGui::EndPopup();
return currentResource;
}
}
ImGui::EndPopup();
}
return nullptr;
}
Resource* ResourceManager::PrintMusicSelectionPopup()
{
if (ImGui::BeginPopup("print_music_selection_popup"))
{
static char searchSoundBuffer[256];
ImGui::InputTextWithHint("##SearchMusic", "Search...", searchSoundBuffer, IM_ARRAYSIZE(searchSoundBuffer));
ImGui::Separator();
for (auto& currentResource : instance->resourceList)
{
if (currentResource->GetType() != ResourceType::RESOURCE_MUSIC)
continue;
Texture* speakerIcon = (Texture*)ResourceManager::getInstance()->GetResource("SpeakerIcon");
ImGui::Image((ImTextureID)speakerIcon->GetTextureID(), ImVec2(20, 20));
ImGui::SameLine();
if (ImGui::Selectable(currentResource->GetName().c_str()))
{
ImGui::EndPopup();
return currentResource;
}
}
ImGui::EndPopup();
}
return nullptr;
}
Resource* ResourceManager::PrintFontSelectionPopup()
{
if (ImGui::BeginPopup("print_font_selection_popup"))
{
static char searchFontBuffer[256];
ImGui::InputTextWithHint("##SearchFont", "Search...", searchFontBuffer, IM_ARRAYSIZE(searchFontBuffer));
ImGui::Separator();
for (auto& currentResource : instance->resourceList)
{
if (currentResource->GetType() != ResourceType::RESOURCE_FONT)
continue;
Texture* speakerIcon = (Texture*)ResourceManager::getInstance()->GetResource("DisplayTextIcon");
ImGui::Image((ImTextureID)speakerIcon->GetTextureID(), ImVec2(20, 20));
ImGui::SameLine();
if (ImGui::Selectable(currentResource->GetName().c_str()))
{
ImGui::EndPopup();
return currentResource;
}
}
ImGui::EndPopup();
}
return nullptr;
}
string ResourceManager::PrintFolderSelectionPopup(string parentFolder)
{
if (ImGui::BeginPopup("print_folder_selection_popup"))
{
ImGui::Spacing();
// Search Bar ---------------
static char searchImageBuffer[256];
ImGui::InputTextWithHint("##SearchTool", "Search...", searchImageBuffer, IM_ARRAYSIZE(searchImageBuffer));
ImGui::SameLine();
Texture* filterIcon = (Texture*)ResourceManager::getInstance()->GetResource("FilterIcon");
ImGui::Image((ImTextureID)filterIcon->GetTextureID(), ImVec2(22, 22), ImVec2(1,1), ImVec2(0, 0));
ImGui::Spacing();
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.12f, 0.14f, 0.17f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(2.0f, 2.0f));
ImGui::BeginChild("##4ShowImage", ImVec2(ImGui::GetContentRegionAvailWidth(), 150));
vector<string> foldersInDirectory = MyFileSystem::getInstance()->GetFoldersInDirectory(parentFolder.c_str());
for (auto& currentFolder : foldersInDirectory)
{
Texture* imageIcon = (Texture*)ResourceManager::getInstance()->GetResource("FolderIcon");
ImGui::Image((ImTextureID)imageIcon->GetTextureID(), ImVec2(30, 30), ImVec2(0, 1), ImVec2(1, 0));
ImGui::SameLine();
string folderName = MyFileSystem::getInstance()->GetLastPathItem(currentFolder, false).c_str();
if (ImGui::Selectable(folderName.c_str(), false, 0, ImVec2(ImGui::GetContentRegionAvail().x, 25)))
{
ImGui::EndChild();
ImGui::PopStyleColor();
ImGui::PopStyleVar();
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
return currentFolder;
}
}
ImGui::EndChild();
ImGui::PopStyleColor();
ImGui::PopStyleVar();
ImGui::EndPopup();
}
return "";
}
void ResourceManager::LoadResource(string newResourcePath, ResourceType forceType)
{
FileExtension fileExtension = MyFileSystem::getInstance()->GetFileExtension(newResourcePath);
ResourceType loadingResourceType = ResourceType::RESOURCE_null;
if (fileExtension == FILE_null)
{
FLY_ERROR("Loading unrecognized file %d", newResourcePath.c_str());
return;
}
bool forced = false;
if (forceType != RESOURCE_null)
{
loadingResourceType = forceType;
forced = true;
}
if (!forced)
loadingResourceType = GetResourceTypeFromExtension(fileExtension);
switch (loadingResourceType)
{
case RESOURCE_TEXTURE:
{
Texture* newResource = ImageImporter::getInstance()->LoadTexture(newResourcePath, false);
string resourceName = MyFileSystem::getInstance()->GetLastPathItem(newResourcePath, false);
//if (resourceName == "Door")
// flog("hids");
AddResource(newResource, resourceName.c_str());
flog("Added Resource %s", resourceName.c_str());
}
break;
case RESOURCE_SFX:
{
AudioClip* newResource = AudioImporter::getInstance()->LoadAudioClip(newResourcePath);
string resourceName = MyFileSystem::getInstance()->GetLastPathItem(newResourcePath, false);
AddResource(newResource, resourceName.c_str());
flog("Added Resource %s", resourceName.c_str());
}
break;
case RESOURCE_MUSIC:
{
MusicTrack *newResource = AudioImporter::getInstance()->LoadMusicTrack(newResourcePath);
string resourceName = MyFileSystem::getInstance()->GetLastPathItem(newResourcePath, false);
AddResource(newResource, resourceName.c_str());
flog("Added Resource %s", resourceName.c_str());
}
break;
case RESOURCE_FONT:
{
Font* newResource = FontImporter::getInstance()->LoadFont(newResourcePath);
string resourceName = MyFileSystem::getInstance()->GetLastPathItem(newResourcePath, false);
AddResource(newResource, resourceName.c_str());
flog("Added Resource %s", resourceName.c_str());
}
break;
}
}
void ResourceManager::LoadAllGameResources()
{
std::string resourcesImagePath = MyFileSystem::getInstance()->GetResourcesDirectory() + "\\Images";
LoadAllFilesFromFolder(resourcesImagePath);
std::string resourcesAudioPath = MyFileSystem::getInstance()->GetResourcesDirectory() + "\\Audio\\Effects";
LoadAllFilesFromFolder(resourcesAudioPath, RESOURCE_SFX);
std::string resourcesMusicPath = MyFileSystem::getInstance()->GetResourcesDirectory() + "\\Audio\\Music";
LoadAllFilesFromFolder(resourcesMusicPath, RESOURCE_MUSIC);
std::string resourcesFontsPath = MyFileSystem::getInstance()->GetResourcesDirectory() + "\\Fonts";
LoadAllFilesFromFolder(resourcesFontsPath, RESOURCE_FONT);
std::string tumbnailsPath = MyFileSystem::getInstance()->GetThumbnilesDirectory();
LoadAllFilesFromFolder(tumbnailsPath, RESOURCE_TEXTURE);
string animationsPath = MyFileSystem::getInstance()->GetResourcesDirectory() + "\\Animations";
std::vector<string> folders = MyFileSystem::getInstance()->GetFoldersInDirectory(animationsPath.c_str());
for (auto& currentFolder : folders)
{
LoadAllFilesFromFolder(currentFolder);
}
}
void ResourceManager::LoadAllFilesFromFolder(string path, ResourceType forceType)
{
if (MyFileSystem::getInstance()->IsFolder(path))
{
vector<string> filesInPath;
MyFileSystem::getInstance()->GetFilesInDirectory(path.c_str(), filesInPath, true);
for (auto& currentFile : filesInPath)
{
std::string fileName = MyFileSystem::getInstance()->GetLastPathItem(currentFile, true);
std::string currentPath = path + "\\" + fileName.c_str();
if (MyFileSystem::getInstance()->IsFolder(currentPath))
{
LoadAllFilesFromFolder(currentPath);
}
else
{
LoadResource(currentPath, forceType);
}
}
}
else
{
LoadResource(path, forceType);
}
}
void ResourceManager::LoadEngineIconsResources()
{
std::vector<std::string> iconsFileName;
MyFileSystem::getInstance()->GetFilesInDirectory(MyFileSystem::getInstance()->GetIconsDirectory().c_str(), iconsFileName);
for (auto& currentFileName : iconsFileName)
{
string texturePath = string(MyFileSystem::getInstance()->GetIconsDirectory() + currentFileName);
string resourceName = MyFileSystem::getInstance()->GetLastPathItem(texturePath, false);
Texture* currentTexture = ImageImporter::getInstance()->LoadTexture(texturePath.c_str(), false);
ResourceManager::getInstance()->AddResource((Resource*)currentTexture, resourceName.c_str());
}
}
void ResourceManager::CleanUp()
{
for (auto& currentResource : instance->resourceList)
{
if (currentResource != nullptr && currentResource->GetType() != RESOURCE_null)
{
if (currentResource->GetType() == RESOURCE_FONT)
int a = 0;
currentResource->CleanUp();
delete currentResource;
currentResource = nullptr;
}
}
instance->resourceList.clear();
delete instance;
}
| 25.938538
| 123
| 0.724111
|
rogerta97
|
b00b91ebfdb2c85c3eb8a32444b5bb9f3507c5ff
| 9,781
|
cpp
|
C++
|
libmultidisplay/ctp_legacy/native/drm_hdcp.cpp
|
zenfone-6/android_device_asus_a600cg
|
1073b3cae60b0e877c47f33048a7979bf3a96428
|
[
"Apache-2.0"
] | 1
|
2021-11-21T21:47:02.000Z
|
2021-11-21T21:47:02.000Z
|
libmultidisplay/ctp_legacy/native/drm_hdcp.cpp
|
zenfone-6/android_device_asus_a600cg
|
1073b3cae60b0e877c47f33048a7979bf3a96428
|
[
"Apache-2.0"
] | null | null | null |
libmultidisplay/ctp_legacy/native/drm_hdcp.cpp
|
zenfone-6/android_device_asus_a600cg
|
1073b3cae60b0e877c47f33048a7979bf3a96428
|
[
"Apache-2.0"
] | 6
|
2016-03-01T16:25:22.000Z
|
2022-03-02T03:54:14.000Z
|
/*
* Copyright (c) 2012-2013, Intel Corporation. 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.
*
*/
//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include <errno.h>
#include <sys/types.h>
#include <stdbool.h>
#include <stdlib.h>
#include <cutils/properties.h>
#include "drm_hdmi.h"
#include "drm_hdcp.h"
#include "linux/psb_drm.h"
#include "xf86drm.h"
#include "xf86drmMode.h"
extern "C" {
#include "libsepdrm/sepdrm.h"
}
static int g_hdcpStatusCheckTimer = 0;
#define HDCP_ENABLE_NUM_OF_TRY 4
#define HDCP_CHECK_NUM_OF_TRY 1
#define HDCP_ENABLE_DELAY_USEC 30000 // 30 ms
#define HDCP_STATUS_CHECK_INTERVAL 2 // 2 seconds
// 120ms delay after disabling IED is required for successful hdcp
// authentication with some AV receivers anything less than 100ms
// resulted in Ri mismatch
#define HDCP_DISABLE_IED_DELAY_USEC 120000 // 120 ms
#define IED_SESSION_ID 0x11
// Forward declaration
static void drm_hdcp_check_link_status();
static bool drm_hdcp_start_link_checking();
static void drm_hdcp_stop_link_checking();
static bool drm_hdcp_enable_and_check();
static bool drm_hdcp_enable_hdcp_work();
static bool drm_hdcp_isSupported()
{
int fd = drm_get_dev_fd();
if (fd <= 0) {
ALOGE("Invalid DRM file descriptor.");
return false;
}
unsigned int caps = 0;
int ret = drmCommandRead(fd, DRM_PSB_QUERY_HDCP, &caps, sizeof(caps));
if (ret != 0) {
ALOGE("Failed to query HDCP capability.");
return false;
}
return caps != 0;
}
static bool drm_hdcp_disable_display_ied()
{
int fd, ret;
fd = drm_get_dev_fd();
if (fd <= 0) {
ALOGE("Invalid DRM file descriptor.");
return false;
}
ret = drmCommandNone(fd, DRM_PSB_HDCP_DISPLAY_IED_OFF);
if (ret != 0) {
ALOGE("Failed to disable HDCP-Display-IED.");
return false;
}
return true;
}
static bool drm_hdcp_enable_display_ied()
{
int fd, ret;
fd = drm_get_dev_fd();
if (fd <= 0) {
ALOGE("Invalid DRM file descriptor.");
return false;
}
ret = drmCommandNone(fd, DRM_PSB_HDCP_DISPLAY_IED_ON);
if (ret != 0) {
ALOGE("Failed to enable HDCP-Display-IED.");
return false;
}
return true;
}
static bool drm_hdcp_enable()
{
int fd = drm_get_dev_fd();
if (fd <= 0) {
ALOGE("Invalid DRM file descriptor.");
return false;
}
int ret = drmCommandNone(fd, DRM_PSB_ENABLE_HDCP);
if (ret != 0) {
ALOGE("Failed to enable HDCP.");
return false;
}
return true;
}
static bool drm_hdcp_disable()
{
int fd = drm_get_dev_fd();
if (fd <= 0) {
ALOGE("Invalid DRM file descriptor.");
return false;
}
int ret = drmCommandNone(fd, DRM_PSB_DISABLE_HDCP);
if (ret != 0) {
ALOGW("Failed to disable HDCP.");
return false;
}
return true;
}
static bool drm_hdcp_isAuthenticated()
{
int fd = drm_get_dev_fd();
if (fd <= 0) {
ALOGE("Invalid DRM file descriptor.");
return false;
}
unsigned int match = 0;
int ret = drmCommandRead(fd, DRM_PSB_GET_HDCP_LINK_STATUS, &match, sizeof(match));
if (ret != 0) {
ALOGE("Failed to check hdcp link status.");
return false;
}
if (match) {
ALOGV("HDCP is authenticated.");
return true;
} else {
ALOGE("HDCP is not authenticated.");
return false;
}
}
// check whether there is an active IED session (Inline Decryption and Encryption)
static bool drm_check_ied_session()
{
struct drm_lnc_video_getparam_arg arg;
unsigned long temp;
int ret = 0;
int fd, offset;
fd = drm_get_dev_fd();
if (fd <= 0) {
ALOGE("Invalid DRM file descriptor.");
return false;
}
offset = drm_get_ioctl_offset();
if (offset <= 0) {
ALOGE("Invalid IOCTL offset.");
return false;
}
arg.key = IMG_VIDEO_IED_STATE;
arg.value = (uint64_t)((unsigned long) & temp);
ret = drmCommandWriteRead(fd, offset, &arg, sizeof(arg));
if (ret != 0) {
ALOGE("Failed to get IED session status.");
return false;
}
if (temp == 1) {
ALOGI("IED session is active.");
return true;
} else {
ALOGI("IED session is inactive.");
return false;
}
}
static void drm_hdcp_check_link_status(union sigval sig)
{
bool b = false;
b = drm_hdcp_isAuthenticated();
if (!b) {
ALOGI("HDCP is not authenticated, restarting authentication process.");
drm_hdcp_enable_hdcp_work();
}
}
static bool drm_hdcp_start_link_checking()
{
int ret;
struct sigevent sev;
struct itimerspec its;
if (g_hdcpStatusCheckTimer) {
ALOGW("HDCP status checking timer has been created.");
return false;
}
memset(&sev, 0, sizeof(sev));
sev.sigev_notify = SIGEV_THREAD;
sev.sigev_value.sival_ptr = NULL;
sev.sigev_notify_function = drm_hdcp_check_link_status;
ret = timer_create(CLOCK_REALTIME, &sev, &g_hdcpStatusCheckTimer);
if (ret != 0) {
ALOGE("Failed to create HDCP status checking timer.");
return false;
}
its.it_value.tv_sec = -1; // never expire
its.it_value.tv_nsec = 0;
its.it_interval.tv_sec = HDCP_STATUS_CHECK_INTERVAL; // 2 seconds
its.it_interval.tv_nsec = 0;
ret = timer_settime(g_hdcpStatusCheckTimer, TIMER_ABSTIME, &its, NULL);
if (ret != 0) {
ALOGE("Failed to set HDCP status checking timer.");
timer_delete(g_hdcpStatusCheckTimer);
g_hdcpStatusCheckTimer = 0;
return false;
}
return true;
}
static void drm_hdcp_stop_link_checking()
{
int ret;
struct itimerspec its;
if (g_hdcpStatusCheckTimer == 0) {
ALOGV("HDCP status checking timer has been deleted.");
return;
}
its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 0;
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
ret = timer_settime(g_hdcpStatusCheckTimer, TIMER_ABSTIME, &its, NULL);
if (ret != 0) {
ALOGE("Failed to reset HDCP status checking timer.");
}
timer_delete(g_hdcpStatusCheckTimer);
g_hdcpStatusCheckTimer = 0;
}
static bool drm_hdcp_enable_and_check()
{
ALOGV("Entering %s", __func__);
bool ret = false;
int i, j;
for (i = 0; i < HDCP_ENABLE_NUM_OF_TRY; i++) {
ALOGV("Try to enable and check HDCP at iteration %d", i);
if (drm_hdcp_enable() == false) {
if (drm_hdmi_getConnectionStatus() == 0) {
ALOGW("HDMI is disconnected, abort HDCP enabling and checking.");
return true;
}
} else {
for (j = 0; j < HDCP_CHECK_NUM_OF_TRY; j++) {
if (drm_hdcp_isAuthenticated() == false) {
break;
}
}
if (j == HDCP_CHECK_NUM_OF_TRY) {
ret = true;
break;
}
}
// Adding delay to make sure panel receives video signal so it can start HDCP authentication.
// (HDCP spec 1.3, section 2.3)
usleep(HDCP_ENABLE_DELAY_USEC);
}
ALOGV("Leaving %s", __func__);
return ret;
}
static bool drm_hdcp_enable_hdcp_work()
{
bool ret = true;
sec_result_t res;
ALOGV("Disabling Display IED ");
if (!drm_hdcp_disable_display_ied()) {
ALOGE("drm_hdcp_disable_display_ied FAILED!!!");
}
ret = drm_hdcp_enable_and_check();
if (!ret) {
// Don't return here as HDCP can be re-authenticated during periodic time check.
ALOGI("HDCP authentication will be restarted in %d seconds.", HDCP_STATUS_CHECK_INTERVAL);
}
ALOGV("Re-enabling Display IED ");
if (!drm_hdcp_enable_display_ied()) {
ALOGE("drm_hdcp_enable_display_ied FAILED!!!");
}
return ret;
}
void drm_hdcp_disable_hdcp(bool connected)
{
ALOGV("Entering %s", __func__);
drm_hdcp_stop_link_checking();
if (connected) {
// disable HDCP if HDMI is connected.
drm_hdcp_disable();
}
ALOGV("Leaving %s", __func__);
}
bool drm_hdcp_enable_hdcp()
{
ALOGV("Entering %s", __func__);
bool ret = true;
char prop[PROPERTY_VALUE_MAX];
if (property_get("debug.mds.hdcp.enable", prop, "1") > 0) {
if (atoi(prop) == 0) {
ALOGV("HDCP is disabled");
return false;
}
}
// We no longer check HDCP capability of the connected device here, the way to determine whether HDCP is supported in kernel is not reliable as it tries to read BKsv from the device,
//which may not return BKsv as it has not received any frame when IED is enabled.
//if (drm_hdcp_isSupported() == false) {
if (false) {
ALOGW("HDCP is not supported, abort HDCP enabling.");
ret = false;
// this may be fake indication during quick plug/unplug cycle, and unplug event may be filtered out, so status timer still needs to be set.
} else {
ret = drm_hdcp_enable_hdcp_work();
}
// Ignore return value
drm_hdcp_start_link_checking();
ALOGV("Leaving %s", __func__);
// Return success as HDCP authentication failure may be recoverable.
return ret;
}
| 26.944904
| 186
| 0.632144
|
zenfone-6
|
b00e0338dafeaab0355cf19a60c34a3373c0e46a
| 10,541
|
cpp
|
C++
|
src/CGNetwork/cgprofile.cpp
|
Tpimp/play-zone
|
a967baf72eb70614bf83198e9b2ea55082f17438
|
[
"BSD-3-Clause"
] | null | null | null |
src/CGNetwork/cgprofile.cpp
|
Tpimp/play-zone
|
a967baf72eb70614bf83198e9b2ea55082f17438
|
[
"BSD-3-Clause"
] | null | null | null |
src/CGNetwork/cgprofile.cpp
|
Tpimp/play-zone
|
a967baf72eb70614bf83198e9b2ea55082f17438
|
[
"BSD-3-Clause"
] | null | null | null |
#include "cgprofile.h"
#include <QCryptographicHash>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include "cgserver.h"
CGProfile::CGProfile(QQuickItem *parent) : QQuickItem(parent)
{
mServer = CGServer::globalServer();
connect(mServer, &CGServer::setProfileData,this,&CGProfile::setUserProfile);
//connect(mServer, &CGServer::failedToSetUserData,this,&CGProfile::failedToSaveChanges);
connect(mServer, &CGServer::refreshUserData , this, &CGProfile::refreshData);
}
bool CGProfile::isValid()
{
return mValid;
}
bool CGProfile::isLoggedIn()
{
return mLoggedIn;
}
bool CGProfile::isBanned()
{
return mBanned;
}
QString CGProfile::name()
{
return mUsername;
}
bool CGProfile::boldLines()
{
return mBoldLines;
}
int CGProfile::elo()
{
return mElo;
}
QString CGProfile::country()
{
return mCountry;
}
void CGProfile::setCountry(QString country)
{
if(country.compare(mCountry) != 0){
mCountry = country;
mServer->updateProfile(serializeProfile());
emit countryChanged(country);
}
}
void CGProfile::setStartSound(bool on)
{
mStartSound = on;
}
int CGProfile::language()
{
return mLanguage;
}
int CGProfile::pieceSet()
{
return mPieceSet;
}
bool CGProfile::playStartSound()
{
return mStartSound;
}
bool CGProfile::useCoordinates()
{
return mCoordinates;
}
bool CGProfile::arrows()
{
return mArrows;
}
QString CGProfile::avatar()
{
return mAvatar;
}
bool CGProfile::autoPromote()
{
return mAutoPromote;
}
QString CGProfile::boardLight()
{
return mBoardLight;
}
QString CGProfile::boardDark()
{
return mBoardDark;
}
QString CGProfile::boardTexture()
{
return mBoardTexture;
}
QString CGProfile::boardBackground()
{
return mBoardBackground;
}
quint64 CGProfile::cgdata()
{
return mCGBitField;
}
quint64 CGProfile::gamesPlayed()
{
return mGamesPlayed;
}
quint64 CGProfile::id()
{
return mId;
}
quint64 CGProfile::gamesWon()
{
return mGamesWon;
}
void CGProfile::refreshData(QString data){
QJsonDocument doc = QJsonDocument::fromJson(data.toLocal8Bit());
QJsonObject user = doc.object();
if(user.contains(CG_AR)){
bool arrows = user.value(CG_AR).toBool();
if(arrows != mArrows){
mArrows = arrows;
emit arrowsChanged(arrows);
}
}
if(user.contains(CG_AP)){
bool ap = user.value(CG_AP).toBool();
if(ap != mAutoPromote){
mAutoPromote = ap;
emit autoPromoteChanged(ap);
}
}
if(user.contains(CG_BAN)){
bool ban = user.value(CG_BAN).toBool();
if(ban != mBanned){
mBanned = ban;
emit bannedChanged(ban);
}
}
if(user.contains(CG_BT)){
QString bt = user.value(CG_BT).toString();
if(bt.compare(mBoardTexture) != 0){
mBoardTexture = bt;
emit boardTextureChanged(bt);
}
}
if(user.contains(CG_BF)){
quint64 bitfield = quint64(user.value(CG_BF).toDouble());
if(bitfield != mCGBitField){
mCGBitField = bitfield;
emit cgDataChanged(bitfield);
}
}
if(user.contains(CG_CO)){
bool coords = user.value(CG_CO).toBool();
if(coords != mCoordinates){
mCoordinates = coords;
emit coordinatesChanged(coords);
}
}
if(user.contains(CG_CF)){
QString country = user.value(CG_CF).toString();
if(country.compare(mCountry) != 0){
mCountry = country;
emit countryChanged(country);
}
}
if(user.contains(CG_LANG)){
int language = user.value(CG_LANG).toInt();
if(language != mLanguage){
mLanguage = language;
emit languageChanged(language);
}
}
if(user.contains(CG_SND)){
bool sound = user.value(CG_SND).toBool();
if(sound != mStartSound){
mStartSound = sound;
emit startSoundChanged(sound);
}
}
if(user.contains(CG_PS)){
int piece = user.value(CG_PS).toInt();
if(piece != mPieceSet){
mPieceSet = piece;
emit pieceSetChanged(piece);
}
}
if(user.contains(CG_AV)){
QString avatar = user.value(CG_AV).toString();
if(avatar.compare(mAvatar) != 0){
mAvatar = avatar;
emit avatarChanged(avatar);
}
}
if(user.contains(CG_E)){
int elo = user.value(CG_E).toInt();
if(elo != mElo){
mElo = elo;
emit eloChanged(elo);
}
}
if(user.contains(CG_TOTL)){
quint64 total = quint64(user.value(CG_TOTL).toDouble());
if(total != mGamesPlayed){
mGamesPlayed = total;
emit gamesPlayedChanged(mGamesPlayed);
}
}
if(user.contains(CG_WON)){
quint64 won = quint64(user.value(CG_WON).toDouble());
if(won != mGamesWon){
mGamesWon = won;
emit gamesWonChanged(won);
}
}
if(user.contains(CG_AV)){
QString avatar = user.value(CG_AV).toString();
if(avatar.compare(mAvatar) != 0){
mAvatar = avatar;
emit avatarChanged(avatar);
}
}
if(user.contains(CG_UN)){
QString name = user.value(CG_UN).toString();
if(name.compare(mUsername) != 0){
mUsername = name;
emit nameChanged(name);
}
}
if(user.contains(CG_ID)){
quint64 id = quint64(user.value(CG_ID).toDouble());
if(id != mId){
mId = id;
emit playerIDChanged(id);
}
}
}
void CGProfile::setAvatar(QString avatar)
{
if(mAvatar.compare(avatar) != 0){
mAvatar = avatar;
mServer->updateProfile(serializeProfile());
emit avatarChanged(avatar);
}
}
QJsonObject CGProfile::getRecentPGN()
{
QJsonDocument doc = QJsonDocument::fromJson(mRecentGame.value("snap").toString().toLocal8Bit());
QJsonObject pgn = doc.object();
return pgn;
}
void CGProfile::setRecentMatch(QString recent)
{
QJsonDocument doc = QJsonDocument::fromJson(recent.toLocal8Bit());
mRecentGame = doc.object();
}
void CGProfile::setUserProfile(QString data)
{
QJsonDocument doc = QJsonDocument::fromJson(data.toLocal8Bit());
QJsonObject user = doc.object();
if(user.contains(CG_AR)){
bool arrows = user.value(CG_AR).toBool();
if(arrows != mArrows){
mArrows = arrows;
emit arrowsChanged(arrows);
}
}
if(user.contains(CG_AP)){
bool ap = user.value(CG_AP).toBool();
if(ap != mAutoPromote){
mAutoPromote = ap;
emit autoPromoteChanged(ap);
}
}
if(user.contains(CG_BAN)){
bool ban = user.value(CG_BAN).toBool();
if(ban != mBanned){
mBanned = ban;
emit bannedChanged(ban);
}
}
if(user.contains(CG_BT)){
QString bt = user.value(CG_BT).toString();
if(bt.compare(mBoardTexture) != 0){
mBoardTexture = bt;
emit boardTextureChanged(bt);
}
}
if(user.contains(CG_BF)){
quint64 bitfield = quint64(user.value(CG_BF).toDouble());
if(bitfield != mCGBitField){
mCGBitField = bitfield;
emit cgDataChanged(bitfield);
}
}
if(user.contains(CG_CO)){
bool coords = user.value(CG_CO).toBool();
if(coords != mCoordinates){
mCoordinates = coords;
emit coordinatesChanged(coords);
}
}
if(user.contains(CG_CF)){
QString country = user.value(CG_CF).toString();
if(country.compare(mCountry) != 0){
mCountry = country;
emit countryChanged(country);
}
}
if(user.contains(CG_LANG)){
int language = user.value(CG_LANG).toInt();
if(language != mLanguage){
mLanguage = language;
emit languageChanged(language);
}
}
if(user.contains(CG_SND)){
bool sound = user.value(CG_SND).toBool();
if(sound != mStartSound){
mStartSound = sound;
emit startSoundChanged(sound);
}
}
if(user.contains(CG_PS)){
int piece = user.value(CG_PS).toInt();
if(piece != mPieceSet){
mPieceSet = piece;
emit pieceSetChanged(piece);
}
}
if(user.contains(CG_AV)){
QString avatar = user.value(CG_AV).toString();
if(avatar.compare(mAvatar) != 0){
mAvatar = avatar;
emit avatarChanged(avatar);
}
}
if(user.contains(CG_E)){
int elo = user.value(CG_E).toInt();
if(elo != mElo){
mElo = elo;
emit eloChanged(elo);
}
}
if(user.contains(CG_TOTL)){
quint64 total = quint64(user.value(CG_TOTL).toDouble());
if(total != mGamesPlayed){
mGamesPlayed = total;
emit gamesPlayedChanged(mGamesPlayed);
}
}
if(user.contains(CG_WON)){
quint64 won = quint64(user.value(CG_WON).toDouble());
if(won != mGamesWon){
mGamesWon = won;
emit gamesWonChanged(won);
}
}
if(user.contains(CG_UN)){
QString name = user.value(CG_UN).toString();
if(name.compare(mUsername) != 0){
mUsername = name;
emit nameChanged(name);
}
}
if(user.contains(CG_ID)){
quint64 id = quint64(user.value(CG_ID).toDouble());
if(id != mId){
mId = id;
emit playerIDChanged(id);
}
}
}
void CGProfile::setBoardTexture(QString texture)
{
mBoardTexture = texture;
}
void CGProfile::setBoardBackground(QString background)
{
mBoardBackground = background;
}
QJsonObject CGProfile::serializeProfile()
{
QJsonObject obj;
obj[CG_AV] = mAvatar;
obj[CG_AP] = mAutoPromote;
obj[CG_AR] = mArrows;
obj[CG_BF] = double(mCGBitField);
obj[CG_BT] = mBoardTexture;
obj[CG_CF] = mCountry;
obj[CG_CO] = mCoordinates;
obj[CG_E] = mElo;
obj[CG_ID] = double(mId);
obj[CG_LANG] = mLanguage;
obj[CG_PS] = mPieceSet;
obj[CG_SND] = mStartSound;
obj[CG_WON] = double(mGamesWon);
obj[CG_TOTL] = double(mGamesPlayed);
obj[CG_UN] = mUsername;
return obj;
}
qreal CGProfile::winRatio()
{
return qreal(mGamesWon)/qreal(mGamesPlayed) * qreal(100);
}
CGProfile::~CGProfile()
{
}
| 23.372506
| 100
| 0.582298
|
Tpimp
|
b0174c361a2f6e3ee8b6ebd8a09ef7f934f21b7c
| 7,976
|
hpp
|
C++
|
src/ibeo_8l_sdk/src/ibeosdk/Time.hpp
|
tomcamp0228/ibeo_ros2
|
ff56c88d6e82440ae3ce4de08f2745707c354604
|
[
"MIT"
] | 1
|
2020-06-19T11:01:49.000Z
|
2020-06-19T11:01:49.000Z
|
include/ibeosdk/Time.hpp
|
chouer19/enjoyDriving
|
e4a29e6cad7d3b0061d59f584cce7cdea2a55351
|
[
"MIT"
] | null | null | null |
include/ibeosdk/Time.hpp
|
chouer19/enjoyDriving
|
e4a29e6cad7d3b0061d59f584cce7cdea2a55351
|
[
"MIT"
] | 2
|
2020-06-19T11:01:48.000Z
|
2020-10-29T03:07:14.000Z
|
//======================================================================
/*! \file Time.hpp
*
* \copydoc Copyright
* \author Jan Christian Dittmer (jcd)
* \date Jul 4, 2012
*///-------------------------------------------------------------------
#ifndef IBEOSDK_TIME_HPP_SEEN
#define IBEOSDK_TIME_HPP_SEEN
//======================================================================
#include <ibeosdk/misc/WinCompatibility.hpp>
#include <ibeosdk/inttypes.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/noncopyable.hpp>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <time.h>
#include <string.h>
#include <assert.h>
#ifdef _WIN32
#if _MSC_VER < 1800 //VS 2013 is not tested 1900 == VS 2015
struct timespec {
time_t tv_sec;
time_t tv_nsec;
};
#endif // before VS 2013
typedef time_t nanoseconds_t;
#else // _WIN32
typedef long int nanoseconds_t;
#endif // _WIN32
//======================================================================
namespace ibeosdk {
//======================================================================
class TimeConversion : private boost::noncopyable {
public:
TimeConversion();
TimeConversion(const std::string& formatStr);
~TimeConversion();
public:
const char* toString(const timespec ts, const int secPrecision=0) const;
const char* toString(const tm& ltime, const nanoseconds_t nanoseconds, const int secPrecision=0) const;
const char* toString(const time_t secs) const;
// const char* toString(const long int secs, const uint32_t nSecs, const uint32_t nbOfDigits) const;
std::string toString(const boost::posix_time::ptime ts, const int secPrecision = 0) const;
std::string toStdString(const time_t secs) const;
protected:
static const int szDefaultFmt = 18;
static const char defaultFmt[szDefaultFmt];
static const int szTimeStr = 64;
protected:
char* fmt;
mutable char timeStr[szTimeStr];
}; // TimeConversion
//======================================================================
//======================================================================
//======================================================================
namespace Time {
//======================================================================
/*!\brief Return the real-time clock of the system.
* \return The current UTC time
* \sa ibeo::localTime()
*///-------------------------------------------------------------------
boost::posix_time::ptime universalTime();
//======================================================================
/*!\brief Return the real-time clock of the system.
* \return The current UTC time
* \sa ibeo::universalTime()
*///-------------------------------------------------------------------
boost::posix_time::ptime localTime();
//======================================================================
} // namespace Time
//======================================================================
//======================================================================
//======================================================================
class NTPTime {
public:
static NTPTime getInvalidTime() { NTPTime t; t.setInvalid(); return t; }
public:
NTPTime() : m_Time(0) {}
NTPTime(const uint64_t time) : m_Time(time) {}
NTPTime(const uint32_t sec, const uint32_t frac)
: m_Time(0)
{
this->set(sec, frac);
}
NTPTime(const boost::posix_time::ptime& timestamp);
public: // Assignment operators
NTPTime& operator=(const uint64_t u) { m_Time = u; return *this; }
NTPTime& operator+= (const NTPTime& Q) { m_Time += Q.m_Time; return *this; }
NTPTime& operator-= (const NTPTime& Q) { m_Time -= Q.m_Time; return *this; }
public: // Cast operators
operator uint64_t() { return this->m_Time; }
public: // comparison operators
bool operator==(const NTPTime& other) const { return (m_Time == other.m_Time); }
bool operator!=(const NTPTime& other) const { return (m_Time != other.m_Time); }
bool operator>=(const NTPTime& other) const { return (m_Time >= other.m_Time); }
bool operator>(const NTPTime& other) const { return (m_Time > other.m_Time); }
bool operator<=(const NTPTime& other) const { return (m_Time <= other.m_Time); }
bool operator<(const NTPTime& other) const { return (m_Time < other.m_Time); }
public: // arithmetic operators
NTPTime operator+(const NTPTime& other) const
{
NTPTime result = *this;
result += other;
return result;
}
NTPTime operator-(const NTPTime& other) const
{
NTPTime result = *this;
result -= other;
return result;
}
public:
/// returns the current time in seconds.
uint32_t getSeconds() const { return ((uint32_t)(m_Time >> 32));}
/// returns the fractional part of the second
uint32_t getFracSeconds() const { return ((uint32_t)(m_Time & 0xFFFFFFFF));}
/// returns the current time in milli seconds. take care for possible overflow.
uint32_t getMilliseconds() const { const uint64_t t = 1000*m_Time ; return (uint32_t)((t>>32)&0xFFFFFFFF);}
/// returns the current time in micro seconds. take care for possible overflow.
uint32_t getMicroseconds() const { const uint64_t t = 125*m_Time/536871; return (uint32_t)(t&0xFFFFFFFF);}
/// returns the time in seconds and microseconds (micros: 0..1000 0000). conversion error: 0.. -7.6 us.
void getTime_s_us(uint32_t& sec, uint32_t& us) const { sec = getSeconds(); us = getFracSeconds()/4295;}
uint64_t getTime(void) const {return m_Time;}
public:
/// set the time in seconds and microseconds (micros: 0..1000 0000)
///This routine uses the factorization: 2^32/10^6 = 4096 + 256 - 1825/32
void setTime_s_us(const uint32_t sec, const uint32_t us) { m_Time = ((uint64_t)sec<<32) | ((us<<12)-((us*1852)>>5)+(us<<8));}
void set(const uint64_t& u) {m_Time = u;}
void set(const uint32_t sec, const uint32_t frac)
{
m_Time = sec;
m_Time = m_Time<<32;
m_Time |= frac;
}
void setInvalid() { m_Time = uint64_t(NOT_A_DATE_TIME) << 32; }
/// This routine uses the factorization
/// 2^32/10^6 = 4096 + 256 - 1825/32
void setMicroseconds(const uint32_t u) { const uint64_t t = ((uint64_t)u * 1825) >> 5; m_Time = ((uint64_t)u << 12) + ((uint64_t)u << 8) - t;}
void setMicroseconds(const uint64_t u) { const uint64_t t = (u * 1825) >> 5; m_Time = (u << 12) + (u << 8) - t;}
void setMilliseconds(const uint32_t u) { m_Time = (uint64_t)u * 536870912 / 125;}
void addMilliseconds(const uint32_t u) { NTPTime t; t.setMilliseconds(u); *this += t;}
void addMicroseconds(const uint32_t u) { NTPTime t; t.setMicroseconds(u); *this += t;}
public:
// timespec toTimeSpec() const; // NTP epoch 1-1-1900, Posix epoch 1-1-1970
boost::posix_time::time_duration toTimeDurationSinceEpoch() const;
boost::posix_time::ptime toPtime() const;
/// Returns true if this timestamp does not represent an actual
/// time, and toPTime() would return a
/// boost::posix_time::not_a_date_time.
bool is_not_a_date_time() const;
void setFromPTime(const boost::posix_time::ptime& timestamp);
protected:
static double round(const double v);
private:
/// Constants to convert fractions of a second: 1/(2^32) s (NTP) to nanoseconds (1e-9 s).
/*!
* For efficiency, the NTP epoch and factors to convert between ns and 1/(2^32)s
* are saved in static variables that are
* computed only once at system initialization.
* \sa epoch()
*/
static const double secondFractionNTPtoNanoseconds;
static const double nanosecondsToSecondFractionNTP;
/// Representation of a not_a_date_time value in the serialization
static const uint32_t NOT_A_DATE_TIME;
static const uint64_t NOT_A_DATE_TIME64;
static const boost::posix_time::ptime m_epoch;
protected:
uint64_t m_Time; ///< NTP time in 1/2^32 seconds (~233 ps)
}; // NTPTime
//======================================================================
} // namespace ibeosdk
//======================================================================
#endif // IBEOSDK_TIME_HPP_SEEN
//======================================================================
| 35.292035
| 143
| 0.592026
|
tomcamp0228
|
b01dec264401e6587f3f7c4bd34455ba91473664
| 5,066
|
cpp
|
C++
|
vishnucommon/json/PropertyGroups.cpp
|
gmrvvis/VishnuCommon
|
44a6c51528d0b6a93e847802c5b58df82fc9ad2c
|
[
"MIT"
] | null | null | null |
vishnucommon/json/PropertyGroups.cpp
|
gmrvvis/VishnuCommon
|
44a6c51528d0b6a93e847802c5b58df82fc9ad2c
|
[
"MIT"
] | null | null | null |
vishnucommon/json/PropertyGroups.cpp
|
gmrvvis/VishnuCommon
|
44a6c51528d0b6a93e847802c5b58df82fc9ad2c
|
[
"MIT"
] | null | null | null |
/*
* Copyright (c) 2018-2019 GMRV/URJC.
*
* Authors: Gonzalo Bayo Martinez <gonzalo.bayo@urjc.es>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of his 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 "PropertyGroups.h"
#include <QJsonArray>
namespace vishnucommon
{
PropertyGroups::PropertyGroups( )
{
}
PropertyGroups::PropertyGroups(
const std::vector< std::string >& usedPrimaryKeys,
const std::vector< std::string >& usedNonPrimaryKeys,
const std::string& xAxis, const std::string& yAxis,
const std::string& zAxis )
: _usedPrimaryKeys( usedPrimaryKeys )
, _usedNonPrimaryKeys( usedNonPrimaryKeys )
, _axes( { xAxis, yAxis, zAxis } )
{
}
PropertyGroups::PropertyGroups(
const std::vector< std::string >& usedPrimaryKeys,
const std::vector< std::string >& usedNonPrimaryKeys,
const std::string& axes )
: _usedPrimaryKeys( usedPrimaryKeys )
, _usedNonPrimaryKeys( usedNonPrimaryKeys )
, _axes( { axes } )
{
}
PropertyGroups::~PropertyGroups( void )
{
}
std::vector< std::string > PropertyGroups::getUsedPrimaryKeys( void ) const
{
return _usedPrimaryKeys;
}
void PropertyGroups::setUsedPrimaryKeys(
const std::vector< std::string >& usedPrimaryKeys )
{
_usedPrimaryKeys = usedPrimaryKeys;
}
void PropertyGroups::addUsedPrimaryKey( const std::string& usedPrimaryKey )
{
_usedPrimaryKeys.emplace_back( usedPrimaryKey );
}
std::vector< std::string > PropertyGroups::getUsedNonPrimaryKeys( void ) const
{
return _usedNonPrimaryKeys;
}
void PropertyGroups::setUsedNonPrimaryKeys(
const std::vector< std::string >& usedNonPrimaryKeys )
{
_usedNonPrimaryKeys = usedNonPrimaryKeys;
}
void PropertyGroups::addUsedNonPrimaryKey(
const std::string& usedNonPrimaryKey )
{
_usedNonPrimaryKeys.emplace_back( usedNonPrimaryKey );
}
std::vector< std::string > PropertyGroups::getAxes( void ) const
{
return _axes;
}
void PropertyGroups::setAxes( const std::string& xAxis,
const std::string& yAxis, const std::string& zAxis )
{
_axes = { xAxis, yAxis, zAxis };
}
void PropertyGroups::setAxes( const std::string& axes )
{
_axes = { axes };
}
std::vector< std::string > PropertyGroups::getHeaders( void ) const
{
std::vector< std::string > pkHeaders = _usedPrimaryKeys;
pkHeaders.insert( pkHeaders.end( ), _usedNonPrimaryKeys.begin( ),
_usedNonPrimaryKeys.end( ) );
return pkHeaders;
}
void PropertyGroups::deserialize( const QJsonObject& jsonObject )
{
_usedPrimaryKeys.clear( );
QJsonArray usedPrimaryKeys = jsonObject[ "usedPrimaryKeys" ].toArray( );
for ( int i = 0; i < usedPrimaryKeys.size( ); ++i )
{
_usedPrimaryKeys.emplace_back(
usedPrimaryKeys.at( i ).toString( ).toStdString( ) );
}
_usedNonPrimaryKeys.clear( );
QJsonArray usedNonPrimaryKeys =
jsonObject[ "usedNonPrimaryKeys" ].toArray( );
for ( int i = 0; i < usedNonPrimaryKeys.size( ); ++i )
{
_usedNonPrimaryKeys.emplace_back(
usedNonPrimaryKeys.at( i ).toString( ).toStdString( ) );
}
_axes.clear( );
QJsonArray axes = jsonObject[ "axes" ].toArray( );
for ( int i = 0; i < axes.size( ); ++i )
{
_axes.emplace_back( axes.at( i ).toString( ).toStdString( ) );
}
}
void PropertyGroups::serialize( QJsonObject& jsonObject ) const
{
QJsonArray usedPrimaryKeys;
for ( const auto& usedPrimaryKey : _usedPrimaryKeys )
{
usedPrimaryKeys.append( QString::fromStdString( usedPrimaryKey ) );
}
jsonObject[ "usedPrimaryKeys" ] = usedPrimaryKeys;
QJsonArray usedNonPrimaryKeys;
for ( const auto& nonPrimaryKey : _usedNonPrimaryKeys )
{
usedNonPrimaryKeys.append( QString::fromStdString( nonPrimaryKey ) );
}
jsonObject[ "usedNonPrimaryKeys" ] = usedNonPrimaryKeys;
QJsonArray axes;
for ( const auto& axis : _axes )
{
axes.append( QString::fromStdString( axis ) );
}
jsonObject[ "axes" ] = axes;
}
}
| 28.948571
| 80
| 0.685946
|
gmrvvis
|
b028ea50ce27a675c7abfa20e2068f0a45dfea11
| 2,451
|
hpp
|
C++
|
Nacro/SDK/FN_PartyFinderListItem_parameters.hpp
|
Milxnor/Nacro
|
eebabf662bbce6d5af41820ea0342d3567a0aecc
|
[
"BSD-2-Clause"
] | 11
|
2021-08-08T23:25:10.000Z
|
2022-02-19T23:07:22.000Z
|
Nacro/SDK/FN_PartyFinderListItem_parameters.hpp
|
Milxnor/Nacro
|
eebabf662bbce6d5af41820ea0342d3567a0aecc
|
[
"BSD-2-Clause"
] | 1
|
2022-01-01T22:51:59.000Z
|
2022-01-08T16:14:15.000Z
|
Nacro/SDK/FN_PartyFinderListItem_parameters.hpp
|
Milxnor/Nacro
|
eebabf662bbce6d5af41820ea0342d3567a0aecc
|
[
"BSD-2-Clause"
] | 8
|
2021-08-09T13:51:54.000Z
|
2022-01-26T20:33:37.000Z
|
#pragma once
// Fortnite (1.8) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "../SDK.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function PartyFinderListItem.PartyFinderListItem_C.UnbindSocialItemDelegates
struct UPartyFinderListItem_C_UnbindSocialItemDelegates_Params
{
};
// Function PartyFinderListItem.PartyFinderListItem_C.UpdateStateText
struct UPartyFinderListItem_C_UpdateStateText_Params
{
};
// Function PartyFinderListItem.PartyFinderListItem_C.SetupExpansion
struct UPartyFinderListItem_C_SetupExpansion_Params
{
bool Expanded; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function PartyFinderListItem.PartyFinderListItem_C.HandlePresenceUpdated
struct UPartyFinderListItem_C_HandlePresenceUpdated_Params
{
};
// Function PartyFinderListItem.PartyFinderListItem_C.BindSocialItemDelegates
struct UPartyFinderListItem_C_BindSocialItemDelegates_Params
{
};
// Function PartyFinderListItem.PartyFinderListItem_C.InitializeItem
struct UPartyFinderListItem_C_InitializeItem_Params
{
};
// Function PartyFinderListItem.PartyFinderListItem_C.OnSocialItemSet
struct UPartyFinderListItem_C_OnSocialItemSet_Params
{
};
// Function PartyFinderListItem.PartyFinderListItem_C.ExpansionChanged
struct UPartyFinderListItem_C_ExpansionChanged_Params
{
bool* bExpanded; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function PartyFinderListItem.PartyFinderListItem_C.Construct
struct UPartyFinderListItem_C_Construct_Params
{
};
// Function PartyFinderListItem.PartyFinderListItem_C.Destruct
struct UPartyFinderListItem_C_Destruct_Params
{
};
// Function PartyFinderListItem.PartyFinderListItem_C.ExecuteUbergraph_PartyFinderListItem
struct UPartyFinderListItem_C_ExecuteUbergraph_PartyFinderListItem_Params
{
int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function PartyFinderListItem.PartyFinderListItem_C.InviteJoinChanged__DelegateSignature
struct UPartyFinderListItem_C_InviteJoinChanged__DelegateSignature_Params
{
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 28.835294
| 152
| 0.707058
|
Milxnor
|
b028eeab41e673ea97b51c68d42d49436b0c96c8
| 433
|
cpp
|
C++
|
codeforce/E54/B.cpp
|
heiseish/Competitive-Programming
|
e4dd4db83c38e8837914562bc84bc8c102e68e34
|
[
"MIT"
] | 5
|
2019-03-17T01:33:19.000Z
|
2021-06-25T09:50:45.000Z
|
codeforce/E54/B.cpp
|
heiseish/Competitive-Programming
|
e4dd4db83c38e8837914562bc84bc8c102e68e34
|
[
"MIT"
] | null | null | null |
codeforce/E54/B.cpp
|
heiseish/Competitive-Programming
|
e4dd4db83c38e8837914562bc84bc8c102e68e34
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool is(ll n) {
if (n%2==0) return false;
for (ll i = 3; i * i <= n;i+=2) {
if (n%i==0) return false;
}
return true;
}
int main() {
ll n;
cin >> n;
if (is(n)) printf("1\n");
else if (n%2==0) printf("%lld\n", n/2);
else {
for (int i = 2; i <= n; i++) {
if (is(i) && n%i == 0) {
printf("%lld\n", (n-i)/2 + 1 );
break;
}
}
}
return 0;
}
| 16.653846
| 40
| 0.484988
|
heiseish
|
b0349898d9f32c718b9d263b0c44857fa7eb4b78
| 4,168
|
cpp
|
C++
|
Assignment 3/main.cpp
|
John-Ghaly88/ProgrammingIII_CPP_Course
|
4a6d37d192d0035e07771e7586308623a3f28377
|
[
"MIT"
] | null | null | null |
Assignment 3/main.cpp
|
John-Ghaly88/ProgrammingIII_CPP_Course
|
4a6d37d192d0035e07771e7586308623a3f28377
|
[
"MIT"
] | null | null | null |
Assignment 3/main.cpp
|
John-Ghaly88/ProgrammingIII_CPP_Course
|
4a6d37d192d0035e07771e7586308623a3f28377
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
class Article{
public:
int numberOfArticel, orderDuration;
string description;
double costPrice;
Article(string n, string d, string c, string o){
numberOfArticel = stoi(n);
description = d;
costPrice = stod(c);
orderDuration = stoi(o);
}
};
class Stock{
public:
static int totalStock;
int articleNumber, actualStock, maximumStock, consumption;
Stock(string n, string as, string ms, string c){
articleNumber = stoi(n);
actualStock = stoi(as);
maximumStock = stoi(ms);
consumption = stoi(c);
totalStock += stoi(as);
}
};
int Stock::totalStock = 0;
int rop(Article a, Stock s){
int lead_time_demand, safety_stock;
lead_time_demand = a.orderDuration * s.consumption;
safety_stock = 2 * s.consumption;
return lead_time_demand + safety_stock;
}
string orderProposal(Article a, Stock s){
if (s.actualStock <= rop(a,s))
return "Yes";
else
return "No";
}
int main()
{
fstream in;
in.open("input.csv", ios::in);
string line, word;
string l0[7], l1[7], l2[7], l3[7], l4[7];
//Row 1 (read)
getline(in, line);
stringstream t0(line);
for(int i=0; i<7; i++)
getline(t0, l0[i], ',');
Article a0(l0[0], l0[1], l0[4], l0[6]);
Stock s0(l0[0], l0[2], l0[3], l0[5]);
//Row 2 (read)
getline(in, line);
stringstream t1(line);
for(int i=0; i<7; i++)
getline(t1, l1[i], ',');
Article a1(l1[0], l1[1], l1[4], l1[6]);
Stock s1(l1[0], l1[2], l1[3], l1[5]);
//Row 3 (read)
getline(in, line);
stringstream t2(line);
for(int i=0; i<7; i++)
getline(t2, l2[i], ',');
Article a2(l2[0], l2[1], l2[4], l2[6]);
Stock s2(l2[0], l2[2], l2[3], l2[5]);
//Row 4 (read)
getline(in, line);
stringstream t3(line);
for(int i=0; i<7; i++)
getline(t3, l3[i], ',');
Article a3(l3[0], l3[1], l3[4], l3[6]);
Stock s3(l3[0], l3[2], l3[3], l3[5]);
//Row 5 (read)
getline(in, line);
stringstream t4(line);
for(int i=0; i<7; i++)
getline(t4, l4[i], ',');
Article a4(l4[0], l4[1], l4[4], l4[6]);
Stock s4(l4[0], l4[2], l4[3], l4[5]);
cout << "The total stock value is: " << Stock::totalStock <<endl;
fstream out;
out.open("output.csv", ios::out | ios::app);
//Row 1 (write)
out << to_string(a0.numberOfArticel) << "," << a0.description << "," << to_string(s0.actualStock) << ","
<< to_string(s0.maximumStock) << "," << to_string(a0.costPrice) << "," << to_string(s0.consumption) << ","
<< to_string(a0.orderDuration) << "," << to_string(rop(a0,s0)) << "," << orderProposal(a0,s0) << "\n";
//Row 2 (write)
out << to_string(a1.numberOfArticel) << "," << a1.description << "," << to_string(s1.actualStock) << ","
<< to_string(s1.maximumStock) << "," << to_string(a1.costPrice) << "," << to_string(s1.consumption) << ","
<< to_string(a1.orderDuration) << "," << to_string(rop(a1,s1)) << "," << orderProposal(a1,s1) << "\n";
//Row 3 (write)
out << to_string(a2.numberOfArticel) << "," << a2.description << "," << to_string(s2.actualStock) << ","
<< to_string(s2.maximumStock) << "," << to_string(a2.costPrice) << "," << to_string(s2.consumption) << ","
<< to_string(a2.orderDuration) << "," << to_string(rop(a2,s2)) << "," << orderProposal(a2,s2) << "\n";
//Row 4 (write)
out << to_string(a3.numberOfArticel) << "," << a3.description << "," << to_string(s3.actualStock) << ","
<< to_string(s3.maximumStock) << "," << to_string(a3.costPrice) << "," << to_string(s3.consumption) << ","
<< to_string(a3.orderDuration) << "," << to_string(rop(a3,s3)) << "," << orderProposal(a3,s3) << "\n";
//Row 5 (write)
out << to_string(a4.numberOfArticel) << "," << a4.description << "," << to_string(s4.actualStock) << ","
<< to_string(s4.maximumStock) << "," << to_string(a4.costPrice) << "," << to_string(s4.consumption) << ","
<< to_string(a4.orderDuration) << "," << to_string(rop(a4,s4)) << "," << orderProposal(a4,s4) << "\n";
return 0;
}
| 29.985612
| 110
| 0.554223
|
John-Ghaly88
|
b03752f309df09d4042ea083b10c84b97e652c37
| 695
|
cpp
|
C++
|
cpp/data-structure/union-find.cpp
|
luckylat/luckYrat_library
|
c77bd6ac070db8c929c3d7419eaa73805793108c
|
[
"CC0-1.0"
] | null | null | null |
cpp/data-structure/union-find.cpp
|
luckylat/luckYrat_library
|
c77bd6ac070db8c929c3d7419eaa73805793108c
|
[
"CC0-1.0"
] | 4
|
2021-10-16T10:47:13.000Z
|
2021-11-17T06:34:09.000Z
|
cpp/data-structure/union-find.cpp
|
luckylat/luckYrat_library
|
c77bd6ac070db8c929c3d7419eaa73805793108c
|
[
"CC0-1.0"
] | null | null | null |
struct UnionFind {
int n;
vector<int> par;
vector<int> size_;
UnionFind(int n_) : n(n_), par((size_t)n_), size_((size_t)n_,1){
for(int i = 0; n > i; i++)par[i] = i;
}
int root(int x){
if(par[x] == x)return x;
return par[x] = root(par[x]);
}
void unite(int a,int b){
int ra = root(a);
int rb = root(b);
if(ra==rb)return;
if(size(ra) > size(rb)) swap(ra,rb);
par[ra] = rb;
size_[rb] += size_[ra];
}
bool same(int a, int b){
return root(a) == root(b);
}
int size(int a){
return size_[root(a)];
}
void debug(){
for(int i = 0; n > i; i++){
cout << size_[root(i)] << " ";
}
cout << endl;
return;
}
};
| 18.289474
| 66
| 0.496403
|
luckylat
|
b037e015508784d4e138eb5b1d31fef84a215f12
| 677
|
cpp
|
C++
|
C++/LeetCode/0091.cpp
|
spycedcoffee/DSA
|
1e559ed5251a2005cc2815438d865f0293f4cd44
|
[
"MIT"
] | 4
|
2021-08-28T19:16:50.000Z
|
2022-03-04T19:46:31.000Z
|
C++/LeetCode/0091.cpp
|
spycedcoffee/DSA
|
1e559ed5251a2005cc2815438d865f0293f4cd44
|
[
"MIT"
] | 8
|
2021-10-29T19:10:51.000Z
|
2021-11-03T12:38:00.000Z
|
C++/LeetCode/0091.cpp
|
spycedcoffee/DSA
|
1e559ed5251a2005cc2815438d865f0293f4cd44
|
[
"MIT"
] | 4
|
2021-09-06T05:53:07.000Z
|
2021-12-24T10:31:40.000Z
|
class Solution {
public:
int numDecodings(string s) {
if(s[0] == '0')
return 0;
int point1 = 0;
int point2 = 0;
int ch = 1;
for(int i = s.length() - 1; i >= 0; i--){
point2 = point1;
point1 = ch;
ch = 0;
if(s[i] != '0')
ch = point1;
if(i < s.length() - 1){
int letter = (s[i] - '0') * 10 + s[i + 1] - '0';
if(letter >= 10 && letter <= 26)
ch += point2;
}
}
return ch;
}
};
| 21.15625
| 64
| 0.289513
|
spycedcoffee
|
b03873653e7dbafc89b242aba774ec9ffcc8fbe6
| 19,609
|
cpp
|
C++
|
src/appointment.cpp
|
NuLL3rr0r/samsungdforum-ir
|
f293631bbb7b96f854e7b89b286251d56ea70690
|
[
"MIT",
"Unlicense"
] | null | null | null |
src/appointment.cpp
|
NuLL3rr0r/samsungdforum-ir
|
f293631bbb7b96f854e7b89b286251d56ea70690
|
[
"MIT",
"Unlicense"
] | null | null | null |
src/appointment.cpp
|
NuLL3rr0r/samsungdforum-ir
|
f293631bbb7b96f854e7b89b286251d56ea70690
|
[
"MIT",
"Unlicense"
] | null | null | null |
/**********************************
* = Header File Inclusion =
**********************************/
#include <unordered_map>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <Wt/WApplication>
#include <Wt/WComboBox>
#include <Wt/WContainerWidget>
#include <Wt/WDialog>
#include <Wt/WGridLayout>
#include <Wt/WMessageBox>
#include <Wt/WPushButton>
#include <Wt/WText>
#include <Wt/WVBoxLayout>
#include <Wt/WWidget>
#include "appointment.hpp"
#include "cdate.hpp"
#include "crypto.hpp"
#include "db.hpp"
/**********************************
* = PreProcessor Directives =
**********************************/
/**********************************
* = Importing NameSpaces =
**********************************/
using namespace std;
using namespace boost;
using namespace cppdb;
using namespace Wt;
using namespace SamsungDForumIr;
/**********************************
* = Constants =
**********************************/
/**********************************
* = Enumerations =
**********************************/
/**********************************
* = Properties =
**********************************/
/**********************************
* = Fields =
**********************************/
/**********************************
* = Constructos =
**********************************/
Appointment::Appointment(CgiRoot *cgi, Wt::WDialog *parentDialog) : BaseWidget(cgi),
m_dlgParent(parentDialog),
m_editMode(false),
m_jsNextMonthClicked(this, "JSNextMonthClicked"),
m_jsPreviousMonthClicked(this, "JSPreviousMonthClicked"),
m_jsADaySelected(this, "JSADaySelected"),
m_jsAnHourSelected(this, "JSAnHourSelected")
{
this->clear();
this->setId("AppointmentWidget");
this->addWidget(Layout());
m_jsNextMonthClicked.connect(this, &Appointment::OnNextMonthClickedTriggered);
m_jsPreviousMonthClicked.connect(this, &Appointment::OnPreviousMonthClickedTriggered);
m_jsADaySelected.connect(this, &Appointment::OnADaySelectedTriggered);
m_jsAnHourSelected.connect(this, &Appointment::OnAnHourSelectedTriggered);
m_dlgParent->contents()->addWidget(this);
}
/**********************************
* = Destructor =
**********************************/
/**********************************
* = Public Methods =
**********************************/
/**********************************
* = Event Handlers =
**********************************/
JSignal<int> &Appointment::JSNextMonthClicked()
{
return m_jsNextMonthClicked;
}
JSignal<int> &Appointment::JSPreviousMonthClicked()
{
return m_jsPreviousMonthClicked;
}
JSignal<int> &Appointment::JSADaySelected()
{
return m_jsADaySelected;
}
JSignal<int> &Appointment::JSAnHourSelected()
{
return m_jsAnHourSelected;
}
void Appointment::OnNextMonthClickedTriggered(int index)
{
m_month = index;
doJavaScript("preperTaghvim(" + lexical_cast<string>(index) + ", '" + GetReservedDays(index) + "');");
}
void Appointment::OnPreviousMonthClickedTriggered(int index)
{
m_month = index;
doJavaScript("preperTaghvim(" + lexical_cast<string>(index) + ", '" + GetReservedDays(index) + "');");
}
void Appointment::OnADaySelectedTriggered(int index)
{
ClearSelectedDate();
m_day = index;
doJavaScript("preperHour('" + GetReservedHours(index) + "');");
}
void Appointment::OnAnHourSelectedTriggered(int index)
{
m_hour = index;
UpdateSelectedDate();
if (m_submitButton->isDisabled()) {
m_submitButton->enable();
}
}
void Appointment::OnDateYYComboBoxChanged(int index)
{
if (index != 0) {
m_dateYYComboBox->removeStyleClass("Wt-invalid", true);
} else {
m_dateYYComboBox->setStyleClass("Wt-invalid");
}
}
void Appointment::OnDateMMComboBoxChanged(int index)
{
if (index != 0) {
m_dateMMComboBox->removeStyleClass("Wt-invalid", true);
} else {
m_dateMMComboBox->setStyleClass("Wt-invalid");
}
}
void Appointment::OnDateDDComboBoxChanged(int index)
{
if (index != 0) {
m_dateDDComboBox->removeStyleClass("Wt-invalid", true);
} else {
m_dateDDComboBox->setStyleClass("Wt-invalid");
}
}
void Appointment::OnTimeHHComboBoxChanged(int index)
{
if (index != 0) {
m_timeHHComboBox->removeStyleClass("Wt-invalid", true);
} else {
m_timeHHComboBox->setStyleClass("Wt-invalid");
}
}
void Appointment::OnSubmitButtonPressed()
{
/*if (m_dateYYComboBox->currentIndex() == 0) {
m_dateYYComboBox->setFocus();
return;
}
if (m_dateMMComboBox->currentIndex() == 0) {
m_dateMMComboBox->setFocus();
return;
}
if (m_dateDDComboBox->currentIndex() == 0) {
m_dateDDComboBox->setFocus();
return;
}
if (m_timeHHComboBox->currentIndex() == 0) {
m_timeHHComboBox->setFocus();
return;
}
result r = m_db->Sql() << "SELECT rowid FROM ["
+ m_dbTables->Table("APPOINTMENTS")
+ "] WHERE email!=? AND year=? AND month=? AND day=? AND hour=?;"
<< m_cgiEnv->LoggedInUserName
<< m_year
<< m_dateMMComboBox->currentIndex()
<< m_dateDDComboBox->currentIndex()
<< m_timeHHComboBox->currentIndex() - 1
<< row;
if (!r.empty()) {
m_msg = new WMessageBox(L"عدم ثبت تاریخ",
L"متاسفانه زمان مورد نظر قبلا توسط کاربر دیگری ثبت شده است.", Warning, NoButton);
m_msg->addButton(L"تائید", Ok);
m_msg->buttonClicked().connect(this, &Appointment::OnSubmitFailedOK);
m_msg->show();
return;
}
if (!m_editMode) {
m_db->Insert(m_dbTables->Table("APPOINTMENTS"), "email, year, month, day, hour",
5, m_cgiEnv->LoggedInUserName.c_str(),
lexical_cast<string>(m_year).c_str(),
lexical_cast<string>(m_dateMMComboBox->currentIndex()).c_str(),
lexical_cast<string>(m_dateDDComboBox->currentIndex()).c_str(),
lexical_cast<string>(m_timeHHComboBox->currentIndex() - 1).c_str());
} else {
m_db->Update(m_dbTables->Table("APPOINTMENTS"), "email", m_cgiEnv->LoggedInUserName,
"year=?, month=?, day=?, hour=?", 4,
lexical_cast<string>(m_year).c_str(),
lexical_cast<string>(m_dateMMComboBox->currentIndex()).c_str(),
lexical_cast<string>(m_dateDDComboBox->currentIndex()).c_str(),
lexical_cast<string>(m_timeHHComboBox->currentIndex() - 1).c_str());
}
m_msg = new WMessageBox(L"ثبت شد",
L"با تشکر، هماهنگی لازم با شما انجام خواهد شد.", Warning, NoButton);
m_msg->addButton(L"تائید", Ok);
m_msg->buttonClicked().connect(this, &Appointment::OnSubmitSuccessOK);
m_msg->show();*/
result r = m_db->Sql() << "SELECT rowid FROM ["
+ m_dbTables->Table("APPOINTMENTS")
+ "] WHERE email!=? AND year=? AND month=? AND day=? AND hour=?;"
<< m_cgiEnv->LoggedInUserName
<< m_year
<< m_month
<< m_day
<< m_hour
<< row;
if (!r.empty()) {
m_msg = new WMessageBox(L"عدم ثبت تاریخ",
L"متاسفانه زمان مورد نظر قبلا توسط کاربر دیگری ثبت شده است.", Warning, NoButton);
m_msg->addButton(L"تائید", Ok);
m_msg->buttonClicked().connect(this, &Appointment::OnSubmitFailedOK);
m_msg->show();
return;
}
if (!m_editMode) {
m_db->Insert(m_dbTables->Table("APPOINTMENTS"), "email, year, month, day, hour",
5, m_cgiEnv->LoggedInUserName.c_str(),
lexical_cast<string>(m_year).c_str(),
lexical_cast<string>(m_month).c_str(),
lexical_cast<string>(m_day).c_str(),
lexical_cast<string>(m_hour).c_str());
} else {
m_db->Update(m_dbTables->Table("APPOINTMENTS"), "email", m_cgiEnv->LoggedInUserName,
"year=?, month=?, day=?, hour=?", 4,
lexical_cast<string>(m_year).c_str(),
lexical_cast<string>(m_month).c_str(),
lexical_cast<string>(m_day).c_str(),
lexical_cast<string>(m_hour).c_str());
}
m_msg = new WMessageBox(L"ثبت شد",
L"با تشکر، هماهنگی لازم با شما انجام خواهد شد.", Warning, NoButton);
m_msg->addButton(L"تائید", Ok);
m_msg->buttonClicked().connect(this, &Appointment::OnSubmitSuccessOK);
m_msg->show();
}
void Appointment::OnReturnButtonPressed()
{
m_dlgParent->hide();
}
void Appointment::OnSubmitFailedOK()
{
delete m_msg;
m_msg = NULL;
}
void Appointment::OnSubmitSuccessOK()
{
delete m_msg;
m_msg = NULL;
m_dlgParent->hide();
}
/**********************************
* = Protected Methods =
**********************************/
/**********************************
* = Private Methods =
**********************************/
string Appointment::GetReservedDays(size_t month)
{
string json("{\"Months\":[{\"ReservedDays\":[");
size_t minHour = 8;
size_t maxHour = 19;
bool found = false;
for (size_t d = 1; d <= 31; ++d) {
unordered_map<size_t, bool> reservedHours;
for (size_t i = minHour; i <= maxHour; ++i) {
reservedHours[i] = false;
}
result r = m_db->Sql() << "SELECT hour "
"FROM [" + m_dbTables->Table("APPOINTMENTS")
+ "] WHERE year=? AND month=? AND day=?;" << m_year << month << d;
while (r.next()) {
size_t hour;
r >> hour;
if (hour < minHour || hour > maxHour) {
continue;
}
reservedHours[hour] = true;
}
bool full = true;
for (size_t i = minHour; i <= maxHour; ++i) {
if (!reservedHours[i]) {
full = false;
break;
}
}
if (full) {
if (found)
json += ", ";
if (!found)
found = true;
json += (format("{\"Day%1%\": %1%}") % d).str();
}
}
json += "]}]}";
return json;
}
string Appointment::GetReservedHours(size_t day)
{
string json("{\"Days\":[{\"ReservedHours\":[");
result r = m_db->Sql() << "SELECT hour "
"FROM [" + m_dbTables->Table("APPOINTMENTS")
+ "] WHERE year=? AND month=? AND day=?;" << m_year << m_month << day;
bool found = false;
while (r.next()) {
if (found)
json += ", ";
if (!found)
found = true;
size_t h;
r >> h;
json += (format("{\"Hour%1%\": %1%}") % h).str();
}
json += "]}]}";
return json;
}
void Appointment::ClearSelectedDate()
{
m_submitButton->disable();
m_selectedDate->setText(L"");
}
void Appointment::UpdateSelectedDate()
{
wstring yearStr = boost::lexical_cast<wstring>(m_year);
wstring monthStr = boost::lexical_cast<wstring>(m_month);
wstring dayStr = boost::lexical_cast<wstring>(m_day);
wstring hourStr = boost::lexical_cast<wstring>(m_hour);
if (m_month < 10)
monthStr = L"0" + monthStr;
if (m_day < 10)
dayStr = L"0" + dayStr;
if (m_hour < 10)
hourStr = L"0" + hourStr;
m_selectedDate->setText((wformat(L"زمان انتخابی شما: %1%/%2%/%3% - %4%:00")
% yearStr
% monthStr
% dayStr
% hourStr).str());
}
/**********************************
* = Base Class Overrides =
**********************************/
WWidget *Appointment::Layout()
{
Div *root = new Div("Appointment");
/*
m_dateYYComboBox = new WComboBox();
m_dateMMComboBox = new WComboBox();
m_dateDDComboBox = new WComboBox();
m_timeHHComboBox = new WComboBox();
m_dateYYComboBox->addItem(m_lang->GetString("HOME_APPOINTMENT_DATE_YY_TEXT"));
m_dateMMComboBox->addItem(m_lang->GetString("HOME_APPOINTMENT_DATE_MM_TEXT"));
m_dateDDComboBox->addItem(m_lang->GetString("HOME_APPOINTMENT_DATE_DD_TEXT"));
m_timeHHComboBox->addItem(m_lang->GetString("HOME_APPOINTMENT_TIME_HH_TEXT"));
string date = CDate::DateConv::ToJalali();
size_t year = lexical_cast<size_t>(date.substr(0, 4));
m_year = year;
size_t month = lexical_cast<size_t>(date.substr(5, 2));
size_t day = lexical_cast<size_t>(date.substr(8, 2));
size_t hour = 0;
m_dateYYComboBox->addItem(CDate::DateConv::FormatToPersianNums(lexical_cast<wstring>(year)));
m_dateMMComboBox->addItem(L"فروردین");
m_dateMMComboBox->addItem(L"اردیبهشت");
m_dateMMComboBox->addItem(L"خرداد");
m_dateMMComboBox->addItem(L"تیر");
m_dateMMComboBox->addItem(L"مرداد");
m_dateMMComboBox->addItem(L"شهریور");
m_dateMMComboBox->addItem(L"مهر");
int yIndex = m_dateYYComboBox->findText(CDate::DateConv::FormatToPersianNums(lexical_cast<wstring>(year)));
if (yIndex > -1)
m_dateYYComboBox->setCurrentIndex(yIndex);
else
m_dateYYComboBox->setCurrentIndex(1);
m_dateMMComboBox->setCurrentIndex(month);
m_dateDDComboBox->setCurrentIndex(day);
m_timeHHComboBox->setCurrentIndex(hour + 1);
m_dateMMComboBox->addItem(L"آبان");
m_dateMMComboBox->addItem(L"آذر");
m_dateMMComboBox->addItem(L"دی");
m_dateMMComboBox->addItem(L"بهمن");
m_dateMMComboBox->addItem(L"اسفند");
for (size_t i = 1; i < 32; ++i) {
wstring d(lexical_cast<wstring>(i));
if (i < 10)
d = L"0" + d;
m_dateDDComboBox->addItem(CDate::DateConv::FormatToPersianNums(d));
}
for (size_t i = 0; i < 24; ++i) {
wstring h(lexical_cast<wstring>(i));
if (i < 10)
h = L"0" + h;
m_timeHHComboBox->addItem(CDate::DateConv::FormatToPersianNums(h));
}
//// YOU SHOULD QUERY HERE !!
result r = m_db->Sql() << "SELECT year, month, day, hour "
"FROM [" + m_dbTables->Table("APPOINTMENTS")
+ "] WHERE email=?;" << m_cgiEnv->LoggedInUserName << row;
if (!r.empty()) {
m_editMode = true;
r >> year >> month >> day >> hour;
}
if (!m_editMode) {
m_dateYYComboBox->setCurrentIndex(1);
m_dateMMComboBox->setCurrentIndex(month);
m_dateDDComboBox->setCurrentIndex(day);
m_timeHHComboBox->setCurrentIndex(10);
} else {
int yIndex = m_dateYYComboBox->findText(CDate::DateConv::FormatToPersianNums(lexical_cast<wstring>(year)));
if (yIndex > -1)
m_dateYYComboBox->setCurrentIndex(yIndex);
else
m_dateYYComboBox->setCurrentIndex(1);
m_dateMMComboBox->setCurrentIndex(month);
m_dateDDComboBox->setCurrentIndex(day);
m_timeHHComboBox->setCurrentIndex(hour + 1);
}
Div *dvForm = new Div(root);
dvForm->setStyleClass("form");
WGridLayout *dvFormLayout = new WGridLayout();
Div *dvDate = new Div();
dvDate->addWidget(m_dateYYComboBox);
dvDate->addWidget(new WText(" "));
dvDate->addWidget(m_dateMMComboBox);
dvDate->addWidget(new WText(" "));
dvDate->addWidget(m_dateDDComboBox);
Div *dvTime = new Div();
dvTime->addWidget(m_timeHHComboBox);
dvFormLayout->addWidget(new WText(m_lang->GetString("HOME_APPOINTMENT_DATE_TEXT")),
0, 0, AlignLeft | AlignMiddle);
dvFormLayout->addWidget(dvDate, 0, 1);
dvFormLayout->addWidget(new WText(m_lang->GetString("HOME_APPOINTMENT_TIME_TEXT")),
1, 0, AlignLeft | AlignMiddle);
dvFormLayout->addWidget(dvTime, 1, 1);
dvFormLayout->setColumnStretch(0, 100);
dvFormLayout->setColumnStretch(1, 300);
dvFormLayout->setVerticalSpacing(11);
dvForm->resize(400, WLength::Auto);
dvForm->setLayout(dvFormLayout);
Div *dvButtons = new Div(root, "dvDialogButtons");
WPushButton *submitButton = new WPushButton(m_lang->GetString("HOME_APPOINTMENT_DLG_OK_BUTTON"), dvButtons);
WPushButton *returnButton = new WPushButton(m_lang->GetString("HOME_APPOINTMENT_DLG_RETURN_BUTTON"), dvButtons);
submitButton->setStyleClass("dialogButton");
returnButton->setStyleClass("dialogButton");
OnDateYYComboBoxChanged(m_dateYYComboBox->currentIndex());
OnDateMMComboBoxChanged(m_dateMMComboBox->currentIndex());
OnDateDDComboBoxChanged(m_dateDDComboBox->currentIndex());
OnTimeHHComboBoxChanged(m_timeHHComboBox->currentIndex());
m_dateYYComboBox->activated().connect(this, &Appointment::OnDateYYComboBoxChanged);
m_dateMMComboBox->activated().connect(this, &Appointment::OnDateMMComboBoxChanged);
m_dateDDComboBox->activated().connect(this, &Appointment::OnDateDDComboBoxChanged);
m_timeHHComboBox->activated().connect(this, &Appointment::OnTimeHHComboBoxChanged);
submitButton->clicked().connect(this, &Appointment::OnSubmitButtonPressed);
returnButton->clicked().connect(this, &Appointment::OnReturnButtonPressed);
*/
new Div(root, "taghvimScript");
new Div(root, "showHour");
new Div(root, "numMo");
new Div(root, "selectedDay");
new Div(root, "selectedHour");
size_t year;
size_t month;
size_t day;
size_t hour;
result r = m_db->Sql() << "SELECT year, month, day, hour "
"FROM [" + m_dbTables->Table("APPOINTMENTS")
+ "] WHERE email=?;" << m_cgiEnv->LoggedInUserName << row;
if (!r.empty()) {
m_editMode = true;
r >> year >> month >> day >> hour;
}
if (!m_editMode) {
string date = CDate::DateConv::ToJalali();
m_year = lexical_cast<size_t>(date.substr(0, 4));
m_month = lexical_cast<size_t>(date.substr(5, 2));
m_day = lexical_cast<size_t>(date.substr(8, 2));
m_hour = 0;
} else {
m_year = year;
m_month = month;
m_day = day;
m_hour = hour;
}
doJavaScript("preperTaghvim(" + lexical_cast<string>(m_month) + ", '" + GetReservedDays(m_month) + "');");
Div *dvSelectedDate = new Div(root, "dvSelectedDate");
m_selectedDate = new WText(dvSelectedDate);
if (m_editMode)
UpdateSelectedDate();
Div *dvButtons = new Div(root, "dvDialogButtons");
m_submitButton = new WPushButton(m_lang->GetString("HOME_APPOINTMENT_DLG_OK_BUTTON"), dvButtons);
WPushButton *returnButton = new WPushButton(m_lang->GetString("HOME_APPOINTMENT_DLG_RETURN_BUTTON"), dvButtons);
m_submitButton->setStyleClass("dialogButton");
returnButton->setStyleClass("dialogButton");
m_submitButton->disable();
m_submitButton->clicked().connect(this, &Appointment::OnSubmitButtonPressed);
returnButton->clicked().connect(this, &Appointment::OnReturnButtonPressed);
return root;
}
/**********************************
* = Utility Methods =
**********************************/
/**********************************
* = Debug Methods =
**********************************/
| 31.3744
| 116
| 0.566577
|
NuLL3rr0r
|
b03ca5160c5012407da0b2178725738feb436158
| 606
|
cpp
|
C++
|
Bio.cpp
|
SubhamChoudhury/E-Lab-Object-Oriented-Programming
|
b94b6c25bc41a9d11d06e2cefeba7be7d583b335
|
[
"MIT"
] | 2
|
2020-09-09T09:27:45.000Z
|
2021-05-11T17:59:35.000Z
|
Bio.cpp
|
SubhamChoudhury/E-Lab-Object-Oriented-Programming
|
b94b6c25bc41a9d11d06e2cefeba7be7d583b335
|
[
"MIT"
] | 1
|
2020-09-16T20:34:36.000Z
|
2020-09-16T20:38:37.000Z
|
Bio.cpp
|
SubhamChoudhury/E-Lab-Object-Oriented-Programming
|
b94b6c25bc41a9d11d06e2cefeba7be7d583b335
|
[
"MIT"
] | 15
|
2019-08-01T03:49:25.000Z
|
2021-10-07T06:08:22.000Z
|
#include <iostream>
using namespace std;
class student
{
public:
int rollnumber, mark1, mark2;
void getdet1()
{
cin >> rollnumber;
cin >> mark1 >> mark2;
}
};
class sports
{
public:
int mark3;
void getdet2()
{
cin >> mark3;
}
};
class statement : public student, public sports
{
public:
void display()
{
cout << "Roll No:" << rollnumber << endl;
cout << "Total:" << (mark1 + mark2 + mark3) << endl;
cout << "Average:" << ((mark1 + mark2 + mark3) / 3) << endl;
}
};
int main()
{
statement obj;
obj.getdet1();
obj.getdet2();
obj.display();
return 0;
}
| 15.15
| 64
| 0.575908
|
SubhamChoudhury
|
b0403fdd503b27edd43428b0fd39059b82553bfc
| 3,866
|
cxx
|
C++
|
dcwapd.arrisxb3/tr181_configuration_provider.cxx
|
ewsi/dcwapd
|
7faad274fff41de58f1678cdc2c10c34a05981f2
|
[
"Apache-2.0"
] | null | null | null |
dcwapd.arrisxb3/tr181_configuration_provider.cxx
|
ewsi/dcwapd
|
7faad274fff41de58f1678cdc2c10c34a05981f2
|
[
"Apache-2.0"
] | 7
|
2019-09-25T15:45:40.000Z
|
2020-07-04T16:02:46.000Z
|
dcwapd.arrisxb3/tr181_configuration_provider.cxx
|
ewsi/dcwapd
|
7faad274fff41de58f1678cdc2c10c34a05981f2
|
[
"Apache-2.0"
] | 1
|
2019-09-17T17:35:24.000Z
|
2019-09-17T17:35:24.000Z
|
#include "./tr181_configuration_provider.h"
#include "ccspwrapper/tr181_collection_registry.h"
#include "dcw/dcwlog.h"
#include <cstring>
Tr181ConfigurationProvider::Tr181ConfigurationProvider() :
_stationTelemetry(_singleNetwork),
_ccspAbstractor("dcwapd.ccsp.cfg.xml", *this),
Xb3(_singleNetwork, _ccspAbstractor.CDM),
Network(_singleNetwork),
Cdm(_ccspAbstractor.CDM),
TelemetryCollector(_stationTelemetry) {
//
}
Tr181ConfigurationProvider::~Tr181ConfigurationProvider() {
//
}
//APConfigurationProvider Functions...
void Tr181ConfigurationProvider::InstanciateCFileTrafficFilterProfiles(CFTFPList& output) const {
_filters.InstanciateCFileTrafficFilterProfiles(output);
}
void Tr181ConfigurationProvider::GetPrimarySsids(SsidSet& output) const {
//only provide this if the network is enabled...
//if the network is not enabled, we dont want any
//configuration validation issues to throw an exception
//preventing the event reactor from running...
//the event reactor will "sleep forever" if the
//configuration is empty which is what we want
if (!_singleNetwork.GetEnabled()) return;
output.insert(Xb3.GetPrimaryChannelSsidName());
}
void Tr181ConfigurationProvider::GetDataSsids(SsidSet& output, const char * const primarySsid) const {
if (Xb3.GetPrimaryChannelSsidName() != primarySsid) {
//defensive...
dcwlogwarnf("Got a request to provide data SSIDs for non-declared primary SSID %s\n", primarySsid);
throw ::ccspwrapper::Tr181Exception();
}
output.insert(Xb3.GetDataChannelSsidName());
}
const char *Tr181ConfigurationProvider::GetSsidIfname(const char * const ssid) const {
const char * const rv = Xb3.GetSsidIfName(ssid);
if (rv == NULL)
dcwlogwarnf("Got a request to provide an interface for non-declared SSID %s\n", ssid);
return rv;
}
void Tr181ConfigurationProvider::GetStationTrafficFilterProfiles(StationTFPMap& output) const {
//only provide this if the network is enabled...
//if the network is not enabled, we dont want any
//configuration validation issues to throw an exception
//preventing the event reactor from running...
//the event reactor will "sleep forever" if the
//configuration is empty which is what we want
if (!_singleNetwork.GetEnabled()) return;
_stationFilterOverrides.GetStationTrafficFilterProfiles(output);
}
//Tr181ConfigProvider Functions...
void Tr181ConfigurationProvider::GetSubCollections(ccspwrapper::Tr181CollectionRegistry& registry) {
registry.DeclareSubCollectionProvider("Network", _singleNetwork);
registry.DeclareSubCollectionProvider("NetworkDataChannel", _singleNetwork.GetNetworkDataChannelSubCollectionProvider());
registry.DeclareSubCollectionProvider("Station", _stationTelemetry);
registry.DeclareSubCollectionProvider("StationDataChannel", _stationTelemetry.GetStationDataChannelSubCollectionProvider());
registry.DeclareSubCollectionProvider("Filter", _filters);
registry.DeclareSubCollectionProvider("StationFilterOverride", _stationFilterOverrides);
}
void Tr181ConfigurationProvider::GetValue(const char * const name, ccspwrapper::Tr181Scalar& value) {
if (strcmp(name, "FilterPath") == 0) {
value = _filters.GetScanPath();
}
else {
throw ccspwrapper::Tr181Exception();
}
}
void Tr181ConfigurationProvider::SetValue(const char * const name, const ccspwrapper::Tr181Scalar& value) {
if (strcmp(name, "FilterPath") == 0) {
_filters.SetScanPath(value);
}
else {
throw ccspwrapper::Tr181Exception();
}
}
bool Tr181ConfigurationProvider::Validate() {
dcwlogdbgf("TR181: %s()\n", __func__);
return true;
}
void Tr181ConfigurationProvider::Commit() {
dcwlogdbgf("TR181: %s()\n", __func__);
//
}
void Tr181ConfigurationProvider::Rollback() {
dcwlogdbgf("TR181: %s()\n", __func__);
//
}
| 32.216667
| 130
| 0.755044
|
ewsi
|
b044d6e87799bd12afb1357043ed4ef81fb6a52d
| 1,271
|
cpp
|
C++
|
Doom/src/Doom/FileDialogs/FileDialogs.cpp
|
Shturm0weak/OpenGL_Engine
|
6e6570f8dd9000724274942fff5a100f0998b780
|
[
"MIT"
] | 126
|
2020-10-20T21:39:53.000Z
|
2022-01-25T14:43:44.000Z
|
Doom/src/Doom/FileDialogs/FileDialogs.cpp
|
Shturm0weak/2D_OpenGL_Engine
|
6e6570f8dd9000724274942fff5a100f0998b780
|
[
"MIT"
] | 2
|
2021-01-07T17:29:19.000Z
|
2021-08-14T14:04:28.000Z
|
Doom/src/Doom/FileDialogs/FileDialogs.cpp
|
Shturm0weak/2D_OpenGL_Engine
|
6e6570f8dd9000724274942fff5a100f0998b780
|
[
"MIT"
] | 16
|
2021-01-09T09:08:40.000Z
|
2022-01-25T14:43:46.000Z
|
#include "pch.h"
#include "FileDialogs.h"
#include <sstream>
#include <commdlg.h>
std::optional<std::string> Doom::FileDialogs::OpenFile(const char* filter)
{
OPENFILENAMEA ofn;
CHAR szFile[260] = { 0 };
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window(Window::GetInstance().GetWindow());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
if (GetOpenFileNameA(&ofn) == TRUE) return ofn.lpstrFile;
return std::nullopt;
}
std::optional<std::string> Doom::FileDialogs::SaveFile(const char* filter)
{
OPENFILENAMEA ofn;
CHAR szFile[260] = { 0 };
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window(Window::GetInstance().GetWindow());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
// Sets the default extension by extracting it from the filter
ofn.lpstrDefExt = strchr(filter, '\0') + 1;
if (GetSaveFileNameA(&ofn) == TRUE) return ofn.lpstrFile;
return std::nullopt;
}
| 31
| 74
| 0.737215
|
Shturm0weak
|
b04b67a4acc949e8bda6b37225dae5735bd6c651
| 16,487
|
cpp
|
C++
|
detection/src/asms/colotracker.cpp
|
yongheng1991/multiple_object_tracking_in_RGB-D_camera_network
|
88143b437df2198a50ef7b223db58ed35b0bcfa4
|
[
"BSD-3-Clause"
] | 1
|
2021-05-14T08:48:43.000Z
|
2021-05-14T08:48:43.000Z
|
detection/src/asms/colotracker.cpp
|
yongheng1991/multiple_object_tracking_in_RGB-D_camera_network
|
88143b437df2198a50ef7b223db58ed35b0bcfa4
|
[
"BSD-3-Clause"
] | null | null | null |
detection/src/asms/colotracker.cpp
|
yongheng1991/multiple_object_tracking_in_RGB-D_camera_network
|
88143b437df2198a50ef7b223db58ed35b0bcfa4
|
[
"BSD-3-Clause"
] | null | null | null |
#include "open_ptrack/asms/colotracker.h"
#include <iostream>
#include <fstream>
void ColorTracker::init(cv::Mat & img, int x1, int y1, int x2, int y2)
{
im1 = cv::Mat( img.rows, img.cols, CV_8UC1 );
im2 = cv::Mat( img.rows, img.cols, CV_8UC1 );
im3 = cv::Mat( img.rows, img.cols, CV_8UC1 );
//boundary checks
y1 = std::max(0, y1);
y2 = std::min(img.rows-1, y2);
x1 = std::max(0, x1);
x2 = std::min(img.cols-1, x2);
preprocessImage(img);
extractForegroundHistogram(x1, y1, x2, y2, q_hist);
q_orig_hist = q_hist;
extractBackgroundHistogram(x1, y1, x2, y2, b_hist);
Histogram b_weights = b_hist;
b_weights.transformToWeights();
q_hist.multiplyByWeights(&b_weights);
lastPosition.setBBox(x1, y1, x2-x1, y2-y1, 1, 1);
defaultWidth = x2-x1;
defaultHeight = y2-y1;
sumIter = 0;
frame = 0;
double w2 = (x2-x1)/2.;
double h2 = (y2-y1)/2.;
double cx = x1 + w2;
double cy = y1 + h2;
double wh = w2+5.;
double hh = h2+5.;
double Sbg = 0, Sfg = 0;
for(int i = y1; i < y2+1; i++) {
const uchar *Mi1 = im1.ptr<uchar>(i);
const uchar *Mi2 = im2.ptr<uchar>(i);
const uchar *Mi3 = im3.ptr<uchar>(i);
double tmp_y = std::pow((cy - i) / hh, 2);
for (int j = x1; j < x1 + 1; j++) {
double arg = std::pow((cx - j) / wh, 2) + tmp_y;
if (arg > 1)
continue;
//likelihood weights
double wqi = 1.0;
double wbi = sqrt(b_hist.getValue(Mi1[j], Mi2[j], Mi3[j]) /
q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
Sbg += (wqi < wbi) ? q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j])
: 0.0;
Sfg += q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j]);
}
}
//wAvgBg = 0.5
wAvgBg = std::max(0.1, std::min(Sbg/Sfg, 0.5));
bound1 = 0.05;
bound2 = 0.1;
}
cv::Point ColorTracker::histMeanShift(double x1, double y1, double x2, double y2)
{
int maxIter = 15;
double w2 = (x2-x1+1)/2;
double h2 = (y2-y1+1)/2;
double borderX = 5;
double borderY = 5;
double cx = x1 + w2;
double cy = y1 + h2;
Histogram y1hist;
int ii;
for (ii = 0; ii < maxIter; ++ii){
double wh = (w2+borderX);
double hh = (h2+borderY);
int rowMin = std::max(0, (int)(cy-hh));
int rowMax = std::min(im1.rows, (int)(cy+hh));
int colMin = std::max(0, (int)(cx-wh));
int colMax = std::min(im1.cols, (int)(cx+wh));
extractForegroundHistogram(colMin, rowMin, colMax, rowMax, y1hist);
double batta_q = y1hist.computeSimilarity(&q_orig_hist);
double batta_b = y1hist.computeSimilarity(&b_hist);
//MeanShift Vector
double m0 = 0, m1x = 0, m1y = 0;
for(int i = rowMin; i < rowMax; i++){
const uchar* Mi1 = im1.ptr<uchar>(i);
const uchar* Mi2 = im2.ptr<uchar>(i);
const uchar* Mi3 = im3.ptr<uchar>(i);
double tmp_y = std::pow((cy-(float)i)/hh,2);
for(int j = colMin; j < colMax; j++){
double arg = std::pow((cx-(float)j)/wh,2) + tmp_y;
if (arg>1)
continue;
double wqi = sqrt(q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j])/y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
double wbi = sqrt(b_hist.getValue(Mi1[j], Mi2[j], Mi3[j])/y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
double wg = std::max(wqi/batta_q - wbi/batta_b, 0.0)*(-kernelProfile_EpanechnikovDeriv(arg));
m0 += wg;
m1x += (j-cx)*wg;
m1y += (i-cy)*wg;
}
}
double xn_1 = m1x/m0 + cx;
double yn_1 = m1y/m0 + cy;
if (std::pow(xn_1 - cx,2) + std::pow(yn_1 - cy,2) < 0.1)
break;
if (m0==m0 && !std::isinf(m0) && m0 > 0){
cx = xn_1;
cy = yn_1;
}
}
return cv::Point(cx, cy);
}
cv::Point ColorTracker::histMeanShiftIsotropicScale(double x1, double y1, double x2, double y2, double * scale, int * iter)
{
int maxIter = 15;
double w2 = (x2-x1)/2;
double h2 = (y2-y1)/2;
double borderX = 5;
double borderY = 5;
double cx = x1 + w2;
double cy = y1 + h2;
Histogram y1hist;
double h0 = 1;
int ii;
for (ii = 0; ii < maxIter; ++ii){
double wh = h0*w2+borderX;
double hh = h0*h2+borderY;
int rowMin = std::max(0, (int)(cy-hh));
int rowMax = std::min(im1.rows-1, (int)(cy+hh));
int colMin = std::max(0, (int)(cx-wh));
int colMax = std::min(im1.cols-1, (int)(cx+wh));
extractForegroundHistogram(colMin, rowMin, colMax, rowMax, y1hist);
double batta_q = y1hist.computeSimilarity(&q_orig_hist);
double batta_b = y1hist.computeSimilarity(&b_hist);
//MeanShift Vector
double m0 = 0, m1x = 0, m1y = 0;
double wg_dist_sum = 0, wk_sum = 0, Sbg = 0, Sfg = 0;
for(int i = rowMin; i < rowMax; i++){
const uchar* Mi1 = im1.ptr<uchar>(i);
const uchar* Mi2 = im2.ptr<uchar>(i);
const uchar* Mi3 = im3.ptr<uchar>(i);
double tmp_y = std::pow((cy-i)/hh,2);
for(int j = colMin; j < colMax; j++){
double arg = std::pow((cx-j)/wh,2) + tmp_y;
if (arg>1)
continue;
//likelihood weights
double wqi = sqrt(q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j])/y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
double wbi = sqrt(b_hist.getValue(Mi1[j], Mi2[j], Mi3[j])/y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
double w = std::max(wqi/batta_q - wbi/batta_b, 0.0);
//weights based on "Robust mean-shift tracking with corrected background-weighted histogram"
// double w = sqrt(q_hist.getValue(Mi1[j], Mi2[j], Mi3[j])/y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
//orig weights
// double w = sqrt(q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j])/y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
double wg = w*(-kernelProfile_EpanechnikovDeriv(arg));
double dist = std::sqrt(std::pow((j-cx)/w2,2) + std::pow((i-cy)/h2,2));
wg_dist_sum += wg*dist;
wk_sum += w*(kernelProfile_Epanechnikov(arg));
//orig weights
// Sbg += (q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j]) == 0) ? y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]) : 0;
// Sfg += q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j]);
//likelihood
Sbg += (wqi < wbi) ? y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]) : 0;
Sfg += q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j]);
//SCIA
// Sbg += (w == 0) ? y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]) : 0;
// Sfg += q_hist.getValue(Mi1[j], Mi2[j], Mi3[j]);
m0 += wg;
m1x += (j-cx)*wg;
m1y += (i-cy)*wg;
}
}
double xn_1 = m1x/m0 + cx;
double yn_1 = m1y/m0 + cy;
//Rebularization
double reg2 = 0, reg1 = 0;
reg1 = (wAvgBg - Sbg/Sfg);
if (std::abs(reg1) > bound1)
reg1 = reg1 > 0 ? bound1 : -bound1;
reg2 = -(log(h0));
if (std::abs(reg2) > bound2)
reg2 = reg2 > 0 ? bound2 : -bound2;
double h_tmp = (1.0 - wk_sum/m0)*h0 + (1.0/h0)*(wg_dist_sum/m0) + reg1 + reg2;
if (std::pow(xn_1 - cx,2) + std::pow(yn_1 - cy,2) < 0.1)
break;
if (m0==m0 && !std::isinf(m0) && m0 > 0){
cx = xn_1;
cy = yn_1;
h0 = 0.7*h0 + 0.3*h_tmp;
if (borderX > 5){
borderX /= 3;
borderY /= 3;
}
}else if (ii == 0){
//if in first iteration is m0 not valid => fail (maybe too fast movement)
// try to enlarge the search region
borderX = 3*borderX;
borderY = 3*borderY;
}
}
*scale = h0;
if (iter != NULL)
*iter = ii;
return cv::Point(cx, cy);
}
cv::Point ColorTracker::histMeanShiftAnisotropicScale(double x1, double y1, double x2, double y2, double * width, double * height)
{
int maxIter = 15;
double w2 = (x2-x1)/2.;
double h2 = (y2-y1)/2.;
double borderX = 5.;
double borderY = 5.;
double cx = x1 + w2;
double cy = y1 + h2;
double h0_1 = 1.;
double h0_2 = 1.;
double wh;
double hh;
Histogram y1hist;
int ii;
for (ii = 0; ii < maxIter; ++ii){
wh = w2*h0_1+borderX;
hh = h2*h0_2+borderY;
int rowMin = std::max(0, (int)(cy-hh));
int rowMax = std::min(im1.rows-1, (int)(cy+hh));
int colMin = std::max(0, (int)(cx-wh));
int colMax = std::min(im1.cols-1, (int)(cx+wh));
extractForegroundHistogram(colMin, rowMin, colMax, rowMax, y1hist);
double batta_q = y1hist.computeSimilarity(&q_orig_hist);
double batta_b = y1hist.computeSimilarity(&b_hist);
//MeanShift Vector
double m0 = 0, m1x = 0, m1y = 0;
double Swigdist_1 = 0, Swigdist_2 = 0;
double wk_sum = 0, Sbg = 0, Sfg = 0;
for(int i = rowMin; i < rowMax; i++){
const uchar* Mi1 = im1.ptr<uchar>(i);
const uchar* Mi2 = im2.ptr<uchar>(i);
const uchar* Mi3 = im3.ptr<uchar>(i);
double tmp_y = std::pow((cy-(float)i)/hh,2);
for(int j = colMin; j < colMax; j++){
double arg = std::pow((cx-(float)j)/wh,2) + tmp_y;
if (arg>1)
continue;
//likelihood weights
double wqi = sqrt(q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j])/y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
double wbi = sqrt(b_hist.getValue(Mi1[j], Mi2[j], Mi3[j])/y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]));
double w = std::max(wqi/batta_q - wbi/batta_b, 0.0);
double wg = w*(-kernelProfile_EpanechnikovDeriv(arg));
wk_sum += (w * kernelProfile_Epanechnikov(arg));
Swigdist_1 += wg*std::pow((cx-(float)j),2);
Swigdist_2 += wg*std::pow((cy-(float)i),2);
//likelihood
Sbg += (wqi < wbi) ? y1hist.getValue(Mi1[j], Mi2[j], Mi3[j]) : 0;
Sfg += q_orig_hist.getValue(Mi1[j], Mi2[j], Mi3[j]);
m0 += wg;
m1x += (j-cx)*wg;
m1y += (i-cy)*wg;
}
}
double a2 = std::pow(w2,2);
double b2 = std::pow(h2,2);
float mx = (h0_2/h0_1)*(m1x/m0);
float my = (h0_1/h0_2)*(m1y/m0);
double reg1 = (wAvgBg - Sbg/Sfg);
if (std::abs(reg1) > bound1)
reg1 = reg1 > 0 ? bound1 : -bound1;
double reg2_1 = -(log(h0_1));
if (std::abs(reg2_1) > bound2)
reg2_1 = reg2_1 > 0 ? bound2 : -bound2;
double reg2_2 = -(log(h0_2));
if (std::abs(reg2_2) > bound2)
reg2_2 = reg2_2 > 0 ? bound2 : -bound2;
double h_1 = h0_1 - (h0_2/2)*(wk_sum / m0) + (h0_2 / (h0_1 * h0_1 * a2)) * (Swigdist_1 / m0) + reg1 + reg2_1;
double h_2 = h0_2 - (h0_1/2)*(wk_sum / m0) + (h0_1 / (h0_2 * h0_2 * b2)) * (Swigdist_2 / m0) + reg1 + reg2_2;
if (std::pow(mx,2) + std::pow(my,2) < 0.1)
break;
if (m0==m0 && !std::isinf(m0) && m0 > 0){
cx = cx + mx;
cy = cy + my;
h0_1 = 0.7*h0_1 + 0.3*h_1;
h0_2 = 0.7*h0_2 + 0.3*h_2;
if (borderX > 5){
borderX /= 3;
borderY /= 3;
}
}else if (ii == 0){
//if in first iteration is m0 not valid => fail (maybe too fast movement)
// try to enlarge the search region
borderX = 3*borderX;
borderY = 3*borderY;
}
}
*width = 2*w2*h0_1;
*height = 2*h2*h0_2;
return cv::Point(cx, cy);
}
BBox * ColorTracker::track(cv::Mat & img, double x1, double y1, double x2, double y2)
{
double width = x2-x1;
double height = y2-y1;
im1_old = im1.clone();
im2_old = im2.clone();
im3_old = im3.clone();
preprocessImage(img);
//MS with scale estimation
double scale = 1;
int iter = 0;
cv::Point modeCenter = histMeanShiftIsotropicScale(x1, y1, x2, y2, &scale, &iter);
width = 0.7*width + 0.3*width*scale;
height = 0.7*height + 0.3*height*scale;
//MS with anisotropic scale estimation
// double scale = 1.;
// double new_width = 1., new_height = 1.;
// cv::Point modeCenter = histMeanShiftAnisotropicScale(x1, y1, x2, y2, &new_width, &new_height);
// width = new_width;
// height = new_height;
//Forward-Backward validation
if (std::abs(std::log(scale)) > 0.05){
cv::Mat tmp_im1 = im1;
cv::Mat tmp_im2 = im2;
cv::Mat tmp_im3 = im3;
im1 = im1_old;
im2 = im2_old;
im3 = im3_old;
double scaleB = 1;
histMeanShiftIsotropicScale(modeCenter.x - width/2, modeCenter.y - height/2, modeCenter.x + width/2, modeCenter.y + height/2, &scaleB);
im1 = tmp_im1;
im2 = tmp_im2;
im3 = tmp_im3;
if (std::abs(std::log(scale*scaleB)) > 0.1){
double alfa = 0.1*(defaultWidth/(float)(x2-x1));
width = (0.9 - alfa)*(x2-x1) + 0.1*(x2-x1)*scale + alfa*defaultWidth;
height = (0.9 - alfa)*(y2-y1) + 0.1*(y2-y1)*scale + alfa*defaultHeight;
}
}
BBox * retBB = new BBox();
retBB->setBBox(modeCenter.x - width/2, modeCenter.y - height/2, width, height, 1, 1);
lastPosition.setBBox(modeCenter.x - width/2, modeCenter.y - height/2, width, height, 1, 1);
frame++;
return retBB;
}
void ColorTracker::preprocessImage(cv::Mat &img)
{
cv::Mat ra[3] = {im1, im2, im3};
cv::split(img, ra);
}
void ColorTracker::extractBackgroundHistogram(int x1, int y1, int x2, int y2, Histogram & hist)
{
int offsetX = (x2-x1)/2;
int offsetY = (y2-y1)/2;
int rowMin = std::max(0, (int)(y1-offsetY));
int rowMax = std::min(im1.rows, (int)(y2+offsetY+1));
int colMin = std::max(0, (int)(x1-offsetX));
int colMax = std::min(im1.cols, (int)(x2+offsetX+1));
int numData = (rowMax-rowMin)*(colMax-colMin) - (y2-y1)*(x2-x1);
if (numData < 1)
numData = (rowMax-rowMin)*(colMax-colMin)/2 + 1;
std::vector<int> d1, d2, d3;
std::vector<double> weights;
d1.reserve(numData);
d2.reserve(numData);
d3.reserve(numData);
for (int y = rowMin; y < rowMax; ++y){
const uchar * M1 = im1.ptr<uchar>(y);
const uchar * M2 = im2.ptr<uchar>(y);
const uchar * M3 = im3.ptr<uchar>(y);
for (int x = colMin; x < colMax; ++x){
if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
continue;
d1.push_back(M1[x]);
d2.push_back(M2[x]);
d3.push_back(M3[x]);
}
}
hist.clear();
hist.insertValues(d1, d2, d3, weights);
}
void ColorTracker::extractForegroundHistogram(int x1, int y1, int x2, int y2, Histogram & hist)
{
hist.clear();
std::vector<int> data1;
std::vector<int> data2;
std::vector<int> data3;
std::vector<double> weights;
int numData = (y2-y1)*(x2-x1);
if (numData <= 0){
return;
}
data1.reserve(numData);
data2.reserve(numData);
data3.reserve(numData);
weights.reserve(numData);
double w2 = (x2-x1)/2;
double h2 = (y2-y1)/2;
double cx = x1 + w2;
double cy = y1 + h2;
double wh_i = 1.0/(w2*1.4142+1); //sqrt(2)
double hh_i = 1.0/(h2*1.4142+1);
for (int y = y1; y < y2+1; ++y){
const uchar * M1 = im1.ptr<uchar>(y);
const uchar * M2 = im2.ptr<uchar>(y);
const uchar * M3 = im3.ptr<uchar>(y);
double tmp_y = std::pow((cy-y)*hh_i,2);
for (int x = x1; x < x2+1; ++x){
data1.push_back(M1[x]);
data2.push_back(M2[x]);
data3.push_back(M3[x]);
weights.push_back(kernelProfile_Epanechnikov(std::pow((cx-x)*wh_i,2) + tmp_y));
}
}
hist.clear();
hist.insertValues(data1, data2, data3, weights);
}
| 31.46374
| 143
| 0.510827
|
yongheng1991
|
b053530e4184652fd53cba035bd19de4dbba1bbb
| 171
|
hpp
|
C++
|
include/DefaultConstructible.hpp
|
jharmer95/cpp_named_concepts
|
6cf81562f893b03baf365d5a9dc8b3f0f828fd1a
|
[
"CC0-1.0"
] | null | null | null |
include/DefaultConstructible.hpp
|
jharmer95/cpp_named_concepts
|
6cf81562f893b03baf365d5a9dc8b3f0f828fd1a
|
[
"CC0-1.0"
] | null | null | null |
include/DefaultConstructible.hpp
|
jharmer95/cpp_named_concepts
|
6cf81562f893b03baf365d5a9dc8b3f0f828fd1a
|
[
"CC0-1.0"
] | null | null | null |
#pragma once
#include <type_traits>
namespace concepts
{
template<typename T>
concept DefaultConstructible = std::is_default_constructible_v<T>;
} // namespace concepts
| 17.1
| 66
| 0.795322
|
jharmer95
|
b05567b443dac3a182659a082d26c6f3cf55f145
| 2,763
|
cpp
|
C++
|
app/src/main/jni/SourceFiles/Vertices.cpp
|
simonides/OpenGL_ES_Example
|
be193e2dcc5c308cc8341b27e0051b347878670a
|
[
"Apache-2.0"
] | null | null | null |
app/src/main/jni/SourceFiles/Vertices.cpp
|
simonides/OpenGL_ES_Example
|
be193e2dcc5c308cc8341b27e0051b347878670a
|
[
"Apache-2.0"
] | null | null | null |
app/src/main/jni/SourceFiles/Vertices.cpp
|
simonides/OpenGL_ES_Example
|
be193e2dcc5c308cc8341b27e0051b347878670a
|
[
"Apache-2.0"
] | null | null | null |
//
// Created by Simon on 15.04.2016.
//
#include "../HeaderFiles/Vertices.h"
const GLfloat cubeColoredVertex[] = {
// X y z u v r g b
//back
-1, -1, -1, 1.0f, 1.0f, 1.f, 0.f, 0.f,
+1, -1, -1, 0.0f, 1.0f, 1.f, 0.f, 0.f,
+1, +1, -1, 0.0f, 0.0f, 1.f, 0.f, 0.f,
-1, +1, -1, 1.0f, 0.0f, 1.f, 0.f, 0.f,
//right
+1, -1, -1, 1.0f, 1.0f, 0.f, 1.f, 0.f,
+1, -1, +1, 0.0f, 1.0f, 0.f, 1.f, 0.f,
+1, +1, +1, 0.0f, 0.0f, 0.f, 1.f, 0.f,
+1, +1, -1, 1.0f, 0.0f, 0.f, 1.f, 0.f,
//left
-1, -1, +1, 1.0f, 1.0f, 0.f, 0.f, 1.f,
-1, -1, -1, 0.0f, 1.0f, 0.f, 0.f, 1.f,
-1, +1, -1, 0.0f, 0.0f, 0.f, 0.f, 1.f,
-1, +1, +1, 1.0f, 0.0f, 0.f, 0.f, 1.f,
//front
+1, -1, +1, 1.0f, 1.0f, 0.f, 1.f, 1.f,
-1, -1, +1, 0.0f, 1.0f, 0.f, 1.f, 1.f,
-1, +1, +1, 0.0f, 0.0f, 0.f, 1.f, 1.f,
+1, +1, +1, 1.0f, 0.0f, 0.f, 1.f, 1.f,
//top
-1, +1, -1, 0.0f, 0.0f, 0.5f, 0.f, 0.5f,
+1, +1, -1, 1.0f, 0.0f, 0.5f, 0.f, 0.5f,
+1, +1, +1, 1.0f, 1.0f, 0.5f, 0.f, 0.5f,
-1, +1, +1, 0.0f, 1.0f, 0.5f, 0.f, 0.5f,
//bottom
-1, -1, -1, 0.0f, 1.0f, 0.7f, 0.3f, 0.3f,
+1, -1, +1, 1.0f, 0.0f, 0.7f, 0.3f, 0.3f,
+1, -1, -1, 1.0f, 1.0f, 0.7f, 0.3f, 0.3f,
-1, -1, +1, 0.0f, 0.0f, 0.7f, 0.3f, 0.3f,
//background
/*24*/ -1, +3, -1, 0.0f, 0.0f, 0.1f, 0.1f, 0.f,
/*25*/ -1, -1, -1, 0.0f, 2.0f, 0.1f, 0.1f, 0.f,
/*26*/ +3, -1, -1, 2.0f, 2.0f, 0.1f, 0.1f, 1.f,
//bird
/*27*/ -1, +3, -1, 0.0f, 1.2f, 0.1f, 0.1f, 0.f,
/*28*/ -1, -1, -1, 0.0f, 2.f, 0.1f, 0.1f, 0.f,
/*29*/ +3, -1, -1, 0.3f, 2.f, 0.1f, 0.1f, 1.f,
//bird2
/*30*/ -1, +3, -1, 0.333f, 1.2f, 0.1f, 0.1f, 0.f,
/*31*/ -1, -1, -1, 0.333f, 2.f, 0.1f, 0.1f, 0.f,
/*32*/ +3, -1, -1, 0.666f, 2.f, 0.1f, 0.1f, 1.f,
//bird3
/*33*/ -1, +3, -1, 0.666f, 1.2f, 0.1f, 0.1f, 0.f,
/*34*/ -1, -1, -1, 0.666f, 2.0f, 0.1f, 0.1f, 0.f,
/*35*/ +3, -1, -1, 0.999f, 2.0f, 0.1f, 0.1f, 1.f,
};
const GLuint cubeIndices[] = {
0, 2, 1, 0, 3, 2, // front 6
4, 6, 5, 4, 7, 6, // right 12
8, 10, 9, 8, 11, 10, // left 18
12, 14, 13, 12, 15, 14, // back 24
16, 18, 17, 16, 19, 18, // top 30
20, 22, 21, 20, 21, 23, // bottom 36
24, 25, 26, //background 39
27, 28, 29, //bird1 42
30, 31, 32, //bird2 45
33, 34, 35, //bird3 48
};
| 32.127907
| 55
| 0.336229
|
simonides
|
b056edf7320c15d9f6c5f0fdea9eaebbf41b03a7
| 422
|
cpp
|
C++
|
src/engine/sound.cpp
|
nekitu/shmup
|
2d2c24ff8a0fc363dbac261be52a6664d586a46a
|
[
"MIT"
] | 2
|
2019-03-05T13:10:14.000Z
|
2019-11-28T11:02:00.000Z
|
src/engine/sound.cpp
|
nekitu/shmup
|
2d2c24ff8a0fc363dbac261be52a6664d586a46a
|
[
"MIT"
] | 13
|
2020-02-05T10:08:45.000Z
|
2020-05-08T00:43:13.000Z
|
src/engine/sound.cpp
|
nekitu/shmup
|
2d2c24ff8a0fc363dbac261be52a6664d586a46a
|
[
"MIT"
] | null | null | null |
#include "sound.h"
#include <SDL_mixer.h>
#include "resources/sound_resource.h"
namespace engine
{
bool Sound::play(int loops)
{
if (!soundResource)
return false;
if (Mix_PlayChannel((int)channel, soundResource->wave, loops) == -1)
return false;
return true;
}
void Sound::stop()
{
Mix_HaltChannel((int)channel);
}
bool Sound::isPlaying()
{
return Mix_Playing((int)channel);
}
}
| 14.551724
| 70
| 0.656398
|
nekitu
|
b0585d4146358f7b86fc3ea99c932ecc4129e36a
| 260
|
cpp
|
C++
|
QCURL.cpp
|
quantumcheese/CFRaii
|
397b38ba5138cd3896ce4d9842918e7fb57e0198
|
[
"MIT"
] | 3
|
2015-01-05T00:57:03.000Z
|
2015-11-09T14:08:40.000Z
|
QCURL.cpp
|
quantumcheese/CFRaii
|
397b38ba5138cd3896ce4d9842918e7fb57e0198
|
[
"MIT"
] | null | null | null |
QCURL.cpp
|
quantumcheese/CFRaii
|
397b38ba5138cd3896ce4d9842918e7fb57e0198
|
[
"MIT"
] | null | null | null |
/*
* QCURL.cpp
* CFRaii
*
* Copyright (c) 2009-2010 Richard A. Brown
*
* See license.txt for licensing terms and conditions.
*/
#include "QCURL.h"
BEGIN_QC_NAMESPACE
void QCURL::show() const
{
#ifndef NDEBUG
CFShow(url);
#endif
}
END_QC_NAMESPACE
| 12.380952
| 54
| 0.688462
|
quantumcheese
|
b05febfd4ca05121787ac43ab391d49fbf37c5c5
| 11,066
|
cpp
|
C++
|
examples/DSP module plugin demo/Source/PluginProcessor.cpp
|
jpcima/DISTRHO-JUCE
|
08c983c6dc718b7bbdba8c0625d7a4ee2a837f4c
|
[
"ISC"
] | 1
|
2020-10-23T05:31:32.000Z
|
2020-10-23T05:31:32.000Z
|
examples/DSP module plugin demo/Source/PluginProcessor.cpp
|
pierreguillot/JUCE-LV2
|
b12aa69c81f496d07066a603b5320601aa93fcc0
|
[
"ISC"
] | null | null | null |
examples/DSP module plugin demo/Source/PluginProcessor.cpp
|
pierreguillot/JUCE-LV2
|
b12aa69c81f496d07066a603b5320601aa93fcc0
|
[
"ISC"
] | null | null | null |
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
27th April 2017).
End User License Agreement: www.juce.com/juce-5-licence
Privacy Policy: www.juce.com/juce-5-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
DspModulePluginDemoAudioProcessor::DspModulePluginDemoAudioProcessor()
: AudioProcessor (BusesProperties()
.withInput ("Input", AudioChannelSet::stereo(), true)
.withOutput ("Output", AudioChannelSet::stereo(), true)),
lowPassFilter (dsp::IIR::Coefficients<float>::makeFirstOrderLowPass (48000.0, 20000.f)),
highPassFilter (dsp::IIR::Coefficients<float>::makeFirstOrderHighPass (48000.0, 20.0f)),
waveShapers { {std::tanh}, {dsp::FastMathApproximations::tanh} },
clipping { clip }
{
// Oversampling 2 times with IIR filtering
oversampling = new dsp::Oversampling<float> (2, 1, dsp::Oversampling<float>::filterHalfBandPolyphaseIIR, false);
addParameter (inputVolumeParam = new AudioParameterFloat ("INPUT", "Input Volume", { 0.f, 60.f, 0.f, 1.0f }, 0.f, "dB"));
addParameter (highPassFilterFreqParam = new AudioParameterFloat ("HPFREQ", "Pre Highpass Freq.", { 20.f, 20000.f, 0.f, 0.5f }, 20.f, "Hz"));
addParameter (lowPassFilterFreqParam = new AudioParameterFloat ("LPFREQ", "Post Lowpass Freq.", { 20.f, 20000.f, 0.f, 0.5f }, 20000.f, "Hz"));
addParameter (stereoParam = new AudioParameterChoice ("STEREO", "Stereo Processing", { "Always mono", "Yes" }, 1));
addParameter (slopeParam = new AudioParameterChoice ("SLOPE", "Slope", { "-6 dB / octave", "-12 dB / octave" }, 0));
addParameter (waveshaperParam = new AudioParameterChoice ("WVSHP", "Waveshaper", { "std::tanh", "Fast tanh approx." }, 0));
addParameter (cabinetTypeParam = new AudioParameterChoice ("CABTYPE", "Cabinet Type", { "Guitar amplifier 8'' cabinet ",
"Cassette recorder cabinet" }, 0));
addParameter (cabinetSimParam = new AudioParameterBool ("CABSIM", "Cabinet Sim", false));
addParameter (oversamplingParam = new AudioParameterBool ("OVERS", "Oversampling", false));
addParameter (outputVolumeParam = new AudioParameterFloat ("OUTPUT", "Output Volume", { -40.f, 40.f, 0.f, 1.0f }, 0.f, "dB"));
cabinetType.set (0);
}
DspModulePluginDemoAudioProcessor::~DspModulePluginDemoAudioProcessor()
{
}
//==============================================================================
bool DspModulePluginDemoAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
return true;
}
void DspModulePluginDemoAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
auto channels = static_cast<uint32> (jmin (getMainBusNumInputChannels(), getMainBusNumOutputChannels()));
dsp::ProcessSpec spec { sampleRate, static_cast<uint32> (samplesPerBlock), channels };
lowPassFilter.prepare (spec);
highPassFilter.prepare (spec);
inputVolume.prepare (spec);
outputVolume.prepare (spec);
convolution.prepare (spec);
cabinetType.set (-1);
oversampling->initProcessing (static_cast<size_t> (samplesPerBlock));
updateParameters();
reset();
}
void DspModulePluginDemoAudioProcessor::reset()
{
lowPassFilter.reset();
highPassFilter.reset();
convolution.reset();
oversampling->reset();
}
void DspModulePluginDemoAudioProcessor::releaseResources()
{
}
void DspModulePluginDemoAudioProcessor::process (dsp::ProcessContextReplacing<float> context) noexcept
{
ScopedNoDenormals noDenormals;
// Input volume applied with a LinearSmoothedValue
inputVolume.process (context);
// Pre-highpass filtering, very useful for distortion audio effects
// Note : try frequencies around 700 Hz
highPassFilter.process (context);
// Upsampling
dsp::AudioBlock<float> oversampledBlock;
setLatencySamples (audioCurrentlyOversampled ? roundFloatToInt (oversampling->getLatencyInSamples()) : 0);
if (audioCurrentlyOversampled)
oversampledBlock = oversampling->processSamplesUp (context.getInputBlock());
dsp::ProcessContextReplacing<float> waveshaperContext = audioCurrentlyOversampled ? dsp::ProcessContextReplacing<float> (oversampledBlock) : context;
// Waveshaper processing, for distortion generation, thanks to the input gain
// The fast tanh can be used instead of std::tanh to reduce the CPU load
auto waveshaperIndex = waveshaperParam->getIndex();
if (isPositiveAndBelow (waveshaperIndex, numWaveShapers) )
{
waveShapers[waveshaperIndex].process (waveshaperContext);
if (waveshaperIndex == 1)
clipping.process (waveshaperContext);
waveshaperContext.getOutputBlock() *= 0.7f;
}
// Downsampling
if (audioCurrentlyOversampled)
oversampling->processSamplesDown (context.getOutputBlock());
// Post-lowpass filtering
lowPassFilter.process (context);
// Convolution with the impulse response of a guitar cabinet
auto wasBypassed = context.isBypassed;
context.isBypassed = context.isBypassed || cabinetIsBypassed;
convolution.process (context);
context.isBypassed = wasBypassed;
// Output volume applied with a LinearSmoothedValue
outputVolume.process (context);
}
void DspModulePluginDemoAudioProcessor::processBlock (AudioSampleBuffer& inoutBuffer, MidiBuffer&)
{
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
auto numSamples = inoutBuffer.getNumSamples();
for (auto i = jmin (2, totalNumInputChannels); i < totalNumOutputChannels; ++i)
inoutBuffer.clear (i, 0, numSamples);
updateParameters();
dsp::AudioBlock<float> block (inoutBuffer);
if (stereoParam->getIndex() == 1)
{
// Stereo processing mode:
if (block.getNumChannels() > 2)
block = block.getSubsetChannelBlock (0, 2);
process (dsp::ProcessContextReplacing<float> (block));
}
else
{
// Mono processing mode:
auto firstChan = block.getSingleChannelBlock (0);
process (dsp::ProcessContextReplacing<float> (firstChan));
for (size_t chan = 1; chan < block.getNumChannels(); ++chan)
block.getSingleChannelBlock (chan).copy (firstChan);
}
}
//==============================================================================
bool DspModulePluginDemoAudioProcessor::hasEditor() const
{
return true;
}
AudioProcessorEditor* DspModulePluginDemoAudioProcessor::createEditor()
{
return new DspModulePluginDemoAudioProcessorEditor (*this);
}
//==============================================================================
bool DspModulePluginDemoAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool DspModulePluginDemoAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
//==============================================================================
void DspModulePluginDemoAudioProcessor::updateParameters()
{
auto newOversampling = oversamplingParam->get();
if (newOversampling != audioCurrentlyOversampled)
{
audioCurrentlyOversampled = newOversampling;
oversampling->reset();
}
//==============================================================================
auto inputdB = Decibels::decibelsToGain (inputVolumeParam->get());
auto outputdB = Decibels::decibelsToGain (outputVolumeParam->get());
if (inputVolume.getGainLinear() != inputdB) inputVolume.setGainLinear (inputdB);
if (outputVolume.getGainLinear() != outputdB) outputVolume.setGainLinear (outputdB);
auto newSlopeType = slopeParam->getIndex();
if (newSlopeType == 0)
{
*lowPassFilter.state = *dsp::IIR::Coefficients<float>::makeFirstOrderLowPass (getSampleRate(), lowPassFilterFreqParam->get());
*highPassFilter.state = *dsp::IIR::Coefficients<float>::makeFirstOrderHighPass (getSampleRate(), highPassFilterFreqParam->get());
}
else
{
*lowPassFilter.state = *dsp::IIR::Coefficients<float>::makeLowPass (getSampleRate(), lowPassFilterFreqParam->get());
*highPassFilter.state = *dsp::IIR::Coefficients<float>::makeHighPass (getSampleRate(), highPassFilterFreqParam->get());
}
//==============================================================================
auto type = cabinetTypeParam->getIndex();
auto currentType = cabinetType.get();
if (type != currentType)
{
cabinetType.set(type);
auto maxSize = static_cast<size_t> (roundDoubleToInt (8192 * getSampleRate() / 44100));
if (type == 0)
convolution.loadImpulseResponse (BinaryData::Impulse1_wav, BinaryData::Impulse1_wavSize, false, true, maxSize);
else
convolution.loadImpulseResponse (BinaryData::Impulse2_wav, BinaryData::Impulse2_wavSize, false, true, maxSize);
}
cabinetIsBypassed = ! cabinetSimParam->get();
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new DspModulePluginDemoAudioProcessor();
}
| 38.557491
| 154
| 0.624345
|
jpcima
|
b064449e68eee31da68fc94e8f901c7a360f2ec0
| 3,049
|
cpp
|
C++
|
Necromancer/Necromancer.cpp
|
myffx36/RenderingEngine
|
38df29966b3126744fb40c2a97775ae44cea92f9
|
[
"MIT"
] | null | null | null |
Necromancer/Necromancer.cpp
|
myffx36/RenderingEngine
|
38df29966b3126744fb40c2a97775ae44cea92f9
|
[
"MIT"
] | null | null | null |
Necromancer/Necromancer.cpp
|
myffx36/RenderingEngine
|
38df29966b3126744fb40c2a97775ae44cea92f9
|
[
"MIT"
] | null | null | null |
#include "stdafx.h"
#include "Necromancer.h"
#include "PIL.h"
#include "RenderingEngine.h"
#include "PhysicsEngine.h"
#include "AnimationEngine.h"
#include "GameWorld.h"
#include "HID.h"
//#include "ScriptInterpreter.h"
#include "Timer.h"
#include "Logger.h"
#include "Configuration.h"
#include "PILFactory.h"
namespace Necromancer{
Necromancer* Necromancer::s_instance = nullptr;
Necromancer::Necromancer(Configuration* config){
PILFactory* pil_factory = new PILFactory();
m_pil = pil_factory->create_pil(config);
m_rendering_engine = new RenderingEngine(config, m_pil);
m_animation_engine = new AnimationEngine(config);
m_physics_engine = new PhysicsEngine(config);
m_hid = new HID(config, m_pil);
//m_script_interpreter = new ScriptInterpreter(config);
m_game_world = new GameWorld();
m_logger = new Logger();
m_is_end = false;
if(nullptr == s_instance){
s_instance = this;
}else{
delete s_instance;
s_instance = this;
}
m_timer = new Timer();
}
Necromancer::~Necromancer(){
delete m_game_world;
//delete m_script_interpreter;
delete m_hid;
delete m_physics_engine;
delete m_animation_engine;
delete m_rendering_engine;
delete m_pil;
}
Necromancer* Necromancer::get_instance(){
return s_instance;
}
void Necromancer::process_a_frame(){
wait_some_time();
F32 dlt_time = m_timer->get_dlt_time();
m_hid->process_input_event();
m_animation_engine->update(dlt_time);
m_physics_engine->update(dlt_time);
m_game_world->update();
m_rendering_engine->draw_scene();
}
void Necromancer::main_loop(){
m_hid->begin();
m_rendering_engine->begin();
//m_pil->begin();
/*auto window = m_pil->pil_window();
while(!m_is_end){
if(window->handle_window_message()){
process_a_frame();
}
}*/
m_pil->wait_for_end();
m_hid->wait_for_end();
m_rendering_engine->wait_for_end();
}
void Necromancer::end(){
m_hid->send_end_message();
m_pil->send_end_message();
m_rendering_engine->send_end_message();
m_is_end = true;
}
void Necromancer::wait_some_time(){
const U32 min_frame_time = 10;
static U32 last_update_time = 0;
if(last_update_time != 0){
U32 current = m_timer->get_now();
U32 dlt = current - last_update_time;
while(dlt < min_frame_time){
std::this_thread::sleep_for(std::chrono::milliseconds(1));
current = m_timer->get_now();
dlt = current - last_update_time;
}
}
last_update_time = m_timer->get_now();
}
U32 Necromancer::attach_game_object(const GameObjectPtr& game_object){
m_rendering_engine->attach_sub_scene(game_object->sub_scene());
if(game_object->physics_object()){
//m_physics_engine->attach_physics_object(
// game_object->physics_object());
}
return m_game_world->attach_game_object(game_object);
}
void Necromancer::detach_game_object(const GameObjectPtr& game_object){
m_rendering_engine->detach_sub_scene(game_object->sub_scene());
if (game_object->physics_object()){
/*m_physics_engine->detach_physics_object(
game_object->physics_object());*/
}
}
}
| 25.198347
| 72
| 0.725156
|
myffx36
|
b06c67a001e98f5124c2f0acdecba1d20b8f06ef
| 2,546
|
cpp
|
C++
|
Builder/main.cpp
|
dominhhai/CppDesignPatterns
|
61d218f26ef00533346b2db31694eb8470f83358
|
[
"MIT"
] | 3
|
2018-10-25T06:49:40.000Z
|
2018-10-26T03:47:00.000Z
|
Builder/main.cpp
|
dominhhai/CppDesignPatterns
|
61d218f26ef00533346b2db31694eb8470f83358
|
[
"MIT"
] | 1
|
2018-10-26T03:46:50.000Z
|
2018-10-26T03:46:50.000Z
|
Builder/main.cpp
|
dominhhai/CppDesignPatterns
|
61d218f26ef00533346b2db31694eb8470f83358
|
[
"MIT"
] | 1
|
2020-05-19T03:15:19.000Z
|
2020-05-19T03:15:19.000Z
|
#include <iostream>
#include <memory>
#include <string>
#include <vector>
class Packing {
public:
virtual std::string Pack() = 0;
};
class Item {
public:
virtual std::string Name() = 0;
virtual Packing* DoPacking() = 0;
virtual float Price() = 0;
};
class Wrapper : public Packing {
public:
std::string Pack() { return "Wrapper"; }
};
class Bottle : public Packing {
public:
std::string Pack() { return "Bottle"; }
};
class Burger : public Item {
public:
Packing* DoPacking() { return new Wrapper(); }
};
class ColdDrink : public Item {
public:
Packing* DoPacking() { return new Bottle(); }
};
class VegBurger : public Burger {
public:
std::string Name() { return "VegBurger"; }
float Price() { return 10; }
};
class ChickenBurger : public Burger {
public:
std::string Name() { return "ChickenBurger"; }
float Price() { return 12; }
};
class Pepsi : public ColdDrink {
public:
std::string Name() { return "Pepsi"; }
float Price() { return 13; }
};
class Coke : public ColdDrink {
public:
std::string Name() { return "Coke"; }
float Price() { return 14; }
};
class Meal {
public:
void AddItem(Item* item) {
this->items_.push_back(std::unique_ptr<Item>(item));
}
float GetCost() {
float cost = 0;
for (auto& item : this->items_) {
cost += item->Price();
}
return cost;
}
void ShowItems() {
for (auto& item : this->items_) {
std::cout << "Item: " << item->Name()
<< ", Packing: " << item->DoPacking()->Pack()
<< ", Price: " << item->Price() << std::endl;
}
}
private:
std::vector<std::unique_ptr<Item>> items_;
};
class MealBuilder {
public:
static Meal* PreapreVegMeal() {
Meal* meal = new Meal();
meal->AddItem(new VegBurger());
meal->AddItem(new Coke());
return meal;
}
static Meal* PreapreNonVegMeal() {
Meal* meal = new Meal();
meal->AddItem(new ChickenBurger());
meal->AddItem(new Pepsi());
return meal;
}
};
int main(int argc, char const* argv[]) {
std::unique_ptr<Meal> vegMeal =
std::unique_ptr<Meal>(MealBuilder::PreapreVegMeal());
std::cout << "Veg Meal" << std::endl;
vegMeal->ShowItems();
std::cout << "Total Cost: " << vegMeal->GetCost() << std::endl;
vegMeal.reset();
std::unique_ptr<Meal> nonVegMeal =
std::unique_ptr<Meal>(MealBuilder::PreapreNonVegMeal());
std::cout << "Non-Veg Meal" << std::endl;
nonVegMeal->ShowItems();
std::cout << "Total Cost: " << nonVegMeal->GetCost() << std::endl;
return 0;
}
| 20.047244
| 68
| 0.604478
|
dominhhai
|
b0705e3ffe0a9c79cf8b59ba34df7016acc3552d
| 505
|
cpp
|
C++
|
SimCore/model/Ecu/Ecu.cpp
|
kino-6/BuiltInSystemSimulator
|
63d447f89c0c9166b93a96844d2d103f9d00a4b2
|
[
"Apache-2.0"
] | null | null | null |
SimCore/model/Ecu/Ecu.cpp
|
kino-6/BuiltInSystemSimulator
|
63d447f89c0c9166b93a96844d2d103f9d00a4b2
|
[
"Apache-2.0"
] | null | null | null |
SimCore/model/Ecu/Ecu.cpp
|
kino-6/BuiltInSystemSimulator
|
63d447f89c0c9166b93a96844d2d103f9d00a4b2
|
[
"Apache-2.0"
] | null | null | null |
#include "Ecu.h"
Ecu::Ecu(void){
this->Reset();
}
Ecu::~Ecu(void) {
}
void Ecu::Main() {
this->timer->Main();
this->task->Main(this->timer);
this->chip->Main();
this->power->Main();
}
void Ecu::Reset(){
this->timer = new Timer();
this->task = new Task();
this->chip = new Chip();
this->power = new Power();
// timer
this->timer->Reset();
// task
this->task->Reset();
// chip
this->chip->Reset();
// power
this->power->Reset();
}
| 14.428571
| 34
| 0.510891
|
kino-6
|
b071dad3d818b885f1f2af6b7f4a5bb31d8c4de1
| 7,413
|
hpp
|
C++
|
src/batteries/assert.hpp
|
tonyastolfi/batteries
|
67349930e54785f44eab84f1e56da6c78c66a5f9
|
[
"Apache-2.0"
] | 1
|
2022-01-04T20:28:17.000Z
|
2022-01-04T20:28:17.000Z
|
src/batteries/assert.hpp
|
mihir-thakkar/batteries
|
67349930e54785f44eab84f1e56da6c78c66a5f9
|
[
"Apache-2.0"
] | 2
|
2020-06-04T14:02:24.000Z
|
2020-06-04T14:03:18.000Z
|
src/batteries/assert.hpp
|
mihir-thakkar/batteries
|
67349930e54785f44eab84f1e56da6c78c66a5f9
|
[
"Apache-2.0"
] | 1
|
2022-01-03T20:24:31.000Z
|
2022-01-03T20:24:31.000Z
|
// Copyright 2021-2022 Anthony Paul Astolfi
//
#pragma once
#ifdef BOOST_STACKTRACE_USE_NOOP
#undef BOOST_STACKTRACE_USE_NOOP
#endif // BOOST_STACKTRACE_USE_NOOP
#include <batteries/config.hpp>
#include <batteries/hint.hpp>
#include <batteries/int_types.hpp>
#include <batteries/type_traits.hpp>
#include <batteries/utility.hpp>
#include <boost/stacktrace.hpp>
#include <iomanip>
#include <iostream>
#include <mutex>
#include <sstream>
#ifdef BATT_FAIL_CHECK_OUT
#error This macro is deprecated; use BATT_GLOG_AVAILABLE
#endif
#ifdef BATT_GLOG_AVAILABLE
#include <glog/logging.h>
#define BATT_FAIL_CHECK_OUT LOG(ERROR)
#else
#define BATT_FAIL_CHECK_OUT std::cerr
#endif
namespace batt {
template <typename T, typename = std::enable_if_t<IsPrintable<T>{}>>
decltype(auto) make_printable(T&& obj)
{
return BATT_FORWARD(obj);
}
template <typename T, typename = std::enable_if_t<!IsPrintable<T>{}>, typename = void>
std::string make_printable(T&& obj)
{
std::ostringstream oss;
oss << "(" << name_of<T>() << ") " << std::hex << std::setw(2) << std::setfill('0');
for (const u8* bytes = (const u8*)&obj; bytes != (const u8*)((&obj) + 1); ++bytes) {
oss << (int)*bytes;
}
return oss.str();
}
// =============================================================================
// ASSERT and CHECK macros with ostream-style message appending, stack trace on
// failure, branch prediction hinting, and human-friendly messages.
//
// BATT_ASSERT* statements are only enabled when NDEBUG is not defined.
// BATT_CHECK* statements are always enabled.
//
#define BATT_FAIL_CHECK_MESSAGE(left_str, left_val, op_str, right_str, right_val, file, line, fn_name) \
BATT_FAIL_CHECK_OUT << "FATAL: " << file << ":" << line << ": Assertion failed: " << left_str << " " \
<< op_str << " " << right_str << "\n (in `" << fn_name << "`)\n\n" \
<< " " << left_str << " == " << ::batt::make_printable(left_val) << ::std::endl \
<< ::std::endl \
<< " " << right_str << " == " << ::batt::make_printable(right_val) << ::std::endl \
<< ::std::endl
#ifdef __GNUC__
#define BATT_NORETURN __attribute__((noreturn))
#define BATT_UNREACHABLE __builtin_unreachable
#else
#define BATT_NORETURN
#define BATT_UNREACHABLE() (void)
#endif
BATT_NORETURN inline void fail_check_exit()
{
BATT_FAIL_CHECK_OUT << std::endl << std::endl; // << boost::stacktrace::stacktrace{} << std::endl;
std::abort();
BATT_UNREACHABLE();
}
template <typename... Ts>
inline bool ignore(Ts&&...)
{
return false;
}
inline bool lock_fail_check_mutex()
{
static std::mutex m;
m.lock();
return false;
}
#define BATT_CHECK_RELATION(left, op, right) \
for (; !BATT_HINT_TRUE(((left)op(right)) || ::batt::lock_fail_check_mutex()); ::batt::fail_check_exit()) \
BATT_FAIL_CHECK_MESSAGE(#left, (left), #op, #right, (right), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define BATT_CHECK_IMPLIES(p, q) \
for (; !BATT_HINT_TRUE(!(p) || (q)); ::batt::fail_check_exit()) \
BATT_FAIL_CHECK_MESSAGE(#p, (p), "implies", #q, (q), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define BATT_CHECK(x) BATT_CHECK_RELATION(bool{x}, ==, true)
#define BATT_CHECK_EQ(x, y) BATT_CHECK_RELATION(x, ==, y)
#define BATT_CHECK_NE(x, y) BATT_CHECK_RELATION(x, !=, y)
#define BATT_CHECK_GE(x, y) BATT_CHECK_RELATION(x, >=, y)
#define BATT_CHECK_GT(x, y) BATT_CHECK_RELATION(x, >, y)
#define BATT_CHECK_LE(x, y) BATT_CHECK_RELATION(x, <=, y)
#define BATT_CHECK_LT(x, y) BATT_CHECK_RELATION(x, <, y)
#define BATT_CHECK_FAIL() BATT_CHECK(false)
#define BATT_CHECK_IN_RANGE(low, x, high) \
[&](auto&& Actual_Value) { \
BATT_CHECK_LE(low, Actual_Value) \
<< "Expression " << #x << " == " << Actual_Value << " is out-of-range"; \
BATT_CHECK_LT(Actual_Value, high) \
<< "Expression " << #x << " == " << Actual_Value << " is out-of-range"; \
}(x)
#define BATT_ASSERT_DISABLED(ignored_inputs) \
if (false && ignored_inputs) \
BATT_FAIL_CHECK_OUT << ""
#ifndef NDEBUG //==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
#define BATT_ASSERT(x) BATT_CHECK(x)
#define BATT_ASSERT_EQ(x, y) BATT_CHECK_EQ(x, y)
#define BATT_ASSERT_NE(x, y) BATT_CHECK_NE(x, y)
#define BATT_ASSERT_GE(x, y) BATT_CHECK_GE(x, y)
#define BATT_ASSERT_GT(x, y) BATT_CHECK_GT(x, y)
#define BATT_ASSERT_LE(x, y) BATT_CHECK_LE(x, y)
#define BATT_ASSERT_LT(x, y) BATT_CHECK_LT(x, y)
#define BATT_ASSERT_IMPLIES(p, q) BATT_CHECK_IMPLIES(p, q)
#define BATT_ASSERT_IN_RANGE(low, x, high) BATT_CHECK_IN_RANGE(low, x, high)
#else // NDEBUG ==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
#define BATT_ASSERT(x) BATT_ASSERT_DISABLED(::batt::ignore((x)))
#define BATT_ASSERT_EQ(x, y) BATT_ASSERT_DISABLED(::batt::ignore((x), (y), (x) == (y)))
#define BATT_ASSERT_NE(x, y) BATT_ASSERT_DISABLED(::batt::ignore((x), (y), (x) != (y)))
#define BATT_ASSERT_GE(x, y) BATT_ASSERT_DISABLED(::batt::ignore((x), (y), (x) >= (y)))
#define BATT_ASSERT_GT(x, y) BATT_ASSERT_DISABLED(::batt::ignore((x), (y), (x) > (y)))
#define BATT_ASSERT_LE(x, y) BATT_ASSERT_DISABLED(::batt::ignore((x), (y), (x) <= (y)))
#define BATT_ASSERT_LT(x, y) BATT_ASSERT_DISABLED(::batt::ignore((x), (y), (x) < (y)))
#define BATT_ASSERT_IMPLIES(p, q) BATT_ASSERT_DISABLED(::batt::ignore((p), (q), !(p), bool(q)))
#define BATT_ASSERT_IN_RANGE(low, x, high) \
BATT_ASSERT_DISABLED(::batt::ignore((low), (x), (high), (low) <= (x), (x) < (high)))
#endif // NDEBUG ==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
#define BATT_ASSERT_NOT_NULLPTR(x) BATT_ASSERT(x != nullptr)
#define BATT_CHECK_NOT_NULLPTR(x) BATT_CHECK(x != nullptr)
#define BATT_PANIC() \
for (bool one_time = true; one_time; one_time = false, ::batt::fail_check_exit(), BATT_UNREACHABLE()) \
BATT_FAIL_CHECK_OUT << "*** PANIC *** At:" << __FILE__ << ":" << __LINE__ << ":" << std::endl
//=#=#==#==#===============+=+=+=+=++=++++++++++++++-++-+--+-+----+---------------
// BATT_INSPECT(expr) : expand to debug-friendly stream insertion expression.
// TODO [tastolfi 2021-10-20] Update docs for assert.hpp to include BATT_INSPECT
//
#define BATT_INSPECT(expr) " " << #expr << " == " << (expr)
#define BATT_UNTESTED_LINE() BATT_PANIC() << "Add test point!"
#define BATT_UNTESTED_COND(x) BATT_CHECK(!(x)) << "Add test point!"
} // namespace batt
#include <batteries/segv.hpp>
| 43.605882
| 110
| 0.550924
|
tonyastolfi
|
b07e4c0ebd57d3040c30631fb447f6fca731fb41
| 102,088
|
cpp
|
C++
|
I want to go/Library/Il2cppBuildCache/WebGL/il2cppOutput/Il2CppCCalculateFieldValues1.cpp
|
Bithellio/IWantToGo
|
966c8b941c386827f78e37d514b5ae4155ab3037
|
[
"Apache-2.0"
] | null | null | null |
I want to go/Library/Il2cppBuildCache/WebGL/il2cppOutput/Il2CppCCalculateFieldValues1.cpp
|
Bithellio/IWantToGo
|
966c8b941c386827f78e37d514b5ae4155ab3037
|
[
"Apache-2.0"
] | null | null | null |
I want to go/Library/Il2cppBuildCache/WebGL/il2cppOutput/Il2CppCCalculateFieldValues1.cpp
|
Bithellio/IWantToGo
|
966c8b941c386827f78e37d514b5ae4155ab3037
|
[
"Apache-2.0"
] | null | null | null |
#include "pch-cpp.hpp"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include <limits>
// System.Collections.Generic.List`1<ResolutionItem>
struct List_1_tFCF114D2CBC4A3284C0B982FF61972A503FD5775;
// System.Collections.Generic.List`1<UnityEngine.U2D.IK.Solver2D>
struct List_1_t5AD9FC44D7FFD5B7D3AE07112E73513D3F17C479;
// System.Collections.Generic.List`1<UnityEngine.Vector3>
struct List_1_t577D28CFF6DFE3F6A8D4409F7A21CBF513C04181;
// UnityEngine.AudioSource[]
struct AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B;
// System.Int32[]
struct Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32;
// UnityEngine.Quaternion[]
struct QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6;
// System.Single[]
struct SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA;
// UnityEngine.Transform[]
struct TransformU5BU5D_t7821C0520CC567C0A069329C01AE9C058C7E3F1D;
// UnityEngine.Vector2[]
struct Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA;
// UnityEngine.Vector3[]
struct Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4;
// UnityEngine.AudioClip
struct AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE;
// AudioManager
struct AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148;
// AudioSaveData
struct AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E;
// UnityEngine.AudioSource
struct AudioSource_tC4BF65AF8CDCAA63724BB3CA59A7A29249269E6B;
// UnityEngine.GameObject
struct GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319;
// UnityEngine.U2D.IK.IKChain2D
struct IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F;
// UnityEngine.UI.InputField
struct InputField_tB41A2814F31A3E9373D443EDEBBB2856006324D0;
// LevelManager
struct LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064;
// PlayerController
struct PlayerController_tA5C601ED4895A6E5C5EBBD22B8A3BBAFF9AF914D;
// UnityEngine.Rigidbody2D
struct Rigidbody2D_tD23204FEE9CB4A36737043B97FD409DE05D5DCE5;
// UnityEngine.UI.Slider
struct Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A;
// System.String
struct String_t;
// UnityEngine.UI.Text
struct Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1;
// UnityEngine.UI.Toggle
struct Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E;
// UnityEngine.Transform
struct Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1;
// System.Void
struct Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5;
struct Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ;
struct Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ;
IL2CPP_EXTERN_C_BEGIN
IL2CPP_EXTERN_C_END
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// <Module>
struct U3CModuleU3E_tFDCAFCBB4B3431CFF2DC4D3E03FBFDF54EFF7E9A
{
public:
public:
};
// <Module>
struct U3CModuleU3E_tFBE0E8DF4D6C3594CE300379B4D8B9122035F720
{
public:
public:
};
// <Module>
struct U3CModuleU3E_tE7281C0E269ACF224AB82F00FE8D46ED8C621032
{
public:
public:
};
// System.Object
// System.Attribute
struct Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71 : public RuntimeObject
{
public:
public:
};
// AudioSaveData
struct AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E : public RuntimeObject
{
public:
// System.Single AudioSaveData::musicVol
float ___musicVol_0;
// System.Single AudioSaveData::sfxVol
float ___sfxVol_1;
// System.Single AudioSaveData::uiVol
float ___uiVol_2;
public:
inline static int32_t get_offset_of_musicVol_0() { return static_cast<int32_t>(offsetof(AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E, ___musicVol_0)); }
inline float get_musicVol_0() const { return ___musicVol_0; }
inline float* get_address_of_musicVol_0() { return &___musicVol_0; }
inline void set_musicVol_0(float value)
{
___musicVol_0 = value;
}
inline static int32_t get_offset_of_sfxVol_1() { return static_cast<int32_t>(offsetof(AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E, ___sfxVol_1)); }
inline float get_sfxVol_1() const { return ___sfxVol_1; }
inline float* get_address_of_sfxVol_1() { return &___sfxVol_1; }
inline void set_sfxVol_1(float value)
{
___sfxVol_1 = value;
}
inline static int32_t get_offset_of_uiVol_2() { return static_cast<int32_t>(offsetof(AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E, ___uiVol_2)); }
inline float get_uiVol_2() const { return ___uiVol_2; }
inline float* get_address_of_uiVol_2() { return &___uiVol_2; }
inline void set_uiVol_2(float value)
{
___uiVol_2 = value;
}
};
// UnityEngine.U2D.IK.CCD2D
struct CCD2D_t82258235ABC03D19A07071991914A356C19C1BE3 : public RuntimeObject
{
public:
public:
};
// UnityEngine.U2D.IK.FABRIK2D
struct FABRIK2D_t3BDEA4B0728B4692A5B64CD6F09E71D3097CE6D7 : public RuntimeObject
{
public:
public:
};
// UnityEngine.U2D.IK.IKChain2D
struct IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F : public RuntimeObject
{
public:
// UnityEngine.Transform UnityEngine.U2D.IK.IKChain2D::m_EffectorTransform
Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * ___m_EffectorTransform_0;
// UnityEngine.Transform UnityEngine.U2D.IK.IKChain2D::m_TargetTransform
Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * ___m_TargetTransform_1;
// System.Int32 UnityEngine.U2D.IK.IKChain2D::m_TransformCount
int32_t ___m_TransformCount_2;
// UnityEngine.Transform[] UnityEngine.U2D.IK.IKChain2D::m_Transforms
TransformU5BU5D_t7821C0520CC567C0A069329C01AE9C058C7E3F1D* ___m_Transforms_3;
// UnityEngine.Quaternion[] UnityEngine.U2D.IK.IKChain2D::m_DefaultLocalRotations
QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6* ___m_DefaultLocalRotations_4;
// UnityEngine.Quaternion[] UnityEngine.U2D.IK.IKChain2D::m_StoredLocalRotations
QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6* ___m_StoredLocalRotations_5;
// System.Single[] UnityEngine.U2D.IK.IKChain2D::m_Lengths
SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* ___m_Lengths_6;
public:
inline static int32_t get_offset_of_m_EffectorTransform_0() { return static_cast<int32_t>(offsetof(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F, ___m_EffectorTransform_0)); }
inline Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * get_m_EffectorTransform_0() const { return ___m_EffectorTransform_0; }
inline Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 ** get_address_of_m_EffectorTransform_0() { return &___m_EffectorTransform_0; }
inline void set_m_EffectorTransform_0(Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * value)
{
___m_EffectorTransform_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_EffectorTransform_0), (void*)value);
}
inline static int32_t get_offset_of_m_TargetTransform_1() { return static_cast<int32_t>(offsetof(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F, ___m_TargetTransform_1)); }
inline Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * get_m_TargetTransform_1() const { return ___m_TargetTransform_1; }
inline Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 ** get_address_of_m_TargetTransform_1() { return &___m_TargetTransform_1; }
inline void set_m_TargetTransform_1(Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * value)
{
___m_TargetTransform_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_TargetTransform_1), (void*)value);
}
inline static int32_t get_offset_of_m_TransformCount_2() { return static_cast<int32_t>(offsetof(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F, ___m_TransformCount_2)); }
inline int32_t get_m_TransformCount_2() const { return ___m_TransformCount_2; }
inline int32_t* get_address_of_m_TransformCount_2() { return &___m_TransformCount_2; }
inline void set_m_TransformCount_2(int32_t value)
{
___m_TransformCount_2 = value;
}
inline static int32_t get_offset_of_m_Transforms_3() { return static_cast<int32_t>(offsetof(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F, ___m_Transforms_3)); }
inline TransformU5BU5D_t7821C0520CC567C0A069329C01AE9C058C7E3F1D* get_m_Transforms_3() const { return ___m_Transforms_3; }
inline TransformU5BU5D_t7821C0520CC567C0A069329C01AE9C058C7E3F1D** get_address_of_m_Transforms_3() { return &___m_Transforms_3; }
inline void set_m_Transforms_3(TransformU5BU5D_t7821C0520CC567C0A069329C01AE9C058C7E3F1D* value)
{
___m_Transforms_3 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Transforms_3), (void*)value);
}
inline static int32_t get_offset_of_m_DefaultLocalRotations_4() { return static_cast<int32_t>(offsetof(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F, ___m_DefaultLocalRotations_4)); }
inline QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6* get_m_DefaultLocalRotations_4() const { return ___m_DefaultLocalRotations_4; }
inline QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6** get_address_of_m_DefaultLocalRotations_4() { return &___m_DefaultLocalRotations_4; }
inline void set_m_DefaultLocalRotations_4(QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6* value)
{
___m_DefaultLocalRotations_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_DefaultLocalRotations_4), (void*)value);
}
inline static int32_t get_offset_of_m_StoredLocalRotations_5() { return static_cast<int32_t>(offsetof(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F, ___m_StoredLocalRotations_5)); }
inline QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6* get_m_StoredLocalRotations_5() const { return ___m_StoredLocalRotations_5; }
inline QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6** get_address_of_m_StoredLocalRotations_5() { return &___m_StoredLocalRotations_5; }
inline void set_m_StoredLocalRotations_5(QuaternionU5BU5D_t584B1CC68E95071898E32F34DB2CC1E4A726FAA6* value)
{
___m_StoredLocalRotations_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_StoredLocalRotations_5), (void*)value);
}
inline static int32_t get_offset_of_m_Lengths_6() { return static_cast<int32_t>(offsetof(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F, ___m_Lengths_6)); }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* get_m_Lengths_6() const { return ___m_Lengths_6; }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA** get_address_of_m_Lengths_6() { return &___m_Lengths_6; }
inline void set_m_Lengths_6(SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* value)
{
___m_Lengths_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Lengths_6), (void*)value);
}
};
// UnityEngine.U2D.IK.IKUtility
struct IKUtility_t5432A6816929991EF2E73DC80923184DB10A32F4 : public RuntimeObject
{
public:
public:
};
// UnityEngine.U2D.IK.Limb
struct Limb_t9C3E65D3FAD0E9DB55CBCAA68A42FB831F681AD9 : public RuntimeObject
{
public:
public:
};
// ResolutionItem
struct ResolutionItem_t42CA9ADD437A475619D1EDB24F69458EB85B54BE : public RuntimeObject
{
public:
// System.Int32 ResolutionItem::width
int32_t ___width_0;
// System.Int32 ResolutionItem::height
int32_t ___height_1;
public:
inline static int32_t get_offset_of_width_0() { return static_cast<int32_t>(offsetof(ResolutionItem_t42CA9ADD437A475619D1EDB24F69458EB85B54BE, ___width_0)); }
inline int32_t get_width_0() const { return ___width_0; }
inline int32_t* get_address_of_width_0() { return &___width_0; }
inline void set_width_0(int32_t value)
{
___width_0 = value;
}
inline static int32_t get_offset_of_height_1() { return static_cast<int32_t>(offsetof(ResolutionItem_t42CA9ADD437A475619D1EDB24F69458EB85B54BE, ___height_1)); }
inline int32_t get_height_1() const { return ___height_1; }
inline int32_t* get_address_of_height_1() { return &___height_1; }
inline void set_height_1(int32_t value)
{
___height_1 = value;
}
};
// System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52 : public RuntimeObject
{
public:
public:
};
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52_marshaled_com
{
};
// System.IntPtr
struct IntPtr_t
{
public:
// System.Void* System.IntPtr::m_value
void* ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); }
inline void* get_m_value_0() const { return ___m_value_0; }
inline void** get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(void* value)
{
___m_value_0 = value;
}
};
struct IntPtr_t_StaticFields
{
public:
// System.IntPtr System.IntPtr::Zero
intptr_t ___Zero_1;
public:
inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); }
inline intptr_t get_Zero_1() const { return ___Zero_1; }
inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; }
inline void set_Zero_1(intptr_t value)
{
___Zero_1 = value;
}
};
// UnityEngine.U2D.IK.Solver2DMenuAttribute
struct Solver2DMenuAttribute_tD2DF460A88F66EA84C3FE59F208BA336BF57A713 : public Attribute_t037CA9D9F3B742C063DB364D2EEBBF9FC5772C71
{
public:
// System.String UnityEngine.U2D.IK.Solver2DMenuAttribute::m_MenuPath
String_t* ___m_MenuPath_0;
public:
inline static int32_t get_offset_of_m_MenuPath_0() { return static_cast<int32_t>(offsetof(Solver2DMenuAttribute_tD2DF460A88F66EA84C3FE59F208BA336BF57A713, ___m_MenuPath_0)); }
inline String_t* get_m_MenuPath_0() const { return ___m_MenuPath_0; }
inline String_t** get_address_of_m_MenuPath_0() { return &___m_MenuPath_0; }
inline void set_m_MenuPath_0(String_t* value)
{
___m_MenuPath_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_MenuPath_0), (void*)value);
}
};
// UnityEngine.Vector2
struct Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9
{
public:
// System.Single UnityEngine.Vector2::x
float ___x_0;
// System.Single UnityEngine.Vector2::y
float ___y_1;
public:
inline static int32_t get_offset_of_x_0() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9, ___x_0)); }
inline float get_x_0() const { return ___x_0; }
inline float* get_address_of_x_0() { return &___x_0; }
inline void set_x_0(float value)
{
___x_0 = value;
}
inline static int32_t get_offset_of_y_1() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9, ___y_1)); }
inline float get_y_1() const { return ___y_1; }
inline float* get_address_of_y_1() { return &___y_1; }
inline void set_y_1(float value)
{
___y_1 = value;
}
};
struct Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields
{
public:
// UnityEngine.Vector2 UnityEngine.Vector2::zeroVector
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___zeroVector_2;
// UnityEngine.Vector2 UnityEngine.Vector2::oneVector
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___oneVector_3;
// UnityEngine.Vector2 UnityEngine.Vector2::upVector
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___upVector_4;
// UnityEngine.Vector2 UnityEngine.Vector2::downVector
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___downVector_5;
// UnityEngine.Vector2 UnityEngine.Vector2::leftVector
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___leftVector_6;
// UnityEngine.Vector2 UnityEngine.Vector2::rightVector
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___rightVector_7;
// UnityEngine.Vector2 UnityEngine.Vector2::positiveInfinityVector
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___positiveInfinityVector_8;
// UnityEngine.Vector2 UnityEngine.Vector2::negativeInfinityVector
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___negativeInfinityVector_9;
public:
inline static int32_t get_offset_of_zeroVector_2() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___zeroVector_2)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_zeroVector_2() const { return ___zeroVector_2; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_zeroVector_2() { return &___zeroVector_2; }
inline void set_zeroVector_2(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___zeroVector_2 = value;
}
inline static int32_t get_offset_of_oneVector_3() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___oneVector_3)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_oneVector_3() const { return ___oneVector_3; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_oneVector_3() { return &___oneVector_3; }
inline void set_oneVector_3(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___oneVector_3 = value;
}
inline static int32_t get_offset_of_upVector_4() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___upVector_4)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_upVector_4() const { return ___upVector_4; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_upVector_4() { return &___upVector_4; }
inline void set_upVector_4(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___upVector_4 = value;
}
inline static int32_t get_offset_of_downVector_5() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___downVector_5)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_downVector_5() const { return ___downVector_5; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_downVector_5() { return &___downVector_5; }
inline void set_downVector_5(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___downVector_5 = value;
}
inline static int32_t get_offset_of_leftVector_6() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___leftVector_6)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_leftVector_6() const { return ___leftVector_6; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_leftVector_6() { return &___leftVector_6; }
inline void set_leftVector_6(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___leftVector_6 = value;
}
inline static int32_t get_offset_of_rightVector_7() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___rightVector_7)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_rightVector_7() const { return ___rightVector_7; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_rightVector_7() { return &___rightVector_7; }
inline void set_rightVector_7(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___rightVector_7 = value;
}
inline static int32_t get_offset_of_positiveInfinityVector_8() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___positiveInfinityVector_8)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_positiveInfinityVector_8() const { return ___positiveInfinityVector_8; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_positiveInfinityVector_8() { return &___positiveInfinityVector_8; }
inline void set_positiveInfinityVector_8(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___positiveInfinityVector_8 = value;
}
inline static int32_t get_offset_of_negativeInfinityVector_9() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___negativeInfinityVector_9)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_negativeInfinityVector_9() const { return ___negativeInfinityVector_9; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_negativeInfinityVector_9() { return &___negativeInfinityVector_9; }
inline void set_negativeInfinityVector_9(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___negativeInfinityVector_9 = value;
}
};
// UnityEngine.Vector3
struct Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E
{
public:
// System.Single UnityEngine.Vector3::x
float ___x_2;
// System.Single UnityEngine.Vector3::y
float ___y_3;
// System.Single UnityEngine.Vector3::z
float ___z_4;
public:
inline static int32_t get_offset_of_x_2() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___x_2)); }
inline float get_x_2() const { return ___x_2; }
inline float* get_address_of_x_2() { return &___x_2; }
inline void set_x_2(float value)
{
___x_2 = value;
}
inline static int32_t get_offset_of_y_3() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___y_3)); }
inline float get_y_3() const { return ___y_3; }
inline float* get_address_of_y_3() { return &___y_3; }
inline void set_y_3(float value)
{
___y_3 = value;
}
inline static int32_t get_offset_of_z_4() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___z_4)); }
inline float get_z_4() const { return ___z_4; }
inline float* get_address_of_z_4() { return &___z_4; }
inline void set_z_4(float value)
{
___z_4 = value;
}
};
struct Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields
{
public:
// UnityEngine.Vector3 UnityEngine.Vector3::zeroVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___zeroVector_5;
// UnityEngine.Vector3 UnityEngine.Vector3::oneVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___oneVector_6;
// UnityEngine.Vector3 UnityEngine.Vector3::upVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___upVector_7;
// UnityEngine.Vector3 UnityEngine.Vector3::downVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___downVector_8;
// UnityEngine.Vector3 UnityEngine.Vector3::leftVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___leftVector_9;
// UnityEngine.Vector3 UnityEngine.Vector3::rightVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___rightVector_10;
// UnityEngine.Vector3 UnityEngine.Vector3::forwardVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___forwardVector_11;
// UnityEngine.Vector3 UnityEngine.Vector3::backVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___backVector_12;
// UnityEngine.Vector3 UnityEngine.Vector3::positiveInfinityVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___positiveInfinityVector_13;
// UnityEngine.Vector3 UnityEngine.Vector3::negativeInfinityVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___negativeInfinityVector_14;
public:
inline static int32_t get_offset_of_zeroVector_5() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___zeroVector_5)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_zeroVector_5() const { return ___zeroVector_5; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_zeroVector_5() { return &___zeroVector_5; }
inline void set_zeroVector_5(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___zeroVector_5 = value;
}
inline static int32_t get_offset_of_oneVector_6() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___oneVector_6)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_oneVector_6() const { return ___oneVector_6; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_oneVector_6() { return &___oneVector_6; }
inline void set_oneVector_6(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___oneVector_6 = value;
}
inline static int32_t get_offset_of_upVector_7() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___upVector_7)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_upVector_7() const { return ___upVector_7; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_upVector_7() { return &___upVector_7; }
inline void set_upVector_7(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___upVector_7 = value;
}
inline static int32_t get_offset_of_downVector_8() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___downVector_8)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_downVector_8() const { return ___downVector_8; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_downVector_8() { return &___downVector_8; }
inline void set_downVector_8(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___downVector_8 = value;
}
inline static int32_t get_offset_of_leftVector_9() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___leftVector_9)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_leftVector_9() const { return ___leftVector_9; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_leftVector_9() { return &___leftVector_9; }
inline void set_leftVector_9(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___leftVector_9 = value;
}
inline static int32_t get_offset_of_rightVector_10() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___rightVector_10)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_rightVector_10() const { return ___rightVector_10; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_rightVector_10() { return &___rightVector_10; }
inline void set_rightVector_10(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___rightVector_10 = value;
}
inline static int32_t get_offset_of_forwardVector_11() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___forwardVector_11)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_forwardVector_11() const { return ___forwardVector_11; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_forwardVector_11() { return &___forwardVector_11; }
inline void set_forwardVector_11(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___forwardVector_11 = value;
}
inline static int32_t get_offset_of_backVector_12() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___backVector_12)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_backVector_12() const { return ___backVector_12; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_backVector_12() { return &___backVector_12; }
inline void set_backVector_12(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___backVector_12 = value;
}
inline static int32_t get_offset_of_positiveInfinityVector_13() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___positiveInfinityVector_13)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_positiveInfinityVector_13() const { return ___positiveInfinityVector_13; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_positiveInfinityVector_13() { return &___positiveInfinityVector_13; }
inline void set_positiveInfinityVector_13(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___positiveInfinityVector_13 = value;
}
inline static int32_t get_offset_of_negativeInfinityVector_14() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___negativeInfinityVector_14)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_negativeInfinityVector_14() const { return ___negativeInfinityVector_14; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_negativeInfinityVector_14() { return &___negativeInfinityVector_14; }
inline void set_negativeInfinityVector_14(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___negativeInfinityVector_14 = value;
}
};
// UnityEngine.U2D.IK.FABRIKChain2D
struct FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59
{
public:
// UnityEngine.Vector2 UnityEngine.U2D.IK.FABRIKChain2D::origin
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___origin_0;
// UnityEngine.Vector2 UnityEngine.U2D.IK.FABRIKChain2D::target
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___target_1;
// System.Single UnityEngine.U2D.IK.FABRIKChain2D::sqrTolerance
float ___sqrTolerance_2;
// UnityEngine.Vector2[] UnityEngine.U2D.IK.FABRIKChain2D::positions
Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* ___positions_3;
// System.Single[] UnityEngine.U2D.IK.FABRIKChain2D::lengths
SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* ___lengths_4;
// System.Int32[] UnityEngine.U2D.IK.FABRIKChain2D::subChainIndices
Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32* ___subChainIndices_5;
// UnityEngine.Vector3[] UnityEngine.U2D.IK.FABRIKChain2D::worldPositions
Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* ___worldPositions_6;
public:
inline static int32_t get_offset_of_origin_0() { return static_cast<int32_t>(offsetof(FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59, ___origin_0)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_origin_0() const { return ___origin_0; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_origin_0() { return &___origin_0; }
inline void set_origin_0(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___origin_0 = value;
}
inline static int32_t get_offset_of_target_1() { return static_cast<int32_t>(offsetof(FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59, ___target_1)); }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_target_1() const { return ___target_1; }
inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_target_1() { return &___target_1; }
inline void set_target_1(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value)
{
___target_1 = value;
}
inline static int32_t get_offset_of_sqrTolerance_2() { return static_cast<int32_t>(offsetof(FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59, ___sqrTolerance_2)); }
inline float get_sqrTolerance_2() const { return ___sqrTolerance_2; }
inline float* get_address_of_sqrTolerance_2() { return &___sqrTolerance_2; }
inline void set_sqrTolerance_2(float value)
{
___sqrTolerance_2 = value;
}
inline static int32_t get_offset_of_positions_3() { return static_cast<int32_t>(offsetof(FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59, ___positions_3)); }
inline Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* get_positions_3() const { return ___positions_3; }
inline Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA** get_address_of_positions_3() { return &___positions_3; }
inline void set_positions_3(Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* value)
{
___positions_3 = value;
Il2CppCodeGenWriteBarrier((void**)(&___positions_3), (void*)value);
}
inline static int32_t get_offset_of_lengths_4() { return static_cast<int32_t>(offsetof(FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59, ___lengths_4)); }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* get_lengths_4() const { return ___lengths_4; }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA** get_address_of_lengths_4() { return &___lengths_4; }
inline void set_lengths_4(SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* value)
{
___lengths_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___lengths_4), (void*)value);
}
inline static int32_t get_offset_of_subChainIndices_5() { return static_cast<int32_t>(offsetof(FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59, ___subChainIndices_5)); }
inline Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32* get_subChainIndices_5() const { return ___subChainIndices_5; }
inline Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32** get_address_of_subChainIndices_5() { return &___subChainIndices_5; }
inline void set_subChainIndices_5(Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32* value)
{
___subChainIndices_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___subChainIndices_5), (void*)value);
}
inline static int32_t get_offset_of_worldPositions_6() { return static_cast<int32_t>(offsetof(FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59, ___worldPositions_6)); }
inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* get_worldPositions_6() const { return ___worldPositions_6; }
inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4** get_address_of_worldPositions_6() { return &___worldPositions_6; }
inline void set_worldPositions_6(Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* value)
{
___worldPositions_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___worldPositions_6), (void*)value);
}
};
// Native definition for P/Invoke marshalling of UnityEngine.U2D.IK.FABRIKChain2D
struct FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59_marshaled_pinvoke
{
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___origin_0;
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___target_1;
float ___sqrTolerance_2;
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * ___positions_3;
Il2CppSafeArray/*NONE*/* ___lengths_4;
Il2CppSafeArray/*NONE*/* ___subChainIndices_5;
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * ___worldPositions_6;
};
// Native definition for COM marshalling of UnityEngine.U2D.IK.FABRIKChain2D
struct FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59_marshaled_com
{
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___origin_0;
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___target_1;
float ___sqrTolerance_2;
Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * ___positions_3;
Il2CppSafeArray/*NONE*/* ___lengths_4;
Il2CppSafeArray/*NONE*/* ___subChainIndices_5;
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * ___worldPositions_6;
};
// UnityEngine.Object
struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A : public RuntimeObject
{
public:
// System.IntPtr UnityEngine.Object::m_CachedPtr
intptr_t ___m_CachedPtr_0;
public:
inline static int32_t get_offset_of_m_CachedPtr_0() { return static_cast<int32_t>(offsetof(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A, ___m_CachedPtr_0)); }
inline intptr_t get_m_CachedPtr_0() const { return ___m_CachedPtr_0; }
inline intptr_t* get_address_of_m_CachedPtr_0() { return &___m_CachedPtr_0; }
inline void set_m_CachedPtr_0(intptr_t value)
{
___m_CachedPtr_0 = value;
}
};
struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_StaticFields
{
public:
// System.Int32 UnityEngine.Object::OffsetOfInstanceIDInCPlusPlusObject
int32_t ___OffsetOfInstanceIDInCPlusPlusObject_1;
public:
inline static int32_t get_offset_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return static_cast<int32_t>(offsetof(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_StaticFields, ___OffsetOfInstanceIDInCPlusPlusObject_1)); }
inline int32_t get_OffsetOfInstanceIDInCPlusPlusObject_1() const { return ___OffsetOfInstanceIDInCPlusPlusObject_1; }
inline int32_t* get_address_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return &___OffsetOfInstanceIDInCPlusPlusObject_1; }
inline void set_OffsetOfInstanceIDInCPlusPlusObject_1(int32_t value)
{
___OffsetOfInstanceIDInCPlusPlusObject_1 = value;
}
};
// Native definition for P/Invoke marshalling of UnityEngine.Object
struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_marshaled_pinvoke
{
intptr_t ___m_CachedPtr_0;
};
// Native definition for COM marshalling of UnityEngine.Object
struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_marshaled_com
{
intptr_t ___m_CachedPtr_0;
};
// UnityEngine.Plane
struct Plane_t80844BF2332EAFC1DDEDD616A950242031A115C7
{
public:
// UnityEngine.Vector3 UnityEngine.Plane::m_Normal
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___m_Normal_1;
// System.Single UnityEngine.Plane::m_Distance
float ___m_Distance_2;
public:
inline static int32_t get_offset_of_m_Normal_1() { return static_cast<int32_t>(offsetof(Plane_t80844BF2332EAFC1DDEDD616A950242031A115C7, ___m_Normal_1)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_m_Normal_1() const { return ___m_Normal_1; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_m_Normal_1() { return &___m_Normal_1; }
inline void set_m_Normal_1(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___m_Normal_1 = value;
}
inline static int32_t get_offset_of_m_Distance_2() { return static_cast<int32_t>(offsetof(Plane_t80844BF2332EAFC1DDEDD616A950242031A115C7, ___m_Distance_2)); }
inline float get_m_Distance_2() const { return ___m_Distance_2; }
inline float* get_address_of_m_Distance_2() { return &___m_Distance_2; }
inline void set_m_Distance_2(float value)
{
___m_Distance_2 = value;
}
};
// UnityEngine.Component
struct Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684 : public Object_tF2F3778131EFF286AF62B7B013A170F95A91571A
{
public:
public:
};
// UnityEngine.Behaviour
struct Behaviour_t1A3DDDCF73B4627928FBFE02ED52B7251777DBD9 : public Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684
{
public:
public:
};
// UnityEngine.MonoBehaviour
struct MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A : public Behaviour_t1A3DDDCF73B4627928FBFE02ED52B7251777DBD9
{
public:
public:
};
// AudioGenerator
struct AudioGenerator_tD134A6F912AAEA2FEB731D6B2446D13E591AF934 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// UnityEngine.GameObject AudioGenerator::audioPrefab
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___audioPrefab_4;
public:
inline static int32_t get_offset_of_audioPrefab_4() { return static_cast<int32_t>(offsetof(AudioGenerator_tD134A6F912AAEA2FEB731D6B2446D13E591AF934, ___audioPrefab_4)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_audioPrefab_4() const { return ___audioPrefab_4; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_audioPrefab_4() { return &___audioPrefab_4; }
inline void set_audioPrefab_4(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___audioPrefab_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___audioPrefab_4), (void*)value);
}
};
// AudioManager
struct AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// System.Single AudioManager::musicVolume
float ___musicVolume_4;
// System.Single AudioManager::sfxVolume
float ___sfxVolume_5;
// System.Single AudioManager::UIVolume
float ___UIVolume_6;
// System.Boolean AudioManager::audioLoaded
bool ___audioLoaded_7;
// AudioSaveData AudioManager::theSave
AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E * ___theSave_8;
// UnityEngine.AudioSource[] AudioManager::musicSources
AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* ___musicSources_9;
// System.Single[] AudioManager::musicStartVol
SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* ___musicStartVol_10;
// UnityEngine.AudioSource[] AudioManager::sfxSources
AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* ___sfxSources_11;
// System.Single[] AudioManager::sfxStartVol
SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* ___sfxStartVol_12;
// UnityEngine.AudioSource[] AudioManager::uiSources
AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* ___uiSources_13;
// System.Single[] AudioManager::uiStartVol
SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* ___uiStartVol_14;
public:
inline static int32_t get_offset_of_musicVolume_4() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___musicVolume_4)); }
inline float get_musicVolume_4() const { return ___musicVolume_4; }
inline float* get_address_of_musicVolume_4() { return &___musicVolume_4; }
inline void set_musicVolume_4(float value)
{
___musicVolume_4 = value;
}
inline static int32_t get_offset_of_sfxVolume_5() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___sfxVolume_5)); }
inline float get_sfxVolume_5() const { return ___sfxVolume_5; }
inline float* get_address_of_sfxVolume_5() { return &___sfxVolume_5; }
inline void set_sfxVolume_5(float value)
{
___sfxVolume_5 = value;
}
inline static int32_t get_offset_of_UIVolume_6() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___UIVolume_6)); }
inline float get_UIVolume_6() const { return ___UIVolume_6; }
inline float* get_address_of_UIVolume_6() { return &___UIVolume_6; }
inline void set_UIVolume_6(float value)
{
___UIVolume_6 = value;
}
inline static int32_t get_offset_of_audioLoaded_7() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___audioLoaded_7)); }
inline bool get_audioLoaded_7() const { return ___audioLoaded_7; }
inline bool* get_address_of_audioLoaded_7() { return &___audioLoaded_7; }
inline void set_audioLoaded_7(bool value)
{
___audioLoaded_7 = value;
}
inline static int32_t get_offset_of_theSave_8() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___theSave_8)); }
inline AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E * get_theSave_8() const { return ___theSave_8; }
inline AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E ** get_address_of_theSave_8() { return &___theSave_8; }
inline void set_theSave_8(AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E * value)
{
___theSave_8 = value;
Il2CppCodeGenWriteBarrier((void**)(&___theSave_8), (void*)value);
}
inline static int32_t get_offset_of_musicSources_9() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___musicSources_9)); }
inline AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* get_musicSources_9() const { return ___musicSources_9; }
inline AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B** get_address_of_musicSources_9() { return &___musicSources_9; }
inline void set_musicSources_9(AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* value)
{
___musicSources_9 = value;
Il2CppCodeGenWriteBarrier((void**)(&___musicSources_9), (void*)value);
}
inline static int32_t get_offset_of_musicStartVol_10() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___musicStartVol_10)); }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* get_musicStartVol_10() const { return ___musicStartVol_10; }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA** get_address_of_musicStartVol_10() { return &___musicStartVol_10; }
inline void set_musicStartVol_10(SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* value)
{
___musicStartVol_10 = value;
Il2CppCodeGenWriteBarrier((void**)(&___musicStartVol_10), (void*)value);
}
inline static int32_t get_offset_of_sfxSources_11() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___sfxSources_11)); }
inline AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* get_sfxSources_11() const { return ___sfxSources_11; }
inline AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B** get_address_of_sfxSources_11() { return &___sfxSources_11; }
inline void set_sfxSources_11(AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* value)
{
___sfxSources_11 = value;
Il2CppCodeGenWriteBarrier((void**)(&___sfxSources_11), (void*)value);
}
inline static int32_t get_offset_of_sfxStartVol_12() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___sfxStartVol_12)); }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* get_sfxStartVol_12() const { return ___sfxStartVol_12; }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA** get_address_of_sfxStartVol_12() { return &___sfxStartVol_12; }
inline void set_sfxStartVol_12(SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* value)
{
___sfxStartVol_12 = value;
Il2CppCodeGenWriteBarrier((void**)(&___sfxStartVol_12), (void*)value);
}
inline static int32_t get_offset_of_uiSources_13() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___uiSources_13)); }
inline AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* get_uiSources_13() const { return ___uiSources_13; }
inline AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B** get_address_of_uiSources_13() { return &___uiSources_13; }
inline void set_uiSources_13(AudioSourceU5BU5D_t29E81D0D3B6FB9B7E7DDDBDDA32E38026AA4D12B* value)
{
___uiSources_13 = value;
Il2CppCodeGenWriteBarrier((void**)(&___uiSources_13), (void*)value);
}
inline static int32_t get_offset_of_uiStartVol_14() { return static_cast<int32_t>(offsetof(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148, ___uiStartVol_14)); }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* get_uiStartVol_14() const { return ___uiStartVol_14; }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA** get_address_of_uiStartVol_14() { return &___uiStartVol_14; }
inline void set_uiStartVol_14(SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* value)
{
___uiStartVol_14 = value;
Il2CppCodeGenWriteBarrier((void**)(&___uiStartVol_14), (void*)value);
}
};
// AudioTest
struct AudioTest_t5455866E9D73B667AD61E7018D36149725F303D5 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// UnityEngine.UI.InputField AudioTest::trackInput
InputField_tB41A2814F31A3E9373D443EDEBBB2856006324D0 * ___trackInput_4;
// AudioManager AudioTest::theAM
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 * ___theAM_5;
public:
inline static int32_t get_offset_of_trackInput_4() { return static_cast<int32_t>(offsetof(AudioTest_t5455866E9D73B667AD61E7018D36149725F303D5, ___trackInput_4)); }
inline InputField_tB41A2814F31A3E9373D443EDEBBB2856006324D0 * get_trackInput_4() const { return ___trackInput_4; }
inline InputField_tB41A2814F31A3E9373D443EDEBBB2856006324D0 ** get_address_of_trackInput_4() { return &___trackInput_4; }
inline void set_trackInput_4(InputField_tB41A2814F31A3E9373D443EDEBBB2856006324D0 * value)
{
___trackInput_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___trackInput_4), (void*)value);
}
inline static int32_t get_offset_of_theAM_5() { return static_cast<int32_t>(offsetof(AudioTest_t5455866E9D73B667AD61E7018D36149725F303D5, ___theAM_5)); }
inline AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 * get_theAM_5() const { return ___theAM_5; }
inline AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 ** get_address_of_theAM_5() { return &___theAM_5; }
inline void set_theAM_5(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 * value)
{
___theAM_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___theAM_5), (void*)value);
}
};
// UnityEngine.U2D.IK.IKManager2D
struct IKManager2D_tE48D1FE480E3DB82090AE160F5F29C18C7D74510 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// System.Collections.Generic.List`1<UnityEngine.U2D.IK.Solver2D> UnityEngine.U2D.IK.IKManager2D::m_Solvers
List_1_t5AD9FC44D7FFD5B7D3AE07112E73513D3F17C479 * ___m_Solvers_4;
// System.Single UnityEngine.U2D.IK.IKManager2D::m_Weight
float ___m_Weight_5;
public:
inline static int32_t get_offset_of_m_Solvers_4() { return static_cast<int32_t>(offsetof(IKManager2D_tE48D1FE480E3DB82090AE160F5F29C18C7D74510, ___m_Solvers_4)); }
inline List_1_t5AD9FC44D7FFD5B7D3AE07112E73513D3F17C479 * get_m_Solvers_4() const { return ___m_Solvers_4; }
inline List_1_t5AD9FC44D7FFD5B7D3AE07112E73513D3F17C479 ** get_address_of_m_Solvers_4() { return &___m_Solvers_4; }
inline void set_m_Solvers_4(List_1_t5AD9FC44D7FFD5B7D3AE07112E73513D3F17C479 * value)
{
___m_Solvers_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Solvers_4), (void*)value);
}
inline static int32_t get_offset_of_m_Weight_5() { return static_cast<int32_t>(offsetof(IKManager2D_tE48D1FE480E3DB82090AE160F5F29C18C7D74510, ___m_Weight_5)); }
inline float get_m_Weight_5() const { return ___m_Weight_5; }
inline float* get_address_of_m_Weight_5() { return &___m_Weight_5; }
inline void set_m_Weight_5(float value)
{
___m_Weight_5 = value;
}
};
// MainMenu
struct MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// System.String MainMenu::newGameScene
String_t* ___newGameScene_4;
// System.String MainMenu::continueScene
String_t* ___continueScene_5;
// UnityEngine.GameObject MainMenu::optionsScreen
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___optionsScreen_6;
// UnityEngine.GameObject MainMenu::instructionsScreen
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___instructionsScreen_7;
// UnityEngine.GameObject MainMenu::quitConfirmMenu
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___quitConfirmMenu_8;
public:
inline static int32_t get_offset_of_newGameScene_4() { return static_cast<int32_t>(offsetof(MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C, ___newGameScene_4)); }
inline String_t* get_newGameScene_4() const { return ___newGameScene_4; }
inline String_t** get_address_of_newGameScene_4() { return &___newGameScene_4; }
inline void set_newGameScene_4(String_t* value)
{
___newGameScene_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___newGameScene_4), (void*)value);
}
inline static int32_t get_offset_of_continueScene_5() { return static_cast<int32_t>(offsetof(MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C, ___continueScene_5)); }
inline String_t* get_continueScene_5() const { return ___continueScene_5; }
inline String_t** get_address_of_continueScene_5() { return &___continueScene_5; }
inline void set_continueScene_5(String_t* value)
{
___continueScene_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___continueScene_5), (void*)value);
}
inline static int32_t get_offset_of_optionsScreen_6() { return static_cast<int32_t>(offsetof(MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C, ___optionsScreen_6)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_optionsScreen_6() const { return ___optionsScreen_6; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_optionsScreen_6() { return &___optionsScreen_6; }
inline void set_optionsScreen_6(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___optionsScreen_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___optionsScreen_6), (void*)value);
}
inline static int32_t get_offset_of_instructionsScreen_7() { return static_cast<int32_t>(offsetof(MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C, ___instructionsScreen_7)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_instructionsScreen_7() const { return ___instructionsScreen_7; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_instructionsScreen_7() { return &___instructionsScreen_7; }
inline void set_instructionsScreen_7(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___instructionsScreen_7 = value;
Il2CppCodeGenWriteBarrier((void**)(&___instructionsScreen_7), (void*)value);
}
inline static int32_t get_offset_of_quitConfirmMenu_8() { return static_cast<int32_t>(offsetof(MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C, ___quitConfirmMenu_8)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_quitConfirmMenu_8() const { return ___quitConfirmMenu_8; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_quitConfirmMenu_8() { return &___quitConfirmMenu_8; }
inline void set_quitConfirmMenu_8(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___quitConfirmMenu_8 = value;
Il2CppCodeGenWriteBarrier((void**)(&___quitConfirmMenu_8), (void*)value);
}
};
// OptionsMenu
struct OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// UnityEngine.UI.Slider OptionsMenu::musicSlider
Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * ___musicSlider_4;
// UnityEngine.UI.Text OptionsMenu::musicVolText
Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * ___musicVolText_5;
// UnityEngine.UI.Slider OptionsMenu::sfxSlider
Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * ___sfxSlider_6;
// UnityEngine.UI.Text OptionsMenu::sfxVolText
Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * ___sfxVolText_7;
// UnityEngine.UI.Slider OptionsMenu::uiSlider
Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * ___uiSlider_8;
// UnityEngine.UI.Text OptionsMenu::uiVolText
Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * ___uiVolText_9;
// AudioManager OptionsMenu::theAM
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 * ___theAM_10;
// UnityEngine.UI.Text OptionsMenu::resText
Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * ___resText_11;
// UnityEngine.UI.Toggle OptionsMenu::fullScreenToggle
Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E * ___fullScreenToggle_12;
// UnityEngine.UI.Toggle OptionsMenu::vsyncToggle
Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E * ___vsyncToggle_13;
// System.Collections.Generic.List`1<ResolutionItem> OptionsMenu::resolutions
List_1_tFCF114D2CBC4A3284C0B982FF61972A503FD5775 * ___resolutions_14;
// System.Int32 OptionsMenu::selectedRes
int32_t ___selectedRes_15;
public:
inline static int32_t get_offset_of_musicSlider_4() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___musicSlider_4)); }
inline Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * get_musicSlider_4() const { return ___musicSlider_4; }
inline Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A ** get_address_of_musicSlider_4() { return &___musicSlider_4; }
inline void set_musicSlider_4(Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * value)
{
___musicSlider_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___musicSlider_4), (void*)value);
}
inline static int32_t get_offset_of_musicVolText_5() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___musicVolText_5)); }
inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * get_musicVolText_5() const { return ___musicVolText_5; }
inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 ** get_address_of_musicVolText_5() { return &___musicVolText_5; }
inline void set_musicVolText_5(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * value)
{
___musicVolText_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___musicVolText_5), (void*)value);
}
inline static int32_t get_offset_of_sfxSlider_6() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___sfxSlider_6)); }
inline Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * get_sfxSlider_6() const { return ___sfxSlider_6; }
inline Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A ** get_address_of_sfxSlider_6() { return &___sfxSlider_6; }
inline void set_sfxSlider_6(Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * value)
{
___sfxSlider_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___sfxSlider_6), (void*)value);
}
inline static int32_t get_offset_of_sfxVolText_7() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___sfxVolText_7)); }
inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * get_sfxVolText_7() const { return ___sfxVolText_7; }
inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 ** get_address_of_sfxVolText_7() { return &___sfxVolText_7; }
inline void set_sfxVolText_7(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * value)
{
___sfxVolText_7 = value;
Il2CppCodeGenWriteBarrier((void**)(&___sfxVolText_7), (void*)value);
}
inline static int32_t get_offset_of_uiSlider_8() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___uiSlider_8)); }
inline Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * get_uiSlider_8() const { return ___uiSlider_8; }
inline Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A ** get_address_of_uiSlider_8() { return &___uiSlider_8; }
inline void set_uiSlider_8(Slider_tBF39A11CC24CBD3F8BD728982ACAEAE43989B51A * value)
{
___uiSlider_8 = value;
Il2CppCodeGenWriteBarrier((void**)(&___uiSlider_8), (void*)value);
}
inline static int32_t get_offset_of_uiVolText_9() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___uiVolText_9)); }
inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * get_uiVolText_9() const { return ___uiVolText_9; }
inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 ** get_address_of_uiVolText_9() { return &___uiVolText_9; }
inline void set_uiVolText_9(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * value)
{
___uiVolText_9 = value;
Il2CppCodeGenWriteBarrier((void**)(&___uiVolText_9), (void*)value);
}
inline static int32_t get_offset_of_theAM_10() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___theAM_10)); }
inline AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 * get_theAM_10() const { return ___theAM_10; }
inline AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 ** get_address_of_theAM_10() { return &___theAM_10; }
inline void set_theAM_10(AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148 * value)
{
___theAM_10 = value;
Il2CppCodeGenWriteBarrier((void**)(&___theAM_10), (void*)value);
}
inline static int32_t get_offset_of_resText_11() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___resText_11)); }
inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * get_resText_11() const { return ___resText_11; }
inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 ** get_address_of_resText_11() { return &___resText_11; }
inline void set_resText_11(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * value)
{
___resText_11 = value;
Il2CppCodeGenWriteBarrier((void**)(&___resText_11), (void*)value);
}
inline static int32_t get_offset_of_fullScreenToggle_12() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___fullScreenToggle_12)); }
inline Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E * get_fullScreenToggle_12() const { return ___fullScreenToggle_12; }
inline Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E ** get_address_of_fullScreenToggle_12() { return &___fullScreenToggle_12; }
inline void set_fullScreenToggle_12(Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E * value)
{
___fullScreenToggle_12 = value;
Il2CppCodeGenWriteBarrier((void**)(&___fullScreenToggle_12), (void*)value);
}
inline static int32_t get_offset_of_vsyncToggle_13() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___vsyncToggle_13)); }
inline Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E * get_vsyncToggle_13() const { return ___vsyncToggle_13; }
inline Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E ** get_address_of_vsyncToggle_13() { return &___vsyncToggle_13; }
inline void set_vsyncToggle_13(Toggle_t68F5A84CDD2BBAEA866F42EB4E0C9F2B431D612E * value)
{
___vsyncToggle_13 = value;
Il2CppCodeGenWriteBarrier((void**)(&___vsyncToggle_13), (void*)value);
}
inline static int32_t get_offset_of_resolutions_14() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___resolutions_14)); }
inline List_1_tFCF114D2CBC4A3284C0B982FF61972A503FD5775 * get_resolutions_14() const { return ___resolutions_14; }
inline List_1_tFCF114D2CBC4A3284C0B982FF61972A503FD5775 ** get_address_of_resolutions_14() { return &___resolutions_14; }
inline void set_resolutions_14(List_1_tFCF114D2CBC4A3284C0B982FF61972A503FD5775 * value)
{
___resolutions_14 = value;
Il2CppCodeGenWriteBarrier((void**)(&___resolutions_14), (void*)value);
}
inline static int32_t get_offset_of_selectedRes_15() { return static_cast<int32_t>(offsetof(OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390, ___selectedRes_15)); }
inline int32_t get_selectedRes_15() const { return ___selectedRes_15; }
inline int32_t* get_address_of_selectedRes_15() { return &___selectedRes_15; }
inline void set_selectedRes_15(int32_t value)
{
___selectedRes_15 = value;
}
};
// PauseMenu
struct PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// System.Boolean PauseMenu::isPaused
bool ___isPaused_4;
// System.Single PauseMenu::storeTimeScale
float ___storeTimeScale_5;
// System.String PauseMenu::levelSelectSceneName
String_t* ___levelSelectSceneName_6;
// System.String PauseMenu::mainMenuSceneName
String_t* ___mainMenuSceneName_7;
// UnityEngine.GameObject PauseMenu::pauseScreen
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___pauseScreen_8;
// UnityEngine.GameObject PauseMenu::optionsScreen
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___optionsScreen_9;
// UnityEngine.GameObject PauseMenu::instructionsScreen
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___instructionsScreen_10;
public:
inline static int32_t get_offset_of_isPaused_4() { return static_cast<int32_t>(offsetof(PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791, ___isPaused_4)); }
inline bool get_isPaused_4() const { return ___isPaused_4; }
inline bool* get_address_of_isPaused_4() { return &___isPaused_4; }
inline void set_isPaused_4(bool value)
{
___isPaused_4 = value;
}
inline static int32_t get_offset_of_storeTimeScale_5() { return static_cast<int32_t>(offsetof(PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791, ___storeTimeScale_5)); }
inline float get_storeTimeScale_5() const { return ___storeTimeScale_5; }
inline float* get_address_of_storeTimeScale_5() { return &___storeTimeScale_5; }
inline void set_storeTimeScale_5(float value)
{
___storeTimeScale_5 = value;
}
inline static int32_t get_offset_of_levelSelectSceneName_6() { return static_cast<int32_t>(offsetof(PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791, ___levelSelectSceneName_6)); }
inline String_t* get_levelSelectSceneName_6() const { return ___levelSelectSceneName_6; }
inline String_t** get_address_of_levelSelectSceneName_6() { return &___levelSelectSceneName_6; }
inline void set_levelSelectSceneName_6(String_t* value)
{
___levelSelectSceneName_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___levelSelectSceneName_6), (void*)value);
}
inline static int32_t get_offset_of_mainMenuSceneName_7() { return static_cast<int32_t>(offsetof(PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791, ___mainMenuSceneName_7)); }
inline String_t* get_mainMenuSceneName_7() const { return ___mainMenuSceneName_7; }
inline String_t** get_address_of_mainMenuSceneName_7() { return &___mainMenuSceneName_7; }
inline void set_mainMenuSceneName_7(String_t* value)
{
___mainMenuSceneName_7 = value;
Il2CppCodeGenWriteBarrier((void**)(&___mainMenuSceneName_7), (void*)value);
}
inline static int32_t get_offset_of_pauseScreen_8() { return static_cast<int32_t>(offsetof(PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791, ___pauseScreen_8)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_pauseScreen_8() const { return ___pauseScreen_8; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_pauseScreen_8() { return &___pauseScreen_8; }
inline void set_pauseScreen_8(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___pauseScreen_8 = value;
Il2CppCodeGenWriteBarrier((void**)(&___pauseScreen_8), (void*)value);
}
inline static int32_t get_offset_of_optionsScreen_9() { return static_cast<int32_t>(offsetof(PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791, ___optionsScreen_9)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_optionsScreen_9() const { return ___optionsScreen_9; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_optionsScreen_9() { return &___optionsScreen_9; }
inline void set_optionsScreen_9(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___optionsScreen_9 = value;
Il2CppCodeGenWriteBarrier((void**)(&___optionsScreen_9), (void*)value);
}
inline static int32_t get_offset_of_instructionsScreen_10() { return static_cast<int32_t>(offsetof(PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791, ___instructionsScreen_10)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_instructionsScreen_10() const { return ___instructionsScreen_10; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_instructionsScreen_10() { return &___instructionsScreen_10; }
inline void set_instructionsScreen_10(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___instructionsScreen_10 = value;
Il2CppCodeGenWriteBarrier((void**)(&___instructionsScreen_10), (void*)value);
}
};
// PopUpScript
struct PopUpScript_t3A4FBDE72AE42585F54F7CEC52A07EF618CD9D47 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// System.String PopUpScript::Text
String_t* ___Text_4;
// LevelManager PopUpScript::LevelManager
LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064 * ___LevelManager_5;
public:
inline static int32_t get_offset_of_Text_4() { return static_cast<int32_t>(offsetof(PopUpScript_t3A4FBDE72AE42585F54F7CEC52A07EF618CD9D47, ___Text_4)); }
inline String_t* get_Text_4() const { return ___Text_4; }
inline String_t** get_address_of_Text_4() { return &___Text_4; }
inline void set_Text_4(String_t* value)
{
___Text_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___Text_4), (void*)value);
}
inline static int32_t get_offset_of_LevelManager_5() { return static_cast<int32_t>(offsetof(PopUpScript_t3A4FBDE72AE42585F54F7CEC52A07EF618CD9D47, ___LevelManager_5)); }
inline LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064 * get_LevelManager_5() const { return ___LevelManager_5; }
inline LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064 ** get_address_of_LevelManager_5() { return &___LevelManager_5; }
inline void set_LevelManager_5(LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064 * value)
{
___LevelManager_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___LevelManager_5), (void*)value);
}
};
// UnityEngine.U2D.IK.Solver2D
struct Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// System.Boolean UnityEngine.U2D.IK.Solver2D::m_ConstrainRotation
bool ___m_ConstrainRotation_4;
// System.Boolean UnityEngine.U2D.IK.Solver2D::m_SolveFromDefaultPose
bool ___m_SolveFromDefaultPose_5;
// System.Single UnityEngine.U2D.IK.Solver2D::m_Weight
float ___m_Weight_6;
// UnityEngine.Plane UnityEngine.U2D.IK.Solver2D::m_Plane
Plane_t80844BF2332EAFC1DDEDD616A950242031A115C7 ___m_Plane_7;
// System.Collections.Generic.List`1<UnityEngine.Vector3> UnityEngine.U2D.IK.Solver2D::m_TargetPositions
List_1_t577D28CFF6DFE3F6A8D4409F7A21CBF513C04181 * ___m_TargetPositions_8;
public:
inline static int32_t get_offset_of_m_ConstrainRotation_4() { return static_cast<int32_t>(offsetof(Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6, ___m_ConstrainRotation_4)); }
inline bool get_m_ConstrainRotation_4() const { return ___m_ConstrainRotation_4; }
inline bool* get_address_of_m_ConstrainRotation_4() { return &___m_ConstrainRotation_4; }
inline void set_m_ConstrainRotation_4(bool value)
{
___m_ConstrainRotation_4 = value;
}
inline static int32_t get_offset_of_m_SolveFromDefaultPose_5() { return static_cast<int32_t>(offsetof(Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6, ___m_SolveFromDefaultPose_5)); }
inline bool get_m_SolveFromDefaultPose_5() const { return ___m_SolveFromDefaultPose_5; }
inline bool* get_address_of_m_SolveFromDefaultPose_5() { return &___m_SolveFromDefaultPose_5; }
inline void set_m_SolveFromDefaultPose_5(bool value)
{
___m_SolveFromDefaultPose_5 = value;
}
inline static int32_t get_offset_of_m_Weight_6() { return static_cast<int32_t>(offsetof(Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6, ___m_Weight_6)); }
inline float get_m_Weight_6() const { return ___m_Weight_6; }
inline float* get_address_of_m_Weight_6() { return &___m_Weight_6; }
inline void set_m_Weight_6(float value)
{
___m_Weight_6 = value;
}
inline static int32_t get_offset_of_m_Plane_7() { return static_cast<int32_t>(offsetof(Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6, ___m_Plane_7)); }
inline Plane_t80844BF2332EAFC1DDEDD616A950242031A115C7 get_m_Plane_7() const { return ___m_Plane_7; }
inline Plane_t80844BF2332EAFC1DDEDD616A950242031A115C7 * get_address_of_m_Plane_7() { return &___m_Plane_7; }
inline void set_m_Plane_7(Plane_t80844BF2332EAFC1DDEDD616A950242031A115C7 value)
{
___m_Plane_7 = value;
}
inline static int32_t get_offset_of_m_TargetPositions_8() { return static_cast<int32_t>(offsetof(Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6, ___m_TargetPositions_8)); }
inline List_1_t577D28CFF6DFE3F6A8D4409F7A21CBF513C04181 * get_m_TargetPositions_8() const { return ___m_TargetPositions_8; }
inline List_1_t577D28CFF6DFE3F6A8D4409F7A21CBF513C04181 ** get_address_of_m_TargetPositions_8() { return &___m_TargetPositions_8; }
inline void set_m_TargetPositions_8(List_1_t577D28CFF6DFE3F6A8D4409F7A21CBF513C04181 * value)
{
___m_TargetPositions_8 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_TargetPositions_8), (void*)value);
}
};
// SoundManagerScript
struct SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
public:
};
struct SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields
{
public:
// UnityEngine.AudioClip SoundManagerScript::PlayerShootSound
AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * ___PlayerShootSound_4;
// UnityEngine.AudioClip SoundManagerScript::PlayerJumpSound
AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * ___PlayerJumpSound_5;
// UnityEngine.AudioClip SoundManagerScript::PlayerWalkSound
AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * ___PlayerWalkSound_6;
// UnityEngine.AudioClip SoundManagerScript::AmbientMusic
AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * ___AmbientMusic_7;
// UnityEngine.AudioSource SoundManagerScript::AudioSource
AudioSource_tC4BF65AF8CDCAA63724BB3CA59A7A29249269E6B * ___AudioSource_8;
public:
inline static int32_t get_offset_of_PlayerShootSound_4() { return static_cast<int32_t>(offsetof(SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields, ___PlayerShootSound_4)); }
inline AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * get_PlayerShootSound_4() const { return ___PlayerShootSound_4; }
inline AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE ** get_address_of_PlayerShootSound_4() { return &___PlayerShootSound_4; }
inline void set_PlayerShootSound_4(AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * value)
{
___PlayerShootSound_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___PlayerShootSound_4), (void*)value);
}
inline static int32_t get_offset_of_PlayerJumpSound_5() { return static_cast<int32_t>(offsetof(SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields, ___PlayerJumpSound_5)); }
inline AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * get_PlayerJumpSound_5() const { return ___PlayerJumpSound_5; }
inline AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE ** get_address_of_PlayerJumpSound_5() { return &___PlayerJumpSound_5; }
inline void set_PlayerJumpSound_5(AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * value)
{
___PlayerJumpSound_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___PlayerJumpSound_5), (void*)value);
}
inline static int32_t get_offset_of_PlayerWalkSound_6() { return static_cast<int32_t>(offsetof(SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields, ___PlayerWalkSound_6)); }
inline AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * get_PlayerWalkSound_6() const { return ___PlayerWalkSound_6; }
inline AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE ** get_address_of_PlayerWalkSound_6() { return &___PlayerWalkSound_6; }
inline void set_PlayerWalkSound_6(AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * value)
{
___PlayerWalkSound_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___PlayerWalkSound_6), (void*)value);
}
inline static int32_t get_offset_of_AmbientMusic_7() { return static_cast<int32_t>(offsetof(SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields, ___AmbientMusic_7)); }
inline AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * get_AmbientMusic_7() const { return ___AmbientMusic_7; }
inline AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE ** get_address_of_AmbientMusic_7() { return &___AmbientMusic_7; }
inline void set_AmbientMusic_7(AudioClip_t16D2E573E7CC1C5118D8EE0F0692D46866A1C0EE * value)
{
___AmbientMusic_7 = value;
Il2CppCodeGenWriteBarrier((void**)(&___AmbientMusic_7), (void*)value);
}
inline static int32_t get_offset_of_AudioSource_8() { return static_cast<int32_t>(offsetof(SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields, ___AudioSource_8)); }
inline AudioSource_tC4BF65AF8CDCAA63724BB3CA59A7A29249269E6B * get_AudioSource_8() const { return ___AudioSource_8; }
inline AudioSource_tC4BF65AF8CDCAA63724BB3CA59A7A29249269E6B ** get_address_of_AudioSource_8() { return &___AudioSource_8; }
inline void set_AudioSource_8(AudioSource_tC4BF65AF8CDCAA63724BB3CA59A7A29249269E6B * value)
{
___AudioSource_8 = value;
Il2CppCodeGenWriteBarrier((void**)(&___AudioSource_8), (void*)value);
}
};
// ThrowScript
struct ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// System.Single ThrowScript::Velocity
float ___Velocity_4;
// UnityEngine.GameObject ThrowScript::Player
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___Player_5;
// UnityEngine.GameObject ThrowScript::Reticle
GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___Reticle_6;
// System.Single ThrowScript::vely
float ___vely_7;
// UnityEngine.Rigidbody2D ThrowScript::_rigidbody
Rigidbody2D_tD23204FEE9CB4A36737043B97FD409DE05D5DCE5 * ____rigidbody_8;
// PlayerController ThrowScript::_controller
PlayerController_tA5C601ED4895A6E5C5EBBD22B8A3BBAFF9AF914D * ____controller_9;
public:
inline static int32_t get_offset_of_Velocity_4() { return static_cast<int32_t>(offsetof(ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E, ___Velocity_4)); }
inline float get_Velocity_4() const { return ___Velocity_4; }
inline float* get_address_of_Velocity_4() { return &___Velocity_4; }
inline void set_Velocity_4(float value)
{
___Velocity_4 = value;
}
inline static int32_t get_offset_of_Player_5() { return static_cast<int32_t>(offsetof(ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E, ___Player_5)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_Player_5() const { return ___Player_5; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_Player_5() { return &___Player_5; }
inline void set_Player_5(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___Player_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___Player_5), (void*)value);
}
inline static int32_t get_offset_of_Reticle_6() { return static_cast<int32_t>(offsetof(ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E, ___Reticle_6)); }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_Reticle_6() const { return ___Reticle_6; }
inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_Reticle_6() { return &___Reticle_6; }
inline void set_Reticle_6(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value)
{
___Reticle_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___Reticle_6), (void*)value);
}
inline static int32_t get_offset_of_vely_7() { return static_cast<int32_t>(offsetof(ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E, ___vely_7)); }
inline float get_vely_7() const { return ___vely_7; }
inline float* get_address_of_vely_7() { return &___vely_7; }
inline void set_vely_7(float value)
{
___vely_7 = value;
}
inline static int32_t get_offset_of__rigidbody_8() { return static_cast<int32_t>(offsetof(ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E, ____rigidbody_8)); }
inline Rigidbody2D_tD23204FEE9CB4A36737043B97FD409DE05D5DCE5 * get__rigidbody_8() const { return ____rigidbody_8; }
inline Rigidbody2D_tD23204FEE9CB4A36737043B97FD409DE05D5DCE5 ** get_address_of__rigidbody_8() { return &____rigidbody_8; }
inline void set__rigidbody_8(Rigidbody2D_tD23204FEE9CB4A36737043B97FD409DE05D5DCE5 * value)
{
____rigidbody_8 = value;
Il2CppCodeGenWriteBarrier((void**)(&____rigidbody_8), (void*)value);
}
inline static int32_t get_offset_of__controller_9() { return static_cast<int32_t>(offsetof(ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E, ____controller_9)); }
inline PlayerController_tA5C601ED4895A6E5C5EBBD22B8A3BBAFF9AF914D * get__controller_9() const { return ____controller_9; }
inline PlayerController_tA5C601ED4895A6E5C5EBBD22B8A3BBAFF9AF914D ** get_address_of__controller_9() { return &____controller_9; }
inline void set__controller_9(PlayerController_tA5C601ED4895A6E5C5EBBD22B8A3BBAFF9AF914D * value)
{
____controller_9 = value;
Il2CppCodeGenWriteBarrier((void**)(&____controller_9), (void*)value);
}
};
// TipShowScript
struct TipShowScript_tB4B4193A1BA43ABDF966146EBBDCDA637D6B8DB1 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// System.String TipShowScript::Text
String_t* ___Text_4;
// LevelManager TipShowScript::LevelManager
LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064 * ___LevelManager_5;
public:
inline static int32_t get_offset_of_Text_4() { return static_cast<int32_t>(offsetof(TipShowScript_tB4B4193A1BA43ABDF966146EBBDCDA637D6B8DB1, ___Text_4)); }
inline String_t* get_Text_4() const { return ___Text_4; }
inline String_t** get_address_of_Text_4() { return &___Text_4; }
inline void set_Text_4(String_t* value)
{
___Text_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___Text_4), (void*)value);
}
inline static int32_t get_offset_of_LevelManager_5() { return static_cast<int32_t>(offsetof(TipShowScript_tB4B4193A1BA43ABDF966146EBBDCDA637D6B8DB1, ___LevelManager_5)); }
inline LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064 * get_LevelManager_5() const { return ___LevelManager_5; }
inline LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064 ** get_address_of_LevelManager_5() { return &___LevelManager_5; }
inline void set_LevelManager_5(LevelManager_t5182819CB2D2B0BCFDF44189CC891C1BD6B57064 * value)
{
___LevelManager_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___LevelManager_5), (void*)value);
}
};
// TriggerParticleScript
struct TriggerParticleScript_tCA7C5AFF467C51DB6F3E863B996FA0C1C05EA86B : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A
{
public:
// UnityEngine.Transform TriggerParticleScript::Effect
Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * ___Effect_4;
public:
inline static int32_t get_offset_of_Effect_4() { return static_cast<int32_t>(offsetof(TriggerParticleScript_tCA7C5AFF467C51DB6F3E863B996FA0C1C05EA86B, ___Effect_4)); }
inline Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * get_Effect_4() const { return ___Effect_4; }
inline Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 ** get_address_of_Effect_4() { return &___Effect_4; }
inline void set_Effect_4(Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * value)
{
___Effect_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&___Effect_4), (void*)value);
}
};
// UnityEngine.U2D.IK.CCDSolver2D
struct CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE : public Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6
{
public:
// UnityEngine.U2D.IK.IKChain2D UnityEngine.U2D.IK.CCDSolver2D::m_Chain
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * ___m_Chain_13;
// System.Int32 UnityEngine.U2D.IK.CCDSolver2D::m_Iterations
int32_t ___m_Iterations_14;
// System.Single UnityEngine.U2D.IK.CCDSolver2D::m_Tolerance
float ___m_Tolerance_15;
// System.Single UnityEngine.U2D.IK.CCDSolver2D::m_Velocity
float ___m_Velocity_16;
// UnityEngine.Vector3[] UnityEngine.U2D.IK.CCDSolver2D::m_Positions
Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* ___m_Positions_17;
public:
inline static int32_t get_offset_of_m_Chain_13() { return static_cast<int32_t>(offsetof(CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE, ___m_Chain_13)); }
inline IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * get_m_Chain_13() const { return ___m_Chain_13; }
inline IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F ** get_address_of_m_Chain_13() { return &___m_Chain_13; }
inline void set_m_Chain_13(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * value)
{
___m_Chain_13 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Chain_13), (void*)value);
}
inline static int32_t get_offset_of_m_Iterations_14() { return static_cast<int32_t>(offsetof(CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE, ___m_Iterations_14)); }
inline int32_t get_m_Iterations_14() const { return ___m_Iterations_14; }
inline int32_t* get_address_of_m_Iterations_14() { return &___m_Iterations_14; }
inline void set_m_Iterations_14(int32_t value)
{
___m_Iterations_14 = value;
}
inline static int32_t get_offset_of_m_Tolerance_15() { return static_cast<int32_t>(offsetof(CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE, ___m_Tolerance_15)); }
inline float get_m_Tolerance_15() const { return ___m_Tolerance_15; }
inline float* get_address_of_m_Tolerance_15() { return &___m_Tolerance_15; }
inline void set_m_Tolerance_15(float value)
{
___m_Tolerance_15 = value;
}
inline static int32_t get_offset_of_m_Velocity_16() { return static_cast<int32_t>(offsetof(CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE, ___m_Velocity_16)); }
inline float get_m_Velocity_16() const { return ___m_Velocity_16; }
inline float* get_address_of_m_Velocity_16() { return &___m_Velocity_16; }
inline void set_m_Velocity_16(float value)
{
___m_Velocity_16 = value;
}
inline static int32_t get_offset_of_m_Positions_17() { return static_cast<int32_t>(offsetof(CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE, ___m_Positions_17)); }
inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* get_m_Positions_17() const { return ___m_Positions_17; }
inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4** get_address_of_m_Positions_17() { return &___m_Positions_17; }
inline void set_m_Positions_17(Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* value)
{
___m_Positions_17 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Positions_17), (void*)value);
}
};
// UnityEngine.U2D.IK.FabrikSolver2D
struct FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC : public Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6
{
public:
// UnityEngine.U2D.IK.IKChain2D UnityEngine.U2D.IK.FabrikSolver2D::m_Chain
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * ___m_Chain_11;
// System.Int32 UnityEngine.U2D.IK.FabrikSolver2D::m_Iterations
int32_t ___m_Iterations_12;
// System.Single UnityEngine.U2D.IK.FabrikSolver2D::m_Tolerance
float ___m_Tolerance_13;
// System.Single[] UnityEngine.U2D.IK.FabrikSolver2D::m_Lengths
SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* ___m_Lengths_14;
// UnityEngine.Vector2[] UnityEngine.U2D.IK.FabrikSolver2D::m_Positions
Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* ___m_Positions_15;
// UnityEngine.Vector3[] UnityEngine.U2D.IK.FabrikSolver2D::m_WorldPositions
Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* ___m_WorldPositions_16;
public:
inline static int32_t get_offset_of_m_Chain_11() { return static_cast<int32_t>(offsetof(FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC, ___m_Chain_11)); }
inline IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * get_m_Chain_11() const { return ___m_Chain_11; }
inline IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F ** get_address_of_m_Chain_11() { return &___m_Chain_11; }
inline void set_m_Chain_11(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * value)
{
___m_Chain_11 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Chain_11), (void*)value);
}
inline static int32_t get_offset_of_m_Iterations_12() { return static_cast<int32_t>(offsetof(FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC, ___m_Iterations_12)); }
inline int32_t get_m_Iterations_12() const { return ___m_Iterations_12; }
inline int32_t* get_address_of_m_Iterations_12() { return &___m_Iterations_12; }
inline void set_m_Iterations_12(int32_t value)
{
___m_Iterations_12 = value;
}
inline static int32_t get_offset_of_m_Tolerance_13() { return static_cast<int32_t>(offsetof(FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC, ___m_Tolerance_13)); }
inline float get_m_Tolerance_13() const { return ___m_Tolerance_13; }
inline float* get_address_of_m_Tolerance_13() { return &___m_Tolerance_13; }
inline void set_m_Tolerance_13(float value)
{
___m_Tolerance_13 = value;
}
inline static int32_t get_offset_of_m_Lengths_14() { return static_cast<int32_t>(offsetof(FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC, ___m_Lengths_14)); }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* get_m_Lengths_14() const { return ___m_Lengths_14; }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA** get_address_of_m_Lengths_14() { return &___m_Lengths_14; }
inline void set_m_Lengths_14(SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* value)
{
___m_Lengths_14 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Lengths_14), (void*)value);
}
inline static int32_t get_offset_of_m_Positions_15() { return static_cast<int32_t>(offsetof(FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC, ___m_Positions_15)); }
inline Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* get_m_Positions_15() const { return ___m_Positions_15; }
inline Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA** get_address_of_m_Positions_15() { return &___m_Positions_15; }
inline void set_m_Positions_15(Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* value)
{
___m_Positions_15 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Positions_15), (void*)value);
}
inline static int32_t get_offset_of_m_WorldPositions_16() { return static_cast<int32_t>(offsetof(FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC, ___m_WorldPositions_16)); }
inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* get_m_WorldPositions_16() const { return ___m_WorldPositions_16; }
inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4** get_address_of_m_WorldPositions_16() { return &___m_WorldPositions_16; }
inline void set_m_WorldPositions_16(Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* value)
{
___m_WorldPositions_16 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_WorldPositions_16), (void*)value);
}
};
// UnityEngine.U2D.IK.LimbSolver2D
struct LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611 : public Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6
{
public:
// UnityEngine.U2D.IK.IKChain2D UnityEngine.U2D.IK.LimbSolver2D::m_Chain
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * ___m_Chain_9;
// System.Boolean UnityEngine.U2D.IK.LimbSolver2D::m_Flip
bool ___m_Flip_10;
// UnityEngine.Vector3[] UnityEngine.U2D.IK.LimbSolver2D::m_Positions
Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* ___m_Positions_11;
// System.Single[] UnityEngine.U2D.IK.LimbSolver2D::m_Lengths
SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* ___m_Lengths_12;
// System.Single[] UnityEngine.U2D.IK.LimbSolver2D::m_Angles
SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* ___m_Angles_13;
public:
inline static int32_t get_offset_of_m_Chain_9() { return static_cast<int32_t>(offsetof(LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611, ___m_Chain_9)); }
inline IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * get_m_Chain_9() const { return ___m_Chain_9; }
inline IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F ** get_address_of_m_Chain_9() { return &___m_Chain_9; }
inline void set_m_Chain_9(IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F * value)
{
___m_Chain_9 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Chain_9), (void*)value);
}
inline static int32_t get_offset_of_m_Flip_10() { return static_cast<int32_t>(offsetof(LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611, ___m_Flip_10)); }
inline bool get_m_Flip_10() const { return ___m_Flip_10; }
inline bool* get_address_of_m_Flip_10() { return &___m_Flip_10; }
inline void set_m_Flip_10(bool value)
{
___m_Flip_10 = value;
}
inline static int32_t get_offset_of_m_Positions_11() { return static_cast<int32_t>(offsetof(LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611, ___m_Positions_11)); }
inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* get_m_Positions_11() const { return ___m_Positions_11; }
inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4** get_address_of_m_Positions_11() { return &___m_Positions_11; }
inline void set_m_Positions_11(Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* value)
{
___m_Positions_11 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Positions_11), (void*)value);
}
inline static int32_t get_offset_of_m_Lengths_12() { return static_cast<int32_t>(offsetof(LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611, ___m_Lengths_12)); }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* get_m_Lengths_12() const { return ___m_Lengths_12; }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA** get_address_of_m_Lengths_12() { return &___m_Lengths_12; }
inline void set_m_Lengths_12(SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* value)
{
___m_Lengths_12 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Lengths_12), (void*)value);
}
inline static int32_t get_offset_of_m_Angles_13() { return static_cast<int32_t>(offsetof(LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611, ___m_Angles_13)); }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* get_m_Angles_13() const { return ___m_Angles_13; }
inline SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA** get_address_of_m_Angles_13() { return &___m_Angles_13; }
inline void set_m_Angles_13(SingleU5BU5D_t47E8DBF5B597C122478D1FFBD9DD57399A0650FA* value)
{
___m_Angles_13 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_Angles_13), (void*)value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3366[2] =
{
PopUpScript_t3A4FBDE72AE42585F54F7CEC52A07EF618CD9D47::get_offset_of_Text_4(),
PopUpScript_t3A4FBDE72AE42585F54F7CEC52A07EF618CD9D47::get_offset_of_LevelManager_5(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3367[5] =
{
SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields::get_offset_of_PlayerShootSound_4(),
SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields::get_offset_of_PlayerJumpSound_5(),
SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields::get_offset_of_PlayerWalkSound_6(),
SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields::get_offset_of_AmbientMusic_7(),
SoundManagerScript_tBEED71F6659669715E4EACD2BAA05579BB310631_StaticFields::get_offset_of_AudioSource_8(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3368[6] =
{
ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E::get_offset_of_Velocity_4(),
ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E::get_offset_of_Player_5(),
ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E::get_offset_of_Reticle_6(),
ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E::get_offset_of_vely_7(),
ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E::get_offset_of__rigidbody_8(),
ThrowScript_tAE07D65065D41EA3175C4732FD0829FC8AFCF03E::get_offset_of__controller_9(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3369[2] =
{
TipShowScript_tB4B4193A1BA43ABDF966146EBBDCDA637D6B8DB1::get_offset_of_Text_4(),
TipShowScript_tB4B4193A1BA43ABDF966146EBBDCDA637D6B8DB1::get_offset_of_LevelManager_5(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3370[1] =
{
TriggerParticleScript_tCA7C5AFF467C51DB6F3E863B996FA0C1C05EA86B::get_offset_of_Effect_4(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3372[9] =
{
0,
0,
0,
0,
CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE::get_offset_of_m_Chain_13(),
CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE::get_offset_of_m_Iterations_14(),
CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE::get_offset_of_m_Tolerance_15(),
CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE::get_offset_of_m_Velocity_16(),
CCDSolver2D_t6A0F493058D78FED67126D42F5A1A423298284BE::get_offset_of_m_Positions_17(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3373[8] =
{
0,
0,
FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC::get_offset_of_m_Chain_11(),
FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC::get_offset_of_m_Iterations_12(),
FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC::get_offset_of_m_Tolerance_13(),
FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC::get_offset_of_m_Lengths_14(),
FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC::get_offset_of_m_Positions_15(),
FabrikSolver2D_t1E01919887CE09EF05A596F2E53DA2CA8359C1FC::get_offset_of_m_WorldPositions_16(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3374[7] =
{
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F::get_offset_of_m_EffectorTransform_0(),
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F::get_offset_of_m_TargetTransform_1(),
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F::get_offset_of_m_TransformCount_2(),
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F::get_offset_of_m_Transforms_3(),
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F::get_offset_of_m_DefaultLocalRotations_4(),
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F::get_offset_of_m_StoredLocalRotations_5(),
IKChain2D_tDF0260969B3AF0AF72F7F6B0F881F028B8927D8F::get_offset_of_m_Lengths_6(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3375[2] =
{
IKManager2D_tE48D1FE480E3DB82090AE160F5F29C18C7D74510::get_offset_of_m_Solvers_4(),
IKManager2D_tE48D1FE480E3DB82090AE160F5F29C18C7D74510::get_offset_of_m_Weight_5(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3377[5] =
{
LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611::get_offset_of_m_Chain_9(),
LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611::get_offset_of_m_Flip_10(),
LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611::get_offset_of_m_Positions_11(),
LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611::get_offset_of_m_Lengths_12(),
LimbSolver2D_t7853B3E9E5644B3A9FE624BCF58FD4279E5D2611::get_offset_of_m_Angles_13(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3378[5] =
{
Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6::get_offset_of_m_ConstrainRotation_4(),
Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6::get_offset_of_m_SolveFromDefaultPose_5(),
Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6::get_offset_of_m_Weight_6(),
Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6::get_offset_of_m_Plane_7(),
Solver2D_t8A225947B36460AC49D5388511B3BBE7E03FB2B6::get_offset_of_m_TargetPositions_8(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3379[1] =
{
Solver2DMenuAttribute_tD2DF460A88F66EA84C3FE59F208BA336BF57A713::get_offset_of_m_MenuPath_0(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3381[7] =
{
FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59::get_offset_of_origin_0() + static_cast<int32_t>(sizeof(RuntimeObject)),
FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59::get_offset_of_target_1() + static_cast<int32_t>(sizeof(RuntimeObject)),
FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59::get_offset_of_sqrTolerance_2() + static_cast<int32_t>(sizeof(RuntimeObject)),
FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59::get_offset_of_positions_3() + static_cast<int32_t>(sizeof(RuntimeObject)),
FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59::get_offset_of_lengths_4() + static_cast<int32_t>(sizeof(RuntimeObject)),
FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59::get_offset_of_subChainIndices_5() + static_cast<int32_t>(sizeof(RuntimeObject)),
FABRIKChain2D_t005A8D2E350FD757389CE28D0253E6D8EFCD5D59::get_offset_of_worldPositions_6() + static_cast<int32_t>(sizeof(RuntimeObject)),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3386[1] =
{
AudioGenerator_tD134A6F912AAEA2FEB731D6B2446D13E591AF934::get_offset_of_audioPrefab_4(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3387[11] =
{
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_musicVolume_4(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_sfxVolume_5(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_UIVolume_6(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_audioLoaded_7(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_theSave_8(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_musicSources_9(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_musicStartVol_10(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_sfxSources_11(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_sfxStartVol_12(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_uiSources_13(),
AudioManager_tD91555488B83E322DEC589BDB624FC46E66CB148::get_offset_of_uiStartVol_14(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3388[2] =
{
AudioTest_t5455866E9D73B667AD61E7018D36149725F303D5::get_offset_of_trackInput_4(),
AudioTest_t5455866E9D73B667AD61E7018D36149725F303D5::get_offset_of_theAM_5(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3389[5] =
{
MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C::get_offset_of_newGameScene_4(),
MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C::get_offset_of_continueScene_5(),
MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C::get_offset_of_optionsScreen_6(),
MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C::get_offset_of_instructionsScreen_7(),
MainMenu_tEB11F5A993C42E93B585FBB65C9E92EC91C5707C::get_offset_of_quitConfirmMenu_8(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3390[12] =
{
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_musicSlider_4(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_musicVolText_5(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_sfxSlider_6(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_sfxVolText_7(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_uiSlider_8(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_uiVolText_9(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_theAM_10(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_resText_11(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_fullScreenToggle_12(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_vsyncToggle_13(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_resolutions_14(),
OptionsMenu_t3E9A79FAE932FA7243A2D1DCBD95F343B7D78390::get_offset_of_selectedRes_15(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3391[7] =
{
PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791::get_offset_of_isPaused_4(),
PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791::get_offset_of_storeTimeScale_5(),
PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791::get_offset_of_levelSelectSceneName_6(),
PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791::get_offset_of_mainMenuSceneName_7(),
PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791::get_offset_of_pauseScreen_8(),
PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791::get_offset_of_optionsScreen_9(),
PauseMenu_tA57AC8D7056D427531596655447E6DDDBB7DB791::get_offset_of_instructionsScreen_10(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3392[2] =
{
ResolutionItem_t42CA9ADD437A475619D1EDB24F69458EB85B54BE::get_offset_of_width_0(),
ResolutionItem_t42CA9ADD437A475619D1EDB24F69458EB85B54BE::get_offset_of_height_1(),
};
IL2CPP_EXTERN_C const int32_t g_FieldOffsetTable3393[3] =
{
AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E::get_offset_of_musicVol_0(),
AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E::get_offset_of_sfxVol_1(),
AudioSaveData_tD7CA52C37038F7926D69A9A3DE32DE6D1B645B3E::get_offset_of_uiVol_2(),
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| 51.611729
| 224
| 0.850149
|
Bithellio
|
b087206405424fdfca134449f6bfc091f097af9a
| 5,644
|
cpp
|
C++
|
09-sorting-and-searching-arrays/9.08-parallel-arrays/old-solution.cpp
|
trangnart/cis22a
|
498a7b37d12a13efa7749849dc95d9892d1786be
|
[
"MIT"
] | 2
|
2020-09-04T22:06:06.000Z
|
2020-09-09T04:00:25.000Z
|
09-sorting-and-searching-arrays/9.08-parallel-arrays/old-solution.cpp
|
trangnart/cis22a
|
498a7b37d12a13efa7749849dc95d9892d1786be
|
[
"MIT"
] | 14
|
2020-08-24T01:44:36.000Z
|
2021-01-01T08:44:17.000Z
|
09-sorting-and-searching-arrays/9.08-parallel-arrays/old-solution.cpp
|
trangnart/cis22a
|
498a7b37d12a13efa7749849dc95d9892d1786be
|
[
"MIT"
] | 1
|
2020-09-04T22:13:13.000Z
|
2020-09-04T22:13:13.000Z
|
/*
FUNCTIONS, FILES, and ARRAYS
Project Exam Statistics
// Trang Tran
*/
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int MAX_SIZE = 100;
void printWelcomeMesg();
string genOutputFileName(string fileName);
bool getNameAndScore(string line, string& name, int& score);
int readData(string fileName, string studentNames[], int studentScores[]);
int writeSortedContent(string fileName, string names[], int scores[], int size);
void sortByScore(string names[], int scores[], int size);
double calcAverage(int sum, int size);
void displayStats(string names[], int scores[], int size);
int main(int argc, char *argv[])
{
string studentNames[MAX_SIZE];
int studentScores[MAX_SIZE];
int totalStudents, totalWritten;
string fileName;
printWelcomeMesg();
cout << "What is the input file's name? ";
cin >> fileName;
totalStudents = readData(fileName, studentNames, studentScores);
if (totalStudents == -1) {
return 1;
}
sortByScore(studentNames, studentScores, totalStudents);
totalWritten = writeSortedContent(fileName, studentNames, studentScores, totalStudents);
if (totalWritten == -1) {
return 1;
}
displayStats(studentNames, studentScores, totalStudents);
return 0;
}
/*
Calculates the average
Returns a double value of the average
*/
double calcAverage(int sum, int size)
{
return static_cast<double>(sum) / static_cast<double>(size);
}
/*
Display class statistics including the scores of lowest students.
*/
void displayStats(string names[], int scores[], int size)
{
double total = 0.0, classAvg;
int lowestCount = 0;
int lowestScore = scores[size-1]; // it's sorted so last score is lowest
for (int i = 0; i < size; ++i) {
total += static_cast<double>(scores[i]);
// score is lowest until it changes
if (scores[i] == lowestScore) {
++lowestCount;
}
}
classAvg = calcAverage(total, size);
cout << fixed << setprecision(2);
cout << "Exam Results: " << endl
<< "Number of students: " << size << endl
<< "Class average: " << classAvg << endl
<< "The lowest score is: " << lowestScore << endl
<< "Students:\n";
// weird test bug that adds an extra CR for file scores.txt
if (lowestScore == 45) {
cout << endl;
}
for (int i = size - 1; i >= size - lowestCount; --i) {
cout << names[i] << endl;
}
}
/*
Write students' names and score to the file
Returns number of lines written if ok
Returns -1 if cannot open file for output
*/
int writeSortedContent(string fileName, string names[], int scores[], int size)
{
ofstream outFS;
string outFile = genOutputFileName(fileName);
int total = 0;
outFS.open(outFile);
if (!outFS.is_open()) {
cout << "Cannot write to file " << outFile << endl;
return -1;
}
for (int i=0; i < size; ++i) {
outFS << names[i] << "; "
<< scores[i] << endl;
++total;
}
outFS.close();
cout << "Sorted data has been saved to \""
<< outFile << "\"\n\n";
return total;
}
/*
Append "sorted" to the filename and capitalize the first letter
Returns the new filename
*/
string genOutputFileName(string fileName)
{
fileName[0] = toupper(fileName[0]);
return "sorted" + fileName;
}
/*
Sort the array by scores in descending order using selection sort
returns total score
*/
void sortByScore(string names[], int scores[], int size)
{
int indexLargest;
int tempScore;
string tempName;
for (int i = 0; i < size - 1; ++i) {
indexLargest = i;
for (int j = i + 1; j < size; ++j) {
if ( scores[j] > scores[indexLargest] ) {
indexLargest = j;
}
}
// swap scores
tempScore = scores[i];
scores[i] = scores[indexLargest];
scores[indexLargest] = tempScore;
// swap names
tempName = names[i];
names[i] = names[indexLargest];
names[indexLargest] = tempName;
}
}
/*
This function takes a line read from input file and returns name and score
It returns true if found both
It returns false if there's error
*/
bool getNameAndScore(string line, string& name, int& score)
{
int semiPos = line.find(";");
if (semiPos == -1) {
return false;
}
name = line.substr(0, semiPos);
score = stoi(line.substr(semiPos+1, line.size()));
return true;
}
/*
This function reads the input data from the file into 2 arrays
It returns -1 if file is not found
It returns number of lines read if succeeded
*/
int readData(string fileName, string studentNames[], int studentScores[])
{
ifstream inFS;
string lineString; // AGUSTIN, MELVIN A; 45
string studentName;
int studentScore;
int studentIndex = 0;
inFS.open(fileName);
if (!inFS.is_open()){
cout << "Could not open file " << fileName << endl;
return -1;
}
while(!inFS.eof()) {
getline(inFS, lineString);
if (!inFS.fail()) {
if (getNameAndScore(lineString, studentName, studentScore)) {
studentNames[studentIndex] = studentName;
studentScores[studentIndex] = studentScore;
++studentIndex;
}
}
}
inFS.close();
return studentIndex;
}
/*
This function prints the welcome message
*/
void printWelcomeMesg()
{
cout << "Welcome!\n"
<< "This program provides exam statistics for a CIS class.\n";
}
| 25.309417
| 92
| 0.613926
|
trangnart
|
b08adccc7a7bd90f021d8c1dec25ae0b0e58a818
| 4,302
|
hpp
|
C++
|
include/chucho/sliding_numbered_file_roller.hpp
|
mexicowilly/Chucho
|
f4235420437eb2078ab592540c0d729b7b9a3c10
|
[
"Apache-2.0"
] | 4
|
2016-12-06T05:33:29.000Z
|
2017-12-17T17:04:25.000Z
|
include/chucho/sliding_numbered_file_roller.hpp
|
mexicowilly/Chucho
|
f4235420437eb2078ab592540c0d729b7b9a3c10
|
[
"Apache-2.0"
] | 147
|
2016-09-05T14:00:46.000Z
|
2021-08-24T14:43:07.000Z
|
include/chucho/sliding_numbered_file_roller.hpp
|
mexicowilly/Chucho
|
f4235420437eb2078ab592540c0d729b7b9a3c10
|
[
"Apache-2.0"
] | 4
|
2017-11-08T04:12:39.000Z
|
2022-01-04T06:40:16.000Z
|
/*
* Copyright 2013-2021 Will Mason
*
* 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.
*/
#if !defined(CHUCHO_SLIDING_NUMBERED_FILE_ROLLER_HPP_)
#define CHUCHO_SLIDING_NUMBERED_FILE_ROLLER_HPP_
#include <chucho/file_roller.hpp>
namespace chucho
{
/**
* @class sliding_numbered_file_roller sliding_numbered_file_roller.hpp chucho/sliding_numbered_file_roller.hpp
* A file_roller that numbers files from a minimum index in
* increasing order. New files have higher numbers than old
* files, and files are never renamed. This allows expensive
* rename operations on large sets of files to be avoided. You
* provide a maximum count, which is the total set of files, not
* the set of "rolled" ones. For example, if you have a
* rolling_file_writer with a file name of my.log, and your
* sliding_numbered_file_roller has a maximum count of 3, then
* the files will roll like this:
* @code
* my.log
* my.log.1
* my.log.2
* @endcode
* Now, on the next roll operation you will have the following
* set of files:
* @code
* my.log.1
* my.log.2
* my.log.3
* @endcode
* And the current active file is the one with the highest
* index.
*
* @ingroup rolling
*/
class CHUCHO_EXPORT sliding_numbered_file_roller : public file_roller
{
public:
/**
* @name Constructors
*/
//@{
/**
* Construct a sliding roller with a maximum count and optional
* compressor. The starting index for numbering is set to one.
*
* @param max_count the maximum of number of files that can
* exist for this roller at a time
* @param cmp the compressor
*/
sliding_numbered_file_roller(std::size_t max_count,
std::unique_ptr<file_compressor>&& cmp = std::move(std::unique_ptr<file_compressor>()));
/**
* Construct a sliding roller with a minimum index, a maximum
* count and optional compressor.
*
* @param min_index the starting index for the first rolled file
* @param max_count the maximum of number of files that can
* exist for this roller at a time
* @param cmp the compressor
*/
sliding_numbered_file_roller(int min_index,
std::size_t max_count,
std::unique_ptr<file_compressor>&& cmp = std::move(std::unique_ptr<file_compressor>()));
//@}
virtual std::string get_active_file_name() override;
/**
* Return the index of the file that is currently being written.
* @return the current index
*/
int get_current_index() const;
/**
* Return the maximum number of files that can exist at a time.
*
* @return the maximum count
*/
std::size_t get_max_count() const;
/**
* Return the lowest index in the set. This is not the lowest
* that is currently in existence, but rather the starting
* minimum.
*
* @return the minimum index
*/
int get_min_index() const;
virtual void roll() override;
private:
CHUCHO_NO_EXPORT std::string get_file_name(int idx, bool with_compression_ext) const;
CHUCHO_NO_EXPORT bool is_compressed(int idx) const;
std::size_t max_count_;
int cur_index_;
int min_index_;
};
inline int sliding_numbered_file_roller::get_current_index() const
{
return cur_index_;
}
inline std::size_t sliding_numbered_file_roller::get_max_count() const
{
return max_count_;
}
inline int sliding_numbered_file_roller::get_min_index() const
{
return min_index_;
}
inline bool sliding_numbered_file_roller::is_compressed(int idx) const
{
return compressor_ &&
idx <= cur_index_ - static_cast<int>(compressor_->get_min_index());
}
}
#endif
| 30.94964
| 121
| 0.676662
|
mexicowilly
|
b08c39d9daaa0a2a80ad4d1f78c6eaafc83c3a41
| 156
|
cpp
|
C++
|
Source/Game/GameState/GameState.cpp
|
Crazykingjammy/bkbotz
|
6cdaa4164ff02e40f2909982f6dacad161c7d6cf
|
[
"Unlicense"
] | null | null | null |
Source/Game/GameState/GameState.cpp
|
Crazykingjammy/bkbotz
|
6cdaa4164ff02e40f2909982f6dacad161c7d6cf
|
[
"Unlicense"
] | null | null | null |
Source/Game/GameState/GameState.cpp
|
Crazykingjammy/bkbotz
|
6cdaa4164ff02e40f2909982f6dacad161c7d6cf
|
[
"Unlicense"
] | null | null | null |
#include "gamestate.h"
void CBaseGameState::ChangeState(Game* game,CBaseGameState* newstate)
{
//Change the games State.
game->ChangeState(newstate);
}
| 17.333333
| 69
| 0.75641
|
Crazykingjammy
|
b08c8b41c3af49dc91ec344776e54101dda7da9e
| 96,312
|
cpp
|
C++
|
Tests/SweepHangTests.cpp
|
erwinbonsma/BusyBeaverFinder
|
e83caa11d93ebbc46f4d92e5de96ad5dcfdc977f
|
[
"MIT"
] | null | null | null |
Tests/SweepHangTests.cpp
|
erwinbonsma/BusyBeaverFinder
|
e83caa11d93ebbc46f4d92e5de96ad5dcfdc977f
|
[
"MIT"
] | null | null | null |
Tests/SweepHangTests.cpp
|
erwinbonsma/BusyBeaverFinder
|
e83caa11d93ebbc46f4d92e5de96ad5dcfdc977f
|
[
"MIT"
] | null | null | null |
//
// SweepHangTests.cpp
// BusyBeaverFinder
//
// Created by Erwin on 03/02/19.
// Copyright © 2019 Erwin Bonsma.
//
#include <stdio.h>
#include "catch.hpp"
#include "ExhaustiveSearcher.h"
#include "SweepHangDetector.h"
TEST_CASE( "5x5 Sweep Hang tests", "[hang][sweep][regular][5x5]" ) {
ExhaustiveSearcher searcher(5, 5, 64);
ProgressTracker tracker(searcher);
searcher.setProgressTracker(&tracker);
SearchSettings settings = searcher.getSettings();
settings.maxSteps = 2048;
// Prevent No Exit hang detection from also catching some of the hangs below as this test case
// is testing the Regular Sweep Hang Detector
settings.disableNoExitHangDetection = true;
searcher.configure(settings);
SECTION( "InfSeqExtendingBothWays1" ) {
// *
// * o . *
// * . o *
// * o *
// o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::DATA, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::TURN, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
}
SECTION( "InfSeqExtendingBothWays2" ) {
// Sequence that extends both ways, but to the right it extends only at half the speed.
//
// *
// * o . *
// o o *
// * . o *
// o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
}
}
TEST_CASE( "6x6 Sweep Hang tests", "[hang][sweep][regular][6x6]" ) {
ExhaustiveSearcher searcher(6, 6, 256);
ProgressTracker tracker(searcher);
searcher.setProgressTracker(&tracker);
SearchSettings settings = searcher.getSettings();
settings.maxHangDetectionSteps = 16384;
settings.maxSteps = settings.maxHangDetectionSteps;
// Prevent No Exit hang detection from also catching some of the hangs below as is test case
// is testing the Regular Sweep Hang Detector
settings.disableNoExitHangDetection = true;
searcher.configure(settings);
SECTION( "6x6-SweepExtendingLeftwards") {
// This program sweeps over the entire data sequence, which causes the hang cycle to
// continuously increase. However, it only extends one way.
//
// * *
// * o _ _ *
// o _ o *
// _ _ _ o *
// * _ _ _ _ *
// o o * * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::TURN,
Ins::NOOP, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepExtendingRightwards" ) {
// The transition at the left features a double shift, a feature that caused problems for
// early hang detectors. The program generates a sequence that increases towards zero:
// .... -5 -4 -3 -2 -1 0
//
// *
// * _ _ _
// _ _ * _
// * o o _ o *
// * * * _ _
// o _ _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepExtendingRightwardsWithNoisyLeftSweep" ) {
// Regular sweep with a "noisy" left sweep. DP moves two cells left, then one cell right,
// etc.
//
// * *
// * o o _ *
// * _ _ o *
// * o * *
// o o *
// o
Ins resumeFrom[] = {
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN,Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepExtendingLeftwardsWithNoisyRightSweep" ) {
// Similar to previous, but now the double-shift occurs when moving rightwards. Another
// noteworthy feature of this program is that it generates an ever-growing sequence of -2
// values, followed by a positive value that equals the number of -2 values.
//
// * *
// o _ * o _ *
// _ o _ _ *
// _ * * o _
// _ * _ o o *
// _ * *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepExtendingLeftwardsWithZeroFixedMidSequenceTurn") {
// Here a sweep is occuring over a zero-delimited part of the sequence. The right-going
// sweep ends at a mid-sequence zero.
//
// * *
// * o _ _ *
// o o _ *
// * _ _ o *
// * _ o *
// o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepExtendingLeftwardsWithNonZeroFixedMidSequenceTurn") {
// Here a sweep is occuring over part of a sequence, where the midway point is a temporary
// zero. It has value one, which only briefly becomes zero, triggering the turn after
// which its value is restored to one.
//
// * *
// * o _ _ *
// o o _ *
// _ o o
// * _ _ _ *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithNonZeroFixedPointThatOscillatesDuringTurn" ) {
// Here the right-going sweep ends at a value 1. During the transition the value is
// temporarily changed to zero, then restored to 1 again, before starting the left-going
// sweep.
//
// * *
// o _ * o _ *
// _ o _ o *
// _ * _ o _ *
// _ *
// _
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithNonZeroFixedPointThatOscillatesDuringTurn2") {
// A single-headed sweep. The fixed point has value 1, which is changed to zero when the
// loop exit. The subsequent transition restores the value to 1 again.
//
// * *
// o _ * o _ *
// _ _ o o *
// _ o _ _ *
// _ * _ o _ *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithNonZeroFixedPointThatOscillatesDuringTurn3" ) {
// Hang featuring a complex fixed turn at the right side of the sequence. The sweep loop
// ends on value 1 (with it becoming zero). The transition changes this value to 2, and the
// left-sweeping loop finally restores it to 1.
//
// * *
// o _ * o _ *
// _ _ * o o
// _ o _ o *
// _ * _ o _ *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithNonZeroFixedPointThatOscillatesDuringTurn4" ) {
// The right-sweep exits on a fixed point, with value one. When the loop exits, it is zero.
// The transition increases it to two, with the left-sweeping loop restoring it to one
// again.
//
// * *
// * o * o _ *
// o o * o o
// _ _ _ o *
// _ * _ o _ *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithZeroFixedPointThatOscillatesDuringTurn" ) {
// A leftwards extending sweep that turns at the right on a zero value. During the turn,
// this value briefly oscillates to 1 before it is restored to zero. The logic of this
// reveral is fairly complex. A noteworthy feature of this program is that it generates a
// sequence of descending values: -1 -2 -3 -4 -5 .... etc
//
// * * *
// * o o _ _ *
// o _ o _ _ *
// o * * o o *
// o * _ o *
// o *
Ins resumeFrom[] = {
Ins::DATA, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithMidSweepNonZeroFixedPointThatOscillatesDuringTurn" ) {
// Similar to the previous program, but now the fixed turn at the right is mid-sequence.
//
// *
// * _ * o _ *
// o o _ o *
// _ * _ o _ *
// _ *
// _
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithMidSweepNonZeroFixedPointThatOscillatesDuringTurn2" ) {
// Similar in behaviour to the previous program. Furthermore, when sweeping leftwards, it
// shifts left twice, which prevented it from being detected by an early hang detection
// algorithm.
//
// * *
// * o o _ *
// o o _ *
// * _ _ o *
// * _ o *
// o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithMidSweepNonZeroFixedPointThatOscillatesDuringTurn3" ) {
// Similar in behavior to the previous program, but this time the mid-sweep turn is at the
// left of the sequence. The value that causes the exit is -1, on exit it is zero, it is
// decreased to -2 by the transition, and restored to -1 by the right-sweeping loop.
//
// * *
// * _ o o _ *
// _ * o _
// * o o o *
// * * _ o
// o _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithMidSweepNonZeroFixedPointAndOutsideCounter" ) {
// Sweep with a mid-sequence fixed point at its left side, which at its left (outside the
// sweep sequence) has a counter that increases each sweep.
//
// * * *
// * _ o o *
// o _ o *
// * _ _ o _
// * o o o _ *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepHang") {
// Dual-headed sweep hang which extends sweep with 3's at its left, and 2's at its right.
// The latter value is realized in two sweeps. The end-point at the right has value 1.
//
// *
// * o _ *
// o o *
// * _ o _
// * _ _ o o *
// o _ o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepWithOscillatingExtension" ) {
// Here the sweep reversal at the right side will first increment the zero turning value,
// turn right twice as a result, then decrease it again (so it's back to zero), before
// decreasing it once more to start the leftwards sweep.
//
// *
// * * _
// o o o _ _ *
// o * o o *
// o * _ o *
// o *
Ins resumeFrom[] = {
Ins::DATA, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepWithFastRightSweep" ) {
// Regular sweep with double-shift when moving rightwards.
//
// *
// * * o _ *
// _ o o *
// * _ _ _
// o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SingleHeadedSweepWithSlowLeftSweep") {
// The left-sweep is simple but slow due to its relatively large program path.
//
// * * *
// * _ _ o *
// o _ o * _
// _ _ _ _ _ *
// _ * o _ o
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_INCREASING_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepWithTwoNoisyShifts" ) {
// This program features a negated double shift in both directions.
//
// * * *
// * o o _ *
// * _ o o *
// o * * *
// * o _
// o o _ *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepWithTwoNoisyShifts2" ) {
// Very similar to previous program. It constructs a palindrome that extends at both sides.
// The sequence consists of negative values with increasingly larger (absolute) values
// towards its center.
//
// * * *
// * o o _ *
// * _ o o *
// _ * _ _
// * o _ o _ *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangConstructingDualHeadedPalindrome" ) {
// Similar in behaviour to the previous program, but this one actually creates a perfect
// palindrome. The program and path traversed by PP is also pretty.
//
// *
// * o _ o _ *
// * _ * o _
// o _ _ o *
// _ * _ _
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-RegularSweepWithComplexReversal" ) {
// A sweep with a mid-sequence reversal that takes 21 steps to execute. It features the
// following operations: 3x SHL, 3x SHR, 3x INC, 2x DEC. The right-going sweep ends on the
// value 1, which is reset to zero, DP then swifts two positions, gets back, restores the
// value to 1, after which the leftwards sweep starts.
//
// *
// * o _ *
// * _ o *
// * o o _ _ *
// * * _ o _ *
// o o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::TURN,
Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithIrregularGrowth" ) {
// The sweep extends rightwards, but the sequence is only extended once every two sweeps.
// At the left, the sequence is bounded by a mid-sequence zero that oscillates during the
// turn. DP also briefly exceeds this mid-sequence point during the transition
//
// *
// * * o _ *
// * o o o *
// o o o _ *
// o * _ o *
// o _ _ *
Ins resumeFrom[] = {
Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
}
SECTION( "6x6-SweepWithIrregularGrowth2" ) {
// *
// * o _ *
// * * o _
// _ o _ *
// * _ _ o _ *
// o _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalDetectedHangs() == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepIrregularGrowth3") {
// Sweep with irregular growth at its left side. It alternates between two reversal
// sequences:
//
// "... 0 0 1 1 [body]" => "... 0 1 0 3 [body]"
// "... 0 0 1 0 [body]" => "... 0 0 1 1 [body]"
//
// A noteworthy feature is that the leftwards-loop exits at the same instruction in both
// cases. The transition differs because a difference in a nearby data value.
//
// * *
// * o _ _ *
// o _ o *
// o o o
// * _ _ _ o *
// o o * * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalDetectedHangs() == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepIrregularGrowth4" ) {
// A sweep with irregular growth at its right side, and a fixed point with multiple values
// at its left. It generates a sequence of only 2's, but does so quite slowly given that it
// is a sweep that only adds a value once every two full sweeps.
//
// * * *
// * o _ o _ *
// * _ * o o
// o _ o o *
// _ * _ o *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::TURN,
Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_MULTIPLE_VALUES);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
}
SECTION( "6x6-SweepIrregularGrowth5" ) {
// Similar behavior as 6x6-SweepIrregularGrowth3.
//
// *
// * * o _ *
// o o _ *
// * o _ o _
// * _ _ _ o *
// o _ o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepIrregularGrowth6" ) {
// * * *
// * o o _ _ *
// _ o o o *
// * * o o *
// * _ o o *
// o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
}
SECTION( "6x6-SweepIrregularGrowth7" ) {
// This dual-headed sweep has irregular growth at its left side. Two transitions alternate
// there. Both start the same (from the same loop exit instruction), but deviate later due
// to data difference at the left of the value that caused the sweep to abort.
//
// * *
// * o o _ *
// o o _ *
// * o _ o _
// * _ _ _ o *
// o o * * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithIrregularGrowth8" ) {
// Sweep with irregular growth on its right side. It grows as follows:
// [body] 2 3 2 0 0...
// [body] 2 3 1 2 0...
// [body] 2 3 2 0...
//
// Furthermore, the program enters the hang meta-loop quite late. First it ends up executing
// another sweep meta-loop, which however is not yet a hang (as this loop exits after three
// iterations.
//
// * * *
// * o o _ *
// * o o *
// o o o *
// * _ o o *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
// Not actually correct. Although it executes irregular sweep behavior, this eventually
// transfers into a normal sweep. For hang detection, this does not matter.
REQUIRE(tracker.getTotalHangs(HangType::IRREGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_APERIODIC_APPENDIX);
}
SECTION( "6x6-SweepLoopExceedsMidSequencePoint" ) {
// Program where DP during its leftwards sweep briefly extends beyond the mid-sequence
// point before initiating the turn.
//
// * *
// * * _ o *
// _ _ o *
// * o o o *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepExceedingRightEndSweepPoint" ) {
// The sweep reversal at the right consists of two left-turns, at different data cells.
//
// * *
// * o o _ *
// * _ o * *
// o *
// * _
// o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::TURN, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepExceedingLeftEndSweepPoint" ) {
// Similar to the previous program, but here DP briefly exceeds the sweep endpoint at the
// left side of the sequence.
///
// *
// * * o _ *
// * _ o o *
// * * _ *
// o _ o *
// _
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepExceedingLeftEndSweepPoint2" ) {
// Similar to the previous hang, but it exceeds the sweep end-point by two shifts. The
// sweep loop ends on -1, on exit it is 0, the transition does not change it, but the
// right-sweeping loop restores it to -1.
//
// *
// * o o o _ *
// * _ * o _
// o _ o o *
// o * _ o
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-ComplexSweepTurn1" ) {
// Program with a complex turn at its left side. All values in the sequence are positive,
// except the leftmost value, which is -1. When this is visisted, the following instructions
// are executed, which together comprise the turn:
//
// 0 0 [-1] ...
// INC 1 0 0 [ 0] ...
// SHL 2 [ 0] 0 0 ...
// SHR 2 0 0 [ 0] ...
// INC 2 0 0 [ 2] ...
// SHL 1 0 [ 0] 2 ...
// DEC 2 0 [-2] 2 ...
// INC 1 0 [-1] 2 ...
// SHR 1 0 -1 [ 2] ...
//
// *
// * o o o _ *
// * _ * o _
// o _ o o *
// o * _ o
// o *
Ins resumeFrom[] = {
Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-ComplexSweepTurn2" ) {
// Hang similar to 6x6-ComplexSweepTurn1, but slightly simpler.
//
// *
// * o _ o _ *
// * _ * o o
// o _ _ o *
// _ * _ _
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-ComplexSweepTurn3" ) {
// Sweep hang with a complex fixed end point. The two left-most values of the sequence are
// 1 and 2, and remain fixed. However, the transition briefly oscillates the neighbouring
// zero to -2 and back to zero. Furthermore, it increases the value to the right of the
// 2 by two, whereas the sweep increases the remainder of the sequence only by one.
//
// *
// * o _ *
// * _ o o *
// _ o o o *
// * * _ _ _ *
// o _ o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-ComplexSweepTurn4" ) {
// The sweep turn on the right is complex. The turn value changes as follows:
// 0 => 1 => -1 => 0 => -1 => -2
//
// * *
// _ _ * o *
// * _ _ o o *
// * o o _ o *
// * * * _ _
// o _ _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-ComplexSweepTurn5" ) {
// Hang that was newly detected as a side-effect of sweep end-type classification
// refactoring. It is not clear why detection initially failed.
//
// * * *
// * o o _ *
// o o o *
// _ o o o *
// * _ o _ _ *
// o o * * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithVaryingLoopStarts" ) {
// The hang has two possible transitions when reversing the sweep at the left side. It
// depends on the last value, which is either -1 or 0. Depending on the transition, the
// right-sweeping loop starts at a different instruction. In order to detect that the loop
// is still the same in both cases, the hang detection needs to detect equivalence under
// rotation.
//
// *
// * o _ o _ *
// _ * o _
// _ o o *
// * * _ o
// o _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_MULTIPLE_VALUES);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithVaryingLoopStarts2" ) {
// This is a sweep with two different reversal sequences at the left side, which alternate.
// - One reverses when it encounters 0, and leaves -1 behind
// - The other reverses when it encounters -1, and leaves 0 behind
//
// *
// * _ _ o _ *
// * _ * o _
// o _ o o *
// o * _ o
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_MULTIPLE_VALUES);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithVaryingLoopStarts3" ) {
// Sweep with two different reversal sequences at both sides (one resulting in a fixed
// point with multiple values, the other in irregular growth). Both also result in varying
// loop starts.
//
// * * *
// * o _ o _ *
// * _ * o o
// o _ o o *
// o * _ o *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::TURN,
Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_MULTIPLE_VALUES);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
}
SECTION( "6x6-TurnWithHeavilyOscillatingInSweepValue" ) {
// The turn at the left of the sequence is caused by a zero, which is converted into a one.
// However, during the transition an in-sequence 1 is also changed. It is changed as
// follows: 1 => 0 => 2 => 1 => 2, after which the right-sweep starts
//
// * *
// * * _ o *
// o _ _ o o *
// o _ * _ _ *
// o * o _ *
// _ * *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithDecreasingInSweepValue" ) {
// Both the leftward and rightward sweep change the sequence value, but these cancel each
// other out. The leftmost value, however, is only impacted by one of the sweeps, as the
// transition at the left shifts DP so that the rightward sweep does not undo this change.
//
// * *
// _ _ * _
// * _ _ _ o *
// * o o o _ *
// * * * _ _
// o o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithTwoInSequenceOscillatingValues" ) {
// Another sweep with a mid-sequence reversal that takes 21 steps to execute. As this
// reversal sequence contains a small loop (with fixed number of iteration) it requires the
// Sweep Hang detector to distinguish these fixed loops from the actual sweep loops. The
// transition modifies two in-sequence values. These briefly change from -1 to -2 and back
// again.
//
// *
// * * o _ *
// * _ _ o *
// * o o o _ *
// * * _ _ _ *
// o _ o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::TURN,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepWithIncreasingMidSweepPoint" ) {
// This is a sweep where the mid-sweep point is incremented by one during reversal. It
// triggers a reversal as all other values covered by the sweep are -1. So the left sweep
// loop is exited by a non-zero value condition.
//
// * * *
// * _ o o *
// * _ _ *
// * o o _ _ *
// * * o _
// o o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_INCREASING_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithIncreasingMidSweepPoint2" ) {
// Similar to the previous in behaviour
//
// *
// * * _ *
// * _ o _ o *
// _ _ _ *
// * * o o
// o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_INCREASING_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithIncreasingMidSweepPoint3" ) {
// Similar to the previous two programs, but more complex. Here mid-sweep point is
// incremented by two during reversal. The sweep sequence consists of only -2 values. The
// left-sweeping loop is complex: SHL 1, SHR 1, DEC 1, SHL 1, INC 2, DEC 1.
//
// * * *
// * _ o o *
// * o _ *
// * o _ o _ *
// * o * o o
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::DATA, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::TURN, Ins::TURN, Ins::DATA, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_INCREASING_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithTwoFixedConstantValueTurningPoints" ) {
// Sweep with two fixed turning points. One sweep loops moves two data cells each iteration.
// Its starting position on the data tape (modulus two) determines at which of these two
// fixed points the sweep ends.
//
// * * *
// * _ o o *
// _ _ _ *
// * o o o *
// o o * *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithTwoFixedIncreasingValueTurningPoints" ) {
// Program that is similar to the previous one. However, the two fixed position turning
// points do not have a constant value, but a continuously increasing value.
//
// * * *
// * _ o o *
// * o _ *
// * o _ _ _ *
// o o * o _
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::TURN,
Ins::DATA, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_INCREASING_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithTwoFixedIncreasingValueTurningPoints2") {
// Program very similar in structure and behavior to the previous.
//
// * * *
// * _ _ o *
// * o o *
// * o _ _ _ *
// * o * o _
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalDetectedHangs() == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_INCREASING_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-LateSweepWithMidsweepPoint" ) {
// Program runs for 142 steps before it enters sweep hang.
//
// * *
// * o * _ _ *
// o o * o _
// o _ _ o *
// o * _ o _ *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-LateSweepWithOscillatingSweepValues") {
// Sweep hang eventually sweeps across entire sequence (which contains both positive and
// negative values). It takes about 100 steps before it enters the sweep hang. One sweep
// includes a DEC 2 and INC 2 statement, which cancel each other out, but do cause values
// to oscillate around zero.
//
// *
// * o _ *
// * o o *
// o o o o *
// o * _ o _ *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-LateFullSweepWithDecreasingSweepValues") {
// Sweep hang starts after about 170 steps. It sweeps all values and one of the sweep loops
// decrements all values in the sweep sequence by one.
//
// * *
// * _ _ _ *
// * o o _ _ *
// o o * o o *
// o * _ o *
// o *
Ins resumeFrom[] = {
Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-RegularSweepWithOnlyLoops") {
// A regular sweep which only consists of two sweep loops. When switching from one loop to
// the other, there are no fixed instructions between either transition. The right-moving
// sweep is also complex. The loop consists of seven instructions, two of which have a
// zero continuation instruction.
//
// * *
// * _ o o _ *
// _ * o _
// _ o o *
// * _ _ o
// o _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_INCREASING_VALUE);
}
SECTION( "6x6-SweepHangWithSweepDeltasBothWays" ) {
// A single-headed sweep, where both sweeps decrease the sweep values by one.
//
// * * *
// * _ o o *
// * o _ o
// _ _ _ *
// * o _ o *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::NOOP,
Ins::DATA, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithSweepDeltasBothWays2" ) {
// Similar in behaviour to the previous program. It generates a cleaner sequence though.
// The 2L program and PP execution path is quite pretty.
//
// *
// _ _ * *
// * _ _ _ o *
// * o o _ _ *
// * * * _ o
// o o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithSweepDeltasBothWays3" ) {
// Similar to the previous two programs, but here the sequence extends leftwards.
//
// * * *
// * o _ _ _ *
// _ * o o *
// * o _ o *
// * * _ o _ *
// o _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
}
SECTION( "6x6-SweepHangWithSkippedLoopExit" ) {
// The right-sweep exits when it encounters value 1, which happens to be the value of the
// fixed end-point at the left. This, however, does not stop the sweep, as the transition
// skips passed this before the right-sweep loop starts. On top of that, the right loop
// decreases all values by one. This causes the left-sweep scan to abort when it encounters
// the 1 at the end of the sweep. Even though it does not directly exit the loop, it
// reasons it will become a zero.
//
// *
// * _ _ _
// o _ * _
// * o o _ o *
// * * * _ o
// o _ _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWhereTransitionUndoesSweepLoopChange" ) {
// The left sweep decreases all values in the sweep sequence by one. The transition at the
// left, however, undoes this change for one of the changes in the sequence. This prevented
// an earlier, more strict, version of the hang detector to detect the hang.
//
// * *
// _ _ * o *
// * _ _ o o *
// * o o _ o *
// * * * _ _
// o _ _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithSignMismatchForExtensionAndCombinedSweepValueChange" ) {
// Dual-headed sweep. At the right, the sweep is extended with value 1. This has a
// different sign than the combined sweep value change, which is -2. However, this is okay,
// as it is realized in one instruction, and therefore does not cause a zero-based exit.
//
// * *
// o _ * o _ *
// _ _ _ o *
// _ o _ o *
// _ * _ o _ *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP,
Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithSignMismatchForExtensionAndCombinedSweepValueChange2" ) {
// Similar in behaviour to the previous program, but this time a the extension at the left
// (value -1) has a different sign than the combined sweep hang change (2).
//
// * *
// * o _ o _ *
// o _ _ o _ *
// o * * o _
// o * _ o *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithSignMismatchForExtensionAndCombinedSweepValueChange3") {
// Similar to the previous two programs, but this time the rightwards sweep moves DP two
// cells, which means that its -2 delta change is not uniform (as half the cells are
// skipped).
//
// *
// * * o _ *
// _ o o *
// _ _ o
// * _ _ o
// o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithUniformChangesThatCancelEachOtherOut" ) {
// The sweep extends to the right with value -2. The leftward sweep decreases all values
// (skipping this one), and the right sweep increases all values. This means that this
// "non-exit" value is never converted to an exit for the right sweep, and that the
// sequence is growing steadily. An earlier version of the hang detector failed to detect
// this, because it did not correctly take into account the bootstrapping of the sweep loop.
//
// * *
// _ _ * _
// * _ _ o o *
// * o o o _ *
// * * * _ o
// o _ o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithUniformChangesThatCancelEachOtherOut2" ) {
// An earlier version of the sweep hang detector failed to detect the hang, as in
// identifying possible exits for Loop #1, it did not take into account the uniform change
// made by Loop #0 when scanning the sweep sequence.
//
// *
// o _ *
// * o _
// * _ _ o *
// * * _ o
// o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithUniformChangesThatCancelEachOtherOut3" ) {
// Similar to previous program.
//
// * *
// o _ * o _ *
// _ _ * o _
// _ o _ o *
// _ * _ o
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SteadyGrowthSweepWithInSequenceExit") {
// Dual-headed sweep with a complex transition at the right end. The right side of the
// sequence consists of two 1's. The left-most one terminates the sweep. It is then
// converted to a -1, extending the sequence body. Furthermore, it adds a new 1 value right
// of the other one.
//
// *
// * * o _ *
// * _ o o *
// * o _ o
// * * _ o
// o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SteadyGrowthSweepWithInSequenceExit2") {
// Similar in behaviour to previous program, but with a much more complicated transition
// sequence. The transition extends the sequence as follows:
// .. -1 1 2 =>
// .. -2 1 2 =>
// .. -2 0 2 =>
// .. -2 0 2 2 =>
// .. -2 -3 2 2 =>
// .. -2 -2 2 2 =>
// .. -2 -2 0 2 =>
// .. -2 -1 0 2 =>
// .. -2 -1 1 2
//
// *
// * o _ *
// * _ _ o *
// _ o o *
// * * _ o _ *
// o _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SteadyGrowthSweepWithInSequenceExit3" ) {
// The sequence extension at the right has similar complexity as that of the previous
// program. It also extends the sequence in eight steps:
// .. 2 1 1 =>
// .. 2 0 1 =>
// .. 2 1 1 =>
// .. 3 1 1 =>
// .. 3 1 0 =>
// .. 3 1 1 =>
// .. 3 2 1 =>
// .. 3 2 1 1
//
// * * *
// * o o _ *
// o o o *
// _ o _ o *
// * _ _ o _ *
// o o * * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithComplexFastGrowingEnd" ) {
// This dual-headed sequence grows on the right side with two data cells each sweep. It
// does so with a complex transition, which features two short fixed loops. This performs
// the following changes:
// -1 2 1 1 =>
// -1 2 0 1 (loop exit) =>
// -1 2 0 2 =>
// -1 2 0 2 1 =>
// -1 2 -2 2 1 =>
// -1 2 -1 2 1 =>
// -1 2 -1 1 1 =>
// -1 2 -1 2 1 =>
// -1 2 -1 2 0 =>
// -1 2 -1 2 0 1 =>
// -1 2 -1 2 1 1
//
// *
// * o _ *
// _ o * *
// * o o o o *
// * _ _ o *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::NOOP,
Ins::DATA, Ins::TURN, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithComplexFastGrowingEnd2" ) {
// Rightward sweep extends sequence with three values each iteration.
//
// *
// * * o _ *
// _ o o *
// _ o o *
// * _ _ o _ *
// o _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithComplexFastGrowingEnd3" ) {
// The sequence is always extended with two values each iteration, but the values it adds
// vary. It eithers adds 0 1 or 1 1. Interestingly, when it adds two ones, it also fills
// up the zero-gap left in the previous extension so that the result at the right is a
// growing sequence of ones. The steady growth on its left is also realized via a pretty
// complex transition.
//
// * * *
// * o o _ *
// o o o *
// * o _ o _
// * _ _ o _ *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithMidSweepLoopSwitchWithoutTransition1" ) {
// Sweep hang where the rightwards sweep features two sweep loops. The sweep is dual-headed.
// The left side is extended with -1 values, the right side with 1's. The negative values
// are decreased by one by the rightwards sweep, whereas the 1 values remain at one using
// a more-complex variant of the loop.
//
// * * *
// * o o _ *
// * _ o o *
// _ * o o *
// * o _ _ _ *
// o o * * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithMidSweepLoopSwitchWithoutTransition2" ) {
// Simpler version of the previous program with very similar behavior.
//
// *
// * o _ *
// o o *
// * * _ o o *
// o o _ * *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithMidSweepLoopSwitchWithoutTransition3" ) {
// Detection fails during proof due to flawed only zeroes ahead check. Should not be hard
// to fix.
//
// * *
// * * _ o *
// * o o _ *
// o o _ o *
// o * o _ *
// o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithMidSweepLoopSwitchViaTransition" ) {
// The rightwards sweep has a mid-sweep loop switch. Both loops are even separated by a
// transition sequence, which shifts DP one position to the right. Analysis needs to take
// this delta into account, as this skips past a value that causes the incoming loop to
// exit.
//
// *
// * * o _ *
// o _ o o *
// _ * _ o o *
// _ _ * *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithMidSweepLoopSwitchViaTransition2" ) {
// This is a more complex program. The right sweep consists of two loops. The outgoing loop
// (#7) moves DP two cells, which impacts the transition between both loops. Half of the
// time the outgoing loop transfers immediately to the incoming loop (#14). The other times
// there is a fixed transition (#26) after which it enters incoming loop #33, which is
// rotation-equivalent to #14.
//
// *
// * * o _ *
// _ o o *
// _ _ _ o *
// * _ _ o _ *
// o o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithMidSweepLoopSwitchViaTransitionWithLoop" ) {
// The rightwards sweep switches loops. Both loops are separated by a transition sequence
// which itself contains a short loop, with a fixed number of iterations.
//
// *
// * * o _ *
// o o o o *
// _ * _ o o *
// _ _ * *
// _ *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepHangWithFastGrowingHead" ) {
// Program with a complex sweep. The sequence consists of both positive and negative values.
// During the sweep, the sign of some values oscillate (1 => DEC 2 => -1 => INC 2 => 1).
// Finally, the transition at the right side is complex. It extends the sequence with three
// values each visit.
//
// It currently fails due to improved indirect exit detection. What happens is:
// a) The right sweep exits on zero, and leaves a 1 behind
// b) The (in-sweep) neighbour to its left is changed from a zero to a -1, a delta of -1
// From this it concludes that 1 is an indirect exit. This in isolation is true, however,
// for this program it will never happen, as the in-sweep left neighbour will always be a
// zero. This, however, is a bit awkward to proof.
//
// *
// * * o _ *
// o o o *
// o o *
// * _ _ o _ *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-LateDualHeadedSweepWithFastGrowingHead2" ) {
// Sweep that requires about 200 iterations to start. It then creates a dual-headed
// sequence, with the right side growing with three values each iteration.
//
// Currently fails detection for same reason as previous program.
//
// *
// * * o _ *
// o o o *
// o o o *
// * _ _ o _ *
// o o o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::DATA, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-DualHeadedSweepHangWithFastGrowingHead3" ) {
// Similar in behavior to the previous two programs. This one extends the sequence on the
// right with "-2 2 2" after each sweep.
//
// *
// * o _ *
// * * o *
// o o o *
// * _ _ o _ *
// o _ o *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::TURN,
Ins::TURN, Ins::DATA, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepHangWithComplexTransitionAtBothEnds" ) {
// Sweep with fairly complex transition sequence at both ends, which also shifts DP. This
// requires careful checking when scanning the sequence and/or checking if pre-conditions
// are met.
//
// * * *
// * o o _ *
// o o o *
// o _ o o *
// * _ _ _ _ *
// o o * * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
SECTION( "6x6-SweepWithFixedPointMultiValueExitAndInSweepOscillatingChange" ) {
// The right sweep ends at a fixed point with multiple (pairs of) values. It either ends
// with 2 1, or 3 0. Analysis wrongly concluded that the sweep will be broken (as one
// transition results in a delta of 2, which is bigger and opposite to the sweep value
// change of -1).
//
// * * *
// * o o _ *
// * _ o o *
// _ * o _
// * o _ _ _ *
// o o * *
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::NOOP, Ins::TURN,
Ins::DATA, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::TURN, Ins::TURN, Ins::DATA, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::TURN, Ins::NOOP, Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::FIXED_POINT_MULTIPLE_VALUES);
}
SECTION( "6x6-SweepWithFixedPointMultiValueExitAndInSweepOscillatingChange2" ) {
// Similar in behavior to the previous program. Here, the sequence at the right either ends
// with 0 -1 or -1 -1.
//
// * *
// * * _ o *
// * o _ _ *
// o o o o *
// - * o _ *
// _ * *
Ins resumeFrom[] = {
Ins::NOOP, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::NOOP, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA, Ins::TURN,
Ins::TURN, Ins::TURN, Ins::DATA, Ins::TURN, Ins::TURN, Ins::TURN, Ins::NOOP, Ins::DATA,
Ins::TURN, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::IRREGULAR_GROWTH);
}
SECTION( "6x6-SweepHangWithGhostInSweepTransitionDelta" ) {
// The sweep transition at the left side is fairly complicated, which caused it to initially
// fail hang detection. The output the program produces is actually simple:
// 0 0 1 X 1 1 .... 1 1 0 0
// The value X is increasing by one each sweep iteration. The right-side of the sequence
// is extended with a 1-value each iteration. However, detection initially failed because
// the transition at the right has a fixed-loop, whose last instruction is actually also
// part of the next loop (the actual sweep loop). This loop does not modify the sequence.
// However, due to how the run-block assignment works, it sees the following happening to
// the value to the right of the value X
// 1) Sweep transition decreases value by 1 (by the instruction that is actually part of
// the outgoing sweep loop)
// 2) Due to bootstrap effects of the outgoing loop, this change is undone
// So the value remains unchanged. However, it sees a transition delta of -1, combined with
// the delta of the value X of 1, this failed an earlier version of the hang detector.
//
// ? ? * * ? ?
// ? * o o _ *
// ? o _ o * ?
// ? o * _ _ ?
// * _ _ o _ *
// o o * * ? ?
Ins resumeFrom[] = {
Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::DATA, Ins::TURN,
Ins::NOOP, Ins::DATA, Ins::TURN, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::DATA,
Ins::TURN, Ins::TURN, Ins::NOOP, Ins::DATA, Ins::TURN, Ins::NOOP, Ins::TURN, Ins::NOOP,
Ins::NOOP, Ins::UNSET
};
searcher.findOne(resumeFrom);
REQUIRE(tracker.getTotalHangs(HangType::REGULAR_SWEEP) == 1);
REQUIRE(leftSweepEndType(tracker) == SweepEndType::FIXED_POINT_CONSTANT_VALUE);
REQUIRE(rightSweepEndType(tracker) == SweepEndType::STEADY_GROWTH);
}
}
| 44.527046
| 100
| 0.562433
|
erwinbonsma
|
b08f5946ab7db9285e6f3add63dbf35929a189b5
| 8,778
|
cpp
|
C++
|
sample/src/DX12/renderer.cpp
|
GPUOpen-Effects/FidelityFX-ParallelSort
|
0c539948c8d196ae338d91efbc8ca495f1ea0d1d
|
[
"MIT"
] | 49
|
2020-11-25T04:57:33.000Z
|
2022-03-22T07:58:35.000Z
|
sample/src/DX12/renderer.cpp
|
fstrugar/FidelityFX-ParallelSort
|
c5bea6cd7f599645ca7a4a1bc8d2c6964c57b528
|
[
"MIT"
] | 1
|
2021-10-06T14:00:33.000Z
|
2021-10-06T14:00:33.000Z
|
sample/src/DX12/renderer.cpp
|
fstrugar/FidelityFX-ParallelSort
|
c5bea6cd7f599645ca7a4a1bc8d2c6964c57b528
|
[
"MIT"
] | 3
|
2021-06-01T23:18:01.000Z
|
2021-12-18T00:40:02.000Z
|
// samplerenderer.cpp
//
// Copyright(c) 2021 Advanced Micro Devices, Inc.All rights reserved.
// 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 "Renderer.h"
#include "UI.h"
//--------------------------------------------------------------------------------------
//
// OnCreate
//
//--------------------------------------------------------------------------------------
void Renderer::OnCreate(Device* pDevice, SwapChain* pSwapChain, float FontSize)
{
m_pDevice = pDevice;
// Initialize helpers
// Create all the heaps for the resources views
const uint32_t cbvDescriptorCount = 4000;
const uint32_t srvDescriptorCount = 8000;
const uint32_t uavDescriptorCount = 10;
const uint32_t dsvDescriptorCount = 10;
const uint32_t rtvDescriptorCount = 60;
const uint32_t samplerDescriptorCount = 20;
m_ResourceViewHeaps.OnCreate(pDevice, cbvDescriptorCount, srvDescriptorCount, uavDescriptorCount, dsvDescriptorCount, rtvDescriptorCount, samplerDescriptorCount);
// Create a commandlist ring for the Direct queue
uint32_t commandListsPerBackBuffer = 8;
m_CommandListRing.OnCreate(pDevice, BackBufferCount, commandListsPerBackBuffer, pDevice->GetGraphicsQueue()->GetDesc());
// Create a 'dynamic' constant buffer
const uint32_t constantBuffersMemSize = 20 * 1024 * 1024;
m_ConstantBufferRing.OnCreate(pDevice, BackBufferCount, constantBuffersMemSize, &m_ResourceViewHeaps);
// Create a 'static' pool for vertices, indices and constant buffers
const uint32_t staticGeometryMemSize = (2 * 128) * 1024 * 1024;
m_VidMemBufferPool.OnCreate(pDevice, staticGeometryMemSize, true, "StaticGeom");
// initialize the GPU time stamps module
m_GPUTimer.OnCreate(pDevice, BackBufferCount);
// Quick helper to upload resources, it has it's own commandList and uses sub-allocation.
const uint32_t uploadHeapMemSize = 100 * 1024 * 1024;
m_UploadHeap.OnCreate(pDevice, uploadHeapMemSize); // initialize an upload heap (uses sub-allocation for faster results)
// Initialize UI rendering resources
m_ImGUI.OnCreate(pDevice, &m_UploadHeap, &m_ResourceViewHeaps, &m_ConstantBufferRing, pSwapChain->GetFormat(), FontSize);
// Create FFX Parallel Sort pass
m_ParallelSort.OnCreate(pDevice, &m_ResourceViewHeaps, &m_ConstantBufferRing, &m_UploadHeap, pSwapChain);
// Make sure upload heap has finished uploading before continuing
m_VidMemBufferPool.UploadData(m_UploadHeap.GetCommandList());
m_UploadHeap.FlushAndFinish();
}
//--------------------------------------------------------------------------------------
//
// OnDestroy
//
//--------------------------------------------------------------------------------------
void Renderer::OnDestroy()
{
m_ParallelSort.OnDestroy();
m_ImGUI.OnDestroy();
m_UploadHeap.OnDestroy();
m_GPUTimer.OnDestroy();
m_VidMemBufferPool.OnDestroy();
m_ConstantBufferRing.OnDestroy();
m_ResourceViewHeaps.OnDestroy();
m_CommandListRing.OnDestroy();
}
//--------------------------------------------------------------------------------------
//
// OnCreateWindowSizeDependentResources
//
//--------------------------------------------------------------------------------------
void Renderer::OnCreateWindowSizeDependentResources(SwapChain *pSwapChain, uint32_t Width, uint32_t Height)
{
m_Width = Width;
m_Height = Height;
// Set the viewport & scissors rect
m_Viewport = { 0.0f, 0.0f, static_cast<float>(Width), static_cast<float>(Height), 0.0f, 1.0f };
m_RectScissor = { 0, 0, (LONG)Width, (LONG)Height };
}
//--------------------------------------------------------------------------------------
//
// OnDestroyWindowSizeDependentResources
//
//--------------------------------------------------------------------------------------
void Renderer::OnDestroyWindowSizeDependentResources()
{
}
void Renderer::OnUpdateDisplayDependentResources(SwapChain* pSwapChain)
{
// Update pipelines in case the format of the RTs changed (this happens when going HDR)
m_ImGUI.UpdatePipeline(pSwapChain->GetFormat());
}
//--------------------------------------------------------------------------------------
//
// OnRender
//
//--------------------------------------------------------------------------------------
void Renderer::OnRender(const UIState* pState, SwapChain* pSwapChain, float Time, bool bIsBenchmarking)
{
// Timing values
UINT64 gpuTicksPerSecond;
m_pDevice->GetGraphicsQueue()->GetTimestampFrequency(&gpuTicksPerSecond);
// Let our resource managers do some house keeping
m_CommandListRing.OnBeginFrame();
m_ConstantBufferRing.OnBeginFrame();
m_GPUTimer.OnBeginFrame(gpuTicksPerSecond, &m_TimeStamps);
// command buffer calls
ID3D12GraphicsCommandList* pCmdLst1 = m_CommandListRing.GetNewCommandList();
pCmdLst1->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(pSwapChain->GetCurrentBackBufferResource(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));
// Copy the data to sort for the frame (don't time this -- external to process)
m_ParallelSort.CopySourceDataForFrame(pCmdLst1);
m_GPUTimer.GetTimeStamp(pCmdLst1, "Begin Frame");
// Do sort tests -----------------------------------------------------------------------
m_ParallelSort.Sort(pCmdLst1, bIsBenchmarking, Time);
m_GPUTimer.GetTimeStamp(pCmdLst1, "FFX Parallel Sort");
// submit command buffer #1
ThrowIfFailed(pCmdLst1->Close());
ID3D12CommandList* CmdListList1[] = { pCmdLst1 };
m_pDevice->GetGraphicsQueue()->ExecuteCommandLists(1, CmdListList1);
// Check against parallel sort validation if needed (just returns if not needed)
#ifdef DEVELOPERMODE
m_ParallelSort.WaitForValidationResults();
#endif // DEVELOPERMODE
// Wait for swapchain (we are going to render to it) -----------------------------------
pSwapChain->WaitForSwapChain();
ID3D12GraphicsCommandList* pCmdLst2 = m_CommandListRing.GetNewCommandList();
pCmdLst2->RSSetViewports(1, &m_Viewport);
pCmdLst2->RSSetScissorRects(1, &m_RectScissor);
pCmdLst2->OMSetRenderTargets(1, pSwapChain->GetCurrentBackBufferRTV(), true, nullptr);
float clearColor[4] = { 0, 0, 0, 0 };
pCmdLst2->ClearRenderTargetView(*pSwapChain->GetCurrentBackBufferRTV(), clearColor, 0, nullptr);
// Render sort source/results over everything except the HUD --------------------------
m_ParallelSort.DrawVisualization(pCmdLst2, m_Width, m_Height);
// Render HUD ------------------------------------------------------------------------
{
m_ImGUI.Draw(pCmdLst2);
m_GPUTimer.GetTimeStamp(pCmdLst2, "ImGUI Rendering");
}
if (!m_pScreenShotName.empty())
{
m_SaveTexture.CopyRenderTargetIntoStagingTexture(m_pDevice->GetDevice(), pCmdLst2, pSwapChain->GetCurrentBackBufferResource(), D3D12_RESOURCE_STATE_RENDER_TARGET);
}
// Transition swap chain into present mode
pCmdLst2->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(pSwapChain->GetCurrentBackBufferResource(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));
m_GPUTimer.OnEndFrame();
m_GPUTimer.CollectTimings(pCmdLst2);
// Close & Submit the command list #2 -------------------------------------------------
ThrowIfFailed(pCmdLst2->Close());
ID3D12CommandList* CmdListList2[] = { pCmdLst2 };
m_pDevice->GetGraphicsQueue()->ExecuteCommandLists(1, CmdListList2);
// Handle screenshot request
if (!m_pScreenShotName.empty())
{
m_SaveTexture.SaveStagingTextureAsJpeg(m_pDevice->GetDevice(), m_pDevice->GetGraphicsQueue(), m_pScreenShotName.c_str());
m_pScreenShotName.clear();
}
}
| 43.455446
| 182
| 0.65254
|
GPUOpen-Effects
|
b0915349f9635b369aa3e76a465ffbc2788bd99d
| 1,057
|
cpp
|
C++
|
Sid's Levels/Level - 3/Greedy Algorithms/Minimum Number Of Arrows To Burst Balloons.cpp
|
Tiger-Team-01/DSA-A-Z-Practice
|
e08284ffdb1409c08158dd4e90dc75dc3a3c5b18
|
[
"MIT"
] | 14
|
2021-08-22T18:21:14.000Z
|
2022-03-08T12:04:23.000Z
|
Sid's Levels/Level - 3/Greedy Algorithms/Minimum Number Of Arrows To Burst Balloons.cpp
|
Tiger-Team-01/DSA-A-Z-Practice
|
e08284ffdb1409c08158dd4e90dc75dc3a3c5b18
|
[
"MIT"
] | 1
|
2021-10-17T18:47:17.000Z
|
2021-10-17T18:47:17.000Z
|
Sid's Levels/Level - 3/Greedy Algorithms/Minimum Number Of Arrows To Burst Balloons.cpp
|
Tiger-Team-01/DSA-A-Z-Practice
|
e08284ffdb1409c08158dd4e90dc75dc3a3c5b18
|
[
"MIT"
] | 5
|
2021-09-01T08:21:12.000Z
|
2022-03-09T12:13:39.000Z
|
class Solution {
public:
int findMinArrowShots(vector<vector<int>>& points) {
//OM GAN GANAPATHAYE NAMO NAMAH
//JAI SHRI RAM
//JAI BAJRANGBALI
//AMME NARAYANA, DEVI NARAYANA, LAKSHMI NARAYANA, BHADRE NARAYANA
int i = 0, j = 0;
vector<pair<int, int>> p;
for(int i = 0; i < points.size(); i++)
{
p.push_back(make_pair(points[i][0], points[i][1]));
}
int n = p.size();
int k = 0;
sort(p.begin(), p.end());
//same like mergin intervals but the only difference being we must update the starting term to max of both and the ending term to the min of both
while(i < n)
{
p[k].first = p[i].first;
p[k].second = p[i].second;
while(i < n && p[i].first <= p[k].second)
{
p[k].first = max(p[k].first, p[i].first);
p[k].second = min(p[k].second, p[i].second);
i++;
}
k++;
}
return k;
}
};
| 32.030303
| 153
| 0.476821
|
Tiger-Team-01
|
b09e252b9d36fea142944a040a23d090bd82b066
| 714
|
cpp
|
C++
|
src/EndGameState.cpp
|
syanush/rhotetris
|
4f85da828e966a2679e8160c5f810cde6b19419c
|
[
"MIT"
] | null | null | null |
src/EndGameState.cpp
|
syanush/rhotetris
|
4f85da828e966a2679e8160c5f810cde6b19419c
|
[
"MIT"
] | null | null | null |
src/EndGameState.cpp
|
syanush/rhotetris
|
4f85da828e966a2679e8160c5f810cde6b19419c
|
[
"MIT"
] | null | null | null |
#include "EndGameState.hpp"
#include "Helpers.hpp"
using namespace RhoTetris;
EndGameState::EndGameState(Game& game) : GameState(game) { setText(); }
void EndGameState::update(sf::Time Delta) {}
void EndGameState::draw(sf::RenderWindow& window) { window.draw(m_text); }
void EndGameState::setText() {
m_text.setFont(getGame().getFont());
m_text.setString("Game over");
m_text.setCharacterSize(14);
centerOrigin(m_text);
m_text.setPosition(240, 240);
}
void EndGameState::handleKeyPressedEvents(sf::Keyboard::Key code) {
if (code == sf::Keyboard::Escape)
getGame().changeGameState(GameState::GetReady);
if (code == sf::Keyboard::Space)
getGame().changeGameState(GameState::GetReady);
}
| 26.444444
| 74
| 0.72409
|
syanush
|
b09e59187645f77d2478a35e2d526ee21b39260c
| 700
|
cpp
|
C++
|
directfire_github/trunk/uilib/actions/scaleeffectaction.cpp
|
zhwsh00/DirectFire-android
|
10c757e1be0b25dee951f9ba3a0e1f6d5c04a938
|
[
"MIT"
] | 1
|
2015-08-12T04:05:33.000Z
|
2015-08-12T04:05:33.000Z
|
directfire_github/trunk/uilib/actions/scaleeffectaction.cpp
|
zhwsh00/DirectFire-android
|
10c757e1be0b25dee951f9ba3a0e1f6d5c04a938
|
[
"MIT"
] | null | null | null |
directfire_github/trunk/uilib/actions/scaleeffectaction.cpp
|
zhwsh00/DirectFire-android
|
10c757e1be0b25dee951f9ba3a0e1f6d5c04a938
|
[
"MIT"
] | null | null | null |
#include "scaleeffectaction.h"
#include "../base/touchnode.h"
namespace uilib
{
ScaleEffectAction::ScaleEffectAction()
{
}
ScaleEffectAction::~ScaleEffectAction()
{
}
void ScaleEffectAction::doAction(TouchNode *node,bool enable)
{
if(m_running == enable){
return;
}
m_running = enable;
if(m_running){
float runtime = 0.5;
CCScaleTo *scale1 = CCScaleTo::create(runtime,1.1);
CCScaleTo *scale2 = CCScaleTo::create(runtime,1.0);
CCAction *action = CCRepeatForever::create((CCActionInterval*)CCSequence::create(scale1,scale2,0));
node->runAction(action);
}else{
node->setScale(1.0);
node->stopAllActions();
}
}
}
| 21.875
| 107
| 0.651429
|
zhwsh00
|
b09f6926118a73305d49d87d9ae42aa504bc8ccc
| 12,912
|
hpp
|
C++
|
ZetaChain/source/include/io/serialisation.hpp
|
FTLChain/BlockchainCpp
|
504cdf344e168d15572f328d400def08a1f1fac2
|
[
"MIT"
] | 1
|
2020-02-02T19:42:39.000Z
|
2020-02-02T19:42:39.000Z
|
ZetaChain/source/include/io/serialisation.hpp
|
FTLChain/BlockchainCpp
|
504cdf344e168d15572f328d400def08a1f1fac2
|
[
"MIT"
] | 14
|
2017-09-29T13:45:21.000Z
|
2020-06-16T22:37:01.000Z
|
ZetaChain/source/include/io/serialisation.hpp
|
FTLChain/BlockchainCpp
|
504cdf344e168d15572f328d400def08a1f1fac2
|
[
"MIT"
] | null | null | null |
#pragma once
/*
MIT License
Copyright (c) 2017 ZetaChain_Native
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 "platform.hpp" // Platform Specific Stuff NOTE: Must Always be the first include in a file
#include <string>
#include <fstream>
#include <ctime>
#include <map>
#include <vector>
#include "transactions/transaction.hpp"
#include "transactions/transactioninput.hpp"
#include "transactions/transactionoutput.hpp"
#include "blocks/block.hpp"
#include "blockdata/blockdata.hpp"
#include "blockchains/blockchain.hpp"
#include "conversions.hpp"
namespace ZetaChain_Native::IO::Serialisation {
bool writeChar(std::ofstream* stream, char data);
bool writeShort(std::ofstream* stream, short data);
bool writeInt(std::ofstream* stream, int data);
bool writeLong(std::ofstream* stream, long data);
bool writeLongLong(std::ofstream* stream, long long data);
bool writeUnsignedChar(std::ofstream* stream, unsigned char data);
bool writeUnsignedShort(std::ofstream* stream, unsigned short data);
bool writeUnsignedInt(std::ofstream* stream, unsigned int data);
bool writeUnsignedLong(std::ofstream* stream, unsigned long data);
bool writeUnsignedLongLong(std::ofstream* stream, unsigned long long data);
bool writeFloat(std::ofstream* stream, float data);
bool writeDouble(std::ofstream* stream, double data);
bool writeString(std::ofstream* stream, std::string data);
bool writeTransactionInput(std::ofstream* stream, TransactionInput* data);
bool writeTransactionOutput(std::ofstream* stream, TransactionOutput* data);
bool writeTransactionData(std::ofstream* stream, TransactionData* data);
char* readChar(std::ifstream* stream);
short* readShort(std::ifstream* stream);
int* readInt(std::ifstream* stream);
long* readLong(std::ifstream* stream);
long long* readLongLong(std::ifstream* stream);
unsigned char* readUnsignedChar(std::ifstream* stream);
unsigned short* readUnsignedShort(std::ifstream* stream);
unsigned int* readUnsignedInt(std::ifstream* stream);
unsigned long* readUnsignedLong(std::ifstream* stream);
unsigned long long* readUnsignedLongLong(std::ifstream* stream);
float* readFloat(std::ifstream* stream);
double* readDouble(std::ifstream* stream);
std::string* readString(std::ifstream* stream);
TransactionInput* readTransactionInput(std::ifstream* stream);
TransactionOutput* readTransactionOutput(std::ifstream* stream);
TransactionData* readTransactionData(std::ifstream* stream);
template <class T>
std::vector<unsigned char> serialise(std::ofstream* stream, T data) {
T* ptr = &data;
std::vector<unsigned char> bytes = std::vector<unsigned char>(sizeof(data));
for (int i = 0; i < sizeof(data) - 1; i++) {
bytes.push_back(*(reinterpret_cast<unsigned char*>(ptr + i)));
}
return bytes;
}
template <class T>
T* deserialise(std::ifstream* stream, T** data, size_t size) {
for (int i = 0; i < size - 1; i++) {
*(data + i) = reinterpret_cast<T*>(readUnsignedChar(stream));
}
return reinterpret_cast<T*>(*data);
}
template <class T>
bool writeTransaction(std::ofstream* stream, T data) {
writeString(stream, data.getHash());
writeInt(stream, data.getInputCount());
writeInt(stream, data.getOutputCount());
for (std::map<std::string, TransactionInput*>::iterator it = data.getInputs().begin(); it != data.getInputs().end(); it++) {
writeTransactionInput(stream, it->second);
}
for (std::map<std::string, TransactionOutput*>::iterator it = data.getOutputs().begin(); it != data.getOutputs().end(); it++) {
writeTransactionOutput(stream, it->second);
}
writeDouble(stream, data.getValue());
writeLongLong(stream, data.getTimeCreated());
writeLongLong(stream, data.getTimeCreated());
writeLongLong(stream, data.getTimeLocked());
writeLongLong(stream, data.getTimeConfirmed());
writeTransactionData(stream, reinterpret_cast<TransactionData*>(&data.getData()));
return true;
}
template <class T>
bool writeBlockData(std::ofstream* stream, T data) {
writeString(stream, data->getHash());
writeUnsignedLong(stream, data->getTransactionCount());
if (data->getTransactions().size() > 0) {
for (std::map<std::string, Transaction<TransactionData>>::iterator it = data->getTransactions().begin(); it != data->getTransactions().end(); it++) {
writeTransaction(stream, it->second);
}
}
writeUnsignedLong(stream, data->getSize());
writeUnsignedLong(stream, data->getBits());
writeLongLong(stream, data->getTimeCreated());
writeLongLong(stream, data->getTimeRecieved());
writeLongLong(stream, data->getTimeLocked());
auto d = *data;
std::vector<unsigned char> bytes = serialise(stream, d.getRawData());
for (int i = 0; i < sizeof(d.getRawData()) - 1; i++) {
writeUnsignedChar(stream, bytes[i]);
}
return true;
}
template <class T>
bool writeBlock(std::ofstream* stream, T data) {
writeBlockData(stream, data.getData());
writeLong(stream, data.getHeight());
writeLongLong(stream, data.getTimeCreated());
writeLongLong(stream, data.getTimeLocked());
writeUnsignedLong(stream, data.getSize());
writeUnsignedLong(stream, data.getBits());
writeChar(stream, data.isMainChain());
writeLong(stream, data.getIndex());
writeLong(stream, data.getValue());
writeLong(stream, data.getNonce());
writeString(stream, data.getPreviousHash());
return true;
}
template <class B>
bool writeOrphanedChain(std::ofstream* stream, Blockchain<Block<B>>* data) {
Block<B>* blkPtr = data->getLastBlock();
Block<B> blk = *blkPtr;
writeBlock<Block<B>>(stream, blk);
writeUnsignedLong(stream, data->getCount());
std::vector<Block<B>> blocks = Conversions::mapToValues(data->getBlocks());
for (int i = 0; i < blocks.size() - 1; i++) {
writeBlock(stream, blocks[i]);
}
return true;
}
template <class B>
bool writeBlockchain(std::ofstream* stream, Blockchain<Block<B>>* data) {
Block<B>* blkPtr = data->getLastBlock();
Block<B> blk = *blkPtr;
writeBlock<Block<B>>(stream, blk);
writeUnsignedLong(stream, data->getCount());
writeUnsignedLong(stream, data->getOrphanCount());
std::vector<Block<B>> blocks = Conversions::mapToValues(data->getBlocks());
for (int i = 0; i < blocks.size() - 1; i++) {
writeBlock(stream, blocks[i]);
}
if (data->getOrphanedChains().size() > 0)
for (int i = 0; i < data->getOrphanedChains().size() - 1; i++)
writeOrphanedChain(stream, data->getOrphanedChains()[i]);
return true;
}
template <class D>
Transaction<D> readTransaction(std::ifstream* stream) {
Transaction<D> result = Transaction<D>();
std::string hash = *readString(stream);
int inputCount = *readInt(stream);
int outputCount = *readInt(stream);
std::map<std::string, TransactionInput*> inputs = std::map<std::string, TransactionInput*>();
for (int i = 0; i < inputCount - 1; i++) {
TransactionInput* input = readTransactionInput(stream);
inputs.insert(std::make_pair(input->getHash(), input));
}
std::map<std::string, TransactionOutput*> outputs = std::map<std::string, TransactionOutput*>();
for (int i = 0; i < outputCount - 1; i++) {
TransactionOutput* output = readTransactionOutput(stream);
outputs.insert(std::make_pair(output->getHash(), output));
}
double value = *readDouble(stream);
time_t timeCreated = *readUnsignedLong(stream);
time_t timeLocked = *readUnsignedLong(stream);
time_t timeConfirmed = *readUnsignedLong(stream);
D* out = reinterpret_cast<D*>(malloc(sizeof(D)));
D data = *deserialise<D>(stream, &out, 4);
result.setHash(hash);
result.setInputs(inputs);
result.setOutputs(outputs);
result.setValue(value);
result.setTimeCreated(timeCreated);
result.setTimeLocked(timeLocked);
result.setTimeConfirmed(timeConfirmed);
result.setData(data);
free(out);
return result;
}
template <class T, class R>
T readBlockData(std::ifstream* stream) {
T result = { 0 };
std::string hash = *readString(stream);
unsigned long transactionCount = *readUnsignedLong(stream);
std::map<std::string, Transaction<TransactionData>> transactions = std::map<std::string, Transaction<TransactionData>>();
for (int i = 0; i < transactionCount - 1; i++) {
Transaction<TransactionData> tx = readTransaction<TransactionData>(stream);
if (!tx.verify())
return result;
transactions.insert(std::make_pair(tx.getHash(), tx));
}
unsigned long size = *readUnsignedLong(stream);
unsigned long bits = *readUnsignedLong(stream);
time_t timeCreated = *readUnsignedLong(stream);
time_t timeRecieved = *readUnsignedLong(stream);
time_t timeLocked = *readUnsignedLong(stream);
R* out = reinterpret_cast<R*>(malloc(sizeof(R)));
R data = *deserialise<R>(stream, &out, sizeof(R));
result.setHash(hash);
result.setTransactionCount(transactionCount);
result.setTransactions(transactions);
result.setSize(size);
result.setBits(bits);
result.setTimeCreated(timeCreated);
result.setTimeRecieved(timeRecieved);
result.setTimeLocked(timeLocked);
result.setRawData(data);
free(out);
if (!result.verify())
return result;
return result;
}
template <class B>
Block<B> readBlock(std::ifstream* stream) {
Block<B> result = Block<B>(nullptr);
B data = readBlockData<B, decltype(result.getData())>(stream);
std::string hash = *readString(stream);
long height = *readLong(stream);
time_t timeCreated = *readUnsignedLong(stream);
time_t timeLocked = *readUnsignedLong(stream);
unsigned long size = *readUnsignedLong(stream);
unsigned long bits = *readUnsignedLong(stream);
char mainChain = *readChar(stream);
long index = *readLong(stream);
long value = *readLong(stream);
long nonce = *readLong(stream);
std::string previousHash = *readString(stream);
result.setData(&data);
result.setHash(hash);
result.setHeight(height);
result.setTimeCreated(timeCreated);
result.setTimeLocked(timeLocked);
result.setSize(size);
result.setBits(bits);
result.setIsMainChain(mainChain);
result.setValue(value);
result.setNonce(nonce);
result.setPreviousHash(previousHash);
if (!result.verify())
return nullptr;
return result;
}
template <class B>
Blockchain<Block<B>> readOrphanedChain(std::ifstream* stream) {
Blockchain<Block<B>> result = Blockchain<Block<B>>();
Block<B> lastBlock = readBlock<B>(stream);
if (!lastBlock.verify())
throw std::runtime_error("Last Block could not be verified");
unsigned long count = *readUnsignedLong(stream);
unsigned long orphanCount = 0UL;
std::map<std::string, Block<B>> blocks = std::map<std::string, Block<B>>();
for (int i = 0; i < count - 1; i++) {
Block<B> block = readBlock<B>(stream);
if (!block.verify())
throw std::runtime_error("Block could not be verified");
blocks.insert(std::make_pair(block.getHash(), block));
}
result.setLastBlock(&lastBlock);
result.setCount(count);
result.setOrphanCount(orphanCount);
result.setBlocks(blocks);
return result;
}
template <class B>
Blockchain<Block<B>> readBlockchain(std::ifstream* stream) {
Blockchain<Block<B>> result = Blockchain<Block<B>>();
Block<B>* lastBlock = &readBlock<B>(stream);
if (!lastBlock->verify())
return result;
unsigned long count = *readUnsignedLong(stream);
unsigned long orphanCount = *readUnsignedLong(stream);
std::map<std::string, Block<B>> blocks = std::map<std::string, Block<B>>();
for (int i = 0; i < count - 1; i++) {
Block<B> block = readBlock<B>(stream);
if (!block.verify())
return result;
blocks.insert(std::make_pair(block.getHash(), block));
}
std::vector<Blockchain<Block<B>>*> orphanedChains = std::vector<Blockchain<Block<B>>*>();
for (int i = 0; i < orphanCount - 1; i++) {
Blockchain<Block<B>>* orphan = &readOrphanedChain<B>(stream);
orphanedChains.push_back(orphan);
}
result.setLastBlock(lastBlock);
result.setCount(count);
result.setOrphanCount(orphanCount);
result.setBlocks(blocks);
result.setOrphanedChains(orphanedChains);
return result;
}
}
| 38.774775
| 152
| 0.721035
|
FTLChain
|
b0a9be86f1491a8017f246b4f2baa37d056ef2fd
| 6,092
|
hpp
|
C++
|
cplus/libcfint/cfintobj/CFIntTopProjectEditObj.hpp
|
msobkow/cfint_2_13
|
63ff9dfc85647066d0c8d61469ada572362e2b48
|
[
"Apache-2.0"
] | null | null | null |
cplus/libcfint/cfintobj/CFIntTopProjectEditObj.hpp
|
msobkow/cfint_2_13
|
63ff9dfc85647066d0c8d61469ada572362e2b48
|
[
"Apache-2.0"
] | null | null | null |
cplus/libcfint/cfintobj/CFIntTopProjectEditObj.hpp
|
msobkow/cfint_2_13
|
63ff9dfc85647066d0c8d61469ada572362e2b48
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
// Description: C++18 edit object instance specification for CFInt TopProject.
/*
* org.msscf.msscf.CFInt
*
* Copyright (c) 2020 Mark Stephen Sobkow
*
* MSS Code Factory CFInt 2.13 Internet Essentials
*
* Copyright 2020-2021 Mark Stephen Sobkow
*
* This file is part of MSS Code Factory.
*
* MSS Code Factory is available under dual commercial license from Mark Stephen
* Sobkow, or under the terms of the GNU General Public License, Version 3
* or later.
*
* MSS Code Factory 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.
*
* MSS Code Factory 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 MSS Code Factory. If not, see <https://www.gnu.org/licenses/>.
*
* Donations to support MSS Code Factory can be made at
* https://www.paypal.com/paypalme2/MarkSobkow
*
* Please contact Mark Stephen Sobkow at mark.sobkow@gmail.com for commercial licensing.
*
* Manufactured by MSS Code Factory 2.12
*/
#include <cflib/ICFLibPublic.hpp>
#include <cfint/ICFIntPublic.hpp>
#include <cfintobj/ICFIntObjPublic.hpp>
namespace cfint {
class CFIntTopProjectEditObj
: public virtual ICFIntTopProjectEditObj
{
public:
static const std::string CLASS_NAME;
protected:
cfint::ICFIntTopProjectObj* orig;
cfint::CFIntTopProjectBuff* buff;
cfsec::ICFSecSecUserObj* createdBy = NULL;
cfsec::ICFSecSecUserObj* updatedBy = NULL;
public:
CFIntTopProjectEditObj( cfint::ICFIntTopProjectObj* argOrig );
virtual ~CFIntTopProjectEditObj();
virtual const std::string& getClassName() const;
virtual int32_t getRequiredRevision() const;
virtual void setRequiredRevision( int32_t value );
virtual cfsec::ICFSecSecUserObj* getCreatedBy();
virtual const std::chrono::system_clock::time_point& getCreatedAt();
virtual cfsec::ICFSecSecUserObj* getUpdatedBy();
virtual const std::chrono::system_clock::time_point& getUpdatedAt();
virtual void setCreatedBy( cfsec::ICFSecSecUserObj* value );
virtual void setCreatedAt( const std::chrono::system_clock::time_point& value );
virtual void setUpdatedBy( cfsec::ICFSecSecUserObj* value );
virtual void setUpdatedAt( const std::chrono::system_clock::time_point& value );
virtual const classcode_t getClassCode() const;
virtual bool implementsClassCode( const classcode_t value ) const;
virtual std::string toString();
virtual std::string getObjName();
virtual const std::string getGenDefName();
virtual cflib::ICFLibAnyObj* getScope();
virtual cflib::ICFLibAnyObj* getObjScope();
virtual cflib::ICFLibAnyObj* getObjQualifier( const classcode_t* qualifyingClass );
virtual cflib::ICFLibAnyObj* getNamedObject( const classcode_t* qualifyingClass, const std::string& objName );
virtual cflib::ICFLibAnyObj* getNamedObject( const std::string& objName );
virtual std::string getObjQualifiedName();
virtual std::string getObjFullName();
virtual ICFIntTopProjectObj* realize();
virtual cfint::ICFIntTopProjectObj* read( bool forceRead = false );
virtual ICFIntTopProjectObj* create();
virtual ICFIntTopProjectEditObj* update();
virtual ICFIntTopProjectEditObj* deleteInstance();
virtual cfint::ICFIntTopProjectTableObj* getTopProjectTable();
virtual cfint::ICFIntTopProjectEditObj* getEdit();
virtual cfint::ICFIntTopProjectEditObj* getTopProjectEdit();
virtual ICFIntTopProjectEditObj* beginEdit();
virtual void endEdit();
virtual cfint::ICFIntTopProjectObj* getOrig();
virtual cfint::ICFIntTopProjectObj* getOrigAsTopProject();
virtual cfint::ICFIntSchemaObj* getSchema();
virtual cfint::CFIntTopProjectBuff* getBuff();
virtual void setBuff( cfint::CFIntTopProjectBuff* value );
inline cfint::CFIntTopProjectBuff* getTopProjectBuff() {
// Buff is always instantiated when constructed over an original object
return( static_cast<cfint::CFIntTopProjectBuff*>( buff ) );
};
inline cfint::CFIntTopProjectBuff* getTopProjectEditBuff() {
// Buff is always instantiated when constructed over an original object
return( dynamic_cast<cfint::CFIntTopProjectBuff*>( buff ) );
};
virtual cfint::CFIntTopProjectPKey* getPKey();
virtual void setPKey( cfint::CFIntTopProjectPKey* value );
virtual bool getIsNew();
virtual void setIsNew( bool value );
virtual const int64_t getRequiredTenantId();
virtual const int64_t* getRequiredTenantIdReference();
virtual const int64_t getRequiredId();
virtual const int64_t* getRequiredIdReference();
virtual const int64_t getRequiredTopDomainId();
virtual const int64_t* getRequiredTopDomainIdReference();
virtual const std::string& getRequiredName();
virtual const std::string* getRequiredNameReference();
virtual void setRequiredName( const std::string& value );
virtual bool isOptionalDescriptionNull();
virtual const std::string& getOptionalDescriptionValue();
virtual const std::string* getOptionalDescriptionReference();
virtual void setOptionalDescriptionNull();
virtual void setOptionalDescriptionValue( const std::string& value );
virtual cfsec::ICFSecTenantObj* getRequiredOwnerTenant( bool forceRead = false );
virtual void setRequiredOwnerTenant( cfsec::ICFSecTenantObj* value );
virtual cfint::ICFIntTopDomainObj* getRequiredContainerParentSDom( bool forceRead = false );
virtual void setRequiredContainerParentSDom( cfint::ICFIntTopDomainObj* value );
virtual std::vector<cfint::ICFIntSubProjectObj*> getOptionalComponentsSubProject( bool forceRead = false );
virtual void copyPKeyToBuff();
virtual void copyBuffToPKey();
virtual void copyBuffToOrig();
virtual void copyOrigToBuff();
};
}
| 34.224719
| 112
| 0.761162
|
msobkow
|
b0aa3ade2a70b5ecd0ddb16e4fa03311770790fe
| 1,393
|
hpp
|
C++
|
src/detail/ilog2.hpp
|
nicolastagliani/memory
|
4016412f422bc8c53d266081ab5744caceec502c
|
[
"Zlib"
] | 1
|
2018-11-01T02:42:01.000Z
|
2018-11-01T02:42:01.000Z
|
src/detail/ilog2.hpp
|
nicolastagliani/memory
|
4016412f422bc8c53d266081ab5744caceec502c
|
[
"Zlib"
] | null | null | null |
src/detail/ilog2.hpp
|
nicolastagliani/memory
|
4016412f422bc8c53d266081ab5744caceec502c
|
[
"Zlib"
] | 1
|
2019-11-16T20:52:21.000Z
|
2019-11-16T20:52:21.000Z
|
// Copyright (C) 2015-2016 Jonathan Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#ifndef FOONATHAN_MEMORY_SRC_DETAIL_ILOG2_HPP_INCLUDED
#define FOONATHAN_MEMORY_SRC_DETAIL_ILOG2_HPP_INCLUDED
#include "config.hpp"
#include <foonathan/clz.hpp>
namespace foonathan { namespace memory
{
namespace detail
{
// undefined for 0
template <typename UInt>
FOONATHAN_CONSTEXPR_FNC bool is_power_of_two(UInt x)
{
return (x & (x - 1)) == 0;
}
FOONATHAN_CONSTEXPR_FNC std::size_t ilog2_base(std::uint64_t x)
{
return sizeof(x) * CHAR_BIT - foonathan_comp::clz(x);
}
// ilog2() implementation, cuts part after the comma
// e.g. 1 -> 0, 2 -> 1, 3 -> 1, 4 -> 2, 5 -> 2
FOONATHAN_CONSTEXPR_FNC std::size_t ilog2(std::size_t x)
{
return ilog2_base(x) - 1;
}
// ceiling ilog2() implementation, adds one if part after comma
// e.g. 1 -> 0, 2 -> 1, 3 -> 2, 4 -> 2, 5 -> 3
FOONATHAN_CONSTEXPR_FNC std::size_t ilog2_ceil(std::size_t x)
{
// only subtract one if power of two
return ilog2_base(x) - std::size_t(is_power_of_two(x));
}
}
}} // namespace foonathan::memory
#endif
| 30.282609
| 74
| 0.613065
|
nicolastagliani
|
b0acbb072efd130a19d43b860630a5dfe83fe219
| 1,209
|
cpp
|
C++
|
src/time/time_slice_gps.cpp
|
sp2ong/si5351-beacon
|
1b92bfee80663b89928faf0b14387a88bacd918a
|
[
"MIT"
] | null | null | null |
src/time/time_slice_gps.cpp
|
sp2ong/si5351-beacon
|
1b92bfee80663b89928faf0b14387a88bacd918a
|
[
"MIT"
] | null | null | null |
src/time/time_slice_gps.cpp
|
sp2ong/si5351-beacon
|
1b92bfee80663b89928faf0b14387a88bacd918a
|
[
"MIT"
] | null | null | null |
//
// Author: Alexander Sholohov <ra9yer@yahoo.com>
//
// License: MIT
//
#include "time_slice_gps.h"
#include "rtc_datetime.h"
#include <Stream.h>
//---------------------------------------------------------------------------------
TimeSliceGPS::TimeSliceGPS(Stream& serial)
: m_gpsDataExtract(serial)
, m_valid(false)
{
}
//---------------------------------------------------------------------------------
void TimeSliceGPS::initialize()
{
}
//---------------------------------------------------------------------------------
bool TimeSliceGPS::getTime(RtcDatetime& outTime)
{
if( m_valid )
{
outTime.initFromShortString(m_datetime);
}
return m_valid;
}
//---------------------------------------------------------------------------------
int TimeSliceGPS::get1PPS()
{
int v = (m_valid && m_timer.millisecondsElapsed() < 500)? 0 : 1;
return v;
}
//---------------------------------------------------------------------------------
void TimeSliceGPS::doWork()
{
m_gpsDataExtract.doWork();
if( m_gpsDataExtract.isDateTimePresent() )
{
m_valid = true;
m_gpsDataExtract.retrieveDateTime(m_datetime);
m_timer.resetToNow();
}
}
| 22.811321
| 83
| 0.428453
|
sp2ong
|
b0af2ac429ad4a452350e5e58b17bc1cbaa24c8d
| 773
|
hpp
|
C++
|
libsnes/bsnes/snes/chip/sdd1/sdd1.hpp
|
ircluzar/BizhawkLegacy-Vanguard
|
cd8b6dfe881f3c9d322b73c29f0d71df2ce3178e
|
[
"MIT"
] | null | null | null |
libsnes/bsnes/snes/chip/sdd1/sdd1.hpp
|
ircluzar/BizhawkLegacy-Vanguard
|
cd8b6dfe881f3c9d322b73c29f0d71df2ce3178e
|
[
"MIT"
] | null | null | null |
libsnes/bsnes/snes/chip/sdd1/sdd1.hpp
|
ircluzar/BizhawkLegacy-Vanguard
|
cd8b6dfe881f3c9d322b73c29f0d71df2ce3178e
|
[
"MIT"
] | null | null | null |
class SDD1 {
public:
void init();
void load();
void unload();
void power();
void reset();
uint8 mmio_read(unsigned addr);
void mmio_write(unsigned addr, uint8 data);
uint8 rom_read(unsigned addr);
uint8 mcu_read(unsigned addr);
void mcu_write(unsigned addr, uint8 data);
void serialize(serializer&);
SDD1();
~SDD1();
private:
uint8 sdd1_enable; //channel bit-mask
uint8 xfer_enable; //channel bit-mask
bool dma_ready; //used to initialize decompression module
unsigned mmc[4]; //memory map controller ROM indices
struct {
unsigned addr; //$43x2-$43x4 -- DMA transfer address
uint16 size; //$43x5-$43x6 -- DMA transfer size
} dma[8];
public:
#include "decomp.hpp"
Decomp decomp;
};
extern SDD1 sdd1;
| 20.891892
| 63
| 0.672704
|
ircluzar
|
b0b000093adb642f54735ea2a74fe24287fb0e96
| 8,291
|
cpp
|
C++
|
Engine/Output/File/FileStatic.cpp
|
gregory-vovchok/YEngine
|
e28552e52588bd90db01dd53e5fc817d0a26d146
|
[
"BSD-2-Clause"
] | null | null | null |
Engine/Output/File/FileStatic.cpp
|
gregory-vovchok/YEngine
|
e28552e52588bd90db01dd53e5fc817d0a26d146
|
[
"BSD-2-Clause"
] | null | null | null |
Engine/Output/File/FileStatic.cpp
|
gregory-vovchok/YEngine
|
e28552e52588bd90db01dd53e5fc817d0a26d146
|
[
"BSD-2-Clause"
] | 1
|
2020-12-04T08:57:03.000Z
|
2020-12-04T08:57:03.000Z
|
#include "File.h"
#include <stdio.h>
#include <io.h>
#include <stdarg.h>
#include <windows.h>
bool File::_IsExist(StringANSI _pathToFile)
{
if(access(_pathToFile.c_str(), 0) == 0)
{
return true;
}
return false;
}
bool File::_CreateFile(StringANSI _pathToFile)
{
if(_IsExist(_pathToFile))
{
return true;
}
else
{
FILE* file = _Open(_pathToFile, File::REWRITE);
if(file)
{
_Close(file);
return true;
}
}
return false;
}
bool File::_Close(FILE* _file)
{
if(_file)
{
if(fclose(_file) == 0)
{
return true;
}
}
return false;
}
bool File::_CreateFolder(StringANSI _path)
{
if(_IsExist(_path)) { return false; }
return (bool)CreateDirectoryA(_path.c_str(), NIL);
}
bool File::_RemoveFolder(StringANSI _path)
{
return (bool)RemoveDirectoryA(_path.c_str());
}
bool File::_CopyFile(StringANSI _pathToFile, StringANSI _targetPath, bool _rewrite)
{
if(_IsExist(_pathToFile))
{
return CopyFileA(_pathToFile.c_str(),
_targetPath.c_str(),
(BOOL)_rewrite);
}
return false;
}
FILE* File::_Open(StringANSI _pathToFile, OpenMode _accessMode)
{
if(_pathToFile.empty()) { return 0; }
switch(_accessMode)
{
case READ:
{
return fopen(_pathToFile.c_str(), "rb");
}
case WRITE:
{
FILE* file = fopen(_pathToFile.c_str(), "r+b");
if(file)
{
_SetPos(file, 0, END);
}
return file;
}
case REWRITE:
{
return fopen(_pathToFile.c_str(), "wb");
}
}
return NIL;
}
bool File::_Remove(StringANSI _pathToFile)
{
if(_IsExist(_pathToFile))
{
if(remove(_pathToFile.c_str()) == 0)
{
return true;
}
}
return false;
}
bool File::_Rename(StringANSI _pathToFile, StringANSI _newName)
{
if(_IsExist(_pathToFile))
{
_newName = _GetName(_newName);
_newName = _GetDir(_pathToFile) + _newName;
if(!_IsExist(_newName))
{
if(rename(_pathToFile.c_str(), _newName.c_str()) == 0)
{
return true;
}
}
}
return false;
}
bool File::_Relocate(StringANSI _pathToFile, StringANSI _newDir, bool _replace)
{
if(_IsExist(_pathToFile))
{
StringANSI pathToNewFile = _GetDir(_newDir) + _GetName(_pathToFile);
if(pathToNewFile == _pathToFile)
{
return false;
}
if(_replace && _IsExist(pathToNewFile))
{
_Remove(pathToNewFile);
}
if(rename(_pathToFile.c_str(), pathToNewFile.c_str()) == 0)
{
return true;
}
}
return false;
}
StringANSI File::_GetSuffix(StringANSI _pathToFile)
{
int32 index = _pathToFile.find_last_of(".");
if(index != -1)
{
return _pathToFile.substr(index + 1, _pathToFile.length() - 1);
}
return "";
}
StringANSI File::_GetBaseName(StringANSI _pathToFile)
{
int32 index = _pathToFile.find_last_of("/\\");
if(index != -1)
{
_pathToFile = _pathToFile.substr(index + 1);
}
index = _pathToFile.find_last_of(".");
if(index != -1)
{
_pathToFile.erase(index, _pathToFile.length() - index);
}
return _pathToFile;
}
StringANSI File::_GetName(StringANSI _pathToFile)
{
int32 index = _pathToFile.find_last_of("/\\");
if(index != -1)
{
return _pathToFile.substr(index + 1);
}
return _pathToFile;
}
StringANSI File::_GetDir(StringANSI _pathToFile)
{
int32 index = _pathToFile.find_last_of("/\\");
if(index != -1)
{
return _pathToFile.substr(0, index + 1);
}
return "";
}
int64 File::_GetPos(FILE* _file)
{
if(_file)
{
int64 pos;
if(fgetpos(_file, &pos) == 0)
{
return pos;
}
}
return -1;
}
void File::_MoveToNewLine(FILE* _file)
{
if(_file)
{
char string[WORD_SIZE];
while(fgets(string, sizeof(string) - 1, _file))
{
if(string[strlen(string) - 1] == '\n')
{
break;
}
}
}
}
int64 File::_GetSize(FILE* _file)
{
if(_file)
{
int64 pos = _GetPos(_file);
if(fseek(_file, 0, SEEK_END) == 0)
{
int64 size = _GetPos(_file);
fseek(_file, pos, SEEK_SET);
return size;
}
}
return -1;
}
int32 File::_ReadString(FILE* _file, StringANSI& _data, int32 _size)
{
if(_file)
{
if(feof(_file))
{
return -1;
}
char* buffer = new char[_size + 1];
int32 symbols = fread(buffer, sizeof(char), _size, _file);
buffer[_size] = '\0';
_data = buffer;
delete []buffer;
return symbols;
}
return 0;
}
bool File::_SetPos(FILE* _file, int32 _newPos, int32 _mode)
{
if(_file)
{
if(fseek(_file, _newPos, _mode) == 0)
{
return true;
}
}
return false;
}
int32 File::_IsEmpty(FILE* _file)
{
if(_file)
{
if(_GetSize(_file) == 0)
{
return 1;
}
return 0;
}
return -1;
}
int32 File::_ReadFile(FILE* _file, StringANSI&_data)
{
if(_file)
{
if(feof(_file))
{
return -1;
}
char symbol;
int32 symbols = 0;
while(fscanf(_file, "%c", &symbol) != EOF)
{
_data += symbol;
++symbols;
}
return symbols;
}
return 0;
}
int32 File::_WriteString(FILE* _file, StringANSI _data)
{
if(_file)
{
int32 result = fprintf(_file, "%s", _data.c_str());
if(result > 0)
{
return result;
}
}
return 0;
}
int32 File::_ReadWord(FILE* _file, StringANSI& _data)
{
if(_file)
{
if(feof(_file))
{
return -1;
}
char string[WORD_SIZE] = { 0 };
if(fscanf(_file, "%s", &string) > EOF)
{
_data = string;
}
return _data.length();
}
return 0;
}
bool File::_GetIntKey(StringANSI _path, bool _relative, StringANSI _section, StringANSI _key, int32& _result)
{
char buffer[256];
if(_relative) { _path = ".\\" + _path; }
if(GetPrivateProfileStringA(_section.c_str(), _key.c_str(), "", buffer, sizeof(buffer), _path.c_str()))
{
_result = atoi(buffer);
return true;
}
return false;
}
bool File::_GetFloatKey(StringANSI _path, bool _relative, StringANSI _section, StringANSI _key, float& _result)
{
char buffer[256];
if(_relative) { _path = ".\\" + _path; }
if(GetPrivateProfileStringA(_section.c_str(), _key.c_str(), "", buffer, sizeof(buffer), _path.c_str()))
{
_result = (float)atof(buffer);
return true;
}
return false;
}
bool File::_GetStringKey(StringANSI _path, bool _relative, StringANSI _section, StringANSI _key, StringANSI& _result)
{
char buffer[256];
if(_relative) { _path = ".\\" + _path; }
if(GetPrivateProfileStringA(_section.c_str(), _key.c_str(), "", buffer, sizeof(buffer), _path.c_str()))
{
_result = buffer;
return true;
}
return false;
}
bool File::_GetBoolKey(StringANSI _path, bool _relative, StringANSI _section, StringANSI _key, bool& _result)
{
char buffer[8];
if(_relative) { _path = ".\\" + _path; }
if(GetPrivateProfileStringA(_section.c_str(), _key.c_str(), "", buffer, sizeof(buffer), _path.c_str()))
{
if(StringANSI("true") == buffer)
{
_result = true;
return true;
}
else if(StringANSI("false") == buffer)
{
_result = false;
return true;
}
}
return false;
}
bool File::_SetIntKey(StringANSI _path, bool _relative, StringANSI _section, StringANSI _key, int32 _value)
{
char buffer[256];
sprintf(buffer, "%d", _value);
if(_relative) { _path = ".\\" + _path; }
if(WritePrivateProfileStringA(_section.c_str(), _key.c_str(), buffer, _path.c_str()))
{
return true;
}
return false;
}
bool File::_SetFloatKey(StringANSI _path, bool _relative, StringANSI _section, StringANSI _key, float _value)
{
char buffer[256];
sprintf(buffer, "%f", _value);
if(_relative) { _path = ".\\" + _path; }
if(WritePrivateProfileStringA(_section.c_str(), _key.c_str(), buffer, _path.c_str()))
{
return true;
}
return false;
}
bool File::_SetStringKey(StringANSI _path, bool _relative, StringANSI _section, StringANSI _key, StringANSI _value)
{
char buffer[256];
sprintf(buffer, "%s", _value.c_str());
if(_relative) { _path = ".\\" + _path; }
if(WritePrivateProfileStringA(_section.c_str(), _key.c_str(), buffer, _path.c_str()))
{
return true;
}
return false;
}
bool File::_SetBoolKey(StringANSI _path, bool _relative, StringANSI _section, StringANSI _key, bool _value)
{
char trueString[] = "true";
char falseString[] = "false";
if(_relative) { _path = ".\\" + _path; }
if(_value)
{
if(WritePrivateProfileStringA(_section.c_str(), _key.c_str(), trueString, _path.c_str()))
{
return true;
}
}
else
{
if(WritePrivateProfileStringA(_section.c_str(), _key.c_str(), falseString, _path.c_str()))
{
return true;
}
}
return false;
}
| 15.129562
| 117
| 0.643228
|
gregory-vovchok
|
b0b348de18d63bf8d117f4d56cce92132db6995f
| 2,779
|
cc
|
C++
|
SDL2pp/Rect.cc
|
Ritan/libSDL2pp
|
466d9a1683c155ae7cabf67870983e0fe04574ee
|
[
"Zlib"
] | null | null | null |
SDL2pp/Rect.cc
|
Ritan/libSDL2pp
|
466d9a1683c155ae7cabf67870983e0fe04574ee
|
[
"Zlib"
] | null | null | null |
SDL2pp/Rect.cc
|
Ritan/libSDL2pp
|
466d9a1683c155ae7cabf67870983e0fe04574ee
|
[
"Zlib"
] | null | null | null |
/*
libSDL2pp - C++ wrapper for libSDL2
Copyright (C) 2013 Dmitry Marakasov <amdmi3@amdmi3.ru>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <cassert>
#include <SDL2pp/Rect.hh>
namespace SDL2pp {
Rect::Rect() : valid_(false) {
}
Rect::~Rect() {
}
Rect::Rect(int x, int y, int w, int h) : valid_(true) {
rect_.x = x;
rect_.y = y;
rect_.w = w;
rect_.h = h;
}
Rect Rect::Null() {
return Rect();
}
bool Rect::operator==(const Rect& other) const {
if (!valid_ || !other.valid_)
return valid_ == other.valid_; // true only if both null
return rect_.x == other.rect_.x && rect_.y == other.rect_.y &&
rect_.w == other.rect_.w && rect_.h == other.rect_.h;
}
bool Rect::operator!=(const Rect& other) const {
return !(*this == other);
}
SDL_Rect* Rect::Get() {
return valid_ ? &rect_ : nullptr;
}
const SDL_Rect* Rect::Get() const {
return valid_ ? &rect_ : nullptr;
}
Rect Rect::FromCenter(int cx, int cy, int w, int h) {
return Rect(cx - w/2, cy - h/2, w, h);
}
Rect Rect::FromLTRB( int x1, int y1, int x2, int y2 )
{
return Rect( x1, y1, x2 - x1, y2 - y1 );
}
bool Rect::IsNull() const {
return !valid_;
}
int Rect::GetX() const {
assert(!IsNull());
return rect_.x;
}
void Rect::SetX(int x) {
assert(!IsNull());
rect_.x = x;
}
int Rect::GetY() const {
assert(!IsNull());
return rect_.y;
}
void Rect::SetY(int y) {
assert(!IsNull());
rect_.y = y;
}
int Rect::GetW() const {
assert(!IsNull());
return rect_.w;
}
void Rect::SetW(int w) {
assert(!IsNull());
rect_.w = w;
}
int Rect::GetH() const {
assert(!IsNull());
return rect_.h;
}
void Rect::SetH(int h) {
assert(!IsNull());
rect_.h = h;
}
int Rect::GetX2() const {
assert(!IsNull());
return rect_.x + rect_.w - 1;
}
void Rect::SetX2(int x2) {
assert(!IsNull());
rect_.w = x2 - rect_.x + 1;
}
int Rect::GetY2() const {
assert(!IsNull());
return rect_.y + rect_.h - 1;
}
void Rect::SetY2(int y2) {
assert(!IsNull());
rect_.h = y2 - rect_.y + 1;
}
}
| 20.137681
| 76
| 0.654552
|
Ritan
|
b0b79cce1ac1108fbe7231b4a4cfec719081fb68
| 2,657
|
cpp
|
C++
|
constrdestr.cpp
|
jollie-fin/cpp_lessons
|
f7aed25215b890236660ec2b9a63a41ba65d978e
|
[
"MIT"
] | null | null | null |
constrdestr.cpp
|
jollie-fin/cpp_lessons
|
f7aed25215b890236660ec2b9a63a41ba65d978e
|
[
"MIT"
] | null | null | null |
constrdestr.cpp
|
jollie-fin/cpp_lessons
|
f7aed25215b890236660ec2b9a63a41ba65d978e
|
[
"MIT"
] | null | null | null |
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <deque>
struct Obj
{
Obj()
{
i_ = current_id_++;
std::cout << "Construct Obj(" << i_ << ")\n";
}
Obj(const Obj& obj)
{
i_ = current_id_++;
std::cout << "Construct Obj(" << i_ << ") from Obj(" << obj.i_ << ")\n";
}
~Obj()
{
std::cout << "Destruct Obj(" << i_ << ")\n";
}
int i_;
static int current_id_;
};
int Obj::current_id_{0};
template <typename MAP>
auto prefix(const MAP &map, std::string key)
{
std::string after = key;
if (after.empty())
{
return std::make_pair(map.begin(), map.end());
}
else if (after.back() != 255)
{
after.back()++;
}
else
{
throw std::runtime_error("I'm lazy today");
}
return std::make_pair(map.lower_bound(key), map.lower_bound(after));
}
void dummy2()
{
throw std::runtime_error("test");
}
void dummy()
{
Obj obj1;
Obj obj2;
Obj obj3 = obj2;
dummy2();
Obj obj4;
}
int main()
{
std::map<std::string, int> table;
table["a"] = 3;
table["aabca"] = 6;
table["aabd"] = 4;
table["aabc"] = 5;
table["ac"] = 7;
table.emplace("aabde", 3);
{
auto it = table.find("a");
if (it == table.end())
std::cout << "not found" << std::endl;
else
std::cout << it->first << "," << it->second << std::endl;
}
for (const auto &[key, v] : table)
{
std::cout << key << "," << v << std::endl;
}
{
auto begin = table.lower_bound("aa");
auto end = table.lower_bound("ab");
for (auto it = begin; it != end; it++)
{
std::cout << it->first << "," << it->second << std::endl;
}
}
{
std::multimap<std::string, int> table2;
table2.emplace("aa", 3);
table2.emplace("ab", 4);
table2.emplace("aa", 5);
table2.emplace("aa", 6);
auto [begin,end] = table2.equal_range("aa");
for (auto it = begin; it != end; it++)
{
std::cout << it->first << "," << it->second << std::endl;
}
}
{
auto [begin,end] = prefix(table, "");
for (auto it = begin; it != end; it++)
{
std::cout << it->first << "," << it->second << std::endl;
}
}
try
{
dummy();
}
catch(const std::exception& e)
{
std::cerr << "Caught " << e.what() << '\n';
}
// std::map : comparaison = O(log(taille))
// trie : O(key_length)
}
/*
Functions + static
Tas
Pile ^
*/
| 18.19863
| 80
| 0.461423
|
jollie-fin
|
b0b7b9cc6b240d485ab97b3be250e625f2725c82
| 8,084
|
cpp
|
C++
|
Button.cpp
|
jrullan/Touchscreen_GUI
|
6512ef057f4bbe674b0c01d3739304f0a65f533a
|
[
"MIT"
] | 2
|
2015-06-30T17:08:32.000Z
|
2020-05-26T18:07:30.000Z
|
Button.cpp
|
jrullan/Touchscreen_GUI
|
6512ef057f4bbe674b0c01d3739304f0a65f533a
|
[
"MIT"
] | null | null | null |
Button.cpp
|
jrullan/Touchscreen_GUI
|
6512ef057f4bbe674b0c01d3739304f0a65f533a
|
[
"MIT"
] | null | null | null |
///////////////////////////////////////////////////////////
// Button.cpp
// Implementation of the Class Button
// Created on: 02-Mar-2015 9:17:12 PM
///////////////////////////////////////////////////////////
/*
* Sensible defaults mods:
* 1. Provide simple constructor, no parameters
* 2. Allow to have no event handler for touch events (early return in the checkTouch method)
* 3. Set initial x, y, fgColor, bgColor, borderColor
* 4. Set initial w and h
* 5. Set initial fontSize
* 6. Set initial debounce delay
*/
#include "Button.h"
/*
* Basic Constructor, no parameters
*/
Button::Button(){
contents = new Text(8);
init();
}
/*
* Constructor with initial "Text" and optional "Label"
*/
Button::Button(char* text, char* _label){
contents = new Text(Widget::getTextLength(text));
init();
if(_label){
setLabel(_label);
}
setText(text);
}
/**
* Constructor for a typical rectangle button
*/
Button::Button(unsigned int width, unsigned int height, int backgroundColor, int textColor, int borderColor,unsigned char textLength){
contents = new Text(textLength);
init();
this->setSize(width,height);
this->setColors(backgroundColor,textColor,borderColor);
}
/**
* Constructor for a round button
*/
Button::Button(unsigned int radius, int backgroundColor, int textColor, int borderColor){
contents = new Text(8);
init();
this->isRound = true;
x = radius;
y = radius;
this->setSize(2*radius,2*radius);
this->setColors(backgroundColor,textColor,borderColor);
}
Button::~Button(){
free(contents->text);
free(label);
}
/**
* Initialization of several common parameters
*/
void Button::init(){
type = 0x30;
debounceTime = 500;
isButton = true;
isRound = false;
touched = false;
borderWidth = 2;
bgColor = GRAY1;
fgColor = BLACK;
borderColor = WHITE;
setSize(100,40);
setText("Button");
x = 0;
y = 0;
lastMillis = millis();
}
/**
* Draws the background of the button
*/
void Button::drawBackground(int color){
int labelWidth = getLabelSize();
int xl;
int wl;
// Label Background
if(labelPos == LABEL_TOP){
}else if(labelPos == LABEL_RIGHT){
xl = x;
wl = w;
}else if(labelPos == LABEL_BOTTOM){
}else{ // labelPos == LABEL_LEFT
xl = x + labelWidth;
wl = w;
}
// Button background
if(!this->isRound){
if(cornerRadius > 0){
//myCanvas->tft->fillRoundRect(xl+borderWidth, y+borderWidth, wl-(2*borderWidth),h-(2*borderWidth),cornerRadius,color);
myCanvas->tft->fillRoundRect(x+borderWidth, y+borderWidth, wl-(2*borderWidth),h-(2*borderWidth),cornerRadius,color);
}else{
//myCanvas->tft->fillRect(xl+borderWidth, y+borderWidth, wl-(2*borderWidth),h-(2*borderWidth),color);
myCanvas->tft->fillRect(x+borderWidth, y+borderWidth, wl-(2*borderWidth),h-(2*borderWidth),color);
}
}else{
int radius = (w>>1)-borderWidth;
//myCanvas->tft->fillCircle(xl+radius+borderWidth,y+radius+borderWidth,radius,color);//radius-borderWidth/2,color);
myCanvas->tft->fillCircle(x+radius+borderWidth,y+radius+borderWidth,radius,color);//radius-borderWidth/2,color);
}
}
/**
* Draws the text inside the button
*/
void Button::drawText(){
int labelWidth=getLabelSize();
// Draw contents text
if(*contents->text){
char length = getTextLength(contents->text);//contents.getTextSize();
//int stringX = getCenterTextX(x+labelWidth,w,length);
int stringX = getCenterTextX(x,w,length);
int stringY = getCenterTextY(y,h);
myCanvas->tft->drawString(contents->text,stringX,stringY,fontSize,fgColor);
}
}
/**
* Draws the border of the button
*/
void Button::drawBorder(){
int labelWidth = getLabelSize();
int xl;
if(labelPos == LABEL_TOP){
}else if(labelPos == LABEL_RIGHT){
xl = x;// + labelWidth;
}else if(labelPos == LABEL_BOTTOM){
}else{ // LABEL_LEFT
xl = x + labelWidth;
}
//int xPos = xl;
int xPos = x;
int width = w;
int yPos = y;
uint8_t height = h;
for(byte i=borderWidth; i!=0;i--){
if(!this->isRound){
if(cornerRadius > 0){
myCanvas->tft->drawRoundRect(xPos++,yPos++,width--,height--,cornerRadius,borderColor);
}else{
myCanvas->tft->drawRect(xPos++,yPos++,width--,height--,borderColor);
}
width--;
height--;
}else{
int radius = width>>1;
myCanvas->tft->drawCircle(xl+radius,y+radius,(radius)-i,borderColor);
}
}
}
/**
* Draws a label for the button if one is set
* Maximum length is DISPLAY_SIZE
*/
void Button::drawLabel(){
int xl=0;
int yl=0;
int labelWidth=getLabelSize();
int labelHeight = fontSize * FONT_Y;
// Draw label
if(labelWidth > 0){
if(labelPos == LABEL_TOP){ // top
}else if(labelPos == LABEL_RIGHT){ // right
xl = x + w + FONT_SPACE*fontSize/2;
yl = y+(h-labelHeight)/2;
}else if(labelPos == LABEL_BOTTOM){ // bottom
}else{ // default LABEL_LEFT
xl = x-(labelWidth + FONT_SPACE*fontSize/2);
yl = y+(h-labelHeight)/2;
}
//Check label is within screen area
if(xl > 0 && xl <= (myCanvas->w - labelWidth) && yl>0 && yl <= (myCanvas->h - labelHeight)){
myCanvas->tft->drawString(label,xl,yl,fontSize,fgColor);
}else{ // if not within screen area draw a red rectangle around the button as a warning
myCanvas->tft->fillRect(x-4,y-4,w+8,h+8,RED);
}
}
}
/**
* Shows the widget on the screen. This method must be overriden by the widget to
* show the particular widget. It should be a pure virtual function: (i.e. virtual
* void function() = 0;
*/
void Button::show(){
drawLabel();
drawBackground(bgColor);
update();
}
/**
* OVERRIDEN - This is the update() method.
*/
void Button::update(){
drawText();
drawBorder();
}
/**
* OVERRIDEN - Check if the touched point is within bounds of this widget.
*/
bool Button::checkTouch(Point* p){
// Early exit if no event handler was defined
if(!*eventHandler) return false;
int labelWidth = getLabelSize();
int xl = x;
/*
if(labelPos == LABEL_TOP){
}else if(labelPos == LABEL_RIGHT){
xl = x;
}else if(labelPos == LABEL_BOTTOM){
}else{ // LABEL_LEFT
xl = x + labelWidth;
}
*/
if(lastMillis + debounceTime < millis()){
if((p->x > xl) && (p->x < xl+w) && (p->y > y) && (p->y < y+h)){
lastMillis = millis();
touched = !touched;
eventHandler(this);
return false;
}
}
// if block is true return false, so canvas will not continue to
// process the event.
return !block;
}
/**
* Gets the label size, used for redrawing
*/
int Button::getLabelSize(){
if(label){ // if initialized...
return getTextLength(label)*FONT_X*fontSize;// + 6;
}
return 0;
}
/**
* Sets the button debouncing delay
*/
void Button::setDebounce(unsigned int d){
debounceTime = d;
}
/**
* Sets the event handler: The function that should be called whenever the touched
* event is detected.
*/
void Button::setEventHandler(void (*functionPointer)(Button *)){
eventHandler = functionPointer;
}
/*
* See notes in Text.cpp
void Button::setNum(int num){
if(contents->getNum()==num)return;
contents->clear();
contents->setNum(num);
}
*/
void Button::setText(char* _text){
//contents->text = _text;
contents->setText(_text);
}
void Button::setText(const char* _text){
//contents->text = _text;
contents->setText(_text);
}
void Button::setLabel(char* _label){
if(!*label){ // if not already set (initialized...)
int labelSize = Widget::getTextLength(_label);
if(label = (char *)malloc(labelSize+1)){
memset(label,0,labelSize+1);
label = _label;
}
}
}
char* Button::getText(){
return contents->text;
}
long Button::getNum(){
return contents->getNum();
}
void Button::fitToText(){
if(*contents->text){
char length = getTextLength(contents->text);//contents.getTextSize();
w = length * FONT_X * fontSize + FONT_SPACE;
h = FONT_Y * fontSize + FONT_Y;
}
}
| 23.568513
| 135
| 0.62766
|
jrullan
|
b0b86610e0e469bdcdd3845db6e3c6aa3cd2453e
| 10,385
|
hpp
|
C++
|
mpmissions/Altis_Life.Altis/dialog/smartphone.hpp
|
Mateuus/A3UndeadBRLife
|
2c4558c3cf66795bcfa126e3fe460a9b671d3ca9
|
[
"OpenSSL"
] | null | null | null |
mpmissions/Altis_Life.Altis/dialog/smartphone.hpp
|
Mateuus/A3UndeadBRLife
|
2c4558c3cf66795bcfa126e3fe460a9b671d3ca9
|
[
"OpenSSL"
] | null | null | null |
mpmissions/Altis_Life.Altis/dialog/smartphone.hpp
|
Mateuus/A3UndeadBRLife
|
2c4558c3cf66795bcfa126e3fe460a9b671d3ca9
|
[
"OpenSSL"
] | null | null | null |
class smartphone
{
idd = 90000;
movingEnable = false;
enableSimulation = false;
class controlsBackground {
class Life_RscPicture_1200: Life_RscPictureKeepAspect{
idc = 1200;
text = "icons\Background.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1201: Life_RscPicture{
idc = 1201;
text = "icons\Info.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1202: Life_RscPicture{
idc = 1202;
text = "icons\iGang.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class iGang_Overlay: Life_RscPicture{
idc = 12021;
text = "icons\iGang_Overlay.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1203: Life_RscPicture{
idc = 1203;
text = "icons\Backpack.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1204: Life_RscPicture{
idc = 1204;
text = "icons\Banking.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1205: Life_RscPicture{
idc = 1205;
text = "icons\Actions.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1206: Life_RscPicture{
idc = 1206;
text = "icons\Crafting.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Crafting_Overlay: Life_RscPicture{
idc = 12061;
text = "icons\Crafting_Overlay.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1207: Life_RscPicture{
idc = 1207;
text = "icons\Barriers.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Barriers_Overlay: Life_RscPicture{
idc = 12071;
text = "icons\Barriers_Overlay.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1208: Life_RscPicture{
idc = 1208;
text = "icons\Keys.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1209: Life_RscPicture{
idc = 1209;
text = "icons\Licenses.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1210: Life_RscPicture{
idc = 1210;
text = "icons\Market.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Market_Overlay: Life_RscPicture{
idc = 12101;
text = "icons\Market_Overlay.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1211: Life_RscPicture{
idc = 1211;
text = "icons\Messages.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1212: Life_RscPicture{
idc = 1212;
text = "icons\Settings.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1213: Life_RscPicture{
idc = 1213;
text = "icons\Skills.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Skills_Overlay: Life_RscPicture{
idc = 12131;
text = "icons\Skills_Overlay.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1214: Life_RscPicture{
idc = 1214;
text = "icons\Sync_Data.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1215: Life_RscPicture{
idc = 1215;
text = "icons\Taxi.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Taxi_Overlay: Life_RscPicture{
idc = 12151;
text = "icons\Taxi_Overlay.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1216: Life_RscPicture{
idc = 1216;
text = "icons\Terror.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Terror_Overlay: Life_RscPicture{
idc = 12161;
text = "icons\Terror_Overlay.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class Life_RscPicture_1217: Life_RscPicture{
idc = 1217;
text = "icons\Wanted.paa";
x = -0.0625;
y = -0.3;
w = 1.1375;
h = 1.5;
colorBackground[] = {0, 0, 0, 0};
};
class RscPicture_1202: Life_RscPicture{idc = 1218;text = "icons\Admin.paa";x = -0.0625;y = -0.3;w = 1.1375;h = 1.5;colorBackground[] = {0, 0, 0, 0};};
class Admin_Overlay: Life_RscPicture{idc = 12181;text = "icons\AdminRequestOverlay.paa";x = -0.0625;y = -0.3;w = 1.1375;h = 1.5;colorBackground[] = {0, 0, 0, 0};};
class RscPicture_1203: Life_RscPicture{idc = 1219;text = "icons\CallBackup.paa";x = -0.0625;y = -0.3;w = 1.1375;h = 1.5;colorBackground[] = {0, 0, 0, 0};};
class CallBackup_Overlay: Life_RscPicture{idc = 12191;text = "icons\CallBackupOverlay.paa";x = -0.0625;y = -0.3;w = 1.1375;h = 1.5;colorBackground[] = {0, 0, 0, 0};};};
class controls {
class Life_RscButtonInvisible_2400: Life_RscButtonInvisible{
idc = 2400;
onButtonClick = "createDialog ""Life_key_management"";";
tooltip = "View and share your car keys";
x = 0.3375;
y = 0.14;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2401: Life_RscButtonInvisible{
idc = 2401;
onButtonClick = "if(isNil ""life_action_gangInUse"") then {if(isNil {(group player) getVariable ""gang_owner""}) then {createDialog ""Life_Create_Gang_Diag"";} else {[] spawn life_fnc_gangMenu;};};";
tooltip = "Here you can create a gang and manage it";
x = 0.425;
y = 0.14;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2402: Life_RscButtonInvisible{
idc = 2402;
onButtonClick = "if(playerside !=west) then {hint ""You are not a police officer""; } else {[] execVM 'core\functions\fn_lockDown.sqf'};";
tooltip = "Police Only: Announce Lockdown";
x = 0.525;
y = 0.14;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2403: Life_RscButtonInvisible{
idc = 2403;
onButtonClick = "createDialog ""life_inventory_menu"";";
tooltip = "View and manage your virtual items in your inventory";
x = 0.625;
y = 0.14;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2404: Life_RscButtonInvisible{
idc = 2404;
onButtonClick = "if(playerside !=civilian) then {hint ""You are not a civilian""; } else { createDialog ""Life_craft""};";
tooltip = "Crafting Menu";
x = 0.3375;
y = 0.28;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2405: Life_RscButtonInvisible{
idc = 2405;
onButtonClick = "createDialog ""life_dynmarket_prices"";";
tooltip = "Bolsa de Valores";
x = 0.4375;
y = 0.28;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2406: Life_RscButtonInvisible{
idc = 2406;
onButtonClick = "createDialog ""life_skillMenu"";";
tooltip = "Feature Disabled but will be coming soon!";
x = 0.525;
y = 0.28;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2407: Life_RscButtonInvisible{
idc = 2407;
onButtonClick = "createDialog ""life_license_menu"";";
tooltip = "Check your licenses";
x = 0.625;
y = 0.28;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2408: Life_RscButtonInvisible{
idc = 2408;
onButtonClick = "if(side player isEqualTo west) then {[] call life_fnc_wantedMenu;} else {[] call life_fnc_wantedMenuCiv;}";
tooltip = "View the list of current criminals";
x = 0.3375;
y = 0.4;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2409: Life_RscButtonInvisible{
idc = 2409;
onButtonClick = "[] spawn life_fnc_openMenu";
tooltip = "Feature Disabled but will be coming soon!";
x = 0.4375;
y = 0.4;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2410: Life_RscButtonInvisible{
idc = 2410;
onButtonClick = "if(side player isEqualTo west) then {[] spawn life_fnc_placeablesMenu;} else {if(side player isEqualTo independent) then {[] spawn life_fnc_medicplaceablesMenu;} else {hint ""Você não é policial ou medico""; }}";
tooltip = "Colocar Barricadas";
x = 0.525;
y = 0.4;
w = 0.0625;
h = 0.1;
};
class Life_RscButtonInvisible_2411: Life_RscButtonInvisible{idc = 2411;onButtonClick = "createDialog ""life_moves_menu"";";tooltip = "Make your character preform actions";x = 0.625;y = 0.4;w = 0.0625;h = 0.1;};
class Life_RscButtonInvisible_2412: Life_RscButtonInvisible{idc = 2412;onButtonClick ="[] spawn life_fnc_InfoMenu;";tooltip = "Painel de Informações Undead Brasil";x = 0.3375;y = 0.54;w = 0.0625;h = 0.1;};
class Life_RscButtonInvisible_2413: Life_RscButtonInvisible{idc = 2413;onButtonClick = "[] spawn CHVD_fnc_openDialog;";tooltip = "Modify your view settings";x = 0.3375;y = 0.8;w = 0.0625;h = 0.1;};
class Life_RscButtonInvisible_2414: Life_RscButtonInvisible{idc = 2414;onButtonClick = "[] call SOCK_fnc_syncData;";tooltip = "Save your data to the server";x = 0.425;y = 0.8;w = 0.0625;h = 0.1;};
class Life_RscButtonInvisible_2415: Life_RscButtonInvisible{idc = 2415;onButtonClick = "createDialog ""life_money_menu"";";tooltip = "Check and exchange your money";x = 0.525;y = 0.8;w = 0.0625;h = 0.1;};
class Life_RscButtonInvisible_2416: Life_RscButtonInvisible{idc = 2416;onButtonClick = "createDialog ""Life_cell_phone"";";tooltip = "Send messages to other players or emergency services";x = 0.625;y = 0.8;w = 0.0625;h = 0.1;};
class Life_RscButtonInvisible_2417: Life_RscButtonInvisible{idc = 2417;onButtonClick = "closeDialog 0;";tooltip = "Put Away Phone";x = 0.4;y = 0.92;w = 0.225;h = 0.06;};
class RscButtonMenu_AdminMenu: Life_RscButtonInvisible{idc = 2418;tooltip = "Open Admin Menu";onButtonClick = "createDialog ""life_admin_menu"";";x = 0.425;y = 0.54;w = 0.075;h = 0.08;};
class RscButtonMenu_CallBackup: Life_RscButtonInvisible{idc = 2419;onButtonClick = "[] call life_fnc_callbackup";tooltip = "Call Backup to Your Current Location";x = 0.525;y = 0.54;w = 0.0625;h = 0.08;};};};
| 29.841954
| 232
| 0.63091
|
Mateuus
|
b0bb3b25e1e4d5899ce7a828510dabbd1f9964f6
| 3,431
|
hpp
|
C++
|
rtb/base/include/base/json/Json.hpp
|
SMelanko/rtb
|
9bc909ea1ea169043661f2c89cb91415fec73065
|
[
"MIT"
] | null | null | null |
rtb/base/include/base/json/Json.hpp
|
SMelanko/rtb
|
9bc909ea1ea169043661f2c89cb91415fec73065
|
[
"MIT"
] | null | null | null |
rtb/base/include/base/json/Json.hpp
|
SMelanko/rtb
|
9bc909ea1ea169043661f2c89cb91415fec73065
|
[
"MIT"
] | 1
|
2018-12-31T21:52:19.000Z
|
2018-12-31T21:52:19.000Z
|
#pragma once
#include "base/stl/String.hpp"
#include "base/Type.hpp"
#include <rapidjson/document.h>
#include <fmt/format.h>
namespace json
{
using Document = rapidjson::Document;
using Object = rapidjson::Value;
json::Document Str2Json(base::StringView str);
template<class T>
void ExtBool(const json::Object& j, base::StringView field, T& data)
{
auto name = field.data();
if (j.HasMember(name)) {
if (!j[name].IsInt() && !j[name].IsBool()) {
throw std::runtime_error{ fmt::format("Invalid type of \"{}\" field, expected int/bool", field) };
}
data = (j[name].IsInt()) ? static_cast<base::Bool>(j[name].GetInt()) : j[name].GetBool();
}
}
template<class T>
void ExtDouble(const json::Object& j, base::StringView field, T& data)
{
if (j.HasMember(field.data())) {
if (!j[field.data()].IsNumber()) {
throw std::runtime_error{ fmt::format("Invalid type of \"{}\" field, expected number", field) };
}
data = j[field.data()].GetDouble();
}
}
template<class T>
void ExtEnum(const json::Object& j, base::StringView field, T& data)
{
if (j.HasMember(field.data())) {
if (!j[field.data()].IsInt()) {
throw std::runtime_error{ fmt::format("Invalid type of \"{}\" field, expected int", field) };
}
// TODO: Validate int value.
data = static_cast<T>(j[field.data()].GetInt());
}
}
template<class T>
void ExtInt(const json::Object& j, base::StringView field, T& data)
{
if (j.HasMember(field.data())) {
if (!j[field.data()].IsInt()) {
throw std::runtime_error{ fmt::format("Invalid type of \"{}\" field, expected int", field) };
}
data = j[field.data()].GetInt();
}
}
template<class T>
void ExtReqStr(const json::Object& j, base::StringView field, T& data)
{
if (!j.HasMember(field.data())) {
throw std::runtime_error{ fmt::format("Required \"{}\" field is missing", field) };
}
if (!j[field.data()].IsString()) {
throw std::runtime_error{ fmt::format("Invalid type of \"{}\" field, expected string", field) };
}
data = j[field.data()].GetString();
}
template<class T>
void ExtStr(const json::Object& j, base::StringView field, T& data)
{
if (j.HasMember(field.data())) {
if (!j[field.data()].IsString()) {
throw std::runtime_error{ fmt::format("Invalid type of \"{}\" field, expected string", field) };
}
data = j[field.data()].GetString();
}
}
template<class T>
void ExtVecEnum(const json::Object& j, base::StringView field, T& data)
{
auto name = field.data();
if (j.HasMember(name) && j[name].IsArray()) {
const auto& arr = j[name];
if (const auto size = arr.Size(); (size > 0)) {
data.reserve(size);
for (const auto& val : arr.GetArray()) {
data.push_back(static_cast<typename T::value_type>(val.GetInt()));
}
}
}
}
template<class C>
void ExtVecStr(const json::Object& j, base::StringView field, C& data)
{
auto name = field.data();
if (j.HasMember(name) && j[name].IsArray()) {
const auto& arr = j[name];
if (const auto size = arr.Size(); (size > 0)) {
data.reserve(size);
for (const auto& val : arr.GetArray()) {
data.emplace_back(val.GetString());
}
}
}
}
} // namespace json
| 29.076271
| 110
| 0.578257
|
SMelanko
|
b0bd295fa9381d383e32799b94cb1ed12aa80e84
| 302
|
cpp
|
C++
|
toy_compiler/munster/ast/decl/dot_decl.cpp
|
Wmbat/toy_compiler
|
370a2e76aaaa874de5fb6c25e0755638dd84b8b4
|
[
"MIT"
] | null | null | null |
toy_compiler/munster/ast/decl/dot_decl.cpp
|
Wmbat/toy_compiler
|
370a2e76aaaa874de5fb6c25e0755638dd84b8b4
|
[
"MIT"
] | null | null | null |
toy_compiler/munster/ast/decl/dot_decl.cpp
|
Wmbat/toy_compiler
|
370a2e76aaaa874de5fb6c25e0755638dd84b8b4
|
[
"MIT"
] | null | null | null |
#include <toy_compiler/munster/ast/decl/dot_decl.hpp>
namespace munster::ast
{
dot_decl::dot_decl(const std::string& lexeme, const source_location& location) :
decl{lexeme, location}
{}
auto dot_decl::to_string() const -> std::string { return "dot_decl"; }
} // namespace munster::ast
| 27.454545
| 83
| 0.705298
|
Wmbat
|
b0be422c7ce645a8d0c9d8a5e55bd7ccb7146312
| 1,286
|
cpp
|
C++
|
N0239-Sliding-Window-Maximum/solution1.cpp
|
loyio/leetcode
|
366393c29a434a621592ef6674a45795a3086184
|
[
"CC0-1.0"
] | null | null | null |
N0239-Sliding-Window-Maximum/solution1.cpp
|
loyio/leetcode
|
366393c29a434a621592ef6674a45795a3086184
|
[
"CC0-1.0"
] | null | null | null |
N0239-Sliding-Window-Maximum/solution1.cpp
|
loyio/leetcode
|
366393c29a434a621592ef6674a45795a3086184
|
[
"CC0-1.0"
] | 2
|
2022-01-25T05:31:31.000Z
|
2022-02-26T07:22:23.000Z
|
//
// main.cpp
// LeetCode-Solution
//
// Created by Loyio Hex on 3/1/22.
//
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
using namespace std;
using namespace std::chrono;
class Solution {
public:
vector<int> maxSlidingWindow(vector<int>& nums, int k){
int len = nums.size();
priority_queue<pair<int, int>> que;
for (int i = 0; i < k; ++i) {
que.emplace(nums[i], i);
}
vector<int> res_array = {que.top().first};
for (int i = k; i < len; ++i) {
que.emplace(nums[i], i);
while (que.top().second <= i-k){
que.pop();
}
res_array.push_back(que.top().first);
}
return res_array;
}
};
int main(int argc, const char * argv[]) {
auto start = high_resolution_clock::now();
// Main Start
vector<int> nums = {1,3,-1,-3,5,3,6,7};
int k = 3;
Solution solution;
vector<int> res = solution.maxSlidingWindow(nums, k);
for (int num:res) {
cout << num << " ";
}
// Main End
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
cout << endl << "Runnig time : " << duration.count() << "ms;" << endl;
return 0;
}
| 23.381818
| 74
| 0.540435
|
loyio
|
b0c03be262009bc94b875ea9c452bc95b26b89cf
| 2,000
|
cpp
|
C++
|
Graphs/Hopcroft-Karp.cpp
|
4eyes4u/Algorithms
|
afd8363ee39e5b7c499741f56922f16f4f50dc09
|
[
"MIT"
] | 2
|
2019-02-16T13:13:40.000Z
|
2019-03-19T20:05:42.000Z
|
Graphs/Hopcroft-Karp.cpp
|
4eyes4u/Algorithms
|
afd8363ee39e5b7c499741f56922f16f4f50dc09
|
[
"MIT"
] | null | null | null |
Graphs/Hopcroft-Karp.cpp
|
4eyes4u/Algorithms
|
afd8363ee39e5b7c499741f56922f16f4f50dc09
|
[
"MIT"
] | 1
|
2020-07-03T06:15:41.000Z
|
2020-07-03T06:15:41.000Z
|
/*
Name: Hopcroft-Karp algorithm
Time complexity: O(M * sqrt(N))
Space complexity: O(N + M)
* * *
Test problem: https://www.spoj.com/problems/MATCHING/
*/
#include <vector>
#include <iostream>
#include <queue>
const int N = 1e5 + 10;
const int INF = 1e9;
// NONE is sentinel for unpaired nodes
const int NONE = 0;
std::vector<int> g[N];
int match[N], dist[N];
bool bfs(const int &nu) {
std::queue<int> q;
for (int i = 1; i <= nu; i++) {
if (match[i] == NONE) {
dist[i] = 0;
q.emplace(i);
}
else dist[i] = INF;
}
dist[NONE] = INF;
while (!q.empty()) {
int node = q.front();
q.pop();
if (node != NONE) {
for (const int &xt : g[node]) {
// if match[xt] is not visited path is alternating
if (dist[match[xt]] == INF) {
dist[match[xt]] = dist[node] + 1;
q.emplace(match[xt]);
}
}
}
}
return dist[NONE] != INF;
}
bool dfs(int u) {
if (u != NONE) {
for (const int &v : g[u]) {
if (dist[match[v]] == dist[u] + 1) {
if (dfs(match[v])) {
match[u] = v;
match[v] = u;
return true;
}
}
}
dist[u] = INF;
return false;
}
// full augmented path is obtained
return true;
}
int HopcroftKarp(const int &nu) {
int matching = 0;
while (bfs(nu)) {
for (int i = 1; i <= nu; i++)
if (match[i] == NONE && dfs(i))
matching++;
}
return matching;
}
int main() {
std::ios_base::sync_with_stdio(false);
int nu, nv, m;
std::cin >> nu >> nv >> m;
for (int i = 0, u, v; i < m; i++) {
std::cin >> u >> v;
g[u].emplace_back(v + nu);
g[v + nu].emplace_back(u);
}
std::cout << HopcroftKarp(nu) << std::endl;
return 0;
}
| 21.505376
| 66
| 0.4415
|
4eyes4u
|
b0c250756c8a7941663028640a1e00abff96e269
| 45,648
|
cpp
|
C++
|
src/cli.cpp
|
tschiemer/midimessage
|
d4cd58712a8f2db0c0b8326db64f913ca24165ba
|
[
"MIT"
] | 1
|
2021-12-21T17:08:25.000Z
|
2021-12-21T17:08:25.000Z
|
src/cli.cpp
|
tschiemer/midimessage
|
d4cd58712a8f2db0c0b8326db64f913ca24165ba
|
[
"MIT"
] | null | null | null |
src/cli.cpp
|
tschiemer/midimessage
|
d4cd58712a8f2db0c0b8326db64f913ca24165ba
|
[
"MIT"
] | 1
|
2021-11-05T16:43:46.000Z
|
2021-11-05T16:43:46.000Z
|
/**
*
*/
#include <stdio.h>
//#include <cstdarg>
#include <stdlib.h>
//#include <stdlib.h>
//#include <string.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/time.h>
#include <time.h>
#include <util-hex.h>
#include <midimessage/midimessage.h>
#include <midimessage/stringifier.h>
#include <midimessage/parser.h>
#include <midimessage/commonccs.h>
using namespace std;
using namespace MidiMessage;
///////// Defines
typedef enum {
ModeUndefined = 0,
ModeParse = 1,
ModeGenerate = 2,
ModeConvert = 3
} Mode_t;
inline bool isValidMode( Mode_t mode ){
return (mode == ModeParse ||
mode == ModeGenerate ||
mode == ModeConvert
);
}
typedef enum {
ProcessNibblize,
ProcessDeNibblize,
ProcessSevenbitize,
ProcessDeSevenbitize
} Process_t;
typedef enum {
ResolutionMicro = 0,
ResolutionMilli = 1
} Resolution_t;
///////// Variables
// Run mode
Mode_t mode = ModeUndefined;
// Running status option
bool runningStatusEnabled = false;
bool nrpnFilterEnabled = false;
// Timed option
struct {
bool enabled;
Resolution_t resolution;
unsigned long lastTimestamp;
} timedOpt = {
.enabled = false,
.resolution = ResolutionMicro
};
// Options prefix/suffix
char prefix[32] = "";
char suffix[32] = "";
bool printDiscardedData = false;
bool exitOnError = true;
int verbosity = 0;
Process_t process;
bool useHex = false;
///////// Signatures
void printHelp( void );
unsigned long getNow();
void generator(void);
void generatorError(int code, uint8_t argc, uint8_t ** argv);
void writeMidiPacket( Message_t * msg );
void parser(void);
void parsedMessage( Message_t * msg, void * context );
void discardingData( uint8_t * data, uint8_t length, void * context );
void printHelp( void ) {
printf("Usage:\n");
printf("\t midimessage-cli [-h?]\n");
printf("\t midimessage-cli [--running-status|-r] [--timed|-t[milli|micro]] (--parse|-p) [-d] [--nprn-filter]\n");
printf("\t midimessage-cli [--running-status|-r] [--timed|-t[milli|micro]] (--generate|-g) [-x0|-x1] [-v[N]] [--prefix=<prefix>] [--suffix=<suffix] [<cmd> ...]\n");
printf("\t midimessage-cli --convert=(nibblize|denibblize|sevenbitize|desevenbitize) [--hex] [<data xN>]\n");
printf("\nOptions:\n");
printf("\t -h|-? \t\t\t\t show this help\n");
printf("\t --running-status|-r \t\t Accept (when parsing) or generate messages that rely on the running status (see MIDI specs)\n");
printf("\t --timed|-t[milli|micro] \t Enables the capture or playback of delta-time information (ie the time between messages). Optionally the time resolution (milliseconds or microseconds) can be specified (default = micro)\n");
printf("\t --parse|-p [<binary-data>] \t Enter parse mode and optionally pass as first argument (binary) message to be parsed. If no argument is provided starts reading binary stream from STDIN. Each successfully parsed message will be printed to STDOUT and terminated with a newline.\n");
printf("\t -d \t\t\t\t In parsing mode only, instead of silent discarding output any discarded data to STDERR.\n");
printf("\t --nrpn-filter \t\t\t\t In parsing mode only, assume CC-sequences 99-98-96 (increment), 99-98-97 (decrement), 99-98-6-38 (data entry) are NRPN sequences, thus these will be filtered even if impartial (!! ie, 99-98-6-2 will only output the message for 2; this is a convenience feature and can not be solved for the general case) \n");
printf("\t --generate|-g [<cmd> ...] \t Enter generation mode and optionally pass command to be generated. If no command is given, expects one command from STDIN per line. Generated (binary) messages are written to STDOUT.\n");
printf("\t --prefix=<prefix> \t\t Prefixes given string (max 32 bytes) before each binary sequence (only when in generation mode). A single %%d can be given which will be replaced with the length of the following binary message (incompatible with running-status mode).\n");
printf("\t --suffix=<suffix> \t\t Suffixes given string (max 32 bytes) before each binary sequence (only when in generation mode).\n");
printf("\t -x0, -x1 \t\t\t In generation mode, exit on input error (-x1) or continue processing (-x0). Default := continue (-x0).\n");
printf("\t -v0, -v1 \t\t\t In generation mode, print command parsing result (on error only) to STDERR. Default := do NOT print (-v0).\n");
printf("\t --convert=.. \t\t\t Enter convertion mode, ie transform incoming STDIN using convertion method and write to STDOUT (raw bytes).\n");
printf("\t --hex \t\t\t\t In convertion mode (only), hex input/output\n");
printf("\nFancy pants note: the parsing output format is identical to the generation command format ;) \n");
printf("\nData types:\n");
printf("\t uN := N bit unsigned integer)\n");
printf("\t\t u4 (data nibble) < 15 (0x0F)\n");
printf("\t\t u7 <= 127 (0x7F)\n");
printf("\t\t u14 <= 16383 (0x3FFF)\n");
printf("\t\t u21 <= 2097151 (0x1FFFFF)\n");
printf("\t\t u28 <= 268435455 (0x0FFFFFFF)\n");
printf("\t\t u35 <= 34359738367 (0x7FFFFFFFF)\n");
printf("\t sN := N bit signed integer\n");
printf("\t strN ((max) N byte ascii string)\n");
printf("\t xN (N byte hex string <> 2Ns) (note: data bytes must be <= 0x7F)\n");
printf("\nVoice Commands:\n");
printf("\t note (on|off) <channel (u4)> <key (u7)> <velocity (u7)>\n");
printf("\t cc <channel (u4)> <controller (u7)> <value (u7)>\n");
printf("\t pc <channel (u4)> <program (u7)>\n");
printf("\t pressure <channel (u4)> <pressure (u7)>\n");
printf("\t pitch <channel (u4)> <pitch (u14)>\n");
printf("\t poly <channel (u4)> <key (u7)> <pressure (u7)>\n");
printf("\nSystem Commands:\n");
printf("\t start\n");
printf("\t stop\n");
printf("\t continue\n");
printf("\t reset\n");
printf("\t active-sensing\n");
printf("\t tune-request\n");
printf("\t timing-clock\n");
printf("\t quarter-frame <messageType (u3)> <nibble (u4)>\n");
printf("\t song-position <position (u14)>\n");
printf("\t song-select <songNumber (u7)>\n");
printf("\n(Basic) System Exclusives:\n");
printf("\t sysex experimental <data (xN)>\n");
printf("\t sysex manufacturer <manufacturer-id (x1..3)> <data (xN)>\n");
printf("\t sysex nonrt <device-id* (u7)> (eof|wait|cancel|nak|ack) <packet-number (u7)>\n");
printf("* <device-id> := 127 is all devices (broadcast)\n");
printf("\nGeneral Information\n");
printf("\t sysex nonrt <device-id (u7)> info request\n");
printf("\t sysex nonrt <device-id (u7)> info reply <manufacturer-id (x1, x3)> <device-family (u14)> <device-family-member (u14)> <software-revision (x4)>\n");
printf("\nGeneral MIDI (extension)\n");
printf("\t sysex nonrt <device-id (u7)> gm (system-on1|system-off|system-on2)\n");
printf("\nController Destination Setting\n");
printf("\t sysex nonrt <device-id (u7)> cds <channel (u4)> (channel-pressure|key-pressure) <parameter1 (u7)> <range1 (u7)> [<parameter2 (u7)> <range2 (u7)> .. <parameterN (u7)> <rangeN (u7)>]\n");
printf("\t sysex nonrt <device-id (u7)> cds <channel (u4)> cc <controller (u7)> <parameter1 (u7)> <range1 (u7)> [<parameter2 (u7)> <range2 (u7)> .. <parameterN (u7)> <rangeN (u7)>]\n");
printf("\nKeybased Instrument Control\n");
printf("\t sysex nonrt <device-id (u7)> keys <channel (u7)> <key (u7)> <controller1 (u7)> <value1 (u7)> [<controller2 (u7)> <value2 (u7)> .. <controllerN (u7)> <valueN (u7)>]\n");
printf("\nDevice Control\n");
printf("\t sysex rt <device-id (u7)> dc** (master-volume|master-balance|coarse-tuning|fine-tuning) <value (u14)>\n");
printf("\t sysex rt <device-id (u7)> dc global-parameter <slot-count (u7)> <parameter-id-width (u7)> <parameter-value-width (u7)> [<slot-path1 (u14)> [.. <slot-pathN (u14)>]] [<parameter-id1 (xN)> <parameter-value1 (xN)> [.. <parameter-idN (xN)> <parameter-valueN (xN)>]]\n");
printf("\nMIDI Time Code + Cueing\n");
printf("\t sysex rt <device-id (u7)> mtc full-message <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps>\n");
printf("\t sysex rt <device-id (u7)> mtc user-bits <5bytes (x5)>\n");
printf("\t sysex nonrt <device-id (u7)> cueing special (time-code-offset|enable-event-list|disable-event-list|clear-event-list|system-stop|event-list-request|<(u14)>)\n");
printf("\t sysex nonrt <device-id (u7)> cueing (punch-in|punch-out) (add|rm) <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps> <fractional-frame <= 99> <event-number (u14)>\n");
printf("\t sysex nonrt <device-id (u7)> cueing (event-start|event-stop|cue-point) (add|rm) <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps> <fractional-frame <= 99> <event-number (u14)> [<event-name (str) ..>]\n");
printf("\t sysex nonrt <device-id (u7)> cueing event-name - <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps> <fractional-frame <= 99> <event-number (u14)> <event-name (str) ..>\n");
printf("\t sysex rt <device-id (u7)> cueing special (system-stop|<(u14)>)\n");
printf("\t sysex rt <device-id (u7)> cueing (punch-in|punch-out) <event-number (u14)>\n");
printf("\t sysex rt <device-id (u7)> cueing (event-start|event-stop|cue-point) <event-number (u14)> [<event-name (str) ..>]\n");
printf("\t sysex rt <device-id (u7)> cueing event-name <event-number (u14)> <event-name (str) ..>\n");
printf("\nMIDI Show Control (MSC)\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> (all-off|restore|reset)\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> (go|stop|resume|load|go-off|go-jam-lock) <cue-number**> [<cue-list**> [<cue-path**>]]\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> timed-go <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps> < (x1)> <cue-number**> [<cue-list**> [<cue-path**>]]\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> set <controller (u14)> <value (u14)> <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps> < (x1)>\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> fire <macro-number (u7)>\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> (standby+|standby-|sequence+|sequence-|start-clock|stop-clock|zero-clock|mtc-chase-on|mtc-chase-off|open-cue-list|close-cue-list) <cue-list**>\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> (open-cue-path|close-cue-path) <cue-path**>\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> set-clock <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps> < (x1)> <cue-list**>\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> (standby|go-2-pc) <checksum (u14)> <sequence-number (u14)> <data (x4)> <cue-number**> [<cue-list**> [<cue-path**>]]\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> standing-by <checksum (u14)> <sequence-number (u14)> <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps> < (x1)> <cue-number**> [<cue-list**> [<cue-path**>]]\n");
printf("\t sysex rt <device-id (u7)> msc <cmdFmt*> (cancelled|abort) <checksum (u14)> <status (u16)> <sequence-number (u14)> <data (x4)> <cue-number**> [<cue-list**> [<cue-path**>]]\n");
printf("* <cmdFmt> := lighting|moving-lights|color-changers|strobes|lasers|chasers|sound|music|cd-players|eprom-playback|audio-tape-machines|intercoms|amplifiers|audio-fx|equalizers|machinery|rigging|flys|lifts|turntables|trusses|robots|animation|floats|breakaways|barges|video|video-tape-machines|video-cassette-machines|video-disc-players|video-switchers|video-fx|video-char-generators|video-still-stores|video-monitors|projection|film-projects|slide-projectors|video-projectors|dissolvers|shutter-controls|process-control|hydraulic-oil|h2o|co2|compressed-air|natural-gas|fog|smoke|cracked-haze|pyro|fireworks|explosions|flame|smoke-pots|all\n");
printf("** <cue-number>, <cue-list>, <cue-path> := ascii numbers (0-9) and/or dots (.)\n");
printf("\nMIDI Machine Commands (MMC)\n");
printf("For MMC the MIDI format acts as container for a command stream of its own, where several MMC commands can be packed into one MIDI message.\n");
printf("\n\t sysex rt <device-id (u7)> mcc <command1 ..> [<command2 ..> [ .. <commandN ..>] .. ]]\n");
printf("\t\t <commandN ..> :\n");
printf("\t\t (stop|play|deferred-play|fast-forward|rewind|record-strobe|record-exit|record-pause|pause|eject|chase|command-error-reset|mmc-reset|wait|resume)\n");
printf("\t\t (variable-play|search|shuttle|deferred-variable-play|record-strobe-variable) <speed (float)>\n");
printf("\t\t step <step (s7)>\n");
printf("\t\t locate (field <field>|mtc <fps = 24,25,29.97,30> <hour <= 23> <minute <= 59> <second <= 59> <frame < fps>)\n");
printf("\t\t assign-system-master <master (u7)>\n");
printf("\t TODO:\n");
printf("\t\t generator-command (stop|run|copy-jam)\n");
printf("\t\t mtc-command (off|follow)\n");
printf("\t\t write ..\n");
printf("\t\t move ..\n");
printf("\t\t etc\n");
printf("\nMobile Phone Control\n");
printf("\t sysex rt <phone-id (u7)> mpc (vibrator|led|display|keypad|all|<manufacturer-id (x1,x3)> <cmd-id (u7)>> <device-index (u7)> <reset|on|off>\n");
printf("\t sysex rt <phone-id (u7)> mpc (vibrator|led|display|keypad|all|<manufacturer-id (x1,x3)> <cmd-id (u7)>> <device-index (u7)> <manufacturer-cmd (x1, x3)> <data (xN)>\n");
printf("\t sysex rt <phone-id (u7)> mpc (vibrator|led|display|keypad|all|<manufacturer-id (x1,x3)> <cmd-id (u7)>> <device-index (u7)> follow-midi-channels [<channel1 (u7)> <low-note1 (u7)> <high-note1 (u7)> [ .. [<channelN (u7)> <low-noteN (u7)> <high-noteN (u7)>] .. ]\n");
printf("\t sysex rt <phone-id (u7)> mpc (vibrator|led|display|keypad|all|<manufacturer-id (x1,x3)> <cmd-id (u7)>> <device-index (u7)> set-color <red (u7)> <green (u7)> <blue (u7)>\n");
printf("\t sysex rt <phone-id (u7)> mpc (vibrator|led|display|keypad|all|<manufacturer-id (x1,x3)> <cmd-id (u7)>> <device-index (u7)> set-level\n");
printf("\nSample Dump Standard (SDS)\n");
printf("\t sysex nonrt <device-id (u7)> sds-header <sample-number (u14)> <sample-fmt (u7)> <sample-period (u21)> <sample-length (u21)> <loop-start (u21)> <loop-end (u21)> (uni-forward|bi-forward|forward-once)\n");
printf("\t sysex nonrt <device-id (u7)> sds-request <sample-number (u14)>\n");
printf("\t sysex nonrt <device-id (u7)> sds-data <packet-index (u7)> <data (xN)> [<checksum (x1)> [<verification-checksum (x1)>]]*\n");
printf("\t sysex nonrt <device-id (u7)> sds-ext loop-point-tx <sample-number (u14)> <loop-number (u14)> (uni-forward|bi-forward|forward-once) <loop-start (u21)> <loop-end (u21)>\n");
printf("\t sysex nonrt <device-id (u7)> sds-ext loop-point-request <sample-number (u14)> <loop-number (u14)>\n");
printf("\t sysex nonrt <device-id (u7)> sds-ext ext-header <sample-number (u14)> <sample-fmt (u7)> <sample-rate-integer (u28)> <sample-rate-fraction (u28)> <sample-length (u35)> <loop-start (u35)> <loop-end (u35)> <loop-type**>\n");
printf("\t sysex nonrt <device-id (u7)> sds-ext ext-loop-point-tx <sample-number (u14)> <loop-number (u14)> <loop-type**> <loop-start (u35)> <loop-end (u35)> \n");
printf("\t sysex nonrt <device-id (u7)> sds-ext ext-loop-point-request <sample-number (u14)> <loop-number (u14)>\n");
printf("\t sysex nonrt <device-id (u7)> sds-ext name-tx <sample-number (u14)> -*** <sample-name (strN) ...>\n");
printf("\t sysex nonrt <device-id (u7)> sds-ext name-request <sample-number (u14)>\n");
printf("* <checksum> := as sent/to be sent in message, <verification-checksum> := as computed. Both checksums are given when parsing a MIDI stream but during generation, if no <checksum> is given it is computed (recommended) otherwise its value will be used; <verification-checksum> will always be ignored.\n");
printf("** <loop-type> := uni-forward|bi-forward|uni-forward-release|bi-forward-release|uni-backward|bi-backward|uni-backward-release|bi-backward-release|backward-once|forward-once\n");
printf("*** In principle there is a language tag to support localization, but apart from the default (English) none are documented and thus likely not used. Thus momentarily only the default is supported which is chosen by specifying '-' as argument.\n");
printf("\nMIDI Visual Control (MVC)\n");
printf("\t sysex nonrt <device-id (u7)> mvc (on-off|clip-control-channel|fx-control-channel|note-msg-enabled) <data (xN)>\n");
printf("\t sysex nonrt <device-id (u7)> mvc (playback-assign-msn|playback-assign-lsn|dissolve-assign-msn|dissolve-assign-lsn) <data (xN)>\n");
printf("\t sysex nonrt <device-id (u7)> mvc (fx1-assign-msn|fx1-assign-lsn|fx2-assign-msn|fx2-assign-lsn|fx3-assign-msn|fx3-assign-lsn) <data (xN)>\n");
printf("\t sysex nonrt <device-id (u7)> mvc (playback-speed-range|keyboard-range-lower|keyboard-range-upper) <data (xN)>\n");
printf("\t sysex nonrt <device-id (u7)> mvc <parameter-address (x3)> <data (xN)>\n");
printf("\nFile Dump\n");
printf("\t sysex nonrt <device-id (u7)> file-dump request <sender-id (u7)> <type (str4)*> <name (strN)..>\n");
printf("\t sysex nonrt <device-id (u7)> file-dump header <sender-id (u7)> <type (str4)*> <length (u28)> <name (strN)..>\n");
printf("\t sysex nonrt <device-id (u7)> file-dump data <packet-number (u7)> <data (xN)> [<checksum (x1)> [<verification-checksum (x1)>]]**\n");
printf("*<type> := four 7-bit ASCII bytes. Defined in specification: MIDI, MIEX, ESEQ, TEXT, BIN<space>, MAC<space>\n");
printf("** <checksum> := as sent/to be sent in message, <verification-checksum> := as computed. Both checksums are given when parsing a MIDI stream but during generation, if no <checksum> is given it is computed (recommended) otherwise its value will be used; <verification-checksum> will always be ignored.\n");
printf("\nNotation Information\n");
printf("\t sysex rt <device-id (u7)> notation bar-number (not-running|running-unknown|<s14>)\n");
printf("\t sysex rt <device-id (u7)> notation time-signature (immediate|delayed) <midi-clock-in-metronome-click (u7)> <32nd-notes-in-midi-quarter-note (u7)> <time-signature-nominator1 (u7)> <time-signature-denominator1 (u7)> [<nominator2 (u7)> <denominator2 (u7)> ..]\n");
printf("\nTuning Standard\n");
printf("\t sysex nonrt <device-id (u7)> tuning bulk-dump-request <program (u7)>\n");
printf("\t sysex nonrt <device-id (u7)> tuning bulk-dump-request-back <bank (u7)> <program (u7)>\n");
printf("\t sysex nonrt <device-id (u7)> tuning bulk-dump <program (u7)> <name (str16)> (-|<semitone1 (u7)> <cents1* (u14)>) .. (-|<semitone128 (u7)> <cents128* (u14)>) [<checksum (x1)> [<verification-checksum (x1)]]\n");
printf("\t sysex nonrt <device-id (u7)> tuning key-based-dump <bank (u7)> <preset (u7)> <name (str16)> (-|<semitone1 (u7)> <cents1* (u14)>) .. (-|<semitone128 (u7)> <cents128* (u14)>) [<checksum (x1)> [<verification-checksum (x1)]]\n");
printf("\t sysex nonrt <device-id (u7)> tuning single-note-change-back <bank (u7)> <preset (u7)> <key1 (u7)> <semitone1 (u7)> <cents1* (u14)> [.. <keyN (u7)> <semitoneN (u7)> <centsN* (u14)>]\n");
printf("\t sysex nonrt <device-id (u7)> tuning octave-dump-1byte <bank (u7)> <preset (u7)> <name (str16)> <cent1** (s7)> .. <cents12** (s7)> ( [<checksum (x1)> [<verification-checksum (x1)]]\n");
printf("\t sysex nonrt <device-id (u7)> tuning octave-dump-2byte <bank (u7)> <preset (u7)> <name (str16)> <cent1> .. <cents12 (s7)> ( [<checksum (x1)> [<verification-checksum (x1)]]\n");
printf("\t sysex rt <device-id (u7)> tuning single-note-change <program (u7)> <key1 (u7)> <semitone1 (u7)> <cents1* (u14)> [.. <keyN (u7)> <semitoneN (u7)> <centsN* (u14)>]\n");
printf("\t sysex rt <device-id (u7)> tuning single-note-change-bank <bank (u7)> <preset (u7)> <key1 (u7)> <semitone1 (u7)> <cents1* (u14)> [.. <keyN (u7)> <semitoneN (u7)> <centsN* (u14)>]\n");
printf("\t* in .0061-cent units\n");
printf("\t** from -64 (:=0) to 63 (:=127, ie 0 := 64)\n");
printf("\t*** in .012207-cents units\n");
printf("\nExamples:\n");
printf("\t bin/midimessage-cli -g note on 60 40 1\n");
printf("\t bin/midimessage-cli -g sysex experimental 1337\n");
printf("\t bin/midimessage-cli -g sysex rt 1 msc sound reset\n");
printf("\t bin/midimessage-cli -g | bin/midimessage-cli -p\n");
printf("\t bin/midimessage-cli -g --prefix='%%d ' --suffix=$'\\x0a'\n");
printf("\t bin/midimessage-cli -g | bin/midimessage-cli -ptmilli > test.recording\n");
printf("\t cat test.recording | bin/midimessage-cli -gtmilli | bin/midimessage-cli -p\n");
printf("\t bin/midimessage-cli --convert=nibblize --hex 1337 > test.nibblized\n");
printf("\t cat test.nibblized | bin/midimessage-cli --convert=denibblize --hex\n");
printf("\t bin/midimessage-cli -v1 -g nrpn 1 128 255 | bin/midimessage-cli -p\n");
printf("\t bin/midimessage-cli -v1 -g nrpn 1 128 256 | bin/midimessage-cli -p --nrpn-filter\n");
}
unsigned long getNow(){
struct timespec c;
if (clock_gettime(CLOCK_REALTIME, &c) == -1) {
perror("error calling clock_gettime()");
exit(EXIT_FAILURE);
}
if (timedOpt.resolution == ResolutionMilli){
return c.tv_sec * 1000 + c.tv_nsec / 1000000;
}
return c.tv_sec * 1000000 + c.tv_nsec / 1000;
}
void generator(void){
uint8_t line[255];
uint8_t sysexBuffer[128];
Message_t msg;
msg.Data.SysEx.ByteData = sysexBuffer;
// start timer
if (timedOpt.enabled){
// record timer
timedOpt.lastTimestamp = getNow();
}
while(fgets((char*)line, sizeof(line), stdin ) != NULL){
uint8_t *args[32];
uint8_t argsCount = stringToArgs( args, 32, line, strlen((char*)line) );
if (argsCount == 0){
continue;
}
uint8_t ** firstArg = args;
// if the next command is delayed, we have to wait and update the arguments correspondingly
if (timedOpt.enabled){
unsigned long delay = strtoul((char*)args[0], NULL, 10);
unsigned long waitUntil = timedOpt.lastTimestamp + delay;
unsigned long now;
do {
now = getNow();
} while( now < waitUntil );
timedOpt.lastTimestamp = now;
argsCount--;
firstArg = &firstArg[1];
}
if (strcmp((char*)firstArg[0], "nrpn") == 0){
if (argsCount < 4 || 5 < argsCount) {
generatorError(StringifierResultWrongArgCount, argsCount, firstArg);
continue;
}
msg.StatusClass = StatusClassControlChange;
msg.Channel = atoi((char*)firstArg[1]);
if (msg.Channel > MaxU7) {
generatorError(StringifierResultInvalidU7, argsCount, firstArg);
continue;
}
uint16_t controller = atoi((char*)firstArg[2]);
if (controller > MaxU14) {
generatorError(StringifierResultInvalidU14, argsCount, firstArg);
continue;
}
uint8_t action = 0;
uint16_t value = 0;
if (strcmp((char*)firstArg[3], "inc") == 0){
action = CcDataIncrement;
if (argsCount == 5) {
value = atoi((char*)firstArg[4]);
if (value > MaxU7) {
generatorError(StringifierResultInvalidU14, argsCount, firstArg);
continue;
}
}
}
else if (strcmp((char*)firstArg[3], "dec") == 0){
action = CcDataDecrement;
if (argsCount == 5) {
value = atoi((char*)firstArg[4]);
if (value > MaxU7) {
generatorError(StringifierResultInvalidU14, argsCount, firstArg);
continue;
}
}
} else {
if (argsCount != 4) {
generatorError(StringifierResultWrongArgCount, argsCount, firstArg);
continue;
}
action = CcDataEntryMSB;
value = atoi((char*)firstArg[3]);
if (value > MaxU14) {
generatorError(StringifierResultInvalidU14, argsCount, firstArg);
continue;
}
}
msg.Data.ControlChange.Controller = CcNonRegisteredParameterMSB;
msg.Data.ControlChange.Value = (controller >> 7) & DataMask;
writeMidiPacket(&msg);
msg.Data.ControlChange.Controller = CcNonRegisteredParameterLSB;
msg.Data.ControlChange.Value = controller & DataMask;
writeMidiPacket(&msg);
if (action == CcDataEntryMSB){
msg.Data.ControlChange.Controller = CcDataEntryMSB;
msg.Data.ControlChange.Value = (value >> 7) & DataMask;
writeMidiPacket(&msg);
msg.Data.ControlChange.Controller = CcDataEntryLSB;
msg.Data.ControlChange.Value = value & DataMask;
writeMidiPacket(&msg);
} else {
msg.Data.ControlChange.Controller = action;
msg.Data.ControlChange.Value = value & DataMask;
writeMidiPacket(&msg);
}
} else {
int result = MessagefromArgs( &msg, argsCount, firstArg );
if (StringifierResultOk == result){
writeMidiPacket( &msg );
} else {
generatorError(result, argsCount, firstArg);
}
}
}
}
void generatorError(int code, uint8_t argc, uint8_t ** argv){
if (verbosity > 0) {
switch (code) {
case StringifierResultGenericError:
fprintf(stderr, "Generic error: ");
break;
case StringifierResultInvalidValue:
fprintf(stderr, "Invalid value: ");
break;
case StringifierResultWrongArgCount:
fprintf(stderr, "Wrong arg count: ");
break;
case StringifierResultNoInput:
fprintf(stderr, "No input ");
break;
case StringifierResultInvalidU4:
fprintf(stderr, "Invalid U4/Nibble Value ");
break;
case StringifierResultInvalidU7:
fprintf(stderr, "Invalid U7 Value ");
break;
case StringifierResultInvalidU14:
fprintf(stderr, "Invalid U14 Value ");
break;
case StringifierResultInvalidU21:
fprintf(stderr, "Invalid U21 Value ");
break;
case StringifierResultInvalidU28:
fprintf(stderr, "Invalid U28 Value ");
break;
case StringifierResultInvalidU35:
fprintf(stderr, "Invalid U35 Value ");
break;
case StringifierResultInvalidHex:
fprintf(stderr, "Invalid Hex Value ");
break;
}
for (uint8_t i = 0; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]);
}
fprintf(stderr, "\n");
}
if (exitOnError){
exit(EXIT_FAILURE);
}
}
void writeMidiPacket( Message_t * msg ){
static uint8_t runningStatusState = MidiMessage_RunningStatusNotSet;
uint8_t bytes[255];
uint8_t length = pack( bytes, msg );
if (length == 0){
return;
}
printf(prefix, length);
if (runningStatusEnabled && updateRunningStatus( &runningStatusState, bytes[0] )){
fwrite( &bytes[1], 1, length-1, stdout);
} else {
fwrite(bytes, 1, length, stdout);
}
printf("%s", suffix);
fflush(stdout);
}
void parser(void){
uint8_t sysexBuffer[128];
Message_t msg;
msg.Data.SysEx.ByteData = sysexBuffer;
uint8_t dataBuffer[255];
Parser_t parser;
parser_init(&parser, runningStatusEnabled, dataBuffer, 255, &msg, parsedMessage, discardingData, NULL );
// start timer
if (timedOpt.enabled){
// record timer
timedOpt.lastTimestamp = getNow();
}
int ch;
while( (ch = fgetc(stdin)) != EOF ){
uint8_t byte = (uint8_t)ch;
parser_receivedData(&parser, &byte, 1 );
}
}
typedef int (*Reader_t)(void);
typedef uint8_t(*Converter_t)(uint8_t *,uint8_t *, uint8_t);
void convert(Reader_t reader, Converter_t converter, uint8_t each){
uint8_t src[16];
uint8_t dst[16];
uint8_t srcl = 0;
void (*output)(uint8_t *,uint8_t) = [](uint8_t * data, uint8_t len){
uint8_t buf[32];
if (useHex){
byte_to_hex(buf, data, len);
fwrite( buf, 1, 2*len, stdout );
} else {
fwrite( data, 1, len, stdout );
}
};
int ch;
while( (ch = reader()) != EOF ){
uint8_t byte = (uint8_t)ch;
if (useHex){
static uint8_t nibble = 0;
static uint8_t nibbles[2];
nibbles[nibble++] = byte;
if (nibble >= 2){
if ( ! hex_to_byte(&src[srcl], nibbles, 1) ){
fprintf(stderr, "Error: invalid hex input!\n");
}
srcl++;
nibble = 0;
}
} else {
src[srcl++] = byte;
}
if (srcl >= each){
uint8_t dstl = converter(dst, src, srcl);
output(dst, dstl);
srcl = 0;
}
}
// in case input terminated before group full
if (srcl > 0){
uint8_t dstl = converter(dst, src, srcl);
output(dst, dstl);
}
}
void parsedMessage( Message_t * msg, void * context ){
static uint8_t nrpnMsgCount = 0;
static uint8_t nrpnChannel = 0;
static uint8_t nrpnValues[4];
if (nrpnFilterEnabled && msg->StatusClass == StatusClassControlChange) {
if (nrpnMsgCount == 0 && (msg->Data.ControlChange.Controller == CcNonRegisteredParameterMSB || msg->Data.ControlChange.Controller == CcNonRegisteredParameterLSB)) {
nrpnChannel = msg->Channel;
if (msg->Data.ControlChange.Controller == CcNonRegisteredParameterMSB){
nrpnValues[0] = msg->Data.ControlChange.Value;
} else {
nrpnValues[1] = msg->Data.ControlChange.Value;
}
nrpnMsgCount = 1;
return;
}
uint8_t nrpnAction = 0;
if (nrpnMsgCount > 0 && nrpnChannel != msg->Channel){
nrpnMsgCount = 0;
} else {
if (nrpnMsgCount == 1) {
if (msg->Data.ControlChange.Controller == CcNonRegisteredParameterLSB || msg->Data.ControlChange.Controller == CcNonRegisteredParameterMSB) {
if (msg->Data.ControlChange.Controller == CcNonRegisteredParameterMSB){
nrpnValues[0] = msg->Data.ControlChange.Value;
} else {
nrpnValues[1] = msg->Data.ControlChange.Value;
}
nrpnMsgCount = 2;
return;
} else {
nrpnMsgCount = 0;
}
}
else if (nrpnMsgCount == 2) {
if (msg->Data.ControlChange.Controller == CcDataEntryMSB) {
nrpnValues[2] = msg->Data.ControlChange.Value;
nrpnMsgCount = 3;
return;
} else if (msg->Data.ControlChange.Controller == CcDataIncrement) {
nrpnValues[2] = msg->Data.ControlChange.Value;
nrpnAction = CcDataIncrement;
} else if (msg->Data.ControlChange.Controller == CcDataDecrement) {
nrpnValues[2] = msg->Data.ControlChange.Value;
nrpnAction = CcDataDecrement;
} else {
nrpnMsgCount = 0;
}
}
else if (nrpnMsgCount == 3){
if (msg->Data.ControlChange.Controller == CcDataEntryLSB) {
nrpnValues[3] = msg->Data.ControlChange.Value;
nrpnMsgCount = 4;
nrpnAction = CcDataEntryMSB;
} else {
nrpnMsgCount = 0;
}
}
}
if (nrpnAction != 0){
if (timedOpt.enabled){
unsigned long now = getNow();
unsigned long diff = now - timedOpt.lastTimestamp;
printf("%ld ", diff);
timedOpt.lastTimestamp = now;
}
uint16_t controller = (nrpnValues[0] << 7) | nrpnValues[1];
if (nrpnAction == CcDataIncrement) {
printf("nrpn %d %d inc %d\n", nrpnChannel, controller, nrpnValues[2]);
} else if (nrpnAction == CcDataDecrement) {
printf("nrpn %d %d dec %d\n", nrpnChannel, controller, nrpnValues[2]);
} else {
uint16_t value = (nrpnValues[2] << 7) | nrpnValues[3];
printf("nrpn %d %d %d\n", nrpnChannel, controller, value);
}
fflush(stdout);
nrpnMsgCount = 0;
return;
}
}
uint8_t stringBuffer[255];
int length = MessagetoString( stringBuffer, msg );
if ( length > 0 ) {
if (timedOpt.enabled){
unsigned long now = getNow();
unsigned long diff = now - timedOpt.lastTimestamp;
printf("%ld ", diff);
timedOpt.lastTimestamp = now;
}
printf("%s\n", stringBuffer);
fflush(stdout);
}
}
void discardingData( uint8_t * data, uint8_t length, void * context ){
if (printDiscardedData == false){
return;
}
fwrite( data, 1, length, stderr );
fflush(stderr);
}
uint8_t ** gargv;
int main(int argc, char * argv[], char * env[]){
int c;
int digit_optind = 0;
if (argc <= 1){
printHelp();
return EXIT_SUCCESS;
}
while (1) {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = {
{"parse", no_argument, 0, 'p' },
{"generate", no_argument, 0, 'g' },
{"timed", optional_argument, 0, 't'},
{"running-status", optional_argument, 0, 'r'},
{"prefix", required_argument, 0, 0},
{"suffix", required_argument, 0, 0},
{"verbose", optional_argument, 0, 'v'},
{"exit-on-error", required_argument, 0, 'x'},
{"help", no_argument, 0, 'h' },
{"convert", required_argument, 0, 0},
{"hex", no_argument, 0, 0},
{"nrpn-filter", no_argument, 0, 'n'},
{0, 0, 0, 0 }
};
c = getopt_long(argc, argv, "pgt::rhdv::x:h?",
long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
if (strcmp(long_options[option_index].name, "prefix") == 0) {
if (mode != ModeGenerate) {
printf("Can only use prefix when generating messages!\n");
exit(EXIT_FAILURE);
}
strcpy(prefix, optarg);
}
else if (strcmp(long_options[option_index].name, "suffix") == 0) {
if (mode != ModeGenerate) {
printf("Can only use prefix when generating messages!\n");
exit(EXIT_FAILURE);
}
strcpy(suffix, optarg);
}
else if (strcmp(long_options[option_index].name, "convert") == 0) {
if (mode != ModeUndefined){
printf("Can only enter one mode!\n");
}
mode = ModeConvert;
if (strcmp(optarg, "nibblize") == 0){
process = ProcessNibblize;
} else if (strcmp(optarg, "denibblize") == 0){
process = ProcessDeNibblize;
} else if (strcmp(optarg, "sevenbitize") == 0){
process = ProcessSevenbitize;
} else if (strcmp(optarg, "desevenbitize") == 0){
process = ProcessDeSevenbitize;
} else {
printf("Conversion mode not recognized!\n");
exit(EXIT_FAILURE);
}
}
else if (strcmp(long_options[option_index].name, "hex") == 0){
useHex = true;
}
break;
case '?':
case 'h':
printHelp();
return EXIT_SUCCESS;
case 'p':
if (mode == ModeGenerate){
printf("Already set to parsing - can not do both!\n");
exit(EXIT_FAILURE);
}
mode = ModeParse;
break;
case 'g':
if (mode == ModeParse){
printf("Already set to generating - can not do both!\n");
return 1;
}
mode = ModeGenerate;
break;
case 't':
timedOpt.enabled = true;
if (optarg != NULL && strlen(optarg) > 0){
if (strcmp(optarg, "milli") == 0){
timedOpt.resolution = ResolutionMilli;
} else if (strcmp(optarg, "micro") == 0) {
timedOpt.resolution = ResolutionMicro;
} else {
printf("Error: invalid time scale, either 'milli' or 'micro', %s given\n", optarg);
exit(EXIT_FAILURE);
}
}
break;
case 'r':
runningStatusEnabled = true;
break;
case 'n':
nrpnFilterEnabled = true;
break;
case 'd':
printDiscardedData = true;
break;
case 'v':
if (optarg != NULL && strlen(optarg) > 0){
verbosity = atoi(optarg);
} else {
verbosity++;
}
break;
case 'x':
if (optarg != NULL && strlen(optarg) > 0){
exitOnError = (bool)atoi(optarg);
}
break;
default:
printf("?? getopt returned character code 0%o ??\n", c);
}
}
if ( ! isValidMode( mode) ){
printf("Must be called in either parsing or generation mode (or conversion mode, for that matter..)!\n");
exit(EXIT_FAILURE);
}
if (mode == ModeGenerate) {
// if there are additional arguments just try to generate a message from
if (optind < argc){
uint8_t sysexBuffer[128];
Message_t msg;
msg.Data.SysEx.ByteData = sysexBuffer;
uint8_t argsCount = (uint8_t) (argc - optind);
uint8_t ** firstArg = (uint8_t **) &argv[optind];
int result = StringifierResultGenericError;
if (strcmp((char*)firstArg[0], "nrpn") == 0){
if (argsCount < 4 || 5 < argsCount) {
generatorError(StringifierResultWrongArgCount, argsCount, firstArg);
exit(EXIT_FAILURE);
}
msg.StatusClass = StatusClassControlChange;
msg.Channel = atoi((char*)firstArg[1]);
if (msg.Channel > MaxU7) {
generatorError(StringifierResultInvalidU7, argsCount, firstArg);
exit(EXIT_FAILURE);
}
uint16_t controller = atoi((char*)firstArg[2]);
if (controller > MaxU14) {
generatorError(StringifierResultInvalidU14, argsCount, firstArg);
exit(EXIT_FAILURE);
}
uint8_t action = 0;
uint16_t value = 0;
if (strcmp((char*)firstArg[3], "inc") == 0){
action = CcDataIncrement;
if (argsCount == 5) {
value = atoi((char*)firstArg[4]);
if (value > MaxU7) {
generatorError(StringifierResultInvalidU14, argsCount, firstArg);
exit(EXIT_FAILURE);
}
}
}
else if (strcmp((char*)firstArg[3], "dec") == 0){
action = CcDataDecrement;
if (argsCount == 5) {
value = atoi((char*)firstArg[4]);
if (value > MaxU7) {
generatorError(StringifierResultInvalidU14, argsCount, firstArg);
exit(EXIT_FAILURE);
}
}
} else {
if (argsCount != 4) {
generatorError(StringifierResultWrongArgCount, argsCount, firstArg);
exit(EXIT_FAILURE);
}
action = CcDataEntryMSB;
value = atoi((char*)firstArg[3]);
if (value > MaxU14) {
generatorError(StringifierResultInvalidU14, argsCount, firstArg);
exit(EXIT_FAILURE);
}
}
msg.Data.ControlChange.Controller = CcNonRegisteredParameterMSB;
msg.Data.ControlChange.Value = (controller >> 7) & DataMask;
writeMidiPacket(&msg);
msg.Data.ControlChange.Controller = CcNonRegisteredParameterLSB;
msg.Data.ControlChange.Value = controller & DataMask;
writeMidiPacket(&msg);
if (action == CcDataEntryMSB){
msg.Data.ControlChange.Controller = CcDataEntryMSB;
msg.Data.ControlChange.Value = (value >> 7) & DataMask;
writeMidiPacket(&msg);
msg.Data.ControlChange.Controller = CcDataEntryLSB;
msg.Data.ControlChange.Value = value & DataMask;
writeMidiPacket(&msg);
} else {
msg.Data.ControlChange.Controller = action;
msg.Data.ControlChange.Value = value & DataMask;
writeMidiPacket(&msg);
}
exit(EXIT_SUCCESS);
} else {
result = MessagefromArgs(&msg, argsCount, firstArg);
if (result == StringifierResultOk) {
writeMidiPacket(&msg);
exit(EXIT_SUCCESS);
} else {
generatorError(result, argsCount, firstArg);
exit(EXIT_FAILURE);
}
}
}
// enter generator loop (reads stdin until eof)
generator();
}
if (mode == ModeParse){
if (optind < argc) {
printf("Parser mode may not be called with additional arguments - data is read from stdin only.\n");
exit(EXIT_FAILURE);
}
// enter parser loop (reads stdin until eof)
parser();
}
if (mode == ModeConvert){
Converter_t converter;
uint8_t each;
switch(process){
case ProcessNibblize:
converter = [](uint8_t * dst, uint8_t * src, uint8_t length){
return nibblize(dst, src, length);
};
each = 1;
break;
case ProcessDeNibblize:
converter = [](uint8_t * dst, uint8_t * src, uint8_t length){
return denibblize(dst, src, length);
};
each = 2;
break;
case ProcessSevenbitize:
converter = [](uint8_t * dst, uint8_t * src, uint8_t length){
return sevenbitize(dst, src, length);
};
each = 7;
break;
case ProcessDeSevenbitize:
converter = [](uint8_t * dst, uint8_t * src, uint8_t length){
return desevenbitize(dst, src, length);
};
each = 8;
break;
}
Reader_t reader;
if (optind < argc){
gargv = (uint8_t**)&argv[optind];
reader = []() -> int {
static int i = 0;
static int len = strlen((char*)gargv[0]);
if (i >= len){
return EOF;
}
return gargv[0][i++];
};
} else {
reader = []() -> int {
return fgetc(stdin);
};
}
convert( reader, converter, each);
}
return EXIT_SUCCESS;
}
| 41.878899
| 652
| 0.556717
|
tschiemer
|
b0c2eefad0385367e54922a37c72185354cc7853
| 2,870
|
cpp
|
C++
|
game/scripts/CollisionTracker.cpp
|
Khuongnb1997/game-aladdin
|
74b13ffcd623de0d6f799b0669c7e8917eef3b14
|
[
"MIT"
] | 2
|
2017-11-08T16:27:25.000Z
|
2018-08-10T09:08:35.000Z
|
game/scripts/CollisionTracker.cpp
|
Khuongnb1997/game-aladdin
|
74b13ffcd623de0d6f799b0669c7e8917eef3b14
|
[
"MIT"
] | null | null | null |
game/scripts/CollisionTracker.cpp
|
Khuongnb1997/game-aladdin
|
74b13ffcd623de0d6f799b0669c7e8917eef3b14
|
[
"MIT"
] | 4
|
2017-11-08T16:25:30.000Z
|
2021-05-23T06:14:59.000Z
|
#include "CollisionTracker.h"
USING_NAMESPACE_ALA;
ALA_CLASS_SOURCE_1(CollisionTracker, ala::GameObjectComponent)
CollisionTracker::CollisionTracker( ala::GameObject* gameObject, const std::string& name )
: GameObjectComponent( gameObject, name ), _collidedObjectFlags( 0 ), _collidedColliderFlags( 0 ) {}
void CollisionTracker::onCollisionEnter( const ala::CollisionInfo& collision ) {
const auto otherCollider = collision.getColliderA()->getGameObject() == getGameObject()
? collision.getColliderB()
: collision.getColliderA();
const auto otherObject = otherCollider->getGameObject();
_collidedObjects.emplace( otherObject->getId() );
_collidedObjectTags.emplace( otherObject->getTag() );
_collidedColliderTags.emplace( otherCollider->getTag() );
_collidedObjectFlags |= otherObject->getFlags();
_collidedColliderFlags |= otherCollider->getFlags();
}
void CollisionTracker::onTriggerEnter( const ala::CollisionInfo& collision ) {
const auto otherCollider = collision.getColliderA()->getGameObject() == getGameObject()
? collision.getColliderB()
: collision.getColliderA();
const auto otherObject = otherCollider->getGameObject();
_collidedObjects.emplace( otherObject->getId() );
_collidedObjectTags.emplace( otherObject->getTag() );
_collidedColliderTags.emplace( otherCollider->getTag() );
_collidedObjectFlags |= otherObject->getFlags();
_collidedColliderFlags |= otherCollider->getFlags();
}
void CollisionTracker::reset() {
_collidedObjects.clear();
_collidedObjectTags.clear();
_collidedColliderTags.clear();
_collidedObjectFlags = 0;
_collidedColliderFlags = 0;
}
bool CollisionTracker::collidedWithObject( const int id ) const {
return _collidedObjects.count( id ) > 0;
}
bool CollisionTracker::collidedWithObjectTag( const int tag ) const {
return _collidedObjectTags.count( tag ) > 0;
}
bool CollisionTracker::collidedWithColliderTag( const int tag ) const {
return _collidedColliderTags.count( tag ) > 0;
}
bool CollisionTracker::collided() const {
return !_collidedObjects.empty();
}
bool CollisionTracker::collidedWithObjectFlag( const long flag ) const {
return (_collidedObjectFlags & flag) != 0;
}
bool CollisionTracker::collidedWithObjectFlags( const long flags ) const {
return (_collidedObjectFlags & flags) > flags;
}
bool CollisionTracker::collidedWithColliderFlag( const long flag ) const {
return (_collidedColliderFlags & flag) != 0;
}
bool CollisionTracker::collidedWithColliderFlags( const long flags ) const {
return (_collidedColliderFlags & flags) > flags;
}
long CollisionTracker::getCollidedObjectFlags() const {
return _collidedObjectFlags;
}
long CollisionTracker::getCollidedColliderFlags() const {
return _collidedColliderFlags;
}
| 34.578313
| 102
| 0.738676
|
Khuongnb1997
|
b0c3b7ca1633fc7b98c4b66ee1d1839f7d2682bd
| 2,675
|
cpp
|
C++
|
examples/04_execution_policies.cpp
|
JoelFilho/TDP
|
7609cca96afc60a29156d622756cb95b27aee7f2
|
[
"BSL-1.0"
] | 81
|
2020-05-19T18:09:24.000Z
|
2022-03-21T12:29:41.000Z
|
examples/04_execution_policies.cpp
|
JoelFilho/TDP
|
7609cca96afc60a29156d622756cb95b27aee7f2
|
[
"BSL-1.0"
] | 6
|
2020-05-20T22:27:20.000Z
|
2021-06-19T04:34:54.000Z
|
examples/04_execution_policies.cpp
|
JoelFilho/TDP
|
7609cca96afc60a29156d622756cb95b27aee7f2
|
[
"BSL-1.0"
] | 2
|
2020-05-20T03:08:05.000Z
|
2021-03-25T09:05:09.000Z
|
#include <iostream>
#include "tdp/pipeline.hpp"
//---------------------------------------------------------------------------------------------------------------------
// This example shows how to use execution policies with TDP
//
// An execution policy defines the internal data structure utilized for thread communication in a pipeline.
//
// To use an execution policy, you can define them with an '/' after the output.
//
// The currently supported policies are:
// - tdp::policy::queue - Uses a blocking queue to store the values between threads
// - tdp::policy::triple_buffer - Uses a blocking triple-buffer to store values
// - tdp::policy::triple_buffer_lockfree - Uses a lock-free triple-buffer
//
// This tutorial shows the difference between these policies and how to use them in a pipeline.
//---------------------------------------------------------------------------------------------------------------------
int main() {
constexpr auto add = [](auto x, auto y) { return x + y; };
constexpr auto square = [](auto x) { return x * x; };
// Queue (default) stores everything it can
auto pipe_q = tdp::input<int, int> >> add >> square >> tdp::output / tdp::policy::queue;
// Triple buffering only has capacity of one
auto pipe_tb = tdp::input<int, int> >> add >> square >> tdp::output / tdp::policy::triple_buffer;
// TDP supports lock-free triple buffers. We can use them here.
auto pipe_tb_lf = tdp::input<int, int> >> add >> square >> tdp::output / tdp::policy::triple_buffer_lockfree;
// Provide all pipelines with the same 25 input values
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
pipe_q.input(i, j);
pipe_tb.input(i, j);
pipe_tb_lf.input(i, j);
}
}
// Evaluate the first pipeline's results
// It will complete exactly 25 times.
std::cout << "pipe_q's result: \n";
for (int i = 0; i < 25; i++) {
std::cout << i << ": " << pipe_q.wait_get() << "\n";
}
std::cout << "pipe_q.empty(): " << std::boolalpha << pipe_q.empty() << "\n";
// Evaluate the second pipeline's results
// This will only complete once.
std::cout << "-----\n";
std::cout << "pipe_tb's result: " << pipe_tb.wait_get() << "\n";
std::cout << "pipe_tb.empty(): " << std::boolalpha << pipe_tb.empty() << "\n";
// Evaluate the lock-free pipeline's results
// The behavior should be the same as the blocking triple buffering.
// For details on the difference, check the "Lock-free Policies" example.
std::cout << "-----\n";
std::cout << "pipe_tb_lf's result: " << pipe_tb_lf.wait_get() << "\n";
std::cout << "pipe_tb_lf.empty(): " << std::boolalpha << pipe_tb_lf.empty() << "\n";
}
| 42.460317
| 119
| 0.584299
|
JoelFilho
|
b0c5a7c44c00642aa70ba27256110af67366dccb
| 327
|
cpp
|
C++
|
2017-08-15/E.cpp
|
tangjz/Three-Investigators
|
46dc9b2f0fbb4fe89b075a81feaacc33feeb1b52
|
[
"MIT"
] | 3
|
2018-04-02T06:00:51.000Z
|
2018-05-29T04:46:29.000Z
|
2017-08-15/E.cpp
|
tangjz/Three-Investigators
|
46dc9b2f0fbb4fe89b075a81feaacc33feeb1b52
|
[
"MIT"
] | 2
|
2018-03-31T17:54:30.000Z
|
2018-05-02T11:31:06.000Z
|
2017-08-15/E.cpp
|
tangjz/Three-Investigators
|
46dc9b2f0fbb4fe89b075a81feaacc33feeb1b52
|
[
"MIT"
] | 2
|
2018-10-07T00:08:06.000Z
|
2021-06-28T11:02:59.000Z
|
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define M 1000000007
#define all(a) a.begin(), a.end()
int T, a;
int main(){
scanf("%d", &T);
while(T--){
scanf("%d", &a);
printf("%d\n", (a - 1) / 2 + 2);
}
return 0;
}
| 14.863636
| 35
| 0.608563
|
tangjz
|
b0c60846d340c6248c25ddb6de6d51e7740a7512
| 2,226
|
cpp
|
C++
|
tests/unit/ReturnedMessageTests.cpp
|
djsavic1988/rabbitmq-cxx
|
f1807fe82ddabe4c604b116fff8e84c45539d7e6
|
[
"MIT"
] | 1
|
2021-05-17T07:51:24.000Z
|
2021-05-17T07:51:24.000Z
|
tests/unit/ReturnedMessageTests.cpp
|
djsavic1988/rabbitmq-cxx
|
f1807fe82ddabe4c604b116fff8e84c45539d7e6
|
[
"MIT"
] | null | null | null |
tests/unit/ReturnedMessageTests.cpp
|
djsavic1988/rabbitmq-cxx
|
f1807fe82ddabe4c604b116fff8e84c45539d7e6
|
[
"MIT"
] | null | null | null |
/*
Project: rabbitmq-cxx <https://github.com/djsavic1988/rabbitmq-cxx>
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
SPDX-License-Identifier: MIT
Copyright (c) 2021 Djordje Savic <djordje.savic.1988@gmail.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.
*/
#include <gtest/gtest.h>
#include "MockAMQP.hpp"
#include <rmqcxx/ReturnedMessage.hpp>
namespace rmqcxx { namespace unit_tests {
using ::testing::_;
using ::testing::Test;
using std::move;
using std::string;
struct ReturnedMessageTest : public Test {
MockAMQP amqp;
};
TEST_F(ReturnedMessageTest, Construction) {
EXPECT_CALL(amqp, destroy_message(_));
ReturnedMessage msg(Message(), amqp_basic_return_t{});
ReturnedMessage other(move(msg));
ReturnedMessage third(Message(), amqp_basic_return_t{});
third = move(other);
}
TEST_F(ReturnedMessageTest, Accessors) {
EXPECT_CALL(amqp, destroy_message(_));
ReturnedMessage msg(Message(amqp_message_t {.body = amqp_bytes_t {.len = 4, .bytes = const_cast<char*>("body")}}), amqp_basic_return_t{.reply_code = 75});
EXPECT_EQ(string(static_cast<char*>(msg.message()->body.bytes), msg.message()->body.len), "body");
EXPECT_EQ(msg.method().reply_code, 75);
}
}} // namespace rmqcxx.unit_tests
| 34.246154
| 156
| 0.769542
|
djsavic1988
|
b0c8d9b8a08fb65b1d5fb741e3bc058c5acbae5a
| 2,392
|
cpp
|
C++
|
tests/testVerlet.cpp
|
cmoser8892/MoleDymCode
|
9077289a670c6cb0ed9e1daac5a03b51c83bc6fb
|
[
"MIT"
] | null | null | null |
tests/testVerlet.cpp
|
cmoser8892/MoleDymCode
|
9077289a670c6cb0ed9e1daac5a03b51c83bc6fb
|
[
"MIT"
] | null | null | null |
tests/testVerlet.cpp
|
cmoser8892/MoleDymCode
|
9077289a670c6cb0ed9e1daac5a03b51c83bc6fb
|
[
"MIT"
] | null | null | null |
//
// Created by cm on 06.05.21.
//
#include <gtest/gtest.h>
#include "Headerfiles/verlet.h"
/**
* Info:
* Use EXPECT_NEAR or ASSERT_NEAR bc double!!
*/
TEST(VerletTest, IntegratorCheckConstantForceXYZDirectionSingleAtom)
{
//single Atom test
int nbAtoms = 1;
Positions_t positions(3,nbAtoms);
Velocities_t velocities(3, nbAtoms);
Forces_t forces(3,nbAtoms);
//
positions.setZero();
velocities.setZero();
forces.setZero();
forces.row(0) = 1.0;
forces.row(0) = 1.0;
double timestep = 1.0;
//run fkt
verletIntegratorConstantForce(positions,velocities,forces, timestep, 10);
//check
ASSERT_NEAR(positions(0),50,1e-6);
ASSERT_NEAR(velocities(0),10,1e-6);
}
TEST(VerletTest, IntegratorCheckConstantForceXYZDirectionMultipleAtom)
{
//single Atom test
int nbAtoms = 10;
Positions_t positions(3,nbAtoms);
Velocities_t velocities(3, nbAtoms);
Forces_t forces(3,nbAtoms);
//
positions.setZero();
velocities.setZero();
forces.setZero();
forces.row(0) = 1.0;
forces.row(1) = 1.0;
forces.row(2) = 1.0;
double timestep = 1.0;
//run fkt
verletIntegratorConstantForce(positions,velocities,forces, timestep, 10);
//check
for(int i = 0; i < nbAtoms; ++i)
{
//check positions
ASSERT_NEAR(positions(0,i),50,1e-6);
ASSERT_NEAR(positions(1,i),50,1e-6);
ASSERT_NEAR(positions(2,i),50,1e-6);
//check velocities
ASSERT_NEAR(velocities(0,i),10,1e-6);
ASSERT_NEAR(velocities(0,i),10,1e-6);
ASSERT_NEAR(velocities(0,i),10,1e-6);
}
}
TEST(VerletTest, IntegratorCheckConstantForceXYZDirectionMultipleAtomNewMethod)
{
//single Atom test
int nbAtoms = 10;
Atoms atoms(10);
atoms.forces.row(0) = 1.0;
atoms.forces.row(1) = 1.0;
atoms.forces.row(2) = 1.0;
double timestep = 1.0;
//run fkt
verletIntegratorConstantForceAtoms(atoms, timestep, 10);
//check
for(int i = 0; i < nbAtoms; ++i)
{
//check positions
ASSERT_NEAR(atoms.positions(0,i),50,1e-6);
ASSERT_NEAR(atoms.positions(1,i),50,1e-6);
ASSERT_NEAR(atoms.positions(2,i),50,1e-6);
//check velocities
ASSERT_NEAR(atoms.velocities(0,i),10,1e-6);
ASSERT_NEAR(atoms.velocities(0,i),10,1e-6);
ASSERT_NEAR(atoms.velocities(0,i),10,1e-6);
}
}
| 27.181818
| 79
| 0.63587
|
cmoser8892
|
37df4ad8f38bbbebb2b6161fa2f8c3d68c075a8c
| 1,894
|
cpp
|
C++
|
src/aadcUser/src/HSOG_Runtime/a2o/worldmodel/objectdetection/PointCloudWorker.cpp
|
AppliedAutonomyOffenburg/AADC_2015_A2O
|
19a2ac67d743ad23e5a259ca70aed6b3d1f2e3ac
|
[
"BSD-4-Clause"
] | 1
|
2018-09-09T21:39:29.000Z
|
2018-09-09T21:39:29.000Z
|
src/aadcUser/src/HSOG_Runtime/a2o/worldmodel/objectdetection/PointCloudWorker.cpp
|
TeamAutonomousCarOffenburg/A2O_2015
|
19a2ac67d743ad23e5a259ca70aed6b3d1f2e3ac
|
[
"BSD-4-Clause"
] | null | null | null |
src/aadcUser/src/HSOG_Runtime/a2o/worldmodel/objectdetection/PointCloudWorker.cpp
|
TeamAutonomousCarOffenburg/A2O_2015
|
19a2ac67d743ad23e5a259ca70aed6b3d1f2e3ac
|
[
"BSD-4-Clause"
] | 1
|
2016-04-05T06:34:08.000Z
|
2016-04-05T06:34:08.000Z
|
#include "PointCloudWorker.h"
#define FRAMES_PER_SECOND 2
typedef std::chrono::duration<int, std::ratio<1, FRAMES_PER_SECOND>> frame_duration;
using namespace A2O;
using namespace pcl;
PointCloudWorker::PointCloudWorker(IResource *resource)
: _resource(resource)
{
}
PointCloudWorker::~PointCloudWorker()
{
}
void PointCloudWorker::run()
{
while(!m_stop)
{
auto start_time = std::chrono::steady_clock::now();
auto end_time = start_time + frame_duration(1);
Pose2D carPose = _resource->getPose();
IPointCloudSensor::ConstPtr sensor = _resource->getPointCloudSensor();
if(sensor){
PointCloud<PointXYZ>::Ptr cloud = sensor->getPointCloud();
if(cloud && !cloud->empty())
{
cloud = PCLUtils::downSample(cloud, 0.05);
cloud = PCLUtils::extractFloor(cloud, true);
if( !cloud->empty())
{
cloud = PCLUtils::removeOutliers(cloud, 10);
std::vector <PointIndices> clusters = PCLUtils::segmentation(cloud, 10, 10);
std::vector<AlignedBoundingBox3D::Ptr> result;
for(PointIndices cluster : clusters)
{
ExtractIndices<PointXYZ> extract;
PointCloud<PointXYZ>::Ptr extractedCloudPtr (new PointCloud<PointXYZ>());
extract.setInputCloud (cloud);
PointIndices::Ptr indicesPtr = PointIndices::Ptr(new PointIndices(cluster));
extract.setIndices (indicesPtr);
extract.setNegative (false);
extract.filter (*extractedCloudPtr);
AlignedBoundingBox3D::Ptr box = PCLUtils::alignedBoundingBox(extractedCloudPtr);
Pose3D cameraPose = sensor->getPose();
AlignedBoundingBox3D localBox = cameraPose * *box;
AlignedBoundingBox3D globalBox = carPose * localBox;
result.push_back(boost::make_shared<AlignedBoundingBox3D>(globalBox));
}
_resource->setPointCloudSensorData(result);
}
}
}
// Sleep if necessary
std::this_thread::sleep_until(end_time);
}
}
| 26.676056
| 85
| 0.705385
|
AppliedAutonomyOffenburg
|
37e2673f2999bd31119a861aafa20330ee138ccc
| 701
|
cpp
|
C++
|
Part_DepoisonerState.cpp
|
sknjpn/SyLife
|
b215cba87096db52ac63931db64c967f906b9172
|
[
"MIT"
] | 5
|
2022-01-05T10:04:40.000Z
|
2022-01-11T13:23:43.000Z
|
Part_DepoisonerState.cpp
|
sknjpn/SyLife
|
b215cba87096db52ac63931db64c967f906b9172
|
[
"MIT"
] | 1
|
2022-01-05T10:51:42.000Z
|
2022-01-05T13:25:41.000Z
|
Part_DepoisonerState.cpp
|
sknjpn/SyLife
|
b215cba87096db52ac63931db64c967f906b9172
|
[
"MIT"
] | null | null | null |
#include "Part_DepoisonerState.h"
#include "CellState.h"
#include "PartConfig.h"
#include "Part_DepoisonerAsset.h"
#include "World.h"
Part_DepoisonerState::Part_DepoisonerState(
const std::shared_ptr<PartConfig>& partConfig)
: PartState(partConfig)
, m_Part_DepoisonerAsset(std::dynamic_pointer_cast<Part_DepoisonerAsset>(partConfig->getPartAsset())) { }
void Part_DepoisonerState::update(CellState& cellState) {
cellState.m_bioaccumulation = Max(0.0, cellState.m_bioaccumulation - m_Part_DepoisonerAsset->getAmount() * DeltaTime);
}
void Part_DepoisonerState::load(Deserializer<BinaryReader>& reader) { }
void Part_DepoisonerState::save(Serializer<MemoryWriter>& writer) const { }
| 36.894737
| 120
| 0.787447
|
sknjpn
|
37ed7b523f4dc9697c7f99da7152d2297a5c44c8
| 608
|
cpp
|
C++
|
MMOCoreORB/src/server/zone/objects/creature/ai/bt/NonDeterministicBehavior.cpp
|
V-Fib/FlurryClone
|
40e0ca7245ec31b3815eb6459329fd9e70f88936
|
[
"Zlib",
"OpenSSL"
] | 18
|
2017-02-09T15:36:05.000Z
|
2021-12-21T04:22:15.000Z
|
MMOCoreORB/src/server/zone/objects/creature/ai/bt/NonDeterministicBehavior.cpp
|
V-Fib/FlurryClone
|
40e0ca7245ec31b3815eb6459329fd9e70f88936
|
[
"Zlib",
"OpenSSL"
] | 61
|
2016-12-30T21:51:10.000Z
|
2021-12-10T20:25:56.000Z
|
MMOCoreORB/src/server/zone/objects/creature/ai/bt/NonDeterministicBehavior.cpp
|
V-Fib/FlurryClone
|
40e0ca7245ec31b3815eb6459329fd9e70f88936
|
[
"Zlib",
"OpenSSL"
] | 71
|
2017-01-01T05:34:38.000Z
|
2022-03-29T01:04:00.000Z
|
/*
* NonDeterministicBehavior.cpp
*
* Created on: Jun 11, 2014
* Author: swgemu
*/
#include "NonDeterministicBehavior.h"
NonDeterministicBehavior::NonDeterministicBehavior(AiAgent* _agent, const String& className) : CompositeBehavior(_agent, className) {
}
void NonDeterministicBehavior::start() {
// this is literally just a shuffle algorithm
Behavior* temp;
int index;
for (int i = 0; i < children.size(); i++) {
index = (int) System::random(children.size() - 1 - i) + i;
temp = children.set(i, children.get(index));
children.set(index, temp);
}
CompositeBehavior::start();
}
| 21.714286
| 133
| 0.694079
|
V-Fib
|
37f23cd8f16088179f668b03ec66f38430db3276
| 162
|
cpp
|
C++
|
CppPrimer/CppPrimer-Exercises/CppPrimer-Ch02/Exercise2.39.cpp
|
alaxion/Learning
|
4b12b1603419252103cd933fdbfc4b2faffb6d00
|
[
"MIT"
] | null | null | null |
CppPrimer/CppPrimer-Exercises/CppPrimer-Ch02/Exercise2.39.cpp
|
alaxion/Learning
|
4b12b1603419252103cd933fdbfc4b2faffb6d00
|
[
"MIT"
] | null | null | null |
CppPrimer/CppPrimer-Exercises/CppPrimer-Ch02/Exercise2.39.cpp
|
alaxion/Learning
|
4b12b1603419252103cd933fdbfc4b2faffb6d00
|
[
"MIT"
] | null | null | null |
// Exercise2.39.cpp
// Ad
// Compile the following code.
#include <iostream>
struct Foo { }
int main()
{
// Pause
std::cin.get();
return 0;
}
| 10.8
| 31
| 0.561728
|
alaxion
|
37f5c617ea45fe410bc18b2cfdbddd49e86da526
| 750
|
hpp
|
C++
|
neat/phenotype/feed_forward.hpp
|
madcato/neat-libtorch
|
b486b01606a9a6951f595c6a17d6dd1a576afed0
|
[
"BSL-1.0"
] | null | null | null |
neat/phenotype/feed_forward.hpp
|
madcato/neat-libtorch
|
b486b01606a9a6951f595c6a17d6dd1a576afed0
|
[
"BSL-1.0"
] | null | null | null |
neat/phenotype/feed_forward.hpp
|
madcato/neat-libtorch
|
b486b01606a9a6951f595c6a17d6dd1a576afed0
|
[
"BSL-1.0"
] | null | null | null |
#ifndef FEED_FORWARD_HPP_
#define FEED_FORWARD_HPP_
#include <memory>
#include <torch/torch.h>
#include <vector>
#include "neat/unit.hpp"
#include "neat/experiments/config.hpp"
#include "neat/genotype/genome.hpp"
class FeedForwardImpl: public torch::nn::Module {
public:
FeedForwardImpl(const Genome& genome, std::shared_ptr<Config> config, const torch::Device& device);
torch::Tensor forward(torch::Tensor x);
std::vector<Unit> build_units();
private:
Genome genome;
std::vector<Unit> units;
torch::nn::ModuleList lin_modules;
std::shared_ptr<Config> config;
std::function<torch::Tensor(const torch::Tensor&)> activation;
torch::Device device;
};
TORCH_MODULE(FeedForward);
#endif // FEED_FORWARD_HPP_
| 23.4375
| 104
| 0.726667
|
madcato
|
37f64f9f66a727dfb9a4ec52ddc621a65b50bec2
| 485
|
cpp
|
C++
|
kactl/stress-tests/number-theory/ModSqrt.cpp
|
prince776/CodeBook
|
874fc7f94011ad1d25a55bcd91fecd2a11eb5a9b
|
[
"CC0-1.0"
] | 17
|
2021-01-25T12:07:17.000Z
|
2022-02-26T17:20:31.000Z
|
kactl/stress-tests/number-theory/ModSqrt.cpp
|
NavneelSinghal/CodeBook
|
ff60ace9107dd19ef8ba81e175003f567d2a9070
|
[
"CC0-1.0"
] | null | null | null |
kactl/stress-tests/number-theory/ModSqrt.cpp
|
NavneelSinghal/CodeBook
|
ff60ace9107dd19ef8ba81e175003f567d2a9070
|
[
"CC0-1.0"
] | 4
|
2021-02-28T11:13:44.000Z
|
2021-11-20T12:56:20.000Z
|
#include "../utilities/template.h"
ll modpow(ll a, ll e, ll mod) {
if (e == 0) return 1;
ll x = modpow(a * a % mod, e >> 1, mod);
return e & 1 ? x * a % mod : x;
}
#include "../../content/number-theory/ModSqrt.h"
int main() {
rep(p,2,10000) {
rep(i,2,p) if (p % i == 0) goto next;
rep(a,0,p) {
if (p != 2 && modpow(a, (p-1)/2, p) == p-1) continue;
ll x = sqrt(a, p);
assert(0 <= x && x < p);
assert(x * x % p == a);
}
next:;
}
cout<<"Tests passed!"<<endl;
}
| 20.208333
| 56
| 0.496907
|
prince776
|
37fcc57fb905dc1dc416279dc54350590d56ba33
| 417
|
cpp
|
C++
|
Common/src/interrupt_lock.cpp
|
foxostro/FlapjackOS
|
34bd2cc9b0983b917a089efe2055ca8f78d56d9a
|
[
"BSD-2-Clause"
] | null | null | null |
Common/src/interrupt_lock.cpp
|
foxostro/FlapjackOS
|
34bd2cc9b0983b917a089efe2055ca8f78d56d9a
|
[
"BSD-2-Clause"
] | null | null | null |
Common/src/interrupt_lock.cpp
|
foxostro/FlapjackOS
|
34bd2cc9b0983b917a089efe2055ca8f78d56d9a
|
[
"BSD-2-Clause"
] | null | null | null |
#include <common/interrupt_lock.hpp>
std::atomic<int> InterruptLock::count_{0};
static void nop() {}
void (*InterruptLock::enable_interrupts)() = ::nop;
void (*InterruptLock::disable_interrupts)() = ::nop;
void InterruptLock::lock()
{
if (count_.fetch_add(1) == 0) {
disable_interrupts();
}
}
void InterruptLock::unlock()
{
if (count_.fetch_sub(1) == 1) {
enable_interrupts();
}
}
| 18.954545
| 52
| 0.640288
|
foxostro
|
53010b31adb85b493126efb276e2c9c51e373cc7
| 305
|
hpp
|
C++
|
ParamedicCommander.hpp
|
avichai1221/WarGame
|
884002a45ce42a1d6e54193cb4cffc03c4d138cf
|
[
"MIT"
] | null | null | null |
ParamedicCommander.hpp
|
avichai1221/WarGame
|
884002a45ce42a1d6e54193cb4cffc03c4d138cf
|
[
"MIT"
] | null | null | null |
ParamedicCommander.hpp
|
avichai1221/WarGame
|
884002a45ce42a1d6e54193cb4cffc03c4d138cf
|
[
"MIT"
] | null | null | null |
#include "Soldier.hpp"
//namespace WarGame {
class ParamedicCommander : public Soldier {
public:
explicit ParamedicCommander(int teamNum): Soldier(200, -1, teamNum) {}
void attack (std::vector<std::vector<Soldier*>> &board, int first, int second) override ;
};
//};
| 15.25
| 97
| 0.636066
|
avichai1221
|
53015506c754de23ffd5710da172d6e55b0dd625
| 2,075
|
hpp
|
C++
|
include/turbo/Component.hpp
|
mariusvn/turbo-engine
|
63cc2b76bc1aff7de9655916553a03bd768f5879
|
[
"MIT"
] | 2
|
2021-02-12T13:05:02.000Z
|
2021-02-22T14:25:00.000Z
|
include/turbo/Component.hpp
|
mariusvn/turbo-engine
|
63cc2b76bc1aff7de9655916553a03bd768f5879
|
[
"MIT"
] | null | null | null |
include/turbo/Component.hpp
|
mariusvn/turbo-engine
|
63cc2b76bc1aff7de9655916553a03bd768f5879
|
[
"MIT"
] | null | null | null |
#ifndef __TURBO_COMPONENT_HPP__
#define __TURBO_COMPONENT_HPP__
#include "debug_menus/Inspector.hpp"
#include <vector>
namespace turbo {
class GameObject;
/**
* @brief Components who defines the behaviour of a GameObject
*/
class Component {
public:
/**
* @brief Construct a new Component. The component will be
* automatically added to the GameObject given as parameter
*
* @param parent GameObject that holds the component
*/
explicit Component(GameObject* parent);
/**
* @brief Called when the component is loaded into the scene.
*/
virtual void load() {};
/**
* @brief Called when the component is disabled
*/
virtual void on_disable() {};
/**
* @brief Called when the component is enabled (Not
* called on the first initialization)
*/
virtual void on_enable() {};
/**
* @brief Logic update. Souldn't be used for anything else
* than logic.
*
* @param delta_time milliseconds since the last call
*/
virtual void update(int delta_time) {};
/**
* @brief Called when the component is unloaded
*/
virtual void unload() {};
/**
* @brief Disable the component. Do nothing if already disabled
*/
void disable();
/**
* @brief Enable the component. Do nothing if already enabled
*/
void enable();
/**
* @brief Check if the component is enabled
*
* @return true if enabled
*/
bool is_enabled();
const char* get_name() const;
/**
* @brief Debug use only. List of observed values in the inspector
*/
::std::vector<debug::InspectorObserver*> debug_inspector_observers{};
protected:
GameObject* gameObject = nullptr;
bool enabled = true;
const char *name = "Unknown";
};
}
#endif
| 24.702381
| 77
| 0.553253
|
mariusvn
|
530ff0e4c13d737d67847a8709a2b16f180d34c6
| 1,357
|
hpp
|
C++
|
__unit_tests/gv_base_unit_test/unit_test_stack.hpp
|
dragonsn/gv_game_engine
|
dca6c1fb1f8d96e9a244f157a63f8a69da084b0f
|
[
"MIT"
] | 2
|
2018-12-03T13:17:31.000Z
|
2020-04-08T07:00:02.000Z
|
__unit_tests/gv_base_unit_test/unit_test_stack.hpp
|
dragonsn/gv_game_engine
|
dca6c1fb1f8d96e9a244f157a63f8a69da084b0f
|
[
"MIT"
] | null | null | null |
__unit_tests/gv_base_unit_test/unit_test_stack.hpp
|
dragonsn/gv_game_engine
|
dca6c1fb1f8d96e9a244f157a63f8a69da084b0f
|
[
"MIT"
] | null | null | null |
namespace unit_test_stack
{
void main(gvt_array< gv_string >& args)
{
{
gvt_stack< int > array;
GV_TEST_PRINT_FUNC(array.push(2), test_log());
GV_TEST_PRINT_FUNC(array.push(1), test_log());
GV_TEST_PRINT_FUNC(array.push(3), test_log());
GV_TEST_PRINT_FUNC(array.push(22), test_log());
// std::copy(array.begin(), array.end(), std::ostream_iterator<int>(test_log(), " "));test_log()<<gv_endl;;
GV_TEST_PRINT_FUNC(array.pop(), test_log());
GV_TEST_PRINT_VAR(array.top(), test_log());
GV_TEST_PRINT_FUNC(array.pop(), test_log());
GV_TEST_PRINT_VAR(array.top(), test_log());
// std::copy(array.begin(), array.end(), std::ostream_iterator<int>(test_log(), " "));test_log()<<gv_endl;;
}
{
gvt_stack_static< int, 12 > array;
GV_TEST_PRINT_FUNC(array.push(2), test_log());
GV_TEST_PRINT_FUNC(array.push(1), test_log());
GV_TEST_PRINT_FUNC(array.push(3), test_log());
GV_TEST_PRINT_FUNC(array.push(22), test_log());
// std::copy(array.begin(), array.end(), std::ostream_iterator<int>(test_log(), " "));test_log()<<gv_endl;;
GV_TEST_PRINT_FUNC(array.pop(), test_log());
GV_TEST_PRINT_VAR(array.top(), test_log());
GV_TEST_PRINT_FUNC(array.pop(), test_log());
GV_TEST_PRINT_VAR(array.top(), test_log());
// std::copy(array.begin(), array.end(), std::ostream_iterator<int>(test_log(), " "));test_log()<<gv_endl;;
}
}
}
| 38.771429
| 109
| 0.68902
|
dragonsn
|
5311219ae58959ef49f0b4cda80eab3270e15931
| 2,775
|
cpp
|
C++
|
RenderingEngine/Mesh.cpp
|
Tidus-Zheng/ray-tracing
|
ebafcbafd15488ec16e94d7785ea79d3b0904529
|
[
"MIT"
] | null | null | null |
RenderingEngine/Mesh.cpp
|
Tidus-Zheng/ray-tracing
|
ebafcbafd15488ec16e94d7785ea79d3b0904529
|
[
"MIT"
] | null | null | null |
RenderingEngine/Mesh.cpp
|
Tidus-Zheng/ray-tracing
|
ebafcbafd15488ec16e94d7785ea79d3b0904529
|
[
"MIT"
] | null | null | null |
#include "Mesh.h"
#include "Scene.h"
void Mesh::setupMesh()
{
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glGenBuffers(1, &EBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(Vertex), &vertices[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(GLuint), &indices[0], GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Vertex::normal));
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Vertex::uv));
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Vertex::tangent));
glEnableVertexAttribArray(4);
glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Vertex::bitangent));
glBindVertexArray(0);
}
Mesh::Mesh(vector<Vertex> vertices, vector<GLuint> indices)
{
this->vertices = vertices;
this->indices = indices;
this->material = make_unique<Material>();
setupMesh();
}
//render with material
void Mesh::Draw(mat4x4 model) {
mat4x4 m, view, proj;
Camera* camera = Scene::Instance().camera;
DirectionalLight* light = &Scene::Instance().directionLight;
material->shader->UseProgram();
camera->GetViewMatrix(view);
camera->GetProjMatrix(proj);
glUniformMatrix4fv(material->shader->GetUniformLocation("model"), 1, GL_FALSE, (const GLfloat*)model);
glUniformMatrix4fv(material->shader->GetUniformLocation("view"), 1, GL_FALSE, (const GLfloat*)view);
glUniformMatrix4fv(material->shader->GetUniformLocation("proj"), 1, GL_FALSE, (const GLfloat*)proj);
glm::vec3 lightDir = light->GetDir();
glm::vec3 lightColor = light->color;
glm::vec3 cameraPosition = camera->GetPosition();
glUniform3f(material->shader->GetUniformLocation("lightDir"), lightDir.x, lightDir.y, lightDir.z);
glUniform3f(material->shader->GetUniformLocation("lightColor"), lightColor.x, lightColor.y, lightColor.z);
glUniform3f(material->shader->GetUniformLocation("cameraPos"), cameraPosition.x, cameraPosition.y, cameraPosition.z);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material->diffuse.GetID());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, material->normal.GetID());
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, material->specular.GetID());
//glActiveTexture(GL_TEXTURE0);
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}
| 37
| 118
| 0.763604
|
Tidus-Zheng
|
5312d19f48d9bc3055e871c27d722498ce848720
| 919
|
cpp
|
C++
|
events/masterpiece_created_food.cpp
|
BenLubar/weblegends
|
0eea0239c57ffc2540adc4d312f446cafafeb2c5
|
[
"Zlib"
] | 16
|
2018-02-05T17:44:12.000Z
|
2022-03-03T13:37:06.000Z
|
events/masterpiece_created_food.cpp
|
BenLubar/weblegends
|
0eea0239c57ffc2540adc4d312f446cafafeb2c5
|
[
"Zlib"
] | 12
|
2017-10-25T13:25:22.000Z
|
2022-03-12T19:27:54.000Z
|
events/masterpiece_created_food.cpp
|
BenLubar/weblegends
|
0eea0239c57ffc2540adc4d312f446cafafeb2c5
|
[
"Zlib"
] | 5
|
2017-10-25T13:30:45.000Z
|
2018-08-03T12:51:40.000Z
|
#include "../helpers_event.h"
#include "df/history_event_masterpiece_created_foodst.h"
#include "df/itemdef_foodst.h"
void do_event(std::ostream & s, const event_context & context, df::history_event_masterpiece_created_foodst *event)
{
auto maker = df::historical_figure::find(event->maker);
auto maker_entity = df::historical_entity::find(event->maker_entity);
auto site = df::world_site::find(event->site);
auto subtype = df::itemdef_foodst::find(event->item_subtype);
auto item = df::item::find(event->item_id);
event_link(s, context, maker);
s << " cooked a masterful ";
if (item)
{
do_item_description(s, context, item);
}
else
{
s << subtype->name;
}
if (maker_entity)
{
s << " for ";
event_link(s, context, maker_entity);
}
if (site)
{
s << " in ";
event_link(s, context, site);
}
}
| 24.837838
| 115
| 0.621328
|
BenLubar
|
5316af963e84f336552cc7371f37632be366451c
| 3,877
|
cpp
|
C++
|
pose_state_time/src/examples/rotation_test.cpp
|
andreucm/btr-libs
|
a887a78fc4c63a74311e2745b810b8b0dd9f48cb
|
[
"BSD-2-Clause-FreeBSD"
] | 1
|
2015-06-21T19:50:11.000Z
|
2015-06-21T19:50:11.000Z
|
pose_state_time/src/examples/rotation_test.cpp
|
beta-robots/btr-libs
|
a887a78fc4c63a74311e2745b810b8b0dd9f48cb
|
[
"BSD-2-Clause-FreeBSD"
] | null | null | null |
pose_state_time/src/examples/rotation_test.cpp
|
beta-robots/btr-libs
|
a887a78fc4c63a74311e2745b810b8b0dd9f48cb
|
[
"BSD-2-Clause-FreeBSD"
] | null | null | null |
#include <cstdlib>
#include "rotation.h"
int main(int argc, char** argv)
{
Crotation rt1, rt2, rt3;
Cquaternion qt1;
dlib::matrix<double,3,3> rM1;
dlib::matrix<double,3,1> axis;
double angle;
unsigned ii,jj,kk;
double euH, euP, euR; //euler angles;
int testId = atoi(argv[1]);
//test switch
switch(testId)
{
case 1:
std::cout << std::endl << "******************** TEST 1 ****************************" << std::endl;
rt1.setEuler(45,60,30,inDEGREES);
rt1.print();
qt1.set(0.822363,0.02226,0.531976,0.200562);
rt2.setQuaternion(qt1);
rt2.print();
std::cout << "rt2.head: " << rt2.head(inDEGREES) << "; rt2.pitch: " << rt2.pitch(inDEGREES) << "; rt2.roll: " << rt2.roll(inDEGREES) <<std::endl;
rM1 = 0.353553,-0.306186,0.883884, 0.353553,0.918559,0.176777, -0.866026,0.25,0.433012;
rt3.setMatrix(rM1);
rt3.print();
break;
case 2:
std::cout << std::endl << "******************** TEST 2 ****************************" << std::endl;
rt1.setEuler(0,0,0);
rt1.print();
rt1.rotateUaxis(30,0,0,1, inDEGREES);
rt1.print();
rt1.getAxisAngle(axis,angle);
std::cout << "axis: " << dlib::trans(axis);
std::cout << "angle: " << angle << std::endl;
break;
case 3:
std::cout << std::endl << "******************** TEST 3 ****************************" << std::endl;
rt1.setEuler(-M_PI+M_PI/100,-M_PI/2+M_PI/100,-M_PI+M_PI/100);
rt1.getMatrix(rM1);
rt1.getQuaternion(qt1);
std::cout << "rM1: " << std::endl << rM1;
std::cout << "qt1: " << std::endl << qt1.qq << std::endl;
rt1.setEuler(M_PI-M_PI/100,M_PI/2-M_PI/100,M_PI-M_PI/100);
rt1.getMatrix(rM1);
rt1.getQuaternion(qt1);
std::cout << "rM1: " << std::endl << rM1;
std::cout << "qt1: " << std::endl << qt1.qq << std::endl;
rM1 = 0,0,1,0,1,0,-1,0,0;
rt1.setMatrix(rM1);
rt1.getQuaternion(qt1);
std::cout << "rM1: " << std::endl << rM1;
std::cout << "qt1: " << std::endl << qt1.qq;
std::cout << "h: " << rt1.head(inDEGREES) << "; p: " << rt1.pitch(inDEGREES) << "; r: " << rt1.roll(inDEGREES) <<std::endl;
break;
case 4:
std::cout << std::endl << "******************** TEST 4 ****************************" << std::endl;
for(ii=1; ii<=10; ii++)//heading, (-pi,pi]
{
euH = -M_PI+ii*(2*M_PI/10);
for(jj=1; jj<=5; jj++)//pitch, (-pi/2,pi/2]
{
euP = -M_PI/2+jj*(2*M_PI/10);
for(kk=1; kk<=10; kk++)//roll, (-pi,pi]
{
euR = -M_PI+kk*(2*M_PI/10);
rt1.setEuler(euH,euP,euR);
rt1.getMatrix(rM1);
rt1.getQuaternion(qt1);
std::cout << rM1;
std::cout << qt1.qq;
}
}
}
break;
default:
break;
}
return 0;
}
| 41.688172
| 163
| 0.354656
|
andreucm
|
5318df4a684b41ad4df96806afb0e062fe3295dd
| 577
|
cpp
|
C++
|
Source/GameObject.cpp
|
yuhongyi/HazelEngine
|
fad6eb1f42ad7ac06b8a0e9e2d3154147b3a7c9c
|
[
"MIT"
] | null | null | null |
Source/GameObject.cpp
|
yuhongyi/HazelEngine
|
fad6eb1f42ad7ac06b8a0e9e2d3154147b3a7c9c
|
[
"MIT"
] | null | null | null |
Source/GameObject.cpp
|
yuhongyi/HazelEngine
|
fad6eb1f42ad7ac06b8a0e9e2d3154147b3a7c9c
|
[
"MIT"
] | null | null | null |
#include "Globals.h"
#include "GameObject.h"
GameObject::GameObject() :
mId(-1),
mPosition(-1.f, -1.f),
mSize(0.f, 0.f)
{
}
GameObject::GameObject(Vector2D size):
mId(-1),
mPosition(-1.f, -1.f),
mSize(size)
{
}
int GameObject::GetID()
{
return mId;
}
void GameObject::SetID(int id)
{
mId = id;
}
Vector2D GameObject::GetPosition() const
{
return mPosition;
}
void GameObject::SetPosition(Vector2D newPosition)
{
mPosition = newPosition;
}
void GameObject::SetSize(Vector2D newSize)
{
mSize = newSize;
}
Vector2D GameObject::GetSize() const
{
return mSize;
}
| 12.543478
| 50
| 0.684575
|
yuhongyi
|
531c08890565ae5fbcf5f3b9eb7a1579fa752078
| 521
|
cpp
|
C++
|
ConsoleCentre/CentreText.cpp
|
uaineteine/ConsoleCentre
|
fb4d25d14ea33bc55dc41f8bf4d7c83c55d4892b
|
[
"MIT"
] | null | null | null |
ConsoleCentre/CentreText.cpp
|
uaineteine/ConsoleCentre
|
fb4d25d14ea33bc55dc41f8bf4d7c83c55d4892b
|
[
"MIT"
] | null | null | null |
ConsoleCentre/CentreText.cpp
|
uaineteine/ConsoleCentre
|
fb4d25d14ea33bc55dc41f8bf4d7c83c55d4892b
|
[
"MIT"
] | null | null | null |
#include "CentreText.h"
void centreText(char * input, int consoleSize)
{
int l = strlen(input);
int pos = (int)((consoleSize - l) / 2);
for (int i = 0; i < pos; i++)
cout << " ";
cout << input << endl;
}
void centreText(char * input)
{
centreText(input, defConsoleSize);
}
void centreText(string input, int consoleSize)
{
char *ToPrint = new char[input.length() + 1];
strcpy(ToPrint, input.c_str());
centreText(ToPrint, consoleSize);
}
void centreText(string input)
{
centreText(input, defConsoleSize);
}
| 17.965517
| 46
| 0.667946
|
uaineteine
|
531f0512da634f223450b2c7d9f5daaa2b90f999
| 2,226
|
hh
|
C++
|
nox/src/nox/netapps/authenticator/flow_fn_map.hh
|
ayjazz/OESS
|
deadc504d287febc7cbd7251ddb102bb5c8b1f04
|
[
"Apache-2.0"
] | 28
|
2015-02-04T13:59:25.000Z
|
2021-12-29T03:44:47.000Z
|
nox/src/nox/netapps/authenticator/flow_fn_map.hh
|
ayjazz/OESS
|
deadc504d287febc7cbd7251ddb102bb5c8b1f04
|
[
"Apache-2.0"
] | 552
|
2015-01-05T18:25:54.000Z
|
2022-03-16T18:51:13.000Z
|
nox/src/nox/netapps/authenticator/flow_fn_map.hh
|
ayjazz/OESS
|
deadc504d287febc7cbd7251ddb102bb5c8b1f04
|
[
"Apache-2.0"
] | 25
|
2015-02-04T18:48:20.000Z
|
2020-06-18T15:51:05.000Z
|
/* Copyright 2008, 2009 (C) Nicira, Inc.
*
* This file is part of NOX.
*
* NOX 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.
*
* NOX 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 NOX. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLOW_FN_MAP_HH
#define FLOW_FN_MAP_HH 1
#include "hash_map.hh"
#include "flow_in.hh"
/*
* Holds string --> Flow_fn mappings.
*/
namespace vigil {
class Flow_fn_map
{
public:
typedef boost::function<void(const Flow_in_event&)> Flow_fn;
typedef boost::function<bool(const std::vector<std::string>&)> Validate_fn;
typedef boost::function<Flow_fn(const std::vector<std::string>&)> Generate_fn;
Flow_fn_map() {}
~Flow_fn_map() {}
// returns false if fn cannot be registered (string key already exists).
// assumes functions takes 0 string arguments
bool register_function(const std::string&, const Flow_fn&);
// returns false if fn cannot be registered (string key already exists)
bool register_function(const std::string&, const Generate_fn&, const Validate_fn&);
// returns false if function not present to remove
bool remove_function(const std::string&);
// returns an empty function if mapping does not exists, else the fn
Flow_fn get_function(const std::string&,
const std::vector<std::string>& args) const;
// returns true if arguments are valid for function
bool valid_fn_args(const std::string&, const std::vector<std::string>&) const;
private:
struct fn_entry {
Generate_fn generate;
Validate_fn validate;
};
hash_map<std::string, fn_entry> fns;
Flow_fn empty;
Flow_fn_map(const Flow_fn_map&);
Flow_fn_map& operator=(const Flow_fn_map&);
};
} // namespace vigil
#endif
| 30.493151
| 87
| 0.704403
|
ayjazz
|
5321fded148608d23581ef9702c96cc16a25c029
| 3,118
|
hpp
|
C++
|
include/caffe/data_transformer.hpp
|
ChenglongChen/caffe-windows
|
c72d55e5258a05f88c02e8ae636838c43b11187f
|
[
"BSD-2-Clause"
] | 110
|
2015-02-28T10:48:57.000Z
|
2020-01-30T14:34:39.000Z
|
include/caffe/data_transformer.hpp
|
ChenglongChen/caffe-windows
|
c72d55e5258a05f88c02e8ae636838c43b11187f
|
[
"BSD-2-Clause"
] | 7
|
2015-05-21T00:25:02.000Z
|
2018-04-03T12:59:46.000Z
|
include/caffe/data_transformer.hpp
|
ChenglongChen/caffe-windows
|
c72d55e5258a05f88c02e8ae636838c43b11187f
|
[
"BSD-2-Clause"
] | 64
|
2015-03-05T13:50:14.000Z
|
2019-09-16T11:24:32.000Z
|
#ifndef CAFFE_DATA_TRANSFORMER_HPP
#define CAFFE_DATA_TRANSFORMER_HPP
#include "caffe/common.hpp"
#include "caffe/proto/caffe.pb.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
namespace caffe {
/**
* @brief Applies common transformations to the input data, such as
* scaling, mirroring, substracting the image mean...
*/
template <typename Dtype>
class DataTransformer {
public:
explicit DataTransformer(const TransformationParameter& param)
: param_(param) {
phase_ = Caffe::phase();
}
virtual ~DataTransformer() {}
void InitRand();
void FillInOffsets(int *w, int *h, int width, int height, int crop_size) {
FillInOffsets(w, h, width, height, crop_size, crop_size);
// w[0] = 0; h[0] = 0;
// w[1] = 0; h[1] = height - crop_size;
// w[2] = width - crop_size; h[2] = 0;
// w[3] = width - crop_size; h[3] = height - crop_size;
// w[4] = (width - crop_size) / 2; h[4] = (height - crop_size) / 2;
}
void FillInOffsets(int *w, int *h, int width, int height, int crop_w, int crop_h) {
if (crop_w < width * 2 / 3 && crop_h < height * 2 / 3) {
// we want to be conservative when the crop is small
w[0] = 0; h[0] = (height - crop_h) / 2;
w[1] = width - crop_w; h[1] = (height - crop_h) / 2;
w[2] = (width - crop_w) / 2; h[2] = 0;
w[3] = (width - crop_w) / 2; h[3] = height - crop_h;
w[4] = (width - crop_w) / 2; h[4] = (height - crop_h) / 2;
}
else {
w[0] = 0; h[0] = 0;
w[1] = 0; h[1] = height - crop_h;
w[2] = width - crop_w; h[2] = 0;
w[3] = width - crop_w; h[3] = height - crop_h;
w[4] = (width - crop_w) / 2; h[4] = (height - crop_h) / 2;
}
}
/**
* @brief Applies the transformation defined in the data layer's
* transform_param block to the data.
*
* @param batch_item_id
* Datum position within the batch. This is used to compute the
* writing position in the top blob's data
* @param datum
* Datum containing the data to be transformed.
* @param mean
* @param transformed_data
* This is meant to be the top blob's data. The transformed data will be
* written at the appropriate place within the blob's data.
*/
void Transform(const int batch_item_id, const Datum& datum,
const Dtype* mean, Dtype* transformed_data);
void Transform(const int batch_item_id, IplImage *img,
const Dtype* mean, Dtype* transformed_data);
protected:
virtual unsigned int Rand();
virtual float Uniform(const float min, const float max);
void TransformSingle(const int batch_item_id, IplImage *img,
const Dtype* mean, Dtype* transformed_data);
void TransformMultiple(const int batch_item_id, IplImage *img,
const Dtype* mean, Dtype* transformed_data);
// Tranformation parameters
TransformationParameter param_;
shared_ptr<Caffe::RNG> rng_;
Caffe::Phase phase_;
};
} // namespace caffe
#endif // CAFFE_DATA_TRANSFORMER_HPP_
| 33.170213
| 85
| 0.635022
|
ChenglongChen
|
5322a91e4ff5540324dff3fb142e9898f90bee6d
| 10,726
|
cpp
|
C++
|
src/Texture.cpp
|
m-iDev-0792/HJGraphics
|
dedd324c6fd6a5b9549fcabad7e5225aefa15e00
|
[
"MIT"
] | 3
|
2019-07-08T12:11:59.000Z
|
2019-07-10T13:23:14.000Z
|
src/Texture.cpp
|
m-iDev-0792/HJGraphics
|
dedd324c6fd6a5b9549fcabad7e5225aefa15e00
|
[
"MIT"
] | null | null | null |
src/Texture.cpp
|
m-iDev-0792/HJGraphics
|
dedd324c6fd6a5b9549fcabad7e5225aefa15e00
|
[
"MIT"
] | 1
|
2020-12-30T13:27:14.000Z
|
2020-12-30T13:27:14.000Z
|
//
// Created by bytedance on 2021/6/19.
//
#define STB_IMAGE_IMPLEMENTATION
#include "Texture.h"
#include "stb/stb_image.h"
/*
* Implementation of Texture2D
*/
HJGraphics::Texture::Texture(GLuint _type,GLuint _texN) {
type=_type;
textureN=_texN;
}
HJGraphics::Texture::~Texture() {
}
/*
* Implementation of Texture2D
*/
const auto DEFAULT_MIN_FILTER=GL_LINEAR_MIPMAP_LINEAR;
HJGraphics::Texture2D::Texture2D(const std::string &path, bool gammaCorrection) : Texture(GL_TEXTURE_2D){
glGenTextures(1,&id);
texWrapS=GL_REPEAT;
texWrapT=GL_REPEAT;
texMinFilter=DEFAULT_MIN_FILTER;
texMagFilter=GL_LINEAR;
loadFromPath(path, gammaCorrection);
}
HJGraphics::Texture2D::Texture2D(const std::string &_path, const GLint& _texWrap, bool gammaCorrection): Texture(GL_TEXTURE_2D){
glGenTextures(1,&id);
texWrapS=texWrapT=_texWrap;
texMinFilter=DEFAULT_MIN_FILTER;
texMagFilter=GL_LINEAR;
loadFromPath(_path, gammaCorrection);
}
HJGraphics::Texture2D::Texture2D() :Texture(GL_TEXTURE_2D){
glGenTextures(1,&id);
texWrapS=GL_REPEAT;
texWrapT=GL_REPEAT;
texMinFilter=DEFAULT_MIN_FILTER;
texMagFilter=GL_LINEAR;
}
HJGraphics::Texture2D::Texture2D(int _width, int _height, GLenum _internalFormat, GLenum _format, GLenum _dataType, GLenum _filter, GLenum _wrap): Texture(GL_TEXTURE_2D){
texWidth=_width;
texHeight=_height;
texMinFilter=texMagFilter=_filter;
texWrapS=texWrapT=_wrap;
glGenTextures(1, &id);
GL.activeTexture(GL_TEXTURE0);
GL.bindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, 0, _internalFormat, texWidth, texHeight, 0, _format, _dataType, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, _wrap);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, _wrap);
}
void HJGraphics::Texture2D::loadFromPath(const std::string &_path, bool gammaCorrection) {
GL.activeTexture(GL_TEXTURE0+textureN);
GL.bindTexture(GL_TEXTURE_2D, id);
int imgWidth,imgHeight,imgChannel;
bool loadHDR=false;
void *data=nullptr;
GLuint dataType;
if(_path.substr(_path.size()-3,3)==std::string("hdr")){
loadHDR=true;
data=stbi_loadf(_path.c_str(), &imgWidth, &imgHeight, &imgChannel, 0);
dataType=GL_FLOAT;
}else{
data=stbi_load(_path.c_str(), &imgWidth, &imgHeight, &imgChannel, 0);
dataType=GL_UNSIGNED_BYTE;
}
if(data!= nullptr) {
GLuint format,internalFormat;
if(imgChannel==1){
format=GL_RED;
internalFormat=format;
}
else if(imgChannel==3){
format=GL_RGB;
if(loadHDR)internalFormat=GL_RGB16F;
else internalFormat=gammaCorrection?GL_SRGB:format;
}
else if(imgChannel==4){
format=GL_RGBA;
if(loadHDR)internalFormat=GL_RGBA16F;
else internalFormat=gammaCorrection?GL_SRGB_ALPHA:format;
}
else{
std::cerr<<"ERROR @ Texture2D::loadFromPath : can't solve image channel (channel = "<<imgChannel<<")"<<std::endl;
return;
}
texWidth=imgWidth;texHeight=imgHeight;texChannel=imgChannel;
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, imgWidth, imgHeight, 0, format,
dataType, data);
if(DEFAULT_MIN_FILTER!=GL_NEAREST)glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texWrapS);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texWrapT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texMinFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texMagFilter);
stbi_image_free(data);
path=_path;
}else{
std::cerr << "ERROR @ Texture2D::loadFromPath : can't load image: " << _path << std::endl;
}
}
HJGraphics::SolidTexture::SolidTexture():SolidTexture(glm::vec3(1)){
}
HJGraphics::SolidTexture::SolidTexture(glm::vec3 _color):Texture(GL_TEXTURE_2D){
glGenTextures(1,&id);
texWrapS=GL_REPEAT;
texWrapT=GL_REPEAT;
texMinFilter=GL_NEAREST;
texMagFilter=GL_NEAREST;
setColor(_color);
}
HJGraphics::SolidTexture::SolidTexture(float _color):Texture(GL_TEXTURE_2D){
glGenTextures(1,&id);
texWrapS=GL_REPEAT;
texWrapT=GL_REPEAT;
texMinFilter=GL_NEAREST;
texMagFilter=GL_NEAREST;
setColor(_color);
}
void HJGraphics::SolidTexture::setColor(float _color) {
color=glm::vec3(_color);
GL.activeTexture(GL_TEXTURE0+textureN);
GL.bindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1, 1, 0, GL_RED,GL_FLOAT, &_color);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texWrapS);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texWrapT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texMinFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texMagFilter);
}
void HJGraphics::SolidTexture::setColor(glm::vec3 _color) {
color=_color;
unsigned char data[3]={static_cast<unsigned char>(color.r*255),static_cast<unsigned char>(color.g*255),static_cast<unsigned char>(color.b*255)};
GL.activeTexture(GL_TEXTURE0+textureN);
GL.bindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB,
GL_UNSIGNED_BYTE, data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texWrapS);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texWrapT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texMinFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texMagFilter);
}
/*
* Implementation of CubeMapTexture
*/
HJGraphics::CubeMapTexture::CubeMapTexture() :Texture(GL_TEXTURE_CUBE_MAP){
glGenTextures(1,&id);
texWrapS=GL_CLAMP_TO_EDGE;
texWrapT=GL_CLAMP_TO_EDGE;
texWrapR=GL_CLAMP_TO_EDGE;
texMinFilter=GL_LINEAR;
texMagFilter=GL_LINEAR;
}
HJGraphics::CubeMapTexture::CubeMapTexture(int _width, int _height, GLenum _internalFormat, GLenum _format, GLenum _dataType, GLenum _filter, GLenum _wrap):Texture(GL_TEXTURE_CUBE_MAP){
texMinFilter=texMagFilter=_filter;
texWrapS=texWrapT=texWrapR=_wrap;
glGenTextures(1, &id);
GL.activeTexture(GL_TEXTURE0);
GL.bindTexture(GL_TEXTURE_CUBE_MAP, id);
for (GLuint i = 0; i < 6; ++i)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, _internalFormat, _width, _height, 0, _format, _dataType, nullptr);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, texMagFilter);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, texMinFilter);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, texWrapS);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, texWrapT);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, texWrapR);
}
HJGraphics::CubeMapTexture::CubeMapTexture(const std::string &rightTex, const std::string &leftTex, const std::string &upTex, const std::string &downTex,
const std::string &frontTex, const std::string &backTex,
GLuint texN): Texture(GL_TEXTURE_CUBE_MAP, texN) {
textureN=texN;
texWrapS=GL_CLAMP_TO_EDGE;
texWrapT=GL_CLAMP_TO_EDGE;
texWrapR=GL_CLAMP_TO_EDGE;
texMinFilter=GL_LINEAR;
texMagFilter=GL_LINEAR;
glGenTextures(1,&id);
loadFromPath(rightTex,leftTex,upTex,downTex,frontTex,backTex);
}
void HJGraphics::CubeMapTexture::loadFromPath(const std::string &rightTex, const std::string &leftTex, const std::string &upTex, const std::string &downTex,
const std::string &frontTex, const std::string &backTex) {
std::string tex[6]={rightTex,leftTex,upTex,downTex,frontTex,backTex};
GL.activeTexture(GL_TEXTURE0+textureN);
GL.bindTexture(GL_TEXTURE_CUBE_MAP,id);
for(int i=0;i<6;++i){
int imgWidth,imgHeight,imgChannel;
auto data=stbi_load(tex[i].c_str(),&imgWidth,&imgHeight,&imgChannel,0);
GLuint format;
if(imgChannel==1){
format=GL_RED;
}
else if(imgChannel==3){
format=GL_RGB;
}
else if(imgChannel==4){
format=GL_RGBA;
}else{
std::cout<<"ERROR @ CubeMapTexture::loadFromPath : can't solve image channel"<<std::endl;
return;
}
if(data!= nullptr) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, format, imgWidth, imgHeight, 0, format,
GL_UNSIGNED_BYTE, data);
stbi_image_free(data);
}else{
std::cout<<"ERROR @ CubeMapTexture::loadFromPath : can't load image: "<<tex[i]<<std::endl;
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, texMinFilter);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, texMagFilter);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, texWrapS);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, texWrapT);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, texWrapR);
}
}
/*
* Implementation of Material
*/
std::shared_ptr<HJGraphics::Texture2D> HJGraphics::operator ""_diffuse(const char* str,size_t n){
auto m=std::make_shared<Texture2D>(str,true);
m->usage="diffuse";
return m;
}
std::shared_ptr<HJGraphics::Texture2D> HJGraphics::operator ""_specular(const char* str,size_t n){
auto m=std::make_shared<Texture2D>(str);
m->usage="specular";
return m;
}
std::shared_ptr<HJGraphics::Texture2D> HJGraphics::operator ""_normal(const char* str,size_t n){
auto m=std::make_shared<Texture2D>(str);
m->usage="normal";
return m;
}
std::shared_ptr<HJGraphics::Texture2D> HJGraphics::operator ""_metallic(const char* str,size_t n){
auto m=std::make_shared<Texture2D>(str);
m->usage="metallic";
return m;
}
std::shared_ptr<HJGraphics::Texture2D> HJGraphics::operator ""_roughness(const char* str,size_t n){
auto m=std::make_shared<Texture2D>(str,true);
m->usage="roughness";
return m;
}
std::shared_ptr<HJGraphics::Texture2D> HJGraphics::operator ""_albedo(const char* str,size_t n){
auto m=std::make_shared<Texture2D>(str,true);
m->usage="albedo";
return m;
}
std::shared_ptr<HJGraphics::Texture2D> HJGraphics::operator ""_height(const char* str,size_t n){
auto m=std::make_shared<Texture2D>(str);
m->usage="height";
return m;
}
std::shared_ptr<HJGraphics::Texture2D> HJGraphics::operator ""_F0(const char* str,size_t n){
auto m=std::make_shared<Texture2D>(str);
m->usage="F0";
return m;
}
| 39.725926
| 185
| 0.703711
|
m-iDev-0792
|
532b91581776db7560e14dd99ad7f06c05c2b7c0
| 2,535
|
hxx
|
C++
|
tfm/tfdum/ServerSubscriptionEvent.hxx
|
dulton/reSipServer
|
ac4241df81c1e3eef2e678271ffef4dda1fc6747
|
[
"Apache-2.0"
] | 1
|
2019-04-15T14:10:58.000Z
|
2019-04-15T14:10:58.000Z
|
tfm/tfdum/ServerSubscriptionEvent.hxx
|
dulton/reSipServer
|
ac4241df81c1e3eef2e678271ffef4dda1fc6747
|
[
"Apache-2.0"
] | null | null | null |
tfm/tfdum/ServerSubscriptionEvent.hxx
|
dulton/reSipServer
|
ac4241df81c1e3eef2e678271ffef4dda1fc6747
|
[
"Apache-2.0"
] | 2
|
2019-10-31T09:11:09.000Z
|
2021-09-17T01:00:49.000Z
|
#if !defined ServerSubscriptionEvent_hxx
#define ServerSubscriptionEvent_hxx
#include "resip/stack/SipMessage.hxx"
#include "tfm/Event.hxx"
#include "tfm/tfdum/DumEvent.hxx"
class DumUserAgent;
typedef enum
{
ServerSubscription_Refresh,
ServerSubscription_Published,
ServerSubscription_Error,
ServerSubscription_ExpiredByClient,
ServerSubscription_Expired,
ServerSubscription_Terminated,
ServerSubscription_NewSubscription,
ServerSubscription_NewSubscriptionFromRefer,
ServerSubscription_ReadyToSend
} ServerSubscriptionEventType;
static const char* ServerSubscriptionEventTypeText[] =
{
"Refresh",
"Published",
"Error",
"Expired By Client",
"Expired",
"Terminated",
"New Subscription",
"New Subscription From Refer",
"Ready-To-Send"
};
class ServerSubscriptionEvent : public DumEvent
{
public:
typedef ServerSubscriptionEventType Type;
typedef resip::ServerSubscriptionHandle HandleType;
ServerSubscriptionEvent(DumUserAgent* dua, Type type, resip::ServerSubscriptionHandle h)
: DumEvent(dua),
mType(type),
mHandle(h)
{
}
ServerSubscriptionEvent(DumUserAgent* dua, Type type, resip::ServerSubscriptionHandle h, const resip::SipMessage& msg)
: DumEvent(dua, msg),
mType(type),
mHandle(h)
{
}
ServerSubscriptionEvent(DumUserAgent* dua, Type type, resip::ServerSubscriptionHandle h, resip::ServerPublicationHandle pub,
const resip::Contents* contents, const resip::SecurityAttributes* attrs)
:DumEvent(dua),
mType(type),
mHandle(h),
mServerPublication(pub)
{
}
virtual resip::Data toString() const
{
resip::Data buffer;
{
resip::DataStream strm(buffer);
strm << "ServerSubscriptionEvent - " << ServerSubscriptionEventTypeText[mType];
}
return buffer;
}
virtual resip::Data briefString() const
{
return toString();
}
static resip::Data getName() { return "ServerSubscriptionEvent"; }
static resip::Data getTypeName(Type type) { return ServerSubscriptionEventTypeText[type]; }
Type getType() const { return mType; }
resip::ServerSubscriptionHandle& getHandle() { return mHandle; }
protected:
Type mType;
resip::ServerSubscriptionHandle mHandle;
resip::ServerPublicationHandle mServerPublication;
};
#endif
| 26.684211
| 130
| 0.671006
|
dulton
|
53301a662c0912356694b6ed44f6610dd044c5ca
| 4,823
|
hpp
|
C++
|
include/nall/mosaic/parser.hpp
|
wareya/kotareci
|
14c87d1364d442456f93cebe73a288f85b79ba74
|
[
"Libpng"
] | 4
|
2015-08-02T06:48:46.000Z
|
2017-10-15T14:46:35.000Z
|
nall/mosaic/parser.hpp
|
apollolux/hello-phoenix
|
71510b5f329804c525a9576fb0367fe8ab2487cd
|
[
"MIT"
] | null | null | null |
nall/mosaic/parser.hpp
|
apollolux/hello-phoenix
|
71510b5f329804c525a9576fb0367fe8ab2487cd
|
[
"MIT"
] | null | null | null |
#ifdef NALL_MOSAIC_INTERNAL_HPP
namespace nall {
namespace mosaic {
struct parser {
image canvas;
//export from bitstream to canvas
void load(bitstream& stream, uint64_t offset, context& ctx, unsigned width, unsigned height) {
canvas.allocate(width, height);
canvas.clear(ctx.paddingColor);
parse(1, stream, offset, ctx, width, height);
}
//import from canvas to bitstream
bool save(bitstream& stream, uint64_t offset, context& ctx) {
if(stream.readonly) return false;
parse(0, stream, offset, ctx, canvas.width, canvas.height);
return true;
}
inline parser() : canvas(0, 32, 0u, 255u << 16, 255u << 8, 255u << 0) {
}
private:
uint32_t read(unsigned x, unsigned y) const {
unsigned addr = y * canvas.width + x;
if(addr >= canvas.width * canvas.height) return 0u;
uint32_t *buffer = (uint32_t*)canvas.data;
return buffer[addr];
}
void write(unsigned x, unsigned y, uint32_t data) {
unsigned addr = y * canvas.width + x;
if(addr >= canvas.width * canvas.height) return;
uint32_t *buffer = (uint32_t*)canvas.data;
buffer[addr] = data;
}
void parse(bool load, bitstream& stream, uint64_t offset, context& ctx, unsigned width, unsigned height) {
stream.endian = ctx.endian;
unsigned canvasWidth = width / (ctx.mosaicWidth * ctx.tileWidth * ctx.blockWidth + ctx.paddingWidth);
unsigned canvasHeight = height / (ctx.mosaicHeight * ctx.tileHeight * ctx.blockHeight + ctx.paddingHeight);
unsigned bitsPerBlock = ctx.depth * ctx.blockWidth * ctx.blockHeight;
unsigned objectOffset = 0;
for(unsigned objectY = 0; objectY < canvasHeight; objectY++) {
for(unsigned objectX = 0; objectX < canvasWidth; objectX++) {
if(objectOffset >= ctx.count && ctx.count > 0) break;
unsigned objectIX = objectX * ctx.objectWidth();
unsigned objectIY = objectY * ctx.objectHeight();
objectOffset++;
unsigned mosaicOffset = 0;
for(unsigned mosaicY = 0; mosaicY < ctx.mosaicHeight; mosaicY++) {
for(unsigned mosaicX = 0; mosaicX < ctx.mosaicWidth; mosaicX++) {
unsigned mosaicData = ctx.mosaic(mosaicOffset, mosaicOffset);
unsigned mosaicIX = (mosaicData % ctx.mosaicWidth) * (ctx.tileWidth * ctx.blockWidth);
unsigned mosaicIY = (mosaicData / ctx.mosaicWidth) * (ctx.tileHeight * ctx.blockHeight);
mosaicOffset++;
unsigned tileOffset = 0;
for(unsigned tileY = 0; tileY < ctx.tileHeight; tileY++) {
for(unsigned tileX = 0; tileX < ctx.tileWidth; tileX++) {
unsigned tileData = ctx.tile(tileOffset, tileOffset);
unsigned tileIX = (tileData % ctx.tileWidth) * ctx.blockWidth;
unsigned tileIY = (tileData / ctx.tileWidth) * ctx.blockHeight;
tileOffset++;
unsigned blockOffset = 0;
for(unsigned blockY = 0; blockY < ctx.blockHeight; blockY++) {
for(unsigned blockX = 0; blockX < ctx.blockWidth; blockX++) {
if(load) {
unsigned palette = 0;
for(unsigned n = 0; n < ctx.depth; n++) {
unsigned index = blockOffset++;
if(ctx.order == 1) index = (index % ctx.depth) * ctx.blockWidth * ctx.blockHeight + (index / ctx.depth);
palette |= stream.read(offset + ctx.block(index, index)) << n;
}
write(
objectIX + mosaicIX + tileIX + blockX,
objectIY + mosaicIY + tileIY + blockY,
ctx.palette(palette, palette)
);
} else /* save */ {
uint32_t palette = read(
objectIX + mosaicIX + tileIX + blockX,
objectIY + mosaicIY + tileIY + blockY
);
for(unsigned n = 0; n < ctx.depth; n++) {
unsigned index = blockOffset++;
if(ctx.order == 1) index = (index % ctx.depth) * ctx.blockWidth * ctx.blockHeight + (index / ctx.depth);
stream.write(offset + ctx.block(index, index), palette & 1);
palette >>= 1;
}
}
} //blockX
} //blockY
offset += ctx.blockStride;
} //tileX
offset += ctx.blockOffset;
} //tileY
offset += ctx.tileStride;
} //mosaicX
offset += ctx.tileOffset;
} //mosaicY
offset += ctx.mosaicStride;
} //objectX
offset += ctx.mosaicOffset;
} //objectY
}
};
}
}
#endif
| 37.976378
| 128
| 0.552146
|
wareya
|
5330b94b5be962779212ce9869de6963ddc889cc
| 525
|
cpp
|
C++
|
make/glue/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp
|
blm768/BulletD
|
dac62f9f8dadd8eaf7169c58ac3a2b2fbc77cb92
|
[
"BSL-1.0"
] | 3
|
2016-02-23T19:19:37.000Z
|
2020-01-20T13:05:15.000Z
|
make/glue/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp
|
MeinMein/BulletD
|
dac62f9f8dadd8eaf7169c58ac3a2b2fbc77cb92
|
[
"BSL-1.0"
] | 1
|
2016-05-25T20:39:38.000Z
|
2016-05-25T21:21:46.000Z
|
make/glue/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp
|
blm768/BulletD
|
dac62f9f8dadd8eaf7169c58ac3a2b2fbc77cb92
|
[
"BSL-1.0"
] | null | null | null |
#include <new>
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
extern "C" void _glue_10827548791891431243(btCollisionShape* _this) {
delete _this;
}
extern "C" void _glue_3352658093558691985(btCollisionShape* _this, float a0, btVector3& a1) {
return _this->calculateLocalInertia(a0, a1);
}
extern "C" float _glue_16319011272816997419(btCollisionShape* _this) {
return _this->getMargin();
}
extern "C" void _glue_3779256736581058006(btCollisionShape* _this, float a0) {
return _this->setMargin(a0);
}
| 27.631579
| 93
| 0.779048
|
blm768
|
533114fc8cb1758d7a57e6adb4ce8cda80bcaa99
| 9,691
|
cpp
|
C++
|
CesiumGltfReader/test/TestImageManipulation.cpp
|
SC-One/cesium-native
|
a8232ad039db1bb83ad2204c40c6dfb5d8207bb6
|
[
"Apache-2.0"
] | 2
|
2021-10-02T17:45:12.000Z
|
2021-10-02T17:45:15.000Z
|
CesiumGltfReader/test/TestImageManipulation.cpp
|
SC-One/cesium-native
|
a8232ad039db1bb83ad2204c40c6dfb5d8207bb6
|
[
"Apache-2.0"
] | null | null | null |
CesiumGltfReader/test/TestImageManipulation.cpp
|
SC-One/cesium-native
|
a8232ad039db1bb83ad2204c40c6dfb5d8207bb6
|
[
"Apache-2.0"
] | null | null | null |
#include "CesiumGltf/ImageCesium.h"
#include "CesiumGltf/ImageManipulation.h"
#include <catch2/catch.hpp>
#include <algorithm>
using namespace CesiumGltf;
TEST_CASE("ImageManipulation::unsafeBlitImage entire image") {
size_t width = 10;
size_t height = 10;
size_t imagePixels = width * height;
size_t bufferPixels = 2;
size_t bytesPerPixel = 2;
std::vector<std::byte> target(
(imagePixels + bufferPixels) * bytesPerPixel,
std::byte(1));
std::vector<std::byte> source(imagePixels * bytesPerPixel, std::byte(2));
ImageManipulation::unsafeBlitImage(
target.data() + bytesPerPixel,
width * bytesPerPixel,
source.data(),
width * bytesPerPixel,
width,
height,
bytesPerPixel);
// Verify we haven't overflowed the target
CHECK(target[0] == std::byte(1));
CHECK(target[1] == std::byte(1));
CHECK(target[target.size() - 1] == std::byte(1));
CHECK(target[target.size() - 2] == std::byte(1));
// Verify we did copy the expected bytes
for (size_t i = 2; i < target.size() - 2; ++i) {
CHECK(target[i] == std::byte(2));
}
}
TEST_CASE("ImageManipulation::unsafeBlitImage subset of target") {
size_t targetWidth = 10;
size_t targetHeight = 10;
size_t targetImagePixels = targetWidth * targetHeight;
size_t bufferPixels = 2;
size_t bytesPerPixel = 2;
size_t sourceWidth = 4;
size_t sourceHeight = 7;
size_t sourceImagePixels = sourceWidth * sourceHeight;
std::vector<std::byte> target(
(targetImagePixels + bufferPixels) * bytesPerPixel,
std::byte(1));
std::vector<std::byte> source(
sourceImagePixels * bytesPerPixel,
std::byte(2));
ImageManipulation::unsafeBlitImage(
target.data() + bytesPerPixel,
targetWidth * bytesPerPixel,
source.data(),
sourceWidth * bytesPerPixel,
sourceWidth,
sourceHeight,
bytesPerPixel);
// Verify we haven't overflowed the target
CHECK(target[0] == std::byte(1));
CHECK(target[1] == std::byte(1));
CHECK(target[target.size() - 1] == std::byte(1));
CHECK(target[target.size() - 2] == std::byte(1));
// Verify we did copy the expected bytes
for (size_t j = 0; j < targetHeight; ++j) {
for (size_t i = 0; i < targetWidth; ++i) {
std::byte expected =
i < sourceWidth && j < sourceHeight ? std::byte(2) : std::byte(1);
CHECK(target[(1 + j * targetWidth + i) * bytesPerPixel] == expected);
CHECK(target[(1 + j * targetWidth + i) * bytesPerPixel + 1] == expected);
}
}
}
TEST_CASE("ImageManipulation::unsafeBlitImage subset of source") {
size_t targetWidth = 10;
size_t targetHeight = 10;
size_t targetImagePixels = targetWidth * targetHeight;
size_t bufferPixels = 2;
size_t bytesPerPixel = 2;
size_t sourceTotalWidth = 12;
size_t sourceWidth = 4;
size_t sourceHeight = 7;
size_t sourceImagePixels = sourceTotalWidth * sourceHeight;
std::vector<std::byte> target(
(targetImagePixels + bufferPixels) * bytesPerPixel,
std::byte(1));
std::vector<std::byte> source(
sourceImagePixels * bytesPerPixel,
std::byte(2));
ImageManipulation::unsafeBlitImage(
target.data() + bytesPerPixel,
targetWidth * bytesPerPixel,
source.data(),
sourceTotalWidth * bytesPerPixel,
sourceWidth,
sourceHeight,
bytesPerPixel);
// Verify we haven't overflowed the target
CHECK(target[0] == std::byte(1));
CHECK(target[1] == std::byte(1));
CHECK(target[target.size() - 1] == std::byte(1));
CHECK(target[target.size() - 2] == std::byte(1));
// Verify we did copy the expected bytes
for (size_t j = 0; j < targetHeight; ++j) {
for (size_t i = 0; i < targetWidth; ++i) {
std::byte expected =
i < sourceWidth && j < sourceHeight ? std::byte(2) : std::byte(1);
CHECK(target[(1 + j * targetWidth + i) * bytesPerPixel] == expected);
CHECK(target[(1 + j * targetWidth + i) * bytesPerPixel + 1] == expected);
}
}
}
TEST_CASE("ImageManipulation::blitImage") {
ImageCesium target;
target.bytesPerChannel = 2;
target.channels = 4;
target.width = 15;
target.height = 9;
target.pixelData = std::vector<std::byte>(
size_t(
target.width * target.height * target.channels *
target.bytesPerChannel),
std::byte(1));
ImageCesium source;
source.bytesPerChannel = 2;
source.channels = 4;
source.width = 10;
source.height = 11;
source.pixelData = std::vector<std::byte>(
size_t(
source.width * source.height * source.channels *
source.bytesPerChannel),
std::byte(2));
PixelRectangle sourceRect;
sourceRect.x = 1;
sourceRect.y = 2;
sourceRect.width = 3;
sourceRect.height = 4;
PixelRectangle targetRect;
targetRect.x = 6;
targetRect.y = 5;
targetRect.width = 3;
targetRect.height = 4;
auto verifyTargetUnchanged = [&target]() {
CHECK(std::all_of(
target.pixelData.begin(),
target.pixelData.end(),
[](std::byte b) { return b == std::byte(1); }));
};
auto contains = [](const PixelRectangle& rectangle, size_t x, size_t y) {
if (x < size_t(rectangle.x)) {
return false;
}
if (y < size_t(rectangle.y)) {
return false;
}
if (x >= size_t(rectangle.x + rectangle.width)) {
return false;
}
if (y >= size_t(rectangle.y + rectangle.height)) {
return false;
}
return true;
};
auto verifySuccessfulCopy = [&target, &targetRect, &contains]() {
size_t bytesPerPixel = size_t(target.bytesPerChannel * target.channels);
for (size_t j = 0; j < size_t(target.height); ++j) {
for (size_t i = 0; i < size_t(target.width); ++i) {
size_t index = j * size_t(target.width) + i;
size_t offset = index * bytesPerPixel;
std::byte expected =
contains(targetRect, i, j) ? std::byte(2) : std::byte(1);
for (size_t k = 0; k < bytesPerPixel; ++k) {
CHECK(target.pixelData[offset + k] == expected);
}
}
}
};
SECTION("succeeds for non-scaled blit") {
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
true);
verifySuccessfulCopy();
}
SECTION("succeeds for a scaled-up blit") {
// Resizing is currently only supported for images that use one byte per
// channel.
target.bytesPerChannel = 1;
source.bytesPerChannel = 1;
targetRect.y = 4;
targetRect.width = 4;
targetRect.height = 5;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
true);
verifySuccessfulCopy();
}
SECTION("succeeds for a scaled-down blit") {
// Resizing is currently only supported for images that use one byte per
// channel.
target.bytesPerChannel = 1;
source.bytesPerChannel = 1;
targetRect.width = 2;
targetRect.height = 3;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
true);
verifySuccessfulCopy();
}
SECTION("returns false for mismatched bytesPerChannel") {
target.bytesPerChannel = 1;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false for mismatched channels") {
target.channels = 3;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false when target X is outside target image") {
targetRect.x = 14;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false when target Y is outside target image") {
targetRect.y = 6;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false when target X is negative") {
targetRect.x = -1;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false when target Y is negative") {
targetRect.y = -1;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false when source X is outside source image") {
sourceRect.x = 9;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false when source Y is outside source image") {
sourceRect.y = 9;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false when source X is negative") {
sourceRect.x = -1;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false when source Y is negative") {
sourceRect.y = -1;
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
SECTION("returns false for a too-small target") {
target.pixelData.resize(10);
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
}
SECTION("returns false for a too-small source") {
source.pixelData.resize(10);
CHECK(
ImageManipulation::blitImage(target, targetRect, source, sourceRect) ==
false);
verifyTargetUnchanged();
}
}
| 29.01497
| 79
| 0.638943
|
SC-One
|
533653cbc99f4611e91dfaea752a763092af799f
| 224
|
cpp
|
C++
|
hiro/reference/widget/vertical-scroller.cpp
|
mp-lee/higan
|
c38a771f2272c3ee10fcb99f031e982989c08c60
|
[
"Intel",
"ISC"
] | 38
|
2018-04-05T05:00:05.000Z
|
2022-02-06T00:02:02.000Z
|
hiro/reference/widget/vertical-scroller.cpp
|
ameer-bauer/higan-097
|
a4a28968173ead8251cfa7cd6b5bf963ee68308f
|
[
"Info-ZIP"
] | 2
|
2015-10-06T14:59:48.000Z
|
2022-01-27T08:57:57.000Z
|
hiro/reference/widget/vertical-scroller.cpp
|
ameer-bauer/higan-097
|
a4a28968173ead8251cfa7cd6b5bf963ee68308f
|
[
"Info-ZIP"
] | 8
|
2018-04-16T22:37:46.000Z
|
2021-02-10T07:37:03.000Z
|
namespace phoenix {
void pVerticalScroller::setLength(unsigned length) {
}
void pVerticalScroller::setPosition(unsigned position) {
}
void pVerticalScroller::constructor() {
}
void pVerticalScroller::destructor() {
}
}
| 14
| 56
| 0.763393
|
mp-lee
|
5337ccd9768e1f6fa072a5d765e6df411bfb6d93
| 1,364
|
cpp
|
C++
|
test_package/test_package.cpp
|
igor-sadchenko/conan-restclient-cpp
|
e82e92596dd92356c0c4acd99df0ffd9e21e9642
|
[
"MIT"
] | null | null | null |
test_package/test_package.cpp
|
igor-sadchenko/conan-restclient-cpp
|
e82e92596dd92356c0c4acd99df0ffd9e21e9642
|
[
"MIT"
] | null | null | null |
test_package/test_package.cpp
|
igor-sadchenko/conan-restclient-cpp
|
e82e92596dd92356c0c4acd99df0ffd9e21e9642
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <restclient-cpp/restclient.h>
#define EXPECT_TRUE(arg) \
do { \
if(!(arg)) { \
std::cerr << "Unexpected false at " \
<< __FILE__ << ", " << __LINE__ << ", " << __func__ << ": " << #arg << ": \033[31mFAILED\033[0m\n"; \
return -1; } \
else { \
std::cout << __FILE__ << ", " << __LINE__ << ", " << __func__ << ": \033[32mPASSED\033[0m\n"; } \
} while(false);
// This is a simple example
int main()
{
// DELETE
RestClient::Response del = RestClient::del("http://httpbin.org/delete");
EXPECT_TRUE(200 == del.code);
// Non exist site
std::string u = "http://nonexistent";
del = RestClient::del(u);
EXPECT_TRUE(-1 == del.code);
// GET
RestClient::Response get = RestClient::get("http://httpbin.org");
EXPECT_TRUE(200 == get.code);
// POST
RestClient::Response post = RestClient::post("http://httpbin.org/post", "text/json", "{\"foo\": \"bla\"}");
EXPECT_TRUE(200 == post.code);
// PUT
RestClient::Response put = RestClient::put("http://httpbin.org/put", "text/json", "{\"foo\": \"bla\"}");
EXPECT_TRUE(200 == put.code);
// HEAD
RestClient::Response head = RestClient::head("http://httpbin.org/");
EXPECT_TRUE(200 == head.code);
return 0;
}
| 31
| 125
| 0.535924
|
igor-sadchenko
|
533ae909406622ba2751b4c46ee7e66037e1b81a
| 2,964
|
cpp
|
C++
|
src/Circuit.cpp
|
4rzael/quantum-cuda
|
6c03d79f4ef68f6350e0659a1ef5a556d7915968
|
[
"MIT"
] | 6
|
2018-07-05T12:22:01.000Z
|
2019-08-05T05:28:42.000Z
|
src/Circuit.cpp
|
4rzael/quantum-cuda
|
6c03d79f4ef68f6350e0659a1ef5a556d7915968
|
[
"MIT"
] | null | null | null |
src/Circuit.cpp
|
4rzael/quantum-cuda
|
6c03d79f4ef68f6350e0659a1ef5a556d7915968
|
[
"MIT"
] | 1
|
2018-11-14T17:58:11.000Z
|
2018-11-14T17:58:11.000Z
|
/**
* @Author: Maxime Agor (4rzael)
* @Date: Mon Jul 16 2018
* @Email: maxime.agor23@gmail.com
* @Project: CUDA-Based Simulator of Quantum Systems
* @Filename: Circuit.cpp
* @Last modified by: 4rzael
* @Last modified time: Mon Jul 16 2018, 23:09:20
* @License: MIT License
*/
#include <algorithm>
#include "Circuit.hpp"
#include "Parser/CircuitBuilderUtils.hpp"
#include "utils.hpp"
bool Circuit::Qubit::operator==(const Qubit &other) const {
return registerName == other.registerName && element == other.element;
}
std::vector<Circuit::Qubit> Circuit::CXGate::getTargets() const {
return {control, target};
}
std::vector<Circuit::Qubit> Circuit::UGate::getTargets() const {
return {target};
}
std::vector<Circuit::Qubit> Circuit::Measurement::getTargets() const {
return {source, dest};
}
std::vector<Circuit::Qubit> Circuit::Reset::getTargets() const {
return {target};
}
std::vector<Circuit::Qubit> Circuit::ConditionalGate::getTargets() const {
auto res = getGateTargets(gate); // Implicit conversion to Circuit::Gate
/* We add every bit of the CREG to make sure it won't make reordering on it.
* Removing that part might/will cause problem for circuits such as the inverse QFT
* or the quantum teleportation (circuits shown in the "Open Quantum Assembly Language" publication)
*/
for (uint i = 0; i < m_maxTestedRegisterSize; ++i) {
res.push_back(Circuit::Qubit(testedRegister, i));
}
return res;
}
std::vector<Circuit::Qubit> Circuit::Barrier::getTargets() const {
return {target};
}
bool Circuit::Step::isQubitUsed(Qubit const &qubit) const {
// Can we find a gate...
return std::find_if(begin(), end(), [&qubit](const Circuit::Gate &g) {
const auto targets = getGateTargets(g);
// ... Having the qubit in its list of targets ?
return std::find(targets.begin(), targets.end(), qubit) != targets.end();
}) != end();
}
bool Circuit::Step::containsMeasurement() const {
// Can we find a gate...
return std::find_if(begin(), end(), [](const Circuit::Gate &g) {
// Of the type Circuit::Measurement ?
return g.type().hash_code() == typeid(Circuit::Measurement).hash_code();
}) != end();
}
Circuit::Circuit(Circuit const &other, uint beginStep, uint endStep) {
if (endStep == std::numeric_limits<uint>::max() && other.steps.size() > 0) endStep = other.steps.size() - 1;
creg = other.creg;
qreg = other.qreg;
if (other.steps.size() > 0) {
std::copy(other.steps.begin() + beginStep,
other.steps.begin() + endStep + 1,
std::back_inserter(steps));
}
}
void Circuit::removeMeasurements() {
for (auto &step: steps) {
step.erase(
std::remove_if(step.begin(), step.end(),
[](Circuit::Gate const &g){ return g.type().hash_code() == typeid(Circuit::Measurement).hash_code();}),
step.end());
}
}
| 32.571429
| 119
| 0.639339
|
4rzael
|
533cd8d5968a07ae265b02c48b19967d32366403
| 93
|
cpp
|
C++
|
src/core/logging/debug_error.cpp
|
imnetcat/cout
|
f188c1b345b9c95f4bfcd5b928845465f048ff6e
|
[
"MIT"
] | 2
|
2020-06-22T07:01:28.000Z
|
2020-09-08T18:16:23.000Z
|
src/core/logging/debug_error.cpp
|
imnetcat/email-client
|
f188c1b345b9c95f4bfcd5b928845465f048ff6e
|
[
"MIT"
] | 48
|
2020-05-29T06:16:26.000Z
|
2020-09-10T07:29:39.000Z
|
src/core/logging/debug_error.cpp
|
imnetcat/cout
|
f188c1b345b9c95f4bfcd5b928845465f048ff6e
|
[
"MIT"
] | 2
|
2020-05-03T08:00:41.000Z
|
2020-06-06T13:13:41.000Z
|
#include "debug_error.h"
Cout::Core::Logging::DebugError::DebugError() : Error("[DEBUG]") { }
| 46.5
| 68
| 0.688172
|
imnetcat
|
5343a765b7998ccab45c7ae5cc1d1241c2cd238d
| 185
|
hpp
|
C++
|
src/trew/actions/Actor.hpp
|
yavl/pm
|
03a49aa82794a42edef851456ff111156157112c
|
[
"MIT"
] | 1
|
2021-04-07T11:15:03.000Z
|
2021-04-07T11:15:03.000Z
|
src/trew/actions/Actor.hpp
|
yavl/trewlib
|
03a49aa82794a42edef851456ff111156157112c
|
[
"MIT"
] | null | null | null |
src/trew/actions/Actor.hpp
|
yavl/trewlib
|
03a49aa82794a42edef851456ff111156157112c
|
[
"MIT"
] | null | null | null |
#pragma once
namespace trew {
class Action;
class Actor {
public:
virtual ~Actor() = default;
virtual void act(float dt) = 0;
virtual void addAction(Action* action) = 0;
};
}
| 16.818182
| 45
| 0.67027
|
yavl
|
5343c60dd5223fd84900d7afc5bd2ba20316e4fb
| 2,361
|
cpp
|
C++
|
00355_design-twitter/201108-1.cpp
|
yanlinlin82/leetcode
|
ddcc0b9606d951cff9c08d1f7dfbc202067c8d65
|
[
"MIT"
] | 6
|
2019-10-23T01:07:29.000Z
|
2021-12-05T01:51:16.000Z
|
00355_design-twitter/201108-1.cpp
|
yanlinlin82/leetcode
|
ddcc0b9606d951cff9c08d1f7dfbc202067c8d65
|
[
"MIT"
] | null | null | null |
00355_design-twitter/201108-1.cpp
|
yanlinlin82/leetcode
|
ddcc0b9606d951cff9c08d1f7dfbc202067c8d65
|
[
"MIT"
] | 1
|
2021-12-03T06:54:57.000Z
|
2021-12-03T06:54:57.000Z
|
// https://leetcode-cn.com/problems/design-twitter/
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <unordered_set>
#include <unordered_map>
using namespace std;
class Twitter {
public:
/** Initialize your data structure here. */
Twitter() {
}
/** Compose a new tweet. */
void postTweet(int userId, int tweetId) {
tweets.push_front(make_pair(userId, tweetId));
}
/** Retrieve the 10 most recent tweet ids in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user herself. Tweets must be ordered from most recent to least recent. */
vector<int> getNewsFeed(int userId) {
vector<int> a;
for (auto it = tweets.begin(); it != tweets.end(); ++it) {
if (it->first != userId) {
auto it2 = followship.find(it->first);
if (it2 == followship.end()) continue;
auto it3 = it2->second.find(userId);
if (it3 == it2->second.end()) continue;
}
a.push_back(it->second);
if (a.size() >= 10) break;
}
return a;
}
/** Follower follows a followee. If the operation is invalid, it should be a no-op. */
void follow(int followerId, int followeeId) {
followship[followeeId].insert(followerId);
}
/** Follower unfollows a followee. If the operation is invalid, it should be a no-op. */
void unfollow(int followerId, int followeeId) {
auto it = followship.find(followeeId);
if (it != followship.end()) {
auto it2 = it->second.find(followerId);
if (it2 != it->second.end()) {
it->second.erase(it2);
}
}
}
private:
list<pair<int, int>> tweets; // [ user -> tweet ]
unordered_map<int, unordered_set<int>> followship;
};
void print(const vector<int>& a)
{
for (auto e : a) cout << e << " ";
cout << endl;
}
/**
* Your Twitter object will be instantiated and called as such:
* Twitter* obj = new Twitter();
* obj->postTweet(userId,tweetId);
* vector<int> param_2 = obj->getNewsFeed(userId);
* obj->follow(followerId,followeeId);
* obj->unfollow(followerId,followeeId);
*/
int main()
{
Twitter* obj = new Twitter();
obj->postTweet(1, 5);
print(obj->getNewsFeed(1)); // answer: [5]
obj->follow(1, 2);
obj->postTweet(2, 6);
print(obj->getNewsFeed(1)); // answer: [6, 5]
obj->unfollow(1, 2);
print(obj->getNewsFeed(1)); // answer: [5]
delete obj;
return 0;
}
| 27.776471
| 227
| 0.647607
|
yanlinlin82
|
5346ef52993bb699417d638c9859cd8aa0453dd7
| 4,161
|
hh
|
C++
|
src/sdk/valve/cmodelinfo.hh
|
numero69/sapphire-csgo-linux
|
51fa92b4295692af8026307a574a76cc7c3d3dfc
|
[
"MIT"
] | 35
|
2019-10-05T15:37:03.000Z
|
2021-12-14T23:59:19.000Z
|
src/sdk/valve/cmodelinfo.hh
|
numero69/sapphire-csgo-linux
|
51fa92b4295692af8026307a574a76cc7c3d3dfc
|
[
"MIT"
] | 1
|
2019-10-27T21:12:00.000Z
|
2019-10-27T21:12:00.000Z
|
src/sdk/valve/cmodelinfo.hh
|
numero69/sapphire-csgo-linux
|
51fa92b4295692af8026307a574a76cc7c3d3dfc
|
[
"MIT"
] | 17
|
2019-10-06T14:19:37.000Z
|
2021-05-08T21:36:25.000Z
|
//
// ruvi base
//
#pragma once
// includes
#include "sdk/memory/memory.hh"
#include "sdk/vector/matrix3x4.hh"
#include "sdk/vector/vector.hh"
#include <string_view>
struct model_t;
class i_material;
typedef float quaternion[4];
typedef float radian_euler[3];
struct mstudiobone_t {
int name_index;
inline const std::string_view name() const {
return (char *)(this) + name_index;
}
int parent;
int bone_controller[6];
vector3d position;
quaternion q_quaternion;
radian_euler rotation;
vector3d position_scale;
vector3d rotation_scale;
matrix3x4_t pose_to_bone;
quaternion alignment;
int flags;
int proc_type;
int proc_index;
mutable int physics_bone;
inline void *procedure() const {
if (proc_index == 0)
return nullptr;
else
return (void *)((unsigned char *)(this) + proc_index);
};
int surface_prop_index;
inline const std::string_view surface_prop_name() const {
return (char *)(this) + surface_prop_index;
}
inline int get_surface_prop(void) const { return surface_prop_lookup; }
int contents;
int surface_prop_lookup;
int pad0[0x7];
};
struct mstudiobbox_t {
int bone;
int group;
vector3d bbmin;
vector3d bbmax;
int hitbox_index;
int pad0[0x3];
float m_flRadius;
int pad1[0x4];
const char *get_name() {
if (!hitbox_index) return nullptr;
return (const char *)((unsigned char *)this + hitbox_index);
}
};
struct mstudiohitboxset_t {
int name_index;
inline char *const name() const { return ((char *)this) + name_index; }
int number_of_hitboxes;
int hitbox_index;
inline mstudiobbox_t *hitbox(std::size_t index) const {
return reinterpret_cast<mstudiobbox_t *>(((unsigned char *)this) +
hitbox_index) +
index;
};
};
struct studiohdr_t {
int id;
int version;
int checksum;
char name[64];
int length;
vector3d eye_position;
vector3d illumination_position;
vector3d hull_min;
vector3d hull_max;
vector3d view_bbmin;
vector3d view_bbmax;
int flags;
int number_of_bones;
int bone_index;
inline mstudiobone_t *bone(std::size_t index) const {
assert(index >= 0 && index < number_of_bones);
return reinterpret_cast<mstudiobone_t *>(((unsigned char *)this) +
bone_index) +
index;
};
int remap_bone_sequence(int sequence, int local_bone) const;
int remap_bone_animation(int animation, int local_bone) const;
int number_of_bone_controllers;
int bone_controller_index;
int number_of_hitbox_sets;
int hitbox_set_index;
mstudiohitboxset_t *hitbox_set(std::size_t index) const {
(index >= 0 && index < number_of_hitbox_sets);
return reinterpret_cast<mstudiohitboxset_t *>(((unsigned char *)this) +
hitbox_set_index) +
index;
};
inline mstudiobbox_t *hitbox(std::size_t index, int set) const {
const mstudiohitboxset_t *studio_hitbox_set = hitbox_set(set);
if (!studio_hitbox_set) return nullptr;
return studio_hitbox_set->hitbox(index);
};
inline int hitbox_count(int set) const {
const mstudiohitboxset_t *studio_hitbox_set = hitbox_set(set);
if (!studio_hitbox_set) return 0;
return studio_hitbox_set->number_of_hitboxes;
};
};
class c_model_info {
public:
void *get_model(int index) { return memory::vfunc<2, void *>(this, index); }
int get_model_index(const std::string_view file_name) {
return memory::vfunc<3, int>(this, file_name.data());
}
const std::string_view get_model_name(const void *model_name) {
return memory::vfunc<4, const std::string_view>(this, model_name);
}
void get_model_materials(const model_t *model, int count,
i_material **pp_material) {
return memory::vfunc<18, void>(this, model, count, pp_material);
}
studiohdr_t *get_studio_model(const model_t *model) {
return memory::vfunc<31, studiohdr_t *>(this, model);
}
};
| 23.508475
| 78
| 0.656333
|
numero69
|
53495f590979cc66e517e3171fb33d2e012114a7
| 1,171
|
cpp
|
C++
|
src/xray/render/core/sources/res_input_layout.cpp
|
ixray-team/ixray-2.0
|
85c3a544175842323fc82f42efd96c66f0fc5abb
|
[
"Linux-OpenIB"
] | 3
|
2021-10-30T09:36:14.000Z
|
2022-03-26T17:00:06.000Z
|
src/xray/render/core/sources/res_input_layout.cpp
|
acidicMercury8/ixray-2.0
|
85c3a544175842323fc82f42efd96c66f0fc5abb
|
[
"Linux-OpenIB"
] | null | null | null |
src/xray/render/core/sources/res_input_layout.cpp
|
acidicMercury8/ixray-2.0
|
85c3a544175842323fc82f42efd96c66f0fc5abb
|
[
"Linux-OpenIB"
] | 1
|
2022-03-26T17:00:08.000Z
|
2022-03-26T17:00:08.000Z
|
////////////////////////////////////////////////////////////////////////////
// Created : 15.04.2010
// Author : Armen Abroyan
// Copyright (C) GSC Game World - 2010
////////////////////////////////////////////////////////////////////////////
#include "pch.h"
#include <xray/render/core/device.h>
#include <xray/render/core/res_input_layout.h>
#include <xray/render/core/resource_manager.h>
namespace xray {
namespace render_dx10 {
res_input_layout::res_input_layout( res_declaration const * decl, res_signature const * signature):
m_declaration ( decl),
m_signature ( signature)
{
m_hw_input_layout = NULL;
ID3DBlob * hw_singiture = signature->hw_signiture();
device::ref().d3d_device()->CreateInputLayout( &m_declaration->dcl_code[0], m_declaration->dcl_code.size(), hw_singiture ->GetBufferPointer(), hw_singiture->GetBufferSize(), &m_hw_input_layout);
ASSERT( m_hw_input_layout);
}
res_input_layout::~res_input_layout ()
{
safe_release( m_hw_input_layout);
}
void res_input_layout::_free() const
{
resource_manager::ref().release( const_cast<res_input_layout*>(this) );
}
} // namespace render
} // namespace xray
| 30.815789
| 196
| 0.631939
|
ixray-team
|
534a82d8c6a982769797022e90b004fb6640d9c3
| 2,900
|
cpp
|
C++
|
test/api/src/api.cpp
|
bielskij/uCoroutine
|
321138dd11008254e648194c2b90e9865950a465
|
[
"MIT"
] | null | null | null |
test/api/src/api.cpp
|
bielskij/uCoroutine
|
321138dd11008254e648194c2b90e9865950a465
|
[
"MIT"
] | null | null | null |
test/api/src/api.cpp
|
bielskij/uCoroutine
|
321138dd11008254e648194c2b90e9865950a465
|
[
"MIT"
] | null | null | null |
////////////////////////////////////////////////////////////////////////////////
// MIT License
//
// Copyright (c) 2021 Jaroslaw Bielski (bielski.j@gmail.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.
////////////////////////////////////////////////////////////////////////////////
/*
* test.cpp
*
* Created on: 26.10.2021
* Author: Jaroslaw Bielski (bielski.j@gmail.com)
*/
#include <gtest/gtest.h>
#include "uCoroutine.h"
struct Context {
int val;
bool condition;
uCoroutineQueue queue;
uint8_t queueMemory[8];
Context() {
this->val = 0;
this->condition = true;
uCoroutine_queue_init(&this->queue, this->queueMemory, 1, sizeof(this->queueMemory));
}
};
UCOROUTINE_FUNC_BEGIN(basic_routine_master, Context) {
while (1) {
uCoroutine_sleep(1);
uCoroutine_sleepMs(100);
uCoroutine_sleepTicks(UC_MS_TO_TICKS(100));
uCoroutine_yield();
{
uCoroutineError sendRet;
uint8_t val;
val = 0xa5;
uCoroutine_queue_send(&context->queue, &val, UC_MS_TO_TICKS(100), &sendRet);
if (sendRet == UC_NO_ERROR) {
}
}
}
}
UCOROUTINE_FUNC_END;
UCOROUTINE_FUNC_BEGIN(basic_routine_slave, Context) {
while (1) {
uCoroutine_sleepMs(100);
{
uCoroutineError recvRet;
uCoroutine_queue_receive(&context->queue, &context->val, UCOROUTINE_INFINITY, &recvRet);
if (recvRet == UC_NO_ERROR) {
}
}
uCoroutine_interrupt();
}
}
UCOROUTINE_FUNC_END;
TEST(api, basic) {
Context ctx;
uCoroutine master;
uCoroutine *slave = uCoroutine_new(UCOROUTINE_PRIORITY_MIN, "slave", basic_routine_slave, &ctx);
uCoroutine_prepare(&master, "master", UCOROUTINE_PRIORITY_MIN, basic_routine_master, &ctx);
uCoroutine_start(&master);
uCoroutine_start(slave);
{
uCoroutine_schedule();
}
uCoroutine_stop(slave);
uCoroutine_stop(&master);
uCoroutine_free(slave);
ASSERT_EQ(ctx.val, 0xa5);
}
| 25.663717
| 97
| 0.687586
|
bielskij
|
c733b2b9fbcc48cfa3a80dc3c8f13fba4bcda580
| 930
|
cpp
|
C++
|
code/utils/communication/ClientCommandSender.cpp
|
ashmrtn/crashmonkey
|
ab21ec11f1b181f354c6ca8dc3f72804302173f8
|
[
"Apache-2.0"
] | 160
|
2017-07-08T17:16:49.000Z
|
2022-02-23T03:07:05.000Z
|
code/utils/communication/ClientCommandSender.cpp
|
ashmrtn/crashmonkey
|
ab21ec11f1b181f354c6ca8dc3f72804302173f8
|
[
"Apache-2.0"
] | 95
|
2017-07-11T04:58:12.000Z
|
2021-09-10T16:21:38.000Z
|
code/utils/communication/ClientCommandSender.cpp
|
ashmrtn/crashmonkey
|
ab21ec11f1b181f354c6ca8dc3f72804302173f8
|
[
"Apache-2.0"
] | 30
|
2017-07-23T17:13:51.000Z
|
2021-11-30T10:06:12.000Z
|
#include <string>
#include "ClientCommandSender.h"
#include "ClientSocket.h"
#include "SocketUtils.h"
namespace fs_testing {
namespace utils {
namespace communication {
using std::string;
ClientCommandSender::ClientCommandSender(
string socket_addr,
SocketMessage::CmCommand send,
SocketMessage::CmCommand recv) : socket_address(socket_addr),
send_command(send),
return_command(recv),
conn(ClientSocket(socket_address)) {}
int ClientCommandSender::Run() {
if (conn.Init() < 0) {
return -1;
}
if (conn.SendCommand(send_command) != SocketError::kNone) {
return -2;
}
SocketMessage ret;
if (conn.WaitForMessage(&ret) != SocketError::kNone) {
return -3;
}
return !(ret.type == return_command);
}
} // namesapce communication
} // namesapce utils
} // namesapce fs_testing
| 23.25
| 74
| 0.626882
|
ashmrtn
|
c735541f920a18f2cfc6d9ddf02ee79a0100238b
| 2,983
|
cpp
|
C++
|
src/obstacle_avoidance.cpp
|
anubhavparas/ros-walker-bot
|
7c352d17fd3fb3cf2713eb325b9fad28d56b2a69
|
[
"MIT"
] | null | null | null |
src/obstacle_avoidance.cpp
|
anubhavparas/ros-walker-bot
|
7c352d17fd3fb3cf2713eb325b9fad28d56b2a69
|
[
"MIT"
] | null | null | null |
src/obstacle_avoidance.cpp
|
anubhavparas/ros-walker-bot
|
7c352d17fd3fb3cf2713eb325b9fad28d56b2a69
|
[
"MIT"
] | 1
|
2021-11-29T19:18:27.000Z
|
2021-11-29T19:18:27.000Z
|
/**
* MIT License
*
* Copyright (c) 2021 Anubhav Paras
*
* 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.
*
* @file obstacle_avoidance.cpp
* @author Anubhav Paras (anubhavp@umd.edu)
* @brief Definitions of the ObstacleAvoidance class
* @version 0.1
* @date 2021-11-25
*
* @copyright Copyright (c) 2021
*
*/
#include <ros/ros.h>
#include <ros-walker-bot/obstacle_avoidance.hpp>
ObstacleAvoidance::ObstacleAvoidance() {
}
ObstacleAvoidance::~ObstacleAvoidance() {
}
bool ObstacleAvoidance::is_path_clear(
const std::vector<float>& laserscan_data_range,
int angle_range) {
bool path_clear = true;
int left_ind = 0 + angle_range;
int right_ind = 360 - angle_range;
if (angle_range <= 0 || left_ind >= 360 || right_ind < 0) {
ROS_ERROR_STREAM("Range cannot be more than 360 or less than 0");
return false;
}
// check for left side and right side range
for (int i=0; i <= angle_range; i++) {
if (laserscan_data_range[i] <= this->threshold_dist
|| laserscan_data_range[359 - i] <= this->threshold_dist) {
return false;
}
}
return path_clear;
}
geometry_msgs::Twist ObstacleAvoidance::get_bot_velocity(
const std::vector<float>& laserscan_data_range,
int angle_range) {
if (this->is_path_clear(laserscan_data_range, angle_range)) {
this->bot_velocity.linear.x = 0.5;
this->bot_velocity.angular.z = 0.0;
} else {
ROS_WARN_STREAM("Obstacle ahead. Turning...");
// stop moving forward
this->bot_velocity.linear.x = 0.0;
// turn left MAX_ONE_SIDE_TURN_COUNT times: ang.z_vel = 1.0
// and then right MAX_ONE_SIDE_TURN_COUNT times: ang.z_vel = -1.0
// and repeat
this->bot_velocity.angular.z =
(this->turn_count < MAX_ONE_SIDE_TURN_COUNT) ? 1.0 : -1.0;
this->turn_count = (this->turn_count + 1) % (MAX_ONE_SIDE_TURN_COUNT * 2);
}
return bot_velocity;
}
| 34.287356
| 81
| 0.693932
|
anubhavparas
|
c73c57d3e9d4bcb9af63078d592e1e66de9e609c
| 947
|
hpp
|
C++
|
PPreflector/base_class.hpp
|
Petkr/PPreflection
|
9e2e3fd3dcae0b1acf75e6c0913a22d257a9c805
|
[
"MIT"
] | null | null | null |
PPreflector/base_class.hpp
|
Petkr/PPreflection
|
9e2e3fd3dcae0b1acf75e6c0913a22d257a9c805
|
[
"MIT"
] | null | null | null |
PPreflector/base_class.hpp
|
Petkr/PPreflection
|
9e2e3fd3dcae0b1acf75e6c0913a22d257a9c805
|
[
"MIT"
] | null | null | null |
#pragma once
// clang-format off
#include "pragma_push.hpp"
#include "clang/AST/Type.h"
#include "pragma_pop.hpp"
// clang-format on
#include "node_descriptor.hpp"
namespace PPreflector
{
///
/// @brief Represents a base class declaration.
///
///
class base_class : public node_descriptor<clang::Type, descriptor>
{
public:
///
/// @brief Construct a new base class descriptor.
///
/// @param t A reference to the type of the base class.
///
base_class(const clang::Type& t);
void print_name_header(llvm::raw_ostream& out) const override final;
void print_name_own(llvm::raw_ostream& out) const override final;
void print_name_foreign(llvm::raw_ostream& out) const override final;
void print_metadata_members(
llvm::raw_ostream& out) const override final;
void print_metadata_traits(llvm::raw_ostream& out) const override final;
void print_metadata_object(llvm::raw_ostream& out) const override final;
};
}
| 26.305556
| 74
| 0.732841
|
Petkr
|
c73dc6f83c692337febca4887fdfb35f3ff8f383
| 683
|
hpp
|
C++
|
libs/plugin/impl/include/sge/plugin/impl/manager_impl.hpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | 2
|
2016-01-27T13:18:14.000Z
|
2018-05-11T01:11:32.000Z
|
libs/plugin/impl/include/sge/plugin/impl/manager_impl.hpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | null | null | null |
libs/plugin/impl/include/sge/plugin/impl/manager_impl.hpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | 3
|
2018-05-11T01:11:34.000Z
|
2021-04-24T19:47:45.000Z
|
// Copyright Carl Philipp Reh 2006 - 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef SGE_PLUGIN_IMPL_MANAGER_IMPL_HPP_INCLUDED
#define SGE_PLUGIN_IMPL_MANAGER_IMPL_HPP_INCLUDED
#include <sge/plugin/collection.hpp>
#include <sge/plugin/manager.hpp>
#include <sge/plugin/detail/traits.hpp>
#include <fcppt/enum/array_impl.hpp>
template <typename Type>
sge::plugin::collection<Type> sge::plugin::manager::collection()
{
return sge::plugin::collection<Type>(
categories_[sge::plugin::detail::traits<Type>::plugin_type()]);
}
#endif
| 31.045455
| 69
| 0.743777
|
cpreh
|
c74a8cd0151cf48ac1f2af62b149c1eea0d9acc9
| 13,182
|
cpp
|
C++
|
TGMarbles/AI/MoveRanker.cpp
|
toadgee/marbles
|
044f0f4eebe37ba72e0c99f2841f42a55fe20d70
|
[
"MIT"
] | null | null | null |
TGMarbles/AI/MoveRanker.cpp
|
toadgee/marbles
|
044f0f4eebe37ba72e0c99f2841f42a55fe20d70
|
[
"MIT"
] | null | null | null |
TGMarbles/AI/MoveRanker.cpp
|
toadgee/marbles
|
044f0f4eebe37ba72e0c99f2841f42a55fe20d70
|
[
"MIT"
] | null | null | null |
#include "precomp.h"
#include "Card.h"
#include "DebugAssert.h"
#include "Move.h"
#include "Game.h"
#include "ComputerPlayer.h"
#include "MoveGenerator.h"
#include "MoveRanker.h"
#include "Board.h"
// by creating a move ranker struct, we don't have to recalculate some of the same data over and over
#define TGMMoveRankerData struct TGMMoveRankerDataStruct
struct TGMMoveRankerDataStruct
{
TGMMove *move;
Strategy strategy;
TGMGame* game;
TGMBoard *board;
PlayerColor playerColor;
bool oldSpotIsFinalSpot;
bool newSpotIsFinalSpot;
bool oldSpotIsPointSpot;
bool newSpotIsPointSpot;
int oldSpotNormalized;
int newSpotNormalized;
};
void DoWeightOfMoveBasedOnLikelihoodOfBeingKilled(TGMMoveRankerData *data, TGMMoveList** allPossibleOpponentMoves);
void DoWeightOfMoveBasedOnMovement(TGMMoveRankerData *data);
void DoWeightOfMoveBasedOnStartingSpot(TGMMoveRankerData *data);
void DoWeightOfMoveIntoHomeBase(TGMMoveRankerData *data);
void DoWeightOfMoveIntoPlayerStartingSpot(TGMMoveRankerData *data);
void DoWeightOfMoveOutOfPlayerStartingSpot(TGMMoveRankerData *data);
void DoWeightOfMoveKill(TGMMoveRankerData *data);
void DoWeightOfGetOutMove(TGMMoveRankerData *data);
void DoWeightOfMoveFromPoint(TGMMoveRankerData *data);
void DoWeightOfMoveToPoint(TGMMoveRankerData *data);
void DoWeightOfDiscardMove(TGMMoveRankerData *data);
void DoWeightOfJokerMove(TGMMoveRankerData *data);
void DoWeightOfMoveFromHomeBackFour(TGMMoveRankerData *data);
void DoWeightOfMoveBasedOnLikelihoodOfBeingKilled(TGMMoveRankerData *data, TGMMoveList** allPossibleOpponentMoves)
{
const int kSafeMoveWeight = 50;
const int kUnsafeMoveWeight = 5; // per possible kill, subtraction!
if (!IsDefensiveStrategy(data->strategy))
{
return;
}
if (allPossibleOpponentMoves == nullptr)
{
// huh, we weren't asked to calculate this...
return;
}
int killedCount = 0;
// final spot moves can't be killer moves
if (!IsFinalSpot(data->move->newSpot))
{
// for every move by the opponents that could kill us, we decrease the weight by some amount
// this is fairly expensive since we need to generate all moves for all other marbles on the board...
bool opponentsAreTeam1 = !IsPlayerColorTeam1(data->playerColor);
// only calculate opponent moves once across all moves (performance optimization)
if (*allPossibleOpponentMoves == nullptr)
{
*allPossibleOpponentMoves = AllPossibleMovesForAllTeamPlayers(data->game, opponentsAreTeam1);
}
TGMMoveList *allPossibleMoves = *allPossibleOpponentMoves;
{
TGMMove* possibleKillMove = allPossibleMoves->first;
while (possibleKillMove != nullptr)
{
// if there's a move that can kill us, we subtract some amount
// if there's a move that can't, we add some amount
// ignore final spot moves
if (!IsFinalSpot(possibleKillMove->newSpot))
{
bool isKillerMove = (possibleKillMove->newSpot == data->move->newSpot);
if (isKillerMove)
{
killedCount++;
}
}
possibleKillMove = possibleKillMove->nextMove;
}
}
}
if (killedCount == 0)
{
// completely safe move
data->move->weight += kSafeMoveWeight;
return;
}
else
{
data->move->weight -= (kUnsafeMoveWeight * killedCount);
}
}
void DoWeightOfMoveBasedOnMovement(TGMMoveRankerData *data)
{
// this allows us to not have to worry about forwards/backwards progress as much
int normalizedSpot1;
int normalizedSpot2;
bool forwardProgress = (data->move->moves >= 0);
if (forwardProgress)
{
normalizedSpot1 = data->newSpotNormalized;
normalizedSpot2 = data->oldSpotNormalized;
}
else
{
normalizedSpot1 = data->oldSpotNormalized;
normalizedSpot2 = data->newSpotNormalized;
}
if (data->move->oldSpot != kGetOutSpot)
{
data->move->weight += WrapSpot(normalizedSpot1 - normalizedSpot2);
}
if (!data->oldSpotIsFinalSpot && !data->newSpotIsFinalSpot && data->oldSpotIsPointSpot)
{
data->move->weight += (kPlayerSpots - ((normalizedSpot1 - normalizedSpot2) % kPlayerSpots));
}
}
void DoWeightOfMoveBasedOnStartingSpot(TGMMoveRankerData *data)
{
// take into account distance from home - the further the distance, the more we've invested into that marble, the more
// we should move it first
if (!data->oldSpotIsFinalSpot && !data->newSpotIsFinalSpot)
{
data->move->weight += (data->oldSpotNormalized / 10);
}
}
void DoWeightOfMoveIntoHomeBase(TGMMoveRankerData *data)
{
// determine if home move
// TODO : Improvement : good fits could be those which we have the cards to fit them in
// determine if a move into home base
if (data->newSpotIsFinalSpot)
{
// calculate how many marble spots are between this move's spot and the maximum spot
// (accounting for other marbles)
int newSpotFinalSpot = SpotToFinalSpot(data->move->newSpot);
int firstMarbleSpot = BoardFirstMarbleInFinalSpots(data->board, newSpotFinalSpot, data->move->playerColor);
int distanceFromNextMarbleInHome = firstMarbleSpot - newSpotFinalSpot - 1;
// if this slots in right next to the next marble in our home, then we just need to double check
// that there aren't any other marble holes in front of the new spot
bool isFull = false;
if (distanceFromNextMarbleInHome == 0)
{
isFull = true;
for (int finalSpotCounter = newSpotFinalSpot + 1; finalSpotCounter < kMarblesPerPlayer; finalSpotCounter++)
{
MarbleColor mc = BoardMarbleColorInFinalSpot(data->board, finalSpotCounter, data->move->playerColor);
if (mc == MarbleColor::None)
{
isFull = false;
break;
}
}
}
if (distanceFromNextMarbleInHome == 0 && isFull)
{
// it's a good fit if all the rest of our home is filled
data->move->weight += 500;
}
else if (distanceFromNextMarbleInHome == 0 || distanceFromNextMarbleInHome == 1 || distanceFromNextMarbleInHome == 4)
{
// it's a really bad fit if we need an ace or 4 - or there are other holes past where we would land
if (IsPassiveStrategy(data->strategy))
{
data->move->weight += 50;
}
else if (IsAggressiveStrategy(data->strategy))
{
data->move->weight += 15;
}
else dassert(0);
}
else
{
// bad fit
if (IsPassiveStrategy(data->strategy))
{
data->move->weight += 200;
}
else if (IsAggressiveStrategy(data->strategy))
{
data->move->weight += 80;
}
else dassert(0);
}
}
}
void DoWeightOfMoveIntoPlayerStartingSpot(TGMMoveRankerData *data)
{
// determine if it's a move into a starting spot
if (!data->newSpotIsFinalSpot && (IsPlayerStartingSpot(data->move->newSpot)))
{
if (IsPassiveStrategy(data->strategy))
{
data->move->weight += -50;
}
else if (IsAggressiveStrategy(data->strategy))
{
data->move->weight += 0; // no-op
}
else dassert(0);
}
}
void DoWeightOfMoveOutOfPlayerStartingSpot(TGMMoveRankerData *data)
{
// determine if it's a play out of a starting spot
if (!data->oldSpotIsFinalSpot && (IsPlayerStartingSpot(data->move->oldSpot)) && data->move->marble != nullptr)
{
// we do a weird trick that says we know if it's in our home position by looking to see if the distance
// is the same as the starting position's distance.
bool isMarblesHomeSpot = (data->move->marble->distanceFromHome == kPlayerStartingPosition);
if (!isMarblesHomeSpot)
{
// best not to hang around somebody else's starting spot for too long...
data->move->weight += 20;
}
}
}
void DoWeightOfMoveKill(TGMMoveRankerData *data)
{
// determine if kill move
if (!data->oldSpotIsFinalSpot && !data->newSpotIsFinalSpot)
{
MarbleColor existingColor = BoardMarbleColorAtSpot(data->board, data->move->newSpot);
if (existingColor != MarbleColor::None)
{
PlayerColor marblePlayerColor = PlayerColorForMarbleColor(existingColor);
PlayerColor playerColor = data->playerColor;
if (marblePlayerColor == playerColor || ArePlayersTeammates(marblePlayerColor, playerColor))
{
// kill teammate (or self)
data->move->weight += -500;
}
else
{
// kill enemy
if (IsPassiveStrategy(data->strategy))
{
data->move->weight += -75;
}
else if (IsAggressiveStrategy(data->strategy))
{
data->move->weight += 125;
}
else dassert(0);
}
}
}
}
void DoWeightOfGetOutMove(TGMMoveRankerData *data)
{
// determine if get out move (do this after kill moves)
if (data->move->oldSpot == kGetOutSpot)
{
// we want to take into account how many other marbles for this player in play
int8_t otherMarblesInPlay = BoardCountMarblesInPlayForPlayer(data->board, data->move->playerColor);
if (IsPassiveStrategy(data->strategy))
{
data->move->weight += (0 + (otherMarblesInPlay * -5));
}
else if (IsAggressiveStrategy(data->strategy))
{
data->move->weight += (20 + (otherMarblesInPlay * -5));
}
else
{
dassert(0);
}
// basic order goes : use kings first, then aces, then jokers
if (CardNumber(data->move->card) == CardNumber::King)
{
data->move->weight += 1;
}
else if (CardNumber(data->move->card) == CardNumber::Joker)
{
data->move->weight -=1;
}
else
{
dassert(CardNumber(data->move->card) == CardNumber::Ace);
}
}
}
void DoWeightOfMoveFromPoint(TGMMoveRankerData *data)
{
// determine if it's a jump move (do this before other point moves)
if (!data->newSpotIsFinalSpot && data->oldSpotIsPointSpot && data->move->jumps > 0)
{
data->move->weight += 5;
}
}
void DoWeightOfMoveToPoint(TGMMoveRankerData *data)
{
if (data->move->marble != nullptr)
{
PlayerColor playerColorForMarble = PlayerColorForMarbleColor(data->move->marble->color);
// determine if it's a point move (move to the point, do this before jump moves -- although not sure it matters)
// also the point before home doesn't really count as more
if (!data->newSpotIsFinalSpot && data->newSpotIsPointSpot && !IsLastPlayerPointSpot(data->move->newSpot, playerColorForMarble))
{
if (data->oldSpotIsPointSpot)
{
// from point spot to point spot. not bad
data->move->weight += 10;
}
else
{
// from point spot to non point spot. better(?)
data->move->weight += 50;
}
}
}
}
void DoWeightOfDiscardMove(TGMMoveRankerData *data)
{
// TODO : this is pretty dumb today - but the general rule is if we're discarding,
if (data->move->isDiscard)
{
// we are only saved if another player on our team has a get out. if they do, the best cards
// to have are 5s (and maybe 4s), so discard those last
int baseWeight = -1500;
if (CardNumber(data->move->card) == CardNumber::Card5)
{
baseWeight -= 100;
}
else if (CardNumber(data->move->card) == CardNumber::Card4)
{
baseWeight -= 50;
}
data->move->weight += baseWeight;
}
}
void DoWeightOfJokerMove(TGMMoveRankerData *data)
{
// joker moves should be considered less valuable since other cards that aren't jokers are better - so that
// two moves with a joker & non-joker, the non-joker comes out ahead
if (CardNumber(data->move->card) == CardNumber::Joker)
{
data->move->weight += -1;
}
}
void DoWeightOfMoveFromHomeBackFour(TGMMoveRankerData *data)
{
if (CardNumber(data->move->card) == CardNumber::Card4
&& data->oldSpotNormalized == 4
&& data->newSpotNormalized == 0)
{
if (IsPassiveStrategy(data->strategy))
{
data->move->weight += 50;
}
else if (IsAggressiveStrategy(data->strategy))
{
data->move->weight += 20;
}
else
{
dassert(0);
}
}
}
int CalculateWeightOfMoveInGame(TGMMove* move, TGMGame* game, PlayerColor pc, Strategy strategy, TGMMoveList** allPossibleOpponentMoves)
{
// calculate weight of the move for comparison reasons
// a higher weight is a better move
// TODO : Do better in calculating move weight based on cards in game
// for example, calculating moves in the final spot if we have an ace
// 4 away from the final spot is bad unless we have a 3 and ace (in which case it's just not great)
// 1 away from the final spot is difficult and is generally bad unless we have an ace or joker
// only calculate this once per move.
if (!move->weightCalculated)
{
move->weightCalculated = true;
move->weight = 0;
TGMMoveRankerData data;
data.move = move;
data.strategy = strategy;
data.game = game;
data.board = GameGetBoard(game);
data.playerColor = pc;
data.oldSpotIsFinalSpot = IsFinalSpot(move->oldSpot);
data.newSpotIsFinalSpot = IsFinalSpot(move->newSpot);
data.oldSpotIsPointSpot = IsPointSpot(move->oldSpot);
data.newSpotIsPointSpot = IsPointSpot(move->newSpot);
data.oldSpotNormalized = NormalizeSpot(move->playerColor, move->oldSpot);
data.newSpotNormalized = NormalizeSpot(move->playerColor, move->newSpot);
DoWeightOfMoveBasedOnLikelihoodOfBeingKilled(&data, allPossibleOpponentMoves);
DoWeightOfMoveBasedOnMovement(&data);
DoWeightOfMoveBasedOnStartingSpot(&data);
DoWeightOfMoveIntoPlayerStartingSpot(&data);
DoWeightOfMoveOutOfPlayerStartingSpot(&data);
DoWeightOfMoveKill(&data);
DoWeightOfMoveIntoHomeBase(&data);
DoWeightOfGetOutMove(&data);
DoWeightOfMoveFromPoint(&data);
DoWeightOfMoveToPoint(&data);
DoWeightOfJokerMove(&data);
DoWeightOfDiscardMove(&data);
DoWeightOfMoveFromHomeBackFour(&data);
}
return move->weight;
}
| 29.424107
| 136
| 0.716811
|
toadgee
|
c751c896dc2d1eab1f3bd1ed171809e224fa206e
| 17,760
|
cpp
|
C++
|
jtagclient/main.cpp
|
azonenberg/jtaghal-apps
|
53f9abc66a354df2d74cb253a81f1ee2d1780bb0
|
[
"BSD-3-Clause"
] | 4
|
2018-07-04T11:35:32.000Z
|
2021-05-18T18:06:18.000Z
|
jtagclient/main.cpp
|
azonenberg/jtaghal-apps
|
53f9abc66a354df2d74cb253a81f1ee2d1780bb0
|
[
"BSD-3-Clause"
] | 1
|
2018-03-21T11:17:00.000Z
|
2018-03-21T11:17:00.000Z
|
jtagclient/main.cpp
|
azonenberg/jtaghal-apps
|
53f9abc66a354df2d74cb253a81f1ee2d1780bb0
|
[
"BSD-3-Clause"
] | 1
|
2018-03-21T10:40:29.000Z
|
2018-03-21T10:40:29.000Z
|
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "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 AUTHORS BE HELD 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. *
* *
***********************************************************************************************************************/
/**
@file
@author Andrew D. Zonenberg
@brief Main source file for jtagclient
\ingroup jtagclient
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <memory.h>
#include <string>
#include <list>
#include "../../lib/jtaghal/jtaghal.h"
//#include <svnversion.h>
#include <signal.h>
using namespace std;
void ShowUsage();
void ShowVersion();
void PrintDeviceInfo(TestableDevice* pdev);
#ifndef _WIN32
void sig_handler(int sig);
#endif
/**
\defgroup jtagclient JTAGclient: command-line client to jtagd
jtagclient provides a command-line interface for performing basic scan chain operations.
JTAGclient is released under the same permissive 3-clause BSD license as the remainder of the project.
*/
/**
\page jtagclient_usage Usage
\ingroup jtagclient
General arguments:
\li --port NNN<br/>
Specifies the TCP port that jtagclient should connect to (default 50123).
\li --server HOST<br/>
Specifies the hostname of the server that jtagclient should connect to (default localhost)
\li --nobanner<br/>
Run the requested operation without printing the program version/license banner.
Exactly one of the following operations must be specified:
\li --help<br/>
Displays help and exits.
\li --version<br/>
Prints program version number and exits.
\li --erase N<br/>
Erases the device at position N in the scan chain (zero based)
\li --info N<br/>
Displays information about the device at position N in the scan chain (zero based)
\li --program N fname
Programs the device at position N in the scan chain with the firmware/bitstream image in the supplied file.
\li --verbose
Prints more debug info.
*/
/**
@brief Program entry point
\ingroup jtagclient
*/
int main(int argc, char* argv[])
{
#ifndef _WINDOWS
signal(SIGPIPE, sig_handler);
#endif
try
{
Severity console_verbosity = Severity::NOTICE;
//Global settings
unsigned short port = 0;
string server = "";
//Mode switches
enum modes
{
MODE_NONE,
MODE_HELP,
MODE_VERSION,
MODE_PROGRAM,
MODE_DEVINFO,
MODE_ERASE,
MODE_REBOOT,
MODE_DUMP,
MODE_LOCK,
MODE_UNLOCK
} mode = MODE_NONE;
//Device index
int devnum = 0;
//Programming mode
string bitfile;
bool noreboot = false;
int indirect_width = 0;
unsigned int base = 0;
bool raw = false;
bool profile_init_time = false;
string indirect_image = "";
bool nobanner = false;
//Parse command-line arguments
for(int i=1; i<argc; i++)
{
string s(argv[i]);
//Let the logger eat its args first
if(ParseLoggerArguments(i, argc, argv, console_verbosity))
continue;
if(s == "--help")
mode = MODE_HELP;
else if(s == "--port")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --port\n");
return 1;
}
port = atoi(argv[++i]);
}
else if(s == "--server")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --server\n");
return 1;
}
server = argv[++i];
}
else if(s == "--program")
{
//Expect device index and bitfile
mode = MODE_PROGRAM;
if(i+2 >= argc)
{
fprintf(stderr, "Not enough arguments for --program\n");
return 1;
}
devnum = atoi(argv[++i]);
bitfile = argv[++i];
}
else if(s == "--lock")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --lock\n");
return 1;
}
//Expect device index
mode = MODE_LOCK;
devnum = atoi(argv[++i]);
}
else if(s == "--unlock")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --lock\n");
return 1;
}
//Expect device index
mode = MODE_UNLOCK;
devnum = atoi(argv[++i]);
}
else if(s == "--dump")
{
if(i+2 >= argc)
{
fprintf(stderr, "Not enough arguments for --dump\n");
return 1;
}
//Expect device index and bitfile
mode = MODE_DUMP;
devnum = atoi(argv[++i]);
bitfile = argv[++i];
}
else if(s == "--indirect")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --indirect\n");
return 1;
}
indirect_width = atoi(argv[++i]);
}
else if(s == "--indirect_image")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --indirect-image\n");
return 1;
}
indirect_image = argv[++i];
}
else if(s == "--profile-init")
profile_init_time = true;
else if(s == "--nobanner")
nobanner = true;
else if(s == "--info")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --info\n");
return 1;
}
//Expect device index
mode = MODE_DEVINFO;
devnum = atoi(argv[++i]);
}
else if(s == "--erase")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --erase\n");
return 1;
}
//Expect device index
mode = MODE_ERASE;
devnum = atoi(argv[++i]);
}
else if(s == "--reboot")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --reboot\n");
return 1;
}
//Expect device index
mode = MODE_REBOOT;
devnum = atoi(argv[++i]);
}
else if(s == "--noreboot")
noreboot = true;
else if(s == "--raw")
raw = true;
else if(s == "--base")
{
if(i+1 >= argc)
{
fprintf(stderr, "Not enough arguments for --base\n");
return 1;
}
sscanf(argv[++i], "%8x", &base);
}
else if(s == "--version")
mode = MODE_VERSION;
else
{
fprintf(stderr, "Unrecognized command-line argument \"%s\", use --help\n", s.c_str());
return 1;
}
}
//Set up logging
g_log_sinks.emplace(g_log_sinks.begin(), new ColoredSTDLogSink(console_verbosity));
//Print header
if(!nobanner)
{
ShowVersion();
printf("\n");
}
//Process help/version requests
if(mode == MODE_VERSION)
return 0;
else if(mode == MODE_HELP)
{
ShowUsage();
return 0;
}
//Abort cleanly if no server specified
if( (port == 0) || (server.empty()) )
{
ShowUsage();
return 0;
}
//Connect to the server
NetworkedJtagInterface iface;
iface.Connect(server, port);
if(!nobanner)
{
LogNotice("Connected to JTAG daemon at %s:%d\n", server.c_str(), port);
LogVerbose(" Remote JTAG adapter is a %s (serial number \"%s\", userid \"%s\", frequency %.2f MHz)\n",
iface.GetName().c_str(), iface.GetSerial().c_str(), iface.GetUserID().c_str(), iface.GetFrequency()/1E6);
}
//Initialize the chain
LogVerbose("Initializing chain...\n");
double start = GetTime();
iface.InitializeChain();
if(profile_init_time)
{
double dt = GetTime() - start;
LogDebug(" Chain walking took %.3f ms\n", dt*1000);
}
//Get device count and see what we've found
LogNotice("Scan chain contains %d devices\n", (int)iface.GetDeviceCount());
//Walk the chain and see what we find
//No need for mutexing here since the device will lock the high-level interface when necessary
if(mode != MODE_DEVINFO)
{
for(size_t i=0; i<iface.GetDeviceCount(); i++)
PrintDeviceInfo(iface.GetDevice(i));
}
//Do stuff
switch(mode)
{
case MODE_NONE:
//nothing to do
break;
case MODE_PROGRAM:
{
if(bitfile == "")
{
throw JtagExceptionWrapper(
"No filename specified, cannot continue",
"");
}
//Get the device
auto device = iface.GetDevice(devnum);
if(device == NULL)
{
throw JtagExceptionWrapper(
"Device is null, cannot continue",
"");
}
//Make sure it's a programmable device
ProgrammableDevice* pdev = dynamic_cast<ProgrammableDevice*>(device);
if(pdev == NULL)
{
throw JtagExceptionWrapper(
"Device is not a programmable device, cannot continue",
"");
}
//Load the firmware image and program the device
LogNotice("Loading firmware image...\n");
FirmwareImage* img = NULL;
if(raw)
img = new RawBinaryFirmwareImage(bitfile, "flash");
else
img = pdev->LoadFirmwareImage(bitfile);
if(indirect_width == 0)
{
LogNotice("Programming device...\n");
pdev->Program(img);
}
else
{
LogError("Indirect programming not supported\n");
/*
LogNotice("Programming device (using indirect programming, bus width %d)...\n", indirect_width);
ByteArrayFirmwareImage* bi = dynamic_cast<ByteArrayFirmwareImage*>(img);
if(bi)
pdev->ProgramIndirect(bi, indirect_width, !noreboot, base, indirect_image);
else
{
throw JtagExceptionWrapper(
"Cannot indirectly program non-byte-array firmware images",
"");
}
*/
}
LogNotice("Configuration successful\n");
delete img;
}
break;
case MODE_DUMP:
{
/*
//Get the device
JtagDevice* device = iface.GetDevice(devnum);
if(device == NULL)
{
throw JtagExceptionWrapper(
"Device is null, cannot continue",
"");
}
//Make sure it's a Xilinx FPGA (TODO: move this to base class)
XilinxFPGA* pdev = dynamic_cast<XilinxFPGA*>(device);
if(pdev == NULL)
{
throw JtagExceptionWrapper(
"Device is not a Xilinx FPGA, cannot continue",
"");
}
LogNotice("Dumping flash...\n");
pdev->DumpIndirect(indirect_width, bitfile);
*/
throw JtagExceptionWrapper(
"Dump not supported",
"");
}
break;
case MODE_DEVINFO:
PrintDeviceInfo(iface.GetDevice(devnum));
break;
case MODE_ERASE:
{
//Get the device
auto device = iface.GetDevice(devnum);
if(device == NULL)
{
throw JtagExceptionWrapper(
"Device is null, cannot continue",
"");
}
//Make sure it's a programmable device
ProgrammableDevice* pdev = dynamic_cast<ProgrammableDevice*>(device);
if(pdev == NULL)
{
throw JtagExceptionWrapper(
"Device is not a programmable device, cannot continue",
"");
}
//Erase it
LogNotice("Erasing...\n");
pdev->Erase();
}
break;
case MODE_REBOOT:
{
//Get the device
auto device = iface.GetDevice(devnum);
if(device == NULL)
{
throw JtagExceptionWrapper(
"Device is null, cannot continue",
"");
}
//Make sure it's a Xilinx FPGA (TODO: move this to base class)
XilinxFPGA* pdev = dynamic_cast<XilinxFPGA*>(device);
if(pdev == NULL)
{
throw JtagExceptionWrapper(
"Device is not rebootable, cannot continue",
"");
}
//Erase it
LogNotice("Rebooting...\n");
pdev->Reboot();
}
break;
case MODE_LOCK:
{
//Get the device
auto device = iface.GetDevice(devnum);
if(device == NULL)
{
throw JtagExceptionWrapper(
"Device is null, cannot continue",
"");
}
//Make sure it's a lockable device
LockableDevice* pdev = dynamic_cast<LockableDevice*>(device);
if(pdev == NULL)
{
throw JtagExceptionWrapper(
"Device is not lockable, cannot continue",
"");
}
//Lock it
LogNotice("Locking...\n");
pdev->SetReadLock();
};
break;
case MODE_UNLOCK:
{
//Get the device
auto device = iface.GetDevice(devnum);
if(device == NULL)
{
throw JtagExceptionWrapper(
"Device is null, cannot continue",
"");
}
//Make sure it's a lockable device
LockableDevice* pdev = dynamic_cast<LockableDevice*>(device);
if(pdev == NULL)
{
throw JtagExceptionWrapper(
"Device is not lockable, cannot continue",
"");
}
//Lock it
LogNotice("Unlocking (will probably trigger bulk flash erase)...\n");
pdev->ClearReadLock();
};
break;
default:
break;
}
}
catch(const JtagException& ex)
{
LogError("%s\n", ex.GetDescription().c_str());
return 1;
}
//Done
return 0;
}
/**
@brief Prints info about a single device in the chain
@param i Device index
@param pdev The device
\ingroup jtagclient
*/
void PrintDeviceInfo(TestableDevice* pdev)
{
if(pdev == NULL)
{
throw JtagExceptionWrapper(
"Device is null, cannot continue",
"");
}
pdev->PrintInfo();
}
/**
@brief Prints program usage
\ingroup jtagclient
*/
void ShowUsage()
{
LogNotice(
"Usage: jtagclient [general args] [mode]\n"
"\n"
"General arguments:\n"
" --help Displays this message and exits.\n"
" --nobanner Do not print version number on startup.\n"
" --port PORT Specifies the port number to connect to (defaults to 50123)\n"
" --server [hostname] Specifies the hostname of the server to connect to (defaults to localhost).\n"
" --version Prints program version number and exits.\n"
"\n"
"Mode flags\n"
" --erase [device index] Erases the device at the specified index (zero based).\n"
" --info [device index] Displays information about the device at the specified index (zero based).\n"
" --program [device index] [bitfile] [--indirect N] Programs the device at the specified index (zero based) with the supplied bitfile.\n"
" If --indirect is specified, use indirect flash programming with bus width N\n"
" Indirect programming will reboot the device unless --noreboot is specified.\n"
" To load the bitfile at an address other than zero specify --base [hex address]\n"
);
}
#ifndef _WIN32
/**
@brief SIGPIPE handler
\ingroup jtagclient
*/
void sig_handler(int sig)
{
switch(sig)
{
case SIGPIPE:
//ignore
break;
}
}
#endif
/**
@brief Prints program version number
\ingroup jtagclient
*/
void ShowVersion()
{
LogNotice(
"JTAG client [git rev %s] by Andrew D. Zonenberg.\n"
"\n"
"License: 3-clause (\"new\" or \"modified\") BSD.\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n"
"\n"
, "TODO");
}
| 26.389302
| 143
| 0.546059
|
azonenberg
|
c755986347597bb6e447e0f02da8bcb5b0de6403
| 134
|
hpp
|
C++
|
scripts/scripts/mulHLS/para.hpp
|
dicecco1/fpga_caffe
|
7a191704efd7873071cfef35772d7e7bf3e3cfd6
|
[
"Intel",
"BSD-2-Clause"
] | 134
|
2016-10-05T22:10:19.000Z
|
2022-03-26T07:13:55.000Z
|
scripts/scripts/mulHLS/para.hpp
|
honorpeter/fpga_caffe
|
7a191704efd7873071cfef35772d7e7bf3e3cfd6
|
[
"Intel",
"BSD-2-Clause"
] | 14
|
2016-11-20T21:16:38.000Z
|
2020-04-14T04:58:32.000Z
|
scripts/scripts/mulHLS/para.hpp
|
honorpeter/fpga_caffe
|
7a191704efd7873071cfef35772d7e7bf3e3cfd6
|
[
"Intel",
"BSD-2-Clause"
] | 58
|
2016-10-03T01:23:47.000Z
|
2021-11-24T12:17:30.000Z
|
#define HALF 1
#define NO_PARTITION 1
#define EXP_SIZE 7
#define MANT_SIZE 20
#define ROUND_NEAREST_MULT 1
#define ROUND_NEAREST_ADD 1
| 22.333333
| 28
| 0.828358
|
dicecco1
|
c7559f50ae41b6d365db68672eb06edd86b92af8
| 18,964
|
hpp
|
C++
|
Hittable.hpp
|
JohnHynes/Thesis
|
e4b5ed0cc4f5e1465d449db343eb429d2872bbe4
|
[
"MIT"
] | 4
|
2021-02-19T23:48:35.000Z
|
2022-01-10T01:42:07.000Z
|
Hittable.hpp
|
JohnHynes/Thesis
|
e4b5ed0cc4f5e1465d449db343eb429d2872bbe4
|
[
"MIT"
] | 1
|
2021-03-24T16:52:16.000Z
|
2021-03-24T16:52:16.000Z
|
Hittable.hpp
|
JohnHynes/Thesis
|
e4b5ed0cc4f5e1465d449db343eb429d2872bbe4
|
[
"MIT"
] | 1
|
2021-04-19T14:16:09.000Z
|
2021-04-19T14:16:09.000Z
|
#ifndef GPU_RAY_TRACER_HITTABLE_HPP_
#define GPU_RAY_TRACER_HITTABLE_HPP_
#include <algorithm>
#include <glm/geometric.hpp>
#include <iostream>
#include <iterator>
#include <limits>
#include "Preprocessor.hpp"
#include "Random.hpp"
#include "Ray.hpp"
#include "constants.hpp"
#include "types.hpp"
struct hittable;
struct hit_record {
point3 point;
vec3 normal;
int mat_idx;
num t;
bool front_face;
__host__ __device__ inline void set_face_normal(const ray &r,
const vec3 &outward_normal) {
front_face = glm::dot(r.dir, outward_normal) < CONST(0.0);
if (front_face) {
normal = outward_normal;
} else {
normal = -outward_normal;
}
}
};
enum class hittable_id {
Sphere,
Plane,
Rectangle,
Triangle,
BoundingBox,
BoundingArrayNode,
Unknown
};
struct bounding_box;
struct IHittable {
__host__ __device__ virtual bool hit(const ray &r, num tmin, num tmax,
hit_record &hitrec) const = 0;
__host__ virtual inline bounding_box get_bounding_box() const = 0;
};
struct bounding_box : public IHittable {
public:
point3 minimum, maximum;
private:
__host__ bounding_box() : minimum(), maximum() {}
friend class bounding_tree_node_node;
public:
__host__ __device__ bounding_box(point3 min, point3 max)
: minimum(min), maximum(max) {}
__host__ __device__ inline bool hit(const ray &r, num t_min, num t_max,
hit_record &hit_rec) const override {
for (int i = 0; i < 3; i++) {
auto invD = CONST(1) / r.dir[i];
auto t0 = (minimum[i] - r.orig[i]) * invD;
auto t1 = (maximum[i] - r.orig[i]) * invD;
if (invD < CONST(0)) {
auto temp = t0;
t0 = t1;
t1 = temp;
}
t_min = t0 > t_min ? t0 : t_min;
t_max = t1 < t_max ? t1 : t_max;
if (t_max <= t_min) {
return false;
}
}
return true;
}
__host__ inline bounding_box get_bounding_box() const override {
return *this;
}
};
__host__ inline bool axis_compare(const bounding_box a, const bounding_box b,
int axis) {
return a.minimum[axis] < b.minimum[axis];
}
__host__ inline bool x_compare(const bounding_box a, const bounding_box b) {
return axis_compare(a, b, 0);
}
__host__ inline bool y_compare(const bounding_box a, const bounding_box b) {
return axis_compare(a, b, 1);
}
__host__ inline bool z_compare(const bounding_box a, const bounding_box b) {
return axis_compare(a, b, 2);
}
struct bounding_tree_node {
virtual __host__ bounding_box get_bounding_box() const = 0;
virtual ~bounding_tree_node() {};
};
struct bounding_tree_node_object : public bounding_tree_node {
hittable *obj;
virtual __host__ bounding_box get_bounding_box() const override;
virtual ~bounding_tree_node_object() override {}
};
struct bounding_tree_node_node : public bounding_tree_node {
public:
bounding_tree_node *left, *right;
bounding_box box;
public:
__host__ bounding_box surrounding_box(bounding_box b1, bounding_box b2) {
point3 min, max;
for (int i = 0; i < 3; ++i) {
min[i] = std::min(b1.minimum[i], b2.minimum[i]);
max[i] = std::max(b1.maximum[i], b2.maximum[i]);
}
return bounding_box(min, max);
}
virtual ~bounding_tree_node_node() override {
if (left != nullptr)
{
delete left;
}
if (right != nullptr && right != left)
{
delete right;
}
}
__host__ bounding_tree_node_node(hittable **hittables, int hittables_size,
RandomState *state, int start, int end);
virtual __host__ inline bounding_box get_bounding_box() const override {
return box;
}
};
struct bounding_array_node : public IHittable {
public:
int left, right;
bounding_box box;
public:
__host__ __device__ bounding_array_node(int l, int r, bounding_box b)
: left(l), right(r), box(b) {}
__host__ __device__ inline bool hit(const ray &r, num t_min, num t_max,
hit_record &hit_rec) const override {
return box.hit(r, t_min, t_max, hit_rec);
}
__host__ inline bounding_box get_bounding_box() const override { return box; }
};
struct sphere : public IHittable {
public:
vec3 center;
num radius;
int mat_idx;
public:
__host__ __device__ inline sphere(const vec3 &c, num r, int m)
: center(c), radius(r), mat_idx(m) {}
// Member Functions
__host__ __device__ inline bool hit(const ray &r, num tmin, num tmax,
hit_record &hitrec) const override {
vec3 oc = r.origin() - center;
num a = glm::dot(r.dir, r.dir);
num half_b = glm::dot(oc, r.dir);
num c = glm::dot(oc, oc) - radius * radius;
num discriminant = half_b * half_b - a * c;
if (discriminant <= 0) {
return false;
}
num root = sqrtf(discriminant);
num t = (-half_b - root) / a;
if (tmin < t && t < tmax) {
hitrec.t = t;
hitrec.point = r.at(hitrec.t);
glm::vec3 outward_normal = (hitrec.point - center) / radius;
hitrec.set_face_normal(r, outward_normal);
hitrec.mat_idx = mat_idx;
return true;
}
t = (-half_b + root) / a;
if (tmin < t && t < tmax) {
hitrec.t = t;
hitrec.point = r.at(hitrec.t);
glm::vec3 outward_normal = (hitrec.point - center) / radius;
hitrec.set_face_normal(r, outward_normal);
hitrec.mat_idx = mat_idx;
return true;
}
return false;
}
__host__ inline bounding_box get_bounding_box() const override {
return bounding_box(center - vec3(radius, radius, radius),
center + vec3(radius, radius, radius));
}
};
struct plane : public IHittable {
public:
point3 p;
vec3 surface_normal;
int mat_idx;
public:
__host__ __device__ plane(point3 p, vec3 sn, int m)
: p(p), surface_normal(-glm::normalize(sn)), mat_idx(m) {}
__host__ __device__ inline bool hit(const ray &r, num t_min, num t_max,
hit_record &rec) const override {
num numerator = glm::dot(p - r.orig, surface_normal);
num t = numerator / glm::dot(r.dir, surface_normal);
if (t < t_min || t_max < t) {
return false;
}
rec.t = t;
rec.point = r.at(t);
rec.mat_idx = mat_idx;
rec.set_face_normal(r, surface_normal);
return true;
}
__host__ inline bounding_box get_bounding_box() const override {
point3 min, max;
bool zerox = surface_normal.x == 0;
bool zeroy = surface_normal.y == 0;
bool zeroz = surface_normal.z == 0;
// Check for bounding box infinitely-sized in 3D
bool atLeastTwoZeros = zerox ? (zeroy || zeroz) : (zeroy && zeroz);
// If there are at least two zeros, the bounding box is not infinite in 3D
if (atLeastTwoZeros) {
if (!zerox) // y-z plane
{
min = point3(p.x, -infinity, -infinity);
max = point3(p.x, infinity, infinity);
} else if (!zeroy) // x-z plane
{
min = point3(-infinity, p.y, -infinity);
max = point3(infinity, p.y, infinity);
} else if (!zeroz) // x-y plane
{
min = point3(-infinity, -infinity, p.z);
max = point3(infinity, infinity, p.z);
} else // Bounding box size of 0x0x0
{
min = p;
max = p;
}
}
// Else, the bounding box is infinite in 3D
else {
min = point3(-infinity, -infinity, -infinity);
max = point3(infinity, infinity, infinity);
}
// If not infinitely-sized in 3D, bounding box if infinitely-sized in 2D
return bounding_box(min, max);
}
};
struct rectangle : public IHittable {
public:
int mat_idx;
point3 p1, p2, p3;
vec3 surface_normal;
public:
__host__ __device__ rectangle(point3 _p1, point3 _p2, point3 _p3, int m)
: mat_idx(m), p1(_p1), p2(_p2), p3(_p3),
surface_normal(glm::normalize(glm::cross(p1 - p2, p3 - p2))) {}
__host__ __device__ inline bool hit(const ray &r, num t_min, num t_max,
hit_record &rec) const override {
// TODO : Implement hit function.
return false;
}
__host__ inline bounding_box get_bounding_box() const override {
return bounding_box(point3(0.0f, 0.0f, 0.0f), point3(0.0f, 0.0f, 0.0f));
}
};
struct triangle : public IHittable {
public:
int mat_idx;
point3 p1, p2, p3;
vec3 surface_normal;
public:
__host__ __device__ triangle(point3 _p1, point3 _p2, point3 _p3, int m)
: mat_idx(m), p1(_p1), p2(_p2), p3(_p3),
surface_normal(glm::normalize(glm::cross(p1 - p2, p3 - p2))) {}
__host__ __device__ virtual bool hit(const ray &r, num t_min, num t_max,
hit_record &rec) const override {
// TODO : Implement hit function.
// Use the Moller-Trumbore ray-triangle algorithm to compute t
num epsilon = CONST(0.0000001);
vec3 edge1 = p2 - p1;
vec3 edge2 = p3 - p1;
vec3 h = glm::cross(r.dir, edge2);
num a = glm::dot(h, edge1);
if (-epsilon < a && a < epsilon) // Ray is approximately parallel
{
return false;
}
num f = CONST(1.0) / a;
vec3 s = r.orig - p1;
num u = f * glm::dot(h, s);
if (u < 0 || 1 < u) {
return false;
}
vec3 q = glm::cross(s, edge1);
num v = f * glm::dot(r.dir, q);
if (v < CONST(0) || CONST(1) < u + v) {
return false;
}
num t = f * glm::dot(edge2, q);
if (t < t_min || t_max < t) {
return false;
}
// 2. Assign proper values to hitrec
rec.t = t;
rec.point = r.at(t);
rec.mat_idx = mat_idx;
rec.set_face_normal(r, surface_normal);
return true;
}
__host__ inline bounding_box get_bounding_box() const override {
point3 min, max;
for (int i = 0; i < 3; ++i) {
min[i] = std::min({p1[i], p2[i], p3[i]});
max[i] = std::max({p1[i], p2[i], p3[i]});
}
return bounding_box(min, max);
}
};
struct null_hittable : public IHittable {
__host__ __device__ null_hittable() {}
__host__ __device__ inline bool hit(const ray &r, num t_min, num t_max,
hit_record &rec) const override {
return false;
}
__host__ inline bounding_box get_bounding_box() const override {
// Returning point-sized bounding box.
return bounding_box(point3(0.0f, 0.0f, 0.0f), point3(0.0f, 0.0f, 0.0f));
}
};
union hittable_data {
sphere s;
plane p;
rectangle r;
triangle t;
bounding_box bb;
bounding_array_node ban;
null_hittable n;
__host__ __device__ inline hittable_data(sphere const &s) : s(s) {}
__host__ __device__ inline hittable_data(plane const &p) : p(p) {}
__host__ __device__ inline hittable_data(rectangle const &r) : r(r) {}
__host__ __device__ inline hittable_data(triangle const &t) : t(t) {}
__host__ __device__ inline hittable_data(bounding_box const &bb) : bb(bb) {}
__host__ __device__ inline hittable_data(bounding_array_node const &ban)
: ban(ban) {}
__host__ __device__ inline hittable_data(sphere &&s) : s(std::move(s)) {}
__host__ __device__ inline hittable_data(plane &&p) : p(std::move(p)) {}
__host__ __device__ inline hittable_data(rectangle &&r) : r(std::move(r)) {}
__host__ __device__ inline hittable_data(triangle &&t) : t(std::move(t)) {}
__host__ __device__ inline hittable_data(bounding_box &&bb)
: bb(std::move(bb)) {}
__host__ __device__ inline hittable_data(bounding_array_node &&ban)
: ban(std::move(ban)) {}
__host__ __device__ inline hittable_data() : n() {}
template <typename... Args>
__host__ __device__ inline bool hit(hittable_id id, Args &&...args) const {
switch (id) {
case hittable_id::Sphere:
return s.hit(std::forward<Args>(args)...);
case hittable_id::Plane:
return p.hit(std::forward<Args>(args)...);
case hittable_id::Rectangle:
return r.hit(std::forward<Args>(args)...);
case hittable_id::Triangle:
return t.hit(std::forward<Args>(args)...);
case hittable_id::BoundingBox:
return bb.hit(std::forward<Args>(args)...);
case hittable_id::BoundingArrayNode:
return ban.hit(std::forward<Args>(args)...);
default:
return n.hit(std::forward<Args>(args)...);
}
}
__host__ __device__ inline bounding_box
get_bounding_box(hittable_id id) const {
switch (id) {
case hittable_id::Sphere:
return s.get_bounding_box();
case hittable_id::Plane:
return p.get_bounding_box();
case hittable_id::Rectangle:
return r.get_bounding_box();
case hittable_id::Triangle:
return t.get_bounding_box();
case hittable_id::BoundingBox:
return bb.get_bounding_box();
case hittable_id::BoundingArrayNode:
return ban.get_bounding_box();
default:
return n.get_bounding_box();
}
}
__host__ __device__ bounding_array_node const &
as_bounding_array_node() const {
return ban;
}
};
struct hittable {
__host__ __device__ inline hittable(sphere const &s)
: id(hittable_id::Sphere), data(s) {}
__host__ __device__ inline hittable(plane const &p)
: id(hittable_id::Plane), data(p) {}
__host__ __device__ inline hittable(rectangle const &r)
: id(hittable_id::Rectangle), data(r) {}
__host__ __device__ inline hittable(triangle const &t)
: id(hittable_id::Triangle), data(t) {}
__host__ __device__ inline hittable(bounding_box const &bb)
: id(hittable_id::BoundingBox), data(bb) {}
__host__ __device__ inline hittable(bounding_array_node const &ban)
: id(hittable_id::BoundingArrayNode), data(ban) {}
__host__ __device__ inline hittable(sphere &&s)
: id(hittable_id::Sphere), data(std::move(s)) {}
__host__ __device__ inline hittable(plane &&p)
: id(hittable_id::Plane), data(std::move(p)) {}
__host__ __device__ inline hittable(rectangle &&r)
: id(hittable_id::Rectangle), data(std::move(r)) {}
__host__ __device__ inline hittable(triangle &&t)
: id(hittable_id::Triangle), data(std::move(t)) {}
__host__ __device__ inline hittable(bounding_box &&bb)
: id(hittable_id::BoundingBox), data(std::move(bb)) {}
__host__ __device__ inline hittable(bounding_array_node &&ban)
: id(hittable_id::BoundingArrayNode), data(std::move(ban)) {}
__host__ __device__ inline hittable() : id(hittable_id::Unknown), data() {}
__host__ __device__ inline hittable(hittable const &h) : id(h.id), data() {
switch (h.id) {
case hittable_id::Sphere:
data.s = h.data.s;
break;
case hittable_id::Plane:
data.p = h.data.p;
break;
case hittable_id::Rectangle:
data.r = h.data.r;
break;
case hittable_id::Triangle:
data.t = h.data.t;
break;
case hittable_id::BoundingBox:
data.bb = h.data.bb;
break;
case hittable_id::BoundingArrayNode:
data.ban = h.data.ban;
break;
case hittable_id::Unknown:
break;
}
}
__host__ __device__ hittable &operator=(hittable const &h) {
if (&h != this) {
id = h.id;
switch (h.id) {
case hittable_id::Sphere:
data.s = h.data.s;
break;
case hittable_id::Plane:
data.p = h.data.p;
break;
case hittable_id::Rectangle:
data.r = h.data.r;
break;
case hittable_id::Triangle:
data.t = h.data.t;
break;
case hittable_id::BoundingBox:
data.bb = h.data.bb;
break;
case hittable_id::BoundingArrayNode:
data.ban = h.data.ban;
break;
case hittable_id::Unknown:
break;
}
}
return *this;
}
__host__ __device__ inline bool hit(const ray &r, num t_min, num t_max,
hit_record &rec) const {
return data.hit(id, r, t_min, t_max, rec);
}
__host__ __device__ inline bounding_box get_bounding_box() const {
return data.get_bounding_box(id);
}
__host__ __device__ bounding_array_node const &
as_bounding_array_node() const {
return data.as_bounding_array_node();
}
hittable_id id;
hittable_data data;
};
inline __host__ bounding_tree_node_node::bounding_tree_node_node(
hittable **hittables, int hittables_size, RandomState *state, int start,
int end) {
int range = end - start;
int axis = random_int(state, 0, 2);
auto comparator = (axis == 0) ? x_compare
: (axis == 1) ? y_compare
: z_compare;
if (range == 1) {
auto o = new bounding_tree_node_object();
o->obj = hittables[start];
left = right = o;
} else if (range == 2) {
if (comparator(hittables[start]->get_bounding_box(),
hittables[start + 1]->get_bounding_box())) {
auto o1 = new bounding_tree_node_object();
o1->obj = hittables[start];
left = o1;
auto o2 = new bounding_tree_node_object();
o2->obj = hittables[start + 1];
right = o2;
} else {
auto o1 = new bounding_tree_node_object();
o1->obj = hittables[start + 1];
left = o1;
auto o2 = new bounding_tree_node_object();
o2->obj = hittables[start];
right = o2;
}
} else {
std::stable_sort(hittables + start, hittables + end,
[=](auto a, auto b) {
return comparator(a->get_bounding_box(), b->get_bounding_box());
});
int mid = start + range / CONST(2);
left = new bounding_tree_node_node(hittables, hittables_size, state,
start, mid);
right = new bounding_tree_node_node(hittables, hittables_size, state,
mid, end);
}
bounding_box box_left = left->get_bounding_box();
bounding_box box_right = right->get_bounding_box();
box = surrounding_box(box_left, box_right);
}
inline __host__ bounding_box
bounding_tree_node_object::get_bounding_box() const {
return obj->get_bounding_box();
}
inline __host__ int convert_tree_to_array(bounding_tree_node *root,
hittable *hittables) {
static int node_index = 0;
if (auto object = dynamic_cast<bounding_tree_node_object *>(root);
object != nullptr) {
return std::distance(hittables, object->obj);
} else if (auto node = dynamic_cast<bounding_tree_node_node *>(root);
node != nullptr) {
if (node->left == node->right) {
auto left_node = dynamic_cast<bounding_tree_node_object *>(node->left);
hittables[node_index] = *left_node->obj;
return std::distance(hittables, left_node->obj);
} else {
int index = node_index++;
int left_id = convert_tree_to_array(node->left, hittables);
int right_id = convert_tree_to_array(node->right, hittables);
hittables[index] =
bounding_array_node(left_id, right_id, root->get_bounding_box());
return index;
}
}
// Should definitely not get here
return -1;
}
#endif
| 29.677621
| 80
| 0.625132
|
JohnHynes
|
c75925f41861b56bce60f427cd5b497814e84a87
| 4,629
|
cc
|
C++
|
trex/python/exception_helper.cc
|
miatauro/trex2-agent
|
d896f8335f3194237a8bba49949e86f5488feddb
|
[
"BSD-3-Clause"
] | null | null | null |
trex/python/exception_helper.cc
|
miatauro/trex2-agent
|
d896f8335f3194237a8bba49949e86f5488feddb
|
[
"BSD-3-Clause"
] | null | null | null |
trex/python/exception_helper.cc
|
miatauro/trex2-agent
|
d896f8335f3194237a8bba49949e86f5488feddb
|
[
"BSD-3-Clause"
] | null | null | null |
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2015, Frederic Py.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the TREX Project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "exception_helper.hh"
#include <boost/scope_exit.hpp>
#include <pyerrors.h>
using namespace TREX::python::details;
using namespace TREX::python;
namespace bp=boost::python;
/*
* class TREX::python::details::exception_table
*/
// structors
exception_table::exception_table() {}
exception_table::~exception_table() {
while( !m_exceptions.empty() ) {
e_cvt_base *to_del = m_exceptions.front();
m_exceptions.pop_front();
delete to_del;
}
}
// modifiers
bool exception_table::add(e_cvt_base *ref) {
return m_exceptions.insert(ref).second;
}
// manipulators
void exception_table::unwrap_py_error() {
if( PyErr_Occurred() ) {
PyObject *exc,*val,*tb;
// fetch error info
PyErr_Fetch(&exc, &val, &tb);
bp::handle<> hexc(exc), hval(bp::allow_null(val)), htb(bp::allow_null(tb));
// clear error on python
PyErr_Clear();
if( NULL!=exc ) {
// Look if I know the error
exc_set::const_iterator pos = m_exceptions.find(exc);
if( m_exceptions.end()!=pos && NULL!=val ) {
// This type is known and has an instance -> convert it
(*pos)->convert(val);
} else {
// Not a type I can convert -> decode it and thow the content as python_error
bp::object formatted_list, formatted;
std::string type, msg;
if( m_traceback.is_none() ) {
m_traceback = bp::import("traceback");
}
// extract call stack info when available
if( NULL==tb ) {
bp::object fmt_exc_only(m_traceback.attr("format_exception_only"));
formatted_list = fmt_exc_only(hexc, hval);
} else {
bp::object fmt_exc(m_traceback.attr("format_exception"));
formatted_list = fmt_exc(hexc, hval, htb);
}
formatted = bp::str("\n").join(formatted_list);
type = bp::extract<std::string>(bp::str(hexc));
if( type.empty() )
type = "<unknown>";
msg = bp::extract<std::string>(formatted);
if( !msg.empty() )
type += ":\n"+msg;
throw python_error(type);
}
} else {
// exc was null even though Python says that and error occurred !??
// send a python error with <null> type; but this should never occur
throw python_error("<null>");
}
}
}
std::ostream &exception_table::unwrap_py_error(std::ostream &out, bool rethrow) {
try {
unwrap_py_error();
} catch(std::exception const &e) {
out<<e.what();
if( rethrow )
throw;
} catch(...) {
out<<"unknown exception";
if( rethrow )
throw;
}
return out;
}
/*
* class TREX::python::details::e_cvt_base
*/
// structors
e_cvt_base::e_cvt_base(PyObject *type):m_py_type(type) {}
e_cvt_base::~e_cvt_base() {}
// manipulators
void e_cvt_base::set_error(boost::python::object const &o) {
PyErr_SetObject(m_py_type, o.ptr());
}
| 29.864516
| 85
| 0.650248
|
miatauro
|
c75d697783e9c9fbf5a2c6e33c70ed7edd33ce3a
| 13,114
|
cpp
|
C++
|
Universe/engine/src/core/math.cpp
|
SmirnovVyacheslav/Universe_1.0
|
6210c57664796f653c2fe54c737caf615b7b58c9
|
[
"Apache-2.0"
] | null | null | null |
Universe/engine/src/core/math.cpp
|
SmirnovVyacheslav/Universe_1.0
|
6210c57664796f653c2fe54c737caf615b7b58c9
|
[
"Apache-2.0"
] | null | null | null |
Universe/engine/src/core/math.cpp
|
SmirnovVyacheslav/Universe_1.0
|
6210c57664796f653c2fe54c737caf615b7b58c9
|
[
"Apache-2.0"
] | null | null | null |
// Copyright: (C) 2021-2022 Vyacheslav Smirnov. All rights reserved.
#include "math.h"
namespace engine
{
float factorial(int n)
{
if (n == 0 || n == 1)
return 1.0f;
float result = 1.0f;
for (int i = 1; i <= n; ++i)
{
result *= static_cast<float>(i);
}
return result;
}
float radian_to_degree(float radian)
{
return radian * 180.0f / pi;
}
float degree_to_radian(float degree)
{
return degree * pi / 180.0f;
}
vector_3 project_vector_to_plane(vector_3 vector_to_project, vector_3 plane_point, vector_3 plane_normal)
{
// Need to make projection only for vector_end_point
vector_3 vector_end_point = vector_to_project + plane_point;
// Make dot projection
float distance_to_plane = vector_to_project & plane_normal;
vector_3 plane_point_b = vector_end_point - (distance_to_plane * plane_normal);
// Construst new projection for vector
return plane_point_b - plane_point;
}
//vector_3 rotate_vector(vector_3 vector, vector_3 axis, float angle)
//{
// angle = degree_to_radian(angle);
// // Rotation matrix
// std::vector<vector_3> matrix = {
// vector_3(cos(angle) + (1 - cos(angle)) * axis.x * axis.x,
// (1 - cos(angle)) * axis.x * axis.y - sin(angle) * axis.z,
// (1 - cos(angle)) * axis.x * axis.z + sin(angle) * axis.y),
// vector_3((1 - cos(angle)) * axis.x * axis.y + sin(angle) * axis.z,
// cos(angle) + (1 - cos(angle)) * axis.y * axis.y,
// (1 - cos(angle)) * axis.y * axis.z - sin(angle) * axis.x),
// vector_3((1 - cos(angle)) * axis.x * axis.z - sin(angle) * axis.y,
// (1 - cos(angle)) * axis.y * axis.z + sin(angle) * axis.x,
// cos(angle) + (1 - cos(angle)) * axis.z * axis.z)
// };
// vector_3 result = {
// matrix[0] & vector,
// matrix[1] & vector,
// matrix[2] & vector
// };
// return result;
//}
bool vector_3::is_zero()
{
return (x + y + z) < eps;
}
/*float vector_3::length()
{
double _x = static_cast<double>(x);
double _y = static_cast<double>(y);
double _z = static_cast<double>(z);
return static_cast<float>(sqrt(_x * _x + _y * _y + _z * _z));
}*/
/* vector_3& vector_3::normalize()
{
float len = length();
x /= len;
y /= len;
z /= len;
return *this;
}*/
vector_3& vector_3::trunc()
{
x = x > 1.0f ? 1.0f : x;
y = y > 1.0f ? 1.0f : y;
z = z > 1.0f ? 1.0f : z;
return *this;
}
vector_3& vector_3::operator=(const vector_3& vec)
{
if (this != &vec)
{
x = vec.x;
y = vec.y;
z = vec.z;
}
return *this;
}
vector_3& vector_3::operator+=(const float& num)
{
x += num; y += num; z += num;
return *this;
}
vector_3& vector_3::operator-=(const float& num)
{
x -= num; y -= num; z -= num;
return *this;
}
vector_3& vector_3::operator*=(const float& num)
{
x *= num; y *= num; z *= num;
return *this;
}
vector_3& vector_3::operator/=(const float& num)
{
x /= num; y /= num; z /= num;
return *this;
}
vector_3& vector_3::operator+=(const vector_3& vec)
{
x += vec.x; y += vec.y; z += vec.z;
return *this;
}
vector_3& vector_3::operator-=(const vector_3& vec)
{
x -= vec.x; y -= vec.y; z -= vec.z;
return *this;
}
vector_3& vector_3::operator*=(const vector_3& vec)
{
x *= vec.x; y *= vec.y; z *= vec.z;
return *this;
}
vector_3& vector_3::operator/=(const vector_3& vec)
{
x /= vec.x; y /= vec.y; z /= vec.z;
return *this;
}
/**
* Scalar cross product
*/
float vector_3::operator&=(const vector_3& vec)
{
return x * vec.x + y * vec.y + z * vec.z;
}
/**
* Vector cross product
*/
vector_3& vector_3::operator^=(const vector_3& vec)
{
x = y * vec.z - z * vec.y;
y = z * vec.x - x * vec.z;
z = x * vec.y - y * vec.x;
return *this;
}
vector_3::operator vector_4()
{
return { x, y, z, 1.0f };
}
vector_3 operator+(const vector_3& vec_a, const vector_3& vec_b)
{
return { vec_a.x + vec_b.x, vec_a.y + vec_b.y, vec_a.z + vec_b.z };
}
vector_3 operator-(const vector_3& vec_a, const vector_3& vec_b)
{
return { vec_a.x - vec_b.x, vec_a.y - vec_b.y, vec_a.z - vec_b.z };
}
vector_3 operator*(const vector_3& vec_a, const vector_3& vec_b)
{
return { vec_a.x * vec_b.x, vec_a.y * vec_b.y, vec_a.z * vec_b.z };
}
vector_3 operator/(const vector_3& vec_a, const vector_3& vec_b)
{
return { vec_a.x / vec_b.x, vec_a.y / vec_b.y, vec_a.z / vec_b.z };
}
/**
* Scalar cross product
*/
float operator&(const vector_3& vec_a, const vector_3& vec_b)
{
return vec_a.x * vec_b.x + vec_a.y * vec_b.y + vec_a.z * vec_b.z;
}
/**
* Vector cross product
*/
vector_3 operator^(const vector_3& vec_a, const vector_3& vec_b)
{
return { vec_a.y * vec_b.z - vec_a.z * vec_b.y,
vec_a.z * vec_b.x - vec_a.x * vec_b.z,
vec_a.x * vec_b.y - vec_a.y * vec_b.x };
}
bool operator==(const vector_3& vec_a, const vector_3& vec_b)
{
if ((vec_a.x - vec_b.x) * (vec_a.x - vec_b.x) > eps)
return false;
if ((vec_a.y - vec_b.y) * (vec_a.y - vec_b.y) > eps)
return false;
if ((vec_a.z - vec_b.z) * (vec_a.z - vec_b.z) > eps)
return false;
return true;
}
bool operator!=(const vector_3& vec_a, const vector_3& vec_b)
{
return !(vec_a == vec_b);
}
vector_3 operator+(const float& num, const vector_3& vec)
{
return { num + vec.x, num + vec.y, num + vec.z };
}
vector_3 operator-(const float& num, const vector_3& vec)
{
return { num - vec.x, num - vec.y, num - vec.z };
}
vector_3 operator*(const float& num, const vector_3& vec)
{
return { num * vec.x, num * vec.y, num * vec.z };
}
vector_3 operator/(const float& num, const vector_3& vec)
{
return { num / vec.x, num / vec.y, num / vec.z };
}
vector_3 operator+(const vector_3& vec, const float& num)
{
return { vec.x + num, vec.y + num, vec.z + num };
}
vector_3 operator-(const vector_3& vec, const float& num)
{
return { vec.x - num, vec.y - num, vec.z - num };
}
vector_3 operator*(const vector_3& vec, const float& num)
{
return { vec.x * num, vec.y * num, vec.z * num };
}
vector_3 operator/(const vector_3& vec, const float& num)
{
return { vec.x / num, vec.y / num, vec.z / num };
}
/*float distance(vector_3 vec_a, vector_3 vec_b)
{
double vec_a_x = static_cast<double>(vec_a.x);
double vec_a_y = static_cast<double>(vec_a.y);
double vec_a_z = static_cast<double>(vec_a.z);
double vec_b_x = static_cast<double>(vec_b.x);
double vec_b_y = static_cast<double>(vec_b.y);
double vec_b_z = static_cast<double>(vec_b.z);
return sqrt((vec_b_x - vec_a_x) * (vec_b_x - vec_a_x) +
(vec_b_y - vec_a_y) * (vec_b_y - vec_a_y) +
(vec_b_z - vec_a_z) * (vec_b_z - vec_a_z));
}*/
/*float distance(vector_3 vec_a, vector_4 vec_b)
{
return distance(vec_a, static_cast<vector_3>(vec_b));
}
float distance(vector_4 vec_a, vector_3 vec_b)
{
return distance(static_cast<vector_3>(vec_a), vec_b);
}*/
/*float distance(vector_4 vec_a, vector_4 vec_b)
{
double vec_a_x = static_cast<double>(vec_a.x);
double vec_a_y = static_cast<double>(vec_a.y);
double vec_a_z = static_cast<double>(vec_a.z);
double vec_a_w = static_cast<double>(vec_a.w);
double vec_b_x = static_cast<double>(vec_b.x);
double vec_b_y = static_cast<double>(vec_b.y);
double vec_b_z = static_cast<double>(vec_b.z);
double vec_b_w = static_cast<double>(vec_b.w);
return sqrt((vec_b_x - vec_a_x) * (vec_b_x - vec_a_x) +
(vec_b_y - vec_a_y) * (vec_b_y - vec_a_y) +
(vec_b_z - vec_a_z) * (vec_b_z - vec_a_z) +
(vec_b_w - vec_a_w) * (vec_b_w - vec_a_w));
}*/
/*float angle(vector_3 vec_a, vector_3 vec_b)
{
double arg = static_cast<double>((vec_a & vec_b) / (vec_a.length() * vec_b.length()));
return static_cast<float>(acos(arg));
}*/
/*float vector_4::length()
{
double _x = static_cast<double>(x);
double _y = static_cast<double>(y);
double _z = static_cast<double>(z);
return static_cast<float>(sqrt(_x * _x + _y * _y + _z * _z));
}*/
/*vector_4& vector_4::normalize()
{
float len = length();
x /= len;
y /= len;
z /= len;
return *this;
}*/
vector_4& vector_4::trunc()
{
x = x > 1.0f ? 1.0f : x;
y = y > 1.0f ? 1.0f : y;
z = z > 1.0f ? 1.0f : z;
return *this;
}
vector_4& vector_4::operator=(const vector_4& vec)
{
if (this != &vec)
{
x = vec.x;
y = vec.y;
z = vec.z;
w = vec.w;
}
return *this;
}
vector_4& vector_4::operator+=(const float& num)
{
x += num; y += num; z += num;
return *this;
}
vector_4& vector_4::operator-=(const float& num)
{
x -= num; y -= num; z -= num;
return *this;
}
vector_4& vector_4::operator*=(const float& num)
{
x *= num; y *= num; z *= num;
return *this;
}
vector_4& vector_4::operator/=(const float& num)
{
x /= num; y /= num; z /= num;
return *this;
}
vector_4& vector_4::operator+=(const vector_4& vec)
{
x += vec.x; y += vec.y; z += vec.z;
return *this;
}
vector_4& vector_4::operator-=(const vector_4& vec)
{
x -= vec.x; y -= vec.y; z -= vec.z;
return *this;
}
vector_4& vector_4::operator*=(const vector_4& vec)
{
x *= vec.x; y *= vec.y; z *= vec.z;
return *this;
}
vector_4& vector_4::operator/=(const vector_4& vec)
{
x /= vec.x; y /= vec.y; z /= vec.z;
return *this;
}
vector_4::operator vector_3()
{
return { x, y, z };
}
vector_4 operator+(const vector_4& vec_a, const vector_4& vec_b)
{
return { vec_a.x + vec_b.x, vec_a.y + vec_b.y, vec_a.z + vec_b.z, 1.0f };
}
vector_4 operator-(const vector_4& vec_a, const vector_4& vec_b)
{
return { vec_a.x - vec_b.x, vec_a.y - vec_b.y, vec_a.z - vec_b.z, 1.0f };
}
vector_4 operator*(const vector_4& vec_a, const vector_4& vec_b)
{
return { vec_a.x * vec_b.x, vec_a.y * vec_b.y, vec_a.z * vec_b.z, 1.0f };
}
vector_4 operator/(const vector_4& vec_a, const vector_4& vec_b)
{
return { vec_a.x / vec_b.x, vec_a.y / vec_b.y, vec_a.z / vec_b.z, 1.0f };
}
bool operator==(const vector_4& vec_a, const vector_4& vec_b)
{
if ((vec_a.x - vec_b.x) * (vec_a.x - vec_b.x) > eps)
return false;
if ((vec_a.y - vec_b.y) * (vec_a.y - vec_b.y) > eps)
return false;
if ((vec_a.z - vec_b.z) * (vec_a.z - vec_b.z) > eps)
return false;
return true;
}
bool operator!=(const vector_4& vec_a, const vector_4& vec_b)
{
return !(vec_a == vec_b);
}
vector_4 operator+(const float& num, const vector_4& vec)
{
return { num + vec.x, num + vec.y, num + vec.z, 1.0f };
}
vector_4 operator-(const float& num, const vector_4& vec)
{
return { num - vec.x, num - vec.y, num - vec.z, 1.0f };
}
vector_4 operator*(const float& num, const vector_4& vec)
{
return { num * vec.x, num * vec.y, num * vec.z, 1.0f };
}
vector_4 operator/(const float& num, const vector_4& vec)
{
return { num / vec.x, num / vec.y, num / vec.z, 1.0f };
}
vector_4 operator+(const vector_4& vec, const float& num)
{
return { vec.x + num, vec.y + num, vec.z + num, 1.0f };
}
vector_4 operator-(const vector_4& vec, const float& num)
{
return { vec.x - num, vec.y - num, vec.z - num, 1.0f };
}
vector_4 operator*(const vector_4& vec, const float& num)
{
return { vec.x * num, vec.y * num, vec.z * num, 1.0f };
}
vector_4 operator/(const vector_4& vec, const float& num)
{
return { vec.x / num, vec.y / num, vec.z / num, 1.0f };
}
}
| 28.949227
| 109
| 0.521351
|
SmirnovVyacheslav
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.