home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / contrib / datatype.h next >
C/C++ Source or Header  |  1998-10-16  |  7KB  |  159 lines

  1. /*****************************************************************************
  2.   Module : DataType.h
  3.   Contents : Holds data type declarations for robust
  4.   Robust makes use of a number of different data types. All these declarations
  5.   are used by the numerics portion of the program. The Parameters structure
  6.   is also included, as it store stae information about a program.
  7. *****************************************************************************/
  8. #ifndef DATATYPES
  9. #define DATATYPES
  10.  
  11. #include <stdlib.h>
  12.  
  13. //The possible types of data held by a FailureDataSet object
  14. enum DataType { Empty, Failure_Time, Failure_Interval, SRGModel };
  15.  
  16. //The possible data types that could be held by a FailureDataSet or
  17. //CoverageDataSet object. Used by Robust when retaining state information.
  18. //Not all model types are used by the program
  19. enum modtype { Exponential, Logarithmic, Power, DelayedS, Littlewood,
  20.            Static, Coverage, Mixed, User_Defined, NotPresent };
  21.  
  22. /****************************************************************************
  23.   Structure : FailureDataPoint
  24.   Purpose : Encapsulates a single data point in a failure data set. This
  25.   is primarly a helper class for FailureDataSet.
  26. **************************************************************************/
  27. struct FailureDataPoint
  28. {
  29.   double count;
  30.   float time,interval;
  31.   double intensity;
  32. };
  33.  
  34. /****************************************************************************
  35.   Class : FailureDataSet
  36.   Purpose : Encapsulates a set of failure data. This data can be from a model,
  37.   actual project data, or a smoothed version of that data.
  38. ****************************************************************************/
  39.  
  40. class FailureDataSet
  41. {
  42.   void FillInterval(void);    //Method to fill interval data
  43.   void FillTime(void);        //Method to fill time data
  44.   void FillIntensity(void);   //Compute intensity of the data set
  45. public:
  46.   int Size;                          //Number of data points
  47.   char* FileName;                    //Name of file that held original data
  48.   DataType Type;                     //Type of data held
  49.   FailureDataPoint* Failure_Data;    //Pointer to array of failure data
  50.   
  51.   FailureDataSet(void);      //Constructor
  52.   ~FailureDataSet(void);     //Destructor
  53.   FailureDataPoint& operator[](int);
  54.   int OpenFile(char*);       //Method to load data from a file
  55.   int SaveFile(char* = NULL);//Method to save data back to a file
  56.   int SetSize(int);           //Method to change the number of data points
  57.   void Shrink(void);          //Method to shirnk Failure_Data to size
  58.   int Fill(void);             //Method to autofill data
  59. };
  60.  
  61. /****************************************************************************
  62.   Class : StaticMetrics
  63.   Purpose : This class encapsulates a set of static metrics. This should
  64.   probably be defined as a struct, but g++ seems to have trouble with
  65.   member functions for structs.
  66. ****************************************************************************/
  67.  
  68. class StaticMetrics
  69. {
  70. public:
  71.   float Constant;            //Experimentally determined constant
  72.   float Structure;          //The complexity of the project
  73.   float Phase;               //The development phase of the project
  74.   float Prog_Team;           //Average programmer experince, in years
  75.   float Maturity;            //Maturity of the development process
  76.   float CPUrate;             //Testing CPU instruction rate (MIPS)
  77.   float Instructions;        //Average object instructions per line
  78.   float Size;                //Code size in KLOC
  79.   float Time;             //Time to run the model for
  80.   double Alpha;              //These are parameters supplied by the user
  81.   int EstType;
  82.  
  83.   StaticMetrics(void);
  84.   double DefectDensity(void);
  85. };
  86.  
  87. /*******************************************************************
  88.   Class : FailureDataPoint
  89.   Purpose : Encapsulates a single data point in a coverage data set.
  90.   This is primarly a helper class for CoverageDataSet.
  91. *******************************************************************/
  92. class CoverageDataPoint
  93. {
  94.  public:
  95.   double faults; //The number of faults found
  96.   double branch; //These remaining four members are percentage of
  97.   double block; //of coverage obtained when a particular fault was found
  98.   double p_use;
  99.   double c_use;
  100.  
  101.   double map(int); //returns the value of the corresponding enumerable
  102. };
  103.  
  104. /**********************************************************************
  105.   Class : CoverageDataSet
  106.   Purpose : CoverageDataSet encapsulates coverage information about a
  107.   program.
  108. **********************************************************************/
  109. class CoverageDataSet {
  110. public:
  111.   int Size; //The number of data points available
  112.   CoverageDataPoint* cov_data; //Array of data points
  113.   int avail[5]; //boolean array telling if an enumerable is available
  114.   char* FileName; //The name of the file the data was read from, if any
  115.  
  116.   CoverageDataSet(int = 0); //Constructor
  117.   ~CoverageDataSet(void); //Destructor
  118.   int OpenFile(char*); //Routine to read in a coverage data set from CDS file
  119.   int Shrink(void); //Reduce memory used to only what is necessary
  120. };
  121.  
  122. /**************************************************************************
  123.   Sturcture : Parameters
  124.   Purpose : Parameters maintains sate information about the robust program.
  125.   It stores information about the last modeling function used, and what
  126.   data sets are currently being displayed, and the parameters used by the
  127.   models, ect... It is a convient place to put variables without having to
  128.   make them global. (Note: All V programs have global access theApp, a
  129.   pointer to the application class. The robust version of this class contains
  130.   the only instance of this variable, so they are in fact global.)
  131. **************************************************************************/
  132.  
  133. struct Parameters {
  134.   char title[16];
  135.   char mname[24];
  136.   double beta0,beta1; //Parameters used to fit SRGM models
  137.   double alpha0,alpha1,alpha2; //Parameters used to fit coverage models
  138.   double cntbias,intenbias; //Bias of the models
  139.   double mre; // Error of the SRGM model
  140.   modtype mtype; //Type of model currently in use
  141.   int recalibrated; //Wheather or not the model is recalibrated
  142.   int recalibrate; //Tells whether or not new models should be recalibrated
  143.   int stabilize; //Tells whether or not new models should be stabilized
  144.   double laplace; //The trend present in the data
  145.   int data1,data2; //The data sets on display in the text windows of robust
  146.   //Pointers to the modeling functions currently in use
  147.   void (*modfunc)(double, double, double, double&, double&);
  148.   int (*fitfunc)(FailureDataSet*, double&, double&);
  149.   void (*predfunc)(double, double, double&, double&, double&);
  150.   int (*statfunc)(StaticMetrics,double&,double&);
  151. };
  152. #endif
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.