// $Id: dds_rtf2_dcps.idl 90888 2010-06-28 09:35:45Z johnnyw $

#ifndef DDS_RFT2_DCPS_IDL
#define DDS_RFT2_DCPS_IDL

#pragma ciao lem "connectors/dds4ccm/idl/dds_rtf2_dcpsE.idl"

#if (CIAO_DDS4CCM_OPENDDS==1)
# include "dds/DdsDcps.idl"
#endif

#if (CIAO_DDS4CCM_NDDS==1)
# define DOMAINID_TYPE_NATIVE    long
# define HANDLE_TYPE_NATIVE      long
# define HANDLE_NIL_NATIVE       0
# define BUILTIN_TOPIC_KEY_TYPE_NATIVE     long
#endif

#define TheParticipantFactory
#define PARTICIPANT_QOS_DEFAULT
#define TOPIC_QOS_DEFAULT
#define PUBLISHER_QOS_DEFAULT
#define SUBSCRIBER_QOS_DEFAULT
#define DATAWRITER_QOS_DEFAULT
#define DATAREADER_QOS_DEFAULT
#define DATAWRITER_QOS_USE_TOPIC_QOS
#define DATAREADER_QOS_USE_TOPIC_QOS

#include "tao/StringSeq.pidl"
#include "connectors/dds4ccm/idl/dds_rtf2_dcps_instance_handle.idl"

module DDS {
    typedef long DomainId_t;
    struct BuiltinTopicKey_t {
        long value[3];
    };
    typedef long ReturnCode_t;
    typedef long QosPolicyId_t;
    typedef sequence<string> StringSeq;

    struct Duration_t {
        long sec;
        unsigned long nanosec;
    };

    struct Time_t {
        long sec;
        unsigned long nanosec;
    };

    // ----------------------------------------------------------------------
    // Pre-defined values
    // ----------------------------------------------------------------------
    //const InstanceHandle_t HANDLE_NIL = 0;

    const long LENGTH_UNLIMITED = -1;

    const long            DURATION_INFINITE_SEC   = 0x7fffffff;
    const unsigned long   DURATION_INFINITE_NSEC  = 0x7fffffff;

    const long            DURATION_ZERO_SEC       = 0;
    const unsigned long   DURATION_ZERO_NSEC      = 0;

    const long            TIME_INVALID_SEC        = -1;
    const unsigned long   TIME_INVALID_NSEC       = 0xffffffff;

    // ----------------------------------------------------------------------
    // Return codes
    // ----------------------------------------------------------------------
    const ReturnCode_t RETCODE_OK                    = 0;
    const ReturnCode_t RETCODE_ERROR                 = 1;
    const ReturnCode_t RETCODE_UNSUPPORTED           = 2;
    const ReturnCode_t RETCODE_BAD_PARAMETER         = 3;
    const ReturnCode_t RETCODE_PRECONDITION_NOT_MET  = 4;
    const ReturnCode_t RETCODE_OUT_OF_RESOURCES      = 5;
    const ReturnCode_t RETCODE_NOT_ENABLED           = 6;
    const ReturnCode_t RETCODE_IMMUTABLE_POLICY      = 7;
    const ReturnCode_t RETCODE_INCONSISTENT_POLICY   = 8;
    const ReturnCode_t RETCODE_ALREADY_DELETED       = 9;
    const ReturnCode_t RETCODE_TIMEOUT               = 10;
    const ReturnCode_t RETCODE_NO_DATA               = 11;
    const ReturnCode_t RETCODE_ILLEGAL_OPERATION     = 12;

    // ----------------------------------------------------------------------
    // Status to support listeners and conditions
    // ----------------------------------------------------------------------

    typedef unsigned long StatusKind;
    typedef unsigned long StatusMask;    // bit-mask StatusKind

    const StatusKind INCONSISTENT_TOPIC_STATUS                = 0x0001 << 0;
    const StatusKind OFFERED_DEADLINE_MISSED_STATUS           = 0x0001 << 1;
    const StatusKind REQUESTED_DEADLINE_MISSED_STATUS         = 0x0001 << 2;
    const StatusKind OFFERED_INCOMPATIBLE_QOS_STATUS          = 0x0001 << 5;
    const StatusKind REQUESTED_INCOMPATIBLE_QOS_STATUS        = 0x0001 << 6;
    const StatusKind SAMPLE_LOST_STATUS                       = 0x0001 << 7;
    const StatusKind SAMPLE_REJECTED_STATUS                   = 0x0001 << 8;
    const StatusKind DATA_ON_READERS_STATUS                   = 0x0001 << 9;
    const StatusKind DATA_AVAILABLE_STATUS                    = 0x0001 << 10;
    const StatusKind LIVELINESS_LOST_STATUS                   = 0x0001 << 11;
    const StatusKind LIVELINESS_CHANGED_STATUS                = 0x0001 << 12;
    const StatusKind PUBLICATION_MATCHED_STATUS               = 0x0001 << 13;
    const StatusKind SUBSCRIPTION_MATCHED_STATUS              = 0x0001 << 14;
    const StatusKind RELIABLE_WRITER_CACHE_CHANGED_STATUS     = 0x00000001 << 24;
    const StatusKind RELIABLE_READER_ACTIVITY_CHANGED_STATUS  = 0x00000001 << 25;

    struct InconsistentTopicStatus {
        long total_count;
        long total_count_change;
    };

    struct SampleLostStatus {
        long total_count;
        long total_count_change;
    };

