28template <
typename SmaccClientType>
33 storage =
dynamic_cast<SmaccClientType *
>(client.get());
34 if (storage !=
nullptr)
return true;
37 auto requiredClientName = demangledTypeName<SmaccClientType>();
41 <<
"] not found in current orthogonal. Searching in other orthogonals.");
45 for (
auto & client : orthoentry.second->getClients())
47 storage =
dynamic_cast<SmaccClientType *
>(client.get());
48 if (storage !=
nullptr)
52 "Required client [" << requiredClientName <<
"] found in other orthogonal.");
61 <<
"] not found even in other orthogonals. Returning null pointer. If the "
62 "requested client is used may result in a segmentation fault.");
66template <
typename SmaccComponentType>
73 "Cannot use the requiresComponent funcionality from an orthogonal before onInitialize");
81template <
typename TOrthogonal,
typename TClient>
85 client->setOrthogonal(
this);
87 client->template onOrthogonalAllocation<TOrthogonal, TClient>();
90template <
typename TClientBehavior>
96 auto * ret =
dynamic_cast<TClientBehavior *
>(cb.get());
113inline const std::vector<std::vector<std::shared_ptr<smacc2::ISmaccClientBehavior>>> &
134template <
typename TOrthogonal,
typename TClient>
138 template <
typename... TArgs>
145 template <
typename SmaccComponentType,
typename... TArgs>
152 template <
typename SmaccComponentType,
typename... TArgs>
161 return smacc2::introspection::TypeInfo::getTypeInfoFromType<TClient>();
165template <
typename TOrthogonal>
169 template <
typename TClient,
typename... TArgs>
170 std::shared_ptr<ClientHandler<TOrthogonal, TClient>>
createClient(TArgs... args)
180 getLogger(),
"[%s] creating client object, type:'%s' object tag: '%s'",
181 demangleType(
typeid(*
this)).c_str(), demangledTypeName<TClient>().c_str(),
182 demangledTypeName<TOrthogonal>().c_str());
184 auto client = std::make_shared<ClientHandler<TOrthogonal, TClient>>(args...);
185 this->
template assignClientToOrthogonal<TOrthogonal, TClient>(client.get());
ClientHandler(TArgs... args)
smacc2::introspection::TypeInfo::Ptr getType() override
SmaccComponentType * createComponent(TArgs... targs)
SmaccComponentType * createNamedComponent(std::string name, TArgs... targs)
SmaccComponentType * createNamedComponent(std::string name, TArgs... targs)
SmaccComponentType * createComponent(TArgs... targs)
ISmaccStateMachine * getStateMachine()
void setGlobalSMData(std::string name, T value)
bool getGlobalSMData(std::string name, T &ret)
rclcpp::Logger getLogger()
void requiresComponent(SmaccComponentType *&storage)
std::vector< std::shared_ptr< smacc2::ISmaccClient > > clients_
ISmaccStateMachine * stateMachine_
bool requiresClient(SmaccClientType *&storage)
void assignClientToOrthogonal(TClient *client)
std::vector< std::vector< std::shared_ptr< smacc2::ISmaccClientBehavior > > > clientBehaviors_
const std::vector< std::vector< std::shared_ptr< smacc2::ISmaccClientBehavior > > > & getClientBehaviors() const
TClientBehavior * getClientBehavior(int index=0)
const std::vector< std::shared_ptr< smacc2::ISmaccClient > > & getClients()
bool getGlobalSMData(std::string name, T &ret)
void setGlobalSMData(std::string name, T value)
void requiresComponent(SmaccComponentType *&storage, bool throwsException=false)
std::shared_ptr< ClientHandler< TOrthogonal, TClient > > createClient(TArgs... args)
std::shared_ptr< TypeInfo > Ptr
std::string demangleType(const std::type_info *tinfo)