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

#include <plugin.h>

Inheritance diagram for granada::plugin::Plugin:
granada::plugin::SpidermonkeyPlugin granada::plugin::MapSpidermonkeyPlugin granada::plugin::RedisSpidermonkeyPlugin

Public Member Functions

 Plugin ()
 
 Plugin (granada::plugin::PluginHandler *plugin_handler, const std::string id)
 
 Plugin (granada::plugin::PluginHandler *plugin_handler, const web::json::value header, const web::json::value configuration, const std::string script)
 
virtual ~Plugin ()
 
virtual bool Exists ()
 
virtual void IsExtended (bool extended)
 
virtual const bool IsExtended ()
 
virtual const std::string GetId ()
 
virtual void SetId (const std::string id)
 
virtual const web::json::value & GetHeader ()
 
virtual void SetHeader (const web::json::value header)
 
virtual std::string GetScript ()
 
virtual void SetScript (const std::string script)
 
virtual const web::json::value & GetConfiguration ()
 
virtual const web::json::value & SetConfiguration (const web::json::value configuration)
 
const bool & IsRunnable ()
 
void IsRunnable (bool runnable)
 

Protected Member Functions

virtual void LoadProperties ()
 
virtual
granada::plugin::PluginHandler
plugin_handler ()
 

Protected Attributes

std::string id_
 
web::json::value header_
 
std::string script_
 
web::json::value configuration_
 
bool runnable_ = true
 

Static Protected Attributes

static std::once_flag properties_flag_
 

Detailed Description

Extension of the server application. Plug-ins can also extend other plug-ins. Not all of them may be executed, some can just have useful functions or wait to be extended by others. They can communicate.

Constructor & Destructor Documentation

granada::plugin::Plugin::Plugin ( )
inline

Constructor.

granada::plugin::Plugin::Plugin ( granada::plugin::PluginHandler plugin_handler,
const std::string  id 
)
inline

Constructor. Loads Plug-in properties from server configuration file.

Parameters
plugin_handlerPlug-in Handler.
idId of the Plug-in.
granada::plugin::Plugin::Plugin ( granada::plugin::PluginHandler plugin_handler,
const web::json::value  header,
const web::json::value  configuration,
const std::string  script 
)
inline

Constructor. Loads Plug-in properties from server configuration file.

Parameters
plugin_handlerPlug-in Handler that manages the plug-in.
headerPlug-in header is a JSON object that contains information as plug-in id, events, inheritance.
configurationJSON object containing the configuration of a plugin. Example:
{
"factor":5,
"url_to_check":"https://cookinapps.io"
}
scriptScript/Executable or Path of the file containing the script or the executable.
virtual granada::plugin::Plugin::~Plugin ( )
inlinevirtual

Destructor

Member Function Documentation

virtual bool granada::plugin::Plugin::Exists ( )
virtual

Returns true if the plug-in exists in the cache, false if it does not.

Returns
True if plug-in is cached, false if it is not.
virtual const web::json::value& granada::plugin::Plugin::GetConfiguration ( )
inlinevirtual

Returns the plug-in configuration.

Returns
JSON object with the plug-in configuration.
virtual const web::json::value& granada::plugin::Plugin::GetHeader ( )
inlinevirtual

Returns plug-in header. Plug-in header is a JSON object containing basic information about the plug-in such as plug-in id, events and what plug-in it extends. Example of header:

{
"id" : "betterworddefinition.word-filter",
"events" : ["load-text-after","load-description-after"],
"extends" : ["worddefinition.word-filter"]
}
Returns
Plug-in header.
virtual const std::string granada::plugin::Plugin::GetId ( )
inlinevirtual

Returns the plug-in id.

Returns
Plug-in id.
virtual std::string granada::plugin::Plugin::GetScript ( )
inlinevirtual

Returns the plug-in script/executable or plug-in script path or plug-in executable path.

Returns
Plug-in script/executable or plug-in script path or plug-in executable path.
virtual void granada::plugin::Plugin::IsExtended ( bool  extended)
virtual

