2020-09-06 19:01:12 +01:00
|
|
|
#ifndef VOXEL_VIEWER_REF_COUNT_H
|
|
|
|
#define VOXEL_VIEWER_REF_COUNT_H
|
|
|
|
|
2021-12-13 21:38:10 +00:00
|
|
|
#include <core/error/error_macros.h>
|
|
|
|
|
2021-04-15 20:16:27 +01:00
|
|
|
class VoxelRefCount {
|
2020-09-06 19:01:12 +01:00
|
|
|
public:
|
2021-04-15 20:16:27 +01:00
|
|
|
inline void add() {
|
|
|
|
++_count;
|
2020-09-06 19:01:12 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:16:27 +01:00
|
|
|
inline void remove() {
|
|
|
|
ERR_FAIL_COND_MSG(_count == 0, "Trying to decrease refcount when it's already zero");
|
|
|
|
--_count;
|
2020-09-06 19:01:12 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:16:27 +01:00
|
|
|
inline unsigned int get() const {
|
|
|
|
return _count;
|
2020-09-06 19:01:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2021-04-15 20:16:27 +01:00
|
|
|
unsigned int _count = 0;
|
2020-09-06 19:01:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOXEL_VIEWER_REF_COUNT_H
|