diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-12-08 22:26:17 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-12-08 22:26:17 +0900 |
commit | fce86b22a2367f1be1f9aae5e1ba3d18d1371b74 (patch) | |
tree | 707fe84fef0569a152e632ce1e16407f9d19a3d2 /arts/modules/common/env_context_impl.cpp | |
parent | 41fa1afc2c571b909acd0312e4eebb4a0b21e3c2 (diff) | |
download | tdemultimedia-fce86b22a2367f1be1f9aae5e1ba3d18d1371b74.tar.gz tdemultimedia-fce86b22a2367f1be1f9aae5e1ba3d18d1371b74.zip |
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'arts/modules/common/env_context_impl.cpp')
-rw-r--r-- | arts/modules/common/env_context_impl.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/arts/modules/common/env_context_impl.cpp b/arts/modules/common/env_context_impl.cpp new file mode 100644 index 00000000..a9b19a50 --- /dev/null +++ b/arts/modules/common/env_context_impl.cpp @@ -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); +} +} + |