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
7cd69f6f66570ee16e0dfc4a00208ac3e4fce49a
1,924
cpp
C++
Algorithms/Implementation/The_Bomberman_Game/main.cpp
ugurcan-sonmez-95/HackerRank_Problems
187d83422128228c241f279096386df5493d539d
[ "MIT" ]
null
null
null
Algorithms/Implementation/The_Bomberman_Game/main.cpp
ugurcan-sonmez-95/HackerRank_Problems
187d83422128228c241f279096386df5493d539d
[ "MIT" ]
null
null
null
Algorithms/Implementation/The_Bomberman_Game/main.cpp
ugurcan-sonmez-95/HackerRank_Problems
187d83422128228c241f279096386df5493d539d
[ "MIT" ]
null
null
null
// The Bomberman Game - Solution #include <iostream> #include <vector> std::vector<std::string> bomberMan(const int r, const int c, const int n, const std::vector<std::string> &grid) { std::vector<std::string> finalGrid1 = grid, finalGrid2, finalGrid3; for (int i{}; i < r; i++) for (int j{}; j < c; j++) finalGrid1[i][j] = 'O'; finalGrid3 = finalGrid2 = finalGrid1; for (int k{}; k < r; k++) { for (int l{}; l < c; l++) { if (grid[k][l] == 'O') { finalGrid2[k][l] = '.'; if (k > 0) finalGrid2[k-1][l] = '.'; if (l > 0) finalGrid2[k][l-1] = '.'; if (l < c-1) finalGrid2[k][l+1] = '.'; if (k < r-1) finalGrid2[k+1][l] = '.'; } } } for (int m{}; m < r; m++) { for (int p{}; p < c; p++) { if (finalGrid2[m][p] == 'O') { finalGrid3[m][p] = '.'; if (m > 0) finalGrid3[m-1][p] = '.'; if (p > 0) finalGrid3[m][p-1] = '.'; if (p < c-1) finalGrid3[m][p+1] = '.'; if (m < r-1) finalGrid3[m+1][p] = '.'; } } } if (n == 1 || n == 0) return grid; if (n % 2 == 0) return finalGrid1; if (n % 4 == 3) return finalGrid2; return finalGrid3; } int main() { int r, c, n; std::cin >> r >> c >> n; std::vector<std::string> grid(r); char ch; for (int i{}; i < r; i++) { for (int j{}; j < c; j++) { std::cin >> ch; grid[i].push_back(ch); } } const std::vector<std::string> result = bomberMan(r, c, n, grid); for (auto &el: result) std::cout << el << '\n'; return 0; }
28.716418
113
0.37526
ugurcan-sonmez-95
7cd798d6286c3458b708f1391f6a55e9c9d78390
27,815
hpp
C++
common/cmdline.hpp
Mainvooid/common
fd8f966ba283cb8df619166b41c76fb0cfc6a4c7
[ "MIT" ]
null
null
null
common/cmdline.hpp
Mainvooid/common
fd8f966ba283cb8df619166b41c76fb0cfc6a4c7
[ "MIT" ]
null
null
null
common/cmdline.hpp
Mainvooid/common
fd8f966ba283cb8df619166b41c76fb0cfc6a4c7
[ "MIT" ]
null
null
null
/* @brief a simple command line parser @author guobao.v@gmail.com */ #ifndef _COMMON_CMDLINE_HPP_ #define _COMMON_CMDLINE_HPP_ #include <common/precomm.hpp> #include <algorithm> #ifdef __GNUC__ #include <cxxabi.h> #endif /** @addtogroup common @{ @defgroup cmdline cmdline - command line parser @{ @defgroup detail detail @} @} */ namespace common { /// @addtogroup common /// @{ namespace cmdline { /// @addtogroup cmdline /// @{ static const std::string _TAG = "cmdline"; namespace detail { /// @addtogroup detail /// @{ /** *@brief 获取类型 */ static inline std::string demangle(const std::string &name) noexcept { #ifdef _MSC_VER return name; #elif defined(__GNUC__) int status = 0; char *p = abi::__cxa_demangle(name.c_str(), 0, 0, &status); std::string ret(p); free(p); return ret; #else #error unexpected c complier (msc/gcc), Need to implement this method for demangle #endif } /** *@brief 获取类型 */ template <typename T> std::string readable_typename() noexcept { return demangle(typeid(T).name()); } template <> inline std::string readable_typename<std::string>() noexcept { return "string"; } template <> inline std::string readable_typename<std::wstring>() noexcept { return "wstring"; } /** *@brief T -> string */ template <typename T> std::string default_value(T def) noexcept { return convert_to_string<char>(def); } /// @} } // detail -------------------------------------------------- /** *@brief 模块异常类 */ class[[deprecated("unnecessary")]]cmdline_error : public std::exception { public: cmdline_error(const std::string msg) : m_msg(std::move(msg)) {} ~cmdline_error() {} const char *what() const { return m_msg.c_str(); } private: std::string m_msg; }; /** *@brief string -> T */ template <typename T> class default_reader { public: T operator()(const std::string &str) noexcept(false) { return convert_from_string<T>(str); } }; /** *@brief 参数范围检查器 */ template <typename T> class range_reader { public: range_reader(const T &low, const T &high) : m_low(low), m_high(high) {} T operator()(const std::string &s) const noexcept(false) { T ret = default_reader<T>()(s); if (!(ret >= m_low && ret <= m_high)) { std::ostringstream msg; msg << _TAG << "..range error"; throw std::range_error(msg.str()); } return ret; } private: T m_low, m_high; }; /** *@brief 返回一个参数范围检查器 */ template <typename T> range_reader<T> range(const T &low, const T &high) noexcept { return range_reader<T>(low, high); } /** *@brief 可选值检查器 */ template <typename T> class oneof_reader { public: oneof_reader() {} oneof_reader(const std::initializer_list<T> &list) noexcept { for (T item : list) { m_values.push_back(item); } } template <typename ...Values> oneof_reader(const T& v, const Values&...vs) noexcept { add(v, vs...); } T operator=(const std::initializer_list<T> &list) noexcept { for (T item : list) { m_values.push_back(item); } }; T operator()(const std::string &s) noexcept(false) { T ret = default_reader<T>()(s); if (std::find(m_values.begin(), m_values.end(), ret) == m_values.end()) { std::ostringstream msg; msg << _TAG << "..oneof error"; throw std::invalid_argument(msg.str()); } return ret; } template <typename ...Values> void add(const T& v, const Values&...vs) noexcept { m_values.push_back(v); add(vs...); } private: void add(const T& v) noexcept { m_values.push_back(v); } private: std::vector<T> m_values; }; /** *@brief 返回一个可选值检查器 */ template <typename T, typename ...Values> oneof_reader<T> oneof(const T& a1, const Values&... a2) noexcept { return oneof_reader<T>(a1, a2...); } /** *@brief 返回一个可选值检查器 */ template <typename T> oneof_reader<T> oneof(const std::initializer_list<T> &list) noexcept { return oneof_reader<T>(list); } /** *@brief 命令行解析类 */ class parser { public: parser() {} ~parser() { for (std::map<std::string, option_base*>::iterator p = options.begin(); p != options.end(); p++) { delete_s(p->second); } } /** *@brief 添加指定类型的参数 *@param name 长名称 *@param short_name 短名称(\0:表示没有短名称) *@param desc 描述 */ void add(const std::string &name, char short_name = 0, const std::string &desc = "") noexcept(false) { if (options.count(name)) { std::ostringstream msg; msg << _TAG << "..multiple definition:" << name; throw std::invalid_argument(msg.str()); } options[name] = new option_without_value(name, short_name, desc); ordered.push_back(options[name]); } /** *@brief 添加指定类型的参数 *@param name 长名称 *@param short_name 短名称(\0:表示没有短名称) *@param desc 描述 *@param need 是否必需(可选) *@param def 默认值(可选,当不必需时使用) */ template <typename T> void add(const std::string &name, char short_name = 0, const std::string &desc = "", bool need = true, const T def = T()) noexcept(false) { add(name, short_name, desc, need, def, default_reader<T>()); } /** *@brief 添加指定类型的参数 *@param name 长名称 *@param short_name 短名称(\0:表示没有短名称) *@param desc 描述 *@param need 是否必需(可选) *@param def 默认值(可选,当不必需时使用) *@param reader 解析类型 */ template <class T, class F> void add(const std::string &name, char short_name = 0, const std::string &desc = "", bool need = true, const T def = T(), F reader = F()) noexcept(false) { if (options.count(name)) { std::ostringstream msg; msg << _TAG << "..multiple definition:" << name; throw std::invalid_argument(msg.str()); } options[name] = new option_with_value_with_reader<T, F>(name, short_name, need, def, desc, reader); ordered.push_back(options[name]); } /** *@brief usage尾部添加说明(如果需要解析未指定参数) *@param f 补充说明 */ void footer(std::string f) noexcept { ftr = std::move(f); } /** *@brief 设置usage程序名,默认由argv[0]确定 *@param name usage程序名 */ void set_program_name(std::string name) noexcept { prog_name = std::move(name); } /** *@brief 判断bool参数是否被指定 *@param name bool参数名 */ bool exist(const std::string &name) const noexcept(false) { if (options.count(name) == 0) { std::ostringstream msg; msg << _TAG << "..there is no flag: --" << name; throw std::invalid_argument(msg.str()); } return options.find(name)->second->has_set(); } /** *@brief 获取参数的值 *@param name 参数名 *@return 返回相应类型参数值 */ template <class T> const T &get(const std::string &name) const noexcept(false) { if (options.count(name) == 0) { std::ostringstream msg; msg << _TAG << "..there is no flag: --" << name; throw std::invalid_argument(msg.str()); } const option_with_value<T> *p = dynamic_cast<const option_with_value<T>*>(options.find(name)->second); if (p == nullptr) { std::ostringstream msg; msg << _TAG << "..type mismatch flag '" << name << "'"; throw std::invalid_argument(msg.str()); } return p->get(); } /** *@brief 获取未指定的参数的值 */ const std::vector<std::string> &rest() const noexcept { return others; } /** *@brief 解析一行命令 *@param arg 参数 *@return 是否解析成功 */ bool parse(const std::string &arg) noexcept { std::vector<std::string> args; std::string buf; bool in_quote = false;//是否有"" for (std::string::size_type i = 0; i < arg.length(); i++) { if (arg[i] == '\"') { in_quote = !in_quote; continue; } if (arg[i] == ' ' && !in_quote) { args.push_back(buf); buf = ""; continue; } if (arg[i] == '\\') { //跳过'\' i++; if (i >= arg.length()) { errors.push_back("unexpected occurrence of '\\' at end of string"); return false; } } buf += arg[i]; } if (in_quote) { errors.push_back("quote is not closed"); return false; } if (buf.length() > 0) { args.push_back(buf); } for (size_t i = 0; i < args.size(); i++) { std::cout << "\"" << args[i] << "\"" << std::endl; } return parse(args); } /** *@brief 解析参数数组 *@param args 参数数组 *@return 是否解析成功 */ bool parse(const std::vector<std::string> &args) noexcept { int argc = static_cast<int>(args.size()); std::vector<const char*> argv(argc); for (int i = 0; i < argc; i++) { argv[i] = args[i].c_str(); } return parse(argc, &argv[0]); } /** *@brief 解析参数数组 *@param argc 参数数量(+程序名) *@param argv 参数值([0]为程序名) *@return 是否解析成功 */ bool parse(int argc, const char * const argv[]) noexcept { errors.clear(); others.clear(); if (argc < 1) { errors.push_back("argument number must be bigger than 0"); return false; } if (prog_name == "") { prog_name = argv[0]; } std::map<char, std::string> lookup; for (std::map<std::string, option_base*>::iterator p = options.begin(); p != options.end(); p++) { if (p->first.length() == 0) { continue;//key不存在 } char initial = p->second->short_name(); if (initial) { if (lookup.count(initial) > 0) { lookup[initial] = ""; errors.push_back(std::string("short option '") + initial + "' is ambiguous"); return false; } else { lookup[initial] = p->first; } } } for (int i = 1; i < argc; i++) { if (strncmp(argv[i], "--", 2) == 0) {//长名称 const char *p = strchr(argv[i] + 2, '='); if (p) { std::string name(argv[i] + 2, p); std::string val(p + 1); set_option(name, val); } else { std::string name(argv[i] + 2); if (options.count(name) == 0) { errors.push_back("undefined option: --" + name); continue; } if (options[name]->has_value()) { if (i + 1 >= argc) { errors.push_back("option needs value: --" + name); continue; } else { i++; set_option(name, argv[i]); } } else { set_option(name); //bool } } } else if (strncmp(argv[i], "-", 1) == 0) {//短名称 if (!argv[i][1]) {//若'-'后无值 continue; } char last = argv[i][1]; for (int j = 2; argv[i][j]; j++) { last = argv[i][j]; if (lookup.count(argv[i][j - 1]) == 0) { errors.push_back(std::string("undefined short option: -") + argv[i][j - 1]); continue; } if (lookup[argv[i][j - 1]] == "") { errors.push_back(std::string("ambiguous short option: -") + argv[i][j - 1]); continue; } set_option(lookup[argv[i][j - 1]]); } if (lookup.count(last) == 0) { errors.push_back(std::string("undefined short option: -") + last); continue; } if (lookup[last] == "") { errors.push_back(std::string("ambiguous short option: -") + last); continue; } if (i + 1 < argc && options[lookup[last]]->has_value()) { set_option(lookup[last], argv[i + 1]); i++; } else { set_option(lookup[last]); } } else { others.push_back(argv[i]); } } for (std::map<std::string, option_base*>::iterator p = options.begin(); p != options.end(); p++) { if (!p->second->valid()) { errors.push_back("need option: --" + std::string(p->first)); } } return errors.size() == 0; } /** *@brief 包装parse并做检查 *@param arg 一行命令 */ void parse_check(const std::string &arg) noexcept(false) { if (!options.count("help")) { add("help", '?', "print this message"); } check(0, parse(arg)); } /** *@brief 包装parse并做检查 *@param args 参数数组 */ void parse_check(const std::vector<std::string> &args) noexcept(false) { if (!options.count("help")) { add("help", '?', "print this message"); } check(args.size(), parse(args)); } /** *@brief 运行解析器(包装parse并做检查) *@param argc 参数数量(+程序名) *@param argv 参数值([0]为程序名) *@note 仅当命令行参数有效时才返回 如果参数无效,解析器输出错误消息然后退出程序 如果指定了help flag('-help'或'-?')或空命令,则解析器输出用法消息然后退出程序 */ void parse_check(int argc, char *argv[]) noexcept(false) { if (!options.count("help")) { add("help", '?', "print this message"); } check(argc, parse(argc, argv)); } /** *@brief 返回第一条错误消息 */ std::string error() const { return errors.size() > 0 ? errors[0] : ""; } /** *@brief 返回所有错误消息 */ std::string error_full() const noexcept { std::ostringstream oss; for (size_t i = 0; i < errors.size(); i++) { oss << errors[i] << std::endl; } return oss.str(); } /** *@brief 返回使用方法说明 */ std::string usage() const noexcept { std::ostringstream oss; oss << "usage: " << prog_name << " "; for (size_t i = 0; i < ordered.size(); i++) { if (ordered[i]->must()) { oss << ordered[i]->short_description() << " "; } } oss << "[options] ... " << ftr << std::endl; oss << "options:" << std::endl; size_t max_width = 0; for (size_t i = 0; i < ordered.size(); i++) { max_width = std::max(max_width, ordered[i]->name().length()); } for (size_t i = 0; i < ordered.size(); i++) { if (ordered[i]->short_name()) { oss << " -" << ordered[i]->short_name() << ", "; } else { oss << " "; } oss << "--" << ordered[i]->name(); for (size_t j = ordered[i]->name().length(); j < max_width + 4; j++) { oss << ' '; } oss << ordered[i]->description() << std::endl; } return oss.str(); } private: /** *@brief parse检查 *@param argc 参数数量 *@param ok 是否解析成功 */ void check(size_t argc, bool ok) noexcept { if ((argc == 1 && !ok) || exist("help")) { std::cerr << usage(); exit(0); } if (!ok) { std::cerr << error() << std::endl << usage(); exit(1); } } /** *@brief 设置参数选项 *@param name 参数名 */ void set_option(const std::string &name) noexcept { if (options.count(name) == 0) { errors.push_back("undefined option: --" + name); return; } if (!options[name]->set()) { errors.push_back("option needs value: --" + name); return; } } /** *@brief 设置参数选项 *@param name 参数名 *@param value 参数值 */ void set_option(const std::string &name, const std::string &value) noexcept { if (options.count(name) == 0) { errors.push_back("undefined option: --" + name); return; } if (!options[name]->set(value)) { errors.push_back("option value is invalid: --" + name + "=" + value); return; } } /** *@brief 参数选项基础接口类 */ class option_base { public: virtual ~option_base() {} virtual bool has_value() const = 0; virtual bool set() = 0; virtual bool set(const std::string &value) = 0; virtual bool has_set() const = 0; virtual bool valid() const = 0; virtual bool must() const = 0; virtual const std::string &name() const = 0; virtual char short_name() const = 0; virtual const std::string &description() const = 0; virtual std::string short_description() const = 0; }; /** *@brief 参数选项派生类(无值参数:bool) */ class option_without_value : public option_base { public: option_without_value(const std::string &name, char short_name, const std::string &desc) :m_name(name), m_short_name(short_name), m_desc(desc), m_has(false) {} ~option_without_value() {} bool has_value() const noexcept { return false; } bool set() noexcept { m_has = true; return true; } bool set(const std::string &) noexcept { return false; } bool has_set() const noexcept { return m_has; } bool valid() const noexcept { return true; } bool must() const noexcept { return false; } const std::string &name() const noexcept { return m_name; } char short_name() const noexcept { return m_short_name; } const std::string &description() const noexcept { return m_desc; } std::string short_description() const noexcept { return "--" + m_name; } private: std::string m_name; char m_short_name; std::string m_desc; bool m_has; }; /** *@brief 参数选项派生类(有值参数) */ template <class T> class option_with_value : public option_base { public: /** *@brief 参数选项派生类(有值参数) *@param name 长名称 *@param short_name 短名称 *@param need 是否必需 *@param def 默认值 *@param desc 描述 */ option_with_value(const std::string &name, char short_name, bool need, const T &def, const std::string &desc) : m_name(name), m_short_name(short_name), m_need(need), m_has(false), m_def(def), m_actual(def) { this->desc = full_description(desc); } ~option_with_value() {} const T &get() const { return m_actual; } bool has_value() const { return true; } bool set() { return false; } bool set(const std::string &value) noexcept { try { m_actual = read(value); m_has = true; } catch (const std::exception &) { return false; } return true; } bool has_set() const { return m_has; } bool valid() const { return (m_need && !m_has) ? false : true; } bool must() const { return m_need; } const std::string &name() const { return m_name; } char short_name() const { return m_short_name; } const std::string &description() const { return desc; } std::string short_description() const noexcept { return "--" + m_name + "=" + detail::readable_typename<T>(); } protected: std::string full_description(const std::string &desc) noexcept { return desc + " (" + detail::readable_typename<T>() + (m_need ? "" : " [=" + detail::default_value<T>(m_def) + "]") + ")"; } virtual T read(const std::string &s) = 0; protected: std::string m_name; char m_short_name; bool m_need; std::string desc; bool m_has; T m_def;///< 默认值 T m_actual;///< 实际值 }; /** *@brief 有值参数选项派生类 */ template <class T, class F> class option_with_value_with_reader : public option_with_value<T> { public: /** *@brief 有值参数选项派生类 *@param name 长名称 *@param short_name 短名称 *@param need 是否必需 *@param def 默认值 *@param desc 描述 *@param reader 可读包装类型string->T */ option_with_value_with_reader(const std::string &name, char short_name, bool need, const T def, const std::string &desc, F reader) : option_with_value<T>(name, short_name, need, def, desc), reader(reader) {} private: //string -> T T read(const std::string &s) noexcept { return reader(s); } private: F reader; }; private: std::map<std::string, option_base*> options;///< 参数选项map(长名称,一个选项) std::vector<option_base*> ordered; ///< 有序的参数选项(add时push) std::string ftr; ///< usage尾部添加说明 std::string prog_name; ///< 程序名 std::vector<std::string> others; ///< 其他为指定参数 std::vector<std::string> errors; ///< 错误消息 }; /// @} } // cmdline /// @} } // common #endif // _COMMON_CMDLINE_HPP_
34.595771
125
0.39112
Mainvooid
7cdad3ebcc2bf57b9787e69f1a92a256c4646439
990
cpp
C++
engine/src/engine/core/layers_stack.cpp
DmitryK579/Tank-Assault
f20cee73fdaa1e1d34f24cc681d781a26a7311a1
[ "MIT" ]
null
null
null
engine/src/engine/core/layers_stack.cpp
DmitryK579/Tank-Assault
f20cee73fdaa1e1d34f24cc681d781a26a7311a1
[ "MIT" ]
null
null
null
engine/src/engine/core/layers_stack.cpp
DmitryK579/Tank-Assault
f20cee73fdaa1e1d34f24cc681d781a26a7311a1
[ "MIT" ]
2
2021-12-16T13:04:18.000Z
2022-01-07T14:06:06.000Z
#include "pch.h" #include "layers_stack.h" engine::layers_stack::~layers_stack() { for(auto* layer : m_layers) { layer->on_detach(); delete layer; } } void engine::layers_stack::push_layer(layer* layer) { m_layers.emplace(m_layers.begin() + m_layers_insert_index, layer); m_layers_insert_index++; layer->on_attach(); } void engine::layers_stack::push_overlay(layer* overlay) { m_layers.emplace_back(overlay); overlay->on_attach(); } void engine::layers_stack::pop_layer(layer* layer) { auto it = std::find(m_layers.begin(), m_layers.end(), layer); if(it != m_layers.begin() + m_layers_insert_index) { layer->on_detach(); m_layers.erase(it); --m_layers_insert_index; } } void engine::layers_stack::pop_overlay(layer* overlay) { auto it = std::find(m_layers.begin(), m_layers.end(), overlay); if(it != m_layers.end()) { overlay->on_detach(); m_layers.erase(it); } }
21.521739
70
0.638384
DmitryK579
7ce095b7f6667f84a76d62e0e9023d433e372d20
7,051
cpp
C++
src/RSL/UnitTest/RslMigration/TestHarness/main.cpp
nkindberg/RSL
f5907fb694c00ebcc6d6ad54e72e9f8a9b66ff0a
[ "MIT" ]
58
2018-03-21T09:55:08.000Z
2022-03-25T07:21:42.000Z
src/RSL/UnitTest/RslMigration/TestHarness/main.cpp
nkindberg/RSL
f5907fb694c00ebcc6d6ad54e72e9f8a9b66ff0a
[ "MIT" ]
2
2019-01-29T05:56:48.000Z
2019-05-23T04:44:28.000Z
src/RSL/UnitTest/RslMigration/TestHarness/main.cpp
nkindberg/RSL
f5907fb694c00ebcc6d6ad54e72e9f8a9b66ff0a
[ "MIT" ]
17
2018-03-21T12:10:47.000Z
2022-03-20T03:24:37.000Z
#define _WINSOCKAPI_ #include <windows.h> #include <stdio.h> #include <list> #include "libfuncs.h" #include "logging.h" using namespace std; using namespace RSLibImpl; #define NUM_REPLICAS 5 #define MAX_CMD_LEN 256 char procTitles[NUM_REPLICAS][256]; volatile bool endTest; volatile bool endTestCompleted; bool StartProcess(char * programName, int replicaId, HANDLE *processHandlePtr) { _snprintf_s(procTitles[replicaId-1], MAX_CMD_LEN, "%s %d", programName, replicaId); printf("%s\n", procTitles[replicaId-1]); STARTUPINFOA startupInfo; GetStartupInfoA(&startupInfo); startupInfo.lpTitle = procTitles[replicaId-1]; PROCESS_INFORMATION processInfo; if (!CreateProcessA(NULL, procTitles[replicaId-1], NULL, // no process security attributes NULL, // no thread security attributes FALSE, // inherit handles? no CREATE_NEW_CONSOLE, NULL, // no special environment NULL, //directoryPath, &startupInfo, &processInfo)) { return false; } *processHandlePtr = processInfo.hProcess; CloseHandle(processInfo.hThread); return true; } BOOL CtrlHandler(DWORD ctrlType) { if (ctrlType == CTRL_C_EVENT || ctrlType == CTRL_BREAK_EVENT) { endTest = true; while (endTestCompleted == false) { Sleep(100); } } return FALSE; } void ReadNextCommand(int *timeToWaitPtr, list<int> *membersPtr) { *timeToWaitPtr = 0; membersPtr->clear(); char line[1024]; if (fgets(line, 1024, stdin) == NULL) { return; } char *curPos = line, *nextPos; long timeToWait = strtol(curPos, &nextPos, 10); if (nextPos == curPos) { return; } curPos = nextPos; *timeToWaitPtr = (int) timeToWait; for (;;) { long memberId = strtol(curPos, &nextPos, 10); if (nextPos == curPos) { break; } curPos = nextPos; membersPtr->push_back((int) memberId); } } bool SetConfiguration(int configurationNumber, const list<int>& membersInNextConfiguration) { list<int>::const_iterator it; printf("Setting configuration to:\n"); for (it = membersInNextConfiguration.begin(); it != membersInNextConfiguration.end(); ++it) { printf(" %d", *it); } printf("\n"); FILE *fp; if (fopen_s(&fp, "members.txt", "w")) { fprintf(stderr, "Could not open members.txt for writing.\n"); return false; } fprintf(fp, "%d\n%d\n", configurationNumber, (int)membersInNextConfiguration.size()); for (it = membersInNextConfiguration.begin(); it != membersInNextConfiguration.end(); ++it) { fprintf(fp, "%d\n", *it); } fclose(fp); return true; } int GetLastReportedConfigurationNumber () { FILE *fp; if (fopen_s(&fp, "CurrentConfig.txt", "r")) { return 0; } int lastReportedConfigurationNumber = 0; fscanf_s(fp, "%d", &lastReportedConfigurationNumber); fclose(fp); return lastReportedConfigurationNumber; } int __cdecl main(int argc, char **argv) { char * programName = "RSLNetTest.exe"; if (argc == 2) { programName = argv[1]; } if (GetFileAttributesA(programName) == INVALID_FILE_ATTRIBUTES) { printf("Program '%s' not found!\n", programName); ::ExitProcess(1); } if (Logger::Init(".\\") == FALSE) { printf("Logger::Init failed\n"); ::ExitProcess(1); } system("cmd /c rmdir /s /q .\\data"); DeleteFileA("members.txt"); DeleteFileA("CurrentConfig.txt"); Sleep(1000); int currentConfigurationNumber = 0; int timeToWaitForConfigurationChange = 0; list<int> membersInNextConfiguration; printf("Type timeout and replica set:\n"); ReadNextCommand(&timeToWaitForConfigurationChange, &membersInNextConfiguration); currentConfigurationNumber++; SetConfiguration(currentConfigurationNumber, membersInNextConfiguration); HANDLE processHandle[NUM_REPLICAS]; for (int processNumber = 0; processNumber < NUM_REPLICAS; ++processNumber) { if (!StartProcess(programName, processNumber+1, &processHandle[processNumber])) { fprintf(stderr, "ERROR - Could not start process #%d\n", processNumber+1); return -1; } } SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ); endTest = false; endTestCompleted = false; for (; endTest == false; ) { DWORD waitResult = WaitForMultipleObjects(NUM_REPLICAS, processHandle, FALSE, // don't wait for all of them 1000); // time out after 1000 ms if (waitResult < WAIT_OBJECT_0 + NUM_REPLICAS) { int processNumber = waitResult - WAIT_OBJECT_0; printf("Restarting server %d\n", processNumber+1); CloseHandle(processHandle[processNumber]); if (!StartProcess(programName, processNumber+1, &processHandle[processNumber])) { fprintf(stderr, "ERROR - Could not start process #%d\n", processNumber+1); break; } } else if (waitResult == WAIT_TIMEOUT) { --timeToWaitForConfigurationChange; if (timeToWaitForConfigurationChange < 1) { int lastReportedConfig = GetLastReportedConfigurationNumber(); if (currentConfigurationNumber != lastReportedConfig) { fprintf(stderr, "ERROR - Configuration change failed (%d!=%d)!\n", currentConfigurationNumber, lastReportedConfig); break; } else { printf("Configuration number check successful.\n"); } if (membersInNextConfiguration.size() == 0) { break; } ReadNextCommand(&timeToWaitForConfigurationChange, &membersInNextConfiguration); if (membersInNextConfiguration.size() == 0) { break; } currentConfigurationNumber++; if (!SetConfiguration(currentConfigurationNumber, membersInNextConfiguration)) { break; } } } else { printf("WARNING - Unexpected return value %d from WaitForMultipleObjects.\n", waitResult); } } printf("Terminating all processes.\n"); for (int processNumber = 0; processNumber < NUM_REPLICAS; ++processNumber) { TerminateProcess(processHandle[processNumber], 0); CloseHandle(processHandle[processNumber]); } endTestCompleted = true; printf("Test complete.\n"); return 0; }
30.392241
102
0.584598
nkindberg
7ceae8a4f83a95e9ee841983fd42e6251bcedc57
8,606
hpp
C++
include/Mahi/Com/SocketSelector.hpp
chip5441/mahi-com
fc7efcc5d7e9ff995303bbc162e694f25f47d6dd
[ "MIT" ]
1
2021-09-22T08:37:01.000Z
2021-09-22T08:37:01.000Z
include/Mahi/Com/SocketSelector.hpp
chip5441/mahi-com
fc7efcc5d7e9ff995303bbc162e694f25f47d6dd
[ "MIT" ]
1
2020-11-16T04:05:47.000Z
2020-11-16T04:05:47.000Z
include/Mahi/Com/SocketSelector.hpp
chip5441/mahi-com
fc7efcc5d7e9ff995303bbc162e694f25f47d6dd
[ "MIT" ]
2
2020-12-21T09:28:26.000Z
2021-09-17T03:08:19.000Z
// MIT License // // MEL - Mechatronics Engine & Library // Copyright (c) 2019 Mechatronics and Haptic Interfaces Lab - Rice University // // 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. // // This particular source file includes code which has been adapted from the // following open-source projects (all external licenses attached at bottom): // SFML - Simple and Fast Multimedia Library // // Author(s): Evan Pezent (epezent@rice.edu) #pragma once #include <Mahi/Util/Timing/Time.hpp> // #include <Mahi/Util.hpp> namespace mahi { namespace com { class Socket; /// Multiplexer that allows to read from multiple sockets class SocketSelector { public: /// \brief Default constructor SocketSelector(); /// \brief Copy constructor /// /// \param copy Instance to copy SocketSelector(const SocketSelector& copy); /// \brief Destructor ~SocketSelector(); /// \brief Add a new socket to the selector /// /// This function keeps a weak reference to the socket, /// so you have to make sure that the socket is not destroyed /// while it is stored in the selector. /// This function does nothing if the socket is not valid. /// /// \param socket Reference to the socket to add /// /// \see remove, clear void add(Socket& socket); /// \brief Remove a socket from the selector /// /// This function doesn't destroy the socket, it simply /// removes the reference that the selector has to it. /// /// \param socket Reference to the socket to remove /// /// \see add, clear void remove(Socket& socket); /// \brief Remove all the sockets stored in the selector /// /// This function doesn't destroy any instance, it simply /// removes all the references that the selector has to /// external sockets. /// /// \see add, remove void clear(); /// \brief Wait until one or more sockets are ready to receive /// /// This function returns as soon as at least one socket has /// some data available to be received. To know which sockets are /// ready, use the is_ready function. /// If you use a timeout and no socket is ready before the timeout /// is over, the function returns false. /// /// \param timeout Maximum time to wait, (use Time::Zero for infinity) /// /// \return True if there are sockets ready, false otherwise /// /// \see is_ready bool wait(util::Time timeout = util::Time::Zero); /// \brief Test a socket to know if it is ready to receive data /// /// This function must be used after a call to Wait, to know /// which sockets are ready to receive data. If a socket is /// ready, a call to receive will never block because we know /// that there is data available to read. /// Note that if this function returns true for a TcpListener, /// this means that it is ready to accept a new connection. /// /// \param socket Socket to test /// /// \return True if the socket is ready to read, false otherwise /// /// \see is_ready bool is_ready(Socket& socket) const; /// \brief Overload of assignment operator /// /// \param right Instance to assign /// /// \return Reference to self SocketSelector& operator=(const SocketSelector& right); private: struct SocketSelectorImpl; // Member data SocketSelectorImpl* impl_; ///< Opaque pointer to the implementation (which ///< requires OS-specific types) }; } // namespace mahi } // namespace com /// \class mel::SocketSelector /// \ingroup communications /// /// Socket selectors provide a way to wait until some data is /// available on a set of sockets, instead of just one. This /// is convenient when you have multiple sockets that may /// possibly receive data, but you don't know which one will /// be ready first. In particular, it avoids to use a thread /// for each socket; with selectors, a single thread can handle /// all the sockets. /// /// All types of sockets can be used in a selector: /// \li mel::TcpListener /// \li mel::TcpSocket /// \li mel::UdpSocket /// /// A selector doesn't store its own copies of the sockets /// (socket classes are not copyable anyway), it simply keeps /// a reference to the original sockets that you pass to the /// "add" function. Therefore, you can't use the selector as a /// socket container, you must store them outside and make sure /// that they are alive as long as they are used in the selector. /// /// Using a selector is simple: /// \li populate the selector with all the sockets that you want to observe /// \li make it wait until there is data available on any of the sockets /// \li test each socket to find out which ones are ready /// /// Usage example: /// \code /// // Create a socket to listen to new connections /// mel::TcpListener listener; /// listener.listen(55001); /// /// // Create a list to store the future clients /// std::list<mel::TcpSocket*> clients; /// /// // Create a selector /// mel::SocketSelector selector; /// /// // Add the listener to the selector /// selector.add(listener); /// /// // Endless loop that waits for new connections /// while (running) /// { /// // Make the selector wait for data on any socket /// if (selector.wait()) /// { /// // Test the listener /// if (selector.is_ready(listener)) /// { /// // The listener is ready: there is a pending connection /// mel::TcpSocket* client = new mel::TcpSocket; /// if (listener.accept(*client) == mel::Socket::Done) /// { /// // Add the new client to the clients list /// clients.push_back(client); /// /// // Add the new client to the selector so that we will /// // be notified when he sends something /// selector.add(*client); /// } /// else /// { /// // Error, we won't get a new connection, delete the socket /// delete client; /// } /// } /// else /// { /// // The listener socket is not ready, test all other sockets (the /// clients) for (std::list<mel::TcpSocket*>::iterator it = /// clients.begin(); it != clients.end(); ++it) /// { /// mel::TcpSocket& client = **it; /// if (selector.is_ready(client)) /// { /// // The client has sent some data, we can receive it /// mel::Packet packet; /// if (client.receive(packet) == mel::Socket::Done) /// { /// ... /// } /// } /// } /// } /// } /// } /// \endcode /// /// \see mel::Socket /// //============================================================================== // LICENSES //============================================================================== // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007-2017 Laurent Gomila (laurent@melml-dev.org) // // 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.
35.415638
80
0.617128
chip5441
7cf0c63a6872c694335811d2bd24174c58e5614b
415
hpp
C++
tests/thread/tests.hpp
cppfw/nitki
c567c1b60755491bc0c9c53321d175c4df00fc89
[ "MIT" ]
null
null
null
tests/thread/tests.hpp
cppfw/nitki
c567c1b60755491bc0c9c53321d175c4df00fc89
[ "MIT" ]
1
2021-04-09T07:35:37.000Z
2021-04-09T07:35:37.000Z
tests/thread/tests.hpp
cppfw/nitki
c567c1b60755491bc0c9c53321d175c4df00fc89
[ "MIT" ]
1
2020-12-15T01:38:09.000Z
2020-12-15T01:38:09.000Z
#pragma once namespace TestJoinBeforeAndAfterThreadHasFinished{ void Run(); }//~namespace //==================== //Test many threads //==================== namespace TestManyThreads{ void Run(); }//~namespace //========================== //Test immediate thread exit //========================== namespace TestImmediateExitThread{ void Run(); }//~namespace namespace TestNestedJoin{ void Run(); }//~namespace
15.961538
50
0.575904
cppfw
7cf265d3489293daa331751f47b69f65516d8386
698
cpp
C++
Big Number/Division.cpp
MrinmoiHossain/Algorithms
d29a10316219f320b0116ef3b412457a1c1aea26
[ "MIT" ]
2
2017-06-29T14:04:14.000Z
2020-03-21T12:48:21.000Z
Big Number/Division.cpp
MrinmoiHossain/Algorithms
d29a10316219f320b0116ef3b412457a1c1aea26
[ "MIT" ]
null
null
null
Big Number/Division.cpp
MrinmoiHossain/Algorithms
d29a10316219f320b0116ef3b412457a1c1aea26
[ "MIT" ]
2
2020-03-31T15:45:19.000Z
2021-09-15T15:51:06.000Z
#include <bits/stdc++.h> #define LL long long int using namespace std; string division(string a, LL b); int main(void) { int T; cin >> T; for(int i = 1; i <= T; i++){ string a; LL b; cin >> a >> b; cout << division(a, b) << endl; } return 0; } string division(string a, LL b) { string s; LL sum = 0, d; bool flag = 0; for(int i = 0; i < a.length(); i++){ sum = sum * 10 + (a[i] - '0'); d = sum / b; if(d == 0 && !flag) continue; else{ s += (d + '0'); flag = 1; sum = (sum % b); } } if(!flag) s = "0"; return s; }
15.173913
40
0.395415
MrinmoiHossain
7cfb7c135873789f76c032b27d40dd046117f774
1,163
hpp
C++
src/has_cycle.hpp
deepgrace/giant
4070c79892957c8e9244eb7a3d7690a25970f769
[ "BSL-1.0" ]
6
2019-04-02T07:47:37.000Z
2021-05-31T08:01:04.000Z
src/has_cycle.hpp
deepgrace/giant
4070c79892957c8e9244eb7a3d7690a25970f769
[ "BSL-1.0" ]
null
null
null
src/has_cycle.hpp
deepgrace/giant
4070c79892957c8e9244eb7a3d7690a25970f769
[ "BSL-1.0" ]
4
2019-04-15T08:52:17.000Z
2022-03-25T10:29:57.000Z
// // Copyright (c) 2016-present DeepGrace (complex dot invoke at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Official repository: https://github.com/deepgrace/giant // #include <memory> using namespace std; template <typename T> struct node { T data; shared_ptr<node<T>> next; }; template <typename T> shared_ptr<node<T>> has_cycle(const shared_ptr<node<T>>& head) { auto fast = head; auto slow = head; while (fast && fast->next) { slow = slow->next; fast = fast->next->next; if (slow == fast) { int len = 0; do { ++len; fast = fast->next; } while (slow != fast); auto pos = head; while (len--) pos = pos->next; auto start = head; while (start != pos) { pos = pos->next; start = start->next; } return start; } } return nullptr; }
22.365385
90
0.505589
deepgrace
cfb74c5f61e72e167965cd3b6a4877121efebe2c
2,131
cpp
C++
KEditor/Entity/KEEntityNamePool.cpp
King19931229/KApp
f7f855b209348f835de9e5f57844d4fb6491b0a1
[ "MIT" ]
13
2019-10-19T17:41:19.000Z
2021-11-04T18:50:03.000Z
KEditor/Entity/KEEntityNamePool.cpp
King19931229/KApp
f7f855b209348f835de9e5f57844d4fb6491b0a1
[ "MIT" ]
3
2019-12-09T06:22:43.000Z
2020-05-28T09:33:44.000Z
KEditor/Entity/KEEntityNamePool.cpp
King19931229/KApp
f7f855b209348f835de9e5f57844d4fb6491b0a1
[ "MIT" ]
null
null
null
#include "KEEntityNamePool.h" #include "KEditorGlobal.h" KEEntityNamePool::KEEntityNamePool() { } KEEntityNamePool::~KEEntityNamePool() { ASSERT_RESULT(m_Pool.empty()); } bool KEEntityNamePool::Init() { UnInit(); return true; } bool KEEntityNamePool::UnInit() { m_Pool.clear(); return true; } std::string KEEntityNamePool::NamePoolElement::AllocName() { assert(m_FreedName.size() == m_ReservedNameStack.size()); if (!m_ReservedNameStack.empty()) { std::string oldName = m_ReservedNameStack.top(); m_ReservedNameStack.pop(); ASSERT_RESULT(m_FreedName.erase(oldName)); ASSERT_RESULT(m_AllocatedName.insert(oldName).second); return oldName; } else { std::string newName = prefix + "_" + std::to_string(m_NameCounter++); ASSERT_RESULT(m_AllocatedName.insert(newName).second); return newName; } } bool KEEntityNamePool::NamePoolElement::FreeName(const std::string& name) { auto it = m_AllocatedName.find(name); if (it != m_AllocatedName.end()) { bool notInFreeName = m_FreedName.find(name) == m_FreedName.end(); ASSERT_RESULT(notInFreeName); if (notInFreeName) { ASSERT_RESULT(m_FreedName.insert(name).second); m_ReservedNameStack.push(name); assert(m_FreedName.size() == m_ReservedNameStack.size()); } m_AllocatedName.erase(it); return true; } return false; } bool KEEntityNamePool::GetBaseName(const std::string& name, std::string& baseName) { auto pos = name.find_last_of('_'); if (pos == std::string::npos || pos == name.length() - 1) { return false; } baseName = name.substr(0, pos); return true; } void KEEntityNamePool::FreeName(const std::string& name) { std::string baseName; if (GetBaseName(name, baseName)) { auto poolIt = m_Pool.find(baseName); if (poolIt != m_Pool.end()) { NamePoolElement& element = poolIt->second; element.FreeName(name); } } } std::string KEEntityNamePool::AllocName(const std::string& prefix) { auto poolIt = m_Pool.find(prefix); if (poolIt == m_Pool.end()) { poolIt = m_Pool.insert({ prefix, NamePoolElement(prefix) }).first; } NamePoolElement& element = poolIt->second; return element.AllocName(); }
21.525253
82
0.712342
King19931229
cfb7c3be207d4d876b2478472d249000d3e74726
9,931
cpp
C++
jigtest/src/framework/sdlapplicationbase.cpp
Ludophonic/JigLib
541ec63b345ccf01e58cce49eb2f73c21eaf6aa6
[ "Zlib" ]
10
2016-06-01T12:54:45.000Z
2021-09-07T17:34:37.000Z
jigtest/src/framework/sdlapplicationbase.cpp
Ludophonic/JigLib
541ec63b345ccf01e58cce49eb2f73c21eaf6aa6
[ "Zlib" ]
null
null
null
jigtest/src/framework/sdlapplicationbase.cpp
Ludophonic/JigLib
541ec63b345ccf01e58cce49eb2f73c21eaf6aa6
[ "Zlib" ]
4
2017-05-03T14:03:03.000Z
2021-01-04T04:31:15.000Z
//============================================================== // Copyright (C) 2004 Danny Chapman // danny@rowlhouse.freeserve.co.uk //-------------------------------------------------------------- // /// @file SDLApplicationbase.cpp // //============================================================== #include "sdlapplicationbase.hpp" #include "graphics.hpp" #include <stdio.h> using namespace std; using namespace JigLib; void tSDLApplicationBase::LoadConfig(int & argc, char * argv[], string configFileName) { // setup config/tracing bool configFileOk; if (argc > 1) configFileName = string(argv[1]); mConfigFile = new tConfigFile(configFileName, configFileOk); if (!configFileOk) TRACE("Warning: Unable to open main config file: %s\n", configFileName.c_str()); // initialise trace // set up tracing properly bool traceEnabled = true; int traceLevel = 3; bool traceAllStrings = true; vector<string> traceStrings; mConfigFile->GetValue("trace_enabled", traceEnabled); mConfigFile->GetValue("trace_level", traceLevel); mConfigFile->GetValue("trace_all_strings", traceAllStrings); mConfigFile->GetValues("trace_strings", traceStrings); EnableTrace(traceEnabled); SetTraceLevel(traceLevel); EnableTraceAllStrings(traceAllStrings); AddTraceStrings(traceStrings); TRACE_FILE_IF(ONCE_1) TRACE("Logging set up\n"); } //============================================================== // tSDLApplicationBase //============================================================== tSDLApplicationBase::tSDLApplicationBase(int & argc, char * argv[], string configFileName, void (* licenseFn)(void)) { TRACE_METHOD_ONLY(ONCE_1); LoadConfig(argc, argv, configFileName); if (licenseFn) (*licenseFn)(); else DisplayLicense(); } //============================================================== // ~tSDLApplicationBase //============================================================== tSDLApplicationBase::~tSDLApplicationBase() { TRACE_METHOD_ONLY(ONCE_1); } //============================================================== // Initialise //============================================================== bool tSDLApplicationBase::Initialise(const std::string app_name) { TRACE_METHOD_ONLY(ONCE_1); // intialise some vars mStartOfFrameTime = tTime(0.0f); mOldStartOfFrameTime = tTime(0.0f); mFPSInterval = tTime(1.0f); mLastStoredTime = tTime(0.0f); mFPSCounter = 0; mFPS = 1.0f; mNewFPS = true; TRACE_FILE_IF(ONCE_2) TRACE("Initializing SDL.\n"); if((SDL_Init(SDL_INIT_VIDEO)==-1)) { TRACE("Could not initialize SDL: %s.\n", SDL_GetError()); return false; } /* Clean up on exit */ atexit(SDL_Quit); TRACE_FILE_IF(ONCE_2) TRACE("SDL initialized.\n"); // Information about the current video settings. const SDL_VideoInfo* info = NULL; // get some video information. info = SDL_GetVideoInfo( ); if( !info ) { TRACE("Video query failed: %s\n", SDL_GetError( ) ); return false; } mWindowWidth = 800; mWindowHeight = 600; mConfigFile->GetValue("window_width", mWindowWidth); mConfigFile->GetValue("window_height", mWindowHeight); int bpp = info->vfmt->BitsPerPixel; SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); bool fullscreen = false; mConfigFile->GetValue("fullscreen", fullscreen); // don't allow resizing for now - textures etc get zapped int flags = SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0); SDL_Surface *screen = SDL_SetVideoMode( mWindowWidth, mWindowHeight, bpp, flags ); if( screen == 0 ) { TRACE("Video mode set failed: %s\n", SDL_GetError( ) ); return false; } return true; } //============================================================== // GetTimeNow //============================================================== tTime tSDLApplicationBase::GetTimeNow() const { Uint32 millisec = SDL_GetTicks(); return millisec * 0.001f; } //============================================================== // InternalHandleStartOfLoop //============================================================== void tSDLApplicationBase::InternalHandleStartOfLoop() { mOldStartOfFrameTime = mStartOfFrameTime; mStartOfFrameTime = GetTimeNow(); if ( (mStartOfFrameTime > 0.0f) && (mStartOfFrameTime < mFPSInterval) ) { mFPS = mFPSCounter / mStartOfFrameTime; } if (mStartOfFrameTime - mLastStoredTime >= mFPSInterval) { mFPS = (tScalar) mFPSCounter; mLastStoredTime = mStartOfFrameTime; mFPSCounter = 0; mNewFPS = true; } else { ++mFPSCounter; mNewFPS = false; } } //============================================================== // StartMainLoop //============================================================== void tSDLApplicationBase::StartMainLoop() { mExitMainLoop = false; while( false == mExitMainLoop ) { InternalHandleStartOfLoop(); // do all the basic stuff like keyboard, mouse etc, callint the // app. ProcessEvents(); // get the app to do it's own stuff - e.g. physics, rendering ProcessMainEvent(); } } //============================================================== // InternalHandleResize //============================================================== void tSDLApplicationBase::InternalHandleResize(const SDL_ResizeEvent & event) { bool fullscreen = false; mConfigFile->GetValue("fullscreen", fullscreen); mWindowWidth = event.w; mWindowHeight = event.h; const SDL_VideoInfo* info = SDL_GetVideoInfo( ); if( !info ) { TRACE("Video query failed: %s\n", SDL_GetError( ) ); return; } int bpp = info->vfmt->BitsPerPixel; int flags = SDL_RESIZABLE | SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0); SDL_Surface *screen = SDL_SetVideoMode( mWindowWidth, mWindowHeight, bpp, flags ); if( screen == 0 ) { TRACE("Video mode set failed: %s\n", SDL_GetError( ) ); } } //============================================================== // ProcessEvents //============================================================== void tSDLApplicationBase::ProcessEvents() { SDL_Event event; while( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_KEYDOWN: HandleKeyDown( event.key.keysym ); break; case SDL_KEYUP: HandleKeyUp( event.key.keysym ); break; case SDL_MOUSEMOTION: HandleMouseMotion( event.motion ); break; case SDL_MOUSEBUTTONDOWN: HandleMouseButtonDown( event.button ); break; case SDL_MOUSEBUTTONUP: HandleMouseButtonUp( event.button ); break; case SDL_VIDEORESIZE: InternalHandleResize( event.resize ); break; case SDL_QUIT: /* Handle quit requests (like Ctrl-c). */ exit(0); break; } } } //============================================================== // HandleReShape //============================================================== void tSDLApplicationBase::HandleReShape(int newWidth, int newHeight) { } //============================================================== // DisplayLicense //============================================================== void tSDLApplicationBase::DisplayLicense() { TRACE("Application Copyright 2004 Danny Chapman: danny@rowlhouse.freeserve.co.uk\n"); TRACE("Application comes with ABSOLUTELY NO WARRANTY;\n"); TRACE("This is free software, and you are welcome to redistribute it\n"); TRACE("under certain conditions; see the GNU General Public License\n"); } //=========================================================== // Code to write out screen shots //========================================================== static void FlipVertical(unsigned char *data, int w, int h) { int x, y, i1, i2; unsigned char temp; for (x=0;x<w;x++){ for (y=0;y<h/2;y++){ i1 = (y*w + x)*3; // this pixel i2 = ((h - y - 1)*w + x)*3; // its opposite (across x-axis) // swap pixels temp = data[i1]; data[i1] = data[i2]; data[i2] = temp; i1++; i2++; temp = data[i1]; data[i1] = data[i2]; data[i2] = temp; i1++; i2++; temp = data[i1]; data[i1] = data[i2]; data[i2] = temp; } } } //============================================================== // writeFrameBuffer //============================================================== static void WriteFrameBuffer(char *filename) { FILE *fp = fopen(filename, "wb"); int width, height; GetWindowSize(width, height); int data_size = width * height * 3; unsigned char *framebuffer = (unsigned char *) malloc(data_size * sizeof(unsigned char)); glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, framebuffer); FlipVertical(framebuffer, width, height); fprintf(fp, "P6\n%d %d\n%d\n", width, height, 255); fwrite(framebuffer, data_size, 1, fp); fclose(fp); free(framebuffer); } //============================================================== // DoScreenshot //============================================================== void tSDLApplicationBase::DoScreenshot() { static int count = 0; static char screen_file[] = "screenshot-00000.ppm"; sprintf(screen_file, "screenshot-%05d.ppm", count++); // printf("%s\n", movie_file); WriteFrameBuffer(screen_file); }
28.133144
87
0.518578
Ludophonic
cfb7f0230a3dad9f838546d1c0b8a0a0989955ba
17,656
cpp
C++
Source/System/[Platforms]/Windows/Interface.Windows.cpp
jbatonnet/System
227cf491ab5d0660a6bcf654f6cad09d1f82ba8e
[ "MIT" ]
3
2020-04-24T20:23:24.000Z
2022-01-06T22:27:01.000Z
Source/System/[Platforms]/Windows/Interface.Windows.cpp
jbatonnet/system
227cf491ab5d0660a6bcf654f6cad09d1f82ba8e
[ "MIT" ]
null
null
null
Source/System/[Platforms]/Windows/Interface.Windows.cpp
jbatonnet/system
227cf491ab5d0660a6bcf654f6cad09d1f82ba8e
[ "MIT" ]
1
2021-06-25T17:35:08.000Z
2021-06-25T17:35:08.000Z
#ifdef WINDOWS #include <System/System.h> using namespace System; using namespace System::Runtime; using namespace System::Objects; using namespace System::Devices; using namespace System::IO; using namespace System::Interface; using namespace System::Graphics; #undef using #define _INITIALIZER_LIST_ #include <Windows.h> #include <Dwmapi.h> #include <cstdlib> #include <vector> #include <queue> #include <algorithm> #define MAX_WINDOWS_COUNT 32 using namespace std; struct WindowInfo { Window* Window; Surface* Surface; HWND Hwnd; }; struct PendingWindowInfo { Window* Window; }; vector<WindowInfo> windowInfos; queue<PendingWindowInfo> pendingWindowInfos; Buttons virtualKeyMapping[0x100] = { (Buttons)0x00, (Buttons)0x01, (Buttons)0x02, (Buttons)0x03, (Buttons)0x04, (Buttons)0x05, (Buttons)0x06, (Buttons)0x07, Buttons::Backspace, Buttons::Tab, (Buttons)0x0A, (Buttons)0x0B, (Buttons)0x0C, Buttons::Enter, (Buttons)0x0E, (Buttons)0x0F, Buttons::Shift, Buttons::Control, Buttons::Alt, (Buttons)0x13, Buttons::CapsLock, (Buttons)0x15, (Buttons)0x16, (Buttons)0x17, (Buttons)0x18, (Buttons)0x19, (Buttons)0x1A, Buttons::Escape, (Buttons)0x1C, (Buttons)0x1D, (Buttons)0x1E, (Buttons)0x1F, Buttons::Space, Buttons::PageUp, Buttons::PageDown, Buttons::End, Buttons::Origin, Buttons::Left, Buttons::Up, Buttons::Right, Buttons::Down, (Buttons)0x29, (Buttons)0x2A, (Buttons)0x2B, (Buttons)0x2C, Buttons::Insert, Buttons::Delete, (Buttons)0x2F, Buttons::Digit0, Buttons::Digit1, Buttons::Digit2, Buttons::Digit3, Buttons::Digit4, Buttons::Digit5, Buttons::Digit6, Buttons::Digit7, Buttons::Digit8, Buttons::Digit9, (Buttons)0x3A, (Buttons)0x3B, (Buttons)0x3C, (Buttons)0x3D, (Buttons)0x3E, (Buttons)0x3F, (Buttons)0x40, Buttons::A, Buttons::B, Buttons::C, Buttons::D, Buttons::E, Buttons::F, Buttons::G, Buttons::H, Buttons::I, Buttons::J, Buttons::K, Buttons::L, Buttons::M, Buttons::N, Buttons::O, Buttons::P, Buttons::Q, Buttons::R, Buttons::S, Buttons::T, Buttons::U, Buttons::V, Buttons::W, Buttons::X, Buttons::Y, Buttons::Z, (Buttons)0x5B, (Buttons)0x5C, (Buttons)0x5D, (Buttons)0x5E, (Buttons)0x5F, (Buttons)0x60, (Buttons)0x61, (Buttons)0x62, (Buttons)0x63, (Buttons)0x64, (Buttons)0x65, (Buttons)0x66, (Buttons)0x67, (Buttons)0x68, (Buttons)0x69, (Buttons)0x6A, (Buttons)0x6B, (Buttons)0x6C, (Buttons)0x6D, (Buttons)0x6E, (Buttons)0x6F, Buttons::F1, Buttons::F2, Buttons::F3, Buttons::F4, Buttons::F5, Buttons::F6, Buttons::F7, Buttons::F8, Buttons::F9, Buttons::F10, Buttons::F11, Buttons::F12, (Buttons)0x7C, (Buttons)0x7D, (Buttons)0x7E, (Buttons)0x7F, (Buttons)0x80, (Buttons)0x81, (Buttons)0x82, (Buttons)0x83, (Buttons)0x84, (Buttons)0x85, (Buttons)0x86, (Buttons)0x87, (Buttons)0x88, (Buttons)0x89, (Buttons)0x8A, (Buttons)0x8B, (Buttons)0x8C, (Buttons)0x8D, (Buttons)0x8E, (Buttons)0x8F, Buttons::NumLock, (Buttons)0x91, (Buttons)0x92, (Buttons)0x93, (Buttons)0x94, (Buttons)0x95, (Buttons)0x96, (Buttons)0x97, (Buttons)0x98, (Buttons)0x99, (Buttons)0x9A, (Buttons)0x9B, (Buttons)0x9C, (Buttons)0x9D, (Buttons)0x9E, (Buttons)0x9F, Buttons::LeftShift, Buttons::RightShift, Buttons::LeftControl, Buttons::RightControl, (Buttons)0xA4, (Buttons)0xA5, (Buttons)0xA6, (Buttons)0xA7, (Buttons)0xA8, (Buttons)0xA9, (Buttons)0xAA, (Buttons)0xAB, (Buttons)0xAC, (Buttons)0xAD, (Buttons)0xAE, (Buttons)0xAF, (Buttons)0xB0, (Buttons)0xB1, (Buttons)0xB2, (Buttons)0xB3, (Buttons)0xB4, (Buttons)0xB5, (Buttons)0xB6, (Buttons)0xB7, (Buttons)0xB8, (Buttons)0xB9, (Buttons)0xBA, (Buttons)0xBB, (Buttons)0xBC, (Buttons)0xBD, (Buttons)0xBE, (Buttons)0xBF, (Buttons)0xC0, (Buttons)0xC1, (Buttons)0xC2, (Buttons)0xC3, (Buttons)0xC4, (Buttons)0xC5, (Buttons)0xC6, (Buttons)0xC7, (Buttons)0xC8, (Buttons)0xC9, (Buttons)0xCA, (Buttons)0xCB, (Buttons)0xCC, (Buttons)0xCD, (Buttons)0xCE, (Buttons)0xCF, (Buttons)0xD0, (Buttons)0xD1, (Buttons)0xD2, (Buttons)0xD3, (Buttons)0xD4, (Buttons)0xD5, (Buttons)0xD6, (Buttons)0xD7, (Buttons)0xD8, (Buttons)0xD9, (Buttons)0xDA, (Buttons)0xDB, (Buttons)0xDC, (Buttons)0xDD, (Buttons)0xDE, (Buttons)0xDF, (Buttons)0xE0, (Buttons)0xE1, (Buttons)0xE2, (Buttons)0xE3, (Buttons)0xE4, (Buttons)0xE5, (Buttons)0xE6, (Buttons)0xE7, (Buttons)0xE8, (Buttons)0xE9, (Buttons)0xEA, (Buttons)0xEB, (Buttons)0xEC, (Buttons)0xED, (Buttons)0xEE, (Buttons)0xEF, (Buttons)0xF0, (Buttons)0xF1, (Buttons)0xF2, (Buttons)0xF3, (Buttons)0xF4, (Buttons)0xF5, (Buttons)0xF6, (Buttons)0xF7, (Buttons)0xF8, (Buttons)0xF9, (Buttons)0xFA, (Buttons)0xFB, (Buttons)0xFC, (Buttons)0xFD, (Buttons)0xFE, (Buttons)0xFF }; WNDCLASSEX windowClass; POINT clientOffset, nonClientSize; #define DOUBLE_BUFFER 0 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { auto result = find_if(windowInfos.begin(), windowInfos.end(), [=](WindowInfo w) { return w.Hwnd == hwnd; }); if (result == windowInfos.end()) return DefWindowProc(hwnd, msg, wParam, lParam); WindowInfo& windowInfo = *result; Window* window = windowInfo.Window; Surface* surface = windowInfo.Surface; int captionHeight = 23; switch (msg) { #pragma region Mouse case WM_MOUSEMOVE: { PointerPositionEvent pointerPositionEvent; pointerPositionEvent.Index = 0; pointerPositionEvent.X = LOWORD(lParam); pointerPositionEvent.Y = HIWORD(lParam); window->OnPointerMove(window, pointerPositionEvent); break; } case WM_RBUTTONDOWN: { SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, NULL); break; } case WM_LBUTTONDOWN: { PointerEvent pointerEvent; pointerEvent.Index = 0; window->OnPointerDown(window, pointerEvent); break; } case WM_RBUTTONUP: { break; } case WM_LBUTTONUP: { PointerEvent pointerEvent; pointerEvent.Index = 0; window->OnPointerUp(window, pointerEvent); break; } case WM_MOUSELEAVE: { break; } case WM_MOUSEWHEEL: { PointerScrollEvent pointerScrollEvent; pointerScrollEvent.Index = 0; pointerScrollEvent.Delta = -GET_WHEEL_DELTA_WPARAM(wParam) / 120; window->OnPointerScroll(window, pointerScrollEvent); break; } #pragma endregion #pragma region Keyboard case WM_CHAR: { if (wParam < 32) break; ButtonEvent buttonEvent; buttonEvent.Button = Buttons::Unknown; buttonEvent.Character = (char)wParam; bool pressed = !(lParam >> 31); if (pressed) window->OnButtonDown(window, buttonEvent); else window->OnButtonUp(window, buttonEvent); return 0; } case WM_KEYDOWN: { Buttons button = virtualKeyMapping[wParam]; if ((WPARAM)button == wParam) break; u32 character = MapVirtualKey(wParam, MAPVK_VK_TO_CHAR); if (!character || character < 32) { ButtonEvent buttonEvent; buttonEvent.Button = button; buttonEvent.Character = 0; window->OnButtonDown(window, buttonEvent); } return 0; } case WM_KEYUP: { Buttons button = virtualKeyMapping[wParam]; if ((WPARAM)button == wParam) break; ButtonEvent buttonEvent; buttonEvent.Button = button; buttonEvent.Character = 'a'; window->OnButtonUp(window, buttonEvent); return 0; } case WM_SYSKEYDOWN: { Buttons button = virtualKeyMapping[wParam]; if ((WPARAM)button == wParam) break; ButtonEvent buttonEvent; buttonEvent.Button = button; buttonEvent.Character = 0; window->OnButtonDown(window, buttonEvent); return 0; } case WM_SYSKEYUP: { Buttons button = virtualKeyMapping[wParam]; if ((WPARAM)button == wParam) break; ButtonEvent buttonEvent; buttonEvent.Button = button; buttonEvent.Character = 0; window->OnButtonUp(window, buttonEvent); return 0; } #pragma endregion #pragma region Window case WM_CREATE: { RECT rect; rect.left = window->Position.X; rect.top = window->Position.Y; rect.right = window->Position.X + window->Size.X; rect.bottom = window->Position.Y + window->Size.Y; AdjustWindowRect(&rect, WS_POPUP, false); SetWindowPos(hwnd, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOREPOSITION | SWP_NOMOVE); BufferedPaintInit(); break; } case WM_CLOSE: { DestroyWindow(hwnd); break; } case WM_DESTROY: { PostQuitMessage(0); exit(0); // FIXME break; } case WM_SIZE: { s16 width = LOWORD(lParam); s16 height = HIWORD(lParam); window->Size = Point2(width, height); delete surface; windowInfo.Surface = new Surface(window->Size.X, window->Size.Y); InvalidateRect(hwnd, NULL, false); UpdateWindow(hwnd); break; } #pragma endregion #pragma region Non-client case WM_NCPAINT: { //DWMNCRENDERINGPOLICY policy = DWMNCRP_ENABLED; //DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, (void*)&policy, sizeof(DWMNCRENDERINGPOLICY)); MARGINS margins = { 1, 1, 1, 1 }; DwmExtendFrameIntoClientArea(hwnd, &margins); return DefWindowProc(hwnd, msg, wParam, lParam); } case WM_NCCALCSIZE: break; #pragma endregion case WM_ERASEBKGND: return 1; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc, hdcBuffer; HGDIOBJ oldBitmap; BITMAP bitmap; HBITMAP hBitmap; HPAINTBUFFER hPaintBuffer; window->Redraw(surface, System::Graphics::Rectangle(Point2::Zero, window->Size)); #if DOUBLE_BUFFER hdc = GetWindowDC(hwnd); #else hdc = BeginPaint(hwnd, &ps); hdcBuffer = CreateCompatibleDC(hdc); #endif RECT rect; GetClientRect(hwnd, &rect); #if DOUBLE_BUFFER hPaintBuffer = BeginBufferedPaint(hdc, &rect, BPBF_COMPATIBLEBITMAP, NULL, &hdcBuffer); BufferedPaintMakeOpaque(hPaintBuffer, NULL); #endif hBitmap = CreateBitmap(window->Size.X, window->Size.Y, 1, 32, surface->Data); oldBitmap = SelectObject(hdcBuffer, hBitmap); GetObject(hBitmap, sizeof(bitmap), &bitmap); BitBlt(hdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdcBuffer, 0, 0, SRCCOPY); SelectObject(hdcBuffer, oldBitmap); DeleteObject(hBitmap); #if DOUBLE_BUFFER BufferedPaintMakeOpaque(hPaintBuffer, NULL); EndBufferedPaint(hPaintBuffer, TRUE); ReleaseDC(hwnd, hdc); #else EndPaint(hwnd, &ps); #endif break; } default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } HWND GetHwndByWindow(Window* window) { auto result = find_if(windowInfos.begin(), windowInfos.end(), [=](WindowInfo w) { return w.Window == window; }); if (result == windowInfos.end()) return NULL; return result->Hwnd; } void Window_PositionChanged(void* origin, ChangeEventParameter<Point> args) { HWND hwnd = GetHwndByWindow((Window*)origin); SetWindowPos(hwnd, NULL, args.NewValue.X, args.NewValue.Y, 0, 0, SWP_NOREPOSITION | SWP_NOSIZE); } void Window_SizeChanged(void* origin, ChangeEventParameter<Point> args) { HWND hwnd = GetHwndByWindow((Window*)origin); SetWindowPos(hwnd, NULL, 0, 0, args.NewValue.X, args.NewValue.Y, SWP_NOREPOSITION | SWP_NOMOVE); } void Window_Refreshed(void* origin, System::Graphics::Rectangle rectangle) { Window* window = (Window*)origin; HWND hwnd = GetHwndByWindow(window); RECT rect = { 0 }; /*rect.left = rectangle.Position.X; rect.top = rectangle.Position.Y; rect.right = rectangle.Position.X + rectangle.Size.X; rect.bottom = rectangle.Position.Y + rectangle.Size.Y;*/ rect.left = 0; rect.top = 0; rect.right = window->Size.X; rect.bottom = window->Size.Y; InvalidateRect(hwnd, &rect, true); } DWORD WINAPI WindowsManager_Loop(LPVOID parameter) { MSG msg; for (;;) { // Handle window creation requests while (!pendingWindowInfos.empty()) { PendingWindowInfo pendingWindow = pendingWindowInfos.front(); pendingWindowInfos.pop(); // Create the Window Window* window = pendingWindow.Window; HWND hwnd = CreateWindow("myWindowClass", "", WS_OVERLAPPEDWINDOW, window->Position.X, window->Position.Y, window->Size.X, window->Size.Y, NULL, NULL, NULL, NULL); Surface* surface = new Surface(window->Size.X, window->Size.Y); // Register to window events window->PositionChanged += Window_PositionChanged; window->SizeChanged += Window_SizeChanged; window->Refreshed += Window_Refreshed; //window->Initialize(); // Adjust the newly created window /*RECT rect; rect.left = window->Position.X; rect.top = window->Position.Y; rect.right = window->Position.X + window->Size.X; rect.bottom = window->Position.Y + window->Size.Y; AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, false);*/ // Register the new window WindowInfo windowInfo; windowInfo.Window = window; windowInfo.Surface = surface; windowInfo.Hwnd = hwnd; windowInfos.push_back(windowInfo); // Show window SetWindowPos(hwnd, NULL, 0, 0, window->Size.X + nonClientSize.x, window->Size.Y + nonClientSize.y, SWP_NOREPOSITION | SWP_NOMOVE); ShowWindow(hwnd, SW_SHOW); // Force first draw InvalidateRect(hwnd, NULL, true); UpdateWindow(hwnd); } // Handle messages if (!windowInfos.empty()) { for (int i = 0; i < 1024; i++) { if (GetMessage(&msg, NULL, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } } } } return 0; } void WindowsManager::Initialize() { // Compute non client sizes RECT rect; rect.left = 0; rect.top = 0; rect.right = 0; rect.bottom = 0; AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, false); clientOffset.x = -rect.left; clientOffset.y = -rect.top; nonClientSize.x = rect.right - rect.left; nonClientSize.y = rect.bottom - rect.top; // Register a new window class windowClass.cbSize = sizeof(WNDCLASSEX); windowClass.style = 0; windowClass.lpfnWndProc = WndProc; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); windowClass.hbrBackground = NULL; // (HBRUSH)(COLOR_WINDOW + 1); windowClass.lpszMenuName = NULL; windowClass.lpszClassName = "myWindowClass"; windowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if (!RegisterClassEx(&windowClass)) Exception::Assert("Could not register window class"); // Start the window loop thread DWORD threadId; HANDLE threadHandle = CreateThread(NULL, 0, WindowsManager_Loop, NULL, 0, &threadId); } void WindowsManager::Add(Window* window) { int index = 0; // Check for existing window if (find_if(windowInfos.begin(), windowInfos.end(), [=](WindowInfo w) { return w.Window == window; }) != windowInfos.end()) return; // Push a new window creation request PendingWindowInfo pendingWindow; pendingWindow.Window = window; pendingWindowInfos.push(pendingWindow); // Wait for window creation for (;;) { Sleep(20); auto result = find_if(windowInfos.begin(), windowInfos.end(), [=](WindowInfo w) { return w.Window == window; }); if (result != windowInfos.end()) return; } } void WindowsManager::Remove(Window* window) { HWND hwnd = GetHwndByWindow(window); DestroyWindow(hwnd); window->Closed(window, null); } void Mover::OnPointerMove(void* origin, PointerPositionEvent pointerPositionEvent) { } void Mover::OnPointerIn(void* origin, PointerEvent pointerEvent) { } void Mover::OnPointerOut(void* origin, PointerEvent pointerEvent) { } void Mover::OnPointerDown(void* origin, PointerEvent pointerEvent) { HWND hwnd = GetHwndByWindow(window); SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, NULL); } void Mover::OnPointerUp(void* origin, PointerEvent pointerEvent) { } #endif
33.06367
269
0.617864
jbatonnet
cfbaa3403fe6083a83b359001d88539239ef0d88
769
cpp
C++
WumbukDraw/line.cpp
YangPeihao1203/WumbukDraw
e0854e62cc050c99deda04a849d46824f458cbbc
[ "MIT" ]
null
null
null
WumbukDraw/line.cpp
YangPeihao1203/WumbukDraw
e0854e62cc050c99deda04a849d46824f458cbbc
[ "MIT" ]
null
null
null
WumbukDraw/line.cpp
YangPeihao1203/WumbukDraw
e0854e62cc050c99deda04a849d46824f458cbbc
[ "MIT" ]
null
null
null
#include "line.h" Line::Line() { setAdjustFlag(false); } void Line::startDraw(QGraphicsSceneMouseEvent * event) { QPen pen = this->pen(); pen.setWidth(this->width); pen.setColor(this->color); setPen(pen); startPos=event->scenePos(); } void Line::drawing(QGraphicsSceneMouseEvent * event) { EndPos=event->scenePos(); QLineF newLine(startPos,EndPos); setLine(newLine); } void Line::endDraw(QGraphicsSceneMouseEvent *event) { } bool Line::CheckIsContainsPoint(QPointF p) { return shape().contains(p); } void Line::setAdjustFlag(bool val) { setFlag(QGraphicsItem::ItemIsMovable, val); setFlag(QGraphicsItem::ItemIsSelectable, val); setFlag(QGraphicsItem::ItemIsFocusable, val); }
18.756098
55
0.6671
YangPeihao1203
cfbc414efa03b4d00846bddacc360efa3e6b71df
16,075
cpp
C++
diffsim_torch3d/arcsim/src/simulation.cpp
priyasundaresan/kaolin
ddae34ba5f09bffc4368c29bc50491c5ece797d4
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
diffsim_torch3d/arcsim/src/simulation.cpp
priyasundaresan/kaolin
ddae34ba5f09bffc4368c29bc50491c5ece797d4
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
diffsim_torch3d/arcsim/src/simulation.cpp
priyasundaresan/kaolin
ddae34ba5f09bffc4368c29bc50491c5ece797d4
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
/* Copyright ©2013 The Regents of the University of California (Regents). All Rights Reserved. Permission to use, copy, modify, and distribute this software and its documentation for educational, research, and not-for-profit purposes, without fee and without a signed licensing agreement, is hereby granted, provided that the above copyright notice, this paragraph and the following two paragraphs appear in all copies, modifications, and distributions. Contact The Office of Technology Licensing, UC Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620, (510) 643-7201, for commercial licensing opportunities. IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ #include "simulation.hpp" #include "collision.hpp" #include "dynamicremesh.hpp" #include "geometry.hpp" #include "magic.hpp" #include "nearobs.hpp" #include "physics.hpp" #include "plasticity.hpp" #include "popfilter.hpp" #include "proximity.hpp" #include "separate.hpp" #include "obstacle.hpp" #include <iostream> #include <fstream> using namespace std; using torch::Tensor; static const bool verbose = false; static const int proximity = Simulation::Proximity, physics = Simulation::Physics, strainlimiting = Simulation::StrainLimiting, collision = Simulation::Collision, remeshing = Simulation::Remeshing, separation = Simulation::Separation, popfilter = Simulation::PopFilter, plasticity = Simulation::Plasticity; void physics_step (Simulation &sim, const vector<Constraint*> &cons); void plasticity_step (Simulation &sim); void strainlimiting_step (Simulation &sim, const vector<Constraint*> &cons); void strainzeroing_step (Simulation &sim); void equilibration_step (Simulation &sim); void collision_step (Simulation &sim); void remeshing_step (Simulation &sim, bool initializing=false); void validate_handles (const Simulation &sim); void prepare (Simulation &sim) { sim.step = 0; sim.frame = 0; sim.cloth_meshes.resize(sim.cloths.size()); for (int c = 0; c < sim.cloths.size(); c++) { compute_masses(sim.cloths[c]); sim.cloth_meshes[c] = &sim.cloths[c].mesh; update_x0(*sim.cloth_meshes[c]); } sim.obstacle_meshes.resize(sim.obstacles.size()); for (int o = 0; o < sim.obstacles.size(); o++) { obs_compute_masses(sim.obstacles[o]); sim.obstacle_meshes[o] = &sim.obstacles[o].get_mesh(); update_x0(*sim.obstacle_meshes[o]); } } void relax_initial_state (Simulation &sim) { validate_handles(sim); return; if (::magic.preserve_creases) for (int c = 0; c < sim.cloths.size(); c++) reset_plasticity(sim.cloths[c]); bool equilibrate = true; if (equilibrate) { equilibration_step(sim); remeshing_step(sim, true); equilibration_step(sim); } else { remeshing_step(sim, true); strainzeroing_step(sim); remeshing_step(sim, true); strainzeroing_step(sim); } if (::magic.preserve_creases) for (int c = 0; c < sim.cloths.size(); c++) reset_plasticity(sim.cloths[c]); ::magic.preserve_creases = false; if (::magic.fixed_high_res_mesh) sim.enabled[remeshing] = false; } void validate_handles (const Simulation &sim) { for (int h = 0; h < sim.handles.size(); h++) { vector<Node*> nodes = sim.handles[h]->get_nodes(); for (int n = 0; n < nodes.size(); n++) { if (!nodes[n]->preserve) { cout << "Constrained node " << nodes[n]->index << " will not be preserved by remeshing" << endl; abort(); } } } } vector<Constraint*> get_constraints (Simulation &sim, bool include_proximity); void delete_constraints (const vector<Constraint*> &cons); void update_obstacles (Simulation &sim, bool update_positions=true); void advance_step (Simulation &sim); void advance_frame (Simulation &sim) { for (int s = 0; s < sim.frame_steps; s++) advance_step(sim); } void advance_step (Simulation &sim) { Timer ti; ti.tick(); sim.time = sim.time + sim.step_time; sim.step++; // cout << "\t\tstep=" << sim.step << endl; update_obstacles(sim, false); vector<Constraint*> cons = get_constraints(sim, true); physics_step(sim, cons); //plasticity_step(sim); //strainlimiting_step(sim, cons); collision_step(sim); if (sim.step % sim.frame_steps == 0) { remeshing_step(sim); sim.frame++; // cout << "\t\t\tframe="<<sim.frame<<endl; } delete_constraints(cons); ti.tock(); // cout << "\t\ttime= "<< ti.last << endl; } vector<Constraint*> get_constraints (Simulation &sim, bool include_proximity) { // cout << "get_constraints" << endl; vector<Constraint*> cons; for (int h = 0; h < sim.handles.size(); h++) append(cons, sim.handles[h]->get_constraints(sim.time)); // PRIYA if (include_proximity && sim.enabled[proximity]) { sim.timers[proximity].tick(); append(cons, proximity_constraints(sim.cloth_meshes, sim.obstacle_meshes, sim.friction, sim.obs_friction)); sim.timers[proximity].tock(); } return cons; } void delete_constraints (const vector<Constraint*> &cons) { for (int c = 0; c < cons.size(); c++) delete cons[c]; } // Steps void update_velocities (vector<Mesh*> &meshes, vector<Tensor> &xold, Tensor dt); void step_mesh (Mesh &mesh, Tensor dt); void step_obstacle (Obstacle &obstacle, Tensor dt); void physics_step (Simulation &sim, const vector<Constraint*> &cons) { // cout << "physics_step" << endl; if (!sim.enabled[physics]) return; sim.timers[physics].tick(); for (int c = 0; c < sim.cloths.size(); c++) { int nn = sim.cloths[c].mesh.nodes.size(); Tensor fext = torch::zeros({nn,3}, TNOPT)*0; Tensor Jext = torch::zeros({nn,3,3}, TNOPT); add_external_forces(sim.cloths[c], sim.gravity, sim.wind, fext, Jext); for (int m = 0; m < sim.morphs.size(); m++) if (sim.morphs[m].mesh == &sim.cloths[c].mesh) add_morph_forces(sim.cloths[c], sim.morphs[m], sim.time, sim.step_time, fext, Jext); implicit_update(sim.cloths[c], fext, Jext, cons, sim.step_time, false); } for (int o = 0; o < sim.obstacles.size(); o++) { int nn = 2; Tensor fext = torch::zeros({nn,3}, TNOPT); Tensor Jext = torch::zeros({nn,3,3}, TNOPT); // just for test obs_add_external_forces(sim.obstacles[o], sim.gravity, sim.wind, fext, Jext); //fext = fext; //cout << "obs fext = " << fext << endl; obs_implicit_update(sim.obstacles[o], sim.obstacle_meshes, fext, Jext, cons, sim.step_time, false); } for (int c = 0; c < sim.cloth_meshes.size(); c++) step_mesh(*sim.cloth_meshes[c], sim.step_time); //for (int o = 0; o < sim.obstacle_meshes.size(); o++) // step_mesh(*sim.obstacle_meshes[o], sim.step_time); for (int o = 0; o < sim.obstacles.size(); o++) step_obstacle(sim.obstacles[o], sim.step_time); sim.timers[physics].tock(); } void step_mesh (Mesh &mesh, Tensor dt) { for (int n = 0; n < mesh.nodes.size(); n++) { mesh.nodes[n]->x = mesh.nodes[n]->x + mesh.nodes[n]->v*dt; mesh.nodes[n]->xold = mesh.nodes[n]->x; } } // void apply_transformation (Mesh& mesh, const Transformation& tr) { // apply_transformation_onto(mesh, mesh, tr); //} void step_obstacle (Obstacle &obstacle, Tensor dt) { Node *dummy_node = obstacle.curr_state_mesh.dummy_node; //cout << "velocity -------------" << endl; ////cout << dummy_node->x0 ; //cout << dummy_node->x ; if (dummy_node->movable) dummy_node->x = dummy_node->v * dt + dummy_node->x; dummy_node->xold = dummy_node->x; //cout << dummy_node->x0 ; Tensor euler = dummy_node->x.slice(0, 0, 3); Tensor trans = dummy_node->x.slice(0, 3, 6); Transformation tr; tr.rotation = Quaternion::from_euler(euler); tr.translation = trans; tr.scale = dummy_node->scale; //cout << tr.rotation << endl; //cout << tr.translation << endl; //cout << tr.scale << endl; //cout << "step_obstacle" << endl; apply_transformation_onto(obstacle.base_mesh, obstacle.curr_state_mesh, tr); Mesh &mesh = obstacle.curr_state_mesh; for (int n = 0; n < mesh.nodes.size(); n++) { mesh.nodes[n]->xold = mesh.nodes[n]->x; } } void plasticity_step (Simulation &sim) { if (!sim.enabled[plasticity]) return; // cout << "plasticity_step" << endl; sim.timers[plasticity].tick(); for (int c = 0; c < sim.cloths.size(); c++) { plastic_update(sim.cloths[c]); optimize_plastic_embedding(sim.cloths[c]); } sim.timers[plasticity].tock(); } void strainlimiting_step (Simulation &sim, const vector<Constraint*> &cons) { // cout << "strainlimiting_step" << endl; } void equilibration_step (Simulation &sim) { sim.timers[remeshing].tick(); vector<Constraint*> cons;// = get_constraints(sim, true); // double stiff = 1; // swap(stiff, ::magic.handle_stiffness); for (int c = 0; c < sim.cloths.size(); c++) { Mesh &mesh = sim.cloths[c].mesh; for (int n = 0; n < mesh.nodes.size(); n++) mesh.nodes[n]->acceleration = ZERO3; apply_pop_filter(sim.cloths[c], cons, 1); } // swap(stiff, ::magic.handle_stiffness); sim.timers[remeshing].tock(); delete_constraints(cons); cons = get_constraints(sim, false); if (sim.enabled[collision]) { sim.timers[collision].tick(); collision_response(sim, sim.cloth_meshes, cons, sim.obstacle_meshes); sim.timers[collision].tock(); } delete_constraints(cons); } void strainzeroing_step (Simulation &sim) { } void collision_step (Simulation &sim) { if (!sim.enabled[collision]) return; // cout << "collision_step" << endl; sim.timers[collision].tick(); vector<Tensor> xold = node_positions(sim.cloth_meshes); vector<Constraint*> cons = get_constraints(sim, false); collision_response(sim, sim.cloth_meshes, cons, sim.obstacle_meshes); delete_constraints(cons); update_velocities(sim.cloth_meshes, xold, sim.step_time); sim.timers[collision].tock(); } void remeshing_step (Simulation &sim, bool initializing) { if (!sim.enabled[remeshing]) return; // copy old meshes vector<Mesh> old_meshes(sim.cloths.size()); vector<Mesh*> old_meshes_p(sim.cloths.size()); // for symmetry in separate() for (int c = 0; c < sim.cloths.size(); c++) { old_meshes[c] = deep_copy(sim.cloths[c].mesh); old_meshes_p[c] = &old_meshes[c]; } // back up residuals typedef vector<Residual> MeshResidual; vector<MeshResidual> res; if (sim.enabled[plasticity] && !initializing) { sim.timers[plasticity].tick(); res.resize(sim.cloths.size()); for (int c = 0; c < sim.cloths.size(); c++) res[c] = back_up_residuals(sim.cloths[c].mesh); sim.timers[plasticity].tock(); } // remesh sim.timers[remeshing].tick(); for (int c = 0; c < sim.cloths.size(); c++) { if (::magic.fixed_high_res_mesh) static_remesh(sim.cloths[c]); else { vector<Plane> planes = nearest_obstacle_planes(sim.cloths[c].mesh, sim.obstacle_meshes); dynamic_remesh(sim.cloths[c], planes, sim.enabled[plasticity]); } } sim.timers[remeshing].tock(); // restore residuals if (sim.enabled[plasticity] && !initializing) { sim.timers[plasticity].tick(); for (int c = 0; c < sim.cloths.size(); c++) restore_residuals(sim.cloths[c].mesh, old_meshes[c], res[c]); sim.timers[plasticity].tock(); } // separate if (sim.enabled[separation]) { sim.timers[separation].tick(); separate(sim.cloth_meshes, old_meshes_p, sim.obstacle_meshes); sim.timers[separation].tock(); } // apply pop filter if (sim.enabled[popfilter] && !initializing) { sim.timers[popfilter].tick(); vector<Constraint*> cons = get_constraints(sim, true); for (int c = 0; c < sim.cloths.size(); c++) apply_pop_filter(sim.cloths[c], cons); delete_constraints(cons); sim.timers[popfilter].tock(); } // delete old meshes for (int c = 0; c < sim.cloths.size(); c++) delete_mesh(old_meshes[c]); } void update_velocities (vector<Mesh*> &meshes, vector<Tensor> &xold, Tensor dt) { Tensor inv_dt = 1/dt; #pragma omp parallel for for (int n = 0; n < xold.size(); n++) { Node *node = get<Node>(n, meshes); node->v = node->v + (node->x - xold[n])*inv_dt; } } void update_obstacles (Simulation &sim, bool update_positions) { // cout << "update_obstacles" << endl; for (int o = 0; o < sim.obstacles.size(); o++) { sim.obstacles[o].get_mesh(sim.time); // sim.obstacles[o].blend_with_previous(sim.time, sim.step_time, blend); if (!update_positions) { // put positions back where they were Mesh &mesh = sim.obstacles[o].get_mesh(); for (int n = 0; n < mesh.nodes.size(); n++) { Node *node = mesh.nodes[n]; node->v = (node->x - node->x0)/sim.step_time; node->x = node->x0; } } } } // Helper functions template <typename Prim> int size (const vector<Mesh*> &meshes) { int np = 0; for (int m = 0; m < meshes.size(); m++) np += get<Prim>(*meshes[m]).size(); return np; } template int size<Vert> (const vector<Mesh*>&); template int size<Node> (const vector<Mesh*>&); template int size<Edge> (const vector<Mesh*>&); template int size<Face> (const vector<Mesh*>&); template <typename Prim> int get_index (const Prim *p, const vector<Mesh*> &meshes) { int i = 0; for (int m = 0; m < meshes.size(); m++) { const vector<Prim*> &ps = get<Prim>(*meshes[m]); if (p->index < ps.size() && p == ps[p->index]) return i + p->index; else i += ps.size(); } return -1; } template int get_index (const Vert*, const vector<Mesh*>&); template int get_index (const Node*, const vector<Mesh*>&); template int get_index (const Edge*, const vector<Mesh*>&); template int get_index (const Face*, const vector<Mesh*>&); template <typename Prim> Prim *get (int i, const vector<Mesh*> &meshes) { for (int m = 0; m < meshes.size(); m++) { const vector<Prim*> &ps = get<Prim>(*meshes[m]); if (i < ps.size()) return ps[i]; else i -= ps.size(); } return NULL; } template Vert *get (int, const vector<Mesh*>&); template Node *get (int, const vector<Mesh*>&); template Edge *get (int, const vector<Mesh*>&); template Face *get (int, const vector<Mesh*>&); vector<Tensor> node_positions (const vector<Mesh*> &meshes) { vector<Tensor> xs(size<Node>(meshes)); for (int n = 0; n < xs.size(); n++) xs[n] = get<Node>(n, meshes)->x; return xs; }
34.869848
112
0.612877
priyasundaresan
cfbc9166cf99ff55eb9d15aacb24a713551f7d21
2,707
hpp
C++
RubetekIOS-CPP.framework/Versions/A/Headers/libnet/dawn/queue_blocks.hpp
yklishevich/RubetekIOS-CPP-releases
7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb
[ "MIT" ]
null
null
null
RubetekIOS-CPP.framework/Versions/A/Headers/libnet/dawn/queue_blocks.hpp
yklishevich/RubetekIOS-CPP-releases
7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb
[ "MIT" ]
null
null
null
RubetekIOS-CPP.framework/Versions/A/Headers/libnet/dawn/queue_blocks.hpp
yklishevich/RubetekIOS-CPP-releases
7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb
[ "MIT" ]
null
null
null
#pragma once #include <queue> #include <msw/buffer.hpp> namespace dawn { struct queue_blocks { typedef msw::range<msw::byte> block ; typedef msw::range<msw::byte const> const_block ; queue_blocks () ; queue_blocks (queue_blocks&&) ; bool empty () const ; bool has_blocks () const ; std::size_t count () const ; msw::size<msw::byte> size () const ; block front () ; const_block front () const ; block back () ; const_block back () const ; void push (const_block) ; void pop () ; msw::buffer<msw::byte> pull () ; private: std::queue<msw::buffer<msw::byte>> blocks_ ; msw::size<msw::byte> size_ ; }; } namespace dawn { inline queue_blocks::queue_blocks() {} inline queue_blocks::queue_blocks(queue_blocks&& other) : blocks_ (std::move(other.blocks_)) , size_ (std::move(other.size_ )) {} inline bool queue_blocks::empty() const { return blocks_.empty(); } inline bool queue_blocks::has_blocks() const { return !empty(); } inline std::size_t queue_blocks::count() const { return blocks_.size(); } inline msw::size<msw::byte> queue_blocks::size() const { return size_; } inline queue_blocks::block queue_blocks::front() { return blocks_.front().all(); } inline queue_blocks::const_block queue_blocks::front() const { return blocks_.front().all(); } inline queue_blocks::block queue_blocks::back() { return blocks_.back().all(); } inline queue_blocks::const_block queue_blocks::back() const { return blocks_.back().all(); } inline void queue_blocks::push(const_block blk) { blocks_.emplace(blk); size_ += blk.size(); } inline void queue_blocks::pop() { size_ -= front().size(); blocks_.pop(); } inline msw::buffer<msw::byte> queue_blocks::pull() { size_ -= front().size(); msw::buffer<msw::byte> blk = std::move(blocks_.front()); blocks_.pop(); return std::move(blk); } }
27.07
67
0.461396
yklishevich
cfbe411ee255d884970fca91398de8142dd8ec8c
7,250
hpp
C++
math/rotation.hpp
melowntech/libmath
7a473801a93ba5e244d96e773b412a3abed4a400
[ "BSD-2-Clause" ]
1
2021-09-02T08:42:59.000Z
2021-09-02T08:42:59.000Z
externals/browser/externals/browser/externals/libmath/math/rotation.hpp
HanochZhu/vts-browser-unity-plugin
32a22d41e21b95fb015326f95e401d87756d0374
[ "BSD-2-Clause" ]
2
2020-06-09T12:06:16.000Z
2021-10-06T08:15:04.000Z
externals/browser/externals/browser/externals/libmath/math/rotation.hpp
HanochZhu/vts-browser-unity-plugin
32a22d41e21b95fb015326f95e401d87756d0374
[ "BSD-2-Clause" ]
1
2019-09-25T05:20:17.000Z
2019-09-25T05:20:17.000Z
/** * Copyright (c) 2017 Melown Technologies SE * * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /** * @file rotation.hpp * @author Jakub Cerveny <jakub.cerveny@ext.citationtech.net> * * Math related to rotations. */ #ifndef MATH_ROTATION_HPP #define MATH_ROTATION_HPP #include "geometry_core.hpp" namespace math { /** Converts a rotation vector (see below) to a rotation matrix. */ inline Matrix4 rotationMatrix(const Point3 & rvec) { Matrix4 m( ublas::identity_matrix<double>(4) ); double angle = ublas::norm_2(rvec); if (std::abs(angle) < 1e-10) { return m; } Point3 vec(rvec * (1.0 / angle)); double s = sin(angle), c = cos(angle); double xx = vec(0) * vec(0), yy = vec(1) * vec(1), zz = vec(2) * vec(2), xy = vec(0) * vec(1), yz = vec(1) * vec(2), zx = vec(2) * vec(0); double xs = vec(0) * s, ys = vec(1) * s, zs = vec(2) * s; double one_c = 1.0 - c; m(0, 0) = (one_c * xx) + c; m(0, 1) = (one_c * xy) - zs; m(0, 2) = (one_c * zx) + ys; m(1, 0) = (one_c * xy) + zs; m(1, 1) = (one_c * yy) + c; m(1, 2) = (one_c * yz) - xs; m(2, 0) = (one_c * zx) - ys; m(2, 1) = (one_c * yz) + xs; m(2, 2) = (one_c * zz) + c; return m; } /** Converts a rotation matrix to a rotation vector, whose direction represents * the axis of rotation and its magnitude represents the angle of rotation * in radians. */ inline Point3 rotationVector(const Matrix4 & mat) { double angle = acos(0.5 * (mat(0,0) + mat(1,1) + mat(2,2) - 1.0)); Point3 axis(mat(2,1) - mat(1,2), mat(0,2) - mat(2,0), mat(1,0) - mat(0,1)); return angle / (2*sin(angle)) * axis; } /** Quaternion -- represents a rotation. */ class Quaternion { public: Quaternion() : x(0.0), y(0.0), z(0.0), w(1.0) {} Quaternion(double x, double y, double z, double w) : x(x), y(y), z(z), w(w) {} Quaternion(const Quaternion& q) { x = q.x; y = q.y; z = q.z; w = q.w; } Quaternion& operator=(const Quaternion& q) { x = q.x; y = q.y; z = q.z; w = q.w; return *this; } Quaternion(const Matrix4& mat) { fromMatrix(mat); } /// Converts a matrix to a quaternion. void fromMatrix(const Matrix4& m); /// Converts this quaternion to a matrix. Matrix4 toMatrix() const; Quaternion& normalize(); Quaternion operator+(const Quaternion& other) const; Quaternion operator*(const Quaternion& other) const; Quaternion operator*(double scalar) const; Quaternion& operator*=(double scalar); Quaternion& operator*=(const Quaternion& other); double x, y, z; // imaginary part double w; // real part }; inline Quaternion Quaternion::operator*(double s) const { return Quaternion(s*x, s*y, s*z, s*w); } inline Quaternion& Quaternion::operator*=(double s) { x*=s; y*=s; z*=s; w*=s; return *this; } inline Quaternion& Quaternion::operator*=(const Quaternion& other) { return (*this = other * (*this)); } inline Quaternion Quaternion::operator+(const Quaternion& b) const { return Quaternion(x+b.x, y+b.y, z+b.z, w+b.w); } inline Quaternion Quaternion::operator*(const Quaternion& other) const { Quaternion tmp; tmp.w = (other.w * w) - (other.x * x) - (other.y * y) - (other.z * z); tmp.x = (other.w * x) + (other.x * w) + (other.y * z) - (other.z * y); tmp.y = (other.w * y) + (other.y * w) + (other.z * x) - (other.x * z); tmp.z = (other.w * z) + (other.z * w) + (other.x * y) - (other.y * x); return tmp; } inline void Quaternion::fromMatrix(const Matrix4& m) { const double diag = m(0,0) + m(1,1) + m(2,2) + 1; if (diag > 0.0) { const double scale = sqrt(diag) * 2.0; // get scale from diagonal x = (m(2,1) - m(1,2)) / scale; y = (m(0,2) - m(2,0)) / scale; z = (m(1,0) - m(0,1)) / scale; w = 0.25 * scale; } else { if (m(0,0) > m(1,1) && m(0,0) > m(2,2)) { // 1st element of diag is greatest value // find scale according to 1st element, and double it const double scale = sqrt( 1.0 + m(0,0) - m(1,1) - m(2,2)) * 2.0; x = 0.25 * scale; y = (m(0,1) + m(1,0)) / scale; z = (m(2,0) + m(0,2)) / scale; w = (m(2,1) - m(1,2)) / scale; } else if (m(1,1) > m(2,2)) { // 2nd element of diag is greatest value // find scale according to 2nd element, and double it const double scale = sqrt( 1.0 + m(1,1) - m(0,0) - m(2,2)) * 2.0; x = (m(0,1) + m(1,0) ) / scale; y = 0.25 * scale; z = (m(1,2) + m(2,1) ) / scale; w = (m(0,2) - m(2,0) ) / scale; } else { // 3rd element of diag is greatest value // find scale according to 3rd element, and double it const double scale = sqrt( 1.0 + m(2,2) - m(0,0) - m(1,1)) * 2.0; x = (m(0,2) + m(2,0)) / scale; y = (m(1,2) + m(2,1)) / scale; z = 0.25 * scale; w = (m(1,0) - m(0,1)) / scale; } } normalize(); } inline Quaternion& Quaternion::normalize() { double n = x*x + y*y + z*z + w*w; *this *= 1.0 / sqrt(n); return *this; } inline Matrix4 Quaternion::toMatrix() const { Matrix4 m = ublas::identity_matrix<double>(4); m(0,0) = 1.0 - 2.0*y*y - 2.0*z*z; m(1,0) = 2.0*x*y + 2.0*z*w; m(2,0) = 2.0*x*z - 2.0*y*w; m(3,0) = 0.0; m(0,1) = 2.0*x*y - 2.0*z*w; m(1,1) = 1.0 - 2.0*x*x - 2.0*z*z; m(2,1) = 2.0*z*y + 2.0*x*w; m(3,1) = 0.0; m(0,2) = 2.0*x*z + 2.0*y*w; m(1,2) = 2.0*z*y - 2.0*x*w; m(2,2) = 1.0 - 2.0*x*x - 2.0*y*y; m(3,2) = 0.0; m(0,3) = 0.0; m(1,3) = 0.0; m(2,3) = 0.0; m(3,3) = 1.0; return m; } } // namespace math #endif
27.358491
79
0.549379
melowntech
cfc100bde1c5aae9d74ba6d1e7071f3bd1096362
3,215
cpp
C++
src/common/timer/timer_1ms.cpp
caozhiyi/quicX
46b486fc7786faf479b60c24da8ebdec783b3d5b
[ "BSD-3-Clause" ]
1
2021-11-02T14:31:12.000Z
2021-11-02T14:31:12.000Z
src/common/timer/timer_1ms.cpp
caozhiyi/quicX
46b486fc7786faf479b60c24da8ebdec783b3d5b
[ "BSD-3-Clause" ]
null
null
null
src/common/timer/timer_1ms.cpp
caozhiyi/quicX
46b486fc7786faf479b60c24da8ebdec783b3d5b
[ "BSD-3-Clause" ]
1
2021-09-30T08:23:58.000Z
2021-09-30T08:23:58.000Z
// Use of this source code is governed by a BSD 3-Clause License // that can be found in the LICENSE file. // Author: caozhiyi (caozhiyi5@gmail.com) #include "timer_1ms.h" namespace quicx { static const TIMER_CAPACITY __timer_accuracy = TC_1MS; // 1 millisecond static const TIMER_CAPACITY __timer_capacity = TC_50MS; // 50 millisecond Timer1ms::Timer1ms() : _cur_index(0) { _timer_wheel.resize(__timer_capacity); _bitmap.Init(__timer_capacity); } Timer1ms::~Timer1ms() { } bool Timer1ms::AddTimer(std::weak_ptr<TimerSolt> t, uint32_t time, bool always) { if (time >= __timer_capacity) { return false; } auto ptr = t.lock(); if (!ptr) { return false; } if (ptr->IsInTimer()) { return true; } if (always) { ptr->SetAlways(__timer_accuracy); } ptr->SetInterval(time); time += _cur_index; if (time > __timer_capacity) { time %= __timer_capacity; } ptr->SetIndex(time); ptr->SetTimer(); _timer_wheel[time].push_back(t); return _bitmap.Insert(time); } bool Timer1ms::RmTimer(std::weak_ptr<TimerSolt> t) { auto ptr = t.lock(); if (!ptr) { return false; } auto index = ptr->GetIndex(__timer_accuracy); bool ret = _bitmap.Remove(index); ptr->RmTimer(); return ret; } int32_t Timer1ms::CurrentTimer() { return _cur_index; } int32_t Timer1ms::MinTime() { if (_bitmap.Empty()) { return NO_TIMER; } int32_t next_setp = _bitmap.GetMinAfter(_cur_index); if (next_setp >= 0) { return next_setp - _cur_index; } if (_cur_index > 0) { next_setp = _bitmap.GetMinAfter(0); } if (next_setp >= 0) { return next_setp + __timer_capacity - _cur_index; } return NO_TIMER; } uint32_t Timer1ms::TimerRun(uint32_t time) { time = time % __timer_capacity; _cur_index += time; uint32_t ret = 0; if (_cur_index >= __timer_capacity) { _cur_index %= __timer_capacity; ret++; } auto& bucket = _timer_wheel[_cur_index]; if (bucket.size() > 0) { for (auto iter = bucket.begin(); iter != bucket.end();) { auto ptr = (iter)->lock(); if (ptr && ptr->IsInTimer()) { ptr->OnTimer(); } // remove from current bucket iter = bucket.erase(iter); _bitmap.Remove(ptr->GetIndex(__timer_accuracy)); if (!ptr->IsAlways(__timer_accuracy) || !ptr->IsInTimer()) { ptr->RmTimer(); continue; } else { // add to timer again uint16_t next_index = ptr->GetInterval() + _cur_index; if (next_index >= __timer_capacity) { next_index = next_index % __timer_capacity; } AddTimerByIndex(ptr, uint8_t(next_index)); } } } return ret; } void Timer1ms::AddTimerByIndex(std::weak_ptr<TimerSolt> t, uint8_t index) { auto ptr = t.lock(); if (!ptr) { return; } ptr->SetIndex(index, TC_1MS); _timer_wheel[index].push_back(t); _bitmap.Insert(index); } }
22.640845
81
0.576361
caozhiyi
cfc56aecda2a23487b740604cb490928ac2a12b8
1,893
cpp
C++
src/v3/action_constants.cpp
siyuan0322/etcd-cpp-apiv3
1575c5b43a64f85f77897e9b5aad24e6523ea453
[ "BSD-3-Clause" ]
139
2016-09-20T00:28:04.000Z
2020-09-27T15:05:11.000Z
src/v3/action_constants.cpp
siyuan0322/etcd-cpp-apiv3
1575c5b43a64f85f77897e9b5aad24e6523ea453
[ "BSD-3-Clause" ]
85
2020-09-29T16:33:00.000Z
2022-03-30T01:23:23.000Z
src/v3/action_constants.cpp
siyuan0322/etcd-cpp-apiv3
1575c5b43a64f85f77897e9b5aad24e6523ea453
[ "BSD-3-Clause" ]
63
2016-12-06T11:42:29.000Z
2020-09-24T06:15:49.000Z
#include "etcd/v3/action_constants.hpp" char const * etcdv3::CREATE_ACTION = "create"; char const * etcdv3::COMPARESWAP_ACTION = "compareAndSwap"; char const * etcdv3::UPDATE_ACTION = "update"; char const * etcdv3::SET_ACTION = "set"; char const * etcdv3::GET_ACTION = "get"; char const * etcdv3::PUT_ACTION = "put"; char const * etcdv3::DELETE_ACTION = "delete"; char const * etcdv3::COMPAREDELETE_ACTION = "compareAndDelete"; char const * etcdv3::LOCK_ACTION = "lock"; char const * etcdv3::UNLOCK_ACTION = "unlock"; char const * etcdv3::TXN_ACTION = "txn"; char const * etcdv3::WATCH_ACTION = "watch"; char const * etcdv3::LEASEGRANT = "leasegrant"; char const * etcdv3::LEASEREVOKE = "leaserevoke"; char const * etcdv3::LEASEKEEPALIVE = "leasekeepalive"; char const * etcdv3::LEASETIMETOLIVE = "leasetimetolive"; char const * etcdv3::LEASELEASES = "leaseleases"; char const * etcdv3::CAMPAIGN_ACTION = "campaign"; char const * etcdv3::PROCLAIM_ACTION = "preclaim"; char const * etcdv3::LEADER_ACTION = "leader"; char const * etcdv3::OBSERVE_ACTION = "obverse"; char const * etcdv3::RESIGN_ACTION = "resign"; // see: noPrefixEnd in etcd, however c++ doesn't allows '\0' inside a string, thus we use // the UTF-8 char U+0000 (i.e., "\xC0\x80"). char const * etcdv3::NUL = "\xC0\x80"; char const * etcdv3::KEEPALIVE_CREATE = "keepalive create"; char const * etcdv3::KEEPALIVE_WRITE = "keepalive write"; char const * etcdv3::KEEPALIVE_READ = "keepalive read"; char const * etcdv3::KEEPALIVE_DONE = "keepalive done"; char const * etcdv3::WATCH_CREATE = "watch create"; char const * etcdv3::WATCH_WRITE = "watch write"; char const * etcdv3::WATCH_WRITES_DONE = "watch writes done"; char const * etcdv3::ELECTION_OBSERVE_CREATE = "observe create"; const int etcdv3::ERROR_KEY_NOT_FOUND = 100; const int etcdv3::ERROR_COMPARE_FAILED = 101; const int etcdv3::ERROR_KEY_ALREADY_EXISTS = 105;
41.152174
89
0.733228
siyuan0322
cfc5afce8a871cbdf7809d3bd8833c1e30182e5b
4,823
cc
C++
src/Table.cc
mgonnav/flaviadb
af133b30ec97834753d4d24a682cb2691688a854
[ "Apache-2.0" ]
1
2020-08-20T22:34:36.000Z
2020-08-20T22:34:36.000Z
src/Table.cc
mgonnav/flaviadb
af133b30ec97834753d4d24a682cb2691688a854
[ "Apache-2.0" ]
1
2020-08-27T00:01:42.000Z
2020-11-27T17:18:58.000Z
src/Table.cc
mgonnav/flaviadb
af133b30ec97834753d4d24a682cb2691688a854
[ "Apache-2.0" ]
null
null
null
#include "Where.hh" #include "printutils.hh" namespace ft = ftools; namespace fs = std::filesystem; namespace pu = printUtils; Table::Table(std::string name) { this->name = name; loadPaths(name); checkTableExists(); load_metadata(); this->reg_count = ft::getRegCount(name); this->indexes = new std::vector<Index*>; loadIndexes(); } void Table::loadPaths(std::string const& name) { this->path = ft::getTablePath(name); this->regs_path = ft::getRegistersPath(name); this->indexes_path = ft::getIndexesPath(name); this->metadata_path = ft::getMetadataPath(name); } void Table::checkTableExists() { if (!ft::dirExists(this->path)) throw DBException{NON_EXISTING_TABLE, this->name}; } bool Table::load_metadata() { openMetadataFile(); loadMetadataHeader(); for (auto& column : *this->columns) loadColumnData(column); return 1; } void Table::openMetadataFile() { this->metadata_file.open(this->metadata_path); if (!this->metadata_file.is_open()) throw DBException{UNREADABLE_METADATA}; } void Table::loadMetadataHeader() { loadTableName(); loadColumnCount(); loadRegSize(); } void Table::loadTableName() { std::string metadata_table_name; getline(this->metadata_file, metadata_table_name, '\t'); if (this->name != metadata_table_name) throw DBException{DIFFERENT_METADATA_NAME}; } void Table::loadColumnCount() { std::string column_count; getline(this->metadata_file, column_count, '\t'); this->columns = new std::vector<hsql::ColumnDefinition*>(stoi(column_count)); } void Table::loadRegSize() { std::string reg_size; getline(this->metadata_file, reg_size, '\n'); this->reg_size = stoi(reg_size); } void Table::loadColumnData(hsql::ColumnDefinition*& column) { std::string data; getline(this->metadata_file, data, '\t'); char* col_name = new char[data.size()]; strcpy(col_name, data.c_str()); hsql::ColumnType col_type = getColumnType(); getline(this->metadata_file, data, '\n'); bool col_nullable = stoi(data); column = new hsql::ColumnDefinition(col_name, col_type, col_nullable); } void Table::loadIndexes() { for (const auto& reg : fs::directory_iterator(this->indexes_path)) { std::string idx_name = reg.path().filename(); indexes->push_back(new Index(idx_name)); } } void Table::loadStoredRegisters() { this->registers = std::make_unique<std::list<std::pair<std::string, RegisterData>>>(); for (const auto& reg : fs::directory_iterator(this->regs_path)) { // Load data in file to reg_data std::ifstream data_file(reg.path()); std::vector<std::string> reg_data; // Load each piece of data into reg_data std::string data; for (size_t i = 0; i < this->columns->size(); i++) { getline(data_file, data, '\t'); reg_data.push_back(data); } this->registers->push_back({reg.path().filename(), RegisterData(reg_data)}); } } Table::Table(std::string name, std::vector<hsql::ColumnDefinition*>* cols) { this->name = name; loadPaths(name); this->indexes = new std::vector<Index*>; createTableFolders(); this->columns = cols; this->reg_size = calculateRegSize(); this->registers = std::make_unique<std::list<std::pair<std::string, RegisterData>>>(); // Create medata.dat file for table // and fill it with table's name & cols info std::ofstream wMetadata(this->metadata_path); wMetadata << this->name << "\t" << this->columns->size() << "\t" << this->reg_size << "\n"; for (const hsql::ColumnDefinition* col : *this->columns) wMetadata << col->name << "\t" << (int)col->type.data_type << "\t" << col->type.length << "\t" << col->nullable << "\n"; wMetadata.close(); std::ofstream wCount(ft::getRegCountPath(this->name)); wCount << 0; // 0 regs when table is created wCount.close(); std::cout << "Table " << this->name << " was created successfully.\n"; } void Table::createTableFolders() { ft::createFolder(this->path); ft::createFolder(this->regs_path); ft::createFolder(this->indexes_path); } int Table::calculateRegSize() { int reg_size = 0; for (const auto& col : *this->columns) { hsql::DataType data_type = col->type.data_type; if (data_type == hsql::DataType::INT) reg_size += 4; else if (data_type == hsql::DataType::CHAR) reg_size += col->type.length; else if (data_type == hsql::DataType::DATE) reg_size += 8; } return reg_size; } Table::~Table() { delete this->columns; delete this->indexes; } hsql::ColumnType Table::getColumnType() { std::string data; getline(this->metadata_file, data, '\t'); int col_enum = stoi(data); getline(this->metadata_file, data, '\t'); int col_length = stoi(data); hsql::ColumnType col_type((hsql::DataType)col_enum, col_length); return col_type; }
23.758621
80
0.667427
mgonnav
cfd0a388d365849c55299571788a64f78b67ee78
631
cpp
C++
src/scene/Stage.cpp
deianvn/kit2d
a8fd6d75cf1f8d14baabaa04903ab3fdee3b4ef5
[ "Apache-2.0" ]
null
null
null
src/scene/Stage.cpp
deianvn/kit2d
a8fd6d75cf1f8d14baabaa04903ab3fdee3b4ef5
[ "Apache-2.0" ]
null
null
null
src/scene/Stage.cpp
deianvn/kit2d
a8fd6d75cf1f8d14baabaa04903ab3fdee3b4ef5
[ "Apache-2.0" ]
null
null
null
#include "../../include/kit2d/scene/Stage.hpp" #include "../../include/kit2d/scene/Scene.hpp" namespace kit2d { Stage::Stage(Window& window) : window(window) { window.onUpdate([this](float deltaTime) { this->scene->update(deltaTime); }); window.onRender([this](Renderer& renderer) { this->scene->render(spriteBatch); spriteBatch.process(renderer); }); } void Stage::setScene(std::shared_ptr<Scene> scene) { this->scene = scene; scene->prepare(); } void Stage::play() { window.loop(); } Rect Stage::bounds() { return Rect { window->x, y, width, height }; } }
20.354839
54
0.613312
deianvn
cfd67f07a35b31f5fa7582523cad4390e276715f
1,015
cpp
C++
src/io/github/technicalnotes/programming/basics/36-threadNlocking.cpp
chiragbhatia94/programming-cpp
efd6aa901deacf416a3ab599e6599845a8111eac
[ "MIT" ]
null
null
null
src/io/github/technicalnotes/programming/basics/36-threadNlocking.cpp
chiragbhatia94/programming-cpp
efd6aa901deacf416a3ab599e6599845a8111eac
[ "MIT" ]
null
null
null
src/io/github/technicalnotes/programming/basics/36-threadNlocking.cpp
chiragbhatia94/programming-cpp
efd6aa901deacf416a3ab599e6599845a8111eac
[ "MIT" ]
null
null
null
#include "bits/stdc++.h" using namespace std; char *getTime() { chrono::time_point<chrono::system_clock> now = chrono::system_clock::now(); time_t t = chrono::system_clock::to_time_t(now); return ctime(&t); } double accountBalance = 100; mutex accountLock; void getMoney(int id, double amount) { lock_guard<mutex> lock(accountLock); this_thread::sleep_for(chrono::seconds(2)); cout << id << " tries to withdraw Rs " << amount << " at " << getTime() << endl; if ((accountBalance - amount) >= 0) { accountBalance -= amount; cout << "New account balance is Rs " << accountBalance << endl; } else { cout << "Insufficient funds, current balance is Rs " << accountBalance << endl; } } int main() { thread threads[10]; for (int i = 0; i < 10; i++) { threads[i] = thread(getMoney, i, 15); } for (int i = 0; i < 10; i++) { threads[i].join(); } return 0; }
23.068182
88
0.553695
chiragbhatia94
cfd6ec574659e3d92a6abb352f6e84dd8242fc97
4,026
cpp
C++
window.cpp
mauriliodc/path_aligner
fba4a8f95cac54c2bd5ee36626980ca7c4b9efb7
[ "MIT" ]
null
null
null
window.cpp
mauriliodc/path_aligner
fba4a8f95cac54c2bd5ee36626980ca7c4b9efb7
[ "MIT" ]
null
null
null
window.cpp
mauriliodc/path_aligner
fba4a8f95cac54c2bd5ee36626980ca7c4b9efb7
[ "MIT" ]
null
null
null
#include "window.h" Window::Window (QWidget *parent) : QMainWindow (parent),ui (new Ui::Window) { ui->setupUi(this); p=0; laser=0; } Window::~Window(){ delete ui; } void Window::on_fixed_frame_clicked() { QString odometryFilename = QFileDialog::getOpenFileName(this,tr("Open ODOMETRY log file"),"~",tr("All files (*.*)")); if(odometryFilename.length()>0){ QStringList l = odometryFilename.split("/"); p = new Path(odometryFilename.toStdString()); p->color.r=1.0f; this->ui->Scene->_drawables.push_back(p); } else{ std::cout <<"[BUTTON 1][ON FILE OPEN] no file selected"<<std::endl; } } void Window::on_target_frame_clicked() { QString odometryFilename = QFileDialog::getOpenFileName(this,tr("Open ODOMETRY log file"),"~",tr("All files (*.*)")); if(odometryFilename.length()>0){ QStringList l = odometryFilename.split("/"); laser = new Path(odometryFilename.toStdString()); laser->color.r=1.0f; laser->color.g=1.0f; this->ui->Scene->_drawables.push_back(laser); } else{ std::cout <<"[BUTTON 2][ON FILE OPEN] no file selected"<<std::endl; } } void Window::on_t_x_valueChanged(double arg1) { if(laser==0)return; laser->transform.translation().x()=(float)arg1; this->ui->Scene->updateGL(); } void Window::on_t_y_valueChanged(double arg1) { if(laser==0)return; laser->transform.translation().y()=(float)arg1; this->ui->Scene->updateGL(); } void Window::on_t_z_valueChanged(double arg1) { if(laser==0)return; laser->transform.translation().z()=(float)arg1; this->ui->Scene->updateGL(); } void Window::on_r_x_valueChanged(double arg1) { if(laser==0)return; Eigen::Matrix3f m; m = Eigen::AngleAxisf(arg1, Eigen::Vector3f::UnitX()) * Eigen::AngleAxisf(this->ui->r_y->value(), Eigen::Vector3f::UnitY()) * Eigen::AngleAxisf(this->ui->r_z->value(), Eigen::Vector3f::UnitZ()); laser->transform.linear() = m; this->ui->Scene->updateGL(); } void Window::on_r_y_valueChanged(double arg1) { if(laser==0)return; Eigen::Matrix3f m; m = Eigen::AngleAxisf(this->ui->r_x->value(), Eigen::Vector3f::UnitX()) * Eigen::AngleAxisf(arg1, Eigen::Vector3f::UnitY()) * Eigen::AngleAxisf(this->ui->r_z->value(), Eigen::Vector3f::UnitZ()); laser->transform.linear() = m; this->ui->Scene->updateGL(); } void Window::on_r_z_valueChanged(double arg1) { if(laser==0)return; Eigen::Matrix3f m; m = Eigen::AngleAxisf(this->ui->r_x->value(), Eigen::Vector3f::UnitX()) * Eigen::AngleAxisf(this->ui->r_y->value(), Eigen::Vector3f::UnitY()) * Eigen::AngleAxisf(arg1, Eigen::Vector3f::UnitZ()); laser->transform.linear() = m; this->ui->Scene->updateGL(); } void Window::on_print_clicked() { std::cout<<"Translation:"<<std::endl; std::cout<< laser->transform.translation().transpose()<<std::endl<< std::endl; std::cout<<"Rotation quaternion:"<<std::endl; std::cout<< Eigen::Quaternionf(laser->transform.linear()).x()<< " " <<Eigen::Quaternionf(laser->transform.linear()).y()<< " " <<Eigen::Quaternionf(laser->transform.linear()).z()<< " " <<Eigen::Quaternionf(laser->transform.linear()).w()<< std::endl<< std::endl; Eigen::Vector3f ea = laser->transform.linear().matrix().eulerAngles(0, 1, 2); std::cout<<"RPY:"<<std::endl; std::cout<<ea.transpose()<<std::endl<< std::endl; } void Window::on_reset_button_clicked() { if(laser==0)return; laser->transform.translation().x()=0.0f; laser->transform.translation().y()=0.0f; laser->transform.translation().z()=0.0f; Eigen::Matrix3f m; m = Eigen::AngleAxisf(0.0f, Eigen::Vector3f::UnitX()) * Eigen::AngleAxisf(0.0f, Eigen::Vector3f::UnitY()) * Eigen::AngleAxisf(0.0f, Eigen::Vector3f::UnitZ()); laser->transform.linear() = m; this->ui->Scene->updateGL(); }
30.969231
121
0.616244
mauriliodc
cfd7726a7169408dc4d932fb2ff1afdf7efd955f
917
cpp
C++
dp/multi_zero_one_pack.cpp
FrancsXiang/DataStructure-Algorithms
f8f9e6d7be94057b955330cb7058235caef5cfed
[ "MIT" ]
1
2020-04-14T05:44:50.000Z
2020-04-14T05:44:50.000Z
dp/multi_zero_one_pack.cpp
FrancsXiang/DataStructure-Algorithms
f8f9e6d7be94057b955330cb7058235caef5cfed
[ "MIT" ]
null
null
null
dp/multi_zero_one_pack.cpp
FrancsXiang/DataStructure-Algorithms
f8f9e6d7be94057b955330cb7058235caef5cfed
[ "MIT" ]
2
2020-09-02T08:56:31.000Z
2021-06-22T11:20:58.000Z
#include <iostream> #include <algorithm> #define MAXN 101 #define MAXV 1001 using namespace std; // if you want the full pack,initialize res[0] = 0,res[1:] = -inf // or you want the maximum value, initialize res[:] = 0; //you could also use cost-effective sort to solve void orgin() { int vol[MAXN]; int val[MAXN]; int res[MAXN][MAXV]; int v, n; cin >> v >> n; for (int i = 1; i <= n; i++) cin >> vol[i] >> val[i]; for (int i = 0; i <= v; i++) res[0][i] = 0; for (int i = 1; i <= n; i++) { for (int j = vol[i]; j <= v; j++) { res[i][j] = max(res[i - 1][j], res[i][j - vol[i]] + val[i]); } } } void space_opt() { int vol[MAXN]; int val[MAXN]; int res[MAXV]; int v, n; for (int i = 1; i <= n; i++) cin >> vol[i] >> val[i]; for (int i = 0; i <= v; i++) res[i] = 0; for (int i = 1; i <= n; i++) { for (int j = vol[i]; j <= v; j++) { res[j] = max(res[j], res[j - vol[i]] + val[i]); } } }
24.131579
65
0.514722
FrancsXiang
cfdd07948334c7fc84c2caf3fa62b4a2bfad4efa
1,252
cpp
C++
test/src/Version.test.cpp
AMS21/CppBase
a6ec5542682bcebf5958d54557af1e03752a132f
[ "CC0-1.0" ]
null
null
null
test/src/Version.test.cpp
AMS21/CppBase
a6ec5542682bcebf5958d54557af1e03752a132f
[ "CC0-1.0" ]
1
2020-05-12T19:48:20.000Z
2020-05-12T19:48:20.000Z
test/src/Version.test.cpp
AMS21/CppBase
a6ec5542682bcebf5958d54557af1e03752a132f
[ "CC0-1.0" ]
null
null
null
#include <doctest.h> #include <cpp/Version.hpp> TEST_CASE("Version.Attribute") { #if __has_cpp_attribute(carries_dependencies) #endif #if __has_cpp_attribute(deprecated) #endif #if __has_cpp_attribute(fallthrough) #endif #if __has_cpp_attribute(likely) #endif #if __has_cpp_attribute(unlikely) #endif #if __has_cpp_attribute(maybe_unused) #endif #if __has_cpp_attribute(no_unique_address) #endif #if __has_cpp_attribute(nodiscard) #endif #if __has_cpp_attribute(noreturn) #endif } TEST_CASE("Version.CoreLanguage") { int cpp_aggregate_bases = __cpp_aggregate_bases; int cpp_aggregate_nsdmi = __cpp_aggregate_nsdmi; int cpp_aggregate_paren_init = __cpp_aggregate_paren_init; int cpp_alias_templates = __cpp_alias_templates; int cpp_aligned_new = __cpp_aligned_new; int cpp_attributes = __cpp_attributes; int cpp_binary_literals = __cpp_binary_literals; int cpp_capture_star_this = __cpp_capture_star_this; int cpp_char8_t = __cpp_char8_t; int cpp_concepts = __cpp_concepts; int cpp_conditional_explicit = __cpp_conditional_explicit; int cpp_consteval = __cpp_consteval; int cpp_constexpr = __cpp_constexpr; }
29.116279
62
0.746006
AMS21
cfe8e78c2ad096dcfd8c34d5cbddaf14f96b6892
674
cpp
C++
Cpp_Projects/tryandcatch.cpp
EderLukas/Portfolio
1c9adef3435129d26d3c6275a79ed363bf062e8f
[ "MIT" ]
null
null
null
Cpp_Projects/tryandcatch.cpp
EderLukas/Portfolio
1c9adef3435129d26d3c6275a79ed363bf062e8f
[ "MIT" ]
null
null
null
Cpp_Projects/tryandcatch.cpp
EderLukas/Portfolio
1c9adef3435129d26d3c6275a79ed363bf062e8f
[ "MIT" ]
null
null
null
/* * source code: tryandcatch.cpp * author: Lukas Eder * date: 01.01.2018 * * Descr.: * Uebung zu try and catch Fehlerbehandlung inkl. inteligentem Array */ #include <iostream> #include <array> using namespace std; int main() { //Variablen array<double, 3> preise; preise.at(0) = 1.45; preise.at(1) = 3.55; preise.at(2) = 5.25; for (unsigned int i = 0; i < preise.size(); i++) { try { cout << "Preise pos 1 mit []: " << preise[1] << endl; cout << "Preise pos 5 mit at()" << preise.at(5) << endl; cout << "Ende des Try-Blocks" << endl; } catch(exception &e){ cout << "Fehler: " << e.what() << endl; } } }
21.741935
69
0.55638
EderLukas
cfeb15a71d3d8c8a5b4ee0d3a96fd66458c16cc0
1,209
hpp
C++
include/ISubThread.hpp
lordio/insanity
7dfbf398fe08968f40a32280bf2b16cca2b476a1
[ "MIT" ]
1
2015-02-05T10:41:14.000Z
2015-02-05T10:41:14.000Z
include/ISubThread.hpp
lordio/insanity
7dfbf398fe08968f40a32280bf2b16cca2b476a1
[ "MIT" ]
1
2015-02-04T20:47:52.000Z
2015-02-05T07:43:05.000Z
include/ISubThread.hpp
lordio/insanity
7dfbf398fe08968f40a32280bf2b16cca2b476a1
[ "MIT" ]
null
null
null
#ifndef INSANITY_INTERFACE_SUB_THREAD #define INSANITY_INTERFACE_SUB_THREAD #include "Constants.hpp" #include "IThread.hpp" namespace Insanity { //"Sub," in opposition to the "main" thread, represented by IApplication. class INSANITY_API ISubThread : public virtual IThread { public: //================================================= //Create a new subthread. //Not intended for use outside the library. //Inherit from Default::Thread instead. //================================================= static ISubThread * Create(ISubThread * ext, bool start = true); //================================================= //Start a thread that is not currently running, // whether it hasn't started yet, // or has already returned. //Immediately returns if called relative to current thread. //================================================= virtual void Start() = 0; //================================================= //The main body of a thread's operations. // An implementation will call this through the function // passed to the platform-specific thread creation API. //================================================= virtual void Main() = 0; }; } #endif
31.815789
74
0.539289
lordio
cff5243f89c24da48b4e1a8e5bee40914b35363e
16,909
cpp
C++
src/TextureLoaderFrontend/load_dds.cpp
WubiCookie/VkRenderer
87cc5d858591fc976c197ab2834e1ac9a418becd
[ "MIT" ]
2
2020-05-31T19:54:19.000Z
2021-09-14T12:00:12.000Z
src/TextureLoaderFrontend/load_dds.cpp
WubiCookie/VkRenderer
87cc5d858591fc976c197ab2834e1ac9a418becd
[ "MIT" ]
null
null
null
src/TextureLoaderFrontend/load_dds.cpp
WubiCookie/VkRenderer
87cc5d858591fc976c197ab2834e1ac9a418becd
[ "MIT" ]
null
null
null
#include "load_dds.hpp" #define VK_NO_PROTOTYPES #include <vulkan/vulkan.h> //#define MEAN_AND_LEAN //#define NO_MINMAX //#include <windows.h> #include <iostream> /* Can load easier and more indepth with https://github.com/Hydroque/DDSLoader Because a lot of crappy, weird DDS file loader files were found online. The resources are actually VERY VERY limited. Written in C, can very easily port to C++ through casting mallocs (ensure your imports are correct), goto can be replaced. https://www.gamedev.net/forums/topic/637377-loading-dds-textures-in-opengl-black-texture-showing/ http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/ ^ Two examples of terrible code https://gist.github.com/Hydroque/d1a8a46853dea160dc86aa48618be6f9 ^ My first look and clean up 'get it working' https://ideone.com/WoGThC ^ Improvement details File Structure: Section Length /////////////////// FILECODE 4 HEADER 124 HEADER_DX10* 20 (https://msdn.microsoft.com/en-us/library/bb943983(v=vs.85).aspx) PIXELS fseek(f, 0, SEEK_END); (ftell(f) - 128) - (fourCC == "DX10" ? 17 or 20 : 0) * the link tells you that this section isn't written unless its a DX10 file Supports DXT1, DXT3, DXT5. The problem with supporting DX10 is you need to know what it is used for and how opengl would use it. File Byte Order: typedef unsigned int DWORD; // 32bits little endian type index attribute // description /////////////////////////////////////////////////////////////////////////////////////////////// DWORD 0 file_code; //. always `DDS `, or 0x20534444 DWORD 4 size; //. size of the header, always 124 (includes PIXELFORMAT) DWORD 8 flags; //. bitflags that tells you if data is present in the file // CAPS 0x1 // HEIGHT 0x2 // WIDTH 0x4 // PITCH 0x8 // PIXELFORMAT 0x1000 // MIPMAPCOUNT 0x20000 // LINEARSIZE 0x80000 // DEPTH 0x800000 DWORD 12 height; //. height of the base image (biggest mipmap) DWORD 16 width; //. width of the base image (biggest mipmap) DWORD 20 pitchOrLinearSize; //. bytes per scan line in an uncompressed texture, or bytes in the top level texture for a compressed texture // D3DX11.lib and other similar libraries unreliably or inconsistently provide the pitch, convert with // DX* && BC*: max( 1, ((width+3)/4) ) * block-size // *8*8_*8*8 && UYVY && YUY2: ((width+1) >> 1) * 4 // (width * bits-per-pixel + 7)/8 (divide by 8 for byte alignment, whatever that means) DWORD 24 depth; //. Depth of a volume texture (in pixels), garbage if no volume data DWORD 28 mipMapCount; //. number of mipmaps, garbage if no pixel data DWORD 32 reserved1[11]; //. unused DWORD 76 Size; //. size of the following 32 bytes (PIXELFORMAT) DWORD 80 Flags; //. bitflags that tells you if data is present in the file for following 28 bytes // ALPHAPIXELS 0x1 // ALPHA 0x2 // FOURCC 0x4 // RGB 0x40 // YUV 0x200 // LUMINANCE 0x20000 DWORD 84 FourCC; //. File format: DXT1, DXT2, DXT3, DXT4, DXT5, DX10. DWORD 88 RGBBitCount; //. Bits per pixel DWORD 92 RBitMask; //. Bit mask for R channel DWORD 96 GBitMask; //. Bit mask for G channel DWORD 100 BBitMask; //. Bit mask for B channel DWORD 104 ABitMask; //. Bit mask for A channel DWORD 108 caps; //. 0x1000 for a texture w/o mipmaps // 0x401008 for a texture w/ mipmaps // 0x1008 for a cube map DWORD 112 caps2; //. bitflags that tells you if data is present in the file // CUBEMAP 0x200 Required for a cube map. // CUBEMAP_POSITIVEX 0x400 Required when these surfaces are stored in a cube map. // CUBEMAP_NEGATIVEX 0x800 ^ // CUBEMAP_POSITIVEY 0x1000 ^ // CUBEMAP_NEGATIVEY 0x2000 ^ // CUBEMAP_POSITIVEZ 0x4000 ^ // CUBEMAP_NEGATIVEZ 0x8000 ^ // VOLUME 0x200000 Required for a volume texture. DWORD 114 caps3; //. unused DWORD 116 caps4; //. unused DWORD 120 reserved2; //. unused */ struct PixelFormatHeader { enum class FlagBits : uint32_t { AlphaPixels = 0x1, Alpha = 0x2, FourCC = 0x4, Rgb = 0x40, Yuv = 0x200, Luminance = 0x20000, }; uint32_t dwSize; FlagBits dwFlags; char dwFourCC[4]; uint32_t dwRGBBitCount; uint32_t dwRBitMask; uint32_t dwGBitMask; uint32_t dwBBitMask; uint32_t dwABitMask; }; struct Header { enum class FlagBits : uint32_t { Caps = 0x1, Height = 0x2, Width = 0x4, Pitch = 0x8, PixelFormat = 0x1000, MipmapCount = 0x20000, LinearSize = 0x80000, Depth = 0x800000, Texture = Caps | Height | Width | PixelFormat, Mipmap = MipmapCount, Volume = Depth, }; enum class Caps_bits : uint32_t { Complex = 0x8, Mipmap = 0x400000, Texture = 0x1000, }; enum class Caps2_bits : uint32_t { Cubemap = 0x200, CubemapPositiveX = 0x400, CubemapNegativeX = 0x800, CubemapPositiveY = 0x1000, CubemapNegativeY = 0x2000, CubemapPositiveZ = 0x4000, CubemapNegativeZ = 0x8000, Volume = 0x200000, CubemapAllFaces = CubemapPositiveX | CubemapNegativeX | CubemapPositiveY | CubemapNegativeY | CubemapPositiveZ | CubemapNegativeZ, }; char fourCC[4]; FlagBits dwSize; uint32_t dwFlags; uint32_t dwHeight; uint32_t dwWidth; uint32_t dwPitchOrLinearSize; uint32_t dwDepth; uint32_t dwMipMapCount; uint32_t dwReserved1[11]; PixelFormatHeader ddspf; Caps_bits dwCaps; Caps2_bits dwCaps2; uint32_t dwCaps3; uint32_t dwCaps4; uint32_t dwReserved2; }; enum class Format : uint32_t { UNKNOWN, R32G32B32A32_TYPELESS, R32G32B32A32_FLOAT, R32G32B32A32_UINT, R32G32B32A32_SINT, R32G32B32_TYPELESS, R32G32B32_FLOAT, R32G32B32_UINT, R32G32B32_SINT, R16G16B16A16_TYPELESS, R16G16B16A16_FLOAT, R16G16B16A16_UNORM, R16G16B16A16_UINT, R16G16B16A16_SNORM, R16G16B16A16_SINT, R32G32_TYPELESS, R32G32_FLOAT, R32G32_UINT, R32G32_SINT, R32G8X24_TYPELESS, D32_FLOAT_S8X24_UINT, R32_FLOAT_X8X24_TYPELESS, X32_TYPELESS_G8X24_UINT, R10G10B10A2_TYPELESS, R10G10B10A2_UNORM, R10G10B10A2_UINT, R11G11B10_FLOAT, R8G8B8A8_TYPELESS, R8G8B8A8_UNORM, R8G8B8A8_UNORM_SRGB, R8G8B8A8_UINT, R8G8B8A8_SNORM, R8G8B8A8_SINT, R16G16_TYPELESS, R16G16_FLOAT, R16G16_UNORM, R16G16_UINT, R16G16_SNORM, R16G16_SINT, R32_TYPELESS, D32_FLOAT, R32_FLOAT, R32_UINT, R32_SINT, R24G8_TYPELESS, D24_UNORM_S8_UINT, R24_UNORM_X8_TYPELESS, X24_TYPELESS_G8_UINT, R8G8_TYPELESS, R8G8_UNORM, R8G8_UINT, R8G8_SNORM, R8G8_SINT, R16_TYPELESS, R16_FLOAT, D16_UNORM, R16_UNORM, R16_UINT, R16_SNORM, R16_SINT, R8_TYPELESS, R8_UNORM, R8_UINT, R8_SNORM, R8_SINT, A8_UNORM, R1_UNORM, R9G9B9E5_SHAREDEXP, R8G8_B8G8_UNORM, G8R8_G8B8_UNORM, BC1_TYPELESS, BC1_UNORM, BC1_UNORM_SRGB, BC2_TYPELESS, BC2_UNORM, BC2_UNORM_SRGB, BC3_TYPELESS, BC3_UNORM, BC3_UNORM_SRGB, BC4_TYPELESS, BC4_UNORM, BC4_SNORM, BC5_TYPELESS, BC5_UNORM, BC5_SNORM, B5G6R5_UNORM, B5G5R5A1_UNORM, B8G8R8A8_UNORM, B8G8R8X8_UNORM, R10G10B10_XR_BIAS_A2_UNORM, B8G8R8A8_TYPELESS, B8G8R8A8_UNORM_SRGB, B8G8R8X8_TYPELESS, B8G8R8X8_UNORM_SRGB, BC6H_TYPELESS, BC6H_UF16, BC6H_SF16, BC7_TYPELESS, BC7_UNORM, BC7_UNORM_SRGB, AYUV, Y410, Y416, NV12, P010, P016, _420_OPAQUE, YUY2, Y210, Y216, NV11, AI44, IA44, P8, A8P8, B4G4R4A4_UNORM, P208, V208, V408, SAMPLER_FEEDBACK_MIN_MIP_OPAQUE, SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE, FORCE_UINT }; enum class ResourceDim : uint32_t { UNKNOWN, BUFFER, TEXTURE1D, TEXTURE2D, TEXTURE3D }; enum class MiscFlags2 : uint32_t { ALPHA_MODE_UNKNOWN = 0x0, ALPHA_MODE_STRAIGHT = 0x1, ALPHA_MODE_PREMULTIPLIED = 0x2, ALPHA_MODE_OPAQUE = 0x3, ALPHA_MODE_CUSTOM = 0x4, }; struct Header_DXT10 { Format dxgiFormat; ResourceDim resourceDimension; uint32_t miscFlag; uint32_t arraySize; MiscFlags2 miscFlags2; }; static_assert(sizeof(Header) == 128); cdm::Texture2D texture_loadDDS(const char* path, cdm::TextureFactory& factory, cdm::CommandBufferPool& pool, VkImageLayout outputLayout) { // lay out variables to be used Header header; memset(&header, 0xcccc, sizeof(header)); Header_DXT10 header10; memset(&header10, 0xcccc, sizeof(header10)); uint32_t width; uint32_t height; uint32_t mipmapCount; uint32_t blockSize; VkFormat format; uint32_t w; uint32_t h; std::vector<std::byte> buffer; // GLuint tid = 0; cdm::Texture2D texture; // open the DDS file for binary reading and get file size FILE* f; if ((f = fopen(path, "rb")) == 0) return texture; fseek(f, 0, SEEK_END); long file_size = ftell(f); fseek(f, 0, SEEK_SET); // allocate new unsigned char space with 4 (file code) + 124 (header size) // bytes read in 128 bytes from the file fread(&header, 1, sizeof(header), f); // compare the `DDS ` signature if (memcmp(&header, "DDS ", 4) != 0) goto exit; //* // extract height, width, and amount of mipmaps - yes it is stored height // then width height = header.dwHeight; width = header.dwWidth; mipmapCount = header.dwMipMapCount; factory.setWidth(width); factory.setHeight(height); // factory.setMipLevels(mipmapCount); factory.setMipLevels(1); size_t bufferSize = file_size - 128; // figure out what format to use for what fourCC file type it is // block size is about physical chunk storage of compressed data in file // (important) if (char(header.ddspf.dwFourCC[0]) == 'D') { switch (char(header.ddspf.dwFourCC[3])) { case '1': // DXT1 format = VK_FORMAT_BC1_RGBA_UNORM_BLOCK; blockSize = 8; break; case '3': // DXT3 format = VK_FORMAT_BC3_UNORM_BLOCK; blockSize = 16; break; case '5': // DXT5 format = VK_FORMAT_BC5_UNORM_BLOCK; blockSize = 16; break; case '0': // DX10 // unsupported, else will error // as it adds sizeof(struct DDS_HEADER_DXT10) between pixels // so, buffer = malloc((file_size - 128) - sizeof(struct // DDS_HEADER_DXT10)); fread(&header10, 1, sizeof(header10), f); if (header10.dxgiFormat == Format::R32G32B32A32_FLOAT) { format = VK_FORMAT_R32G32B32A32_SFLOAT; blockSize = 16; } else if (header10.dxgiFormat == Format::R32G32_FLOAT) { format = VK_FORMAT_R32G32_SFLOAT; blockSize = 8; } bufferSize -= sizeof(Header_DXT10); break; default: goto exit; } } else // BC4U/BC4S/ATI2/BC55/R8G8_B8G8/G8R8_G8B8/UYVY-packed/YUY2-packed // unsupported goto exit; factory.setFormat(format); // allocate new unsigned char space with file_size - (file_code + // header_size) magnitude read rest of file buffer.resize(bufferSize); // buffer = (unsigned char*)malloc(file_size - 128); // if(buffer == 0) // goto exit; fread(buffer.data(), 1, file_size, f); // prepare new incomplete texture // glGenTextures(1, &tid); // if(tid == 0) // goto exit; // texture = factory.createTexture2D(); // bind the texture // make it complete by specifying all needed parameters and ensuring all // mipmaps are filled // glBindTexture(GL_TEXTURE_2D, tid); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipMapCount-1); // // opengl likes array length of mipmaps glTexParameteri(GL_TEXTURE_2D, // GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, // GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // don't forget to // enable mipmaping glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, // GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, // GL_REPEAT); // prepare some variables unsigned int offset = 0; unsigned int size = 0; w = width; h = height; // loop through sending block at a time with the magic formula // upload to opengl properly, note the offset transverses the pointer // assumes each mipmap is 1/2 the size of the previous mipmap // std::cout << path << " has " << mipmapCount << " mipLevels" << // std::endl; std::cout << path << std::endl; VkBufferImageCopy region{}; // region.imageExtent.width = width; // region.imageExtent.height = height; region.imageExtent.depth = 1; region.bufferRowLength = 0; region.bufferImageHeight = 0; region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; region.imageSubresource.baseArrayLayer = 0; region.imageSubresource.layerCount = 1; // region.imageSubresource.mipLevel = 0; /* for (unsigned int i = 0; i < mipmapCount; i++) { if (w == 0 || h == 0) { // discard any odd mipmaps 0x1 0x2 resolutions std::cout << "odd mipmap " << i << "/" << mipmapCount << " (" << w << ";" << h << ")" << std::endl; // mipmapCount--; // continue; } size = ((w + 3) / 4) * ((h + 3) / 4) * blockSize; //VkBufferImageCopy region{}; region.imageExtent.width = w; region.imageExtent.height = h; //region.imageExtent.depth = 1; //region.bufferRowLength = 0; //region.bufferImageHeight = 0; //region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; //region.imageSubresource.baseArrayLayer = 0; //region.imageSubresource.layerCount = 1; region.imageSubresource.mipLevel = i; //if (i == mipmapCount - 2) { std::cout << "loading level " << i << "/" << mipmapCount << " (" << w << ";" << h << ")" << std::endl; factory.setWidth(w); factory.setHeight(h); texture = factory.createTexture2D(); region.imageSubresource.mipLevel = 0; texture.uploadData(buffer.data() + offset, size, region, VK_IMAGE_LAYOUT_UNDEFINED, outputLayout, pool); if (texture == nullptr) { std::cout << "what" << std::endl; } break; } // glCompressedTexImage2D(GL_TEXTURE_2D, i, format, w, h, 0, size, // buffer + offset); offset += size; w /= 2; h /= 2; } //*/ if (texture.image() == nullptr) { region.imageExtent.width = width; region.imageExtent.height = height; region.imageSubresource.mipLevel = 0; std::cout << "loading level " << 0 << "/" << mipmapCount << " (" << width << ";" << height << ")" << std::endl; //size = ((width + 3) / 4) * ((width + 3) / 4) * blockSize; size = width * width * blockSize; std::cout << "blockSize " << blockSize << std::endl; std::cout << "size " << ((width + 3) / 4) << " * " << ((width + 3) / 4) << " * " << blockSize << std::endl; factory.setWidth(width); factory.setHeight(height); texture = factory.createTexture2D(); texture.uploadData(buffer.data(), size, region, VK_IMAGE_LAYOUT_UNDEFINED, outputLayout, pool); } // discard any odd mipmaps, ensure a complete texture // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipMapCount-1); // unbind // glBindTexture(GL_TEXTURE_2D, 0); //*/ // easy macro to get out quick and uniform (minus like 15 lines of bulk) exit: // free(buffer); // free(header); fclose(f); // return tid; return texture; }
29.305026
98
0.603288
WubiCookie
cfff7dbf1afee58f5dd3a04d6f58c871730fa696
712
cpp
C++
cpp/stl/05_insert.cpp
Trickness/pl_learning
53c10490aed1ba4a02b14aae4890321ad099cc60
[ "Unlicense" ]
null
null
null
cpp/stl/05_insert.cpp
Trickness/pl_learning
53c10490aed1ba4a02b14aae4890321ad099cc60
[ "Unlicense" ]
null
null
null
cpp/stl/05_insert.cpp
Trickness/pl_learning
53c10490aed1ba4a02b14aae4890321ad099cc60
[ "Unlicense" ]
null
null
null
#include <iostream> #include <algorithm> #include <list> #include <vector> #include <iterator> using namespace std; int iArray[5] = {1,2,3,4,5}; void Display(list<int> &a , const char* s){ cout << s << endl; copy(a.begin(),a.end(), ostream_iterator<int>(cout, " ")); cout << endl; } int main(){ list<int> iList; // Copy iArray backwards into iList copy(iArray,iArray + 5, back_inserter(iList)); Display(iList,"Before find and copy"); // Locate value 3 in iList auto p = find(iList.begin(),iList.end(),3); // Copy first two iArray values to iList ahead of p copy(iArray, iArray + 2, inserter(iList,p)); Display(iList,"After find and copy"); return 0; }
22.25
62
0.629213
Trickness
3205b13f2b67c5c04db23a69f1ebf07a9e31ed5d
3,456
cpp
C++
1082_b.cpp
onexmaster/cp
b78b0f1e586d6977d86c97b32f48fed33f1469af
[ "Apache-2.0", "MIT" ]
null
null
null
1082_b.cpp
onexmaster/cp
b78b0f1e586d6977d86c97b32f48fed33f1469af
[ "Apache-2.0", "MIT" ]
null
null
null
1082_b.cpp
onexmaster/cp
b78b0f1e586d6977d86c97b32f48fed33f1469af
[ "Apache-2.0", "MIT" ]
null
null
null
// Created by Tanuj Jain #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int,int> pii; template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int INF = 0x3f3f3f3f; int knight_moves[8][2]={{-2,-1},{-1,-2},{1,-2},{2,-1},{-2,1},{-1,2},{1,2},{2,1}}; int moves[4][2]={{0,1},{0,-1},{1,0},{-1,0}}; struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("inputf.in","r",stdin); freopen("outputf.in","w",stdout); #endif int t; cin>>t; string s; cin>>s; vector<int>v(t,0); if(s[0]=='G') v[0]=1; else v[0]=0; for(int i=1;i<t;i++) { if(s[i]=='G' && s[i-1]=='G') v[i]=v[i-1]+1; if(s[i]=='G' && s[i-1]=='S') v[i]=1; } for(int i=t-2;i>=0;i--) { if(v[i]!=0) v[i]=max(v[i+1],v[i]); } int mx=*max_element(v.begin(),v.end()); //if can swap is >=2 then i can swap the current s with any of the g vector<int>prefix(t,0),suffix(t,0); if(s[0]=='G') prefix[0]=1; for(int i=1;i<t;i++) { if(s[i]=='G') prefix[i]=prefix[i-1]+1; else prefix[i]=prefix[i-1]; } if(s[t-1]=='G') suffix[t-1]=1; for(int i=t-2;i>=0;i--) { if(s[i]=='G') suffix[i]=suffix[i+1]+1; else suffix[i]=suffix[i+1]; } //print // for(int i=0;i<t;i++) // cout<<v[i]<<" "; // cout<<endl; // for(int i=0;i<t;i++) // cout<<prefix[i]<<" "; // cout<<endl; // for(int i=0;i<t;i++) // cout<<suffix[i]<<" "; // cout<<endl; //print over for(int i=1;i<t-1;i++) { if(v[i]==0 && v[i-1]!=0 && v[i+1]!=0) { //check if we have an extra g to swap beyond the 2 consective seq bool ok=false; int look_back=i-v[i-1]-1; int look_front=i+v[i+1]+1; //cout<<i<<" "<<look_back<<" "<<look_front<<endl; if(look_back>=0 && prefix[look_back]>0) ok=true; if(look_front<t && suffix[look_front]>0) ok=true; if(ok) mx=max(mx,v[i-1]+v[i+1]+1); else mx=max(mx,v[i-1]+v[i+1]); } //case 1 GSSGGGG //if here i replce the first S i get the size of 2 if I replace the second S i get 4 else if(v[i]==0 && v[i-1]!=0) { //we are extending the last segment int look_front=i; int look_back=i-v[i-1]-1; bool ok=false; if(suffix[look_front]>0) ok=true; if(look_back>=0 && prefix[look_back]>0) ok=true; if(ok) mx=max(mx,v[i-1]+1); } else if(v[i]==0 && v[i+1]!=0) { bool ok=false; int look_front=i+v[i+1]+1; int look_back=i; if(prefix[look_back]>0) ok=true; if(look_front<t && suffix[look_front]>0) ok=true; if(ok) mx=max(mx,v[i+1]+1); } } cout<<mx<<endl; return 0; }
23.510204
106
0.530093
onexmaster
3208de8949a1662d0acd4a62337215eb51f7ad50
1,728
hpp
C++
modules/core/feature/include/opengv2/feature/FeatureBase.hpp
MobilePerceptionLab/EventCameraCalibration
debd774ac989674b500caf27641b7ad4e94681e9
[ "Apache-2.0" ]
22
2021-08-06T03:21:03.000Z
2022-02-25T03:40:54.000Z
modules/core/feature/include/opengv2/feature/FeatureBase.hpp
MobilePerceptionLab/MultiCamCalib
2f0e94228c2c4aea7f20c26e3e8daa6321ce8022
[ "Apache-2.0" ]
1
2022-02-25T02:55:13.000Z
2022-02-25T15:18:45.000Z
modules/core/feature/include/opengv2/feature/FeatureBase.hpp
MobilePerceptionLab/MultiCamCalib
2f0e94228c2c4aea7f20c26e3e8daa6321ce8022
[ "Apache-2.0" ]
7
2021-08-11T12:29:35.000Z
2022-02-25T03:41:01.000Z
// // Created by huangkun on 2019/12/30. // #ifndef OPENGV2_FEATUREBASE_HPP #define OPENGV2_FEATUREBASE_HPP #include <memory> #include <Eigen/Eigen> #include <opengv2/landmark/LandmarkBase.hpp> namespace opengv2 { class FeatureBase { // TODO: inherit ObservationBase public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::shared_ptr<FeatureBase> Ptr; explicit FeatureBase(const Eigen::Ref<const Eigen::VectorXd> &loc) : locBackup(loc), landmark_(LandmarkBase::Ptr()), loc_(loc), bearingVector_(Eigen::VectorXd()) {} virtual ~FeatureBase() = default; inline LandmarkBase::Ptr landmark() const noexcept { return landmark_.lock(); } /** * @note Warning: Not thread safe. */ inline void setLandmark(const LandmarkBase::Ptr &lm) noexcept { landmark_ = lm; } inline const Eigen::VectorXd &location() const noexcept { return loc_; } /** * @note Warning: Not thread safe. */ virtual inline void setLocation(const Eigen::Ref<const Eigen::VectorXd> &loc) noexcept { loc_ = loc; } inline const Eigen::VectorXd &bearingVector() noexcept { return bearingVector_; } /** * @note Warning: Not thread safe. */ inline void setBearingVector(const Eigen::Ref<const Eigen::VectorXd> &bv) { bearingVector_ = bv; } Eigen::VectorXd locBackup; // backup protected: std::weak_ptr<LandmarkBase> landmark_; Eigen::VectorXd loc_; Eigen::VectorXd bearingVector_; }; } #endif //OPENGV2_FEATUREBASE_HPP
25.043478
111
0.600116
MobilePerceptionLab
320ad7582601aa0c407b9fc613bf6d96159f5191
518
hpp
C++
src/wrapper.hpp
Dreae/SourceLua
5737eaf3d77bbd715b258df78ab101265890662c
[ "Apache-2.0" ]
null
null
null
src/wrapper.hpp
Dreae/SourceLua
5737eaf3d77bbd715b258df78ab101265890662c
[ "Apache-2.0" ]
null
null
null
src/wrapper.hpp
Dreae/SourceLua
5737eaf3d77bbd715b258df78ab101265890662c
[ "Apache-2.0" ]
null
null
null
#ifndef _INCLUDE_WRAPPER #define _INCLUDE_WRAPPER #include <ISmmPlugin.h> #include "iplayerinfo.h" #if SOURCE_ENGINE <= SE_DARKMESSIAH /** * Wrap the CCommand class so our code looks the same on all engines. */ class CCommand { public: const char *ArgS() { return g_Engine->Cmd_Args(); } int ArgC() { return g_Engine->Cmd_Argc(); } const char *Arg(int index) { return g_Engine->Cmd_Argv(index); } }; #define CVAR_INTERFACE_VERSION VENGINE_CVAR_INTERFACE_VERSION #endif #endif // _INCLUDE_WRAPPER
15.69697
69
0.727799
Dreae
320ba053f76ac48a47fd3cf23ed89c7d478b06f7
3,891
cpp
C++
src/SplitFit.cpp
IWantedToBeATranslator/2D-Strip-Packing
4ee9a220f2e9debf775b020d961f0ba547f32636
[ "MIT" ]
1
2017-12-12T19:23:44.000Z
2017-12-12T19:23:44.000Z
src/SplitFit.cpp
IWantedToBeATranslator/2D-Strip-Packing
4ee9a220f2e9debf775b020d961f0ba547f32636
[ "MIT" ]
1
2016-04-20T18:47:05.000Z
2016-05-04T08:05:45.000Z
src/SplitFit.cpp
IWantedToBeATranslator/2D-Strip-Packing
4ee9a220f2e9debf775b020d961f0ba547f32636
[ "MIT" ]
1
2019-07-14T15:39:27.000Z
2019-07-14T15:39:27.000Z
#include "SplitFit.h" SplitFit::SplitFit() { int levelH[30] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; int levels = 1; int levelW[30] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; int levelHmin = 0; int levelRH[30] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; int levelsR = 1; int levelRW[30] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; spColorRectSprite bloxBuffer; spColorRectSprite *WideBlox = new spColorRectSprite[eCount]; spColorRectSprite *ThinBlox = new spColorRectSprite[eCount]; sortNonDecr(_bloxArray, bloxHeights, bloxWidths); int CountRest = 0; int Count12 = 0; FOR(i, 0, eCount) { if (_bloxArray[i]->getWidth() > clipWidth / 2) { WideBlox[Count12] = _bloxArray[i]; Count12++; } else { ThinBlox[CountRest] = _bloxArray[i]; CountRest++; } } FOR(i, 0, Count12) FOR(j, 0, Count12 - 1) if (WideBlox[j]->getWidth() < WideBlox[j + 1]->getWidth()) { bloxBuffer = WideBlox[j]; WideBlox[j] = WideBlox[j + 1]; WideBlox[j + 1] = bloxBuffer; } FOR(i, 0, Count12) { WideBlox[i]->addTween(Actor::TweenPosition(0, levelHmin), 500); levelHmin += WideBlox[i]->getHeight(); } int regionRW = 0; int regionRH = 0; int regionRX = 0; int regionRY = 0; int levelRHmin = 0; FOR(i, 0, Count12) { if (WideBlox[i]->getWidth() < 2 * clipWidth / 3) { regionRX = WideBlox[i]->getWidth(); regionRY = regionRH; regionRW = clipWidth - regionRX; regionRH = levelHmin - regionRH; break; } regionRH += WideBlox[i]->getHeight(); } int Rcheck = 0; int Restcheck = 0; int checker = 0; int RorO = 0; FOR(i, 0, CountRest) { if ((ThinBlox[i]->getHeight() <= regionRH) && (ThinBlox[i]->getWidth() <= regionRW)) RorO = 1; else RorO = 0; if (RorO) { if (Rcheck) { checker = 0; FOR(k, 0, levelsR) { if (regionRW - levelRW[k] >= ThinBlox[i]->getWidth() && !checker) { ThinBlox[i]->addTween(Actor::TweenPosition(regionRX + levelRW[k], regionRY + levelRH[k]), 500); levelRW[k] += ThinBlox[i]->getWidth(); checker = 1; } } if (!checker) { if (ThinBlox[i]->getHeight() <= regionRH - levelRHmin) { levelsR++; levelRHmin += ThinBlox[i]->getHeight(); levelRH[levelsR] = levelRHmin; ThinBlox[i]->addTween(Actor::TweenPosition(regionRX + levelRW[levelsR - 1], regionRY + levelRH[levelsR - 1]), 500); levelRW[levelsR - 1] += ThinBlox[i]->getWidth(); } else RorO = 0; } } else { Rcheck = 1; ThinBlox[i]->addTween(Actor::TweenPosition(regionRX, regionRY), 500); levelRH[1] = ThinBlox[i]->getHeight(); levelRW[0] = ThinBlox[i]->getWidth(); levelRHmin = levelRH[1]; checker = 0; } } if (!RorO) { if (Restcheck) { checker = 0; FOR(k, 0, levels) { if (clipWidth - levelW[k] >= ThinBlox[i]->getWidth() && !checker) { ThinBlox[i]->addTween(Actor::TweenPosition(levelW[k], levelH[k]), 500); levelW[k] += ThinBlox[i]->getWidth(); checker = 1; } } if (!checker) { levels++; levelHmin += ThinBlox[i]->getHeight(); levelH[levels] = levelHmin; ThinBlox[i]->addTween(Actor::TweenPosition(levelW[levels - 1], levelH[levels - 1]), 500); levelW[levels - 1] += ThinBlox[i]->getWidth(); } } else { Restcheck = 1; ThinBlox[i]->addTween(Actor::TweenPosition(0, levelHmin), 500); levelH[0] = levelHmin; levelH[1] = levelHmin + ThinBlox[i]->getHeight(); levelW[0] = ThinBlox[i]->getWidth(); levelHmin = levelH[1]; checker = 0; } } } algosHeights = levelHmin; updateState; }
24.018519
122
0.555641
IWantedToBeATranslator
320bf69707aaae190ebccb03cd7d07ac9c80ace7
677
cpp
C++
codes_of_questions/1007_DNA_sorting.cpp
Zaryob/algorithmsolutions
3f3270aed8274b5a7102afe5f21aa8da0245625e
[ "MIT" ]
5
2021-03-27T21:26:07.000Z
2021-12-23T22:15:37.000Z
codes_of_questions/1007_DNA_sorting.cpp
Zaryob/algorithmsolutions
3f3270aed8274b5a7102afe5f21aa8da0245625e
[ "MIT" ]
null
null
null
codes_of_questions/1007_DNA_sorting.cpp
Zaryob/algorithmsolutions
3f3270aed8274b5a7102afe5f21aa8da0245625e
[ "MIT" ]
null
null
null
#include <iostream> #include <bits/stdc++.h> using namespace std; struct dna { int pos; int key; string str; }; bool cmp(const dna &a, const dna &b) { if (a.key != b.key) { return a.key < b.key; } else { return a.pos < b.pos; } } int main() { int n, m, count; dna inv[110]; string str; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> str; count = 0; for (int j = 0; j < n - 1; j++) { for (int k = j + 1; k < n; k++) { if (str[j] > str[k]) count++; } } inv[i].key = count; inv[i].pos = i; inv[i].str = str; } sort(inv, inv + m, cmp); for (int i = 0; i < m; i++) { cout << inv[i].str << endl; } return 0; }
11.877193
36
0.478582
Zaryob
320e6f684dea75528b653b8b6172938f63e9d919
436
cpp
C++
src/Red/Data/JSON/Number.cpp
OutOfTheVoid/ProjectRed
801327283f5a302be130c90d593b39957c84cce5
[ "MIT" ]
1
2020-06-14T06:14:50.000Z
2020-06-14T06:14:50.000Z
src/Red/Data/JSON/Number.cpp
OutOfTheVoid/ProjectRed
801327283f5a302be130c90d593b39957c84cce5
[ "MIT" ]
null
null
null
src/Red/Data/JSON/Number.cpp
OutOfTheVoid/ProjectRed
801327283f5a302be130c90d593b39957c84cce5
[ "MIT" ]
null
null
null
#include <Red/Data/JSON/Number.h> Red::Data::JSON::Number :: Number ( double Value ): RefCounted ( 0 ), Value ( Value ) { } Red::Data::JSON::Number :: ~Number () { } Red::Data::JSON::IType :: DataType Red::Data::JSON::Number :: GetType () const { return kDataType_Number; } double Red::Data::JSON::Number :: Get () { return Value; } void Red::Data::JSON::Number :: Set ( double Value ) { this -> Value = Value; }
13.212121
78
0.605505
OutOfTheVoid
32112ab813d3aa682de5b9cba42ab4654fb1fb80
10,516
cpp
C++
work_addons/ofxXTween/src/ofxXTweener.cpp
jjongun/ofxAddons
44958f20e5dfcd71cfa5c5596aa0c480893894b8
[ "MIT" ]
null
null
null
work_addons/ofxXTween/src/ofxXTweener.cpp
jjongun/ofxAddons
44958f20e5dfcd71cfa5c5596aa0c480893894b8
[ "MIT" ]
null
null
null
work_addons/ofxXTween/src/ofxXTweener.cpp
jjongun/ofxAddons
44958f20e5dfcd71cfa5c5596aa0c480893894b8
[ "MIT" ]
null
null
null
#include "ofxXTweener.h" #pragma region Easing functions /***** LINEAR ****/ float Linear::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Linear::easeIn(float t, float b, float c, float d) { return c*t / d + b; } float Linear::easeOut(float t, float b, float c, float d) { return c*t / d + b; } float Linear::easeInOut(float t, float b, float c, float d) { return c*t / d + b; } /***** SINE ****/ float Sine::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Sine::easeIn(float t, float b, float c, float d) { return -c * cos(t / d * float(PI / 2)) + c + b; } float Sine::easeOut(float t, float b, float c, float d) { return c * sin(t / d * float(PI / 2)) + b; } float Sine::easeInOut(float t, float b, float c, float d) { return -c / 2 * float(cos(PI*t / d) - 1) + b; } /**** Quint ****/ float Quint::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Quint::easeIn(float t, float b, float c, float d) { return c*(t /= d)*t*t*t*t + b; } float Quint::easeOut(float t, float b, float c, float d) { return c*((t = t / d - 1)*t*t*t*t + 1) + b; } float Quint::easeInOut(float t, float b, float c, float d) { if ((t /= d / 2) < 1) return c / 2 * t*t*t*t*t + b; return c / 2 * ((t -= 2)*t*t*t*t + 2) + b; } /**** Quart ****/ float Quart::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Quart::easeIn(float t, float b, float c, float d) { return c*(t /= d)*t*t*t + b; } float Quart::easeOut(float t, float b, float c, float d) { return -c * ((t = t / d - 1)*t*t*t - 1) + b; } float Quart::easeInOut(float t, float b, float c, float d) { if ((t /= d / 2) < 1) return c / 2 * t*t*t*t + b; return -c / 2 * ((t -= 2)*t*t*t - 2) + b; } /**** Quad ****/ float Quad::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Quad::easeIn(float t, float b, float c, float d) { return c*(t /= d)*t + b; } float Quad::easeOut(float t, float b, float c, float d) { return -c *(t /= d)*(t - 2) + b; } float Quad::easeInOut(float t, float b, float c, float d) { if ((t /= d / 2) < 1) return ((c / 2)*(t*t)) + b; return -c / 2 * (((t - 2)*(--t)) - 1) + b; /* originally return -c/2 * (((t-2)*(--t)) - 1) + b; I've had to swap (--t)*(t-2) due to diffence in behaviour in pre-increment operators between java and c++, after hours of joy */ } /**** Expo ****/ float Expo::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Expo::easeIn(float t, float b, float c, float d) { return float((t == 0) ? b : c * pow(2, 10 * (t / d - 1)) + b); } float Expo::easeOut(float t, float b, float c, float d) { return float((t == d) ? b + c : c * (-pow(2, -10 * t / d) + 1) + b); } float Expo::easeInOut(float t, float b, float c, float d) { if (t == 0) return b; if (t == d) return b + c; if ((t /= d / 2) < 1) return float(c / 2 * pow(2, 10 * (t - 1)) + b); return float(c / 2 * (-pow(2, -10 * --t) + 2) + b); } /**** Elastic ****/ float Elastic::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Elastic::easeIn(float t, float b, float c, float d) { if (t == 0) return b; if ((t /= d) == 1) return b + c; float p = d*.3f; float a = c; float s = p / 4; float postFix = float(a*pow(2, 10 * (t -= 1))); // this is a fix, again, with post-increment operators return float(-(postFix * sin((t*d - s)*(2 * PI) / p)) + b); } float Elastic::easeOut(float t, float b, float c, float d) { if (t == 0) return b; if ((t /= d) == 1) return b + c; float p = d*.3f; float a = c; float s = p / 4; return float(a*pow(2, -10 * t) * sin((t*d - s)*(2 * PI) / p) + c + b); } float Elastic::easeInOut(float t, float b, float c, float d) { if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; float p = d*(.3f*1.5f); float a = c; float s = p / 4; if (t < 1) { float postFix = float(a*pow(2, 10 * (t -= 1))); // postIncrement is evil return float(-.5f*(postFix* sin((t*d - s)*(2 * PI) / p)) + b); } float postFix = float(a*pow(2, -10 * (t -= 1))); // postIncrement is evil return postFix * float(sin((t*d - s)*(2 * PI) / p)*.5f + c + b); } /**** Cubic ****/ float Cubic::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Cubic::easeIn(float t, float b, float c, float d) { return c*(t /= d)*t*t + b; } float Cubic::easeOut(float t, float b, float c, float d) { return c*((t = t / d - 1)*t*t + 1) + b; } float Cubic::easeInOut(float t, float b, float c, float d) { if ((t /= d / 2) < 1) return c / 2 * t*t*t + b; return c / 2 * ((t -= 2)*t*t + 2) + b; } /*** Circ ***/ float Circ::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Circ::easeIn(float t, float b, float c, float d) { return -c * (sqrt(1 - (t /= d)*t) - 1) + b; } float Circ::easeOut(float t, float b, float c, float d) { return c * sqrt(1 - (t = t / d - 1)*t) + b; } float Circ::easeInOut(float t, float b, float c, float d) { if ((t /= d / 2) < 1) return -c / 2 * (sqrt(1 - t*t) - 1) + b; return c / 2 * (sqrt(1 - t*(t -= 2)) + 1) + b; } /**** Bounce ****/ float Bounce::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Bounce::easeIn(float t, float b, float c, float d) { return c - easeOut(d - t, 0, c, d) + b; } float Bounce::easeOut(float t, float b, float c, float d) { if ((t /= d) < (1 / 2.75f)) { return c*(7.5625f*t*t) + b; } else if (t < (2 / 2.75f)) { float postFix = t -= (1.5f / 2.75f); return c*(7.5625f*(postFix)*t + .75f) + b; } else if (t < (2.5 / 2.75)) { float postFix = t -= (2.25f / 2.75f); return c*(7.5625f*(postFix)*t + .9375f) + b; } else { float postFix = t -= (2.625f / 2.75f); return c*(7.5625f*(postFix)*t + .984375f) + b; } } float Bounce::easeInOut(float t, float b, float c, float d) { if (t < d / 2) return easeIn(t * 2, 0, c, d) * .5f + b; else return easeOut(t * 2 - d, 0, c, d) * .5f + c*.5f + b; } /**** Back *****/ float Back::easeNone(float t, float b, float c, float d) { return c*t / d + b; } float Back::easeIn(float t, float b, float c, float d) { float s = 1.70158f; float postFix = t /= d; return c*(postFix)*t*((s + 1)*t - s) + b; } float Back::easeOut(float t, float b, float c, float d) { float s = 1.70158f; return c*((t = t / d - 1)*t*((s + 1)*t + s) + 1) + b; } float Back::easeInOut(float t, float b, float c, float d) { float s = 1.70158f; if ((t /= d / 2) < 1) return c / 2 * (t*t*(((s *= (1.525f)) + 1)*t - s)) + b; float postFix = t -= 2; return c / 2 * ((postFix)*t*(((s *= (1.525f)) + 1)*t + s) + 2) + b; } #pragma endregion //implementation Tweener Class********************************************************* #pragma region ofxXTween float ofxXTweener::runEquation(int transition, int equation, float t, float b, float c, float d) { float result = 0; if (equation == EASE_IN) { result = funcs[transition]->easeIn(t, b, c, d); } else if (equation == EASE_OUT) { result = funcs[transition]->easeOut(t, b, c, d); } else if (equation == EASE_IN_OUT) { result = funcs[transition]->easeInOut(t, b, c, d); } else if (equation == EASE_NONE) { result = funcs[transition]->easeNone(t, b, c, d); } return result; } void ofxXTweener::callTween(long duration, float start , float end, int draw_priority, Transition transition, Equation ease , TWEEN_CALLBACK update, DEFALUT_CALLBACK complete) { updateTween = update; completeTween = complete; this->duration = duration; this->start_value = start; this->end_value = end; this->draw_priority = draw_priority; this->transition = transition; this->ease = ease; zerofloat = 0.0f; updateTween(0.0f); StartTimer(draw_priority); } void ofxXTweener::Run(long duration, float start, float end, int draw_priority, Transition transition, Equation ease, TWEEN_CALLBACK update, DEFALUT_CALLBACK complete) { ofxXTweener* tween = new ofxXTweener(); tween->callTween(duration, start, end, draw_priority, transition, ease, update, [complete , tween]() { complete(); delete tween; }); } void ofxXTweener::Run(long duration, float start, float end, int draw_priority, Transition transition, Equation ease, TWEEN_CALLBACK update) { ofxXTweener* tween = new ofxXTweener(); tween->callTween(duration, start, end, draw_priority, transition, ease, update , [tween]() { delete tween; }); } void ofxXTweener::Run(long duration, float start, float end, Transition transition, Equation ease, TWEEN_CALLBACK update, DEFALUT_CALLBACK complete) { ofxXTweener* tween = new ofxXTweener(); tween->callTween(duration, start, end, ofEventOrder::OF_EVENT_ORDER_APP, transition, ease, update, [complete , tween]() { complete(); delete tween; }); } void ofxXTweener::RunZeroToOne(long duration, Transition transition, Equation ease, TWEEN_CALLBACK update, DEFALUT_CALLBACK complete) { ofxXTweener* tween = new ofxXTweener(); tween->callTween(duration, 0, 1, ofEventOrder::OF_EVENT_ORDER_APP , transition, ease, update, [complete, tween]() { complete(); delete tween; }); } void ofxXTweener::RunZeroToOne(long duration, Transition transition, Equation ease, TWEEN_CALLBACK update) { ofxXTweener* tween = new ofxXTweener(); tween->callTween(duration, 0, 1, ofEventOrder::OF_EVENT_ORDER_APP, transition, ease, update, [tween]() { delete tween; }); } void ofxXTweener::StartTimer(int draw_priority) { start_time = ofGetElapsedTimef(); ofAddListener(ofEvents().draw, this, &ofxXTweener::timeElapsed , draw_priority); } void ofxXTweener::StopTimer(int draw_priority) { ofRemoveListener(ofEvents().draw, this, &ofxXTweener::timeElapsed , draw_priority); } void ofxXTweener::timeElapsed(ofEventArgs &e) { float elapsed = ofGetElapsedTimef() - start_time; if (elapsed < 0.0001f) elapsed = 0; //float res = runEquation(CUBIC, EASE_OUT, elapsed, 0, 1, duration); float res = runEquation(transition, ease, elapsed, 0, 1, duration); res = ofMap(res, 0, 1, start_value, end_value); updateTween(res); if (elapsed > duration) { StopTimer(this->draw_priority); completeTween(); } } ofxXTweener::ofxXTweener() { zerofloat = 0.0f; this->funcs[LINEAR] = &nfLinear; this->funcs[SINE] = &nfSine; this->funcs[QUINT] = &nfQuint; this->funcs[QUART] = &nfQuart; this->funcs[QUAD] = &nfQuad; this->funcs[EXPO] = &nfExpo; this->funcs[ELASTIC] = &nfElastic; this->funcs[CUBIC] = &nfCubic; this->funcs[CIRC] = &nfCirc; this->funcs[BOUNCE] = &nfBounce; this->funcs[BACK] = &nfBack; lastTime = 0; } ofxXTweener::~ofxXTweener() { } #pragma endregion
27.103093
176
0.603461
jjongun
32121d63e621256eef322efc6b1f72fcfcc9a340
761
hpp
C++
src/protocols/wl/data_device.hpp
Link1J/Awning
4e35e092725d1688ac94f8473fb6bffd99a5cfa0
[ "MIT" ]
null
null
null
src/protocols/wl/data_device.hpp
Link1J/Awning
4e35e092725d1688ac94f8473fb6bffd99a5cfa0
[ "MIT" ]
null
null
null
src/protocols/wl/data_device.hpp
Link1J/Awning
4e35e092725d1688ac94f8473fb6bffd99a5cfa0
[ "MIT" ]
null
null
null
#pragma once #include <wayland-server.h> #include <unordered_map> #include <vector> #include <string> namespace Awning::Protocols::WL::Data_Device { extern const struct wl_data_device_interface interface; namespace Interface { void Start_Drag(struct wl_client* client, struct wl_resource* resource, struct wl_resource* source, struct wl_resource* origin, struct wl_resource* icon, uint32_t serial); void Set_Selection(struct wl_client* client, struct wl_resource* resource, struct wl_resource* source, uint32_t serial); void Release(struct wl_client* client, struct wl_resource* resource); } wl_resource* Create(struct wl_client* wl_client, uint32_t version, uint32_t id, struct wl_resource* seat); void Destroy(struct wl_resource* resource); }
34.590909
173
0.792378
Link1J
321459382e58a205aac83dd508d19189b1440df1
7,119
cpp
C++
Engine/Dependences/Framework/Depends/LuaBridge/Tests/Source/NamespaceTests.cpp
GlebShikovec/SREngine
bb806c3e4da06ef6fddee5b46ed5d2fca231be43
[ "MIT" ]
7
2020-10-16T11:34:27.000Z
2022-03-12T17:53:15.000Z
Engine/Dependences/Framework/Depends/LuaBridge/Tests/Source/NamespaceTests.cpp
Kiper220/SREngine
f1fa36b5ded1f489a9fdb59d8d4b40eb294ba9ec
[ "MIT" ]
1
2022-03-07T14:42:22.000Z
2022-03-07T14:42:22.000Z
Engine/Dependences/Framework/Depends/LuaBridge/Tests/Source/NamespaceTests.cpp
GlebShikovec/SREngine
bb806c3e4da06ef6fddee5b46ed5d2fca231be43
[ "MIT" ]
6
2021-05-06T15:09:52.000Z
2022-03-12T17:57:14.000Z
// https://github.com/vinniefalco/LuaBridge // // Copyright 2019, Dmitry Tarakanov // SPDX-License-Identifier: MIT #include "TestBase.h" struct NamespaceTests : TestBase { template <class T> T variable (const std::string& name) { runLua ("result = " + name); return result <T> (); } }; TEST_F (NamespaceTests, Variables) { int int_ = -10; auto any = luabridge::newTable (L); any ["a"] = 1; ASSERT_THROW ( luabridge::getGlobalNamespace (L).addProperty ("int", &int_), std::logic_error); runLua ("result = int"); ASSERT_TRUE (result ().isNil ()); luabridge::getGlobalNamespace (L) .beginNamespace ("ns") .addProperty ("int", &int_) .addProperty ("any", &any) .endNamespace (); ASSERT_EQ (-10, variable <int> ("ns.int")); ASSERT_EQ (any, variable <luabridge::LuaRef> ("ns.any")); runLua ("ns.int = -20"); ASSERT_EQ (-20, int_); runLua ("ns.any = {b = 2}"); ASSERT_TRUE (any.isTable ()); ASSERT_TRUE (any ["b"].isNumber ()); ASSERT_EQ (2, any ["b"].cast <int> ()); } TEST_F (NamespaceTests, ReadOnlyVariables) { int int_ = -10; auto any = luabridge::newTable (L); any ["a"] = 1; ASSERT_THROW ( luabridge::getGlobalNamespace (L).addProperty ("int", &int_), std::logic_error); runLua ("result = int"); ASSERT_TRUE (result ().isNil ()); luabridge::getGlobalNamespace (L) .beginNamespace ("ns") .addProperty ("int", &int_, false) .addProperty ("any", &any, false) .endNamespace (); ASSERT_EQ (-10, variable <int> ("ns.int")); ASSERT_EQ (any, variable <luabridge::LuaRef> ("ns.any")); ASSERT_THROW (runLua ("ns.int = -20"), std::runtime_error); ASSERT_EQ (-10, variable <int> ("ns.int")); ASSERT_THROW (runLua ("ns.any = {b = 2}"), std::runtime_error); ASSERT_EQ (any, variable <luabridge::LuaRef> ("ns.any")); } namespace { template <class T> struct Property { static T value; }; template <class T> T Property <T>::value; template <class T> void setProperty (const T& value) { Property <T>::value = value; } template <class T> const T& getProperty () { return Property <T>::value; } } // namespace TEST_F (NamespaceTests, Properties) { setProperty <int> (-10); ASSERT_THROW ( luabridge::getGlobalNamespace (L) .addProperty ("int", &getProperty <int>, &setProperty <int>), std::logic_error); runLua ("result = int"); ASSERT_TRUE (result ().isNil ()); luabridge::getGlobalNamespace (L) .beginNamespace ("ns") .addProperty ("int", &getProperty <int>, &setProperty <int>) .endNamespace (); ASSERT_EQ (-10, variable <int> ("ns.int")); runLua ("ns.int = -20"); ASSERT_EQ (-20, getProperty <int> ()); } TEST_F (NamespaceTests, ReadOnlyProperties) { setProperty <int> (-10); ASSERT_THROW ( luabridge::getGlobalNamespace (L) .addProperty ("int", &getProperty <int>), std::logic_error); runLua ("result = int"); ASSERT_TRUE (result ().isNil ()); luabridge::getGlobalNamespace (L) .beginNamespace ("ns") .addProperty ("int", &getProperty <int>) .endNamespace (); ASSERT_EQ (-10, variable <int> ("ns.int")); ASSERT_THROW ( runLua ("ns.int = -20"), std::runtime_error); ASSERT_EQ (-10, getProperty <int> ()); } namespace { template <class T> struct Storage { static T value; }; template <class T> T Storage <T>::value; template <class T> int getDataC (lua_State* L) { luabridge::Stack <T>::push (L, Storage <T>::value); return 1; } template <class T> int setDataC (lua_State* L) { Storage <T>::value = luabridge::Stack <T>::get (L, -1); return 0; } } // namespace TEST_F (NamespaceTests, Properties_ProxyCFunctions) { luabridge::getGlobalNamespace (L) .beginNamespace ("ns") .addProperty ("value", &getDataC <int>, &setDataC <int>) .endNamespace (); Storage <int>::value = 1; runLua ("ns.value = 2"); ASSERT_EQ (2, Storage <int>::value); Storage <int>::value = 3; runLua ("result = ns.value"); ASSERT_TRUE (result ().isNumber ()); ASSERT_EQ (3, result ().cast <int> ()); } TEST_F (NamespaceTests, Properties_ProxyCFunctions_ReadOnly) { luabridge::getGlobalNamespace (L) .beginNamespace ("ns") .addProperty ("value", &getDataC <int>) .endNamespace (); Storage <int>::value = 1; ASSERT_THROW (runLua ("ns.value = 2"), std::exception); ASSERT_EQ (1, Storage <int>::value); Storage <int>::value = 3; runLua ("result = ns.value"); ASSERT_TRUE (result ().isNumber ()); ASSERT_EQ (3, result ().cast <int> ()); } namespace { struct Class {}; } TEST_F (NamespaceTests, LuaStackIntegrity) { ASSERT_EQ (1, lua_gettop (L)); // Stack: ... { auto ns2 = luabridge::getGlobalNamespace (L) .beginNamespace ("namespace") .beginNamespace ("ns2"); ASSERT_EQ (4, lua_gettop (L)); // Stack: ..., global namespace table (gns), namespace table (ns), ns2 ns2.endNamespace (); // Stack: ... ASSERT_EQ (1, lua_gettop (L)); // Stack: ... } ASSERT_EQ (1, lua_gettop (L)); // Stack: ... { auto globalNs = luabridge::getGlobalNamespace (L); ASSERT_EQ (2, lua_gettop (L)); // Stack: ..., gns { auto ns = luabridge::getGlobalNamespace (L) .beginNamespace ("namespace"); // both globalNs an ns are active ASSERT_EQ (4, lua_gettop (L)); // Stack: ..., gns, gns, ns } ASSERT_EQ (2, lua_gettop (L)); // Stack: ..., gns { auto ns = globalNs .beginNamespace ("namespace"); // globalNs became inactive ASSERT_EQ (3, lua_gettop (L)); // Stack: ..., gns, ns } ASSERT_EQ (1, lua_gettop (L)); // Stack: ... ASSERT_THROW (globalNs.beginNamespace ("namespace"), std::exception); ASSERT_THROW (globalNs.beginClass <Class> ("Class"), std::exception); } { auto globalNs = luabridge::getGlobalNamespace (L) .beginNamespace ("namespace") .endNamespace (); // globalNs is active ASSERT_EQ (2, lua_gettop (L)); // Stack: ..., gns } ASSERT_EQ (1, lua_gettop (L)); // StacK: ... { auto cls = luabridge::getGlobalNamespace (L) .beginNamespace ("namespace") .beginClass <Class> ("Class"); ASSERT_EQ (6, lua_gettop (L)); // Stack: ..., gns, ns, const table, class table, static table { auto ns = cls.endClass (); ASSERT_EQ (3, lua_gettop (L)); // Stack: ..., gns, ns } ASSERT_EQ (1, lua_gettop (L)); // Stack: ... } ASSERT_EQ (1, lua_gettop (L)); // StacK: ... // Test class continuation { auto cls = luabridge::getGlobalNamespace (L) .beginNamespace ("namespace") .beginClass <Class> ("Class"); ASSERT_EQ (6, lua_gettop (L)); // Stack: ..., gns, ns, const table, class table, static table } ASSERT_EQ (1, lua_gettop (L)); // Stack: ... } #ifdef _M_IX86 // Windows 32bit only namespace { int __stdcall StdCall (int i) { return i + 10; } } // namespace TEST_F (NamespaceTests, StdCallFunctions) { luabridge::getGlobalNamespace (L) .addFunction ("StdCall", &StdCall); runLua ("result = StdCall (2)"); ASSERT_TRUE (result ().isNumber ()); ASSERT_EQ (12, result <int> ()); } #endif // _M_IX86
22.817308
105
0.617643
GlebShikovec
3216a0912083e09e1e4d9a060d8eb8d6739fa22f
5,810
cc
C++
cartographer/mapping_2d/scan_matching/ceres_scan_matcher.cc
linghusmile/Cartographer_-
28be85c1af353efae802cebb299b8d2486fbd800
[ "Apache-2.0" ]
2
2020-02-25T05:52:57.000Z
2021-03-18T08:28:38.000Z
cartographer/mapping_2d/scan_matching/ceres_scan_matcher.cc
linghusmile/Cartographer_-
28be85c1af353efae802cebb299b8d2486fbd800
[ "Apache-2.0" ]
null
null
null
cartographer/mapping_2d/scan_matching/ceres_scan_matcher.cc
linghusmile/Cartographer_-
28be85c1af353efae802cebb299b8d2486fbd800
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2016 The Cartographer Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "../mapping_2d/scan_matching/ceres_scan_matcher.h" #include <utility> #include <vector> #include "eigen3/Eigen/Core" #include "../common/ceres_solver_options.h" #include "../common/lua_parameter_dictionary.h" #include "../kalman_filter/pose_tracker.h" #include "../mapping_2d/probability_grid.h" #include "../mapping_2d/scan_matching/occupied_space_cost_functor.h" #include "../mapping_2d/scan_matching/rotation_delta_cost_functor.h" #include "../mapping_2d/scan_matching/translation_delta_cost_functor.h" #include "../transform/transform.h" #include "ceres/ceres.h" #include "glog/logging.h" /* * 用优化的方式进行scan-match。也就是说这里是用梯度下降的方式来进行scan-match * 因此这里的作用实际上和gmapping的hill-climb方法是差不多的。 * 这种局部优化的方法很容易陷入到局部极小值当中。因此这个方法能正常工作的前提是初始值离全局最优值比较近。 * 因此这个方法一般是用作其他方法的优化。 * 比如在cartographer中 在调用这个方法之前,首先会用CSM方法来进行搜索出来一个初值,然后再用这个优化的方法来进行优化 */ namespace cartographer { namespace mapping_2d { namespace scan_matching { proto::CeresScanMatcherOptions CreateCeresScanMatcherOptions( common::LuaParameterDictionary* const parameter_dictionary) { proto::CeresScanMatcherOptions options; options.set_occupied_space_cost_functor_weight( parameter_dictionary->GetDouble("occupied_space_cost_functor_weight")); options.set_previous_pose_translation_delta_cost_functor_weight( parameter_dictionary->GetDouble( "previous_pose_translation_delta_cost_functor_weight")); options.set_initial_pose_estimate_rotation_delta_cost_functor_weight( parameter_dictionary->GetDouble( "initial_pose_estimate_rotation_delta_cost_functor_weight")); options.set_covariance_scale( parameter_dictionary->GetDouble("covariance_scale")); *options.mutable_ceres_solver_options() = common::CreateCeresSolverOptionsProto( parameter_dictionary->GetDictionary("ceres_solver_options").get()); return options; } CeresScanMatcher::CeresScanMatcher( const proto::CeresScanMatcherOptions& options) : options_(options), ceres_solver_options_( common::CreateCeresSolverOptions(options.ceres_solver_options())) { ceres_solver_options_.linear_solver_type = ceres::DENSE_QR; } CeresScanMatcher::~CeresScanMatcher() {} void CeresScanMatcher::Match(const transform::Rigid2d& previous_pose, const transform::Rigid2d& initial_pose_estimate, const sensor::PointCloud2D& point_cloud, const ProbabilityGrid& probability_grid, transform::Rigid2d* const pose_estimate, kalman_filter::Pose2DCovariance* const covariance, ceres::Solver::Summary* const summary) const { double ceres_pose_estimate[3] = {initial_pose_estimate.translation().x(), initial_pose_estimate.translation().y(), initial_pose_estimate.rotation().angle()}; ceres::Problem problem; CHECK_GT(options_.occupied_space_cost_functor_weight(), 0.); //构造残差--栅格 problem.AddResidualBlock( new ceres::AutoDiffCostFunction<OccupiedSpaceCostFunctor, ceres::DYNAMIC, 3>( new OccupiedSpaceCostFunctor( options_.occupied_space_cost_functor_weight() / std::sqrt(static_cast<double>(point_cloud.size())), point_cloud, probability_grid), point_cloud.size()), nullptr, ceres_pose_estimate); CHECK_GT(options_.previous_pose_translation_delta_cost_functor_weight(), 0.); //构造残差--平移 problem.AddResidualBlock( new ceres::AutoDiffCostFunction<TranslationDeltaCostFunctor, 2, 3>( new TranslationDeltaCostFunctor( options_.previous_pose_translation_delta_cost_functor_weight(), previous_pose)), nullptr, ceres_pose_estimate); CHECK_GT(options_.initial_pose_estimate_rotation_delta_cost_functor_weight(), 0.); //构造残差--旋转 problem.AddResidualBlock( new ceres::AutoDiffCostFunction<RotationDeltaCostFunctor, 1, 3>(new RotationDeltaCostFunctor( options_.initial_pose_estimate_rotation_delta_cost_functor_weight(), ceres_pose_estimate[2])), nullptr, ceres_pose_estimate); //求解器 ceres::Solve(ceres_solver_options_, &problem, summary); //优化完毕之后得到的最优位姿 *pose_estimate = transform::Rigid2d( {ceres_pose_estimate[0], ceres_pose_estimate[1]}, ceres_pose_estimate[2]); //计算位姿的方差 ceres::Covariance::Options options; ceres::Covariance covariance_computer(options); std::vector<std::pair<const double*, const double*>> covariance_blocks; covariance_blocks.emplace_back(ceres_pose_estimate, ceres_pose_estimate); CHECK(covariance_computer.Compute(covariance_blocks, &problem)); double ceres_covariance[3 * 3]; covariance_computer.GetCovarianceBlock(ceres_pose_estimate, ceres_pose_estimate, ceres_covariance); *covariance = Eigen::Map<kalman_filter::Pose2DCovariance>(ceres_covariance); *covariance *= options_.covariance_scale(); } } // namespace scan_matching } // namespace mapping_2d } // namespace cartographer
40.068966
80
0.724269
linghusmile
3217a82afab606ad838675c40d023585b0b4a668
10,699
hpp
C++
cpp/src/test/test_position_manipulation.hpp
arthur-bit-monnot/fire-rs-saop
321e16fceebf44e8e97b482c24f37fbf6dd7d162
[ "BSD-2-Clause" ]
13
2018-11-19T15:51:23.000Z
2022-01-16T11:24:21.000Z
cpp/src/test/test_position_manipulation.hpp
fire-rs-laas/fire-rs-saop
321e16fceebf44e8e97b482c24f37fbf6dd7d162
[ "BSD-2-Clause" ]
14
2017-10-12T16:19:19.000Z
2018-03-12T12:07:56.000Z
cpp/src/test/test_position_manipulation.hpp
fire-rs-laas/fire-rs-saop
321e16fceebf44e8e97b482c24f37fbf6dd7d162
[ "BSD-2-Clause" ]
4
2018-03-12T12:28:55.000Z
2021-07-07T18:32:17.000Z
/* Copyright (c) 2017, CNRS-LAAS 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <iostream> #include "../ext/dubins.h" #include "../core/trajectory.hpp" #include "../core/raster.hpp" #include "../core/uav.hpp" #include "../vns/vns_interface.hpp" #include "../vns/factory.hpp" #include "../vns/neighborhoods/dubins_optimization.hpp" #include "../core/fire_data.hpp" #include <boost/test/included/unit_test.hpp> namespace SAOP { namespace Test { using namespace boost::unit_test; UAV uav("test", 10., 32. * M_PI / 180, 0.1); void test_single_point_to_observe() { // all points ignited at time 0, except ont at time 100 DRaster ignitions(100, 100, 0, 0, 25); ignitions.set(10, 10, 100); DRaster elevation(100, 100, 0, 0, 25); auto fd = make_shared<FireData>(ignitions, elevation); // only interested in the point ignited at time 100 vector<TrajectoryConfig> confs{TrajectoryConfig(uav, 100)}; Plan p(confs, fd, TimeWindow{90, 110}); auto vns = SAOP::build_default(); auto res = vns->search(p, 0, 1); // BOOST_CHECK(res.final()); cout << "SUCCESS" << endl; } void test_many_points_to_observe() { // circular firedata spread DRaster ignitions(100, 100, 0, 0, 1); for (size_t x = 0; x < 100; x++) { for (size_t y = 0; y < 100; y++) { ignitions.set(x, y, sqrt(pow((double) x - 50, 2) + pow((double) y - 50, 2))); } } DRaster elevation(100, 100, 0, 0, 1); auto fd = make_shared<FireData>(ignitions, elevation); vector<TrajectoryConfig> confs{TrajectoryConfig(uav, 10)}; Plan p(confs, fd, TimeWindow{0, 110}); auto vns = SAOP::build_default(); auto res = vns->search(std::move(p), 0, 1); // BOOST_CHECK(Plan(res.final())); cout << "SUCCESS" << endl; } void test_many_points_to_observe_with_start_end_positions() { Waypoint3d start(5, 5, 0, 0); Waypoint3d end(11, 11, 0, 0); // circular firedata spread DRaster ignitions(100, 100, 0, 0, 1); for (size_t x = 0; x < 100; x++) { for (size_t y = 0; y < 100; y++) { ignitions.set(x, y, sqrt(pow((double) x - 50, 2) + pow((double) y - 50, 2))); } } DRaster elevation(100, 100, 0, 0, 1); auto fd = make_shared<FireData>(ignitions, elevation); vector<TrajectoryConfig> confs{TrajectoryConfig( uav, start, end, 10)}; Plan p(confs, fd, TimeWindow{0, 110}); auto vns = SAOP::build_default(); auto res = vns->search(std::move(p), 0, 1); // BOOST_CHECK(Plan(res.final())); const auto& traj = res.final().trajectories()[0]; //ASSERT(traj[0] == start); //ASSERT(traj[traj.size()-1] == end); BOOST_CHECK(traj.insertion_range_start() == 1); BOOST_CHECK(traj.insertion_range_end() == traj.size() - 2); cout << "SUCCESS" << endl; } void test_segment_rotation() { for (size_t i = 0; i < 100; i++) { Waypoint wp(drand(-100000, 10000), drand(-100000, 100000), drand(-10 * M_PI, 10 * M_PI)); Segment seg(wp, drand(0, 1000)); Segment seg_rotated = uav.rotate_on_visibility_center(seg, drand(-10 * M_PI, 10 * M_PI)); Segment seg_back = uav.rotate_on_visibility_center(seg_rotated, wp.dir); BOOST_CHECK(seg == seg_back); } } void test_projection_on_firefront() { // uniform propagation along the y axis { DRaster ignitions(100, 100, 0, 0, 1); for (size_t x = 0; x < 100; x++) { for (size_t y = 0; y < 100; y++) { ignitions.set(x, y, y); } } DRaster elevation(100, 100, 0, 0, 1); FireData fd(ignitions, elevation); auto res = fd.project_on_fire_front(Cell{1, 1}, 50.5); BOOST_CHECK(res && res->y == 50); auto res_back = fd.project_on_fire_front(Cell{79, 1}, 50.5); BOOST_CHECK(res_back && res_back->y == 50); } // uniform propagation along the x axis { DRaster ignitions(10, 10, 0, 0, 1); for (size_t x = 0; x < 10; x++) { for (size_t y = 0; y < 10; y++) { ignitions.set(x, y, x); } } DRaster elevation(10, 10, 0, 0, 1); FireData fd(ignitions, elevation); auto res = fd.project_on_fire_front(Cell{1, 1}, 5.5); BOOST_CHECK(res && res->x == 5); auto res_back = fd.project_on_fire_front(Cell{7, 1}, 5.5); BOOST_CHECK(res_back && res_back->x == 5); } // circular propagation center on (50,50) { auto dist = [](size_t x, size_t y) { return sqrt(pow((double) x - 50., 2.) + pow((double) y - 50., 2.)); }; DRaster ignitions(100, 100, 0, 0, 1); for (size_t x = 0; x < 100; x++) { for (size_t y = 0; y < 100; y++) { ignitions.set(x, y, dist(x, y)); } } DRaster elevation(100, 100, 0, 0, 1); FireData fd(ignitions, elevation); for (size_t i = 0; i < 100; i++) { const size_t x = rand(0, 100); const size_t y = rand(0, 100); auto res = fd.project_on_fire_front(Cell{x, y}, 25); BOOST_CHECK(res && abs(dist(res->x, res->y) - 25) < 1.5); } } } void test_trajectory_as_waypoints() { Trajectory traj((TrajectoryConfig(uav))); traj.sampled(2); } void test_trajectory_slice() { TimeWindow tw1 = TimeWindow(10, 300); TrajectoryConfig config1 = TrajectoryConfig(uav, tw1.start, tw1.end); Trajectory traj = Trajectory(config1); traj.append_segment(Segment3d(Waypoint3d(0, 0, 0, 0))); traj.append_segment(Segment3d(Waypoint3d(100, 100, 0, 0), 50)); traj.append_segment(Segment3d(Waypoint3d(300, 200, 0, 0), 50)); traj.append_segment(Segment3d(Waypoint3d(500, 500, 0, 0))); Trajectory sliced1 = traj.slice(TimeWindow(tw1.start + 1, tw1.end - 1)); Trajectory sliced2 = traj.slice(TimeWindow(tw1.start + 1, 85)); BOOST_CHECK(sliced1.size() == traj.size() - 1); BOOST_CHECK(sliced2.size() == traj.size() - 2); BOOST_CHECK_CLOSE(traj.start_time(1), sliced1.start_time(0), 0.1); BOOST_CHECK_CLOSE(traj.start_time(1), sliced2.start_time(0), 0.1); BOOST_CHECK_CLOSE(traj.start_time(3), sliced1.start_time(2), 0.1); BOOST_CHECK_CLOSE(traj.start_time(2), sliced2.start_time(1), 0.1); } void test_time_window_order() { double s = 10; double e = 25; TimeWindow tw1 = TimeWindow(s, e); TimeWindow tw2 = TimeWindow(e, s); BOOST_CHECK(tw1.start == s); BOOST_CHECK(tw1.end == e); BOOST_CHECK(tw1.start == tw2.start); BOOST_CHECK(tw1.end == tw1.end); } void test_time_window() { double s = 10; double e = 25; TimeWindow tw1 = TimeWindow(s, e); TimeWindow tw2 = TimeWindow(e, s); TimeWindow tw3 = TimeWindow(s - 1, e); TimeWindow tw4 = TimeWindow(s, e + 1); BOOST_CHECK(tw1 == tw2); BOOST_CHECK(tw1 != tw3); BOOST_CHECK(tw3.contains(tw1)); BOOST_CHECK(tw3.contains(tw1.center())); BOOST_CHECK(tw3.intersects(tw4)); BOOST_CHECK(tw3.union_with(tw1) == tw3); BOOST_CHECK(tw4.intersection_with(tw3) == tw1); auto empty_intersect = TimeWindow(s - 1, s).intersection_with(TimeWindow(e, e + 1)); BOOST_CHECK(empty_intersect.is_empty()); } test_suite* position_manipulation_test_suite() { test_suite* ts2 = BOOST_TEST_SUITE("position_manipulation_tests"); srand(time(0)); ts2->add(BOOST_TEST_CASE(&test_trajectory_slice)); ts2->add(BOOST_TEST_CASE(&test_time_window_order)); ts2->add(BOOST_TEST_CASE(&test_time_window)); ts2->add(BOOST_TEST_CASE(&test_trajectory_as_waypoints)); ts2->add(BOOST_TEST_CASE(&test_segment_rotation)); ts2->add(BOOST_TEST_CASE(&test_single_point_to_observe)); ts2->add(BOOST_TEST_CASE(&test_many_points_to_observe)); ts2->add(BOOST_TEST_CASE(&test_many_points_to_observe_with_start_end_positions)); ts2->add(BOOST_TEST_CASE(&test_projection_on_firefront)); return ts2; } } }
38.210714
105
0.549397
arthur-bit-monnot
321c3ffcbfc764ede04835b683800520a8bdff0b
404
cpp
C++
state_mach.cpp
davitkalantaryan/fork-cpp-raft
f8d08a645ba541d42c6f2db54137fbfa53b5908d
[ "BSD-3-Clause" ]
20
2015-01-19T02:12:50.000Z
2020-12-09T17:02:42.000Z
state_mach.cpp
davitkalantaryan/fork-cpp-raft
f8d08a645ba541d42c6f2db54137fbfa53b5908d
[ "BSD-3-Clause" ]
1
2015-12-15T11:28:19.000Z
2015-12-15T11:28:19.000Z
state_mach.cpp
davitkalantaryan/fork-cpp-raft
f8d08a645ba541d42c6f2db54137fbfa53b5908d
[ "BSD-3-Clause" ]
9
2015-08-20T15:35:17.000Z
2020-07-17T02:26:35.000Z
#include "state_mach.h" using namespace Raft; State::State() { } State::~State() { } bool State::is_follower() { return d_state == RAFT_STATE_FOLLOWER; } bool State::is_leader() { return d_state == RAFT_STATE_LEADER; } bool State::is_candidate() { return d_state == RAFT_STATE_CANDIDATE; } void State::set(RAFT_STATE state) { d_state = state; } RAFT_STATE State::get() { return d_state; }
14.962963
54
0.693069
davitkalantaryan
321e52d806270a22769c244eecdbf204b18e506a
1,539
cpp
C++
samples/webserver.cpp
nodenative/nodenative
cf988c9399e0793b1b8c29a8ffd09e910d1a0cb3
[ "MIT" ]
16
2016-03-16T22:16:18.000Z
2021-04-05T04:46:38.000Z
samples/webserver.cpp
nodenative/nodenative
cf988c9399e0793b1b8c29a8ffd09e910d1a0cb3
[ "MIT" ]
11
2016-03-16T22:02:26.000Z
2021-04-04T02:20:51.000Z
samples/webserver.cpp
nodenative/nodenative
cf988c9399e0793b1b8c29a8ffd09e910d1a0cb3
[ "MIT" ]
5
2016-03-22T14:03:34.000Z
2021-01-06T18:08:46.000Z
#include <iostream> #include <native/native.hpp> using namespace native; using namespace http; int main() { std::shared_ptr<Loop> loop = Loop::Create(); std::shared_ptr<Server> server = Server::Create(loop); server->get("/", [](std::shared_ptr<ServerConnection> connection) -> Future<void> { // some initial work on the main thread std::weak_ptr<ServerConnection> connectionWeak = connection; ServerResponse &res = connection->getResponse(); res.setStatus(200); res.setHeader("Content-Type", "text/plain"); // wait... I have some async work too. I will update you when I'm done. return worker([]() { // Some work on the thread pool to keep the main thread free std::chrono::milliseconds time(2000); std::this_thread::sleep_for(time); }) .then([]() { // and some work on the main thread to sync data and avoid race condition std::chrono::milliseconds time(100); std::this_thread::sleep_for(time); }) .finally([connectionWeak]() { // in the end send the response. connectionWeak.lock()->getResponse().end("C++ FTW\n"); }); }); server->onError([](const Error &err) { std::cout << "error name: " << err.name(); }); if (!server->listen("0.0.0.0", 8080)) { std::cout << "cannot start server. Check the port 8080 if it is free.\n"; return 1; // Failed to run server. } std::cout << "Server running at http://0.0.0.0:8080/" << std::endl; return run(); }
34.2
87
0.606888
nodenative
32234a55fff0457a3399490a0db7f51162085257
437
cc
C++
platform/client_native_pixmap_factory_qt.cc
tworaz/ozone_qt
a015069d3d68cfe0826e76977c974baa1f459834
[ "MIT" ]
null
null
null
platform/client_native_pixmap_factory_qt.cc
tworaz/ozone_qt
a015069d3d68cfe0826e76977c974baa1f459834
[ "MIT" ]
null
null
null
platform/client_native_pixmap_factory_qt.cc
tworaz/ozone_qt
a015069d3d68cfe0826e76977c974baa1f459834
[ "MIT" ]
null
null
null
// Copyright 2015 Piotr Tworek. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ozone_qt/platform/client_native_pixmap_factory_qt.h" #include "ui/ozone/common/stub_client_native_pixmap_factory.h" namespace ui { ClientNativePixmapFactory* CreateClientNativePixmapFactoryQt() { return CreateStubClientNativePixmapFactory(); } } // namespace ui
27.3125
73
0.796339
tworaz
322399a6ddafb4e2f67c58e3d8b574741c2d0f87
847
cpp
C++
pvxmatching/utils/rbitmap.cpp
igarashi/matchingwithvcmap
b1bc5441d7b45622edf58f0597f478c07ee6db75
[ "MIT" ]
null
null
null
pvxmatching/utils/rbitmap.cpp
igarashi/matchingwithvcmap
b1bc5441d7b45622edf58f0597f478c07ee6db75
[ "MIT" ]
null
null
null
pvxmatching/utils/rbitmap.cpp
igarashi/matchingwithvcmap
b1bc5441d7b45622edf58f0597f478c07ee6db75
[ "MIT" ]
null
null
null
// // Created by Yuki Igarashi on 2017/05/23. // #include "rbitmap.hpp" namespace utils { RBitmap::RBitmap(int size) : size_(size) { if (size > MAX_BIT_SIZE) throw "Exception: size exceed MAX_BIT_SIZE while creating bitmap. (Use longer int as Bitmap instead.)"; } void RBitmap::set_value(int symbol, size_t caseId) { temp_bitmap_[symbol].set(caseId); temp_default_bitmap_.set(caseId); } void RBitmap::compile() { auto default_mask = temp_default_bitmap_; default_mask ^= ((1 << size_) - 1); default_mask_ = default_mask.to_ulong(); for (auto symbol : temp_bitmap_) { bitmap_[symbol.first] = default_mask_ | symbol.second.to_ulong(); } } RBitmap::Bitmap RBitmap::get_filter(int value) const { auto exists = bitmap_.find(value); if (exists != bitmap_.end()) return exists->second; return default_mask_; } }
22.891892
107
0.702479
igarashi
7a92578132cd9170dd4baece915ccdaab616239c
730
cpp
C++
TCP_ServerClient/AsyncTCPServer_Factory.cpp
aliyavuzkahveci/tcp_serverclient
c37111e21069670972f0fcd08584710af42f591a
[ "MIT" ]
null
null
null
TCP_ServerClient/AsyncTCPServer_Factory.cpp
aliyavuzkahveci/tcp_serverclient
c37111e21069670972f0fcd08584710af42f591a
[ "MIT" ]
null
null
null
TCP_ServerClient/AsyncTCPServer_Factory.cpp
aliyavuzkahveci/tcp_serverclient
c37111e21069670972f0fcd08584710af42f591a
[ "MIT" ]
null
null
null
#include "AsyncTCPServer_Factory.h" #include "AsyncTCPServer_Impl.h" namespace AsyncTCP { AsyncTCPServer_Factory_Ptr AsyncTCPServer_Factory::m_instance = nullptr; AsyncTCPServer_Factory_Ptr& AsyncTCPServer_Factory::getInstance() { if (m_instance == nullptr) m_instance = std::unique_ptr<AsyncTCPServer_Factory>(new AsyncTCPServer_Factory()); return m_instance; } AsyncTCPServer_Factory::AsyncTCPServer_Factory() { } AsyncTCPServer_Factory::~AsyncTCPServer_Factory() { } AsyncTCPServer_Ptr AsyncTCPServer_Factory::createAsyncTCPServer( AsyncTCPServer_Subscriber_Ptr subscriberPtr, short port) { return AsyncTCPServer_Ptr(new AsyncTCPServer_Impl(subscriberPtr, port)); } }
24.333333
87
0.773973
aliyavuzkahveci
7a9a54ee622437b984766c046bb2611a0d0565df
16,941
cpp
C++
src/helpers/ExtraHelpers.cpp
mdhooge/qt-handlebars
e950052e0e758413ee09a9c91499481a3ea51b11
[ "MIT" ]
1
2022-01-11T19:57:39.000Z
2022-01-11T19:57:39.000Z
src/helpers/ExtraHelpers.cpp
mdhooge/qt-handlebars
e950052e0e758413ee09a9c91499481a3ea51b11
[ "MIT" ]
null
null
null
src/helpers/ExtraHelpers.cpp
mdhooge/qt-handlebars
e950052e0e758413ee09a9c91499481a3ea51b11
[ "MIT" ]
2
2016-11-17T12:35:03.000Z
2022-01-11T19:57:19.000Z
#include "ExtraHelpers.h" #include <QChar> #include <QDateTime> #include <QDir> #include <QFile> #include <QObject> #include <QTextStream> #include "HandlebarsParser.h" namespace Handlebars { const escape_fn fn_noEscape, fn_htmlEscape { [] (const QString& str ) { return str.toHtmlEscaped(); } }; void registerAllHelpers( Parser & parser ) { registerBitwiseHelpers( parser ); registerBooleanHelpers( parser ); registerFileHelpers( parser ); registerIntegerHelpers( parser ); registerPropertyHelpers( parser ); registerStringHelpers( parser ); } // ### // ### Bit-wise Helpers // ### static QVariant integerTypes_bit( const QString& tmplate, int bits ) { if( bits <= 8 ) return tmplate.arg( "8" ); if( bits <= 16 ) return tmplate.arg( "16" ); if( bits <= 32 ) return tmplate.arg( "32" ); return tmplate.arg( "64" ); } void registerBitwiseHelpers( Parser & parser ) { parser.registerHelper( "bit-mask", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { int shift = 64 - params.value( 0 ).toInt(); uint64_t mask { UINT64_MAX >> shift }; QString out( "0x" ); out.append( QString::number( mask, 16 ).toUpper() ); return out; } ); parser.registerHelper( "int_fast", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { if( params.size() != 2 ) return QVariant(); // RTFM int bits = params.at( 1 ).toInt(); if( params.at( 0 ).toString().toUpper() == "BYTE" ) bits *= 8; return integerTypes_bit( "int_fast%1_t", bits ); } ); parser.registerHelper( "int_least", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { if( params.size() != 2 ) return QVariant(); // RTFM int bits = params.at( 1 ).toInt(); if( params.at( 0 ).toString().toUpper() == "BYTE" ) bits *= 8; return integerTypes_bit( "int_least%1_t", bits ); } ); parser.registerHelper( "uint_fast", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { if( params.size() != 2 ) return QVariant(); // RTFM int bits = params.at( 1 ).toInt(); if( params.at( 0 ).toString().toUpper() == "BYTE" ) bits *= 8; return integerTypes_bit( "uint_fast%1_t", bits ); } ); parser.registerHelper( "uint_least", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { if( params.size() != 2 ) return QVariant(); // RTFM int bits = params.at( 1 ).toInt(); if( params.at( 0 ).toString().toUpper() == "BYTE" ) bits *= 8; return integerTypes_bit( "uint_least%1_t", bits ); } ); } // ### // ### Boolean Helpers // ### void registerBooleanHelpers( Parser & parser ) { parser.registerHelper( "==", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { return params.value( 0 ) == params.value( 1 ); } ); parser.registerHelper( "!=", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { return params.value( 0 ) != params.value( 1 ); } ); parser.registerHelper( "<", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { return params.value( 0 ) < params.value( 1 ); } ); parser.registerHelper( "<=", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { return params.value( 0 ) <= params.value( 1 ); } ); parser.registerHelper( ">", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { return params.value( 0 ) > params.value( 1 ); } ); parser.registerHelper( ">=", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { return params.value( 0 ) >= params.value( 1 ); } ); parser.registerHelper( "AND", [] ( const RenderingContext & c, const helper_params & params, const helper_options & ) { bool r = true; for( auto v : params ) { r = r && c.propertyAsBool( v ); if( ! r ) break; } return r; } ); parser.registerHelper( "NOT", [] ( const RenderingContext & c, const helper_params & params, const helper_options & ) { return ! c.propertyAsBool( params.value( 0 )); } ); parser.registerHelper( "OR", [] ( const RenderingContext & c, const helper_params & params, const helper_options & ) { bool r = false; for( auto v : params ) { r = r || c.propertyAsBool( v ); if( r ) break; } return r; } ); } // ### // ### File Helpers // ### /** * Concatenate all params to create file path & name */ static QString pathConcatenate( const helper_params & params ) { QString filepath; for( auto element : params ) filepath += element.toString(); return filepath; } /** * Recursively copy content of a folder to another folder. * * - source must be an existing folder. */ static void copyRecursively( const QString& source, const QString& target ) { QDir sourceDir( source ); QDir targetDir( target ); // Create target folder if needed if( ! targetDir.exists() ) targetDir.mkpath( "." ); // Loop & copy auto list = sourceDir.entryInfoList( QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable ); for( int i = 0; i < list.size(); ++i ) { // Create paths auto fileInfo = list.at( i ); QString filename( fileInfo.fileName() ), sourcePath( sourceDir.filePath( filename )), targetPath( targetDir.filePath( filename )); // Copy if( fileInfo.isDir() ) copyRecursively( sourcePath, targetPath ); else QFile::copy( sourcePath, targetPath ); } } void registerFileHelpers( Parser & parser ) { parser.registerHelper( "cd", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { QDir::setCurrent( pathConcatenate( params )); return QVariant(); } ); parser.registerHelper( "copy_into-current-folder_from", [] ( const RenderingContext & context, const helper_params & params, const helper_options & options) { // Check source QString source( pathConcatenate( params )); QFileInfo sourceFileInfo( source ); if( ! sourceFileInfo.exists() ) { context.warning( QString( "Handlebars.helper.copy: Source \"%1\" doesn't exist." ).arg( source )); return QVariant(); } // "contentOnly" option bool contentOnly = options.value( "contentOnly" ).toBool(); // Copy file or folder if ( sourceFileInfo.isDir() ) { QString targetPath( contentOnly ? "." : sourceFileInfo.fileName() ); copyRecursively( source, targetPath ); } else QFile::copy( source, sourceFileInfo.fileName() ); return QVariant(); } ); parser.registerHelper( "mkdir", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) { QDir::current().mkpath( pathConcatenate( params )); return QVariant(); } ); parser.registerHelper( "temp_path", [] ( const RenderingContext &, const helper_params &, const helper_options & ) { return QVariant( QDir::tempPath() ); } ); parser.registerBlockHelper( "create_file", [] ( RenderingContext & context, const helper_params & params, const helper_options & options, const NodeList & truthy, const NodeList & ) { if( params.size() == 0 ) return; // RTFM // Compute file path & name QString filepath( pathConcatenate( params )); // If property "output_folder" exists, use it to compute a relative path (for log messages) QString relative_filepath( filepath ); QVariant output_folder( context.getProperty( "output_folder" )); if( output_folder.isValid() ) { QDir output_dir( output_folder.toString() ); relative_filepath = output_dir.relativeFilePath( QDir::current().absoluteFilePath( filepath )); } // Open file QFile file( filepath ); if( ! file.open( QIODevice::WriteOnly )) { context.warning( QString( "Handlebars.helper.create_file(%1): error #%2" ) .arg( relative_filepath ) .arg( file.error() )); return; } context.info( QString( "Handlebars.helper.create_file(%1)" ).arg( relative_filepath )); // Create context with file info QFileInfo fi( filepath ); QVariantHash infos; infos.insert( "@basename", fi.baseName() ); infos.insert( "@filename", fi.fileName() ); infos.insert( "@filepath", fi.filePath() ); infos.insert( "@filepath_absolute", fi.canonicalFilePath() ); if( output_folder.isValid() ) infos.insert( "@filepath_relative", relative_filepath ); context.pushPropertiesContext( infos ); // If options were given, add them to the context if( ! options.isEmpty() ) context.pushPropertiesContext( options ); // Create file value QTextStream stream( & file ); context.render( truthy, & stream ); file.close(); // Remove temporary contexts if( ! options.isEmpty() ) context.popPropertiesContext(); context.popPropertiesContext(); } ); } // ### // ### Integer Helpers // ### void registerIntegerHelpers( Parser & parser ) { parser.registerHelper( "range", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) -> QVariant { if( params.size() < 2 ) return QVariant(); // RTFM // Retrieve parameters int i = params.at( 0 ).toInt(); int end = params.at( 1 ).toInt(); int incr = ( params.size() > 2 ) ? params.at( 2 ).toInt() : ( i <= end ) ? 1 : -1; // Loop QVariantList range; for(; (incr>0) ? i<=end : i>=end; i+=incr ) range.append( i ); return range; } ); } // ### // ### Property Helpers // ### /** * Loops over a <Container<QVariant>> * * The container is obtained from the "anonymous" QVariant. */ template< template<typename> class C > static QVariant objectsWithProperty( const QVariant& q_input, const helper_params & params ) { C< QVariant > input( q_input.value< C< QVariant > > () ); C< QVariant > output; for( QVariant q_var : input ) { QObject* object( q_var.value<QObject*>() ); if( object != nullptr ) for( auto propertyName : params ) if( object->property( propertyName.toByteArray().constData() ).toBool() ) { output.append( q_var ); break; } } return output; } /** * Loops over a <Container< QString, QVariant >> * * The container is obtained from the "anonymous" QVariant. */ template< template<typename,typename> class C > static QVariant objectsWithProperty( const QVariant& q_input, const helper_params & params ) { C< QString,QVariant > input( q_input.value< C< QString,QVariant > > () ); C< QString,QVariant > output; for( auto i = input.constBegin(), end = input.constEnd(); i != end; ++i ) { QVariant q_var( *i ); QObject* object( q_var.value<QObject*>() ); if( object != nullptr ) for( auto propertyName : params ) if( object->property( propertyName.toByteArray().constData() ).toBool() ) { output.insert( i.key(), i.value() ); break; } } return output; } void registerPropertyHelpers( Parser & parser ) { parser.registerHelper( "objects-with-property", [] ( const RenderingContext &, const helper_params & c_params, const helper_options & ) -> QVariant { if( c_params.size() < 2 ) return QVariant(); // RTFM // Find type of container auto params = c_params; auto container( params.takeFirst() ); auto type( QMetaType::Type( container.type() )); switch( type ) { case QMetaType::QVariantHash: return objectsWithProperty <QHash> ( container, params ); break; case QMetaType::QVariantList: return objectsWithProperty <QList> ( container, params ); break; case QMetaType::QVariantMap: return objectsWithProperty <QMap> ( container, params ); break; default: return QVariant(); break; } } ); parser.registerHelper( "container-value", [] ( const RenderingContext &, const helper_params & params, const helper_options & ) -> QVariant { if( params.size() < 2 ) return QVariant(); // RTFM auto container = params.at( 0 ); auto key = params.at( 1 ).toString(); return RenderingContext::findPropertyInContext( key, container ); } ); parser.registerBlockHelper( "set_property", [] ( RenderingContext & context, const helper_params & params, const helper_options & options, const NodeList & truthy, const NodeList & ) { if( params.size() < 1 ) return; // RTFM auto name = params.at( 0 ).toString(); // Check if property already exists and "only-if" is set to "new" if( options.value( "only-if" ).toString() == "new" && context.hasProperty( name )) return; QVariant value; if( params.size() == 2 ) value = params.at( 1 ); else { // If options were given, add them to the context if( ! options.isEmpty() ) context.pushPropertiesContext( options ); // Use temporary output to collect inner block QString content; QTextStream stream( & content, QIODevice::WriteOnly ); // Create property value context.render( truthy, & stream ); // Remove any options if( ! options.isEmpty() ) context.popPropertiesContext(); value = content; } // Insert property into context (SIDE-EFFECT!) context.addProperty( name, value ); } ); } // ### // ### String Helpers // ### void registerStringHelpers( Parser & parser ) { parser.registerHelper( "camelize", [] ( const RenderingContext &, const helper_params & p, const helper_options & ) { QString in( p.value( 0 ).toString() ); QString out; out.reserve( in.size() ); // bool upper = true; for( QChar c : in ) { if( c.isLetterOrNumber() ) { out += upper ? c.toUpper() : c; upper = false; } else upper = true; } // if( out.isEmpty() || ! out[0].isLetter() ) out.prepend( '_' ); // return out; } ); // date [<format> =] parser.registerHelper( "date", [] ( const RenderingContext &, const helper_params & p, const helper_options & ) { auto format = p.value( 0 ).toString(); if( format.isEmpty() ) format = "yyyy-MM-ddTHH:mmt"; return QDateTime::currentDateTime().toString( format ); } ); parser.registerHelper( "hex", [] ( const RenderingContext &, const helper_params & p, const helper_options & opt ) { qint64 value = p.value( 0 ).toLongLong(); int width = opt.value( "width", 0 ).toInt(); QString fillS = opt.value( "fill" ).toString(); QChar fill = fillS.size() > 0 ? fillS.at( 0 ) : ' '; return QVariant( QString( "%1" ).arg( value, width, 16, fill )); } ); parser.registerHelper( "link", [] ( const RenderingContext &, const helper_params & p, const helper_options & opt ) { QStringList attrs; for( auto i = opt.begin(), end = opt.end(); i != end; ++i ) attrs.append( QString( "%1=\"%2\"" ).arg( i.key() ).arg( i.value().toString() )); return QVariant( QString( "<a %1>%2</a>" ) .arg( attrs.join( ' ' )) .arg( p.value( 0 ).toString() )); } ); parser.registerHelper( "print", [] ( const RenderingContext &, const helper_params & p, const helper_options & ) { QString out; QTextStream stream( & out, QIODevice::WriteOnly ); for( auto i = p.begin(), end = p.end() ;;) { stream << i->typeName() << '(' << i->toString() << ')'; if( ++i == end ) break; stream << ' '; } return QVariant( out ); } ); parser.registerHelper( "upper", [] ( const RenderingContext &, const helper_params & p, const helper_options & ) { return QVariant( p.value( 0 ).toString().toUpper() ); } ); } }// namespace Handlebars
25.90367
106
0.581725
mdhooge
7a9c02bc21da5bd673f3a972a10d7862f117a9b4
1,524
hpp
C++
libs/ledger/include/ledger/tx_status_http_interface.hpp
devjsc/ledger-1
2aa68e05b9f9c10a9971fc8ddf4848695511af3c
[ "Apache-2.0" ]
3
2019-07-11T08:49:27.000Z
2021-09-07T16:49:15.000Z
libs/ledger/include/ledger/tx_status_http_interface.hpp
devjsc/ledger-1
2aa68e05b9f9c10a9971fc8ddf4848695511af3c
[ "Apache-2.0" ]
null
null
null
libs/ledger/include/ledger/tx_status_http_interface.hpp
devjsc/ledger-1
2aa68e05b9f9c10a9971fc8ddf4848695511af3c
[ "Apache-2.0" ]
2
2019-07-13T12:45:22.000Z
2021-03-12T08:48:57.000Z
#pragma once //------------------------------------------------------------------------------ // // Copyright 2018-2019 Fetch.AI Limited // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //------------------------------------------------------------------------------ #include "http/module.hpp" namespace fetch { namespace ledger { class TransactionStatusCache; class TxStatusHttpInterface : public http::HTTPModule { public: // Construction / Destruction explicit TxStatusHttpInterface(TransactionStatusCache &status_cache); TxStatusHttpInterface(TxStatusHttpInterface const &) = delete; TxStatusHttpInterface(TxStatusHttpInterface &&) = delete; ~TxStatusHttpInterface() = default; // Operators TxStatusHttpInterface &operator=(TxStatusHttpInterface const &) = delete; TxStatusHttpInterface &operator=(TxStatusHttpInterface &&) = delete; private: TransactionStatusCache &status_cache_; }; } // namespace ledger } // namespace fetch
33.130435
80
0.654199
devjsc
7a9ea246aeb7df0f5298e76b12ecffced085fafa
3,983
cpp
C++
src/main/cpp/ofxOboeAndroidSoundPlayer.cpp
danoli3/ofxOboe
61b628c48c18c44a4f21a695549fa95286d86779
[ "MIT" ]
1
2021-11-05T08:33:34.000Z
2021-11-05T08:33:34.000Z
src/main/cpp/ofxOboeAndroidSoundPlayer.cpp
danoli3/ofxOboe
61b628c48c18c44a4f21a695549fa95286d86779
[ "MIT" ]
null
null
null
src/main/cpp/ofxOboeAndroidSoundPlayer.cpp
danoli3/ofxOboe
61b628c48c18c44a4f21a695549fa95286d86779
[ "MIT" ]
null
null
null
// // Created by Dan Rosser on 10/9/21. // #include "ofxOboeAndroidSoundPlayer.h" bool ofxOboeAndroidSoundPlayer::load(const std::filesystem::path& fileName, bool stream) { AudioProperties targetProperties { .channelCount = ofxOboe::getChannelCount(), .sampleRate = ofxOboe::getSampleRate() }; filePath = fileName.c_str(); std::shared_ptr<ofxOboeAssetDataSource> trackSource { ofxOboeAssetDataSource::newFromCompressedAsset(ofxOboe::getAssetManager(), fileName.c_str(), targetProperties, AASSET_MODE_UNKNOWN) }; if (trackSource == nullptr){ ofLogError("ofxOboe") << "Could not load source data for track:" << fileName; return false; } track = std::make_unique<ofxOboePlayer>(trackSource); if(track != nullptr) { track->setPlaying(false); track->setLooping(isLooping); ofxOboe::mixer.addTrack(track.get()); } else return false; return true; } void ofxOboeAndroidSoundPlayer::unload() { if(track) { track->setPlaying(false); track.reset(); track.release(); track = nullptr; state = ofxOboeAndroidSoundState::UNLOADED; } } void ofxOboeAndroidSoundPlayer::play() { if(track) track->setPlaying(true); } void ofxOboeAndroidSoundPlayer::stop() { if(track) { track->setPlaying(false); } } void ofxOboeAndroidSoundPlayer::setVolume(float vol) { if(track) { track->setVolume(vol); } } void ofxOboeAndroidSoundPlayer::setPan(float vol) { } void ofxOboeAndroidSoundPlayer::setSpeed(float spd) { } void ofxOboeAndroidSoundPlayer::setPaused(bool bP) { if(track) { track->setPlaying(false); } } void ofxOboeAndroidSoundPlayer::setLoop(bool bLp) { if(track) { track->setLooping(bLp); } } void ofxOboeAndroidSoundPlayer::setMultiPlay(bool bMp) { } void ofxOboeAndroidSoundPlayer::setPosition(float pct) { if(track) { track->setPlayHead((int)pct); } } void ofxOboeAndroidSoundPlayer::setPositionMS(int ms) { if(track) { track->setPlayHead(ms); } } float ofxOboeAndroidSoundPlayer::getPosition() const { return 1.0f; } int ofxOboeAndroidSoundPlayer::getPositionMS() const { return 0; } bool ofxOboeAndroidSoundPlayer::isPlaying() const { if(track) { return track->getPlaying(); } return false; } float ofxOboeAndroidSoundPlayer::getSpeed() const { return 1.0f; } float ofxOboeAndroidSoundPlayer::getPan() const { return 1.0f; } bool ofxOboeAndroidSoundPlayer::isPaused() const { return false; } float ofxOboeAndroidSoundPlayer::getVolume() const { return 1.0f; } bool ofxOboeAndroidSoundPlayer::isLoaded() const { if(track) { return true; } return false; } void ofxOboeAndroidSoundPlayer::audioIn(ofSoundBuffer&) const { } void ofxOboeAndroidSoundPlayer::audioOut(ofSoundBuffer&) const { } ofxOboeAndroidSoundPlayer::~ofxOboeAndroidSoundPlayer() { } oboe::DataCallbackResult ofxOboeAndroidSoundPlayer::onAudioReady(AudioStream *oboeStream, void *audioData, int32_t numFrames) { // auto *outputBuffer = static_cast<float *>(audioData); // // int64_t nextClapEventMs; // // for (int i = 0; i < numFrames; ++i) { // // songPositionMS = convertFramesToMillis( // currentFrame, // ofxOboe::getSampleRate()); // // // ofxOboe::mixer.renderAudio(outputBuffer+(oboeStream->getChannelCount()*i), 1); // currentFrame++; // } return DataCallbackResult::Continue; } void ofxOboeAndroidSoundPlayer::onErrorAfterClose(AudioStream *oboeStream, Result error) { if (error == Result::ErrorDisconnected){ state = ofxOboeAndroidSoundState::FAILED; currentFrame = 0; songPositionMS = 0; lastUpdateTime = 0; //start(); } else { //LOGE("Stream error: %s", convertToText(error)); } }
23.850299
143
0.656038
danoli3
7aa12e259b0d9d4631b6095a6b4f9710001c8f20
1,028
cpp
C++
project2D/Spring.cpp
Master-Mas/2D-Physics-Exmaple
a4ee3401daeb9150b8d2c8953bf6b0e70cacf93a
[ "MIT" ]
null
null
null
project2D/Spring.cpp
Master-Mas/2D-Physics-Exmaple
a4ee3401daeb9150b8d2c8953bf6b0e70cacf93a
[ "MIT" ]
null
null
null
project2D/Spring.cpp
Master-Mas/2D-Physics-Exmaple
a4ee3401daeb9150b8d2c8953bf6b0e70cacf93a
[ "MIT" ]
null
null
null
#include "Spring.h" Spring::Spring(RigidBody2D * join1, RigidBody2D * join2, float springConstant, float damping) { this->join1 = join1; this->join2 = join2; this->springConstant = springConstant; this->damping = damping; this->restDistance = glm::length(join1->getTransform().getPosition() - join2->getTransform().getPosition()); } Spring::~Spring() { } void Spring::fixedUpdate(float fixedTimeStep, glm::vec2 gravity) { float force = -springConstant * (glm::distance(join1->getTransform().getPosition(), join2->getTransform().getPosition()) - restDistance) - damping * glm::length(join1->getVelocity() - join2->getVelocity()); join2->applyForce(glm::normalize(join2->getTransform().getPosition() - join1->getTransform().getPosition()) * force * fixedTimeStep); } void Spring::draw(aie::Renderer2D * renderer) { renderer->setRenderColour(0, 0, 1); glm::vec2 pos1 = join1->getTransform().getPosition(); glm::vec2 pos2 = join2->getTransform().getPosition(); renderer->drawLine(pos1.x, pos1.y, pos2.x, pos2.y); }
33.16129
207
0.719844
Master-Mas
7aa381be8780833746f2bb730b4590fb0337ca7b
975
cpp
C++
app/src/main/cpp/recording/streams/RecordingStreamConstants.cpp
atikur-rabbi/fast-mixer
7b471e102aacb9cdf75af5c7775d18d10e584ff1
[ "CC0-1.0" ]
47
2020-07-16T21:21:37.000Z
2022-03-02T00:18:00.000Z
app/src/main/cpp/recording/streams/RecordingStreamConstants.cpp
iftenet/fast-mixer
9e834d6ebed0b1dd63fe8688f8bf614e19a8467f
[ "CC0-1.0" ]
1
2020-09-29T06:48:22.000Z
2020-10-10T17:40:50.000Z
app/src/main/cpp/recording/streams/RecordingStreamConstants.cpp
iftenet/fast-mixer
9e834d6ebed0b1dd63fe8688f8bf614e19a8467f
[ "CC0-1.0" ]
10
2020-07-19T10:07:21.000Z
2022-02-11T07:03:20.000Z
// // Created by asalehin on 7/30/20. // #include "RecordingStreamConstants.h" int32_t RecordingStreamConstants::mSampleRate = oboe::DefaultStreamValues::SampleRate; int32_t RecordingStreamConstants::mPlaybackSampleRate = RecordingStreamConstants::mSampleRate; int32_t RecordingStreamConstants::mInputChannelCount = oboe::ChannelCount::Stereo; int32_t RecordingStreamConstants::mOutputChannelCount = oboe::ChannelCount::Stereo; oboe::AudioApi RecordingStreamConstants::mAudioApi = oboe::AudioApi::AAudio; oboe::AudioFormat RecordingStreamConstants::mFormat = oboe::AudioFormat::I16; int32_t RecordingStreamConstants::mPlaybackDeviceId = oboe::kUnspecified; int32_t RecordingStreamConstants::mFramesPerBurst{}; int32_t RecordingStreamConstants::mRecordingDeviceId = oboe::kUnspecified; oboe::AudioFormat RecordingStreamConstants::mPlaybackFormat = oboe::AudioFormat::Float; oboe::InputPreset RecordingStreamConstants::mRecordingPreset = oboe::InputPreset::VoicePerformance;
54.166667
99
0.842051
atikur-rabbi
7aa8b4970179dde3e1691202772a982ccd205706
396
cpp
C++
Editor/gui/EngineViewWidget/widget/impl/EngineViewWidgetImpl.cpp
obivan43/pawnengine
ec092fa855d41705f3fb55fcf1aa5e515d093405
[ "MIT" ]
null
null
null
Editor/gui/EngineViewWidget/widget/impl/EngineViewWidgetImpl.cpp
obivan43/pawnengine
ec092fa855d41705f3fb55fcf1aa5e515d093405
[ "MIT" ]
null
null
null
Editor/gui/EngineViewWidget/widget/impl/EngineViewWidgetImpl.cpp
obivan43/pawnengine
ec092fa855d41705f3fb55fcf1aa5e515d093405
[ "MIT" ]
null
null
null
#include "EngineViewWidgetImpl.h" #include <QHBoxLayout> #include <QVBoxLayout> namespace editor::impl { EngineViewWidgetImpl::EngineViewWidgetImpl(QWidget* parent) : EngineViewWidget(parent) , m_EngineFrame(nullptr) { QVBoxLayout* layout = new QVBoxLayout(this); m_EngineFrame = new QFrame(); layout->addWidget(m_EngineFrame); setLayout(layout); } }
18
61
0.70202
obivan43
7aae9e76f79854e77c9493597c3f1005c85189a6
2,918
cpp
C++
RectangleProgressBar.cpp
arvindrajayadav/Good-Robot
c9a0a5f50793acbe7af312fccac48ee035498d1e
[ "MIT" ]
53
2020-08-04T08:38:14.000Z
2021-12-08T18:06:40.000Z
RectangleProgressBar.cpp
arvindrajayadav/Good-Robot
c9a0a5f50793acbe7af312fccac48ee035498d1e
[ "MIT" ]
2
2020-08-15T13:03:26.000Z
2020-08-15T19:54:22.000Z
RectangleProgressBar.cpp
arvindrajayadav/Good-Robot
c9a0a5f50793acbe7af312fccac48ee035498d1e
[ "MIT" ]
5
2020-08-04T09:33:40.000Z
2021-09-13T04:22:49.000Z
#include "master.h" #include "RectangleProgressBar.h" using namespace pyrodactyl; void RectangleProgressBar::Load(rapidxml::xml_node<char> *node) { Element::Load(node); timer.Load(node, "delta_time"); if (NodeValid("bg", node)) bg.Load(node->first_node("bg"), this); if (NodeValid("caption", node)) caption.Load(node->first_node("caption"), this); if (NodeValid("bar", node)) { rapidxml::xml_node<char> *barnode = node->first_node("bar"); if (NodeValid("max", barnode)) max.Load(barnode->first_node("max")); if (NodeValid("cur", barnode)) cur.Load(barnode->first_node("cur")); if (NodeValid("inc", barnode)) change_inc.Load(barnode->first_node("inc")); if (NodeValid("dec", barnode)) change_dec.Load(barnode->first_node("dec")); if (NodeValid("offset", barnode)) offset.Load(barnode->first_node("offset")); } } void RectangleProgressBar::Draw(const int &value, const int &maximum, const char *title, bool draw_value) { //Prevent divide by zero if (maximum == 0) return; bg.Draw(); if (!init) { init = true; prev = value; } //Calculate pixels per unit according to the size IF the bar is of constant width pixels_per_unit = w / (float)maximum; //Draw the outline bar that depends on the maximum value of health max.Draw(x, y, h, pixels_per_unit, maximum, false); //Add the offset for all other bars int X = x + offset.x, Y = y + offset.y; if (prev > value) { //The value decreased, draw the decrease bar change_dec.Draw(X + static_cast<int>(value * pixels_per_unit), Y, h, pixels_per_unit, prev - value, true); //Decrease the bar value so it moves 1px forward every X ms, and eventually becomes equal to value if (timer.TargetReached()) { prev -= 1 + static_cast<int>(pixels_per_unit / 2); if (prev < value) prev = value; //Reset the timer timer.Start(); } //Draw the current bar cur.Draw(X, Y, h, pixels_per_unit, value, true); } else if (prev < value) { //Draw the current bar cur.Draw(X, Y, h, pixels_per_unit, value, true); //The value increased, draw the increase bar change_inc.Draw(X + static_cast<int>(prev * pixels_per_unit), Y, h, pixels_per_unit, value - prev, true); //Increase the bar value so it moves 1px forward every X ms, and eventually becomes equal to value if (timer.TargetReached()) { prev += 1 + static_cast<int>(pixels_per_unit / 2); if (prev > value) prev = value; //Reset the timer timer.Start(); } } else cur.Draw(X, Y, h, pixels_per_unit, value, true); //Draw the caption if (draw_value) caption.text = title + NumberToString<int>(value) +" / " + NumberToString<int>(maximum); else caption.text = title; caption.Draw(); } void RectangleProgressBar::SetUI(pyroRect *parent) { Element::SetUI(parent); bg.SetUI(this); caption.SetUI(this); offset.SetUI(); max.SetUI(); cur.SetUI(); change_inc.SetUI(); change_dec.SetUI(); }
23.918033
108
0.67512
arvindrajayadav
7aafbc38e6b0cfa5feefb5d5f7caec980b83af6d
875
cpp
C++
Source/Insanity/MessageBox.cpp
mice777/Insanity3D
49dc70130f786439fb0e4f91b75b6b686a134760
[ "Apache-2.0" ]
2
2022-02-11T11:59:44.000Z
2022-02-16T20:33:25.000Z
Source/Insanity/MessageBox.cpp
mice777/Insanity3D
49dc70130f786439fb0e4f91b75b6b686a134760
[ "Apache-2.0" ]
null
null
null
Source/Insanity/MessageBox.cpp
mice777/Insanity3D
49dc70130f786439fb0e4f91b75b6b686a134760
[ "Apache-2.0" ]
null
null
null
#include "pch.h" //---------------------------- #pragma comment (lib,"user32.lib") //---------------------------- MSGBOX_RETURN OsMessageBox(void *hwnd, const char *txt, const char *title, MSGBOX_STYLE wmb){ int wtype; switch(wmb){ case MBOX_OK: wtype = MB_OK; break; case MBOX_YESNO: wtype = MB_YESNO; break; case MBOX_YESNOCANCEL: wtype = MB_YESNOCANCEL; break; case MBOX_RETRYCANCEL: wtype = MB_RETRYCANCEL; break; case MBOX_OKCANCEL: wtype = MB_OKCANCEL; break; default: wtype = MB_OK; } int ret = MessageBox((HWND)hwnd, txt, title, wtype); switch(ret){ case IDYES: return MBOX_RETURN_YES; case IDOK: return MBOX_RETURN_YES; case IDNO: return MBOX_RETURN_NO; case IDCANCEL: return MBOX_RETURN_CANCEL; case IDRETRY: return MBOX_RETURN_YES; } assert(0); return MBOX_RETURN_NO; } //----------------------------
26.515152
93
0.635429
mice777
7ab070e798d995ec86e79df525877847fa03cea5
802
cpp
C++
modules/core/base/unit/utility/size.cpp
psiha/nt2
5e829807f6b57b339ca1be918a6b60a2507c54d0
[ "BSL-1.0" ]
34
2017-05-19T18:10:17.000Z
2022-01-04T02:18:13.000Z
modules/core/base/unit/utility/size.cpp
psiha/nt2
5e829807f6b57b339ca1be918a6b60a2507c54d0
[ "BSL-1.0" ]
null
null
null
modules/core/base/unit/utility/size.cpp
psiha/nt2
5e829807f6b57b339ca1be918a6b60a2507c54d0
[ "BSL-1.0" ]
7
2017-12-02T12:59:17.000Z
2021-07-31T12:46:14.000Z
//============================================================================== // Copyright 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #include <nt2/include/functions/size.hpp> #include <nt2/sdk/unit/module.hpp> #include <nt2/sdk/unit/tests/relation.hpp> NT2_TEST_CASE( fundamental_size ) { using nt2::size; NT2_TEST_EQUAL( size( 3 , 1 ), 1u); NT2_TEST_EQUAL( size( 3 , 2 ), 1u); NT2_TEST_EQUAL( size( 3 , 3 ), 1u); }
36.454545
80
0.506234
psiha
7ab1951862a75a5a3df0fff27114f4cde919a359
15,012
cpp
C++
data/474.cpp
TianyiChen/rdcpp-data
75c6868c876511e3ce143fdc3c08ddd74c7aa4ea
[ "MIT" ]
null
null
null
data/474.cpp
TianyiChen/rdcpp-data
75c6868c876511e3ce143fdc3c08ddd74c7aa4ea
[ "MIT" ]
null
null
null
data/474.cpp
TianyiChen/rdcpp-data
75c6868c876511e3ce143fdc3c08ddd74c7aa4ea
[ "MIT" ]
null
null
null
int ds//mX ,t3 , MGA ,s , Kai /*R4k*/,al,C8L , Zt,kW5a ,zNAk , M1l, a5Q7 , K // ,Zj/*ZbNw*/// , xz ,U8 , CQ,pb, msWtM ,PRZEy , wrI , XIc1o , uh,K2s , HR6 ,rvUy3 , Sw/*1*/, t , S8,ha , RH, Na0, q /*9ku*///P1G ,m, v3Wcf , XZ4 ,WxYJ ,OQou , py2, gpl ,h0RF, GyQZ , lVwY4b,sN2 ,c3uy ,dmv,a0,fQ , // NaWv ,Bi5X, Jee//dQ ,Z , PxH , uz, RAT, UC , eSrN , M9, D0fK1 ,/*7tNJ*/yfoS8l , eCD, //Fj sS , tl ,uV, NZm , /*e*/Ws , IPMi5Y ; void f_f0()//5 { { { int eL ;volatile int dm1Y , zAD, nEt ; for(int i=1 ; i<1;++i)if ( true )for(int i=1//s36 ; i< 2;++i )if (true ) eL = nEt +dm1Y +/*Oe*/ zAD ; else {volatile int nk5N , ZSC; IPMi5Y=//Bw ZSC + nk5N; }else return ; return ; {{ int ZehfD/*xh*/;volatile int DyRo7 ,pc ,Vtar ;if ( true )ZehfD/*e*///wsM = /*BbW*/Vtar + DyRo7+/*o4H*/pc; else return ; {//kKem } {{} } } {} }{ // int pX; volatile int WEl,sme8 ; for (int i=1 ; i< 3;++i ) { ; for (int i=1; i< 4;++i ) {} } pX= sme8+ WEl ;}}{ volatile int fZ, sGL , /*I*/ upWO ,mp, IF ; ;{/*N*/volatile int/*Q6*/ Qkuw , gO,Vkk ; //f3Xt { for (int i=1; i<5 ;++i){}} {} {;} ds =Vkk/*PmY*/+Qkuw //z + gO;{} } t3/*eVa*/= IF + fZ +sGL + upWO +mp ;}{ { { } {{ volatile int fC ;{ } for (int i=1;i< 6 ;++i //we )/*wHt*/MGA= fC //QV ; } }/*3*/} //Gy return ; } { int eNPS; //f volatile int /*Xi4C*/ cw, tyX,sQDc ; { /**/; }for (int i=1 ; i<7 ;++i ) if(true /*x*/){ int N5VKlj9;volatile int y0Z , MFk , sGa0 ; { }N5VKlj9 = sGa0+/*sLo1*/y0Z +MFk ; }else eNPS =sQDc + cw+ tyX ; } { /**/ if (true)return ;else return ; { if ( true)return ; else for(int //rDAW i=1 ; //w i<8;++i) for (int i=1;/*CR*/ i<9;++i )//Jz3 //n { }} } } if( true ) //s return ; else//5GWj {{ for (int i=1//GPU ; i< 10;++i) { { }//0yF ;//NLj1ESz } //7 return // ; } /*83*/ if( true ){{ return ; {} } {if( true) return ; else{return ;{ int NECy ;volatile int UaN;if ( true) {} else // NECy= UaN; }} } }/*oO*/else {volatile int K2G//f ,e2gl1 //a , ls ;{for (int i=1 ;i< 11;++i)/*m*/ {{ }//Niv } } s = ls+ K2G + e2gl1 //KSDY ; ; {if( true ) { ;} else /*l*/{ } }if ( true ) ; else {volatile int i3sK /*Gy*/, J ; Kai =J +i3sK ;for (int i=1 ;i<12;++i) ; }if (/*G8*/ true ) { {/*Z*/}; }else{volatile int/*SlD*/ Kdt ,vQwV ;{volatile int aNn ,d1Orr , N9v6 ; al = N9v6 + aNn+d1Orr ;//Jw { {/*XZ*/ }} } C8L = vQwV//wf +Kdt ;{}} }{{for (int i=1 ;i<13;++i); }{volatile int n5 , z ,auzN ,s79H; {} { } if //ZN ( true )for(int i=1 ;i<14 ;++i ) ;else Zt =/*8d*/s79H//Omvo + n5; kW5a=z//q +auzN;}{ { } }}{ //0zi if(true) { {} { }{{}if( true) return ;else { { }} {} if ( true) {}else {}}{ if (true) { //v } else { } return ;} }else ; {if ( true ) {volatile int SaZDa,ah, qFlY//2P9T ,Cy; if/**/( true){} else{ } if//d4r (true) if (true )zNAk =Cy+ SaZDa ; else M1l=/*EH1*//*rS*/ah + qFlY; else {volatile int// n , LZ3Z;if( true ) {}else a5Q7 = LZ3Z+n; /**/ } } /*pI*/else if (true ){} else return ; } {if( true )//Bs4 //p8 ; else {{ { } }for (int i=1 ;i< 15;++i ) {} {} //0TPs if //v (true ) { ;} else { }//2 for (int i=1 ;i<16 ;++i)if (true)if/*ZY*/( true )//E {} else ; else {} } { { } ;}{ return ; }}{{ } {/*oy*/{}} }/*t*/ // }}for(int i=1/*uiX*/; i<17;++i) if(true){ /*oH*/{ { volatile int mCOg , D, PWJTDb;K = PWJTDb + mCOg+//K D;} if(true )return ; else { int IEz6; volatile int cb3,gZ , vW//E , I//6B /*Z*/; for(int i=1 ;i<18 ;++i /*w8*/) ; IEz6= I+ cb3//7x ;/*Jikgg*/ Zj= gZ + vW ;} //kK } { volatile int Un , oan , WDs ,Wz8pk4/*ZBtv*/,eqy ; {/**/int h;volatile int id//O1 , HT8 ,//5iT pY2,AzaWn ; { volatile int qeE ; { {}//n7Y ; } xz = qeE; if (//OB true) {}else { } }{ {{ }} { } } h =AzaWn// +id +HT8 + pY2;} U8= eqy+ Un +oan + WDs + Wz8pk4;{{volatile int //G F4b , g//6u ;{ }CQ= g+F4b; } }} return ; { int P/*Jl*/; volatile int W6, wz, bgVg;;if//ns (true ) if (true ) {//4 { }for (int i=1 ;i< /*7T*/ 19/*b8*/;++i//Zc );{ {{ } } {volatile int fpN ;pb =fpN ; }}} else P= bgVg +W6 +wz;else ;}} else return ;{//5h for(int i=1 ; i< 20 ;++i )//wO { volatile int lOKdG0 , kA , jS3 , Cv ,b8r ; {{ ; } if( true ) /*46*/; else ;//zj }msWtM=//6S b8r + lOKdG0 + kA + jS3 + Cv// ;for//ts (int i=1 ;i< 21;++i){ { { } { //H }{} } { int w4;volatile int R9, IL9u ;return ;/*sSI*/ if(//7u true )w4= IL9u + R9 ;/*9OI*/ else{}{//e /*Won*/ } {//RT } } } }; { ; {{ { if( true){{} }/*Xpa*/ else{ } if ( true)for(int i=1 ;/*6*/ i<22;++i) return ; else ; } /*TR*/} } ; }{int fy ;volatile int /*RO*/ aU , Nkl , C ; { volatile int VBw , QOLl,uc9I2 //nE ; PRZEy = uc9I2//d + //MwR6 VBw + QOLl;{ for(int i=1 ;/*H*/i<//lw 23 ;++i)if//N (true)if(true ){ /**/}else { }else{ } }{{ }} } fy = C + aU+Nkl ; for (int i=1 ; i<24 //Bt ;++i/*j*/ /*BxUS*/ ) { {} ; } }} return ; }void f_f1(){ { { { int WI3 ; volatile int B8 ,m2Uy ; WI3 =/*5N*/m2Uy +//TsJ B8; }{volatile int//EKS /*mU*/ sKf,NJZPkUU8/*S*/, suO ;wrI = suO+sKf+NJZPkUU8 ;if ( true );else{ {} {//Z4 }}} } return ;{{ ; }if (true){ volatile int lY, owz ;for (int i=1; i< 25/*AW*/;++i) XIc1o = owz+ lY ; { }{ //GW5 } }else//RD ; if//64 ( true){;{ for (int i=1; i< 26 ;++i ); return ; } return ; } else { ; ; }{{ { } } ; } } { { int hp ; volatile int Wr,i3Rw//xy ; {volatile int d8c ,y0 , o; uh = o//Q + d8c + y0 ; }if (/*mf*/ true ) /**/{ } else for//4KQa (int i=1 ; i< 27 ;++i )hp = i3Rw +Wr;}{ {} {} { } } } };{// { volatile int DW , US ,e6 ,ouHvl;{ for (int i=1;i< 28 ;++i ){ volatile int//o O,tP ; for(int i=1; i< 29 ;++i){ }if/*teMXjS*/(/*W*///od true ) { int oV;volatile int ZYg,PGkruw;oV= PGkruw+ZYg ; }else { { }{ }return ; }/*rC*/ K2s = tP + O ;return //T ; }; }if (true ) { { } return ; {{ {} } ; }/**/}else/*4gbq*/ return ; HR6= ouHvl + DW + US + e6 ; }{ ; {volatile int pNkW, yA ; /*b0*/for(int // i=1;i< 30;++i ) rvUy3 //4S =yA+ pNkW ; for(int i=1 ; i< 31 ;++i) ; //Iep } } { volatile int caF , i3 ,//i b, D1L, lKSAe,vKF ; for/**/(int /**/i=1;i< 32;++i ) { {{//w } } {for(int i=1 ;i<33;++i );} }//FO { { {}}} Sw = vKF+/*W*//*ANs*/ caF + i3 + b+ D1L +/*Aq*/lKSAe; return ; {volatile int gA , Ui1p ;for(int i=1; i< 34 ;++i)t= /*dUb*/ Ui1p + gA ;{ volatile int Hx , rCY ;S8//4O = rCY+ Hx ; } } }for (int i=1; i< 35 ;++i)return ;} { if(true)for/*hQ6x*/(int i=1 ;i<36;++i ){int Zk ;volatile int Of ,E8,XZl , fr1sI, GOMJ; return ; {if ( /**/true) if( true ) { }else {for(int i=1 ;i< 37 ;++i ) if(true){} else { }{{ }} } else return ; for(int i=1 ;i<38;++i ) if /*bBab*//*wy*/(true ) ; else ; {if(/*HnT*/ true ){volatile int NvB ; if ( true )ha=NvB;else{}} //fv /*Iz*/ else{{ } } }/*ojw*/} Zk/*n*/= GOMJ +Of //CEH +E8 +XZl +//U fr1sI ; }else { { { ;/*HH*/}if ( true ) for (int i=1 ;i< 39;++i ) for (int i=1; i< 40 ;++i ) { }//gq else { }return ;{} } { {int/**/ MCYl7s ; volatile int fw // , O5c ,nmz ;MCYl7s=nmz +fw + O5c//r ;{{//DBxd } } }{{ } } }/*Y*/ if /*Ml*/( true ){ {/*88M*/ {}for (int i=1 ;i<41;++i) { /**/}{ ;//re } } {} { } } else for (int i=1; i<42;++i) if(true ) { volatile int Wwy ,F ,b6V, u ; RH = u+Wwy + F+ b6V ; } else{ volatile int bHoCj ,lNsKL , ZlL;for(int i=1;/**/i< 43 ;++i ) if( true )if(true )Na0= ZlL+ bHoCj +lNsKL;else ; else {{/*BLn*/ }} {if (/*O*//*Ba*/true) for (int /*fYU*/i=1 ; i<44 ;++i)if( true) { } else ; else {}}} } {int dy8 ; volatile int N , AgF , gVS1, VKoG ,tBiAS ; {{{} }} { { } }dy8 = tBiAS+N + /*YG*/AgF + gVS1+VKoG ; }return ;{; for (int i=1 ;i<45;++i) {/*fHj*/ volatile int M9JHS/**/ ,r, oskgFJ ,AHy ;q= AHy+M9JHS +r +/**/oskgFJ ; }{;/*6H*/} }//APg } { volatile int AV ,j7 , fOWkQv , qL9O , E08;{volatile int a,v ,DU ,YCP ; {{ { } {; } } for(int i=1 ; i<46 /**/;++i /*l*/){{ } } } m /*6*/=YCP +a +v +DU; for(int i=1 ; i< 47 ;++i ) if (true) if ( true ) return// ;else {;; {} } else {{ {} } { {}for(int i=1; /*o7*/i< //G0Y 48 ;++i /**/ )for (int i=1;i<49;++i ) ;} }{ ; //G { } } } v3Wcf = E08 +AV +j7 +fOWkQv + qL9O//fV47 ; if( true ){return ;//UW ;/*0*/for(int i=1 ;i< 50;++i) { return ; } } else { { { }{/*d*/ /*RL*/} }{ { {// { } for (int i=1;i< 51;++i) {} } {}for (int i=1;i< 52 ;++i)// {int GF ; volatile int qGd;GF/*p*/=qGd;} {}} { {/*w4*/ } if(true ){ } else{}} }} {{{ }; } {{int A9U ; volatile int qyb,zLEB , b6q; A9U =b6q + qyb + zLEB;}/*1RH5*/{ int OQr; volatile int GA;OQr= GA // ; {} }{/*uJ*/ }} { int zDQ; volatile int fT /*2J*/, iP ,/*n0g*/ qW;zDQ=qW +fT + iP; { } } } //f } { volatile int TNv, JQ , ogxvz , wp , duvoEM2 ,KVQbU,UOn , /*SXA*/ZESm , G3X,QfJ,bAHY//J4s ;{ volatile int sd /*o9U*/,/*UBc*/pCjM , nsqvN ,//9 m9j;for(int i=1;i<53 ;++i)/*Gym*/ {{}{ {} }}/*cKkOFo*/ if ( //FNN true ) { //lH int Pm , //cf7 trS ; volatile int R2kE0/*vk*/ ,s775, /*BA*/ xP, Ne ,Ee3f ; trS = Ee3f +//5mrV R2kE0; Pm= s775+ xP +Ne /*9*/ ; if ( true)return ;else{{ } { }} ; }else ; { {} { ;} return ; } if//0P (true ) {for (int //kJ7 i=1;i<54;++i )for (int i=1; i< 55;++i ) for (int i=1; i< 56;++i) //c ;{{ } {return /**/ ; }return ; } }else if(//R true ) XZ4 =m9j + sd +pCjM // + nsqvN ;else for (int //c i=1 ;i< 57;++i){//U volatile int QG ,IgSa ; /*2zf*/WxYJ = IgSa + QG ; }}for (int i=1 ; i<58 ;++i) if(true ) {int oT; //gOy volatile int NHg , zxBOuX,PjhOs,XH ,A9 ,Y , vO , //4mV kiJZz ; { volatile int ykF1qt ,Uk;OQou = Uk + ykF1qt/*e3*/; { volatile int wIi942 , Sg , i ; py2 = i+wIi942+ Sg ; {} if ( true/*y0*/) return ; else return ;} }/*Dp*/if ( true) { if ( true ){} else { }{ { { } } { {//N }}} } else gpl = kiJZz+NHg +zxBOuX+PjhOs;/*k*/oT= XH +A9+Y +vO ; }//7Dj else{{volatile int /*L*/ rIOZ/*P*/,la , NNw /*Ck*/; for(int i=1 ; //vA2x /*Dch*/i< 59 ;++i//T )//hZ h0RF =NNw/*o6s*/ +rIOZ+ la; { ; }{; } } { return ;{ } }return ; } if( true ) {//I for (int i=1//Wzkw ; i<60 ;++i )for (int i=1 ; i< 61 ;++i) ;{ {; } {for(int //9r i=1 ;i<62;++i//A ){ } { } /*LVk*/ } } } else GyQZ = bAHY +TNv +JQ +ogxvz + wp ;{ {return ; } { return ; { int DO//mkv ; volatile int x47; DO= x47//Bx9m7 ;{ } {{ } } }//fVU /*4Sq*/; }{ {/*eo*/} {{ { } } } /*f*/}/*18*/{ {if ( true ) /*TiS*/{ } else//5NXM return ;}} }//8 lVwY4b =duvoEM2//L +KVQbU + UOn+ZESm + G3X//O +QfJ ;} return ; }void f_f2//Y () {if ( true )if(//MoL true ){int G;volatile int BVm , QgUT9 ,EIU ,Jie, Te//F ,gOA1, NU , Av , Bq, DEL; sN2//ahpv = DEL + BVm + QgUT9+ EIU+Jie + /*k*/ Te ; G = gOA1 +NU+ Av + Bq ; { { volatile int y48L , oc9;{ }c3uy = oc9 + y48L; if( true) { }else ;//N } return ; } ; } else { /*FtE*/volatile int RK ,QP ,/*9*/LM3 , m80U1G ,F9//Uz ; { volatile int T, s4S , vrDVz, Am ; ; { int xu;volatile int mloB ,qq ;{/*r*/ return ;} xu =qq+mloB ; {} } dmv = Am +T + s4S + vrDVz ;//e {volatile int ekzRm,TO; { ;}a0 = TO + ekzRm; return ; { if ( true)return ; else ; }if( true ){/*g*/return ; }/**/ else{ } if ( true ) ;else { /*pO*/{ // int vVr;volatile int oDC ;{ } vVr =oDC ;} {}{volatile int /*4d*/ LE, uSN2q ;if( true) {} else fQ=uSN2q+ LE ; { } }}} } NaWv = F9 + RK+ QP+LM3/*OsG*/+m80U1G ; {{{ }}/*oJ*/{ { }} {{for//W (int i=1;i</*Bo*/ 63 ;++i ) { } }/*RWj*/} } /*emE*/for (int i=1;i< 64;++i) { ;{ { /*v*/{ int LlHG //6 ; volatile int/*iS*/ AZBNdQ //rM ; if( true ) { } else LlHG= AZBNdQ; } {{ } }{} { {} } }} {{ if( true)return ;else return ;{}}{ } { {}{}}} } { volatile int e , pxrO , SEZtJ ; {for (int i=1;i</*KZ*/65 ;++i ) return ;} Bi5X =SEZtJ +e+pxrO//PT ; } }else{ /*0i41*/{/*9d*/volatile int st, WW, yXQ ,//OC Ibr;{volatile int Ado , MCU; Jee =MCU + Ado ; { return ;}for (int i=1;i<66 ;++i ) {} } Z = Ibr+st//du + WW + yXQ//Dv ; return ; } {;/*HlsE*/return ;{ for (int //3Z0KL i=1 ;/**/ i< 67;++i) /*b0Sn*/return ;;} {; //S for(int i=1 ; i< 68 ;++i/*le*/) //o if ( true )return ; else/**/ return ;{ {}} } }{int UE ; volatile int Wfr , ORt1T , wIw, aH7, BUc5t , CY; for (int i=1 ;i< 69//e5js ;++i) PxH/*nps*/ =CY+/*3*/Wfr+ ORt1T ; UE =wIw +aH7 + BUc5t/*o*/; /*b*/} { volatile int FEOCDH ,Cc, eNk , tY9W ,L; if(true ){ {volatile int wc, //GEW vtx/*N1*/;{}{ } if(true){ } else for(int i=1; i< 70;++i ) uz//fXG5T = vtx + wc/*8*/; } }else for/*ew*/(int i=1; i< 71;++i ) {int H ; volatile int/*z*/ Iif,HBVUJq, i5C, iV ,DKVF8i ; //w if ( true )return ;else RAT= DKVF8i// +Iif +//F6 HBVUJq ;H = i5C +iV ;/*F1*/ } UC /**/= L+FEOCDH + Cc+ eNk +tY9W; for (int i=1;i<72;++i ) return ; } //M { { {return ; /*ZUU*/ } { } } if( true){ {return ; ;}} else return ; ; }{ {return ; } {//1 { }//dT if(true) { for (int i=1;i<73 ;++i ) { for (int i=1 ; i<74;++i ) {/*e7*/} return/*j8q*/ ; }// } else return//NUsg /*gY*/ ;//rR1 } ; } } ; ; ;;return ;} //Vf int main() {volatile int pf5Us ,zr0 ,hs , snC6 ,Lv ,AC ;eSrN = AC +pf5Us +zr0/*7jQa*/+//eO hs+ snC6 + Lv;if(true ){{;if ( true ) { {return 497866240 ; { }}if ( true){ {} {volatile int PQ1,opp/*mc6*/;M9=opp +PQ1;}}else /*k*/ return 1231516520 ; return 1626704340 ; } else{ int Vtr;volatile int ye, f2uy,BW ; if//x ( true)return 1624972648 ; else Vtr= BW +ye + f2uy;}{ { { }{ volatile int SV8U; { int WT7; volatile int AS; /**/WT7 = AS; } D0fK1=/**/ SV8U ;} };for (int i=1; i< 75 ;++i){} }//Ub } { volatile int dU , nTk , w2 ,Nu,oJ5 , HGYe,//L uIy,X4gp; yfoS8l = X4gp+ dU/*Vau*/ + nTk + /*Fi*/w2;eCD= Nu//kK7P + oJ5 + HGYe +uIy ; }{ volatile int HE , w,/*4M*/RN , ssD,lq ;sS= lq //TxZVN + HE+w + RN +ssD;for (int i=1 ; i<76;++i ) for(int i=1 ;i<77 ;++i //M ) { // ; }{ ; { if/*gX*/( true ){} else return //WfU 1968188452 ;} } } { {volatile int sFz, cxKP; return 166725831 ;/*K*/tl= cxKP+ sFz; return 989441849 ; } /*u*/; { {} return 1658773024/*czUX*/; } }}else return 634456850 ; return 1275129466 ;/*4YM*/ {; {return 389301623 ;{volatile int sTDbs, LYj ,/*T32*/ D60 ; uV =D60+ sTDbs +LYj; } /*Y*/} {volatile int Zn4U ,//DHrV vsZi, /*UX*/eM ; NZm = eM+Zn4U+vsZi ;for (int i=1; i< 78 ;++i ) { int yS ; volatile int Cjwepm, mm ; yS = mm /*rNp*/+ Cjwepm ; }}}if(true ) { volatile int hTB , NG //RHS , QcYj,R, Cz, DT;Ws = DT +/**/ hTB + NG +/*Tes*/ QcYj+R + Cz ;{{ {} {}} return 1463615358;; { ; }//B }return 634380861 ; ;; } else return 1508537189 ; }/**/
11.078967
72
0.454103
TianyiChen
7abd8d8902d6549c9a9cbd099797a65257771aff
2,124
cpp
C++
src/shape.cpp
SergeyG22/TetrisRepository
527f671f7732cc07109ff30ea9cb1fca673e889e
[ "MIT" ]
null
null
null
src/shape.cpp
SergeyG22/TetrisRepository
527f671f7732cc07109ff30ea9cb1fca673e889e
[ "MIT" ]
null
null
null
src/shape.cpp
SergeyG22/TetrisRepository
527f671f7732cc07109ff30ea9cb1fca673e889e
[ "MIT" ]
null
null
null
#include "shape.h" Shape::~Shape(){ } bool Shape::moveShape(){ for(int i = 0; i < figure.size(); ++i){ //если конец остановить if(figure.value(i).y() == window->height() - shape_configuration.size.width()){ return true; } } if(shape_configuration.activity){ for(QRect& rect: figure){ int y = rect.y() + shape_configuration.step; rect.moveTo(rect.x(),y); repaintShape(); } } return false; } bool Shape::checkArgumentsShape(int pos_x, int pos_y, QSize size_rect){ if(pos_x < 0 || pos_y < 0 || size_rect.width() < 0 || size_rect.height() < 0){ perror("argument is less than zero"); return false; } return true; } void Shape::moveToRight(){ if(shape_configuration.activity){ if(std::all_of(figure.begin(), figure.end(), [&](QRect i){ return i.x() < window->width() - shape_configuration.size.width();})){ for(QRect &rect: figure){ rect.moveTo(rect.x() + rect.size().width(),rect.y()); repaintShape(); } } } } void Shape::moveToLeft(){ if(shape_configuration.activity){ if(std::all_of(figure.begin(), figure.end(), [](QRect i){ return i.x() - i.size().width() >= 0;})){ for(QRect &rect: figure) { rect.moveTo(rect.x() - rect.size().width(),rect.y()); repaintShape(); } } } } bool Shape::moveToDown(FieldOfRectangles& field){ if(shape_configuration.activity){ if(std::all_of(figure.begin(), figure.end(), [&](QRect i){ return i.y() + i.size().width() < window->height();})){ if(field.bottomCollision(figure)){ return true; } for(QRect &rect: figure) { rect.moveTo(rect.x(),rect.y() + rect.size().width()); repaintShape(); } for(QRect &rect: figure){ if(rect.y() + rect.size().width() == window->height()){ return true; } } } } return false; }
27.584416
137
0.51177
SergeyG22
7abe681a701691dc9eb3bb3e36784c972d871c53
2,606
cpp
C++
mcrouter/routes/test/ShadowRouteTest.cpp
hrjaco/mcrouter
5a7b852a1ea2f3c645e0b8366c0549bc992870af
[ "BSD-3-Clause" ]
null
null
null
mcrouter/routes/test/ShadowRouteTest.cpp
hrjaco/mcrouter
5a7b852a1ea2f3c645e0b8366c0549bc992870af
[ "BSD-3-Clause" ]
null
null
null
mcrouter/routes/test/ShadowRouteTest.cpp
hrjaco/mcrouter
5a7b852a1ea2f3c645e0b8366c0549bc992870af
[ "BSD-3-Clause" ]
null
null
null
/** * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ #include <memory> #include <random> #include <vector> #include <gtest/gtest.h> #include "mcrouter/routes/DefaultShadowPolicy.h" #include "mcrouter/routes/ShadowRoute.h" #include "mcrouter/routes/ShadowRouteIf.h" #include "mcrouter/lib/test/RouteHandleTestUtil.h" using namespace facebook::memcache::mcrouter; using namespace facebook::memcache; using std::make_shared; using std::string; using std::vector; TEST(shadowRouteTest, defaultPolicy) { vector<std::shared_ptr<TestHandle>> normalHandle{ make_shared<TestHandle>(GetRouteTestData(mc_res_found, "a")), }; auto normalRh = get_route_handles(normalHandle)[0]; vector<std::shared_ptr<TestHandle>> shadowHandles{ make_shared<TestHandle>(GetRouteTestData(mc_res_found, "b")), make_shared<TestHandle>(GetRouteTestData(mc_res_found, "c")), }; TestFiberManager fm; auto data = make_shared<proxy_pool_shadowing_policy_t::Data>(); vector<std::shared_ptr<proxy_pool_shadowing_policy_t>> settings { make_shared<proxy_pool_shadowing_policy_t>(data, nullptr), make_shared<proxy_pool_shadowing_policy_t>(data, nullptr), }; auto shadowRhs = get_route_handles(shadowHandles); ShadowData<TestRouteHandleIf> shadowData = { {std::move(shadowRhs[0]), std::move(settings[0])}, {std::move(shadowRhs[1]), std::move(settings[1])}, }; TestRouteHandle<ShadowRoute<TestRouteHandleIf, DefaultShadowPolicy>> rh( normalRh, std::move(shadowData), 0, DefaultShadowPolicy()); fm.runAll( { [&] () { auto reply = rh.route(McRequest("key"), McOperation<mc_op_get>()); EXPECT_TRUE(reply.result() == mc_res_found); EXPECT_TRUE(toString(reply.value()) == "a"); } }); EXPECT_TRUE(shadowHandles[0]->saw_keys.empty()); EXPECT_TRUE(shadowHandles[1]->saw_keys.empty()); data->end_index = 1; data->end_key_fraction = 1.0; fm.runAll( { [&] () { auto reply = rh.route(McRequest("key"), McOperation<mc_op_get>()); EXPECT_TRUE(reply.result() == mc_res_found); EXPECT_TRUE(toString(reply.value()) == "a"); } }); EXPECT_TRUE(shadowHandles[0]->saw_keys == vector<string>{"key"}); EXPECT_TRUE(shadowHandles[1]->saw_keys == vector<string>{"key"}); }
29.613636
79
0.683039
hrjaco
7abfa3fe7c72801b08250e37ece2346a6888d62d
3,176
hpp
C++
von_mises.hpp
slmcbane/Le-TO
d8fb0378fb687bb6dd56ed302072b59e5cdfb92f
[ "MIT" ]
null
null
null
von_mises.hpp
slmcbane/Le-TO
d8fb0378fb687bb6dd56ed302072b59e5cdfb92f
[ "MIT" ]
null
null
null
von_mises.hpp
slmcbane/Le-TO
d8fb0378fb687bb6dd56ed302072b59e5cdfb92f
[ "MIT" ]
null
null
null
#ifndef VON_MISES_HPP #define VON_MISES_HPP #include <cassert> #include <iostream> #include <utility> #include "2d.hpp" namespace Elasticity { namespace TwoD { template <class Element> struct VonMisesComputer { template <class Vector> VonMisesComputer(const Element &el, const Vector &v, double lambda, double mu) : el(el), coeffs(), lambda{lambda}, mu{mu} { coeffs = v; } template <class... Args> double evaluate(const Args &... args) const { const auto dudx = partials(args...); const auto div = dudx[0] + dudx[1]; const auto a = lambda * div + 2 * mu * dudx[0]; const auto b = lambda * div + 2 * mu * dudx[1]; const auto c = mu * (dudx[2] + dudx[3]); return std::sqrt(a * a - a * b + b * b + 3 * c * c); } template <class... Args> std::pair<double, Eigen::Matrix<double, 2 * basis_size<Element>, 1>> evaluate_with_gradient(const Args &... args) const { const auto dudx = partials(args...); const auto div = dudx[0] + dudx[1]; const auto a = lambda * div + 2 * mu * dudx[0]; const auto b = lambda * div + 2 * mu * dudx[1]; const auto c = mu * (dudx[2] + dudx[3]); const auto sigma = std::sqrt(a * a - a * b + b * b + 3 * c * c); const double xcoeff1 = (lambda + 2 * mu) * (2 * a - b) + lambda * (2 * b - a); const double ycoeff1 = (lambda + 2 * mu) * (2 * b - a) + lambda * (2 * a - b); const double coeff2 = 6 * c * mu; Eigen::Matrix<double, 2 * basis_size<Element>, 1> grad; Galerkin::static_for<0, basis_size<Element>, 1>([&](auto I) { const double phi_x = el.template partial<0>(Galerkin::get<I()>(Element::basis))(args...); const double phi_y = el.template partial<1>(Galerkin::get<I()>(Element::basis))(args...); grad[2 * I()] = xcoeff1 * phi_x + coeff2 * phi_y; grad[2 * I() + 1] = ycoeff1 * phi_y + coeff2 * phi_x; }); grad /= (2 * sigma); return std::make_pair(sigma, grad); } template <class Vector> void set_coeffs(const Vector &cs) { coeffs = cs; } constexpr static auto coeffs_size = 2 * Element::basis.size(); const Element &element() const noexcept { return el; } private: const Element el; Eigen::Matrix<double, 2 * Element::basis.size(), 1> coeffs; double lambda, mu; // returns (ux_x, uy_y, ux_y, uy_x) template <class... Args> Eigen::Vector4d partials(const Args &... args) const { Eigen::Vector4d ps(0, 0, 0, 0); Galerkin::static_for<0, basis_size<Element>, 1>([&](const auto I) { const auto phi_x = el.template partial<0>(Galerkin::get<I()>(Element::basis))(args...); const auto phi_y = el.template partial<1>(Galerkin::get<I()>(Element::basis))(args...); ps[0] += coeffs[2 * I()] * phi_x; ps[1] += coeffs[2 * I() + 1] * phi_y; ps[2] += coeffs[2 * I()] * phi_y; ps[3] += coeffs[2 * I() + 1] * phi_x; }); return ps; } }; } // namespace TwoD } // namespace Elasticity #endif // VON_MISES_HPP
31.76
101
0.548174
slmcbane
7ac146b3ba0b13ea9afdd1e0860b352a7ac8e7b2
49,475
cpp
C++
Sandbox/HazelDash/HazelDashLayer.cpp
rocketman123456/RocketGE
dd8b6de286ce5d2abebc55454fbdf67968558535
[ "Apache-2.0" ]
2
2020-12-06T23:16:46.000Z
2020-12-27T13:33:26.000Z
Sandbox/HazelDash/HazelDashLayer.cpp
rocketman123456/RocketGE
dd8b6de286ce5d2abebc55454fbdf67968558535
[ "Apache-2.0" ]
null
null
null
Sandbox/HazelDash/HazelDashLayer.cpp
rocketman123456/RocketGE
dd8b6de286ce5d2abebc55454fbdf67968558535
[ "Apache-2.0" ]
null
null
null
#include "HazelDashLayer.h" #include "Components/Amoeba.h" #include "Components/Animation.h" #include "Components/Camera.h" #include "Components/EnemyMovement.h" #include "Components/Explosion.h" #include "Components/Mass.h" #include "Components/PlayerState.h" #include "Components/Roll.h" #include "Random.h" #include "GEModule/Application.h" #include "GEUtils/KeyCodes.h" #include "GEEvent/KeyEvent.h" #include "GERender/RenderCommand.h" #include "GERender2D/Renderer2D.h" #include "Hazel/Scene/Components.h" #include <GLFW/glfw3.h> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> #include <iomanip> #include <sstream> #ifdef _DEBUG #include <imgui.h> #endif // If BATCHRENDER_TEST is non-zero, then starting level is always the // large one with hazel logo, and will use huge viewport. // Otherwise set STARTING_LEVEL to the level index (from levelDefinition) // that you want to start on (and will use normal sized viewport) // Real levels start from index 5, the ones before that are just small tests #define BATCHRENDER_TEST 0 #define STARTING_LEVEL 0 struct LevelDefinition { int Width; int Height; int ScoreRequired; int TimeAllowed; std::string LevelData; }; static std::vector<LevelDefinition> s_LevelDefinition = { {10, 10, 1, 0, "WWWWWWWWWW" "W.......XW" "W........W" "W........W" "W........W" "W........W" "W........W" "W........W" "WP......dW" "WWWWWWWWWW"}, {10, 10, 1, 0, "WWWWWWWWWW" "W.r...r.XW" "W........W" "W... .W" "W... .W" "W... .W" "W... B .W" "W........W" "WP.......W" "WWWWWWWWWW"}, {10, 10, 1, 0, "WWWWWWWWWW" "W.r...r.XW" "W........W" "W... .W" "W... .W" "W... .W" "W... F .W" "W........W" "WP......dW" "WWWWWWWWWW"}, {40, 22, 9, 150, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WP.....................................W" "W......................................W" "W......................................W" "W......................................W" "W.................r................ W" "W....................r.................W" "W.......r...........r..................W" "W..................r...................W" "W....... oooooooooo...........r........W" "W....... ..............................W" "W....... ..................... ........W" "W....... ..................... ........W" "W....... ..................... ........W" "W.......B..................... ........W" "W.......B.....................F........W" "W....... ..................... ........W" "W......................................W" "W......................................W" "W......................................W" "W.....................................XW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"}, {160, 88, 20, 120, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WP.............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W........................................................................ .........................................................W" "W........................................................................ ........................... .........................................................W" "W........................................................................ . B . .........................................................W" "W........................................................................ . ....................... . .........................................................W" "W........................................................................ . ....................... . .........................................................W" "W........................................................................ . ....................... . .........................................................W" "W........................................................................ . ....................... . .........................................................W" "W........................................................................ . ....................... . .........................................................W" "W............ .............. ........................... . ....................... . .........................................................W" "W............ .............. ........................... . . .........................................................W" "W............ .............. ........................... ........................... .........................................................W" "W............F d ..............F d ........................... B .........................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W............................................................................................................................................................. W" "W............................................................................................................................................................. W" "W............................................................................................................................................................. W" "W............................................................................................................................................................. W" "W............................................................................................................................................................. W" "W............................................................................................................................................................. W" "W....................................................................r........................................................................................ W" "W...................................................................rr......................r................................................................. W" "W..................................................................rrr.....................rr................................................................. W" "W.................................................................rrrr....................rrr................................................................. W" "W................................................................rrrrr...................rrrr................................................................. W" "W...................rwwwwwwwwwwwwwwwwwwwwwwr.....................rrrr...................rrrrr....................rwwwwwwwwwwwwwwwwwwwwwwr..................... W" "W....................w....................w......................rrr...................rrrrrr.....................w....................w...................... W" "W....................w....................w......................rr..r.................rrrrrr.....................w....................w...................... W" "W....................w....................w......................r..rr.................rrrrrr.....................w....................w...................... W" "W....................w....................w........................rrr.................rrrrrr.....................w....................w...................... W" "W....................w....................w.......................rrrrrrrrrrrrrrrrrrrrrrrrrrr.....................w....................w...................... W" "W....................w....................w......................rrrrrrrrrrrrrrrrrrrrrrrrrrrr.....................w....................w...................... W" "W....................w....................w......................rrrrrrrrrrrrrrrrrrrrrrrrrrr......................w....................w...................... W" "W....................w....................w......................rrrrr.................rrrr.......................w....................w...................... W" "W....................wAA..................w......................rrrrr.................rrr..r.....................w..................AAw...................... W" "W...................rwwwwwwwwwwwwwwwwwwwwwwr.....................rrrrr.................rr..rr....................rwwwwwwwwwwwwwwwwwwwwwwr..................... W" "W................................................................rrrrr.................r..rrr................................................................. W" "W................................................................rrrrr...................rrrr..................................................................W" "W................... F .....................rrrr...................rrrrr.................... F ......................W" "W................................................................rrr...................rrrrr...................................................................W" "W................................................................rr....................rrrr....................................................................W" "W................................................................r.....................rr......................................................................W" "W......................................................................................r.......................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W..............................................................................................................................................................W" "W.............................................................................................................................................................XW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"}, {40, 22, 1, 150, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WP........r.............r...rr..r......W" "Wr.....r..........r.............r...r.dW" "W....r..........r..wwwwwwwwwwwwwwwwwwwwW" "W..rr........r..w..r.r....r............W" "W..rd.rr.rr.....w......r.........r.r..rW" "W.rr..r......r..w..rr....rr..r..rw.r..rW" "Wwwwwww.........w....r.rr..r.....w.rr..W" "W.........rr.r..w.r..............wrr...W" "W......r.r.r....wrr.......r.....rw.d.r.W" "W.rrr...........wrdr........r....wdd...W" "Wr..r.r......r.rw.....rr.rr.r.r..wdd.r.W" "Wr.r...w....r...w..rrr....rr...r.w....rW" "W....r.w........w......r..rr.r...w.....W" "W......w...r..r.w.....r.r......rrw....rW" "W..r.r.wrr...rdrw..r..r...r......w...rrW" "Wr.....w..r.....w.r....r..rr..r.rw..r.rW" "W.rr...w....r..rw...r.wwwwwwwwwwwwwwwwwW" "W......wwwwwwwwww.r..r...r...r......r..W" "W..rr.....r.rr....d....r.r.r....r....rrW" "W.r....r.....r...dd...rrr.r...r.r.....XW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"}, {40, 22, 9, 150, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WP..........r.....w.......r............W" "W.................w....................W" "W.................w.w.......w.w........W" "W.......w.w.......w.wwwwwwwwwwwwwwwwww.W" "Wwwwwwwww.wwwwwwwww.w ..w W" "W w.w w.w w.w W" "W w.w w.. w.r dW" "WFd r.r wwwwwwwwwww.w.wwwwwwwW" "Wwwwwwwww.wwwwwwwww.w ..w W" "W w.w w.w w.w W" "W w.w w.r w.wd W" "W d r.r w.wwwwwwwww.wwwwwwww.W" "Wwwwwwwww.wwwwwwwww.w w.w W" "W w.w w.w w.w W" "W w.w ..r w.w dW" "W d r.r w.wwwwwwwww.w.wwwwwwwW" "Wwwwwwwww.wwwwwwwww.w ..w W" "W w.w w.w w.w W" "W w.w w.r w.wd .W" "W d r.r dwwwwwwwwwwwwwwwwwwwwXW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"}, {40, 22, 10, 0, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWW WWWWWW W WW WWWW WWWWW" "WWWWWWW WWWW PWW WWWW WW WWWW WWWWW" "WWWWWWWW WW WWW WWWW WW WWWW WWWWW" "WWWWWWWWWW WWWWW WWWW WW WWWW WWWWW" "WWWWWWWWWW WWWWW WWWW WW WWWW WWWWW" "WWWWWWWWWW WWWWW WWW WWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWW WWWWWW WW WWW WWW WWWWWWWW" "WWWW WWWWWW WWWW WWWWW WW WWWWWWWW" "WWWWW WWWW WWWWW WWWWW W WWWWWWWW" "WWWWW W W WWWWW WWWWW W WWWWWWWW" "WWWWWW WWWWWW WWWWW WW WWWWWWWW" "WWWWWW WW WWWW WWW WWW WWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"}}; Tile CharToTile(const char ch) { static std::unordered_map<char, Tile> tileMap = { {'P', Tile::PlayerFirst}, {'X', Tile::DoorFirst}, {'A', Tile::AmoebaFirst}, {'B', Tile::ButterflyFirst}, {'F', Tile::FireflyFirst}, {'W', Tile::Metal1}, {'w', Tile::Brick1}, {'.', Tile::Dirt1}, {'r', Tile::BoulderFirst}, {'d', Tile::DiamondFirst}, {'o', Tile::BarrelFirst}, {' ', Tile::Empty}}; std::unordered_map<char, Tile>::const_iterator tile = tileMap.find(ch); RK_ASSERT(tile != tileMap.end(), "ERROR: Unknown character '{}' in level definition", ch); return (tile != tileMap.end()) ? tile->second : Tile::Empty; } Animation CharToAnimation(const char ch) { static std::unordered_map<char, Animation> animationMap = { {'P', {{Tile::PlayerIdle0, Tile::PlayerIdle1, Tile::PlayerIdle2, Tile::PlayerIdle3}}}, {'A', {{Tile::Amoeba0, Tile::Amoeba1, Tile::Amoeba2, Tile::Amoeba3, Tile::Amoeba4, Tile::Amoeba5, Tile::Amoeba6, Tile::Amoeba7}}}, {'B', {{Tile::Butterfly0, Tile::Butterfly1, Tile::Butterfly2, Tile::Butterfly3}}}, {'F', {{Tile::Firefly0, Tile::Firefly1, Tile::Firefly2, Tile::Firefly3}}}, {'d', {{Tile::Diamond0, Tile::Diamond1, Tile::Diamond2, Tile::Diamond3, Tile::Diamond4, Tile::Diamond5, Tile::Diamond6, Tile::Diamond7}}}}; std::unordered_map<char, Animation>::const_iterator animation = animationMap.find(ch); if (animation == animationMap.end()) { return Animation{}; } else { return animation->second; } } Roll CharToRoll(const char ch) { static std::unordered_map<char, Roll> rollMap = { {'r', {{Tile::Boulder0, Tile::Boulder1, Tile::Boulder2, Tile::Boulder3}}}, {'o', {{Tile::Barrel0, Tile::Barrel1, Tile::Barrel2, Tile::Barrel3}}}}; std::unordered_map<char, Roll>::const_iterator roll = rollMap.find(ch); if (roll == rollMap.end()) { return Roll{}; } else { return roll->second; } } const Animation &GetPlayerAnimation(PlayerState state, bool lastWasLeft) { static std::array<Animation, 6> animations = { Animation{{Tile::PlayerIdle0, Tile::PlayerIdle0, Tile::PlayerIdle0, Tile::PlayerIdle0}}, Animation{{Tile::PlayerIdle0, Tile::PlayerIdle1, Tile::PlayerIdle2, Tile::PlayerIdle3}}, // TODO: idle animations Animation{{Tile::PlayerIdle0, Tile::PlayerIdle1, Tile::PlayerIdle2, Tile::PlayerIdle3}}, // TODO: idle animations Animation{{Tile::PlayerIdle0, Tile::PlayerIdle1, Tile::PlayerIdle2, Tile::PlayerIdle3}}, // TODO: idle animations Animation{{Tile::PlayerLeft0, Tile::PlayerLeft1, Tile::PlayerLeft2, Tile::PlayerLeft3}}, Animation{{Tile::PlayerRight0, Tile::PlayerRight1, Tile::PlayerRight2, Tile::PlayerRight3}}}; if (state == PlayerState::MovingUp || state == PlayerState::MovingDown) { state = lastWasLeft ? PlayerState::MovingLeft : PlayerState::MovingRight; } return animations[static_cast<int>(state)]; } PlayerState SetPlayerBlinkState(PlayerState state) { switch (state) { case PlayerState::Idle: state = PlayerState::Blink; break; case PlayerState::Blink: state = PlayerState::Blink; break; case PlayerState::FootTap: state = PlayerState::BlinkFootTap; break; case PlayerState::BlinkFootTap: state = PlayerState::BlinkFootTap; break; } return state; } PlayerState ClearPlayerBlinkState(PlayerState state) { switch (state) { case PlayerState::Idle: state = PlayerState::Idle; break; case PlayerState::Blink: state = PlayerState::Idle; break; case PlayerState::FootTap: state = PlayerState::FootTap; break; case PlayerState::BlinkFootTap: state = PlayerState::FootTap; break; } return state; } PlayerState SwapPlayerFootTapState(PlayerState state) { switch (state) { case PlayerState::Idle: state = PlayerState::FootTap; break; case PlayerState::Blink: state = PlayerState::BlinkFootTap; break; case PlayerState::FootTap: state = PlayerState::Idle; break; case PlayerState::BlinkFootTap: state = PlayerState::Blink; break; } return state; } HazelDashLayer::HazelDashLayer() : Layer("HelloBoulder"), m_ViewPort(0.0f, 0.0f, 20.0f, 11.0f), m_FixedTimestep(1.0 / 8.0f) // game logic runs at 8 fps , m_AnimationTimestep(1.0f / 25.0f) // animation runs at 25fps , m_FixedUpdateAccumulatedTs(0.0f), m_AnimatorAccumulatedTs(0.0f), m_PushProbability(0.25), m_CurrentLevel(STARTING_LEVEL), m_Width(0), m_Height(0), m_Score(0), m_ScoreRequired(0), m_AmoebaSize(0), m_AmoebaPotential(0), m_GamePaused(false), m_PlayerIsAlive(false), m_WonLevel(false) { #if BATCHRENDER_TEST m_CurrentLevel = 4; m_ViewPort = {0.0f, 0.0f, 160.0f, 88.0f}; #endif m_ViewPort.SetCameraSpeed((1.0f / m_FixedTimestep) - 1.0f); } void HazelDashLayer::OnAttach() { std::string basePath = ProjectSourceDir + "/Assets/textures/dash"; std::string extension = ".png"; for (size_t i = 0; i < m_Tiles.size(); ++i) { std::ostringstream os; os << std::setfill('0') << std::setw(3) << i; std::string path = basePath + os.str() + extension; m_Tiles[i] = Hazel::Texture2D::Create(path); } Hazel::RenderCommand::SetClearColor({0.0f, 0.0f, 0.0f, 1}); LoadScene(m_CurrentLevel); } void HazelDashLayer::OnDetach() { } void HazelDashLayer::OnUpdate(Hazel::Timestep ts) { RK_PROFILE_FUNCTION(); if (m_GamePaused) { return; } if (m_WonLevel) { LoadScene(++m_CurrentLevel); } Hazel::Renderer2D::ResetStats(); Hazel::Renderer2D::StatsBeginFrame(); m_FixedUpdateAccumulatedTs += ts; if (m_FixedUpdateAccumulatedTs > m_FixedTimestep) { // // Each of these functions is a "system" that operates on a set of game entities. // I envisage these will become some sort of scripted game-logic in the future... // // These systems are updated on a fixed timestep PhysicsFixedUpdate(); PlayerControllerFixedUpdate(); EnemiesFixedUpdate(); AmoebaFixedUpdate(); m_FixedUpdateAccumulatedTs = 0.0; } // These systems update as fast as they like PlayerControllerUpdate(ts); ExploderUpdate(ts); AnimatorUpdate(ts); CameraControllerUpdate(ts); RendererUpdate(ts); RK_PROFILE_FRAMEMARKER(); Hazel::Renderer2D::StatsEndFrame(); auto stats = Hazel::Renderer2D::GetStats(); float averageRenderTime = stats.TotalFrameRenderTime / stats.FrameRenderTime.size(); // nb: wont be accurate until we have gathered at least stats.FrameRenderTime().size() results float averageFPS = 1.0f / averageRenderTime; char buffer[64]; sprintf_s(buffer, 64, "Average frame render time: %8.5f (%5.0f fps)", averageRenderTime, averageFPS); glfwSetWindowTitle((GLFWwindow *)Hazel::Application::Get().GetWindow().GetNativeWindow(), buffer); } void HazelDashLayer::OnEvent(Hazel::Event &e) { Hazel::EventDispatcher dispatcher(e); dispatcher.Dispatch<Hazel::KeyPressedEvent>(RK_BIND_EVENT_FN(HazelDashLayer::OnKeyPressed)); } bool HazelDashLayer::OnKeyPressed(Hazel::KeyPressedEvent &e) { if (e.GetKeyCode() == RK_KEY_SPACE) { if (m_PlayerIsAlive) { m_GamePaused = !m_GamePaused; } else { LoadScene(m_CurrentLevel); } } else if (e.GetKeyCode() == RK_KEY_ESCAPE) { LoadScene(m_CurrentLevel); } return true; } void HazelDashLayer::LoadScene(int level) { const LevelDefinition &definition = s_LevelDefinition[level]; m_Scene.DestroyAllEntities(); m_Entities.clear(); m_Width = definition.Width; m_Height = definition.Height; m_WonLevel = false; m_EmptyEntity = m_Scene.CreateEntity(); m_EmptyEntity.AddComponent<Tile>(Tile::Empty); Position playerPosition; m_Entities.resize(m_Width * m_Height); for (int row = 0; row < m_Height; ++row) { for (int col = 0; col < m_Width; ++col) { int charIndex = (m_Width * (m_Height - (row + 1))) + col; RK_ASSERT(charIndex < definition.LevelData.size(), "insufficient levelData supplied"); if (charIndex < definition.LevelData.size()) { char ch = definition.LevelData[charIndex]; Tile tile = CharToTile(ch); int index = (m_Width * row) + col; auto entity = m_EmptyEntity; if (!IsEmpty(tile)) { entity = m_Scene.CreateEntity(); if (IsAmoeba(tile)) { entity.AddComponent<Amoeba>(); } else if (IsBoulder(tile) || IsDiamond(tile)) { entity.AddComponent<Mass>(); } else if (IsBarrel(tile)) { entity.AddComponent<Mass>(MassState::Stationary, 0, 5); } else if (IsButterfly(tile)) { entity.AddComponent<EnemyMovement>(3, false); } else if (IsFirefly(tile)) { entity.AddComponent<EnemyMovement>(1, true); } else if (IsDoor(tile)) { m_ExitEntity = entity; } else if (IsPlayer(tile)) { entity.AddComponent<PlayerState>(PlayerState::Idle); playerPosition = {row, col}; } entity.AddComponent<Position>(row, col); entity.AddComponent<Tile>(tile); Animation animation = CharToAnimation(ch); if (!animation.Frames.empty()) { entity.AddComponent<Animation>(animation); } Roll roll = CharToRoll(ch); if (!roll.Frames.empty()) { entity.AddComponent<Roll>(roll); } } m_Entities[index] = entity; } } } RK_ASSERT((playerPosition.Row > 0) && (playerPosition.Col >= 0), "ERROR: ({},{}) is not a legal starting position for player (check that level definition contains player start point)", playerPosition.Row, playerPosition.Col); m_Score = 0; m_ScoreRequired = definition.ScoreRequired; m_ViewPort.SetLevelSize(static_cast<float>(m_Width), static_cast<float>(m_Height)); m_ViewPort.SetPlayerPosition(static_cast<float>(playerPosition.Col), static_cast<float>(playerPosition.Row)); } void HazelDashLayer::PhysicsFixedUpdate() { RK_PROFILE_FUNCTION(); // Note: To get the behaviour of the original DB game, the "physics" system must evaluate // the entities in level top-down order. // However, the ECS will not do that. // Instead, entities will just be iterated in whatever order they happen to be stored in the // underlying data structures (and to try and iterate them in any other order kind of defeats // the purpose of the ECS in the first place (which is to iterate in a cache-friendly way)) // EnTT does allow for sorting of components (i.e. sort them first, and then iterate them in order) // So that is worth investigating. // However, for now I am just going to ignore it, and iterate the entities in the order that the ECS // has them. static const Position Below = {-1, 0}; static const Position Left = {0, -1}; static const Position BelowLeft = {-1, -1}; static const Position Right = {0, 1}; static const Position BelowRight = {-1, 1}; m_Scene.m_Registry.group<Mass>(entt::get<Position>).each([this](const auto entityHandle, auto &mass, auto &pos) { Hazel::Entity entity(entityHandle, &m_Scene); Hazel::Entity entityBelow = GetEntity(pos + Below); auto tileBelow = entityBelow.GetComponent<Tile>(); if (IsEmpty(tileBelow)) { mass.State = MassState::Falling; ++mass.HeightFallen; SwapEntities(pos, pos + Below); pos += Below; } else { if ((mass.State == MassState::Falling) && IsExplosive(tileBelow)) { OnExplode(pos + Below); } else if (mass.HeightFallen > mass.FallLimit) { OnExplode(pos); } else { if (IsRounded(tileBelow)) { Hazel::Entity entityLeft = GetEntity(pos + Left); Hazel::Entity entityBelowLeft = GetEntity(pos + BelowLeft); auto tileLeft = entityLeft.GetComponent<Tile>(); auto tileBelowLeft = entityBelowLeft.GetComponent<Tile>(); if (IsEmpty(tileLeft) && IsEmpty(tileBelowLeft)) { // bounce left mass.State = MassState::Falling; SwapEntities(pos, pos + Left); pos += Left; if (entity.HasComponent<Roll>()) { auto &roll = entity.GetComponent<Roll>(); auto &tile = entity.GetComponent<Tile>(); roll.CurrentFrame = (roll.CurrentFrame - 1) % roll.Frames.size(); tile = roll.Frames[roll.CurrentFrame]; } } else { Hazel::Entity entityRight = GetEntity(pos + Right); Hazel::Entity entityBelowRight = GetEntity(pos + BelowRight); auto tileRight = entityRight.GetComponent<Tile>(); auto tileBelowRight = entityBelowRight.GetComponent<Tile>(); if (IsEmpty(tileRight) && IsEmpty(tileBelowRight)) { // bounce right mass.State = MassState::Falling; SwapEntities(pos, pos + Right); pos += Right; if (entity.HasComponent<Roll>()) { auto &roll = entity.GetComponent<Roll>(); auto &tile = entity.GetComponent<Tile>(); roll.CurrentFrame = (roll.CurrentFrame + 1) % roll.Frames.size(); tile = roll.Frames[roll.CurrentFrame]; } } else { mass.State = MassState::Stationary; mass.HeightFallen = 0; } } } else { mass.State = MassState::Stationary; mass.HeightFallen = 0; } } } }); } void HazelDashLayer::PlayerControllerFixedUpdate() { RK_PROFILE_FUNCTION(); static const Position Left = {0, -1}; static const Position Right = {0, 1}; static const Position Up = {1, 0}; static const Position Down = {-1, 0}; static bool lastWasLeft = false; // hack m_Scene.m_Registry.group<PlayerState>(entt::get<Position, Animation>).each([this](auto &state, auto &pos, auto &animation) { PlayerState newState = PlayerState::Idle; PlayerState secondaryState = PlayerState::Idle; if (Hazel::Input::IsKeyPressed(RK_KEY_LEFT) || Hazel::Input::IsKeyPressed(RK_KEY_A)) { newState = PlayerState::MovingLeft; lastWasLeft = true; } else if (Hazel::Input::IsKeyPressed(RK_KEY_RIGHT) || Hazel::Input::IsKeyPressed(RK_KEY_D)) { newState = PlayerState::MovingRight; lastWasLeft = false; } if (Hazel::Input::IsKeyPressed(RK_KEY_UP) || Hazel::Input::IsKeyPressed(RK_KEY_W)) { secondaryState = newState; newState = PlayerState::MovingUp; } else if (Hazel::Input::IsKeyPressed(RK_KEY_DOWN) || Hazel::Input::IsKeyPressed(RK_KEY_S)) { secondaryState = newState; newState = PlayerState::MovingDown; } if (IsIdle(state)) { if (!IsIdle(newState)) { state = newState; animation = GetPlayerAnimation(state, lastWasLeft); } } else { if (state != newState) { state = newState; animation = GetPlayerAnimation(state, lastWasLeft); } } bool ctrlPressed = Hazel::Input::IsKeyPressed(RK_KEY_LEFT_CONTROL) || Hazel::Input::IsKeyPressed(RK_KEY_RIGHT_CONTROL); Position oldPos = pos; switch (state) { case PlayerState::MovingLeft: TryMovePlayer(pos, Left, ctrlPressed); break; case PlayerState::MovingRight: TryMovePlayer(pos, Right, ctrlPressed); break; case PlayerState::MovingUp: if (!TryMovePlayer(pos, Up, ctrlPressed)) { if (secondaryState == PlayerState::MovingLeft) { TryMovePlayer(pos, Left, ctrlPressed); } else if (secondaryState == PlayerState::MovingRight) { TryMovePlayer(pos, Right, ctrlPressed); } } break; case PlayerState::MovingDown: if (!TryMovePlayer(pos, Down, ctrlPressed)) { if (secondaryState == PlayerState::MovingLeft) { TryMovePlayer(pos, Left, ctrlPressed); } else if (secondaryState == PlayerState::MovingRight) { TryMovePlayer(pos, Right, ctrlPressed); } } break; } if (oldPos != pos) { Hazel::Entity entityAtNewPos = GetEntity(pos); auto tile = entityAtNewPos.GetComponent<Tile>(); SwapEntities(oldPos, pos); ClearEntity(oldPos); OnPlayerMoved(pos); if (IsDoor(tile)) { OnLevelCompleted(); } if (IsCollectable(tile)) { OnIncreaseScore(); } } }); } void HazelDashLayer::PlayerControllerUpdate(Hazel::Timestep ts) { RK_PROFILE_FUNCTION(); m_Scene.m_Registry.group<PlayerState>(entt::get<Position, Animation>).each([this](auto &state, auto &pos, auto &animation) { if (animation.CurrentFrame == (animation.Frames.size() - 1)) { if (IsIdle(state)) { PlayerState newState = state; if (Random::Uniform0_1() < 0.25f) { newState = SetPlayerBlinkState(state); } else { newState = ClearPlayerBlinkState(state); } if (Random::Uniform0_1() < 1.0f / 16.0f) { newState = SwapPlayerFootTapState(state); } if (state != newState) { state = newState; animation = GetPlayerAnimation(state, false); } } } }); } bool HazelDashLayer::TryMovePlayer(Position &pos, Position direction, const bool ctrlPressed) { bool retVal = false; Hazel::Entity entity = GetEntity(pos + direction); auto &tile = entity.GetComponent<Tile>(); if (CanBeOccupied(tile)) { retVal = true; if (!ctrlPressed) { pos += direction; } } else if ((direction.Row == 0) && IsPushable(tile)) { retVal = true; if (Random::Uniform0_1() < m_PushProbability) { Position posBelow = {pos.Row - 1, pos.Col + direction.Col}; Position posAcross = {pos.Row, pos.Col + (2 * direction.Col)}; Hazel::Entity entityBelow = GetEntity(posBelow); Hazel::Entity entityAcross = GetEntity(posAcross); const auto tileBelow = entityBelow.GetComponent<Tile>(); const auto tileAcross = entityAcross.GetComponent<Tile>(); if (!IsEmpty(tileBelow) && IsEmpty(tileAcross)) { SwapEntities(posAcross, pos + direction); auto &posPushed = entity.GetComponent<Position>(); posPushed += direction; if (entity.HasComponent<Roll>()) { auto &roll = entity.GetComponent<Roll>(); roll.CurrentFrame = (roll.CurrentFrame + direction.Col) % roll.Frames.size(); tile = roll.Frames[roll.CurrentFrame]; } if (!ctrlPressed) { pos += direction; } } } } return retVal; } void HazelDashLayer::OnPlayerMoved(const Position &pos) { // TODO: placeholder code. Should be done with "proper" events at some point m_ViewPort.SetPlayerPosition(static_cast<float>(pos.Col), static_cast<float>(pos.Row)); } void HazelDashLayer::OnPlayerDied() { // TODO: placeholder code. Should be done with "proper" events at some point m_PlayerIsAlive = false; } void HazelDashLayer::OnLevelCompleted() { // TODO: placeholder code. Should be done with "proper" events at some point m_WonLevel = true; } void HazelDashLayer::OnIncreaseScore() { // TODO: placeholder code. Should be done with "proper" events at some point ++m_Score; if (m_Score == m_ScoreRequired) { Animation animation = {{Tile::Door0, Tile::Door1, Tile::Door2, Tile::Door3}, 0, false}; m_ExitEntity.AddComponent<Animation>(animation); } } void HazelDashLayer::EnemiesFixedUpdate() { RK_PROFILE_FUNCTION(); static std::array<Position, 4> Directions{ Position{-1, 0}, Position{0, -1}, Position{1, 0}, Position{0, 1}}; m_Scene.m_Registry.group<EnemyMovement>(entt::get<Position>).each([this](auto &movement, auto &pos) { // If next to player, then explode (and do not move) bool move = true; for (auto direction : Directions) { if (IsPlayer(GetEntity(pos + direction).GetComponent<Tile>())) { OnExplode(pos); move = false; break; } } if (move) { // try to turn in preferred direction // if that is not possible, go straight ahead // if that is not possible either, then don't move, but change to opposite direction for next frame int direction = (movement.Direction + (movement.PreferLeftTurn ? -1 : 1)) % Directions.size(); Position preferredPos = pos + Directions[direction]; if (IsEmpty(GetEntity(preferredPos).GetComponent<Tile>())) { SwapEntities(pos, preferredPos); pos = preferredPos; movement.Direction = direction; } else { Position straightPos = pos + Directions[movement.Direction]; if (IsEmpty(GetEntity(straightPos).GetComponent<Tile>())) { SwapEntities(pos, straightPos); pos = straightPos; } else { movement.Direction = (movement.Direction + 2) % Directions.size(); } } } }); } void HazelDashLayer::OnExplode(const Position &pos) { RK_PROFILE_FUNCTION(); // TODO: placeholder code. Should be done with "proper" events at some point static std::array<Position, 9> Offsets = { Position{1, -1}, Position{1, 0}, Position{1, 1}, Position{0, -1}, Position{0, 0}, Position{0, 1}, Position{-1, -1}, Position{-1, 0}, Position{-1, 1}}; static Animation animation1 = {{Tile::Explosion0, Tile::Explosion1, Tile::Explosion2, Tile::Explosion3, Tile::Explosion4, Tile::Explosion5, Tile::Explosion6, Tile::Explosion7}}; static Animation animation2 = {{Tile::Explosion0, Tile::Explosion1, Tile::Explosion2, Tile::Explosion3, Tile::ExplosionDiamond4, Tile::ExplosionDiamond5, Tile::ExplosionDiamond6, Tile::Diamond7}}; auto tile = GetEntity(pos).GetComponent<Tile>(); if (IsPlayer(tile)) { OnPlayerDied(); } bool explodeToDiamond = IsButterfly(tile); // // At this point, other systems are still iterating their entities, // so we can't go destroying anything just yet. // What we'll do here is create an explosion entities at appropriate // positions, then when the exploder system gets its Update, we will // wreak the destruction there. for (auto offset : Offsets) { if (!IsExplodable(GetEntity(pos + offset).GetComponent<Tile>())) { continue; } Hazel::Entity entity = m_Scene.CreateEntity(); entity.AddComponent<Position>(pos + offset); entity.AddComponent<Explosion>(Explosion::Ignite); if (explodeToDiamond) { entity.AddComponent<Animation>(animation2); entity.AddComponent<Tile>(animation2.Frames[0]); } else { entity.AddComponent<Animation>(animation1); entity.AddComponent<Tile>(animation1.Frames[0]); } } } void HazelDashLayer::AmoebaFixedUpdate() { RK_PROFILE_FUNCTION(); static const std::array<Position, 4> Directions = { Position{-1, 0}, Position{0, -1}, Position{1, 0}, Position{0, 1}}; auto amoebas = m_Scene.m_Registry.group<Amoeba>(entt::get<Position>); m_AmoebaSize = static_cast<int>(amoebas.size()); if (m_AmoebaSize >= 200) { // TODO: parameterize? OnSolidify(Tile::BoulderFirst); } m_AmoebaPotential = 0; std::unordered_set<Position> growPositions; amoebas.each([&](auto &amoeba, auto &pos) { for (auto direction : Directions) { Hazel::Entity entityOther = GetEntity(pos + direction); auto tile = entityOther.GetComponent<Tile>(); if (IsEmpty(tile) || tile == Tile::Dirt1) { ++m_AmoebaPotential; if (Random::Uniform0_1() < amoeba.GrowthProbability) { growPositions.emplace(pos + direction); } } else if (IsExplosive(tile)) { OnExplode(pos + direction); } amoeba.GrowthProbability *= 1.0f + static_cast<float>(amoebas.size()) / 200000.0f; } }); if (m_AmoebaPotential == 0) { OnSolidify(Tile::Diamond0); } else { for (auto pos : growPositions) { Hazel::Entity entity = GetEntity(pos); auto &tileInitial = entity.GetComponent<Tile>(); if (IsEmpty(tileInitial)) { entity = m_Scene.CreateEntity(); entity.AddComponent<Tile>(tileInitial); entity.AddComponent<Position>(pos); SetEntity(pos, entity); } entity.AddComponent<Amoeba>(); const Animation &animation = CharToAnimation('A'); entity.AddComponent<Animation>(animation); auto &tile = entity.GetComponent<Tile>(); tile = animation.Frames[animation.CurrentFrame]; // TODO: it would be nicer to use EnTT "short circuit" to automatically set the tile when Animation component is added } } } void HazelDashLayer::OnSolidify(const Tile solidifyTo) { m_Scene.m_Registry.view<Amoeba, Tile>().each([&](const auto entityHandle, auto &amoeba, auto &tile) { Hazel::Entity entity(entityHandle, &m_Scene); entity.RemoveComponent<Amoeba>(); tile = solidifyTo; if (IsDiamond(tile)) { auto &animation = entity.GetComponent<Animation>(); // we know it has an Animation component because it was an Amoeba, and Amoeba entities have an Animation animation = CharToAnimation('d'); } else { entity.RemoveComponent<Animation>(); } }); } void HazelDashLayer::ExploderUpdate(Hazel::Timestep ts) { RK_PROFILE_FUNCTION(); // When we get here, other systems are finished iterating. // It is now safe to destroy the game entities at position of explosion entities m_Scene.m_Registry.group<Explosion>(entt::get<Position, Animation, Tile>).each([this](const auto entityHandle, auto &explosion, auto &pos, auto &animation, auto &tile) { if (explosion == Explosion::Ignite) { ClearEntity(pos); SetEntity(pos, {entityHandle, &m_Scene}); explosion = Explosion::Burn; } else { if (animation.CurrentFrame == animation.Frames.size() - 1) { if (IsDiamond(animation.Frames.back())) { // turn into a diamond Hazel::Entity entity(entityHandle, &m_Scene); entity.RemoveComponent<Explosion>(); entity.AddComponent<Mass>(); animation = CharToAnimation('d'); } else { //RK_ASSERT(Hazel::Entity(entityHandle, &m_Scene) == GetEntity(pos), "Something has misplaced an explosion - game logic error!"); ClearEntity(pos); } } } }); } void HazelDashLayer::AnimatorUpdate(Hazel::Timestep ts) { RK_PROFILE_FUNCTION(); m_AnimatorAccumulatedTs += ts; if (m_AnimatorAccumulatedTs > m_AnimationTimestep) { m_AnimatorAccumulatedTs = 0.0f; m_Scene.m_Registry.group<Animation>(entt::get<Tile>).each([this](const auto entityHandle, auto &animation, auto &tile) { if (++animation.CurrentFrame >= animation.Frames.size()) { if (animation.Repeat) { animation.CurrentFrame = 0; } else { Hazel::Entity entity(entityHandle, &m_Scene); entity.RemoveComponent<Animation>(); return; } } tile = animation.Frames[animation.CurrentFrame]; }); } } void HazelDashLayer::CameraControllerUpdate(Hazel::Timestep ts) { RK_PROFILE_FUNCTION(); // TODO: placeholder code. Camera and Viewport may become entities and components at some point m_ViewPort.Update(ts); } void HazelDashLayer::RendererUpdate(Hazel::Timestep ts) { RK_PROFILE_FUNCTION(); static glm::vec2 tileSize{1.0f, 1.0f}; Hazel::RenderCommand::Clear(); Hazel::Renderer2D::BeginScene(m_ViewPort.GetCamera()); // Theres a couple of options for how to render here. // Ideally, we'd like to just say "for each entity that has a position and a tile, render it" // That iteration is cache-friendly, but it renders a lot of entities that it doesn't need to // (the ones that are not in the viewport). // (either that, or we have to check "is in viewport" for every entity) // // The other way to do it is use our "index" of entities m_Entities[], since we can efficiently query that // for just the entities that are in the view port. // However, this is not cache-friendly since it will jump all over the place in the underlying // component data. // // Which is best ?? // Is there a better way? m_Scene.m_Registry.group<Position, Tile>().each([this](auto &pos, auto &tile) { if (m_ViewPort.Overlaps(pos)) { glm::vec2 xy = {pos.Col, pos.Row}; Hazel::Renderer2D::DrawQuad(xy, tileSize, m_Tiles[(int)tile]); } }); Hazel::Renderer2D::EndScene(); } Hazel::Entity HazelDashLayer::GetEntity(const Position pos) { return m_Entities[(m_Width * pos.Row) + pos.Col]; } void HazelDashLayer::SetEntity(Position pos, Hazel::Entity entity) { m_Entities[(m_Width * pos.Row) + pos.Col] = entity; } void HazelDashLayer::ClearEntity(const Position pos) { int index = (m_Width * pos.Row) + pos.Col; if (m_Entities[index] != m_EmptyEntity) { m_Scene.DestroyEntity(m_Entities[index]); m_Entities[index] = m_EmptyEntity; } } void HazelDashLayer::SwapEntities(const Position posA, const Position posB) { size_t indexA = (m_Width * posA.Row) + posA.Col; size_t indexB = (m_Width * posB.Row) + posB.Col; Hazel::Entity entityA = m_Entities[indexA]; Hazel::Entity entityB = m_Entities[indexB]; std::swap(m_Entities[(m_Width * posA.Row) + posA.Col], m_Entities[(m_Width * posB.Row) + posB.Col]); Hazel::Entity entityA2 = m_Entities[indexA]; Hazel::Entity entityB2 = m_Entities[indexB]; } #ifdef _DEBUG void HazelDashLayer::OnImGuiRender() { ImGui::Begin("Game Stats"); ImGui::Text("Score: %d", m_Score); ImGui::Separator(); int updateFPS = (int)(1.0f / m_FixedTimestep); ImGui::DragInt("Game Speed: ", &updateFPS, 1, 1, 60); m_FixedTimestep = 1.0f / updateFPS; m_ViewPort.SetCameraSpeed((1.0f / m_FixedTimestep) - 1.0f); ImGui::Separator(); ImGui::Text("Amoeba:"); ImGui::Text("Count: %d", m_AmoebaSize); ImGui::Text("Growth Potential: %d", m_AmoebaPotential); ImGui::Separator(); auto stats = Hazel::Renderer2D::GetStats(); ImGui::Text("Renderer2D Stats:"); ImGui::Text("Draw Calls: %d", stats.DrawCalls); ImGui::Text("Quads: %d", stats.QuadCount); ImGui::Text("Vertices: %d", stats.GetTotalVertexCount()); ImGui::Text("Indices: %d", stats.GetTotalIndexCount()); ImGui::Text("Textures: %d", stats.TextureCount); float averageRenderTime = stats.TotalFrameRenderTime / stats.FrameRenderTime.size(); // nb: wont be accurate until we have gathered at least stats.FrameRenderTime().size() results float averageFPS = 1.0f / averageRenderTime; ImGui::Text("Average frame render time: %8.5f (%5.0f fps)", averageRenderTime, averageFPS); ImGui::End(); } #endif
39.018139
283
0.475331
rocketman123456
7ac42a0cc2d9f6663081876e32d27ff07885aa65
10,437
cpp
C++
main.cpp
shantigilbert/TvTextViewer
87ca192a81bce423af6723c7514b367db6bf6580
[ "MIT" ]
null
null
null
main.cpp
shantigilbert/TvTextViewer
87ca192a81bce423af6723c7514b367db6bf6580
[ "MIT" ]
null
null
null
main.cpp
shantigilbert/TvTextViewer
87ca192a81bce423af6723c7514b367db6bf6580
[ "MIT" ]
null
null
null
/** Copyright (c) 2021 Nikolai Wuttke * * 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 "imgui.h" #include "imgui_internal.h" #include "imgui_impl_sdl.h" #include "imgui_impl_opengl3.h" #include <cxxopts.hpp> #include <GLES2/gl2.h> #include <SDL.h> #include <cstdlib> #include <iostream> #include <fstream> #include <optional> namespace { std::optional<cxxopts::ParseResult> parseArgs(int argc, char** argv) { try { cxxopts::Options options(argv[0], "TvTextViewer - a full-screen text viewer"); options .positional_help("[input file]") .show_positional_help() .add_options() ("input_file", "text file to view", cxxopts::value<std::string>()) ("m,message", "text to show instead of viewing a file", cxxopts::value<std::string>()) ("f,font_size", "font size in pixels", cxxopts::value<int>()) ("t,title", "window title (filename by default)", cxxopts::value<std::string>()) ("y,yes_button", "shows a yes button with different exit code") ("e,error_display", "format as error, background will be red") ("h,help", "show help") ; options.parse_positional({"input_file"}); try { const auto result = options.parse(argc, argv); if (result.count("help")) { std::cout << options.help({""}) << '\n'; std::exit(0); } if (!result.count("input_file") && !result.count("message")) { std::cerr << "Error: No input given\n\n"; std::cerr << options.help({""}) << '\n'; return {}; } if (result.count("input_file") && result.count("message")) { std::cerr << "Error: Cannot use input_file and message at the same time\n\n"; std::cerr << options.help({""}) << '\n'; return {}; } return result; } catch (const cxxopts::OptionParseException& e) { std::cerr << "Error: " << e.what() << "\n\n"; std::cerr << options.help({""}) << '\n'; } } catch (const cxxopts::OptionSpecException& e) { std::cerr << "Error defining options: " << e.what() << '\n'; } return {}; } std::string replaceEscapeSequences(const std::string& original) { std::string result; result.reserve(original.size()); for (auto iChar = original.begin(); iChar != original.end(); ++iChar) { if (*iChar == '\\' && std::next(iChar) != original.end()) { switch (*std::next(iChar)) { case 'f': result.push_back('\f'); ++iChar; break; case 'n': result.push_back('\n'); ++iChar; break; case 'r': result.push_back('\r'); ++iChar; break; case 't': result.push_back('\t'); ++iChar; break; case 'v': result.push_back('\v'); ++iChar; break; case '\\': result.push_back('\\'); ++iChar; break; default: result.push_back(*iChar); break; } } else { result.push_back(*iChar); } } return result; } std::string readInput(const cxxopts::ParseResult& args) { if (args.count("input_file")) { const auto& inputFilename = args["input_file"].as<std::string>(); std::ifstream file(inputFilename, std::ios::ate); if (!file.is_open()) { return {}; } const auto fileSize = file.tellg(); file.seekg(0); std::string inputText; inputText.resize(fileSize); file.read(&inputText[0], fileSize); return inputText; } else { return replaceEscapeSequences(args["message"].as<std::string>()); } } std::string determineTitle(const cxxopts::ParseResult& args) { if (args.count("title")) { return args["title"].as<std::string>(); } else if (args.count("input_file")) { return args["input_file"].as<std::string>(); } else if (args.count("error_display")) { return "Error!!"; } else { return "Info"; } } int run(SDL_Window* pWindow, const cxxopts::ParseResult& args) { const auto inputText = readInput(args); const auto windowTitle = determineTitle(args); const auto showYesNoButtons = args.count("yes_button"); auto& io = ImGui::GetIO(); if (SDL_GameControllerAddMappingsFromFile("/storage/.config/SDL-GameControllerDB/gamecontrollerdb.txt") < 0) { printf("gamecontrollerdb.txt not found!\n"); } auto exitCode = 0; auto running = true; while (running) { SDL_Event event; while (SDL_PollEvent(&event)) { ImGui_ImplSDL2_ProcessEvent(&event); if ( event.type == SDL_QUIT || (event.type == SDL_CONTROLLERBUTTONDOWN && event.cbutton.button == SDL_CONTROLLER_BUTTON_START) || (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(pWindow)) ) { running = false; } } // Start the Dear ImGui frame ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL2_NewFrame(pWindow); ImGui::NewFrame(); // Draw the UI const auto& windowSize = io.DisplaySize; ImGui::SetNextWindowSize(windowSize); ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::Begin( windowTitle.c_str(), &running, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings); const auto buttonSpaceRequired = ImGui::CalcTextSize("Close", nullptr, true).y + ImGui::GetStyle().FramePadding.y * 2.0f; const auto maxTextHeight = ImGui::GetContentRegionAvail().y - ImGui::GetStyle().ItemSpacing.y - buttonSpaceRequired; if (ImGui::IsWindowAppearing() && !showYesNoButtons) { ImGui::SetNextWindowFocus(); } ImGui::BeginChild("#scroll_area", {0, maxTextHeight}, true); ImGui::TextUnformatted(inputText.c_str()); ImGui::EndChild(); // Draw buttons if (showYesNoButtons) { const auto buttonWidth = windowSize.x / 3.0f; ImGui::SetCursorPosX( (windowSize.x - (buttonWidth * 2 + ImGui::GetStyle().ItemSpacing.x)) / 2.0f); if (ImGui::Button("Yes", {buttonWidth, 0.0f})) { // return 21 if selected yes, this is for checking return code in bash scripts exitCode = 21; running = false; } ImGui::SameLine(); if (ImGui::Button("No", {buttonWidth, 0.0f})) { running = false; } // Auto-focus the yes button if (ImGui::IsWindowAppearing()) { ImGui::SetFocusID(ImGui::GetID("Yes"), ImGui::GetCurrentWindow()); ImGui::GetCurrentContext()->NavDisableHighlight = false; ImGui::GetCurrentContext()->NavDisableMouseHover = true; } } else { const auto buttonWidth = windowSize.x / 3.0f; ImGui::SetCursorPosX((windowSize.x - buttonWidth) / 2.0f); if (ImGui::Button("Close", {buttonWidth, 0.0f})) { running = false; } } ImGui::End(); // Rendering ImGui::Render(); glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); SDL_GL_SwapWindow(pWindow); } return exitCode; } } int main(int argc, char** argv) { const auto oArgs = parseArgs(argc, argv); if (!oArgs) { return -2; } const auto& args = *oArgs; // Setup SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) { std::cerr << "Error: " << SDL_GetError() << '\n'; return -1; } // Setup window and OpenGL SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_DisplayMode displayMode; SDL_GetDesktopDisplayMode(0, &displayMode); auto pWindow = SDL_CreateWindow( "Log Viewer", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, displayMode.w, displayMode.h, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_ALLOW_HIGHDPI); auto pGlContext = SDL_GL_CreateContext(pWindow); SDL_GL_MakeCurrent(pWindow, pGlContext); SDL_GL_SetSwapInterval(1); // Enable vsync // Setup Dear ImGui context IMGUI_CHECKVERSION(); ImGui::CreateContext(); auto& io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Setup Dear ImGui style ImGui::StyleColorsDark(); if (args.count("error_display")) { ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(ImColor(94, 11, 22, 255))); // Set window background to red ImGui::PushStyleColor(ImGuiCol_TitleBgActive, ImVec4(ImColor(94, 11, 22, 255))); } if (args.count("font_size")) { ImFontConfig config; config.SizePixels = args["font_size"].as<int>(); ImGui::GetIO().Fonts->AddFontDefault(&config); } // Setup Platform/Renderer bindings ImGui_ImplSDL2_InitForOpenGL(pWindow, pGlContext); ImGui_ImplOpenGL3_Init(nullptr); // Main loop const auto exitCode = run(pWindow, args); // Cleanup ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplSDL2_Shutdown(); ImGui::DestroyContext(); SDL_GL_DeleteContext(pGlContext); SDL_DestroyWindow(pWindow); SDL_Quit(); return exitCode; }
27.393701
111
0.641947
shantigilbert
7ac515e2ac5aa9af9f6bc14e4777dcb36b32ae92
1,575
cpp
C++
krender/gles3/gles3_static_index_buffer.cpp
lulimin/KongFrame-0.1.0
2721a433fe089539621f53c71e26b21a8a293b63
[ "MIT" ]
null
null
null
krender/gles3/gles3_static_index_buffer.cpp
lulimin/KongFrame-0.1.0
2721a433fe089539621f53c71e26b21a8a293b63
[ "MIT" ]
null
null
null
krender/gles3/gles3_static_index_buffer.cpp
lulimin/KongFrame-0.1.0
2721a433fe089539621f53c71e26b21a8a293b63
[ "MIT" ]
null
null
null
// gles3_static_index_buffer.cpp // Created by lulimin on 2020/10/20. #include "gles3_static_index_buffer.h" #include "../render_service.h" #include "../../inc/frame_mem.h" // GLES3StaticIndexBuffer GLES3StaticIndexBuffer* GLES3StaticIndexBuffer::CreateInstance( RenderService* pRS) { GLES3StaticIndexBuffer* p = (GLES3StaticIndexBuffer*)K_ALLOC(sizeof( GLES3StaticIndexBuffer)); new (p) GLES3StaticIndexBuffer(pRS); return p; } void GLES3StaticIndexBuffer::DeleteInstance(GLES3StaticIndexBuffer* pInstance) { K_DELETE(pInstance); } GLES3StaticIndexBuffer::GLES3StaticIndexBuffer(RenderService* pRS) { Assert(pRS != NULL); m_pRenderService = pRS; m_nIndex = 0; m_nSize = 0; m_nBuffer = 0; } GLES3StaticIndexBuffer::~GLES3StaticIndexBuffer() { this->DeleteResource(); } void GLES3StaticIndexBuffer::Release() { m_pRenderService->ReleaseResource(this); } bool GLES3StaticIndexBuffer::CreateResource(size_t index, const void* data, unsigned int size) { Assert(data != NULL); Assert(size > 0); m_nIndex = index; glGenBuffers(1, &m_nBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_nBuffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, data, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // GLenum err = glGetError(); // // if (err != GL_NO_ERROR) // { // return false; // } m_nSize = size; return true; } bool GLES3StaticIndexBuffer::DeleteResource() { if (m_nBuffer != 0) { glDeleteBuffers(1, &m_nBuffer); m_nBuffer = 0; } return true; }
19.936709
79
0.709841
lulimin
7ac709aa596aaae6aee4dc5fda5343c712678580
20,408
cc
C++
src/sge_vk_compute_target.cc
sungiant/sge
89692d4376cb4374e0936b5373878e59dc9a68bb
[ "MIT" ]
6
2020-09-04T10:19:29.000Z
2021-05-07T05:21:37.000Z
src/sge_vk_compute_target.cc
sungiant/sge
89692d4376cb4374e0936b5373878e59dc9a68bb
[ "MIT" ]
null
null
null
src/sge_vk_compute_target.cc
sungiant/sge
89692d4376cb4374e0936b5373878e59dc9a68bb
[ "MIT" ]
null
null
null
#include "sge_vk_compute_target.hh" #include "sge_vk_presentation.hh" #include "sge_utils.hh" namespace sge::vk { compute_target::compute_target (const struct vk::context& z_context, const struct vk::queue_identifier& z_qid, const struct sge::app::content& z_content, const size_fn& z_size_fn) : context (z_context) , identifier (z_qid) , content (z_content) , get_size_fn (z_size_fn) { } void compute_target::end_of_frame () { const int num_blobs = content.blobs.size (); if (sge::utils::contains_value (state.pending_blob_changes)) { destroy_rl (); for (int i = 0; i < num_blobs; ++i) { if (state.pending_blob_changes[i].has_value ()) { dataspan& data = state.pending_blob_changes[i].value (); destroy_blob_buffer (i); prepare_blob_buffer (i, data); } } create_rl (); } state.pending_blob_changes.clear (); state.pending_blob_changes.resize (num_blobs); } void compute_target::create () { auto semaphore_info = utils::init_VkSemaphoreCreateInfo (); vk_assert (vkCreateSemaphore (context.logical_device, &semaphore_info, context.allocation_callbacks, &state.compute_complete)); auto fenceCreateInfo = utils::init_VkFenceCreateInfo (VK_FENCE_CREATE_SIGNALED_BIT); vk_assert (vkCreateFence (context.logical_device, &fenceCreateInfo, context.allocation_callbacks, &state.fence)); create_r (); } void compute_target::create_r () { state.current_size = get_size_fn (); assert (state.current_size.width > 0 && state.current_size.height > 0); prepare_texture_target (VK_FORMAT_R8G8B8A8_UNORM, state.current_size); prepare_uniform_buffers (); prepare_blob_buffers (); create_rl (); } void compute_target::create_rl () { create_descriptor_set_layout (); create_descriptor_set (); create_compute_pipeline (); create_command_buffer (); record_command_buffer (state.current_size); } void compute_target::destroy_rl () { destroy_command_buffer (); destroy_compute_pipeline (); vkDestroyDescriptorPool (context.logical_device, state.descriptor_pool, context.allocation_callbacks); state.descriptor_pool = VK_NULL_HANDLE; vkDestroyDescriptorSetLayout (context.logical_device, state.descriptor_set_layout, context.allocation_callbacks); state.descriptor_set_layout = VK_NULL_HANDLE; } void compute_target::destroy_r () { destroy_rl (); destroy_blob_buffers (); destroy_uniform_buffers (); destroy_texture_target (); } void compute_target::destroy () { destroy_r (); state.compute_tex.destroy (); vkDestroySemaphore (context.logical_device, state.compute_complete, context.allocation_callbacks); state.compute_complete = VK_NULL_HANDLE; vkDestroyFence (context.logical_device, state.fence, context.allocation_callbacks); state.fence = VK_NULL_HANDLE; } void compute_target::enqueue () { auto submitInfo = utils::init_VkSubmitInfo (); submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &state.command_buffer; VkSemaphore signalSemaphores[] = { state.compute_complete }; submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = signalSemaphores; vkWaitForFences (context.logical_device, 1, &state.fence, VK_TRUE, UINT64_MAX); vkResetFences (context.logical_device, 1, &state.fence); vk_assert (vkQueueSubmit (context.get_queue (identifier), 1, &submitInfo, state.fence)); } void compute_target::update (bool& push_flag, std::vector<bool>& ubo_flags, std::vector<std::optional<dataspan>>& sbo_flags) { if (push_flag) { record_command_buffer (state.current_size); push_flag = false; } for (int i = 0; i < content.uniforms.size (); ++i) { if (ubo_flags[i]) { update_uniform_buffer (i); ubo_flags[i] = false; } } for (int i = 0; i < content.blobs.size (); ++i) { if (sbo_flags[i].has_value ()) { dataspan& ds = sbo_flags[i].value (); if (ds == state.latest_blob_infos[i]) { update_blob_buffer (i, ds); } else { state.pending_blob_changes[i] = ds; } sbo_flags[i].reset (); } } } void compute_target::prepare_uniform_buffers () { state.uniform_buffers.resize (content.uniforms.size ()); for (int i = 0; i < content.uniforms.size (); ++i) { auto& u = content.uniforms[i]; context.create_buffer ( VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, &state.uniform_buffers[i], u.size); update_uniform_buffer (i); } } void compute_target::update_uniform_buffer (int ubo_idx) { auto& u = content.uniforms[ubo_idx]; state.uniform_buffers[ubo_idx].map (); assert (state.uniform_buffers[ubo_idx].size == u.size); memcpy (state.uniform_buffers[ubo_idx].mapped, u.address, u.size); state.uniform_buffers[ubo_idx].unmap (); } void compute_target::destroy_uniform_buffers () { for (int i = 0; i < content.uniforms.size (); ++i) { state.uniform_buffers[i].destroy (context.allocation_callbacks); } state.uniform_buffers.clear (); } void compute_target::copy_blob_from_staging_to_storage (int blob_idx) { assert (state.blob_staging_buffers[blob_idx].size == state.blob_storage_buffers[blob_idx].size); VkCommandBuffer copy_command = context.create_command_buffer (VK_COMMAND_BUFFER_LEVEL_PRIMARY, identifier, true); VkBufferCopy copy_region = {}; copy_region.size = state.blob_staging_buffers[blob_idx].size; vkCmdCopyBuffer ( copy_command, state.blob_staging_buffers[blob_idx].buffer, state.blob_storage_buffers[blob_idx].buffer, 1, &copy_region); context.flush_command_buffer (copy_command, identifier, true); } void compute_target::prepare_blob_buffers () { const int num_storage_buffers = content.blobs.size (); state.blob_staging_buffers.resize (num_storage_buffers); state.blob_storage_buffers.resize (num_storage_buffers); state.latest_blob_infos.resize (num_storage_buffers); state.pending_blob_changes.resize (num_storage_buffers); for (int i = 0; i < num_storage_buffers; ++i) { auto& blob = content.blobs[i]; prepare_blob_buffer (i, blob); } } void compute_target::prepare_blob_buffer (int blob_idx, dataspan data) { state.latest_blob_infos[blob_idx].address = data.address; state.latest_blob_infos[blob_idx].size = data.size; // copy user data into a staging buffer context.create_buffer ( VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, &state.blob_staging_buffers[blob_idx], data.size, data.address); // create an empty buffer on the gpu of the same size context.create_buffer ( VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &state.blob_storage_buffers[blob_idx], data.size); // copy the data from staging to gpu storage copy_blob_from_staging_to_storage (blob_idx); } void compute_target::update_blob_buffer (int blob_idx, dataspan data) { state.blob_staging_buffers[blob_idx].map (); state.blob_staging_buffers[blob_idx].copy (data.address, data.size); state.blob_staging_buffers[blob_idx].unmap (); copy_blob_from_staging_to_storage (blob_idx); } void compute_target::destroy_blob_buffer (int blob_idx) { state.blob_storage_buffers[blob_idx].destroy (context.allocation_callbacks); state.blob_staging_buffers[blob_idx].destroy (context.allocation_callbacks); } void compute_target::destroy_blob_buffers () { for (int i = 0; i < state.blob_staging_buffers.size (); ++i) { destroy_blob_buffer (i); } state.blob_storage_buffers.clear (); state.blob_staging_buffers.clear (); } void compute_target::prepare_texture_target (VkFormat format, const VkExtent2D sz) { VkFormatProperties formatProperties; vkGetPhysicalDeviceFormatProperties (context.physical_device, format, &formatProperties); assert (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT); state.compute_tex.width = sz.width; state.compute_tex.height = sz.height; auto imageCreateInfo = utils::init_VkImageCreateInfo (); imageCreateInfo.imageType = VK_IMAGE_TYPE_2D; imageCreateInfo.format = format; imageCreateInfo.extent = { sz.width, sz.height, 1 }; imageCreateInfo.mipLevels = 1; imageCreateInfo.arrayLayers = 1; imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT; imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL; imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; imageCreateInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; imageCreateInfo.flags = 0; auto memAllocInfo = utils::init_VkMemoryAllocateInfo (); VkMemoryRequirements memReqs; vk_assert (vkCreateImage (context.logical_device, &imageCreateInfo, context.allocation_callbacks, &state.compute_tex.image)); vkGetImageMemoryRequirements (context.logical_device, state.compute_tex.image, &memReqs); memAllocInfo.allocationSize = memReqs.size; memAllocInfo.memoryTypeIndex = utils::choose_memory_type (context.physical_device, memReqs, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); vk_assert (vkAllocateMemory (context.logical_device, &memAllocInfo, context.allocation_callbacks, &state.compute_tex.device_memory)); vk_assert (vkBindImageMemory (context.logical_device, state.compute_tex.image, state.compute_tex.device_memory, 0)); VkCommandBuffer layoutCmd = context.create_command_buffer (VK_COMMAND_BUFFER_LEVEL_PRIMARY, identifier, true); state.compute_tex.image_layout = VK_IMAGE_LAYOUT_GENERAL; utils::set_image_layout ( layoutCmd, state.compute_tex.image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, state.compute_tex.image_layout); VkQueue queue = context.get_queue (identifier); context.flush_command_buffer (layoutCmd, identifier, true); auto sampler = utils::init_VkSamplerCreateInfo (); sampler.magFilter = VK_FILTER_LINEAR; sampler.minFilter = VK_FILTER_LINEAR; sampler.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; sampler.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; sampler.addressModeV = sampler.addressModeU; sampler.addressModeW = sampler.addressModeU; sampler.mipLodBias = 0.0f; sampler.maxAnisotropy = 1.0f; sampler.compareOp = VK_COMPARE_OP_NEVER; sampler.minLod = 0.0f; sampler.maxLod = 0.0f; sampler.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; vk_assert (vkCreateSampler (context.logical_device, &sampler, context.allocation_callbacks, &state.compute_tex.sampler)); VkImageViewCreateInfo view = utils::init_VkImageViewCreateInfo (); view.viewType = VK_IMAGE_VIEW_TYPE_2D; view.format = format; view.components = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }; view.subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }; view.image = state.compute_tex.image; vk_assert (vkCreateImageView (context.logical_device, &view, context.allocation_callbacks, &state.compute_tex.view)); state.compute_tex.descriptor.imageLayout = state.compute_tex.image_layout; state.compute_tex.descriptor.imageView = state.compute_tex.view; state.compute_tex.descriptor.sampler = state.compute_tex.sampler; state.compute_tex.context = &context; } void compute_target::destroy_texture_target () { state.compute_tex.destroy (); } void compute_target::create_descriptor_set_layout () { std::vector<VkDescriptorSetLayoutBinding> descriptor_set_layout_bindings = { utils::init_VkDescriptorSetLayoutBinding ( VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_SHADER_STAGE_COMPUTE_BIT, 0) }; int idx = 1; for (int i = 0; i < state.uniform_buffers.size (); ++i) { descriptor_set_layout_bindings.emplace_back ( utils::init_VkDescriptorSetLayoutBinding ( VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT, idx++)); } for (int i = 0; i < state.blob_storage_buffers.size (); ++i) { descriptor_set_layout_bindings.emplace_back ( utils::init_VkDescriptorSetLayoutBinding ( VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT, idx++)); } auto descriptor_set_layout_create_info = utils::init_VkDescriptorSetLayoutCreateInfo (descriptor_set_layout_bindings); vk_assert (vkCreateDescriptorSetLayout ( context.logical_device, &descriptor_set_layout_create_info, context.allocation_callbacks, &state.descriptor_set_layout)); } void compute_target::create_descriptor_set () { std::vector<VkDescriptorPoolSize> pool_sizes = { utils::init_VkDescriptorPoolSize (VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1), }; if (content.uniforms.size ()) { pool_sizes.emplace_back (utils::init_VkDescriptorPoolSize (VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, (uint32_t) content.uniforms.size ())); } if (content.blobs.size ()) { pool_sizes.emplace_back (utils::init_VkDescriptorPoolSize (VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, (uint32_t)content.blobs.size ())); } auto descriptor_pool_create_info = utils::init_VkDescriptorPoolCreateInfo (pool_sizes, (uint32_t) content.uniforms.size () + 1, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT); vk_assert (vkCreateDescriptorPool (context.logical_device, &descriptor_pool_create_info, context.allocation_callbacks, &state.descriptor_pool)); auto descriptor_set_allocate_info = utils::init_VkDescriptorSetAllocateInfo (state.descriptor_pool, &state.descriptor_set_layout, 1); vk_assert (vkAllocateDescriptorSets (context.logical_device, &descriptor_set_allocate_info, &state.descriptor_set)); auto write_descriptor_set = utils::init_VkWriteDescriptorSet (state.descriptor_set, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 0, &state.compute_tex.descriptor, 1); vkUpdateDescriptorSets (context.logical_device, 1, &write_descriptor_set, 0, nullptr); std::vector<VkWriteDescriptorSet> write_descriptor_sets = { utils::init_VkWriteDescriptorSet ( state.descriptor_set, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 0, &state.compute_tex.descriptor, 1) }; int idx = 1; for (int i = 0; i < state.uniform_buffers.size (); ++i) { write_descriptor_sets.emplace_back ( utils::init_VkWriteDescriptorSet ( state.descriptor_set, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, idx++, &state.uniform_buffers[i].descriptor, 1)); }; for (int i = 0; i < state.blob_storage_buffers.size (); ++i) { write_descriptor_sets.emplace_back ( utils::init_VkWriteDescriptorSet ( state.descriptor_set, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, idx++, &state.blob_storage_buffers[i].descriptor, 1)); }; vkUpdateDescriptorSets (context.logical_device, (uint32_t) write_descriptor_sets.size (), write_descriptor_sets.data (), 0, nullptr); } void compute_target::create_compute_pipeline () { std::vector<uint8_t> output; sge::utils::get_file_stream (output, content.shader_path.c_str ()); state.compute_shader_module = utils::create_shader_module (context.logical_device, context.allocation_callbacks, output); auto shader_stage_create_info = utils::init_VkPipelineShaderStageCreateInfo (VK_SHADER_STAGE_COMPUTE_BIT, state.compute_shader_module, "main"); auto pipeline_layout_create_info = utils::init_VkPipelineLayoutCreateInfo (1, &state.descriptor_set_layout); if (content.push_constants.has_value ()) { //https://stackoverflow.com/questions/50956414/what-is-a-push-constant-in-vulkan assert (content.push_constants.value ().size <= 128); VkPushConstantRange pushConstantRange = utils::init_VkPushConstantRange ( VK_SHADER_STAGE_COMPUTE_BIT, (uint32_t) content.push_constants.value ().size); pipeline_layout_create_info.pushConstantRangeCount = 1; pipeline_layout_create_info.pPushConstantRanges = &pushConstantRange; } vk_assert (vkCreatePipelineLayout (context.logical_device, &pipeline_layout_create_info, context.allocation_callbacks, &state.pipeline_layout)); auto pipeline_create_info = utils::init_VkComputePipelineCreateInfo (state.pipeline_layout); pipeline_create_info.stage = shader_stage_create_info; vk_assert (vkCreateComputePipelines ( context.logical_device, VK_NULL_HANDLE, 1, &pipeline_create_info, context.allocation_callbacks, &state.pipeline)); } void compute_target::destroy_compute_pipeline () { vkDestroyPipeline (context.logical_device, state.pipeline, context.allocation_callbacks); state.pipeline = VK_NULL_HANDLE; vkDestroyPipelineLayout (context.logical_device, state.pipeline_layout, context.allocation_callbacks); state.pipeline_layout = VK_NULL_HANDLE; vkDestroyShaderModule (context.logical_device, state.compute_shader_module, context.allocation_callbacks); state.compute_shader_module = VK_NULL_HANDLE; } void compute_target::create_command_buffer () { auto command_pool_create_info = utils::init_VkCommandPoolCreateInfo (identifier.family_index, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); vk_assert (vkCreateCommandPool (context.logical_device, &command_pool_create_info, context.allocation_callbacks, &state.command_pool)); auto command_buffer_allocate_info = utils::init_VkCommandBufferAllocateInfo (state.command_pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, 1); vk_assert (vkAllocateCommandBuffers (context.logical_device, &command_buffer_allocate_info, &state.command_buffer)); } void compute_target::destroy_command_buffer () { state.command_buffer = VK_NULL_HANDLE; vkDestroyCommandPool (context.logical_device, state.command_pool, context.allocation_callbacks); state.command_pool = VK_NULL_HANDLE; } void compute_target::record_command_buffer (const VkExtent2D sz) { auto begin_info = utils::init_VkCommandBufferBeginInfo (); vk_assert (vkBeginCommandBuffer (state.command_buffer, &begin_info)); if (content.push_constants.has_value ()) { vkCmdPushConstants ( state.command_buffer, state.pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, (uint32_t) content.push_constants.value ().size, content.push_constants.value ().address); } vkCmdBindPipeline (state.command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, state.pipeline); vkCmdBindDescriptorSets ( state.command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, state.pipeline_layout, 0, 1, &state.descriptor_set, 0, NULL); const uint32_t workgroup_size_x = 16; const uint32_t workgroup_size_y = 16; const uint32_t workgroup_size_z = 1; vkCmdDispatch ( state.command_buffer, (uint32_t) ceil (sz.width / float (workgroup_size_x)), (uint32_t) ceil (sz.height / float (workgroup_size_y)), workgroup_size_z); vk_assert (vkEndCommandBuffer (state.command_buffer)); } void compute_target::run_command_buffer () { auto submit_info = utils::init_VkSubmitInfo (); submit_info.commandBufferCount = 1; submit_info.pCommandBuffers = &state.command_buffer; VkFence fence; auto fence_create_info = utils::init_VkFenceCreateInfo (); vk_assert (vkCreateFence (context.logical_device, &fence_create_info, context.allocation_callbacks, &fence)); vk_assert (vkQueueSubmit (context.get_queue (identifier), 1, &submit_info, fence)); vk_assert (vkWaitForFences (context.logical_device, 1, &fence, VK_TRUE, 100000000000)); vkDestroyFence (context.logical_device, fence, context.allocation_callbacks); } }
40.015686
183
0.726039
sungiant
7ac8d6535acf4f8ad0ae4a6ab71ef41f8e4e28e8
5,019
cpp
C++
Source/TurretSystem/Turret.cpp
kacmazemin/TurretSystem
dcb90e8eac84d6cbe8108cee3880e4c77e0ac4d4
[ "MIT" ]
1
2021-05-07T09:01:55.000Z
2021-05-07T09:01:55.000Z
Source/TurretSystem/Turret.cpp
kacmazemin/TurretSystem
dcb90e8eac84d6cbe8108cee3880e4c77e0ac4d4
[ "MIT" ]
null
null
null
Source/TurretSystem/Turret.cpp
kacmazemin/TurretSystem
dcb90e8eac84d6cbe8108cee3880e4c77e0ac4d4
[ "MIT" ]
null
null
null
// Fill out your copyright notice in the Description page of Project Settings. #include "Turret.h" #include "DrawDebugHelpers.h" #include "TurretProjectile.h" #include "TurretSystemFunctionLibrary.h" #include "Components/ArrowComponent.h" #include "Components/AudioComponent.h" #include "Components/SphereComponent.h" #include "Kismet/GameplayStatics.h" #include "Kismet/KismetMathLibrary.h" #include "Kismet/KismetSystemLibrary.h" #include "Sound/SoundCue.h" // Sets default values ATurret::ATurret() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; TurretSM = CreateDefaultSubobject<UStaticMeshComponent>("TurretStaticMesh"); SetRootComponent(RootComponent); TurretSM->SetCollisionEnabled(ECollisionEnabled::NoCollision); SphereComponent = CreateDefaultSubobject<USphereComponent>("BoxCollision"); SphereComponent->SetupAttachment(TurretSM); RotationAC = CreateDefaultSubobject<UAudioComponent>("RotationAudioComponent"); RotationAC->SetupAttachment(TurretSM); RotationAC->bAlwaysPlay = true; FireAC = CreateDefaultSubobject<UAudioComponent>("FireAudioComponent"); FireAC->SetupAttachment(TurretSM); FireAC->bAlwaysPlay = true; ArrowComponent = CreateDefaultSubobject<UArrowComponent>("ArrowComponent"); ArrowComponent->SetupAttachment(TurretSM); ArrowComponent->SetRelativeLocation({60.f,0.f,130.f}); ActorsToIgnore.Reserve(3); ActorsToIgnore.Add(this); } // Called when the game starts or when spawned void ATurret::BeginPlay() { Super::BeginPlay(); TraceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Pawn)); if(RotationSoundCue) { RotationAC->SetSound(RotationSoundCue); } if(FireSoundEffect) { FireAC->SetSound(FireSoundEffect); } ActorsToIgnore.Add(ProjectileActor.GetDefaultObject()); } void ATurret::FindTarget() { if(EnableSphere) { DrawDebugSphere(GetWorld(), GetActorLocation(), SenseRange, 8, FColor::Blue, false, -1.0f, SDPG_World); } TArray<AActor*> OverlappingActors; const bool IsOverlapped = UKismetSystemLibrary::SphereOverlapActors(GetWorld(), GetActorLocation(), SenseRange, TraceObjectTypes, nullptr, ActorIgnoreSphereOverlap, OverlappingActors); float BestDistance = SenseRange; AActor* ClosestTarget = nullptr; if(IsOverlapped) { for (AActor*& HitResult : OverlappingActors) { ActorsToIgnore[2] = HitResult; if(!ClosestTarget || GetDistanceTo(HitResult) < BestDistance) { if(UTurretSystemFunctionLibrary::HasLineOfSight(this, SightHitResult, GetActorLocation(), HitResult->GetActorLocation(), ActorsToIgnore)) { ClosestTarget = HitResult; BestDistance = GetDistanceTo(ClosestTarget); } } } BestTarget = ClosestTarget; } else { BestTarget = nullptr; } } // Called every frame void ATurret::Tick(float DeltaTime) { Super::Tick(DeltaTime); if(BestTarget) { RotateToTarget(); FireProjectile(); } else { if(GetWorld()->GetTimerManager().IsTimerActive(FireTimerHandle)) { GetWorld()->GetTimerManager().ClearTimer(FireTimerHandle); } IdleRotate(DeltaTime); } } void ATurret::RotateToTarget() { if(BestTarget && TurretSM) { const FRotator DesiredRotation = UKismetMathLibrary::FindLookAtRotation(TurretSM->GetRelativeLocation(),BestTarget->GetActorLocation()); TurretSM->SetRelativeRotation({TurretSM->GetRelativeRotation().Pitch, DesiredRotation.Yaw, TurretSM->GetRelativeRotation().Roll}); } } void ATurret::PlayRotateSound() { if(RotationSoundCue) { RotationAC->Stop(); RotationAC->Play(); } } void ATurret::PlayFireSound() { if(FireAC) { FireAC->Stop(); FireAC->Play(); } } void ATurret::IdleRotate(const float DeltaSecond) { if(!bIsRotating) { RandValue = FMath::FRandRange(-180.f,180.f); PlayRotateSound(); bIsRotating = true; } if(bIsRotating && !bIsInDelayTime) { RotateValue = FMath::FInterpTo(TurretSM->GetRelativeRotation().Yaw, RandValue, DeltaSecond, InterpolationSpeed); TurretSM->SetRelativeRotation({TurretSM->GetRelativeRotation().Pitch, RotateValue, TurretSM->GetRelativeRotation().Roll}); } if(FMath::IsNearlyEqual(RandValue, TurretSM->GetRelativeRotation().Yaw, 1.f) && !bIsInDelayTime) { bIsInDelayTime = true; if(bIsInDelayTime) { GetWorld()->GetTimerManager().SetTimer(TimerHandle,[&]() { GetWorld()->GetTimerManager().ClearTimer(TimerHandle); bIsInDelayTime = false; bIsRotating = false; },1.f,false,FMath::RandRange(1.1f, 1.6f)); } } } void ATurret::FireProjectile() { if(!GetWorld()->GetTimerManager().IsTimerActive(FireTimerHandle)) { GetWorld()->GetTimerManager().SetTimer(FireTimerHandle,[=]() { ATurretProjectile* TurretProjectile = GetWorld()->SpawnActor<ATurretProjectile>(ProjectileActor.Get(), ArrowComponent->GetComponentLocation(), {0,TurretSM->GetRelativeRotation().Yaw, 0}); PlayFireSound(); },1.f, false, FireRate); } }
24.970149
141
0.737796
kacmazemin
7ac9c0f5206c6a11a1415df465c201f7b288850d
2,644
cpp
C++
Source/Engine/Engine/Transform.cpp
Syoukei66/Animal-Space-Battle
edb17e2f75fd5b43697889597e1eaac2e9e9cd76
[ "MIT" ]
null
null
null
Source/Engine/Engine/Transform.cpp
Syoukei66/Animal-Space-Battle
edb17e2f75fd5b43697889597e1eaac2e9e9cd76
[ "MIT" ]
null
null
null
Source/Engine/Engine/Transform.cpp
Syoukei66/Animal-Space-Battle
edb17e2f75fd5b43697889597e1eaac2e9e9cd76
[ "MIT" ]
null
null
null
#include "Transform.h" #include "GameObject.h" // ================================================================= // Constructor / Destructor // ================================================================= Transform::Transform(GameObject* entity) : entity_(entity) , translate_matrix_(INativeMatrix::Create()) , scale_matrix_(INativeMatrix::Create()) , rotation_matrix_(INativeMatrix::Create()) , matrix_(INativeMatrix::Create()) , world_matrix_(INativeMatrix::Create()) { } Transform::~Transform() { delete this->translate_matrix_; delete this->scale_matrix_; delete this->rotation_matrix_; delete this->matrix_; delete this->world_matrix_; } // ================================================================= // Method // ================================================================= void Transform::Init() { this->OnInit(); this->OnTransformChanged(); this->OnScaleChanged(); this->OnRotationChanged(); this->OnWorldTransformDirty(); } void Transform::OnTransformChanged() { this->entity_->FireOnPositionChanged(this->entity_); this->translation_dirty_ = true; } void Transform::OnScaleChanged() { this->entity_->FireOnScaleChanged(this->entity_); this->scale_dirty_ = true; } void Transform::OnRotationChanged() { this->entity_->FireOnRotationChanged(this->entity_); this->rotation_dirty_ = true; } void Transform::OnWorldTransformDirty() { this->world_transform_dirty_ = true; } void Transform::UpdateMatrix() { bool matrix_dirty = false; if (this->translation_dirty_) { this->translate_matrix_->Init(); this->UpdateTranslateMatrix(this->translate_matrix_); this->translation_dirty_ = false; matrix_dirty = true; } if (this->scale_dirty_) { this->scale_matrix_->Init(); this->UpdateScaleMatrix(this->scale_matrix_); this->scale_dirty_ = false; matrix_dirty = true; } if (this->rotation_dirty_) { this->rotation_matrix_->Init(); this->UpdateRotateMatrix(this->rotation_matrix_); this->rotation_dirty_ = false; matrix_dirty = true; } if (matrix_dirty) { this->matrix_->Init(); this->matrix_->Multiple(*this->scale_matrix_); this->matrix_->Multiple(*this->rotation_matrix_); this->matrix_->Multiple(*this->translate_matrix_); } } void Transform::UpdateWorldMatrix() { if (!this->world_transform_dirty_) { return; } this->world_matrix_->Assign(this->GetMatrix()); const INativeMatrix* parent_world_matrix = this->GetParentWorldMatrix(); if (parent_world_matrix) { this->world_matrix_->Multiple(*parent_world_matrix); } this->world_transform_dirty_ = false; }
24.481481
74
0.639183
Syoukei66
7aca79722a06efa9c4f2ce78404ee6cc1ada06e4
3,710
cpp
C++
Source/10.0.18362.0/ucrt/lowio/dup2.cpp
825126369/UCRT
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
[ "MIT" ]
2
2021-01-27T10:19:30.000Z
2021-02-09T06:24:30.000Z
Source/10.0.18362.0/ucrt/lowio/dup2.cpp
825126369/UCRT
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
[ "MIT" ]
null
null
null
Source/10.0.18362.0/ucrt/lowio/dup2.cpp
825126369/UCRT
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
[ "MIT" ]
1
2021-01-27T10:19:36.000Z
2021-01-27T10:19:36.000Z
// // dup2.cpp // // Copyright (c) Microsoft Corporation. All rights reserved. // // Defines _dup2() and _dup2_nolock, which duplicate lowio file handles // #include <corecrt_internal_lowio.h> static int __cdecl dup2_nolock(int const source_fh, int const target_fh) throw() { if ((_osfile(source_fh) & FOPEN) == 0) { // If the source handle is not open, return an error. Noe that the // DuplicateHandle API will not detect this error, because it implies // that _osfhnd(source_fh) == INVALID_HANDLE_VALUE, and this is a // legal HANDLE value to be duplicated. errno = EBADF; _doserrno = 0; _ASSERTE(("Invalid file descriptor. File possibly closed by a different thread",0)); return -1; } // If the target is open, close it first. We ignore the possibility of an // error here: an error simply means that the OS handle value may remain // bound for the duration of the process. if (_osfile(target_fh) & FOPEN) { _close_nolock(target_fh); } // Duplicate the source file onto the target file: intptr_t new_osfhandle; BOOL const result = DuplicateHandle( GetCurrentProcess(), reinterpret_cast<HANDLE>(_get_osfhandle(source_fh)), GetCurrentProcess(), &reinterpret_cast<HANDLE&>(new_osfhandle), 0, TRUE, DUPLICATE_SAME_ACCESS); if (!result) { __acrt_errno_map_os_error(GetLastError()); return -1; } __acrt_lowio_set_os_handle(target_fh, new_osfhandle); // Copy the _osfile information, with the FNOINHERIT bit cleared: _osfile(target_fh) = _osfile(source_fh) & ~FNOINHERIT; _textmode(target_fh) = _textmode(source_fh); _tm_unicode(target_fh) = _tm_unicode(source_fh); return 0; } // _dup2() makes the target file handle a duplicate of the source file handle, // so that both handles refer to the same file. If the target handle is open // upon entry, it is closed so that it is not leaked. // // Returns 0 if successful; returns -1 and sets errno on failure. extern "C" int __cdecl _dup2(int const source_fh, int const target_fh) { _CHECK_FH_CLEAR_OSSERR_RETURN( source_fh, EBADF, -1 ); _VALIDATE_CLEAR_OSSERR_RETURN((source_fh >= 0 && (unsigned)source_fh < (unsigned)_nhandle), EBADF, -1); _VALIDATE_CLEAR_OSSERR_RETURN((_osfile(source_fh) & FOPEN), EBADF, -1); _CHECK_FH_CLEAR_OSSERR_RETURN( target_fh, EBADF, -1 ); _VALIDATE_CLEAR_OSSERR_RETURN(((unsigned)target_fh < _NHANDLE_), EBADF, -1); // Make sure there is an __crt_lowio_handle_data struct corresponding to the target_fh: if (target_fh >= _nhandle && __acrt_lowio_ensure_fh_exists(target_fh) != 0) return -1; // If the source and target are the same, return success (we've already // verified that the file handle is open, above). This is for conformance // with the POSIX specification for dup2. if (source_fh == target_fh) return 0; // Obtain the two file handle locks. In order to prevent deadlock, we // always obtain the lock for the lower-numbered file handle first: if (source_fh < target_fh) { __acrt_lowio_lock_fh(source_fh); __acrt_lowio_lock_fh(target_fh); } else if (source_fh > target_fh) { __acrt_lowio_lock_fh(target_fh); __acrt_lowio_lock_fh(source_fh); } int result = 0; __try { result = dup2_nolock(source_fh, target_fh); } __finally { // The order in which we unlock the file handles does not matter: __acrt_lowio_unlock_fh(source_fh); __acrt_lowio_unlock_fh(target_fh); } return result; }
32.54386
107
0.674663
825126369
7acae6357a9ec2c4c4d66c30e9f3c8b3cc415a58
973
cpp
C++
vulnerability_examples/vulnerable_contracts/swc-101/case_study/SSA_Encoding_during.cpp
kunjsong01/data_set
dffdc54da103adca217b8c3c20a5097b0fe2fc1e
[ "Apache-2.0" ]
null
null
null
vulnerability_examples/vulnerable_contracts/swc-101/case_study/SSA_Encoding_during.cpp
kunjsong01/data_set
dffdc54da103adca217b8c3c20a5097b0fe2fc1e
[ "Apache-2.0" ]
null
null
null
vulnerability_examples/vulnerable_contracts/swc-101/case_study/SSA_Encoding_during.cpp
kunjsong01/data_set
dffdc54da103adca217b8c3c20a5097b0fe2fc1e
[ "Apache-2.0" ]
null
null
null
Generated 1 VCC(s), 1 remaining after simplification (5 assignments) Encoding remaining VCC(s) using bit-vector/floating-point arithmetic Thread 0 ASSIGNMENT (HIDDEN) func_case_study::$tmp::return_value$_nondet$1?1!0&0#1 == i?1!0&0#0 Thread 0 file MyContract_case_study.sol line 1 function func_case_study ASSIGNMENT () y?1!0&0#1 == func_case_study::$tmp::return_value$_nondet$1?1!0&0#1 Thread 0 file MyContract_case_study.sol line 1 function func_case_study ASSIGNMENT (HIDDEN) goto_symex::guard?0!0&0#1 == (signed int)y?1!0&0#1 > 253 Thread 0 file MyContract_case_study.sol line 1 function func_case_study ASSIGNMENT (HIDDEN) sum?1!0&0#3 == (goto_symex::guard?0!0&0#1 ? 7 : 254) Thread 0 file MyContract_case_study.sol line 1 function func_case_study ASSERT execution_statet::\guard_exec?0!0 => (signed int)sum?1!0&0#3 > 100 assertion Encoding to solver time: 0.001s Solving with solver Z3 v4.8.10 Encoding to solver time: 0.001s Runtime decision procedure: 0.002s
33.551724
71
0.775951
kunjsong01
7ad02eb4d96400072f661c3868362f36475687ac
87,697
cpp
C++
sources/src/antlr4parser/ELDOLexer.cpp
sydelity-net/EDACurry
20cbf9835827e42efeb0b3686bf6b3e9d72417e9
[ "MIT" ]
null
null
null
sources/src/antlr4parser/ELDOLexer.cpp
sydelity-net/EDACurry
20cbf9835827e42efeb0b3686bf6b3e9d72417e9
[ "MIT" ]
null
null
null
sources/src/antlr4parser/ELDOLexer.cpp
sydelity-net/EDACurry
20cbf9835827e42efeb0b3686bf6b3e9d72417e9
[ "MIT" ]
null
null
null
// Generated from g4files/ELDOLexer.g4 by ANTLR 4.7.1 #include "ELDOLexer.h" using namespace antlr4; using namespace edacurry; ELDOLexer::ELDOLexer(CharStream *input) : Lexer(input) { _interpreter = new atn::LexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache); } ELDOLexer::~ELDOLexer() { delete _interpreter; } std::string ELDOLexer::getGrammarFileName() const { return "ELDOLexer.g4"; } const std::vector<std::string>& ELDOLexer::getRuleNames() const { return _ruleNames; } const std::vector<std::string>& ELDOLexer::getChannelNames() const { return _channelNames; } const std::vector<std::string>& ELDOLexer::getModeNames() const { return _modeNames; } const std::vector<std::string>& ELDOLexer::getTokenNames() const { return _tokenNames; } dfa::Vocabulary& ELDOLexer::getVocabulary() const { return _vocabulary; } const std::vector<uint16_t> ELDOLexer::getSerializedATN() const { return _serializedATN; } const atn::ATN& ELDOLexer::getATN() const { return _atn; } bool ELDOLexer::sempred(RuleContext *context, size_t ruleIndex, size_t predicateIndex) { switch (ruleIndex) { case 0: return BOLSempred(dynamic_cast<antlr4::RuleContext *>(context), predicateIndex); default: break; } return true; } bool ELDOLexer::BOLSempred(antlr4::RuleContext *_localctx, size_t predicateIndex) { switch (predicateIndex) { case 0: return getCharPositionInLine() == 0; default: break; } return true; } // Static vars and initialization. std::vector<dfa::DFA> ELDOLexer::_decisionToDFA; atn::PredictionContextCache ELDOLexer::_sharedContextCache; // We own the ATN which in turn owns the ATN states. atn::ATN ELDOLexer::_atn; std::vector<uint16_t> ELDOLexer::_serializedATN; std::vector<std::string> ELDOLexer::_ruleNames = { u8"BOL", u8"DOT_BOL", u8"COMMENT", u8"INCLUDE", u8"DSPF_INCLUDE", u8"LIB", u8"LIB_END", u8"SUBCKT", u8"SUBCKT_END", u8"NETLIST_END", u8"GLOBAL", u8"MODEL_DEF", u8"VERILOG", u8"GLOBAL_PARAM", u8"ALTER", u8"SAVE", u8"OPTION", u8"OPT", u8"NODESET", u8"CALL_TCL", u8"CHRENT", u8"CONNECT", u8"DEFMAC", u8"DEFWAVE", u8"FFILE", u8"IC", u8"MEAS", u8"PLOT", u8"PRINT", u8"PROBE", u8"TEMP_SET", u8"USE_TCL", u8"PARAM", u8"TEMP", u8"KEY", u8"NONOISE", u8"TABLE", u8"PWL", u8"EXP", u8"SIN", u8"SFFM", u8"PULSE", u8"INTERP", u8"MOD", u8"MODEL", u8"WHEN", u8"START", u8"START_OF_RUN", u8"END_OF_RUN", u8"END", u8"FIND", u8"PP", u8"TRIG", u8"TARG", u8"AT", u8"DERIVATIVE", u8"VECT", u8"CATVECT", u8"PARAM_LIST_START", u8"PIN_LIST_START", u8"NET_LIST_START", u8"PORT_LIST_START", u8"COUPLING_LIST_START", u8"GENERIC_LIST_START", u8"AC", u8"AGE", u8"CHECKSOA", u8"DC", u8"DCHIZ", u8"DCMISMATCH", u8"DEX", u8"DSP", u8"DSPMOD", u8"FOUR", u8"LSTB", u8"MC", u8"NOISE", u8"NOISETRAN", u8"OP", u8"OPTFOUR", u8"OPTIMIZE", u8"OPTNOISE", u8"PZ", u8"RAMP", u8"SENS", u8"SENSAC", u8"SENSPARAM", u8"SNF", u8"SOLVE", u8"TF", u8"TRAN", u8"WCASE", u8"EXTRACT", u8"RESISTOR", u8"CAPACITOR", u8"INDUCTOR", u8"COUPLED_INDUCTOR", u8"DIFFUSION_RESISTOR", u8"TRANSMISSION_LINE", u8"LOSSY_TRANSMISSION_LINE", u8"LTL_W_MODEL", u8"LTL_U_MODEL", u8"JUNCTION_DIODE", u8"BJT", u8"JFET", u8"MOSFET", u8"S_DOMAIN_FILTER", u8"Z_DOMAIN_FILTER", u8"SUBCK_INSTANCE", u8"IVSOURCE", u8"ICSOURCE", u8"VCVS", u8"CCCS", u8"VCCS", u8"CCVS", u8"OPA", u8"SW", u8"NOISE_FUNCTION", u8"DIG_NAND", u8"DIG_AND", u8"DIG_NOR", u8"DIG_OR", u8"DIG_XOR", u8"EQUAL", u8"EXCLAMATION_MARK", u8"LESS_THAN", u8"GREATER_THAN", u8"LESS_THAN_EQUAL", u8"GREATER_THAN_EQUAL", u8"LOGIC_EQUAL", u8"LOGIC_NOT_EQUAL", u8"LOGIC_AND", u8"LOGIC_OR", u8"LOGIC_BITWISE_AND", u8"LOGIC_BITWISE_OR", u8"LOGIC_XOR", u8"BITWISE_SHIFT_LEFT", u8"BITWISE_SHIFT_RIGHT", u8"POWER_OPERATOR", u8"AND", u8"OR", u8"COLON", u8"SEMICOLON", u8"PLUS", u8"MINUS", u8"STAR", u8"OPEN_ROUND", u8"CLOSE_ROUND", u8"OPEN_SQUARE", u8"CLOSE_SQUARE", u8"OPEN_CURLY", u8"CLOSE_CURLY", u8"QUESTION_MARK", u8"COMMA", u8"DOLLAR", u8"AMPERSAND", u8"DOT", u8"UNDERSCORE", u8"AT_SIGN", u8"POUND_SIGN", u8"BACKSLASH", u8"SLASH", u8"APEX", u8"QUOTES", u8"PIPE", u8"PERCENT", u8"CARET", u8"TILDE", u8"ARROW", u8"DIGIT", u8"HEXDIGIT", u8"OCTALDIGIT", u8"EXPONENTIAL", u8"INT", u8"FLOAT", u8"HEX", u8"PERCENTAGE", u8"COMPLEX", u8"NUMBER", u8"LETTER", u8"ESCAPE", u8"ID", u8"STRING", u8"NL", u8"WS", u8"CNL" }; std::vector<std::string> ELDOLexer::_channelNames = { "DEFAULT_TOKEN_CHANNEL", "HIDDEN", u8"COMMENTS" }; std::vector<std::string> ELDOLexer::_modeNames = { u8"DEFAULT_MODE" }; std::vector<std::string> ELDOLexer::_literalNames = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", u8"'='", u8"'!'", u8"'<'", u8"'>'", "", "", "", "", "", "", "", "", "", "", "", "", u8"'and'", u8"'or'", u8"':'", u8"';'", u8"'+'", u8"'-'", u8"'*'", u8"'('", u8"')'", u8"'['", u8"']'", u8"'{'", u8"'}'", u8"'?'", u8"','", u8"'$'", u8"'&'", u8"'.'", u8"'_'", u8"'@'", u8"'#'", u8"'\\'", u8"'/'", u8"'''", u8"'\"'", u8"'|'", u8"'%'", u8"'^'", u8"'~'" }; std::vector<std::string> ELDOLexer::_symbolicNames = { "", u8"COMMENT", u8"INCLUDE", u8"DSPF_INCLUDE", u8"LIB", u8"LIB_END", u8"SUBCKT", u8"SUBCKT_END", u8"NETLIST_END", u8"GLOBAL", u8"MODEL_DEF", u8"VERILOG", u8"GLOBAL_PARAM", u8"ALTER", u8"SAVE", u8"OPTION", u8"OPT", u8"NODESET", u8"CALL_TCL", u8"CHRENT", u8"CONNECT", u8"DEFMAC", u8"DEFWAVE", u8"FFILE", u8"IC", u8"MEAS", u8"PLOT", u8"PRINT", u8"PROBE", u8"TEMP_SET", u8"USE_TCL", u8"PARAM", u8"TEMP", u8"KEY", u8"NONOISE", u8"TABLE", u8"PWL", u8"EXP", u8"SIN", u8"SFFM", u8"PULSE", u8"INTERP", u8"MOD", u8"MODEL", u8"WHEN", u8"START", u8"START_OF_RUN", u8"END_OF_RUN", u8"END", u8"FIND", u8"PP", u8"TRIG", u8"TARG", u8"AT", u8"DERIVATIVE", u8"VECT", u8"CATVECT", u8"PARAM_LIST_START", u8"PIN_LIST_START", u8"NET_LIST_START", u8"PORT_LIST_START", u8"COUPLING_LIST_START", u8"GENERIC_LIST_START", u8"AC", u8"AGE", u8"CHECKSOA", u8"DC", u8"DCHIZ", u8"DCMISMATCH", u8"DEX", u8"DSP", u8"DSPMOD", u8"FOUR", u8"LSTB", u8"MC", u8"NOISE", u8"NOISETRAN", u8"OP", u8"OPTFOUR", u8"OPTIMIZE", u8"OPTNOISE", u8"PZ", u8"RAMP", u8"SENS", u8"SENSAC", u8"SENSPARAM", u8"SNF", u8"SOLVE", u8"TF", u8"TRAN", u8"WCASE", u8"EXTRACT", u8"RESISTOR", u8"CAPACITOR", u8"INDUCTOR", u8"COUPLED_INDUCTOR", u8"DIFFUSION_RESISTOR", u8"TRANSMISSION_LINE", u8"LOSSY_TRANSMISSION_LINE", u8"LTL_W_MODEL", u8"LTL_U_MODEL", u8"JUNCTION_DIODE", u8"BJT", u8"JFET", u8"MOSFET", u8"S_DOMAIN_FILTER", u8"Z_DOMAIN_FILTER", u8"SUBCK_INSTANCE", u8"IVSOURCE", u8"ICSOURCE", u8"VCVS", u8"CCCS", u8"VCCS", u8"CCVS", u8"OPA", u8"SW", u8"NOISE_FUNCTION", u8"DIG_NAND", u8"DIG_AND", u8"DIG_NOR", u8"DIG_OR", u8"DIG_XOR", u8"EQUAL", u8"EXCLAMATION_MARK", u8"LESS_THAN", u8"GREATER_THAN", u8"LESS_THAN_EQUAL", u8"GREATER_THAN_EQUAL", u8"LOGIC_EQUAL", u8"LOGIC_NOT_EQUAL", u8"LOGIC_AND", u8"LOGIC_OR", u8"LOGIC_BITWISE_AND", u8"LOGIC_BITWISE_OR", u8"LOGIC_XOR", u8"BITWISE_SHIFT_LEFT", u8"BITWISE_SHIFT_RIGHT", u8"POWER_OPERATOR", u8"AND", u8"OR", u8"COLON", u8"SEMICOLON", u8"PLUS", u8"MINUS", u8"STAR", u8"OPEN_ROUND", u8"CLOSE_ROUND", u8"OPEN_SQUARE", u8"CLOSE_SQUARE", u8"OPEN_CURLY", u8"CLOSE_CURLY", u8"QUESTION_MARK", u8"COMMA", u8"DOLLAR", u8"AMPERSAND", u8"DOT", u8"UNDERSCORE", u8"AT_SIGN", u8"POUND_SIGN", u8"BACKSLASH", u8"SLASH", u8"APEX", u8"QUOTES", u8"PIPE", u8"PERCENT", u8"CARET", u8"TILDE", u8"ARROW", u8"PERCENTAGE", u8"COMPLEX", u8"NUMBER", u8"ID", u8"STRING", u8"NL", u8"WS", u8"CNL" }; dfa::Vocabulary ELDOLexer::_vocabulary(_literalNames, _symbolicNames); std::vector<std::string> ELDOLexer::_tokenNames; ELDOLexer::Initializer::Initializer() { // This code could be in a static initializer lambda, but VS doesn't allow access to private class members from there. for (size_t i = 0; i < _symbolicNames.size(); ++i) { std::string name = _vocabulary.getLiteralName(i); if (name.empty()) { name = _vocabulary.getSymbolicName(i); } if (name.empty()) { _tokenNames.push_back("<INVALID>"); } else { _tokenNames.push_back(name); } } _serializedATN = { 0x3, 0x608b, 0xa72a, 0x8133, 0xb9ed, 0x417c, 0x3be7, 0x7786, 0x5964, 0x2, 0xb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 0x105, 0x82, 0x107, 0x83, 0x109, 0x84, 0x10b, 0x85, 0x10d, 0x86, 0x10f, 0x87, 0x111, 0x88, 0x113, 0x89, 0x115, 0x8a, 0x117, 0x8b, 0x119, 0x8c, 0x11b, 0x8d, 0x11d, 0x8e, 0x11f, 0x8f, 0x121, 0x90, 0x123, 0x91, 0x125, 0x92, 0x127, 0x93, 0x129, 0x94, 0x12b, 0x95, 0x12d, 0x96, 0x12f, 0x97, 0x131, 0x98, 0x133, 0x99, 0x135, 0x9a, 0x137, 0x9b, 0x139, 0x9c, 0x13b, 0x9d, 0x13d, 0x9e, 0x13f, 0x9f, 0x141, 0xa0, 0x143, 0xa1, 0x145, 0xa2, 0x147, 0xa3, 0x149, 0xa4, 0x14b, 0xa5, 0x14d, 0xa6, 0x14f, 0xa7, 0x151, 0xa8, 0x153, 0xa9, 0x155, 0x2, 0x157, 0x2, 0x159, 0x2, 0x15b, 0x2, 0x15d, 0x2, 0x15f, 0x2, 0x161, 0x2, 0x163, 0xaa, 0x165, 0xab, 0x167, 0xac, 0x169, 0x2, 0x16b, 0x2, 0x16d, 0xad, 0x16f, 0xae, 0x171, 0xaf, 0x173, 0xb0, 0x175, 0xb1, 0x3, 0x2, 0x25, 0x4, 0x2, 0xb, 0xb, 0x22, 0x22, 0x4, 0x2, 0x4b, 0x4b, 0x6b, 0x6b, 0x4, 0x2, 0x50, 0x50, 0x70, 0x70, 0x4, 0x2, 0x45, 0x45, 0x65, 0x65, 0x4, 0x2, 0x4e, 0x4e, 0x6e, 0x6e, 0x4, 0x2, 0x57, 0x57, 0x77, 0x77, 0x4, 0x2, 0x46, 0x46, 0x66, 0x66, 0x4, 0x2, 0x47, 0x47, 0x67, 0x67, 0x4, 0x2, 0x55, 0x55, 0x75, 0x75, 0x4, 0x2, 0x52, 0x52, 0x72, 0x72, 0x4, 0x2, 0x48, 0x48, 0x68, 0x68, 0x4, 0x2, 0x44, 0x44, 0x64, 0x64, 0x4, 0x2, 0x4d, 0x4d, 0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180, 0x6, 0x3, 0x2, 0x2, 0x2, 0x181, 0x182, 0x5, 0x145, 0xa3, 0x2, 0x182, 0x186, 0x5, 0x145, 0xa3, 0x2, 0x183, 0x185, 0xb, 0x2, 0x2, 0x2, 0x184, 0x183, 0x3, 0x2, 0x2, 0x2, 0x185, 0x188, 0x3, 0x2, 0x2, 0x2, 0x186, 0x187, 0x3, 0x2, 0x2, 0x2, 0x186, 0x184, 0x3, 0x2, 0x2, 0x2, 0x187, 0x18a, 0x3, 0x2, 0x2, 0x2, 0x188, 0x186, 0x3, 0x2, 0x2, 0x2, 0x189, 0x18b, 0x5, 0x171, 0xb9, 0x2, 0x18a, 0x189, 0x3, 0x2, 0x2, 0x2, 0x18b, 0x18c, 0x3, 0x2, 0x2, 0x2, 0x18c, 0x18a, 0x3, 0x2, 0x2, 0x2, 0x18c, 0x18d, 0x3, 0x2, 0x2, 0x2, 0x18d, 0x1a4, 0x3, 0x2, 0x2, 0x2, 0x18e, 0x190, 0x5, 0x171, 0xb9, 0x2, 0x18f, 0x18e, 0x3, 0x2, 0x2, 0x2, 0x18f, 0x190, 0x3, 0x2, 0x2, 0x2, 0x190, 0x191, 0x3, 0x2, 0x2, 0x2, 0x191, 0x192, 0x5, 0x3, 0x2, 0x2, 0x192, 0x196, 0x5, 0x125, 0x93, 0x2, 0x193, 0x195, 0xb, 0x2, 0x2, 0x2, 0x194, 0x193, 0x3, 0x2, 0x2, 0x2, 0x195, 0x198, 0x3, 0x2, 0x2, 0x2, 0x196, 0x197, 0x3, 0x2, 0x2, 0x2, 0x196, 0x194, 0x3, 0x2, 0x2, 0x2, 0x197, 0x19a, 0x3, 0x2, 0x2, 0x2, 0x198, 0x196, 0x3, 0x2, 0x2, 0x2, 0x199, 0x19b, 0x5, 0x171, 0xb9, 0x2, 0x19a, 0x199, 0x3, 0x2, 0x2, 0x2, 0x19b, 0x19c, 0x3, 0x2, 0x2, 0x2, 0x19c, 0x19a, 0x3, 0x2, 0x2, 0x2, 0x19c, 0x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, 0x9, 0x4, 0x2, 0x2, 0x217, 0x218, 0x9, 0x11, 0x2, 0x2, 0x218, 0x219, 0x9, 0x8, 0x2, 0x2, 0x219, 0x21a, 0x9, 0x9, 0x2, 0x2, 0x21a, 0x21b, 0x9, 0xa, 0x2, 0x2, 0x21b, 0x21c, 0x9, 0x9, 0x2, 0x2, 0x21c, 0x21d, 0x9, 0xf, 0x2, 0x2, 0x21d, 0x28, 0x3, 0x2, 0x2, 0x2, 0x21e, 0x21f, 0x5, 0x5, 0x3, 0x2, 0x21f, 0x220, 0x9, 0x5, 0x2, 0x2, 0x220, 0x221, 0x9, 0x12, 0x2, 0x2, 0x221, 0x222, 0x9, 0x6, 0x2, 0x2, 0x222, 0x223, 0x9, 0x6, 0x2, 0x2, 0x223, 0x224, 0x7, 0x61, 0x2, 0x2, 0x224, 0x225, 0x9, 0xf, 0x2, 0x2, 0x225, 0x226, 0x9, 0x5, 0x2, 0x2, 0x226, 0x227, 0x9, 0x6, 0x2, 0x2, 0x227, 0x2a, 0x3, 0x2, 0x2, 0x2, 0x228, 0x229, 0x5, 0x5, 0x3, 0x2, 0x229, 0x22a, 0x9, 0x5, 0x2, 0x2, 0x22a, 0x22b, 0x9, 0x16, 0x2, 0x2, 0x22b, 0x22c, 0x9, 0x15, 0x2, 0x2, 0x22c, 0x22d, 0x9, 0x9, 0x2, 0x2, 0x22d, 0x22e, 0x9, 0x4, 0x2, 0x2, 0x22e, 0x22f, 0x9, 0xf, 0x2, 0x2, 0x22f, 0x2c, 0x3, 0x2, 0x2, 0x2, 0x230, 0x231, 0x5, 0x5, 0x3, 0x2, 0x231, 0x232, 0x9, 0x5, 0x2, 0x2, 0x232, 0x233, 0x9, 0x11, 0x2, 0x2, 0x233, 0x234, 0x9, 0x4, 0x2, 0x2, 0x234, 0x235, 0x9, 0x4, 0x2, 0x2, 0x235, 0x236, 0x9, 0x9, 0x2, 0x2, 0x236, 0x237, 0x9, 0x5, 0x2, 0x2, 0x237, 0x238, 0x9, 0xf, 0x2, 0x2, 0x238, 0x2e, 0x3, 0x2, 0x2, 0x2, 0x239, 0x23a, 0x5, 0x5, 0x3, 0x2, 0x23a, 0x23b, 0x9, 0x8, 0x2, 0x2, 0x23b, 0x23c, 0x9, 0x9, 0x2, 0x2, 0x23c, 0x23d, 0x9, 0xc, 0x2, 0x2, 0x23d, 0x23e, 0x9, 0x13, 0x2, 0x2, 0x23e, 0x23f, 0x9, 0x12, 0x2, 0x2, 0x23f, 0x240, 0x9, 0x5, 0x2, 0x2, 0x240, 0x30, 0x3, 0x2, 0x2, 0x2, 0x241, 0x242, 0x5, 0x5, 0x3, 0x2, 0x242, 0x243, 0x9, 0x8, 0x2, 0x2, 0x243, 0x244, 0x9, 0x9, 0x2, 0x2, 0x244, 0x245, 0x9, 0xc, 0x2, 0x2, 0x245, 0x246, 0x9, 0x17, 0x2, 0x2, 0x246, 0x247, 0x9, 0x12, 0x2, 0x2, 0x247, 0x248, 0x9, 0x14, 0x2, 0x2, 0x248, 0x249, 0x9, 0x9, 0x2, 0x2, 0x249, 0x32, 0x3, 0x2, 0x2, 0x2, 0x24a, 0x24b, 0x5, 0x5, 0x3, 0x2, 0x24b, 0x24c, 0x9, 0xc, 0x2, 0x2, 0x24c, 0x24d, 0x9, 0xc, 0x2, 0x2, 0x24d, 0x24e, 0x9, 0x3, 0x2, 0x2, 0x24e, 0x24f, 0x9, 0x6, 0x2, 0x2, 0x24f, 0x250, 0x9, 0x9, 0x2, 0x2, 0x250, 0x34, 0x3, 0x2, 0x2, 0x2, 0x251, 0x252, 0x5, 0x5, 0x3, 0x2, 0x252, 0x253, 0x9, 0x3, 0x2, 0x2, 0x253, 0x254, 0x9, 0x5, 0x2, 0x2, 0x254, 0x36, 0x3, 0x2, 0x2, 0x2, 0x255, 0x256, 0x5, 0x5, 0x3, 0x2, 0x256, 0x257, 0x9, 0x13, 0x2, 0x2, 0x257, 0x258, 0x9, 0x9, 0x2, 0x2, 0x258, 0x259, 0x9, 0x12, 0x2, 0x2, 0x259, 0x25a, 0x9, 0xa, 0x2, 0x2, 0x25a, 0x38, 0x3, 0x2, 0x2, 0x2, 0x25b, 0x25c, 0x5, 0x5, 0x3, 0x2, 0x25c, 0x25d, 0x9, 0xb, 0x2, 0x2, 0x25d, 0x25e, 0x9, 0x6, 0x2, 0x2, 0x25e, 0x25f, 0x9, 0x11, 0x2, 0x2, 0x25f, 0x260, 0x9, 0xf, 0x2, 0x2, 0x260, 0x3a, 0x3, 0x2, 0x2, 0x2, 0x261, 0x262, 0x5, 0x5, 0x3, 0x2, 0x262, 0x263, 0x9, 0xb, 0x2, 0x2, 0x263, 0x264, 0x9, 0x15, 0x2, 0x2, 0x264, 0x265, 0x9, 0x3, 0x2, 0x2, 0x265, 0x266, 0x9, 0x4, 0x2, 0x2, 0x266, 0x267, 0x9, 0xf, 0x2, 0x2, 0x267, 0x3c, 0x3, 0x2, 0x2, 0x2, 0x268, 0x269, 0x5, 0x5, 0x3, 0x2, 0x269, 0x26a, 0x9, 0xb, 0x2, 0x2, 0x26a, 0x26b, 0x9, 0x15, 0x2, 0x2, 0x26b, 0x26c, 0x9, 0x11, 0x2, 0x2, 0x26c, 0x26d, 0x9, 0xd, 0x2, 0x2, 0x26d, 0x26e, 0x9, 0x9, 0x2, 0x2, 0x26e, 0x3e, 0x3, 0x2, 0x2, 0x2, 0x26f, 0x270, 0x5, 0x5, 0x3, 0x2, 0x270, 0x271, 0x9, 0xf, 0x2, 0x2, 0x271, 0x272, 0x9, 0x9, 0x2, 0x2, 0x272, 0x273, 0x9, 0x13, 0x2, 0x2, 0x273, 0x274, 0x9, 0xb, 0x2, 0x2, 0x274, 0x40, 0x3, 0x2, 0x2, 0x2, 0x275, 0x276, 0x5, 0x5, 0x3, 0x2, 0x276, 0x277, 0x9, 0x7, 0x2, 0x2, 0x277, 0x278, 0x9, 0xa, 0x2, 0x2, 0x278, 0x279, 0x9, 0x9, 0x2, 0x2, 0x279, 0x27a, 0x7, 0x61, 0x2, 0x2, 0x27a, 0x27b, 0x9, 0xf, 0x2, 0x2, 0x27b, 0x27c, 0x9, 0x5, 0x2, 0x2, 0x27c, 0x27d, 0x9, 0x6, 0x2, 0x2, 0x27d, 0x42, 0x3, 0x2, 0x2, 0x2, 0x27e, 0x27f, 0x9, 0xb, 0x2, 0x2, 0x27f, 0x280, 0x9, 0x12, 0x2, 0x2, 0x280, 0x281, 0x9, 0x15, 0x2, 0x2, 0x281, 0x282, 0x9, 0x12, 0x2, 0x2, 0x282, 0x283, 0x9, 0x13, 0x2, 0x2, 0x283, 0x44, 0x3, 0x2, 0x2, 0x2, 0x284, 0x285, 0x9, 0xf, 0x2, 0x2, 0x285, 0x286, 0x9, 0x9, 0x2, 0x2, 0x286, 0x287, 0x9, 0x13, 0x2, 0x2, 0x287, 0x288, 0x9, 0xb, 0x2, 0x2, 0x288, 0x46, 0x3, 0x2, 0x2, 0x2, 0x289, 0x28a, 0x9, 0xe, 0x2, 0x2, 0x28a, 0x28b, 0x9, 0x9, 0x2, 0x2, 0x28b, 0x28c, 0x9, 0x18, 0x2, 0x2, 0x28c, 0x48, 0x3, 0x2, 0x2, 0x2, 0x28d, 0x28e, 0x9, 0x4, 0x2, 0x2, 0x28e, 0x28f, 0x9, 0x11, 0x2, 0x2, 0x28f, 0x290, 0x9, 0x4, 0x2, 0x2, 0x290, 0x291, 0x9, 0x11, 0x2, 0x2, 0x291, 0x292, 0x9, 0x3, 0x2, 0x2, 0x292, 0x293, 0x9, 0xa, 0x2, 0x2, 0x293, 0x294, 0x9, 0x9, 0x2, 0x2, 0x294, 0x4a, 0x3, 0x2, 0x2, 0x2, 0x295, 0x296, 0x9, 0xf, 0x2, 0x2, 0x296, 0x297, 0x9, 0x12, 0x2, 0x2, 0x297, 0x298, 0x9, 0xd, 0x2, 0x2, 0x298, 0x299, 0x9, 0x6, 0x2, 0x2, 0x299, 0x29a, 0x9, 0x9, 0x2, 0x2, 0x29a, 0x4c, 0x3, 0x2, 0x2, 0x2, 0x29b, 0x29c, 0x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, 0x2, 0x2, 0x318, 0x319, 0x9, 0x12, 0x2, 0x2, 0x319, 0x31a, 0x9, 0x15, 0x2, 0x2, 0x31a, 0x31b, 0x9, 0x12, 0x2, 0x2, 0x31b, 0x31c, 0x9, 0x13, 0x2, 0x2, 0x31c, 0x31d, 0x7, 0x3c, 0x2, 0x2, 0x31d, 0x78, 0x3, 0x2, 0x2, 0x2, 0x31e, 0x31f, 0x9, 0xb, 0x2, 0x2, 0x31f, 0x320, 0x9, 0x3, 0x2, 0x2, 0x320, 0x321, 0x9, 0x4, 0x2, 0x2, 0x321, 0x322, 0x7, 0x3c, 0x2, 0x2, 0x322, 0x7a, 0x3, 0x2, 0x2, 0x2, 0x323, 0x324, 0x9, 0x4, 0x2, 0x2, 0x324, 0x325, 0x9, 0x9, 0x2, 0x2, 0x325, 0x326, 0x9, 0xf, 0x2, 0x2, 0x326, 0x327, 0x7, 0x3c, 0x2, 0x2, 0x327, 0x7c, 0x3, 0x2, 0x2, 0x2, 0x328, 0x329, 0x9, 0xb, 0x2, 0x2, 0x329, 0x32a, 0x9, 0x11, 0x2, 0x2, 0x32a, 0x32b, 0x9, 0x15, 0x2, 0x2, 0x32b, 0x32c, 0x9, 0xf, 0x2, 0x2, 0x32c, 0x32d, 0x7, 0x3c, 0x2, 0x2, 0x32d, 0x7e, 0x3, 0x2, 0x2, 0x2, 0x32e, 0x32f, 0x9, 0x5, 0x2, 0x2, 0x32f, 0x330, 0x9, 0x11, 0x2, 0x2, 0x330, 0x331, 0x9, 0x7, 0x2, 0x2, 0x331, 0x332, 0x9, 0xb, 0x2, 0x2, 0x332, 0x333, 0x9, 0x6, 0x2, 0x2, 0x333, 0x334, 0x9, 0x3, 0x2, 0x2, 0x334, 0x335, 0x9, 0x4, 0x2, 0x2, 0x335, 0x336, 0x9, 0x10, 0x2, 0x2, 0x336, 0x337, 0x7, 0x3c, 0x2, 0x2, 0x337, 0x80, 0x3, 0x2, 0x2, 0x2, 0x338, 0x339, 0x9, 0x10, 0x2, 0x2, 0x339, 0x33a, 0x9, 0x9, 0x2, 0x2, 0x33a, 0x33b, 0x9, 0x4, 0x2, 0x2, 0x33b, 0x33c, 0x9, 0x9, 0x2, 0x2, 0x33c, 0x33d, 0x9, 0x15, 0x2, 0x2, 0x33d, 0x33e, 0x9, 0x3, 0x2, 0x2, 0x33e, 0x33f, 0x9, 0x5, 0x2, 0x2, 0x33f, 0x340, 0x7, 0x3c, 0x2, 0x2, 0x340, 0x82, 0x3, 0x2, 0x2, 0x2, 0x341, 0x342, 0x5, 0x5, 0x3, 0x2, 0x342, 0x343, 0x9, 0x12, 0x2, 0x2, 0x343, 0x344, 0x9, 0x5, 0x2, 0x2, 0x344, 0x84, 0x3, 0x2, 0x2, 0x2, 0x345, 0x346, 0x5, 0x5, 0x3, 0x2, 0x346, 0x347, 0x9, 0x12, 0x2, 0x2, 0x347, 0x348, 0x9, 0x10, 0x2, 0x2, 0x348, 0x349, 0x9, 0x9, 0x2, 0x2, 0x349, 0x86, 0x3, 0x2, 0x2, 0x2, 0x34a, 0x34b, 0x5, 0x5, 0x3, 0x2, 0x34b, 0x34c, 0x9, 0x5, 0x2, 0x2, 0x34c, 0x34d, 0x9, 0x16, 0x2, 0x2, 0x34d, 0x34e, 0x9, 0x9, 0x2, 0x2, 0x34e, 0x34f, 0x9, 0x5, 0x2, 0x2, 0x34f, 0x350, 0x9, 0xe, 0x2, 0x2, 0x350, 0x351, 0x9, 0xa, 0x2, 0x2, 0x351, 0x352, 0x9, 0x11, 0x2, 0x2, 0x352, 0x353, 0x9, 0x12, 0x2, 0x2, 0x353, 0x88, 0x3, 0x2, 0x2, 0x2, 0x354, 0x355, 0x5, 0x5, 0x3, 0x2, 0x355, 0x356, 0x9, 0x8, 0x2, 0x2, 0x356, 0x357, 0x9, 0x5, 0x2, 0x2, 0x357, 0x8a, 0x3, 0x2, 0x2, 0x2, 0x358, 0x359, 0x5, 0x5, 0x3, 0x2, 0x359, 0x35a, 0x9, 0x8, 0x2, 0x2, 0x35a, 0x35b, 0x9, 0x5, 0x2, 0x2, 0x35b, 0x35c, 0x9, 0x16, 0x2, 0x2, 0x35c, 0x35d, 0x9, 0x3, 0x2, 0x2, 0x35d, 0x35e, 0x9, 0x1a, 0x2, 0x2, 0x35e, 0x8c, 0x3, 0x2, 0x2, 0x2, 0x35f, 0x360, 0x5, 0x5, 0x3, 0x2, 0x360, 0x361, 0x9, 0x8, 0x2, 0x2, 0x361, 0x362, 0x9, 0x5, 0x2, 0x2, 0x362, 0x363, 0x9, 0x13, 0x2, 0x2, 0x363, 0x364, 0x9, 0x3, 0x2, 0x2, 0x364, 0x365, 0x9, 0xa, 0x2, 0x2, 0x365, 0x366, 0x9, 0x13, 0x2, 0x2, 0x366, 0x367, 0x9, 0x12, 0x2, 0x2, 0x367, 0x368, 0x9, 0xf, 0x2, 0x2, 0x368, 0x369, 0x9, 0x5, 0x2, 0x2, 0x369, 0x36a, 0x9, 0x16, 0x2, 0x2, 0x36a, 0x8e, 0x3, 0x2, 0x2, 0x2, 0x36b, 0x36c, 0x5, 0x5, 0x3, 0x2, 0x36c, 0x36d, 0x9, 0x8, 0x2, 0x2, 0x36d, 0x36e, 0x9, 0x9, 0x2, 0x2, 0x36e, 0x36f, 0x9, 0x19, 0x2, 0x2, 0x36f, 0x90, 0x3, 0x2, 0x2, 0x2, 0x370, 0x371, 0x5, 0x5, 0x3, 0x2, 0x371, 0x372, 0x9, 0x8, 0x2, 0x2, 0x372, 0x373, 0x9, 0xa, 0x2, 0x2, 0x373, 0x374, 0x9, 0xb, 0x2, 0x2, 0x374, 0x92, 0x3, 0x2, 0x2, 0x2, 0x375, 0x376, 0x5, 0x5, 0x3, 0x2, 0x376, 0x377, 0x9, 0x8, 0x2, 0x2, 0x377, 0x378, 0x9, 0xa, 0x2, 0x2, 0x378, 0x379, 0x9, 0xb, 0x2, 0x2, 0x379, 0x37a, 0x9, 0x13, 0x2, 0x2, 0x37a, 0x37b, 0x9, 0x11, 0x2, 0x2, 0x37b, 0x37c, 0x9, 0x8, 0x2, 0x2, 0x37c, 0x94, 0x3, 0x2, 0x2, 0x2, 0x37d, 0x37e, 0x5, 0x5, 0x3, 0x2, 0x37e, 0x37f, 0x9, 0xc, 0x2, 0x2, 0x37f, 0x380, 0x9, 0x11, 0x2, 0x2, 0x380, 0x381, 0x9, 0x7, 0x2, 0x2, 0x381, 0x382, 0x9, 0x15, 0x2, 0x2, 0x382, 0x96, 0x3, 0x2, 0x2, 0x2, 0x383, 0x384, 0x5, 0x5, 0x3, 0x2, 0x384, 0x385, 0x9, 0x6, 0x2, 0x2, 0x385, 0x386, 0x9, 0xa, 0x2, 0x2, 0x386, 0x387, 0x9, 0xf, 0x2, 0x2, 0x387, 0x388, 0x9, 0xd, 0x2, 0x2, 0x388, 0x98, 0x3, 0x2, 0x2, 0x2, 0x389, 0x38a, 0x5, 0x5, 0x3, 0x2, 0x38a, 0x38b, 0x9, 0x13, 0x2, 0x2, 0x38b, 0x38c, 0x9, 0x5, 0x2, 0x2, 0x38c, 0x9a, 0x3, 0x2, 0x2, 0x2, 0x38d, 0x38e, 0x5, 0x5, 0x3, 0x2, 0x38e, 0x38f, 0x9, 0x4, 0x2, 0x2, 0x38f, 0x390, 0x9, 0x11, 0x2, 0x2, 0x390, 0x391, 0x9, 0x3, 0x2, 0x2, 0x391, 0x392, 0x9, 0xa, 0x2, 0x2, 0x392, 0x393, 0x9, 0x9, 0x2, 0x2, 0x393, 0x9c, 0x3, 0x2, 0x2, 0x2, 0x394, 0x395, 0x5, 0x5, 0x3, 0x2, 0x395, 0x396, 0x9, 0x4, 0x2, 0x2, 0x396, 0x397, 0x9, 0x11, 0x2, 0x2, 0x397, 0x398, 0x9, 0x3, 0x2, 0x2, 0x398, 0x399, 0x9, 0xa, 0x2, 0x2, 0x399, 0x39a, 0x9, 0x9, 0x2, 0x2, 0x39a, 0x39b, 0x9, 0xf, 0x2, 0x2, 0x39b, 0x39c, 0x9, 0x15, 0x2, 0x2, 0x39c, 0x39d, 0x9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418, 0xc4, 0x3, 0x2, 0x2, 0x2, 0x419, 0x41a, 0x5, 0x3, 0x2, 0x2, 0x41a, 0x41b, 0x9, 0xb, 0x2, 0x2, 0x41b, 0x41c, 0x5, 0x16d, 0xb7, 0x2, 0x41c, 0xc6, 0x3, 0x2, 0x2, 0x2, 0x41d, 0x41e, 0x5, 0x3, 0x2, 0x2, 0x41e, 0x41f, 0x9, 0xf, 0x2, 0x2, 0x41f, 0x420, 0x5, 0x16d, 0xb7, 0x2, 0x420, 0xc8, 0x3, 0x2, 0x2, 0x2, 0x421, 0x422, 0x5, 0x3, 0x2, 0x2, 0x422, 0x423, 0x9, 0x18, 0x2, 0x2, 0x423, 0x424, 0x5, 0x16d, 0xb7, 0x2, 0x424, 0xca, 0x3, 0x2, 0x2, 0x2, 0x425, 0x426, 0x5, 0x3, 0x2, 0x2, 0x426, 0x427, 0x9, 0x17, 0x2, 0x2, 0x427, 0x428, 0x5, 0x16d, 0xb7, 0x2, 0x428, 0xcc, 0x3, 0x2, 0x2, 0x2, 0x429, 0x42a, 0x5, 0x3, 0x2, 0x2, 0x42a, 0x42b, 0x9, 0x7, 0x2, 0x2, 0x42b, 0x42c, 0x5, 0x16d, 0xb7, 0x2, 0x42c, 0xce, 0x3, 0x2, 0x2, 0x2, 0x42d, 0x42e, 0x5, 0x3, 0x2, 0x2, 0x42e, 0x42f, 0x9, 0x8, 0x2, 0x2, 0x42f, 0x430, 0x5, 0x16d, 0xb7, 0x2, 0x430, 0xd0, 0x3, 0x2, 0x2, 0x2, 0x431, 0x432, 0x5, 0x3, 0x2, 0x2, 0x432, 0x433, 0x9, 0x1b, 0x2, 0x2, 0x433, 0x434, 0x5, 0x16d, 0xb7, 0x2, 0x434, 0xd2, 0x3, 0x2, 0x2, 0x2, 0x435, 0x436, 0x5, 0x3, 0x2, 0x2, 0x436, 0x437, 0x9, 0x1c, 0x2, 0x2, 0x437, 0x438, 0x5, 0x16d, 0xb7, 0x2, 0x438, 0xd4, 0x3, 0x2, 0x2, 0x2, 0x439, 0x43a, 0x5, 0x3, 0x2, 0x2, 0x43a, 0x43b, 0x9, 0x13, 0x2, 0x2, 0x43b, 0x43c, 0x5, 0x16d, 0xb7, 0x2, 0x43c, 0xd6, 0x3, 0x2, 0x2, 0x2, 0x43d, 0x43e, 0x5, 0x3, 0x2, 0x2, 0x43e, 0x43f, 0x9, 0xc, 0x2, 0x2, 0x43f, 0x440, 0x9, 0x4, 0x2, 0x2, 0x440, 0x441, 0x9, 0xa, 0x2, 0x2, 0x441, 0x442, 0x5, 0x16d, 0xb7, 0x2, 0x442, 0xd8, 0x3, 0x2, 0x2, 0x2, 0x443, 0x444, 0x5, 0x3, 0x2, 0x2, 0x444, 0x445, 0x9, 0xc, 0x2, 0x2, 0x445, 0x446, 0x9, 0x4, 0x2, 0x2, 0x446, 0x447, 0x9, 0x1a, 0x2, 0x2, 0x447, 0x448, 0x5, 0x16d, 0xb7, 0x2, 0x448, 0xda, 0x3, 0x2, 0x2, 0x2, 0x449, 0x44a, 0x5, 0x3, 0x2, 0x2, 0x44a, 0x44b, 0x9, 0x19, 0x2, 0x2, 0x44b, 0x44c, 0x5, 0x16d, 0xb7, 0x2, 0x44c, 0xdc, 0x3, 0x2, 0x2, 0x2, 0x44d, 0x44e, 0x5, 0x3, 0x2, 0x2, 0x44e, 0x44f, 0x9, 0x14, 0x2, 0x2, 0x44f, 0x450, 0x5, 0x16d, 0xb7, 0x2, 0x450, 0xde, 0x3, 0x2, 0x2, 0x2, 0x451, 0x452, 0x5, 0x3, 0x2, 0x2, 0x452, 0x453, 0x9, 0x3, 0x2, 0x2, 0x453, 0x454, 0x5, 0x16d, 0xb7, 0x2, 0x454, 0xe0, 0x3, 0x2, 0x2, 0x2, 0x455, 0x456, 0x5, 0x3, 0x2, 0x2, 0x456, 0x457, 0x9, 0x9, 0x2, 0x2, 0x457, 0x458, 0x5, 0x16d, 0xb7, 0x2, 0x458, 0xe2, 0x3, 0x2, 0x2, 0x2, 0x459, 0x45a, 0x5, 0x3, 0x2, 0x2, 0x45a, 0x45b, 0x9, 0xc, 0x2, 0x2, 0x45b, 0x45c, 0x5, 0x16d, 0xb7, 0x2, 0x45c, 0xe4, 0x3, 0x2, 0x2, 0x2, 0x45d, 0x45e, 0x5, 0x3, 0x2, 0x2, 0x45e, 0x45f, 0x9, 0x10, 0x2, 0x2, 0x45f, 0x460, 0x5, 0x16d, 0xb7, 0x2, 0x460, 0xe6, 0x3, 0x2, 0x2, 0x2, 0x461, 0x462, 0x5, 0x3, 0x2, 0x2, 0x462, 0x463, 0x9, 0x16, 0x2, 0x2, 0x463, 0x464, 0x5, 0x16d, 0xb7, 0x2, 0x464, 0xe8, 0x3, 0x2, 0x2, 0x2, 0x465, 0x466, 0x5, 0x3, 0x2, 0x2, 0x466, 0x467, 0x9, 0x11, 0x2, 0x2, 0x467, 0x468, 0x9, 0xb, 0x2, 0x2, 0x468, 0x469, 0x9, 0x12, 0x2, 0x2, 0x469, 0x46a, 0x5, 0x16d, 0xb7, 0x2, 0x46a, 0xea, 0x3, 0x2, 0x2, 0x2, 0x46b, 0x46c, 0x5, 0x3, 0x2, 0x2, 0x46c, 0x46d, 0x9, 0xa, 0x2, 0x2, 0x46d, 0x46e, 0x5, 0x16d, 0xb7, 0x2, 0x46e, 0xec, 0x3, 0x2, 0x2, 0x2, 0x46f, 0x470, 0x5, 0x3, 0x2, 0x2, 0x470, 0x471, 0x9, 0x4, 0x2, 0x2, 0x471, 0x472, 0x9, 0x11, 0x2, 0x2, 0x472, 0x473, 0x9, 0x3, 0x2, 0x2, 0x473, 0x474, 0x9, 0xa, 0x2, 0x2, 0x474, 0x475, 0x9, 0x9, 0x2, 0x2, 0x475, 0x476, 0x5, 0x16d, 0xb7, 0x2, 0x476, 0xee, 0x3, 0x2, 0x2, 0x2, 0x477, 0x478, 0x5, 0x3, 0x2, 0x2, 0x478, 0x479, 0x9, 0x4, 0x2, 0x2, 0x479, 0x47a, 0x9, 0x12, 0x2, 0x2, 0x47a, 0x47b, 0x9, 0x4, 0x2, 0x2, 0x47b, 0x47c, 0x9, 0x8, 0x2, 0x2, 0x47c, 0x47d, 0x5, 0x16d, 0xb7, 0x2, 0x47d, 0xf0, 0x3, 0x2, 0x2, 0x2, 0x47e, 0x47f, 0x5, 0x3, 0x2, 0x2, 0x47f, 0x480, 0x9, 0x12, 0x2, 0x2, 0x480, 0x481, 0x9, 0x4, 0x2, 0x2, 0x481, 0x482, 0x9, 0x8, 0x2, 0x2, 0x482, 0x483, 0x5, 0x16d, 0xb7, 0x2, 0x483, 0xf2, 0x3, 0x2, 0x2, 0x2, 0x484, 0x485, 0x5, 0x3, 0x2, 0x2, 0x485, 0x486, 0x9, 0x4, 0x2, 0x2, 0x486, 0x487, 0x9, 0x11, 0x2, 0x2, 0x487, 0x488, 0x9, 0x15, 0x2, 0x2, 0x488, 0x489, 0x5, 0x16d, 0xb7, 0x2, 0x489, 0xf4, 0x3, 0x2, 0x2, 0x2, 0x48a, 0x48b, 0x5, 0x3, 0x2, 0x2, 0x48b, 0x48c, 0x9, 0x11, 0x2, 0x2, 0x48c, 0x48d, 0x9, 0x15, 0x2, 0x2, 0x48d, 0x48e, 0x5, 0x16d, 0xb7, 0x2, 0x48e, 0xf6, 0x3, 0x2, 0x2, 0x2, 0x48f, 0x490, 0x5, 0x3, 0x2, 0x2, 0x490, 0x491, 0x9, 0x19, 0x2, 0x2, 0x491, 0x492, 0x9, 0x11, 0x2, 0x2, 0x492, 0x493, 0x9, 0x15, 0x2, 0x2, 0x493, 0x494, 0x5, 0x16d, 0xb7, 0x2, 0x494, 0xf8, 0x3, 0x2, 0x2, 0x2, 0x495, 0x496, 0x7, 0x3f, 0x2, 0x2, 0x496, 0xfa, 0x3, 0x2, 0x2, 0x2, 0x497, 0x498, 0x7, 0x23, 0x2, 0x2, 0x498, 0xfc, 0x3, 0x2, 0x2, 0x2, 0x499, 0x49a, 0x7, 0x3e, 0x2, 0x2, 0x49a, 0xfe, 0x3, 0x2, 0x2, 0x2, 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2, 0x514, 0x15c, 0x3, 0x2, 0x2, 0x2, 0x515, 0x517, 0x9, 0x1f, 0x2, 0x2, 0x516, 0x515, 0x3, 0x2, 0x2, 0x2, 0x516, 0x517, 0x3, 0x2, 0x2, 0x2, 0x517, 0x519, 0x3, 0x2, 0x2, 0x2, 0x518, 0x51a, 0x5, 0x155, 0xab, 0x2, 0x519, 0x518, 0x3, 0x2, 0x2, 0x2, 0x51a, 0x51b, 0x3, 0x2, 0x2, 0x2, 0x51b, 0x519, 0x3, 0x2, 0x2, 0x2, 0x51b, 0x51c, 0x3, 0x2, 0x2, 0x2, 0x51c, 0x15e, 0x3, 0x2, 0x2, 0x2, 0x51d, 0x51f, 0x9, 0x1f, 0x2, 0x2, 0x51e, 0x51d, 0x3, 0x2, 0x2, 0x2, 0x51e, 0x51f, 0x3, 0x2, 0x2, 0x2, 0x51f, 0x521, 0x3, 0x2, 0x2, 0x2, 0x520, 0x522, 0x5, 0x155, 0xab, 0x2, 0x521, 0x520, 0x3, 0x2, 0x2, 0x2, 0x522, 0x523, 0x3, 0x2, 0x2, 0x2, 0x523, 0x521, 0x3, 0x2, 0x2, 0x2, 0x523, 0x524, 0x3, 0x2, 0x2, 0x2, 0x524, 0x525, 0x3, 0x2, 0x2, 0x2, 0x525, 0x529, 0x7, 0x30, 0x2, 0x2, 0x526, 0x528, 0x5, 0x155, 0xab, 0x2, 0x527, 0x526, 0x3, 0x2, 0x2, 0x2, 0x528, 0x52b, 0x3, 0x2, 0x2, 0x2, 0x529, 0x527, 0x3, 0x2, 0x2, 0x2, 0x529, 0x52a, 0x3, 0x2, 0x2, 0x2, 0x52a, 0x52d, 0x3, 0x2, 0x2, 0x2, 0x52b, 0x529, 0x3, 0x2, 0x2, 0x2, 0x52c, 0x52e, 0x5, 0x15b, 0xae, 0x2, 0x52d, 0x52c, 0x3, 0x2, 0x2, 0x2, 0x52d, 0x52e, 0x3, 0x2, 0x2, 0x2, 0x52e, 0x547, 0x3, 0x2, 0x2, 0x2, 0x52f, 0x531, 0x9, 0x1f, 0x2, 0x2, 0x530, 0x52f, 0x3, 0x2, 0x2, 0x2, 0x530, 0x531, 0x3, 0x2, 0x2, 0x2, 0x531, 0x533, 0x3, 0x2, 0x2, 0x2, 0x532, 0x534, 0x5, 0x155, 0xab, 0x2, 0x533, 0x532, 0x3, 0x2, 0x2, 0x2, 0x534, 0x535, 0x3, 0x2, 0x2, 0x2, 0x535, 0x533, 0x3, 0x2, 0x2, 0x2, 0x535, 0x536, 0x3, 0x2, 0x2, 0x2, 0x536, 0x538, 0x3, 0x2, 0x2, 0x2, 0x537, 0x539, 0x5, 0x15b, 0xae, 0x2, 0x538, 0x537, 0x3, 0x2, 0x2, 0x2, 0x538, 0x539, 0x3, 0x2, 0x2, 0x2, 0x539, 0x547, 0x3, 0x2, 0x2, 0x2, 0x53a, 0x53c, 0x9, 0x1f, 0x2, 0x2, 0x53b, 0x53a, 0x3, 0x2, 0x2, 0x2, 0x53b, 0x53c, 0x3, 0x2, 0x2, 0x2, 0x53c, 0x53d, 0x3, 0x2, 0x2, 0x2, 0x53d, 0x53f, 0x7, 0x30, 0x2, 0x2, 0x53e, 0x540, 0x5, 0x155, 0xab, 0x2, 0x53f, 0x53e, 0x3, 0x2, 0x2, 0x2, 0x540, 0x541, 0x3, 0x2, 0x2, 0x2, 0x541, 0x53f, 0x3, 0x2, 0x2, 0x2, 0x541, 0x542, 0x3, 0x2, 0x2, 0x2, 0x542, 0x544, 0x3, 0x2, 0x2, 0x2, 0x543, 0x545, 0x5, 0x15b, 0xae, 0x2, 0x544, 0x543, 0x3, 0x2, 0x2, 0x2, 0x544, 0x545, 0x3, 0x2, 0x2, 0x2, 0x545, 0x547, 0x3, 0x2, 0x2, 0x2, 0x546, 0x51e, 0x3, 0x2, 0x2, 0x2, 0x546, 0x530, 0x3, 0x2, 0x2, 0x2, 0x546, 0x53b, 0x3, 0x2, 0x2, 0x2, 0x547, 0x160, 0x3, 0x2, 0x2, 0x2, 0x548, 0x549, 0x7, 0x32, 0x2, 0x2, 0x549, 0x54b, 0x9, 0x19, 0x2, 0x2, 0x54a, 0x54c, 0x5, 0x157, 0xac, 0x2, 0x54b, 0x54a, 0x3, 0x2, 0x2, 0x2, 0x54c, 0x54d, 0x3, 0x2, 0x2, 0x2, 0x54d, 0x54b, 0x3, 0x2, 0x2, 0x2, 0x54d, 0x54e, 0x3, 0x2, 0x2, 0x2, 0x54e, 0x162, 0x3, 0x2, 0x2, 0x2, 0x54f, 0x550, 0x5, 0x15f, 0xb0, 0x2, 0x550, 0x551, 0x7, 0x27, 0x2, 0x2, 0x551, 0x164, 0x3, 0x2, 0x2, 0x2, 0x552, 0x553, 0x5, 0x15d, 0xaf, 0x2, 0x553, 0x554, 0x7, 0x6b, 0x2, 0x2, 0x554, 0x559, 0x3, 0x2, 0x2, 0x2, 0x555, 0x556, 0x5, 0x15f, 0xb0, 0x2, 0x556, 0x557, 0x7, 0x6b, 0x2, 0x2, 0x557, 0x559, 0x3, 0x2, 0x2, 0x2, 0x558, 0x552, 0x3, 0x2, 0x2, 0x2, 0x558, 0x555, 0x3, 0x2, 0x2, 0x2, 0x559, 0x166, 0x3, 0x2, 0x2, 0x2, 0x55a, 0x55e, 0x5, 0x15d, 0xaf, 0x2, 0x55b, 0x55e, 0x5, 0x15f, 0xb0, 0x2, 0x55c, 0x55e, 0x5, 0x161, 0xb1, 0x2, 0x55d, 0x55a, 0x3, 0x2, 0x2, 0x2, 0x55d, 0x55b, 0x3, 0x2, 0x2, 0x2, 0x55d, 0x55c, 0x3, 0x2, 0x2, 0x2, 0x55e, 0x560, 0x3, 0x2, 0x2, 0x2, 0x55f, 0x561, 0x5, 0x169, 0xb5, 0x2, 0x560, 0x55f, 0x3, 0x2, 0x2, 0x2, 0x560, 0x561, 0x3, 0x2, 0x2, 0x2, 0x561, 0x563, 0x3, 0x2, 0x2, 0x2, 0x562, 0x564, 0x5, 0x169, 0xb5, 0x2, 0x563, 0x562, 0x3, 0x2, 0x2, 0x2, 0x563, 0x564, 0x3, 0x2, 0x2, 0x2, 0x564, 0x566, 0x3, 0x2, 0x2, 0x2, 0x565, 0x567, 0x5, 0x169, 0xb5, 0x2, 0x566, 0x565, 0x3, 0x2, 0x2, 0x2, 0x566, 0x567, 0x3, 0x2, 0x2, 0x2, 0x567, 0x569, 0x3, 0x2, 0x2, 0x2, 0x568, 0x56a, 0x5, 0x169, 0xb5, 0x2, 0x569, 0x568, 0x3, 0x2, 0x2, 0x2, 0x569, 0x56a, 0x3, 0x2, 0x2, 0x2, 0x56a, 0x168, 0x3, 0x2, 0x2, 0x2, 0x56b, 0x56c, 0x9, 0x20, 0x2, 0x2, 0x56c, 0x16a, 0x3, 0x2, 0x2, 0x2, 0x56d, 0x586, 0x7, 0x5e, 0x2, 0x2, 0x56e, 0x587, 0x9, 0x21, 0x2, 0x2, 0x56f, 0x570, 0x7, 0x77, 0x2, 0x2, 0x570, 0x571, 0x5, 0x157, 0xac, 0x2, 0x571, 0x572, 0x5, 0x157, 0xac, 0x2, 0x572, 0x573, 0x5, 0x157, 0xac, 0x2, 0x573, 0x574, 0x5, 0x157, 0xac, 0x2, 0x574, 0x587, 0x3, 0x2, 0x2, 0x2, 0x575, 0x576, 0x7, 0x77, 0x2, 0x2, 0x576, 0x577, 0x7, 0x7d, 0x2, 0x2, 0x577, 0x578, 0x5, 0x157, 0xac, 0x2, 0x578, 0x579, 0x5, 0x157, 0xac, 0x2, 0x579, 0x57a, 0x5, 0x157, 0xac, 0x2, 0x57a, 0x57b, 0x5, 0x157, 0xac, 0x2, 0x57b, 0x57c, 0x7, 0x7f, 0x2, 0x2, 0x57c, 0x587, 0x3, 0x2, 0x2, 0x2, 0x57d, 0x57e, 0x9, 0x22, 0x2, 0x2, 0x57e, 0x57f, 0x9, 0x23, 0x2, 0x2, 0x57f, 0x587, 0x9, 0x23, 0x2, 0x2, 0x580, 0x581, 0x9, 0x23, 0x2, 0x2, 0x581, 0x587, 0x9, 0x23, 0x2, 0x2, 0x582, 0x587, 0x9, 0x23, 0x2, 0x2, 0x583, 0x584, 0x5, 0x157, 0xac, 0x2, 0x584, 0x585, 0x5, 0x157, 0xac, 0x2, 0x585, 0x587, 0x3, 0x2, 0x2, 0x2, 0x586, 0x56e, 0x3, 0x2, 0x2, 0x2, 0x586, 0x56f, 0x3, 0x2, 0x2, 0x2, 0x586, 0x575, 0x3, 0x2, 0x2, 0x2, 0x586, 0x57d, 0x3, 0x2, 0x2, 0x2, 0x586, 0x580, 0x3, 0x2, 0x2, 0x2, 0x586, 0x582, 0x3, 0x2, 0x2, 0x2, 0x586, 0x583, 0x3, 0x2, 0x2, 0x2, 0x587, 0x16c, 0x3, 0x2, 0x2, 0x2, 0x588, 0x591, 0x5, 0x169, 0xb5, 0x2, 0x589, 0x591, 0x5, 0xfb, 0x7e, 0x2, 0x58a, 0x591, 0x5, 0x13f, 0xa0, 0x2, 0x58b, 0x591, 0x5, 0x141, 0xa1, 0x2, 0x58c, 0x591, 0x5, 0x155, 0xab, 0x2, 0x58d, 0x591, 0x5, 0x13d, 0x9f, 0x2, 0x58e, 0x591, 0x5, 0x137, 0x9c, 0x2, 0x58f, 0x591, 0x5, 0x13b, 0x9e, 0x2, 0x590, 0x588, 0x3, 0x2, 0x2, 0x2, 0x590, 0x589, 0x3, 0x2, 0x2, 0x2, 0x590, 0x58a, 0x3, 0x2, 0x2, 0x2, 0x590, 0x58b, 0x3, 0x2, 0x2, 0x2, 0x590, 0x58c, 0x3, 0x2, 0x2, 0x2, 0x590, 0x58d, 0x3, 0x2, 0x2, 0x2, 0x590, 0x58e, 0x3, 0x2, 0x2, 0x2, 0x590, 0x58f, 0x3, 0x2, 0x2, 0x2, 0x591, 0x5a8, 0x3, 0x2, 0x2, 0x2, 0x592, 0x5a7, 0x5, 0x145, 0xa3, 0x2, 0x593, 0x5a7, 0x5, 0x169, 0xb5, 0x2, 0x594, 0x5a7, 0x5, 0xfb, 0x7e, 0x2, 0x595, 0x5a7, 0x5, 0x13f, 0xa0, 0x2, 0x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0x5d8, 0x5d1, 0x3, 0x2, 0x2, 0x2, 0x5d9, 0x5da, 0x3, 0x2, 0x2, 0x2, 0x5da, 0x5db, 0x8, 0xbb, 0x2, 0x2, 0x5db, 0x176, 0x3, 0x2, 0x2, 0x2, 0x2f, 0x2, 0x17b, 0x186, 0x18c, 0x18f, 0x196, 0x19c, 0x1a1, 0x1a3, 0x507, 0x50d, 0x511, 0x516, 0x51b, 0x51e, 0x523, 0x529, 0x52d, 0x530, 0x535, 0x538, 0x53b, 0x541, 0x544, 0x546, 0x54d, 0x558, 0x55d, 0x560, 0x563, 0x566, 0x569, 0x586, 0x590, 0x5a6, 0x5a8, 0x5ae, 0x5b0, 0x5b8, 0x5ba, 0x5bf, 0x5c2, 0x5c9, 0x5d3, 0x5d8, 0x3, 0x8, 0x2, 0x2, }; atn::ATNDeserializer deserializer; _atn = deserializer.deserialize(_serializedATN); size_t count = _atn.getNumberOfDecisions(); _decisionToDFA.reserve(count); for (size_t i = 0; i < count; i++) { _decisionToDFA.emplace_back(_atn.getDecisionState(i), i); } } ELDOLexer::Initializer ELDOLexer::_init;
69.711447
120
0.604912
sydelity-net
7ad4120cf35887c1299d20c4bd55bfff365a9bf5
989
cpp
C++
Source/EngineStd/GameAssetManager/Factory/Components/Refrigeration/GameAssetRefrigerationUnit.cpp
vivienneanthony/MyForkEditor
273e15ca3610b3d3b68fdf2efbac2ba1b3659e7f
[ "Apache-2.0" ]
2
2015-12-30T00:32:09.000Z
2016-02-27T14:50:06.000Z
Source/EngineStd/GameAssetManager/Factory/Components/Refrigeration/GameAssetRefrigerationUnit.cpp
vivienneanthony/MyForkEditor
273e15ca3610b3d3b68fdf2efbac2ba1b3659e7f
[ "Apache-2.0" ]
null
null
null
Source/EngineStd/GameAssetManager/Factory/Components/Refrigeration/GameAssetRefrigerationUnit.cpp
vivienneanthony/MyForkEditor
273e15ca3610b3d3b68fdf2efbac2ba1b3659e7f
[ "Apache-2.0" ]
null
null
null
// include engine headers #include "EngineStd.h" // header for specific component #include "GameAssetRefrigerationUnit.h" const GameAssetType GameAssetRefrigerationUnit::g_Type = GAType_RefrigerationUnit; GameAssetRefrigerationUnit::GameAssetRefrigerationUnit(Context* context) : BaseComponent(context) { } // Game Asset Component - Type GameAssetRefrigerationUnit::GameAssetRefrigerationUnit() : BaseComponent() { // Set type and state to nothing for now m_GameAssetType=GAType_RefrigerationUnit; m_GameAssetState=GAState_None; // Only the physics update event is needed: unsubscribe from the rest for optimization SetUpdateEventMask(USE_FIXEDUPDATE); } // Destructor GameAssetRefrigerationUnit::~GameAssetRefrigerationUnit(void) { return; } bool GameAssetRefrigerationUnit::VInit(const GameAsset* pGameAsset) { // Set type and state to nothing for now m_GameAssetType = GAType_RefrigerationUnit; m_GameAssetState = GAState_None; return true; }
23.547619
97
0.790698
vivienneanthony
7ad46012f30985b3883346136ac0fde6f90bd87a
1,930
cpp
C++
src/frameworks/wilhelm/src/itf/I3DCommit.cpp
dAck2cC2/m3e
475b89b59d5022a94e00b636438b25e27e4eaab2
[ "Apache-2.0" ]
3
2015-08-31T15:24:31.000Z
2020-04-24T20:31:29.000Z
src/frameworks/wilhelm/src/itf/I3DCommit.cpp
dAck2cC2/m3e
475b89b59d5022a94e00b636438b25e27e4eaab2
[ "Apache-2.0" ]
null
null
null
src/frameworks/wilhelm/src/itf/I3DCommit.cpp
dAck2cC2/m3e
475b89b59d5022a94e00b636438b25e27e4eaab2
[ "Apache-2.0" ]
3
2015-07-29T07:17:15.000Z
2020-11-04T06:55:37.000Z
/* * Copyright (C) 2010 The Android Open Source Project * * 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. */ /* 3DCommit implementation */ #include "sles_allinclusive.h" static SLresult I3DCommit_Commit(SL3DCommitItf self) { SL_ENTER_INTERFACE I3DCommit *thiz = (I3DCommit *) self; IObject *thisObject = InterfaceToIObject(thiz); object_lock_exclusive(thisObject); if (thiz->mDeferred) { SLuint32 myGeneration = thiz->mGeneration; do { ++thiz->mWaiting; object_cond_wait(thisObject); } while (thiz->mGeneration == myGeneration); } object_unlock_exclusive(thisObject); result = SL_RESULT_SUCCESS; SL_LEAVE_INTERFACE } static SLresult I3DCommit_SetDeferred(SL3DCommitItf self, SLboolean deferred) { SL_ENTER_INTERFACE I3DCommit *thiz = (I3DCommit *) self; IObject *thisObject = InterfaceToIObject(thiz); object_lock_exclusive(thisObject); thiz->mDeferred = SL_BOOLEAN_FALSE != deferred; // normalize object_unlock_exclusive(thisObject); result = SL_RESULT_SUCCESS; SL_LEAVE_INTERFACE } static const struct SL3DCommitItf_ I3DCommit_Itf = { I3DCommit_Commit, I3DCommit_SetDeferred }; void I3DCommit_init(void *self) { I3DCommit *thiz = (I3DCommit *) self; thiz->mItf = &I3DCommit_Itf; thiz->mDeferred = SL_BOOLEAN_FALSE; thiz->mGeneration = 0; thiz->mWaiting = 0; }
27.183099
77
0.712953
dAck2cC2
7ad48e2d8cdf0736321f0782af88979d3b513bb0
1,596
cpp
C++
libs/systems/impl/src/systems/impl/log_context.cpp
cpreh/spacegameengine
313a1c34160b42a5135f8223ffaa3a31bc075a01
[ "BSL-1.0" ]
2
2016-01-27T13:18:14.000Z
2018-05-11T01:11:32.000Z
libs/systems/impl/src/systems/impl/log_context.cpp
cpreh/spacegameengine
313a1c34160b42a5135f8223ffaa3a31bc075a01
[ "BSL-1.0" ]
null
null
null
libs/systems/impl/src/systems/impl/log_context.cpp
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) #include <sge/log/default_level.hpp> #include <sge/log/default_level_streams.hpp> #include <sge/systems/optional_log_context_ref.hpp> #include <sge/systems/impl/log_context.hpp> #include <fcppt/make_ref.hpp> #include <fcppt/make_unique_ptr.hpp> #include <fcppt/reference_impl.hpp> #include <fcppt/unique_ptr_impl.hpp> #include <fcppt/log/context.hpp> #include <fcppt/log/context_reference.hpp> #include <fcppt/optional/maybe.hpp> #include <fcppt/variant/match.hpp> sge::systems::impl::log_context::log_context( sge::systems::optional_log_context_ref const _log_context) : impl_{fcppt::optional::maybe( _log_context, [] { return variant{fcppt::make_unique_ptr<fcppt::log::context>( sge::log::default_level(), sge::log::default_level_streams())}; }, [](fcppt::reference<fcppt::log::context> const _ref) { return variant{_ref}; })} { } sge::systems::impl::log_context::~log_context() = default; fcppt::log::context_reference sge::systems::impl::log_context::get() const { return fcppt::variant::match( impl_, [](fcppt::unique_ptr<fcppt::log::context> const &_context) -> fcppt::log::context_reference { return fcppt::make_ref(*_context); }, [](fcppt::reference<fcppt::log::context> const &_context) -> fcppt::log::context_reference { return _context; }); }
37.116279
97
0.687343
cpreh
7ad684895c182e13c88f71645d1010a43c383515
6,260
cc
C++
sdl1/tennix/archive.cc
pdpdds/sdldualsystem
d74ea84cbea705fef62868ba8c693bf7d2555636
[ "BSD-2-Clause" ]
null
null
null
sdl1/tennix/archive.cc
pdpdds/sdldualsystem
d74ea84cbea705fef62868ba8c693bf7d2555636
[ "BSD-2-Clause" ]
null
null
null
sdl1/tennix/archive.cc
pdpdds/sdldualsystem
d74ea84cbea705fef62868ba8c693bf7d2555636
[ "BSD-2-Clause" ]
null
null
null
/** * * Tennix Archive File Format * Copyright (C) 2009-2010 Thomas Perl <thp@thpinfo.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * **/ #include <iostream> #include <libgen.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> //#include <arpa/inet.h> #include <WinSock2.h> #include "archive.hh" TennixArchive::TennixArchive(const char* filename, const char* fallback) { fp = fopen(filename, "rb"); if (fp == NULL && fallback != NULL) { fp = fopen(fallback, "rb"); } assert(fp != NULL); offset = sizeof(TennixArchiveHeader)*fread(&(header), sizeof(TennixArchiveHeader), 1, fp); assert(offset == sizeof(TennixArchiveHeader)); assert(strncmp(header.header, TENNIX_ARCHIVE_HEADER, TENNIX_ARCHIVE_HEADER_LEN) == 0); assert(header.versionmajor == TENNIX_ARCHIVE_VERSIONMAJOR); assert(header.versionminor == TENNIX_ARCHIVE_VERSIONMINOR); items = (TennixArchiveItem*)calloc(header.items, sizeof(TennixArchiveItem)); assert(items != NULL); offset += sizeof(TennixArchiveItem)*fread(items, sizeof(TennixArchiveItem), header.items, fp); assert(offset == sizeof(TennixArchiveHeader) + header.items*sizeof(TennixArchiveItem)); xormem((char*)(items), header.items*sizeof(TennixArchiveItem), header.key); for (int i=0; i<header.items; i++) { /* convert offset + length from network byte order */ items[i].offset = ntohl(items[i].offset); items[i].length = ntohl(items[i].length); } current_item = 0; building = 0; } std::ostream& operator<<(std::ostream& out, TennixArchiveHeader& header) { out << "Header: " << header.header << std::endl; out << "Version: " << (int)header.versionmajor << '.' << (int)header.versionminor << std::endl; out << "Master key: " << header.key << std::endl; out << "Items: " << header.items; return out; } std::ostream& operator<<(std::ostream& out, TennixArchiveItem& item) { out << "File: " << item.filename << std::endl; out << "Size: " << item.length << std::endl; out << "Offset: " << item.offset << std::endl; out << "Key: " << (int)item.key; return out; } int TennixArchive::setItemFilename(const char* filename) { int i; for (i=0; i<header.items; i++) { if (strncmp(items[i].filename, filename, TENNIX_ARCHIVE_ITEM_MAXNAME) == 0) { current_item = i; return 1; } } return 0; } char* TennixArchive::getItemBytes() { size_t size = getItemSize(); char* data = (char*)malloc(size+1); /* the last char is a null character, so this works for strings, too */ data[size]='\0'; fseek(fp, items[current_item].offset, SEEK_SET); assert(fread(data, size, 1, fp) == 1); xormem(data, size, items[current_item].key); return data; } void TennixArchive::xormem(char* mem, uint32_t length, char key) { char *i = mem, *end = mem+length; for(; i != end; i++) { *i ^= key; } } void TennixArchive::appendItem(char* filename, char* data, uint32_t length) { TennixArchiveItem* item; header.items++; items = (TennixArchiveItem*)realloc(items, sizeof(TennixArchiveItem)*header.items); blobs = (char**)realloc(blobs, sizeof(char*)*header.items); item = &(items[header.items-1]); blobs[header.items-1] = data; for (int i=0; i<TENNIX_ARCHIVE_ITEM_MAXNAME; i++) { item->filename[i] = data[(i*2)%length]; } strcpy(item->filename, filename); item->length = length; } void TennixArchive::buildFile(char* filename) { size_t offset = 0; size_t *memsize = NULL; memsize = (size_t*)calloc(header.items, sizeof(size_t)); fp = fopen(filename, "wb"); assert(fp != NULL); offset += sizeof(TennixArchiveHeader) + header.items*sizeof(TennixArchiveItem); header.versionmajor = TENNIX_ARCHIVE_VERSIONMAJOR; header.versionminor = TENNIX_ARCHIVE_VERSIONMINOR; header.key = (0xaa + 0x77*header.items*3) % 0xff; fprintf(stderr, "Packing: "); for (int i=0; i<header.items; i++) { fprintf(stderr, "%s", items[i].filename); items[i].offset = htonl(offset); /* network byte order */ items[i].key = 0xaa ^ ((i<<2)%0x100); xormem(blobs[i], items[i].length, items[i].key); memsize[i] = items[i].length; offset += items[i].length; items[i].length = htonl(items[i].length); /* network byte order */ xormem((char*)(items + i), sizeof(TennixArchiveItem), header.key); if (i != header.items-1) { fprintf(stderr, ", "); } } fputc('\n', stderr); fprintf(stderr, "Writing: %s", filename); fputc('.', stderr); assert(fwrite(&(header), sizeof(TennixArchiveHeader), 1, fp) == 1); fputc('.', stderr); assert(fwrite(items, sizeof(TennixArchiveItem), header.items, fp) == header.items); fputc('.', stderr); for (int i=0; i<header.items; i++) { assert(fwrite(blobs[i], memsize[i], 1, fp) == 1); free(blobs[i]); } fputc('.', stderr); fprintf(stderr, "OK\n"); free(memsize); free(blobs); } std::ostream& operator<<(std::ostream& out, TennixArchive& archive) { out << "Tennix Archive" << std::endl; out << archive.header << std::endl; for (int i=0; i<archive.header.items; i++) { out << "=======================" << std::endl; out << archive.items[i] << std::endl; } out << "=== END OF ARCHIVE ====" << std::endl; return out; }
28.715596
98
0.625879
pdpdds
7ad74b65a2b09feee3a5ac1a965420ac2c9bd381
3,286
cpp
C++
osgDB/Registry.cpp
gideonmay/PyOSG
fe44853d52a92596aeb3983f1f6d73191872affe
[ "BSD-2-Clause-FreeBSD" ]
5
2019-05-09T14:09:05.000Z
2022-03-21T01:31:41.000Z
osgDB/Registry.cpp
gideonmay/PyOSG
fe44853d52a92596aeb3983f1f6d73191872affe
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
osgDB/Registry.cpp
gideonmay/PyOSG
fe44853d52a92596aeb3983f1f6d73191872affe
[ "BSD-2-Clause-FreeBSD" ]
4
2018-05-10T07:54:23.000Z
2020-01-08T07:37:05.000Z
// Copyright (C) 2016 Gideon May (gideon@borges.xyz) // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. // Permission to modify the code and to distribute modified code is granted // provided this copyright notice appears in all copies, and a notice // that the code was modified is included with the copyright notice. // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. #include <boost/python.hpp> #include <osg/Referenced> #include <osgDB/Registry> #include "held_ptr.hpp" using namespace boost::python; namespace { osgDB::Registry * instance() { return osgDB::Registry::instance(); } } namespace PyOSG { void init_Registry() { class_<osgDB::Registry, osg::ref_ptr<osgDB::Registry>, bases<osg::Referenced>, boost::noncopyable > // class_<osgDB::Registry, osg::ref_ptr<osgDB::Registry>, boost::noncopyable > registry("Registry", "Registry is a singleton factory which stores the reader/writers which are linked in at runtime for reading non-native file formats.", no_init); registry .def("readCommandLine", &osgDB::Registry::readCommandLine) .def("addFileExtensionAlias", &osgDB::Registry::addFileExtensionAlias) // .def("addDotOsgWrapper", &osgDB::Registry::addDotOsgWrapper) // .def("removeDotOsgWrapper", &osgDB::Registry::removeDotOsgWrapper) .def("addReaderWriter", &osgDB::Registry::addReaderWriter) .def("removeReaderWriter", &osgDB::Registry::removeReaderWriter) .def("loadLibrary", &osgDB::Registry::loadLibrary) .def("closeLibrary", &osgDB::Registry::closeLibrary) /* .def("getReaderWriterForExtension", &osgDB::Registry::getReaderWriterForExtension) .def("readObject", &osgDB::Registry::readObject) .def("writeObject", &osgDB::Registry::writeObject) .def("readImage", &osgDB::Registry::readImage) .def("writeImage", &osgDB::Registry::writeImage) .def("readNode", &osgDB::Registry::readNode) .def("writeNode", &osgDB::Registry::writeNode) */ .def("initFilePathLists", &osgDB::Registry::initFilePathLists, "initilize both the Data and Library FilePaths, by default called by the constructor, so it should only be required if you want to force the re-reading of environmental variables.") .def("initDataFilePathList", &osgDB::Registry::initDataFilePathList, "initilize the Data FilePath by reading the OSG_FILE_PATH environmental variable.") .def("removeExpiredObjectsInCache", &osgDB::Registry::removeExpiredObjectsInCache) .def("clearObjectCache", &osgDB::Registry::clearObjectCache) // XXX .def("setUseObjectCacheHint", &osgDB::Registry::setUseObjectCacheHint) .def("instance", &osgDB::Registry::instance, return_value_policy<manage_osg_object>()) .def("instance", &instance, return_value_policy<manage_osg_object>()) .staticmethod("instance") ; } }
45.013699
197
0.664638
gideonmay
7ad85bca62cdc124c66b287180f153907aa2cb0e
310
cpp
C++
lib/EMP/emp-tool/gc/backend.cpp
zpleefly/libscapi
27d7d964d645ed111c2cc9870087971cf13e24f4
[ "MIT" ]
null
null
null
lib/EMP/emp-tool/gc/backend.cpp
zpleefly/libscapi
27d7d964d645ed111c2cc9870087971cf13e24f4
[ "MIT" ]
2
2021-03-20T05:38:48.000Z
2021-03-31T20:14:11.000Z
lib/EMP/emp-tool/gc/backend.cpp
zpleefly/libscapi
27d7d964d645ed111c2cc9870087971cf13e24f4
[ "MIT" ]
null
null
null
#include "backend.h" #ifdef THREADING __thread Backend* local_backend = nullptr; __thread GarbleCircuit* local_gc = nullptr; #else Backend* local_backend = nullptr; GarbleCircuit* local_gc = nullptr; #endif int greatestPowerOfTwoLessThan(int n) { int k = 1; while (k < n) k = k << 1; return k >> 1; }
16.315789
43
0.709677
zpleefly
7ad8cb9cbb1e8954aa8f4ab4ff01f9b3107b6137
2,398
hpp
C++
src/Error.hpp
JesseMaurais/SGe
f73bd03d30074a54642847b05f82151128481371
[ "MIT" ]
1
2017-04-20T06:27:36.000Z
2017-04-20T06:27:36.000Z
src/Error.hpp
JesseMaurais/SGe
f73bd03d30074a54642847b05f82151128481371
[ "MIT" ]
null
null
null
src/Error.hpp
JesseMaurais/SGe
f73bd03d30074a54642847b05f82151128481371
[ "MIT" ]
null
null
null
#ifndef Error_hpp #define Error_hpp #include "io.hpp" #include "SDL.hpp" #include "Strings.hpp" #include <system_error> #include <exception> namespace SDL { /// Overload of SDL::LogError that takes std::string inline bool LogError(std::string const &prefix) { return LogError(prefix.c_str()); } /// Overload of SDL::LogError that takes Strings enumeration inline bool LogError(enum Strings prefix) { return LogError(String(prefix)); } /// Overload of SDL::SetErrno that takes std::string inline bool SetErrno(std::string const &prefix) { return SetErrno(prefix.c_str()); } /// Overload of SDL::SetErrno that takes Strings enumeration inline bool SetErrno(enum Strings prefix) { return SetErrno(String(prefix)); } /// Set error string with current errno and log it like perror does inline bool perror(std::string const &prefix) { return SDL::SetErrno() and SDL::LogError(prefix); } /// Type-safe and format-safe version of SDL_SetError. Always returns true template <typename... Args> bool SetError(std::string const &format, Args&&... args) { std::string message; io::sprintf(message, format, args...); return 0 > SDL_SetError("%s", message.c_str()); } /// Type-safe and format-safe version taking Strings enum. Always returns true template <typename... Args> bool SetError(enum Strings format, Args&&... args) { return SetError(String(format), args...); } /// Set error string with given std::exception inline bool SetError(std::exception const except) { std::string const message = except.what(); return SetError(message); } /// Set error string with given std::error_code inline bool SetError(std::error_code const error_code) { std::string const message = error_code.message(); return SetError(message); } /// Set error string with given std::errc inline bool SetError(std::errc const errc) { std::error_code const error_code = std::make_error_code(errc); return SetError(error_code); } /// Type-safe and format-safe version of SDL_Log template <typename... Args> void Log(std::string const &format, Args&&... args) { std::string message; io::sprintf(message, format, args...); SDL_Log("%s", message.c_str()); } // Type-safe and format-safe version taking Strings enum template <typename... Args> void Log(enum Strings format, Args&&... args) { Log(String(format), args...); } } #endif // file
25.784946
85
0.706422
JesseMaurais
7addb7a8683610c2d49fefd995a33ca5c51645cf
1,302
hpp
C++
traffic.hpp
iszczesniak/ddpp
bc27ad2b7f699d8ef2e11dcb3b56d538d92e4b4e
[ "BSL-1.0" ]
null
null
null
traffic.hpp
iszczesniak/ddpp
bc27ad2b7f699d8ef2e11dcb3b56d538d92e4b4e
[ "BSL-1.0" ]
null
null
null
traffic.hpp
iszczesniak/ddpp
bc27ad2b7f699d8ef2e11dcb3b56d538d92e4b4e
[ "BSL-1.0" ]
null
null
null
#ifndef TRAFFIC_HPP #define TRAFFIC_HPP #include "client.hpp" #include "graph.hpp" #include "module.hpp" #include "sim.hpp" #include <queue> #include <random> #include <set> class traffic: public module<sim> { // The set of active clients. std::set<client *> cs; // The queue of clients to delete later. std::queue<client *> dl; // The ID counter. int idc; // The client arrival time distribution. std::exponential_distribution<> m_catd; // The mean holding time. double m_mht; // The mean number of units. double m_mnu; // Shortest distances. mutable std::map<npair, int> sd; public: traffic(double mcat, double mht, double mnu); ~traffic(); // Processes the event and changes the state of the client. void operator()(double t); // Return the number of clients. int nr_clients() const; // Insert the client to the traffic. void insert(client *); // Remote the client from the traffic. void erase(client *); // Delete this client later. void delete_me_later(client *); // Calculate the capacity currently served, i.e., the sum of the // products of the number of units used and the weight of an edge. COST capacity_served() const; private: void schedule_next(double); void delete_clients(); }; #endif /* TRAFFIC_HPP */
19.432836
68
0.686636
iszczesniak
7adff761af2c06c28166a3736f93b726e6228626
1,418
cpp
C++
src/Command.cpp
eXpl0it3r/SecondaryMap
0c5dbe98f0f08a33771045bf80fa4197e7bc09f8
[ "Zlib" ]
null
null
null
src/Command.cpp
eXpl0it3r/SecondaryMap
0c5dbe98f0f08a33771045bf80fa4197e7bc09f8
[ "Zlib" ]
null
null
null
src/Command.cpp
eXpl0it3r/SecondaryMap
0c5dbe98f0f08a33771045bf80fa4197e7bc09f8
[ "Zlib" ]
null
null
null
#include "Command.hpp" #include "utility.hpp" #include "Application.hpp" #include <SFML/System/Err.hpp> #include <iostream> Command::Command(const std::string& tokens, const std::string& data) : m_failed{false} { init_tokens(tokens); init_data(data); if(m_failed) { m_tokens.clear(); m_data.clear(); } } bool Command::failed() { return m_failed; } std::deque<std::string>& Command::tokens() { return m_tokens; } Json::Value& Command::data() { return m_data; } void Command::init_tokens(const std::string& tokens) { // Split the tokens m_tokens = utility::split(tokens, '/'); // Required: API call & correct version if(m_tokens.empty()) { sf::err() << "No tokens given!" << std::endl; m_failed = true; } else if(m_tokens.front() != Application::VERSION) { sf::err() << "API version miss match!" << std::endl; m_failed = true; } // Remove the API version information m_tokens.pop_front(); //for(auto& token : m_tokens) // std::cout << "Split: " << token << std::endl; } void Command::init_data(const std::string& data) { // Extract JSON data Json::Reader reader; if(!reader.parse(data, m_data)) { sf::err() << "Failed to parse the data" << std::endl << reader.getFormattedErrorMessages() << std::endl; m_failed = true; } else { //std::cout << "Parsed successfully!" << std::endl; } }
18.657895
107
0.615656
eXpl0it3r
7ae5bf12ce5bfce9821c206a5a97798a21725b19
132
cpp
C++
Engine/src/Engine/Renderer/RendererAPI.cpp
PalliativeX/GameEngine
704cf5f3ebc81fdf5e3e514908c3ac47305ccd33
[ "Apache-2.0" ]
null
null
null
Engine/src/Engine/Renderer/RendererAPI.cpp
PalliativeX/GameEngine
704cf5f3ebc81fdf5e3e514908c3ac47305ccd33
[ "Apache-2.0" ]
null
null
null
Engine/src/Engine/Renderer/RendererAPI.cpp
PalliativeX/GameEngine
704cf5f3ebc81fdf5e3e514908c3ac47305ccd33
[ "Apache-2.0" ]
null
null
null
#include "enginepch.h" #include "RendererAPI.h" namespace Engine { RendererAPI::API RendererAPI::api = RendererAPI::API::OpenGL; }
18.857143
62
0.75
PalliativeX
7ae639511551668ded269856b7d603838e0f1496
597
cpp
C++
cpp/671-680/Valid Parenthesis String.cpp
KaiyuWei/leetcode
fd61f5df60cfc7086f7e85774704bacacb4aaa5c
[ "MIT" ]
150
2015-04-04T06:53:49.000Z
2022-03-21T13:32:08.000Z
cpp/671-680/Valid Parenthesis String.cpp
yizhu1012/leetcode
d6fa443a8517956f1fcc149c8c4f42c0ad93a4a7
[ "MIT" ]
1
2015-04-13T15:15:40.000Z
2015-04-21T20:23:16.000Z
cpp/671-680/Valid Parenthesis String.cpp
yizhu1012/leetcode
d6fa443a8517956f1fcc149c8c4f42c0ad93a4a7
[ "MIT" ]
64
2015-06-30T08:00:07.000Z
2022-01-01T16:44:14.000Z
class Solution { public: bool checkValidString(string s) { int minLeft = 0, maxLeft = 0; for (char ch : s) { if (ch == '(') { minLeft++; maxLeft++; } else if (ch == ')') { minLeft--; maxLeft--; } else { minLeft--; maxLeft++; } if (maxLeft < 0) { return false; } minLeft = max(0, minLeft); } return minLeft == 0; } };
21.321429
38
0.311558
KaiyuWei
7aed715ef9ebe3d0c540d0b86c92e8f17661c4c3
105
hh
C++
build/x86/mem/protocol/Message.hh
billionshang/gem5
18cc4294f32315595f865d07d1f33434e92b06b2
[ "BSD-3-Clause" ]
null
null
null
build/x86/mem/protocol/Message.hh
billionshang/gem5
18cc4294f32315595f865d07d1f33434e92b06b2
[ "BSD-3-Clause" ]
null
null
null
build/x86/mem/protocol/Message.hh
billionshang/gem5
18cc4294f32315595f865d07d1f33434e92b06b2
[ "BSD-3-Clause" ]
null
null
null
#include "/mnt/hgfs/ShareShen/gem5-origin-stable-2015-9-3/build/x86/mem/ruby/slicc_interface/Message.hh"
52.5
104
0.8
billionshang
7aee2b1245a3c594ce397943a8c0548854afb060
159
cpp
C++
Chapter1/Excercise15.cpp
yapbenzet/absolute-c-plusplus
67adef6c177e7ef3c71406cd26cef2a944fd0d19
[ "MIT" ]
1
2019-08-13T17:51:24.000Z
2019-08-13T17:51:24.000Z
Chapter1/Excercise15.cpp
yapbenzet/absolute-c-plusplus
67adef6c177e7ef3c71406cd26cef2a944fd0d19
[ "MIT" ]
null
null
null
Chapter1/Excercise15.cpp
yapbenzet/absolute-c-plusplus
67adef6c177e7ef3c71406cd26cef2a944fd0d19
[ "MIT" ]
1
2020-06-05T13:37:56.000Z
2020-06-05T13:37:56.000Z
#include <iostream> #include <string> using namespace std; int main() { string s1 = "5"; string s2 = "3"; string s3 = s1 + s2; cout << s3 << endl; }
13.25
22
0.578616
yapbenzet
7aeee5aad78a4ab307997ac05137ee63e7b9b340
30,880
cpp
C++
test/qupzilla-master/src/plugins/TabManager/tabmanagerwidget.cpp
JamesMBallard/qmake-unity
cf5006a83e7fb1bbd173a9506771693a673d387f
[ "MIT" ]
16
2019-05-23T08:10:39.000Z
2021-12-21T11:20:37.000Z
test/qupzilla-master/src/plugins/TabManager/tabmanagerwidget.cpp
JamesMBallard/qmake-unity
cf5006a83e7fb1bbd173a9506771693a673d387f
[ "MIT" ]
null
null
null
test/qupzilla-master/src/plugins/TabManager/tabmanagerwidget.cpp
JamesMBallard/qmake-unity
cf5006a83e7fb1bbd173a9506771693a673d387f
[ "MIT" ]
2
2019-05-23T18:37:43.000Z
2021-08-24T21:29:40.000Z
/* ============================================================ * TabManager plugin for QupZilla * Copyright (C) 2013-2017 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com> * Copyright (C) 2018 David Rosca <nowrep@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ============================================================ */ #include "tabmanagerwidget.h" #include "ui_tabmanagerwidget.h" #include "mainapplication.h" #include "browserwindow.h" #include "webtab.h" #include "webpage.h" #include "tabbedwebview.h" #include "tabwidget.h" #include "locationbar.h" #include "bookmarkstools.h" #include "bookmarkitem.h" #include "bookmarks.h" #include "tabmanagerplugin.h" #include "tldextractor/tldextractor.h" #include "tabmanagerdelegate.h" #include "tabcontextmenu.h" #include "tabbar.h" #include <QDesktopWidget> #include <QDialogButtonBox> #include <QStackedWidget> #include <QDialog> #include <QTimer> #include <QLabel> #include <QMimeData> TLDExtractor* TabManagerWidget::s_tldExtractor = 0; TabManagerWidget::TabManagerWidget(BrowserWindow* mainClass, QWidget* parent, bool defaultWidget) : QWidget(parent) , ui(new Ui::TabManagerWidget) , p_QupZilla(mainClass) , m_webPage(0) , m_isRefreshing(false) , m_refreshBlocked(false) , m_waitForRefresh(false) , m_isDefaultWidget(defaultWidget) { if(s_tldExtractor == 0) { s_tldExtractor = TLDExtractor::instance(); s_tldExtractor->setDataSearchPaths(QStringList() << TabManagerPlugin::settingsPath()); } ui->setupUi(this); ui->treeWidget->setSelectionMode(QTreeWidget::SingleSelection); ui->treeWidget->setUniformRowHeights(true); ui->treeWidget->setColumnCount(2); ui->treeWidget->header()->hide(); ui->treeWidget->header()->setStretchLastSection(false); ui->treeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch); ui->treeWidget->header()->setSectionResizeMode(1, QHeaderView::Fixed); ui->treeWidget->header()->resizeSection(1, 16); ui->treeWidget->setExpandsOnDoubleClick(false); ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->treeWidget->installEventFilter(this); ui->filterBar->installEventFilter(this); QPushButton* closeButton = new QPushButton(ui->filterBar); closeButton->setFlat(true); closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); ui->filterBar->addWidget(closeButton, LineEdit::RightSide); ui->filterBar->hide(); ui->treeWidget->setItemDelegate(new TabManagerDelegate(ui->treeWidget)); connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(filterBarClosed())); connect(ui->filterBar, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(ui->treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onItemActivated(QTreeWidgetItem*,int))); connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint))); connect(ui->treeWidget, SIGNAL(requestRefreshTree()), this, SLOT(delayedRefreshTree())); } TabManagerWidget::~TabManagerWidget() { delete ui; } void TabManagerWidget::setGroupType(GroupType type) { m_groupType = type; } QString TabManagerWidget::domainFromUrl(const QUrl &url, bool useHostName) { QString appendString = QL1S(":"); QString urlString = url.toString(); if (url.scheme() == "file") { return tr("Local File System:"); } else if (url.scheme() == "qupzilla" || urlString.isEmpty()) { return tr("QupZilla:"); } else if (url.scheme() == "ftp") { appendString.prepend(tr(" [FTP]")); } QString host = url.host(); if (host.isEmpty()) { return urlString.append(appendString); } if (useHostName || host.contains(QRegExp("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$"))) { if (host.startsWith("www.", Qt::CaseInsensitive)) { host.remove(0, 4); } return host.append(appendString); } else { const QString registeredDomain = s_tldExtractor->registrableDomain(host); if (!registeredDomain.isEmpty()) { host = registeredDomain; } return host.append(appendString); } } void TabManagerWidget::delayedRefreshTree(WebPage* p) { if (m_refreshBlocked || m_waitForRefresh) { return; } if (m_isRefreshing && !p) { return; } m_webPage = p; m_waitForRefresh = true; QTimer::singleShot(50, this, SLOT(refreshTree())); } void TabManagerWidget::refreshTree() { if (m_refreshBlocked) { return; } if (m_isRefreshing && !m_webPage) { return; } // store selected items QList<QWidget*> selectedTabs; for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i); if (winItem->checkState(0) == Qt::Unchecked) { continue; } for (int j = 0; j < winItem->childCount(); ++j) { TabItem* tabItem = static_cast<TabItem*>(winItem->child(j)); if (!tabItem || tabItem->checkState(0) == Qt::Unchecked) { continue; } selectedTabs << tabItem->webTab(); } } ui->treeWidget->clear(); ui->treeWidget->setEnableDragTabs(m_groupType == GroupByWindow); QTreeWidgetItem* currentTabItem = nullptr; if (m_groupType == GroupByHost) { currentTabItem = groupByDomainName(true); } else if (m_groupType == GroupByDomain) { currentTabItem = groupByDomainName(); } else { // fallback to GroupByWindow m_groupType = GroupByWindow; currentTabItem = groupByWindow(); } // restore selected items for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i); for (int j = 0; j < winItem->childCount(); ++j) { TabItem* tabItem = static_cast<TabItem*>(winItem->child(j)); if (tabItem && selectedTabs.contains(tabItem->webTab())) { tabItem->setCheckState(0, Qt::Checked); } } } filterChanged(m_filterText, true); ui->treeWidget->expandAll(); if (currentTabItem) ui->treeWidget->scrollToItem(currentTabItem, QAbstractItemView::EnsureVisible); m_isRefreshing = false; m_waitForRefresh = false; } void TabManagerWidget::onItemActivated(QTreeWidgetItem* item, int column) { TabItem* tabItem = static_cast<TabItem*>(item); if (!tabItem) { return; } BrowserWindow* mainWindow = tabItem->window(); QWidget* tabWidget = tabItem->webTab(); if (column == 1) { if (item->childCount() > 0) QMetaObject::invokeMethod(mainWindow ? mainWindow : mApp->getWindow(), "addTab"); else if (tabWidget && mainWindow) mainWindow->tabWidget()->requestCloseTab(mainWindow->tabWidget()->indexOf(tabWidget)); return; } if (!mainWindow) { return; } if (mainWindow->isMinimized()) { mainWindow->showNormal(); } else { mainWindow->show(); } mainWindow->activateWindow(); mainWindow->raise(); mainWindow->weView()->setFocus(); if (tabWidget && tabWidget != mainWindow->tabWidget()->currentWidget()) { mainWindow->tabWidget()->setCurrentIndex(mainWindow->tabWidget()->indexOf(tabWidget)); } } bool TabManagerWidget::isTabSelected() { bool selected = false; for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* parentItem = ui->treeWidget->topLevelItem(i); if (parentItem->checkState(0) != Qt::Unchecked) { selected = true; break; } } return selected; } void TabManagerWidget::customContextMenuRequested(const QPoint &pos) { QMenu* menu = nullptr; TabItem* item = static_cast<TabItem*>(ui->treeWidget->itemAt(pos)); if (item) { BrowserWindow* mainWindow = item->window(); QWidget* tabWidget = item->webTab(); if (mainWindow && tabWidget) { int index = mainWindow->tabWidget()->indexOf(tabWidget); // if items are not grouped by Window then actions "Close Other Tabs", // "Close Tabs To The Bottom" and "Close Tabs To The Top" // are ambiguous and should be hidden. TabContextMenu::Options options = TabContextMenu::VerticalTabs; if (m_groupType == GroupByWindow) { options |= TabContextMenu::ShowCloseOtherTabsActions; } menu = new TabContextMenu(index, mainWindow, options); menu->addSeparator(); } } if (!menu) menu = new QMenu; menu->setAttribute(Qt::WA_DeleteOnClose); QAction* action; QMenu groupTypeSubmenu(tr("Group by")); action = groupTypeSubmenu.addAction(tr("&Window"), this, SLOT(changeGroupType())); action->setData(GroupByWindow); action->setCheckable(true); action->setChecked(m_groupType == GroupByWindow); action = groupTypeSubmenu.addAction(tr("&Domain"), this, SLOT(changeGroupType())); action->setData(GroupByDomain); action->setCheckable(true); action->setChecked(m_groupType == GroupByDomain); action = groupTypeSubmenu.addAction(tr("&Host"), this, SLOT(changeGroupType())); action->setData(GroupByHost); action->setCheckable(true); action->setChecked(m_groupType == GroupByHost); menu->addMenu(&groupTypeSubmenu); if (m_isDefaultWidget) { menu->addAction(QIcon(":/tabmanager/data/side-by-side.png"), tr("&Show side by side"), this, SIGNAL(showSideBySide()))->setObjectName("sideBySide"); } menu->addSeparator(); if (isTabSelected()) { menu->addAction(QIcon(":/tabmanager/data/tab-detach.png"), tr("&Detach checked tabs"), this, SLOT(processActions()))->setObjectName("detachSelection"); menu->addAction(QIcon(":/tabmanager/data/tab-bookmark.png"), tr("Book&mark checked tabs"), this, SLOT(processActions()))->setObjectName("bookmarkSelection"); menu->addAction(QIcon(":/tabmanager/data/tab-close.png"), tr("&Close checked tabs"), this, SLOT(processActions()))->setObjectName("closeSelection"); menu->addAction(tr("&Unload checked tabs"), this, SLOT(processActions()))->setObjectName("unloadSelection"); } menu->exec(ui->treeWidget->viewport()->mapToGlobal(pos)); } void TabManagerWidget::filterChanged(const QString &filter, bool force) { if (force || filter != m_filterText) { m_filterText = filter.simplified(); ui->treeWidget->itemDelegate()->setProperty("filterText", m_filterText); if (m_filterText.isEmpty()) { for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* parentItem = ui->treeWidget->topLevelItem(i); for (int j = 0; j < parentItem->childCount(); ++j) { QTreeWidgetItem* childItem = parentItem->child(j); childItem->setHidden(false); } parentItem->setHidden(false); parentItem->setExpanded(true); } return; } const QRegularExpression filterRegExp(filter.simplified().replace(QChar(' '), QLatin1String(".*")) .append(QLatin1String(".*")).prepend(QLatin1String(".*")), QRegularExpression::CaseInsensitiveOption); for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* parentItem = ui->treeWidget->topLevelItem(i); int visibleChildCount = 0; for (int j = 0; j < parentItem->childCount(); ++j) { TabItem* childItem = static_cast<TabItem*>(parentItem->child(j)); if (!childItem) { continue; } if (childItem->text(0).contains(filterRegExp) || childItem->webTab()->url().toString().simplified().contains(filterRegExp)) { ++visibleChildCount; childItem->setHidden(false); } else { childItem->setHidden(true); } } if (visibleChildCount == 0) { parentItem->setHidden(true); } else { parentItem->setHidden(false); parentItem->setExpanded(true); } } } } void TabManagerWidget::filterBarClosed() { ui->filterBar->clear(); ui->filterBar->hide(); ui->treeWidget->setFocusProxy(0); ui->treeWidget->setFocus(); } bool TabManagerWidget::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); const QString text = keyEvent->text().simplified(); if (obj == ui->treeWidget) { // switch to tab/window on enter if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { onItemActivated(ui->treeWidget->currentItem(), 0); return QObject::eventFilter(obj, event); } if (!text.isEmpty() || ((keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() == Qt::Key_F)) { ui->filterBar->show(); ui->treeWidget->setFocusProxy(ui->filterBar); ui->filterBar->setFocus(); if (!text.isEmpty() && text.at(0).isPrint()) { ui->filterBar->setText(ui->filterBar->text() + text); } return true; } } else if (obj == ui->filterBar) { bool isNavigationOrActionKey = keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || keyEvent->key() == Qt::Key_PageDown || keyEvent->key() == Qt::Key_PageUp || keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return; // send scroll or action press key to treeWidget if (isNavigationOrActionKey) { QKeyEvent ev(QKeyEvent::KeyPress, keyEvent->key(), keyEvent->modifiers()); QApplication::sendEvent(ui->treeWidget, &ev); return false; } } } if (obj == ui->treeWidget && (event->type() == QEvent::Resize || event->type() == QEvent::Show)) ui->treeWidget->setColumnHidden(1, ui->treeWidget->viewport()->width() < 150); return QObject::eventFilter(obj, event); } void TabManagerWidget::processActions() { if (!sender()) { return; } m_refreshBlocked = true; QHash<BrowserWindow*, WebTab*> selectedTabs; const QString &command = sender()->objectName(); for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i); if (winItem->checkState(0) == Qt::Unchecked) { continue; } for (int j = 0; j < winItem->childCount(); ++j) { TabItem* tabItem = static_cast<TabItem*>(winItem->child(j)); if (!tabItem || tabItem->checkState(0) == Qt::Unchecked) { continue; } BrowserWindow* mainWindow = tabItem->window(); WebTab* webTab = tabItem->webTab(); // current supported actions are not applied to pinned tabs if (webTab->isPinned()) { tabItem->setCheckState(0, Qt::Unchecked); continue; } selectedTabs.insertMulti(mainWindow, webTab); } winItem->setCheckState(0, Qt::Unchecked); } if (!selectedTabs.isEmpty()) { if (command == "closeSelection") { closeSelectedTabs(selectedTabs); } else if (command == "detachSelection") { detachSelectedTabs(selectedTabs); } else if (command == "bookmarkSelection") { bookmarkSelectedTabs(selectedTabs); } else if (command == "unloadSelection") { unloadSelectedTabs(selectedTabs); } } m_refreshBlocked = false; delayedRefreshTree(); } void TabManagerWidget::changeGroupType() { QAction* action = qobject_cast<QAction*>(sender()); if (action) { int type = action->data().toInt(); if (m_groupType != GroupType(type)) { m_groupType = GroupType(type); delayedRefreshTree(); emit groupTypeChanged(m_groupType); } } } void TabManagerWidget::closeSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash) { if (tabsHash.isEmpty()) { return; } const QList<BrowserWindow*> &windows = tabsHash.uniqueKeys(); foreach (BrowserWindow* mainWindow, windows) { QList<WebTab*> tabs = tabsHash.values(mainWindow); foreach (WebTab* webTab, tabs) { mainWindow->tabWidget()->requestCloseTab(webTab->tabIndex()); } } } static void detachTabsTo(BrowserWindow* targetWindow, const QHash<BrowserWindow*, WebTab*> &tabsHash) { const QList<BrowserWindow*> &windows = tabsHash.uniqueKeys(); foreach (BrowserWindow* mainWindow, windows) { const QList<WebTab*> &tabs = tabsHash.values(mainWindow); foreach (WebTab* webTab, tabs) { mainWindow->tabWidget()->detachTab(webTab); if (mainWindow && mainWindow->tabCount() == 0) { mainWindow->close(); mainWindow = 0; } targetWindow->tabWidget()->addView(webTab, Qz::NT_NotSelectedTab); } } } void TabManagerWidget::detachSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash) { if (tabsHash.isEmpty() || (tabsHash.uniqueKeys().size() == 1 && tabsHash.size() == tabsHash.keys().at(0)->tabCount())) { return; } BrowserWindow* newWindow = mApp->createWindow(Qz::BW_OtherRestoredWindow); newWindow->move(mApp->desktop()->availableGeometry(this).topLeft() + QPoint(30, 30)); detachTabsTo(newWindow, tabsHash); } bool TabManagerWidget::bookmarkSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash) { QDialog* dialog = new QDialog(getQupZilla(), Qt::WindowStaysOnTopHint | Qt::MSWindowsFixedSizeDialogHint); QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, dialog); QLabel* label = new QLabel(dialog); BookmarksFoldersButton* folderButton = new BookmarksFoldersButton(dialog); QDialogButtonBox* box = new QDialogButtonBox(dialog); box->addButton(QDialogButtonBox::Ok); box->addButton(QDialogButtonBox::Cancel); QObject::connect(box, SIGNAL(rejected()), dialog, SLOT(reject())); QObject::connect(box, SIGNAL(accepted()), dialog, SLOT(accept())); layout->addWidget(label); layout->addWidget(folderButton); layout->addWidget(box); label->setText(tr("Choose folder for bookmarks:")); dialog->setWindowTitle(tr("Bookmark Selected Tabs")); QSize size = dialog->size(); size.setWidth(350); dialog->resize(size); dialog->exec(); if (dialog->result() == QDialog::Rejected) { return false; } foreach (WebTab* tab, tabsHash) { if (!tab->url().isEmpty()) { BookmarkItem* bookmark = new BookmarkItem(BookmarkItem::Url); bookmark->setTitle(tab->title()); bookmark->setUrl(tab->url()); mApp->bookmarks()->addBookmark(folderButton->selectedFolder(), bookmark); } } delete dialog; return true; } void TabManagerWidget::unloadSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash) { if (tabsHash.isEmpty()) { return; } const QList<BrowserWindow*> &windows = tabsHash.uniqueKeys(); foreach (BrowserWindow* mainWindow, windows) { QList<WebTab*> tabs = tabsHash.values(mainWindow); foreach (WebTab* webTab, tabs) { mainWindow->tabWidget()->unloadTab(webTab->tabIndex()); } } } QTreeWidgetItem* TabManagerWidget::groupByDomainName(bool useHostName) { QTreeWidgetItem* currentTabItem = nullptr; QList<BrowserWindow*> windows = mApp->windows(); int currentWindowIdx = windows.indexOf(getQupZilla()); if (currentWindowIdx == -1) { // getQupZilla() instance is closing return nullptr; } QMap<QString, QTreeWidgetItem*> tabsGroupedByDomain; for (int win = 0; win < windows.count(); ++win) { BrowserWindow* mainWin = windows.at(win); QList<WebTab*> tabs = mainWin->tabWidget()->allTabs(); for (int tab = 0; tab < tabs.count(); ++tab) { WebTab* webTab = tabs.at(tab); if (webTab->webView() && m_webPage == webTab->webView()->page()) { m_webPage = 0; continue; } QString domain = domainFromUrl(webTab->url(), useHostName); if (!tabsGroupedByDomain.contains(domain)) { TabItem* groupItem = new TabItem(ui->treeWidget, false, false, 0, false); groupItem->setTitle(domain); groupItem->setIsActiveOrCaption(true); tabsGroupedByDomain.insert(domain, groupItem); } QTreeWidgetItem* groupItem = tabsGroupedByDomain.value(domain); TabItem* tabItem = new TabItem(ui->treeWidget, false, true, groupItem); tabItem->setBrowserWindow(mainWin); tabItem->setWebTab(webTab); if (webTab == mainWin->weView()->webTab()) { tabItem->setIsActiveOrCaption(true); if (mainWin == getQupZilla()) currentTabItem = tabItem; } tabItem->updateIcon(); tabItem->setTitle(webTab->title()); } } ui->treeWidget->insertTopLevelItems(0, tabsGroupedByDomain.values()); return currentTabItem; } QTreeWidgetItem* TabManagerWidget::groupByWindow() { QTreeWidgetItem* currentTabItem = nullptr; QList<BrowserWindow*> windows = mApp->windows(); int currentWindowIdx = windows.indexOf(getQupZilla()); if (currentWindowIdx == -1) { return nullptr; } m_isRefreshing = true; if (!m_isDefaultWidget) { windows.move(currentWindowIdx, 0); currentWindowIdx = 0; } for (int win = 0; win < windows.count(); ++win) { BrowserWindow* mainWin = windows.at(win); TabItem* winItem = new TabItem(ui->treeWidget, true, false); winItem->setBrowserWindow(mainWin); winItem->setText(0, tr("Window %1").arg(QString::number(win + 1))); winItem->setToolTip(0, tr("Double click to switch")); winItem->setIsActiveOrCaption(win == currentWindowIdx); QList<WebTab*> tabs = mainWin->tabWidget()->allTabs(); for (int tab = 0; tab < tabs.count(); ++tab) { WebTab* webTab = tabs.at(tab); if (webTab->webView() && m_webPage == webTab->webView()->page()) { m_webPage = 0; continue; } TabItem* tabItem = new TabItem(ui->treeWidget, true, true, winItem); tabItem->setBrowserWindow(mainWin); tabItem->setWebTab(webTab); if (webTab == mainWin->weView()->webTab()) { tabItem->setIsActiveOrCaption(true); if (mainWin == getQupZilla()) currentTabItem = tabItem; } tabItem->updateIcon(); tabItem->setTitle(webTab->title()); } } return currentTabItem; } BrowserWindow* TabManagerWidget::getQupZilla() { if (m_isDefaultWidget || !p_QupZilla) { return mApp->getWindow(); } else { return p_QupZilla.data(); } } TabItem::TabItem(QTreeWidget* treeWidget, bool supportDrag, bool isTab, QTreeWidgetItem* parent, bool addToTree) : QObject() , QTreeWidgetItem(addToTree ? (parent ? parent : treeWidget->invisibleRootItem()) : 0, 1) , m_treeWidget(treeWidget) , m_window(0) , m_webTab(0) , m_isTab(isTab) { Qt::ItemFlags flgs = flags() | (parent ? Qt::ItemIsUserCheckable : Qt::ItemIsUserCheckable | Qt::ItemIsTristate); if (supportDrag) { if (isTab) { flgs |= Qt::ItemIsDragEnabled | Qt::ItemNeverHasChildren; flgs &= ~Qt::ItemIsDropEnabled; } else { flgs |= Qt::ItemIsDropEnabled; flgs &= ~Qt::ItemIsDragEnabled; } } setFlags(flgs); setCheckState(0, Qt::Unchecked); } BrowserWindow* TabItem::window() const { return m_window; } void TabItem::setBrowserWindow(BrowserWindow* window) { m_window = window; } WebTab* TabItem::webTab() const { return m_webTab; } void TabItem::setWebTab(WebTab* webTab) { m_webTab = webTab; if (m_webTab->isRestored()) setIsActiveOrCaption(m_webTab->isCurrentTab()); else setIsSavedTab(true); connect(m_webTab->webView(), SIGNAL(titleChanged(QString)), this, SLOT(setTitle(QString))); connect(m_webTab->webView(), SIGNAL(iconChanged(QIcon)), this, SLOT(updateIcon())); auto pageChanged = [this](WebPage *page) { connect(page, &WebPage::audioMutedChanged, this, &TabItem::updateIcon); connect(page, &WebPage::loadFinished, this, &TabItem::updateIcon); connect(page, &WebPage::loadStarted, this, &TabItem::updateIcon); }; pageChanged(m_webTab->webView()->page()); connect(m_webTab->webView(), &WebView::pageChanged, this, pageChanged); } void TabItem::updateIcon() { if (!m_webTab) return; if (!m_webTab->isLoading()) { if (!m_webTab->isPinned()) { if (m_webTab->isMuted()) { setIcon(0, QIcon::fromTheme(QSL("audio-volume-muted"), QIcon(QSL(":icons/other/audiomuted.svg")))); } else if (!m_webTab->isMuted() && m_webTab->webView()->page()->recentlyAudible()) { setIcon(0, QIcon::fromTheme(QSL("audio-volume-high"), QIcon(QSL(":icons/other/audioplaying.svg")))); } else { setIcon(0, m_webTab->icon()); } } else { setIcon(0, QIcon(":tabmanager/data/tab-pinned.png")); } if (m_webTab->isRestored()) setIsActiveOrCaption(m_webTab->isCurrentTab()); else setIsSavedTab(true); } else { setIcon(0, QIcon(":tabmanager/data/tab-loading.png")); setIsActiveOrCaption(m_webTab->isCurrentTab()); } } void TabItem::setTitle(const QString &title) { setText(0, title); setToolTip(0, title); } void TabItem::setIsActiveOrCaption(bool yes) { setData(0, ActiveOrCaptionRole, yes ? QVariant(true) : QVariant()); setIsSavedTab(false); } void TabItem::setIsSavedTab(bool yes) { setData(0, SavedRole, yes ? QVariant(true) : QVariant()); } bool TabItem::isTab() const { return m_isTab; } TabTreeWidget::TabTreeWidget(QWidget *parent) : QTreeWidget(parent) { invisibleRootItem()->setFlags(invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled); } Qt::DropActions TabTreeWidget::supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } #define MIMETYPE QLatin1String("application/qupzilla.tabs") QStringList TabTreeWidget::mimeTypes() const { QStringList types; types.append(MIMETYPE); return types; } QMimeData *TabTreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const { QMimeData* mimeData = new QMimeData(); QByteArray encodedData; QDataStream stream(&encodedData, QIODevice::WriteOnly); if (items.size() > 0) { TabItem* tabItem = static_cast<TabItem*>(items.at(0)); if (!tabItem || !tabItem->isTab()) return 0; stream << (quintptr) tabItem->window() << (quintptr) tabItem->webTab(); mimeData->setData(MIMETYPE, encodedData); return mimeData; } return 0; } bool TabTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) { if (action == Qt::IgnoreAction) { return true; } TabItem* parentItem = static_cast<TabItem*>(parent); if (!data->hasFormat(MIMETYPE) || !parentItem) { return false; } Q_ASSERT(!parentItem->isTab()); BrowserWindow* targetWindow = parentItem->window(); QByteArray encodedData = data->data(MIMETYPE); QDataStream stream(&encodedData, QIODevice::ReadOnly); if (!stream.atEnd()) { quintptr webTabPtr; quintptr windowPtr; stream >> windowPtr >> webTabPtr; WebTab* webTab = (WebTab*) webTabPtr; BrowserWindow* window = (BrowserWindow*) windowPtr; if (window == targetWindow) { if (index > 0 && webTab->tabIndex() < index) --index; if (webTab->isPinned() && index >= targetWindow->tabWidget()->pinnedTabsCount()) index = targetWindow->tabWidget()->pinnedTabsCount() - 1; if (!webTab->isPinned() && index < targetWindow->tabWidget()->pinnedTabsCount()) index = targetWindow->tabWidget()->pinnedTabsCount(); if (index != webTab->tabIndex()) { targetWindow->tabWidget()->tabBar()->moveTab(webTab->tabIndex(), index); if (!webTab->isCurrentTab()) emit requestRefreshTree(); } else { return false; } } else if (!webTab->isPinned()) { QHash<BrowserWindow*, WebTab*> tabsHash; tabsHash.insert(window, webTab); detachTabsTo(targetWindow, tabsHash); if (index < targetWindow->tabWidget()->pinnedTabsCount()) index = targetWindow->tabWidget()->pinnedTabsCount(); targetWindow->tabWidget()->tabBar()->moveTab(webTab->tabIndex(), index); } } return true; } void TabTreeWidget::setEnableDragTabs(bool enable) { setDragEnabled(enable); setAcceptDrops(enable); viewport()->setAcceptDrops(enable); setDropIndicatorShown(enable); }
31.671795
165
0.60761
JamesMBallard
7af253211c133ff1d64a36449099be624c5d6939
314
cpp
C++
Sandbox/src/main.cpp
WhoseTheNerd/Fusion
35ab536388392b3ba2e14f288eecbc292abd7dea
[ "Apache-2.0" ]
4
2018-11-12T18:43:02.000Z
2020-02-02T10:18:56.000Z
Sandbox/src/main.cpp
WhoseTheNerd/Fusion
35ab536388392b3ba2e14f288eecbc292abd7dea
[ "Apache-2.0" ]
2
2018-12-22T13:18:05.000Z
2019-07-24T20:15:45.000Z
Sandbox/src/main.cpp
WhoseTheNerd/Fusion
35ab536388392b3ba2e14f288eecbc292abd7dea
[ "Apache-2.0" ]
null
null
null
#define F_MAIN_APP #include <Fusion.h> #include "SandboxLayer.h" class SandboxApp : public Fusion::Application { public: SandboxApp() { PushLayer(Fusion::CreateRef<Sandbox::SandboxLayer>()); } }; Fusion::Scope<Fusion::Application> Fusion::CreateApplication() { return Fusion::CreateScope<SandboxApp>(); }
16.526316
62
0.735669
WhoseTheNerd
7af62dc3a32990df3f3b89549c6273f24df6473e
2,614
cpp
C++
examples/fxflow/MainWindow.cpp
moiggi/nodeeditor
8b2ffcfaa934bc69ff9f52e27b4a24859431541d
[ "BSD-3-Clause" ]
null
null
null
examples/fxflow/MainWindow.cpp
moiggi/nodeeditor
8b2ffcfaa934bc69ff9f52e27b4a24859431541d
[ "BSD-3-Clause" ]
null
null
null
examples/fxflow/MainWindow.cpp
moiggi/nodeeditor
8b2ffcfaa934bc69ff9f52e27b4a24859431541d
[ "BSD-3-Clause" ]
null
null
null
#include "MainWindow.h" #include "ui_mainwindow.h" #include <nodes/Node> #include <nodes/NodeData> #include <nodes/FlowScene> #include <nodes/FlowView> #include <nodes/FlowViewStyle> #include <nodes/NodeStyle> #include <nodes/ConnectionStyle> #include <nodes/DataModelRegistry> #include <QApplication> #include <QScreen> #include <QFile> #include "ImageSourceDataModel.hpp" #include "ImageDisplayDataModel.hpp" #include "BlurEffectDataModel.hpp" #include "AlphaBlendEffectDataModel.hpp" using QtNodes::DataModelRegistry; using QtNodes::FlowScene; using QtNodes::FlowView; using QtNodes::Node; namespace { std::shared_ptr<DataModelRegistry> registerDataModels() { auto ret = std::make_shared<DataModelRegistry>(); ret->registerModel<ImageSourceDataModel>("Sources"); ret->registerModel<ImageDisplayDataModel>("Displays"); ret->registerModel<BlurEffectDataModel>("Effects"); ret->registerModel<AlphaBlendEffectDataModel>("Effects"); return ret; } void setStyle() { QFile file(":Style.json"); if (!file.open(QIODevice::ReadOnly)) { qWarning() << "Couldn't open Style.json"; return; } QString style = file.readAll(); QtNodes::FlowViewStyle::setStyle(style); QtNodes::NodeStyle::setNodeStyle(style); QtNodes::ConnectionStyle::setConnectionStyle(style); } } //namespace MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ::setStyle(); auto scene = new FlowScene(registerDataModels(), this); ui->effectNodeView->setScene(scene); connect(scene, &FlowScene::nodeContextMenu, this, [](Node& n, const QPointF& pos) { qInfo() << "context menu of node: " << n.nodeDataModel()->name() << " @ " << pos; }); connect(scene, &FlowScene::focusNodeChanged, this, [](Node* newFocus, Node* oldFocus) { qInfo() << "node focus changed: from" << (oldFocus ? oldFocus->nodeDataModel()->name() : "null") << " to " << (newFocus ? newFocus->nodeDataModel()->name() : "null"); }); connect(scene, &FlowScene::selectedNodeChanged, this, [](std::vector<Node*> nodes) { QString selected("selected nodes = "); for (auto* node : nodes) { selected += node->nodeDataModel()->name(); } qDebug() << selected; }); int screenHeight = QGuiApplication::primaryScreen()->size().height(); ui->imageNodeViewSplitter->setSizes({screenHeight*2/3, screenHeight*1/3}); int screenWidth = QGuiApplication::primaryScreen()->size().width(); ui->effectUISplitter->setSizes({screenWidth*3/4, screenWidth*1/4}); setWindowTitle("FxFlow"); } MainWindow::~MainWindow() { delete ui; }
27.515789
89
0.700459
moiggi
7afd0beb6eb7291d3d2590691599def05b06cecb
474
hpp
C++
src/window_create_info.hpp
zfccxt/calcium
9cc3a00904c05e675bdb5d35eef0f5356796e564
[ "MIT" ]
null
null
null
src/window_create_info.hpp
zfccxt/calcium
9cc3a00904c05e675bdb5d35eef0f5356796e564
[ "MIT" ]
null
null
null
src/window_create_info.hpp
zfccxt/calcium
9cc3a00904c05e675bdb5d35eef0f5356796e564
[ "MIT" ]
null
null
null
#pragma once #include <cstddef> #include <string> #include "colour.hpp" #include "winding_order.hpp" namespace cl { struct WindowCreateInfo { size_t width = 1280; size_t height = 720; std::string title; bool center = true; bool enable_backface_cull = true; WindingOrder front_face = WindingOrder::kClockwise; bool enable_depth_test = true; // TODO: fully implement this bool enable_resize = true; bool enable_vsync = true; Colour clear_colour; }; }
18.96
62
0.727848
zfccxt
bb01ef490444042e217f29370106795b930b3207
868
cpp
C++
02_Estructuras y Archivos/Ejercicios/E13_Archivos05.cpp
vazeri/Programacion-Orientada-a-Objetos
57d1dc413956e50d31f34c0bb339b32a176f9616
[ "MIT" ]
null
null
null
02_Estructuras y Archivos/Ejercicios/E13_Archivos05.cpp
vazeri/Programacion-Orientada-a-Objetos
57d1dc413956e50d31f34c0bb339b32a176f9616
[ "MIT" ]
null
null
null
02_Estructuras y Archivos/Ejercicios/E13_Archivos05.cpp
vazeri/Programacion-Orientada-a-Objetos
57d1dc413956e50d31f34c0bb339b32a176f9616
[ "MIT" ]
null
null
null
//Hacer un programa que cuente el numero de palabras que contiene un archivo de texto #include <fstream> #include <ctype.h> #include <string> #include <iostream> #include<exception> using namespace std; int main() { ifstream X1; ifstream X2; char b,c,ban; X1.open("A.txt"); X2.open("B.txt"); if (!X1 || !X2) { cout<<"No hay archivo"; exit(1); } if(X1.get(c)==X2.get(c)) X1.get(b); X2.get(c); while(X1.get(b) && X2.get(c)) { if(b==c) ban=1; else ban=0; } if (ban==1) cout<<"Los archivos son iguales"; else cout<<"Los archivos NO son iguales"; } /* cout<<"Los archivos son iguales"; else cout<<"No son iguales los archivos"; X1.close(); X2.close(); */ }}
20.186047
86
0.496544
vazeri
bb022f2a12dfa936473249ae2f6855d5e0b6816d
10,582
cpp
C++
tests/unittests/MemberTests.cpp
toddstrader/slang
77a31619e27dc25f6b29a53a5003e1781c6b3034
[ "MIT" ]
null
null
null
tests/unittests/MemberTests.cpp
toddstrader/slang
77a31619e27dc25f6b29a53a5003e1781c6b3034
[ "MIT" ]
null
null
null
tests/unittests/MemberTests.cpp
toddstrader/slang
77a31619e27dc25f6b29a53a5003e1781c6b3034
[ "MIT" ]
null
null
null
#include "Test.h" #include <nlohmann/json.hpp> TEST_CASE("Nets") { auto tree = SyntaxTree::fromText(R"( module Top; wire logic f = 1; endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; } TEST_CASE("Bad signed specifier") { auto tree = SyntaxTree::fromText(R"( module Top; bit signed; endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); auto& diags = compilation.getAllDiagnostics(); REQUIRE(diags.size() == 1); CHECK(diags[0].code == diag::ExpectedDeclarator); } TEST_CASE("Continuous Assignments") { auto tree = SyntaxTree::fromText(R"( module Top; wire foo; assign foo = 1, foo = 'z; logic bar; assign bar = 1; endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; } TEST_CASE("User defined nettypes") { auto tree1 = SyntaxTree::fromText(R"( module m; import p::*; typedef logic[10:0] stuff; nettype foo bar; nettype stuff baz; // test that enum members get hoisted here nettype enum { SDF = 42 } blah; foo a = 1; bar b = 2; baz c = 3; blah d = SDF; bar e[5]; endmodule )"); auto tree2 = SyntaxTree::fromText(R"( package p; nettype logic [3:0] foo; endpackage )"); Compilation compilation; compilation.addSyntaxTree(tree1); compilation.addSyntaxTree(tree2); NO_COMPILATION_ERRORS; auto& root = compilation.getRoot(); CHECK(root.lookupName<NetSymbol>("m.a").getType().toString() == "logic[3:0]"); CHECK(root.lookupName<NetSymbol>("m.b").netType.name == "bar"); CHECK(root.lookupName<NetSymbol>("m.b").netType.getAliasTarget()->name == "foo"); CHECK(root.lookupName<NetSymbol>("m.b").getType().toString() == "logic[3:0]"); CHECK(root.lookupName<NetSymbol>("m.c").getType().toString() == "logic[10:0]"); CHECK(root.lookupName<NetSymbol>("m.e").getType().toString() == "logic[3:0]$[0:4]"); } TEST_CASE("JSON dump") { auto tree = SyntaxTree::fromText(R"( interface I; modport m(input f); endinterface package p1; parameter int BLAH = 1; endpackage module Top; wire foo; assign foo = 1; (* foo, bar = 1 *) I array [3] (); always_comb begin end if (1) begin end for (genvar i = 0; i < 10; i++) begin end import p1::BLAH; import p1::*; logic f; I stuff(); Child child(.i(stuff), .f); function logic func(logic bar); endfunction endmodule module Child(I.m i, input logic f = 1); endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; // This basic test just makes sure that JSON dumping doesn't crash. json output = compilation.getRoot(); output.dump(); } TEST_CASE("Attributes") { auto tree = SyntaxTree::fromText(R"( module m; (* foo, bar = 1 *) (* baz = 1 + 2 * 3 *) wire foo, bar; (* blah *) n n1((* blah2 *) 0); (* blah3 *); function logic func; return 0; endfunction int j; always_comb begin : block (* blah4 *) func (* blah5 *) (); j = 3 + (* blah6 *) 4; end endmodule module n((* asdf *) input foo); endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; auto& root = compilation.getRoot(); auto attrs = compilation.getAttributes(*root.lookupName("m.bar")); REQUIRE(attrs.size() == 3); CHECK(attrs[0]->value.integer() == SVInt(1)); CHECK(attrs[1]->value.integer() == SVInt(1)); CHECK(attrs[2]->value.integer() == SVInt(7)); auto& n1 = root.lookupName<InstanceSymbol>("m.n1"); attrs = compilation.getAttributes(n1); REQUIRE(attrs.size() == 1); CHECK(attrs[0]->name == "blah"); auto ports = n1.membersOfType<PortSymbol>(); REQUIRE(ports.size() == 1); auto& fooPort = *ports.begin(); attrs = compilation.getAttributes(fooPort); REQUIRE(attrs.size() == 1); CHECK(attrs[0]->name == "asdf"); attrs = fooPort.getConnectionAttributes(); REQUIRE(attrs.size() == 1); CHECK(attrs[0]->name == "blah2"); auto& m = root.lookupName<InstanceSymbol>("m"); attrs = compilation.getAttributes(*m.membersOfType<EmptyMemberSymbol>().begin()); REQUIRE(attrs.size() == 1); CHECK(attrs[0]->name == "blah3"); auto& block = root.lookupName<SequentialBlockSymbol>("m.block"); auto stmtList = block.getBody().as<StatementList>().list; REQUIRE(stmtList.size() == 2); attrs = compilation.getAttributes(*stmtList[0]); REQUIRE(attrs.size() == 1); CHECK(attrs[0]->name == "blah4"); auto& call = stmtList[0]->as<ExpressionStatement>().expr.as<CallExpression>(); attrs = compilation.getAttributes(call); REQUIRE(attrs.size() == 1); CHECK(attrs[0]->name == "blah5"); auto& assign = stmtList[1]->as<ExpressionStatement>().expr.as<AssignmentExpression>(); attrs = compilation.getAttributes(assign.right().as<BinaryExpression>()); REQUIRE(attrs.size() == 1); CHECK(attrs[0]->name == "blah6"); } TEST_CASE("Attribute diagnostics") { auto tree = SyntaxTree::fromText(R"( module m; (* foo, foo = 2 *) wire foo; (* foo,, *) wire bar; (* foo = 1 + (* nested *) 3 *) wire baz; endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); auto& diags = compilation.getAllDiagnostics(); auto it = diags.begin(); CHECK((it++)->code == diag::DuplicateAttribute); CHECK((it++)->code == diag::ExpectedIdentifier); CHECK((it++)->code == diag::MisplacedTrailingSeparator); CHECK((it++)->code == diag::AttributesNotAllowed); CHECK(it == diags.end()); auto& root = compilation.getRoot(); auto attrs = compilation.getAttributes(*root.lookupName("m.foo")); REQUIRE(attrs.size() == 1); CHECK(attrs[0]->value.integer() == SVInt(2)); } TEST_CASE("Time units declarations") { auto tree = SyntaxTree::fromText(R"( timeunit 10us; module m; timeunit 10ns / 10ps; logic f; // Further decls ok as long as identical timeprecision 10ps; timeunit 10ns; timeunit 10ns / 10ps; endmodule module n; endmodule `timescale 100s / 10fs module o; endmodule package p; timeprecision 1ps; endpackage )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; CHECK(compilation.getDefinition("m")->getTimeScale() == TimeScale("10ns", "10ps")); CHECK(compilation.getDefinition("n")->getTimeScale() == TimeScale("10us", "1ns")); CHECK(compilation.getDefinition("o")->getTimeScale() == TimeScale("100s", "10fs")); CHECK(compilation.getPackage("p")->getTimeScale() == TimeScale("100s", "1ps")); } TEST_CASE("Time units error cases") { auto tree = SyntaxTree::fromText(R"( module m; timeunit; endmodule module n; logic f; timeunit 10ns; timeunit 100ns / 10ps; endmodule module o; timeunit 20ns; endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); auto& diags = compilation.getAllDiagnostics(); auto it = diags.begin(); CHECK((it++)->code == diag::ExpectedTimeLiteral); CHECK((it++)->code == diag::TimeScaleFirstInScope); CHECK((it++)->code == diag::MismatchedTimeScales); CHECK((it++)->code == diag::InvalidTimeScaleSpecifier); CHECK(it == diags.end()); } TEST_CASE("Port decl in ANSI module") { auto tree = SyntaxTree::fromText(R"( module m(input logic a); input b; endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); auto& diags = compilation.getAllDiagnostics(); auto it = diags.begin(); CHECK((it++)->code == diag::PortDeclInANSIModule); CHECK(it == diags.end()); } TEST_CASE("Type parameters") { auto tree = SyntaxTree::fromText(R"( module m #(parameter type foo_t = int, foo_t foo = 1) (); if (foo) begin parameter type asdf = shortint, basdf = logic; end endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; } TEST_CASE("Type parameters 2") { auto tree = SyntaxTree::fromText(R"( module m #(parameter type foo_t, foo_t foo = 1) (); if (foo) begin parameter type asdf = shortint, basdf = logic; end endmodule module top; m #(longint) m1(); endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; } TEST_CASE("Type parameters 3") { auto tree = SyntaxTree::fromText(R"( module m #(parameter type foo_t, foo_t foo = 1) (); if (foo) begin parameter type asdf = shortint, basdf = logic; end endmodule module top; typedef struct packed { logic l; } asdf; m #(.foo_t(asdf)) m1(); endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; } TEST_CASE("Type parameters 4") { auto tree = SyntaxTree::fromText(R"( module m; parameter int i = 0; localparam j = i; parameter type t = int; t t1 = 2; endmodule module top; m #(1, shortint) m1(); endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; } TEST_CASE("Type parameters -- bad replacement") { auto tree = SyntaxTree::fromText(R"( module m #(parameter type foo_t, foo_t foo = 1) (); if (foo) begin parameter type asdf = shortint, basdf = logic; end endmodule module top; typedef struct { logic l; } asdf; m #(asdf) m1(); endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); auto& diags = compilation.getAllDiagnostics(); REQUIRE(diags.size() == 1); CHECK(diags[0].code == diag::BadAssignment); } TEST_CASE("Type parameters unset -- ok") { auto tree = SyntaxTree::fromText(R"( module m #(parameter type foo_t = int, foo_t foo = 1) (); if (foo) begin parameter type asdf = shortint, basdf = logic; end endmodule module top; m #(.foo_t()) m1(); endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); NO_COMPILATION_ERRORS; } TEST_CASE("Type parameters unset -- bad") { auto tree = SyntaxTree::fromText(R"( module m #(parameter type foo_t, foo_t foo = 1) (); if (foo) begin parameter type asdf = shortint, basdf = logic; end endmodule module top; m #(.foo_t()) m1(); endmodule )"); Compilation compilation; compilation.addSyntaxTree(tree); auto& diags = compilation.getAllDiagnostics(); REQUIRE(diags.size() == 1); CHECK(diags[0].code == diag::ParamHasNoValue); }
23.359823
90
0.639104
toddstrader
bb0505d68e9fac69826312d8cb3365825004ca7e
655
cpp
C++
leetcode.com/0672 Bulb Switcher II/better.cpp
sky-bro/AC
29bfa3f13994612887e18065fa6e854b9a29633d
[ "MIT" ]
1
2020-08-20T11:02:49.000Z
2020-08-20T11:02:49.000Z
leetcode.com/0672 Bulb Switcher II/better.cpp
sky-bro/AC
29bfa3f13994612887e18065fa6e854b9a29633d
[ "MIT" ]
null
null
null
leetcode.com/0672 Bulb Switcher II/better.cpp
sky-bro/AC
29bfa3f13994612887e18065fa6e854b9a29633d
[ "MIT" ]
1
2022-01-01T23:23:13.000Z
2022-01-01T23:23:13.000Z
#include <iostream> #include <vector> #include "leetcode.hpp" using namespace std; // ref: Java O(1) // https://leetcode.com/problems/bulb-switcher-ii/discuss/107269/Java-O(1) class Solution { public: // n and m both fit in range [0, 1000]. int flipLights(int n, int m) { if (m == 0 || n == 0) return 1; if (n == 1) return 2; if (n == 2 && m == 1) return 3; if (n == 2) return 4; if (m == 1) return 4; if (m == 2) return 7; if (m >= 3) return 8; return 8; } }; int main(int argc, char const *argv[]) { int m, n; Solution s; while (cin >> n >> m) { cout << s.flipLights(n, m) << endl; } return 0; }
19.848485
74
0.549618
sky-bro
bb0d637f18c3a336bf1cf54c0fef06642aa8c44f
883
hpp
C++
include/async/logger_wostream.hpp
MadNiko/async
5f384380e8f4ec40ea78c277455ca5180559bd07
[ "BSD-3-Clause" ]
null
null
null
include/async/logger_wostream.hpp
MadNiko/async
5f384380e8f4ec40ea78c277455ca5180559bd07
[ "BSD-3-Clause" ]
null
null
null
include/async/logger_wostream.hpp
MadNiko/async
5f384380e8f4ec40ea78c277455ca5180559bd07
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include <iostream> #include <async\logger.hpp> namespace async { class ASYNC_LIB_API logger_wostream : public logger { public: logger_wostream(std::wostream& stream) noexcept; public: virtual void message(std::wstring_view text) noexcept override; virtual void exception(std::exception_ptr except, std::wstring_view failed_action) noexcept override; virtual void enter_to_scope(std::wstring_view scope_name) noexcept override; virtual void leave_scope(std::wstring_view scope_name) noexcept override; private: std::size_t print_head(); std::wostream& print_multiline(std::size_t head_size, std::wstring_view text); private: std::wostream& m_str_ref; }; } // namespace async #ifdef ASYNC_LIB_HEADERS_ONLY # include <async\logger_wostream_impl.hpp> #endif
19.195652
109
0.704417
MadNiko
bb0ec29179010ef2a7823eff6879e657180a9c07
2,453
cc
C++
src/kudu/ranger/mini_ranger-test.cc
bbhavsar/kudu
d23ee5d38ddc4317f431dd65df0c825c00cc968a
[ "Apache-2.0" ]
6
2020-05-12T02:18:48.000Z
2021-04-15T20:39:21.000Z
src/kudu/ranger/mini_ranger-test.cc
bbhavsar/kudu
d23ee5d38ddc4317f431dd65df0c825c00cc968a
[ "Apache-2.0" ]
16
2020-01-19T07:17:00.000Z
2020-06-10T09:43:55.000Z
src/kudu/ranger/mini_ranger-test.cc
bbhavsar/kudu
d23ee5d38ddc4317f431dd65df0c825c00cc968a
[ "Apache-2.0" ]
1
2020-03-13T09:59:08.000Z
2020-03-13T09:59:08.000Z
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. #include "kudu/ranger/mini_ranger.h" #include <string> #include <utility> #include <vector> #include <gtest/gtest.h> #include "kudu/ranger/ranger.pb.h" #include "kudu/util/curl_util.h" #include "kudu/util/path_util.h" #include "kudu/util/faststring.h" #include "kudu/util/test_macros.h" #include "kudu/util/test_util.h" using std::string; namespace kudu { namespace ranger { class MiniRangerTest : public KuduTest { public: MiniRangerTest() : ranger_("127.0.0.1") {} void SetUp() override { ASSERT_OK(ranger_.Start()); } protected: MiniRanger ranger_; }; TEST_F(MiniRangerTest, TestGrantPrivilege) { PolicyItem item; item.first.emplace_back("testuser"); item.second.emplace_back(ActionPB::ALTER); AuthorizationPolicy policy; policy.databases.emplace_back("foo"); policy.tables.emplace_back("bar"); policy.items.emplace_back(std::move(item)); ASSERT_OK(ranger_.AddPolicy(std::move(policy))); } TEST_F(MiniRangerTest, TestPersistence) { PolicyItem item; item.first.emplace_back("testuser"); item.second.emplace_back(ActionPB::ALTER); AuthorizationPolicy policy; policy.databases.emplace_back("foo"); policy.tables.emplace_back("bar"); policy.items.emplace_back(std::move(item)); ASSERT_OK(ranger_.AddPolicy(policy)); ASSERT_OK(ranger_.Stop()); ASSERT_OK(ranger_.Start()); EasyCurl curl; curl.set_auth(CurlAuthType::BASIC, "admin", "admin"); faststring result; ASSERT_OK(curl.FetchURL(JoinPathSegments(ranger_.admin_url(), "service/plugins/policies/count"), &result)); ASSERT_EQ("1", result.ToString()); } } // namespace ranger } // namespace kudu
27.875
98
0.732165
bbhavsar
bb1125c59766e0bb14088b0523e9a1eb251e83ea
4,993
cc
C++
cpp/demo/smtp_main_stub.cc
propaganda-gold/deeprev
0c6ccf83131a879ed858acdb0675e75ebf2f2d3d
[ "BSD-3-Clause" ]
null
null
null
cpp/demo/smtp_main_stub.cc
propaganda-gold/deeprev
0c6ccf83131a879ed858acdb0675e75ebf2f2d3d
[ "BSD-3-Clause" ]
2
2021-05-11T16:29:38.000Z
2022-01-22T12:28:49.000Z
cpp/demo/smtp_main_stub.cc
propaganda-gold/deeprev
0c6ccf83131a879ed858acdb0675e75ebf2f2d3d
[ "BSD-3-Clause" ]
null
null
null
/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at https://curl.haxx.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ***************************************************************************/ /* <DESC> * Send e-mail with SMTP * </DESC> */ #include <curl/curl.h> #include <stdio.h> #include <string.h> /* * For an SMTP example using the multi interface please see smtp-multi.c. */ /* The libcurl options want plain addresses, the viewable headers in the mail * can very well get a full name as well. */ #define FROM_ADDR "<sender@example.org>" #define TO_ADDR "<addressee@example.net>" #define CC_ADDR "<info@example.org>" #define FROM_MAIL "Sender Person " FROM_ADDR #define TO_MAIL "A Receiver " TO_ADDR #define CC_MAIL "John CC Smith " CC_ADDR static const char *payload_text[] = { "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n", "To: " TO_MAIL "\r\n", "From: " FROM_MAIL "\r\n", "Cc: " CC_MAIL "\r\n", "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "rfcpedant.example.org>\r\n", "Subject: SMTP example message\r\n", "\r\n", /* empty line to divide headers from body, see RFC5322 */ "The body of the message starts here.\r\n", "\r\n", "It could be a lot of lines, could be MIME encoded, whatever.\r\n", "Check RFC5322.\r\n", NULL}; struct upload_status { int lines_read; }; static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp) { struct upload_status *upload_ctx = (struct upload_status *)userp; const char *data; if ((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { return 0; } data = payload_text[upload_ctx->lines_read]; if (data) { size_t len = strlen(data); memcpy(ptr, data, len); upload_ctx->lines_read++; return len; } return 0; } int main(void) { CURL *curl; CURLcode res = CURLE_OK; struct curl_slist *recipients = NULL; struct upload_status upload_ctx; upload_ctx.lines_read = 0; curl = curl_easy_init(); if (curl) { /* This is the URL for your mailserver */ curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); /* Note that this option isn't strictly required, omitting it will result * in libcurl sending the MAIL FROM command with empty sender data. All * autoresponses should have an empty reverse-path, and should be directed * to the address in the reverse-path which triggered them. Otherwise, * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * details. */ curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM_ADDR); /* Add two recipients, in this particular case they correspond to the * To: and Cc: addressees in the header, but they could be any kind of * recipient. */ recipients = curl_slist_append(recipients, TO_ADDR); recipients = curl_slist_append(recipients, CC_ADDR); curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients); /* We're using a callback function to specify the payload (the headers and * body of the message). You could just use the CURLOPT_READDATA option to * specify a FILE pointer to read from. */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source); curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* Send the message */ res = curl_easy_perform(curl); /* Check for errors */ if (res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); /* Free the list of recipients */ curl_slist_free_all(recipients); /* curl won't send the QUIT command until you call cleanup, so you should * be able to re-use this connection for additional messages (setting * CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and calling * curl_easy_perform() again. It may not be a good idea to keep the * connection open for a very long time though (more than a few minutes * may result in the server timing out the connection), and you do want to * clean up in the end. */ curl_easy_cleanup(curl); } return (int)res; }
33.736486
78
0.631484
propaganda-gold
bb14e332faaecd5704fc153ba478726ab8fe1a1d
1,197
cpp
C++
Lab/Salazar_Uriel_Lab6/Employee.cpp
salazaru/Cpp_Programming_Objects
8cc1e7d4b96b31a1ff57f2296d025d14b032d1c7
[ "MIT" ]
1
2016-03-10T02:47:46.000Z
2016-03-10T02:47:46.000Z
Lab/Salazar_Uriel_Lab6/Employee.cpp
salazaru/Salazar_Uriel_CSC17A_32232
8cc1e7d4b96b31a1ff57f2296d025d14b032d1c7
[ "MIT" ]
null
null
null
Lab/Salazar_Uriel_Lab6/Employee.cpp
salazaru/Salazar_Uriel_CSC17A_32232
8cc1e7d4b96b31a1ff57f2296d025d14b032d1c7
[ "MIT" ]
null
null
null
#include <iostream> #include "Employee.h" #include "Date.h" using namespace std; Employee::Employee( const string &first, const string &last, const string &ssn, int month, int day, int year) : firstName(first), lastName(last), socialSecurityNumber(ssn), birthDate(month, day, year) { } void Employee::setFirstName(const string &first) { firstName = first; } string Employee::getFirstName() const { return firstName; } void Employee::setLastName(const string &last) { lastName = last; } string Employee::getLastName() const { return lastName; } void Employee::setSocialSecurityNumber(const string &ssn) { socialSecurityNumber = ssn; } string Employee::getSocialSecurityNumber() const { return socialSecurityNumber; } void Employee::setBirthDate(int month, int day, int year) { birthDate.setDate(month, day, year); } Date Employee::getBirthDate() const { return birthDate; } void Employee::print() const { cout << getFirstName() << ' ' << getLastName() << "\nsocial security number: " << getSocialSecurityNumber() << "\ndate of birth: " << getBirthDate(); }
19.95
70
0.651629
salazaru
bb189286b4a2582c860b5816aa9afaabd55ae43d
12,806
cpp
C++
src/age_emulator_gb/age_gb_memory.cpp
c-sp/AGE
054bc4c7c0fe703439b73575d56a23eb3700d695
[ "Apache-2.0" ]
2
2022-02-12T12:51:14.000Z
2022-02-13T19:14:36.000Z
src/age_emulator_gb/age_gb_memory.cpp
c-sp/AGE
054bc4c7c0fe703439b73575d56a23eb3700d695
[ "Apache-2.0" ]
4
2021-05-19T18:11:22.000Z
2021-09-27T18:17:26.000Z
src/age_emulator_gb/age_gb_memory.cpp
c-sp/AGE
054bc4c7c0fe703439b73575d56a23eb3700d695
[ "Apache-2.0" ]
null
null
null
// // Copyright 2020 Christoph Sprenger // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #include <algorithm> #include <age_debug.hpp> #include "age_gb_memory.hpp" namespace { constexpr age::uint16_t gb_cia_ofs_title = 0x0134; uint16_t mbc2_ram_address(uint16_t address) { uint16_t ram_offset = address - 0xA000; return 0xA000 + (ram_offset & 0x1FF); } bool is_cartridge_ram(uint16_t address) { return (address & 0xE000) == 0xA000; } } // namespace //--------------------------------------------------------- // // public methods // //--------------------------------------------------------- const age::uint8_t* age::gb_memory::get_video_ram() const { return &m_memory[m_video_ram_offset]; } const age::uint8_t* age::gb_memory::get_rom_header() const { return m_memory.data(); } std::string age::gb_memory::get_cartridge_title() const { const char* buffer = reinterpret_cast<const char*>(&m_memory[gb_cia_ofs_title]); std::string result = {buffer, 16}; return result; } age::uint8_vector age::gb_memory::get_persistent_ram() const { uint8_vector result; if (m_has_battery) { int cart_ram_size = m_num_cart_ram_banks * gb_cart_ram_bank_size; AGE_ASSERT(cart_ram_size > 0) result.resize(static_cast<unsigned>(cart_ram_size)); std::copy(begin(m_memory) + m_cart_ram_offset, begin(m_memory) + m_cart_ram_offset + cart_ram_size, begin(result)); } else { result = uint8_vector(); } return result; } void age::gb_memory::set_persistent_ram(const uint8_vector& source) { if (m_has_battery) { AGE_ASSERT(source.size() <= int_max) int source_size = static_cast<int>(source.size()); int cart_ram_size = m_num_cart_ram_banks * gb_cart_ram_bank_size; // copy persistent ram int bytes_to_copy = std::min(cart_ram_size, source_size); std::copy(begin(source), begin(source) + bytes_to_copy, begin(m_memory) + m_cart_ram_offset); // fill up with zeroes, if the source vector is smaller than the actual persistent ram if (cart_ram_size > source_size) { std::fill(begin(m_memory) + m_cart_ram_offset + source_size, begin(m_memory) + m_cart_ram_offset + cart_ram_size, 0); } } } age::uint8_t age::gb_memory::read_byte(uint16_t address) const { AGE_ASSERT(address < 0xFE00) // rom, video ram & work ram if (!is_cartridge_ram(address)) { return m_memory[get_offset(address)]; } // cartridge ram not readable if (!m_cart_ram_enabled) { log() << "read [" << log_hex16(address) << "] = 0xFF: cartridge RAM disabled"; return 0xFF; } // read MBC2 ram if (m_is_mbc2) { return m_memory[get_offset(mbc2_ram_address(address))] | 0xF0; } // read regular cartridge ram return m_memory[get_offset(address)]; } age::uint8_t age::gb_memory::read_svbk() const { return m_svbk; } age::uint8_t age::gb_memory::read_vbk() const { return m_vbk; } void age::gb_memory::write_byte(uint16_t address, uint8_t value) { AGE_ASSERT(address < 0xFE00) // access MBC if (address < 0x8000) { m_mbc_writer(*this, address, value); return; } // write video ram & work ram if (!is_cartridge_ram(address)) { m_memory[get_offset(address)] = value; return; } // cartridge ram not writable if (!m_cart_ram_enabled) { log() << "write [" << log_hex16(address) << "] = " << log_hex8(value) << " ignored: cartridge RAM disabled"; return; } // write MBC2 ram if (m_is_mbc2) { m_memory[get_offset(mbc2_ram_address(address))] = value | 0xF0; } // write regular cartridge ram m_memory[get_offset(address)] = value; } void age::gb_memory::write_svbk(uint8_t value) { m_svbk = value | 0xF8; int bank_id = value & 0x07; if (bank_id == 0) { bank_id = 1; } log() << "switch to SVBK bank " << bank_id; int offset = bank_id * gb_work_ram_bank_size; m_offsets[0xD] = m_work_ram_offset + offset - 0xD000; m_offsets[0xF] = m_work_ram_offset + offset - 0xF000; } void age::gb_memory::write_vbk(uint8_t value) { m_vbk = value | 0xFE; auto bank = m_vbk & 1; log() << "switch to VBK bank " << bank; auto offset = bank * gb_video_ram_bank_size; m_offsets[8] = m_video_ram_offset + offset - 0x8000; m_offsets[9] = m_offsets[8]; } //--------------------------------------------------------- // // private methods // //--------------------------------------------------------- unsigned age::gb_memory::get_offset(uint16_t address) const { auto offset = m_offsets[address >> 12]; offset += address; AGE_ASSERT(offset >= 0) AGE_ASSERT(static_cast<unsigned>(offset) < m_memory.size()) return static_cast<unsigned>(offset); } void age::gb_memory::set_ram_accessible(uint8_t value) { m_cart_ram_enabled = ((value & 0x0F) == 0x0A) && (m_num_cart_ram_banks > 0); log() << "enable cartridge ram = " << log_hex8(value) << " (cartridge ram " << (m_cart_ram_enabled ? "enabled" : "disabled") << ")"; } void age::gb_memory::set_rom_banks(int low_bank_id, int high_bank_id) { AGE_ASSERT(low_bank_id >= 0) AGE_ASSERT(high_bank_id >= 0) AGE_ASSERT(m_num_cart_rom_banks >= 0) low_bank_id &= m_num_cart_rom_banks - 1; high_bank_id &= m_num_cart_rom_banks - 1; m_offsets[0] = low_bank_id * gb_cart_rom_bank_size; m_offsets[1] = m_offsets[0]; m_offsets[2] = m_offsets[0]; m_offsets[3] = m_offsets[0]; m_offsets[4] = high_bank_id * gb_cart_rom_bank_size - 0x4000; m_offsets[5] = m_offsets[4]; m_offsets[6] = m_offsets[4]; m_offsets[7] = m_offsets[4]; log() << "switch to rom banks " << log_hex(low_bank_id) << " @ 0x0000-0x3FFF, " << log_hex(high_bank_id) << " @ 0x4000-0x7FFF"; } void age::gb_memory::set_ram_bank(int bank_id) { AGE_ASSERT(bank_id >= 0) bank_id &= m_num_cart_ram_banks - 1; m_offsets[0xA] = m_cart_ram_offset + bank_id * gb_cart_ram_bank_size - 0xA000; m_offsets[0xB] = m_offsets[0xA]; log() << "switch to ram bank " << log_hex(bank_id); } //--------------------------------------------------------- // // private methods: mbc // //--------------------------------------------------------- age::gb_memory::mbc_writer age::gb_memory::get_mbc_writer(gb_mbc_data& mbc, uint8_t mbc_type) { mbc_writer result; switch (mbc_type) { //case 0x00: //case 0x08: //case 0x09: default: return write_to_mbc_no_op; case 0x01: case 0x02: case 0x03: mbc = gb_mbc1_data{.m_bank1 = 1, .m_bank2 = 0, .m_mode1 = false}; return write_to_mbc1; case 0x05: case 0x06: return write_to_mbc2; case 0x0F: case 0x10: case 0x11: case 0x12: case 0x13: return write_to_mbc3; case 0x19: case 0x1A: case 0x1B: mbc = gb_mbc5_data{.m_2000 = 1, .m_3000 = 0}; return write_to_mbc5; case 0x1C: case 0x1D: case 0x1E: mbc = gb_mbc5_data{.m_2000 = 1, .m_3000 = 0}; return write_to_mbc5_rumble; } } void age::gb_memory::write_to_mbc_no_op(gb_memory& memory, uint16_t offset, uint8_t value) { AGE_UNUSED(memory); AGE_UNUSED(offset); AGE_UNUSED(value); memory.log() << "write to [" << log_hex16(offset) << "] = " << log_hex8(value) << " ignored: no MBC configured"; } void age::gb_memory::write_to_mbc1(gb_memory& memory, uint16_t offset, uint8_t value) { AGE_ASSERT(offset < 0x8000) // workaround for older STL implementations // (we actually want to use std::get<gb_mbc1_data> here ...) auto* p_mbc_data = std::get_if<gb_mbc1_data>(&memory.m_mbc_data); auto& mbc_data = *p_mbc_data; switch (offset & 0x6000) { case 0x0000: // (de)activate ram memory.set_ram_accessible(value); return; case 0x2000: // select rom bank (lower 5 bits) mbc_data.m_bank1 = ((value & 0x1F) == 0) ? value + 1 : value; break; case 0x4000: // select rom/ram bank mbc_data.m_bank2 = value; break; case 0x6000: // select MBC1 mode: // - mode 0: bank2 affects 0x4000-0x7FFF // - mode 1: bank2 affects 0x0000-0x7FFF, 0xA000-0xBFFF mbc_data.m_mode1 = (value & 0x01) > 0; break; } // // verified by mooneye-gb tests // // - The value written to 0x4000 is used for rom bank switching // independent of the MBC1 mode. // - With MBC1 mode 1 the value written to 0x4000 switches the // rom bank at 0x0000. // // emulator-only/mbc1/rom_8Mb // emulator-only/mbc1/rom_16Mb // int mbc_high_bits = mbc_data.m_bank2 & 0x03; int high_rom_bits = mbc_high_bits << (memory.m_mbc1_multi_cart ? 4 : 5); int low_rom_bank_id = mbc_data.m_mode1 ? high_rom_bits : 0; int high_rom_bank_id = high_rom_bits + (mbc_data.m_bank1 & (memory.m_mbc1_multi_cart ? 0x0FU : 0x1FU)); int ram_bank_id = mbc_data.m_mode1 ? mbc_high_bits : 0; // set rom & ram banks AGE_ASSERT(memory.m_mbc1_multi_cart || ((high_rom_bank_id & 0x1F) > 0)) memory.set_rom_banks(low_rom_bank_id, high_rom_bank_id); memory.set_ram_bank(ram_bank_id); } void age::gb_memory::write_to_mbc2(gb_memory& memory, uint16_t offset, uint8_t value) { AGE_ASSERT(offset < 0x8000) // writes to $4000-$7FFF have no effect if (offset >= 0x4000) { return; } // (de)activate ram if ((offset & 0x100) == 0) { memory.set_ram_accessible(value); } // switch rom bank else { int rom_bank_id = value & 0x0F; memory.set_rom_banks(0, (rom_bank_id == 0) ? 1 : rom_bank_id); } } void age::gb_memory::write_to_mbc3(gb_memory& memory, uint16_t offset, uint8_t value) { AGE_ASSERT(offset < 0x8000) switch (offset & 0x6000) { case 0x0000: // (de)activate ram memory.set_ram_accessible(value); break; case 0x2000: { // select rom bank int rom_bank_id = value & 0x7F; if (rom_bank_id == 0) { rom_bank_id = 1; } memory.set_rom_banks(0, rom_bank_id); break; } case 0x4000: // select ram bank memory.set_ram_bank(value & 0x03); break; case 0x6000: // latch real time clock break; } } void age::gb_memory::write_to_mbc5(gb_memory& memory, uint16_t offset, uint8_t value) { AGE_ASSERT(offset < 0x8000) // workaround for older STL implementations // (we actually want to use std::get<gb_mbc1_data> here ...) auto* p_mbc_data = std::get_if<gb_mbc5_data>(&memory.m_mbc_data); auto& mbc_data = *p_mbc_data; switch (offset & 0x6000) { case 0x0000: // (de)activate ram memory.set_ram_accessible(value); break; case 0x2000: // select rom bank (lower 5 bits) if ((offset & 0x1000) == 0) { mbc_data.m_2000 = value; } else { mbc_data.m_3000 = value; } memory.set_rom_banks(0, ((mbc_data.m_3000 & 0x01) << 8) + mbc_data.m_2000); break; case 0x4000: // select ram bank memory.set_ram_bank(value & 0x0F); break; } } void age::gb_memory::write_to_mbc5_rumble(gb_memory& memory, uint16_t offset, uint8_t value) { AGE_ASSERT(offset < 0x8000) // clear rumble motor bit if ((offset & 0x6000) == 0x4000) { value &= 0x07; } // behave like MBC5 write_to_mbc5(memory, offset, value); }
24.914397
116
0.586366
c-sp
bb1b23b8f30083780e16d50e4733816ad1054831
2,375
cpp
C++
avrdude/libftd2xx0.4.16_x86_64/libusb-0.1.12/tests/descriptor_test.cpp
makagucci/cARM
fc4311125cd60f875c9e56735f0df6ff4407c7c9
[ "Beerware" ]
10
2017-01-20T05:16:03.000Z
2017-01-20T05:16:18.000Z
avrdude/libftd2xx0.4.16_x86_64/libusb-0.1.12/tests/descriptor_test.cpp
makagucci/cARM
fc4311125cd60f875c9e56735f0df6ff4407c7c9
[ "Beerware" ]
null
null
null
avrdude/libftd2xx0.4.16_x86_64/libusb-0.1.12/tests/descriptor_test.cpp
makagucci/cARM
fc4311125cd60f875c9e56735f0df6ff4407c7c9
[ "Beerware" ]
null
null
null
// -*- C++;indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*- /* * descriptor_test.cpp * * Test suite program for C++ bindings */ #include <iostream> #include <iomanip> #include "usbpp.h" using namespace std; int main(void) { USB::Busses buslist; cout << "bus/device idVendor/idProduct" << endl; // buslist.init(); USB::Bus *bus; list<USB::Bus *>::const_iterator biter; USB::Device *device; list<USB::Device *>::const_iterator diter; int i, j, k, l; for (biter = buslist.begin(); biter != buslist.end(); biter++) { bus = *biter; for (diter = bus->begin(); diter != bus->end(); diter++) { device = *diter; cout << bus->directoryName() << "/" << device->fileName() << " " << ios::uppercase << hex << setw(4) << setfill('0') << device->idVendor() << "/" << ios::uppercase << hex << setw(4) << setfill('0') << device->idProduct() << endl; if (device->Vendor() != "") { cout << "- Manufacturer : " << device->Vendor() << endl; } else { cout << "- Unable to fetch manufacturer string" << endl; } if (device->Product() != "") { cout << "- Product : " << device->Product() << endl; } else { cout << "- Unable to fetch product string" << endl; } if (device->SerialNumber() != "") { cout << "- Serial Number: " << device->SerialNumber() << endl; } USB::Configuration *this_Configuration; this_Configuration = device->firstConfiguration(); for (i=0; i < device->numConfigurations(); i++) { this_Configuration->dumpDescriptor(); USB::Interface *this_Interface; this_Interface = this_Configuration->firstInterface(); for (j=0; j < this_Configuration->numInterfaces(); j++) { USB::AltSetting *this_AltSetting; this_AltSetting = this_Interface->firstAltSetting(); for (k=0; k < this_Interface->numAltSettings(); k++) { this_AltSetting->dumpDescriptor(); USB::Endpoint *this_Endpoint; this_Endpoint = this_AltSetting->firstEndpoint(); for (l=0; l < this_AltSetting->numEndpoints(); l++) { this_Endpoint->dumpDescriptor(); this_Endpoint = this_AltSetting->nextEndpoint(); } this_AltSetting = this_Interface->nextAltSetting(); } this_Interface = this_Configuration->nextInterface(); } this_Configuration = device->nextConfiguration(); } } } return 0; }
28.614458
68
0.604211
makagucci
bb1c1c7b2f5a9987397bfbf8bf87c2f1b99d4c2f
3,120
cpp
C++
dep/include/yse/JuceLibraryCode/examples/Demo/Source/Demos/CodeEditorDemo.cpp
ChrSacher/MyEngine
8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8
[ "Apache-2.0" ]
2
2015-10-27T21:36:59.000Z
2017-03-17T21:52:19.000Z
dep/include/yse/JuceLibraryCode/examples/Demo/Source/Demos/CodeEditorDemo.cpp
ChrSacher/MyEngine
8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8
[ "Apache-2.0" ]
null
null
null
dep/include/yse/JuceLibraryCode/examples/Demo/Source/Demos/CodeEditorDemo.cpp
ChrSacher/MyEngine
8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8
[ "Apache-2.0" ]
null
null
null
/* ============================================================================== This file is part of the JUCE library. Copyright (c) 2015 - ROLI Ltd. Permission is granted to use this software under the terms of either: a) the GPL v2 (or any later version) b) the Affero GPL v3 Details of these licenses can be found at: www.gnu.org/licenses JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.juce.com for more information. ============================================================================== */ #include "../JuceDemoHeader.h" //============================================================================== class CodeEditorDemo : public Component, private FilenameComponentListener { public: CodeEditorDemo() : fileChooser ("File", File::nonexistent, true, false, false, "*.cpp;*.h;*.hpp;*.c;*.mm;*.m", String(), "Choose a C++ file to open it in the editor") { setOpaque (true); // Create the editor.. addAndMakeVisible (editor = new CodeEditorComponent (codeDocument, &cppTokeniser)); editor->loadContent ("\n" "/* Code editor demo!\n" "\n" " To see a real-world example of the code editor\n" " in action, try the Introjucer!\n" "\n" "*/\n" "\n"); // Create a file chooser control to load files into it.. addAndMakeVisible (fileChooser); fileChooser.addListener (this); } ~CodeEditorDemo() { fileChooser.removeListener (this); } void paint (Graphics& g) override { g.fillAll (Colours::lightgrey); } void resized() override { Rectangle<int> r (getLocalBounds().reduced (8)); fileChooser.setBounds (r.removeFromTop (25)); editor->setBounds (r.withTrimmedTop (8)); } private: // this is the document that the editor component is showing CodeDocument codeDocument; // this is a tokeniser to apply the C++ syntax highlighting CPlusPlusCodeTokeniser cppTokeniser; // the editor component ScopedPointer<CodeEditorComponent> editor; FilenameComponent fileChooser; void filenameComponentChanged (FilenameComponent*) override { editor->loadContent (fileChooser.getCurrentFile().loadFileAsString()); } JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CodeEditorDemo) }; // This static object will register this demo type in a global list of demos.. static JuceDemoType<CodeEditorDemo> demo ("10 Components: Code Editor");
31.836735
91
0.552885
ChrSacher
bb1e983ca949afa38e38b5e676b6c020cc774aec
6,504
cpp
C++
Sail/src/Sail/graphics/shader/basic/SimpleTextureShader.cpp
h3nx/Sail
96c13ee50bf9666c01bb8bb263e0c2dc3ba0eff9
[ "MIT" ]
null
null
null
Sail/src/Sail/graphics/shader/basic/SimpleTextureShader.cpp
h3nx/Sail
96c13ee50bf9666c01bb8bb263e0c2dc3ba0eff9
[ "MIT" ]
null
null
null
Sail/src/Sail/graphics/shader/basic/SimpleTextureShader.cpp
h3nx/Sail
96c13ee50bf9666c01bb8bb263e0c2dc3ba0eff9
[ "MIT" ]
null
null
null
#include "SimpleTextureShader.h" using namespace DirectX::SimpleMath; D3D11_INPUT_ELEMENT_DESC SimpleTextureShader::IED[2] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; SimpleTextureShader::SimpleTextureShader() { ModelDataBuffer defaultBuffer = { Vector4::One, Matrix::Identity, Matrix::Identity }; m_transformBuffer = std::unique_ptr<ShaderComponent::ConstantBuffer>(new ShaderComponent::ConstantBuffer(&defaultBuffer, sizeof(ModelDataBuffer))); m_sampler = std::make_unique<ShaderComponent::Sampler>(); ClippingPlaneBuffer defaultClippingBuffer = { Vector4(0.f, 0.f, 0.f, 0.f) }; m_clippingPlaneBuffer = std::unique_ptr<ShaderComponent::ConstantBuffer>(new ShaderComponent::ConstantBuffer(&defaultClippingBuffer, sizeof(ClippingPlaneBuffer))); // Compile shader and add to this shaderSet auto vsBlob = compileShader(L"SimpleTextureShader.hlsl", "VSMain", "vs_5_0"); setVertexShader(vsBlob); // Compile shader and add to this shaderSet auto psBlob = compileShader(L"SimpleTextureShader.hlsl", "PSMain", "ps_5_0"); setPixelShader(psBlob); // Create the inputlayout Application::getInstance()->getDXManager()->getDevice()->CreateInputLayout(IED, 2, vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), &m_inputLayout); // Done with the blobs, release them Memory::safeRelease(vsBlob); Memory::safeRelease(psBlob); } SimpleTextureShader::~SimpleTextureShader() { Memory::safeRelease(m_inputLayout); } void SimpleTextureShader::updateCamera(Camera& cam) { m_vpMatrix = cam.getViewProjection(); } void SimpleTextureShader::updateBuffer(const DirectX::SimpleMath::Vector4& color, const DirectX::SimpleMath::Matrix& w, const DirectX::SimpleMath::Matrix& vp) const { ModelDataBuffer data = { color, w.Transpose(), vp.Transpose() }; m_transformBuffer->updateData(&data, sizeof(data)); } void SimpleTextureShader::setClippingPlane(const DirectX::SimpleMath::Vector4& clippingPlane) { ClippingPlaneBuffer data = { clippingPlane }; m_clippingPlaneBuffer->updateData(&data, sizeof(data)); } void SimpleTextureShader::bind() { ShaderSet::bind(); // Set input layout as active Application::getInstance()->getDXManager()->getDeviceContext()->IASetInputLayout(m_inputLayout); // Bind the transform constant buffer m_transformBuffer->bind(ShaderComponent::VS, 0); // Bind clipping plane buffer m_clippingPlaneBuffer->bind(ShaderComponent::VS, 1); // Bind sampler m_sampler->bind(); } void SimpleTextureShader::createBufferFromModelData(ID3D11Buffer** vertexBuffer, ID3D11Buffer** indexBuffer, ID3D11Buffer** instanceBuffer, const void* data) { Model::Data modelData = *(Model::Data*)data; if (modelData.numVertices <= 0 || !modelData.positions) Logger::Error("numVertices or position data not set for model"); if (!modelData.texCoords) { Logger::Warning("Texture coordinates not set for model that will render with a texture shader"); } // Create the vertex array that this shader uses SimpleTextureShader::Vertex* vertices = new SimpleTextureShader::Vertex[modelData.numVertices]; for (UINT i = 0; i < modelData.numVertices; i++) { vertices[i].position = modelData.positions[i]; if (modelData.texCoords) vertices[i].texCoord = modelData.texCoords[i]; else vertices[i].texCoord = Vector2(0.f, 0.f); } D3D11_BUFFER_DESC vbd; ZeroMemory(&vbd, sizeof(vbd)); vbd.Usage = D3D11_USAGE_IMMUTABLE; vbd.ByteWidth = modelData.numVertices * sizeof(SimpleTextureShader::Vertex); vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER; vbd.CPUAccessFlags = 0; D3D11_SUBRESOURCE_DATA vertexData; ZeroMemory(&vertexData, sizeof(vertexData)); vertexData.pSysMem = vertices; // Create the vertex buffer ThrowIfFailed(Application::getInstance()->getDXManager()->getDevice()->CreateBuffer(&vbd, &vertexData, vertexBuffer)); // Delete vertices from cpu memory Memory::safeDeleteArr(vertices); // Set up index buffer if indices are set if (modelData.numIndices > 0) { ULONG* indices = new ULONG[modelData.numIndices]; // Fill the array with the model indices for (UINT i = 0; i < modelData.numIndices; i++) { indices[i] = modelData.indices[i]; } // Set up index buffer description D3D11_BUFFER_DESC ibd; ZeroMemory(&ibd, sizeof(ibd)); ibd.Usage = D3D11_USAGE_IMMUTABLE; ibd.ByteWidth = modelData.numIndices * sizeof(UINT); ibd.BindFlags = D3D11_BIND_INDEX_BUFFER; ibd.CPUAccessFlags = 0; D3D11_SUBRESOURCE_DATA indexData; ZeroMemory(&indexData, sizeof(indexData)); indexData.pSysMem = indices; // Create the index buffer ThrowIfFailed(Application::getInstance()->getDXManager()->getDevice()->CreateBuffer(&ibd, &indexData, indexBuffer)); // Delete indices from cpu memory Memory::safeDeleteArr(indices); } } void SimpleTextureShader::draw(Model& model, bool bindFirst) { // TODO: remove //if (bindFirst) { // // Bind the shaders // // Bind the input layout // // bind constant buffer // bind(); //} //// Update the world matrix to match this model //auto modelColor = model.getMaterial()->getColor(); //updateBuffer(modelColor, model.getTransform().getMatrix(), m_vpMatrix); //// Bind the texture if it exists //UINT numTextures; //auto tex = model.getMaterial()->getTextures(numTextures); //if (tex) // Application::getInstance()->getDXManager()->getDeviceContext()->PSSetShaderResources(0, numTextures, tex); //// Bind vertex buffer //UINT stride = sizeof(SimpleTextureShader::Vertex); //UINT offset = 0; //Application::getInstance()->getDXManager()->getDeviceContext()->IASetVertexBuffers(0, 1, model.getVertexBuffer(), &stride, &offset); //// Bind index buffer if one exists //auto* iBuffer = model.getIndexBuffer(); //if (iBuffer) // Application::getInstance()->getDXManager()->getDeviceContext()->IASetIndexBuffer(iBuffer, DXGI_FORMAT_R32_UINT, 0); //// Set topology //Application::getInstance()->getDXManager()->getDeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); //// Draw //if (iBuffer) // Application::getInstance()->getDXManager()->getDeviceContext()->DrawIndexed(model.getNumIndices(), 0, 0); //else // Application::getInstance()->getDXManager()->getDeviceContext()->Draw(model.getNumVertices(), 0); //ID3D11ShaderResourceView* nullSRV[5] = { nullptr, nullptr, nullptr, nullptr, nullptr }; //Application::getInstance()->getDXManager()->getDeviceContext()->PSSetShaderResources(0, 5, nullSRV); }
36.539326
166
0.747386
h3nx
bb1f0f656cfcbb9839e610c3c0eb24ab2b902c2f
1,332
cpp
C++
CppProject/product.cpp
maximlo91/Store-Management-System
1da6136baf964834834925f0d4ac1adac2cb306f
[ "MIT" ]
null
null
null
CppProject/product.cpp
maximlo91/Store-Management-System
1da6136baf964834834925f0d4ac1adac2cb306f
[ "MIT" ]
null
null
null
CppProject/product.cpp
maximlo91/Store-Management-System
1da6136baf964834834925f0d4ac1adac2cb306f
[ "MIT" ]
null
null
null
#pragma warning(disable: 4996) #include <iostream> #include <string> #include "product.h" #include "general.h" using namespace std; const char* Product::categories[] = {"Children","Office","Electricity","Clothes"}; int Product::s_counter = 0; //constructor . Product::Product(Item e_category, const string& itemName, int price,Seller& itemSeller) : m_serialNum(Product::s_counter), e_category(e_category), m_itemSeller(&itemSeller), m_price(price), m_itemName(itemName) { Product::s_counter++; } //destructor . Product::~Product() { } //returns a category . const char* Product::getCategory() const { return Product::categories[e_category-1]; } //returns a name . const string& Product::getName() const { return this->m_itemName; } //returns a price . int Product::getPrice() const { return this->m_price; } //returns a id . int Product::getId() const { return this->m_serialNum; } // returns a pointer to a seller of an item Seller* Product::getSeller() const { return this->m_itemSeller; } // overloaded ostream, prints product info std::ostream& operator<<(std::ostream& out, const Product& product) { out << "Product Name: " << product.m_itemName << "\nProduct Category: " << product.getCategory() << "\nProdcut ID: " << product.getId() << "\nProduct Price: " << product.getPrice() << endl; return out; }
21.483871
121
0.704955
maximlo91
bb244c4e99cee843542cc93c74b2a689745c651f
2,707
hpp
C++
breath/counting/signed_count.hpp
erez-o/breath
adf197b4e959beffce11e090c5e806d2ff4df38a
[ "BSD-3-Clause" ]
null
null
null
breath/counting/signed_count.hpp
erez-o/breath
adf197b4e959beffce11e090c5e806d2ff4df38a
[ "BSD-3-Clause" ]
null
null
null
breath/counting/signed_count.hpp
erez-o/breath
adf197b4e959beffce11e090c5e806d2ff4df38a
[ "BSD-3-Clause" ]
null
null
null
// =========================================================================== // Copyright 2007 Gennaro Prota // // Licensed under the 3-Clause BSD License. // (See accompanying file 3_CLAUSE_BSD_LICENSE.txt or // <https://opensource.org/licenses/BSD-3-Clause>.) // ___________________________________________________________________________ // //! \file //! \brief Arrays and containers element counter. //! //! An extension of \c container::size() to cover both standard //! containers and built-in arrays. //! //! The syntax is, uniformly, \c breath::count( a ) regardless of //! the actual type of \c a. See also begin_end.hpp. //! //! Following C++ best practices, these templates return a \e signed //! integer. They are made obsolete in C++20 by the namespace-scope //! \c std::ssize()'s. However our version avoids any fancy //! derivation of the return type, even for containers; and, for //! containers again, has a conditional noexcept that the standard //! version is not required to have. // --------------------------------------------------------------------------- #ifndef BREATH_GUARD_ivBlyIgMoh0KJl1p5J44xFCWiI9nPqRi #define BREATH_GUARD_ivBlyIgMoh0KJl1p5J44xFCWiI9nPqRi #include "breath/top_level_namespace.hpp" #include "breath/diagnostics/assert.hpp" #include "breath/preprocessing/prevent_macro_expansion.hpp" #include <cstddef> #include <limits> namespace breath_ns { // signed_count(): // =============== // //! \return //! The number of elements of the array argument (obviously, \c //! n). See also the file-level documentation. // --------------------------------------------------------------------------- template< typename T, std::ptrdiff_t n > constexpr std::ptrdiff_t signed_count( T const ( & )[ n ] ) noexcept { return n ; } // signed_count(): // =============== // //! \return //! The value of \c t.size() converted to \c std::ptrdiff_t. See //! also the file-level documentation. // --------------------------------------------------------------------------- template< typename T > constexpr std::ptrdiff_t signed_count( T const & t ) noexcept( noexcept( t.size() ) ) { typedef std::ptrdiff_t return_type ; BREATH_ASSERT( t.size() <= std::numeric_limits< return_type >::max BREATH_PREVENT_MACRO_EXPANSION () ) ; return static_cast< return_type >( t.size() ) ; } } #endif // Local Variables: // mode: c++ // indent-tabs-mode: nil // c-basic-offset: 4 // End: // vim: set ft=cpp et sts=4 sw=4:
33.012195
78
0.559291
erez-o
bb24f5903b0733ec5b5f9a9bf18deb5493a48743
7,524
cpp
C++
Axis.CommonLibrary/domain/elements/ElementGeometry.cpp
renato-yuzup/axis-fem
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
[ "MIT" ]
2
2021-07-23T08:49:54.000Z
2021-07-29T22:07:30.000Z
Axis.CommonLibrary/domain/elements/ElementGeometry.cpp
renato-yuzup/axis-fem
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
[ "MIT" ]
null
null
null
Axis.CommonLibrary/domain/elements/ElementGeometry.cpp
renato-yuzup/axis-fem
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
[ "MIT" ]
null
null
null
#include "ElementGeometry.hpp" #include "foundation/ArgumentException.hpp" #include "foundation/OutOfBoundsException.hpp" #include "System.hpp" #include "foundation/memory/pointer.hpp" namespace ade = axis::domain::elements; namespace adi = axis::domain::integration; namespace afb = axis::foundation::blas; namespace afm = axis::foundation::memory; ade::ElementGeometry::ElementGeometry( int numNodes ) { InitGeometry(numNodes); points_ = NULLPTR; } ade::ElementGeometry::ElementGeometry( int numNodes, int numIntegrationPoints ) { InitGeometry(numNodes); numIntegrPoints_ = numIntegrationPoints; points_ = System::ModelMemory().Allocate(sizeof(afm::RelativePointer)*numIntegrationPoints); } void ade::ElementGeometry::InitGeometry( int numNodes ) { // check for a valid number of nodes if (numNodes < 1) { throw axis::foundation::ArgumentException(_TEXT("numNodes")); } // create arrays #if defined(AXIS_NO_MEMORY_ARENA) nodes_ = new Node*[numNodes]; Node **nodes = nodes_; #else nodes_ = System::ModelMemory().Allocate(sizeof(afm::RelativePointer) * numNodes); afm::RelativePointer *nodes = (afm::RelativePointer*)*nodes_; #endif numNodes_ = numNodes; for (int i = 0; i < numNodes; i++) { nodes[i] = NULLPTR; } // init variables numIntegrPoints_ = 0; } ade::ElementGeometry::~ElementGeometry( void ) { if(numIntegrPoints_ > 0) { afm::RelativePointer *ptr = (afm::RelativePointer *)*points_; for (int i = 0; i < numIntegrPoints_; i++) { adi::IntegrationPoint& p = absref<adi::IntegrationPoint>(ptr[i]); System::ModelMemory().Deallocate(ptr[i]); p.Destroy(); } System::ModelMemory().Deallocate(points_); } #if defined(AXIS_NO_MEMORY_ARENA) delete [] nodes_; #else System::ModelMemory().Deallocate(nodes_); #endif } #if defined(AXIS_NO_MEMORY_ARENA) void ade::ElementGeometry::SetNode( int nodeIndex, Node& node ) #else void ade::ElementGeometry::SetNode( int nodeIndex, const afm::RelativePointer& node ) #endif { if (nodeIndex < 0 || nodeIndex >= numNodes_) { throw axis::foundation::OutOfBoundsException(); } #if defined(AXIS_NO_MEMORY_ARENA) nodes_[nodeIndex] = &node; #else afm::RelativePointer * n = (afm::RelativePointer*)*nodes_; n[nodeIndex] = node; #endif } const ade::Node& ade::ElementGeometry::GetNode( int nodeId ) const { #if defined(AXIS_NO_MEMORY_ARENA) return *nodes_[nodeId]; #else const afm::RelativePointer * n = absptr<afm::RelativePointer>(nodes_); return absref<Node>(n[nodeId]); #endif } ade::Node& ade::ElementGeometry::GetNode( int nodeId ) { #if defined(AXIS_NO_MEMORY_ARENA) return *nodes_[nodeId]; #else afm::RelativePointer * n = absptr<afm::RelativePointer>(nodes_); return absref<Node>(n[nodeId]); #endif } const ade::Node& ade::ElementGeometry::operator[]( int nodeId ) const { #if defined(AXIS_NO_MEMORY_ARENA) return *nodes_[nodeId]; #else const afm::RelativePointer * n = absptr<afm::RelativePointer>(nodes_); return absref<Node>(n[nodeId]); #endif } ade::Node& ade::ElementGeometry::operator[]( int nodeId ) { #if defined(AXIS_NO_MEMORY_ARENA) return *nodes_[nodeId]; #else afm::RelativePointer * n = absptr<afm::RelativePointer>(nodes_); return absref<Node>(n[nodeId]); #endif } int ade::ElementGeometry::GetNodeCount( void ) const { return numNodes_; } void ade::ElementGeometry::ExtractLocalField( afb::ColumnVector& localField, const afb::ColumnVector& globalField ) const { // build a matrix large enough for local field int totalDof = GetTotalDofCount(); int pos = 0; #if defined(AXIS_NO_MEMORY_ARENA) Node** n = nodes_; #else const afm::RelativePointer * n = absptr<afm::RelativePointer>(nodes_); #endif for (int i = 0; i < numNodes_; i++) { const Node& node = absref<Node>(n[i]); int nodeDofCount = node.GetDofCount(); for (int j = 0; j < nodeDofCount; j++) { localField(pos) = globalField(node[j].GetId()); ++pos; } } } bool ade::ElementGeometry::HasIntegrationPoints( void ) const { return (numIntegrPoints_ > 0); } const adi::IntegrationPoint& ade::ElementGeometry::GetIntegrationPoint( int index ) const { if (index < 0 || index >= numIntegrPoints_) { throw axis::foundation::OutOfBoundsException(); } afm::RelativePointer *points = (afm::RelativePointer *)*points_; return absref<adi::IntegrationPoint>(points[index]); } adi::IntegrationPoint& ade::ElementGeometry::GetIntegrationPoint( int index ) { if (index < 0 || index >= numIntegrPoints_) { throw axis::foundation::OutOfBoundsException(); } afm::RelativePointer *points = (afm::RelativePointer *)*points_; return absref<adi::IntegrationPoint>(points[index]); } void ade::ElementGeometry::SetIntegrationPoint( int index, const afm::RelativePointer& point ) { if (index < 0 || index >= numIntegrPoints_) { throw axis::foundation::OutOfBoundsException(); } afm::RelativePointer *points = (afm::RelativePointer *)*points_; points[index] = point; } int ade::ElementGeometry::GetIntegrationPointCount( void ) const { return numIntegrPoints_; } bool ade::ElementGeometry::HasNode( const ade::Node& node ) const { #if defined(AXIS_NO_MEMORY_ARENA) Node** n = nodes_; #else afm::RelativePointer * n = (afm::RelativePointer*)*nodes_; #endif for (int i = 0; i < numNodes_; ++i) { if (absptr<Node>(n[i]) == &node) return true; } return false; } int ade::ElementGeometry::GetNodeIndex( const ade::Node& node ) const { #if defined(AXIS_NO_MEMORY_ARENA) Node** n = nodes_; #else afm::RelativePointer * n = (afm::RelativePointer*)*nodes_; #endif for (int i = 0; i < numNodes_; ++i) { if (absptr<Node>(n[i]) == &node) return i; } return -1; } int ade::ElementGeometry::GetTotalDofCount( void ) const { #if defined(AXIS_NO_MEMORY_ARENA) Node** n = nodes_; #else afm::RelativePointer * n = (afm::RelativePointer*)*nodes_; #endif int totalDof = 0; for (int i = 0; i < numNodes_; ++i) { totalDof += absref<Node>(n[i]).GetDofCount(); } return totalDof; } #if !defined(AXIS_NO_MEMORY_ARENA) afm::RelativePointer ade::ElementGeometry::Create( int numNodes, int integrationPointCount ) { afm::RelativePointer ptr = System::ModelMemory().Allocate(sizeof(ElementGeometry)); new (*ptr) ElementGeometry(numNodes, integrationPointCount); return ptr; } afm::RelativePointer ade::ElementGeometry::Create( int numNodes ) { afm::RelativePointer ptr = System::ModelMemory().Allocate(sizeof(ElementGeometry)); new (*ptr) ElementGeometry(numNodes); return ptr; } void * ade::ElementGeometry::operator new( size_t bytes ) { // It is supposed that the finite element object will remain in memory // until the end of the program. That's why we discard the relative // pointer. We ignore the fact that an exception might occur in // constructor because if it does happen, the program will end. afm::RelativePointer ptr = System::GlobalMemory().Allocate(bytes); return *ptr; } void * ade::ElementGeometry::operator new( size_t, void *ptr ) { return ptr; } void ade::ElementGeometry::operator delete( void * ) { // Since the relative pointer was discarded, we can't discard memory. // If it is really necessary, to free up resources, obliterating // memory pool is a better approach. } void ade::ElementGeometry::operator delete( void *, void * ) { // Since the relative pointer was discarded, we can't discard memory. // If it is really necessary, to free up resources, obliterating // memory pool is a better approach. } #endif
26.216028
94
0.708931
renato-yuzup
bb2819488732cdb10144f8467b2b9371ae358f8f
239
cpp
C++
docs/mfc/reference/codesnippet/CPP/cricheditctrl-class_33.cpp
bobbrow/cpp-docs
769b186399141c4ea93400863a7d8463987bf667
[ "CC-BY-4.0", "MIT" ]
965
2017-06-25T23:57:11.000Z
2022-03-31T14:17:32.000Z
docs/mfc/reference/codesnippet/CPP/cricheditctrl-class_33.cpp
bobbrow/cpp-docs
769b186399141c4ea93400863a7d8463987bf667
[ "CC-BY-4.0", "MIT" ]
3,272
2017-06-24T00:26:34.000Z
2022-03-31T22:14:07.000Z
docs/mfc/reference/codesnippet/CPP/cricheditctrl-class_33.cpp
bobbrow/cpp-docs
769b186399141c4ea93400863a7d8463987bf667
[ "CC-BY-4.0", "MIT" ]
951
2017-06-25T12:36:14.000Z
2022-03-26T22:49:06.000Z
CHARFORMAT cf; // Modify the word format so that the selected word is // displayed in bold and not striked out. cf.cbSize = sizeof(cf); cf.dwMask = CFM_STRIKEOUT | CFM_BOLD; cf.dwEffects = CFE_BOLD; m_myRichEditCtrl.SetWordCharFormat(cf);
29.875
54
0.769874
bobbrow
bb2ea0b7844a55c68b9f7edf1048828b7691db8c
3,309
cpp
C++
test/functional/gfalt_test_copy_file_mkdir.cpp
adevress/gfal2
ce8945d1c153e26c5d10ad43d1940b8dcace0579
[ "Apache-2.0" ]
null
null
null
test/functional/gfalt_test_copy_file_mkdir.cpp
adevress/gfal2
ce8945d1c153e26c5d10ad43d1940b8dcace0579
[ "Apache-2.0" ]
null
null
null
test/functional/gfalt_test_copy_file_mkdir.cpp
adevress/gfal2
ce8945d1c153e26c5d10ad43d1940b8dcace0579
[ "Apache-2.0" ]
1
2020-04-28T09:36:46.000Z
2020-04-28T09:36:46.000Z
/** * Compile command : gcc -o gfalt_copyfile gfalt_copyfile.c `pkg-config --libs --cflags gfal_transfer` */ #include <gtest/gtest.h> #include <gfal_api.h> #include <stdio.h> #include <stdlib.h> #include <utils/exceptions/gerror_to_cpp.h> #include <transfer/gfal_transfer.h> #include <common/gfal_lib_test.h> #include <common/gfal_gtest_asserts.h> #include <list> class CopyTestMkdir: public testing::Test { public: static const char* source_root; static const char* destination_root; char source[2048]; char destination[2048]; gfal2_context_t handle; gfalt_params_t params; std::list<std::string> directories; CopyTestMkdir() { GError *error = NULL; handle = gfal2_context_new(&error); Gfal::gerror_to_cpp(&error); params = gfalt_params_handle_new(NULL); gfalt_set_create_parent_dir(params, TRUE, NULL); } virtual ~CopyTestMkdir() { gfal2_context_free(handle); gfalt_params_handle_delete(params, NULL); } virtual void SetUp() { generate_random_uri(source_root, "copyfile_replace_source", source, 2048); RecordProperty("Source", source); RecordProperty("Destination", source); GError* error = NULL; int ret = generate_file_if_not_exists(handle, source, "file:///etc/hosts", &error); EXPECT_PRED_FORMAT2(AssertGfalSuccess, ret, error); } virtual void TearDown() { gfal_unlink(source); gfal_unlink(destination); std::list<std::string>::const_iterator i; for (i = directories.begin(); i != directories.end(); ++i) gfal_rmdir(i->c_str()); directories.clear(); } }; const char* CopyTestMkdir::source_root; const char* CopyTestMkdir::destination_root; TEST_F(CopyTestMkdir, CopyNested) { char first_level[2048]; char second_level[2048]; char third_level[2048]; generate_random_uri(destination_root, "generate_folder", first_level, 2048); generate_random_uri(first_level, "generate_folder2", second_level, 2048); generate_random_uri(second_level, "generate_folder3", third_level, 2048); generate_random_uri(third_level, "generate_dest_file", destination, 2048); directories.push_front(first_level); directories.push_front(second_level); directories.push_front(third_level); GError *error = NULL; int ret = 0; ret = gfalt_copy_file(handle, params, source, destination, &error); EXPECT_PRED_FORMAT2(AssertGfalSuccess, ret, error); } TEST_F(CopyTestMkdir, CopyAtRoot) { generate_random_uri(destination_root, "simple_file_at_root", destination, 2048); GError *error = NULL; int ret = 0; ret = gfalt_copy_file(handle, params, source, destination, &error); EXPECT_PRED_FORMAT2(AssertGfalSuccess, ret, error); } int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); if (argc < 2) { printf("Missing source and destination base urls\n"); printf("\t%s [options] srm://host/base/path/ srm://destination/base/path/\n", argv[0]); return 1; } CopyTestMkdir::source_root = argv[1]; CopyTestMkdir::destination_root = argv[2]; // gfal_set_verbose(GFAL_VERBOSE_TRACE | GFAL_VERBOSE_VERBOSE | GFAL_VERBOSE_DEBUG); return RUN_ALL_TESTS(); }
27.347107
102
0.68903
adevress
bb329733361f1d7ce48a9156918d00aed2690e55
4,402
cpp
C++
Source/FPSProject/FPSHud.cpp
ellji/FPSProject
d1ae8b45acd52426aa4391caaae01ccd13c09a80
[ "MIT" ]
null
null
null
Source/FPSProject/FPSHud.cpp
ellji/FPSProject
d1ae8b45acd52426aa4391caaae01ccd13c09a80
[ "MIT" ]
null
null
null
Source/FPSProject/FPSHud.cpp
ellji/FPSProject
d1ae8b45acd52426aa4391caaae01ccd13c09a80
[ "MIT" ]
null
null
null
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #include "FPSProject.h" //#include "CardInvUIWidget.h" #include "FPSHud.h" AFPSHud::AFPSHud(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { // set the crosshair texture static ConstructorHelpers::FObjectFinder<UTexture2D> CrosshairTexObj(TEXT("Texture2D'/Game/UI/Textures/crosshair.crosshair'")); CrosshairTex = CrosshairTexObj.Object; static ConstructorHelpers::FObjectFinder<UTexture2D> GrowTexObj(TEXT("Texture2D'/Game/UI/Textures/gui_card_grow.gui_card_grow'")); UICardTexAtlas.Add(GrowTexObj.Object); static ConstructorHelpers::FObjectFinder<UTexture2D> ShrinkTexObj(TEXT("Texture2D'/Game/UI/Textures/gui_card_shrink.gui_card_shrink'")); UICardTexAtlas.Add(ShrinkTexObj.Object); static ConstructorHelpers::FObjectFinder<UTexture2D> JumpTexObj(TEXT("Texture2D'/Game/UI/Textures/card_jump.card_jump'")); UICardTexAtlas.Add(JumpTexObj.Object); LeftInset = 20.0f; BottomInset = 150.0f; HighlightScale = 1.2f; } void AFPSHud::BeginPlay() { if (GetOwningPlayerController() != NULL) { PlayerController = Cast<AFPSCharacter>(GetOwningPlayerController()->GetPawn()); } //// So far only TSharedPtr<SCardInvUIWidget> has been created, now create the actual object //// Create a SCardInvUIWidget on heap, our CardInvUIWidget shared pointer provides a handle to object //// widget will not self-destruct unless the hud's sharedptr (and all other sharedptrs) destruct first //SAssignNew(CardInvUIWidget, SCardInvUIWidget).OwnerHUD(this); //// pass our viewport a weak ptr to our widget //if (GEngine->IsValidLowLevel()) //{ // GEngine->GameViewport-> // // viewport's weak ptr will not give viewport ownership of widget // AddViewportWidgetContent(SNew(SWeakWidget).PossiblyNullContent(CardInvUIWidget.ToSharedRef())); //} //if (CardInvUIWidget.IsValid()) //{ // // set widget's properties as visible (sets child widget properties recursively // CardInvUIWidget->SetVisibility(EVisibility::Visible); //} } void AFPSHud::DrawHUD() { Super::DrawHUD(); if (!Canvas) return; DrawCrosshair(); DrawInventory(); } void AFPSHud::DrawCrosshair() { // draw simple crosshair // in the middle of the screen const FVector2D Center(Canvas->ClipX * 0.5f, Canvas->ClipY * 0.5f); // offset by half the texture's dimensions to align in the centre const FVector2D CrosshairDrawPosition( (Center.X - CrosshairTex->GetSurfaceWidth() * 0.5f), (Center.Y - CrosshairTex->GetSurfaceHeight() * 0.5f)); // draw FCanvasTileItem TileItem(CrosshairDrawPosition, CrosshairTex->Resource, FLinearColor::White); TileItem.BlendMode = SE_BLEND_Translucent; Canvas->DrawItem(TileItem); } void AFPSHud::DrawInventory() { FVector2D CardScale = FVector2D(1.0f, 1.0f); for (int32 i = 0; i < PlayerController->ItemInventory.Num(); i++) { // get the card type to draw ECardType::Type CardType = PlayerController->ItemInventory[i].GetValue(); CardScale.X = UICardTexAtlas[CardType]->GetSurfaceWidth() * 0.2f; CardScale.Y = UICardTexAtlas[CardType]->GetSurfaceHeight() * 0.2f; FVector2D CardPosition = FVector2D( LeftInset + (i * UICardTexAtlas[CardType]->GetSurfaceWidth() * 0.2f), Canvas->ClipY - BottomInset); // make the card larger if it's the selected card if (i == PlayerController->SelectedInventoryItem) { // move the card up because it's selected CardPosition.Y = CardPosition.Y - ((CardScale.Y * HighlightScale) - CardScale.Y); CardScale.X = CardScale.X * HighlightScale; CardScale.Y = CardScale.Y * HighlightScale; } else if (i > PlayerController->SelectedInventoryItem) { CardPosition.X = CardPosition.X + (CardScale.X - (CardScale.X / HighlightScale)); } DrawCard(CardType, CardPosition, CardScale); //reset CardScale = FVector2D(1.0f, 1.0f); } } void AFPSHud::DrawCard(ECardType::Type CardType, FVector2D Position, FVector2D Scale) { FCanvasTileItem TileItem(Position, UICardTexAtlas[CardType]->Resource, Scale, FLinearColor::White); TileItem.BlendMode = SE_BLEND_Translucent; Canvas->DrawItem(TileItem); } void AFPSHud::DrawTextString() { //Text and Font FCanvasTextItem NewText( FVector2D(10.0f, 100.0f), FText::FromString("Hello"), TextFont, FColor::Red ); NewText.bOutlined = true; NewText.OutlineColor = FColor::Black; NewText.OutlineColor.A = FColor::Red.A * 2; Canvas->DrawItem(NewText); }
30.569444
137
0.74239
ellji
bb338cd9ab1314e902f43b4f53526e7e9ec22fa7
4,352
cpp
C++
Engine/Source/Graphics/Vulkan/VulkanCmdList.cpp
IcanCUthere/Gravity-Engine
3d61e7b78543572850efd9de3870a684ab476c7a
[ "MIT" ]
null
null
null
Engine/Source/Graphics/Vulkan/VulkanCmdList.cpp
IcanCUthere/Gravity-Engine
3d61e7b78543572850efd9de3870a684ab476c7a
[ "MIT" ]
null
null
null
Engine/Source/Graphics/Vulkan/VulkanCmdList.cpp
IcanCUthere/Gravity-Engine
3d61e7b78543572850efd9de3870a684ab476c7a
[ "MIT" ]
null
null
null
module; #include <vulkan/vulkan.h> #include "Core/DebugUtils.h" module Graphics:Vulkan.CmdList; import :Vulkan.Context; import :Vulkan.Viewport; import :Vulkan.Queue; namespace GFX { AVulkanCmdList::AVulkanCmdList(const VkCommandBuffer handle, const VkCommandBufferLevel level, const VkPipelineStageFlags waitStages) : Handle(handle), Semaphore(true), Level(level), WaitStages(waitStages) { } AVulkanCmdList::AVulkanCmdList(AVulkanCmdList&& other) : Handle(other.Handle), Level(other.Level), WaitStages(other.WaitStages), Semaphore(std::move(other.Semaphore)) { other.Handle = VK_NULL_HANDLE; other.Level = VK_COMMAND_BUFFER_LEVEL_MAX_ENUM; other.WaitStages = VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM; } void AVulkanCmdList::operator=(AVulkanCmdList&& other) { Handle = other.Handle; Level = other.Level; WaitStages = other.WaitStages; Semaphore = std::move(other.Semaphore); other.Handle = VK_NULL_HANDLE; other.Level = VK_COMMAND_BUFFER_LEVEL_MAX_ENUM; other.WaitStages = VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM; } void AVulkanCmdList::BeginRecording(const ERenderStage stage, const IViewport* viewport) { const AVulkanViewport* vViewport = (AVulkanViewport*)viewport; VkCommandBufferInheritanceInfo inheritanceInfo; inheritanceInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; inheritanceInfo.pNext = nullptr; inheritanceInfo.occlusionQueryEnable = false; inheritanceInfo.queryFlags = 0; inheritanceInfo.pipelineStatistics = 0; VkCommandBufferBeginInfo beginInfo; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; beginInfo.pNext = nullptr; if (stage == ERenderStage::Transfer) { inheritanceInfo.framebuffer = VK_NULL_HANDLE; inheritanceInfo.renderPass = VK_NULL_HANDLE; inheritanceInfo.subpass = (uint32_t)stage; beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; beginInfo.pInheritanceInfo = nullptr; } else { inheritanceInfo.framebuffer = vViewport->GetSwapchain().GetFramebuffer().GetHandle(); inheritanceInfo.renderPass = vViewport->GetSwapchain().GetRenderPass().GetHandle(); inheritanceInfo.subpass = (uint32_t)stage; beginInfo.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; beginInfo.pInheritanceInfo = (Level == VK_COMMAND_BUFFER_LEVEL_SECONDARY ? &inheritanceInfo : nullptr); } vkValidate(vkf::vkBeginCommandBuffer(Handle, &beginInfo)) } void AVulkanCmdList::StopRecording() { vkValidate(vkf::vkEndCommandBuffer(Handle)) } void AVulkanCmdList::Submit(const ISemaphore* waitSemaphore) { const AVulkanSemaphore* vSemaphore = (AVulkanSemaphore*)waitSemaphore; Semaphore.WaitForSignal(); Semaphore.ResetFence(); VkQueue submitQueue = nullptr; switch (WaitStages) { case VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT: submitQueue = AVulkanContext::GetDevice().GetRenderQueue().GetHandle(); break; case VK_PIPELINE_STAGE_TRANSFER_BIT: submitQueue = AVulkanContext::GetDevice().GetTransferQueue().GetHandle(); break; case VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT: /*TODO: implement compute queue*/ break; default: verify(0, "No valid submit queue found."); } VkSubmitInfo submitInfo = {}; submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.pNext = nullptr; submitInfo.pWaitDstStageMask = &WaitStages; submitInfo.waitSemaphoreCount = (vSemaphore ? 1 : 0); submitInfo.pWaitSemaphores = &vSemaphore->GetSemaphore(); submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &Handle; submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &Semaphore.GetSemaphore(); vkValidate(vkf::vkQueueSubmit(submitQueue, 1, &submitInfo, Semaphore.GetFence())) } void AVulkanCmdList::Reset() { Semaphore.WaitForSignal(); vkValidate(vkf::vkResetCommandBuffer(Handle, 0)) } void AVulkanCmdList::ConsumeLists(const std::vector<ICmdList*>& lists) { std::vector<VkCommandBuffer> handles; for (const ICmdList* list : lists) { AVulkanCmdList* vList = (AVulkanCmdList*)list; handles.push_back(vList->GetHandle()); } vkf::vkCmdExecuteCommands(Handle, (uint32_t)handles.size(), handles.data()); } void AVulkanCmdList::WaitToFinish() const { Semaphore.WaitForSignal(); } ISemaphore* AVulkanCmdList::GetSemaphore() const { return (ISemaphore*)&Semaphore; } }
32.969697
134
0.777803
IcanCUthere