Browse Source

allow PStatCollector output

David Rose 18 years ago
parent
commit
1de3b1d9df
2 changed files with 50 additions and 0 deletions
  1. 40 0
      panda/src/pstatclient/pStatCollector.I
  2. 10 0
      panda/src/pstatclient/pStatCollector.h

+ 40 - 0
panda/src/pstatclient/pStatCollector.I

@@ -149,6 +149,46 @@ is_valid() const {
   return (_client != (PStatClient *)NULL);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PStatCollector::get_name
+//       Access: Published
+//  Description: Returns the local name of this collector.  This is
+//               the rightmost part of the fullname, after the
+//               rightmost colon.
+////////////////////////////////////////////////////////////////////
+INLINE string PStatCollector::
+get_name() const {
+  if (_client != (PStatClient *)NULL) {
+    return _client->get_collector_name(_index);
+  }
+  return string();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatCollector::get_fullname
+//       Access: Published
+//  Description: Returns the full name of this collector.  This
+//               includes the names of all the collector's parents,
+//               concatenated together with colons.
+////////////////////////////////////////////////////////////////////
+INLINE string PStatCollector::
+get_fullname() const {
+  if (_client != (PStatClient *)NULL) {
+    return _client->get_collector_fullname(_index);
+  }
+  return string();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PStatCollector::output
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE void PStatCollector::
+output(ostream &out) const {
+  out << "PStatCollector(\"" << get_fullname() << "\")";
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PStatCollector::is_active
 //       Access: Published

+ 10 - 0
panda/src/pstatclient/pStatCollector.h

@@ -69,6 +69,9 @@ PUBLISHED:
   INLINE void operator = (const PStatCollector &copy);
 
   INLINE bool is_valid() const;
+  INLINE string get_name() const;
+  INLINE string get_fullname() const;
+  INLINE void output(ostream &out) const;
 
   INLINE bool is_active();
   INLINE bool is_started();
@@ -152,5 +155,12 @@ PUBLISHED:
 
 #include "pStatCollector.I"
 
+inline ostream &operator << (ostream &out, const PStatCollector &pcol) {
+#ifdef DO_PSTATS
+  pcol.output(out);
+#endif  // DO_PSTATS
+  return out;
+}
+
 #endif