29 #ifndef OPTIMIZER_OBSERVER_HXX_
30 #define OPTIMIZER_OBSERVER_HXX_
35 #include <itkCommand.h>
37 #include <Core/Utils/Log.h>
43 template <
typename TOptimizer>
48 typedef itk::Command Superclass;
49 typedef itk::SmartPointer<Self> Pointer;
53 void Execute(itk::Object *caller,
const itk::EventObject & event)
54 { Execute((
const itk::Object *)(caller), event); }
56 void Execute(
const itk::Object *
object,
const itk::EventObject & event)
58 if (
typeid(event) !=
typeid(itk::IterationEvent))
return;
60 const TOptimizer * optimizer =
dynamic_cast<const TOptimizer *
>(object);
61 std::ostringstream oss;
62 oss << static_cast<unsigned int>(optimizer->GetCurrentIteration()) <<
'\t'
63 << optimizer->GetValue() <<
'\t'
64 << optimizer->GetCurrentPosition() << std::endl;
65 CORE_LOG_MESSAGE(oss.str());
73 #endif // OPTIMIZER_OBSERVER_HXX_
Definition: optimizer_observer.hxx:44