12345678910111213141516171819202122232425262728293031 |
- #pragma once
- namespace Framework
- {
- template< class T >
- class ReferenceCounting : public T
- {
- private:
- int ref;
- public:
- ReferenceCounting()
- : T()
- {
- ref = 1;
- }
- T *getThis()
- {
- ref++;
- return this;
- }
- T *release()
- {
- if( !--ref )
- delete this;
- return 0;
- }
- };
- }
|