00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <classlib\listimp.h>
00036
00037 #include "mytrace.h"
00038 #include "bellcode.h"
00039
00040 #include "bclist.h"
00041
00042
00043 using namespace Monitor::BellMaster;
00044
00045
00046
00047 BellCodeList::BellCodeList() :
00048 myList(0), listSize(0)
00049 {
00050 _USEMYTRACE_("BellCodeList::BellCodeList()")
00051 }
00052
00053
00054
00055 BellCodeList::BellCodeList(const BellCodeList& other) :
00056 myList(0), listSize(0)
00057 {
00058 _USEMYTRACE_("BellCodeList::BellCodeList(other)")
00059
00060
00061 operator=(other);
00062 }
00063
00064
00065
00066 BellCodeList::~BellCodeList()
00067 {
00068 _USEMYTRACE_("BellCodeList::~BellCodeList")
00069
00070 clear();
00071 }
00072
00073
00074
00075 const BellCodeList&
00076 BellCodeList::operator=(const BellCodeList& other)
00077 {
00078 _USEMYTRACE_("BellCodeList::operator=(other)")
00079
00080
00081 clear();
00082
00083
00084 TSListIteratorImp< BellCode > otherCodes(other.getList());
00085
00086
00087 while (0 != otherCodes)
00088 {
00089 addBellCode(otherCodes.Current());
00090
00091 otherCodes++;
00092 }
00093
00094 return *this;
00095 }
00096
00097
00098
00099 void
00100 BellCodeList::addBellCode(const BellCode &newBellCode)
00101 {
00102 _USEMYTRACE_("BellCodeList::addBellCode")
00103
00104 getList().Add(newBellCode);
00105 listSize++;
00106 }
00107
00108
00109
00110 void
00111 BellCodeList::removeBellCode(const BellCode &oldBellCode)
00112 {
00113 _USEMYTRACE_("BellCodeList::removeBellCode")
00114
00115 getList().Detach(oldBellCode);
00116 listSize--;
00117 }
00118
00119
00120
00121 void
00122 BellCodeList::clear()
00123 {
00124 _USEMYTRACE_("BellCodeList::clear")
00125
00126 delete myList, myList = 0;
00127 listSize = 0;
00128 }
00129
00130
00131
00132 const unsigned&
00133 BellCodeList::size() const
00134 {
00135 return listSize;
00136 }
00137
00138
00139
00140 BellCode&
00141 BellCodeList::operator[](int index) const
00142 {
00143 TSListIteratorImp< BellCode > bellCodes(getList());
00144
00145 while (0 < index)
00146 {
00147 index--;
00148 bellCodes++;
00149 }
00150
00151 return const_cast< BellCode& >(bellCodes.Current());
00152 }
00153
00154
00155 const BellCodeList
00156 BellCodeList::matchSequence(const string& sequence) const
00157 {
00158 _USEMYTRACE_("BellCodeList::matchSequence(sequence)")
00159
00160
00161 BellCodeList matchedCodes;
00162 TSListIteratorImp< BellCode > bellCodes(getList());
00163
00164
00165 while (0 != bellCodes)
00166 {
00167 if (bellCodes.Current().matchesSequence(sequence))
00168 {
00169 matchedCodes.addBellCode(bellCodes.Current());
00170 }
00171
00172 bellCodes++;
00173 }
00174
00175 return matchedCodes;
00176 }
00177
00178
00179
00180 TSListImp< BellCode >&
00181 BellCodeList::getList() const
00182 {
00183 if (0 == myList)
00184 {
00185 const_cast< BellCodeList* >(this)->myList =
00186 new TSListImp< BellCode >;
00187
00188 const_cast< BellCodeList* >(this)->listSize = 0;
00189 }
00190
00191 return *myList;
00192 }
00193