3 #ifndef __SOMEENVIRONMENT_H_INCLUDED__
4 #define __SOMEENVIRONMENT_H_INCLUDED__
19 #include "SomeThing.h"
37 //====== LIFECYCLE ========
40 SomeEnvironment(std::map<std::string,int>* concepts,std::map< std::string,SomeThing<T> >* things);
44 //====== OPERATIONS =======
46 * Adds a thing to the program
47 * @param name: name of the thing
48 * @param thing: thing to be added
49 * @return true if the thing was succesfully added
53 bool addThing(std::string name,T thing);
57 * Add thing with the name given to the instant given
59 * the thing that has that name IS ALREADY ADDED TO THE PROGRAM
60 * @param name: name of the EXISTANT thing
61 * @param instant: instant associated to the thing
62 * @return true if the thing was succesfully added
65 bool addInstantToThing(std::string name,Instant* instant);
68 * Add thing with the name given, and the data given in the instant given
69 * @param name: name of the thing
70 * @param thing: information of the thing to be added
71 * @param instant: instant associated to the thing
72 * @return true if the thing was succesfully added
75 bool addThingWithInstant(std::string name,T thing,Instant* instant);
78 * Add a concept to the environment
79 * @param name: name of the concept
80 * @param size: size of the concept, it means that its indexes are
81 * distributed 0..size-1
82 * @return true if succesful, false otherwise
86 bool addConcept(std::string name, int size);
88 //bool addConceptToThing(std::string nameConcept,std::string nameThing,int indexInConcept);
91 * Validate the index of a concept in an instant
93 bool isValidIndex(int index, int indexInInstant);
95 //====== INQUIRY =========
98 * Get the things of that instant
99 * @param instant: the instant for wich we need to know its things
100 * @return thingsOfInstant: a vector with the pointers to the things
101 * of the instant asked
103 std::vector<T*>* getThings(Instant* instant);
106 * Returns the things with their names in the environment
107 * @param names, vector where is goint to be safe the names
108 * of the things in the environment.
109 * @param things, vector where is going to be save the things
110 * @parama instant, instant for wich
113 void getThings(std::vector<std::string>& names,std::vector<T*>& thingsVector,Instant* instant);
116 * Returns the instants where the thing identified by the name
118 * @param nameThing, name of the thing in the environment
119 * @return instants of that thing
120 * NOTE SENDS THE POINT TO A COPY OF THE VECTORS OF INSTANTS
123 std::vector<Instant*>* getInstantsOfThing(std::string nameThing);
126 * Returns the instants define in the environment
127 * @return existing instants in the environment
130 std::vector<Instant*>* getExistingInstants();
133 * Returns the size of the concept identified by nameConcept
134 * @param nameConcept, name of the concept in the environment
135 * @return size, of the concept given
137 int getSizeConcept(std::string nameConcept);
140 * returns the index of the concept in the instants
142 int getIndexConcept(std::string nameConcept);
145 * Give the names of the names defined
146 * @param nameConcepts, vector where is goin to be save the names of the concepts
148 void getConceptsNames(std::vector<std::string>& namesConcepts);
151 * Method that retorns the name of each concept and the size of it.
152 * @param conceptNameVect, Vector in which is disposed to be setted the name for each of the included concepts
153 * @param conceptSizeVect, Vector in which is disposed to be setted the size for each of the included concepts
155 void getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect);
158 * returns all the things of the environment
159 * @param vector where is going to be charge the things
161 * thingsVector is empty
163 void getThingsOfEnvironment(std::vector<T*>* thingsVector);
166 * returns a pointer to the thing with the name given
168 T* getThingByName(std::string name);
170 * returns the number of concepts defined
172 int getNumberOfConcepts();
175 * Gets the number of things
176 * @return Returns the number of existing things in the environment
178 int getNumberOfThings ();
180 //====== ACCESS ==========
182 * Remove a thing from all the instants, it means from the program
183 * @param name: name of the thing
184 * @return: true if the removed is succesful (false if the thing doesnt exist)
187 bool removeThing(std::string name);
190 * Removes the thing with the name given, from the instant
192 * @param name: name of the thing
193 * @param Instant: Instant from which it will be removed
194 * @return true: if the removed is succesful (false if the thing doesn exist)
197 bool removeThingFromInstant(std::string name, Instant* instant);
201 * Remove Instant from the program, it means, that from all the
202 * somethings that have that instant, after call this method them
203 * doesnt have that instant anymore
204 * @param instant: instant that is going to be removed
205 * @return true: if the removed is succesful (false other wise)
207 bool removeInstant(Instant* instant);
212 * Change the instant (any index of any concept) for all the things
213 * that should be find in that instant
214 * @param indexInstant: index of the instant in the existing instants
216 * @param indexConcept: index of the concept in the instant to be changed
217 * @param indexInConcept: which value between 0-sizeConcept is going to be saved
220 void changeInstantForAllThings(int indexInstant, int indexConcept, int indexInConcept);
223 //void changeInstantOnlyForThing(std::string nameThing, Instant* instant, int indexConcept,);
225 * Remove a dimension from the environment
226 * THE REMOVE OF THE CONCEPT IS WHEN IS BEING DEFINED THE ENVIRONMENT ,NO IN
229 * the name of the concept given is already added to the environment
230 * @param nameConcept, name of the concept to remove
233 bool removeConcept(std::string nameConcept);
239 //======= ATTRIBUTES=======
242 * Concepts that was defined
243 * Saving in like (nameConcept,sizeConcept), where the key
244 * is the name of the concept
247 std::map<std::string,int> concepts;
249 * The things that this concepts handle
251 * in visualization the concepts handle actors, it means that
252 * the actor are them things, but things also store the thing's name
254 * each thing has a unique name, and is stored like (nameThing,Thing)
255 * where the key is the name of the thing
258 std::map < std::string,SomeThing<T> > things;
261 * this is the things of the instant asked
262 * use for returning the data
264 std::vector<T*> thingsOfInstant;
267 * this vector saves the instants that
268 * are defined in the Environment
270 std::vector<Instant*> existingInstants;
273 * is the relation between the the indexes of the instants and the
274 * concepts in the environment
276 std::map<std::string,int> indexesConcepts;
278 //====== PRIVATE METHODS=========
280 * Checks if in the instant given the something given has it
281 * @param instant, instant to check
282 * @param something;, something to check in the instant
285 bool isInInstant(SomeThing<T>* something,Instant *instant);
288 * Remove the instant from the environment
289 * @param instant, to be erased
292 void removeInstantFromExistingInstants(Instant* instant);
295 * Adds an instant to the existing instants, verifying if
296 * the instant is already added
297 * @param instant, to be added
298 * @return the index of that instant in the existing instants in the
301 int addInstant(Instant* instant);
303 * Return the index in the existing instants of the instant
304 * that the user had given
305 * @param instant, instant for which we are looking the index in
306 * the existings intants in the environment
307 * @return an index in (0,existingInstants.size()-1)
309 int getIndexInstantInExistingInstants(Instant* instant);
317 //include the implementation of the template
318 #include "SomeEnvironment_Txx.h"