Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4519 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jun 6, 2005, 2:36:04 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: changed all getInstances into inline functions to save some (minor) time

Location:
orxonox/trunk/src
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/event/event_handler.cc

    r4457 r4519  
    5555*/
    5656EventHandler* EventHandler::singletonRef = NULL;
    57 
    58 
    59 /**
    60    \returns a Pointer to this Class
    61 */
    62 EventHandler* EventHandler::getInstance(void)
    63 {
    64   if (!EventHandler::singletonRef)
    65     EventHandler::singletonRef = new EventHandler();
    66   return EventHandler::singletonRef;
    67 }
    6857
    6958
  • orxonox/trunk/src/lib/event/event_handler.h

    r4457 r4519  
    1919
    2020 public:
    21   static EventHandler* getInstance(void);
    2221  virtual ~EventHandler(void);
     22  /** \returns a Pointer to the only object of this Class */
     23  inline static EventHandler* getInstance(void) { if (!singletonRef) singletonRef = new EventHandler();  return singletonRef; };
    2324  void init();
    2425
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4458 r4519  
    4747*/
    4848GraphicsEngine* GraphicsEngine::singletonRef = NULL;
    49 
    50 /**
    51    \returns A pointer to this GraphicsEngine
    52 */
    53 GraphicsEngine* GraphicsEngine::getInstance()
    54 {
    55   if (!GraphicsEngine::singletonRef)
    56     GraphicsEngine::singletonRef = new GraphicsEngine();
    57   return GraphicsEngine::singletonRef;
    58 }
    59 
    6049
    6150/**
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r4458 r4519  
    2525{
    2626 public:
    27   static GraphicsEngine* getInstance();
    2827  virtual ~GraphicsEngine();
     28  /** \returns a Pointer to the only object of this Class */
     29  inline static GraphicsEngine* getInstance(void) { if (!singletonRef) singletonRef = new GraphicsEngine();  return singletonRef; };
    2930
    3031  int initVideo();
  • orxonox/trunk/src/lib/graphics/light.cc

    r4471 r4519  
    251251*/
    252252LightManager* LightManager::singletonRef = NULL;
    253 
    254 
    255 /**
    256    \returns The Instance of the Lights
    257 */
    258 LightManager* LightManager::getInstance(void)
    259 {
    260   if (!singletonRef)
    261     LightManager::singletonRef = new LightManager();
    262   return singletonRef;
    263 }
    264 
    265253
    266254/**
  • orxonox/trunk/src/lib/graphics/light.h

    r4469 r4519  
    106106 public:
    107107  virtual ~LightManager(void);
    108   static LightManager* getInstance();
     108  /** \returns a Pointer to the only object of this Class */
     109  inline static LightManager* getInstance(void) { if (!singletonRef) singletonRef = new LightManager();  return singletonRef; };
    109110
    110111  // set Attributes
  • orxonox/trunk/src/lib/graphics/text_engine.cc

    r4518 r4519  
    814814
    815815/**
    816    \returns a Pointer to this Class
    817 */
    818 TextEngine* TextEngine::getInstance(void)
    819 {
    820   if (!TextEngine::singletonRef)
    821     TextEngine::singletonRef = new TextEngine();
    822   return TextEngine::singletonRef;
    823 }
    824 
    825 /**
    826816   \brief standard deconstructor
    827817
  • orxonox/trunk/src/lib/graphics/text_engine.h

    r4458 r4519  
    205205{
    206206 public:
    207   static TextEngine* getInstance(void);
    208207  virtual ~TextEngine(void);
     208  /** \returns a Pointer to the only object of this Class */
     209  inline static TextEngine* getInstance(void) { if (!singletonRef) singletonRef = new TextEngine();  return singletonRef; };
    209210
    210211  Text* createText(const char* fontFile,
  • orxonox/trunk/src/lib/particles/particle_engine.cc

    r4478 r4519  
    4343*/
    4444ParticleEngine* ParticleEngine::singletonRef = NULL;
    45 
    46 /**
    47    \returns a Pointer to this Class
    48 */
    49 ParticleEngine* ParticleEngine::getInstance(void)
    50 {
    51   if (!ParticleEngine::singletonRef)
    52     ParticleEngine::singletonRef = new ParticleEngine();
    53   return ParticleEngine::singletonRef;
    54 }
    5545
    5646/**
  • orxonox/trunk/src/lib/particles/particle_engine.h

    r4478 r4519  
    3030
    3131 public:
    32   static ParticleEngine* getInstance(void);
    3332  virtual ~ParticleEngine(void);
     33  /** \returns a Pointer to the only object of this Class */
     34  inline static ParticleEngine* getInstance(void) { if (!singletonRef) singletonRef = new ParticleEngine();  return singletonRef; };
    3435
    3536  void tick(float dt);
  • orxonox/trunk/src/lib/physics/physics_engine.cc

    r4396 r4519  
    4141*/
    4242PhysicsEngine* PhysicsEngine::singletonRef = NULL;
    43 
    44 /**
    45    \returns a Pointer to this Class
    46 */
    47 PhysicsEngine* PhysicsEngine::getInstance(void)
    48 {
    49   if (!PhysicsEngine::singletonRef)
    50     PhysicsEngine::singletonRef = new PhysicsEngine();
    51   return PhysicsEngine::singletonRef;
    52 }
    5343
    5444/**
  • orxonox/trunk/src/lib/physics/physics_engine.h

    r4394 r4519  
    2222
    2323 public:
    24   static PhysicsEngine* getInstance(void);
    2524  virtual ~PhysicsEngine(void);
     25  /** \returns a Pointer to the only object of this Class */
     26  inline static PhysicsEngine* getInstance(void) { if (!singletonRef) singletonRef = new PhysicsEngine();  return singletonRef; };
    2627
    2728  void addPhysicsInterface(PhysicsInterface* physicsInterface);
  • orxonox/trunk/src/lib/sound/sound_engine.cc

    r4506 r4519  
    174174*/
    175175SoundEngine* SoundEngine::singletonRef = NULL;
    176 
    177 /**
    178    \returns a Pointer to this Class
    179 */
    180 SoundEngine* SoundEngine::getInstance(void)
    181 {
    182   if (!SoundEngine::singletonRef)
    183     SoundEngine::singletonRef = new SoundEngine();
    184   return SoundEngine::singletonRef;
    185 }
    186176
    187177/**
  • orxonox/trunk/src/lib/sound/sound_engine.h

    r4506 r4519  
    7171
    7272 public:
    73   static SoundEngine* getInstance(void);
    7473  virtual ~SoundEngine(void);
     74  /** \returns a Pointer to the only object of this Class */
     75  inline static SoundEngine* getInstance(void) { if (!singletonRef) singletonRef = new SoundEngine();  return singletonRef; };
    7576
    7677  SoundSource* createSource(const char* fileName, PNode* sourceNode = NULL);
  • orxonox/trunk/src/proto/proto_singleton.cc

    r4320 r4519  
    4747
    4848/**
    49    \returns a Pointer to this Class
    50 */
    51 ProtoSingleton* ProtoSingleton::getInstance(void)
    52 {
    53   if (!ProtoSingleton::singletonRef)
    54     ProtoSingleton::singletonRef = new ProtoSingleton();
    55   return ProtoSingleton::singletonRef;
    56 }
    57 
    58 /**
    5949   \brief standard deconstructor
    6050
  • orxonox/trunk/src/proto/proto_singleton.h

    r3955 r4519  
    1616
    1717 public:
    18   static ProtoSingleton* getInstance(void);
    1918  virtual ~ProtoSingleton(void);
     19  /** \returns a Pointer to the only object of this Class */
     20  inline static ProtoSingleton* getInstance(void) { if (!singletonRef) singletonRef = new ProtoSingleton();  return singletonRef; };
    2021
    2122 private:
  • orxonox/trunk/src/subprojects/framework.cc

    r4374 r4519  
    236236Framework* Framework::singletonRef = NULL;
    237237
    238 Framework* Framework::getInstance(void)
    239 {
    240   if (Framework::singletonRef == NULL)
    241     Framework::singletonRef = new Framework();
    242   return Framework::singletonRef;
    243 }
    244 
    245238Framework::Framework()
    246239{
  • orxonox/trunk/src/subprojects/framework.h

    r4374 r4519  
    3737  ~Framework();
    3838 
    39   static Framework* getInstance(void);
     39  /** \returns a Pointer to the only object of this Class */
     40  inline static Framework* getInstance(void) { if (!singletonRef) singletonRef = new Framework();  return singletonRef; };
    4041
    4142
  • orxonox/trunk/src/util/collision_detection/cd_engine.cc

    r4511 r4519  
    3636
    3737/**
    38    \returns a Pointer to this Class
    39 */
    40 CDEngine* CDEngine::getInstance(void)
    41 {
    42   if (!CDEngine::singletonRef)
    43     CDEngine::singletonRef = new CDEngine();
    44   return CDEngine::singletonRef;
    45 }
    46 
    47 /**
    4838   \brief standard deconstructor
    4939
  • orxonox/trunk/src/util/collision_detection/cd_engine.h

    r4511 r4519  
    1515
    1616 public:
    17   static CDEngine* getInstance(void);
    1817  virtual ~CDEngine(void);
     18  /** \returns a Pointer to the only object of this Class */
     19  inline static CDEngine* getInstance(void) { if (!singletonRef) singletonRef = new CDEngine();  return singletonRef; };
    1920
    2021 private:
  • orxonox/trunk/src/util/garbage_collector.cc

    r4485 r4519  
    4848  // delete what has to be deleted here
    4949}
    50 
    51 
    52 /**
    53    \brief this returns the singleton reference this this class
    54    \returns singleton reference
    55 */
    56 GarbageCollector* GarbageCollector::getInstance()
    57 {
    58   if( singletonRef == NULL)
    59     singletonRef = new GarbageCollector();
    60   return singletonRef;
    61 }
    62 
    6350
    6451/**
  • orxonox/trunk/src/util/garbage_collector.h

    r4485 r4519  
    2222
    2323 public:
    24   GarbageCollector();
    2524  virtual ~GarbageCollector();
    26   static GarbageCollector* getInstance();
     25  /** \returns a Pointer to the only object of this Class */
     26  inline static GarbageCollector* getInstance(void) { if (!singletonRef) singletonRef = new GarbageCollector();  return singletonRef; };
    2727
    2828  void setCollectionDelay(float delay);
     
    3434
    3535 private:
     36  GarbageCollector();
     37
     38 private:
    3639  static GarbageCollector*    singletonRef;           //!< The reference to this class (singleton)
    3740  float                       delay;                  //!< this is the delay to wait until collection
  • orxonox/trunk/src/util/object_manager.cc

    r4485 r4519  
    4444*/
    4545ObjectManager* ObjectManager::singletonRef = NULL;
    46 
    47 /**
    48    \returns a Pointer to this Class
    49 */
    50 ObjectManager* ObjectManager::getInstance(void)
    51 {
    52   if (!ObjectManager::singletonRef)
    53     ObjectManager::singletonRef = new ObjectManager();
    54   return ObjectManager::singletonRef;
    55 }
    56 
    5746
    5847/**
  • orxonox/trunk/src/util/object_manager.h

    r4485 r4519  
    4848
    4949 public:
    50   static ObjectManager* getInstance(void);
    5150  virtual ~ObjectManager(void);
     51  /** \returns a Pointer to the only object of this Class */
     52  inline static ObjectManager* getInstance(void) { if (!singletonRef) singletonRef = new ObjectManager();  return singletonRef; };
    5253 
    5354  /** a class handled by the objectManage */
  • orxonox/trunk/src/util/resource_manager.cc

    r4504 r4519  
    4646   this->imageDirs = new tList<char>();
    4747   this->resourceList = new tList<Resource>();
    48 }
    49 
    50 /**
    51    \returns the Instance to this ResourceManager
    52 */
    53 ResourceManager* ResourceManager::getInstance(void)
    54 {
    55   if (!ResourceManager::singletonRef)
    56     ResourceManager::singletonRef = new ResourceManager();
    57   return ResourceManager::singletonRef;
    5848}
    5949
  • orxonox/trunk/src/util/resource_manager.h

    r4465 r4519  
    7474 public:
    7575  virtual ~ResourceManager();
    76 
    77   static ResourceManager* getInstance();
     76  /** \returns a Pointer to the only object of this Class */
     77  inline static ResourceManager* getInstance(void) { if (!singletonRef) singletonRef = new ResourceManager();  return singletonRef; };
    7878
    7979  bool setDataDir(const char* dataDir);
Note: See TracChangeset for help on using the changeset viewer.