// 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; }