RefCountedObj.h 800 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. /// \file
  11. /// \brief \b Reference counted object. Very simple class for quick and dirty uses.
  12. ///
  13. #ifndef __REF_COUNTED_OBJ_H
  14. #define __REF_COUNTED_OBJ_H
  15. #include "RakMemoryOverride.h"
  16. /// World's simplest class :)
  17. class RefCountedObj
  18. {
  19. public:
  20. RefCountedObj() {refCount=1;}
  21. virtual ~RefCountedObj() {}
  22. void AddRef(void) {refCount++;}
  23. void Deref(void) {if (--refCount==0) RakNet::OP_DELETE(this, _FILE_AND_LINE_);}
  24. int refCount;
  25. };
  26. #endif
粤ICP备19079148号