$darkmode
cloe::Registrar Class Referenceabstract

#include <registrar.hpp>

Inheritance diagram for cloe::Registrar:

Public Member Functions

virtual void register_static_handler (const std::string &endpoint, Handler)=0
 
virtual void register_api_handler (const std::string &endpoint, HandlerType, Handler)=0
 
virtual std::unique_ptr< Registrarwith_api_prefix (const std::string &prefix) const =0
 
virtual std::unique_ptr< Registrarwith_static_prefix (const std::string &prefix) const =0
 
virtual std::unique_ptr< Registrarwith_trigger_prefix (const std::string &prefix) const =0
 
virtual void register_action (std::unique_ptr< ActionFactory > &&)=0
 
virtual DataBrokerdata_broker () const =0
 
template<typename F , typename... Ctx>
void register_action (Ctx &&... ctx)
 
virtual void register_event (std::unique_ptr< EventFactory > &&f, std::shared_ptr< Callback > c)=0
 
virtual sol::table register_lua_table ()=0
 
template<typename F , typename... Ctx>
DirectCallbackPtr< typename F::EventType, Ctx... > register_event (std::unique_ptr< F > &&f)
 
template<typename F , typename... Ctx, typename... Args>
DirectCallbackPtr< typename F::EventType, Ctx... > register_event (Args... args)
 

Detailed Description

Registrar is passed to controllers and simulators to allow them to register action factories as well as web handlers.

Note that a Registrar may modify the key or endpoint that you provide.

Member Function Documentation

◆ register_action() [1/2]

template<typename F , typename... Ctx>
void cloe::Registrar::register_action ( Ctx &&...  ctx)
inline

Construct and register an ActionFactory.

This replaces what otherwise would be a very common pattern:

r.register_action(std::make_unique<F>(args...));

with:

r.register_action<F>(args...);

Here is the call graph for this function:

◆ register_action() [2/2]

virtual void cloe::Registrar::register_action ( std::unique_ptr< ActionFactory > &&  )
pure virtual

Register an ActionFactory.

Here is the caller graph for this function:

◆ register_api_handler()

virtual void cloe::Registrar::register_api_handler ( const std::string &  endpoint,
HandlerType  ,
Handler   
)
pure virtual

Register a web handler that can be accessed at the given endpoint.

Currently, the endpoint should be a valid static path, starting with a slash "/". The root represents whatever receives the Registrar, e.g., the controller or simulator. Any endpoint registered will be prefixed to ensure identifiability.

Implemented in engine::Registrar.

Here is the caller graph for this function:

◆ register_event() [1/3]

template<typename F , typename... Ctx, typename... Args>
DirectCallbackPtr<typename F::EventType, Ctx...> cloe::Registrar::register_event ( Args...  args)
inline

Construct and register an EventFactory and return a DirectCallback for storage of events.

This replaces what otherwise would be a common pattern:

r.register_event<F, Ctx...>(std::make_unique<F, Args...>(args...));

with:

r.register_event<F, Ctx...>(args...);

Here is the call graph for this function:

◆ register_event() [2/3]

virtual void cloe::Registrar::register_event ( std::unique_ptr< EventFactory > &&  f,
std::shared_ptr< Callback c 
)
pure virtual

Register an EventFactory.

The Callback is shared by the Registrar and the "Originator" that registers the event. The Registrar owner places triggers with the corresponding event into the callback, which the Originator can trigger when the event occurs.

See also
cloe/trigger.hpp
Here is the caller graph for this function:

◆ register_event() [3/3]

template<typename F , typename... Ctx>
DirectCallbackPtr<typename F::EventType, Ctx...> cloe::Registrar::register_event ( std::unique_ptr< F > &&  f)
inline

Register an EventFactory and return a DirectCallback for storage of events.

Here is the call graph for this function:

◆ register_lua_table()

virtual sol::table cloe::Registrar::register_lua_table ( )
pure virtual

Provide a Lua table for registration of functions and variables.

Implemented in engine::Registrar.

Here is the caller graph for this function:

◆ register_static_handler()

virtual void cloe::Registrar::register_static_handler ( const std::string &  endpoint,
Handler   
)
pure virtual

Register a static web handler that can be given at the endpoint.

Currently, the endpoint should be a valid static path, starting with a slash "/". The root represents whatever receives the Registrar, e.g., the controller or simulator. Any endpoint registered will be prefixed to ensure identifiability.

Implemented in engine::Registrar.

◆ with_api_prefix()

virtual std::unique_ptr<Registrar> cloe::Registrar::with_api_prefix ( const std::string &  prefix) const
pure virtual

Return a new Registrar with the given static handler prefix.

The returned object should remain valid even if the object creating it is destroyed.

Implemented in engine::Registrar.

◆ with_static_prefix()

virtual std::unique_ptr<Registrar> cloe::Registrar::with_static_prefix ( const std::string &  prefix) const
pure virtual

Return a new Registrar with the given dynamic handler prefix.

The returned object should remain valid even if the object creating it is destroyed.

Implemented in engine::Registrar.

◆ with_trigger_prefix()

virtual std::unique_ptr<Registrar> cloe::Registrar::with_trigger_prefix ( const std::string &  prefix) const
pure virtual

Return a new Registrar with the given trigger prefix.

The returned object should remain valid even if the object creating it is destroyed.

Implemented in engine::Registrar.


The documentation for this class was generated from the following file: