BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball::Context Class Reference

#include <ball_context.h>

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (Context, bslma::UsesBslmaAllocator)
 
 Context (bslma::Allocator *basicAllocator=0)
 
 Context (Transmission::Cause transmissionCause, int recordIndex, int sequenceLength, bslma::Allocator *basicAllocator=0)
 
 Context (const Context &original, bslma::Allocator *basicAllocator=0)
 
 ~Context ()=default
 Destroy this object.
 
Contextoperator= (const Context &rhs)
 
int setAttributes (Transmission::Cause transmissionCause, int recordIndex, int sequenceLength)
 
void setAttributesRaw (Transmission::Cause transmissionCause, int recordIndex, int sequenceLength)
 
void setRecordIndexRaw (int index)
 
Transmission::Cause transmissionCause () const
 Return the transmission cause attribute of this context object.
 
int recordIndex () const
 Return the record index attribute of this context object.
 
int sequenceLength () const
 Return the sequence length attribute of this context object.
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Static Public Member Functions

static bool isValid (Transmission::Cause transmissionCause, int recordIndex, int sequenceLength)
 

Friends

bool operator== (const Context &, const Context &)
 

Detailed Description

This class provides a container for aggregating the auxiliary information needed to transmit a log record. For each context attribute in this class (e.g., recordIndex), there is an accessor for obtaining the attribute's value (recordIndex) and there are manipulators for changing the contained attribute values (setAttributes checks attribute constraints; setAttributesRaw and setRecordIndexRaw do not). A static isValid method is also provided to verify that particular attribute values are consistent before they are used to create or modify a context object. Note that it is the client's responsibility not to construct or unilaterally modify a context object to hold incompatible attribute values.

Additionally, this class supports a complete set of value semantic operations, including copy construction, assignment and equality comparison, and ostream printing. A precise operational definition of when two instances have the same value can be found in the description of operator== for the class. This class is exception neutral with no guarantee of rollback: if an exception is thrown during the invocation of a method on a pre-existing instance, the object is left in a valid state, but its value is undefined. In no event is memory leaked. Finally, aliasing (e.g., using all or part of an object as both source and destination) is supported in all cases.

See ball_context

Constructor & Destructor Documentation

◆ Context() [1/3]

ball::Context::Context ( bslma::Allocator basicAllocator = 0)
inline

Create a context object with all attributes having default values. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that basicAllocator is currently ignored.

◆ Context() [2/3]

ball::Context::Context ( Transmission::Cause  transmissionCause,
int  recordIndex,
int  sequenceLength,
bslma::Allocator basicAllocator = 0 
)
inline

Create a context object indicating the specified transmissionCause, recordIndex, and sequenceLength values. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless the resulting attribute values are compatible. Note that basicAllocator is currently ignored.

◆ Context() [3/3]

ball::Context::Context ( const Context original,
bslma::Allocator basicAllocator = 0 
)
inline

Create a context object having the value of the specified original context object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that basicAllocator is currently ignored.

◆ ~Context()

ball::Context::~Context ( )
default

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

ball::Context::BSLMF_NESTED_TRAIT_DECLARATION ( Context  ,
bslma::UsesBslmaAllocator   
)

◆ isValid()

static bool ball::Context::isValid ( Transmission::Cause  transmissionCause,
int  recordIndex,
int  sequenceLength 
)
static

Return true if the specified transmissionCause, recordIndex, and sequenceLength represent a valid context, and false otherwise. (See the CONSTRAINTS section of the component-level documentation above for a complete specification of the constraints on attribute values.)

◆ operator=()

Context & ball::Context::operator= ( const Context rhs)
inline

Assign to this context object the value of the specified rhs context object.

◆ print()

bsl::ostream & ball::Context::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the optionally specified indentation level and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. Each line is indented by the absolute value of level * spacesPerLevel. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, suppress line breaks and format the entire output on one line. If stream is initially invalid, this operation has no effect.

◆ recordIndex()

int ball::Context::recordIndex ( ) const
inline

◆ sequenceLength()

int ball::Context::sequenceLength ( ) const
inline

◆ setAttributes()

int ball::Context::setAttributes ( Transmission::Cause  transmissionCause,
int  recordIndex,
int  sequenceLength 
)
inline

Set the value of this context object to the specified transmissionCause, recordIndex, and sequenceLength values if transmissionCause, recordIndex, and sequenceLength represent a valid context. Return 0 on success, and a non-zero value (with no effect on this context object) otherwise.

◆ setAttributesRaw()

void ball::Context::setAttributesRaw ( Transmission::Cause  transmissionCause,
int  recordIndex,
int  sequenceLength 
)
inline

Set the value of this context object to the specified transmissionCause, recordIndex, and sequenceLength values. The behavior is undefined if the resulting attribute values are incompatible.

◆ setRecordIndexRaw()

void ball::Context::setRecordIndexRaw ( int  index)
inline

Set the record index attribute of this context object to the specified index. The behavior is undefined if the resulting attribute values are incompatible.

◆ transmissionCause()

Transmission::Cause ball::Context::transmissionCause ( ) const
inline

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const Context ,
const Context  
)
friend

Return true if the specified lhs and rhs context objects have the same value, and false otherwise. Two context objects have the same value if each respective pair of corresponding attributes have the same value.


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