graph_manager.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @file tests/devs/graph_manager.cpp
  3. * @author The ARTIS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * ARTIS - the multimodeling and simulation environment
  8. * This file is a part of the ARTIS environment
  9. *
  10. * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.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_DEVS_GRAPH_MANAGER_HPP
  26. #define TESTS_DEVS_GRAPH_MANAGER_HPP
  27. #include <tests/devs/models.hpp>
  28. #include <artis-star/kernel/devs/Coordinator.hpp>
  29. #include <artis-star/kernel/devs/GraphManager.hpp>
  30. #include <artis-star/kernel/devs/Simulator.hpp>
  31. namespace artis {
  32. namespace tests {
  33. namespace devs {
  34. class FlatGraphManager :
  35. public artis::devs::GraphManager<common::DoubleTime> {
  36. public:
  37. enum submodels {
  38. FirstA, SecondA,
  39. FirstB, SecondB
  40. };
  41. FlatGraphManager(common::Coordinator<common::DoubleTime> *coordinator,
  42. const artis::common::NoParameters &parameters,
  43. const artis::common::NoParameters &graph_parameters)
  44. :
  45. artis::devs::GraphManager<common::DoubleTime>(coordinator, parameters,
  46. graph_parameters),
  47. a1("a1", parameters), b1("b1", parameters),
  48. a2("a2", parameters), b2("b2", parameters) {
  49. add_child(FirstA, &a1);
  50. add_child(FirstB, &b1);
  51. add_child(SecondA, &a2);
  52. add_child(SecondB, &b2);
  53. add_link(&a1, &b1);
  54. add_link(&b1, &a2);
  55. add_link(&a2, &b2);
  56. }
  57. ~FlatGraphManager() override = default;
  58. private:
  59. artis::devs::Simulator<common::DoubleTime, A> a1;
  60. artis::devs::Simulator<common::DoubleTime, B> b1;
  61. artis::devs::Simulator<common::DoubleTime, A> a2;
  62. artis::devs::Simulator<common::DoubleTime, B> b2;
  63. };
  64. class Select {
  65. public:
  66. Select() = default;
  67. common::Model<common::DoubleTime> *
  68. operator()(const common::Models<common::DoubleTime> &list) const { return list.at(0); }
  69. };
  70. }
  71. }
  72. } // namespace artis tests devs
  73. #endif