Mercurial > ~dholland > hg > ag > index.cgi
view anagram/support/agref.h @ 13:43d8b194fb4e
Remove unused variables.
author | David A. Holland |
---|---|
date | Tue, 31 May 2022 00:59:00 -0400 |
parents | 13d2b8934445 |
children |
line wrap: on
line source
/********************************************************** The AnaGram Class Library The AgReference Class Copyright 1997 Parsifal Software. All Rights Reserved. See the file COPYING for license and usage terms. ***********************************************************/ #ifndef AGREF_H #define AGREF_H #include "assert.h" class AgReferenceCount { private: int count; public: AgReferenceCount() : count(0) {} virtual ~AgReferenceCount() { assert(count == 0); } inline AgReferenceCount(const AgReferenceCount &) : count(0) {} inline AgReferenceCount &operator = (const AgReferenceCount &) { return *this; } inline void lock() { count++; } inline int unlock() { /* if (count <= 0) { LOGSECTION("AgReferenceCount::unlock"); LOGV(count); } */ assert(count > 0); return (--count <= 0); } }; class AgReferenceBase { protected: AgReferenceCount *object; void doAssignmentLocks(const AgReferenceBase &r); /* { if (object!=0 && object->unlock()) delete object; object = r.object; if (object != 0) object->lock(); } */ public: AgReferenceBase();// : object(0) {} AgReferenceBase(AgReferenceCount* object_); AgReferenceBase(const AgReferenceBase &r); virtual ~AgReferenceBase(); int exists() const; void discardData(); /* AgReferenceBase(AgReferenceCount* object_) : object(object_) { if (object != 0) object->lock(); } AgReferenceBase(const AgReferenceBase &r) : object(r.object) { if (object!= 0) object->lock(); } virtual ~AgReferenceBase() { if (object!= 0 && object->unlock()) delete object; } int exists() const { return object != 0; } void discardData() { if (object && object->unlock()) delete object; object = 0; } */ }; /* template <class T> class AgReference : public AgReferenceBase { public: inline AgReference() : AgReferenceBase() {} inline AgReference(T *x) : AgReferenceBase(x) {} inline AgReference(const AgReference<T> &r) : AgReferenceBase((const AgReferenceBase &)r) {} inline AgReference<T> &operator = (const AgReference<T> &t) { doAssignmentLocks(t); return *this; } inline T *operator -> () const { return (T *) object; } inline T *pointer() const { return (T *) object; } }; */ #endif /* AGREF_H */