CodeSonar C++ API
Public Member Functions | Related Symbols | List of all members
cs::sfile_metricclass Class Reference

A sfile granularity metric class. More...

Public Member Functions

bool allowed () const
 Check: are METRIC_FILTER settings such that reported instances of this metric class will be submitted to the hub?
 
bool always_discarded () const
 Check: are METRIC_FILTER settings such that instances of this metric class will always be ignored?
 
std::string as_repr () const
 Get a representation of a sfile_metricclass object that includes information useful for debugging.
 
std::string as_string () const
 Get a simple string representation of a sfile_metricclass object.
 
int cmp (const sfile_metricclass &other) const
 Comparison function for sfile_metricclass, with respect to a stable overall ordering.
 
std::string description () const
 Get the description (longer, human readable identifier) for a metric class (sfile_metricclass).
 
metricclass_flags flags () const
 Get the metricclass_flags for a sfile_metricclass.
 
cs_hash_t hash () const
 Get a hash value for this sfile_metricclass.
 
void report (sfile elt, double val) const
 Report a metric value to the hub.
 
void retract (sfile elt) const
 Retract a metric value.
 
std::string tag () const
 Get the tag (short string identifier) for a metric class (sfile_metricclass).
 
double value (sfile elt) const
 Get the value of a metric.
 

Related Symbols

(Note that these are not member symbols.)

bool operator!= (const sfile_metricclass &a, const sfile_metricclass &b)
 Inequality operator for sfile_metricclass.
 
bool operator< (const sfile_metricclass &a, const sfile_metricclass &b)
 Less-than operator for sfile_metricclass.
 
std::ostream & operator<< (std::ostream &out, const sfile_metricclass &a)
 Print a representation of a sfile_metricclass object to the specified stream.
 
bool operator<= (const sfile_metricclass &a, const sfile_metricclass &b)
 Less-than-or-equal operator for sfile_metricclass.
 
bool operator== (const sfile_metricclass &a, const sfile_metricclass &b)
 Equality operator for sfile_metricclass.
 
bool operator> (const sfile_metricclass &a, const sfile_metricclass &b)
 Greater-than operator for sfile_metricclass.
 
bool operator>= (const sfile_metricclass &a, const sfile_metricclass &b)
 Greater-than-or-equal operator for sfile_metricclass.
 

Detailed Description

A sfile granularity metric class.

The sfile granularity metric classes are managed by sfile_metricclass_manager.

You can retrieve metric values with value(), and examine metric properties with description(), tag(), and flags().

For more information about metrics in CodeSonar, see the Metrics manual page.

Member Function Documentation

◆ allowed()

bool cs::sfile_metricclass::allowed ( ) const
inlineinherited

Check: are METRIC_FILTER settings such that reported instances of this metric class will be submitted to the hub?

Returns
true if reported instances of the class will be submitted to the hub, false otherwise.

If you have defined a custom metric class C in a plug-in, you can use a test based on C.allowed() to avoid unnecessary work in the case where C is ignored.

This is the complement of sfile_metricclass::always_discarded().

◆ always_discarded()

bool cs::sfile_metricclass::always_discarded ( ) const
inlineinherited

Check: are METRIC_FILTER settings such that instances of this metric class will always be ignored?

Returns
true if all instances of the class are being discarded, false otherwise.

If you have defined a custom metric class C in a plug-in, you can use a test based on C.always_discarded() to avoid unnecessary work in the case where C is ignored.

This is the complement of sfile_metricclass::allowed.

◆ as_repr()

std::string cs::sfile_metricclass::as_repr ( ) const
inlineinherited

Get a representation of a sfile_metricclass object that includes information useful for debugging.

Returns
The string representation.

◆ as_string()

std::string cs::sfile_metricclass::as_string ( ) const
inlineinherited

Get a simple string representation of a sfile_metricclass object.

Returns
The string representation.

◆ cmp()

cs::sfile_metricclass::cmp ( const sfile_metricclass other) const
inlineinherited

Comparison function for sfile_metricclass, with respect to a stable overall ordering.

this and other will only compare equal if they are the same sfile_metricclass object.

Parameters
otherThe sfile_metricclass object to compare against.
Returns
An integer N such that:
  • N<0 if this < other
  • N==0 if this == other
  • N>0 if this > other

◆ description()

std::string cs::sfile_metricclass::description ( ) const
inlineinherited

Get the description (longer, human readable identifier) for a metric class (sfile_metricclass).

Returns
The description, as a std::string.

For example, CodeSonar ships with built-in project granularity metric class Include file instances.

  • its tag is "InclF"
  • its description is "Include file instances"

◆ flags()

metricclass_flags cs::sfile_metricclass::flags ( ) const
inlineinherited

◆ hash()

cs_hash_t cs::sfile_metricclass::hash ( ) const
inlineinherited

Get a hash value for this sfile_metricclass.

◆ report()

void cs::sfile_metricclass::report ( sfile   elt,
double  val 
) const

Report a metric value to the hub.

Parameters
[in]eltThe element that the metric value is associated with.
[in]valThe value to report.
Returns
void

