Skip to content

Commit

Permalink
Refs 17138. Introducing namespaces
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Barro <[email protected]>
  • Loading branch information
Miguel Barro committed Apr 12, 2023
1 parent 7d9e138 commit 37b1d7f
Show file tree
Hide file tree
Showing 7 changed files with 321 additions and 230 deletions.
510 changes: 297 additions & 213 deletions code/CodeTester.cpp

Large diffs are not rendered by default.

32 changes: 19 additions & 13 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include <sstream>

using namespace eprosima::fastdds::dds;
using namespace eprosima::fastrtps::types::literals;

class CustomChainingTransportDescriptor : public eprosima::fastdds::rtps::ChainingTransportDescriptor
{
Expand Down Expand Up @@ -206,7 +205,7 @@ class CustomDomainParticipantListener : public DomainParticipantListener
const eprosima::fastrtps::string_255& topic,
const eprosima::fastrtps::types::TypeIdentifier* identifier,
const eprosima::fastrtps::types::TypeObject* object,
eprosima::fastrtps::types::DynamicType_ptr dyn_type) override
eprosima::fastrtps::types::v1_3::DynamicType_ptr dyn_type) override
{
static_cast<void>(participant);
static_cast<void>(request_sample_id);
Expand Down Expand Up @@ -879,7 +878,7 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener
const eprosima::fastrtps::string_255& topic,
const eprosima::fastrtps::types::TypeIdentifier* identifier,
const eprosima::fastrtps::types::TypeObject* object,
eprosima::fastrtps::types::DynamicType_ptr dyn_type) override
eprosima::fastrtps::types::v1_3::DynamicType_ptr dyn_type) override
{
static_cast<void>(participant);
static_cast<void>(request_sample_id);
Expand Down Expand Up @@ -1632,6 +1631,8 @@ void dds_topic_examples()

{
//DDS_DYNAMIC_TYPES
namespace xtypes = eprosima::fastrtps::types::v1_3;

// Create a DomainParticipant in the desired domain
DomainParticipant* participant =
DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT);
Expand All @@ -1645,7 +1646,7 @@ void dds_topic_examples()
eprosima::fastrtps::xmlparser::XMLProfileManager::loadXMLFile("example_type.xml");

// Retrieve the an instance of the desired type and register it
eprosima::fastrtps::types::DynamicType_ptr dyn_type =
xtypes::DynamicType_ptr dyn_type =
eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName("DynamicType")->build();
TypeSupport dyn_type_support(new eprosima::fastrtps::types::DynamicPubSubType(dyn_type));
dyn_type_support.register_type(participant, nullptr);
Expand Down Expand Up @@ -4340,6 +4341,8 @@ void xml_profiles_examples()
}
{
//XML-USAGE
namespace xtypes = eprosima::fastrtps::types::v1_3;

// Create a DomainParticipant
DomainParticipant* participant =
DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT);
Expand All @@ -4354,7 +4357,7 @@ void xml_profiles_examples()
DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml"))
{
// Retrieve the an instance of MyStruct type
eprosima::fastrtps::types::DynamicType_ptr my_struct_type =
xtypes::DynamicType_ptr my_struct_type =
eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName("MyStruct")->build();
// Register MyStruct type
TypeSupport my_struct_type_support(new eprosima::fastrtps::types::DynamicPubSubType(my_struct_type));
Expand Down Expand Up @@ -5277,6 +5280,9 @@ void dds_persistence_examples()
* };
*/

using namespace eprosima::fastrtps::types;
namespace xtypes = v1_3;

// Configure persistence service plugin for DomainParticipant
DomainParticipantQos pqos;
pqos.properties().properties().emplace_back("dds.persistence.plugin", "builtin.SQLITE3");
Expand All @@ -5292,26 +5298,26 @@ void dds_persistence_examples()
********************************************************************************************************/
// Create a struct builder for a type with name "persistence_topic_type"
const std::string topic_type_name = "persistence_topic_type";
eprosima::fastrtps::types::DynamicTypeBuilder_ptr struct_type_builder(
eprosima::fastrtps::types::DynamicTypeBuilderFactory::get_instance().create_struct_builder());
xtypes::DynamicTypeBuilder_ptr struct_type_builder(
xtypes::DynamicTypeBuilderFactory::get_instance().create_struct_builder());
struct_type_builder->set_name(topic_type_name);

// The type consists of two members, and index and a message. Add members to the struct.
struct_type_builder->add_member(0, "index",
eprosima::fastrtps::types::DynamicTypeBuilderFactory::get_instance().create_uint32_type());
xtypes::DynamicTypeBuilderFactory::get_instance().create_uint32_type());
struct_type_builder->add_member(1, "message",
eprosima::fastrtps::types::DynamicTypeBuilderFactory::get_instance().create_string_type());
xtypes::DynamicTypeBuilderFactory::get_instance().create_string_type());

// Build the type
eprosima::fastrtps::types::DynamicType_ptr dyn_type_ptr = struct_type_builder->build();
xtypes::DynamicType_ptr dyn_type_ptr = struct_type_builder->build();

// Create type support and register the type
TypeSupport type_support(new eprosima::fastrtps::types::DynamicPubSubType(dyn_type_ptr));
TypeSupport type_support(new DynamicPubSubType(dyn_type_ptr));
type_support.register_type(participant);

// Create data sample a populate data. This is to be used when calling `writer->write()`
eprosima::fastrtps::types::DynamicData* dyn_helloworld;
dyn_helloworld = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dyn_type_ptr);
xtypes::DynamicData* dyn_helloworld;
dyn_helloworld = xtypes::DynamicDataFactory::get_instance()->create_data(dyn_type_ptr);
dyn_helloworld->set_uint32_value(0, 0_id);
dyn_helloworld->set_string_value("HelloWorld", 1_id);
/********************************************************************************************************
Expand Down
1 change: 1 addition & 0 deletions docs/fastdds/api_reference/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ typedef
TypeIdentifier
TypeIdV
TypeInformation
TypeKind
typelookup
TypeLookup
TypeLookup
Expand Down
2 changes: 1 addition & 1 deletion docs/fastdds/api_reference/xtypes/DynamicData.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
DynamicType
-----------

.. doxygenclass:: eprosima::fastrtps::types::DynamicData
.. doxygenclass:: eprosima::fastrtps::types::v1_3::DynamicData
:project: FastDDS
:members:
2 changes: 1 addition & 1 deletion docs/fastdds/api_reference/xtypes/DynamicType.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
DynamicType
-----------

.. doxygenclass:: eprosima::fastrtps::types::DynamicType
.. doxygenclass:: eprosima::fastrtps::types::v1_3::DynamicType
:project: FastDDS
:members:
2 changes: 1 addition & 1 deletion docs/fastdds/api_reference/xtypes/DynamicTypeBuilder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
DynamicTypeBuilder
------------------

.. doxygenclass:: eprosima::fastrtps::types::DynamicTypeBuilder
.. doxygenclass:: eprosima::fastrtps::types::v1_3::DynamicTypeBuilder
:project: FastDDS
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
DynamicTypeBuilderFactory
-------------------------

.. doxygenclass:: eprosima::fastrtps::types::DynamicTypeBuilderFactory
.. doxygenclass:: eprosima::fastrtps::types::v1_3::DynamicTypeBuilderFactory
:project: FastDDS
:members:

0 comments on commit 37b1d7f

Please sign in to comment.