All Handler classes are encapsulated into the OnixS::Mts::Cash::SDP namespace. Header files are collected in the master
"OnixS/MTS/Cash/SDP.h" header file.
The typical way of using the Handler is as follows:
The OnixS::Mts::Cash::SDP::Handler constructor accepts an instance of the OnixS::Mts::Cash::SDP::HandlerSettings class which defines values for various parameters that affect Handler's behavior. The section below describes the most important parameters.
By default,the Handler logs all important aspects of its activity while processing market data. Therefore, it must know where on local file system it can store this kind of information. The OnixS::Mts::Cash::SDP::HandlerSettings::logDirectory parameter value must be defined to point the Handler in which directory it can place its log files.
The Handler needs a license for successful execution. If the Handler is not able to find a valid License, it will throw an exception at the initialization stage.
The OnixS::Mts::Cash::SDP::HandlerSettings structure exposes the OnixS::Mts::Cash::SDP::HandlerSettings::licenseDirectory parameter which allows to instruct the Handler where to look for a valid license. By default, the Handler looks for a license in the current directory for the application which uses the Handler.
Following example demonstrates how to setup primary settings for the Handler:
Being C++ class library, the Handler uses exceptions to Cashrt about error occurred while performing certain action. For example, the Handler will raise regular exception to Cashrt about inability to find actual license for the product. However, the Handler processes market data asynchronously, therefore it is not able to Cashrt about any further errors since market data processing is started. For this reason, the Handler exposes the OnixS::Mts::Cash::SDP::ErrorListener interface and the OnixS::Mts::Cash::SDP::Handler::registerErrorListener member to be able to subscribe and handle errors.
Once instance of OnixS::Mts::Cash::SDP::ErrorListener is assigned to the Handler, it will invoke the OnixS::Mts::Cash::SDP::ErrorListener::onError member each time error occurs. The OnixS::Mts::Cash::SDP::ErrorListener::onError member has several incoming parameters one of which defines human-readable explanation (description) of the error.
Following sample demonstrates how to receive error notifications:
Miscellaneous non-critical issues may occur while the Handler is being executed. The Handler will handle such issues by itself, thus no special handling is required for such cases. However, sometimes it's reasonable to be notified about such events. For this reason, a handler exposes the OnixS::Mts::Cash::SDP::WarningListener class and will invoke its OnixS::Mts::Cash::SDP::WarningListener::onWarning member each time a non-critical issue will take place.
Once the Handler is started, it listens to a message from the Mts Cash/SDP message flow, processes it and invokes client code for further processing.
The Handler processes messages asynchronously and uses concept of events and event listeners to notify client code about a particular occasion like reception of record.
For each event like Error Occurred Handler provides an interface (C++ class with pure virtual members) like OnixS::Mts::Cash::SDP::ErrorListener. Client code must implement this interface (C++ class) to be able to handle events of a particular type. The Handler also exposes a member like OnixS::Mts::Cash::SDP::Handler::registerErrorListener which allows to associate an instance of the event handler with an appropriate event in bounds of a particular instance of the OnixS::Mts::Cash::SDP::Handler class.
Associating event listener with an instance of the OnixS::Mts::Cash::SDP::Handler class is also called subscribing to an event.