Orfeo Toolbox  3.16
otbWrapperCommandLineLauncher.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17  =========================================================================*/
19 
20 // Single value parameter
35 #include "otbWrapperRAMParameter.h"
37 
38 // List value parameter
42 
43 #include "otbImageFileWriter.h"
44 
45 
47 #include "otbWrapperApplication.h"
48 #include "otbWrapperTypes.h"
49 #include <itksys/RegularExpression.hxx>
50 #include <string>
51 #include <iostream>
52 
53 namespace otb
54 {
55 namespace Wrapper
56 {
57 
59  m_Expression(""), m_WatcherList(), m_ReportProgress(true), m_MaxKeySize(0)
60 {
64  m_LogOutput->SetStream(std::cout);
65 
66  // Add the callback to be added when a AddProcessToWatch event is invoked
68  m_AddProcessCommand->SetCallbackFunction(this, &CommandLineLauncher::LinkWatchers);
69 }
70 
72  m_Expression(exp)
73 {
76 }
77 
79 {
80  this->DeleteWatcherList();
81 }
82 
84 {
85  for (unsigned int i = 0; i < m_WatcherList.size(); i++)
86  {
87  delete m_WatcherList[i];
88  m_WatcherList[i] = NULL;
89  }
90  m_WatcherList.clear();
91 }
92 
93 bool CommandLineLauncher::Load(const std::string & exp)
94 {
95  std::cout<<exp<<std::endl;
96  m_Expression = exp;
97 
98  return this->Load();
99 }
100 
102 {
103  // Add a space to clarify output logs
104  std::cerr << std::endl;
105  if (m_Expression == "")
106  {
107  itkExceptionMacro("No expression specified...");
108  }
109 
110  if (this->CheckParametersPrefix() == false)
111  {
112  std::cerr << "ERROR: Parameter keys have to set using \"-\", not \"--\"" << std::endl;
113  return false;
114  }
115 
116  if (this->CheckUnicity() == false)
117  {
118  std::cerr << "ERROR: At least one key is not unique in the expression..." << std::endl;
119  return false;
120  }
121 
122  if (this->LoadPath() == false)
123  {
124  if (m_Parser->GetPathsAsString(m_Expression).size() != 0)
125  {
126  std::cerr << "ERROR: At least one specified path within \"" << m_Parser->GetPathsAsString(m_Expression)
127  << "\" is invalid or doesn't exist..." << std::endl;
128  return false;
129  }
130  }
131 
132  this->LoadApplication();
133 
134  return true;
135 }
136 
138 {
139  if (this->BeforeExecute() == false)
140  {
141  return false;
142  }
143 
144  if( m_Application->Execute() == 0 )
145  {
146  this->DisplayOutputParameters();
147  return true;
148  }
149  else
150  return false;
151 }
152 
154 {
155  try
156  {
157  if (this->BeforeExecute() == false)
158  {
159  return false;
160  }
161 
162  if( m_Application->ExecuteAndWriteOutput() == 0 )
163  {
164  this->DisplayOutputParameters();
165  }
166  else
167  return false;
168  }
169  catch(std::exception& err)
170  {
171  std::ostringstream message;
172  message << "The following error occurred during application execution : " << err.what() << std::endl;
173  m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, message.str() );
174  return false;
175  }
176  catch(...)
177  {
178  m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, "An unknown exception has been raised during application execution" );
179  return false;
180  }
181 
182  return true;
183 }
184 
186 {
187  if (m_Application.IsNull())
188  {
189  std::cerr << "ERROR: No loaded application..." << std::endl;
190  return false;
191  }
192 
193  // Check if there's keys in the expression if the application takes
194  // at least 1 mandatory parameter
195  const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
196  std::vector<std::string> keyList = m_Parser->GetKeyList( m_Expression );
197 
198  if( appKeyList.size()!=0 && keyList.size()==0 )
199  {
200  std::cerr << "ERROR: Waiting for at least one parameter..." << std::endl;
201  this->DisplayHelp();
202  return false;
203  }
204 
205  // if help is asked...
206  if (m_Parser->IsAttributExists("-help", m_Expression) == true)
207  {
208  this->DisplayHelp();
209  return false;
210  }
211 
212  // if we want to load test environnement
213  if (m_Parser->IsAttributExists("-testenv", m_Expression) == true)
214  {
215  this->LoadTestEnv();
216  }
217 
218  // Check the key validity (ie. exist in the application parameters)
219  std::string unknownKey;
220  if (this->CheckKeyValidity(unknownKey) == false)
221  {
222  std::cerr << "ERROR: option -"<<unknownKey<<" does not exist in the application." << std::endl;
223  this->DisplayHelp();
224  return false;
225  }
226  try
227  {
228  if (this->LoadParameters() != OKPARAM)
229  {
230  std::cerr << "ERROR: Troubles loading parameter, please check your line argument..." << std::endl;
231  // Force to reload the application, the LoadParameters can change wrong values
232  this->LoadApplication();
233  m_Application->Init();
234  this->DisplayHelp();
235 
236  return false;
237  }
238  }
239  catch (itk::ExceptionObject& err)
240  {
241  std::cerr << "ERROR: Troubles in parameter setting, please check your line argument..." << std::endl;
242  std::cerr << err.GetDescription() << std::endl;
243  // Force to reload the application, the LoadParameters can change wrong values
244  this->LoadApplication();
245  m_Application->Init();
246  this->DisplayHelp();
247 
248  return false;
249  }
250 
251  // Check for the progress report
252  if (m_Parser->IsAttributExists("-progress", m_Expression) == true)
253  {
254  std::vector<std::string> val;
255  val = m_Parser->GetAttribut("-progress", m_Expression);
256  if (val.size() != 1)
257  {
258  std::cerr << "ERROR: Invalid progress argument, must be unique value..." << std::endl;
259  return false;
260  }
261  if (val[0] == "1" || val[0] == "true")
262  {
263  m_ReportProgress = true;
264  }
265  else
266  if (val[0] == "0" || val[0] == "false")
267  {
268  m_ReportProgress = false;
269  }
270  else
271  {
272  std::cerr << "ERROR: Invalid progress argument, must be 0, 1, false or true..." << std::endl;
273  // Force to reload the application, the LoadParameters can change wrong values
274  this->LoadApplication();
275  this->DisplayHelp();
276 
277  return false;
278  }
279  }
280 
281  return true;
282 }
283 
285 {
286  std::vector<std::string> pathList;
287  // If users has set path...
288  if (m_Parser->GetPaths(pathList, m_Expression) == CommandLineParser::OK)
289  {
290  for (unsigned i = 0; i < pathList.size(); i++)
291  {
293  }
294  }
295  else
296  {
297  return false;
298  }
299 
300  return true;
301 }
302 
304 {
305  // Look for the module name
306  std::string moduleName;
307  if (m_Parser->GetModuleName(moduleName, m_Expression) != CommandLineParser::OK)
308  {
309  std::cerr << "ERROR: LoadApplication, no module found..." << std::endl;
310  return;
311  }
312 
313  // Instantiate the application using the factory
315 
316  if (m_Application.IsNull())
317  {
318  std::cerr << "ERROR: Could not find application \"" << moduleName << "\"" << std::endl;
319 
320  const char * ITK_AUTOLOAD_PATH = itksys::SystemTools::GetEnv("ITK_AUTOLOAD_PATH");
321  std::cerr << "ERROR: Module search path: " << (ITK_AUTOLOAD_PATH ? ITK_AUTOLOAD_PATH : "none (check ITK_AUTOLOAD_PATH)") << std::endl;
322 
323  std::vector<std::string> list = ApplicationRegistry::GetAvailableApplications();
324  if (list.size() == 0)
325  {
326  std::cerr << "ERROR: Available modules : none." << std::endl;
327  }
328  else
329  {
330  std::cerr << "ERROR: Available modules :" << std::endl;
331  for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
332  {
333  std::cerr << "\t" << *it << std::endl;
334  }
335  }
336  }
337  else
338  {
339  // Attach log output to the Application logger
340  m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
341  m_Application->GetLogger()->AddLogOutput(m_LogOutput);
342 
343  // Add an observer to the AddedProcess event
345 
346  }
347 }
348 
350 {
351  if (m_Application.IsNull())
352  {
353  itkExceptionMacro("No application loaded");
354  }
355 
356  const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
357  // Loop over each parameter key declared in the application
358  for (unsigned int i = 0; i < appKeyList.size(); i++)
359  {
360  const std::string paramKey(appKeyList[i]);
361  std::vector<std::string> values;
362  Parameter::Pointer param = m_Application->GetParameterByKey(paramKey);
363  ParameterType type = m_Application->GetParameterType(paramKey);
364 
365  const bool paramExists(m_Parser->IsAttributExists(std::string("-").append(paramKey), m_Expression));
366 
367  // if param is a Group, dont do anything, ParamGroup dont have values
368  if (type != ParameterType_Group)
369  {
370  // Get the attribute relative to this key as vector
371  values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_Expression);
372 
373  // If the param does not exists in the cli, dont try to set a
374  // value on it, an exception will be thrown later in this function
375  if (paramExists)
376  {
377  // Check if there is a value associated to the attribute
378  if ( values.empty() )
379  {
380  std::cerr << "ERROR: No value associated to the parameter : \"" << paramKey << "\", invalid number of values " << values.size() << std::endl;
381  return INVALIDNUMBEROFVALUE;
382  }
383 
384  // Ensure that the parameter is enabled
385  m_Application->EnableParameter(paramKey);
386 
388  {
389  dynamic_cast<InputVectorDataListParameter *> (param.GetPointer())->SetListFromFileName(values);
390  }
391  else
392  if (type == ParameterType_InputImageList)
393  {
394  dynamic_cast<InputImageListParameter *> (param.GetPointer())->SetListFromFileName(values);
395  }
396  else
397  if (type == ParameterType_StringList)
398  {
399  dynamic_cast<StringListParameter *> (param.GetPointer())->SetValue(values);
400  }
401  else
402  if (type == ParameterType_String)
403  {
404  dynamic_cast<StringParameter *> (param.GetPointer())->SetValue( m_Parser->GetAttributAsString(std::string("-").append(paramKey), m_Expression) );
405  }
406  else
407  if (type == ParameterType_OutputImage)
408  {
409  m_Application->SetParameterString(paramKey, values[0]);
410  // Check if pixel type is given
411  if (values.size() == 2)
412  {
414  if (values[1] == "uint8")
415  outPixType = ImagePixelType_uint8;
416  else if (values[1] == "int16")
417  outPixType = ImagePixelType_int16;
418  else if (values[1] == "uint16")
419  outPixType = ImagePixelType_uint16;
420  else if (values[1] == "int32")
421  outPixType = ImagePixelType_int32;
422  else if (values[1] == "uint32")
423  outPixType = ImagePixelType_uint32;
424  else if (values[1] == "float")
425  outPixType = ImagePixelType_float;
426  else if (values[1] == "double")
427  outPixType = ImagePixelType_double;
428  else
429  {
430  return WRONGPARAMETERVALUE;
431  }
432  dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType);
433  }
434  else
435  if (values.size() != 1 && values.size() != 2)
436  {
437  std::cerr << "ERROR: Invalid number of value for: \"" << paramKey << "\", invalid number of values " << values.size() << std::endl;
438  return INVALIDNUMBEROFVALUE;
439  }
440  }
441  else
442  if (type == ParameterType_ListView)
443  {
444  dynamic_cast<ListViewParameter *> (param.GetPointer())->SetSelectedNames(values);
445  }
446  else
447  if(values.size() != 1)
448  {
449  // Handle space in filename. Only for input
450  // files or directories
453  {
454  for(unsigned int i=1; i<values.size(); i++)
455  {
456  values[0].append(" ");
457  values[0].append(values[i]);
458  }
459  }
460  else if (!param->GetAutomaticValue())
461  {
462  std::cerr << "ERROR: Invalid number of value for: \"" << paramKey << "\", must have 1 value, not "
463  << values.size() << std::endl;
464  return INVALIDNUMBEROFVALUE;
465  }
466  }
467 
468  // Single value parameter
469  if (type == ParameterType_Choice || type == ParameterType_Float || type == ParameterType_Int || type
470  == ParameterType_Radius || type == ParameterType_Directory || type
473  || type == ParameterType_RAM)
474  {
475  m_Application->SetParameterString(paramKey, values[0]);
476  }
477  else
478  if (type == ParameterType_Empty)
479  {
480  if (values[0] == "1" || values[0] == "true")
481  {
482  dynamic_cast<EmptyParameter *> (param.GetPointer())->SetActive(true);
483  }
484  else
485  if (values[0] == "0" || values[0] == "false")
486  {
487  dynamic_cast<EmptyParameter *> (param.GetPointer())->SetActive(false);
488  }
489  else
490  {
491  std::cerr << "ERROR: Wrong parameter value: " << paramKey << std::endl;
492  return WRONGPARAMETERVALUE;
493  }
494  }
495  // Update the flag UserValue
496  param->SetUserValue(true);
497  // Call the DoUpdateParameter to update dependant params
498  m_Application->UpdateParameters();
499  }
500  }
501 
502  // When a parameter is mandatory :
503  // it must be set if :
504  // - The param is root
505  // - The param is not root and belonging to a Mandatory Group
506  // wich is activated
507  bool mustBeSet = false;
508  const bool hasValue = m_Application->HasValue(paramKey);
509 
510  if( param->GetMandatory() == true && param->GetRole() != Role_Output && type != ParameterType_Group)
511  {
512  // check if the parameter is linked to a root parameter with a chain of active parameters
513  if( param->IsRoot() || param->GetRoot()->IsRoot())
514  {
515  // the parameter is a root or inside a group at root level
516  mustBeSet = true;
517  }
518  else
519  {
520  Parameter* currentParam = param->GetRoot();
521  while (!currentParam->IsRoot())
522  {
523  if (!currentParam->GetActive())
524  {
525  // the missing parameter is not on an active branch : we can ignore it
526  break;
527  }
528  currentParam = currentParam->GetRoot();
529 
530  if (currentParam->IsRoot())
531  {
532  // the missing parameter is on an active branch : we need it
533  mustBeSet = true;
534  }
535  }
536  }
537  }
538 
539  if( mustBeSet )
540  {
541  if (!paramExists)
542  {
543  // If key doesn't exist and parameter hasn't default value set...
544  if (!hasValue)
545  {
546  std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << " " << m_Application->HasValue(paramKey)
547  << std::endl;
549  }
550  }
551  else
552  {
553  values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_Expression);
554  if (values.size() == 0 && !m_Application->HasValue(paramKey))
555  {
556  std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << std::endl;
557  return MISSINGPARAMETERVALUE;
558  }
559  }
560  }
561 
562  // Check if non mandatory parameter have values
563  else
564  {
565  if( paramExists )
566  {
567  values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_Expression);
568  if (values.size() == 0)
569  {
570  std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << std::endl;
571  return MISSINGPARAMETERVALUE;
572  }
573  }
574 
575  }
576  }
577  return OKPARAM;
578 }
579 
581 {
582  // Report the progress only if asked
583  if (m_ReportProgress)
584  {
585 
586  if (typeid(otb::Wrapper::AddProcessToWatchEvent) == typeid( event ))
587  {
588  const AddProcessToWatchEvent* eventToWacth = dynamic_cast<const AddProcessToWatchEvent*> (&event);
589 
591  eventToWacth->GetProcessDescription());
592  m_WatcherList.push_back(watch);
593  }
594  }
595 }
596 
598 {
599  std::cerr << std::endl;
600 
601  std::cerr << "This is the "<<m_Application->GetName() << " application."<<std::endl;
602  std::cerr<<std::endl;
603  std::cerr << m_Application->GetDescription() << std::endl;
604  std::cerr<<std::endl;
605  std::string link = "http://www.orfeo-toolbox.org/Applications/";
606  link.append(m_Application->GetName());
607  link.append(".html");
608 
609  std::cerr << "Complete documentation: " << link << std::endl;
610  std::cerr<<std::endl;
611  std::cerr << "Parameters: " << std::endl;
612 
613  const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
614  const unsigned int nbOfParam = appKeyList.size();
615 
616  m_MaxKeySize = std::string("progress").size();
617  for (unsigned int i = 0; i < nbOfParam; i++)
618  {
619  if (m_Application->GetParameterRole(appKeyList[i]) != Role_Output)
620  {
621  if( m_MaxKeySize < appKeyList[i].size() )
622  m_MaxKeySize = appKeyList[i].size();
623  }
624  }
625 
627  std::string bigKey = "progress";
628  for(unsigned int i=0; i<m_MaxKeySize-std::string("progress").size(); i++)
629  bigKey.append(" ");
630 
631  std::cerr << " -"<<bigKey<<" <boolean> Report progress " << std::endl;
632 
633  for (unsigned int i = 0; i < nbOfParam; i++)
634  {
635  Parameter::Pointer param = m_Application->GetParameterByKey(appKeyList[i]);
636  if (param->GetRole() != Role_Output)
637  {
638  std::cerr << this->DisplayParameterHelp(param, appKeyList[i]);
639  }
640  }
641 
642  std::cerr<<std::endl;
643  std::string cl(m_Application->GetCLExample());
644  std::cerr << m_Application->GetCLExample() << std::endl;
645 
646 }
647 
648 
650 {
651  //Set seed for rand and itk mersenne twister
652  //srand(1);
653  // itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed(121212);
654 }
655 
656 
657 std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & param, const std::string paramKey)
658 {
659  // Display the type the type
660  ParameterType type = m_Application->GetParameterType(paramKey);
661 
662  // Discard Group parameters (they don't need a value)
663  if (type == ParameterType_Group)
664  {
665  return "";
666  }
667 
668  std::ostringstream oss;
669 
670  // When a parameter is mandatory :
671  // it must be set if :
672  // - The param is root
673  // - The param is not root and belonging to a Mandatory Group
674  // wich is activated
675  bool isMissing = false;
676  if (!m_Parser->IsAttributExists(std::string("-").append(paramKey), m_Expression))
677  {
678  if (!m_Application->HasValue(paramKey))
679  {
680  if( param->GetMandatory() && param->GetRole() != Role_Output )
681  {
682  if( param->IsRoot() || param->GetRoot()->IsRoot())
683  {
684  // the parameter is a root or inside a group at root level
685  isMissing = true;
686  }
687  else
688  {
689  Parameter* currentParam = param->GetRoot();
690  while (!currentParam->IsRoot())
691  {
692  if (!currentParam->GetActive())
693  {
694  // the missing parameter is not on an active branch : we can ignore it
695  break;
696  }
697  currentParam = currentParam->GetRoot();
698 
699  if (currentParam->IsRoot())
700  {
701  // the missing parameter is on an active branch : we need it
702  isMissing = true;
703  }
704  }
705  }
706  }
707  }
708  }
709 
710  if( isMissing )
711  {
712  oss << "MISSING ";
713  }
714  else
715  {
716  oss << " ";
717  }
718 
719  std::string bigKey = paramKey;
720  for(unsigned int i=0; i<m_MaxKeySize-paramKey.size(); i++)
721  bigKey.append(" ");
722 
723  oss<< "-" << bigKey << " ";
724 
725  // Display the type the parameter
726  if (type == ParameterType_Radius || type == ParameterType_Int || type == ParameterType_RAM)
727  {
728  oss << "<int32> ";
729  }
730  else if (type == ParameterType_Empty )
731  {
732  oss << "<boolean> ";
733  }
734  else if (type == ParameterType_Float)
735  {
736  oss << "<float> ";
737  }
740  type == ParameterType_String || type == ParameterType_Choice )
741  {
742  oss << "<string> ";
743  }
744  else if (type == ParameterType_OutputImage)
745  {
746  oss << "<string> [pixel]";
747  }
750  {
751  oss << "<string list> ";
752  }
753  else
754  itkExceptionMacro("Not handled parameter type.");
755 
756 
757  oss<< " " << param->GetName() << " ";
758 
759  if (type == ParameterType_OutputImage)
760  {
761  oss << " [pixel=uint8/uint16/int16/uint32/int32/float/double]";
762  oss << " (default value is float)";
763  }
764 
765 
766  if (type == ParameterType_Choice)
767  {
768  std::vector<std::string> keys = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceKeys();
769  std::vector<std::string> names = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceNames();
770 
771  oss << "[";
772  for(unsigned int i=0; i<keys.size(); i++)
773  {
774  oss<<keys[i];
775  if( i != keys.size()-1 )
776  oss << "/";
777  }
778 
779  oss << "]";
780  }
781 
782  if(m_Application->IsMandatory(paramKey))
783  {
784  oss<<" (mandatory";
785  }
786  else
787  {
788  oss<<" (optional";
789 
790  if(m_Application->IsParameterEnabled(paramKey))
791  {
792  oss<<", on by default";
793  }
794  else
795  {
796  oss<<", off by default";
797  }
798  }
799 
800  if(m_Application->HasValue(paramKey))
801  {
802  oss<<", default value is "<<m_Application->GetParameterAsString(paramKey);
803  }
804  oss<<")";
805 
806  oss << std::endl;
807  return oss.str();
808 }
809 
811 {
812  bool res = true;
813  // Extract expression keys
814  std::vector<std::string> keyList = m_Parser->GetKeyList(m_Expression);
815 
816  // Check Unicity
817  for (unsigned int i = 0; i < keyList.size(); i++)
818  {
819  std::vector<std::string> listTmp = keyList;
820  const std::string keyRef = keyList[i];
821  listTmp.erase(listTmp.begin() + i);
822  for (unsigned int j = 0; j < listTmp.size(); j++)
823  {
824  if (keyRef == listTmp[j])
825  {
826  res = false;
827  break;
828  }
829  }
830  if (!res)
831  break;
832  }
833 
834  return res;
835 }
836 
838 {
839  bool res = true;
840  // Check if the chain " --" appears in the expression, could be a common mistake
841  if (m_Expression.find(" --") != std::string::npos )
842  {
843  res = false;
844  }
845 
846  return res;
847 }
848 
849 bool CommandLineLauncher::CheckKeyValidity(std::string& refKey)
850 {
851  bool res = true;
852  // Extract expression keys
853  std::vector<std::string> expKeyList = m_Parser->GetKeyList(m_Expression);
854 
855  // Extract application keys
856  std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
857  appKeyList.push_back("help");
858  appKeyList.push_back("progress");
859  appKeyList.push_back("testenv");
860 
861  // Check if each key in the expression exists in the application
862  for (unsigned int i = 0; i < expKeyList.size(); i++)
863  {
864  refKey = expKeyList[i];
865  bool keyExist = false;
866  for (unsigned int j = 0; j < appKeyList.size(); j++)
867  {
868  if (refKey == appKeyList[j])
869  {
870  keyExist = true;
871  break;
872  }
873  }
874  if (keyExist == false)
875  {
876  res = false;
877  break;
878  }
879  }
880 
881  return res;
882 }
883 
885 {
886  std::vector< std::pair<std::string, std::string> > paramList;
887  paramList = m_Application->GetOutputParametersSumUp();
888  if( paramList.size() == 0 )
889  return;
890 
891  std::ostringstream oss;
892  for( unsigned int i=0; i<paramList.size(); i++)
893  {
894  oss << paramList[i].first;
895  oss << ": ";
896  oss << paramList[i].second;
897  oss << std::endl;
898  }
899 
900 
901  if ( m_Parser->IsAttributExists("-testenv", m_Expression) )
902  {
903  std::vector<std::string> val = m_Parser->GetAttribut("-testenv", m_Expression);
904  if( val.size() == 1 )
905  {
906  std::ofstream ofs(val[0].c_str());
907  if (!ofs.is_open())
908  {
909  fprintf(stderr, "Error, can't open file");
910  itkExceptionMacro( << "Error, can't open file "<<val[0]<<".");
911  }
912  ofs << oss.str();
913  ofs.close();
914  }
915  }
916 
917  std::cout << "Output parameters value:" << std::endl;
918  std::cout << oss.str() << std::endl;
919 }
920 
921 }
922 }

Generated at Sun Feb 3 2013 00:59:08 for Orfeo Toolbox with doxygen 1.8.1.1