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 /arts/modules/common/env_context_impl.cc | |
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 'arts/modules/common/env_context_impl.cc')
-rw-r--r-- | arts/modules/common/env_context_impl.cc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/arts/modules/common/env_context_impl.cc b/arts/modules/common/env_context_impl.cc new file mode 100644 index 00000000..a9b19a50 --- /dev/null +++ b/arts/modules/common/env_context_impl.cc @@ -0,0 +1,72 @@ +#include "artsmodulescommon.h" +#include <debug.h> + +using namespace std; + +namespace Arts { +namespace Environment { + +class Context_impl : virtual public Context_skel { +protected: + struct ContextEntry { + ContextEntry(const string& name, Object object) + : name(name), object(object) + { + } + ContextEntry(const ContextEntry& entry) + : name(entry.name), object(entry.object) + { + } + string name; + Object object; + }; + list<ContextEntry> entries; + + list<ContextEntry>::iterator findEntry(const string& name) + { + list<ContextEntry>::iterator i = entries.begin(); + for(i = entries.begin(); i != entries.end(); i++) + if(i->name == name) return i; + + return entries.end(); + } + + list<ContextEntry>::iterator findEntry(Object object) + { + list<ContextEntry>::iterator i = entries.begin(); + for(i = entries.begin(); i != entries.end(); i++) + if(object._isEqual(i->object)) return i; + + return entries.end(); + } + + +public: + void addEntry(const string& name, Object object) + { + arts_return_if_fail(findEntry(name) != entries.end()); + entries.push_back(ContextEntry(name, object)); + } + + string lookupEntry(Object object) + { + list<ContextEntry>::iterator i = findEntry(object); + + if(i == entries.end()) + return ""; + else + return i->name; + } + + void removeEntry(Object object) + { + list<ContextEntry>::iterator i = findEntry(object); + + arts_return_if_fail(i != entries.end()); + entries.erase(i); + } +}; +REGISTER_IMPLEMENTATION(Context_impl); +} +} + |