1 #ifndef ANNOTATIONS_HPP_
2 #define ANNOTATIONS_HPP_
7 #include <boost/shared_ptr.hpp>
9 #include "mussa_exceptions.hpp"
12 typedef boost::shared_ptr<Annotations> AnnotationsRef;
15 * \brief Annotations provides a simple "dictionary" of name value pairs
17 * The intent is that this is to be used as a mix-in class to add
18 * a uniform way of storing annotation metadata.
22 static const std::string name_str;
25 typedef std::map<std::string, std::string> metadata_map;
26 typedef metadata_map::size_type size_type;
29 Annotations(const std::string n);
30 Annotations(const Annotations&);
31 Annotations(const AnnotationsRef);
33 //! make a shared pointer copy of our object
34 AnnotationsRef copy() const;
36 //! provide a special case for accessing a name
37 std::string name() const { return metadata.find(name_str)->second; }
38 //! special case for setting name
39 void setName(const std::string& n) { metadata[name_str] = n; }
41 //! Generic metadata handling
43 //! remove some key from our "dictionary"
44 void erase(const std::string& key);
45 //! set a metadata element
46 void set(const std::string key, const std::string value );
47 //! look for a key, \throws annotation_key_error if it doesn't find it
48 std::string get(const std::string key) const;
49 //! look for a key, if not found return default
50 std::string getdefault(const std::string key, std::string default_value) const;
52 bool has_key(const std::string key) const;
53 //! return all the keys of our metadata map
54 //std::list<std::string> keys() const;
55 size_type size() const { return metadata.size(); }
58 metadata_map metadata;
60 #endif /*ANNOTATIONS_HPP_*/