diff --git a/include/dxfeed_graal_cpp_api/api/DXFeed.hpp b/include/dxfeed_graal_cpp_api/api/DXFeed.hpp index febf77de..80429983 100644 --- a/include/dxfeed_graal_cpp_api/api/DXFeed.hpp +++ b/include/dxfeed_graal_cpp_api/api/DXFeed.hpp @@ -223,7 +223,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity { * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role (never fills in the event). * * @tparam E The type of event. - * @param event the event. + * @param event The event. * @return The same event. */ template E> std::shared_ptr getLastEvent(std::shared_ptr event) { @@ -232,6 +232,25 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity { return event; } + /** + * Returns the last events for the specified list of event instances. + * This is a bulk version of @ref ::getLastEvent() "getLastEvent" method. + * + *

Note, that this method does not work when DXEndpoint was created with + * @ref DXEndpoint::Role::STREAM_FEED "STREAM_FEED" role. + * + * @tparam Collection The collection type. + * @param events The collection of shared ptrs of events. + * @return The same collection of shared ptrs of events. + */ + template const Collection &getLastEvents(const Collection &events) { + for (auto e : events) { + getLastEvent(e); + } + + return events; + } + /** * Creates new subscription for a single event type that is attached to this feed. * This method creates new DXFeedSubscription and invokes @link DXFeed::attachSubscription. diff --git a/samples/cpp/DxFeedSample/src/main.cpp b/samples/cpp/DxFeedSample/src/main.cpp index 129784c2..b90a6f1d 100644 --- a/samples/cpp/DxFeedSample/src/main.cpp +++ b/samples/cpp/DxFeedSample/src/main.cpp @@ -3,8 +3,8 @@ #include -#include #include +#include #include using namespace dxfcpp; @@ -59,6 +59,14 @@ void testTradeSnapshots(const std::string &symbol) { auto feed = DXFeed::getInstance(); auto sub = feed->createSubscription(Trade::TYPE); + std::vector e = {std::make_shared("AAPL"), std::make_shared("IBM")}; + auto x = std::remove_reference_t>::iterator>::value_type>>(); + + decltype(x) y; + + auto z = feed->getLastEvents(e); + sub->addSymbols(symbol); while (true) {