--------------------- PatchSet 4037 Date: 2007/02/14 02:30:55 Author: rousskov Branch: squid3-icap Tag: snapshot_b4BodyPipe Log: - Support printing refcounted pointers to ostreams. When 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. Members: include/RefCount.h:1.8.12.1->1.8.12.2 Index: squid3/include/RefCount.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/include/RefCount.h,v retrieving revision 1.8.12.1 retrieving revision 1.8.12.2 diff -u -r1.8.12.1 -r1.8.12.2 --- squid3/include/RefCount.h 17 Oct 2005 23:38:14 -0000 1.8.12.1 +++ squid3/include/RefCount.h 14 Feb 2007 02:30:55 -0000 1.8.12.2 @@ -1,6 +1,6 @@ /* - * $Id: RefCount.h,v 1.8.12.1 2005/10/17 23:38:14 rousskov Exp $ + * $Id: RefCount.h,v 1.8.12.2 2007/02/14 02:30:55 rousskov Exp $ * * DEBUG: section xx Refcount allocator * AUTHOR: Robert Collins @@ -36,6 +36,8 @@ #ifndef _SQUID_REFCOUNT_H_ #define _SQUID_REFCOUNT_H_ +#include + template class RefCount @@ -139,10 +141,21 @@ return --count_; } + unsigned RefCountCount() const { return count_; } // for debugging only + private: mutable unsigned count_; }; #define RefCountable virtual RefCountable_ +template +inline std::ostream &operator <<(std::ostream &os, const RefCount &p) +{ + if (p != NULL) + return os << p.getRaw() << '*' << p->RefCountCount(); + else + return os << "NULL"; +} + #endif /* _SQUID_REFCOUNT_H_ */