Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7331 for code/branches/doc/src


Ignore:
Timestamp:
Sep 3, 2010, 1:06:52 AM (14 years ago)
Author:
rgrieder
Message:

Added documentation for util/Clock.

Location:
code/branches/doc/src/libraries/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/doc/src/libraries/util/Clock.cc

    r6417 r7331  
    5050        long, which will eventually overflow. But if you use the subtraction of
    5151        the current time minus the last time the timer gave us and sum these up to
    52         a 64 bit integer, we get the desired result.
     52        a 64 bit integer, we get the desired result. <br>
    5353        Also mind that we don't have to store the last timer's time as unsigned long
    5454        as well because (unsigned long)tickTime_ will do exactly that.
  • code/branches/doc/src/libraries/util/Clock.h

    r6417 r7331  
    3535namespace orxonox
    3636{
     37    /** Simple real time clock based on Ogre::Timer
     38    @details
     39        The class can be used to both capture the current real time or to
     40        incrementally capture the time and then distribute that time information
     41        via Clock& references (for instance for the game tick). <br>
     42        Precision: <br>
     43        The maximum precision is given by the Ogre::Timer and that is somewhere
     44        in the microsecond range for both Windows and UNIX.
     45    @remarks
     46        For proper functionality this class MUST be used in the same thread! <br>
     47        Further more it might be possible that the Ogre::Timer has a performance
     48        caveat on Windows because it will only capture the time on the same
     49        CPU core. Confining the main thread to one process could speed up the game.
     50        See command line argument 'limitToCPU'.
     51    */
    3752    class _UtilExport Clock
    3853    {
    3954    public:
     55        //! Starts the time at 0
    4056        Clock();
    4157        ~Clock();
    4258
     59        //! Internally captures the time and stays at that particular time
    4360        void capture();
    4461
    45         unsigned long long getMicroseconds()   const { return tickTime_; }
    46         unsigned long long getMilliseconds()   const { return tickTime_ / 1000; }
    47         unsigned long      getSeconds()        const { return static_cast<long> (tickTime_ / 1000000); }
    48         float              getSecondsPrecise() const { return static_cast<float>(tickTime_ / 1000000.0f); }
     62        //! Returns the last captured absolute time in microseconds
     63        unsigned long long getMicroseconds() const
     64            { return tickTime_; }
     65        //! Returns the last captured absolute time in milliseconds
     66        unsigned long long getMilliseconds() const
     67            { return tickTime_ / 1000; }
     68        //! Returns the last captured absolute time in seconds
     69        unsigned long getSeconds() const
     70            { return static_cast<long> (tickTime_ / 1000000); }
     71        //! Returns the last captured absolute time in seconds as float
     72        float getSecondsPrecise() const
     73            { return static_cast<float>(tickTime_ / 1000000.0f); }
    4974
    50         float              getDeltaTime()      const { return tickDtFloat_; }
    51         long               getDeltaTimeMicroseconds() const { return tickDt_; }
     75        //! Returns the timespan in seconds between the last two calls to capture()
     76        float getDeltaTime() const
     77            { return tickDtFloat_; }
     78        //! Returns the timespan in microseconds between the last two calls to capture()
     79        long getDeltaTimeMicroseconds() const
     80            { return tickDt_; }
    5281
     82        /** Returns the current real time in microseconds
     83        @note
     84            This is especially useful to measure execution times because of the
     85            high precision.
     86        */
    5387        unsigned long long getRealMicroseconds() const;
    5488
    5589    private:
     90        //! Undefined
    5691        Clock(const Clock& instance);
    5792
    58         Ogre::Timer*       timer_;
    59         unsigned long long tickTime_;
    60         long               tickDt_;
    61         float              tickDtFloat_;
     93        Ogre::Timer*       timer_;       //!< Ogre timer object
     94        unsigned long long tickTime_;    //!< Currently captured time
     95        long               tickDt_;      //!< Delta time in microseconds (cache value)
     96        float              tickDtFloat_; //!< Delta time in seconds (cache value)
    6297    };
    6398}
Note: See TracChangeset for help on using the changeset viewer.