|
| 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 |
0 commit comments