BLPAPI C++  3.23.2
blpapi_session.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_SESSION
29 #define INCLUDED_BLPAPI_SESSION
30 
59 #ifndef INCLUDED_BLPAPI_ABSTRACTSESSION
60 #include <blpapi_abstractsession.h>
61 #endif
62 
63 #ifndef INCLUDED_BLPAPI_CALL
64 #include <blpapi_call.h>
65 #endif
66 
67 #ifndef INCLUDED_BLPAPI_CORRELATIONID
68 #include <blpapi_correlationid.h>
69 #endif
70 
71 #ifndef INCLUDED_BLPAPI_DEFS
72 #include <blpapi_defs.h>
73 #endif
74 
75 #ifndef INCLUDED_BLPAPI_EVENT
76 #include <blpapi_event.h>
77 #endif
78 
79 #ifndef INCLUDED_BLPAPI_EVENTDISPATCHER
80 #include <blpapi_eventdispatcher.h>
81 #endif
82 
83 #ifndef INCLUDED_BLPAPI_IDENTITY
84 #include <blpapi_identity.h>
85 #endif
86 
87 #ifndef INCLUDED_BLPAPI_REQUEST
88 #include <blpapi_request.h>
89 #endif
90 
91 #ifndef INCLUDED_BLPAPI_REQUESTTEMPLATE
92 #include <blpapi_requesttemplate.h>
93 #endif
94 
95 #ifndef INCLUDED_BLPAPI_SERVICE
96 #include <blpapi_service.h>
97 #endif
98 
99 #ifndef INCLUDED_BLPAPI_SESSIONOPTIONS
100 #include <blpapi_sessionoptions.h>
101 #endif
102 
103 #ifndef INCLUDED_BLPAPI_SUBSCRIPTIONLIST
104 #include <blpapi_subscriptionlist.h>
105 #endif
106 
107 #ifndef INCLUDED_BLPAPI_TYPES
108 #include <blpapi_types.h>
109 #endif
110 
111 #include <stddef.h>
112 
113 #ifdef __cplusplus
114 extern "C" {
115 #endif
116 
117 typedef void (*blpapi_EventHandler_t)(
118  blpapi_Event_t *event, blpapi_Session_t *session, void *userData);
119 
121  const blpapi_CorrelationId_t *correlationId,
122  const char *subscriptionString,
123  int errorCode,
124  const char *errorDescription,
125  void *userData);
126 
129  blpapi_EventHandler_t handler,
130  blpapi_EventDispatcher_t *dispatcher,
131  void *userData);
132 
135 
138 
141 
144 
147 
150  blpapi_Event_t **eventPointer,
151  unsigned int timeoutInMilliseconds);
152 
155  blpapi_Session_t *session, blpapi_Event_t **eventPointer);
156 
159  const blpapi_SubscriptionList_t *subscriptionList,
160  const blpapi_Identity_t *handle,
161  const char *requestLabel,
162  int requestLabelLen);
163 
166  const blpapi_SubscriptionList_t *subscriptionList,
167  const blpapi_Identity_t *handle,
168  const char *requestLabel,
169  int requestLabelLen,
171  void *userData);
172 
175  const blpapi_SubscriptionList_t *resubscriptionList,
176  const char *requestLabel,
177  int requestLabelLen);
178 
181  const blpapi_SubscriptionList_t *resubscriptionList,
182  const char *requestLabel,
183  int requestLabelLen,
185  void *userData);
186 
189  const blpapi_SubscriptionList_t *resubscriptionList,
190  int resubscriptionId,
191  const char *requestLabel,
192  int requestLabelLen);
193 
196  const blpapi_SubscriptionList_t *resubscriptionList,
197  int resubscriptionId,
198  const char *requestLabel,
199  int requestLabelLen,
201  void *userData);
202 
205  const blpapi_SubscriptionList_t *unsubscriptionList,
206  const char *requestLabel,
207  int requestLabelLen);
208 
211  const blpapi_CorrelationId_t *correlationIds,
212  size_t numCorrelationIds,
213  const char *requestLabel,
214  int requestLabelLen);
215 
218  const blpapi_Service_t *service,
219  const blpapi_Identity_t *identity,
220  const blpapi_CorrelationId_t *correlationId);
221 
224  const blpapi_Request_t *request,
225  blpapi_CorrelationId_t *correlationId,
226  blpapi_Identity_t *identity,
227  blpapi_EventQueue_t *eventQueue,
228  const char *requestLabel,
229  int requestLabelLen);
230 
233  const blpapi_RequestTemplate_t *requestTemplate,
234  blpapi_CorrelationId_t *correlationId);
235 
238  blpapi_RequestTemplate_t **requestTemplate,
239  blpapi_Session_t *session,
240  const char *subscriptionString,
241  const blpapi_Identity_t *identity,
242  blpapi_CorrelationId_t *correlationId);
243 
246  const blpapi_Request_t *request,
247  blpapi_Identity_t *identity,
248  blpapi_CorrelationId_t *correlationId,
249  blpapi_EventQueue_t *eventQueue,
250  const char *requestLabel,
251  int requestLabelLen);
252 
255  blpapi_Session_t *session, const char *serviceName);
256 
259  const char *serviceName,
260  blpapi_CorrelationId_t *correlationId);
261 
264  blpapi_CorrelationId_t *correlationId,
265  blpapi_EventQueue_t *eventQueue);
266 
269  blpapi_Service_t **service,
270  const char *serviceName);
271 
272 // Deprecated: Use blpapi_Session_createIdentity instead
275  blpapi_Session_t *session);
276 
279 
282  blpapi_Session_t *session);
283 
286  blpapi_Session_t *session);
287 
290 
293  const char **subscriptionString,
294  blpapi_CorrelationId_t *correlationId,
295  int *status);
296 
299  const blpapi_SubscriptionIterator_t *iterator);
300 
301 #ifdef __cplusplus
302 }
303 
304 #include <cassert>
305 
306 #ifndef INCLUDED_CSTRING
307 #include <cstring> // for std::memset
308 #define INCLUDED_CSTRING
309 #endif
310 
318 namespace BloombergLP {
319 namespace blpapi {
320 
321 class Session;
322 
335 
336  public:
337  virtual ~EventHandler() = 0;
338 
339  virtual bool processEvent(const Event& event, Session *session) = 0;
350 };
351 
352 extern "C" void blpapi_eventHandlerAdapter(
353  blpapi_Event_t *event, blpapi_Session_t *, void *userData);
361  enum Code {
365 
372  };
373 
375  std::string subscriptionString;
376  int code;
377  /*
378  * The error code that is one of <code>Code</code> enum values.
379  */
380  std::string description;
381 
383  const std::string& subscriptionString,
384  int code,
385  const char *description)
388  , code(code)
390  {
391  }
392 };
393 
394 inline std::ostream& operator<<(
395  std::ostream& os, const SubscriptionPreprocessError& error)
396 {
397  os << "{"
398  << "correlationId: " << error.correlationId
399  << ", subscriptionString: " << error.subscriptionString << ", code: ";
400  if (error.code
402  os << "InvalidSubscriptionString";
403  } else if (error.code
405  os << "CorrelationIdError";
406  } else {
407  os << "UNKNOWN";
408  }
409 
410  os << "(" << error.code << ")";
411  os << ", description: " << error.description << "}";
412 
413  return os;
414 }
415 
417  const blpapi_CorrelationId_t *correlationId,
418  const char *subscriptionString,
419  int errorCode,
420  const char *description,
421  void *userData)
422 {
423  typedef std::vector<SubscriptionPreprocessError> Errors;
424  Errors *errors = reinterpret_cast<Errors *>(userData);
425  errors->emplace_back(
426  *correlationId, subscriptionString, errorCode, description);
427 }
428 
434  enum Enum {
435 
442 
448  };
449 };
450 
451 typedef std::vector<SubscriptionPreprocessError> SubscriptionPreprocessErrors;
452 
500 class Session : public AbstractSession {
501 
502  public:
503  typedef ::BloombergLP::blpapi::EventHandler EventHandler;
504 
505  private:
506  blpapi_Session_t *d_handle_p;
507  EventHandler *d_eventHandler_p;
508 
509  // NOT IMPLEMENTED
510  Session(const Session&);
511  Session& operator=(const Session&);
512 
513  friend void blpapi_eventHandlerAdapter(
514  blpapi_Event_t *event, blpapi_Session_t *, void *userData);
515 
516  public:
517  /*
518  * The possible statuses a subscription may be in.
519  */
530  };
531 
532  Session(const SessionOptions& options = SessionOptions(),
533  EventHandler *eventHandler = 0,
534  EventDispatcher *eventDispatcher = 0);
568  explicit Session(blpapi_Session_t *handle);
569 
570  virtual ~Session();
575  virtual bool start();
586  virtual bool startAsync();
597  virtual void stop();
609  virtual void stopAsync();
621  virtual Event nextEvent(int timeout = 0);
637  virtual int tryNextEvent(Event *event);
645  virtual void subscribe(const SubscriptionList& subscriptionList,
646  const Identity& identity,
647  const char *requestLabel = 0,
648  int requestLabelLen = 0);
663  const SubscriptionList& subscriptionList,
664  const Identity& identity,
666  const char *requestLabel = 0,
667  int requestLabelLen = 0);
687  virtual void subscribe(const SubscriptionList& subscriptionList,
688  const char *requestLabel = 0,
689  int requestLabelLen = 0);
706  const SubscriptionList& subscriptionList,
708  const char *requestLabel = 0,
709  int requestLabelLen = 0);
730  virtual void unsubscribe(const SubscriptionList& subscriptionList);
751  virtual void resubscribe(const SubscriptionList& subscriptions);
766  const SubscriptionList& subscriptions,
783  virtual void resubscribe(const SubscriptionList& subscriptions,
784  const char *requestLabel,
785  int requestLabelLen);
804  const SubscriptionList& subscriptions,
805  const char *requestLabel,
806  int requestLabelLen,
827  virtual void resubscribe(
828  const SubscriptionList& subscriptions, int resubscriptionId);
844  const SubscriptionList& subscriptions,
845  int resubscriptionId,
863  virtual void resubscribe(const SubscriptionList& subscriptions,
864  int resubscriptionId,
865  const char *requestLabel,
866  int requestLabelLen);
886  const SubscriptionList& subscriptions,
887  int resubscriptionId,
888  const char *requestLabel,
889  int requestLabelLen,
911  virtual void setStatusCorrelationId(
912  const Service& service, const CorrelationId& correlationID);
913 
914  virtual void setStatusCorrelationId(const Service& service,
915  const Identity& identity,
916  const CorrelationId& correlationID);
922  virtual CorrelationId sendRequest(const Request& request,
923  const CorrelationId& correlationId = CorrelationId(),
924  EventQueue *eventQueue = 0,
925  const char *requestLabel = 0,
926  int requestLabelLen = 0);
948  virtual CorrelationId sendRequest(const Request& request,
949  const Identity& user,
950  const CorrelationId& correlationId = CorrelationId(),
951  EventQueue *eventQueue = 0,
952  const char *requestLabel = 0,
953  int requestLabelLen = 0);
974  virtual CorrelationId sendRequest(const RequestTemplate& requestTemplate,
975  const CorrelationId& correlationId = CorrelationId());
994  const char *subscriptionString,
995  const CorrelationId& statusCid,
996  const Identity& identity = Identity());
1072  blpapi_Session_t *handle() const;
1073 };
1074 
1090 
1091  blpapi_SubscriptionIterator_t *d_handle_p;
1092  const char *d_subscriptionString;
1093  CorrelationId d_correlationId;
1094  int d_status;
1095  bool d_isValid;
1096 
1097  private:
1098  // NOT IMPLEMENTED
1100  SubscriptionIterator& operator=(const SubscriptionIterator&);
1101 
1102  public:
1103  SubscriptionIterator(Session *session);
1115  // MANIPULATORS
1116 
1117  bool next();
1126  // ACCESSORS
1127 
1128  bool isValid() const;
1134  const char *subscriptionString() const;
1142  const CorrelationId& correlationId() const;
1153 };
1154 
1158 // ============================================================================
1159 // INLINE FUNCTION DEFINITIONS
1160 // ============================================================================
1161 
1162 // ------------------
1163 // class EventHandler
1164 // ------------------
1165 
1167 
1168 // FREE FUNCTIONS
1169 extern "C" inline void blpapi_eventHandlerAdapter(
1170  blpapi_Event_t *event, blpapi_Session_t *, void *userData)
1171 {
1172  Session *session = reinterpret_cast<Session *>(userData);
1173  assert(session);
1174  assert(session->d_eventHandler_p);
1175  session->d_eventHandler_p->processEvent(Event(event), session);
1176 }
1177 
1178 // -------------
1179 // class Session
1180 // -------------
1181 
1182 inline Session::Session(const SessionOptions& parameters,
1183  EventHandler *handler,
1184  EventDispatcher *dispatcher)
1185  : d_eventHandler_p(handler)
1186 {
1187  if (dispatcher && !handler) {
1189  "Event dispatcher provided without handler.");
1190  }
1191  d_handle_p = blpapi_Session_create(parameters.handle(),
1192  handler ? &blpapi_eventHandlerAdapter : 0,
1193  dispatcher ? dispatcher->impl() : 0,
1194  this);
1195  initAbstractSessionHandle(blpapi_Session_getAbstractSession(d_handle_p));
1196 }
1197 
1198 inline Session::Session(blpapi_Session_t *newHandle)
1199  : d_handle_p(newHandle)
1200 {
1201  initAbstractSessionHandle(blpapi_Session_getAbstractSession(d_handle_p));
1202 }
1203 
1205 
1206 inline bool Session::start()
1207 {
1208  return blpapi_Session_start(d_handle_p) ? false : true;
1209 }
1210 
1211 inline bool Session::startAsync()
1212 {
1213  return blpapi_Session_startAsync(d_handle_p) ? false : true;
1214 }
1215 
1216 inline void Session::stop() { blpapi_Session_stop(d_handle_p); }
1217 
1218 inline void Session::stopAsync() { blpapi_Session_stopAsync(d_handle_p); }
1219 
1220 inline Event Session::nextEvent(int timeout)
1221 {
1222  if (timeout < 0) {
1223  throw InvalidArgumentException("Timeout must be >= 0.");
1224  }
1225 
1226  blpapi_Event_t *event = 0;
1228  d_handle_p, &event, static_cast<unsigned>(timeout)));
1229  return Event(event);
1230 }
1231 
1232 inline int Session::tryNextEvent(Event *event)
1233 {
1234  blpapi_Event_t *impl = 0;
1235  int ret = blpapi_Session_tryNextEvent(d_handle_p, &impl);
1236  if (0 == ret) {
1237  assert(event);
1238 
1239  *event = Event(impl);
1240  }
1241  return ret;
1242 }
1243 
1244 inline void Session::subscribe(const SubscriptionList& subscriptions,
1245  const char *requestLabel,
1246  int requestLabelLen)
1247 {
1249  subscriptions.impl(),
1250  0, // identityHandle
1251  requestLabel,
1252  requestLabelLen));
1253 }
1254 
1256  const SubscriptionList& subscriptions,
1258  const char *requestLabel,
1259  int requestLabelLen)
1260 {
1263  subscribe(subscriptions, requestLabel, requestLabelLen);
1264  } else {
1267  subscriptions.impl(),
1268  0, // identityHandle
1269  requestLabel,
1270  requestLabelLen,
1272  &errors));
1273  }
1274 
1275  return errors;
1276 }
1277 
1278 inline void Session::subscribe(const SubscriptionList& subscriptions,
1279  const Identity& identity,
1280  const char *requestLabel,
1281  int requestLabelLen)
1282 {
1284  subscriptions.impl(),
1285  identity.handle(),
1286  requestLabel,
1287  requestLabelLen));
1288 }
1289 
1291  const SubscriptionList& subscriptions,
1292  const Identity& identity,
1294  const char *requestLabel,
1295  int requestLabelLen)
1296 {
1299  subscribe(subscriptions, identity, requestLabel, requestLabelLen);
1300  } else {
1303  subscriptions.impl(),
1304  identity.handle(),
1305  requestLabel,
1306  requestLabelLen,
1308  &errors));
1309  }
1310 
1311  return errors;
1312 }
1313 
1314 inline void Session::resubscribe(const SubscriptionList& subscriptions)
1315 {
1317  subscriptions.impl(),
1318  0, // requestLabel
1319  0)); // requestLabelLen
1320 }
1321 
1323  const SubscriptionList& subscriptions,
1325 {
1328  resubscribe(subscriptions);
1329  } else {
1332  subscriptions.impl(),
1333  0, // requestLabel
1334  0, // requestLabelLen
1336  &errors));
1337  }
1338 
1339  return errors;
1340 }
1341 
1342 inline void Session::resubscribe(const SubscriptionList& subscriptions,
1343  const char *requestLabel,
1344  int requestLabelLen)
1345 {
1347  d_handle_p, subscriptions.impl(), requestLabel, requestLabelLen));
1348 }
1349 
1351  const SubscriptionList& subscriptions,
1352  const char *requestLabel,
1353  int requestLabelLen,
1355 {
1358  resubscribe(subscriptions, requestLabel, requestLabelLen);
1359  } else {
1362  subscriptions.impl(),
1363  requestLabel,
1364  requestLabelLen,
1366  &errors));
1367  }
1368 
1369  return errors;
1370 }
1371 
1373  const SubscriptionList& subscriptions, int resubscriptionId)
1374 {
1377  subscriptions.impl(),
1378  resubscriptionId,
1379  0, // requestLabel
1380  0)); // requestLabelLen
1381 }
1382 
1384  const SubscriptionList& subscriptions,
1385  int resubscriptionId,
1387 {
1390  resubscribe(subscriptions, resubscriptionId);
1391  } else {
1394  subscriptions.impl(),
1395  resubscriptionId,
1396  0, // requestLabel
1397  0, // requestLabelLen
1399  &errors));
1400  }
1401 
1402  return errors;
1403 }
1404 
1405 inline void Session::resubscribe(const SubscriptionList& subscriptions,
1406  int resubscriptionId,
1407  const char *requestLabel,
1408  int requestLabelLen)
1409 {
1412  subscriptions.impl(),
1413  resubscriptionId,
1414  requestLabel,
1415  requestLabelLen));
1416 }
1417 
1419  const SubscriptionList& subscriptions,
1420  int resubscriptionId,
1421  const char *requestLabel,
1422  int requestLabelLen,
1424 {
1427  resubscribe(subscriptions,
1428  resubscriptionId,
1429  requestLabel,
1430  requestLabelLen);
1431  } else {
1434  subscriptions.impl(),
1435  resubscriptionId,
1436  requestLabel,
1437  requestLabelLen,
1439  &errors));
1440  }
1441 
1442  return errors;
1443 }
1444 
1445 inline void Session::unsubscribe(const SubscriptionList& list)
1446 {
1448  blpapi_Session_unsubscribe(d_handle_p, list.impl(), 0, 0));
1449 }
1450 
1452  const Service& service, const CorrelationId& correlationID)
1453 {
1455  d_handle_p, service.handle(), 0, &correlationID.impl()));
1456 }
1457 
1458 inline void Session::setStatusCorrelationId(const Service& service,
1459  const Identity& identity,
1460  const CorrelationId& correlationID)
1461 {
1464  service.handle(),
1465  identity.handle(),
1466  &correlationID.impl()));
1467 }
1468 
1470  const Identity& identity,
1471  const CorrelationId& correlationId,
1472  EventQueue *eventQueue,
1473  const char *requestLabel,
1474  int requestLabelLen)
1475 {
1476  CorrelationId retCorrelationId(correlationId);
1477 
1479  request.handle(),
1480  &retCorrelationId.impl(),
1481  identity.handle(),
1482  eventQueue ? eventQueue->handle() : 0,
1483  requestLabel,
1484  requestLabelLen));
1485 
1486  return retCorrelationId;
1487 }
1488 
1490  const CorrelationId& correlationId,
1491  EventQueue *eventQueue,
1492  const char *requestLabel,
1493  int requestLabelLen)
1494 {
1495  CorrelationId retCorrelationId(correlationId);
1496 
1498  request.handle(),
1499  &retCorrelationId.impl(),
1500  0,
1501  eventQueue ? eventQueue->handle() : 0,
1502  requestLabel,
1503  requestLabelLen));
1504 
1505  return retCorrelationId;
1506 }
1507 
1509  const RequestTemplate& requestTemplate,
1510  const CorrelationId& correlationId)
1511 {
1512  CorrelationId retCorrelationId(correlationId);
1513 
1516  d_handle_p, requestTemplate.impl(), &retCorrelationId.impl()));
1517 
1518  return retCorrelationId;
1519 }
1520 
1522  const char *subscriptionString,
1523  const CorrelationId& correlationID,
1524  const Identity& identity)
1525 {
1526  blpapi_RequestTemplate_t *requestTemplate = 0;
1527 
1530  d_handle_p,
1531  subscriptionString,
1532  identity.handle(),
1533  const_cast<blpapi_CorrelationId_t *>(&correlationID.impl())));
1534 
1535  return RequestTemplate(requestTemplate);
1536 }
1537 
1538 inline blpapi_Session_t *Session::handle() const { return d_handle_p; }
1539 
1540 // --------------------------
1541 // class SubscriptionIterator
1542 // --------------------------
1543 
1544 inline SubscriptionIterator::SubscriptionIterator(Session *session)
1545  : d_isValid(false)
1546 {
1547  assert(session);
1548 
1549  d_handle_p = blpapi_SubscriptionItr_create(session->handle());
1550 }
1551 
1553 {
1554  blpapi_SubscriptionItr_destroy(d_handle_p);
1555 }
1556 
1558 {
1559  blpapi_CorrelationId_t nextCorrelationIdImpl;
1560  d_isValid = !blpapi_SubscriptionItr_next(d_handle_p,
1561  &d_subscriptionString,
1562  &nextCorrelationIdImpl,
1563  &d_status);
1564 
1565  d_correlationId = d_isValid ? CorrelationId(nextCorrelationIdImpl)
1566  : CorrelationId();
1567 
1568  return d_isValid;
1569 }
1570 
1571 inline bool SubscriptionIterator::isValid() const { return d_isValid; }
1572 
1574 {
1575  return d_handle_p;
1576 }
1577 
1579 {
1580  if (!isValid()) {
1582  }
1583 
1584  return d_subscriptionString;
1585 }
1586 
1588 {
1589  if (!isValid()) {
1591  }
1592 
1593  return d_correlationId;
1594 }
1595 
1598 {
1599  if (!isValid()) {
1601  }
1602 
1603  return static_cast<Session::SubscriptionStatus>(d_status);
1604 }
1605 
1606 } // close namespace blpapi
1607 } // close namespace BloombergLP
1608 
1609 #endif // ifdef __cplusplus
1610 
1611 #endif // INCLUDED_BLPAPI_SESSION
struct blpapi_SubscriptionList blpapi_SubscriptionList_t
Definition: blpapi_subscriptionlist.h:224
struct blpapi_Identity blpapi_UserHandle_t
Definition: blpapi_types.h:185
#define BLPAPI_SUBSCRIPTIONSTATUS_UNSUBSCRIBED
Definition: blpapi_defs.h:103
int blpapi_Session_resubscribeWithIdEx(blpapi_Session_t *session, const blpapi_SubscriptionList_t *resubscriptionList, int resubscriptionId, const char *requestLabel, int requestLabelLen, blpapi_SubscriptionPreprocessErrorHandler_t errorHandler, void *userData)
#define BLPAPI_SUBSCRIPTIONPREPROCESS_CORRELATIONID_ERROR
Definition: blpapi_defs.h:161
bool isValid() const
Definition: blpapi_session.h:1571
blpapi_Identity_t * blpapi_Session_createIdentity(blpapi_Session_t *session)
virtual void subscribe(const SubscriptionList &subscriptionList, const Identity &identity, const char *requestLabel=0, int requestLabelLen=0)
Definition: blpapi_session.h:1278
blpapi_Request_t * handle() const
Definition: blpapi_request.h:712
int blpapi_Session_resubscribe(blpapi_Session_t *session, const blpapi_SubscriptionList_t *resubscriptionList, const char *requestLabel, int requestLabelLen)
struct blpapi_Request blpapi_Request_t
Definition: blpapi_request.h:67
Enum
Definition: blpapi_session.h:434
SubscriptionPreprocessError(const CorrelationId &correlationId, const std::string &subscriptionString, int code, const char *description)
Definition: blpapi_session.h:382
const char * subscriptionString() const
Definition: blpapi_session.h:1578
Common definitions used by the library.
No longer active, terminated by API.
Definition: blpapi_session.h:521
#define BLPAPI_SUBSCRIPTIONSTATUS_SUBSCRIBING
Definition: blpapi_defs.h:104
struct blpapi_Event blpapi_Event_t
Definition: blpapi_types.h:139
blpapi_EventQueue_t * handle() const
Definition: blpapi_event.h:583
Definition: blpapi_session.h:1089
#define BLPAPI_SUBSCRIPTIONSTATUS_CANCELLED
Definition: blpapi_defs.h:106
Updates are flowing.
Definition: blpapi_session.h:525
Definition: blpapi_abstractsession.h:220
virtual void stop()
Definition: blpapi_session.h:1216
#define BLPAPI_CALL(FUNCNAME)
Definition: blpapi_call.h:353
Definition: blpapi_service.h:304
int blpapi_Session_startAsync(blpapi_Session_t *session)
Initiated but no updates received.
Definition: blpapi_session.h:523
blpapi_SessionOptions_t * handle() const
Definition: blpapi_sessionoptions.h:1398
virtual bool start()
Definition: blpapi_session.h:1206
#define BLPAPI_SUBSCRIPTIONPREPROCESS_INVALID_SUBSCRIPTION_STRING
Definition: blpapi_defs.h:160
void blpapi_SubscriptionPreprocess_handleError(const blpapi_CorrelationId_t *correlationId, const char *subscriptionString, int errorCode, const char *description, void *userData)
Definition: blpapi_session.h:416
::BloombergLP::blpapi::EventHandler EventHandler
Definition: blpapi_session.h:503
Definition: blpapi_abstractsession.h:286
int blpapi_Session_stopAsync(blpapi_Session_t *session)
#define BLPAPI_ERROR_ILLEGAL_STATE
Definition: blpapi_error.h:74
int blpapi_Session_nextEvent(blpapi_Session_t *session, blpapi_Event_t **eventPointer, unsigned int timeoutInMilliseconds)
int blpapi_Session_openServiceAsync(blpapi_Session_t *session, const char *serviceName, blpapi_CorrelationId_t *correlationId)
blpapi_Service_t * handle() const
Definition: blpapi_service.h:706
blpapi_AbstractSession_t * blpapi_Session_getAbstractSession(blpapi_Session_t *session)
Definition: blpapi_event.h:386
Definition: blpapi_requesttemplate.h:131
virtual ~EventHandler()=0
Definition: blpapi_session.h:1166
CorrelationId correlationId
Definition: blpapi_session.h:374
int blpapi_Session_sendRequestTemplate(blpapi_Session_t *session, const blpapi_RequestTemplate_t *requestTemplate, blpapi_CorrelationId_t *correlationId)
int blpapi_SubscriptionItr_isValid(const blpapi_SubscriptionIterator_t *iterator)
Provide access to the entitlements for a user.
void blpapi_SubscriptionItr_destroy(blpapi_SubscriptionIterator_t *iterator)
A service which provides access to API data (provide or consume).
int blpapi_Session_openService(blpapi_Session_t *session, const char *serviceName)
A component which defines events related operations.
int blpapi_Session_createSnapshotRequestTemplate(blpapi_RequestTemplate_t **requestTemplate, blpapi_Session_t *session, const char *subscriptionString, const blpapi_Identity_t *identity, blpapi_CorrelationId_t *correlationId)
void blpapi_Session_destroy(blpapi_Session_t *session)
Provide a key to identify individual subscriptions or requests.
struct blpapi_EventQueue blpapi_EventQueue_t
Definition: blpapi_types.h:148
Definition: blpapi_request.h:145
static void throwOnError(int errorCode)
Definition: blpapi_exception.h:526
#define BLPAPI_SUBSCRIPTIONSTATUS_PENDING_CANCELLATION
Definition: blpapi_defs.h:107
int blpapi_Session_unsubscribe(blpapi_Session_t *session, const blpapi_SubscriptionList_t *unsubscriptionList, const char *requestLabel, int requestLabelLen)
const blpapi_RequestTemplate_t * impl() const
Definition: blpapi_requesttemplate.h:224
blpapi_SubscriptionIterator_t * blpapi_SubscriptionItr_create(blpapi_Session_t *session)
Defines a request which can be sent for a service.
Definition: blpapi_session.h:429
Definition: blpapi_session.h:500
std::string subscriptionString
Definition: blpapi_session.h:375
int blpapi_Session_subscribeEx(blpapi_Session_t *session, const blpapi_SubscriptionList_t *subscriptionList, const blpapi_Identity_t *handle, const char *requestLabel, int requestLabelLen, blpapi_SubscriptionPreprocessErrorHandler_t errorHandler, void *userData)
struct blpapi_Identity blpapi_Identity_t
Definition: blpapi_types.h:188
struct blpapi_EventDispatcher blpapi_EventDispatcher_t
Definition: blpapi_types.h:142
Definition: blpapi_session.h:360
blpapi_Session_t * handle() const
Definition: blpapi_session.h:1538
virtual ~Session()
Definition: blpapi_session.h:1204
#define BLPAPI_CALL_SESSION_RESUBSCRIBEWITHID(a1, a2, a3, a4, a5)
Definition: blpapi_call.h:406
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition: blpapi_correlationid.h:592
Definition: blpapi_correlationid.h:201
Definition: blpapi_subscriptionlist.h:314
Definition: blpapi_eventdispatcher.h:116
virtual bool startAsync()
Definition: blpapi_session.h:1211
Provide a dispatcher to dispatch events.
friend void blpapi_eventHandlerAdapter(blpapi_Event_t *event, blpapi_Session_t *, void *userData)
Definition: blpapi_session.h:1169
~SubscriptionIterator()
Definition: blpapi_session.h:1552
virtual void resubscribe(const SubscriptionList &subscriptions)
Definition: blpapi_session.h:1314
void(* blpapi_SubscriptionPreprocessErrorHandler_t)(const blpapi_CorrelationId_t *correlationId, const char *subscriptionString, int errorCode, const char *errorDescription, void *userData)
Definition: blpapi_session.h:120
virtual RequestTemplate createSnapshotRequestTemplate(const char *subscriptionString, const CorrelationId &statusCid, const Identity &identity=Identity())
Definition: blpapi_session.h:1521
Definition: blpapi_identity.h:131
int blpapi_Session_getService(blpapi_Session_t *session, blpapi_Service_t **service, const char *serviceName)
int blpapi_Session_setStatusCorrelationId(blpapi_Session_t *session, const blpapi_Service_t *service, const blpapi_Identity_t *identity, const blpapi_CorrelationId_t *correlationId)
void(* blpapi_EventHandler_t)(blpapi_Event_t *event, blpapi_Session_t *session, void *userData)
Definition: blpapi_session.h:117
const CorrelationId & correlationId() const
Definition: blpapi_session.h:1587
struct blpapi_RequestTemplate blpapi_RequestTemplate_t
Definition: blpapi_types.h:163
virtual int tryNextEvent(Event *event)
Definition: blpapi_session.h:1232
int blpapi_Session_cancel(blpapi_Session_t *session, const blpapi_CorrelationId_t *correlationIds, size_t numCorrelationIds, const char *requestLabel, int requestLabelLen)
int blpapi_Session_stop(blpapi_Session_t *session)
SubscriptionStatus
Definition: blpapi_session.h:520
struct blpapi_SubscriptionItrerator blpapi_SubscriptionIterator_t
Definition: blpapi_types.h:181
int code
Definition: blpapi_session.h:376
blpapi_Session_t * blpapi_Session_create(blpapi_SessionOptions_t *parameters, blpapi_EventHandler_t handler, blpapi_EventDispatcher_t *dispatcher, void *userData)
Definition: blpapi_event.h:196
blpapi_SubscriptionIterator_t * handle() const
Definition: blpapi_session.h:1573
int blpapi_Session_tryNextEvent(blpapi_Session_t *session, blpapi_Event_t **eventPointer)
No longer active, terminated by Application.
Definition: blpapi_session.h:527
Definition: blpapi_session.h:334
struct blpapi_AbstractSession blpapi_AbstractSession_t
Definition: blpapi_types.h:127
struct blpapi_Session blpapi_Session_t
Definition: blpapi_types.h:169
virtual void stopAsync()
Definition: blpapi_session.h:1218
int blpapi_Session_resubscribeWithId(blpapi_Session_t *session, const blpapi_SubscriptionList_t *resubscriptionList, int resubscriptionId, const char *requestLabel, int requestLabelLen)
int blpapi_Session_start(blpapi_Session_t *session)
virtual void unsubscribe(const SubscriptionList &subscriptionList)
Definition: blpapi_session.h:1445
virtual void setStatusCorrelationId(const Service &service, const CorrelationId &correlationID)
Definition: blpapi_session.h:1451
bool next()
Definition: blpapi_session.h:1557
Code
Definition: blpapi_session.h:361
A common interface shared between publish and consumer sessions.
Invalid subscription string.
Definition: blpapi_session.h:362
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
struct blpapi_Service blpapi_Service_t
Definition: blpapi_types.h:166
int blpapi_Session_resubscribeEx(blpapi_Session_t *session, const blpapi_SubscriptionList_t *resubscriptionList, const char *requestLabel, int requestLabelLen, blpapi_SubscriptionPreprocessErrorHandler_t errorHandler, void *userData)
struct blpapi_SessionOptions blpapi_SessionOptions_t
Definition: blpapi_types.h:172
Provide functions for dispatchtbl.
virtual CorrelationId sendRequest(const Request &request, const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0, const char *requestLabel=0, int requestLabelLen=0)
Definition: blpapi_session.h:1489
Provide a list of subscriptions.
int blpapi_Session_sendRequest(blpapi_Session_t *session, const blpapi_Request_t *request, blpapi_CorrelationId_t *correlationId, blpapi_Identity_t *identity, blpapi_EventQueue_t *eventQueue, const char *requestLabel, int requestLabelLen)
Provide BLPAPI types.
Definition: blpapi_exception.h:238
Provide a handle for a request template.
int blpapi_Session_generateToken(blpapi_Session_t *session, blpapi_CorrelationId_t *correlationId, blpapi_EventQueue_t *eventQueue)
blpapi_Identity_t * handle() const
Definition: blpapi_identity.h:381
void blpapi_eventHandlerAdapter(blpapi_Event_t *event, blpapi_Session_t *, void *userData)
Definition: blpapi_session.h:1169
Definition: blpapi_sessionoptions.h:431
blpapi_EventDispatcher_t * impl() const
Definition: blpapi_eventdispatcher.h:198
int blpapi_Session_sendAuthorizationRequest(blpapi_Session_t *session, const blpapi_Request_t *request, blpapi_Identity_t *identity, blpapi_CorrelationId_t *correlationId, blpapi_EventQueue_t *eventQueue, const char *requestLabel, int requestLabelLen)
int blpapi_SubscriptionItr_next(blpapi_SubscriptionIterator_t *iterator, const char **subscriptionString, blpapi_CorrelationId_t *correlationId, int *status)
Session::SubscriptionStatus subscriptionStatus() const
Definition: blpapi_session.h:1597
virtual Event nextEvent(int timeout=0)
Definition: blpapi_session.h:1220
#define BLPAPI_SUBSCRIPTIONSTATUS_SUBSCRIBED
Definition: blpapi_defs.h:105
std::vector< SubscriptionPreprocessError > SubscriptionPreprocessErrors
Definition: blpapi_session.h:451
A common interface shared between publisher and consumer sessions.
blpapi_UserHandle_t * blpapi_Session_createUserHandle(blpapi_Session_t *session)
std::string description
Definition: blpapi_session.h:380
int blpapi_Session_subscribe(blpapi_Session_t *session, const blpapi_SubscriptionList_t *subscriptionList, const blpapi_Identity_t *handle, const char *requestLabel, int requestLabelLen)
virtual bool processEvent(const Event &event, Session *session)=0