#include "DataFactory.h" #include "Data.h" #include "NullData.h" #include "DateTimeData.h" #include "IntegerData.h" #include "StringData.h" #include "StructData.h" #include "data/TorqueModeStructData.h" #include "data/BoltModeStructData.h" #include "data/GearModeStructData.h" #include "data/AngleModeStructData.h" #include "data/SensorModeStructData.h" #include "data/FallbackStructData.h" DataFactory *DataFactory::m_pInstance = nullptr; std::mutex DataFactory::m_mutex; Data *DataFactory::createData(int type) { Data *data = nullptr; if(m_pInstance) { switch (type) { case DATA_TYPE_NULL : data = new NullData() ; break; case DATA_TYPE_DATETIME : data = new DateTimeData(); break; case DATA_TYPE_INTEGER : data = new IntegerData() ; break; case DATA_TYPE_STRING : data = new StringData() ; break; case DATA_TYPE_STRUCT : data = new StructData() ; break; case DATA_TYPE_STRUCT_OF_TORQUE : data = new TorqueModeStructData(); break; case DATA_TYPE_STRUCT_OF_BOLT : data = new BoltModeStructData() ; break; case DATA_TYPE_STRUCT_OF_ANGLE : data = new AngleModeStructData() ; break; case DATA_TYPE_STRUCT_OF_GEAR : data = new GearModeStructData() ; break; case DATA_TYPE_STRUCT_OF_SENSOR : data = new SensorModeStructData(); break; case DATA_TYPE_STRUCT_OF_FALLBACK: data = new FallbackStructData() ; break; default: break; } } return data; }