Bladeren bron

Move context classes

Eric Ramat 7 jaren geleden
bovenliggende
commit
087ec5a8ff

+ 1 - 0
src/artis/CMakeLists.txt

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

+ 12 - 0
src/artis/builder/CMakeLists.txt

@@ -0,0 +1,12 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src)
+
+LINK_DIRECTORIES()
+
+SET(ARTIS_BUILDER_HPP Builder.hpp ModelFactory.hpp)
+
+SET(ARTIS_BUILDER_CPP Builder.cpp)
+
+ADD_SOURCES(artis-lib ${ARTIS_BUILDER_HPP} ${ARTIS_BUILDER_CPP})
+
+INSTALL(FILES ${ARTIS_BUILDER_HPP} DESTINATION ${ARTIS_INCLUDE_DIRS}/builder)

+ 12 - 0
src/artis/context/CMakeLists.txt

@@ -0,0 +1,12 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src)
+
+LINK_DIRECTORIES()
+
+SET(ARTIS_CONTEXT_HPP Context.hpp State.hpp Values.hpp)
+
+SET(ARTIS_CONTEXT_CPP)
+
+ADD_SOURCES(artis-lib ${ARTIS_CONTEXT_HPP} ${ARTIS_CONTEXT_CPP})
+
+INSTALL(FILES ${ARTIS_CONTEXT_HPP} DESTINATION ${ARTIS_INCLUDE_DIRS}/context)

+ 3 - 3
src/artis/kernel/Context.hpp

@@ -1,5 +1,5 @@
 /**
- * @file artis/kernel/Context.hpp
+ * @file artis/context/Context.hpp
  * @author See the AUTHORS file
  */
 
@@ -23,11 +23,11 @@
 #ifndef __ARTIS_KERNEL_CONTEXT_HPP
 #define __ARTIS_KERNEL_CONTEXT_HPP
 
-#include <artis/kernel/State.hpp>
+#include <artis/context/State.hpp>
 
 #include <boost/serialization/serialization.hpp>
 
