graph_manager.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. {
  37. public:
  38. enum submodels
  39. {
  40. FirstA, SecondA,
  41. FirstB, SecondB
  42. };
  43. FlatGraphManager(common::Coordinator<common::DoubleTime> *coordinator,
  44. const artis::common::NoParameters &parameters,
  45. const artis::common::NoParameters &graph_parameters)
  46. :
  47. artis::devs::GraphManager<common::DoubleTime>(coordinator, parameters,
  48. graph_parameters),
  49. a1("a1", parameters), b1("b1", parameters),
  50. a2("a2", parameters), b2("b2", parameters)
  51. {
  52. add_child(FirstA, &a1);
  53. add_child(FirstB, &b1);
  54. add_child(SecondA, &a2);
  55. add_child(SecondB, &b2);
  56. add_link(&a1, &b1);
  57. add_link(&b1, &a2);
  58. add_link(&a2, &b2);
  59. }
  60. ~FlatGraphManager() override = default;
  61. private:
  62. artis::devs::Simulator<common::DoubleTime, A> a1;
  63. artis::devs::Simulator<common::DoubleTime, B> b1;
  64. artis::devs::Simulator<common::DoubleTime, A> a2;
  65. artis::devs::Simulator<common::DoubleTime, B> b2;
  66. };
  67. class Select
  68. {
  69. public:
  70. Select() = default;
  71. common::Model<common::DoubleTime> *
  72. operator()(const common::Models<common::DoubleTime> &list) const
  73. { return list.at(0); }
  74. };
  75. }
  76. }
  77. } // namespace artis tests devs
  78. #endif