BLPAPI C++  3.24.10
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 
28 #ifndef INCLUDED_BLPAPI_IDENTITY
29 #define INCLUDED_BLPAPI_IDENTITY
30 
59 #include <blpapi_defs.h>
60 #include <blpapi_exception.h>
61 #include <blpapi_service.h>
62 #include <blpapi_types.h>
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
70 
73 
76  const blpapi_Service_t *service,
77  const blpapi_Element_t *eidElement,
78  const int *entitlementIds,
79  size_t numEntitlements,
80  int *failedEntitlements,
81  int *failedEntitlementsCount);
82 
85  const blpapi_Identity_t *handle, const blpapi_Service_t *service);
86 
89  const blpapi_Identity_t *handle, int *seatType);
90 
91 #ifdef __cplusplus
92 }
93 
94 #include <utility>
95 
103 namespace BloombergLP {
104 namespace blpapi {
105 
106 class Element;
107 
131 class Identity {
132 
133  blpapi_Identity_t *d_handle_p;
134 
135  void addRef();
136  void release();
137 
138  public:
139  enum SeatType {
143 
146 
149  };
150 
151  public:
152  explicit Identity(blpapi_Identity_t *handle);
157  Identity();
164  Identity(const Identity& original);
169  ~Identity();
175  // MANIPULATORS
176 
177  Identity& operator=(const Identity&);
182  // ACCESSORS
183  bool hasEntitlements(const Service& service,
184  const int *entitlementIds,
185  size_t numEntitlements) const;
195  bool hasEntitlements(const Service& service,
196  const int *entitlementIds,
197  size_t numEntitlements,
198  int *failedEntitlements,
199  int *failedEntitlementsCount) const;
219  bool hasEntitlements(const Service& service,
220  const Element& entitlementIds,
221  int *failedEntitlements,
222  int *failedEntitlementsCount) const;
243  bool isValid() const;
250  bool isAuthorized(const Service& service) const;
256  SeatType getSeatType() const;
261  blpapi_Identity_t *handle() const;
262 };
263 
267 //=============================================================================
268 // INLINE FUNCTION DEFINITIONS
269 //=============================================================================
270 
271 // --------------
272 // class Identity
273 // --------------
274 
276  : d_handle_p(0)
277 {
278 }
279 
281  : d_handle_p(newHandle)
282 {
283 }
284 
285 inline Identity::Identity(const Identity& original)
286  : d_handle_p(original.d_handle_p)
287 {
288  addRef();
289 }
290 
291 inline Identity::~Identity() { release(); }
292 
294 {
295  using std::swap;
296 
297  Identity tmp(rhs);
298  swap(tmp.d_handle_p, d_handle_p);
299 
300  return *this;
301 }
302 
303 inline void Identity::addRef()
304 {
305  if (d_handle_p) {
306  blpapi_Identity_addRef(d_handle_p);
307  }
308 }
309 
310 inline void Identity::release()
311 {
312  if (d_handle_p) {
313  blpapi_Identity_release(d_handle_p);
314  }
315 }
316 
317 inline bool Identity::hasEntitlements(const Service& service,
318  const int *entitlementIds,
319  size_t numEntitlements) const
320 {
321  return blpapi_Identity_hasEntitlements(d_handle_p,
322  service.handle(),
323  0,
324  entitlementIds,
325  numEntitlements,
326  0,
327  0)
328  ? true
329  : false;
330 }
331 
332 inline bool Identity::hasEntitlements(const Service& service,
333  const int *entitlementIds,
334  size_t numEntitlements,
335  int *failedEntitlements,
336  int *failedEntitlementsCount) const
337 {
338  return blpapi_Identity_hasEntitlements(d_handle_p,
339  service.handle(),
340  0,
341  entitlementIds,
342  numEntitlements,
343  failedEntitlements,
344  failedEntitlementsCount)
345  ? true
346  : false;
347 }
348 
349 inline bool Identity::hasEntitlements(const Service& service,
350  const Element& entitlementIds,
351  int *failedEntitlements,
352  int *failedEntitlementsCount) const
353 {
354  return blpapi_Identity_hasEntitlements(d_handle_p,
355  service.handle(),
356  entitlementIds.handle(),
357  0,
358  0,
359  failedEntitlements,
360  failedEntitlementsCount)
361  ? true
362  : false;
363 }
364 
365 inline bool Identity::isValid() const { return (d_handle_p != 0); }
366 
367 inline bool Identity::isAuthorized(const Service& service) const
368 {
369  return blpapi_Identity_isAuthorized(d_handle_p, service.handle()) ? true
370  : false;
371 }
372 
374 {
375  int seatType = BLPAPI_SEATTYPE_INVALID_SEAT;
377  blpapi_Identity_getSeatType(d_handle_p, &seatType));
378  return static_cast<SeatType>(seatType);
379 }
380 
381 inline blpapi_Identity_t *Identity::handle() const { return d_handle_p; }
382 
383 } // close namespace blpapi
384 } // close namespace BloombergLP
385 
386 #endif // #ifdef __cplusplus
387 #endif // #ifndef INCLUDED_BLPAPI_IDENTITY
Identity()
Definition: blpapi_identity.h:275
bool isValid() const
Definition: blpapi_identity.h:365
blpapi_Element_t * handle()
Definition: blpapi_element.h:1903
struct blpapi_Element blpapi_Element_t
Definition: blpapi_types.h:136
Common definitions used by the library.
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition: blpapi_event.h:723
bool isAuthorized(const Service &service) const
Definition: blpapi_identity.h:367
Definition: blpapi_abstractsession.h:187
Definition: blpapi_service.h:304
int blpapi_Identity_hasEntitlements(const blpapi_Identity_t *handle, const blpapi_Service_t *service, const blpapi_Element_t *eidElement, const int *entitlementIds, size_t numEntitlements, int *failedEntitlements, int *failedEntitlementsCount)
~Identity()
Definition: blpapi_identity.h:291
Definition: blpapi_identity.h:140
Identity & operator=(const Identity &)
Definition: blpapi_identity.h:293
int blpapi_Identity_addRef(blpapi_Identity_t *handle)
blpapi_Service_t * handle() const
Definition: blpapi_service.h:706
A service which provides access to API data (provide or consume).
SeatType getSeatType() const
Definition: blpapi_identity.h:373
static void throwOnError(int errorCode)
Definition: blpapi_exception.h:526
Definition: blpapi_element.h:465
int blpapi_Identity_isAuthorized(const blpapi_Identity_t *handle, const blpapi_Service_t *service)
struct blpapi_Identity blpapi_Identity_t
Definition: blpapi_types.h:188
int blpapi_Identity_getSeatType(const blpapi_Identity_t *handle, int *seatType)
Not permissioned for Bloomberg Professional Service.
Definition: blpapi_identity.h:147
SeatType
Definition: blpapi_identity.h:139
Definition: blpapi_identity.h:131
#define BLPAPI_SEATTYPE_BPS
Definition: blpapi_defs.h:120
Defines Exceptions that can be thrown by the blpapi library.
#define BLPAPI_SEATTYPE_INVALID_SEAT
Definition: blpapi_defs.h:119
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
struct blpapi_Service blpapi_Service_t
Definition: blpapi_types.h:166
bool hasEntitlements(const Service &service, const int *entitlementIds, size_t numEntitlements) const
Definition: blpapi_identity.h:317
Provide BLPAPI types.
Bloomberg Professional Service.
Definition: blpapi_identity.h:144
blpapi_Identity_t * handle() const
Definition: blpapi_identity.h:381
#define BLPAPI_SEATTYPE_NONBPS
Definition: blpapi_defs.h:121
void blpapi_Identity_release(blpapi_Identity_t *handle)