-namespace artis { namespace kernel {
+namespace artis { namespace context {
 
 template < typename U >
 class Context

+ 3 - 3
src/artis/kernel/State.hpp

@@ -1,5 +1,5 @@
 /**
- * @file artis/kernel/State.hpp
+ * @file artis/context/State.hpp
  * @author See the AUTHORS file
  */
 
@@ -23,7 +23,7 @@
 #ifndef __ARTIS_KERNEL_STATE_HPP
 #define __ARTIS_KERNEL_STATE_HPP
 
-#include <artis/kernel/Values.hpp>
+#include <artis/context/Values.hpp>
 
 #include <map>
 
@@ -31,7 +31,7 @@
 #include <boost/serialization/map.hpp>
 #include <boost/serialization/vector.hpp>
 
-namespace artis { namespace kernel {
+namespace artis { namespace context {
 
 template < typename U >
 class State

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

@@ -1,5 +1,5 @@
 /**
- * @file artis/kernel/Values.hpp
+ * @file artis/context/Values.hpp
  * @author See the AUTHORS file
  */
 
@@ -30,7 +30,7 @@
 #include <boost/serialization/serialization.hpp>
 #include <boost/serialization/map.hpp>
 
-namespace artis { namespace kernel {
+namespace artis { namespace context {
 
 class Values
 {
@@ -43,16 +43,16 @@ public:
 
     template < typename T >
     void add_internal(unsigned int key, T value)
-    { _internals[key] = Value(value); }
+    { _internals[key] = kernel::Value(value); }
 
     template < typename T >
     void add_state(unsigned int key, T value)
-    { _states[key] = Value(value); }
+    { _states[key] = kernel::Value(value); }
 
     template < typename T >
     void get_internal(unsigned int key, T& value) const
     {
-        std::map < unsigned int, Value >::const_iterator it =
+        std::map < unsigned int, kernel::Value >::const_iterator it =
             _internals.find(key);
 
         if (it != _internals.end()) {
@@ -65,7 +65,7 @@ public:
     template < typename T >
     void get_state(unsigned int key, T& value) const
     {
-        std::map < unsigned int, Value >::const_iterator it =
+        std::map < unsigned int, kernel::Value >::const_iterator it =
             _states.find(key);
 
         if (it != _states.end()) {
@@ -87,8 +87,8 @@ private:
         ar & _states;
     }
 
-    std::map < unsigned int, Value > _internals;
-    std::map < unsigned int, Value > _states;
+    std::map < unsigned int, kernel::Value > _internals;
+    std::map < unsigned int, kernel::Value > _states;
 };
 
 } }

+ 2 - 2
src/artis/kernel/AbstractAtomicModel.hpp

@@ -173,14 +173,14 @@ public:
     virtual bool is_updated() const
     { return Externals < T, U >::updated; }
 
-    virtual void restore(const State < U >& state)
+    virtual void restore(const context::State < U >& state)
     {
         States < T, U >::restore(state);
         Internals < T, U >::restore(state);
         type::last_time = state.last_time();
     }
 
-    virtual void save(State < U >& state) const
+    virtual void save(context::State < U >& state) const
     {
         States < T, U >::save(state);
         Internals < T, U >::save(state);

+ 3 - 3
src/artis/kernel/AbstractCoupledModel.hpp

@@ -305,7 +305,7 @@ public:
         }
     }
 
-    virtual void restore(const State < U >& state)
+    virtual void restore(const context::State < U >& state)
     {
         typename AbstractCoupledModel::Submodels::const_iterator it =
             submodels.begin();
@@ -318,13 +318,13 @@ public:
         Internals < T, U >::restore(state);
     }
 
-    virtual void save(State < U >& state) const
+    virtual void save(context::State < U >& state) const
     {
         typename AbstractCoupledModel::Submodels::const_iterator it =
             submodels.begin();
 
         while (it != submodels.end()) {
-            State < U > substate;
+            context::State < U > substate;
 
             it->second->save(substate);
             state.add_substate(it->first, substate);

+ 3 - 4
src/artis/kernel/AbstractModel.hpp

@@ -24,8 +24,7 @@
 #define __ARTIS_KERNEL_ABSTRACT_MODEL_HPP
 
 #include <artis/kernel/Node.hpp>
-#include <artis/kernel/State.hpp>
-
+#include <artis/context/State.hpp>
 #include <artis/utils/DoubleTime.hpp>
 
 #include <boost/core/demangle.hpp>
@@ -121,9 +120,9 @@ public:
         }
     }
 
-    virtual void restore(const State < Time >& state) = 0;
+    virtual void restore(const context::State < Time >& state) = 0;
 
-    virtual void save(State < Time >& state) const = 0;
+    virtual void save(context::State < Time >& state) const = 0;
 
     void set_parent(const AbstractModel < Time, Parameters >* p)
     { parent = p; }

+ 3 - 4
src/artis/kernel/CMakeLists.txt

@@ -3,10 +3,9 @@ INCLUDE_DIRECTORIES(
 
 LINK_DIRECTORIES()
 
-SET(ARTIS_KERNEL_HPP AbstractAtomicModel.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_HPP AbstractAtomicModel.hpp AbstractCoupledModel.hpp
+  AbstractModel.hpp Externals.hpp Internals.hpp Macro.hpp Node.hpp
+  Simulator.hpp States.hpp Value.hpp)
 
 SET(ARTIS_KERNEL_CPP Simulator.cpp)
 

+ 0 - 1
src/artis/kernel/Externals.hpp

@@ -24,7 +24,6 @@
 #define __ARTIS_KERNEL_EXTERNALS_HPP
 
 #include <artis/kernel/Macro.hpp>
-#include <artis/kernel/State.hpp>
 #include <vector>
 
 namespace artis { namespace kernel {

+ 3 - 3
src/artis/kernel/Internals.hpp

@@ -24,7 +24,7 @@
 #define __ARTIS_KERNEL_INTERNALS_HPP
 
 #include <artis/kernel/Macro.hpp>
-#include <artis/kernel/State.hpp>
+#include <artis/context/State.hpp>
 #include <artis/kernel/Value.hpp>
 
 #include <vector>
@@ -84,7 +84,7 @@ public:
     const std::string& name(unsigned int index) const
     { return internal_names.at(index); }
 
-    virtual void restore(const State < U >& /* state */)
+    virtual void restore(const context::State < U >& /* state */)
     {
         // unsigned int index = 0;
 
@@ -107,7 +107,7 @@ public:
         // }
     }
 
-    virtual void save(State < U >& /* state */) const
+    virtual void save(context::State < U >& /* state */) const
     {
         // unsigned int index = 0;
 

+ 4 - 4
src/artis/kernel/Simulator.hpp

@@ -24,7 +24,7 @@
 #define ARTIS_KERNEL_SIMULATOR_HPP
 
 #include <artis/kernel/AbstractCoupledModel.hpp>
-#include <artis/kernel/Context.hpp>
+#include <artis/context/Context.hpp>
 #include <artis/observer/Observer.hpp>
 #include <artis/observer/View.hpp>
 #include <artis/utils/DoubleTime.hpp>
@@ -67,12 +67,12 @@ public:
         }
     }
 
-    void restore(const Context < utils::DoubleTime >& context)
+    void restore(const context::Context < utils::DoubleTime >& context)
     {
         _model->restore(context.state());
     }
 
-    void resume(const Context < utils::DoubleTime >& context)
+    void resume(const context::Context < utils::DoubleTime >& context)
     {
         for (double t = context.begin(); t <= context.end(); t++) {
             (*_model)(t);
@@ -80,7 +80,7 @@ public:
         }
     }
 
-    void save(Context < utils::DoubleTime >& context) const
+    void save(context::Context < utils::DoubleTime >& context) const
     {
         _model->save(context.state());
     }

+ 3 - 3
src/artis/kernel/States.hpp

@@ -23,7 +23,7 @@
 #ifndef __ARTIS_KERNEL_STATES_HPP
 #define __ARTIS_KERNEL_STATES_HPP
 
-#include <artis/kernel/State.hpp>
+#include <artis/context/State.hpp>
 #include <artis/kernel/Value.hpp>
 
 #include <vector>
@@ -69,7 +69,7 @@ public:
         }
     }
 
-    virtual void restore(const State < U >& /* state */)
+    virtual void restore(const context::State < U >& /* state */)
     {
         // unsigned int index = 0;
 
@@ -92,7 +92,7 @@ public:
         // }
     }
 
-    virtual void save(State < U >& /* state */) const
+    virtual void save(context::State < U >& /* state */) const
     {
         // unsigned int index = 0;