Sets the boolean value of extended, true if the plug-in has been extended by others. false if the plug-in has not already been extended by others. Normally extended plug-ins won't run anymore, so this flag is used to know if a plug-in is somekind active | inactive.

Parameters
extendedTrue if the plug-in has been extended by others. False if the plug-in has not already been extended by others.
virtual const bool granada::plugin::Plugin::IsExtended ( )
virtual

Returns true if the plug-in has been extended by others. false if the plug-in has not already been extended by others. Normally extended plug-ins won't run anymore, so this flag is used to know if a plug-in is somekind active | inactive.

Returns
True if the plug-in has been extended by others. False if the plug-in has not already been extended by others.
const bool& granada::plugin::Plugin::IsRunnable ( )
inline

Returns true if plug-in is runnable, and false if it is not.

Returns
True if plug-in is runnable, and false if it is not.
void granada::plugin::Plugin::IsRunnable ( bool  runnable)
inline

Sets the runnable status of a plug-in. Set it to true if plug-in is runnable, and false if it is not.

Parameters
runnableRunnable status of a plug-in. True if plug-in is runnable, and false if it is not.
virtual void granada::plugin::Plugin::LoadProperties ( )
inlineprotectedvirtual

Load Plug-in properties. Normally called once, as the properties are statics shared by all plug-ins.

virtual granada::plugin::PluginHandler* granada::plugin::Plugin::plugin_handler ( )
inlineprotectedvirtual

Returns the Plug-in Handler that manages the lifecycle of the plug-in.

Returns
Plug-in Handler that manages the lifecycle of the plug-in.

Reimplemented in granada::plugin::MapSpidermonkeyPlugin, and granada::plugin::RedisSpidermonkeyPlugin.

virtual const web::json::value& granada::plugin::Plugin::SetConfiguration ( const web::json::value  configuration)
inlinevirtual

Returns the plug-in configuration.

Parameters
JSONobject with the plug-in configuration.
virtual void granada::plugin::Plugin::SetHeader ( const web::json::value  header)
inlinevirtual

Set plug-in header. Plug-in header is a JSON object containing basic information about the plug-in such as plug-in id, events and what plug-in it extends.

Parameters
headerJSON object containing the header parameters. Example of header:
{
"id" : "betterworddefinition.word-filter",
"events" : ["load-text-after","load-description-after"],
"extends" : ["worddefinition.word-filter"]
}
virtual void granada::plugin::Plugin::SetId ( const std::string  id)
inlinevirtual

Sets the plug-in id.

Parameters
Plug-inid.
virtual void granada::plugin::Plugin::SetScript ( const std::string  script)
inlinevirtual

Sets the plug-in script/executable or plug-in script path or plug-in executable path.

Parameters
Plug-inscript/executable or plug-in script path or plug-in executable path.

Member Data Documentation

web::json::value granada::plugin::Plugin::configuration_
protected

Plug-in configuration is a JSON object containing the plug-in properties and values needed during the plug-in runtime influencing the plug-in behavior. Example of plug-in configuration:

{
"url_to_scrap" : "https://cookinapps.io",
"maximum_execution_time" : 3600,
"output_directory" : "user/output/directory"
}
web::json::value granada::plugin::Plugin::header_
protected

Plug-in header is a JSON object containing basic information about the plug-in such as plug-in id, events, what plug-in it extends and plug-in loader. Example of header:

{
"id" : "betterworddefinition.word-filter",
"events" : ["load-text-after","load-description-after"],
"extends" : ["worddefinition.word-filter"],
"loader" : {}
}
std::string granada::plugin::Plugin::id_
protected

String Plug-in id unique identifier. Normally composed of the name of the package + the name of the plug-in with a dot as separator. Name of the plug-ins should be descriptives. Example:

math.square
math.multiplication
std::once_flag granada::plugin::Plugin::properties_flag_
staticprotected

Once flag used for loading plug-in properties only once.

bool granada::plugin::Plugin::runnable_ = true
protected

Runnable status of a plug-in. True if plug-in is runnable, and false if it is not.

std::string granada::plugin::Plugin::script_
protected

Script/executable to execute, can be a sript or a path to a script or a path to an executable.


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