EventsCollection.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file EventsCollection.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_CORE_EVENTSCOLLECTION_HPP__
41 #define __OPENFLUID_CORE_EVENTSCOLLECTION_HPP__
42 
43 
44 #include <list>
45 
46 #include <openfluid/core/Event.hpp>
47 #include <openfluid/dllexport.hpp>
48 
49 
50 namespace openfluid { namespace core {
51 
52 class Event;
53 
54 typedef std::list<Event> EventsList_t;
55 
56 /**
57  @brief Class defining a collection of discrete events
58 */
60 {
61  private:
62 
63  EventsList_t m_Events;
64 
65  public:
66 
67  /**
68  Default constructor
69  */
70  EventsCollection() = default;
71 
73  { }
74 
75 
76  /**
77  Inserts an event in the event collection, ordered by date
78  @deprecated Since version 1.7.1. Use openfluid::core::EventsCollection::addEvent(const Event&) instead
79  */
80  [[deprecated]] bool addEvent(const Event* Ev);
81 
82  /**
83  Inserts an event in the event collection, ordered by date
84  */
85  bool addEvent(const Event& Ev);
86 
87  /**
88  Returns an event collection extracted from the current event collection, taking into account a time period
89  If some events are already in the given collection, they are not deleted. Events matching the period are appended
90  at the end of the given collection
91  @deprecated Since version 1.7.1.
92  Use openfluid::core::EventsCollection::getEventsBetween(const DateTime&,const DateTime&,EventsCollection&) const
93  instead
94  */
95  [[deprecated]] bool getEventsBetween(const DateTime& BeginDate, const DateTime& EndDate,
96  EventsCollection *Events) const ;
97 
98  /**
99  Returns an event collection extracted from the current event collection, taking into account a time period
100  If some events are already in the given collection, they are not deleted. Events matching the period are appended
101  at the end of the given collection
102  */
103  bool getEventsBetween(const DateTime& BeginDate, const DateTime& EndDate, EventsCollection& Events) const;
104 
105  /**
106  Returns the event collection as a list
107  */
108  inline EventsList_t* eventsList()
109  {
110  return &m_Events;
111  };
112 
113  /**
114  @deprecated Since version 2.1.0. Use openfluid::core::EventsCollection::eventsList() instead
115  */
116  [[deprecated]] inline EventsList_t* getEventsList()
117  {
118  return &m_Events;
119  };
120 
121  /**
122  Returns number of events in the event collection
123  */
124  inline int getCount() const
125  {
126  return m_Events.size();
127  };
128 
129  /**
130  Clears the event collection
131  */
132  void clear()
133  {
134  m_Events.clear();
135  };
136 
137  void println() const;
138 };
139 
140 
141 } } // namespace openfluid::core
142 
143 
144 #endif /* __OPENFLUID_CORE_EVENTSCOLLECTION_HPP__*/
Class for management of date and time information.
Definition: DateTime.hpp:116
Definition: Event.hpp:59
EventsList_t * getEventsList()
Definition: EventsCollection.hpp:116
int getCount() const
Definition: EventsCollection.hpp:124
void clear()
Definition: EventsCollection.hpp:132
std::list< Event > EventsList_t
Definition: EventsCollection.hpp:52
Definition: ApplicationException.hpp:47
#define OPENFLUID_API
Definition: dllexport.hpp:86
virtual ~EventsCollection()
Definition: EventsCollection.hpp:72
EventsList_t * eventsList()
Definition: EventsCollection.hpp:108
Class defining a collection of discrete events.
Definition: EventsCollection.hpp:59