Skip to content

Commit

Permalink
[EN-7588] Implement PublishProfiles sample
Browse files Browse the repository at this point in the history
DXPublisherObservableSubscription's stub.
  • Loading branch information
ttldtor committed May 17, 2024
1 parent 5503703 commit 424b984
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ set(dxFeedGraalCxxApi_Api_Sources
src/api/DXEndpoint.cpp
src/api/DXFeed.cpp
src/api/DXFeedSubscription.cpp
src/api/DXPublisherObservableSubscription.cpp
src/api/DXPublisher.cpp
)

Expand Down
1 change: 1 addition & 0 deletions include/dxfeed_graal_cpp_api/api/ApiModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
#include "DXEndpoint.hpp"
#include "DXFeed.hpp"
#include "DXFeedSubscription.hpp"
#include "DXPublisherObservableSubscription.hpp"
#include "DXPublisher.hpp"
#include "FilteredSubscriptionSymbol.hpp"
#include "osub/OsubModule.hpp"
Expand Down
2 changes: 0 additions & 2 deletions include/dxfeed_graal_cpp_api/api/DXFeedSubscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
#include "../internal/Common.hpp"
#include "../internal/Handler.hpp"
#include "../internal/JavaObjectHandle.hpp"
#include "../symbols/StringSymbol.hpp"
#include "../symbols/SymbolWrapper.hpp"
#include "osub/WildcardSymbol.hpp"

#include <concepts>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2024 Devexperts LLC.
// SPDX-License-Identifier: MPL-2.0

#pragma once

#include "../internal/Conf.hpp"

DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)

#include "../internal/EventClassList.hpp"
#include "../internal/context/ApiContext.hpp"

#include "../entity/EntityModule.hpp"
#include "osub/ObservableSubscription.hpp"
#include "../event/EventType.hpp"
#include "../event/EventTypeEnum.hpp"
#include "../internal/Common.hpp"
#include "../internal/Handler.hpp"
#include "../internal/JavaObjectHandle.hpp"
#include "../symbols/SymbolWrapper.hpp"

#include <concepts>
#include <memory>
#include <type_traits>
#include <unordered_set>

DXFCPP_BEGIN_NAMESPACE

class DXFCPP_EXPORT DXPublisherObservableSubscription : public ObservableSubscription, public SharedEntity {
public:
bool isClosed() override;
std::unordered_set<EventTypeEnum> getEventTypes() override;
bool containsEventType(const EventTypeEnum &eventType) override;
std::size_t addChangeListener(std::shared_ptr<ObservableSubscriptionChangeListener> listener) override;
void removeChangeListener(std::size_t id) override;
};

DXFCPP_END_NAMESPACE

DXFCXX_DISABLE_MSC_WARNINGS_POP()
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)

#include "../../event/IndexedEventSource.hpp"
#include "../../symbols/SymbolWrapper.hpp"
#include "ObservableSubscriptionChangeListener.hpp"

#include <cstdint>
#include <memory>
Expand Down Expand Up @@ -53,7 +54,7 @@ struct DXFCPP_EXPORT ObservableSubscription {
* @param listener The subscription change listener.
* @return The listener id
*/
virtual std::size_t addChangeListener(ObservableSubscriptionChangeListener &&listener) = 0;
virtual std::size_t addChangeListener(std::shared_ptr<ObservableSubscriptionChangeListener> listener) = 0;

/**
* Removes subscription change listener by id. This method does nothing if the listener with the given id was not
Expand Down
4 changes: 2 additions & 2 deletions samples/cpp/PublishProfiles/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
auto publisher = endpoint->getPublisher();

// Observe Profile subscriptions and publish profiles for "xxx:TEST" symbols
// publisher->getSubscription(Profile::TYPE)->addChangeListener(ObservableSubscriptionChangeListener {
// publisher->getSubscription(Profile::TYPE)->addChangeListener(ObservableSubscriptionChangeListener::create(
// [publisher](auto&& symbols) /* symbolsAdded */ {
// std::vector<std::shared_ptr<Profile>> events{};
// events.reserve(symbols.sise());
Expand All @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) {
// events.shrink_to_fit();
// publisher->publishEvents(events);
// }
// });
// ));

std::cin.get();
} catch (const JavaException &e) {
Expand Down
38 changes: 38 additions & 0 deletions src/api/DXPublisherObservableSubscription.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2024 Devexperts LLC.
// SPDX-License-Identifier: MPL-2.0

#include <dxfg_api.h>

#include <dxfeed_graal_cpp_api/api.hpp>

#include <memory>
#include <typeinfo>

#include <fmt/chrono.h>
#include <fmt/format.h>
#include <fmt/ostream.h>
#include <fmt/std.h>

DXFCPP_BEGIN_NAMESPACE

bool DXPublisherObservableSubscription::isClosed() {
return false;
}

std::unordered_set<EventTypeEnum> DXPublisherObservableSubscription::getEventTypes() {
return {};
}

bool DXPublisherObservableSubscription::containsEventType(const EventTypeEnum &eventType) {
return false;
}

std::size_t
DXPublisherObservableSubscription::addChangeListener(std::shared_ptr<ObservableSubscriptionChangeListener> listener) {
return Id<ObservableSubscriptionChangeListener>::UNKNOWN.getValue();
}

void DXPublisherObservableSubscription::removeChangeListener(std::size_t id) {
}

DXFCPP_END_NAMESPACE

0 comments on commit 424b984

Please sign in to comment.