CodeSonar C++ API
[For improved navigation, enable JavaScript.]
Public Member Functions | Related Functions | List of all members
cs::procedure_metricclass Class Reference

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

Related Functions

(Note that these are not member functions.)

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

Detailed Description

A procedure granularity metric class.

The procedure granularity metric classes are managed by procedure_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::procedure_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 procedure_metricclass::always_discarded().

◆ always_discarded()

bool cs::procedure_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 procedure_metricclass::allowed.

◆ as_repr()

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

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

Returns
The string representation.

◆ as_string()

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

Get a simple string representation of a procedure_metricclass object.

Returns
The string representation.

◆ cmp()

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

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

Parameters
otherThe procedure_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
this and other will only compare equal if they are the same procedure_metricclass object.

◆ description()

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

Get the description (longer, human readable identifier) for a metric class (procedure_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::procedure_metricclass::flags ( ) const
inlineinherited

◆ hash()

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

Get a hash value for this procedure_metricclass.

◆ report()

cs::procedure_metricclass::report ( procedure   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 procedure_metricclass_manager::create() when the class was created.

Exceptions
result::FILTERED_OUTif the procedure_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 procedure_metricclass. See the metricclass_flags::POST_ANALYSIS documentation for more information.
result::ERROR_INVALID_SLAVE_OPERATIONif called from a CodeSonar slave process.
result::NO_POSITIONif elt has kind procedure_kind::UNDEFINED or its entry point does not have a position.

◆ retract()

void cs::procedure_metricclass::retract ( procedure   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::procedure_metricclass::tag ( ) const
inlineinherited

Get the tag (short string identifier) for a metric class (procedure_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()

cs::procedure_metricclass::value ( procedure   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 procedure_metricclass_manager::create() when the metric class was created.

Exceptions
result::FILTERED_OUTif the procedure_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 procedure_metricclass was not created with metricclass_flags::AUTO and a value has not been reported with report(), or if the procedure_metricclass was not created with metricclass_flags::POST_ANALYSIS but value() is called during the serial depth-first traversal or parallel-depth first traversal.
result::NO_SOURCE_CORRESPONDENCEif elt does not have kind procedure_kind::USER_DEFINED, or if its entry point does not have a position.

Friends And Related Function Documentation

◆ operator!=()

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

Inequality operator for procedure_metricclass.

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

◆ operator<()

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

Less-than operator for procedure_metricclass.

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

◆ operator<<()

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

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

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

◆ operator<=()

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

Less-than-or-equal operator for procedure_metricclass.

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

◆ operator==()

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

Equality operator for procedure_metricclass.

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

◆ operator>()

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

Greater-than operator for procedure_metricclass.

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

◆ operator>=()

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

Greater-than-or-equal operator for procedure_metricclass.

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

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