BLPAPI C++ 3.26.5
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
35
36#ifndef INCLUDED_BLPAPI_TOPICLIST
37#define INCLUDED_BLPAPI_TOPICLIST
38
66
67#ifndef INCLUDED_BLPAPI_TYPES
68#include <blpapi_types.h>
69#endif
70
71#ifndef INCLUDED_BLPAPI_CORRELATIONID
73#endif
74
75#ifndef INCLUDED_BLPAPI_DEFS
76#include <blpapi_defs.h>
77#endif
78
79#ifndef INCLUDED_BLPAPI_ELEMENT
80#include <blpapi_element.h>
81#endif
82
83#ifndef INCLUDED_BLPAPI_NAME
84#include <blpapi_name.h>
85#endif
86
87#ifndef INCLUDED_BLPAPI_MESSAGE
88#include <blpapi_message.h>
89#endif
90
91#ifndef INCLUDED_BLPAPI_RESOLUTIONLIST
93#endif
94
95struct blpapi_TopicList;
96#ifdef __cplusplus
97extern "C" {
98#endif
99
101typedef struct blpapi_TopicList blpapi_TopicList_t;
102
106
107BLPAPI_EXPORT
108blpapi_TopicList_t *blpapi_TopicList_create(blpapi_TopicList_t *from);
109
110BLPAPI_EXPORT
111void blpapi_TopicList_destroy(blpapi_TopicList_t *list);
112
113BLPAPI_EXPORT
114int blpapi_TopicList_add(blpapi_TopicList_t *list,
115 const char *topic,
116 const blpapi_CorrelationId_t *correlationId);
117
118BLPAPI_EXPORT
119int blpapi_TopicList_addFromMessage(blpapi_TopicList_t *list,
120 const blpapi_Message_t *topic,
121 const blpapi_CorrelationId_t *correlationId);
122
123BLPAPI_EXPORT
124int blpapi_TopicList_correlationIdAt(const blpapi_TopicList_t *list,
125 blpapi_CorrelationId_t *result,
126 size_t index);
127
128BLPAPI_EXPORT
129int blpapi_TopicList_topicString(const blpapi_TopicList_t *list,
130 const char **topic,
131 const blpapi_CorrelationId_t *id);
132
133BLPAPI_EXPORT
134int blpapi_TopicList_topicStringAt(
135 const blpapi_TopicList_t *list, const char **topic, size_t index);
136
137BLPAPI_EXPORT
138int blpapi_TopicList_status(const blpapi_TopicList_t *list,
139 int *status,
140 const blpapi_CorrelationId_t *id);
141
142BLPAPI_EXPORT
143int blpapi_TopicList_statusAt(
144 const blpapi_TopicList_t *list, int *status, size_t index);
145
146BLPAPI_EXPORT
147int blpapi_TopicList_message(const blpapi_TopicList_t *list,
148 blpapi_Message_t **element,
149 const blpapi_CorrelationId_t *id);
150
151BLPAPI_EXPORT
152int blpapi_TopicList_messageAt(const blpapi_TopicList_t *list,
153 blpapi_Message_t **element,
154 size_t index);
155
156BLPAPI_EXPORT
157int blpapi_TopicList_size(const blpapi_TopicList_t *list);
158
161
162#ifdef __cplusplus
163}
164
165#ifndef INCLUDED_BLPAPI_EXCEPTION
166#include <blpapi_exception.h>
167#endif
168
175
176namespace BloombergLP {
177namespace blpapi {
178
179class ResolutionList;
180
194
195 blpapi_TopicList_t *d_handle_p;
196
197 public:
198 enum Status {
199 NOT_CREATED = BLPAPI_TOPICLIST_NOT_CREATED,
200 CREATED = BLPAPI_TOPICLIST_CREATED,
201 FAILURE = BLPAPI_TOPICLIST_FAILURE
202 };
203
204 // CLASS METHODS
205 TopicList();
209
210 explicit TopicList(const ResolutionList& original);
216
217 TopicList(const TopicList& original);
221
222 virtual ~TopicList();
226
227 // MANIPULATORS
228 virtual int add(const char *topic,
229 const CorrelationId& correlationId = CorrelationId());
236
237 virtual int add(Message const& message,
238 const CorrelationId& correlationId = CorrelationId());
247
248 virtual CorrelationId correlationIdAt(size_t index) const;
253
254 virtual const char *topicString(const CorrelationId& correlationId) const;
260
261 virtual const char *topicStringAt(size_t index) const;
266
267 virtual int status(const CorrelationId& correlationId) const;
275
276 virtual int statusAt(size_t index) const;
282
283 virtual Message const message(const CorrelationId& correlationId) const;
292
293 virtual Message const messageAt(size_t index) const;
301
302 virtual size_t size() const;
306
307 const blpapi_TopicList_t *impl() const;
308
309 blpapi_TopicList_t *impl();
310};
311
314
315// ============================================================================
316// INLINE FUNCTION DEFINITIONS
317// ============================================================================
318
319// ---------------
320// class TopicList
321// ---------------
322
324 : d_handle_p(blpapi_TopicList_create(0))
325{
326}
327
328inline TopicList::TopicList(const TopicList& original)
329 : d_handle_p(blpapi_TopicList_create(original.d_handle_p))
330{
331}
332
334 : d_handle_p(
335 blpapi_TopicList_create(reinterpret_cast<blpapi_TopicList_t *>(
336 const_cast<blpapi_ResolutionList_t *>(original.impl()))))
337{
338}
339
340inline TopicList::~TopicList() { blpapi_TopicList_destroy(d_handle_p); }
341
342inline int TopicList::add(
343 const char *topic, const CorrelationId& correlationId)
344{
345 return blpapi_TopicList_add(d_handle_p, topic, &correlationId.impl());
346}
347
348inline int TopicList::add(
349 const Message& newMessage, const CorrelationId& correlationId)
350{
351 return blpapi_TopicList_addFromMessage(
352 d_handle_p, newMessage.impl(), &correlationId.impl());
353}
354
356{
357 blpapi_CorrelationId_t correlationId;
358 ExceptionUtil::throwOnError(blpapi_TopicList_correlationIdAt(
359 d_handle_p, &correlationId, index));
360
361 return CorrelationId(correlationId);
362}
363
364inline const char *TopicList::topicString(
365 const CorrelationId& correlationId) const
366{
367 const char *topic = 0;
368 ExceptionUtil::throwOnError(blpapi_TopicList_topicString(
369 d_handle_p, &topic, &correlationId.impl()));
370
371 return topic;
372}
373
374inline const char *TopicList::topicStringAt(size_t index) const
375{
376 const char *topic = 0;
378 blpapi_TopicList_topicStringAt(d_handle_p, &topic, index));
379
380 return topic;
381}
382
383inline int TopicList::status(const CorrelationId& correlationId) const
384{
385 int result = 0;
386 ExceptionUtil::throwOnError(blpapi_TopicList_status(
387 d_handle_p, &result, &correlationId.impl()));
388
389 return result;
390}
391
392inline int TopicList::statusAt(size_t index) const
393{
394 int result = 0;
396 blpapi_TopicList_statusAt(d_handle_p, &result, index));
397
398 return result;
399}
400
402 const CorrelationId& correlationId) const
403{
404 blpapi_Message_t *messageByCid = 0;
405 ExceptionUtil::throwOnError(blpapi_TopicList_message(
406 d_handle_p, &messageByCid, &correlationId.impl()));
407 BLPAPI_CALL_MESSAGE_ADDREF(messageByCid);
408 return Message(messageByCid, true);
409}
410
411inline Message const TopicList::messageAt(size_t index) const
412{
413 blpapi_Message_t *messageByIndex = 0;
415 blpapi_TopicList_messageAt(d_handle_p, &messageByIndex, index));
416
417 BLPAPI_CALL_MESSAGE_ADDREF(messageByIndex);
418 return Message(messageByIndex, true);
419}
420
421inline size_t TopicList::size() const
422{
423 return static_cast<size_t>(blpapi_TopicList_size(d_handle_p));
424}
425
426inline const blpapi_TopicList_t *TopicList::impl() const { return d_handle_p; }
427
428inline blpapi_TopicList_t *TopicList::impl() { return d_handle_p; }
429
430} // close namespace blpapi
431} // close namespace BloombergLP
432
433#endif // ifdef __cplusplus
434
435#endif // #ifndef INCLUDED_BLPAPI_TOPICLIST
#define BLPAPI_CALL_MESSAGE_ADDREF(a1)
Definition blpapi_call.h:368
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:225
static void throwOnError(int errorCode)
Definition blpapi_exception.h:541
Definition blpapi_message.h:177
Definition blpapi_resolutionlist.h:211
Definition blpapi_topiclist.h:193
virtual const char * topicString(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:364
virtual Message const message(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:401
virtual const char * topicStringAt(size_t index) const
Definition blpapi_topiclist.h:374
virtual size_t size() const
Definition blpapi_topiclist.h:421
Status
Definition blpapi_topiclist.h:198
@ CREATED
Created successfully.
Definition blpapi_topiclist.h:200
@ FAILURE
Topic creation failed.
Definition blpapi_topiclist.h:201
@ NOT_CREATED
Not created.
Definition blpapi_topiclist.h:199
virtual int statusAt(size_t index) const
Definition blpapi_topiclist.h:392
virtual CorrelationId correlationIdAt(size_t index) const
Definition blpapi_topiclist.h:355
TopicList()
Definition blpapi_topiclist.h:323
const blpapi_TopicList_t * impl() const
Definition blpapi_topiclist.h:426
virtual ~TopicList()
Definition blpapi_topiclist.h:340
virtual int status(const CorrelationId &correlationId) const
Definition blpapi_topiclist.h:383
virtual int add(const char *topic, const CorrelationId &correlationId=CorrelationId())
Definition blpapi_topiclist.h:342
virtual Message const messageAt(size_t index) const
Definition blpapi_topiclist.h:411
Definition blpapi_abstractsession.h:212
Definition blpapi_abstractsession.h:211