Quick Links: |
#include <balm_metricdescription.h>
Public Types | |
typedef int | UserDataKey |
Public Member Functions | |
MetricDescription (const Category *category, const char *name, bslma::Allocator *basicAllocator=0) | |
void | setName (const char *name) |
void | setCategory (const Category *category) |
void | setPreferredPublicationType (PublicationType::Value type) |
void | setFormat (const bsl::shared_ptr< const MetricFormat > &format) |
void | setUserData (UserDataKey key, const void *value) |
const char * | name () const |
const Category * | category () const |
PublicationType::Value | preferredPublicationType () const |
bsl::shared_ptr< const MetricFormat > | format () const |
const void * | userData (UserDataKey key) const |
bsl::ostream & | print (bsl::ostream &stream) const |
bsl::ostream & | printDescription (bsl::ostream &stream) const |
This class provides a mechanism for describing a metric. A MetricDescription
holds the category to which the metric belongs, and a null-terminated string containing the name of the metric.
See Component balm_metricdescription
typedef int balm::MetricDescription::UserDataKey |
balm::MetricDescription::MetricDescription | ( | const Category * | category, | |
const char * | name, | |||
bslma::Allocator * | basicAllocator = 0 | |||
) |
Create a metric description for the specified category
and the specified name
. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. The initial value for preferredPublicationType
is e_UNSPECIFIED
, and the initial value for format
is 0. The behavior is undefined unless name
and category
remain valid, and the contents of name
remain unmodified, for the lifetime of this object.
void balm::MetricDescription::setName | ( | const char * | name | ) |
Set the name of this metric description to the specified name
. The behavior is undefined unless the contents of name
remains valid and unmodified for the lifetime of this object.
void balm::MetricDescription::setCategory | ( | const Category * | category | ) |
Set the category of this metric description to the object at the specified category
address. The behavior is undefined unless category
remains valid for the lifetime of this object.
void balm::MetricDescription::setPreferredPublicationType | ( | PublicationType::Value | type | ) |
Set the preferred publication type of this metric to the specified type
. The preferred publication type of this metric indicates the preferred aggregate to publish for this metric, or PublicationType::UNSPECIFIED
if there is no preference. Note that there is no uniform definition for how publishers will interpret this value; an UNSPECIFIED
value generally indicates that all the collected aggregates (total, count, minimum, and maximum value) should be published.
void balm::MetricDescription::setFormat | ( | const bsl::shared_ptr< const MetricFormat > & | format | ) |
Set the format for this metric description to the specified format
.
void balm::MetricDescription::setUserData | ( | UserDataKey | key, | |
const void * | value | |||
) |
Associate the specified value
with the specified data key
. The behavior is undefined unless key >= 0
. Note that this method allows clients of balm
to associate (opaque) application-specific information with a metric.
const char* balm::MetricDescription::name | ( | ) | const |
Return the address of the non-modifiable, null-terminated string containing the name of the described metric.
const Category* balm::MetricDescription::category | ( | ) | const |
Return the address of the non-modifiable category object indicating the category of the metric described by this object.
PublicationType::Value balm::MetricDescription::preferredPublicationType | ( | ) | const |
Return the preferred publication type of this metric. The preferred publication type of this metric indicates the preferred aggregate to publish for this metric, or PublicationType::UNSPECIFIED
if there is no preference. Note that there is no uniform definition for how publishers will interpret this value; an UNSPECIFIED
value generally indicates that the all the collected aggregates (total, count, minimum, and maximum value) should be published.
bsl::shared_ptr<const MetricFormat> balm::MetricDescription::format | ( | ) | const |
Return a shared pointer to the non-modifiable format for this metric description. Note that the returned shared pointer may be null if a format has not been provided for the described metric.
const void* balm::MetricDescription::userData | ( | UserDataKey | key | ) | const |
Return the non-modifiable value associated with the specified user-data key
. If the data for key
has not been set, a value of 0 is returned, which is indistinguishable from a valid key
with a 0 value. The behavior is undefined unless key >= 0
. Note that this method allows clients of balm
to access the (opaque) application-specific information that they have previously associated with a metric (via setUserData
).
bsl::ostream& balm::MetricDescription::print | ( | bsl::ostream & | stream | ) | const |
Print the category and name of this metric description to the specified output stream
in some single-line human-readable form, and return a reference to the modifiable stream
.
bsl::ostream& balm::MetricDescription::printDescription | ( | bsl::ostream & | stream | ) | const |
Print the properties of this metric description to the specified output stream
in some single-line human-readable form, and return a reference to the modifiable stream
.