Skip to content

Commit 867fdf8

Browse files
committed
Adapt to new InstanceHandle in DDS and global operators
Signed-off-by: Iker Luengo <ikerluengo@eprosima.com>
1 parent 9fbfc1c commit 867fdf8

5 files changed

Lines changed: 121 additions & 1 deletion

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
%{
2+
#include "fastdds/dds/common/InstanceHandle.hpp"
3+
%}
4+
5+
// SWIG does not support type conversion operators correctly unless converted to a normal method
6+
%rename(get_guid) eprosima::fastdds::dds::InstanceHandle_t::operator const GUID_t&;
7+
8+
//Operators declared outside the class conflict with those declared for other types
9+
%ignore eprosima::fastdds::dds::operator<<(std::ostream&, const InstanceHandle_t&);
10+
%ignore eprosima::fastdds::dds::operator>>(std::ostream&, const InstanceHandle_t&);
11+
12+
%include "fastdds/dds/common/InstanceHandle.hpp"

src/swig/fastdds/rtps/common/EntityId_t.i

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
%ignore eprosima::fastrtps::rtps::operator<<(std::ostream&, const EntityId_t&);
1010
%ignore eprosima::fastrtps::rtps::operator>>(std::ostream&, const EntityId_t&);
1111

12+
%ignore eprosima::fastrtps::rtps::operator==;
13+
%ignore eprosima::fastrtps::rtps::operator!=;
14+
1215
// Declare hash so that we do not get a warning
1316
// This will make an empty class on the target, but the user should not need this anyway.
1417
namespace std {
@@ -17,3 +20,21 @@ namespace std {
1720
}
1821

1922
%include "fastdds/rtps/common/EntityId_t.hpp"
23+
24+
// Declare the comparison operators as internal to the class
25+
%extend eprosima::fastrtps::rtps::EntityId_t {
26+
bool operator==(const eprosima::fastrtps::rtps::EntityId_t& other) const
27+
{
28+
return *$self == other;
29+
}
30+
31+
bool operator==(uint32_t other) const
32+
{
33+
return *$self == other;
34+
}
35+
36+
bool operator!=(const eprosima::fastrtps::rtps::EntityId_t& other) const
37+
{
38+
return *$self != other;
39+
}
40+
}

src/swig/fastdds/rtps/common/Guid.i

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,28 @@
99
%ignore eprosima::fastrtps::rtps::operator<<(std::ostream&, const GUID_t&);
1010
%ignore eprosima::fastrtps::rtps::operator>>(std::ostream&, const GUID_t&);
1111

12+
// Ignore the global comparison operators and make them class-internal
13+
%ignore eprosima::fastrtps::operator==(const Time_t&, const Time_t&);
14+
%ignore eprosima::fastrtps::operator!=(const Time_t&, const Time_t&);
15+
%ignore eprosima::fastrtps::operator<(const Time_t&, const Time_t&);
16+
1217
%include "fastdds/rtps/common/Guid.h"
18+
19+
// Declare the comparison operators as internal to the class
20+
%extend eprosima::fastrtps::rtps::GUID_t {
21+
bool operator==(const eprosima::fastrtps::rtps::GUID_t& other) const
22+
{
23+
return *$self == other;
24+
}
25+
26+
bool operator!=(const eprosima::fastrtps::rtps::GUID_t& other) const
27+
{
28+
return *$self != other;
29+
}
30+
31+
bool operator<(const eprosima::fastrtps::rtps::GUID_t& other) const
32+
{
33+
return *$self < other;
34+
}
35+
}
36+

src/swig/fastdds/rtps/common/Time_t.i

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
// We remove the one that is not used in the user API
88
// We also remove all the related operators
99
%ignore eprosima::fastrtps::rtps::Time_t;
10+
%ignore eprosima::fastrtps::rtps::operator==(const Time_t&, const Time_t&);
11+
%ignore eprosima::fastrtps::rtps::operator!=(const Time_t&, const Time_t&);
12+
%ignore eprosima::fastrtps::rtps::operator<(const Time_t&, const Time_t&);
13+
%ignore eprosima::fastrtps::rtps::operator<=(const Time_t&, const Time_t&);
14+
%ignore eprosima::fastrtps::rtps::operator>(const Time_t&, const Time_t&);
15+
%ignore eprosima::fastrtps::rtps::operator>=(const Time_t&, const Time_t&);
16+
%ignore eprosima::fastrtps::rtps::operator+(const Time_t&, const Time_t&);
17+
%ignore eprosima::fastrtps::rtps::operator-(const Time_t&, const Time_t&);
1018
%ignore eprosima::fastrtps::rtps::operator<<(std::ostream&, const Time_t&);
1119
%ignore eprosima::fastrtps::rtps::operator>>(std::ostream&, const Time_t&);
1220

@@ -15,4 +23,59 @@
1523
%ignore eprosima::fastrtps::operator<<(std::ostream&, const Time_t&);
1624
%ignore eprosima::fastrtps::operator>>(std::ostream&, const Time_t&);
1725

26+
// Ignore the global comparison and arithmetic operators
27+
// and make them class-internal
28+
%ignore eprosima::fastrtps::operator==(const Time_t&, const Time_t&);
29+
%ignore eprosima::fastrtps::operator!=(const Time_t&, const Time_t&);
30+
%ignore eprosima::fastrtps::operator<(const Time_t&, const Time_t&);
31+
%ignore eprosima::fastrtps::operator<=(const Time_t&, const Time_t&);
32+
%ignore eprosima::fastrtps::operator>(const Time_t&, const Time_t&);
33+
%ignore eprosima::fastrtps::operator>=(const Time_t&, const Time_t&);
34+
%ignore eprosima::fastrtps::operator+(const Time_t&, const Time_t&);
35+
%ignore eprosima::fastrtps::operator-(const Time_t&, const Time_t&);
36+
1837
%include "fastdds/rtps/common/Time_t.h"
38+
39+
// Declare the comparison operators as internal to the class
40+
%extend eprosima::fastrtps::Time_t {
41+
bool operator==(const eprosima::fastrtps::Time_t& other) const
42+
{
43+
return *$self == other;
44+
}
45+
46+
bool operator!=(const eprosima::fastrtps::Time_t& other) const
47+
{
48+
return *$self != other;
49+
}
50+
51+
bool operator<(const eprosima::fastrtps::Time_t& other) const
52+
{
53+
return *$self < other;
54+
}
55+
56+
bool operator>(const eprosima::fastrtps::Time_t& other) const
57+
{
58+
return *$self > other;
59+
}
60+
61+
bool operator<=(const eprosima::fastrtps::Time_t& other) const
62+
{
63+
return *$self <= other;
64+
}
65+
66+
bool operator>=(const eprosima::fastrtps::Time_t& other) const
67+
{
68+
return *$self >= other;
69+
}
70+
71+
eprosima::fastrtps::Time_t operator+ (const eprosima::fastrtps::Time_t& other) const
72+
{
73+
return *$self + other;
74+
}
75+
76+
eprosima::fastrtps::Time_t operator- (const eprosima::fastrtps::Time_t& other) const
77+
{
78+
return *$self - other;
79+
}
80+
}
81+

src/swig/fastdds_wrapper.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ namespace builtin {
385385
%include "fastdds/rtps/common/EntityId_t.i"
386386
%include "fastdds/rtps/common/GuidPrefix_t.i"
387387
%include "fastdds/rtps/common/Guid.i"
388-
%include "fastdds/rtps/common/InstanceHandle.i"
388+
%include "fastdds/dds/common/InstanceHandle.i"
389389
%include "fastdds/dds/core/policy/ParameterTypes.i"
390390
%include "fastdds/dds/core/policy/QosPolicies.i"
391391
%include "fastdds/dds/topic/TopicDataType.i"

0 commit comments

Comments
 (0)