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 /****************************************************************************/
20 // Time manager: able to manipulate the time using Sumo's format (seconds)
21 /****************************************************************************/
22 #ifndef AGTIME_H
23 #define AGTIME_H
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #include <config.h>
30 
31 #include <iostream>
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
37 class AGTime {
38 public:
39  AGTime() {};
40  AGTime(int seconds) :
41  sec(seconds) {};
42  AGTime(int hour, int minutes) :
43  sec(convert(0, hour, minutes, 0)) {};
44  AGTime(int day, int hour, int min) :
45  sec(convert(day, hour, min, 0)) {};
46  AGTime(int day, int hour, int min, int sec) :
47  sec(convert(day, hour, min, sec)) {};
48  AGTime(const AGTime& time);
49  bool operator==(const AGTime& time);
50  bool operator<(const AGTime& time);
51  bool operator<=(const AGTime& time);
52  void operator+=(const AGTime& time);
53  void operator+=(int seconds);
54  void operator-=(const AGTime& time);
55  AGTime operator+(const AGTime& time);
56 
57  /********************
58  * In/Out functions *
59  ********************/
60  int getDay();
61  int getHour();
62  int getMinute();
63  int getSecond();
69  int getTime();
70 
71  void setDay(int d);
72  void setHour(int h);
73  void setMinute(int m);
74  void setSecond(int s);
78  void setTime(int sec);
79 
80 
81  /**************************
82  * Manipulation functions *
83  **************************/
89  void addSeconds(int sec);
90 
96  void addMinutes(int min);
97 
103  void addHours(int hours);
104 
110  void addDays(int days);
111 
119  int getSecondsOf(double minutes);
120 
121 private:
125  int convert(int days, int hours, int minutes, int seconds);
126 
127 
128  // @brief: the seconds representing this date (day, hour, minute)
129  // @brief: used for in/out
130  int sec;
131 };
132 
133 #endif
134 
135 /****************************************************************************/
AGTime::getSecondsInCurrentDay
int getSecondsInCurrentDay()
Definition: AGTime.cpp:119
AGTime::addSeconds
void addSeconds(int sec)
addition of seconds to the current moment
Definition: AGTime.cpp:181
AGTime::operator+
AGTime operator+(const AGTime &time)
Definition: AGTime.cpp:93
AGTime::addDays
void addDays(int days)
addition of days to the current moment
Definition: AGTime.cpp:166
AGTime::AGTime
AGTime()
Definition: AGTime.h:39
AGTime::AGTime
AGTime(int day, int hour, int min)
Definition: AGTime.h:44
AGTime::operator-=
void operator-=(const AGTime &time)
Definition: AGTime.cpp:88
AGTime::getTime
int getTime()
: returns the number of seconds from the beginning of the first day of simulation this includes
Definition: AGTime.cpp:124
AGTime::convert
int convert(int days, int hours, int minutes, int seconds)
converts days, hours and minutes to seconds
Definition: AGTime.cpp:40
AGTime
Definition: AGTime.h:37
AGTime::operator<=
bool operator<=(const AGTime &time)
Definition: AGTime.cpp:69
AGTime::operator<
bool operator<(const AGTime &time)
Definition: AGTime.cpp:60
AGTime::setHour
void setHour(int h)
Definition: AGTime.cpp:137
AGTime::operator+=
void operator+=(const AGTime &time)
Definition: AGTime.cpp:78
AGTime::operator==
bool operator==(const AGTime &time)
Definition: AGTime.cpp:51
AGTime::getMinute
int getMinute()
Definition: AGTime.cpp:109
AGTime::setSecond
void setSecond(int s)
Definition: AGTime.cpp:153
AGTime::getHour
int getHour()
Definition: AGTime.cpp:104
AGTime::AGTime
AGTime(int day, int hour, int min, int sec)
Definition: AGTime.h:46
AGTime::addMinutes
void addMinutes(int min)
addition of minutes to the current moment
Definition: AGTime.cpp:176
AGTime::getSecondsOf
int getSecondsOf(double minutes)
computes the number of seconds in the given minutes
Definition: AGTime.cpp:46
AGTime::sec
int sec
Definition: AGTime.h:128
AGTime::setMinute
void setMinute(int m)
Definition: AGTime.cpp:145
AGTime::setDay
void setDay(int d)
Definition: AGTime.cpp:129
AGTime::getSecond
int getSecond()
Definition: AGTime.cpp:114
config.h
AGTime::AGTime
AGTime(int hour, int minutes)
Definition: AGTime.h:42
AGTime::getDay
int getDay()
Definition: AGTime.cpp:99
AGTime::AGTime
AGTime(int seconds)
Definition: AGTime.h:40
AGTime::addHours
void addHours(int hours)
addition of hours to the current moment
Definition: AGTime.cpp:171
AGTime::setTime
void setTime(int sec)
: sets the time from the beginning of the first day of simulation in seconds
Definition: AGTime.cpp:161