dbp::plugin Class Reference

Plugin loader. More...

#include <plugin.h>

Inheritance diagram for dbp::plugin:
Inheritance graph
[legend]
Collaboration diagram for dbp::plugin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 plugin ()
 Constructor.
 ~plugin ()
 Destructor.
virtual void load (const std::string &file_name) throw (plugin_exception)
 Load plugin.
virtual disposablecreate_object (const std::string &object_name)
 Create object.
virtual void destroy_object (disposable *object)
 Destroy object.

Detailed Description

Plugin loader.

Plugin loader loads a dynamic library (.so, .dll) as a program plugin.


Member Function Documentation

virtual disposable* dbp::plugin::create_object ( const std::string &  object_name  )  [virtual]

Create object.

This function creates an object by its name. Each object created by this function should be properly destroyed by calling destroy_object to avoid memory leaks.

Parameters:
object_name a name of the object to create.
Returns:
pointer to a object or NULL if this object is not supported.

Implements dbp::plugin_int.

virtual void dbp::plugin::destroy_object ( disposable object  )  [virtual]

Destroy object.

This function is used to destroy object created by create_object(const std::string&) function.

Parameters:
object the object to destroy.

Implements dbp::plugin_int.

virtual void dbp::plugin::load ( const std::string &  file_name  )  throw (plugin_exception) [virtual]

Load plugin.

Loads the plugin from a given file which should be a dynamic library.

Parameters:
file_name a name of the dynamic library file to load.
Returns:
a reference to a plugin object factory of the specified plugin.

The plugin (dynamic library) should export two following C-functions:

void* create_object(const char*);
void destroy_object(void*);

First function should create the specified class and return the pointer to the class instance created.

Second function should destroy object created by create_object(const std::string&) and free up the memory.

Implements dbp::plugin_int.


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

 
Support This Project
SourceForge.net Logo