    enum SampleRejectedStatusKind {
        NOT_REJECTED,
        REJECTED_BY_INSTANCES_LIMIT,
        REJECTED_BY_SAMPLES_LIMIT,
        REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT
    };

    struct SampleRejectedStatus {
        long                         total_count;
        long                         total_count_change;
        SampleRejectedStatusKind     last_reason;
        InstanceHandle_t             last_instance_handle;
    };

    struct LivelinessLostStatus {
        long                 total_count;
        long                 total_count_change;
    };

    struct LivelinessChangedStatus {
        long                 alive_count;
        long                 not_alive_count;
        long                 alive_count_change;
        long                 not_alive_count_change;
        InstanceHandle_t     last_publication_handle;
    };

    struct OfferedDeadlineMissedStatus {
        long                 total_count;
        long                 total_count_change;
        InstanceHandle_t     last_instance_handle;
    };

    struct RequestedDeadlineMissedStatus {
        long                 total_count;
        long                 total_count_change;
        InstanceHandle_t     last_instance_handle;
    };

    struct QosPolicyCount {
        QosPolicyId_t        policy_id;
        long                 count;
    };

    typedef sequence<QosPolicyCount> QosPolicyCountSeq;

    struct OfferedIncompatibleQosStatus {
        long                 total_count;
        long                 total_count_change;
        QosPolicyId_t        last_policy_id;
        QosPolicyCountSeq    policies;
    };

    struct RequestedIncompatibleQosStatus {
        long                 total_count;
        long                 total_count_change;
        QosPolicyId_t        last_policy_id;
        QosPolicyCountSeq    policies;
    };

    struct PublicationMatchedStatus {
        long                 total_count;
        long                 total_count_change;
        long                 current_count;
        long                 current_count_change;
        InstanceHandle_t     last_subscription_handle;
    };

    struct SubscriptionMatchedStatus {
        long                 total_count;
        long                 total_count_change;
        long                 current_count;
        long                 current_count_change;
        InstanceHandle_t     last_publication_handle;
    };

    struct ReliableReaderActivityChangedStatus {
        long                 active_count;
        long                 inactive_count;
        long                 active_count_change;
        long                 inactive_count_change;
        InstanceHandle_t     last_instance_handle;
    };

    struct ReliableWriterCacheEventCount {
        long                 total_count;
        long                 total_count_change;
    };

    struct ReliableWriterCacheChangedStatus {
        ReliableWriterCacheEventCount       empty_reliable_writer_cache;
        ReliableWriterCacheEventCount       full_reliable_writer_cache;
        ReliableWriterCacheEventCount       low_watermark_reliable_writer_cache;
        ReliableWriterCacheEventCount       high_watermark_reliable_writer_cache;
        long                                unacknowledged_sample_count;
        long                                unacknowledged_sample_count_peak;
    };

    // ----------------------------------------------------------------------
    // Listeners
    // ----------------------------------------------------------------------

    local interface Listener;
    local interface Entity;
    local interface TopicDescription;
    local interface Topic;
    local interface ContentFilteredTopic;
    local interface MultiTopic;
    local interface DataWriter;
    local interface DataReader;
    local interface Subscriber;
    local interface Publisher;

    typedef sequence<DataReader> DataReaderSeq;

    local interface Listener {};

    local interface TopicListener : Listener {
    void on_inconsistent_topic(in Topic the_topic,
        in InconsistentTopicStatus status);
    };

    local interface DataWriterListener : Listener {
        void on_offered_deadline_missed(
            in DataWriter writer,
            in OfferedDeadlineMissedStatus status);
        void on_offered_incompatible_qos(
            in DataWriter writer,
            in OfferedIncompatibleQosStatus status);
        void on_liveliness_lost(
            in DataWriter writer,
            in LivelinessLostStatus status);
        void on_publication_matched(
            in DataWriter writer,
            in PublicationMatchedStatus status);
        void on_reliable_writer_cache_changed (
            in DataWriter writer,
            in ReliableWriterCacheChangedStatus status);
        void on_reliable_reader_activity_changed (
            in DataWriter writer,
            in ReliableReaderActivityChangedStatus status);
    };

    local interface PublisherListener : DataWriterListener {
    };

    local interface DataReaderListener : Listener {
        void on_requested_deadline_missed(
            in DataReader the_reader,
            in RequestedDeadlineMissedStatus status);
        void on_requested_incompatible_qos(
            in DataReader the_reader,
            in RequestedIncompatibleQosStatus status);
        void on_sample_rejected(
            in DataReader the_reader,
            in SampleRejectedStatus status);
        void on_liveliness_changed(
            in DataReader the_reader,
            in LivelinessChangedStatus status);
        void on_data_available(
            in DataReader the_reader);
        void on_subscription_matched(
            in DataReader the_reader,
            in SubscriptionMatchedStatus status);
        void on_sample_lost(
            in DataReader the_reader,
            in SampleLostStatus status);
    };

    local interface SubscriberListener : DataReaderListener {
        void on_data_on_readers(
            in Subscriber the_subscriber);
    };


    local interface DomainParticipantListener : TopicListener,
                                      PublisherListener,
                                      SubscriberListener {
    };


    // ----------------------------------------------------------------------
    // Conditions
    // ----------------------------------------------------------------------

    local interface Condition {
        boolean get_trigger_value();
    };

    typedef sequence<Condition> ConditionSeq;

