You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
C++
69 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
class IRfId;
|
|
|
|
#ifdef BUILD_COMMDLL
|
|
#define COMMDLL_DLLCLASS __declspec(dllexport)
|
|
#else
|
|
#define COMMDLL_DLLCLASS __declspec(dllimport)
|
|
#endif
|
|
|
|
class COMMDLL_DLLCLASS CAbstractRfIdFactory
|
|
{
|
|
private:
|
|
std::string m_RfIDType;
|
|
public:
|
|
explicit CAbstractRfIdFactory(const std::string &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 std::string &name, CAbstractRfIdFactory *pFactory);
|
|
void RemoveFactory(const std::string &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;
|
|
|