|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef BBCANALYSER_H_ |
|
20 #define BBCANALYSER_H_ |
|
21 |
|
22 #ifdef __WIN__ |
|
23 #pragma warning(disable:4786) |
|
24 #endif |
|
25 #include <assert.h> |
|
26 #include <map> |
|
27 #include <list> |
|
28 #include "CmdGlobals.h" |
|
29 #include "ReportGenerator.h" |
|
30 #include "XMLUtils.h" |
|
31 #include "NodeIndex.h" |
|
32 #include "HANodeIterator.h" |
|
33 |
|
34 #include "HeaderAnalyser.h" |
|
35 #include "PreAnalysis.h" |
|
36 #include "NodeAnalysis.h" |
|
37 #include "BBCPreAnalysis.h" |
|
38 |
|
39 #include <xercesc/dom/DOM.hpp> |
|
40 |
|
41 using namespace std; |
|
42 |
|
43 XERCES_CPP_NAMESPACE_USE |
|
44 |
|
45 |
|
46 /** |
|
47 * The BBCAnalyser implements the HeaderAnalyser interface and includes the analysis |
|
48 * functionality. |
|
49 * |
|
50 * The BBCAnalyser includes two kinds of analysis. Firstly, some frequently used |
|
51 * properties of declarations are calculated and saved in XML document for usage |
|
52 * in further analysis. These are implemented in classes implementing the |
|
53 * PreAnalysis interface. |
|
54 * |
|
55 * Secondly, the declarations are analyzed by classes that implement the |
|
56 * NodeAnalysis interface. The idea is to have the top level NodeAnalysis to analyze |
|
57 * all global declarations and delegate the complex declarations to other |
|
58 * NodeAnalysis classes for further analysis. This enables the problem partitioning |
|
59 * in solvable units and keeps the analysis algorithms maintainable. |
|
60 */ |
|
61 class BBCAnalyser: public HeaderAnalyser |
|
62 { |
|
63 public: |
|
64 /** |
|
65 * Constructor |
|
66 * @param report reference to <code>ReportGenerator</code> |
|
67 */ |
|
68 BBCAnalyser(ReportGenerator & report); |
|
69 |
|
70 /** |
|
71 * Traverses recursively the parsed xml tree and analyses it. |
|
72 * @param baseline Pointer to the root of the baseline platform's xml output. |
|
73 * @param current Pointer to the root of the current platform's xml output. |
|
74 * @param filesToAnalyse List containing the filepairs to be analysed. |
|
75 * @return Error code, return code 0 means no error. |
|
76 */ |
|
77 int analyseTrees(DOMNode* baseline, DOMNode* current, const list< pair<string,string> >& filesToAnalyse, const list<string>& aMacroFiles); |
|
78 |
|
79 /** |
|
80 * This method does the actual analysis recursively for the nodes of the parser's xml output. |
|
81 * This method is called by <code>analyseTrees</code>. |
|
82 * @param baseline Iterator object pointing to the baseline platform's node. |
|
83 * @param current Iterator object pointing to the current platform's node. |
|
84 * @param filesToAnalyse List of the files to be analysed (ordered as pairs). |
|
85 * @return Error code, return code 0 means no error. |
|
86 */ |
|
87 int nodeAnalyseTrees(HANodeIterator baseline, HANodeIterator current, const list< pair<string,string> >& filesToAnalyse); |
|
88 |
|
89 /** |
|
90 * Destructor |
|
91 */ |
|
92 ~BBCAnalyser(){} |
|
93 |
|
94 private: |
|
95 /** |
|
96 * Check if there is empty files |
|
97 * @param Iterator pointing to the root node of the parsers xml output |
|
98 * @param filesToAnalyse List of files to analyse |
|
99 * @return Vector containing the boolean values, that indicate is the file in the |
|
100 * position empty or not. For example, if <code>vector<bool>[0]==true</code>, then |
|
101 * the first file in <code>filesToAnalyse</code> is empty. |
|
102 */ |
|
103 vector<bool> checkForEmptyFiles(HANodeIterator rootnode, const list<string>& filesToAnalyse, const list<string>& aMacroFiles); |
|
104 |
|
105 private: |
|
106 //! Preanalyse object |
|
107 BBCPreAnalysis preAnalysis; |
|
108 |
|
109 //! Baseline node index |
|
110 NodeIndex iBaselineIndex; |
|
111 |
|
112 //! Current node index |
|
113 NodeIndex iCurrentIndex; |
|
114 |
|
115 //! Reference to ReporGenerator object |
|
116 ReportGenerator& iReport; |
|
117 }; |
|
118 |
|
119 |
|
120 class UnderConstructionNodeAnalysis: public NodeAnalysis |
|
121 { |
|
122 public: |
|
123 /** |
|
124 * Constructor |
|
125 * @return pointer NodeAnalysis object |
|
126 */ |
|
127 static NodeAnalysis* Construct(); |
|
128 public: |
|
129 |
|
130 /** |
|
131 * Find node and analyse it |
|
132 * @param baseline to analyse |
|
133 * @param current to analyse |
|
134 * @return 0 if there was no issues |
|
135 */ |
|
136 int FindNodeAndAnalyse(HANodeIterator baseline,HANodeIterator current); |
|
137 |
|
138 /** |
|
139 * Analyse nodes |
|
140 * @param baseline to analyse |
|
141 * @param current to analyse |
|
142 * @param report true if analysed results are reported (default=true) |
|
143 * @return 0 if no issues found |
|
144 */ |
|
145 int Analyse(HANodeIterator baseline,HANodeIterator current, bool report = true); |
|
146 |
|
147 /** |
|
148 * Destructor |
|
149 */ |
|
150 ~UnderConstructionNodeAnalysis(){}; |
|
151 }; |
|
152 |
|
153 #endif |