    local interface WaitSet {
        ReturnCode_t wait(
            inout ConditionSeq active_conditions,
            in Duration_t timeout);
        ReturnCode_t attach_condition(
            in Condition cond);
        ReturnCode_t detach_condition(
            in Condition cond);
        ReturnCode_t get_conditions(
            inout ConditionSeq attached_conditions);
    };

    local interface GuardCondition : Condition {
        ReturnCode_t set_trigger_value(
            in boolean value);
    };

    local interface StatusCondition : Condition {
        StatusMask get_enabled_statuses();
        ReturnCode_t set_enabled_statuses(
            in StatusMask mask);
        Entity get_entity();
    };

    // Sample states to support reads
    typedef unsigned long SampleStateKind;
    const SampleStateKind READ_SAMPLE_STATE                     = 0x0001 << 0;
    const SampleStateKind NOT_READ_SAMPLE_STATE                 = 0x0001 << 1;

    // This is a bit-mask SampleStateKind
    typedef unsigned long SampleStateMask;
    const SampleStateMask ANY_SAMPLE_STATE                      = 0xffff;

    // View states to support reads
    typedef unsigned long ViewStateKind;
    const ViewStateKind NEW_VIEW_STATE                          = 0x0001 << 0;
    const ViewStateKind NOT_NEW_VIEW_STATE                      = 0x0001 << 1;

    // This is a bit-mask ViewStateKind
    typedef unsigned long ViewStateMask;
    const ViewStateMask ANY_VIEW_STATE                          = 0xffff;

    // Instance states to support reads
    typedef unsigned long InstanceStateKind;
    const InstanceStateKind ALIVE_INSTANCE_STATE                = 0x0001 << 0;
    const InstanceStateKind NOT_ALIVE_DISPOSED_INSTANCE_STATE   = 0x0001 << 1;
    const InstanceStateKind NOT_ALIVE_NO_WRITERS_INSTANCE_STATE = 0x0001 << 2;

    // This is a bit-mask InstanceStateKind
    typedef unsigned long InstanceStateMask;
    const InstanceStateMask ANY_INSTANCE_STATE                  = 0xffff;
    const InstanceStateMask NOT_ALIVE_INSTANCE_STATE            = 0x006;


    local interface ReadCondition : Condition {
        SampleStateMask     get_sample_state_mask();
        ViewStateMask       get_view_state_mask();
        InstanceStateMask   get_instance_state_mask();
        DataReader          get_datareader();
    };

    local interface QueryCondition : ReadCondition {
        string         get_query_expression();
        ReturnCode_t   get_query_parameters(
            inout StringSeq query_parameters);
        ReturnCode_t   set_query_parameters(
            in StringSeq query_parameters);
    };

    // ----------------------------------------------------------------------
    // Qos
    // ----------------------------------------------------------------------
    const string USERDATA_QOS_POLICY_NAME              = "UserData";
    const string DURABILITY_QOS_POLICY_NAME            = "Durability";
    const string PRESENTATION_QOS_POLICY_NAME          = "Presentation";
    const string DEADLINE_QOS_POLICY_NAME              = "Deadline";
    const string LATENCYBUDGET_QOS_POLICY_NAME         = "LatencyBudget";
    const string OWNERSHIP_QOS_POLICY_NAME             = "Ownership";
    const string OWNERSHIPSTRENGTH_QOS_POLICY_NAME     = "OwnershipStrength";
    const string LIVELINESS_QOS_POLICY_NAME            = "Liveliness";
    const string TIMEBASEDFILTER_QOS_POLICY_NAME       = "TimeBasedFilter";
    const string PARTITION_QOS_POLICY_NAME             = "Partition";
    const string RELIABILITY_QOS_POLICY_NAME           = "Reliability";
    const string DESTINATIONORDER_QOS_POLICY_NAME      = "DestinationOrder";
    const string HISTORY_QOS_POLICY_NAME               = "History";
    const string RESOURCELIMITS_QOS_POLICY_NAME        = "ResourceLimits";
    const string ENTITYFACTORY_QOS_POLICY_NAME         = "EntityFactory";
    const string WRITERDATALIFECYCLE_QOS_POLICY_NAME   = "WriterDataLifecycle";
    const string READERDATALIFECYCLE_QOS_POLICY_NAME   = "ReaderDataLifecycle";
    const string TOPICDATA_QOS_POLICY_NAME             = "TopicData";
    const string GROUPDATA_QOS_POLICY_NAME             = "TransportPriority";
    const string LIFESPAN_QOS_POLICY_NAME              = "Lifespan";
    const string DURABILITYSERVICE_POLICY_NAME         = "DurabilityService";

