28 #ifndef INCLUDED_BLPAPI_CORRELATIONID 29 #define INCLUDED_BLPAPI_CORRELATIONID 61 #ifndef INCLUDED_BLPAPI_TYPES 65 #ifndef INCLUDED_BLPAPI_DEFS 74 struct blpapi_ManagedPtr_t_;
75 typedef struct blpapi_ManagedPtr_t_ blpapi_ManagedPtr_t;
77 typedef int (*blpapi_ManagedPtr_ManagerFunction_t)(
78 blpapi_ManagedPtr_t *managedPtr,
79 const blpapi_ManagedPtr_t *srcPtr,
85 } blpapi_ManagedPtr_t_data_;
87 struct blpapi_ManagedPtr_t_ {
89 blpapi_ManagedPtr_t_data_ userData[4];
90 blpapi_ManagedPtr_ManagerFunction_t manager;
93 typedef struct blpapi_CorrelationId_t_ {
94 unsigned int size : 8;
95 unsigned int valueType : 4;
96 unsigned int classId : 16;
97 unsigned int reserved : 4;
101 blpapi_ManagedPtr_t ptrValue;
103 } blpapi_CorrelationId_t;
203 blpapi_CorrelationId_t d_impl;
205 void copy(
const blpapi_CorrelationId_t& src);
207 template <
typename TYPE>
208 static int managerFunc(blpapi_ManagedPtr_t *managedPtr,
209 const blpapi_ManagedPtr_t *srcPtr,
212 template <
typename TYPE>
static void assertSmartPtrFits();
273 template <
typename TYPE>
307 unsigned short classId()
const;
335 blpapi_CorrelationId_t& impl();
337 const blpapi_CorrelationId_t& impl()
const;
345 inline bool operator==(
const CorrelationId& lhs,
const CorrelationId& rhs);
354 inline bool operator!=(
const CorrelationId& lhs,
const CorrelationId& rhs);
359 inline bool operator<(
const CorrelationId& lhs,
const CorrelationId& rhs);
380 std::memset(&d_impl, 0,
sizeof(d_impl));
384 const blpapi_CorrelationId_t& correlationId)
391 copy(original.d_impl);
396 std::memset(&d_impl, 0,
sizeof(d_impl));
398 d_impl.size = static_cast<unsigned>(
sizeof(d_impl));
400 d_impl.value.intValue = static_cast<blpapi_UInt64_t>(intValue);
401 d_impl.classId = static_cast<unsigned>(newClassId);
406 std::memset(&d_impl, 0,
sizeof(d_impl));
408 d_impl.size = static_cast<unsigned>(
sizeof(d_impl));
410 d_impl.value.ptrValue.pointer = ptrValue;
411 d_impl.classId = static_cast<unsigned>(newClassId);
414 template <
typename TYPE>
416 const TYPE& smartPtr,
void *ptrValue,
int newClassId)
421 assertSmartPtrFits<TYPE>();
423 std::memset(&d_impl, 0,
sizeof(d_impl));
425 d_impl.size =
sizeof(d_impl);
427 d_impl.classId = newClassId;
429 d_impl.value.ptrValue.pointer = ptrValue;
430 d_impl.value.ptrValue.manager = &CorrelationId::managerFunc<TYPE>;
432 void *arena = (
void *)d_impl.value.ptrValue.userData;
433 new (arena) TYPE(smartPtr);
439 blpapi_ManagedPtr_ManagerFunction_t& manager
440 = d_impl.value.ptrValue.manager;
451 swap(other.d_impl, d_impl);
461 inline blpapi_CorrelationId_t& CorrelationId::impl() {
return d_impl; }
472 return d_impl.value.ptrValue.pointer;
477 typedef int (*ManagerFuncPtr)(
478 blpapi_ManagedPtr_t *,
const blpapi_ManagedPtr_t *, int);
480 ManagerFuncPtr managerFnPtr
481 = static_cast<ManagerFuncPtr>(&(CorrelationId::managerFunc<TYPE>));
483 || (d_impl.value.ptrValue.manager != managerFnPtr)) {
486 return *(TYPE *)d_impl.value.ptrValue.userData;
491 return static_cast<long long>(d_impl.value.intValue);
494 inline const blpapi_CorrelationId_t& CorrelationId::impl()
const 499 inline void CorrelationId::copy(
const blpapi_CorrelationId_t& src)
504 blpapi_ManagedPtr_ManagerFunction_t& manager
505 = d_impl.value.ptrValue.manager;
507 manager(&d_impl.value.ptrValue,
514 template <
typename TYPE>
515 inline int CorrelationId::managerFunc(blpapi_ManagedPtr_t *managedPtr,
516 const blpapi_ManagedPtr_t *srcPtr,
520 managedPtr->pointer = srcPtr->pointer;
521 managedPtr->manager = srcPtr->manager;
523 void *arena = managedPtr->userData;
524 new (arena) TYPE(*((TYPE *)&srcPtr->userData[0]));
526 TYPE *managedPtr_p = (TYPE *)&managedPtr->userData[0];
527 managedPtr_p->~TYPE();
529 static int uniquePerTemplateInstantiation;
531 const int *address = &uniquePerTemplateInstantiation;
533 std::memcpy(&rc, &address, std::min(
sizeof address,
sizeof rc));
549 template <
typename TYPE>
inline void CorrelationId::assertSmartPtrFits()
555 char errorIfSmartPtrDoesNotFit[
sizeof(TYPE) <= (
sizeof(
void *) * 4)
558 (void)errorIfSmartPtrDoesNotFit;
584 return !(lhs == rhs);
589 return std::memcmp(&lhs.impl(), &rhs.impl(),
sizeof(rhs.impl())) < 0;
595 const char *valueType = 0;
604 valueType =
"POINTER";
607 valueType =
"AUTOGEN";
610 valueType =
"UNKNOWN";
613 os <<
"[ valueType=" << valueType <<
" classId=" << correlator.
classId()
628 #endif // #ifdef __cplusplus 629 #endif // #ifndef INCLUDED_BLPAPI_CORRELATIONID ValueType valueType() const
Definition: blpapi_correlationid.h:463
The CorrelationId was created internally by API.
Definition: blpapi_correlationid.h:227
~CorrelationId()
Definition: blpapi_correlationid.h:436
bool operator!=(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:582
#define BLPAPI_CORRELATION_TYPE_POINTER
Definition: blpapi_defs.h:53
#define BLPAPI_CORRELATION_TYPE_AUTOGEN
Definition: blpapi_defs.h:54
Common definitions used by the library.
bool operator==(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:562
void swap(Event::iterator &lhs, Event::iterator &rhs)
Swap the contents of the lhs and rhs iterators.
Definition: blpapi_event.h:720
bool operator<(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:587
Definition: blpapi_abstractsession.h:220
#define BLPAPI_MANAGEDPTR_DESTROY
Definition: blpapi_defs.h:58
Definition: blpapi_correlationid.h:221
#define BLPAPI_CORRELATION_MAX_CLASS_ID
Definition: blpapi_defs.h:55
Definition: blpapi_correlationid.h:234
long long asInteger() const
Definition: blpapi_correlationid.h:489
Definition: blpapi_correlationid.h:218
Definition: blpapi_correlationid.h:224
void swap(CorrelationId &other)
Definition: blpapi_correlationid.h:447
CorrelationId()
Definition: blpapi_correlationid.h:378
unsigned long long blpapi_UInt64_t
Definition: blpapi_types.h:70
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition: blpapi_correlationid.h:592
Definition: blpapi_correlationid.h:201
#define BLPAPI_CORRELATION_TYPE_UNSET
Definition: blpapi_defs.h:51
CorrelationId & operator=(const CorrelationId &rhs)
Definition: blpapi_correlationid.h:454
#define BLPAPI_MANAGEDPTR_IMPOSSIBLE_OPERATION
Definition: blpapi_defs.h:59
ValueType
Definition: blpapi_correlationid.h:217
TYPE asSmartPointer() const
Definition: blpapi_correlationid.h:475
#define BLPAPI_CORRELATION_TYPE_INT
Definition: blpapi_defs.h:52
void * asPointer() const
Definition: blpapi_correlationid.h:470
unsigned short classId() const
Definition: blpapi_correlationid.h:468
#define BLPAPI_MANAGEDPTR_COPY
Definition: blpapi_defs.h:57