dxFeed Graal CXX API v4.2.0
Loading...
Searching...
No Matches
SymbolWrapper.hpp
1// Copyright (c) 2025 Devexperts LLC.
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include "../internal/Conf.hpp"
7
9
10#include <concepts>
11#include <cstdint>
12#include <memory>
13#include <optional>
14#include <utility>
15#include <variant>
16
17#include "../api/osub/IndexedEventSubscriptionSymbol.hpp"
18#include "../api/osub/TimeSeriesSubscriptionSymbol.hpp"
19#include "../api/osub/WildcardSymbol.hpp"
20#include "../event/candle/CandleSymbol.hpp"
21#include "../internal/Common.hpp"
22#include "StringSymbol.hpp"
23
25
26/**
27 * A concept describing a symbol that can be wrapped.
28 *
29 * @tparam T Probable symbol type
30 */
31template <typename T>
32concept ConvertibleToSymbolWrapper =
33 ConvertibleToStringSymbol<std::decay_t<T>> || std::is_same_v<std::decay_t<T>, WildcardSymbol> ||
34 std::is_same_v<std::decay_t<T>, IndexedEventSubscriptionSymbol> ||
35 std::is_same_v<std::decay_t<T>, TimeSeriesSubscriptionSymbol> || std::is_same_v<std::decay_t<T>, CandleSymbol>;
36
37/**
38 * A concept that defines a collection of wrapped or wrapping symbols.
39 *
40 * @tparam Collection The collection type
41 */
42template <typename Collection>
43concept ConvertibleToSymbolWrapperCollection =
44 requires(Collection c) {
45 std::begin(c);
46 std::end(c);
47 } &&
48 (
49 requires(Collection c) {
50 { *std::begin(c) } -> dxfcpp::ConvertibleTo<SymbolWrapper>;
51 } ||
52 requires(Collection c) {
53 { *std::begin(c) } -> ConvertibleToSymbolWrapper;
54 });
55
56/**
57 * A helper wrapper class needed to pass heterogeneous symbols using a container and convert them to internal Graal
58 * representation.
59 */
60struct DXFCPP_EXPORT SymbolWrapper final {
61 using DataType = typename std::variant<WildcardSymbol, StringSymbol, IndexedEventSubscriptionSymbol,
62 TimeSeriesSubscriptionSymbol, CandleSymbol>;
63
64 class DXFCPP_EXPORT SymbolListUtils final {
65 static std::ptrdiff_t calculateGraalListSize(std::ptrdiff_t initSize) noexcept;
66 static void *newGraalList(std::ptrdiff_t size);
67 static bool setGraalListElement(void *graalList, std::ptrdiff_t elementIdx, void *element) noexcept;
68 static bool freeGraalListElements(void *graalList, std::ptrdiff_t count);
69
70 public:
71 template <typename SymbolIt> static void *toGraalList(SymbolIt begin, SymbolIt end) {
72 if constexpr (Debugger::isDebug) {
73 Debugger::debug("SymbolWrapper::toGraalList(symbols = " + elementsToString(begin, end) + ")");
74 }
75
76 auto size = calculateGraalListSize(std::distance(begin, end));
77
78 // Zero size is needed, for example, to clear the list of symbols.
79 auto *list = newGraalList(size);
80
81 if (!list || size == 0) {
82 return list;
83 }
84
85 std::ptrdiff_t elementIdx = 0;
86 bool needToFree = false;
87
88 for (auto it = begin; it != end && elementIdx < size; it++, elementIdx++) {
89 if constexpr (requires { it->toGraal(); }) {
90 needToFree = setGraalListElement(list, elementIdx, it->toGraal()) == false;
91 } else if constexpr (std::is_convertible_v<decltype(*it), SymbolWrapper> ||
92 dxfcpp::ConvertibleToSymbolWrapper<decltype(*it)>) {
93 needToFree = setGraalListElement(list, elementIdx, SymbolWrapper(*it).toGraal()) == false;
94 }
95
96 if (needToFree) {
97 break;
98 }
99 }
100
101 if (needToFree) {
102 freeGraalListElements(list, elementIdx);
103
104 return nullptr;
105 }
106
107 return list;
108 }
109
110 template <ConvertibleToSymbolWrapperCollection SymbolsCollection>
111 static void *toGraalList(const SymbolsCollection &collection) {
112 return SymbolListUtils::toGraalList(std::begin(collection), std::end(collection));
113 }
114
115 static void *toGraalList(std::initializer_list<SymbolWrapper> collection) {
116 return SymbolListUtils::toGraalList(collection.begin(), collection.end());
117 }
118
119 static void freeGraalList(void *graalList);
120
121 template <typename SymbolIt>
122 static std::unique_ptr<void, decltype(&freeGraalList)> toGraalListUnique(SymbolIt begin, SymbolIt end) {
123 return {toGraalList(begin, end), freeGraalList};
124 }
125
126 template <ConvertibleToSymbolWrapperCollection SymbolsCollection>
127 static std::unique_ptr<void, decltype(&freeGraalList)> toGraalListUnique(const SymbolsCollection &collection) {
128 return {toGraalList(collection), freeGraalList};
129 }
130
131 static std::unique_ptr<void, decltype(&freeGraalList)>
132 toGraalListUnique(std::initializer_list<SymbolWrapper> collection) {
133 return {toGraalList(collection), freeGraalList};
134 }
135
136 static std::vector<SymbolWrapper> fromGraalList(void *graalList);
137 };
138
139 private:
140 DataType data_;
141
142 public:
143 SymbolWrapper(const SymbolWrapper &) noexcept = default;
144 SymbolWrapper(SymbolWrapper &&) noexcept = default;
145 SymbolWrapper &operator=(const SymbolWrapper &) noexcept = default;
146 SymbolWrapper &operator=(SymbolWrapper &&) noexcept = default;
147 SymbolWrapper() noexcept = default;
148 ~SymbolWrapper() noexcept = default;
149
150 /**
151 * Constructor for any wrapped symbol.
152 * Must be implicit to wrap symbols passed to collection or container
153 *
154 * @tparam Symbol The symbol type
155 * @param symbol The symbol
156 */
157 template <ConvertibleToStringSymbol Symbol>
158 SymbolWrapper(Symbol &&symbol) noexcept : SymbolWrapper(StringSymbol(std::forward<Symbol>(symbol))) {
159 if constexpr (Debugger::isDebug) {
160 // Could be "perfectly" moved, so it won't show up in the logs
161 Debugger::debug("SymbolWrapper(symbol = " + toStringAny(symbol) + ")");
162 }
163 }
164
165 /**
166 * Constructor for any wrapped string symbol.
167 * Must be implicit to wrap symbols passed to collection or container
168 *
169 * @param stringSymbol The wrapped string (std::string, std::string_view, const char*) symbol
170 */
171 SymbolWrapper(const StringSymbol &stringSymbol) noexcept {
172 if constexpr (Debugger::isDebug) {
173 Debugger::debug("SymbolWrapper(stringSymbol = " + toStringAny(stringSymbol) + ")");
174 }
175
176 data_ = stringSymbol;
177 }
178
179 /**
180 * Constructor for any wrapped wildcard (*) symbol.
181 *
182 * @param wildcardSymbol The wrapped wildcard symbol
183 */
184 SymbolWrapper(const WildcardSymbol &wildcardSymbol) noexcept {
185 if constexpr (Debugger::isDebug) {
186 Debugger::debug("SymbolWrapper(wildcardSymbol = " + toStringAny(wildcardSymbol) + ")");
187 }
188
189 data_ = wildcardSymbol;
190 }
191
192 /**
193 * Constructor for IndexedEventSubscriptionSymbol.
194 *
195 * @param indexedEventSubscriptionSymbol The IndexedEventSubscriptionSymbol
196 */
197 SymbolWrapper(const IndexedEventSubscriptionSymbol &indexedEventSubscriptionSymbol) noexcept {
198 if constexpr (Debugger::isDebug) {
199 Debugger::debug(
200 "SymbolWrapper(indexedEventSubscriptionSymbol = " + toStringAny(indexedEventSubscriptionSymbol) + ")");
201 }
202
203 data_ = indexedEventSubscriptionSymbol;
204 }
205
206 /**
207 * Constructor for TimeSeriesSubscriptionSymbol.
208 *
209 * @param timeSeriesSubscriptionSymbol The TimeSeriesSubscriptionSymbol
210 */
211 SymbolWrapper(const TimeSeriesSubscriptionSymbol &timeSeriesSubscriptionSymbol) noexcept {
212 if constexpr (Debugger::isDebug) {
213 Debugger::debug(
214 "SymbolWrapper(timeSeriesSubscriptionSymbol = " + toStringAny(timeSeriesSubscriptionSymbol) + ")");
215 }
216
217 data_ = timeSeriesSubscriptionSymbol;
218 }
219
220 /**
221 * Constructor for CandleSymbol.
222 *
223 * @param candleSymbol The CandleSymbol
224 */
225 SymbolWrapper(const CandleSymbol &candleSymbol) noexcept {
226 if constexpr (Debugger::isDebug) {
227 Debugger::debug("SymbolWrapper(candleSymbol = " + toStringAny(candleSymbol) + ")");
228 }
229
230 data_ = candleSymbol;
231 }
232
233 /**
234 * Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
235 *
236 * @param graalNative The pointer to the dxFeed Graal SDK structure.
237 * @throws InvalidArgumentException
238 */
239 static void freeGraal(void *graalNative);
240
241 /**
242 * Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
243 *
244 * @param graalNative The pointer to the dxFeed Graal SDK structure.
245 * @return The object of current type.
246 * @throws InvalidArgumentException
247 * @throws RuntimeException if symbol type is unknown
248 */
249 static SymbolWrapper fromGraal(void *graalNative);
250
251 /**
252 * Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
253 * Fills the dxFeed Graal SDK structure's fields by the data of the current entity (recursively if necessary).
254 * Returns the pointer to the filled structure.
255 *
256 * @return The pointer to the filled dxFeed Graal SDK structure
257 */
258 void *toGraal() const noexcept {
259 if constexpr (Debugger::isDebug) {
260 Debugger::debug("SymbolWrapper::toGraal()");
261 }
262
263 return std::visit(
264 [](const auto &symbol) {
265 return symbol.toGraal();
266 },
267 data_);
268 }
269
270 /**
271 * Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
272 * Fills the dxFeed Graal SDK structure's fields by the data of the current entity (recursively if necessary).
273 * Returns the pointer to the filled structure.
274 *
275 * @return The smart unique pointer to the filled dxFeed Graal SDK structure
276 */
277 std::unique_ptr<void, decltype(&SymbolWrapper::freeGraal)> toGraalUnique() const noexcept {
278 return {toGraal(), SymbolWrapper::freeGraal};
279 }
280
281 /**
282 * Returns a string representation of the current object.
283 *
284 * @return a string representation
285 */
286 std::string toString() const {
287 return "SymbolWrapper{" +
288 std::visit(
289 [](const auto &symbol) {
290 return toStringAny(symbol);
291 },
292 data_) +
293 "}";
294 }
295
296 /**
297 * Returns a string representation of the underlying object.
298 *
299 * @return a string representation of the underlying object.
300 */
301 std::string toStringUnderlying() const {
302 return std::visit(
303 [](const auto &symbol) {
304 return toStringAny(symbol);
305 },
306 data_);
307 }
308
309 /**
310 * @return `true` if current SymbolWrapper holds a StringSymbol.
311 */
312 bool isStringSymbol() const noexcept {
313 return std::holds_alternative<StringSymbol>(data_);
314 }
315
316 /**
317 * @return String representation of StringSymbol or an empty string.
318 */
319 std::string asStringSymbol() const noexcept {
320 return isStringSymbol() ? std::get<StringSymbol>(data_).getData() : String::EMPTY;
321 }
322
323 /**
324 * @return `true` if current SymbolWrapper holds a WildcardSymbol.
325 */
326 bool isWildcardSymbol() const noexcept {
327 return std::holds_alternative<WildcardSymbol>(data_);
328 }
329
330 /**
331 * @return WildcardSymbol (optional) or std::nullopt if current SymbolWrapper doesn't hold WildcardSymbol.
332 */
333 std::optional<WildcardSymbol> asWildcardSymbol() const noexcept {
334 return isWildcardSymbol() ? std::make_optional(WildcardSymbol::ALL) : std::nullopt;
335 }
336
337 /**
338 * @return `true` if current SymbolWrapper holds a IndexedEventSubscriptionSymbol.
339 */
340 bool isIndexedEventSubscriptionSymbol() const noexcept {
341 return std::holds_alternative<IndexedEventSubscriptionSymbol>(data_);
342 }
343
344 /**
345 * @return IndexedEventSubscriptionSymbol (optional) or std::nullopt if current SymbolWrapper doesn't hold
346 * IndexedEventSubscriptionSymbol.
347 */
349 return isIndexedEventSubscriptionSymbol()
350 ? std::make_optional<IndexedEventSubscriptionSymbol>(std::get<IndexedEventSubscriptionSymbol>(data_))
351 : std::nullopt;
352 }
353
354 /**
355 * @return `true` if current SymbolWrapper holds a TimeSeriesSubscriptionSymbol.
356 */
357 bool isTimeSeriesSubscriptionSymbol() const noexcept {
358 return std::holds_alternative<TimeSeriesSubscriptionSymbol>(data_);
359 }
360
361 /**
362 * @return TimeSeriesSubscriptionSymbol (optional) or std::nullopt if current SymbolWrapper doesn't hold
363 * TimeSeriesSubscriptionSymbol.
364 */
365 std::optional<TimeSeriesSubscriptionSymbol> asTimeSeriesSubscriptionSymbol() const noexcept {
366 return isTimeSeriesSubscriptionSymbol()
367 ? std::make_optional<TimeSeriesSubscriptionSymbol>(std::get<TimeSeriesSubscriptionSymbol>(data_))
368 : std::nullopt;
369 }
370
371 /**
372 * @return `true` if current SymbolWrapper holds a CandleSymbol.
373 */
374 bool isCandleSymbol() const noexcept {
375 return std::holds_alternative<CandleSymbol>(data_);
376 }
377
378 /**
379 * @return CandleSymbol (optional) or std::nullopt if current SymbolWrapper doesn't hold
380 * CandleSymbol.
381 */
382 std::optional<CandleSymbol> asCandleSymbol() const noexcept {
383 return isCandleSymbol() ? std::make_optional<CandleSymbol>(std::get<CandleSymbol>(data_)) : std::nullopt;
384 }
385
386 /**
387 * @return The internal data.
388 */
389 const DataType &getData() const noexcept {
390 return data_;
391 }
392
393 bool operator==(const SymbolWrapper &symbolWrapper) const {
394 return getData() == symbolWrapper.getData();
395 }
396
397 auto operator<(const SymbolWrapper &symbolWrapper) const {
398 return getData() < symbolWrapper.getData();
399 }
400
401 using GraalPtr = std::unique_ptr<void, decltype(&SymbolWrapper::freeGraal)>;
402
403 friend std::ostream &operator<<(std::ostream &os, const SymbolWrapper &symbolWrapper) {
404 return os << symbolWrapper.toStringUnderlying();
405 }
406};
407
408inline namespace literals {
409
410/**
411 * String literal that helps to construct SymbolWrapper from a char array.
412 *
413 * @param string The char array
414 * @param length Tha char array's length
415 * @return Wrapped string view built on char array
416 */
417inline SymbolWrapper operator""_sw(const char *string, size_t length) noexcept {
418 return {std::string_view{string, length}};
419}
420
421} // namespace literals
422
424
425template <> struct std::hash<dxfcpp::SymbolWrapper> {
426 std::size_t operator()(const dxfcpp::SymbolWrapper &symbolWrapper) const noexcept {
427 return std::hash<dxfcpp::SymbolWrapper::DataType>{}(symbolWrapper.getData());
428 }
429};
430
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:22
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:70
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:67
#define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:38
#define DXFCXX_DISABLE_GCC_WARNINGS_POP()
Definition Conf.hpp:40
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:21
#define DXFCPP_TRACE_ISOLATES
Definition Debug.hpp:19
#define DXFCPP_DEBUG
Definition Debug.hpp:15
#define DXFCPP_TRACE_LISTS
Definition Debug.hpp:22
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builder_t builder, const dxfc_dxendpoint_property_t **properties, size_t size)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.cpp:700
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:943
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1133
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_builder_t builder, const char *key, DXFC_OUT int *supports)
Checks if a property is supported.
Definition DXEndpoint.cpp:727
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Adds listener that is notified about changes in state property.
Definition DXEndpoint.cpp:1079
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:994
#define DXFCPP_EXPORT
Definition api.h:35
void * dxfc_dxendpoint_builder_t
The dxFeed endpoint's builder handle.
Definition api.h:207
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t endpoint)
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:892
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint)
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:1045
dxfc_dxendpoint_state_t
Represents the current state of endpoint.
Definition api.h:149
@ DXFC_DXENDPOINT_STATE_CLOSED
Endpoint was closed.
Definition api.h:169
@ DXFC_DXENDPOINT_STATE_NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition api.h:153
@ DXFC_DXENDPOINT_STATE_CONNECTING
The connect function was called to establish connection to remove endpoint, but connection is not act...
Definition api.h:159
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to remote endpoint is established.
Definition api.h:164
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of dxFeed endpoint with a FEED role.
Definition DXEndpoint.cpp:785
#define DXFC_OUT
Definition api.h:17
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_state_t *state)
Returns the state of this endpoint.
Definition DXEndpoint.cpp:1062
void * dxfc_dxendpoint_t
The dxFeed endpoint handle.
Definition api.h:198
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_t builder, const char *key, const char *value)
Sets the specified property.
Definition DXEndpoint.cpp:683
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:773
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:960
dxfc_error_code_t
List of error codes.
Definition api.h:49
@ DXFC_EC_ERROR
The error returned if the current operation cannot be completed.
Definition api.h:60
@ DXFC_EC_SUCCESS
OK.
Definition api.h:53
@ DXFC_EC_G_ERR
dxFeed Graal Native API error.
Definition api.h:57
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Removes listener that is notified about changes in state property.
Definition DXEndpoint.cpp:1105
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builder, const char *name)
Changes name that is used to distinguish multiple endpoints in the same process (GraalVM Isolate) in ...
Definition DXEndpoint.cpp:667
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value)
Sets the system property indicated by the specified key.
Definition System.cpp:68
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Builds the new dxFeed endpoint instance.
Definition DXEndpoint.cpp:744
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1128
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint)
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:1028
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:875
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder)
Creates new dxFeed endpoint's builder instance.
Definition DXEndpoint.cpp:634
void(* dxfc_dxendpoint_state_change_listener)(dxfc_dxendpoint_state_t old_state, dxfc_dxendpoint_state_t new_state, void *user_data)
The endpoint current state change listener.
Definition api.h:178
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint)
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:977
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_role(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_role_t *role)
Returns the role of this endpoint.
Definition DXEndpoint.cpp:909
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:926
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size)
Gets the system property indicated by the specified key.
dxfc_dxendpoint_role_t
Represents the role of endpoint that was specified during its creation.
Definition api.h:89
@ DXFC_DXENDPOINT_ROLE_PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition api.h:127
@ DXFC_DXENDPOINT_ROLE_STREAM_FEED
STREAM_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED and also connects to the remote data fee...
Definition api.h:116
@ DXFC_DXENDPOINT_ROLE_FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition api.h:99
@ DXFC_DXENDPOINT_ROLE_STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remot...
Definition api.h:136
@ DXFC_DXENDPOINT_ROLE_LOCAL_HUB
LOCAL_HUB endpoint is a local hub without ability to establish network connections.
Definition api.h:143
@ DXFC_DXENDPOINT_ROLE_ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED, but it is designed to be used with d...
Definition api.h:107
void * dxfc_dxpublisher_t
The dxFeed publisher handle.
Definition api.h:217
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:830
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:807
void * dxfc_dxfeed_t
The dxFeed handle.
Definition api.h:212
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t builder, dxfc_dxendpoint_role_t role)
Sets role for the created dxFeed endpoint.
Definition DXEndpoint.cpp:650
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:852
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1138
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:1011
The enumeration type that provides additional information about the dxFeed Graal C++-API event type.
Definition EventTypeEnum.hpp:21
bool isTimeSeries() const noexcept
Definition EventTypeEnum.hpp:174
const std::string & getClassName() const &noexcept
Definition EventTypeEnum.hpp:117
bool isLasting() const noexcept
Definition EventTypeEnum.hpp:160
bool isOnlyIndexed() const noexcept
Definition EventTypeEnum.hpp:181
bool isIndexed() const noexcept
Definition EventTypeEnum.hpp:167
std::uint32_t getId() const noexcept
Definition EventTypeEnum.hpp:103
bool isMarket() const noexcept
Definition EventTypeEnum.hpp:188
const std::string & getName() const &noexcept
Definition EventTypeEnum.hpp:110
Source identifier for IndexedEvent.
Definition IndexedEventSource.hpp:22
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition IndexedEventSource.cpp:21
const std::string & name() const noexcept
Returns the string representation of the object.
Definition IndexedEventSource.hpp:90
static IndexedEventSource fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition IndexedEventSource.cpp:32
static const IndexedEventSource DEFAULT
The default source with zero identifier for all events that do not support multiple sources.
Definition IndexedEventSource.hpp:13
std::int32_t id() const noexcept
Returns the source identifier.
Definition IndexedEventSource.hpp:81
virtual void * toGraal() const
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition IndexedEventSource.cpp:15
std::string toString() const
Returns the string representation of the object.
Definition IndexedEventSource.hpp:99
IndexedEventSource(std::int32_t id, std::string name) noexcept
Creates the new IndexedEvent's source by id and name.
Definition IndexedEventSource.hpp:73
Represents subscription to a specific source of indexed events.
Definition IndexedEventSubscriptionSymbol.hpp:40
static const OrderSource GLBX
CME Globex.
Definition OrderSource.hpp:307
static const OrderSource smfe
Small Exchange.
Definition OrderSource.hpp:371
static const OrderSource bzx
Bats BZX Exchange.
Definition OrderSource.hpp:235
static const OrderSource DEX
Direct-Edge EDGX Exchange.
Definition OrderSource.hpp:202
static const OrderSource NTV
NASDAQ Total View.
Definition OrderSource.hpp:138
static const OrderSource AGGREGATE_ASK
Ask side of an aggregate order book (futures depth and NASDAQ Level II).
Definition OrderSource.hpp:123
static const OrderSource & valueOf(std::int32_t sourceId)
Returns order source for the specified source identifier.
Definition OrderSource.cpp:178
static const OrderSource ESPD
NASDAQ eSpeed.
Definition OrderSource.hpp:162
static const OrderSource CFE
CBOE Futures Exchange.
Definition OrderSource.hpp:347
static const OrderSource ntv
NASDAQ Total View.
Definition OrderSource.hpp:146
static const OrderSource ICE
Intercontinental Exchange.
Definition OrderSource.hpp:178
static const OrderSource BZX
Bats BZX Exchange.
Definition OrderSource.hpp:227
static const OrderSource C2OX
CBOE Options C2 Exchange.
Definition OrderSource.hpp:355
static const OrderSource REGIONAL_ASK
Ask side of a regional Quote.
Definition OrderSource.hpp:111
static const OrderSource REGIONAL_BID
Bid side of a regional Quote.
Definition OrderSource.hpp:104
static const OrderSource ABE
ABE (abe.io) exchange.
Definition OrderSource.hpp:291
static const OrderSource CEUX
Bats Europe DXE Exchange.
Definition OrderSource.hpp:259
static const OrderSource OCEA
Blue Ocean Technologies Alternative Trading System.
Definition OrderSource.hpp:403
static const OrderSource AGGREGATE_BID
Bid side of an aggregate order book (futures depth and NASDAQ Level II).
Definition OrderSource.hpp:117
static const OrderSource BXTR
Bats Europe TRF.
Definition OrderSource.hpp:267
static const OrderSource dex
Direct-Edge EDGX Exchange.
Definition OrderSource.hpp:211
static const OrderSource cedx
Cboe European Derivatives.
Definition OrderSource.hpp:444
static const OrderSource COMPOSITE_ASK
Ask side of a composite Quote.
Definition OrderSource.hpp:97
static const OrderSource XNFI
NASDAQ Fixed Income.
Definition OrderSource.hpp:170
static const OrderSource iex
Investors exchange.
Definition OrderSource.hpp:379
static const OrderSource xeur
Eurex Exchange.
Definition OrderSource.hpp:339
static const OrderSource CEDX
Cboe European Derivatives.
Definition OrderSource.hpp:436
static const OrderSource ISE
International Securities Exchange.
Definition OrderSource.hpp:186
static const OrderSource DEA
Direct-Edge EDGA Exchange.
Definition OrderSource.hpp:194
static const OrderSource glbx
CME Globex.
Definition OrderSource.hpp:315
static const OrderSource BI20
Borsa Istanbul Exchange.
Definition OrderSource.hpp:283
static const OrderSource BYX
Bats BYX Exchange.
Definition OrderSource.hpp:219
static const OrderSource FAIR
FAIR (FairX) exchange.
Definition OrderSource.hpp:299
static const OrderSource BATE
Bats Europe BXE Exchange.
Definition OrderSource.hpp:243
static const OrderSource pink
Pink Sheets.
Definition OrderSource.hpp:412
static const OrderSource DEFAULT
Default source for publishing custom order books.
Definition OrderSource.hpp:130
static const OrderSource NFX
NASDAQ Futures Exchange.
Definition OrderSource.hpp:154
static const OrderSource memx
Members Exchange.
Definition OrderSource.hpp:395
static bool isSpecialSourceId(std::int32_t sourceId) noexcept
Determines whether specified source identifier refers to special order source.
Definition OrderSource.cpp:174
static const OrderSource IST
Borsa Istanbul Exchange.
Definition OrderSource.hpp:275
static const OrderSource ARCA
NYSE Arca traded securities.
Definition OrderSource.hpp:420
static const OrderSource CHIX
Bats Europe CXE Exchange.
Definition OrderSource.hpp:251
static const OrderSource & valueOf(const std::string &name)
Returns order source for the specified source name.
Definition OrderSource.cpp:192
static const OrderSource ERIS
Eris Exchange group of companies.
Definition OrderSource.hpp:323
static const OrderSource XEUR
Eurex Exchange.
Definition OrderSource.hpp:331
static const OrderSource MEMX
Members Exchange.
Definition OrderSource.hpp:387
static const OrderSource COMPOSITE_BID
Bid side of a composite Quote.
Definition OrderSource.hpp:90
static const OrderSource arca
NYSE Arca traded securities.
Definition OrderSource.hpp:428
static const OrderSource SMFE
Small Exchange.
Definition OrderSource.hpp:363
Symbol that should be used with DXFeedSubscription class to subscribe for Candle events.
Definition CandleSymbol.hpp:83
Base abstract class for all dxFeed C++ API entities.
Definition Entity.hpp:13
virtual ~Entity() noexcept=default
The default virtual d-tor.
bool isOrderSource() const noexcept
Definition EventSourceWrapper.hpp:242
std::unique_ptr< void, decltype(&EventSourceWrapper::freeGraal)> toGraalUnique() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition EventSourceWrapper.hpp:200
std::string toStringUnderlying() const
Returns a string representation of the underlying object.
Definition EventSourceWrapper.hpp:224
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition EventSourceWrapper.hpp:163
std::string toString() const
Returns a string representation of the current object.
Definition EventSourceWrapper.hpp:209
void * toGraal() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition EventSourceWrapper.hpp:184
static EventSourceWrapper fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition EventSourceWrapper.cpp:40
const DataType & getData() const noexcept
Definition EventSourceWrapper.hpp:266
EventSourceWrapper(const IndexedEventSource &data) noexcept
Constructs a wrapper from IndexedEventSource.
Definition EventSourceWrapper.hpp:145
bool isIndexedEventSource() const noexcept
Definition EventSourceWrapper.hpp:235
std::optional< IndexedEventSource > asIndexedEventSource() const noexcept
Definition EventSourceWrapper.hpp:250
std::optional< OrderSource > asOrderSource() const noexcept
Definition EventSourceWrapper.hpp:259
EventSourceWrapper(const OrderSource &data) noexcept
Constructs a wrapper from OrderSource.
Definition EventSourceWrapper.hpp:153
Event type parametrized by a symbol.
Definition EventType.hpp:116
virtual const std::optional< Symbol > & getEventSymbolOpt() const &noexcept=0
Returns event symbol that identifies this event type in subscription.
virtual void setEventSymbol(const Symbol &eventSymbol) noexcept=0
Changes event symbol that identifies this event type in subscription.
virtual const Symbol & getEventSymbol() const &noexcept=0
Returns event symbol that identifies this event type in subscription.
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:31
std::string toString() const override
Returns a string representation of the current object.
Definition EventType.hpp:89
virtual std::int64_t getEventTime() const noexcept
Returns time when event was created or zero when time is not available.
Definition EventType.hpp:54
virtual void assign(std::shared_ptr< EventType > event)
Replaces the contents of the event.
Definition EventType.hpp:84
virtual void * toGraal() const =0
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
virtual void setEventTime(std::int64_t) noexcept
Changes event creation time.
Definition EventType.hpp:66
The wrapper over CEntryPointErrorsEnum, the error code returned by GraalVM.
Definition GraalException.hpp:22
GraalException(CEntryPointErrorsEnum entryPointErrorsEnum)
Constructs an exception.
Definition GraalException.cpp:10
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:123
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:157
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:209
std::size_t operator+=(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:198
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:147
Handler(std::size_t mainFuturesSize=MAIN_FUTURES_DEFAULT_SIZE) noexcept
Creates the new handler by specified size of circular buffer of futures.
Definition Handler.hpp:85
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:237
std::size_t addLowPriority(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group) It will be called after the "main" liste...
Definition Handler.hpp:178
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:218
A helper class needed to construct smart pointers to objects, and does not allow explicit constructio...
Definition SharedEntity.hpp:89
static auto createShared(Args &&...args)
Creates smart pointer to object.
Definition SharedEntity.hpp:103
A runtime axception with stacktrace.
Definition RuntimeException.hpp:20
RuntimeException(const StringLikeWrapper &message, const StringLikeWrapper &additionalStackTrace="")
Constructs a runtime exception.
Definition RuntimeException.cpp:71
const std::string & getStackTrace() const &
Definition RuntimeException.cpp:85
Base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:21
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:78
std::shared_ptr< T > sharedAs() const noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:69
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:56
bool is() const noexcept
Checks that pointer to the current type could be converted to type T* In other words: whether type T ...
Definition SharedEntity.hpp:35
std::size_t operator+=(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:378
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:398
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:316
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:327
SimpleHandler() noexcept=default
Creates the new handler.
std::size_t addLowPriority(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group) It will be called after the "main" liste...
Definition Handler.hpp:358
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:417
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:389
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:337
Universal functional object that allows searching std::unordered_map for string-like keys.
Definition Common.hpp:911
A simple wrapper around strings or something similar to strings to reduce the amount of code for meth...
Definition Common.hpp:794
std::optional< CandleSymbol > asCandleSymbol() const noexcept
Definition SymbolWrapper.hpp:382
SymbolWrapper(Symbol &&symbol) noexcept
Constructor for any wrapped symbol.
Definition SymbolWrapper.hpp:158
bool isIndexedEventSubscriptionSymbol() const noexcept
Definition SymbolWrapper.hpp:340
std::string toString() const
Returns a string representation of the current object.
Definition SymbolWrapper.hpp:286
static SymbolWrapper fromGraal(void *graalNative)
Creates an object of the current type and fills it with data from the the dxFeed Graal SDK structure.
Definition SymbolWrapper.cpp:79
std::string toStringUnderlying() const
Returns a string representation of the underlying object.
Definition SymbolWrapper.hpp:301
std::unique_ptr< void, decltype(&SymbolWrapper::freeGraal)> toGraalUnique() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition SymbolWrapper.hpp:277
bool isStringSymbol() const noexcept
Definition SymbolWrapper.hpp:312
std::optional< IndexedEventSubscriptionSymbol > asIndexedEventSubscriptionSymbol() const noexcept
Definition SymbolWrapper.hpp:348
bool isWildcardSymbol() const noexcept
Definition SymbolWrapper.hpp:326
void * toGraal() const noexcept
Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
Definition SymbolWrapper.hpp:258
SymbolWrapper(const IndexedEventSubscriptionSymbol &indexedEventSubscriptionSymbol) noexcept
Constructor for IndexedEventSubscriptionSymbol.
Definition SymbolWrapper.hpp:197
const DataType & getData() const noexcept
Definition SymbolWrapper.hpp:389
std::string asStringSymbol() const noexcept
Definition SymbolWrapper.hpp:319
SymbolWrapper(const StringSymbol &stringSymbol) noexcept
Constructor for any wrapped string symbol.
Definition SymbolWrapper.hpp:171
std::optional< WildcardSymbol > asWildcardSymbol() const noexcept
Definition SymbolWrapper.hpp:333
SymbolWrapper(const CandleSymbol &candleSymbol) noexcept
Constructor for CandleSymbol.
Definition SymbolWrapper.hpp:225
SymbolWrapper(const WildcardSymbol &wildcardSymbol) noexcept
Constructor for any wrapped wildcard (*) symbol.
Definition SymbolWrapper.hpp:184
bool isTimeSeriesSubscriptionSymbol() const noexcept
Definition SymbolWrapper.hpp:357
SymbolWrapper(const TimeSeriesSubscriptionSymbol &timeSeriesSubscriptionSymbol) noexcept
Constructor for TimeSeriesSubscriptionSymbol.
Definition SymbolWrapper.hpp:211
bool isCandleSymbol() const noexcept
Definition SymbolWrapper.hpp:374
std::optional< TimeSeriesSubscriptionSymbol > asTimeSeriesSubscriptionSymbol() const noexcept
Definition SymbolWrapper.hpp:365
static void freeGraal(void *graalNative)
Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).
Definition SymbolWrapper.cpp:42
Utility class for parsing and formatting dates and times in ISO-compatible format.
Definition TimeFormat.hpp:29
std::string format(std::int64_t timestamp) const
Converts timestamp into string according to the format.
Definition TimeFormat.cpp:55
static const TimeFormat GMT
An instance of TimeFormat that corresponds to GMT timezone as returned by TimeZone::getTimeZone("GMT"...
Definition TimeFormat.hpp:41
std::int64_t parse(const StringLikeWrapper &value) const
Reads Date from String and returns timestamp.
Definition TimeFormat.cpp:49
static const TimeFormat DEFAULT
An instance of TimeFormat that corresponds to default timezone as returned by TimeZone::getDefault() ...
Definition TimeFormat.hpp:33
static const WildcardSymbol ALL
Represents [wildcard] subscription to all events of the specific event type.
Definition WildcardSymbol.hpp:13
The simple key-value structure that represents an endpoint's property.
Definition api.h:184
const char * key
The property's key.
Definition api.h:186
const char * value
The property's value.
Definition api.h:188