Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

PluginCollection Class Reference

Holds the complete collection of shared objects. More...

#include <page_magick.h>

List of all members.

Public Member Functions

 PluginCollection ()
 Plugin Collection - loads all shared objects in the specified directory.
 ~PluginCollection ()
void Initialise (char *directory)
void RegisterPlugin (char *filename)
unsigned int Count ()
PluginGet (unsigned int index)

Private Attributes

vector< Plugin * > collection


Detailed Description

Holds the complete collection of shared objects.

Definition at line 52 of file page_magick.h.


Constructor & Destructor Documentation

PluginCollection::PluginCollection  ) 
 

Plugin Collection - loads all shared objects in the specified directory.

Definition at line 375 of file page_magick.cc.

00376 {}

PluginCollection::~PluginCollection  ) 
 

Definition at line 378 of file page_magick.cc.

References collection.

00379 {
00380     for ( unsigned int index = 0; index < collection.size(); index ++ )
00381     {
00382         collection[ index ] ->Close();
00383         delete collection[ index ];
00384     }
00385 }


Member Function Documentation

unsigned int PluginCollection::Count  ) 
 

Definition at line 431 of file page_magick.cc.

References collection.

Referenced by PageMagick::PageMagick().

00432 {
00433     return collection.size();
00434 }

Plugin * PluginCollection::Get unsigned int  index  ) 
 

Definition at line 436 of file page_magick.cc.

References collection.

Referenced by PageMagick::PageMagick().

00437 {
00438     return collection[ index ];
00439 }

void PluginCollection::Initialise char *  directory  ) 
 

Definition at line 387 of file page_magick.cc.

References RegisterPlugin().

Referenced by PageMagick::PageMagick().

00388 {
00389     char * filename;
00390     char *extension;
00391     DIR *dir;
00392     struct dirent *entry;
00393     struct stat statbuf;
00394 
00395     dir = opendir( directory );
00396 
00397     if ( dir )
00398     {
00399         while ( ( entry = readdir( dir ) ) != NULL )
00400         {
00401             filename = g_strdup_printf( "%s/%s", directory, entry->d_name );
00402             extension = strrchr( entry->d_name, '.' );
00403             if ( extension != NULL && !stat( filename, &statbuf ) && S_ISREG( statbuf.st_mode ) )
00404             {
00405                 if ( !strcmp( extension, ".so" ) )
00406                 {
00407                     RegisterPlugin( filename );
00408                 }
00409             }
00410             g_free( filename );
00411         }
00412         closedir( dir );
00413     }
00414 }

void PluginCollection::RegisterPlugin char *  filename  ) 
 

Definition at line 416 of file page_magick.cc.

References collection, Plugin::GetError(), and Plugin::Open().

Referenced by Initialise().

00417 {
00418     Plugin * plugin = new Plugin;
00419     if ( plugin->Open( filename ) )
00420     {
00421         cerr << ">>> Registering plugin " << filename << endl;
00422         collection.push_back( plugin );
00423     }
00424     else
00425     {
00426         cerr << ">>> Rejecting plugin " << filename << " : " << plugin->GetError() << endl;
00427         delete plugin;
00428     }
00429 }


Member Data Documentation

vector< Plugin * > PluginCollection::collection [private]
 

Definition at line 55 of file page_magick.h.

Referenced by Count(), Get(), RegisterPlugin(), and ~PluginCollection().


The documentation for this class was generated from the following files:
Generated on Sun Mar 11 22:13:23 2007 for Kino by  doxygen 1.4.2