[Saga-devel] saga SVN commit 3392: /trunk/

hkaiser at cct.lsu.edu hkaiser at cct.lsu.edu
Sun Jan 25 13:02:18 CST 2009


User: hkaiser
Date: 2009/01/25 01:02 PM

Modified:
 /trunk/adaptors/default/stream/
  stream.hpp
 /trunk/saga/saga/detail/
  hold_any.hpp
 /trunk/saga/saga/packages/cpr/
  cpr_job_service.cpp, cpr_job_service.hpp
 /trunk/saga/saga/packages/job/
  job_service.cpp, job_service.hpp
 /trunk/saga/saga/packages/stream/
  stream.cpp, stream.hpp, stream_service.cpp, stream_service.hpp

Log:
 Fixed asynchronous object creation for job::service, stream::stream, stream::server and cpr::service.

File Changes:

Directory: /trunk/saga/saga/packages/cpr/
=========================================

File [modified]: cpr_job_service.cpp
Delta lines: +5 -1
===================================================================
--- trunk/saga/saga/packages/cpr/cpr_job_service.cpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/packages/cpr/cpr_job_service.cpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -54,7 +54,11 @@
           : saga::job::service (impl)
         {
         }
-        
+
+        service::service (int)
+        {
+        }
+
         service::~service (void)
         {
         }

File [modified]: cpr_job_service.hpp
Delta lines: +26 -2
===================================================================
--- trunk/saga/saga/packages/cpr/cpr_job_service.hpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/packages/cpr/cpr_job_service.hpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -46,7 +46,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 namespace saga
 {
-    namespace cpr 
+      namespace cpr 
     {
         /*! \brief The cpr::service, as a job::service, represents a resource management 
          * backend, which additionally offers checkpoint management capabilities.
@@ -71,8 +71,11 @@
             /// @cond
             /** These methods are not within API scope */
             friend class saga::impl::cpr_job_service;
+            friend saga::detail::create_default<service>;
+
             TR1::shared_ptr <saga::impl::cpr_job_service> get_impl (void) const;
             explicit service(saga::impl::cpr_job_service *impl);
+            explicit service(int);    // dummy constructor to create empty facade
             /// @endcond
 
         public:
@@ -187,8 +190,29 @@
 
         };
 
-    }}   // namespace saga::cpr
+    }
 
+    namespace detail
+    {
+        // we need to specialize the create_default template (used in hold_any) 
+        // to be able to create a truly default constructed service (empty 
+        // facade)
+        template<>
+        struct create_default<saga::cpr::service>
+        {
+            static saga::cpr::service* call()
+            {
+                return new saga::cpr::service(1);    // use dummy constructor
+            }
+            template <typename T_> static void call(T_* obj) 
+            { 
+                new (obj) saga::cpr::service(1); 
+            }
+        };
+    }
+
+}   // namespace saga
+
 ///////////////////////////////////////////////////////////////////////////////
 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
 #pragma wave option(output: null)

Directory: /trunk/saga/saga/detail/
===================================

File [modified]: hold_any.hpp
Delta lines: +18 -5
===================================================================
--- trunk/saga/saga/detail/hold_any.hpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/detail/hold_any.hpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -150,8 +150,21 @@
 
     }
     ///@endcond
-    
+
     ///////////////////////////////////////////////////////////////////////////
+    // We need to be able to default construct any type stored in a hold_any
+    // Some of the saga API objects do have a default constructor doing more
+    // than just creating an empty API (facade object), which is evil. So we
+    // use the create_default template. This template is specialized for those 
+    // picky types elsewhere.
+    template <typename T>
+    struct create_default
+    {
+        static T* call() { return new T; }
+        template <typename T_> static void call(T_* obj) { new (obj) T; }
+    };
+
+    ///////////////////////////////////////////////////////////////////////////
     class hold_any
     {
     public:
@@ -246,22 +259,22 @@
                 table->destruct(&object);    // first destruct the old content
                 if (saga::detail::internals::get_table<T>::is_small::value) {
                     // create copy on-top of object pointer itself
-                    new (&object) T;
+                    create_default<T>::call(&object);
                 }
                 else {
                     // create copy on-top of old version
-                    new (object) T;
+                    create_default<T>::call(object);
                 }
             }
             else {
                 if (saga::detail::internals::get_table<T>::is_small::value) {
                     // create copy on-top of object pointer itself
                     table->destruct(&object); // first destruct the old content
-                    new (&object) T; 
+                    create_default<T>::call(&object); 
                 }
                 else {
                     reset();                  // first delete the old content
-                    object = new T;
+                    object = create_default<T>::call();
                 }
                 table = x_table;      // update table pointer
             }

Directory: /trunk/saga/saga/packages/job/
=========================================

File [modified]: job_service.cpp
Delta lines: +4 -0
===================================================================
--- trunk/saga/saga/packages/job/job_service.cpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/packages/job/job_service.cpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -54,6 +54,10 @@
   {
   }
 
+  service::service (int)
+  {
+  }
+
   service::~service (void)
   {
   }

File [modified]: job_service.hpp
Delta lines: +26 -2
===================================================================
--- trunk/saga/saga/packages/job/job_service.hpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/packages/job/job_service.hpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -45,7 +45,7 @@
 namespace saga
 {
     namespace job {
-    
+
     /*! \brief The job_service represents a resource management backend, and as 
      *such allows to create and submit jobs, and to discover jobs. 
      *
@@ -72,8 +72,11 @@
         /// @cond
         /** These methods are not within API scope */
         friend class saga::impl::job_service;
+        friend saga::detail::create_default<service>;
+
         TR1::shared_ptr <saga::impl::job_service> get_impl (void) const;
         explicit service(saga::impl::job_service *impl);
+        explicit service(int);    // dummy constructor to create empty facade
         /// @endcond
 
     public:
@@ -214,8 +217,29 @@
 
     };
 
-}}   // namespace saga::job
+    } // saga::job
 
