10 //#include "Instant.h"
23 //====== LIFECYCLE ========
25 SomeThing<U>::SomeThing(std::string name)
31 SomeThing<U>::~SomeThing()
34 instantsVector.clear();
40 //====== OPERATIONS =======
43 * Add a new instant to the thing
44 * @param instant: new instant
47 bool SomeThing<U>::addInstant(Instant* instant)
50 int sizeInstant=instant->getSize();
51 for(int i=0;i<sizeInstant;i++)
52 int j=instant->getIndexInConcept(i);
54 int index= hasInstant(instant);
56 this->instantsVector.push_back(instant);
60 //====== INQUIRY =========
62 * Get the thing stored
66 U* SomeThing<U>::getThing()
71 * Get the name of the thing
75 std::string SomeThing<U>::getName()
80 * Get all the instants
84 std::vector<Instant*>* SomeThing<U>::getInstants()
86 return &instantsVector;
89 * Get the instant that's in the index given
90 * @param indexInstant: index of the instant that they want
91 * @return instants[instantIndex]
94 Instant* SomeThing<U>::getInstant(int indexInstant)
96 return instantsVector[indexInstant];
99 * Get the number of instants that the
101 * @return instants.size()
104 int SomeThing<U>::getNumberInstants()
106 return this->instantsVector.size();
110 * if this is in the instant given
111 * @param instant: instant to verified if this has it
112 * @return 0<=i<numberOfInstants if this has the instant, -1 otherwise
115 int SomeThing<U>::hasInstant(Instant* instant)
118 int sizeInstants=this->getNumberInstants();
120 for(i=0;i<sizeInstants;i++)
122 Instant* instanti=this->getInstant(i);
123 isEquals=instanti->isEquals(instant);
129 //====== ACCESS ==========
135 void SomeThing<U>::setThing(U thing)
140 * Set the name of the thing
144 void SomeThing<U>::setName(std::string name)
146 this->nameThing=name;
149 * Set the instants of the thing
153 void SomeThing<U>::setInstants(std::vector<Instant*> instants)
155 this->instantsVector=instants;
158 * Remove an instant from the thing
159 * @param indexInstant: index of the instant to be removed
160 * @return true if succesful , false otherwise
163 bool SomeThing<U>::removeInstant(int indexInstant)
166 std::vector<Instant*>::iterator instantsIterator=this->instantsVector.begin();
167 int sizeInstants=this->getNumberInstants();
168 for(i=0;i<sizeInstants;i++)
172 this->instantsVector.erase(instantsIterator);
180 * Remove an instant from the thing
181 * @param instant: instant to be deleted
182 * @return true if succesful , false otherwise
185 bool SomeThing<U>::removeInstant(Instant* instant)
187 int index=hasInstant(instant);
190 removeInstant(index);