/src/Fast-DDS/include/fastrtps/attributes/TopicAttributes.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2016 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 | | * @file TopicAttributes.h |
17 | | */ |
18 | | |
19 | | #ifndef TOPICPARAMETERS_H_ |
20 | | #define TOPICPARAMETERS_H_ |
21 | | |
22 | | #include <string> |
23 | | |
24 | | #include <fastdds/rtps/common/Types.h> |
25 | | #include <fastrtps/qos/QosPolicies.h> |
26 | | |
27 | | |
28 | | namespace eprosima { |
29 | | namespace fastrtps{ |
30 | | |
31 | | /** |
32 | | * Class TopicAttributes, used by the user to define the attributes of the topic associated with a Publisher or Subscriber. |
33 | | * @ingroup FASTRTPS_ATTRIBUTES_MODULE |
34 | | */ |
35 | | class TopicAttributes |
36 | | { |
37 | | public: |
38 | | |
39 | | /** |
40 | | * Default constructor |
41 | | */ |
42 | | TopicAttributes() |
43 | | : topicKind(rtps::NO_KEY) |
44 | | , topicName("UNDEF") |
45 | | , topicDataType("UNDEF") |
46 | | , auto_fill_type_object(true) |
47 | | , auto_fill_type_information(true) |
48 | 97.6k | { |
49 | 97.6k | } |
50 | | |
51 | | //!Constructor, you need to provide the topic name and the topic data type. |
52 | | TopicAttributes( |
53 | | const char* name, |
54 | | const char* dataType, |
55 | | rtps::TopicKind_t tKind= rtps::NO_KEY) |
56 | 0 | { |
57 | 0 | topicKind = tKind; |
58 | 0 | topicName = name; |
59 | 0 | topicDataType = dataType; |
60 | 0 | auto_fill_type_object = true; |
61 | 0 | auto_fill_type_information = true; |
62 | 0 | } |
63 | | |
64 | 93.3k | virtual ~TopicAttributes() {} |
65 | | |
66 | | bool operator==(const TopicAttributes& b) const |
67 | 0 | { |
68 | 0 | return (this->topicKind == b.topicKind) && |
69 | 0 | (this->topicName == b.topicName) && |
70 | 0 | (this->topicDataType == b.topicDataType) && |
71 | 0 | (this->historyQos == b.historyQos); |
72 | 0 | } |
73 | | |
74 | | /** |
75 | | * Get the topic data type |
76 | | * @return Topic data type |
77 | | */ |
78 | 0 | const string_255& getTopicDataType() const { |
79 | 0 | return topicDataType; |
80 | 0 | } |
81 | | |
82 | | /** |
83 | | * Get the topic kind |
84 | | * @return Topic kind |
85 | | */ |
86 | 0 | rtps::TopicKind_t getTopicKind() const { |
87 | 0 | return topicKind; |
88 | 0 | } |
89 | | |
90 | | /** |
91 | | * Get the topic name |
92 | | * @return Topic name |
93 | | */ |
94 | 0 | const string_255& getTopicName() const { |
95 | 0 | return topicName; |
96 | 0 | } |
97 | | |
98 | | //! TopicKind_t, default value NO_KEY. |
99 | | rtps::TopicKind_t topicKind; |
100 | | //! Topic Name. |
101 | | string_255 topicName; |
102 | | //!Topic Data Type. |
103 | | string_255 topicDataType; |
104 | | //!QOS Regarding the History to be saved. |
105 | | HistoryQosPolicy historyQos; |
106 | | //!QOS Regarding the resources to allocate. |
107 | | ResourceLimitsQosPolicy resourceLimitsQos; |
108 | | //!Type Identifier XTYPES 1.1 |
109 | | TypeIdV1 type_id; |
110 | | //!Type Object XTYPES 1.1 |
111 | | TypeObjectV1 type; |
112 | | //!XTYPES 1.2 |
113 | | xtypes::TypeInformation type_information; |
114 | | //!Tries to complete type identifier and type object (TypeObjectV1) |
115 | | bool auto_fill_type_object; |
116 | | //!Tries to complete type information (TypeObjectV2) |
117 | | bool auto_fill_type_information; |
118 | | |
119 | | /** |
120 | | * Method to check whether the defined QOS are correct. |
121 | | * @return True if they are valid. |
122 | | */ |
123 | | bool checkQos() const; |
124 | | }; |
125 | | |
126 | | #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
127 | | |
128 | | /** |
129 | | * Check if two topic attributes are not equal |
130 | | * @param t1 First instance of TopicAttributes to compare |
131 | | * @param t2 Second instance of TopicAttributes to compare |
132 | | * @return True if the instances are not equal. False if the instances are equal. |
133 | | */ |
134 | | bool inline operator!=(const TopicAttributes& t1, const TopicAttributes& t2) |
135 | 0 | { |
136 | 0 | if(t1.topicKind != t2.topicKind |
137 | 0 | || t1.topicName != t2.topicName |
138 | 0 | || t1.topicDataType != t2.topicDataType |
139 | 0 | || t1.historyQos.kind != t2.historyQos.kind |
140 | 0 | || (t1.historyQos.kind == KEEP_LAST_HISTORY_QOS && t1.historyQos.depth != t2.historyQos.depth)) |
141 | 0 | { |
142 | 0 | return true; |
143 | 0 | } |
144 | 0 | return false; |
145 | 0 | } |
146 | | #endif |
147 | | |
148 | | } /* namespace fastrtps */ |
149 | | } /* namespace eprosima */ |
150 | | |
151 | | #endif /* TOPICPARAMETERS_H_ */ |