    const QosPolicyId_t INVALID_QOS_POLICY_ID              = 0;
    const QosPolicyId_t USERDATA_QOS_POLICY_ID             = 1;
    const QosPolicyId_t DURABILITY_QOS_POLICY_ID           = 2;
    const QosPolicyId_t PRESENTATION_QOS_POLICY_ID         = 3;
    const QosPolicyId_t DEADLINE_QOS_POLICY_ID             = 4;
    const QosPolicyId_t LATENCYBUDGET_QOS_POLICY_ID        = 5;
    const QosPolicyId_t OWNERSHIP_QOS_POLICY_ID            = 6;
    const QosPolicyId_t OWNERSHIPSTRENGTH_QOS_POLICY_ID    = 7;
    const QosPolicyId_t LIVELINESS_QOS_POLICY_ID           = 8;
    const QosPolicyId_t TIMEBASEDFILTER_QOS_POLICY_ID      = 9;
    const QosPolicyId_t PARTITION_QOS_POLICY_ID            = 10;
    const QosPolicyId_t RELIABILITY_QOS_POLICY_ID          = 11;
    const QosPolicyId_t DESTINATIONORDER_QOS_POLICY_ID     = 12;
    const QosPolicyId_t HISTORY_QOS_POLICY_ID              = 13;
    const QosPolicyId_t RESOURCELIMITS_QOS_POLICY_ID       = 14;
    const QosPolicyId_t ENTITYFACTORY_QOS_POLICY_ID        = 15;
    const QosPolicyId_t WRITERDATALIFECYCLE_QOS_POLICY_ID  = 16;
    const QosPolicyId_t READERDATALIFECYCLE_QOS_POLICY_ID  = 17;
    const QosPolicyId_t TOPICDATA_QOS_POLICY_ID            = 18;
    const QosPolicyId_t GROUPDATA_QOS_POLICY_ID            = 19;
    const QosPolicyId_t TRANSPORTPRIORITY_QOS_POLICY_ID    = 20;
    const QosPolicyId_t LIFESPAN_QOS_POLICY_ID             = 21;
    const QosPolicyId_t DURABILITYSERVICE_QOS_POLICY_ID    = 22;

    typedef sequence<octet> OctetSeq;
    struct UserDataQosPolicy {
        OctetSeq value;
    };

    struct TopicDataQosPolicy {
        OctetSeq value;
    };

    struct GroupDataQosPolicy {
        OctetSeq value;
    };

    struct TransportPriorityQosPolicy {
        long value;
    };

    struct LifespanQosPolicy {
        Duration_t duration;
    };

    enum DurabilityQosPolicyKind {
        VOLATILE_DURABILITY_QOS,
        TRANSIENT_LOCAL_DURABILITY_QOS,
        TRANSIENT_DURABILITY_QOS,
        PERSISTENT_DURABILITY_QOS
    };
    struct DurabilityQosPolicy {
        DurabilityQosPolicyKind kind;
    };

    enum PresentationQosPolicyAccessScopeKind {
        INSTANCE_PRESENTATION_QOS,
        TOPIC_PRESENTATION_QOS,
        GROUP_PRESENTATION_QOS
    };
    struct PresentationQosPolicy {
        PresentationQosPolicyAccessScopeKind access_scope;
        boolean coherent_access;
        boolean ordered_access;
    };

    struct DeadlineQosPolicy {
        Duration_t period;
    };

    struct LatencyBudgetQosPolicy {
        Duration_t duration;
    };

    enum OwnershipQosPolicyKind {
        SHARED_OWNERSHIP_QOS,
        EXCLUSIVE_OWNERSHIP_QOS
    };
    struct OwnershipQosPolicy {
        OwnershipQosPolicyKind kind;
    };

    struct OwnershipStrengthQosPolicy {
        long value;
    };

    enum LivelinessQosPolicyKind {
        AUTOMATIC_LIVELINESS_QOS,
        MANUAL_BY_PARTICIPANT_LIVELINESS_QOS,
        MANUAL_BY_TOPIC_LIVELINESS_QOS
    };

    struct LivelinessQosPolicy {
        LivelinessQosPolicyKind kind;
        Duration_t lease_duration;
    };

    struct TimeBasedFilterQosPolicy {
        Duration_t minimum_separation;
    };

    struct PartitionQosPolicy {
        StringSeq name;
    };

    enum ReliabilityQosPolicyKind {
        BEST_EFFORT_RELIABILITY_QOS,
        RELIABLE_RELIABILITY_QOS
    };

    struct ReliabilityQosPolicy {
        ReliabilityQosPolicyKind kind;
        Duration_t max_blocking_time;
    };

   enum DestinationOrderQosPolicyKind {
        BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS,
        BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS
    };
    struct DestinationOrderQosPolicy {
        DestinationOrderQosPolicyKind kind;
    };

    enum HistoryQosPolicyKind {
        KEEP_LAST_HISTORY_QOS,
        KEEP_ALL_HISTORY_QOS
    };
    struct HistoryQosPolicy {
        HistoryQosPolicyKind kind;
        long depth;
    };

    struct ResourceLimitsQosPolicy {
        long max_samples;
        long max_instances;
        long max_samples_per_instance;
    };

    struct EntityFactoryQosPolicy {
        boolean autoenable_created_entities;
    };

    struct WriterDataLifecycleQosPolicy {
        boolean autodispose_unregistered_instances;
    };

    struct ReaderDataLifecycleQosPolicy {
        Duration_t autopurge_nowriter_samples_delay;
        Duration_t autopurge_disposed_samples_delay;
    };

    struct DurabilityServiceQosPolicy {
        Duration_t              service_cleanup_delay;
        HistoryQosPolicyKind    history_kind;
        long                    history_depth;
        long                    max_samples;
        long                    max_instances;
        long                    max_samples_per_instance;
    };

    struct DomainParticipantFactoryQos {
        EntityFactoryQosPolicy entity_factory;
    };

    struct DomainParticipantQos {
        UserDataQosPolicy  user_data;
        EntityFactoryQosPolicy entity_factory;
    };

    struct TopicQos {
        TopicDataQosPolicy                   topic_data;
        DurabilityQosPolicy                  durability;
        DurabilityServiceQosPolicy           durability_service;
        DeadlineQosPolicy                    deadline;
        LatencyBudgetQosPolicy               latency_budget;
        LivelinessQosPolicy                  liveliness;
        ReliabilityQosPolicy                 reliability;
        DestinationOrderQosPolicy            destination_order;
        HistoryQosPolicy                     history;
        ResourceLimitsQosPolicy              resource_limits;
        TransportPriorityQosPolicy           transport_priority;
        LifespanQosPolicy                    lifespan;

