51Degrees Device Detection C/C++  4.1

A device detection library that is used natively or by 51Degrees products

EngineBase.hpp

1 /* *********************************************************************
2  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3  * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
5  *
6  * This Original Work is licensed under the European Union Public Licence (EUPL)
7  * v.1.2 and is subject to its terms as set out below.
8  *
9  * If a copy of the EUPL was not distributed with this file, You can obtain
10  * one at https://opensource.org/licenses/EUPL-1.2.
11  *
12  * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13  * amended by the European Commission) shall be deemed incompatible for
14  * the purposes of the Work and the provisions of the compatibility
15  * clause in Article 5 of the EUPL shall not apply.
16  *
17  * If using the Work as, or as part of, a network application, by
18  * including the attribution notice(s) required under Article 5 of the EUPL
19  * in the end user terms of the application under an appropriate heading,
20  * such notice(s) shall fulfill the requirements of that article.
21  * ********************************************************************* */
22 
23 #ifndef FIFTYONE_DEGREES_ENGINE_BASE_HPP
24 #define FIFTYONE_DEGREES_ENGINE_BASE_HPP
25 
26 #include <string>
27 #include <vector>
28 #include <sstream>
29 #include <memory>
30 #include <algorithm>
31 #include "Exceptions.hpp"
32 #include "RequiredPropertiesConfig.hpp"
33 #include "Date.hpp"
34 #include "ConfigBase.hpp"
35 #include "MetaData.hpp"
36 #include "EvidenceBase.hpp"
37 #include "ResultsBase.hpp"
38 #include "dataset.h"
39 #include "property.h"
40 #include "collection.h"
41 
42 using namespace std;
43 
44 namespace FiftyoneDegrees {
45  namespace Common {
78  class EngineBase {
79  public:
92  EngineBase(
93  ConfigBase *config,
94  RequiredPropertiesConfig *properties);
95 
100  virtual ~EngineBase();
101 
115  virtual ResultsBase* processBase(EvidenceBase *evidence) = 0;
116 
121  virtual void refreshData() = 0;
122 
127  virtual void refreshData(const char *fileName) = 0;
128 
134  virtual void refreshData(void *data, long length) = 0;
135 
141  virtual void refreshData(unsigned char data[], long length) = 0;
142 
153  void setLicenseKey(const string &licenseKey);
154 
159  void setDataUpdateUrl(const string &updateUrl);
160 
173  MetaData* getMetaData();
174 
181  bool getAutomaticUpdatesEnabled();
182 
188  virtual string getDataFilePath() = 0;
189 
195  virtual string getDataFileTempPath() = 0;
196 
202  virtual string getDataUpdateUrl();
203 
208  virtual Date getPublishedTime() = 0;
209 
215  virtual Date getUpdateAvailableTime() = 0;
216 
221  virtual string getProduct() = 0;
222 
228  virtual string getType() = 0;
229 
236  vector<string>* getKeys();
237 
243  bool getIsThreadSafe();
244 
248  protected:
251 
258  shared_ptr<fiftyoneDegreesResourceManager> manager;
259 
262 
266 
268  string licenceKey;
269 
271  string updateUrl;
272 
275 
277  vector<string> keys;
278 
285  virtual void appendString(
286  stringstream &stream,
287  fiftyoneDegreesCollection *strings,
288  uint32_t offset);
289 
296  void initHttpHeaderKeys(fiftyoneDegreesHeaders *uniqueHeaders);
297 
304  void initOverrideKeys(
305  fiftyoneDegreesOverridePropertyArray *overrideProperties);
306 
312  void addKey(string key);
313  };
314  }
315 }
316 
317 #endif
shared_ptr< fiftyoneDegreesResourceManager > manager
A shared pointer to the manager is passed around and referenced by all instances that hold open a res...
Definition: EngineBase.hpp:258
MetaData * metaData
Pointer to the meta data relating to the contents of the engine's data set.
Definition: EngineBase.hpp:265
string licenceKey
License key used to update the data set.
Definition: EngineBase.hpp:268
string defaultDataKey
The default key to use when adding the results to a dictionary.
Definition: EngineBase.hpp:274
Base evidence class containing evidence to be processed by an engine.
Definition: EvidenceBase.hpp:64
Encapsulates the engine class to be extended by engine implementations.
Definition: EngineBase.hpp:78
The Date class wraps the C fiftyoneDegreesDate structure and is used to represent dates in engines.
Definition: Date.hpp:48
51Degrees base namespace.
Definition: ComponentMetaDataBuilderHash.hpp:34
C++ class wrapper for the fiftyoneDegreesConfigBase configuration structure.
Definition: ConfigBase.hpp:60
ConfigBase * config
Pointer to the configuration used to build the engine.
Definition: EngineBase.hpp:250
vector< string > keys
Keys which should be added to evidence.
Definition: EngineBase.hpp:277
string updateUrl
URL used to update the data set.
Definition: EngineBase.hpp:271
Contains meta data for the properties, values, profiles and components that exist within the engine i...
Definition: MetaData.hpp:68
Array of items of type fiftyoneDegreesHeader used to easily access and track the size of the array.
Definition: headers.h:131
C++ class wrapper for the fiftyoneDegreesPropertiesRequired structure.
Definition: RequiredPropertiesConfig.hpp:57
RequiredPropertiesConfig * requiredProperties
Pointer to the properties which are going to be used.
Definition: EngineBase.hpp:261
Array of items of type fiftyoneDegreesOverrideProperty used to easily access and track the size of th...
Definition: overrides.h:102
Encapsulates the results of an engine's processing.
Definition: ResultsBase.hpp:81
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:407