#include <stdio.h>
#include <stdlib.h>
#include "ndds/ndds_c.h"
#include "HelloWorld.h"
#include "HelloWorldSupport.h"
void HelloWorldListener_on_requested_deadline_missed(
void* listener_data,
{
}
void HelloWorldListener_on_requested_incompatible_qos(
void* listener_data,
{
}
void HelloWorldListener_on_sample_rejected(
void* listener_data,
{
}
void HelloWorldListener_on_liveliness_changed(
void* listener_data,
{
}
void HelloWorldListener_on_sample_lost(
void* listener_data,
{
}
void HelloWorldListener_on_subscription_matched(
void* listener_data,
{
}
void HelloWorldListener_on_data_available(
void* listener_data,
{
HelloWorldDataReader *HelloWorld_reader = NULL;
int i;
HelloWorld_reader = HelloWorldDataReader_narrow(reader);
if (HelloWorld_reader == NULL) {
fprintf(stderr, "DataReader narrow error\n");
return;
}
retcode = HelloWorldDataReader_take(
HelloWorld_reader,
return;
fprintf(stderr, "take error %d\n", retcode);
return;
}
for (i = 0; i < HelloWorldSeq_get_length(&data_seq); ++i) {
if (DDS_SampleInfoSeq_get_reference(&info_seq, i)->valid_data) {
printf("Received data\n");
HelloWorldTypeSupport_print_data(
HelloWorldSeq_get_reference(&data_seq, i));
}
}
retcode = HelloWorldDataReader_return_loan(
HelloWorld_reader,
&data_seq, &info_seq);
fprintf(stderr, "return loan error %d\n", retcode);
}
}
static int subscriber_shutdown(
{
int status = 0;
if (participant != NULL) {
fprintf(stderr, "delete_contained_entities error %d\n", retcode);
status = -1;
}
fprintf(stderr, "delete_participant error %d\n", retcode);
status = -1;
}
}
return status;
}
int subscriber_main(int domainId, int sample_count)
{
const char *type_name = NULL;
int count = 0;
if (participant == NULL) {
fprintf(stderr, "create_participant error\n");
subscriber_shutdown(participant);
return -1;
}
if (subscriber == NULL) {
fprintf(stderr, "create_subscriber error\n");
subscriber_shutdown(participant);
return -1;
}
type_name = HelloWorldTypeSupport_get_type_name();
retcode = HelloWorldTypeSupport_register_type(participant, type_name);
fprintf(stderr, "register_type error %d\n", retcode);
subscriber_shutdown(participant);
return -1;
}
participant, "Example HelloWorld",
if (topic == NULL) {
fprintf(stderr, "create_topic error\n");
subscriber_shutdown(participant);
return -1;
}
HelloWorldListener_on_requested_deadline_missed;
HelloWorldListener_on_requested_incompatible_qos;
HelloWorldListener_on_sample_rejected;
HelloWorldListener_on_liveliness_changed;
HelloWorldListener_on_sample_lost;
HelloWorldListener_on_subscription_matched;
HelloWorldListener_on_data_available;
if (reader == NULL) {
fprintf(stderr, "create_datareader error\n");
subscriber_shutdown(participant);
return -1;
}
for (count=0; (sample_count == 0) || (count < sample_count); ++count) {
printf("HelloWorld subscriber sleeping for %d sec...\n",
}
return subscriber_shutdown(participant);
}
int main(int argc, char *argv[])
{
int domain_id = 0;
int sample_count = 0;
if (argc >= 2) {
domain_id = atoi(argv[1]);
}
if (argc >= 3) {
sample_count = atoi(argv[2]);
}
return subscriber_main(domain_id, sample_count);
}
#define DDS_TheParticipantFactory
Can be used as an alias for the singleton factory returned by the operation DDS_DomainParticipantFact...
Definition: domain.ifc:2844
const struct DDS_DomainParticipantQos DDS_PARTICIPANT_QOS_DEFAULT
Special value for creating a DomainParticipant with default QoS.
DDS_ReturnCode_t DDS_DomainParticipantFactory_delete_participant(DDS_DomainParticipantFactory *self, DDS_DomainParticipant *a_participant)
Deletes an existing DDS_DomainParticipant.
DDS_DomainParticipant * DDS_DomainParticipantFactory_create_participant(DDS_DomainParticipantFactory *self, DDS_DomainId_t domainId, const struct DDS_DomainParticipantQos *qos, const struct DDS_DomainParticipantListener *listener, DDS_StatusMask mask)
Creates a new DDS_DomainParticipant object.
struct DDS_DomainParticipantImpl DDS_DomainParticipant
<<interface>> Container for all DDS_DomainEntity objects.
Definition: infrastructure.ifc:9423
const struct DDS_SubscriberQos DDS_SUBSCRIBER_QOS_DEFAULT
Special value for creating a DDS_Subscriber with default QoS.
const struct DDS_TopicQos DDS_TOPIC_QOS_DEFAULT
Special value for creating a DDS_Topic with default QoS.
DDS_Subscriber * DDS_DomainParticipant_create_subscriber(DDS_DomainParticipant *self, const struct DDS_SubscriberQos *qos, const struct DDS_SubscriberListener *listener, DDS_StatusMask mask)
Creates a DDS_Subscriber with the desired QoS policies and attaches to it the specified DDS_Subscribe...
DDS_Topic * DDS_DomainParticipant_create_topic(DDS_DomainParticipant *self, const char *topic_name, const char *type_name, const struct DDS_TopicQos *qos, const struct DDS_TopicListener *listener, DDS_StatusMask mask)
Creates a DDS_Topic with the desired QoS policies and attaches to it the specified DDS_TopicListener.
DDS_ReturnCode_t DDS_DomainParticipant_delete_contained_entities(DDS_DomainParticipant *self)
Delete all the entities that were created by means of the "create" operations on the DDS_DomainPartic...
const DDS_InstanceStateMask DDS_ANY_INSTANCE_STATE
Any instance state ALIVE_INSTANCE_STATE | NOT_ALIVE_DISPOSED_INSTANCE_STATE | NOT_ALIVE_NO_WRITERS_IN...
struct DDS_DataReaderImpl DDS_DataReader
<<interface>> Allows the application to: (1) declare the data it wishes to receive (i....
Definition: subscription.ifc:230
#define DDS_DataReaderListener_INITIALIZER
Initializer for new DDS_DataReaderListener.
Definition: subscription.ifc:2200
const DDS_Long DDS_LENGTH_UNLIMITED
A special value indicating an unlimited quantity.
DDS_ReturnCode_t
Type for return codes.
Definition: infrastructure.ifc:1336
@ DDS_RETCODE_OK
Successful return.
Definition: infrastructure.ifc:1339
@ DDS_RETCODE_NO_DATA
Indicates a transient situation where the operation did not return any data but there is no inherent ...
Definition: infrastructure.ifc:1383
const DDS_SampleStateMask DDS_ANY_SAMPLE_STATE
Any sample state DDS_READ_SAMPLE_STATE | DDS_NOT_READ_SAMPLE_STATE.
#define DDS_SEQUENCE_INITIALIZER
An initializer for new sequence instances.
Definition: sequence.ifc:566
#define DDS_STATUS_MASK_NONE
No bits are set.
Definition: infrastructure.ifc:1410
#define DDS_STATUS_MASK_ALL
All bits are set.
Definition: infrastructure.ifc:1416
const struct DDS_DataReaderQos DDS_DATAREADER_QOS_DEFAULT
Special value for creating data reader with default QoS.
DDS_DataReader * DDS_Subscriber_create_datareader(DDS_Subscriber *self, DDS_TopicDescription *topic, const struct DDS_DataReaderQos *qos, const struct DDS_DataReaderListener *listener, DDS_StatusMask mask)
Creates a DDS_DataReader that will be attached and belong to the DDS_Subscriber.
struct DDS_SubscriberImpl DDS_Subscriber
<<interface>> A subscriber is the object responsible for actually receiving data from a subscription.
Definition: subscription.ifc:239
DDS_TopicDescription * DDS_Topic_as_topicdescription(DDS_Topic *topic)
Access a DDS_Topic's DDS_TopicDescription supertype instance.
struct DDS_TopicWrapperI DDS_Topic
<<interface>> The most basic description of the data to be published and subscribed.
Definition: topic.ifc:515
const DDS_ViewStateMask DDS_ANY_VIEW_STATE
Any view state DDS_NEW_VIEW_STATE | DDS_NOT_NEW_VIEW_STATE.
void NDDS_Utility_sleep(const struct DDS_Duration_t *durationIn)
Block the calling thread for the specified duration.
<<interface>> DDS_Listener for reader status.
Definition: subscription.ifc:2158
DDS_DataReaderListener_RequestedIncompatibleQosCallback on_requested_incompatible_qos
Handles the DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS communication status.
Definition: subscription.ifc:2172
DDS_DataReaderListener_SampleRejectedCallback on_sample_rejected
Handles the DDS_SAMPLE_REJECTED_STATUS communication status.
Definition: subscription.ifc:2176
DDS_DataReaderListener_SampleLostCallback on_sample_lost
Handles the DDS_SAMPLE_LOST_STATUS communication status.
Definition: subscription.ifc:2193
DDS_DataReaderListener_DataAvailableCallback on_data_available
Handle the DDS_DATA_AVAILABLE_STATUS communication status.
Definition: subscription.ifc:2185
DDS_DataReaderListener_LivelinessChangedCallback on_liveliness_changed
Handles the DDS_LIVELINESS_CHANGED_STATUS communication status.
Definition: subscription.ifc:2181
DDS_DataReaderListener_SubscriptionMatchedCallback on_subscription_matched
Handles the DDS_SUBSCRIPTION_MATCHED_STATUS communication status.
Definition: subscription.ifc:2189
DDS_DataReaderListener_RequestedDeadlineMissedCallback on_requested_deadline_missed
Handles the DDS_REQUESTED_DEADLINE_MISSED_STATUS communication status.
Definition: subscription.ifc:2167
Type for duration representation.
Definition: infrastructure.ifc:642
DDS_Long sec
seconds
Definition: infrastructure.ifc:645
DDS_LIVELINESS_CHANGED_STATUS
Definition: subscription.ifc:311
DDS_REQUESTED_DEADLINE_MISSED_STATUS
Definition: subscription.ifc:266
DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS
Definition: subscription.ifc:365
Declares IDL sequence < DDS_SampleInfo > .
Definition: subscription.ifc:1305
DDS_SAMPLE_LOST_STATUS
Definition: subscription.ifc:492
DDS_SAMPLE_REJECTED_STATUS
Definition: subscription.ifc:578
DDS_SUBSCRIPTION_MATCHED_STATUS
Definition: subscription.ifc:626