Skip to content

Commit

Permalink
Reverting changes on rtps/common headers.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany committed Sep 17, 2021
1 parent 5c19e6c commit 35e723e
Show file tree
Hide file tree
Showing 4 changed files with 505 additions and 335 deletions.
9 changes: 8 additions & 1 deletion include/fastdds/rtps/common/EntityId_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ inline bool operator !=(
const EntityId_t& id1,
const EntityId_t& id2)
{
return !(id1 == id2);
for (uint8_t i = 0; i < 4; ++i)
{
if (id1.value[i] != id2.value[i])
{
return true;
}
}
return false;
}

#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
Expand Down
97 changes: 58 additions & 39 deletions include/fastdds/rtps/common/Guid.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,62 +122,81 @@ struct RTPS_DllAPI GUID_t
return *reinterpret_cast<const InstanceHandle_t*>(this);
}

};

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

/**
* GUID comparison operator
* @param other Second GUID to compare
* @return True if equal
*/
inline bool operator ==(
const GUID_t& other) const
/**
* GUID comparison operator
* @param g1 First GUID to compare
* @param g2 Second GUID to compare
* @return True if equal
*/
inline bool operator ==(
const GUID_t& g1,
const GUID_t& g2)
{
if (g1.guidPrefix == g2.guidPrefix && g1.entityId == g2.entityId)
{
return (guidPrefix == other.guidPrefix && entityId == other.entityId);
return true;
}
else
{
return false;
}
}

/**
* GUID comparison operator
* @param other Second GUID to compare
* @return True if not equal
*/
inline bool operator !=(
const GUID_t& other) const
/**
* GUID comparison operator
* @param g1 First GUID to compare
* @param g2 Second GUID to compare
* @return True if not equal
*/
inline bool operator !=(
const GUID_t& g1,
const GUID_t& g2)
{
if (g1.guidPrefix != g2.guidPrefix || g1.entityId != g2.entityId)
{
return (guidPrefix != other.guidPrefix || entityId != other.entityId);
return true;
}
else
{
return false;
}
}

inline bool operator <(
const GUID_t& other) const
inline bool operator <(
const GUID_t& g1,
const GUID_t& g2)
{
for (uint8_t i = 0; i < 12; ++i)
{
for (uint8_t i = 0; i < 12; ++i)
if (g1.guidPrefix.value[i] < g2.guidPrefix.value[i])
{
if (guidPrefix.value[i] < other.guidPrefix.value[i])
{
return true;
}
else if (guidPrefix.value[i] > other.guidPrefix.value[i])
{
return false;
}
return true;
}
for (uint8_t i = 0; i < 4; ++i)
else if (g1.guidPrefix.value[i] > g2.guidPrefix.value[i])
{
if (entityId.value[i] < other.entityId.value[i])
{
return true;
}
else if (entityId.value[i] > other.entityId.value[i])
{
return false;
}
return false;
}
}
for (uint8_t i = 0; i < 4; ++i)
{
if (g1.entityId.value[i] < g2.entityId.value[i])
{
return true;
}
else if (g1.entityId.value[i] > g2.entityId.value[i])
{
return false;
}
return false;
}
return false;
}

#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

};

const GUID_t c_Guid_Unknown;

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
Expand Down
64 changes: 31 additions & 33 deletions include/fastdds/rtps/common/InstanceHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,50 +126,41 @@ struct RTPS_DllAPI InstanceHandle_t
return *reinterpret_cast<const GUID_t*>(this);
}

/**
* Strictly less than operator
* @param other The other InstanceHandle_t to compare
* @return True if the value of this handle lexicographically preceeds that of \p other
*/
inline bool operator <(
const InstanceHandle_t& other) const
{
return memcmp(value, other.value, 16) < 0;
}
};

const InstanceHandle_t c_InstanceHandle_Unknown;

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

/**
* Comparison operator
* @param other Second InstanceHandle_t to compare
* @return True if equal
*/
inline bool operator ==(
const InstanceHandle_t& other) const
/**
* Comparison operator
* @param ihandle1 First InstanceHandle_t to compare
* @param ihandle2 Second InstanceHandle_t to compare
* @return True if equal
*/
inline bool operator ==(
const InstanceHandle_t& ihandle1,
const InstanceHandle_t& ihandle2)
{
for (uint8_t i = 0; i < 16; ++i)
{
for (uint8_t i = 0; i < 16; ++i)
if (ihandle1.value[i] != ihandle2.value[i])
{
if (value[i] != other.value[i])
{
return false;
}
return false;
}
return true;
}
return true;
}

inline bool operator !=(
const InstanceHandle_t& other) const
{
return !(*this == other);
}
inline bool operator !=(
const InstanceHandle_t& ihandle1,
const InstanceHandle_t& ihandle2)
{
return !(ihandle1 == ihandle2);
}

#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

};

const InstanceHandle_t c_InstanceHandle_Unknown;


/**
* Convert InstanceHandle_t to GUID
* @param guid GUID to store the results
Expand Down Expand Up @@ -216,6 +207,13 @@ inline GUID_t iHandle2GUID(
return guid;
}

inline bool operator <(
const InstanceHandle_t& h1,
const InstanceHandle_t& h2)
{
return memcmp(h1.value, h2.value, 16) < 0;
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

/**
Expand Down
Loading

0 comments on commit 35e723e

Please sign in to comment.