        OwnershipQosPolicy                   ownership;
    };

    struct DataWriterQos {
        DurabilityQosPolicy                  durability;
        DurabilityServiceQosPolicy           durability_service;
        DeadlineQosPolicy                    deadline;
        LatencyBudgetQosPolicy               latency_budget;
        LivelinessQosPolicy                  liveliness;
        ReliabilityQosPolicy                 reliability;
        DestinationOrderQosPolicy            destination_order;
        HistoryQosPolicy                     history;
        ResourceLimitsQosPolicy              resource_limits;
        TransportPriorityQosPolicy           transport_priority;
        LifespanQosPolicy                    lifespan;

        UserDataQosPolicy                    user_data;
        OwnershipQosPolicy                   ownership;
        OwnershipStrengthQosPolicy           ownership_strength;
        WriterDataLifecycleQosPolicy         writer_data_lifecycle;
    };

    struct PublisherQos {
        PresentationQosPolicy                presentation;
        PartitionQosPolicy                   partition;
        GroupDataQosPolicy                   group_data;
        EntityFactoryQosPolicy               entity_factory;
    };

    struct DataReaderQos {
        DurabilityQosPolicy                  durability;
        DeadlineQosPolicy                    deadline;
        LatencyBudgetQosPolicy               latency_budget;
        LivelinessQosPolicy                  liveliness;
        ReliabilityQosPolicy                 reliability;
        DestinationOrderQosPolicy            destination_order;
        HistoryQosPolicy                     history;
        ResourceLimitsQosPolicy              resource_limits;

        UserDataQosPolicy                    user_data;
        OwnershipQosPolicy                   ownership;
        TimeBasedFilterQosPolicy             time_based_filter;
        ReaderDataLifecycleQosPolicy         reader_data_lifecycle;
    };

    struct SubscriberQos {
        PresentationQosPolicy                presentation;
        PartitionQosPolicy                   partition;
        GroupDataQosPolicy                   group_data;
        EntityFactoryQosPolicy               entity_factory;
    };

    // ----------------------------------------------------------------------

    struct ParticipantBuiltinTopicData {
        BuiltinTopicKey_t                    key;
        UserDataQosPolicy                    user_data;
    };

    struct TopicBuiltinTopicData {
        BuiltinTopicKey_t                    key;
        string                               name;
        string                               type_name;
        DurabilityQosPolicy                  durability;
        DurabilityServiceQosPolicy           durability_service;
        DeadlineQosPolicy                    deadline;
        LatencyBudgetQosPolicy               latency_budget;
        LivelinessQosPolicy                  liveliness;
        ReliabilityQosPolicy                 reliability;
        TransportPriorityQosPolicy           transport_priority;
        LifespanQosPolicy                    lifespan;
        DestinationOrderQosPolicy            destination_order;
        HistoryQosPolicy                     history;
        ResourceLimitsQosPolicy              resource_limits;
        OwnershipQosPolicy                   ownership;
        TopicDataQosPolicy                   topic_data;
    };

    struct PublicationBuiltinTopicData {
        BuiltinTopicKey_t                    key;
        BuiltinTopicKey_t                    participant_key;
        string                               topic_name;
        string                               type_name;

        DurabilityQosPolicy                  durability;
        DurabilityServiceQosPolicy           durability_service;
        DeadlineQosPolicy                    deadline;
        LatencyBudgetQosPolicy               latency_budget;
        LivelinessQosPolicy                  liveliness;
        ReliabilityQosPolicy                 reliability;
        LifespanQosPolicy                    lifespan;
        UserDataQosPolicy                    user_data;
        OwnershipQosPolicy                   ownership;
        OwnershipStrengthQosPolicy           ownership_strength;
        DestinationOrderQosPolicy            destination_order;

        PresentationQosPolicy                presentation;
        PartitionQosPolicy                   partition;
        TopicDataQosPolicy                   topic_data;
        GroupDataQosPolicy                   group_data;
    };

    struct SubscriptionBuiltinTopicData {
        BuiltinTopicKey_t                    key;
        BuiltinTopicKey_t                    participant_key;
        string                               topic_name;
        string                               type_name;

        DurabilityQosPolicy                  durability;
        DeadlineQosPolicy                    deadline;
        LatencyBudgetQosPolicy               latency_budget;
        LivelinessQosPolicy                  liveliness;
        ReliabilityQosPolicy                 reliability;
        OwnershipQosPolicy                   ownership;
        DestinationOrderQosPolicy            destination_order;
        UserDataQosPolicy                    user_data;
        TimeBasedFilterQosPolicy             time_based_filter;

        PresentationQosPolicy                presentation;
        PartitionQosPolicy                   partition;
        TopicDataQosPolicy                   topic_data;
        GroupDataQosPolicy                   group_data;
    };

    // ----------------------------------------------------------------------
    local interface Entity {
    //  ReturnCode_t set_qos(
    //      in EntityQos qos);
    //  ReturnCode_t get_qos(
    //      inout EntityQos qos);
    //  ReturnCode_t set_listener(
    //      in Listener l,
    //      in StatusMask mask);
    //  Listener get_listener();

        ReturnCode_t enable();

        StatusCondition get_statuscondition();

        StatusMask get_status_changes();

        InstanceHandle_t get_instance_handle();
    };

