Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 452 for code/branches


Ignore:
Timestamp:
Dec 10, 2007, 3:21:33 PM (17 years ago)
Author:
landauf
Message:

More documentation and comments (it's so much fun!)

Location:
code/branches/objecthierarchy/src/orxonox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/core/ClassFactory.h

    r447 r452  
    11/*!
    22    @file ClassFactory.h
    3     @brief Definition of the ClassFactory class
     3    @brief Definition and implementation of the ClassFactory class
    44
    55    The ClassFactory is able to create new objects of a specific class.
  • code/branches/objecthierarchy/src/orxonox/core/Identifier.h

    r447 r452  
    11/*!
    22    @file Identifier.h
    3     @brief Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes.
     3    @brief Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes, implementation of the ClassIdentifier and SubclassIdentifier classes.
    44
    55    The Identifier contains all needed informations about the class it belongs to:
  • code/branches/objecthierarchy/src/orxonox/core/Iterator.h

    r447 r452  
    11/*!
    22    @file Iterator.h
    3     @brief Definition of the Iterator class.
     3    @brief Definition and implementation of the Iterator class.
    44
    55    The Iterator of a given class allows to iterate through an ObjectList, containing all objects of that type.
  • code/branches/objecthierarchy/src/orxonox/core/ObjectList.h

    r447 r452  
    11/*!
    22    @file ObjectList.h
    3     @brief Definition of the ObjectList class.
     3    @brief Definition and implementation of the ObjectList class.
    44
    55    The ObjectList is a double-linked list, used by Identifiers to store all objects of a given class.
  • code/branches/objecthierarchy/src/orxonox/objects/BaseObject.cc

    r258 r452  
     1/*!
     2    @file BaseObject.cc
     3    @brief Implementation of the BaseObject class.
     4*/
     5
    16#include "BaseObject.h"
    27
     
    510    CreateFactory(BaseObject);
    611
     12    /**
     13        @brief Constructor: Registers the object in the BaseObject-list.
     14    */
    715    BaseObject::BaseObject()
    816    {
     
    1018    }
    1119
     20    /**
     21        @brief Destructor
     22    */
    1223    BaseObject::~BaseObject()
    1324    {
  • code/branches/objecthierarchy/src/orxonox/objects/BaseObject.h

    r443 r452  
     1/*!
     2    @file BaseObject.h
     3    @brief Definition of the BaseObject class.
     4
     5    The BaseObject is the parent of all classes representing an instance in the game.
     6*/
     7
    18#ifndef _BaseObject_H__
    29#define _BaseObject_H__
     
    613namespace orxonox
    714{
     15    //! The BaseObject is the parent of all classes representing an instance in the game.
    816    class BaseObject : virtual public OrxonoxClass
    917    {
  • code/branches/objecthierarchy/src/orxonox/objects/Tickable.h

    r443 r452  
     1/*!
     2    @file Tickable.h
     3    @brief Definition of the Tickable interface.
     4
     5    The Tickable interface provides a tick(dt) function, that gets called every frame.
     6    float dt is the time since the last frame.
     7
     8    Attention:
     9    Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
     10    parent::tick(dt) function explicit in their implementation of tick(dt) because it's a virtual function.
     11*/
     12
    113#ifndef _Tickable_H__
    214#define _Tickable_H__
     
    719namespace orxonox
    820{
    9     class TickFrameListener;
     21    class TickFrameListener; // Forward declaration
    1022
     23    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
    1124    class Tickable : virtual public OrxonoxClass
    1225    {
    1326        public:
     27            /**
     28                @brief Gets called every frame.
     29                @param dt The time since the last frame
     30            */
    1431            virtual void tick(float dt) = 0;
    1532
    1633        protected:
     34            /**
     35                @brief Constructor: Registers the object in the Tickable-list
     36            */
    1737            Tickable() { RegisterRootObject(Tickable); }
    1838    };
    1939
     40    //! The TickFrameListener calls the tick(dt) function of all Tickables every frame.
    2041    class TickFrameListener : public Ogre::FrameListener
    2142    {
    2243        private:
     44            /** @brief Gets called before a frame gets rendered. */
    2345            bool frameStarted(const Ogre::FrameEvent &evt)
    2446            {
     47                // Iterate through all Tickables and call their tick(dt) function
    2548                for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    2649                    it->tick(evt.timeSinceLastFrame);
  • code/branches/objecthierarchy/src/orxonox/objects/Timer.h

    r443 r452  
     1/*!
     2    @file Timer.h
     3    @brief Definition and Implementation of the Timer class.
     4
     5    The Timer is a callback-object, calling a given function after a given time-interval.
     6
     7    Usage:
     8    header.h:
     9        class ClassName
     10        {
     11            public:
     12                ClassName();
     13                void functionName();
     14                Timer myTimer;
     15        };
     16
     17    source.cc:
     18        ClassName::ClassName()
     19        {
     20            myTimer.setTimer(interval_in_seconds, bLoop, this, &ClassName::functionName);
     21        }
     22
     23        void ClassName::functionName()
     24        {
     25            whateveryouwant();
     26            something(else);
     27        }
     28*/
     29
    130#ifndef _Timer_H__
    231#define _Timer_H__
     
    736namespace orxonox
    837{
     38    //! TimerBase is the parent of the Timer class.
    939    class TimerBase : public OrxonoxClass
    1040    {
     
    1242
    1343        public:
     44            /** @brief Constructor: Sets the default-values. */
    1445            TimerBase()
    1546            {
     
    2556            virtual void run() const = 0;
    2657
     58            /** @brief Starts the Timer: Function-call after 'interval' seconds. */
    2759            inline void startTimer() { this->bActive_ = true; this->time_ = this->interval_; }
     60            /** @brief Stops the Timer. */
    2861            inline void stopTimer() { this->bActive_ = false; this->time_ = this->interval_; }
     62            /** @brief Pauses the Timer - it will continue with the actual state if you unpause it. */
    2963            inline void pauseTimer() { this->bActive_ = false; }
     64            /** @brief Unpauses the Timer - continues with the given state. */
    3065            inline void unpauseTimer() { this->bActive_ = true; }
     66            /** @returns true if the Timer is active (= not stoped, not paused). */
    3167            inline bool isActive() const { return this->bActive_; }
    3268
    3369        protected:
    34             float interval_;
    35             bool bLoop_;
    36             bool bActive_;
     70            float interval_;    //!< The time-interval in seconds
     71            bool bLoop_;        //!< If true, the function gets called every 'interval' seconds
     72            bool bActive_;      //!< If true, the Timer ticks and calls the function if the time's up
    3773
    38             float time_;
     74            float time_;        //!< Internal variable, counting the time till the next function-call
    3975    };
    4076
     77    //! The Timer is a callback-object, calling a given function after a given time-interval.
    4178    template <class T = BaseObject>
    4279    class Timer : public TimerBase
    4380    {
    4481        public:
     82            /** @brief Constructor: Sets the default-values. */
    4583            Timer()
    4684            {
     
    4987            }
    5088
     89            /**
     90                @brief Constructor: Initializes the Timer with given values.
     91                @param interval The timer-interval in seconds
     92                @param bLoop If true, the function gets called every 'interval' seconds
     93                @param object The object owning the timer and the function
     94                @param timerFunction A function pointer to the function to call
     95            */
    5196            Timer(float interval, bool bLoop, T* object, void (T::*timerFunction)())
    5297            {
     
    5499            }
    55100
     101            /**
     102                @brief Initializes the Timer with given values.
     103                @param interval The timer-interval in seconds
     104                @param bLoop If true, the function gets called every 'interval' seconds
     105                @param object The object owning the timer and the function
     106                @param timerFunction A function pointer to the function to call
     107            */
    56108            void setTimer(float interval, bool bLoop, T* object, void (T::*timerFunction)())
    57109            {
     
    65117            }
    66118
     119            /** @brief Calls the given function of the given object. */
    67120            void run() const
    68121            {
     
    75128    };
    76129
     130    //! The TimerFrameListener manages all Timers in the game.
    77131    class TimerFrameListener : public Ogre::FrameListener
    78132    {
    79133        private:
     134            /** @brief Gets called before a frame gets rendered. */
    80135            bool frameStarted(const Ogre::FrameEvent &evt)
    81136            {
     137                // Iterate through all Timers
    82138                for (Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; ++it)
    83139                {
    84140                    if (it->isActive())
    85141                    {
     142                        // If active: Decrease the timer by the duration of the last frame
    86143                        it->time_ -= evt.timeSinceLastFrame;
    87144
    88145                        if (it->time_ <= 0)
    89146                        {
     147                            // It's time to call the function
    90148                            if (it->bLoop_)
    91                                 it->time_ += it->interval_;
     149                                it->time_ += it->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
    92150                            else
    93                                 it->stopTimer();
     151                                it->stopTimer(); // Stop the timer if we don't want to loop
    94152
    95153                            it->run();
Note: See TracChangeset for help on using the changeset viewer.