-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCRateList.cpp
117 lines (92 loc) · 2.26 KB
/
CRateList.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
This software is Copyright by the Board of Trustees of Michigan
State University (c) Copyright 2005.
You may use this software under the terms of the GNU public license
(GPL). The terms of this license are described at:
http://www.gnu.org/licenses/gpl.txt
Author:
Ron Fox
NSCL
Michigan State University
East Lansing, MI 48824-1321
*/
#include <config.h>
#include "CRateList.h"
#ifdef HAVE_STD_NAMESPACE
using namespace std;
#endif
CRateList* CRateList::m_pInstance(0);
/*!
Constructor is no-op but must be implemented so that it can be privatized.
*/
CRateList::CRateList() {}
/*! Return the singleton instance of the class.
*/
CRateList*
CRateList::getInstance()
{
if (!m_pInstance) {
m_pInstance = new CRateList;
}
return m_pInstance;
}
////////////////////////////////////////////////////////////////////////
//////////////////// List operations ///////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/*
Add a processor to the tail of the list.
*/
void
CRateList::addProcessor(CRateProcessor& processor)
{
CRateProcessor* p = &processor;
Entry e(p, false);
m_rates.push_back(e);
}
/*!
Remove a processor from the list... first we need to find it.
- no-op if it does not exist.
*/
void
CRateList::deleteProcessor(CRateProcessor& processor)
{
RateListIterator i = find(processor);
if (i != end()) {
m_rates.erase(i);
}
}
/*!
Mark an item for deletion.
*/
void
CRateList::markForDeletion(CRateProcessor& processor)
{
RateListIterator i= find(processor);
if (i != end()) {
i->second = true;
}
}
////////////////////////////////////////////////////////////////////////
//////////////////////////////// List iteration ////////////////////////
////////////////////////////////////////////////////////////////////////
/*!
Find an event processor. Returns end() if failure.
*/
CRateList::RateListIterator
CRateList::find(CRateProcessor& processor)
{
RateListIterator i = begin();
while (i != end()) {
if (i->first == &processor) break;
i++;
}
return i;
}
CRateList::RateListIterator
CRateList::begin() {
return m_rates.begin();
}
CRateList::RateListIterator
CRateList::end() {
return m_rates.end();
}