WvStreams
debian/libwvstreams-dev/usr/include/wvstreams/wvcallbacklist.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 */
6#ifndef __WVCALLBACKLIST_H
7#define __WVCALLBACKLIST_H
8
9#include <assert.h>
10#include <map>
11
12
13template<class InnerCallback>
15{
16private:
17 std::map<void*, InnerCallback> list;
18
19 /* The idea of copying this gives me a headache. */
21 WvCallbackList& operator=(const WvCallbackList&);
22
23public:
25 {
26 }
27 void add(const InnerCallback &cb, void *cookie)
28 {
29 assert(list.find(cookie) == list.end());
30 list.insert(std::make_pair(cookie, cb));
31 }
32 void del(void *cookie)
33 {
34 typename std::map<void*, InnerCallback>::iterator it =
35 list.find(cookie);
36 assert(it != list.end());
37 list.erase(it);
38 }
39 bool isempty() const
40 {
41 return list.empty();
42 }
43 void operator()() const
44 {
45 typename std::map<void*, InnerCallback>::const_iterator it;
46
47 for (it = list.begin(); it != list.end(); ++it)
48 it->second();
49 }
50 template<typename P1>
51 void operator()(P1 &p1) const
52 {
53 typename std::map<void*, InnerCallback>::const_iterator it;
54
55 for (it = list.begin(); it != list.end(); ++it)
56 it->second(p1);
57 }
58 template<typename P1,
59 typename P2>
60 void operator()(P1 &p1, P2 &p2) const
61 {
62 typename std::map<void*, InnerCallback>::const_iterator it;
63
64 for (it = list.begin(); it != list.end(); ++it)
65 it->second(p1, p2);
66 }
67 template<typename P1,
68 typename P2,
69 typename P3>
70 void operator()(P1 &p1, P2 &p2, P3 &p3) const
71 {
72 typename std::map<void*, InnerCallback>::const_iterator it;
73
74 for (it = list.begin(); it != list.end(); ++it)
75 it->second(p1, p2, p3);
76 }
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
82 {
83 typename std::map<void*, InnerCallback>::const_iterator it;
84
85 for (it = list.begin(); it != list.end(); ++it)
86 it->second(p1, p2, p3, p4);
87 }
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
94 {
95 typename std::map<void*, InnerCallback>::const_iterator it;
96
97 for (it = list.begin(); it != list.end(); ++it)
98 it->second(p1, p2, p3, p4, p5);
99 }
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
107 {
108 typename std::map<void*, InnerCallback>::const_iterator it;
109
110 for (it = list.begin(); it != list.end(); ++it)
111 it->second(p1, p2, p3, p4, p5, p6);
112 }
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
122 {
123 typename std::map<void*, InnerCallback>::const_iterator it;
124
125 for (it = list.begin(); it != list.end(); ++it)
126 it->second(p1, p2, p3, p4, p5, p6, p7);
127 }
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
138 {
139 typename std::map<void*, InnerCallback>::const_iterator it;
140
141 for (it = list.begin(); it != list.end(); ++it)
142 it->second(p1, p2, p3, p4, p5, p6, p7, p8);
143 }
144};
145
146
147#endif /* __WVCALLBACKLIST_H */