ReferenceCounter.cpp 394 B

1234567891011121314151617181920212223242526272829
  1. #include "ReferenceCounter.h"
  2. using namespace Framework;
  3. ReferenceCounter::ReferenceCounter()
  4. {
  5. ref = 1;
  6. }
  7. ReferenceCounter::~ReferenceCounter() {}
  8. int ReferenceCounter::getReferenceCount() const
  9. {
  10. return ref;
  11. }
  12. ReferenceCounter *ReferenceCounter::getThis()
  13. {
  14. ref++;
  15. return this;
  16. }
  17. void *ReferenceCounter::release()
  18. {
  19. if( !--ref )
  20. delete this;
  21. return 0;
  22. }