#ifndef __XIOS_ATTRIBUTE_ARRAY_IMPL_HPP__ #define __XIOS_ATTRIBUTE_ARRAY_IMPL_HPP__ #include "buffer_in.hpp" #include "buffer_out.hpp" #include "generate_interface.hpp" #include "attribute_array.hpp" namespace xios { /// ////////////////////// Définitions ////////////////////// /// template CAttributeArray::CAttributeArray(const StdString & id) : CAttribute(id) { /* Ne rien faire de plus */ } template CAttributeArray::CAttributeArray(const StdString & id, const CArray& value) : CAttribute(id) { this->setValue(value); } template CAttributeArray::CAttributeArray(const StdString & id, xios_map & umap) : CAttribute(id) { umap.insert(umap.end(), std::make_pair(id, this)); } template CAttributeArray::CAttributeArray (const StdString & id, const CArray& value, xios_map & umap) : CAttribute(id) { this->setValue(value); umap.insert(umap.end(), std::make_pair(id, this)); } ///-------------------------------------------------------------- template void CAttributeArray::reset(void) { CArray::reset() ; inheritedValue.reset() ; } template CArray CAttributeArray::getValue(void) const { return this->copy() ; } template void CAttributeArray::setValue(const CArray& value) { this->resize(value.shape()) ; *this=value ; } template void CAttributeArray::set(const CAttribute& attr) { this->set(dynamic_cast& >(attr)) ; } template void CAttributeArray::set(const CAttributeArray& attr) { this->setValue(attr) ; } template void CAttributeArray::setInheritedValue(const CAttribute& attr) { this->setInheritedValue(dynamic_cast& >(attr)) ; } template void CAttributeArray::setInheritedValue(const CAttributeArray& attr) { if (this->isEmpty() && _canInherite && attr.hasInheritedValue()) { inheritedValue.resize(attr.shape()) ; inheritedValue=attr ; } } template CArray CAttributeArray::getInheritedValue(void) const { if (this->isEmpty()) return inheritedValue.copy() ; else return getValue() ; } template bool CAttributeArray::hasInheritedValue(void) const { return !this->isEmpty() || !inheritedValue.isEmpty() ; } template bool CAttributeArray::isEqual(const CAttribute& attr) { const CAttributeArray& tmp = dynamic_cast& >(attr); return this->isEqual_(tmp); } template bool CAttributeArray::isEqual_(const CAttributeArray& attr) { if ((!this->hasInheritedValue() && !attr.hasInheritedValue())) return true; if (this->hasInheritedValue() && attr.hasInheritedValue()) return (this->getInheritedValue() == attr.getInheritedValue()); else return false; } template StdString CAttributeArray::_toString(void) const { StdOStringStream oss; if (! isEmpty() && this->hasId()) oss << this->getName() << "=\"" << CArray::toString() << "\""; return (oss.str()); } template void CAttributeArray::_fromString(const StdString & str) { CArray::fromString(str) ; } template bool CAttributeArray::_toBuffer (CBufferOut& buffer) const { return CArray::toBuffer(buffer) ; } template bool CAttributeArray::_fromBuffer(CBufferIn& buffer) { return CArray::fromBuffer(buffer) ; } template void CAttributeArray::generateCInterface(ostream& oss,const string& className) { CInterface::AttributeCInterface >(oss, className, this->getName()); } template void CAttributeArray::generateFortran2003Interface(ostream& oss,const string& className) { CInterface::AttributeFortran2003Interface >(oss, className, this->getName()); } template void CAttributeArray::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) { CInterface::AttributeFortranInterfaceDeclaration >(oss, className, this->getName() + "_"); } template void CAttributeArray::generateFortranInterfaceBody_(ostream& oss,const string& className) { CInterface::AttributeFortranInterfaceBody >(oss, className, this->getName()); } template void CAttributeArray::generateFortranInterfaceDeclaration(ostream& oss,const string& className) { CInterface::AttributeFortranInterfaceDeclaration >(oss, className, this->getName()); } template void CAttributeArray::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) { CInterface::AttributeFortranInterfaceGetDeclaration >(oss, className, this->getName() + "_"); } template void CAttributeArray::generateFortranInterfaceGetBody_(ostream& oss,const string& className) { CInterface::AttributeFortranInterfaceGetBody >(oss, className, this->getName()); } template void CAttributeArray::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) { CInterface::AttributeFortranInterfaceGetDeclaration >(oss, className, this->getName()); } } // namespace xios #endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__