[cig-commits] r13513 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Tue Dec 9 18:13:01 PST 2008


Author: luis
Date: 2008-12-09 18:13:00 -0800 (Tue, 09 Dec 2008)
New Revision: 13513

Modified:
   cs/cigma/trunk/src/Function.cpp
   cs/cigma/trunk/src/Function.h
Log:
Migrated function factory to returning a shared pointer

Modified: cs/cigma/trunk/src/Function.cpp
===================================================================
--- cs/cigma/trunk/src/Function.cpp	2008-12-10 02:12:59 UTC (rev 13512)
+++ cs/cigma/trunk/src/Function.cpp	2008-12-10 02:13:00 UTC (rev 13513)
@@ -1,27 +1,35 @@
 #include "Function.h"
 #include "FunctionRegistry.h"
+#include "tri_logger.hpp"
 #include "fn_zero.h"
-
 using namespace cigma;
+using boost::shared_ptr;
 
-// ----------------------------------------------------------------------------
+shared_ptr<Function> Function::New(const char *source)
+{
+    TRI_LOG_STR("Function::New()");
+    TRI_LOG_STR(source);
 
-Function* Function::New(const char *source)
-{
-    //
-    // XXX: Change the return type to boost::shared_ptr<Function>
-    // See http://www.boost.org/doc/libs/1_35_0/libs/smart_ptr/sp_techniques.html#encapsulation
-    //
     static FunctionRegistry registry;
-    return registry.getFunction(source);
+    shared_ptr<Function> tmp;
 
+    if (registry.hasFunction(source))
+    {
+        tmp = registry.getFunction(source);
+        return tmp;
+    }
+
     // XXX: change char* to DataPath&
     // XXX: if not found, try to instantiate Explicit, or load from shared library
+
+    return tmp;
 }
 
-// ----------------------------------------------------------------------------
+Function::Function()
+{
+}
 
-Function::Function() {}
-Function::~Function() {}
+Function::~Function()
+{
+}
 
-// ----------------------------------------------------------------------------

Modified: cs/cigma/trunk/src/Function.h
===================================================================
--- cs/cigma/trunk/src/Function.h	2008-12-10 02:12:59 UTC (rev 13512)
+++ cs/cigma/trunk/src/Function.h	2008-12-10 02:13:00 UTC (rev 13513)
@@ -18,7 +18,8 @@
     virtual int n_rank() const = 0;
     virtual bool eval(double *point, double *value) = 0;
 
-    static Function* New(const char *source); // XXX: use boost::shared_ptr<Function>
+    //static Function* New(const char *source); // XXX: use boost::shared_ptr<Function>
+    static boost::shared_ptr<Function> New(const char* source);
 };
 
 #endif



More information about the CIG-COMMITS mailing list