Skip to content

[MDAPI-249] [C++] Hide transitive dependencies. #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ if (DXFCXX_USE_PRECOMPILED_HEADERS)
target_precompile_headers(${PROJECT_NAME}_static PRIVATE include/dxfeed_graal_cpp_api/internal/PrecompiledHeaders.hpp)
endif ()

target_link_libraries(${PROJECT_NAME} PUBLIC DxFeedGraalNativeSdk utf8cpp fmt::fmt-header-only date::date)
target_link_libraries(${PROJECT_NAME}_static PUBLIC DxFeedGraalNativeSdk utf8cpp fmt::fmt-header-only date::date)
target_link_libraries(${PROJECT_NAME} PRIVATE DxFeedGraalNativeSdk utf8cpp fmt::fmt-header-only date::date)
target_link_libraries(${PROJECT_NAME}_static PRIVATE DxFeedGraalNativeSdk utf8cpp fmt::fmt-header-only date::date)

if (DXFCXX_FEATURE_STACKTRACE)
LinkStacktrace(${PROJECT_NAME})
Expand Down
7 changes: 0 additions & 7 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ if (DXFCXX_BUILD_DOC)
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
# set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/../docs/Doxyfile.in)
# set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
set(DOXYGEN_OUT Doxyfile)

# request to configure the file
# configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")

# note the option ALL which allows to build the docs together with the application
add_custom_target(${PROJECT_NAME} ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
Expand Down
4 changes: 0 additions & 4 deletions include/dxfeed_graal_cpp_api/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4996)

#include "internal/context/ApiContext.hpp"

#include "internal/managers/DXEndpointManager.hpp"
#include "internal/managers/DXFeedManager.hpp"
#include "internal/managers/DXFeedSubscriptionManager.hpp"
#include "internal/managers/DXPublisherManager.hpp"
#include "internal/managers/EntityManager.hpp"
#include "internal/managers/ErrorHandlingManager.hpp"

Expand Down
3 changes: 2 additions & 1 deletion include/dxfeed_graal_cpp_api/api/DXFeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
#include "../internal/Common.hpp"
#include "../internal/Isolate.hpp"
#include "../internal/JavaObjectHandle.hpp"
#include "../internal/managers/EntityManager.hpp"
#include "../promise/Promise.hpp"

#include "DXFeedSubscription.hpp"
Expand Down Expand Up @@ -474,7 +475,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
auto list = EventClassList::create(begin, end);
auto sub = RequireMakeShared<DXFeedTimeSeriesSubscription>::createShared(
begin, end, std::move(createTimeSeriesSubscriptionHandleFromEventClassList(list)));
auto id = ApiContext::getInstance()->getManager<DXFeedSubscriptionManager>()->registerEntity(sub);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);

dxfcpp::ignoreUnused(id);

Expand Down
4 changes: 2 additions & 2 deletions include/dxfeed_graal_cpp_api/api/DXFeedSubscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class DXFCPP_EXPORT DXFeedSubscription : public RequireMakeShared<DXFeedSubscrip
}

auto sub = createShared(begin, end);
auto id = ApiContext::getInstance()->getManager<DXFeedSubscriptionManager>()->registerEntity(sub);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);

dxfcpp::ignoreUnused(id);

Expand Down Expand Up @@ -257,7 +257,7 @@ class DXFCPP_EXPORT DXFeedSubscription : public RequireMakeShared<DXFeedSubscrip
template <typename EventTypesCollection>
static std::shared_ptr<DXFeedSubscription> create(EventTypesCollection &&eventTypes) {
auto sub = createShared(std::forward<EventTypesCollection>(eventTypes));
auto id = ApiContext::getInstance()->getManager<DXFeedSubscriptionManager>()->registerEntity(sub);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);

dxfcpp::ignoreUnused(id);

Expand Down
31 changes: 5 additions & 26 deletions include/dxfeed_graal_cpp_api/internal/context/ApiContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,24 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)

#include <memory>

#include "../managers/DXEndpointManager.hpp"
#include "../managers/DXFeedManager.hpp"
#include "../managers/DXFeedSubscriptionManager.hpp"
#include "../managers/DXPublisherManager.hpp"

DXFCPP_BEGIN_NAMESPACE

