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

A project 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 project_metricclass object that includes information useful for debugging. More...
 
std::string as_string () const
 Get a simple string representation of a project_metricclass object. More...
 
int cmp (const project_metricclass &other) const
 Comparison function for project_metricclass, with respect to a stable overall ordering. More...
 
std::string description () const
 Get the description (longer, human readable identifier) for a metric class (project_metricclass). More...
 
metricclass_flags flags () const
 Get the metricclass_flags for a project_metricclass. More...
 
cs_hash_t hash () const
 Get a hash value for this project_metricclass. More...
 
void report (project elt, double val) const
 Report a metric value to the hub. More...
 
void retract (project elt) const
 Retract a metric value. More...
 
std::string tag () const
 Get the tag (short string identifier) for a metric class (project_metricclass). More...
 
double value (project elt) const
 Get the value of a metric. More...
 

Related Functions

(Note that these are not member functions.)

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

Detailed Description

A project granularity metric class.

The project granularity metric classes are managed by project_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::project_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 project_metricclass::always_discarded().

◆ always_discarded()

bool cs::project_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 project_metricclass::allowed.

◆ as_repr()

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

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

Returns
The string representation.

◆ as_string()

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

Get a simple string representation of a project_metricclass object.

Returns
The string representation.

◆ cmp()

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

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

Parameters
otherThe project_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 project_metricclass object.

◆ description()

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

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

◆ hash()

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

Get a hash value for this project_metricclass.

◆ report()

void cs::project_metricclass::report ( project   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 project_metricclass_manager::create() when the class was created.

Exceptions
result::FILTERED_OUTif the project_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 project_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::project_metricclass::retract ( project   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::project_metricclass::tag ( ) const
inlineinherited

Get the tag (short string identifier) for a metric class (project_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::project_metricclass::value ( project   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 project_metricclass_manager::create() when the metric class was created.

Exceptions
result::FILTERED_OUTif the project_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 project_metricclass was not created with metricclass_flags::AUTO and a value has not been reported with report(), or if the project_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 Function Documentation

◆ operator!=()

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

Inequality operator for project_metricclass.

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

◆ operator<()

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

Less-than operator for project_metricclass.

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

◆ operator<<()

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

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

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

◆ operator<=()

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

Less-than-or-equal operator for project_metricclass.

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

◆ operator==()

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

Equality operator for project_metricclass.

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

◆ operator>()

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

Greater-than operator for project_metricclass.

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

◆ operator>=()

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

Greater-than-or-equal operator for project_metricclass.

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

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