-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataStore.h
executable file
·156 lines (102 loc) · 4.57 KB
/
DataStore.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
#ifndef DATASTORE_H
#define DATASTORE_H
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DataStore.h (ver 1.0) - Hold all the Static Data required to be stored for analysis. //
// //
// 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 will define and declare all the static data structure that will be required for analysis.
TypeTable : Key - Fully Qualified Name.
TypeTable : Value - TypeItem [ fileName - package name - lineNumber ]
parse_mode : FIRST_PASS : Pass 1 -> Functionality to add to TypeTable Enabled in ActionsAndRules.cpp
parse_mode : SECOND_PASS : Pass 2 -> Functionality to add to TypeTable Disabled in ActionsAndRules.cpp
currentPackageName : Hold the package name of the current package being analyzed.
currentFileName : Hold the file name of the file being analyzed.
curr_function_cyclo : Keep track of Cyclomatic Complexity for current control block.
depth_scope_nesting : Keep track of Depth Scope Nesting for current file.
current_file_size : Keep track of number of lines parsed. Finally gives line count for file.
namespaceList : List of all the files and namespaces used in the file.
fileSizeList : List of all the files along with the size of each file.
Public Interface:
=================
Get - Set methods for all static data.
DataStore::addTypeToTypeTable("variable",ti);
bool find = DataStore::findKeyInTypeTable("varialbe");
Build Process:
==============
Required files
- DataStore.cpp
Build commands
- devenv CodeMetricsAnalyzer.sln /rebuild debug
Maintenance History:
====================
ver 1.0 : 25 Feb 11
*/
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <map>
class TypeItem{
std::string fileName;
std::string packageName;
int lineNumber;
public :
void setFileName(std::string);
std::string getFileName();
void setpackageName(std::string);
std::string getpackageName();
void setLineNumber(int);
int getLineNumber();
};
inline void TypeItem::setFileName(std::string fn){ fileName = fn; }
inline std::string TypeItem::getFileName(){ return fileName; }
inline void TypeItem::setpackageName(std::string fq){ packageName = fq; }
inline std::string TypeItem::getpackageName(){ return packageName; }
inline void TypeItem::setLineNumber(int ln){ lineNumber = ln; }
inline int TypeItem::getLineNumber(){ return lineNumber; }
class DataStore {
public:
enum mode { FIRST_PASS,SECOND_PASS } ;
static bool findKeyInTypeTable(std::string);
static TypeItem getTypeItemFromTypeTable(std::string);
static void setcurrentPackageName(std::string);
static std::string getcurrentPackageName();
static void setcurrentFileName(std::string);
static std::string getcurrentFileName();
static void setCurr_function_cyclo(int);
static int getCurr_function_cyclo();
static void Increment_Cyclo();
static void setDepth_scope_nesting(int);
static int getDepth_scope_nesting();
static void setCurrent_File_Size(int);
static int getCurrent_File_Size();
static void setParseMode(DataStore::mode);
static mode DataStore::getParseMode();
static void InsertNamespace(std::string,std::string);
static std::vector<std::string> GetNamespace(std::string);
static void InsertFileSize(std::string,int);
static int GetFileSize(std::string);
static void addTypeToTypeTable(std::string,TypeItem);
static void printDetectedTypes(std::string);
static void DataStore::printNamespace(std::string);
private:
static mode parse_mode;
static std::string currentPackageName;
static std::string currentFileName;
static int curr_function_cyclo;
static int depth_scope_nesting;
static int current_file_size;
static std::vector<std::pair<std::string,std::string>> namespaceList;
static std::vector<std::pair<std::string,int>> fileSizeList;
static std::map<std::string,TypeItem> TypeTable;
};
#endif