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 # ------------------------------------------------------------------------ */
37 #include "ConceptInstantHandler.h"
46 //====== LIFECYCLE ========
48 Instant::Instant(std::vector<int>* instant)
50 nTuple=new std::vector<int>();
56 nTuple=new std::vector<int>();
59 Instant::Instant(int size)
61 nTuple= new std::vector<int>();
74 //====== OPERATIONS =======
76 * Add a new concept to the instant
77 * @param indexConcept: index concept that is going
78 * to be added of the new concept added to the instant
82 void Instant::addConcept(int value)
84 nTuple->push_back(value);
86 //======= INQUIRY ===========
88 * Returns the value nTuple
91 std::vector<int>* Instant::getInstant()
96 * Returns the index of the concept that's
97 * in the instant's concept index
98 * @param indexConcept: index of the concept in the instant
99 * @return indexInConcept
101 int Instant::getIndexInConcept(int indexConcept)
103 return (*nTuple)[indexConcept];
107 * returns the number of concepts that the instant has
108 * @return nTuple.size()
110 int Instant::getSize()
112 return nTuple->size();
116 * Compares if the instant given is equals to the nTuple
117 * @param instant: instant for compare
118 * @return true if is equals to the nTuple, false otherwise
120 bool Instant::isEquals(Instant* instant)
122 int sizeInstant=instant->getSize();
124 int sizeThisInstant=getSize();
125 if(sizeInstant==sizeThisInstant)
128 for(i=0;i<sizeThisInstant;i++)
130 int indexi=(*nTuple)[i];
131 int indexInConcept=instant->getIndexInConcept(i);
132 if(indexi!=indexInConcept)
142 //=========== ACCESS ==========
145 * @param instant: the vector that's going to be save in
148 void Instant::setInstant(std::vector<int>* instant)
151 size=instant->size();
155 nTuple->push_back(k);
160 * Change the concept's index saved in the nTuple index (the index
161 * that's is for that concept
162 * @param indexConcept: Concept that's going to change the value
166 void Instant::setConcept(int indexConcept, int index)
168 (*nTuple)[indexConcept]=index;
171 * remove a concept from the instant
172 * @param indexConcept: Concept that's going to be removec
173 * @return true if succesful, false otherwise
176 bool Instant::removeConcept(int indexConcept)
179 std::vector<int>::iterator conceptsIterator=nTuple->begin();
180 int size=nTuple->size();
185 nTuple->erase(conceptsIterator);