Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
AGTime.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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 are made available under the
7// terms of the Eclipse Public License 2.0 which is available at
8// https://www.eclipse.org/legal/epl-2.0/
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License 2.0 are satisfied: GNU General Public License, version 2
12// or later which is available at
13// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
15/****************************************************************************/
23// Time manager: able to manipulate the time using Sumo's format (seconds)
24/****************************************************************************/
25#pragma once
26#include <config.h>
27
28#include <iostream>
29
30
31// ===========================================================================
32// class definitions
33// ===========================================================================
34class AGTime {
35public:
36 AGTime(int seconds) :
37 mySeconds(seconds) {};
38 AGTime(int hour, int minutes) :
39 mySeconds(convert(0, hour, minutes, 0)) {};
40 AGTime(int day, int hour, int min) :
41 mySeconds(convert(day, hour, min, 0)) {};
42 AGTime(int day, int hour, int min, int sec) :
43 mySeconds(convert(day, hour, min, sec)) {};
44 AGTime(const AGTime& time);
45 bool operator==(const AGTime& time);
46 bool operator<(const AGTime& time);
47 bool operator<=(const AGTime& time);
48 void operator+=(const AGTime& time);
49 void operator+=(int seconds);
50 void operator-=(const AGTime& time);
51 AGTime operator+(const AGTime& time);
52
53 /********************
54 * In/Out functions *
55 ********************/
56 int getDay();
57 int getHour();
58 int getMinute();
59 int getSecond();
65 int getTime();
66
67 void setDay(int d);
68 void setHour(int h);
69 void setMinute(int m);
70 void setSecond(int s);
74 void setTime(int sec);
75
76
77 /**************************
78 * Manipulation functions *
79 **************************/
85 void addSeconds(int sec);
86
92 void addMinutes(int min);
93
99 void addHours(int hours);
100
106 void addDays(int days);
107
115 int getSecondsOf(double minutes);
116
117private:
121 int convert(int days, int hours, int minutes, int seconds);
122
123
124 // @brief: the seconds representing this date (day, hour, minute)
125 // @brief: used for in/out
127};
void operator-=(const AGTime &time)
Definition AGTime.cpp:86
bool operator==(const AGTime &time)
Definition AGTime.cpp:49
int getSecond()
Definition AGTime.cpp:112
bool operator<=(const AGTime &time)
Definition AGTime.cpp:67
int getTime()
: returns the number of seconds from the beginning of the first day of simulation this includes
Definition AGTime.cpp:122
void setSecond(int s)
Definition AGTime.cpp:151
AGTime operator+(const AGTime &time)
Definition AGTime.cpp:91
int getSecondsInCurrentDay()
Definition AGTime.cpp:117
void setDay(int d)
Definition AGTime.cpp:127
void setHour(int h)
Definition AGTime.cpp:135
int convert(int days, int hours, int minutes, int seconds)
converts days, hours and minutes to seconds
Definition AGTime.cpp:38
void addMinutes(int min)
addition of minutes to the current moment
Definition AGTime.cpp:174
void setTime(int sec)
: sets the time from the beginning of the first day of simulation in seconds
Definition AGTime.cpp:159
void operator+=(const AGTime &time)
Definition AGTime.cpp:76
int getSecondsOf(double minutes)
computes the number of seconds in the given minutes
Definition AGTime.cpp:44
AGTime(int hour, int minutes)
Definition AGTime.h:38
void setMinute(int m)
Definition AGTime.cpp:143
bool operator<(const AGTime &time)
Definition AGTime.cpp:58
void addDays(int days)
addition of days to the current moment
Definition AGTime.cpp:164
int getMinute()
Definition AGTime.cpp:107
void addSeconds(int sec)
addition of seconds to the current moment
Definition AGTime.cpp:179
int getHour()
Definition AGTime.cpp:102
int getDay()
Definition AGTime.cpp:97
AGTime(int seconds)
Definition AGTime.h:36
int mySeconds
Definition AGTime.h:126
void addHours(int hours)
addition of hours to the current moment
Definition AGTime.cpp:169
AGTime(int day, int hour, int min, int sec)
Definition AGTime.h:42
AGTime(int day, int hour, int min)
Definition AGTime.h:40