CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
Public Member Functions | Private Attributes | Friends | List of all members
CCCC_Metric Class Reference

#include <cccc_met.h>

Collaboration diagram for CCCC_Metric:
[legend]

Public Member Functions

 CCCC_Metric ()
 
 CCCC_Metric (int n, const char *treatment_tag="")
 
 CCCC_Metric (int n, int d, const char *treatment_tag="")
 
void set_treatment (const char *code)
 
void set_ratio (float _num, float _denom=1.0)
 
EmphasisLevel emphasis_level () const
 
string code () const
 
string name () const
 
string value_string () const
 

Private Attributes

Metric_Treatmenttreatment
 
float numerator
 
float denominator
 

Friends

CCCC_Metricoperator+ (const CCCC_Metric &, const CCCC_Metric &)
 

Detailed Description

Definition at line 68 of file cccc_met.h.

Constructor & Destructor Documentation

CCCC_Metric::CCCC_Metric ( )

Definition at line 59 of file cccc_met.cc.

60 {
61  set_ratio(0,0);
62  set_treatment("");
63 }
void set_ratio(float _num, float _denom=1.0)
Definition: cccc_met.cc:80
void set_treatment(const char *code)
Definition: cccc_met.cc:75

Here is the call graph for this function:

CCCC_Metric::CCCC_Metric ( int  n,
const char *  treatment_tag = "" 
)

Definition at line 65 of file cccc_met.cc.

66 {
67  set_ratio(n,1); set_treatment(treatment_tag);
68 }
void set_ratio(float _num, float _denom=1.0)
Definition: cccc_met.cc:80
void set_treatment(const char *code)
Definition: cccc_met.cc:75

Here is the call graph for this function:

CCCC_Metric::CCCC_Metric ( int  n,
int  d,
const char *  treatment_tag = "" 
)

Definition at line 70 of file cccc_met.cc.

71 {
72  set_ratio(n,d); set_treatment(treatment_tag);
73 }
void set_ratio(float _num, float _denom=1.0)
Definition: cccc_met.cc:80
void set_treatment(const char *code)
Definition: cccc_met.cc:75

Here is the call graph for this function:

Member Function Documentation

string CCCC_Metric::code ( ) const

Definition at line 102 of file cccc_met.cc.

103 {
104  string retval;
105  if(treatment != NULL) { retval=treatment->code; }
106  return retval;
107 }
Metric_Treatment * treatment
Definition: cccc_met.h:69
EmphasisLevel CCCC_Metric::emphasis_level ( ) const

Definition at line 85 of file cccc_met.cc.

86 {
87  EmphasisLevel retval=elLOW;
89  {
91  {
92  retval=elHIGH;
93  }
95  {
96  retval=elMEDIUM;
97  }
98  }
99  return retval;
100 }
float denominator
Definition: cccc_met.h:70
Definition: cccc_met.h:27
Metric_Treatment * treatment
Definition: cccc_met.h:69
float lower_threshold
Definition: cccc_met.h:49
int numerator_threshold
Definition: cccc_met.h:56
EmphasisLevel
Definition: cccc_met.h:27
float numerator
Definition: cccc_met.h:70
float upper_threshold
Definition: cccc_met.h:49

Here is the caller graph for this function:

string CCCC_Metric::name ( ) const

Definition at line 109 of file cccc_met.cc.

110 {
111  string retval;
112  if(treatment != NULL) { retval=treatment->name; }
113  return retval;
114 }
Metric_Treatment * treatment
Definition: cccc_met.h:69
void CCCC_Metric::set_ratio ( float  _num,
float  _denom = 1.0 
)

Definition at line 80 of file cccc_met.cc.

81 {
82  numerator=_num; denominator=_denom;
83 }
float denominator
Definition: cccc_met.h:70
float numerator
Definition: cccc_met.h:70

Here is the caller graph for this function:

void CCCC_Metric::set_treatment ( const char *  code)

Definition at line 75 of file cccc_met.cc.

76 {
78 }
Metric_Treatment * treatment
Definition: cccc_met.h:69
string code() const
Definition: cccc_met.cc:102
static Metric_Treatment * getMetricTreatment(const string &metric_tag)
Definition: cccc_opt.cc:253

Here is the call graph for this function:

Here is the caller graph for this function:

string CCCC_Metric::value_string ( ) const

Definition at line 116 of file cccc_met.cc.

117 {
118  string retval;
119  char numerator_too_low='-';
120  char infinity='*';
121 
122  ostringstream valuestr;
123  valuestr.setf(std::ios::fixed);
124  int width=6, precision=0;
125  float n_threshold=0, low_threshold=1e9, high_threshold=1e9;
126  if(treatment!=NULL)
127  {
128  width=treatment->width;
129  precision=treatment->precision;
130  n_threshold=treatment->numerator_threshold;
131  low_threshold=treatment->lower_threshold;
132  high_threshold=treatment->upper_threshold;
133  }
134  valuestr.width(width);
135  valuestr.precision(precision);
136  if(numerator<n_threshold)
137  {
138  string too_low_string(width,numerator_too_low);
139  valuestr << too_low_string;
140  }
141  else if(denominator==0)
142  {
143  string infinity_string(width,infinity);
144  valuestr << infinity_string;
145  }
146  else
147  {
148  double result=numerator;
149  result/=denominator;
150  if(result!=0.0L)
151  {
152  // Visual C++ and GCC appear to give different behaviours
153  // when rounding a value which is exactly half way between
154  // two points representable in the desired format.
155  // An example of this occurs results from prn14, where the
156  // numerator 21 and denominator 16 are combined to give the
157  // value 1.2125 exactly, which Visual Studio renders as 1.213,
158  // GCC renders as 1.212. For consistency with the existing
159  // reference data, I choose to apply a very small downward
160  // rounding factor. The rounding factor is only applied if
161  // the value is not exactly equal to zero, as applying it
162  // to zero causes the value to be displayed as -0.0 instead
163  // of 0.0.
164  const double ROUNDING_FACTOR = 1.0e-9;
165  result-=ROUNDING_FACTOR;
166  }
167  valuestr << result;
168  }
169  retval=valuestr.str();
170  return retval;
171 }
float denominator
Definition: cccc_met.h:70
Metric_Treatment * treatment
Definition: cccc_met.h:69
float lower_threshold
Definition: cccc_met.h:49
int numerator_threshold
Definition: cccc_met.h:56
float numerator
Definition: cccc_met.h:70
float upper_threshold
Definition: cccc_met.h:49

Here is the caller graph for this function:

Friends And Related Function Documentation

CCCC_Metric& operator+ ( const CCCC_Metric ,
const CCCC_Metric  
)
friend

Member Data Documentation

float CCCC_Metric::denominator
private

Definition at line 70 of file cccc_met.h.

float CCCC_Metric::numerator
private

Definition at line 70 of file cccc_met.h.

Metric_Treatment* CCCC_Metric::treatment
private

Definition at line 69 of file cccc_met.h.


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