BLPAPI C++  3.24.4
blpapi_topic.h
Go to the documentation of this file.
1 /* Copyright 2012. Bloomberg Finance L.P.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions: The above
9  * copyright notice and this permission notice shall be included in all copies
10  * or substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18  * IN THE SOFTWARE.
19  */
20 
28 #ifndef INCLUDED_BLPAPI_TOPIC
29 #define INCLUDED_BLPAPI_TOPIC
30 
59 #ifndef INCLUDED_BLPAPI_DEFS
60 #include <blpapi_defs.h>
61 #endif
62 
63 #ifndef INCLUDED_BLPAPI_SERVICE
64 #include <blpapi_service.h>
65 #endif
66 
67 struct blpapi_Topic;
68 typedef struct blpapi_Topic blpapi_Topic_t;
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
76 
79 
81 int blpapi_Topic_compare(const blpapi_Topic_t *lhs, const blpapi_Topic_t *rhs);
82 
85 
87 int blpapi_Topic_isActive(const blpapi_Topic_t *topic);
88 
89 #ifdef __cplusplus
90 }
91 
92 #include <utility>
93 
101 namespace BloombergLP {
102 namespace blpapi {
103 
114 class Topic {
115 
116  blpapi_Topic_t *d_handle;
117 
118  public:
119  Topic();
126  explicit Topic(blpapi_Topic_t *handle);
131  Topic(const Topic& original);
136  ~Topic();
141  Topic& operator=(const Topic& rhs);
142 
143  bool isValid() const;
149  bool isActive() const;
155  Service service() const;
160  const blpapi_Topic_t *impl() const;
161 
162  blpapi_Topic_t *impl();
163 };
164 
168 bool operator==(Topic const& lhs, Topic const& rhs);
169 
170 bool operator!=(Topic const& lhs, Topic const& rhs);
171 
172 bool operator<(Topic const& lhs, Topic const& rhs);
173 
174 // ============================================================================
175 // INLINE FUNCTION DEFINITIONS
176 // ============================================================================
177 
178 // -----------
179 // class Topic
180 // -----------
181 
182 inline Topic::Topic()
183  : d_handle(0)
184 {
185 }
186 
188  : d_handle(handle)
189 {
190 }
191 
192 inline Topic::Topic(Topic const& original)
193  : d_handle(blpapi_Topic_create(original.d_handle))
194 {
195 }
196 
197 inline Topic::~Topic() { blpapi_Topic_destroy(d_handle); }
198 
199 inline Topic& Topic::operator=(Topic const& rhs)
200 {
201  using std::swap;
202 
203  Topic tmp(rhs);
204  swap(tmp.d_handle, d_handle);
205 
206  return *this;
207 }
208 
209 inline bool Topic::isValid() const { return 0 != d_handle; }
210 
211 inline bool Topic::isActive() const
212 {
213  return blpapi_Topic_isActive(d_handle) != 0;
214 }
215 
216 inline Service Topic::service() const
217 {
218  return Service(blpapi_Topic_service(d_handle));
219 }
220 
221 inline const blpapi_Topic_t *Topic::impl() const { return d_handle; }
222 
223 inline blpapi_Topic_t *Topic::impl() { return d_handle; }
224 
225 inline bool operator==(Topic const& lhs, Topic const& rhs)
226 {
227  return blpapi_Topic_compare(lhs.impl(), rhs.impl()) == 0;
228 }
229 
230 inline bool operator!=(Topic const& lhs, Topic const& rhs)
231 {
232  return blpapi_Topic_compare(lhs.impl(), rhs.impl()) != 0;
233 }
234 
235 inline bool operator<(Topic const& lhs, Topic const& rhs)
236 {
237  return blpapi_Topic_compare(lhs.impl(), rhs.impl()) < 0;
238 }
239 
240 } // close namespace blpapi
241 } // close namespace BloombergLP
242 
243 #endif // #ifdef __cplusplus
244 #endif // #ifndef INCLUDED_BLPAPI_TOPIC
bool operator!=(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:582
Common definitions used by the library.
bool operator==(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:562
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition: blpapi_event.h:723
bool operator<(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:587
Definition: blpapi_abstractsession.h:220
Definition: blpapi_service.h:304
blpapi_Topic_t * blpapi_Topic_create(blpapi_Topic_t *from)
blpapi_Service_t * blpapi_Topic_service(const blpapi_Topic_t *topic)
Topic()
Definition: blpapi_topic.h:182
A service which provides access to API data (provide or consume).
struct blpapi_Topic blpapi_Topic_t
Definition: blpapi_topic.h:68
bool isActive() const
Definition: blpapi_topic.h:211
const blpapi_Topic_t * impl() const
Definition: blpapi_topic.h:221
int blpapi_Topic_compare(const blpapi_Topic_t *lhs, const blpapi_Topic_t *rhs)
~Topic()
Definition: blpapi_topic.h:197
Topic & operator=(const Topic &rhs)
Definition: blpapi_topic.h:199
void blpapi_Topic_destroy(blpapi_Topic_t *victim)
bool isValid() const
Definition: blpapi_topic.h:209
Definition: blpapi_topic.h:114
int blpapi_Topic_isActive(const blpapi_Topic_t *topic)
Service service() const
Definition: blpapi_topic.h:216
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
struct blpapi_Service blpapi_Service_t
Definition: blpapi_types.h:166