LCOV - code coverage report
Current view: top level - src/activitygen/city - AGTime.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 6 6 100.0 %
Date: 2024-05-05 15:31:14 Functions: 0 0 -

          Line data    Source code
       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             : /****************************************************************************/
      16             : /// @file    AGTime.h
      17             : /// @author  Piotr Woznica
      18             : /// @author  Daniel Krajzewicz
      19             : /// @author  Michael Behrisch
      20             : /// @author  Walter Bamberger
      21             : /// @date    July 2010
      22             : ///
      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             : // ===========================================================================
      34             : class AGTime {
      35             : public:
      36        2633 :     AGTime(int seconds) :
      37        2633 :         mySeconds(seconds) {};
      38             :     AGTime(int hour, int minutes) :
      39             :         mySeconds(convert(0, hour, minutes, 0)) {};
      40        1132 :     AGTime(int day, int hour, int min) :
      41        1132 :         mySeconds(convert(day, hour, min, 0)) {};
      42        4616 :     AGTime(int day, int hour, int min, int sec) :
      43        4616 :         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();
      60             :     int getSecondsInCurrentDay();
      61             :     /**
      62             :      * @brief: returns the number of seconds from the beginning of the first day of simulation
      63             :      * this includes
      64             :      */
      65             :     int getTime();
      66             : 
      67             :     void setDay(int d);
      68             :     void setHour(int h);
      69             :     void setMinute(int m);
      70             :     void setSecond(int s);
      71             :     /**
      72             :      * @brief: sets the time from the beginning of the first day of simulation in seconds
      73             :      */
      74             :     void setTime(int sec);
      75             : 
      76             : 
      77             :     /**************************
      78             :      * Manipulation functions *
      79             :      **************************/
      80             :     /**
      81             :      * @brief addition of seconds to the current moment
      82             :      *
      83             :      * @param[in] sec the number of seconds
      84             :      */
      85             :     void addSeconds(int sec);
      86             : 
      87             :     /**
      88             :      * @brief addition of minutes to the current moment
      89             :      *
      90             :      * @param[in] min the number of minutes
      91             :      */
      92             :     void addMinutes(int min);
      93             : 
      94             :     /**
      95             :      * @brief addition of hours to the current moment
      96             :      *
      97             :      * @param[in] hours the number of hours to add
      98             :      */
      99             :     void addHours(int hours);
     100             : 
     101             :     /**
     102             :      * @brief addition of days to the current moment
     103             :      *
     104             :      * @param[in] days the number of days to add
     105             :      */
     106             :     void addDays(int days);
     107             : 
     108             :     /**
     109             :      * @brief computes the number of seconds in the given minutes
     110             :      *
     111             :      * @param[in] minutes, can be fraction of minutes
     112             :      *
     113             :      * @return number of seconds
     114             :      */
     115             :     int getSecondsOf(double minutes);
     116             : 
     117             : private:
     118             :     /**
     119             :      * @brief converts days, hours and minutes to seconds
     120             :      */
     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
     126             :     int mySeconds;
     127             : };

Generated by: LCOV version 1.14