.. _dds_layers_subscription_create_subscriber: Create a Subscriber =================== .. include:: ../../../safety_manual/rules/RULE_CREATION_ORDER.inc .. include:: ../../../safety_manual/rules/RULE_ENABLING_ORDER.inc A :ref:`dds_layers_subscription_subscriber` always belongs to a :ref:`dds_layers_domain_participant`. Creation of a Subscriber is done with the ``DomainParticipant::create_subscriber`` member function on the DomainParticipant instance, that acts as a factory for the Subscriber. Mandatory arguments are: * The :ref:`dds_layers_subscription_subscriberqos` describing the behavior of the Subscriber. Optional arguments are: * A Listener derived from :ref:`dds_layers_subscription_subscriberlistener`, implementing the callbacks that will be triggered in response to events and state changes on the Subscriber. * A ``StatusMask`` that activates or deactivates triggering of individual callbacks on the SubscriberListener. ``DomainParticipant::create_subscriber`` will return a null pointer if there was an error during the operation, e.g. if the provided QoS is not compatible or is not supported. It is advisable to check that the returned value is a valid pointer. .. _dds_layers_create_subscriber_classic: Example """"""" .. literalinclude:: ../../../code/entity_creation/main.cpp :language: c++ :start-after: // DDS_SUBSCRIBER_CREATION :end-before: //! DDS_SUBSCRIBER_CREATION :dedent: 4 .. _dds_layers_create_subscriber_static: Static memory example """"""""""""""""""""" In order to create a :ref:`dds_layers_subscription_subscriber` that does not use any :ref:`platform allocation ` a ``StaticSubscriber`` can be instantiated: .. note:: When using Safe DDS Static memory API, any :ref:`dds_layers_infrastructure_policies` related with :ref:`dds_layers_infrastructure_safedds_preallocmemoryconfig` in :ref:`dds_layers_subscription_subscriberqos` will be ignored. .. literalinclude:: ../../../code/entity_creation/main.cpp :language: c++ :start-after: // DDS_STATIC_SUBSCRIBER_CREATION :end-before: //! DDS_STATIC_SUBSCRIBER_CREATION :dedent: 4