/* dtkContainerVectorWrapper.tpp --- * * Author: tkloczko * Copyright (C) 2011 - Thibaud Kloczko, Inria. * Created: Fri May 25 09:47:39 2012 (+0200) * Version: $Id: 76e7530c55840c7c83296235950a932cae8ec847 $ * Last-Updated: Mon Sep 30 16:51:18 2013 (+0200) * By: Julien Wintz * Update #: 61 */ /* Commentary: * */ /* Change log: * */ #ifndef DTKCONTAINERVECTORWRAPPER_TPP #define DTKCONTAINERVECTORWRAPPER_TPP // ///////////////////////////////////////////////////////////////// // dtkContainerVectorWrapper implementation // ///////////////////////////////////////////////////////////////// template dtkContainerVectorWrapper::dtkContainerVectorWrapper(void) : dtkAbstractContainerWrapper() { this->init(this); }; template dtkContainerVectorWrapper::dtkContainerVectorWrapper(dtkContainerVector *vector) : dtkAbstractContainerWrapper(), m_vector(vector) { this->init(this); }; template dtkContainerVectorWrapper::dtkContainerVectorWrapper(const dtkContainerVectorWrapper& other) : dtkAbstractContainerWrapper(), m_vector(other.m_vector) { dtkAbstractData::operator=(other); this->init(this); }; template dtkContainerVectorWrapper::~dtkContainerVectorWrapper(void) { m_vector = NULL; }; template dtkContainerVectorWrapper& dtkContainerVectorWrapper::operator = (const dtkContainerVectorWrapper& other) { dtkAbstractData::operator = (other); m_vector = other.m_vector; return *this; }; template dtkContainerVectorWrapper *dtkContainerVectorWrapper::clone(void) { return new dtkContainerVectorWrapper(*this); }; template dtkContainerVectorWrapper *dtkContainerVectorWrapper::voidClone(void) { // hack dtkContainerVector *vec = new dtkContainerVector(); return new dtkContainerVectorWrapper(vec); }; template QString dtkContainerVectorWrapper::identifier(void) const { return QString("dtkContainerVectorWrapper<%1>").arg(typeid(T).name()); }; template QString dtkContainerVectorWrapper::description(void) const { if (m_vector) return m_vector->description(); return QString("dtkContainerVectorWrapper<%1> is void! It might not be what you expect.").arg(typeid(T).name()); }; template void dtkContainerVectorWrapper::setVector(dtkContainerVector *vector) { m_vector = vector; }; template dtkContainerVector *dtkContainerVectorWrapper::vector(void) { return m_vector; }; template dtkAbstractContainerWrapper::Type dtkContainerVectorWrapper::type(void) const { return dtkAbstractContainerWrapper::Vector; }; template void dtkContainerVectorWrapper::clear(void) { m_vector->clear(); }; template void dtkContainerVectorWrapper::append(const QVariant& data) { m_vector->append(data.value()); }; template void dtkContainerVectorWrapper::prepend(const QVariant& data) { m_vector->prepend(data.value()); }; template void dtkContainerVectorWrapper::remove(const QVariant& data) { m_vector->remove(data.value()); }; template void dtkContainerVectorWrapper::insert(const QVariant& data, qlonglong index) { m_vector->insert(index, data.value()); }; template void dtkContainerVectorWrapper::replace(const QVariant& data, qlonglong index) { m_vector->replace(index, data.value()); }; template void dtkContainerVectorWrapper::resize(qlonglong size) { m_vector->resize(size); }; template bool dtkContainerVectorWrapper::isEmpty(void) const { return m_vector->isEmpty(); }; template bool dtkContainerVectorWrapper::contains(const QVariant& data) const { return m_vector->contains(data.value()); }; template qlonglong dtkContainerVectorWrapper::count(void) const { return m_vector->count(); }; template qlonglong dtkContainerVectorWrapper::indexOf(const QVariant& data, qlonglong from) const { return m_vector->indexOf(data.value(), from); }; template QVariant dtkContainerVectorWrapper::at(qlonglong index) const { return qVariantFromValue(m_vector->at(index)); }; template bool dtkContainerVectorWrapper::operator != (const dtkContainerVectorWrapper& other) const { return (*m_vector != *other.m_vector); }; template bool dtkContainerVectorWrapper::operator == (const dtkContainerVectorWrapper& other) const { return (*m_vector == *other.m_vector); }; template bool dtkContainerVectorWrapper::isEqual(const dtkAbstractObject& other) const { if (this == &other) return true; if (this->identifier() != other.identifier()) return false; const dtkAbstractContainerWrapper& wrapper = reinterpret_cast(other); if (wrapper.type() == Vector) { if (const dtkContainerVectorWrapper *other_v = dynamic_cast *>(&wrapper)) { return (*m_vector == *other_v->m_vector); } } return false; }; #endif