graph_manager.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * @file tests/dtss/graph_manager.hpp
  3. * @author The PARADEVS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * PARADEVS - the multimodeling and simulation environment
  8. * This file is a part of the PARADEVS environment
  9. *
  10. * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #ifndef TESTS_DTSS_GRAPH_MANAGER_HPP
  26. #define TESTS_DTSS_GRAPH_MANAGER_HPP 1
  27. #include <tests/dtss/models.hpp>
  28. #include <paradevs/kernel/dtss/Coordinator.hpp>
  29. #include <paradevs/kernel/dtss/GraphManager.hpp>
  30. #include <paradevs/kernel/dtss/Simulator.hpp>
  31. namespace paradevs { namespace tests { namespace dtss {
  32. struct Policy
  33. {
  34. const common::Bag < common::DoubleTime >& bag() const
  35. { return _bag; }
  36. virtual void operator()(
  37. common::DoubleTime::type /* t */,
  38. const common::ExternalEvent < common::DoubleTime >& event,
  39. common::DoubleTime::type /* tl */,
  40. common::DoubleTime::type /* tn */)
  41. {
  42. _bag.clear();
  43. _bag.push_back(event);
  44. }
  45. private:
  46. common::Bag < common::DoubleTime > _bag;
  47. };
  48. class OnlyOneGraphManager :
  49. public paradevs::dtss::GraphManager < common::DoubleTime,
  50. paradevs::common::NoParameters >
  51. {
  52. public:
  53. OnlyOneGraphManager(common::Coordinator < common::DoubleTime >* coordinator,
  54. const paradevs::common::NoParameters& parameters) :
  55. paradevs::dtss::GraphManager < common::DoubleTime,
  56. paradevs::common::NoParameters >(
  57. coordinator, parameters),
  58. a("a", 1., common::NoParameters())
  59. {
  60. add_child(&a);
  61. }
  62. virtual ~OnlyOneGraphManager()
  63. { }
  64. private:
  65. paradevs::dtss::Simulator < common::DoubleTime, A > a;
  66. };
  67. class TwoGraphManager :
  68. public paradevs::dtss::GraphManager < common::DoubleTime,
  69. paradevs::common::NoParameters >
  70. {
  71. public:
  72. TwoGraphManager(common::Coordinator < common::DoubleTime >* coordinator,
  73. const paradevs::common::NoParameters& parameters) :
  74. paradevs::dtss::GraphManager < common::DoubleTime,
  75. paradevs::common::NoParameters >(
  76. coordinator, parameters),
  77. a("a", 1., common::NoParameters()), b("b", 1., common::NoParameters())
  78. {
  79. add_child(&a);
  80. add_child(&b);
  81. a.add_out_port("out");
  82. b.add_in_port("in");
  83. add_link(&a, "out", &b, "in");
  84. }
  85. virtual ~TwoGraphManager()
  86. { }
  87. private:
  88. paradevs::dtss::Simulator < common::DoubleTime, A > a;
  89. paradevs::dtss::Simulator < common::DoubleTime, B > b;
  90. };
  91. } } } // namespace paradevs tests dtss
  92. #endif