akregator/src
storagefactoryregistry.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "storagefactory.h"
00026 #include "storagefactoryregistry.h"
00027
00028 #include <kstaticdeleter.h>
00029
00030 #include <tqmap.h>
00031 #include <tqstring.h>
00032 #include <tqstringlist.h>
00033
00034 namespace Akregator {
00035 namespace Backend {
00036
00037 class StorageFactoryRegistry::StorageFactoryRegistryPrivate
00038 {
00039 public:
00040 TQMap<TQString, StorageFactory*> map;
00041 };
00042
00043 StorageFactoryRegistry* StorageFactoryRegistry::m_instance = 0;
00044 static KStaticDeleter<StorageFactoryRegistry> storagefactoryregistrysd;
00045
00046 StorageFactoryRegistry* StorageFactoryRegistry::self()
00047 {
00048 if (!m_instance)
00049 m_instance = storagefactoryregistrysd.setObject(m_instance, new StorageFactoryRegistry);
00050 return m_instance;
00051 }
00052
00053 bool StorageFactoryRegistry::registerFactory(StorageFactory* factory, const TQString& typestr)
00054 {
00055 if (containsFactory(typestr))
00056 return false;
00057 d->map[typestr] = factory;
00058 return true;
00059 }
00060
00061 void StorageFactoryRegistry::unregisterFactory(const TQString& typestr)
00062 {
00063 d->map.remove(typestr);
00064 }
00065
00066 StorageFactory* StorageFactoryRegistry::getFactory(const TQString& typestr)
00067 {
00068 return d->map[typestr];
00069 }
00070
00071 bool StorageFactoryRegistry::containsFactory(const TQString& typestr) const
00072 {
00073 return d->map.contains(typestr);
00074 }
00075
00076 TQStringList StorageFactoryRegistry::list() const
00077 {
00078 return d->map.keys();
00079 }
00080
00081 StorageFactoryRegistry::StorageFactoryRegistry() : d(new StorageFactoryRegistryPrivate)
00082 {
00083 }
00084
00085 StorageFactoryRegistry::~StorageFactoryRegistry()
00086 {
00087 delete d;
00088 d = 0;
00089 }
00090
00091 }
00092 }
|