#include <stdio.h>
#include <stdlib.h>
#include "ndds/ndds_c.h"
#include "HelloWorld.h"
#include "HelloWorldSupport.h"
 
static int publisher_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 publisher_main(int domainId, int sample_count)
{
    HelloWorldDataWriter *HelloWorld_writer = NULL;
    HelloWorld *instance = NULL;
    const char *type_name = NULL;
    int count = 0;  
 
    
    if (participant == NULL) {
        fprintf(stderr, "create_participant error\n");
        publisher_shutdown(participant);
        return -1;
    }
 
    
    if (publisher == NULL) {
        fprintf(stderr, "create_publisher error\n");
        publisher_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);
        publisher_shutdown(participant);
        return -1;
    }
 
    
        participant, "Example HelloWorld",
    if (topic == NULL) {
        fprintf(stderr, "create_topic error\n");
        publisher_shutdown(participant);
        return -1;
    }
 
    
        publisher, topic,
    if (writer == NULL) {
        fprintf(stderr, "create_datawriter error\n");
        publisher_shutdown(participant);
        return -1;
    }
    HelloWorld_writer = HelloWorldDataWriter_narrow(writer);
    if (HelloWorld_writer == NULL) {
        fprintf(stderr, "DataWriter narrow error\n");
        publisher_shutdown(participant);
        return -1;
    }
 
    
    if (instance == NULL) {
        fprintf(stderr, "HelloWorldTypeSupport_create_data error\n");
        publisher_shutdown(participant);
        return -1;
    }
 
    
    
    
    for (count=0; (sample_count == 0) || (count < sample_count); ++count) {
 
        printf("Writing HelloWorld, count %d\n", count);
 
        
 
        
        retcode = HelloWorldDataWriter_write(
            HelloWorld_writer, instance, &instance_handle);
            fprintf(stderr, "write error %d\n", retcode);
        }
 
 
    }
 
    
    
        fprintf(stderr, "HelloWorldTypeSupport_delete_data error %d\n", retcode);
    }
             
    return publisher_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 publisher_main(domain_id, sample_count);
}
 
#define DDS_BOOLEAN_TRUE
Defines "true" value of DDS_Boolean data type.
Definition: common.ifc:294
 
#define DDS_TheParticipantFactory
Can be used as an alias for the singleton factory returned by the operation DDS_DomainParticipantFact...
Definition: domain.ifc:2855
 
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:9765
 
const struct DDS_TopicQos DDS_TOPIC_QOS_DEFAULT
Special value for creating a DDS_Topic with default QoS.
 
DDS_Publisher * DDS_DomainParticipant_create_publisher(DDS_DomainParticipant *self, const struct DDS_PublisherQos *qos, const struct DDS_PublisherListener *listener, DDS_StatusMask mask)
Creates a DDS_Publisher with the desired QoS policies and attaches to it the specified DDS_PublisherL...
 
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.
 
const struct DDS_PublisherQos DDS_PUBLISHER_QOS_DEFAULT
Special value for creating a DDS_Publisher with default QoS.
 
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...
 
struct DDS_PublisherImpl DDS_Publisher
<<interface>> A publisher is the object responsible for the actual dissemination of publications.
Definition: publication.ifc:182
 
const struct DDS_DataWriterQos DDS_DATAWRITER_QOS_DEFAULT
Special value for creating DDS_DataWriter with default QoS.
 
DDS_DataWriter * DDS_Publisher_create_datawriter(DDS_Publisher *self, DDS_Topic *topic, const struct DDS_DataWriterQos *qos, const struct DDS_DataWriterListener *listener, DDS_StatusMask mask)
Creates a DDS_DataWriter that will be attached and belong to the DDS_Publisher.
 
DDS_ReturnCode_t
Type for return codes.
Definition: infrastructure.ifc:1352
 
@ DDS_RETCODE_OK
Successful return.
Definition: infrastructure.ifc:1355
 
#define DDS_STATUS_MASK_NONE
No bits are set.
Definition: infrastructure.ifc:1424
 
struct DDS_TopicWrapperI DDS_Topic
<<interface>> The most basic description of the data to be published and subscribed.
Definition: topic.ifc:521
 
DDS_HANDLE_TYPE_NATIVE DDS_InstanceHandle_t
Type definition for an instance handle.
Definition: infrastructure.ifc:858
 
const DDS_InstanceHandle_t DDS_HANDLE_NIL
The NIL instance handle.
 
struct DDS_DataWriterImpl DDS_DataWriter
<<interface>> Allows an application to set the value of the data to be published under a given DDS_To...
Definition: publication.ifc:174
 
void NDDS_Utility_sleep(const struct DDS_Duration_t *durationIn)
Block the calling thread for the specified duration.
 
Type for duration representation.
Definition: infrastructure.ifc:444