BLPAPI C++  3.21.0
blpapi_topiclist.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_TOPICLIST
29 #define INCLUDED_BLPAPI_TOPICLIST
30 
59 #ifndef INCLUDED_BLPAPI_TYPES
60 #include <blpapi_types.h>
61 #endif
62 
63 #ifndef INCLUDED_BLPAPI_CORRELATIONID
64 #include <blpapi_correlationid.h>
65 #endif
66 
67 #ifndef INCLUDED_BLPAPI_DEFS
68 #include <blpapi_defs.h>
69 #endif
70 
71 #ifndef INCLUDED_BLPAPI_ELEMENT
72 #include <blpapi_element.h>
73 #endif
74 
75 #ifndef INCLUDED_BLPAPI_NAME
76 #include <blpapi_name.h>
77 #endif
78 
79 #ifndef INCLUDED_BLPAPI_MESSAGE
80 #include <blpapi_message.h>
81 #endif
82 
83 #ifndef INCLUDED_BLPAPI_RESOLUTIONLIST
84 #include <blpapi_resolutionlist.h>
85 #endif
86 
87 struct blpapi_TopicList;
88 typedef struct blpapi_TopicList blpapi_TopicList_t;
89 
90 #ifdef __cplusplus
91 extern "C" {
92 #endif
93 
96 
99 
102  const char *topic,
103  const blpapi_CorrelationId_t *correlationId);
104 
107  const blpapi_Message_t *topic,
108  const blpapi_CorrelationId_t *correlationId);
109 
112  blpapi_CorrelationId_t *result,
113  size_t index);
114 
117  const char **topic,
118  const blpapi_CorrelationId_t *id);
119 
122  const blpapi_TopicList_t *list, const char **topic, size_t index);
123 
126  int *status,
127  const blpapi_CorrelationId_t *id);
128 
131  const blpapi_TopicList_t *list, int *status, size_t index);
132 
135  blpapi_Message_t **element,
136  const blpapi_CorrelationId_t *id);
137 
140  blpapi_Message_t **element,
141  size_t index);
142 
145 
146 #ifdef __cplusplus
147 }
148 
149 #ifndef INCLUDED_BLPAPI_EXCEPTION
150 #include <blpapi_exception.h>
151 #endif
152 
160 namespace BloombergLP {
161 namespace blpapi {
162 
163 class ResolutionList;
164 
177 class TopicList {
178 
179  blpapi_TopicList_t *d_handle_p;
180 
181  public:
182  enum Status {
186  };
187 
188  // CLASS METHODS
189  TopicList();
194  TopicList(const ResolutionList& original);
201  TopicList(const TopicList& original);
206  virtual ~TopicList();
211  // MANIPULATORS
212  virtual int add(const char *topic,
213  const CorrelationId& correlationId = CorrelationId());
221  virtual int add(Message const& message,
222  const CorrelationId& correlationId = CorrelationId());
232  virtual CorrelationId correlationIdAt(size_t index) const;
238  virtual const char *topicString(const CorrelationId& correlationId) const;
245  virtual const char *topicStringAt(size_t index) const;
251  virtual int status(const CorrelationId& correlationId) const;
260  virtual int statusAt(size_t index) const;
267  virtual Message const message(const CorrelationId& correlationId) const;
277  virtual Message const messageAt(size_t index) const;
286  virtual size_t size() const;
291  const blpapi_TopicList_t *impl() const;
292 
294 };
295 
299 // ============================================================================
300 // INLINE FUNCTION DEFINITIONS
301 // ============================================================================
302 
303 // ---------------
304 // class TopicList
305 // ---------------
306 
308  : d_handle_p(blpapi_TopicList_create(0))
309 {
310 }
311 
312 inline TopicList::TopicList(const TopicList& original)
313  : d_handle_p(blpapi_TopicList_create(original.d_handle_p))
314 {
315 }
316 
317 inline TopicList::TopicList(const ResolutionList& original)
318  : d_handle_p(
319  blpapi_TopicList_create(reinterpret_cast<blpapi_TopicList_t *>(
320  const_cast<blpapi_ResolutionList_t *>(original.impl()))))
321 {
322 }
323 
325 
326 inline int TopicList::add(
327  const char *topic, const CorrelationId& correlationId)
328 {
329  return blpapi_TopicList_add(d_handle_p, topic, &correlationId.impl());
330 }
331 
332 inline int TopicList::add(
333  const Message& newMessage, const CorrelationId& correlationId)
334 {
336  d_handle_p, newMessage.impl(), &correlationId.impl());
337 }
338 
339 inline CorrelationId TopicList::correlationIdAt(size_t index) const
340 {
341  blpapi_CorrelationId_t correlationId;
343  d_handle_p, &correlationId, index));
344 
345  return CorrelationId(correlationId);
346 }
347 
348 inline const char *TopicList::topicString(
349  const CorrelationId& correlationId) const
350 {
351  const char *topic = 0;
353  d_handle_p, &topic, &correlationId.impl()));
354 
355  return topic;
356 }
357 
358 inline const char *TopicList::topicStringAt(size_t index) const
359 {
360  const char *topic = 0;
362  blpapi_TopicList_topicStringAt(d_handle_p, &topic, index));
363 
364  return topic;
365 }
366 
367 inline int TopicList::status(const CorrelationId& correlationId) const
368 {
369  int result = 0;
371  d_handle_p, &result, &correlationId.impl()));
372 
373  return result;
374 }
375 
376 inline int TopicList::statusAt(size_t index) const
377 {
378  int result = 0;
380  blpapi_TopicList_statusAt(d_handle_p, &result, index));
381 
382  return result;
383 }
384 
386  const CorrelationId& correlationId) const
387 {
388  blpapi_Message_t *messageByCid = 0;
390  d_handle_p, &messageByCid, &correlationId.impl()));
391  BLPAPI_CALL_MESSAGE_ADDREF(messageByCid);
392  return Message(messageByCid, true);
393 }
394 
395 inline Message const TopicList::messageAt(size_t index) const
396 {
397  blpapi_Message_t *messageByIndex = 0;
399  blpapi_TopicList_messageAt(d_handle_p, &messageByIndex, index));
400 
401  BLPAPI_CALL_MESSAGE_ADDREF(messageByIndex);
402  return Message(messageByIndex, true);
403 }
404 
405 inline size_t TopicList::size() const
406 {
407  return static_cast<size_t>(blpapi_TopicList_size(d_handle_p));
408 }
409 
410 inline const blpapi_TopicList_t *TopicList::impl() const { return d_handle_p; }
411 
412 inline blpapi_TopicList_t *TopicList::impl() { return d_handle_p; }
413 
414 } // close namespace blpapi
415 } // close namespace BloombergLP
416 
417 #endif // ifdef __cplusplus
418 
419 #endif // #ifndef INCLUDED_BLPAPI_TOPICLIST
virtual Message const message(const CorrelationId &correlationId) const
Definition: blpapi_topiclist.h:385
virtual size_t size() const
Definition: blpapi_topiclist.h:405
Definition: blpapi_message.h:159
blpapi_TopicList_t * blpapi_TopicList_create(blpapi_TopicList_t *from)
#define BLPAPI_TOPICLIST_FAILURE
Definition: blpapi_defs.h:135
virtual int add(const char *topic, const CorrelationId &correlationId=CorrelationId())
Definition: blpapi_topiclist.h:326
Common definitions used by the library.
int blpapi_TopicList_addFromMessage(blpapi_TopicList_t *list, const blpapi_Message_t *topic, const blpapi_CorrelationId_t *correlationId)
struct blpapi_TopicList blpapi_TopicList_t
Definition: blpapi_topiclist.h:88
Definition: blpapi_abstractsession.h:215
int blpapi_TopicList_add(blpapi_TopicList_t *list, const char *topic, const blpapi_CorrelationId_t *correlationId)
virtual Message const messageAt(size_t index) const
Definition: blpapi_topiclist.h:395
int blpapi_TopicList_topicStringAt(const blpapi_TopicList_t *list, const char **topic, size_t index)
virtual ~TopicList()
Definition: blpapi_topiclist.h:324
int blpapi_TopicList_size(const blpapi_TopicList_t *list)
Status
Definition: blpapi_topiclist.h:182
struct blpapi_ResolutionList blpapi_ResolutionList_t
Definition: blpapi_resolutionlist.h:88
Not created.
Definition: blpapi_topiclist.h:183
TopicList()
Definition: blpapi_topiclist.h:307
Provide a key to identify individual subscriptions or requests.
struct blpapi_Message blpapi_Message_t
Definition: blpapi_message.h:70
static void throwOnError(int errorCode)
Definition: blpapi_exception.h:526
Topic creation failed.
Definition: blpapi_topiclist.h:185
int blpapi_TopicList_message(const blpapi_TopicList_t *list, blpapi_Message_t **element, const blpapi_CorrelationId_t *id)
const blpapi_TopicList_t * impl() const
Definition: blpapi_topiclist.h:410
Definition: blpapi_correlationid.h:201
Defines a message containing elements.
#define BLPAPI_TOPICLIST_CREATED
Definition: blpapi_defs.h:134
int blpapi_TopicList_topicString(const blpapi_TopicList_t *list, const char **topic, const blpapi_CorrelationId_t *id)
Definition: blpapi_topiclist.h:177
int blpapi_TopicList_messageAt(const blpapi_TopicList_t *list, blpapi_Message_t **element, size_t index)
virtual const char * topicStringAt(size_t index) const
Definition: blpapi_topiclist.h:358
virtual int statusAt(size_t index) const
Definition: blpapi_topiclist.h:376
int blpapi_TopicList_correlationIdAt(const blpapi_TopicList_t *list, blpapi_CorrelationId_t *result, size_t index)
Created successfully.
Definition: blpapi_topiclist.h:184
#define BLPAPI_TOPICLIST_NOT_CREATED
Definition: blpapi_defs.h:133
int blpapi_TopicList_statusAt(const blpapi_TopicList_t *list, int *status, size_t index)
Defines Exceptions that can be thrown by the blpapi library.
virtual CorrelationId correlationIdAt(size_t index) const
Definition: blpapi_topiclist.h:339
virtual int status(const CorrelationId &correlationId) const
Definition: blpapi_topiclist.h:367
int blpapi_TopicList_status(const blpapi_TopicList_t *list, int *status, const blpapi_CorrelationId_t *id)
virtual const char * topicString(const CorrelationId &correlationId) const
Definition: blpapi_topiclist.h:348
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
void blpapi_TopicList_destroy(blpapi_TopicList_t *list)
#define BLPAPI_CALL_MESSAGE_ADDREF(a1)
Definition: blpapi_call.h:360
Provide BLPAPI types.
Provide a representation of an item in a message.
Provide a representation of strings for use as container keys.
Definition: blpapi_resolutionlist.h:195
Provide a representation of a list of topics.