00001 // Annotation.h: An annotation associates symbolic information to a 00002 // region of signal 00003 // Author: Xiaoyi Ma, Steven Bird 00004 // Copyright (C) 2001 Linguistic Data Consortium, U Penn. 00005 // Web: http://www.ldc.upenn.edu/; Email: ldc@ldc.upenn.edu 00006 // For license information, see the file `LICENSE' included 00007 // with the distribution. 00008 00009 00010 #ifndef Annotation_h 00011 #define Annotation_h 00012 00013 #include <string> 00014 00015 #include "AGTypes.h" 00016 #include "Anchor.h" 00017 #include "FeatureMap.h" 00018 00019 using namespace std; 00020 00029 class Annotation { 00030 friend class AG; 00031 friend class AnnotationIndex; 00032 00033 private: 00035 const Id id; 00036 00038 String type; 00039 00041 Anchor* start; 00042 00044 Anchor* end; 00045 00047 FeatureMap featureMap; 00048 00049 protected: 00051 void setStartAnchor(Anchor* a) { start = a; } 00052 00054 void setEndAnchor(Anchor* a) { end = a; } 00055 00057 void setFeature(const FeatureName& feature, const FeatureValue& value); 00058 00059 public: 00061 Annotation(Id id, const Annotation*); 00062 00071 Annotation(Id id, Anchor* start, Anchor* end, String type); 00072 00074 Id getId() const { return id; } 00075 00077 Anchor* getStartAnchor() const { return start; } 00078 00080 Anchor* getEndAnchor() const { return end; } 00081 00091 String getAnnotationInfo(); 00092 00093 00095 String getType() const { return type; } 00096 00098 const FeatureMap getFeatureMap() const { return featureMap; } 00099 00101 FeatureValue getFeature(const FeatureName&) ; 00102 00104 const char* getFeatureC(const FeatureName&) ; 00105 00107 bool existsFeature(FeatureName featureName); 00108 00110 void deleteFeature(FeatureName featureName); 00111 00116 StringSet getFeatureNames(); 00117 00125 Features getFeatures(); 00126 00131 void unsetFeatures(); 00132 00134 string toString(); 00135 00136 Annotation operator = (const Annotation&); 00137 friend bool operator < (const Annotation&, const Annotation&); 00138 friend bool operator == (const Annotation&, const Annotation&); 00139 }; 00140 00141 00148 class AnnotationCompFunc { 00149 public: 00150 bool operator() (const Annotation* a1, const Annotation* a2) const { 00151 Offset a1StartOffset = a1->getStartAnchor()->getOffset(); 00152 Offset a1EndOffset = a1->getEndAnchor()->getOffset(); 00153 Offset a2StartOffset = a2->getStartAnchor()->getOffset(); 00154 Offset a2EndOffset = a2->getEndAnchor()->getOffset(); 00155 00156 if (a1StartOffset != a2StartOffset) 00157 return a1StartOffset < a2StartOffset; 00158 else if (a1EndOffset != a2EndOffset) 00159 return a1EndOffset < a2EndOffset; 00160 else 00161 return a1->getId() < a2->getId(); 00162 } 00163 }; 00164 00170 typedef set<Annotation*,AnnotationCompFunc> AnnotationSeq; 00171 typedef set<Annotation*> AnnotationSet; 00172 #endif
1.2.7 written by Dimitri van Heesch,
 © 1997-2001