1 /*
2  * This file is part of the FortranProject plugin for Code::Blocks IDE
3  * and licensed under the GNU General Public License, version 3
4  * http://www.gnu.org/licenses/gpl-3.0.html
5  *
6  * Author: Darius Markauskas
7  *
8  */
9 
10 #ifndef PROJECTDEPENDENCIES_H
11 #define PROJECTDEPENDENCIES_H
12 
13 #include <sdk.h>
14 #ifndef CB_PRECOMP
15     #include <cbproject.h>
16 #endif
17 #include <set>
18 #include <vector>
19 #include <map>
20 
21 #include "parserf.h"
22 
23 typedef std::vector<StringSet*> StringSetPVector;
24 typedef std::map<wxString,int> StringIntMap;
25 typedef std::map<int,wxString> IntStringMap;
26 typedef std::set<int> IntSet;
27 typedef std::vector<IntSet*> PointersToIntSet;
28 typedef std::vector<ProjectFile*> ProjectFilesArray;
29 typedef std::vector<bool> BoolVector;
30 
31 class NativeParserF;
32 
33 
34 class ProjectDependencies
35 {
36     public:
37         ProjectDependencies(cbProject* project);
38         virtual ~ProjectDependencies();
39         void Clear();
40         void MakeProjectFilesDependencies(ProjectFilesArray& prFilesArr, ParserF& parser);
41         unsigned short int GetFileWeight(wxString& fileName);
42         void EnsureUpToDateObjs();
43         bool HasInfiniteDependences();
44         size_t GetSizeFiles();
45         static void RemoveModFiles(cbProject* pr, ProjectBuildTarget* bTarget, NativeParserF* nativeParser);
46         static void RemoveModFilesWS(NativeParserF* nativeParser);
47         void GetUseFilesFile(const wxString& filename, wxArrayString& use);
48         void GetExtendsFilesFile(const wxString& filename, wxArrayString& extFiles);
49         void GetIncludeFilesFile(const wxString& filename, wxArrayString& includesFile);
50 
51     protected:
52     private:
53         unsigned short int GetFileWeightByIndex(size_t idx);
54         void MakeFileChildren(IntSet* children, size_t fileIndex);
55 
56         cbProject* m_Project;
57         ProjectFilesArray m_prFilesArr;
58     	StringSetPVector m_pUseModules;
59         StringSetPVector m_pDeclaredModules;
60         StringSetPVector m_pExtendsSModules;
61         StringSetPVector m_pDeclaredSubmodules;
62         StringSetPVector m_pIncludes;
63         StringIntMap m_FileIndexMap;
64         StringIntMap m_ModuleFileIdxMap;
65         StringIntMap m_SubmoduleFileIdxMap;
66         StringIntMap m_IncludeFileIdxMap;
67         PointersToIntSet m_ChildrenTable;
68         int m_Deep;
69         bool m_WasInfiniteLoop;
70         bool m_BreakChain;
71         wxArrayInt m_FileWeights;
72         BoolVector m_MadeChildrenSet;
73 
74         void PrintChildrenTable();
75 };
76 
77 #endif // PROJECTDEPENDENCIES_H
78