00001 #ifndef SERVICEMANAGER_H
00002 #define SERVICEMANAGER_H
00003
00004 #include <kore/kore.h>
00005 #include <kore/serviceprovider.h>
00006 #ifdef WIN32
00007 #include <map>
00008 #else
00009 #if (__GNUC__<3)
00010 #include <hash_map>
00011 #else
00012 #include <ext/hash_map>
00013 #endif
00014 #endif
00015 #include <set>
00016
00017 namespace kore
00018 {
00027 class KORE_API ServiceManager : public ServiceProvider
00028 {
00029 public:
00033 ServiceManager();
00037 virtual ~ServiceManager();
00038
00043 virtual void registerProvider(ServiceProvider* provider);
00048 virtual void unregisterProvider(ServiceProvider* provider);
00054 virtual void registerProviders(ServiceProvider** providers);
00058 virtual void unregisterProviders();
00063
00064 virtual void registerService(const Service* service);
00069 virtual void unregisterService(const Service* service);
00074 virtual void registerServices(const Service** srvs);
00078 virtual void unregisterServices();
00079
00086 virtual const Service** registeredServices() const;
00095 virtual const Service** registeredServices(ServiceProvider* provider) const;
00104
00105 virtual const Service** registeredServices(const Service* service) const;
00114 virtual const Service** registeredServices(const char* service) const;
00120
00121 virtual const Service* registeredService(const Service* service) const;
00127 virtual const Service* registeredService(const char* service) const;
00128
00136 virtual ServiceProvider** registeredProviders() const;
00145 virtual ServiceProvider** registeredProviders(const Service* service) const;
00154 virtual ServiceProvider** registeredProviders(const char* service) const;
00161 virtual ServiceProvider* registeredProvider(const Service* service) const;
00168 virtual ServiceProvider* registeredProvider(const char* service) const;
00169
00170 protected:
00171 private:
00172
00173 const Version* _smVersion;
00174
00175 const Version* _smAPIVersion;
00176
00177 const Info* _smInfo;
00178
00179 const Service* _smService;
00180
00181 #ifdef WIN32
00182 struct ltstr
00183 {
00184 bool operator()(const char* s1, const char* s2) const
00185 {
00186 return strcmp(s1,s2) == -1;
00187 }
00188 };
00189
00190 typedef multimap<const char*,const Service*, ltstr> srv_hash_type;
00191 #else
00192 struct eqstr
00193 {
00194 bool operator()(const char* s1, const char* s2) const
00195 {
00196 return strcmp(s1,s2) == 0;
00197 }
00198 };
00199 typedef hash_multimap<const char*,const Service*, hash<const char*>, eqstr> srv_hash_type;
00200 #endif
00201 struct ltptr
00202 {
00203 bool operator()(ServiceProvider* sp1, ServiceProvider* sp2) const
00204 {
00205 return sp1 < sp2;
00206 }
00207 };
00208 typedef set<ServiceProvider* , ltptr> sp_set_type;
00209
00210
00211
00212 srv_hash_type _services;
00213 };
00214 };
00215
00216 #endif