BLPAPI C++  3.24.11
CorrelationId Class Reference

#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)
 
CorrelationIdoperator= (const CorrelationId &rhs)
 
ValueType valueType () const
 
unsigned short classId () const
 
void * asPointer () const
 
template<typename TYPE >
TYPE asSmartPointer () const
 
long long asInteger () const
 

Detailed Description

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

  • a 64 bit integer,
  • a simple pointer or
  • a "smart" pointer object (for example, std::shared_ptr)

For 64 bit integers and simple pointers the values are copied when CorrelationIds are copied and compared when CorrelationIds are compared.

For "smart" pointers the API can accommodate smart pointer classes that meet the following restrictions.

  • It implements a default constructor
  • It is no more than sizeof(void*)*4 bytes in size.
  • It is thread safe.
  • It performs all its necessary management as a direct side effect of their copy constructor and destructor.
  • Its contents are location independent (that is given two instances of a smart pointer s1 and s2 one can call 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.

CorrelationIds based on a simple pointer and CorrelationIds 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 CorrelationIds based on a smart pointer only the pointer value itself is used for the comparison, the contents of the smart pointer object are ignored.

See Component blpapi_correlationid

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_CLASS_ID 

The maximum value allowed for classId

◆ ValueType

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.

Constructor & Destructor Documentation

◆ CorrelationId() [1/5]

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() [2/5]

CorrelationId ( const CorrelationId original)

Copy constructor. If the specified original contains a smart pointer it will be copy constructed into this CorrelationId.

◆ CorrelationId() [3/5]

CorrelationId ( long long  value,
int  classId = 0 
)
explicit

Construct a CorrelationId object and initialize it with the specified integer value. The behavior is undefined unless 0 <= classId < MAX_CLASS_ID (65535)

◆ CorrelationId() [4/5]

CorrelationId ( void *  value,
int  classId = 0 
)
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() [5/5]

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.

Member Function Documentation

◆ asInteger()

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.

◆ asPointer()

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.

◆ asSmartPointer()

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.

◆ classId()

unsigned short classId ( ) const

Return the user defined classification of this correlation correlation id object.

◆ operator=()

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.

◆ swap()

void swap ( CorrelationId other)

Swap the value of this CorrelationId object and the specified other CorrelationId object.

◆ valueType()

CorrelationId::ValueType valueType ( ) const

Return the type of this CorrelationId object.


The documentation for this class was generated from the following file: