00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef AnnotationIndex_h
00013 #define AnnotationIndex_h
00014
00015 #include <map>
00016 #include <algorithm>
00017
00018 #include "AGTypes.h"
00019 #include "Identifiers.h"
00020 #include "Anchor.h"
00021 #include "Annotation.h"
00022 #include "Hash.h"
00023
00024 using namespace std;
00025
00026
00027 typedef hash_map<Id, Anchor*, hashString, StringEqual > AnchorById;
00028 typedef map<Offset, AnchorSet, less<Offset> > AnchorSetByOffset;
00029
00030
00031
00032 typedef hash_map<Id, Annotation*, hashString, StringEqual > ById;
00033 typedef hash_map<String, AnnotationSet, hashString, StringEqual > ByType;
00034 typedef map<Offset, AnnotationSet> ByOffset;
00035 typedef hash_map<pair<string,string>, AnnotationSet, hashStringPair, StringPairEqual > ByFeature;
00036 typedef hash_map<Anchor*, AnnotationSet, hashPointer, PointerEqual> ByAnchor;
00037
00045 class AnnotationIndex {
00046 friend class AG;
00047 private:
00049 AnchorSeq anchorSet;
00050
00052 AnchorById anchorById;
00054 AnchorSetByOffset anchorSetByOffset;
00055
00057 ById byId;
00059 ByType byType;
00061 ByOffset byStartAnchorOffset;
00063 ByOffset byEndAnchorOffset;
00065 ByFeature byFeature;
00066
00068 ByAnchor incoming;
00070 ByAnchor outgoing;
00071
00073 void addAnchor(Anchor*);
00075 void deleteAnchor(Anchor*);
00076
00077 public:
00079 AnnotationIndex();
00081 ~AnnotationIndex();
00082
00083
00085 void add(Annotation* a);
00087 void deleteAnnotation(Annotation* a);
00089 void addFeature(Annotation* a, const String& feature, const String& value);
00091 void deleteFeature(Annotation* a, const String& feature);
00098 AnnotationSet getByOffset(Offset offset);
00107 Annotation* getAnnotationByOffset(Offset offset);
00109 bool existsAnnotation(const Id& id);
00111 bool existsAnchor(const Id& id);
00113 Offset getNearestOffset(Offset o);
00114 };
00115
00116 #endif