    // ----------------------------------------------------------------------
    local interface DomainParticipant : Entity {
        // Factory interfaces
        Publisher create_publisher(
            in PublisherQos qos,
            in PublisherListener a_listener,
            in StatusMask mask);
        Publisher create_publisher_with_profile(
            in string library_name,
            in string profile_name,
            in PublisherListener a_listener,
            in StatusMask mask);
        ReturnCode_t delete_publisher(
            in Publisher p);

        Subscriber create_subscriber(
            in SubscriberQos qos,
            in SubscriberListener a_listener,
            in StatusMask mask);
        Subscriber create_subscriber_with_profile(
            in string library_name,
            in string profile_name,
            in SubscriberListener a_listener,
            in StatusMask mask);
        ReturnCode_t delete_subscriber(
            in Subscriber s);
        Subscriber get_builtin_subscriber();

        Topic create_topic(
            in string topic_name,
            in string type_name,
            in TopicQos qos,
            in TopicListener a_listener,
            in StatusMask mask);
        Topic create_topic_with_profile(
            in string topic_name,
            in string type_name,
            in string library_name,
            in string profile_name,
            in TopicListener a_listener,
            in StatusMask mask);

        ReturnCode_t delete_topic(
            in Topic a_topic);

        Topic find_topic(
            in string topic_name,
            in Duration_t timeout);
        TopicDescription lookup_topicdescription(
            in string name);

        ContentFilteredTopic create_contentfilteredtopic(
            in string name,
            in Topic related_topic,
            in string filter_expression,
            in StringSeq expression_parameters);

        ReturnCode_t delete_contentfilteredtopic(
            in ContentFilteredTopic a_contentfilteredtopic);

        MultiTopic create_multitopic(
            in string name,
            in string type_name,
            in string subscription_expression,
            in StringSeq expression_parameters);

        ReturnCode_t delete_multitopic(
            in MultiTopic a_multitopic);

        ReturnCode_t delete_contained_entities();

        ReturnCode_t set_qos(
            in DomainParticipantQos qos);
        ReturnCode_t get_qos(
            inout DomainParticipantQos qos);

        ReturnCode_t set_listener(
            in DomainParticipantListener a_listener,
            in StatusMask mask);
        DomainParticipantListener get_listener();

        ReturnCode_t ignore_participant(
            in InstanceHandle_t handle);
        ReturnCode_t ignore_topic(
            in InstanceHandle_t handle);
        ReturnCode_t ignore_publication(
            in InstanceHandle_t handle);
        ReturnCode_t ignore_subscription(
            in InstanceHandle_t handle);

        DomainId_t get_domain_id();
        ReturnCode_t assert_liveliness();

        ReturnCode_t set_default_publisher_qos(
            in PublisherQos qos);
        ReturnCode_t get_default_publisher_qos(
            inout PublisherQos qos);

        ReturnCode_t set_default_subscriber_qos(
            in SubscriberQos qos);
        ReturnCode_t get_default_subscriber_qos(
            inout SubscriberQos qos);

        ReturnCode_t set_default_topic_qos(
            in TopicQos qos);
        ReturnCode_t get_default_topic_qos(
            inout TopicQos qos);

        ReturnCode_t get_discovered_participants(
            inout InstanceHandleSeq participant_handles);
        ReturnCode_t get_discovered_participant_data(
            inout ParticipantBuiltinTopicData participant_data,
            in InstanceHandle_t participant_handle);

        ReturnCode_t get_discovered_topics(
            inout InstanceHandleSeq topic_handles);
        ReturnCode_t get_discovered_topic_data(
            inout TopicBuiltinTopicData topic_data,
            in InstanceHandle_t topic_handle);

        boolean contains_entity(
            in InstanceHandle_t a_handle);

        ReturnCode_t get_current_time(
            inout Time_t current_time);
    };

    local interface DomainParticipantFactory {
        DomainParticipant create_participant(
            in DomainId_t domain_id,
            in DomainParticipantQos qos,
            in DomainParticipantListener a_listener,
            in StatusMask mask);
        DomainParticipant create_participant_with_profile(
            in DomainId_t domain_id,
            in string library_name,
            in string profile_name,
            in DomainParticipantListener a_listener,
            in StatusMask mask);
        ReturnCode_t delete_participant(
            in DomainParticipant a_participant);

        DomainParticipant lookup_participant(
            in DomainId_t domain_id);

        ReturnCode_t set_default_participant_qos(
            in DomainParticipantQos qos);
        ReturnCode_t set_default_participant_qos_with_profile(
            in string library_name,
            in string profile_name);
        ReturnCode_t get_default_participant_qos(
            inout DomainParticipantQos qos);

        ReturnCode_t set_qos(
            in DomainParticipantFactoryQos qos);
        ReturnCode_t get_qos(
            inout DomainParticipantFactoryQos qos);
    };

    local interface TypeSupport {
    //     ReturnCode_t register_type(
    //         in DomainParticipant domain,
    //         in string type_name);
    //     string get_type_name();
    };

    // ----------------------------------------------------------------------
    local interface TopicDescription {
        string get_type_name();
        string get_name();

        DomainParticipant get_participant();
    };

