BLPAPI C++ 3.26.7
Loading...
Searching...
No Matches
blpapi_identity.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_IDENTITY
39#define INCLUDED_BLPAPI_IDENTITY
40
67
68#include <blpapi_defs.h>
69#include <blpapi_exception.h>
70#include <blpapi_service.h>
71#include <blpapi_types.h>
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
78
81
95BLPAPI_EXPORT
96void blpapi_Identity_release(blpapi_Identity_t *handle);
97
109BLPAPI_EXPORT
110int blpapi_Identity_addRef(blpapi_Identity_t *handle);
111
137BLPAPI_EXPORT
138int blpapi_Identity_hasEntitlements(const blpapi_Identity_t *handle,
139 const blpapi_Service_t *service,
140 const blpapi_Element_t *eidElement,
141 const int *entitlementIds,
142 size_t numEntitlements,
143 int *failedEntitlements,
144 int *failedEntitlementsCount);
145
156BLPAPI_EXPORT
157int blpapi_Identity_isAuthorized(
158 const blpapi_Identity_t *handle, const blpapi_Service_t *service);
159
171BLPAPI_EXPORT
172int blpapi_Identity_getSeatType(
173 const blpapi_Identity_t *handle, int *seatType);
174
177
178#ifdef __cplusplus
179}
180
181#include <utility>
182
183namespace BloombergLP {
184namespace blpapi {
191
192class Element;
193
217class Identity {
218
219 blpapi_Identity_t *d_handle_p;
220
221 void addRef();
222 void release();
223
224 public:
225 enum SeatType {
226 INVALID_SEAT = BLPAPI_SEATTYPE_INVALID_SEAT,
229
230 BPS = BLPAPI_SEATTYPE_BPS,
232
233 NONBPS = BLPAPI_SEATTYPE_NONBPS
235 };
236
237 public:
238 explicit Identity(blpapi_Identity_t *handle);
242
243 Identity();
249
250 Identity(const Identity& original);
254
255 ~Identity();
259
260 // MANIPULATORS
261
262 Identity& operator=(const Identity&);
266
267 // ACCESSORS
268 bool hasEntitlements(const Service& service,
269 const int *entitlementIds,
270 size_t numEntitlements) const;
279
280 bool hasEntitlements(const Service& service,
281 const int *entitlementIds,
282 size_t numEntitlements,
283 int *failedEntitlements,
284 int *failedEntitlementsCount) const;
303
304 bool hasEntitlements(const Service& service,
305 const Element& entitlementIds,
306 int *failedEntitlements,
307 int *failedEntitlementsCount) const;
327
328 bool isValid() const;
336
337 bool isAuthorized(const Service& service) const;
342
343 SeatType getSeatType() const;
347
349 blpapi_Identity_t *handle() const;
351};
352
355
356namespace util {
357
361
362constexpr const char *to_string(Identity::SeatType seatType);
366
368
369} // close namespace util
370
371//=============================================================================
372// INLINE FUNCTION DEFINITIONS
373//=============================================================================
374
375// --------------
376// class Identity
377// --------------
378
380 : d_handle_p(0)
381{
382}
383
384inline Identity::Identity(blpapi_Identity_t *newHandle)
385 : d_handle_p(newHandle)
386{
387}
388
389inline Identity::Identity(const Identity& original)
390 : d_handle_p(original.d_handle_p)
391{
392 addRef();
393}
394
395inline Identity::~Identity() { release(); }
396
398{
399 using std::swap;
400
401 Identity tmp(rhs);
402 swap(tmp.d_handle_p, d_handle_p);
403
404 return *this;
405}
406
407inline void Identity::addRef()
408{
409 if (d_handle_p) {
410 blpapi_Identity_addRef(d_handle_p);
411 }
412}
413
414inline void Identity::release()
415{
416 if (d_handle_p) {
417 blpapi_Identity_release(d_handle_p);
418 }
419}
420
421inline bool Identity::hasEntitlements(const Service& service,
422 const int *entitlementIds,
423 size_t numEntitlements) const
424{
425 return blpapi_Identity_hasEntitlements(d_handle_p,
426 service.handle(),
427 0,
428 entitlementIds,
429 numEntitlements,
430 0,
431 0)
432 ? true
433 : false;
434}
435
436inline bool Identity::hasEntitlements(const Service& service,
437 const int *entitlementIds,
438 size_t numEntitlements,
439 int *failedEntitlements,
440 int *failedEntitlementsCount) const
441{
442 return blpapi_Identity_hasEntitlements(d_handle_p,
443 service.handle(),
444 0,
445 entitlementIds,
446 numEntitlements,
447 failedEntitlements,
448 failedEntitlementsCount)
449 ? true
450 : false;
451}
452
453inline bool Identity::hasEntitlements(const Service& service,
454 const Element& entitlementIds,
455 int *failedEntitlements,
456 int *failedEntitlementsCount) const
457{
458 return blpapi_Identity_hasEntitlements(d_handle_p,
459 service.handle(),
460 entitlementIds.handle(),
461 0,
462 0,
463 failedEntitlements,
464 failedEntitlementsCount)
465 ? true
466 : false;
467}
468
469inline bool Identity::isValid() const { return (d_handle_p != 0); }
470
471inline bool Identity::isAuthorized(const Service& service) const
472{
473 return blpapi_Identity_isAuthorized(d_handle_p, service.handle()) ? true
474 : false;
475}
476
478{
479 int seatType = BLPAPI_SEATTYPE_INVALID_SEAT;
481 blpapi_Identity_getSeatType(d_handle_p, &seatType));
482 return static_cast<SeatType>(seatType);
483}
484
486inline blpapi_Identity_t *Identity::handle() const { return d_handle_p; }
488
489// --------------
490// namespace util
491// --------------
492constexpr const char *util::to_string(Identity::SeatType seatType)
493{
494 switch (seatType) {
496 return "INVALID_SEAT";
497 case Identity::BPS:
498 return "BPS";
499 case Identity::NONBPS:
500 return "NONBPS";
501 }
502 // Silence warnings on some compilers
503 return "UNDEFINED";
504}
505
506} // close namespace blpapi
507} // close namespace BloombergLP
508
509#endif // #ifdef __cplusplus
510#endif // #ifndef INCLUDED_BLPAPI_IDENTITY
Common definitions used by the library.
Defines Exceptions that can be thrown by the blpapi library.
A service which provides access to API data (provide or consume).
Provide BLPAPI types.
Definition blpapi_element.h:1098
static void throwOnError(int errorCode)
Definition blpapi_exception.h:556
Definition blpapi_identity.h:217
Identity()
Definition blpapi_identity.h:379
~Identity()
Definition blpapi_identity.h:395
SeatType
Definition blpapi_identity.h:225
@ NONBPS
Not permissioned for Bloomberg Professional Service.
Definition blpapi_identity.h:233
@ BPS
Bloomberg Professional Service.
Definition blpapi_identity.h:230
@ INVALID_SEAT
Definition blpapi_identity.h:226
bool isValid() const
Definition blpapi_identity.h:469
bool hasEntitlements(const Service &service, const int *entitlementIds, size_t numEntitlements) const
Definition blpapi_identity.h:421
Identity & operator=(const Identity &)
Definition blpapi_identity.h:397
Identity(blpapi_Identity_t *handle)
Definition blpapi_identity.h:384
SeatType getSeatType() const
Definition blpapi_identity.h:477
bool isAuthorized(const Service &service) const
Definition blpapi_identity.h:471
Definition blpapi_service.h:616
constexpr const char * to_string(CorrelationId::ValueType valueType)
Definition blpapi_correlationid.h:830
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition blpapi_event.h:916
Definition blpapi_abstractsession.h:448
Definition blpapi_abstractsession.h:447