BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balm::MetricSample Class Reference

#include <balm_metricsample.h>

Public Types

typedef bsl::vector< MetricSampleGroup >::const_iterator const_iterator
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (MetricSample, bslma::UsesBslmaAllocator)
 
 MetricSample (bslma::Allocator *basicAllocator=0)
 
 MetricSample (const MetricSample &original, bslma::Allocator *basicAllocator=0)
 
 ~MetricSample ()
 Destroy this metric sample.
 
MetricSampleoperator= (const MetricSample &rhs)
 
void setTimeStamp (const bdlt::DatetimeTz &timeStamp)
 
void appendGroup (const MetricSampleGroup &group)
 
void appendGroup (const MetricRecord *records, int numRecords, const bsls::TimeInterval &elapsedTime)
 
void removeAllRecords ()
 Remove all metric records from this sample.
 
const MetricSampleGroupsampleGroup (int index) const
 
const bdlt::DatetimeTztimeStamp () const
 Return a reference to the non-modifiable timestamp for this sample.
 
const_iterator begin () const
 
const_iterator end () const
 
int numGroups () const
 
int numRecords () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Friends

bool operator== (const MetricSample &lhs, const MetricSample &rhs)
 

Detailed Description

This class provides an in-core value-semantic representation of a sample of metric values. The class contains a collection of addresses to (external) MetricRecord objects holding the values for their respective metrics (aggregated over some period of time). The metric records contained by a sample are broken into a series of groups, which are represented by MetricSampleGroup objects. Each group contains a sequence of records and an elapsed time value, indicating the period of time over which those records were taken. This class also provides a timestamp value, used to indicate when the sample was collected. The class provides a method, appendGroups, that appends a group of metric records to the sample. Arrays supplied using appendGroups must be valid for the productive lifetime of the MetricSample object or until they are removed by calling removeAllRecords.

See balm_metricsample

Member Typedef Documentation

◆ const_iterator

A const_iterator is an alias for an iterator over the non-modifiable sample groups contained in a MetricSample.

Constructor & Destructor Documentation

◆ MetricSample() [1/2]

balm::MetricSample::MetricSample ( bslma::Allocator basicAllocator = 0)
inline

Create an empty metric sample. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ MetricSample() [2/2]

balm::MetricSample::MetricSample ( const MetricSample original,
bslma::Allocator basicAllocator = 0 
)

Create a metric sample containing the same value as the specified original sample. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that copying the contained MetricSampleGroup objects copies only the pointers to their respective MetricRecord arrays, and does not copy the records themselves; hence, these record arrays must remain valid for the productive lifetimes of all copied objects or until the records are removed by calling removeAllRecords.

◆ ~MetricSample()

balm::MetricSample::~MetricSample ( )
inline

Member Function Documentation

◆ appendGroup() [1/2]

void balm::MetricSample::appendGroup ( const MetricRecord records,
int  numRecords,
const bsls::TimeInterval elapsedTime 
)
inline

Append to the sequence of groups maintained by this sample a new group containing the specified sequence of records of specified length numRecords measuring the specified elapsedTime. The behavior is undefined unless 0 <= numRecords, records refers to a contiguous sequence of size (at least) numRecords, and elapsedTime > bsls::TimeInterval(0, 0). Note that records is not copied: hence, the supplied array must remain valid for the lifetime of this object or until the records are removed by calling removeAllRecords(). This method is functionally equivalent to:

appendGroup(MetricSampleGroup(records, numRecords, elapsedTime));
Definition balm_metricsample.h:199
void appendGroup(const MetricSampleGroup &group)
Definition balm_metricsample.h:645
int numRecords() const
Definition balm_metricsample.h:703

◆ appendGroup() [2/2]

void balm::MetricSample::appendGroup ( const MetricSampleGroup group)
inline

Append the specified group of records to the sequence of groups maintained by this sample. If group.numRecords() is 0 this method has no effect. The behavior is undefined unless group.elapsedTime() > bsls::TimeInterval(0, 0). Note that the MetricRecord objects referred to by records are not copied: hence, the supplied array must remain valid for the productive lifetime of this object or until the group is removed by calling removeAllRecords().

◆ begin()

MetricSample::const_iterator balm::MetricSample::begin ( ) const
inline

Return an iterator positioned at the beginning of the sequence of MetricSampleGroup objects contained by this object. Note that the iterator will remain valid until this sample is modified by invoking either appendGroups or removeAllRecords().

◆ BSLMF_NESTED_TRAIT_DECLARATION()

balm::MetricSample::BSLMF_NESTED_TRAIT_DECLARATION ( MetricSample  ,
bslma::UsesBslmaAllocator   
)

◆ end()

MetricSample::const_iterator balm::MetricSample::end ( ) const
inline

Return an iterator positioned one one past the final MetricSampleGroup object in the sequence of sample groups contained by this object. Note that the iterator will remain valid until this sample is modified by invoking appendGroup or removeAllRecords().

◆ numGroups()

int balm::MetricSample::numGroups ( ) const
inline

Return the number of record groups (i.e., MetricSampleGroup objects) that are contained in this object.

◆ numRecords()

int balm::MetricSample::numRecords ( ) const
inline

Return the total number of records in this sample (i.e., the sum of the lengths of all the appended record groups).

◆ operator=()

MetricSample & balm::MetricSample::operator= ( const MetricSample rhs)

Assign to this sample the value of the specified rhs sample and return a reference to this modifiable sample. Note that copying the MetricSampleGroup objects contained in rhs copies only the pointers to their respective MetricRecord arrays, and does not copy records themselves; hence, these record arrays must remain valid for the productive lifetimes of all copied objects or until records are removed by calling removeAllRecords.

◆ print()

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

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.

◆ removeAllRecords()

void balm::MetricSample::removeAllRecords ( )
inline

◆ sampleGroup()

const MetricSampleGroup & balm::MetricSample::sampleGroup ( int  index) const
inline

Return a reference to the non-modifiable MetricSampleGroup object at the specified index in this sample. The behavior is undefined unless 0 <= index < numGroups(). Note that the returned reference will remain valid until this sample is modified by invoking appendGroup or removeAllRecords().

◆ setTimeStamp()

void balm::MetricSample::setTimeStamp ( const bdlt::DatetimeTz timeStamp)
inline

Set the timestamp (used to indicate when the sample was taken) to the specified timeStamp.

◆ timeStamp()

const bdlt::DatetimeTz & balm::MetricSample::timeStamp ( ) const
inline

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const MetricSample lhs,
const MetricSample rhs 
)
friend

Return true if the specified lhs and rhs samples have the same value, and false otherwise. Two samples have the same value if they have the same timestamp value, contain the same number of record groups, and if the respective groups of records at each index position have the same value.


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