BaseSingleton.cpp
Go to the documentation of this file.
00001 /*
00002  * BaseSingleton.cpp
00003  *
00004  *  Created on: Mar 22, 2012
00005  *      Author: mriedel
00006  */
00007 
00008 #include <telekyb_base/Base/BaseSingleton.hpp>
00009 
00010 #include <iostream>
00011 
00012 namespace TELEKYB_NAMESPACE {
00013 
00014 // static field
00015 std::list<BaseSingleton*> BaseSingleton::singletons;
00016 
00017 BaseSingleton::BaseSingleton() {
00018         //std::cout << "Creating Singleton with Pointer " << (size_t)this << std::endl;
00019         // Add yourself to BEGINNING of the list
00020         singletons.push_front(this);
00021         // List iterators survive insertation and deletion operation of other elements.
00022         it_self = singletons.begin();
00023         //std::cout << "(END) Creating Singleton with Pointer " << (size_t)this << std::endl;
00024 }
00025 
00026 BaseSingleton::~BaseSingleton() {
00027         //std::cout << "Destroying Singleton with Pointer " << (size_t)this << std::endl;
00028         // Delete yourself from Singleton List
00029         singletons.erase(it_self);
00030         //std::cout << "(END) Destroying Singleton with Pointer " << (size_t)this << std::endl;
00031 }
00032 
00033 void BaseSingleton::deleteAllSingletons()
00034 {
00035         //std::cout << "Delete all Singletons: " << singletons.size() << std::endl;
00036 
00037         // Destruktor removes Singleton from list!
00038         std::list<BaseSingleton*>::iterator it = singletons.begin();
00039         while (it != singletons.end()) {
00040                 delete (*(it++));
00041         }
00042 
00043         //std::cout << "(END) Delete all Singletons: " << singletons.size() << std::endl;
00044 }
00045 
00046 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


telekyb_base
Author(s): Dr. Antonio Franchi and Martin Riedel
autogenerated on Mon Nov 11 2013 11:12:34