Skip to content

Commit ae2dfc6

Browse files
authored
Split Time_t.i in dds::Time_t and rtps::Time_t (#164)
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
1 parent 976dcd6 commit ae2dfc6

3 files changed

Lines changed: 96 additions & 74 deletions

File tree

fastdds_python/src/swig/fastdds.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ namespace xtypes {
173173
%include "fastdds/dds/core/status/StatusMask.i"
174174
%include "fastdds/dds/core/policy/ParameterTypes.i"
175175
%include "fastdds/dds/core/policy/QosPolicies.i"
176+
%include "fastdds/dds/core/Time_t.i"
176177
%include "fastdds/dds/topic/IContentFilter.i"
177178
%include "fastdds/dds/topic/TopicDataType.i"
178179
%include "fastdds/dds/topic/IContentFilterFactory.i"
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
%{
16+
#include <fastdds/dds/core/Time_t.hpp>
17+
%}
18+
19+
// Also ignore the insertion/exraction operator of the remaining Time_t,
20+
// as it makes no sense on the target language
21+
%ignore eprosima::fastdds::dds::operator<<(std::ostream&, const Time_t&);
22+
%ignore eprosima::fastdds::dds::operator>>(std::istream&, Time_t&);
23+
24+
// Ignore the global comparison and arithmetic operators
25+
// and make them class-internal
26+
%ignore eprosima::fastdds::dds::operator==(const Time_t&, const Time_t&);
27+
%ignore eprosima::fastdds::dds::operator!=(const Time_t&, const Time_t&);
28+
%ignore eprosima::fastdds::dds::operator<(const Time_t&, const Time_t&);
29+
%ignore eprosima::fastdds::dds::operator<=(const Time_t&, const Time_t&);
30+
%ignore eprosima::fastdds::dds::operator>(const Time_t&, const Time_t&);
31+
%ignore eprosima::fastdds::dds::operator>=(const Time_t&, const Time_t&);
32+
%ignore eprosima::fastdds::dds::operator+(const Time_t&, const Time_t&);
33+
%ignore eprosima::fastdds::dds::operator-(const Time_t&, const Time_t&);
34+
35+
// Declare the comparison operators as internal to the class
36+
%extend eprosima::fastdds::dds::Time_t {
37+
bool operator==(const eprosima::fastdds::dds::Time_t& other) const
38+
{
39+
return *$self == other;
40+
}
41+
42+
bool operator!=(const eprosima::fastdds::dds::Time_t& other) const
43+
{
44+
return *$self != other;
45+
}
46+
47+
bool operator<(const eprosima::fastdds::dds::Time_t& other) const
48+
{
49+
return *$self < other;
50+
}
51+
52+
bool operator>(const eprosima::fastdds::dds::Time_t& other) const
53+
{
54+
return *$self > other;
55+
}
56+
57+
bool operator<=(const eprosima::fastdds::dds::Time_t& other) const
58+
{
59+
return *$self <= other;
60+
}
61+
62+
bool operator>=(const eprosima::fastdds::dds::Time_t& other) const
63+
{
64+
return *$self >= other;
65+
}
66+
67+
eprosima::fastdds::dds::Time_t operator+ (const eprosima::fastdds::dds::Time_t& other) const
68+
{
69+
return *$self + other;
70+
}
71+
72+
eprosima::fastdds::dds::Time_t operator- (const eprosima::fastdds::dds::Time_t& other) const
73+
{
74+
return *$self - other;
75+
}
76+
}
77+
78+
%include <fastdds/dds/core/Time_t.hpp>
79+
80+
namespace eprosima {
81+
namespace fastdds {
82+
namespace dds {
83+
84+
struct Duration_t : public Time_t
85+
{
86+
Duration_t();
87+
88+
Duration_t(
89+
int32_t sec,
90+
uint32_t nsec);
91+
};
92+
93+
} // namespace dds
94+
} // namespace fastdds
95+
} // namespace eprosima

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

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -32,78 +32,4 @@
3232
%ignore eprosima::fastdds::rtps::operator<<(std::ostream&, const Time_t&);
3333
%ignore eprosima::fastdds::rtps::operator>>(std::istream&, Time_t&);
3434

35-
// Also ignore the insertion/exraction operator of the remaining Time_t,
36-
// as it makes no sense on the target language
37-
%ignore eprosima::fastdds::operator<<(std::ostream&, const Time_t&);
38-
%ignore eprosima::fastdds::operator>>(std::istream&, Time_t&);
39-
40-
// Ignore the global comparison and arithmetic operators
41-
// and make them class-internal
42-
%ignore eprosima::fastdds::operator==(const Time_t&, const Time_t&);
43-
%ignore eprosima::fastdds::operator!=(const Time_t&, const Time_t&);
44-
%ignore eprosima::fastdds::operator<(const Time_t&, const Time_t&);
45-
%ignore eprosima::fastdds::operator<=(const Time_t&, const Time_t&);
46-
%ignore eprosima::fastdds::operator>(const Time_t&, const Time_t&);
47-
%ignore eprosima::fastdds::operator>=(const Time_t&, const Time_t&);
48-
%ignore eprosima::fastdds::operator+(const Time_t&, const Time_t&);
49-
%ignore eprosima::fastdds::operator-(const Time_t&, const Time_t&);
50-
5135
%include <fastdds/rtps/common/Time_t.hpp>
52-
53-
// Declare the comparison operators as internal to the class
54-
%extend eprosima::fastdds::Time_t {
55-
bool operator==(const eprosima::fastdds::Time_t& other) const
56-
{
57-
return *$self == other;
58-
}
59-
60-
bool operator!=(const eprosima::fastdds::Time_t& other) const
61-
{
62-
return *$self != other;
63-
}
64-
65-
bool operator<(const eprosima::fastdds::Time_t& other) const
66-
{
67-
return *$self < other;
68-
}
69-
70-
bool operator>(const eprosima::fastdds::Time_t& other) const
71-
{
72-
return *$self > other;
73-
}
74-
75-
bool operator<=(const eprosima::fastdds::Time_t& other) const
76-
{
77-
return *$self <= other;
78-
}
79-
80-
bool operator>=(const eprosima::fastdds::Time_t& other) const
81-
{
82-
return *$self >= other;
83-
}
84-
85-
eprosima::fastdds::Time_t operator+ (const eprosima::fastdds::Time_t& other) const
86-
{
87-
return *$self + other;
88-
}
89-
90-
eprosima::fastdds::Time_t operator- (const eprosima::fastdds::Time_t& other) const
91-
{
92-
return *$self - other;
93-
}
94-
}
95-
96-
namespace eprosima {
97-
namespace fastdds {
98-
99-
struct Duration_t : public Time_t
100-
{
101-
Duration_t();
102-
103-
Duration_t(
104-
int32_t sec,
105-
uint32_t nsec);
106-
};
107-
108-
} // namespace fastdds
109-
} // namespace eprosima

0 commit comments

Comments
 (0)