godot_voxel/storage/voxel_ref_count.h

26 lines
430 B
C
Raw Normal View History

2020-09-06 19:01:12 +01:00
#ifndef VOXEL_VIEWER_REF_COUNT_H
#define VOXEL_VIEWER_REF_COUNT_H
#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