dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
DXFeedSubscription.hpp
1// Copyright (c) 2026 Devexperts LLC.
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include "../detail/Conf.hpp"
7
8DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
9
10#include "../entity/EntityModule.hpp"
11#include "../event/EventType.hpp"
12#include "../event/EventTypeEnum.hpp"
13#include "../detail/Concepts.hpp"
14#include "../detail/EventClassList.hpp"
15#include "../util/Handler.hpp"
16#include "../detail/JavaObjectHandle.hpp"
17#include "../symbols/SymbolWrapper.hpp"
18#include "../util/TimePeriod.hpp"
19#include "../util/TimePeriodInfo.hpp"
20#include "./osub/ObservableSubscription.hpp"
21
22#include <atomic>
23#include <chrono>
24#include <concepts>
25#include <cstddef>
26#include <functional>
27#include <memory>
28#include <mutex>
29#include <type_traits>
30#include <unordered_set>
31#include <vector>
32
33/**
34 * @page listener_threads Listeners and threads
35 *
36 * The event listeners of a subscription (DXFeedSubscription::addEventListener()) are called on a thread of the
37 * executor of the endpoint (DXEndpoint::Builder::withExecutor(); by default a pool of `dxfeed.threadPoolSize` threads,
38 * see DXEndpoint::DXFEED_THREAD_POOL_SIZE_PROPERTY). The calls for one subscription are serial: the next batch of
39 * events is delivered only after all the listeners have returned from the previous one, so the order of the events is
40 * kept.
41 *
42 * A listener that blocks or works long delays all the events of its subscription. The events wait in the buffers of
43 * the endpoint and of the server: the lasting events (for example Quote) are conflated, the newest values come late,
44 * and the other events may be dropped (DXFeedSubscription::getTotalDroppedEvents()). From the outside it looks like a
45 * delayed feed. A listener should only take the events and return: copy them into a queue of its own and process them
46 * on another thread, do not wait for locks, network or user input in the listener.
47 *
48 * The library checks this and reports warnings through ErrorManager (ErrorInfo::Level::WARN, the component
49 * `DXFeedSubscription`, see @ref error_handling "Error handling"):
50 *
51 * - **A slow listener.** When the listeners of a subscription take longer than the threshold for one batch, a
52 * warning names the subscription (its number and event types), the time and the size of the batch. The threshold is
53 * the system property DXFeedSubscription::SLOW_LISTENER_THRESHOLD_PROPERTY, `0.1s` by default; `0` turns the check
54 * off.
55 * - **Events that lag behind.** When the system property DXFeedSubscription::EVENT_LAG_THRESHOLD_PROPERTY is set
56 * (it is `0`, off, by default), a warning is reported when the newest event of a batch is older than the threshold
57 * when the batch is received: the current time minus the time of the event. Only the events with the time of a
58 * market action are checked: Quote, Trade, TradeETH (TradeBase::getTime()) and TimeAndSale; a zero time is skipped.
59 * A DXFeedTimeSeriesSubscription is not checked, its history comes with past times. The lag includes the delay
60 * before the data reaches dxFeed and the difference between the clocks of this computer and of the source; the
61 * time of Quote and Trade is often in whole seconds; the first Quote or Trade of a symbol that does not trade often
62 * is old; a replay of recorded data comes with past times. Set the threshold to several seconds.
63 *
64 * Each check of a subscription reports at most one warning per the period DXFeedSubscription::WARNING_PERIOD_PROPERTY
65 * (`1m` by default; `0` reports every excess, `inf` only the first). The first excess is reported at once; the next
66 * warning tells how many excesses were since the previous one and the largest of them.
67 *
68 * The values of the properties are time periods, as TimePeriod::valueOf() reads them: `0.1s`, `5s`, `1m`, `inf`
69 * (never). A subscription reads the properties when it is created (System::setProperty() or the isolate arguments,
70 * see @ref isolate_arguments "Isolate arguments"): a change does not affect the subscriptions that exist. A value that
71 * is not a time period is reported as a warning once, and the default is used.
72 *
73 * The opposite problem, a subscription that receives no events while its endpoint stays connected, is reported by the
74 * silence watchdog of the subscription, which is off by default: see DXFeedSubscription::setSilenceWatchdog(). Its
75 * function is called on a thread of the library, not of the executor of the endpoint.
76 */
77
78/**
79 * \addtogroup dxfcpp_api
80 * @{
81 */
82
83DXFCPP_BEGIN_NAMESPACE
84
85struct DXFeed;
86struct MarketEvent;
87struct IndexedEvent;
88struct TimeSeriesEvent;
89struct LastingEvent;
90
91/**
92 * Subscription for a set of symbols and event types.
93 *
94 * The functions that take symbols throw InvalidArgumentException if a symbol is not valid UTF-8 (see StringParam); the
95 * set of subscribed symbols is not changed then.
96 *
97 * <h3>Threads and locks</h3>
98 *
99 * This class is thread-safe. The event listeners are called on a thread of the executor of the endpoint, one batch at a
100 * time, and must not block: see @ref listener_threads "Listeners and threads".
101 */
103 public:
104 static constexpr std::size_t FAKE_CHANGE_LISTENER_ID{static_cast<std::size_t>(-1)};
105
106 /**
107 * `"dxfcpp.subscription.slowListenerThreshold"`
108 *
109 * The system property with the time that the listeners of a subscription may take for one batch of events; a
110 * longer time is reported as a warning. A time period, `0.1s` by default; `0` turns the check off. Read when a
111 * subscription is created. See @ref listener_threads "Listeners and threads".
112 */
113 static constexpr char SLOW_LISTENER_THRESHOLD_PROPERTY[] = "dxfcpp.subscription.slowListenerThreshold";
114
115 /**
116 * `"dxfcpp.subscription.eventLagThreshold"`
117 *
118 * The system property with the age of the newest event of a received batch above which a warning is reported. A
119 * time period, `0` (the check is off) by default. Read when a subscription is created. See
120 * @ref listener_threads "Listeners and threads".
121 */
122 static constexpr char EVENT_LAG_THRESHOLD_PROPERTY[] = "dxfcpp.subscription.eventLagThreshold";
123
124 /**
125 * `"dxfcpp.subscription.warningPeriod"`
126 *
127 * The system property with the period of the warnings of a slow listener and of lagging events: each check of a
128 * subscription reports at most one warning per period. A time period, `1m` by default. Read when a subscription
129 * is created. See @ref listener_threads "Listeners and threads".
130 */
131 static constexpr char WARNING_PERIOD_PROPERTY[] = "dxfcpp.subscription.warningPeriod";
132
133 ///
134 using OnEventHandler = SimpleHandler<void(const std::vector<std::shared_ptr<EventType>> &)>;
135
136 // These constants are linked with the same ones in RecordBuffer - POOLED_CAPACITY and UNLIMITED_CAPACITY.
137 /**
138 * The optimal events' batch limit for a single notification in OnEventHandler.
139 */
140 static constexpr std::int32_t OPTIMAL_BATCH_LIMIT = 0;
141
142 /**
143 * The maximum events' batch limit for a single notification in OnEventHandler.
144 */
146
147 protected:
148 friend struct DXFeed;
149
150 inline static std::atomic<std::size_t> lastChangeListenerId_{};
151
152 struct Impl;
153
154 std::unique_ptr<Impl> impl_;
155
156 std::unordered_set<EventTypeEnum> eventTypes_;
157 JavaObjectHandle<DXFeedSubscription> handle_;
158
159 // Set first by close(): the callbacks drop the batches of a closed subscription, its methods do nothing.
160 mutable std::atomic<bool> closed_{false};
161
162 // The id of the registration for the callbacks (see registerSubscription()); close() removes the registration.
163 std::size_t id_{};
164
165 mutable std::mutex eventListenerMutex_{};
166 mutable JavaObjectHandle<DXFeedEventListener> eventListenerHandle_;
167 mutable OnEventHandler onEvent_{"DXFeedSubscription"};
169 mutable std::recursive_mutex changeListenersMutex_{};
170
171 // The feeds that own this subscription while it is attached to them (see DXFeed::attachSubscription()).
172 mutable std::mutex feedsMutex_{};
173 mutable std::vector<std::weak_ptr<const DXFeed>> feeds_{};
174
175 static JavaObjectHandle<DXFeedSubscription>
176 createSubscriptionHandleFromEventClassList(const std::unique_ptr<EventClassList> &list);
177
178 // Registers a new subscription for the callbacks of its native listener.
179 static void registerSubscription(const std::shared_ptr<DXFeedSubscription> &subscription);
180
181 void addFeed(const std::shared_ptr<const DXFeed> &feed) const;
182 void removeFeed(const DXFeed *feed) const;
183
184 void setEventListenerHandle(std::size_t id);
185
186 bool tryToSetEventListenerHandle();
187
188 void setSymbolsImpl(void *graalSymbolList) const;
189 void addSymbolsImpl(void *graalSymbolList) const;
190 void removeSymbolsImpl(void *graalSymbolList) const;
191
192 DXFeedSubscription();
193
194 DXFeedSubscription(const EventTypeEnum &eventType);
195
196 DXFeedSubscription(const EventTypeEnum &eventType, JavaObjectHandle<DXFeedSubscription> &&handle);
197
198 template <typename EventTypeIt>
199#if __cpp_concepts
200 requires requires(EventTypeIt iter) {
202 }
203#endif
206
208
210 }
211
212 template <typename EventTypeIt>
213#if __cpp_concepts
214 requires requires(EventTypeIt iter) {
216 }
217#endif
222 }
223
224 public:
225 /// The alias to a type of shared pointer to the DXFeedSubscription object
227
228 /// The alias to a type of unique pointer to the DXFeedSubscription object
230
231 DXFeedSubscription(LockExternalConstructionTag);
232
233 DXFeedSubscription(LockExternalConstructionTag, const EventTypeEnum &eventType);
234
235 template <typename EventTypeIt>
236#if __cpp_concepts
237 requires requires(EventTypeIt iter) {
239 }
240#endif
243 }
244
246
247 template <typename EventTypesCollection>
248 explicit DXFeedSubscription(LockExternalConstructionTag tag, EventTypesCollection &&eventTypes)
249#if __cpp_concepts
250 requires requires {
251 {
252 DXFeedSubscription(tag, std::begin(std::forward<EventTypesCollection>(eventTypes)),
253 std::end(std::forward<EventTypesCollection>(eventTypes)))
254 };
255 }
256#endif
257 : DXFeedSubscription(tag, std::begin(std::forward<EventTypesCollection>(eventTypes)),
258 std::end(std::forward<EventTypesCollection>(eventTypes))) {
259 }
260
261 ///
262 std::string toString() const override;
263
264 ~DXFeedSubscription() override;
265
266 /**
267 * Creates a <i>detached</i> subscription for a single event type.
268 *
269 * Example:
270 * ```cpp
271 * auto sub = dxfcpp::DXFeedSubscription::create(dxfcpp::Quote::TYPE);
272 * ```
273 *
274 * @param eventType the event type.
275 */
276 static std::shared_ptr<DXFeedSubscription> create(const EventTypeEnum &eventType);
277
278 /**
279 * Creates a <i>detached</i> subscription for the given collection of event types.
280 *
281 * Example:
282 * ```cpp
283 * auto eventTypes = {dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE};
284 *
285 * auto sub = dxfcpp::DXFeedSubscription::create(eventTypes.begin(), eventTypes.end());
286 * ```
287 *
288 * ```cpp
289 * std::vector types{dxfcpp::Quote::TYPE, dxfcpp::Trade::TYPE, dxfcpp::Summary::TYPE};
290 *
291 * auto sub = dxfcpp::DXFeedSubscription::create(types.begin(), types.end());
292 * ```
293 *
294 * @tparam EventTypeIt The collection's iterator type
295 * @param begin The beginning of the event type collection.
296 * @param end The end of an event type collection.
297 * @return The new <i>detached</i> subscription for the given collection of event types.
298 */
299 template <typename EventTypeIt>
300#if __cpp_concepts
301 requires requires(EventTypeIt iter) {
303 }
304#endif
311
312 /**
313 * Creates a <i>detached</i> subscription for the given collection of event types.
314 *
315 * Example:
316 * ```cpp
317 * auto sub = dxfcpp::DXFeedSubscription::create({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
318 * ```
319 *
320 * @param eventTypes The event type collection.
321 * @return The new <i>detached</i> subscription for the given collection of event types.
322 */
324
325 /**
326 * Creates a <i>detached</i> subscription for the given collection of event types.
327 *
328 * Example:
329 * ```cpp
330 * auto sub = dxfcpp::DXFeedSubscription::create(std::unordered_set{dxfcpp::Quote::TYPE,
331 * dxfcpp::TimeAndSale::TYPE});
332 * ```
333 *
334 * ```cpp
335 * std::vector types = {dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE};
336 * auto sub = dxfcpp::DXFeedSubscription::create(types);
337 * ```
338 *
339 * @tparam EventTypesCollection The type of the collection of event types
340 * @param eventTypes The event type collection.
341 * @return The new <i>detached</i> subscription for the given collection of event types.
342 */
343 template <typename EventTypesCollection>
344 static std::shared_ptr<DXFeedSubscription> create(EventTypesCollection &&eventTypes) {
345 auto sub = createShared(std::forward<EventTypesCollection>(eventTypes));
346 registerSubscription(sub);
347
348 return sub;
349 }
350
351 /**
352 * Attaches subscription to the specified feed.
353 *
354 * @param feed The feed to attach to.
355 */
356 void attach(std::shared_ptr<DXFeed> feed);
357
358 /**
359 * Detaches subscription from the specified feed.
360 *
361 * @param feed The feed to detach from.
362 */
363 void detach(std::shared_ptr<DXFeed> feed);
364
365 /**
366 * Returns `true` if this subscription is closed.
367 *
368 * @return `true` if this subscription is closed.
369 *
370 * @see DXFeedSubscription::close()
371 */
372 bool isClosed() override;
373
374 /**
375 * Closes this subscription and makes it <i>permanently detached</i>.
376 * This method notifies all installed instances of subscription change listeners by invoking `subscriptionClosed`
377 * while holding the lock for this subscription. This method clears lists of all installed
378 * event listeners and subscription change listeners and makes sure that no more listeners
379 * can be added.
380 *
381 * The subscription is detached from all the feeds, which do not own it anymore. After this method returns, the
382 * event listeners are not called; called from a listener or a callback of the library, it does not wait for the
383 * calls in progress on the other threads. Adding a listener to a closed subscription or attaching it to a feed does
384 * nothing, as a second close() does. A subscription that is attached to no feed is closed when its last pointer is
385 * released. See @ref entity_lifetime "Lifetime of the entities" and AutoClose.
386 */
387 void close() const;
388
389 /**
390 * The function that the silence watchdog calls (see setSilenceWatchdog()): the subscription and the time since its
391 * silence began.
392 */
395
396 /**
397 * Turns the silence watchdog of this subscription on or off. It is off by default.
398 *
399 * When the subscription receives no events for `timeout` while the endpoint of its feed is connected
400 * (DXEndpoint::State::CONNECTED), the library reports a warning through ErrorManager (ErrorInfo::Level::WARN, the
401 * component `DXFeedSubscription`) with the name of the subscription (its number and event types) and the time of
402 * the silence, then calls `onSilence`. This happens once per silence: the next batch of events, a new connection of
403 * the endpoint or an attach to a feed arm the watchdog again. The silence is counted from the latest of these: the
404 * last batch of events, this call, the attach to a feed and the transition of the endpoint to CONNECTED. A
405 * subscription that is attached to no feed, or whose endpoints are not connected, is not watched; with several
406 * connected endpoints the earliest connection counts.
407 *
408 * The data can stop while the connection stays up: the state of the endpoint does not change, and nothing else
409 * tells about it. The watchdog is off by default because a silence is not always a failure: a symbol that does not
410 * trade, a quiet market, the hours outside the trading session and a subscription without symbols receive no events
411 * for a long time. Choose a timeout above the usual pause of the symbols of the subscription, or watch a separate
412 * subscription to a symbol that is always active.
413 *
414 * `onSilence` is called on a thread of the library, one for all the subscriptions, outside of its locks. It may
415 * call the methods of the subscription and of the endpoint, for example reconnect:
416 *
417 * ```cpp
418 * auto endpoint = DXEndpoint::create()->connect("demo.dxfeed.com:7300");
419 * auto sub = endpoint->getFeed()->createSubscription(Quote::TYPE);
420 *
421 * sub->addEventListener<Quote>([](const auto &quotes) { ... });
422 * sub->addSymbols("AAPL");
423 *
424 * // A weak pointer: the subscription must not own its endpoint.
425 * sub->setSilenceWatchdog(std::chrono::seconds(30),
426 * [weakEndpoint = std::weak_ptr<DXEndpoint>(endpoint)](const auto &, auto silence) {
427 * if (const auto endpoint = weakEndpoint.lock()) {
428 * endpoint->reconnect();
429 * }
430 * });
431 * ```
432 *
433 * Each new connection arms the watchdog again: if the symbols stay silent, such a function reconnects once per
434 * timeout. Count the reconnects or pause them if this is not wanted.
435 *
436 * `onSilence` should return soon: it delays the watchdog of the other subscriptions and the shutdown of the library
437 * at exit. Like a listener, it must not
438 * call dxfcpp::shutdown(). Its exception is reported through ErrorManager. close() of the subscription and a call
439 * with a zero timeout stop the watchdog, but do not wait for a call of `onSilence` in progress.
440 *
441 * A new call replaces the timeout and the function and arms the watchdog again. On a closed subscription it does
442 * nothing.
443 *
444 * The watchdog receives the events as an event listener does. So, like addEventListener(), on a subscription
445 * without event listeners it must be turned on before symbols are added to the attached subscription.
446 *
447 * @param timeout The silence to report; 0 or less turns the watchdog off.
448 * @param onSilence The function to call, or an empty one for the warning only.
449 * @throws JavaException IllegalStateException if the subscription has no event listeners, is attached and has
450 * symbols. The watchdog does not change then.
451 */
452 void setSilenceWatchdog(std::chrono::milliseconds timeout, OnSilenceHandler onSilence = {});
453
454 /**
455 * Returns a set of subscribed event types.
456 *
457 * @return A set of subscribed event types.
458 */
460
461 /**
462 * Returns `true` if this subscription contains the corresponding event type.
463 *
464 * @param eventType The type of event that is checked.
465 * @return `true` if this subscription contains the corresponding event type.
466 *
467 * @see DXFeedSubscription::getEventTypes()
468 */
469 bool containsEventType(const EventTypeEnum &eventType) override;
470
471 /**
472 * Clears the set of subscribed symbols.
473 */
474 void clear() const;
475
476 /**
477 * Returns a set of subscribed symbols (depending on the actual implementation of the subscription).
478 *
479 * The resulting set is maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a
480 * weakly consistent view of the set.
481 *
482 * @return A set of subscribed symbols.
483 */
485
486 /**
487 * Returns a set of decorated symbols (depending on the actual implementation of the subscription).
488 *
489 * The resulting set is maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a
490 * weakly consistent view of the set.
491 *
492 * @return A set of decorated subscribed symbols.
493 */
495
496 /**
497 * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (using
498 * iterators).
499 *
500 * Example:
501 * ```cpp
502 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
503 *
504 * sub->setSymbols(v.begin(), v.end());
505 * ```
506 *
507 * @tparam SymbolIt The collection's iterator type
508 * @param begin The beginning of the symbol collection.
509 * @param end The end of the symbol collection.
510 */
511 template <typename SymbolIt> void setSymbols(SymbolIt begin, SymbolIt end) const {
512 auto list = SymbolWrapper::SymbolListUtils::toGraalListUnique(begin, end);
513
514 setSymbolsImpl(list.get());
515 }
516
517 /**
518 * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection.
519 *
520 * Example:
521 * ```cpp
522 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
523 *
524 * sub->setSymbols(std::vector{"AAPL", "IBM"});
525 * sub->setSymbols(v);
526 * ```
527 *
528 * @tparam SymbolsCollection The symbol collection's type
529 * @param collection The symbol collection
530 */
531 template <ConvertibleToSymbolWrapperCollection SymbolsCollection>
532 void setSymbols(SymbolsCollection &&collection) const {
533 setSymbols(std::begin(collection), std::end(collection));
534 }
535
536 /**
537 * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection
538 * (initializer list).
539 *
540 * Example:
541 * ```cpp
542 * sub->setSymbols({"AAPL", "IBM"sv, "TSLA"s, "GOOG"_s});
543 * ```
544 *
545 * @param collection The symbol collection
546 */
547 void setSymbols(std::initializer_list<SymbolWrapper> collection) const;
548
549 /**
550 * Adds the specified symbol to the set of subscribed symbols.
551 * This is a convenience method to subscribe to one symbol at a time that has a return fast-path for a case when
552 * the symbol is already in the set.
553 * When subscribing to multiple symbols at once, it is preferable to use
554 * @ref DXFeedSubscription::addSymbols(const SymbolsCollection &) const "addSymbols(symbols)" method.
555 *
556 * Example:
557 * ```cpp
558 * sub->addSymbols("TSLA");
559 * sub->addSymbols("XBT/USD:GDAX"s);
560 * sub->addSymbols("BTC/EUR:CXBITF"sv);
561 * ```
562 *
563 * @param symbolWrapper The symbol.
564 */
565 void addSymbols(const SymbolWrapper &symbolWrapper) const;
566
567 /**
568 * Adds the specified collection (using iterators) of symbols to the set of subscribed symbols.
569 *
570 * Example:
571 * ```cpp
572 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
573 *
574 * sub->addSymbols(v.begin(), v.end());
575 * ```
576 *
577 * @tparam SymbolIt The collection's iterator type
578 * @param begin The beginning of the symbol collection.
579 * @param end The end of the symbol collection.
580 */
581 template <typename SymbolIt> void addSymbols(SymbolIt begin, SymbolIt end) const {
582 auto list = SymbolWrapper::SymbolListUtils::toGraalListUnique(begin, end);
583
584 addSymbolsImpl(list.get());
585 }
586
587 /**
588 * Adds the specified collection of symbols to the set of subscribed symbols.
589 *
590 * Example:
591 * ```cpp
592 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
593 *
594 * sub->addSymbols(std::vector{"AAPL", "IBM"});
595 * sub->addSymbols(v);
596 * ```
597 *
598 * @tparam SymbolsCollection The symbol collection's type
599 * @param collection The symbol collection
600 */
601 template <ConvertibleToSymbolWrapperCollection SymbolsCollection>
602 void addSymbols(const SymbolsCollection &collection) const {
603 addSymbols(std::begin(collection), std::end(collection));
604 }
605
606 /**
607 * Adds the specified collection (initializer list) of symbols to the set of subscribed symbols.
608 *
609 * Example:
610 * ```cpp
611 * sub->addSymbols({"AAPL", "IBM"sv, "TSLA"s, "GOOG"_s});
612 * ```
613 *
614 * @param collection The symbol collection
615 */
616 void addSymbols(std::initializer_list<SymbolWrapper> collection) const;
617
618 /**
619 * Removes the specified symbol from the set of subscribed symbols.
620 * To conveniently remove one or few symbols, you can use
621 * @ref DXFeedSubscription::removeSymbols(SymbolsCollection &&) const "removeSymbols(symbols)" method.
622 *
623 * Example:
624 * ```cpp
625 * sub->removeSymbols("TSLA");
626 * sub->removeSymbols("XBT/USD:GDAX"s);
627 * sub->removeSymbols("BTC/EUR:CXBITF"sv);
628 * ```
629 *
630 * @param symbolWrapper The symbol.
631 */
632 void removeSymbols(const SymbolWrapper &symbolWrapper) const;
633
634 /**
635 * Removes the specified collection (using iterators) of symbols from the set of subscribed symbols.
636 *
637 * Example:
638 * ```cpp
639 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
640 *
641 * sub->removeSymbols(v.begin(), v.end());
642 * ```
643 *
644 * @tparam SymbolIt The collection's iterator type
645 * @param begin The beginning of the symbol collection.
646 * @param end The end of the symbol collection.
647 */
648 template <typename SymbolIt> void removeSymbols(SymbolIt begin, SymbolIt end) const {
649 auto list = SymbolWrapper::SymbolListUtils::toGraalListUnique(begin, end);
650
651 removeSymbolsImpl(list.get());
652 }
653
654 /**
655 * Removes the specified collection of symbols from the set of subscribed symbols.
656 *
657 * Example:
658 * ```cpp
659 * auto v = std::vector<dxfcpp::SymbolWrapper>{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s};
660 *
661 * sub->removeSymbols(std::vector{"AAPL", "IBM"});
662 * sub->removeSymbols(v);
663 * ```
664 *
665 * @tparam SymbolsCollection The symbol collection's type
666 * @param collection The symbol collection
667 */
668 template <ConvertibleToSymbolWrapperCollection SymbolsCollection>
669 void removeSymbols(SymbolsCollection &&collection) const {
670 removeSymbols(std::begin(collection), std::end(collection));
671 }
672
673 /**
674 * Removes the specified collection (initializer list) of symbols from the set of subscribed symbols.
675 *
676 * Example:
677 * ```cpp
678 * sub->removeSymbols({"AAPL", "IBM"sv, "TSLA"s, "GOOG"_s});
679 * ```
680 *
681 * @param collection The symbol collection
682 */
683 void removeSymbols(std::initializer_list<SymbolWrapper> collection) const;
684
685 /**
686 * Returns the aggregation period for data for this subscription instance.
687 *
688 * @return The aggregation period for data, represented as a TimePeriod object.
689 */
691
692 /**
693 * Sets the aggregation period for data.
694 * This method sets a new aggregation period for data, which will only take effect on the next iteration of
695 * data notification. For example, if the current aggregation period is 5 seconds, and it is changed
696 * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which
697 * the new aggregation period will take effect.
698 *
699 * @param aggregationPeriod the new aggregation period for data
700 */
701 void setAggregationPeriod(const TimePeriod &aggregationPeriod) const;
702
703 /**
704 * Sets the aggregation period for data.
705 * This method sets a new aggregation period for data, which will only take effect on the next iteration of
706 * data notification. For example, if the current aggregation period is 5 seconds, and it is changed
707 * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which
708 * the new aggregation period will take effect.
709 *
710 * @param aggregationPeriod the new aggregation period (in millis) for data
711 */
712 void setAggregationPeriod(std::chrono::milliseconds aggregationPeriod) const;
713
714 /**
715 * Sets the aggregation period for data.
716 * This method sets a new aggregation period for data, which will only take effect on the next iteration of
717 * data notification. For example, if the current aggregation period is 5 seconds, and it is changed
718 * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which
719 * the new aggregation period will take effect.
720 *
721 * @param aggregationPeriod the new aggregation period (in millis) for data
722 */
723 void setAggregationPeriod(std::int64_t aggregationPeriod) const;
724
725 /**
726 * Returns the aggregation period that was applied to the events delivered to this subscription: the maximum of the
727 * period that the server applies (see DXEndpoint::getAggregationPeriodInfo()) and getAggregationPeriod(), as it
728 * was used when the events were delivered.
729 *
730 * The value is informational and updates when the events are delivered: it is TimePeriodInfo::UNKNOWN until the
731 * first events arrive.
732 *
733 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXFeedSubscription.html#getAggregationPeriodInfo--)
734 *
735 * @return The applied aggregation period info, or TimePeriodInfo::UNKNOWN.
736 * @throws InvalidArgumentException
737 * @throws JavaException
738 * @throws GraalException
739 */
741
742 /**
743 * Returns the total number of events that were dropped for this subscription since it was created.
744 *
745 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXFeedSubscription.html#getTotalDroppedEvents--)
746 *
747 * @return The total number of dropped events.
748 * @throws InvalidArgumentException
749 * @throws JavaException
750 * @throws GraalException
751 */
753
754 /**
755 * Adds listener for events.
756 * Event lister can be added only when the subscription is not producing any events.
757 * The subscription must be either empty
758 * (its set of @ref DXFeedSubscription::getSymbols() "symbols" is empty or not @ref DXFeedSubscription::attach()
759 * "attached" to any feed (its set of change listeners is empty).
760 *
761 * This method does nothing if this subscription is closed.
762 *
763 * Example:
764 * ```cpp
765 * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
766 *
767 * sub->addEventListener([](auto &&events) {
768 * for (const auto &e : events) {
769 * if (auto quote = e->template sharedAs<dxfcpp::Quote>(); quote) {
770 * std::cout << "Q : " + quote->toString() << std::endl;
771 * } else if (auto tns = e->template sharedAs<dxfcpp::TimeAndSale>(); tns) {
772 * std::cout << "TnS : " + tns->toString() << std::endl;
773 * }
774 * }
775 * });
776 *
777 * sub->addSymbols({"$TOP10L/Q", "$SP500#45", "$TICK", "SPX"});
778 * ```
779 *
780 * @tparam EventListener The listener type. Listener can be callable with signature: `void(const
781 * std::vector<std::shared_ptr<EventType>&)`
782 * @param listener The event listener
783 * @return The listener id
784 */
785 template <typename EventListener>
787#if __cpp_concepts
788 requires requires {
789 { listener(std::vector<std::shared_ptr<EventType>>{}) } -> std::same_as<void>;
790 }
791#endif
792 {
793 if (!tryToSetEventListenerHandle()) {
794 return OnEventHandler::FAKE_ID;
795 }
796
797 return onEvent_ += listener;
798 }
799
800 /**
801 * Adds typed listener for events.
802 * Event lister can be added only when the subscription is not producing any events.
803 * The subscription must be either empty
804 * (its set of @ref DXFeedSubscription::getSymbols() "symbols" is empty or not @ref DXFeedSubscription::attach()
805 * "attached" to any feed (its set of change listeners is empty).
806 *
807 * This method does nothing if this subscription is closed.
808 *
809 * Example:
810 * ```cpp
811 * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
812 *
813 * sub->addEventListener(std::function([](const std::vector<std::shared_ptr<dxfcpp::Quotes>> &quotes) -> void {
814 * for (const auto &q : quotes) {
815 * std::cout << "Q : " + q->toString() << std::endl;
816 * }
817 * }));
818 *
819 * sub->addEventListener<dxfcpp::TimeAndSale>([](const auto &timeAndSales) -> void {
820 * for (const auto &tns : timeAndSales) {
821 * std::cout << "TnS : " + tns->toString() << std::endl;
822 * }
823 * });
824 *
825 * sub->addEventListener<dxfcpp::MarketEvent>([](const auto &marketEvents) -> void {
826 * for (const auto &me : marketEvents) {
827 * std::cout << "Market Event's symbol: " + me->getEventSymbol() << std::endl;
828 * }
829 * });
830 *
831 * sub->addSymbols({"$TOP10L/Q", "AAPL", "$TICK", "SPX"});
832 * ```
833 *
834 * @tparam EventT The event type (EventType's child with field TYPE, convertible to EventTypeEnum or MarketEvent
835 * or LastingEvent or TimeSeriesEvent or IndexedEvent)
836 * @param listener The listener. Listener can be callable with signature: `void(const
837 * std::vector<std::shared_ptr<EventT>&)`
838 * @return The listener id
839 */
840 template <typename EventT>
841 std::size_t addEventListener(std::function<void(const std::vector<std::shared_ptr<EventT>> &)> &&listener)
842#if __cpp_concepts
843 requires std::is_base_of_v<EventType, EventT> &&
844 (requires {
848#endif
849 {
851 return SimpleHandler<void(const std::vector<std::shared_ptr<EventType>> &)>::FAKE_ID;
852 }
853
854 return onEvent_ += [l = listener](auto &&events) {
856
858
859 for (const auto &e : events) {
860 if (auto expected = e->template sharedAs<EventT>(); expected) {
862 }
863 }
864
866 };
867 }
868
869 /**
870 * Removes listener for events.
871 *
872 * Example:
873 * ```cpp
874 * auto id = sub->addEventListener([](auto){});
875 *
876 * sub->removeEventListener(id);
877 * ```
878 *
879 * @param listenerId The listener id
880 */
882
883 /**
884 * Returns a reference to an incoming events' handler (delegate), to which listeners can be added and removed.
885 * Listener can be callable with signature: `void(const std::vector<std::shared_ptr<EventType>&)`
886 *
887 * Example:
888 * ```cpp
889 * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE});
890 * auto id = sub->onEvent() += [](auto &&events) {
891 * for (const auto &e : events) {
892 * if (auto quote = e->template sharedAs<dxfcpp::Quote>(); quote) {
893 * std::cout << "Q : " + quote->toString() << std::endl;
894 * } else if (auto tns = e->template sharedAs<dxfcpp::TimeAndSale>(); tns) {
895 * std::cout << "TnS : " + tns->toString() << std::endl;
896 * }
897 * }
898 * };
899 *
900 * sub->addSymbols({"$TOP10L/Q", "$SP500#45", "$TICK", "SPX"});
901 * sub->onEvent() -= id;
902 * ```
903 *
904 * @return The incoming events' handler (delegate)
905 */
906 OnEventHandler &onEvent();
907
909
910 void removeChangeListener(std::size_t changeListenerId) override;
911
912 /**
913 * @return maximum number of events in the single notification of OnEventHandler.
914 * Special cases are supported for constants ::OPTIMAL_BATCH_LIMIT and ::MAX_BATCH_LIMIT.
915 */
917
918 /**
919 * Sets maximum number of events in the single notification of OnEventHandler.
920 * Special cases are supported for constants ::OPTIMAL_BATCH_LIMIT and ::MAX_BATCH_LIMIT.
921 *
922 * @param eventsBatchLimit the notification events limit
923 * @throws JavaException if eventsBatchLimit < 0 (see ::OPTIMAL_BATCH_LIMIT or ::MAX_BATCH_LIMIT)
924 */
925 void setEventsBatchLimit(std::int32_t eventsBatchLimit) const;
926};
927
928/**
929 * Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols and event types.
930 * This class decorates symbols that are passed to `xxxSymbols` methods in DXFeedSubscription by wrapping them into
931 * TimeSeriesSubscriptionSymbol instances with the current value of
932 * @ref DXFeedTimeSeriesSubscription::getFromTime() "fromTime" property. While
933 * @ref DXFeedSubscription::getSymbols() "getSymbols" method returns original (undecorated) symbols, any installed
934 * ObservableSubscriptionChangeListener will see decorated ones.
935 *
936 * <p> Only events that implement the TimeSeriesEvent interface can be subscribed to with DXFeedTimeSeriesSubscription.
937 *
938 * <h3>From time</h3>
939 *
940 * The value of @ref DXFeedTimeSeriesSubscription::getFromTime() "fromTime" property defines the time-span of events
941 * that are subscribed to. Only events that satisfy `event.getEventTime() >= thisSubscription->getFromTime()` are
942 * looked for.
943 *
944 * <p> The value `fromTime` is initially set to `std::numeric_limits<std::int64_t>::max()` with a special meaning that
945 * no events will be received until `fromTime` is changed with
946 * @ref DXFeedTimeSeriesSubscription::setFromTime() "setFromTime" method.
947 *
948 * <h3>Threads and locks</h3>
949 *
950 * This class is thread-safe and can be used concurrently from multiple threads without external synchronization.
951 */
953 public DXFeedSubscription {
954 std::atomic<std::int64_t> fromTime_{(std::numeric_limits<std::int64_t>::max)()};
955
956 static void registerEntity();
957
958 public:
959 DXFeedTimeSeriesSubscription(RequireMakeShared<DXFeedTimeSeriesSubscription>::LockExternalConstructionTag lockTag);
960
961 DXFeedTimeSeriesSubscription(RequireMakeShared<DXFeedTimeSeriesSubscription>::LockExternalConstructionTag lockTag,
962 const EventTypeEnum &eventType, JavaObjectHandle<DXFeedSubscription> &&handle);
963
964 ~DXFeedTimeSeriesSubscription() override;
965
966 template <typename EventTypeIt>
967#if __cpp_concepts
968 requires requires(EventTypeIt iter) {
970 }
971#endif
976 }
977
982 }
983
984 template <typename EventTypesCollection>
988#if __cpp_concepts
989 requires requires {
990 {
993 std::move(handle))
994 };
995 }
996#endif
999 }
1000
1001 ///
1002 std::string toString() const override;
1003
1004 /**
1005 * Returns the earliest timestamp from which time-series of events shall be received.
1006 * The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
1007 *
1008 * @return the earliest timestamp from which time-series of events shall be received.
1009 */
1011
1012 /**
1013 * Sets the earliest timestamp from which time-series of events shall be received.
1014 * The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
1015 *
1016 * @param fromTime the timestamp.
1017 */
1018 void setFromTime(std::int64_t fromTime);
1019
1020 /**
1021 * Sets the earliest timestamp from which time-series of events shall be received.
1022 * The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
1023 *
1024 * @param fromTime the timestamp.
1025 */
1026 void setFromTime(std::chrono::milliseconds fromTime);
1027};
1028
1029DXFCPP_END_NAMESPACE
1030
1031/// @}
1032
1033DXFCXX_DISABLE_MSC_WARNINGS_POP()
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:1125
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:1168
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:1451
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1652
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:1200
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:1598
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1513
#define DXFCPP_EXPORT
Definition api.h:35
void * dxfc_dxendpoint_builder_t
The dxFeed endpoint's builder handle.
Definition api.h:219
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:1395
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:1564
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:190
dxfc_dxendpoint_state_t
Represents the current state of endpoint.
Definition api.h:161
@ DXFC_DXENDPOINT_STATE_CLOSED
Endpoint was closed.
Definition api.h:181
@ DXFC_DXENDPOINT_STATE_NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition api.h:165
@ DXFC_DXENDPOINT_STATE_CONNECTING
The connect function was called to establish connection to remove endpoint, but the connection is not...
Definition api.h:171
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to the remote endpoint is established.
Definition api.h:176
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:1264
#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:1581
void * dxfc_dxendpoint_t
The dxFeed endpoint handle.
Definition api.h:210
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:1146
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:1252
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:1473
dxfc_error_code_t
List of error codes.
Definition api.h:61
@ DXFC_EC_ERROR
The error returned if the current operation cannot be completed.
Definition api.h:72
@ DXFC_EC_SUCCESS
OK.
Definition api.h:65
@ DXFC_EC_G_ERR
dxFeed Graal Native API error.
Definition api.h:69
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:1624
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:208
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:1222
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1647
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:1547
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:1378
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:1087
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:1496
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:1412
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:1429
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:101
@ DXFC_DXENDPOINT_ROLE_PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition api.h:139
@ 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:128
@ 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:111
@ DXFC_DXENDPOINT_ROLE_STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remot...
Definition api.h:148
@ DXFC_DXENDPOINT_ROLE_LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition api.h:155
@ 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:119
void * dxfc_dxpublisher_t
The dxFeed publisher handle.
Definition api.h:229
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:1321
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:1292
void * dxfc_dxfeed_t
The dxFeed handle.
Definition api.h:224
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:1108
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:1349
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1657
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:1530
T & operator*() const noexcept
Definition AutoClose.hpp:173
AutoClose() noexcept=default
Creates an empty AutoClose.
AutoClose(std::shared_ptr< T > entity) noexcept
Creates an AutoClose that closes the entity.
Definition AutoClose.hpp:119
~AutoClose() noexcept
Closes the entity.
Definition AutoClose.hpp:140
const std::shared_ptr< T > & get() const noexcept
Definition AutoClose.hpp:163
std::shared_ptr< T > release() noexcept
Makes this AutoClose empty without closing the entity.
Definition AutoClose.hpp:158
AutoClose & operator=(AutoClose &&other) noexcept
Closes the current entity and takes the entity of the other AutoClose, which becomes empty.
Definition AutoClose.hpp:130
operator bool() const noexcept
Definition AutoClose.hpp:178
AutoClose(AutoClose &&other) noexcept
Takes the entity of the other AutoClose, which becomes empty.
Definition AutoClose.hpp:126
T * operator->() const noexcept
Definition AutoClose.hpp:168
void reset() noexcept
Closes the entity now and makes this AutoClose empty.
Definition AutoClose.hpp:145
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:1069
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:695
std::shared_ptr< Builder > withExecutor(const std::shared_ptr< Executor > &executor)
Sets the executor that is used for notifications (events, state changes, etc.) of the endpoint to bui...
Definition DXEndpoint.hpp:1194
std::shared_ptr< Builder > withProperties(Properties &&properties)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.hpp:1160
~Builder() noexcept override
Releases the GraalVM handle.
Definition DXEndpoint.cpp:733
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:647
Subscription for a set of symbols and event types.
Definition DXFeedSubscription.hpp:102
TimePeriodInfo getAggregationPeriodInfo() const
Returns the aggregation period that was applied to the events delivered to this subscription: the max...
Definition DXFeedSubscription.cpp:1042
bool containsEventType(const EventTypeEnum &eventType) override
Returns true if this subscription contains the corresponding event type.
Definition DXFeedSubscription.cpp:961
std::size_t addChangeListener(std::shared_ptr< ObservableSubscriptionChangeListener > listener) override
Adds subscription change listener.
Definition DXFeedSubscription.cpp:1062
bool isClosed() override
Returns true if this subscription is closed.
Definition DXFeedSubscription.cpp:823
void addSymbols(SymbolIt begin, SymbolIt end) const
Adds the specified collection (using iterators) of symbols to the set of subscribed symbols.
Definition DXFeedSubscription.hpp:581
void close() const
Closes this subscription and makes it permanently detached.
Definition DXFeedSubscription.cpp:832
static constexpr char SLOW_LISTENER_THRESHOLD_PROPERTY[]
"dxfcpp.subscription.slowListenerThreshold"
Definition DXFeedSubscription.hpp:113
void setEventsBatchLimit(std::int32_t eventsBatchLimit) const
Sets maximum number of events in the single notification of OnEventHandler.
Definition DXFeedSubscription.cpp:1108
std::unordered_set< EventTypeEnum > getEventTypes() override
Returns a set of subscribed event types.
Definition DXFeedSubscription.cpp:957
void setSymbols(std::initializer_list< SymbolWrapper > collection) const
Changes the set of subscribed symbols so that it contains just the symbols from the specified collect...
Definition DXFeedSubscription.cpp:992
static constexpr std::int32_t MAX_BATCH_LIMIT
The maximum events' batch limit for a single notification in OnEventHandler.
Definition DXFeedSubscription.hpp:145
void removeSymbols(SymbolIt begin, SymbolIt end) const
Removes the specified collection (using iterators) of symbols from the set of subscribed symbols.
Definition DXFeedSubscription.hpp:648
void removeSymbols(SymbolsCollection &&collection) const
Removes the specified collection of symbols from the set of subscribed symbols.
Definition DXFeedSubscription.hpp:669
void removeSymbols(const SymbolWrapper &symbolWrapper) const
Removes the specified symbol from the set of subscribed symbols.
Definition DXFeedSubscription.cpp:1011
static constexpr char EVENT_LAG_THRESHOLD_PROPERTY[]
"dxfcpp.subscription.eventLagThreshold"
Definition DXFeedSubscription.hpp:122
void attach(std::shared_ptr< DXFeed > feed)
Attaches subscription to the specified feed.
Definition DXFeedSubscription.cpp:805
TimePeriod getAggregationPeriod() const
Returns the aggregation period for data for this subscription instance.
Definition DXFeedSubscription.cpp:1026
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeedSubscription.cpp:732
static constexpr std::int32_t OPTIMAL_BATCH_LIMIT
The optimal events' batch limit for a single notification in OnEventHandler.
Definition DXFeedSubscription.hpp:140
void addSymbols(std::initializer_list< SymbolWrapper > collection) const
Adds the specified collection (initializer list) of symbols to the set of subscribed symbols.
Definition DXFeedSubscription.cpp:1007
void setSymbols(SymbolsCollection &&collection) const
Changes the set of subscribed symbols so that it contains just the symbols from the specified collect...
Definition DXFeedSubscription.hpp:532
void setAggregationPeriod(const TimePeriod &aggregationPeriod) const
Sets the aggregation period for data.
Definition DXFeedSubscription.cpp:1030
static std::shared_ptr< DXFeedSubscription > create(const EventTypeEnum &eventType)
Creates a detached subscription for a single event type.
Definition DXFeedSubscription.cpp:753
std::int32_t getEventsBatchLimit() const
Definition DXFeedSubscription.cpp:1104
std::size_t addEventListener(EventListener &&listener)
Adds listener for events.
Definition DXFeedSubscription.hpp:786
static std::shared_ptr< DXFeedSubscription > create(EventTypesCollection &&eventTypes)
Creates a detached subscription for the given collection of event types.
Definition DXFeedSubscription.hpp:344
OnEventHandler & onEvent()
Returns a reference to an incoming events' handler (delegate), to which listeners can be added and re...
Definition DXFeedSubscription.cpp:1056
void addSymbols(const SymbolsCollection &collection) const
Adds the specified collection of symbols to the set of subscribed symbols.
Definition DXFeedSubscription.hpp:602
void setSymbols(SymbolIt begin, SymbolIt end) const
Changes the set of subscribed symbols so that it contains just the symbols from the specified collect...
Definition DXFeedSubscription.hpp:511
void removeChangeListener(std::size_t changeListenerId) override
Removes subscription change listener by id.
Definition DXFeedSubscription.cpp:1087
std::vector< SymbolWrapper > getDecoratedSymbols() const
Returns a set of decorated symbols (depending on the actual implementation of the subscription).
Definition DXFeedSubscription.cpp:983
void clear() const
Clears the set of subscribed symbols.
Definition DXFeedSubscription.cpp:965
std::int64_t getTotalDroppedEvents() const
Returns the total number of events that were dropped for this subscription since it was created.
Definition DXFeedSubscription.cpp:1048
void detach(std::shared_ptr< DXFeed > feed)
Detaches subscription from the specified feed.
Definition DXFeedSubscription.cpp:814
void addSymbols(const SymbolWrapper &symbolWrapper) const
Adds the specified symbol to the set of subscribed symbols.
Definition DXFeedSubscription.cpp:996
static constexpr char WARNING_PERIOD_PROPERTY[]
"dxfcpp.subscription.warningPeriod"
Definition DXFeedSubscription.hpp:131
void setAggregationPeriod(std::chrono::milliseconds aggregationPeriod) const
Sets the aggregation period for data.
Definition DXFeedSubscription.cpp:1034
void removeSymbols(std::initializer_list< SymbolWrapper > collection) const
Removes the specified collection (initializer list) of symbols from the set of subscribed symbols.
Definition DXFeedSubscription.cpp:1022
std::vector< SymbolWrapper > getSymbols() const
Returns a set of subscribed symbols (depending on the actual implementation of the subscription).
Definition DXFeedSubscription.cpp:974
Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols an...
Definition DXFeedSubscription.hpp:953
std::int64_t getFromTime()
Returns the earliest timestamp from which time-series of events shall be received.
Definition DXFeedSubscription.cpp:1136
void setFromTime(std::chrono::milliseconds fromTime)
Sets the earliest timestamp from which time-series of events shall be received.
Definition DXFeedSubscription.cpp:1147
The enumeration type that provides additional information about the dxFeed Graal C++-API event type.
Definition EventTypeEnum.hpp:40
Source identifier for IndexedEvent.
Definition IndexedEventSource.hpp:31
Mixin for wrapping calls to common promise methods.
Definition Promise.hpp:91
JavaException getException() const
Returns exceptional outcome of computation.
Definition Promise.hpp:139
void cancel() const
This method cancels computation.
Definition Promise.hpp:186
bool hasResult() const
Returns true when computation has completed normally.
Definition Promise.hpp:107
bool isCancelled() const
Returns true when computation was cancelled.
Definition Promise.hpp:126
bool hasException() const
Returns true when a computation has completed exceptionally or was canceled.
Definition Promise.hpp:116
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:173
bool isDone() const
Returns true when a computation has completed normally, or exceptionally, or was canceled.
Definition Promise.hpp:97
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:156
Manages network connections to feed or publisher.
Definition DXEndpoint.hpp:189
void removeMessageConnectorListener(std::size_t listenerId) noexcept
Removes a listener added with DXEndpoint::addMessageConnectorListener().
Definition DXEndpoint.cpp:946
bool isClosed() const
Definition DXEndpoint.cpp:901
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:918
static std::shared_ptr< DXEndpoint > create(Role role)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:888
void setRequestedAggregationPeriod(const TimePeriod &requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:568
static constexpr char DXFEED_AGGREGATION_PERIOD_PROPERTY[]
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:279
static constexpr char DXENDPOINT_EVENT_TIME_PROPERTY[]
"dxendpoint.eventTime"
Definition DXEndpoint.hpp:366
void setRequestedAggregationPeriod(std::chrono::milliseconds requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:573
static constexpr char NAME_PROPERTY[]
"name"
Definition DXEndpoint.hpp:206
static constexpr char DXFEED_PASSWORD_PROPERTY[]
"dxfeed.password"
Definition DXEndpoint.hpp:260
std::shared_ptr< DXFeed > getFeed() const
Definition DXEndpoint.cpp:528
static constexpr char DXSCHEME_NANO_TIME_PROPERTY[]
"dxscheme.nanoTime"
Definition DXEndpoint.hpp:399
State
Represents the current state of endpoint.
Definition DXEndpoint.hpp:491
@ CLOSED
Endpoint was closed.
Definition DXEndpoint.hpp:511
@ CONNECTING
The connect method was called to establish connection to remove endpoint, but the connection is not e...
Definition DXEndpoint.hpp:501
@ CONNECTED
The connection to the remote endpoint is established.
Definition DXEndpoint.hpp:506
@ NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition DXEndpoint.hpp:495
static constexpr char DXFEED_THREAD_POOL_SIZE_PROPERTY[]
"dxfeed.threadPoolSize"
Definition DXEndpoint.hpp:269
TimePeriodInfo getAggregationPeriodInfo() const
Returns the aggregation period that the servers report, over all connections of this endpoint.
Definition DXEndpoint.cpp:586
static constexpr char DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY[]
"dxpublisher.threadPoolSize"
Definition DXEndpoint.hpp:349
void reconnect() const
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:473
std::shared_ptr< DXEndpoint > Ptr
The alias to a type of shared pointer to the DXEndpoint object.
Definition DXEndpoint.hpp:191
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:879
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:909
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:905
Role
Represents the role of an endpoint that was specified during its creation.
Definition DXEndpoint.hpp:420
@ PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition DXEndpoint.hpp:465
@ STREAM_FEED
STREAM_FEED endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provide...
Definition DXEndpoint.hpp:453
@ LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition DXEndpoint.hpp:481
@ ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandSe...
Definition DXEndpoint.hpp:444
@ STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publish...
Definition DXEndpoint.hpp:474
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition DXEndpoint.hpp:431
std::string toString() const override
Returns a string representation of the current object.
Definition DXEndpoint.cpp:754
void awaitProcessed() const
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:509
std::shared_ptr< DXPublisher > getPublisher() const
Definition DXEndpoint.cpp:537
static constexpr char DXFEED_PROPERTIES_PROPERTY[]
"dxfeed.properties"
Definition DXEndpoint.hpp:221
std::optional< TimePeriod > getRequestedAggregationPeriod() const
Returns the aggregation period that this endpoint requests from the server, or an empty value if no p...
Definition DXEndpoint.cpp:556
static constexpr char DXSCHEME_ENABLED_PROPERTY_PREFIX[]
"dxscheme.enabled."
Definition DXEndpoint.hpp:413
State getState() const
Returns the state of this endpoint.
Definition DXEndpoint.cpp:433
static constexpr char DXPUBLISHER_ADDRESS_PROPERTY[]
"dxpublisher.address"
Definition DXEndpoint.hpp:340
std::vector< MessageConnectorInfo > getConnectors() const
Returns the snapshots of the message connectors of this endpoint: one for each address it connects to...
Definition DXEndpoint.cpp:926
void awaitNotConnected() const
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:500
static constexpr char DXFEED_STRIPE_PROPERTY[]
"dxfeed.stripe"
Definition DXEndpoint.hpp:296
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:861
void close() const
Closes this endpoint.
Definition DXEndpoint.cpp:956
static constexpr char DXFEED_REQUESTED_AGGREGATION_PERIOD_PROPERTY[]
"dxfeed.requestedAggregationPeriod"
Definition DXEndpoint.hpp:321
void setRequestedAggregationPeriod(std::int64_t requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:577
void disconnect() const
Terminates all remote network connections.
Definition DXEndpoint.cpp:482
void closeAndAwaitTermination() const
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:518
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:852
static constexpr char DXPUBLISHER_PROPERTIES_PROPERTY[]
"dxpublisher.properties"
Definition DXEndpoint.hpp:330
static constexpr char DXFEED_WILDCARD_ENABLE_PROPERTY[]
"dxfeed.wildcard.enable"
Definition DXEndpoint.hpp:288
static constexpr char DXFEED_ADDRESS_PROPERTY[]
"dxfeed.address"
Definition DXEndpoint.hpp:240
static constexpr char DXFEED_STICKY_SUBSCRIPTION_PROPERTY[]
"dxfeed.stickySubscriptionPeriod"
Definition DXEndpoint.hpp:304
static constexpr char DXFEED_USER_PROPERTY[]
"dxfeed.user"
Definition DXEndpoint.hpp:250
void disconnectAndClear() const
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:491
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:897
std::optional< ConnectionError > getLastConnectionError() const
Returns the last connection error of this endpoint: the newest failed connect attempt or dropped conn...
Definition DXEndpoint.cpp:922
static constexpr char DXENDPOINT_STORE_EVERYTHING_PROPERTY[]
"dxendpoint.storeEverything"
Definition DXEndpoint.hpp:379
static std::shared_ptr< Builder > newBuilder()
Creates a new Builder instance.
Definition DXEndpoint.cpp:870
Main entry class for dxFeed API (read it first).
Definition DXFeed.hpp:142
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:102
Collection getLastEvents(Collection &&events)
Returns the last events for the specified list of event instances.
Definition DXFeed.hpp:330
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:778
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:1056
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:167
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(std::initializer_list< EventTypeEnum > eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:214
std::shared_ptr< DXFeedSubscription > createSubscription(EventTypeIt begin, EventTypeIt end) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:424
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:729
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:364
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:180
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:1087
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(EventTypeIt begin, EventTypeIt end) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:523
static std::shared_ptr< DXFeed > getInstance()
Returns a default application-wide singleton instance of feed.
Definition DXFeed.cpp:25
std::shared_ptr< E > getLastEvent(std::shared_ptr< E > event)
Returns the last event for the specified event instance.
Definition DXFeed.hpp:306
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:670
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypesCollection &eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:469
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:616
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypesCollection &eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:582
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeed.cpp:359
std::shared_ptr< DXFeed > Ptr
The alias to a type of shared pointer to the DXFeed object.
Definition DXFeed.hpp:144
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:834
void detachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Detaches the given subscription from this feed.
Definition DXFeed.cpp:76
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:892
void attachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Attaches the given subscription to this feed.
Definition DXFeed.cpp:34
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:195
Provides API for publishing of events to local or remote DXFeed.
Definition DXPublisher.hpp:62
Mixin for wrapping Promise method calls for a single event.
Definition Promise.hpp:253
std::shared_ptr< E > getResult() const
Returns result of computation.
Definition Promise.hpp:261
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:271
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:303
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:287
Concrete implementation of a event for std::string.
Definition EventType.hpp:148
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:42
std::string toString() const override
Returns a string representation of the current object.
Definition api.cpp:57
virtual std::int64_t getEventTime() const noexcept
Returns time when an event was created or zero when time is not available.
Definition api.cpp:44
virtual void assign(std::shared_ptr< EventType > event)
Replaces the contents of the event.
Definition api.cpp:53
virtual void setEventTime(std::int64_t eventTime) noexcept
Changes event creation time.
Definition api.cpp:48
The part of IndexedEventTxModel that does not depend on the type of events.
Definition IndexedEventTxModel.hpp:48
Represents an indexed collection of up-to-date information about some condition or state of an extern...
Definition IndexedEvent.hpp:46
Thrown to indicate that a method has been passed an illegal or inappropriate argument.
Definition InvalidArgumentException.hpp:23
A wrapper over the interceptable Java exceptions thrown by the dxFeed Native Graal SDK.
Definition JavaException.hpp:26
static void throwIfJavaThreadExceptionExists()
Throws a JavaException if it exists (i.e. intercepted by Graal SDK).
Definition JavaException.cpp:131
JavaException(StringParam message, StringParam className, StringParam stackTrace)
Creates an exception using Java message, className and stack trace.
Definition JavaException.cpp:89
const std::string & getJavaClassName() const &noexcept
Definition JavaException.cpp:101
static JavaException createAndRelease(void *exceptionHandle)
Creates an exception from a native Java exception handle and releases the native representation.
Definition JavaException.cpp:123
static JavaException create(void *exceptionHandle)
Creates an exception using native (GraalVM) Java exception handle.
Definition JavaException.cpp:113
const std::string & getJavaStackTrace() const &noexcept
Definition JavaException.cpp:109
const std::string & getJavaMessage() const &noexcept
Definition JavaException.cpp:105
Represents up-to-date information about some condition or state of an external entity that updates in...
Definition LastingEvent.hpp:33
std::shared_ptr< LastingEvent > Ptr
The alias to a type of shared pointer to the LastingEvent object.
Definition LastingEvent.hpp:35
static bool isActive() noexcept
Base class for all market events.
Definition MarketEvent.hpp:31
Observable set of subscription symbols.
Definition ObservableSubscription.hpp:26
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:77
The raw description of the request that created a promise of DXFeed.
Definition PromiseContext.hpp:24
A list of event receiving results that will be completed normally or exceptionally in the future.
Definition Promise.hpp:457
static std::shared_ptr< PromiseList > create(void *handle, const std::vector< std::shared_ptr< const PromiseContext > > &contexts={})
Creates the list of promises from the native list.
Definition Promise.hpp:495
Result of an event receiving that will be completed normally or exceptionally in the future.
Definition Promise.hpp:406
Result of an void receiving that will be completed normally or exceptionally in the future.
Definition Promise.hpp:376
Result of a computation that will be completed normally or exceptionally in the future.
Definition Promise.hpp:371
A class that represents a promise-based implementation often used for handling asynchronous operation...
Definition Promises.hpp:46
A helper class needed to construct smart pointers to objects and does not allow explicit construction...
Definition SharedEntity.hpp:80
static auto createShared(Args &&...args)
Creates a smart pointer to an object.
Definition SharedEntity.hpp:95
A runtime axception with stacktrace.
Definition RuntimeException.hpp:27
const std::string & getStackTrace() const &
Returns the stacktrace.
Definition RuntimeException.cpp:94
RuntimeException(StringParam message, StringParam additionalStackTrace="")
Constructs a runtime exception.
Definition RuntimeException.cpp:82
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:25
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:69
std::shared_ptr< T > sharedAs() const noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:60
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:49
std::shared_ptr< SharedEntity > Ptr
The alias to a type of shared pointer to the SharedEntity object.
Definition SharedEntity.hpp:27
bool is() const noexcept
Checks that the object is of type T: its dynamic type is T or derived from T.
Definition SharedEntity.hpp:38
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:309
SimpleHandler(const char *component) noexcept
Creates the new handler.
Definition Handler.hpp:197
void removeAll()
Removes all the listeners.
Definition Handler.hpp:352
SimpleHandler() noexcept=default
Creates the new handler.
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:381
void operator()(ArgTypes... args) noexcept
Calls the listeners on the current thread and passes the args to them.
Definition Handler.hpp:254
void handle(ArgTypes... args) noexcept
Calls the listeners on the current thread and passes the args to them.
Definition Handler.hpp:229
A thread-safe list of listeners with a given signature.
Definition Handler.hpp:63
Immutable value class for a range of time periods: the minimum and the maximum period in milliseconds...
Definition TimePeriodInfo.hpp:30
constexpr std::int64_t getMax() const noexcept
Returns the maximum period in milliseconds.
Definition TimePeriodInfo.hpp:63
static const TimePeriodInfo EMPTY
The value meaning "known to be zero". It has zero minimum and maximum.
Definition TimePeriodInfo.hpp:17
constexpr bool isUnknown() const noexcept
Definition TimePeriodInfo.hpp:70
std::string toString() const
Returns the info as JSON with the periods in seconds, as Java does: {"min":1.5,"max":2}...
Definition TimePeriodInfo.cpp:103
static const TimePeriodInfo UNKNOWN
The value meaning "not set / unknown". It has negative minimum and maximum.
Definition TimePeriodInfo.hpp:16
constexpr std::int64_t getMin() const noexcept
Returns the minimum period in milliseconds.
Definition TimePeriodInfo.hpp:53
Value class for a period of time with support for ISO8601 duration format.
Definition TimePeriod.hpp:29
static const TimePeriod UNLIMITED
Time-period of "infinity" (time of std::numeric_limits<std::int64_t>::max() or LLONG_MAX).
Definition TimePeriod.hpp:15
static TimePeriod valueOf(std::chrono::milliseconds value)
Returns TimePeriod with value milliseconds.
Definition TimePeriod.cpp:21
std::int64_t getNanos() const
Returns value in nanoseconds.
Definition TimePeriod.cpp:37
static const TimePeriod ZERO
Time-period of zero.
Definition TimePeriod.hpp:14
std::int32_t getSeconds() const
Returns value in seconds.
Definition TimePeriod.cpp:33
std::int64_t getTime() const
Returns value in milliseconds.
Definition TimePeriod.cpp:29
TimePeriod(ConstructionKey, JavaObjectHandle< TimePeriod > &&handle)
Not a part of the API: it lets std::optional<TimePeriod> create the value in place (TimePeriod can no...
Definition TimePeriod.cpp:44
Represents time-series snapshots of some process that is evolving in time or actual events in some ex...
Definition TimeSeriesEvent.hpp:84
Mixin for wrapping Promise method calls for a void.
Definition Promise.hpp:196
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:226
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:241
void await() const
Wait for the computation to complete and return its result or throw an exception in case of exception...
Definition Promise.hpp:211
void getResult() const
Returns result of computation.
Definition Promise.hpp:202
Whether T is std::shared_ptr<E>, where E is a descendant of LastingEvent (the elements of DXFeed::get...
Definition DXFeed.hpp:39
The simple key-value structure that represents an endpoint's property.
Definition api.h:196
const char * key
The property's key.
Definition api.h:198
const char * value
The property's value.
Definition api.h:200