Sfoglia il codice sorgente

Move builder classes

Eric Ramat 7 anni fa
parent
commit
4e46339337

+ 1 - 0
src/artis/CMakeLists.txt

@@ -1,6 +1,7 @@
 INCLUDE_DIRECTORIES(
   ${CMAKE_SOURCE_DIR}/src)
 
+ADD_SUBDIRECTORY(builder)
 ADD_SUBDIRECTORY(kernel)
 ADD_SUBDIRECTORY(observer)
 ADD_SUBDIRECTORY(utils)

+ 3 - 3
src/artis/kernel/Builder.cpp

@@ -1,5 +1,5 @@
 /**
- * @file artis/kernel/Builder.cpp
+ * @file artis/builder/Builder.cpp
  * @author See the AUTHORS file
  */
 
@@ -20,8 +20,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <artis/kernel/Builder.hpp>
+#include <artis/builder/Builder.hpp>
 
-namespace artis { namespace kernel {
+namespace artis { namespace builder {
 
 } }

+ 12 - 11
src/artis/kernel/Builder.hpp

@@ -1,5 +1,5 @@
 /**
- * @file artis/kernel/Simulator.hpp
+ * @file artis/builder/Builder.hpp
  * @author See the AUTHORS file
  */
 
@@ -20,18 +20,18 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef ARTIS_KERNEL_BUILDER_HPP
-#define ARTIS_KERNEL_BUILDER_HPP
+#ifndef ARTIS_BUILDER_BUILDER_HPP
+#define ARTIS_BUILDER_BUILDER_HPP
 
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/json_parser.hpp>
 
 #include <artis/kernel/AbstractCoupledModel.hpp>
-#include <artis/kernel/ModelFactory.hpp>
+#include <artis/builder/ModelFactory.hpp>
 
 #include <sstream>
 
-namespace artis { namespace kernel {
+namespace artis { namespace builder {
 
 template < typename F, typename T, typename U, typename V, typename W >
 class Builder
@@ -52,11 +52,12 @@ public:
     { return dynamic_cast < T* >(build_model(tree)); }
 
 private:
-    AbstractModel < U, V >* build_model(boost::property_tree::ptree const& pt)
+    kernel::AbstractModel < U, V >* build_model(
+        boost::property_tree::ptree const& pt)
     {
         using boost::property_tree::ptree;
 
-        AbstractModel < U, V >* model = nullptr;
+        kernel::AbstractModel < U, V >* model = nullptr;
         std::string name;
         ptree::const_iterator it_type = pt.end();
         ptree::const_iterator it_name = pt.end();
@@ -113,7 +114,7 @@ private:
     }
 
     void build_internals(boost::property_tree::ptree const& pt,
-                         AbstractModel < U, V >* model)
+                         kernel::AbstractModel < U, V >* model)
     {
         using boost::property_tree::ptree;
 
@@ -123,7 +124,7 @@ private:
     }
 
     void build_externals(boost::property_tree::ptree const& pt,
-                         AbstractModel < U, V >* model)
+                         kernel::AbstractModel < U, V >* model)
     {
         using boost::property_tree::ptree;
 
@@ -133,7 +134,7 @@ private:
     }
 
     void build_states(boost::property_tree::ptree const& pt,
-                      AbstractModel < U, V >* model)
+                      kernel::AbstractModel < U, V >* model)
     {
         using boost::property_tree::ptree;
 
@@ -143,7 +144,7 @@ private:
     }
 
     void build_variable(boost::property_tree::ptree const& pt,
-                        AbstractModel < U, V >* /* model */)
+                        kernel::AbstractModel < U, V >* /* model */)
     {
         using boost::property_tree::ptree;
 

+ 8 - 8
src/artis/kernel/ModelFactory.hpp

@@ -1,5 +1,5 @@
 /**
- * @file artis/kernel/ModelFactory.hpp
+ * @file artis/builder/ModelFactory.hpp
  * @author See the AUTHORS file
  */
 
@@ -20,8 +20,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __ARTIS_KERNEL_MODEL_FACTORY_HPP
-#define __ARTIS_KERNEL_MODEL_FACTORY_HPP
+#ifndef __ARTIS_BUILDER_MODEL_FACTORY_HPP
+#define __ARTIS_BUILDER_MODEL_FACTORY_HPP
 
 #include <algorithm>
 #include <memory>
@@ -30,7 +30,7 @@
 
 #include <boost/core/demangle.hpp>
 
-namespace artis { namespace kernel {
+namespace artis { namespace builder {
 
 template < typename M >
 class ObjectCreator
@@ -120,14 +120,14 @@ private:
 } }
 
 template < typename M, typename I, typename O >
-std::shared_ptr < artis::kernel::ModelFactory < M, I, O > >
-artis::kernel::ModelFactory < M, I, O >::_instance;
+std::shared_ptr < artis::builder::ModelFactory < M, I, O > >
+artis::builder::ModelFactory < M, I, O >::_instance;
 
 template < typename M, typename I, typename O >
-std::once_flag artis::kernel::ModelFactory < M, I, O >::_flag;
+std::once_flag artis::builder::ModelFactory < M, I, O >::_flag;
 
 #define DECLARE_MODEL(mdl, type, fct)                                   \
-    class creator_##mdl : public artis::kernel::ObjectCreator < type > { \
+    class creator_##mdl : public artis::builder::ObjectCreator < type > { \
     public:                                                             \
     creator_##mdl()                                                     \
         {                                                               \

+ 2 - 2
src/artis/kernel/CMakeLists.txt

@@ -4,11 +4,11 @@ INCLUDE_DIRECTORIES(
 LINK_DIRECTORIES()
 
 SET(ARTIS_KERNEL_HPP AbstractAtomicModel.hpp
-  AbstractCoupledModel.hpp AbstractModel.hpp Builder.hpp Context.hpp
+  AbstractCoupledModel.hpp AbstractModel.hpp Context.hpp
   Externals.hpp Internals.hpp Macro.hpp Node.hpp Simulator.hpp State.hpp
   States.hpp Value.hpp Values.hpp)
 
-SET(ARTIS_KERNEL_CPP Simulator.cpp Builder.cpp)
+SET(ARTIS_KERNEL_CPP Simulator.cpp)
 
 ADD_SOURCES(artis-lib ${ARTIS_KERNEL_HPP} ${ARTIS_KERNEL_CPP})
 

+ 8 - 7
src/test/test.cpp

@@ -25,14 +25,15 @@
 
 #include <test/models.hpp>
 
-#include <artis/kernel/Builder.hpp>
-#include <artis/kernel/ModelFactory.hpp>
+#include <artis/builder/Builder.hpp>
+#include <artis/builder/ModelFactory.hpp>
 #include <artis/kernel/Simulator.hpp>
 #include <artis/observer/Output.hpp>
 
 #include <artis/utils/DateTime.hpp>
 
 using namespace artis::kernel;
+using namespace artis::builder;
 
 using Creator = ObjectCreator < Model >;
 using Factory = ModelFactory < Model, int, Creator >;
@@ -46,11 +47,11 @@ typedef artis::kernel::Simulator < RootModel,
                                    ModelParameters,
                                    GlobalParameters > ASimulator;
 
-typedef artis::kernel::Builder < ::Factory,
-                                 RootModel,
-                                 artis::utils::DoubleTime,
-                                 ModelParameters,
-                                 GlobalParameters > ABuilder;
+typedef artis::builder::Builder < ::Factory,
+                                  RootModel,
+                                  artis::utils::DoubleTime,
+                                  ModelParameters,
+                                  GlobalParameters > ABuilder;
 
 class AView : public artis::observer::View < artis::utils::DoubleTime,
                                              ModelParameters >