- Timestamp:
- Aug 29, 2015, 5:35:59 PM (9 years ago)
- Location:
- code/branches/core7
- Files:
-
- 27 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/BaseObject.h
r10298 r10555 51 51 #include "class/OrxonoxClass.h" 52 52 #include "class/Super.h" 53 #include "object/S martPtr.h"53 #include "object/StrongPtr.h" 54 54 55 55 namespace orxonox … … 138 138 { return this->templates_; } 139 139 140 inline void setNamespace(const S martPtr<Namespace>& ns) { this->namespace_ = ns; }141 inline const S martPtr<Namespace>& getNamespace() const { return this->namespace_; }140 inline void setNamespace(const StrongPtr<Namespace>& ns) { this->namespace_ = ns; } 141 inline const StrongPtr<Namespace>& getNamespace() const { return this->namespace_; } 142 142 143 143 inline void setCreator(BaseObject* creator) { this->creator_ = creator; } 144 144 inline BaseObject* getCreator() const { return this->creator_; } 145 145 146 inline void setScene(const S martPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; }147 inline const S martPtr<Scene>& getScene() const { return this->scene_; }146 inline void setScene(const StrongPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; } 147 inline const StrongPtr<Scene>& getScene() const { return this->scene_; } 148 148 inline virtual uint32_t getSceneID() const { return this->sceneID_; } 149 149 150 inline void setGametype(const S martPtr<Gametype>& gametype)150 inline void setGametype(const StrongPtr<Gametype>& gametype) 151 151 { 152 152 if (gametype != this->gametype_) … … 157 157 } 158 158 } 159 inline const S martPtr<Gametype>& getGametype() const { return this->gametype_; }159 inline const StrongPtr<Gametype>& getGametype() const { return this->gametype_; } 160 160 inline Gametype* getOldGametype() const { return this->oldGametype_; } 161 161 virtual void changedGametype() {} 162 162 163 inline void setLevel(const S martPtr<Level>& level)163 inline void setLevel(const StrongPtr<Level>& level) 164 164 { 165 165 if (level != this->level_) … … 169 169 } 170 170 } 171 inline const S martPtr<Level>& getLevel() const { return this->level_; }171 inline const StrongPtr<Level>& getLevel() const { return this->level_; } 172 172 virtual void changedLevel() {} 173 173 … … 222 222 std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes 223 223 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 224 S martPtr<Namespace>namespace_;224 StrongPtr<Namespace> namespace_; 225 225 BaseObject* creator_; 226 S martPtr<Scene>scene_;226 StrongPtr<Scene> scene_; 227 227 uint32_t sceneID_; 228 S martPtr<Gametype>gametype_;228 StrongPtr<Gametype> gametype_; 229 229 Gametype* oldGametype_; 230 S martPtr<Level>level_;230 StrongPtr<Level> level_; 231 231 std::set<Template*> templates_; 232 232 -
code/branches/core7/src/libraries/core/CorePrereqs.h
r10552 r10555 218 218 class ScopedSingletonWrapper; 219 219 class SettingsConfigFile; 220 template <class T>221 class SmartPtr;222 220 class StaticallyInitializedInstance; 223 221 class StaticInitializationHandler; 224 222 class StaticInitializationManager; 223 template <class T> 224 class StrongPtr; 225 225 template <class T> 226 226 class SubclassIdentifier; -
code/branches/core7/src/libraries/core/CoreStaticInitializationHandler.cc
r10542 r10555 102 102 identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(*it)->getIdentifier()); 103 103 104 // destroy objects. some objects may survive this at first because they still have s martpointers pointing at them. this is105 // ok as long as those s martpointers are held by objects that are also about to be destroyed in the same loop. this means106 // that objects within one module may reference each other by s martpointers. but it is not allowed that objects from another107 // module (which is not unloaded) uses s martpointers to point at objects inside the unloaded module. this will lead to a crash.104 // destroy objects. some objects may survive this at first because they still have strong pointers pointing at them. this is 105 // ok as long as those strong pointers are held by objects that are also about to be destroyed in the same loop. this means 106 // that objects within one module may reference each other by strong pointers. but it is not allowed that objects from another 107 // module (which is not unloaded) uses strong pointers to point at objects inside the unloaded module. this will lead to a crash. 108 108 for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it) 109 109 (*it)->destroyObjects(); 110 110 111 // check if all objects were really destroyed. this is not the case if an object is referenced by a s martpointer from another111 // check if all objects were really destroyed. this is not the case if an object is referenced by a strong pointer from another 112 112 // module (or if two objects inside this module reference each other). this will lead to a crash and must be fixed (e.g. by 113 113 // changing object dependencies; or by changing the logic that allows modules to be unloaded). -
code/branches/core7/src/libraries/core/Namespace.cc
r10298 r10555 47 47 RegisterObject(Namespace); 48 48 49 this->setNamespace(S martPtr<Namespace>(this, false));49 this->setNamespace(StrongPtr<Namespace>(this, false)); 50 50 } 51 51 -
code/branches/core7/src/libraries/core/object/DestroyLaterManager.cc
r10464 r10555 51 51 void DestroyLaterManager::postUpdate(const Clock& time) 52 52 { 53 // clearing the list will destroy all s martpointers and thus all retained instances (as long as there are no other smartpointers pointing to them).53 // clearing the list will destroy all strong pointers and thus all retained instances (as long as there are no other strong pointers pointing to them). 54 54 this->retainedInstances_.clear(); 55 55 } -
code/branches/core7/src/libraries/core/object/DestroyLaterManager.h
r10419 r10555 34 34 #include "util/Singleton.h" 35 35 #include "core/UpdateListener.h" 36 #include "S martPtr.h"36 #include "StrongPtr.h" 37 37 38 38 namespace orxonox … … 52 52 53 53 private: 54 std::vector<S martPtr<Destroyable> > retainedInstances_;54 std::vector<StrongPtr<Destroyable> > retainedInstances_; 55 55 56 56 static DestroyLaterManager* singletonPtr_s; -
code/branches/core7/src/libraries/core/object/Destroyable.cc
r10419 r10555 61 61 62 62 /** 63 @brief Deletes the object if no @ref orxonox::S martPtr "smartpointers" point to this object. Otherwise schedules the object to be deleted as soon as possible.64 Always call destroy() instead of using 'delete' directly, otherwise s martpointers won't work.63 @brief Deletes the object if no @ref orxonox::StrongPtr "strong pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible. 64 Always call destroy() instead of using 'delete' directly, otherwise strong pointers won't work. 65 65 */ 66 66 void Destroyable::destroy() … … 81 81 void Destroyable::destroyLater() 82 82 { 83 // register in DestroyLaterManager - this ensures that a s martPtr points to this object and keeps it alive for a while83 // register in DestroyLaterManager - this ensures that a strongPtr points to this object and keeps it alive for a while 84 84 DestroyLaterManager::getInstance().retain(this); 85 85 86 // request destruction -> object will be deleted after all s martPtrs (including the one in DestroyLaterManager) were destroyed.86 // request destruction -> object will be deleted after all strongPtrs (including the one in DestroyLaterManager) were destroyed. 87 87 this->destroy(); 88 88 } -
code/branches/core7/src/libraries/core/object/Destroyable.h
r10419 r10555 30 30 @file 31 31 @ingroup Object 32 @brief Declaration of Destroyable, the base class of all objects which can be used with S martPtr and WeakPtr.32 @brief Declaration of Destroyable, the base class of all objects which can be used with StrongPtr and WeakPtr. 33 33 */ 34 34 … … 43 43 { 44 44 /** 45 @brief Classes must inherit from this class if they should be used with S martPtr or WeakPtr.45 @brief Classes must inherit from this class if they should be used with StrongPtr or WeakPtr. 46 46 */ 47 47 class _CoreExport Destroyable 48 48 { 49 49 template <class T> 50 friend class S martPtr;50 friend class StrongPtr; 51 51 52 52 friend class DestructionListener; … … 59 59 void destroyLater(); 60 60 61 /// Returns the number of @ref orxonox::S martPtr "smartpointers" that point to this object.61 /// Returns the number of @ref orxonox::StrongPtr "strong pointers" that point to this object. 62 62 inline unsigned int getReferenceCount() const 63 63 { return this->referenceCount_; } 64 64 65 65 protected: 66 /// This virtual function is called if destroy() is called and no S martPtr points to this object. Used in some cases to create a new SmartPtr to66 /// This virtual function is called if destroy() is called and no StrongPtr points to this object. Used in some cases to create a new StrongPtr to 67 67 /// prevent destruction. Don't call this function directly - use destroy() instead. 68 68 virtual void preDestroy() {} 69 69 70 70 private: 71 /// Increments the reference counter (for s martpointers).71 /// Increments the reference counter (for strong pointers). 72 72 inline void incrementReferenceCount() 73 73 { ++this->referenceCount_; } 74 /// Decrements the reference counter (for s martpointers).74 /// Decrements the reference counter (for strong pointers). 75 75 inline void decrementReferenceCount() 76 76 { … … 87 87 { this->destructionListeners_.erase(pointer); } 88 88 89 int referenceCount_; //!< Counts the references from s martpointers to this object89 int referenceCount_; //!< Counts the references from strong pointers to this object 90 90 bool requestedDestruction_; //!< Becomes true after someone called delete on this object 91 91 std::set<DestructionListener*> destructionListeners_; //!< All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies) -
code/branches/core7/src/libraries/core/object/StrongPtr.h
r10553 r10555 30 30 31 31 /** 32 @defgroup SmartPtr S martPtr<T> and WeakPtr<T>32 @defgroup SmartPtr StrongPtr<T> and WeakPtr<T> 33 33 @ingroup Object 34 34 */ … … 37 37 @file 38 38 @ingroup Object SmartPtr 39 @brief Definition of S martPtr<T>, wraps a pointer to an object and keeps it alive.40 41 @anchor S martPtrExample42 43 orxonox::S martPtr is an implementation of a smart pointer - it wraps a pointer to an44 object and keeps this object alive until no S martPtr points to this object anymore.45 In contrast to orxonox::SharedPtr, S martPtr works only with classes that are derived39 @brief Definition of StrongPtr<T>, wraps a pointer to an object and keeps it alive. 40 41 @anchor StrongPtrExample 42 43 orxonox::StrongPtr is an implementation of a smart pointer - it wraps a pointer to an 44 object and keeps this object alive until no StrongPtr points to this object anymore. 45 In contrast to orxonox::SharedPtr, StrongPtr works only with classes that are derived 46 46 from orxonox::Destroyable, because it's an intrusive implementation, meaning the 47 47 reference counter is stored in the object itself. 48 48 49 It's possible to use normal pointers and s martpointers to an object simultaneously.50 You don't have to use S martPtr all the time, you can create a SmartPtr for an object49 It's possible to use normal pointers and strong pointers to an object simultaneously. 50 You don't have to use StrongPtr all the time, you can create a StrongPtr for an object 51 51 at any time and also convert it back to a normal pointer if you like. This is possible 52 because the reference counter is stored in the object itself and not in S martPtr (in52 because the reference counter is stored in the object itself and not in StrongPtr (in 53 53 contrast to SharedPtr). 54 54 55 55 @b Important: If you want to delete an object, you must not use @c delete @c object but 56 rather @c object->destroy(). This function will check if there are s martpointers57 pointing to the object. If yes, the object will be kept alive until all s mart pointes56 rather @c object->destroy(). This function will check if there are strong pointers 57 pointing to the object. If yes, the object will be kept alive until all strong pointers 58 58 are destroyed. If no, the object is deleted instantly. 59 59 60 If all s martpointers that point to an object are destroyed, but you never called61 @c object->destroy() before, the object will not be deleted! All a S martPtr will do60 If all strong pointers that point to an object are destroyed, but you never called 61 @c object->destroy() before, the object will not be deleted! All a StrongPtr will do 62 62 is to really just keep an object alive, but it will not delete it automatically 63 63 unless you tried to destroy it before. … … 68 68 { 69 69 public: 70 void setObject(OtherClass* object) // passes a normal pointer which will be stored in a S martPtr70 void setObject(OtherClass* object) // passes a normal pointer which will be stored in a StrongPtr 71 71 { this->object_ = object; } 72 72 73 OtherClass* getObject() const // converts the S martPtr to a normal pointer and returns it73 OtherClass* getObject() const // converts the StrongPtr to a normal pointer and returns it 74 74 { return this->object_; } 75 75 76 76 private: 77 S martPtr<OtherClass> object_; // a pointer to an instance of OtherClass is stored in a SmartPtr77 StrongPtr<OtherClass> object_; // a pointer to an instance of OtherClass is stored in a StrongPtr 78 78 }; 79 79 @endcode … … 85 85 MyClass* myclass = new MyClass(); // create an instance of MyClass 86 86 OtherClass* object = new OtherClass(); // create an instance of OtherClass 87 myclass->setObject(object); // the object is now stored in a S martPtr inside myclass88 89 object->destroy(); // we try to destroy object, but there's still a S martPtr pointing at it.90 91 # object still exists at this point (because a S martPtr points at it)92 93 delete myclass; // now we delete myclass, which also destroys the S martPtr94 95 # object doesn't exist anymore (because the S martPtr is now destroyed)87 myclass->setObject(object); // the object is now stored in a StrongPtr inside myclass 88 89 object->destroy(); // we try to destroy object, but there's still a StrongPtr pointing at it. 90 91 # object still exists at this point (because a StrongPtr points at it) 92 93 delete myclass; // now we delete myclass, which also destroys the StrongPtr 94 95 # object doesn't exist anymore (because the StrongPtr is now destroyed) 96 96 @endcode 97 97 … … 100 100 MyClass* myclass = new MyClass(); // create an instance of MyClass 101 101 OtherClass* object = new OtherClass(); // create an instance of OtherClass 102 myclass->setObject(object); // the object is now stored in a S martPtr inside myclass103 104 delete myclass; // we delete myclass, which also destroys the S martPtr102 myclass->setObject(object); // the object is now stored in a StrongPtr inside myclass 103 104 delete myclass; // we delete myclass, which also destroys the StrongPtr 105 105 106 106 # object still exists at this point (because destroy() was not called yet) … … 112 112 113 113 Note that in any case @c object->destroy() has to be called to delete the object. 114 However if a S martPtr points at it, the destruction is delayed until all SmartPtr114 However if a StrongPtr points at it, the destruction is delayed until all StrongPtr 115 115 are destroyed. 116 116 */ 117 117 118 #ifndef _S martPtr_H__119 #define _S martPtr_H__118 #ifndef _StrongPtr_H__ 119 #define _StrongPtr_H__ 120 120 121 121 #include "core/CorePrereqs.h" … … 129 129 { 130 130 /** 131 @brief A s mart pointer which wraps a pointer to an object and keeps this object alive as long as the smartpointer exists.132 133 @see See @ref S martPtrExample "this description" for more information and an example.131 @brief A strong pointer which wraps a pointer to an object and keeps this object alive as long as the strong pointer exists. 132 133 @see See @ref StrongPtrExample "this description" for more information and an example. 134 134 */ 135 135 template <class T> 136 class S martPtr136 class StrongPtr 137 137 { 138 138 public: 139 /// Constructor: Initializes the s martpointer with a null pointer.140 inline S martPtr() : pointer_(0), base_(0)141 { 142 } 143 144 /// Constructor: Initializes the s martpointer with a pointer to an object. @param pointer The pointer @param bAddRef If true, the reference counter is increased. Don't set this to false unless you know exactly what you're doing! (for example to avoid circular references if the @c this pointer of the possessing object is stored)145 inline S martPtr(T* pointer, bool bAddRef = true) : pointer_(pointer), base_(pointer)139 /// Constructor: Initializes the strong pointer with a null pointer. 140 inline StrongPtr() : pointer_(0), base_(0) 141 { 142 } 143 144 /// Constructor: Initializes the strong pointer with a pointer to an object. @param pointer The pointer @param bAddRef If true, the reference counter is increased. Don't set this to false unless you know exactly what you're doing! (for example to avoid circular references if the @c this pointer of the possessing object is stored) 145 inline StrongPtr(T* pointer, bool bAddRef = true) : pointer_(pointer), base_(pointer) 146 146 { 147 147 if (this->base_ && bAddRef) … … 150 150 151 151 /// Copy-constructor 152 inline S martPtr(const SmartPtr& other) : pointer_(other.pointer_), base_(other.base_)152 inline StrongPtr(const StrongPtr& other) : pointer_(other.pointer_), base_(other.base_) 153 153 { 154 154 if (this->base_) … … 156 156 } 157 157 158 /// Copy-constructor for s martpointers to objects of another class.158 /// Copy-constructor for strong pointers to objects of another class. 159 159 template <class O> 160 inline S martPtr(const SmartPtr<O>& other) : pointer_(other.get()), base_(other.base_)160 inline StrongPtr(const StrongPtr<O>& other) : pointer_(other.get()), base_(other.base_) 161 161 { 162 162 if (this->base_) … … 164 164 } 165 165 166 /// Constructor: Initializes the s martpointer with the pointer that is stored in a WeakPtr.166 /// Constructor: Initializes the strong pointer with the pointer that is stored in a WeakPtr. 167 167 template <class O> 168 inline S martPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase())168 inline StrongPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase()) 169 169 { 170 170 if (this->base_) … … 173 173 174 174 /// Destructor: Decrements the reference counter. 175 inline ~S martPtr()175 inline ~StrongPtr() 176 176 { 177 177 if (this->base_) … … 180 180 181 181 /// Assigns a new pointer. 182 inline S martPtr& operator=(T* pointer)183 { 184 S martPtr(pointer).swap(*this);182 inline StrongPtr& operator=(T* pointer) 183 { 184 StrongPtr(pointer).swap(*this); 185 185 return *this; 186 186 } 187 187 188 /// Assigns the wrapped pointer of another S martPtr.189 inline S martPtr& operator=(const SmartPtr& other)190 { 191 S martPtr(other).swap(*this);188 /// Assigns the wrapped pointer of another StrongPtr. 189 inline StrongPtr& operator=(const StrongPtr& other) 190 { 191 StrongPtr(other).swap(*this); 192 192 return *this; 193 193 } 194 194 195 /// Assigns the wrapped pointer of a S martPtr of another class195 /// Assigns the wrapped pointer of a StrongPtr of another class 196 196 template <class O> 197 inline S martPtr& operator=(const SmartPtr<O>& other)198 { 199 S martPtr(other).swap(*this);197 inline StrongPtr& operator=(const StrongPtr<O>& other) 198 { 199 StrongPtr(other).swap(*this); 200 200 return *this; 201 201 } … … 203 203 /// Assigns the wrapped pointer of a WeakPtr. 204 204 template <class O> 205 inline S martPtr& operator=(const WeakPtr<O>& other)206 { 207 S martPtr(other).swap(*this);205 inline StrongPtr& operator=(const WeakPtr<O>& other) 206 { 207 StrongPtr(other).swap(*this); 208 208 return *this; 209 209 } … … 221 221 } 222 222 223 /// Implicitly converts the S martPtr to a pointer of type @c T*223 /// Implicitly converts the StrongPtr to a pointer of type @c T* 224 224 inline operator T*() const 225 225 { … … 247 247 } 248 248 249 /// Swaps the contents of two s martpointers.250 inline void swap(S martPtr& other)249 /// Swaps the contents of two strong pointers. 250 inline void swap(StrongPtr& other) 251 251 { 252 252 { … … 262 262 } 263 263 264 /// Resets the s martpointer (equivalent to assigning a NULL pointer).264 /// Resets the strong pointer (equivalent to assigning a NULL pointer). 265 265 inline void reset() 266 266 { 267 S martPtr().swap(*this);267 StrongPtr().swap(*this); 268 268 } 269 269 270 270 private: 271 271 T* pointer_; ///< The wrapped pointer to an object of type @a T 272 Destroyable* base_; ///< The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, S martPtr couln't be used with forward declarations)272 Destroyable* base_; ///< The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, StrongPtr couln't be used with forward declarations) 273 273 }; 274 274 275 /// Swaps the contents of two s martpointers.275 /// Swaps the contents of two strong pointers. 276 276 template <class T> 277 void swap(S martPtr<T>& a, SmartPtr<T>& b)277 void swap(StrongPtr<T>& a, StrongPtr<T>& b) 278 278 { 279 279 a.swap(b); 280 280 } 281 281 282 /// Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new S martPtr<T>.282 /// Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>. 283 283 template <class T, class U> 284 S martPtr<T> static_pointer_cast(const SmartPtr<U>& p)284 StrongPtr<T> static_pointer_cast(const StrongPtr<U>& p) 285 285 { 286 286 return static_cast<T*>(p.get()); 287 287 } 288 288 289 /// Uses a const_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new S martPtr<T>.289 /// Uses a const_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>. 290 290 template <class T, class U> 291 S martPtr<T> const_pointer_cast(const SmartPtr<U>& p)291 StrongPtr<T> const_pointer_cast(const StrongPtr<U>& p) 292 292 { 293 293 return const_cast<T*>(p.get()); 294 294 } 295 295 296 /// Uses a dynamic_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new S martPtr<T>.296 /// Uses a dynamic_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>. 297 297 template <class T, class U> 298 S martPtr<T> dynamic_pointer_cast(const SmartPtr<U>& p)298 StrongPtr<T> dynamic_pointer_cast(const StrongPtr<U>& p) 299 299 { 300 300 return orxonox_cast<T*>(p.get()); … … 302 302 } 303 303 304 #endif /* _S martPtr_H__ */304 #endif /* _StrongPtr_H__ */ -
code/branches/core7/src/libraries/network/synchronisable/Serialise.h
r9667 r10555 78 78 } 79 79 80 // These functions implement loading / saving / etc. for S martPtr<T>80 // These functions implement loading / saving / etc. for StrongPtr<T> 81 81 82 82 /** @brief returns the size of the objectID needed to synchronise the pointer */ 83 template <class T> inline uint32_t returnSize( const S martPtr<T>& )83 template <class T> inline uint32_t returnSize( const StrongPtr<T>& ) 84 84 { 85 85 return sizeof(uint32_t); … … 87 87 88 88 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 89 template <class T> inline void loadAndIncrease( const S martPtr<T>& variable, uint8_t*& mem )89 template <class T> inline void loadAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem ) 90 90 { 91 91 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 92 *const_cast<typename Loki::TypeTraits<S martPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));92 *const_cast<typename Loki::TypeTraits<StrongPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem))); 93 93 mem += returnSize( variable ); 94 94 } 95 95 96 96 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 97 template <class T> inline void saveAndIncrease( const S martPtr<T>& variable, uint8_t*& mem )97 template <class T> inline void saveAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem ) 98 98 { 99 99 if ( variable.get() ) … … 105 105 106 106 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 107 template <class T> inline bool checkEquality( const S martPtr<T>& variable, uint8_t* mem )107 template <class T> inline bool checkEquality( const StrongPtr<T>& variable, uint8_t* mem ) 108 108 { 109 109 if ( variable.get() ) … … 125 125 { 126 126 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 127 *const_cast<typename Loki::TypeTraits<S martPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));127 *const_cast<typename Loki::TypeTraits<StrongPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem))); 128 128 mem += returnSize( variable ); 129 129 } -
code/branches/core7/src/modules/overlays/hud/HUDHealthBar.h
r9667 r10555 115 115 private: 116 116 WeakPtr<Pawn> owner_; 117 S martPtr<OverlayText> textoverlay_;117 StrongPtr<OverlayText> textoverlay_; 118 118 bool bUseBarColour_; 119 119 ColourValue textColour_; -
code/branches/core7/src/modules/pickup/PickupSpawner.cc
r9667 r10555 145 145 if(GameMode::isMaster() && this->isActive()) 146 146 { 147 WeakPtr<PickupSpawner> spawner = this; // Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 147 // TODO: why is this a WeakPtr when the comment says StrongPtr? 148 WeakPtr<PickupSpawner> spawner = this; // Create a strong pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 148 149 149 150 // Remove PickupCarriers from the blocked list if they have exceeded their time. -
code/branches/core7/src/modules/pickup/items/ShrinkPickup.cc
r9667 r10555 182 182 183 183 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 184 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();184 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 185 185 int size = cameraPositions.size(); 186 186 for(int index = 0; index < size; index++) … … 208 208 209 209 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 210 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();210 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 211 211 int size = cameraPositions.size(); 212 212 for(int index = 0; index < size; index++) … … 263 263 264 264 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 265 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();265 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 266 266 int size = cameraPositions.size(); 267 267 for(int index = 0; index < size; index++) … … 304 304 305 305 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 306 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();306 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 307 307 int size = cameraPositions.size(); 308 308 for(int index = 0; index < size; index++) -
code/branches/core7/src/modules/tetris/Tetris.cc
r9834 r10555 104 104 } 105 105 106 for (std::list<S martPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)106 for (std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 107 107 (*it)->destroy(); 108 108 this->stones_.clear(); … … 136 136 return false; 137 137 138 for(std::list<S martPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)138 for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 139 139 { 140 140 const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone … … 192 192 193 193 // check for collisions with all stones 194 for(std::list<S martPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)194 for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 195 195 { 196 196 //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount()); … … 469 469 { 470 470 stonesPerRow = 0; 471 for(std::list<S martPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )472 { 473 std::list<S martPtr<TetrisStone> >::iterator it_temp = it++;471 for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ) 472 { 473 std::list<StrongPtr<TetrisStone> >::iterator it_temp = it++; 474 474 correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize()); 475 475 if(correctPosition == row) … … 491 491 void Tetris::clearRow(unsigned int row) 492 492 {// clear the full row 493 for(std::list<S martPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )493 for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ) 494 494 { 495 495 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row) … … 502 502 } 503 503 // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug. 504 for(std::list<S martPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)504 for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 505 505 { 506 506 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row) -
code/branches/core7/src/modules/tetris/Tetris.h
r9833 r10555 94 94 95 95 WeakPtr<TetrisCenterpoint> center_; //!< The playing field. 96 std::list<S martPtr<TetrisStone> > stones_; //!< A list of all stones in play.96 std::list<StrongPtr<TetrisStone> > stones_; //!< A list of all stones in play. 97 97 WeakPtr<TetrisBrick> activeBrick_; 98 98 WeakPtr<TetrisBrick> futureBrick_; -
code/branches/core7/src/orxonox/Scene.cc
r10415 r10555 62 62 RegisterObject(Scene); 63 63 64 this->setScene(S martPtr<Scene>(this, false), OBJECTID_UNKNOWN);64 this->setScene(StrongPtr<Scene>(this, false), OBJECTID_UNKNOWN); 65 65 this->bShadows_ = true; 66 66 this->bDebugDrawPhysics_ = false; … … 366 366 { 367 367 // get the WorldEntity pointers 368 S martPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());369 S martPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());368 StrongPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer()); 369 StrongPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer()); 370 370 371 371 // get the CollisionShape pointers -
code/branches/core7/src/orxonox/gametypes/Gametype.cc
r10554 r10555 61 61 RegisterObject(Gametype); 62 62 63 this->setGametype(S martPtr<Gametype>(this, false));63 this->setGametype(StrongPtr<Gametype>(this, false)); 64 64 65 65 this->gtinfo_ = new GametypeInfo(context); -
code/branches/core7/src/orxonox/interfaces/RadarViewable.h
r9939 r10555 37 37 #include "util/Math.h" 38 38 #include "core/class/OrxonoxInterface.h" 39 #include "core/object/S martPtr.h"39 #include "core/object/StrongPtr.h" 40 40 41 41 namespace orxonox … … 163 163 //Radar 164 164 const WorldEntity* wePtr_; 165 S martPtr<Radar> radar_;165 StrongPtr<Radar> radar_; 166 166 float radarObjectCamouflage_; 167 167 Shape radarObjectShape_; -
code/branches/core7/src/orxonox/overlays/OverlayGroup.cc
r10347 r10555 61 61 OverlayGroup::~OverlayGroup() 62 62 { 63 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)63 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 64 64 (*it)->destroy(); 65 65 this->hudElements_.clear(); … … 85 85 void OverlayGroup::setScale(const Vector2& scale) 86 86 { 87 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)87 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 88 88 (*it)->scale(scale / this->scale_); 89 89 this->scale_ = scale; … … 93 93 void OverlayGroup::setScroll(const Vector2& scroll) 94 94 { 95 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)95 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 96 96 (*it)->scroll(scroll - this->scroll_); 97 97 this->scroll_ = scroll; … … 106 106 void OverlayGroup::addElement(OrxonoxOverlay* element) 107 107 { 108 hudElements_.insert(S martPtr<OrxonoxOverlay>(element));108 hudElements_.insert(StrongPtr<OrxonoxOverlay>(element)); 109 109 element->setOverlayGroup( this ); 110 110 if (this->owner_) … … 122 122 bool OverlayGroup::removeElement(OrxonoxOverlay* element) 123 123 { 124 if(this->hudElements_.erase(S martPtr<OrxonoxOverlay>(element)) == 0)124 if(this->hudElements_.erase(StrongPtr<OrxonoxOverlay>(element)) == 0) 125 125 return false; 126 126 return true; … … 132 132 if (index < this->hudElements_.size()) 133 133 { 134 std::set< S martPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin();134 std::set< StrongPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin(); 135 135 for (unsigned int i = 0; i != index; ++it, ++i) 136 136 ; … … 146 146 SUPER( OverlayGroup, changedVisibility ); 147 147 148 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)148 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 149 149 (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed 150 150 } … … 155 155 SUPER( OverlayGroup, changedGametype ); 156 156 157 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)157 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 158 158 (*it)->setGametype(this->getGametype()); 159 159 } … … 163 163 this->owner_ = owner; 164 164 165 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)165 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 166 166 (*it)->setOwner(owner); 167 167 } -
code/branches/core7/src/orxonox/overlays/OverlayGroup.h
r9667 r10555 65 65 static void scrollGroup(const std::string& name, const Vector2& scroll); 66 66 67 inline const std::set< S martPtr<OrxonoxOverlay> >& getOverlays() const67 inline const std::set< StrongPtr<OrxonoxOverlay> >& getOverlays() const 68 68 { return this->hudElements_; } 69 69 … … 92 92 93 93 private: 94 std::set< S martPtr<OrxonoxOverlay> > hudElements_; //!< Contains all the OrxonoxOverlays of the this group.94 std::set< StrongPtr<OrxonoxOverlay> > hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 95 95 Vector2 scale_; //!< Current scale (independent of the elements). 96 96 Vector2 scroll_; //!< Current scrolling offset. -
code/branches/core7/src/orxonox/sound/AmbientSound.cc
r10380 r10555 51 51 if (GameMode::playsSound()) 52 52 { 53 // Smoothly fade out by keeping a S martPtr53 // Smoothly fade out by keeping a StrongPtr 54 54 SoundManager::getInstance().unregisterAmbientSound(this); 55 55 } -
code/branches/core7/src/orxonox/sound/SoundBuffer.h
r6764 r10555 46 46 friend class SoundManager; 47 47 #if !defined(_MSC_VER) || _MSC_VER >= 1500 48 // Make sure nobody deletes an instance (using s martpointers)48 // Make sure nobody deletes an instance (using strong pointers) 49 49 template <class T> 50 50 friend void boost::checked_delete(T*); -
code/branches/core7/src/orxonox/sound/SoundManager.cc
r10464 r10555 165 165 SoundManager::~SoundManager() 166 166 { 167 // Erase fade lists because of the s martpointers167 // Erase fade lists because of the strong pointers 168 168 this->bDestructorCalled_ = true; 169 169 this->fadeInList_.clear(); … … 419 419 } 420 420 421 void SoundManager::fadeIn(const S martPtr<AmbientSound>& sound)421 void SoundManager::fadeIn(const StrongPtr<AmbientSound>& sound) 422 422 { 423 423 // If we're already fading out --> remove that 424 for (std::list<S martPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)424 for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++) 425 425 { 426 426 if (*it == sound) … … 435 435 } 436 436 437 void SoundManager::fadeOut(const S martPtr<AmbientSound>& sound)437 void SoundManager::fadeOut(const StrongPtr<AmbientSound>& sound) 438 438 { 439 439 // If we're already fading in --> remove that 440 for (std::list<S martPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)440 for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++) 441 441 { 442 442 if (*it == sound) … … 461 461 462 462 // FADE IN 463 for (std::list<S martPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )463 for (std::list<StrongPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); ) 464 464 { 465 465 if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f) … … 476 476 477 477 // FADE OUT 478 for (std::list<S martPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )478 for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); ) 479 479 { 480 480 if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f) -
code/branches/core7/src/orxonox/sound/SoundManager.h
r10413 r10555 40 40 #include "util/Singleton.h" 41 41 #include "core/config/Configurable.h" 42 #include "core/object/S martPtr.h"42 #include "core/object/StrongPtr.h" 43 43 #include "core/UpdateListener.h" 44 44 … … 106 106 private: 107 107 void processCrossFading(float dt); 108 void fadeIn(const S martPtr<AmbientSound>& sound);109 void fadeOut(const S martPtr<AmbientSound>& sound);108 void fadeIn(const StrongPtr<AmbientSound>& sound); 109 void fadeOut(const StrongPtr<AmbientSound>& sound); 110 110 111 111 void checkFadeStepValidity(); … … 129 129 //! Absolute change per second (0.1 means 10% of the nominal volume) for cross fading 130 130 float crossFadeStep_; 131 std::list<S martPtr<AmbientSound> > fadeInList_;132 std::list<S martPtr<AmbientSound> > fadeOutList_;131 std::list<StrongPtr<AmbientSound> > fadeInList_; 132 std::list<StrongPtr<AmbientSound> > fadeOutList_; 133 133 134 134 // Volume related -
code/branches/core7/src/orxonox/worldentities/ControllableEntity.cc
r10478 r10555 108 108 this->camera_->destroy(); 109 109 110 for (std::list<S martPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)110 for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 111 111 (*it)->destroy(); 112 112 … … 165 165 { 166 166 unsigned int i = 0; 167 for (std::list<S martPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)167 for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 168 168 { 169 169 if (i == index) … … 180 180 181 181 unsigned int counter = 0; 182 for (std::list<S martPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)182 for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 183 183 { 184 184 if ((*it) == this->currentCameraPosition_) … … 219 219 else if (this->cameraPositions_.size() > 0) 220 220 { 221 for (std::list<S martPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)221 for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 222 222 { 223 223 if ((*it) == this->camera_->getParent()) … … 477 477 if (parent) 478 478 { 479 for (std::list<S martPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)479 for (std::list<StrongPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 480 480 if ((*it)->getIsAbsolute()) 481 481 parent->attach((*it)); -
code/branches/core7/src/orxonox/worldentities/ControllableEntity.h
r9667 r10555 114 114 void addCameraPosition(CameraPosition* position); 115 115 CameraPosition* getCameraPosition(unsigned int index) const; 116 inline const std::list<S martPtr<CameraPosition> >& getCameraPositions() const116 inline const std::list<StrongPtr<CameraPosition> >& getCameraPositions() const 117 117 { return this->cameraPositions_; } 118 118 unsigned int getCurrentCameraIndex() const; … … 235 235 bool bMouseLook_; 236 236 float mouseLookSpeed_; 237 std::list<S martPtr<CameraPosition> > cameraPositions_;237 std::list<StrongPtr<CameraPosition> > cameraPositions_; 238 238 CameraPosition* currentCameraPosition_; 239 239 std::string cameraPositionTemplate_; -
code/branches/core7/src/orxonox/worldentities/WorldEntity.cc
r10362 r10555 130 130 WorldEntity* entity = *it; 131 131 132 // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to s martpointers pointing to it132 // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to strong pointers pointing to it 133 133 entity->setPosition(entity->getWorldPosition()); 134 134 this->detach(entity); // detach also erases the element from the children set -
code/branches/core7/test/core/CMakeLists.txt
r10407 r10555 26 26 object/ObjectListBaseTest.cc 27 27 object/ObjectListIteratorTest.cc 28 object/S martPtrTest.cc28 object/StrongPtrTest.cc 29 29 object/WeakPtrTest.cc 30 30 singleton/ScopeTest.cc -
code/branches/core7/test/core/object/StrongPtrTest.cc
r10553 r10555 1 1 #include <gtest/gtest.h> 2 #include "core/object/S martPtr.h"2 #include "core/object/StrongPtr.h" 3 3 4 4 namespace orxonox … … 17 17 } 18 18 19 TEST(S martPtrTest, CanReferenceObject)19 TEST(StrongPtrTest, CanReferenceObject) 20 20 { 21 21 bool bla; 22 22 DestroyableTest* test = new DestroyableTest(bla); 23 S martPtr<DestroyableTest> smartPtr = test;24 EXPECT_EQ(test, s martPtr.get());23 StrongPtr<DestroyableTest> strongPtr = test; 24 EXPECT_EQ(test, strongPtr.get()); 25 25 test->destroy(); 26 26 } 27 27 28 TEST(S martPtrTest, IncreasesReferenceCount)28 TEST(StrongPtrTest, IncreasesReferenceCount) 29 29 { 30 30 bool bla; … … 32 32 EXPECT_EQ(0u, test->getReferenceCount()); 33 33 { 34 S martPtr<DestroyableTest> smartPtr = test;34 StrongPtr<DestroyableTest> strongPtr = test; 35 35 EXPECT_EQ(1u, test->getReferenceCount()); 36 36 } … … 39 39 } 40 40 41 TEST(S martPtrTest, DestroyDeletesInstance)41 TEST(StrongPtrTest, DestroyDeletesInstance) 42 42 { 43 43 bool destroyed = false; … … 48 48 } 49 49 50 TEST(S martPtrTest, PreventsDestruction)50 TEST(StrongPtrTest, PreventsDestruction) 51 51 { 52 52 bool destroyed = false; 53 53 DestroyableTest* test = new DestroyableTest(destroyed); 54 54 EXPECT_FALSE(destroyed); 55 S martPtr<DestroyableTest> smartPtr = test;55 StrongPtr<DestroyableTest> strongPtr = test; 56 56 test->destroy(); 57 57 EXPECT_FALSE(destroyed); 58 58 } 59 59 60 TEST(S martPtrTest, DestroysIfSmartPtrRemoved)60 TEST(StrongPtrTest, DestroysIfStrongPtrRemoved) 61 61 { 62 62 bool destroyed = false; … … 64 64 EXPECT_FALSE(destroyed); 65 65 { 66 S martPtr<DestroyableTest> smartPtr = test;66 StrongPtr<DestroyableTest> strongPtr = test; 67 67 test->destroy(); 68 68 EXPECT_FALSE(destroyed); … … 71 71 } 72 72 73 TEST(S martPtrTest, DestroysIfAllSmartPtrsRemoved)73 TEST(StrongPtrTest, DestroysIfAllStrongPtrsRemoved) 74 74 { 75 75 bool destroyed = false; … … 77 77 EXPECT_FALSE(destroyed); 78 78 { 79 S martPtr<DestroyableTest> smartPtr1 = test;79 StrongPtr<DestroyableTest> strongPtr1 = test; 80 80 { 81 S martPtr<DestroyableTest> smartPtr2 = test;81 StrongPtr<DestroyableTest> strongPtr2 = test; 82 82 { 83 S martPtr<DestroyableTest> smartPtr3 = test;83 StrongPtr<DestroyableTest> strongPtr3 = test; 84 84 test->destroy(); 85 85 EXPECT_FALSE(destroyed); … … 92 92 } 93 93 94 void isNull(const S martPtr<DestroyableTest> smartPtr)94 void isNull(const StrongPtr<DestroyableTest> strongPtr) 95 95 { 96 EXPECT_TRUE(s martPtr == NULL);97 EXPECT_TRUE(s martPtr == 0);98 EXPECT_TRUE(!s martPtr);99 EXPECT_FALSE(s martPtr != NULL);100 EXPECT_FALSE(s martPtr != 0);101 EXPECT_FALSE(s martPtr);96 EXPECT_TRUE(strongPtr == NULL); 97 EXPECT_TRUE(strongPtr == 0); 98 EXPECT_TRUE(!strongPtr); 99 EXPECT_FALSE(strongPtr != NULL); 100 EXPECT_FALSE(strongPtr != 0); 101 EXPECT_FALSE(strongPtr); 102 102 } 103 103 104 TEST(S martPtrTest, IsNull)104 TEST(StrongPtrTest, IsNull) 105 105 { 106 106 { 107 S martPtr<DestroyableTest> smartPtr;108 isNull(s martPtr);107 StrongPtr<DestroyableTest> strongPtr; 108 isNull(strongPtr); 109 109 } 110 110 { 111 S martPtr<DestroyableTest> smartPtr = NULL;112 isNull(s martPtr);111 StrongPtr<DestroyableTest> strongPtr = NULL; 112 isNull(strongPtr); 113 113 } 114 114 { 115 S martPtr<DestroyableTest> smartPtr;116 s martPtr = NULL;117 isNull(s martPtr);115 StrongPtr<DestroyableTest> strongPtr; 116 strongPtr = NULL; 117 isNull(strongPtr); 118 118 } 119 119 { 120 S martPtr<DestroyableTest> smartPtr = 0;121 isNull(s martPtr);120 StrongPtr<DestroyableTest> strongPtr = 0; 121 isNull(strongPtr); 122 122 } 123 123 { 124 S martPtr<DestroyableTest> smartPtr;125 s martPtr = 0;126 isNull(s martPtr);124 StrongPtr<DestroyableTest> strongPtr; 125 strongPtr = 0; 126 isNull(strongPtr); 127 127 } 128 128 } 129 129 130 TEST(S martPtrTest, IsNotNull)130 TEST(StrongPtrTest, IsNotNull) 131 131 { 132 132 bool destroyed = false; 133 133 DestroyableTest* test = new DestroyableTest(destroyed); 134 S martPtr<DestroyableTest> smartPtr = test;135 EXPECT_FALSE(s martPtr == NULL);136 EXPECT_FALSE(s martPtr == 0);137 EXPECT_FALSE(!s martPtr);138 EXPECT_TRUE(s martPtr != NULL);139 EXPECT_TRUE(s martPtr != 0);140 EXPECT_TRUE(s martPtr);134 StrongPtr<DestroyableTest> strongPtr = test; 135 EXPECT_FALSE(strongPtr == NULL); 136 EXPECT_FALSE(strongPtr == 0); 137 EXPECT_FALSE(!strongPtr); 138 EXPECT_TRUE(strongPtr != NULL); 139 EXPECT_TRUE(strongPtr != 0); 140 EXPECT_TRUE(strongPtr); 141 141 test->destroy(); 142 142 }
Note: See TracChangeset
for help on using the changeset viewer.