+    namespace detail
+    {
+        // we need to specialize the create_default template (used in hold_any) 
+        // to be able to create a truly default constructed job_service (empty 
+        // facade)
+        template<>
+        struct create_default<saga::job::service>
+        {
+            static saga::job::service* call()
+            {
+                return new saga::job::service(1);    // use dummy constructor
+            }
+            template <typename T_> static void call(T_* obj) 
+            { 
+                new (obj) saga::job::service(1); 
+            }
+        };
+    }
+
+}   // namespace saga
+
 ///////////////////////////////////////////////////////////////////////////////
 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
 #pragma wave option(output: null)

Directory: /trunk/adaptors/default/stream/
==========================================

File [modified]: stream.hpp
Delta lines: +1 -1
===================================================================
--- trunk/adaptors/default/stream/stream.hpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/adaptors/default/stream/stream.hpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -39,7 +39,7 @@
         //  base class since we are using our own instance_data type.
         //  Note: we're using dynamic_instance_data to ensure the accessed data
         //        is really of the expected type
-        typedef stream::stream_cpi_data dyn_cpi_instance_data;
+        typedef stream_cpi_data dyn_cpi_instance_data;
         friend class saga::adaptors::dynamic_instance_data<dyn_cpi_instance_data>;
         typedef      saga::adaptors::dynamic_instance_data<dyn_cpi_instance_data> 
             dyn_instance_data_type;

Directory: /trunk/saga/saga/packages/stream/
============================================

File [modified]: stream.cpp
Delta lines: +4 -0
===================================================================
--- trunk/saga/saga/packages/stream/stream.cpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/packages/stream/stream.cpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -122,6 +122,10 @@
         this->saga::object::get_impl()->init();
     }
 
+    stream::stream (int)
+    {
+    }
+
     void stream::init_attributes()
     {
         using namespace boost::assign;

File [modified]: stream.hpp
Delta lines: +25 -1
===================================================================
--- trunk/saga/saga/packages/stream/stream.hpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/packages/stream/stream.hpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -134,7 +134,10 @@
         /** These methods are not within API scope */
         TR1::shared_ptr <saga::impl::stream> get_impl (void) const;
         friend class saga::impl::stream;
+        friend saga::detail::create_default<stream>;
+
         explicit stream (saga::impl::stream *);
+        explicit stream (int);    // dummy constructor to create empty facade
         /// @endcond
 
     private:
@@ -304,8 +307,29 @@
         SAGA_CALL_PUB_2_DEF_1(write, saga::const_buffer, saga::ssize_t, 0)
     };
 
-}} 
+  }
 
+  namespace detail
+  {
+      // we need to specialize the create_default template (used in hold_any) 
+      // to be able to create a truly default constructed stream (empty 
+      // facade)
+      template<>
+      struct create_default<saga::stream::stream>
+      {
+          static saga::stream::stream* call()
+          {
+              return new saga::stream::stream(1);    // use dummy constructor
+          }
+          template <typename T_> static void call(T_* obj) 
+          { 
+              new (obj) saga::stream::stream(1); 
+          }
+      };
+  }
+
+} 
+
 // re-enable warnings about dependent classes not being exported from the dll
 #if defined(BOOST_MSVC)
 #pragma warning(pop)

File [modified]: stream_service.cpp
Delta lines: +4 -0
===================================================================
--- trunk/saga/saga/packages/stream/stream_service.cpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/packages/stream/stream_service.cpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -83,6 +83,10 @@
         init_metrics();
     }
 
+    server::server (int)
+    {
+    }
+
     void server::init_metrics()
     {
         // initialize metrics

File [modified]: stream_service.hpp
Delta lines: +25 -2
===================================================================
--- trunk/saga/saga/packages/stream/stream_service.hpp	2009-01-25 10:11:23 UTC (rev 3391)
+++ trunk/saga/saga/packages/stream/stream_service.hpp	2009-01-25 19:02:11 UTC (rev 3392)
@@ -36,7 +36,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 namespace saga
 {
-  
     namespace stream {
 
     namespace metrics 
@@ -67,7 +66,10 @@
         /** These methods are not within API scope */
         TR1::shared_ptr <saga::impl::server> get_impl (void) const;
         friend class saga::impl::server;
+        friend saga::detail::create_default<server>;
+
         explicit server (saga::impl::server* impl);
+        explicit server (int);    // dummy constructor to create empty facade
         /// @endcond
 
     private:
@@ -175,8 +177,29 @@
         SAGA_CALL_PUB_1_DEF_1(close, double, 0.0)
     };
     
-}}
+    }   // namespace saga::stream
 
+    namespace detail
+    {
+        // we need to specialize the create_default template (used in hold_any) 
+        // to be able to create a truly default constructed server (empty 
+        // facade)
+        template<>
+        struct create_default<saga::stream::server>
+        {
+            static saga::stream::server* call()
+            {
+                return new saga::stream::server(1);    // use dummy constructor
+            }
+            template <typename T_> static void call(T_* obj) 
+            { 
+                new (obj) saga::stream::server(1); 
+            }
+        };
+    }
+
+}
+
 // re-enable warnings about dependent classes not being exported from the dll
 #if defined(BOOST_MSVC)
 #pragma warning(pop)



More information about the saga-devel mailing list