pdevs_tests.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * @file pdevs_examples.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 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. #include <common/Builder.hpp>
  26. #include <pdevs/Dynamics.hpp>
  27. #include <pdevs/Simulator.hpp>
  28. namespace paradevs { namespace pdevs {
  29. class A : public Dynamics
  30. {
  31. public:
  32. A(const std::string& name) : Dynamics(name)
  33. { }
  34. virtual ~A()
  35. { }
  36. virtual void dint(common::Time /* t */);
  37. virtual void dext(common::Time /* t */, common::Time /* e */,
  38. const common::Messages& /* msgs */);
  39. virtual void dconf(common::Time /* t */, common::Time /* e */,
  40. const common::Messages& /* msgs */);
  41. virtual common::Time start(common::Time /* t */);
  42. virtual common::Time ta(common::Time /* t */) const;
  43. virtual common::Messages lambda(common::Time /* t */) const;
  44. virtual void observation(std::ostream& /* file */) const;
  45. private:
  46. enum Phase { WAIT, SEND };
  47. Phase _phase;
  48. };
  49. class B : public Dynamics
  50. {
  51. public:
  52. B(const std::string& name) : Dynamics(name)
  53. { }
  54. virtual ~B()
  55. { }
  56. virtual void dint(common::Time /* t */);
  57. virtual void dext(common::Time /* t */, common::Time /* e */,
  58. const common::Messages& /* msgs */);
  59. virtual void dconf(common::Time /* t */, common::Time /* e */,
  60. const common::Messages& /* msgs */);
  61. virtual common::Time start(common::Time /* t */);
  62. virtual common::Time ta(common::Time /* t */) const;
  63. virtual common::Messages lambda(common::Time /* t */) const;
  64. virtual void observation(std::ostream& /* file */) const;
  65. private:
  66. enum Phase { WAIT, SEND };
  67. Phase _phase;
  68. };
  69. class HierachicalBuilder : public common::Builder
  70. {
  71. public:
  72. HierachicalBuilder()
  73. { }
  74. virtual ~HierachicalBuilder()
  75. { }
  76. virtual common::Model* build() const;
  77. };
  78. class OnlyOneBuilder : public common::Builder
  79. {
  80. public:
  81. OnlyOneBuilder()
  82. { }
  83. virtual ~OnlyOneBuilder()
  84. { }
  85. virtual common::Model* build() const;
  86. };
  87. class FlatBuilder : public common::Builder
  88. {
  89. public:
  90. FlatBuilder()
  91. { }
  92. virtual ~FlatBuilder()
  93. { }
  94. virtual common::Model* build() const;
  95. };
  96. } } // namespace paradevs pdevs