Make WvStreams compile with gcc 4.4.
[wvstreams.git] / include / wvcallbacklist.h
blobdf1155d4db25c4366fa3356da07d1f5f047f5138
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 */
6 #ifndef __WVCALLBACKLIST_H
7 #define __WVCALLBACKLIST_H
9 #include <assert.h>
10 #include <map>
13 template<class InnerCallback>
14 class WvCallbackList
16 private:
17 std::map<void*, InnerCallback> list;
19 /* The idea of copying this gives me a headache. */
20 WvCallbackList(const WvCallbackList &);
21 WvCallbackList& operator=(const WvCallbackList&);
23 public:
24 WvCallbackList()
27 void add(const InnerCallback &cb, void *cookie)
29 assert(list.find(cookie) == list.end());
30 list.insert(std::make_pair(cookie, cb));
32 void del(void *cookie)
34 typename std::map<void*, InnerCallback>::iterator it =
35 list.find(cookie);
36 assert(it != list.end());
37 list.erase(it);
39 bool isempty() const
41 return list.empty();
43 void operator()() const
45 typename std::map<void*, InnerCallback>::const_iterator it;
47 for (it = list.begin(); it != list.end(); ++it)
48 it->second();
50 template<typename P1>
51 void operator()(P1 &p1) const
53 typename std::map<void*, InnerCallback>::const_iterator it;
55 for (it = list.begin(); it != list.end(); ++it)
56 it->second(p1);
58 template<typename P1,
59 typename P2>
60 void operator()(P1 &p1, P2 &p2) const
62 typename std::map<void*, InnerCallback>::const_iterator it;
64 for (it = list.begin(); it != list.end(); ++it)
65 it->second(p1, p2);
67 template<typename P1,
68 typename P2,
69 typename P3>
70 void operator()(P1 &p1, P2 &p2, P3 &p3) const
72 typename std::map<void*, InnerCallback>::const_iterator it;
74 for (it = list.begin(); it != list.end(); ++it)
75 it->second(p1, p2, p3);
77 template<typename P1,
78 typename P2,
79 typename P3,
80 typename P4>
81 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4) const
83 typename std::map<void*, InnerCallback>::const_iterator it;
85 for (it = list.begin(); it != list.end(); ++it)
86 it->second(p1, p2, p3, p4);
88 template<typename P1,
89 typename P2,
90 typename P3,
91 typename P4,
92 typename P5>
93 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5) const
95 typename std::map<void*, InnerCallback>::const_iterator it;
97 for (it = list.begin(); it != list.end(); ++it)
98 it->second(p1, p2, p3, p4, p5);
100 template<typename P1,
101 typename P2,
102 typename P3,
103 typename P4,
104 typename P5,
105 typename P6>
106 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5, P6 &p6) const
108 typename std::map<void*, InnerCallback>::const_iterator it;
110 for (it = list.begin(); it != list.end(); ++it)
111 it->second(p1, p2, p3, p4, p5, p6);
113 template<typename P1,
114 typename P2,
115 typename P3,
116 typename P4,
117 typename P5,
118 typename P6,
119 typename P7>
120 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5, P6 &p6,
121 P7 &p7) const
123 typename std::map<void*, InnerCallback>::const_iterator it;
125 for (it = list.begin(); it != list.end(); ++it)
126 it->second(p1, p2, p3, p4, p5, p6, p7);
128 template<typename P1,
129 typename P2,
130 typename P3,
131 typename P4,
132 typename P5,
133 typename P6,
134 typename P7,
135 typename P8>
136 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5, P6 &p6, P7 &p7,
137 P8 &p8) const
139 typename std::map<void*, InnerCallback>::const_iterator it;
141 for (it = list.begin(); it != list.end(); ++it)
142 it->second(p1, p2, p3, p4, p5, p6, p7, p8);
147 #endif /* __WVCALLBACKLIST_H */