template <typename Manager> struct AddManagerMixin {
mutable std::shared_ptr<Manager> manager_;

AddManagerMixin() noexcept : manager_{std::make_shared<Manager>()} {
}

std::shared_ptr<Manager> getManager() const noexcept {
return manager_;
}
};

class DXFCPP_EXPORT ApiContext : AddManagerMixin<DXEndpointManager>,
AddManagerMixin<DXFeedSubscriptionManager>,
AddManagerMixin<DXFeedManager>,
AddManagerMixin<DXPublisherManager> {
class DXFCPP_EXPORT ApiContext {
ApiContext() noexcept = default;

public:
~ApiContext() noexcept = default;

static std::shared_ptr<ApiContext> getInstance() noexcept {
static std::shared_ptr<ApiContext> instance = std::shared_ptr<ApiContext>(new ApiContext{});

return instance;
}

template <typename Manager> std::shared_ptr<Manager> getManager() const noexcept {
if constexpr (std::is_base_of_v<AddManagerMixin<Manager>, ApiContext>) {
return AddManagerMixin<Manager>::getManager();
} else {
static std::shared_ptr<Manager> instance = std::shared_ptr<Manager>(new Manager{});
static std::shared_ptr<Manager> instance = std::shared_ptr<Manager>(new Manager{});

return instance;
}
return instance;
}
};

Expand Down

This file was deleted.

25 changes: 0 additions & 25 deletions include/dxfeed_graal_cpp_api/internal/managers/DXFeedManager.hpp

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions include/dxfeed_graal_cpp_api/model/TxModelListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
#include "../internal/Handler.hpp"
#include "../internal/Id.hpp"
#include "../internal/JavaObjectHandle.hpp"
#include "../internal/managers/EntityManager.hpp"
#include "../internal/context/ApiContext.hpp"

#include <functional>
Expand Down
8 changes: 4 additions & 4 deletions src/api/DXEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct DXEndpoint::Impl {
static void onPropertyChange(graal_isolatethread_t * /*thread*/, dxfg_endpoint_state_t oldState,
dxfg_endpoint_state_t newState, void *userData) {
auto id = Id<DXEndpoint>::from(dxfcpp::bit_cast<Id<DXEndpoint>::ValueType>(userData));
auto endpoint = ApiContext::getInstance()->getManager<DXEndpointManager>()->getEntity(id);
auto endpoint = ApiContext::getInstance()->getManager<EntityManager<DXEndpoint>>()->getEntity(id);

if constexpr (Debugger::isDebug) {
Debugger::debug("onStateChange: id = " + std::to_string(id.getValue()) +
Expand All @@ -67,7 +67,7 @@ struct DXEndpoint::Impl {

if (newState == DXFG_ENDPOINT_STATE_CLOSED) {
// TODO: fix endpoint lifetime
// ApiContext::getInstance()->getManager<DXEndpointManager>()->unregisterEntity(id);
// ApiContext::getInstance()->getManager<EntityManager<DXEndpoint>>()->unregisterEntity(id);
}
}
};
Expand Down Expand Up @@ -128,13 +128,13 @@ std::shared_ptr<DXEndpoint> DXEndpoint::create(void *endpointHandle, DXEndpoint:
auto name = properties.contains(NAME_PROPERTY) ? properties.at(NAME_PROPERTY) : std::string{};

if (name.empty()) {
std::size_t id = ApiContext::getInstance()->getManager<DXEndpointManager>()->getLastId();
std::size_t id = ApiContext::getInstance()->getManager<EntityManager<DXEndpoint>>()->getLastId();

name = fmt::format("qdcxx{}", (id <= 1) ? "" : fmt::format("-{}", id));
}

auto endpoint = DXEndpoint::createShared(JavaObjectHandle<DXEndpoint>(endpointHandle), role, name);
auto id = ApiContext::getInstance()->getManager<DXEndpointManager>()->registerEntity(endpoint);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXEndpoint>>()->registerEntity(endpoint);

endpoint->stateChangeListenerHandle_ = isolated::api::IsolatedDXEndpoint::StateChangeListener::create(
dxfcpp::bit_cast<void *>(&Impl::onPropertyChange), dxfcpp::bit_cast<void *>(id.getValue()));
Expand Down
4 changes: 2 additions & 2 deletions src/api/DXFeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ std::shared_ptr<DXFeedTimeSeriesSubscription> DXFeed::createTimeSeriesSubscripti

auto sub = RequireMakeShared<DXFeedTimeSeriesSubscription>::template createShared(
eventType, isolated::api::IsolatedDXFeed::createTimeSeriesSubscription(handle_, eventType));
auto id = ApiContext::getInstance()->getManager<DXFeedSubscriptionManager>()->registerEntity(sub);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);

dxfcpp::ignoreUnused(id);
attachSubscription(sub);
Expand All @@ -145,7 +145,7 @@ std::shared_ptr<DXFeed> DXFeed::create(void *feedHandle) {

std::shared_ptr<DXFeed> feed{new DXFeed{}};

auto id = ApiContext::getInstance()->getManager<DXFeedManager>()->registerEntity(feed);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeed>>()->registerEntity(feed);
ignoreUnused(id);

feed->handle_ = JavaObjectHandle<DXFeed>(feedHandle);
Expand Down
10 changes: 5 additions & 5 deletions src/api/DXFeedSubscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DXFCPP_BEGIN_NAMESPACE
struct DXFeedSubscription::Impl {
static void onEvents(graal_isolatethread_t * /*thread*/, dxfg_event_type_list *graalNativeEvents, void *userData) {
auto id = Id<DXFeedSubscription>::from(dxfcpp::bit_cast<Id<DXFeedSubscription>::ValueType>(userData));
auto sub = ApiContext::getInstance()->getManager<DXFeedSubscriptionManager>()->getEntity(id);
auto sub = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->getEntity(id);

if (sub) {
auto &&events = EventMapper::fromGraalList(static_cast<void *>(graalNativeEvents));
Expand All @@ -46,8 +46,8 @@ bool DXFeedSubscription::tryToSetEventListenerHandle() {
std::lock_guard lock{eventListenerMutex_};

if (!eventListenerHandle_) {
auto idOpt =
ApiContext::getInstance()->getManager<DXFeedSubscriptionManager>()->getId(sharedAs<DXFeedSubscription>());
auto idOpt = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->getId(
sharedAs<DXFeedSubscription>());

if (!idOpt) {
return false;
Expand Down Expand Up @@ -124,7 +124,7 @@ std::shared_ptr<DXFeedSubscription> DXFeedSubscription::create(const EventTypeEn
}

auto sub = createShared(eventType);
auto id = ApiContext::getInstance()->getManager<DXFeedSubscriptionManager>()->registerEntity(sub);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);

dxfcpp::ignoreUnused(id);

Expand All @@ -133,7 +133,7 @@ std::shared_ptr<DXFeedSubscription> DXFeedSubscription::create(const EventTypeEn

std::shared_ptr<DXFeedSubscription> DXFeedSubscription::create(std::initializer_list<EventTypeEnum> eventTypes) {
auto sub = createShared(eventTypes);
auto id = ApiContext::getInstance()->getManager<DXFeedSubscriptionManager>()->registerEntity(sub);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXFeedSubscription>>()->registerEntity(sub);

dxfcpp::ignoreUnused(id);

Expand Down
2 changes: 1 addition & 1 deletion src/api/DXPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::shared_ptr<DXPublisher> DXPublisher::create(void *handle) {

std::shared_ptr<DXPublisher> publisher{new DXPublisher{}};

auto id = ApiContext::getInstance()->getManager<DXPublisherManager>()->registerEntity(publisher);
auto id = ApiContext::getInstance()->getManager<EntityManager<DXPublisher>>()->registerEntity(publisher);
ignoreUnused(id);

publisher->handle_ = JavaObjectHandle<DXPublisher>(handle);
Expand Down
4 changes: 3 additions & 1 deletion third_party/utfcpp-3.2.3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
cmake_minimum_required (VERSION 3.0.2)
# CMake Error at third_party/utfcpp-3.2.3/CMakeLists.txt:1 (cmake_minimum_required):
# Compatibility with CMake < 3.5 has been removed from CMake.
cmake_minimum_required (VERSION 3.5)
project (utf8cpp VERSION 3.2.2 LANGUAGES CXX)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
Expand Down
Loading