FNSS C++ library
C++ API for the Fast Network Simulation Setup (FNSS) toolchain
 All Classes Functions Typedefs Pages
event-schedule.h
1 #ifndef EVENT_SCHEDULE_H
2 #define EVENT_SCHEDULE_H
3 
4 #include "event.h"
5 #include "quantity.h"
6 #include "units.h"
7 
8 #include <vector>
9 #include <exception>
10 #include <sstream>
11 
12 namespace fnss {
13 
22 public:
29  EventSchedule(const Quantity &startTime_ = Quantity("0s", Units::Time),
30  const Quantity &endTime_ = Quantity("0s", Units::Time));
31 
37  Quantity getStartTime() const;
38 
44  void setStartTime(const Quantity &time);
45 
51  Quantity getEndTime() const;
52 
58  void setEndTime(const Quantity &time);
59 
65  unsigned int size() const;
66 
76  Event getEvent(unsigned int index) const;
77 
83  void addEvent(const Event &event);
84 
93  void removeEvent(unsigned int index);
94 
95  class IndexOutOfBoundsException : public std::exception {
96  public:
97  IndexOutOfBoundsException(unsigned int index) throw() {
98  std::stringstream ss;
99  ss<<"The EventSchedule index "<<index<<" was out-of-bounds.";
100  this->exceptionStr = ss.str();
101  }
102 
103  ~IndexOutOfBoundsException() throw() {
104  }
105 
106  const char* what() const throw() {
107  return this->exceptionStr.c_str();
108  }
109 
110  private:
111  std::string exceptionStr;
112  };
113 
114 private:
115  Quantity startTime;
116  Quantity endTime;
117  typedef std::vector<Event> scheduleType;
118  scheduleType schedule;
119 };
120 
121 } //namespace
122 
123 #endif //EVENT_SCHEDULE_H
void setStartTime(const Quantity &time)
Definition: event-schedule.cpp:14
Definition: event-schedule.h:21
void setEndTime(const Quantity &time)
Definition: event-schedule.cpp:22
unsigned int size() const
Definition: event-schedule.cpp:26
Quantity getStartTime() const
Definition: event-schedule.cpp:10
void addEvent(const Event &event)
Definition: event-schedule.cpp:37
Definition: event.h:18
EventSchedule(const Quantity &startTime_=Quantity("0s", Units::Time), const Quantity &endTime_=Quantity("0s", Units::Time))
Definition: event-schedule.cpp:7
void removeEvent(unsigned int index)
Definition: event-schedule.cpp:42
Quantity getEndTime() const
Definition: event-schedule.cpp:18
Definition: event-schedule.h:95
Definition: quantity.h:16
Event getEvent(unsigned int index) const
Definition: event-schedule.cpp:30