24 #ifndef __WATCHABLECONTAINERS_H__
25 #define __WATCHABLECONTAINERS_H__
39 mutable typename UNORDERED_SET<T>::iterator
it;
42 cHashSetWatcher(
const char *name, UNORDERED_SET<T>& var) : cStdVectorWatcherBase(name), v(var) {
44 classname = std::string(
"unordered_set<")+opp_typename(
typeid(T))+
">";
48 virtual int size()
const {
return v.size();}
49 virtual std::string
at(
int i)
const {
51 it=v.begin(); itPos=0;
52 }
else if (i==itPos+1 && it!=v.end()) {
56 for (
int k=0; k<i && it!=v.end(); k++) ++it;
60 return std::string(
"out of bounds");
64 virtual std::string
atIt()
const {
65 std::stringstream out;
83 mutable typename std::deque<T>::iterator
it;
86 cDequeWatcher(
const char *name, std::deque<T>& var) : cStdVectorWatcherBase(name), v(var) {
88 classname = std::string(
"deque<")+opp_typename(
typeid(T))+
">";
90 const char *
className()
const {
return classname.c_str();}
92 virtual int size()
const {
return v.size();}
93 virtual std::string
at(
int i)
const {
95 it=v.begin(); itPos=0;
96 }
else if (i==itPos+1 && it!=v.end()) {
100 for (
int k=0; k<i && it!=v.end(); k++) ++it;
104 return std::string(
"out of bounds");
108 virtual std::string
atIt()
const {
109 std::stringstream out;
121 template<
class KeyT,
class ValueT,
class CmpT>
125 UNORDERED_MAP<KeyT,ValueT,CmpT>&
m;
126 mutable typename UNORDERED_MAP<KeyT,ValueT,CmpT>::iterator
it;
130 cHashMapWatcher(
const char *name, UNORDERED_MAP<KeyT,ValueT,CmpT>& var) : cStdVectorWatcherBase(name), m(var) {
132 classname = std::string(
"unordered_map<")+opp_typename(
typeid(KeyT))+
","+opp_typename(
typeid(ValueT))+
">";
136 virtual int size()
const {
return m.size();}
137 virtual std::string
at(
int i)
const {
139 it=m.begin(); itPos=0;
140 }
else if (i==itPos+1 && it!=m.end()) {
144 for (
int k=0; k<i && it!=m.end(); k++) ++it;
148 return std::string(
"out of bounds");
152 virtual std::string
atIt()
const {
153 std::stringstream out;
154 out << it->first <<
" ==> " << it->second;
159 template <
class KeyT,
class ValueT,
class CmpT>
165 template<
class KeyT,
class ValueT,
class CmpT>
169 const UNORDERED_MAP<KeyT,ValueT,CmpT>&
m;
170 mutable typename UNORDERED_MAP<KeyT,ValueT,CmpT>::const_iterator
it;
174 cConstHashMapWatcher(
const char *name,
const UNORDERED_MAP<KeyT,ValueT,CmpT>& var) : cStdVectorWatcherBase(name), m(var) {
176 classname = std::string(
"unordered_map<")+opp_typename(
typeid(KeyT))+
","+opp_typename(
typeid(ValueT))+
">";
180 virtual int size()
const {
return m.size();}
181 virtual std::string
at(
int i)
const {
183 it=m.begin(); itPos=0;
184 }
else if (i==itPos+1 && it!=m.end()) {
188 for (
int k=0; k<i && it!=m.end(); k++) ++it;
192 return std::string(
"out of bounds");
196 virtual std::string
atIt()
const {
197 std::stringstream out;
198 out << it->first <<
" ==> " << it->second;
203 template <
class KeyT,
class ValueT,
class CmpT>
209 template<
class KeyT,
class ValueT,
class CmpT>
213 std::map<KeyT,ValueT,CmpT>&
m;
214 mutable typename std::map<KeyT,ValueT,CmpT>::iterator
it;
218 cPointerMapWatcher(
const char *name, std::map<KeyT,ValueT,CmpT>& var) : cStdVectorWatcherBase(name), m(var) {
220 classname = std::string(
"pointer_map<")+opp_typename(
typeid(KeyT))+
","+opp_typename(
typeid(ValueT))+
">";
224 virtual int size()
const {
return m.size();}
225 virtual std::string
at(
int i)
const {
227 it=m.begin(); itPos=0;
228 }
else if (i==itPos+1 && it!=m.end()) {
232 for (
int k=0; k<i && it!=m.end(); k++) ++it;
236 return std::string(
"out of bounds");
240 virtual std::string
atIt()
const {
241 std::stringstream out;
242 out << it->first <<
" ==> " << *(it->second);
247 template <
class KeyT,
class ValueT,
class CmpT>
253 template<
class KeyT,
class ValueT,
class CmpT>
257 std::multimap<KeyT,ValueT,CmpT>&
m;
258 mutable typename std::multimap<KeyT,ValueT,CmpT>::iterator
it;
262 cStdMultiMapWatcher(
const char *name, std::multimap<KeyT,ValueT,CmpT>& var) : cStdVectorWatcherBase(name),
m(var) {
264 classname = std::string(
"std::multimap<")+opp_typename(
typeid(KeyT))+
","+opp_typename(
typeid(ValueT))+
">";
268 virtual int size()
const {
return m.size();}
269 virtual std::string
at(
int i)
const {
275 }
else if (i==
itPos+1 &&
it!=
m.end()) {
279 for (
int k=0; k<i &&
it!=
m.end(); k++) ++
it;
283 return std::string(
"out of bounds");
287 virtual std::string
atIt()
const {
288 std::stringstream out;
289 out <<
it->first <<
" ==> " <<
it->second;
294 template <
class KeyT,
class ValueT,
class CmpT>
306 #define WATCH_UNORDERED_SET(variable) createHashSetWatcher(#variable,(variable))
313 #define WATCH_DEQUE(variable) createDequeWatcher(#variable,(variable))
320 #define WATCH_UNORDERED_MAP(m) createHashMapWatcher(#m,(m))
327 #define WATCH_POINTER_MAP(m) createPointerMapWatcher(#m,(m))
334 #define WATCH_MULTIMAP(m) createStdMultiMapWatcher(#m,(m))