RTI Connext Modern C++ API Version 7.2.0
rti::core::policy::Property Class Reference

<<extension>> Stores key/value string pairs that can configure certain parameters of RTI Connext not exposed through QoS policies. It can also store and propagate through the discovery mechanism application-specific information associated to a dds::core::Entity. More...

#include <rti/core/policy/CorePolicy.hpp>

Public Types

typedef std::pair< std::string, std::string > Entry
 The type of the elements that Property contains. More...
 

Public Member Functions

 Property ()
 Creates an empty Property container. More...
 
template<typename EntryIter >
 Property (EntryIter begin, EntryIter end, bool is_propagate=false)
 Creates a Property container with the entries specified by an iterator range. More...
 
 Property (std::initializer_list< Entry > entries)
 <<C++11>> Creates a Property container with entries from an initializer_list More...
 
bool exists (const std::string &key) const
 Returns true if a property exists. More...
 
std::string get (const std::string &key) const
 Returns the value of a property identified by a key if it exists. More...
 
rti::core::optional_value< std::string > try_get (const std::string &key) const
 Returns the value of a property identified by a key or an empty optional_value if it doesn't exist. More...
 
Propertyset (const Entry &property, bool propagate=false)
 Adds or assigns a property from a pair of strings. More...
 
template<typename EntryIter >
Propertyset (EntryIter begin, EntryIter end, bool is_propagate=false)
 Adds a range of properties. More...
 
bool remove (const std::string &key)
 Removes the property identified by a key. More...
 
size_t size () const
 Returns the number of properties. More...
 
std::map< std::string, std::string > get_all () const
 Retrieves a copy of all the entries in a std::map. More...
 
void set (std::initializer_list< Entry > entries, bool is_propagate=false)
 <<C++11>> Adds properties from an initializer_list More...
 
bool propagate (const std::string &key) const
 Returns whether the 'propagate' attribute for a property is set or not. More...
 

Detailed Description

<<extension>> Stores key/value string pairs that can configure certain parameters of RTI Connext not exposed through QoS policies. It can also store and propagate through the discovery mechanism application-specific information associated to a dds::core::Entity.

Entity:
dds::domain::DomainParticipant dds::sub::DataReader dds::pub::DataWriter
Properties:
RxO = N/A;
Changeable = YES
See also
dds::sub::builtin_subscriber

Usage

The PROPERTY QoS policy can be used to associate a set of properties in the form of (name, value) pairs with a dds::sub::DataReader, dds::pub::DataWriter, or dds::domain::DomainParticipant. This is similar to the dds::core::policy::UserData, except this policy uses (name, value) pairs, and you can select whether or not a particular pair should be propagated (included in the builtin topic).

You can find a complete list of predefined properties in the Property Reference Guide.

This QoS policy may be used to configure:

In addition, you may add your own name/value pairs to the Property QoS policy of an Entity. Via this QoS policy, you can direct RTI Connext to propagate these name/value pairs with the discovery information for the Entity. Applications that discover the Entity can then access the user-specific name/value pairs in the discovery information of the remote Entity. This allows you to add meta-information about an Entity for application-specific use, for example, authentication/authorization certificates (which can also be done using the dds::core::policy::UserData or dds::core::policy::GroupData).

Reasons for Using the PropertyQosPolicy

  • Supports dynamic loading of extension transports
  • Supports multiple instances of the builtin transports
  • Allows full pluggable transport configuration for non-C/C++ language bindings (Java, .NET, etc.)
  • Avoids the process of creating entities disabled, changing their QoS settings, then enabling them
  • Allows selection of clock

Some of the RTI Connext capabilities configurable via the Property QoS policy can also be configured in code via APIs. However, the Property QoS policy allows you to configure those parameters via XML files. In addition, some of the configuration APIs will only work if the Entity was created in a disabled state and then enabled after the configuration change was applied. By configuring those parameters using the Property QoS policy during entity creation, you avoid the additional work of first creating a disabled entity and then enabling it afterwards.

There are helper functions to facilitate working with properties, see the PROPERTY page.

Member Typedef Documentation

◆ Entry

typedef std::pair<std::string, std::string> rti::core::policy::Property::Entry

The type of the elements that Property contains.

Key/value string pairs.

Constructor & Destructor Documentation

◆ Property() [1/3]

rti::core::policy::Property::Property ( )
inline

Creates an empty Property container.

◆ Property() [2/3]

template<typename EntryIter >
rti::core::policy::Property::Property ( EntryIter  begin,
EntryIter  end,
bool  is_propagate = false 
)
inline

Creates a Property container with the entries specified by an iterator range.

See also
set(EntryIter, EntryIter, bool)

◆ Property() [3/3]

rti::core::policy::Property::Property ( std::initializer_list< Entry entries)
inline

<<C++11>> Creates a Property container with entries from an initializer_list

For example:

Property my_properties {{"key 1", "value 1"}, {"key 2", "value 2"}};
Property()
Creates an empty Property container.
Definition: rti/core/policy/CorePolicy.hpp:2715

If a key is duplicated, only one entry will be inserted, with the value that comes last.

Member Function Documentation

◆ exists()

bool rti::core::policy::Property::exists ( const std::string &  key) const
inline

Returns true if a property exists.

◆ get()

std::string rti::core::policy::Property::get ( const std::string &  key) const

Returns the value of a property identified by a key if it exists.

If the property doesn't exist it throws dds::core::PreconditionNotMetError.

◆ try_get()

rti::core::optional_value< std::string > rti::core::policy::Property::try_get ( const std::string &  key) const

Returns the value of a property identified by a key or an empty optional_value if it doesn't exist.

◆ set() [1/3]

Property & rti::core::policy::Property::set ( const Entry property,
bool  propagate = false 
)

Adds or assigns a property from a pair of strings.

If the key doesn't exists it adds the new entry, otherwise it overrides its value with the new one.

Parameters
propertyproperty.first is the key and property.second is the value
propagateIndicates if the property must be propagated on discovery

◆ set() [2/3]

template<typename EntryIter >
Property & rti::core::policy::Property::set ( EntryIter  begin,
EntryIter  end,
bool  is_propagate = false 
)
inline

Adds a range of properties.

If a key is duplicated, only one entry will remain, with the value that comes last.

Template Parameters
EntryIterA forward iterator whose value type is Property::Entry, such as the iterators of a std::map<std::string, std::string>.
Parameters
beginBeginning of a range of Entry
endEnd of that range
is_propagateIndicates if the property must be propagated on discovery

◆ remove()

bool rti::core::policy::Property::remove ( const std::string &  key)

Removes the property identified by a key.

Returns
true if the property was removed or false if it didn't exist.

◆ size()

size_t rti::core::policy::Property::size ( ) const

Returns the number of properties.

◆ get_all()

std::map< std::string, std::string > rti::core::policy::Property::get_all ( ) const

Retrieves a copy of all the entries in a std::map.

◆ set() [3/3]

void rti::core::policy::Property::set ( std::initializer_list< Entry entries,
bool  is_propagate = false 
)
inline

<<C++11>> Adds properties from an initializer_list

◆ propagate()

bool rti::core::policy::Property::propagate ( const std::string &  key) const

Returns whether the 'propagate' attribute for a property is set or not.