123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #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
|