Incorporated glbarcode library into source tree.

This commit is contained in:
Jim Evins
2017-04-09 19:14:13 -04:00
parent 76bd5a0c6b
commit b17cea7ace
47 changed files with 6290 additions and 0 deletions
+130
View File
@@ -0,0 +1,130 @@
/* Factory.h
*
* Copyright (C) 2013-2014 Jim Evins <evins@snaught.com>
*
* This file is part of glbarcode++.
*
* glbarcode++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* glbarcode++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with glbarcode++. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glbarcode_Factory_h
#define glbarcode_Factory_h
#include "Barcode.h"
#include <string>
#include <map>
#include "TypeIdList.h"
/**
* Barcode factory base for CAPI
*/
extern "C" struct gbcFactory {};
namespace glbarcode
{
/**
* @class Factory Factory.h glbarcode/Factory.h
*
* Singleton Barcode factory class.
*/
class Factory : public gbcFactory
{
public:
/**
* Barcode creation function signature.
*/
typedef Barcode* (*BarcodeCreateFct)( void );
private:
/**
* Barcode factory constructor
*/
Factory();
public:
/**
* Initialize barcode factory.
*
* Initializes the barcode factory and registers all built-in Barcode types. It
* is optional for an application to call init(), because glbarcode++ will automatically
* initialize the factory on demand.
*/
static void init( void );
/**
* Create barcode based on type ID string.
*
* @param[in] typeId Barcode type ID string
*/
static Barcode* createBarcode( const std::string& typeId );
/**
* Register barcode type ID.
*
* @param[in] typeId Barcode type ID string
* @param[in] fct Function to create barcode object of concrete Barcode class
*/
static void registerType( const std::string& typeId, BarcodeCreateFct fct );
/**
* Is barcode type supported?
*
* @param[in] typeId Barcode type ID string
*/
static bool isTypeSupported( const std::string& typeId );
/**
* Get list of supported types.
*/
static TypeIdList getSupportedTypes( void );
private:
/**
* Internal register barcode type ID.
*
* @param[in] typeId Barcode type ID string
* @param[in] fct Function to create barcode object of concrete Barcode class
*/
static void internalRegisterType( const std::string& typeId, BarcodeCreateFct fct );
/**
* Map barcode type strings to creation functions.
*/
typedef std::map<std::string,BarcodeCreateFct> BarcodeTypeMap;
static BarcodeTypeMap mBarcodeTypeMap;
/**
* Supported barcode types.
*/
static TypeIdList mSupportedTypes;
};
}
#endif // glbarcode_Factory_h