Miscelleneous C++ Utilities¶
The following C++ utilities are provided by the Core Component:
“ifw-core/utils/bat”: A class and tools to manage CII Configuration Service, instance and schema files and providing a basic schema for the common configuration for IFW applications.
“ifw-core/utils/base”: Constant definitions of common nature.
“ifw-core/utils/string”: Small tools to facilitate string manipulation.
“ifw-core/utils/conversion”: Tools to convert between various type representations.
“ifw-core/utils/system”: Contains small ‘system level’ tools, e.g. to for obtaining time stamps, obtaining information about the OS platform, generating unique IDs, generating random numbers, fail safe mutex semaphore, and more.
“ifw-core/utils/time”: Contains utilities to handle time related aspects, like generating ISO 8601 timestamps.
“ifw-core/utils/param”: Tools to handle parameters.
“ifw-core/utils/file”: Provides small tools for handling files, for instance a function to locate files in the ELT ICS directory structure. Also provides a parameter set class to handle parameter files, and a specialization for YAML.
Basic Application Tools - BAT¶
The bat
library provides some base definitions for C++ applications within the
IFW.
Base Configuration File¶
The bat module defines base configuration parameters for an IFW server application. This
is a configuration file (config/utils/bat/definitions.yaml
) that can be included in
other applications.
!cfg.typedef Timeout(uint32):
default: 5000 #timeout in milliseconds
min: 1
!cfg.typedef IfwServer:
!cfg.required server_id : !cfg.type:string
!cfg.required req_endpoint : !cfg.type:string
!cfg.required pub_endpoint : !cfg.type:string
!cfg.required db_endpoint : !cfg.type:string
!cfg.optional db_timeout : !cfg.type:Timeout
!cfg.required scxml : !cfg.type:string # State machine XML file used by the server
!cfg.required log_properties : !cfg.type:string
!cfg.optional req_timeout : !cfg.type:Timeout # Timeout for req/rep.
!cfg.optional mon_timeout : !cfg.type:Timeout # Timeout for monitoring blocking calls
!cfg.optional dictionaries : !cfg.type:vector_string # List of dictionaries
!cfg.optional oldb_prefix : !cfg.type:string # OLDB prefix
!cfg.optional fits_prefix : !cfg.type:string # FITS prefix for metadata header
Base Configuration Class¶
Namespace: “utils::bat”.
Library: “coreBat”.
Header file: “utils/bat/config.hpp”.
This is a class (utils::bat::Config) that provide few services that can be used by IFW servers like the handling of command line parameters or the loading and checking of the configuration files using CII config-ng library.
The basic schema for the configuration is found in file definitions.yaml. The supported command line parameters are:
Options:
-h [ --help ] Print help messages
-i [ --server-id ] arg Server ID
-l [ --log-level ] arg Log level: ERROR, INFO, DEBUG, TRACE
-p [ --log-prop-file ] arg Log property filename
-c [ --config ] arg Configuration filename
-r [ --req-endpoint ] arg Req/Rep endpoint (zpb.rr://<ipaddr>:<port>/)
-d [ --db-endpoint ] arg Redis DB endpoint (<ipaddr>:<port>)
Warning
The command line parameters override the same parameters that can be found in the configuration. This means that regardless what it is in the configuration, the command line parameters have precedence.
Miscelleneous C++ Tools¶
Module: “ifw-core/utils/base”¶
Namespace: “core::utils::base”.
Library: “coreUtilsBase”.
Header file: “ifw-core/utils/base/base.hpp”.
Provides various basic definitions of constants and a few convenience functions.
Module: “ifw-hl/core/utils/string”¶
Namespace: “core::utils::string”.
Library: “coreString”.
Header file: “core/utils/string/string.hpp”.
Provides small convenience tools for string manipulation.
Module: “ifw-core/utils/conversion”¶
Namespace: “core::utils::conversion”.
Library: “coreConversion”.
Header file: “core/utils/conversion/conversion.hpp”.
Provides utilites to convert between different data types.
Module: “ifw-core/system”¶
Namespace: “core::utils::system”.
Library: “coreSystem”.
Header file: “core/utils/system/system.hpp”.
Provides various system level utilities (functions) and a scope based mutex semaphore class.
Doxygen documentation:
Module: “ifw-core/utils/time”¶
Namespace: “core::utils::time”.
Library: “coreTime”.
Header file: “core/utils/time/time.hpp”.
Provides small convenience functions for dealing with time aspects, e.g. generating ISO 8601 time stamps.
Doxygen documentation:
Module: “ifw-core/param”¶
Namespace: “core::utils::param”.
Library: “coreParam”.
Header files:
“core/utils/param/Parameter.hpp”: Contains class to handle one parameter.
“core/utils/ParameterSet.hpp”: Contains class to handle a set of parameter class instances.
Provides two classes for handling parameter files in a generic way.
Note: This module is under evaluation. During the porting of ICS to CII, it will be evaluated whether to keep this.
Module: “ifw-core/utils/file”¶
Namespace: “core::utils::file”.
Library: “coreFile”.
Header files:
“core/utils/file/file.hpp”: Defines various constants to be used in the context of the ICS directory structure. Moreover, various utilities to handle files and filenames, e.g. a tool for locating files in the ICS directory structure.
“core/utils/file/ParameterFile.hpp”: Provides a class, “ParameterFile”, based on “core::param::ParameterSet” to handle parameter files in a simple ASCII format.
“core/utils/file/Yaml.hpp”: Provides a class, based on “core::utils::param::ParameterSet”, to handle YAML files in the ICS directory structure.
Note: It is under consideration to provide a class, which transparently can handle YAML and JSON files transparently. This will be assessed in connection with the porting to CII.