Go to the documentation of this file.
45 const std::string S_ToolName =
"getversionsample";
46 const std::string S_ToolVersion =
"1.0";
53 "<dca-redist-folder> <ticket> <product>\n"
54 " dca-redist-folder - the folder where the DCA is installed to\n"
55 " ticket - a valid ticket\n"
56 " product - the product associated with your ticket\n\n"
64 # define DCA_BINDIR "bin/Win32"
66 # define DCA_BINDIR "bin/linux"
73 #define DCA_INITDIR "init"
78 #define DCA_LOGDIR "./logs"
102 static void SetupLicense(
const std::string& ticket,
const std::string& product,
105 licenseData.
ticket = ticket;
117 struct tm *expirationTime = localtime( &expirationDate );
119 std::cout <<
"License Info:" << std::endl;
120 std::cout <<
" DCA is " << ( aLicense.
isLicensed() ?
"licensed." :
121 "not licensed." ) << std::endl;
122 std::cout <<
" MaxUsers:" << aLicense.
getMaxUsers() <<
126 std::cout <<
" Ticket:" << aLicense.
getTicket() <<
128 std::cout <<
" Session:" << aLicense.
getSession() <<
132 std::cout <<
" Expiration Date:" << asctime( expirationTime ) <<
145 if( numOfVersionInfoResults == 0 ) {
147 std::cout <<
"No version information found." << std::endl;
151 std::cout <<
"Retrieved " << numOfVersionInfoResults <<
152 " VersionInfoResult objects" << std::endl;
158 std::cout <<
" #" << (i+1) <<
") VersionInfoResult [ name=" <<
159 myVersionInfoResult.
name() <<
", id=" << myVersionInfoResult.
id() <<
160 ", size=" << numOfVersionInfoDetails <<
" ]" << std::endl;
164 myVersionInfoResult[ u ];
166 std::cout <<
" #" << (u+1) <<
") VersionInfoResultDetail [" <<
167 " component='" << myVersionInfoResultDetail.
component() <<
168 ", version=" << myVersionInfoResultDetail.
version() <<
"] "
180 std::cout <<
"IBM DCA Sample: " << S_ToolName <<
" (" << S_ToolVersion <<
")" << std::endl;
190 std::cout << name <<
" usage:" << std::endl;
201 int main(
int argc,
char *argv[] )
213 std::string myRedistFolder = argv[ 1 ];
214 const std::string myTicket = argv[ 2 ];
215 const std::string myProduct = argv[ 3 ];
217 if( myRedistFolder.empty() || myTicket.empty() || myProduct.empty() ) {
223 const char c = myRedistFolder[ myRedistFolder.length() - 1 ];
224 if( c !=
'/' && c !=
'\\' )
225 myRedistFolder +=
"/";
255 catch(
const ExDca& ex ) {
256 std::cerr <<
"DCA Exception occured. Details: " << ex.
getDescription() <<
260 catch(
const std::exception& s ) {
261 std::cerr <<
"std::exception occured. Details: " << s.what() <<
"." <<
266 std::cerr <<
"Unknown exception caught." << std::endl;
Is used to create a License object. A license first must be created with DcaInstance::createLicense t...
Exception class used in the DCA.
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
int getMaxSessions() const
Returns the maximum allowed sessions associated with your ticket/license.
VersionInfoResults getVersionInfo() const
Returns enumerable version information about all currently loaded modules.
time_t getExpirationDate() const
Returns the expiration date of the license in UTC.
std::string getDescription() const
Returns a description of the error.
DCA_SIZE_TYPE size() const
Returns the number of VersionInfoResultDetail objects in the container.
static void SetupInitData(const std::string &redist_folder, InitData &initData)
Sets up the given initData by substituting the given redist_folder with DCA subdirectories.
std::string binDir
the directory in which the DCA binary (*.dca) files are stored
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.
int getMaxUsers() const
Returns the maximum allowed users associated with your ticket/license.
DCA_MODULE_ID_TYPE id() const
void DeinitCUrl()
Deinitializes libcurl. Do not call any DCA function after you have called this function.
std::string version() const
#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.
Class that contains all version information of all initialized DCA modules.
static void PrintToolHeader()
Prints out the name and the version of this sample.
Class that contains all details of type dca::VersionInfoResult object.
static void PrintVersion(const VersionInfoResults &aVersionInfoResults)
Prints out the version information gathered from current DcaInstance.
Use a License to initialize a classification package or a toolbox package.
std::string name() const
Returns the name.
bool isLicensed(DCA_MODULE_ID_TYPE id=0, bool force=false) const
Checks whether the given License is valid for the given module id.
static void PrintLicenseInfo(const License &aLicense)
Prints out the information about the provided License.
std::string ticket
The ticket as provided in the license.
This header includes all header files of the DCA Base Package.
Class that contains all details of a dca::VersionInfoResult object.
Encapsulates the init and deinit of the DCA API.
std::string product
The product code used with the license.
DCA_SIZE_TYPE size() const
Returns the number of VersionInfoResult objects in the container.
std::string logDir
the directory in which the DCA log file should be created
static void PrintUsage(const char *name)
Prints out the syntax of the sample.
std::string getLastMessage() const
Returns the last message received from our license server or if none available the last available mes...
size_t DCA_INDEX_TYPE
Type for index access (used for arrays and collections).
std::string component() const
size_t DCA_SIZE_TYPE
Type for size (used for size of array and collections).
std::string getTicket() const
Returns the ticket of the license as string.
#define DCA_BINDIR
DCA subdirectory of the DCA binaries.
std::string getSession() const
Returns the session of the license as string.
const std::string S_UsageString
Usage string, displayed if a parameter is missing.
This structure is used to initialize the DcaInstance.
static DcaInstance create(const InitData &initData)
Creates a DcaInstance, starts up the DCA API and initializes the required main module.
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.
License createLicense(const LicenseData &licData, const ProxySettings &proxySettings=ProxySettings(), LogLevel aLogLevel=LOG_Initial) const
Creates a License object using the given LicenseData.
int main(int argc, char *argv[])
The main routine.