21 #ifndef otbWrapperParameterList_hxx
22 #define otbWrapperParameterList_hxx
55 return m_Parameters.
begin();
62 return m_Parameters.
end();
69 return Size() > 0 && std::all_of(begin(), end(), [](
auto p) ->
bool {
71 return p && p->HasValue();
82 Superclass::ClearValue();
89 this->SetStrings(strings);
96 m_Parameters.insert(index >= m_Parameters.size() ? m_Parameters.end() : m_Parameters.begin() + index,
typename T::Pointer());
104 template <
typename T>
107 assert(!filename.empty());
109 typename T::Pointer p(T::New());
111 p->FromString(filename);
113 m_Parameters.push_back(p);
115 assert(!m_Parameters.back().IsNull());
123 template <
typename T>
126 typename T::Pointer p(T::New());
128 p->FromString(filename);
130 InsertElement(p, index);
134 template <
typename T>
137 m_Parameters.insert(m_Parameters.begin() + index, p);
139 assert(!m_Parameters.back().IsNull());
147 template <
typename T>
150 assert(i < m_Parameters.size());
151 assert(!m_Parameters[i].IsNull());
154 m_Parameters[i]->FromString(filename);
162 template <
typename T>
168 if (!strings.empty())
170 std::transform(strings.begin(), strings.end(), std::back_inserter(m_Parameters), [](
auto s) ->
auto {
171 typename T::Pointer parameter(T::New());
172 parameter->FromString(s);
179 return strings.size();
183 template <
typename T>
186 std::transform(begin(), end(), std::back_inserter(strings), [](
auto p) ->
auto {
return p->ToString(); });
188 return m_Parameters.size();
192 template <
typename T>
197 GetStrings(filenames);
203 template <
typename T>
206 assert(i < m_Parameters.size());
208 return m_Parameters[i]->ToString();
212 template <
typename T>
215 assert(i < m_Parameters.size());
216 assert(!m_Parameters[i].IsNull());
219 return m_Parameters[i]->GetDescription();
223 template <
typename T>
226 assert(start < m_Parameters.size());
227 assert(start + count <= m_Parameters.size());
230 m_Parameters.erase(m_Parameters.begin() + start, m_Parameters.begin() + start + count);
236 template <
typename T>
239 return m_Parameters.size();
243 template <
typename T>
246 assert(i < m_Parameters.size());
247 assert(!m_Parameters[i].IsNull());
250 return m_Parameters[i]->GetActive();
254 template <
typename T>
257 assert(!m_Parameters.empty());
259 auto clamp = [
this](std::size_t i) -> std::size_t {
return i >= m_Parameters.size() ? m_Parameters.size() - 1 : i; };
261 std::swap(m_Parameters[
clamp(i1)], m_Parameters[
clamp(i2)]);
265 template <
typename T>
266 template <
typename L,
typename From,
typename Get>
270 for (std::size_t i = 0; i < list.Size(); i++)
272 assert(list.GetNthElement(i) !=
nullptr);
275 list.GetNthElement(i)->UpdateOutputInformation();
281 for (std::size_t i = 0; i < list.Size(); i++)
283 assert(list.GetNthElement(i) !=
nullptr);
285 typename T::Pointer parameter;
287 from(parameter, list.GetNthElement(i));
289 m_Parameters.push_back(parameter);
291 assert(get(parameter) !=
nullptr);
293 this_list.PushBack(get(parameter));
302 template <
typename T>
303 template <
typename L,
typename Get>
310 std::for_each(begin(), end(), [this_list, get](
auto parameter) ->
void {
312 assert(parameter == otb::DynamicCast<T>(parameter));
314 assert(get(DynamicCast<T>(parameter)));
316 this_list->PushBack(get(DynamicCast<T>(parameter)));
323 template <
typename T>
324 template <
typename L,
typename Get>
331 template <
typename T>
332 template <
typename D,
typename From>
335 assert(data !=
nullptr);
338 data->UpdateOutputInformation();
341 m_Parameters.push_back(from(data));
347 template <
typename T>
348 template <
typename D,
typename Set>
351 assert(data !=
nullptr);
353 typename T::Pointer p(T::New());
355 return FromData(p, data, set, description);
359 template <
typename T>
360 template <
typename D,
typename Set>
363 assert(data !=
nullptr);
365 set(parameter, data);
366 parameter->SetDescription(description);
371 template <
typename T>
374 return GetFileNameList();
377 template <
typename T>
383 template <
typename T>
386 std::ostringstream oss;
387 oss << std::setprecision(10);
388 auto strList = GetFileNameList();
389 for (
size_t i = 0; i < strList.size(); i++)
400 template <
typename T>
403 return m_Parameters[i];