CDRMonitor: print to streams
This commit is contained in:
@@ -67,6 +67,15 @@ CDRMonitor::show(FILE *fd)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CDRMonitor::show(std::ostream& out) const
|
||||
{
|
||||
for(CDRNode *cur=first(); !!cur; cur=cur->next())
|
||||
{
|
||||
cur->show(out);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CDRNode::show(FILE *fd)
|
||||
{
|
||||
@@ -86,6 +95,23 @@ CDRNode::show(FILE *fd)
|
||||
fprintf(fd,"\n");
|
||||
}
|
||||
|
||||
void
|
||||
CDRNode::show(std::ostream& out) const
|
||||
{
|
||||
Lock x(&guard);
|
||||
if(!current.cons && !current.dtys && !current.refs)
|
||||
return;
|
||||
out<<nodeName<<" totalConstruct "<<current.cons
|
||||
<<" totalDestruct "<<current.dtys;
|
||||
ssize_t alive=current.cons;
|
||||
alive-=current.dtys;
|
||||
if(current.refs)
|
||||
out<<" totalReference "<<current.refs;
|
||||
if(alive)
|
||||
out<<" ACTIVE "<<alive;
|
||||
out<<"\n";
|
||||
}
|
||||
|
||||
void
|
||||
onceNode(void* raw)
|
||||
{
|
||||
@@ -93,4 +119,16 @@ onceNode(void* raw)
|
||||
inst->node=new CDRNode(inst->name);
|
||||
}
|
||||
|
||||
}}
|
||||
}} // namespace epics::pvData
|
||||
|
||||
std::ostream& operator<<(std::ostream& out,const epics::pvData::CDRMonitor& mon)
|
||||
{
|
||||
mon.show(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out,const epics::pvData::CDRNode& node)
|
||||
{
|
||||
node.show(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
#ifndef CDRMONITOR_H
|
||||
#define CDRMONITOR_H
|
||||
#include <ostream>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
@@ -46,9 +47,10 @@ public:
|
||||
|
||||
CDRCount current(); //!< current global count
|
||||
|
||||
CDRNode* first(){return firstNode;}
|
||||
CDRNode* first() const{return firstNode;}
|
||||
|
||||
void show(FILE*);
|
||||
void show(std::ostream&) const;
|
||||
private:
|
||||
// Private ctor for singleton
|
||||
CDRMonitor();
|
||||
@@ -77,6 +79,7 @@ public:
|
||||
CDRCount get() const{Lock x(&guard); return current;}
|
||||
|
||||
void show(FILE*);
|
||||
void show(std::ostream&) const;
|
||||
private:
|
||||
const String nodeName;
|
||||
CDRCount current;
|
||||
@@ -130,4 +133,8 @@ static CDRNodeInstance NAME ## _node={0,EPICS_THREAD_ONCE_INIT,#NAME}
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
std::ostream& operator<<(std::ostream&,const epics::pvData::CDRMonitor&);
|
||||
std::ostream& operator<<(std::ostream&,const epics::pvData::CDRNode&);
|
||||
|
||||
#endif /* CDRMONITOR_H */
|
||||
|
||||
Reference in New Issue
Block a user