Skip to content

Commit

Permalink
[#210] Use _h_ref instead of _ref_h in C API
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Sep 28, 2024
1 parent 77ab786 commit aa1d7f5
Show file tree
Hide file tree
Showing 60 changed files with 680 additions and 680 deletions.
2 changes: 1 addition & 1 deletion examples/c/domains/src/discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main(int argc, char** argv) {
iox2_config_ptr config_ptr = iox2_config_global_config();
iox2_config_h config = NULL;
iox2_config_from_ptr(config_ptr, NULL, &config);
iox2_config_ref_h config_ref = iox2_cast_config_ref_h(config);
iox2_config_h_ref config_ref = iox2_cast_config_h_ref(config);
config_ptr = iox2_cast_config_ptr(config);

// The domain name becomes the prefix for all resources.
Expand Down
20 changes: 10 additions & 10 deletions examples/c/domains/src/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char** argv) {
iox2_config_ptr config_ptr = iox2_config_global_config();
iox2_config_h config = NULL;
iox2_config_from_ptr(config_ptr, NULL, &config);
iox2_config_ref_h config_ref = iox2_cast_config_ref_h(config);
iox2_config_h_ref config_ref = iox2_cast_config_h_ref(config);

// The domain name becomes the prefix for all resources.
// Therefore, different domain names never share the same resources.
Expand All @@ -44,7 +44,7 @@ int main(int argc, char** argv) {
// create new node
iox2_node_builder_h node_builder_handle = iox2_node_builder_new(NULL);
iox2_node_h node_handle = NULL;
iox2_node_builder_ref_h node_builder_ref = iox2_cast_node_builder_ref_h(node_builder_handle);
iox2_node_builder_h_ref node_builder_ref = iox2_cast_node_builder_h_ref(node_builder_handle);

// use the custom config when creating the custom node
// every service constructed by the node will use this config
Expand All @@ -63,11 +63,11 @@ int main(int argc, char** argv) {

// create service builder
iox2_service_name_ptr service_name_ptr = iox2_cast_service_name_ptr(service_name);
iox2_node_ref_h node_ref_handle = iox2_cast_node_ref_h(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_ref_handle, NULL, service_name_ptr);
iox2_node_h_ref node_h_refandle = iox2_cast_node_h_ref(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_h_refandle, NULL, service_name_ptr);
iox2_service_builder_pub_sub_h service_builder_pub_sub = iox2_service_builder_pub_sub(service_builder);
iox2_service_builder_pub_sub_ref_h service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_ref_h(service_builder_pub_sub);
iox2_service_builder_pub_sub_h_ref service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_h_ref(service_builder_pub_sub);

// set pub sub payload type
const char* payload_type_name = "16TransmissionData";
Expand All @@ -90,18 +90,18 @@ int main(int argc, char** argv) {
}

// create publisher
iox2_port_factory_pub_sub_ref_h ref_service = iox2_cast_port_factory_pub_sub_ref_h(service);
iox2_port_factory_pub_sub_h_ref ref_service = iox2_cast_port_factory_pub_sub_h_ref(service);
iox2_port_factory_publisher_builder_h publisher_builder =
iox2_port_factory_pub_sub_publisher_builder(ref_service, NULL);
iox2_publisher_h publisher = NULL;
if (iox2_port_factory_publisher_builder_create(publisher_builder, NULL, &publisher) != IOX2_OK) {
printf("Unable to create publisher!\n");
goto drop_service;
}
iox2_publisher_ref_h publisher_ref = iox2_cast_publisher_ref_h(publisher);
iox2_publisher_h_ref publisher_ref = iox2_cast_publisher_h_ref(publisher);

int32_t counter = 0;
while (iox2_node_wait(node_ref_handle, 1, 0) == iox2_node_event_e_TICK) {
while (iox2_node_wait(node_h_refandle, 1, 0) == iox2_node_event_e_TICK) {
counter += 1;

// loan sample
Expand All @@ -110,7 +110,7 @@ int main(int argc, char** argv) {
printf("Failed to loan sample\n");
goto drop_publisher;
}
iox2_sample_mut_ref_h sample_ref = iox2_cast_sample_mut_ref_h(sample);
iox2_sample_mut_h_ref sample_ref = iox2_cast_sample_mut_h_ref(sample);

// write payload
struct TransmissionData* payload = NULL;
Expand Down
20 changes: 10 additions & 10 deletions examples/c/domains/src/subscriber.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char** argv) {
iox2_config_ptr config_ptr = iox2_config_global_config();
iox2_config_h config = NULL;
iox2_config_from_ptr(config_ptr, NULL, &config);
iox2_config_ref_h config_ref = iox2_cast_config_ref_h(config);
iox2_config_h_ref config_ref = iox2_cast_config_h_ref(config);

// The domain name becomes the prefix for all resources.
// Therefore, different domain names never share the same resources.
Expand All @@ -44,7 +44,7 @@ int main(int argc, char** argv) {
// create new node
iox2_node_builder_h node_builder_handle = iox2_node_builder_new(NULL);
iox2_node_h node_handle = NULL;
iox2_node_builder_ref_h node_builder_ref = iox2_cast_node_builder_ref_h(node_builder_handle);
iox2_node_builder_h_ref node_builder_ref = iox2_cast_node_builder_h_ref(node_builder_handle);

// use the custom config when creating the custom node
// every service constructed by the node will use this config
Expand All @@ -64,11 +64,11 @@ int main(int argc, char** argv) {

// create service builder
iox2_service_name_ptr service_name_ptr = iox2_cast_service_name_ptr(service_name);
iox2_node_ref_h node_ref_handle = iox2_cast_node_ref_h(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_ref_handle, NULL, service_name_ptr);
iox2_node_h_ref node_h_refandle = iox2_cast_node_h_ref(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_h_refandle, NULL, service_name_ptr);
iox2_service_builder_pub_sub_h service_builder_pub_sub = iox2_service_builder_pub_sub(service_builder);
iox2_service_builder_pub_sub_ref_h service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_ref_h(service_builder_pub_sub);
iox2_service_builder_pub_sub_h_ref service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_h_ref(service_builder_pub_sub);

// set pub sub payload type
const char* payload_type_name = "16TransmissionData";
Expand All @@ -91,19 +91,19 @@ int main(int argc, char** argv) {
}

// create subscriber
iox2_port_factory_pub_sub_ref_h ref_service = iox2_cast_port_factory_pub_sub_ref_h(service);
iox2_port_factory_pub_sub_h_ref ref_service = iox2_cast_port_factory_pub_sub_h_ref(service);
iox2_port_factory_subscriber_builder_h subscriber_builder =
iox2_port_factory_pub_sub_subscriber_builder(ref_service, NULL);
iox2_subscriber_h subscriber = NULL;
if (iox2_port_factory_subscriber_builder_create(subscriber_builder, NULL, &subscriber) != IOX2_OK) {
printf("Unable to create subscriber!\n");
goto drop_service;
}
iox2_subscriber_ref_h subscriber_ref = iox2_cast_subscriber_ref_h(subscriber);
iox2_subscriber_h_ref subscriber_ref = iox2_cast_subscriber_h_ref(subscriber);

uint64_t counter = 0;
printf("subscribed to: [domain: \"%s\", service: \"%s\"]\n", argv[1], argv[2]);
while (iox2_node_wait(node_ref_handle, 1, 0) == iox2_node_event_e_TICK) {
while (iox2_node_wait(node_h_refandle, 1, 0) == iox2_node_event_e_TICK) {
counter += 1;

// receive sample
Expand All @@ -114,7 +114,7 @@ int main(int argc, char** argv) {
}

if (sample != NULL) {
iox2_sample_ref_h sample_ref = iox2_cast_sample_ref_h(sample);
iox2_sample_h_ref sample_ref = iox2_cast_sample_h_ref(sample);
struct TransmissionData* payload = NULL;
iox2_sample_payload(sample_ref, (const void**) &payload, NULL);

Expand Down
10 changes: 5 additions & 5 deletions examples/c/event/src/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ int main(void) {

// create service
iox2_service_name_ptr service_name_ptr = iox2_cast_service_name_ptr(service_name);
iox2_node_ref_h node_ref_handle = iox2_cast_node_ref_h(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_ref_handle, NULL, service_name_ptr);
iox2_node_h_ref node_h_refandle = iox2_cast_node_h_ref(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_h_refandle, NULL, service_name_ptr);
iox2_service_builder_event_h service_builder_event = iox2_service_builder_event(service_builder);
iox2_port_factory_event_h service = NULL;
if (iox2_service_builder_event_open_or_create(service_builder_event, NULL, &service) != IOX2_OK) {
Expand All @@ -45,17 +45,17 @@ int main(void) {
}

// create listener
iox2_port_factory_event_ref_h ref_service = iox2_cast_port_factory_event_ref_h(service);
iox2_port_factory_event_h_ref ref_service = iox2_cast_port_factory_event_h_ref(service);
iox2_port_factory_listener_builder_h listener_builder = iox2_port_factory_event_listener_builder(ref_service, NULL);
iox2_listener_h listener = NULL;
if (iox2_port_factory_listener_builder_create(listener_builder, NULL, &listener) != IOX2_OK) {
printf("Unable to create listener!\n");
goto drop_service;
}
iox2_listener_ref_h listener_ref = iox2_cast_listener_ref_h(listener);
iox2_listener_h_ref listener_ref = iox2_cast_listener_h_ref(listener);
iox2_event_id_t event_id;

while (iox2_node_wait(node_ref_handle, 0, 0) == iox2_node_event_e_TICK) {
while (iox2_node_wait(node_h_refandle, 0, 0) == iox2_node_event_e_TICK) {
bool has_received_one = false;
if (iox2_listener_timed_wait_one(listener_ref, &event_id, &has_received_one, 1, 0) != IOX2_OK) {
printf("Unable to wait for notification!\n");
Expand Down
10 changes: 5 additions & 5 deletions examples/c/event/src/notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ int main(void) {

// create service
iox2_service_name_ptr service_name_ptr = iox2_cast_service_name_ptr(service_name);
iox2_node_ref_h node_ref_handle = iox2_cast_node_ref_h(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_ref_handle, NULL, service_name_ptr);
iox2_node_h_ref node_h_refandle = iox2_cast_node_h_ref(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_h_refandle, NULL, service_name_ptr);
iox2_service_builder_event_h service_builder_event = iox2_service_builder_event(service_builder);
iox2_port_factory_event_h service = NULL;
if (iox2_service_builder_event_open_or_create(service_builder_event, NULL, &service) != IOX2_OK) {
Expand All @@ -52,17 +52,17 @@ int main(void) {
}

// create notifier
iox2_port_factory_event_ref_h ref_service = iox2_cast_port_factory_event_ref_h(service);
iox2_port_factory_event_h_ref ref_service = iox2_cast_port_factory_event_h_ref(service);
iox2_port_factory_notifier_builder_h notifier_builder = iox2_port_factory_event_notifier_builder(ref_service, NULL);
iox2_notifier_h notifier = NULL;
if (iox2_port_factory_notifier_builder_create(notifier_builder, NULL, &notifier) != IOX2_OK) {
printf("Unable to create notifier!\n");
goto drop_service;
}
iox2_notifier_ref_h notifier_ref = iox2_cast_notifier_ref_h(notifier);
iox2_notifier_h_ref notifier_ref = iox2_cast_notifier_h_ref(notifier);

uint64_t counter = 0;
while (iox2_node_wait(node_ref_handle, 0, 0) == iox2_node_event_e_TICK) {
while (iox2_node_wait(node_h_refandle, 0, 0) == iox2_node_event_e_TICK) {
counter += 1;
iox2_event_id_t event_id = { .value = counter % 12 }; // NOLINT
if (iox2_notifier_notify_with_custom_event_id(notifier_ref, &event_id, NULL) != IOX2_OK) {
Expand Down
16 changes: 8 additions & 8 deletions examples/c/publish_subscribe/src/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ int main(void) {

// create service builder
iox2_service_name_ptr service_name_ptr = iox2_cast_service_name_ptr(service_name);
iox2_node_ref_h node_ref_handle = iox2_cast_node_ref_h(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_ref_handle, NULL, service_name_ptr);
iox2_node_h_ref node_h_refandle = iox2_cast_node_h_ref(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_h_refandle, NULL, service_name_ptr);
iox2_service_builder_pub_sub_h service_builder_pub_sub = iox2_service_builder_pub_sub(service_builder);
iox2_service_builder_pub_sub_ref_h service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_ref_h(service_builder_pub_sub);
iox2_service_builder_pub_sub_h_ref service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_h_ref(service_builder_pub_sub);

// set pub sub payload type
const char* payload_type_name = "16TransmissionData";
Expand All @@ -68,18 +68,18 @@ int main(void) {
}

// create publisher
iox2_port_factory_pub_sub_ref_h ref_service = iox2_cast_port_factory_pub_sub_ref_h(service);
iox2_port_factory_pub_sub_h_ref ref_service = iox2_cast_port_factory_pub_sub_h_ref(service);
iox2_port_factory_publisher_builder_h publisher_builder =
iox2_port_factory_pub_sub_publisher_builder(ref_service, NULL);
iox2_publisher_h publisher = NULL;
if (iox2_port_factory_publisher_builder_create(publisher_builder, NULL, &publisher) != IOX2_OK) {
printf("Unable to create publisher!\n");
goto drop_service;
}
iox2_publisher_ref_h publisher_ref = iox2_cast_publisher_ref_h(publisher);
iox2_publisher_h_ref publisher_ref = iox2_cast_publisher_h_ref(publisher);

int32_t counter = 0;
while (iox2_node_wait(node_ref_handle, 1, 0) == iox2_node_event_e_TICK) {
while (iox2_node_wait(node_h_refandle, 1, 0) == iox2_node_event_e_TICK) {
counter += 1;

// loan sample
Expand All @@ -88,7 +88,7 @@ int main(void) {
printf("Failed to loan sample\n");
goto drop_publisher;
}
iox2_sample_mut_ref_h sample_ref = iox2_cast_sample_mut_ref_h(sample);
iox2_sample_mut_h_ref sample_ref = iox2_cast_sample_mut_h_ref(sample);

// write payload
struct TransmissionData* payload = NULL;
Expand Down
16 changes: 8 additions & 8 deletions examples/c/publish_subscribe/src/subscriber.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ int main(void) {

// create service builder
iox2_service_name_ptr service_name_ptr = iox2_cast_service_name_ptr(service_name);
iox2_node_ref_h node_ref_handle = iox2_cast_node_ref_h(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_ref_handle, NULL, service_name_ptr);
iox2_node_h_ref node_h_refandle = iox2_cast_node_h_ref(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_h_refandle, NULL, service_name_ptr);
iox2_service_builder_pub_sub_h service_builder_pub_sub = iox2_service_builder_pub_sub(service_builder);
iox2_service_builder_pub_sub_ref_h service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_ref_h(service_builder_pub_sub);
iox2_service_builder_pub_sub_h_ref service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_h_ref(service_builder_pub_sub);

// set pub sub payload type
const char* payload_type_name = "16TransmissionData";
Expand All @@ -68,18 +68,18 @@ int main(void) {
}

// create subscriber
iox2_port_factory_pub_sub_ref_h ref_service = iox2_cast_port_factory_pub_sub_ref_h(service);
iox2_port_factory_pub_sub_h_ref ref_service = iox2_cast_port_factory_pub_sub_h_ref(service);
iox2_port_factory_subscriber_builder_h subscriber_builder =
iox2_port_factory_pub_sub_subscriber_builder(ref_service, NULL);
iox2_subscriber_h subscriber = NULL;
if (iox2_port_factory_subscriber_builder_create(subscriber_builder, NULL, &subscriber) != IOX2_OK) {
printf("Unable to create subscriber!\n");
goto drop_service;
}
iox2_subscriber_ref_h subscriber_ref = iox2_cast_subscriber_ref_h(subscriber);
iox2_subscriber_h_ref subscriber_ref = iox2_cast_subscriber_h_ref(subscriber);

uint64_t counter = 0;
while (iox2_node_wait(node_ref_handle, 1, 0) == iox2_node_event_e_TICK) {
while (iox2_node_wait(node_h_refandle, 1, 0) == iox2_node_event_e_TICK) {
counter += 1;

// receive sample
Expand All @@ -90,7 +90,7 @@ int main(void) {
}

if (sample != NULL) {
iox2_sample_ref_h sample_ref = iox2_cast_sample_ref_h(sample);
iox2_sample_h_ref sample_ref = iox2_cast_sample_h_ref(sample);
struct TransmissionData* payload = NULL;
iox2_sample_payload(sample_ref, (const void**) &payload, NULL);

Expand Down
16 changes: 8 additions & 8 deletions examples/c/publish_subscribe_with_user_header/src/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ int main(void) {

// create service builder
iox2_service_name_ptr service_name_ptr = iox2_cast_service_name_ptr(service_name);
iox2_node_ref_h node_ref_handle = iox2_cast_node_ref_h(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_ref_handle, NULL, service_name_ptr);
iox2_node_h_ref node_h_refandle = iox2_cast_node_h_ref(node_handle);
iox2_service_builder_h service_builder = iox2_node_service_builder(node_h_refandle, NULL, service_name_ptr);
iox2_service_builder_pub_sub_h service_builder_pub_sub = iox2_service_builder_pub_sub(service_builder);
iox2_service_builder_pub_sub_ref_h service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_ref_h(service_builder_pub_sub);
iox2_service_builder_pub_sub_h_ref service_builder_pub_sub_ref =
iox2_cast_service_builder_pub_sub_h_ref(service_builder_pub_sub);

// set pub sub payload type
const char* payload_type_name = "m";
Expand Down Expand Up @@ -81,18 +81,18 @@ int main(void) {
}

// create publisher
iox2_port_factory_pub_sub_ref_h ref_service = iox2_cast_port_factory_pub_sub_ref_h(service);
iox2_port_factory_pub_sub_h_ref ref_service = iox2_cast_port_factory_pub_sub_h_ref(service);
iox2_port_factory_publisher_builder_h publisher_builder =
iox2_port_factory_pub_sub_publisher_builder(ref_service, NULL);
iox2_publisher_h publisher = NULL;
if (iox2_port_factory_publisher_builder_create(publisher_builder, NULL, &publisher) != IOX2_OK) {
printf("Unable to create publisher!\n");
goto drop_service;
}
iox2_publisher_ref_h publisher_ref = iox2_cast_publisher_ref_h(publisher);
iox2_publisher_h_ref publisher_ref = iox2_cast_publisher_h_ref(publisher);

int32_t counter = 0;
while (iox2_node_wait(node_ref_handle, 1, 0) == iox2_node_event_e_TICK) {
while (iox2_node_wait(node_h_refandle, 1, 0) == iox2_node_event_e_TICK) {
counter += 1;

// loan sample
Expand All @@ -101,7 +101,7 @@ int main(void) {
printf("Failed to loan sample\n");
goto drop_publisher;
}
iox2_sample_mut_ref_h sample_ref = iox2_cast_sample_mut_ref_h(sample);
iox2_sample_mut_h_ref sample_ref = iox2_cast_sample_mut_h_ref(sample);

// write payload
uint64_t* payload = NULL;
Expand Down
Loading

0 comments on commit aa1d7f5

Please sign in to comment.