/* # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la SantÈ) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ // SYSTEM INCLUDES // PROJECT INCLUDES #include #include // LOCAL INCLUDES #include "ConceptInstantHandler.h" #include "Instant.h" // FORWARD REFERENCES //NAMESPACE //====== LIFECYCLE ======== Instant::Instant(std::vector* instant) { nTuple=new std::vector(); setInstant(instant); } Instant::Instant() { nTuple=new std::vector(); } Instant::Instant(int size) { nTuple= new std::vector(); int i; for(i=0;ipush_back(0); } Instant::~Instant() { //deleting nTuple nTuple->clear(); } //====== OPERATIONS ======= /* * Add a new concept to the instant * @param indexConcept: index concept that is going * to be added of the new concept added to the instant * @return -- * */ void Instant::addConcept(int value) { nTuple->push_back(value); } //======= INQUIRY =========== /* * Returns the value nTuple * @return nTuple */ std::vector* Instant::getInstant() { return nTuple; } /* * Returns the index of the concept that's * in the instant's concept index * @param indexConcept: index of the concept in the instant * @return indexInConcept */ int Instant::getIndexInConcept(int indexConcept) { return (*nTuple)[indexConcept]; } /* * returns the number of concepts that the instant has * @return nTuple.size() */ int Instant::getSize() { return nTuple->size(); } /* * Compares if the instant given is equals to the nTuple * @param instant: instant for compare * @return true if is equals to the nTuple, false otherwise */ bool Instant::isEquals(Instant* instant) { int sizeInstant=instant->getSize(); bool equals=true; int sizeThisInstant=getSize(); if(sizeInstant==sizeThisInstant) { int i; for(i=0;igetIndexInConcept(i); if(indexi!=indexInConcept) equals=false; } } else equals=false; return equals; } //=========== ACCESS ========== /* * Sets the nTuple * @param instant: the vector that's going to be save in * nTuple */ void Instant::setInstant(std::vector* instant) { int i,size; size=instant->size(); for(i=0;ipush_back(k); } } /* * Change the concept's index saved in the nTuple index (the index * that's is for that concept * @param indexConcept: Concept that's going to change the value * @return-- * */ void Instant::setConcept(int indexConcept, int index) { (*nTuple)[indexConcept]=index; } /* * remove a concept from the instant * @param indexConcept: Concept that's going to be removec * @return true if succesful, false otherwise * */ bool Instant::removeConcept(int indexConcept) { int i; std::vector::iterator conceptsIterator=nTuple->begin(); int size=nTuple->size(); for(i=0;ierase(conceptsIterator); return true; } conceptsIterator++; } return false; }