dca_interface  6.3.4
Initializing and Deinitializing the API

Initialization

The first thing you must do when using the SCA is to start the 3rd party libraries startup functions:

(see also Initialization of 3rd party libraries)

Next step is to set up a dca::DcaInstance object. This class encapsulates the API as a whole.

To create the instance fill out a dca::InitData structure, and call the function dca::DcaInstance::create().

Note that the provided directories are (once initialized) not changeable for this instance.

The use of two or more DcaInstance objects in the same process (using the same initialization directory) is currently not supported.

Deinitialization

The SCA will be deinitialized automatically once the DcaInstance object goes out of scope. For more information on DCA startup and shutdown, Please refer to Startup/Shutdown sequence.

Before going out of scope, call the Deinitilization functions of the 3rd party libraries in reverse order:

Sample code

The following code demonstrates how to initialize the SCA.

#include <dca_base.h>
#include <dca_callbacks.h>
// assume the DCA has been installed to the ~/dca directory
#define DCA_INSTALLDIR "~/dca"
#define DCA_BINDIR DCA_INSTALLDIR"/bin/linux"
#define DCA_INITDIR DCA_INSTALLDIR"/init"
#define DCA_LOGDIR "./logs"
void main()
{
try {
// required 3rd party library startups
// set up the required directories
dca::InitData myInitData;
myInitData.binDir = DCA_BINDIR;
myInitData.initDir = DCA_INITDIR;
myInitData.logDir = DCA_LOGDIR;
// start up DCA API
...
// when going out of scope, myDca will be automatically deinitialized
}
catch( const dca::ExDca& ex ) {
cout << "DCA error occurred (Error code: " << ex.getReturnCode() <<
", Description: " << ex.getDescription() << ")." << endl;
}
// required 3rd party library shutdowns
}
Exception class used in the DCA.
Definition: base_classes.h:237
void InitCUrl()
Initializes libcurl. Do not use any DCA function before initializing libcurl.
std::string initDir
the directory in which the DCA init files are stored
Definition: base_classes.h:266
std::string getDescription() const
Returns a description of the error.
std::string binDir
the directory in which the DCA binary (*.dca) files are stored
Definition: base_classes.h:265
This header includes initialization/deinitialization support functions for the 3rd party libraries us...
void SetOpenSslCallbacks()
Initializes the required callbacks for OpenSSL when using HTTPS or SSL connections in a multi-threade...
void UnsetOpenSslCallbacks()
Unsets the openssl callbacks. Do not call any DCA function after you have called this function.
void DeinitCUrl()
Deinitializes libcurl. Do not call any DCA function after you have called this function.
#define DCA_LOGDIR
Relative directory for logfile(s).
#define DCA_INITDIR
DCA subdirectory of the DCA initialization data.
DCA_RESULT_TYPE getReturnCode() const
Gets the code of the error.
This header includes all header files of the DCA Base Package.
Encapsulates the init and deinit of the DCA API.
Definition: base_classes.h:315
std::string logDir
the directory in which the DCA log file should be created
Definition: base_classes.h:267
#define DCA_BINDIR
DCA subdirectory of the DCA binaries.
This structure is used to initialize the DcaInstance.
Definition: base_classes.h:264
static DcaInstance create(const InitData &initData)
Creates a DcaInstance, starts up the DCA API and initializes the required main module.
int main(int argc, char *argv[])
The main routine.