BLPAPI C++
3.24.11
|
#include <blpapi_correlationid.h>
Public Types | |
enum | ValueType { UNSET_VALUE = BLPAPI_CORRELATION_TYPE_UNSET, INT_VALUE = BLPAPI_CORRELATION_TYPE_INT, POINTER_VALUE = BLPAPI_CORRELATION_TYPE_POINTER, AUTOGEN_VALUE = BLPAPI_CORRELATION_TYPE_AUTOGEN } |
enum | { MAX_CLASS_ID = BLPAPI_CORRELATION_MAX_CLASS_ID } |
Public Member Functions | |
CorrelationId () | |
CorrelationId (const CorrelationId &original) | |
CorrelationId (long long value, int classId=0) | |
CorrelationId (void *value, int classId=0) | |
template<typename TYPE > | |
CorrelationId (const TYPE &smartPtr, void *pointerValue, int classId=0) | |
~CorrelationId () | |
void | swap (CorrelationId &other) |
CorrelationId & | operator= (const CorrelationId &rhs) |
ValueType | valueType () const |
unsigned short | classId () const |
void * | asPointer () const |
template<typename TYPE > | |
TYPE | asSmartPointer () const |
long long | asInteger () const |
A key used to identify individual subscriptions or requests.
CorrelationId objects are passed to many of the Session object methods which initiate an asynchronous operations and are obtained from Message objects which are delivered as a result of those asynchronous operations.
When subscribing or requesting information an application has the choice of providing a CorrelationId they construct themselves or allowing the session to construct one for them. If the application supplies a CorrelationId it must not re-use the value contained in it in another CorrelationId whilst the original request or subscription is still active.
It is possible that an application supplied CorrelationId and a CorrelationId constructed by the API could return the same result for asInteger(). However, they will not compare equal using the defined operator==
for CorrelationId and there is a consistent order defined using the provided operator<
for CorrelationId.
The classId
provides scopes for the correlation id values. Two distinct CorrelationId can have the same value
and differ only by classId
. This can be useful for operations that are related, for example the correlation id to create a request template and the correlation id for requests using that template could share the same pointer value
and different classId
.
A CorrelationId constructed by an application can contain either
For 64 bit integers and simple pointers the values are copied when CorrelationId
s are copied and compared when CorrelationId
s are compared.
For "smart" pointers the API can accommodate smart pointer classes that meet the following restrictions.
sizeof(void*)*4
bytes in size.std::swap(s1, s2)
).The API will embed a smart pointer in the CorrelationId without allocating memory separately for it. The specified smartPtr
will have its copy constructor invoked when the CorrelationId is copied and its destructor invoked when the CorrelationId is destroyed so its resource management will continue to work as normal.
CorrelationId
s based on a simple pointer and CorrelationId
s based on a smart pointer have the same ValueType (POINTER_VALUE) which allows them to be compared to each other.
A CorrelationId based on a simple pointer and a CorrelationId based on a smart pointer will compare equally with operator==
as long as the pointer is the same.
Likewise, when comparing two CorrelationId
s based on a smart pointer only the pointer value itself is used for the comparison, the contents of the smart pointer object are ignored.
enum ValueType |
Enumerator | |
---|---|
UNSET_VALUE | The CorrelationId is unset. That is, it was created by the default CorrelationId constructor. |
INT_VALUE | The CorrelationId was created from an integer supplied by the user. |
POINTER_VALUE | The CorrelationId was created from a pointer supplied by the user or internally generated by the API. |
AUTOGEN_VALUE | The CorrelationId was created internally by API. |
CorrelationId | ( | ) |
The default constructor creates an uninitialized CorrelationId. This will compare equal to another CorrelationId object constructed using the default constructor. The only valid operations on an uninitialized CorrelationId are assignment, comparison for equality and destruction.
CorrelationId | ( | const CorrelationId & | original | ) |
Copy constructor. If the specified original
contains a smart pointer it will be copy constructed into this CorrelationId.
|
explicit |
Construct a CorrelationId object and initialize it with the specified integer value
. The behavior is undefined unless 0 <= classId < MAX_CLASS_ID
(65535)
|
explicit |
Construct a CorrelationId object and initialize it with the specified pointer value
. The behavior is undefined unless 0 <= classId < MAX_CLASS_ID
(65535)
CorrelationId | ( | const TYPE & | smartPtr, |
void * | pointerValue, | ||
int | classId = 0 |
||
) |
Construct a CorrelationId object and initialize it with the specified smartPtr
(whose copy constructor will be called in the process) and with the specified pointerValue
which should be the result of operator->
on the specified smartPtr
. The behavior is undefined unless 0 <= classId < MAX_CLASS_ID
(65535)
~CorrelationId | ( | ) |
Destroy this CorrelationId. If this CorrelationId contains a smart pointer its destructor will be called.
long long asInteger | ( | ) | const |
Return the value of this CorrelationId as an integer value. The result is undefined if this CorrelationId does not have valueType()==INT_VALUE or valueType()==AUTOGEN_VALUE.
void * asPointer | ( | ) | const |
Return the value of this CorrelationId as a pointer value. The result is undefined if this CorrelationId does not have valueType()==POINTER_VALUE.
TYPE asSmartPointer | ( | ) | const |
Return the CorrelationId as a smart pointer. Returns a default constructed TYPE
if this CorrelationId does not contain a pointer value, or TYPE
is not the same type that was used during construction of this CorrelationId.
unsigned short classId | ( | ) | const |
Return the user defined classification of this correlation correlation id object.
CorrelationId & operator= | ( | const CorrelationId & | rhs | ) |
Assign to this CorrelationId object the value of the specified rhs
CorrelationId object. Return a modifiable reference to this object.
void swap | ( | CorrelationId & | other | ) |
Swap the value of this CorrelationId object and the specified other
CorrelationId object.
CorrelationId::ValueType valueType | ( | ) | const |
Return the type of this CorrelationId object.