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
sequencelengths 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
sequencelengths 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
sequencelengths 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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f90e466b4b041fdce6f38dfc35d3732befd0a0d3 | 1,476 | cpp | C++ | Source/source/mob_types/ship_type.cpp | Neocraftz1553/Pikifen | e10e1f9f28d4e5229db64c291a8b2ccbb013b7e2 | [
"MIT"
] | null | null | null | Source/source/mob_types/ship_type.cpp | Neocraftz1553/Pikifen | e10e1f9f28d4e5229db64c291a8b2ccbb013b7e2 | [
"MIT"
] | null | null | null | Source/source/mob_types/ship_type.cpp | Neocraftz1553/Pikifen | e10e1f9f28d4e5229db64c291a8b2ccbb013b7e2 | [
"MIT"
] | null | null | null | /*
* Copyright (c) Andre 'Espyo' Silva 2013.
* The following source file belongs to the open-source project Pikifen.
* Please read the included README and LICENSE files for more information.
* Pikmin is copyright (c) Nintendo.
*
* === FILE DESCRIPTION ===
* Ship type class and ship type-related functions.
*/
#include "ship_type.h"
#include "../functions.h"
#include "../mob_fsms/ship_fsm.h"
#include "../mobs/ship.h"
#include "../utils/string_utils.h"
/* ----------------------------------------------------------------------------
* Creates a type of ship.
*/
ship_type::ship_type() :
mob_type(MOB_CATEGORY_SHIPS),
can_heal(false),
beam_radius(0.0f) {
target_type = MOB_TARGET_TYPE_NONE;
ship_fsm::create_fsm(this);
}
/* ----------------------------------------------------------------------------
* Returns the vector of animation conversions.
*/
anim_conversion_vector ship_type::get_anim_conversions() const {
anim_conversion_vector v;
v.push_back(std::make_pair(SHIP_ANIM_IDLING, "idling"));
return v;
}
/* ----------------------------------------------------------------------------
* Loads properties from a data file.
* file:
* File to read from.
*/
void ship_type::load_properties(data_node* file) {
reader_setter rs(file);
rs.set("beam_offset_x", beam_offset.x);
rs.set("beam_offset_y", beam_offset.y);
rs.set("beam_radius", beam_radius);
rs.set("can_heal", can_heal);
}
| 26.357143 | 79 | 0.576558 | Neocraftz1553 |
f911468765228b7d1ecd797f927a2b1e5ad48ac8 | 3,102 | hpp | C++ | drivers/inc/reg.hpp | scatty101/imxrt1062 | 4fb991c138d16e02ed8ea58b096be2034c9e5063 | [
"MIT"
] | 2 | 2021-02-01T21:21:52.000Z | 2021-02-07T07:19:18.000Z | drivers/inc/reg.hpp | scatty101/imxrt1062 | 4fb991c138d16e02ed8ea58b096be2034c9e5063 | [
"MIT"
] | null | null | null | drivers/inc/reg.hpp | scatty101/imxrt1062 | 4fb991c138d16e02ed8ea58b096be2034c9e5063 | [
"MIT"
] | 1 | 2021-02-01T21:25:19.000Z | 2021-02-01T21:25:19.000Z | #ifndef IMXRT_DRIVERS_REG_HPP_
#define IMXRT_DRIVERS_REG_HPP_
#include <imxrt1062/hardware.hpp>
namespace imxdrivers
{
/**
* @brief DSB
*
*/
static inline void data_sync()
{
__DSB();
}
/**
* @brief Sometimes IRQ are executed so fast, that irq flag isn't cleared until leave of irq. This function solves this problem.
*
*/
static inline void irq_save_exit()
{
data_sync();
}
/**
* @brief Performs OR operation.
*
* @tparam reg_t
* @tparam value_t
* @param reg
* @param value
*/
template <typename reg_t, typename value_t>
static inline constexpr void reg_set(reg_t ®, const value_t &value = static_cast<value_t>(0))
{
reg |= static_cast<reg_t>(value);
}
/**
* @brief Performs write operation.
*
* @tparam reg_t
* @tparam value_t
* @param reg
* @param value
*/
template <typename reg_t, typename value_t>
static inline constexpr void reg_write(reg_t ®, const value_t &value = static_cast<value_t>(0))
{
reg = static_cast<reg_t>(value);
}
/**
* @brief Peforms AND NOT operation
*
* @tparam reg_t
* @tparam value_t
* @param reg
* @param value
*/
template <typename reg_t, typename value_t>
static inline constexpr void reg_clear(reg_t ®, const value_t &value = static_cast<value_t>(0))
{
reg &= static_cast<reg_t>(~value);
}
/**
* @brief Performs read operation
*
* @tparam reg_t
* @param reg
* @return constexpr reg_t
*/
template <typename reg_t>
static inline constexpr reg_t reg_get(const reg_t ®)
{
return reg;
}
template <typename reg_t, typename mask_t, typename shift_t, typename value_t>
static inline constexpr void reg_manipulate(reg_t ®, const mask_t &mask, const shift_t &shift, const value_t &value)
{
auto reg_temp = reg_get(reg);
reg_clear(reg_temp, mask);
reg_set(reg_temp, (value << shift) & mask);
reg_write(reg, reg_temp);
}
template <typename reg_t, typename bit_pos_t>
static inline bool reg_get_bit(const reg_t ®, const bit_pos_t &bit_pos)
{
return (reg_get(reg) >> bit_pos) & 0x1;
}
template <typename reg_t, typename bit_pos_t>
static inline constexpr void reg_clear_bit(reg_t ®, const bit_pos_t &bit_pos)
{
reg_clear(reg, 1 << bit_pos);
}
template <typename reg_t, typename bit_pos_t>
static inline constexpr void reg_set_bit(reg_t ®, const bit_pos_t &bit_pos)
{
reg_set(reg, 1 << bit_pos);
}
template <typename reg_t, typename bit_pos_t>
static inline constexpr void reg_manipulate_bit(reg_t ®, const bit_pos_t &bit_pos, const bool &value)
{
if (value)
{
reg_set_bit(reg, bit_pos);
}
else
{
reg_clear_bit(reg, bit_pos);
}
}
} // namespace imxdrivers
#endif // IMXRT_DRIVERS_REG_HPP_ | 25.636364 | 132 | 0.60735 | scatty101 |
f9161a0c7752ad4996b90dd7c9ff0793a01177b3 | 319,755 | hpp | C++ | include/alibabacloud/pai_plugin_20220112.hpp | alibabacloud-sdk-cpp/paiplugin-20220112 | 350e03cc56139f270d6ef0eb75b474a79d9ded8d | [
"Apache-2.0"
] | null | null | null | include/alibabacloud/pai_plugin_20220112.hpp | alibabacloud-sdk-cpp/paiplugin-20220112 | 350e03cc56139f270d6ef0eb75b474a79d9ded8d | [
"Apache-2.0"
] | null | null | null | include/alibabacloud/pai_plugin_20220112.hpp | alibabacloud-sdk-cpp/paiplugin-20220112 | 350e03cc56139f270d6ef0eb75b474a79d9ded8d | [
"Apache-2.0"
] | null | null | null | // This file is auto-generated, don't edit it. Thanks.
#ifndef ALIBABACLOUD_PAIPLUGIN20220112_H_
#define ALIBABACLOUD_PAIPLUGIN20220112_H_
#include <alibabacloud/open_api.hpp>
#include <boost/throw_exception.hpp>
#include <darabonba/core.hpp>
#include <darabonba/util.hpp>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
namespace Alibabacloud_PaiPlugin20220112 {
class CreateCampaignRequest : public Darabonba::Model {
public:
shared_ptr<string> name{};
shared_ptr<string> remark{};
CreateCampaignRequest() {}
explicit CreateCampaignRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
}
virtual ~CreateCampaignRequest() = default;
};
class CreateCampaignResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<string> updatedTime{};
CreateCampaignResponseBodyData() {}
explicit CreateCampaignResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~CreateCampaignResponseBodyData() = default;
};
class CreateCampaignResponseBody : public Darabonba::Model {
public:
shared_ptr<CreateCampaignResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
CreateCampaignResponseBody() {}
explicit CreateCampaignResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
CreateCampaignResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<CreateCampaignResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~CreateCampaignResponseBody() = default;
};
class CreateCampaignResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<CreateCampaignResponseBody> body{};
CreateCampaignResponse() {}
explicit CreateCampaignResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
CreateCampaignResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<CreateCampaignResponseBody>(model1);
}
}
}
virtual ~CreateCampaignResponse() = default;
};
class CreateGroupRequest : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> column{};
shared_ptr<string> filter{};
shared_ptr<string> inferenceJobId{};
shared_ptr<string> name{};
shared_ptr<bool> phoneNumber{};
shared_ptr<string> project{};
shared_ptr<string> remark{};
shared_ptr<long> source{};
shared_ptr<string> table{};
shared_ptr<string> text{};
shared_ptr<string> uri{};
CreateGroupRequest() {}
explicit CreateGroupRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (column) {
res["Column"] = boost::any(*column);
}
if (filter) {
res["Filter"] = boost::any(*filter);
}
if (inferenceJobId) {
res["InferenceJobId"] = boost::any(*inferenceJobId);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (phoneNumber) {
res["PhoneNumber"] = boost::any(*phoneNumber);
}
if (project) {
res["Project"] = boost::any(*project);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (source) {
res["Source"] = boost::any(*source);
}
if (table) {
res["Table"] = boost::any(*table);
}
if (text) {
res["Text"] = boost::any(*text);
}
if (uri) {
res["Uri"] = boost::any(*uri);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("Column") != m.end() && !m["Column"].empty()) {
column = make_shared<string>(boost::any_cast<string>(m["Column"]));
}
if (m.find("Filter") != m.end() && !m["Filter"].empty()) {
filter = make_shared<string>(boost::any_cast<string>(m["Filter"]));
}
if (m.find("InferenceJobId") != m.end() && !m["InferenceJobId"].empty()) {
inferenceJobId = make_shared<string>(boost::any_cast<string>(m["InferenceJobId"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PhoneNumber") != m.end() && !m["PhoneNumber"].empty()) {
phoneNumber = make_shared<bool>(boost::any_cast<bool>(m["PhoneNumber"]));
}
if (m.find("Project") != m.end() && !m["Project"].empty()) {
project = make_shared<string>(boost::any_cast<string>(m["Project"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Source") != m.end() && !m["Source"].empty()) {
source = make_shared<long>(boost::any_cast<long>(m["Source"]));
}
if (m.find("Table") != m.end() && !m["Table"].empty()) {
table = make_shared<string>(boost::any_cast<string>(m["Table"]));
}
if (m.find("Text") != m.end() && !m["Text"].empty()) {
text = make_shared<string>(boost::any_cast<string>(m["Text"]));
}
if (m.find("Uri") != m.end() && !m["Uri"].empty()) {
uri = make_shared<string>(boost::any_cast<string>(m["Uri"]));
}
}
virtual ~CreateGroupRequest() = default;
};
class CreateGroupResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<long> amount{};
shared_ptr<string> column{};
shared_ptr<string> createdTime{};
shared_ptr<string> filter{};
shared_ptr<string> id{};
shared_ptr<string> inferenceJobId{};
shared_ptr<string> name{};
shared_ptr<bool> phoneNumber{};
shared_ptr<string> project{};
shared_ptr<string> remark{};
shared_ptr<long> source{};
shared_ptr<long> status{};
shared_ptr<string> table{};
shared_ptr<string> text{};
shared_ptr<string> updatedTime{};
shared_ptr<string> uri{};
CreateGroupResponseBodyData() {}
explicit CreateGroupResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (amount) {
res["Amount"] = boost::any(*amount);
}
if (column) {
res["Column"] = boost::any(*column);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (filter) {
res["Filter"] = boost::any(*filter);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (inferenceJobId) {
res["InferenceJobId"] = boost::any(*inferenceJobId);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (phoneNumber) {
res["PhoneNumber"] = boost::any(*phoneNumber);
}
if (project) {
res["Project"] = boost::any(*project);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (source) {
res["Source"] = boost::any(*source);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (table) {
res["Table"] = boost::any(*table);
}
if (text) {
res["Text"] = boost::any(*text);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (uri) {
res["Uri"] = boost::any(*uri);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("Amount") != m.end() && !m["Amount"].empty()) {
amount = make_shared<long>(boost::any_cast<long>(m["Amount"]));
}
if (m.find("Column") != m.end() && !m["Column"].empty()) {
column = make_shared<string>(boost::any_cast<string>(m["Column"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Filter") != m.end() && !m["Filter"].empty()) {
filter = make_shared<string>(boost::any_cast<string>(m["Filter"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("InferenceJobId") != m.end() && !m["InferenceJobId"].empty()) {
inferenceJobId = make_shared<string>(boost::any_cast<string>(m["InferenceJobId"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PhoneNumber") != m.end() && !m["PhoneNumber"].empty()) {
phoneNumber = make_shared<bool>(boost::any_cast<bool>(m["PhoneNumber"]));
}
if (m.find("Project") != m.end() && !m["Project"].empty()) {
project = make_shared<string>(boost::any_cast<string>(m["Project"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Source") != m.end() && !m["Source"].empty()) {
source = make_shared<long>(boost::any_cast<long>(m["Source"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("Table") != m.end() && !m["Table"].empty()) {
table = make_shared<string>(boost::any_cast<string>(m["Table"]));
}
if (m.find("Text") != m.end() && !m["Text"].empty()) {
text = make_shared<string>(boost::any_cast<string>(m["Text"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("Uri") != m.end() && !m["Uri"].empty()) {
uri = make_shared<string>(boost::any_cast<string>(m["Uri"]));
}
}
virtual ~CreateGroupResponseBodyData() = default;
};
class CreateGroupResponseBody : public Darabonba::Model {
public:
shared_ptr<CreateGroupResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
CreateGroupResponseBody() {}
explicit CreateGroupResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
CreateGroupResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<CreateGroupResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~CreateGroupResponseBody() = default;
};
class CreateGroupResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<CreateGroupResponseBody> body{};
CreateGroupResponse() {}
explicit CreateGroupResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
CreateGroupResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<CreateGroupResponseBody>(model1);
}
}
}
virtual ~CreateGroupResponse() = default;
};
class CreateInferenceJobRequest : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> campaignId{};
shared_ptr<string> dataPath{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<string> targetPath{};
shared_ptr<string> trainingJobId{};
shared_ptr<string> userConfig{};
CreateInferenceJobRequest() {}
explicit CreateInferenceJobRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (dataPath) {
res["DataPath"] = boost::any(*dataPath);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (targetPath) {
res["TargetPath"] = boost::any(*targetPath);
}
if (trainingJobId) {
res["TrainingJobId"] = boost::any(*trainingJobId);
}
if (userConfig) {
res["UserConfig"] = boost::any(*userConfig);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("DataPath") != m.end() && !m["DataPath"].empty()) {
dataPath = make_shared<string>(boost::any_cast<string>(m["DataPath"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("TargetPath") != m.end() && !m["TargetPath"].empty()) {
targetPath = make_shared<string>(boost::any_cast<string>(m["TargetPath"]));
}
if (m.find("TrainingJobId") != m.end() && !m["TrainingJobId"].empty()) {
trainingJobId = make_shared<string>(boost::any_cast<string>(m["TrainingJobId"]));
}
if (m.find("UserConfig") != m.end() && !m["UserConfig"].empty()) {
userConfig = make_shared<string>(boost::any_cast<string>(m["UserConfig"]));
}
}
virtual ~CreateInferenceJobRequest() = default;
};
class CreateInferenceJobResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> campaignId{};
shared_ptr<string> createdTime{};
shared_ptr<string> dataPath{};
shared_ptr<string> groupId{};
shared_ptr<string> history{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<long> status{};
shared_ptr<string> targetPath{};
shared_ptr<string> trainingJobId{};
shared_ptr<string> updatedTime{};
shared_ptr<string> userConfig{};
CreateInferenceJobResponseBodyData() {}
explicit CreateInferenceJobResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (dataPath) {
res["DataPath"] = boost::any(*dataPath);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (history) {
res["History"] = boost::any(*history);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (targetPath) {
res["TargetPath"] = boost::any(*targetPath);
}
if (trainingJobId) {
res["TrainingJobId"] = boost::any(*trainingJobId);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (userConfig) {
res["UserConfig"] = boost::any(*userConfig);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("DataPath") != m.end() && !m["DataPath"].empty()) {
dataPath = make_shared<string>(boost::any_cast<string>(m["DataPath"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("History") != m.end() && !m["History"].empty()) {
history = make_shared<string>(boost::any_cast<string>(m["History"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TargetPath") != m.end() && !m["TargetPath"].empty()) {
targetPath = make_shared<string>(boost::any_cast<string>(m["TargetPath"]));
}
if (m.find("TrainingJobId") != m.end() && !m["TrainingJobId"].empty()) {
trainingJobId = make_shared<string>(boost::any_cast<string>(m["TrainingJobId"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("UserConfig") != m.end() && !m["UserConfig"].empty()) {
userConfig = make_shared<string>(boost::any_cast<string>(m["UserConfig"]));
}
}
virtual ~CreateInferenceJobResponseBodyData() = default;
};
class CreateInferenceJobResponseBody : public Darabonba::Model {
public:
shared_ptr<CreateInferenceJobResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
CreateInferenceJobResponseBody() {}
explicit CreateInferenceJobResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
CreateInferenceJobResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<CreateInferenceJobResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~CreateInferenceJobResponseBody() = default;
};
class CreateInferenceJobResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<CreateInferenceJobResponseBody> body{};
CreateInferenceJobResponse() {}
explicit CreateInferenceJobResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
CreateInferenceJobResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<CreateInferenceJobResponseBody>(model1);
}
}
}
virtual ~CreateInferenceJobResponse() = default;
};
class CreateScheduleRequest : public Darabonba::Model {
public:
shared_ptr<long> endTime{};
shared_ptr<string> executeTime{};
shared_ptr<string> groupId{};
shared_ptr<string> name{};
shared_ptr<long> repeatCycle{};
shared_ptr<long> repeatCycleUnit{};
shared_ptr<long> repeatTimes{};
shared_ptr<string> signName{};
shared_ptr<string> signatureId{};
shared_ptr<string> templateCode{};
shared_ptr<string> templateId{};
CreateScheduleRequest() {}
explicit CreateScheduleRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (endTime) {
res["EndTime"] = boost::any(*endTime);
}
if (executeTime) {
res["ExecuteTime"] = boost::any(*executeTime);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (repeatCycle) {
res["RepeatCycle"] = boost::any(*repeatCycle);
}
if (repeatCycleUnit) {
res["RepeatCycleUnit"] = boost::any(*repeatCycleUnit);
}
if (repeatTimes) {
res["RepeatTimes"] = boost::any(*repeatTimes);
}
if (signName) {
res["SignName"] = boost::any(*signName);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (templateId) {
res["TemplateId"] = boost::any(*templateId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("EndTime") != m.end() && !m["EndTime"].empty()) {
endTime = make_shared<long>(boost::any_cast<long>(m["EndTime"]));
}
if (m.find("ExecuteTime") != m.end() && !m["ExecuteTime"].empty()) {
executeTime = make_shared<string>(boost::any_cast<string>(m["ExecuteTime"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("RepeatCycle") != m.end() && !m["RepeatCycle"].empty()) {
repeatCycle = make_shared<long>(boost::any_cast<long>(m["RepeatCycle"]));
}
if (m.find("RepeatCycleUnit") != m.end() && !m["RepeatCycleUnit"].empty()) {
repeatCycleUnit = make_shared<long>(boost::any_cast<long>(m["RepeatCycleUnit"]));
}
if (m.find("RepeatTimes") != m.end() && !m["RepeatTimes"].empty()) {
repeatTimes = make_shared<long>(boost::any_cast<long>(m["RepeatTimes"]));
}
if (m.find("SignName") != m.end() && !m["SignName"].empty()) {
signName = make_shared<string>(boost::any_cast<string>(m["SignName"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("TemplateId") != m.end() && !m["TemplateId"].empty()) {
templateId = make_shared<string>(boost::any_cast<string>(m["TemplateId"]));
}
}
virtual ~CreateScheduleRequest() = default;
};
class CreateScheduleResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<long> endTime{};
shared_ptr<string> executeTime{};
shared_ptr<string> groupId{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<long> repeatCycle{};
shared_ptr<long> repeatCycleUnit{};
shared_ptr<long> repeatTimes{};
shared_ptr<string> signName{};
shared_ptr<string> signatureId{};
shared_ptr<long> status{};
shared_ptr<string> templateCode{};
shared_ptr<string> templateId{};
shared_ptr<string> updatedTime{};
CreateScheduleResponseBodyData() {}
explicit CreateScheduleResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (endTime) {
res["EndTime"] = boost::any(*endTime);
}
if (executeTime) {
res["ExecuteTime"] = boost::any(*executeTime);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (repeatCycle) {
res["RepeatCycle"] = boost::any(*repeatCycle);
}
if (repeatCycleUnit) {
res["RepeatCycleUnit"] = boost::any(*repeatCycleUnit);
}
if (repeatTimes) {
res["RepeatTimes"] = boost::any(*repeatTimes);
}
if (signName) {
res["SignName"] = boost::any(*signName);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (templateId) {
res["TemplateId"] = boost::any(*templateId);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("EndTime") != m.end() && !m["EndTime"].empty()) {
endTime = make_shared<long>(boost::any_cast<long>(m["EndTime"]));
}
if (m.find("ExecuteTime") != m.end() && !m["ExecuteTime"].empty()) {
executeTime = make_shared<string>(boost::any_cast<string>(m["ExecuteTime"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("RepeatCycle") != m.end() && !m["RepeatCycle"].empty()) {
repeatCycle = make_shared<long>(boost::any_cast<long>(m["RepeatCycle"]));
}
if (m.find("RepeatCycleUnit") != m.end() && !m["RepeatCycleUnit"].empty()) {
repeatCycleUnit = make_shared<long>(boost::any_cast<long>(m["RepeatCycleUnit"]));
}
if (m.find("RepeatTimes") != m.end() && !m["RepeatTimes"].empty()) {
repeatTimes = make_shared<long>(boost::any_cast<long>(m["RepeatTimes"]));
}
if (m.find("SignName") != m.end() && !m["SignName"].empty()) {
signName = make_shared<string>(boost::any_cast<string>(m["SignName"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("TemplateId") != m.end() && !m["TemplateId"].empty()) {
templateId = make_shared<string>(boost::any_cast<string>(m["TemplateId"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~CreateScheduleResponseBodyData() = default;
};
class CreateScheduleResponseBody : public Darabonba::Model {
public:
shared_ptr<CreateScheduleResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
CreateScheduleResponseBody() {}
explicit CreateScheduleResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
CreateScheduleResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<CreateScheduleResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~CreateScheduleResponseBody() = default;
};
class CreateScheduleResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<CreateScheduleResponseBody> body{};
CreateScheduleResponse() {}
explicit CreateScheduleResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
CreateScheduleResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<CreateScheduleResponseBody>(model1);
}
}
}
virtual ~CreateScheduleResponse() = default;
};
class CreateSignatureRequest : public Darabonba::Model {
public:
shared_ptr<string> description{};
shared_ptr<string> name{};
CreateSignatureRequest() {}
explicit CreateSignatureRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (description) {
res["Description"] = boost::any(*description);
}
if (name) {
res["Name"] = boost::any(*name);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Description") != m.end() && !m["Description"].empty()) {
description = make_shared<string>(boost::any_cast<string>(m["Description"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
}
virtual ~CreateSignatureRequest() = default;
};
class CreateSignatureResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<long> status{};
shared_ptr<string> updatedTime{};
CreateSignatureResponseBodyData() {}
explicit CreateSignatureResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~CreateSignatureResponseBodyData() = default;
};
class CreateSignatureResponseBody : public Darabonba::Model {
public:
shared_ptr<CreateSignatureResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
CreateSignatureResponseBody() {}
explicit CreateSignatureResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
CreateSignatureResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<CreateSignatureResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~CreateSignatureResponseBody() = default;
};
class CreateSignatureResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<CreateSignatureResponseBody> body{};
CreateSignatureResponse() {}
explicit CreateSignatureResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
CreateSignatureResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<CreateSignatureResponseBody>(model1);
}
}
}
virtual ~CreateSignatureResponse() = default;
};
class CreateTemplateRequest : public Darabonba::Model {
public:
shared_ptr<string> content{};
shared_ptr<string> description{};
shared_ptr<string> name{};
shared_ptr<string> signature{};
shared_ptr<string> signatureId{};
shared_ptr<long> type{};
CreateTemplateRequest() {}
explicit CreateTemplateRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (content) {
res["Content"] = boost::any(*content);
}
if (description) {
res["Description"] = boost::any(*description);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (signature) {
res["Signature"] = boost::any(*signature);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (type) {
res["Type"] = boost::any(*type);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Content") != m.end() && !m["Content"].empty()) {
content = make_shared<string>(boost::any_cast<string>(m["Content"]));
}
if (m.find("Description") != m.end() && !m["Description"].empty()) {
description = make_shared<string>(boost::any_cast<string>(m["Description"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Signature") != m.end() && !m["Signature"].empty()) {
signature = make_shared<string>(boost::any_cast<string>(m["Signature"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("Type") != m.end() && !m["Type"].empty()) {
type = make_shared<long>(boost::any_cast<long>(m["Type"]));
}
}
virtual ~CreateTemplateRequest() = default;
};
class CreateTemplateResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> content{};
shared_ptr<string> createdTime{};
shared_ptr<string> description{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> reason{};
shared_ptr<string> signatureId{};
shared_ptr<long> status{};
shared_ptr<string> templateCode{};
shared_ptr<long> type{};
shared_ptr<string> updatedTime{};
CreateTemplateResponseBodyData() {}
explicit CreateTemplateResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (content) {
res["Content"] = boost::any(*content);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (description) {
res["Description"] = boost::any(*description);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (reason) {
res["Reason"] = boost::any(*reason);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (type) {
res["Type"] = boost::any(*type);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Content") != m.end() && !m["Content"].empty()) {
content = make_shared<string>(boost::any_cast<string>(m["Content"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Description") != m.end() && !m["Description"].empty()) {
description = make_shared<string>(boost::any_cast<string>(m["Description"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Reason") != m.end() && !m["Reason"].empty()) {
reason = make_shared<string>(boost::any_cast<string>(m["Reason"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("Type") != m.end() && !m["Type"].empty()) {
type = make_shared<long>(boost::any_cast<long>(m["Type"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~CreateTemplateResponseBodyData() = default;
};
class CreateTemplateResponseBody : public Darabonba::Model {
public:
shared_ptr<CreateTemplateResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
CreateTemplateResponseBody() {}
explicit CreateTemplateResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
CreateTemplateResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<CreateTemplateResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~CreateTemplateResponseBody() = default;
};
class CreateTemplateResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<CreateTemplateResponseBody> body{};
CreateTemplateResponse() {}
explicit CreateTemplateResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
CreateTemplateResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<CreateTemplateResponseBody>(model1);
}
}
}
virtual ~CreateTemplateResponse() = default;
};
class CreateTrainingJobRequest : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> campaignId{};
shared_ptr<string> dataPath{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<string> userConfig{};
CreateTrainingJobRequest() {}
explicit CreateTrainingJobRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (dataPath) {
res["DataPath"] = boost::any(*dataPath);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (userConfig) {
res["UserConfig"] = boost::any(*userConfig);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("DataPath") != m.end() && !m["DataPath"].empty()) {
dataPath = make_shared<string>(boost::any_cast<string>(m["DataPath"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("UserConfig") != m.end() && !m["UserConfig"].empty()) {
userConfig = make_shared<string>(boost::any_cast<string>(m["UserConfig"]));
}
}
virtual ~CreateTrainingJobRequest() = default;
};
class CreateTrainingJobResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> campaignId{};
shared_ptr<string> createdTime{};
shared_ptr<string> dataPath{};
shared_ptr<string> history{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<long> status{};
shared_ptr<string> updatedTime{};
shared_ptr<string> userConfig{};
CreateTrainingJobResponseBodyData() {}
explicit CreateTrainingJobResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (dataPath) {
res["DataPath"] = boost::any(*dataPath);
}
if (history) {
res["History"] = boost::any(*history);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (userConfig) {
res["UserConfig"] = boost::any(*userConfig);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("DataPath") != m.end() && !m["DataPath"].empty()) {
dataPath = make_shared<string>(boost::any_cast<string>(m["DataPath"]));
}
if (m.find("History") != m.end() && !m["History"].empty()) {
history = make_shared<string>(boost::any_cast<string>(m["History"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("UserConfig") != m.end() && !m["UserConfig"].empty()) {
userConfig = make_shared<string>(boost::any_cast<string>(m["UserConfig"]));
}
}
virtual ~CreateTrainingJobResponseBodyData() = default;
};
class CreateTrainingJobResponseBody : public Darabonba::Model {
public:
shared_ptr<CreateTrainingJobResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
CreateTrainingJobResponseBody() {}
explicit CreateTrainingJobResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
CreateTrainingJobResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<CreateTrainingJobResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~CreateTrainingJobResponseBody() = default;
};
class CreateTrainingJobResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<CreateTrainingJobResponseBody> body{};
CreateTrainingJobResponse() {}
explicit CreateTrainingJobResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
CreateTrainingJobResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<CreateTrainingJobResponseBody>(model1);
}
}
}
virtual ~CreateTrainingJobResponse() = default;
};
class DeleteCampaignResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
DeleteCampaignResponseBody() {}
explicit DeleteCampaignResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~DeleteCampaignResponseBody() = default;
};
class DeleteCampaignResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<DeleteCampaignResponseBody> body{};
DeleteCampaignResponse() {}
explicit DeleteCampaignResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
DeleteCampaignResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<DeleteCampaignResponseBody>(model1);
}
}
}
virtual ~DeleteCampaignResponse() = default;
};
class DeleteGroupResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
DeleteGroupResponseBody() {}
explicit DeleteGroupResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~DeleteGroupResponseBody() = default;
};
class DeleteGroupResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<DeleteGroupResponseBody> body{};
DeleteGroupResponse() {}
explicit DeleteGroupResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
DeleteGroupResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<DeleteGroupResponseBody>(model1);
}
}
}
virtual ~DeleteGroupResponse() = default;
};
class DeleteInferenceJobResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
DeleteInferenceJobResponseBody() {}
explicit DeleteInferenceJobResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~DeleteInferenceJobResponseBody() = default;
};
class DeleteInferenceJobResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<DeleteInferenceJobResponseBody> body{};
DeleteInferenceJobResponse() {}
explicit DeleteInferenceJobResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
DeleteInferenceJobResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<DeleteInferenceJobResponseBody>(model1);
}
}
}
virtual ~DeleteInferenceJobResponse() = default;
};
class DeleteScheduleResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
DeleteScheduleResponseBody() {}
explicit DeleteScheduleResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~DeleteScheduleResponseBody() = default;
};
class DeleteScheduleResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<DeleteScheduleResponseBody> body{};
DeleteScheduleResponse() {}
explicit DeleteScheduleResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
DeleteScheduleResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<DeleteScheduleResponseBody>(model1);
}
}
}
virtual ~DeleteScheduleResponse() = default;
};
class DeleteSignatureResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
DeleteSignatureResponseBody() {}
explicit DeleteSignatureResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~DeleteSignatureResponseBody() = default;
};
class DeleteSignatureResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<DeleteSignatureResponseBody> body{};
DeleteSignatureResponse() {}
explicit DeleteSignatureResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
DeleteSignatureResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<DeleteSignatureResponseBody>(model1);
}
}
}
virtual ~DeleteSignatureResponse() = default;
};
class DeleteTemplateResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
DeleteTemplateResponseBody() {}
explicit DeleteTemplateResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~DeleteTemplateResponseBody() = default;
};
class DeleteTemplateResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<DeleteTemplateResponseBody> body{};
DeleteTemplateResponse() {}
explicit DeleteTemplateResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
DeleteTemplateResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<DeleteTemplateResponseBody>(model1);
}
}
}
virtual ~DeleteTemplateResponse() = default;
};
class DeleteTrainingJobResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
DeleteTrainingJobResponseBody() {}
explicit DeleteTrainingJobResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~DeleteTrainingJobResponseBody() = default;
};
class DeleteTrainingJobResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<DeleteTrainingJobResponseBody> body{};
DeleteTrainingJobResponse() {}
explicit DeleteTrainingJobResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
DeleteTrainingJobResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<DeleteTrainingJobResponseBody>(model1);
}
}
}
virtual ~DeleteTrainingJobResponse() = default;
};
class GetAlgorithmResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> description{};
shared_ptr<string> id{};
shared_ptr<string> inferUserConfigMap{};
shared_ptr<string> name{};
shared_ptr<string> trainUserConfigMap{};
GetAlgorithmResponseBodyData() {}
explicit GetAlgorithmResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (description) {
res["Description"] = boost::any(*description);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (inferUserConfigMap) {
res["InferUserConfigMap"] = boost::any(*inferUserConfigMap);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (trainUserConfigMap) {
res["TrainUserConfigMap"] = boost::any(*trainUserConfigMap);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Description") != m.end() && !m["Description"].empty()) {
description = make_shared<string>(boost::any_cast<string>(m["Description"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("InferUserConfigMap") != m.end() && !m["InferUserConfigMap"].empty()) {
inferUserConfigMap = make_shared<string>(boost::any_cast<string>(m["InferUserConfigMap"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("TrainUserConfigMap") != m.end() && !m["TrainUserConfigMap"].empty()) {
trainUserConfigMap = make_shared<string>(boost::any_cast<string>(m["TrainUserConfigMap"]));
}
}
virtual ~GetAlgorithmResponseBodyData() = default;
};
class GetAlgorithmResponseBody : public Darabonba::Model {
public:
shared_ptr<GetAlgorithmResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetAlgorithmResponseBody() {}
explicit GetAlgorithmResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetAlgorithmResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetAlgorithmResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetAlgorithmResponseBody() = default;
};
class GetAlgorithmResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetAlgorithmResponseBody> body{};
GetAlgorithmResponse() {}
explicit GetAlgorithmResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetAlgorithmResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetAlgorithmResponseBody>(model1);
}
}
}
virtual ~GetAlgorithmResponse() = default;
};
class GetCampaignResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<string> updatedTime{};
GetCampaignResponseBodyData() {}
explicit GetCampaignResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~GetCampaignResponseBodyData() = default;
};
class GetCampaignResponseBody : public Darabonba::Model {
public:
shared_ptr<GetCampaignResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetCampaignResponseBody() {}
explicit GetCampaignResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetCampaignResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetCampaignResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetCampaignResponseBody() = default;
};
class GetCampaignResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetCampaignResponseBody> body{};
GetCampaignResponse() {}
explicit GetCampaignResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetCampaignResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetCampaignResponseBody>(model1);
}
}
}
virtual ~GetCampaignResponse() = default;
};
class GetGroupResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<long> amount{};
shared_ptr<string> column{};
shared_ptr<string> createdTime{};
shared_ptr<string> filter{};
shared_ptr<string> id{};
shared_ptr<string> inferenceJobId{};
shared_ptr<string> name{};
shared_ptr<bool> phoneNumber{};
shared_ptr<string> project{};
shared_ptr<string> remark{};
shared_ptr<long> source{};
shared_ptr<long> status{};
shared_ptr<string> table{};
shared_ptr<string> text{};
shared_ptr<string> updatedTime{};
shared_ptr<string> uri{};
GetGroupResponseBodyData() {}
explicit GetGroupResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (amount) {
res["Amount"] = boost::any(*amount);
}
if (column) {
res["Column"] = boost::any(*column);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (filter) {
res["Filter"] = boost::any(*filter);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (inferenceJobId) {
res["InferenceJobId"] = boost::any(*inferenceJobId);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (phoneNumber) {
res["PhoneNumber"] = boost::any(*phoneNumber);
}
if (project) {
res["Project"] = boost::any(*project);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (source) {
res["Source"] = boost::any(*source);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (table) {
res["Table"] = boost::any(*table);
}
if (text) {
res["Text"] = boost::any(*text);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (uri) {
res["Uri"] = boost::any(*uri);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("Amount") != m.end() && !m["Amount"].empty()) {
amount = make_shared<long>(boost::any_cast<long>(m["Amount"]));
}
if (m.find("Column") != m.end() && !m["Column"].empty()) {
column = make_shared<string>(boost::any_cast<string>(m["Column"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Filter") != m.end() && !m["Filter"].empty()) {
filter = make_shared<string>(boost::any_cast<string>(m["Filter"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("InferenceJobId") != m.end() && !m["InferenceJobId"].empty()) {
inferenceJobId = make_shared<string>(boost::any_cast<string>(m["InferenceJobId"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PhoneNumber") != m.end() && !m["PhoneNumber"].empty()) {
phoneNumber = make_shared<bool>(boost::any_cast<bool>(m["PhoneNumber"]));
}
if (m.find("Project") != m.end() && !m["Project"].empty()) {
project = make_shared<string>(boost::any_cast<string>(m["Project"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Source") != m.end() && !m["Source"].empty()) {
source = make_shared<long>(boost::any_cast<long>(m["Source"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("Table") != m.end() && !m["Table"].empty()) {
table = make_shared<string>(boost::any_cast<string>(m["Table"]));
}
if (m.find("Text") != m.end() && !m["Text"].empty()) {
text = make_shared<string>(boost::any_cast<string>(m["Text"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("Uri") != m.end() && !m["Uri"].empty()) {
uri = make_shared<string>(boost::any_cast<string>(m["Uri"]));
}
}
virtual ~GetGroupResponseBodyData() = default;
};
class GetGroupResponseBody : public Darabonba::Model {
public:
shared_ptr<GetGroupResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetGroupResponseBody() {}
explicit GetGroupResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetGroupResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetGroupResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetGroupResponseBody() = default;
};
class GetGroupResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetGroupResponseBody> body{};
GetGroupResponse() {}
explicit GetGroupResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetGroupResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetGroupResponseBody>(model1);
}
}
}
virtual ~GetGroupResponse() = default;
};
class GetInferenceJobResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> campaignId{};
shared_ptr<string> createdTime{};
shared_ptr<string> dataPath{};
shared_ptr<string> groupId{};
shared_ptr<string> history{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<long> status{};
shared_ptr<string> targetPath{};
shared_ptr<string> trainingJobId{};
shared_ptr<string> updatedTime{};
shared_ptr<string> userConfig{};
GetInferenceJobResponseBodyData() {}
explicit GetInferenceJobResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (dataPath) {
res["DataPath"] = boost::any(*dataPath);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (history) {
res["History"] = boost::any(*history);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (targetPath) {
res["TargetPath"] = boost::any(*targetPath);
}
if (trainingJobId) {
res["TrainingJobId"] = boost::any(*trainingJobId);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (userConfig) {
res["UserConfig"] = boost::any(*userConfig);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("DataPath") != m.end() && !m["DataPath"].empty()) {
dataPath = make_shared<string>(boost::any_cast<string>(m["DataPath"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("History") != m.end() && !m["History"].empty()) {
history = make_shared<string>(boost::any_cast<string>(m["History"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TargetPath") != m.end() && !m["TargetPath"].empty()) {
targetPath = make_shared<string>(boost::any_cast<string>(m["TargetPath"]));
}
if (m.find("TrainingJobId") != m.end() && !m["TrainingJobId"].empty()) {
trainingJobId = make_shared<string>(boost::any_cast<string>(m["TrainingJobId"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("UserConfig") != m.end() && !m["UserConfig"].empty()) {
userConfig = make_shared<string>(boost::any_cast<string>(m["UserConfig"]));
}
}
virtual ~GetInferenceJobResponseBodyData() = default;
};
class GetInferenceJobResponseBody : public Darabonba::Model {
public:
shared_ptr<GetInferenceJobResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetInferenceJobResponseBody() {}
explicit GetInferenceJobResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetInferenceJobResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetInferenceJobResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetInferenceJobResponseBody() = default;
};
class GetInferenceJobResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetInferenceJobResponseBody> body{};
GetInferenceJobResponse() {}
explicit GetInferenceJobResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetInferenceJobResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetInferenceJobResponseBody>(model1);
}
}
}
virtual ~GetInferenceJobResponse() = default;
};
class GetMessageConfigResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> smsReportUrl{};
shared_ptr<string> smsUpUrl{};
GetMessageConfigResponseBodyData() {}
explicit GetMessageConfigResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (smsReportUrl) {
res["SmsReportUrl"] = boost::any(*smsReportUrl);
}
if (smsUpUrl) {
res["SmsUpUrl"] = boost::any(*smsUpUrl);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("SmsReportUrl") != m.end() && !m["SmsReportUrl"].empty()) {
smsReportUrl = make_shared<string>(boost::any_cast<string>(m["SmsReportUrl"]));
}
if (m.find("SmsUpUrl") != m.end() && !m["SmsUpUrl"].empty()) {
smsUpUrl = make_shared<string>(boost::any_cast<string>(m["SmsUpUrl"]));
}
}
virtual ~GetMessageConfigResponseBodyData() = default;
};
class GetMessageConfigResponseBody : public Darabonba::Model {
public:
shared_ptr<GetMessageConfigResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetMessageConfigResponseBody() {}
explicit GetMessageConfigResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetMessageConfigResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetMessageConfigResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetMessageConfigResponseBody() = default;
};
class GetMessageConfigResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetMessageConfigResponseBody> body{};
GetMessageConfigResponse() {}
explicit GetMessageConfigResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetMessageConfigResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetMessageConfigResponseBody>(model1);
}
}
}
virtual ~GetMessageConfigResponse() = default;
};
class GetScheduleResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<long> endTime{};
shared_ptr<string> executeTime{};
shared_ptr<string> groupId{};
shared_ptr<string> history{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<long> repeatCycle{};
shared_ptr<long> repeatCycleUnit{};
shared_ptr<long> repeatTimes{};
shared_ptr<string> signName{};
shared_ptr<string> signatureId{};
shared_ptr<long> status{};
shared_ptr<string> templateCode{};
shared_ptr<string> templateId{};
shared_ptr<string> updatedTime{};
GetScheduleResponseBodyData() {}
explicit GetScheduleResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (endTime) {
res["EndTime"] = boost::any(*endTime);
}
if (executeTime) {
res["ExecuteTime"] = boost::any(*executeTime);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (history) {
res["History"] = boost::any(*history);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (repeatCycle) {
res["RepeatCycle"] = boost::any(*repeatCycle);
}
if (repeatCycleUnit) {
res["RepeatCycleUnit"] = boost::any(*repeatCycleUnit);
}
if (repeatTimes) {
res["RepeatTimes"] = boost::any(*repeatTimes);
}
if (signName) {
res["SignName"] = boost::any(*signName);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (templateId) {
res["TemplateId"] = boost::any(*templateId);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("EndTime") != m.end() && !m["EndTime"].empty()) {
endTime = make_shared<long>(boost::any_cast<long>(m["EndTime"]));
}
if (m.find("ExecuteTime") != m.end() && !m["ExecuteTime"].empty()) {
executeTime = make_shared<string>(boost::any_cast<string>(m["ExecuteTime"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("History") != m.end() && !m["History"].empty()) {
history = make_shared<string>(boost::any_cast<string>(m["History"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("RepeatCycle") != m.end() && !m["RepeatCycle"].empty()) {
repeatCycle = make_shared<long>(boost::any_cast<long>(m["RepeatCycle"]));
}
if (m.find("RepeatCycleUnit") != m.end() && !m["RepeatCycleUnit"].empty()) {
repeatCycleUnit = make_shared<long>(boost::any_cast<long>(m["RepeatCycleUnit"]));
}
if (m.find("RepeatTimes") != m.end() && !m["RepeatTimes"].empty()) {
repeatTimes = make_shared<long>(boost::any_cast<long>(m["RepeatTimes"]));
}
if (m.find("SignName") != m.end() && !m["SignName"].empty()) {
signName = make_shared<string>(boost::any_cast<string>(m["SignName"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("TemplateId") != m.end() && !m["TemplateId"].empty()) {
templateId = make_shared<string>(boost::any_cast<string>(m["TemplateId"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~GetScheduleResponseBodyData() = default;
};
class GetScheduleResponseBody : public Darabonba::Model {
public:
shared_ptr<GetScheduleResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetScheduleResponseBody() {}
explicit GetScheduleResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetScheduleResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetScheduleResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetScheduleResponseBody() = default;
};
class GetScheduleResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetScheduleResponseBody> body{};
GetScheduleResponse() {}
explicit GetScheduleResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetScheduleResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetScheduleResponseBody>(model1);
}
}
}
virtual ~GetScheduleResponse() = default;
};
class GetSignatureResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<string> description{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> reason{};
shared_ptr<long> status{};
shared_ptr<string> updatedTime{};
GetSignatureResponseBodyData() {}
explicit GetSignatureResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (description) {
res["Description"] = boost::any(*description);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (reason) {
res["Reason"] = boost::any(*reason);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Description") != m.end() && !m["Description"].empty()) {
description = make_shared<string>(boost::any_cast<string>(m["Description"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Reason") != m.end() && !m["Reason"].empty()) {
reason = make_shared<string>(boost::any_cast<string>(m["Reason"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~GetSignatureResponseBodyData() = default;
};
class GetSignatureResponseBody : public Darabonba::Model {
public:
shared_ptr<GetSignatureResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetSignatureResponseBody() {}
explicit GetSignatureResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetSignatureResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetSignatureResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetSignatureResponseBody() = default;
};
class GetSignatureResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetSignatureResponseBody> body{};
GetSignatureResponse() {}
explicit GetSignatureResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetSignatureResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetSignatureResponseBody>(model1);
}
}
}
virtual ~GetSignatureResponse() = default;
};
class GetTemplateResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> content{};
shared_ptr<string> createdTime{};
shared_ptr<string> description{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> reason{};
shared_ptr<string> signatureId{};
shared_ptr<long> status{};
shared_ptr<string> templateCode{};
shared_ptr<long> type{};
shared_ptr<string> updatedTime{};
GetTemplateResponseBodyData() {}
explicit GetTemplateResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (content) {
res["Content"] = boost::any(*content);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (description) {
res["Description"] = boost::any(*description);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (reason) {
res["Reason"] = boost::any(*reason);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (type) {
res["Type"] = boost::any(*type);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Content") != m.end() && !m["Content"].empty()) {
content = make_shared<string>(boost::any_cast<string>(m["Content"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Description") != m.end() && !m["Description"].empty()) {
description = make_shared<string>(boost::any_cast<string>(m["Description"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Reason") != m.end() && !m["Reason"].empty()) {
reason = make_shared<string>(boost::any_cast<string>(m["Reason"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("Type") != m.end() && !m["Type"].empty()) {
type = make_shared<long>(boost::any_cast<long>(m["Type"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~GetTemplateResponseBodyData() = default;
};
class GetTemplateResponseBody : public Darabonba::Model {
public:
shared_ptr<GetTemplateResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetTemplateResponseBody() {}
explicit GetTemplateResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetTemplateResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetTemplateResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetTemplateResponseBody() = default;
};
class GetTemplateResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetTemplateResponseBody> body{};
GetTemplateResponse() {}
explicit GetTemplateResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetTemplateResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetTemplateResponseBody>(model1);
}
}
}
virtual ~GetTemplateResponse() = default;
};
class GetTrainingJobResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> campaignId{};
shared_ptr<string> createdTime{};
shared_ptr<string> dataPath{};
shared_ptr<string> history{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<long> status{};
shared_ptr<string> updatedTime{};
shared_ptr<string> userConfig{};
GetTrainingJobResponseBodyData() {}
explicit GetTrainingJobResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (dataPath) {
res["DataPath"] = boost::any(*dataPath);
}
if (history) {
res["History"] = boost::any(*history);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (userConfig) {
res["UserConfig"] = boost::any(*userConfig);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("DataPath") != m.end() && !m["DataPath"].empty()) {
dataPath = make_shared<string>(boost::any_cast<string>(m["DataPath"]));
}
if (m.find("History") != m.end() && !m["History"].empty()) {
history = make_shared<string>(boost::any_cast<string>(m["History"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("UserConfig") != m.end() && !m["UserConfig"].empty()) {
userConfig = make_shared<string>(boost::any_cast<string>(m["UserConfig"]));
}
}
virtual ~GetTrainingJobResponseBodyData() = default;
};
class GetTrainingJobResponseBody : public Darabonba::Model {
public:
shared_ptr<GetTrainingJobResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetTrainingJobResponseBody() {}
explicit GetTrainingJobResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetTrainingJobResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetTrainingJobResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetTrainingJobResponseBody() = default;
};
class GetTrainingJobResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetTrainingJobResponseBody> body{};
GetTrainingJobResponse() {}
explicit GetTrainingJobResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetTrainingJobResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetTrainingJobResponseBody>(model1);
}
}
}
virtual ~GetTrainingJobResponse() = default;
};
class GetUserResponseBodyData : public Darabonba::Model {
public:
shared_ptr<long> accountStatus{};
GetUserResponseBodyData() {}
explicit GetUserResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (accountStatus) {
res["AccountStatus"] = boost::any(*accountStatus);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("AccountStatus") != m.end() && !m["AccountStatus"].empty()) {
accountStatus = make_shared<long>(boost::any_cast<long>(m["AccountStatus"]));
}
}
virtual ~GetUserResponseBodyData() = default;
};
class GetUserResponseBody : public Darabonba::Model {
public:
shared_ptr<GetUserResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
GetUserResponseBody() {}
explicit GetUserResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
GetUserResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<GetUserResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~GetUserResponseBody() = default;
};
class GetUserResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<GetUserResponseBody> body{};
GetUserResponse() {}
explicit GetUserResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
GetUserResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<GetUserResponseBody>(model1);
}
}
}
virtual ~GetUserResponse() = default;
};
class ListAlgorithmsRequest : public Darabonba::Model {
public:
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
ListAlgorithmsRequest() {}
explicit ListAlgorithmsRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
}
virtual ~ListAlgorithmsRequest() = default;
};
class ListAlgorithmsResponseBodyDataAlgorithms : public Darabonba::Model {
public:
shared_ptr<string> id{};
shared_ptr<string> name{};
ListAlgorithmsResponseBodyDataAlgorithms() {}
explicit ListAlgorithmsResponseBodyDataAlgorithms(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
}
virtual ~ListAlgorithmsResponseBodyDataAlgorithms() = default;
};
class ListAlgorithmsResponseBodyData : public Darabonba::Model {
public:
shared_ptr<vector<ListAlgorithmsResponseBodyDataAlgorithms>> algorithms{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> totalCount{};
ListAlgorithmsResponseBodyData() {}
explicit ListAlgorithmsResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithms) {
vector<boost::any> temp1;
for(auto item1:*algorithms){
temp1.push_back(boost::any(item1.toMap()));
}
res["Algorithms"] = boost::any(temp1);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithms") != m.end() && !m["Algorithms"].empty()) {
if (typeid(vector<boost::any>) == m["Algorithms"].type()) {
vector<ListAlgorithmsResponseBodyDataAlgorithms> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Algorithms"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListAlgorithmsResponseBodyDataAlgorithms model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
algorithms = make_shared<vector<ListAlgorithmsResponseBodyDataAlgorithms>>(expect1);
}
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListAlgorithmsResponseBodyData() = default;
};
class ListAlgorithmsResponseBody : public Darabonba::Model {
public:
shared_ptr<ListAlgorithmsResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListAlgorithmsResponseBody() {}
explicit ListAlgorithmsResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListAlgorithmsResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListAlgorithmsResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListAlgorithmsResponseBody() = default;
};
class ListAlgorithmsResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListAlgorithmsResponseBody> body{};
ListAlgorithmsResponse() {}
explicit ListAlgorithmsResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListAlgorithmsResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListAlgorithmsResponseBody>(model1);
}
}
}
virtual ~ListAlgorithmsResponse() = default;
};
class ListCampaignsRequest : public Darabonba::Model {
public:
shared_ptr<string> name{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<string> remark{};
ListCampaignsRequest() {}
explicit ListCampaignsRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (name) {
res["Name"] = boost::any(*name);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
}
virtual ~ListCampaignsRequest() = default;
};
class ListCampaignsResponseBodyDataCampaigns : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<string> updatedTime{};
ListCampaignsResponseBodyDataCampaigns() {}
explicit ListCampaignsResponseBodyDataCampaigns(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~ListCampaignsResponseBodyDataCampaigns() = default;
};
class ListCampaignsResponseBodyData : public Darabonba::Model {
public:
shared_ptr<vector<ListCampaignsResponseBodyDataCampaigns>> campaigns{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> totalCount{};
ListCampaignsResponseBodyData() {}
explicit ListCampaignsResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (campaigns) {
vector<boost::any> temp1;
for(auto item1:*campaigns){
temp1.push_back(boost::any(item1.toMap()));
}
res["Campaigns"] = boost::any(temp1);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Campaigns") != m.end() && !m["Campaigns"].empty()) {
if (typeid(vector<boost::any>) == m["Campaigns"].type()) {
vector<ListCampaignsResponseBodyDataCampaigns> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Campaigns"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListCampaignsResponseBodyDataCampaigns model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
campaigns = make_shared<vector<ListCampaignsResponseBodyDataCampaigns>>(expect1);
}
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListCampaignsResponseBodyData() = default;
};
class ListCampaignsResponseBody : public Darabonba::Model {
public:
shared_ptr<ListCampaignsResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListCampaignsResponseBody() {}
explicit ListCampaignsResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListCampaignsResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListCampaignsResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListCampaignsResponseBody() = default;
};
class ListCampaignsResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListCampaignsResponseBody> body{};
ListCampaignsResponse() {}
explicit ListCampaignsResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListCampaignsResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListCampaignsResponseBody>(model1);
}
}
}
virtual ~ListCampaignsResponse() = default;
};
class ListGroupsRequest : public Darabonba::Model {
public:
shared_ptr<string> name{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<bool> phoneNumber{};
shared_ptr<string> remark{};
shared_ptr<long> source{};
shared_ptr<long> status{};
ListGroupsRequest() {}
explicit ListGroupsRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (name) {
res["Name"] = boost::any(*name);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (phoneNumber) {
res["PhoneNumber"] = boost::any(*phoneNumber);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (source) {
res["Source"] = boost::any(*source);
}
if (status) {
res["Status"] = boost::any(*status);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("PhoneNumber") != m.end() && !m["PhoneNumber"].empty()) {
phoneNumber = make_shared<bool>(boost::any_cast<bool>(m["PhoneNumber"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Source") != m.end() && !m["Source"].empty()) {
source = make_shared<long>(boost::any_cast<long>(m["Source"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
}
virtual ~ListGroupsRequest() = default;
};
class ListGroupsResponseBodyDataGroups : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<long> amount{};
shared_ptr<string> column{};
shared_ptr<string> createdTime{};
shared_ptr<string> filter{};
shared_ptr<string> id{};
shared_ptr<string> inferenceJobId{};
shared_ptr<string> name{};
shared_ptr<bool> phoneNumber{};
shared_ptr<string> project{};
shared_ptr<string> remark{};
shared_ptr<long> source{};
shared_ptr<long> status{};
shared_ptr<string> table{};
shared_ptr<string> text{};
shared_ptr<string> updatedTime{};
shared_ptr<string> uri{};
ListGroupsResponseBodyDataGroups() {}
explicit ListGroupsResponseBodyDataGroups(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (amount) {
res["Amount"] = boost::any(*amount);
}
if (column) {
res["Column"] = boost::any(*column);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (filter) {
res["Filter"] = boost::any(*filter);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (inferenceJobId) {
res["InferenceJobId"] = boost::any(*inferenceJobId);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (phoneNumber) {
res["PhoneNumber"] = boost::any(*phoneNumber);
}
if (project) {
res["Project"] = boost::any(*project);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (source) {
res["Source"] = boost::any(*source);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (table) {
res["Table"] = boost::any(*table);
}
if (text) {
res["Text"] = boost::any(*text);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (uri) {
res["Uri"] = boost::any(*uri);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("Amount") != m.end() && !m["Amount"].empty()) {
amount = make_shared<long>(boost::any_cast<long>(m["Amount"]));
}
if (m.find("Column") != m.end() && !m["Column"].empty()) {
column = make_shared<string>(boost::any_cast<string>(m["Column"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Filter") != m.end() && !m["Filter"].empty()) {
filter = make_shared<string>(boost::any_cast<string>(m["Filter"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("InferenceJobId") != m.end() && !m["InferenceJobId"].empty()) {
inferenceJobId = make_shared<string>(boost::any_cast<string>(m["InferenceJobId"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PhoneNumber") != m.end() && !m["PhoneNumber"].empty()) {
phoneNumber = make_shared<bool>(boost::any_cast<bool>(m["PhoneNumber"]));
}
if (m.find("Project") != m.end() && !m["Project"].empty()) {
project = make_shared<string>(boost::any_cast<string>(m["Project"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Source") != m.end() && !m["Source"].empty()) {
source = make_shared<long>(boost::any_cast<long>(m["Source"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("Table") != m.end() && !m["Table"].empty()) {
table = make_shared<string>(boost::any_cast<string>(m["Table"]));
}
if (m.find("Text") != m.end() && !m["Text"].empty()) {
text = make_shared<string>(boost::any_cast<string>(m["Text"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("Uri") != m.end() && !m["Uri"].empty()) {
uri = make_shared<string>(boost::any_cast<string>(m["Uri"]));
}
}
virtual ~ListGroupsResponseBodyDataGroups() = default;
};
class ListGroupsResponseBodyData : public Darabonba::Model {
public:
shared_ptr<vector<ListGroupsResponseBodyDataGroups>> groups{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> totalCount{};
ListGroupsResponseBodyData() {}
explicit ListGroupsResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (groups) {
vector<boost::any> temp1;
for(auto item1:*groups){
temp1.push_back(boost::any(item1.toMap()));
}
res["Groups"] = boost::any(temp1);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Groups") != m.end() && !m["Groups"].empty()) {
if (typeid(vector<boost::any>) == m["Groups"].type()) {
vector<ListGroupsResponseBodyDataGroups> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Groups"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListGroupsResponseBodyDataGroups model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
groups = make_shared<vector<ListGroupsResponseBodyDataGroups>>(expect1);
}
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListGroupsResponseBodyData() = default;
};
class ListGroupsResponseBody : public Darabonba::Model {
public:
shared_ptr<ListGroupsResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListGroupsResponseBody() {}
explicit ListGroupsResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListGroupsResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListGroupsResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListGroupsResponseBody() = default;
};
class ListGroupsResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListGroupsResponseBody> body{};
ListGroupsResponse() {}
explicit ListGroupsResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListGroupsResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListGroupsResponseBody>(model1);
}
}
}
virtual ~ListGroupsResponse() = default;
};
class ListInferenceJobsRequest : public Darabonba::Model {
public:
shared_ptr<string> campaignId{};
shared_ptr<string> name{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<string> remark{};
shared_ptr<long> status{};
ListInferenceJobsRequest() {}
explicit ListInferenceJobsRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (status) {
res["Status"] = boost::any(*status);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
}
virtual ~ListInferenceJobsRequest() = default;
};
class ListInferenceJobsResponseBodyDataInferenceJobs : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> campaignId{};
shared_ptr<string> createdTime{};
shared_ptr<string> dataPath{};
shared_ptr<string> groupId{};
shared_ptr<string> history{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<long> status{};
shared_ptr<string> targetPath{};
shared_ptr<string> trainingJobId{};
shared_ptr<string> updatedTime{};
shared_ptr<string> userConfig{};
ListInferenceJobsResponseBodyDataInferenceJobs() {}
explicit ListInferenceJobsResponseBodyDataInferenceJobs(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (dataPath) {
res["DataPath"] = boost::any(*dataPath);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (history) {
res["History"] = boost::any(*history);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (targetPath) {
res["TargetPath"] = boost::any(*targetPath);
}
if (trainingJobId) {
res["TrainingJobId"] = boost::any(*trainingJobId);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (userConfig) {
res["UserConfig"] = boost::any(*userConfig);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("DataPath") != m.end() && !m["DataPath"].empty()) {
dataPath = make_shared<string>(boost::any_cast<string>(m["DataPath"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("History") != m.end() && !m["History"].empty()) {
history = make_shared<string>(boost::any_cast<string>(m["History"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TargetPath") != m.end() && !m["TargetPath"].empty()) {
targetPath = make_shared<string>(boost::any_cast<string>(m["TargetPath"]));
}
if (m.find("TrainingJobId") != m.end() && !m["TrainingJobId"].empty()) {
trainingJobId = make_shared<string>(boost::any_cast<string>(m["TrainingJobId"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("UserConfig") != m.end() && !m["UserConfig"].empty()) {
userConfig = make_shared<string>(boost::any_cast<string>(m["UserConfig"]));
}
}
virtual ~ListInferenceJobsResponseBodyDataInferenceJobs() = default;
};
class ListInferenceJobsResponseBodyData : public Darabonba::Model {
public:
shared_ptr<vector<ListInferenceJobsResponseBodyDataInferenceJobs>> inferenceJobs{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> totalCount{};
ListInferenceJobsResponseBodyData() {}
explicit ListInferenceJobsResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (inferenceJobs) {
vector<boost::any> temp1;
for(auto item1:*inferenceJobs){
temp1.push_back(boost::any(item1.toMap()));
}
res["InferenceJobs"] = boost::any(temp1);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("InferenceJobs") != m.end() && !m["InferenceJobs"].empty()) {
if (typeid(vector<boost::any>) == m["InferenceJobs"].type()) {
vector<ListInferenceJobsResponseBodyDataInferenceJobs> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["InferenceJobs"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListInferenceJobsResponseBodyDataInferenceJobs model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
inferenceJobs = make_shared<vector<ListInferenceJobsResponseBodyDataInferenceJobs>>(expect1);
}
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListInferenceJobsResponseBodyData() = default;
};
class ListInferenceJobsResponseBody : public Darabonba::Model {
public:
shared_ptr<ListInferenceJobsResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListInferenceJobsResponseBody() {}
explicit ListInferenceJobsResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListInferenceJobsResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListInferenceJobsResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListInferenceJobsResponseBody() = default;
};
class ListInferenceJobsResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListInferenceJobsResponseBody> body{};
ListInferenceJobsResponse() {}
explicit ListInferenceJobsResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListInferenceJobsResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListInferenceJobsResponseBody>(model1);
}
}
}
virtual ~ListInferenceJobsResponse() = default;
};
class ListMessageMetricsRequest : public Darabonba::Model {
public:
shared_ptr<string> endDate{};
shared_ptr<string> groupId{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<string> scheduleId{};
shared_ptr<string> signature{};
shared_ptr<string> signatureId{};
shared_ptr<string> startDate{};
shared_ptr<string> templateCode{};
shared_ptr<string> templateId{};
shared_ptr<long> templateType{};
ListMessageMetricsRequest() {}
explicit ListMessageMetricsRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (endDate) {
res["EndDate"] = boost::any(*endDate);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (scheduleId) {
res["ScheduleId"] = boost::any(*scheduleId);
}
if (signature) {
res["Signature"] = boost::any(*signature);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (startDate) {
res["StartDate"] = boost::any(*startDate);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (templateId) {
res["TemplateId"] = boost::any(*templateId);
}
if (templateType) {
res["TemplateType"] = boost::any(*templateType);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("EndDate") != m.end() && !m["EndDate"].empty()) {
endDate = make_shared<string>(boost::any_cast<string>(m["EndDate"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("ScheduleId") != m.end() && !m["ScheduleId"].empty()) {
scheduleId = make_shared<string>(boost::any_cast<string>(m["ScheduleId"]));
}
if (m.find("Signature") != m.end() && !m["Signature"].empty()) {
signature = make_shared<string>(boost::any_cast<string>(m["Signature"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("StartDate") != m.end() && !m["StartDate"].empty()) {
startDate = make_shared<string>(boost::any_cast<string>(m["StartDate"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("TemplateId") != m.end() && !m["TemplateId"].empty()) {
templateId = make_shared<string>(boost::any_cast<string>(m["TemplateId"]));
}
if (m.find("TemplateType") != m.end() && !m["TemplateType"].empty()) {
templateType = make_shared<long>(boost::any_cast<long>(m["TemplateType"]));
}
}
virtual ~ListMessageMetricsRequest() = default;
};
class ListMessageMetricsResponseBodyDataMetrics : public Darabonba::Model {
public:
shared_ptr<string> date{};
shared_ptr<long> fail{};
shared_ptr<long> pending{};
shared_ptr<double> rate{};
shared_ptr<long> success{};
shared_ptr<long> total{};
ListMessageMetricsResponseBodyDataMetrics() {}
explicit ListMessageMetricsResponseBodyDataMetrics(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (date) {
res["Date"] = boost::any(*date);
}
if (fail) {
res["Fail"] = boost::any(*fail);
}
if (pending) {
res["Pending"] = boost::any(*pending);
}
if (rate) {
res["Rate"] = boost::any(*rate);
}
if (success) {
res["Success"] = boost::any(*success);
}
if (total) {
res["Total"] = boost::any(*total);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Date") != m.end() && !m["Date"].empty()) {
date = make_shared<string>(boost::any_cast<string>(m["Date"]));
}
if (m.find("Fail") != m.end() && !m["Fail"].empty()) {
fail = make_shared<long>(boost::any_cast<long>(m["Fail"]));
}
if (m.find("Pending") != m.end() && !m["Pending"].empty()) {
pending = make_shared<long>(boost::any_cast<long>(m["Pending"]));
}
if (m.find("Rate") != m.end() && !m["Rate"].empty()) {
rate = make_shared<double>(boost::any_cast<double>(m["Rate"]));
}
if (m.find("Success") != m.end() && !m["Success"].empty()) {
success = make_shared<long>(boost::any_cast<long>(m["Success"]));
}
if (m.find("Total") != m.end() && !m["Total"].empty()) {
total = make_shared<long>(boost::any_cast<long>(m["Total"]));
}
}
virtual ~ListMessageMetricsResponseBodyDataMetrics() = default;
};
class ListMessageMetricsResponseBodyData : public Darabonba::Model {
public:
shared_ptr<vector<ListMessageMetricsResponseBodyDataMetrics>> metrics{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> totalCount{};
ListMessageMetricsResponseBodyData() {}
explicit ListMessageMetricsResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (metrics) {
vector<boost::any> temp1;
for(auto item1:*metrics){
temp1.push_back(boost::any(item1.toMap()));
}
res["Metrics"] = boost::any(temp1);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Metrics") != m.end() && !m["Metrics"].empty()) {
if (typeid(vector<boost::any>) == m["Metrics"].type()) {
vector<ListMessageMetricsResponseBodyDataMetrics> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Metrics"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListMessageMetricsResponseBodyDataMetrics model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
metrics = make_shared<vector<ListMessageMetricsResponseBodyDataMetrics>>(expect1);
}
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListMessageMetricsResponseBodyData() = default;
};
class ListMessageMetricsResponseBody : public Darabonba::Model {
public:
shared_ptr<ListMessageMetricsResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListMessageMetricsResponseBody() {}
explicit ListMessageMetricsResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListMessageMetricsResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListMessageMetricsResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListMessageMetricsResponseBody() = default;
};
class ListMessageMetricsResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListMessageMetricsResponseBody> body{};
ListMessageMetricsResponse() {}
explicit ListMessageMetricsResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListMessageMetricsResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListMessageMetricsResponseBody>(model1);
}
}
}
virtual ~ListMessageMetricsResponse() = default;
};
class ListMessagesRequest : public Darabonba::Model {
public:
shared_ptr<string> datetime{};
shared_ptr<string> errorCode{};
shared_ptr<string> groupId{};
shared_ptr<string> messageId{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<string> phoneNumber{};
shared_ptr<string> requestId{};
shared_ptr<string> scheduleId{};
shared_ptr<string> signature{};
shared_ptr<string> signatureId{};
shared_ptr<long> status{};
shared_ptr<string> templateCode{};
shared_ptr<string> templateId{};
shared_ptr<long> templateType{};
ListMessagesRequest() {}
explicit ListMessagesRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (datetime) {
res["Datetime"] = boost::any(*datetime);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (messageId) {
res["MessageId"] = boost::any(*messageId);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (phoneNumber) {
res["PhoneNumber"] = boost::any(*phoneNumber);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
if (scheduleId) {
res["ScheduleId"] = boost::any(*scheduleId);
}
if (signature) {
res["Signature"] = boost::any(*signature);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (templateId) {
res["TemplateId"] = boost::any(*templateId);
}
if (templateType) {
res["TemplateType"] = boost::any(*templateType);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Datetime") != m.end() && !m["Datetime"].empty()) {
datetime = make_shared<string>(boost::any_cast<string>(m["Datetime"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<string>(boost::any_cast<string>(m["ErrorCode"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("MessageId") != m.end() && !m["MessageId"].empty()) {
messageId = make_shared<string>(boost::any_cast<string>(m["MessageId"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("PhoneNumber") != m.end() && !m["PhoneNumber"].empty()) {
phoneNumber = make_shared<string>(boost::any_cast<string>(m["PhoneNumber"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
if (m.find("ScheduleId") != m.end() && !m["ScheduleId"].empty()) {
scheduleId = make_shared<string>(boost::any_cast<string>(m["ScheduleId"]));
}
if (m.find("Signature") != m.end() && !m["Signature"].empty()) {
signature = make_shared<string>(boost::any_cast<string>(m["Signature"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("TemplateId") != m.end() && !m["TemplateId"].empty()) {
templateId = make_shared<string>(boost::any_cast<string>(m["TemplateId"]));
}
if (m.find("TemplateType") != m.end() && !m["TemplateType"].empty()) {
templateType = make_shared<long>(boost::any_cast<long>(m["TemplateType"]));
}
}
virtual ~ListMessagesRequest() = default;
};
class ListMessagesResponseBodyDataMessages : public Darabonba::Model {
public:
shared_ptr<string> errorCode{};
shared_ptr<string> groupId{};
shared_ptr<string> id{};
shared_ptr<string> outId{};
shared_ptr<string> phoneNumber{};
shared_ptr<string> scheduleId{};
shared_ptr<string> signature{};
shared_ptr<long> status{};
shared_ptr<string> templateCode{};
shared_ptr<string> templateParams{};
shared_ptr<long> templateType{};
ListMessagesResponseBodyDataMessages() {}
explicit ListMessagesResponseBodyDataMessages(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (outId) {
res["OutId"] = boost::any(*outId);
}
if (phoneNumber) {
res["PhoneNumber"] = boost::any(*phoneNumber);
}
if (scheduleId) {
res["ScheduleId"] = boost::any(*scheduleId);
}
if (signature) {
res["Signature"] = boost::any(*signature);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (templateParams) {
res["TemplateParams"] = boost::any(*templateParams);
}
if (templateType) {
res["TemplateType"] = boost::any(*templateType);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<string>(boost::any_cast<string>(m["ErrorCode"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("OutId") != m.end() && !m["OutId"].empty()) {
outId = make_shared<string>(boost::any_cast<string>(m["OutId"]));
}
if (m.find("PhoneNumber") != m.end() && !m["PhoneNumber"].empty()) {
phoneNumber = make_shared<string>(boost::any_cast<string>(m["PhoneNumber"]));
}
if (m.find("ScheduleId") != m.end() && !m["ScheduleId"].empty()) {
scheduleId = make_shared<string>(boost::any_cast<string>(m["ScheduleId"]));
}
if (m.find("Signature") != m.end() && !m["Signature"].empty()) {
signature = make_shared<string>(boost::any_cast<string>(m["Signature"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("TemplateParams") != m.end() && !m["TemplateParams"].empty()) {
templateParams = make_shared<string>(boost::any_cast<string>(m["TemplateParams"]));
}
if (m.find("TemplateType") != m.end() && !m["TemplateType"].empty()) {
templateType = make_shared<long>(boost::any_cast<long>(m["TemplateType"]));
}
}
virtual ~ListMessagesResponseBodyDataMessages() = default;
};
class ListMessagesResponseBodyData : public Darabonba::Model {
public:
shared_ptr<vector<ListMessagesResponseBodyDataMessages>> messages{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> totalCount{};
ListMessagesResponseBodyData() {}
explicit ListMessagesResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (messages) {
vector<boost::any> temp1;
for(auto item1:*messages){
temp1.push_back(boost::any(item1.toMap()));
}
res["Messages"] = boost::any(temp1);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Messages") != m.end() && !m["Messages"].empty()) {
if (typeid(vector<boost::any>) == m["Messages"].type()) {
vector<ListMessagesResponseBodyDataMessages> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Messages"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListMessagesResponseBodyDataMessages model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
messages = make_shared<vector<ListMessagesResponseBodyDataMessages>>(expect1);
}
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListMessagesResponseBodyData() = default;
};
class ListMessagesResponseBody : public Darabonba::Model {
public:
shared_ptr<ListMessagesResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListMessagesResponseBody() {}
explicit ListMessagesResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListMessagesResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListMessagesResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListMessagesResponseBody() = default;
};
class ListMessagesResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListMessagesResponseBody> body{};
ListMessagesResponse() {}
explicit ListMessagesResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListMessagesResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListMessagesResponseBody>(model1);
}
}
}
virtual ~ListMessagesResponse() = default;
};
class ListSchedulesRequest : public Darabonba::Model {
public:
shared_ptr<string> name{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> status{};
ListSchedulesRequest() {}
explicit ListSchedulesRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (name) {
res["Name"] = boost::any(*name);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (status) {
res["Status"] = boost::any(*status);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
}
virtual ~ListSchedulesRequest() = default;
};
class ListSchedulesResponseBodyDataSchedules : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<long> endTime{};
shared_ptr<string> executeTime{};
shared_ptr<string> groupId{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<long> repeatCycle{};
shared_ptr<long> repeatCycleUnit{};
shared_ptr<long> repeatTimes{};
shared_ptr<string> signName{};
shared_ptr<string> signatureId{};
shared_ptr<long> status{};
shared_ptr<string> templateCode{};
shared_ptr<string> templateId{};
shared_ptr<string> updatedTime{};
ListSchedulesResponseBodyDataSchedules() {}
explicit ListSchedulesResponseBodyDataSchedules(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (endTime) {
res["EndTime"] = boost::any(*endTime);
}
if (executeTime) {
res["ExecuteTime"] = boost::any(*executeTime);
}
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (repeatCycle) {
res["RepeatCycle"] = boost::any(*repeatCycle);
}
if (repeatCycleUnit) {
res["RepeatCycleUnit"] = boost::any(*repeatCycleUnit);
}
if (repeatTimes) {
res["RepeatTimes"] = boost::any(*repeatTimes);
}
if (signName) {
res["SignName"] = boost::any(*signName);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (templateId) {
res["TemplateId"] = boost::any(*templateId);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("EndTime") != m.end() && !m["EndTime"].empty()) {
endTime = make_shared<long>(boost::any_cast<long>(m["EndTime"]));
}
if (m.find("ExecuteTime") != m.end() && !m["ExecuteTime"].empty()) {
executeTime = make_shared<string>(boost::any_cast<string>(m["ExecuteTime"]));
}
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("RepeatCycle") != m.end() && !m["RepeatCycle"].empty()) {
repeatCycle = make_shared<long>(boost::any_cast<long>(m["RepeatCycle"]));
}
if (m.find("RepeatCycleUnit") != m.end() && !m["RepeatCycleUnit"].empty()) {
repeatCycleUnit = make_shared<long>(boost::any_cast<long>(m["RepeatCycleUnit"]));
}
if (m.find("RepeatTimes") != m.end() && !m["RepeatTimes"].empty()) {
repeatTimes = make_shared<long>(boost::any_cast<long>(m["RepeatTimes"]));
}
if (m.find("SignName") != m.end() && !m["SignName"].empty()) {
signName = make_shared<string>(boost::any_cast<string>(m["SignName"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("TemplateId") != m.end() && !m["TemplateId"].empty()) {
templateId = make_shared<string>(boost::any_cast<string>(m["TemplateId"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~ListSchedulesResponseBodyDataSchedules() = default;
};
class ListSchedulesResponseBodyData : public Darabonba::Model {
public:
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<vector<ListSchedulesResponseBodyDataSchedules>> schedules{};
shared_ptr<long> totalCount{};
ListSchedulesResponseBodyData() {}
explicit ListSchedulesResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (schedules) {
vector<boost::any> temp1;
for(auto item1:*schedules){
temp1.push_back(boost::any(item1.toMap()));
}
res["Schedules"] = boost::any(temp1);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Schedules") != m.end() && !m["Schedules"].empty()) {
if (typeid(vector<boost::any>) == m["Schedules"].type()) {
vector<ListSchedulesResponseBodyDataSchedules> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Schedules"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListSchedulesResponseBodyDataSchedules model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
schedules = make_shared<vector<ListSchedulesResponseBodyDataSchedules>>(expect1);
}
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListSchedulesResponseBodyData() = default;
};
class ListSchedulesResponseBody : public Darabonba::Model {
public:
shared_ptr<ListSchedulesResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListSchedulesResponseBody() {}
explicit ListSchedulesResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListSchedulesResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListSchedulesResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListSchedulesResponseBody() = default;
};
class ListSchedulesResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListSchedulesResponseBody> body{};
ListSchedulesResponse() {}
explicit ListSchedulesResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListSchedulesResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListSchedulesResponseBody>(model1);
}
}
}
virtual ~ListSchedulesResponse() = default;
};
class ListSignaturesRequest : public Darabonba::Model {
public:
shared_ptr<string> name{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> status{};
ListSignaturesRequest() {}
explicit ListSignaturesRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (name) {
res["Name"] = boost::any(*name);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (status) {
res["Status"] = boost::any(*status);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
}
virtual ~ListSignaturesRequest() = default;
};
class ListSignaturesResponseBodyDataSignatures : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<long> status{};
shared_ptr<string> updatedTime{};
ListSignaturesResponseBodyDataSignatures() {}
explicit ListSignaturesResponseBodyDataSignatures(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~ListSignaturesResponseBodyDataSignatures() = default;
};
class ListSignaturesResponseBodyData : public Darabonba::Model {
public:
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<vector<ListSignaturesResponseBodyDataSignatures>> signatures{};
shared_ptr<long> totalCount{};
ListSignaturesResponseBodyData() {}
explicit ListSignaturesResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (signatures) {
vector<boost::any> temp1;
for(auto item1:*signatures){
temp1.push_back(boost::any(item1.toMap()));
}
res["Signatures"] = boost::any(temp1);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Signatures") != m.end() && !m["Signatures"].empty()) {
if (typeid(vector<boost::any>) == m["Signatures"].type()) {
vector<ListSignaturesResponseBodyDataSignatures> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Signatures"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListSignaturesResponseBodyDataSignatures model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
signatures = make_shared<vector<ListSignaturesResponseBodyDataSignatures>>(expect1);
}
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListSignaturesResponseBodyData() = default;
};
class ListSignaturesResponseBody : public Darabonba::Model {
public:
shared_ptr<ListSignaturesResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListSignaturesResponseBody() {}
explicit ListSignaturesResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListSignaturesResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListSignaturesResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListSignaturesResponseBody() = default;
};
class ListSignaturesResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListSignaturesResponseBody> body{};
ListSignaturesResponse() {}
explicit ListSignaturesResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListSignaturesResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListSignaturesResponseBody>(model1);
}
}
}
virtual ~ListSignaturesResponse() = default;
};
class ListTemplatesRequest : public Darabonba::Model {
public:
shared_ptr<string> content{};
shared_ptr<string> name{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> status{};
shared_ptr<long> type{};
ListTemplatesRequest() {}
explicit ListTemplatesRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (content) {
res["Content"] = boost::any(*content);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (type) {
res["Type"] = boost::any(*type);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Content") != m.end() && !m["Content"].empty()) {
content = make_shared<string>(boost::any_cast<string>(m["Content"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("Type") != m.end() && !m["Type"].empty()) {
type = make_shared<long>(boost::any_cast<long>(m["Type"]));
}
}
virtual ~ListTemplatesRequest() = default;
};
class ListTemplatesResponseBodyDataTemplates : public Darabonba::Model {
public:
shared_ptr<string> content{};
shared_ptr<string> createdTime{};
shared_ptr<string> description{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> reason{};
shared_ptr<string> signatureId{};
shared_ptr<long> status{};
shared_ptr<string> templateCode{};
shared_ptr<long> type{};
shared_ptr<string> updatedTime{};
ListTemplatesResponseBodyDataTemplates() {}
explicit ListTemplatesResponseBodyDataTemplates(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (content) {
res["Content"] = boost::any(*content);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (description) {
res["Description"] = boost::any(*description);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (reason) {
res["Reason"] = boost::any(*reason);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (type) {
res["Type"] = boost::any(*type);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Content") != m.end() && !m["Content"].empty()) {
content = make_shared<string>(boost::any_cast<string>(m["Content"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Description") != m.end() && !m["Description"].empty()) {
description = make_shared<string>(boost::any_cast<string>(m["Description"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Reason") != m.end() && !m["Reason"].empty()) {
reason = make_shared<string>(boost::any_cast<string>(m["Reason"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("Type") != m.end() && !m["Type"].empty()) {
type = make_shared<long>(boost::any_cast<long>(m["Type"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~ListTemplatesResponseBodyDataTemplates() = default;
};
class ListTemplatesResponseBodyData : public Darabonba::Model {
public:
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<vector<ListTemplatesResponseBodyDataTemplates>> templates{};
shared_ptr<long> totalCount{};
ListTemplatesResponseBodyData() {}
explicit ListTemplatesResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (templates) {
vector<boost::any> temp1;
for(auto item1:*templates){
temp1.push_back(boost::any(item1.toMap()));
}
res["Templates"] = boost::any(temp1);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Templates") != m.end() && !m["Templates"].empty()) {
if (typeid(vector<boost::any>) == m["Templates"].type()) {
vector<ListTemplatesResponseBodyDataTemplates> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Templates"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListTemplatesResponseBodyDataTemplates model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
templates = make_shared<vector<ListTemplatesResponseBodyDataTemplates>>(expect1);
}
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
}
virtual ~ListTemplatesResponseBodyData() = default;
};
class ListTemplatesResponseBody : public Darabonba::Model {
public:
shared_ptr<ListTemplatesResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListTemplatesResponseBody() {}
explicit ListTemplatesResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListTemplatesResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListTemplatesResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListTemplatesResponseBody() = default;
};
class ListTemplatesResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListTemplatesResponseBody> body{};
ListTemplatesResponse() {}
explicit ListTemplatesResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListTemplatesResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListTemplatesResponseBody>(model1);
}
}
}
virtual ~ListTemplatesResponse() = default;
};
class ListTrainingJobsRequest : public Darabonba::Model {
public:
shared_ptr<string> campaignId{};
shared_ptr<string> name{};
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<string> remark{};
shared_ptr<long> status{};
ListTrainingJobsRequest() {}
explicit ListTrainingJobsRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (status) {
res["Status"] = boost::any(*status);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
}
virtual ~ListTrainingJobsRequest() = default;
};
class ListTrainingJobsResponseBodyDataTrainingJobs : public Darabonba::Model {
public:
shared_ptr<string> algorithm{};
shared_ptr<string> campaignId{};
shared_ptr<string> createdTime{};
shared_ptr<string> dataPath{};
shared_ptr<string> history{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<long> status{};
shared_ptr<string> updatedTime{};
shared_ptr<string> userConfig{};
ListTrainingJobsResponseBodyDataTrainingJobs() {}
explicit ListTrainingJobsResponseBodyDataTrainingJobs(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (algorithm) {
res["Algorithm"] = boost::any(*algorithm);
}
if (campaignId) {
res["CampaignId"] = boost::any(*campaignId);
}
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (dataPath) {
res["DataPath"] = boost::any(*dataPath);
}
if (history) {
res["History"] = boost::any(*history);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (status) {
res["Status"] = boost::any(*status);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
if (userConfig) {
res["UserConfig"] = boost::any(*userConfig);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Algorithm") != m.end() && !m["Algorithm"].empty()) {
algorithm = make_shared<string>(boost::any_cast<string>(m["Algorithm"]));
}
if (m.find("CampaignId") != m.end() && !m["CampaignId"].empty()) {
campaignId = make_shared<string>(boost::any_cast<string>(m["CampaignId"]));
}
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("DataPath") != m.end() && !m["DataPath"].empty()) {
dataPath = make_shared<string>(boost::any_cast<string>(m["DataPath"]));
}
if (m.find("History") != m.end() && !m["History"].empty()) {
history = make_shared<string>(boost::any_cast<string>(m["History"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("Status") != m.end() && !m["Status"].empty()) {
status = make_shared<long>(boost::any_cast<long>(m["Status"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
if (m.find("UserConfig") != m.end() && !m["UserConfig"].empty()) {
userConfig = make_shared<string>(boost::any_cast<string>(m["UserConfig"]));
}
}
virtual ~ListTrainingJobsResponseBodyDataTrainingJobs() = default;
};
class ListTrainingJobsResponseBodyData : public Darabonba::Model {
public:
shared_ptr<long> pageNumber{};
shared_ptr<long> pageSize{};
shared_ptr<long> totalCount{};
shared_ptr<vector<ListTrainingJobsResponseBodyDataTrainingJobs>> trainingJobs{};
ListTrainingJobsResponseBodyData() {}
explicit ListTrainingJobsResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (pageNumber) {
res["PageNumber"] = boost::any(*pageNumber);
}
if (pageSize) {
res["PageSize"] = boost::any(*pageSize);
}
if (totalCount) {
res["TotalCount"] = boost::any(*totalCount);
}
if (trainingJobs) {
vector<boost::any> temp1;
for(auto item1:*trainingJobs){
temp1.push_back(boost::any(item1.toMap()));
}
res["TrainingJobs"] = boost::any(temp1);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("PageNumber") != m.end() && !m["PageNumber"].empty()) {
pageNumber = make_shared<long>(boost::any_cast<long>(m["PageNumber"]));
}
if (m.find("PageSize") != m.end() && !m["PageSize"].empty()) {
pageSize = make_shared<long>(boost::any_cast<long>(m["PageSize"]));
}
if (m.find("TotalCount") != m.end() && !m["TotalCount"].empty()) {
totalCount = make_shared<long>(boost::any_cast<long>(m["TotalCount"]));
}
if (m.find("TrainingJobs") != m.end() && !m["TrainingJobs"].empty()) {
if (typeid(vector<boost::any>) == m["TrainingJobs"].type()) {
vector<ListTrainingJobsResponseBodyDataTrainingJobs> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["TrainingJobs"])){
if (typeid(map<string, boost::any>) == item1.type()) {
ListTrainingJobsResponseBodyDataTrainingJobs model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
trainingJobs = make_shared<vector<ListTrainingJobsResponseBodyDataTrainingJobs>>(expect1);
}
}
}
virtual ~ListTrainingJobsResponseBodyData() = default;
};
class ListTrainingJobsResponseBody : public Darabonba::Model {
public:
shared_ptr<ListTrainingJobsResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
ListTrainingJobsResponseBody() {}
explicit ListTrainingJobsResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
ListTrainingJobsResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<ListTrainingJobsResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~ListTrainingJobsResponseBody() = default;
};
class ListTrainingJobsResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<ListTrainingJobsResponseBody> body{};
ListTrainingJobsResponse() {}
explicit ListTrainingJobsResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
ListTrainingJobsResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<ListTrainingJobsResponseBody>(model1);
}
}
}
virtual ~ListTrainingJobsResponse() = default;
};
class SendMessageRequest : public Darabonba::Model {
public:
shared_ptr<string> groupId{};
shared_ptr<vector<string>> outIds{};
shared_ptr<vector<string>> phoneNumbers{};
shared_ptr<string> scheduleId{};
shared_ptr<string> signName{};
shared_ptr<string> signatureId{};
shared_ptr<vector<string>> smsUpExtendCodes{};
shared_ptr<string> templateCode{};
shared_ptr<string> templateId{};
shared_ptr<vector<string>> templateParams{};
SendMessageRequest() {}
explicit SendMessageRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (groupId) {
res["GroupId"] = boost::any(*groupId);
}
if (outIds) {
res["OutIds"] = boost::any(*outIds);
}
if (phoneNumbers) {
res["PhoneNumbers"] = boost::any(*phoneNumbers);
}
if (scheduleId) {
res["ScheduleId"] = boost::any(*scheduleId);
}
if (signName) {
res["SignName"] = boost::any(*signName);
}
if (signatureId) {
res["SignatureId"] = boost::any(*signatureId);
}
if (smsUpExtendCodes) {
res["SmsUpExtendCodes"] = boost::any(*smsUpExtendCodes);
}
if (templateCode) {
res["TemplateCode"] = boost::any(*templateCode);
}
if (templateId) {
res["TemplateId"] = boost::any(*templateId);
}
if (templateParams) {
res["TemplateParams"] = boost::any(*templateParams);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("GroupId") != m.end() && !m["GroupId"].empty()) {
groupId = make_shared<string>(boost::any_cast<string>(m["GroupId"]));
}
if (m.find("OutIds") != m.end() && !m["OutIds"].empty()) {
vector<string> toVec1;
if (typeid(vector<boost::any>) == m["OutIds"].type()) {
vector<boost::any> vec1 = boost::any_cast<vector<boost::any>>(m["OutIds"]);
for (auto item:vec1) {
toVec1.push_back(boost::any_cast<string>(item));
}
}
outIds = make_shared<vector<string>>(toVec1);
}
if (m.find("PhoneNumbers") != m.end() && !m["PhoneNumbers"].empty()) {
vector<string> toVec1;
if (typeid(vector<boost::any>) == m["PhoneNumbers"].type()) {
vector<boost::any> vec1 = boost::any_cast<vector<boost::any>>(m["PhoneNumbers"]);
for (auto item:vec1) {
toVec1.push_back(boost::any_cast<string>(item));
}
}
phoneNumbers = make_shared<vector<string>>(toVec1);
}
if (m.find("ScheduleId") != m.end() && !m["ScheduleId"].empty()) {
scheduleId = make_shared<string>(boost::any_cast<string>(m["ScheduleId"]));
}
if (m.find("SignName") != m.end() && !m["SignName"].empty()) {
signName = make_shared<string>(boost::any_cast<string>(m["SignName"]));
}
if (m.find("SignatureId") != m.end() && !m["SignatureId"].empty()) {
signatureId = make_shared<string>(boost::any_cast<string>(m["SignatureId"]));
}
if (m.find("SmsUpExtendCodes") != m.end() && !m["SmsUpExtendCodes"].empty()) {
vector<string> toVec1;
if (typeid(vector<boost::any>) == m["SmsUpExtendCodes"].type()) {
vector<boost::any> vec1 = boost::any_cast<vector<boost::any>>(m["SmsUpExtendCodes"]);
for (auto item:vec1) {
toVec1.push_back(boost::any_cast<string>(item));
}
}
smsUpExtendCodes = make_shared<vector<string>>(toVec1);
}
if (m.find("TemplateCode") != m.end() && !m["TemplateCode"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["TemplateCode"]));
}
if (m.find("TemplateId") != m.end() && !m["TemplateId"].empty()) {
templateId = make_shared<string>(boost::any_cast<string>(m["TemplateId"]));
}
if (m.find("TemplateParams") != m.end() && !m["TemplateParams"].empty()) {
vector<string> toVec1;
if (typeid(vector<boost::any>) == m["TemplateParams"].type()) {
vector<boost::any> vec1 = boost::any_cast<vector<boost::any>>(m["TemplateParams"]);
for (auto item:vec1) {
toVec1.push_back(boost::any_cast<string>(item));
}
}
templateParams = make_shared<vector<string>>(toVec1);
}
}
virtual ~SendMessageRequest() = default;
};
class SendMessageResponseBodyDataMessages : public Darabonba::Model {
public:
shared_ptr<string> id{};
shared_ptr<string> phoneNumber{};
SendMessageResponseBodyDataMessages() {}
explicit SendMessageResponseBodyDataMessages(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (id) {
res["Id"] = boost::any(*id);
}
if (phoneNumber) {
res["PhoneNumber"] = boost::any(*phoneNumber);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("PhoneNumber") != m.end() && !m["PhoneNumber"].empty()) {
phoneNumber = make_shared<string>(boost::any_cast<string>(m["PhoneNumber"]));
}
}
virtual ~SendMessageResponseBodyDataMessages() = default;
};
class SendMessageResponseBodyData : public Darabonba::Model {
public:
shared_ptr<vector<SendMessageResponseBodyDataMessages>> messages{};
shared_ptr<string> requestId{};
SendMessageResponseBodyData() {}
explicit SendMessageResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (messages) {
vector<boost::any> temp1;
for(auto item1:*messages){
temp1.push_back(boost::any(item1.toMap()));
}
res["Messages"] = boost::any(temp1);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Messages") != m.end() && !m["Messages"].empty()) {
if (typeid(vector<boost::any>) == m["Messages"].type()) {
vector<SendMessageResponseBodyDataMessages> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["Messages"])){
if (typeid(map<string, boost::any>) == item1.type()) {
SendMessageResponseBodyDataMessages model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
messages = make_shared<vector<SendMessageResponseBodyDataMessages>>(expect1);
}
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~SendMessageResponseBodyData() = default;
};
class SendMessageResponseBody : public Darabonba::Model {
public:
shared_ptr<SendMessageResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
SendMessageResponseBody() {}
explicit SendMessageResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
SendMessageResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<SendMessageResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~SendMessageResponseBody() = default;
};
class SendMessageResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<SendMessageResponseBody> body{};
SendMessageResponse() {}
explicit SendMessageResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
SendMessageResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<SendMessageResponseBody>(model1);
}
}
}
virtual ~SendMessageResponse() = default;
};
class SmsReportRequestBody : public Darabonba::Model {
public:
shared_ptr<string> bizId{};
shared_ptr<string> errCode{};
shared_ptr<string> errMsg{};
shared_ptr<string> messageId{};
shared_ptr<string> outId{};
shared_ptr<string> phoneNumber{};
shared_ptr<string> reportTime{};
shared_ptr<string> requestId{};
shared_ptr<string> sendTime{};
shared_ptr<string> signName{};
shared_ptr<string> smsSize{};
shared_ptr<bool> success{};
shared_ptr<string> templateCode{};
SmsReportRequestBody() {}
explicit SmsReportRequestBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (bizId) {
res["biz_id"] = boost::any(*bizId);
}
if (errCode) {
res["err_code"] = boost::any(*errCode);
}
if (errMsg) {
res["err_msg"] = boost::any(*errMsg);
}
if (messageId) {
res["message_id"] = boost::any(*messageId);
}
if (outId) {
res["out_id"] = boost::any(*outId);
}
if (phoneNumber) {
res["phone_number"] = boost::any(*phoneNumber);
}
if (reportTime) {
res["report_time"] = boost::any(*reportTime);
}
if (requestId) {
res["request_id"] = boost::any(*requestId);
}
if (sendTime) {
res["send_time"] = boost::any(*sendTime);
}
if (signName) {
res["sign_name"] = boost::any(*signName);
}
if (smsSize) {
res["sms_size"] = boost::any(*smsSize);
}
if (success) {
res["success"] = boost::any(*success);
}
if (templateCode) {
res["template_code"] = boost::any(*templateCode);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("biz_id") != m.end() && !m["biz_id"].empty()) {
bizId = make_shared<string>(boost::any_cast<string>(m["biz_id"]));
}
if (m.find("err_code") != m.end() && !m["err_code"].empty()) {
errCode = make_shared<string>(boost::any_cast<string>(m["err_code"]));
}
if (m.find("err_msg") != m.end() && !m["err_msg"].empty()) {
errMsg = make_shared<string>(boost::any_cast<string>(m["err_msg"]));
}
if (m.find("message_id") != m.end() && !m["message_id"].empty()) {
messageId = make_shared<string>(boost::any_cast<string>(m["message_id"]));
}
if (m.find("out_id") != m.end() && !m["out_id"].empty()) {
outId = make_shared<string>(boost::any_cast<string>(m["out_id"]));
}
if (m.find("phone_number") != m.end() && !m["phone_number"].empty()) {
phoneNumber = make_shared<string>(boost::any_cast<string>(m["phone_number"]));
}
if (m.find("report_time") != m.end() && !m["report_time"].empty()) {
reportTime = make_shared<string>(boost::any_cast<string>(m["report_time"]));
}
if (m.find("request_id") != m.end() && !m["request_id"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["request_id"]));
}
if (m.find("send_time") != m.end() && !m["send_time"].empty()) {
sendTime = make_shared<string>(boost::any_cast<string>(m["send_time"]));
}
if (m.find("sign_name") != m.end() && !m["sign_name"].empty()) {
signName = make_shared<string>(boost::any_cast<string>(m["sign_name"]));
}
if (m.find("sms_size") != m.end() && !m["sms_size"].empty()) {
smsSize = make_shared<string>(boost::any_cast<string>(m["sms_size"]));
}
if (m.find("success") != m.end() && !m["success"].empty()) {
success = make_shared<bool>(boost::any_cast<bool>(m["success"]));
}
if (m.find("template_code") != m.end() && !m["template_code"].empty()) {
templateCode = make_shared<string>(boost::any_cast<string>(m["template_code"]));
}
}
virtual ~SmsReportRequestBody() = default;
};
class SmsReportRequest : public Darabonba::Model {
public:
shared_ptr<vector<SmsReportRequestBody>> body{};
SmsReportRequest() {}
explicit SmsReportRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (body) {
vector<boost::any> temp1;
for(auto item1:*body){
temp1.push_back(boost::any(item1.toMap()));
}
res["body"] = boost::any(temp1);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(vector<boost::any>) == m["body"].type()) {
vector<SmsReportRequestBody> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["body"])){
if (typeid(map<string, boost::any>) == item1.type()) {
SmsReportRequestBody model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
body = make_shared<vector<SmsReportRequestBody>>(expect1);
}
}
}
virtual ~SmsReportRequest() = default;
};
class SmsReportResponseBody : public Darabonba::Model {
public:
shared_ptr<long> code{};
shared_ptr<string> msg{};
SmsReportResponseBody() {}
explicit SmsReportResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (code) {
res["code"] = boost::any(*code);
}
if (msg) {
res["msg"] = boost::any(*msg);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("code") != m.end() && !m["code"].empty()) {
code = make_shared<long>(boost::any_cast<long>(m["code"]));
}
if (m.find("msg") != m.end() && !m["msg"].empty()) {
msg = make_shared<string>(boost::any_cast<string>(m["msg"]));
}
}
virtual ~SmsReportResponseBody() = default;
};
class SmsReportResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<SmsReportResponseBody> body{};
SmsReportResponse() {}
explicit SmsReportResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
SmsReportResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<SmsReportResponseBody>(model1);
}
}
}
virtual ~SmsReportResponse() = default;
};
class SmsUpRequestBody : public Darabonba::Model {
public:
shared_ptr<string> content{};
shared_ptr<string> destCode{};
shared_ptr<string> phoneNumber{};
shared_ptr<string> sendTime{};
shared_ptr<long> sequenceId{};
shared_ptr<string> signName{};
SmsUpRequestBody() {}
explicit SmsUpRequestBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (content) {
res["content"] = boost::any(*content);
}
if (destCode) {
res["dest_code"] = boost::any(*destCode);
}
if (phoneNumber) {
res["phone_number"] = boost::any(*phoneNumber);
}
if (sendTime) {
res["send_time"] = boost::any(*sendTime);
}
if (sequenceId) {
res["sequence_id"] = boost::any(*sequenceId);
}
if (signName) {
res["sign_name"] = boost::any(*signName);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("content") != m.end() && !m["content"].empty()) {
content = make_shared<string>(boost::any_cast<string>(m["content"]));
}
if (m.find("dest_code") != m.end() && !m["dest_code"].empty()) {
destCode = make_shared<string>(boost::any_cast<string>(m["dest_code"]));
}
if (m.find("phone_number") != m.end() && !m["phone_number"].empty()) {
phoneNumber = make_shared<string>(boost::any_cast<string>(m["phone_number"]));
}
if (m.find("send_time") != m.end() && !m["send_time"].empty()) {
sendTime = make_shared<string>(boost::any_cast<string>(m["send_time"]));
}
if (m.find("sequence_id") != m.end() && !m["sequence_id"].empty()) {
sequenceId = make_shared<long>(boost::any_cast<long>(m["sequence_id"]));
}
if (m.find("sign_name") != m.end() && !m["sign_name"].empty()) {
signName = make_shared<string>(boost::any_cast<string>(m["sign_name"]));
}
}
virtual ~SmsUpRequestBody() = default;
};
class SmsUpRequest : public Darabonba::Model {
public:
shared_ptr<vector<SmsUpRequestBody>> body{};
SmsUpRequest() {}
explicit SmsUpRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (body) {
vector<boost::any> temp1;
for(auto item1:*body){
temp1.push_back(boost::any(item1.toMap()));
}
res["body"] = boost::any(temp1);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(vector<boost::any>) == m["body"].type()) {
vector<SmsUpRequestBody> expect1;
for(auto item1:boost::any_cast<vector<boost::any>>(m["body"])){
if (typeid(map<string, boost::any>) == item1.type()) {
SmsUpRequestBody model2;
model2.fromMap(boost::any_cast<map<string, boost::any>>(item1));
expect1.push_back(model2);
}
}
body = make_shared<vector<SmsUpRequestBody>>(expect1);
}
}
}
virtual ~SmsUpRequest() = default;
};
class SmsUpResponseBody : public Darabonba::Model {
public:
shared_ptr<long> code{};
shared_ptr<string> msg{};
SmsUpResponseBody() {}
explicit SmsUpResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (code) {
res["code"] = boost::any(*code);
}
if (msg) {
res["msg"] = boost::any(*msg);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("code") != m.end() && !m["code"].empty()) {
code = make_shared<long>(boost::any_cast<long>(m["code"]));
}
if (m.find("msg") != m.end() && !m["msg"].empty()) {
msg = make_shared<string>(boost::any_cast<string>(m["msg"]));
}
}
virtual ~SmsUpResponseBody() = default;
};
class SmsUpResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<SmsUpResponseBody> body{};
SmsUpResponse() {}
explicit SmsUpResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
SmsUpResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<SmsUpResponseBody>(model1);
}
}
}
virtual ~SmsUpResponse() = default;
};
class UpdateCampaignRequest : public Darabonba::Model {
public:
shared_ptr<string> name{};
shared_ptr<string> remark{};
UpdateCampaignRequest() {}
explicit UpdateCampaignRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
}
virtual ~UpdateCampaignRequest() = default;
};
class UpdateCampaignResponseBodyData : public Darabonba::Model {
public:
shared_ptr<string> createdTime{};
shared_ptr<string> id{};
shared_ptr<string> name{};
shared_ptr<string> remark{};
shared_ptr<string> updatedTime{};
UpdateCampaignResponseBodyData() {}
explicit UpdateCampaignResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (createdTime) {
res["CreatedTime"] = boost::any(*createdTime);
}
if (id) {
res["Id"] = boost::any(*id);
}
if (name) {
res["Name"] = boost::any(*name);
}
if (remark) {
res["Remark"] = boost::any(*remark);
}
if (updatedTime) {
res["UpdatedTime"] = boost::any(*updatedTime);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("CreatedTime") != m.end() && !m["CreatedTime"].empty()) {
createdTime = make_shared<string>(boost::any_cast<string>(m["CreatedTime"]));
}
if (m.find("Id") != m.end() && !m["Id"].empty()) {
id = make_shared<string>(boost::any_cast<string>(m["Id"]));
}
if (m.find("Name") != m.end() && !m["Name"].empty()) {
name = make_shared<string>(boost::any_cast<string>(m["Name"]));
}
if (m.find("Remark") != m.end() && !m["Remark"].empty()) {
remark = make_shared<string>(boost::any_cast<string>(m["Remark"]));
}
if (m.find("UpdatedTime") != m.end() && !m["UpdatedTime"].empty()) {
updatedTime = make_shared<string>(boost::any_cast<string>(m["UpdatedTime"]));
}
}
virtual ~UpdateCampaignResponseBodyData() = default;
};
class UpdateCampaignResponseBody : public Darabonba::Model {
public:
shared_ptr<UpdateCampaignResponseBodyData> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
UpdateCampaignResponseBody() {}
explicit UpdateCampaignResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
if (typeid(map<string, boost::any>) == m["Data"].type()) {
UpdateCampaignResponseBodyData model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
data = make_shared<UpdateCampaignResponseBodyData>(model1);
}
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~UpdateCampaignResponseBody() = default;
};
class UpdateCampaignResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<UpdateCampaignResponseBody> body{};
UpdateCampaignResponse() {}
explicit UpdateCampaignResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
UpdateCampaignResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<UpdateCampaignResponseBody>(model1);
}
}
}
virtual ~UpdateCampaignResponse() = default;
};
class UpdateReportUrlRequest : public Darabonba::Model {
public:
shared_ptr<string> url{};
UpdateReportUrlRequest() {}
explicit UpdateReportUrlRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (url) {
res["Url"] = boost::any(*url);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Url") != m.end() && !m["Url"].empty()) {
url = make_shared<string>(boost::any_cast<string>(m["Url"]));
}
}
virtual ~UpdateReportUrlRequest() = default;
};
class UpdateReportUrlResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
UpdateReportUrlResponseBody() {}
explicit UpdateReportUrlResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~UpdateReportUrlResponseBody() = default;
};
class UpdateReportUrlResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<UpdateReportUrlResponseBody> body{};
UpdateReportUrlResponse() {}
explicit UpdateReportUrlResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
UpdateReportUrlResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<UpdateReportUrlResponseBody>(model1);
}
}
}
virtual ~UpdateReportUrlResponse() = default;
};
class UpdateUploadUrlRequest : public Darabonba::Model {
public:
shared_ptr<string> url{};
UpdateUploadUrlRequest() {}
explicit UpdateUploadUrlRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (url) {
res["Url"] = boost::any(*url);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Url") != m.end() && !m["Url"].empty()) {
url = make_shared<string>(boost::any_cast<string>(m["Url"]));
}
}
virtual ~UpdateUploadUrlRequest() = default;
};
class UpdateUploadUrlResponseBody : public Darabonba::Model {
public:
shared_ptr<string> data{};
shared_ptr<long> errorCode{};
shared_ptr<string> errorMessage{};
shared_ptr<string> requestId{};
UpdateUploadUrlResponseBody() {}
explicit UpdateUploadUrlResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (data) {
res["Data"] = boost::any(*data);
}
if (errorCode) {
res["ErrorCode"] = boost::any(*errorCode);
}
if (errorMessage) {
res["ErrorMessage"] = boost::any(*errorMessage);
}
if (requestId) {
res["RequestId"] = boost::any(*requestId);
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("Data") != m.end() && !m["Data"].empty()) {
data = make_shared<string>(boost::any_cast<string>(m["Data"]));
}
if (m.find("ErrorCode") != m.end() && !m["ErrorCode"].empty()) {
errorCode = make_shared<long>(boost::any_cast<long>(m["ErrorCode"]));
}
if (m.find("ErrorMessage") != m.end() && !m["ErrorMessage"].empty()) {
errorMessage = make_shared<string>(boost::any_cast<string>(m["ErrorMessage"]));
}
if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
}
}
virtual ~UpdateUploadUrlResponseBody() = default;
};
class UpdateUploadUrlResponse : public Darabonba::Model {
public:
shared_ptr<map<string, string>> headers{};
shared_ptr<long> statusCode{};
shared_ptr<UpdateUploadUrlResponseBody> body{};
UpdateUploadUrlResponse() {}
explicit UpdateUploadUrlResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
fromMap(config);
};
void validate() override {
if (!headers) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
}
if (!statusCode) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("statusCode is required.")));
}
if (!body) {
BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
}
}
map<string, boost::any> toMap() override {
map<string, boost::any> res;
if (headers) {
res["headers"] = boost::any(*headers);
}
if (statusCode) {
res["statusCode"] = boost::any(*statusCode);
}
if (body) {
res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
}
return res;
}
void fromMap(map<string, boost::any> m) override {
if (m.find("headers") != m.end() && !m["headers"].empty()) {
map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
map<string, string> toMap1;
for (auto item:map1) {
toMap1[item.first] = item.second;
}
headers = make_shared<map<string, string>>(toMap1);
}
if (m.find("statusCode") != m.end() && !m["statusCode"].empty()) {
statusCode = make_shared<long>(boost::any_cast<long>(m["statusCode"]));
}
if (m.find("body") != m.end() && !m["body"].empty()) {
if (typeid(map<string, boost::any>) == m["body"].type()) {
UpdateUploadUrlResponseBody model1;
model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
body = make_shared<UpdateUploadUrlResponseBody>(model1);
}
}
}
virtual ~UpdateUploadUrlResponse() = default;
};
class Client : Alibabacloud_OpenApi::Client {
public:
explicit Client(const shared_ptr<Alibabacloud_OpenApi::Config>& config);
string getEndpoint(shared_ptr<string> productId,
shared_ptr<string> regionId,
shared_ptr<string> endpointRule,
shared_ptr<string> network,
shared_ptr<string> suffix,
shared_ptr<map<string, string>> endpointMap,
shared_ptr<string> endpoint);
CreateCampaignResponse createCampaign(shared_ptr<CreateCampaignRequest> request);
CreateCampaignResponse createCampaignWithOptions(shared_ptr<CreateCampaignRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
CreateGroupResponse createGroup(shared_ptr<CreateGroupRequest> request);
CreateGroupResponse createGroupWithOptions(shared_ptr<CreateGroupRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
CreateInferenceJobResponse createInferenceJob(shared_ptr<CreateInferenceJobRequest> request);
CreateInferenceJobResponse createInferenceJobWithOptions(shared_ptr<CreateInferenceJobRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
CreateScheduleResponse createSchedule(shared_ptr<CreateScheduleRequest> request);
CreateScheduleResponse createScheduleWithOptions(shared_ptr<CreateScheduleRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
CreateSignatureResponse createSignature(shared_ptr<CreateSignatureRequest> request);
CreateSignatureResponse createSignatureWithOptions(shared_ptr<CreateSignatureRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
CreateTemplateResponse createTemplate(shared_ptr<CreateTemplateRequest> request);
CreateTemplateResponse createTemplateWithOptions(shared_ptr<CreateTemplateRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
CreateTrainingJobResponse createTrainingJob(shared_ptr<CreateTrainingJobRequest> request);
CreateTrainingJobResponse createTrainingJobWithOptions(shared_ptr<CreateTrainingJobRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
DeleteCampaignResponse deleteCampaign(shared_ptr<string> Id);
DeleteCampaignResponse deleteCampaignWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
DeleteGroupResponse deleteGroup(shared_ptr<string> Id);
DeleteGroupResponse deleteGroupWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
DeleteInferenceJobResponse deleteInferenceJob(shared_ptr<string> Id);
DeleteInferenceJobResponse deleteInferenceJobWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
DeleteScheduleResponse deleteSchedule(shared_ptr<string> Id);
DeleteScheduleResponse deleteScheduleWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
DeleteSignatureResponse deleteSignature(shared_ptr<string> Id);
DeleteSignatureResponse deleteSignatureWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
DeleteTemplateResponse deleteTemplate(shared_ptr<string> Id);
DeleteTemplateResponse deleteTemplateWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
DeleteTrainingJobResponse deleteTrainingJob(shared_ptr<string> Id);
DeleteTrainingJobResponse deleteTrainingJobWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetAlgorithmResponse getAlgorithm(shared_ptr<string> Id);
GetAlgorithmResponse getAlgorithmWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetCampaignResponse getCampaign(shared_ptr<string> Id);
GetCampaignResponse getCampaignWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetGroupResponse getGroup(shared_ptr<string> Id);
GetGroupResponse getGroupWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetInferenceJobResponse getInferenceJob(shared_ptr<string> Id);
GetInferenceJobResponse getInferenceJobWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetMessageConfigResponse getMessageConfig();
GetMessageConfigResponse getMessageConfigWithOptions(shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetScheduleResponse getSchedule(shared_ptr<string> Id);
GetScheduleResponse getScheduleWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetSignatureResponse getSignature(shared_ptr<string> Id);
GetSignatureResponse getSignatureWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetTemplateResponse getTemplate(shared_ptr<string> Id);
GetTemplateResponse getTemplateWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetTrainingJobResponse getTrainingJob(shared_ptr<string> Id);
GetTrainingJobResponse getTrainingJobWithOptions(shared_ptr<string> Id, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
GetUserResponse getUser();
GetUserResponse getUserWithOptions(shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListAlgorithmsResponse listAlgorithms(shared_ptr<ListAlgorithmsRequest> request);
ListAlgorithmsResponse listAlgorithmsWithOptions(shared_ptr<ListAlgorithmsRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListCampaignsResponse listCampaigns(shared_ptr<ListCampaignsRequest> request);
ListCampaignsResponse listCampaignsWithOptions(shared_ptr<ListCampaignsRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListGroupsResponse listGroups(shared_ptr<ListGroupsRequest> request);
ListGroupsResponse listGroupsWithOptions(shared_ptr<ListGroupsRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListInferenceJobsResponse listInferenceJobs(shared_ptr<ListInferenceJobsRequest> request);
ListInferenceJobsResponse listInferenceJobsWithOptions(shared_ptr<ListInferenceJobsRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListMessageMetricsResponse listMessageMetrics(shared_ptr<ListMessageMetricsRequest> request);
ListMessageMetricsResponse listMessageMetricsWithOptions(shared_ptr<ListMessageMetricsRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListMessagesResponse listMessages(shared_ptr<ListMessagesRequest> request);
ListMessagesResponse listMessagesWithOptions(shared_ptr<ListMessagesRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListSchedulesResponse listSchedules(shared_ptr<ListSchedulesRequest> request);
ListSchedulesResponse listSchedulesWithOptions(shared_ptr<ListSchedulesRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListSignaturesResponse listSignatures(shared_ptr<ListSignaturesRequest> request);
ListSignaturesResponse listSignaturesWithOptions(shared_ptr<ListSignaturesRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListTemplatesResponse listTemplates(shared_ptr<ListTemplatesRequest> request);
ListTemplatesResponse listTemplatesWithOptions(shared_ptr<ListTemplatesRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
ListTrainingJobsResponse listTrainingJobs(shared_ptr<ListTrainingJobsRequest> request);
ListTrainingJobsResponse listTrainingJobsWithOptions(shared_ptr<ListTrainingJobsRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
SendMessageResponse sendMessage(shared_ptr<SendMessageRequest> request);
SendMessageResponse sendMessageWithOptions(shared_ptr<SendMessageRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
SmsReportResponse smsReport(shared_ptr<SmsReportRequest> request);
SmsReportResponse smsReportWithOptions(shared_ptr<SmsReportRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
SmsUpResponse smsUp(shared_ptr<SmsUpRequest> request);
SmsUpResponse smsUpWithOptions(shared_ptr<SmsUpRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
UpdateCampaignResponse updateCampaign(shared_ptr<string> Id, shared_ptr<UpdateCampaignRequest> request);
UpdateCampaignResponse updateCampaignWithOptions(shared_ptr<string> Id,
shared_ptr<UpdateCampaignRequest> request,
shared_ptr<map<string, string>> headers,
shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
UpdateReportUrlResponse updateReportUrl(shared_ptr<UpdateReportUrlRequest> request);
UpdateReportUrlResponse updateReportUrlWithOptions(shared_ptr<UpdateReportUrlRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
UpdateUploadUrlResponse updateUploadUrl(shared_ptr<UpdateUploadUrlRequest> request);
UpdateUploadUrlResponse updateUploadUrlWithOptions(shared_ptr<UpdateUploadUrlRequest> request, shared_ptr<map<string, string>> headers, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
virtual ~Client() = default;
};
} // namespace Alibabacloud_PaiPlugin20220112
#endif
| 33.454175 | 199 | 0.615746 | alibabacloud-sdk-cpp |
f916613855148acf4ddb6053fd02d8472bba92ea | 1,924 | cpp | C++ | kdl/schema/resource_type/resource_field.cpp | EvocationGames/libKDL | 90eb2ce71a1545f6e33164230f0e5d6ece0acaa7 | [
"MIT"
] | null | null | null | kdl/schema/resource_type/resource_field.cpp | EvocationGames/libKDL | 90eb2ce71a1545f6e33164230f0e5d6ece0acaa7 | [
"MIT"
] | null | null | null | kdl/schema/resource_type/resource_field.cpp | EvocationGames/libKDL | 90eb2ce71a1545f6e33164230f0e5d6ece0acaa7 | [
"MIT"
] | null | null | null | // Copyright (c) 2021 Tom Hancocks
//
// 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 <kdl/schema/resource_type/resource_field.hpp>
#include <kdl/schema/resource_type/resource_field_value.hpp>
// MARK: - Constructor
kdl::lib::resource_field::resource_field(const std::string& name)
: m_name(name)
{
}
kdl::lib::resource_field::resource_field(const std::shared_ptr<struct resource_field_value>& field)
: m_name(field->name()), m_values({ field })
{
}
// MARK: - Accessor
auto kdl::lib::resource_field::name() const -> std::string
{
return m_name;
}
// MARK: - Field Value Management
auto kdl::lib::resource_field::add_value(const std::shared_ptr<struct resource_field_value> &value) -> void
{
m_values.emplace_back(value);
}
auto kdl::lib::resource_field::values() const -> const std::vector<std::shared_ptr<struct resource_field_value>> &
{
return m_values;
}
| 34.357143 | 114 | 0.748441 | EvocationGames |
f922029c60842453b1aff0f88adab5004227c320 | 2,135 | cpp | C++ | plugins/notifications/notifier.cpp | boomt1337/nitroshare-desktop | 3ab9eb4075f78cbf2ee0fb82cea66814406a2248 | [
"MIT"
] | 1,460 | 2015-01-31T14:09:18.000Z | 2022-03-24T09:43:19.000Z | plugins/notifications/notifier.cpp | boomt1337/nitroshare-desktop | 3ab9eb4075f78cbf2ee0fb82cea66814406a2248 | [
"MIT"
] | 254 | 2015-01-29T19:58:28.000Z | 2022-03-30T01:00:38.000Z | plugins/notifications/notifier.cpp | boomt1337/nitroshare-desktop | 3ab9eb4075f78cbf2ee0fb82cea66814406a2248 | [
"MIT"
] | 245 | 2015-02-18T16:40:52.000Z | 2022-03-29T18:38:45.000Z | /*
* The MIT License (MIT)
*
* Copyright (c) 2018 Nathan Osman
*
* 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 <nitroshare/action.h>
#include <nitroshare/actionregistry.h>
#include <nitroshare/application.h>
#include <nitroshare/logger.h>
#include <nitroshare/message.h>
#include "notifier.h"
const QString MessageTag = "mdns";
const QString ShowTrayNotificationAction = "showtraynotification";
Notifier::Notifier(Application *application)
: mApplication(application)
{
}
void Notifier::showNotification(const QString &actionName, const QString &title, const QString &message)
{
// Find the action for showing the tray notification
Action *action = mApplication->actionRegistry()->find(actionName);
if (!action) {
mApplication->logger()->log(new Message(
Message::Warning,
MessageTag,
QString("\"%1\" action was not found").arg(actionName)
));
return;
}
// Invoke the action to show the notification
action->invoke(QVariantMap{
{ "title", title },
{ "message", message }
});
}
| 35 | 104 | 0.717564 | boomt1337 |
f9240d7d91ab4d35253d601837acf6a1707a1799 | 500 | cpp | C++ | lib/stringManipulation/src/string_manipulation.cpp | Xav83/AdventOfCode | 7e305b89abe0a497efdab0f1a3bfe2bfc24b36d5 | [
"MIT"
] | 2 | 2019-11-14T18:11:02.000Z | 2020-01-20T22:40:31.000Z | lib/stringManipulation/src/string_manipulation.cpp | Xav83/AdventOfCode | 7e305b89abe0a497efdab0f1a3bfe2bfc24b36d5 | [
"MIT"
] | null | null | null | lib/stringManipulation/src/string_manipulation.cpp | Xav83/AdventOfCode | 7e305b89abe0a497efdab0f1a3bfe2bfc24b36d5 | [
"MIT"
] | null | null | null | #include <functional>
#include <sstream>
void foreachElementsInStringDelimitedBy(
const std::string &input, const char delimiter,
std::function<void(const std::string &)> callback) {
std::stringstream ss(input);
std::string token;
while (std::getline(ss, token, delimiter)) {
callback(token);
}
}
void foreachLineIn(const std::string &input,
std::function<void(const std::string &)> callback) {
foreachElementsInStringDelimitedBy(input, '\n', callback);
}
| 26.315789 | 71 | 0.688 | Xav83 |
f924414c965b39dcf3af5eabf4ac9a247dbad819 | 31,268 | cpp | C++ | unittests/test.cpp | attcs/TreeNode | 1728cc3a1c605e17c328a27c12de5aa685f80fc1 | [
"MIT"
] | null | null | null | unittests/test.cpp | attcs/TreeNode | 1728cc3a1c605e17c328a27c12de5aa685f80fc1 | [
"MIT"
] | null | null | null | unittests/test.cpp | attcs/TreeNode | 1728cc3a1c605e17c328a27c12de5aa685f80fc1 | [
"MIT"
] | null | null | null | #include "pch.h"
#include <memory>
#include "../treenode.h"
#include <vector>
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
#include <execution>
#endif
struct DbEntity
{
int val = 0;
};
bool operator==(DbEntity const& l, DbEntity const& r)
{
return l.val == r.val;
}
namespace TreeNodeTests
{
using namespace std;
TEST(TreeNode, add_child_parent_eq)
{
TreeNode<DbEntity> root;
auto const node = root.add_child(DbEntity{ 1 });
EXPECT_EQ(&root, node->parent());
}
TEST(TreeNode, get_1)
{
TreeNode<DbEntity> root;
auto const node = root.add_child(DbEntity{ 1 });
EXPECT_EQ(1, node->get().val);
}
TEST(TreeNode, add_child_1child_PrevIsNull)
{
TreeNode<DbEntity> root;
auto const node = root.add_child(DbEntity{ 1 });
EXPECT_EQ(nullptr, node->prev());
}
TEST(TreeNode, add_child_1child_NextIsNull)
{
TreeNode<DbEntity> root;
auto const node = root.add_child(DbEntity{ 1 });
EXPECT_EQ(nullptr, node->next());
}
TEST(TreeNode, add_child_1child_next_bfsIsNullAndNode)
{
TreeNode<DbEntity> root;
auto const node = root.add_child(DbEntity{ 1 });
EXPECT_EQ(nullptr, node->next_bfs());
EXPECT_EQ(node, root.next_bfs());
}
TEST(TreeNode, add_child_2child_PrevNextParent)
{
TreeNode<DbEntity> root;
auto const node1 = root.add_child(DbEntity{ 1 });
auto const node2 = root.add_child(DbEntity{ 2 });
EXPECT_EQ(1, node1->get().val);
EXPECT_EQ(2, node2->get().val);
EXPECT_EQ(&root, node1->parent());
EXPECT_EQ(&root, node2->parent());
EXPECT_EQ(nullptr, node1->prev());
EXPECT_EQ(node2, node1->next());
EXPECT_EQ(nullptr, node2->next());
}
TEST(TreeNode, add_child_2child_parentIsRoot)
{
TreeNode<DbEntity> root;
auto const node1 = root.add_child(DbEntity{ 1 });
auto const node2 = root.add_child(DbEntity{ 2 });
EXPECT_EQ(&root, node1->parent());
EXPECT_EQ(&root, node2->parent());
}
TEST(TreeNode, add_child_2child_valsAreOk)
{
TreeNode<DbEntity> root;
auto const node1 = root.add_child(DbEntity{ 1 });
auto const node2 = root.add_child(DbEntity{ 2 });
EXPECT_EQ(1, node1->get().val);
EXPECT_EQ(2, node2->get().val);
}
TEST(TreeNode, add_child_2child_prevAndnextAreOk)
{
TreeNode<DbEntity> root;
auto const node1 = root.add_child(DbEntity{ 1 });
auto const node2 = root.add_child(DbEntity{ 2 });
EXPECT_EQ(nullptr, node1->prev());
EXPECT_EQ(node2, node1->next());
EXPECT_EQ(nullptr, node2->next());
}
TEST(TreeNode, add_child_2child_next_bfsIsOk)
{
TreeNode<DbEntity> root;
auto const node1 = root.add_child(DbEntity{ 1 });
auto const node2 = root.add_child(DbEntity{ 2 });
EXPECT_EQ(node1, root.next_bfs());
EXPECT_EQ(node2, node1->next_bfs());
EXPECT_EQ(nullptr, node2->next_bfs());
}
TEST(TreeNode, add_child_2child1grandchild1_bfsOk)
{
TreeNode<DbEntity> root;
auto child1 = root.add_child(DbEntity{ 1 });
auto child2 = root.add_child(DbEntity{ 2 });
auto grandchild11 = child1->add_child(DbEntity{ 11 });
EXPECT_EQ(child2, child1->next_bfs());
EXPECT_EQ(grandchild11, child2->next_bfs());
EXPECT_EQ(nullptr, grandchild11->next_bfs());
}
TEST(TreeNode, add_child_2child1grandchild2_bfsOk)
{
TreeNode<DbEntity> root;
auto child1 = root.add_child(DbEntity{ 1 });
auto child2 = root.add_child(DbEntity{ 2 });
auto grandchild21 = child2->add_child(DbEntity{ 21 });
EXPECT_EQ(child2, child1->next_bfs());
EXPECT_EQ(grandchild21, child2->next_bfs());
EXPECT_EQ(nullptr, grandchild21->next_bfs());
}
TEST(TreeNode, add_child_2child2grandchildInOrder_bfsOk)
{
TreeNode<DbEntity> root;
auto child1 = root.add_child(DbEntity{ 1 });
auto child2 = root.add_child(DbEntity{ 2 });
auto grandchild11 = child1->add_child(DbEntity{ 11 });
auto grandchild21 = child2->add_child(DbEntity{ 21 });
EXPECT_EQ(child2, child1->next_bfs());
EXPECT_EQ(grandchild11, child2->next_bfs());
EXPECT_EQ(grandchild21, grandchild11->next_bfs());
EXPECT_EQ(nullptr, grandchild21->next_bfs());
}
TEST(TreeNode, add_child_2child2grandchildInReverseOrder_bfsOk)
{
TreeNode<DbEntity> root;
auto child1 = root.add_child(DbEntity{ 1 });
auto child2 = root.add_child(DbEntity{ 2 });
auto grandchild21 = child2->add_child(DbEntity{ 21 });
auto grandchild11 = child1->add_child(DbEntity{ 11 });
EXPECT_EQ(child2, child1->next_bfs());
EXPECT_EQ(grandchild11, child2->next_bfs());
EXPECT_EQ(grandchild21, grandchild11->next_bfs());
EXPECT_EQ(nullptr, grandchild21->next_bfs());
}
TEST(TreeNode, add_child_3child2grandchildInOrder_bfsOk)
{
TreeNode<DbEntity> root;
auto child1 = root.add_child(DbEntity{ 1 });
auto child2 = root.add_child(DbEntity{ 2 });
auto child3 = root.add_child(DbEntity{ 3 });
auto grandchild11 = child1->add_child(DbEntity{ 11 });
auto grandchild31 = child3->add_child(DbEntity{ 31 });
EXPECT_EQ(child2, child1->next_bfs());
EXPECT_EQ(child3, child2->next_bfs());
EXPECT_EQ(grandchild11, child3->next_bfs());
EXPECT_EQ(grandchild31, grandchild11->next_bfs());
EXPECT_EQ(nullptr, grandchild31->next_bfs());
EXPECT_EQ(6, root.size());
EXPECT_EQ(2, child3->size());
}
TEST(TreeNode, add_child_3child2grandchild3Atlast_bfsOk)
{
TreeNode<DbEntity> root;
auto child1 = root.add_child(DbEntity{ 1 });
auto child2 = root.add_child(DbEntity{ 2 });
auto grandchild11 = child1->add_child(DbEntity{ 11 });
auto child3 = root.add_child(DbEntity{ 3 });
auto grandchild31 = child3->add_child(DbEntity{ 31 });
EXPECT_EQ(child2, child1->next_bfs());
EXPECT_EQ(child3, child2->next_bfs());
EXPECT_EQ(grandchild11, child3->next_bfs());
EXPECT_EQ(grandchild31, grandchild11->next_bfs());
EXPECT_EQ(nullptr, grandchild31->next_bfs());
}
TEST(TreeNode, add_child_3child3grandchild_bfsOk)
{
TreeNode<DbEntity> root;
auto child1 = root.add_child(DbEntity{ 1 });
auto child2 = root.add_child(DbEntity{ 2 });
auto child3 = root.add_child(DbEntity{ 3 });
auto grandchild11 = child1->add_child(DbEntity{ 11 });
auto grandchild12 = child1->add_child(DbEntity{ 12 });
auto grandchild31 = child3->add_child(DbEntity{ 31 });
EXPECT_EQ(child2, child1->next_bfs());
EXPECT_EQ(child3, child2->next_bfs());
EXPECT_EQ(grandchild11, child3->next_bfs());
EXPECT_EQ(grandchild12, grandchild11->next_bfs());
EXPECT_EQ(grandchild31, grandchild12->next_bfs());
EXPECT_EQ(nullptr, grandchild31->next_bfs());
EXPECT_EQ(7, root.size());
EXPECT_EQ(3, child1->size());
}
TEST(TreeNode, add_child_3child3grandchild3Atlast_bfsOk)
{
TreeNode<DbEntity> root;
auto child1 = root.add_child(DbEntity{ 1 });
auto child2 = root.add_child(DbEntity{ 2 });
auto grandchild11 = child1->add_child(DbEntity{ 11 });
auto grandchild12 = child1->add_child(DbEntity{ 12 });
auto child3 = root.add_child(DbEntity{ 3 });
auto grandchild31 = child3->add_child(DbEntity{ 31 });
EXPECT_EQ(child2, child1->next_bfs());
EXPECT_EQ(child3, child2->next_bfs());
EXPECT_EQ(grandchild11, child3->next_bfs());
EXPECT_EQ(grandchild12, grandchild11->next_bfs());
EXPECT_EQ(grandchild31, grandchild12->next_bfs());
EXPECT_EQ(nullptr, grandchild31->next_bfs());
}
TEST(TreeNode, add_child_3_3_1_111_bfsOk)
{
TreeNode<DbEntity> root;
auto c1 = root.add_child(DbEntity{ 1 });
auto c2 = root.add_child(DbEntity{ 2 });
auto c3 = root.add_child(DbEntity{ 3 });
auto c11 = c1->add_child(DbEntity{ 11 });
auto c12 = c1->add_child(DbEntity{ 12 });
auto c31 = c3->add_child(DbEntity{ 31 });
auto c111 = c11->add_child(DbEntity{ 111 });
EXPECT_EQ(c2, c1->next_bfs());
EXPECT_EQ(c3, c2->next_bfs());
EXPECT_EQ(c11, c3->next_bfs());
EXPECT_EQ(c12, c11->next_bfs());
EXPECT_EQ(c31, c12->next_bfs());
EXPECT_EQ(c111, c31->next_bfs());
EXPECT_EQ(nullptr, c111->next_bfs());
}
TEST(TreeNode, add_child_3_3_1_111_r_bfsOk)
{
TreeNode<DbEntity> root;
auto c1 = root.add_child(DbEntity{ 1 });
auto c2 = root.add_child(DbEntity{ 2 });
auto c11 = c1->add_child(DbEntity{ 11 });
auto c12 = c1->add_child(DbEntity{ 12 });
auto c111 = c11->add_child(DbEntity{ 111 });
auto c3 = root.add_child(DbEntity{ 3 });
auto c31 = c3->add_child(DbEntity{ 31 });
EXPECT_EQ(c2, c1->next_bfs());
EXPECT_EQ(c3, c2->next_bfs());
EXPECT_EQ(c11, c3->next_bfs());
EXPECT_EQ(c12, c11->next_bfs());
EXPECT_EQ(c31, c12->next_bfs());
EXPECT_EQ(c111, c31->next_bfs());
EXPECT_EQ(nullptr, c111->next_bfs());
}
TEST(TreeNode, add_child_3_3_1_121_bfsOk)
{
TreeNode<DbEntity> root;
auto c1 = root.add_child(DbEntity{ 1 });
auto c2 = root.add_child(DbEntity{ 2 });
auto c3 = root.add_child(DbEntity{ 3 });
auto c11 = c1->add_child(DbEntity{ 11 });
auto c12 = c1->add_child(DbEntity{ 12 });
auto c31 = c3->add_child(DbEntity{ 31 });
auto c121 = c12->add_child(DbEntity{ 121 });
EXPECT_EQ(c2, c1->next_bfs());
EXPECT_EQ(c3, c2->next_bfs());
EXPECT_EQ(c11, c3->next_bfs());
EXPECT_EQ(c12, c11->next_bfs());
EXPECT_EQ(c31, c12->next_bfs());
EXPECT_EQ(c121, c31->next_bfs());
EXPECT_EQ(nullptr, c121->next_bfs());
}
TEST(TreeNode, add_child_3_3_1_121_r_bfsOk)
{
TreeNode<DbEntity> root;
auto c1 = root.add_child(DbEntity{ 1 });
auto c2 = root.add_child(DbEntity{ 2 });
auto c3 = root.add_child(DbEntity{ 3 });
auto c11 = c1->add_child(DbEntity{ 11 });
auto c12 = c1->add_child(DbEntity{ 12 });
auto c121 = c12->add_child(DbEntity{ 121 });
auto c31 = c3->add_child(DbEntity{ 31 });
EXPECT_EQ(c2, c1->next_bfs());
EXPECT_EQ(c3, c2->next_bfs());
EXPECT_EQ(c11, c3->next_bfs());
EXPECT_EQ(c12, c11->next_bfs());
EXPECT_EQ(c31, c12->next_bfs());
EXPECT_EQ(c121, c31->next_bfs());
EXPECT_EQ(nullptr, c121->next_bfs());
}
TEST(TreeNode, add_child_3_3_1_131_bfsOk)
{
TreeNode<DbEntity> root;
auto c1 = root.add_child(DbEntity{ 1 });
auto c2 = root.add_child(DbEntity{ 2 });
auto c3 = root.add_child(DbEntity{ 3 });
auto c11 = c1->add_child(DbEntity{ 11 });
auto c12 = c1->add_child(DbEntity{ 12 });
auto c31 = c3->add_child(DbEntity{ 31 });
auto c131 = c31->add_child(DbEntity{ 131 });
EXPECT_EQ(c2, c1->next_bfs());
EXPECT_EQ(c3, c2->next_bfs());
EXPECT_EQ(c11, c3->next_bfs());
EXPECT_EQ(c12, c11->next_bfs());
EXPECT_EQ(c31, c12->next_bfs());
EXPECT_EQ(c131, c31->next_bfs());
EXPECT_EQ(nullptr, c131->next_bfs());
}
TEST(TreeNode, add_child_3_3_1_211_131_bfsOk)
{
TreeNode<DbEntity> root;
auto c1 = root.add_child(DbEntity{ 1 });
auto c2 = root.add_child(DbEntity{ 2 });
auto c21 = c2->add_child(DbEntity{ 21 });
auto c211 = c21->add_child(DbEntity{ 211 });
auto c212 = c21->add_child(DbEntity{ 212 });
auto c3 = root.add_child(DbEntity{ 3 });
auto c11 = c1->add_child(DbEntity{ 11 });
auto c12 = c1->add_child(DbEntity{ 12 });
auto c31 = c3->add_child(DbEntity{ 31 });
auto c131 = c31->add_child(DbEntity{ 131 });
EXPECT_EQ(c2, c1->next_bfs());
EXPECT_EQ(c3, c2->next_bfs());
EXPECT_EQ(c11, c3->next_bfs());
EXPECT_EQ(c12, c11->next_bfs());
EXPECT_EQ(c21, c12->next_bfs());
EXPECT_EQ(c31, c21->next_bfs());
EXPECT_EQ(c211, c31->next_bfs());
EXPECT_EQ(c212, c211->next_bfs());
EXPECT_EQ(c131, c212->next_bfs());
EXPECT_EQ(nullptr, c131->next_bfs());
EXPECT_EQ(11, root.size());
EXPECT_EQ(3, c3->size());
EXPECT_EQ(1, c3->size_segment());
}
TEST(TreeNode, child_begin_in_depth__empty__0__root)
{
TreeNode<int> root(0);
auto node = root.child_begin_in_depth(0);
EXPECT_EQ(&root, node);
}
TEST(TreeNode, child_begin_in_depth__2level__0__root)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c11 = c1->add_child(11);
auto node = root.child_begin_in_depth(0);
EXPECT_EQ(&root, node);
}
TEST(TreeNode, child_begin_in_depth__2level__1__c1)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c11 = c1->add_child(11);
auto node = root.child_begin_in_depth(1);
EXPECT_EQ(c1, node);
}
TEST(TreeNode, child_begin_in_depth__2level__2__c11)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c11 = c1->add_child(11);
auto node = root.child_begin_in_depth(2);
EXPECT_EQ(c11, node);
}
TEST(TreeNode, child_begin_in_depth__2level__2__c21)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c21 = c2->add_child(21);
auto node = root.child_begin_in_depth(2);
EXPECT_EQ(c21, node);
}
TEST(TreeNode, child_begin_in_depth__3level__3__c211)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c21 = c2->add_child(21);
auto c211 = c21->add_child(211);
auto node = root.child_begin_in_depth(3);
EXPECT_EQ(c211, node);
}
TEST(TreeNode, child_begin_in_depth__3level__4__null)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c21 = c2->add_child(21);
auto c211 = c21->add_child(211);
auto node = root.child_begin_in_depth(4);
EXPECT_EQ(nullptr, node);
}
TEST(TreeNode, child_end_in_depth__empty__0__null)
{
TreeNode<int> root(0);
auto node = root.child_end_in_depth(0);
EXPECT_EQ(nullptr, node);
}
TEST(TreeNode, child_end_in_depth__2level__0__c1)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c11 = c1->add_child(11);
auto node = root.child_end_in_depth(0);
EXPECT_EQ(c1, node);
}
TEST(TreeNode, child_end_in_depth__2level__1__c11)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c11 = c1->add_child(11);
auto node = root.child_end_in_depth(1);
EXPECT_EQ(c11, node);
}
TEST(TreeNode, child_end_in_depth__2level11__2__null)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c11 = c1->add_child(11);
auto node = root.child_end_in_depth(2);
EXPECT_EQ(nullptr, node);
}
TEST(TreeNode, child_end_in_depth__2level21__2__null)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c21 = c2->add_child(21);
auto node = root.child_end_in_depth(2);
EXPECT_EQ(nullptr, node);
}
TEST(TreeNode, child_end_in_depth__3level__2__c211)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c21 = c2->add_child(21);
auto c211 = c21->add_child(211);
auto node = root.child_end_in_depth(2);
EXPECT_EQ(c211, node);
}
TEST(TreeNode, child_end_in_depth__3level__4__null)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto c21 = c2->add_child(21);
auto c211 = c21->add_child(211);
auto node = root.child_end_in_depth(4);
EXPECT_EQ(nullptr, node);
}
TEST(TreeNode, clear_root_DoesNothing)
{
TreeNode<int> root(0);
root.clear();
EXPECT_EQ(0, root.get());
EXPECT_EQ(nullptr, root.child_first());
EXPECT_EQ(nullptr, root.next());
}
TEST(TreeNode, clear_root_ChildsAreNull)
{
TreeNode<int> root(0);
root.add_child(1)->add_child(11);
root.add_child(2);
root.add_child(3);
root.clear();
EXPECT_EQ(nullptr, root.child_first());
EXPECT_EQ(nullptr, root.child_last());
EXPECT_EQ(1, root.size());
}
TEST(TreeNode, clear_c21_complex)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
c1->add_child(11)
->add_child(111)
->parent()
->add_child(112)
->parent()
->add_child(113)
->add_child(1131)
->add_child(11311);
auto c21 = root.add_child(2)
->add_child(21);
c21->add_child(211)
->add_child(2111);
c21->add_child(212)
->add_child(2121);
c21->add_child(213)
->add_child(2131);
root.add_child(3);
vector<int> vals_before;
copy(root.begin(), root.end(), back_inserter(vals_before));
vector<int> const expected_before = { 0, 1, 2, 3, 11, 21, 111, 112, 113, 211, 212, 213, 1131, 2111, 2121, 2131, 11311 };
EXPECT_EQ(expected_before, vals_before);
c21->clear();
vector<int> vals_after;
copy(root.begin(), root.end(), back_inserter(vals_after));
vector<int> const expected_after = { 0, 1, 2, 3, 11, 21, 111, 112, 113, 1131, 11311 };
EXPECT_EQ(expected_after, vals_after);
EXPECT_EQ(11, root.size());
EXPECT_EQ(7, c1->size());
}
TEST(TreeNode, remove_c21_1level)
{
TreeNode<int> root(0);
root.add_child(1);
auto c2 = root.add_child(2);
root.add_child(3);
c2->remove();
vector<int> vals;
copy(root.begin(), root.end(), back_inserter(vals));
vector<int> expected = { 0, 1, 3 };
EXPECT_EQ(expected, vals);
EXPECT_EQ(3, root.size());
}
TEST(TreeNode, remove_c21_complex)
{
TreeNode<int> root(0);
root.add_child(1)
->add_child(11)
->add_child(111)
->parent()
->add_child(112)
->parent()
->add_child(113)
->add_child(1131)
->add_child(11311);
auto c2 = root.add_child(2);
auto c21 = c2->add_child(21);
c21->add_child(211)
->add_child(2111);
c21->add_child(212)
->add_child(2121);
c21->add_child(213)
->add_child(2131);
root.add_child(3);
vector<int> vals_before;
copy(root.begin(), root.end(), back_inserter(vals_before));
vector<int> const expected_before = { 0, 1, 2, 3, 11, 21, 111, 112, 113, 211, 212, 213, 1131, 2111, 2121, 2131, 11311 };
EXPECT_EQ(expected_before, vals_before);
c21->remove();
vector<int> vals_after;
copy(root.begin(), root.end(), back_inserter(vals_after));
vector<int> const expected_after = { 0, 1, 2, 3, 11, 111, 112, 113, 1131, 11311 };
EXPECT_EQ(expected_after, vals_after);
EXPECT_EQ(10, root.size());
EXPECT_EQ(1, c2->size());
}
TEST(TreeNode, begin_segment_const_ShouldCompile)
{
TreeNode<int> const root;
root.begin_segment();
}
TEST(TreeNode, end_segment_const_ShouldCompile)
{
TreeNode<int> const root;
root.end_segment();
}
TEST(TreeNode, begin_segment_nodeptr_const_ShouldCompile)
{
TreeNode<int> const root;
root.begin_segment<TreeNode<int> const*>();
}
TEST(TreeNode, end_segment_nodeptr_const_ShouldCompile)
{
TreeNode<int> const root;
root.end_segment<TreeNode<int> const*>();
}
TEST(TreeNode, begin_dfs_const_ShouldCompile)
{
TreeNode<int> const root;
root.begin_dfs();
}
TEST(TreeNode, end_dfs_const_ShouldCompile)
{
TreeNode<int> const root;
root.end_dfs();
}
TEST(TreeNode, begin_dfs_nodeptr_const_ShouldCompile)
{
TreeNode<int> const root;
root.begin_dfs<TreeNode<int> const*>();
}
TEST(TreeNode, end_dfs_nodeptr_const_ShouldCompile)
{
TreeNode<int> const root;
root.end_dfs<TreeNode<int> const*>();
}
TEST(TreeNode, begin_bfs_const_ShouldCompile)
{
TreeNode<int> const root;
root.begin_bfs();
}
TEST(TreeNode, end_bfs_const_ShouldCompile)
{
TreeNode<int> const root;
root.end_bfs();
}
TEST(TreeNode, begin_bfs_nodeptr_const_ShouldCompile)
{
TreeNode<int> const root;
root.begin_bfs<TreeNode<int> const*>();
}
TEST(TreeNode, end_bfs_nodeptr_const_ShouldCompile)
{
TreeNode<int> const root;
root.end_bfs<TreeNode<int> const*>();
}
TEST(TreeNode, begin_const_ShouldCompile)
{
TreeNode<int> const root;
root.begin();
}
TEST(TreeNode, end_const_ShouldCompile)
{
TreeNode<int> const root;
root.end();
}
TEST(TreeNode, copyctor)
{
TreeNode<int> root(0);
auto c11o = root.add_child(1)->add_child(11);
root.add_child(2);
root.add_child(3);
auto root_copied(root);
EXPECT_EQ(0, root_copied.get());
auto c1 = root_copied.next_bfs();
EXPECT_EQ(1, c1->get());
auto c2 = c1->next_bfs();
EXPECT_EQ(2, c2->get());
auto c3 = c2->next_bfs();
EXPECT_EQ(3, c3->get());
auto c11 = c3->next_bfs();
EXPECT_EQ(11, c11->get());
EXPECT_EQ(c11, c1->child_first());
EXPECT_NE(c11, c11o);
}
TEST(TreeNode, initializerlist)
{
TreeNode<int> root = { 0, 1, 2, 3};
EXPECT_EQ(0, root.get());
auto c1 = root.next_bfs();
EXPECT_EQ(1, c1->get());
auto c2 = c1->next_bfs();
EXPECT_EQ(2, c2->get());
auto c3 = c2->next_bfs();
EXPECT_EQ(3, c3->get());
}
TEST(TreeNode, foreach)
{
TreeNode<int> root = { 0, 1, 2, 3 };
auto c11 = root.child_first()->add_child(4);
c11->add_child(5);
int i = 0;
for (auto v : root)
EXPECT_EQ(i++, v);
}
}
namespace IteratorSegmentTests
{
using namespace std;
TEST(IteratorSegment, begin_segment_RootEmptySg_Null)
{
TreeNode<DbEntity> root;
EXPECT_EQ(IteratorSegment<DbEntity>(nullptr), root.begin_segment());
}
TEST(IteratorSegment, end_segment_RootEmptySg_Null)
{
TreeNode<DbEntity> root;
EXPECT_EQ(IteratorSegment<DbEntity>(nullptr), root.end_segment());
}
TEST(IteratorSegment, begin_segment_1Child_Is1)
{
TreeNode<DbEntity> root;
auto const node = root.add_child(DbEntity{ 1 });
EXPECT_EQ(node->get().val, (*root.begin_segment()).val);
}
TEST(IteratorSegment, end_segment_1Child_IsNull)
{
TreeNode<DbEntity> root;
auto const node = root.add_child(DbEntity{ 1 });
EXPECT_EQ(IteratorSegment<DbEntity>(nullptr), root.end_segment());
}
TEST(IteratorSegment, pointer_operator_T)
{
TreeNode<DbEntity> root;
auto const node = root.add_child(DbEntity{ 1 });
EXPECT_EQ(node->get().val, root.begin_segment()->val);
}
TEST(IteratorSegment, usability_copy_value123)
{
TreeNode<DbEntity> root;
root.add_child(DbEntity{ 1 });
root.add_child(DbEntity{ 2 });
root.add_child(DbEntity{ 3 });
vector<DbEntity> vals;
copy(root.begin_segment(), root.end_segment(), back_inserter(vals));
auto const expected = vector<DbEntity>{ DbEntity{1}, DbEntity{2}, DbEntity{3} };
EXPECT_EQ(expected, vals);
}
TEST(IteratorSegment, usability_copy_node123)
{
TreeNode<DbEntity> root;
auto node1 = root.add_child(DbEntity{ 1 });
auto node2 = root.add_child(DbEntity{ 2 });
auto node3 = root.add_child(DbEntity{ 3 });
vector<TreeNode<DbEntity>*> vals;
copy(root.begin_segment<TreeNode<DbEntity>*>(), root.end_segment<TreeNode<DbEntity>*>(), back_inserter(vals));
auto const expected = vector<TreeNode<DbEntity>*>{ node1, node2, node3 };
EXPECT_EQ(expected, vals);
}
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
TEST(IteratorSegment, usability_copy_par_val10)
{
constexpr int n = 10;
TreeNode<DbEntity> root;
vector<DbEntity> expected;
for (int i = 0; i < n; ++i)
root.add_child(expected.emplace_back(DbEntity{ i + 1 }));
vector<DbEntity> vals(n);
copy(execution::par_unseq, root.begin_segment(), root.end_segment(), vals.begin());
EXPECT_EQ(expected, vals);
}
#endif
}
namespace IteratorDepthFirstSearchTests
{
using namespace std;
TEST(IteratorDfs, order_copy_value0)
{
TreeNode<int> root(0);
vector<int> vals;
copy(root.begin_dfs(), root.end_dfs(), back_inserter(vals));
auto const expected = vector<int>{ 0 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorDfs, order_copy_value0123)
{
TreeNode<int> root;
root.add_child(1);
root.add_child(2);
root.add_child(3);
vector<int> vals;
copy(root.begin_dfs(), root.end_dfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 2, 3};
EXPECT_EQ(expected, vals);
}
TEST(IteratorDfs, order_copy_value011123)
{
TreeNode<int> root;
auto n1 = root.add_child(1);
auto n2 = root.add_child(2);
auto n3 = root.add_child(3);
n1->add_child(11);
vector<int> vals;
copy(root.begin_dfs(), root.end_dfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 11, 2, 3 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorDfs, order_copy_value012213)
{
TreeNode<int> root;
root.add_child(1);
root.add_child(2)
->add_child(21);
root.add_child(3);
vector<int> vals;
copy(root.begin_dfs(), root.end_dfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 2, 21, 3 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorDfs, order_copy_value012331)
{
TreeNode<int> root;
root.add_child(1);
root.add_child(2);
root.add_child(3)
->add_child(31);
vector<int> vals;
copy(root.begin_dfs(), root.end_dfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 2, 3, 31 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorDfs, order_copy_value01112331)
{
TreeNode<int> root;
root.add_child(1)
->add_child(11);
root.add_child(2);
root.add_child(3)
->add_child(31);
vector<int> vals;
copy(root.begin_dfs(), root.end_dfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 11, 2, 3, 31 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorDfs, order_copy_value011111123)
{
TreeNode<int> root;
root.add_child(1)
->add_child(11)
->add_child(111);
root.add_child(2);
root.add_child(3);
vector<int> vals;
copy(root.begin_dfs(), root.end_dfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 11, 111, 2, 3 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorDfs, order_copy_value01111112212113)
{
TreeNode<int> root;
root.add_child(1)
->add_child(11)
->add_child(111);
auto n2 = root.add_child(2)
->add_child(21)
->add_child(211);
auto n3 = root.add_child(3);
vector<int> vals;
copy(root.begin_dfs(), root.end_dfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 11, 111, 2, 21, 211, 3 };
EXPECT_EQ(expected, vals);
}
TEST(StepManagerDfs, next_1_null)
{
TreeNode<int> root;
TreeNode<int>* node = &root;
StepManagerDfs::next<TreeNode<int>>(node);
EXPECT_EQ(nullptr, node);
}
TEST(StepManagerDfs, prev_1_null)
{
TreeNode<int> root;
TreeNode<int>* node = &root;
StepManagerDfs::prev<TreeNode<int>>(node);
EXPECT_EQ(nullptr, node);
}
TEST(StepManagerDfs, next_parent_child)
{
TreeNode<int> root(0);
auto node = &root;
auto ch = root.add_child(1);
StepManagerDfs::next<TreeNode<int>>(node);
EXPECT_EQ(ch, node);
}
TEST(StepManagerDfs, prev_parent_child)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto node = c1;
StepManagerDfs::prev<TreeNode<int>>(node);
EXPECT_EQ(&root, node);
}
TEST(StepManagerDfs, next_neighbour)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto node = c1;
StepManagerDfs::next<TreeNode<int>>(node);
EXPECT_EQ(c2, node);
}
TEST(StepManagerDfs, prev_neighbour)
{
TreeNode<int> root(0);
auto c1 = root.add_child(1);
auto c2 = root.add_child(2);
auto node = c2;
StepManagerDfs::prev<TreeNode<int>>(node);
EXPECT_EQ(c1, node);
}
TEST(StepManagerDfs, next_c1111_to_c2)
{
TreeNode<int> root(0);
auto c1111 = root.add_child(1)
->add_child(11)
->add_child(111)
->add_child(1111);
auto c2 = root.add_child(2);
auto node = c1111;
StepManagerDfs::next<TreeNode<int>>(node);
EXPECT_EQ(c2, node);
}
TEST(StepManagerDfs, prev_c2_to_c1111)
{
TreeNode<int> root(0);
auto c1111 = root.add_child(1)
->add_child(11)
->add_child(111)
->add_child(1111);
auto c2 = root.add_child(2);
auto node = c2;
StepManagerDfs::prev<TreeNode<int>>(node);
EXPECT_EQ(c1111, node);
}
TEST(StepManagerDfs, next_c1111_null)
{
TreeNode<int> root(0);
auto c1111 = root.add_child(1)
->add_child(11)
->add_child(111)
->add_child(1111);
auto node = c1111;
StepManagerDfs::next<TreeNode<int>>(node);
EXPECT_EQ(nullptr, node);
}
TEST(StepManagerDfs, prev_c1111_c111)
{
TreeNode<int> root(0);
auto c111 = root.add_child(1)
->add_child(11)
->add_child(111);
auto c1111 = c111->add_child(1111);
auto node = c1111;
StepManagerDfs::prev<TreeNode<int>>(node);
EXPECT_EQ(c111, node);
}
}
namespace IteratorBreadthFirstSearchTests
{
using namespace std;
TEST(IteratorBfs, order_copy_value0)
{
TreeNode<int> root(0);
vector<int> vals;
copy(root.begin_bfs(), root.end_bfs(), back_inserter(vals));
auto const expected = vector<int>{ 0 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorBfs, order_copy_value0123)
{
TreeNode<int> root;
root.add_child(1);
root.add_child(2);
root.add_child(3);
vector<int> vals;
copy(root.begin_bfs(), root.end_bfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 2, 3 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorBfs, order_copy_value012311212231111311)
{
TreeNode<int> root;
root.add_child(1)
->add_child(11)
->add_child(111);
auto node2 = root.add_child(2);
node2->add_child(21);
root.add_child(3)
->add_child(31)
->add_child(311);
node2->add_child(22);
vector<int> vals;
copy(root.begin_bfs(), root.end_bfs(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 2, 3, 11, 21, 22, 31, 111, 311 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorBfs, order_inrange_level23_copy_value11212231111311)
{
TreeNode<int> root;
root.add_child(1)
->add_child(11)
->add_child(111);
auto node2 = root.add_child(2);
node2->add_child(21);
root.add_child(3)
->add_child(31)
->add_child(311)
->add_child(3111);
node2->add_child(22);
vector<int> vals;
copy(root.begin_bfs(2), root.end_bfs(3), back_inserter(vals));
auto const expected = vector<int>{ 11, 21, 22, 31, 111, 311 };
EXPECT_EQ(expected, vals);
}
TEST(IteratorBfs, begin_end_const_ShouldCompile)
{
TreeNode<int> root;
root.add_child(1)
->add_child(11)
->add_child(111);
auto node2 = root.add_child(2);
node2->add_child(21);
root.add_child(3)
->add_child(31)
->add_child(311);
node2->add_child(22);
auto const& root_const = root;
vector<int> vals;
copy(root_const.begin(), root_const.end(), back_inserter(vals));
auto const expected = vector<int>{ 0, 1, 2, 3, 11, 21, 22, 31, 111, 311 };
EXPECT_EQ(expected, vals);
}
} | 24.428125 | 124 | 0.646444 | attcs |
f9244945ecec1e566af7c4149db1742b7f2ee1f7 | 469 | cpp | C++ | lcm.cpp | shu736/First | 034d0326def08fb6b104411dd3b37eb6c1e03eda | [
"MIT"
] | null | null | null | lcm.cpp | shu736/First | 034d0326def08fb6b104411dd3b37eb6c1e03eda | [
"MIT"
] | null | null | null | lcm.cpp | shu736/First | 034d0326def08fb6b104411dd3b37eb6c1e03eda | [
"MIT"
] | null | null | null | #include <stdio.h>
int lcm(int, int);
int main()
{
int a, b, result;
int prime[100];
printf("Enter two numbers: ");
scanf("%d%d", &a, &b);
result = lcm(a, b);
printf("The LCM of %d and %d is %d\n", a, b, result);
return 0;
}
int lcm(int a, int b)
{
static int common = 1;
if (common % a == 0 && common % b == 0)
{
return common;
}
common++;
lcm(a, b);
return common;
}
| 16.75 | 58 | 0.460554 | shu736 |
234d42fdfc563de21241340a582b66d85721babd | 28,425 | cpp | C++ | src/j_plot.cpp | tsyw/JoSIM | c1dc2a127787a5f5f6750ef84768f30abee8dcae | [
"MIT"
] | 1 | 2020-07-25T12:15:30.000Z | 2020-07-25T12:15:30.000Z | src/j_plot.cpp | tsyw/JoSIM | c1dc2a127787a5f5f6750ef84768f30abee8dcae | [
"MIT"
] | null | null | null | src/j_plot.cpp | tsyw/JoSIM | c1dc2a127787a5f5f6750ef84768f30abee8dcae | [
"MIT"
] | null | null | null | // Copyright (c) 2018 Johannes Delport
// This code is licensed under MIT license (see LICENSE for details)
#include "j_plot.hpp"
#ifdef USING_MATPLOTLIB
namespace plt = matplotlibcpp;
#endif
/*
Determine traces to plot from the control part of the main circuit
*/
void traces_to_plot(InputFile& iFile, std::vector<std::string> controlPart, std::vector<std::string>& traceLabel, std::vector<std::vector<double>>& traceData) {
std::vector<std::string> tokens, labeltokens, nodesTokens;
std::vector<double> trace;
std::map<std::string, std::vector<double>> traces;
std::string columnLabel1, columnLabel2, label, nodesToPlot;
int index1 = -1;
int index2 = -1;
for (const auto &string : controlPart) {
/****************************************************/
/* PRINT */
/****************************************************/
if (string.find("PRINT") != std::string::npos) {
tokens = tokenize_space(string);
/* Print the identified node voltage */
/*****************************************************************************************************/
if (tokens[1] == "NODEV") {
/* If more than one node is specified */
if (tokens.size() == 4) {
/* If second node is ground */
if(tokens[3] == "0" || tokens[3] == "GND") {
label = "NODE VOLTAGE " + tokens[2];
if (tokens[2][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[2], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
tokens[2] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
tokens[2] = tokens[2] + "_" + labeltokens[n];
}
}
columnLabel1 = "C_NV" + tokens[2];
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
traceLabel.push_back(label);
traceData.push_back(xVect[index1]);
}
else {
/* Error this node was not found and can therefore not be printed */
plotting_errors(NO_SUCH_NODE_FOUND, tokens[2]);
}
}
/* If first node is ground */
else if (tokens[2] == "0" || tokens[3] == "GND") {
label = "NODE VOLTAGE " + tokens[3];
if (tokens[3][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[3], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
tokens[3] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
tokens[3] = tokens[3] + "_" + labeltokens[n];
}
}
columnLabel1 = "C_NV" + tokens[3];
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
trace.clear();
trace = xVect[index1];
std::fill(trace.begin(), trace.end(), 0.0);
std::transform(trace.begin(), trace.end(), xVect[index1].begin(), trace.begin(), std::minus<double>());
traceLabel.push_back(label);
traceData.push_back(trace);
}
else {
/* Error this node was not found and can therefore not be printed */
plotting_errors(NO_SUCH_NODE_FOUND, tokens[3]);
}
}
/* If neither are ground*/
else {
label = "NODE VOLTAGE " + tokens[2] + " to " + tokens[3];
columnLabel1 = "C_NV" + tokens[2];
columnLabel2 = "C_NV" + tokens[3];
if (tokens[2][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[2], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
tokens[2] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
tokens[2] = tokens[2] + "_" + labeltokens[n];
}
}
if (tokens[3][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[3], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
tokens[3] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
tokens[3] = tokens[3] + "_" + labeltokens[n];
}
}
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
trace.clear();
trace = xVect[index1];
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel2) != iFile.matA.columnNames.end()) {
index2 = index_of(iFile.matA.columnNames, columnLabel2);
std::transform(xVect[index1].begin(), xVect[index1].end(), xVect[index2].begin(), trace.begin(), std::minus<double>());
traceLabel.push_back(label);
traceData.push_back(trace);
}
else {
/* Error this node was not found and can therefore not be printed */
plotting_errors(NO_SUCH_NODE_FOUND, tokens[3]);
}
}
else {
/* Error this node was not found and can therefore not be printed */
plotting_errors(NO_SUCH_NODE_FOUND, tokens[2]);
}
}
}
/* If only one node is specified */
else {
label = "NODE VOLTAGE " + tokens[2];
columnLabel1 = "C_NV" + tokens[2];
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
traceLabel.push_back(label);
traceData.push_back(xVect[index1]);
}
else {
/* Error this node was not found and can therefore not be printed */
}
}
}
/* Print the identified junction phase */
/*****************************************************************************************************/
else if (tokens[1] == "PHASE") {
label = "PHASE " + tokens[2];
if (tokens[2][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[2], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
tokens[2] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
tokens[2] = tokens[2] + "_" + labeltokens[n];
}
}
columnLabel1 = "C_P" + tokens[2];
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
traceLabel.push_back(label);
traceData.push_back(xVect[index1]);
}
else {
/* Error this node was not found and can therefore not be printed */
plotting_errors(NO_SUCH_DEVICE_FOUND, tokens[2]);
}
}
/* Print the identified device voltage */
/*****************************************************************************************************/
else if (tokens[1] == "DEVV") {
label = "NOTHING";
if (tokens[2][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[2], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
tokens[2] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
tokens[2] = tokens[2] + "_" + labeltokens[n];
}
}
for (auto i : iFile.matA.elements) {
if (i.label == tokens[2]) {
trace.clear();
if (i.VPindex == -1) trace = xVect[i.VNindex];
else if (i.VNindex == -1) trace = xVect[i.VPindex];
else {
trace = xVect[i.VPindex];
std::transform(xVect[i.VPindex].begin(), xVect[i.VPindex].end(), xVect[i.VNindex].begin(), trace.begin(), std::minus<double>());
}
label = "DEVICE VOLTAGE " + i.label;
traceLabel.push_back(label);
traceData.push_back(trace);
}
}
if (label == "NOTHING") {
if (VERBOSE) plotting_errors(NO_SUCH_DEVICE_FOUND, tokens[2]);
}
}
/* Print the identified device current */
/*****************************************************************************************************/
else if (tokens[1] == "DEVI") {
label = "NOTHING";
if (tokens[2][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[2], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
tokens[2] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
tokens[2] = tokens[2] + "_" + labeltokens[n];
}
}
std::vector<double> trace;
for (auto i : iFile.matA.elements) {
if (i.label == tokens[2]) {
if (tokens[2][0] == 'R') {
if (i.VPindex == -1) trace = xVect[i.VNindex];
else if (i.VNindex == -1) trace = xVect[i.VPindex];
else std::transform(xVect[i.VPindex].begin(), xVect[i.VPindex].end(), xVect[i.VNindex].begin(), trace.begin(), std::minus<double>());
std::transform(trace.begin(), trace.end(), trace.begin(), std::bind(std::multiplies<double>(), std::placeholders::_1, (1/i.value)));
label = "DEVICE CURRENT " + i.label;
traceLabel.push_back(label);
traceData.push_back(trace);
}
else if (tokens[2][0] == 'C') {
}
else if (tokens[2][0] == 'L') {
if (i.CURindex == -1) simulation_errors(INDUCTOR_CURRENT_NOT_FOUND, i.label);
else trace = xVect[i.CURindex];
label = "DEVICE CURRENT " + i.label;
traceLabel.push_back(label);
traceData.push_back(trace);
}
else if (tokens[2][0] == 'I') {
label = "DEVICE CURRENT " + i.label;
traceLabel.push_back(label);
traceData.push_back(iFile.matA.sources[i.label]);
}
else if (tokens[2][0] == 'V') {
if (VERBOSE) simulation_errors(CURRENT_THROUGH_VOLTAGE_SOURCE, i.label);
}
else if (tokens[2][0] == 'B') {
trace = junctionCurrents["R_" + i.label];
label = "DEVICE CURRENT " + i.label;
traceLabel.push_back(label);
traceData.push_back(trace);
}
else plotting_errors(NO_SUCH_DEVICE_FOUND, tokens[2]);
}
}
if (label == "NOTHING") {
plotting_errors(NO_SUCH_DEVICE_FOUND, tokens[2]);
}
}
/* No such print command error thrown */
else {
if (VERBOSE) plotting_errors(NO_SUCH_PLOT_TYPE, tokens[1]);
}
}
/****************************************************/
/* PLOT */
/****************************************************/
else if (string.find("PLOT") != std::string::npos) {
tokens = tokenize_space(string);
for (int k = 1; k < tokens.size(); k++) {
/* If plotting voltage */
if(tokens[k][0] == 'V') {
/* Identify part between brackets */
nodesToPlot = tokens[k].substr(2);
nodesToPlot = nodesToPlot.substr(0, nodesToPlot.size() - 1);
/* If multiple arguments are specified for V */
if (nodesToPlot.find(',') != std::string::npos) {
nodesTokens = tokenize_delimeter(nodesToPlot, ",");
if(nodesTokens.size() > 2) {
plotting_errors(TOO_MANY_NODES, string);
}
/* Ensure node 1 is not ground */
if(nodesTokens[0] == "0" || nodesTokens[0] == "GND") {
if(nodesTokens[1] == "0" || nodesTokens[1] == "GND") {
plotting_errors(BOTH_ZERO, string);
}
else {
if (nodesTokens[1][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[1], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
nodesTokens[1] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
nodesTokens[1] = nodesTokens[1] + "_" + labeltokens[n];
}
}
columnLabel1 = "C_NV" + nodesTokens[1];
/* If this is a node voltage */
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
trace.clear();
trace = xVect[index1];
std::fill(trace.begin(), trace.end(), 0.0);
std::transform(trace.begin(), trace.end(), xVect[index1].begin(), trace.begin(), std::minus<double>());
traceLabel.push_back(label);
traceData.push_back(trace);
}
/* Else node not found */
else {
plotting_errors(NO_SUCH_NODE_FOUND, string);
}
}
}
/* Check if node 2 is ground */
else {
if(tokens[1] == "0" || tokens[1] == "GND") {
if (tokens[0][0] == 'X') {
labeltokens = tokenize_delimeter(tokens[0], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
tokens[0] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
tokens[0] = tokens[0] + "_" + labeltokens[n];
}
}
columnLabel1 = "C_NV" + tokens[0];
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
traceLabel.push_back(label);
traceData.push_back(xVect[index1]);
}
else {
plotting_errors(NO_SUCH_NODE_FOUND, string);
}
}
/* Neither nodes are ground */
else {
label = "NODE VOLTAGE " + nodesTokens[0] + " to " + nodesTokens[1];
columnLabel1 = "C_NV" + nodesTokens[0];
columnLabel2 = "C_NV" + nodesTokens[1];
if (nodesTokens[0][0] == 'X') {
labeltokens = tokenize_delimeter(nodesTokens[0], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
nodesTokens[0] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
nodesTokens[0] = nodesTokens[0] + "_" + labeltokens[n];
}
}
if (nodesTokens[1][0] == 'X') {
labeltokens = tokenize_delimeter(nodesTokens[1], "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
nodesTokens[1] = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
nodesTokens[1] = nodesTokens[1] + "_" + labeltokens[n];
}
}
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
trace.clear();
trace = xVect[index1];
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel2) != iFile.matA.columnNames.end()) {
index2 = index_of(iFile.matA.columnNames, columnLabel2);
std::transform(xVect[index1].begin(), xVect[index1].end(), xVect[index2].begin(), trace.begin(), std::minus<double>());
traceLabel.push_back(label);
traceData.push_back(trace);
}
else {
/* Error this node was not found and can therefore not be printed */
plotting_errors(NO_SUCH_NODE_FOUND, string);
}
}
}
}
}
/* If only one argument is specified for V */
else {
/* Ensure node is not ground */
if(nodesToPlot != "0" || nodesToPlot != "GND") {
if (nodesToPlot[0] == 'X') {
labeltokens = tokenize_delimeter(nodesToPlot, "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
nodesToPlot = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
nodesToPlot = nodesToPlot + "_" + labeltokens[n];
}
}
label = "C_NV" + nodesToPlot;
/* If this is a node voltage */
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), label) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, label);
label = "NODE VOLTAGE " + nodesToPlot;
traceLabel.push_back(label);
traceData.push_back(xVect[index1]);
}
/* Else it might be device voltage */
else {
label = "NOTHING";
for (auto i : iFile.matA.elements) {
if (i.label == nodesToPlot) {
trace.clear();
if (i.VPindex == -1) trace = xVect[i.VNindex];
else if (i.VNindex == -1) trace = xVect[i.VPindex];
else {
trace = xVect[i.VPindex];
std::transform(xVect[i.VPindex].begin(), xVect[i.VPindex].end(), xVect[i.VNindex].begin(), trace.begin(), std::minus<double>());
}
label = "DEVICE VOLTAGE " + i.label;
traceLabel.push_back(label);
traceData.push_back(trace);
}
}
if (label == "NOTHING") {
if (VERBOSE) plotting_errors(NO_SUCH_DEVICE_FOUND, nodesToPlot);
}
}
}
}
}
else if (tokens[k][0] == 'I') {
/* Identify part between brackets */
nodesToPlot = tokens[k].substr(2);
nodesToPlot = nodesToPlot.substr(0, nodesToPlot.size() - 1);
label = "NOTHING";
if (nodesToPlot[0] == 'X') {
labeltokens = tokenize_delimeter(nodesToPlot, "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
nodesToPlot = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
nodesToPlot = nodesToPlot + "_" + labeltokens[n];
}
}
std::vector<double> trace;
for (auto i : iFile.matA.elements) {
if (i.label == nodesToPlot) {
if (nodesToPlot[0] == 'R') {
if (i.VPindex == -1) trace = xVect[i.VNindex];
else if (i.VNindex == -1) trace = xVect[i.VPindex];
else std::transform(xVect[i.VPindex].begin(), xVect[i.VPindex].end(), xVect[i.VNindex].begin(), trace.begin(), std::minus<double>());
std::transform(trace.begin(), trace.end(), trace.begin(), std::bind(std::multiplies<double>(), std::placeholders::_1, (1/i.value)));
label = "DEVICE CURRENT " + i.label;
traceLabel.push_back(label);
traceData.push_back(trace);
}
else if (nodesToPlot[0] == 'C') {
}
else if (nodesToPlot[0] == 'L') {
if (i.CURindex == -1) simulation_errors(INDUCTOR_CURRENT_NOT_FOUND, i.label);
else trace = xVect[i.CURindex];
label = "DEVICE CURRENT " + i.label;
traceLabel.push_back(label);
traceData.push_back(trace);
}
else if (nodesToPlot[0] == 'I') {
label = "DEVICE CURRENT " + i.label;
traceLabel.push_back(label);
traceData.push_back(iFile.matA.sources[i.label]);
}
else if (nodesToPlot[0] == 'V') {
if (VERBOSE) simulation_errors(CURRENT_THROUGH_VOLTAGE_SOURCE, i.label);
}
else if (nodesToPlot[0] == 'B') {
trace = junctionCurrents["R_" + i.label];
label = "DEVICE CURRENT " + i.label;
traceLabel.push_back(label);
traceData.push_back(trace);
}
else plotting_errors(NO_SUCH_DEVICE_FOUND, string);
}
}
if (label == "NOTHING") {
plotting_errors(NO_SUCH_DEVICE_FOUND, string);
}
}
else if (tokens[k][0] == 'P') {
/* Identify part between brackets */
nodesToPlot = tokens[k].substr(2);
nodesToPlot = nodesToPlot.substr(0, nodesToPlot.size() - 1);
label = "PHASE " + nodesToPlot;
if (nodesToPlot[0] == 'X') {
labeltokens = tokenize_delimeter(nodesToPlot, "_");
std::rotate(labeltokens.begin(), labeltokens.end() - 1, labeltokens.end());
nodesToPlot = labeltokens[0];
for (int n = 1; n < labeltokens.size(); n++) {
nodesToPlot = nodesToPlot + "_" + labeltokens[n];
}
}
columnLabel1 = "C_P" + nodesToPlot;
if (std::find(iFile.matA.columnNames.begin(), iFile.matA.columnNames.end(), columnLabel1) != iFile.matA.columnNames.end()) {
index1 = index_of(iFile.matA.columnNames, columnLabel1);
traceLabel.push_back(label);
traceData.push_back(xVect[index1]);
}
else {
/* Error this node was not found and can therefore not be printed */
plotting_errors(NO_SUCH_DEVICE_FOUND, nodesToPlot);
}
}
}
}
/****************************************************/
/* SAVE */
/****************************************************/
else if (string.find("SAVE") != std::string::npos) {
tokens = tokenize_space(string);
for (int k = 1; k < tokens.size(); k++) {
index1 = tokens[k].find("@");
if(index1 != std::string::npos) tokens[k] = tokens[k].substr(0, index1) + tokens[k].substr(index1+1);
index1 = tokens[k].find("[");
if(index1 != std::string::npos) tokens[k] = tokens[k].substr(0, index1);
index1 = tokens[k].find(".");
if(index1 != std::string::npos) {
tokens[k] = tokens[k].substr(0, index1) + "_" + tokens[k].substr(index1+1);
}
/* If this is a current source */
if (iFile.matA.sources.find(tokens[k]) != iFile.matA.sources.end()) {
label = "CURRENT " + tokens[k];
traceLabel.push_back(label);
traceData.push_back(iFile.matA.sources[tokens[k]]);
}
}
}
}
}
/*
Function that creates a plotting window with all available traces to plot
*/
int plot_all_traces(InputFile& iFile) {
#ifdef USING_FLTK
Fl_Window * win = new Fl_Window(1240, 768);
Fl_Scroll * scroll = new Fl_Scroll(0, 0, win->w(), win->h());
std::vector<Fl_Chart *> Charts;
std::string label;
int counter = 0;
for (auto i : iFile.matA.columnNames) {
label = substring_after(i, "C_");
Charts.push_back(new Fl_Chart(20, 20 + (counter * (scroll->h() / 3)), scroll->w() - 40, (scroll->h()/3 - 20)));
Charts[counter]->type(FL_LINE_CHART);
for (int j = 0; j < xVect[counter].size(); j++) {
Charts[counter]->add(xVect[counter][j]);
}
Charts[counter]->color(FL_WHITE);
Charts[counter]->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER|FL_ALIGN_TOP);
Charts[counter]->copy_label(label.c_str());
counter++;
}
win->resizable(scroll);
win->label(INPUT_FILE.c_str());
win->show();
return(Fl::run());
#elif USING_MATPLOTLIB
int counter = 0;
if (iFile.matA.columnNames.size() <= 3) {
plt::figure();
//plt::figure_size(800, 600);
for (auto i : iFile.matA.columnNames) {
plt::subplot(iFile.matA.columnNames.size(), 1, counter + 1);
plt::grid(true);
plt::plot(timeAxis, xVect[counter]);
plt::title(substring_after(i, "C_"));
if(substring_after(i, "C_")[0] == 'N') plt::ylabel("Voltage (V)");
else if (substring_after(i, "C_")[0] == 'I') plt::ylabel("Current (A)");
else if (substring_after(i, "C_")[0] == 'P') plt::ylabel("Phase (rads)");
counter++;
}
plt::xlabel("Time (s)");
plt::tight_layout();
plt::show();
}
else {
for (int j = 0; j < iFile.matA.columnNames.size(); j = j + 3) {
counter = j;
//plt::figure_size(800, 600);
plt::figure();
while((counter < iFile.matA.columnNames.size()) && (counter < j + 3)) {
plt::subplot(3, 1, (counter - j) + 1);
plt::grid(true);
plt::plot(timeAxis, xVect[counter]);
plt::title(substring_after(iFile.matA.columnNames[counter], "C_"));
if(substring_after(iFile.matA.columnNames[counter], "C_")[0] == 'N') plt::ylabel("Voltage (V)");
else if (substring_after(iFile.matA.columnNames[counter], "C_")[0] == 'I') plt::ylabel("Current (A)");
else if (substring_after(iFile.matA.columnNames[counter], "C_")[0] == 'P') plt::ylabel("Phase (rads)");
counter++;
}
plt::xlabel("Time (s)");
plt::tight_layout();
plt::show(false);
}
plt::show();
}
return 0;
#endif
return 0;
}
/*
Function that creates a plotting window only for the specified plots in the simulation
*/
int plot_traces(InputFile& iFile) {
#ifdef USING_FLTK
std::vector<std::string> traceLabel;
std::vector<std::vector<double>> traceData;
traces_to_plot(iFile.controlPart, traceLabel, traceData);
Fl_Window * win = new Fl_Window(1240, 768);
Fl_Scroll * scroll = new Fl_Scroll(0, 0, win->w(), win->h());
std::vector<Fl_Chart *> Charts;
if(traceLabel.size() > 0) {
for (int i = 0; i < traceLabel.size(); i++) {
Charts.push_back(new Fl_Chart(20, 20 + (i * (scroll->h() / 3)), scroll->w() - 40, (scroll->h() / 3 - 20)));
Charts[i]->type(FL_LINE_CHART);
for (int j = 0; j < traceData[i].size(); j++) {
Charts[i]->add(traceData[i][j]);
}
Charts[i]->color(FL_WHITE);
Charts[i]->align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER | FL_ALIGN_TOP);
Charts[i]->copy_label(traceLabel[i].c_str());
}
}
else if (traceLabel.size() == 0) {
std::cout << "W: Plotting requested but no plot/print/save commands found." << std::endl;
std::cout << "W: Plotting all the node voltages by default." << std::endl;
int j = 0;
std::string label;
for (int i = 0; i < iFile.matA.columnNames.size(); i++) {
label = substring_after(iFile.matA.columnNames[i], "C_");
if(label[0] == 'N') {
Charts.push_back(new Fl_Chart(20, 20 + (j * (scroll->h() / 3)), scroll->w() - 40, (scroll->h() / 3 - 20)));
Charts[j]->type(FL_LINE_CHART);
for (int k = 0; k < xVect[i].size(); k++) {
Charts[j]->add(xVect[i][k]);
}
Charts[j]->color(FL_WHITE);
Charts[j]->align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER | FL_ALIGN_TOP);
Charts[j]->copy_label(label.c_str());
j++;
}
}
}
win->resizable(win);
win->label(INPUT_FILE.c_str());
win->show();
return(Fl::run());
#elif USING_MATPLOTLIB
std::vector<std::string> traceLabel;
std::vector<std::vector<double>> traceData;
traces_to_plot(iFile, iFile.controlPart, traceLabel, traceData);
if(traceLabel.size() > 0) {
if (traceLabel.size() <= 3) {
//plt::figure_size(800, 600);
plt::figure();
for (int i = 0; i < traceLabel.size(); i++) {
plt::subplot(traceLabel.size(), 1, i + 1);
plt::grid(true);
plt::plot(timeAxis, traceData[i]);
plt::title(traceLabel[i].c_str());
if(traceLabel[i].find("VOLTAGE") != std::string::npos) plt::ylabel("Voltage (V)");
else if (traceLabel[i].find("CURRENT") != std::string::npos) plt::ylabel("Current (A)");
else if (traceLabel[i].find("PHASE") != std::string::npos) plt::ylabel("Phase (rads)");
}
plt::xlabel("Time (s)");
plt::tight_layout();
plt::show();
}
else {
for (int j = 0; j < traceLabel.size(); j = j + 3) {
int i = j;
//plt::figure_size(800, 600);
plt::figure();
while((i < traceLabel.size()) && (i < j + 3)) {
plt::subplot(3, 1, (i - j) + 1);
plt::grid(true);
plt::plot(timeAxis, traceData[i]);
plt::title(traceLabel[i].c_str());
if(traceLabel[i].find("VOLTAGE") != std::string::npos) { plt::ylabel("Voltage (V)"); }
else if (traceLabel[i].find("CURRENT") != std::string::npos) { plt::ylabel("Current (A)"); }
else if (traceLabel[i].find("PHASE") != std::string::npos) { plt::ylabel("Phase (rads)"); }
i++;
}
plt::xlabel("Time (s)");
plt::tight_layout();
plt::show(false);
}
plt::show();
}
}
else if(traceLabel.size() == 0) {
std::cout << "W: Plotting requested but no plot/print/save commands found." << std::endl;
std::cout << "W: Plotting all the node voltages by default." << std::endl;
// Find all the NV column indices
std::vector<int> nvIndices;
for(int i = 0; i < iFile.matA.columnNames.size(); i++) if(iFile.matA.columnNames[i][2] == 'N') nvIndices.push_back(i);
for (int j = 0; j < nvIndices.size(); j = j + 3) {
int i = j;
plt::figure_size(800, 600);
while((i < nvIndices.size()) && (i < j + 3)) {
plt::subplot(3, 1, (i - j) + 1);
plt::grid(true);
plt::plot(timeAxis, xVect[nvIndices[i]]);
plt::title(substring_after(iFile.matA.columnNames[nvIndices[i]], "C_").c_str());
plt::ylabel("Voltage (V)");
i++;
}
plt::xlabel("Time (s)");
plt::tight_layout();
plt::show(false);
}
plt::show();
}
return 0;
#endif
return 0;
}
| 41.07659 | 161 | 0.552366 | tsyw |
234fdceea4773f1e33084b230737b0ffba9d8adf | 4,431 | cpp | C++ | src/cui-1.0.4/MBA/MBA.cpp | MaiReo/crass | 11579527090faecab27f98b1e221172822928f57 | [
"BSD-3-Clause"
] | 1 | 2021-07-21T00:58:45.000Z | 2021-07-21T00:58:45.000Z | src/cui-1.0.4/MBA/MBA.cpp | MaiReo/crass | 11579527090faecab27f98b1e221172822928f57 | [
"BSD-3-Clause"
] | null | null | null | src/cui-1.0.4/MBA/MBA.cpp | MaiReo/crass | 11579527090faecab27f98b1e221172822928f57 | [
"BSD-3-Clause"
] | null | null | null | #include <windows.h>
#include <tchar.h>
#include <crass_types.h>
#include <acui.h>
#include <cui.h>
#include <package.h>
#include <resource.h>
#include <cui_error.h>
#include <stdio.h>
/* 接口数据结构: 表示cui插件的一般信息 */
struct acui_information MBA_cui_information = {
_T("飛翔システム"), /* copyright */
_T(""), /* system */
_T(".gdp"), /* package */
_T("1.0.1"), /* revision */
_T("痴漢公賊"), /* author */
_T("2009-3-18 20:35"), /* date */
NULL, /* notion */
ACUI_ATTRIBUTE_LEVEL_STABLE
};
/* 所有的封包特定的数据结构都要放在这个#pragma段里 */
#pragma pack (1)
typedef struct {
u32 index_entries;
} gdp_header_t;
typedef struct {
s8 name[260];
u32 length;
u32 offset;
} gdp_entry_t;
#pragma pack ()
/********************* gdp *********************/
static int MBA_gdp_extract_directory(struct package *pkg,
struct package_directory *pkg_dir);
/* 封包匹配回调函数 */
static int MBA_gdp_match(struct package *pkg)
{
if (pkg->pio->open(pkg, IO_READONLY))
return -CUI_EOPEN;
struct package_directory pkg_dir;
int ret = MBA_gdp_extract_directory(pkg, &pkg_dir);
if (!ret)
delete [] pkg_dir.directory;
return ret;
}
/* 封包索引目录提取函数 */
static int MBA_gdp_extract_directory(struct package *pkg,
struct package_directory *pkg_dir)
{
if (pkg->pio->readvec(pkg, &pkg_dir->index_entries, 4, 0, IO_SEEK_SET))
return -CUI_EREADVEC;
DWORD index_buffer_length = pkg_dir->index_entries * sizeof(gdp_entry_t);
gdp_entry_t *index_buffer = new gdp_entry_t[pkg_dir->index_entries];
if (!index_buffer)
return -CUI_EMEM;
if (pkg->pio->read(pkg, index_buffer, index_buffer_length)) {
delete [] index_buffer;
return -CUI_EREAD;
}
pkg_dir->directory = index_buffer;
pkg_dir->directory_length = index_buffer_length;
pkg_dir->index_entry_length = sizeof(gdp_entry_t);
return 0;
}
/* 封包索引项解析函数 */
static int MBA_gdp_parse_resource_info(struct package *pkg,
struct package_resource *pkg_res)
{
gdp_entry_t *gdp_entry;
gdp_entry = (gdp_entry_t *)pkg_res->actual_index_entry;
strcpy(pkg_res->name, gdp_entry->name);
pkg_res->name_length = -1; /* -1表示名称以NULL结尾 */
pkg_res->raw_data_length = gdp_entry->length;
pkg_res->actual_data_length = 0; /* 数据都是明文 */
pkg_res->offset = gdp_entry->offset;
return 0;
}
/* 封包资源提取函数 */
static int MBA_gdp_extract_resource(struct package *pkg,
struct package_resource *pkg_res)
{
BYTE *raw = new BYTE[pkg_res->raw_data_length];
if (!raw)
return -CUI_EMEM;
if (pkg->pio->readvec(pkg, raw, pkg_res->raw_data_length,
pkg_res->offset, IO_SEEK_SET)) {
delete [] raw;
return -CUI_EREADVEC;
}
pkg_res->raw_data = raw;
return 0;
}
/* 资源保存函数 */
static int MBA_gdp_save_resource(struct resource *res,
struct package_resource *pkg_res)
{
if (res->rio->create(res))
return -CUI_ECREATE;
if (pkg_res->actual_data && pkg_res->actual_data_length) {
if (res->rio->write(res, pkg_res->actual_data, pkg_res->actual_data_length)) {
res->rio->close(res);
return -CUI_EWRITE;
}
} else if (pkg_res->raw_data && pkg_res->raw_data_length) {
if (res->rio->write(res, pkg_res->raw_data, pkg_res->raw_data_length)) {
res->rio->close(res);
return -CUI_EWRITE;
}
}
res->rio->close(res);
return 0;
}
/* 封包资源释放函数 */
static void MBA_gdp_release_resource(struct package *pkg,
struct package_resource *pkg_res)
{
if (pkg_res->actual_data) {
delete [] pkg_res->actual_data;
pkg_res->actual_data = NULL;
}
if (pkg_res->raw_data) {
delete [] pkg_res->raw_data;
pkg_res->raw_data = NULL;
}
}
/* 封包卸载函数 */
static void MBA_gdp_release(struct package *pkg,
struct package_directory *pkg_dir)
{
if (pkg_dir->directory) {
delete [] pkg_dir->directory;
pkg_dir->directory = NULL;
}
pkg->pio->close(pkg);
}
/* 封包处理回调函数集合 */
static cui_ext_operation MBA_gdp_operation = {
MBA_gdp_match, /* match */
MBA_gdp_extract_directory, /* extract_directory */
MBA_gdp_parse_resource_info, /* parse_resource_info */
MBA_gdp_extract_resource, /* extract_resource */
MBA_gdp_save_resource, /* save_resource */
MBA_gdp_release_resource, /* release_resource */
MBA_gdp_release /* release */
};
/* 接口函数: 向cui_core注册支持的封包类型 */
int CALLBACK MBA_register_cui(struct cui_register_callback *callback)
{
if (callback->add_extension(callback->cui, _T(".gdp"), NULL,
NULL, &MBA_gdp_operation, CUI_EXT_FLAG_PKG | CUI_EXT_FLAG_DIR
| CUI_EXT_FLAG_WEAK_MAGIC))
return -1;
return 0;
}
}
| 23.822581 | 80 | 0.693297 | MaiReo |
2351dd801afdf4dd24e9dec216d419dd3d8c8b83 | 11,486 | cpp | C++ | src/stacker_system.cpp | scullion/stacker | ba9241c85962f210ea37784ebee3072dac63df46 | [
"MIT"
] | null | null | null | src/stacker_system.cpp | scullion/stacker | ba9241c85962f210ea37784ebee3072dac63df46 | [
"MIT"
] | null | null | null | src/stacker_system.cpp | scullion/stacker | ba9241c85962f210ea37784ebee3072dac63df46 | [
"MIT"
] | null | null | null | #include "stacker_system.h"
#include "stacker_shared.h"
#include "stacker_attribute_buffer.h"
#include "stacker_util.h"
#include "stacker_platform.h"
#include "stacker_document.h"
#include "stacker_layer.h"
namespace stkr {
static void make_font_descriptor(LogicalFont *descriptor, const char *face,
unsigned size, unsigned flags)
{
if (face != NULL) {
strncpy(descriptor->face, face, sizeof(descriptor->face));
descriptor->face[sizeof(descriptor->face) - 1] = '\0';
} else {
descriptor->face[0] = '\0';
}
descriptor->font_size = size;
descriptor->flags = (uint16_t)flags;
}
static void initialize_font_cache(System *system)
{
system->default_font_id = INVALID_FONT_ID;
system->font_cache_entries = 0;
make_font_descriptor(&system->default_font_descriptor,
DEFAULT_FONT_FACE, DEFAULT_FONT_SIZE, DEFAULT_FONT_FLAGS);
system->default_font_id = get_font_id(system,
&system->default_font_descriptor);
ensure(system->default_font_id != INVALID_FONT_ID);
system->debug_label_font_id = INVALID_FONT_ID;
}
/* Returns a key uniquely identifying a font specification. */
static uint32_t make_font_key(const LogicalFont *logfont)
{
uint32_t seed = logfont->font_size | (logfont->flags << 16);
return murmur3_32(logfont->face, strlen(logfont->face), seed);
}
/* Precalculates numbers needed for typesetting from the system font metrics. */
static void calculate_derived_font_metrics(FontMetrics *metrics)
{
/* w = (1/3)em, y = (1/6)em, z = (1/9)em */
static const int ONE_THIRD = (1 << TEXT_METRIC_PRECISION) / 3;
static const int ONE_SIXTH = (1 << TEXT_METRIC_PRECISION) / 6;
static const int ONE_NINTH = (1 << TEXT_METRIC_PRECISION) / 9;
metrics->space_width = fixed_multiply(metrics->em_width, ONE_THIRD, TEXT_METRIC_PRECISION);
metrics->space_stretch = fixed_multiply(metrics->em_width, ONE_SIXTH, TEXT_METRIC_PRECISION);
metrics->space_shrink = fixed_multiply(metrics->em_width, ONE_NINTH, TEXT_METRIC_PRECISION);
metrics->paragraph_indent_width = metrics->em_width;
}
/* Returns the ID of a font from the font cache, creating it if necessary. */
int16_t get_font_id(System *system, const LogicalFont *logfont)
{
uint32_t key = make_font_key(logfont);
for (unsigned i = 0; i < system->font_cache_entries; ++i)
if (system->font_cache[i].key == key)
return (int16_t)i;
if (system->font_cache_entries == MAX_CACHED_FONTS)
return 0;
void *handle = platform_match_font(system->back_end, logfont);
if (handle == NULL)
return system->default_font_id;
CachedFont *cf = system->font_cache + system->font_cache_entries;
cf->key = key;
cf->handle = handle;
cf->descriptor = *logfont;
platform_font_metrics(system->back_end, handle, &cf->metrics);
calculate_derived_font_metrics(&cf->metrics);
return int16_t(system->font_cache_entries++);
}
/* Returns the system handle for a cached font. */
void *get_font_handle(System *system, int16_t font_id)
{
assertb(unsigned(font_id) < system->font_cache_entries);
return system->font_cache[font_id].handle;
}
/* Returns the logical font used to create a font ID. */
const LogicalFont *get_font_descriptor(System *system, int16_t font_id)
{
if (font_id != INVALID_FONT_ID) {
assertb(unsigned(font_id) < system->font_cache_entries);
return &system->font_cache[font_id].descriptor;
}
return &system->default_font_descriptor;
}
const FontMetrics *get_font_metrics(System *system, int16_t font_id)
{
assertb(unsigned(font_id) < system->font_cache_entries);
return &system->font_cache[font_id].metrics;
}
unsigned measure_text(System *system, int16_t font_id, const void *text,
unsigned length, unsigned *advances)
{
void *font_handle = get_font_handle(system, font_id);
return platform_measure_text(system->back_end, font_handle,
text, length, advances);
}
/* A convenience function to determine the size of a string's bounding
* rectangle. Optionally returns the temporary heap-allocated advances array
* used, for which the caller takes responsibility. */
unsigned measure_text_rectangle(System *system, int16_t font_id,
const void *text, unsigned length, unsigned *out_width,
unsigned *out_height, unsigned **out_advances)
{
unsigned *advances = new unsigned[length];
unsigned num_characters = measure_text(system, font_id, text,
length, advances);
if (out_width != NULL) {
*out_width = 0;
for (unsigned i = 0; i < num_characters; ++i)
*out_width += advances[i];
*out_width = round_fixed_to_int(*out_width, TEXT_METRIC_PRECISION);
}
if (out_height != NULL) {
const FontMetrics *metrics = get_font_metrics(system, font_id);
*out_height = round_fixed_to_int(metrics->height, TEXT_METRIC_PRECISION);
}
if (out_advances != NULL) {
*out_advances = advances;
} else {
delete [] out_advances;
}
return num_characters;
}
/* Precomputes hashed rule names for tag tokens and pseudo classes. */
static void make_built_in_rule_names(System *system)
{
system->rule_name_all = murmur3_64_cstr("*");
system->rule_name_active = murmur3_64_cstr(":active");
system->rule_name_highlighted = murmur3_64_cstr(":highlighted");
for (unsigned i = 0; i < NUM_KEYWORDS; ++i) {
system->token_rule_names[i] = murmur3_64_cstr(
TOKEN_STRINGS[TOKEN_KEYWORD_FIRST + i]);
}
}
static unsigned add_font_assignments(AttributeAssignment *attributes,
unsigned count, const char *face, unsigned size, unsigned flags)
{
attributes[count++] = make_assignment(TOKEN_FONT, face);
attributes[count++] = make_assignment(TOKEN_FONT_SIZE, size);
attributes[count++] = make_assignment(TOKEN_BOLD, (flags & STYLE_BOLD) != 0, VSEM_BOOLEAN);
attributes[count++] = make_assignment(TOKEN_ITALIC, (flags & TOKEN_ITALIC) != 0, VSEM_BOOLEAN);
attributes[count++] = make_assignment(TOKEN_UNDERLINE, (flags & STYLE_UNDERLINE) != 0, VSEM_BOOLEAN);
return count;
}
static void add_default_rules(System *system)
{
static const unsigned MAX_ROOT_ATTRIBUTES = 32;
AttributeAssignment attributes[MAX_ROOT_ATTRIBUTES];
unsigned count = 0;
attributes[count++] = make_assignment(TOKEN_COLOR, DEFAULT_TEXT_COLOR, VSEM_COLOR);
attributes[count++] = make_assignment(TOKEN_JUSTIFY, TOKEN_LEFT, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_WRAP, TOKEN_WORD_WRAP, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_LEADING, TOKEN_AUTO, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_WHITE_SPACE, TOKEN_NORMAL, VSEM_TOKEN);
count = add_font_assignments(attributes, count, DEFAULT_FONT_FACE, DEFAULT_FONT_SIZE, DEFAULT_FONT_FLAGS);
add_rule(NULL, system, NULL, "document", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
count = 0;
attributes[count++] = make_assignment(TOKEN_WIDTH, TOKEN_GROW, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_JUSTIFY, TOKEN_FLUSH, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_INDENT, TOKEN_AUTO, VSEM_TOKEN);
add_rule(NULL, system, NULL, "p", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
count = 0;
attributes[count++] = make_assignment(TOKEN_CURSOR, TOKEN_CURSOR_HAND, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_UNDERLINE, true, VSEM_BOOLEAN);
attributes[count++] = make_assignment(TOKEN_COLOR, DEFAULT_LINK_COLOR, VSEM_COLOR);
add_rule(NULL, system, NULL, "a", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
count = 0;
attributes[count++] = make_assignment(TOKEN_COLOR, DEFAULT_HIGHLIGHTED_LINK_COLOR, VSEM_COLOR);
add_rule(NULL, system, NULL, "a:highlighted", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
count = 0;
attributes[count++] = make_assignment(TOKEN_COLOR, DEFAULT_ACTIVE_LINK_COLOR, VSEM_COLOR);
add_rule(NULL, system, NULL, "a:active", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
count = 0;
attributes[count++] = make_assignment(TOKEN_WIDTH, TOKEN_GROW, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_FONT_SIZE, 2.5f, VSEM_NONE, AOP_MULTIPLY);
attributes[count++] = make_assignment(TOKEN_BOLD, true, VSEM_BOOLEAN);
add_rule(NULL, system, NULL, "h1", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
count = 0;
attributes[count++] = make_assignment(TOKEN_WIDTH, TOKEN_GROW, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_FONT_SIZE, 2.0f, VSEM_NONE, AOP_MULTIPLY);
attributes[count++] = make_assignment(TOKEN_BOLD, true, VSEM_BOOLEAN);
add_rule(NULL, system, NULL, "h2", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
count = 0;
attributes[count++] = make_assignment(TOKEN_WIDTH, TOKEN_GROW, VSEM_TOKEN);
attributes[count++] = make_assignment(TOKEN_FONT_SIZE, 1.5f, VSEM_NONE, AOP_MULTIPLY);
attributes[count++] = make_assignment(TOKEN_BOLD, true, VSEM_BOOLEAN);
add_rule(NULL, system, NULL, "h3", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
count = 0;
attributes[count++] = make_assignment(TOKEN_WHITE_SPACE, TOKEN_PRESERVE, VSEM_TOKEN);
count = add_font_assignments(attributes, count, DEFAULT_FIXED_FONT_FACE, DEFAULT_FIXED_FONT_SIZE, DEFAULT_FIXED_FONT_FLAGS);
add_rule(NULL, system, NULL, "code", -1, attributes, count, RFLAG_ENABLED | RFLAG_GLOBAL, RULE_PRIORITY_LOWEST);
}
static void initialize_url_notifications(System *system, UrlCache *url_cache)
{
if (url_cache != NULL) {
system->image_layer_notify_id = url_cache->add_notify_sink(
(urlcache::NotifyCallback)&image_layer_notify_callback, system);
system->document_notify_id = url_cache->add_notify_sink(
(urlcache::NotifyCallback)&document_fetch_notify_callback, system);
} else {
system->image_layer_notify_id = urlcache::INVALID_NOTIFY_SINK_ID;
}
}
static void deinitialize_url_notifications(System *system, UrlCache *url_cache)
{
if (url_cache != NULL) {
url_cache->remove_notify_sink(system->image_layer_notify_id);
url_cache->remove_notify_sink(system->document_notify_id);
}
}
int16_t get_debug_label_font_id(System *system)
{
if (system->debug_label_font_id == INVALID_FONT_ID) {
LogicalFont descriptor;
make_font_descriptor(&descriptor, DEBUG_LABEL_FONT_FACE,
DEBUG_LABEL_FONT_SIZE, DEBUG_LABEL_FONT_FLAGS);
system->debug_label_font_id = get_font_id(system, &descriptor);
}
return system->debug_label_font_id;
}
System *create_system(unsigned flags, BackEnd *back_end, UrlCache *url_cache,
TextEncoding encoding, TextEncoding message_encoding)
{
System *system = new System();
system->flags = flags;
system->encoding = encoding;
system->message_encoding = message_encoding;
system->back_end = back_end;
system->url_cache = url_cache;
system->rule_table_revision = 0;
system->rule_revision_counter = 0;
system->total_boxes = 0;
system->total_nodes = 0;
initialize_font_cache(system);
make_built_in_rule_names(system);
initialize_url_notifications(system, url_cache);
add_default_rules(system);
return system;
}
void destroy_system(System *system)
{
assertb(system->total_nodes == 0);
assertb(system->total_boxes == 0);
clear_rule_table(&system->global_rules);
for (unsigned i = 0; i < system->font_cache_entries; ++i)
platform_release_font(system->back_end, system->font_cache[i].handle);
deinitialize_url_notifications(system, system->url_cache);
delete system;
}
BackEnd *get_back_end(System *system)
{
return system->back_end;
}
unsigned get_total_nodes(const System *system)
{
return system->total_nodes;
}
unsigned get_total_boxes(const System *system)
{
return system->total_boxes;
}
} // namespace stkr
| 38.673401 | 125 | 0.765715 | scullion |
2355492847a974f82b3e39e3ad68c1326d4c7bdf | 407 | cpp | C++ | src/format.cpp | nalinraut/System-Monitor | cd51a040455bad43d835606fb3013b35a40f4fc4 | [
"MIT"
] | null | null | null | src/format.cpp | nalinraut/System-Monitor | cd51a040455bad43d835606fb3013b35a40f4fc4 | [
"MIT"
] | null | null | null | src/format.cpp | nalinraut/System-Monitor | cd51a040455bad43d835606fb3013b35a40f4fc4 | [
"MIT"
] | null | null | null | #include <string>
#include "format.h"
using std::string;
string Format::ElapsedTime(long int seconds) {
long int HH{seconds/3600};
long int H_re{seconds%3600};
long int MM{H_re/60};
long int SS{H_re%60};
string HH_str{std::to_string(HH)};
string MM_str{std::to_string(MM)};
string SS_str{std::to_string(SS)};
string time{HH_str+':'+MM_str+':'+SS_str};
return time;
} | 23.941176 | 47 | 0.653563 | nalinraut |
2355c6b669e088ed141f637d36ec5804b5e750df | 1,510 | hh | C++ | Archive/Stroika_FINAL_for_STERL_1992/Library/User/Headers/EnableView.hh | SophistSolutions/Stroika | f4e5d84767903a054fba0a6b9c7c4bd1aaefd105 | [
"MIT"
] | 28 | 2015-09-22T21:43:32.000Z | 2022-02-28T01:35:01.000Z | Archive/Stroika_FINAL_for_STERL_1992/Library/User/Headers/EnableView.hh | SophistSolutions/Stroika | f4e5d84767903a054fba0a6b9c7c4bd1aaefd105 | [
"MIT"
] | 98 | 2015-01-22T03:21:27.000Z | 2022-03-02T01:47:00.000Z | Archive/Stroika_FINAL_for_STERL_1992/Library/User/Headers/EnableView.hh | SophistSolutions/Stroika | f4e5d84767903a054fba0a6b9c7c4bd1aaefd105 | [
"MIT"
] | 4 | 2019-02-21T16:45:25.000Z | 2022-02-18T13:40:04.000Z | /* Copyright(c) Sophist Solutions Inc. 1990-1992. All rights reserved */
#ifndef __EnableView__
#define __EnableView__
/*
* $Header: /fuji/lewis/RCS/EnableView.hh,v 1.1 1992/06/20 17:33:49 lewis Exp $
*
* Description:
*
*
* TODO:
*
*
* Notes:
*
* Changes:
* $Log: EnableView.hh,v $
* Revision 1.1 1992/06/20 17:33:49 lewis
* Initial revision
*
* Revision 1.2 1992/03/26 09:24:26 lewis
* Got rid of oldLive first argument to EffectiveLiveChanged () method.
*
* Revision 1.1 1992/03/13 16:00:55 lewis
* Initial revision
*
*
*
*/
#include "EnableItem.hh"
#include "View.hh"
#if qCanFreelyUseVirtualBaseClasses
class EnableView : public virtual EnableItem, public virtual View {
#else
class EnableView : public EnableItem, public View {
#endif
protected:
EnableView (Boolean enabled = kEnabled);
public:
override Boolean GetLive () const;
protected:
override void EffectiveLiveChanged (Boolean newLive, UpdateMode updateMode);
override Boolean GetEnabled_ () const;
override void SetEnabled_ (Boolean enabled, UpdateMode updateMode);
private:
Boolean fEnabled;
};
/*
********************************************************************************
************************************ InLines ***********************************
********************************************************************************
*/
// For gnuemacs:
// Local Variables: ***
// mode:C++ ***
// tab-width:4 ***
// End: ***
#endif /*__EnableView__*/
| 19.358974 | 81 | 0.570861 | SophistSolutions |
235d7868e431534664a820838212d93d28440767 | 7,370 | cpp | C++ | PhysicsEngine/ModulePhysics.cpp | bielrabasa/PhysicsEngine | ef3bc64c419a6da4ae234873e3d9da8c196197ec | [
"MIT"
] | 1 | 2021-12-27T15:12:27.000Z | 2021-12-27T15:12:27.000Z | PhysicsEngine/ModulePhysics.cpp | bielrabasa/PhysicsEngine | ef3bc64c419a6da4ae234873e3d9da8c196197ec | [
"MIT"
] | null | null | null | PhysicsEngine/ModulePhysics.cpp | bielrabasa/PhysicsEngine | ef3bc64c419a6da4ae234873e3d9da8c196197ec | [
"MIT"
] | null | null | null | #include "Globals.h"
#include "Application.h"
#include "ModulePhysics.h"
#include "math.h"
ModulePhysics::ModulePhysics(Application* app, bool start_enabled) : Module(app, start_enabled)
{
debug = true;
}
ModulePhysics::~ModulePhysics()
{
}
bool ModulePhysics::Start()
{
LOG("Creating Physics 2D environment");
cannon_ball_texture = App->textures->Load("Assets/cannon_ball.png");
return true;
}
update_status ModulePhysics::PreUpdate()
{
return UPDATE_CONTINUE;
}
update_status ModulePhysics::Update()
{
return UPDATE_CONTINUE;
}
update_status ModulePhysics::PostUpdate()
{
p2List_item<Ball*>* current_ball = balls.getFirst();
while (current_ball != NULL) {
if (current_ball->data->physics_enabled) {
ResetForces(current_ball->data);
ComputeForces(current_ball->data);
NewtonsLaw(current_ball->data);
Integrator(current_ball->data);
CollisionSolver(current_ball->data);
}
current_ball = current_ball->next;
}
//DeleteBalls();
DrawBalls();
DrawColliders();
//Debug
if(App->input->GetKey(SDL_SCANCODE_F1) == KEY_DOWN)
debug = !debug;
if(!debug)
return UPDATE_CONTINUE;
//Debug options (mode debug activated)
return UPDATE_CONTINUE;
}
bool ModulePhysics::CleanUp()
{
LOG("Destroying physics world");
return true;
}
void ModulePhysics::ResetForces(Ball* ball) {
ball->fx = ball->fy = 0.0;
ball->ax = ball->ay = 0.0;
}
void ModulePhysics::ComputeForces(Ball* ball) {
//Apply Gravity
ball->fgx = ball->mass * GRAVITY_X;
ball->fgy = ball->mass * GRAVITY_Y;
ball->fx += ball->fgx;
ball->fy += ball->fgy;
//Apply Aerodinamic lift / drag
}
void ModulePhysics::NewtonsLaw(Ball* ball) {
//ForceSum = m * a
ball->ax = ball->fx / ball->mass;
ball->ay = ball->fy / ball->mass;
}
void ModulePhysics::Integrator(Ball* ball) {
if (integrator_type == integrators::VERLET) {
ball->x += ball->vx * dt + 0.5 * ball->ax * dt * dt;
ball->y += ball->vy * dt + 0.5 * ball->ay * dt * dt;
ball->vx += ball->ax * dt;
ball->vy += ball->ay * dt;
}
if (integrator_type == integrators::EULER_BACK) {
}
if (integrator_type == integrators::EULER_FORW) {
}
}
void ModulePhysics::CollisionSolver(Ball* ball) {
p2List_item<Collider*>* current_collider = colliders.getFirst();
while (current_collider != NULL) {
if (current_collider->data->rectangle) {
if ((ball->x + ball->radius > current_collider->data->rect.x) &&
(ball->x - ball->radius < current_collider->data->rect.x + current_collider->data->rect.w) &&
(ball->y + ball->radius > current_collider->data->rect.y) &&
(ball->y - ball->radius < current_collider->data->rect.y + current_collider->data->rect.h)) {
if ((ball->x + ball->radius > current_collider->data->rect.x) &&
(ball->x - ball->radius < current_collider->data->rect.x + current_collider->data->rect.w) &&
(ball->y + ball->radius - ball->vy > current_collider->data->rect.y) &&
(ball->y - ball->radius - ball->vy < current_collider->data->rect.y + current_collider->data->rect.h)) { //Horizontal Colision
if (ball->vx > 0) { //Right colision
ball->x -= 2 * (ball->x - (current_collider->data->rect.x - ball->radius));
}
else { //Left colision
ball->x += 2 * (-ball->x + (current_collider->data->rect.x + current_collider->data->rect.w + ball->radius));
}
ball->vy = ball->vy * ball->cr;
ball->vx = -ball->vx * ball->cr;
}
else if ((ball->x + ball->radius - ball->vx > current_collider->data->rect.x) &&
(ball->x - ball->radius - ball->vx < current_collider->data->rect.x + current_collider->data->rect.w) &&
(ball->y + ball->radius > current_collider->data->rect.y) &&
(ball->y - ball->radius < current_collider->data->rect.y + current_collider->data->rect.h)) { //Vertical Colision
if (ball->vy > 0) { //Floor colision
ball->y -= 2*(ball->y - (current_collider->data->rect.y - ball->radius));
}
else { //Ceiling colision
ball->y = current_collider->data->rect.y + (-ball->y + (current_collider->data->rect.y + current_collider->data->rect.h));
}
ball->vy = -ball->vy * ball->cr;
ball->vx = ball->vx * ball->cr;
}
else {//diagonal colision FUYM
if (ball->vy > 0) { //floor colision
ball->y = current_collider->data->rect.y - ball->radius;
}
else { //ceiling colision
ball->y = current_collider->data->rect.y + current_collider->data->rect.h + ball->radius;
}
ball->vy = -ball->vy * ball->cr;
ball->vx = -ball->vx * ball->cr;
}
}
}
else { //CIRCLE
double vecX = ball->x - current_collider->data->rect.x;
double vecY = ball->y - current_collider->data->rect.y;
double distance = sqrt(vecX * vecX + vecY * vecY);
if (current_collider->data->r + ball->radius > distance) { //Ball colliding ARREGLAR
//unitary vector
vecX = vecX / distance;
vecY = vecY / distance;
//tp out
ball->x = current_collider->data->rect.x + vecX * (current_collider->data->r + ball->radius);
ball->y = current_collider->data->rect.y + vecY * (current_collider->data->r + ball->radius);
//solver
double vector[2] = { ball->x - current_collider->data->rect.x,
ball->y - current_collider->data->rect.y };
double dotProduct = (ball->vx * vector[0]) + (ball->vy * vector[1]);
double vectorModule = sqrt((vector[0] * vector[0]) + (vector[1] * vector[1]));
ball->vx += -2 * (dotProduct / (vectorModule * vectorModule)) * vector[0] * ball->cr;
ball->vy += -2 * (dotProduct / (vectorModule * vectorModule)) * vector[1] * ball->cr;
}
}
current_collider = current_collider->next;
}
}
void ModulePhysics::DeleteBalls() {
p2List_item<Ball*>* current_ball = balls.getFirst();
while (current_ball != NULL) {
if (current_ball->data->y > 700) {
Ball* b = current_ball->data;
current_ball = current_ball->next;
balls.del(balls.findNode(b));
delete b;
}
else {
current_ball = current_ball->next;
}
}
}
void ModulePhysics::DeleteAllBalls() {
p2List_item<Ball*>* current_ball = balls.getFirst();
while (current_ball != NULL) {
Ball* b = current_ball->data;
current_ball = current_ball->next;
balls.del(balls.findNode(b));
delete b;
}
}
void ModulePhysics::DisableEnablePhysics() {
p2List_item<Ball*>* current_ball = balls.getFirst();
while (current_ball != NULL) {
current_ball->data->physics_enabled = !current_ball->data->physics_enabled;
current_ball = current_ball->next;
}
}
void ModulePhysics::DrawBalls() {
p2List_item<Ball*>* current_ball = balls.getFirst();
while (current_ball != NULL) {
//App->renderer->Blit(cannon_ball_texture, current_ball->data->x - 16, current_ball->data->y - 16, NULL, 2);
App->renderer->DrawCircle(current_ball->data->x, current_ball->data->y, current_ball->data->radius, 250, 250, 250);
current_ball = current_ball->next;
}
}
void ModulePhysics::DrawColliders() {
p2List_item<Collider*>* current_collider = colliders.getFirst();
while (current_collider != NULL) {
if (current_collider->data->rectangle) { //RECTANGLE
App->renderer->DrawQuad(current_collider->data->rect, 100, 100, 100, 255, false);
}
else { //CIRCLE
App->renderer->DrawCircle(current_collider->data->rect.x,
current_collider->data->rect.y, current_collider->data->r, 100, 100, 100);
}
current_collider = current_collider->next;
}
}
| 30.580913 | 131 | 0.650204 | bielrabasa |
236052da1cee9c60bc77d7d85ec7c9de2059bfe4 | 880 | hpp | C++ | src/Structures/SymbolBBox.hpp | Werni2A/O2CP | a20c0102e1c5aca35874cc6bc89f083c66dfeb0e | [
"MIT"
] | 5 | 2021-10-01T06:48:21.000Z | 2021-12-23T11:14:41.000Z | src/Structures/SymbolBBox.hpp | Werni2A/O2CP | a20c0102e1c5aca35874cc6bc89f083c66dfeb0e | [
"MIT"
] | 7 | 2021-09-26T19:53:53.000Z | 2022-01-06T13:04:03.000Z | src/Structures/SymbolBBox.hpp | Werni2A/O2CP | a20c0102e1c5aca35874cc6bc89f083c66dfeb0e | [
"MIT"
] | 1 | 2022-01-05T19:24:58.000Z | 2022-01-05T19:24:58.000Z | #ifndef SYMBOLBBOX_H
#define SYMBOLBBOX_H
#include <cstdint>
#include <iostream>
#include <ostream>
#include <string>
#include "../General.hpp"
struct SymbolBBox
{
int32_t x1;
int32_t y1;
int32_t x2;
int32_t y2;
};
[[maybe_unused]]
static std::string to_string(const SymbolBBox& aObj)
{
std::string str;
str += std::string(nameof::nameof_type<decltype(aObj)>()) + ":" + newLine();
str += indent(1) + "x1 = " + std::to_string(aObj.x1) + newLine();
str += indent(1) + "y1 = " + std::to_string(aObj.y1) + newLine();
str += indent(1) + "x2 = " + std::to_string(aObj.x2) + newLine();
str += indent(1) + "y2 = " + std::to_string(aObj.y2) + newLine();
return str;
}
[[maybe_unused]]
static std::ostream& operator<<(std::ostream& aOs, const SymbolBBox& aVal)
{
aOs << to_string(aVal);
return aOs;
}
#endif // SYMBOLBBOX_H | 18.723404 | 80 | 0.617045 | Werni2A |
23625249e60afe425625fa27e472e0f1fd16cf6e | 6,196 | cpp | C++ | ui-qt/Pretreatment/GrayHistogram/Roi/LabelGrayHistogram.cpp | qianyongjun123/FPGA-Industrial-Smart-Camera | 54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32 | [
"MIT"
] | 1 | 2017-12-28T08:08:02.000Z | 2017-12-28T08:08:02.000Z | ui-qt/Pretreatment/GrayHistogram/Roi/LabelGrayHistogram.cpp | qianyongjun123/FPGA-Industrial-Smart-Camera | 54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32 | [
"MIT"
] | null | null | null | ui-qt/Pretreatment/GrayHistogram/Roi/LabelGrayHistogram.cpp | qianyongjun123/FPGA-Industrial-Smart-Camera | 54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32 | [
"MIT"
] | 3 | 2017-12-28T08:08:05.000Z | 2021-11-12T07:59:13.000Z |
#include "LabelGrayHistogram.h"
#include <qdebug.h>
#include <QPen>
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
#define LINEWIDTH 30
LabelGrayHistogram::LabelGrayHistogram(QWidget *parent) : QLabel(parent)
{
m_max =100;
m_mode = -1;
for(int i=0; i<2560;i++)
{
m_grade[i] = 0;
}
}
void LabelGrayHistogram::mousePressEvent(QMouseEvent *e)
{
QLabel::mousePressEvent(e);
}
void LabelGrayHistogram::mouseMoveEvent(QMouseEvent *e)
{
QLabel::mouseMoveEvent(e);
}
void LabelGrayHistogram::mouseReleaseEvent(QMouseEvent *e)
{
QLabel::mouseReleaseEvent(e);
}
void LabelGrayHistogram::PaintGray(QPainter *painter)
{
painter->drawLine(100,400,610,400);//x轴
painter->drawLine(600,390,610,400);
painter->drawLine(600,410,610,400);
painter->drawLine(100,400,100,100);//y轴
painter->drawLine(90,110,100,100);
painter->drawLine(110,110,100,100);
painter->drawText(90,420,"0");
painter->drawText(610,420,"255");
int i = 0;
for(i= 1; i< 15;i++)
{
painter->drawLine(100+i*34,400,100+i*34,395);
painter->drawText(100+i*34-5,420,QString::number(15+16*(i-1)));
}
int iGrade = this->m_max/10;
//painter->drawText(60,100+5,QString::number(m_max));
//painter->drawText(100,100,QString::number(m_max));
for(i = 1;i<10;i++)
{
painter->drawLine(100,100+i*30,105,100+i*30);
//painter->drawText(60,100+i*30+5,QString::number(m_max-iGrade*i));
/*QString strTemp = QString::number(10-i);
strTemp +="/10";
painter->drawText(60,100+i*30+5,strTemp);*/
}
float fScale = 0.0;
fScale = 300.0/m_max*1.0;
int iMax = m_grade[0];
int iIndex = 0;
for(i = 0; i<255;i++)
{
if(m_grade[i] > iMax)
{
iMax = m_grade[i];
iIndex = i;
}
painter->drawLine(100+i*2,400-m_grade[i]*fScale,100+i*2+1,400-m_grade[i+1]*fScale);
}
painter->drawText(100+iIndex*2,400-m_grade[iIndex]*fScale,QString::number(m_max));
}
void LabelGrayHistogram::PaintByColoum(QPainter *painter)
{
painter->drawLine(0,400,640,400);//x轴
painter->drawLine(630,390,640,400);
painter->drawLine(630,410,640,400);
painter->drawLine(0,400,0,100);//y轴
painter->drawLine(-10,110,0,100);
painter->drawLine(10,110,0,100);
painter->drawText(3,420,"0");
painter->drawText(610,420,"640");
int i = 0;
for(i= 1; i< 15;i++)
{
painter->drawLine(i*42,400,i*42,395);
painter->drawText(i*42-8,420,QString::number(42+42*(i-1)));
}
int iGrade = this->m_max/10;
//painter->drawText(0,100+5,QString::number(m_max));
//painter->drawText(0,100,QString::number(m_max));
for(i = 1;i<10;i++)
{
painter->drawLine(0,100+i*30,5,100+i*30);
//painter->drawText(5,100+i*30+10,QString::number(m_max-iGrade*i));
/*QString strTemp = QString::number(10-i);
strTemp +="/10";
painter->drawText(5,100+i*30+5,strTemp);*/
}
float fScale = 0.0;
fScale = 300.0/m_max*1.0;
int iMax = m_grade[0];
int iIndex = 0;
for(i = 0; i<639;i++)
{
if(m_times == 4)
painter->drawLine(i,400-m_grade[i*4]*fScale,i+1,400-m_grade[i*4+4]*fScale);
else if(m_times == 2)
painter->drawLine(i,400-m_grade[i*2]*fScale,i+1,400-m_grade[i*2+2]*fScale);
else if(m_times == 1)
painter->drawLine(i,400-m_grade[i]*fScale,i+1,400-m_grade[i+1]*fScale);
if(m_grade[i*m_times] > iMax)
{
iMax = m_grade[i*m_times];
iIndex = i;
}
}
painter->drawText(iIndex,400-m_grade[iIndex*m_times]*fScale,QString::number(m_max));
}
void LabelGrayHistogram::PaintByRow(QPainter *painter)
{
painter->drawLine(100,400,580,400);//x轴
painter->drawLine(570,390,580,400);
painter->drawLine(570,410,580,400);
painter->drawLine(100,400,100,100);//y轴
painter->drawLine(90,110,100,100);
painter->drawLine(110,110,100,100);
painter->drawText(90,420,"0");
painter->drawText(580,420,"480");
int i = 0;
for(i= 1; i< 15;i++)
{
painter->drawLine(100+i*32,400,100+i*32,395);
painter->drawText(100+i*32-5,420,QString::number(32+32*(i-1)));
}
int iGrade = this->m_max/10;
//painter->drawText(60,100+5,QString::number(m_max));
//painter->drawText(100,100,QString::number(m_max));
for(i = 1;i<10;i++)
{
painter->drawLine(100,100+i*30,105,100+i*30);
//painter->drawText(60,100+i*30+5,QString::number(m_max-iGrade*i));
/*QString strTemp = QString::number(10-i);
strTemp += "/10";
painter->drawText(60,100+i*30+5,strTemp);*/
}
float fScale = 0.0;
fScale = 300.0/m_max*1.0;
int iMax = m_grade[0];
int iIndex = 0;
for(i = 0; i<479;i++)
{
if(m_times == 1)
painter->drawLine(100+i,400-m_grade[i]*fScale,100+i+1,400-m_grade[i+1]*fScale);
else if(m_times == 2)
painter->drawLine(100+i,400-m_grade[i*2]*fScale,100+i+1,400-m_grade[i*2+2]*fScale);
else if(m_times == 4)
painter->drawLine(100+i,400-m_grade[i*4]*fScale,100+i+1,400-m_grade[i*4+4]*fScale);
if(m_grade[i*m_times] > iMax)
{
iMax = m_grade[i*m_times];
iIndex = i;
}
}
painter->drawText(100+iIndex,400-m_grade[iIndex*m_times]*fScale,QString::number(m_max));
}
void LabelGrayHistogram::paintEvent(QPaintEvent *e)
{
QLabel::paintEvent(e);
QPainter painter(this);
QPen pen;
pen.setColor(Qt::red);
pen.setWidth(1);
painter.setPen(pen);
if(m_mode == 0)
{
PaintGray(&painter);
}else if(m_mode == 1) //列
{
PaintByColoum(&painter);
}else if(m_mode == 2) //行
{
PaintByRow(&painter);
}
}
void LabelGrayHistogram::SetGrade(unsigned int *gradeArr, int size, int mode,int times)
{
this->m_size = size;
this->m_mode = mode;
m_times = times;
m_max = gradeArr[0];
for(int i = 0;i<size;i++)
{
this->m_grade[i] = gradeArr[i];
if(gradeArr[i] > m_max)
{
m_max = gradeArr[i];
}
}
update();
}
| 27.784753 | 95 | 0.589413 | qianyongjun123 |
236ae6d7f99c44649c72258be304280ce3c1dadb | 2,025 | cpp | C++ | SAEEngineCore/submodules/object/tests/build_test/test.cpp | SAEEngine/SAEEngineCore | bede6c973caf7c4526ac5539ec2c9917139f2067 | [
"MIT"
] | 2 | 2020-10-31T09:59:36.000Z | 2020-11-01T04:22:56.000Z | SAEEngineCore/submodules/object/tests/build_test/test.cpp | SAEEngine/SAEEngineCore | bede6c973caf7c4526ac5539ec2c9917139f2067 | [
"MIT"
] | null | null | null | SAEEngineCore/submodules/object/tests/build_test/test.cpp | SAEEngine/SAEEngineCore | bede6c973caf7c4526ac5539ec2c9917139f2067 | [
"MIT"
] | null | null | null | /*
Return GOOD_TEST (0) if the test was passed.
Return anything other than GOOD_TEST (0) if the test was failed.
*/
// Common standard library headers
#include <cassert>
/**
* @brief Return this from main if the test was passsed.
*/
constexpr static inline int GOOD_TEST = 0;
// Include the headers you need for testing here
#include <SAEEngineCore_Object.h>
#include <SAEEngineCore_Environment.h>
#include <SAEEngineCore_glObject.h>
#include <chrono>
#include <thread>
#include <fstream>
#include <sstream>
#include <string>
#include <array>
#include <iostream>
#include <cmath>
using namespace sae::engine::core;
class ElementList : public GFXView
{
public:
void refresh() override
{
if (this->child_count() == 0)
return;
auto _x = this->bounds().left();
auto _w = this->bounds().width();
auto _eachWidth = (_w - ((this->child_count() - 1) * this->margin_)) / (this->child_count());
for (auto& o : this->children())
{
auto& _b = o->bounds();
_b.left() = _x;
_b.right() = _b.left() + _eachWidth;
_b.top() = this->bounds().top();
_b.bottom() = this->bounds().bottom();
_x += _eachWidth + this->margin_;
};
};
ElementList(GFXContext* _context, Rect _r, pixels_t _margin = 5_px) :
GFXView{ _context, _r }, margin_{ _margin }
{};
private:
pixels_t margin_ = 0;
};
int main(int argc, char* argv[], char* envp[])
{
GFXContext _context{ nullptr, Rect{{ 0_px, 0_px}, { 1600_px, 900_px } } };
auto _listB = _context.bounds();
auto _listPtr = new ElementList{ &_context, _listB, 0_px };
_listPtr->emplace(new GFXObject{ {} });
_listPtr->emplace(new GFXObject{ {} });
_listPtr->emplace(new GFXObject{ {} });
_listPtr->emplace(new GFXObject{ {} });
_context.emplace(_listPtr);
_context.refresh();
_listB.right() = _listB.left() + 600_px;
auto _list2Ptr = new ElementList{ &_context, _listB, 0_px };
_list2Ptr->emplace(new GFXObject{ {} });
_list2Ptr->emplace(new GFXObject{ {} });
_context.emplace(_list2Ptr);
_context.refresh();
return GOOD_TEST;
}; | 22.252747 | 95 | 0.669136 | SAEEngine |
2373bfefa0e0944e7f73099ae42a8648da18b3b6 | 2,085 | cpp | C++ | src/Log.cpp | wibbe/zum-cpp | 0fc753cac5f577eb56eaa9e8330f466b2cdaa38c | [
"MIT"
] | null | null | null | src/Log.cpp | wibbe/zum-cpp | 0fc753cac5f577eb56eaa9e8330f466b2cdaa38c | [
"MIT"
] | null | null | null | src/Log.cpp | wibbe/zum-cpp | 0fc753cac5f577eb56eaa9e8330f466b2cdaa38c | [
"MIT"
] | null | null | null |
#include "Log.h"
#include "bx/platform.h"
#include <cstdlib>
#include <cstdio>
static std::string logFile()
{
#if BX_PLATFORM_LINUX || BX_PLATFORM_OSX
static const std::string LOG_FILE = "/.zumlog";
const char * home = getenv("HOME");
if (home)
return std::string(home) + LOG_FILE;
else
return "~" + LOG_FILE;
#else
return "log.txt";
#endif
}
void clearLog()
{
FILE * file = fopen(logFile().c_str(), "w");
fclose(file);
}
void _logValue(FILE * file, char value)
{
fprintf(file, "%c", value);
fprintf(stderr, "%c", value);
}
void _logValue(FILE * file, int value)
{
fprintf(file, "%d", value);
fprintf(stderr, "%d", value);
}
void _logValue(FILE * file, uint32_t value)
{
fprintf(file, "%d", value);
fprintf(stderr, "%d", value);
}
void _logValue(FILE * file, long value)
{
fprintf(file, "%ld", value);
fprintf(stderr, "%ld", value);
}
void _logValue(FILE * file, long long int value)
{
fprintf(file, "%lld", value);
fprintf(stderr, "%lld", value);
}
void _logValue(FILE * file, float value)
{
fprintf(file, "%f", value);
fprintf(stderr, "%f", value);
}
void _logValue(FILE * file, double value)
{
fprintf(file, "%f", value);
fprintf(stderr, "%f", value);
}
void _logValue(FILE * file, const char * value)
{
fprintf(file, "%s", value);
fprintf(stderr, "%s", value);
}
void _logValue(FILE * file, Str const& value)
{
fprintf(file, "%s", value.utf8().c_str());
fprintf(stderr, "%s", value.utf8().c_str());
}
void _logValue(FILE * file, std::string const& value)
{
fprintf(file, "%s", value.c_str());
fprintf(stderr, "%s", value.c_str());
}
FILE * _logBegin()
{
return fopen(logFile().c_str(), "at");
}
void _logEnd(FILE * file)
{
_logValue(file, "\n");
fclose(file);
fflush(stderr);
}
void logInfo(Str const& message)
{
FILE * file = fopen(logFile().c_str(), "at");
fprintf(file, "INFO: %s\n", message.utf8().c_str());
fclose(file);
}
void logError(Str const& message)
{
FILE * file = fopen(logFile().c_str(), "at");
fprintf(file, "ERROR: %s\n", message.utf8().c_str());
fclose(file);
}
| 18.289474 | 55 | 0.62446 | wibbe |
2374eece4b5cb807686524d494c2f570d888704c | 7,577 | hpp | C++ | include/yamail/resource_pool/async/detail/queue.hpp | JonasProgrammer/resource_pool | 5b8e0d542e40805b187af7b94770e95f292379c9 | [
"MIT"
] | 17 | 2018-12-02T10:16:37.000Z | 2022-02-25T22:58:35.000Z | include/yamail/resource_pool/async/detail/queue.hpp | JonasProgrammer/resource_pool | 5b8e0d542e40805b187af7b94770e95f292379c9 | [
"MIT"
] | 27 | 2017-12-25T14:54:38.000Z | 2021-01-28T12:30:10.000Z | include/yamail/resource_pool/async/detail/queue.hpp | JonasProgrammer/resource_pool | 5b8e0d542e40805b187af7b94770e95f292379c9 | [
"MIT"
] | 5 | 2017-12-25T14:41:52.000Z | 2022-03-26T06:22:22.000Z | #ifndef YAMAIL_RESOURCE_POOL_ASYNC_DETAIL_QUEUE_HPP
#define YAMAIL_RESOURCE_POOL_ASYNC_DETAIL_QUEUE_HPP
#include <yamail/resource_pool/error.hpp>
#include <yamail/resource_pool/time_traits.hpp>
#include <boost/asio/executor.hpp>
#include <boost/asio/post.hpp>
#include <algorithm>
#include <list>
#include <map>
#include <mutex>
#include <unordered_map>
namespace yamail {
namespace resource_pool {
namespace async {
namespace asio = boost::asio;
namespace detail {
using clock = std::chrono::steady_clock;
template <class Handler>
class expired_handler {
Handler handler;
public:
using executor_type = std::decay_t<decltype(asio::get_associated_executor(handler))>;
expired_handler() = default;
template <class HandlerT>
explicit expired_handler(HandlerT&& handler,
std::enable_if_t<!std::is_same_v<std::decay_t<HandlerT>, expired_handler>, void*> = nullptr)
: handler(std::forward<HandlerT>(handler)) {
static_assert(std::is_same_v<std::decay_t<HandlerT>, Handler>, "HandlerT is not Handler");
}
void operator ()() {
handler(make_error_code(error::get_resource_timeout));
}
void operator ()() const {
handler(make_error_code(error::get_resource_timeout));
}
auto get_executor() const noexcept {
return asio::get_associated_executor(handler);
}
};
template <class Handler>
expired_handler(Handler&&) -> expired_handler<std::decay_t<Handler>>;
template <class Value, class IoContext>
struct queued_value {
Value request;
IoContext& io_context;
};
template <class Value, class Mutex, class IoContext, class Timer>
class queue : public std::enable_shared_from_this<queue<Value, Mutex, IoContext, Timer>> {
public:
using value_type = Value;
using io_context_t = IoContext;
using timer_t = Timer;
using queued_value_t = queued_value<value_type, io_context_t>;
queue(std::size_t capacity) : _capacity(capacity) {}
queue(const queue&) = delete;
queue(queue&&) = delete;
std::size_t capacity() const noexcept { return _capacity; }
std::size_t size() const noexcept;
bool empty() const noexcept;
const timer_t& timer(io_context_t& io_context);
bool push(io_context_t& io_context, time_traits::duration wait_duration, value_type&& request);
boost::optional<queued_value_t> pop();
private:
using mutex_t = Mutex;
using lock_guard = std::lock_guard<mutex_t>;
struct expiring_request {
using list = std::list<expiring_request>;
using list_it = typename list::iterator;
using multimap = std::multimap<time_traits::time_point, expiring_request*>;
using multimap_it = typename multimap::iterator;
io_context_t* io_context;
queue::value_type request;
list_it order_it;
multimap_it expires_at_it;
expiring_request() = default;
};
using request_multimap_value = typename expiring_request::multimap::value_type;
using timers_map = typename std::unordered_map<const io_context_t*, timer_t>;
const std::size_t _capacity;
mutable mutex_t _mutex;
typename expiring_request::list _ordered_requests_pool;
typename expiring_request::list _ordered_requests;
typename expiring_request::multimap _expires_at_requests;
timers_map _timers;
bool fit_capacity() const { return _expires_at_requests.size() < _capacity; }
void cancel(boost::system::error_code ec, time_traits::time_point expires_at);
void update_timer();
timer_t& get_timer(io_context_t& io_context);
};
template <class V, class M, class I, class T>
std::size_t queue<V, M, I, T>::size() const noexcept {
const lock_guard lock(_mutex);
return _expires_at_requests.size();
}
template <class V, class M, class I, class T>
bool queue<V, M, I, T>::empty() const noexcept {
const lock_guard lock(_mutex);
return _ordered_requests.empty();
}
template <class V, class M, class I, class T>
const typename queue<V, M, I, T>::timer_t& queue<V, M, I, T>::timer(io_context_t& io_context) {
const lock_guard lock(_mutex);
return get_timer(io_context);
}
template <class V, class M, class I, class T>
bool queue<V, M, I, T>::push(io_context_t& io_context, time_traits::duration wait_duration, value_type&& request) {
const lock_guard lock(_mutex);
if (!fit_capacity()) {
return false;
}
if (_ordered_requests_pool.empty()) {
_ordered_requests_pool.emplace_back();
}
const auto order_it = _ordered_requests_pool.begin();
_ordered_requests.splice(_ordered_requests.end(), _ordered_requests_pool, order_it);
expiring_request& req = *order_it;
req.io_context = std::addressof(io_context);
req.request = std::move(request);
req.order_it = order_it;
const auto expires_at = time_traits::add(time_traits::now(), wait_duration);
req.expires_at_it = _expires_at_requests.insert(std::make_pair(expires_at, &req));
update_timer();
return true;
}
template <class V, class M, class I, class T>
boost::optional<typename queue<V, M, I, T>::queued_value_t> queue<V, M, I, T>::pop() {
const lock_guard lock(_mutex);
if (_ordered_requests.empty()) {
return {};
}
const auto ordered_it = _ordered_requests.begin();
expiring_request& req = *ordered_it;
queued_value_t result {std::move(req.request), *req.io_context};
_expires_at_requests.erase(req.expires_at_it);
_ordered_requests_pool.splice(_ordered_requests_pool.begin(), _ordered_requests, ordered_it);
update_timer();
return { std::move(result) };
}
template <class V, class M, class I, class T>
void queue<V, M, I, T>::cancel(boost::system::error_code ec, time_traits::time_point expires_at) {
if (ec) {
return;
}
const lock_guard lock(_mutex);
const auto begin = _expires_at_requests.begin();
const auto end = _expires_at_requests.upper_bound(expires_at);
std::for_each(begin, end, [&] (request_multimap_value& v) {
const auto req = v.second;
asio::post(*req->io_context, expired_handler(std::move(req->request)));
_ordered_requests_pool.splice(_ordered_requests_pool.begin(), _ordered_requests, req->order_it);
});
_expires_at_requests.erase(_expires_at_requests.begin(), end);
update_timer();
}
template <class V, class M, class I, class T>
void queue<V, M, I, T>::update_timer() {
using timers_map_value = typename timers_map::value_type;
if (_expires_at_requests.empty()) {
std::for_each(_timers.begin(), _timers.end(), [] (timers_map_value& v) { v.second.cancel(); });
_timers.clear();
return;
}
const auto earliest_expire = _expires_at_requests.begin();
const auto expires_at = earliest_expire->first;
auto& timer = get_timer(*earliest_expire->second->io_context);
timer.expires_at(expires_at);
std::weak_ptr<queue> weak(this->shared_from_this());
timer.async_wait([weak, expires_at] (boost::system::error_code ec) {
if (const auto locked = weak.lock()) {
locked->cancel(ec, expires_at);
}
});
}
template <class V, class M, class I, class T>
typename queue<V, M, I, T>::timer_t& queue<V, M, I, T>::get_timer(io_context_t& io_context) {
auto it = _timers.find(&io_context);
if (it != _timers.end()) {
return it->second;
}
return _timers.emplace(&io_context, timer_t(io_context)).first->second;
}
} // namespace detail
} // namespace async
} // namespace resource_pool
} // namespace yamail
#endif // YAMAIL_RESOURCE_POOL_ASYNC_DETAIL_QUEUE_HPP
| 33.526549 | 115 | 0.700937 | JonasProgrammer |
2378fd7fec6d7510bbff013b9a0ea4b2b7f215bd | 268 | cpp | C++ | src/portaudiohandler.cpp | aparks5/synthcastle | ebb542d014c87a11a83b9e212668eca75a333fbf | [
"MIT"
] | 2 | 2021-12-20T03:20:05.000Z | 2021-12-28T16:15:20.000Z | src/portaudiohandler.cpp | aparks5/synthcastle | ebb542d014c87a11a83b9e212668eca75a333fbf | [
"MIT"
] | 69 | 2021-08-30T13:09:01.000Z | 2022-01-15T17:41:40.000Z | src/portaudiohandler.cpp | aparks5/synthcastle | ebb542d014c87a11a83b9e212668eca75a333fbf | [
"MIT"
] | null | null | null | /// Copyright(c) 2021. Anthony Parks. All rights reserved.
#include "portaudiohandler.h"
PortAudioHandler::PortAudioHandler()
: m_result(Pa_Initialize())
{
}
PortAudioHandler::~PortAudioHandler()
{
if (m_result == paNoError)
{
Pa_Terminate();
}
} | 17.866667 | 59 | 0.682836 | aparks5 |
2379857d0af4607a620b76853af3c51e2d41dcac | 1,173 | cpp | C++ | Source/Trickery/Test.cpp | D4rk1n/ModernProblemsModernSolutions | bb8f96f9701fe3eee3b5a513b42575a3d0075bb4 | [
"Apache-2.0"
] | null | null | null | Source/Trickery/Test.cpp | D4rk1n/ModernProblemsModernSolutions | bb8f96f9701fe3eee3b5a513b42575a3d0075bb4 | [
"Apache-2.0"
] | null | null | null | Source/Trickery/Test.cpp | D4rk1n/ModernProblemsModernSolutions | bb8f96f9701fe3eee3b5a513b42575a3d0075bb4 | [
"Apache-2.0"
] | null | null | null | // Fill out your copyright notice in the Description page of Project Settings.
#include "Test.h"
// Sets default values for this component's properties
UTest::UTest()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UTest::BeginPlay()
{
Super::BeginPlay();
Owner = GetOwner();
POpen = GetWorld()->GetFirstPlayerController()->GetPawn();
// ...
}
// Called every frame
void UTest::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (AOpen&&PPlate)
{
//UE_LOG(LogTemp, Warning, TEXT("lol "));
if (PPlate->IsOverlappingActor(AOpen)) {
UE_LOG(LogTemp, Warning, TEXT("Actor that opens "))
FRotator r(0, -50, 0);
Owner->SetActorRotation(r);
}
if (PPlate->IsOverlappingActor(POpen)) {
UE_LOG(LogTemp, Warning, TEXT("Pawn that opens "))
FRotator r(0, -50, 0);
Owner->SetActorRotation(r);
}
}
// ...
}
| 24.4375 | 121 | 0.700767 | D4rk1n |
237cc3acae3061fd145e90a3004595c0a35619b0 | 354 | hpp | C++ | include/toy/gadget/IntToHexChar.hpp | ToyAuthor/ToyBox | f517a64d00e00ccaedd76e33ed5897edc6fde55e | [
"Unlicense"
] | 4 | 2017-07-06T22:18:41.000Z | 2021-05-24T21:28:37.000Z | include/toy/gadget/IntToHexChar.hpp | ToyAuthor/ToyBox | f517a64d00e00ccaedd76e33ed5897edc6fde55e | [
"Unlicense"
] | null | null | null | include/toy/gadget/IntToHexChar.hpp | ToyAuthor/ToyBox | f517a64d00e00ccaedd76e33ed5897edc6fde55e | [
"Unlicense"
] | 1 | 2020-08-02T13:00:38.000Z | 2020-08-02T13:00:38.000Z |
#pragma once
#include "toy/Standard.hpp"
#include "toy/gadget/Export.hpp"
namespace toy{
namespace gadget{
// 1 -> '1'
// 2 -> '2'
// 11 -> 'b'
// 15 -> 'f'
// 16 -> [error]
TOY_API_GADGET extern char IntToHexChar(int);
// 1 -> '1'
// 2 -> '2'
// 11 -> 'B'
// 15 -> 'F'
// 16 -> [error]
TOY_API_GADGET extern char IntToHexChar_Capital(int);
}}
| 14.16 | 53 | 0.573446 | ToyAuthor |
237fc3ac31b5b7e05509b8d16e2810e96459d81d | 278 | hpp | C++ | package/config/config/config_config.hpp | mambaru/wfc_core | 0c3e7fba82a9bb1580582968efae02ef7fabc87a | [
"MIT"
] | null | null | null | package/config/config/config_config.hpp | mambaru/wfc_core | 0c3e7fba82a9bb1580582968efae02ef7fabc87a | [
"MIT"
] | 5 | 2019-12-06T01:01:01.000Z | 2021-04-20T21:16:34.000Z | package/config/config/config_config.hpp | mambaru/wfc_core | 0c3e7fba82a9bb1580582968efae02ef7fabc87a | [
"MIT"
] | null | null | null | //
// Author: Vladimir Migashko <migashko@gmail.com>, (C) 2013-2018
//
// Copyright: See COPYING file that comes with this distribution
//
#pragma once
namespace wfc{ namespace core{
struct config_config
{
bool reload_sighup = false;
time_t reload_changed_ms = 0;
};
}}
| 15.444444 | 64 | 0.715827 | mambaru |
238147189c29475ac43a113d5e97782feee7d072 | 345 | cpp | C++ | OOP Lab/Lab9/LE/LE9_9.cpp | HANS-2002/Jab-sab-aapki-le-rahe-ho-tab-aap-bhi-kuch-lelo | 8a9d67153797e9a6d438151c70f6726a50079df4 | [
"MIT"
] | 2 | 2021-09-18T10:50:20.000Z | 2021-11-12T13:19:45.000Z | OOP Lab/Lab9/LE/LE9_9.cpp | HANS-2002/Jab-sab-aapki-le-rahe-ho-tab-aap-bhi-kuch-lelo | 8a9d67153797e9a6d438151c70f6726a50079df4 | [
"MIT"
] | null | null | null | OOP Lab/Lab9/LE/LE9_9.cpp | HANS-2002/Jab-sab-aapki-le-rahe-ho-tab-aap-bhi-kuch-lelo | 8a9d67153797e9a6d438151c70f6726a50079df4 | [
"MIT"
] | 3 | 2021-09-10T14:08:12.000Z | 2021-09-18T10:52:09.000Z | // (Class Template) Write a program to explain class template by creating a template T for a class
// named pair having two data members of type T which are inputted by a constructor and a
// member function get-max() return the greatest of two numbers to main. Note: the value of T
// depends upon the data type specified during object creation | 86.25 | 98 | 0.776812 | HANS-2002 |
2385728ed6e584fa445b30a6a16b3161dcf5820b | 3,542 | cpp | C++ | scaffold/Setting.cpp | taozhijiang/roo | bea672b9274f91f4002a9742e096152b0d62f122 | [
"BSD-3-Clause"
] | null | null | null | scaffold/Setting.cpp | taozhijiang/roo | bea672b9274f91f4002a9742e096152b0d62f122 | [
"BSD-3-Clause"
] | null | null | null | scaffold/Setting.cpp | taozhijiang/roo | bea672b9274f91f4002a9742e096152b0d62f122 | [
"BSD-3-Clause"
] | 2 | 2019-08-23T02:31:42.000Z | 2020-05-02T00:12:36.000Z | /*-
* Copyright (c) 2019 TAO Zhijiang<taozhijiang@gmail.com>
*
* Licensed under the BSD-3-Clause license, see LICENSE for full information.
*
*/
#include <sstream>
#include <iostream>
#include <scaffold/Setting.h>
#include <scaffold/Status.h>
namespace roo {
bool Setting::init(std::string file) {
cfg_file_ = file;
setting_ptr_.reset( new libconfig::Config() );
if (!setting_ptr_) {
log_err("create libconfig failed.");
return false;
}
// try load and explain the cfg_file first.
try {
setting_ptr_->readFile(file.c_str());
} catch(libconfig::FileIOException &fioex) {
fprintf(stderr, "I/O error while reading file: %s.", file.c_str());
log_err( "I/O error while reading file: %s.", file.c_str());
setting_ptr_.reset();
} catch(libconfig::ParseException &pex) {
fprintf(stderr, "Parse error at %d - %s", pex.getLine(), pex.getError());
log_err( "Parse error at %d - %s", pex.getLine(), pex.getError());
setting_ptr_.reset();
}
// when init, parse conf failed was critical.
if (!setting_ptr_) {
return false;
}
return true;
}
int Setting::update_runtime_setting() {
if (cfg_file_.empty()) {
log_err("param cfg_file is not set, may not initialized ???");
return -1;
}
std::lock_guard<std::mutex> lock(lock_);
if (in_process_) {
log_err("!!! already in process, please try again later!");
return 0;
}
auto setting = load_cfg_file();
if (!setting) {
in_process_ = false;
log_err("load config file %s failed.", cfg_file_.c_str());
return false;
}
// 重新读取配置并且解析成功之后,才更新这个指针
std::swap(setting, setting_ptr_);
last_update_time_ = ::time(NULL);
int ret = 0;
for (auto it = calls_.begin(); it != calls_.end(); ++it) {
ret += (it->second)(*setting_ptr_); // call it!
}
log_warning("Setting::update_runtime_conf total callback return: %d", ret);
in_process_ = false;
return ret;
}
int Setting::attach_runtime_callback(const std::string& name, SettingUpdateCallable func) {
if (name.empty() || !func){
log_err("invalid name or func param.");
return -1;
}
std::lock_guard<std::mutex> lock(lock_);
calls_.push_back({name, func});
log_info("register runtime for %s success.", name.c_str());
return 0;
}
int Setting::module_status(std::string& module, std::string& name, std::string& val) {
module = "roo";
name = "Setting";
std::stringstream ss;
ss << "attached runtime update: " << std::endl;
std::lock_guard<std::mutex> lock(lock_);
int i = 1;
for (auto it = calls_.begin(); it != calls_.end(); ++it) {
ss << "\t" << i++ << ". "<< it->first << std::endl;
}
val = ss.str();
return 0;
}
std::shared_ptr<libconfig::Config> Setting::load_cfg_file() {
std::shared_ptr<libconfig::Config> setting = std::make_shared<libconfig::Config>();
if (!setting) {
log_err("create libconfig::Config instance failed!");
return setting; // nullptr
}
try {
setting->readFile(cfg_file_.c_str());
} catch (libconfig::FileIOException& fioex) {
log_err("I/O error while reading file: %s.", cfg_file_.c_str());
setting.reset();
} catch (libconfig::ParseException& pex) {
log_err("Parse error at %d - %s", pex.getLine(), pex.getError());
setting.reset();
}
return setting;
}
} // end namespace roo
| 25.120567 | 91 | 0.601073 | taozhijiang |
23875d96f499e5a6f87d8a846965a7aab0aeabaa | 1,736 | cxx | C++ | HTRunInfo/HTDAQStackInfo.cxx | dellaquilamaster/RIBbit2 | 5e792724676a7b84e19e9512b2d6295287f81a4e | [
"Unlicense"
] | null | null | null | HTRunInfo/HTDAQStackInfo.cxx | dellaquilamaster/RIBbit2 | 5e792724676a7b84e19e9512b2d6295287f81a4e | [
"Unlicense"
] | null | null | null | HTRunInfo/HTDAQStackInfo.cxx | dellaquilamaster/RIBbit2 | 5e792724676a7b84e19e9512b2d6295287f81a4e | [
"Unlicense"
] | 1 | 2019-05-03T17:50:21.000Z | 2019-05-03T17:50:21.000Z | #include <HTDAQStackInfo.h>
//________________________________________________
HTDAQStackInfo::HTDAQStackInfo(const char * name, int stackID) :
fNModules(0),
fStackName(name),
fStackID(stackID)
{}
//________________________________________________
HTDAQStackInfo::~HTDAQStackInfo()
{
Clear();
}
//________________________________________________
void HTDAQStackInfo::Clear()
{
for(int i=0; i<fNModules; i++) {
if(fModuleInStack[i]) {
delete fModuleInStack[i];
}
}
fModuleInStack.clear();
fNModules=0;
}
//________________________________________________
int HTDAQStackInfo::GetNModules() const
{
return fNModules;
}
//________________________________________________
RBElectronics * HTDAQStackInfo::GetModule(int n_module) const
{
return fModuleInStack[n_module]->GetModule();
}
//________________________________________________
const char * HTDAQStackInfo::GetModuleType(int n_module) const
{
return fModuleInStack[n_module]->GetModuleType();
}
//________________________________________________
int HTDAQStackInfo::GetModuleVSN(int n_module) const
{
return fModuleInStack[n_module]->GetVSN();
}
//________________________________________________
int HTDAQStackInfo::GetStackID() const
{
return fStackID;
}
//________________________________________________
const char * HTDAQStackInfo::GetStackName() const
{
return fStackName.c_str();
}
//________________________________________________
HTModuleInfo * HTDAQStackInfo::GetModuleInfo(int n_module) const
{
return fModuleInStack[n_module];
}
//________________________________________________
void HTDAQStackInfo::AddModuleInfo(HTModuleInfo * new_module_info)
{
fNModules++;
fModuleInStack.push_back(new_module_info);
return;
}
| 22.545455 | 66 | 0.801843 | dellaquilamaster |
238de8358cb0938b34eacfe1305a0bb6b5442982 | 3,202 | cpp | C++ | unit_tests/core/math/euler_angles/src/unit_euler_angles.cpp | ricortiz/OpenTissue | f8c8ebc5137325b77ba90bed897f6be2795bd6fb | [
"Zlib"
] | 76 | 2018-02-20T11:30:52.000Z | 2022-03-31T12:45:06.000Z | unit_tests/core/math/euler_angles/src/unit_euler_angles.cpp | ricortiz/OpenTissue | f8c8ebc5137325b77ba90bed897f6be2795bd6fb | [
"Zlib"
] | 27 | 2018-11-20T14:32:49.000Z | 2021-11-24T15:26:45.000Z | unit_tests/core/math/euler_angles/src/unit_euler_angles.cpp | ricortiz/OpenTissue | f8c8ebc5137325b77ba90bed897f6be2795bd6fb | [
"Zlib"
] | 24 | 2018-02-21T01:45:26.000Z | 2022-03-07T07:06:49.000Z | //
// OpenTissue, A toolbox for physical based simulation and animation.
// Copyright (C) 2007 Department of Computer Science, University of Copenhagen
//
#include <OpenTissue/configuration.h>
#include <OpenTissue/core/math/math_euler_angles.h>
#define BOOST_AUTO_TEST_MAIN
#include <OpenTissue/utility/utility_push_boost_filter.h>
#include <boost/test/auto_unit_test.hpp>
#include <boost/test/unit_test_suite.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <boost/test/test_tools.hpp>
#include <OpenTissue/utility/utility_pop_boost_filter.h>
using namespace OpenTissue;
void do_test( double const & phi_in, double const & psi_in, double const & theta_in)
{
OpenTissue::math::Quaternion<double> Q_in;
OpenTissue::math::Quaternion<double> Q_out;
OpenTissue::math::Quaternion<double> identity;
OpenTissue::math::Quaternion<double> Qz1;
OpenTissue::math::Quaternion<double> Qy;
OpenTissue::math::Quaternion<double> Qz2;
double const too_small = 10e-7;
double phi_out = 0.0;
double psi_out = 0.0;
double theta_out = 0.0;
Qz1.Rz(theta_in);
Qy.Ry(psi_in);
Qz2.Rz(phi_in);
Q_in = OpenTissue::math::prod( Qz2 , OpenTissue::math::prod( Qy , Qz1) );
OpenTissue::math::ZYZ_euler_angles(Q_in,phi_out,psi_out,theta_out);
if(psi_in > 0.0)
{
// we only want to do this if we are not in a gimbal lock
Qz1.Rz(theta_out);
Qy.Ry(psi_out);
Qz2.Rz(phi_out);
Q_out = OpenTissue::math::prod( Qz2 , OpenTissue::math::prod( Qy , Qz1) );
identity = OpenTissue::math::prod( OpenTissue::math::conj(Q_out), Q_in );
double const s = fabs( fabs(identity.s()) - 1.0 );
double const v0 = fabs(identity.v()(0));
double const v1 = fabs(identity.v()(1));
double const v2 = fabs(identity.v()(2));
BOOST_CHECK( s < too_small);
BOOST_CHECK( v0 < too_small);
BOOST_CHECK( v1 < too_small);
BOOST_CHECK( v2 < too_small);
double const dphi = fabs(phi_in - phi_out);
double const dpsi = fabs(psi_in - psi_out);
double const dtheta = fabs(theta_in - theta_out);
BOOST_CHECK( dphi < too_small);
BOOST_CHECK( dpsi < too_small);
BOOST_CHECK( dtheta < too_small);
}
else
{
// In gimbal lock phi and theta behaves strangely
BOOST_CHECK_CLOSE( 0.0, theta_out, 0.01);
double const dpsi = fabs(psi_out);
BOOST_CHECK( dpsi < too_small);
double new_phi = phi_in + theta_in;
double const pi = 3.1415926535897932384626433832795;
double const two_pi = 2.0*pi;
while(new_phi>pi) new_phi -= two_pi;
while(new_phi<-pi) new_phi += two_pi;
double const dphi = fabs(new_phi - phi_out);
BOOST_CHECK( dphi < too_small);
}
}
BOOST_AUTO_TEST_SUITE(opentissue_math_euler_angles);
BOOST_AUTO_TEST_CASE(ZYZ)
{
size_t N = 15;
double const pi = 3.1415926535897932384626433832795;
double const two_pi = 2.0*pi;
double const delta = (two_pi)/(N-1);
double phi = -pi+delta;
for(;phi<pi;)
{
double psi = 0.0;
for(;psi<pi;)
{
double theta = -pi+delta;
for(;theta<pi;)
{
do_test( phi, psi, theta );
theta += delta;
}
psi += delta;
}
phi += delta;
}
}
BOOST_AUTO_TEST_SUITE_END();
| 27.367521 | 84 | 0.67614 | ricortiz |
2390b9de6c1a931be7e506b913688dfde1b290ed | 902 | cpp | C++ | Recover Binary Search Tree.cpp | Subhash3/Algorithms-For-Software-Developers | 2e0ac4f51d379a2b10a40fca7fa82a8501d3db94 | [
"BSD-2-Clause"
] | 2 | 2021-10-01T04:20:04.000Z | 2021-10-01T04:20:06.000Z | Recover Binary Search Tree.cpp | Subhash3/Algorithms-For-Software-Developers | 2e0ac4f51d379a2b10a40fca7fa82a8501d3db94 | [
"BSD-2-Clause"
] | 1 | 2021-10-01T18:00:09.000Z | 2021-10-01T18:00:09.000Z | Recover Binary Search Tree.cpp | Subhash3/Algorithms-For-Software-Developers | 2e0ac4f51d379a2b10a40fca7fa82a8501d3db94 | [
"BSD-2-Clause"
] | 8 | 2021-10-01T04:20:38.000Z | 2022-03-19T17:05:05.000Z | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
TreeNode* first=0;
TreeNode* sec=0;
TreeNode* prev=new TreeNode(INT_MIN);
void inorder(TreeNode* root){
if(!root)
return;
inorder(root->left);
if(!first&&root->val<prev->val)
first=prev;
if(first&&root->val<prev->val)
sec=root;
prev=root;
inorder(root->right);
}
void recoverTree(TreeNode* root) {
inorder(root);
int temp=first->val;
first->val=sec->val;
sec->val=temp;
}
};
| 25.771429 | 93 | 0.543237 | Subhash3 |
23930b18119937fc7644d72e096d087022e91ab1 | 864 | cpp | C++ | src/gfxtk/Buffer.cpp | NostalgicGhoul/gfxtk | 6662d6d1b285e20806ecfef3cdcb620d6605e478 | [
"BSD-2-Clause"
] | null | null | null | src/gfxtk/Buffer.cpp | NostalgicGhoul/gfxtk | 6662d6d1b285e20806ecfef3cdcb620d6605e478 | [
"BSD-2-Clause"
] | null | null | null | src/gfxtk/Buffer.cpp | NostalgicGhoul/gfxtk | 6662d6d1b285e20806ecfef3cdcb620d6605e478 | [
"BSD-2-Clause"
] | null | null | null | #include "Buffer.hpp"
#ifdef GFXTK_GRAPHICS_BACKEND_VULKAN
#include <gfxtk/backend/vulkan/Buffer.hpp>
#elif GFXTK_GRAPHICS_BACKEND_METAL
#include <gfxtk/backend/metal/Buffer.hpp>
#else
#error target OS is not supported by any existing graphics backend!
#endif
gfxtk::Buffer gfxtk::Buffer::create(
std::shared_ptr<backend::Device> const& backendDevice,
size_t size,
gfxtk::BufferUsageFlags bufferUsageFlags,
gfxtk::MemoryUsage memoryUsage
) {
return Buffer(backend::Buffer::create(backendDevice, size, bufferUsageFlags, memoryUsage));
}
gfxtk::Buffer::Buffer(std::shared_ptr<backend::Buffer> backendBuffer)
: _backendBuffer(std::move(backendBuffer)) {}
gfxtk::Buffer::~Buffer() = default;
void* gfxtk::Buffer::map() {
return _backendBuffer->map();
}
void gfxtk::Buffer::unmap() {
_backendBuffer->unmap();
}
| 27 | 95 | 0.726852 | NostalgicGhoul |
2393d38d4a5a137d14b49a994ed5ea0b6f9fe7fa | 2,091 | hpp | C++ | obs-studio/UI/window-basic-main-outputs.hpp | noelemahcz/libobspp | 029472b973e5a1985f883242f249848385df83a3 | [
"MIT"
] | null | null | null | obs-studio/UI/window-basic-main-outputs.hpp | noelemahcz/libobspp | 029472b973e5a1985f883242f249848385df83a3 | [
"MIT"
] | null | null | null | obs-studio/UI/window-basic-main-outputs.hpp | noelemahcz/libobspp | 029472b973e5a1985f883242f249848385df83a3 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
class OBSBasic;
struct BasicOutputHandler {
OBSOutputAutoRelease fileOutput;
OBSOutputAutoRelease streamOutput;
OBSOutputAutoRelease replayBuffer;
OBSOutputAutoRelease virtualCam;
bool streamingActive = false;
bool recordingActive = false;
bool delayActive = false;
bool replayBufferActive = false;
bool virtualCamActive = false;
OBSBasic *main;
std::string outputType;
std::string lastError;
std::string lastRecordingPath;
OBSSignal startRecording;
OBSSignal stopRecording;
OBSSignal startReplayBuffer;
OBSSignal stopReplayBuffer;
OBSSignal startStreaming;
OBSSignal stopStreaming;
OBSSignal startVirtualCam;
OBSSignal stopVirtualCam;
OBSSignal streamDelayStarting;
OBSSignal streamStopping;
OBSSignal recordStopping;
OBSSignal replayBufferStopping;
OBSSignal replayBufferSaved;
inline BasicOutputHandler(OBSBasic *main_);
virtual ~BasicOutputHandler(){};
virtual bool SetupStreaming(obs_service_t *service) = 0;
virtual bool StartStreaming(obs_service_t *service) = 0;
virtual bool StartRecording() = 0;
virtual bool StartReplayBuffer() { return false; }
virtual bool StartVirtualCam();
virtual void StopStreaming(bool force = false) = 0;
virtual void StopRecording(bool force = false) = 0;
virtual void StopReplayBuffer(bool force = false) { (void)force; }
virtual void StopVirtualCam();
virtual bool StreamingActive() const = 0;
virtual bool RecordingActive() const = 0;
virtual bool ReplayBufferActive() const { return false; }
virtual bool VirtualCamActive() const;
virtual void Update() = 0;
virtual void SetupOutputs() = 0;
inline bool Active() const
{
return streamingActive || recordingActive || delayActive ||
replayBufferActive || virtualCamActive;
}
protected:
void SetupAutoRemux(const char *&ext);
std::string GetRecordingFilename(const char *path, const char *ext,
bool noSpace, bool overwrite,
const char *format, bool ffmpeg);
};
BasicOutputHandler *CreateSimpleOutputHandler(OBSBasic *main);
BasicOutputHandler *CreateAdvancedOutputHandler(OBSBasic *main);
| 28.256757 | 68 | 0.780966 | noelemahcz |
239529e3a0656005ba014a4ca0e76a86b1b2136a | 646 | cpp | C++ | mrJudge/problems/countfishes (197)/countfishes.cpp | object-oriented-human/competitive | 9e761020e887d8980a39a64eeaeaa39af0ecd777 | [
"MIT"
] | 1 | 2022-02-21T15:43:01.000Z | 2022-02-21T15:43:01.000Z | mrJudge/problems/countfishes (197)/countfishes.cpp | foooop/competitive | 9e761020e887d8980a39a64eeaeaa39af0ecd777 | [
"MIT"
] | null | null | null | mrJudge/problems/countfishes (197)/countfishes.cpp | foooop/competitive | 9e761020e887d8980a39a64eeaeaa39af0ecd777 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
int tc, inf=1000001; cin >> tc;
vector<int> isprime(inf, 1), prefix(inf);
for (int i = 2; i*i < inf; i++) {
if (isprime[i]) {
for (int j = i*i; j < inf; j+= i) {
isprime[j] = 0;
}
}
}
prefix[0] = 0, prefix[1] = 0;
for (int i = 2; i < inf; i++) {
prefix[i] = prefix[i-1];
if (isprime[i]) {
prefix[i]++;
}
}
while (tc--) {
int p, q; cin >> p >> q;
cout << prefix[q] - prefix[p-1] << '\n';
}
} | 21.533333 | 48 | 0.410217 | object-oriented-human |
2399e24ba2dbf07647952ce82ee88f98e7b1095d | 6,547 | cpp | C++ | src/structs.cpp | Algorithms-and-Data-Structures-2021/classwork-02-cpp-basics-demo | dccf30fd03a7ed4e8e68f85c395f786a643ea3db | [
"MIT"
] | null | null | null | src/structs.cpp | Algorithms-and-Data-Structures-2021/classwork-02-cpp-basics-demo | dccf30fd03a7ed4e8e68f85c395f786a643ea3db | [
"MIT"
] | null | null | null | src/structs.cpp | Algorithms-and-Data-Structures-2021/classwork-02-cpp-basics-demo | dccf30fd03a7ed4e8e68f85c395f786a643ea3db | [
"MIT"
] | 3 | 2021-03-10T06:20:27.000Z | 2021-03-17T05:53:36.000Z | #include <iostream> // cout
// Подключаем свой заголовочный файл -
// целью заголовочных файлов является удобное хранение набора объявлений
// для их последующего использования в других программах.
// поиск заголовочного файла осуществляется в папках проекта (а не в системных директориях)
#include "structs.hpp"
// директива #pragma once (см. заголовочный файл) не позволит повторно подключить заголовочный файл
// поэтому, повторный include просто не сработает
#include "structs.hpp"
using namespace std;
int main() {
{
Student student; // { id = <мусор>, age = <мусор>, name = "", avg_score = <мусор> }
// инициализация структуры (aggregate initialization)
student = {0, 24, "Ramil Safin", 92.6};
// доступ к полям (оператор .)
const double avg_score = student.avg_score; // чтение
student.avg_score = avg_score - 0.3; // запись
// копирование
Student const student_copy = student; // { id = 0, age = 24, name = "Ramil Safin", avg_score = 92.3 }
// student_copy.name = ""; // <- ошибка компиляции
// указатель и ссылка
Student *ptr_to_student = &student;
// оператор обращения к полям структуры через указатель (->)
ptr_to_student->age = 32; // эквивалентно (*ptr_to_student).age = 32;
update_score(ptr_to_student, 86);
Student &ref_to_student = student;
// оператор обращения к полям . (точка)
ref_to_student.age += 1;
update_score(ref_to_student, 90);
print_details(ref_to_student /* ссылка на const */);
}
{ // конструкторы и деструкторы
{ // вошли в новую область видимости
University u1; // конструктор по-умолчанию (объект создается на стеке)
u1.~University(); // ручной вызов деструктора (объект НЕ удаляется со стека)
// здесь мы ещё можем продолжать использовать u1
} // вышли из области видимости => автоматический вызов деструктора u1
University u2("KFU"); // explicit конструктор по name
// University u2_str = string("KFU"); // <- ошибка компиляции (неявное приведение типа string к University)
University u2_str = static_cast<University>(string("KFU")); // явное приведение типа
University u3(1); // НЕ explicit конструктор по ranking
University u3_int = 1; // ОК, вызов конструктора с ranking (неявное преобразование типа int в University)
University u4("KFU", 1); // конструктор по name и ranking
}
{ // приватные/публичные поля и методы структуры
University uni; // вызов конструктора по-умолчанию (создание объекта класса uni)
// uni.name_ = ""; // <- ошибка компиляции (поле name_ приватное)
// для получения доступа к приватным полям используются публичные методы
string name = uni.GetName(); // копия поля name_
string &name_ref = uni.GetNameRef(); // ссылка на поле name_
name_ref = ""; // ОК, теперь uni.name_ = ""
uni.SetName("MSU");
string const &name_const_ref = uni.GetNameConstRef(); // ссылка на неизменяемое поле name_
// name_const_ref = ""; // <- ошибка компиляции
// вызов приватных функций - невозможен
// uni.private_function(); // <- ошибка компиляции
}
{ // неявный указатель this
University uni;
auto &this_ref = uni.GetThisRef();
// компилятор записывает строку кода выше примерно следующим образом:
// GetThisRef(&uni) - т.е. компилятор передает указатель на объект неявным аргументом
// Ex.: Python: self (явный), Java: this (неявный)
}
{ // статические методы и поля
int ID = University::ID; // получение значения статического поля структуры (объект не обязательно создавать)
int curr_id = University::CurrentID(); // вызов статического метода структуры
// можно получить доступ к публичному статическому полю и через объект
University u;
curr_id = u.ID;
}
{ // создание объектов структуры на куче, деструктор
auto *u_ptr = new University("KFU", 1);
string name = u_ptr->GetName();
delete u_ptr; // ручной вызов деструктора и освобождение памяти
} // при выходе из области видимости деструктор не вызовется (высвободится лишь память под указатель u_ptr)
return 0;
}
// определение функций, объявленных в заголовочном файле structs.hpp
void update_score(Student &student, double new_score) {
student.avg_score = new_score;
}
void update_score(Student *student, double new_score) {
student->avg_score = new_score;
}
void print_details(Student const &student) {
// student нужен только для чтения данных: id и пр.
std::cout << "Student: " << "ID = " << student.id << "\tName: " << student.name << endl;
}
// определение методов University из заголовочного файла
// <название структуры>::<название метода>(<параметры>) : <список инициализации полей> { <тело метода> }
// :: - оператор разрешение области, используется для идентификации и устранения неоднозначности идентификаторов
University::University(const string &name, int ranking) : name_{name}, ranking_{ranking} {
// генерация идентификатора на базе статического поля структуры
id_ = ID++; // эквивалентно: id_ = ID и ID += 1
}
int University::GetId() const {
// id_ = 0; // <- ошибка компиляции
return id_;
}
std::string University::GetName() const {
return name_;
}
int University::GetRanking() const {
return ranking_;
}
std::string &University::GetNameRef() /* const - нельзя, нет гарантии, что name_ не изменится */ {
// ranking_ = 0; // можно изменять поля объекта, но не стоит, это плохой код
return name_; // по ссылке можно будет изменять поле name_ у объекта типа University
}
std::string const &University::GetNameConstRef() const /* const - уже есть гарантии неизменности name_ */ {
// private_function(); // <- ошибка компиляции
private_const_function();
return name_;
}
University &University::GetThisRef() {
// std::string name = this->name_;
// эквивалентно: std::string name = name_;
return *this; // разыменуем указатель и получаем адрес объекта в памяти
// который можем вернуть как ссылку (можно и указатель вернуть)
}
void University::SetRanking(int ranking) {
ranking_ = ranking;
}
void University::SetName(const string &name) {
name_ = name;
}
void University::private_function() {
// блок кода
}
void University::private_const_function() const {
// блок кода
}
University::University(const std::string &name) : University(name, 0) {
std::cout << "explicit University(name)" << std::endl;
}
//University::University(const string &name)
| 31.781553 | 113 | 0.685352 | Algorithms-and-Data-Structures-2021 |
239dfe62dd54c7c176526a8d355e463822fe0611 | 32,683 | cpp | C++ | sam/sam2016.cpp | leandrohga/cs4298_MacNCheese | 89e6b381341c5b647c98a0d84af6f71c57a4e147 | [
"Apache-2.0"
] | null | null | null | sam/sam2016.cpp | leandrohga/cs4298_MacNCheese | 89e6b381341c5b647c98a0d84af6f71c57a4e147 | [
"Apache-2.0"
] | null | null | null | sam/sam2016.cpp | leandrohga/cs4298_MacNCheese | 89e6b381341c5b647c98a0d84af6f71c57a4e147 | [
"Apache-2.0"
] | null | null | null | /* ____________________________________________________________________________
S A M 2 0 0 7
An Assembler for the MACC2 Virtual Computer
James L. Richards
Last Update: August 28, 2007
Last Update: January 2, 2016
by Marty J. Wolf
____________________________________________________________________________
*/
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <sstream>
#include <algorithm>
using namespace std;
const int MAXINT = 32767;
typedef unsigned char Byte;
typedef unsigned short Word;
enum OpKind {OIN, IA, IS, IM, IDENT, FN, FA, FS, FM, FD,
BI, BO, BA, IC, FC, JSR, BKT, LD, STO, LDA,
FLT, FIX, J, SR, SL, SRD, SLD, RD, WR, TRNG,
HALT, NOP, CLR, REALDIR, STRINGDIR, INTDIR,
SKIPDIR, LABELDIR};
enum ErrorKind {NO_ERROR, UNKNOWN_OP_NAME, BAD_REG_ADDR, BAD_GEN_ADDR,
BAD_INTEGER, BAD_REAL, BAD_STR, BAD_NAME, ILL_REG_ADDR,
ILL_MED_ADDR, BAD_SHFT_AMT, BAD_STRING, INVALID_NAME};
enum WarnKind {LONG_NAME, MISSING_R, MISSING_NUM, MISSING_RP,
MISSING_COMMA, NAME_DEFINED, BAD_SKIP, ESC_TOO_SHORT,
STR_TOO_SHORT, TEXT_FOLLOWS};
struct SymRec;
typedef SymRec* SymPtr;
struct SymRec
{
string id;
SymPtr left, right;
short patch, loc;
};
// GLOBAL VARIABLES
// ----------------
Word
Inop, Iaop, Isop, Imop, Idop, Fnop, Faop, Fsop, Fmop, Fdop,
Biop, Boop, Baop, Icop, Fcop, Jsrop, Bktop, Ldop, Stoop, Ldaop,
Fltop, Fixop, Jop, Srop, Slop, Rdop, Wrop, Trngop, Haltop;
string Source;
ifstream InFile;
ofstream ListFile;
bool Saved; // Flag for one character lookahead
char Ch; // Current character from the input
vector<Byte> Mem; // Memory Image being created
Word Lc; // Location Counter
ofstream MemFile; // File for the memory image
SymPtr Symbols;
int Line; // Number of the current input line
ErrorKind Error;
bool Errs;
bool Warning;
bool Morewarn;
WarnKind Warns[11];
int Windex;
string Arg,
Memfname,
Srcfname;
const Word BYTE_MASK = 0x00FF;
void WordToBytes(Word w, Byte& hiByte, Byte& loByte)
//
// Converts a word to two bytes.
//
{
loByte = Byte(w & BYTE_MASK);
hiByte = Byte((w >> 8) & BYTE_MASK);
}
void BytesToWord(Byte hiByte, Byte loByte, Word& w)
//
// Converts two bytes to a word.
{
w = (Word(hiByte) << 8) | Word(loByte);
}
void InsertMem(Word w)
//
// Puts one word into memory with the high byte first.
//
{
Byte loByte, hiByte;
WordToBytes(w, hiByte, loByte);
Mem.push_back(hiByte);
Mem.push_back(loByte);
Lc += 2;
}
void CheckTab(SymPtr cur)
//
// Checks for undefined symbols in the symbol table.
//
{
if (cur != NULL)
{
CheckTab(cur->left);
if (cur->loc < 0)
{
Warning = true;
ListFile << " WARNING -- " << cur->id << " Undefined"
<< endl;
cout << " WARNING -- " << cur->id << " Undefined"
<< endl;
}
CheckTab(cur->right);
}
}
void Warn(WarnKind w)
//
// Adds a warning to the list of warnings.
//
{
if (!Morewarn)
Windex = 1;
Morewarn = true;
Warns[Windex] = w;
Windex++;
}
void PrintWarn()
//
// Prints warning messages.
//
{
ListFile << "\n WARNING -- ";
cout << "\n WARNING -- ";
switch (Warns[1])
{
case TEXT_FOLLOWS:
ListFile << "Text follows instruction";
cout << "Text follows instruction";
break;
case ESC_TOO_SHORT:
ListFile <<
"Need 3 digits to specify an unprintable character";
cout << "Need 3 digits to specify an unprintable character";
break;
case STR_TOO_SHORT:
ListFile << "Missing \" in string";
cout << "Missing \" in string";
break;
case BAD_SKIP:
ListFile <<
"Skip value must be positive, skip directive ignored";
cout << "Skip value must be positive, skip directive ignored";
break;
case NAME_DEFINED:
ListFile <<
"Name already defined, earlier definition lost";
cout << "Name already defined, earlier definition lost";
break;
case LONG_NAME:
ListFile << "Name too long, only 7 characters used";
cout << "Name too long, only 7 characters used";
break;
case MISSING_R:
ListFile << "Missing R in Register Address";
cout << "Missing R in Register Address";
break;
case MISSING_NUM:
ListFile <<
"Missing Number in Register Address (0 assumed)";
cout << "Missing Number in Register Address (0 assumed)";
break;
case MISSING_RP:
ListFile << "Missing "" in Indexed Address";
cout << "Missing "" in Indexed Address";
break;
case MISSING_COMMA:
ListFile << "Missing ","";
cout << "Missing ","";
break;
default:;
}
ListFile << " on line " << Line << endl;
cout << " on line " << Line << endl;
for (int i = 2; i < Windex; i++)
Warns[i - 1] = Warns[i];
Windex--;
if (Windex <= 1)
Morewarn = false;
}
void InRegAddr (Word& w, int reg, int hbit)
//
// Insert a register address into a word
//
{
Word mask1 = 0xFFFF,
mask2 = 0xFFFF,
wreg;
wreg = Word(reg);
wreg <<= hbit - 3;
w &= ((mask1 << (hbit+1)) | (mask2 >> (19-hbit)));
w |= wreg;
}
bool Eoln(istream& in)
//
// Returns true iff the next in stream character is a new line
// character.
//
{
return (in.peek() == '\n');
}
void GetCh()
//
// Get a character from the input -- character may have been saved
//
{
if (!Saved)
{
if (InFile.eof())
Ch = '%';
else if (!Eoln(InFile))
{
do
{
InFile.get(Ch);
ListFile << Ch;
} while((Ch == ' ' || Ch == '\t') && !Eoln(InFile));
if (Ch == '%') // skip remainder of line
{
while (!Eoln(InFile))
{
InFile.get(Ch);
ListFile << Ch;
}
Ch = '%';
}
}
else
Ch = '%';
}
else
Saved = false;
}
void ScanName (string& id)
//
// Builds a label.
//
{
id = "";
while (id.length() < 7 && ((Ch >= 'A' && Ch <= 'Z')|| isdigit(Ch)))
{
id += Ch;
GetCh();
}
if ((Ch >= 'A' && Ch <= 'Z') || isdigit(Ch))
{
Warn(LONG_NAME);
while ((Ch >= 'A' && Ch <= 'Z') || isdigit(Ch))
GetCh();
}
Saved = true;
}
SymPtr FindName (const string& id)
//
// Returns a pointer to the symbol table record containing id
// or returns NULL pointer if id is not in the symbol table.
//
{
SymPtr temp;
bool found;
temp = Symbols;
found = false;
while (!found && (temp != NULL))
if (temp->id == id)
found = true;
else if (temp->id > id)
temp = temp->left;
else
temp = temp->right;
return temp;
}
SymPtr InName (const string& id)
//
// Inserts id into the symbol table and returns a pointer
// to its symbol table record.
//
{
SymPtr cur, prev;
cur = Symbols;
prev = NULL;
while (cur != NULL)
{
prev = cur;
if (cur->id > id)
cur = cur->left;
else
cur = cur->right;
}
cur = new SymRec;
cur->left = NULL;
cur->right = NULL;
cur->id = id;
if (prev == NULL)
Symbols = cur;
else if (prev->id > id)
prev->left = cur;
else
prev->right = cur;
return cur;
}
void ScanStr()
//
// Gets a quoted string from the input stream.
//
{
bool one;
int ival;
Byte byte1, byte2;
Word wf;
one = true;
GetCh();
if (Ch == '"')
{
if (!Eoln(InFile))
{
InFile.get(Ch);
ListFile << Ch;
}
while (Ch != '"' && !Eoln(InFile))
{
if (Ch == ':')
{
if (!Eoln(InFile))
{
InFile.get(Ch);
ListFile << Ch;
if (isdigit(Ch))
{
ival = int(Ch) - int('0');
if (!Eoln(InFile))
{
InFile.get(Ch);
ListFile << Ch;
if (isdigit(Ch))
{
ival = ival * 10
+ int(Ch) - int('0');
if (!Eoln(InFile))
{
InFile.get(Ch);
ListFile << Ch;
if (isdigit(Ch))
ival = ival * 10
+ int(Ch) - int('0');
else
Warn(ESC_TOO_SHORT);
}
else
Warn(ESC_TOO_SHORT);
}
else
Warn(ESC_TOO_SHORT);
}
else
Warn(ESC_TOO_SHORT);
Ch = char(ival);
}
}
else
Warn(ESC_TOO_SHORT);
}
if (one)
{
one = false;
byte1 = Byte(Ch);
}
else
{
one = true;
byte2 = Byte(Ch);
BytesToWord(byte1, byte2, wf);
InsertMem(wf);
}
if (!Eoln(InFile))
{
InFile.get(Ch);
ListFile << Ch;
}
}
if (one)
byte1 = Byte(0);
else
byte2 = Byte(0);
BytesToWord(byte1, byte2, wf);
InsertMem(wf);
if (Ch != '"')
Warn(STR_TOO_SHORT);
}
else
Error = BAD_STR;
}
void ScanReal (Word& w1, Word& w2)
//
// Gets a real number from the input stream.
//
{
union FloatRec
{
Byte b[4];
float rf;
};
FloatRec real;
float dval = 10.0f, rf = 0.0f;
bool neg = false;
real.rf = 0.0;
GetCh();
if (Ch == '-' || Ch == '+')
{
if (Ch == '-') neg = true;
GetCh();
}
while (isdigit(Ch))
{
real.rf = real.rf * 10 + int(Ch) - int('0');
GetCh();
}
if (Ch == '.')
{
GetCh();
while (isdigit(Ch))
{
real.rf = real.rf + (int(Ch) - int('0')) / dval;
dval = dval * 10.0f;
GetCh();
}
}
else
Saved = true;
if (neg) real.rf = -real.rf;
BytesToWord(real.b[3], real.b[2], w1);
BytesToWord(real.b[1], real.b[0], w2);
}
void ScanInt (Word& w)
//
// Gets an integer from the input stream.
//
{
int temp;
bool neg;
neg = false;
temp = 0;
GetCh();
if (Ch == '-' || Ch == '+')
{
if (Ch == '-')
neg = true;
GetCh();
}
while (isdigit(Ch))
{
temp = temp * 10 + int(Ch) - int('0');
GetCh();
}
Saved = true; // Note the lookahead.
if (neg)
temp = -temp;
if (temp > MAXINT || temp < -MAXINT-1)
Error = BAD_INTEGER;
else
w = Word(temp);
}
int GetRegAddr()
//
// Get a register address from the input stream.
//
{
int temp;
GetCh();
if (Ch == 'R')
GetCh();
else
Warn(MISSING_R);
if (isdigit(Ch))
{
temp = int(Ch) - int('0');
GetCh();
if (isdigit(Ch)) // check for two digits
temp = temp * 10 + int(Ch) - int('0');
else
Saved = true;
if (temp > 15)
Error = BAD_REG_ADDR;
}
else
Warn(MISSING_NUM);
return temp;
}
void GetGenAddr(OpKind op, Word& w1, Word& w2, bool& flag)
//
// Sets an addressing mode.
//
{
int reg;
string id;
SymPtr idrec;
flag = false;
GetCh();
if (Ch == '*')
{
w1 = w1 | 0x0040; // [6]
GetCh();
}
if (Ch >= 'A' && Ch <= 'Z' && Ch != 'R')
{
flag = true;
ScanName(id);
idrec = FindName(id);
if (idrec == NULL)
{
idrec = InName(id);
idrec->loc = -1;
idrec->patch = Lc + 2;
w2 = Word(-1);
}
else if (idrec->loc == -1)
{
w2 = Word(idrec->patch);
idrec->patch = Lc + 2;
}
else
w2 = Word(idrec->loc);
GetCh();
if (Ch == '(')
{
w1 = w1 | 0x0020; // [5]
reg = GetRegAddr();
if (Error == NO_ERROR)
{
InRegAddr(w1, reg, 3);
GetCh();
if (Ch != ')')
Warn(MISSING_RP);
}
}
else // Ch != ')'
w1 = w1 | 0x0010; // [4]
}
else if (isdigit(Ch))
{
Saved = true;
w1 = w1 | 0x0010; // [4]
flag = true;
ScanInt(w2);
}
else
switch (Ch)
{
case 'R': // direct register
flag = false;
Saved = true;
reg = GetRegAddr();
InRegAddr(w1, reg, 3);
if ((op == JSR || op == BKT || op == LDA || op == J)
&& !(w1 & 0x0040))
Error = ILL_REG_ADDR;
break;
case '#': // immediate
flag = true;
if (w1 & 0x0040)
Error = BAD_GEN_ADDR;
else if (op == FN || op == FA || op == FS|| op == FM
|| op == FD || op == FC || op == FIX
|| op == JSR || op == BKT || op == STO
|| op == J || op == RD || op == TRNG)
Error = ILL_MED_ADDR;
else if (w1 == (Wrop | 0x0080))
Error = ILL_MED_ADDR;
else if (w1 == (Wrop | 0x0480))
Error = ILL_MED_ADDR;
else
{
w1 = w1 | 0x0030; // [4, 5]
ScanInt(w2);
}
break;
case '-': case '+': // indexed
w1 = w1 | 0x0020; // [5]
flag = true;
if (Ch == '-')
Saved = true;
ScanInt(w2);
GetCh();
if (Ch == '(')
{
reg = GetRegAddr();
if (Error == NO_ERROR)
{
InRegAddr(w1, reg, 3);
GetCh();
if (Ch != ')')
Warn(MISSING_RP);
}
}
else // Ch != '('
Error = BAD_GEN_ADDR;
break;
case '&':
flag = true;
if (w1 & 0x0040) // [6]
Error = BAD_GEN_ADDR;
else
{
w1 = w1 | 0x0070; // [4, 5, 6]
ScanInt(w2);
}
break;
default:
Error = BAD_GEN_ADDR;
}
}
void GetBop (OpKind& op, Word& wd)
//
// Get an operator or directive name that begins with 'B'.
//
{
GetCh();
switch (Ch)
{
case 'A':
op = BA;
wd = Baop;
break;
case 'I':
op = BI;
wd = Biop;
break;
case 'K':
GetCh();
if (Ch == 'T')
{
op = BKT;
wd = Bktop;
}
else
Error = UNKNOWN_OP_NAME;
break;
case 'O':
op = BO;
wd = Boop;
break;
default:
// character does not legally follow `B'
Error = UNKNOWN_OP_NAME;
}
}
void GetFop (OpKind& op, Word& wd)
//
// Get an operator or directive name that begins with 'F'.
//
{
GetCh();
switch (Ch)
{
case 'A':
op = FA;
wd = Faop;
break;
case 'C':
op = FC;
wd = Fcop;
break;
case 'D':
op = FD;
wd = Fdop;
break;
case 'I':
GetCh();
if (Ch == 'X')
{
op = FIX;
wd = Fixop;
}
else
Error = UNKNOWN_OP_NAME;
break;
case 'L':
GetCh();
if (Ch == 'T')
{
op = FLT;
wd = Fltop;
}
else
Error = UNKNOWN_OP_NAME;
break;
case 'M':
op = FM;
wd = Fmop;
break;
case 'N':
op = FN;
wd = Fnop;
break;
case 'S':
op = FS;
wd = Fsop;
break;
default: // character does not legally follow `F'
Error = UNKNOWN_OP_NAME;
}
}
void GetIop (OpKind& op, Word& wd)
//
// Get an operator or directive name that begins with 'I'.
//
{
GetCh();
switch (Ch)
{
case 'A':
op = IA;
wd = Iaop;
break;
case 'C':
op = IC;
wd = Icop;
break;
case 'D':
op = IDENT;
wd = Idop;
break;
case 'M':
op = IM;
wd = Imop;
break;
case 'N':
GetCh();
if (Ch == 'T')
op = INTDIR;
else
{
op = OIN;
wd = Inop;
Saved = true;
}
break;
case 'S':
op = IS;
wd = Isop;
break;
default:
// character does not legally follow `I'
Error = UNKNOWN_OP_NAME;
}
}
void GetJop (OpKind& op, Word& wd)
//
// Get an operator or directive name that begins with 'J'.
//
{
GetCh();
op = J; // most are simple jumps--except JSR!!
switch (Ch)
{
case 'E':
GetCh();
if (Ch == 'Q')
wd = Jop | 0x0180; // [7, 8]
else
Error = UNKNOWN_OP_NAME;
break;
case 'G':
GetCh();
if (Ch == 'E')
wd = Jop | 0x0280; // [7, 9]
else if (Ch == 'T')
wd = Jop | 0x0300; // [8, 9]
else
Error = UNKNOWN_OP_NAME;
break;
case 'L':
GetCh();
if (Ch == 'E')
wd = Jop | 0x0100; // [8]
else if (Ch == 'T')
wd = Jop | 0x0080; // [7]
else
Error = UNKNOWN_OP_NAME;
break;
case 'M':
GetCh();
if (Ch == 'P')
wd = Jop;
else
Error = UNKNOWN_OP_NAME;
break;
case 'N':
GetCh();
if (Ch == 'E')
wd = Jop | 0x0200; // [9]
else
Error = UNKNOWN_OP_NAME;
break;
case 'S':
GetCh();
if (Ch == 'R')
{
op = JSR;
wd = Jsrop;
}
else
Error = UNKNOWN_OP_NAME;
break;
default:
//Ch not in ['E','G',...] }
Error = UNKNOWN_OP_NAME;
}
}
void GetLop(OpKind& op, Word& wd)
//
// Get an operator or directive name that begins with 'L'.
//
{
GetCh();
switch (Ch)
{
case 'A':
GetCh();
if (Ch == 'B')
{
GetCh();
if (Ch == 'E')
{
GetCh();
if (Ch == 'L')
op = LABELDIR;
else
Error = UNKNOWN_OP_NAME;
}
else
Error = UNKNOWN_OP_NAME;
}
else
Error = UNKNOWN_OP_NAME;
break;
case 'D':
GetCh();
if (Ch == 'A')
{
op = LDA;
wd = Ldaop;
}
else
{
op = LD;
wd = Ldop;
Saved = true;
}
break;
default:
Error = UNKNOWN_OP_NAME;
}
}
void GetRop (OpKind& op, Word& wd)
//
// Get an operator or directive name that begins with 'R'.
//
{
GetCh();
if (Ch == 'D')
{
op = RD;
GetCh();
switch (Ch)
{
case 'B':
GetCh();
if (Ch == 'D')
wd = Rdop | 0x0100; // [8]
else if (Ch == 'W')
wd = Rdop | 0x0180; // [7, 8]
else
Error = UNKNOWN_OP_NAME;
break;
case 'C':
GetCh();
if (Ch == 'H')
wd = Rdop | 0x0400; // [10]
else
Error = UNKNOWN_OP_NAME;
break;
case 'F':
wd = Rdop | 0x0080; // [7]
break;
case 'H':
GetCh();
if (Ch == 'D')
wd = Rdop | 0x0300; // [8, 9]
else if (Ch == 'W')
wd = Rdop | 0x0380; // [7, 8, 9]
else
Error = UNKNOWN_OP_NAME;
break;
case 'I':
wd = Rdop;
break;
case 'N':
GetCh();
if (Ch == 'L')
wd = Rdop | 0x0580; // [7, 8, 10]
else
Error = UNKNOWN_OP_NAME;
break;
case 'O':
GetCh();
if (Ch == 'D')
wd = Rdop | 0x0200; // [9]
else if (Ch == 'W')
wd = Rdop | 0x0280; // [7, 10]
else
Error = UNKNOWN_OP_NAME;
break;
case 'S':
GetCh();
if (Ch == 'T')
wd = Rdop | 0x0480; // [7, 10]
else
Error = UNKNOWN_OP_NAME;
break;
default:
// Ch not in ['B','C',...] }
Error = UNKNOWN_OP_NAME;
}
}
else if (Ch == 'E')
{
GetCh();
if (Ch == 'A')
{
GetCh();
if (Ch == 'L')
op = REALDIR;
else
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'A'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'E'
Error = UNKNOWN_OP_NAME;
}
void GetSop (OpKind& op, Word& wd)
//
// Get an operator or directive name that begins with 'S'.
//
{
GetCh();
switch (Ch)
{
case 'K':
GetCh();
if (Ch == 'I')
{
GetCh();
if (Ch == 'P')
op = SKIPDIR;
else
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'I'
Error = UNKNOWN_OP_NAME;
break;
case 'L':
GetCh();
op = SL;
switch (Ch)
{
case 'D':
GetCh();
op = SLD;
switch (Ch)
{
case 'C':
wd = Slop | 0x0070; // [4, 5, 6]
break;
case 'E':
wd = Slop | 0x0060; // [5, 6]
break;
case 'O':
wd = Slop | 0x0050; // [4, 6]
break;
case 'Z':
wd = Slop | 0x0040; // [6]
break;
default:
Error = UNKNOWN_OP_NAME;
}
break;
case 'C':
wd = Slop | 0x0030; // [4, 5]
break;
case 'E':
wd = Slop | 0x0020; // [5]
break;
case 'O':
wd = Slop | 0x0010; // [4]
break;
case 'Z':
wd = Slop;
break;
default:
Error = UNKNOWN_OP_NAME;
}
break;
case 'R':
GetCh();
op = SR;
switch (Ch)
{
case 'D':
GetCh();
op = SRD;
switch (Ch)
{
case 'C':
wd = Srop | 0x0070; // [4, 5, 6]
break;
case 'E':
wd = Srop | 0x0060; // [5, 6]
break;
case 'O':
wd = Srop | 0x0050; // [4, 6]
break;
case 'Z':
wd = Srop | 0x0040; // [6]
break;
default:
Error = UNKNOWN_OP_NAME;
}
break;
case 'C':
wd = Srop | 0x0030; // [4, 5]
break;
case 'E':
wd = Srop | 0x0020; // [5]
break;
case 'O':
wd = Srop | 0x0010; // [4]
break;
case 'Z':
wd = Srop;
break;
default:
Error = UNKNOWN_OP_NAME;
}
break;
case 'T':
GetCh();
if (Ch == 'O')
{
op = STO;
wd = Stoop;
}
else if (Ch == 'R')
{
GetCh();
if (Ch == 'I')
{
GetCh();
if (Ch == 'N')
{
GetCh();
if (Ch == 'G')
op = STRINGDIR;
else
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'N'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'I'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'R'
Error = UNKNOWN_OP_NAME;
break;
default:
Error = UNKNOWN_OP_NAME;
}
}
void GetWop (OpKind& op, Word& wd)
//
// Get an operator or directive name that begins with 'W'.
//
{
GetCh();
if (Ch == 'R')
{
op = WR;
GetCh();
switch (Ch)
{
case 'B':
GetCh();
if (Ch == 'D')
wd = Wrop | 0x0100; // WRBD
else if (Ch == 'W')
wd = Wrop | 0x0180; // WRBW
else
Error = UNKNOWN_OP_NAME;
break;
case 'C':
GetCh();
if (Ch == 'H')
wd = Wrop | 0x0400; // WRCH
else
Error = UNKNOWN_OP_NAME;
break;;
case 'F':
wd = Wrop | 0x0080; // WRF
break;
case 'H':
GetCh();
if (Ch == 'D')
wd = Wrop | 0x0300; // WRHD
else if (Ch == 'W')
wd = Wrop | 0x0380; // WRHW
else
Error = UNKNOWN_OP_NAME;
break;
case 'I': // WRI
wd = Wrop;
break;
case 'N':
GetCh();
if (Ch == 'L')
wd = Wrop | 0x0580; // WRNL
else
Error = UNKNOWN_OP_NAME;
break;
case 'O':
GetCh();
if (Ch == 'D')
wd = Wrop | 0x0200; // WROD
else if (Ch == 'W')
wd = Wrop | 0x0280; // WROW
else
Error = UNKNOWN_OP_NAME;
break;
case 'S':
GetCh();
if (Ch == 'T')
wd = Wrop | 0x0480; // WRST
else
Error = UNKNOWN_OP_NAME;
break;
default:
Error = UNKNOWN_OP_NAME;
}
}
else // Ch != 'R'
Error = UNKNOWN_OP_NAME;
}
void ProLine()
//
// Process the current line of input.
//
{
Word wd = 0, wd2;
Byte b1, b2;
OpKind op;
int reg;
bool twowds;
short i1, i2;
string id;
SymPtr idrec;
twowds = false;
Error = NO_ERROR;
switch (Ch)
{
case 'B':
GetBop(op, wd);
break;
case 'C':
GetCh();
if (Ch == 'L')
{
GetCh();
if (Ch == 'R')
{
op = CLR;
wd = Srop;
}
else // Ch != 'R'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'L'
Error = UNKNOWN_OP_NAME;
break;
case 'F':
GetFop(op, wd);
break;
case 'H':
GetCh();
if (Ch == 'A')
{
GetCh();
if (Ch == 'L')
{
GetCh();
if (Ch == 'T')
{
op = HALT;
wd = Haltop;
}
else // Ch != 'T'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'L'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'A'
Error = UNKNOWN_OP_NAME;
break;
case 'I':
GetIop(op, wd);
break;
case 'J':
GetJop(op, wd);
break;
case 'L':
GetLop(op, wd);
break;
case 'N':
GetCh();
if (Ch == 'O')
{
GetCh();
if (Ch == 'P')
{
op = NOP;
wd = Jop | 0x0380; // [7, 8, 9]
}
else // Ch != 'P'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'O'
Error = UNKNOWN_OP_NAME;
break;
case 'R':
GetRop(op, wd);
break;
case 'S':
GetSop(op, wd);
break;
case 'T':
GetCh();
if (Ch == 'R')
{
GetCh();
if (Ch == 'N')
{
GetCh();
if (Ch == 'G')
{
op = TRNG;
wd = Trngop;
}
else // Ch != 'G'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'N'
Error = UNKNOWN_OP_NAME;
}
else // Ch != 'R'
Error = UNKNOWN_OP_NAME;
break;
case 'W':
GetWop(op, wd);
break;
default:
Error = UNKNOWN_OP_NAME;
}
if (Error == NO_ERROR)
{
switch (op)
{
case CLR:
// need to find a reg address }
reg = GetRegAddr();
if (Error == NO_ERROR)
{
InRegAddr(wd, reg, 10);
InsertMem (wd);
}
break;
case SL:
case SR:
case SLD:
case SRD:
reg = GetRegAddr();
if (Error == NO_ERROR)
InRegAddr(wd, reg, 10);
GetCh();
if (Ch != ',')
{
Warn(MISSING_COMMA);
Saved = true;
}
ScanInt(wd2);
if (Error == NO_ERROR)
{
reg = short(wd2) ;
if (reg == 16)
reg = 0;
if ((reg < 16) && (reg >= 0))
{
InRegAddr(wd, reg, 3);
InsertMem (wd);
}
else
Error = BAD_SHFT_AMT;
}
break;
case OIN:
case IA:
case IS:
case IM:
case IDENT:
case FN:
case FA:
case FS:
case FM:
case FD:
case BI:
case BO:
case BA:
case IC:
case FC:
case JSR:
case BKT:
case LD:
case STO:
case LDA:
case FLT:
case FIX:
case TRNG:
reg = GetRegAddr();
if (Error == NO_ERROR)
{
InRegAddr(wd, reg, 10);
GetCh();
if (Ch != ',')
{
Warn(MISSING_COMMA);
Saved = true;
}
GetGenAddr(op, wd, wd2, twowds);
if (Error == NO_ERROR)
if (twowds)
{
InsertMem (wd);
InsertMem (wd2);
}
else
InsertMem (wd);
}
break;
case J:
GetGenAddr(op, wd, wd2, twowds);
if (Error == NO_ERROR)
if (twowds)
{
InsertMem (wd);
InsertMem (wd2);
}
else
InsertMem (wd);
break;
case RD:
case WR:
twowds = false;
if (!((0x0400 & wd)&&(0x0100 & wd)))
GetGenAddr(op, wd, wd2, twowds);
if (Error == NO_ERROR)
if (twowds)
{
InsertMem (wd);
InsertMem (wd2);
}
else
InsertMem (wd);
break;
case NOP:
case HALT:
InsertMem(wd);
break;
case INTDIR:
ScanInt(wd);
InsertMem(wd);
break;
case REALDIR:
ScanReal(wd, wd2);
InsertMem(wd);
InsertMem(wd2);
break;
case SKIPDIR:
ScanInt(wd);
i1 = int(wd);
if (i1 < 0)
Warn(BAD_SKIP);
else
{
Lc = Lc + i1;
for (int i = 1; i <= i1; i++)
Mem.push_back(Byte(0));
}
break;
case STRINGDIR:
ScanStr();
break;
case LABELDIR:
GetCh();
if ((Ch >= 'A' && Ch <= 'Q') || (Ch >= 'S' && Ch <= 'Z'))
{
ScanName(id);
idrec = FindName(id);
if (idrec == NULL)
idrec = InName(id);
else
{
if (idrec->loc >= 0)
Warn(NAME_DEFINED);
i1 = idrec->patch;
wd = Word(Lc);
WordToBytes(wd, b1, b2);
while (i1 >= 0)
{
BytesToWord(Mem[i1], Mem[i1+1], wd);
i2 = int(wd);
Mem[i1] = b1;
Mem[i1+1] = b2;
i1 = i2;
}
}
idrec->patch = -1;
idrec->loc = Lc;
}
else
Error = INVALID_NAME;
}
} // if Error = NO_ERROR
}
void InitOpcodes()
//
// Initalize all the opcodes.0
//
{
Inop = 0x0000; // 00000
Iaop = 0x0800; // 00001
Isop = 0x1000; // 00010
Imop = 0x1800; // 00011
Idop = 0x2000; // 00100
Fnop = 0x2800; // 00101
Faop = 0x3000; // 00110
Fsop = 0x3800; // 00111
Fmop = 0x4000; // 01000
Fdop = 0x4800; // 01001
Biop = 0x5000; // 01010
Boop = 0x5800; // 01011
Baop = 0x6000; // 01100
Icop = 0x6800; // 01101
Fcop = 0x7000; // 01110
Jsrop = 0x7800; // 01111
Bktop = 0x8000; // 10000
Ldop = 0x8800; // 10001
Stoop = 0x9000; // 10010
Ldaop = 0x9800; // 10011
Fltop = 0xA000; // 10100
Fixop = 0xA800; // 10101
Jop = 0xB000; // 10110
Srop = 0xB800; // 10111
Slop = 0xC000; // 11000
Rdop = 0xC800; // 11001
Wrop = 0xD000; // 11010
Trngop = 0xD800; // 11011
Haltop = 0xF800; // 11111
}
//---------------------------------------------------------------------
string Date()
{
const string MONTH[] =
{ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
"December" };
/*
char theDate[10];
int moNumber;
_strdate_s(theDate);
string strDate(theDate, theDate+8);
moNumber = 10 * (theDate[0] - '0') + theDate[1] - '0' - 1;
return MONTH[moNumber] + ' '
+ ((strDate[3] == '0') ? strDate.substr(4,1)
: strDate.substr(3,2))
+ ", 20" + strDate.substr(6,3);
*/
time_t now = time(0);
tm *ltm = localtime(&now);
return MONTH[ltm->tm_mon] + " " +
static_cast<ostringstream*>(
&(ostringstream() << ltm->tm_mday) )->str()
+ ", " +
static_cast<ostringstream*>(
&(ostringstream() << 1900 + ltm->tm_year) )->str();
}
string Time()
{
const string HOUR[]
= { "12", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "10", "11" };
int hrNumber;
string suffix;
string pad = "";
time_t now = time(0);
tm *ltm = localtime(&now);
hrNumber = ltm->tm_hour;
if (ltm->tm_hour < 12)
suffix = " A.M.";
else
{
suffix = " P.M.";
hrNumber -= 12;
}
if ( ltm->tm_min < 10)
pad = "0";
return HOUR[hrNumber] + ':' + pad +
static_cast<ostringstream*>(
&(ostringstream() << ltm->tm_min) )->str()
+ suffix;
}
int main(int argc, char *argv[])
{
cout << "SAM 2016 ASSEMBLER\n" << endl;
if (argc > 1) {
if (strcmp(argv[1], "help") == 0) {
cout << "Usage: ./sam [sourceFile]\n ./sam help";
} else {
Source = argv[1];
Source = Source.substr(0, Source.find(".asm"));
cout << "SAM source file name: " << Source << ".asm" << endl;
}
} else {
cout << "SAM source file name: ";
getline(cin, Source);
}
InFile.open((Source + ".asm").data());
if(!InFile.is_open())
{
cout << "\nFile \"" << Source + ".asm" << "\" not found!"
<< "\nAssembly aborted.\n" << endl;
cin.get();
exit(1);
}
ListFile.open((Source+".lis").data());
ListFile << endl;
ListFile << " SAM 2016 Assembler Listing\n" << endl;
ListFile << " " + Date() << " at " << Time() << endl;
ListFile << " SOURCE FILE: " + Source + ".asm" << endl;
Symbols = NULL;
InitOpcodes();
Line = 0;
Lc = 0;
Errs = false;
Warning = false;
Saved = false;
InFile.peek();
if (!InFile.eof())
{
ListFile << endl;
ListFile << setw(10) << "LN" << setw(6) << "LC" << endl;
ListFile << setw(10) << Line
<< setw(6) << hex << uppercase << Lc
<< dec << ": ";
}
else
{
InFile.close();
ListFile.close();
cout << "\nFile is empty.\n" << endl;
exit(1);
}
InFile.peek();
while (!InFile.eof())
{
GetCh();
InFile.peek();
while (!InFile.eof() && (Ch == '%'))
{
InFile.ignore(256, '\n');
InFile.peek();
if (!InFile.eof())
{
ListFile << endl << flush;
ListFile << setw(10) << ++Line
<< setw(6) << hex << uppercase << Lc
<< dec << ": ";
GetCh();
}
}
if (Eoln(InFile)){//skip over blank lines in input file
GetCh();
continue;
}
if (!InFile.eof())
{ // instruction processing
Error = NO_ERROR;
Morewarn = false;
ProLine();
GetCh();
if (Ch != '%' && !isspace(Ch))
{ // skip text after instruction
Warn(TEXT_FOLLOWS);
do
{
InFile.get(Ch);
ListFile << Ch;
} while (Ch != '\n');
}
if (Error != NO_ERROR)
{
ListFile << endl;
Errs = true;
ListFile << " ERROR -- ";
switch (Error)
{
case INVALID_NAME:
ListFile <<
"Invalid Name in Label Directive";
break;
case UNKNOWN_OP_NAME:
ListFile <<
"Unknown Operation or Directive Name";
break;
case BAD_STR:
ListFile <<
"Improper String Directive -- Missing \"";
break;
case BAD_GEN_ADDR:
ListFile <<
"Improperly Formed General Address";
break;
case BAD_REG_ADDR:
ListFile <<
"Register Address Out of Range";
break;
case BAD_INTEGER:
ListFile <<
"Improperly Formed Integer Constant";
break;
case BAD_REAL:
ListFile <<
"Improperly Formed Real Constant";
break;
case BAD_STRING:
ListFile <<
"Improperly Formed String Constant";
break;
case BAD_NAME:
ListFile <<
"Improperly Formed Name";
break;
case ILL_REG_ADDR:
ListFile <<
"Direct Register Address not Permitted";
break;
case ILL_MED_ADDR:
ListFile <<
"Immediate Address not Permitted";
break;
case BAD_SHFT_AMT:
ListFile <<
"Shift Amount not in Range";
break;
default:;
}
ListFile << " detected on line " << Line << endl;
}
while (Morewarn)
PrintWarn();
}
}
ListFile << endl << endl;
CheckTab(Symbols);
if (!Errs && !Warning)
{
MemFile.open((Source+".obj").data(), ios_base::binary);
ListFile << "\nMACC Memory Hexadecimal Dump\n" << endl;
ListFile << " ADDR |";
for (int i = 0; i < 16; i++) ListFile << setw(4) << hex << i;
ListFile << endl;
ListFile << "------+";
for (int i = 0; i < 16; i++) ListFile << "----";
for (int i = 0; i < Lc; i++)
{
MemFile.put(Mem[i]);
if (i % 16 == 0) ListFile << endl << setw(5) << i << " |";
ListFile << " ";
if (Mem[i] < 16) ListFile << "0";
ListFile << hex << short(Mem[i]);
}
ListFile << endl << endl;
MemFile.close();
cout << " SUCCESSFUL ASSEMBLY." << endl;
cout << " OBJECT CODE FILE: "+ Source + ".obj" << endl;
}
else
{
cout << " ERRORS/WARNINGS IN ASSEMBLY CODE." << endl;
cout << " NO OBJECT CODE FILE WAS GENERATED." << endl;
ListFile.close();
InFile.close();
exit(1);
}
ListFile.close();
InFile.close();
//cin.ignore(256, '\n');
//cin.get(); // wait for Enter
return 0;
}
| 17.165441 | 79 | 0.504207 | leandrohga |
23a4241af81aa23c0da2f9375699cb1983670347 | 1,153 | cpp | C++ | src/RuleTimer.cpp | d3wy/pool-controller | 182d8c67638abf56d8e5126103b5995006c06b42 | [
"MIT"
] | 12 | 2020-03-04T18:43:43.000Z | 2022-01-30T22:59:27.000Z | src/RuleTimer.cpp | d3wy/pool-controller | 182d8c67638abf56d8e5126103b5995006c06b42 | [
"MIT"
] | 17 | 2019-05-20T20:22:09.000Z | 2022-01-11T16:55:26.000Z | src/RuleTimer.cpp | d3wy/pool-controller | 182d8c67638abf56d8e5126103b5995006c06b42 | [
"MIT"
] | 6 | 2020-06-05T18:17:13.000Z | 2022-03-19T20:13:58.000Z |
#include "RuleTimer.hpp"
/**
*
*/
RuleTimer::RuleTimer(RelayModuleNode* solarRelay, RelayModuleNode* poolRelay) {
_solarRelay = solarRelay;
_poolRelay = poolRelay;
}
/**
*
*/
void RuleTimer::loop() {
Homie.getLogger() << cIndent << F("§ RuleTimer: loop") << endl;
_poolRelay->setSwitch(checkPoolPumpTimer());
if (_solarRelay->getSwitch()) {
_solarRelay->setSwitch(false);
}
}
/**
*
*/
bool RuleTimer::checkPoolPumpTimer() {
Homie.getLogger() << F("↕ checkPoolPumpTimer") << endl;
tm time = getCurrentDateTime();
bool retval;
tm startTime = getStartTime(getTimerSetting());
tm endTime = getEndTime(getTimerSetting());
Homie.getLogger() << cIndent << F("time= ") << asctime(&time);
Homie.getLogger() << cIndent << F("startTime= ") << asctime(&startTime);
Homie.getLogger() << cIndent << F("endTime= ") << asctime(&endTime);
if (difftime(mktime(&time), mktime(&startTime)) >= 0
&& difftime(mktime(&time), mktime(&endTime)) <= 0) {
retval = true;
} else {
retval = false;
}
Homie.getLogger() << cIndent << F("checkPoolPumpTimer = ") << retval << endl;
return retval;
}
| 20.589286 | 79 | 0.626193 | d3wy |
23ae7e5ac53ac779985446beb4d8c74dbbeccd09 | 572 | cpp | C++ | Source/Musa/GameObject/DemoGameObjects/OrbitingObject.cpp | frobro98/Musa | 6e7dcd5d828ca123ce8f43d531948a6486428a3d | [
"MIT"
] | null | null | null | Source/Musa/GameObject/DemoGameObjects/OrbitingObject.cpp | frobro98/Musa | 6e7dcd5d828ca123ce8f43d531948a6486428a3d | [
"MIT"
] | null | null | null | Source/Musa/GameObject/DemoGameObjects/OrbitingObject.cpp | frobro98/Musa | 6e7dcd5d828ca123ce8f43d531948a6486428a3d | [
"MIT"
] | null | null | null | #include "OrbitingObject.hpp"
#include "Math/Matrix4.hpp"
#include "Math/Quat.hpp"
OrbitingObject::OrbitingObject(const Vector4& orbitAxis, const Vector4& orbitPos)
: axis(orbitAxis),
orbitLocation(orbitPos)
{
}
void OrbitingObject::Update(float /*tick*/)
{
// constexpr float angleOffsetDeg = .005f;
// Matrix4 trans(TRANS, orbitLocation);
// Quat rot(ROT_AXIS_ANGLE, axis, angleOffsetDeg * tick);
// Matrix4 negTrans(TRANS, -orbitLocation);
//
// Matrix4 orbitTrans = negTrans * rot * trans;
//
// position *= orbitTrans;
//
// GameObject::Update(tick);
}
| 23.833333 | 81 | 0.713287 | frobro98 |
23b6267156ba30d4212a91e8925ca4c296c927a0 | 5,285 | hpp | C++ | packages/monte_carlo/estimator/native/src/MonteCarlo_CellPulseHeightEstimator.hpp | lkersting/SCR-2123 | 06ae3d92998664a520dc6a271809a5aeffe18f72 | [
"BSD-3-Clause"
] | null | null | null | packages/monte_carlo/estimator/native/src/MonteCarlo_CellPulseHeightEstimator.hpp | lkersting/SCR-2123 | 06ae3d92998664a520dc6a271809a5aeffe18f72 | [
"BSD-3-Clause"
] | null | null | null | packages/monte_carlo/estimator/native/src/MonteCarlo_CellPulseHeightEstimator.hpp | lkersting/SCR-2123 | 06ae3d92998664a520dc6a271809a5aeffe18f72 | [
"BSD-3-Clause"
] | null | null | null | //---------------------------------------------------------------------------//
//!
//! \file MonteCarlo_CellPulseHeightEstimator.hpp
//! \author Alex Robinson
//! \brief Cell pulse height estimator class declaration
//!
//---------------------------------------------------------------------------//
#ifndef FACEMC_CELL_PULSE_HEIGHT_ESTIMATOR_HPP
#define FACEMC_CELL_PULSE_HEIGHT_ESTIMATOR_HPP
// Boost Includes
#include <boost/unordered_set.hpp>
#include <boost/mpl/vector.hpp>
// FRENSIE Includes
#include "MonteCarlo_EntityEstimator.hpp"
#include "MonteCarlo_EstimatorContributionMultiplierPolicy.hpp"
#include "MonteCarlo_ParticleEnteringCellEventObserver.hpp"
#include "MonteCarlo_ParticleLeavingCellEventObserver.hpp"
#include "Geometry_ModuleTraits.hpp"
namespace MonteCarlo{
/*! The pulse height entity estimator class
* \details This class has been set up to get correct results with multiple
* threads. However, the commitHistoryContribution member function call
* should only appear within an omp critical block. Use the enable thread
* support member function to set up an instance of this class for the
* requested number of threads. The classes default initialization is for
* a single thread.
*/
template<typename ContributionMultiplierPolicy = WeightMultiplier>
class CellPulseHeightEstimator : public EntityEstimator<Geometry::ModuleTraits::InternalCellHandle>,
public ParticleEnteringCellEventObserver,
public ParticleLeavingCellEventObserver
{
private:
// Typedef for the serial update tracker
typedef boost::unordered_map<Geometry::ModuleTraits::InternalCellHandle,
double>
SerialUpdateTracker;
// Typedef for the parallel update tracker
typedef Teuchos::Array<SerialUpdateTracker>
ParallelUpdateTracker;
public:
//! Typedef for the cell id type
typedef Geometry::ModuleTraits::InternalCellHandle cellIdType;
//! Typedef for event tags used for quick dispatcher registering
typedef boost::mpl::vector<ParticleEnteringCellEventObserver::EventTag,
ParticleLeavingCellEventObserver::EventTag>
EventTags;
//! Constructor
CellPulseHeightEstimator( const Estimator::idType id,
const double multiplier,
const Teuchos::Array<cellIdType>& entity_ids );
//! Destructor
~CellPulseHeightEstimator()
{ /* ... */ }
//! Set the response functions
void setResponseFunctions(
const Teuchos::Array<Teuchos::RCP<ResponseFunction> >& response_functions );
//! Set the particle types that can contribute to the estimator
void setParticleTypes( const Teuchos::Array<ParticleType>& particle_types );
//! Add current history estimator contribution
void updateFromParticleEnteringCellEvent( const ParticleState& particle,
const cellIdType cell_entering );
//! Add current history estimator contribution
void updateFromParticleLeavingCellEvent( const ParticleState& particle,
const cellIdType cell_leaving );
//! Commit the contribution from the current history to the estimator
void commitHistoryContribution();
//! Print the estimator data
void print( std::ostream& os ) const;
//! Enable support for multiple threads
void enableThreadSupport( const unsigned num_threads );
//! Reset the estimator data
void resetData();
//! Export the estimator data
void exportData( EstimatorHDF5FileHandler& hdf5_file,
const bool process_data ) const;
private:
// Assign bin boundaries to an estimator dimension
void assignBinBoundaries(
const Teuchos::RCP<EstimatorDimensionDiscretization>& bin_boundaries );
// Calculate the estimator contribution from the entire history
double calculateHistoryContribution( const double energy_deposition,
WeightMultiplier );
// Calculate the estimator contribution from the entire history
double calculateHistoryContribution( const double energy_deposition,
WeightAndEnergyMultiplier );
// Add info to update tracker
void addInfoToUpdateTracker( const unsigned thread_id,
const cellIdType cell_id,
const double contribution );
// Get the entity iterators from the update tracker
void getCellIteratorFromUpdateTracker(
const unsigned thread_id,
typename SerialUpdateTracker::const_iterator& start_cell,
typename SerialUpdateTracker::const_iterator& end_cell ) const;
// Reset the update tracker
void resetUpdateTracker( const unsigned thread_id );
// The entities that have been updated
ParallelUpdateTracker d_update_tracker;
// The generic particle state map (avoids having to make a new map for cont.)
Teuchos::Array<Estimator::DimensionValueMap> d_dimension_values;
};
} // end MonteCarlo namespace
//---------------------------------------------------------------------------//
// Template Includes
//---------------------------------------------------------------------------//
#include "MonteCarlo_CellPulseHeightEstimator_def.hpp"
//---------------------------------------------------------------------------//
#endif // end FACEMC_CELL_PULSE_HEIGHT_ESTIMATOR_HPP
//---------------------------------------------------------------------------//
// end MonteCarlo_CellPulseHeightEstimator.hpp
//---------------------------------------------------------------------------//
| 35.233333 | 101 | 0.693661 | lkersting |
23b6b5a280f6b6b9fc6621a21ebcdf8dd9977483 | 5,206 | cpp | C++ | src/formats/RareSnesInstr.cpp | ValleyBell/vgmtrans | fc7ad99857450d3a943d8201a05331837e5db938 | [
"Zlib"
] | 2 | 2021-01-18T05:47:48.000Z | 2022-03-15T18:27:41.000Z | src/formats/RareSnesInstr.cpp | ValleyBell/vgmtrans | fc7ad99857450d3a943d8201a05331837e5db938 | [
"Zlib"
] | null | null | null | src/formats/RareSnesInstr.cpp | ValleyBell/vgmtrans | fc7ad99857450d3a943d8201a05331837e5db938 | [
"Zlib"
] | null | null | null | #include "stdafx.h"
#include "RareSnesInstr.h"
#include "Format.h"
#include "SNESDSP.h"
#include "RareSnesFormat.h"
// ****************
// RareSnesInstrSet
// ****************
RareSnesInstrSet::RareSnesInstrSet(RawFile* file, uint32_t offset, uint32_t spcDirAddr, const std::wstring & name) :
VGMInstrSet(RareSnesFormat::name, file, offset, 0, name),
spcDirAddr(spcDirAddr),
maxSRCNValue(255)
{
Initialize();
}
RareSnesInstrSet::RareSnesInstrSet(RawFile* file, uint32_t offset, uint32_t spcDirAddr,
const std::map<uint8_t, int8_t> & instrUnityKeyHints, const std::map<uint8_t, int16_t> & instrPitchHints, const std::map<uint8_t, uint16_t> & instrADSRHints,
const std::wstring & name) :
VGMInstrSet(RareSnesFormat::name, file, offset, 0, name),
spcDirAddr(spcDirAddr),
maxSRCNValue(255),
instrUnityKeyHints(instrUnityKeyHints),
instrPitchHints(instrPitchHints),
instrADSRHints(instrADSRHints)
{
Initialize();
}
RareSnesInstrSet::~RareSnesInstrSet()
{
}
void RareSnesInstrSet::Initialize()
{
for (uint32_t srcn = 0; srcn < 256; srcn++)
{
uint32_t offDirEnt = spcDirAddr + (srcn * 4);
if (offDirEnt + 4 > 0x10000)
{
maxSRCNValue = srcn - 1;
break;
}
if (GetShort(offDirEnt) == 0)
{
maxSRCNValue = srcn - 1;
break;
}
}
unLength = 0x100;
if (dwOffset + unLength > GetRawFile()->size())
{
unLength = GetRawFile()->size() - dwOffset;
}
ScanAvailableInstruments();
}
void RareSnesInstrSet::ScanAvailableInstruments()
{
availInstruments.clear();
bool firstZero = true;
for (uint32_t inst = 0; inst < unLength; inst++)
{
uint8_t srcn = GetByte(dwOffset + inst);
if (srcn == 0 && !firstZero)
{
continue;
}
if (srcn == 0)
{
firstZero = false;
}
uint32_t offDirEnt = spcDirAddr + (srcn * 4);
if (offDirEnt + 4 > 0x10000)
{
continue;
}
if (srcn > maxSRCNValue)
{
continue;
}
uint16_t addrSampStart = GetShort(offDirEnt);
uint16_t addrSampLoop = GetShort(offDirEnt + 2);
// valid loop?
if (addrSampStart > addrSampLoop)
{
continue;
}
// not in DIR table
if (addrSampStart < spcDirAddr + (128 * 4))
{
continue;
}
// address 0 is probably legit, but it should not be used
if (addrSampStart == 0)
{
continue;
}
// Rare engine does not break the following rule... perhaps
if (addrSampStart < spcDirAddr)
{
continue;
}
availInstruments.push_back(inst);
}
}
bool RareSnesInstrSet::GetHeaderInfo()
{
return true;
}
bool RareSnesInstrSet::GetInstrPointers()
{
for (std::vector<uint8_t>::iterator itr = availInstruments.begin(); itr != availInstruments.end(); ++itr)
{
uint8_t inst = (*itr);
uint8_t srcn = GetByte(dwOffset + inst);
int8_t transpose = 0;
std::map<uint8_t, int8_t>::iterator itrKey;
itrKey = this->instrUnityKeyHints.find(inst);
if (itrKey != instrUnityKeyHints.end())
{
transpose = itrKey->second;
}
int16_t pitch = 0;
std::map<uint8_t, int16_t>::iterator itrPitch;
itrPitch = this->instrPitchHints.find(inst);
if (itrPitch != instrPitchHints.end())
{
pitch = itrPitch->second;
}
uint16_t adsr = 0x8FE0;
std::map<uint8_t, uint16_t>::iterator itrADSR;
itrADSR = this->instrADSRHints.find(inst);
if (itrADSR != instrADSRHints.end())
{
adsr = itrADSR->second;
}
std::wostringstream instrName;
instrName << L"Instrument " << inst;
RareSnesInstr * newInstr = new RareSnesInstr(this, dwOffset + inst, inst >> 7, inst & 0x7f, spcDirAddr, transpose, pitch, adsr, instrName.str());
aInstrs.push_back(newInstr);
}
return aInstrs.size() != 0;
}
const std::vector<uint8_t>& RareSnesInstrSet::GetAvailableInstruments()
{
return availInstruments;
}
// *************
// RareSnesInstr
// *************
RareSnesInstr::RareSnesInstr(VGMInstrSet* instrSet, uint32_t offset, uint32_t theBank, uint32_t theInstrNum, uint32_t spcDirAddr, int8_t transpose, int16_t pitch, uint16_t adsr, const std::wstring& name) :
VGMInstr(instrSet, offset, 1, theBank, theInstrNum, name),
spcDirAddr(spcDirAddr),
transpose(transpose),
pitch(pitch),
adsr(adsr)
{
}
RareSnesInstr::~RareSnesInstr()
{
}
bool RareSnesInstr::LoadInstr()
{
uint8_t srcn = GetByte(dwOffset);
uint32_t offDirEnt = spcDirAddr + (srcn * 4);
if (offDirEnt + 4 > 0x10000)
{
return false;
}
uint16_t addrSampStart = GetShort(offDirEnt);
RareSnesRgn * rgn = new RareSnesRgn(this, dwOffset, transpose, pitch, adsr);
rgn->sampOffset = addrSampStart - spcDirAddr;
aRgns.push_back(rgn);
return true;
}
// ***********
// RareSnesRgn
// ***********
RareSnesRgn::RareSnesRgn(RareSnesInstr* instr, uint32_t offset, int8_t transpose, int16_t pitch, uint16_t adsr) :
VGMRgn(instr, offset, 1),
transpose(transpose),
pitch(pitch),
adsr(adsr)
{
// normalize (it is needed especially since SF2 pitch correction is signed 8-bit)
int16_t pitchKeyShift = (pitch / 100);
int8_t realTranspose = transpose + pitchKeyShift;
int16_t realPitch = pitch - (pitchKeyShift * 100);
// NOTE_PITCH_TABLE[73] == 0x1000
// 0x80 + (73 - 36) = 0xA5
SetUnityKey(36 + 36 - realTranspose);
SetFineTune(realPitch);
SNESConvADSR<VGMRgn>(this, adsr >> 8, adsr & 0xff, 0);
}
RareSnesRgn::~RareSnesRgn()
{
}
bool RareSnesRgn::LoadRgn()
{
return true;
}
| 22.634783 | 205 | 0.684595 | ValleyBell |
23bacc4836a2719609c6d5f7e06370e32f250472 | 3,953 | cpp | C++ | test/fence_counting.cpp | mdsudara/percy | b593922b98c9c20fe0a3e4726e50401e54b9cb09 | [
"MIT"
] | 14 | 2018-03-10T21:50:20.000Z | 2021-11-22T04:09:09.000Z | test/fence_counting.cpp | mdsudara/percy | b593922b98c9c20fe0a3e4726e50401e54b9cb09 | [
"MIT"
] | 3 | 2018-06-12T15:17:22.000Z | 2019-06-20T12:00:45.000Z | test/fence_counting.cpp | mdsudara/percy | b593922b98c9c20fe0a3e4726e50401e54b9cb09 | [
"MIT"
] | 12 | 2018-03-10T17:02:07.000Z | 2022-01-09T16:04:56.000Z | #include <percy/percy.hpp>
#include <cassert>
#include <cstdio>
#include <vector>
using namespace percy;
using std::vector;
/*******************************************************************************
Counts and prints all fences up to and including F_5 and ensures that the
number is correct.
*******************************************************************************/
int main(void)
{
fence f;
auto total_expected_fences = 0u;
for (unsigned k = 1; k <= 5; k++) {
printf("F_%u\n", k);
for (unsigned l = 1; l <= k; l++) {
printf("F(%u, %u)\n", k, l);
partition_generator g(k, l);
auto nfences = 0u;
while (g.next_fence(f)) {
nfences++;
print_fence(f);
printf("\n");
}
const auto expected_fences = binomial_coeff(k-1, l-1);
assert(nfences == expected_fences);
total_expected_fences += nfences;
}
auto nfences = 0u;
family_generator g(k);
auto expected_fences = 0u;
for (auto l = 1u; l <= k; l++) {
expected_fences += binomial_coeff(k-1, l-1);
}
while (g.next_fence(f)) {
nfences++;
}
assert(nfences == (unsigned)expected_fences);
}
unbounded_generator g;
auto nfences = 0u;
while (true) {
g.next_fence(f);
if (g.get_nnodes() >= 6) {
break;
}
nfences++;
}
assert(nfences == total_expected_fences);
rec_fence_generator recgen;
recgen.set_po_filter(false);
for (unsigned k = 1; k <= 5; k++) {
printf("F_%u\n", k);
auto total_nr_fences = 0u;
for (unsigned l = 1; l <= k; l++) {
printf("F(%u, %u)\n", k, l);
recgen.reset(k, l);
vector<fence> fences;
recgen.generate_fences(fences);
const auto nfences = fences.size();
for (auto& f : fences) {
print_fence(f);
printf("\n");
}
const auto expected_fences = binomial_coeff(k-1, l-1);
assert(nfences == expected_fences);
total_nr_fences += nfences;
}
auto fences = generate_fences(k, false);
assert(fences.size() == total_nr_fences);
}
// Count the maximum number of fences needed to synthesize all 5-input
// functions.
auto global_total = 0u;
recgen.set_po_filter(true);
vector<fence> po_fences;
for (unsigned k = 1; k <= 12; k++) {
auto total_nr_fences = 0u;
for (unsigned l = 1; l <= k; l++) {
recgen.reset(k, l);
total_nr_fences += recgen.count_fences();
}
generate_fences(po_fences, k);
global_total += total_nr_fences;
printf("Number of fences in F_%d = %d\n", k, total_nr_fences);
}
assert(po_fences.size() == global_total);
for (unsigned k = 13; k <= 15; k++) {
auto total_nr_fences = 0u;
for (unsigned l = 1; l <= k; l++) {
recgen.reset(k, l);
total_nr_fences += recgen.count_fences();
}
printf("Number of fences in F_%u = %d\n", k, total_nr_fences);
}
printf("Nr. of fences relevant to 5-input single-output synthesis is %d\n",
global_total);
// Count the number of fence relevant to synthesizing single-output chains
// with 3-input operators
global_total = 0;
recgen.set_po_filter(true);
po_fences.clear();
for (unsigned k = 1; k <= 15; k++) {
auto total_nr_fences = 0;
for (unsigned l = 1; l <= k; l++) {
recgen.reset(k, l, 1, 3);
total_nr_fences += recgen.count_fences();
}
generate_fences(po_fences, k);
global_total += total_nr_fences;
printf("Number of fences in F_%u = %u (3-input gates)\n", k, total_nr_fences);
}
return 0;
}
| 31.125984 | 86 | 0.510751 | mdsudara |
23bcd21af6406c7041ba801dab6dcc72689b9dd5 | 2,240 | hpp | C++ | src/base/include/structs.hpp | N4G170/generic | 29c8be184b1420b811e2a3db087f9bd6b76ed8bf | [
"MIT"
] | null | null | null | src/base/include/structs.hpp | N4G170/generic | 29c8be184b1420b811e2a3db087f9bd6b76ed8bf | [
"MIT"
] | null | null | null | src/base/include/structs.hpp | N4G170/generic | 29c8be184b1420b811e2a3db087f9bd6b76ed8bf | [
"MIT"
] | null | null | null | #ifndef STRUCTS_HPP
#define STRUCTS_HPP
#include <type_traits>
#include <string>
#include "vector3.hpp"
#include "enums.hpp"
#include "SDL.h"
template<typename T>
struct Bounds
{
//check if we initialize the vector with the right values
static_assert(std::is_integral<T>::value || std::is_floating_point<T>::value, "Bounds template can only integrals of floating point types");
T min_x{0}, min_y{0}, min_z{0}, max_x{0}, max_y{0}, max_z{0};
Bounds(): min_x{0}, min_y{0}, min_z{0}, max_x{0}, max_y{0}, max_z{0} {};
Bounds(T minx, T miny, T minz, T maxx, T maxy, T maxz): min_x{minx}, min_y{miny}, min_z{minz}, max_x{maxx}, max_y{maxy}, max_z{maxz} {};
Bounds(const Vector3<T>& position, const Vector3<T>& size): min_x{position.X()}, min_y{position.Y()}, min_z{position.Z()},
max_x{position.X() + size.X()}, max_y{position.Y() + size.Y()}, max_z{position.Z() + size.Z()} {}
Vector3<T> Size(){ return {max_x - min_x, max_y - min_y, max_z - min_z}; }
Vector3<T> PointPosition(BoundsPositions bounds_position = BoundsPositions::Front_Top_Left)
{
switch (bounds_position)
{
case BoundsPositions::Front_Top_Left: return {min_x, min_y, min_z}; break;
case BoundsPositions::Front_Top_Right: return {max_x, min_y, min_z}; break;
case BoundsPositions::Front_Bottom_Left: return {min_x, max_y, min_z}; break;
case BoundsPositions::Front_Bottom_Right: return {max_x, max_y, min_z}; break;
case BoundsPositions::Back_Top_Left: return {min_x, min_y, max_z}; break;
case BoundsPositions::Back_Top_Right: return {max_x, min_y, max_z}; break;
case BoundsPositions::Back_Bottom_Left: return {min_x, max_y, max_z}; break;
case BoundsPositions::Back_Bottom_Right: return {max_x, max_y, max_z}; break;
default: return {min_x, min_y, min_z};
}
}
};
struct BasicFrame
{
std::string image_path{};
bool has_src_rect{false};
SDL_Rect source_rect{0,0,0,0};
BasicFrame(const std::string& path, bool has_rect, const SDL_Rect& src_rect) : image_path{path}, has_src_rect{has_rect}, source_rect{src_rect} {}
};
#endif //STRUCTS_HPP
| 42.264151 | 149 | 0.658036 | N4G170 |
23bf3d4e2e7fccc5f011f98b95a9fa02783391b3 | 1,604 | cpp | C++ | src/type.cpp | robey/nolove | d83e5ba34e5e53dbef066f4da2f22c6cc2d0572c | [
"Apache-2.0"
] | 1 | 2015-11-05T12:17:23.000Z | 2015-11-05T12:17:23.000Z | src/type.cpp | robey/nolove | d83e5ba34e5e53dbef066f4da2f22c6cc2d0572c | [
"Apache-2.0"
] | null | null | null | src/type.cpp | robey/nolove | d83e5ba34e5e53dbef066f4da2f22c6cc2d0572c | [
"Apache-2.0"
] | null | null | null | #include "llvm/Support/raw_ostream.h"
#include "type.h"
using namespace v8;
// ----- LType
NodeProto<LType> LType::proto("Type");
void LType::init() {
proto.addMethod("isDoubleType", <ype::isDoubleType);
proto.addMethod("isFunctionType", <ype::isFunctionType);
proto.addMethod("toString", <ype::toString);
}
Handle<Value> LType::isDoubleType(const Arguments& args) {
return Boolean::New(type()->isDoubleTy());
}
Handle<Value> LType::isFunctionType(const Arguments& args) {
return Boolean::New(type()->isFunctionTy());
}
Handle<Value> LType::toString(const Arguments& args) {
std::string s("<Type ");
llvm::raw_string_ostream os(s);
type()->print(os);
os << ">";
return String::New(os.str().c_str());
}
// ----- LFunctionType
NodeProto<LFunctionType> LFunctionType::proto("FunctionType");
void LFunctionType::init() {
proto.inherit(LType::proto);
proto.addMethod("isVarArg", &LFunctionType::isVarArg);
proto.addMethod("getNumParams", &LFunctionType::getNumParams);
proto.addMethod("getParamType", &LFunctionType::getParamType);
}
Handle<Value> LFunctionType::isVarArg(const Arguments& args) {
return Boolean::New(functionType()->isVarArg());
}
Handle<Value> LFunctionType::getNumParams(const Arguments& args) {
return Integer::New(functionType()->getNumParams());
}
Handle<Value> LFunctionType::getParamType(const Arguments& args) {
CHECK_ARG_COUNT("getParamType", 1, 1, "index: Number");
CHECK_ARG_NUMBER(0);
unsigned int index = (unsigned int) args[0]->ToNumber()->Value();
return LType::create(functionType()->getParamType(index))->handle_;
}
| 28.140351 | 69 | 0.714464 | robey |
23bf978e1a5d09fea9cb909b5ec53ef5d141c86e | 1,564 | cpp | C++ | gui/NativeWindow.cpp | razaqq/PotatoAlert | 4dfb54a7841ca71d8dbf58620173f2a9fc1886f2 | [
"MIT"
] | 20 | 2020-06-16T01:30:29.000Z | 2022-03-08T14:54:30.000Z | gui/NativeWindow.cpp | razaqq/PotatoAlert | 4dfb54a7841ca71d8dbf58620173f2a9fc1886f2 | [
"MIT"
] | 26 | 2019-07-15T10:49:47.000Z | 2022-02-16T19:25:48.000Z | gui/NativeWindow.cpp | razaqq/PotatoAlert | 4dfb54a7841ca71d8dbf58620173f2a9fc1886f2 | [
"MIT"
] | 5 | 2020-06-16T01:31:03.000Z | 2022-01-22T19:43:48.000Z | // Copyright 2020 <github.com/razaqq>
#include <QWidget>
#include <QVBoxLayout>
#include <QMainWindow>
#include <QWindow>
#include "NativeWindow.hpp"
#include "TitleBar.hpp"
#include "Config.hpp"
#include "FramelessWindowsManager.hpp"
using PotatoAlert::NativeWindow;
NativeWindow::NativeWindow(QMainWindow* mainWindow) : QWidget()
{
this->mainWindow = mainWindow;
this->mainWindow->setParent(this);
this->init();
}
void NativeWindow::closeEvent(QCloseEvent* event)
{
PotatoConfig().set<int>("window_height", this->height());
PotatoConfig().set<int>("window_width", this->width());
PotatoConfig().set<int>("window_x", this->x());
PotatoConfig().set<int>("window_y", this->y());
QWidget::closeEvent(event);
}
void NativeWindow::init()
{
this->createWinId();
QWindow* w = this->windowHandle();
this->titleBar->setFixedHeight(23);
for (auto& o : this->titleBar->getIgnores())
FramelessWindowsManager::addIgnoreObject(w, o);
FramelessWindowsManager::addWindow(w);
FramelessWindowsManager::setBorderWidth(w, borderWidth);
FramelessWindowsManager::setBorderHeight(w, borderWidth);
FramelessWindowsManager::setTitleBarHeight(w, this->titleBar->height());
auto layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(this->titleBar);
layout->addWidget(this->mainWindow);
this->setLayout(layout);
this->resize(PotatoConfig().get<int>("window_width"), PotatoConfig().get<int>("window_height"));
this->move(PotatoConfig().get<int>("window_x"), PotatoConfig().get<int>("window_y"));
}
| 26.508475 | 97 | 0.734655 | razaqq |
23cb33ca493b6d2d59fc46ba0968a4adb2718e58 | 1,922 | cpp | C++ | 584 Bowling.cpp | zihadboss/UVA-Solutions | 020fdcb09da79dc0a0411b04026ce3617c09cd27 | [
"Apache-2.0"
] | 86 | 2016-01-20T11:36:50.000Z | 2022-03-06T19:43:14.000Z | 584 Bowling.cpp | Mehedishihab/UVA-Solutions | 474fe3d9d9ba574b97fd40ca5abb22ada95654a1 | [
"Apache-2.0"
] | null | null | null | 584 Bowling.cpp | Mehedishihab/UVA-Solutions | 474fe3d9d9ba574b97fd40ca5abb22ada95654a1 | [
"Apache-2.0"
] | 113 | 2015-12-04T06:40:57.000Z | 2022-02-11T02:14:28.000Z | #include <cstdio>
int handle(char current, char previous, char twoPrevious, bool addOwnScore)
{
int baseScore(0);
int score = 0;
if (current == 'X')
{
baseScore = 10;
}
else if (current == '/')
{
baseScore = 10 - (previous - '0');
}
else
{
baseScore = current - '0';
}
if (addOwnScore)
score = baseScore;
if (previous == '/' || previous == 'X')
score += baseScore;
if (twoPrevious == 'X')
score += baseScore;
return score;
}
const int countedThrows = 20;
int main()
{
char first;
while (scanf(" %c", &first), first != 'G')
{
char current = first, previous = ' ', twoPrevious = ' ';
int score;
score = handle(current, previous, twoPrevious, true);
previous = current;
int bonusThrows = 0;
for (int i = (current == 'X') ? 2 : 1; i < countedThrows; ++i)
{
scanf(" %c", ¤t);
score += handle(current, previous, twoPrevious, true);
twoPrevious = previous;
previous = current;
if (current == 'X')
{
if (i == 18) // First throw of the last round
bonusThrows = 2;
++i;
}
if (current == '/' && i == 19)
bonusThrows = 1;
}
for (int i = 0; i < bonusThrows; ++i)
{
scanf(" %c", ¤t);
score += handle(current, previous, twoPrevious, false);
twoPrevious = previous;
previous = current; // The just thrown ball does not improve score
if (previous == 'X')
previous = ' ';
}
printf("%d\n", score);
}
} | 22.091954 | 78 | 0.426639 | zihadboss |
23cd22431b7eedfa78296fb3cadd0a30e4363843 | 1,071 | cpp | C++ | dynamic_progrmmaing/coursera_primitive_calculator.cpp | BackAged/100_days_of_problem_solving | 2e24efad6d46804c4b31f415dbd69d7b80703a4f | [
"Apache-2.0"
] | 3 | 2020-06-15T10:39:34.000Z | 2021-01-17T14:03:37.000Z | dynamic_progrmmaing/coursera_primitive_calculator.cpp | BackAged/100_days_of_problem_solving | 2e24efad6d46804c4b31f415dbd69d7b80703a4f | [
"Apache-2.0"
] | null | null | null | dynamic_progrmmaing/coursera_primitive_calculator.cpp | BackAged/100_days_of_problem_solving | 2e24efad6d46804c4b31f415dbd69d7b80703a4f | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int choice[1000000];
int visited[1000000];
int optimal_sequence(int n) {
visited[0] = 0;
visited[1] = 0;
for (int i = 2; i <= n; i++) {
int ans = INT32_MAX;
int t1 = 1 + visited[i - 1];
if (t1 < ans) {
ans = t1;
choice[i] = i - 1;
}
if (i % 2 == 0) {
int t2 = 1 + visited[i/2];
if (t2 < ans) {
ans = t2;
choice[i] = i / 2;
}
}
if (i % 3 == 0) {
int t3 = 1 + visited[i/3];
if (t3 < ans) {
ans = t3;
choice[i] = i / 3;
}
}
visited[i] = min(ans, visited[i]);
}
return visited[n];
}
void printOptimalSolution(int n) {
if (n == 1) {
cout << 1 << " ";
return;
}
printOptimalSolution(choice[n]);
cout << n << " ";
}
int main() {
int n;
cin >> n;
fill_n(visited, 1000005, INT32_MAX);
int sequence = optimal_sequence(n);
cout << sequence << endl;
printOptimalSolution(n);
} | 18.789474 | 40 | 0.46592 | BackAged |
23e60ab5fbae97a04f5642bcb8bc617f26084126 | 51 | cpp | C++ | src/LoginInfo.cpp | NoSuchBoyException/QT-PureMVC | cc84e68ddc2666941af6970a4fab364ab74f5190 | [
"Apache-2.0"
] | 40 | 2016-06-20T12:22:42.000Z | 2022-03-10T03:20:00.000Z | src/LoginInfo.cpp | NoSuchBoyException/PureMVC_QT | cc84e68ddc2666941af6970a4fab364ab74f5190 | [
"Apache-2.0"
] | null | null | null | src/LoginInfo.cpp | NoSuchBoyException/PureMVC_QT | cc84e68ddc2666941af6970a4fab364ab74f5190 | [
"Apache-2.0"
] | 24 | 2017-01-03T13:18:04.000Z | 2022-03-20T01:24:41.000Z | #include "LoginInfo.h"
LoginInfo::LoginInfo()
{
}
| 8.5 | 22 | 0.686275 | NoSuchBoyException |
23ea38bae9e49e20a987deab48c375b42aa64b46 | 7,474 | cpp | C++ | src/bin/balanceHandler.cpp | D7ry/valhallaCombat | 07929d29a48401c2878a1ed5993b7bba14743c6f | [
"MIT"
] | 1 | 2022-01-19T07:13:48.000Z | 2022-01-19T07:13:48.000Z | src/bin/balanceHandler.cpp | D7ry/valhallaCombat | 07929d29a48401c2878a1ed5993b7bba14743c6f | [
"MIT"
] | null | null | null | src/bin/balanceHandler.cpp | D7ry/valhallaCombat | 07929d29a48401c2878a1ed5993b7bba14743c6f | [
"MIT"
] | 1 | 2022-01-19T07:13:52.000Z | 2022-01-19T07:13:52.000Z | #include "include/balanceHandler.h"
#include "include/reactionHandler.h"
#include "include/offsets.h"
#include "include/Utils.h"
inline const float balanceRegenTime = 6;//time it takes for balance to regen, in seconds.
void balanceHandler::update() {
//DEBUG("update");
/*if (garbageCollectionQueued) {
collectGarbage();
garbageCollectionQueued = false;
}*/
mtx_balanceBrokenActors.lock();
if (balanceBrokenActors.empty()) {//stop updating when there is 0 actor need to regen balance.
mtx_balanceBrokenActors.unlock();
//DEBUG("no balance broken actors, stop update");
ValhallaCombat::GetSingleton()->deactivateUpdate(ValhallaCombat::HANDLER::balanceHandler);
return;
}
//DEBUG("non-empty balance map");
//regenerate balance for all balance broken actors.
auto it = balanceBrokenActors.begin();
mtx_actorBalanceMap.lock();
while (it != balanceBrokenActors.end()) {
if (!actorBalanceMap.contains(*it)) { //edge case: actor's balance broken but no longer tracked on actor balance map.
//DEBUG("edge case");
it = balanceBrokenActors.erase(it);
continue;
}
//regen a single actor's balance.
auto* balanceData = &actorBalanceMap.find(*it)->second;
float regenVal = balanceData->first * *RE::Offset::g_deltaTime * 1 / balanceRegenTime;
//DEBUG(regenVal);
//DEBUG(a_balanceData.second);
//DEBUG(a_balanceData.first);
if (balanceData->second + regenVal >= balanceData->first) {//this regen exceeds actor's max balance.
//DEBUG("{}'s balance has recovered", (*it)->GetName());
balanceData->second = balanceData->first;//reset balance.
debuffHandler::GetSingleton()->quickStopStaminaDebuff(*it);
it = balanceBrokenActors.erase(it);
continue;
}
else {
//DEBUG("normal regen");
balanceData->second += regenVal;
}
it++;
}
mtx_actorBalanceMap.unlock();
mtx_balanceBrokenActors.unlock();
}
void balanceHandler::queueGarbageCollection() {
garbageCollectionQueued = true;
}
float balanceHandler::calculateMaxBalance(RE::Actor* a_actor) {
return a_actor->GetPermanentActorValue(RE::ActorValue::kHealth);
}
void balanceHandler::trackBalance(RE::Actor* a_actor) {
float maxBalance = calculateMaxBalance(a_actor);
mtx_actorBalanceMap.lock();
actorBalanceMap.emplace(a_actor, std::pair<float, float> {maxBalance, maxBalance});
mtx_actorBalanceMap.unlock();
}
void balanceHandler::untrackBalance(RE::Actor* a_actor) {
mtx_actorBalanceMap.lock();
actorBalanceMap.erase(a_actor);
mtx_actorBalanceMap.unlock();
}
void balanceHandler::collectGarbage() {
INFO("Cleaning up balance map...");
int ct = 0;
mtx_actorBalanceMap.lock();
auto it_balanceMap = actorBalanceMap.begin();
while (it_balanceMap != actorBalanceMap.end()) {
auto a_actor = it_balanceMap->first;
if (!a_actor || !a_actor->currentProcess || !a_actor->currentProcess->InHighProcess()) {
safeErase_BalanceBrokenActors(a_actor);
it_balanceMap = actorBalanceMap.erase(it_balanceMap);
ct++;
continue;
}
it_balanceMap++;
}
mtx_actorBalanceMap.unlock();
INFO("...done; cleaned up {} inactive actors.", ct);
}
void balanceHandler::reset() {
INFO("Reset all balance...");
mtx_actorBalanceMap.lock();
actorBalanceMap.clear();
mtx_actorBalanceMap.unlock();
mtx_balanceBrokenActors.lock();
balanceBrokenActors.clear();
mtx_balanceBrokenActors.unlock();
INFO("..done");
}
bool balanceHandler::isBalanceBroken(RE::Actor* a_actor) {
mtx_balanceBrokenActors.lock();
if (balanceBrokenActors.contains(a_actor)) {
mtx_balanceBrokenActors.unlock();
return true;
}
else {
mtx_balanceBrokenActors.unlock();
return false;
}
}
void balanceHandler::damageBalance(DMGSOURCE dmgSource, RE::Actor* a_aggressor, RE::Actor* a_victim, float damage) {
//DEBUG("damaging balance: aggressor: {}, victim: {}, damage: {}", aggressor->GetName(), victim->GetName(), damage);
mtx_actorBalanceMap.lock();
if (!actorBalanceMap.contains(a_victim)) {
mtx_actorBalanceMap.unlock();
trackBalance(a_victim);
damageBalance(dmgSource, a_aggressor, a_victim, damage);
return;
}
#define a_balanceData actorBalanceMap.find(a_victim)->second
//DEBUG("curr balance: {}", a_balanceData.second);
if (a_balanceData.second - damage <= 0) { //balance broken, ouch!
a_balanceData.second = 0;
mtx_actorBalanceMap.unlock();
mtx_balanceBrokenActors.lock();
if (!balanceBrokenActors.contains(a_victim)) {//if not balance broken already
//DEBUG("{}'s balance has broken", victim->GetName());
balanceBrokenActors.insert(a_victim);
if (dmgSource == DMGSOURCE::parry) {
reactionHandler::triggerStagger(a_aggressor, a_victim, reactionHandler::kLarge);
}
ValhallaCombat::GetSingleton()->activateUpdate(ValhallaCombat::HANDLER::balanceHandler);
}
else {//balance already broken, yet broken again, ouch!
//DEBUG("{}'s balance double broken", victim->GetName());
reactionHandler::triggerContinuousStagger(a_aggressor, a_victim, reactionHandler::kLarge);
}
mtx_balanceBrokenActors.unlock();
}
else {
//DEBUG("normal balance damage.");
a_balanceData.second -= damage;
mtx_actorBalanceMap.unlock();
mtx_balanceBrokenActors.lock();
if (balanceBrokenActors.contains(a_victim)) {
if (dmgSource == DMGSOURCE::powerAttack) {
reactionHandler::triggerStagger(a_aggressor, a_victim, reactionHandler::reactionType::kKnockBack);
}
else {
reactionHandler::triggerContinuousStagger(a_aggressor, a_victim, reactionHandler::kLarge);
}
}//if balance broken, trigger stagger.
else if (dmgSource == DMGSOURCE::powerAttack
&& !debuffHandler::GetSingleton()->isInDebuff(a_aggressor)) //or if is power attack and not in debuff
{
reactionHandler::triggerContinuousStagger(a_aggressor, a_victim, reactionHandler::kLarge);
}
mtx_balanceBrokenActors.unlock();
}
}
void balanceHandler::recoverBalance(RE::Actor* a_actor, float recovery) {
mtx_actorBalanceMap.lock();
if (!actorBalanceMap.contains(a_actor)) {
mtx_actorBalanceMap.unlock();
return;
}
float attempedRecovery = actorBalanceMap[a_actor].second + recovery;
if (attempedRecovery >= actorBalanceMap[a_actor].first) {//balance fully recovered.
actorBalanceMap[a_actor].second = actorBalanceMap[a_actor].first;
mtx_actorBalanceMap.unlock();
if (isBalanceBroken(a_actor)) {
safeErase_BalanceBrokenActors(a_actor);
debuffHandler::GetSingleton()->quickStopStaminaDebuff(a_actor);
}
}
else {
actorBalanceMap[a_actor].second = attempedRecovery;
mtx_actorBalanceMap.unlock();
}
}
void balanceHandler::processBalanceDamage(DMGSOURCE dmgSource, RE::TESObjectWEAP* weapon, RE::Actor* aggressor, RE::Actor* victim, float baseDamage) {
if (!settings::bBalanceToggle) {
return;
}
baseDamage *= 2;
if (isBalanceBroken(victim) && dmgSource < DMGSOURCE::bash) {
recoverBalance(victim, baseDamage * 1);
baseDamage = 0;
}
else {
if (debuffHandler::GetSingleton()->isInDebuff(victim)) {
baseDamage *= 1.5;
}
if (dmgSource == DMGSOURCE::parry) {
baseDamage *= 1.5;
}
if (victim->IsRangedAttacking() || ValhallaUtils::isCasting(victim)) {
baseDamage * 2.25;
}
}
damageBalance(dmgSource, aggressor, victim, baseDamage);
}
void balanceHandler::safeErase_ActorBalanceMap(RE::Actor* a_actor) {
mtx_actorBalanceMap.lock();
actorBalanceMap.erase(a_actor);
mtx_actorBalanceMap.unlock();
}
void balanceHandler::safeErase_BalanceBrokenActors(RE::Actor* a_actor) {
mtx_balanceBrokenActors.lock();
balanceBrokenActors.erase(a_actor);
mtx_balanceBrokenActors.unlock();
} | 32.637555 | 150 | 0.737624 | D7ry |
23eae08214ee1ecabf369ec840d1dcb03d36ba1e | 1,138 | cpp | C++ | pbr/Mesh.cpp | chuxu1793/pbr-1 | c77d9bcc2c19637ab79382cbef3fc0e2a31b6560 | [
"MIT"
] | 51 | 2016-04-03T20:37:57.000Z | 2022-03-31T00:38:11.000Z | pbr/Mesh.cpp | chuxu1793/pbr-1 | c77d9bcc2c19637ab79382cbef3fc0e2a31b6560 | [
"MIT"
] | 2 | 2016-11-14T21:14:10.000Z | 2016-11-16T15:01:47.000Z | pbr/Mesh.cpp | chuxu1793/pbr-1 | c77d9bcc2c19637ab79382cbef3fc0e2a31b6560 | [
"MIT"
] | 9 | 2016-06-02T03:46:23.000Z | 2020-10-16T23:30:16.000Z | #include "Mesh.h"
#include <glbinding/gl/gl.h>
void Mesh::draw()
{
glBindVertexArray(m_VAO);
glDrawElements(GL_TRIANGLES, m_IndicesCount * 3, GL_UNSIGNED_INT, nullptr);
glBindVertexArray(0);
}
void Mesh::initialize(const std::vector<Vertex>& vertices, const std::vector<Triangle>& indices)
{
m_IndicesCount = indices.size();
glGenVertexArrays(1, &m_VAO);
glBindVertexArray(m_VAO);
{
glGenBuffers(1, &m_VBO);
glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(Vertex), vertices.data(), GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_TRUE, sizeof(Vertex), (void*)(sizeof(glm::vec3)));
glVertexAttribPointer(2, 2, GL_FLOAT, GL_TRUE, sizeof(Vertex), (void*)(2 * sizeof(glm::vec3)));
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glGenBuffers(1, &m_EBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(Triangle), indices.data(), GL_STATIC_DRAW);
}
glBindVertexArray(0);
} | 31.611111 | 107 | 0.748682 | chuxu1793 |
23eb4c38cc7c876ace8bc06e105f134921e3f8b7 | 1,130 | cpp | C++ | src/CursATE/Curses/Field/detail/resizePadded.cpp | qiagen/LogATE | aa43595c89bf3bcaa302d8406e5ad789efc0e035 | [
"BSD-2-Clause"
] | null | null | null | src/CursATE/Curses/Field/detail/resizePadded.cpp | qiagen/LogATE | aa43595c89bf3bcaa302d8406e5ad789efc0e035 | [
"BSD-2-Clause"
] | null | null | null | src/CursATE/Curses/Field/detail/resizePadded.cpp | qiagen/LogATE | aa43595c89bf3bcaa302d8406e5ad789efc0e035 | [
"BSD-2-Clause"
] | 3 | 2021-01-12T18:52:49.000Z | 2021-01-19T17:48:50.000Z | #include "CursATE/Curses/Field/detail/resizePadded.hpp"
#include <But/assert.hpp>
namespace CursATE::Curses::Field::detail
{
VisibleSize resizePaddedVisibleSize(std::string const& in, size_t maxSize, size_t selectedElement)
{
if( in.size() <= maxSize )
return {0, selectedElement, in.size()};
if( selectedElement > in.size() )
BUT_THROW(SelectionOutOfRange, "requested element " << selectedElement << " in a string of length " << in.size());
const auto half = maxSize / 2;
auto start = 0u;
if( selectedElement > half )
start = selectedElement - half;
if( in.size() - start < maxSize )
start = in.size() - maxSize;
const auto offset = selectedElement - start;
BUT_ASSERT( offset <= maxSize && "offset it outside of display window" );
return {start, offset, maxSize};
}
std::string resizePadded(std::string const& in, const size_t maxSize, const size_t selectedElement)
{
if( in.size() <= maxSize )
{
auto tmp = in;
tmp.resize(maxSize, ' ');
return tmp;
}
const auto vs = resizePaddedVisibleSize(in, maxSize, selectedElement);
return in.substr(vs.start_, vs.count_);
}
}
| 29.736842 | 118 | 0.685841 | qiagen |
6710cae5db7291a10684008a748246fc5eeec215 | 1,483 | cpp | C++ | Pearly/src/Pearly/Math/Math.cpp | JumpyLionnn/Pearly | 2dce5f54144980cecd998a325422e56bff6c4c83 | [
"Apache-2.0"
] | null | null | null | Pearly/src/Pearly/Math/Math.cpp | JumpyLionnn/Pearly | 2dce5f54144980cecd998a325422e56bff6c4c83 | [
"Apache-2.0"
] | null | null | null | Pearly/src/Pearly/Math/Math.cpp | JumpyLionnn/Pearly | 2dce5f54144980cecd998a325422e56bff6c4c83 | [
"Apache-2.0"
] | null | null | null | #include "prpch.h"
#include "Math.h"
namespace Pearly {
bool Math::DecomposeTransform(const glm::mat4& transform, glm::vec3& position, float& rotation, glm::vec2& scale)
{
glm::mat4 localMatrix(transform);
// Normalize the matrix.
if (glm::epsilonEqual(localMatrix[3][3], static_cast<float>(0), glm::epsilon<float>()))
return false;
// First, isolate perspective. floathis is the messiest.
if (
glm::epsilonNotEqual(localMatrix[0][3], static_cast<float>(0), glm::epsilon<float>()) ||
glm::epsilonNotEqual(localMatrix[1][3], static_cast<float>(0), glm::epsilon<float>()) ||
glm::epsilonNotEqual(localMatrix[2][3], static_cast<float>(0), glm::epsilon<float>()))
{
// Clear the perspective partition
localMatrix[0][3] = localMatrix[1][3] = localMatrix[2][3] = static_cast<float>(0);
localMatrix[3][3] = static_cast<float>(1);
}
// Next take care of translation (easy).
position = glm::vec3(localMatrix[3]);
localMatrix[3] = glm::vec4(0, 0, 0, localMatrix[3].w);
glm::vec3 row[3];
// Now get scale and shear.
for (glm::length_t i = 0; i < 3; ++i)
for (glm::length_t j = 0; j < 3; ++j)
row[i][j] = localMatrix[i][j];
// Compute X scale factor and normalize first row.
scale.x = glm::length(row[0]);
row[0] = glm::detail::scale(row[0], static_cast<float>(1));
scale.y = glm::length(row[1]);
row[1] = glm::detail::scale(row[1], static_cast<float>(1));
rotation = atan2(row[0][1], row[0][0]);
return true;
}
} | 32.23913 | 114 | 0.646662 | JumpyLionnn |
6711ec4603bd0025df95902abfec0d44315c7bae | 2,149 | cc | C++ | device/device_rom.cc | CompaqDisc/zippy | e8c3b67ea59adbbdf9881e1bc34f0eab0eab6abe | [
"MIT"
] | null | null | null | device/device_rom.cc | CompaqDisc/zippy | e8c3b67ea59adbbdf9881e1bc34f0eab0eab6abe | [
"MIT"
] | null | null | null | device/device_rom.cc | CompaqDisc/zippy | e8c3b67ea59adbbdf9881e1bc34f0eab0eab6abe | [
"MIT"
] | null | null | null | #include "device_rom.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cerrno>
DeviceROM::DeviceROM(uint16_t address_start, size_t region_length) {
address_start_ = address_start;
region_length_ = region_length;
buffer_contents_ = (uint8_t*) malloc(region_length_ * sizeof(uint8_t));
}
DeviceROM::DeviceROM(uint16_t address_start, size_t region_length,
std::string file_path
) {
address_start_ = address_start;
region_length_ = region_length;
buffer_contents_ = (uint8_t*) malloc(region_length_ * sizeof(uint8_t));
std::ifstream f(file_path);
// Bail if file wasn't found.
if (!f.good()) {
std::cout
<< "[FATL] [device_rom.cc] Specified file does not exist!"
<< std::endl;
exit(ENOENT);
}
f.seekg(0, f.end);
size_t file_length = f.tellg();
f.seekg(0, f.beg);
/*
Check that file length <= buffer space.
If not, only read until buffer is filled.
*/
if (file_length > region_length_) {
// Warn that we will truncate the read.
std::cout
<< "[WARN] [device_rom.cc] Specified romfile is too long for virtual ROM!"
<< "Truncating read!" << std::endl;
// Warn how large the file was.
printf(
"[WARN] [device_rom.cc] "
"Attempting to load %s (%li bytes), into virtual ROM with size of %li bytes!\n",
file_path.c_str(), file_length, region_length_
);
// Truncate read.
file_length = sizeof(buffer_contents_);
} else {
printf(
"[INFO] [device_rom.cc] "
"Loaded %s (%li bytes), into virtual ROM with size of %li bytes\n",
file_path.c_str(), file_length, region_length_
);
}
// Read the file into our buffer.
f.read((char*) buffer_contents_, file_length);
}
DeviceROM::~DeviceROM() {
free(buffer_contents_);
}
void DeviceROM::Clock() {
if (bus_->MemoryRequestActive()) {
if (bus_->ReadRequestActive()) {
if (bus_->Address() >= address_start_ &&
bus_->Address() < (address_start_ + region_length_))
{
printf("[INFO] [device_rom.cc] /RD request made for 0x%04x\n",
bus_->Address());
bus_->PushData(
buffer_contents_[bus_->Address() - address_start_]);
}
}
}
}
void DeviceROM::BindToBus(Bus* bus) {
bus_ = bus;
}
| 23.615385 | 83 | 0.676128 | CompaqDisc |
671afcda2345039279bc47492c4f1a66cbd14d83 | 328 | cpp | C++ | Zerojudge/d111.cpp | w181496/OJ | 67d1d32770376865eba8a9dd1767e97dae68989a | [
"MIT"
] | 9 | 2017-10-08T16:22:03.000Z | 2021-08-20T09:32:17.000Z | Zerojudge/d111.cpp | w181496/OJ | 67d1d32770376865eba8a9dd1767e97dae68989a | [
"MIT"
] | null | null | null | Zerojudge/d111.cpp | w181496/OJ | 67d1d32770376865eba8a9dd1767e97dae68989a | [
"MIT"
] | 2 | 2018-01-15T16:35:44.000Z | 2019-03-21T18:30:04.000Z | #include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
long long int n;
while(cin >> n)
{
if(n==0)break;
long long int t=sqrt(n);
if(t*t==n)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}
| 15.619048 | 33 | 0.45122 | w181496 |
671fb22bf156d02ccdb16b73138f40f99f753d9b | 1,042 | cpp | C++ | course1/laba4/L_pairosochetatie_max_weight/main.cpp | flydzen/ITMO_algo | ea251dca0fddb0d4d212377c6785cdc3667ece89 | [
"MIT"
] | null | null | null | course1/laba4/L_pairosochetatie_max_weight/main.cpp | flydzen/ITMO_algo | ea251dca0fddb0d4d212377c6785cdc3667ece89 | [
"MIT"
] | null | null | null | course1/laba4/L_pairosochetatie_max_weight/main.cpp | flydzen/ITMO_algo | ea251dca0fddb0d4d212377c6785cdc3667ece89 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <fstream>
using namespace std;
vector<vector<pair<int, int>>> ss;
vector<long long> a;
vector<long long> b;
vector<long long> c;
void discrete_finger_simulation(int i, int from) {
for (pair<int, int> p : ss[i]) {
if (p.first == from)
continue;
discrete_finger_simulation(p.first, i);
a[i] = max(a[i], b[p.first] + p.second - c[p.first]);
b[i] += c[p.first];
}
a[i] += b[i];
c[i] = max(a[i], b[i]);
}
int main() {
ifstream fin("matching.in");
ofstream fout("matching.out");
int n;
fin >> n;
ss = vector<vector<pair<int, int>>>(n, vector<pair<int, int>>());
a = vector<long long>(n);
b = vector<long long>(n);
c = vector<long long>(n);
for (int i = 0; i < n - 1; i++) {
int f, t, w;
fin >> f >> t >> w;
ss[f - 1].push_back(make_pair(t - 1, w));
ss[t - 1].push_back(make_pair(f - 1, w));
}
discrete_finger_simulation(0, -1);
fout << c[0];
return 0;
}
| 24.809524 | 69 | 0.52975 | flydzen |
6725b0780abb7d9c0419b517fcf07d347c0c3a45 | 1,771 | hpp | C++ | asteria/src/reference.hpp | MaskRay/asteria | 56a9251f5bb80b92e5aff25eac145f8cd2495096 | [
"BSD-3-Clause"
] | null | null | null | asteria/src/reference.hpp | MaskRay/asteria | 56a9251f5bb80b92e5aff25eac145f8cd2495096 | [
"BSD-3-Clause"
] | null | null | null | asteria/src/reference.hpp | MaskRay/asteria | 56a9251f5bb80b92e5aff25eac145f8cd2495096 | [
"BSD-3-Clause"
] | null | null | null | // This file is part of Asteria.
// Copyleft 2018, LH_Mouse. All wrongs reserved.
#ifndef ASTERIA_REFERENCE_HPP_
#define ASTERIA_REFERENCE_HPP_
#include "fwd.hpp"
#include "reference_root.hpp"
#include "reference_modifier.hpp"
namespace Asteria {
class Reference
{
private:
Reference_root m_root;
Vector<Reference_modifier> m_mods;
public:
Reference() noexcept
: m_root(), m_mods()
{
}
// This constructor does not accept lvalues.
template<typename XrootT, typename std::enable_if<(Reference_root::Variant::index_of<XrootT>::value || true)>::type * = nullptr>
Reference(XrootT &&xroot)
: m_root(std::forward<XrootT>(xroot)), m_mods()
{
}
// This assignment operator does not accept lvalues.
template<typename XrootT, typename std::enable_if<(Reference_root::Variant::index_of<XrootT>::value || true)>::type * = nullptr>
Reference & operator=(XrootT &&xroot)
{
this->m_root = std::forward<XrootT>(xroot);
this->m_mods.clear();
return *this;
}
~Reference();
Reference(const Reference &) noexcept;
Reference & operator=(const Reference &) noexcept;
Reference(Reference &&) noexcept;
Reference & operator=(Reference &&) noexcept;
public:
bool is_constant() const noexcept
{
return this->m_root.index() == Reference_root::index_constant;
}
Value read() const;
Value & write(Value value) const;
Value unset() const;
Reference & zoom_in(Reference_modifier mod);
Reference & zoom_out();
Reference & convert_to_temporary();
Reference & convert_to_variable(Global_context &global);
void enumerate_variables(const Abstract_variable_callback &callback) const;
};
}
#endif
| 26.432836 | 132 | 0.671937 | MaskRay |
672705ff65970239683ce82be68db76924118ba7 | 1,160 | cpp | C++ | search_algorithms/coding_problems/search_sorted_rotated.cpp | sky-lynx/Algorithms | 95592a73dcd1dc04be7df3ce3157e63230fac27b | [
"MIT"
] | null | null | null | search_algorithms/coding_problems/search_sorted_rotated.cpp | sky-lynx/Algorithms | 95592a73dcd1dc04be7df3ce3157e63230fac27b | [
"MIT"
] | null | null | null | search_algorithms/coding_problems/search_sorted_rotated.cpp | sky-lynx/Algorithms | 95592a73dcd1dc04be7df3ce3157e63230fac27b | [
"MIT"
] | null | null | null | // searches an element in an array which is sorted and then rotated
#include <iostream>
using namespace std;
int binary_search(int* arr, int l, int r, int key)
{
int m;
while(l != r)
{
m = (l + r) / 2;
if(arr[m] == key)
return m;
else if(arr[m] > key)
r = m - 1;
else
l = m + 1;
}
return -1;
}
int pivot_search(int* arr, int l, int r)
{
if(l < r)
return -1;
if(l == r)
return l;
int m = (l+r)/2;
if(m < r && arr[m] > arr[m+1])
return m;
if(m > l && arr[m] < arr[m-1])
return m-1;
if(arr[l] >= arr[m])
return pivot_search(arr, l, m-1);
return pivot_search(arr, m+1, r);
}
int pivoted_binary(int* arr, int l, int r, int key)
{
int pivot = pivot_search(arr, l, r);
if(pivot == -1)
return binary_search(arr, l, r, key);
if(arr[pivot] == key)
return pivot;
if(arr[0] <= key)
return binary_search(arr, l, pivot-1, key);
return binary_search(arr, pivot+1, r, key);
}
int main(void)
{
int array[] = {4,5,6,7,8,1,2,3};
int left = 0;
int right = (sizeof(array) / sizeof(*array)) - 1;
cout<<pivoted_binary(array, left, right, 7)<<'\n';
return 0;
}
| 17.575758 | 67 | 0.551724 | sky-lynx |
672b1c0d09b5b2ffa2f2bddaf4536ef544fc227b | 2,516 | cpp | C++ | kernel/main.cpp | ethan4984/rock | 751b9af1009b622bedf384c1f80970b333c436c3 | [
"BSD-2-Clause"
] | 207 | 2020-05-27T21:57:28.000Z | 2022-02-26T15:17:27.000Z | kernel/main.cpp | ethan4984/crepOS | 751b9af1009b622bedf384c1f80970b333c436c3 | [
"BSD-2-Clause"
] | 3 | 2020-07-26T18:14:05.000Z | 2020-12-09T05:32:07.000Z | kernel/main.cpp | ethan4984/rock | 751b9af1009b622bedf384c1f80970b333c436c3 | [
"BSD-2-Clause"
] | 17 | 2020-07-05T19:08:48.000Z | 2021-10-13T12:30:13.000Z | #include <mm/vmm.hpp>
#include <mm/pmm.hpp>
#include <mm/slab.hpp>
#include <int/idt.hpp>
#include <int/gdt.hpp>
#include <int/apic.hpp>
#include <fs/dev.hpp>
#include <fs/vfs.hpp>
#include <fs/fd.hpp>
#include <drivers/hpet.hpp>
#include <drivers/tty.hpp>
#include <drivers/pci.hpp>
#include <sched/smp.hpp>
#include <sched/scheduler.hpp>
#include <debug.hpp>
#include <stivale.hpp>
#include <font.hpp>
static stivale *stivale_virt = NULL;
extern "C" void _init();
extern "C" void __cxa_pure_virtual() { for(;;); }
extern "C" int main(size_t stivale_phys) {
cpuid_state cpu_id = cpuid(7, 0);
if(cpu_id.rcx & (1 << 16)) {
vmm::high_vma = 0xff00000000000000;
}
stivale_virt = reinterpret_cast<stivale*>(stivale_phys + vmm::high_vma);
pmm::init(stivale_virt);
kmm::cache(NULL, 0, 32);
kmm::cache(NULL, 0, 64);
kmm::cache(NULL, 0, 128);
kmm::cache(NULL, 0, 256);
kmm::cache(NULL, 0, 512);
kmm::cache(NULL, 0, 1024);
kmm::cache(NULL, 0, 2048);
kmm::cache(NULL, 0, 4096);
kmm::cache(NULL, 0, 8192);
kmm::cache(NULL, 0, 16384);
kmm::cache(NULL, 0, 32768);
kmm::cache(NULL, 0, 65536);
kmm::cache(NULL, 0, 131072);
kmm::cache(NULL, 0, 262144);
vmm::init();
_init();
x86::gdt_init();
x86::idt_init();
new x86::tss;
acpi::rsdp_ptr = (acpi::rsdp*)(stivale_virt->rsdp + vmm::high_vma);
if(acpi::rsdp_ptr->xsdt_addr) {
acpi::xsdt_ptr = (acpi::xsdt*)(acpi::rsdp_ptr->xsdt_addr + vmm::high_vma);
print("[ACPI] xsdt found at {x}\n", (size_t)(acpi::xsdt_ptr));
} else {
acpi::rsdt_ptr = (acpi::rsdt*)(acpi::rsdp_ptr->rsdt_addr + vmm::high_vma);
print("[ACPI] rsdt found at {x}\n", (size_t)(acpi::rsdt_ptr));
}
lib::vector<vmm::region> region_list;
cpu_init_features();
init_hpet();
apic::init();
smp::boot_aps();
dev::init();
tty::screen screen(stivale_virt);
new tty::tty(screen, (uint8_t*)font_bitmap, 16, 8);
asm ("sti");
pci::init();
apic::timer_calibrate(100);
vfs::mount("sd0-0", "/");
const char *argv[] = { "/usr/bin/bash", NULL };
const char *envp[] = {
"HOME=/",
"PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
"TERM=linux",
NULL
};
sched::arguments args(argv, envp);
sched::task *new_task = new sched::task(-1);
new_task->exec("/usr/bin/bash", 0x23, args, vfs::root_cluster->root_node);
for(;;)
asm ("pause");
}
| 22.666667 | 82 | 0.589825 | ethan4984 |
6736e6775cf4db401229a62885c84877683c0d0b | 2,498 | cpp | C++ | Jan-3/src/ofApp.cpp | Lywa/Genuary | 865ef0515eb986a175c565faa1fa56529a70f599 | [
"MIT"
] | 1 | 2022-01-06T09:34:03.000Z | 2022-01-06T09:34:03.000Z | Jan-3/src/ofApp.cpp | Lywa/Genuary | 865ef0515eb986a175c565faa1fa56529a70f599 | [
"MIT"
] | null | null | null | Jan-3/src/ofApp.cpp | Lywa/Genuary | 865ef0515eb986a175c565faa1fa56529a70f599 | [
"MIT"
] | 1 | 2022-01-06T09:34:04.000Z | 2022-01-06T09:34:04.000Z | #include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
smileys.load("images/face_tiny.png");
smileysIcon.load("images/smileys_q.png");
smileysIcon.setImageType(OF_IMAGE_GRAYSCALE);
}
//--------------------------------------------------------------
void ofApp::update(){
ofBackground(255);
}
//--------------------------------------------------------------
void ofApp::draw(){
//smileys.draw(0, 0);
// Code based on OF example: imageLoaderExample
ofPixels & pixels = smileysIcon.getPixels();
ofSetColor(0, 0, 0);
int w = smileysIcon.getWidth();
int h = smileysIcon.getHeight();
float diameter = 10;
for(int y = 0; y < h; y++) {
for(int x = 0; x < w; x++) {
int index = y * w + x;
unsigned char cur = pixels[index];
float size = 1 - ((float) cur / 255);
int xPos = 30 + x * diameter;
int yPos = 30 + y * diameter;
int radius = 0.5 + size * diameter /2 ;
ofDrawCircle(xPos, yPos, radius);
//ofDrawRectangle(xPos, yPos, radius, radius);
}
}
//ofSetColor(255);
//smileysIcon.draw(100, 100, 20, 20);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
| 23.790476 | 64 | 0.367894 | Lywa |
673d4e691c78287353086652ae0a2ba79d09840e | 2,247 | cpp | C++ | src/animation_widget.cpp | CourrierGui/plotcpp | 00b5a94e4c9804cbc441a0bcede67f70cef08a0c | [
"MIT"
] | null | null | null | src/animation_widget.cpp | CourrierGui/plotcpp | 00b5a94e4c9804cbc441a0bcede67f70cef08a0c | [
"MIT"
] | null | null | null | src/animation_widget.cpp | CourrierGui/plotcpp | 00b5a94e4c9804cbc441a0bcede67f70cef08a0c | [
"MIT"
] | null | null | null | #include <animation_widget.hpp>
#include <plotwidget.hpp>
#include <iostream>
#include <QElapsedTimer>
#include <QTimer>
namespace pcpp {
AnimationWidget::AnimationWidget(
int rows, int cols,
QWidget* parent)
: _plot{rows, cols, parent}, _actions{},
_continue{true}, _qtime{new QElapsedTimer}
{
}
void AnimationWidget::init(const std::function<void(PlotWrapper&)>& setup) {
setup(_plot);
}
void AnimationWidget::add(int msec, const Action& action) {
auto* timer = new QTimer{_plot.context().get()};
timer->setInterval(msec);
_actions.push_back({timer, action});
}
void AnimationWidget::start() {
if (!_actions.empty()) {
auto action_it = _actions.begin();
while (action_it != _actions.end()) {
auto action = action_it->second;
auto* timer = action_it->first;
if ((action_it+1) != _actions.end()) {
auto* next_timer = (action_it+1)->first;
QObject::connect(
timer, &QTimer::timeout,
[this, action, timer, next_timer]()
{
if (_continue) {
int64_t time = _qtime->elapsed();
_continue = action(time, _plot);
} else {
timer->stop();
_qtime->start();
_continue = true;
next_timer->start();
}
}
);
} else {
QObject::connect(
timer, &QTimer::timeout,
[this, action, timer]()
{
if (_continue) {
int64_t time = _qtime->elapsed();
_continue = action(time, _plot);
} else {
timer->stop();
_continue = true;
}
}
);
}
++action_it;
}
auto* first_timer = new QTimer{_plot.context().get()};
first_timer->setInterval(5);
QObject::connect(
first_timer, &QTimer::timeout,
[first_timer, this]()
{
first_timer->stop();
_actions.front().first->start();
_qtime->start();
}
);
first_timer->start();
}
_plot.show();
}
} /* end of namespace pcpp */
| 25.827586 | 78 | 0.503783 | CourrierGui |
67441b108ccb6440a5e7333e0263e018224a5db1 | 6,086 | cpp | C++ | Sankore-3.1/src/domain/UBGraphicsEllipseItem.cpp | eaglezzb/rsdc | cce881f6542ff206bf286cf798c8ec8da3b51d50 | [
"MIT"
] | null | null | null | Sankore-3.1/src/domain/UBGraphicsEllipseItem.cpp | eaglezzb/rsdc | cce881f6542ff206bf286cf798c8ec8da3b51d50 | [
"MIT"
] | null | null | null | Sankore-3.1/src/domain/UBGraphicsEllipseItem.cpp | eaglezzb/rsdc | cce881f6542ff206bf286cf798c8ec8da3b51d50 | [
"MIT"
] | null | null | null | /*
* Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA)
*
* This file is part of Open-Sankoré.
*
* Open-Sankoré 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, version 3 of the License,
* with a specific linking exception for the OpenSSL project's
* "OpenSSL" library (or with modified versions of it that use the
* same license as the "OpenSSL" library).
*
* Open-Sankoré 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 Open-Sankoré. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBGraphicsEllipseItem.h"
UB3HEditableGraphicsEllipseItem::UB3HEditableGraphicsEllipseItem(QGraphicsItem* parent):
UB3HEditablesGraphicsBasicShapeItem(parent)
{
// Ellipse has Stroke and Fill capabilities :
initializeStrokeProperty();
initializeFillingProperty();
mRadiusX = 0;
mRadiusY = 0;
}
UB3HEditableGraphicsEllipseItem::~UB3HEditableGraphicsEllipseItem()
{
}
UBItem *UB3HEditableGraphicsEllipseItem::deepCopy() const
{
UB3HEditableGraphicsEllipseItem* copy = new UB3HEditableGraphicsEllipseItem();
copyItemParameters(copy);
return copy;
}
void UB3HEditableGraphicsEllipseItem::copyItemParameters(UBItem *copy) const
{
UB3HEditablesGraphicsBasicShapeItem::copyItemParameters(copy);
UB3HEditableGraphicsEllipseItem *cp = dynamic_cast<UB3HEditableGraphicsEllipseItem*>(copy);
if(cp){
cp->mRadiusX = mRadiusX;
cp->mRadiusY = mRadiusY;
}
}
QPointF UB3HEditableGraphicsEllipseItem::center() const
{
QPointF centre;
centre.setX(pos().x() + mRadiusX);
centre.setY(pos().y() + mRadiusY);
return centre;
}
void UB3HEditableGraphicsEllipseItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
setStyle(painter);
int rx = (mRadiusX < 0 ? -mRadiusX : mRadiusX);
int ry = (mRadiusY < 0 ? -mRadiusY : mRadiusY);
int x = (mRadiusX < 0 ? mRadiusX : 0);
int y = (mRadiusY < 0 ? mRadiusY : 0);
//N/C - NNE - 20140312 : Litle work around for avoid crash under MacOs 10.9
QPainterPath path;
path.addEllipse(QRectF(x*2, y*2, rx*2, ry*2));
painter->drawPath(path);
if(isInEditMode()){
QPen p;
p.setColor(QColor(128, 128, 200));
p.setStyle(Qt::DotLine);
p.setWidth(pen().width());
painter->setPen(p);
painter->setBrush(QBrush());
painter->drawRect(0, 0, mRadiusX*2, mRadiusY*2);
}
}
QRectF UB3HEditableGraphicsEllipseItem::boundingRect() const
{
int x = (mRadiusX < 0 ? mRadiusX : 0);
int y = (mRadiusY < 0 ? mRadiusY : 0);
int rx = (mRadiusX < 0 ? -mRadiusX : mRadiusX);
int ry = (mRadiusY < 0 ? -mRadiusY : mRadiusY);
rx *= 2;
ry *= 2;
x *= 2;
y *= 2;
QRectF rect(x, y, rx, ry);
rect = adjustBoundingRect(rect);
return rect;
}
void UB3HEditableGraphicsEllipseItem::onActivateEditionMode()
{
verticalHandle()->setPos(mRadiusX, mRadiusY*2);
horizontalHandle()->setPos(mRadiusX*2, mRadiusY);
diagonalHandle()->setPos(mRadiusX*2, mRadiusY*2);
}
void UB3HEditableGraphicsEllipseItem::updateHandle(UBAbstractHandle *handle)
{
prepareGeometryChange();
qreal maxSize = handle->radius() * 4;
if(handle->getId() == 1){
//it's the vertical handle
if(handle->pos().y() >= maxSize){
mRadiusY = handle->pos().y() / 2;
}
}else if(handle->getId() == 0){
//it's the horizontal handle
if(handle->pos().x() >= maxSize){
mRadiusX = handle->pos().x() / 2;
}
}else{
//it's the diagonal handle
if(handle->pos().x() >= maxSize && handle->pos().y() >= maxSize){
float ratio = mRadiusY / mRadiusX;
if(mRadiusX > mRadiusY){
mRadiusX = handle->pos().x() / 2;
mRadiusY = ratio * mRadiusX;
}else{
mRadiusY = handle->pos().y() / 2;
mRadiusX = 1/ratio * mRadiusY;
}
}
}
verticalHandle()->setPos(mRadiusX, mRadiusY*2);
horizontalHandle()->setPos(mRadiusX*2, mRadiusY);
diagonalHandle()->setPos(mRadiusX*2, mRadiusY*2);
if(hasGradient()){
QLinearGradient g(QPointF(), QPointF(mRadiusX*2, 0));
g.setColorAt(0, brush().gradient()->stops().at(0).second);
g.setColorAt(1, brush().gradient()->stops().at(1).second);
setBrush(g);
}
}
QPainterPath UB3HEditableGraphicsEllipseItem::shape() const
{
QPainterPath path;
if(isInEditMode()){
path.addRect(boundingRect());
}else{
path.addEllipse(boundingRect());
}
return path;
}
void UB3HEditableGraphicsEllipseItem::setRadiusX(qreal radius)
{
prepareGeometryChange();
mRadiusX = radius;
}
void UB3HEditableGraphicsEllipseItem::setRadiusY(qreal radius)
{
prepareGeometryChange();
mRadiusY = radius;
}
void UB3HEditableGraphicsEllipseItem::setRect(QRectF rect){
prepareGeometryChange();
setPos(rect.topLeft());
mRadiusX = rect.width()/2;
mRadiusY = rect.height()/2;
if(hasGradient()){
QLinearGradient g(QPointF(), QPointF(mRadiusX*2, 0));
g.setColorAt(0, brush().gradient()->stops().at(0).second);
g.setColorAt(1, brush().gradient()->stops().at(1).second);
setBrush(g);
}
}
QRectF UB3HEditableGraphicsEllipseItem::rect() const
{
QRectF r;
r.setTopLeft(pos());
r.setWidth(mRadiusX*2);
r.setHeight(mRadiusY*2);
return r;
}
qreal UB3HEditableGraphicsEllipseItem::radiusX() const
{
return mRadiusX;
}
qreal UB3HEditableGraphicsEllipseItem::radiusY() const
{
return mRadiusY;
}
| 25.464435 | 119 | 0.651002 | eaglezzb |
674773b616afc8e7d9f9b0fb29de3211aa0096cc | 19,627 | cpp | C++ | TransferLogManager.cpp | agomez0207/wdt | d85fd11b14ae835e88cfffe970284fcf42866b18 | [
"BSD-3-Clause"
] | 1 | 2020-07-19T21:21:11.000Z | 2020-07-19T21:21:11.000Z | TransferLogManager.cpp | agomez0207/wdt | d85fd11b14ae835e88cfffe970284fcf42866b18 | [
"BSD-3-Clause"
] | null | null | null | TransferLogManager.cpp | agomez0207/wdt | d85fd11b14ae835e88cfffe970284fcf42866b18 | [
"BSD-3-Clause"
] | null | null | null | /**
* Copyright (c) 2014-present, 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 "TransferLogManager.h"
#include <wdt/WdtConfig.h>
#include "ErrorCodes.h"
#include "WdtOptions.h"
#include "SerializationUtil.h"
#include "Reporting.h"
#include <folly/Range.h>
#include <folly/ScopeGuard.h>
#include <folly/Bits.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <map>
#include <ctime>
#include <iomanip>
namespace facebook {
namespace wdt {
void TransferLogManager::setRootDir(const std::string &rootDir) {
rootDir_ = rootDir;
}
std::string TransferLogManager::getFullPath(const std::string &relPath) {
WDT_CHECK(!rootDir_.empty()) << "Root directory not set";
std::string fullPath = rootDir_;
if (fullPath.back() != '/') {
fullPath.push_back('/');
}
fullPath.append(relPath);
return fullPath;
}
int TransferLogManager::open() {
WDT_CHECK(!rootDir_.empty()) << "Root directory not set";
auto openFlags = O_CREAT | O_WRONLY | O_APPEND;
int fd = ::open(getFullPath(LOG_NAME).c_str(), openFlags, 0644);
if (fd < 0) {
PLOG(ERROR) << "Could not open wdt log";
}
return fd;
}
bool TransferLogManager::openAndStartWriter() {
WDT_CHECK(fd_ == -1) << "Trying to open wdt log multiple times";
fd_ = open();
if (fd_ < 0) {
return false;
} else {
writerThread_ =
std::move(std::thread(&TransferLogManager::writeEntriesToDisk, this));
LOG(INFO) << "Log writer thread started " << fd_;
return true;
}
}
void TransferLogManager::enableLogging() {
loggingEnabled_ = true;
}
int64_t TransferLogManager::timestampInMicroseconds() const {
auto timestamp = Clock::now();
return std::chrono::duration_cast<std::chrono::microseconds>(
timestamp.time_since_epoch()).count();
}
std::string TransferLogManager::getFormattedTimestamp(int64_t timestampMicros) {
// This assumes Clock's epoch is Posix's epoch (1970/1/1)
// to_time_t is unfortunately only on the system_clock and not
// on high_resolution_clock (on MacOS at least it isn't)
time_t seconds = timestampMicros / kMicroToSec;
int microseconds = timestampMicros - seconds * kMicroToSec;
// need 25 bytes to encode date in format mm/dd/yy HH:MM:SS.MMMMMM
char buf[25];
struct tm tm;
localtime_r(&seconds, &tm);
snprintf(buf, sizeof(buf), "%02d/%02d/%02d %02d:%02d:%02d.%06d",
tm.tm_mon + 1, tm.tm_mday, (tm.tm_year % 100), tm.tm_hour, tm.tm_min,
tm.tm_sec, microseconds);
return buf;
}
void TransferLogManager::addLogHeader(const std::string &recoveryId) {
if (!loggingEnabled_ || fd_ < 0) {
return;
}
VLOG(1) << "Adding log header " << LOG_VERSION << " " << recoveryId;
char buf[kMaxEntryLength];
// increment by 2 bytes to later store the total length
char *ptr = buf + sizeof(int16_t);
int64_t size = 0;
ptr[size++] = HEADER;
encodeInt(ptr, size, timestampInMicroseconds());
encodeInt(ptr, size, LOG_VERSION);
encodeString(ptr, size, recoveryId);
folly::storeUnaligned<int16_t>(buf, size);
std::lock_guard<std::mutex> lock(mutex_);
entries_.emplace_back(buf, size + sizeof(int16_t));
}
void TransferLogManager::addFileCreationEntry(const std::string &fileName,
int64_t seqId, int64_t fileSize) {
if (!loggingEnabled_ || fd_ < 0) {
return;
}
VLOG(1) << "Adding file entry to log " << fileName << " " << seqId << " "
<< fileSize;
char buf[kMaxEntryLength];
// increment by 2 bytes to later store the total length
char *ptr = buf + sizeof(int16_t);
int64_t size = 0;
ptr[size++] = FILE_CREATION;
encodeInt(ptr, size, timestampInMicroseconds());
encodeString(ptr, size, fileName);
encodeInt(ptr, size, seqId);
encodeInt(ptr, size, fileSize);
folly::storeUnaligned<int16_t>(buf, size);
std::lock_guard<std::mutex> lock(mutex_);
entries_.emplace_back(buf, size + sizeof(int16_t));
}
void TransferLogManager::addBlockWriteEntry(int64_t seqId, int64_t offset,
int64_t blockSize) {
if (!loggingEnabled_ || fd_ < 0) {
return;
}
VLOG(1) << "Adding block entry to log " << seqId << " " << offset << " "
<< blockSize;
char buf[kMaxEntryLength];
// increment by 2 bytes to later store the total length
char *ptr = buf + sizeof(int16_t);
int64_t size = 0;
ptr[size++] = BLOCK_WRITE;
encodeInt(ptr, size, timestampInMicroseconds());
encodeInt(ptr, size, seqId);
encodeInt(ptr, size, offset);
encodeInt(ptr, size, blockSize);
folly::storeUnaligned<int16_t>(buf, size);
std::lock_guard<std::mutex> lock(mutex_);
entries_.emplace_back(buf, size + sizeof(int16_t));
}
void TransferLogManager::addInvalidationEntry(int64_t seqId) {
if (!loggingEnabled_ || fd_ < 0) {
return;
}
VLOG(1) << "Adding invalidation entry " << seqId;
char buf[kMaxEntryLength];
int64_t size = 0;
encodeInvalidationEntry(buf, size, seqId);
std::lock_guard<std::mutex> lock(mutex_);
entries_.emplace_back(buf, size + sizeof(int16_t));
}
bool TransferLogManager::close() {
if (fd_ < 0) {
return false;
}
if (::close(fd_) != 0) {
PLOG(ERROR) << "Failed to close wdt log " << fd_;
fd_ = -1;
return false;
}
LOG(INFO) << "wdt log closed";
fd_ = -1;
return true;
}
bool TransferLogManager::unlink() {
std::string fullLogName = getFullPath(LOG_NAME);
if (::unlink(fullLogName.c_str()) != 0) {
PLOG(ERROR) << "Could not unlink " << fullLogName;
return false;
}
return true;
}
bool TransferLogManager::closeAndStopWriter() {
if (fd_ < 0) {
return false;
}
{
std::lock_guard<std::mutex> lock(mutex_);
finished_ = true;
conditionFinished_.notify_all();
}
writerThread_.join();
WDT_CHECK(entries_.empty());
if (!close()) {
return false;
}
return true;
}
void TransferLogManager::writeEntriesToDisk() {
WDT_CHECK(fd_ >= 0) << "Writer thread started before the log is opened";
auto &options = WdtOptions::get();
WDT_CHECK(options.transfer_log_write_interval_ms >= 0);
auto waitingTime =
std::chrono::milliseconds(options.transfer_log_write_interval_ms);
std::vector<std::string> entries;
bool finished = false;
while (!finished) {
{
std::unique_lock<std::mutex> lock(mutex_);
conditionFinished_.wait_for(lock, waitingTime);
finished = finished_;
// make a copy of all the entries so that we do not need to hold lock
// during writing
entries = entries_;
entries_.clear();
}
std::string buffer;
// write entries to disk
for (const auto &entry : entries) {
buffer.append(entry);
}
int toWrite = buffer.size();
int written = ::write(fd_, buffer.c_str(), toWrite);
if (written != toWrite) {
PLOG(ERROR) << "Disk write error while writing transfer log " << written
<< " " << toWrite;
close();
return;
}
}
}
bool TransferLogManager::parseLogHeader(char *buf, int16_t entrySize,
int64_t ×tamp, int &version,
std::string &recoveryId) {
folly::ByteRange br((uint8_t *)buf, entrySize);
try {
timestamp = decodeInt(br);
version = decodeInt(br);
if (!decodeString(br, buf, entrySize, recoveryId)) {
return false;
}
} catch (const std::exception &ex) {
LOG(ERROR) << "got exception " << folly::exceptionStr(ex);
return false;
}
return checkForOverflow(br.start() - (uint8_t *)buf, entrySize);
}
bool TransferLogManager::parseFileCreationEntry(char *buf, int16_t entrySize,
int64_t ×tamp,
std::string &fileName,
int64_t &seqId,
int64_t &fileSize) {
folly::ByteRange br((uint8_t *)buf, entrySize);
try {
timestamp = decodeInt(br);
if (!decodeString(br, buf, entrySize, fileName)) {
return false;
}
seqId = decodeInt(br);
fileSize = decodeInt(br);
} catch (const std::exception &ex) {
LOG(ERROR) << "got exception " << folly::exceptionStr(ex);
return false;
}
return checkForOverflow(br.start() - (uint8_t *)buf, entrySize);
}
bool TransferLogManager::parseBlockWriteEntry(char *buf, int16_t entrySize,
int64_t ×tamp,
int64_t &seqId, int64_t &offset,
int64_t &blockSize) {
folly::ByteRange br((uint8_t *)buf, entrySize);
try {
timestamp = decodeInt(br);
seqId = decodeInt(br);
offset = decodeInt(br);
blockSize = decodeInt(br);
} catch (const std::exception &ex) {
LOG(ERROR) << "got exception " << folly::exceptionStr(ex);
return false;
}
return checkForOverflow(br.start() - (uint8_t *)buf, entrySize);
}
bool TransferLogManager::parseInvalidationEntry(char *buf, int16_t entrySize,
int64_t ×tamp,
int64_t &seqId) {
folly::ByteRange br((uint8_t *)buf, entrySize);
try {
timestamp = decodeInt(br);
seqId = decodeInt(br);
} catch (const std::exception &ex) {
LOG(ERROR) << "got exception " << folly::exceptionStr(ex);
return false;
}
return checkForOverflow(br.start() - (uint8_t *)buf, entrySize);
}
void TransferLogManager::encodeInvalidationEntry(char *dest, int64_t &off,
int64_t seqId) {
int64_t oldOffset = off;
char *ptr = dest + off + sizeof(int16_t);
ptr[off++] = ENTRY_INVALIDATION;
encodeInt(ptr, off, timestampInMicroseconds());
encodeInt(ptr, off, seqId);
folly::storeUnaligned<int16_t>(dest, off - oldOffset);
}
bool TransferLogManager::writeInvalidationEntries(
const std::set<int64_t> &seqIds) {
int fd = open();
if (fd < 0) {
return false;
}
char buf[kMaxEntryLength];
for (auto seqId : seqIds) {
int64_t size = 0;
encodeInvalidationEntry(buf, size, seqId);
int toWrite = size + sizeof(int16_t);
int written = ::write(fd, buf, toWrite);
if (written != toWrite) {
PLOG(ERROR) << "Disk write error while writing transfer log " << written
<< " " << toWrite;
::close(fd);
return false;
}
}
if (::fsync(fd) != 0) {
PLOG(ERROR) << "fsync() failed for fd " << fd;
::close(fd);
return false;
}
if (::close(fd) != 0) {
PLOG(ERROR) << "close() failed for fd " << fd;
}
return true;
}
bool TransferLogManager::truncateExtraBytesAtEnd(int fd, int extraBytes) {
LOG(INFO) << "Removing extra " << extraBytes
<< " bytes from the end of transfer log";
struct stat statBuffer;
if (fstat(fd, &statBuffer) != 0) {
PLOG(ERROR) << "fstat failed on fd " << fd;
return false;
}
off_t fileSize = statBuffer.st_size;
if (::ftruncate(fd, fileSize - extraBytes) != 0) {
PLOG(ERROR) << "ftruncate failed for fd " << fd;
return false;
}
return true;
}
bool TransferLogManager::parseAndPrint() {
std::vector<FileChunksInfo> parsedInfo;
return parseVerifyAndFix("", true, parsedInfo);
}
std::vector<FileChunksInfo> TransferLogManager::parseAndMatch(
const std::string &recoveryId) {
std::vector<FileChunksInfo> parsedInfo;
parseVerifyAndFix(recoveryId, false, parsedInfo);
return parsedInfo;
}
bool TransferLogManager::parseVerifyAndFix(
const std::string &recoveryId, bool parseOnly,
std::vector<FileChunksInfo> &parsedInfo) {
WDT_CHECK(parsedInfo.empty()) << "parsedInfo vector must be empty";
std::string fullLogName = getFullPath(LOG_NAME);
int logFd = ::open(fullLogName.c_str(), O_RDONLY);
if (logFd < 0) {
PLOG(ERROR) << "Unable to open transfer log " << fullLogName;
return false;
}
auto errorGuard = folly::makeGuard([&] {
if (logFd >= 0) {
::close(logFd);
}
if (!parseOnly) {
if (::rename(getFullPath(LOG_NAME).c_str(),
getFullPath(BUGGY_LOG_NAME).c_str()) != 0) {
PLOG(ERROR) << "log rename failed " << LOG_NAME << " "
<< BUGGY_LOG_NAME;
}
}
});
std::map<int64_t, FileChunksInfo> fileInfoMap;
std::map<int64_t, int64_t> seqIdToSizeMap;
std::string fileName, logRecoveryId;
int64_t timestamp, seqId, fileSize, offset, blockSize;
int logVersion;
std::set<int64_t> invalidSeqIds;
char entry[kMaxEntryLength];
while (true) {
int16_t entrySize;
int toRead = sizeof(entrySize);
int numRead = ::read(logFd, &entrySize, toRead);
if (numRead < 0) {
PLOG(ERROR) << "Error while reading transfer log " << numRead << " "
<< toRead;
return false;
}
if (numRead == 0) {
break;
}
if (numRead != toRead) {
// extra bytes at the end, most likely part of the previous write
// succeeded partially
if (parseOnly) {
LOG(INFO) << "Extra " << numRead << " bytes at the end of the log";
} else if (!truncateExtraBytesAtEnd(logFd, numRead)) {
return false;
}
break;
}
if (entrySize < 0 || entrySize > kMaxEntryLength) {
LOG(ERROR) << "Transfer log parse error, invalid entry length "
<< entrySize;
return false;
}
numRead = ::read(logFd, entry, entrySize);
if (numRead < 0) {
PLOG(ERROR) << "Error while reading transfer log " << numRead << " "
<< entrySize;
return false;
}
if (numRead == 0) {
break;
}
if (numRead != entrySize) {
if (parseOnly) {
LOG(INFO) << "Extra " << numRead << " bytes at the end of the log";
} else if (!truncateExtraBytesAtEnd(logFd, numRead)) {
return false;
}
break;
}
EntryType type = (EntryType)entry[0];
switch (type) {
case HEADER: {
if (!parseLogHeader(entry + 1, entrySize - 1, timestamp, logVersion,
logRecoveryId)) {
return false;
}
if (logVersion != LOG_VERSION) {
LOG(ERROR) << "Can not parse log version " << logVersion
<< ", parser version " << LOG_VERSION;
return false;
}
if (!parseOnly && recoveryId != logRecoveryId) {
LOG(ERROR)
<< "Current recovery-id does not match with log recovery-id "
<< recoveryId << " " << logRecoveryId;
return false;
}
if (parseOnly) {
std::cout << getFormattedTimestamp(timestamp)
<< " New transfer started, log-version " << logVersion
<< " recovery-id " << logRecoveryId << std::endl;
}
break;
}
case FILE_CREATION: {
if (!parseFileCreationEntry(entry + 1, entrySize - 1, timestamp,
fileName, seqId, fileSize)) {
return false;
}
if (fileInfoMap.find(seqId) != fileInfoMap.end() ||
invalidSeqIds.find(seqId) != invalidSeqIds.end()) {
LOG(ERROR) << "Multiple FILE_CREATION entry for same sequence-id "
<< fileName << " " << seqId << " " << fileSize;
return false;
}
if (parseOnly) {
std::cout << getFormattedTimestamp(timestamp) << " File created "
<< fileName << " seq-id " << seqId << " file-size "
<< fileSize << std::endl;
fileInfoMap.emplace(seqId, FileChunksInfo(seqId, fileName, fileSize));
break;
}
// verify size
bool sizeVerificationSuccess = false;
struct stat buffer;
if (stat(getFullPath(fileName).c_str(), &buffer) != 0) {
PLOG(ERROR) << "stat failed for " << fileName;
} else {
#ifdef HAS_POSIX_FALLOCATE
sizeVerificationSuccess = (buffer.st_size == fileSize);
#else
sizeVerificationSuccess = (buffer.st_size <= fileSize);
#endif
}
if (sizeVerificationSuccess) {
fileInfoMap.emplace(seqId, FileChunksInfo(seqId, fileName, fileSize));
seqIdToSizeMap.emplace(seqId, buffer.st_size);
} else {
LOG(INFO) << "Sanity check failed for " << fileName << " seq-id "
<< seqId << " file-size " << fileSize;
invalidSeqIds.insert(seqId);
}
break;
}
case BLOCK_WRITE: {
if (!parseBlockWriteEntry(entry + 1, entrySize - 1, timestamp, seqId,
offset, blockSize)) {
return false;
}
if (invalidSeqIds.find(seqId) != invalidSeqIds.end()) {
LOG(INFO) << "Block entry for an invalid sequence-id " << seqId
<< ", ignoring";
continue;
}
auto it = fileInfoMap.find(seqId);
if (it == fileInfoMap.end()) {
LOG(ERROR) << "Block entry for unknown sequence-id " << seqId << " "
<< offset << " " << blockSize;
return false;
}
FileChunksInfo &chunksInfo = it->second;
if (parseOnly) {
std::cout << getFormattedTimestamp(timestamp) << " Block written "
<< chunksInfo.getFileName() << " seq-id " << seqId
<< " offset " << offset << " block-size " << blockSize
<< std::endl;
} else {
auto sizeIt = seqIdToSizeMap.find(seqId);
WDT_CHECK(sizeIt != seqIdToSizeMap.end());
if (offset + blockSize > sizeIt->second) {
LOG(ERROR) << "Block end point is greater than file size in disk "
<< chunksInfo.getFileName() << " seq-id " << seqId
<< " offset " << offset << " block-size " << blockSize
<< " file size in disk " << sizeIt->second;
return false;
}
}
chunksInfo.addChunk(Interval(offset, offset + blockSize));
break;
}
case ENTRY_INVALIDATION: {
if (!parseInvalidationEntry(entry + 1, entrySize - 1, timestamp,
seqId)) {
return false;
}
if (fileInfoMap.find(seqId) == fileInfoMap.end() &&
invalidSeqIds.find(seqId) == invalidSeqIds.end()) {
LOG(ERROR) << "Invalidation entry for an unknown sequence id "
<< seqId;
return false;
}
if (parseOnly) {
std::cout << getFormattedTimestamp(timestamp)
<< " Invalidation entry for seq-id " << seqId << std::endl;
}
fileInfoMap.erase(seqId);
invalidSeqIds.erase(seqId);
break;
}
default: {
LOG(ERROR) << "Invalid entry type found " << type;
return false;
}
}
}
if (parseOnly) {
// no need to add invalidation entries in case of invocation from cmd line
return true;
}
if (::close(logFd) != 0) {
PLOG(ERROR) << "close() failed for fd " << logFd;
}
logFd = -1;
if (!invalidSeqIds.empty()) {
if (!writeInvalidationEntries(invalidSeqIds)) {
return false;
}
}
errorGuard.dismiss();
for (auto &pair : fileInfoMap) {
FileChunksInfo &fileInfo = pair.second;
fileInfo.mergeChunks();
parsedInfo.emplace_back(std::move(fileInfo));
}
return true;
}
}
}
| 32.657238 | 80 | 0.590972 | agomez0207 |
6748cabbd113ed004698fdb04af485f3e4f6acf6 | 2,186 | cpp | C++ | src/status.cpp | Nakeib/RonClient | 9e816c580ec2a6f1b15fdefd8e15ad62647ca29f | [
"MIT"
] | 11 | 2020-11-07T19:35:24.000Z | 2021-08-19T12:25:27.000Z | src/status.cpp | Nakeib/RonClient | 9e816c580ec2a6f1b15fdefd8e15ad62647ca29f | [
"MIT"
] | null | null | null | src/status.cpp | Nakeib/RonClient | 9e816c580ec2a6f1b15fdefd8e15ad62647ca29f | [
"MIT"
] | 5 | 2020-11-06T20:52:11.000Z | 2021-02-25T11:02:31.000Z | /* -------------------------------------------------------------------------- */
/* ------------- RonClient --- Oficial client for RonOTS servers ------------ */
/* -------------------------------------------------------------------------- */
#include "status.h"
#include "allocator.h"
#include "icons.h"
#include "window.h"
// ---- Status ---- //
MUTEX Status::lockStatus;
Status::Status() {
icons = 0;
container = NULL;
}
Status::~Status() { }
void Status::SetIcons(unsigned short icons) {
this->icons = icons;
}
unsigned short Status::GetIcons() {
return icons;
}
void Status::SetPeriod(unsigned char id, unsigned int period) {
LOCKCLASS lockClass(lockStatus);
time_lt now = RealTime::getTime();
std::map<unsigned char, StatusTime>::iterator it = times.find(id);
if (it != times.end()) {
StatusTime stime = it->second;
if (abs((long)(stime.first + stime.second) - (long)(now + period)) > 1000)
times[id] = StatusTime(now, period);
}
else
times[id] = StatusTime(now, period);
}
void Status::SetContainer(WindowElementContainer* container) {
LOCKCLASS lockClass(lockStatus);
this->container = container;
}
void Status::UpdateContainer() {
LOCKCLASS lockClass1(Windows::lockWindows);
LOCKCLASS lockClass2(lockStatus);
if (!container)
return;
container->DeleteAllElements();
Window* window = container->GetWindow();
WindowTemplate* wndTemplate = window->GetWindowTemplate();
window->SetActiveElement(NULL);
POINT size_int = window->GetWindowContainer()->GetIntSize();
POINT size_ext = container->GetIntSize();
int num = 0;
for (int i = 0; i < 15; i++) {
if (icons & (1 << i)) {
StatusTime stime(0, 0);
std::map<unsigned char, StatusTime>::iterator it = times.find(i + 1);
if (it != times.end())
stime = it->second;
AD2D_Image* image = Icons::GetStatusIcon(i + 1);
WindowElementCooldown* wstatus = new(M_PLACE) WindowElementCooldown;
wstatus->Create(0, 0, num * 32, 32, 32, wndTemplate);
wstatus->SetCast(stime.first, stime.second);
wstatus->SetIcon(image);
container->AddElement(wstatus);
num++;
}
}
container->SetPosition(0, size_int.y - num * 32);
container->SetSize(32, num * 32);
}
| 23.505376 | 80 | 0.618939 | Nakeib |
674a7eb21be0415058f79fdae32ac00ef058376d | 1,664 | hpp | C++ | Router/Data/Route_Stop_Data.hpp | kravitz/transims4 | ea0848bf3dc71440d54724bb3ecba3947b982215 | [
"NASA-1.3"
] | 2 | 2018-04-27T11:07:02.000Z | 2020-04-24T06:53:21.000Z | Router/Data/Route_Stop_Data.hpp | idkravitz/transims4 | ea0848bf3dc71440d54724bb3ecba3947b982215 | [
"NASA-1.3"
] | null | null | null | Router/Data/Route_Stop_Data.hpp | idkravitz/transims4 | ea0848bf3dc71440d54724bb3ecba3947b982215 | [
"NASA-1.3"
] | null | null | null | //*********************************************************
// Route_Stop_Data.hpp - transit route stop data classes
//*********************************************************
#ifndef ROUTE_STOP_DATA_HPP
#define ROUTE_STOP_DATA_HPP
#include "Data_Array.hpp"
//---------------------------------------------------------
// Route_Stop_Data class definition
//---------------------------------------------------------
class Route_Stop_Data
{
public:
Route_Stop_Data (void);
int Route (void) { return (route); }
int Stop (void) { return (stop); }
int List (void) { return (list); }
void Route (int value) { route = (short) value; }
void Stop (int value) { stop = (short) value; }
void List (int value) { list = value; }
private:
short route;
short stop;
int list;
};
//---------------------------------------------------------
// Route_Stop_Array
//---------------------------------------------------------
class Route_Stop_Array : public Data_Array
{
public:
Route_Stop_Array (int max_records = 0);
bool Add (Route_Stop_Data *data) { return (Data_Array::Add ((void *) data)); }
Route_Stop_Data * First (void) { return ((Route_Stop_Data *) Data_Array::First ()); }
Route_Stop_Data * Next (void) { return ((Route_Stop_Data *) Data_Array::Next ()); }
Route_Stop_Data * Last (void) { return ((Route_Stop_Data *) Data_Array::Last ()); }
Route_Stop_Data * Previous (void) { return ((Route_Stop_Data *) Data_Array::Previous ()); }
Route_Stop_Data * operator[] (int index) { return ((Route_Stop_Data *) Record (index)); }
};
#endif
| 30.814815 | 100 | 0.497596 | kravitz |
6750116edd11d113a2610814ba8adbaca4bcf5b5 | 4,518 | cpp | C++ | src/main.cpp | scaryrawr/tofi | 15b3757c4d492d5bbc7f57aef94f582549d2bef3 | [
"MIT"
] | 1 | 2020-08-03T18:57:01.000Z | 2020-08-03T18:57:01.000Z | src/main.cpp | scaryrawr/tofi | 15b3757c4d492d5bbc7f57aef94f582549d2bef3 | [
"MIT"
] | 1 | 2021-03-07T21:32:10.000Z | 2021-03-08T13:56:10.000Z | src/main.cpp | scaryrawr/tofi | 15b3757c4d492d5bbc7f57aef94f582549d2bef3 | [
"MIT"
] | null | null | null | #include <TofiConfig.h>
#include "tofi.h"
#include "modes/dmenu.h"
#ifdef GIOMM_FOUND
#include "modes/drun.h"
#endif
#ifdef I3IPC_FOUND
#include "modes/i3wm.h"
#endif
#ifdef GTKMM_FOUND
#include "modes/recent.h"
#endif
#include "modes/run.h"
#include "modes/script.h"
#include <getopt.h>
#include <ftxui/component/screen_interactive.hpp>
#include <mtl/string.hpp>
struct LaunchMode
{
std::string_view mode;
std::optional<std::string_view> script;
};
struct LaunchOptions
{
bool dmenu{};
std::vector<LaunchMode> modes;
};
void help()
{
std::cout << "tofi usage:" << std::endl
<< "\ttofi [--options]" << std::endl
<< "Options:" << std::endl;
std::cout << "\t-d, --dmenu\tRun in dmenu mode" << std::endl;
std::cout << "\t-m, --modes\tStart with modes enabled [drun,run,i3wm]" << std::endl
<< "\t-h, --help \tDisplay this message" << std::endl
<< "Modes:" << std::endl;
#ifdef GIOMM_FOUND
std::cout << "\tdrun\tRun from list of desktop installed applications" << std::endl;
#endif
#ifdef GTKMM_FOUND
std::cout << "\recent\tOpen a recently opened file" << std::endl;
#endif
std::cout << "\trun \tRun from binaries on $PATH" << std::endl;
#ifdef I3IPC_FOUND
std::cout << "\ti3wm\tSwitch between active windows using i3ipc" << std::endl;
#endif
std::cout << "Script:" << std::endl
<< "\tPass a custom command disp:command" << std::endl
<< "\t\t -m list:ls" << std::endl
<< std::endl
<< "\tcommand will be called with selected result" << std::endl
<< "\ttofi will stay open as long as command prints output" << std::endl;
exit(-1);
}
LaunchOptions parse_args(int argc, char **argv)
{
LaunchOptions launch{};
enum class Option
{
modes,
dmenu,
help,
};
static option options[] = {
{"modes", required_argument, nullptr, 0},
{"dmenu", no_argument, nullptr, 0},
{"help", no_argument, nullptr, 0},
};
for (int index{}, code{getopt_long(argc, argv, "m:dh", options, &index)}; code >= 0; code = getopt_long(argc, argv, "m:dh", options, &index))
{
switch (code)
{
case 'd':
index = static_cast<int>(Option::dmenu);
break;
case 'm':
index = static_cast<int>(Option::modes);
break;
case 'h':
index = static_cast<int>(Option::help);
break;
}
switch (static_cast<Option>(index))
{
case Option::dmenu:
{
launch.dmenu = true;
break;
}
case Option::modes:
{
std::vector<std::string_view> modes;
mtl::string::split(optarg, ",", std::back_inserter(modes));
launch.modes.reserve(modes.size());
std::transform(std::begin(modes), std::end(modes), std::back_inserter(launch.modes), [](std::string_view mode) {
std::vector<std::string_view> parts;
parts.reserve(2);
mtl::string::split(mode, ":", std::back_inserter(parts));
return parts.size() == 1 ? LaunchMode{parts[0], std::nullopt} : LaunchMode{parts[0], parts[1]};
});
break;
}
case Option::help:
{
help();
break;
}
}
}
return launch;
}
int main(int argc, char **argv)
{
LaunchOptions options{parse_args(argc, argv)};
tofi::Modes modes;
// If we're in dmenu mode, other modes might break, so... just dmenu
if (options.dmenu)
{
modes.emplace_back(std::make_unique<tofi::modes::dmenu>());
}
else
{
std::transform(std::begin(options.modes), std::end(options.modes), std::back_inserter(modes), [](const LaunchMode &mode) -> std::unique_ptr<tofi::Mode> {
if (mode.script.has_value())
{
return std::make_unique<tofi::modes::script>(mode.mode, mode.script.value());
}
#ifdef I3IPC_FOUND
if ("i3wm" == mode.mode)
{
return std::make_unique<tofi::modes::i3wm>("tofi");
}
#endif
if ("run" == mode.mode)
{
return std::make_unique<tofi::modes::run>();
}
#ifdef GIOMM_FOUND
if ("drun" == mode.mode)
{
return std::make_unique<tofi::modes::drun>();
}
#endif
#ifdef GTKMM_FOUND
if ("recent" == mode.mode)
{
return std::make_unique<tofi::modes::recent>();
}
#endif
return nullptr;
});
}
modes.erase(std::remove(std::begin(modes), std::end(modes), nullptr), std::end(modes));
if (modes.empty())
{
// We don't have any modes, so show user help.
help();
}
// Use active wal theme if available
system("[ -f $HOME/.cache/wal/sequences ] && cat $HOME/.cache/wal/sequences");
tofi::Tofi tofi{std::move(modes)};
int exit{};
auto screen = ftxui::ScreenInteractive::TerminalOutput();
tofi.on_exit = [&exit, &screen](int code) {
exit = code;
screen.ExitLoopClosure()();
};
screen.Loop(&tofi);
return exit;
}
| 22.366337 | 155 | 0.634794 | scaryrawr |
67510af1134b5530b703475985ce9f9b695fc754 | 3,147 | cpp | C++ | SceneServer/SSBattleMgr/SSProfileStatics.cpp | tsymiar/---- | 90e21cbfe7b3bc730c998e9f5ef87aa3581e357a | [
"Unlicense"
] | 6 | 2019-07-15T23:55:15.000Z | 2020-09-07T15:07:54.000Z | SceneServer/SSBattleMgr/SSProfileStatics.cpp | j1527156/BattleServer | 68c9146bf35e93dfd5a175b46e9761ee3c7c0d04 | [
"Unlicense"
] | null | null | null | SceneServer/SSBattleMgr/SSProfileStatics.cpp | j1527156/BattleServer | 68c9146bf35e93dfd5a175b46e9761ee3c7c0d04 | [
"Unlicense"
] | 7 | 2019-07-15T23:55:24.000Z | 2021-08-10T07:49:05.000Z | #include "StdAfx.h"
#include "SSProfileStatics.h"
#include <iostream>
#include <fstream>
#include "SSWorkThreadMgr.h"
#include <iomanip>
namespace SceneServer{
CSSProfileStatics::CSSProfileStatics(void):m_LastMsgShow(0)
{
}
CSSProfileStatics::~CSSProfileStatics(void)
{
}
void CSSProfileStatics::Begin(StaticsType aType){
auto iter = m_ProfileMap.find(aType);
TIME_MILSEC now = GetWinMiliseconds();
if (iter == m_ProfileMap.end()){
ProfileData lProfileData;
lProfileData.beginTime = now;
switch(aType){
case StaticsType_NPCLookEnemy:
lProfileData.debugString = "NPCLookEnemy";
break;
case StaticsType_Move:
lProfileData.debugString = "Move";
break;
case StaticsType_Sight:
lProfileData.debugString = "Sight";
break;
}
m_ProfileMap.insert(std::make_pair(aType, lProfileData));
}
else{
iter->second.beginTime = now;
}
}
void CSSProfileStatics::End(StaticsType aType){
auto iter = m_ProfileMap.find(aType);
TIME_MILSEC now = GetWinMiliseconds();
if (iter != m_ProfileMap.end()){
iter->second.tottime += now - iter->second.beginTime;
iter->second.beginTime = 0;
}
}
CSSProfileStatics& CSSProfileStatics::GetInstance(){
static CSSProfileStatics lCSSProfileStatics;
return lCSSProfileStatics;
}
void CSSProfileStatics::GetProfileReport(wstringstream &report){
if (!CSSWorkThreadMgr::GetInstance().m_IfStatics){
return;
}
//if (CSSWorkThreadMgr::GetInstance().GetKernel()->GetHeartBeatUTCMilsec() - m_LastMsgShow < CSSWorkThreadMgr::GetInstance().m_MsgStaticsInterval){
// return;
//}
stringstream lTestStream;
//m_LastMsgShow = CSSWorkThreadMgr::GetInstance().GetKernel()->GetHeartBeatUTCMilsec();
//for (auto iter = m_ProfileMap.begin(); iter != m_ProfileMap.end(); ++iter){
// ProfileData& lProfileData = iter->second;
// if (lProfileData.tottime != 0){
// lTestStream << " " << setw(7) << lProfileData.debugString.c_str() << ":" << lProfileData.tottime;
// lProfileData.tottime = 0;
// }
//}
int i = 0;
set<MsgInterval> tempSet;
for (auto iter = m_TotNumForPerMsg.begin(); iter != m_TotNumForPerMsg.end(); ++iter){
MsgInterval lMsgInterval(iter->first, iter->second);
tempSet.insert(lMsgInterval);
}
int max = CSSWorkThreadMgr::GetInstance().m_MaxStatisMsgToShow;
for (auto iter = tempSet.begin(); iter != tempSet.end(); ++iter){
if (i > max){
break;
}
++i;
lTestStream << " " << setw(7) << iter->msgid << "," << iter->msgnum;
}
if (!lTestStream.str().empty()){
ELOG(LOG_SpecialDebug, "%s", lTestStream.str().c_str());
}
}
void CSSProfileStatics::AddMsg(int Msgid){
if (!CSSWorkThreadMgr::GetInstance().m_IfStatics){
return;
}
auto iter = m_TotNumForPerMsg.find(Msgid);
if (iter == m_TotNumForPerMsg.end()){
m_TotNumForPerMsg.insert(std::make_pair(Msgid, 1));
}
else{
++iter->second;
}
}
ProfileInScope::ProfileInScope(StaticsType aType):m_Type(aType){
if (!CSSWorkThreadMgr::GetInstance().m_IfStatics){
return;
}
CSSProfileStatics::GetInstance().Begin(m_Type);
}
ProfileInScope::~ProfileInScope(){
if (!CSSWorkThreadMgr::GetInstance().m_IfStatics){
return;
}
CSSProfileStatics::GetInstance().End(m_Type);
}
} | 24.779528 | 148 | 0.71306 | tsymiar |
677683951ea683a30b3a06aa27a6d6031be6b75e | 77,473 | cpp | C++ | source/game/gamesys/SysCvar.cpp | JasonHutton/QWTA | 7f42dc70eb230cf69a8048fc98d647a486e752f1 | [
"MIT"
] | 2 | 2021-05-02T18:37:48.000Z | 2021-07-18T16:18:14.000Z | source/game/gamesys/SysCvar.cpp | JasonHutton/QWTA | 7f42dc70eb230cf69a8048fc98d647a486e752f1 | [
"MIT"
] | null | null | null | source/game/gamesys/SysCvar.cpp | JasonHutton/QWTA | 7f42dc70eb230cf69a8048fc98d647a486e752f1 | [
"MIT"
] | null | null | null | // Copyright (C) 2007 Id Software, Inc.
//
#include "../precompiled.h"
#pragma hdrstop
#if defined( _DEBUG ) && !defined( ID_REDIRECT_NEWDELETE )
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "../../framework/BuildVersion.h"
#include "../../framework/BuildDefines.h"
#include "../../framework/Licensee.h"
#include "../rules/GameRules.h"
#if defined( _DEBUG )
#define BUILD_DEBUG "(debug)"
#else
#define BUILD_DEBUG ""
#endif
/*
All game cvars should be defined here.
*/
struct gameVersion_t {
static const int strSize = 256;
gameVersion_t( void ) {
idStr::snPrintf( string, strSize, "%s %d.%d.%d.%d %s %s %s %s", GAME_NAME, ENGINE_VERSION_MAJOR, ENGINE_VERSION_MINOR, ENGINE_SRC_REVISION, ENGINE_MEDIA_REVISION, BUILD_DEBUG, BUILD_STRING, __DATE__, __TIME__ );
string[ strSize - 1 ] = '\0';
}
char string[strSize];
} gameVersion;
#define MOD_NAME "QWTA"
#define MOD_VERSION_MAJOR 0
#define MOD_VERSION_MINOR 3
#define MOD_VERSION_REVISION 5
struct modVersion_t {
static const int strSize = 256;
modVersion_t( void ) {
idStr::snPrintf( string, strSize, "%s %d.%d.%d", MOD_NAME, MOD_VERSION_MAJOR, MOD_VERSION_MINOR, MOD_VERSION_REVISION );
}
char string[strSize];
} modVersion;
idCVar g_version( "g_version", gameVersion.string, CVAR_GAME | CVAR_ROM, "game version" );
idCVar g_modVersion( "g_modVersion", modVersion.string, CVAR_GAME | CVAR_ROM, "mod version" );
// noset vars
idCVar gamename( "gamename", GAME_VERSION, CVAR_GAME | CVAR_SERVERINFO | CVAR_ROM, "" );
idCVar gamedate( "gamedate", __DATE__, CVAR_GAME | CVAR_ROM, "" );
// server info
idCVar si_name( "si_name", GAME_NAME " Server", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "name of the server" );
idCVar si_maxPlayers( "si_maxPlayers", "24", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_RANKLOCKED, "max number of players allowed on the server", 1, static_cast< float >( MAX_CLIENTS ) );
idCVar si_privateClients( "si_privateClients", "0", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_INTEGER, "max number of private players allowed on the server", 0, static_cast< float >( MAX_CLIENTS ) );
idCVar si_teamDamage( "si_teamDamage", "1", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL | CVAR_RANKLOCKED, "enable team damage" );
idCVar si_needPass( "si_needPass", "0", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL | CVAR_RANKLOCKED, "enable client password checking" );
idCVar si_pure( "si_pure", "1", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL | CVAR_RANKLOCKED, "server is pure and does not allow modified data" );
idCVar si_spectators( "si_spectators", "1", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL, "allow spectators or require all clients to play" );
idCVar si_rules( "si_rules", "sdGameRulesCampaign", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_RANKLOCKED, "ruleset for game", sdGameRules::ArgCompletion_RuleTypes );
idCVar si_timeLimit( "si_timelimit", "20", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_RANKLOCKED, "time limit (mins)" );
idCVar si_map( "si_map", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ROM, "current active map" );
idCVar si_campaign( "si_campaign", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ROM, "current active campaign" );
idCVar si_campaignInfo( "si_campaignInfo", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ROM, "current campaign map info" );
idCVar si_tactical( "si_tactical", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ROM, "current active tactical" );
idCVar si_tacticalInfo( "si_tacticalInfo", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ROM, "current tactical map info" );
idCVar si_teamForceBalance( "si_teamForceBalance", "1", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL | CVAR_RANKLOCKED, "Stop players from unbalancing teams" );
idCVar si_website( "si_website", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "website info" );
idCVar si_adminname( "si_adminname", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "admin name(s)" );
idCVar si_email( "si_email", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "contact email address" );
idCVar si_irc( "si_irc", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "IRC channel" );
idCVar si_motd_1( "si_motd_1", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "motd line 1" );
idCVar si_motd_2( "si_motd_2", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "motd line 2" );
idCVar si_motd_3( "si_motd_3", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "motd line 3" );
idCVar si_motd_4( "si_motd_4", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "motd line 4" );
idCVar si_adminStart( "si_adminStart", "0", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_RANKLOCKED, "admin required to start the match" );
idCVar si_disableVoting( "si_disableVoting", "0", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "disable/enable all voting" );
idCVar si_readyPercent( "si_readyPercent", "51", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_RANKLOCKED, "percentage of players that need to ready up to start a match" );
idCVar si_minPlayers( "si_minPlayers", "6", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_RANKLOCKED, "minimum players before a game can be started" );
idCVar si_allowLateJoin( "si_allowLateJoin", "1", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL, "Enable/disable players joining a match in progress" );
idCVar si_noProficiency( "si_noProficiency", "0", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL | CVAR_RANKLOCKED, "enable/disable XP" );
idCVar si_disableGlobalChat( "si_disableGlobalChat", "0", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL | CVAR_RANKLOCKED, "disable global text communication" );
idCVar si_gameReviewReadyWait( "si_gameReviewReadyWait", "0", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_BOOL, "wait for players to ready up before going to the next map" );
idCVar si_serverURL( "si_serverURL", "", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "server information page" );
idCVar* si_motd_cvars[] = {
&si_motd_1, &si_motd_2, &si_motd_3, &si_motd_4,
};
// user info
idCVar ui_name( "ui_name", "Player", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE, "player name" );
idCVar ui_clanTag( "ui_clanTag", "", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE, "player clan tag" );
idCVar ui_clanTagPosition( "ui_clanTagPosition", "0", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_INTEGER, "positioning of player clan tag. 0 is before their name, 1 is after" );
idCVar ui_showGun( "ui_showGun", "1", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "show gun" );
idCVar ui_autoSwitchEmptyWeapons( "ui_autoSwitchEmptyWeapons", "1", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, will switch to the next usable weapon when the current weapon runs out of ammo" );
idCVar ui_ignoreExplosiveWeapons( "ui_ignoreExplosiveWeapons", "1", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, weapons marked as explosive will be ignored during auto-switches" );
idCVar ui_postArmFindBestWeapon( "ui_postArmFindBestWeapon", "0", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, after arming players' best weapon will be selected" );
idCVar ui_advancedFlightControls( "ui_advancedFlightControls", "0", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, advanced flight controls are activated" );
idCVar ui_rememberCameraMode( "ui_rememberCameraMode", "0", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "use same camera mode as was previously used when re-entering a vehicle" );
idCVar ui_drivingCameraFreelook( "ui_drivingCameraFreelook", "0", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, driving cameras where there is no weapon defaults to freelook" );
idCVar ui_voipReceiveGlobal( "ui_voipReceiveGlobal", "0", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, receive voice chat sent to the global channel" );
idCVar ui_voipReceiveTeam( "ui_voipReceiveTeam", "1", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, receive voice chat sent to the team channel" );
idCVar ui_voipReceiveFireTeam( "ui_voipReceiveFireTeam", "1", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, receive voice chat sent to the fireteam channel" );
idCVar ui_showComplaints( "ui_showComplaints", "1", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, receive complaints popups for team kills" );
idCVar ui_swapFlightYawAndRoll( "ui_swapFlightYawAndRoll", "0", CVAR_GAME | CVAR_PROFILE | CVAR_USERINFO | CVAR_ARCHIVE | CVAR_BOOL, "if true, swaps the yaw & roll controls for flying vehicles - mouse becomes yaw and keys become roll" );
// change anytime vars
idCVar g_decals( "g_decals", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_BOOL, "show decals such as bullet holes" );
idCVar g_knockback( "g_knockback", "1", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_gravity( "g_gravity", DEFAULT_GRAVITY_STRING, CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_disasm( "g_disasm", "0", CVAR_GAME | CVAR_BOOL, "disassemble script into base/script/disasm.txt on the local drive when script is compiled" );
idCVar g_debugBounds( "g_debugBounds", "0", CVAR_GAME | CVAR_BOOL, "checks for models with bounds > 2048" );
idCVar g_debugAnim( "g_debugAnim", "-1", CVAR_GAME | CVAR_INTEGER, "displays information on which animations are playing on the specified entity number. set to -1 to disable." );
idCVar g_debugAnimStance( "g_debugAnimStance", "-1", CVAR_GAME | CVAR_INTEGER, "displays information on which stances are set on the specified entity number. set to -1 to disable." );
idCVar g_debugDamage( "g_debugDamage", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_debugWeapon( "g_debugWeapon", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_debugWeaponSpread( "g_debugWeaponSpread", "0", CVAR_GAME | CVAR_BOOL, "displays the current spread value for the weapon" );
idCVar g_debugScript( "g_debugScript", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_debugCinematic( "g_debugCinematic", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_debugPlayerList( "g_debugPlayerList", "0", CVAR_GAME | CVAR_INTEGER, "fills UI lists with fake players" );
idCVar g_showPVS( "g_showPVS", "0", CVAR_GAME | CVAR_INTEGER, "", 0, 2 );
idCVar g_showTargets( "g_showTargets", "0", CVAR_GAME | CVAR_BOOL, "draws entities and their targets. hidden entities are drawn grey." );
idCVar g_showTriggers( "g_showTriggers", "0", CVAR_GAME | CVAR_BOOL, "draws trigger entities (orange) and their targets (green). disabled triggers are drawn grey." );
idCVar g_showCollisionWorld( "g_showCollisionWorld", "0", CVAR_GAME | CVAR_INTEGER, "" );
idCVar g_showVehiclePathNodes( "g_showVehiclePathNodes", "0", CVAR_GAME | CVAR_INTEGER, "" );
idCVar g_showCollisionModels( "g_showCollisionModels", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_showRenderModelBounds( "g_showRenderModelBounds", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_collisionModelMask( "g_collisionModelMask", "-1", CVAR_GAME | CVAR_INTEGER, "" );
idCVar g_showCollisionTraces( "g_showCollisionTraces", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_showClipSectors( "g_showClipSectors", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_showClipSectorFilter( "g_showClipSectorFilter", "0", CVAR_GAME, "" );
idCVar g_showAreaClipSectors( "g_showAreaClipSectors", "0", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_maxShowDistance( "g_maxShowDistance", "128", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_showEntityInfo( "g_showEntityInfo", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_showcamerainfo( "g_showcamerainfo", "0", CVAR_GAME, "displays the current frame # for the camera when playing cinematics" );
idCVar g_showTestModelFrame( "g_showTestModelFrame", "0", CVAR_GAME | CVAR_BOOL, "displays the current animation and frame # for testmodels" );
idCVar g_showActiveEntities( "g_showActiveEntities", "0", CVAR_GAME | CVAR_BOOL, "draws boxes around thinking entities. " );
idCVar g_debugMask( "g_debugMask", "", CVAR_GAME, "debugs a deployment mask" );
idCVar g_debugLocations( "g_debugLocations", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_showActiveDeployZones( "g_showActiveDeployZones", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_disableVehicleSpawns( "g_disableVehicleSpawns", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT | CVAR_RANKLOCKED, "disables vehicles spawning from construction pads" );
idCVar g_frametime( "g_frametime", "0", CVAR_GAME | CVAR_BOOL, "displays timing information for each game frame" );
//idCVar g_timeentities( "g_timeEntities", "0", CVAR_GAME | CVAR_FLOAT, "when non-zero, shows entities whose think functions exceeded the # of milliseconds specified" );
//idCVar g_timetypeentities( "g_timeTypeEntities", "", CVAR_GAME, "" );
idCVar ai_debugScript( "ai_debugScript", "-1", CVAR_GAME | CVAR_INTEGER, "displays script calls for the specified monster entity number" );
idCVar ai_debugAnimState( "ai_debugAnimState", "-1", CVAR_GAME | CVAR_INTEGER, "displays animState changes for the specified monster entity number" );
idCVar ai_debugMove( "ai_debugMove", "0", CVAR_GAME | CVAR_BOOL, "draws movement information for monsters" );
idCVar ai_debugTrajectory( "ai_debugTrajectory", "0", CVAR_GAME | CVAR_BOOL, "draws trajectory tests for monsters" );
idCVar g_kickTime( "g_kickTime", "1", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_kickAmplitude( "g_kickAmplitude", "0.0001", CVAR_GAME | CVAR_FLOAT, "" );
//idCVar g_blobTime( "g_blobTime", "1", CVAR_GAME | CVAR_FLOAT, "" );
//idCVar g_blobSize( "g_blobSize", "1", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_editEntityMode( "g_editEntityMode", "0", CVAR_GAME | CVAR_INTEGER, "0 = off\n"
"1 = lights\n"
"2 = sounds\n"
"3 = articulated figures\n"
"4 = particle systems\n"
"5 = monsters\n"
"6 = entity names\n"
"7 = entity models", 0, 7, idCmdSystem::ArgCompletion_Integer<0,7> );
idCVar g_dragEntity( "g_dragEntity", "0", CVAR_GAME | CVAR_BOOL, "allows dragging physics objects around by placing the crosshair over them and holding the fire button" );
idCVar g_dragDamping( "g_dragDamping", "0.5", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_dragMaxforce( "g_dragMaxforce", "5000000", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_dragShowSelection( "g_dragShowSelection", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_vehicleVelocity( "g_vehicleVelocity", "1000", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_vehicleForce( "g_vehicleForce", "50000", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_vehicleSuspensionUp( "g_vehicleSuspensionUp", "32", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_vehicleSuspensionDown( "g_vehicleSuspensionDown", "20", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_vehicleSuspensionKCompress("g_vehicleSuspensionKCompress","200", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_vehicleSuspensionDamping( "g_vehicleSuspensionDamping","400", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_vehicleTireFriction( "g_vehicleTireFriction", "0.8", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_commandMapZoomStep( "g_commandMapZoomStep", "0.125", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "percent to increase/decrease command map zoom by" );
idCVar g_commandMapZoom( "g_commandMapZoom", "0.25", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "command map zoom level", 0.125f, 0.75f );
idCVar g_showPlayerSpeed( "g_showPlayerSpeed", "0", CVAR_GAME | CVAR_BOOL, "displays player movement speed" );
idCVar m_helicopterPitch( "m_helicopterPitch", "-0.022", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "helicopter mouse pitch scale" );
idCVar m_helicopterYaw( "m_helicopterYaw", "0.022", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "helicopter mouse yaw scale" );
idCVar m_helicopterPitchScale( "m_helicopterPitchScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for Anansi/Tormentor pitch" );
idCVar m_helicopterYawScale( "m_helicopterYawScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for Anansi/Tormentor yaw" );
idCVar m_bumblebeePitchScale( "m_bumblebeePitchScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for Bumblebee pitch" );
idCVar m_bumblebeeYawScale( "m_bumblebeeYawScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for Bumblebee yaw" );
idCVar m_lightVehiclePitchScale( "m_lightVehiclePitchScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for Husky/Armadillo/Hog/Trojan pitch" );
idCVar m_lightVehicleYawScale( "m_lightVehicleYawScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for Husky/Armadillo/Hog/Trojan yaw" );
idCVar m_heavyVehiclePitchScale( "m_heavyVehiclePitchScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for Titan/Cyclops pitch" );
idCVar m_heavyVehicleYawScale( "m_heavyVehicleYawScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for Titan/Cyclops yaw" );
idCVar m_playerPitchScale( "m_playerPitchScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for player pitch" );
idCVar m_playerYawScale( "m_playerYawScale", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NOCHEAT, "sensitivity scale (over base) for player yaw" );
idCVar ik_enable( "ik_enable", "1", CVAR_GAME | CVAR_BOOL, "enable IK" );
idCVar ik_debug( "ik_debug", "0", CVAR_GAME | CVAR_BOOL, "show IK debug lines" );
idCVar af_useLinearTime( "af_useLinearTime", "1", CVAR_GAME | CVAR_BOOL, "use linear time algorithm for tree-like structures" );
idCVar af_useImpulseFriction( "af_useImpulseFriction", "0", CVAR_GAME | CVAR_BOOL, "use impulse based contact friction" );
idCVar af_useJointImpulseFriction( "af_useJointImpulseFriction","0", CVAR_GAME | CVAR_BOOL, "use impulse based joint friction" );
idCVar af_useSymmetry( "af_useSymmetry", "1", CVAR_GAME | CVAR_BOOL, "use constraint matrix symmetry" );
idCVar af_skipSelfCollision( "af_skipSelfCollision", "0", CVAR_GAME | CVAR_BOOL, "skip self collision detection" );
idCVar af_skipLimits( "af_skipLimits", "0", CVAR_GAME | CVAR_BOOL, "skip joint limits" );
idCVar af_skipFriction( "af_skipFriction", "0", CVAR_GAME | CVAR_BOOL, "skip friction" );
idCVar af_forceFriction( "af_forceFriction", "-1", CVAR_GAME | CVAR_FLOAT, "force the given friction value" );
idCVar af_maxLinearVelocity( "af_maxLinearVelocity", "128", CVAR_GAME | CVAR_FLOAT, "maximum linear velocity" );
idCVar af_maxAngularVelocity( "af_maxAngularVelocity", "1.57", CVAR_GAME | CVAR_FLOAT, "maximum angular velocity" );
idCVar af_timeScale( "af_timeScale", "1", CVAR_GAME | CVAR_FLOAT, "scales the time" );
idCVar af_jointFrictionScale( "af_jointFrictionScale", "0", CVAR_GAME | CVAR_FLOAT, "scales the joint friction" );
idCVar af_contactFrictionScale( "af_contactFrictionScale", "0", CVAR_GAME | CVAR_FLOAT, "scales the contact friction" );
idCVar af_highlightBody( "af_highlightBody", "", CVAR_GAME, "name of the body to highlight" );
idCVar af_highlightConstraint( "af_highlightConstraint", "", CVAR_GAME, "name of the constraint to highlight" );
idCVar af_showTimings( "af_showTimings", "0", CVAR_GAME | CVAR_BOOL, "show articulated figure cpu usage" );
idCVar af_showConstraints( "af_showConstraints", "0", CVAR_GAME | CVAR_BOOL, "show constraints" );
idCVar af_showConstraintNames( "af_showConstraintNames", "0", CVAR_GAME | CVAR_BOOL, "show constraint names" );
idCVar af_showConstrainedBodies( "af_showConstrainedBodies", "0", CVAR_GAME | CVAR_BOOL, "show the two bodies contrained by the highlighted constraint" );
idCVar af_showPrimaryOnly( "af_showPrimaryOnly", "0", CVAR_GAME | CVAR_BOOL, "show primary constraints only" );
idCVar af_showTrees( "af_showTrees", "0", CVAR_GAME | CVAR_BOOL, "show tree-like structures" );
idCVar af_showLimits( "af_showLimits", "0", CVAR_GAME | CVAR_BOOL, "show joint limits" );
idCVar af_showBodies( "af_showBodies", "0", CVAR_GAME | CVAR_BOOL, "show bodies" );
idCVar af_showBodyNames( "af_showBodyNames", "0", CVAR_GAME | CVAR_BOOL, "show body names" );
idCVar af_showMass( "af_showMass", "0", CVAR_GAME | CVAR_BOOL, "show the mass of each body" );
idCVar af_showTotalMass( "af_showTotalMass", "0", CVAR_GAME | CVAR_BOOL, "show the total mass of each articulated figure" );
idCVar af_showInertia( "af_showInertia", "0", CVAR_GAME | CVAR_BOOL, "show the inertia tensor of each body" );
idCVar af_showVelocity( "af_showVelocity", "0", CVAR_GAME | CVAR_BOOL, "show the velocity of each body" );
idCVar af_showActive( "af_showActive", "0", CVAR_GAME | CVAR_BOOL, "show tree-like structures of articulated figures not at rest" );
idCVar af_testSolid( "af_testSolid", "1", CVAR_GAME | CVAR_BOOL, "test for bodies initially stuck in solid" );
idCVar rb_showTimings( "rb_showTimings", "0", CVAR_GAME | CVAR_INTEGER, "show rigid body cpu usage" );
idCVar rb_showBodies( "rb_showBodies", "0", CVAR_GAME | CVAR_BOOL, "show rigid bodies" );
idCVar rb_showMass( "rb_showMass", "0", CVAR_GAME | CVAR_BOOL, "show the mass of each rigid body" );
idCVar rb_showInertia( "rb_showInertia", "0", CVAR_GAME | CVAR_BOOL, "show the inertia tensor of each rigid body" );
idCVar rb_showVelocity( "rb_showVelocity", "0", CVAR_GAME | CVAR_BOOL, "show the velocity of each rigid body" );
idCVar rb_showActive( "rb_showActive", "0", CVAR_GAME | CVAR_BOOL, "show rigid bodies that are not at rest" );
idCVar rb_showContacts( "rb_showContacts", "0", CVAR_GAME | CVAR_BOOL, "show contact points on rigid bodies" );
idCVar pm_friction( "pm_friction", "4", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "friction applied to player on the ground" );
idCVar pm_jumpheight( "pm_jumpheight", "68", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "approximate height the player can jump" );
idCVar pm_stepsize( "pm_stepsize", "16", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "maximum height the player can step up without jumping" );
idCVar pm_pronespeed( "pm_pronespeed", "60", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "speed the player can move while prone" );
idCVar pm_crouchspeed( "pm_crouchspeed", "80", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "speed the player can move while crouched" );
idCVar pm_walkspeed( "pm_walkspeed", "128", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "speed the player can move while walking" );
idCVar pm_runspeedforward( "pm_runspeedforward", "256", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "speed the player can move forwards while running" );
idCVar pm_runspeedback( "pm_runspeedback", "160", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "speed the player can move backwards while running" );
idCVar pm_runspeedstrafe( "pm_runspeedstrafe", "212", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "speed the player can move sideways while running" );
idCVar pm_sprintspeedforward( "pm_sprintspeedforward", "352", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "speed the player can move forwards while sprinting" );
idCVar pm_sprintspeedstrafe( "pm_sprintspeedstrafe", "176", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "speed the player can move sideways while sprinting" );
idCVar pm_noclipspeed( "pm_noclipspeed", "480", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "speed the player can move while in noclip" );
idCVar pm_noclipspeedsprint( "pm_noclipspeedsprint", "960", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "speed the player can move while in noclip and sprinting" );
idCVar pm_noclipspeedwalk( "pm_noclipspeedwalk", "256", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "speed the player can move while in noclip and walking" );
idCVar pm_democamspeed( "pm_democamspeed", "200", CVAR_GAME | CVAR_FLOAT | CVAR_NOCHEAT, "speed the player can move while flying around in a demo" );
idCVar pm_spectatespeed( "pm_spectatespeed", "450", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "speed the player can move while spectating" );
idCVar pm_spectatespeedsprint( "pm_spectatespeedsprint", "1024", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "speed the player can move while spectating and sprinting" );
idCVar pm_spectatespeedwalk( "pm_spectatespeedwalk", "256", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT, "speed the player can move while spectating and walking" );
idCVar pm_spectatebbox( "pm_spectatebbox", "16", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "size of the spectator bounding box" );
idCVar pm_minviewpitch( "pm_minviewpitch", "-89", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "amount player's view can look up (negative values are up)" );
idCVar pm_maxviewpitch( "pm_maxviewpitch", "88", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "amount player's view can look down" );
idCVar pm_minproneviewpitch( "pm_minproneviewpitch", "-45", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "amount player's view can look up when prone(negative values are up)" );
idCVar pm_maxproneviewpitch( "pm_maxproneviewpitch", "89", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "amount player's view can look down when prone" );
idCVar pm_proneheight( "pm_proneheight", "20", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "height of player's bounding box while prone" );
idCVar pm_proneviewheight( "pm_proneviewheight", "16", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "height of player's view while prone" );
idCVar pm_proneviewdistance( "pm_proneviewdistance", "10", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "distance in front of the player's view while prone" );
idCVar pm_crouchheight( "pm_crouchheight", "56", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "height of player's bounding box while crouched" );
idCVar pm_crouchviewheight( "pm_crouchviewheight", "48", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "height of player's view while crouched" );
idCVar pm_normalheight( "pm_normalheight", "79", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "height of player's bounding box while standing" );
idCVar pm_normalviewheight( "pm_normalviewheight", "72", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "height of player's view while standing" );
idCVar pm_deadheight( "pm_deadheight", "20", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "height of player's bounding box while dead" );
idCVar pm_deadviewheight( "pm_deadviewheight", "10", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "height of player's view while dead" );
idCVar pm_crouchrate( "pm_crouchrate", "180", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "time it takes for player's view to change from standing to crouching" );
idCVar pm_bboxwidth( "pm_bboxwidth", "32", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_FLOAT | CVAR_RANKLOCKED, "x/y size of player's bounding box" );
idCVar pm_crouchbob( "pm_crouchbob", "0.23", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "bob much faster when crouched" );
idCVar pm_walkbob( "pm_walkbob", "0.3", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "bob slowly when walking" );
idCVar pm_runbob( "pm_runbob", "0.4", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "bob faster when running" );
idCVar pm_runpitch( "pm_runpitch", "0.002", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "" );
idCVar pm_runroll( "pm_runroll", "0.005", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "" );
idCVar pm_bobup( "pm_bobup", "0.005", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "" );
idCVar pm_bobpitch( "pm_bobpitch", "0.002", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "" );
idCVar pm_bobroll( "pm_bobroll", "0.002", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "" );
idCVar pm_skipBob( "pm_skipBob", "0", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE | CVAR_PROFILE, "Disable all bobbing" );
idCVar pm_thirdPersonRange( "pm_thirdPersonRange", "80", CVAR_GAME | CVAR_FLOAT, "camera distance from player in 3rd person" );
idCVar pm_thirdPersonHeight( "pm_thirdPersonHeight", "0", CVAR_GAME | CVAR_FLOAT, "height of camera from normal view height in 3rd person" );
idCVar pm_thirdPersonAngle( "pm_thirdPersonAngle", "0", CVAR_GAME | CVAR_FLOAT, "direction of camera from player in 3rd person in degrees (0 = behind player, 180 = in front)" );
idCVar pm_thirdPersonOrbit( "pm_thirdPersonOrbit", "0", CVAR_GAME | CVAR_FLOAT, "if set, will automatically increment pm_thirdPersonAngle every frame" );
idCVar pm_thirdPersonNoPitch( "pm_thirdPersonNoPitch", "0", CVAR_GAME | CVAR_BOOL, "ignore camera pitch when in third person mode" );
idCVar pm_thirdPersonClip( "pm_thirdPersonClip", "1", CVAR_GAME | CVAR_BOOL, "clip third person view into world space" );
idCVar pm_thirdPerson( "pm_thirdPerson", "0", CVAR_GAME | CVAR_BOOL, "enables third person view" );
idCVar pm_pausePhysics( "pm_pausePhysics", "0", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_BOOL | CVAR_RANKLOCKED, "pauses physics" );
idCVar pm_deployThirdPersonRange( "pm_deployThirdPersonRange","200", CVAR_GAME | CVAR_FLOAT, "camera distance from player in 3rd person" );
idCVar pm_deployThirdPersonHeight( "pm_deployThirdPersonHeight","100", CVAR_GAME | CVAR_FLOAT, "height of camera from normal view height in 3rd person" );
idCVar pm_deployThirdPersonAngle( "pm_deployThirdPersonAngle","0", CVAR_GAME | CVAR_FLOAT, "direction of camera from player in 3rd person in degrees (0 = behind player, 180 = in front)" );
idCVar pm_deathThirdPersonRange( "pm_deathThirdPersonRange", "100", CVAR_GAME | CVAR_FLOAT, "camera distance from player in 3rd person" );
idCVar pm_deathThirdPersonHeight( "pm_deathThirdPersonHeight","20", CVAR_GAME | CVAR_FLOAT, "height of camera from normal view height in 3rd person" );
idCVar pm_deathThirdPersonAngle( "pm_deathThirdPersonAngle", "0", CVAR_GAME | CVAR_FLOAT, "direction of camera from player in 3rd person in degrees (0 = behind player, 180 = in front)" );
idCVar pm_slidevelocity( "pm_slidevelocity", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC | CVAR_RANKLOCKED, "what to do with velocity when hitting a surface at an angle. 0: use horizontal speed, 1: keep some of the impact speed to push along the slide" );
idCVar pm_powerslide( "pm_powerslide", "0.09", CVAR_GAME | CVAR_FLOAT | CVAR_NETWORKSYNC, "adjust the push when pm_slidevelocity == 1, set power < 1 -> more speed, > 1 -> closer to pm_slidevelocity 0", 0, 4 );
idCVar g_showPlayerArrows( "g_showPlayerArrows", "2", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC, "enable/disable arrows above the heads of players (0=off,1=all,2=friendly only)" );
idCVar g_showPlayerClassIcon( "g_showPlayerClassIcon", "0", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE, "Force drawing of player class icon above players in the fireteam." );
idCVar g_showPlayerShadow( "g_showPlayerShadow", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_BOOL, "enables shadow of player model" );
idCVar g_showHud( "g_showHud", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "draw the hud gui" );
idCVar g_advancedHud( "g_advancedHud", "0", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE | CVAR_PROFILE, "Draw advanced HUD" );
idCVar g_skipPostProcess( "g_skipPostProcess", "0", CVAR_GAME | CVAR_BOOL, "draw the post process gui" );
idCVar g_gun_x( "g_gunX", "0", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_gun_y( "g_gunY", "0", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_gun_z( "g_gunZ", "0", CVAR_GAME | CVAR_FLOAT, "" );
idCVar g_fov( "g_fov", "90", CVAR_GAME | CVAR_INTEGER | CVAR_NOCHEAT, "", 1.0f, 179.0f );
idCVar g_skipViewEffects( "g_skipViewEffects", "0", CVAR_GAME | CVAR_BOOL, "skip damage and other view effects" );
idCVar g_forceClear( "g_forceClear", "1", CVAR_GAME | CVAR_BOOL, "forces clearing of color buffer on main game draw (faster)" );
idCVar g_testParticle( "g_testParticle", "0", CVAR_GAME | CVAR_INTEGER, "test particle visualization, set by the particle editor" );
idCVar g_testParticleName( "g_testParticleName", "", CVAR_GAME, "name of the particle being tested by the particle editor" );
idCVar g_testModelRotate( "g_testModelRotate", "0", CVAR_GAME, "test model rotation speed" );
idCVar g_testPostProcess( "g_testPostProcess", "", CVAR_GAME, "name of material to draw over screen" );
idCVar g_testViewSkin( "g_testViewSkin", "", CVAR_GAME, "name of skin to use for the view" );
idCVar g_testModelAnimate( "g_testModelAnimate", "0", CVAR_GAME | CVAR_INTEGER, "test model animation,\n"
"0 = cycle anim with origin reset\n"
"1 = cycle anim with fixed origin\n"
"2 = cycle anim with continuous origin\n"
"3 = frame by frame with continuous origin\n"
"4 = play anim once", 0, 4, idCmdSystem::ArgCompletion_Integer<0,4> );
idCVar g_disableGlobalAudio( "g_disableGlobalAudio", "0", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_BOOL, "disable global VOIP communication" );
idCVar g_maxPlayerWarnings( "g_maxPlayerWarnings", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_RANKLOCKED, "maximum warnings before player is kicked" );
idCVar g_testModelBlend( "g_testModelBlend", "0", CVAR_GAME | CVAR_INTEGER, "number of frames to blend" );
idCVar g_exportMask( "g_exportMask", "", CVAR_GAME, "" );
idCVar password( "password", "", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_RANKLOCKED, "client password used when connecting" );
idCVar net_useAOR( "net_useAOR", "1", CVAR_GAME | CVAR_BOOL, "Enable/Disable Area of Relevance" );
idCVar net_aorPVSScale( "net_aorPVSScale", "4", CVAR_GAME | CVAR_FLOAT, "AoR scale for outside of PVS" );
idCVar pm_vehicleSoundLerpScale( "pm_vehicleSoundLerpScale", "10", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT, "" );
idCVar pm_waterSpeed( "pm_waterSpeed", "400", CVAR_GAME | CVAR_FLOAT | CVAR_RANKLOCKED, "speed player will be pushed up in water when totally under water" );
idCVar pm_realisticMovement( "pm_realisticMovement", "2", CVAR_GAME | CVAR_NETWORKSYNC | CVAR_INTEGER, "Which player movement physics to use: 0=Quake-style, 1=Realistic-style 2=Realistic for players, Quake-style for bots" );
idCVar g_ignorePersistentRanks( "g_ignorePersistentRanks", "0", CVAR_GAME | CVAR_BOOL | CVAR_INIT, "Whether or not persistent ranks are ignored for use in game purposes. 0=Use persistent ranks, 1=Ignore persistent ranks" );
idCVar g_debugNetworkWrite( "g_debugNetworkWrite", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_debugProficiency( "g_debugProficiency", "0", CVAR_GAME | CVAR_BOOL, "" );
idCVar g_weaponSwitchTimeout( "g_weaponSwitchTimeout", "1.5", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_FLOAT, "" );
idCVar g_hitBeep( "g_hitBeep", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_INTEGER, "play hit beep sound when you inflict damage.\n 0 = do nothing\n 1 = beep/flash cross-hair\n 2 = beep\n 3 = flash cross-hair" );
idCVar g_allowHitBeep( "g_allowHitBeep", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Allow or disallow players' use of hitbeep damage feedbck." );
idCVar fs_debug( "fs_debug", "0", CVAR_SYSTEM | CVAR_INTEGER, "", 0, 2, idCmdSystem::ArgCompletion_Integer<0,2> );
#if !defined( _XENON ) && !defined( MONOLITHIC )
idCVar r_aspectRatio( "r_aspectRatio", "0", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "aspect ratio. 0 is 4:3, 1 is 16:9, 2 is 16:10, 3 is 5:4. -1 uses r_customAspectRatioH and r_customAspectRatioV" );
idCVar r_customAspectRatioH( "r_customAspectRatioH", "16", CVAR_RENDERER | CVAR_FLOAT | CVAR_ARCHIVE, "horizontal custom aspect ratio" );
idCVar r_customAspectRatioV( "r_customAspectRatioV", "10", CVAR_RENDERER | CVAR_FLOAT | CVAR_ARCHIVE, "vertical custom aspect ratio" );
#endif
idCVar anim_showMissingAnims( "anim_showMissingAnims", "0", CVAR_BOOL, "Show warnings for missing animations" );
const char *aas_types[] = {
"aas_player",
"aas_vehicle",
NULL
};
idCVar aas_test( "aas_test", "0", CVAR_GAME, "select which AAS to test", aas_types, idCmdSystem::ArgCompletion_String<aas_types> );
idCVar aas_showEdgeNums( "aas_showEdgeNums", "0", CVAR_GAME | CVAR_BOOL, "show edge nums" );
idCVar aas_showAreas( "aas_showAreas", "0", CVAR_GAME | CVAR_INTEGER, "show the areas in the selected aas", 0, 2, idCmdSystem::ArgCompletion_Integer<0,2> );
idCVar aas_showAreaNumber( "aas_showAreaNumber", "0", CVAR_GAME | CVAR_INTEGER, "show the specific area number set" );
idCVar aas_showPath( "aas_showPath", "0", CVAR_GAME, "show the path to the walk specified area" );
idCVar aas_showHopPath( "aas_showHopPath", "0", CVAR_GAME, "show hop path to specified area" );
idCVar aas_showWallEdges( "aas_showWallEdges", "0", CVAR_GAME | CVAR_INTEGER, "show the edges of walls, 2 = project all to same height, 3 = project onscreen", 0, 3, idCmdSystem::ArgCompletion_Integer<0,3> );
idCVar aas_showWallEdgeNums( "aas_showWallEdgeNums", "0", CVAR_GAME | CVAR_BOOL, "show the number of the edges of walls" );
idCVar aas_showNearestCoverArea( "aas_showNearestCoverArea", "0", CVAR_GAME | CVAR_INTEGER, "show the nearest area with cover from the selected area (aas_showHideArea 4 will show the nearest area in cover from area 4)" );
idCVar aas_showNearestInsideArea( "aas_showNearestInsideArea", "0", CVAR_GAME | CVAR_BOOL, "show the nearest area that is inside" );
idCVar aas_showTravelTime( "aas_showTravelTime", "0", CVAR_GAME | CVAR_INTEGER, "print the travel time to the specified goal area (only when aas_showAreas is set)" );
idCVar aas_showPushIntoArea( "aas_showPushIntoArea", "0", CVAR_GAME | CVAR_BOOL, "show an arrow going to the closest area" );
idCVar aas_showFloorTrace( "aas_showFloorTrace", "0", CVAR_GAME | CVAR_BOOL, "show floor trace" );
idCVar aas_showObstaclePVS( "aas_showObstaclePVS", "0", CVAR_GAME | CVAR_INTEGER, "show obstacle PVS for the given area" );
idCVar aas_showManualReachabilities("aas_showManualReachabilities", "0", CVAR_GAME | CVAR_BOOL, "show manually placed reachabilities" );
idCVar aas_showFuncObstacles( "aas_showFuncObstacles", "0", CVAR_GAME | CVAR_BOOL, "show the AAS func_obstacles on the map" );
idCVar aas_showBadAreas( "aas_showBadAreas", "0", CVAR_GAME | CVAR_INTEGER, "show bad AAS areas", 0, 3, idCmdSystem::ArgCompletion_Integer<0,3> );
idCVar aas_locationMemory( "aas_locationMemory", "0", CVAR_GAME, "used to remember a particular location, set to 'current' to store the current x,y,z location" );
idCVar aas_pullPlayer( "aas_pullPlayer", "0", CVAR_GAME, "pull the player to the specified area" );
idCVar aas_randomPullPlayer( "aas_randomPullPlayer", "0", CVAR_GAME | CVAR_INTEGER, "pull the player to a random area" );
idCVar bot_threading( "bot_threading", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "enable running the bot AI in a separate thread" );
idCVar bot_threadMinFrameDelay( "bot_threadMinFrameDelay", "1", CVAR_GAME | CVAR_INTEGER | CVAR_NOCHEAT, "minimum number of game frames the bot AI trails behind", 0, 4, idCmdSystem::ArgCompletion_Integer<0,4> );
idCVar bot_threadMaxFrameDelay( "bot_threadMaxFrameDelay", "4", CVAR_GAME | CVAR_INTEGER | CVAR_NOCHEAT, "maximum number of game frames the bot AI can trail behind", 0, 4, idCmdSystem::ArgCompletion_Integer<0,4> );
idCVar bot_pause( "bot_pause", "0", CVAR_GAME | CVAR_BOOL, "Pause the bot's thinking - useful for screenshots/debugging/etc" );
idCVar bot_drawClientNumbers( "bot_drawClientNumbers", "0", CVAR_GAME | CVAR_BOOL, "Draw every clients number above their head" );
idCVar bot_drawActions( "bot_drawActions", "0", CVAR_GAME | CVAR_BOOL, "Draw the bot's actions." );
idCVar bot_drawBadIcarusActions( "bot_drawBadIcarusActions", "0", CVAR_GAME | CVAR_BOOL, "Draw actions with an icarus flag, that aren't in a valid vehicle AAS area." );
idCVar bot_drawIcarusActions( "bot_drawIcarusActions", "0", CVAR_GAME | CVAR_BOOL, "Draw actions with an icarus flag, that appear valid to the AAS." );
idCVar bot_drawActionRoutesOnly( "bot_drawActionRoutesOnly", "-1", CVAR_GAME | CVAR_INTEGER, "Draw only the bot actions that have the defined route." );
idCVar bot_drawNodes( "bot_drawNodes", "0", CVAR_BOOL | CVAR_GAME, "draw vehicle path nodes" );
idCVar bot_drawNodeNumber( "bot_drawNodeNumber", "-1", CVAR_INTEGER | CVAR_GAME, "draw a specific vehicle path node" );
idCVar bot_drawDefuseHints( "bot_drawDefuseHints", "0", CVAR_BOOL | CVAR_GAME, "draw the bot's defuse hints." );
idCVar bot_drawActionNumber( "bot_drawActionNumber", "-1", CVAR_GAME | CVAR_INTEGER, "Draw a specific bot action only. -1 = disable" );
idCVar bot_drawActionVehicleType( "bot_drawActionVehicleType", "-1", CVAR_GAME | CVAR_INTEGER, "Draw only the actions that have this vehicleType set. -1 = disable" );
idCVar bot_drawActiveActionsOnly( "bot_drawActiveActionsOnly", "0", CVAR_GAME | CVAR_INTEGER, "Draw only active bot actions. 1 = all active actions. 2 = only GDF active actions. 3 = only Strogg active actions. Combo actions, that have both GDF and strogg goals, will still show up." );
idCVar bot_drawActionWithClasses( "bot_drawActionWithClasses", "0", CVAR_GAME | CVAR_BOOL, "Draw only actions that have a validClass set to anything other then 0 ( 0 = any class )." );
idCVar bot_drawActionTypeOnly( "bot_drawActionTypeOnly", "-1", CVAR_GAME | CVAR_INTEGER, "Draw only actions that have a gdf/strogg goal number matching the cvar value. Check the bot manual for goal numbers. -1 = disabled." );
idCVar bot_drawRoutes( "bot_drawRoutes", "0", CVAR_GAME | CVAR_BOOL, "Draw the routes on the map." );
idCVar bot_drawActiveRoutesOnly( "bot_drawActiveRoutesOnly", "0", CVAR_GAME | CVAR_BOOL, "Only draw the active routes on the map." );
idCVar bot_drawRouteGroupOnly( "bot_drawRouteGroupOnly", "-1", CVAR_GAME | CVAR_INTEGER, "Only draw routes that have the groupID specified." );
idCVar bot_drawActionSize( "bot_drawActionSize", "0.2", CVAR_GAME | CVAR_FLOAT, "How big to draw the bot action info. Default is 0.2" );
idCVar bot_drawActionGroupNum( "bot_drawActionGroupNum", "-1", CVAR_GAME | CVAR_INTEGER, "Filter what action groups to draw with the bot_drawAction cmd. -1 = disabled." );
idCVar bot_drawActionDist( "bot_drawActionDist", "4092", CVAR_GAME | CVAR_FLOAT, "How far away to draw the bot action info. Default is 2048" );
idCVar bot_drawObstacles( "bot_drawObstacles", "0", CVAR_GAME | CVAR_BOOL, "Draw the bot's dynamic obstacles in the world" );
idCVar bot_drawRearSpawnLocations( "bot_drawRearSpawnLocations", "0", CVAR_GAME | CVAR_BOOL, "Draw the rear spawn locations for each team" );
idCVar bot_enable( "bot_enable", "1", CVAR_GAME | CVAR_BOOL | CVAR_SERVERINFO, "0 = bots will not be loaded in the game. 1 = bots are loaded." );
idCVar bot_doObjectives( "bot_doObjectives", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC | CVAR_NOCHEAT, "0 = bots let the player play the hero, with the bots filling a supporting role, 1 = bots do all the major objectives along with the player" );
idCVar bot_ignoreGoals( "bot_ignoreGoals", "0", CVAR_GAME | CVAR_INTEGER | CVAR_CHEAT, "If set to 1, bots will ignore all map objectives. Useful for debugging bot behavior" );
idCVar bot_useVehicles( "bot_useVehicles", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots dont use vehicles, 1 = bots do use vehicles" );
idCVar bot_useVehicleDrops( "bot_useVehicleDrops", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots don't use vehicle drops, 1 = bots do use vehicle drops" );
idCVar bot_stayInVehicles( "bot_stayInVehicles", "0", CVAR_GAME | CVAR_BOOL, "1 = bots will never leave their vehicle. Only useful for debugging. Default is 0" );
idCVar bot_useStrafeJump( "bot_useStrafeJump", "0", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots can't strafe jump, 1 = bots CAN strafe jump to goal locations that are far away" );
idCVar bot_useSuicideWhenStuck( "bot_useSuicideWhenStuck", "1", CVAR_GAME | CVAR_BOOL, "0 = bots never suicide when stuck. 1 = bots suicide if they detect that they're stuck" );
idCVar bot_useDeployables( "bot_useDeployables", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots dont drop deployables of any kind, 1 = bots can drop all deployables" );
idCVar bot_useMines( "bot_useMines", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots dont use mines, 1 = bots can use mines. Default = 1" );
idCVar bot_sillyWarmup( "bot_sillyWarmup", "0", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots play the game like normal, 1 = bots shoot each other and act silly during warmup" );
idCVar bot_useSpawnHosts( "bot_useSpawnHosts", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = strogg bots can't use spawn host bodies, 1 = bots can use spawnhosts" );
idCVar bot_useUniforms( "bot_useUniforms", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots won't steal uniforms, 1 = bots take uniforms" );
idCVar bot_noChat( "bot_noChat", "0", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots chat, 1 = bots never chat" );
idCVar bot_noTaunt( "bot_noTaunt", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots taunt, 1 = bots never taunt" );
idCVar bot_aimSkill( "bot_aimSkill", "1", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC | CVAR_NOCHEAT, "Sets the bot's default aiming skill. 0 = EASY, 1 = MEDIUM, 2 = EXPERT, 3 = MASTER", 0, 3, idCmdSystem::ArgCompletion_Integer<0,3> );
idCVar bot_skill( "bot_skill", "3", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC | CVAR_NOCHEAT, "Sets the bot's default AI skill. 0 = EASY, 1 = NORMAL, 2 = EXPERT, 3 = TRAINING MODE - this mode is useful for learning about the game", 0, 3, idCmdSystem::ArgCompletion_Integer<0,3> );
idCVar bot_knifeOnly( "bot_knifeOnly", "0", CVAR_GAME | CVAR_BOOL, "goofy mode where the bots only use their knifes in combat." );
idCVar bot_ignoreEnemies( "bot_ignoreEnemies", "0", CVAR_GAME | CVAR_INTEGER, "If set to 1, bots will ignore all enemies. 2 = Ignore Strogg. 3 = Ignore GDF. Useful for debugging bot behavior" );
idCVar bot_debug( "bot_debug", "0", CVAR_GAME | CVAR_BOOL, "Debug various bot subsystems. Many bot debugging features are disabled if this is not set to 1" );
idCVar bot_debugActionGoalNumber( "bot_debugActionGoalNumber", "-1", CVAR_GAME | CVAR_INTEGER, "Set to any action number on the map to have the bot ALWAYS do that action, for debugging. -1 = disabled. NOTE: The bot will treat the goal as a camp goal. This is useful for path testing." );
idCVar bot_debugSpeed( "bot_debugSpeed", "-1", CVAR_GAME | CVAR_INTEGER, "Debug bot's move speed. -1 = disable" );
idCVar bot_debugGroundVehicles( "bot_debugGroundVehicles", "-1", CVAR_GAME | CVAR_INTEGER, "Debug bot ground vehicle usage. -1 = disable" );
idCVar bot_debugAirVehicles( "bot_debugAirVehicles", "-1", CVAR_GAME | CVAR_INTEGER, "Debug bot air vehicle usage. -1 = disable" );
idCVar bot_debugObstacles( "bot_debugObstacles", "0", CVAR_GAME | CVAR_BOOL, "Debug bot obstacles in the world" );
idCVar bot_spectateDebug( "bot_spectateDebug", "0", CVAR_GAME | CVAR_BOOL, "If enabled, automatically sets the debug hud to the bot being spectated" );
idCVar bot_followMe( "bot_followMe", "0", CVAR_GAME | CVAR_INTEGER, "Have the bots follow you in debug mode" );
idCVar bot_breakPoint( "bot_breakPoint", "0", CVAR_GAME | CVAR_BOOL, "Cause a program break to occur inside the bot's AI" );
idCVar bot_useShotguns( "bot_useShotguns", "0", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots wont use shotguns/nailguns. 1 = bots will use shotguns/nailguns." );
idCVar bot_useSniperWeapons( "bot_useSniperWeapons", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots wont use sniper rifles. 1 = bots will use sniper rifles." );
idCVar bot_minClients( "bot_minClients", "-1", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC | CVAR_NOCHEAT, "Keep a minimum number of clients on the server with bots and humans. -1 to disable", -1, MAX_CLIENTS );
idCVar bot_minClientsMax( "bot_minClientsMax", "16", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC | CVAR_INIT, "Maximum allowed value of bot_minClients. Only affects the in-game UI.", -1, MAX_CLIENTS );
idCVar bot_debugPersonalVehicles( "bot_debugPersonalVehicles", "0", CVAR_GAME | CVAR_BOOL, "Only used for debugging the use of the husky/icarus." );
idCVar bot_debugWeapons( "bot_debugWeapons", "0", CVAR_GAME | CVAR_BOOL, "Only used for debugging bots weapons." );
idCVar bot_uiNumStrogg( "bot_uiNumStrogg", "-1", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC | CVAR_NOCHEAT, "The number of strogg bots to add to the server. -1 to disable" );
idCVar bot_uiNumGDF( "bot_uiNumGDF", "-1", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC | CVAR_NOCHEAT, "The number of gdf bots to add to the server. -1 to disable" );
idCVar bot_uiSkill( "bot_uiSkill", "5", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC | CVAR_NOCHEAT, "The overall skill the bots should play at in the game. 0 = EASY, 1 = MEDIUM, 2 = EXPERT, 3 = MASTER, 4 = CUSTOM, 5 = TRAINING" );
idCVar bot_showPath( "bot_showPath", "-1", CVAR_GAME | CVAR_INTEGER, "Show the path for the bot's client number. -1 = disable." );
idCVar bot_skipThinkClient( "bot_skipThinkClient", "-1", CVAR_GAME | CVAR_INTEGER, "A debug only cvar that skips thinking for a particular bot with the client number entered. -1 = disabled." );
idCVar bot_debugMapScript( "bot_debugMapScript", "0", CVAR_GAME | CVAR_BOOL, "Allows you to debug the bot script." );
idCVar bot_useTKRevive( "bot_useTKRevive", "1", CVAR_GAME | CVAR_BOOL, "Allows the bots to use the advanced tactic of TK reviving if their teammate is weak. 0 = disabled. Default is 1" );
idCVar bot_debugObstacleAvoidance( "bot_debugObstacleAvoidance", "0", CVAR_GAME | CVAR_BOOL, "Debug obstacle avoidance" );
idCVar bot_testObstacleQuery( "bot_testObstacleQuery", "", CVAR_GAME, "test a previously recorded obstacle avoidance query" );
idCVar bot_balanceCriticalClass( "bot_balanceCriticalClass", "1", CVAR_GAME | CVAR_BOOL, "Have the bots try to keep someone playing the critical class at all times. 0 = keep the class they spawn in as. Default = 1." );
idCVar bot_useAltRoutes( "bot_useAltRoutes", "1", CVAR_GAME | CVAR_BOOL, "Debug the bot's alternate path use." );
idCVar bot_godMode( "bot_godMode", "-1", CVAR_GAME | CVAR_INTEGER, "Set to the bot client you want to enter god mode. -1 = disable." );
idCVar bot_useRearSpawn( "bot_useRearSpawn", "1", CVAR_BOOL | CVAR_GAME, "debug bots using rear spawn points" );
idCVar bot_sleepWhenServerEmpty( "bot_sleepWhenServerEmpty", "1", CVAR_BOOL | CVAR_GAME | CVAR_NOCHEAT, "has the bots stop thinking when the server is idle and there are no humans playing, to conserve CPU." );
idCVar bot_allowObstacleDecay( "bot_allowObstacleDecay", "1", CVAR_BOOL | CVAR_GAME, "0 = dont allow obstacle decay. 1 = allow obstacle decay." );
idCVar bot_allowClassChanges( "bot_allowClassChanges", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots won't ever change their class. 1 = Bots can change their class thru script/code." );
idCVar bot_testPathToBotAction( "bot_testPathToBotAction", "-1", CVAR_GAME | CVAR_INTEGER, "based on which aas type aas_test is set to, will test to see if a path is available from the players current origin, to the bot action in question. You need to join a team for this to work properly! -1 = disabled." );
idCVar bot_pauseInVehicleTime( "bot_pauseInVehicleTime", "7", CVAR_GAME | CVAR_INTEGER, "Time the bots will pause when first enter a vehicle ( in seconds ) to allow others to jump in. Default is 7 seconds." );
idCVar bot_doObjsInTrainingMode( "bot_doObjsInTrainingMode", "1", CVAR_GAME | CVAR_BOOL, "Controls whether or not bots will do objectives in training mode, if the human isn't the correct class to do the objective. 0 = bots won't do primary or secondary objecitives in training mode. 1 = bots will do objectives. Default = 1. " );
idCVar bot_doObjsDelayTimeInMins( "bot_doObjsDelayTimeInMins", "3", CVAR_GAME | CVAR_INTEGER, "How long of a delay in time the bots will have before they start considering objectives while in Training mode. Default is 3 minutes. " );
idCVar bot_useAirVehicles( "bot_useAirVehicles", "1", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "0 = bots dont use air vehicles, 1 = bots do use air vehicles. Useful for debugging ground vehicles only." );
idCVar g_showCrosshairInfo( "g_showCrosshairInfo", "1", CVAR_INTEGER | CVAR_GAME, "shows information about the entity under your crosshair" );
idCVar g_banner_1( "g_banner_1", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 1" );
idCVar g_banner_2( "g_banner_2", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 2" );
idCVar g_banner_3( "g_banner_3", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 3" );
idCVar g_banner_4( "g_banner_4", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 4" );
idCVar g_banner_5( "g_banner_5", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 5" );
idCVar g_banner_6( "g_banner_6", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 6" );
idCVar g_banner_7( "g_banner_7", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 7" );
idCVar g_banner_8( "g_banner_8", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 8" );
idCVar g_banner_9( "g_banner_9", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 9" );
idCVar g_banner_10( "g_banner_10", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 10" );
idCVar g_banner_11( "g_banner_11", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 11" );
idCVar g_banner_12( "g_banner_12", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 12" );
idCVar g_banner_13( "g_banner_13", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 13" );
idCVar g_banner_14( "g_banner_14", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 14" );
idCVar g_banner_15( "g_banner_15", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 15" );
idCVar g_banner_16( "g_banner_16", "", CVAR_GAME | CVAR_NOCHEAT, "banner message 16" );
idCVar g_bannerDelay( "g_banner_delay", "1", CVAR_GAME | CVAR_NOCHEAT | CVAR_INTEGER, "delay in seconds between banner messages" );
idCVar g_bannerLoopDelay( "g_banner_loopdelay", "0", CVAR_GAME | CVAR_NOCHEAT | CVAR_INTEGER, "delay in seconds before banner messages repeat, 0 = off" );
idCVar* g_bannerCvars[ NUM_BANNER_MESSAGES ] = {
&g_banner_1, &g_banner_2, &g_banner_3, &g_banner_4, &g_banner_5, &g_banner_6, &g_banner_7, &g_banner_8,
&g_banner_9, &g_banner_10, &g_banner_11, &g_banner_12, &g_banner_13, &g_banner_14, &g_banner_15, &g_banner_16,
};
idCVar g_allowComplaintFiresupport( "g_allowComplaint_firesupport", "1", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL, "Allow complaints for teamkills with fire support" );
idCVar g_allowComplaintCharge( "g_allowComplaint_charge", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL, "Allow complaints for teamkills with charges" );
idCVar g_allowComplaintExplosives( "g_allowComplaint_explosives", "1", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL, "Allow complaints for teamkills with explosive weapons and items" );
idCVar g_allowComplaintVehicles( "g_allowComplaint_vehicles", "1", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL, "Allow complaints for teamkills with vehicle" );
idCVar g_complaintLimit( "g_complaintLimit", "6", CVAR_GAME | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_RANKLOCKED, "Total complaints at which a player will be kicked" );
idCVar g_complaintGUIDLimit( "g_complaintGUIDLimit", "4", CVAR_GAME | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_RANKLOCKED, "Total unique complaints at which a player will be kicked" );
idCVar g_execMapConfigs( "g_execMapConfigs", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL, "Execute map cfg with same name" );
idCVar g_teamSwitchDelay( "g_teamSwitchDelay", "5", CVAR_GAME | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_RANKLOCKED, "Delay (in seconds) before player can change teams again" );
idCVar g_warmupDamage( "g_warmupDamage", "1", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL, "Enable/disable players taking damage during warmup" );
idCVar g_muteSpecs( "g_muteSpecs", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL | CVAR_RANKLOCKED, "Send all spectator global chat to team chat" );
idCVar g_warmup( "g_warmup", "0.5", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_RANKLOCKED, "Length (in minutes) of warmup period" );
idCVar g_gameReviewPause( "g_gameReviewPause", "0.5", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_RANKLOCKED, "Time (in minutes) for scores review time" );
idCVar g_password( "g_password", "", CVAR_GAME | CVAR_ARCHIVE | CVAR_RANKLOCKED, "game password" );
idCVar g_privatePassword( "g_privatePassword", "", CVAR_GAME | CVAR_ARCHIVE, "game password for private slots" );
idCVar g_xpSave( "g_xpSave", "1", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL | CVAR_RANKLOCKED, "stores xp for disconnected players which will be given back if they reconnect" );
idCVar g_kickBanLength( "g_kickBanLength", "2", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_RANKLOCKED, "length of time a kicked player will be banned for" );
idCVar g_maxSpectateTime( "g_maxSpectateTime", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_RANKLOCKED, "maximum length of time a player may spectate for" );
idCVar g_unlock_updateAngles( "g_unlock_updateAngles", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_BOOL, "update view angles in fps unlock mode" );
idCVar g_unlock_updateViewpos( "g_unlock_updateViewpos", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_BOOL, "update view origin in fps unlock mode" );
idCVar g_unlock_interpolateMoving( "g_unlock_interpolateMoving", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_BOOL, "interpolate moving objects in fps unlock mode" );
idCVar g_unlock_viewStyle( "g_unlock_viewStyle", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_INTEGER, "0: extrapolate view origin, 1: interpolate view origin" );
idCVar g_voteWait( "g_voteWait", "2.5", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_RANKLOCKED, "Delay (in minutes) before player may perform a callvote again" );
idCVar g_useTraceCollection( "g_useTraceCollection", "1", CVAR_GAME | CVAR_BOOL, "Use optimized trace collections" );
idCVar g_removeStaticEntities( "g_removeStaticEntities", "1", CVAR_GAME | CVAR_BOOL, "Remove non-dynamic entities on map spawn when they aren't needed" );
idCVar g_maxVoiceChats( "g_maxVoiceChats", "4", CVAR_GAME | CVAR_ARCHIVE | CVAR_INTEGER, "maximum number of voice chats a player may do in a period of time" );
idCVar g_maxVoiceChatsOver( "g_maxVoiceChatsOver", "30", CVAR_GAME | CVAR_ARCHIVE | CVAR_INTEGER, "time over which the maximum number of voice chat limit is applied" );
idCVar g_profileEntityThink( "g_profileEntityThink", "0", CVAR_GAME | CVAR_BOOL, "Enable entity think profiling" );
idCVar g_timeoutToSpec( "g_timeoutToSpec", "0", CVAR_GAME | CVAR_FLOAT | CVAR_NOCHEAT, "Timeout in minutes for players who are AFK to go into spectator mode (0=disabled)" );
idCVar g_autoReadyPercent( "g_autoReadyPercent", "50", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE, "Percentage of a full server that must be in game for auto ready to start" );
idCVar g_autoReadyWait( "g_autoReadyWait", "1", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE, "Length of time in minutes auto ready will wait before starting the countdown" );
idCVar g_useBotsInPlayerTotal( "g_useBotsInPlayerTotal", "1", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE, "Should bots count towards the number of players required to start the game?" );
idCVar g_playTooltipSound( "g_playTooltipSound", "2", CVAR_GAME | CVAR_INTEGER | CVAR_ARCHIVE | CVAR_PROFILE, "0: no sound 1: play tooltip sound in single player only 2: Always play tooltip sound" );
idCVar g_tooltipTimeScale( "g_tooltipTimeScale", "1", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "Scale the amount of time that a tooltip is visible. 0 will disable all tooltips." );
idCVar g_tooltipVolumeScale( "g_tooltipVolumeScale", "-20", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "Change the game volume while playing a tooltip with VO." );
idCVar g_allowSpecPauseFreeFly( "g_allowSpecPauseFreeFly", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Allow spectators to free fly when the game is paused" );
idCVar g_smartTeamBalance( "g_smartTeamBalance", "1", CVAR_GAME | CVAR_BOOL | CVAR_RANKLOCKED, "Encourages players to balance teams themselves by giving rewards." );
idCVar g_smartTeamBalanceReward( "g_smartTeamBalanceReward", "10", CVAR_GAME | CVAR_INTEGER | CVAR_RANKLOCKED, "The amount of XP to give people who switch teams when asked to." );
idCVar g_keepFireTeamList( "g_keepFireTeamList", "0", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE | CVAR_PROFILE, "Always show the fireteam list on the HUD." );
idCVar net_serverDownload( "net_serverDownload", "0", CVAR_GAME | CVAR_INTEGER | CVAR_ARCHIVE, "enable server download redirects. 0: off 1: client exits and opens si_serverURL in web browser 2: client downloads pak files from an URL and connects again. See net_serverDl* cvars for configuration" );
idCVar net_serverDlBaseURL( "net_serverDlBaseURL", "", CVAR_GAME | CVAR_ARCHIVE, "base URL for the download redirection" );
idCVar net_serverDlTable( "net_serverDlTable", "", CVAR_GAME | CVAR_ARCHIVE, "pak names for which download is provided, seperated by ; - use a * to mark all paks" );
idCVar g_drawMineIcons( "g_drawMineIcons", "1", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE | CVAR_PROFILE, "Draw icons on the HUD for mines." );
idCVar g_allowMineIcons( "g_allowMineIcons", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC | CVAR_RANKLOCKED, "Allow clients to draw icons on the HUD for mines." );
idCVar g_mineIconSize( "g_mineIconSize", "10", CVAR_FLOAT | CVAR_GAME | CVAR_ARCHIVE | CVAR_PROFILE, "Size of the screen space mine icons. NOTE: Will only take effect for new mines, not those already existing.", 0, 20 );
idCVar g_mineIconAlphaScale( "g_mineIconAlphaScale", "1", CVAR_GAME | CVAR_FLOAT | CVAR_ARCHIVE | CVAR_PROFILE, "Alpha scale to apply to mine icons. NOTE: Will only take effect for new mines, not those already existing." );
idCVar g_drawVehicleIcons( "g_drawVehicleIcons", "1", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE | CVAR_PROFILE, "Draw icons on the HUD for vehicles (eg spawn invulnerability)." );
#ifdef SD_SUPPORT_REPEATER
idCVar ri_useViewerPass( "ri_useViewerPass", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_REPEATERINFO | CVAR_BOOL, "use g_viewerPassword for viewers/repeaters" );
idCVar g_viewerPassword( "g_viewerPassword", "", CVAR_GAME | CVAR_ARCHIVE, "password for viewers" );
idCVar g_repeaterPassword( "g_repeaterPassword", "", CVAR_GAME | CVAR_ARCHIVE, "password for repeaters" );
idCVar ri_privateViewers( "ri_privateViewers", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_REPEATERINFO | CVAR_INTEGER, "number of private viewer slots" );
idCVar g_privateViewerPassword( "g_privateViewerPassword", "", CVAR_GAME | CVAR_ARCHIVE, "privatePassword for private viewer slots" );
idCVar ri_name( "ri_name", "", CVAR_GAME | CVAR_ARCHIVE | CVAR_REPEATERINFO, "override the server's si_name with this for relays" );
idCVar g_noTVChat( "g_noTVChat", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_BOOL, "Server enable/disable flag for viewer chat on ETQW:TV" );
#endif // SD_SUPPORT_REPEATER
idCVar g_drawHudMessages( "g_drawHudMessages", "1", CVAR_GAME | CVAR_INTEGER | CVAR_ARCHIVE | CVAR_PROFILE, "Draw task, task success and objective text on HUD." );
idCVar g_allowMineTriggerWarning( "g_allowMineTriggerWarning", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC | CVAR_RANKLOCKED, "Allow clients to draw warning text on the HUD for mine triggering." );
idCVar g_mineTriggerWarning( "g_mineTriggerWarning", "1", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE | CVAR_PROFILE, "Show warning message on HUD when triggering a proximity mine." );
idCVar g_allowAPTWarning( "g_allowAPTWarning", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC | CVAR_RANKLOCKED, "Allow clients to draw warning text on the HUD for APT lock ons." );
idCVar g_aptWarning( "g_aptWarning", "3", CVAR_GAME | CVAR_INTEGER | CVAR_ARCHIVE | CVAR_PROFILE, "Show warning message on HUD when APT is locking on. 0: Off 1: Visual warning only 2: Beep only 3: Visual and beep" );
idCVar g_useBaseETQW12Shotguns( "g_useBaseETQW12Shotguns", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use BaseETQW v1.2 behaviour for shotgun and nailgun." );
idCVar g_useQuake4DarkMatter( "g_useQuake4DarkMatter", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use Quake 4-style Dark Matter weaponry." );
idCVar g_artilleryWarning( "g_artilleryWarning", "0", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE, "Notify players of the launch of Hammer or DMC artillery." );
idCVar g_useDeathFading( "g_useDeathFading", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use screen fading effects when dead or unconscious?" );
idCVar g_useReverseAirstrikes( "g_useReverseAirstrikes", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use reversed airstrikes on the altfire of the Vampire and Violator?" );
idCVar g_useShieldAbsorber( "g_useShieldAbsorber", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use the shield absorber as the altfire of the Tactical Shield?" );
idCVar g_useNuclearHammer( "g_useNuclearHammer", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Make the Hammer and SSM missiles behave more like tactical nukes?" );
idCVar g_useQuake4Hyperblaster( "g_useQuake4Hyperblaster", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use Quake 4-style Hyperblaster weaponry?" );
idCVar g_useQuake4Railgun( "g_useQuake4Railgun", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use Quake 4-style Railgun weaponry?" );
idCVar g_useClassLimits( "g_useClassLimits", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Enables or disables class number limitations." );
idCVar g_useGibKills( "g_useGibKills", "1", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE, "Enables or disables certain attacks that don't normally gib, to do so." );
idCVar g_useAwardJackOfAllTrades( "g_useAwardJackOfAllTrades", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Enables or disables the new Jack of All Trades after-mission award." );
idCVar g_advancedVehicleDrops( "g_advancedVehicleDrops", "-1", CVAR_GAME | CVAR_INTEGER | CVAR_NETWORKSYNC, "Bitfield that specifies which vehicles may be dropped in via quickchat commands." );
idCVar g_useSpecificRadar( "g_useSpecificRadar", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should players(but not vehicles) be invisible to radar? (3rd eye and MCP exempt.)" );
idCVar g_vehicleDropsUseFE( "g_vehicleDropsUseFE", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should vehicle drops have Force Escalation requirements for their use?" );
idCVar g_vehicleDropsUseLP( "g_vehicleDropsUseLP", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should vehicle drops have Logistics Points requirements for their use?" );
idCVar g_huskyIcarusDropsIgnoreFE( "g_huskyIcarusDropsIgnoreFE", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should the Husky and Icarus ignore FE requirements? (Treat them as costing 0 FE.)" );
idCVar g_huskyIcarusDropsIgnoreLP( "g_huskyIcarusDropsIgnoreLP", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should the Husky and Icarus ignore LP requirements? (Treat them as costing 0 LP.)" );
idCVar g_useBaseETQWVehicleCredits("g_useBaseETQWVehicleCredits", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should the Icarus and Husky use BaseETQW vehicle credit costs?" );
idCVar g_useBaseETQWProficiencies( "g_useBaseETQWProficiencies", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should BaseETQW proficiencies be used? (QWTA gives free Vehicle Drops otherwise.)" );
idCVar g_useBaseETQWVehicleCharge( "g_useBaseETQWVehicleCharge", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should the BaseETQW vehicle credit charge timer duration be used?" );
idCVar g_vehicleSpawnsUseFE( "g_vehicleSpawnsUseFE", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Do vehicle spawns have Force Escalation requirements?" );
idCVar g_disableVehicleRespawns( "g_disableVehicleRespawns", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Are vehicles permitted to respawn after being destroyed?" );
idCVar g_disablePlayerRespawns( "g_disablePlayerRespawns", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Are players permitted to respawn after being killed?" );
idCVar g_allowCrosshairs( "g_allowCrosshairs", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Allow or disallow player's crosshairs." );
//idCVar g_allowTimerCircles( "g_allowTimerCircles", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Allow or disallow the timer circles that normally surround the crosshairs." );
//idCVar g_useStraightRockets( "g_useStraightRockets", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use Rocket Launcher projectiles that fly straight, or keep the flight arc of the BaseETQW Rocket Launcher?" );
idCVar g_useBaseETQW12SniperTrail( "g_useBaseETQW12SniperTrail", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Use the BaseETQW 1.2 sniper rifle's trail-tracer effect?" );
//idCVar g_hideHud( "g_hideHud", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Disables most aspects of the HUD, revealing them only when they're accessed in some way." );
idCVar g_useRealisticWeapons( "g_useRealisticWeapons", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should weapons behave in a realistic manner, or more game-oriented?" );
idCVar g_useVehicleAmmo( "g_useVehicleAmmo", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should vehicle weapons consume ammunition or not?" );
idCVar g_useVehicleDecoyAmmo( "g_useVehicleDecoyAmmo", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Should vehicle decoys consume ammunition or not?" );
idCVar g_allowEMPFriendlyFire( "g_allowEMPFriendlyFire", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Allow or disallow EMP effects from affecting friendly units." );
idCVar g_allowRadFriendlyFire( "g_allowRadFriendlyFire", "1", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Allow or disallow radiation effects from affecting friendly units." );
idCVar g_forgivingBotMatch( "g_forgivingBotMatch", "0", CVAR_GAME | CVAR_BOOL | CVAR_NETWORKSYNC, "Make BotMatches be more forgiving for a player." );
idCVar g_blood( "g_blood", "1", CVAR_GAME | CVAR_PROFILE | CVAR_ARCHIVE | CVAR_BOOL, "Show blood" );
idCVar g_trainingMode( "g_trainingMode", "0", CVAR_GAME | CVAR_BOOL | CVAR_NOCHEAT, "whether the game is in training mode or not" );
idCVar g_objectiveDecayTime( "g_objectiveDecayTime", "5", CVAR_GAME | CVAR_FLOAT | CVAR_RANKLOCKED, "Length of time in seconds that it takes a construct/hack objective to decay once after the initial timeout is complete" );
idCVar g_noQuickChats( "g_noQuickChats", "0", CVAR_GAME | CVAR_BOOL | CVAR_ARCHIVE | CVAR_PROFILE, "disables sound and text of quickchats" );
idCVar g_maxProficiency( "g_maxProficiency", "0", CVAR_GAME | CVAR_BOOL | CVAR_RANKLOCKED, "" );
idCVar g_vehicleSpawnMinPlayersHusky( "g_vehicleSpawnMinPlayersHusky", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersPlatypus( "g_vehicleSpawnMinPlayersPlatypus", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersArmadillo( "g_vehicleSpawnMinPlayersArmadillo", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersTrojan( "g_vehicleSpawnMinPlayersTrojan", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersBumblebee( "g_vehicleSpawnMinPlayersBumblebee", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersTitan( "g_vehicleSpawnMinPlayersTitan", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersAnansi( "g_vehicleSpawnMinPlayersAnansi", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersIcarus( "g_vehicleSpawnMinPlayersIcarus", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersHog( "g_vehicleSpawnMinPlayersHog", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersDesecrator( "g_vehicleSpawnMinPlayersDesecrator", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersCyclops( "g_vehicleSpawnMinPlayersCyclops", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersTormentor( "g_vehicleSpawnMinPlayersTormentor", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersJupiter( "g_vehicleSpawnMinPlayersJupiter", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
idCVar g_vehicleSpawnMinPlayersAbaddon( "g_vehicleSpawnMinPlayersAbaddon", "0", CVAR_GAME | CVAR_NETWORKSYNC, "The minimum players that have to be on server before this vehicle will spawn.");
| 116.325826 | 337 | 0.722832 | JasonHutton |
677f46fc06e7d13606731f6f380c3030e3e2c04e | 4,986 | cpp | C++ | Server/GameServer/SealHandler.cpp | APistole/KnightOnline | 80268e2fa971389a3e94c430966a7943c2631dbf | [
"MIT"
] | 191 | 2016-03-05T16:44:15.000Z | 2022-03-09T00:52:31.000Z | Server/GameServer/SealHandler.cpp | APistole/KnightOnline | 80268e2fa971389a3e94c430966a7943c2631dbf | [
"MIT"
] | 128 | 2016-08-31T04:09:06.000Z | 2022-01-14T13:42:56.000Z | Server/GameServer/SealHandler.cpp | APistole/KnightOnline | 80268e2fa971389a3e94c430966a7943c2631dbf | [
"MIT"
] | 165 | 2016-03-05T16:43:59.000Z | 2022-01-22T00:52:25.000Z | #include "stdafx.h"
using std::string;
#define ITEM_SEAL_PRICE 1000000
enum
{
SEAL_TYPE_SEAL = 1,
SEAL_TYPE_UNSEAL = 2,
SEAL_TYPE_KROWAZ = 3
};
enum SealErrorCodes
{
SealErrorNone = 0, // no error, success!
SealErrorFailed = 2, // "Seal Failed."
SealErrorNeedCoins = 3, // "Not enough coins."
SealErrorInvalidCode = 4, // "Invalid Citizen Registry Number" (i.e. invalid code/password)
SealErrorPremiumOnly = 5, // "Only available to premium users"
SealErrorFailed2 = 6, // "Seal Failed."
SealErrorTooSoon = 7, // "Please try again. You may not repeat this function instantly."
};
/**
* @brief Packet handler for the item sealing system.
*
* @param pkt The packet.
*/
void CUser::ItemSealProcess(Packet & pkt)
{
// Seal type
uint8_t opcode = pkt.read<uint8_t>();
Packet result(WIZ_ITEM_UPGRADE);
result << uint8_t(ITEM_SEAL) << opcode;
switch (opcode)
{
// Used when sealing an item.
case SEAL_TYPE_SEAL:
{
string strPasswd;
uint32_t nItemID;
int16_t unk0; // set to -1 in this case
uint8_t bSrcPos, bResponse = SealErrorNone;
pkt >> unk0 >> nItemID >> bSrcPos >> strPasswd;
/*
Most of these checks are handled client-side, so we shouldn't need to provide error messages.
Also, item sealing requires certain premium types (gold, platinum, etc) - need to double-check
these before implementing this check.
*/
// is this a valid position? (need to check if it can be taken from new slots)
if (bSrcPos >= HAVE_MAX
// does the item exist where the client says it does?
|| GetItem(SLOT_MAX + bSrcPos)->nNum != nItemID
// i ain't be allowin' no stealth items to be sealed!
|| GetItem(SLOT_MAX + bSrcPos)->nSerialNum == 0)
bResponse = SealErrorFailed;
// is the password valid by client limits?
else if (strPasswd.empty() || strPasswd.length() > 8)
bResponse = SealErrorInvalidCode;
// do we have enough coins?
else if (!hasCoins(ITEM_SEAL_PRICE))
bResponse = SealErrorNeedCoins;
_ITEM_TABLE* pItem = g_pMain->m_ItemtableArray.GetData(nItemID);
if(pItem == nullptr)
return;
#if 0 // this doesn't look right
// If the item's not equippable we not be lettin' you seal no moar!
if (pItem->m_bSlot >= SLOT_MAX)
bResponse = SealErrorFailed;
#endif
// If no error, pass it along to the database.
if (bResponse == SealErrorNone)
{
result << nItemID << bSrcPos << strPasswd << bResponse;
g_pMain->AddDatabaseRequest(result, this);
}
// If there's an error, tell the client.
// From memory though, there was no need -- it handled all of these conditions itself
// so there was no need to differentiate (just ignore the packet). Need to check this.
else
{
result << bResponse;
Send(&result);
}
} break;
// Used when unsealing an item.
case SEAL_TYPE_UNSEAL:
{
string strPasswd;
uint32_t nItemID;
int16_t unk0; // set to -1 in this case
uint8_t bSrcPos, bResponse = SealErrorNone;
pkt >> unk0 >> nItemID >> bSrcPos >> strPasswd;
if (bSrcPos >= HAVE_MAX
|| GetItem(SLOT_MAX+bSrcPos)->bFlag != ITEM_FLAG_SEALED
|| GetItem(SLOT_MAX+bSrcPos)->nNum != nItemID)
bResponse = SealErrorFailed;
else if (strPasswd.empty() || strPasswd.length() > 8)
bResponse = SealErrorInvalidCode;
// If no error, pass it along to the database.
if (bResponse == SealErrorNone)
{
result << nItemID << bSrcPos << strPasswd << bResponse;
g_pMain->AddDatabaseRequest(result, this);
}
// If there's an error, tell the client.
// From memory though, there was no need -- it handled all of these conditions itself
// so there was no need to differentiate (just ignore the packet). Need to check this.
else
{
result << bResponse;
Send(&result);
}
} break;
// Used when binding a Krowaz item (used to take it from not bound -> bound)
case SEAL_TYPE_KROWAZ:
{
string strPasswd = "0"; //Dummy, not actually used.
uint32_t nItemID;
uint8_t bSrcPos = 0 , unk3, bResponse = SealErrorNone;
uint16_t unk1, unk2;
pkt >> unk1 >> nItemID >> bSrcPos >> unk3 >> unk2;
if (bSrcPos >= HAVE_MAX
|| GetItem(SLOT_MAX+bSrcPos)->bFlag != ITEM_FLAG_NONE
|| GetItem(SLOT_MAX+bSrcPos)->nNum != nItemID)
bResponse = SealErrorFailed;
if (bResponse == SealErrorNone)
{
result << nItemID << bSrcPos << strPasswd << bResponse;
g_pMain->AddDatabaseRequest(result, this);
}
} break;
}
}
void CUser::SealItem(uint8_t bSealType, uint8_t bSrcPos)
{
_ITEM_DATA * pItem = GetItem(SLOT_MAX + bSrcPos);
if (pItem == nullptr)
return;
switch (bSealType)
{
case SEAL_TYPE_SEAL:
pItem->bFlag = ITEM_FLAG_SEALED;
GoldLose(ITEM_SEAL_PRICE);
break;
case SEAL_TYPE_UNSEAL:
pItem->bFlag = 0;
break;
case SEAL_TYPE_KROWAZ:
pItem->bFlag = ITEM_FLAG_BOUND;
break;
}
}
/**
* @brief Packet handler for the character sealing system.
*
* @param pkt The packet.
*/
void CUser::CharacterSealProcess(Packet & pkt)
{
} | 27.546961 | 98 | 0.676093 | APistole |
677f4c58a0957dd00800731a89c97b4a7d44ce20 | 13,771 | cpp | C++ | vs2017/screenshot/GeneratedFiles/moc_FullScreenWidget.cpp | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | vs2017/screenshot/GeneratedFiles/moc_FullScreenWidget.cpp | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | vs2017/screenshot/GeneratedFiles/moc_FullScreenWidget.cpp | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | /****************************************************************************
** Meta object code from reading C++ file 'FullScreenWidget.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../FullScreenWidget.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'FullScreenWidget.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.12.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_fullScreenWidget_t {
QByteArrayData data[37];
char stringdata0[541];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_fullScreenWidget_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_fullScreenWidget_t qt_meta_stringdata_fullScreenWidget = {
{
QT_MOC_LITERAL(0, 0, 16), // "fullScreenWidget"
QT_MOC_LITERAL(1, 17, 12), // "finishPixmap"
QT_MOC_LITERAL(2, 30, 0), // ""
QT_MOC_LITERAL(3, 31, 10), // "exitPixmap"
QT_MOC_LITERAL(4, 42, 12), // "finishedshot"
QT_MOC_LITERAL(5, 55, 3), // "cmd"
QT_MOC_LITERAL(6, 59, 24), // "signalChangeCurrentShape"
QT_MOC_LITERAL(7, 84, 11), // "Shape::Code"
QT_MOC_LITERAL(8, 96, 3), // "pen"
QT_MOC_LITERAL(9, 100, 20), // "signalDeleteLastDraw"
QT_MOC_LITERAL(10, 121, 22), // "signalSelectPenChanged"
QT_MOC_LITERAL(11, 144, 23), // "signalSelectFontChanged"
QT_MOC_LITERAL(12, 168, 19), // "signalAddTextToView"
QT_MOC_LITERAL(13, 188, 20), // "loadBackgroundPixmap"
QT_MOC_LITERAL(14, 209, 8), // "bgPixmap"
QT_MOC_LITERAL(15, 218, 1), // "x"
QT_MOC_LITERAL(16, 220, 1), // "y"
QT_MOC_LITERAL(17, 222, 5), // "width"
QT_MOC_LITERAL(18, 228, 6), // "height"
QT_MOC_LITERAL(19, 235, 14), // "exitShotScreen"
QT_MOC_LITERAL(20, 250, 8), // "iscancel"
QT_MOC_LITERAL(21, 259, 10), // "savePixmap"
QT_MOC_LITERAL(22, 270, 16), // "finishScreenShot"
QT_MOC_LITERAL(23, 287, 19), // "slotDrawRectClicked"
QT_MOC_LITERAL(24, 307, 22), // "slotDrawEllipseClicked"
QT_MOC_LITERAL(25, 330, 20), // "slotDrawArrowClicked"
QT_MOC_LITERAL(26, 351, 19), // "slotDrawTextClicked"
QT_MOC_LITERAL(27, 371, 19), // "slotDrawPathClicked"
QT_MOC_LITERAL(28, 391, 17), // "slotRevokeClicked"
QT_MOC_LITERAL(29, 409, 20), // "slotSelectPenChanged"
QT_MOC_LITERAL(30, 430, 21), // "slotSelectFontChanged"
QT_MOC_LITERAL(31, 452, 4), // "font"
QT_MOC_LITERAL(32, 457, 27), // "slotSceneTextLeftBtnPressed"
QT_MOC_LITERAL(33, 485, 3), // "pos"
QT_MOC_LITERAL(34, 489, 10), // "bIsPressed"
QT_MOC_LITERAL(35, 500, 19), // "slotEditTextChanged"
QT_MOC_LITERAL(36, 520, 20) // "slotBtnCancelClicked"
},
"fullScreenWidget\0finishPixmap\0\0"
"exitPixmap\0finishedshot\0cmd\0"
"signalChangeCurrentShape\0Shape::Code\0"
"pen\0signalDeleteLastDraw\0"
"signalSelectPenChanged\0signalSelectFontChanged\0"
"signalAddTextToView\0loadBackgroundPixmap\0"
"bgPixmap\0x\0y\0width\0height\0exitShotScreen\0"
"iscancel\0savePixmap\0finishScreenShot\0"
"slotDrawRectClicked\0slotDrawEllipseClicked\0"
"slotDrawArrowClicked\0slotDrawTextClicked\0"
"slotDrawPathClicked\0slotRevokeClicked\0"
"slotSelectPenChanged\0slotSelectFontChanged\0"
"font\0slotSceneTextLeftBtnPressed\0pos\0"
"bIsPressed\0slotEditTextChanged\0"
"slotBtnCancelClicked"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_fullScreenWidget[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
25, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
8, // signalCount
// signals: name, argc, parameters, tag, flags
1, 1, 139, 2, 0x06 /* Public */,
3, 0, 142, 2, 0x06 /* Public */,
4, 1, 143, 2, 0x06 /* Public */,
6, 2, 146, 2, 0x06 /* Public */,
9, 0, 151, 2, 0x06 /* Public */,
10, 1, 152, 2, 0x06 /* Public */,
11, 2, 155, 2, 0x06 /* Public */,
12, 1, 160, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
13, 1, 163, 2, 0x0a /* Public */,
13, 5, 166, 2, 0x0a /* Public */,
19, 1, 177, 2, 0x0a /* Public */,
19, 0, 180, 2, 0x2a /* Public | MethodCloned */,
21, 0, 181, 2, 0x0a /* Public */,
22, 0, 182, 2, 0x0a /* Public */,
23, 0, 183, 2, 0x0a /* Public */,
24, 0, 184, 2, 0x0a /* Public */,
25, 0, 185, 2, 0x0a /* Public */,
26, 0, 186, 2, 0x0a /* Public */,
27, 0, 187, 2, 0x0a /* Public */,
28, 0, 188, 2, 0x0a /* Public */,
29, 1, 189, 2, 0x0a /* Public */,
30, 2, 192, 2, 0x0a /* Public */,
32, 2, 197, 2, 0x0a /* Public */,
35, 0, 202, 2, 0x0a /* Public */,
36, 0, 203, 2, 0x0a /* Public */,
// signals: parameters
QMetaType::Void, QMetaType::QPixmap, 1,
QMetaType::Void,
QMetaType::Void, QMetaType::QString, 5,
QMetaType::Void, 0x80000000 | 7, QMetaType::QPen, 2, 8,
QMetaType::Void,
QMetaType::Void, QMetaType::QPen, 2,
QMetaType::Void, QMetaType::QPen, QMetaType::QFont, 2, 2,
QMetaType::Void, QMetaType::QString, 2,
// slots: parameters
QMetaType::Void, QMetaType::QPixmap, 14,
QMetaType::Void, QMetaType::QPixmap, QMetaType::Int, QMetaType::Int, QMetaType::Int, QMetaType::Int, 14, 15, 16, 17, 18,
QMetaType::Void, QMetaType::Bool, 20,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void, QMetaType::QPen, 8,
QMetaType::Void, QMetaType::QPen, QMetaType::QFont, 8, 31,
QMetaType::Void, QMetaType::QPointF, QMetaType::Bool, 33, 34,
QMetaType::Void,
QMetaType::Void,
0 // eod
};
void fullScreenWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
auto *_t = static_cast<fullScreenWidget *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->finishPixmap((*reinterpret_cast< const QPixmap(*)>(_a[1]))); break;
case 1: _t->exitPixmap(); break;
case 2: _t->finishedshot((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 3: _t->signalChangeCurrentShape((*reinterpret_cast< Shape::Code(*)>(_a[1])),(*reinterpret_cast< QPen(*)>(_a[2]))); break;
case 4: _t->signalDeleteLastDraw(); break;
case 5: _t->signalSelectPenChanged((*reinterpret_cast< QPen(*)>(_a[1]))); break;
case 6: _t->signalSelectFontChanged((*reinterpret_cast< QPen(*)>(_a[1])),(*reinterpret_cast< QFont(*)>(_a[2]))); break;
case 7: _t->signalAddTextToView((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 8: _t->loadBackgroundPixmap((*reinterpret_cast< const QPixmap(*)>(_a[1]))); break;
case 9: _t->loadBackgroundPixmap((*reinterpret_cast< const QPixmap(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< int(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
case 10: _t->exitShotScreen((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 11: _t->exitShotScreen(); break;
case 12: _t->savePixmap(); break;
case 13: _t->finishScreenShot(); break;
case 14: _t->slotDrawRectClicked(); break;
case 15: _t->slotDrawEllipseClicked(); break;
case 16: _t->slotDrawArrowClicked(); break;
case 17: _t->slotDrawTextClicked(); break;
case 18: _t->slotDrawPathClicked(); break;
case 19: _t->slotRevokeClicked(); break;
case 20: _t->slotSelectPenChanged((*reinterpret_cast< QPen(*)>(_a[1]))); break;
case 21: _t->slotSelectFontChanged((*reinterpret_cast< QPen(*)>(_a[1])),(*reinterpret_cast< QFont(*)>(_a[2]))); break;
case 22: _t->slotSceneTextLeftBtnPressed((*reinterpret_cast< QPointF(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
case 23: _t->slotEditTextChanged(); break;
case 24: _t->slotBtnCancelClicked(); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
{
using _t = void (fullScreenWidget::*)(const QPixmap );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&fullScreenWidget::finishPixmap)) {
*result = 0;
return;
}
}
{
using _t = void (fullScreenWidget::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&fullScreenWidget::exitPixmap)) {
*result = 1;
return;
}
}
{
using _t = void (fullScreenWidget::*)(QString );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&fullScreenWidget::finishedshot)) {
*result = 2;
return;
}
}
{
using _t = void (fullScreenWidget::*)(Shape::Code , QPen );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&fullScreenWidget::signalChangeCurrentShape)) {
*result = 3;
return;
}
}
{
using _t = void (fullScreenWidget::*)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&fullScreenWidget::signalDeleteLastDraw)) {
*result = 4;
return;
}
}
{
using _t = void (fullScreenWidget::*)(QPen );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&fullScreenWidget::signalSelectPenChanged)) {
*result = 5;
return;
}
}
{
using _t = void (fullScreenWidget::*)(QPen , QFont );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&fullScreenWidget::signalSelectFontChanged)) {
*result = 6;
return;
}
}
{
using _t = void (fullScreenWidget::*)(QString );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&fullScreenWidget::signalAddTextToView)) {
*result = 7;
return;
}
}
}
}
QT_INIT_METAOBJECT const QMetaObject fullScreenWidget::staticMetaObject = { {
&QWidget::staticMetaObject,
qt_meta_stringdata_fullScreenWidget.data,
qt_meta_data_fullScreenWidget,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *fullScreenWidget::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *fullScreenWidget::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_fullScreenWidget.stringdata0))
return static_cast<void*>(this);
return QWidget::qt_metacast(_clname);
}
int fullScreenWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 25)
qt_static_metacall(this, _c, _id, _a);
_id -= 25;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 25)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 25;
}
return _id;
}
// SIGNAL 0
void fullScreenWidget::finishPixmap(const QPixmap _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
// SIGNAL 1
void fullScreenWidget::exitPixmap()
{
QMetaObject::activate(this, &staticMetaObject, 1, nullptr);
}
// SIGNAL 2
void fullScreenWidget::finishedshot(QString _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 2, _a);
}
// SIGNAL 3
void fullScreenWidget::signalChangeCurrentShape(Shape::Code _t1, QPen _t2)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)) };
QMetaObject::activate(this, &staticMetaObject, 3, _a);
}
// SIGNAL 4
void fullScreenWidget::signalDeleteLastDraw()
{
QMetaObject::activate(this, &staticMetaObject, 4, nullptr);
}
// SIGNAL 5
void fullScreenWidget::signalSelectPenChanged(QPen _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 5, _a);
}
// SIGNAL 6
void fullScreenWidget::signalSelectFontChanged(QPen _t1, QFont _t2)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)) };
QMetaObject::activate(this, &staticMetaObject, 6, _a);
}
// SIGNAL 7
void fullScreenWidget::signalAddTextToView(QString _t1)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 7, _a);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
| 38.90113 | 239 | 0.609469 | cheechang |
6783defb9c837966b097ecad6ae9876a83d5ce20 | 43,237 | hpp | C++ | task-movement/Koala/container/assoctab.hpp | miloszc/task-movement | 26b40595b590b0fcc3c226fbe8576faa3b5c1244 | [
"MIT"
] | null | null | null | task-movement/Koala/container/assoctab.hpp | miloszc/task-movement | 26b40595b590b0fcc3c226fbe8576faa3b5c1244 | [
"MIT"
] | 19 | 2019-02-15T09:04:22.000Z | 2020-06-23T21:42:29.000Z | task-movement/Koala/container/assoctab.hpp | miloszc/task-movement | 26b40595b590b0fcc3c226fbe8576faa3b5c1244 | [
"MIT"
] | 1 | 2019-05-04T16:12:25.000Z | 2019-05-04T16:12:25.000Z |
// AssocTabConstInterface
template< class K, class V > V AssocTabConstInterface< std::map< K,V > >::operator[]( K arg ) const
{
koalaAssert( !Privates::ZeroAssocKey<K>::isZero(arg),ContExcOutpass );
typename std::map< K,V >::const_iterator i;
i = cont.find( arg );
if (i == cont.end()) return V();
else return i->second;
}
template< class K, class V > V &AssocTabConstInterface< std::map< K,V > >::get( K arg )
{
koalaAssert( !Privates::ZeroAssocKey<K>::isZero(arg),ContExcOutpass );
return (_cont())[arg];
}
template< class K, class V > typename AssocTabConstInterface< std::map< K,V > >::ValType
*AssocTabConstInterface< std::map< K,V > >::valPtr( K arg )
{
koalaAssert( !Privates::ZeroAssocKey<K>::isZero(arg),ContExcOutpass );
typename std::map< K,V >::iterator i = _cont().find( arg );
if (i == _cont().end()) return NULL;
else return &(_cont())[arg];
}
template< class K, class V > bool AssocTabConstInterface< std::map< K,V > >::delKey( K arg )
{
typename std::map< K,V >::iterator pos = _cont().find( arg );
if (pos == _cont().end()) return false;
_cont().erase( pos );
return true;
}
template< class K, class V > K AssocTabConstInterface<std::map< K,V > >::firstKey() const
{
if (cont.begin() == cont.end()) return Privates::ZeroAssocKey<K>::zero();
return cont.begin()->first;
}
template< class K, class V > K AssocTabConstInterface<std::map< K,V > >::lastKey() const
{
typename std::map< K,V >::const_iterator pos;
if (cont.begin() == (pos = cont.end())) return Privates::ZeroAssocKey<K>::zero();
pos--;
return pos->first;
}
template< class K, class V > K AssocTabConstInterface<std::map< K,V > >::prevKey( K arg ) const
{
if (Privates::ZeroAssocKey<K>::isZero(arg)) return lastKey();
typename std::map< K,V >::const_iterator pos = cont.find( arg );
koalaAssert( pos != cont.end(),ContExcOutpass );
if (pos == cont.begin()) return Privates::ZeroAssocKey<K>::zero();
pos--;
return pos->first;
}
template< class K, class V > K AssocTabConstInterface<std::map< K,V > >::nextKey( K arg ) const
{
if (Privates::ZeroAssocKey<K>::isZero(arg)) return firstKey();
typename std::map< K,V >::const_iterator pos = cont.find( arg );
koalaAssert( pos != cont.end(),ContExcOutpass );
pos++;
if (pos == cont.end()) return Privates::ZeroAssocKey<K>::zero();
return pos->first;
}
template< class K, class V > template< class Iterator >
int AssocTabConstInterface< std::map< K,V > >::getKeys( Iterator iter ) const
{
for( K key = firstKey(); !Privates::ZeroAssocKey<K>::isZero(key); key = nextKey( key ) )
{
*iter = key;
iter++;
}
return size();
}
// AssocTabInterface
template< class T > AssocTabInterface< T > &AssocTabInterface< T >::operator=( const AssocTabInterface< T > &arg )
{
if (&arg.cont == &cont) return *this;
clear();
for( KeyType k = arg.firstKey(); !Privates::ZeroAssocKey<KeyType>::isZero(k); k = arg.nextKey( k ) ) operator[]( k ) = arg[k];
return *this;
}
template< class T > AssocTabInterface< T > &AssocTabInterface< T >::operator=( const AssocTabConstInterface< T > &arg )
{
if (&arg.cont == &cont) return *this;
clear();
for( KeyType k = arg.firstKey(); !Privates::ZeroAssocKey<KeyType>::isZero(k); k = arg.nextKey( k ) ) operator[]( k )=arg[k];
return *this;
}
template< class T > template< class AssocCont >
AssocTabInterface< T > &AssocTabInterface< T >::operator=( const AssocCont &arg )
{
Privates::AssocTabTag< KeyType >::operator=( arg );
clear();
for( KeyType k = arg.firstKey(); !Privates::ZeroAssocKey<KeyType>::isZero(k); k = arg.nextKey( k ) ) operator[]( k )=arg[k];
return *this;
}
// AssocTable
template< class T > AssocTable< T > &AssocTable< T >::operator=( const AssocTable< T > &X )
{
if (this == &X) return *this;
cont = X.cont;
return *this;
}
template< class T > AssocTable< T > &AssocTable< T >::operator=( const T &X )
{
if (&cont == &X) return *this;
cont = X;
return *this;
}
template< class T > template< class AssocCont >
AssocTable< T > &AssocTable< T >::operator=( const AssocCont &arg )
{
Privates::AssocTabTag< typename AssocTabInterface< T >::KeyType >::operator=( arg );
if (Privates::asssocTabInterfTest( arg ) == &cont) return *this;
clear();
for( typename AssocTabInterface< T >::KeyType k = arg.firstKey(); !Privates::ZeroAssocKey<KeyType>::isZero(k); k = arg.nextKey( k ) )
operator[]( k ) = arg[k];
return *this;
}
// AssocContReg
AssocKeyContReg &AssocKeyContReg::operator=( const AssocKeyContReg &X )
{
if (&X != this) next = 0;
return *this;
}
AssocContReg *AssocKeyContReg::find( AssocContBase *cont )
{
AssocContReg *res;
for( res = this; res->next; res= &(res->next->getReg( res->nextPos )) )
if (res->next == cont) return res;
return NULL;
}
void AssocKeyContReg::deregister()
{
std::pair< AssocContBase *,int > a = std::pair< AssocContBase *,int >( next,nextPos ), n;
next = 0;
while (a.first)
{
AssocContReg *p = &a.first->getReg( a.second );
n = std::pair< AssocContBase *,int >( p->next,p->nextPos );
a.first->DelPosCommand( a.second );
a = n;
}
}
// AssocArray
template< class Klucz, class Elem, class Container > template< class AssocCont >
AssocArray< Klucz,Elem,Container > &AssocArray< Klucz,Elem,Container >::operator=( const AssocCont &arg )
{
Privates::AssocTabTag< Klucz >::operator=( arg );
clear();
for( Klucz k = arg.firstKey(); k; k = arg.nextKey( k ) ) operator[]( k ) = arg[k];
return *this;
}
template< class Klucz, class Elem, class Container > Elem *AssocArray< Klucz,Elem,Container >::valPtr( Klucz v )
{
int x = keyPos( v );
if (x == -1) return NULL;
else return &tab[x].val;
}
template< class Klucz, class Elem, class Container >
AssocArray< Klucz,Elem,Container >::AssocArray( const AssocArray< Klucz,Elem,Container > &X ):
tab(X.tab)
{
for( int i = tab.firstPos(); i != -1; i = tab.nextPos( i ) )
{
tab[i].assocReg = tab[i].key->assocReg;
tab[i].key->assocReg.next = this;
tab[i].key->assocReg.nextPos = i;
}
}
template< class Klucz, class Elem, class Container > AssocArray< Klucz,Elem,Container >
&AssocArray< Klucz,Elem,Container >::operator=( const AssocArray< Klucz,Elem,Container > &X )
{
if (&X == this) return *this;
clear();
tab = X.tab;
for( int i = tab.firstPos(); i != -1; i = tab.nextPos( i ) )
{
tab[i].assocReg = tab[i].key->assocReg;
tab[i].key->assocReg.next = this;
tab[i].key->assocReg.nextPos = i;
}
return *this;
}
template< class Klucz, class Elem, class Container > int AssocArray< Klucz,Elem,Container >::keyPos( Klucz v ) const
{
if (!v) return -1;
AssocContReg *preg = v->assocReg.find( const_cast<AssocArray< Klucz,Elem,Container > * > (this) );
if (preg) return preg->nextPos;
else return -1;
}
template< class Klucz, class Elem, class Container > bool AssocArray< Klucz,Elem,Container >::delKey( Klucz v )
{
int x;
if (!v) return false;
AssocContReg *preg = v->assocReg.find( this );
if (!preg) return false;
x = preg->nextPos;
*preg = tab[x].assocReg;
tab.delPos( x );
return true;
}
template< class Klucz, class Elem, class Container > Klucz AssocArray< Klucz,Elem,Container >::firstKey() const
{
if (tab.empty()) return 0;
else return tab[tab.firstPos()].key;
}
template< class Klucz, class Elem, class Container > Klucz AssocArray< Klucz,Elem,Container >::lastKey() const
{
if (tab.empty()) return 0;
else return tab[tab.lastPos()].key;
}
template< class Klucz, class Elem, class Container > Klucz AssocArray< Klucz,Elem,Container >::nextKey( Klucz v ) const
{
if (!v) return firstKey();
int x= keyPos( v );
koalaAssert( x != -1,ContExcOutpass );
if ((x = tab.nextPos( x )) == -1) return 0;
return tab[x].key;
}
template< class Klucz, class Elem, class Container > Klucz AssocArray< Klucz,Elem,Container >::prevKey( Klucz v ) const
{
if (!v) return lastKey();
int x = keyPos( v );
koalaAssert( x != -1,ContExcOutpass );
if ((x = tab.prevPos( x )) == -1) return 0;
return tab[x].key;
}
template< class Klucz, class Elem, class Container > Elem &AssocArray< Klucz,Elem,Container >::operator[]( Klucz v )
{
koalaAssert( v,ContExcWrongArg );
int x = keyPos( v );
if (x == -1)
{
x = tab.newPos();
tab[x].key = v;
tab[x].assocReg = v->assocReg;
v->assocReg.next = this;
v->assocReg.nextPos = x;
}
return tab[x].val;
}
template< class Klucz, class Elem, class Container > Elem AssocArray< Klucz,Elem,Container >::operator[]( Klucz v ) const
{
koalaAssert( v,ContExcWrongArg );
int x = keyPos( v );
if (x == -1) return Elem();
return tab[x].val;
}
template< class Klucz, class Elem, class Container > void AssocArray< Klucz,Elem,Container >::defrag()
{
tab.defrag();
for( int i = 0; i < tab.size(); i++ )
tab[i].key->assocReg.find( this )->nextPos = i;
}
template< class Klucz, class Elem, class Container > void AssocArray< Klucz,Elem,Container >::clear()
{
for( Klucz v = firstKey(); v; v = firstKey() ) delKey( v );
}
template< class Klucz, class Elem, class Container > template< class Iterator >
int AssocArray< Klucz,Elem,Container >::getKeys( Iterator iter ) const
{
for( Klucz key = firstKey(); key; key = nextKey( key ) )
{
*iter = key;
iter++;
}
return size();
}
namespace Privates {
// PseudoAssocArray
template< class Klucz, class Elem, class AssocCont, class Container > template< class AssocCont2 >
PseudoAssocArray< Klucz,Elem,AssocCont,Container >
&PseudoAssocArray< Klucz,Elem,AssocCont,Container >::operator=( const AssocCont2 &arg )
{
Privates::AssocTabTag< Klucz >::operator=( arg );
clear();
for( Klucz k = arg.firstKey(); k; k = arg.nextKey( k ) ) operator[]( k ) = arg[k];
return *this;
}
template< class Klucz, class Elem, class AssocCont, class Container >
int PseudoAssocArray< Klucz,Elem,AssocCont,Container >::keyPos( Klucz v ) const
{
if (!v) return -1;
if (!assocTab.hasKey( v )) return -1;
return assocTab[v];
}
template< class Klucz, class Elem, class AssocCont, class Container >
bool PseudoAssocArray< Klucz,Elem,AssocCont,Container >::delKey( Klucz v )
{
if (!v) return false;
if (!assocTab.hasKey( v )) return false;
tab.delPos( assocTab[v] );
assocTab.delKey( v );
return true;
}
template< class Klucz, class Elem, class AssocCont, class Container >
Klucz PseudoAssocArray< Klucz,Elem,AssocCont,Container >::firstKey() const
{
if (tab.empty()) return 0;
else return tab[tab.firstPos()].key;
}
template< class Klucz, class Elem, class AssocCont, class Container >
Klucz PseudoAssocArray< Klucz,Elem,AssocCont,Container >::lastKey() const
{
if (tab.empty()) return 0;
else return tab[tab.lastPos()].key;
}
template< class Klucz, class Elem, class AssocCont, class Container >
Klucz PseudoAssocArray< Klucz,Elem,AssocCont,Container >::nextKey( Klucz v ) const
{
if (!v) return firstKey();
int x = keyPos( v );
koalaAssert( x != -1,ContExcOutpass );
if ((x = tab.nextPos( x )) == -1) return 0;
return tab[x].key;
}
template< class Klucz, class Elem, class AssocCont, class Container >
Klucz PseudoAssocArray< Klucz,Elem,AssocCont,Container >::prevKey( Klucz v ) const
{
if (!v) return lastKey();
int x = keyPos( v );
koalaAssert( x != -1,ContExcOutpass );
if ((x = tab.prevPos( x )) == -1) return 0;
return tab[x].key;
}
template< class Klucz, class Elem, class AssocCont, class Container >
Elem &PseudoAssocArray< Klucz,Elem,AssocCont,Container >::operator[]( Klucz v )
{
koalaAssert( v,ContExcWrongArg );
int x = keyPos( v );
if (x == -1)
{
tab[x = tab.newPos()].key = v;
assocTab[v] = x;
}
return tab[x].val;
}
template< class Klucz, class Elem, class AssocCont, class Container >
Elem PseudoAssocArray< Klucz,Elem,AssocCont,Container >::operator[]( Klucz v ) const
{
koalaAssert( v,ContExcOutpass );
int x = keyPos( v );
if (x == -1) return Elem();
return tab[x].val;
}
template< class Klucz, class Elem, class AssocCont, class Container >
void PseudoAssocArray< Klucz,Elem,AssocCont,Container >::defrag()
{
tab.defrag();
for( int i = 0; i < tab.size(); i++ ) assocTab[tab[i].key] = i;
}
template< class Klucz, class Elem, class AssocCont, class Container > template< class Iterator >
int PseudoAssocArray< Klucz,Elem,AssocCont,Container >::getKeys( Iterator iter ) const
{
for( Klucz key = firstKey(); key; key = nextKey( key ) )
{
*iter = key;
iter++;
}
return size();
}
template< class Klucz, class Elem, class AssocCont, class Container >
void PseudoAssocArray< Klucz,Elem,AssocCont,Container >::reserve( int arg )
{
tab.reserve( arg );
assocTab.reserve( arg );
}
template< class Klucz, class Elem, class AssocCont, class Container >
Elem *PseudoAssocArray< Klucz,Elem,AssocCont,Container >::valPtr( Klucz v )
{
int x = keyPos( v );
if (x == -1) return NULL;
else return &tab[x].val;
}
template< class Klucz, class Elem, class AssocCont, class Container >
void PseudoAssocArray< Klucz,Elem,AssocCont,Container >::clear()
{
tab.clear();
assocTab.clear();
}
}
// Assoc2DimTabAddr
inline int Assoc2DimTabAddr< AMatrFull >::wsp2pos( std::pair< int,int > w ) const
{
int mfs = std::max( w.first,w.second );
return mfs * mfs + mfs + w.second - w.first;
}
inline std::pair< int,int > Assoc2DimTabAddr< AMatrFull >::pos2wsp( int pos ) const
{
int x = (int)sqrt( (double)pos );
if (x * x + x - pos > 0) return std::pair< int,int >( x,pos - x * x );
else return std::pair< int,int >( x * x + 2 * x - pos,x );
}
inline int Assoc2DimTabAddr< AMatrNoDiag >::wsp2pos( std::pair< int,int > w ) const
{
int mfs = std::max( w.first,w.second );
return mfs * mfs + w.second - w.first - ((w.first > w.second) ? 0 : 1);
}
inline std::pair< int,int > Assoc2DimTabAddr< AMatrNoDiag >::pos2wsp( int pos ) const
{
int x = (int)sqrt( (double)pos );
if (pos - x * x - x >= 0) return std::pair< int,int >( x + 1,pos - x * x - x );
else return std::pair< int,int >( x * x + x - 1 - pos,x );
}
inline int Assoc2DimTabAddr< AMatrClTriangle >::wsp2pos( std::pair< int,int > w ) const
{
if (w.first < w.second)
{
int z = w.first;
w.first = w.second;
w.second = z;
}
return w.first * (w.first + 1) / 2 + w.second;
}
inline std::pair< int,int > Assoc2DimTabAddr< AMatrClTriangle >::pos2wsp( int pos ) const
{
int x = (int)sqrt( (double)2 * pos ), xx = pos - x * (x + 1) / 2;
if (xx >= 0) return std::pair< int,int >( x,xx );
else return std::pair< int,int >( x - 1,xx + x );
}
inline int Assoc2DimTabAddr< AMatrTriangle >::wsp2pos( std::pair< int,int > w ) const
{
if (w.first < w.second)
{
int z = w.first;
w.first = w.second;
w.second = z;
}
return w.first * (w.first - 1) / 2 + w.second;
}
inline std::pair< int,int > Assoc2DimTabAddr< AMatrTriangle >::pos2wsp( int pos ) const
{
int x = (int)sqrt( (double)2 * pos ), xx = pos - x * (x + 1) / 2;
if (xx >= 0) return std::pair< int,int >( x + 1,xx );
else return std::pair< int,int >( x,xx + x );
}
// AssocMatrix
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
Klucz AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::AssocIndex::pos2klucz( int arg )
{
if (arg == -1) return 0;
return IndexContainer::tab[arg].key;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::AssocIndex::DelPosCommand( int pos )
{
int LOCALARRAY( tabpos,IndexContainer::size() );
int l = 0;
int i = IndexContainer::tab.firstPos();
for( ; i != -1; i = IndexContainer::tab.nextPos( i ) )
tabpos[l++] = i;
for( l--; l >= 0; l-- )
{
owner->delPos( std::pair< int,int >( pos,tabpos[l] ) );
if ((aType == AMatrNoDiag || aType == AMatrFull) && (pos != tabpos[l]))
owner->delPos( std::pair< int,int >( tabpos[l],pos ) );
}
IndexContainer::tab.delPos( pos );
Klucz LOCALARRAY(keytab,IndexContainer::size() );
int res=this->getKeys(keytab);
for( int j=0;j<res;j++)
if (!this->operator[]( keytab[j] )) IndexContainer::delKey( keytab[j] );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::delPos( std::pair< int,int > wsp )
{
if (!Assoc2DimTabAddr< aType >::correctPos( wsp.first,wsp.second )) return;
int x;
if (!bufor[x = Assoc2DimTabAddr< aType >::wsp2pos( wsp )].present()) return;
if (bufor[x].next != -1) bufor[bufor[x].next].prev = bufor[x].prev;
else last = bufor[x].prev;
if (bufor[x].prev != -1) bufor[bufor[x].prev].next = bufor[x].next;
else first = bufor[x].next;
bufor[x] = Privates::BlockOfAssocMatrix< Elem >();
siz--;
--index.tab[wsp.first].val;
--index.tab[wsp.second].val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::AssocMatrix( int asize):
index( asize ), siz( 0 ), first( -1 ), last( -1 )
{
bufor.clear();
bufor.reserve( Assoc2DimTabAddr< aType >::bufLen( asize ) );
index.owner = this;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >
&AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::operator=(
const AssocMatrix< Klucz,Elem,aType,Container,IndexContainer > &X )
{
if (&X == this) return *this;
index = X.index;
bufor = X.bufor;
siz = X.siz;
first = X.first;
last = X.last;
index.owner = this;
return *this;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
bool AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::delInd( Klucz v )
{
if (!hasInd( v )) return false;
Klucz LOCALARRAY( tab,index.size() );
int i = 0;
for( Klucz x = index.firstKey(); x; x = index.nextKey( x ) ) tab[i++] = x;
for( i--; i >= 0; i-- )
{
delKey( v,tab[i] );
if ((aType == AMatrNoDiag || aType == AMatrFull) && (v != tab[i]))
delKey( tab[i],v );
}
index.delKey( v );
return true;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
template <class ExtCont>
int AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::slice1( Klucz v, ExtCont &tab ) const
{
if (!index.hasKey( v )) return 0;
int licz = 0;
for( Klucz x = index.firstKey(); x; x = index.nextKey( x ) )
if (hasKey( v,x ))
{
tab[x] = this->operator()( v,x );
licz++;
}
return licz;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
template<class ExtCont >
int AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::slice2( Klucz v, ExtCont &tab ) const
{
if (!index.hasKey( v )) return 0;
int licz = 0;
for( Klucz x = index.firstKey(); x; x = index.nextKey( x ) )
if (hasKey( x,v ))
{
tab[x] = this->operator()( x,v );
licz++;
}
return licz;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
bool AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::hasKey( Klucz u, Klucz v ) const
{
if (!u || !v) return false;
if (!Assoc2DimTabAddr< aType >::correctPos( u,v )) return false;
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1 || wsp.second == -1) return false;
return bufor[Assoc2DimTabAddr< aType >::wsp2pos( wsp )].present();
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
bool AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::delKey( Klucz u, Klucz v )
{
if (!u || !v) return false;
if (!Assoc2DimTabAddr< aType >::correctPos( u,v )) return false;
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1 || wsp.second == -1) return false;
int x;
if (bufor[x = Assoc2DimTabAddr< aType >::wsp2pos( wsp )].present())
{
if (bufor[x].next != -1) bufor[bufor[x].next].prev = bufor[x].prev;
else last = bufor[x].prev;
if (bufor[x].prev != -1) bufor[bufor[x].prev].next = bufor[x].next;
else first = bufor[x].next;
bufor[x] = Privates::BlockOfAssocMatrix< Elem >();
siz--;
if (--index[u] == 0) index.delKey( u );
if (--index[v] == 0) index.delKey( v );
return true;
}
return false;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
Elem &AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::operator()( Klucz u, Klucz v )
{
koalaAssert( u && v && Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1)
{
index[u] = 0;
wsp.first = index.klucz2pos( u );
}
if (wsp.second == -1)
{
index[v] = 0;
wsp.second = index.klucz2pos( v );
}
bufor.resize( std::max( (int)bufor.size(),Assoc2DimTabAddr< aType >::bufLen( index.size() ) ) );
int x = Assoc2DimTabAddr< aType >::wsp2pos( wsp );
if (!bufor[x].present())
{
if ((bufor[x].prev = last) == -1) first = x;
else bufor[bufor[x].prev].next = x;
bufor[x].next = -1;
last = x;
index[u]++;
index[v]++;
siz++;
}
return bufor[x].val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
Elem AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::operator()( Klucz u, Klucz v ) const
{
koalaAssert( u && v && Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1 || wsp.second == -1) return Elem();
int x = Assoc2DimTabAddr< aType >::wsp2pos( wsp );
if (!bufor[x].present()) return Elem();
return bufor[x].val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
Elem* AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::valPtr( Klucz u, Klucz v )
{
koalaAssert( u && v && Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1 || wsp.second == -1) return NULL;
int pos;
if (!bufor[pos = Assoc2DimTabAddr< aType >::wsp2pos( wsp )].present()) return NULL;
return &bufor[pos].val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
std::pair< Klucz,Klucz > AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::firstKey() const
{
if (!siz) return std::pair< Klucz,Klucz >( (Klucz)0,(Klucz)0 );
std::pair< int,int > wsp = Assoc2DimTabAddr< aType >::pos2wsp( first );
return Assoc2DimTabAddr< aType >::key( std::pair< Klucz,Klucz >( index.pos2klucz( wsp.first ),
index.pos2klucz( wsp.second ) ) );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
std::pair< Klucz,Klucz > AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::lastKey() const
{
if (!siz) return std::pair< Klucz,Klucz >( (Klucz)0,(Klucz)0 );
std::pair< int,int > wsp = Assoc2DimTabAddr< aType >::pos2wsp( last );
return Assoc2DimTabAddr< aType >::key( std::pair< Klucz,Klucz >( index.pos2klucz( wsp.first ),
index.pos2klucz( wsp.second ) ) );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
std::pair< Klucz,Klucz > AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::nextKey( Klucz u, Klucz v ) const
{
if (!u || !v) return firstKey();
koalaAssert( Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
koalaAssert( wsp.first != -1 && wsp.second != -1,ContExcOutpass );
int x = Assoc2DimTabAddr< aType >::wsp2pos( wsp );
koalaAssert( bufor[x].present(),ContExcOutpass );
x = bufor[x].next;
if (x == -1) return std::pair< Klucz,Klucz >( (Klucz)0,(Klucz)0 );
wsp = Assoc2DimTabAddr< aType >::pos2wsp( x );
return Assoc2DimTabAddr< aType >::key( std::pair< Klucz,Klucz >( index.pos2klucz( wsp.first ),
index.pos2klucz( wsp.second ) ) );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
template< class MatrixContainer > AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >
&AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::operator=( const MatrixContainer &X )
{
Privates::Assoc2DimTabTag< Klucz,aType >::operator=( X );
this->clear();
int rozm;
std::pair<Klucz,Klucz> LOCALARRAY(tab,rozm=X.size());
X.getKeys(tab);
for( int i=0;i<rozm;i++ )
this->operator()( tab[i] )=X( tab[i] );
return *this;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
std::pair< Klucz,Klucz > AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::prevKey( Klucz u, Klucz v ) const
{
if (!u || !v) return lastKey();
koalaAssert( Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
koalaAssert( wsp.first != -1 && wsp.second != -1,ContExcOutpass );
int x = Assoc2DimTabAddr< aType >::wsp2pos( wsp );
koalaAssert( bufor[x].present(),ContExcOutpass );
x = bufor[x].prev;
if (x == -1) return std::pair< Klucz,Klucz >( (Klucz)0,(Klucz)0 );
wsp = Assoc2DimTabAddr< aType >::pos2wsp( x );
return Assoc2DimTabAddr< aType >::key( std::pair< Klucz,Klucz >(index.pos2klucz( wsp.first ),
index.pos2klucz( wsp.second ) ) );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::clear()
{
index.clear();
int in;
for( int i = first; i != -1; i = in )
{
in = bufor[i].next;
bufor[i] = Privates::BlockOfAssocMatrix< Elem >();
}
siz = 0;
first = last = -1;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::reserve( int arg )
{
index.reserve( arg );
bufor.reserve( Assoc2DimTabAddr< aType >::bufLen( arg ) );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::defrag()
{
DefragMatrixPom LOCALARRAY( tab,siz );
int i=0;
for( int pos = first; pos != -1; pos = bufor[pos].next )
{
tab[i].val = bufor[pos].val;
std::pair< int,int > wsp = Assoc2DimTabAddr< aType >::pos2wsp( pos );
tab[i].u = index.pos2klucz( wsp.first );
tab[i].v = index.pos2klucz( wsp.second );
i++;
}
bufor.clear();
index.clear();
index.defrag();
{
Container tmp;
bufor.swap(tmp);
}
siz = 0;
first = last = -1;
for( int ii = 0; ii < i ; ii++ ) this->operator()( tab[ii].u,tab[ii].v ) = tab[ii].val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer > template< class Iterator >
int AssocMatrix< Klucz,Elem,aType,Container,IndexContainer >::getKeys( Iterator iter ) const
{
for( std::pair< Klucz,Klucz > key = firstKey(); key.first; key = nextKey( key ) )
{
*iter = key;
iter++;
}
return size();
}
//template<class Klucz, class Elem, AssocMatrixType aType, class C, class IC >
// std::ostream &operator<<( std::ostream &out, const AssocMatrix< Klucz,Elem,aType,C,IC > &cont )
//{
// out << '{';
// int siz = cont.size();
// std::pair< typename AssocMatrix< Klucz,Elem,aType,C,IC >::KeyType,typename AssocMatrix< Klucz,Elem,aType,C,IC >::KeyType >
// key = cont.firstKey();
// for( ; siz; siz-- )
// {
// out << '(' << key.first << ',' << key.second << ':'<< cont(key) << ')';
// if (siz>1)
// {
// key = cont.nextKey( key );
// out << ',';
// }
// }
// out << '}';
// return out;
//}
// AssocInserter
template< class T > template< class K, class V >
AssocInserter< T > &AssocInserter< T >::operator=( const std::pair< K,V > &pair )
{
(*container)[(typename T::KeyType)pair.first] = (typename T::ValType)pair.second;
return *this;
}
template< class T, class Fun > template< class K >
AssocFunctorInserter< T,Fun > &AssocFunctorInserter< T,Fun >::operator=( const K &arg )
{
(*container)[(typename T::KeyType)arg] = (typename T::ValType)functor( arg );
return *this;
}
template< class Cont,class K > std::ostream &Privates::printAssoc( std::ostream &out, const Cont &cont,Privates::AssocTabTag< K > )
{
out << '{';
int siz = cont.size();
typename Cont::KeyType key = cont.firstKey();
for( ; siz; siz-- )
{
out << '(' << key << ',' << cont[key] << ')';
if (key != cont.lastKey())
{
key = cont.nextKey( key );
out << ',';
}
}
out << '}';
return out;
}
template< class Cont,class K,AssocMatrixType aType > std::ostream &Privates::printAssoc( std::ostream &out, const Cont &cont, Privates::Assoc2DimTabTag< K,aType > )
{
out << '{';
int siz = cont.size();
std::pair< typename Cont::KeyType,typename Cont::KeyType >
key = cont.firstKey();
for( ; siz; siz-- )
{
out << '(' << key.first << ',' << key.second << ':'<< cont(key) << ')';
if (siz>1)
{
key = cont.nextKey( key );
out << ',';
}
}
out << '}';
return out;
}
template< AssocMatrixType aType, class Container>
Assoc2DimTable< aType,Container > &Assoc2DimTable< aType,Container >::operator=(const Assoc2DimTable< aType,Container > &X)
{
if (this==&X) return *this;
acont=X.acont;
return *this;
}
template< AssocMatrixType aType, class Container> template< class MatrixContainer >
Assoc2DimTable< aType,Container > &Assoc2DimTable< aType,Container >::operator=( const MatrixContainer &X )
{
Privates::Assoc2DimTabTag< KeyType,aType >::operator=( X );
this->clear();
int rozm;
std::pair<KeyType,KeyType> LOCALARRAY(tab,rozm=X.size());
X.getKeys(tab);
for( int i=0;i<rozm;i++ )
this->operator()( tab[i] )=X( tab[i] );
return *this;
}
template< AssocMatrixType aType, class Container>
bool Assoc2DimTable< aType,Container >::hasKey( typename Assoc2DimTable< aType,Container >::KeyType u,
typename Assoc2DimTable< aType,Container >::KeyType v ) const
{
if (!u || !v) return false;
if (!Assoc2DimTabAddr< aType >::correctPos( u,v )) return false;
return interf.hasKey(Assoc2DimTabAddr< aType >::key(u,v));
}
template< AssocMatrixType aType, class Container>
bool Assoc2DimTable< aType,Container >::delKey( typename Assoc2DimTable< aType,Container >::KeyType u,
typename Assoc2DimTable< aType,Container >::KeyType v)
{
if (!u || !v) return false;
if (!Assoc2DimTabAddr< aType >::correctPos( u,v )) return false;
return interf.delKey(Assoc2DimTabAddr< aType >::key(u,v));
}
template< AssocMatrixType aType, class Container>
std::pair< typename Assoc2DimTable< aType,Container >::KeyType,typename Assoc2DimTable< aType,Container >::KeyType >
Assoc2DimTable< aType,Container >::nextKey( typename Assoc2DimTable< aType,Container >::KeyType u,
typename Assoc2DimTable< aType,Container >::KeyType v) const
{
if (!u || !v) return firstKey();
koalaAssert( Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
return interf.nextKey(Assoc2DimTabAddr< aType >::key(u,v));
}
template< AssocMatrixType aType, class Container>
std::pair< typename Assoc2DimTable< aType,Container >::KeyType,typename Assoc2DimTable< aType,Container >::KeyType >
Assoc2DimTable< aType,Container >::prevKey( typename Assoc2DimTable< aType,Container >::KeyType u,
typename Assoc2DimTable< aType,Container >::KeyType v) const
{
if (!u || !v) return lastKey();
koalaAssert( Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
return interf.prevKey(Assoc2DimTabAddr< aType >::key(u,v));
}
template< AssocMatrixType aType, class Container>
bool Assoc2DimTable< aType,Container >::hasInd( typename Assoc2DimTable< aType,Container >::KeyType v ) const
{
for(std::pair< KeyType,KeyType> key=this->firstKey();
!Privates::ZeroAssocKey<std::pair< KeyType,KeyType> >::isZero(key);
key=this->nextKey(key)) if (key.first==v || key.second==v) return true;
return false;
}
template< AssocMatrixType aType, class Container>
bool Assoc2DimTable< aType,Container >::delInd( typename Assoc2DimTable< aType,Container >::KeyType v )
{
bool flag=false;
std::pair< KeyType,KeyType> key,key2;
for(std::pair< KeyType,KeyType> key=this->firstKey();
!Privates::ZeroAssocKey<std::pair< KeyType,KeyType> >::isZero(key);key=key2)
{
key2=this->nextKey(key);
if (key.first==v || key.second==v)
{
flag=true;
this->delKey(key);
}
}
return flag;
}
template< AssocMatrixType aType, class Container> template<class DefaultStructs, class Iterator >
int Assoc2DimTable< aType,Container >::getInds( Iterator iter ) const
{ typename DefaultStructs:: template AssocCont< KeyType, char >::Type inds(2*this->size());
for(std::pair< KeyType,KeyType> key=this->firstKey();
!Privates::ZeroAssocKey<std::pair< KeyType,KeyType> >::isZero(key);
key=this->nextKey(key))
inds[key.first]=inds[key.second]='A';
return inds.getKeys(iter);
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
inline void SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::AssocIndex::DelPosCommand( int pos )
{
int LOCALARRAY( tabpos,IndexContainer::size() );
int l = 0;
int i = IndexContainer::tab.firstPos();
for( ; i != -1; i = IndexContainer::tab.nextPos( i ) )
tabpos[l++] = i;
for( l--; l >= 0; l-- )
{
owner->delPos( std::pair< int,int >( pos,tabpos[l] ) );
if ((aType == AMatrNoDiag || aType == AMatrFull) && (pos != tabpos[l]))
owner->delPos( std::pair< int,int >( tabpos[l],pos ) );
}
IndexContainer::tab.delPos( pos );
Klucz LOCALARRAY(keytab,IndexContainer::size() );
int res=this->getKeys(keytab);
for( int j=0;j<res;j++)
if (!this->operator[]( keytab[j] )) IndexContainer::delKey( keytab[j] );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::delPos( std::pair< int,int > wsp )
{
if (!Assoc2DimTabAddr< aType >::correctPos( wsp.first,wsp.second )) return;
std::pair< int,int > x=Assoc2DimTabAddr< aType >::wsp2pos2( wsp );
if (!bufor.operator[](x.first).operator[](x.second).present) return;
bufor.operator[](x.first).operator[](x.second) = Privates::BlockOfSimpleAssocMatrix< Elem >();
siz--;
--index.tab[wsp.first].val;
--index.tab[wsp.second].val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::resizeBuf( int asize )
{
asize=std::max((int)bufor.size(),asize );
bufor.resize(asize);
for(int i=0;i<asize;i++) bufor.operator[](i).resize
( std::max(Assoc2DimTabAddr< aType >::colSize( i,asize ),(int)bufor.operator[](i).size()) );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
SimpleAssocMatrix< Klucz,Elem,aType,Container,IndexContainer >
&SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::operator=( const SimpleAssocMatrix< Klucz,Elem,aType,Container,IndexContainer > & X)
{
if (&X == this) return *this;
index = X.index;
bufor = X.bufor;
siz = X.siz;
index.owner = this;
return *this;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
template< class MatrixContainer > SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>
&SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::operator=( const MatrixContainer &X )
{
Privates::Assoc2DimTabTag< Klucz,aType >::operator=( X );
this->clear();
int rozm;
std::pair<Klucz,Klucz> LOCALARRAY(tab,rozm=X.size());
X.getKeys(tab);
for( int i=0;i<rozm;i++ )
this->operator()( tab[i] )=X( tab[i] );
return *this;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::reserve( int asize )
{
index.reserve( asize );
bufor.resize( asize=std::max((int)bufor.size(),asize ));
for(int i=0;i<asize;i++) bufor.operator[](i).reserve( Assoc2DimTabAddr< aType >::colSize( i,asize ) );
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::clear()
{
index.clear();
int bufsize=bufor.size();
bufor.clear();
this->resizeBuf(bufsize);
siz = 0;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
template <class ExtCont> int SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::slice1( Klucz v, ExtCont &tab ) const
{
if (!index.hasKey( v )) return 0;
int licz = 0;
for( Klucz x = index.firstKey(); x; x = index.nextKey( x ) )
if (hasKey( v,x ))
{
tab[x] = this->operator()( v,x );
licz++;
}
return licz;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
template <class ExtCont> int SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::slice2( Klucz v, ExtCont &tab ) const
{
if (!index.hasKey( v )) return 0;
int licz = 0;
for( Klucz x = index.firstKey(); x; x = index.nextKey( x ) )
if (hasKey( x,v ))
{
tab[x] = this->operator()( x,v );
licz++;
}
return licz;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
bool SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::delInd( Klucz v )
{
if (!hasInd( v )) return false;
Klucz LOCALARRAY( tab,index.size() );
int i = 0;
for( Klucz x = index.firstKey(); x; x = index.nextKey( x ) ) tab[i++] = x;
for( i--; i >= 0; i-- )
{
delKey( v,tab[i] );
if ((aType == AMatrNoDiag || aType == AMatrFull) && (v != tab[i]))
delKey( tab[i],v );
}
index.delKey( v );
return true;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
bool SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::hasKey( Klucz u, Klucz v ) const
{
if (!u || !v) return false;
if (!Assoc2DimTabAddr< aType >::correctPos( u,v )) return false;
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1 || wsp.second == -1) return false;
wsp=Assoc2DimTabAddr< aType >::wsp2pos2( wsp );
return bufor.operator[](wsp.first).operator[](wsp.second).present;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
bool SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::delKey( Klucz u, Klucz v)
{
if (!u || !v) return false;
if (!Assoc2DimTabAddr< aType >::correctPos( u,v )) return false;
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1 || wsp.second == -1) return false;
std::pair< int,int > x=Assoc2DimTabAddr< aType >::wsp2pos2( wsp );
if (bufor.operator[](x.first).operator[](x.second).present)
{
bufor.operator[](x.first).operator[](x.second) = Privates::BlockOfSimpleAssocMatrix< Elem >();
siz--;
if (--index[u] == 0) index.delKey( u );
if (--index[v] == 0) index.delKey( v );
return true;
}
return false;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
Elem &SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::operator()( Klucz u, Klucz v )
{
koalaAssert( u && v && Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1)
{
index[u] = 0;
wsp.first = index.klucz2pos( u );
}
if (wsp.second == -1)
{
index[v] = 0;
wsp.second = index.klucz2pos( v );
}
int q,qq;
this->resizeBuf( q=std::max( qq=(int)bufor.size(), index.size() ) );
std::pair< int,int > x = Assoc2DimTabAddr< aType >::wsp2pos2( wsp );
if (!bufor.operator[](x.first).operator[](x.second).present)
{
bufor.operator[](x.first).operator[](x.second).present=true;
index[u]++;
index[v]++;
siz++;
}
return bufor.operator[](x.first).operator[](x.second).val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
Elem SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::operator()( Klucz u, Klucz v) const
{
koalaAssert( u && v && Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1 || wsp.second == -1) return Elem();
std::pair< int,int > x = Assoc2DimTabAddr< aType >::wsp2pos2( wsp );
if (!bufor.operator[](x.first).operator[](x.second).present) return Elem();
return bufor.operator[](x.first).operator[](x.second).val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
Elem *SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::valPtr(Klucz u, Klucz v)
{
koalaAssert( u && v && Assoc2DimTabAddr< aType >::correctPos( u,v ),ContExcWrongArg );
std::pair< int,int > wsp = std::pair< int,int >( index.klucz2pos( u ),index.klucz2pos( v ) );
if (wsp.first == -1 || wsp.second == -1) return NULL;
std::pair< int,int > pos=Assoc2DimTabAddr< aType >::wsp2pos2( wsp );
if (!bufor.operator[](pos.first).operator[](pos.second).present) return NULL;
return &bufor.operator[](pos.first).operator[](pos.second).val;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
template< class Iterator > int SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::getKeys( Iterator iter ) const
{
for(Klucz x=this->firstInd();x;x=this->nextInd(x))
for(Klucz y=(aType==AMatrFull || aType==AMatrNoDiag) ? this->firstInd() : x;
y;y=this->nextInd(y))
if (this->hasKey(x,y))
{
*iter=Assoc2DimTabAddr<aType>::key(std::pair<Klucz,Klucz>(x,y));
++iter;
}
return siz;
}
template< class Klucz, class Elem, AssocMatrixType aType, class Container, class IndexContainer >
void SimpleAssocMatrix<Klucz,Elem,aType,Container,IndexContainer>::defrag()
{
int n;
std::pair<Klucz,Klucz> LOCALARRAY(keys,n=this->size());
ValType LOCALARRAY(vals,n);
this->getKeys(keys);
for(int i=0;i<n;i++) vals[i]=this->operator()(keys[i].first,keys[i].second);
index.clear();
index.defrag();
siz=0;
{
Container tmp;
bufor.swap(tmp);
}
for(int i=0;i<n;i++) this->operator()(keys[i].first,keys[i].second)=vals[i];
}
| 35.009717 | 164 | 0.660568 | miloszc |
6787d8c779a3ba6a702a7af7db4f78c9d5b97891 | 8,821 | cxx | C++ | Hybrid/Testing/Cxx/TestKWEGPUArrayCalculator.cxx | wuzhuobin/vtkEdge | ed13af68a72cec79e3645f7e842d6074592abfa2 | [
"BSD-3-Clause"
] | 1 | 2021-01-09T16:06:14.000Z | 2021-01-09T16:06:14.000Z | Hybrid/Testing/Cxx/TestKWEGPUArrayCalculator.cxx | wuzhuobin/vtkEdge | ed13af68a72cec79e3645f7e842d6074592abfa2 | [
"BSD-3-Clause"
] | null | null | null | Hybrid/Testing/Cxx/TestKWEGPUArrayCalculator.cxx | wuzhuobin/vtkEdge | ed13af68a72cec79e3645f7e842d6074592abfa2 | [
"BSD-3-Clause"
] | null | null | null | //=============================================================================
// This file is part of VTKEdge. See vtkedge.org for more information.
//
// Copyright (c) 2010 Kitware, Inc.
//
// VTKEdge may be used under the terms of the BSD License
// Please see the file Copyright.txt in the root directory of
// VTKEdge for further information.
//
// Alternatively, you may see:
//
// http://www.vtkedge.org/vtkedge/project/license.html
//
//
// For custom extensions, consulting services, or training for
// this or any other Kitware supported open source project, please
// contact Kitware at sales@kitware.com.
//
//
//=============================================================================
// This test covers vtkKWEGPUArrayCalulator, compare to vtkArrayCalculator.
// The command line arguments are:
// -I => run in interactive mode; unless this is used, the program will
// not allow interaction and exit
// An image data is first created with a raw array.
// Some computation on the data array is performed
// IF THIS TEST TIMEOUT, IT IS PROBABLY ON VISTA WITH A NOT-FAST-ENOUGH
// GRAPHICS CARD:
// Depending on how fast/slow is the graphics card, the computation on the GPU
// can take more than 2 seconds. On Vista, after a 2 seconds timeout, the
// Windows Vista's Timeout Detection and Recovery (TDR) kills all the graphics
// contexts, resets the graphics chip and recovers the graphics driver, in
// order to keep the operating system responsive.
// ref: http://www.opengl.org/pipeline/article/vol003_7/
// This reset actually freezes the test. And it really times out this time...
// Example of pathological case: dash1vista32.kitware/Win32Vista-vs80
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include "vtkArrayCalculator.h"
#include "vtkKWEGPUArrayCalculator.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderWindow.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkOutlineFilter.h"
#include "vtkImageData.h"
#include "vtkPointData.h"
#include "vtkImageImport.h"
#include <assert.h>
#include "vtkTimerLog.h"
#include "vtkDoubleArray.h"
#include "vtkXYPlotWidget.h"
#include "vtkXYPlotActor.h"
// On a nVidia Quadro FX 3600M (~GeForce8),
// GL_MAX_TEXTURE_SIZE = 8192, GL_MAX_3D_TEXTURE_SIZE = 2048
// GL_MAX_VIEWPORT_DIMS = 8192, 8192
// The following size matches two complete full 2D textures, one 2D texture
// with one complete row and one 2D texture with just one pixel.
//const vtkIdType TestNumberOfPoints=2*(8192*8192)+8192+1;
const vtkIdType TestNumberOfPoints=(2*(8192*8192)+8192+1)/10; // 2*(8192*8192)+8192+1; //4096*4096;
const int TestNumberOfComponents=1; // 1 or 3
void ComputeAndDisplayMeanErrorAndStandardDeviation(vtkDoubleArray *c,
vtkDoubleArray *g)
{
assert("pre: c_exists" && c!=0);
assert("pre: g_exists" && g!=0);
assert("pre: same_size" && c->GetNumberOfTuples()==g->GetNumberOfTuples());
assert("pre: same_components" && c->GetNumberOfComponents()==g->GetNumberOfComponents());
assert("pre: not_empty" && c->GetNumberOfTuples()>0);
vtkIdType n=c->GetNumberOfTuples()*c->GetNumberOfComponents();
double *a=static_cast<double *>(c->GetVoidPointer(0));
double *b=static_cast<double *>(g->GetVoidPointer(0));
vtkIdType i;
// mean error
double meanError=0.0;
double maxError=0.0;
i=0;
while(i<n)
{
double delta=fabs(a[i]-b[i]);
if(delta>maxError)
{
maxError=delta;
}
meanError+=delta;
++i;
}
meanError/=static_cast<double>(n);
// std deviation
double stdDeviation=0.0;
i=0;
while(i<n)
{
double delta=fabs(a[i]-b[i])-meanError;
stdDeviation+=delta*delta;
++i;
}
stdDeviation=sqrt(stdDeviation/static_cast<double>(n));
cout<<" number of values="<<n<<endl;
cout<<" mean error="<<meanError<<endl;
cout<<" standard deviation="<<stdDeviation<<endl;
cout<<" maxError="<<maxError<<endl;
}
vtkImageImport *CreateSource(vtkIdType numberOfPoints,
int numberOfComponents)
{
assert("pre: valid_number_of_points" && numberOfPoints>0);
vtkImageImport *im=vtkImageImport::New();
float *ptr=new float[numberOfPoints*numberOfComponents];
vtkIdType i=0;
while(i<numberOfPoints*numberOfComponents)
{
ptr[i]=static_cast<float>(i); // 2.0
++i;
}
im->SetDataScalarTypeToFloat();
im->SetImportVoidPointer(ptr,0); // let the importer delete it.
im->SetNumberOfScalarComponents(numberOfComponents);
im->SetDataExtent(0,static_cast<int>(numberOfPoints-1),0,0,0,0);
im->SetWholeExtent(0,static_cast<int>(numberOfPoints-1),0,0,0,0);
im->SetScalarArrayName("values");
return im;
}
int TestKWEGPUArrayCalculator(int vtkNotUsed(argc),
char *vtkNotUsed(argv)[])
{
vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->SetSize(101,99);
renWin->SetAlphaBitPlanes(1);
renWin->SetReportGraphicErrors(1);
iren->SetRenderWindow(renWin);
renWin->Delete();
// Useful when looking at the test output in CDash:
cout << "IF THIS TEST TIMEOUT, IT IS PROBABLY ON VISTA WITH"
<< " A NOT-FAST-ENOUGH GRAPHICS CARD."<<endl;
cout<<"numPoints="<<TestNumberOfPoints<<endl;
vtkImageImport *im=CreateSource(TestNumberOfPoints,TestNumberOfComponents);
im->Update();
double range[2];
vtkImageData *image=vtkImageData::SafeDownCast(im->GetOutputDataObject(0));
image->GetPointData()->GetScalars()->GetRange(range);
cout<<"range[2]="<<range[0]<<" "<<range[1]<<endl;
vtkArrayCalculator *calc=vtkArrayCalculator::New();
calc->SetInputConnection(0,im->GetOutputPort(0)); // reader or source
calc->AddScalarArrayName("values");
calc->SetResultArrayName("Result");
calc->SetFunction("values+10.0");
// calc->SetFunction("sin(norm(values))+cos(norm(values))+10.0");
// calc->SetFunction("sin(values)*cos(values)+10.0");
// calc->SetFunction("exp(sqrt(sin(values)*cos(values)+10.0))");
vtkTimerLog *timer=vtkTimerLog::New();
timer->StartTimer();
calc->Update();
timer->StopTimer();
cout<<"Elapsed time with CPU version:"<<timer->GetElapsedTime()<<" seconds."<<endl;
image=vtkImageData::SafeDownCast(calc->GetOutputDataObject(0));
image->GetPointData()->GetScalars()->GetRange(range);
cout<<"range2[2]="<<range[0]<<" "<<range[1]<<endl;
vtkKWEGPUArrayCalculator *calc2=vtkKWEGPUArrayCalculator::New();
calc2->SetContext(renWin);
calc2->SetInputConnection(0,im->GetOutputPort(0)); // reader or source
calc2->AddScalarArrayName("values");
calc2->SetResultArrayName("Result");
calc2->SetFunction("values+10");
// calc2->SetFunction("sin(norm(values))+cos(norm(values))+10.0");
// calc2->SetFunction("sin(values)*cos(values)+10.0");
// calc2->SetFunction("exp(sqrt(sin(values)*cos(values)+10.0))");
// my nVidia Quadro FX 3600M has 512MB
// esimatation of 28MB already taken for screen+current context
// at 1600*1200: 512-28=484
// calc2->SetMaxGPUMemorySizeInBytes(512*1024*1024);
calc2->SetMaxGPUMemorySizeInBytes(128*1024*1024);
timer->StartTimer();
calc2->Update();
timer->StopTimer();
cout<<"Elapsed time with GPU version:"<<timer->GetElapsedTime()<<" seconds."<<endl;
vtkImageData *image2;
image2=vtkImageData::SafeDownCast(calc2->GetOutputDataObject(0));
image2->GetPointData()->GetScalars()->GetRange(range);
cout<<"range3[2]="<<range[0]<<" "<<range[1]<<endl;
ComputeAndDisplayMeanErrorAndStandardDeviation(
vtkDoubleArray::SafeDownCast(image->GetPointData()->GetScalars()),
vtkDoubleArray::SafeDownCast(image2->GetPointData()->GetScalars()));
timer->Delete();
calc2->Calibrate();
cout<<"Calibrated size threshold="<<calc2->GetCalibratedSizeThreshold()<<endl;
#if 0
vtkRenderer *renderer=vtkRenderer::New();
renderer->SetBackground(0.0,0.0,0.3);
renWin->AddRenderer(renderer);
renderer->Delete();
vtkXYPlotActor *actor=vtkXYPlotActor::New();
renderer->AddViewProp(actor);
actor->Delete();
actor->AddInput(image,"Result",0);
actor->SetPlotColor(0,1.0,0.0,0.0);
actor->AddInput(image2,"Result",0);
actor->SetPlotColor(1,0.0,1.0,0.0);
renWin->Render();
vtkXYPlotWidget *w=vtkXYPlotWidget::New();
w->SetInteractor(iren);
w->SetXYPlotActor(actor);
w->SetEnabled(1);
int retVal = vtkRegressionTestImage(renWin);
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
w->Delete();
#endif
calc2->Delete(); // need context
iren->Delete();
im->Delete();
calc->Delete();
return 0; // !retVal; 0: passed, 1: failed
}
| 33.796935 | 117 | 0.677247 | wuzhuobin |
6787f8c55a86572359a8d1c112817aa47613cec8 | 4,365 | hpp | C++ | src/items/SpatialItem.hpp | maltewi/envire-envire_core | 549b64ed30ba8afc4d91ae67b216a78b40cee016 | [
"BSD-2-Clause"
] | 9 | 2017-05-13T12:33:46.000Z | 2021-01-27T18:50:40.000Z | src/items/SpatialItem.hpp | maltewi/envire-envire_core | 549b64ed30ba8afc4d91ae67b216a78b40cee016 | [
"BSD-2-Clause"
] | 37 | 2016-02-11T17:34:41.000Z | 2021-10-04T10:14:18.000Z | src/items/SpatialItem.hpp | maltewi/envire-envire_core | 549b64ed30ba8afc4d91ae67b216a78b40cee016 | [
"BSD-2-Clause"
] | 11 | 2016-07-11T14:49:34.000Z | 2021-06-04T08:23:39.000Z | //
// Copyright (c) 2015, Deutsches Forschungszentrum für Künstliche Intelligenz GmbH.
// 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.
//
#ifndef __ENVIRE_CORE_SPATIAL_ITEM__
#define __ENVIRE_CORE_SPATIAL_ITEM__
#include <envire_core/items/Item.hpp>
#include <envire_core/items/BoundingVolume.hpp>
#include <boost/shared_ptr.hpp>
#include <Eigen/Geometry>
namespace envire { namespace core
{
/**@class SpatialItem
*
* SpatialItem class
*/
template<class _ItemData>
class SpatialItem : public Item<_ItemData>
{
public:
typedef boost::shared_ptr< SpatialItem<_ItemData> > Ptr;
protected:
boost::shared_ptr<BoundingVolume> boundary;
public:
SpatialItem() : Item<_ItemData>()
{
};
virtual ~SpatialItem() {}
void setBoundary(const boost::shared_ptr<BoundingVolume>& boundary) {this->boundary = boundary;}
boost::shared_ptr<BoundingVolume> getBoundary() {return boundary;}
const boost::shared_ptr<BoundingVolume>& getBoundary() const {return boundary;}
void extendBoundary(const Eigen::Vector3d& point)
{
checkBoundingVolume();
boundary->extend(point);
}
template<typename _Data>
void extendBoundary(const SpatialItem<_Data>& spatial_item)
{
checkBoundingVolume();
boundary->extend(spatial_item.getBoundary());
}
template<typename _Data>
bool intersects(const SpatialItem<_Data>& spatial_item) const
{
checkBoundingVolume();
return boundary->intersects(spatial_item.getBoundary());
}
template<typename _Data>
boost::shared_ptr<BoundingVolume> intersection(const SpatialItem<_Data>& spatial_item) const
{
checkBoundingVolume();
return boundary->intersection(spatial_item.getBoundary());
}
bool contains(const Eigen::Vector3d& point) const
{
checkBoundingVolume();
return boundary->contains(point);
}
template<typename _Data>
bool contains(const SpatialItem<_Data>& spatial_item) const
{
checkBoundingVolume();
return boundary->contains(spatial_item.getBoundary());
}
double exteriorDistance(const Eigen::Vector3d& point) const
{
checkBoundingVolume();
return boundary->exteriorDistance(point);
}
template<typename _Data>
double exteriorDistance(const SpatialItem<_Data>& spatial_item) const
{
checkBoundingVolume();
return boundary->exteriorDistance(spatial_item.getBoundary());
}
Eigen::Vector3d centerOfBoundary() const
{
checkBoundingVolume();
return boundary->center();
}
protected:
void checkBoundingVolume() const
{
if(boundary.get() == NULL)
throw std::runtime_error("BoundingVolume is not available!");
}
};
}}
#endif
| 31.630435 | 104 | 0.666208 | maltewi |
678cf958b2fa6c02ad42f430b91df752c6f7a2c8 | 1,061 | cpp | C++ | tau/TauEngine/src/dx/dxgi/DXGI11GraphicsDisplay.cpp | hyfloac/TauEngine | 1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c | [
"MIT"
] | 1 | 2020-04-22T04:07:01.000Z | 2020-04-22T04:07:01.000Z | tau/TauEngine/src/dx/dxgi/DXGI11GraphicsDisplay.cpp | hyfloac/TauEngine | 1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c | [
"MIT"
] | null | null | null | tau/TauEngine/src/dx/dxgi/DXGI11GraphicsDisplay.cpp | hyfloac/TauEngine | 1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c | [
"MIT"
] | null | null | null | #include "dx/dxgi/DXGI11GraphicsDisplay.hpp"
#ifdef _WIN32
NullableRef<DXGI11GraphicsDisplay> DXGI11GraphicsDisplay::build(IDXGIOutput* const dxgiOutput) noexcept
{
UINT numDisplayModes;
HRESULT res = dxgiOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numDisplayModes, nullptr);
if(FAILED(res))
{ return null; }
DynArray<DXGI_MODE_DESC> dxgiDisplayModes(numDisplayModes);
res = dxgiOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numDisplayModes, dxgiDisplayModes);
RefDynArray<IGraphicsDisplay::GraphicsDisplayMode> displayModes(numDisplayModes);
if(FAILED(res))
{ return null; }
for(uSys i = 0; i < numDisplayModes; ++i)
{
const auto& mode = dxgiDisplayModes[i];
displayModes[i] = { mode.Width, mode.Height, mode.RefreshRate.Numerator, mode.RefreshRate.Denominator };
}
return NullableRef<DXGI11GraphicsDisplay>(DefaultTauAllocator::Instance(), dxgiOutput, displayModes);
}
#endif
| 35.366667 | 134 | 0.737983 | hyfloac |
6790d2017a223d244fde06f4fd43c86abecc4182 | 1,419 | hpp | C++ | deeplab/code/include/caffe/layers/graphcut_layer.hpp | dmitrii-marin/adm-seg | e730b79bcd2b30cee66efac0ce961090c2cd4e62 | [
"MIT"
] | 10 | 2019-05-28T22:00:08.000Z | 2021-11-27T04:00:11.000Z | deeplab/code/include/caffe/layers/graphcut_layer.hpp | dmitrii-marin/adm-seg | e730b79bcd2b30cee66efac0ce961090c2cd4e62 | [
"MIT"
] | 2 | 2019-09-10T09:47:13.000Z | 2019-10-26T02:58:03.000Z | deeplab/code/include/caffe/layers/graphcut_layer.hpp | dmitrii-marin/adm-seg | e730b79bcd2b30cee66efac0ce961090c2cd4e62 | [
"MIT"
] | 2 | 2019-12-26T01:58:20.000Z | 2020-03-11T02:22:08.000Z | #ifndef CAFFE_GRAPHCUT_LAYER_HPP_
#define CAFFE_GRAPHCUT_LAYER_HPP_
#include <vector>
#include "caffe/blob.hpp"
#include "caffe/layer.hpp"
#include "caffe/proto/caffe.pb.h"
#include "caffe/filterrgbxy.hpp"
#include "gco-v3.0/GCoptimization.h"
#include <cstddef>
namespace caffe{
template <typename Dtype>
class GraphCutLayer : public Layer<Dtype>{
public:
virtual ~GraphCutLayer();
explicit GraphCutLayer(const LayerParameter & param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*> & bottom,
const vector<Blob<Dtype>*> & top);
virtual inline const char* type() const { return "GraphCut";}
virtual inline int ExactNumBottomBlobs() const {return 2;}
virtual inline int ExactNumTopBlobs() const {return 2;}
protected:
void runGraphCut(const Dtype * image, const Dtype * unary, Dtype * gc_segmentation, bool * ROI);
virtual void Forward_cpu(const vector<Blob<Dtype>*> & bottom,
const vector<Blob<Dtype>*> & top);
virtual void Backward_cpu(const vector<Blob<Dtype>*> & top,
const vector<bool> & propagate_down, const vector<Blob<Dtype>*> & bottom);
int N, C, H, W;
float sigma;
int max_iter;
float potts_weight;
Blob<Dtype> * unaries;
bool * ROI_allimages;
};
} // namespace caffe
#endif // CAFFE_GRAPHCUT_LAYER_HPP_
| 26.277778 | 98 | 0.711769 | dmitrii-marin |
09661d776586905743293e00b25c523c21f0b200 | 3,792 | cpp | C++ | RTIDPRR/Source/Graphics/Core/Buffer.cpp | brunosegiu/RTIDPRR | d7daef7611899db4e23ba6a2b5a91135c57e0871 | [
"MIT"
] | 3 | 2020-12-06T02:22:48.000Z | 2021-06-24T13:52:10.000Z | RTIDPRR/Source/Graphics/Core/Buffer.cpp | brunosegiu/RTIDPRR | d7daef7611899db4e23ba6a2b5a91135c57e0871 | [
"MIT"
] | null | null | null | RTIDPRR/Source/Graphics/Core/Buffer.cpp | brunosegiu/RTIDPRR | d7daef7611899db4e23ba6a2b5a91135c57e0871 | [
"MIT"
] | 1 | 2021-10-13T10:36:36.000Z | 2021-10-13T10:36:36.000Z | #include "Buffer.h"
#include "Command.h"
#include "Context.h"
#include "DeviceMemory.h"
using namespace RTIDPRR::Graphics;
Buffer::Buffer(const vk::DeviceSize& size, const vk::BufferUsageFlags& usage,
const vk::MemoryPropertyFlags& memoryProperties)
: mSize(size) {
const Device& device = Context::get().getDevice();
vk::BufferCreateInfo bufferCreateInfo =
vk::BufferCreateInfo().setSize(size).setUsage(usage).setSharingMode(
vk::SharingMode::eExclusive);
mBuffer = RTIDPRR_ASSERT_VK(
device.getLogicalDeviceHandle().createBuffer(bufferCreateInfo));
vk::MemoryRequirements memRequirements =
device.getLogicalDeviceHandle().getBufferMemoryRequirements(mBuffer);
vk::MemoryAllocateInfo memAllocInfo =
vk::MemoryAllocateInfo()
.setAllocationSize(memRequirements.size)
.setMemoryTypeIndex(DeviceMemory::findMemoryIndex(
memRequirements.memoryTypeBits, memoryProperties));
mMemory = RTIDPRR_ASSERT_VK(
device.getLogicalDeviceHandle().allocateMemory(memAllocInfo));
RTIDPRR_ASSERT_VK(
device.getLogicalDeviceHandle().bindBufferMemory(mBuffer, mMemory, 0));
mPMapped = nullptr;
}
Buffer::Buffer(Buffer&& other)
: mBuffer(std::move(other.mBuffer)),
mMemory(std::move(other.mMemory)),
mSize(std::move(other.mSize)) {
other.mBuffer = nullptr;
other.mMemory = nullptr;
}
const vk::DeviceSize Buffer::sInvalidSize = static_cast<vk::DeviceSize>(-1);
void Buffer::update(const void* value, const vk::DeviceSize& offset,
const vk::DeviceSize& size) {
const Device& device = Context::get().getDevice();
vk::DeviceSize effectiveSize = size == Buffer::sInvalidSize ? mSize : size;
void* data = RTIDPRR_ASSERT_VK(device.getLogicalDeviceHandle().mapMemory(
mMemory, offset, effectiveSize, vk::MemoryMapFlags{}));
memcpy(data, value, effectiveSize);
device.getLogicalDeviceHandle().unmapMemory(mMemory);
}
void* Buffer::map() {
if (!mPMapped) {
const Device& device = Context::get().getDevice();
mPMapped = RTIDPRR_ASSERT_VK(device.getLogicalDeviceHandle().mapMemory(
mMemory, 0, mSize, vk::MemoryMapFlags{}));
}
return mPMapped;
}
void Buffer::unmap() {
const Device& device = Context::get().getDevice();
device.getLogicalDeviceHandle().unmapMemory(mMemory);
mPMapped = nullptr;
}
void Buffer::copyInto(Buffer& other) {
const Device& device = Context::get().getDevice();
const Queue& graphicsQueue = device.getGraphicsQueue();
Command* command = Context::get().getCommandPool().allocateGraphicsCommand();
// Copy
vk::CommandBufferBeginInfo commandBeginInfo =
vk::CommandBufferBeginInfo().setFlags(
vk::CommandBufferUsageFlagBits::eOneTimeSubmit);
RTIDPRR_ASSERT_VK(command->begin(commandBeginInfo));
vk::BufferCopy copyRegion =
vk::BufferCopy().setSrcOffset(0).setDstOffset(0).setSize(mSize);
command->copyBuffer(mBuffer, other.mBuffer, copyRegion);
RTIDPRR_ASSERT_VK(command->end());
vk::SubmitInfo submitInfo = vk::SubmitInfo().setCommandBuffers(
*static_cast<vk::CommandBuffer*>(command));
vk::FenceCreateInfo fenceCreateInfo = vk::FenceCreateInfo();
vk::Fence waitFence = RTIDPRR_ASSERT_VK(
device.getLogicalDeviceHandle().createFence(fenceCreateInfo));
graphicsQueue.submit(submitInfo, waitFence);
vk::Result copyRes = device.getLogicalDeviceHandle().waitForFences(
waitFence, true, std::numeric_limits<uint64_t>::max());
RTIDPRR_ASSERT(copyRes == vk::Result::eSuccess);
device.getLogicalDeviceHandle().destroyFence(waitFence);
}
Buffer::~Buffer() {
const Device& device = Context::get().getDevice();
device.getLogicalDeviceHandle().destroyBuffer(mBuffer);
device.getLogicalDeviceHandle().freeMemory(mMemory);
}
| 36.461538 | 79 | 0.726002 | brunosegiu |
096a3969d7f748663f63ee71124263026f3bfee6 | 513 | cpp | C++ | codeshef/CIN011.cpp | sonuKumar03/data-structure-and-algorithm | d1fd3cad494cbcc91ce7ff37ec611752369b50b6 | [
"MIT"
] | null | null | null | codeshef/CIN011.cpp | sonuKumar03/data-structure-and-algorithm | d1fd3cad494cbcc91ce7ff37ec611752369b50b6 | [
"MIT"
] | null | null | null | codeshef/CIN011.cpp | sonuKumar03/data-structure-and-algorithm | d1fd3cad494cbcc91ce7ff37ec611752369b50b6 | [
"MIT"
] | null | null | null | #include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<fstream>
#include<climits>
#include<math.h>
using namespace std;
typedef long long ll ;
void solve(){
ll n ;
cin>>n;
ll *roses = new ll[n];
for(int i =0;i<n;i++){
cin>>roses[i];
}
ll happiness = -1;
for(int i =0;i<n;i++){
int t = roses[i] + happiness;
if(t>happiness){
happiness = t;
}
}
cout<<happiness<<endl;
}
int main() {
ll t;
cin>>t;
while(t--){
solve();
}
return 0;
}
| 14.25 | 33 | 0.569201 | sonuKumar03 |
096f6455e70034e7bad0407873ba591b77351925 | 18,237 | cpp | C++ | PersistentStore/SqliteStore.cpp | MFransen69/rdkservices | ce13efeb95779bc04c20e69be5fe86fd8565a6c6 | [
"BSD-2-Clause"
] | null | null | null | PersistentStore/SqliteStore.cpp | MFransen69/rdkservices | ce13efeb95779bc04c20e69be5fe86fd8565a6c6 | [
"BSD-2-Clause"
] | null | null | null | PersistentStore/SqliteStore.cpp | MFransen69/rdkservices | ce13efeb95779bc04c20e69be5fe86fd8565a6c6 | [
"BSD-2-Clause"
] | null | null | null | /*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2022 RDK Management
*
* 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 "SqliteStore.h"
#include "UtilsLogging.h"
#include <sqlite3.h>
#if defined(USE_PLABELS)
#include "pbnj_utils.hpp"
#include <glib.h>
#endif
#ifndef SQLITE_FILE_HEADER
#define SQLITE_FILE_HEADER "SQLite format 3"
#endif
#define SQLITE *(sqlite3**)&_data
#define SQLITE_IS_ERROR_DBWRITE(rc) (rc == SQLITE_READONLY || rc == SQLITE_CORRUPT)
namespace {
#if defined(USE_PLABELS)
bool GenerateKey(const char *key, std::vector<uint8_t> &pKey)
{
// NOTE: pbnj_utils stores the nonce under XDG_DATA_HOME/data.
// If the dir doesn't exist it will fail
auto path = g_build_filename(g_get_user_data_dir(), "data", nullptr);
if (!Core::File(string(path)).Exists())
g_mkdir_with_parents(path, 0755);
g_free(path);
return pbnj_utils::prepareBufferForOrigin(key, [&pKey](const std::vector<uint8_t> &buffer)
{
pKey = buffer;
});
}
#endif
}
namespace WPEFramework {
namespace Plugin {
SqliteStore::SqliteStore()
: _data(nullptr),
_path(),
_key(),
_maxSize(0),
_maxValue(0),
_clients(),
_clientLock(),
_lock()
{
}
uint32_t SqliteStore::Register(Exchange::IStore::INotification *notification)
{
Core::SafeSyncType<Core::CriticalSection> lock(_clientLock);
ASSERT(std::find(_clients.begin(), _clients.end(), notification) == _clients.end());
notification->AddRef();
_clients.push_back(notification);
return Core::ERROR_NONE;
}
uint32_t SqliteStore::Unregister(Exchange::IStore::INotification *notification)
{
Core::SafeSyncType<Core::CriticalSection> lock(_clientLock);
std::list<Exchange::IStore::INotification *>::iterator
index(std::find(_clients.begin(), _clients.end(), notification));
ASSERT(index != _clients.end());
if (index != _clients.end()) {
notification->Release();
_clients.erase(index);
}
return Core::ERROR_NONE;
}
uint32_t SqliteStore::Open(const string &path, const string &key, uint32_t maxSize, uint32_t maxValue)
{
CountingLockSync lock(_lock, 0);
if (IsOpen()) {
// Seems open!
return Core::ERROR_ILLEGAL_STATE;
}
Close();
_path = path;
_key = key;
_maxSize = maxSize;
_maxValue = maxValue;
#if defined(SQLITE_HAS_CODEC)
bool shouldEncrypt = !key.empty();
bool shouldReKey = shouldEncrypt && IsValid() && !IsEncrypted();
std::vector<uint8_t> pKey;
if (shouldEncrypt) {
#if defined(USE_PLABELS)
if (!GenerateKey(key.c_str(), pKey)) {
LOGERR("pbnj_utils fail");
Close();
return Core::ERROR_GENERAL;
}
#else
LOGWARN("Key is not secure");
pKey = std::vector<uint8_t>(key.begin(), key.end());
#endif
}
#endif
sqlite3* &db = SQLITE;
int rc = sqlite3_open(path.c_str(), &db);
if (rc != SQLITE_OK) {
LOGERR("%d : %s", rc, sqlite3_errstr(rc));
Close();
return Core::ERROR_OPENING_FAILED;
}
#if defined(SQLITE_HAS_CODEC)
if (shouldEncrypt) {
rc = Encrypt(pKey);
if (rc != SQLITE_OK) {
LOGERR("Failed to attach key - %s", sqlite3_errstr(rc));
Close();
return Core::ERROR_GENERAL;
}
}
#endif
rc = CreateTables();
#if defined(SQLITE_HAS_CODEC)
if (rc == SQLITE_NOTADB
&& shouldEncrypt
&& !shouldReKey // re-key should never fail
) {
LOGWARN("The key doesn't work");
Close();
if (!Core::File(path).Destroy() || IsValid()) {
LOGERR("Can't remove file");
return Core::ERROR_DESTRUCTION_FAILED;
}
sqlite3* &db = SQLITE;
rc = sqlite3_open(path.c_str(), &db);
if (rc != SQLITE_OK) {
LOGERR("Can't create file");
return Core::ERROR_OPENING_FAILED;
}
LOGWARN("SQLite database has been reset, trying re-key");
rc = Encrypt(pKey);
if (rc != SQLITE_OK) {
LOGERR("Failed to attach key - %s", sqlite3_errstr(rc));
Close();
return Core::ERROR_GENERAL;
}
rc = CreateTables();
}
#endif
return Core::ERROR_NONE;
}
uint32_t SqliteStore::SetValue(const string &ns, const string &key, const string &value)
{
if (ns.size() > _maxValue ||
key.size() > _maxValue ||
value.size() > _maxValue) {
return Core::ERROR_INVALID_INPUT_LENGTH;
}
uint32_t result = Core::ERROR_GENERAL;
int retry = 0;
int rc;
do {
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
if (!db)
break;
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "SELECT sum(s) FROM ("
" SELECT sum(length(key)+length(value)) s FROM item"
" UNION ALL"
" SELECT sum(length(name)) s FROM namespace"
");", -1, &stmt, nullptr);
rc = sqlite3_step(stmt);
if (rc == SQLITE_ROW) {
int64_t size = sqlite3_column_int64(stmt, 0);
if (size > _maxSize) {
LOGWARN("max size exceeded: %ld", size);
result = Core::ERROR_WRITE_ERROR;
} else {
result = Core::ERROR_NONE;
}
}
else
LOGERR("ERROR getting size: %s", sqlite3_errstr(rc));
sqlite3_finalize(stmt);
if (result == Core::ERROR_NONE) {
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "INSERT OR IGNORE INTO namespace (name) values (?);", -1, &stmt, nullptr);
sqlite3_bind_text(stmt, 1, ns.c_str(), -1, SQLITE_TRANSIENT);
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
LOGERR("ERROR inserting data: %s", sqlite3_errstr(rc));
result = Core::ERROR_GENERAL;
}
sqlite3_finalize(stmt);
}
if (result == Core::ERROR_NONE) {
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "INSERT INTO item (ns,key,value)"
" SELECT id, ?, ?"
" FROM namespace"
" WHERE name = ?"
";", -1, &stmt, nullptr);
sqlite3_bind_text(stmt, 1, key.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 2, value.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 3, ns.c_str(), -1, SQLITE_TRANSIENT);
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
LOGERR("ERROR inserting data: %s", sqlite3_errstr(rc));
result = Core::ERROR_GENERAL;
}
else {
ValueChanged(ns, key, value);
}
sqlite3_finalize(stmt);
}
}
while ((result != Core::ERROR_NONE) &&
SQLITE_IS_ERROR_DBWRITE(rc) &&
(++retry < 2) &&
(Open(_path, _key, _maxSize, _maxValue) == Core::ERROR_NONE));
if (result == Core::ERROR_NONE) {
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "SELECT sum(s) FROM ("
" SELECT sum(length(key)+length(value)) s FROM item"
" UNION ALL"
" SELECT sum(length(name)) s FROM namespace"
");", -1, &stmt, nullptr);
rc = sqlite3_step(stmt);
if (rc == SQLITE_ROW) {
int64_t size = sqlite3_column_int64(stmt, 0);
if (size > _maxSize) {
LOGWARN("max size exceeded: %ld", size);
StorageExceeded();
}
}
else
LOGERR("ERROR getting size: %s", sqlite3_errstr(rc));
sqlite3_finalize(stmt);
}
return result;
}
uint32_t SqliteStore::GetValue(const string &ns, const string &key, string &value)
{
uint32_t result = Core::ERROR_GENERAL;
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
if (db) {
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "SELECT value"
" FROM item"
" INNER JOIN namespace ON namespace.id = item.ns"
" where name = ? and key = ?"
";", -1, &stmt, nullptr);
sqlite3_bind_text(stmt, 1, ns.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 2, key.c_str(), -1, SQLITE_TRANSIENT);
int rc = sqlite3_step(stmt);
if (rc == SQLITE_ROW) {
value = (const char *) sqlite3_column_text(stmt, 0);
result = Core::ERROR_NONE;
}
else
LOGWARN("not found: %d", rc);
sqlite3_finalize(stmt);
}
return result;
}
uint32_t SqliteStore::DeleteKey(const string &ns, const string &key)
{
uint32_t result = Core::ERROR_GENERAL;
int retry = 0;
int rc;
do {
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
if (!db)
break;
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "DELETE FROM item"
" where ns in (select id from namespace where name = ?)"
" and key = ?"
";", -1, &stmt, NULL);
sqlite3_bind_text(stmt, 1, ns.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 2, key.c_str(), -1, SQLITE_TRANSIENT);
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE)
LOGERR("ERROR removing data: %s", sqlite3_errstr(rc));
else
result = Core::ERROR_NONE;
sqlite3_finalize(stmt);
}
while ((result != Core::ERROR_NONE) &&
SQLITE_IS_ERROR_DBWRITE(rc) &&
(++retry < 2) &&
(Open(_path, _key, _maxSize, _maxValue) == Core::ERROR_NONE));
return result;
}
uint32_t SqliteStore::DeleteNamespace(const string &ns)
{
uint32_t result = Core::ERROR_GENERAL;
int retry = 0;
int rc;
do {
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
if (!db)
break;
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "DELETE FROM namespace where name = ?;", -1, &stmt, NULL);
sqlite3_bind_text(stmt, 1, ns.c_str(), -1, SQLITE_TRANSIENT);
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE)
LOGERR("ERROR removing data: %s", sqlite3_errstr(rc));
else
result = Core::ERROR_NONE;
sqlite3_finalize(stmt);
}
while ((result != Core::ERROR_NONE) &&
SQLITE_IS_ERROR_DBWRITE(rc) &&
(++retry < 2) &&
(Open(_path, _key, _maxSize, _maxValue) == Core::ERROR_NONE));
return result;
}
uint32_t SqliteStore::GetKeys(const string &ns, std::vector<string> &keys)
{
uint32_t result = Core::ERROR_GENERAL;
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
keys.clear();
if (db) {
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "SELECT key"
" FROM item"
" where ns in (select id from namespace where name = ?)"
";", -1, &stmt, NULL);
sqlite3_bind_text(stmt, 1, ns.c_str(), -1, SQLITE_TRANSIENT);
while (sqlite3_step(stmt) == SQLITE_ROW)
keys.push_back((const char *) sqlite3_column_text(stmt, 0));
sqlite3_finalize(stmt);
result = Core::ERROR_NONE;
}
return result;
}
uint32_t SqliteStore::GetNamespaces(std::vector<string> &namespaces)
{
uint32_t result = Core::ERROR_GENERAL;
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
namespaces.clear();
if (db) {
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "SELECT name FROM namespace;", -1, &stmt, NULL);
while (sqlite3_step(stmt) == SQLITE_ROW)
namespaces.push_back((const char *) sqlite3_column_text(stmt, 0));
sqlite3_finalize(stmt);
result = Core::ERROR_NONE;
}
return result;
}
uint32_t SqliteStore::GetStorageSize(std::map<string, uint64_t> &namespaceSizes)
{
uint32_t result = Core::ERROR_GENERAL;
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
namespaceSizes.clear();
if (db) {
sqlite3_stmt *stmt;
sqlite3_prepare_v2(db, "SELECT name, sum(length(key)+length(value))"
" FROM item"
" INNER JOIN namespace ON namespace.id = item.ns"
" GROUP BY name"
";", -1, &stmt, NULL);
while (sqlite3_step(stmt) == SQLITE_ROW)
namespaceSizes[(const char *) sqlite3_column_text(stmt, 0)] = sqlite3_column_int(stmt, 1);
sqlite3_finalize(stmt);
result = Core::ERROR_NONE;
}
return result;
}
uint32_t SqliteStore::FlushCache()
{
uint32_t result = Core::ERROR_GENERAL;
CountingLockSync lock(_lock);
sqlite3* &db = SQLITE;
if (db) {
int rc = sqlite3_db_cacheflush(db);
if (rc != SQLITE_OK) {
LOGERR("Error while flushing sqlite database cache: %d", rc);
}
else {
result = Core::ERROR_NONE;
}
}
sync();
return result;
}
uint32_t SqliteStore::Term()
{
CountingLockSync lock(_lock, 0);
Close();
return Core::ERROR_NONE;
}
void SqliteStore::ValueChanged(const string &ns, const string &key, const string &value)
{
Core::SafeSyncType<Core::CriticalSection> lock(_clientLock);
std::list<Exchange::IStore::INotification *>::iterator
index(_clients.begin());
while (index != _clients.end()) {
(*index)->ValueChanged(ns, key, value);
index++;
}
}
void SqliteStore::StorageExceeded()
{
Core::SafeSyncType<Core::CriticalSection> lock(_clientLock);
std::list<Exchange::IStore::INotification *>::iterator
index(_clients.begin());
while (index != _clients.end()) {
(*index)->StorageExceeded();
index++;
}
}
int SqliteStore::Encrypt(const std::vector<uint8_t> &key)
{
int rc = SQLITE_OK;
#if defined(SQLITE_HAS_CODEC)
sqlite3* &db = SQLITE;
bool shouldReKey = !IsEncrypted();
if (!shouldReKey) {
rc = sqlite3_key_v2(db, nullptr, key.data(), key.size());
} else {
rc = sqlite3_rekey_v2(db, nullptr, key.data(), key.size());
if (rc == SQLITE_OK)
Vacuum();
}
if (shouldReKey && !IsEncrypted()) {
LOGERR("SQLite database file is clear after re-key");
}
#endif
return rc;
}
int SqliteStore::CreateTables()
{
sqlite3* &db = SQLITE;
char *errmsg;
int rc = sqlite3_exec(db, "CREATE TABLE if not exists namespace ("
"id INTEGER PRIMARY KEY,"
"name TEXT UNIQUE"
");", 0, 0, &errmsg);
if (rc != SQLITE_OK || errmsg) {
if (errmsg) {
LOGERR("%d : %s", rc, errmsg);
sqlite3_free(errmsg);
}
else
LOGERR("%d", rc);
return rc;
}
rc = sqlite3_exec(db, "CREATE TABLE if not exists item ("
"ns INTEGER,"
"key TEXT,"
"value TEXT,"
"FOREIGN KEY(ns) REFERENCES namespace(id) ON DELETE CASCADE ON UPDATE NO ACTION,"
"UNIQUE(ns,key) ON CONFLICT REPLACE"
");", 0, 0, &errmsg);
if (rc != SQLITE_OK || errmsg) {
if (errmsg) {
LOGERR("%d : %s", rc, errmsg);
sqlite3_free(errmsg);
}
else
LOGERR("%d", rc);
return rc;
}
rc = sqlite3_exec(db, "PRAGMA foreign_keys = ON;", 0, 0, &errmsg);
if (rc != SQLITE_OK || errmsg) {
if (errmsg) {
LOGERR("%d : %s", rc, errmsg);
sqlite3_free(errmsg);
}
else
LOGERR("%d", rc);
return rc;
}
return SQLITE_OK;
}
int SqliteStore::Vacuum()
{
sqlite3* &db = SQLITE;
char *errmsg;
int rc = sqlite3_exec(db, "VACUUM", 0, 0, &errmsg);
if (rc != SQLITE_OK || errmsg) {
if (errmsg) {
LOGERR("%s", errmsg);
sqlite3_free(errmsg);
}
else {
LOGERR("%d", rc);
}
return rc;
}
return SQLITE_OK;
}
int SqliteStore::Close()
{
sqlite3* &db = SQLITE;
if (db) {
int rc = sqlite3_db_cacheflush(db);
if (rc != SQLITE_OK) {
LOGERR("Error while flushing sqlite database cache: %d", rc);
}
sqlite3_close_v2(db);
}
db = nullptr;
return SQLITE_OK;
}
bool SqliteStore::IsOpen() const
{
sqlite3* &db = SQLITE;
return (db && IsValid());
}
bool SqliteStore::IsValid() const
{
return (Core::File(_path).Exists());
}
bool SqliteStore::IsEncrypted() const
{
bool result = false;
Core::File file(_path);
if (file.Exists() && file.Open(true)) {
const uint32_t bufLen = strlen(SQLITE_FILE_HEADER);
char buffer[bufLen];
result =
(file.Read(reinterpret_cast<uint8_t *>(buffer), bufLen) != bufLen) ||
(::memcmp(buffer, SQLITE_FILE_HEADER, bufLen) != 0);
}
return result;
}
} // namespace Plugin
} // namespace WPEFramework
| 25.119835 | 109 | 0.551132 | MFransen69 |
09705a8a905f583738cbc53fc70fa2e3c0205846 | 136 | cpp | C++ | test/llvm_test_code/linear_constant/call_10.cpp | janniclas/phasar | 324302ae96795e6f0a065c14d4f7756b1addc2a4 | [
"MIT"
] | 1 | 2022-02-15T07:56:29.000Z | 2022-02-15T07:56:29.000Z | test/llvm_test_code/linear_constant/call_10.cpp | fabianbs96/phasar | 5b8acd046d8676f72ce0eb85ca20fdb0724de444 | [
"MIT"
] | null | null | null | test/llvm_test_code/linear_constant/call_10.cpp | fabianbs96/phasar | 5b8acd046d8676f72ce0eb85ca20fdb0724de444 | [
"MIT"
] | null | null | null | void bar(int b) {}
void foo(int a) { // clang-format off
bar(a);
} // clang-format on
int main() {
int i;
foo(2);
return 0;
}
| 11.333333 | 37 | 0.551471 | janniclas |
0973942ad6b4dc43319155d9cb62b01f3c1675d2 | 4,551 | cpp | C++ | Source/BlackWolf.Lupus.Core/Cookie.cpp | chronos38/lupus-core | ea5196b1b8663999f0a6fcfb5ee3dc5c01d48f32 | [
"MIT"
] | null | null | null | Source/BlackWolf.Lupus.Core/Cookie.cpp | chronos38/lupus-core | ea5196b1b8663999f0a6fcfb5ee3dc5c01d48f32 | [
"MIT"
] | null | null | null | Source/BlackWolf.Lupus.Core/Cookie.cpp | chronos38/lupus-core | ea5196b1b8663999f0a6fcfb5ee3dc5c01d48f32 | [
"MIT"
] | 1 | 2020-10-03T05:05:03.000Z | 2020-10-03T05:05:03.000Z | /**
* Copyright (C) 2014 David Wolf <d.wolf@live.at>
*
* This file is part of Lupus.
* 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 "Cookie.h"
#include "Version.h"
#include <iomanip>
#include <sstream>
using namespace std;
using namespace std::chrono;
namespace Lupus {
namespace Net {
Cookie::Cookie(String name, String value) :
mName(name), mValue(value)
{
}
Cookie::Cookie(String name, String value, String path) :
mName(name), mValue(value), mPath(path)
{
}
Cookie::Cookie(String name, String value, String path, String domain) :
mName(name), mValue(value), mPath(path), mDomain(domain)
{
}
String Cookie::Name() const
{
return mName;
}
void Cookie::Name(String value)
{
mName = value;
}
String Cookie::Value() const
{
return mValue;
}
void Cookie::Value(String value)
{
mValue = value;
}
String Cookie::Path() const
{
return mPath;
}
void Cookie::Path(String value)
{
mPath = value;
}
String Cookie::Domain() const
{
return mDomain;
}
void Cookie::Domain(String value)
{
mDomain = value;
}
bool Cookie::Expired() const
{
return mExpired;
}
void Cookie::Expired(bool value)
{
mExpired = value;
}
bool Cookie::HttpOnly() const
{
return mHttpOnly;
}
void Cookie::HttpOnly(bool value)
{
mHttpOnly = value;
}
bool Cookie::Secure() const
{
return mSecure;
}
void Cookie::Secure(bool value)
{
mSecure = value;
}
TimePoint Cookie::Expires() const
{
return mExpires;
}
void Cookie::Expires(const TimePoint& value)
{
mExpires = value;
}
String Cookie::ToString() const
{
String expires;
if (mExpired) {
stringstream ss;
time_t time = Clock::to_time_t(Clock::now());
tm timetm;
memset(&timetm, 0, sizeof(timetm));
localtime_s(&timetm, &time);
ss << put_time(&timetm, "%a, %Y-%b-%d %T GMT");
expires += ss.str();
} else if (mExpires != TimePoint::min()) {
stringstream ss;
time_t time = Clock::to_time_t(mExpires);
tm timetm;
memset(&timetm, 0, sizeof(timetm));
localtime_s(&timetm, &time);
ss << put_time(&timetm, "%a, %Y-%b-%d %T GMT");
expires += ss.str();
}
String result = mName + "=" + mValue;
result += (expires.IsEmpty() ? "" : ("; expires=" + expires));
result += (mDomain.IsEmpty() ? "" : ("; domain=" + mDomain));
result += (mPath.IsEmpty() ? "" : ("; path=" + mPath));
result += (mSecure ? "; secure" : "");
result += (mHttpOnly ? "; httponly" : "");
return result;
}
}
}
| 28.267081 | 80 | 0.513733 | chronos38 |
0975c8e52cf2a7a3ea23ce38e36b92ffcf6843b4 | 517 | cc | C++ | gearbox/t/core/config_file.t.cc | coryb/gearbox | 88027f2f101c2d1fab16093928963052b9d3294d | [
"Artistic-1.0-Perl",
"BSD-3-Clause"
] | 3 | 2015-06-26T15:37:40.000Z | 2016-05-22T07:42:39.000Z | gearbox/t/core/config_file.t.cc | coryb/gearbox | 88027f2f101c2d1fab16093928963052b9d3294d | [
"Artistic-1.0-Perl",
"BSD-3-Clause"
] | null | null | null | gearbox/t/core/config_file.t.cc | coryb/gearbox | 88027f2f101c2d1fab16093928963052b9d3294d | [
"Artistic-1.0-Perl",
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2012, Yahoo! Inc. All rights reserved.
// Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
#include <tap/trivial.h>
#include <gearbox/core/ConfigFile.h>
using namespace Gearbox;
int main() {
chdir(TESTDIR);
TEST_START(5);
ConfigFile cfg("cfg/2.cfg");
Json a;
NOTHROW( a = cfg.get_json( "json" ) );
IS( a.empty(), true );
IS( a.length(), 0 );
IS( a.typeName(), "array" );
IS( a.serialize(), "[]" );
TEST_END;
}
| 21.541667 | 94 | 0.617021 | coryb |
097678ae1ef604a6f07542e23a230b58a61679e4 | 3,944 | cpp | C++ | Drivers/GranularJet/dec13_A254_Hi0075_RC06_MU05.cpp | gustavo-castillo-bautista/Mercury | eeb402ccec8e487652229d4595c46ec84f6aefbb | [
"BSD-3-Clause"
] | null | null | null | Drivers/GranularJet/dec13_A254_Hi0075_RC06_MU05.cpp | gustavo-castillo-bautista/Mercury | eeb402ccec8e487652229d4595c46ec84f6aefbb | [
"BSD-3-Clause"
] | null | null | null | Drivers/GranularJet/dec13_A254_Hi0075_RC06_MU05.cpp | gustavo-castillo-bautista/Mercury | eeb402ccec8e487652229d4595c46ec84f6aefbb | [
"BSD-3-Clause"
] | null | null | null | //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
//For the list of developers, see <http://www.MercuryDPM.org/Team>.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name MercuryDPM nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM 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 <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <Species/LinearViscoelasticSlidingFrictionSpecies.h>
#include "Funnel.h"
int main(int argc UNUSED, char *argv[] UNUSED)
{
Funnel problem;
// Problem parameters
problem.setName("dec13_A254_Hi0075_RC06_MU05");
auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSlidingFrictionSpecies());
species->setSlidingFrictionCoefficient(0.5);
species->setDensity(1442.0);
//problem.set_HGRID_max_levels(2);
//problem.set_HGRID_num_buckets(1e6);
// Particle properties
problem.setFixedParticleRadius(300e-6);
problem.setInflowParticleRadius(300e-6);
species->setCollisionTimeAndRestitutionCoefficient(4e-4, 0.6, species->getMassFromRadius(problem.getFixedParticleRadius()));
//problem.setStiffness(1e5*4/3*pi*problem.getInflowParticleRadius()*9.81*problem.getDensity());
//problem.set_disp(50*sqrt(9.81/(2*problem.getInflowParticleRadius());
std::cout << "Setting k to " << species->getStiffness() << " and disp to " << species->getDissipation() << std::endl;
species->setSlidingStiffness(species->getStiffness()*2.0/7.0);
species->setSlidingDissipation(species->getDissipation()*2.0/7.0);
double mass = species->getMassFromRadius(0.5 * (problem.getMinInflowParticleRadius() + problem.getMaxInflowParticleRadius()));
problem.setTimeStep(0.02 * species->getCollisionTime(mass));
problem.setTimeMax(3);
problem.setSaveCount(100);
problem.setChuteLength(0.6);
problem.setChuteWidth(0.25);
problem.setChuteAngle(25.4);
problem.setRoughBottomType(MONOLAYER_DISORDERED);
double funx = problem.getXMin()+0.5*(problem.getXMax()-problem.getXMin());
problem.set_funa(60.0);
problem.set_funD(0.015);
problem.set_funHf(0.075+(problem.getXMax()-funx)*sin(problem.getChuteAngle()));
problem.set_funnz(50.0);
problem.set_funO(-funx, 0.5*(problem.getYMax()-problem.getYMin()));
problem.set_funfr(0.3);
problem.setInflowVelocity(0);
problem.setInflowVelocityVariance(0.01);
problem.setMaxFailed(1);
//solve
//cout << "Maximum allowed speed of particles: " << problem.getMaximumVelocity() << endl; // speed allowed before particles move through each other!
std::cout << "dt=" << problem.getTimeStep() << std::endl;
problem.solve();
problem.writeRestartFile();
}
| 40.659794 | 149 | 0.761663 | gustavo-castillo-bautista |
097d29910f58bf15984a871e201ddf64e159f4b3 | 3,105 | cpp | C++ | tests/mapping/Map2DTest.cpp | jonahbardos/PY2020 | af4f61b86ae5013e58faf4842bf20863b3de3957 | [
"Apache-2.0"
] | 11 | 2019-10-03T01:17:16.000Z | 2020-10-25T02:38:32.000Z | tests/mapping/Map2DTest.cpp | jonahbardos/PY2020 | af4f61b86ae5013e58faf4842bf20863b3de3957 | [
"Apache-2.0"
] | 53 | 2019-10-03T02:11:04.000Z | 2021-06-05T03:11:55.000Z | tests/mapping/Map2DTest.cpp | jonahbardos/PY2020 | af4f61b86ae5013e58faf4842bf20863b3de3957 | [
"Apache-2.0"
] | 3 | 2019-09-20T04:09:29.000Z | 2020-08-18T22:25:20.000Z | #define CATCH_CONFIG_MAIN
#include "mapping/Map2D.h"
#include <iostream>
#include <cmath>
#include <chrono>
#include <ctime>
#include <thread>
constexpr int test_iterations = 100;
constexpr int vertex_count = 1000;
constexpr int sparsity_factor = 2;
#include <catch2/catch.hpp>
namespace Mapping
{
// creates a map with given number of vertices
// when connecting neighbors, the probability that any node will be connected to any other node
// is 1 / sparse_factor
// thus if sparse_factor is 1, each node is connected to each other node
std::shared_ptr<Map2D> CreateRandMap(int vertices, int sparse_factor)
{
Map2D map;
for (int i = 0; i < vertices; i++)
{
Point2D p;
p.id = i;
p.x = (float)(rand() % vertices);
p.y = (float)(rand() % vertices);
std::shared_ptr<Point2D> p_ptr = std::make_shared<Point2D>(p);
for (int j = 0; j < map.vertices.size(); j++)
{
if (rand() % sparse_factor == 0)
{
Connect(p_ptr, map.vertices.at(j));
}
}
map.vertices.push_back(p_ptr);
}
return std::make_shared<Map2D>(map);
}
// randomly picks a start and end vertex, making sure they are different nodes
// returns average time of shortest path computation, in seconds
double TimeShortestPath(std::shared_ptr<Map2D> map, int num_iterations)
{
double avg = 0;
for (int i = 0; i < num_iterations; i++)
{
int start_ind = rand() % map->vertices.size();
int target_ind = rand() % map->vertices.size();
while (target_ind == start_ind)
{
target_ind = rand() % map->vertices.size();
}
auto start = std::chrono::system_clock::now();
ComputePath(map, map->vertices[start_ind], map->vertices[target_ind]);
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
avg += elapsed_seconds.count() / num_iterations;
}
return avg;
}
bool verifyCorrectPath()
{
Map2D map;
float x_pts[10] = {0, -1, 2, -3, 4, -5, 6, -7, 8, -9};
float y_pts[10] = {0, -1, 2, -3, 4, -5, 6, -7, 8, -9};
for (int i = 0; i < 10; i++)
{
Point2D p;
p.id = i;
p.x = x_pts[i];
p.y = y_pts[i];
map.vertices.push_back(std::make_shared<Point2D>(p));
if (i > 0)
{
Connect(map.vertices[i], map.vertices[i - 1]);
}
}
Connect(map.vertices[9], map.vertices[2]);
std::vector<std::shared_ptr<Point2D>> actual = ComputePath(std::make_shared<Map2D>(map),
map.vertices[9], map.vertices[0]);
int expected[3] = {0, 1, 2};
for (int i = 0; i < actual.size(); i++)
{
if (expected[i] != actual[i]->id)
{
return false;
}
}
return true;
}
} // namespace Mapping
TEST_CASE("computes correct path")
{
REQUIRE(Mapping::verifyCorrectPath());
}
| 29.571429 | 98 | 0.554267 | jonahbardos |
09807f83c5fd4e83dddd8cef01b63649a688bc23 | 1,520 | cpp | C++ | attacker/SSL/sslPublic.cpp | satadriver/attacker | 24e4434d8a836e040e48df195f2ca8919ab52609 | [
"Apache-2.0"
] | null | null | null | attacker/SSL/sslPublic.cpp | satadriver/attacker | 24e4434d8a836e040e48df195f2ca8919ab52609 | [
"Apache-2.0"
] | null | null | null | attacker/SSL/sslPublic.cpp | satadriver/attacker | 24e4434d8a836e040e48df195f2ca8919ab52609 | [
"Apache-2.0"
] | 1 | 2022-03-20T03:21:00.000Z | 2022-03-20T03:21:00.000Z |
#include "sslPublic.h"
#include "../attacker.h"
#include "../FileOper.h"
#include <vector>
#include <iostream>
#include <string>
using namespace std;
WORKERCONTROL gWorkControl;
vector <string> gHostAttackList;
char G_USERNAME[64];
SSLPublic::SSLPublic(vector<string>list) {
if (mInstance)
{
return;
}
mInstance = this;
gHostAttackList = list;
}
SSLPublic::~SSLPublic() {
}
int SSLPublic::isTargetHost(string host) {
unsigned int targetlen = gHostAttackList.size();
for (unsigned int i = 0; i < targetlen; i++) {
if (strstr(host.c_str(), gHostAttackList[i].c_str())) {
return TRUE;
}
}
return FALSE;
}
int SSLPublic::prepareCertChain(string certname) {
int ret = 0;
string curpath = gLocalPath + CA_CERT_PATH +"\\";
string crtname = curpath + certname + ".crt";
string midcrtname = curpath+ certname + ".mid.crt";
string crtchainname = curpath+ certname + ".chain.crt";
string cafn = curpath + DIGICERTCA;
if (FileOper::isFileExist(crtchainname))
{
DeleteFileA(crtchainname.c_str());
}
string cmd = "cmd /c type " + crtname + " >> " + crtchainname;
ret = system(cmd.c_str());
cmd = "cmd /c echo.>> " + crtchainname;
ret = system(cmd.c_str());
cmd = "cmd /c type " + midcrtname + " >> " + crtchainname;
ret = system(cmd.c_str());
cmd = "cmd /c echo.>> " + crtchainname;
ret = system(cmd.c_str());
cmd = "cmd /c type " + cafn + " >> " + crtchainname;
ret = system(cmd.c_str());
cmd = "cmd /c echo.>> " + crtchainname;
ret = system(cmd.c_str());
return 0;
}
| 19.74026 | 63 | 0.651316 | satadriver |
09817f55dee6853da4cc8fcc42feaf934082197f | 119 | cpp | C++ | src/IModel.cpp | soraphis/Boids-MPI | 87ce64b6bfa5f8f9dba94a641046979621e7a71c | [
"MIT"
] | null | null | null | src/IModel.cpp | soraphis/Boids-MPI | 87ce64b6bfa5f8f9dba94a641046979621e7a71c | [
"MIT"
] | 1 | 2017-05-30T14:59:29.000Z | 2017-05-30T14:59:29.000Z | src/IModel.cpp | soraphis/Boids-MPI | 87ce64b6bfa5f8f9dba94a641046979621e7a71c | [
"MIT"
] | null | null | null | /*
* IModel.cpp
*
* Created on: 29.06.2014
* Author: oliver
*/
#include "IModel.h"
IModel::~IModel(){
}
| 8.5 | 26 | 0.537815 | soraphis |
0982fc2f50f944be4581a3e21cd40ce1d769102d | 1,273 | cpp | C++ | src/trade_book/TradeBook.cpp | karelhala-cz/BitstampTax | 361b94a8acf233082badc21da256b4089aad2188 | [
"MIT"
] | null | null | null | src/trade_book/TradeBook.cpp | karelhala-cz/BitstampTax | 361b94a8acf233082badc21da256b4089aad2188 | [
"MIT"
] | null | null | null | src/trade_book/TradeBook.cpp | karelhala-cz/BitstampTax | 361b94a8acf233082badc21da256b4089aad2188 | [
"MIT"
] | null | null | null | //*********************************************************************************************************************
// Author: Karel Hala, hala.karel@gmail.com
// Copyright: (c) 2021-2022 Karel Hala
// License: MIT
//*********************************************************************************************************************
#include "TradeBook.h"
#include "TradeItem.h"
#include "TradeItemMarket.h"
C_TradeBook::C_TradeBook()
{
}
void C_TradeBook::Reserve(size_t const count)
{
m_TradeItems.reserve(count);
}
void C_TradeBook::AddItem(std::unique_ptr<C_TradeItem> && item)
{
m_TradeItems.emplace_back(std::move(item));
}
void C_TradeBook::SetTradeItems(T_TradeItems && items)
{
m_TradeItems = std::move(items);
}
T_CurrencyType C_TradeBook::AssessUserCurrency() const
{
T_CurrencyType userCurrency;
for (T_TradeItemUniquePtr const & item : m_TradeItems)
{
C_TradeItemMarket const * const itemMarket (dynamic_cast<C_TradeItemMarket const *>(item.get()));
if (itemMarket != nullptr)
{
userCurrency = itemMarket->GetValue().GetType();
break;
}
}
return userCurrency;
}
void C_TradeBook::PrintData(std::ostringstream & str)
{
for (T_TradeItemUniquePtr & item : m_TradeItems)
{
item->PrintData(str);
str << std::endl;
}
} | 23.574074 | 119 | 0.586803 | karelhala-cz |
09839fb928a67e869b7b8cf5c6a1129430fd171f | 796 | cpp | C++ | src/gamelib/utils/LifetimeTracker.cpp | mall0c/GameLib | df4116b53c39be7b178dd87f7eb0fe32a94d00d3 | [
"MIT"
] | 1 | 2020-02-17T09:53:36.000Z | 2020-02-17T09:53:36.000Z | src/gamelib/utils/LifetimeTracker.cpp | mall0c/GameLib | df4116b53c39be7b178dd87f7eb0fe32a94d00d3 | [
"MIT"
] | null | null | null | src/gamelib/utils/LifetimeTracker.cpp | mall0c/GameLib | df4116b53c39be7b178dd87f7eb0fe32a94d00d3 | [
"MIT"
] | null | null | null | #include "gamelib/utils/LifetimeTracker.hpp"
namespace gamelib
{
SlotMapShort<void*> LifetimeTrackerManager::_data;
LifetimeTrackerManager::LifetimeTrackerManager()
{ }
auto LifetimeTrackerManager::add(void* ptr) -> LifetimeHandle
{
auto h = _data.acquire();
_data[h] = ptr;
return h;
}
auto LifetimeTrackerManager::del(LifetimeHandle handle) -> void
{
_data.destroy(handle);
}
auto LifetimeTrackerManager::get(LifetimeHandle handle) -> void*
{
if (_data.isValid(handle))
return _data[handle];
return nullptr;
}
auto LifetimeTrackerManager::update(LifetimeHandle handle, void* newptr) -> void
{
if (_data.isValid(handle))
_data[handle] = newptr;
}
}
| 22.742857 | 84 | 0.628141 | mall0c |
0988cb9ad208ef6d58ccf6001e8cd49c540a41e6 | 2,410 | cpp | C++ | VoDTCPServer/VoDTCPServerView.cpp | ckaraca/VoD | 415590649053eb560ef094768bec210c4c0fe19f | [
"MIT"
] | 3 | 2021-11-26T21:26:32.000Z | 2022-01-09T20:54:49.000Z | VoDTCPServer/VoDTCPServerView.cpp | ckaraca/VoD | 415590649053eb560ef094768bec210c4c0fe19f | [
"MIT"
] | null | null | null | VoDTCPServer/VoDTCPServerView.cpp | ckaraca/VoD | 415590649053eb560ef094768bec210c4c0fe19f | [
"MIT"
] | null | null | null | // VoDTCPServerView.cpp : implementation of the CVoDTCPServerView class
//
#include "stdafx.h"
#include "VoDTCPServer.h"
#include "VoDTCPServerDoc.h"
#include "VoDTCPServerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define WSA_VERSION MAKEWORD(2,0)
extern TCHAR ServerPathName[];
extern TCHAR ServerPath[];
// CVoDTCPServerView
IMPLEMENT_DYNCREATE(CVoDTCPServerView, CListView)
BEGIN_MESSAGE_MAP(CVoDTCPServerView, CListView)
ON_MESSAGE(WM_SETLIST,SetListEx)
ON_MESSAGE(WM_SETLISTS,SetListSuccessEx)
END_MESSAGE_MAP()
// CVoDTCPServerView construction/destruction
extern HWND hWnd;
CVoDTCPServerView::CVoDTCPServerView()
{
index = 0;
}
CVoDTCPServerView::~CVoDTCPServerView()
{
}
BOOL CVoDTCPServerView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~LVS_TYPEMASK;
cs.style |= LVS_REPORT;
return CListView::PreCreateWindow(cs);
}
void CVoDTCPServerView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
RECT rc;
GetClientRect(&rc);
GetListCtrl ().InsertColumn (0, _T ("Status ID"), LVCFMT_LEFT, 100);
GetListCtrl ().InsertColumn (1, _T ("Event"), LVCFMT_LEFT, 300);
GetListCtrl ().InsertColumn (2, _T ("Success"), LVCFMT_LEFT,rc.right-400);
// begin adding here
SetList("002","Starting Windows sockets");
SetListSuccess("OK!");
SetList("003","Starting TCP Listener thread");
//Listen = new CTCPListener;
hWnd = this->m_hWnd;
AfxBeginThread(TCPListener,(LPVOID)0);
SetListSuccess("OK!");
}
void CVoDTCPServerView::SetList(TCHAR *Code,TCHAR *Event)
{
GetListCtrl ().InsertItem (index,Code);
GetListCtrl ().SetItemText (index, 1, Event);
}
void CVoDTCPServerView::SetListSuccess(TCHAR *Success)
{
GetListCtrl ().SetItemText (index++, 2, Success);
}
LONG CVoDTCPServerView::SetListEx(WPARAM wParam,LPARAM lParam)
{
SetList((TCHAR *)wParam,(TCHAR *)lParam);
return 0;
}
LONG CVoDTCPServerView::SetListSuccessEx(WPARAM wParam,LPARAM /*lParam*/)
{
SetListSuccess((TCHAR *)wParam);
return 0;
}
// CVoDTCPServerView diagnostics
#ifdef _DEBUG
void CVoDTCPServerView::AssertValid() const
{
CListView::AssertValid();
}
void CVoDTCPServerView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
CVoDTCPServerDoc* CVoDTCPServerView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVoDTCPServerDoc)));
return (CVoDTCPServerDoc*)m_pDocument;
}
#endif //_DEBUG
// CVoDTCPServerView message handlers
| 21.327434 | 87 | 0.755602 | ckaraca |
09899356e00cbb258e99c61dd65dd32b225df382 | 2,492 | cpp | C++ | plugins/builtin.cpp | iotbzh/DEPRECATED_afb-signal-composer | ee50d58c38e4a8f2dafd40b6cdf3aa6c7612e866 | [
"Apache-2.0"
] | null | null | null | plugins/builtin.cpp | iotbzh/DEPRECATED_afb-signal-composer | ee50d58c38e4a8f2dafd40b6cdf3aa6c7612e866 | [
"Apache-2.0"
] | null | null | null | plugins/builtin.cpp | iotbzh/DEPRECATED_afb-signal-composer | ee50d58c38e4a8f2dafd40b6cdf3aa6c7612e866 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2016 "IoT.bzh"
* Author Romain Forlot <romain.forlot@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define AFB_BINDING_VERSION 2
#include <afb/afb-binding.h>
#include <systemd/sd-event.h>
#include <json-c/json_object.h>
#include <stdbool.h>
#include <string.h>
#include "signal-composer.hpp"
#include "ctl-config.h"
#include "wrap-json.h"
extern "C"
{
CTLP_LUA_REGISTER("builtin");
static struct signalCBT* pluginCtx = NULL;
// Call at initialisation time
/*CTLP_ONLOAD(plugin, handle) {
pluginCtx = (struct signalCBT*)calloc (1, sizeof(struct signalCBT));
pluginCtx = (struct signalCBT*)handle;
AFB_NOTICE ("Signal Composer builtin plugin: label='%s' info='%s'",
plugin->uid,
plugin->info);
return (void*)pluginCtx;
}*/
CTLP_CAPI (defaultOnReceived, source, argsJ, eventJ)
{
struct signalCBT* ctx = (struct signalCBT*)source->context;
AFB_NOTICE("source: %s argj: %s, eventJ %s", source->uid,
json_object_to_json_string(argsJ),
json_object_to_json_string(eventJ));
void* sig = ctx->aSignal;
json_object* valueJ = nullptr;
json_object* timestampJ = nullptr;
double value = 0;
uint64_t timestamp = 0;
if(json_object_object_get_ex(eventJ, "value", &valueJ))
{value = json_object_get_double(valueJ);}
if(json_object_object_get_ex(eventJ, "timestamp", ×tampJ))
{timestamp = json_object_get_int64(timestampJ);}
struct signalValue v = value;
ctx->setSignalValue(sig, timestamp, v);
return 0;
}
CTLP_LUA2C (setSignalValueWrap, source, argsJ, responseJ)
{
const char* name = nullptr;
double resultNum;
uint64_t timestamp;
if(! wrap_json_unpack(argsJ, "{ss, sF, sI? !}",
"name", &name,
"value", &resultNum,
"timestamp", ×tamp))
{
AFB_ERROR("Fail to set value for uid: %s, argsJ: %s", source->uid, json_object_to_json_string(argsJ));
return -1;
}
struct signalValue result = resultNum;
pluginCtx->searchNsetSignalValue(name, timestamp*MICRO, result);
return 0;
}
// extern "C" closure
}
| 27.688889 | 104 | 0.725522 | iotbzh |
0998a6a1c67e59ff7263fff32514f9b73af3fa9b | 1,583 | cpp | C++ | modules/cudaimgproc/samples/connected_components.cpp | pccvlab/opencv_contrib | f6a39c5d01a7b2d2bb223a2a67beb9736fce7d93 | [
"Apache-2.0"
] | null | null | null | modules/cudaimgproc/samples/connected_components.cpp | pccvlab/opencv_contrib | f6a39c5d01a7b2d2bb223a2a67beb9736fce7d93 | [
"Apache-2.0"
] | null | null | null | modules/cudaimgproc/samples/connected_components.cpp | pccvlab/opencv_contrib | f6a39c5d01a7b2d2bb223a2a67beb9736fce7d93 | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <opencv2/core/utility.hpp>
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/cudaimgproc.hpp"
using namespace cv;
using namespace std;
using namespace cv::cuda;
void colorLabels(const Mat1i& labels, Mat3b& colors) {
colors.create(labels.size());
for (int r = 0; r < labels.rows; ++r) {
int const* labels_row = labels.ptr<int>(r);
Vec3b* colors_row = colors.ptr<Vec3b>(r);
for (int c = 0; c < labels.cols; ++c) {
colors_row[c] = Vec3b(labels_row[c] * 131 % 255, labels_row[c] * 241 % 255, labels_row[c] * 251 % 255);
}
}
}
int main(int argc, const char** argv)
{
CommandLineParser parser(argc, argv, "{@image|stuff.jpg|image for converting to a grayscale}");
parser.about("This program finds connected components in a binary image and assign each of them a different color.\n"
"The connected components labeling is performed in GPU.\n");
parser.printMessage();
String inputImage = parser.get<string>(0);
Mat1b img = imread(samples::findFile(inputImage), IMREAD_GRAYSCALE);
Mat1i labels;
if (img.empty())
{
cout << "Could not read input image file: " << inputImage << endl;
return EXIT_FAILURE;
}
GpuMat d_img, d_labels;
d_img.upload(img);
cuda::connectedComponents(d_img, d_labels, 8, CV_32S);
d_labels.download(labels);
Mat3b colors;
colorLabels(labels, colors);
imshow("Labels", colors);
waitKey(0);
return EXIT_SUCCESS;
}
| 26.830508 | 121 | 0.655085 | pccvlab |
099a548581f12d5b5a3a2a36c45dd14ccf4a8336 | 176 | cpp | C++ | src/world/health.cpp | louiz/batajelo | 4d8edce8da9d3b17dbad68eb4881d7f6fee2f76e | [
"BSL-1.0",
"BSD-2-Clause",
"Zlib",
"MIT"
] | 7 | 2015-01-28T09:17:08.000Z | 2020-04-21T13:51:16.000Z | src/world/health.cpp | louiz/batajelo | 4d8edce8da9d3b17dbad68eb4881d7f6fee2f76e | [
"BSL-1.0",
"BSD-2-Clause",
"Zlib",
"MIT"
] | null | null | null | src/world/health.cpp | louiz/batajelo | 4d8edce8da9d3b17dbad68eb4881d7f6fee2f76e | [
"BSL-1.0",
"BSD-2-Clause",
"Zlib",
"MIT"
] | 1 | 2020-07-11T09:20:25.000Z | 2020-07-11T09:20:25.000Z | #include <world/health.hpp>
const ComponentType Health::component_type;
Health::Health(const Quantity::type max):
Quantity(max)
{
}
void Health::tick(Entity*, World*)
{
}
| 13.538462 | 43 | 0.721591 | louiz |
099a85de008229877140cca914f025843039871f | 372 | cpp | C++ | 05_bits/digits_demo.cpp | anton0xf/stepik_cpp | fe87fff8523bc62c92b13dc8c0908b6d984aec43 | [
"MIT"
] | null | null | null | 05_bits/digits_demo.cpp | anton0xf/stepik_cpp | fe87fff8523bc62c92b13dc8c0908b6d984aec43 | [
"MIT"
] | null | null | null | 05_bits/digits_demo.cpp | anton0xf/stepik_cpp | fe87fff8523bc62c92b13dc8c0908b6d984aec43 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include "digits.hpp"
int main() {
init_digits();
printf("values: \n");
for (int i=0; i < VALUES_COUNT; i++) {
if (values[i] == UNUSED) continue;
printf("%c -> %lld\n", (char)i, values[i]);
}
printf("digits: ");
for (int i=0; i < DIGITS_COUNT; i++) {
printf("%c, ", digits[i]);
}
printf("\n");
}
| 21.882353 | 51 | 0.491935 | anton0xf |
099fbb7c121449c95fb9f56489000d921c612477 | 814 | hpp | C++ | Kuplung/kuplung/utilities/consumption/WindowsCPUUsage.hpp | supudo/Kuplung | f0e11934fde0675fa531e6dc263bedcc20a5ea1a | [
"Unlicense"
] | 14 | 2017-02-17T17:12:40.000Z | 2021-12-22T01:55:06.000Z | Kuplung/kuplung/utilities/consumption/WindowsCPUUsage.hpp | supudo/Kuplung | f0e11934fde0675fa531e6dc263bedcc20a5ea1a | [
"Unlicense"
] | null | null | null | Kuplung/kuplung/utilities/consumption/WindowsCPUUsage.hpp | supudo/Kuplung | f0e11934fde0675fa531e6dc263bedcc20a5ea1a | [
"Unlicense"
] | 1 | 2019-10-15T08:10:10.000Z | 2019-10-15T08:10:10.000Z | //
// WindowsCPUUsage.hpp
// Kuplung
//
// Created by Sergey Petrov on 12/16/15.
// Copyright © 2015 supudo.net. All rights reserved.
//
#ifndef WindowsCPUUsage_hpp
#define WindowsCPUUsage_hpp
namespace KuplungApp { namespace Utilities { namespace Consumption {
#include <windows.h>
class WindowsCPUUsage {
public:
WindowsCPUUsage();
short GetUsage();
private:
ULONGLONG SubtractTimes(const FILETIME& ftA, const FILETIME& ftB);
bool EnoughTimePassed();
inline bool IsFirstRun() const { return (m_dwLastRun == 0); }
//system total times
FILETIME m_ftPrevSysKernel;
FILETIME m_ftPrevSysUser;
//process times
FILETIME m_ftPrevProcKernel;
FILETIME m_ftPrevProcUser;
short m_nCpuUsage;
ULONGLONG m_dwLastRun;
volatile LONG m_lRunCount;
};
}}}
#endif /* WindowsCPUUsage_hpp */
| 18.930233 | 68 | 0.739558 | supudo |
09a0d8fbc646e7ed4bca93c50809b96655e90b06 | 787 | cpp | C++ | assingment/32.cpp | aditya1k2/CPP-SEM-2-KIIT | 1afceeb39458201b6dafe33422d7de8e613d96de | [
"MIT"
] | null | null | null | assingment/32.cpp | aditya1k2/CPP-SEM-2-KIIT | 1afceeb39458201b6dafe33422d7de8e613d96de | [
"MIT"
] | null | null | null | assingment/32.cpp | aditya1k2/CPP-SEM-2-KIIT | 1afceeb39458201b6dafe33422d7de8e613d96de | [
"MIT"
] | null | null | null | /* Name:- Aditya Kumar Gupta
Roll No.:- 1706291
Sec:- B-19
Ques No.:-32 */
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
char str[100],pat[20],new_str[100],rep_pat[50];
int i=0,j=0,k,n=0,copy_loop=0, rep_index=0;
cout<<"Enter the string:\n";
gets(str);
cout<<"\nEnter the pattern: ";
gets(pat);
cout<<"\nEnter the replace pattern:";
gets(rep_pat);
while(str[i]!='\0')
{ j=0,k=i;
while(str[k]==pat[j] && pat[j]!='\0')
{ k++;
j++;
}
if(pat[j]=='\0')
{ copy_loop=k;
while(rep_pat[rep_index]!='\0')
{ new_str[n]=rep_pat[rep_index];
rep_index++;
n++;
}
}
new_str[n]=str[copy_loop];
i++;
copy_loop++;
n++;
}
new_str[n]='\0';
cout<<"\nThe new string is: ";
puts(new_str);
return 0;
}
| 18.738095 | 48 | 0.556544 | aditya1k2 |
09a191ad3902e2287e28eccae3b07851957fe736 | 2,035 | cpp | C++ | cpp/HeapStack/HeapStack_v1/main.cpp | ArboreusSystems/arboreus_examples | 17d39e18f4b2511c19f97d4e6c07ec9d7087fae8 | [
"BSD-3-Clause"
] | 17 | 2019-02-19T21:29:22.000Z | 2022-01-29T11:03:45.000Z | cpp/HeapStack/HeapStack_v1/main.cpp | MbohBless/arboreus_examples | 97f0e25182bbc4b5ffab37c6157514332002aeee | [
"BSD-3-Clause"
] | null | null | null | cpp/HeapStack/HeapStack_v1/main.cpp | MbohBless/arboreus_examples | 97f0e25182bbc4b5ffab37c6157514332002aeee | [
"BSD-3-Clause"
] | 9 | 2021-02-21T05:32:23.000Z | 2022-02-26T07:51:52.000Z | /* -------------------------------------------------------------------
* @doc
* @notice Template file wizards/projects/plaincpp/main.cpp
*
* @copyright Arboreus (http://arboreus.systems)
* @author Alexandr Kirilov (http://alexandr.kirilov.me)
* @created 19/07/2020 at 13:12:12
* */// --------------------------------------------------------------
// System includes
#include <iostream>
// Application includes
#include "maindatamodels.h"
#include "alogger.h"
// Constants
#define A_MAX_LOOP_COUNT 10000000
// Namespace
using namespace std;
// Application
int main(int inCounter, char *inArguments[]) {
int oStackInteger = 10;
int oStackArray[10];
oStackArray[0] = 0; oStackArray[1] = 1;
oStackArray[2] = 2; oStackArray[3] = 3;
oStackArray[4] = 4; oStackArray[5] = 5;
oStackArray[6] = 6; oStackArray[7] = 7;
oStackArray[8] = 8; oStackArray[9] = 9;
ACordinates oStackCordinates;
oStackCordinates.pX = 100;
oStackCordinates.pY = 100;
int* oHeapInteger = new int; *oHeapInteger = 5;
int* oHeapArray = new int[10];
oHeapArray[0] = 0; oHeapArray[1] = 1;
oHeapArray[2] = 2; oHeapArray[3] = 3;
oHeapArray[4] = 4; oHeapArray[5] = 5;
oHeapArray[6] = 6; oHeapArray[7] = 7;
oHeapArray[8] = 8; oHeapArray[9] = 9;
ACordinates* oHeapCordinates = new ACordinates();
oHeapCordinates->pX = 20;
oHeapCordinates->pY = 20;
delete oHeapInteger;
delete[] oHeapArray;
delete oHeapCordinates;
clock_t oStackAllocStart = clock();
for (int i = 0; i < A_MAX_LOOP_COUNT; ++i) {
ACordinates iStackCordinates1 = ACordinates();
}
clock_t oStackAllocDuartion = clock() - oStackAllocStart;
ALOG << "Stack allocation duration: " << oStackAllocDuartion << endl;
clock_t oHeapAllocStart = clock();
for (int i = 0; i < A_MAX_LOOP_COUNT; ++i) {
ACordinates* iHeapCordinates1 = new ACordinates();
// delete iHeapCordinates1;
}
clock_t oHeapAllocDuartion = clock() - oHeapAllocStart;
ALOG << "Heap allocation duration: " << oHeapAllocDuartion << endl;
ALOG << "Heap and stack demo OK" << endl;
return 0;
}
| 26.776316 | 70 | 0.648649 | ArboreusSystems |
09a1db3d62886f85788529fe56a696428bd6d4d2 | 11,674 | cpp | C++ | vm/external_libs/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp | marnen/rubinius | 05b3f9789d01bada0604a7f09921c956bc9487e7 | [
"BSD-3-Clause"
] | 1 | 2016-05-08T16:58:14.000Z | 2016-05-08T16:58:14.000Z | vm/external_libs/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp | taf2/rubinius | 493bfa2351fc509ca33d3bb03991c2e9c2b6dafa | [
"BSD-3-Clause"
] | null | null | null | vm/external_libs/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp | taf2/rubinius | 493bfa2351fc509ca33d3bb03991c2e9c2b6dafa | [
"BSD-3-Clause"
] | null | null | null | //===-- ValueEnumerator.cpp - Number values and types for bitcode writer --===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the ValueEnumerator class.
//
//===----------------------------------------------------------------------===//
#include "ValueEnumerator.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/TypeSymbolTable.h"
#include "llvm/ValueSymbolTable.h"
#include "llvm/Instructions.h"
#include <algorithm>
using namespace llvm;
static bool isFirstClassType(const std::pair<const llvm::Type*,
unsigned int> &P) {
return P.first->isFirstClassType();
}
static bool isIntegerValue(const std::pair<const Value*, unsigned> &V) {
return isa<IntegerType>(V.first->getType());
}
static bool CompareByFrequency(const std::pair<const llvm::Type*,
unsigned int> &P1,
const std::pair<const llvm::Type*,
unsigned int> &P2) {
return P1.second > P2.second;
}
/// ValueEnumerator - Enumerate module-level information.
ValueEnumerator::ValueEnumerator(const Module *M) {
// Enumerate the global variables.
for (Module::const_global_iterator I = M->global_begin(),
E = M->global_end(); I != E; ++I)
EnumerateValue(I);
// Enumerate the functions.
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) {
EnumerateValue(I);
EnumerateParamAttrs(cast<Function>(I)->getParamAttrs());
}
// Enumerate the aliases.
for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
I != E; ++I)
EnumerateValue(I);
// Remember what is the cutoff between globalvalue's and other constants.
unsigned FirstConstant = Values.size();
// Enumerate the global variable initializers.
for (Module::const_global_iterator I = M->global_begin(),
E = M->global_end(); I != E; ++I)
if (I->hasInitializer())
EnumerateValue(I->getInitializer());
// Enumerate the aliasees.
for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
I != E; ++I)
EnumerateValue(I->getAliasee());
// Enumerate types used by the type symbol table.
EnumerateTypeSymbolTable(M->getTypeSymbolTable());
// Insert constants that are named at module level into the slot pool so that
// the module symbol table can refer to them...
EnumerateValueSymbolTable(M->getValueSymbolTable());
// Enumerate types used by function bodies and argument lists.
for (Module::const_iterator F = M->begin(), E = M->end(); F != E; ++F) {
for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
I != E; ++I)
EnumerateType(I->getType());
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){
for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
OI != E; ++OI)
EnumerateOperandType(*OI);
EnumerateType(I->getType());
if (const CallInst *CI = dyn_cast<CallInst>(I))
EnumerateParamAttrs(CI->getParamAttrs());
else if (const InvokeInst *II = dyn_cast<InvokeInst>(I))
EnumerateParamAttrs(II->getParamAttrs());
}
}
// Optimize constant ordering.
OptimizeConstants(FirstConstant, Values.size());
// Sort the type table by frequency so that most commonly used types are early
// in the table (have low bit-width).
std::stable_sort(Types.begin(), Types.end(), CompareByFrequency);
// Partition the Type ID's so that the first-class types occur before the
// aggregate types. This allows the aggregate types to be dropped from the
// type table after parsing the global variable initializers.
std::partition(Types.begin(), Types.end(), isFirstClassType);
// Now that we rearranged the type table, rebuild TypeMap.
for (unsigned i = 0, e = Types.size(); i != e; ++i)
TypeMap[Types[i].first] = i+1;
}
// Optimize constant ordering.
struct CstSortPredicate {
ValueEnumerator &VE;
CstSortPredicate(ValueEnumerator &ve) : VE(ve) {}
bool operator()(const std::pair<const Value*, unsigned> &LHS,
const std::pair<const Value*, unsigned> &RHS) {
// Sort by plane.
if (LHS.first->getType() != RHS.first->getType())
return VE.getTypeID(LHS.first->getType()) <
VE.getTypeID(RHS.first->getType());
// Then by frequency.
return LHS.second > RHS.second;
}
};
/// OptimizeConstants - Reorder constant pool for denser encoding.
void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) {
if (CstStart == CstEnd || CstStart+1 == CstEnd) return;
CstSortPredicate P(*this);
std::stable_sort(Values.begin()+CstStart, Values.begin()+CstEnd, P);
// Ensure that integer constants are at the start of the constant pool. This
// is important so that GEP structure indices come before gep constant exprs.
std::partition(Values.begin()+CstStart, Values.begin()+CstEnd,
isIntegerValue);
// Rebuild the modified portion of ValueMap.
for (; CstStart != CstEnd; ++CstStart)
ValueMap[Values[CstStart].first] = CstStart+1;
}
/// EnumerateTypeSymbolTable - Insert all of the types in the specified symbol
/// table.
void ValueEnumerator::EnumerateTypeSymbolTable(const TypeSymbolTable &TST) {
for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end();
TI != TE; ++TI)
EnumerateType(TI->second);
}
/// EnumerateValueSymbolTable - Insert all of the values in the specified symbol
/// table into the values table.
void ValueEnumerator::EnumerateValueSymbolTable(const ValueSymbolTable &VST) {
for (ValueSymbolTable::const_iterator VI = VST.begin(), VE = VST.end();
VI != VE; ++VI)
EnumerateValue(VI->getValue());
}
void ValueEnumerator::EnumerateValue(const Value *V) {
assert(V->getType() != Type::VoidTy && "Can't insert void values!");
// Check to see if it's already in!
unsigned &ValueID = ValueMap[V];
if (ValueID) {
// Increment use count.
Values[ValueID-1].second++;
return;
}
// Enumerate the type of this value.
EnumerateType(V->getType());
if (const Constant *C = dyn_cast<Constant>(V)) {
if (isa<GlobalValue>(C)) {
// Initializers for globals are handled explicitly elsewhere.
} else if (isa<ConstantArray>(C) && cast<ConstantArray>(C)->isString()) {
// Do not enumerate the initializers for an array of simple characters.
// The initializers just polute the value table, and we emit the strings
// specially.
} else if (C->getNumOperands()) {
// If a constant has operands, enumerate them. This makes sure that if a
// constant has uses (for example an array of const ints), that they are
// inserted also.
// We prefer to enumerate them with values before we enumerate the user
// itself. This makes it more likely that we can avoid forward references
// in the reader. We know that there can be no cycles in the constants
// graph that don't go through a global variable.
for (User::const_op_iterator I = C->op_begin(), E = C->op_end();
I != E; ++I)
EnumerateValue(*I);
// Finally, add the value. Doing this could make the ValueID reference be
// dangling, don't reuse it.
Values.push_back(std::make_pair(V, 1U));
ValueMap[V] = Values.size();
return;
}
}
// Add the value.
Values.push_back(std::make_pair(V, 1U));
ValueID = Values.size();
}
void ValueEnumerator::EnumerateType(const Type *Ty) {
unsigned &TypeID = TypeMap[Ty];
if (TypeID) {
// If we've already seen this type, just increase its occurrence count.
Types[TypeID-1].second++;
return;
}
// First time we saw this type, add it.
Types.push_back(std::make_pair(Ty, 1U));
TypeID = Types.size();
// Enumerate subtypes.
for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end();
I != E; ++I)
EnumerateType(*I);
}
// Enumerate the types for the specified value. If the value is a constant,
// walk through it, enumerating the types of the constant.
void ValueEnumerator::EnumerateOperandType(const Value *V) {
EnumerateType(V->getType());
if (const Constant *C = dyn_cast<Constant>(V)) {
// If this constant is already enumerated, ignore it, we know its type must
// be enumerated.
if (ValueMap.count(V)) return;
// This constant may have operands, make sure to enumerate the types in
// them.
for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i)
EnumerateOperandType(C->getOperand(i));
}
}
void ValueEnumerator::EnumerateParamAttrs(const PAListPtr &PAL) {
if (PAL.isEmpty()) return; // null is always 0.
// Do a lookup.
unsigned &Entry = ParamAttrMap[PAL.getRawPointer()];
if (Entry == 0) {
// Never saw this before, add it.
ParamAttrs.push_back(PAL);
Entry = ParamAttrs.size();
}
}
/// PurgeAggregateValues - If there are any aggregate values at the end of the
/// value list, remove them and return the count of the remaining values. If
/// there are none, return -1.
int ValueEnumerator::PurgeAggregateValues() {
// If there are no aggregate values at the end of the list, return -1.
if (Values.empty() || Values.back().first->getType()->isFirstClassType())
return -1;
// Otherwise, remove aggregate values...
while (!Values.empty() && !Values.back().first->getType()->isFirstClassType())
Values.pop_back();
// ... and return the new size.
return Values.size();
}
void ValueEnumerator::incorporateFunction(const Function &F) {
NumModuleValues = Values.size();
// Adding function arguments to the value table.
for(Function::const_arg_iterator I = F.arg_begin(), E = F.arg_end();
I != E; ++I)
EnumerateValue(I);
FirstFuncConstantID = Values.size();
// Add all function-level constants to the value table.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I)
for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
OI != E; ++OI) {
if ((isa<Constant>(*OI) && !isa<GlobalValue>(*OI)) ||
isa<InlineAsm>(*OI))
EnumerateValue(*OI);
}
BasicBlocks.push_back(BB);
ValueMap[BB] = BasicBlocks.size();
}
// Optimize the constant layout.
OptimizeConstants(FirstFuncConstantID, Values.size());
// Add the function's parameter attributes so they are available for use in
// the function's instruction.
EnumerateParamAttrs(F.getParamAttrs());
FirstInstID = Values.size();
// Add all of the instructions.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
if (I->getType() != Type::VoidTy)
EnumerateValue(I);
}
}
}
void ValueEnumerator::purgeFunction() {
/// Remove purged values from the ValueMap.
for (unsigned i = NumModuleValues, e = Values.size(); i != e; ++i)
ValueMap.erase(Values[i].first);
for (unsigned i = 0, e = BasicBlocks.size(); i != e; ++i)
ValueMap.erase(BasicBlocks[i]);
Values.resize(NumModuleValues);
BasicBlocks.clear();
}
| 35.591463 | 80 | 0.640569 | marnen |
09a3ffc1941a8251858d718e4c97e3e9aa166202 | 533 | cpp | C++ | competitive_programming/programming_contests/spoj_br/bafo.cpp | LeandroTk/Algorithms | 569ed68eba3eeff902f8078992099c28ce4d7cd6 | [
"MIT"
] | 205 | 2018-12-01T17:49:49.000Z | 2021-12-22T07:02:27.000Z | competitive_programming/programming_contests/spoj_br/bafo.cpp | LeandroTk/Algorithms | 569ed68eba3eeff902f8078992099c28ce4d7cd6 | [
"MIT"
] | 2 | 2020-01-01T16:34:29.000Z | 2020-04-26T19:11:13.000Z | competitive_programming/programming_contests/spoj_br/bafo.cpp | LeandroTk/Algorithms | 569ed68eba3eeff902f8078992099c28ce4d7cd6 | [
"MIT"
] | 50 | 2018-11-28T20:51:36.000Z | 2021-11-29T04:08:25.000Z | // BAFO
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, t_beto=0, t_aldo=0, x, y, counter=1;
string result;
cin >> n;
if(n == 0)
return 0;
while(n != 0) {
for (int i = 0; i < n; i++) {
cin >> x >> y;
t_aldo += x;
t_beto += y;
}
if (t_aldo > t_beto)
result = "Aldo";
else
result = "Beto";
cout << "Teste " << counter << endl;
cout << result << endl << endl;
cin >> n;
counter++;
t_beto = 0;
t_aldo = 0;
}
}
| 13.666667 | 45 | 0.467167 | LeandroTk |
09a93f4f2ec3d6e761c821efe40a8908d8d0a2a0 | 1,632 | hpp | C++ | include/foundation/gameobject.hpp | namelessvoid/qrwar | bbc4036cd3bab6b0edcaccbc95286379ef51f12b | [
"MIT"
] | 3 | 2015-03-28T02:51:58.000Z | 2018-11-08T16:49:53.000Z | include/foundation/gameobject.hpp | namelessvoid/qrwar | bbc4036cd3bab6b0edcaccbc95286379ef51f12b | [
"MIT"
] | 39 | 2015-05-18T08:29:16.000Z | 2020-07-18T21:17:44.000Z | include/foundation/gameobject.hpp | namelessvoid/qrwar | bbc4036cd3bab6b0edcaccbc95286379ef51f12b | [
"MIT"
] | null | null | null | #ifndef QRW_GAMEOBJECT_HPP
#define QRW_GAMEOBJECT_HPP
#include <map>
#include <typeinfo>
#include <typeindex>
#include <cassert>
#include <functional>
#include <foundation/gamecomponent.hpp>
#include "meta/reflectable.hpp"
namespace qrw
{
class GameComponent;
class GameObject : public Reflectable
{
public:
GameObject();
~GameObject() override;
// Called by Scene::destroy(GameObject*).
// This is useful to clean up resources which have to call other game objects in the cleanup process.
// The GameObject is not destroyed immediately but is scheduled for deletion on the
// next frame.
virtual void onDestroy();
// Called by Scene::addtoScene(GameObject*).
virtual void onAddToScene() {}
// Called by Scene::update() right before the GameObject's update method would
// be called for the first time.
// This is useful for e.g. initializing resources which depend on other game objects and therefore
// cannot be initialized in the constructor since not all scene objects my be created yet.
virtual void initialize() { initialized_ = true; }
bool isInitialized() { return initialized_; }
void addComponent(GameComponent* component);
void removeComponent(GameComponent* component);
virtual void update(float elapsedTimeInSeconds) {}
template<class T>
T* getFirstComponent();
private:
bool initialized_;
std::multimap<std::type_index, GameComponent*> components_;
};
template<class T>
T* GameObject::getFirstComponent()
{
assert(components_.find(typeid(T))!=components_.end());
return dynamic_cast<T*>(components_.find(typeid(T))->second);
}
} // namespace qrw
#endif // QRW_GAMEOBJECT_HPP
| 24.727273 | 102 | 0.756127 | namelessvoid |
09a994f79ffde40a6455a8f05ceb83d9f5aa9c8a | 421 | cpp | C++ | CodeFourses/A.HelpfulMaths.cpp | Rafat97/RafatProgtammingContest | f39ef6a71511abb91d42c6af469e4b24959be226 | [
"Apache-2.0"
] | null | null | null | CodeFourses/A.HelpfulMaths.cpp | Rafat97/RafatProgtammingContest | f39ef6a71511abb91d42c6af469e4b24959be226 | [
"Apache-2.0"
] | null | null | null | CodeFourses/A.HelpfulMaths.cpp | Rafat97/RafatProgtammingContest | f39ef6a71511abb91d42c6af469e4b24959be226 | [
"Apache-2.0"
] | null | null | null | #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
char str[500],str1[500];
int i = 0;
gets(str);
for(int j = 0;j<strlen(str);i++,j = j + 2 )
str1[i] = str[j];
str1[i] = '\0';
sort(str1,str1+strlen(str1));
for(int j = 0,i = 0;j<strlen(str);i++,j = j + 2 )
str[j] = str1[i];
puts(str);
return 0;
}
| 13.580645 | 53 | 0.524941 | Rafat97 |
09acab92de7bc049d3b6f4ac9b00aa0877acd311 | 174 | cpp | C++ | unsafe_coerce/unsafe-coerce.cpp | mikesol/purescript-native-cpp-ffi | 3805115716e7f5dfe3b046c2e2967bfbdf2ce19f | [
"MIT"
] | 11 | 2019-07-28T14:19:04.000Z | 2021-06-11T11:40:43.000Z | unsafe_coerce/unsafe-coerce.cpp | andyarvanitis/purescript-cpp-ffi | 268567879eed9a1da8450f07277382a76c658a90 | [
"MIT"
] | 4 | 2018-11-16T07:59:01.000Z | 2019-05-19T01:03:06.000Z | unsafe_coerce/unsafe-coerce.cpp | andyarvanitis/purescript-cpp-ffi | 268567879eed9a1da8450f07277382a76c658a90 | [
"MIT"
] | 4 | 2019-12-22T05:36:30.000Z | 2021-11-08T09:49:59.000Z | #include "purescript.h"
// Tested with package v4.0.0
FOREIGN_BEGIN( Unsafe_Coerce )
exports["unsafeCoerce"] = [](const boxed& x) -> boxed {
return x;
};
FOREIGN_END
| 14.5 | 55 | 0.678161 | mikesol |
09ad28d0d52ed20c83b23d6d45647ed5aafc88b4 | 6,374 | cpp | C++ | apps/Viewer/src/Preferences.cpp | asuessenbach/pipeline | 2e49968cc3b9948a57f7ee6c4cc3258925c92ab2 | [
"BSD-3-Clause"
] | 217 | 2015-01-06T09:26:53.000Z | 2022-03-23T14:03:18.000Z | apps/Viewer/src/Preferences.cpp | asuessenbach/pipeline | 2e49968cc3b9948a57f7ee6c4cc3258925c92ab2 | [
"BSD-3-Clause"
] | 10 | 2015-01-25T12:42:05.000Z | 2017-11-28T16:10:16.000Z | apps/Viewer/src/Preferences.cpp | asuessenbach/pipeline | 2e49968cc3b9948a57f7ee6c4cc3258925c92ab2 | [
"BSD-3-Clause"
] | 44 | 2015-01-13T01:19:41.000Z | 2022-02-21T21:35:08.000Z | // Copyright (c) 2009-2015, NVIDIA CORPORATION. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Preferences.h"
#include "Viewer.h"
#include <QMetaProperty>
#include <QProcessEnvironment>
#include <QSettings>
#include <dp/fx/EffectLibrary.h>
#include <dp/util/File.h>
Preferences::Preferences( QObject * parent )
: QObject( parent )
, m_environmentEnabled( true )
, m_normalsLineLength( 1.f )
, m_transparencyMode( static_cast<unsigned int>(dp::sg::renderer::rix::gl::TransparencyMode::ORDER_INDEPENDENT_ALL) )
{
load();
QProcessEnvironment pe = QProcessEnvironment::systemEnvironment();
QString home = pe.contains( "DPHOME" ) ? pe.value( "DPHOME" ) : QString( "." );
// Add the DPHOME media folders if m_searchPath is empty
// which is the case on the very first program run.
// Different paths can be added inside the Preferences Dialog.
if ( !m_searchPaths.count() )
{
m_searchPaths.append( home + QString( "/media/dpfx" ) );
m_searchPaths.append( home + QString("/media/effects") );
m_searchPaths.append( home + QString("/media/effects/xml") );
m_searchPaths.append( home + QString("/media/textures") );
m_searchPaths.append( home + QString("/media/textures/maxbench") );
}
if ( m_environmentTextureName.isEmpty() )
{
m_environmentTextureName = home + "/media/textures/spheremaps/spherical_checker.png";
}
if ( m_materialCatalogPath.isEmpty() )
{
m_materialCatalogPath = home + "/media/effects";
}
if ( m_sceneSelectionPath.isEmpty() )
{
m_sceneSelectionPath = home + QString( "/media/scenes" );
}
if ( m_textureSelectionPath.isEmpty() )
{
m_textureSelectionPath = home + QString( "/media/textures" );
}
}
Preferences::~Preferences()
{
save();
}
void Preferences::load()
{
QSettings settings( VIEWER_APPLICATION_VENDOR, VIEWER_APPLICATION_NAME );
const QMetaObject * mo = metaObject();
for( int i = 0; i < mo->propertyCount(); i ++ )
{
QMetaProperty mp = mo->property( i );
if( settings.contains( mp.name() ) )
{
mp.write( this, settings.value( mp.name() ) );
}
}
}
void Preferences::save() const
{
QSettings settings( VIEWER_APPLICATION_VENDOR, VIEWER_APPLICATION_NAME );
const QMetaObject * mo = metaObject();
for( int i = 0; i < mo->propertyCount(); i ++ )
{
QMetaProperty mp = mo->property( i );
settings.setValue( mp.name(), mp.read(this) );
}
}
void Preferences::setDepthPass( bool enabled )
{
if ( m_depthPassEnabled != enabled )
{
m_depthPassEnabled = enabled;
emit depthPassEnabled( enabled );
}
}
bool Preferences::getDepthPass() const
{
return( m_depthPassEnabled );
}
void Preferences::setEnvironmentEnabled( bool enabled )
{
if ( m_environmentEnabled != enabled )
{
m_environmentEnabled = enabled;
emit environmentEnabledChanged();
}
}
bool Preferences::getEnvironmentEnabled() const
{
return( m_environmentEnabled );
}
void Preferences::setEnvironmentTextureName( const QString & name )
{
if ( m_environmentTextureName != name )
{
m_environmentTextureName = name;
emit environmentTextureNameChanged( name );
}
}
QString Preferences::getEnvironmentTextureName() const
{
return( m_environmentTextureName );
}
void Preferences::setMaterialCatalogPath( QString const& name )
{
if ( m_materialCatalogPath != name )
{
m_materialCatalogPath = name;
emit materialCatalogPathChanged( name );
}
}
QString Preferences::getMaterialCatalogPath() const
{
return( m_materialCatalogPath );
}
void Preferences::setNormalsLineLength( float len )
{
if( len != m_normalsLineLength )
{
m_normalsLineLength = len;
emit normalsLineLengthChanged( len );
}
}
float Preferences::getNormalsLineLength() const
{
return m_normalsLineLength;
}
void Preferences::setSceneSelectionPath( QString const& path )
{
m_sceneSelectionPath = path;
}
QString Preferences::getSceneSelectionPath() const
{
return( m_sceneSelectionPath );
}
void Preferences::setSearchPaths( const QStringList & paths )
{
if( paths != m_searchPaths )
{
m_searchPaths = paths;
emit searchPathsChanged( paths );
}
}
QStringList Preferences::getSearchPaths() const
{
return m_searchPaths;
}
std::vector<std::string> Preferences::getSearchPathsAsStdVector() const
{
std::vector< std::string > searchPaths;
for( int i = 0; i < m_searchPaths.count(); i ++ )
{
searchPaths.push_back( m_searchPaths.at(i).toStdString() );
dp::util::convertPath( searchPaths.back() );
}
return searchPaths;
}
void Preferences::setTextureSelectionPath( QString const& path )
{
m_textureSelectionPath = path;
}
QString Preferences::getTextureSelectionPath() const
{
return( m_textureSelectionPath );
}
void Preferences::setTransparencyMode( unsigned int tm )
{
m_transparencyMode = tm;
}
unsigned int Preferences::getTransparencyMode() const
{
return( m_transparencyMode );
}
| 27.239316 | 119 | 0.720427 | asuessenbach |
09b0ad0b6b27c21c962625822124d58e14ea0684 | 1,701 | cpp | C++ | src/main/zsystem/Backtrace.cpp | SLukasDE/zsystem | d75d361e5e0226416d1f143051195a30530bc128 | [
"MIT"
] | null | null | null | src/main/zsystem/Backtrace.cpp | SLukasDE/zsystem | d75d361e5e0226416d1f143051195a30530bc128 | [
"MIT"
] | null | null | null | src/main/zsystem/Backtrace.cpp | SLukasDE/zsystem | d75d361e5e0226416d1f143051195a30530bc128 | [
"MIT"
] | null | null | null | /*
MIT License
Copyright (c) 2019-2021 Sven Lukas
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 <zsystem/Backtrace.h>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
namespace zsystem {
Backtrace::Backtrace() {
constexpr int SIZE = 100;
void *buffer[SIZE];
int stackSize;
char **stack;
stackSize = backtrace(buffer, SIZE);
stack = backtrace_symbols(buffer, stackSize);
if (stack != nullptr) {
int skipLines = 1;
for(int i = skipLines; i < stackSize; i++) {
elements.push_back(stack[i]);
}
free(stack);
}
}
const std::vector<std::string>& Backtrace::getElements() const {
return elements;
}
} /* namespace zsystem */
| 31.5 | 78 | 0.741329 | SLukasDE |
09b1d686c973d57dbff589cd1f60935d614eb813 | 631 | cpp | C++ | platform/android/CCStorePaymentTransactionWrapper.cpp | kpkhxlgy0/cocos2dh-js | d84f76b505ad0f2fdb799721352a4f510795a096 | [
"MIT"
] | 2 | 2017-11-17T02:54:32.000Z | 2018-11-26T08:17:23.000Z | platform/android/CCStorePaymentTransactionWrapper.cpp | kpkhxlgy0/cocos2dh-js | d84f76b505ad0f2fdb799721352a4f510795a096 | [
"MIT"
] | null | null | null | platform/android/CCStorePaymentTransactionWrapper.cpp | kpkhxlgy0/cocos2dh-js | d84f76b505ad0f2fdb799721352a4f510795a096 | [
"MIT"
] | null | null | null |
#include "../../quick/store/CCStorePaymentTransactionWrapper.h"
// #import <StoreKit/StoreKit.h>
NS_CC_H_BEGIN
CCStorePaymentTransactionWrapper* CCStorePaymentTransactionWrapper::createWithTransaction(void* transactionObj)
{
// CCStorePaymentTransactionWrapper* transaction = new CCStorePaymentTransactionWrapper();
// transaction->m_transactionObj = transactionObj;
// [(SKPaymentTransaction *)transactionObj retain];
// return transaction;
return NULL;
}
CCStorePaymentTransactionWrapper::~CCStorePaymentTransactionWrapper(void)
{
// [(SKPaymentTransaction *)m_transactionObj release];
}
NS_CC_H_END
| 28.681818 | 111 | 0.787639 | kpkhxlgy0 |
09b4c813e5c3ad608ea37ed0d4b5b8c93ea9edb8 | 582 | cpp | C++ | 6 - User defined functions/6.2 - Paramaters/activity/multiple_parameters.cpp | aTonyXiao/Zybook | 36cd05a436c6ca007cdd14638cf5ee2a7724b889 | [
"MIT"
] | 11 | 2017-11-17T07:31:44.000Z | 2020-12-05T14:46:56.000Z | 6 - User defined functions/6.2 - Paramaters/activity/multiple_parameters.cpp | aTonyXiao/Zybook | 36cd05a436c6ca007cdd14638cf5ee2a7724b889 | [
"MIT"
] | null | null | null | 6 - User defined functions/6.2 - Paramaters/activity/multiple_parameters.cpp | aTonyXiao/Zybook | 36cd05a436c6ca007cdd14638cf5ee2a7724b889 | [
"MIT"
] | 1 | 2019-10-15T20:58:51.000Z | 2019-10-15T20:58:51.000Z | #include <iostream>
/*
Modify PrintFace() to have three parameters: char eyeChar, char noseChar, char mouthChar. Call the function with arguments 'o', '*', and '#', which should draw this face:
*/
using namespace std;
void PrintFace(char eye, char nose, char mouth) { // FIXME: Support 3 parameters
cout << " " << eye << " " << eye << endl; // Eyes
cout << " " << nose << endl; // Nose
cout << " " << mouth << mouth << mouth << endl; // Mouth
return;
}
int main() {
PrintFace('*','o','_'); // FIXME: Pass 3 arguments
return 0;
}
| 32.333333 | 171 | 0.568729 | aTonyXiao |
09b5be6958269c0c89eb66cd5aa7d56479d2f59a | 15,550 | cpp | C++ | CONTRIB/LLVM/_Demo/Lib_GZ/Gpu/ShaderModel/GzModel/GzShModel.cpp | Cwc-Test/CpcdosOS2.1 | d52c170be7f11cc50de38ef536d4355743d21706 | [
"Apache-2.0"
] | 1 | 2021-05-05T20:42:24.000Z | 2021-05-05T20:42:24.000Z | CONTRIB/LLVM/_Demo/Lib_GZ/Gpu/ShaderModel/GzModel/GzShModel.cpp | Cwc-Test/CpcdosOS2.1 | d52c170be7f11cc50de38ef536d4355743d21706 | [
"Apache-2.0"
] | null | null | null | CONTRIB/LLVM/_Demo/Lib_GZ/Gpu/ShaderModel/GzModel/GzShModel.cpp | Cwc-Test/CpcdosOS2.1 | d52c170be7f11cc50de38ef536d4355743d21706 | [
"Apache-2.0"
] | null | null | null | //This file is part of "GZE - GroundZero Engine"
//The permisive licence allow to use GZE for free or commercial project (Apache License, Version 2.0).
//For conditions of distribution and use, see copyright notice in Licence.txt, this license must be included with any distribution of the code.
//Though not required by the license agreement, please consider the following will be greatly appreciated:
//- We would like to hear about projects where GZE is used.
//- Include an attribution statement somewhere in your project.
//- If you want to see GZE evolve please help us with a donation.
#include "Lib_GZ/Gpu/ShaderModel/GzModel/GzShModel.h"
#include "Lib_GZ/Gpu/ShaderBase/FragmentShader.h"
#include "Lib_GZ/Gpu/ShaderBase/VertexShader.h"
#include "Lib_GZ/Gpu/ShaderBase/ProgramShader.h"
#include "Lib_GZ/Gpu/Base/Attribute.h"
#include "Lib_GZ/Gpu/Base/Uniform.h"
#include "Lib_GZ/Gpu/Base/UnVec2.h"
#include "Lib_GZ/Gpu/ShaderBase/Vbo.h"
#include "Lib_GZ/Gpu/GpuObj/GpuBatch.h"
#include "Lib_GZ/Base/Perspective.h"
#include "Lib_GZ/Base/TestPod.h"
#include "Lib_GZ/Base/TestPod2.h"
#include "Lib_GZ/Sys/Debug.h"
#include "Lib_GZ/Class.h"
#include "Lib_GZ/ThreadMsg.h"
//Sub Class include
#include "Lib_GZ/Base/Vec2.h"
namespace Lib_GZ{namespace Gpu{namespace ShaderModel{namespace GzModel{namespace GzShModel{
////// Current Lib Access ////
//// Current Static Access ////
#undef _
#define _ GzShModel
void Ini_Class(){
}
#ifdef GZ_tHaveCallStack
gzFuncStack zFuncName[] = {{0,"GzShModel"},{0,"fLoad"},{0,"fPod"},{0,"fDraw"}};
#endif
///////////////////////////////
}
GZ_mCppClass(GzShModel)
cGzShModel::cGzShModel(Lib_GZ::cBase* _parent) : Lib_GZ::cClass(_parent){
}
void cGzShModel::Ini_cGzShModel(){ gz_(0)
Lib_GZ::Sys::Debug::Get(thread)->fTrace1(gzStrL("--- GzShModel Created!! ---"));
fLoad();
}
gzBool cGzShModel::fLoad(){ gz_(1)
oVertex = gzSCast<Lib_GZ::Gpu::ShaderBase::cVertexShader>((Lib_GZ::Gpu::ShaderBase::VertexShader::Get(thread)->New(this)));
oFragement = gzSCast<Lib_GZ::Gpu::ShaderBase::cFragmentShader>((Lib_GZ::Gpu::ShaderBase::FragmentShader::Get(thread)->New(this)));
oProgram = gzSCast<Lib_GZ::Gpu::ShaderBase::cProgramShader>((Lib_GZ::Gpu::ShaderBase::ProgramShader::Get(thread)->New(this)));
// --- Tag Glsl
oVertex->fAddLine(gzStrL("in vec4 atObjPos;"));
oVertex->fAddLine(gzStrL("xflat out vec4 vColor;"));
oVertex->fAddLine(gzStrL("out vec2 ioTexture;"));
oVertex->fAddLine(gzStrL("void main(){"));
oVertex->fAddLine(gzStrL("if (nVertexID < 2){"));
oVertex->fAddLine(gzStrL("if(nVertexID == 0){"));
oVertex->fAddLine(gzStrL("gl_Position.x = -1.0;"));
oVertex->fAddLine(gzStrL("gl_Position.y = -1.0;"));
oVertex->fAddLine(gzStrL("}else{"));
oVertex->fAddLine(gzStrL("gl_Position.x = 1.0;"));
oVertex->fAddLine(gzStrL("gl_Position.y = -1.0;"));
oVertex->fAddLine(gzStrL("}"));
oVertex->fAddLine(gzStrL("}else{"));
oVertex->fAddLine(gzStrL("if(nVertexID == 2){"));
oVertex->fAddLine(gzStrL("gl_Position.x = 1.0;"));
oVertex->fAddLine(gzStrL("gl_Position.y = 1.0;"));
oVertex->fAddLine(gzStrL("}else{"));
oVertex->fAddLine(gzStrL("gl_Position.x = -1.0;"));
oVertex->fAddLine(gzStrL("gl_Position.y = 1.0;"));
oVertex->fAddLine(gzStrL("}"));
oVertex->fAddLine(gzStrL("}"));
oVertex->fAddLine(gzStrL("gl_Position.z = 0.5;"));
oVertex->fAddLine(gzStrL("gl_Position.w = 1.0;"));
oVertex->fAddLine(gzStrL("//gl_Position.xy = atObjPos.xy; //Temp"));
oVertex->fAddLine(gzStrL("vColor = atObjPos;"));
oVertex->fAddLine(gzStrL("//vColor = vec4(atObjPos.y, 0.0,1.0,1.0 );"));
oVertex->fAddLine(gzStrL("// vColor = vec4(1.0,0.0,0.0,1.0);"));
oVertex->fAddLine(gzStrL("}"));
// --- End Tag Glsl
oVertex->fLoad();
if (oVertex->fCompile() == false){
Lib_GZ::Sys::Debug::Get(thread)->fError(gzStrL("Vertex Shader: ") + oVertex->fGetErrorLine());
Lib_GZ::Sys::Debug::Get(thread)->fTrace1(gzStrL(" -->") + oVertex->fGetLog());
}else{
Lib_GZ::Sys::Debug::Get(thread)->fPass(gzStrL("Vertex Success"));
}
// --- Tag Glsl
oFragement->fAddLine(gzStrL("uniform vec2 vTexDim;"));
oFragement->fAddLine(gzStrL("uniform vec2 vWinDim;"));
oFragement->fAddLine(gzStrL("uniform vec2 vMouse;"));
oFragement->fAddLine(gzStrL("xflat in vec4 vColor;"));
oFragement->fAddLine(gzStrL("xflat in vec2 ioTexture;"));
oFragement->fAddLine(gzStrL("vec3 cam_pos = vec3(0,0,0);"));
oFragement->fAddLine(gzStrL("float PI=3.14159265;"));
oFragement->fAddLine(gzStrL("///////////////////////// OBJ /////////////////"));
oFragement->fAddLine(gzStrL("//Sol"));
oFragement->fAddLine(gzStrL("vec2 obj_floor( vec3 p){"));
oFragement->fAddLine(gzStrL("return vec2(p.y+10.0,0);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("//Sphere"));
oFragement->fAddLine(gzStrL("vec2 obj_sphere( vec3 p){"));
oFragement->fAddLine(gzStrL("float d = length(p)-1.9;"));
oFragement->fAddLine(gzStrL("return vec2(d,1);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("//Tore"));
oFragement->fAddLine(gzStrL("vec2 obj_torus( vec3 p){"));
oFragement->fAddLine(gzStrL("vec2 r = vec2(1.4,1.2);"));
oFragement->fAddLine(gzStrL("vec2 q = vec2(length(p.xz)-r.x,p.y);"));
oFragement->fAddLine(gzStrL("float d = length(q)-r.y;"));
oFragement->fAddLine(gzStrL("return vec2(d,1);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("//Box"));
oFragement->fAddLine(gzStrL("vec2 obj_round_box(vec3 p){"));
oFragement->fAddLine(gzStrL("float d = length(max(abs(p)-vec3(0.3,0.15,1.0),0.0))-0.2;"));
oFragement->fAddLine(gzStrL("return vec2(d,1);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("/*"));
oFragement->fAddLine(gzStrL("vec2 obj_round_box(vec3 p){"));
oFragement->fAddLine(gzStrL("float d= length(max(abs(p)-vec3(1.0,0.5,2.0),0.0))-0.08;"));
oFragement->fAddLine(gzStrL("// float d = length(max(abs(p)-vec3(2.0,0.5,2.0),0.0))-0.2;"));
oFragement->fAddLine(gzStrL("return vec2(d,1);"));
oFragement->fAddLine(gzStrL("}*/"));
oFragement->fAddLine(gzStrL("///////////////////////////////////////////////////////"));
oFragement->fAddLine(gzStrL("/// Operator ////////"));
oFragement->fAddLine(gzStrL("vec2 op_union(vec2 a, vec2 b){"));
oFragement->fAddLine(gzStrL("float d = min(a.x, b.x);"));
oFragement->fAddLine(gzStrL("return vec2(d,1);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("vec2 op_rep(vec3 p, vec3 c){"));
oFragement->fAddLine(gzStrL("vec3 q = mod(p,c)-0.5*c;"));
oFragement->fAddLine(gzStrL("return obj_round_box(q);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("vec2 op_sub(vec2 a, vec2 b) {"));
oFragement->fAddLine(gzStrL("float d = max(a.x, -b.x);"));
oFragement->fAddLine(gzStrL("return vec2(d,1);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("vec2 op_blend(vec3 p, vec2 a, vec2 b){"));
oFragement->fAddLine(gzStrL("float s = smoothstep(length(p), 0.0, 1.0);"));
oFragement->fAddLine(gzStrL("float d = mix(a.x, b.x, s);"));
oFragement->fAddLine(gzStrL("return vec2(d,1);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("/////////// Union ////////////////////"));
oFragement->fAddLine(gzStrL("vec2 obj_union( vec2 obj0, vec2 obj1){"));
oFragement->fAddLine(gzStrL("if (obj0.x < obj1.x){"));
oFragement->fAddLine(gzStrL("return obj0;"));
oFragement->fAddLine(gzStrL("}else{"));
oFragement->fAddLine(gzStrL("return obj1;"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("// Union d'objets"));
oFragement->fAddLine(gzStrL("vec2 distance_to_obj( vec3 p){"));
oFragement->fAddLine(gzStrL("//return obj_floor(p);"));
oFragement->fAddLine(gzStrL("//return obj_union(obj_floor(p), obj_round_box(p));"));
oFragement->fAddLine(gzStrL("//return obj_union(obj_floor(p), op_union(obj_round_box(p), obj_sphere(p)));"));
oFragement->fAddLine(gzStrL("//return obj_union(obj_floor(p), op_sub(obj_round_box(p), obj_sphere(p)));"));
oFragement->fAddLine(gzStrL("//return obj_union(obj_floor(p), op_blend(p, obj_round_box(p), obj_torus(p)) ) ;"));
oFragement->fAddLine(gzStrL("//return obj_union(obj_floor(p), op_blend(p, obj_round_box(p), obj_torus(p)) ) ;"));
oFragement->fAddLine(gzStrL("return obj_union(obj_floor(p), op_rep(p , vec3(3.0, 2.0, 6.0)));"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("//// Couleur du sol (damier)"));
oFragement->fAddLine(gzStrL("vec3 floor_color( vec3 p){"));
oFragement->fAddLine(gzStrL("vec3 c = vec3(8.0, 5.0, 9.0);"));
oFragement->fAddLine(gzStrL("vec3 q = mod(p,c) - 0.5 * c;"));
oFragement->fAddLine(gzStrL("return q ;"));
oFragement->fAddLine(gzStrL("// return vec3( smoothstep(length(p), fract(p.x*0.2), fract(p.y*0.2)),1,1);"));
oFragement->fAddLine(gzStrL("/*"));
oFragement->fAddLine(gzStrL("if (fract(p.x*0.2)>0.2){"));
oFragement->fAddLine(gzStrL("if (fract(p.z*0.2)>0.2){"));
oFragement->fAddLine(gzStrL("return vec3(0,0.1,0.2);"));
oFragement->fAddLine(gzStrL("}else{"));
oFragement->fAddLine(gzStrL("return vec3(1,1,1);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("}else{"));
oFragement->fAddLine(gzStrL("if (fract(p.z*.2)>.2){"));
oFragement->fAddLine(gzStrL("return vec3(1,1,1);"));
oFragement->fAddLine(gzStrL("}else{"));
oFragement->fAddLine(gzStrL("return vec3(0.3,0,0);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("}*/"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("//// Couleur de la primitive"));
oFragement->fAddLine(gzStrL("vec3 prim_c( vec3 p){"));
oFragement->fAddLine(gzStrL("return vec3(0.9137,0.83,0.70);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("void main(){"));
oFragement->fAddLine(gzStrL("vec2 q = ( gl_FragCoord.xy / vec2(800.0,800.0) );"));
oFragement->fAddLine(gzStrL("//FragColor = vec4(0,q.y,0,1.0);"));
oFragement->fAddLine(gzStrL("//return;"));
oFragement->fAddLine(gzStrL("float _nMove = 2.5 * vMouse.x;"));
oFragement->fAddLine(gzStrL("//vec2 q = vec2(1.0, 0.5);"));
oFragement->fAddLine(gzStrL("vec2 vPos = -1.0 + 2.0 * q;"));
oFragement->fAddLine(gzStrL("// Inclinaison de la caméra."));
oFragement->fAddLine(gzStrL("vec3 vuv = vec3(0,1.5,0.0);"));
oFragement->fAddLine(gzStrL("// Direction de la caméra."));
oFragement->fAddLine(gzStrL("vec3 vrp = vec3(0.5,0.5,1.0);"));
oFragement->fAddLine(gzStrL("//vec3 vrp = vec3(0.0, _nMove, 0.0) * 6.0;"));
oFragement->fAddLine(gzStrL("// Position de la caméra."));
oFragement->fAddLine(gzStrL("vec2 mouse = vec2(0.5, 0.5);"));
oFragement->fAddLine(gzStrL("float mx = mouse.x* PI * 2.0;"));
oFragement->fAddLine(gzStrL("float my = mouse.y* PI / 2.01;"));
oFragement->fAddLine(gzStrL("//vec3 prp = vec3( cos(my)*cos(mx), sin(my), cos(my)*sin(mx) ) * 6.0;"));
oFragement->fAddLine(gzStrL("vec3 prp = vec3( _nMove * 1.5 - 0.2 , _nMove - 0.3- 1.0, -0.6 ) * 6.0 ;"));
oFragement->fAddLine(gzStrL("//vec3 prp = cam_pos;"));
oFragement->fAddLine(gzStrL("vec3 vpn = normalize(vrp-prp);"));
oFragement->fAddLine(gzStrL("vec3 u = normalize(cross(vuv , vpn));"));
oFragement->fAddLine(gzStrL("vec3 v = cross(vpn , u);"));
oFragement->fAddLine(gzStrL("vec3 vcv = (prp + vpn);"));
oFragement->fAddLine(gzStrL("//vec3 scrCoord=vcv+vPos.x*u*resolution.x/resolution.y+vPos.y*v;"));
oFragement->fAddLine(gzStrL("vec3 scrCoord = vcv + vPos.x * u * 0.8 + vPos.y * v * 0.8;"));
oFragement->fAddLine(gzStrL("vec3 scp = normalize(scrCoord - prp);"));
oFragement->fAddLine(gzStrL("// Raymarching."));
oFragement->fAddLine(gzStrL("const vec3 e = vec3(0.02, 0, 0);"));
oFragement->fAddLine(gzStrL("const float maxd = 100.0;"));
oFragement->fAddLine(gzStrL("vec2 d = vec2(0.02,0.0);"));
oFragement->fAddLine(gzStrL("vec3 c,p,N;"));
oFragement->fAddLine(gzStrL("float f = 1.0;"));
oFragement->fAddLine(gzStrL("for(int i = 0; i< 260; i++){"));
oFragement->fAddLine(gzStrL("if ((abs(d.x) < .001) || (f > maxd)) {"));
oFragement->fAddLine(gzStrL("break;"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("f += d.x;"));
oFragement->fAddLine(gzStrL("p = prp + scp * f;"));
oFragement->fAddLine(gzStrL("d = distance_to_obj(p);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("if (f < maxd){"));
oFragement->fAddLine(gzStrL("if (d.y==0.0){"));
oFragement->fAddLine(gzStrL("c=floor_color(p);"));
oFragement->fAddLine(gzStrL("}else{"));
oFragement->fAddLine(gzStrL("c=prim_c(p);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("vec3 n = vec3(d.x-distance_to_obj(p-e.xyy).x, d.x-distance_to_obj(p-e.yxy).x, d.x-distance_to_obj(p-e.yyx).x);"));
oFragement->fAddLine(gzStrL("N = normalize(n);"));
oFragement->fAddLine(gzStrL("float b=dot(N,normalize(prp-p));"));
oFragement->fAddLine(gzStrL("// Simple éclairage Phong, LightPosition = CameraPosition"));
oFragement->fAddLine(gzStrL("FragColor = vec4((b*c+pow(b,16.0))*(1.0-f*.01),1.0);"));
oFragement->fAddLine(gzStrL("}else{"));
oFragement->fAddLine(gzStrL("FragColor = vec4(0.0 + vColor.x,0,0,1.0);"));
oFragement->fAddLine(gzStrL("//FragColor = vec4(0 ,0,0,1.0);"));
oFragement->fAddLine(gzStrL("}"));
oFragement->fAddLine(gzStrL("}"));
// --- End Tag Glsl
oFragement->fLoad();
if (oFragement->fCompile() == false){
Lib_GZ::Sys::Debug::Get(thread)->fError(gzStrL("Fragment Shader: ") + oFragement->fGetErrorLine());
Lib_GZ::Sys::Debug::Get(thread)->fTrace1(gzStrL(" -->") + oFragement->fGetLog());
}else{
Lib_GZ::Sys::Debug::Get(thread)->fPass(gzStrL("Fragement Shader Success"));
}
oProgram->fAttachShader((Lib_GZ::Gpu::ShaderBase::cShaderBase*)(oVertex.get()));
oProgram->fAttachShader((Lib_GZ::Gpu::ShaderBase::cShaderBase*)(oFragement.get()));
if (oProgram->fLink() != 0){
Lib_GZ::Sys::Debug::Get(thread)->fPass(gzStrL("Link Success"));
}
oProgram->fUse();
oProgram->fSetDefaultAttribDivisor(1);
oVboBatch = gzSCast<Lib_GZ::Gpu::ShaderBase::cVbo>(oProgram->fAddVbo());
oGpuBatch = gzSCast<Lib_GZ::Gpu::GpuObj::cGpuBatch>((Lib_GZ::Gpu::GpuObj::GpuBatch::Get(thread)->New(this)));
gzSp<Lib_GZ::Gpu::Base::cAttribute> _oAtObjPos = gzSCast<Lib_GZ::Gpu::Base::cAttribute>(oProgram->fAddAttribute(gzStrL("atObjPos")));
gzSp<Lib_GZ::Gpu::Base::cAttribute> _oAtVertexID = gzSCast<Lib_GZ::Gpu::Base::cAttribute>(oProgram->fAddAttribute(gzStrL("atVertexID")));
oUvMouse = gzSCast<Lib_GZ::Gpu::Base::cUnVec2>((Lib_GZ::Gpu::Base::UnVec2::Get(thread)->New(this, (Lib_GZ::Gpu::ShaderBase::cProgramShader*)(oProgram.get()), gzStrL("vMouse"))));
gzSp<Lib_GZ::Base::cPerspective> _oPersv = gzSCast<Lib_GZ::Base::cPerspective>((Lib_GZ::Base::Perspective::Get(thread)->New(this)));
gzPod<Lib_GZ::Base::cTestPod> _oPod = (Lib_GZ::Base::TestPod::Get(thread)->New(this, gzFloat(5), gzFloat(5)));
gzPod<Lib_GZ::Base::cTestPod2> _oPod2 = (Lib_GZ::Base::TestPod2::Get(thread)->New(this, gzFloat(1), 2.5, gzFloat(3), gzFloat(4)));
fPod((Lib_GZ::Base::cTestPod2*)(_oPod2.get()));
return false;
}
void cGzShModel::fPod(Lib_GZ::Base::cTestPod2* _oPod){ gz_(2)
Lib_GZ::Sys::Debug::Get(thread)->fTrace1(gzStrL("PodsX:") + gzStrF(_oPod->nW));
}
void cGzShModel::fDraw(){ gz_(3)
oUvMouse->oVal->nX += 0.01;
oUvMouse->fSend();
oVboBatch->fSendData();
oGpuBatch->fDraw();
}
gzAny cGzShModel::MemCopy(){
return (gzAny)new cGzShModel(*this);
}
gzAny cGzShModel::DeepCopy(){
return (gzAny)new cGzShModel(*this, true);
}
cGzShModel::~cGzShModel(){
}
}}}} | 51.490066 | 179 | 0.668746 | Cwc-Test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.