Skip to content

Commit

Permalink
Fix HelloWorld DataSharing example idl (#3885)
Browse files Browse the repository at this point in the history
* Fix HelloWorld DataSharing example idl (#3714)

* Refs #19089: Fix HelloWorld DataSharing example idl as bounded

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #19089: Revert uncrustify fix in types

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: JesusPoderoso <[email protected]>
(cherry picked from commit 4fed0bd)

# Conflicts:
#	examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorld.h
#	examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldCdrAux.hpp

* Refs #19089: Fix conflicts (regenerate types with proper fastddsgen & fastcdr versions)

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: JesusPoderoso <[email protected]>
Co-authored-by: Jesús Poderoso <[email protected]>
Co-authored-by: JesusPoderoso <[email protected]>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent 1f05538 commit 6d06c00
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
16 changes: 10 additions & 6 deletions examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorld.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace eprosima::fastcdr::exception;

#include <utility>

#define HelloWorld_max_cdr_typesize 264ULL;
#define HelloWorld_max_cdr_typesize 29ULL;
#define HelloWorld_max_key_cdr_typesize 0ULL;

HelloWorld::HelloWorld()
Expand Down Expand Up @@ -137,7 +137,11 @@ void HelloWorld::deserialize(
{

dcdr >> m_index;
dcdr >> m_message;
{
std::string aux;
dcdr >> aux;
m_message = aux.c_str();
}
}

/*!
Expand Down Expand Up @@ -173,7 +177,7 @@ uint32_t& HelloWorld::index()
* @param _message New value to be copied in member message
*/
void HelloWorld::message(
const std::string& _message)
const eprosima::fastrtps::fixed_string<20>& _message)
{
m_message = _message;
}
Expand All @@ -183,7 +187,7 @@ void HelloWorld::message(
* @param _message New value to be moved in member message
*/
void HelloWorld::message(
std::string&& _message)
eprosima::fastrtps::fixed_string<20>&& _message)
{
m_message = std::move(_message);
}
Expand All @@ -192,7 +196,7 @@ void HelloWorld::message(
* @brief This function returns a constant reference to member message
* @return Constant reference to member message
*/
const std::string& HelloWorld::message() const
const eprosima::fastrtps::fixed_string<20>& HelloWorld::message() const
{
return m_message;
}
Expand All @@ -201,7 +205,7 @@ const std::string& HelloWorld::message() const
* @brief This function returns a reference to member message
* @return Reference to member message
*/
std::string& HelloWorld::message()
eprosima::fastrtps::fixed_string<20>& HelloWorld::message()
{
return m_message;
}
Expand Down
20 changes: 10 additions & 10 deletions examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,33 +147,33 @@ class HelloWorld
* @param _message New value to be copied in member message
*/
eProsima_user_DllExport void message(
const std::string& _message);
const eprosima::fastrtps::fixed_string<20>& _message);

/*!
* @brief This function moves the value in member message
* @param _message New value to be moved in member message
*/
eProsima_user_DllExport void message(
std::string&& _message);
eprosima::fastrtps::fixed_string<20>&& _message);

/*!
* @brief This function returns a constant reference to member message
* @return Constant reference to member message
*/
eProsima_user_DllExport const std::string& message() const;
eProsima_user_DllExport const eprosima::fastrtps::fixed_string<20>& message() const;

/*!
* @brief This function returns a reference to member message
* @return Reference to member message
*/
eProsima_user_DllExport std::string& message();
eProsima_user_DllExport eprosima::fastrtps::fixed_string<20>& message();

/*!
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getMaxCdrSerializedSize(
size_t current_alignment = 0);

Expand Down Expand Up @@ -228,7 +228,7 @@ class HelloWorld
private:

uint32_t m_index;
std::string m_message;
eprosima::fastrtps::fixed_string<20> m_message;

};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct HelloWorld
{
unsigned long index;
string message;
string<20> message;
};
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType
#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
eProsima_user_DllExport inline bool is_bounded() const override
{
return false;
return true;
}

#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
Expand Down

0 comments on commit 6d06c00

Please sign in to comment.