Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

kore::ServiceProvider Class Reference

class kore::ServiceProvider - a ServiceProvider is a Module which provides or more services to be used by the other modules. More...

#include <serviceprovider.h>

Inheritance diagram for kore::ServiceProvider::

kore::Module kore::Kernel kore::ModuleManager kore::PluginLoader kore::PluginManager kore::ServiceManager List of all members.

Public Methods

virtual const Service ** services () const
 Gets the list services provided by this ServiceProvider. More...

virtual const Serviceservice (const Service *srv) const
 Checks whether this SP provides a service who's name matches the given srv->name(). More...

virtual const Serviceservice (const char *srv) const
 Checks whether this SP provides a service who's name matches the given srv->name(). More...

virtual void registeringProvider (ServiceManager *sm)
 Callback method triggered right BEFORE REGISTERING this ServiceProvider to a ServiceManager. More...

virtual void providerRegistered (ServiceManager *sm)
 Callback method triggered right AFTER REGISTERING this ServiceProvider to a ServiceManager. More...

virtual void unregisteringProvider (ServiceManager *sm)
 Callback method triggered right BEFORE UNREGISTERING this ServiceProvider from a ServiceManager. More...

virtual void providerUnregistered (ServiceManager *sm)
 Callback method triggered right AFTER UNREGISTERING this ServiceProvider from a ServiceManager. More...

virtual void registeringService (ServiceManager *sm, const Service *srv)
 Callback method triggered right BEFORE REGISTERING to a ServiceManager one of the Services provided by this SP. More...

virtual void serviceRegistered (ServiceManager *sm, const Service *srv)
 Callback method triggered right AFTER REGISTERING to a ServiceManager one of the Services provided by this SP. More...

virtual void unregisteringService (ServiceManager *sm, const Service *srv)
 Callback method triggered right BEFORE UNREGISTERING from a ServiceManager one of the Services provided by this SP. More...

virtual void serviceUnregistered (ServiceManager *sm, const Service *srv)
 Callback method triggered right AFTER UNREGISTERING from a ServiceManager one of the Services provided by this SP. More...


Protected Methods

 ServiceProvider ()
 Default constructor. More...

 ServiceProvider (const Info *info)
 Creates a ServiceProvider and sets its Info. More...

virtual ~ServiceProvider ()
 Destructor. More...

virtual void addService (const Service *service)
 Convenience method for adding a Service to this SP services list. More...

virtual const ServicepassiveService (const Service *service) const
 Searches for a passive service who's name matches service->name(). More...

virtual const ServiceactiveService (const Service *service) const
 Searches for an active service who's name matches service->name(). More...


Private Attributes

vector< const Service *> _services

Detailed Description

class kore::ServiceProvider - a ServiceProvider is a Module which provides or more services to be used by the other modules.

Definition at line 20 of file serviceprovider.h.


Constructor & Destructor Documentation

ServiceProvider::ServiceProvider   [protected]
 

Default constructor.

Creates an empty ServiceProvider.

Definition at line 54 of file serviceprovider.cpp.

Referenced by kore::ServiceProvider::Service::provider(), kore::ServiceManager::registeredProviders(), and kore::ServiceManager::unregisterProviders().

00055 {
00056 }

ServiceProvider::ServiceProvider const Info *    info [protected]
 

Creates a ServiceProvider and sets its Info.

Parameters:
info  - the ServiceProvider info.

Definition at line 57 of file serviceprovider.cpp.

00057                                                 :Module(info)
00058 {
00059 }

ServiceProvider::~ServiceProvider   [protected, virtual]
 

Destructor.

Definition at line 60 of file serviceprovider.cpp.

00061 {
00062 }


Member Function Documentation

const ServiceProvider::Service * ServiceProvider::activeService const Service   srv const [protected, virtual]
 

Searches for an active service who's name matches service->name().

This function gets called by ServiceProvider::service(const Service*) functions, only when ServiceProvider::passiveService() returns NULL. Subclasses may override this function in order to tell whether a given service name mathces or not on of the active services this SP provides.

Parameters:
srv  - the service name used for mathcing.
Returns:
- the actual active service, if a match was found, NULL otherwise.

Definition at line 117 of file serviceprovider.cpp.

Referenced by service().

00118 {
00119     return 0;
00120 }

void ServiceProvider::addService const Service   service [protected, virtual]
 

Convenience method for adding a Service to this SP services list.

Parameters:
service  - the service to be added.

Definition at line 64 of file serviceprovider.cpp.

References _services, and service().

Referenced by kore::Kernel::Kernel(), kore::ModuleManager::ModuleManager(), kore::PluginLoader::PluginLoader(), kore::PluginManager::PluginManager(), and kore::ServiceManager::ServiceManager().

00065 {
00066     _services.push_back(service);
00067 }

const ServiceProvider::Service * ServiceProvider::passiveService const Service   srv const [protected, virtual]
 

Searches for a passive service who's name matches service->name().

This function gets called by ServiceProvider::service(const Service*) function.

Parameters:
srv  - the service name used for mathcing.
Returns:
- the actual passive service, if a match was found, NULL otherwise.

Definition at line 100 of file serviceprovider.cpp.

References services().

Referenced by service().

00101 {
00102     // paranoia
00103     if( !srv )
00104         return 0;
00105     const Service* res = 0;
00106     const Service** srvs = services();
00107     for(int i=0; srvs[i]; i++)
00108         if( (srvs[i] == srv) || ( strcmp(srvs[i]->name(),srv->name()) == 0 ) )
00109         {
00110             res = srvs[i];
00111             break;
00112         }
00113     delete[] srvs;
00114     return res;
00115 }

void ServiceProvider::providerRegistered ServiceManager   sm [virtual]
 

Callback method triggered right AFTER REGISTERING this ServiceProvider to a ServiceManager.

Parameters:
sm  - the ServiceManager this SP got registered to.

Definition at line 126 of file serviceprovider.cpp.

00127 {
00128     //cout << info()->name() << " " << (const char*)*(info()->version()) << " : registered to " << sm->info()->name() << " " << (const char*)*(sm->info()->version()) << endl;
00129 }

void ServiceProvider::providerUnregistered ServiceManager   sm [virtual]
 

Callback method triggered right AFTER UNREGISTERING this ServiceProvider from a ServiceManager.

Parameters:
sm  - the ServiceManager this SP got unregistered from.

Definition at line 134 of file serviceprovider.cpp.

00135 {
00136     //cout << info()->name() << " " << (const char*)*(info()->version()) << " : unregistered from " << sm->info()->name() << " " << (const char*)*(sm->info()->version()) << endl;
00137 }

void ServiceProvider::registeringProvider ServiceManager   sm [virtual]
 

Callback method triggered right BEFORE REGISTERING this ServiceProvider to a ServiceManager.

Parameters:
sm  - the ServiceManager this SP will get registered to.

Definition at line 122 of file serviceprovider.cpp.

00123 {
00124     //cout << info()->name() << " " << (const char*)*(info()->version()) << " : registering to " << sm->info()->name() << " " << (const char*)*(sm->info()->version()) << endl;
00125 }

void ServiceProvider::registeringService ServiceManager   sm,
const Service   srv
[virtual]
 

Callback method triggered right BEFORE REGISTERING to a ServiceManager one of the Services provided by this SP.

Parameters:
sm  - ServiceManager the Service will get registered to.
srv  - the Service that will get registered.

Definition at line 139 of file serviceprovider.cpp.

00140 {
00141     //cout << info()->name() << " " << (const char*)*(info()->version()) << " : registering service " << srv->name() << " (" << srv->description() << ") to " << sm->info()->name() << " " << (const char*)*(sm->info()->version()) << endl;
00142 }

const ServiceProvider::Service * ServiceProvider::service const char *    srv const [virtual]
 

Checks whether this SP provides a service who's name matches the given srv->name().

The default implementation creates a temporary Service object, sets its name to srv, and calls ServiceProvider::service(const Service*).

Parameters:
srv  - the service name used for mathcing.
Returns:
- the actual service, if a match was found, NULL otherwise.

Definition at line 80 of file serviceprovider.cpp.

References service().

00081 {
00082     if( !srv )
00083         return 0;
00084     Service serv(0, srv, 0);
00085     return service(&serv);
00086 }

