Trippin Cyril
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
trippingcyril::Module Class Referenceabstract

Base class for modules. More...

#include <Module.h>

Public Member Functions

 Module (ModHandle so, const String &modName, const String &path, const libconfig::Config *config)
 
virtual ~Module ()
 
virtual String GetVersion () const =0
 
virtual void OnLoaded ()
 
virtual void * InternalApiCall (int method, void *arg)
 
virtual void CleanUpInterData (int method, void *arg)
 
const String GetModName () const
 
const String GetPath () const
 
struct event_base * GetEventBase () const
 
struct evdns_base * GetDNSBase () const
 

Static Public Member Functions

static ModuleLoadModule (const String &path, const String &modName, String &retMsg, const String &config)
 

Protected Attributes

bool wantsThread: 1
 
bool unloadOnCrash: 1
 
bool reloadOnCrash: 1
 
const libconfig::Config * config
 

Detailed Description

Base class for modules.

Constructor & Destructor Documentation

trippingcyril::Module::Module ( ModHandle  so,
const String modName,
const String path,
const libconfig::Config *  config 
)

Use MODCONSTRUCTOR and MODCONSTRUCTORHEADER instead of directly calling this constructor yourself

See Also
MODCONSTRUCTOR
MODCONSTRUCTORHEADER
virtual trippingcyril::Module::~Module ( )
virtual

Deconstructor, clean up your own resources here. Don't clean up any timers or sockets that you allocated with this module, those will get cleaned up for you. This includes any callbacks (if ShouldDelete::shouldDelete() returns true that is)

Member Function Documentation

virtual void trippingcyril::Module::CleanUpInterData ( int  method,
void *  arg 
)
inlinevirtual

Used to clean up the data returned by InternalApiCall

struct evdns_base* trippingcyril::Module::GetDNSBase ( ) const
inline
Returns
The libevent dns base for this module
struct event_base* trippingcyril::Module::GetEventBase ( ) const
inline
Returns
The libevent base for this module
const String trippingcyril::Module::GetModName ( ) const
inline
Returns
The name of the module
const String trippingcyril::Module::GetPath ( ) const
inline
Returns
The path of the module
virtual String trippingcyril::Module::GetVersion ( ) const
pure virtual

Should return the version of the module, required to override

virtual void* trippingcyril::Module::InternalApiCall ( int  method,
void *  arg 
)
inlinevirtual

Will get called for any calls to Global::ModuleInternalApiCall, implement this method to actually create internal api methods.

static Module* trippingcyril::Module::LoadModule ( const String path,
const String modName,
String retMsg,
const String config 
)
static

Used to actually load modules from shared libraries.

Parameters
pathThe path of the shared library to actually load
modNameThe name the module should get, see Module::GetModName
retMsgA human readable string about the status of the loading
configPath to the configuration file of this module
Returns
NULL on error, the loaded module otherwise
virtual void trippingcyril::Module::OnLoaded ( )
inlinevirtual

Will get called once after the module is loaded, initialize any timers or sockets in this method, don't do that in your constructor!

Member Data Documentation

const libconfig::Config* trippingcyril::Module::config
protected

The loaded config file

bool trippingcyril::Module::reloadOnCrash
protected

Reload the module again after unloading it because of a crash, only works if unloadOnCrash is true

bool trippingcyril::Module::unloadOnCrash
protected

Attempt to unload the module if it causes a crash, only works if wantsThread is true

bool trippingcyril::Module::wantsThread
protected

Set this to true in your constructor if you want to run in your own seperate thread


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