]> Creatis software - creaEnvironment.git/blob - lib/kernel_Environment/ReaderEnvironment.h
License Files Headers
[creaEnvironment.git] / lib / kernel_Environment / ReaderEnvironment.h
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27 //      MACRO
28 #ifndef __READERENVIRONMENT_H_INCLUDED__
29 #define __READERENVIRONMENT_H_INCLUDED__
30
31 // SYSTEM INCLUDES
32
33 // PROJECT INCLUDES
34 #include <map>
35 #include <iostream>
36 #include <string>
37 #include <fstream>
38
39 // LOCAL INCLUDES
40 //#ifndef __INSTANTHANDLER_H_INCLUDED
41 #include "InstantHandler.h"
42 //#endif
43
44 // FORWARD REFERENCES
45
46 /*
47 *       COMMENT
48 *       @param
49 *       @return
50 */
51
52
53
54 template<class T>
55 class ReaderEnvironment
56                 {
57                                 public:
58
59                                         //=========== CONSTANTS ==============
60                                          std::string NUMCONCEPTS;
61                                          std::string CONCEPT;
62                                          std::string OBJECT;
63                                          std::string NUMOBJECTS;
64                                          std::string NAME;
65                                          std::string SIZE;
66                                          std::string PATH;
67                                          std::string INSTANT;
68                                          std::string NUMINSTANTS;
69                                          std::string RANGE;
70                                          std::string COMMENT;
71                                          std::string EQUAL;
72                                          std::string POINT;
73                                          std::string ALL;
74
75                                         //====== LIFECYCLE ========
76                                         
77                                         ReaderEnvironment(std::string nameConfigurationFile,std::map<std::string,T>* things);
78                                         ReaderEnvironment(std::string nameConceptFile,std::string nameObjectFile,std::map<std::string,T>* things);
79                                         ReaderEnvironment(std::string nameOtherConceptsFile, std::string nameConceptFile,std::string nameObjectFile, std::map<std::string,T>* things);
80                                         ~ReaderEnvironment();
81                                                 
82                                         //====== OPERATIONS =======
83                                         /*
84                                         * @return environment builded
85                                         */
86                                         SomeEnvironment<T>* getEnvironment();
87                                         
88                                         //====== ACCESS ==========
89                                 
90                                                 
91
92                                 private:
93                                         
94                                         //======= ATTRIBUTES=======
95                                         /*
96                                         *       Environment
97                                         */
98                                         SomeEnvironment<T>* environment;
99                                         /*
100                                         * things of the environment
101                                         */
102                                         std::map<std::string,T>* things;
103                                         /*
104                                         * name of the configuration file 
105                                         */
106                                         std::string nameConfigurationFile;
107                                         /*
108                                         * name of the configuration file for the objects
109                                         */
110                                         std::string nameObjectFile;
111                                         /*
112                                         *  name of the configuration file for the concepts
113                                         */
114                                         std::string nameConceptFile;
115                                         /*
116                                         *  name of the configuration file for other concepts
117                                         */
118                                         std::string nameOtherConceptsFile;
119
120                                         /*
121                                         *  data in the file
122                                         */
123                                         std::map<std::string,std::string> dataInFile;
124                                         /*
125                                         * instant handler
126                                         */
127                                         InstantHandler<T>* instantHandler;
128                                         /*
129                                         * concepts number count
130                                         */
131                                         int numberOfConcepts;
132
133                                         
134                                         //======== PRIVATE METHODS ==========
135                                         /*
136                                         * build the environment
137                                         */      
138
139                                         void buildEnvironment();
140                                         /*
141                                         * read the configuration file
142                                         */
143                                         void readFile(std::string nameFile);
144                                         
145                                         /*
146                                         * add the concepts of the file to the environment
147                                         */
148                                         bool addConcepts();
149                                         /*
150                                         * adds the things to the  environment
151                                         */
152                                         bool addThings();
153                                         /*
154                                         *       add the instants defined in the file for the name of the
155                                         *       object given
156                                         *       @param nameObject, name of the object for which we want to search
157                                         *       its instant
158                                         */
159                                         bool addInstantToThing(std::string nameObject,std::string index);
160                                         /*
161                                         *       build the instant from the string readed in the file
162                                         *       @param instant, string with the description of the instant
163                                         *       @param nameObject, name of the object for wich we can add an instant or several instants
164                                         *       @return 
165                                         */
166                                         bool addInstants(std::string nameObject,std::string instant);
167                                         /*
168                                         *       Returns the instant object of the instant string given
169                                         *       1 1 1 1 and returns an instant object (1,1,1,1)
170                                         *       @param instant, instant for which  we want to construct an Instant object
171                                         */
172                                         Instant* getInstant(std::string instant);
173                                         /*
174                                         *       Returns the number of the concept in the instant string read
175                                         *       @param instant,instant where we are going to search the number of the
176                                         *       concept that is in the position given
177                                         *       @param position, position of the concept for which we want the number in the instant given
178                                         */
179                                         int getNumConcept(std::string& instant,int position  );
180                                         /*
181                                         *       Returns the name of the concept in the concepts defined given the number 
182                                         *       of the concept in the instant
183                                         *       @param nameConcept, string where is going to be load the name of the concept
184                                         *       @param numConcept, number of the concept in the instant for which we are looking
185                                         *       for the name
186                                         */
187                                         
188                                         void  getConceptName(std::string& nameConcept,int numConcept);
189
190                                         /*
191                                         * Returns the number of decimals places of the number given
192                                         */
193                                         int getNumberOfDecimalPlaces(int number);
194
195                                         /*
196                                         * Clean the line readed from the file
197                                         */
198                                         void cleanLine(std::string & line);
199                                         
200                                         
201
202         };
203 //include the implementation of the template
204 #include "ReaderEnvironment_Txx.h"
205 #endif
206
207
208