Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

AnnotationIndex.h

Go to the documentation of this file.
00001 // AnnotationIndex.h: This class maintains all the indexes over annotations.
00002 // Author: Xiaoyi Ma, Steven Bird
00003 // Copyright (C) 2001 Linguistic Data Consortium, U Penn.
00004 // Web: http://www.ldc.upenn.edu/; Email: ldc@ldc.upenn.edu
00005 // For license information, see the file `LICENSE' included
00006 // with the distribution.
00007 
00008 
00009 // The annotation data is indexed in a wide variety of ways.
00010 // This class maintains all the indexes.
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 // Indexes on Anchors
00027 typedef hash_map<Id, Anchor*, hashString, StringEqual > AnchorById;
00028 typedef map<Offset, AnchorSet, less<Offset> > AnchorSetByOffset;
00029 
00030 // Indexes on Annotations
00031 // - by convention we leave "annotation" out of the name
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

Generated at Wed Jul 3 14:54:02 2002 for Annotation Graph API by doxygen1.2.7 written by Dimitri van Heesch, © 1997-2001