summaryrefslogtreecommitdiff
path: root/orkbasecxx
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2007-02-05 21:34:01 +0000
committerHenri Herscher <henri@oreka.org>2007-02-05 21:34:01 +0000
commit94e3eb2d0cda7df2d876d1698db2e8e75cd0a0b1 (patch)
tree35361de8c5dd9d8cf43dbb84674cf503c03b3e4a /orkbasecxx
parenteb3b1d6a3dcf20864d0610758f8bcf426a1af7ec (diff)
ObjectFactory becomes a home brewed singleton instead of an ACE singleton. ACE singletons have the problem of not being unique across DLL.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@398 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx')
-rw-r--r--orkbasecxx/MultiThreadedServer.cpp4
-rw-r--r--orkbasecxx/ObjectFactory.cpp13
-rw-r--r--orkbasecxx/ObjectFactory.h10
3 files changed, 22 insertions, 5 deletions
diff --git a/orkbasecxx/MultiThreadedServer.cpp b/orkbasecxx/MultiThreadedServer.cpp
index cda25a9..fb799fd 100644
--- a/orkbasecxx/MultiThreadedServer.cpp
+++ b/orkbasecxx/MultiThreadedServer.cpp
@@ -94,7 +94,7 @@ int CommandLineServer::svc(void)
try
{
CStdString className = SingleLineSerializer::FindClass(command);
- ObjectRef objRef = ObjectFactorySingleton::instance()->NewInstance(className);
+ ObjectRef objRef = ObjectFactory::GetSingleton()->NewInstance(className);
if (objRef.get())
{
objRef->DeSerializeSingleLine(command);
@@ -186,7 +186,7 @@ int HttpServer::svc(void)
CStdString className = UrlSerializer::FindClass(url);
- ObjectRef objRef = ObjectFactorySingleton::instance()->NewInstance(className);
+ ObjectRef objRef = ObjectFactory::GetSingleton()->NewInstance(className);
if (objRef.get())
{
objRef->DeSerializeUrl(url);
diff --git a/orkbasecxx/ObjectFactory.cpp b/orkbasecxx/ObjectFactory.cpp
index 173d581..97536e9 100644
--- a/orkbasecxx/ObjectFactory.cpp
+++ b/orkbasecxx/ObjectFactory.cpp
@@ -15,12 +15,23 @@
#include "ObjectFactory.h"
+ObjectFactory* ObjectFactory::m_singleton = NULL;
+
+ObjectFactory::ObjectFactory()
+{
+}
void ObjectFactory::Initialize()
{
- ;
+ m_singleton = new ObjectFactory();
}
+ObjectFactory* ObjectFactory::GetSingleton()
+{
+ return m_singleton;
+}
+
+
ObjectRef ObjectFactory::NewInstance(CStdString& className)
{
std::map<CStdString, ObjectRef>::iterator pair;
diff --git a/orkbasecxx/ObjectFactory.h b/orkbasecxx/ObjectFactory.h
index 4ebaf60..0c5cd31 100644
--- a/orkbasecxx/ObjectFactory.h
+++ b/orkbasecxx/ObjectFactory.h
@@ -22,18 +22,24 @@
/** The ObjectFactory can be used to instanciate Objects based on class name.
All existing Objects must be registered to the ObjectFactory at startup.
*/
+class ObjectFactory;
+
class DLL_IMPORT_EXPORT_ORKBASE ObjectFactory
{
public:
- void Initialize();
+ static void Initialize();
+ static ObjectFactory* GetSingleton();
+
ObjectRef NewInstance(CStdString& className);
void RegisterObject(ObjectRef&);
private:
+ ObjectFactory();
+ static ObjectFactory* m_singleton;
std::map<CStdString, ObjectRef> m_classes;
};
-typedef ACE_Singleton<ObjectFactory, ACE_Thread_Mutex> ObjectFactorySingleton;
+//typedef ACE_Singleton<ObjectFactory, ACE_Thread_Mutex> ObjectFactorySingleton;
#endif