OnixS C++ FIX Engine  4.8.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 
28 
29 namespace OnixS {
30 namespace FIX {
31 ONIXS_FIXENGINE_API_DECL(class, IEngineListener);
32 ONIXS_FIXENGINE_API_DECL(class, ISessionReactor);
33 ONIXS_FIXENGINE_API_DECL(class, EngineSettings);
34 
35 typedef std::vector<OnixS::FIX::Dictionary> Dictionaries;
36 typedef std::vector<int> ListenPorts;
37 
38 /// FIX Engine.
40 {
41 public:
42  /// Initializes the FIX Engine.
43  ///
44  /// @param listenPort The engine listens on this port for incoming connections.
45  /// If '0' then only session-initiators can be created.
46  /// If '-1' then the telecommunication level is disabled and only message parsing/assembling can be used.
47  /// @param stack An instance of an externally managed reactor for acceptor sessions.
48  ///
49  /// @note This call is thread-safe.
50  static Engine * init(int listenPort = 0, ISessionReactor * stack = ONIXS_FIXENGINE_NULLPTR);
51 
52  /// Initializes the FIX Engine.
53  ///
54  /// @param configFile Configuration file.
55  /// @param stack An instance of an externally managed reactor for acceptor sessions.
56  ///
57  /// @note This call is thread-safe.
58  static Engine * init(const std::string & configFile, ISessionReactor * stack = ONIXS_FIXENGINE_NULLPTR);
59 
60  /// Initializes the FIX Engine.
61  ///
62  /// @param configuration Configuration string.
63  /// @param stack An instance of an externally managed reactor for acceptor sessions.
64  ///
65  /// @note This call is thread-safe.
66  static Engine * initFromString(const std::string & configuration, ISessionReactor * stack = ONIXS_FIXENGINE_NULLPTR);
67 
68  /// Initializes the FIX Engine.
69  ///
70  /// @param settings Engine settings.
71  /// @param stack An instance of an externally managed reactor for acceptor sessions.
72  ///
73  /// @note This call is thread-safe.
74  static Engine * init(const EngineSettings & settings, ISessionReactor * stack = ONIXS_FIXENGINE_NULLPTR);
75 
76  /// Logs the given user's message to FIX Engine's log file.
77  ///
78  /// @note This call is thread-safe.
79  void log(const std::string & message);
80 
81  /// Shutdowns the FIX Engine and releases all resources.
82  ///
83  /// @note This call is thread-safe.
84  static void shutdown();
85 
86  /// Returns the Engine instance.
87  ///
88  /// @throw OnixS::DomainException if the FIX Engine has not been initialized yet.
89  ///
90  /// @note This call is thread-safe.
91  static Engine * instance();
92 
93  /// Returns 'true' if the FIX Engine has been initialized, otherwise - 'false'.
94  ///
95  /// @note This call is thread-safe.
96  static bool initialized();
97 
98  /// Returns the listen port.
99  ///
100  /// The FIX Engine listens on this port for incoming connections.
101  int listenPort() const;
102 
103  /// Returns the Engine log directory.
104  ///
105  /// Inbound and outbound FIX messages, session's state data,
106  /// and the FIX Engine log file are stored in this directory.
107  const std::string & logDirectory() const;
108 
109  /// Returns Engine's license expiration date.
110  Timestamp licenseExpirationDate() const;
111 
112  /// Returns the array of loaded dictionaries.
113  Dictionaries dictionaries() const;
114 
115  /// Adds the session level dictionary(s) from the XML file(s) with the description of the FIX Dictionary(s).
116  /// @note More than one file could be specified. Symbol '|' is used as the file name delimiter.
117  /// @param dictionaryFile Specifies the path(s) to the XML file(s) with the description of the FIX Dictionary(s).
118  /// @throw OnixS::DomainException if there are standart dictionary(s) in the XML file(s).
119  ///
120  /// @note This call is thread-safe.
121  void addSessionDictionary(const std::string & dictionaryFile);
122 
123  /// Adds the session level dictionary(s) from the plain text string with the description of the FIX Dictionary(s).
124  /// @param dialectString Specifies the plain text string with the description of the FIX Dictionary(s).
125  /// @throw OnixS::DomainException if there are standart dictionary(s) in the dialect string.
126  ///
127  /// @note This call is thread-safe.
128  void addSessionDictionaryFromString(const std::string & dialectString);
129 
130  /// Adds the listen port(s) for incoming connections.
131  /// @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).
132  ///
133  /// @note This call is thread-safe.
134  void addListenPort(int port);
135  void addListenPorts(const ListenPorts & ports);
136 
137  /// Removes the listen port(s) for incoming connections.
138  /// @throw Exception if the telecommunication level is disabled (the Listen Port is -1 or 0).
139  ///
140  /// @note This call is thread-safe.
141  void removeListenPort(int port);
142  void removeListenPorts(const ListenPorts & ports);
143 
144  /// Adds the ssl listen port(s) for incoming ssl connections.
145  /// @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).
146  ///
147  /// @note This call is thread-safe.
148  void addSslListenPort(int port);
149  void addSslListenPorts(const ListenPorts & ports);
150 
151  /// Removes the ssl listen port(s) for incoming ssl connections.
152  /// @throw Exception if the telecommunication level is disabled (the Listen Port is -1 or 0).
153  ///
154  /// @note This call is thread-safe.
155  void removeSslListenPort(int port);
156  void removeSslListenPorts(const ListenPorts & ports);
157 
158  /// Registers the Engine listener.
159  /// @throw Exception if the listener is already registered.
160  ///
161  /// @note This call is thread-safe.
162  void registerListener(IEngineListener * listener);
163 
164  /// Un-registers the Engine listener.
165  ///
166  /// @note This call is thread-safe.
167  void unregisterListener();
168 
169  /// Performs the synchronization of the high-resolution internal time service with the system time on Windows OS.
170  /// On OS less than Windows 8 and Windows Server 2012, the internal high-resolution time service, is based on QueryPerformanceCounter API.
171  /// 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.
172  /// 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.
173  ///
174  /// @throw Exception if there is a session in non-disconnected state.
175  ///
176  /// @note This call is thread-safe.
177  /// @note The method should be called when all sessions are disconnected to avoid time resynchronization side effects.
178  void synchronizeHighResolutionTimeServiceWithSystemTime();
179 
180  /// Returns the current Engine-level settings.
181  const EngineSettings & settings() const;
182 
183  class Impl;
184 
185 private:
186  Engine();
187  ~Engine();
188 };
189 
190 }
191 }
Engine&#39;s Listener.
std::vector< OnixS::FIX::Dictionary > Dictionaries
Definition: Engine.h:35
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
std::vector< int > ListenPorts
Listen ports.
Definition: Engine.h:36
ONIXS_FIXENGINE_API_DECL(class, IEngineListener)
FIX Engine settings.
Session&#39;s network stack reactor interface.
FIX Engine.
Definition: Engine.h:39
Timestamps related functionality.
Definition: Timestamp.h:91