Loading net/include/net/config.hpp 0 → 100644 +17 −0 Original line number Diff line number Diff line #pragma once #include <com/context.hpp> struct Config final : public com::File { static inline std::string self_name() { return "config"; } Config(); ~Config() override; double replication_full_resend_interval() const { return m_replication_full_resend_interval; } void set_replication_full_resend_interval(double interval) { m_replication_full_resend_interval = interval; } private: void register_functions() override; double m_replication_full_resend_interval; }; net/include/net/index.hpp +4 −0 Original line number Diff line number Diff line #pragma once #include <com/context.hpp> #include <net/config.hpp> #include <net/driver.hpp> #include <net/replication_system.hpp> Loading @@ -14,6 +15,7 @@ namespace net { Driver* driver() const { return m_driver; } RPCSystem* rpc_system() const { return m_rpc_system; } ReplicationSystem* replication() const { return m_replication_system; } Config* config() const { return m_config; } private: Index(); Loading @@ -26,6 +28,7 @@ namespace net { Driver* m_driver; RPCSystem* m_rpc_system; ReplicationSystem* m_replication_system; Config* m_config; }; inline Index const& index() { return Index::instance(); } Loading @@ -34,4 +37,5 @@ namespace net { inline Driver* driver() { return index().driver(); } inline RPCSystem* rpc_system() { return index().rpc_system(); } inline ReplicationSystem* replication() { return index().replication(); } inline Config* config() { return index().config(); } } net/include/net/types.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ namespace net { com::Reflection::ValuePtr last_value; std::function<void(std::vector<com::Reflection::ValuePtr>& params)> getter_func; double time_since_last_send = 0.0; }; enum class PacketType : uint8_t Loading net/src/config.cpp 0 → 100644 +30 −0 Original line number Diff line number Diff line #include <net/config.hpp> Config::Config() : com::File(self_name()), m_replication_full_resend_interval(1.0) { } Config::~Config() = default; void Config::register_functions() { COM_REFLECTION_USINGS(); com::Reflection::register_function(this, { "set_replication_full_resend_interval", { TypeID::FLOAT }, false, [this](std::vector<ValuePtr>& params) -> void { set_replication_full_resend_interval(com::as<ValueFLOAT>(params[0])->value); } }); com::Reflection::register_function(this, { "get_replication_full_resend_interval", { TypeID::FLOAT }, false, [this](std::vector<ValuePtr>& params) -> void { com::as<ValueFLOAT>(params[0])->value = static_cast<float>(replication_full_resend_interval()); } }); } net/src/index.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -13,11 +13,13 @@ namespace net { , m_driver { m_root->find<Driver>(Driver::self_name()) } , m_rpc_system { m_root->find<RPCSystem>(RPCSystem::self_name()) } , m_replication_system { m_root->find<ReplicationSystem>(ReplicationSystem::self_name()) } , m_config { m_root->find<Config>(Config::self_name()) } { ASSUMPTION( m_driver != nullptr && m_rpc_system != nullptr && m_replication_system != nullptr m_replication_system != nullptr && m_config != nullptr ); } } No newline at end of file Loading
net/include/net/config.hpp 0 → 100644 +17 −0 Original line number Diff line number Diff line #pragma once #include <com/context.hpp> struct Config final : public com::File { static inline std::string self_name() { return "config"; } Config(); ~Config() override; double replication_full_resend_interval() const { return m_replication_full_resend_interval; } void set_replication_full_resend_interval(double interval) { m_replication_full_resend_interval = interval; } private: void register_functions() override; double m_replication_full_resend_interval; };
net/include/net/index.hpp +4 −0 Original line number Diff line number Diff line #pragma once #include <com/context.hpp> #include <net/config.hpp> #include <net/driver.hpp> #include <net/replication_system.hpp> Loading @@ -14,6 +15,7 @@ namespace net { Driver* driver() const { return m_driver; } RPCSystem* rpc_system() const { return m_rpc_system; } ReplicationSystem* replication() const { return m_replication_system; } Config* config() const { return m_config; } private: Index(); Loading @@ -26,6 +28,7 @@ namespace net { Driver* m_driver; RPCSystem* m_rpc_system; ReplicationSystem* m_replication_system; Config* m_config; }; inline Index const& index() { return Index::instance(); } Loading @@ -34,4 +37,5 @@ namespace net { inline Driver* driver() { return index().driver(); } inline RPCSystem* rpc_system() { return index().rpc_system(); } inline ReplicationSystem* replication() { return index().replication(); } inline Config* config() { return index().config(); } }
net/include/net/types.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ namespace net { com::Reflection::ValuePtr last_value; std::function<void(std::vector<com::Reflection::ValuePtr>& params)> getter_func; double time_since_last_send = 0.0; }; enum class PacketType : uint8_t Loading
net/src/config.cpp 0 → 100644 +30 −0 Original line number Diff line number Diff line #include <net/config.hpp> Config::Config() : com::File(self_name()), m_replication_full_resend_interval(1.0) { } Config::~Config() = default; void Config::register_functions() { COM_REFLECTION_USINGS(); com::Reflection::register_function(this, { "set_replication_full_resend_interval", { TypeID::FLOAT }, false, [this](std::vector<ValuePtr>& params) -> void { set_replication_full_resend_interval(com::as<ValueFLOAT>(params[0])->value); } }); com::Reflection::register_function(this, { "get_replication_full_resend_interval", { TypeID::FLOAT }, false, [this](std::vector<ValuePtr>& params) -> void { com::as<ValueFLOAT>(params[0])->value = static_cast<float>(replication_full_resend_interval()); } }); }
net/src/index.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -13,11 +13,13 @@ namespace net { , m_driver { m_root->find<Driver>(Driver::self_name()) } , m_rpc_system { m_root->find<RPCSystem>(RPCSystem::self_name()) } , m_replication_system { m_root->find<ReplicationSystem>(ReplicationSystem::self_name()) } , m_config { m_root->find<Config>(Config::self_name()) } { ASSUMPTION( m_driver != nullptr && m_rpc_system != nullptr && m_replication_system != nullptr m_replication_system != nullptr && m_config != nullptr ); } } No newline at end of file