BLPAPI C++ 3.26.6
Loading...
Searching...
No Matches
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
37
38#ifndef INCLUDED_BLPAPI_TOPICLIST
39#define INCLUDED_BLPAPI_TOPICLIST
40
67
68#ifndef INCLUDED_BLPAPI_TYPES
69#include <blpapi_types.h>
70#endif
71
72#ifndef INCLUDED_BLPAPI_CORRELATIONID
74#endif
75
76#ifndef INCLUDED_BLPAPI_DEFS
77#include <blpapi_defs.h>
78#endif
79
80#ifndef INCLUDED_BLPAPI_ELEMENT
81#include <blpapi_element.h>
82#endif
83
84#ifndef INCLUDED_BLPAPI_NAME
85#include <blpapi_name.h>
86#endif
87
88#ifndef INCLUDED_BLPAPI_MESSAGE
89#include <blpapi_message.h>
90#endif
91
92#ifndef INCLUDED_BLPAPI_RESOLUTIONLIST
94#endif
95
96struct blpapi_TopicList;
97#ifdef __cplusplus
98extern "C" {
99#endif
100
102typedef struct blpapi_TopicList blpapi_TopicList_t;
103
107
118BLPAPI_EXPORT
119blpapi_TopicList_t *blpapi_TopicList_create(blpapi_TopicList_t *from);
120
128BLPAPI_EXPORT
129void blpapi_TopicList_destroy(blpapi_TopicList_t *list);
130
144BLPAPI_EXPORT
145int blpapi_TopicList_add(blpapi_TopicList_t *list,
146 const char *topic,
147 const blpapi_CorrelationId_t *correlationId);
148
164BLPAPI_EXPORT
165int blpapi_TopicList_addFromMessage(blpapi_TopicList_t *list,
166 const blpapi_Message_t *topic,
167 const blpapi_CorrelationId_t *correlationId);
168
181BLPAPI_EXPORT
182int blpapi_TopicList_correlationIdAt(const blpapi_TopicList_t *list,
183 blpapi_CorrelationId_t *result,
184 size_t index);
185
199BLPAPI_EXPORT
200int blpapi_TopicList_topicString(const blpapi_TopicList_t *list,
201 const char **topic,
202 const blpapi_CorrelationId_t *id);
203
216BLPAPI_EXPORT
217int blpapi_TopicList_topicStringAt(
218 const blpapi_TopicList_t *list, const char **topic, size_t index);
219
233BLPAPI_EXPORT
234int blpapi_TopicList_status(const blpapi_TopicList_t *list,
235 int *status,
236 const blpapi_CorrelationId_t *id);
237
251BLPAPI_EXPORT
252int blpapi_TopicList_statusAt(
253 const blpapi_TopicList_t *list, int *status, size_t index);
254
270BLPAPI_EXPORT
271int blpapi_TopicList_message(const blpapi_TopicList_t *list,
272 blpapi_Message_t **element,
273 const blpapi_CorrelationId_t *id);
274
288BLPAPI_EXPORT
289int blpapi_TopicList_messageAt(const blpapi_TopicList_t *list,
290 blpapi_Message_t **element,
291 size_t index);
292
300BLPAPI_EXPORT
301int blpapi_TopicList_size(const blpapi_TopicList_t *list);
302
305
306#ifdef __cplusplus
307}
308
309#ifndef INCLUDED_BLPAPI_EXCEPTION
310#include <blpapi_exception.h>
311#endif
312
313namespace BloombergLP {
314namespace blpapi {
321
322class ResolutionList;
323
337
338 blpapi_TopicList_t *d_handle_p;
339
340 public:
341 enum Status {
342 NOT_CREATED = BLPAPI_TOPICLIST_NOT_CREATED,
343 CREATED = BLPAPI_TOPICLIST_CREATED,
344 FAILURE = BLPAPI_TOPICLIST_FAILURE
345 };
346
347 // CLASS METHODS
348 TopicList();
352
353 explicit TopicList(const ResolutionList& original);
359
360 TopicList(const TopicList& original);
364
365 virtual ~TopicList();
369
370 // MANIPULATORS
371 virtual int add(const char *topic,
372 const CorrelationId& correlationId = CorrelationId());
379
380 virtual int add(Message const& message,
381 const CorrelationId& correlationId = CorrelationId());
390
391 virtual CorrelationId correlationIdAt(size_t index) const;
396
397 virtual const char *topicString(const CorrelationId& correlationId) const;
403
404 virtual const char *topicStringAt(size_t index) const;
409
410 virtual int status(const CorrelationId& correlationId) const;
418
419 virtual int statusAt(size_t index) const;
425
426 virtual Message const message(const CorrelationId& correlationId) const;
435
436 virtual Message const messageAt(size_t index) const;
444
445 virtual size_t size() const;
449
451 const blpapi_TopicList_t *impl() const;
452
453 blpapi_TopicList_t *impl();
455};
456
459
460// ============================================================================
461// INLINE FUNCTION DEFINITIONS
462// ============================================================================
463
464// ---------------
465// class TopicList
466// ---------------
467
469 : d_handle_p(blpapi_TopicList_create(0))
470{
471}
472
473inline TopicList::TopicList(const TopicList& original)
474 : d_handle_p(blpapi_TopicList_create(original.d_handle_p))
475{
476}
477
479 : d_handle_p(
480 blpapi_TopicList_create(reinterpret_cast<blpapi_TopicList_t *>(
481 const_cast<blpapi_ResolutionList_t *>(original.impl()))))
482{
483}
484
485inline TopicList::~TopicList() { blpapi_TopicList_destroy(d_handle_p); }
486
487inline int TopicList::add(
488 const char *topic, const CorrelationId& correlationId)
489{
490 return blpapi_TopicList_add(d_handle_p, topic, &correlationId.impl());
491}
492
493inline int TopicList::add(
494 const Message& newMessage, const CorrelationId& correlationId)
495{
496 return blpapi_TopicList_addFromMessage(
497 d_handle_p, newMessage.impl(), &correlationId.impl());
498}
499
501{
502 blpapi_CorrelationId_t correlationId;
503 ExceptionUtil::throwOnError(blpapi_TopicList_correlationIdAt(
504 d_handle_p, &correlationId, index));
505
506 return CorrelationId(correlationId);
507}
508
509inline const char *TopicList::topicString(
510 const CorrelationId& correlationId) const
511{
512 const char *topic = 0;
513 ExceptionUtil::throwOnError(blpapi_TopicList_topicString(
514 d_handle_p, &topic, &correlationId.impl()));
515
516 return topic;
517}
518
519inline const char *TopicList::topicStringAt(size_t index) const
520{
521 const char *topic = 0;
523 blpapi_TopicList_topicStringAt(d_handle_p, &topic, index));
524
525 return topic;
526}
527
528inline int TopicList::status(const CorrelationId& correlationId) const
529{
530 int result = 0;
531 ExceptionUtil::throwOnError(blpapi_TopicList_status(
532 d_handle_p, &result, &correlationId.impl()));
533
534 return result;
535}
536
537inline int TopicList::statusAt(size_t index) const
538{
539 int result = 0;
541 blpapi_TopicList_statusAt(d_handle_p, &result, index));
542
543 return result;
544}
545
547 const CorrelationId& correlationId) const
548{
549 blpapi_Message_t *messageByCid = 0;
550 ExceptionUtil::throwOnError(blpapi_TopicList_message(
551 d_handle_p, &messageByCid, &correlationId.impl()));
552 BLPAPI_CALL_MESSAGE_ADDREF(messageByCid);
553 return Message(messageByCid, true);
554}
555
556inline Message const TopicList::messageAt(size_t index) const
557{
558 blpapi_Message_t *messageByIndex = 0;
560 blpapi_TopicList_messageAt(d_handle_p, &messageByIndex, index));
561
562 BLPAPI_CALL_MESSAGE_ADDREF(messageByIndex);
563 return Message(messageByIndex, true);
564}
565
566inline size_t TopicList::size() const
567{
568 return static_cast<size_t>(blpapi_TopicList_size(d_handle_p));
569}
570
572inline const blpapi_TopicList_t *TopicList::impl() const { return d_handle_p; }
573
574inline blpapi_TopicList_t *TopicList::impl() { return d_handle_p; }
576
577} // close namespace blpapi
578} // close namespace BloombergLP
579
580#endif // ifdef __cplusplus
581
582#endif // #ifndef INCLUDED_BLPAPI_TOPICLIST
Provide a key to identify individual subscriptions or requests.
Common definitions used by the library.
Provide a representation of an item in a message.
Defines Exceptions that can be thrown by the blpapi library.
Defines a message containing elements.
Provide a representation of strings for use as container keys.
Provide a representation of a list of topics.
Provide BLPAPI types.
Definition blpapi_correlationid.h:306
static void throwOnError(int errorCode)
Definition blpapi_exception.h:556
Definition blpapi_message.h:344
Definition blpapi_resolutionlist.h:418
Definition blpapi_topiclist.h:336
virtual const char * topicString(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:509
virtual Message const message(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:546
virtual const char * topicStringAt(size_t index) const
Definition blpapi_topiclist.h:519
virtual size_t size() const
Definition blpapi_topiclist.h:566
Status
Definition blpapi_topiclist.h:341
@ CREATED
Created successfully.
Definition blpapi_topiclist.h:343
@ FAILURE
Topic creation failed.
Definition blpapi_topiclist.h:344
@ NOT_CREATED
Not created.
Definition blpapi_topiclist.h:342
virtual int statusAt(size_t index) const
Definition blpapi_topiclist.h:537
virtual CorrelationId correlationIdAt(size_t index) const
Definition blpapi_topiclist.h:500
TopicList()
Definition blpapi_topiclist.h:468
virtual ~TopicList()
Definition blpapi_topiclist.h:485
virtual int status(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:528
virtual int add(const char *topic, const CorrelationId &correlationId=CorrelationId())
Definition blpapi_topiclist.h:487
virtual Message const messageAt(size_t index) const
Definition blpapi_topiclist.h:556
Definition blpapi_abstractsession.h:452
Definition blpapi_abstractsession.h:451