AbstractString.h

Go to the documentation of this file.
00001 
00027 #ifndef _ABSTRACTSTRING_H
00028 #define _ABSTRACTSTRING_H
00029 
00030 #include "Feature.h"
00031 
00033 typedef map<string, unsigned long> stringcode;
00034 
00043 class AbstractStringFeature: public PersistantFeature
00044 {
00045         public:
00047                 typedef enum ComparatorType { None, Levenshtein };
00048 
00049         protected:
00065                 AbstractStringFeature(ComparatorType comp, stringcode *code, long *maxlen);
00066 
00082                 AbstractStringFeature(ComparatorType comp, stringcode *code, long *maxlen, const string &name);
00083 
00084         public:
00085                 virtual ~AbstractStringFeature();
00086 
00087                 virtual double getPosition() const;
00088                 virtual double getDistance(Feature *f) const;
00089                 virtual void moveTowards(Feature *f, double factor);
00090 
00091                 virtual string serialize() const;
00092                 virtual void unserialize(string value);
00093 
00094                 virtual featureparams write() const;
00095                 virtual void read(featureparams *param);
00096 
00097                 virtual Feature* clone() const;
00098                 virtual void aggregate(aggregatelist samples);
00099 
00100                 virtual FeatureType getType() const { return nominal; }
00101                 virtual const string getName() const {  return "AbstractStringFeature"; }
00102 
00108                 const string& getVal() const { return name; }
00109 
00111                 const unsigned long getCodeVal() const { return codeval; }
00112 
00114                 const stringcode* getCode() { return code; }
00115 
00116 #if _DEBUG_FEATURES
00117 
00123                 virtual string toString() const;
00124 #endif
00125 
00126         private:
00128                 string name;
00129 
00130         protected:
00132                 long *maxlength;
00134                 stringcode *code;
00136                 char *position;
00137 
00144                 unsigned long codeval;
00145 
00155                 unsigned long getCodeForName(const string &name);
00156 
00157         private:
00159                 ComparatorType comparator;
00160 };
00161 
00167 class AbstractStringListFeature: public AbstractStringFeature
00168 {
00169         private:
00171                 stringvector names;
00172 
00173         protected:
00180                 bit_vector listval;
00181 
00196                 AbstractStringListFeature(stringcode *code, long *maxlen);
00197 
00212                 AbstractStringListFeature(stringcode *code, long *maxlen, const stringvector *names);
00213 
00225                 bit_vector getCodeForList(const stringvector *names);
00226 
00227         public:
00228                 virtual string serialize() const;
00229                 virtual void unserialize(string value);
00230 
00231                 virtual double getPosition() const;
00232                 virtual double getDistance(Feature *f) const;
00233                 virtual void moveTowards(Feature *f, double factor);
00234 
00235                 virtual Feature* clone() const;
00236 
00237                 virtual const string getName() const { return "AbstractStringListFeature"; }
00238 
00244                 const bit_vector& getListVal() const {
00245                         return listval;
00246                 }
00247 
00253                 const stringvector& getListValues() const {
00254                         return names;
00255                 }
00256 
00257 #if _DEBUG_FEATURES
00258                 virtual string toString() const;
00259 #endif
00260 };
00261 
00262 #endif // _ABSTRACTSTRING_H

Generated on Mon Jun 5 10:20:42 2006 for Intelligence.kdevelop by  doxygen 1.4.6