Detailed Description
Encapsulates the engine class to be extended by engine implementations.
Common logic is contained in this base class to be used by any extending classes.
An engine is constructed with a configuration, then used to process evidence in order to return a set of results. It also exposes methods to refresh the data using a new data set, and get properties relating to the data set being used by the engine.
Usage Example
Inheritance diagram for FiftyoneDegrees::Common::EngineBase:
Collaboration diagram for FiftyoneDegrees::Common::EngineBase:
Public Member Functions | |
Constructors and Destructors | |
| EngineBase (ConfigBase *config, RequiredPropertiesConfig *properties) | |
| Construct a new instance of the engine class with the configuration and properties provided. | |
| virtual | ~EngineBase () |
| Frees the meta data class and the data set resource created by the extending class. | |
Engine Methods | |
| virtual ResultsBase * | processBase (EvidenceBase *evidence) const =0 |
| Processes the evidence provided and returns the result. | |
| virtual void | refreshData () const =0 |
| Refresh the data set from the original file location. | |
| virtual void | refreshData (const char *fileName) const =0 |
| Refresh the data set from the file location provided. | |
| virtual void | refreshData (void *data, fiftyoneDegreesFileOffset length) const =0 |
| Refresh the data set from the memory location provided. | |
| virtual void | refreshData (unsigned char data[], fiftyoneDegreesFileOffset length) const =0 |
| Refresh the data set from the memory location provided. | |
Setters | |
| void | setLicenseKey (const string &licenseKey) |
| Sets the license key to be used when updating the data set. | |
| void | setDataUpdateUrl (const string &updateUrl) |
| Sets the URL to be used when updating the data set. | |
Getters | |
| MetaData * | getMetaData () const |
| Return the a pointer to the meta data class which contains meta data for the properties, values, profiles and components that exist within the engine. | |
| bool | getAutomaticUpdatesEnabled () const |
| Gets whether or not automatic updates are enabled. | |
| virtual string | getDataFilePath () const =0 |
| Get the path to the data file the current data set was initialised from. | |
| virtual string | getDataFileTempPath () const =0 |
| Get the path to the temporary data file created by the engine, or an empty string if one was not created. | |
| virtual string | getDataUpdateUrl () const |
| Get the URL to be used when updating the data file, or an empty string if this is not set. | |
| virtual Date | getPublishedTime () const =0 |
| Get the date at which the current data set was published. | |
| virtual Date | getUpdateAvailableTime () const =0 |
| Get the date at which a new data file will be available to download from the URL returned by getDataUpdateUrl(). | |
| virtual string | getProduct () const =0 |
| Get the name of the data set being used e.g. | |
| virtual string | getType () const =0 |
| Get the tier of the data set being used e.g. | |
| const vector< string > * | getKeys () const |
| Get the list of keys which the engine accepts as evidence. | |
| vector< string > | getRequiredProperties () const |
| Get the names of the required properties in required property index order, so position i in the vector is the index a caller passes for that property. | |
| bool | getIsThreadSafe () const |
| Get whether or not the engine was compiled with thread-safe support. | |
Protected Member Functions | |
| virtual void | appendValue (stringstream &stream, fiftyoneDegreesCollection *strings, uint32_t offset, fiftyoneDegreesPropertyValueType storedValueType) const |
| Gets a string from a strings collection, and appends to a stream. | |
| virtual void | appendString (stringstream &stream, fiftyoneDegreesCollection *strings, uint32_t offset) const |
| Gets a string from a strings collection, and appends to a stream. | |
| virtual void | initHttpHeaderKeys (fiftyoneDegreesHeaders *uniqueHeaders) |
| Initialise the HTTP header keys which are used by this engine. | |
| void | initOverrideKeys (fiftyoneDegreesOverridePropertyArray *overrideProperties) |
| Initialise the override keys which are used by this engine. | |
| void | addKey (string key) |
| Adds a key to the list of keys which should be added as evidence. | |
Protected Attributes | |
| ConfigBase * | config |
| Pointer to the configuration used to build the engine. | |
| shared_ptr< fiftyoneDegreesResourceManager > | manager |
| A shared pointer to the manager is passed around and referenced by all instances that hold open a resource handle. | |
| RequiredPropertiesConfig * | requiredProperties |
| Pointer to the properties which are going to be used. | |
| MetaData * | metaData |
| Pointer to the meta data relating to the contents of the engine's data set. | |
| string | licenceKey |
| License key used to update the data set. | |
| string | updateUrl |
| URL used to update the data set. | |
| string | defaultDataKey |
| The default key to use when adding the results to a dictionary. | |
| vector< string > | keys |
| Keys which should be added to evidence. | |
Constructor & Destructor Documentation
◆ EngineBase()
| FiftyoneDegrees::Common::EngineBase::EngineBase | ( | ConfigBase * | config, |
| RequiredPropertiesConfig * | properties ) |
Construct a new instance of the engine class with the configuration and properties provided.
- Parameters
-
config used to build the engine properties the properties expected to be fetched from results, or null for every property
Member Function Documentation
◆ addKey()
|
protected |
Adds a key to the list of keys which should be added as evidence.
This is called by the key init methods.
- Parameters
-
key to add
◆ appendString()
|
protectedvirtual |
Gets a string from a strings collection, and appends to a stream.
- Parameters
-
stream to append the string to strings collection to get the string from offset of the string in the collection
◆ appendValue()
|
protectedvirtual |
Gets a string from a strings collection, and appends to a stream.
- Parameters
-
stream to append the string to strings collection to get the string from offset of the string in the collection storedValueType format of byte array representation.
◆ getAutomaticUpdatesEnabled()
| bool FiftyoneDegrees::Common::EngineBase::getAutomaticUpdatesEnabled | ( | ) | const |
Gets whether or not automatic updates are enabled.
If they are, then this tells an external service that it should update the data set.
- Returns
- true if updates are enabled
◆ getDataFilePath()
|
pure virtual |
Get the path to the data file the current data set was initialised from.
- Returns
- data file path
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ getDataFileTempPath()
|
pure virtual |
Get the path to the temporary data file created by the engine, or an empty string if one was not created.
- Returns
- temp data file path or empty string
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ getDataUpdateUrl()
|
virtual |
Get the URL to be used when updating the data file, or an empty string if this is not set.
- Returns
- URL to download new data file from
◆ getIsThreadSafe()
| bool FiftyoneDegrees::Common::EngineBase::getIsThreadSafe | ( | ) | const |
Get whether or not the engine was compiled with thread-safe support.
If it was not then certain precautions should be taken.
- Returns
- true if the engine is thread-safe
◆ getKeys()
| const vector< string > * FiftyoneDegrees::Common::EngineBase::getKeys | ( | ) | const |
Get the list of keys which the engine accepts as evidence.
This is a pointer to an internal vector should not (and cannot) be freed.
- Returns
- pointer to the list of evidence keys
◆ getMetaData()
| MetaData * FiftyoneDegrees::Common::EngineBase::getMetaData | ( | ) | const |
Return the a pointer to the meta data class which contains meta data for the properties, values, profiles and components that exist within the engine.
- Returns
- pointer to the meta data class
- Examples
- Hash/MetaData.cpp.
◆ getProduct()
|
pure virtual |
Get the name of the data set being used e.g.
Pattern or Hash.
- Returns
- product name
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ getPublishedTime()
|
pure virtual |
Get the date at which the current data set was published.
- Returns
- data set published date
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ getRequiredProperties()
| vector< string > FiftyoneDegrees::Common::EngineBase::getRequiredProperties | ( | ) | const |
Get the names of the required properties in required property index order, so position i in the vector is the index a caller passes for that property.
When the engine named its properties these are the names it was created with, in that order, and a refresh does not change them. When it named none, they are the names of every property the data file loaded has, sorted by name.
- Returns
- the required property names
◆ getType()
|
pure virtual |
Get the tier of the data set being used e.g.
Premium or Enterprise.
- Returns
- data set type
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ getUpdateAvailableTime()
|
pure virtual |
Get the date at which a new data file will be available to download from the URL returned by getDataUpdateUrl().
- Returns
- new data set available date
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ initHttpHeaderKeys()
|
protectedvirtual |
Initialise the HTTP header keys which are used by this engine.
These are the pieces of evidence which should be passed in if available.
- Parameters
-
uniqueHeaders to get the keys from
◆ initOverrideKeys()
|
protected |
Initialise the override keys which are used by this engine.
These are additional pieces of evidence which should be passed in if available.
- Parameters
-
overrideProperties to get the keys from
◆ processBase()
|
pure virtual |
Processes the evidence provided and returns the result.
- Parameters
-
evidence to process. The keys in getKeys() will be the only ones considered by the engine.
- Returns
- a new results instance with the values for all requested properties
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ refreshData() [1/4]
|
pure virtual |
Refresh the data set from the original file location.
This should be implemented by the extending class.
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ refreshData() [2/4]
|
pure virtual |
Refresh the data set from the file location provided.
- Parameters
-
fileName of the new data file
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ refreshData() [3/4]
|
pure virtual |
Refresh the data set from the memory location provided.
- Parameters
-
data pointer to the data in memory length of the data in memory
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ refreshData() [4/4]
|
pure virtual |
Refresh the data set from the memory location provided.
- Parameters
-
data pointer to the data in memory length length of the data in memory
Implemented in FiftyoneDegrees::DeviceDetection::Hash::EngineHash.
◆ setDataUpdateUrl()
| void FiftyoneDegrees::Common::EngineBase::setDataUpdateUrl | ( | const string & | updateUrl | ) |
Sets the URL to be used when updating the data set.
- Parameters
-
updateUrl to set
◆ setLicenseKey()
| void FiftyoneDegrees::Common::EngineBase::setLicenseKey | ( | const string & | licenseKey | ) |
Sets the license key to be used when updating the data set.
- Parameters
-
licenseKey to set
Field Documentation
◆ licenceKey
|
protected |
License key used to update the data set.
May be empty.
◆ manager
|
protected |
A shared pointer to the manager is passed around and referenced by all instances that hold open a resource handle.
This acts as a counter to ensure that the pointer to the manager remains valid until the last handle is freed. The shared pointer also handles freeing the pointer once no references remain. See resource.h for more information.
The documentation for this class was generated from the following file:
