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