Policy.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * @file kernel/dtss/Coordinator.hpp
  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 DTSS_POLICY
  26. #define DTSS_POLICY
  27. #include <artis-star/common/Bag.hpp>
  28. #include <cassert>
  29. namespace artis {
  30. namespace dtss {
  31. class Policy
  32. {
  33. public:
  34. Policy() = default;
  35. virtual ~Policy() = default;
  36. const common::Bag<common::DoubleTime> &bag() const
  37. { return _bag; }
  38. void clear()
  39. { _bag.clear(); }
  40. void push(const common::ExternalEvent<common::DoubleTime> &event)
  41. { _bag.push_back(event); }
  42. private:
  43. common::Bag<common::DoubleTime> _bag;
  44. };
  45. class AllEventsPolicy : public Policy
  46. {
  47. public:
  48. AllEventsPolicy() = default;
  49. virtual ~AllEventsPolicy() = default;
  50. virtual void operator()(
  51. typename common::DoubleTime::type /* t */,
  52. const common::ExternalEvent<common::DoubleTime> &event,
  53. typename common::DoubleTime::type /* tl */,
  54. typename common::DoubleTime::type /* tn */)
  55. {
  56. push(event);
  57. }
  58. };
  59. class LastBagPolicy : public Policy
  60. {
  61. public:
  62. LastBagPolicy() = default;
  63. virtual ~LastBagPolicy() = default;
  64. virtual void operator()(
  65. typename common::DoubleTime::type /* t */,
  66. const common::ExternalEvent<common::DoubleTime> &event,
  67. typename common::DoubleTime::type /* tl */,
  68. typename common::DoubleTime::type /* tn */)
  69. {
  70. clear();
  71. push(event);
  72. }
  73. };
  74. class IgnorePolicy : public Policy
  75. {
  76. public:
  77. IgnorePolicy() = default;
  78. virtual ~IgnorePolicy() = default;
  79. virtual void operator()(
  80. typename common::DoubleTime::type /* t */,
  81. const common::ExternalEvent<common::DoubleTime> & /* event */,
  82. typename common::DoubleTime::type /* tl */,
  83. typename common::DoubleTime::type /* tn */)
  84. {}
  85. };
  86. }
  87. }
  88. #endif