Granada  1.54.0
Structured layer on top of C++ REST SDK for building server applications in C++. Granada implements sessions, server side plug-in framework, C++ OAuth 2.0 server, data storage access, server script running, server browsing.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Protected Attributes | List of all members
granada::FunctionsMap Class Reference

#include <functions.h>

Inheritance diagram for granada::FunctionsMap:
granada::Functions

Public Member Functions

 FunctionsMap ()
 
virtual ~FunctionsMap ()
 
virtual bool Has (const std::string &name)
 
virtual void Add (const std::string &name, function_json_json fn)
 
virtual void Remove (const std::string &name)
 
virtual function_json_json Get (const std::string &name)
 
virtual function_json_json operator[] (const std::string &name)
 
virtual void Call (const std::string &name, const web::json::value &parameters, function_void_json callback)
 
virtual void Call (const std::string &name, const web::json::value &parameters)
 
virtual void Call (const std::string &name, function_void_json callback)
 
virtual void Call (const std::string &name)
 
virtual void CallAll (const web::json::value &parameters, function_void_json callback)
 
virtual void CallAll (function_void_json callback)
 
virtual void CallAll (const web::json::value &parameters)
 
virtual void CallAll ()
 
virtual std::shared_ptr
< std::map< std::string,
function_json_json > > & 
GetAll ()
 
virtual std::mutex * GetMtx ()
 
virtual std::shared_ptr
< FunctionsIterator
make_iterator ()
 
- Public Member Functions inherited from granada::Functions
virtual ~Functions ()
 

Protected Attributes

std::mutex mtx_
 
std::shared_ptr< std::map
< std::string,
function_json_json > > 
functions_
 

Additional Inherited Members

- Static Protected Member Functions inherited from granada::Functions
static web::json::value UndefinedErrorFunction (const web::json::value &data)
 
static web::json::value DefaultParameters ()
 

Detailed Description

Functions collection, stored using a map as container.

Constructor & Destructor Documentation

granada::FunctionsMap::FunctionsMap ( )
inline

Constructor

virtual granada::FunctionsMap::~FunctionsMap ( )
inlinevirtual

Destructor

Member Function Documentation

virtual void granada::FunctionsMap::Add ( const std::string &  name,
function_json_json  fn 
)
virtual

Adds a function to the collection of functions, and identify it with a name so it can be called or removed by the given name. The name of a function is unique, if you add two functions with the same name, the last one will be the one present in the collection.

Parameters
nameName of the function
fnFunction.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::Call ( const std::string &  name,
const web::json::value &  parameters,
function_void_json  callback 
)
virtual

Calls a function from the collection with the given name identifier and with given parameters. After the function is called a callback function will be called with the return of the called function.

Parameters
nameName identifying the function.
parametersJSON to pass to the function to call.
callbackCallback function.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::Call ( const std::string &  name,
const web::json::value &  parameters 
)
virtual

Calls a function from the collection with the given name identifier and with given parameters.

Parameters
nameName identifying the function.
parametersJSON to pass to the function to call.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::Call ( const std::string &  name,
function_void_json  callback 
)
virtual

Calls a function from the collection with the given name identifier. After the function is called a callback function will be called with the return of the called function.

Parameters
nameName identifying the function.
callbackCallback function.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::Call ( const std::string &  name)
virtual

Calls a function from the collection with the given name identifier.

Parameters
nameName identifying the function.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::CallAll ( const web::json::value &  parameters,
function_void_json  callback 
)
virtual

Calls all functions from the collection with given parameters. After the function is called a callback function will be called with the returns of the called functions contained in a json object like: { "data": { "RemoveUserEntries" : { "data" : {"success":true} }, "RemoveUserClipboard" : { "data" : {"success":true} }, } }

Parameters
parametersJSON to pass to the functions.
callbackCallback function with a JSON array containing the returns of the functions.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::CallAll ( function_void_json  callback)
virtual

Calls all functions from the collection. After the function is called a callback function will be called with the returns of the called functions contained in a json object like: { "data": { "RemoveUserEntries" : { "data" : {"success":true} }, "RemoveUserClipboard" : { "data" : {"success":true} }, } }

Parameters
callbackCallback function with a JSON array containing the returns of the functions.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::CallAll ( const web::json::value &  parameters)
virtual

Calls all functions from the collection with given parameters.

Parameters
parametersJSON to pass to the functions.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::CallAll ( )
virtual

Calls all functions from the collection.

Reimplemented from granada::Functions.

virtual function_json_json granada::FunctionsMap::Get ( const std::string &  name)
virtual

Returns the function from the collection identified with given name. If function does not exist in the collection a function returning an JSON object : {"error":"undefined_function"} is returned.

Parameters
nameName of the function
Returns
function Function.

Reimplemented from granada::Functions.

virtual std::shared_ptr<std::map<std::string,function_json_json> >& granada::FunctionsMap::GetAll ( )
inlinevirtual

Returns a pointer to the map containing all the functions.

virtual std::mutex* granada::FunctionsMap::GetMtx ( )
inlinevirtual

Returns a pointer to the mutex.

virtual bool granada::FunctionsMap::Has ( const std::string &  name)
virtual

Return true if function with given name is in the collection and false if it is not.

Parameters
nameName of the function.
Returns
True if function with given name is in the collection and false if it is not.

Reimplemented from granada::Functions.

virtual std::shared_ptr<FunctionsIterator> granada::FunctionsMap::make_iterator ( )
virtual

Returns a function iterator to iterate over all the functions of the collection.

Reimplemented from granada::Functions.

virtual function_json_json granada::FunctionsMap::operator[] ( const std::string &  name)
virtual

Returns the function from the collection identified with given name. If function does not exist in the collection a function returning an JSON object : {"error":"undefined_function"} is returned.

Parameters
nameName of the function
Returns
function Function.

Reimplemented from granada::Functions.

virtual void granada::FunctionsMap::Remove ( const std::string &  name)
virtual

Removes function from the collection with given name.

Parameters
nameName of the function.

Reimplemented from granada::Functions.

Member Data Documentation

std::shared_ptr<std::map<std::string,function_json_json> > granada::FunctionsMap::functions_
protected

Map containing the functions and its identifying name.

std::mutex granada::FunctionsMap::mtx_
protected

Mutex for preventing multithread problems when accessign to the functions.


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