X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=blobdiff_plain;f=alg%2Fannotations.hpp;h=132b865346b2862c6d975cc25779a38ac1517a66;hp=607d6cb46d9ad81417f350fe9c950f11a21e8c24;hb=c417e847eccd0af3bf9dfed0bc252115bbbf3d83;hpb=7a55c95eeeb792f89df39dc9375040dcbd415dfd diff --git a/alg/annotations.hpp b/alg/annotations.hpp index 607d6cb..132b865 100644 --- a/alg/annotations.hpp +++ b/alg/annotations.hpp @@ -22,7 +22,11 @@ protected: static const std::string name_str; public: - typedef std::map metadata_map; + typedef std::string key_type; + typedef std::string mapped_type; + typedef std::map metadata_map; + typedef metadata_map::iterator iterator; + typedef metadata_map::const_iterator const_iterator; typedef metadata_map::size_type size_type; Annotations(); @@ -32,6 +36,8 @@ public: //! make a shared pointer copy of our object AnnotationsRef copy() const; + + mapped_type& operator[](const key_type& k) { return metadata[k]; } //! provide a special case for accessing a name std::string name() const { return metadata.find(name_str)->second; } @@ -40,8 +46,19 @@ public: //! Generic metadata handling //@{ + //! begin iterator + iterator begin() { return metadata.begin(); } + //! const begin iterator + const_iterator begin() const { return metadata.begin(); } + //! end iterator + iterator end() { return metadata.end(); } + //! const end iterator + const_iterator end() const { return metadata.end(); } //! remove some key from our "dictionary" void erase(const std::string& key); + //! find an element in the map + iterator find( const key_type& key) { return metadata.find(key); } + const_iterator find( const key_type& key) const { return metadata.find(key); } //! set a metadata element void set(const std::string key, const std::string value ); //! look for a key, \throws annotation_key_error if it doesn't find it @@ -50,8 +67,7 @@ public: std::string getdefault(const std::string key, std::string default_value) const; //! check for a key bool has_key(const std::string key) const; - //! return all the keys of our metadata map - //std::list keys() const; + //! return number of items in the map size_type size() const { return metadata.size(); } //@} protected: