51Degrees Device Detection C/C++  4.1

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

FiftyoneDegrees::DeviceDetection::Hash::EngineHash Class Reference

Detailed Description

Encapsulates the Hash engine class which implements EngineDeviceDetection.

This carries out processing using a Hash data set.

An engine is constructed with a configuration, and either a data file, or an in memory data set, 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;
string dataFilePath;
void *inMemoryDataSet;
long inMemoryDataSetLength;
// Construct the engine from a data file
EngineHash *engine = new EngineHash(
dataFilePath,
properties);
// Or from a data file which has been loaded into continuous
// memory
EngineHash *engine = new EngineHash(
inMemoryDataSet,
inMemoryDataSetLength,
properties);
// Process some evidence
ResultsHash *results = engine->process(evidence);
// Or just process a single User-Agent string
ResultsHash *results = engine->process("some User-Agent");
// Do something with the results
// ...
// Delete the results and the engine
delete results;
delete engine;
Examples
Hash/GettingStarted.cpp, Hash/MatchMetrics.cpp, Hash/MetaData.cpp, and Hash/StronglyTyped.cpp.

Inheritance diagram for FiftyoneDegrees::DeviceDetection::Hash::EngineHash:

[legend]

Collaboration diagram for FiftyoneDegrees::DeviceDetection::Hash::EngineHash:

[legend]

Public Member Functions

Constructors

 EngineHash (const char *fileName, ConfigHash *config, RequiredPropertiesConfig *properties)
Construct a new instance of the engine class with the configuration and properties provided. More...
 EngineHash (const string &fileName, ConfigHash *config, RequiredPropertiesConfig *properties)
Construct a new instance of the engine class with the configuration and properties provided. More...
 EngineHash (void *data, long length, ConfigHash *config, RequiredPropertiesConfig *properties)
Construct a new instance of the engine class with the configuration and properties provided. More...
 EngineHash (unsigned char data[], long length, ConfigHash *config, RequiredPropertiesConfig *properties)
Construct a new instance of the engine class with the configuration and properties provided. More...

Engine Methods

ResultsHash *  process (EvidenceDeviceDetection *evidence)
Processes the evidence provided and returns the result. More...
ResultsHash *  process (const char *userAgent)
Processes the User-Agent provided and returns the result. More...

Common::EngineBase Implementation

void  refreshData ()
Refresh the data set from the original file location. More...
void  refreshData (const char *fileName)
Refresh the data set from the file location provided. More...
void  refreshData (void *data, long length)
Refresh the data set from the memory location provided. More...
void  refreshData (unsigned char data[], long length)
Refresh the data set from the memory location provided. More...
ResultsBase *  processBase (EvidenceBase *evidence)
Processes the evidence provided and returns the result. More...
Date  getPublishedTime ()
Get the date at which the current data set was published. More...
Date  getUpdateAvailableTime ()
Get the date at which a new data file will be available to download from the URL returned by getDataUpdateUrl(). More...
string  getDataFilePath ()
Get the path to the data file the current data set was initialised from. More...
string  getDataFileTempPath ()
Get the path to the temporary data file created by the engine, or an empty string if one was not created. More...
string  getProduct ()
Get the name of the data set being used e.g. More...
string  getType ()
Get the tier of the data set being used e.g. More...

DeviceDetection::EngineDeviceDetection Implementation

ResultsDeviceDetection *  processDeviceDetection (EvidenceDeviceDetection *evidence)
Processes the evidence provided and returns the result. More...
ResultsDeviceDetection *  processDeviceDetection (const char *userAgent)
Processes the User-Agent provided and returns the result. More...

Public Member Functions inherited from FiftyoneDegrees::DeviceDetection::EngineDeviceDetection

 EngineDeviceDetection (ConfigDeviceDetection *config, RequiredPropertiesConfig *properties)
Construct a new instance of the engine class with the configuration and properties provided. More...
virtual ResultsDeviceDetection *  processDeviceDetection (string &userAgent)
Processes the User-Agent provided and returns the result. More...

Public Member Functions inherited from FiftyoneDegrees::Common::EngineBase

 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.
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...
MetaData *  getMetaData ()
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 ()
Gets whether or not automatic updates are enabled. More...
virtual string  getDataUpdateUrl ()
Get the URL to be used when updating the data file, or an empty string if this is not set. More...
vector< string > *  getKeys ()
Get the list of keys which the engine accepts as evidence. More...
bool  getIsThreadSafe ()
Get whether or not the engine was compiled with thread-safe support. More...

Protected Member Functions

void  init (fiftyoneDegreesDataSetHash *dataSet)
Initialise the engine with the data set provided. More...

Protected Member Functions inherited from FiftyoneDegrees::DeviceDetection::EngineDeviceDetection

virtual void  init (fiftyoneDegreesDataSetDeviceDetection *dataSet)
Initialise the engine with the data set provided. More...

Protected Member Functions inherited from FiftyoneDegrees::Common::EngineBase

virtual void  appendString (stringstream &stream, fiftyoneDegreesCollection *strings, uint32_t offset)
Gets a string from a strings collection, and appends to a stream. More...
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...

Friends

class  ::EngineHashTests

Constructor & Destructor Documentation

◆ EngineHash() [1/4]

