Quick Links: |
#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 () | |
Record & | operator= (const Record &rhs) |
void | clear () |
void | addAttribute (const ball::Attribute &attribute) |
RecordAttributes & | fixedFields () |
void | setFixedFields (const RecordAttributes &fixedFields) |
void | setCustomFields (const ball::UserFields &userFields) |
ball::UserFields & | customFields () |
const RecordAttributes & | fixedFields () const |
const ball::UserFields & | customFields () 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 &) |
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.
ball::Record::Record | ( | bslma::Allocator * | basicAllocator = 0 |
) | [explicit] |
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.
ball::Record::Record | ( | const RecordAttributes & | fixedFields, | |
const UserFields & | userFields, | |||
bslma::Allocator * | basicAllocator = 0 | |||
) |
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.
ball::Record::Record | ( | const Record & | original, | |
bslma::Allocator * | basicAllocator = 0 | |||
) |
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.
ball::Record::~Record | ( | ) |
Destroy this log record.
static void ball::Record::deleteObject | ( | const Record * | object | ) | [static] |
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.
ball::Record::BSLMF_NESTED_TRAIT_DECLARATION | ( | Record | , | |
bslma::UsesBslmaAllocator | ||||
) |
Assign to this log record the value of the specified rhs
log record and return the reference to this modifiable record.
void ball::Record::clear | ( | ) |
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.
void ball::Record::addAttribute | ( | const ball::Attribute & | attribute | ) |
Add a managed copy of the specified attribute
to the container of attributes maintained by this log record.
RecordAttributes& ball::Record::fixedFields | ( | ) |
Return the modifiable fixed fields of this log record.
void ball::Record::setFixedFields | ( | const RecordAttributes & | fixedFields | ) |
Set the fixed fields of this log record to the value of the specified fixedFields
.
void ball::Record::setCustomFields | ( | const ball::UserFields & | userFields | ) |
DEPRECATED: Use log record attributes. Set the custom user-defined fields of this log record to the value of the specified userFields
.
ball::UserFields& ball::Record::customFields | ( | ) |
DEPRECATED: Use log record attributes. Return a reference providing modifiable access to the custom user-defined fields of this log record.
const RecordAttributes& ball::Record::fixedFields | ( | ) | const |
Return the non-modifiable fixed fields of this log record.
const ball::UserFields& ball::Record::customFields | ( | ) | const |
DEPRECATED: Use log record attributes. Return a reference providing non-modifiable access to the custom user-defined fields of this log record.
const bsl::vector<ball::ManagedAttribute>& ball::Record::attributes | ( | ) | const |
Return a reference providing non-modifiable access to the attributes of this log record.
int ball::Record::numAllocatedBytes | ( | ) | const |
Return the total number of bytes of dynamic memory allocated by this log record object. Note that this value does not include sizeof *this
.
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.
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.