Main  /  Edit version 1  /  Edit version 2  /   /  Users Area

Difference "New Plugin API in 1.2" ver. 1 versus ver. 2

Content:

CppCMS 1.2 introduces a new plugin API together with new improved support
<!--toc-->
CppCMS 1.2 introduces a new plugin API together with new improved support of dynamic templates
## Writing Plugins
Plugins are shared object that can register their functions within `cppcms::plugin::manager` singleton. For example:
For example you write some class that implements a certain API:
namespace myplugin {
class my_class : public plugin_api {
public:
statuc my_class *create(std::string const &parameter)
{
return new my_class(parameter);
}
...
};
}
Than you can register it within the `plugin::manager` using special macro.
CPPCMS_PLUGIN_ENTRY(myplugin,my_class::create,plugin_api *(std::string const &))
Note: the 3rd parameter that defines the signature of the entry for typesafe plugin access.
Than you can access the required plugins from the main code calling
// callback object
booster::callback<plugin_api *(std::string const &)> cb;
// get it from plugin
cb = cppcms::manager::instance().entry<plugin_api *(std::string const &)>("myplugin","my_class::create");
// call it
plugin_api *ptr = cb("foo");
## Loading plugins
`cppcms::service` allows to load the plugins [from the configuration](/wikipp/en/page/cppcms_1x_config#plugin)
You can also link the views with the same plugin and they will be loaded automatically.
## Template System Support
In order to create dynamically loaded templates from plugins, there are several improvements in template systems:
New [view helpers](/wikipp/en/page/cppcms_1x_templates_comm#Views.Helpers) allow to call specific functions from templates by their names

About

CppCMS is a web development framework for performance demanding applications.

Support This Project

SourceForge.net Logo

Поддержать проект

CppCMS needs You


Navigation

Main Page


Valid CSS | Valid XHTML 1.0