MCommandParameter.h
00001 #ifndef ASCOMMANDPARAMETER_H 00002 #define ASCOMMANDPARAMETER_H 00003 00004 #include "MUID.h" 00005 #include "MTypes.h" 00006 00008 enum MCommandParameterType{ 00009 MPT_INT = 0, 00010 MPT_UINT = 1, 00011 MPT_FLOAT = 2, 00012 MPT_BOOL = 3, 00013 MPT_STR = 4, 00014 MPT_VECTOR = 5, 00015 MPT_POS = 6, 00016 MPT_DIR = 7, 00017 MPT_COLOR = 8, 00018 MPT_UID = 9, 00019 MPT_BLOB = 10, 00020 00021 MPT_CHAR = 11, 00022 MPT_UCHAR = 12, 00023 MPT_SHORT = 13, 00024 MPT_USHORT = 14, 00025 MPT_INT64 = 15, 00026 MPT_UINT64 = 16, 00027 // 숫자는 고정된 값이다. (확장은 가능하되, 수정은 불가) 00028 00029 MPT_END = 17, 00030 }; 00031 00033 class MCommandParameterDesc{ 00034 protected: 00035 MCommandParameterType m_nType; 00036 char m_szDescription[64]; 00037 public: 00038 MCommandParameterDesc(MCommandParameterType nType, char* szDescription); 00039 virtual ~MCommandParameterDesc(void); 00040 00041 MCommandParameterType GetType(void){ return m_nType; } 00042 const char* GetDescription(void){ return m_szDescription; } 00043 }; 00044 00045 00047 class MCommandParameter{ 00048 protected: 00049 MCommandParameterType m_nType; 00050 public: 00051 MCommandParameter(MCommandParameterType nType){ m_nType = nType; } 00052 virtual ~MCommandParameter(void){} 00053 00054 MCommandParameterType GetType(void){ return m_nType; } 00055 00057 virtual MCommandParameter* Clone(void) = 0; 00059 virtual void GetValue(void* p) = 0; 00061 virtual int GetData(char* pData, int nSize) = 0; 00063 virtual int SetData(char* pData) = 0; 00065 virtual void *GetPointer(void) =0; 00066 00068 virtual const char* GetClassName(void) = 0; 00070 virtual void GetString(char* szValue) = 0; 00071 }; 00072 00074 class MCommandParameterInt : public MCommandParameter{ 00075 public: 00076 int m_Value; 00077 public: 00078 MCommandParameterInt(void); 00079 MCommandParameterInt(int Value); 00080 00081 virtual MCommandParameter* Clone(void); 00082 virtual void GetValue(void* p); 00083 virtual int GetData(char* pData, int nSize); 00084 virtual int SetData(char* pData); 00085 virtual void *GetPointer() { return &m_Value; } 00086 virtual const char* GetClassName(void){ return "Int"; } 00087 virtual void GetString(char* szValue){ sprintf(szValue, "%d", m_Value); } 00088 }; 00089 00091 class MCommandParameterUInt : public MCommandParameter{ 00092 public: 00093 unsigned int m_Value; 00094 public: 00095 MCommandParameterUInt(void); 00096 MCommandParameterUInt(unsigned int Value); 00097 00098 virtual MCommandParameter* Clone(void); 00099 virtual void GetValue(void* p); 00100 virtual int GetData(char* pData, int nSize); 00101 virtual int SetData(char* pData); 00102 virtual void *GetPointer() { return &m_Value; } 00103 virtual const char* GetClassName(void){ return "UInt"; } 00104 virtual void GetString(char* szValue){ sprintf(szValue, "%u", m_Value); } 00105 }; 00106 00108 class MCommandParameterFloat : public MCommandParameter{ 00109 public: 00110 float m_Value; 00111 public: 00112 MCommandParameterFloat(void); 00113 MCommandParameterFloat(float Value); 00114 00115 virtual MCommandParameter* Clone(void); 00116 virtual void GetValue(void* p); 00117 virtual int GetData(char* pData, int nSize); 00118 virtual int SetData(char* pData); 00119 virtual void *GetPointer() { return &m_Value; } 00120 virtual const char* GetClassName(void){ return "Float"; } 00121 virtual void GetString(char* szValue){ sprintf(szValue, "%f", m_Value); } 00122 }; 00123 00125 class MCommandParameterString : public MCommandParameter{ 00126 public: 00127 char* m_Value; 00128 public: 00129 MCommandParameterString(void); 00130 MCommandParameterString(const char* Value); 00131 virtual ~MCommandParameterString(void); 00132 00133 virtual MCommandParameter* Clone(void); 00134 virtual void GetValue(void* p); 00135 virtual int GetData(char* pData, int nSize); 00136 virtual int SetData(char* pData); 00137 virtual void *GetPointer() { return &m_Value; } 00138 virtual const char* GetClassName(void){ return "String"; } 00139 virtual void GetString(char* szValue){ strcpy(szValue, m_Value); } 00140 }; 00141 00143 class MCommandParameterVector : public MCommandParameter{ 00144 public: 00145 float m_fX; 00146 float m_fY; 00147 float m_fZ; 00148 public: 00149 MCommandParameterVector(void); 00150 MCommandParameterVector(float x ,float y, float z); 00151 virtual ~MCommandParameterVector(void); 00152 00153 virtual MCommandParameter* Clone(void); 00154 virtual void GetValue(void* p); 00155 virtual int GetData(char* pData, int nSize); 00156 virtual int SetData(char* pData); 00157 virtual void *GetPointer() { return &m_fX; } 00158 virtual const char* GetClassName(void){ return "Vector"; } 00159 virtual void GetString(char* szValue){ sprintf(szValue, "%.2f,%.2f,%.2f", m_fX, m_fY, m_fZ); } 00160 }; 00161 00163 class MCommandParameterPos : public MCommandParameterVector{ 00164 public: 00165 MCommandParameterPos(void) : MCommandParameterVector() { m_nType=MPT_POS; } 00166 MCommandParameterPos(float x, float y, float z) : MCommandParameterVector(x, y, z){ m_nType=MPT_POS; } 00167 00168 virtual MCommandParameter* Clone(void){ return new MCommandParameterPos(m_fX, m_fY, m_fZ); } 00169 virtual const char* GetClassName(void){ return "Pos"; } 00170 }; 00171 00173 class MCommandParameterDir : public MCommandParameterVector{ 00174 public: 00175 MCommandParameterDir(void) : MCommandParameterVector() { m_nType=MPT_DIR; } 00176 MCommandParameterDir(float x, float y, float z) : MCommandParameterVector(x, y, z){ m_nType=MPT_DIR; } 00177 00178 virtual MCommandParameter* Clone(void){ return new MCommandParameterDir(m_fX, m_fY, m_fZ); } 00179 virtual const char* GetClassName(void){ return "Dir"; } 00180 }; 00181 00183 class MCommandParameterColor : public MCommandParameterVector{ 00184 public: 00185 MCommandParameterColor(void) : MCommandParameterVector() { m_nType=MPT_COLOR; } 00186 MCommandParameterColor(float r, float g, float b) : MCommandParameterVector(r, g, b){ m_nType=MPT_COLOR; } 00187 00188 virtual MCommandParameter* Clone(void){ return new MCommandParameterColor(m_fX, m_fY, m_fZ); } 00189 virtual const char* GetClassName(void){ return "Color"; } 00190 }; 00191 00193 class MCommandParameterBool : public MCommandParameter{ 00194 bool m_Value; 00195 public: 00196 MCommandParameterBool(void) : MCommandParameter(MPT_BOOL) { } 00197 MCommandParameterBool(bool bValue) : MCommandParameter(MPT_BOOL) { 00198 m_Value = bValue; 00199 } 00200 00201 virtual MCommandParameter* Clone(void); 00202 virtual void GetValue(void* p); 00203 virtual int GetData(char* pData, int nSize); 00204 virtual int SetData(char* pData); 00205 virtual void *GetPointer(void); 00206 virtual const char* GetClassName(void){ return "Bool"; } 00207 virtual void GetString(char* szValue){ if(m_Value==true) strcpy(szValue, "true"); else strcpy(szValue, "false"); } 00208 }; 00209 00211 class MCommandParameterUID : public MCommandParameter{ 00212 public: 00213 MUID m_Value; 00214 public: 00215 MCommandParameterUID(void); 00216 MCommandParameterUID(const MUID& uid); 00217 virtual ~MCommandParameterUID(void); 00218 00219 virtual MCommandParameterUID* Clone(void); 00220 virtual void GetValue(void* p); 00221 virtual int GetData(char* pData, int nSize); 00222 virtual int SetData(char* pData); 00223 virtual void *GetPointer() { return &m_Value; } 00224 virtual const char* GetClassName(void){ return "UID"; } 00225 virtual void GetString(char* szValue){ sprintf(szValue, "%u:%u", m_Value.High, m_Value.Low); } 00226 }; 00227 00228 class MCommandParameterBlob : public MCommandParameter{ 00229 public: 00230 void* m_Value; 00231 int m_nSize; 00232 public: 00233 MCommandParameterBlob(void); 00234 MCommandParameterBlob(const void* Value, int nSize); 00235 virtual ~MCommandParameterBlob(void); 00236 00237 virtual MCommandParameterBlob* Clone(void); 00238 virtual void GetValue(void* p); 00239 virtual int GetData(char* pData, int nSize); 00240 virtual int SetData(char* pData); 00241 virtual void *GetPointer() { return m_Value; } 00242 virtual const char* GetClassName(void){ return "Blob"; } 00243 virtual void GetString(char* szValue){ sprintf(szValue, "%02X%02X..", *((unsigned char*)(m_Value)), *((unsigned char*)(m_Value)+1)); } 00244 }; 00245 00246 00248 class MCommandParameterChar : public MCommandParameter 00249 { 00250 public: 00251 char m_Value; 00252 public: 00253 MCommandParameterChar(void); 00254 MCommandParameterChar(char Value); 00255 00256 virtual MCommandParameter* Clone(void); 00257 virtual void GetValue(void* p); 00258 virtual int GetData(char* pData, int nSize); 00259 virtual int SetData(char* pData); 00260 virtual void *GetPointer() { return &m_Value; } 00261 virtual const char* GetClassName(void){ return "Char"; } 00262 virtual void GetString(char* szValue){ sprintf(szValue, "%d", m_Value); } 00263 }; 00264 00265 00267 class MCommandParameterUChar : public MCommandParameter 00268 { 00269 public: 00270 unsigned char m_Value; 00271 public: 00272 MCommandParameterUChar(void); 00273 MCommandParameterUChar(unsigned char Value); 00274 00275 virtual MCommandParameter* Clone(void); 00276 virtual void GetValue(void* p); 00277 virtual int GetData(char* pData, int nSize); 00278 virtual int SetData(char* pData); 00279 virtual void *GetPointer() { return &m_Value; } 00280 virtual const char* GetClassName(void){ return "UChar"; } 00281 virtual void GetString(char* szValue){ sprintf(szValue, "%u", m_Value); } 00282 }; 00283 00284 00286 class MCommandParameterShort : public MCommandParameter 00287 { 00288 public: 00289 short m_Value; 00290 public: 00291 MCommandParameterShort(void); 00292 MCommandParameterShort(short Value); 00293 00294 virtual MCommandParameter* Clone(void); 00295 virtual void GetValue(void* p); 00296 virtual int GetData(char* pData, int nSize); 00297 virtual int SetData(char* pData); 00298 virtual void *GetPointer() { return &m_Value; } 00299 virtual const char* GetClassName(void){ return "Short"; } 00300 virtual void GetString(char* szValue){ sprintf(szValue, "%d", m_Value); } 00301 }; 00302 00304 class MCommandParameterUShort : public MCommandParameter 00305 { 00306 public: 00307 short m_Value; 00308 public: 00309 MCommandParameterUShort(void); 00310 MCommandParameterUShort(unsigned short Value); 00311 00312 virtual MCommandParameter* Clone(void); 00313 virtual void GetValue(void* p); 00314 virtual int GetData(char* pData, int nSize); 00315 virtual int SetData(char* pData); 00316 virtual void *GetPointer() { return &m_Value; } 00317 virtual const char* GetClassName(void){ return "UShort"; } 00318 virtual void GetString(char* szValue){ sprintf(szValue, "%u", m_Value); } 00319 }; 00320 00321 00323 class MCommandParameterInt64 : public MCommandParameter 00324 { 00325 public: 00326 int64 m_Value; 00327 public: 00328 MCommandParameterInt64(void); 00329 MCommandParameterInt64(int64 Value); 00330 00331 virtual MCommandParameter* Clone(void); 00332 virtual void GetValue(void* p); 00333 virtual int GetData(char* pData, int nSize); 00334 virtual int SetData(char* pData); 00335 virtual void *GetPointer() { return &m_Value; } 00336 virtual const char* GetClassName(void){ return "Int64"; } 00337 virtual void GetString(char* szValue){ sprintf(szValue, "%lld", m_Value); } 00338 }; 00339 00341 class MCommandParameterUInt64 : public MCommandParameter 00342 { 00343 public: 00344 uint64 m_Value; 00345 public: 00346 MCommandParameterUInt64(void); 00347 MCommandParameterUInt64(uint64 Value); 00348 00349 virtual MCommandParameter* Clone(void); 00350 virtual void GetValue(void* p); 00351 virtual int GetData(char* pData, int nSize); 00352 virtual int SetData(char* pData); 00353 virtual void *GetPointer() { return &m_Value; } 00354 virtual const char* GetClassName(void){ return "UInt64"; } 00355 virtual void GetString(char* szValue){ sprintf(szValue, "%llu", m_Value); } 00356 }; 00357 00358 00359 00360 // Short Name 00361 typedef MCommandParameterBlob MCmdParamBlob; 00362 typedef MCommandParameterUID MCmdParamUID; 00363 typedef MCommandParameter MCmdParam; 00364 typedef MCommandParameterDesc MCmdParamDesc; 00365 typedef MCommandParameterInt MCmdParamInt; 00366 typedef MCommandParameterUInt MCmdParamUInt; 00367 typedef MCommandParameterFloat MCmdParamFloat; 00368 typedef MCommandParameterString MCmdParamStr; 00369 typedef MCommandParameterVector MCmdParamVector; 00370 typedef MCommandParameterPos MCmdParamPos; 00371 typedef MCommandParameterDir MCmdParamDir; 00372 typedef MCommandParameterColor MCmdParamColor; 00373 typedef MCommandParameterBool MCmdParamBool; 00374 typedef MCommandParameterChar MCmdParamChar; 00375 typedef MCommandParameterUChar MCmdParamUChar; 00376 typedef MCommandParameterShort MCmdParamShort; 00377 typedef MCommandParameterUShort MCmdParamUShort; 00378 typedef MCommandParameterInt64 MCmdParamInt64; 00379 typedef MCommandParameterUInt64 MCmdParamUInt64; 00380 00381 00382 00383 00384 #endif
MAIET entertainment