destroy support added
This commit is contained in:
@@ -43,6 +43,23 @@ CDRMonitor::init(void *)
|
||||
theone=new CDRMonitor;
|
||||
}
|
||||
|
||||
void
|
||||
CDRMonitor::destroy()
|
||||
{
|
||||
if (theone)
|
||||
{
|
||||
CDRNode *node = theone->first();
|
||||
while (node)
|
||||
{
|
||||
CDRNode* tmp = node;
|
||||
node = node->next();
|
||||
delete tmp;
|
||||
}
|
||||
delete theone;
|
||||
theone = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CDRMonitor::CDRMonitor()
|
||||
:firstNode(0)
|
||||
{}
|
||||
@@ -59,21 +76,25 @@ CDRMonitor::current()
|
||||
}
|
||||
|
||||
void
|
||||
CDRMonitor::show(FILE *fd)
|
||||
CDRMonitor::show(FILE *fd, bool destroy)
|
||||
{
|
||||
for(CDRNode *cur=first(); !!cur; cur=cur->next())
|
||||
{
|
||||
cur->show(fd);
|
||||
}
|
||||
if (destroy)
|
||||
CDRMonitor::destroy();
|
||||
}
|
||||
|
||||
void
|
||||
CDRMonitor::show(std::ostream& out) const
|
||||
CDRMonitor::show(std::ostream& out, bool destroy) const
|
||||
{
|
||||
for(CDRNode *cur=first(); !!cur; cur=cur->next())
|
||||
{
|
||||
cur->show(out);
|
||||
}
|
||||
if (destroy)
|
||||
CDRMonitor::destroy();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -36,6 +36,7 @@ class CDRNode;
|
||||
class CDRMonitor : private NoDefaultMethods {
|
||||
public:
|
||||
static CDRMonitor& get();
|
||||
static void destroy();
|
||||
|
||||
CDRNode* addNode(CDRNode& next)
|
||||
{
|
||||
@@ -48,8 +49,8 @@ public:
|
||||
|
||||
CDRNode* first() const{return firstNode;}
|
||||
|
||||
void show(FILE*);
|
||||
void show(std::ostream&) const;
|
||||
void show(FILE*, bool destroy = false);
|
||||
void show(std::ostream&, bool destroy = false) const;
|
||||
private:
|
||||
// Private ctor for singleton
|
||||
CDRMonitor();
|
||||
|
||||
Reference in New Issue
Block a user