SUMO - Simulation of Urban MObility
AGTime.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Time manager: able to manipulate the time using Sumo's format (seconds)
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
14 // activitygen module
15 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 #ifndef AGTIME_H
26 #define AGTIME_H
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <iostream>
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
44 class AGTime {
45 public:
46  AGTime() {};
47  AGTime(int seconds) :
48  sec(seconds) {};
49  AGTime(int hour, int minutes) :
50  sec(convert(0, hour, minutes, 0)) {};
51  AGTime(int day, int hour, int min) :
52  sec(convert(day, hour, min, 0)) {};
53  AGTime(int day, int hour, int min, int sec) :
54  sec(convert(day, hour, min, sec)) {};
55  AGTime(const AGTime& time);
56  bool operator==(const AGTime& time);
57  bool operator<(const AGTime& time);
58  bool operator<=(const AGTime& time);
59  void operator+=(const AGTime& time);
60  void operator+=(int seconds);
61  void operator-=(const AGTime& time);
62  AGTime operator+(const AGTime& time);
63 
64  /********************
65  * In/Out functions *
66  ********************/
67  int getDay();
68  int getHour();
69  int getMinute();
70  int getSecond();
76  int getTime();
77 
78  void setDay(int d);
79  void setHour(int h);
80  void setMinute(int m);
81  void setSecond(int s);
85  void setTime(int sec);
86 
87 
88  /**************************
89  * Manipulation functions *
90  **************************/
96  void addSeconds(int sec);
97 
103  void addMinutes(int min);
104 
110  void addHours(int hours);
111 
117  void addDays(int days);
118 
126  int getSecondsOf(SUMOReal minutes);
127 
128 private:
132  int convert(int days, int hours, int minutes, int seconds);
133 
134 
135  // @brief: the seconds representing this date (day, hour, minute)
136  // @brief: used for in/out
137  int sec;
138 };
139 
140 #endif
141 
142 /****************************************************************************/
int getHour()
Definition: AGTime.cpp:111
int convert(int days, int hours, int minutes, int seconds)
converts days, hours and minutes to seconds
Definition: AGTime.cpp:47
void setDay(int d)
Definition: AGTime.cpp:136
#define min(a, b)
Definition: polyfonts.c:66
Definition: AGTime.h:44
AGTime(int day, int hour, int min, int sec)
Definition: AGTime.h:53
void operator-=(const AGTime &time)
Definition: AGTime.cpp:95
int getSecondsOf(SUMOReal minutes)
computes the number of seconds in the given minutes
Definition: AGTime.cpp:53
int getSecond()
Definition: AGTime.cpp:121
void addDays(int days)
addition of days to the current moment
Definition: AGTime.cpp:173
bool operator<=(const AGTime &time)
Definition: AGTime.cpp:76
void addHours(int hours)
addition of hours to the current moment
Definition: AGTime.cpp:178
bool operator<(const AGTime &time)
Definition: AGTime.cpp:67
AGTime(int hour, int minutes)
Definition: AGTime.h:49
bool operator==(const AGTime &time)
Definition: AGTime.cpp:58
AGTime(int day, int hour, int min)
Definition: AGTime.h:51
AGTime operator+(const AGTime &time)
Definition: AGTime.cpp:100
void operator+=(const AGTime &time)
Definition: AGTime.cpp:85
int sec
Definition: AGTime.h:137
void addMinutes(int min)
addition of minutes to the current moment
Definition: AGTime.cpp:183
void addSeconds(int sec)
addition of seconds to the current moment
Definition: AGTime.cpp:188
AGTime()
Definition: AGTime.h:46
void setMinute(int m)
Definition: AGTime.cpp:152
int getSecondsInCurrentDay()
Definition: AGTime.cpp:126
void setSecond(int s)
Definition: AGTime.cpp:160
int getTime()
: returns the number of seconds from the beginning of the first day of simulation this includes ...
Definition: AGTime.cpp:131
void setHour(int h)
Definition: AGTime.cpp:144
int getMinute()
Definition: AGTime.cpp:116
#define SUMOReal
Definition: config.h:215
AGTime(int seconds)
Definition: AGTime.h:47
void setTime(int sec)
: sets the time from the beginning of the first day of simulation in seconds
Definition: AGTime.cpp:168
int getDay()
Definition: AGTime.cpp:106