SUMO - Simulation of Urban MObility
AGTime.h
Go to the documentation of this file.
00001 /****************************************************************************/
00010 // Time manager: able to manipulate the time using Sumo's format (seconds)
00011 /****************************************************************************/
00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00014 // activitygen module
00015 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
00016 /****************************************************************************/
00017 //
00018 //   This file is part of SUMO.
00019 //   SUMO is free software: you can redistribute it and/or modify
00020 //   it under the terms of the GNU General Public License as published by
00021 //   the Free Software Foundation, either version 3 of the License, or
00022 //   (at your option) any later version.
00023 //
00024 /****************************************************************************/
00025 #ifndef AGTIME_H
00026 #define AGTIME_H
00027 
00028 
00029 // ===========================================================================
00030 // included modules
00031 // ===========================================================================
00032 #ifdef _MSC_VER
00033 #include <windows_config.h>
00034 #else
00035 #include <config.h>
00036 #endif
00037 
00038 #include <iostream>
00039 
00040 
00041 // ===========================================================================
00042 // class definitions
00043 // ===========================================================================
00044 class AGTime {
00045 public:
00046     AGTime() {};
00047     AGTime(int seconds) :
00048         sec(seconds) {};
00049     AGTime(int hour, int minutes) :
00050         sec(convert(0, hour, minutes, 0)) {};
00051     AGTime(int day, int hour, int min) :
00052         sec(convert(day, hour, min, 0)) {};
00053     AGTime(int day, int hour, int min, int sec) :
00054         sec(convert(day, hour, min, sec)) {};
00055     AGTime(const AGTime& time);
00056     bool operator==(const AGTime& time);
00057     bool operator<(const AGTime& time);
00058     bool operator<=(const AGTime& time);
00059     void operator+=(const AGTime& time);
00060     void operator+=(int seconds);
00061     void operator-=(const AGTime& time);
00062     AGTime operator+(const AGTime& time);
00063 
00064     /********************
00065      * In/Out functions *
00066      ********************/
00067     int getDay();
00068     int getHour();
00069     int getMinute();
00070     int getSecond();
00071     int getSecondsInCurrentDay();
00076     int getTime();
00077 
00078     void setDay(int d);
00079     void setHour(int h);
00080     void setMinute(int m);
00081     void setSecond(int s);
00085     void setTime(int sec);
00086 
00087 
00088     /**************************
00089      * Manipulation functions *
00090      **************************/
00096     void addSeconds(int sec);
00097 
00103     void addMinutes(int min);
00104 
00110     void addHours(int hours);
00111 
00117     void addDays(int days);
00118 
00126     int getSecondsOf(SUMOReal minutes);
00127 
00128 private:
00132     int convert(int days, int hours, int minutes, int seconds);
00133 
00134 
00135     // @brief: the seconds representing this date (day, hour, minute)
00136     // @brief: used for in/out
00137     int sec;
00138 };
00139 
00140 #endif
00141 
00142 /****************************************************************************/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines