15 //====== LIFECYCLE ========
17 EnvironmentHandler<P>::EnvironmentHandler(SomeEnvironment<P>* environment)
19 this->environment=environment;
23 EnvironmentHandler<P>::~EnvironmentHandler()
25 //deleting actual instants
26 this->actualInstants.clear();
27 //deleting environment
28 if(this->environment) delete this->environment;
32 //====== OPERATIONS =======
34 * change the actual intants associated to the
38 void EnvironmentHandler<P>::nextInstants(std::vector<std::string> nameConcepts)
40 int size,i,indexConcept,indexInConcept,sizeConcept;
41 size=nameConcepts.size();
42 std::map<std::string,Instant*>::iterator actualInstantsIterator;
43 std::string nameConcepti;
46 nameConcepti=nameConcepts[i];
47 actualInstantsIterator=actualInstants.find(nameConcepti);
48 if(actualInstantsIterator!=actualInstants.end())
50 Instant* instant=actualInstantsIterator->second;
51 indexConcept=environment->getIndexConcept(nameConcepti);
52 indexInConcept=instant->getIndexInConcept(indexConcept);
54 sizeConcept=environment->getSizeConcept(nameConcepti);
55 if(indexInConcept<sizeConcept)
56 instant->setConcept(indexConcept,indexInConcept);
63 * add an actual Instant to a concept, it means, this instant
64 * has all index fixed, except the index in the instant of the concept
65 * identified by nameConcept
68 void EnvironmentHandler<P>::addActualInstantOfCOncept(std::string nameConcept,Instant* instant)
70 actualInstants.insert(std::pair<std::string,int>(nameConcept,instant));
74 * removes the pair in the map of actual concepts
77 void EnvironmentHandler<P>::removeActualInstantOfConcept(std::string nameConcept)
79 std::map<std::string,Instant*>::iterator actualInstantsIterator=actualInstants.find(nameConcept);
80 if(actualInstantsIterator!=actualInstants.end())
81 actualInstants.erase(actualInstantsIterator);
84 //====== INQUIRY =========
86 * get all the actual instants
89 void EnvironmentHandler<P>::getActualsInstants(std::vector<Instant*>& instantsVector)
92 std::map<std::string,Instant*>::iterator actualInstantsIterator=
93 actualInstants.begin();
94 while(actualInstantsIterator!=actualInstants.end())
96 Instant* instant=actualInstantsIterator->second;
97 instantsVector.push_back(instant);
98 actualInstantsIterator++;
104 * get the actual instant fot the concept identified by the name
107 Instant* EnvironmentHandler<P>::getActualInstant(std::string nameConcept)
109 std::map<std::string,Instant*>::iterator actualInstantsIterator=actualInstants.find(nameConcept);
110 if(actualInstantsIterator!=actualInstants.end())
112 return instant=actualInstantsIterator->second;
116 return (Instant*)NULL;
118 //====== ACCESS ==========