1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #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( RCPointer &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;
- }
- };
- }
|