* This method merges `this` and `other` to return a new FieldInfo. */
| 166 | * This method merges `this` and `other` to return a new FieldInfo. |
| 167 | */ |
| 168 | FieldInfo operator+(const FieldInfo& other) const |
| 169 | { |
| 170 | if (!this->IsEmpty() && this->IsSimilar(other)) |
| 171 | { |
| 172 | FieldInfo result; |
| 173 | result = *this; |
| 174 | result.LUT = result.LUT ? result.LUT : other.LUT; |
| 175 | result.Information = result.Information ? result.Information : other.Information; |
| 176 | |
| 177 | // merge component names. |
| 178 | assert(result.ComponentNames.size() == other.ComponentNames.size()); |
| 179 | std::transform(result.ComponentNames.begin(), result.ComponentNames.end(), |
| 180 | other.ComponentNames.begin(), result.ComponentNames.begin(), |
| 181 | [](const std::string& in0, const std::string& in1) { return in0.empty() ? in1 : in0; }); |
| 182 | |
| 183 | assert(other.Location.size() == 1); |
| 184 | result.Location.insert(result.Location.end(), other.Location.begin(), other.Location.end()); |
| 185 | |
| 186 | result.AttributeTypes.insert( |
| 187 | result.AttributeTypes.end(), other.AttributeTypes.begin(), other.AttributeTypes.end()); |
| 188 | return result; |
| 189 | } |
| 190 | else |
| 191 | { |
| 192 | return FieldInfo(); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | ///@{ |
| 197 | /** |