library of assembled shared sources

http://lass.cocamware.com

lass::util::impl::SingletonGuard Class Reference

The singleton guard will take care of the destruction of all singletons. More...

Collaboration diagram for lass::util::impl::SingletonGuard:

Collaboration graph
[legend]

Data Structures

class  CustomSemaphore
 Special semaphore for the guard. More...

Public Member Functions

 ~SingletonGuard ()
 on destruction, you have to kill all singletons.
void subscribe (SingletonBase *iSingleton)
 subscribe singleton to the destruction list

Static Public Member Functions

static SingletonGuardinstance ()
 return the SingletonGuard singleton instance =)

Private Types

typedef std::priority_queue
< SingletonBase *, std::vector
< SingletonBase * >
, CompareDestructionPriority
TDeathRow

Private Member Functions

 SingletonGuard ()

Static Private Member Functions

static void killEmAll ()
 kills singleton guard and all its guarded singleton.
static bool deadReference (bool iSetReferenceToDead=false)
 return true if singleton guard is destructed.

Private Attributes

TDeathRow deathRow_

Static Private Attributes

static SingletonGuardinstance_ = 0

Detailed Description

The singleton guard will take care of the destruction of all singletons.

Definition at line 87 of file singleton_impl.cpp.


Member Typedef Documentation

Definition at line 133 of file singleton_impl.cpp.


Constructor & Destructor Documentation

lass::util::impl::SingletonGuard::~SingletonGuard (  ) 

on destruction, you have to kill all singletons.

This isn't thread safe as it is, but that's ok because it's only "caller" singletonCleanUp() is already locking on SingletonGuard level for us.

Definition at line 207 of file singleton_impl.cpp.

References deadReference(), and deathRow_.

lass::util::impl::SingletonGuard::SingletonGuard (  )  [inline, private]

Definition at line 99 of file singleton_impl.cpp.


Member Function Documentation

void lass::util::impl::SingletonGuard::subscribe ( SingletonBase iSingleton  ) 

subscribe singleton to the destruction list

This isn't thread safe as it is, but that's ok because it's only indirect caller Singleton::instance() is already locking on SingletonGuard level for us.

Definition at line 229 of file singleton_impl.cpp.

References deathRow_.

SingletonGuard * lass::util::impl::SingletonGuard::instance (  )  [static]

return the SingletonGuard singleton instance =)

Definition at line 238 of file singleton_impl.cpp.

References lass::io::cerr(), deadReference(), instance_, and killEmAll().

Referenced by lass::util::impl::SingletonBase::subscribeInstance().

void killEmAll (  )  [static, private]

kills singleton guard and all its guarded singleton.

This function is subscribed to atexit to kill all singletons at exit of the application<

Definition at line 267 of file singleton_impl.cpp.

References instance_.

Referenced by instance().

bool lass::util::impl::SingletonGuard::deadReference ( bool  iSetReferenceToDead = false  )  [static, private]

return true if singleton guard is destructed.

Parameters:
iSetReferenceToDead - call this method with true on destruction of singleton
  • call this method with false to check it.

Definition at line 280 of file singleton_impl.cpp.

Referenced by instance(), and ~SingletonGuard().


Field Documentation

Definition at line 135 of file singleton_impl.cpp.

Referenced by subscribe(), and ~SingletonGuard().

Definition at line 140 of file singleton_impl.cpp.

Referenced by instance(), and killEmAll().


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

Generated on Mon Nov 10 14:22:20 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo