git mv Code\Sandbox\Editor Code/Editor

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-06-29 12:41:59 -07:00
parent 9f0bbf3b74
commit e34e36cb35
1415 changed files with 0 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Reference counted base object.
#ifndef CRYINCLUDE_EDITOR_UTIL_REFCOUNTBASE_H
#define CRYINCLUDE_EDITOR_UTIL_REFCOUNTBASE_H
#pragma once
#include <Include/EditorCoreAPI.h>
//! Derive from this class to get reference counting in your class.
class EDITOR_CORE_API CRefCountBase
{
public:
CRefCountBase() {}
//! Add a new reference to this object.
int AddRef()
{
m_nRefCount++;
return m_nRefCount;
}
//! Release reference to this object.
//! When the reference count reaches zero, the object is deleted.
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 // CRYINCLUDE_EDITOR_UTIL_REFCOUNTBASE_H