8#include "./utils/StringUtils.hpp"
12#ifdef __cpp_lib_bit_cast
26#include "utils/debug/Debug.hpp"
31template <
typename,
template <
class...>
class>
struct IsInstanceImpl : std::false_type {};
33template <
template <
class...>
class C,
typename... Ts>
struct IsInstanceImpl<C<Ts...>, C> : std::true_type {};
36template <
typename T,
template <
class...>
class C>
constexpr bool isInstanceOf = detail::IsInstanceImpl<T, C>::value;
37template <
typename T,
template <
class...>
class C>
38concept InstanceOf = isInstanceOf<T, C>;
41concept Integral = std::is_integral_v<T>;
44concept EnumConcept = std::is_enum_v<T>;
46template <
class From,
class To>
47concept ConvertibleTo = std::is_convertible_v<From, To> && requires {
static_cast<To>(std::declval<From>()); };
49template <
class T,
class U>
50concept Derived = std::is_base_of_v<U, T>;
52template <
class T,
class U>
53concept Extends = Derived<T, U>;
55template <
class T,
class U>
56concept BaseOf = Derived<U, T>;
59concept PairLike = requires(T t) {
65concept MapLike = requires(T t) {
66 { std::begin(t) } -> std::input_iterator;
67 { std::end(t) } -> std::sentinel_for<
decltype(std::begin(t))>;
68} && PairLike<std::remove_cvref_t<
decltype(*std::begin(std::declval<T &>()))>>;
72struct RemoveAllPointers
73 : std::conditional_t<std::is_pointer_v<T>, RemoveAllPointers<std::remove_pointer_t<T>>, std::type_identity<T>> {};
76template <
typename T>
using RemoveAllPointers =
typename detail::RemoveAllPointers<T>::type;
78template <
class... Ts>
struct Overloads : Ts... {
79 using Ts::operator()...;
82template <
class... Ts> Overloads(Ts...) -> Overloads<Ts...>;
84struct DXFeedEventListener {};
86struct DXEndpointStateChangeListener {};
88struct IpfPropertyChangeListener {};
90struct InstrumentProfileUpdateListener {};
92template <
typename... T>
constexpr void ignoreUnused(
const T &...) {
95constexpr inline auto is_constant_evaluated(
bool default_value =
false)
noexcept ->
bool {
96#ifdef __cpp_lib_is_constant_evaluated
97 ignoreUnused(default_value);
98 return std::is_constant_evaluated();
100 return default_value;
105template <
typename To,
typename From>
106constexpr To bit_cast(
const From &from)
108 requires(
sizeof(To) ==
sizeof(From))
111#ifdef __cpp_lib_bit_cast
112 if (is_constant_evaluated())
113 return std::bit_cast<To>(from);
117 std::memcpy(
static_cast<
void *>(&to), &from,
sizeof(to));
122enum class Tristate : std::uint8_t {
129#define DXFCPP_MACRO_CONCAT_INNER(a, b) a##b
133template <
typename Func>
struct OnScopeExit {
137 OnScopeExit(
const Func &f) : func(
static_cast<Func &&>(f)) {
141 OnScopeExit(Func &&f) : func(f) {
144 OnScopeExit(
const OnScopeExit &) =
delete;
154template <
typename GraalList,
typename ElementWrapper>
struct GraalListUtils {
155 static std::ptrdiff_t calculateSize(std::ptrdiff_t initSize)
noexcept {
156 using ListType = GraalList;
157 using SizeType =
decltype(ListType::size);
163 if (initSize > std::numeric_limits<SizeType>::max()) {
164 return std::numeric_limits<SizeType>::max();
170 static void *newList(std::ptrdiff_t size) {
171 using ListType = GraalList;
172 using SizeType =
decltype(ListType::size);
173 using ElementType = std::remove_pointer_t<
decltype(ListType::elements)>;
175 auto *list =
new ListType{
static_cast<SizeType>(size),
nullptr};
178 return static_cast<
void *>(list);
181 list->elements =
new ElementType[size]{
nullptr};
186 static bool setElement(
void *graalList, std::ptrdiff_t elementIdx,
void *element)
noexcept {
187 using ListType = GraalList;
188 using SizeType =
decltype(ListType::size);
189 using ElementType = std::remove_pointer_t<
decltype(ListType::elements)>;
191 if (graalList ==
nullptr || elementIdx < 0 || elementIdx >= std::numeric_limits<SizeType>::max() ||
192 element ==
nullptr) {
196 static_cast<ListType *>(graalList)->elements[elementIdx] =
static_cast<ElementType>(element);
201 static bool freeElements(
void *graalList, std::ptrdiff_t count) {
202 using ListType = GraalList;
203 using SizeType =
decltype(ListType::size);
205 if (graalList ==
nullptr || count < 0 || count >= std::numeric_limits<SizeType>::max()) {
209 auto *list =
static_cast<ListType *>(graalList);
211 for (SizeType i = 0; i < count; i++) {
212 if (list->elements[i]) {
213 ElementWrapper::freeGraal(
static_cast<
void *>(list->elements[i]));
217 delete[] list->elements;
223 static void freeList(
void *graalList) {
224 using ListType = GraalList;
225 using SizeType =
decltype(ListType::size);
227 if (graalList ==
nullptr) {
231 auto list =
static_cast<ListType *>(graalList);
233 if (list->size > 0 && list->elements !=
nullptr) {
234 for (SizeType elementIndex = 0; elementIndex < list->size; elementIndex++) {
235 if (list->elements[elementIndex]) {
236 ElementWrapper::freeGraal(
static_cast<
void *>(list->elements[elementIndex]));
240 delete[] list->elements;
246 static std::vector<ElementWrapper> fromList(
void *graalList) {
247 using ListType = GraalList;
248 using SizeType =
decltype(ListType::size);
254 std::vector<ElementWrapper> result{};
256 auto list =
static_cast<ListType *>(graalList);
258 if (list->size > 0 && list->elements !=
nullptr) {
259 for (SizeType elementIndex = 0; elementIndex < list->size; elementIndex++) {
260 if (list->elements[elementIndex]) {
261 result.emplace_back(ElementWrapper::fromGraal(
static_cast<
void *>(list->elements[elementIndex])));
271
272
274 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
279static constexpr std::int64_t floorDiv(std::int64_t x, std::int64_t y) {
280 std::int64_t r = x / y;
283 if ((x < 0) != (y < 0) && (r * y != x)) {
290static constexpr std::int64_t floorMod(std::int64_t x, std::int64_t y) {
291 return x - (floorDiv(x, y) * y);
294static const double NaN = std::numeric_limits<
double>::quiet_NaN();
296inline bool equals(
double a,
double b,
double eps = std::numeric_limits<
double>::epsilon()) {
297 if (std::isnan(a) || std::isnan(b)) {
301 return std::abs(a - b) < eps;
304template <
typename T,
typename U>
static bool equals(T a, U b,
double eps = std::numeric_limits<
double>::epsilon()) {
305 if (std::isnan(
static_cast<
double>(a)) || std::isnan(
static_cast<
double>(b))) {
309 return std::abs(
static_cast<
double>(a) -
static_cast<
double>(b)) < eps;
314namespace time_nanos_util {
315static constexpr std::int64_t NANOS_IN_MILLIS = 1'000'000LL;
318
319
320
321
322
323
324
325static constexpr std::int64_t getNanosFromMillisAndNanoPart(std::int64_t timeMillis, std::int32_t timeNanoPart) {
326 return (timeMillis * NANOS_IN_MILLIS) + timeNanoPart;
330
331
332
333
334
335
336
337
338
339static constexpr std::int64_t getMillisFromNanos(std::int64_t timeNanos) {
340 return math::floorDiv(timeNanos, NANOS_IN_MILLIS);
344
345
346
347
348
349
350
351
352
353static constexpr std::int32_t getNanoPartFromNanos(std::int64_t timeNanos) {
354 return static_cast<std::int32_t>(math::floorMod(timeNanos, NANOS_IN_MILLIS));
361static constexpr std::int64_t SECOND = 1000LL;
364static constexpr std::int64_t MINUTE = 60LL * SECOND;
367static constexpr std::int64_t HOUR = 60LL * MINUTE;
370static constexpr std::int64_t DAY = 24LL * HOUR;
373
374
375
376
377
378
379static constexpr std::int32_t getMillisFromTime(std::int64_t timeMillis) {
380 return static_cast<std::int32_t>(math::floorMod(timeMillis, SECOND));
384
385
386
387
388
389
390static constexpr std::int32_t getSecondsFromTime(std::int64_t timeMillis) {
391 if (timeMillis >= 0) {
392 return static_cast<std::int32_t>(
393 std::min(timeMillis / SECOND,
static_cast<std::int64_t>(std::numeric_limits<std::int32_t>::max())));
396 return static_cast<std::int32_t>(
397 std::max((timeMillis + 1) / SECOND - 1,
static_cast<std::int64_t>(std::numeric_limits<std::int32_t>::min())));
404
405
406
407
408
409
410
411template <Integral T>
constexpr static T div(T a, T b) {
417 return ((a + 1) / b) - 1;
420 return ((a + 1) / b) + 1;
423template <Integral T>
constexpr static T abs(T a) {
424 return a < 0 ? -a : a;
432static std::int32_t DAY_OF_YEAR[] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
436
437
438
439
440
441
442
443
444constexpr static std::int32_t getYearMonthDayByDayId(std::int32_t dayId) {
445 std::int32_t j = dayId + 2472632;
446 std::int32_t g = math_util::div(j, 146097);
447 std::int32_t dg = j - g * 146097;
448 std::int32_t c = (dg / 36524 + 1) * 3 / 4;
449 std::int32_t dc = dg - c * 36524;
450 std::int32_t b = dc / 1461;
451 std::int32_t db = dc - b * 1461;
452 std::int32_t a = (db / 365 + 1) * 3 / 4;
453 std::int32_t da = db - a * 365;
454 std::int32_t y = g * 400 + c * 100 + b * 4 +
456 std::int32_t m = (da * 5 + 308) / 153 -
459 da - (m + 4) * 153 / 5 + 122;
460 std::int32_t yyyy = y - 4800 + (m + 2) / 12;
461 std::int32_t mm = (m + 2) % 12 + 1;
462 std::int32_t dd = d + 1;
463 std::int32_t yyyymmdd = math_util::abs(yyyy) * 10000 + mm * 100 + dd;
465 return yyyy >= 0 ? yyyymmdd : -yyyymmdd;
468std::int32_t getDayIdByYearMonthDay(std::int32_t year, std::int32_t month, std::int32_t day);
473template <
typename...>
struct MaxImpl;
475template <
typename T>
struct MaxImpl<T> {
479template <
typename T,
typename U>
struct MaxImpl<T, U> {
480 using Type = std::conditional_t<
sizeof(T) >=
sizeof(U), T, U>;
483template <
typename T,
typename U,
typename V,
typename... Ws>
struct MaxImpl<T, U, V, Ws...> {
484 using Type =
typename MaxImpl<T,
typename MaxImpl<U,
typename MaxImpl<V, Ws...>::Type>::Type>::Type;
489
490
491template <
typename... Ts>
using Max =
typename detail::MaxImpl<Ts...>::Type;
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508template <Integral V, Integral S>
static constexpr V sar(V value, S shift)
noexcept;
511
512
513
514
515
516
517
518
519
520
521
522
523
524template <Integral V, Integral S>
static constexpr V leftArithmeticShift(V value, S shift)
noexcept {
525 if constexpr (std::is_signed_v<S>) {
527 return sar(value, -shift);
531 if (shift == 0 || value == 0) {
535 auto unsignedShift =
static_cast<std::make_unsigned_t<S>>(shift);
537 if (unsignedShift >=
sizeof(V) * CHAR_BIT) {
541 return value << unsignedShift;
545
546
547
548
549
550
551
552
553
554
555
556
557
558template <Integral V, Integral S>
static constexpr V sal(V value, S shift)
noexcept {
559 return leftArithmeticShift(value, shift);
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577template <Integral V, Integral S>
static constexpr V rightArithmeticShift(V value, S shift)
noexcept {
578 if constexpr (std::is_signed_v<S>) {
580 return sal(value, -shift);
584 if (shift == 0 || value == 0) {
588 auto unsignedShift =
static_cast<std::make_unsigned_t<S>>(shift);
590 if (unsignedShift >=
sizeof(V) * CHAR_BIT) {
591 return value < 0 ? -1 : 0;
594 return value >> unsignedShift;
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612template <Integral V, Integral S>
static constexpr V sar(V value, S shift)
noexcept {
613 return rightArithmeticShift(value, shift);
617
618
619
620
621
622
623
624
625
626
627
628
629
630template <Integral V, Integral S>
static constexpr V shr(V value, S shift)
noexcept;
633
634
635
636
637
638
639
640
641
642
643
644
645
646template <Integral V, Integral S>
static constexpr V leftLogicalShift(V value, S shift)
noexcept {
647 if constexpr (std::is_signed_v<S>) {
649 return shr(value, -shift);
653 if (shift == 0 || value == 0) {
657 auto unsignedShift =
static_cast<std::make_unsigned_t<S>>(shift);
659 if (unsignedShift >=
sizeof(V) * CHAR_BIT) {
663 return value << unsignedShift;
667
668
669
670
671
672
673
674
675
676
677
678
679
680template <Integral V, Integral S>
static constexpr V shl(V value, S shift)
noexcept {
681 return leftLogicalShift(value, shift);
685
686
687
688
689
690
691
692
693
694
695
696
697
698template <Integral V, Integral S>
static constexpr V rightLogicalShift(V value, S shift)
noexcept {
699 if constexpr (std::is_signed_v<S>) {
701 return shl(value, -shift);
705 if (shift == 0 || value == 0) {
709 auto unsignedShift =
static_cast<std::make_unsigned_t<S>>(shift);
711 if (unsignedShift >=
sizeof(V) * CHAR_BIT) {
715 return static_cast<V>(
static_cast<std::make_unsigned_t<V>>(value) >> unsignedShift);
719
720
721
722
723
724
725
726
727
728
729
730
731
732template <Integral V, Integral S>
static constexpr V shr(V value, S shift)
noexcept {
733 return rightLogicalShift(value, shift);
736template <Integral A, Integral B>
static constexpr A andOp(A a, B b)
noexcept {
737 using Common = std::make_unsigned_t<Max<A, B>>;
739 return static_cast<A>(
static_cast<Common>(a) &
static_cast<Common>(b));
742template <Integral A, Integral B>
static constexpr A orOp(A a, B b)
noexcept {
743 using Common = std::make_unsigned_t<Max<A, B>>;
745 return static_cast<A>(
static_cast<Common>(a) |
static_cast<Common>(b));
748template <Integral A, Integral B>
static constexpr A xorOp(A a, B b)
noexcept {
749 using Common = std::make_unsigned_t<Max<A, B>>;
751 return static_cast<A>(
static_cast<Common>(a) ^
static_cast<Common>(b));
754template <Integral F, Integral M, Integral S>
static constexpr F getBits(F flags, M mask, S shift)
noexcept {
755 return static_cast<F>(andOp(shr(flags, shift), mask));
758template <Integral T>
static constexpr T setBits(T flags, T mask, T shift, T bits)
noexcept {
759 if constexpr (std::is_signed_v<T>) {
760 using U = std::make_unsigned_t<T>;
762 return static_cast<T>((
static_cast<U>(flags) & ~(
static_cast<U>(mask) <<
static_cast<U>(shift))) |
763 ((
static_cast<U>(bits) &
static_cast<U>(mask)) <<
static_cast<U>(shift)));
765 return (flags & ~(mask << shift)) | ((bits & mask) << shift);
769template <Integral F, Integral M, Integral S, Integral B>
770static constexpr F setBits(F flags, M mask, S shift, B bits)
noexcept {
771 if constexpr (std::is_signed_v<F> || std::is_signed_v<M> || std::is_signed_v<S> || std::is_signed_v<B>) {
772 using U = std::make_unsigned_t<Max<F, M, S, B>>;
774 return static_cast<F>((
static_cast<U>(flags) & ~(
static_cast<U>(mask) <<
static_cast<U>(shift))) |
775 ((
static_cast<U>(bits) &
static_cast<U>(mask)) <<
static_cast<U>(shift)));
777 return (flags & ~(mask << shift)) | ((bits & mask) << shift);
781template <std::size_t Bits>
struct hashMixImpl;
783template <>
struct hashMixImpl<64> {
784 constexpr static std::uint64_t fn(std::uint64_t x)
noexcept {
785 std::uint64_t
const m = (
static_cast<std::uint64_t>(0xe9846af) << 32) + 0x9b1a615d;
797template <>
struct hashMixImpl<32> {
798 constexpr static std::uint32_t fn(std::uint32_t x)
noexcept {
799 std::uint32_t
const m1 = 0x21f0aaad;
800 std::uint32_t
const m2 = 0x735a2d97;
812constexpr static std::size_t hashMix(std::size_t v)
noexcept {
813 return hashMixImpl<
sizeof(std::size_t) * CHAR_BIT>::fn(v);
816template <
class T>
constexpr void hashCombine(std::size_t &seed,
const T &v)
noexcept {
817 seed = hashMix(seed + 0x9e3779b9 + std::hash<T>()(v));
820template <Integral T, Integral U>
constexpr std::size_t pack(T t, U u)
noexcept {
821 constexpr auto sizeOfSize =
sizeof(std::size_t) * CHAR_BIT;
823 return orOp(shl(t, sizeOfSize / 2), u);
826constexpr std::pair<std::size_t, std::size_t> unpack(std::size_t v)
noexcept {
827 constexpr auto sizeOfSize =
sizeof(std::size_t) * CHAR_BIT;
829 return {shr(v, sizeOfSize / 2), andOp(v, shr(~std::size_t{}, sizeOfSize / 2))};
832template <
typename T,
typename U> T fitToType(
const U &size) {
833 static_assert(
sizeof(T) <=
sizeof(U));
835 return static_cast<T>(
static_cast<U>(std::numeric_limits<T>::max()) < size ? std::numeric_limits<T>::max() : size);
839
840
841
849 StringLikeWrapperOld(std::string_view sv) : data_{sv} {
852 StringLikeWrapperOld(
const char *chars) : data_{chars ==
nullptr ? std::string_view{} : std::string_view{chars}} {
855 StringLikeWrapperOld(
const std::string &s) : data_{s} {
858 StringLikeWrapperOld(std::string &&s) : data_{std::move(s)} {
862 StringLikeWrapperOld(
const char (&chars)[N]) : StringLikeWrapperOld{std::string_view{chars, chars + N}} {
865 operator std::string()
const {
866 if (
auto sv = std::get_if<std::string_view>(&data_); sv) {
867 return {sv->data(), sv->size()};
869 return std::get<std::string>(data_);
881 const char *
data()
const {
889 const char *
c_str()
const {
944#ifdef _LIBCPP_VERSION
961 using is_transparent =
void;
963 std::size_t operator()(
const char *str)
const {
964 return HashType{}(str);
967 std::size_t operator()(std::string_view sw)
const {
968 return HashType{}(sw);
971 std::size_t operator()(std::string
const &str)
const {
972 return HashType{}(str);
976 return HashType{}(sw);
982void throwInvalidChar(
char c,
const std::string &name);
984inline void checkChar(
char c, std::uint32_t mask,
const std::string &name) {
985 if ((andOp(c, ~mask)) != 0) {
986 throwInvalidChar(c, name);
994template <Integral Type,
typename ResultType =
int> ResultType compare(Type v1, Type v2) {
1006inline int compare(
double d1,
double d2) {
1007 if (std::isnan(d1) || std::isnan(d2)) {
1008 return std::isnan(d1) ? (std::isnan(d2) ? 0 : -1) : 1;
#define DXFCPP_MACRO_CONCAT_INNER(a, b)
Definition Common.hpp:129
#define DXFCPP_MACRO_CONCAT(a, b)
Definition Common.hpp:128
#define DXFCPP_MACRO_UNIQUE_NAME(base)
Definition Common.hpp:130
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:31
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:97
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:94
#define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:47
#define DXFCXX_DISABLE_GCC_WARNINGS_POP()
Definition Conf.hpp:49
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:30
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builderHandle, const char *name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:680
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builder_t builder, const dxfc_dxendpoint_property_t **properties, size_t size)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.cpp:713
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:961
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1151
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_builder_t builder, const char *key, DXFC_OUT int *supports)
Checks if a property is supported.
Definition DXEndpoint.cpp:740
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Adds a listener notified about changes in state property.
Definition DXEndpoint.cpp:1097
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1012
#define DXFCPP_EXPORT
Definition api.h:35
void * dxfc_dxendpoint_builder_t
The dxFeed endpoint's builder handle.
Definition api.h:207
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t endpoint)
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:910
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint)
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:1063
dxfc_dxendpoint_state_t
Represents the current state of endpoint.
Definition api.h:149
@ DXFC_DXENDPOINT_STATE_CLOSED
Endpoint was closed.
Definition api.h:169
@ DXFC_DXENDPOINT_STATE_NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition api.h:153
@ DXFC_DXENDPOINT_STATE_CONNECTING
The connect function was called to establish connection to remove endpoint, but the connection is not...
Definition api.h:159
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to the remote endpoint is established.
Definition api.h:164
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of dxFeed endpoint with a FEED role.
Definition DXEndpoint.cpp:799
#define DXFC_OUT
Definition api.h:17
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_state_t *state)
Returns the state of this endpoint.
Definition DXEndpoint.cpp:1080
void * dxfc_dxendpoint_t
The dxFeed endpoint handle.
Definition api.h:198
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_t builder, const char *key, const char *value)
Sets the specified property.
Definition DXEndpoint.cpp:696
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:787
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:978
dxfc_error_code_t
List of error codes.
Definition api.h:49
@ DXFC_EC_ERROR
The error returned if the current operation cannot be completed.
Definition api.h:60
@ DXFC_EC_SUCCESS
OK.
Definition api.h:53
@ DXFC_EC_G_ERR
dxFeed Graal Native API error.
Definition api.h:57
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:1123
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value)
Sets the system property indicated by the specified key.
Definition System.cpp:73
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Builds the new dxFeed endpoint instance.
Definition DXEndpoint.cpp:757
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1146
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint)
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:1046
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:893
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder)
Creates a new dxFeed endpoint's builder instance.
Definition DXEndpoint.cpp:647
void(* dxfc_dxendpoint_state_change_listener)(dxfc_dxendpoint_state_t old_state, dxfc_dxendpoint_state_t new_state, void *user_data)
The endpoint current state change listener.
Definition api.h:178
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint)
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:995
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_role(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_role_t *role)
Returns the role of this endpoint.
Definition DXEndpoint.cpp:927
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:944
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size)
Gets the system property indicated by the specified key.
dxfc_dxendpoint_role_t
Represents the role of an endpoint that was specified during its creation.
Definition api.h:89
@ DXFC_DXENDPOINT_ROLE_PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition api.h:127
@ DXFC_DXENDPOINT_ROLE_STREAM_FEED
STREAM_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED and also connects to the remote data fee...
Definition api.h:116
@ DXFC_DXENDPOINT_ROLE_FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition api.h:99
@ DXFC_DXENDPOINT_ROLE_STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remot...
Definition api.h:136
@ DXFC_DXENDPOINT_ROLE_LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition api.h:143
@ DXFC_DXENDPOINT_ROLE_ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED, but it is designed to be used with d...
Definition api.h:107
void * dxfc_dxpublisher_t
The dxFeed publisher handle.
Definition api.h:217
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:846
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:822
void * dxfc_dxfeed_t
The dxFeed handle.
Definition api.h:212
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t builder, dxfc_dxendpoint_role_t role)
Sets role for the created dxFeed endpoint.
Definition DXEndpoint.cpp:663
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:869
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1156
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:1029
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:842
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:323
std::shared_ptr< Builder > withName(const StringLike &name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:366
bool supportsProperty(const StringLike &key) const
Checks if a property is supported.
Definition DXEndpoint.cpp:313
std::shared_ptr< Builder > withProperties(Properties &&properties)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.hpp:931
~Builder() noexcept override
Releases the GraalVM handle.
Definition DXEndpoint.cpp:355
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:285
std::shared_ptr< Builder > withProperty(const StringLike &key, const StringLike &value)
Sets the specified property.
Definition DXEndpoint.cpp:298
Manages network connections to feed or publisher.
Definition DXEndpoint.hpp:172
bool isClosed() const
Definition DXEndpoint.cpp:499
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:511
static const std::string DXFEED_PASSWORD_PROPERTY
"dxfeed.password"
Definition DXEndpoint.hpp:238
static std::shared_ptr< DXEndpoint > create(Role role)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:486
std::shared_ptr< DXFeed > getFeed() const
Definition DXEndpoint.cpp:212
std::shared_ptr< DXEndpoint > password(const StringLike &password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:139
State
Represents the current state of endpoint.
Definition DXEndpoint.hpp:436
@ CLOSED
Endpoint was closed.
Definition DXEndpoint.hpp:456
@ CONNECTING
The connect method was called to establish connection to remove endpoint, but the connection is not e...
Definition DXEndpoint.hpp:446
@ CONNECTED
The connection to the remote endpoint is established.
Definition DXEndpoint.hpp:451
@ NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition DXEndpoint.hpp:440
std::shared_ptr< DXEndpoint > user(const StringLike &user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:132
void reconnect() const
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:158
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:477
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:507
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:503
Role
Represents the role of an endpoint that was specified during its creation.
Definition DXEndpoint.hpp:365
@ PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition DXEndpoint.hpp:410
@ STREAM_FEED
STREAM_FEED endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provide...
Definition DXEndpoint.hpp:398
@ LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition DXEndpoint.hpp:426
@ ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandSe...
Definition DXEndpoint.hpp:389
@ STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publish...
Definition DXEndpoint.hpp:419
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition DXEndpoint.hpp:376
std::string toString() const override
Returns a string representation of the current object.
Definition DXEndpoint.cpp:376
void awaitProcessed() const
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:194
std::shared_ptr< DXPublisher > getPublisher() const
Definition DXEndpoint.cpp:221
static const std::string DXFEED_WILDCARD_ENABLE_PROPERTY
"dxfeed.wildcard.enable"
Definition DXEndpoint.hpp:266
std::size_t addStateChangeListener(std::function< void(State, State)> listener) noexcept
Adds a listener notified about changes in state property.
Definition DXEndpoint.hpp:611
static const std::string DXENDPOINT_EVENT_TIME_PROPERTY
"dxendpoint.eventTime"
Definition DXEndpoint.hpp:311
static const std::string DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY
"dxpublisher.threadPoolSize"
Definition DXEndpoint.hpp:294
State getState() const
Returns the state of this endpoint.
Definition DXEndpoint.cpp:128
static const std::string DXENDPOINT_STORE_EVERYTHING_PROPERTY
"dxendpoint.storeEverything"
Definition DXEndpoint.hpp:324
void awaitNotConnected() const
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:185
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:459
static const std::string DXFEED_AGGREGATION_PERIOD_PROPERTY
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:257
void close() const
Closes this endpoint.
Definition DXEndpoint.cpp:515
static const std::string DXFEED_THREAD_POOL_SIZE_PROPERTY
"dxfeed.threadPoolSize"
Definition DXEndpoint.hpp:247
void disconnect() const
Terminates all remote network connections.
Definition DXEndpoint.cpp:167
void closeAndAwaitTermination() const
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:203
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:450
static const std::string DXPUBLISHER_ADDRESS_PROPERTY
"dxpublisher.address"
Definition DXEndpoint.hpp:285
static const std::string DXFEED_USER_PROPERTY
"dxfeed.user"
Definition DXEndpoint.hpp:228
static const std::string NAME_PROPERTY
"name"
Definition DXEndpoint.hpp:189
static const std::string DXSCHEME_ENABLED_PROPERTY_PREFIX
"dxscheme.enabled."
Definition DXEndpoint.hpp:358
static const std::string DXPUBLISHER_PROPERTIES_PROPERTY
"dxpublisher.properties"
Definition DXEndpoint.hpp:275
static const std::string DXSCHEME_NANO_TIME_PROPERTY
"dxscheme.nanoTime"
Definition DXEndpoint.hpp:344
static const std::string DXFEED_ADDRESS_PROPERTY
"dxfeed.address"
Definition DXEndpoint.hpp:218
void disconnectAndClear() const
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:176
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:495
static const std::string DXFEED_PROPERTIES_PROPERTY
"dxfeed.properties"
Definition DXEndpoint.hpp:200
static std::shared_ptr< Builder > newBuilder()
Creates a new Builder instance.
Definition DXEndpoint.cpp:468
std::shared_ptr< DXEndpoint > connect(const StringLike &address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:146
Main entry class for dxFeed API (read it first).
Definition DXFeed.hpp:115
Provides API for publishing of events to local or remote DXFeed.
Definition DXPublisher.hpp:56
Base abstract class for all dxFeed C++ API entities.
Definition Entity.hpp:13
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:31
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:71
A helper class needed to construct smart pointers to objects and does not allow explicit construction...
Definition SharedEntity.hpp:88
static auto createShared(Args &&...args)
Creates a smart pointer to an object.
Definition SharedEntity.hpp:102
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:20
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:77
std::shared_ptr< T > sharedAs() const noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:68
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T.
Definition SharedEntity.hpp:55
bool is() const noexcept
Checks that the pointer to the current type could be converted to type T* In other words: whether typ...
Definition SharedEntity.hpp:34
Universal functional object that allows searching std::unordered_map for string-like keys.
Definition Common.hpp:959
A simple wrapper around strings or something similar to strings to reduce the amount of code for meth...
Definition Common.hpp:842
A lightweight wrapper around strings or string-like inputs.
Definition StringUtils.hpp:27
The simple key-value structure that represents an endpoint's property.
Definition api.h:184
const char * key
The property's key.
Definition api.h:186
const char * value
The property's value.
Definition api.h:188