-
Notifications
You must be signed in to change notification settings - Fork 0
/
Package.h
executable file
·312 lines (214 loc) · 8.62 KB
/
Package.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#ifndef PACKAGE_H
#define PACKAGE_H
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Package.h (ver 1.0) - Class to hold information about each package ( .h + .cpp ) file. //
// //
// Language : Visual C++, 2010 //
// Platform : Toshiba Satellite (R25-S3503), Windows 7 Professional //
// Application : CSE687 - Project #1 - CodeMetricsAnalyzer, Spring 2011 //
// Author : Harshal Bhakta, Syracuse University. //
// E-mail : harshal.c.bhakta@gmail.com //
// Cell : 714-876-4273 //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
Module Operations:
==================
This module defines a Package class that will hold the information related to each package.
Part 1 ) Function
Part 2 ) Variable
Part 3 ) Control
This module will basically hold the information related to the above mentioned parts. The
statistics related to the analysis of the header and the source files will be stored in
the sub modules.
Function : Holds information related to the functions detected.
Function Name - no_of_lines - cyclo_complexity - scope - from_line - to_line;
Variable : Holds information related to the variables detected.
Variable Name - fromFile - fromLine - toFile - toLine - loc_reference - ref_density
Control : Holds informaiton related to the controls detected.
Control Name - breadthControlSpan - scope - from_line - to_line
Public Interface:
=================
Package pk;
Function fk;
fk.setFunctionName("Test");
fk.setNoOfLines(12);
fk.setDepthOfNesting(20);
fk.setCycloComplexity(15);
Variable vb;
vb.setVariableName("LocOfReference");
vb.setLocReference(20);
vb.setRefDensity(5);
Control ct;
ct.setControlName("For");
pk.addFunction(fk);
pk.addControl(ct);
pk.addVariable(vb);
Build Process:
==============
Required files
- Package.cpp
Build commands
- devenv CodeMetricsAnalyzer.sln /rebuild debug
Maintenance History:
====================
ver 1.0 : 25 Feb 11
*/
#include <string>
#include <vector>
///////////////////////////////////////////////////////////////
// Class to hold information relate the function.
class Function
{
public :
std::string getFunctionName();
void setFunctionName(std::string);
int getNoOfLines();
void setNoOfLines(int);
int getCycloComplexity();
void setCycloComplexity(int);
std::string getScope();
void setScope(std::string);
int getFromLine();
void setFromLine(int);
int getToLine();
void setToLine(int );
Function();
private :
std::string name;
int no_of_lines;
int cyclo_complexity;
std::string scope;
int from_line;
int to_line;
};
inline Function::Function() : name("XXXXX"),no_of_lines(0),cyclo_complexity(0),scope("XXXXX"),from_line(0),to_line(0) {}
inline std::string Function::getFunctionName() { return name; }
inline void Function::setFunctionName(std::string nm) { name = nm; }
inline int Function::getNoOfLines() { return no_of_lines; }
inline void Function::setNoOfLines(int lines) { no_of_lines = lines; }
inline int Function::getCycloComplexity() { return cyclo_complexity; }
inline void Function::setCycloComplexity(int cyclo) { cyclo_complexity = cyclo; }
inline std::string Function::getScope() { return scope; }
inline void Function::setScope(std::string sc) { scope = sc; }
inline int Function::getFromLine() { return from_line; }
inline void Function::setFromLine(int frm) { from_line = frm; }
inline int Function::getToLine() { return to_line; }
inline void Function::setToLine(int tl) { to_line = tl; }
///////////////////////////////////////////////////////////////
// Class to hold information related to variables.
class Variable
{
public :
std::string getVariableName();
void setVariableName(std::string);
std::string getFromFileName();
void setFromFileName(std::string);
int getFromFileLine();
void setFromFileLine(int);
std::string getToFileName();
void setToFileName(std::string);
int getToFileLine();
void setToFileLine(int);
int getLocReference();
void setLocReference(int);
int getRefDensity();
void setRefDensity(int);
Variable();
private :
std::string name;
std::string fromFile;
int fromLine;
std::string toFile;
int toLine;
int loc_reference;
int ref_density;
};
inline Variable::Variable() : name("XXXXX"),fromFile("XXXXX"),fromLine(0),toFile("XXXXX"),toLine(0),loc_reference(0),ref_density(0)
{}
inline std::string Variable::getVariableName() { return name; }
inline void Variable::setVariableName(std::string nm) { name = nm; }
inline std::string Variable::getFromFileName() { return fromFile; }
inline void Variable::setFromFileName(std::string ff) { fromFile = ff; }
inline int Variable::getFromFileLine() { return fromLine; }
inline void Variable::setFromFileLine(int fl) { fromLine = fl; }
inline std::string Variable::getToFileName() { return toFile; }
inline void Variable::setToFileName(std::string tf) { toFile = tf; }
inline int Variable::getToFileLine() { return toLine; }
inline void Variable::setToFileLine(int tl) { toLine = tl; }
inline int Variable::getLocReference() { return loc_reference; }
inline void Variable::setLocReference(int loc) { loc_reference = loc; }
inline int Variable::getRefDensity() { return ref_density; }
inline void Variable::setRefDensity(int density) { ref_density = density; }
///////////////////////////////////////////////////////////////
// Class to hold information related to Control.
class Control
{
public :
std::string getControlName();
void setControlName(std::string);
int getBreadthControlSpan();
void setBreadthControlSpan(int);
std::string getScope();
void setScope(std::string);
int getFromLine();
void setFromLine(int);
int getToLine();
void setToLine(int );
Control();
private :
std::string name;
int breadthControlSpan;
std::string scope;
int from_line;
int to_line;
};
inline Control::Control() : name("XXXXX"),breadthControlSpan(0),scope("XXXXX"),from_line(0),to_line(0) {}
inline std::string Control::getControlName() { return name; }
inline void Control::setControlName(std::string nm) { name = nm; }
inline int Control::getBreadthControlSpan() { return breadthControlSpan; }
inline void Control::setBreadthControlSpan(int bcs) { breadthControlSpan = bcs; }
inline std::string Control::getScope() { return scope; }
inline void Control::setScope(std::string sc) { scope = sc; }
inline int Control::getFromLine() { return from_line; }
inline void Control::setFromLine(int frm) { from_line = frm; }
inline int Control::getToLine() { return to_line; }
inline void Control::setToLine(int tl) { to_line = tl; }
///////////////////////////////////////////////////////////////
// Class to hold information related to function,variables & controls.
// A list will be maintined.
class Package
{
public :
void addControl(Control);
void addFunction(Function);
void addVariable(std::string,std::string, std::string ,int,std::string,int,int);
int getDepthOfNesting();
void setDepthOfNesting(int);
std::string getSourceFile();
void setSourceFile(std::string);
std::string getHeaderFile();
void setHeaderFile(std::string);
std::vector<Variable> getVariableListPrint();
std::vector<Function> getFunctionList();
std::vector<Control> getControlList();
private :
std::vector<Variable>* getVariableList();
std::vector<Variable> VariableList;
std::vector<Function> FunctionList;
std::vector<Control> ControlList;
int number_of_identifiers;
int depth_of_nesting;
std::string header_file;
std::string source_file;
};
inline std::vector<Variable>* Package::getVariableList() { return &VariableList; }
inline std::vector<Variable> Package::getVariableListPrint() { return VariableList; }
inline std::vector<Function> Package::getFunctionList() { return FunctionList; }
inline std::vector<Control> Package::getControlList() { return ControlList; }
inline int Package::getDepthOfNesting() { return depth_of_nesting; }
inline void Package::setDepthOfNesting(int depth) { depth_of_nesting = depth; }
inline std::string Package::getSourceFile(){ return source_file; }
inline void Package::setSourceFile(std::string src) { source_file = src ;}
inline std::string Package::getHeaderFile(){ return header_file; }
inline void Package::setHeaderFile(std::string hd){ header_file = hd; }
#endif