    local interface Topic : Entity, TopicDescription {
        ReturnCode_t set_qos(
            in TopicQos qos);
        ReturnCode_t get_qos(
            inout TopicQos qos);
        ReturnCode_t set_listener(
            in TopicListener a_listener,
            in StatusMask mask);
        TopicListener get_listener();
        // Access the status
        ReturnCode_t get_inconsistent_topic_status(
            inout InconsistentTopicStatus a_status);
    };

    local interface ContentFilteredTopic : TopicDescription {
        string get_filter_expression();
        ReturnCode_t get_expression_parameters(
            inout StringSeq expression_parameters);
        ReturnCode_t set_expression_parameters(
            in StringSeq expression_parameters);
        Topic get_related_topic();
    };

    local interface MultiTopic : TopicDescription {
        string get_subscription_expression();
        ReturnCode_t get_expression_parameters(
            inout StringSeq expression_parameters);
        ReturnCode_t set_expression_parameters(
            in StringSeq expression_parameters);
    };

    // ----------------------------------------------------------------------
    local interface Publisher : Entity {
        DataWriter create_datawriter(
            in Topic a_topic,
            in DataWriterQos qos,
            in DataWriterListener a_listener,
            in StatusMask mask);
        DataWriter create_datawriter_with_profile(
            in Topic a_topic,
            in string library_name,
            in string probile_name,
            in DataWriterListener a_listener,
            in StatusMask mask);
        ReturnCode_t delete_datawriter(
            in DataWriter a_datawriter);
        DataWriter lookup_datawriter(
            in string topic_name);

        ReturnCode_t delete_contained_entities();

        ReturnCode_t set_qos(
            in PublisherQos qos);
        ReturnCode_t get_qos(
            inout PublisherQos qos);

        ReturnCode_t set_listener(
            in PublisherListener a_listener,
            in StatusMask mask);
        PublisherListener get_listener();

        ReturnCode_t suspend_publications();
        ReturnCode_t resume_publications();

        ReturnCode_t begin_coherent_changes();
        ReturnCode_t end_coherent_changes();

        ReturnCode_t wait_for_acknowledgments(
            in Duration_t max_wait);

        DomainParticipant get_participant();

        ReturnCode_t set_default_datawriter_qos(
            in DataWriterQos qos);
        ReturnCode_t get_default_datawriter_qos(
            inout DataWriterQos qos);

        ReturnCode_t copy_from_topic_qos(
            inout DataWriterQos a_datawriter_qos,
            in TopicQos a_topic_qos);
    };

    local interface DataWriter : Entity {
    //  InstanceHandle_t register_instance(
    //      in Data instance_data);
    //  InstanceHandle_t register_instance_w_timestamp(
    //      in Data instance_data,
    //      in Time_t source_timestamp);
    //  ReturnCode_t unregister_instance(
    //      in Data instance_data,
    //      in InstanceHandle_t  handle);
    //  ReturnCode_t unregister_instance_w_timestamp(
    //      in Data instance_data,
    //      in InstanceHandle_t  handle,
    //      in Time_t source_timestamp);
    //  ReturnCode_t write(
    //      in Data instance_data,
    //      in InstanceHandle_t handle);
    //  ReturnCode_t write_w_timestamp(
    //      in Data instance_data,
    //      in InstanceHandle_t handle,
    //      in Time_t source_timestamp);
    //  ReturnCode_t dispose(
    //      in Data instance_data,
    //      in InstanceHandle_t instance_handle);
    //  ReturnCode_t dispose_w_timestamp(
    //      in Data instance_data,
    //      in InstanceHandle_t instance_handle,
    //      in Time_t source_timestamp);
    //  ReturnCode_t get_key_value(
    //      inout Data key_holder,
    //      in InstanceHandle_t handle);
    //  InstanceHandle_t lookup_instance(
    //      in Data instance_data);

        ReturnCode_t set_qos(
            in DataWriterQos qos);
        ReturnCode_t get_qos(
            inout DataWriterQos qos);

        ReturnCode_t set_listener(
            in DataWriterListener a_listener,
            in StatusMask mask);
        DataWriterListener get_listener();

        Topic get_topic();
        Publisher get_publisher();

        ReturnCode_t wait_for_acknowledgments(
            in Duration_t max_wait);

        // Access the status
        ReturnCode_t get_liveliness_lost_status(
            inout LivelinessLostStatus status);
        ReturnCode_t get_offered_deadline_missed_status(
            inout OfferedDeadlineMissedStatus status);
        ReturnCode_t get_offered_incompatible_qos_status(
            inout OfferedIncompatibleQosStatus status);
        ReturnCode_t get_publication_matched_status(
            inout PublicationMatchedStatus status);

        ReturnCode_t assert_liveliness();

        ReturnCode_t get_matched_subscriptions(
            inout InstanceHandleSeq subscription_handles);
        ReturnCode_t get_matched_subscription_data(
            inout SubscriptionBuiltinTopicData subscription_data,
            in InstanceHandle_t subscription_handle);
    };

