|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Time manager: able to manipulate the time using Sumo's format (seconds) 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 // activitygen module 00012 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/) 00013 /****************************************************************************/ 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; either version 2 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 #ifndef AGTIME_H 00022 #define AGTIME_H 00023 00024 00025 // =========================================================================== 00026 // included modules 00027 // =========================================================================== 00028 #ifdef _MSC_VER 00029 #include <windows_config.h> 00030 #else 00031 #include <config.h> 00032 #endif 00033 00034 #include <iostream> 00035 00036 00037 // =========================================================================== 00038 // class definitions 00039 // =========================================================================== 00040 class AGTime { 00041 public: 00042 AGTime() {}; 00043 AGTime(int seconds) : 00044 sec(seconds) {}; 00045 AGTime(int hour, int minutes) : 00046 sec(convert(0, hour, minutes, 0)) {}; 00047 AGTime(int day, int hour, int min) : 00048 sec(convert(day, hour, min, 0)) {}; 00049 AGTime(int day, int hour, int min, int sec) : 00050 sec(convert(day, hour, min, sec)) {}; 00051 AGTime(const AGTime& time); 00052 bool operator==(const AGTime& time); 00053 bool operator<(const AGTime& time); 00054 bool operator<=(const AGTime& time); 00055 void operator+=(const AGTime& time); 00056 void operator+=(int seconds); 00057 void operator-=(const AGTime& time); 00058 AGTime operator+(const AGTime& time); 00059 00060 /******************** 00061 * In/Out functions * 00062 ********************/ 00063 int getDay(); 00064 int getHour(); 00065 int getMinute(); 00066 int getSecond(); 00067 int getSecondsInCurrentDay(); 00072 int getTime(); 00073 00074 void setDay(int d); 00075 void setHour(int h); 00076 void setMinute(int m); 00077 void setSecond(int s); 00081 void setTime(int sec); 00082 00083 00084 /************************** 00085 * Manipulation functions * 00086 **************************/ 00092 void addSeconds(int sec); 00093 00099 void addMinutes(int min); 00100 00106 void addHours(int hours); 00107 00113 void addDays(int days); 00114 00122 int getSecondsOf(SUMOReal minutes); 00123 00124 private: 00128 int convert(int days, int hours, int minutes, int seconds); 00129 00130 00131 // @brief: the seconds representing this date (day, hour, minute) 00132 // @brief: used for in/out 00133 int sec; 00134 }; 00135 00136 #endif 00137 00138 /****************************************************************************/