Blue Brain BioExplorer
core::ActionInterface Class Referenceabstract

#include <ActionInterface.h>

Inheritance diagram for core::ActionInterface:

Public Member Functions

virtual ~ActionInterface ()=default
 
virtual void registerNotification (const RpcDescription &desc, const std::function< void()> &action)=0
 
virtual void registerNotification (const RpcParameterDescription &desc, const PropertyMap &input, const std::function< void(PropertyMap)> &action)=0
 
virtual void registerRequest (const RpcParameterDescription &desc, const PropertyMap &input, const PropertyMap &output, const std::function< PropertyMap(PropertyMap)> &action)=0
 
virtual void registerRequest (const RpcDescription &desc, const PropertyMap &output, const std::function< PropertyMap()> &action)=0
 
void registerNotification (const std::string &name, const std::function< void()> &action)
 
template<typename Params >
void registerNotification (const std::string &name, const std::function< void(Params)> &action)
 
template<typename Params , typename RetVal >
void registerRequest (const std::string &name, const std::function< RetVal(Params)> &action)
 
template<typename RetVal >
void registerRequest (const std::string &name, const std::function< RetVal()> &action)
 

Protected Types

using RetParamFunc = std::function< std::string(std::string)>
 
using RetFunc = std::function< std::string()>
 
using ParamFunc = std::function< void(std::string)>
 
using VoidFunc = std::function< void()>
 

Detailed Description

Interface for registering actions, namely notifications which have no return values with an optional parameter, and requests which return a value after processing.

The encoding of the parameter and return value is restricted to JSON.

The parameters object must be deserializable by a free function:

bool from_json(Params& object, const std::string& json)
bool from_json(T &obj, const std::string &json, PRE preUpdateFunc=[] {}, POST postUpdateFunc=[] {})

The return type must be serializable by a free function:

std::string to_json(const RetVal&)
std::string to_json(const core::PropertyMap &obj)

Definition at line 48 of file ActionInterface.h.

Member Typedef Documentation

◆ ParamFunc

using core::ActionInterface::ParamFunc = std::function<void(std::string)>
protected

Definition at line 137 of file ActionInterface.h.

◆ RetFunc

using core::ActionInterface::RetFunc = std::function<std::string()>
protected

Definition at line 136 of file ActionInterface.h.

◆ RetParamFunc

using core::ActionInterface::RetParamFunc = std::function<std::string(std::string)>
protected

Definition at line 135 of file ActionInterface.h.

◆ VoidFunc

using core::ActionInterface::VoidFunc = std::function<void()>
protected

Definition at line 138 of file ActionInterface.h.

Constructor & Destructor Documentation

◆ ~ActionInterface()

virtual core::ActionInterface::~ActionInterface ( )
virtualdefault

Member Function Documentation

◆ registerNotification() [1/4]

virtual void core::ActionInterface::registerNotification ( const RpcDescription desc,
const std::function< void()> &  action 
)
pure virtual

Register an action with no parameter and no return value.

Parameters
descdescription of the action/RPC
actionthe action to perform on an incoming notification

Implemented in core::RocketsPlugin::Impl.

◆ registerNotification() [2/4]

virtual void core::ActionInterface::registerNotification ( const RpcParameterDescription desc,
const PropertyMap input,
const std::function< void(PropertyMap)> &  action 
)
pure virtual

Register an action with a property map as the parameter and no return value.

Parameters
descdescription of the action/RPC
inputthe acceptable property map as the parameter for the RPC
actionthe action to perform on an incoming notification

Implemented in core::RocketsPlugin::Impl.

◆ registerNotification() [3/4]

void core::ActionInterface::registerNotification ( const std::string &  name,
const std::function< void()> &  action 
)
inline

Register an action with no parameter and no return value.

Definition at line 98 of file ActionInterface.h.

◆ registerNotification() [4/4]

template<typename Params >
void core::ActionInterface::registerNotification ( const std::string &  name,
const std::function< void(Params)> &  action 
)
inline

Register an action with a parameter and no return value.

Definition at line 105 of file ActionInterface.h.

◆ registerRequest() [1/4]

virtual void core::ActionInterface::registerRequest ( const RpcDescription desc,
const PropertyMap output,
const std::function< PropertyMap()> &  action 
)
pure virtual

Register an action with no parameter and a property map as the return value.

Parameters
descdescription of the action/RPC
outputthe property map layout that is returned on a successful request
actionthe action to perform on an incoming request

Implemented in core::RocketsPlugin::Impl.

◆ registerRequest() [2/4]

virtual void core::ActionInterface::registerRequest ( const RpcParameterDescription desc,
const PropertyMap input,
const PropertyMap output,
const std::function< PropertyMap(PropertyMap)> &  action 
)
pure virtual

Register an action with a property map as the parameter and a property map as the return value.

Parameters
descdescription of the action/RPC
inputthe acceptable property map as the parameter for the RPC
outputthe property map layout that is returned on a successful request
actionthe action to perform on an incoming request

Implemented in core::RocketsPlugin::Impl.

◆ registerRequest() [3/4]

template<typename RetVal >
void core::ActionInterface::registerRequest ( const std::string &  name,
const std::function< RetVal()> &  action 
)
inline

Register an action with no parameter and a return value.

Definition at line 129 of file ActionInterface.h.

◆ registerRequest() [4/4]

template<typename Params , typename RetVal >
void core::ActionInterface::registerRequest ( const std::string &  name,
const std::function< RetVal(Params)> &  action 
)
inline

Register an action with a parameter and a return value.

Definition at line 117 of file ActionInterface.h.


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