url_samples: urldbdownloadsample


Introduction

Demonstrates the use of dca::DbConnection, dca::UpdateModule and dca::DcaInstance::schedule() to update a local database.

Syntax:

urldbdownloadsample <dca-redist-folder> <ticket> <product>
Note:
The execution of this sample (at least for the first time) may take a long time until the large local URL database is being downloaded. Subsequent executions are much faster since they only will download incremental database update files.
See also:

Classes

class  MyUrlScheduleEventSubscriber
 Example implementation of a schedule event subscriber. More...

Files

file  url_samples/urldbdownloadsample/main.cpp
 

Sample to update an existing local database, and download a complete database if necessary.


file  url_samples/urldbdownloadsample/schedule_event_subscriber.h
 

Header file for the schedule event subscriber.


Defines

#define DCA_BINDIR   "bin/linux"
 DCA subdirectory of the DCA binaries.
#define DCA_INITDIR   "init"
 DCA subdirectory of the DCA initialization data.
#define DCA_LOGDIR   "./logs"
 Relative directory for logfile(s).

Functions

static void SetupInitData (const std::string &redist_folder, InitData &initData)
 Sets up the given initData by substituting the given redist_folder with DCA subdirectories.
static void SetupLicense (const std::string &ticket, const std::string &product, LicenseData &licenseData)
 Sets up the given licenseData by copying the given ticket and product strings.
static void SetupConnectionData (DbConnectionData &cData)
 Sets up the given cData to use a local URL database.
static void PrintToolHeader ()
 Prints out the name and the version of this sample.
static void PrintUsage (const char *name)
 Prints out the syntax of the sample.
static void PrintUpdateResults (const UpdateResults &results)
 Prints out the update results on the screen.
static void PerformUpdateAndSchedule (const DcaInstance &myDca, const DbConnection &myDbConnection, const UpdateModule &myUpdateModule)
 Sets up required classes and performs a DCA update and schedule.
int main (int argc, char *argv[])
 The main routine.

Variables

const std::string S_UsageString
 Usage string, displayed if a parameter was missing.

Function Documentation

static void SetupInitData ( const std::string &  redist_folder,
InitData initData 
) [static]

Sets up the given initData by substituting the given redist_folder with DCA subdirectories.

Parameters:
[in] redist_folder This is the folder where the DCA has been installed to (assuming trailing fileslash)
[out] initData The InitData structure to set up
Note:
Only DCA_BINDIR differs between Windows and Linux
The directory ./logs is used for the logfile(s)

Definition at line 93 of file url_samples/urldbdownloadsample/main.cpp.

static void SetupLicense ( const std::string &  ticket,
const std::string &  product,
LicenseData licenseData 
) [static]

Sets up the given licenseData by copying the given ticket and product strings.

Parameters:
[in] ticket This is the ticket data as provided with your DCA license
[in] product This is the product shortcut e.g. DC oder MS etc
[out] licenseData The LicenseData structure to set up

Definition at line 107 of file url_samples/urldbdownloadsample/main.cpp.

static void SetupConnectionData ( DbConnectionData cData  )  [static]

Sets up the given cData to use a local URL database.

Parameters:
[in] cData The DbConnectionData structure to set up

Definition at line 119 of file url_samples/urldbdownloadsample/main.cpp.

static void PrintUsage ( const char *  name  )  [static]

Prints out the syntax of the sample.

Parameters:
[in] name The name of the executable

Definition at line 139 of file url_samples/urldbdownloadsample/main.cpp.

static void PrintUpdateResults ( const UpdateResults results  )  [static]

Prints out the update results on the screen.

Parameters:
[in] results The update results object

Definition at line 149 of file url_samples/urldbdownloadsample/main.cpp.

static void PerformUpdateAndSchedule ( const DcaInstance myDca,
const DbConnection myDbConnection,
const UpdateModule myUpdateModule 
) [static]

Sets up required classes and performs a DCA update and schedule.

This function first performs an Update using UpdateModule::performUpdate(). After the update is complete, DcaInstance::schedule() is called to either download a complete database, or refresh the database cache with the new updates.

Parameters:
[in] myDca A valid set up DCA Instance
[in] myDbConnection A valid and initialized DbConnection
[in] myUpdateModule A valid and initialized UpdateModule
Note:
This is a simple example to demonstrate the effects of UpdateModule::performUpdate and DcaInstance::schedule. In your application you should set up dedicated threads to call these functions at regular intervals.
See also:
url_samples: urldbsample_extended

Definition at line 212 of file url_samples/urldbdownloadsample/main.cpp.

int main ( int  argc,
char *  argv[] 
)

The main routine.

Parameters:
[in] argc The count of arguments provided
[in] argv An array of provided arguments
Returns:
5 on usage error, 10 on exception and internal error and 0 on success

Definition at line 252 of file url_samples/urldbdownloadsample/main.cpp.


Variable Documentation

const std::string S_UsageString
Initial value:
        " <redist-folder> <ticket> <product>\n"
        "  redist-folder - the folder where the DCA is installed to\n"
        "  ticket - a valid ticket\n"
        "  product - the product associated with your ticket\n\n"

Usage string, displayed if a parameter was missing.

Definition at line 57 of file url_samples/urldbdownloadsample/main.cpp.


Generated on 26 Sep 2016 for dca_interface by  doxygen 1.6.1