OnixS C++ FIX Engine  4.2.0
API Documentation
Engine.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
4 *
5 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
6 * and international copyright treaties.
7 *
8 * Access to and use of the software is governed by the terms of the applicable OnixS Software
9 * Services Agreement (the Agreement) and Customer end user license agreements granting
10 * a non-assignable, non-transferable and non-exclusive license to use the software
11 * for it's own data processing purposes under the terms defined in the Agreement.
12 *
13 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
14 * of this source code or associated reference material to any other location for further reproduction
15 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
16 *
17 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
18 * the terms of the Agreement is a violation of copyright law.
19 */
20 
21 #include <string>
22 #include <set>
23 #include <vector>
24 
27 
28 namespace OnixS {
29 namespace FIX {
30 ONIXS_FIXENGINE_API_DECL(class, IEngineListener);
31 ONIXS_FIXENGINE_API_DECL(class, EngineSettings);
32 
33 typedef std::vector<OnixS::FIX::Dictionary> Dictionaries;
34 typedef std::vector<int> ListenPorts;
35 
36 /// FIX Engine.
38 {
39 public:
40  /// Initializes the FIX Engine.
41  ///
42  /// @param listenPort The engine listens on this port for incoming connections.
43  /// If '0' then only session-initiators can be created.
44  /// If '-1' then the telecommunication level is disabled and only message parsing/assembling can be used.
45  ///
46  /// @note This call is thread-safe.
47  static Engine * init(int listenPort = 0);
48 
49  /// Initializes the FIX Engine.
50  ///
51  /// @param configFile Configuration file.
52  ///
53  /// @note This call is thread-safe.
54  static Engine * init(const std::string & configFile);
55 
56  /// Initializes the FIX Engine.
57  ///
58  /// @param configuration Configuration string.
59  ///
60  /// @note This call is thread-safe.
61  static Engine * initFromString(const std::string & configuration);
62 
63  /// Initializes the FIX Engine.
64  ///
65  /// @param settings Engine settings.
66  ///
67  /// @note This call is thread-safe.
68  static Engine * init(const EngineSettings & settings);
69 
70  /// Logs the given user's message to FIX Engine's log file.
71  ///
72  /// @note This call is thread-safe.
73  void log(const std::string & message);
74 
75  /// Shutdowns the FIX Engine and releases all resources.
76  ///
77  /// @note This call is thread-safe.
78  static void shutdown();
79 
80  /// Returns the Engine instance.
81  ///
82  /// @throw OnixS::DomainException if the FIX Engine has not been initialized yet.
83  ///
84  /// @note This call is thread-safe.
85  static Engine * instance();
86 
87  /// Returns 'true' if the FIX Engine has been initialized, otherwise - 'false'.
88  ///
89  /// @note This call is thread-safe.
90  static bool initialized();
91 
92  /// Returns the listen port.
93  ///
94  /// The FIX Engine listens on this port for incoming connections.
95  int listenPort() const;
96 
97  /// Returns the Engine log directory.
98  ///
99  /// Inbound and outbound FIX messages, session's state data,
100  /// and the FIX Engine log file are stored in this directory.
101  const std::string & logDirectory() const;
102 
103  /// Returns Engine's license expiration date.
104  Timestamp licenseExpirationDate() const;
105 
106  /// Returns the array of loaded dictionaries.
107  Dictionaries dictionaries() const;
108 
109  /// Adds the session level dictionary(s) from the XML file(s) with the description of the FIX Dictionary(s).
110  /// @note More than one file could be specified. Symbol '|' is used as the file name delimiter.
111  /// @param dictionaryFile Specifies the path(s) to the XML file(s) with the description of the FIX Dictionary(s).
112  /// @throw OnixS::DomainException if there are standart dictionary(s) in the XML file(s).
113  ///
114  /// @note This call is thread-safe.
115  void addSessionDictionary(const std::string & dictionaryFile);
116 
117  /// Adds the session level dictionary(s) from the plain text string with the description of the FIX Dictionary(s).
118  /// @param dialectString Specifies the plain text string with the description of the FIX Dictionary(s).
119  /// @throw OnixS::DomainException if there are standart dictionary(s) in the dialect string.
120  ///
121  /// @note This call is thread-safe.
122  void addSessionDictionaryFromString(const std::string & dialectString);
123 
124  /// Adds the listen port(s) for incoming connections.
125  /// @throw Exception if the FIX Engine cannot start listening on the specified port(s) or the telecommunication level is disabled (the Listen Port is -1 or 0).
126  ///
127  /// @note This call is thread-safe.
128  void addListenPort(int port);
129  void addListenPorts(const ListenPorts & ports);
130 
131  /// Removes the listen port(s) for incoming connections.
132  /// @throw Exception if the telecommunication level is disabled (the Listen Port is -1 or 0).
133  ///
134  /// @note This call is thread-safe.
135  void removeListenPort(int port);
136  void removeListenPorts(const ListenPorts & ports);
137 
138  /// Adds the ssl listen port(s) for incoming ssl connections.
139  /// @throw Exception if the FIX Engine cannot start listening on the specified ssl port(s) or the telecommunication level is disabled (the Listen Port is -1 or 0).
140  ///
141  /// @note This call is thread-safe.
142  void addSslListenPort(int port);
143  void addSslListenPorts(const ListenPorts & ports);
144 
145  /// Removes the ssl listen port(s) for incoming ssl connections.
146  /// @throw Exception if the telecommunication level is disabled (the Listen Port is -1 or 0).
147  ///
148  /// @note This call is thread-safe.
149  void removeSslListenPort(int port);
150  void removeSslListenPorts(const ListenPorts & ports);
151 
152  /// Registers the Engine listener.
153  /// @throw Exception if the listener is already registered.
154  ///
155  /// @note This call is thread-safe.
156  void registerListener(IEngineListener * listener);
157 
158  /// Un-registers the Engine listener.
159  ///
160  /// @note This call is thread-safe.
161  void unregisterListener();
162 
163  /// Performs the synchronization of the high-resolution internal time service with the system time on Windows OS.
164  /// On OS less than Windows 8 and Windows Server 2012, the internal high-resolution time service, is based on QueryPerformanceCounter API.
165  /// This service is synchronized with the system time only once when an application is started, as a result, a time difference can occur in time.
166  /// Therefore, for such old windows versions, it makes sense to synchronize the internal time service periodically (e.g. once per day) with the system time to avoid time drift issues.
167  ///
168  /// @throw Exception if there is a session in non-disconnected state.
169  ///
170  /// @note This call is thread-safe.
171  /// @note The method should be called when all sessions are disconnected to avoid time resynchronization side effects.
172  void synchronizeHighResolutionTimeServiceWithSystemTime();
173 
174  class Impl;
175 
176 private:
177  Engine();
178  ~Engine();
179 };
180 
181 }
182 }
std::vector< int > ListenPorts
Listen ports.
Definition: Engine.h:34
std::vector< OnixS::FIX::Dictionary > Dictionaries
Definition: Engine.h:33
ONIXS_FIXENGINE_API_DECL(class, IEngineListener)
FIX Engine settings.
Timestamps related functionality.
Definition: Timestamp.h:91
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
FIX Engine.
Definition: Engine.h:37
Engine&#39;s Listener.