forked from dxFeed/dxfeed-c-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataStructures.h
182 lines (156 loc) · 7.09 KB
/
DataStructures.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is Devexperts LLC.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*/
#ifndef DATA_STRUCTURES_H_INCLUDED
#define DATA_STRUCTURES_H_INCLUDED
#include "DXTypes.h"
#include "RecordFieldSetters.h"
#include "EventData.h"
#include "DXThreads.h"
/* -------------------------------------------------------------------------- */
/*
* Connection context functions
*/
/* -------------------------------------------------------------------------- */
void* dx_get_data_structures_connection_context (dxf_connection_t connection);
/* -------------------------------------------------------------------------- */
/*
* Event record types and structures
*/
/* -------------------------------------------------------------------------- */
typedef enum {
dx_fid_void = 0,
dx_fid_byte = 1,
dx_fid_utf_char = 2,
dx_fid_short = 3,
dx_fid_int = 4,
// ids 5,6,7 are reserved for future use
dx_fid_compact_int = 8,
dx_fid_byte_array = 9,
dx_fid_utf_char_array = 10,
// ids 11-15 are reserved for future use as array of short, array of int, etc
dx_fid_flag_int = 0x00, // plain int as int field
dx_fid_flag_decimal = 0x10, // decimal representation as int field
dx_fid_flag_short_string = 0x20, // short (up to 4-character) string representation as int field
dx_fid_flag_time_seconds = 0x30, // time in seconds as integer field
dx_fid_flag_sequence = 0x40, // sequence in this integer fields (with top 10 bits representing millis)
dx_fid_flag_date = 0x50, // day id in this integer field
dx_fid_flag_long = 0x60, // plain long as two int fields
dx_fid_flag_wide_decimal = 0x70, // WideDecimal representation as long field
dx_fid_flag_string = 0x80, // String representation as byte array
dx_fid_flag_time_millis = 0x90, // time in millis as long field
dx_fid_flag_time_nanos = 0xa0, // Reserved for future use: time in nanos as long field
dx_fid_flag_custom_object = 0xe0, // custom serialized object as byte array
dx_fid_flag_serial_object = 0xf0, // serialized object as byte array
dx_fid_mask_serialization = 0x0f,
dx_fid_mask_representation = 0xf0,
dx_fid_flag_wide_decimal_by_compact_int = dx_fid_compact_int | dx_fid_flag_wide_decimal,
dx_fid_flag_wd_by_ci = dx_fid_flag_wide_decimal_by_compact_int,
dx_fid_flag_date_by_compact_int = dx_fid_compact_int | dx_fid_flag_date,
dx_fid_flag_date_by_ci = dx_fid_flag_date_by_compact_int,
dx_fid_flag_time_seconds_by_compact_int = dx_fid_compact_int | dx_fid_flag_time_seconds,
dx_fid_flag_sec_by_ci = dx_fid_flag_time_seconds_by_compact_int,
dx_fid_flag_time_millis_by_compact_int = dx_fid_compact_int | dx_fid_flag_time_millis,
dx_fid_flag_millis_by_ci = dx_fid_flag_time_millis_by_compact_int,
dx_fid_flag_long_by_compact_int = dx_fid_compact_int | dx_fid_flag_long,
dx_fid_flag_long_by_ci = dx_fid_flag_long_by_compact_int,
dx_fid_flag_sequence_by_compact_int = dx_fid_compact_int | dx_fid_flag_sequence,
dx_fid_flag_seq_by_ci = dx_fid_flag_sequence_by_compact_int,
} dx_field_id_t;
/* -------------------------------------------------------------------------- */
typedef enum {
dx_ft_common_field = 0,
dx_ft_first_time_int_field = 1,
dx_ft_second_time_int_field = 2
} dx_scheme_field_time_t;
/* -------------------------------------------------------------------------- */
typedef struct {
int type;
dxf_const_string_t field_name;
dxf_const_string_t field_property_name;
dxf_const_string_t event_property_name;
dx_record_field_setter_t setter;
dx_record_field_def_val_getter_t def_val_getter;
dx_record_field_getter_t getter;
dx_scheme_field_time_t time;
} dx_field_info_t;
/* -------------------------------------------------------------------------- */
typedef struct {
dxf_const_string_t default_name;
int field_count;
const dx_field_info_t* fields;
} dx_record_info_t;
typedef struct {
dxf_string_t name;
int field_count;
const dx_field_info_t* fields;
dx_record_info_id_t info_id;
dxf_char_t suffix[DXF_RECORD_SUFFIX_SIZE];
dxf_char_t exchange_code;
} dx_record_item_t;
typedef int dx_record_server_support_state_t;
typedef struct {
dx_record_server_support_state_t* elements;
size_t size;
size_t capacity;
} dx_record_server_support_state_list_t;
/* -------------------------------------------------------------------------- */
/*
* Record functions
*/
/* -------------------------------------------------------------------------- */
dx_record_id_t dx_get_record_id(void* context, dxf_int_t server_record_id);
int dx_assign_server_record_id(void* context, dx_record_id_t record_id, dxf_int_t server_record_id);
/*
* Returns pointer to record data.
* Don't modify any field of struct and don't free this resources.
*
* context - a data structures connection context.
* record_id - id of record to get data.
* Return: pointer to records item or NULL if connection or record_id is not valid.
*/
const dx_record_item_t* dx_get_record_by_id(void* context, dx_record_id_t record_id);
dx_record_id_t dx_get_record_id_by_name(void* context, dxf_const_string_t record_name);
dx_record_id_t dx_get_next_unsubscribed_record_id(void* context, int isUpdate);
void dx_drop_unsubscribe_counter(void* context);
int dx_find_record_field(const dx_record_item_t* record_info, dxf_const_string_t field_name,
dxf_int_t field_type);
dxf_char_t dx_get_record_exchange_code(void* context, dx_record_id_t record_id);
int dx_set_record_exchange_code(void* context, dx_record_id_t record_id, dxf_char_t exchange_code);
/*
* Creates subscription time field according to record model. Function uses
* dx_ft_first_time_int_field and dx_ft_second_time_int_field flags of the
* record to compose time value. This time value is necessary for correct event
* subscription.
*
* context - data structures connection context pointer
* record_id - subscribed record id
* time - unix time in milliseconds
* value - the result subscription time
* return true if no errors occur otherwise returns false
*/
int dx_create_subscription_time(void* context, dx_record_id_t record_id,
dxf_long_t time, OUT dxf_long_t* value);
dx_record_server_support_state_list_t* dx_get_record_server_support_states(void* context);
int dx_get_record_server_support_state_value(dx_record_server_support_state_list_t* states,
dx_record_id_t record_id,
OUT dx_record_server_support_state_t **value);
/* Functions for working with records list */
dx_record_id_t dx_add_or_get_record_id(dxf_connection_t connection, dxf_const_string_t name);
dx_record_id_t dx_get_records_list_count(void* context);
#endif /* DATA_STRUCTURES_H_INCLUDED */