-
Notifications
You must be signed in to change notification settings - Fork 6
/
FileManager.h
155 lines (123 loc) · 5.05 KB
/
FileManager.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
/**
cpp2cxx is an open source software distributed under terms of the
Apache2.0 licence.
Copyrights remain with the original copyright holders.
Use of this material is by permission and/or license.
Copyright [2012] Aditya Kumar, Andrew Sutton, Bjarne Stroustrup
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef FILEMANAGER_H
#define FILEMANAGER_H
/**
* @file FileManager.h
* @brief maintains the files, directories.
* acts as an interface which can be used to get input files one by one
* or all at a time. also provides the interface to write to an output file
* @version 1.0
* @author Aditya Kumar
* @note
* compiles with g++-4.5 or higher,
* for compiling pass -std=c++0x to the compiler
*/
#include<vector>
#include<string>
#include<fstream>
#include<iostream>
//depending upon the demacrofication scheme the demacrofier should
//return to the subject class which should call the FileManager for file handling
/**
* @class FileManagerScheme
* @brief forward declaration
*/
class FileManagerScheme;
/**
* @class DemacroficationScheme
* @brief forward declaration
*/
class DemacroficationScheme;
/**
* @class OverSeer
* @brief forward declaration
*/
class Overseer;
/**
* @class FileManager
* @brief will be responsible for maintaining all the files that are required
* to be demacrofied and
*/
class FileManager {
public:
/// @function FileManager(FileManagerScheme const& fs)
/// @brief constructor takes the file scheme FileManagerScheme
/// uses the FileManagerScheme to configure the settings
/// configuration can also be changed using the Configure function.
FileManager(FileManagerScheme const& fs, DemacroficationScheme const& ds);
/// @brief uses the FileManagerScheme to configure the settings
void Configure(FileManagerScheme const& fs);
/// @brief performs checks etc., not implemented as of now
/// check if the directory exists or not, if the files
/// in the list are actually found or not
bool SanityCheck();
//
//not useful as of now
/*
FileManager(std::vector<std::string> const& input_files,
std::vector<std::string> const& output_files,
std::string const& input_directory,
std::string const& output_directory,
std::string const& backup_directory);
//not useful as of now
FileManager(std::vector<std::string> const& input_files,
std::vector<std::string> const& output_files,
std::string const& backup_directory);
//not useful as of now
FileManager(std::vector<std::string> const& input_files);
*/
std::vector<std::string>const& OutputFiles();
std::vector<std::string>const& InputFiles();
std::string const& OutputDirectory();
std::string const& InputDirectory();
//check whether this file is there in the list of output_files or not
void UpdateFile(std::string const& file_str);
void UpdateFile(std::ostream& fp, std::string const& file_str);
/// @brief observer, gets updated whenever a new file is demacrofied
void UpdateFile(Overseer const& overseer);
/// @brief returns the list of input files
std::vector<std::string> const& GetInputFiles() const;
/// @brief returns the output file which will be updated in the
/// current iteration
std::string GetOutputFile();
/// @brief returns the search paths
std::vector<std::string> const& GetSearchPaths() const;
/// @brief writes the string to the log file fileManagerScheme.pConfigFile
void WriteLog(std::string const& str);
/// @brief writes the header to the stat file
void PrepareMacroStatFile();
/// @brief writes the header to the demacrofied macro stat file
void PrepareDemacrofiedMacroStatFile();
/// @brief returns the reference to the pLogFile where the messages
/// can be logged
std::ostream& GetLogFile();
/// @brief returns the reference to the pListMacroFile where the macros
/// can be listed
std::ostream& GetMacroStatFile();
/// @brief returns the reference to the pDemacrofiedMacroStatFile
/// where the list of macros and related information can be logged
std::ostream& GetDemacrofiedMacroStatFile();
private:
/// @var reference to the fileManagerScheme
FileManagerScheme const& fileManagerScheme;
DemacroficationScheme const& demacroficationScheme;
/// @todo try to make a map from input files to output files
unsigned int inputFileIndex;
unsigned int outputFileIndex;
};
#endif /*FILEMANAGER_H*/