[369] | 1 | #ifndef __XIOS_ATTRIBUTE_ARRAY_IMPL_HPP__ |
---|
| 2 | #define __XIOS_ATTRIBUTE_ARRAY_IMPL_HPP__ |
---|
| 3 | |
---|
| 4 | #include "buffer_in.hpp" |
---|
| 5 | #include "buffer_out.hpp" |
---|
| 6 | #include "generate_interface.hpp" |
---|
| 7 | #include "attribute_array.hpp" |
---|
| 8 | |
---|
[775] | 9 | |
---|
[369] | 10 | namespace xios |
---|
| 11 | { |
---|
| 12 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 13 | template <typename T_numtype, int N_rank> |
---|
| 14 | CAttributeArray<T_numtype, N_rank>::CAttributeArray(const StdString & id) |
---|
| 15 | : CAttribute(id) |
---|
| 16 | { /* Ne rien faire de plus */ } |
---|
| 17 | |
---|
| 18 | template <typename T_numtype, int N_rank> |
---|
| 19 | CAttributeArray<T_numtype,N_rank>::CAttributeArray(const StdString & id, const CArray<T_numtype,N_rank>& value) |
---|
| 20 | : CAttribute(id) |
---|
| 21 | { |
---|
| 22 | this->setValue(value); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | template <typename T_numtype, int N_rank> |
---|
| 26 | CAttributeArray<T_numtype, N_rank>::CAttributeArray(const StdString & id, xios_map<StdString, CAttribute*> & umap) |
---|
| 27 | : CAttribute(id) |
---|
| 28 | { |
---|
| 29 | umap.insert(umap.end(), std::make_pair(id, this)); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | template <typename T_numtype, int N_rank> |
---|
| 33 | CAttributeArray<T_numtype, N_rank>::CAttributeArray (const StdString & id, const CArray<T_numtype,N_rank>& value, |
---|
| 34 | xios_map<StdString, CAttribute*> & umap) |
---|
| 35 | : CAttribute(id) |
---|
| 36 | { |
---|
| 37 | this->setValue(value); |
---|
| 38 | umap.insert(umap.end(), std::make_pair(id, this)); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | ///-------------------------------------------------------------- |
---|
| 42 | |
---|
| 43 | template <typename T_numtype, int N_rank> |
---|
[460] | 44 | void CAttributeArray<T_numtype, N_rank>::reset(void) |
---|
| 45 | { |
---|
| 46 | CArray<T_numtype, N_rank>::reset() ; |
---|
| 47 | inheritedValue.reset() ; |
---|
| 48 | } |
---|
[775] | 49 | |
---|
[460] | 50 | template <typename T_numtype, int N_rank> |
---|
[369] | 51 | CArray<T_numtype,N_rank> CAttributeArray<T_numtype, N_rank>::getValue(void) const |
---|
| 52 | { |
---|
| 53 | return this->copy() ; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | template <typename T_numtype, int N_rank> |
---|
| 57 | void CAttributeArray<T_numtype,N_rank>::setValue(const CArray<T_numtype,N_rank>& value) |
---|
| 58 | { |
---|
| 59 | this->resize(value.shape()) ; |
---|
| 60 | *this=value ; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | template <typename T_numtype, int N_rank> |
---|
| 64 | void CAttributeArray<T_numtype,N_rank>::set(const CAttribute& attr) |
---|
| 65 | { |
---|
| 66 | this->set(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ; |
---|
[775] | 67 | } |
---|
[369] | 68 | |
---|
| 69 | template <typename T_numtype, int N_rank> |
---|
| 70 | void CAttributeArray<T_numtype,N_rank>::set(const CAttributeArray& attr) |
---|
| 71 | { |
---|
| 72 | this->setValue(attr) ; |
---|
[775] | 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
[445] | 76 | template <typename T_numtype, int N_rank> |
---|
| 77 | void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttribute& attr) |
---|
| 78 | { |
---|
| 79 | this->setInheritedValue(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ; |
---|
[775] | 80 | } |
---|
[369] | 81 | |
---|
| 82 | template <typename T_numtype, int N_rank> |
---|
[445] | 83 | void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttributeArray& attr) |
---|
| 84 | { |
---|
[1112] | 85 | if (this->isEmpty() && _canInherite && attr.hasInheritedValue()) |
---|
[447] | 86 | { |
---|
| 87 | inheritedValue.resize(attr.shape()) ; |
---|
| 88 | inheritedValue=attr ; |
---|
| 89 | } |
---|
[775] | 90 | } |
---|
[445] | 91 | |
---|
| 92 | template <typename T_numtype, int N_rank> |
---|
| 93 | CArray<T_numtype,N_rank> CAttributeArray<T_numtype,N_rank>::getInheritedValue(void) const |
---|
| 94 | { |
---|
| 95 | if (this->isEmpty()) return inheritedValue.copy() ; |
---|
| 96 | else return getValue() ; |
---|
[775] | 97 | } |
---|
| 98 | |
---|
[445] | 99 | template <typename T_numtype, int N_rank> |
---|
| 100 | bool CAttributeArray<T_numtype,N_rank>::hasInheritedValue(void) const |
---|
| 101 | { |
---|
| 102 | return !this->isEmpty() || !inheritedValue.isEmpty() ; |
---|
[775] | 103 | } |
---|
[445] | 104 | |
---|
[1105] | 105 | template <typename T_numtype, int N_rank> |
---|
| 106 | bool CAttributeArray<T_numtype,N_rank>::isEqual(const CAttributeArray& attr) |
---|
| 107 | { |
---|
| 108 | return ((dynamic_cast<CArray<T_numtype,N_rank>& >(*this)) == (dynamic_cast<const CArray<T_numtype,N_rank>& >(attr))); |
---|
| 109 | } |
---|
[775] | 110 | |
---|
[445] | 111 | template <typename T_numtype, int N_rank> |
---|
[1105] | 112 | bool CAttributeArray<T_numtype,N_rank>::isEqual(const CAttribute& attr) |
---|
| 113 | { |
---|
| 114 | return ((*this) == (dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr))); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | template <typename T_numtype, int N_rank> |
---|
[369] | 118 | StdString CAttributeArray<T_numtype,N_rank>::_toString(void) const |
---|
| 119 | { |
---|
| 120 | StdOStringStream oss; |
---|
| 121 | if (! isEmpty() && this->hasId()) oss << this->getName() << "=\"" << CArray<T_numtype, N_rank>::toString() << "\""; |
---|
| 122 | return (oss.str()); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | template <typename T_numtype, int N_rank> |
---|
| 126 | void CAttributeArray<T_numtype, N_rank>::_fromString(const StdString & str) |
---|
| 127 | { |
---|
| 128 | CArray<T_numtype, N_rank>::fromString(str) ; |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | template <typename T_numtype, int N_rank> |
---|
| 132 | bool CAttributeArray<T_numtype, N_rank>::_toBuffer (CBufferOut& buffer) const |
---|
| 133 | { |
---|
| 134 | return CArray<T_numtype, N_rank>::toBuffer(buffer) ; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | template <typename T_numtype, int N_rank> |
---|
| 138 | bool CAttributeArray<T_numtype, N_rank>::_fromBuffer(CBufferIn& buffer) |
---|
| 139 | { |
---|
| 140 | return CArray<T_numtype, N_rank>::fromBuffer(buffer) ; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | template <typename T_numtype, int N_rank> |
---|
| 144 | void CAttributeArray<T_numtype, N_rank>::generateCInterface(ostream& oss,const string& className) |
---|
| 145 | { |
---|
[778] | 146 | CInterface::AttributeCInterface<CArray<T_numtype, N_rank> >(oss, className, this->getName()); |
---|
[369] | 147 | } |
---|
[775] | 148 | |
---|
[369] | 149 | template <typename T_numtype, int N_rank> |
---|
| 150 | void CAttributeArray<T_numtype, N_rank>::generateFortran2003Interface(ostream& oss,const string& className) |
---|
| 151 | { |
---|
[778] | 152 | CInterface::AttributeFortran2003Interface<CArray<T_numtype, N_rank> >(oss, className, this->getName()); |
---|
[369] | 153 | } |
---|
[775] | 154 | |
---|
[369] | 155 | template <typename T_numtype, int N_rank> |
---|
| 156 | void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) |
---|
| 157 | { |
---|
[778] | 158 | CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_"); |
---|
[369] | 159 | } |
---|
[775] | 160 | |
---|
[369] | 161 | template <typename T_numtype, int N_rank> |
---|
| 162 | void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceBody_(ostream& oss,const string& className) |
---|
| 163 | { |
---|
[778] | 164 | CInterface::AttributeFortranInterfaceBody<CArray<T_numtype, N_rank> >(oss, className, this->getName()); |
---|
[369] | 165 | } |
---|
| 166 | |
---|
| 167 | template <typename T_numtype, int N_rank> |
---|
| 168 | void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration(ostream& oss,const string& className) |
---|
| 169 | { |
---|
[778] | 170 | CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()); |
---|
[369] | 171 | } |
---|
[775] | 172 | |
---|
[369] | 173 | template <typename T_numtype, int N_rank> |
---|
| 174 | void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) |
---|
| 175 | { |
---|
[778] | 176 | CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName() + "_"); |
---|
[369] | 177 | } |
---|
[775] | 178 | |
---|
[369] | 179 | template <typename T_numtype, int N_rank> |
---|
| 180 | void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetBody_(ostream& oss,const string& className) |
---|
| 181 | { |
---|
[778] | 182 | CInterface::AttributeFortranInterfaceGetBody<CArray<T_numtype, N_rank> >(oss, className, this->getName()); |
---|
[369] | 183 | } |
---|
| 184 | |
---|
| 185 | template <typename T_numtype, int N_rank> |
---|
| 186 | void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) |
---|
| 187 | { |
---|
[778] | 188 | CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()); |
---|
[369] | 189 | } |
---|
| 190 | } // namespace xios |
---|
| 191 | |
---|
| 192 | #endif // __XIOS_ATTRIBUTE_ENUM_IMPL_HPP__ |
---|