BLPAPI C++ 3.26.7
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
289BLPAPI_EXPORT
290int blpapi_TopicList_messageAt(const blpapi_TopicList_t *list,
291 blpapi_Message_t **element,
292 size_t index);
293
301BLPAPI_EXPORT
302int blpapi_TopicList_size(const blpapi_TopicList_t *list);
303
306
307#ifdef __cplusplus
308}
309
310#ifndef INCLUDED_BLPAPI_EXCEPTION
311#include <blpapi_exception.h>
312#endif
313
314namespace BloombergLP {
315namespace blpapi {
322
323class ResolutionList;
324
338
339 blpapi_TopicList_t *d_handle_p;
340
341 public:
342 enum Status {
343 NOT_CREATED = BLPAPI_TOPICLIST_NOT_CREATED,
344 CREATED = BLPAPI_TOPICLIST_CREATED,
345 FAILURE = BLPAPI_TOPICLIST_FAILURE
346 };
347
348 // CLASS METHODS
349 TopicList();
353
354 explicit TopicList(const ResolutionList& original);
360
361 TopicList(const TopicList& original);
365
366 virtual ~TopicList();
370
371 // MANIPULATORS
372 virtual int add(const char *topic,
373 const CorrelationId& correlationId = CorrelationId());
380
381 virtual int add(Message const& message,
382 const CorrelationId& correlationId = CorrelationId());
391
392 virtual CorrelationId correlationIdAt(size_t index) const;
397
398 virtual const char *topicString(const CorrelationId& correlationId) const;
404
405 virtual const char *topicStringAt(size_t index) const;
410
411 virtual int status(const CorrelationId& correlationId) const;
419
420 virtual int statusAt(size_t index) const;
426
427 virtual Message const message(const CorrelationId& correlationId) const;
436
437 virtual Message const messageAt(size_t index) const;
445
446 virtual size_t size() const;
450
452 const blpapi_TopicList_t *impl() const;
453
454 blpapi_TopicList_t *impl();
456};
457
460
461namespace util {
462
466
467constexpr const char *to_string(TopicList::Status status);
471
473
474} // close namespace util
475
476// ============================================================================
477// INLINE FUNCTION DEFINITIONS
478// ============================================================================
479
480// ---------------
481// class TopicList
482// ---------------
483
485 : d_handle_p(blpapi_TopicList_create(0))
486{
487}
488
489inline TopicList::TopicList(const TopicList& original)
490 : d_handle_p(blpapi_TopicList_create(original.d_handle_p))
491{
492}
493
495 : d_handle_p(
496 blpapi_TopicList_create(reinterpret_cast<blpapi_TopicList_t *>(
497 const_cast<blpapi_ResolutionList_t *>(original.impl()))))
498{
499}
500
501inline TopicList::~TopicList() { blpapi_TopicList_destroy(d_handle_p); }
502
503inline int TopicList::add(
504 const char *topic, const CorrelationId& correlationId)
505{
506 return blpapi_TopicList_add(d_handle_p, topic, &correlationId.impl());
507}
508
509inline int TopicList::add(
510 const Message& newMessage, const CorrelationId& correlationId)
511{
512 return blpapi_TopicList_addFromMessage(
513 d_handle_p, newMessage.impl(), &correlationId.impl());
514}
515
517{
518 blpapi_CorrelationId_t correlationId;
519 ExceptionUtil::throwOnError(blpapi_TopicList_correlationIdAt(
520 d_handle_p, &correlationId, index));
521
522 return CorrelationId(correlationId);
523}
524
525inline const char *TopicList::topicString(
526 const CorrelationId& correlationId) const
527{
528 const char *topic = 0;
529 ExceptionUtil::throwOnError(blpapi_TopicList_topicString(
530 d_handle_p, &topic, &correlationId.impl()));
531
532 return topic;
533}
534
535inline const char *TopicList::topicStringAt(size_t index) const
536{
537 const char *topic = 0;
539 blpapi_TopicList_topicStringAt(d_handle_p, &topic, index));
540
541 return topic;
542}
543
544inline int TopicList::status(const CorrelationId& correlationId) const
545{
546 int result = 0;
547 ExceptionUtil::throwOnError(blpapi_TopicList_status(
548 d_handle_p, &result, &correlationId.impl()));
549
550 return result;
551}
552
553inline int TopicList::statusAt(size_t index) const
554{
555 int result = 0;
557 blpapi_TopicList_statusAt(d_handle_p, &result, index));
558
559 return result;
560}
561
563 const CorrelationId& correlationId) const
564{
565 blpapi_Message_t *messageByCid = 0;
566 ExceptionUtil::throwOnError(blpapi_TopicList_message(
567 d_handle_p, &messageByCid, &correlationId.impl()));
568 BLPAPI_CALL_MESSAGE_ADDREF(messageByCid);
569 return Message(messageByCid, true);
570}
571
572inline Message const TopicList::messageAt(size_t index) const
573{
574 blpapi_Message_t *messageByIndex = 0;
576 blpapi_TopicList_messageAt(d_handle_p, &messageByIndex, index));
577
578 BLPAPI_CALL_MESSAGE_ADDREF(messageByIndex);
579 return Message(messageByIndex, true);
580}
581
582inline size_t TopicList::size() const
583{
584 return static_cast<size_t>(blpapi_TopicList_size(d_handle_p));
585}
586
588inline const blpapi_TopicList_t *TopicList::impl() const { return d_handle_p; }
589
590inline blpapi_TopicList_t *TopicList::impl() { return d_handle_p; }
592
593// --------------
594// namespace util
595// --------------
596constexpr const char *util::to_string(TopicList::Status status)
597{
598 switch (status) {
600 return "NOT_CREATED";
602 return "CREATED";
604 return "FAILURE";
605 }
606 // Silence warnings on some compilers
607 return "UNDEFINED";
608}
609
610} // close namespace blpapi
611} // close namespace BloombergLP
612
613#endif // ifdef __cplusplus
614
615#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:322
static void throwOnError(int errorCode)
Definition blpapi_exception.h:556
Definition blpapi_message.h:344
Definition blpapi_resolutionlist.h:418
Definition blpapi_topiclist.h:337
virtual const char * topicString(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:525
virtual Message const message(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:562
virtual const char * topicStringAt(size_t index) const
Definition blpapi_topiclist.h:535
virtual size_t size() const
Definition blpapi_topiclist.h:582
Status
Definition blpapi_topiclist.h:342
@ CREATED
Created successfully.
Definition blpapi_topiclist.h:344
@ FAILURE
Topic creation failed.
Definition blpapi_topiclist.h:345
@ NOT_CREATED
Not created.
Definition blpapi_topiclist.h:343
virtual int statusAt(size_t index) const
Definition blpapi_topiclist.h:553
virtual CorrelationId correlationIdAt(size_t index) const
Definition blpapi_topiclist.h:516
TopicList()
Definition blpapi_topiclist.h:484
virtual ~TopicList()
Definition blpapi_topiclist.h:501
virtual int status(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:544
virtual int add(const char *topic, const CorrelationId &correlationId=CorrelationId())
Definition blpapi_topiclist.h:503
virtual Message const messageAt(size_t index) const
Definition blpapi_topiclist.h:572
constexpr const char * to_string(CorrelationId::ValueType valueType)
Definition blpapi_correlationid.h:830
Definition blpapi_abstractsession.h:448
Definition blpapi_abstractsession.h:447