26 #ifndef CLOE_CONTROLLER_HPP_ 27 #define CLOE_CONTROLLER_HPP_ 30 #include <type_traits> 50 #define DEFINE_CONTROLLER_FACTORY(xFactoryType, xConfigType, xName, xDescription) \ 51 class xFactoryType : public ::cloe::ControllerFactory { \ 53 xFactoryType() : ::cloe::ControllerFactory(xName, xDescription) {} \ 54 std::unique_ptr<::cloe::ControllerFactory> clone() const override { \ 55 return std::make_unique<std::decay<decltype(*this)>::type>(*this); \ 58 std::unique_ptr<::cloe::Controller> make(const ::cloe::Conf&) const override; \ 61 ::cloe::Schema schema_impl() override { return config_.schema(); } \ 64 xConfigType config_; \ 75 #define DEFINE_CONTROLLER_FACTORY_MAKE(xFactoryType, xControllerType) \ 76 std::unique_ptr<::cloe::Controller> xFactoryType::make(const ::cloe::Conf& c) const { \ 77 decltype(config_) conf{config_}; \ 78 if (!c->is_null()) { \ 81 return std::make_unique<xControllerType>(this->name(), conf); \ 138 virtual bool has_vehicle()
const {
return static_cast<bool>(veh_); }
146 virtual std::shared_ptr<Vehicle>
get_vehicle()
const {
return veh_; }
156 virtual void set_vehicle(std::shared_ptr<Vehicle> v) { veh_ = std::move(v); }
159 std::shared_ptr<Vehicle> veh_{
nullptr};
168 static constexpr
char const* PLUGIN_TYPE =
"controller";
169 static constexpr
char const* PLUGIN_API_VERSION =
"2.0";
174 using ModelFactory::ModelFactory;
189 virtual std::unique_ptr<ControllerFactory> clone()
const = 0;
197 virtual std::unique_ptr<Controller> make(
const Conf& c)
const = 0;
202 #endif // CLOE_CONTROLLER_HPP_
Definition: coordinator.hpp:36
virtual bool has_vehicle() const
Definition: controller.hpp:138
Definition: controller.hpp:166
virtual std::shared_ptr< Vehicle > get_vehicle() const
Definition: controller.hpp:146
Definition: model.hpp:414
Definition: model.hpp:214
virtual void set_vehicle(std::shared_ptr< Vehicle > v)
Definition: controller.hpp:156
Definition: controller.hpp:128