From Gideon, support for tracking the number of objects constructed and deleted,

only compiled in when unit tests are compiled in.
This commit is contained in:
Robert Osfield
2002-09-20 15:55:50 +00:00
parent 444a6eaf97
commit fb629ae87d
2 changed files with 34 additions and 2 deletions

View File

@@ -14,8 +14,20 @@ class SG_EXPORT Referenced
{
public:
Referenced() { _refCount=0; }
Referenced(const Referenced&) { _refCount=0; }
Referenced()
{
_refCount=0;
#ifdef OSG_COMPILE_UNIT_TESTS
_createdCount ++;
#endif
}
Referenced(const Referenced&) {
_refCount=0;
#ifdef OSG_COMPILE_UNIT_TESTS
_createdCount ++;
#endif
}
inline Referenced& operator = (Referenced&) { return *this; }
@@ -40,9 +52,21 @@ class SG_EXPORT Referenced
/** return the number pointers currently referencing this object. */
inline int referenceCount() const { return _refCount; }
#ifdef OSG_COMPILE_UNIT_TESTS
/** return the total number of created referenced objects */
inline static int createdCount() { return _createdCount; }
/** return the total number of deleted referenced objects */
inline static int deletedCount() { return _deletedCount; }
#endif
protected:
virtual ~Referenced();
mutable int _refCount;
#ifdef OSG_COMPILE_UNIT_TESTS
static int _createdCount; // incremented in the constructor
static int _deletedCount; // incremented in the destructor
#endif
};