blob: 6391280100fd4c23a0ff5c05757029db0b479faf (
plain)
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
|
#include "noatunarts.h"
#include <list>
#include <algorithm>
using namespace Arts;
using namespace std;
static bool compareArtsObjects(const Noatun::Listener &left, const Noatun::Listener &right)
{
return left._isEqual(right);
}
list<Noatun::Listener>::iterator find(list<Noatun::Listener> &v, const Noatun::Listener &is,
bool (*compare)(const Noatun::Listener& left, const Noatun::Listener& right))
{
for (list<Noatun::Listener>::iterator i=v.begin(); i!=v.end(); ++i)
{
if ((*compare)(is, *i))
return i;
}
return v.end();
}
static void sendMessage(Noatun::Listener l)
{
l.message();
}
namespace Noatun
{
class Session_impl : public Session_skel
{
list<Listener> listeners;
long mPid;
public:
~Session_impl()
{
for_each(listeners.begin(), listeners.end(), sendMessage);
}
long pid() { return mPid; }
void pid(long p) { mPid=p; }
void addListener(Noatun::Listener listener)
{
listeners.push_back(listener);
}
void removeListener(Noatun::Listener listener)
{
list<Listener>::iterator i=
find(listeners, listener, &compareArtsObjects);
if (i!=listeners.end())
listeners.erase(i);
}
};
class Listener_impl : public Listener_skel
{
private:
virtual void message()
{
// hmm
}
};
REGISTER_IMPLEMENTATION(Session_impl);
REGISTER_IMPLEMENTATION(Listener_impl);
} // namespace Noatun
|