lumiera::singleton::AutoDestroy< S > Struct Template Reference

Policy relying on the compiler/runtime system for Singleton Lifecycle.

#include <singletonpolicies.hpp>

List of all members.

Static Public Member Functions

static void onDeadReference ()
static void scheduleDelete (DelFunc kill_the_singleton)
 implements the Singleton removal by calling the provided deleter function(s) at application shutdown, relying on the runtime system calling destructors of static objects.


Detailed Description

template<class S>
struct lumiera::singleton::AutoDestroy< S >

Definition at line 92 of file singletonpolicies.hpp.


Member Function Documentation

template<class S>
static void lumiera::singleton::AutoDestroy< S >::scheduleDelete ( DelFunc  kill_the_singleton  )  [inline, static]

Because this Policy class can be shared between several Singletons, we need to memoize all registered deleter functions for calling them at shutdown.

Definition at line 101 of file singletonpolicies.hpp.

00102             {
00103                  class DeleteTrigger
00104                         {
00105                           vector<DelFunc> dels_;
00106                           
00107                         public:
00108                           void schedule (DelFunc del) 
00109                             { 
00110                               dels_.push_back(del); 
00111                             }
00112                          ~DeleteTrigger()        
00113                             { 
00114                               vector<DelFunc>::iterator i = dels_.begin();
00115                               for ( ; i != dels_.end(); ++i )
00116                                 (*i)(); // invoke deleter func 
00117                             }
00118                         };
00119                         
00120               REQUIRE (kill_the_singleton);
00121               static DeleteTrigger finally;
00122               finally.schedule (kill_the_singleton);
00123             }


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

Generated on Sat Aug 16 18:10:45 2008 for Lumiera by  doxygen 1.5.5