dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1// Copyright (c) 2025 Devexperts LLC.
2// SPDX-License-Identifier: MPL-2.0
3
4#ifndef DXFEED_NATIVE_API_H_INCLUDED
5#define DXFEED_NATIVE_API_H_INCLUDED
6
7#ifdef __cplusplus
8# include <cstddef>
9# include <cstdint>
10
11extern "C" {
12#else
13# include <stddef.h>
14# include <stdint.h>
15#endif
16
17#define DXFC_OUT
18
19#ifndef DXFCPP_EXPORT
20# if defined(DXFCPP_USE_DLLS) && defined(_MSC_VER)
21# if defined(LIBDXFCPP_EXPORTS)
22# define DXFCPP_EXPORT __declspec(dllexport)
23# define DXFCPP_EXPORT_TEMPLATE_DECLARE
24# define DXFCPP_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
25# else
26# define DXFCPP_EXPORT __declspec(dllimport)
27# define DXFCPP_EXPORT_TEMPLATE_DECLARE
28# define DXFCPP_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
29# endif // defined(LIBDXFCPP_EXPORTS)
30# elif defined(DXFCPP_USE_DLLS) && (defined(LIBDXFCPP_EXPORTS) || !defined(_WIN32))
31# define DXFCPP_EXPORT __attribute__((visibility("default")))
32# define DXFCPP_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
33# define DXFCPP_EXPORT_TEMPLATE_DEFINE
34# else
35# define DXFCPP_EXPORT
36# define DXFCPP_EXPORT_TEMPLATE_DECLARE
37# define DXFCPP_EXPORT_TEMPLATE_DEFINE
38# endif
39#endif
40
41/**
42 * @file
43 * @brief dxFeed Native C API enums, structs and functions declarations
44 *
45 * The Graal isolate of the library takes arguments (the sizes of the heap, the system properties that must be set
46 * before the first Java code runs, the options of the runtime). The C API has no function to set them yet: use the
47 * `DXFCPP_ISOLATE_ARGUMENTS` environment variable, set before the first call of the library. The value is split into
48 * arguments by the whitespace characters; a part in `'...'` or in `"..."` keeps them and loses the quotes, for example
49 * `-Dmy.prop="a b" -Xmx512m`; there are no escape sequences; an unmatched quote and an argument that starts with `@`
50 * are errors. When the isolate cannot be created (an invalid argument; the SDK prints the reason to the standard error
51 * output), dxfc_system_set_property(), dxfc_system_get_property(), dxfc_dxendpoint_new_builder(),
52 * dxfc_dxendpoint_get_instance(), dxfc_dxendpoint_get_instance2(), dxfc_dxendpoint_create() and
53 * dxfc_dxendpoint_create2() return DXFC_EC_ERROR; the other functions need a handle that these return. The creation
54 * is not retried. The rules, the table of the arguments and the examples for the shells are in the C++ documentation
55 * of the library, the page "Isolate arguments".
56 */
57
58/**
59 * @brief List of error codes.
60 */
61typedef enum dxfc_error_code_t {
62 /**
63 * @brief OK.
64 */
66 /**
67 * @brief dxFeed Graal Native API error.
68 */
70
71 /// The error returned if the current operation cannot be completed.
73} dxfc_error_code_t;
74
75/**
76 * Sets the system property indicated by the specified key.
77 *
78 * @param key The name of the system property (UTF-8 string).
79 * @param value The value of the system property (UTF-8 string).
80 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
81 */
82DXFCPP_EXPORT dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value);
83
84/**
85 * Gets the system property indicated by the specified key.
86 *
87 * The buffer must be allocated in advance. If the system property value does not fit into the buffer, it will be
88 * truncated. The buffer should be large enough to the \0 at the end.
89 * Invalid UTF-8 characters resulting from a string that does not fit in the buffer will be discarded.
90 *
91 * @param key The name of the system property (UTF-8 string)
92 * @param[out] buffer The buffer to store the system property (UTF-8 string)
93 * @param buffer_size The buffer's size.
94 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
95 */
96DXFCPP_EXPORT dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size);
97
98/**
99 * Represents the role of an endpoint that was specified during its @ref dxfc_dxendpoint_create() "creation".
100 */
102 /**
103 * `FEED` endpoint connects to the remote data feed provider and is optimized for real-time or
104 * delayed data processing (<b>this is a default role</b>). dxfc_dxendpoint_get_feed() function
105 * returns a feed object that subscribes to the remote data feed provider and receives events from it.
106 * When event processing threads cannot keep up (don't have enough CPU time), data is dynamically conflated to
107 * minimize latency between received events and their processing time.
108 *
109 * This endpoint is automatically connected to the configured data feed.
110 */
112
113 /**
114 * `ON_DEMAND_FEED` endpoint is similar to ::DXFC_DXENDPOINT_ROLE_FEED, but it is designed to be used with
115 * dxfc_on_demand_service_t for historical data replay only.
116 *
117 * `ON_DEMAND_FEED` endpoint cannot be connected to an ordinary data feed at all.
118 */
120
121 /**
122 * `STREAM_FEED` endpoint is similar to ::DXFC_DXENDPOINT_ROLE_FEED and also connects to the remote data feed
123 * provider, but is designed for bulk parsing of data from files. dxfc_dxendpoint_get_feed() function returns a feed
124 * object that subscribes to the data from the opened files and receives events from them. Events from the files are
125 * not conflated, are not skipped, and are processed as fast as possible. Note that in this role,
126 * the dxfc_dxfeed_get_last_event () function does not work.
127 */
129
130 /**
131 * `PUBLISHER` endpoint connects to the remote publisher hub (also known as multiplexor) or
132 * creates a publisher on the local host. dxfc_dxendpoint_get_publisher() function returns
133 * a publisher object that publishes events to all connected feeds.
134 * Note that in this role, the dxfc_dxfeed_get_last_event () function does not work, and
135 * time-series subscription is not supported.
136 *
137 * This endpoint is automatically connected to the configured data feed.
138 */
140
141 /**
142 * `STREAM_PUBLISHER` endpoint is similar to ::DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remote
143 * publisher hub, but is designed for bulk publishing of data. dxfc_dxendpoint_get_publisher() function returns a
144 * publisher object that publishes events to all connected feeds. Published events are not conflated, are not
145 * skipped, and are processed as fast as possible. Note that in this role, the dxfc_dxfeed_get_last_event () function does not work,
146 * and time-series subscription is not supported.
147 */
149
150 /**
151 * `LOCAL_HUB` endpoint is a local hub without the ability to establish network connections.
152 * Events that are published via @ref dxfc_dxendpoint_get_publisher() "publisher" are delivered to local
153 * @ref dxfc_dxendpoint_get_feed() "feed" only.
154 */
156} dxfc_dxendpoint_role_t;
157
158/**
159 * Represents the current state of endpoint.
160 */
162 /**
163 * Endpoint was created by is not connected to remote endpoints.
164 */
166
167 /**
168 * The @ref dxfc_dxendpoint_connect() "connect" function was called to establish connection to
169 * remove endpoint, but the connection is not established yet or was lost.
170 */
172
173 /**
174 * The connection to the remote endpoint is established.
175 */
177
178 /**
179 * Endpoint was @ref dxfc_dxendpoint_close() "closed".
180 */
182} dxfc_dxendpoint_state_t;
183
184/**
185 * The endpoint current state change listener
186 *
187 * @see dxfc_dxendpoint_add_state_change_listener()
188 * @see dxfc_dxendpoint_remove_state_change_listener()
189 */
190typedef void (*dxfc_dxendpoint_state_change_listener)(dxfc_dxendpoint_state_t old_state,
191 dxfc_dxendpoint_state_t new_state, void *user_data);
192
193/**
194 * The simple key-value structure that represents an endpoint's property
195 */
197 /// The property's key
198 const char *key;
199 /// The property's value
200 const char *value;
201} dxfc_dxendpoint_property_t;
202
203/**
204 * The dxFeed endpoint handle. It is used for searching, adding endpoints to the "registry", deleting endpoints from
205 * the "registry" and calling functions associated with a particular endpoint.
206 *
207 * The "registry" is responsible for neatly closing resources, shutting down work, and freeing up memory on shutdown.
208 * This can be forced by calling the dxfc_dxendpoint_free() function.
209 */
210typedef void *dxfc_dxendpoint_t;
211
212/**
213 * The dxFeed endpoint's builder handle. It is used for searching, adding builders to the "registry", deleting builders
214 * from the "registry" and calling functions associated with a particular builder.
215 *
216 * The "registry" is responsible for neatly closing resources, shutting down work, and freeing up memory on shutdown.
217 * This can be forced by calling the dxfc_dxendpoint_builder_free() function.
218 */
220
221/**
222 * The dxFeed handle.
223 */
224typedef void *dxfc_dxfeed_t;
225
226/**
227 * The dxFeed publisher handle.
228 */
229typedef void *dxfc_dxpublisher_t;
230
231/**
232 * Creates a new dxFeed endpoint's builder instance.
233 * Use dxfc_dxendpoint_builder_build to build an instance of dxFeed endpoint when all configuration properties were set.
234 *
235 * @param[out] builder The created endpoint's builder.
236 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
237 */
239
240/**
241 * Sets role for the created dxFeed endpoint.
242 * Default role is @ref DXFC_DXENDPOINT_ROLE_FEED "FEED".
243 *
244 * @param builder The endpoint's builder
245 * @param role The endpoint's role
246 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
247 */
249 dxfc_dxendpoint_role_t role);
250
251/**
252 * Changes the name used to distinguish multiple endpoints
253 * in the same process (GraalVM Isolate) in logs and in other diagnostic means.
254 *
255 * @param builderHandle The endpoint's builder
256 * @param name The endpoint's name
257 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
258 */
259DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builderHandle, const char *name);
260
261/**
262 * Sets the specified property. Unsupported properties are ignored.
263 *
264 * @param builder The endpoint's builder
265 * @param key The endpoint's property key
266 * @param value The endpoint's property value
267 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
268 */
270 const char *key, const char *value);
271
272/**
273 * Sets all supported properties from the provided properties object.
274 *
275 * @param builder The endpoint's builder
276 * @param properties The endpoint's properties
277 * @param size The size of the endpoint's properties
278 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
279 */
281 const dxfc_dxendpoint_property_t **properties,
282 size_t size);
283
284/**
285 * Checks if a property is supported
286 *
287 * @param builder The endpoint's builder
288 * @param key The property's key to be checked for support
289 * @param[out] supports `1` if the corresponding property key is supported.
290 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
291 */
293 const char *key, DXFC_OUT int *supports);
294
295/**
296 * Builds the new dxFeed endpoint instance.
297 *
298 * @param builder The endpoint's builder
299 * @param user_data User data that will be passed to the endpoint's state transition listeners.
300 * @param[out] endpoint The created endpoint
301 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
302 */
303DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data,
304 DXFC_OUT dxfc_dxendpoint_t *endpoint);
305
306/**
307 * Removes a builder from the registry.
308 *
309 * @param builder The endpoint's builder
310 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
311 */
313
314/**
315 * Returns a default application-wide singleton instance of dxFeed endpoint with a @ref DXFC_DXENDPOINT_ROLE_FEED "FEED"
316 * role. Most applications use only a single data-source and should rely on this function to get one. This function
317 * creates an endpoint on the first use with a default configuration. You can provide configuration via system
318 * properties.
319 *
320 * This is a shortcut to
321 * ```c
322 * dxfc_dxendpoint_t endpoint;
323 *
324 * dxfc_dxendpoint_get_instance2(DXFC_DXENDPOINT_ROLE_FEED, user_data, &endpoint);
325 * ```
326 *
327 * @param user_data User data that will be passed to the endpoint's state transition listeners.
328 * @param[out] endpoint The created endpoint
329 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
330 */
331DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint);
332
333/**
334 * Returns a default application-wide singleton instance of DXEndpoint for a specific role.
335 * Most applications use only a single data-source and should rely on this function to get one.
336 * This function creates an endpoint with the corresponding role on the first use with a default
337 * configuration.
338 * You can provide configuration via system properties.
339 *
340 * The configuration does not have to include an address. You can use @ref dxfc_dxendpoint_connect()
341 * "connect(endpoint, address)" and dxfc_dxendpoint_disconnect() functions on the instance that is returned by this
342 * function to programmatically
343 * establish and tear-down connection to a user-provided address.
344 *
345 * If you need a fully programmatic configuration and/or multiple endpoints of the same role in your
346 * application, then create a custom instance of dxFeed endpoint with dxfc_dxendpoint_new_builder() function, configure
347 * it, and use dxfc_dxendpoint_builder_build() function.
348 *
349 * @param role The role of dxFeed endpoint instance
350 * @param user_data User data that will be passed to the endpoint's state transition listeners.
351 * @param[out] endpoint The created endpoint
352 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
353 */
354DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data,
355 DXFC_OUT dxfc_dxendpoint_t *endpoint);
356
357/**
358 * Creates an endpoint with @ref DXFC_DXENDPOINT_ROLE_FEED "FEED" role.
359 * The result of this function is the same as <b>`dxfc_dxendpoint_create2(DXFC_DXENDPOINT_ROLE_FEED, user_data,
360 * &endpoint)`</b>. This is a shortcut to
361 * ```c
362 * dxfc_dxendpoint_builder_t builder;
363 * dxfc_dxendpoint_t endpoint;
364 *
365 * dxfc_dxendpoint_new_builder(&builder);
366 * dxfc_dxendpoint_builder_build(builder, user_data, &endpoint);
367 * ```
368 *
369 * @param user_data User data that will be passed to the endpoint's state transition listeners.
370 * @param[out] endpoint The created endpoint
371 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
372 */
373DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint);
374
375/**
376 * Creates an endpoint with a specified role.
377 * This is a shortcut to
378 * ```c
379 * dxfc_dxendpoint_builder_t builder;
380 * dxfc_dxendpoint_t endpoint;
381 *
382 * dxfc_dxendpoint_new_builder(&builder);
383 * dxfc_dxendpoint_builder_with_role(builder, role);
384 * dxfc_dxendpoint_builder_build(builder, user_data, &endpoint);
385 * ```
386 *
387 * @param role The role of dxFeed endpoint instance
388 * @param user_data User data that will be passed to the endpoint's state transition listeners.
389 * @param[out] endpoint The created endpoint
390 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
391 */
392DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data,
393 DXFC_OUT dxfc_dxendpoint_t *endpoint);
394
395/**
396 * Closes this endpoint. All network connections are terminated as with the dxfc_dxendpoint_disconnect () function, and no
397 * further connections can be established.
398 *
399 * The endpoint @ref dxfc_dxendpoint_get_state() "state" immediately becomes @ref DXFC_DXENDPOINT_STATE_CLOSED "CLOSED".
400 * All resources associated with this endpoint are released.
401 *
402 * @param endpoint The dxFeed endpoint to close
403 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
404 */
405DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint);
406
407/**
408 * Closes this endpoint and wait until all pending data processing tasks are completed.
409 * This function performs the same actions as dxfc_dxendpoint_close() but also awaits
410 * termination of all outstanding data processing tasks. It is designed to be used
411 * with @ref DXFC_DXENDPOINT_ROLE_STREAM_FEED "STREAM_FEED" role after the dxfc_dxendpoint_await_not_connected () function
412 * returns to make sure that the file was completely processed.
413 *
414 * <p><b>This function is blocking.</b>
415 *
416 * @param endpoint The dxFeed endpoint
417 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
418 */
420
421/**
422 * Returns the role of this endpoint.
423 *
424 * @param endpoint The dxFeed endpoint
425 * @param[out] role The role of this endpoint
426 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
427 */
429 DXFC_OUT dxfc_dxendpoint_role_t *role);
430
431/**
432 * Changes username for this endpoint.
433 * This function shall be called before @ref dxfc_dxendpoint_connect() "connect"
434 * with @ref dxfc_dxendpoint_password() "password" to configure service access credentials.
435 *
436 * @param endpoint The dxFeed endpoint
437 * @param user The username
438 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
439 */
440DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user);
441
442/**
443 * Changes password for this endpoint.
444 * This function shall be called before @ref dxfc_dxendpoint_connect() "connect"
445 * with @ref dxfc_dxendpoint_user() "user" to configure service access credentials.
446 *
447 * @param endpoint The dxFeed endpoint
448 * @param password The user password
449 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
450 */
451DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password);
452
453/**
454 * Connects to the specified remote address. Previously established connections are closed if
455 * the new address is different from the old one.
456 * This function does nothing if the address does not change or if this endpoint is @ref DXFC_DXENDPOINT_STATE_CLOSED
457 * "CLOSED". The endpoint @ref dxfc_dxendpoint_get_state() "state" immediately becomes @ref
458 * DXFC_DXENDPOINT_STATE_CONNECTING "CONNECTING" otherwise.
459 *
460 * <p> The address string is provided with the market data vendor agreement.
461 * Use "demo.dxfeed.com:7300" for a demo quote feed.
462 *
463 * <p> The simplest address strings have the following format:
464 * * `host:port` to establish a TCP/IP connection.
465 * * `:port` to listen for a TCP/IP connection with a plain socket connector (good for up to a
466 * few hundred of connections).
467 *
468 * <p>An address that starts with `http://`, `https://`, `ws://` or `wss://` is not an address of an endpoint (for
469 * example, the URLs of REST, CometD and IPF services): the function returns DXFC_EC_ERROR. A QD configuration URL
470 * `http(s)://host/path/<name>.config#<name>` is passed to the SDK.
471 *
472 * <p>For premium services access credentials must be configured before invocation of the ` connect ` function
473 * using @ref dxfc_dxendpoint_user() "user" and @ref dxfc_dxendpoint_password() "password" functions.
474 *
475 * <p> <b>This function does not wait until the connection actually gets established</b>. The actual connection
476 * establishment happens asynchronously after the invocation of this function. However, this function waits until
477 * notification about state transition from DXFC_DXENDPOINT_STATE_NOT_CONNECTED to DXFC_DXENDPOINT_STATE_CONNECTING gets
478 * processed by all listeners.
479 *
480 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#connect-java.lang.String-)
481 *
482 * @param endpoint The dxFeed endpoint
483 * @param address The data source address
484 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
485 */
486DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address);
487
488/**
489 * Terminates all established network connections and initiates connecting again with the same address.
490 *
491 * <p>The effect of the function is alike to invoking dxfc_dxendpoint_disconnect() and dxfc_dxendpoint_connect()
492 * with the current address, but internal resources used for connections may be reused by implementation.
493 * TCP connections with multiple target addresses will try to switch to an alternative address, configured
494 * reconnect timeouts will apply.
495 *
496 * <p><b>Note:</b> The function will not connect an endpoint that was not initially connected with
497 * dxfc_dxendpoint_connect() function or was disconnected with dxfc_dxendpoint_disconnect() function.
498 *
499 * <p>The function initiates a short-pathway for reconnecting, so whether observers will have a chance to see
500 * an intermediate state DXFC_DXENDPOINT_STATE_NOT_CONNECTED depends on the implementation.
501 *
502 * @param endpoint The dxFeed endpoint to reconnect
503 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
504 */
506
507/**
508 * Terminates all remote network connections.
509 * This function does nothing if this endpoint is @ref DXFC_DXENDPOINT_STATE_CLOSED "CLOSED".
510 * The endpoint @ref dxfc_dxendpoint_get_state() "state" immediately becomes @ref DXFC_DXENDPOINT_STATE_NOT_CONNECTED
511 * "NOT_CONNECTED" otherwise.
512 *
513 * <p>This function does not release all resources that are associated with this endpoint.
514 * Use dxfc_dxendpoint_disconnect() function to release all resources.
515 *
516 * @param endpoint The dxFeed endpoint to disconnect
517 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
518 */
520
521/**
522 * Terminates all remote network connections and clears stored data.
523 * This function does nothing if this endpoint is @ref DXFC_DXENDPOINT_STATE_CLOSED "CLOSED".
524 * The endpoint @ref dxfc_dxendpoint_get_state() "state" immediately becomes @ref DXFC_DXENDPOINT_STATE_NOT_CONNECTED
525 * "NOT_CONNECTED" otherwise.
526 *
527 * <p>This function does not release all resources that are associated with this endpoint.
528 * Use dxfc_dxendpoint_close() function to release all resources.
529 *
530 * @param endpoint The dxFeed endpoint
531 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
532 */
534
535/**
536 * Waits until this endpoint stops processing data (becomes quiescent).
537 * This is important when writing data to file via "tape:..." connector to make sure that
538 * all published data was written before closing this endpoint.
539 *
540 * @param endpoint The dxFeed endpoint
541 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
542 */
544
545/**
546 * Waits while this endpoint @ref dxfc_dxendpoint_get_state() "state" becomes @ref DXFC_DXENDPOINT_STATE_NOT_CONNECTED
547 * "NOT_CONNECTED" or
548 * @ref DXFC_DXENDPOINT_STATE_CLOSED "CLOSED". It is a signal that any files opened with
549 * @ref dxfc_dxendpoint_connect() "dxfc_dxendpoint_connect(endpoint, \"file:...\")" function were finished reading, but
550 * not necessarily were completely processed by the corresponding subscription listeners. Use
551 * dxfc_dxendpoint_and_await_termination() after this function returns to make sure that all processing has completed.
552 *
553 * <p><b>This function is blocking.</b>
554 *
555 * @param endpoint The dxFeed endpoint
556 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
557 */
559
560/**
561 * Returns the state of this endpoint.
562 *
563 * @param endpoint The dxFeed endpoint
564 * @param[out] state The state of this endpoint
565 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
566 */
568 DXFC_OUT dxfc_dxendpoint_state_t *state);
569
570/**
571 * Adds a listener notified about changes in @ref dxfc_dxendpoint_get_state() "state" property.
572 *
573 * <p>Installed listener can be removed by dxfc_dxendpoint_remove_state_change_listener() function.
574 *
575 * @param endpoint The dxFeed endpoint
576 * @param listener The listener to add
577 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
578 */
579DXFCPP_EXPORT dxfc_error_code_t
581
582/**
583 * Removes a listener notified about changes in @ref dxfc_dxendpoint_get_state() "state" property.
584 * It removes the listener previously installed with the dxfc_dxendpoint_add_state_change_listener () function.
585 *
586 * @param endpoint The dxFeed endpoint
587 * @param listener The listener to remove
588 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
589 */
592
593/**
594 *
595 * @param endpoint The dxFeed endpoint
596 * @param[out] feed
597 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
598 */
600
601/**
602 *
603 * @param endpoint The dxFeed endpoint
604 * @param[out] publisher
605 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
606 */
608 DXFC_OUT dxfc_dxpublisher_t *publisher);
609
610/**
611 * Removes the dxFeed endpoint from the registry.
612 * @param endpoint The dxFeed endpoint to remove
613 * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR.
614 */
615DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint);
616
617#ifdef __cplusplus
618}
619#endif
620
621#endif // DXFEED_NATIVE_API_H_INCLUDED
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:1125
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:1168
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:1451
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1652
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:1200
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:1598
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1513
#define DXFCPP_EXPORT
Definition api.h:35
void * dxfc_dxendpoint_builder_t
The dxFeed endpoint's builder handle.
Definition api.h:219
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:1395
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:1564
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:190
dxfc_dxendpoint_state_t
Represents the current state of endpoint.
Definition api.h:161
@ DXFC_DXENDPOINT_STATE_CLOSED
Endpoint was closed.
Definition api.h:181
@ DXFC_DXENDPOINT_STATE_NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition api.h:165
@ DXFC_DXENDPOINT_STATE_CONNECTING
The connect function was called to establish connection to remove endpoint, but the connection is not...
Definition api.h:171
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to the remote endpoint is established.
Definition api.h:176
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:1264
#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:1581
void * dxfc_dxendpoint_t
The dxFeed endpoint handle.
Definition api.h:210
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:1146
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:1252
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:1473
dxfc_error_code_t
List of error codes.
Definition api.h:61
@ DXFC_EC_ERROR
The error returned if the current operation cannot be completed.
Definition api.h:72
@ DXFC_EC_SUCCESS
OK.
Definition api.h:65
@ DXFC_EC_G_ERR
dxFeed Graal Native API error.
Definition api.h:69
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:1624
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:208
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:1222
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1647
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:1547
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:1378
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:1087
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:1496
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:1412
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:1429
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:101
@ DXFC_DXENDPOINT_ROLE_PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition api.h:139
@ 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:128
@ 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:111
@ DXFC_DXENDPOINT_ROLE_STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remot...
Definition api.h:148
@ DXFC_DXENDPOINT_ROLE_LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition api.h:155
@ 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:119
void * dxfc_dxpublisher_t
The dxFeed publisher handle.
Definition api.h:229
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:1321
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:1292
void * dxfc_dxfeed_t
The dxFeed handle.
Definition api.h:224
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:1108
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:1349
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1657
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:1530
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:42
std::string toString() const override
Returns a string representation of the current object.
Definition api.cpp:57
virtual std::int64_t getEventTime() const noexcept
Returns time when an event was created or zero when time is not available.
Definition api.cpp:44
virtual void assign(std::shared_ptr< EventType > event)
Replaces the contents of the event.
Definition api.cpp:53
virtual void setEventTime(std::int64_t eventTime) noexcept
Changes event creation time.
Definition api.cpp:48
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:25
The simple key-value structure that represents an endpoint's property.
Definition api.h:196
const char * key
The property's key.
Definition api.h:198
const char * value
The property's value.
Definition api.h:200