浏览代码

Use DTSS policies

Eric Ramat 5 年之前
父节点
当前提交
d9b08e29c6
共有 4 个文件被更改,包括 19 次插入54 次删除
  1. 0 17
      src/tests/dtss/graph_manager.hpp
  2. 6 5
      src/tests/dtss/tests.cpp
  3. 2 31
      src/tests/mixed/graph_manager.hpp
  4. 11 1
      src/tests/mixed/tests.cpp

+ 0 - 17
src/tests/dtss/graph_manager.hpp

@@ -37,23 +37,6 @@ namespace artis {
     namespace tests {
         namespace dtss {
 
-            struct Policy {
-                const common::Bag<common::DoubleTime>& bag() const { return _bag; }
-
-                virtual void operator()(
-                        common::DoubleTime::type /* t */,
-                        const common::ExternalEvent<common::DoubleTime>& event,
-                        common::DoubleTime::type /* tl */,
-                        common::DoubleTime::type /* tn */)
-                {
-                    _bag.clear();
-                    _bag.push_back(event);
-                }
-
-            private:
-                common::Bag<common::DoubleTime> _bag;
-            };
-
             class OnlyOneGraphManager :
                     public artis::dtss::GraphManager<common::DoubleTime,
                             artis::dtss::Parameters<common::DoubleTime>,

+ 6 - 5
src/tests/dtss/tests.cpp

@@ -28,6 +28,7 @@
 #include <tests/dtss/models.hpp>
 
 #include <artis-star/common/RootCoordinator.hpp>
+#include <artis-star/kernel/dtss/Policy.hpp>
 
 #define CATCH_CONFIG_MAIN
 
@@ -42,7 +43,7 @@ TEST_CASE("dtss/only_one", "run")
     artis::common::RootCoordinator<
             DoubleTime, artis::dtss::Coordinator<
                     DoubleTime,
-                    Policy,
+                    artis::dtss::LastBagPolicy,
                     OnlyOneGraphManager,
                     artis::dtss::Parameters<DoubleTime>,
                     artis::common::NoParameters>
@@ -58,7 +59,7 @@ TEST_CASE("dtss/only_one", "run")
         REQUIRE(artis::common::Trace<
                 DoubleTime > ::trace().elements().
                         filter_model_name("a").filter_time(t).
-                        filter_type(artis::common::TraceType::DELTA_INT).size() == 1);
+                        filter_type(artis::common::TraceType::TRANSITION).size() == 1);
         REQUIRE(artis::common::Trace<
                 DoubleTime > ::trace().elements().
                         filter_model_name("a").filter_time(t).
@@ -72,7 +73,7 @@ TEST_CASE("dtss/two", "run")
     artis::common::RootCoordinator<
             DoubleTime, artis::dtss::Coordinator<
                     DoubleTime,
-                    Policy,
+                    artis::dtss::LastBagPolicy,
                     TwoGraphManager,
                     artis::dtss::Parameters<DoubleTime> >
     > rc(context, "root",
@@ -90,7 +91,7 @@ TEST_CASE("dtss/two", "run")
         REQUIRE(artis::common::Trace<
                 DoubleTime > ::trace().elements().
                         filter_model_name("a").filter_time(t).
-                        filter_type(artis::common::TraceType::DELTA_INT).size() == 1);
+                        filter_type(artis::common::TraceType::TRANSITION).size() == 1);
         REQUIRE(artis::common::Trace<
                 DoubleTime > ::trace().elements().
                         filter_model_name("a").filter_time(t).
@@ -105,7 +106,7 @@ TEST_CASE("dtss/two", "run")
         REQUIRE(artis::common::Trace<
                 DoubleTime > ::trace().elements().
                         filter_model_name("b").filter_time(t).
-                        filter_type(artis::common::TraceType::DELTA_INT).size() == 1);
+                        filter_type(artis::common::TraceType::TRANSITION).size() == 1);
         REQUIRE(artis::common::Trace<
                 DoubleTime > ::trace().elements().
                         filter_model_name("b").filter_time(t).

+ 2 - 31
src/tests/mixed/graph_manager.hpp

@@ -31,6 +31,7 @@
 
 #include <artis-star/kernel/dtss/Coordinator.hpp>
 #include <artis-star/kernel/dtss/GraphManager.hpp>
+#include <artis-star/kernel/dtss/Policy.hpp>
 #include <artis-star/kernel/dtss/Simulator.hpp>
 
 #include <artis-star/kernel/pdevs/Coordinator.hpp>
@@ -41,36 +42,6 @@ namespace artis {
     namespace tests {
         namespace mixed {
 
-            struct LastBagPolicy {
-                const common::Bag<common::DoubleTime>& bag() const { return _bag; }
-
-                virtual void operator()(
-                        typename common::DoubleTime::type /* t */,
-                        const common::ExternalEvent<common::DoubleTime>& event,
-                        typename common::DoubleTime::type /* tl */,
-                        typename common::DoubleTime::type /* tn */)
-                {
-                    _bag.clear();
-                    _bag.push_back(event);
-                }
-
-            private:
-                common::Bag<common::DoubleTime> _bag;
-            };
-
-            struct IgnorePolicy {
-                const common::Bag<common::DoubleTime>& bag() const { return _bag; }
-
-                virtual void operator()(
-                        typename common::DoubleTime::type /* t */,
-                        const common::ExternalEvent<common::DoubleTime>& /* event */,
-                        typename common::DoubleTime::type /* tl */,
-                        typename common::DoubleTime::type /* tn */) { }
-
-            private:
-                common::Bag<common::DoubleTime> _bag;
-            };
-
             class S1GraphManager : public pdevs::GraphManager<common::DoubleTime> {
             public:
                 enum submodels {
@@ -164,7 +135,7 @@ namespace artis {
                 artis::pdevs::Coordinator<common::DoubleTime, S1GraphManager> S1;
                 artis::dtss::Coordinator<
                         common::DoubleTime,
-                        LastBagPolicy,
+                        artis::dtss::LastBagPolicy,
                         S2GraphManager,
                         artis::dtss::Parameters<common::DoubleTime>> S2;
             };

+ 11 - 1
src/tests/mixed/tests.cpp

@@ -135,12 +135,22 @@ TEST_CASE("mixed/hierachical", "run")
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(6).
                     filter_type(artis::common::TraceType::TRANSITION).at(0).get_comment()
-                    == "x = { ( 0 , a2 , 2 ) }");
+                    == "x = { }");
     REQUIRE(artis::common::Trace<
             DoubleTime > ::trace().elements().
                     filter_model_name("a2").filter_time(8).
                     filter_type(artis::common::TraceType::TRANSITION).at(0).get_comment()
                     == "x = { ( 0 , a2 , 3 ) }");
+    REQUIRE(artis::common::Trace<
+            DoubleTime > ::trace().elements().
+                    filter_model_name("a2").filter_time(10).
+                    filter_type(artis::common::TraceType::TRANSITION).at(0).get_comment()
+                    == "x = { ( 0 , a2 , 4 ) }");
+    REQUIRE(artis::common::Trace<
+            DoubleTime > ::trace().elements().
+                    filter_model_name("a2").filter_time(12).
+                    filter_type(artis::common::TraceType::TRANSITION).at(0).get_comment()
+                    == "x = { }");
 
     for (unsigned int t = 0; t <= 100; t += 2) {
         REQUIRE(artis::common::Trace<