]> Creatis software - creaEnvironment.git/blob - lib/kernel_Environment/ReaderEnvironment.h
2e497fc3f8a397665a23ee72b91e640f422eb958
[creaEnvironment.git] / lib / kernel_Environment / ReaderEnvironment.h
1 //      MACRO
2 #ifndef __READERENVIRONMENT_H_INCLUDED__
3 #define __READERENVIRONMENT_H_INCLUDED__
4
5 // SYSTEM INCLUDES
6
7 // PROJECT INCLUDES
8 #include <map>
9 #include <iostream>
10 #include <string>
11 #include <fstream>
12
13 // LOCAL INCLUDES
14 //#ifndef __INSTANTHANDLER_H_INCLUDED
15 #include "InstantHandler.h"
16 //#endif
17
18 // FORWARD REFERENCES
19
20 /*
21 *       COMMENT
22 *       @param
23 *       @return
24 */
25
26
27
28 template<class T>
29 class ReaderEnvironment
30                 {
31                                 public:
32
33                                         //=========== CONSTANTS ==============
34                                          std::string NUMCONCEPTS;
35                                          std::string CONCEPT;
36                                          std::string OBJECT;
37                                          std::string NUMOBJECTS;
38                                          std::string NAME;
39                                          std::string SIZE;
40                                          std::string PATH;
41                                          std::string INSTANT;
42                                          std::string NUMINSTANTS;
43                                          std::string RANGE;
44                                          std::string COMMENT;
45                                          std::string EQUAL;
46                                          std::string POINT;
47                                          std::string ALL;
48
49                                         //====== LIFECYCLE ========
50                                         
51                                         ReaderEnvironment(std::string nameConfigurationFile,std::map<std::string,T>* things);
52                                         ReaderEnvironment(std::string nameConceptFile,std::string nameObjectFile,std::map<std::string,T>* things);
53                                         ReaderEnvironment(std::string nameOtherConceptsFile, std::string nameConceptFile,std::string nameObjectFile, std::map<std::string,T>* things);
54                                         ~ReaderEnvironment();
55                                                 
56                                         //====== OPERATIONS =======
57                                         /*
58                                         * @return environment builded
59                                         */
60                                         SomeEnvironment<T>* getEnvironment();
61                                         
62                                         //====== ACCESS ==========
63                                 
64                                                 
65
66                                 private:
67                                         
68                                         //======= ATTRIBUTES=======
69                                         /*
70                                         *       Environment
71                                         */
72                                         SomeEnvironment<T>* environment;
73                                         /*
74                                         * things of the environment
75                                         */
76                                         std::map<std::string,T>* things;
77                                         /*
78                                         * name of the configuration file 
79                                         */
80                                         std::string nameConfigurationFile;
81                                         /*
82                                         * name of the configuration file for the objects
83                                         */
84                                         std::string nameObjectFile;
85                                         /*
86                                         *  name of the configuration file for the concepts
87                                         */
88                                         std::string nameConceptFile;
89                                         /*
90                                         *  name of the configuration file for other concepts
91                                         */
92                                         std::string nameOtherConceptsFile;
93
94                                         /*
95                                         *  data in the file
96                                         */
97                                         std::map<std::string,std::string> dataInFile;
98                                         /*
99                                         * instant handler
100                                         */
101                                         InstantHandler<T>* instantHandler;
102                                         /*
103                                         * concepts number count
104                                         */
105                                         int numberOfConcepts;
106
107                                         
108                                         //======== PRIVATE METHODS ==========
109                                         /*
110                                         * build the environment
111                                         */      
112
113                                         void buildEnvironment();
114                                         /*
115                                         * read the configuration file
116                                         */
117                                         void readFile(std::string nameFile);
118                                         
119                                         /*
120                                         * add the concepts of the file to the environment
121                                         */
122                                         bool addConcepts();
123                                         /*
124                                         * adds the things to the  environment
125                                         */
126                                         bool addThings();
127                                         /*
128                                         *       add the instants defined in the file for the name of the
129                                         *       object given
130                                         *       @param nameObject, name of the object for which we want to search
131                                         *       its instant
132                                         */
133                                         bool addInstantToThing(std::string nameObject,std::string index);
134                                         /*
135                                         *       build the instant from the string readed in the file
136                                         *       @param instant, string with the description of the instant
137                                         *       @param nameObject, name of the object for wich we can add an instant or several instants
138                                         *       @return 
139                                         */
140                                         bool addInstants(std::string nameObject,std::string instant);
141                                         /*
142                                         *       Returns the instant object of the instant string given
143                                         *       1 1 1 1 and returns an instant object (1,1,1,1)
144                                         *       @param instant, instant for which  we want to construct an Instant object
145                                         */
146                                         Instant* getInstant(std::string instant);
147                                         /*
148                                         *       Returns the number of the concept in the instant string read
149                                         *       @param instant,instant where we are going to search the number of the
150                                         *       concept that is in the position given
151                                         *       @param position, position of the concept for which we want the number in the instant given
152                                         */
153                                         int getNumConcept(std::string& instant,int position  );
154                                         /*
155                                         *       Returns the name of the concept in the concepts defined given the number 
156                                         *       of the concept in the instant
157                                         *       @param nameConcept, string where is going to be load the name of the concept
158                                         *       @param numConcept, number of the concept in the instant for which we are looking
159                                         *       for the name
160                                         */
161                                         
162                                         void  getConceptName(std::string& nameConcept,int numConcept);
163
164                                         /*
165                                         * Returns the number of decimals places of the number given
166                                         */
167                                         int getNumberOfDecimalPlaces(int number);
168
169                                         /*
170                                         * Clean the line readed from the file
171                                         */
172                                         void cleanLine(std::string & line);
173                                         
174                                         
175
176         };
177 //include the implementation of the template
178 #include "ReaderEnvironment_Txx.h"
179 #endif
180
181
182