#include <ReferenceCounting.hpp>


Public Member Functions | |
| ReferenceCountingCenter () | |
| The only public part is the constructor and destructor! | |
| ~ReferenceCountingCenter () | |
| Destructs a ReferenceCountingCenter. | |
Static Public Member Functions | |
| static ReferenceCountingCenter & | instance () |
| static void | create () |
| static void | destroy () |
Static Protected Attributes | |
| static ReferenceCountingCenter * | __pInstance |
Private Member Functions | |
| template<typename ReferenceCounterType> | |
| const size_t & | numberOfReferences (const ReferenceCounterType &rc) |
| The number of references for a given address. | |
| template<typename ReferenceCounterType> | |
| void | addReference (ReferenceCounterType &rc) |
| Adds a reference to a given address. | |
| template<typename ReferenceCounterType> | |
| size_t | removeReference (ReferenceCounterType &rc) |
| Removes a reference. | |
Private Attributes | |
| std::map< const void *, size_t > | __counter |
| The counter of references. | |
| std::map< const void *, std::string > | __typeName |
| associates the name of the associate type. | |
Friends | |
| class | ReferenceCounting |
| class | ConstReferenceCounting |
Definition at line 47 of file ReferenceCounting.hpp.
| ReferenceCountingCenter::ReferenceCountingCenter | ( | ) | [inline] |
The only public part is the constructor and destructor!
Builts a ReferenceCountingCenter
Definition at line 103 of file ReferenceCounting.hpp.
| ReferenceCountingCenter::~ReferenceCountingCenter | ( | ) | [inline] |
Destructs a ReferenceCountingCenter.
Definition at line 109 of file ReferenceCounting.hpp.
References __counter, __typeName, and fflog().
00110 { 00111 #ifndef NDEBUG 00112 fflog(0) << "\n###### REFERENCE COUNTING STATE ######\n"; 00113 fflog(0) << "Number of referenced addresses: " 00114 << std::setw(5) << __counter.size() << '\n'; 00115 size_t n = 0; 00116 for (std::map<const void*,size_t>::iterator i= __counter.begin(); 00117 i != __counter.end(); ++i) { 00118 n += (i->second != 0); 00119 } 00120 fflog(0) << "Number of unallocaded addresses: " 00121 << std::setw(5) << n << '\n'; 00122 fflog(0) << "--------------------------------------\n"; 00123 for (std::map<const void*,size_t>::iterator i= __counter.begin(); 00124 i != __counter.end(); ++i) { 00125 if (i->second != 0) { 00126 fflog(0) << i->first << ": " << __typeName[i->first] 00127 << ':' << std::setw(5) << i->second << '\n'; 00128 } 00129 } 00130 fflog(0) << "######################################\n"; 00131 #endif // NDEBUG 00132 }

| const size_t& ReferenceCountingCenter::numberOfReferences | ( | const ReferenceCounterType & | rc | ) | [inline, private] |
The number of references for a given address.
Definition at line 67 of file ReferenceCounting.hpp.
References __counter.
Referenced by ReferenceCounting< Undefined >::numberOfReferences(), and ConstReferenceCounting< SpectralConformTransformation >::numberOfReferences().
00068 { 00069 return __counter[rc.__ref]; 00070 }
| void ReferenceCountingCenter::addReference | ( | ReferenceCounterType & | rc | ) | [inline, private] |
Adds a reference to a given address.
Definition at line 74 of file ReferenceCounting.hpp.
References __counter, and __typeName.
Referenced by ConstReferenceCounting< SpectralConformTransformation >::ConstReferenceCounting(), ReferenceCounting< Undefined >::operator=(), ConstReferenceCounting< SpectralConformTransformation >::operator=(), and ReferenceCounting< Undefined >::ReferenceCounting().
00075 { 00076 __counter[rc.__ref]++; 00077 #ifndef NDEBUG 00078 __typeName[rc.__ref] = rc.typeName(); 00079 #endif //NDEBUG 00080 }
| size_t ReferenceCountingCenter::removeReference | ( | ReferenceCounterType & | rc | ) | [inline, private] |
Removes a reference.
Definition at line 84 of file ReferenceCounting.hpp.
References __counter, and __typeName.
Referenced by ReferenceCounting< Undefined >::operator=(), ConstReferenceCounting< SpectralConformTransformation >::operator=(), ConstReferenceCounting< SpectralConformTransformation >::~ConstReferenceCounting(), and ReferenceCounting< Undefined >::~ReferenceCounting().
00085 { 00086 const void* address = rc.__ref; 00087 std::map<const void*,size_t>::iterator i = __counter.find(address); 00088 if ((i->second == 1)&&(address != 0)) { 00089 rc.eraseData(); 00090 __counter.erase(i); 00091 #ifndef NDEBUG 00092 __typeName.erase(address); 00093 #endif // NDEBUG 00094 return 0; 00095 } 00096 return (--(i->second)); 00097 }
| static ReferenceCountingCenter & StaticBase< ReferenceCountingCenter >::instance | ( | ) | [inline, static, inherited] |
Access to auto instanciated static;
Definition at line 46 of file StaticBase.hpp.
00047 { 00048 return *__pInstance; 00049 }
| static void StaticBase< ReferenceCountingCenter >::create | ( | ) | [inline, static, inherited] |
Creates __pInstance in Embedding class.
Definition at line 55 of file StaticBase.hpp.
Referenced by ThreadStaticCenter::ThreadStaticCenter().
00056 { 00057 __pInstance = new EmbeddingClass(); 00058 }
| static void StaticBase< ReferenceCountingCenter >::destroy | ( | ) | [inline, static, inherited] |
Destroyes __autoInstanciated in Embedding class.
Definition at line 64 of file StaticBase.hpp.
Referenced by ThreadStaticCenter::~ThreadStaticCenter().
00065 { 00066 delete __pInstance; 00067 }
friend class ReferenceCounting [friend] |
Definition at line 52 of file ReferenceCounting.hpp.
friend class ConstReferenceCounting [friend] |
Definition at line 55 of file ReferenceCounting.hpp.
std::map<const void*,size_t> ReferenceCountingCenter::__counter [private] |
The counter of references.
Definition at line 58 of file ReferenceCounting.hpp.
Referenced by addReference(), numberOfReferences(), removeReference(), and ~ReferenceCountingCenter().
std::map<const void*,std::string> ReferenceCountingCenter::__typeName [private] |
associates the name of the associate type.
Definition at line 62 of file ReferenceCounting.hpp.
Referenced by addReference(), removeReference(), and ~ReferenceCountingCenter().
ReferenceCountingCenter * StaticBase< ReferenceCountingCenter >::__pInstance [static, protected, inherited] |
The static variable
Definition at line 37 of file StaticBase.hpp.
1.5.6