Changeset 97f035 for molecuilder/src
- Timestamp:
- Mar 11, 2010, 3:17:29 PM (15 years ago)
- Children:
- 1e0785
- Parents:
- e9f2e1
- Location:
- molecuilder/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/Patterns/Singleton.hpp
re9f2e1 r97f035 32 32 void reset(T* _content); 33 33 void reset(); 34 ptr_t& operator=( ptr_t& rhs);34 ptr_t& operator=(const ptr_t& rhs); 35 35 private: 36 T* content;36 mutable T* content; 37 37 }; 38 38 … … 85 85 static void setInstance(T*); 86 86 protected: 87 // constructor accessible by subclasses 88 Singleton(); 87 89 88 90 private: 91 // private copy constructor to avoid unintended copying 92 Singleton(const Singleton&); 93 89 94 static boost::recursive_mutex instanceLock; 90 95 static ptr_t theInstance; -
molecuilder/src/Patterns/Singleton_impl.hpp
re9f2e1 r97f035 77 77 } 78 78 79 template<class T, bool _may_create> 80 Singleton<T,_may_create>::Singleton(){/* empty */} 81 82 // private copy constructor to avoid unintended copying 83 template <class T, bool _may_create> 84 Singleton<T,_may_create>::Singleton(const Singleton<T,_may_create>&){ 85 assert(0 && "Copy constructor of singleton template called"); 86 } 87 79 88 /** 80 89 * This define allows simple instantiation of the necessary singleton functions … … 121 130 122 131 template <class T,bool _may_create> 123 typename Singleton<T,_may_create>::ptr_t& Singleton<T,_may_create>::ptr_t::operator=( typename Singleton<T,_may_create>::ptr_t& rhs){132 typename Singleton<T,_may_create>::ptr_t& Singleton<T,_may_create>::ptr_t::operator=(const typename Singleton<T,_may_create>::ptr_t& rhs){ 124 133 if(&rhs!=this){ 125 134 delete content; -
molecuilder/src/unittests/SingletonTest.cpp
re9f2e1 r97f035 29 29 count1++; 30 30 } 31 // explicit copy constructor to catch if this is ever called 32 SingletonStub1(const SingletonStub1&){ 33 CPPUNIT_FAIL ( "Copy constructor of Singleton called" ); 34 } 31 35 virtual ~SingletonStub1(){ 32 36 count2++; … … 47 51 SingletonStub2(){ 48 52 count1++; 53 } 54 // explicit copy constructor to catch if thsi is ever called 55 SingletonStub2(const SingletonStub2&){ 56 CPPUNIT_FAIL ( "Copy constructor of Singleton called" ); 49 57 } 50 58 virtual ~SingletonStub2(){
Note:
See TracChangeset
for help on using the changeset viewer.