\r\n

51Degrees Device Detection C/C++  4.4

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

FiftyoneDegrees::Common::EngineBase Class Reference abstract

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

using namespace FiftyoneDegrees::Common;
// Construct the engine
EngineBase *engine = new EngineBase(config, properties);
// Process some evidence
ResultsBase *results = engine->processBase(evidence);
// Do something with the results
// ...
// Delete the results and the engine
delete results;
delete engine;

Inheritance diagram for FiftyoneDegrees::Common::EngineBase:

[legend]

Collaboration diagram for FiftyoneDegrees::Common::EngineBase:

[legend]

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. More...
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. More...
virtual void  refreshData () const =0
Refresh the data set from the original file location. More...
virtual void  refreshData (const char *fileName) const =0
Refresh the data set from the file location provided. More...
virtual void  refreshData (void *data, long length) const =0
Refresh the data set from the memory location provided. More...
virtual void  refreshData (unsigned char data[], long length) const =0
Refresh the data set from the memory location provided. More...

Setters

void  setLicenseKey (const string &licenseKey)
Sets the license key to be used when updating the data set. More...
void  setDataUpdateUrl (const string &updateUrl)
Sets the URL to be used when updating the data set. More...

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. More...
bool  getAutomaticUpdatesEnabled () const
Gets whether or not automatic updates are enabled. More...
virtual string  getDataFilePath () const =0
Get the path to the data file the current data set was initialised from. More...
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. More...
virtual string  getDataUpdateUrl () const
Get the URL to be used when updating the data file, or an empty string if this is not set. More...
virtual Date  getPublishedTime () const =0
Get the date at which the current data set was published. More...
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(). More...
virtual string  getProduct () const =0
Get the name of the data set being used e.g. More...
virtual string  getType () const =0
Get the tier of the data set being used e.g. More...
const vector< string > *  getKeys () const
Get the list of keys which the engine accepts as evidence. More...
bool  getIsThreadSafe () const
Get whether or not the engine was compiled with thread-safe support. More...

Protected Member Functions

virtual void  appendString (stringstream &stream, fiftyoneDegreesCollection *strings, uint32_t offset) const
Gets a string from a strings collection, and appends to a stream. More...
virtual void  initHttpHeaderKeys (fiftyoneDegreesHeaders *uniqueHeaders)
Initialise the HTTP header keys which are used by this engine. More...
void  initOverrideKeys (fiftyoneDegreesOverridePropertyArray *overrideProperties)
Initialise the override keys which are used by this engine. More...
void  addKey (string key)
Adds a key to the list of keys which should be added as evidence. More...

Protected Attributes

ConfigBase *  config
Pointer to the configuration used to build the engine. More...
shared_ptr< fiftyoneDegreesResourceManager >  manager
A shared pointer to the manager is passed around and referenced by all instances that hold open a resource handle. More...
RequiredPropertiesConfig *  requiredProperties
Pointer to the properties which are going to be used. More...
MetaData *  metaData
Pointer to the meta data relating to the contents of the engine's data set. More...
string  licenceKey
License key used to update the data set. More...
string  updateUrl
URL used to update the data set. More...
string  defaultDataKey
The default key to use when adding the results to a dictionary. More...
vector< string >  keys
Keys which should be added to evidence. More...

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

Member Function Documentation

◆ addKey()

void FiftyoneDegrees::Common::EngineBase::addKey ( string   key )
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()

virtual void FiftyoneDegrees::Common::EngineBase::appendString ( stringstream &   stream,
fiftyoneDegreesCollection *   strings,
uint32_t   offset  
) const
protected virtual

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

◆ 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()

virtual string FiftyoneDegrees::Common::EngineBase::getDataFilePath ( ) const
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()

virtual string FiftyoneDegrees::Common::EngineBase::getDataFileTempPath ( ) const
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 string FiftyoneDegrees::Common::EngineBase::getDataUpdateUrl ( ) const
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.

◆ initHttpHeaderKeys()

virtual void FiftyoneDegrees::Common::EngineBase::initHttpHeaderKeys ( fiftyoneDegreesHeaders *   uniqueHeaders )
protected virtual

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()

void FiftyoneDegrees::Common::EngineBase::initOverrideKeys ( fiftyoneDegreesOverridePropertyArray *   overrideProperties )
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()

virtual ResultsBase* FiftyoneDegrees::Common::EngineBase::processBase ( EvidenceBase *   evidence ) const
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]

virtual void FiftyoneDegrees::Common::EngineBase::refreshData ( ) const
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]

virtual void FiftyoneDegrees::Common::EngineBase::refreshData ( const char *   fileName ) const
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]

virtual void FiftyoneDegrees::Common::EngineBase::refreshData ( void *   data,
long   length  
) const
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.

◆ refreshData() [4/4]

virtual void FiftyoneDegrees::Common::EngineBase::refreshData ( unsigned char   data[],
long   length  
) const
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.

◆ 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

◆ config

ConfigBase* FiftyoneDegrees::Common::EngineBase::config
protected

Pointer to the configuration used to build the engine.

◆ defaultDataKey

string FiftyoneDegrees::Common::EngineBase::defaultDataKey
protected

The default key to use when adding the results to a dictionary.

◆ keys

vector<string> FiftyoneDegrees::Common::EngineBase::keys
protected

Keys which should be added to evidence.

◆ licenceKey

string FiftyoneDegrees::Common::EngineBase::licenceKey
protected

License key used to update the data set.

May be empty.

◆ manager

shared_ptr<fiftyoneDegreesResourceManager> FiftyoneDegrees::Common::EngineBase::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.

◆ metaData

MetaData* FiftyoneDegrees::Common::EngineBase::metaData
protected

Pointer to the meta data relating to the contents of the engine's data set.

◆ requiredProperties

RequiredPropertiesConfig* FiftyoneDegrees::Common::EngineBase::requiredProperties
protected

Pointer to the properties which are going to be used.

◆ updateUrl

string FiftyoneDegrees::Common::EngineBase::updateUrl
protected

URL used to update the data set.


The documentation for this class was generated from the following file:
  • /home/runner/work/device-detection-cxx/device-detection-cxx/common/device-detection-cxx/src/common-cxx/EngineBase.hpp