Clay Library  1.0.1
All Classes Functions Variables Groups
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clay::core::ClayServiceProvider Class Reference

Service Provider Class. More...

#include <clay.h>

Public Member Functions

int GetCode ()
 
std::string GetName ()
 
bool ServiceExists (int iSvcCode)
 
bool ServiceExists (const std::string &sSvcName)
 
CLAY_SVC_CLASS_FUNC GetService (int iSvcCode)
 
CLAY_SVC_CLASS_FUNC GetService (const std::string &sSvcName)
 
virtual int DoService (int iSvcCode, void *pParam)
 
virtual int DoService (const std::string &sSvcName, void *pParam)
 
 ClayServiceProvider (int iCode)
 
 ClayServiceProvider (const std::string &sName)
 
 ClayServiceProvider (int iCode, const std::string &sName)
 
virtual ~ClayServiceProvider ()
 Destructor function.
 

Protected Member Functions

void ClearServices ()
 Remove all services.
 
int RegisterService (int iSvcCode, CLAY_SVC_CLASS_FUNC pSvcFunc)
 
int RegisterService (const std::string &sSvcName, CLAY_SVC_CLASS_FUNC pSvcFunc)
 
int UnregisterService (int iSvcCode)
 
int UnregisterService (const std::string &sSvcName)
 
int GetServiceCount ()
 
virtual void SetupServices ()
 Setup all services.
 
int GetVersion (void *pParam)
 

Protected Attributes

int m_code
 The code of the service provider(default value is 0)
 
std::string m_name
 The name of the service provider(default value is empty string)
 
ClayServiceIntMap m_svcintmap
 The code map of the services.
 
ClayServiceStrMap m_svcstrmap
 The name map of the services.
 

Detailed Description

Service Provider Class.

Constructor & Destructor Documentation

clay::core::ClayServiceProvider::ClayServiceProvider ( int  iCode)
explicit

Constructor function

Parameters
iCodeThe service code
clay::core::ClayServiceProvider::ClayServiceProvider ( const std::string &  sName)
explicit

Constructor function

Parameters
sNameThe service name
clay::core::ClayServiceProvider::ClayServiceProvider ( int  iCode,
const std::string &  sName 
)

Constructor function

Parameters
iCodeThe service code
sNameThe service name

Member Function Documentation

virtual int clay::core::ClayServiceProvider::DoService ( int  iSvcCode,
void *  pParam 
)
virtual

Execute the service function by the service code

Parameters
iSvcCodeThe service code
pParamThe parameter passed to the service function
Returns
The return code of the service function
virtual int clay::core::ClayServiceProvider::DoService ( const std::string &  sSvcName,
void *  pParam 
)
virtual

Execute the service function by the service name

Parameters
sSvcNameThe service name
pParamThe parameter passed to the service function
Returns
The return code of the service function
int clay::core::ClayServiceProvider::GetCode ( )

Get the code of the service provider

Returns
Return the code of the service provider
std::string clay::core::ClayServiceProvider::GetName ( )

Get the name of the service provider

Returns
Return the name of the service provider
CLAY_SVC_CLASS_FUNC clay::core::ClayServiceProvider::GetService ( int  iSvcCode)

Get the pointer of the service function by the service code

Parameters
iSvcCodeThe service code
Returns
Return the pointer of the service function(or return NULL for none found)
CLAY_SVC_CLASS_FUNC clay::core::ClayServiceProvider::GetService ( const std::string &  sSvcName)

Get the pointer of the service function by the service name

Parameters
sSvcNameThe service name
Returns
Return the pointer of the service function(or return NULL for none found)
int clay::core::ClayServiceProvider::GetServiceCount ( )
protected

Get the count of the registered services

Returns
The total count of the services
int clay::core::ClayServiceProvider::GetVersion ( void *  pParam)
protected

Get the version of the service provider

Parameters
pParamThe parameter(normally it should always be NULL)
Returns
Return the version code of the service provider
int clay::core::ClayServiceProvider::RegisterService ( int  iSvcCode,
CLAY_SVC_CLASS_FUNC  pSvcFunc 
)
protected

Register a service by its code

Parameters
iSvcCodeThe code of the service
pSvcFuncThe service function pointer
Returns
Return -1 for fail
int clay::core::ClayServiceProvider::RegisterService ( const std::string &  sSvcName,
CLAY_SVC_CLASS_FUNC  pSvcFunc 
)
protected

Register a service by its name

Parameters
sSvcNameThe name of the service
pSvcFuncThe service function pointer
Returns
Return -1 for fail
bool clay::core::ClayServiceProvider::ServiceExists ( int  iSvcCode)

Check the existence of the service by its code

Parameters
iSvcCodeThe code of the service
Returns
Return true if the service with the code exists
bool clay::core::ClayServiceProvider::ServiceExists ( const std::string &  sSvcName)

Check the existence of the service by its name

Parameters
sSvcNameThe name of the service
Returns
Return true if the service with the name exists
int clay::core::ClayServiceProvider::UnregisterService ( int  iSvcCode)
protected

Unregister a service by its code

Parameters
iSvcCodeThe code of the service
Returns
If the service is not found then return 0
int clay::core::ClayServiceProvider::UnregisterService ( const std::string &  sSvcName)
protected

Unregister a service by its name

Parameters
sSvcNameThe name of the service
Returns
If the service is not found then return 0

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