diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch) | |
tree | 9047cf9e6b5c43878d5bf82660adae77ceee097a /noatun/library/noatunarts/Session_impl.cpp | |
download | tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun/library/noatunarts/Session_impl.cpp')
-rw-r--r-- | noatun/library/noatunarts/Session_impl.cpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/noatun/library/noatunarts/Session_impl.cpp b/noatun/library/noatunarts/Session_impl.cpp new file mode 100644 index 00000000..63912801 --- /dev/null +++ b/noatun/library/noatunarts/Session_impl.cpp @@ -0,0 +1,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 + |