BLPAPI C++ 3.26.6
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
356//=============================================================================
357// INLINE FUNCTION DEFINITIONS
358//=============================================================================
359
360// --------------
361// class Identity
362// --------------
363
365 : d_handle_p(0)
366{
367}
368
369inline Identity::Identity(blpapi_Identity_t *newHandle)
370 : d_handle_p(newHandle)
371{
372}
373
374inline Identity::Identity(const Identity& original)
375 : d_handle_p(original.d_handle_p)
376{
377 addRef();
378}
379
380inline Identity::~Identity() { release(); }
381
383{
384 using std::swap;
385
386 Identity tmp(rhs);
387 swap(tmp.d_handle_p, d_handle_p);
388
389 return *this;
390}
391
392inline void Identity::addRef()
393{
394 if (d_handle_p) {
395 blpapi_Identity_addRef(d_handle_p);
396 }
397}
398
399inline void Identity::release()
400{
401 if (d_handle_p) {
402 blpapi_Identity_release(d_handle_p);
403 }
404}
405
406inline bool Identity::hasEntitlements(const Service& service,
407 const int *entitlementIds,
408 size_t numEntitlements) const
409{
410 return blpapi_Identity_hasEntitlements(d_handle_p,
411 service.handle(),
412 0,
413 entitlementIds,
414 numEntitlements,
415 0,
416 0)
417 ? true
418 : false;
419}
420
421inline bool Identity::hasEntitlements(const Service& service,
422 const int *entitlementIds,
423 size_t numEntitlements,
424 int *failedEntitlements,
425 int *failedEntitlementsCount) const
426{
427 return blpapi_Identity_hasEntitlements(d_handle_p,
428 service.handle(),
429 0,
430 entitlementIds,
431 numEntitlements,
432 failedEntitlements,
433 failedEntitlementsCount)
434 ? true
435 : false;
436}
437
438inline bool Identity::hasEntitlements(const Service& service,
439 const Element& entitlementIds,
440 int *failedEntitlements,
441 int *failedEntitlementsCount) const
442{
443 return blpapi_Identity_hasEntitlements(d_handle_p,
444 service.handle(),
445 entitlementIds.handle(),
446 0,
447 0,
448 failedEntitlements,
449 failedEntitlementsCount)
450 ? true
451 : false;
452}
453
454inline bool Identity::isValid() const { return (d_handle_p != 0); }
455
456inline bool Identity::isAuthorized(const Service& service) const
457{
458 return blpapi_Identity_isAuthorized(d_handle_p, service.handle()) ? true
459 : false;
460}
461
463{
464 int seatType = BLPAPI_SEATTYPE_INVALID_SEAT;
466 blpapi_Identity_getSeatType(d_handle_p, &seatType));
467 return static_cast<SeatType>(seatType);
468}
469
471inline blpapi_Identity_t *Identity::handle() const { return d_handle_p; }
473
474} // close namespace blpapi
475} // close namespace BloombergLP
476
477#endif // #ifdef __cplusplus
478#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:364
~Identity()
Definition blpapi_identity.h:380
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:454
bool hasEntitlements(const Service &service, const int *entitlementIds, size_t numEntitlements) const
Definition blpapi_identity.h:406
Identity & operator=(const Identity &)
Definition blpapi_identity.h:382
Identity(blpapi_Identity_t *handle)
Definition blpapi_identity.h:369
SeatType getSeatType() const
Definition blpapi_identity.h:462
bool isAuthorized(const Service &service) const
Definition blpapi_identity.h:456
Definition blpapi_service.h:619
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition blpapi_event.h:860
Definition blpapi_abstractsession.h:452
Definition blpapi_abstractsession.h:451