Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4827 in orxonox.OLD for orxonox/trunk/src/util


Ignore:
Timestamp:
Jul 9, 2005, 12:48:50 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: state is no more singleton, but static class.
This is faster, and easier to handle, because one can just say State::getBLA() and not State::getInstance()→getBLA(); ——→>> less redundant

Location:
orxonox/trunk/src/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/state.cc

    r4597 r4827  
    2525
    2626
    27 /**
    28    \brief standard constructor
    29 */
    30 State::State ()
    31 {
    32    this->setClassID(CL_STATE, "State");
    33    this->setName("State");
    3427
    35    this->camera = NULL;
    36    this->cameraTarget = NULL;
    37 }
     28const PNode* State::camera = NULL;
     29const PNode* State::cameraTarget = NULL;
    3830
    39 /**
    40    \brief the singleton reference to this class
    41 */
    42 State* State::singletonRef = NULL;
    43 
    44 /**
    45    \brief standard deconstructor
    46 */
    47 State::~State ()
    48 {
    49   State::singletonRef = NULL;
    50 
    51 }
     31tList<WorldEntity>* State::worldEntityList = NULL;
    5232
    5333/**
     
    5636void State::setCamera(const PNode* camera, const PNode* cameraTarget)
    5737{
    58   this->camera = camera;
    59   this->cameraTarget = cameraTarget;
     38  State::camera = camera;
     39  State::cameraTarget = cameraTarget;
    6040}
  • orxonox/trunk/src/util/state.h

    r4746 r4827  
    1111// FORWARD DEFINITION
    1212class PNode;
     13class WorldEntity;
     14template<class T> class tList;
    1315
    1416//! A Singleton class, that handles some states about orxonox's objects
     
    1618
    1719 public:
    18   /** \returns a Pointer to the only object of this Class */
    19   inline static State* getInstance() { if (!singletonRef) singletonRef = new State();  return singletonRef; };
     20  // CAMERA //
     21  /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */
     22  static void setCamera(const PNode* camera, const PNode* cameraTarget);
     23  /** @returns a Pointer to the PNode of the Camera */
     24  static inline const PNode* getCamera() { return State::camera; };
     25  /** @returns a Pointer to the CameraTarget */
     26  static inline const PNode* getCameraTarget() { return State::cameraTarget; };
    2027
    21   virtual ~State();
    22 
    23   void setCamera(const PNode* camera, const PNode* cameraTarget);
    24   /** \returns a Pointer to the PNode of the Camera */
    25   const PNode* getCamera() const { return this->camera; };
    26   /** \returns a Pointer to the CameraTarget */
    27   const PNode* getCameraTarget() const { return this->cameraTarget; };
     28  // WORLD_ENTITY_LIST //
     29  /** @param worldEntityList The World's List of WorldEntities */
     30  static inline void setWorldEntityList(tList<WorldEntity>* worldEntityList) { State::worldEntityList = worldEntityList; };
     31  /** @returns the List of WorldEntities */
     32  static inline tList<WorldEntity>* getWorldEntityList() { return State::worldEntityList; };
    2833
    2934 private:
    3035  State();
    31   static State*       singletonRef;       //!< a reference to this class
    3236
    33   const PNode*        camera;             //!< A reference to the camera
    34   const PNode*        cameraTarget;       //!< a reference to the cameraTarget
     37  static const PNode*           camera;             //!< A reference to the camera
     38  static const PNode*           cameraTarget;       //!< a reference to the cameraTarget
     39
     40  static tList<WorldEntity>*    worldEntityList;    //!< The List of the worldEntities
    3541};
    3642
Note: See TracChangeset for help on using the changeset viewer.