InternalEvent.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @file InternalEvent.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_INTERNAL_EVENT
  26. #define COMMON_INTERNAL_EVENT 1
  27. #include <common/Model.hpp>
  28. #include <functional>
  29. namespace paradevs { namespace common {
  30. template < class Time >
  31. class Model;
  32. template < class Time >
  33. class InternalEvent
  34. {
  35. public:
  36. InternalEvent(const typename Time::type& time, Model < Time >* model)
  37. : _time(time), _model(model)
  38. { }
  39. virtual ~InternalEvent()
  40. { }
  41. Model < Time >* get_model() const
  42. { return _model; }
  43. typename Time::type get_time() const
  44. { return _time; }
  45. bool operator<(InternalEvent const &e) const
  46. {
  47. return _time < e._time;
  48. }
  49. bool operator==(InternalEvent const &e) const
  50. {
  51. return _time == e._time;
  52. }
  53. private:
  54. typename Time::type _time;
  55. Model < Time >* _model;
  56. };
  57. template < typename Event >
  58. struct EventCompare
  59. : std::binary_function < Event, Event, bool >
  60. {
  61. bool operator()(const Event &left, const Event &right) const
  62. {
  63. return left.get_time() > right.get_time();
  64. }
  65. };
  66. } } // namespace paradevs common
  67. #endif