CDRMonitor: print to streams

This commit is contained in:
Michael Davidsaver
2011-02-09 20:29:08 -05:00
parent 89f5e27577
commit afa17f8f4f
2 changed files with 47 additions and 2 deletions

View File

@@ -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;
}