<?xml version="1.0" encoding="UTF-8"?>

<qos_library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.omg.org/spec/DDS-XML"
    xsi:schemaLocation="http://www.omg.org/spec/DDS-XML https://www.omg.org/spec/DDS-XML/20260301/dds-xml_qos_definitions.xsd"
    name="MyQosLib">

    <qos_snippet name="DefaultReliability">
        <!-- Entity Qos: datareader_qos, datawriter_qos, etc. appearing inside <qos_snippet>
             can optionally have a name attribute. But no base_name or topic_filer attributes
        -->
        <datawriter_qos>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
                <max_blocking_time>
                    <sec>0</sec>
                    <nanosec>100000000</nanosec>
                </max_blocking_time>
            </reliability>
        </datawriter_qos>
        <datareader_qos>
            <reliability>
                <kind>BEST_EFFORT_RELIABILITY_QOS</kind>
            </reliability>
        </datareader_qos>
    </qos_snippet>

    <qos_snippet name="ReliableReliability">
        <datawriter_qos>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
                <max_blocking_time>
                    <sec>0</sec>
                    <nanosec>100000000</nanosec>
                </max_blocking_time>
            </reliability>
        </datawriter_qos>
        <datareader_qos>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
            </reliability>
        </datareader_qos>
    </qos_snippet>

    <qos_snippet name="ReliableKeepAllHistory">
        <datawriter_qos>
            <history>
                <kind>KEEP_ALL_HISTORY_QOS</kind>
            </history>
        </datawriter_qos>
        <datareader_qos name="OptionalName" >
            <history>
                <kind>KEEP_ALL_HISTORY_QOS</kind>
            </history>
        </datareader_qos>
    </qos_snippet>

    <qos_snippet name="HistoryKeepLast1">
        <datawriter_qos>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>1</depth>
            </history>
        </datawriter_qos>
        <datareader_qos name="OptionalName" >
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>1</depth>
            </history>
        </datareader_qos>
    </qos_snippet>

    <qos_snippet name="ReliableKeepAll">
        <qos_snippets>
            <snippet snippet_ref="ReliableReliability" />
            <snippet snippet_ref="ReliableKeepAllHistory" />
        </qos_snippets>
    </qos_snippet>

    <qos_snippet name="SharedOwnership">
        <datawriter_qos>
            <ownership>
                <kind>SHARED_OWNERSHIP_QOS</kind>
            </ownership>
        </datawriter_qos>
        <datareader_qos>
            <ownership>
                <kind>SHARED_OWNERSHIP_QOS</kind>
            </ownership>
        </datareader_qos>
        <topic_qos>
            <ownership>
                <kind>SHARED_OWNERSHIP_QOS</kind>
            </ownership>            
        </topic_qos>
    </qos_snippet>

    <qos_snippet name="ExclusiveOwnership">
        <datawriter_qos>
            <ownership>
                <kind>EXCLUSIVE_OWNERSHIP_QOS</kind>
            </ownership>
            <ownership_strength>
                <value>0</value>
            </ownership_strength>
        </datawriter_qos>
        <datareader_qos>
            <ownership>
                <kind>EXCLUSIVE_OWNERSHIP_QOS</kind>
            </ownership>
        </datareader_qos>
        <topic_qos>
            <ownership>
                <kind>EXCLUSIVE_OWNERSHIP_QOS</kind>
            </ownership>            
        </topic_qos>
    </qos_snippet>

    <qos_snippet name="TransientKeepLast1" >
        <qos_snippets>
            <!-- TODO Need to figure out element/attribute names-->
            <snippet snippet_ref="ReliableReliability" />
            <snippet snippet_ref="HistoryKeepLast1" />
        </qos_snippets>
        <datawriter_qos>
            <durability>
                <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
            </durability>
        </datawriter_qos>
        <datareader_qos>
            <durability>
                <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
            </durability>        
        </datareader_qos>
    </qos_snippet>

    <qos_snippet name="CreateEntitiesDisabled">
        <domain_participant_qos>
            <entity_factory>
                <autoenable_created_entities>false</autoenable_created_entities>
            </entity_factory>
        </domain_participant_qos>
    </qos_snippet>

    <qos_profile name="MyCustomProfile1">
        <datawriter_qos>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
                <max_blocking_time>
                    <sec>1</sec>
                    <nanosec>0</nanosec>
                </max_blocking_time>
            </reliability>
        </datawriter_qos>
        <datareader_qos>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
            </reliability>
        </datareader_qos>
    </qos_profile>

    <qos_profile name="MyCustomProfile2">
        <datawriter_qos>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
                <max_blocking_time>
                    <sec>1</sec>
                    <nanosec>0</nanosec>
                </max_blocking_time>
            </reliability>
            <durability>
                <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
            </durability>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>10</depth>
            </history>
        </datawriter_qos>
        <datareader_qos>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
            </reliability>
                        <durability>
                <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
            </durability>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>1</depth>
            </history>
        </datareader_qos>
    </qos_profile>

    <qos_profile name="MyCustomProfile3" base_name="MyQosLib::MyCustomProfile1">
        <qos_snippets>
            <snippet snippet_ref="TransientKeepLast1" />
            <snippet snippet_ref="SharedOwnership" />
        </qos_snippets>
        <domain_participant_qos>
            <properties inherit="true">
                <property name="my_property_name" propagate="true">ThePropertyValue</property>
            </properties>
            <user_data>
                <value>
                    01234567 89ABCDEF 
                    ab cd ef 01 23 45 67 89 AB CD EF
                    0123456789ABCDEFabcdef0123456789ABCDEF
                </value>
            </user_data>
            <binary_properties>
                <binary_property name="my_binary_property_name1" propagate="true">
                    0123456789ABCDEabcde  0123456789ABCDEabcde
                </binary_property>
                <binary_property name="my_binary_property_name2" propagate="true">
                    0123456789ABCDEabcde
                    01 23 45 67 89 AB CD EF ab cd ef
                    0123 456789AB
                </binary_property>
            </binary_properties>
            <property>  <!-- Legacy format use <properties> -->
                <value>
                    <element>
                        <name>my_property_name</name>
                        <value>ThePropertyValue</value>
                        <propagate>true</propagate>
                    </element>
                    <element>
                        <name>FAE_Property</name>
                        <value>100</value>
                    </element>
                </value>
            </property>
        </domain_participant_qos>

        <datareader_qos>
            <qos_snippets>
                <snippet snippet_ref="ReliableKeepAll" />
                <snippet snippet_ref="ExclusiveOwnership" />
            </qos_snippets>
            <reliability>
                <kind>BEST_EFFORT_RELIABILITY_QOS</kind>
            </reliability>
            <deadline>
                <period>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </period>
            </deadline>
            <latency_budget>
                <duration>
                    <sec>0</sec>
                    <nanosec>0</nanosec>
                </duration>
            </latency_budget>
            <liveliness>
                <kind>AUTOMATIC_LIVELINESS_QOS</kind>
                <lease_duration>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </lease_duration>
            </liveliness>
            <destination_order>
                <kind>BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS</kind>
            </destination_order>
            <resource_limits>
                <max_samples>LENGTH_UNLIMITED</max_samples>
                <max_instances>LENGTH_UNLIMITED</max_instances>
                <max_samples_per_instance>LENGTH_UNLIMITED</max_samples_per_instance>
            </resource_limits>
            <user_data>
                <value>
                    0123456789ABCDEFabcdef
                    01 23 45 67 89 AB CD EF ab cd ef
                </value>
            </user_data>
            <time_based_filter>
                <minimum_separation>
                    <sec>0</sec>
                    <nanosec>0</nanosec>
                </minimum_separation>
            </time_based_filter>
            <properties inherit="true">
                <property name="my_property_name">value</property>
            </properties>
            <reader_data_lifecycle>
                <autopurge_nowriter_samples_delay>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </autopurge_nowriter_samples_delay>
                <autopurge_disposed_samples_delay>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </autopurge_disposed_samples_delay>
            </reader_data_lifecycle>
            <data_representation>
                <value>
                    <element>XCDR_DATA_REPRESENTATION</element>
                    <element>XCDR2_DATA_REPRESENTATION</element>
                </value>
            </data_representation>
            <durability>
                <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
            </durability>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>10</depth>
            </history>
            <ownership>
                <kind>SHARED_OWNERSHIP_QOS</kind>
            </ownership>
            <partition>
                <name>
                    <element>Partition1</element>
                    <element>Partition2</element>
                </name>
            </partition>
            <transport_priority>
                <value>10</value>
            </transport_priority>
            <type_consistency>
                <kind>ALLOW_TYPE_COERCION</kind>
                <force_type_validation>true</force_type_validation>
                <ignore_enum_literal_names>true</ignore_enum_literal_names>
                <ignore_member_names>true</ignore_member_names>
                <ignore_sequence_bounds>true</ignore_sequence_bounds>
                <ignore_string_bounds>true</ignore_string_bounds>
                <prevent_type_widening>true</prevent_type_widening>
            </type_consistency>
        </datareader_qos>

        <datawriter_qos>
            <qos_snippets>
                <snippet snippet_ref="ReliableKeepAll" />
                <snippet snippet_ref="ExclusiveOwnership" />
            </qos_snippets>
            <properties inherit="true">
                <property name="my_property_name" propagate="true">ThePropertyValue</property>
            </properties>
            <binary_properties>
                <binary_property name="my_binary_property_name1" propagate="true">
                    0123456789ABCDEabcde  0123456789ABCDEabcde
                </binary_property>
                <binary_property name="my_binary_property_name2" propagate="true">
                    0123456789ABCDEabcde
                    01 23 45 67 89 AB CD EF ab cd ef
                    0123 456789AB
                </binary_property>
            </binary_properties>
            <property>  <!-- Legacy format use <properties> -->
                <value>
                    <element>
                        <name>my_property_name</name>
                        <value>ThePropertyValue</value>
                        <propagate>true</propagate>
                    </element>
                </value>
            </property>
            <durability_service>
                <service_cleanup_delay>
                    <sec>0</sec>
                    <nanosec>0</nanosec>
                </service_cleanup_delay>
                <history_kind>KEEP_LAST_HISTORY_QOS</history_kind>
                <history_depth>1</history_depth>
                <max_samples>LENGTH_UNLIMITED</max_samples>
                <max_instances>LENGTH_UNLIMITED</max_instances>
                <max_samples_per_instance>LENGTH_UNLIMITED</max_samples_per_instance>
            </durability_service>
            <deadline>
                <period>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </period>
            </deadline>
            <latency_budget>
                <duration>
                    <sec>0</sec>
                    <nanosec>0</nanosec>
                </duration>
            </latency_budget>
            <liveliness>
                <kind>AUTOMATIC_LIVELINESS_QOS</kind>
                <lease_duration>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </lease_duration>
            </liveliness>
            <destination_order>
                <kind>BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS</kind>
            </destination_order>
            <resource_limits>
                <max_samples>LENGTH_UNLIMITED</max_samples>
                <max_instances>LENGTH_UNLIMITED</max_instances>
                <max_samples_per_instance>LENGTH_UNLIMITED</max_samples_per_instance>
            </resource_limits>
            <transport_priority>
                <value>0</value>
            </transport_priority>
            <lifespan>
                <duration>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </duration>
            </lifespan>
            <user_data>
                <value></value>
            </user_data>
            <writer_data_lifecycle>
                <autodispose_unregistered_instances>
                    true
                </autodispose_unregistered_instances>
            </writer_data_lifecycle>
            <data_representation>
                <value>
                    <element>XCDR2_DATA_REPRESENTATION</element>
                </value>
            </data_representation>
        </datawriter_qos>

        <domain_participant_qos>
            <qos_snippets>
                <snippet snippet_ref="CreateEntitiesDisabled" />
            </qos_snippets>

            <!-- New syntax -->
            <properties>
                <property name="MyPName1">  MyPValue1   </property>
                <property name="MyPName2" propagate="true"> file://MyPValue1 </property>
             </properties>
             <binary_properties>
                <binary_property name="MyBPName1">
                    0123456789ABCDEabcde
                    01 23 45 67 89 AB CD EF ab cd ef
                    0123 456789AB
                </binary_property>
             </binary_properties>

             <property>  <!-- Legacy format use <properties> -->
                <value>
                    <element>
                        <name>MyPName1</name>
                        <value>MyPValue1</value>
                    </element>
                    <element>
                        <name>MyPName2</name>
                        <value>MyPValue2</value>
                        <propagate>true</propagate>
                    </element>
                </value>
            </property>
            
            <partition>
                <name>
                    <element>MyDomainPartition1</element>
                    <element>MyDomainPartition2</element>
                </name>
            </partition>
        </domain_participant_qos>

        <subscriber_qos>
            <presentation>
                <access_scope>INSTANCE_PRESENTATION_QOS</access_scope>
                <coherent_access>false</coherent_access>
                <ordered_access>false</ordered_access>
            </presentation>
            <partition>
                <name></name>
            </partition>
            <group_data>
                <value></value>
            </group_data>
            <entity_factory>
                <autoenable_created_entities>true</autoenable_created_entities>
            </entity_factory>
        </subscriber_qos>

        <publisher_qos>
            <presentation>
                <access_scope>INSTANCE_PRESENTATION_QOS</access_scope>
                <coherent_access>false</coherent_access>
                <ordered_access>false</ordered_access>
            </presentation>
            <partition>
                <name></name>
            </partition>
            <group_data>
                <value></value>
            </group_data>
            <entity_factory>
                <autoenable_created_entities>true</autoenable_created_entities>
            </entity_factory>
        </publisher_qos>

        <topic_qos>
            <topic_data>
                <value></value>
            </topic_data>
            <durability>
                <kind>VOLATILE_DURABILITY_QOS</kind>
            </durability>
            <durability_service>
                <service_cleanup_delay>
                    <sec>0</sec>
                    <nanosec>0</nanosec>
                </service_cleanup_delay>
                <history_kind>KEEP_LAST_HISTORY_QOS</history_kind>
                <history_depth>1</history_depth>
                <max_samples>LENGTH_UNLIMITED</max_samples>
                <max_instances>LENGTH_UNLIMITED</max_instances>
                <max_samples_per_instance>LENGTH_UNLIMITED</max_samples_per_instance>
            </durability_service>
            <deadline>
                <period>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </period>
            </deadline>
            <latency_budget>
                <duration>
                    <sec>0</sec>
                    <nanosec>0</nanosec>
                </duration>
            </latency_budget>
            <liveliness>
                <kind>AUTOMATIC_LIVELINESS_QOS</kind>
                <lease_duration>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </lease_duration>
            </liveliness>
            <reliability>
                <kind>BEST_EFFORT_RELIABILITY_QOS</kind>
                <max_blocking_time>
                    <sec>0</sec>
                    <nanosec>100000000</nanosec>
                </max_blocking_time>
            </reliability>
            <destination_order>
                <kind>BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS</kind>
            </destination_order>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>1</depth>
            </history>
            <resource_limits>
                <max_samples>LENGTH_UNLIMITED</max_samples>
                <max_instances>LENGTH_UNLIMITED</max_instances>
                <max_samples_per_instance>LENGTH_UNLIMITED</max_samples_per_instance>
            </resource_limits>
            <transport_priority>
                <value>0</value>
            </transport_priority>
            <lifespan>
                <duration>
                    <sec>DURATION_INFINITE_SEC</sec>
                    <nanosec>DURATION_INFINITE_NSEC</nanosec>
                </duration>
            </lifespan>
            <data_representation>
                <value>
                    <element>XCDR2_DATA_REPRESENTATION</element>
                </value>
            </data_representation>
        </topic_qos>

    </qos_profile>

    <qos_profile name="MyCustomProfile4" base_name="MyCustomProfile1" >
        <!-- name, base_name, and topic_filter are optional inside <qos_profile> definition -->
        <domain_participant_qos>
            <user_data><value>0A0B0C</value></user_data>
        </domain_participant_qos>
        <datawriter_qos topic_filter="A*Topic">
            <properties>
                <property name="Hello">World</property>
            </properties>
            <ownership><kind>EXCLUSIVE_OWNERSHIP_QOS</kind></ownership>
            <ownership_strength><value>10</value></ownership_strength>
        </datawriter_qos>

        <datawriter_qos name="writer_qos_option2" topic_filter="B*Topic" base_name="MyCustomProfile1">
            <properties>
                <property name="Hello">World</property>
            </properties>
            <ownership><kind>SHARED_OWNERSHIP_QOS</kind></ownership>
            <ownership_strength><value>10</value></ownership_strength>
        </datawriter_qos>

        <datareader_qos  name="reader_qos_option1" topic_filter="A*Topic"> 
            <ownership><kind>EXCLUSIVE_OWNERSHIP_QOS</kind></ownership>
        </datareader_qos>

        <datareader_qos  name="reader_qos_option2" topic_filter="B*Topic"  base_name="MyCustomProfile1"> 
            <ownership><kind>SHARED_OWNERSHIP_QOS</kind></ownership>
        </datareader_qos>
    </qos_profile>

    <!-- Entity Qos: datareader_qos, datawriter_qos, etc. May be used as a profile as well
         in this case name is mandatory, base_name is optional, and thre is no topic_filter
    -->
    <datareader_qos name="MyDataReaderQosProfile" base_name="MyCustomProfile1">
        <qos_snippets>
            <snippet snippet_ref="HistoryKeepLast1"/>
        </qos_snippets>
        <reliability>
            <kind>BEST_EFFORT_RELIABILITY_QOS</kind>
        </reliability>
    </datareader_qos>

    <datawriter_qos name="MyDataWriterQosProfile" base_name="MyCustomProfile1">
        <qos_snippets>
            <snippet snippet_ref="HistoryKeepLast1" />
        </qos_snippets>
        <reliability>
            <kind>BEST_EFFORT_RELIABILITY_QOS</kind>
        </reliability>
    </datawriter_qos>

    <topic_qos name="MyTopicQosProfile" base_name="MyCustomProfile1">
        <qos_snippets>
            <snippet snippet_ref="HistoryKeepLast1" />
        </qos_snippets>
        <reliability>
            <kind>BEST_EFFORT_RELIABILITY_QOS</kind>
        </reliability>
    </topic_qos>

    <!-- Profiles & Snippets used in the ShapeDemo PS example -->
    <qos_snippet name="ReliableKeepLast1">
        <datareader_qos>
            <durability>
                <kind>VOLATILE_DURABILITY_QOS</kind>
            </durability>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
            </reliability>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>1</depth>
            </history>
        </datareader_qos>
        <datawriter_qos>    
            <durability>
                <kind>VOLATILE_DURABILITY_QOS</kind>
            </durability>
            <reliability>
                <kind>RELIABLE_RELIABILITY_QOS</kind>
            </reliability>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>1</depth>
            </history>
        </datawriter_qos>
    </qos_snippet>

    <qos_snippet name="TransientLocal">
        <datareader_qos>
            <durability>
                <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
            </durability>
        </datareader_qos>
        <datawriter_qos>    
            <durability>
                <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
            </durability>
        </datawriter_qos>
    </qos_snippet>

    <qos_snippet name="TransientLocalKeepLast1">
         <qos_snippets>
            <snippet snippet_ref="ReliableKeepLast1" />
            <snippet snippet_ref="TransientLocal" />
        </qos_snippets>
    </qos_snippet>
    

    <qos_profile name="ReliableKeepLast6">
        <qos_snippets>
            <snippet snippet_ref="ReliableKeepLast1" />
        </qos_snippets>
        <datareader_qos>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>6</depth>
            </history>
        </datareader_qos>
        <datawriter_qos>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>6</depth>
            </history>
        </datawriter_qos>
    </qos_profile>

    <qos_profile name="StreamProfile">
        <datareader_qos>
            <qos_snippets>
                <snippet snippet_ref="TransientLocalKeepLast1" />
            </qos_snippets>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>6</depth>
            </history>
        </datareader_qos>
        <datawriter_qos>
            <qos_snippets>
                <snippet snippet_ref="TransientLocalKeepLast1" />
            </qos_snippets>
            <history>
                <kind>KEEP_LAST_HISTORY_QOS</kind>
                <depth>6</depth>
            </history>
        </datawriter_qos>
    </qos_profile>

    <qos_profile name="CommandProfile">
        <qos_snippets>
            <snippet snippet_ref="ReliableKeepAllHistory" />
        </qos_snippets>
    </qos_profile>

</qos_library>
