#ifndef _RFIDFACTORY_H_ #define _RFIDFACTORY_H_ class IRfId; #ifdef BUILD_COMMDLL #define COMMDLL_DLLCLASS __declspec(dllexport) #else #define COMMDLL_DLLCLASS __declspec(dllimport) #endif class COMMDLL_DLLCLASS CAbstractRfIdFactory { private: CString m_RfIDType; public: explicit CAbstractRfIdFactory(const CString &name); virtual ~CAbstractRfIdFactory(); virtual void *Create(int index) = 0; }; /** * @class RfIdFactory * * @brief The RfIdFactory is used to create all motors. * */ class COMMDLL_DLLCLASS RfIdFactory { private: RfIdFactory(void); public: virtual ~RfIdFactory(void); static RfIdFactory &Instance(); void AddFactory(const CString &name, CAbstractRfIdFactory *pFactory); void RemoveFactory(const CString &name); IRfId *Create(int index); }; /** * @def REGISTER_RFID_FACTORY(type, rfid_class) * * @brief A macro that defines rfid factory. * * The factories are registered to the RfIdFactory which uses them to create RfID scanners. * * Example usage: * * \code{.cpp} * REGISTER_RFID_FACTORY("Omron600", RfId_Omron600) * \endcode * * @param type The rfid type. * @param rfid_class The class of the rfid that the factory creates. */ #define REGISTER_RFID_FACTORY(r_type, rfid_class) \ class Factory ## rfid_class : public CAbstractRfIdFactory \ { \ public: \ Factory ## rfid_class() : CAbstractRfIdFactory(r_type){} \ void *Create(int index) \ { return new rfid_class(index); } \ }; \ static Factory ## rfid_class StaticFactory ## rfid_class; #endif // _RFIDFACTORY_H_