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 
53 class Event;
54 
55 typedef std::list<Event> EventsList_t;
56 
57 
58 /**
59  Class defining a collection of discrete events
60 
61  @cond OpenFLUID:completion
62  {
63  "contexts" : ["ANYWARE"],
64  "menupath" : ["Compute code", "Types", "Events"],
65  "title" : "Events collection",
66  "text" : "openfluid::core::EventsCollection %%SEL_START%%EvColl%%SEL_END%%"
67  }
68  @endcond
69 */
71 {
72  private:
73 
74  EventsList_t m_Events;
75 
76  public:
77 
78  /**
79  Default constructor
80  */
81  EventsCollection() = default;
82 
84  { }
85 
86 
87  /**
88  Inserts an event in the event collection, ordered by date
89  @deprecated Since version 1.7.1. Use openfluid::core::EventsCollection::addEvent(const Event&) instead
90  */
91  [[deprecated]] bool addEvent(const Event* Ev);
92 
93  /**
94  Inserts an event in the event collection, ordered by date
95  */
96  bool addEvent(const Event& Ev);
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  @deprecated Since version 1.7.1.
103  Use openfluid::core::EventsCollection::getEventsBetween(const DateTime&,const DateTime&,EventsCollection&) const
104  instead
105  */
106  [[deprecated]] bool getEventsBetween(const DateTime& BeginDate, const DateTime& EndDate,
107  EventsCollection *Events) const ;
108 
109  /**
110  Returns an event collection extracted from the current event collection, taking into account a time period
111  If some events are already in the given collection, they are not deleted. Events matching the period are appended
112  at the end of the given collection
113  */
114  bool getEventsBetween(const DateTime& BeginDate, const DateTime& EndDate, EventsCollection& Events) const;
115 
116  /**
117  Returns the event collection as a list
118  */
119  inline EventsList_t* eventsList()
120  {
121  return &m_Events;
122  };
123 
124  /**
125  @deprecated Since version 2.1.0. Use openfluid::core::EventsCollection::eventsList() instead
126  */
127  [[deprecated]] inline EventsList_t* getEventsList()
128  {
129  return &m_Events;
130  };
131 
132  /**
133  Returns number of events in the event collection
134  */
135  inline int getCount() const
136  {
137  return m_Events.size();
138  };
139 
140  /**
141  Clears the event collection
142  */
143  void clear()
144  {
145  m_Events.clear();
146  };
147 
148  void println() const;
149 };
150 
151 
152 } } // namespace openfluid::core
153 
154 
155 #endif /* __OPENFLUID_CORE_EVENTSCOLLECTION_HPP__*/
std::list< Event > EventsList_t
Definition: EventsCollection.hpp:53
Definition: EventsCollection.hpp:70
EventsList_t * eventsList()
Definition: EventsCollection.hpp:119
Class for management of date and time information.
Definition: DateTime.hpp:87
EventsList_t * getEventsList()
Definition: EventsCollection.hpp:127
Definition: Event.hpp:68
Definition: ApplicationException.hpp:47
int getCount() const
Definition: EventsCollection.hpp:135
#define OPENFLUID_API
Definition: dllexport.hpp:86
void clear()
Definition: EventsCollection.hpp:143
virtual ~EventsCollection()
Definition: EventsCollection.hpp:83