CppCMS
Public Member Functions | Static Public Member Functions | List of all members
cppcms::plugin::scope Class Reference

#include <cppcms/plugin.h>

Public Member Functions

 scope ()
 
 ~scope ()
 
 scope (int argc, char **argv)
 
 scope (json::value const &value)
 
void paths (std::vector< std::string > const &paths)
 Set search path for plugins if undefined search according to the OS rules, if one of the paths in the vector is empty the search is performed by. More...
 
void shared_object_pattern (std::string const &pattern)
 
void load (std::string const &module)
 
booster::shared_object const & get (std::string const &module) const
 
bool is_loaded_by_this_scope (std::string const &module) const
 

Static Public Member Functions

static bool is_loaded (std::string const &module)
 

Detailed Description

Class that esures that plugin is loaded and unloads it in destructor if needed

Note: it tracks the loaded plugins by its name globally such that if another scope had loaded the plugin it wouldn't be loaded again.

It is useable when plugin should be used outside of life scope of cppcms::service

CppCMS configuration:

New in CppCMS 1.2

Constructor & Destructor Documentation

cppcms::plugin::scope::scope ( )

Create an empty scope

cppcms::plugin::scope::~scope ( )

Unloads all loaded plugins

cppcms::plugin::scope::scope ( int  argc,
char **  argv 
)

Loads the plugins provided in main cppcms configuration file - argc,argv are same parameters as for cppcms::service constructor

cppcms::plugin::scope::scope ( json::value const &  value)

Loads the plugins provided in main cppcms configuration json file - same parameters as for cppcms::service constructor

Member Function Documentation

booster::shared_object const& cppcms::plugin::scope::get ( std::string const &  module) const

Get shared object loading withing this scope. If it wasn't loaded withing this scope throws cppcms_error

static bool cppcms::plugin::scope::is_loaded ( std::string const &  module)
static

Check if the module was loaded withing any of the scopes - note it is static member function

bool cppcms::plugin::scope::is_loaded_by_this_scope ( std::string const &  module) const

Check if module is loaded withing this scope, unlike is_loaded that checks for the module globally, it refers to this scope only

void cppcms::plugin::scope::load ( std::string const &  module)

Load specific module according to the paths and shared_object_pattern provided. Also note paths and pattern can be defined in cppcms configuration in the constructor

Note
module name isn't nessary same as plugin name. Module refers to name of shared object or dll while plugin is application defined. Same dll/so can contain multiple plugins or none.
void cppcms::plugin::scope::paths ( std::vector< std::string > const &  paths)

Set search path for plugins if undefined search according to the OS rules, if one of the paths in the vector is empty the search is performed by.

OS search rules

void cppcms::plugin::scope::shared_object_pattern ( std::string const &  pattern)

Specify shared object/DLL naming convension. For example lib{1}.dll or lib{1}.so for converting the module name to shared object/dll name.

Thus in the shared object pattern is lib{1}.dll that when module "foo" is loaded it tries to load libfoo.dll If not speficied default nameing is used, see booster::shared_object::name


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