implement a color mapper class
[mussa.git] / alg / annotation_colors.hpp
1 #ifndef ANNOTATION_COLOR_H
2 #define ANNOTATION_COLOR_H
3
4 #include <map>
5 #include <string>
6
7 #include "alg/color.hpp"
8 #include "alg/sequence.hpp"
9
10 struct DefaultColorMap;
11 struct DefaultColorMap
12 {
13   typedef std::map<std::string, DefaultColorMap> color_map_type;
14   typedef color_map_type::iterator iterator;
15   DefaultColorMap();
16   //! initialize color map with a default color
17   DefaultColorMap(const Color &);
18   DefaultColorMap(const color_map_type&);
19   DefaultColorMap(const DefaultColorMap&);
20
21   Color defaultColor;
22   //! color map
23   color_map_type cm;
24 };
25
26 class AnnotationColors
27 {
28 public:
29   AnnotationColors();
30   AnnotationColors(AnnotationColors &);
31
32   //! set default color
33   void setColor(Color &);
34   //! retreive default color
35   Color color();
36
37   //! add default color for a particular type
38   void appendTypeColor(const std::string &, const Color &);
39   //! get default color for a type
40   Color typeColor(const std::string &);
41   //! remove a type (and all of its instances)
42   void erase(const std::string &);
43
44   //! add default color for a particular type
45   void appendInstanceColor(const std::string &type, 
46                            const std::string &instance, 
47                            const Color &);
48   //! get color for a particular type
49   Color instanceColor(const std::string &type, 
50                       const std::string &instance);
51   //! remove an instance of particular type
52   void erase(const std::string &type, const std::string& instance);
53
54   //! lookup an annotation color
55   Color lookup(const annot &);
56   Color lookup(const std::string &, const std::string &);
57 private:
58   // nested maps, with default?
59   DefaultColorMap root_map;
60 };
61 #endif