Changeset 5805 for code/branches
- Timestamp:
- Sep 27, 2009, 2:33:48 AM (15 years ago)
- Location:
- code/branches/core5/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/BaseObject.h
r5738 r5805 53 53 #include "OrxonoxClass.h" 54 54 #include "Super.h" 55 #include "SmartPtr.h" 55 56 56 57 namespace orxonox … … 134 135 inline BaseObject* getCreator() const { return this->creator_; } 135 136 136 inline void setScene( Scene*scene) { this->scene_ = scene; }137 inline Scene*getScene() const { return this->scene_; }137 inline void setScene(const SmartPtr<Scene>& scene) { this->scene_ = scene; } 138 inline const SmartPtr<Scene>& getScene() const { return this->scene_; } 138 139 139 140 inline void setGametype(Gametype* gametype) … … 194 195 Namespace* namespace_; 195 196 BaseObject* creator_; 196 S cene*scene_;197 SmartPtr<Scene> scene_; 197 198 Gametype* gametype_; 198 199 Gametype* oldGametype_; -
code/branches/core5/src/libraries/core/OrxonoxClass.cc
r5804 r5805 55 55 // COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ")" << std::endl; 56 56 57 assert(this->referenceCount_ == 0);57 assert(this->referenceCount_ <= 0); 58 58 59 59 delete this->metaList_; -
code/branches/core5/src/libraries/core/OrxonoxClass.h
r5804 r5805 135 135 std::set<const Identifier*>* parents_; //!< List of all parents of the object 136 136 MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in 137 unsigned int referenceCount_;//!< Counts the references from smart pointers to this object137 int referenceCount_; //!< Counts the references from smart pointers to this object 138 138 bool requestedDestruction_; //!< Becomes true after someone called delete on this object 139 139 -
code/branches/core5/src/libraries/core/SmartPtr.h
r5804 r5805 42 42 { 43 43 public: 44 inline SmartPtr() : pointer_(0) 45 { 46 } 47 48 inline SmartPtr(T* pointer) : pointer_(pointer) 49 { 50 if (this->pointer_) 51 this->pointer_->incrementReferenceCount(); 52 } 53 54 inline SmartPtr(const SmartPtr& other) : pointer_(other.pointer_) 55 { 56 if (this->pointer_) 57 this->pointer_->incrementReferenceCount(); 44 inline SmartPtr() : pointer_(0), base_(0) 45 { 46 } 47 48 inline SmartPtr(int) : pointer_(0), base_(0) 49 { 50 } 51 52 inline SmartPtr(T* pointer, bool bAddRef = true) : pointer_(pointer), base_(pointer) 53 { 54 if (this->base_ && bAddRef) 55 this->base_->incrementReferenceCount(); 56 } 57 58 inline SmartPtr(const SmartPtr& other) : pointer_(other.pointer_), base_(other.base_) 59 { 60 if (this->base_) 61 this->base_->incrementReferenceCount(); 58 62 } 59 63 60 64 template <class O> 61 inline SmartPtr(const SmartPtr<O>& other) : pointer_(other.get()) 62 { 63 if (this-> pointer_)64 this-> pointer_->incrementReferenceCount();65 inline SmartPtr(const SmartPtr<O>& other) : pointer_(other.get()), base_(other.base_) 66 { 67 if (this->base_) 68 this->base_->incrementReferenceCount(); 65 69 } 66 70 67 71 inline ~SmartPtr() 68 72 { 69 if (this->pointer_) 70 this->pointer_->decrementReferenceCount(); 73 if (this->base_) 74 this->base_->decrementReferenceCount(); 75 } 76 77 inline const SmartPtr& operator=(int) 78 { 79 SmartPtr(0).swap(*this); 80 return *this; 71 81 } 72 82 … … 96 106 97 107 inline operator T*() const 98 { std::cout << "(implizit)";108 { 99 109 return this->pointer_; 100 110 } … … 117 127 inline void swap(SmartPtr& other) 118 128 { 119 T* temp = this->pointer_; 120 this->pointer_ = other.pointer_; 121 other.pointer_ = temp; 129 { 130 T* temp = this->pointer_; 131 this->pointer_ = other.pointer_; 132 other.pointer_ = temp; 133 } 134 { 135 OrxonoxClass* temp = this->base_; 136 this->base_ = other.base_; 137 other.base_ = temp; 138 } 122 139 } 123 140 … … 129 146 private: 130 147 T* pointer_; 148 OrxonoxClass* base_; 131 149 }; 132 150 -
code/branches/core5/src/modules/gamestates/GSLevel.cc
r5799 r5805 242 242 void GSLevel::unloadLevel() 243 243 { 244 ////////////////////////////////////////////////////////////////////////////////////////// 245 // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // 246 ////////////////////////////////////////////////////////////////////////////////////////// 247 // Loader::unload(startFile_); // TODO: REACTIVATE THIS IF LOADER::UNLOAD WORKS PROPERLY / 248 ////////////////////////////////////////////////////////////////////////////////////////// 244 Loader::unload(startFile_s); 249 245 250 246 delete startFile_s; -
code/branches/core5/src/orxonox/CameraManager.cc
r5738 r5805 53 53 { 54 54 if (this->fallbackCamera_) 55 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 55 this->fallbackCameraScene_->getSceneManager()->destroyCamera(this->fallbackCamera_); 56 GUIManager::getInstance().setCamera(0); 56 57 } 57 58 … … 74 75 else if (this->fallbackCamera_) 75 76 { 76 this->fallbackCamera _->getSceneManager()->destroyCamera(this->fallbackCamera_);77 this->fallbackCameraScene_->getSceneManager()->destroyCamera(this->fallbackCamera_); 77 78 this->fallbackCamera_ = 0; 78 79 } … … 107 108 // there are no more cameras, create a fallback 108 109 if (!this->fallbackCamera_) 109 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 110 { 111 this->fallbackCameraScene_ = camera->getScene(); 112 this->fallbackCamera_ = this->fallbackCameraScene_->getSceneManager()->createCamera(getUniqueNumberString()); 113 } 110 114 this->useCamera(this->fallbackCamera_); 111 115 } -
code/branches/core5/src/orxonox/CameraManager.h
r3370 r5805 42 42 #include "util/OgreForwardRefs.h" 43 43 #include "util/Singleton.h" 44 #include "core/SmartPtr.h" 44 45 45 46 namespace orxonox … … 67 68 Ogre::Viewport* viewport_; 68 69 Ogre::Camera* fallbackCamera_; 70 SmartPtr<Scene> fallbackCameraScene_; 69 71 70 72 static CameraManager* singletonPtr_s; -
code/branches/core5/src/orxonox/Scene.cc
r5738 r5805 54 54 RegisterObject(Scene); 55 55 56 this->setScene( this);56 this->setScene(SmartPtr<Scene>(this, false)); 57 57 this->bShadows_ = true; 58 58
Note: See TracChangeset
for help on using the changeset viewer.