SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.sourceforge.net/
13 // Copyright (C) 2001-2012 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 /****************************************************************************/