FiftyoneDegrees::DeviceDetection::Hash::EngineHash::EngineHash ( const char *   fileName,
ConfigHash *   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 The data set is constructed from the file provided.
fileName - path to the file containing the data file to load

◆ EngineHash() [2/4]

FiftyoneDegrees::DeviceDetection::Hash::EngineHash::EngineHash ( const string &   fileName,
ConfigHash *   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 The data set is constructed from the file provided.
fileName - path to the file containing the data file to load

◆ EngineHash() [3/4]

FiftyoneDegrees::DeviceDetection::Hash::EngineHash::EngineHash ( void *   data,
long   length,
ConfigHash *   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 The data set is constructed from data stored in memory described by the data and length parameters.
data - pointer to the memory containing the data set
length - size of the data in memory

◆ EngineHash() [4/4]

FiftyoneDegrees::DeviceDetection::Hash::EngineHash::EngineHash ( unsigned char   data[],
long   length,
ConfigHash *   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 The data set is constructed from data stored in memory described by the data and length parameters.
data - pointer to the memory containing the data set
length - size of the data in memory

Member Function Documentation

◆ getDataFilePath()

string FiftyoneDegrees::DeviceDetection::Hash::EngineHash::getDataFilePath ( )
virtual

Get the path to the data file the current data set was initialised from.

Returns
data file path

Implements FiftyoneDegrees::Common::EngineBase.

◆ getDataFileTempPath()

string FiftyoneDegrees::DeviceDetection::Hash::EngineHash::getDataFileTempPath ( )
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

Implements FiftyoneDegrees::Common::EngineBase.

◆ getProduct()

length - size of the data in memory

Member Function Documentation

◆ getDataFilePath()

string FiftyoneDegrees::DeviceDetection::Hash::EngineHash::getDataFilePath ( )
virtual

Get the path to the data file the current data set was initialised from.

Returns
data file path

Implements FiftyoneDegrees::Common::EngineBase.

◆ getDataFileTempPath()

string FiftyoneDegrees::DeviceDetection::Hash::EngineHash::getDataFileTempPath ( )
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

Implements FiftyoneDegrees::Common::EngineBase.

◆ getProduct()

string FiftyoneDegrees::DeviceDetection::Hash::EngineHash::getProduct ( )
virtual

Get the name of the data set being used e.g.

Pattern or Hash.

Returns
product name

Implements FiftyoneDegrees::Common::EngineBase.

◆ getPublishedTime()

Date FiftyoneDegrees::DeviceDetection::Hash::EngineHash::getPublishedTime ( )
virtual

Get the date at which the current data set was published.

Returns
data set published date

Implements FiftyoneDegrees::Common::EngineBase.

◆ getType()

string FiftyoneDegrees::DeviceDetection::Hash::EngineHash::getType ( )
virtual

Get the tier of the data set being used e.g.

Premium or Enterprise.

Returns
data set type

Implements FiftyoneDegrees::Common::EngineBase.

◆ getUpdateAvailableTime()

Date FiftyoneDegrees::DeviceDetection::Hash::EngineHash::getUpdateAvailableTime ( )
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

Implements FiftyoneDegrees::Common::EngineBase.

◆ init()

void FiftyoneDegrees::DeviceDetection::Hash::EngineHash::init ( fiftyoneDegreesDataSetHash *   dataSet )
protected

Initialise the engine with the data set provided.

This is the data set which carries out all the processing in the engine.

Parameters
dataSet - pointer to the data used by the engine

◆ process() [2/2]

ResultsHash* FiftyoneDegrees::DeviceDetection::Hash::EngineHash::process ( const char *   userAgent )

Processes the User-Agent provided and returns the result.

Parameters
userAgent - to process. This is equivalent to processing the string as an item of evidence with the User-Agent header key.
Returns
a new results instance with the values for all requested properties

◆ processBase()

ResultsBase* FiftyoneDegrees::DeviceDetection::Hash::EngineHash::processBase ( EvidenceBase *   evidence )
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

Implements FiftyoneDegrees::Common::EngineBase.

◆ processDeviceDetection() [2/2]

ResultsDeviceDetection* FiftyoneDegrees::DeviceDetection::Hash::EngineHash::processDeviceDetection ( const char *   userAgent )
virtual

Processes the User-Agent provided and returns the result.

Parameters
userAgent - to process. This is equivalent to processing the string as an item of evidence with the User-Agent header key.
Returns
a new results instance with the values for all requested properties

Implements FiftyoneDegrees::DeviceDetection::EngineDeviceDetection.

◆ refreshData() [1/4]

void FiftyoneDegrees::DeviceDetection::Hash::EngineHash::refreshData ( )
virtual

Refresh the data set from the original file location.

This should be implemented by the extending class.

Implements FiftyoneDegrees::Common::EngineBase.

◆ refreshData() [2/4]

void FiftyoneDegrees::DeviceDetection::Hash::EngineHash::refreshData ( const char *   fileName )
virtual

Refresh the data set from the file location provided.

Parameters
fileName - of the new data file

Implements FiftyoneDegrees::Common::EngineBase.

◆ refreshData() [3/4]

void FiftyoneDegrees::DeviceDetection::Hash::EngineHash::refreshData ( void *   data,
long   length  
)
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

Implements FiftyoneDegrees::Common::EngineBase.

◆ refreshData() [4/4]

void FiftyoneDegrees::DeviceDetection::Hash::EngineHash::refreshData ( unsigned char   data[],
long   length  
)
virtual

Refresh the data set from the memory location provided.

Parameters
data - pointer to the data in memory
length - of the data in memory

Implements FiftyoneDegrees::Common::EngineBase.


The documentation for this class was generated from the following file:
  • /home/vsts/work/1/s/apis/device-detection-cxx/src/hash/EngineHash.hpp