BLPAPI C++ 3.26.5
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
35
36#ifndef INCLUDED_BLPAPI_IDENTITY
37#define INCLUDED_BLPAPI_IDENTITY
38
66
67#include <blpapi_defs.h>
68#include <blpapi_exception.h>
69#include <blpapi_service.h>
70#include <blpapi_types.h>
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
77
80
81BLPAPI_EXPORT
82void blpapi_Identity_release(blpapi_Identity_t *handle);
83
84BLPAPI_EXPORT
85int blpapi_Identity_addRef(blpapi_Identity_t *handle);
86
87BLPAPI_EXPORT
88int blpapi_Identity_hasEntitlements(const blpapi_Identity_t *handle,
89 const blpapi_Service_t *service,
90 const blpapi_Element_t *eidElement,
91 const int *entitlementIds,
92 size_t numEntitlements,
93 int *failedEntitlements,
94 int *failedEntitlementsCount);
95
96BLPAPI_EXPORT
97int blpapi_Identity_isAuthorized(
98 const blpapi_Identity_t *handle, const blpapi_Service_t *service);
99
100BLPAPI_EXPORT
101int blpapi_Identity_getSeatType(
102 const blpapi_Identity_t *handle, int *seatType);
103
106
107#ifdef __cplusplus
108}
109
110#include <utility>
111
118
119namespace BloombergLP {
120namespace blpapi {
121
122class Element;
123
147class Identity {
148
149 blpapi_Identity_t *d_handle_p;
150
151 void addRef();
152 void release();
153
154 public:
155 enum SeatType {
156 INVALID_SEAT = BLPAPI_SEATTYPE_INVALID_SEAT,
159
160 BPS = BLPAPI_SEATTYPE_BPS,
162
163 NONBPS = BLPAPI_SEATTYPE_NONBPS
165 };
166
167 public:
168 explicit Identity(blpapi_Identity_t *handle);
172
173 Identity();
179
180 Identity(const Identity& original);
184
185 ~Identity();
189
190 // MANIPULATORS
191
192 Identity& operator=(const Identity&);
196
197 // ACCESSORS
198 bool hasEntitlements(const Service& service,
199 const int *entitlementIds,
200 size_t numEntitlements) const;
209
210 bool hasEntitlements(const Service& service,
211 const int *entitlementIds,
212 size_t numEntitlements,
213 int *failedEntitlements,
214 int *failedEntitlementsCount) const;
233
234 bool hasEntitlements(const Service& service,
235 const Element& entitlementIds,
236 int *failedEntitlements,
237 int *failedEntitlementsCount) const;
257
258 bool isValid() const;
264
265 bool isAuthorized(const Service& service) const;
270
271 SeatType getSeatType() const;
275
276 blpapi_Identity_t *handle() const;
277};
278
281
282//=============================================================================
283// INLINE FUNCTION DEFINITIONS
284//=============================================================================
285
286// --------------
287// class Identity
288// --------------
289
291 : d_handle_p(0)
292{
293}
294
295inline Identity::Identity(blpapi_Identity_t *newHandle)
296 : d_handle_p(newHandle)
297{
298}
299
300inline Identity::Identity(const Identity& original)
301 : d_handle_p(original.d_handle_p)
302{
303 addRef();
304}
305
306inline Identity::~Identity() { release(); }
307
309{
310 using std::swap;
311
312 Identity tmp(rhs);
313 swap(tmp.d_handle_p, d_handle_p);
314
315 return *this;
316}
317
318inline void Identity::addRef()
319{
320 if (d_handle_p) {
321 blpapi_Identity_addRef(d_handle_p);
322 }
323}
324
325inline void Identity::release()
326{
327 if (d_handle_p) {
328 blpapi_Identity_release(d_handle_p);
329 }
330}
331
332inline bool Identity::hasEntitlements(const Service& service,
333 const int *entitlementIds,
334 size_t numEntitlements) const
335{
336 return blpapi_Identity_hasEntitlements(d_handle_p,
337 service.handle(),
338 0,
339 entitlementIds,
340 numEntitlements,
341 0,
342 0)
343 ? true
344 : false;
345}
346
347inline bool Identity::hasEntitlements(const Service& service,
348 const int *entitlementIds,
349 size_t numEntitlements,
350 int *failedEntitlements,
351 int *failedEntitlementsCount) const
352{
353 return blpapi_Identity_hasEntitlements(d_handle_p,
354 service.handle(),
355 0,
356 entitlementIds,
357 numEntitlements,
358 failedEntitlements,
359 failedEntitlementsCount)
360 ? true
361 : false;
362}
363
364inline bool Identity::hasEntitlements(const Service& service,
365 const Element& entitlementIds,
366 int *failedEntitlements,
367 int *failedEntitlementsCount) const
368{
369 return blpapi_Identity_hasEntitlements(d_handle_p,
370 service.handle(),
371 entitlementIds.handle(),
372 0,
373 0,
374 failedEntitlements,
375 failedEntitlementsCount)
376 ? true
377 : false;
378}
379
380inline bool Identity::isValid() const { return (d_handle_p != 0); }
381
382inline bool Identity::isAuthorized(const Service& service) const
383{
384 return blpapi_Identity_isAuthorized(d_handle_p, service.handle()) ? true
385 : false;
386}
387
389{
390 int seatType = BLPAPI_SEATTYPE_INVALID_SEAT;
392 blpapi_Identity_getSeatType(d_handle_p, &seatType));
393 return static_cast<SeatType>(seatType);
394}
395
396inline blpapi_Identity_t *Identity::handle() const { return d_handle_p; }
397
398} // close namespace blpapi
399} // close namespace BloombergLP
400
401#endif // #ifdef __cplusplus
402#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:1167
blpapi_Element_t * handle()
Definition blpapi_element.h:2635
static void throwOnError(int errorCode)
Definition blpapi_exception.h:541
Definition blpapi_identity.h:147
Identity()
Definition blpapi_identity.h:290
~Identity()
Definition blpapi_identity.h:306
SeatType
Definition blpapi_identity.h:155
@ NONBPS
Not permissioned for Bloomberg Professional Service.
Definition blpapi_identity.h:163
@ BPS
Bloomberg Professional Service.
Definition blpapi_identity.h:160
@ INVALID_SEAT
Definition blpapi_identity.h:156
bool isValid() const
Definition blpapi_identity.h:380
bool hasEntitlements(const Service &service, const int *entitlementIds, size_t numEntitlements) const
Definition blpapi_identity.h:332
blpapi_Identity_t * handle() const
Definition blpapi_identity.h:396
Identity & operator=(const Identity &)
Definition blpapi_identity.h:308
Identity(blpapi_Identity_t *handle)
Definition blpapi_identity.h:295
SeatType getSeatType() const
Definition blpapi_identity.h:388
bool isAuthorized(const Service &service) const
Definition blpapi_identity.h:382
Definition blpapi_service.h:320
blpapi_Service_t * handle() const
Definition blpapi_service.h:722
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition blpapi_event.h:739
Definition blpapi_abstractsession.h:212
Definition blpapi_abstractsession.h:211