libt2n: (gerd) some refactoring, documentation improvement
[libt2n] / src / client_wrapper.hxx
index 0822af0..faf906b 100644 (file)
@@ -150,14 +150,21 @@ class T2nSingletonWrapper : public T2nSingletonWrapperMessages
 #undef _GEN_PREP
 #undef _GEN_ARG
 
-        T2nSingletonWrapper()
+        T2nSingletonWrapper(std::auto_ptr<Client> stub)
+        {
+            Stub=stub;
+        }
+
+        static void init()
         {
             if (WrappedConnection.get() == NULL)
                 throw std::logic_error(NotInitializedMessage);
 
-            Stub=std::auto_ptr<Client>(new Client(*(WrappedConnection->get_connection()),
+            std::auto_ptr<Client> stub(new Client(*(WrappedConnection->get_connection()),
                 WrappedConnection->get_command_timeout_usec(),
                 WrappedConnection->get_hello_timeout_usec()));
+
+            SingletonObject=std::auto_ptr<T2nSingletonWrapper>(new T2nSingletonWrapper(stub));
         }
 
         template< typename R >
@@ -188,7 +195,7 @@ class T2nSingletonWrapper : public T2nSingletonWrapperMessages
         static void ensure_singleton_there(void)
         {
             if (SingletonObject.get() == NULL)
-                SingletonObject=std::auto_ptr<T2nSingletonWrapper>(new T2nSingletonWrapper());
+                init();
         }
 
         // create an exec-method for each possible number of parameters