    // ----------------------------------------------------------------------
    local interface Subscriber : Entity {
        DataReader create_datareader(
            in TopicDescription a_topic,
            in DataReaderQos qos,
            in DataReaderListener a_listener,
            in StatusMask mask);
        DataReader create_datareader_with_profile(
            in TopicDescription a_topic,
            in string library_name,
            in string profile_name,
            in DataReaderListener a_listener,
            in StatusMask mask);
        ReturnCode_t delete_datareader(
            in DataReader a_datareader);
        ReturnCode_t delete_contained_entities();
        DataReader lookup_datareader(
            in string topic_name);
        ReturnCode_t get_datareaders(
            inout DataReaderSeq readers,
            in SampleStateMask sample_states,
            in ViewStateMask view_states,
            in InstanceStateMask instance_states);
        ReturnCode_t notify_datareaders();

        ReturnCode_t set_qos(
            in SubscriberQos qos);
        ReturnCode_t get_qos(
            inout SubscriberQos qos);

        ReturnCode_t set_listener(
            in SubscriberListener a_listener,
            in StatusMask mask);
        SubscriberListener get_listener();

        ReturnCode_t begin_access();
        ReturnCode_t end_access();

        DomainParticipant get_participant();

        ReturnCode_t set_default_datareader_qos(
            in DataReaderQos qos);
        ReturnCode_t get_default_datareader_qos(
            inout DataReaderQos qos);

        ReturnCode_t copy_from_topic_qos(
            inout DataReaderQos a_datareader_qos,
            in TopicQos a_topic_qos);
    };

    local interface DataReader : Entity {
    //  ReturnCode_t read(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in SampleStateMask sample_states,
    //      in ViewStateMask view_states,
    //      in InstanceStateMask instance_states);

    //  ReturnCode_t take(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in SampleStateMask sample_states,
    //      in ViewStateMask view_states,
    //      in InstanceStateMask instance_states);

    //  ReturnCode_t read_w_condition(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in ReadCondition a_condition);

    //  ReturnCode_t take_w_condition(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in ReadCondition a_condition);

    //  ReturnCode_t read_next_sample(
    //      inout Data data_values,
    //      inout SampleInfo sample_info);

    //  ReturnCode_t take_next_sample(
    //      inout Data data_values,
    //      inout SampleInfo sample_info);

    //  ReturnCode_t read_instance(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in InstanceHandle_t a_handle,
    //      in SampleStateMask sample_states,
    //      in ViewStateMask view_states,
    //      in InstanceStateMask instance_states);

    //  ReturnCode_t take_instance(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in InstanceHandle_t a_handle,
    //      in SampleStateMask sample_states,
    //      in ViewStateMask view_states,
    //      in InstanceStateMask instance_states);

    //  ReturnCode_t read_next_instance(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in InstanceHandle_t previous_handle,
    //      in SampleStateMask sample_states,
    //      in ViewStateMask view_states,
    //      in InstanceStateMask instance_states);

    //  ReturnCode_t take_next_instance(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in InstanceHandle_t previous_handle,
    //      in SampleStateMask sample_states,
    //      in ViewStateMask view_states,
    //      in InstanceStateMask instance_states);

    //  ReturnCode_t read_next_instance_w_condition(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in InstanceHandle_t previous_handle,
    //      in ReadCondition a_condition);

    //  ReturnCode_t take_next_instance_w_condition(
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos,
    //      in long max_samples,
    //      in InstanceHandle_t previous_handle,
    //      in ReadCondition a_condition);

    //  ReturnCode_t return_loan (
    //      inout DataSeq data_values,
    //      inout SampleInfoSeq sample_infos);

    //  ReturnCode_t get_key_value(
    //      inout Data key_holder,
    //      in InstanceHandle_t handle);

    //  InstanceHandle_t lookup_instance(
    //      in Data instance_data);

        ReadCondition create_readcondition(
            in SampleStateMask sample_states,
            in ViewStateMask view_states,
            in InstanceStateMask instance_states);

        QueryCondition create_querycondition(
            in SampleStateMask sample_states,
            in ViewStateMask view_states,
            in InstanceStateMask instance_states,
            in string query_expression,
            in StringSeq query_parameters);

        ReturnCode_t delete_readcondition(
            in ReadCondition a_condition);

        ReturnCode_t delete_contained_entities();

        ReturnCode_t set_qos(
            in DataReaderQos qos);
        ReturnCode_t get_qos(
            inout DataReaderQos qos);

        ReturnCode_t set_listener(
            in DataReaderListener a_listener,
            in StatusMask mask);
        DataReaderListener get_listener();

        TopicDescription get_topicdescription();
        Subscriber get_subscriber();

        ReturnCode_t get_sample_rejected_status(
            inout SampleRejectedStatus status);
        ReturnCode_t get_liveliness_changed_status(
            inout LivelinessChangedStatus status);
        ReturnCode_t get_requested_deadline_missed_status(
            inout RequestedDeadlineMissedStatus status);
        ReturnCode_t get_requested_incompatible_qos_status(
            inout RequestedIncompatibleQosStatus status);
        ReturnCode_t get_subscription_matched_status(
            inout SubscriptionMatchedStatus status);
        ReturnCode_t get_sample_lost_status(
            inout SampleLostStatus status);

        ReturnCode_t wait_for_historical_data(
            in Duration_t max_wait);

        ReturnCode_t get_matched_publications(
            inout InstanceHandleSeq publication_handles);
        ReturnCode_t get_matched_publication_data(
            inout PublicationBuiltinTopicData publication_data,
            in InstanceHandle_t publication_handle);
    };


    struct SampleInfo {
        SampleStateKind      sample_state;
        ViewStateKind        view_state;
        InstanceStateKind    instance_state;
        Time_t               source_timestamp;
        InstanceHandle_t     instance_handle;
        InstanceHandle_t     publication_handle;
        long                 disposed_generation_count;
        long                 no_writers_generation_count;
        long                 sample_rank;
        long                 generation_rank;
        long                 absolute_generation_rank;
        boolean              valid_data;
    };

    typedef sequence<SampleInfo> SampleInfoSeq;
};

#endif
