Model.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * @file Model.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. #ifndef COMMON_MODEL
  26. #define COMMON_MODEL 1
  27. #include <common/Bag.hpp>
  28. #include <common/ExternalEvent.hpp>
  29. #include <common/Time.hpp>
  30. #include <iostream>
  31. #include <vector>
  32. namespace paradevs { namespace common {
  33. class Bag;
  34. class ExternalEvent;
  35. class Model
  36. {
  37. public:
  38. Model(const std::string& name);
  39. virtual ~Model();
  40. virtual void observation(std::ostream& file) const =0;
  41. virtual void output(common::Time t) =0;
  42. virtual void post_message(common::Time t,
  43. const common::ExternalEvent& event) = 0;
  44. virtual common::Time start(common::Time t) =0;
  45. virtual common::Time transition(common::Time t) =0;
  46. virtual const std::string& get_name() const
  47. { return _name; }
  48. Model* get_parent() const
  49. { return _parent; }
  50. void set_parent(Model* parent)
  51. { _parent = parent; }
  52. void add_event(const common::ExternalEvent& event);
  53. void clear_bag();
  54. const common::Bag& get_bag() const;
  55. unsigned int event_number() const;
  56. protected:
  57. Time _tl;
  58. Time _tn;
  59. private :
  60. Model* _parent;
  61. std::string _name;
  62. Bag* _inputs;
  63. };
  64. class Models : public std::vector < Model* >
  65. {
  66. public:
  67. Models()
  68. { }
  69. virtual ~Models()
  70. { }
  71. std::string to_string() const;
  72. };
  73. } } // namespace paradevs common
  74. #endif