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