Sirikata
Public Member Functions | Private Types | Private Attributes
Sirikata::Plugin Class Reference

Plugin provides loading of plugins to allow for extension of the system. More...

#include <Plugin.hpp>

Collaboration diagram for Sirikata::Plugin:

List of all members.

Public Member Functions

 Plugin (const String &path)
 ~Plugin ()
bool load ()
 Loads the plugin, returning true if it satisfies all the plugin requirements, i.e.
bool unload ()
 Forcefully unloads the plugin.
void initialize ()
 Run this plugin's initialization code.
int incref ()
 Increment the ref count on this plugin by one.
int decref ()
 Decrease the ref count on this plugin by one.
void destroy ()
 Destroy this plugin.
String name ()
 Get the name of this plugin.
int refcount ()
 Get the current refcount of this plugin.

Private Types

typedef void(* InitFunc )()
typedef void(* DestroyFunc )()
typedef const char *(* NameFunc )()
typedef int(* RefCountFunc )()
typedef int(* IncRefCountFunc )()
typedef int(* DecRefCountFunc )()

Private Attributes

DynamicLibrary mDL
InitFunc mInit
DestroyFunc mDestroy
NameFunc mName
RefCountFunc mRefCount
IncRefCountFunc mIncRefCount
DecRefCountFunc mDecRefCount
int mInitialized

Detailed Description

Plugin provides loading of plugins to allow for extension of the system.

Plugins are dynamic libraries which register services with the core system. Generally these will take the form of implementations of services which are registered with the appropriate factory. Plugins must provide a simple interface implemented as a small set of C functions: void init(); // initialize this plugin, generally just register services void destroy(); // destroy this plugin, generally just unregister services const char* name(); // get the name of this plugin int refcount(); // get the reference count of this plugin These should be mostly self explanatory. The reference count is maintained by the plugin but used by the main system itself. While a plugin's code is potentially in use it should ensure that its refcount is greater than 0.


Member Typedef Documentation

typedef int(* Sirikata::Plugin::DecRefCountFunc)() [private]
typedef void(* Sirikata::Plugin::DestroyFunc)() [private]
typedef int(* Sirikata::Plugin::IncRefCountFunc)() [private]
typedef void(* Sirikata::Plugin::InitFunc)() [private]
typedef const char*(* Sirikata::Plugin::NameFunc)() [private]
typedef int(* Sirikata::Plugin::RefCountFunc)() [private]

Constructor & Destructor Documentation

Sirikata::Plugin::Plugin ( const String &  path)
Sirikata::Plugin::~Plugin ( )

Member Function Documentation

int Sirikata::Plugin::decref ( )

Decrease the ref count on this plugin by one.

References mDecRefCount.

void Sirikata::Plugin::destroy ( )

Destroy this plugin.

References mDestroy, and mInitialized.

Referenced by ~Plugin().

int Sirikata::Plugin::incref ( )

Increment the ref count on this plugin by one.

References mIncRefCount.

void Sirikata::Plugin::initialize ( )

Run this plugin's initialization code.

References mInit, and mInitialized.

Referenced by Sirikata::PluginManager::load().

bool Sirikata::Plugin::load ( )

Loads the plugin, returning true if it satisfies all the plugin requirements, i.e.

if it is successfully loaded from disk and has the appropriate interface.

References Sirikata::DynamicLibrary::load(), mDecRefCount, mDestroy, mDL, mIncRefCount, mInit, mName, mRefCount, and Sirikata::DynamicLibrary::symbol().

Referenced by Sirikata::PluginManager::load().

String Sirikata::Plugin::name ( )

Get the name of this plugin.

References mName.

Referenced by Sirikata::PluginManager::load().

int Sirikata::Plugin::refcount ( )

Get the current refcount of this plugin.

References mRefCount.

Referenced by ~Plugin().

bool Sirikata::Plugin::unload ( )

Forcefully unloads the plugin.

Note that this *does not* call the destroy method.

References mDecRefCount, mDestroy, mDL, mIncRefCount, mInit, mName, mRefCount, and Sirikata::DynamicLibrary::unload().

Referenced by ~Plugin().


Member Data Documentation

Referenced by decref(), load(), and unload().

Referenced by destroy(), load(), unload(), and ~Plugin().

Referenced by load(), and unload().

Referenced by incref(), load(), and unload().

Referenced by initialize(), load(), and unload().

Referenced by destroy(), initialize(), and ~Plugin().

Referenced by load(), name(), and unload().

Referenced by load(), refcount(), unload(), and ~Plugin().


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