Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rotu committed Apr 6, 2020
1 parent c465466 commit 03cf2e0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
41 changes: 39 additions & 2 deletions rmw_cyclonedds_cpp/src/CDR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,43 @@ enum class EncodingVersion {
CDR2,
};

/// aka ENC_HEADER
struct EncapsulationHeader
{
/// stream endianness
endian m_endian = native_endian();
/// encoding version
EncodingVersion m_eversion;
/// encoding options
std::array<byte, 2> m_options;
};

/// aka DHEADER
struct DelimiterHeaderData
{
int32_t size;
};

/// aka LC
enum class LengthCode {
Bytes1 = 0,
Bytes2 = 1,
Bytes4 = 2,
Bytes8 = 3,
BytesN = 4,
BytesN_ = 5,
Bytes4N = 6,
Byten8N = 7,
};

/// aka EMHEADER
struct MemberHeader
{
bool must_understand = false;
LengthCode length_code;
uint32_t next_int;
};

class CDREncodingInfo
{
EncodingVersion m_version;
Expand Down Expand Up @@ -65,9 +102,9 @@ class CDREncodingInfo
size_t get_align_of_primitive(ROSIDL_TypeKind tk) const
{
size_t sizeof_ = get_size_of_primitive(tk);
return std::min(sizeof_ ,max_align());
return std::min(sizeof_, max_align());
}
};
}
} // namespace rmw_cyclonedds_cpp

#endif //ROS2_MASTER_CDR_HPP
5 changes: 5 additions & 0 deletions rmw_cyclonedds_cpp/src/CDRCursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct AbstractCDRCursor
explicit AbstractCDRCursor(AbstractCDRCursor const &) = delete;
void operator=(AbstractCDRCursor const & x) = delete;

virtual endian stream_endian() const = 0;

// virtual functions to be implemented
// get the cursor's current offset.
virtual size_t offset() const = 0;
Expand Down Expand Up @@ -48,6 +50,9 @@ struct AbstractCDRCursor
struct AbstractCDRWritingCursor : AbstractCDRCursor
{
virtual void put_bytes(const void *, size_t n_bytes) = 0;
endian stream_endian() const override {
return native_endian();
}
};

struct CDRWritingCursor : public AbstractCDRWritingCursor
Expand Down

0 comments on commit 03cf2e0

Please sign in to comment.