registryiterator.hh
Go to the documentation of this file.00001 #ifndef TYPELIB_REGISTRYITERATOR_HH
00002 #define TYPELIB_REGISTRYITERATOR_HH
00003
00004 #include "registry.hh"
00005 #include "typemodel.hh"
00006 #include "typename.hh"
00007 #include <boost/iterator/iterator_facade.hpp>
00008
00009 namespace Typelib
00010 {
00011 class Registry;
00012
00014 class RegistryIterator
00015 : public boost::iterator_facade
00016 < RegistryIterator
00017 , Type const
00018 , boost::forward_traversal_tag >
00019 {
00020 friend class Registry;
00021
00022 public:
00023 RegistryIterator(RegistryIterator const& other)
00024 : m_iter(other.m_iter), m_registry(other.m_registry) {}
00025
00027 std::string getName() const { return m_iter->first; }
00029 std::string getBasename() const { return getTypename(m_iter->first); }
00031 std::string getNamespace() const { return Typelib::getNamespace(m_iter->first); }
00033 std::string getSource() const { return m_iter->second.source_id; }
00035 bool isAlias() const { return m_iter->first != m_iter->second.type->getName(); }
00037 Type const& aliased() const { return *m_iter->second.type; }
00040 bool isPersistent() const { return m_iter->second.persistent; }
00041
00042 Registry const& getRegistry() const { return m_registry; }
00043
00044 private:
00045 typedef Registry::TypeMap::const_iterator BaseIter;
00046 Registry const& m_registry;
00047 BaseIter m_iter;
00048
00049 explicit RegistryIterator(Registry const& registry, BaseIter init)
00050 : m_registry(registry), m_iter(init) {}
00051 friend class boost::iterator_core_access;
00052
00053 bool equal(RegistryIterator const& other) const
00054 { return other.m_iter == m_iter; }
00055 void increment()
00056 { ++m_iter; }
00057 Type const& dereference() const
00058 { return *m_iter->second.type; }
00059 };
00060 }
00061
00062 #endif
00063