You do not need to call this method if the metric class was created with metricclass_flags::AUTO. In that case, CodeSonar will automatically report the values calculated using the operator() method of the metric_function<T> argument provided to sfile_metricclass_manager::create() when the class was created.

Exceptions
result::FILTERED_OUTif the sfile_metricclass is filtered out by a METRIC_FILTER discard rule.
result::ERROR_INVALID_PHASE_FOR_OPERATIONif called during a traversal phase that is not consistent with the metricclass_flags for the sfile_metricclass. See the metricclass_flags::POST_ANALYSIS documentation for more information.
result::ERROR_INVALID_SLAVE_OPERATIONif called from a CodeSonar slave process.

◆ retract()

void cs::sfile_metricclass::retract ( sfile   elt) const
inlineinherited

Retract a metric value.

Parameters
[in]eltThe element for which the value will be retracted.
Returns
void
Exceptions
result::ERROR_INVALID_SLAVE_OPERATIONif called from a CodeSonar slave process.
result::ELEMENT_NOT_PRESENTif retraction did not occur for any other reason.
result::ERROR_INVALID_PHASE_FOR_OPERATIONif called outside the drop traversal phase.

In typical usage, retract() is called during the drop traversal (that is, by a visitor added with one of the analysis add_*_drop_visitor() methods).

◆ tag()

std::string cs::sfile_metricclass::tag ( ) const
inlineinherited

Get the tag (short string identifier) for a metric class (sfile_metricclass).

Returns
The short tag, as a std::string.

The tag will usually be only a few characters long. Retrieve the metric class description with description() for a longer string that is generally more human-readable.

For example, CodeSonar ships with built-in project granularity metric class Include file instances.

  • its tag is "InclF"
  • its description is "Include file instances"

◆ value()

double cs::sfile_metricclass::value ( sfile   elt) const

Get the value of a metric.

Parameters
[in]eltThe element for which the metric value is required.
Returns
The metric value for elt.

You do not need to call this method if the metric class was created with metricclass_flags::AUTO. In that case, CodeSonar will automatically report the values calculated using the metric_function<T> argument provided to sfile_metricclass_manager::create() when the metric class was created.

Exceptions
result::FILTERED_OUTif the sfile_metricclass is filtered out by a METRIC_FILTER discard rule.
result::METRIC_NOT_COMPUTEDif a value for the metric has not been computed. This can happen if the sfile_metricclass was not created with metricclass_flags::AUTO and a value has not been reported with report(), or if the sfile_metricclass was not created with metricclass_flags::POST_ANALYSIS but value() is called during the serial depth-first traversal or parallel-depth first traversal.

Friends And Related Symbol Documentation

◆ operator!=()

bool operator!= ( const sfile_metricclass a,
const sfile_metricclass b 
)
related

Inequality operator for sfile_metricclass.

Parameters
[in]aThe sfile_metricclass object to compare.
[in]bThe sfile_metricclass object to compare against.
Returns
false if a equal to b according to sfile_metricclass::cmp() , true otherwise.

◆ operator<()

bool operator< ( const sfile_metricclass a,
const sfile_metricclass b 
)
related

Less-than operator for sfile_metricclass.

Parameters
[in]aThe sfile_metricclass object to compare.
[in]bThe sfile_metricclass object to compare against.
Returns
true if a < b according to sfile_metricclass::cmp() , false otherwise.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const sfile_metricclass a 
)
related

Print a representation of a sfile_metricclass object to the specified stream.

Parameters
[in]outThe stream to print to.
[in]aThe sfile_metricclass object to print.
Returns
void

◆ operator<=()

bool operator<= ( const sfile_metricclass a,
const sfile_metricclass b 
)
related

Less-than-or-equal operator for sfile_metricclass.

Parameters
[in]aThe sfile_metricclass object to compare.
[in]bThe sfile_metricclass object to compare against.
Returns
true if a <= b according to sfile_metricclass::cmp() , false otherwise.

◆ operator==()

bool operator== ( const sfile_metricclass a,
const sfile_metricclass b 
)
related

Equality operator for sfile_metricclass.

Parameters
[in]aThe sfile_metricclass object to compare.
[in]bThe sfile_metricclass object to compare against.
Returns
true if a equal to b according to cs::sfile_metricclass::cmp() , false otherwise.

◆ operator>()

bool operator> ( const sfile_metricclass a,
const sfile_metricclass b 
)
related

Greater-than operator for sfile_metricclass.

Parameters
[in]aThe sfile_metricclass object to compare.
[in]bThe sfile_metricclass object to compare against.
Returns
true if a > b according to sfile_metricclass::cmp() , false otherwise.

◆ operator>=()

bool operator>= ( const sfile_metricclass a,
const sfile_metricclass b 
)
related

Greater-than-or-equal operator for sfile_metricclass.

Parameters
[in]aThe sfile_metricclass object to compare.
[in]bThe sfile_metricclass object to compare against.
Returns
true if a >= b according to sfile_metricclass::cmp() , false otherwise.

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