12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #pragma once
- #include "Betriebssystem.h"
- namespace Framework
- {
- template<typename T> class RCPointer
- {
- private:
- T* pointer;
- public:
- static RCPointer<T> of(T* pointer)
- {
- return RCPointer<T>() = pointer;
- }
- RCPointer()
- {
- pointer = 0;
- }
- RCPointer(const RCPointer<T>& ptr)
- {
- this->pointer
- = ptr.pointer ? dynamic_cast<T*>(ptr.pointer->getThis()) : 0;
- }
- ~RCPointer()
- {
- if (pointer) pointer->release();
- }
- RCPointer<T>& operator=(RCPointer<T>& ptr)
- {
- if (this->pointer) this->pointer->release();
- this->pointer
- = ptr.pointer ? dynamic_cast<T*>(ptr.pointer->getThis()) : 0;
- return *this;
- }
- RCPointer<T>& operator=(T* ptr)
- {
- if (this->pointer) this->pointer->release();
- this->pointer = ptr;
- return *this;
- }
- T* operator->()
- {
- return pointer;
- }
- operator T*()
- {
- return pointer;
- }
- };
- } // namespace Framework
|