32 #include <type_traits>
55 #define DEFINE_COMPONENT_FACTORY(xFactoryType, xConfigType, xName, xDescription) \
56 class xFactoryType : public ::cloe::ComponentFactory { \
58 xFactoryType() : ComponentFactory(xName, xDescription) {} \
59 std::unique_ptr<::cloe::ComponentFactory> clone() const override { \
60 return std::make_unique<std::decay<decltype(*this)>::type>(*this); \
62 std::unique_ptr<::cloe::Component> make( \
63 const ::fable::Conf&, std::vector<std::shared_ptr<::cloe::Component>>) const override; \
66 ::cloe::Schema schema_impl() override { return config_.schema(); } \
69 xConfigType config_; \
81 #define DEFINE_COMPONENT_FACTORY_MAKE(xFactoryType, xComponentType, xInputType) \
82 std::unique_ptr<::cloe::Component> xFactoryType::make( \
83 const ::fable::Conf& c, std::vector<std::shared_ptr<::cloe::Component>> comp) const { \
84 decltype(config_) conf{config_}; \
85 assert(comp.size() == 1); \
86 if (!c->is_null()) { \
89 return std::make_unique<xComponentType>( \
90 this->name(), conf, std::dynamic_pointer_cast<xInputType>(std::move(comp.front()))); \
158 uint64_t
id()
const {
return id_; }
165 template <
typename T>
167 return dynamic_cast<T*
>(
this);
197 j[
"name"] = c.
name();
201 static uint64_t gid_;
211 static constexpr
char const* PLUGIN_TYPE =
"component";
212 static constexpr
char const* PLUGIN_API_VERSION =
"2.0";
217 using ModelFactory::ModelFactory;
232 virtual std::unique_ptr<ComponentFactory>
clone()
const = 0;
241 std::vector<std::shared_ptr<Component>>)
const = 0;
Definition: component.hpp:209
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:143
uint64_t id() const
Definition: component.hpp:158
T * as()
Definition: component.hpp:166
Duration process(const Sync &sync) override
Definition: component.hpp:181
virtual fable::Json active_state() const =0
void abort() override
Definition: component.hpp:191
void reset() override
Definition: component.hpp:186
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