181 lines
5.2 KiB
C++
181 lines
5.2 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include "../DataManage/RWData.h"
|
|
|
|
class BaseData {
|
|
public:
|
|
BaseData(const std::string& code,const std::string& context):m_code(code),m_context(context){}
|
|
virtual ~BaseData() {}
|
|
|
|
virtual void SetValue(float f) {}
|
|
virtual void SetValue(int i) {}
|
|
virtual void SetValue(unsigned short us) {}
|
|
virtual void SetValue(short s) {}
|
|
virtual void SetValue(bool b) {}
|
|
virtual void SetValue(const string& str) {}
|
|
|
|
//virtual void GetValue(DATATYPE& dataType, float& f) {}
|
|
//virtual void GetValue(DATATYPE& dataType, int& i) {}
|
|
//virtual void GetValue(DATATYPE& dataType, unsigned short& us) {}
|
|
//virtual void GetValue(DATATYPE& dataType, short& s) {}
|
|
//virtual void GetValue(DATATYPE& dataType, bool& b) {}
|
|
|
|
std::string GetCode() { return m_code; }
|
|
virtual std::string GetValueStr() { return ""; }
|
|
virtual DATATYPE GetDataType() { return UNKNOW; }
|
|
private:
|
|
std::string m_code; //key编码
|
|
std::string m_context; //中文内容
|
|
|
|
};
|
|
|
|
class FloatData : public BaseData {
|
|
public:
|
|
FloatData(const std::string& code, const std::string& context/*, float val*/)
|
|
: BaseData(code, context), m_value(0.0f) {
|
|
//if (m_baseMp.find(code) != m_baseMp.end()) {
|
|
// printf("%s is repeated...", code.c_str());
|
|
//}
|
|
//else {
|
|
// m_baseMp.insert(make_pair(code, this));
|
|
//}
|
|
}
|
|
~FloatData() {}
|
|
|
|
void SetValue(float f) { m_value = f; }
|
|
//void GetValue(DATATYPE& dataType, float& f) { dataType = iFLOAT; f = m_value; }
|
|
DATATYPE GetDataType() { return iFLOAT; }
|
|
float GetValue() { return m_value; }
|
|
virtual std::string GetValueStr() { return to_string(m_value); }
|
|
private:
|
|
float m_value;
|
|
};
|
|
|
|
|
|
class IntData : public BaseData {
|
|
public:
|
|
IntData(const std::string& code, const std::string& context/*, int val*/)
|
|
: BaseData(code, context), m_value(0) {
|
|
//if (m_baseMp.find(code) != m_baseMp.end()) {
|
|
// printf("%s is repeated...", code.c_str());
|
|
//}
|
|
//else {
|
|
// m_baseMp.insert(make_pair(code, this));
|
|
//}
|
|
}
|
|
~IntData() {}
|
|
|
|
void SetValue(int i) { m_value = i; }
|
|
//void GetValue(DATATYPE& dataType,int& i) { dataType = iINT; i = m_value; }
|
|
DATATYPE GetDataTypeI() { return iINT; }
|
|
int GetValue() { return m_value; }
|
|
virtual std::string GetValueStr() { return to_string(m_value); }
|
|
private:
|
|
int m_value;
|
|
};
|
|
|
|
|
|
class ShortData : public BaseData {
|
|
public:
|
|
ShortData(const std::string& code, const std::string& context/*, short val*/)
|
|
: BaseData(code, context), m_value(0) {
|
|
//if (m_baseMp.find(code) != m_baseMp.end()) {
|
|
// printf("%s is repeated...", code.c_str());
|
|
//}
|
|
//else {
|
|
// m_baseMp.insert(make_pair(code, this));
|
|
//}
|
|
}
|
|
~ShortData() {}
|
|
|
|
void SetValue(short s) { m_value = s; }
|
|
//void GetValue(DATATYPE& dataType, short& s) { dataType = iSHORT; s = m_value; }
|
|
DATATYPE GetDataType() { return iSHORT; }
|
|
short GetValue() { return m_value; }
|
|
virtual std::string GetValueStr() { return to_string(m_value); }
|
|
private:
|
|
short m_value;
|
|
};
|
|
|
|
class UShortData : public BaseData {
|
|
public:
|
|
UShortData(const std::string& code, const std::string& context/*, unsigned short val*/)
|
|
: BaseData(code, context), m_value(0) {
|
|
//if (m_baseMp.find(code) != m_baseMp.end()) {
|
|
// printf("%s is repeated...", code.c_str());
|
|
//}
|
|
//else {
|
|
// m_baseMp.insert(make_pair(code, this));
|
|
//}
|
|
}
|
|
~UShortData() {}
|
|
|
|
void SetValue(unsigned short us) { m_value = us; }
|
|
//void GetValue(DATATYPE& dataType, unsigned short& us) { dataType = iUSHORT; us = m_value; }
|
|
DATATYPE GetDataType() { return iUSHORT; }
|
|
unsigned short GetValue() { return m_value; }
|
|
virtual std::string GetValueStr() { return to_string(m_value); }
|
|
private:
|
|
unsigned short m_value;
|
|
};
|
|
|
|
|
|
class BoolData : public BaseData {
|
|
public:
|
|
BoolData(const std::string& code, const std::string& context/*, bool val*/)
|
|
: BaseData(code, context), m_value(0) {
|
|
//if (m_baseMp.find(code) != m_baseMp.end()) {
|
|
// printf("%s is repeated...", code.c_str());
|
|
//}
|
|
//else {
|
|
// m_baseMp.insert(make_pair(code, this));
|
|
//}
|
|
}
|
|
~BoolData() {}
|
|
|
|
void SetValue(bool b) { m_value = b; }
|
|
//string GetValueStr() { return to_string(m_value); }
|
|
DATATYPE GetDataType() { return iBOOL; }
|
|
bool GetValue() { return m_value; }
|
|
virtual std::string GetValueStr() { return to_string(m_value); }
|
|
private:
|
|
bool m_value;
|
|
};
|
|
|
|
|
|
class UcharData : public BaseData {
|
|
public:
|
|
UcharData(const std::string& code, const std::string& context/*, bool val*/)
|
|
: BaseData(code, context), m_value(0) {
|
|
//if (m_baseMp.find(code) != m_baseMp.end()) {
|
|
// printf("%s is repeated...", code.c_str());
|
|
//}
|
|
//else {
|
|
// m_baseMp.insert(make_pair(code, this));
|
|
//}
|
|
}
|
|
~UcharData() {}
|
|
|
|
void SetValue(UCHAR uc) { m_value = uc; }
|
|
//void GetValue(DATATYPE& dataType, UCHAR& uc) { dataType = iUCHAR; uc = m_value; }
|
|
DATATYPE GetDataType() { return iUCHAR; }
|
|
UCHAR GetValue() { return m_value; }
|
|
virtual std::string GetValueStr() { return to_string(m_value); }
|
|
private:
|
|
UCHAR m_value;
|
|
};
|
|
|
|
class StrData : public BaseData {
|
|
public:
|
|
StrData(const std::string& code, const std::string& context)
|
|
: BaseData(code, context), m_value("") {
|
|
}
|
|
~StrData() {}
|
|
|
|
void SetValue(const std::string& str) { m_value = str; }
|
|
DATATYPE GetDataType() { return iSTRING; }
|
|
//std::string GetValue() { return m_value; }
|
|
virtual std::string GetValueStr() { return m_value; }
|
|
private:
|
|
string m_value;
|
|
}; |