Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Attributes | List of all members
orxonox::ClassScopedSingletonWrapper< T, allowedToFail > Class Template Reference

Manages a scoped singleton. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/singleton/ScopedSingletonWrapper.h>

Inheritance diagram for orxonox::ClassScopedSingletonWrapper< T, allowedToFail >:
orxonox::ScopedSingletonWrapper orxonox::ScopeListener

Public Member Functions

 ClassScopedSingletonWrapper (const std::string &className)
 
 ~ClassScopedSingletonWrapper ()
 
virtual void activated () override
 Called if the Scope of the Singleton gets active (creates the instance) More...
 
virtual void deactivated () override
 Called if the Scope of this Singleton gets deactivated (destroys the instance) More...
 
void destroy (Destroyable *)
 Destroys the singleton instance - overloaded for Destroyable, calls Destroyable::destroy() More...
 
void destroy (void *)
 Destroys the singleton instance - overloaded for all other pointers, calls delete. More...
 
- Public Member Functions inherited from orxonox::ScopedSingletonWrapper
 ScopedSingletonWrapper (const std::string &className)
 Constructor: Initializes all the values. More...
 
virtual ~ScopedSingletonWrapper ()=default
 

Private Attributes

T * singletonPtr_
 Unique instance of the singleton class T. More...
 

Additional Inherited Members

- Protected Member Functions inherited from orxonox::ScopeListener
 ScopeListener ()
 
virtual ~ScopeListener ()=default
 
- Protected Attributes inherited from orxonox::ScopedSingletonWrapper
const std::string className_
 The name of the scoped singleton class that is managed by this object. More...
 

Detailed Description

template<class T, bool allowedToFail>
class orxonox::ClassScopedSingletonWrapper< T, allowedToFail >

Manages a scoped singleton.

Parameters
TThe managed singleton class
allowedToFailIf true, a specialization of this template is used, that uses try-catch blocks to handle possible failures.

This class inherits from ScopeListener and is registered for a scope in ScopeManager and thus its functions activated() and deactivated() are called whenever the Scope changes its state.

If the Scope is activated, a new instance of T (which must be a singleton) is created. If the Scope is deactivated, the singleton is destroyed.

See also
Singleton

Constructor & Destructor Documentation

template<class T , bool allowedToFail>
orxonox::ClassScopedSingletonWrapper< T, allowedToFail >::ClassScopedSingletonWrapper ( const std::string &  className)
inline
template<class T , bool allowedToFail>
orxonox::ClassScopedSingletonWrapper< T, allowedToFail >::~ClassScopedSingletonWrapper ( )
inline

Member Function Documentation

template<class T , bool allowedToFail>
virtual void orxonox::ClassScopedSingletonWrapper< T, allowedToFail >::activated ( )
inlineoverridevirtual

Called if the Scope of the Singleton gets active (creates the instance)

Implements orxonox::ScopeListener.

template<class T , bool allowedToFail>
virtual void orxonox::ClassScopedSingletonWrapper< T, allowedToFail >::deactivated ( )
inlineoverridevirtual

Called if the Scope of this Singleton gets deactivated (destroys the instance)

Implements orxonox::ScopeListener.

template<class T , bool allowedToFail>
void orxonox::ClassScopedSingletonWrapper< T, allowedToFail >::destroy ( Destroyable )
inline

Destroys the singleton instance - overloaded for Destroyable, calls Destroyable::destroy()

template<class T , bool allowedToFail>
void orxonox::ClassScopedSingletonWrapper< T, allowedToFail >::destroy ( void )
inline

Destroys the singleton instance - overloaded for all other pointers, calls delete.

Member Data Documentation

template<class T , bool allowedToFail>
T* orxonox::ClassScopedSingletonWrapper< T, allowedToFail >::singletonPtr_
private

Unique instance of the singleton class T.


The documentation for this class was generated from the following file: