printing, report the reference count after the raw pointer.
This makes debugs() statements simpler and their output more
informative. Null pointers are printed as a "NULL" string.
/*
- * $Id: RefCount.h,v 1.9 2005/11/21 22:45:16 wessels Exp $
+ * $Id: RefCount.h,v 1.10 2007/04/06 04:40:58 rousskov Exp $
*
* DEBUG: section xx Refcount allocator
* AUTHOR: Robert Collins
#ifndef _SQUID_REFCOUNT_H_
#define _SQUID_REFCOUNT_H_
+#include <iostream>
+
template <class C>
class RefCount
return --count_;
}
+ unsigned RefCountCount() const { return count_; } // for debugging only
+
private:
mutable unsigned count_;
};
#define RefCountable virtual RefCountable_
+template <class C>
+inline std::ostream &operator <<(std::ostream &os, const RefCount<C> &p)
+{
+ if (p != NULL)
+ return os << p.getRaw() << '*' << p->RefCountCount();
+ else
+ return os << "NULL";
+}
+
#endif /* _SQUID_REFCOUNT_H_ */