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

#include <ball_record.h>

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (Record, bslma::UsesBslmaAllocator)
 
 Record (bslma::Allocator *basicAllocator=0)
 
 Record (const RecordAttributes &fixedFields, const UserFields &userFields, bslma::Allocator *basicAllocator=0)
 
 Record (const Record &original, bslma::Allocator *basicAllocator=0)
 
 ~Record ()=default
 Destroy this object.
 
Recordoperator= (const Record &rhs)
 
void clear ()
 
void addAttribute (const ball::Attribute &attribute)
 
RecordAttributesfixedFields ()
 Return the modifiable fixed fields of this log record.
 
void setFixedFields (const RecordAttributes &fixedFields)
 
void setCustomFields (const ball::UserFields &userFields)
 
ball::UserFieldscustomFields ()
 
const RecordAttributesfixedFields () const
 Return the non-modifiable fixed fields of this log record.
 
const ball::UserFieldscustomFields () const
 
const bsl::vector< ball::ManagedAttribute > & attributes () const
 
int numAllocatedBytes () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Static Public Member Functions

static void deleteObject (const Record *object)
 

Friends

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

Detailed Description

This class provides a container for a set of fields that are appropriate for a user-configurable log record. The class contains a RecordAttributes object that in turn holds a fixed set of fields, a ball::UserFields object that holds a set of optional, user-defined fields, and a set of attributes associated with this log record. For each of these three sub-containers there is an accessor for obtaining the container value and a manipulator for changing that value.

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_record

Constructor & Destructor Documentation

◆ Record() [1/3]

ball::Record::Record ( bslma::Allocator basicAllocator = 0)
inlineexplicit

Create a log record having default values for its fixed fields and its user-defined fields. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ Record() [2/3]

ball::Record::Record ( const RecordAttributes fixedFields,
const UserFields userFields,
bslma::Allocator basicAllocator = 0 
)
inline

Create a log record with fixed fields having the value of the specified fixedFields and user-defined fields having the value of the specified userFields. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ Record() [3/3]

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

Create a log record having the value of the specified original log record. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ ~Record()

ball::Record::~Record ( )
default

Member Function Documentation

◆ addAttribute()

void ball::Record::addAttribute ( const ball::Attribute attribute)
inline

Add a managed copy of the specified attribute to the container of attributes maintained by this log record.

◆ attributes()

const bsl::vector< ball::ManagedAttribute > & ball::Record::attributes ( ) const
inline

Return a reference providing non-modifiable access to the attributes of this log record.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ clear()

void ball::Record::clear ( )
inline

Clear this log record by removing the user fields, attributes, and clearing the fixed field's message buffer. Note that this method is tailored for efficient memory use within the ball logging system.

◆ customFields() [1/2]

ball::UserFields & ball::Record::customFields ( )
inline

Return a reference providing modifiable access to the custom user-defined fields of this log record.

Deprecated:
Use log record attributes.

◆ customFields() [2/2]

const ball::UserFields & ball::Record::customFields ( ) const
inline

Return a reference providing non-modifiable access to the custom user-defined fields of this log record.

Deprecated:
Use log record attributes.

◆ deleteObject()

void ball::Record::deleteObject ( const Record object)
inlinestatic

Destroy the specified *object and use the allocator held by *object to deallocate its memory footprint. The behavior is undefined unless object is the address of a valid log record.

◆ fixedFields() [1/2]

RecordAttributes & ball::Record::fixedFields ( )
inline

◆ fixedFields() [2/2]

const RecordAttributes & ball::Record::fixedFields ( ) const
inline

◆ numAllocatedBytes()

int ball::Record::numAllocatedBytes ( ) const
inline

Return the total number of bytes of dynamic memory allocated by this log record object. Note that this value does not include sizeof *this.

◆ operator=()

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

Assign to this log record the value of the specified rhs log record and return the reference to this modifiable record.

◆ print()

bsl::ostream & ball::Record::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.

◆ setCustomFields()

void ball::Record::setCustomFields ( const ball::UserFields userFields)
inline

Set the custom user-defined fields of this log record to the value of the specified userFields.

Deprecated:
Use log record attributes.

◆ setFixedFields()

void ball::Record::setFixedFields ( const RecordAttributes fixedFields)
inline

Set the fixed fields of this log record to the value of the specified fixedFields.

Friends And Related Symbol Documentation

◆ operator==

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

Return true if the specified lhs and rhs log records have the same value, and false otherwise. Two log records have the same value if the respective fixed fields have the same value and the respective user-defined fields have the same value.


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