dxFeed Graal CXX API v5.0.0
Loading...
Searching...
No Matches
Promise.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 "../exceptions/JavaException.hpp"
11
12#include <atomic>
13#include <chrono>
14#include <memory>
15#include <vector>
16
18
19struct EventType;
20struct JavaException;
21struct Promises;
22
23struct DXFCPP_EXPORT PromiseImpl {
24 protected:
25 std::atomic<void *> handle = nullptr;
26
27 public:
28 explicit PromiseImpl(void *handle);
29
30 bool isDone() const;
31 bool hasResult() const;
32 bool hasException() const;
33 bool isCancelled() const;
34 JavaException getException() const;
35 void await() const;
36 void await(std::int32_t timeoutInMilliseconds) const;
37 bool awaitWithoutException(std::int32_t timeoutInMilliseconds) const;
38 void cancel() const;
39};
40
41struct DXFCPP_EXPORT VoidPromiseImpl : PromiseImpl {
42 std::atomic<void *> handle = nullptr;
43 std::atomic<bool> own = true;
44
45 explicit VoidPromiseImpl(void *handle, bool own = true);
46 ~VoidPromiseImpl();
47 void getResult() const;
48};
49
50struct DXFCPP_EXPORT EventPromiseImpl : PromiseImpl {
51 std::atomic<void *> handle = nullptr;
52 std::atomic<bool> own = true;
53
54 explicit EventPromiseImpl(void *handle, bool own = true);
55 ~EventPromiseImpl();
56 std::shared_ptr<EventType> getResult() const;
57};
58
59struct DXFCPP_EXPORT EventsPromiseImpl : PromiseImpl {
60 std::atomic<void *> handle = nullptr;
61 std::atomic<bool> own = true;
62
63 explicit EventsPromiseImpl(void *handle, bool own = true);
64 ~EventsPromiseImpl();
65 std::vector<std::shared_ptr<EventType>> getResult() const;
66};
67
68/**
69 * Mixin for wrapping calls to common promise methods.
70 *
71 * @tparam P The promise type
72 */
73template <typename P> struct CommonPromiseMixin {
74 /**
75 * Returns `true` when a computation has completed normally, or exceptionally, or was canceled.
76 *
77 * @return `true` when computation has completed.
78 */
79 bool isDone() const {
80 return static_cast<const P *>(this)->impl.isDone();
81 }
82
83 /**
84 * Returns `true` when computation has completed normally.
85 * Use ::getResult() method to get the result of the computation.
86 * @return `true` when computation has completed normally.
87 * @see ::getResult()
88 */
89 bool hasResult() const {
90 return static_cast<const P *>(this)->impl.hasResult();
91 }
92
93 /**
94 * Returns `true` when a computation has completed exceptionally or was canceled.
95 * Use ::getException() method to get the exceptional outcome of the computation.
96 * @return `true` when computation has completed exceptionally or was canceled.
97 */
98 bool hasException() const {
99 return static_cast<const P *>(this)->impl.hasException();
100 }
101
102 /**
103 * Returns `true` when computation was cancelled.
104 * Use ::getException() method to get the corresponding CancellationException.
105 * @return `true` when computation was cancelled.
106 * @see ::getException()
107 */
108 bool isCancelled() const {
109 return static_cast<const P *>(this)->impl.isCancelled();
110 }
111
112 /**
113 * Returns exceptional outcome of computation. If the computation has no ::hasException() exception,
114 * then this method returns an exception with a message "null". If a computation has completed exceptionally or was
115 * cancelled, then the result of this method is not an exception with a message "null". If computation was @ref
116 * ::isCancelled() "cancelled", then this method returns "an instance of CancellationException".
117 *
118 * @return exceptional outcome of computation.
119 * @see ::hasException()
120 */
122 return static_cast<const P *>(this)->impl.getException();
123 }
124
125 /**
126 * Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
127 * If the wait is interrupted, then the computation is @ref ::cancel() "canceled",
128 * the interruption flag on the current thread is set, and "CancellationException" is thrown.
129 *
130 * <p>If the wait times are out, then the computation is @ref ::cancel() "canceled" and this method returns `false`.
131 * Use this method in the code that shall continue normal execution in case of timeout.
132 *
133 * @param timeoutInMilliseconds The timeout.
134 * @return `true` if the computation has completed normally; `false` when wait timed out.
135 * @throws CancellationException if computation was cancelled.
136 * @throws PromiseException if computation has completed exceptionally.
137 */
138 bool awaitWithoutException(std::int32_t timeoutInMilliseconds) const {
139 return static_cast<const P *>(this)->impl.awaitWithoutException(timeoutInMilliseconds);
140 }
141
142 /**
143 * Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
144 * If the wait is interrupted, then the computation is @ref ::cancel() "canceled",
145 * the interruption flag on the current thread is set, and "CancellationException" is thrown.
146 *
147 * <p>If the wait times are out, then the computation is @ref ::cancel() "canceled" and this method returns `false`.
148 * Use this method in the code that shall continue normal execution in case of timeout.
149 *
150 * @param timeoutInMilliseconds The timeout.
151 * @return `true` if the computation has completed normally; `false` when wait timed out.
152 * @throws CancellationException if computation was cancelled.
153 * @throws PromiseException if computation has completed exceptionally.
154 */
155 bool awaitWithoutException(const std::chrono::milliseconds &timeoutInMilliseconds) const {
156 return static_cast<const P *>(this)->impl.awaitWithoutException(
157 dxfcpp::fitToType<std::int32_t>(timeoutInMilliseconds.count()));
158 }
159
160 /**
161 * This method cancels computation. This method does nothing if the computation has already @ref ::isDone() "completed".
162 *
163 * <p>If cancelled, then ::getException() will return "CancellationException",
164 * @ref ::isDone() "isDone", @ref ::isCancelled() "isCancelled", and @ref ::hasException() "hasException" will
165 * return `true`, all handlers that were installed with `whenDone` method are notified by invoking their
166 * `promiseDone` method, and all waiters on @ref ::await() "join" method throw "CancellationException".
167 */
168 void cancel() const {
169 static_cast<const P *>(this)->impl.cancel();
170 }
171};
172
173/**
174 * Mixin for wrapping Promise method calls for a void.
175 *
176 * @tparam P The promise type.
177 */
178template <typename P> struct VoidPromiseMixin {
179 /**
180 * Returns result of computation.
181 *
182 * @return The result of computation.
183 * @see CommonPromiseMixin::hasResult()
184 */
185 void getResult() const {
186 return static_cast<const P *>(this)->impl.getResult();
187 }
188
189 /**
190 * Wait for the computation to complete and return its result or throw an exception in case of exceptional completion.
191 * @return result of computation.
192 * @throws CancellationException if computation was canceled.
193 * @throws PromiseException if computation has completed exceptionally.
194 */
195 void await() const {
196 static_cast<const P *>(this)->impl.await();
197
198 return getResult();
199 }
200
201 /**
202 * Wait for the computation to complete or timeout and return its result or throw an exception in case of exceptional
203 * completion or timeout.
204 *
205 * @param timeoutInMilliseconds The timeout.
206 * @return The result of computation.
207 * @throws CancellationException if computation was canceled or timed out.
208 * @throws PromiseException if computation has completed exceptionally.
209 */
210 void await(std::int32_t timeoutInMilliseconds) const & {
211 static_cast<const P *>(this)->impl.await(timeoutInMilliseconds);
212
213 return getResult();
214 }
215
216 /**
217 * Wait for the computation to complete or timeout and return its result or throw an exception in case of exceptional
218 * completion or timeout.
219 *
220 * @param timeoutInMilliseconds The timeout.
221 * @return The result of computation.
222 * @throws CancellationException if computation was cancelled or timed out.
223 * @throws PromiseException if computation has completed exceptionally.
224 */
225 void await(const std::chrono::milliseconds &timeoutInMilliseconds) const & {
226 static_cast<const P *>(this)->impl.await(dxfcpp::fitToType<std::int32_t>(timeoutInMilliseconds.count()));
227
228 return getResult();
229 }
230};
231
232/**
233 * Mixin for wrapping Promise method calls for a single event.
234 * @tparam E The event type.
235 * @tparam P The promise type.
236 */
237template <typename E, typename P> struct EventPromiseMixin {
238 /**
239 * Returns result of computation. If the computation has no @ref CommonPromiseMixin::hasResult() "result", then
240 * this method returns `std::shared_ptr<E>(nullptr)`.
241 *
242 * @return The result of computation.
243 * @see CommonPromiseMixin::hasResult()
244 */
245 std::shared_ptr<E> getResult() const {
246 return convertEvent<EventType, E>(static_cast<const P *>(this)->impl.getResult());
247 }
248
249 /**
250 * Wait for the computation to complete and return its result or throw an exception in case of exceptional completion.
251 * @return result of computation.
252 * @throws CancellationException if computation was canceled.
253 * @throws PromiseException if computation has completed exceptionally.
254 */
255 std::shared_ptr<E> await() const {
256 static_cast<const P *>(this)->impl.await();
257
258 return getResult();
259 }
260
261 /**
262 * Wait for computation to complete or timeout and return its result or throw an exception in case of exceptional
263 * completion or timeout.
264 *
265 * @param timeoutInMilliseconds The timeout.
266 * @return The result of computation.
267 * @throws CancellationException if computation was canceled or timed out.
268 * @throws PromiseException if computation has completed exceptionally.
269 */
270 std::shared_ptr<E> await(std::int32_t timeoutInMilliseconds) const & {
271 static_cast<const P *>(this)->impl.await(timeoutInMilliseconds);
272
273 return getResult();
274 }
275
276 /**
277 * Wait for computation to complete or timeout and return its result or throw an exception in case of exceptional
278 * completion or timeout.
279 *
280 * @param timeoutInMilliseconds The timeout.
281 * @return The result of computation.
282 * @throws CancellationException if computation was cancelled or timed out.
283 * @throws PromiseException if computation has completed exceptionally.
284 */
285 std::shared_ptr<E> await(const std::chrono::milliseconds &timeoutInMilliseconds) const & {
286 static_cast<const P *>(this)->impl.await(dxfcpp::fitToType<std::int32_t>(timeoutInMilliseconds.count()));
287
288 return getResult();
289 }
290};
291
292template <typename E, typename P> struct EventsPromiseMixin {
293 /**
294 * Returns result of computation. If computation has no @ref CommonPromiseMixin::hasResult() "result", then
295 * this method returns an empty collection.
296 *
297 * @return The result of computation.
298 * @see CommonPromiseMixin::hasResult()
299 */
300 std::vector<std::shared_ptr<E>> getResult() const {
301 return convertEvents<EventType, E>(static_cast<const P *>(this)->impl.getResult());
302 }
303
304 /**
305 * Wait for computation to complete and return its result or throw an exception in case of exceptional completion.
306 * @return result of computation.
307 * @throws CancellationException if computation was cancelled.
308 * @throws PromiseException if computation has completed exceptionally.
309 */
310 std::vector<std::shared_ptr<E>> await() const {
311 static_cast<const P *>(this)->impl.await();
312
313 return getResult();
314 }
315
316 /**
317 * Wait for computation to complete or timeout and return its result or throw an exception in case of exceptional
318 * completion or timeout.
319 *
320 * @param timeoutInMilliseconds The timeout.
321 * @return The result of computation.
322 * @throws CancellationException if computation was cancelled or timed out.
323 * @throws PromiseException if computation has completed exceptionally.
324 */
325 std::vector<std::shared_ptr<E>> await(std::int32_t timeoutInMilliseconds) const & {
326 static_cast<const P *>(this)->impl.await(timeoutInMilliseconds);
327
328 return getResult();
329 }
330
331 /**
332 * Wait for computation to complete or timeout and return its result or throw an exception in case of exceptional
333 * completion or timeout.
334 *
335 * @param timeoutInMilliseconds The timeout.
336 * @return The result of computation.
337 * @throws CancellationException if computation was cancelled or timed out.
338 * @throws PromiseException if computation has completed exceptionally.
339 */
340 std::vector<std::shared_ptr<E>> await(const std::chrono::milliseconds &timeoutInMilliseconds) const & {
341 static_cast<const P *>(this)->impl.await(dxfcpp::fitToType<std::int32_t>(timeoutInMilliseconds.count()));
342
343 return getResult();
344 }
345};
346
347/**
348 * Result of a computation that will be completed normally or exceptionally in the future.
349 * @tparam T The result type.
350 */
351template <typename T> struct Promise {};
352
353/**
354 * Result of an void receiving that will be completed normally or exceptionally in the future.
355 */
356template <> struct Promise<void> : CommonPromiseMixin<Promise<void>>, VoidPromiseMixin<Promise<void>> {
357 friend struct CommonPromiseMixin<Promise>;
358 friend struct VoidPromiseMixin<Promise>;
359 friend struct Promises;
360
361 private:
362 VoidPromiseImpl impl;
363
364 public:
365 explicit Promise(void *handle, bool own = true) : impl(handle, own) {
366 }
367
368 Promise(const Promise &) = delete;
369 Promise &operator=(const Promise &) = delete;
370
371 Promise(Promise && other) noexcept : impl(other.impl.handle, other.impl.own) {
372 other.impl.handle = nullptr;
373 other.impl.own = false;
374 }
375
376 Promise &operator=(Promise &&) noexcept = delete;
377};
378
379/**
380 * Result of an event receiving that will be completed normally or exceptionally in the future.
381 * @tparam E The event type.
382 */
383template <typename E>
384struct Promise<std::shared_ptr<E>> : CommonPromiseMixin<Promise<std::shared_ptr<E>>>,
385 EventPromiseMixin<E, Promise<std::shared_ptr<E>>> {
386 friend struct CommonPromiseMixin<Promise>;
387 friend struct EventPromiseMixin<E, Promise>;
388 friend struct Promises;
389
390 private:
391 EventPromiseImpl impl;
392
393 public:
394 explicit Promise(void *handle, bool own = true) : impl(handle, own) {
395 }
396
397 template <Derived<E> D>
398 explicit Promise(std::shared_ptr<Promise<std::shared_ptr<D>>> other) : impl(other->impl->handle, false) {
399 }
400
401 template <BaseOf<E> B> std::shared_ptr<Promise<std::shared_ptr<B>>> sharedAs(bool transferOwnership = false) {
402 if (transferOwnership) {
403 impl.own = false;
404 }
405
406 return std::make_shared<Promise<std::shared_ptr<B>>>(impl.handle, transferOwnership);
407 }
408
409 Promise(const Promise &) = delete;
410 Promise &operator=(const Promise &) = delete;
411
412 Promise(Promise && other) noexcept : impl(other.impl.handle, other.impl.own) {
413 other.impl.handle = nullptr;
414 other.impl.own = false;
415 }
416
417 Promise &operator=(Promise &&) noexcept = delete;
418};
419
420struct DXFCPP_EXPORT PromiseListImpl {
421 std::atomic<void *> handle = nullptr;
422
423 explicit PromiseListImpl(void *handle);
424 ~PromiseListImpl();
425
426 static std::size_t getSize(void *handle);
427 static void *getElement(void *handle, std::size_t index);
428};
429
430/**
431 * A list of event receiving results that will be completed normally or exceptionally in the future.
432 * It is a std::vector<Promise<std::shared_ptr<E>>> wrapper with Graal semantics.
433 * @tparam E The event type.
434 */
435template <typename E> struct PromiseList {
436 friend struct Promises;
437
439
440 using iterator_category = std::random_access_iterator_tag;
441
442 using value_type = typename data_type::value_type;
443 using allocator_type = typename data_type::allocator_type;
444 using pointer = typename data_type::pointer;
445 using const_pointer = typename data_type::const_pointer;
446 using reference = typename data_type::reference;
447 using const_reference = typename data_type::const_reference;
448 using size_type = typename data_type::size_type;
449 using difference_type = typename data_type::difference_type;
450
451 using iterator = typename data_type::iterator;
452 using const_iterator = typename data_type::const_iterator;
455
456 private:
457 PromiseListImpl impl;
458
459 data_type data_;
460
461 public:
462 explicit PromiseList(void *handle = nullptr) : impl(handle) {
463 }
464
465 static std::shared_ptr<PromiseList> create(void *handle) {
466 if (!handle) {
467 return {};
468 }
469
470 std::vector<Promise<std::shared_ptr<E>>> result{};
471 auto size = PromiseListImpl::getSize(handle);
472 auto promiseList = std::make_shared<PromiseList<E>>(handle);
473
474 promiseList->data_.reserve(size);
475
476 for (std::size_t elementIndex = 0; elementIndex < size; elementIndex++) {
477 if (auto element = PromiseListImpl::getElement(handle, elementIndex)) {
478 promiseList->data_.emplace_back(element, false);
479 }
480 }
481
482 return promiseList;
483 }
484
485 pointer data() noexcept {
486 return data_.data();
487 }
488
489 const_pointer data() const noexcept {
490 return data_.data();
491 }
492
493 iterator begin() noexcept {
494 return data_.begin();
495 }
496
497 const_iterator begin() const noexcept {
498 return data_.begin();
499 }
500
501 iterator end() noexcept {
502 return data_.end();
503 }
504
505 const_iterator end() const noexcept {
506 return data_.end();
507 }
508
509 const_iterator cbegin() const noexcept {
510 return data_.cbegin();
511 }
512
513 const_iterator cend() const noexcept {
514 return data_.cend();
515 }
516
517 reverse_iterator rbegin() noexcept {
518 return data_.rbegin();
519 }
520
521 reverse_iterator rend() noexcept {
522 return data_.rend();
523 }
524
525 const_reverse_iterator crbegin() const noexcept {
526 return data_.crbegin();
527 }
528
529 const_reverse_iterator crend() const noexcept {
530 return data_.crend();
531 }
532
533 bool empty() const noexcept {
534 return data_.empty();
535 }
536
537 size_type size() const noexcept {
538 return data_.size();
539 }
540
541 size_type max_size() const noexcept {
542 return data_.max_size();
543 }
544
545 size_type capacity() const noexcept {
546 return data_.capacity();
547 }
548
549 reference operator[](const size_type pos) noexcept {
550 return data_[pos];
551 }
552
553 const_reference operator[](const size_type pos) const noexcept {
554 return data_[pos];
555 }
556
557 reference at(const size_type pos) {
558 return data_.at(pos);
559 }
560
561 const_reference at(const size_type pos) const {
562 return data_.at(pos);
563 }
564
565 reference front() noexcept {
566 return data_.front();
567 }
568
569 const_reference front() const noexcept {
570 return data_.front();
571 }
572
573 reference back() noexcept {
574 return data_.back();
575 }
576
577 const_reference back() const noexcept {
578 return data_.back();
579 }
580};
581
582/**
583 * Result of an collection of events receiving that will be completed normally or exceptionally in the future.
584 * @tparam E The event type.
585 */
586template <typename E>
587struct Promise<std::vector<std::shared_ptr<E>>> : CommonPromiseMixin<Promise<std::vector<std::shared_ptr<E>>>>,
588 EventsPromiseMixin<E, Promise<std::vector<std::shared_ptr<E>>>> {
589 friend struct CommonPromiseMixin<Promise>;
590 friend struct EventsPromiseMixin<E, Promise>;
591 friend struct Promises;
592
593 private:
594 EventsPromiseImpl impl;
595
596 public:
597 explicit Promise(void *handle, bool own = true) : impl(handle, own) {
598 }
599
600 Promise(const Promise &) = delete;
601 Promise &operator=(const Promise &) = delete;
602
603 Promise(Promise && other) noexcept : impl(other.impl.handle, other.impl.own) {
604 other.impl.handle = nullptr;
605 other.impl.own = false;
606 }
607
608 Promise &operator=(Promise &&) noexcept = delete;
609};
610
612
#define DXFCPP_MACRO_CONCAT_INNER(a, b)
Definition Common.hpp:129
#define DXFCPP_MACRO_CONCAT(a, b)
Definition Common.hpp:128
#define DXFCPP_MACRO_UNIQUE_NAME(base)
Definition Common.hpp:130
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:31
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:97
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:94
#define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:47
#define DXFCXX_DISABLE_GCC_WARNINGS_POP()
Definition Conf.hpp:49
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:30
#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_name(dxfc_dxendpoint_builder_t builderHandle, const char *name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:680
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:713
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:961
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1151
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:740
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Adds a listener notified about changes in state property.
Definition DXEndpoint.cpp:1097
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1012
#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:910
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:1063
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 the connection is not...
Definition api.h:159
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to the 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:799
#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:1080
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:696
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:787
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:978
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 a listener notified about changes in state property.
Definition DXEndpoint.cpp:1123
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:73
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:757
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1146
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:1046
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:893
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder)
Creates a new dxFeed endpoint's builder instance.
Definition DXEndpoint.cpp:647
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:995
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:927
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:944
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 an 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 the 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:846
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:822
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:663
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:869
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1156
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:1029
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:842
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:323
std::shared_ptr< Builder > withName(const StringLike &name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:366
bool supportsProperty(const StringLike &key) const
Checks if a property is supported.
Definition DXEndpoint.cpp:313
std::shared_ptr< Builder > withProperties(Properties &&properties)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.hpp:931
~Builder() noexcept override
Releases the GraalVM handle.
Definition DXEndpoint.cpp:355
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:285
std::shared_ptr< Builder > withProperty(const StringLike &key, const StringLike &value)
Sets the specified property.
Definition DXEndpoint.cpp:298
Subscription for a set of symbols and event types.
Definition DXFeedSubscription.hpp:39
Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols an...
Definition DXFeedSubscription.hpp:786
The enumeration type that provides additional information about the dxFeed Graal C++-API event type.
Definition EventTypeEnum.hpp:21
Source identifier for IndexedEvent.
Definition IndexedEventSource.hpp:22
Mixin for wrapping calls to common promise methods.
Definition Promise.hpp:73
JavaException getException() const
Returns exceptional outcome of computation.
Definition Promise.hpp:121
void cancel() const
This method cancels computation.
Definition Promise.hpp:168
bool hasResult() const
Returns true when computation has completed normally.
Definition Promise.hpp:89
bool isCancelled() const
Returns true when computation was cancelled.
Definition Promise.hpp:108
bool hasException() const
Returns true when a computation has completed exceptionally or was canceled.
Definition Promise.hpp:98
bool awaitWithoutException(const std::chrono::milliseconds &timeoutInMilliseconds) const
Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
Definition Promise.hpp:155
bool isDone() const
Returns true when a computation has completed normally, or exceptionally, or was canceled.
Definition Promise.hpp:79
bool awaitWithoutException(std::int32_t timeoutInMilliseconds) const
Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
Definition Promise.hpp:138
Manages network connections to feed or publisher.
Definition DXEndpoint.hpp:172
bool isClosed() const
Definition DXEndpoint.cpp:499
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:511
static const std::string DXFEED_PASSWORD_PROPERTY
"dxfeed.password"
Definition DXEndpoint.hpp:238
static std::shared_ptr< DXEndpoint > create(Role role)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:486
std::shared_ptr< DXFeed > getFeed() const
Definition DXEndpoint.cpp:212
std::shared_ptr< DXEndpoint > password(const StringLike &password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:139
State
Represents the current state of endpoint.
Definition DXEndpoint.hpp:436
@ CLOSED
Endpoint was closed.
Definition DXEndpoint.hpp:456
@ CONNECTING
The connect method was called to establish connection to remove endpoint, but the connection is not e...
Definition DXEndpoint.hpp:446
@ CONNECTED
The connection to the remote endpoint is established.
Definition DXEndpoint.hpp:451
@ NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition DXEndpoint.hpp:440
std::shared_ptr< DXEndpoint > user(const StringLike &user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:132
void reconnect() const
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:158
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:477
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:507
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:503
Role
Represents the role of an endpoint that was specified during its creation.
Definition DXEndpoint.hpp:365
@ PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition DXEndpoint.hpp:410
@ STREAM_FEED
STREAM_FEED endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provide...
Definition DXEndpoint.hpp:398
@ LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition DXEndpoint.hpp:426
@ ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandSe...
Definition DXEndpoint.hpp:389
@ STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publish...
Definition DXEndpoint.hpp:419
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition DXEndpoint.hpp:376
std::string toString() const override
Returns a string representation of the current object.
Definition DXEndpoint.cpp:376
void awaitProcessed() const
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:194
std::shared_ptr< DXPublisher > getPublisher() const
Definition DXEndpoint.cpp:221
static const std::string DXFEED_WILDCARD_ENABLE_PROPERTY
"dxfeed.wildcard.enable"
Definition DXEndpoint.hpp:266
std::size_t addStateChangeListener(std::function< void(State, State)> listener) noexcept
Adds a listener notified about changes in state property.
Definition DXEndpoint.hpp:611
static const std::string DXENDPOINT_EVENT_TIME_PROPERTY
"dxendpoint.eventTime"
Definition DXEndpoint.hpp:311
static const std::string DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY
"dxpublisher.threadPoolSize"
Definition DXEndpoint.hpp:294
State getState() const
Returns the state of this endpoint.
Definition DXEndpoint.cpp:128
static const std::string DXENDPOINT_STORE_EVERYTHING_PROPERTY
"dxendpoint.storeEverything"
Definition DXEndpoint.hpp:324
void awaitNotConnected() const
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:185
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:459
static const std::string DXFEED_AGGREGATION_PERIOD_PROPERTY
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:257
void close() const
Closes this endpoint.
Definition DXEndpoint.cpp:515
static const std::string DXFEED_THREAD_POOL_SIZE_PROPERTY
"dxfeed.threadPoolSize"
Definition DXEndpoint.hpp:247
void disconnect() const
Terminates all remote network connections.
Definition DXEndpoint.cpp:167
void closeAndAwaitTermination() const
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:203
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:450
static const std::string DXPUBLISHER_ADDRESS_PROPERTY
"dxpublisher.address"
Definition DXEndpoint.hpp:285
static const std::string DXFEED_USER_PROPERTY
"dxfeed.user"
Definition DXEndpoint.hpp:228
static const std::string NAME_PROPERTY
"name"
Definition DXEndpoint.hpp:189
static const std::string DXSCHEME_ENABLED_PROPERTY_PREFIX
"dxscheme.enabled."
Definition DXEndpoint.hpp:358
static const std::string DXPUBLISHER_PROPERTIES_PROPERTY
"dxpublisher.properties"
Definition DXEndpoint.hpp:275
static const std::string DXSCHEME_NANO_TIME_PROPERTY
"dxscheme.nanoTime"
Definition DXEndpoint.hpp:344
static const std::string DXFEED_ADDRESS_PROPERTY
"dxfeed.address"
Definition DXEndpoint.hpp:218
void disconnectAndClear() const
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:176
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:495
static const std::string DXFEED_PROPERTIES_PROPERTY
"dxfeed.properties"
Definition DXEndpoint.hpp:200
static std::shared_ptr< Builder > newBuilder()
Creates a new Builder instance.
Definition DXEndpoint.cpp:468
std::shared_ptr< DXEndpoint > connect(const StringLike &address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:146
Main entry class for dxFeed API (read it first).
Definition DXFeed.hpp:115
void detachSubscriptionAndClear(const std::shared_ptr< DXFeedSubscription > &subscription) const
Detaches the given subscription from this feed and clears data delivered to this subscription by publ...
Definition DXFeed.cpp:65
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::int64_t fromTime) const
Returns time series of events for the specified event type, symbol and a range of time (without an up...
Definition DXFeed.hpp:1000
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(EventTypeIt begin, EventTypeIt end)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:469
std::shared_ptr< DXFeedSubscription > createSubscription(EventTypeIt begin, EventTypeIt end)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:357
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypesCollection &eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:407
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypesCollection &eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:534
std::shared_ptr< PromiseList< E > > getLastEventsPromises(std::initializer_list< SymbolWrapper > collection) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:716
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::chrono::milliseconds fromTime, std::chrono::milliseconds toTime) const
Returns time series of events for the specified event type, symbol and a range of time if there is a ...
Definition DXFeed.hpp:984
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::int64_t fromTime, std::int64_t toTime) const
Returns time series of events for the specified event type, symbol and a range of time if there is a ...
Definition DXFeed.hpp:932
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypeEnum &eventType) const
Creates a new subscription for a single event type that is attached to this feed.
Definition DXFeed.cpp:85
std::shared_ptr< Promise< std::vector< std::shared_ptr< E > > > > getTimeSeriesPromise(const SymbolWrapper &symbol, std::int64_t fromTime, std::int64_t toTime) const
Requests time series of events for the specified event type, symbol and a range of time.
Definition DXFeed.hpp:880
std::shared_ptr< PromiseList< E > > getLastEventsPromises(const SymbolsCollection &collection) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:670
std::shared_ptr< E > getLastEventIfSubscribed(const SymbolWrapper &symbol)
Returns the last event for the specified event type and symbol if there is a subscription for it.
Definition DXFeed.hpp:304
std::shared_ptr< DXFeedSubscription > createSubscription(std::initializer_list< EventTypeEnum > eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:98
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::chrono::milliseconds fromTime) const
Returns time series of events for the specified event type, symbol and a range of time (without an up...
Definition DXFeed.hpp:1015
static std::shared_ptr< DXFeed > getInstance()
Returns a default application-wide singleton instance of feed.
Definition DXFeed.cpp:16
std::shared_ptr< E > getLastEvent(std::shared_ptr< E > event)
Returns the last event for the specified event instance.
Definition DXFeed.hpp:244
std::shared_ptr< PromiseList< E > > getLastEventsPromises(SymbolIt begin, SymbolIt end) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:623
std::shared_ptr< Promise< std::shared_ptr< E > > > getLastEventPromise(const SymbolWrapper &symbol) const
Requests the last event for the specified event type and symbol.
Definition DXFeed.hpp:575
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(std::initializer_list< EventTypeEnum > eventTypes)
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:135
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeed.cpp:224
std::shared_ptr< Promise< std::vector< std::shared_ptr< E > > > > getIndexedEventsPromise(const SymbolWrapper &symbol, const IndexedEventSource &source) const
Requests a container of indexed events for the specified event type, symbol and source.
Definition DXFeed.hpp:769
void detachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Detaches the given subscription from this feed.
Definition DXFeed.cpp:45
std::vector< std::shared_ptr< E > > getIndexedEventsIfSubscribed(const SymbolWrapper &symbol, const IndexedEventSource &source) const
Returns a vector of indexed events for the specified event type, symbol and source if there is a subs...
Definition DXFeed.hpp:825
const Collection & getLastEvents(const Collection &events)
Returns the last events for the specified list of event instances.
Definition DXFeed.hpp:265
void attachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Attaches the given subscription to this feed.
Definition DXFeed.cpp:25
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypeEnum &eventType) const
Creates a new subscription for a single event type that is attached to this feed.
Definition DXFeed.cpp:113
Provides API for publishing of events to local or remote DXFeed.
Definition DXPublisher.hpp:56
Base abstract class for all dxFeed C++ API entities.
Definition Entity.hpp:13
virtual ~Entity() noexcept=default
The default virtual d-tor.
Mixin for wrapping Promise method calls for a single event.
Definition Promise.hpp:237
std::shared_ptr< E > getResult() const
Returns result of computation.
Definition Promise.hpp:245
std::shared_ptr< E > await() const
Wait for the computation to complete and return its result or throw an exception in case of exception...
Definition Promise.hpp:255
std::shared_ptr< E > await(const std::chrono::milliseconds &timeoutInMilliseconds) const &
Wait for computation to complete or timeout and return its result or throw an exception in case of ex...
Definition Promise.hpp:285
std::shared_ptr< E > await(std::int32_t timeoutInMilliseconds) const &
Wait for computation to complete or timeout and return its result or throw an exception in case of ex...
Definition Promise.hpp:270
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:31
The wrapper over CEntryPointErrorsEnum, the error code returned by GraalVM.
Definition GraalException.hpp:21
GraalException(CEntryPointErrorsEnum entryPointErrorsEnum)
Constructs an exception.
Definition GraalException.cpp:8
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:122
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:156
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:208
std::size_t operator+=(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:197
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:146
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:84
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:236
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:177
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:217
Thrown to indicate that a method has been passed an illegal or inappropriate argument.
Definition InvalidArgumentException.hpp:18
A wrapper over the interceptable Java exceptions thrown by the dxFeed Native Graal SDK.
Definition JavaException.hpp:20
Represents up-to-date information about some condition or state of an external entity that updates in...
Definition LastingEvent.hpp:28
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:71
A list of event receiving results that will be completed normally or exceptionally in the future.
Definition Promise.hpp:435
Result of a computation that will be completed normally or exceptionally in the future.
Definition Promise.hpp:351
A class that represents a promise-based implementation often used for handling asynchronous operation...
Definition Promises.hpp:41
A helper class needed to construct smart pointers to objects and does not allow explicit construction...
Definition SharedEntity.hpp:88
static auto createShared(Args &&...args)
Creates a smart pointer to an object.
Definition SharedEntity.hpp:102
A runtime axception with stacktrace.
Definition RuntimeException.hpp:20
const std::string & getStackTrace() const &
Definition RuntimeException.cpp:81
RuntimeException(const StringLike &message, const StringLike &additionalStackTrace="")
Constructs a runtime exception.
Definition RuntimeException.cpp:67
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:20
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:77
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:68
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:55
bool is() const noexcept
Checks that the pointer to the current type could be converted to type T* In other words: whether typ...
Definition SharedEntity.hpp:34
std::size_t operator+=(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:377
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:397
void handle(ArgTypes... args)
Calls the listeners and pass the args to them.
Definition Handler.hpp:315
void operator()(ArgTypes... args)
Calls the listeners and pass the ars to them.
Definition Handler.hpp:326
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:357
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:416
std::size_t operator%=(ListenerType &&listener)
Adds the low priority listener (to the "low priority" group).
Definition Handler.hpp:388
std::size_t add(ListenerType &&listener)
Adds the listener to "main" group.
Definition Handler.hpp:336
Universal functional object that allows searching std::unordered_map for string-like keys.
Definition Common.hpp:959
Universal functional object that allows searching std::unordered_map for string-like keys.
Definition StringUtils.hpp:171
A simple wrapper around strings or something similar to strings to reduce the amount of code for meth...
Definition Common.hpp:842
A lightweight wrapper around strings or string-like inputs.
Definition StringUtils.hpp:27
Mixin for wrapping Promise method calls for a void.
Definition Promise.hpp:178
void await(std::int32_t timeoutInMilliseconds) const &
Wait for the computation to complete or timeout and return its result or throw an exception in case o...
Definition Promise.hpp:210
void await(const std::chrono::milliseconds &timeoutInMilliseconds) const &
Wait for the computation to complete or timeout and return its result or throw an exception in case o...
Definition Promise.hpp:225
void await() const
Wait for the computation to complete and return its result or throw an exception in case of exception...
Definition Promise.hpp:195
void getResult() const
Returns result of computation.
Definition Promise.hpp:185
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