ReCodEx - Task Broker
ReCodEx is complex programmer testing solution, primary targeted to technical universities. It's highly customizable and based on modern technologies.
command_holder Class Reference

#include <command_holder.h>

Public Types

typedef std::function< void(const std::string &, const std::vector< std::string > &, handler_interface::response_cb)> callback_fn
 

Public Member Functions

void call_function (const std::string &command, const std::string &identity, const std::vector< std::string > &message, handler_interface::response_cb respond)
 
bool register_command (const std::string &command, callback_fn callback)
 

Detailed Description

Command holder.

This class can handle, register and execute commands with corresponding callbacks. Command is std::string, callback is a function with signature corresponding to command_holder::callback_fn

Definition at line 22 of file command_holder.h.

Member Typedef Documentation

§ callback_fn

typedef std::function<void(const std::string &, const std::vector<std::string> &, handler_interface::response_cb)> command_holder::callback_fn

Type of callback function for easier use.

Definition at line 27 of file command_holder.h.

Member Function Documentation

§ call_function()

void command_holder::call_function ( const std::string &  command,
const std::string &  identity,
const std::vector< std::string > &  message,
handler_interface::response_cb  respond 
)

Invoke registered callback for given command (if any).

Parameters
commandString reprezentation of command for processing.
identityUnique ID of each worker for connection subsystem.
messageArguments for callback function.
responda callback to let the handler respond

Definition at line 3 of file command_holder.cpp.

§ register_command()

bool command_holder::register_command ( const std::string &  command,
command_holder::callback_fn  callback 
)

Register new command with a callback.

Parameters
commandString reprezentation of command.
callbackFunction to call when this command occurs.
Returns
true if add successful, false othewise

Definition at line 14 of file command_holder.cpp.


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