glbarcode++
 
Loading...
Searching...
No Matches
Factory.hpp
Go to the documentation of this file.
1// Factory.hpp
2//
3// Copyright (C) 2013-2026 Jaye Evins <evins@snaught.com>
4//
5// This file is part of glbarcode++.
6//
7// glbarcode++ is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// glbarcode++ is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU Lesser General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with glbarcode++. If not, see <http://www.gnu.org/licenses/>.
19//
20
21#ifndef glbarcode_Factory_hpp
22#define glbarcode_Factory_hpp
23
24
25#include "Barcode.hpp"
26
27#include "TypeIdList.hpp"
28
29#include <string>
30#include <map>
31
32
33namespace glbarcode
34{
40 class Factory
41 {
42
43 public:
47 using BarcodeCreateFct = Barcode* (*)();
48
49
50 private:
54 Factory();
55
56
57 public:
65 static void init();
66
67
73 static Barcode* createBarcode( const std::string& typeId );
74
75
82 static void registerType( const std::string& typeId, BarcodeCreateFct fct );
83
84
90 static bool isTypeSupported( const std::string& typeId );
91
92
97
98
99 private:
106 static void internalRegisterType( const std::string& typeId, BarcodeCreateFct fct );
107
108
112 using BarcodeTypeMap = std::map<std::string,BarcodeCreateFct>;
113 static BarcodeTypeMap mBarcodeTypeMap;
114
115
119 static TypeIdList mSupportedTypes;
120
121 };
122
123}
124
125
126#endif // glbarcode_Factory_hpp
Definition Barcode.hpp:52
Definition Factory.hpp:41
static void registerType(const std::string &typeId, BarcodeCreateFct fct)
static TypeIdList getSupportedTypes()
Barcode *(*)() BarcodeCreateFct
Definition Factory.hpp:47
static bool isTypeSupported(const std::string &typeId)
static void init()
static Barcode * createBarcode(const std::string &typeId)
Definition TypeIdList.hpp:39
Definition Barcode.hpp:38