2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
29 #ifndef __SOMEENVIRONMENT_H_INCLUDED__
30 #define __SOMEENVIRONMENT_H_INCLUDED__
45 #include "SomeThing.h"
63 //====== LIFECYCLE ========
66 SomeEnvironment(std::map<std::string,int>* concepts,std::map< std::string,SomeThing<T> >* things);
70 //====== OPERATIONS =======
72 * Adds a thing to the program
73 * @param name: name of the thing
74 * @param thing: thing to be added
75 * @return true if the thing was succesfully added
79 bool addThing(std::string name,T thing);
83 * Add thing with the name given to the instant given
85 * the thing that has that name IS ALREADY ADDED TO THE PROGRAM
86 * @param name: name of the EXISTANT thing
87 * @param instant: instant associated to the thing
88 * @return true if the thing was succesfully added
91 bool addInstantToThing(std::string name,Instant* instant);
94 * Add thing with the name given, and the data given in the instant given
95 * @param name: name of the thing
96 * @param thing: information of the thing to be added
97 * @param instant: instant associated to the thing
98 * @return true if the thing was succesfully added
101 bool addThingWithInstant(std::string name,T thing,Instant* instant);
104 * Add a concept to the environment
105 * @param name: name of the concept
106 * @param size: size of the concept, it means that its indexes are
107 * distributed 0..size-1
108 * @return true if succesful, false otherwise
112 bool addConcept(std::string name, int size);
114 //bool addConceptToThing(std::string nameConcept,std::string nameThing,int indexInConcept);
117 * Validate the index of a concept in an instant
119 bool isValidIndex(int index, int indexInInstant);
121 //====== INQUIRY =========
124 * Get the things of that instant
125 * @param instant: the instant for wich we need to know its things
126 * @return thingsOfInstant: a vector with the pointers to the things
127 * of the instant asked
129 std::vector<T*>* getThings(Instant* instant);
132 * Returns the things with their names in the environment
133 * @param names, vector where is goint to be safe the names
134 * of the things in the environment.
135 * @param things, vector where is going to be save the things
136 * @parama instant, instant for wich
139 void getThings(std::vector<std::string>& names,std::vector<T*>& thingsVector,Instant* instant);
142 * Returns the instants where the thing identified by the name
144 * @param nameThing, name of the thing in the environment
145 * @return instants of that thing
146 * NOTE SENDS THE POINT TO A COPY OF THE VECTORS OF INSTANTS
149 std::vector<Instant*>* getInstantsOfThing(std::string nameThing);
152 * Returns the instants define in the environment
153 * @return existing instants in the environment
156 std::vector<Instant*>* getExistingInstants();
159 * Returns the size of the concept identified by nameConcept
160 * @param nameConcept, name of the concept in the environment
161 * @return size, of the concept given
163 int getSizeConcept(std::string nameConcept);
166 * returns the index of the concept in the instants
168 int getIndexConcept(std::string nameConcept);
171 * Give the names of the names defined
172 * @param nameConcepts, vector where is goin to be save the names of the concepts
174 void getConceptsNames(std::vector<std::string>& namesConcepts);
177 * Method that retorns the name of each concept and the size of it.
178 * @param conceptNameVect, Vector in which is disposed to be setted the name for each of the included concepts
179 * @param conceptSizeVect, Vector in which is disposed to be setted the size for each of the included concepts
181 void getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect);
184 * returns all the things of the environment
185 * @param vector where is going to be charge the things
187 * thingsVector is empty
189 void getThingsOfEnvironment(std::vector<T*>* thingsVector);
192 * returns a pointer to the thing with the name given
194 T* getThingByName(std::string name);
196 * returns the number of concepts defined
198 int getNumberOfConcepts();
201 * Gets the number of things
202 * @return Returns the number of existing things in the environment
204 int getNumberOfThings ();
206 //====== ACCESS ==========
208 * Remove a thing from all the instants, it means from the program
209 * @param name: name of the thing
210 * @return: true if the removed is succesful (false if the thing doesnt exist)
213 bool removeThing(std::string name);
216 * Removes the thing with the name given, from the instant
218 * @param name: name of the thing
219 * @param Instant: Instant from which it will be removed
220 * @return true: if the removed is succesful (false if the thing doesn exist)
223 bool removeThingFromInstant(std::string name, Instant* instant);
227 * Remove Instant from the program, it means, that from all the
228 * somethings that have that instant, after call this method them
229 * doesnt have that instant anymore
230 * @param instant: instant that is going to be removed
231 * @return true: if the removed is succesful (false other wise)
233 bool removeInstant(Instant* instant);
238 * Change the instant (any index of any concept) for all the things
239 * that should be find in that instant
240 * @param indexInstant: index of the instant in the existing instants
242 * @param indexConcept: index of the concept in the instant to be changed
243 * @param indexInConcept: which value between 0-sizeConcept is going to be saved
246 void changeInstantForAllThings(int indexInstant, int indexConcept, int indexInConcept);
249 //void changeInstantOnlyForThing(std::string nameThing, Instant* instant, int indexConcept,);
251 * Remove a dimension from the environment
252 * THE REMOVE OF THE CONCEPT IS WHEN IS BEING DEFINED THE ENVIRONMENT ,NO IN
255 * the name of the concept given is already added to the environment
256 * @param nameConcept, name of the concept to remove
259 bool removeConcept(std::string nameConcept);
265 //======= ATTRIBUTES=======
268 * Concepts that was defined
269 * Saving in like (nameConcept,sizeConcept), where the key
270 * is the name of the concept
273 std::map<std::string,int> concepts;
275 * The things that this concepts handle
277 * in visualization the concepts handle actors, it means that
278 * the actor are them things, but things also store the thing's name
280 * each thing has a unique name, and is stored like (nameThing,Thing)
281 * where the key is the name of the thing
284 std::map < std::string,SomeThing<T> > things;
287 * this is the things of the instant asked
288 * use for returning the data
290 std::vector<T*> thingsOfInstant;
293 * this vector saves the instants that
294 * are defined in the Environment
296 std::vector<Instant*> existingInstants;
299 * is the relation between the the indexes of the instants and the
300 * concepts in the environment
302 std::map<std::string,int> indexesConcepts;
304 //====== PRIVATE METHODS=========
306 * Checks if in the instant given the something given has it
307 * @param instant, instant to check
308 * @param something;, something to check in the instant
311 bool isInInstant(SomeThing<T>* something,Instant *instant);
314 * Remove the instant from the environment
315 * @param instant, to be erased
318 void removeInstantFromExistingInstants(Instant* instant);
321 * Adds an instant to the existing instants, verifying if
322 * the instant is already added
323 * @param instant, to be added
324 * @return the index of that instant in the existing instants in the
327 int addInstant(Instant* instant);
329 * Return the index in the existing instants of the instant
330 * that the user had given
331 * @param instant, instant for which we are looking the index in
332 * the existings intants in the environment
333 * @return an index in (0,existingInstants.size()-1)
335 int getIndexInstantInExistingInstants(Instant* instant);
343 //include the implementation of the template
344 #include "SomeEnvironment_Txx.h"