Skip to content

Commit

Permalink
Documentation about Fast-CDR v2.0.0 and new annotations (#550)
Browse files Browse the repository at this point in the history
* Refs #18678. Fix compilation

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18678. Document optional and extensibility

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Update option extrastg

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Add suggested note

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Improve hightlighing

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Add link to custom template example

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Fix spelling

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Apply suggestions

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Apply suggestions

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Apply suggestion

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Fixes

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #18687. Apply suggestion

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware authored Sep 27, 2023
1 parent f37dbab commit 327dfa0
Show file tree
Hide file tree
Showing 30 changed files with 706 additions and 329 deletions.
2 changes: 1 addition & 1 deletion code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ target_link_libraries(doctest fastrtps)
# DDSCodeTester utilizes Fast DDS API
add_executable(dds-doctest DDSCodeTester.cpp FastDDSGenCodeTester.cpp)
target_include_directories(dds-doctest PRIVATE ${FAST_INCLUDE_DIR})
target_link_libraries(dds-doctest fastrtps)
target_link_libraries(dds-doctest fastrtps fastcdr)

####################################################################################################
# Add tests
Expand Down
7 changes: 5 additions & 2 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class CustomDomainParticipantListener : public DomainParticipantListener
class CustomPayloadPool : public eprosima::fastrtps::rtps::IPayloadPool
{
public:

CustomPayloadPool() = default;
~CustomPayloadPool() = default;
bool get_payload(
Expand All @@ -267,18 +268,21 @@ class CustomPayloadPool : public eprosima::fastrtps::rtps::IPayloadPool
{
return true;
}

bool get_payload(
eprosima::fastrtps::rtps::SerializedPayload_t& data,
eprosima::fastrtps::rtps::IPayloadPool*& data_owner,
eprosima::fastrtps::rtps::CacheChange_t& cache_change)
{
return true;
}

bool release_payload(
eprosima::fastrtps::rtps::CacheChange_t& cache_change)
{
return true;
}

};
//!--

Expand Down Expand Up @@ -1946,8 +1950,7 @@ void dds_custom_filters_examples()
* }
*/
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
eprosima::fastcdr::Cdr deser(fastbuffer);
// Deserialize encapsulation.
deser.read_encapsulation();
int index = 0;
Expand Down
12 changes: 6 additions & 6 deletions code/Examples/C++/DDSHelloWorld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.12.4)
cmake_minimum_required(VERSION 3.22)




if(NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy(SET CMP0048 NEW)
endif()

project(DDSHelloWorld)

# Find requirements
if(NOT fastcdr_FOUND)
find_package(fastcdr REQUIRED)
find_package(fastcdr 2 REQUIRED)
endif()

if(NOT fastrtps_FOUND)
find_package(fastrtps REQUIRED)
find_package(fastrtps 2.12 REQUIRED)
endif()

# Set C++11
Expand Down
113 changes: 35 additions & 78 deletions code/Examples/C++/DDSHelloWorld/src/HelloWorld.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,53 @@

/*!
* @file HelloWorld.cpp
* This source file contains the definition of the described types in the IDL file.
* This source file contains the implementation of the described types in the IDL file.
*
* This file was generated by the tool gen.
* This file was generated by the tool fastddsgen.
*/

#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace { char dummy; }
#endif
namespace {
char dummy;
} // namespace
#endif // _WIN32

#include "HelloWorld.h"
#include <fastcdr/Cdr.h>


#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;

#include <utility>


HelloWorld::HelloWorld()
{
// m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@e720b71
m_index = 0;
// m_message com.eprosima.idl.parser.typecode.StringTypeCode@74ad1f1f
m_message ="";

}

HelloWorld::~HelloWorld()
{


}

HelloWorld::HelloWorld(const HelloWorld &x)
HelloWorld::HelloWorld(
const HelloWorld& x)
{
m_index = x.m_index;
m_message = x.m_message;
}

HelloWorld::HelloWorld(HelloWorld &&x)
HelloWorld::HelloWorld(
HelloWorld&& x) noexcept
{
m_index = x.m_index;
m_message = std::move(x.m_message);
}

HelloWorld& HelloWorld::operator=(const HelloWorld &x)
HelloWorld& HelloWorld::operator =(
const HelloWorld& x)
{

m_index = x.m_index;
Expand All @@ -68,7 +69,8 @@ HelloWorld& HelloWorld::operator=(const HelloWorld &x)
return *this;
}

HelloWorld& HelloWorld::operator=(HelloWorld &&x)
HelloWorld& HelloWorld::operator =(
HelloWorld&& x) noexcept
{

m_index = x.m_index;
Expand All @@ -77,56 +79,27 @@ HelloWorld& HelloWorld::operator=(HelloWorld &&x)
return *this;
}

size_t HelloWorld::getMaxCdrSerializedSize(size_t current_alignment)
bool HelloWorld::operator ==(
const HelloWorld& x) const
{
size_t initial_alignment = current_alignment;


current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);


current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1;


return current_alignment - initial_alignment;
return (m_index == x.m_index &&
m_message == x.m_message);
}

size_t HelloWorld::getCdrSerializedSize(const HelloWorld& data, size_t current_alignment)
bool HelloWorld::operator !=(
const HelloWorld& x) const
{
(void)data;
size_t initial_alignment = current_alignment;


current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);


current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1;


return current_alignment - initial_alignment;
}

void HelloWorld::serialize(eprosima::fastcdr::Cdr &scdr) const
{

scdr << m_index;
scdr << m_message;
}

void HelloWorld::deserialize(eprosima::fastcdr::Cdr &dcdr)
{

dcdr >> m_index;
dcdr >> m_message;
return !(*this == x);
}

/*!
* @brief This function sets a value in member index
* @param _index New value for member index
*/
void HelloWorld::index(uint32_t _index)
void HelloWorld::index(
uint32_t _index)
{
m_index = _index;
m_index = _index;
}

/*!
Expand All @@ -147,22 +120,25 @@ uint32_t& HelloWorld::index()
return m_index;
}


/*!
* @brief This function copies the value in member message
* @param _message New value to be copied in member message
*/
void HelloWorld::message(const std::string &_message)
void HelloWorld::message(
const std::string& _message)
{
m_message = _message;
m_message = _message;
}

/*!
* @brief This function moves the value in member message
* @param _message New value to be moved in member message
*/
void HelloWorld::message(std::string &&_message)
void HelloWorld::message(
std::string&& _message)
{
m_message = std::move(_message);
m_message = std::move(_message);
}

/*!
Expand All @@ -183,25 +159,6 @@ std::string& HelloWorld::message()
return m_message;
}

size_t HelloWorld::getKeyMaxCdrSerializedSize(size_t current_alignment)
{
size_t current_align = current_alignment;





return current_align;
}

bool HelloWorld::isKeyDefined()
{
return false;
}

void HelloWorld::serializeKey(eprosima::fastcdr::Cdr &scdr) const
{
(void) scdr;


}
// Include auxiliary functions like for serializing/deserializing.
#include "HelloWorldCdrAux.ipp"
Loading

0 comments on commit 327dfa0

Please sign in to comment.