BLPAPI C++  3.24.11
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(CorrelationId(*correlationId),
426  subscriptionString,
427  errorCode,
428  description);
429 }
430 
436  enum Enum {
437 
444 
450  };
451 };
452 
453 typedef std::vector<SubscriptionPreprocessError> SubscriptionPreprocessErrors;
454 
502 class Session : public AbstractSession {
503 
504  public:
505  typedef ::BloombergLP::blpapi::EventHandler EventHandler;
506 
507  private:
508  blpapi_Session_t *d_handle_p;
509  EventHandler *d_eventHandler_p;
510 
511  // NOT IMPLEMENTED
512  Session(const Session&);
513  Session& operator=(const Session&);
514 
515  friend void blpapi_eventHandlerAdapter(
516  blpapi_Event_t *event, blpapi_Session_t *, void *userData);
517 
518  public:
519  /*
520  * The possible statuses a subscription may be in.
521  */
532  };
533 
534  explicit Session(const SessionOptions& options = SessionOptions(),
535  EventHandler *eventHandler = 0,
536  EventDispatcher *eventDispatcher = 0);
570  explicit Session(blpapi_Session_t *handle);
571 
572  virtual ~Session();
577  virtual bool start();
588  virtual bool startAsync();
599  virtual void stop();
611  virtual void stopAsync();
623  virtual Event nextEvent(int timeout = 0);
639  virtual int tryNextEvent(Event *event);
647  virtual void subscribe(const SubscriptionList& subscriptionList,
648  const Identity& identity,
649  const char *requestLabel = 0,
650  int requestLabelLen = 0);
665  const SubscriptionList& subscriptionList,
666  const Identity& identity,
668  const char *requestLabel = 0,
669  int requestLabelLen = 0);
689  virtual void subscribe(const SubscriptionList& subscriptionList,
690  const char *requestLabel = 0,
691  int requestLabelLen = 0);
708  const SubscriptionList& subscriptionList,
710  const char *requestLabel = 0,
711  int requestLabelLen = 0);
732  virtual void unsubscribe(const SubscriptionList& subscriptionList);
753  virtual void resubscribe(const SubscriptionList& subscriptions);
768  const SubscriptionList& subscriptions,
785  virtual void resubscribe(const SubscriptionList& subscriptions,
786  const char *requestLabel,
787  int requestLabelLen);
806  const SubscriptionList& subscriptions,
807  const char *requestLabel,
808  int requestLabelLen,
829  virtual void resubscribe(
830  const SubscriptionList& subscriptions, int resubscriptionId);
846  const SubscriptionList& subscriptions,
847  int resubscriptionId,
865  virtual void resubscribe(const SubscriptionList& subscriptions,
866  int resubscriptionId,
867  const char *requestLabel,
868  int requestLabelLen);
888  const SubscriptionList& subscriptions,
889  int resubscriptionId,
890  const char *requestLabel,
891  int requestLabelLen,
913  virtual void setStatusCorrelationId(
914  const Service& service, const CorrelationId& correlationID);
915 
916  virtual void setStatusCorrelationId(const Service& service,
917  const Identity& identity,
918  const CorrelationId& correlationID);
924  virtual CorrelationId sendRequest(const Request& request,
925  const CorrelationId& correlationId = CorrelationId(),
926  EventQueue *eventQueue = 0,
927  const char *requestLabel = 0,
928  int requestLabelLen = 0);
950  virtual CorrelationId sendRequest(const Request& request,
951  const Identity& user,
952  const CorrelationId& correlationId = CorrelationId(),
953  EventQueue *eventQueue = 0,
954  const char *requestLabel = 0,
955  int requestLabelLen = 0);
976  virtual CorrelationId sendRequest(const RequestTemplate& requestTemplate,
977  const CorrelationId& correlationId = CorrelationId());
996  const char *subscriptionString,
997  const CorrelationId& statusCid,
998  const Identity& identity = Identity());
1074  blpapi_Session_t *handle() const;
1075 };
1076 
1092 
1093  blpapi_SubscriptionIterator_t *d_handle_p;
1094  const char *d_subscriptionString;
1095  CorrelationId d_correlationId;
1096  int d_status;
1097  bool d_isValid;
1098 
1099  private:
1100  // NOT IMPLEMENTED
1102  SubscriptionIterator& operator=(const SubscriptionIterator&);
1103 
1104  public:
1105  explicit SubscriptionIterator(Session *session);
1117  // MANIPULATORS
1118 
1119  bool next();
1128  // ACCESSORS
1129 
1130  bool isValid() const;
1136  const char *subscriptionString() const;
1144  const CorrelationId& correlationId() const;
1155 };
1156 
1160 // ============================================================================
1161 // INLINE FUNCTION DEFINITIONS
1162 // ============================================================================
1163 
1164 // ------------------
1165 // class EventHandler
1166 // ------------------
1167 
1169 
1170 // FREE FUNCTIONS
1171 extern "C" inline void blpapi_eventHandlerAdapter(
1172  blpapi_Event_t *event, blpapi_Session_t *, void *userData)
1173 {
1174  Session *session = reinterpret_cast<Session *>(userData);
1175  assert(session);
1176  assert(session->d_eventHandler_p);
1177  session->d_eventHandler_p->processEvent(Event(event), session);
1178 }
1179 
1180 // -------------
1181 // class Session
1182 // -------------
1183 
1184 inline Session::Session(const SessionOptions& parameters,
1185  EventHandler *handler,
1186  EventDispatcher *dispatcher)
1187  : d_eventHandler_p(handler)
1188 {
1189  if (dispatcher && !handler) {
1191  "Event dispatcher provided without handler.");
1192  }
1193  d_handle_p = blpapi_Session_create(parameters.handle(),
1194  handler ? &blpapi_eventHandlerAdapter : 0,
1195  dispatcher ? dispatcher->impl() : 0,
1196  this);
1197  initAbstractSessionHandle(blpapi_Session_getAbstractSession(d_handle_p));
1198 }
1199 
1200 inline Session::Session(blpapi_Session_t *newHandle)
1201  : d_handle_p(newHandle)
1202 {
1203  initAbstractSessionHandle(blpapi_Session_getAbstractSession(d_handle_p));
1204 }
1205 
1207 
1208 inline bool Session::start()
1209 {
1210  return blpapi_Session_start(d_handle_p) ? false : true;
1211 }
1212 
1213 inline bool Session::startAsync()
1214 {
1215  return blpapi_Session_startAsync(d_handle_p) ? false : true;
1216 }
1217 
1218 inline void Session::stop() { blpapi_Session_stop(d_handle_p); }
1219 
1220 inline void Session::stopAsync() { blpapi_Session_stopAsync(d_handle_p); }
1221 
1222 inline Event Session::nextEvent(int timeout)
1223 {
1224  if (timeout < 0) {
1225  throw InvalidArgumentException("Timeout must be >= 0.");
1226  }
1227 
1228  blpapi_Event_t *event = 0;
1230  d_handle_p, &event, static_cast<unsigned>(timeout)));
1231  return Event(event);
1232 }
1233 
1234 inline int Session::tryNextEvent(Event *event)
1235 {
1236  blpapi_Event_t *impl = 0;
1237  int ret = blpapi_Session_tryNextEvent(d_handle_p, &impl);
1238  if (0 == ret) {
1239  assert(event);
1240 
1241  *event = Event(impl);
1242  }
1243  return ret;
1244 }
1245 
1246 inline void Session::subscribe(const SubscriptionList& subscriptions,
1247  const char *requestLabel,
1248  int requestLabelLen)
1249 {
1251  subscriptions.impl(),
1252  0, // identityHandle
1253  requestLabel,
1254  requestLabelLen));
1255 }
1256 
1258  const SubscriptionList& subscriptions,
1260  const char *requestLabel,
1261  int requestLabelLen)
1262 {
1265  subscribe(subscriptions, requestLabel, requestLabelLen);
1266  } else {
1269  subscriptions.impl(),
1270  0, // identityHandle
1271  requestLabel,
1272  requestLabelLen,
1274  &errors));
1275  }
1276 
1277  return errors;
1278 }
1279 
1280 inline void Session::subscribe(const SubscriptionList& subscriptions,
1281  const Identity& identity,
1282  const char *requestLabel,
1283  int requestLabelLen)
1284 {
1286  subscriptions.impl(),
1287  identity.handle(),
1288  requestLabel,
1289  requestLabelLen));
1290 }
1291 
1293  const SubscriptionList& subscriptions,
1294  const Identity& identity,
1296  const char *requestLabel,
1297  int requestLabelLen)
1298 {
1301  subscribe(subscriptions, identity, requestLabel, requestLabelLen);
1302  } else {
1305  subscriptions.impl(),
1306  identity.handle(),
1307  requestLabel,
1308  requestLabelLen,
1310  &errors));
1311  }
1312 
1313  return errors;
1314 }
1315 
1316 inline void Session::resubscribe(const SubscriptionList& subscriptions)
1317 {
1319  subscriptions.impl(),
1320  0, // requestLabel
1321  0)); // requestLabelLen
1322 }
1323 
1325  const SubscriptionList& subscriptions,
1327 {
1330  resubscribe(subscriptions);
1331  } else {
1334  subscriptions.impl(),
1335  0, // requestLabel
1336  0, // requestLabelLen
1338  &errors));
1339  }
1340 
1341  return errors;
1342 }
1343 
1344 inline void Session::resubscribe(const SubscriptionList& subscriptions,
1345  const char *requestLabel,
1346  int requestLabelLen)
1347 {
1349  d_handle_p, subscriptions.impl(), requestLabel, requestLabelLen));
1350 }
1351 
1353  const SubscriptionList& subscriptions,
1354  const char *requestLabel,
1355  int requestLabelLen,
1357 {
1360  resubscribe(subscriptions, requestLabel, requestLabelLen);
1361  } else {
1364  subscriptions.impl(),
1365  requestLabel,
1366  requestLabelLen,
1368  &errors));
1369  }
1370 
1371  return errors;
1372 }
1373 
1375  const SubscriptionList& subscriptions, int resubscriptionId)
1376 {
1379  subscriptions.impl(),
1380  resubscriptionId,
1381  0, // requestLabel
1382  0)); // requestLabelLen
1383 }
1384 
1386  const SubscriptionList& subscriptions,
1387  int resubscriptionId,
1389 {
1392  resubscribe(subscriptions, resubscriptionId);
1393  } else {
1396  subscriptions.impl(),
1397  resubscriptionId,
1398  0, // requestLabel
1399  0, // requestLabelLen
1401  &errors));
1402  }
1403 
1404  return errors;
1405 }
1406 
1407 inline void Session::resubscribe(const SubscriptionList& subscriptions,
1408  int resubscriptionId,
1409  const char *requestLabel,
1410  int requestLabelLen)
1411 {
1414  subscriptions.impl(),
1415  resubscriptionId,
1416  requestLabel,
1417  requestLabelLen));
1418 }
1419 
1421  const SubscriptionList& subscriptions,
1422  int resubscriptionId,
1423  const char *requestLabel,
1424  int requestLabelLen,
1426 {
1429  resubscribe(subscriptions,
1430  resubscriptionId,
1431  requestLabel,
1432  requestLabelLen);
1433  } else {
1436  subscriptions.impl(),
1437  resubscriptionId,
1438  requestLabel,
1439  requestLabelLen,
1441  &errors));
1442  }
1443 
1444  return errors;
1445 }
1446 
1447 inline void Session::unsubscribe(const SubscriptionList& list)
1448 {
1450  blpapi_Session_unsubscribe(d_handle_p, list.impl(), 0, 0));
1451 }
1452 
1454  const Service& service, const CorrelationId& correlationID)
1455 {
1457  d_handle_p, service.handle(), 0, &correlationID.impl()));
1458 }
1459 
1460 inline void Session::setStatusCorrelationId(const Service& service,
1461  const Identity& identity,
1462  const CorrelationId& correlationID)
1463 {
1466  service.handle(),
1467  identity.handle(),
1468  &correlationID.impl()));
1469 }
1470 
1472  const Identity& identity,
1473  const CorrelationId& correlationId,
1474  EventQueue *eventQueue,
1475  const char *requestLabel,
1476  int requestLabelLen)
1477 {
1478  CorrelationId retCorrelationId(correlationId);
1479 
1481  request.handle(),
1482  &retCorrelationId.impl(),
1483  identity.handle(),
1484  eventQueue ? eventQueue->handle() : 0,
1485  requestLabel,
1486  requestLabelLen));
1487 
1488  return retCorrelationId;
1489 }
1490 
1492  const CorrelationId& correlationId,
1493  EventQueue *eventQueue,
1494  const char *requestLabel,
1495  int requestLabelLen)
1496 {
1497  CorrelationId retCorrelationId(correlationId);
1498 
1500  request.handle(),
1501  &retCorrelationId.impl(),
1502  0,
1503  eventQueue ? eventQueue->handle() : 0,
1504  requestLabel,
1505  requestLabelLen));
1506 
1507  return retCorrelationId;
1508 }
1509 
1511  const RequestTemplate& requestTemplate,
1512  const CorrelationId& correlationId)
1513 {
1514  CorrelationId retCorrelationId(correlationId);
1515 
1518  d_handle_p, requestTemplate.impl(), &retCorrelationId.impl()));
1519 
1520  return retCorrelationId;
1521 }
1522 
1524  const char *subscriptionString,
1525  const CorrelationId& correlationID,
1526  const Identity& identity)
1527 {
1528  blpapi_RequestTemplate_t *requestTemplate = 0;
1529 
1532  d_handle_p,
1533  subscriptionString,
1534  identity.handle(),
1535  const_cast<blpapi_CorrelationId_t *>(&correlationID.impl())));
1536 
1537  return RequestTemplate(requestTemplate);
1538 }
1539 
1540 inline blpapi_Session_t *Session::handle() const { return d_handle_p; }
1541 
1542 // --------------------------
1543 // class SubscriptionIterator
1544 // --------------------------
1545 
1546 inline SubscriptionIterator::SubscriptionIterator(Session *session)
1547  : d_isValid(false)
1548 {
1549  assert(session);
1550 
1551  d_handle_p = blpapi_SubscriptionItr_create(session->handle());
1552 }
1553 
1555 {
1556  blpapi_SubscriptionItr_destroy(d_handle_p);
1557 }
1558 
1560 {
1561  blpapi_CorrelationId_t nextCorrelationIdImpl;
1562  d_isValid = !blpapi_SubscriptionItr_next(d_handle_p,
1563  &d_subscriptionString,
1564  &nextCorrelationIdImpl,
1565  &d_status);
1566 
1567  d_correlationId = d_isValid ? CorrelationId(nextCorrelationIdImpl)
1568  : CorrelationId();
1569 
1570  return d_isValid;
1571 }
1572 
1573 inline bool SubscriptionIterator::isValid() const { return d_isValid; }
1574 
1576 {
1577  return d_handle_p;
1578 }
1579 
1581 {
1582  if (!isValid()) {
1584  }
1585 
1586  return d_subscriptionString;
1587 }
1588 
1590 {
1591  if (!isValid()) {
1593  }
1594 
1595  return d_correlationId;
1596 }
1597 
1600 {
1601  if (!isValid()) {
1603  }
1604 
1605  return static_cast<Session::SubscriptionStatus>(d_status);
1606 }
1607 
1608 } // close namespace blpapi
1609 } // close namespace BloombergLP
1610 
1611 #endif // ifdef __cplusplus
1612 
1613 #endif // INCLUDED_BLPAPI_SESSION
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:1573
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:1280
blpapi_Request_t * handle() const
Definition: blpapi_request.h:718
int blpapi_Session_resubscribe(blpapi_Session_t *session, const blpapi_SubscriptionList_t *resubscriptionList, const char *requestLabel, int requestLabelLen)
Enum
Definition: blpapi_session.h:436
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:1580
Common definitions used by the library.
No longer active, terminated by API.
Definition: blpapi_session.h:523
#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:586
Definition: blpapi_session.h:1091
#define BLPAPI_SUBSCRIPTIONSTATUS_CANCELLED
Definition: blpapi_defs.h:106
Updates are flowing.
Definition: blpapi_session.h:527
Definition: blpapi_abstractsession.h:187
virtual void stop()
Definition: blpapi_session.h:1218
#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:525
blpapi_SessionOptions_t * handle() const
Definition: blpapi_sessionoptions.h:1401
virtual bool start()
Definition: blpapi_session.h:1208
#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:505
Definition: blpapi_abstractsession.h:253
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:1168
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:147
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
struct blpapi_RequestTemplate blpapi_RequestTemplate_t
Definition: blpapi_dispatchtbl.h:97
blpapi_SubscriptionIterator_t * blpapi_SubscriptionItr_create(blpapi_Session_t *session)
struct blpapi_SubscriptionList blpapi_SubscriptionList_t
Definition: blpapi_dispatchtbl.h:90
Defines a request which can be sent for a service.
Definition: blpapi_session.h:431
Definition: blpapi_session.h:502
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:1540
virtual ~Session()
Definition: blpapi_session.h:1206
#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:1213
Provide a dispatcher to dispatch events.
friend void blpapi_eventHandlerAdapter(blpapi_Event_t *event, blpapi_Session_t *, void *userData)
Definition: blpapi_session.h:1171
~SubscriptionIterator()
Definition: blpapi_session.h:1554
virtual void resubscribe(const SubscriptionList &subscriptions)
Definition: blpapi_session.h:1316
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:1523
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:1589
virtual int tryNextEvent(Event *event)
Definition: blpapi_session.h:1234
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:522
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:1575
int blpapi_Session_tryNextEvent(blpapi_Session_t *session, blpapi_Event_t **eventPointer)
No longer active, terminated by Application.
Definition: blpapi_session.h:529
struct blpapi_Request blpapi_Request_t
Definition: blpapi_dispatchtbl.h:81
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:1220
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:1447
virtual void setStatusCorrelationId(const Service &service, const CorrelationId &correlationID)
Definition: blpapi_session.h:1453
bool next()
Definition: blpapi_session.h:1559
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:1491
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:1171
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:1599
virtual Event nextEvent(int timeout=0)
Definition: blpapi_session.h:1222
#define BLPAPI_SUBSCRIPTIONSTATUS_SUBSCRIBED
Definition: blpapi_defs.h:105
std::vector< SubscriptionPreprocessError > SubscriptionPreprocessErrors
Definition: blpapi_session.h:453
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