25 #ifndef DATAHUB_COMMON_H
26 #define DATAHUB_COMMON_H
42 #define DH_ERR_INVALID_PARAMS ((DHErrorCode)0)
43 #define DH_ERROR_DATA_TOO_BIG ((DHErrorCode)1)
44 #define DH_ERR_NOT_CONNECTED \
46 #define DH_ERR_ALREADY_CONNECTED ((DHErrorCode)3)
47 #define DH_ERR_UNKNOWN_ERROR ((DHErrorCode)4)
48 #define DH_ERR_INTERNAL_ERROR ((DHErrorCode)5)
49 #define DH_ERR_INVALID_ID \
51 #define DH_ERR_INVALID_TOPIC ((DHErrorCode)7)
52 #define DH_ERR_NOT_INITIALIZED ((DHErrorCode)8)
53 #define DH_ERR_MAX_CLIENTS \
55 #define DH_ERR_MAX_CONNECTIONS \
57 #define DH_ERR_AUTHENTICATION_FAILED ((DHErrorCode)11)
58 #define DH_ERR_TOPIC_EXISTS ((DHErrorCode)12)
59 #define DH_ERR_MAX_TOPIC ((DHErrorCode)13)
60 #define DH_ERR_CONNECTION_ERROR ((DHErrorCode)14)
61 #define DH_ERR_INVALID_DATA ((DHErrorCode)15)
62 #define DH_ERR_INVALID_INSTANCE ((DHErrorCode)16)
63 #define DH_ERR_INVALID_KEYS ((DHErrorCode)17)
64 #define DH_ERR_INVALID_SUBSCRIPTION ((DHErrorCode)18)
65 #define DH_ERR_INSTANCE_EXISTS \
67 #define DH_ERR_INSTANCES_NOT_SUPPORTED ((DHErrorCode)20)
68 #define DH_ERR_MAX_INSTANCES \
70 #define DH_ERR_MAX_SUBSCRIPTIONS \
72 #define DH_ERR_AUTHORIZATION_FAILED \
74 #define DH_ERR_MAX_PRODUCTIONS \
76 #define DH_ERR_INVALID_PRODUCTION \
78 #define DH_ERR_INVALID_REQUEST ((DHErrorCode)26)
79 #define DH_ERR_CREDENTIAL_ERROR ((DHErrorCode)27)
89 typedef struct DHError_t
DHError;
215 typedef struct DHTopic_t
DHTopic;
470 const char** out_value,
struct DHTopicSample_t DHTopicSample
Opaque topic sample.
Definition: common.h:250
void dh_topic_data_destroy(DHTopicData *topic_data)
Destroys a topic data object.
void dh_error_destroy(DHError *err)
Destroys an error object.
const DHTimestamp * dh_topic_sample_get_timestamp(const DHTopicSample *topic_sample)
Gets the source timestamp.
bool dh_topic_sample_is_historical(const DHTopicSample *topic_sample)
Checks if the sample is historical data.
struct DHTopicInstance_t DHTopicInstance
Opaque topic instance.
Definition: common.h:242
void dh_timestamp_set_current(DHTimestamp *timestamp)
Updates the timestamp to the current time.
struct DHTimestamp_t DHTimestamp
Opaque UTC timestamp.
Definition: common.h:151
const char * dh_topic_sample_get_topic_name(const DHTopicSample *topic_sample)
Gets the topic name from a sample.
const char * dh_topic_get_json_definition(const DHTopic *topic, DHError **error)
Gets the topic definition as a JSON string.
bool dh_instance_keys_get_integer(const DHInstanceKeys *keys, const char *name, int64_t *out_value, DHError **error)
Gets the integer value of a key.
void dh_topic_list_destroy(DHTopicList *topic_list)
Frees a topic list.
void dh_timestamp_set_with_ms(DHTimestamp *timestamp, int64_t milliseconds)
Sets the timestamp from a Unix epoch value in milliseconds.
void dh_topic_instance_list_destroy(DHTopicInstanceList *instance_list)
Frees a topic instance list.
uint32_t DHErrorCode
API error codes enumeration.
Definition: common.h:41
const char * dh_topic_instance_get_info(const DHTopicInstance *topic_instance)
Gets the instance information.
void dh_instance_keys_destroy(DHInstanceKeys *keys)
Destroys an instance keys object.
uint32_t dh_topic_list_get_count(const DHTopicList *list)
Gets the number of topics in the list.
const DHInstanceKeys * dh_topic_instance_get_keys(const DHTopicInstance *topic_instance)
Gets the instance keys.
bool dh_instance_keys_has_key(const DHInstanceKeys *keys, const char *name)
Checks whether a key exists.
struct DHTopicInstanceList_t DHTopicInstanceList
Opaque topic instance list.
Definition: common.h:266
void dh_topic_destroy(DHTopic *topic)
Destroys a topic.
int64_t dh_timestamp_get_as_ms(const DHTimestamp *timestamp)
Gets the timestamp value as milliseconds since Unix epoch.
const char * dh_topic_instance_get_topic_name(const DHTopicInstance *topic_instance)
Gets the topic name of an instance.
struct DHTopic_t DHTopic
Opaque topic.
Definition: common.h:215
const char * dh_error_to_string(const DHError *err)
Gets a string representation of the complete error.
const char * dh_error_get_message(const DHError *err)
Gets the error message from an error object.
uint64_t dh_topic_sample_get_sample_id(const DHTopicSample *topic_sample)
Gets the sample ID.
bool dh_instance_keys_remove(DHInstanceKeys *keys, const char *name, DHError **error)
Removes a key.
bool dh_instance_keys_add_string(DHInstanceKeys *keys, const char *name, const char *value, DHError **error)
Adds a string key-value pair.
int64_t dh_timestamp_get_as_sec(const DHTimestamp *timestamp)
Gets the timestamp value as seconds since Unix epoch.
const char * dh_error_code_to_string(DHErrorCode code)
Converts an error code to its string representation.
void dh_timestamp_set_with_sec(DHTimestamp *timestamp, int64_t seconds)
Sets the timestamp from a Unix epoch value in seconds.
struct DHInstanceKeys_t DHInstanceKeys
Opaque instance keys.
Definition: common.h:231
const char * dh_topic_get_name(const DHTopic *topic)
Gets the name of a topic.
struct DHTopicList_t DHTopicList
Opaque topic list.
Definition: common.h:258
DHTopicData * dh_topic_data_create(void)
Creates an empty topic data object.
DHErrorCode dh_error_get_code(const DHError *err)
Gets the error code from an error object.
uint32_t dh_topic_instance_list_get_count(const DHTopicInstanceList *list)
Gets the number of instances in the list.
bool dh_instance_keys_add_integer(DHInstanceKeys *keys, const char *name, int64_t value, DHError **error)
Adds an integer key-value pair.
bool dh_instance_keys_get_string(const DHInstanceKeys *keys, const char *name, const char **out_value, DHError **error)
Gets the string value of a key.
bool dh_topic_data_set_json_data(DHTopicData *topic_data, const char *json_str, DHError **error)
Sets the value of topic data from JSON string.
const char * dh_topic_data_get_json_data(const DHTopicData *topic_data)
Gets the topic data value as a JSON string.
const DHTopicInstance * dh_topic_instance_list_get(const DHTopicInstanceList *list, uint32_t index)
Gets a topic instance by index.
void dh_timestamp_destroy(DHTimestamp *timestamp)
Destroys a timestamp.
DHTimestamp * dh_timestamp_create(void)
Creates a timestamp set to the current time.
void dh_topic_instance_destroy(DHTopicInstance *topic_instance)
Destroys a topic instance.
struct DHError_t DHError
Opaque error.
Definition: common.h:89
const char * dh_topic_list_get_name(const DHTopicList *list, uint32_t index)
Gets a topic name by index.
const DHTopicData * dh_topic_sample_get_data(const DHTopicSample *topic_sample)
Gets the topic data from a sample.
DHInstanceKeys * dh_instance_keys_create(void)
Creates an empty instance keys object.
struct DHTopicData_t DHTopicData
Opaque topic data.
Definition: common.h:223