~ubuntu-branches/ubuntu/utopic/cccc/utopic

« back to all changes in this revision

Viewing changes to cccc/cccc_met.h

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2003-08-23 04:34:05 UTC
  • Revision ID: james.westby@ubuntu.com-20030823043405-xnzd3mn3hwtvi6dr
Tags: upstream-3.pre81
ImportĀ upstreamĀ versionĀ 3.pre81

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __CCCC_MET_H
 
2
#define __CCCC_MET_H
 
3
 
 
4
 
 
5
#include <string>
 
6
#include "cccc_db.h"
 
7
#include "cccc_itm.h"
 
8
 
 
9
enum EmphasisLevel { elLOW=0, elMEDIUM=1, elHIGH=2 };
 
10
 
 
11
class CCCC_Html_Stream;
 
12
 
 
13
// the single class CCCC_Metric which will be defined later in this file 
 
14
// will be used for all metrics
 
15
// differences in output formats will be handled by giving each object
 
16
// of type CCCC_Metric a pointer to a an object of type Metric_Treatment
 
17
// which will be held in a global array called Metric_Treatment_Table
 
18
class Metric_Treatment
 
19
{
 
20
  friend class CCCC_Metric;
 
21
  friend void add_treatment(CCCC_Item&);
 
22
  friend CCCC_Html_Stream& operator <<(CCCC_Html_Stream&,const CCCC_Metric&);
 
23
 
 
24
  // a short code string is used to search for the metric treatment, and
 
25
  // it has a full name
 
26
  string code, name;
 
27
  
 
28
  // lower_threshold and upper_threshold are the levels at which the metric
 
29
  // is interpreted as moving between low, medium and high emphasis levels
 
30
  float lower_threshold, upper_threshold;
 
31
  
 
32
  // for ratio type metrics, we provide the facility for screening out of 
 
33
  // items for which the numerator lies below a given value
 
34
  // e.g. we may impose a standard of 1 line of comment per 3 of code, but
 
35
  // say that we do not require this standard to apply to routines shorter
 
36
  // than 5 lines
 
37
  int numerator_threshold;
 
38
  
 
39
  // preferred display width and number of decimal places
 
40
  int width, precision;
 
41
 
 
42
 public:  
 
43
  Metric_Treatment(CCCC_Item& treatment_line);
 
44
 
 
45
  friend class CCCC_Options;
 
46
};
 
47
 
 
48
// the main metric class
 
49
class CCCC_Metric {
 
50
  Metric_Treatment* treatment;
 
51
  float numerator, denominator;
 
52
  friend CCCC_Metric& operator+(const CCCC_Metric&, const CCCC_Metric&);
 
53
 public:
 
54
  CCCC_Metric();
 
55
  CCCC_Metric(int n, const char* treatment_tag="");
 
56
  CCCC_Metric(int n, int d, const char* treatment_tag="");
 
57
  void set_treatment(const char* code);
 
58
  void set_ratio(float _num, float _denom=1.0);
 
59
  EmphasisLevel emphasis_level() const;
 
60
  string code() const;
 
61
  string name() const;
 
62
  string value_string() const;
 
63
};
 
64
    
 
65
 
 
66
    
 
67
#endif /* __CCCC_MET_H */
 
68
 
 
69
 
 
70
 
 
71
 
 
72
 
 
73
 
 
74
 
 
75