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-2017 German Aerospace Center (DLR) and others.
4 // activitygen module
5 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6 /****************************************************************************/
7 //
8 // This program and the accompanying materials
9 // are made available under the terms of the Eclipse Public License v2.0
10 // which accompanies this distribution, and is available at
11 // http://www.eclipse.org/legal/epl-v20.html
12 //
13 /****************************************************************************/
22 // Time manager: able to manipulate the time using Sumo's format (seconds)
23 /****************************************************************************/
24 #ifndef AGTIME_H
25 #define AGTIME_H
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <iostream>
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
43 class AGTime {
44 public:
45  AGTime() {};
46  AGTime(int seconds) :
47  sec(seconds) {};
48  AGTime(int hour, int minutes) :
49  sec(convert(0, hour, minutes, 0)) {};
50  AGTime(int day, int hour, int min) :
51  sec(convert(day, hour, min, 0)) {};
52  AGTime(int day, int hour, int min, int sec) :
53  sec(convert(day, hour, min, sec)) {};
54  AGTime(const AGTime& time);
55  bool operator==(const AGTime& time);
56  bool operator<(const AGTime& time);
57  bool operator<=(const AGTime& time);
58  void operator+=(const AGTime& time);
59  void operator+=(int seconds);
60  void operator-=(const AGTime& time);
61  AGTime operator+(const AGTime& time);
62 
63  /********************
64  * In/Out functions *
65  ********************/
66  int getDay();
67  int getHour();
68  int getMinute();
69  int getSecond();
75  int getTime();
76 
77  void setDay(int d);
78  void setHour(int h);
79  void setMinute(int m);
80  void setSecond(int s);
84  void setTime(int sec);
85 
86 
87  /**************************
88  * Manipulation functions *
89  **************************/
95  void addSeconds(int sec);
96 
102  void addMinutes(int min);
103 
109  void addHours(int hours);
110 
116  void addDays(int days);
117 
125  int getSecondsOf(double minutes);
126 
127 private:
131  int convert(int days, int hours, int minutes, int seconds);
132 
133 
134  // @brief: the seconds representing this date (day, hour, minute)
135  // @brief: used for in/out
136  int sec;
137 };
138 
139 #endif
140 
141 /****************************************************************************/
int getHour()
Definition: AGTime.cpp:110
int convert(int days, int hours, int minutes, int seconds)
converts days, hours and minutes to seconds
Definition: AGTime.cpp:46
void setDay(int d)
Definition: AGTime.cpp:135
Definition: AGTime.h:43
AGTime(int day, int hour, int min, int sec)
Definition: AGTime.h:52
void operator-=(const AGTime &time)
Definition: AGTime.cpp:94
int getSecond()
Definition: AGTime.cpp:120
void addDays(int days)
addition of days to the current moment
Definition: AGTime.cpp:172
bool operator<=(const AGTime &time)
Definition: AGTime.cpp:75
void addHours(int hours)
addition of hours to the current moment
Definition: AGTime.cpp:177
bool operator<(const AGTime &time)
Definition: AGTime.cpp:66
AGTime(int hour, int minutes)
Definition: AGTime.h:48
bool operator==(const AGTime &time)
Definition: AGTime.cpp:57
AGTime(int day, int hour, int min)
Definition: AGTime.h:50
AGTime operator+(const AGTime &time)
Definition: AGTime.cpp:99
void operator+=(const AGTime &time)
Definition: AGTime.cpp:84
int sec
Definition: AGTime.h:136
void addMinutes(int min)
addition of minutes to the current moment
Definition: AGTime.cpp:182
void addSeconds(int sec)
addition of seconds to the current moment
Definition: AGTime.cpp:187
AGTime()
Definition: AGTime.h:45
void setMinute(int m)
Definition: AGTime.cpp:151
int getSecondsInCurrentDay()
Definition: AGTime.cpp:125
void setSecond(int s)
Definition: AGTime.cpp:159
int getSecondsOf(double minutes)
computes the number of seconds in the given minutes
Definition: AGTime.cpp:52
int getTime()
: returns the number of seconds from the beginning of the first day of simulation this includes ...
Definition: AGTime.cpp:130
void setHour(int h)
Definition: AGTime.cpp:143
int getMinute()
Definition: AGTime.cpp:115
AGTime(int seconds)
Definition: AGTime.h:46
void setTime(int sec)
: sets the time from the beginning of the first day of simulation in seconds
Definition: AGTime.cpp:167
int getDay()
Definition: AGTime.cpp:105