28 #ifndef CLOE_COMPONENT_HPP_ 29 #define CLOE_COMPONENT_HPP_ 34 #include <type_traits> 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 ::cloe::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 ::cloe::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);
195 friend void to_json(Json& j,
const Component& c) {
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;
241 virtual std::unique_ptr<Component> make(
const Conf& c,
242 std::vector<std::shared_ptr<Component>>)
const = 0;
247 #endif // CLOE_COMPONENT_HPP_
uint64_t id() const
Definition: component.hpp:159
virtual Duration time() const =0
T * as()
Definition: component.hpp:167
Definition: coordinator.hpp:36
Duration process(const Sync &sync) override
Definition: component.hpp:182
std::chrono::nanoseconds Duration
Definition: duration.hpp:45
Definition: component.hpp:210
virtual Json active_state() const =0
void abort() override
Definition: component.hpp:192
std::string name() const
Definition: entity.hpp:68
Definition: component.hpp:144
std::string description() const
Definition: entity.hpp:91
Definition: model.hpp:414
Definition: model.hpp:214
void reset() override
Definition: component.hpp:187