Eclipse SUMO - Simulation of Urban MObility
AGTime.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // activitygen module
5 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 // SPDX-License-Identifier: EPL-2.0
11 /****************************************************************************/
19 // Time manager: able to manipulate the time using Sumo's format (seconds)
20 /****************************************************************************/
21 #ifndef AGTIME_H
22 #define AGTIME_H
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <iostream>
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
36 class AGTime {
37 public:
38  AGTime(int seconds) :
39  mySeconds(seconds) {};
40  AGTime(int hour, int minutes) :
41  mySeconds(convert(0, hour, minutes, 0)) {};
42  AGTime(int day, int hour, int min) :
43  mySeconds(convert(day, hour, min, 0)) {};
44  AGTime(int day, int hour, int min, int sec) :
45  mySeconds(convert(day, hour, min, sec)) {};
46  AGTime(const AGTime& time);
47  bool operator==(const AGTime& time);
48  bool operator<(const AGTime& time);
49  bool operator<=(const AGTime& time);
50  void operator+=(const AGTime& time);
51  void operator+=(int seconds);
52  void operator-=(const AGTime& time);
53  AGTime operator+(const AGTime& time);
54 
55  /********************
56  * In/Out functions *
57  ********************/
58  int getDay();
59  int getHour();
60  int getMinute();
61  int getSecond();
67  int getTime();
68 
69  void setDay(int d);
70  void setHour(int h);
71  void setMinute(int m);
72  void setSecond(int s);
76  void setTime(int sec);
77 
78 
79  /**************************
80  * Manipulation functions *
81  **************************/
87  void addSeconds(int sec);
88 
94  void addMinutes(int min);
95 
101  void addHours(int hours);
102 
108  void addDays(int days);
109 
117  int getSecondsOf(double minutes);
118 
119 private:
123  int convert(int days, int hours, int minutes, int seconds);
124 
125 
126  // @brief: the seconds representing this date (day, hour, minute)
127  // @brief: used for in/out
128  int mySeconds;
129 };
130 
131 #endif
132 
133 /****************************************************************************/
AGTime::getSecondsInCurrentDay
int getSecondsInCurrentDay()
Definition: AGTime.cpp:118
AGTime::addSeconds
void addSeconds(int sec)
addition of seconds to the current moment
Definition: AGTime.cpp:180
AGTime::operator+
AGTime operator+(const AGTime &time)
Definition: AGTime.cpp:92
AGTime::addDays
void addDays(int days)
addition of days to the current moment
Definition: AGTime.cpp:165
AGTime::AGTime
AGTime(int day, int hour, int min)
Definition: AGTime.h:42
AGTime::operator-=
void operator-=(const AGTime &time)
Definition: AGTime.cpp:87
AGTime::getTime
int getTime()
: returns the number of seconds from the beginning of the first day of simulation this includes
Definition: AGTime.cpp:123
AGTime::convert
int convert(int days, int hours, int minutes, int seconds)
converts days, hours and minutes to seconds
Definition: AGTime.cpp:39
AGTime
Definition: AGTime.h:36
AGTime::operator<=
bool operator<=(const AGTime &time)
Definition: AGTime.cpp:68
AGTime::operator<
bool operator<(const AGTime &time)
Definition: AGTime.cpp:59
AGTime::setHour
void setHour(int h)
Definition: AGTime.cpp:136
AGTime::operator+=
void operator+=(const AGTime &time)
Definition: AGTime.cpp:77
AGTime::operator==
bool operator==(const AGTime &time)
Definition: AGTime.cpp:50
AGTime::getMinute
int getMinute()
Definition: AGTime.cpp:108
AGTime::mySeconds
int mySeconds
Definition: AGTime.h:126
AGTime::setSecond
void setSecond(int s)
Definition: AGTime.cpp:152
AGTime::getHour
int getHour()
Definition: AGTime.cpp:103
AGTime::AGTime
AGTime(int day, int hour, int min, int sec)
Definition: AGTime.h:44
AGTime::addMinutes
void addMinutes(int min)
addition of minutes to the current moment
Definition: AGTime.cpp:175
AGTime::getSecondsOf
int getSecondsOf(double minutes)
computes the number of seconds in the given minutes
Definition: AGTime.cpp:45
AGTime::setMinute
void setMinute(int m)
Definition: AGTime.cpp:144
AGTime::setDay
void setDay(int d)
Definition: AGTime.cpp:128
AGTime::getSecond
int getSecond()
Definition: AGTime.cpp:113
config.h
AGTime::AGTime
AGTime(int hour, int minutes)
Definition: AGTime.h:40
AGTime::getDay
int getDay()
Definition: AGTime.cpp:98
AGTime::AGTime
AGTime(int seconds)
Definition: AGTime.h:38
AGTime::addHours
void addHours(int hours)
addition of hours to the current moment
Definition: AGTime.cpp:170
AGTime::setTime
void setTime(int sec)
: sets the time from the beginning of the first day of simulation in seconds
Definition: AGTime.cpp:160