123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #ifndef CRYINCLUDE_EDITOR_UTIL_REFCOUNTBASE_H
- #define CRYINCLUDE_EDITOR_UTIL_REFCOUNTBASE_H
- #pragma once
- #include <Include/EditorCoreAPI.h>
- #include <CryCommon/ISystem.h>
- class EDITOR_CORE_API CRefCountBase
- {
- public:
- CRefCountBase() {}
-
- int AddRef()
- {
- m_nRefCount++;
- return m_nRefCount;
- }
-
-
- int Release()
- {
- int refs = --m_nRefCount;
- if (m_nRefCount == 0)
- {
- delete this;
- }
- else if (m_nRefCount < 0)
- {
- CryFatalError("Negative ref count");
- }
- return refs;
- }
- protected:
- virtual ~CRefCountBase() {}
- private:
- int m_nRefCount = 0;
- };
- #endif
|