Skip to content

Commit 8aac1d3

Browse files
authored
[MDAPI-254][C++] Migrate to dxFeed Graal Native SDK 2.5.0 (#80)
2 parents dfa6e17 + 01a24c5 commit 8aac1d3

File tree

7 files changed

+195
-47
lines changed

7 files changed

+195
-47
lines changed

CMakeLists.txt

+20-27
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(DXFCXX_VERSION "v4.2.0" CACHE STRING "The dxFeed Graal CXX API package versi
2121

2222
dxfcxx_ParseVersion(${DXFCXX_VERSION} DXFCXX_MAJOR_VERSION DXFCXX_MINOR_VERSION DXFCXX_PATCH_VERSION DXFCXX_SUFFIX_VERSION)
2323

24-
set(DXFEED_GRAAL_NATIVE_SDK_VERSION "2.2.1" CACHE STRING "")
24+
set(DXFEED_GRAAL_NATIVE_SDK_VERSION "2.5.0" CACHE STRING "")
2525
set(FMTLIB_VERSION "11.0.2")
2626
set(BOOST_VERSION "1.84.0")
2727
set(UTFCPP_VERSION "3.2.3")
@@ -63,7 +63,7 @@ option(DXFCXX_INSTALL_SAMPLES "Prepare install the samples" ${DXFCXX_IS_ROOT_PRO
6363
option(DXFCXX_INSTALL_TOOLS "Prepare install the tools" ${DXFCXX_IS_ROOT_PROJECT})
6464

6565
option(DXFCXX_LINK_STATIC_RUNTIME "Compile and link with -MT/-MTd or equivalent flag(s) to use a multi-threaded statically-linked runtime library. Visual Studio only." OFF)
66-
option(DXFCXX_NODEFAULTLIB_LIBCMT "Ignore libcmt/libcmtd. Use if DXFCXX_LINK_STATIC_RUNTIME == ON." ${DXFCXX_LINK_STATIC_RUNTIME})
66+
option(DXFCXX_NODEFAULTLIB "Ignore libcmt/libcmtd/msvcrt/msvcrtd. Use if DXFCXX_LINK_STATIC_RUNTIME == ON." ${DXFCXX_LINK_STATIC_RUNTIME})
6767

6868
option(DXFCXX_ENABLE_METRICS "Enable metrics collection" OFF)
6969

@@ -93,6 +93,7 @@ set(DXFCXX_GRAAL_TARGET_CPU "unknown" CACHE STRING "")
9393
include(cmake/ParseAndDetectPlatforms.cmake)
9494
include(cmake/LinkStacktrace.cmake)
9595
include(cmake/LinkAsanUbsan.cmake)
96+
include(cmake/SetupStaticRuntimeMSVC.cmake)
9697

9798
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/graal-native-sdk-${DXFEED_GRAAL_NATIVE_SDK_VERSION}-${DXFCXX_GRAAL_TARGET_PLATFORM}/CMakeLists.txt")
9899
add_subdirectory(third_party/graal-native-sdk-${DXFEED_GRAAL_NATIVE_SDK_VERSION}-${DXFCXX_GRAAL_TARGET_PLATFORM})
@@ -146,17 +147,8 @@ else ()
146147
CPMAddPackage("gh:ttldtor/Process#v${PROCESS_VERSION}")
147148
endif ()
148149

149-
if (DXFCXX_LINK_STATIC_RUNTIME)
150-
set_target_properties(process PROPERTIES
151-
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
152-
)
153-
154-
if (DXFCXX_NODEFAULTLIB_LIBCMT)
155-
target_link_options(process PRIVATE
156-
"/NODEFAULTLIB:LIBCMT"
157-
"/NODEFAULTLIB:LIBCMTD"
158-
)
159-
endif ()
150+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
151+
SetupStaticRuntimeMSVC(process ${DXFCXX_LINK_STATIC_RUNTIME} ${DXFCXX_NODEFAULTLIB})
160152
endif ()
161153

162154
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/Console-${CONSOLE_VERSION}/CMakeLists.txt")
@@ -165,12 +157,20 @@ else ()
165157
CPMAddPackage("gh:ttldtor/Console#v${CONSOLE_VERSION}")
166158
endif ()
167159

160+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
161+
SetupStaticRuntimeMSVC(console ${DXFCXX_LINK_STATIC_RUNTIME} ${DXFCXX_NODEFAULTLIB})
162+
endif ()
163+
168164
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/portals/CMakeLists.txt")
169165
add_subdirectory(third_party/portals)
170166
else ()
171167
CPMAddPackage("gh:ttldtor/portals#default")
172168
endif ()
173169

170+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
171+
SetupStaticRuntimeMSVC(portals ${DXFCXX_LINK_STATIC_RUNTIME} ${DXFCXX_NODEFAULTLIB})
172+
endif ()
173+
174174
add_subdirectory(third_party/utfcpp-${UTFCPP_VERSION})
175175

176176
set(FMT_INSTALL OFF)
@@ -189,6 +189,10 @@ else ()
189189
FetchContent_MakeAvailable(fmt)
190190
endif ()
191191

192+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
193+
SetupStaticRuntimeMSVC(fmt ${DXFCXX_LINK_STATIC_RUNTIME} ${DXFCXX_NODEFAULTLIB})
194+
endif ()
195+
192196
#set(BUILD_TZ_LIB ON)
193197
#set(USE_SYSTEM_TZ_DB ON)
194198
add_subdirectory(third_party/date-${DATE_VERSION})
@@ -469,20 +473,9 @@ add_library(dxfcxx ALIAS ${PROJECT_NAME})
469473
add_library(dxfcxx::static ALIAS ${PROJECT_NAME}_static)
470474
add_library(dxfcxx::graal ALIAS DxFeedGraalNativeSdk)
471475

472-
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
473-
set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
474-
if (DXFCXX_LINK_STATIC_RUNTIME)
475-
set_target_properties(${PROJECT_NAME}_static PROPERTIES
476-
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
477-
)
478-
479-
if (DXFCXX_NODEFAULTLIB_LIBCMT)
480-
target_link_options(${PROJECT_NAME}_static PRIVATE
481-
"/NODEFAULTLIB:LIBCMT"
482-
"/NODEFAULTLIB:LIBCMTD"
483-
)
484-
endif ()
485-
endif ()
476+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
477+
# set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
478+
SetupStaticRuntimeMSVC(${PROJECT_NAME}_static ${DXFCXX_LINK_STATIC_RUNTIME} ${DXFCXX_NODEFAULTLIB})
486479
endif ()
487480

488481
target_include_directories(${PROJECT_NAME} PUBLIC include)

ReleaseNotes.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## v4.3.0
2+
3+
* Renamed `DXFCXX_NODEFAULTLIB_LIBCMT` to `DXFCXX_NODEFAULTLIB` CMake project option for clearer purposes and added support for additional libraries in `/NODEFAULTLIB` configuration.
4+
* **\[MDAPI-254]\[C++]** Migrated to Graal SDK v2.5.0
5+
* Added `AGGREGATE`, `COMPOSITE`, `REGIONAL` OrderSource. The new system property `dxscheme.unitaryOrderSource=true|false` has been added.
6+
It controls whether a single or unitary source is used when subscribing to all sources. It is set to 'false' by default.
7+
All separate sources, such as `COMPOSITE_ASK`, `COMPOSITE_BID`, `REGIONAL_ASK`, `REGIONAL_BID`, `AGGREGATE_ASK` and `AGGREGATE_BID` have been
8+
declared deprecated.
9+
* Added new Order source for BlueOcean ATS: ocea.
10+
* Added new Order sources for IG CFDs Gate: IGC, igc.
11+
* Added new Order sources for EDX Gate: EDX, edx.
12+
* Added new Order sources for Nuam Exchange Gate: NUAM, nuam.
13+
* Added the ability to automatically generate the DXEndpoint name.
14+
If the user does not explicitly specify the endpoint name, it will be generated using the template `qdcxx{Id}`,
15+
where `{Id}` will be an empty string for the first instance of the endpoint and "-2", "-3", etc. for subsequent instances.
16+
117
## v4.2.0
218

319
* **\[MDAPI-249]\[C++]** Transitive dependencies are hidden.

cmake/LinkAsanUbsan.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function(LinkAsan targetName)
88
target_link_options(${targetName} PRIVATE "-fsanitize=address")
99
else ()
1010
target_compile_options(${targetName} PRIVATE "/fsanitize=address")
11-
target_link_options(${targetName} PRIVATE "/fsanitize=address")
11+
# target_link_options(${targetName} PRIVATE "/fsanitize=address")
1212

1313
target_compile_definitions(${targetName}
1414
PUBLIC

cmake/SetupStaticRuntimeMSVC.cmake

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2025 Devexperts LLC.
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
function(SetupStaticRuntimeMSVC targetName linkStaticRuntime noDefaultLib)
5+
if (${linkStaticRuntime})
6+
set_target_properties(${targetName} PROPERTIES
7+
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
8+
)
9+
10+
if (${noDefaultLib})
11+
target_link_options(${targetName} PRIVATE
12+
/NODEFAULTLIB:libcmt
13+
/NODEFAULTLIB:libcmtd
14+
/NODEFAULTLIB:msvcrt
15+
/NODEFAULTLIB:msvcrtd
16+
/VERBOSE
17+
)
18+
endif ()
19+
endif ()
20+
endfunction()

include/dxfeed_graal_cpp_api/event/market/OrderSource.hpp

+104-4
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ class DXFCPP_EXPORT OrderSource final : public IndexedEventSource {
4242
static constexpr std::uint32_t PUB_OTC_MARKETS_ORDER = 0x0004;
4343
static constexpr std::uint32_t PUB_SPREAD_ORDER = 0x0008U;
4444
static constexpr std::uint32_t FULL_ORDER_BOOK = 0x0010U;
45+
static constexpr std::uint32_t PUB_NUAM_ORDER = 0x0020U;
4546

46-
static constexpr std::uint32_t FLAGS_SIZE = 5U;
47+
static constexpr std::uint32_t FLAGS_SIZE = 6U;
4748

4849
public:
4950
static const std::unordered_map<std::variant<std::int32_t, std::string>, std::reference_wrapper<const OrderSource>>
@@ -85,43 +86,87 @@ class DXFCPP_EXPORT OrderSource final : public IndexedEventSource {
8586
/**
8687
* Bid side of a composite Quote.
8788
* It is a <em>synthetic</em> source.
89+
* It cannot be used with DXFeed::getIndexedEventsPromise method and it cannot be published directly to.
8890
* The subscription on composite Quote event is observed when this source is subscribed to.
91+
* @deprecated Use the OrderSource::COMPOSITE source.
8992
*/
9093
static const OrderSource COMPOSITE_BID;
9194

9295
/**
9396
* Ask side of a composite Quote.
94-
* It is a <em>synthetic</em> source.
97+
* It is a <em>synthetic</em> and <em>separate</em> source.
98+
* It cannot be used with DXFeed::getIndexedEventsPromise method and it cannot be published directly to.
9599
* The subscription on composite Quote event is observed when this source is subscribed to.
100+
* @deprecated Use the OrderSource::COMPOSITE source.
96101
*/
97102
static const OrderSource COMPOSITE_ASK;
98103

99104
/**
100105
* Bid side of a regional Quote.
101-
* It is a <em>synthetic</em> source.
106+
* It is a <em>synthetic</em> and <em>separate</em> source.
107+
* It cannot be used with DXFeed::getIndexedEventsPromise method and it cannot be published directly to.
102108
* The subscription on regional Quote event is observed when this source is subscribed to.
109+
* @deprecated Use the OrderSource::REGIONAL source.
103110
*/
104111
static const OrderSource REGIONAL_BID;
105112

106113
/**
107114
* Ask side of a regional Quote.
108-
* It is a <em>synthetic</em> source.
115+
* It is a <em>synthetic</em> and <em>separate</em> source.
116+
* It cannot be used with DXFeed::getIndexedEventsPromise method and it cannot be published directly to.
109117
* The subscription on regional Quote event is observed when this source is subscribed to.
118+
* @deprecated Use the OrderSource::REGIONAL source.
110119
*/
111120
static const OrderSource REGIONAL_ASK;
112121

113122
/**
114123
* Bid side of an aggregate order book (futures depth and NASDAQ Level II).
124+
* It is a <em>aggregate</em> and <em>separate</em> source.
115125
* This source cannot be directly published via dxFeed API, but otherwise it is fully operational.
126+
* @deprecated Use the OrderSource::AGGREGATE source.
116127
*/
117128
static const OrderSource AGGREGATE_BID;
118129

119130
/**
120131
* Ask side of an aggregate order book (futures depth and NASDAQ Level II).
132+
* It is a <em>aggregate</em> and <em>separate</em> source.
121133
* This source cannot be directly published via dxFeed API, but otherwise it is fully operational.
134+
* @deprecated Use the OrderSource::AGGREGATE source.
122135
*/
123136
static const OrderSource AGGREGATE_ASK;
124137

138+
/**
139+
* Composite Quote.
140+
* It is a <em>synthetic</em> and <em>unitary</em> source, that represents both bid and ask side.
141+
* It cannot be used with DXFeed::getIndexedEventsPromise method and it cannot be published directly to.
142+
* The subscription on composite Quote event is observed when this source is subscribed to.
143+
* To use this source when subscribing to all sources (e.g., when subscribing to an order without specifying a
144+
* source), instead of OrderSource::COMPOSITE_ASK and OrderSource::COMPOSITE_BID, set the system property
145+
* <b>`dxscheme.unitaryOrderSource`</b> to `true`.
146+
*/
147+
static const OrderSource COMPOSITE;
148+
149+
/**
150+
* Regional Quote.
151+
* It is a <em>synthetic</em> and <em>unitary</em> source, that represents both bid and ask side.
152+
* It cannot be used with DXFeed::getIndexedEventsPromise method and it cannot be published directly to.
153+
* The subscription on regional Quote event is observed when this source is subscribed to.
154+
* To use this source when subscribing to all sources (e.g., when subscribing to an order without specifying a
155+
* source), instead of OrderSource::REGIONAL_ASK and OrderSource::REGIONAL_BID, set the system property
156+
* <b>`dxscheme.unitaryOrderSource`</b> to `true`.
157+
*/
158+
static const OrderSource REGIONAL;
159+
160+
/**
161+
* Aggregate order book (futures depth and NASDAQ Level II).
162+
* It is a <em>aggregate</em> and <em>unitary</em> source, that represents both bid and ask side.
163+
* This source cannot be directly published via dxFeed API, but otherwise it is fully operational.
164+
* To use this source when subscribing to all sources (e.g., when subscribing to an order without specifying a
165+
* source), instead of OrderSource::AGGREGATE_ASK and OrderSource::AGGREGATE_BID, set the system property
166+
* <b>`dxscheme.unitaryOrderSource`</b> to `true`.
167+
*/
168+
static const OrderSource AGGREGATE;
169+
125170
/**
126171
* Default source for publishing custom order books.
127172
* Order, AnalyticOrder, OtcMarketsOrder and SpreadOrder events are @ref ::isPublishable() "publishable"
@@ -402,6 +447,13 @@ class DXFCPP_EXPORT OrderSource final : public IndexedEventSource {
402447
*/
403448
static const OrderSource OCEA;
404449

450+
/**
451+
* Blue Ocean Technologies Alternative Trading System. Record for price level book.
452+
* Order events are @ref ::isPublishable() "publishable" on this source and the corresponding subscription can be
453+
* observed via DXPublisher.
454+
*/
455+
static const OrderSource ocea;
456+
405457
/**
406458
* Pink Sheets. Record for price level book.
407459
* Pink sheets are listings for stocks that trade over-the-counter (OTC).
@@ -443,6 +495,54 @@ class DXFCPP_EXPORT OrderSource final : public IndexedEventSource {
443495
*/
444496
static const OrderSource cedx;
445497

498+
/**
499+
* IG CFDs Gate.
500+
*
501+
* Order events are @ref ::isPublishable() "publishable" on this source and the corresponding subscription can be
502+
* observed via DXPublisher.
503+
*/
504+
static const OrderSource IGC;
505+
506+
/**
507+
* IG CFDs Gate. Record for price level book.
508+
*
509+
* Order events are @ref ::isPublishable() "publishable" on this source and the corresponding subscription can be
510+
* observed via DXPublisher.
511+
*/
512+
static const OrderSource igc;
513+
514+
/**
515+
* EDX Exchange.
516+
*
517+
* Order events are @ref ::isPublishable() "publishable" on this source and the corresponding subscription can be
518+
* observed via DXPublisher.
519+
*/
520+
static const OrderSource EDX;
521+
522+
/**
523+
* EDX Exchange. Record for price level book.
524+
*
525+
* Order events are @ref ::isPublishable() "publishable" on this source and the corresponding subscription can be
526+
* observed via DXPublisher.
527+
*/
528+
static const OrderSource edx;
529+
530+
/**
531+
* Nuam Exchange Gate.
532+
*
533+
* Order and NuamOrder events are @ref ::isPublishable() "publishable" on this source and the corresponding
534+
* subscription can be observed via DXPublisher.
535+
*/
536+
static const OrderSource NUAM;
537+
538+
/**
539+
* Nuam Exchange Gate. Record for price level book.
540+
*
541+
* Order and NuamOrder events are @ref ::isPublishable() "publishable" on this source and the corresponding
542+
* subscription can be observed via DXPublisher.
543+
*/
544+
static const OrderSource nuam;
545+
446546
/**
447547
* Determines whether specified source identifier refers to special order source.
448548
* Special order sources are used for wrapping non-order events into order events.

src/api/DXEndpoint.cpp

+13-10
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,9 @@ std::shared_ptr<DXEndpoint> DXEndpoint::create(void *endpointHandle, DXEndpoint:
125125
", role = " + roleToString(role) + ", properties[" + std::to_string(properties.size()) + "])");
126126
}
127127

128-
auto name = properties.contains(NAME_PROPERTY) ? properties.at(NAME_PROPERTY) : std::string{};
129-
130-
if (name.empty()) {
131-
std::size_t id = ApiContext::getInstance()->getManager<EntityManager<DXEndpoint>>()->getLastId();
132-
133-
name = fmt::format("qdcxx{}", (id <= 1) ? "" : fmt::format("-{}", id));
134-
}
135-
136-
auto endpoint = DXEndpoint::createShared(JavaObjectHandle<DXEndpoint>(endpointHandle), role, name);
137-
auto id = ApiContext::getInstance()->getManager<EntityManager<DXEndpoint>>()->registerEntity(endpoint);
128+
auto endpoint =
129+
DXEndpoint::createShared(JavaObjectHandle<DXEndpoint>(endpointHandle), role, properties.at(NAME_PROPERTY));
130+
const auto id = ApiContext::getInstance()->getManager<EntityManager<DXEndpoint>>()->registerEntity(endpoint);
138131

139132
endpoint->stateChangeListenerHandle_ = isolated::api::IsolatedDXEndpoint::StateChangeListener::create(
140133
dxfcpp::bit_cast<void *>(&Impl::onPropertyChange), dxfcpp::bit_cast<void *>(id.getValue()));
@@ -336,6 +329,16 @@ std::shared_ptr<DXEndpoint> DXEndpoint::Builder::build() {
336329

337330
loadDefaultPropertiesImpl();
338331

332+
if (auto name = properties_.contains(NAME_PROPERTY) ? properties_.at(NAME_PROPERTY) : std::string{}; name.empty()) {
333+
std::size_t id = ApiContext::getInstance()->getManager<EntityManager<DXEndpoint>>()->getLastId();
334+
335+
name = fmt::format("qdcxx{}", (id <= 1) ? "" : fmt::format("-{}", id));
336+
337+
const auto newBuilder = withProperty(NAME_PROPERTY, name);
338+
339+
return newBuilder->build();
340+
}
341+
339342
return DXEndpoint::create(isolated::api::IsolatedDXEndpoint::Builder::build(handle_), role_, properties_);
340343
}
341344

0 commit comments

Comments
 (0)