00001 #ifndef Impala_Persistency_FeatureLocator_h
00002 #define Impala_Persistency_FeatureLocator_h
00003
00004 #include "Persistency/Locator.h"
00005 #include "Core/Feature/FeatureDefinition.h"
00006
00007 namespace Impala
00008 {
00009 namespace Persistency
00010 {
00011
00012
00024 class FeatureLocator : public Locator
00025 {
00026 public:
00027 typedef Core::Feature::FeatureDefinition FeatureDefinition;
00028
00029 FeatureLocator()
00030 {
00031 }
00032
00033 FeatureLocator(CString protocolAndHost, CString dataSet,
00034 bool isCodebook, bool isIndex, CString walkType,
00035 String featureString, CString container)
00036 : Locator(protocolAndHost, dataSet)
00037 {
00038 mIsCodebook = isCodebook;
00039 mIsIndex = isIndex;
00040 mWalkType = walkType;
00041 mFeatureString = featureString;
00042 mContainer = container;
00043 Init();
00044 }
00045
00046 FeatureLocator(CString dataSet, bool isCodebook, bool isIndex,
00047 CString walkType, String featureString, CString container,
00048 CmdOptions& options)
00049 : Locator(dataSet, options)
00050 {
00051 mIsCodebook = isCodebook;
00052 mIsIndex = isIndex;
00053 mWalkType = walkType;
00054 mFeatureString = featureString;
00055 mContainer = container;
00056 Init();
00057 }
00058
00059 FeatureLocator(const Locator& base, bool isCodebook, bool isIndex,
00060 CString walkType, String featureString, CString container)
00061 : Locator(base.GetProtocol(), base.GetHost(), base.GetDataSet())
00062 {
00063 mIsCodebook = isCodebook;
00064 mIsIndex = isIndex;
00065 mWalkType = walkType;
00066 mFeatureString = featureString;
00067 mContainer = container;
00068 Init();
00069 }
00070
00071 virtual
00072 ~FeatureLocator()
00073 {
00074 }
00075
00076 bool
00077 GetIsCodebook() const
00078 {
00079 return mIsCodebook;
00080 }
00081
00082 bool
00083 GetIsIndex() const
00084 {
00085 return mIsIndex;
00086 }
00087
00088 String
00089 GetTopString() const
00090 {
00091 if (mIsCodebook)
00092 return "Codebooks";
00093 if (mIsIndex)
00094 return "FeatureIndex";
00095 return "FeatureData";
00096 }
00097
00098 String
00099 GetWalkType() const
00100 {
00101 return mWalkType;
00102 }
00103
00104 void
00105 SetWalkType(CString walkType)
00106 {
00107 mWalkType = walkType;
00108 }
00109
00110 String
00111 GetFeatureString() const
00112 {
00113 return mFeatureString;
00114 }
00115
00116 void
00117 SetFeatureString(CString featureString)
00118 {
00119 mFeatureDef = featureString;
00120 mFeatureString = featureString;
00121 }
00122
00123 FeatureDefinition
00124 GetFeatureDef() const
00125 {
00126 return mFeatureDef;
00127 }
00128
00129 void
00130 SetFeatureDef(FeatureDefinition def)
00131 {
00132 mFeatureDef = def;
00133 mFeatureString = def.AsString();
00134 }
00135
00136 String
00137 GetFeatureName() const
00138 {
00139 return mFeatureDef.GetName();
00140 }
00141
00142 String
00143 GetContainer() const
00144 {
00145 return mContainer;
00146 }
00147
00148 void
00149 SetContainer(CString container)
00150 {
00151 mContainer = container;
00152 }
00153
00154 bool
00155 GetIsPartial() const
00156 {
00157 return mNumberFrames != 0;
00158 }
00159
00160 int
00161 GetNumberFrames() const
00162 {
00163 return mNumberFrames;
00164 }
00165
00166 void
00167 SetNumberFrames(int number)
00168 {
00169 mNumberFrames = number;
00170 }
00171
00172 int
00173 GetStartFrame() const
00174 {
00175 return mStartFrame;
00176 }
00177
00178 void
00179 SetStartFrame(int number)
00180 {
00181 mStartFrame = number;
00182 }
00183
00184 bool
00185 GetUseBroadcast() const
00186 {
00187 return mUseBroadcast;
00188 }
00189
00190 void
00191 SetUseBroadcast(bool flag)
00192 {
00193 mUseBroadcast = flag;
00194 }
00195
00196 String
00197 GetSuffix() const
00198 {
00199 return mSuffix;
00200 }
00201
00202 void
00203 SetSuffix(CString suffix)
00204 {
00205 mSuffix = suffix;
00206 }
00207
00208 void
00209 ExtendSuffix(CString suffix)
00210 {
00211 mSuffix = mSuffix + suffix;
00212 }
00213
00214 String
00215 ToString() const
00216 {
00217 return "FeatureLocator(" + GetProtocol() + "," + GetHost()
00218 + "," + GetDataSet() + "," + GetTopString() + ","
00219 + GetWalkType() + "," + GetFeatureString() + GetSuffix() + ","
00220 + GetContainer() + "," + MakeString(GetNumberFrames()) + ")";
00221 }
00222
00223 private:
00224
00225 void
00226 Init()
00227 {
00228 mFeatureDef = mFeatureString;
00229 mSuffix = ".tab";
00230 mNumberFrames = 0;
00231 mUseBroadcast = false;
00232 }
00233
00234 bool mIsCodebook;
00235 bool mIsIndex;
00236 String mWalkType;
00237 String mFeatureString;
00238 String mContainer;
00239
00240 FeatureDefinition mFeatureDef;
00241 String mSuffix;
00242 int mNumberFrames;
00243 int mStartFrame;
00244 bool mUseBroadcast;
00245
00246 ILOG_VAR_DEC;
00247 };
00248
00249 ILOG_VAR_INIT(FeatureLocator, Impala.Persistency);
00250
00251 std::ostream&
00252 operator<< (std::ostream& os, const FeatureLocator& loc)
00253 {
00254 os << loc.ToString();
00255 return os;
00256 }
00257
00258 }
00259 }
00260
00261 #endif