Examples.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @file 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 <devs/Builder.hpp>
  26. #include <devs/Dynamics.hpp>
  27. #include <devs/Simulator.hpp>
  28. namespace paradevs {
  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(const Time& t);
  37. virtual void dext(const Time& /* e */, const Message& msg);
  38. virtual Time start();
  39. virtual Time ta() const;
  40. virtual Messages lambda() const;
  41. virtual void observation(std::ostream& /* file */) const;
  42. private:
  43. enum Phase { WAIT, SEND };
  44. Phase _phase;
  45. };
  46. class B : public Dynamics
  47. {
  48. public:
  49. B(const std::string& name) : Dynamics(name)
  50. { }
  51. virtual ~B()
  52. { }
  53. virtual void dint(const Time& t);
  54. virtual void dext(const Time& /* e */, const Message& msg);
  55. virtual Time start();
  56. virtual Time ta() const;
  57. virtual Messages lambda() const;
  58. virtual void observation(std::ostream& /* file */) const;
  59. private:
  60. enum Phase { WAIT, SEND };
  61. Phase _phase;
  62. };
  63. class MyBuilder : public Builder
  64. {
  65. public:
  66. MyBuilder()
  67. { }
  68. virtual ~MyBuilder()
  69. { }
  70. virtual Coordinator* build() const;
  71. };
  72. } // namespace paradevs