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 # ------------------------------------------------------------------------ */
36 //#include "Instant.h"
49 //====== LIFECYCLE ========
51 SomeThing<U>::SomeThing(std::string name)
57 SomeThing<U>::~SomeThing()
60 instantsVector.clear();
66 //====== OPERATIONS =======
69 * Add a new instant to the thing
70 * @param instant: new instant
73 bool SomeThing<U>::addInstant(Instant* instant)
76 int sizeInstant=instant->getSize();
77 for(int i=0;i<sizeInstant;i++)
78 /// \TODO fix warning unused variable j
79 int j=instant->getIndexInConcept(i);
81 int index= hasInstant(instant);
83 this->instantsVector.push_back(instant);
87 //====== INQUIRY =========
89 * Get the thing stored
93 U* SomeThing<U>::getThing()
98 * Get the name of the thing
102 std::string SomeThing<U>::getName()
107 * Get all the instants
111 std::vector<Instant*>* SomeThing<U>::getInstants()
113 return &instantsVector;
116 * Get the instant that's in the index given
117 * @param indexInstant: index of the instant that they want
118 * @return instants[instantIndex]
121 Instant* SomeThing<U>::getInstant(int indexInstant)
123 return instantsVector[indexInstant];
126 * Get the number of instants that the
128 * @return instants.size()
131 int SomeThing<U>::getNumberInstants()
133 return this->instantsVector.size();
137 * if this is in the instant given
138 * @param instant: instant to verified if this has it
139 * @return 0<=i<numberOfInstants if this has the instant, -1 otherwise
142 int SomeThing<U>::hasInstant(Instant* instant)
145 int sizeInstants=this->getNumberInstants();
147 for(i=0;i<sizeInstants;i++)
149 Instant* instanti=this->getInstant(i);
150 isEquals=instanti->isEquals(instant);
156 //====== ACCESS ==========
162 void SomeThing<U>::setThing(U thing)
167 * Set the name of the thing
171 void SomeThing<U>::setName(std::string name)
173 this->nameThing=name;
176 * Set the instants of the thing
180 void SomeThing<U>::setInstants(std::vector<Instant*> instants)
182 this->instantsVector=instants;
185 * Remove an instant from the thing
186 * @param indexInstant: index of the instant to be removed
187 * @return true if succesful , false otherwise
190 bool SomeThing<U>::removeInstant(int indexInstant)
193 std::vector<Instant*>::iterator instantsIterator=this->instantsVector.begin();
194 int sizeInstants=this->getNumberInstants();
195 for(i=0;i<sizeInstants;i++)
199 this->instantsVector.erase(instantsIterator);
207 * Remove an instant from the thing
208 * @param instant: instant to be deleted
209 * @return true if succesful , false otherwise
212 bool SomeThing<U>::removeInstant(Instant* instant)
214 int index=hasInstant(instant);
217 removeInstant(index);