51Degrees Common C/C++  4.1

A shared functionality library that is used by 51Degrees products

EngineBase.hpp

1 /* *********************************************************************
2  * This Source Code Form 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 Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0.
8  *
9  * If a copy of the MPL was not distributed with this file, You can obtain
10  * one at http://mozilla.org/MPL/2.0/.
11  *
12  * This Source Code Form is "Incompatible With Secondary Licenses", as
13  * defined by the Mozilla Public License, v. 2.0.
14  * ********************************************************************* */
15 
16 #ifndef FIFTYONE_DEGREES_ENGINE_BASE_HPP
17 #define FIFTYONE_DEGREES_ENGINE_BASE_HPP
18 
19 #include <string>
20 #include <vector>
21 #include <sstream>
22 #include <memory>
23 #include <algorithm>
24 #include "Exceptions.hpp"
25 #include "RequiredPropertiesConfig.hpp"
26 #include "Date.hpp"
27 #include "ConfigBase.hpp"
28 #include "MetaData.hpp"
29 #include "EvidenceBase.hpp"
30 #include "ResultsBase.hpp"
31 #include "dataset.h"
32 #include "property.h"
33 #include "collection.h"
34 
35 using namespace std;
36 
37 namespace FiftyoneDegrees {
38  namespace Common {
71  class EngineBase {
72  public:
85  EngineBase(
86  ConfigBase *config,
87  RequiredPropertiesConfig *properties);
88 
93  virtual ~EngineBase();
94 
108  virtual ResultsBase* processBase(EvidenceBase *evidence) = 0;
109 
114  virtual void refreshData() = 0;
115 
120  virtual void refreshData(const char *fileName) = 0;
121 
127  virtual void refreshData(void *data, long length) = 0;
128 
134  virtual void refreshData(unsigned char data[], long length) = 0;
135 
146  void setLicenseKey(const string &licenseKey);
147 
152  void setDataUpdateUrl(const string &updateUrl);
153 
166  MetaData* getMetaData();
167 
174  bool getAutomaticUpdatesEnabled();
175 
181  virtual string getDataFilePath() = 0;
182 
188  virtual string getDataFileTempPath() = 0;
189 
195  virtual string getDataUpdateUrl();
196 
201  virtual Date getPublishedTime() = 0;
202 
208  virtual Date getUpdateAvailableTime() = 0;
209 
214  virtual string getProduct() = 0;
215 
221  virtual string getType() = 0;
222 
229  vector<string>* getKeys();
230 
236  bool getIsThreadSafe();
237 
241  protected:
244 
251  shared_ptr<fiftyoneDegreesResourceManager> manager;
252 
255 
259 
261  string licenceKey;
262 
264  string updateUrl;
265 
268 
270  vector<string> keys;
271 
278  virtual void appendString(
279  stringstream &stream,
280  fiftyoneDegreesCollection *strings,
281  uint32_t offset);
282 
289  void initHttpHeaderKeys(fiftyoneDegreesHeaders *uniqueHeaders);
290 
297  void initOverrideKeys(
298  fiftyoneDegreesOverridePropertyArray *overrideProperties);
299 
305  void addKey(string key);
306  };
307  }
308 }
309 
310 #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:251
MetaData * metaData
Pointer to the meta data relating to the contents of the engine's data set.
Definition: EngineBase.hpp:258
string licenceKey
License key used to update the data set.
Definition: EngineBase.hpp:261
string defaultDataKey
The default key to use when adding the results to a dictionary.
Definition: EngineBase.hpp:267
Base evidence class containing evidence to be processed by an engine.
Definition: EvidenceBase.hpp:57
Encapsulates the engine class to be extended by engine implementations.
Definition: EngineBase.hpp:71
The Date class wraps the C fiftyoneDegreesDate structure and is used to represent dates in engines.
Definition: Date.hpp:41
51Degrees base namespace.
Definition: Collection.hpp:24
C++ class wrapper for the fiftyoneDegreesConfigBase configuration structure.
Definition: ConfigBase.hpp:53
ConfigBase * config
Pointer to the configuration used to build the engine.
Definition: EngineBase.hpp:243
vector< string > keys
Keys which should be added to evidence.
Definition: EngineBase.hpp:270
string updateUrl
URL used to update the data set.
Definition: EngineBase.hpp:264
Contains meta data for the properties, values, profiles and components that exist within the engine i...
Definition: MetaData.hpp:61
Array of items of type fiftyoneDegreesHeader used to easily access and track the size of the array.
Definition: headers.h:124
C++ class wrapper for the fiftyoneDegreesPropertiesRequired structure.
Definition: RequiredPropertiesConfig.hpp:50
RequiredPropertiesConfig * requiredProperties
Pointer to the properties which are going to be used.
Definition: EngineBase.hpp:254
Array of items of type fiftyoneDegreesOverrideProperty used to easily access and track the size of th...
Definition: overrides.h:95
Encapsulates the results of an engine's processing.
Definition: ResultsBase.hpp:74
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:400