CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
cccc_met.h
Go to the documentation of this file.
1 /*
2  CCCC - C and C++ Code Counter
3  Copyright (C) 1994-2005 Tim Littlefair (tim_littlefair@hotmail.com)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 #ifndef __CCCC_MET_H
20 #define __CCCC_MET_H
21 
22 
23 #include <string>
24 #include "cccc_db.h"
25 #include "cccc_itm.h"
26 
28 
29 class CCCC_Html_Stream;
30 class CCCC_Metric;
31 
32 // the single class CCCC_Metric which will be defined later in this file
33 // will be used for all metrics
34 // differences in output formats will be handled by giving each object
35 // of type CCCC_Metric a pointer to a an object of type Metric_Treatment
36 // which will be held in a global array called Metric_Treatment_Table
38 {
39  friend class CCCC_Metric;
40  friend void add_treatment(CCCC_Item&);
42 
43  // a short code string is used to search for the metric treatment, and
44  // it has a full name
45  string code, name;
46 
47  // lower_threshold and upper_threshold are the levels at which the metric
48  // is interpreted as moving between low, medium and high emphasis levels
50 
51  // for ratio type metrics, we provide the facility for screening out of
52  // items for which the numerator lies below a given value
53  // e.g. we may impose a standard of 1 line of comment per 3 of code, but
54  // say that we do not require this standard to apply to routines shorter
55  // than 5 lines
57 
58  // preferred display width and number of decimal places
60 
61  public:
62  Metric_Treatment(CCCC_Item& treatment_line);
63 
64  friend class CCCC_Options;
65 };
66 
67 // the main metric class
68 class CCCC_Metric {
71  friend CCCC_Metric& operator+(const CCCC_Metric&, const CCCC_Metric&);
72  public:
73  CCCC_Metric();
74  CCCC_Metric(int n, const char* treatment_tag="");
75  CCCC_Metric(int n, int d, const char* treatment_tag="");
76  void set_treatment(const char* code);
77  void set_ratio(float _num, float _denom=1.0);
79  string code() const;
80  string name() const;
81  string value_string() const;
82 };
83 
84 
85 
86 #endif /* __CCCC_MET_H */
87 
88 
89 
90 
91 
92 
93 
94 
Metric_Treatment(CCCC_Item &treatment_line)
Definition: cccc_met.cc:31
float denominator
Definition: cccc_met.h:70
Definition: cccc_met.h:27
Metric_Treatment * treatment
Definition: cccc_met.h:69
void set_ratio(float _num, float _denom=1.0)
Definition: cccc_met.cc:80
string code() const
Definition: cccc_met.cc:102
EmphasisLevel emphasis_level() const
Definition: cccc_met.cc:85
string value_string() const
Definition: cccc_met.cc:116
friend void add_treatment(CCCC_Item &)
Definition: cccc_opt.cc:56
float lower_threshold
Definition: cccc_met.h:49
string name() const
Definition: cccc_met.cc:109
friend CCCC_Metric & operator+(const CCCC_Metric &, const CCCC_Metric &)
friend CCCC_Html_Stream & operator<<(CCCC_Html_Stream &, const CCCC_Metric &)
Definition: cccc_htm.cc:1026
int numerator_threshold
Definition: cccc_met.h:56
void set_treatment(const char *code)
Definition: cccc_met.cc:75
EmphasisLevel
Definition: cccc_met.h:27
float numerator
Definition: cccc_met.h:70
float upper_threshold
Definition: cccc_met.h:49