26
26
******************************************************************************/
28
#ifndef WNS_SMARTPTR_HPP
29
#define WNS_SMARTPTR_HPP
31
#include "SmartPtrBase.hpp"
32
#include "RefCountable.hpp"
33
#include "TypeInfo.hpp"
29
#include <openwns/SmartPtrBase.hpp>
30
#include <openwns/RefCountable.hpp>
31
#include <openwns/TypeInfo.hpp>
46
44
* @ingroup group_main_classes
48
46
* SmartPtr is a template that supports automatic memory
49
* management. Once a SmartPtr is allocated you don't need to care about
47
* management. Once a SmartPtr is allocated you don't need to care
52
50
template <typename T>
128
116
#ifdef WNS_SMARTPTR_DEBUGGING
130
118
id(++getCounter()),
137
123
ptr->incRefCount();
139
// #ifdef WNS_SMARTPTR_DEBUGGING
140
// this->created("", 0);
144
// #ifdef WNS_SMARTPTR_DEBUGGING
146
// * @brief Construct NULL pointer (additional debugging support)
148
// SmartPtr(const std::string& file, int line) :
150
// id(++getCounter()),
155
// this->created(file, line);
159
// * @brief Pointer p will be stored in / handled by SmartPtr
160
// * (additional debugging support)
163
// SmartPtr(const std::string& file, int line, T* p) :
165
// id(++getCounter()),
171
// ptr->incRefCount();
172
// this->created(file, line);
176
// * @brief "Copy-constructor" from same SmartPtr type (additional
177
// * debugging support)
179
// SmartPtr(const std::string& file, int line, const SmartPtr& s) :
181
// id(++getCounter()),
187
// ptr->incRefCount();
189
// this->created(file, line);
193
// * @brief Copy-constructor from other SmartPtr type (additional
194
// * debugging support)
196
// template <typename OtherType>
197
// SmartPtr(const std::string& file, int line, const SmartPtr<OtherType>& s) :
199
// id(++getCounter()),
205
// ptr->incRefCount();
207
// this->created(file, line);
209
// #endif // defined WNS_SMARTPTR_DEBUGGING
212
128
* @brief Assign operator for same SmartPtr type
373
286
printAllExistingPointers()
375
// #ifdef WNS_SMARTPTR_DEBUGGING
376
// std::cout << "Curently existing SmartPtr<"
377
// << wns::TypeInfo::create<T>()
380
// for(typename std::list<SmartPtr*>::const_iterator itr = getAllPointers().begin();
381
// itr != getAllPointers().end();
383
// std::cout << "Pointer id: " << (*itr)->id << "\n"
384
// << "Created at: " << (*itr)->file << ":" << (*itr)->line << "\n";
394
294
printNumberOfExistingPointers()
396
// #ifdef WNS_SMARTPTR_DEBUGGING
397
// std::cout << "Number of curently existing SmartPtr<"
398
// << wns::TypeInfo::create<T>()
399
// << ">: " << getAllPointers().size() << "\n";
405
300
#ifdef WNS_SMARTPTR_DEBUGGING
406
301
boost::int64_t id;
412
// created(const std::string& _file, int _line)
414
// this->getAllPointers().push_back(this);
415
// this->file = _file;
416
// this->line = _line;
422
// SmartPtr::getAllPointers().remove(this);
425
303
static boost::int64_t&