const ServiceProvider::Service * ServiceProvider::service const Service   srv const [virtual]
 

Checks whether this SP provides a service who's name matches the given srv->name().

The default implementation returns ServiceProvider::activeService(...), or if the activeService()'s result is NULL, it returns ServiceProvider::passiveService(...).

Parameters:
srv  - the service who's name is used for mathcing.
Returns:
- the actual service, if a match was found, NULL otherwise.

Definition at line 88 of file serviceprovider.cpp.

References activeService(), and passiveService().

Referenced by addService(), kore::ServiceManager::registeredProvider(), kore::ServiceManager::registeredProviders(), kore::ServiceManager::registeredService(), kore::ServiceManager::registeredServices(), and service().

00089 {
00090     if( !srv )
00091         return 0;
00092     const Service* serv = 0;
00093     serv = passiveService(srv);
00094     if( serv )
00095         return serv;
00096     else
00097         return activeService(srv);
00098 }

void ServiceProvider::serviceRegistered ServiceManager   sm,
const Service   srv
[virtual]
 

Callback method triggered right AFTER REGISTERING to a ServiceManager one of the Services provided by this SP.

Parameters:
sm  - ServiceManager the Service got registered to.
srv  - the Service that got registered.

Definition at line 143 of file serviceprovider.cpp.

00144 {
00145     //cout << info()->name() << " " << (const char*)*(info()->version()) << " : registered service " << srv->name() << " (" << srv->description() << ") to " << sm->info()->name() << " " << (const char*)*(sm->info()->version()) << endl;
00146 }

const ServiceProvider::Service ** ServiceProvider::services   const [virtual]
 

Gets the list services provided by this ServiceProvider.

Returns:
- a null-terminated array of Services.

Definition at line 69 of file serviceprovider.cpp.

References _services.

Referenced by passiveService().

00070 {
00071     int n = _services.size();
00072     const Service** srv = new const Service*[n+1];
00073     int i;
00074     for( i = 0; i < n; i++ )
00075         srv[i] = _services[i];
00076     srv[i] = 0;
00077     return srv;
00078 }

void ServiceProvider::serviceUnregistered ServiceManager   sm,
const Service   srv
[virtual]
 

Callback method triggered right AFTER UNREGISTERING from a ServiceManager one of the Services provided by this SP.

Parameters:
sm  - ServiceManager the Service got unregistered from.
srv  - the Service that got unregistered.

Definition at line 151 of file serviceprovider.cpp.

00152 {
00153     //cout << info()->name() << " " << (const char*)*(info()->version()) << " : unregistered service " << srv->name() << " (" << srv->description() << ") from " << sm->info()->name() << " " << (const char*)*(sm->info()->version()) << endl;
00154 }

void ServiceProvider::unregisteringProvider ServiceManager   sm [virtual]
 

Callback method triggered right BEFORE UNREGISTERING this ServiceProvider from a ServiceManager.

Parameters:
sm  - the ServiceManager this SP will get unregistered from.

Definition at line 130 of file serviceprovider.cpp.

00131 {
00132     //cout << info()->name() << " " << (const char*)*(info()->version()) << " : unregistering from " << sm->info()->name() << " " << (const char*)*(sm->info()->version()) << endl;
00133 }

void ServiceProvider::unregisteringService ServiceManager   sm,
const Service   srv
[virtual]
 

Callback method triggered right BEFORE UNREGISTERING from a ServiceManager one of the Services provided by this SP.

Parameters:
sm  - ServiceManager the Service will get unregistered from.
srv  - the Service that will get unregistered.

Definition at line 147 of file serviceprovider.cpp.

00148 {
00149     //cout << info()->name() << " " << (const char*)*(info()->version()) << " : unregistering service " << srv->name() << " (" << srv->description() << ") from " << sm->info()->name() << " " << (const char*)*(sm->info()->version()) << endl;
00150 }


Member Data Documentation

vector<const Service*> kore::ServiceProvider::_services [private]
 

Reimplemented in kore::ServiceManager.

Definition at line 204 of file serviceprovider.h.

Referenced by addService(), and services().


The documentation for this class was generated from the following files:
Generated on Sat Feb 16 10:53:06 2002 for Korelib by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001