From b8888c72aded3a92150c013ff6b77d6f3431aab6 Mon Sep 17 00:00:00 2001 From: Anatoly Kalin Date: Wed, 10 Jul 2024 18:59:09 +0300 Subject: [PATCH] [MDAPI-26] Update Graal SDK to v1.1.21 DXFeedSubscription::getAggregationPeriod DXFeedSubscription::setAggregationPeriod --- .../api/DXFeedSubscription.hpp | 452 ++++++++++-------- .../api/IsolatedDXFeedSubscription.hpp | 131 ++--- .../dxfeed_graal_cpp_api/util/TimePeriod.hpp | 4 + src/api/DXFeedSubscription.cpp | 102 ++-- .../api/IsolatedDXFeedSubscription.cpp | 140 +++--- 5 files changed, 468 insertions(+), 361 deletions(-) diff --git a/include/dxfeed_graal_cpp_api/api/DXFeedSubscription.hpp b/include/dxfeed_graal_cpp_api/api/DXFeedSubscription.hpp index ce23424a..3b939a72 100644 --- a/include/dxfeed_graal_cpp_api/api/DXFeedSubscription.hpp +++ b/include/dxfeed_graal_cpp_api/api/DXFeedSubscription.hpp @@ -19,6 +19,8 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) #include "../internal/JavaObjectHandle.hpp" #include "../symbols/SymbolWrapper.hpp" +#include "../util/TimePeriod.hpp" + #include #include #include @@ -67,12 +69,10 @@ class DXFCPP_EXPORT DXFeedSubscription : public RequireMakeShared; @@ -234,6 +234,15 @@ class DXFCPP_EXPORT DXFeedSubscription : public RequireMakeShared feed); + /** + * Returns `true` if this subscription is closed. + * + * @return `true` if this subscription is closed. + * + * @see DXFeedSubscription::close() + */ + bool isClosed() override; + /** * Closes this subscription and makes it permanently detached. * This method notifies all installed instances of subscription change listeners by invoking `subscriptionClosed` @@ -244,158 +253,105 @@ class DXFCPP_EXPORT DXFeedSubscription : public RequireMakeSharedgetFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE}); + * Returns a set of subscribed event types. * - * sub->addEventListener([](auto &&events) { - * for (const auto &e : events) { - * if (auto quote = e->template sharedAs(); quote) { - * std::cout << "Q : " + quote->toString() << std::endl; - * } else if (auto tns = e->template sharedAs(); tns) { - * std::cout << "TnS : " + tns->toString() << std::endl; - * } - * } - * }); + * @return A set of subscribed event types. + */ + std::unordered_set getEventTypes() override; + + /** + * Returns `true` if this subscription contains the corresponding event type. * - * sub->addSymbols({"$TOP10L/Q", "$SP500#45", "$TICK", "SPX"}); - * ``` + * @param eventType The type of event that is checked. + * @return `true` if this subscription contains the corresponding event type. * - * @tparam EventListener The listener type. Listener can be callable with signature: `void(const - * std::vector&)` - * @param listener The event listener - * @return The listener id + * @see DXFeedSubscription::getEventTypes() */ - template - std::size_t addEventListener(EventListener &&listener) -#if __cpp_concepts - requires requires { - { listener(std::vector>{}) } -> std::same_as; - } -#endif - { - if (!tryToSetEventListenerHandle()) { - return OnEventHandler::FAKE_ID; - } + bool containsEventType(const EventTypeEnum &eventType) override; - return onEvent_ += listener; - } + /** + * Clears the set of subscribed symbols. + */ + void clear() const; /** - * Adds typed listener for events. - * Event lister can be added only when subscription is not producing any events. - * The subscription must be either empty - * (its set of @ref DXFeedSubscription::getSymbols() "symbols" is empty or not @ref DXFeedSubscription::attach() - * "attached" to any feed (its set of change listeners is empty). + * Returns a set of subscribed symbols (depending on the actual implementation of subscription). * - * This method does nothing if this subscription is closed. + * The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a + * weakly consistent view of the set. * - * Example: - * ```cpp - * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE}); + * @return A set of subscribed symbols. + */ + std::vector getSymbols() const; + + /** + * Returns a set of decorated symbols (depending on the actual implementation of subscription). * - * sub->addEventListener(std::function([](const std::vector> "es) -> void { - * for (const auto &q : quotes) { - * std::cout << "Q : " + q->toString() << std::endl; - * } - * })); + * The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a + * weakly consistent view of the set. * - * sub->addEventListener([](const auto &timeAndSales) -> void { - * for (const auto &tns : timeAndSales) { - * std::cout << "TnS : " + tns->toString() << std::endl; - * } - * }); + * @return A set of decorated subscribed symbols. + */ + std::vector getDecoratedSymbols() const; + + /** + * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (using + * iterators). * - * sub->addEventListener([](const auto &marketEvents) -> void { - * for (const auto &me : marketEvents) { - * std::cout << "Market Event's symbol: " + me->getEventSymbol() << std::endl; - * } - * }); + * Example: + * ```cpp + * auto v = std::vector{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s}; * - * sub->addSymbols({"$TOP10L/Q", "AAPL", "$TICK", "SPX"}); + * sub->setSymbols(v.begin(), v.end()); * ``` * - * @tparam EventT The event type (EventType's child with field TYPE, convertible to EventTypeEnum or MarketEvent or - * LastingEvent or TimeSeriesEvent or IndexedEvent) - * @param listener The listener. Listener can be callable with signature: `void(const - * std::vector&)` - * @return The listener id + * @tparam SymbolIt The collection's iterator type + * @param begin The beginning of the collection of symbols. + * @param end The end of symbol collection. */ - template - std::size_t addEventListener(std::function> &)> &&listener) -#if __cpp_concepts - requires std::is_base_of_v && - (requires { - { EventT::TYPE } -> dxfcpp::ConvertibleTo; - } || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v) -#endif - { - if (!tryToSetEventListenerHandle()) { - return SimpleHandler> &)>::FAKE_ID; + template void setSymbols(SymbolIt begin, SymbolIt end) const { + if constexpr (Debugger::isDebug) { + // ReSharper disable once CppDFAUnreachableCode + Debugger::debug(toString() + "::setSymbols(symbols = " + elementsToString(begin, end) + ")"); } - return onEvent_ += [l = listener](auto &&events) { - std::vector> filteredEvents{}; - - filteredEvents.reserve(events.size()); - - for (const auto &e : events) { - if (auto expected = e->template sharedAs(); expected) { - filteredEvents.emplace_back(expected); - } - } + auto *list = SymbolWrapper::SymbolListUtils::toGraalList(begin, end); - l(filteredEvents); - }; + setSymbolsImpl(list); + SymbolWrapper::SymbolListUtils::freeGraalList(list); } /** - * Removes listener for events. + * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection. * * Example: * ```cpp - * auto id = sub->addEventListener([](auto){}); + * auto v = std::vector{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s}; * - * sub->removeEventListener(id); + * sub->setSymbols(std::vector{"AAPL", "IBM"}); + * sub->setSymbols(v); * ``` * - * @param listenerId The listener id + * @tparam SymbolsCollection The symbols collection's type + * @param collection The symbols collection */ - void removeEventListener(std::size_t listenerId); + template + void setSymbols(SymbolsCollection &&collection) const { + setSymbols(std::begin(collection), std::end(collection)); + } /** - * Returns a reference to an incoming events' handler (delegate), to which listeners can be added and removed. - * Listener can be callable with signature: `void(const std::vector&)` + * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection + * (initializer list). * * Example: * ```cpp - * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE}); - * auto id = sub->onEvent() += [](auto &&events) { - * for (const auto &e : events) { - * if (auto quote = e->template sharedAs(); quote) { - * std::cout << "Q : " + quote->toString() << std::endl; - * } else if (auto tns = e->template sharedAs(); tns) { - * std::cout << "TnS : " + tns->toString() << std::endl; - * } - * } - * }; - * - * sub->addSymbols({"$TOP10L/Q", "$SP500#45", "$TICK", "SPX"}); - * sub->onEvent() -= id; + * sub->setSymbols({"AAPL", "IBM"sv, "TSLA"s, "GOOG"_s}); * ``` * - * @return The incoming events' handler (delegate) + * @param collection The symbols collection */ - OnEventHandler &onEvent(); + void setSymbols(std::initializer_list collection) const; /** * Adds the specified symbol to the set of subscribed symbols. @@ -415,22 +371,6 @@ class DXFCPP_EXPORT DXFeedSubscription : public RequireMakeSharedremoveSymbols("TSLA"); - * sub->removeSymbols("XBT/USD:GDAX"s); - * sub->removeSymbols("BTC/EUR:CXBITF"sv); - * ``` - * - * @param symbolWrapper The symbol. - */ - void removeSymbols(const SymbolWrapper &symbolWrapper) const; - /** * Adds the specified collection (using iterators) of symbols to the set of subscribed symbols. * @@ -488,6 +428,22 @@ class DXFCPP_EXPORT DXFeedSubscription : public RequireMakeShared collection) const; + /** + * Removes the specified symbol from the set of subscribed symbols. + * To conveniently remove one or few symbols you can use @ref DXFeedSubscription::removeSymbols(const + * SymbolsCollection &collection) "removeSymbols(symbols)" method. + * + * Example: + * ```cpp + * sub->removeSymbols("TSLA"); + * sub->removeSymbols("XBT/USD:GDAX"s); + * sub->removeSymbols("BTC/EUR:CXBITF"sv); + * ``` + * + * @param symbolWrapper The symbol. + */ + void removeSymbols(const SymbolWrapper &symbolWrapper) const; + /** * Removes the specified collection (using iterators) of symbols from the set of subscribed symbols. * @@ -546,114 +502,202 @@ class DXFCPP_EXPORT DXFeedSubscription : public RequireMakeShared collection) const; /** - * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (using - * iterators). + * Returns the aggregation period for data for this subscription instance. * - * Example: - * ```cpp - * auto v = std::vector{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s}; - * - * sub->setSymbols(v.begin(), v.end()); - * ``` + * @return The aggregation period for data, represented as a TimePeriod object. + */ + TimePeriod getAggregationPeriod() const; + + /** + * Sets the aggregation period for data. + * This method sets a new aggregation period for data, which will only take effect on the next iteration of + * data notification. For example, if the current aggregation period is 5 seconds and it is changed + * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which + * the new aggregation period will take effect. * - * @tparam SymbolIt The collection's iterator type - * @param begin The beginning of the collection of symbols. - * @param end The end of symbol collection. + * @param aggregationPeriod the new aggregation period for data */ - template void setSymbols(SymbolIt begin, SymbolIt end) const { - if constexpr (Debugger::isDebug) { - // ReSharper disable once CppDFAUnreachableCode - Debugger::debug(toString() + "::setSymbols(symbols = " + elementsToString(begin, end) + ")"); - } + void setAggregationPeriod(const TimePeriod &aggregationPeriod) const; - auto *list = SymbolWrapper::SymbolListUtils::toGraalList(begin, end); + /** + * Sets the aggregation period for data. + * This method sets a new aggregation period for data, which will only take effect on the next iteration of + * data notification. For example, if the current aggregation period is 5 seconds and it is changed + * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which + * the new aggregation period will take effect. + * + * @param aggregationPeriod the new aggregation period (in millis) for data + */ + void setAggregationPeriod(std::chrono::milliseconds aggregationPeriod) const { + return setAggregationPeriod(TimePeriod::valueOf(aggregationPeriod)); + } - setSymbolsImpl(list); - SymbolWrapper::SymbolListUtils::freeGraalList(list); + /** + * Sets the aggregation period for data. + * This method sets a new aggregation period for data, which will only take effect on the next iteration of + * data notification. For example, if the current aggregation period is 5 seconds and it is changed + * to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which + * the new aggregation period will take effect. + * + * @param aggregationPeriod the new aggregation period (in millis) for data + */ + void setAggregationPeriod(std::int64_t aggregationPeriod) const { + return setAggregationPeriod(TimePeriod::valueOf(aggregationPeriod)); } /** - * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection. + * Adds listener for events. + * Event lister can be added only when subscription is not producing any events. + * The subscription must be either empty + * (its set of @ref DXFeedSubscription::getSymbols() "symbols" is empty or not @ref DXFeedSubscription::attach() + * "attached" to any feed (its set of change listeners is empty). + * + * This method does nothing if this subscription is closed. * * Example: * ```cpp - * auto v = std::vector{"XBT/USD:GDAX"s, "BTC/EUR:CXBITF"sv, "TSLA", "GOOG"_s}; + * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE}); * - * sub->setSymbols(std::vector{"AAPL", "IBM"}); - * sub->setSymbols(v); + * sub->addEventListener([](auto &&events) { + * for (const auto &e : events) { + * if (auto quote = e->template sharedAs(); quote) { + * std::cout << "Q : " + quote->toString() << std::endl; + * } else if (auto tns = e->template sharedAs(); tns) { + * std::cout << "TnS : " + tns->toString() << std::endl; + * } + * } + * }); + * + * sub->addSymbols({"$TOP10L/Q", "$SP500#45", "$TICK", "SPX"}); * ``` * - * @tparam SymbolsCollection The symbols collection's type - * @param collection The symbols collection + * @tparam EventListener The listener type. Listener can be callable with signature: `void(const + * std::vector&)` + * @param listener The event listener + * @return The listener id */ - template - void setSymbols(SymbolsCollection &&collection) const { - setSymbols(std::begin(collection), std::end(collection)); + template + std::size_t addEventListener(EventListener &&listener) +#if __cpp_concepts + requires requires { + { listener(std::vector>{}) } -> std::same_as; + } +#endif + { + if (!tryToSetEventListenerHandle()) { + return OnEventHandler::FAKE_ID; + } + + return onEvent_ += listener; } /** - * Changes the set of subscribed symbols so that it contains just the symbols from the specified collection - * (initializer list). + * Adds typed listener for events. + * Event lister can be added only when subscription is not producing any events. + * The subscription must be either empty + * (its set of @ref DXFeedSubscription::getSymbols() "symbols" is empty or not @ref DXFeedSubscription::attach() + * "attached" to any feed (its set of change listeners is empty). + * + * This method does nothing if this subscription is closed. * * Example: * ```cpp - * sub->setSymbols({"AAPL", "IBM"sv, "TSLA"s, "GOOG"_s}); + * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE}); + * + * sub->addEventListener(std::function([](const std::vector> "es) -> void { + * for (const auto &q : quotes) { + * std::cout << "Q : " + q->toString() << std::endl; + * } + * })); + * + * sub->addEventListener([](const auto &timeAndSales) -> void { + * for (const auto &tns : timeAndSales) { + * std::cout << "TnS : " + tns->toString() << std::endl; + * } + * }); + * + * sub->addEventListener([](const auto &marketEvents) -> void { + * for (const auto &me : marketEvents) { + * std::cout << "Market Event's symbol: " + me->getEventSymbol() << std::endl; + * } + * }); + * + * sub->addSymbols({"$TOP10L/Q", "AAPL", "$TICK", "SPX"}); * ``` * - * @param collection The symbols collection + * @tparam EventT The event type (EventType's child with field TYPE, convertible to EventTypeEnum or MarketEvent + * or LastingEvent or TimeSeriesEvent or IndexedEvent) + * @param listener The listener. Listener can be callable with signature: `void(const + * std::vector&)` + * @return The listener id */ - void setSymbols(std::initializer_list collection) const; + template + std::size_t addEventListener(std::function> &)> &&listener) +#if __cpp_concepts + requires std::is_base_of_v && + (requires { + { EventT::TYPE } -> dxfcpp::ConvertibleTo; + } || std::is_same_v || std::is_same_v || + std::is_same_v || std::is_same_v) +#endif + { + if (!tryToSetEventListenerHandle()) { + return SimpleHandler> &)>::FAKE_ID; + } - /** - * Clears the set of subscribed symbols. - */ - void clear() const; + return onEvent_ += [l = listener](auto &&events) { + std::vector> filteredEvents{}; - /** - * Returns `true` if this subscription is closed. - * - * @return `true` if this subscription is closed. - * - * @see DXFeedSubscription::close() - */ - bool isClosed() override; + filteredEvents.reserve(events.size()); - /** - * Returns a set of subscribed event types. - * - * @return A set of subscribed event types. - */ - std::unordered_set getEventTypes() override; + for (const auto &e : events) { + if (auto expected = e->template sharedAs(); expected) { + filteredEvents.emplace_back(expected); + } + } - /** - * Returns `true` if this subscription contains the corresponding event type. - * - * @param eventType The type of event that is checked. - * @return `true` if this subscription contains the corresponding event type. - * - * @see DXFeedSubscription::getEventTypes() - */ - bool containsEventType(const EventTypeEnum &eventType) override; + l(filteredEvents); + }; + } /** - * Returns a set of subscribed symbols (depending on the actual implementation of subscription). + * Removes listener for events. * - * The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a - * weakly consistent view of the set. + * Example: + * ```cpp + * auto id = sub->addEventListener([](auto){}); * - * @return A set of subscribed symbols. + * sub->removeEventListener(id); + * ``` + * + * @param listenerId The listener id */ - std::vector getSymbols() const; + void removeEventListener(std::size_t listenerId); /** - * Returns a set of decorated symbols (depending on the actual implementation of subscription). + * Returns a reference to an incoming events' handler (delegate), to which listeners can be added and removed. + * Listener can be callable with signature: `void(const std::vector&)` * - * The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a - * weakly consistent view of the set. + * Example: + * ```cpp + * auto sub = endpoint->getFeed()->createSubscription({dxfcpp::Quote::TYPE, dxfcpp::TimeAndSale::TYPE}); + * auto id = sub->onEvent() += [](auto &&events) { + * for (const auto &e : events) { + * if (auto quote = e->template sharedAs(); quote) { + * std::cout << "Q : " + quote->toString() << std::endl; + * } else if (auto tns = e->template sharedAs(); tns) { + * std::cout << "TnS : " + tns->toString() << std::endl; + * } + * } + * }; * - * @return A set of decorated subscribed symbols. + * sub->addSymbols({"$TOP10L/Q", "$SP500#45", "$TICK", "SPX"}); + * sub->onEvent() -= id; + * ``` + * + * @return The incoming events' handler (delegate) */ - std::vector getDecoratedSymbols() const; + OnEventHandler &onEvent(); std::size_t addChangeListener(std::shared_ptr listener) override; diff --git a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp index 1bd18a5e..73e080cb 100644 --- a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp @@ -7,12 +7,12 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) -#include - #include "../../api/DXFeedSubscription.hpp" DXFCPP_BEGIN_NAMESPACE +struct TimePeriod; + namespace isolated::api::IsolatedDXFeedSubscription { /** @@ -37,6 +37,21 @@ create(/* dxfg_event_clazz_t */ const EventTypeEnum &eventType); JavaObjectHandle /* dxfg_subscription_t* */ create(/* dxfg_event_clazz_list_t * */ const std::unique_ptr &eventClassList); +// int32_t dxfg_DXFeedSubscription_attach(graal_isolatethread_t *thread, dxfg_subscription_t *sub, dxfg_feed_t *feed); + +// int32_t dxfg_DXFeedSubscription_detach(graal_isolatethread_t *thread, dxfg_subscription_t *sub, dxfg_feed_t *feed); + +/** + * Calls the Graal SDK function `dxfg_DXFeedSubscription_isClosed` in isolation. + * + * @param sub The subscription's handle. + * @return `true` if subscription is closed. + * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. + * @throws JavaException if something happened with the dxFeed API backend. + * @throws GraalException if something happened with the GraalVM. + */ +bool /* int32_t */ isClosed(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); + /** * Calls the Graal SDK function `dxfg_DXFeedSubscription_close` in isolation. * @@ -47,36 +62,48 @@ create(/* dxfg_event_clazz_list_t * */ const std::unique_ptr &ev */ void /* int32_t */ close(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); +// dxfg_event_clazz_list_t* dxfg_DXFeedSubscription_getEventTypes(graal_isolatethread_t *thread, dxfg_subscription_t +// *sub); + +// int32_t dxfg_DXFeedSubscription_containsEventType(graal_isolatethread_t *thread, dxfg_subscription_t *sub, +// dxfg_event_clazz_t eventClazz); + /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_addEventListener` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_clear` in isolation. * * @param sub The subscription's handle. - * @param listener The listener's handle. - * @throws std::invalid_argument if DXFeedSubscription's or DXFeedEventListener's handle is invalid. + * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -void /* int32_t */ -addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, - /* dxfg_feed_event_listener_t * */ const JavaObjectHandle &listener); +void /* int32_t */ clear(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); -// int32_t dxfg_DXFeedSubscription_removeEventListener(graal_isolatethread_t *thread, dxfg_subscription_t *sub, -// dxfg_feed_event_listener_t *listener); +/** + * Calls the Graal SDK function `dxfg_DXFeedSubscription_getSymbols` in isolation. + * + * @param sub The subscription's handle. + * @return The subscription's symbols. + * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. + * @throws JavaException if something happened with the dxFeed API backend. + * @throws GraalException if something happened with the GraalVM. + */ +std::vector /* dxfg_symbol_list* */ getSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbol` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_getDecoratedSymbols` in isolation. * * @param sub The subscription's handle. - * @param symbol The subscription's symbol. - * @throws std::invalid_argument if DXFeedSubscription's handle is invalid or the symbol is nullptr. + * @return The subscription's decorated symbols. + * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, - /* dxfg_symbol_t * */ void *symbol); +std::vector /* dxfg_symbol_list* */ getDecoratedSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); + +// int32_t dxfg_DXFeedSubscription_setSymbol(graal_isolatethread_t *thread, dxfg_subscription_t *sub, dxfg_symbol_t *symbol); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbols` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_setSymbols` in isolation. * * @param sub The subscription's handle. * @param symbols The subscription's symbols. @@ -84,11 +111,10 @@ void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle< * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, - /* dxfg_symbol_list * */ void *symbols); +void /* int32_t */ setSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_list * */ void* symbols); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_removeSymbol` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbol` in isolation. * * @param sub The subscription's handle. * @param symbol The subscription's symbol. @@ -96,11 +122,11 @@ void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -void /* int32_t */ removeSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, - /* dxfg_symbol_t * */ void *symbol); +void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_t * */ void *symbol); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_removeSymbols` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbols` in isolation. * * @param sub The subscription's handle. * @param symbols The subscription's symbols. @@ -108,78 +134,73 @@ void /* int32_t */ removeSymbol(/* dxfg_subscription_t * */ const JavaObjectHand * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -void /* int32_t */ removeSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, - /* dxfg_symbol_list * */ void *symbols); +void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_list * */ void *symbols); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_clear` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_removeSymbol` in isolation. * * @param sub The subscription's handle. - * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. + * @param symbol The subscription's symbol. + * @throws std::invalid_argument if DXFeedSubscription's handle is invalid or the symbol is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -void /* int32_t */ clear(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); - -// int32_t dxfg_DXFeedSubscription_attach(graal_isolatethread_t *thread, dxfg_subscription_t *sub, dxfg_feed_t *feed); - -// int32_t dxfg_DXFeedSubscription_detach(graal_isolatethread_t *thread, dxfg_subscription_t *sub, dxfg_feed_t *feed); +void /* int32_t */ removeSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_t * */ void *symbol); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_isClosed` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_removeSymbols` in isolation. * * @param sub The subscription's handle. - * @return `true` if subscription is closed. - * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. + * @param symbols The subscription's symbols. + * @throws std::invalid_argument if DXFeedSubscription's handle is invalid or the symbols is nullptr. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -bool /* int32_t */ isClosed(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); +void /* int32_t */ removeSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_list * */ void *symbols); -// dxfg_event_clazz_list_t* dxfg_DXFeedSubscription_getEventTypes(graal_isolatethread_t *thread, dxfg_subscription_t -// *sub); +// dxfg_executor_t* dxfg_DXFeedSubscription_getExecutor(graal_isolatethread_t *thread, dxfg_subscription_t *sub); -// int32_t dxfg_DXFeedSubscription_containsEventType(graal_isolatethread_t *thread, dxfg_subscription_t *sub, -// dxfg_event_clazz_t eventClazz); +// int32_t dxfg_DXFeedSubscription_setExecutor(graal_isolatethread_t *thread, dxfg_executor_t *executor); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_getSymbols` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_getAggregationPeriod` in isolation. * * @param sub The subscription's handle. - * @return The subscription's symbols. * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -std::vector /* dxfg_symbol_list* */ getSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); - -// int32_t dxfg_DXFeedSubscription_setSymbol(graal_isolatethread_t *thread, dxfg_subscription_t *sub, dxfg_symbol_t *symbol); +/* dxfg_time_period_t* */ JavaObjectHandle getAggregationPeriod(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_setSymbols` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_setAggregationPeriod` in isolation. * * @param sub The subscription's handle. - * @param symbols The subscription's symbols. - * @throws std::invalid_argument if DXFeedSubscription's handle is invalid or the symbols is nullptr. + * @param period The period's handle. + * @throws std::invalid_argument if DXFeedSubscription's handle or period's handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -void /* int32_t */ setSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_list * */ void* symbols); +/* int32_t */ void setAggregationPeriod(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_time_period_t * */ const JavaObjectHandle& period); /** - * Calls the Graal SDK function `dxfg_DXFeedSubscription_getDecoratedSymbols` in isolation. + * Calls the Graal SDK function `dxfg_DXFeedSubscription_addEventListener` in isolation. * * @param sub The subscription's handle. - * @return The subscription's decorated symbols. - * @throws std::invalid_argument if DXFeedSubscription's handle is invalid. + * @param listener The listener's handle. + * @throws std::invalid_argument if DXFeedSubscription's or DXFeedEventListener's handle is invalid. * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -std::vector /* dxfg_symbol_list* */ getDecoratedSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub); - -// dxfg_executor_t* dxfg_DXFeedSubscription_getExecutor(graal_isolatethread_t *thread, dxfg_subscription_t *sub); +void /* int32_t */ +addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_feed_event_listener_t * */ const JavaObjectHandle &listener); -// int32_t dxfg_DXFeedSubscription_setExecutor(graal_isolatethread_t *thread, dxfg_executor_t *executor); +// int32_t dxfg_DXFeedSubscription_removeEventListener(graal_isolatethread_t *thread, dxfg_subscription_t *sub, +// dxfg_feed_event_listener_t *listener); /** * Calls the Graal SDK function `dxfg_DXFeedSubscription_addChangeListener` in isolation. diff --git a/include/dxfeed_graal_cpp_api/util/TimePeriod.hpp b/include/dxfeed_graal_cpp_api/util/TimePeriod.hpp index 70380a92..d181aadc 100644 --- a/include/dxfeed_graal_cpp_api/util/TimePeriod.hpp +++ b/include/dxfeed_graal_cpp_api/util/TimePeriod.hpp @@ -11,10 +11,14 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) DXFCPP_BEGIN_NAMESPACE +class DXFeedSubscription; + /** * Value class for period of time with support for ISO8601 duration format. */ struct DXFCPP_EXPORT TimePeriod { + friend DXFeedSubscription; + /// Time-period of zero. static const TimePeriod ZERO; diff --git a/src/api/DXFeedSubscription.cpp b/src/api/DXFeedSubscription.cpp index 3ce0dc80..933dec71 100644 --- a/src/api/DXFeedSubscription.cpp +++ b/src/api/DXFeedSubscription.cpp @@ -57,6 +57,10 @@ bool DXFeedSubscription::tryToSetEventListenerHandle() { return true; } +void DXFeedSubscription::setSymbolsImpl(void *graalSymbolList) const { + isolated::api::IsolatedDXFeedSubscription::setSymbols(handle_, graalSymbolList); +} + void DXFeedSubscription::addSymbolsImpl(void *graalSymbolList) const { isolated::api::IsolatedDXFeedSubscription::addSymbols(handle_, graalSymbolList); } @@ -65,10 +69,6 @@ void DXFeedSubscription::removeSymbolsImpl(void *graalSymbolList) const { isolated::api::IsolatedDXFeedSubscription::removeSymbols(handle_, graalSymbolList); } -void DXFeedSubscription::setSymbolsImpl(void *graalSymbolList) const { - isolated::api::IsolatedDXFeedSubscription::setSymbols(handle_, graalSymbolList); -} - DXFeedSubscription::DXFeedSubscription(LockExternalConstructionTag) : impl_(std::make_unique()) { } @@ -135,6 +135,15 @@ void DXFeedSubscription::detach(std::shared_ptr feed) { feed->detachSubscription(sharedAs()); } +bool DXFeedSubscription::isClosed() { + if constexpr (Debugger::isDebug) { + // ReSharper disable once CppDFAUnreachableCode + Debugger::debug(toString() + "::isClosed()"); + } + + return isolated::api::IsolatedDXFeedSubscription::isClosed(handle_); +} + void DXFeedSubscription::close() const { if constexpr (Debugger::isDebug) { // ReSharper disable once CppDFAUnreachableCode @@ -144,92 +153,91 @@ void DXFeedSubscription::close() const { isolated::api::IsolatedDXFeedSubscription::close(handle_); } -void DXFeedSubscription::removeEventListener(std::size_t listenerId) { - onEvent_ -= listenerId; +std::unordered_set DXFeedSubscription::getEventTypes() { + return eventTypes_; } -DXFeedSubscription::OnEventHandler &DXFeedSubscription::onEvent() { - tryToSetEventListenerHandle(); - - return onEvent_; +bool DXFeedSubscription::containsEventType(const EventTypeEnum &eventType) { + return eventTypes_.contains(eventType); } -void DXFeedSubscription::addSymbols(const SymbolWrapper &symbolWrapper) const { +void DXFeedSubscription::clear() const { if constexpr (Debugger::isDebug) { // ReSharper disable once CppDFAUnreachableCode - Debugger::debug(toString() + "::addSymbols(symbolWrapper = " + toStringAny(symbolWrapper) + ")"); + Debugger::debug(toString() + "::clear()"); } - auto graal = symbolWrapper.toGraalUnique(); - - isolated::api::IsolatedDXFeedSubscription::addSymbol(handle_, graal.get()); + isolated::api::IsolatedDXFeedSubscription::clear(handle_); } -void DXFeedSubscription::removeSymbols(const SymbolWrapper &symbolWrapper) const { +std::vector DXFeedSubscription::getSymbols() const { if constexpr (Debugger::isDebug) { // ReSharper disable once CppDFAUnreachableCode - Debugger::debug(toString() + "::removeSymbols(symbolWrapper = " + toStringAny(symbolWrapper) + ")"); + Debugger::debug(toString() + "::getSymbols()"); } - auto graal = symbolWrapper.toGraalUnique(); - - isolated::api::IsolatedDXFeedSubscription::removeSymbol(handle_, graal.get()); + return isolated::api::IsolatedDXFeedSubscription::getSymbols(handle_); } -void DXFeedSubscription::addSymbols(std::initializer_list collection) const { - addSymbols(collection.begin(), collection.end()); -} +std::vector DXFeedSubscription::getDecoratedSymbols() const { + if constexpr (Debugger::isDebug) { + // ReSharper disable once CppDFAUnreachableCode + Debugger::debug(toString() + "::getDecoratedSymbols()"); + } -void DXFeedSubscription::removeSymbols(std::initializer_list collection) const { - removeSymbols(collection.begin(), collection.end()); + return isolated::api::IsolatedDXFeedSubscription::getDecoratedSymbols(handle_); } void DXFeedSubscription::setSymbols(std::initializer_list collection) const { setSymbols(collection.begin(), collection.end()); } -void DXFeedSubscription::clear() const { +void DXFeedSubscription::addSymbols(const SymbolWrapper &symbolWrapper) const { if constexpr (Debugger::isDebug) { // ReSharper disable once CppDFAUnreachableCode - Debugger::debug(toString() + "::clear()"); + Debugger::debug(toString() + "::addSymbols(symbolWrapper = " + toStringAny(symbolWrapper) + ")"); } - isolated::api::IsolatedDXFeedSubscription::clear(handle_); + auto graal = symbolWrapper.toGraalUnique(); + + isolated::api::IsolatedDXFeedSubscription::addSymbol(handle_, graal.get()); } -bool DXFeedSubscription::isClosed() { +void DXFeedSubscription::addSymbols(std::initializer_list collection) const { + addSymbols(collection.begin(), collection.end()); +} + +void DXFeedSubscription::removeSymbols(const SymbolWrapper &symbolWrapper) const { if constexpr (Debugger::isDebug) { // ReSharper disable once CppDFAUnreachableCode - Debugger::debug(toString() + "::isClosed()"); + Debugger::debug(toString() + "::removeSymbols(symbolWrapper = " + toStringAny(symbolWrapper) + ")"); } - return isolated::api::IsolatedDXFeedSubscription::isClosed(handle_); + auto graal = symbolWrapper.toGraalUnique(); + + isolated::api::IsolatedDXFeedSubscription::removeSymbol(handle_, graal.get()); } -std::unordered_set DXFeedSubscription::getEventTypes() { - return eventTypes_; +void DXFeedSubscription::removeSymbols(std::initializer_list collection) const { + removeSymbols(collection.begin(), collection.end()); } -bool DXFeedSubscription::containsEventType(const EventTypeEnum &eventType) { - return eventTypes_.contains(eventType); +TimePeriod DXFeedSubscription::getAggregationPeriod() const { + return TimePeriod(isolated::api::IsolatedDXFeedSubscription::getAggregationPeriod(handle_)); } -std::vector DXFeedSubscription::getSymbols() const { - if constexpr (Debugger::isDebug) { - // ReSharper disable once CppDFAUnreachableCode - Debugger::debug(toString() + "::getSymbols()"); - } +void DXFeedSubscription::setAggregationPeriod(const TimePeriod &aggregationPeriod) const { + isolated::api::IsolatedDXFeedSubscription::setAggregationPeriod(handle_, aggregationPeriod.handle_); +} - return isolated::api::IsolatedDXFeedSubscription::getSymbols(handle_); +void DXFeedSubscription::removeEventListener(std::size_t listenerId) { + onEvent_ -= listenerId; } -std::vector DXFeedSubscription::getDecoratedSymbols() const { - if constexpr (Debugger::isDebug) { - // ReSharper disable once CppDFAUnreachableCode - Debugger::debug(toString() + "::getDecoratedSymbols()"); - } +DXFeedSubscription::OnEventHandler &DXFeedSubscription::onEvent() { + tryToSetEventListenerHandle(); - return isolated::api::IsolatedDXFeedSubscription::getDecoratedSymbols(handle_); + return onEvent_; } std::size_t DXFeedSubscription::addChangeListener(std::shared_ptr listener) { diff --git a/src/isolated/api/IsolatedDXFeedSubscription.cpp b/src/isolated/api/IsolatedDXFeedSubscription.cpp index a76c818d..0d64b395 100644 --- a/src/isolated/api/IsolatedDXFeedSubscription.cpp +++ b/src/isolated/api/IsolatedDXFeedSubscription.cpp @@ -9,7 +9,6 @@ DXFCPP_BEGIN_NAMESPACE namespace isolated::api::IsolatedDXFeedSubscription { - JavaObjectHandle /* dxfg_subscription_t* */ create(/* dxfg_event_clazz_t */ const EventTypeEnum &eventType) { return JavaObjectHandle(runGraalFunctionAndThrowIfNullptr( @@ -26,6 +25,16 @@ create(/* dxfg_event_clazz_list_t * */ const std::unique_ptr &ev dxfg_DXFeedSubscription_new2, static_cast(eventClassList->getHandle()))); } +bool /* int32_t */ isClosed(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { + if (!sub) { + throw std::invalid_argument( + "Unable to execute function `dxfg_DXFeedSubscription_isClosed`. The `sub` handle is invalid"); + } + + return runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_isClosed, + static_cast(sub.get())) == 1; +} + void /* int32_t */ close(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { throw std::invalid_argument( @@ -36,22 +45,65 @@ void /* int32_t */ close(/* dxfg_subscription_t * */ const JavaObjectHandle(sub.get())); } -void /* int32_t */ -addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, - /* dxfg_feed_event_listener_t * */ const JavaObjectHandle &listener) { +void /* int32_t */ clear(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { throw std::invalid_argument( - "Unable to execute function `dxfg_DXFeedSubscription_addEventListener`. The `sub` handle is invalid"); + "Unable to execute function `dxfg_DXFeedSubscription_clear`. The `sub` handle is invalid"); } - if (!listener) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_addEventListener`. The " - "`listener` handle is invalid"); + runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_clear, + static_cast(sub.get())); +} + +std::vector /* dxfg_symbol_list* */ +getSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { + if (!sub) { + throw std::invalid_argument( + "Unable to execute function `dxfg_DXFeedSubscription_getSymbols`. The `sub` handle is invalid"); } - runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_addEventListener, + dxfg_symbol_list *list = runGraalFunctionAndThrowIfNullptr(dxfg_DXFeedSubscription_getSymbols, + static_cast(sub.get())); + + auto result = SymbolWrapper::SymbolListUtils::fromGraalList(static_cast(list)); + + runGraalFunctionAndThrowIfLessThanZero(dxfg_CList_symbol_release, list); + + return result; +} + +std::vector /* dxfg_symbol_list* */ +getDecoratedSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { + if (!sub) { + throw std::invalid_argument( + "Unable to execute function `dxfg_DXFeedSubscription_getDecoratedSymbols`. The `sub` handle is invalid"); + } + + dxfg_symbol_list *list = runGraalFunctionAndThrowIfNullptr(dxfg_DXFeedSubscription_getDecoratedSymbols, + static_cast(sub.get())); + + auto result = SymbolWrapper::SymbolListUtils::fromGraalList(static_cast(list)); + + runGraalFunctionAndThrowIfLessThanZero(dxfg_CList_symbol_release, list); + + return result; +} + +void /* int32_t */ setSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_list * */ void *symbols) { + if (!sub) { + throw std::invalid_argument( + "Unable to execute function `dxfg_DXFeedSubscription_setSymbols`. The `sub` handle is invalid"); + } + + if (!symbols) { + throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_setSymbols`. The " + "`symbols` is nullptr"); + } + + runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_setSymbols, static_cast(sub.get()), - static_cast(listener.get())); + static_cast(symbols)); } void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, @@ -122,72 +174,50 @@ void /* int32_t */ removeSymbols(/* dxfg_subscription_t * */ const JavaObjectHan static_cast(symbols)); } -void /* int32_t */ clear(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { +/* dxfg_time_period_t* */ JavaObjectHandle +getAggregationPeriod(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { if (!sub) { throw std::invalid_argument( - "Unable to execute function `dxfg_DXFeedSubscription_clear`. The `sub` handle is invalid"); + "Unable to execute function `dxfg_DXFeedSubscription_getAggregationPeriod`. The `sub` handle is invalid"); } - runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_clear, - static_cast(sub.get())); + return JavaObjectHandle(runGraalFunctionAndThrowIfNullptr( + dxfg_DXFeedSubscription_getAggregationPeriod, static_cast(sub.get()))); } -bool /* int32_t */ isClosed(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { +/* int32_t */ void setAggregationPeriod(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_time_period_t * */ const JavaObjectHandle &period) { if (!sub) { throw std::invalid_argument( - "Unable to execute function `dxfg_DXFeedSubscription_isClosed`. The `sub` handle is invalid"); + "Unable to execute function `dxfg_DXFeedSubscription_setAggregationPeriod`. The `sub` handle is invalid"); } - return runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_isClosed, - static_cast(sub.get())) == 1; -} - -std::vector /* dxfg_symbol_list* */ getSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { - if (!sub) { - throw std::invalid_argument( - "Unable to execute function `dxfg_DXFeedSubscription_getSymbols`. The `sub` handle is invalid"); + if (!period) { + throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_setAggregationPeriod`. The " + "`period` handle is invalid"); } - dxfg_symbol_list *list = runGraalFunctionAndThrowIfNullptr( - dxfg_DXFeedSubscription_getSymbols, static_cast(sub.get())); - - auto result = SymbolWrapper::SymbolListUtils::fromGraalList(static_cast(list)); - - runGraalFunctionAndThrowIfLessThanZero(dxfg_CList_symbol_release, list); - - return result; + runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_setAggregationPeriod, + static_cast(sub.get()), + static_cast(period.get())); } -void /* int32_t */ setSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_list * */ void* symbols) { +void /* int32_t */ +addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_feed_event_listener_t * */ const JavaObjectHandle &listener) { if (!sub) { throw std::invalid_argument( - "Unable to execute function `dxfg_DXFeedSubscription_setSymbols`. The `sub` handle is invalid"); + "Unable to execute function `dxfg_DXFeedSubscription_addEventListener`. The `sub` handle is invalid"); } - if (!symbols) { - throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_setSymbols`. The " - "`symbols` is nullptr"); + if (!listener) { + throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_addEventListener`. The " + "`listener` handle is invalid"); } - runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_setSymbols, + runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_addEventListener, static_cast(sub.get()), - static_cast(symbols)); -} - -std::vector /* dxfg_symbol_list* */ getDecoratedSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub) { - if (!sub) { - throw std::invalid_argument( - "Unable to execute function `dxfg_DXFeedSubscription_getDecoratedSymbols`. The `sub` handle is invalid"); - } - - dxfg_symbol_list *list = runGraalFunctionAndThrowIfNullptr( - dxfg_DXFeedSubscription_getDecoratedSymbols, static_cast(sub.get())); - - auto result = SymbolWrapper::SymbolListUtils::fromGraalList(static_cast(list)); - - runGraalFunctionAndThrowIfLessThanZero(dxfg_CList_symbol_release, list); - - return result; + static_cast(listener.get())); } void /* int32_t */ addChangeListener(