8 #ifndef CPPCMS_PLUGIN_H 9 #define CPPCMS_PLUGIN_H 10 #include <cppcms/defs.h> 11 #include <cppcms/cppcms_error.h> 12 #include <booster/callback.h> 13 #include <booster/hold_ptr.h> 17 namespace booster {
class shared_object; }
20 namespace json {
class value; }
35 virtual char const *what()
const throw();
58 void operator=(scope
const &);
72 scope(
int argc,
char **argv);
82 void paths(std::vector<std::string>
const &paths);
89 void shared_object_pattern(std::string
const &pattern);
98 void load(std::string
const &module);
103 static bool is_loaded(std::string
const &module);
113 bool is_loaded_by_this_scope(std::string
const &module)
const;
117 static _class_data &class_data();
145 typedef refcounted_ptr (*entry_point_type)();
167 template<
typename Signature>
169 entry(std::string
const &plugin_name,std::string
const &entry_name)
172 typedef typename callback_type::callable_type callable_type;
173 typedef typename callback_type::pointer_type pointer_type;
175 entry_point_type plugin_call = instance().
get_entry(plugin_name,entry_name);
177 throw cppcms_error(
"Could not find entry `" + entry_name +
"' in plugin `" + plugin_name +
"'");
178 refcounted_ptr call = plugin_call();
180 throw cppcms_error(
"Failed to create callback from plugin `"+plugin_name+
"':entry `" + entry_name +
"'");
182 callable_type *real_call =
dynamic_cast<callable_type *
>(call.get());
184 throw signature_error(
"Invalid signature request in plugin `"+ plugin_name +
"':entry `"+entry_name+
"', expected following signaure `" + instance().signature(plugin_name,entry_name) +
"'");
186 pointer_type ptr(real_call);
187 callback_type result(ptr);
194 template<
typename Signature>
195 bool has_entry(std::string
const &plugin,std::string
const &name)
199 entry_point_type plugin_call = get_entry(plugin,name);
202 return dynamic_cast<callback_type *
>(plugin_call().get())!=0;
208 entry_point_type get_entry(std::string
const &plugin,std::string
const &name);
212 std::string signature(std::string
const &plugin,std::string
const &name);
217 void add_entry(
char const *plugin_name,
char const *entry_name,entry_point_type entry,
char const *signature);
221 void remove_entry(entry_point_type entry);
226 std::set<std::string> plugins();
230 std::set<std::string> entries(std::string
const &plugin);
235 bool has_plugin(std::string
const &name);
241 void operator=(
manager const &);
248 #define CPPCMS_PLUGIN_CONCAT(x,y) x ## y 249 #define CPPCMS_PLUGIN_CONCAT2(x,y) CPPCMS_PLUGIN_CONCAT(x,y) 271 #define CPPCMS_FULL_PLUGIN_ENTRY(plugin_name,entry_name,call,type) \ 273 struct CPPCMS_PLUGIN_CONCAT2(stpg_ , __LINE__) { \ 274 static booster::intrusive_ptr<booster::refcounted> entry() \ 276 typedef booster::callback<type> ct; \ 278 booster::refcounted *tmp = cb.get_pointer().get(); \ 279 booster::intrusive_ptr<booster::refcounted> ptr(tmp); \ 282 CPPCMS_PLUGIN_CONCAT2(stpg_,__LINE__) () { \ 283 cppcms::plugin::manager::instance().add_entry( \ 284 plugin_name,entry_name,&entry,#type \ 288 ~CPPCMS_PLUGIN_CONCAT2(stpg_,__LINE__)() { \ 289 cppcms::plugin::manager::instance().remove_entry(&entry); \ 291 } CPPCMS_PLUGIN_CONCAT2(instance_of_stpg_,__LINE__); \ 317 #define CPPCMS_PLUGIN_ENTRY(name,call,type) CPPCMS_FULL_PLUGIN_ENTRY(#name,#call,& name :: call,type) 341 #define CPPCMS_NAMED_PLUGIN_ENTRY(name,entry,call,type) CPPCMS_FULL_PLUGIN_ENTRY(#name,#entry,& name :: call,type)
This class is central representation of json objects.
Definition: json.h:140
Definition: callback.h:18
Exception thrown by CppCMS framework.
Definition: cppcms_error.h:22
Class that allows loading dynamic libraries: shared objects and dlls.
Definition: shared_object.h:22
This is the namespace where all CppCMS functionality is placed.
Definition: application.h:19
bool has_entry(std::string const &plugin, std::string const &name)
Definition: plugin.h:195
intrusive_ptr is the class taken as-is from boost.
Definition: intrusive_ptr.h:42
Same as std::bad_cast but records stack trace.
Definition: backtrace.h:151
booster::callback< Signature > entry(std::string const &plugin_name, std::string const &entry_name)
Definition: plugin.h:169
entry_point_type get_entry(std::string const &plugin, std::string const &name)
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23