32 #include <type_traits>
39 #include <cloe/version.hpp>
56 #define DEFINE_COMPONENT_FACTORY(xFactoryType, xConfigType, xName, xDescription) \
57 class xFactoryType : public ::cloe::ComponentFactory { \
59 xFactoryType() : ComponentFactory(xName, xDescription) {} \
60 std::unique_ptr<::cloe::ComponentFactory> clone() const override { \
61 return std::make_unique<std::decay<decltype(*this)>::type>(*this); \
63 std::unique_ptr<::cloe::Component> make( \
64 const ::fable::Conf&, std::vector<std::shared_ptr<::cloe::Component>>) const override; \
67 ::cloe::Schema schema_impl() override { return config_.schema(); } \
70 xConfigType config_; \
82 #define DEFINE_COMPONENT_FACTORY_MAKE(xFactoryType, xComponentType, xInputType) \
83 std::unique_ptr<::cloe::Component> xFactoryType::make( \
84 const ::fable::Conf& c, std::vector<std::shared_ptr<::cloe::Component>> comp) const { \
85 decltype(config_) conf{config_}; \
86 assert(comp.size() == 1); \
87 if (!c->is_null()) { \
90 return std::make_unique<xComponentType>( \
91 this->name(), conf, std::dynamic_pointer_cast<xInputType>(std::move(comp.front()))); \
159 uint64_t
id()
const {
return id_; }
166 template <
typename T>
168 return dynamic_cast<T*
>(
this);
198 j[
"name"] = c.
name();
202 static uint64_t gid_;
212 static constexpr
char const* PLUGIN_TYPE =
"component";
213 static constexpr
char const* PLUGIN_API_VERSION =
"2.0";
218 using ModelFactory::ModelFactory;
233 virtual std::unique_ptr<ComponentFactory>
clone()
const = 0;
242 std::vector<std::shared_ptr<Component>>)
const = 0;
Definition: component.hpp:210
virtual std::unique_ptr< ComponentFactory > clone() const =0
virtual std::unique_ptr< Component > make(const fable::Conf &c, std::vector< std::shared_ptr< Component >>) const =0
Definition: component.hpp:144
uint64_t id() const
Definition: component.hpp:159
T * as()
Definition: component.hpp:167
Duration process(const Sync &sync) override
Definition: component.hpp:182
virtual fable::Json active_state() const =0
void abort() override
Definition: component.hpp:192
void reset() override
Definition: component.hpp:187
const std::string & description() const
Definition: entity.hpp:90
const std::string & name() const
Definition: entity.hpp:67
Definition: model.hpp:403
Definition: model.hpp:203
virtual Duration time() const =0
std::chrono::nanoseconds Duration
Definition: cloe_fwd.hpp:36
nlohmann::json Json
Definition: fable_fwd.hpp:35