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 | Static Protected Member Functions | List of all members
granada::Functions Class Reference

#include <functions.h>

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

Public Member Functions

virtual ~Functions ()
 
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
< FunctionsIterator
make_iterator ()
 

Static Protected Member Functions

static web::json::value UndefinedErrorFunction (const web::json::value &data)
 
static web::json::value DefaultParameters ()
 

Detailed Description

Interface for managing functions collections. Manages a function collection in memory, can add and remove functions identified with a string name and call them by their name or call them all at once. The functions accept a json value as parameter and return a json value.

Constructor & Destructor Documentation

virtual granada::Functions::~Functions ( )
inlinevirtual

Destructor

Member Function Documentation

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

Adds a function to the collection.

Parameters
nameName of the function.
fnFunction.

Reimplemented in granada::FunctionsMap.

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

Calls a function by its name passing a json value as parameters to the called function, accepts a callback to get the value returned by the called function.

Parameters
nameName of the function to call.
parametersParameters in form of json value to pass to the called function.
callbackCallback function to get the value returned by the called function. Function with JSON as a parameter.

Reimplemented in granada::FunctionsMap.

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

Calls a function by its name passing a json value as parameters to the called function.

Parameters
nameName of the function to call.
parametersParameters in form of json value to pass to the called function.

Reimplemented in granada::FunctionsMap.

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

Calls a function by its name, accepts a callback to get the value returned by the called function.

Parameters
nameName of the function to call.
callbackCallback function to get the value returned by the called function. Function with JSON as a parameter.

Reimplemented in granada::FunctionsMap.

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

Calls a function by its name.

Parameters
nameName of the function to call.

Reimplemented in granada::FunctionsMap.

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

Calls all functions of the collection passing a json value as parameters to the called functions, accepts a callback to get the values returned by the called functions. The values returned by the functions will be structured in a json object and passed through the callback parameters like this: { "data": { "RemoveUserEntries" : { "data" : {"success":true} }, "RemoveUserClipboard" : { "data" : {"success":true} }, } }

Parameters
nameName of the function to call.
parametersParameters in form of json value to pass to the called function.
callbackCallback function to get the value returned by the called function. Function with JSON as a parameter.

Reimplemented in granada::FunctionsMap.

virtual void granada::Functions::CallAll ( function_void_json  callback)
inlinevirtual

Calls all functions of the collection accepts a callback to get the values returned by the called functions. The values returned by the functions will be structured in a json object and passed through the callback parameters like this: { "data": { "RemoveUserEntries" : { "data" : {"success":true} }, "RemoveUserClipboard" : { "data" : {"success":true} }, } }

Parameters
callbackCallback function to get the value returned by the called function. Function with JSON as a parameter.

Reimplemented in granada::FunctionsMap.

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

Calls all functions of the collection passing a json value as parameters to the called functions.

Parameters
parametersJSON value containing the parameters to pass to the called functions.

Reimplemented in granada::FunctionsMap.

virtual void granada::Functions::CallAll ( )
inlinevirtual

Calls all functions of the collection.

Reimplemented in granada::FunctionsMap.

static web::json::value granada::Functions::DefaultParameters ( )
inlinestaticprotected

JSON used as the called function default parameters in case the user does not specify them.

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

Returns a function with given name.

Parameters
nameName of the function.
Returns
Function with JSON as a parameter and that returns a JSON.

Reimplemented in granada::FunctionsMap.

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

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 in granada::FunctionsMap.

virtual std::shared_ptr<FunctionsIterator> granada::Functions::make_iterator ( )
inlinevirtual

Returns an iterator to iterate over the functions of the collection.

Returns
Iterator to iterate over the functions of the collection.

Reimplemented in granada::FunctionsMap.

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

Returns a function with given name.

Parameters
nameName of the function.
Returns
Function with JSON as a parameter and that returns a JSON.

Reimplemented in granada::FunctionsMap.

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

Removes function with given name from the collection.

Parameters
nameName of the function.

Reimplemented in granada::FunctionsMap.

static web::json::value granada::Functions::UndefinedErrorFunction ( const web::json::value &  data)
inlinestaticprotected

Function used to tell the user the function he/she is trying to call does not exist.


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