basic wrapping of Annotations
[mussa.git] / alg / annotations.hpp
index 607d6cb46d9ad81417f350fe9c950f11a21e8c24..132b865346b2862c6d975cc25779a38ac1517a66 100644 (file)
@@ -22,7 +22,11 @@ protected:
   static const std::string name_str;
 
 public:
-  typedef std::map<std::string, std::string> metadata_map;
+  typedef std::string key_type;
+  typedef std::string mapped_type;
+  typedef std::map<key_type, mapped_type> 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<std::string> keys() const;
+  //! return number of items in the map
   size_type size() const { return metadata.size(); }
   //@}
 protected: