KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Multi_model_recorder< Model > Class Template Reference

#include <sample_recorder.h>

Public Types

typedef Model Model_type
 
typedef Null_value Value_type
 

Public Member Functions

 Multi_model_recorder ()
 
virtual void operator() (const Model &m, const Step_log< Model > &step_log)
 
size_t size () const
 
template<class RecorderIn >
void push_back (const RecorderIn &r)
 
template<class RecorderIn >
void add (const RecorderIn &r_in)
 
template<class RecorderIn >
void add (const typename boost::reference_wrapper< RecorderIn > &r)
 
template<class RecorderIn >
void add (const typename boost::shared_ptr< RecorderIn > &r)
 
template<class RecorderIn >
void add (RecorderIn *r)
 
const Value_typeget () const
 Useless: returns void. Call the original recorders' get() methods directly. More...
 
template<class RecorderOut >
const RecorderOut & get_recorder (size_t i) const
 
template<class RecorderOut >
const RecorderOut::Value_type & get (size_t i) const
 

Protected Types

typedef Model_recorder< Model > Recorder
 

Protected Member Functions

 BOOST_CONCEPT_ASSERT ((BaseModel< Model >))
 

Protected Attributes

std::vector< typename
Model_recorder< Model >::Type > 
record_callbacks_
 
std::vector< boost::any > recorders_
 
std::vector< bool > is_reference_
 

Detailed Description

template<class Model>
class Multi_model_recorder< Model >

Implements the Model_recorder concept.

Collection of recorders that are called in sequence.

Note
This recorder's get() method is useless. To get values from individual recorders, call the get<>(int) template method (see example code below).

typedef Best_model_recorder<Model> Best_recorder; typedef boost::shared_ptr<Best_recorder> Best_recorder_ptr; Multi_model_recorder<Model> recorders;

// Initialize multi-recorder // example 1: simple add Best_recorder r1; recorders.add(r1);

// example 2: inline add recorders.add( Best_recorder() );

// example 3: add by pointer Best_recorder_ptr r3(new Best_recorder()); recorders.add(r3);

// example 4: add by reference Best_recorder r4; recorders.add(boost::ref(r4));

// RUN SAMPLER Sampler sampler(..., recorders); sampler.run(1000);

// RETRIEVE RESULTS Model best;

// EXAMPLE 1: GET RECORDED VALUE DIRECTLY best = sampler.get_recorder().get<Best_recorder>(0);

// EXAMPLE 2: GET RECORDER FIRST, THEN GET VALUES // This allows us to call the speciailized methods of the // recorder, e.g. Best_model_recorder::get_log_target().

Best_recorder& tmp = sampler.get_recorder().get_recorder<Best_recorder>(0); best = tmp.get(); best_target = tmp.get_log_target();

// EXAMPLE 3: using passed-in pointer/reference // Since r3 and r4 were passed by pointer and reference, // we can get results directly from them.

best = r3->get(); best = r4.get();

// Note that if we tried // this with r1, we wouldn't get anything, because it was // copied into the multi-recorder, whereas r3 and r4 were // stored as references.

Member Typedef Documentation

template<class Model>
typedef Model Multi_model_recorder< Model >::Model_type
template<class Model>
typedef Model_recorder<Model> Multi_model_recorder< Model >::Recorder
protected
template<class Model>
typedef Null_value Multi_model_recorder< Model >::Value_type

Constructor & Destructor Documentation

template<class Model>
Multi_model_recorder< Model >::Multi_model_recorder ( )
inline

Member Function Documentation

template<class Model>
template<class RecorderIn >
void Multi_model_recorder< Model >::add ( const RecorderIn &  r_in)
inline

Add a Recorder by value. Recorder is copied.

template<class Model>
template<class RecorderIn >
void Multi_model_recorder< Model >::add ( const typename boost::reference_wrapper< RecorderIn > &  r)
inline

Add a Recorder by reference.

template<class Model>
template<class RecorderIn >
void Multi_model_recorder< Model >::add ( const typename boost::shared_ptr< RecorderIn > &  r)
inline

Add a Recorder using a smart pointer.

template<class Model>
template<class RecorderIn >
void Multi_model_recorder< Model >::add ( RecorderIn *  r)
inline

Add a Recorder using a smart pointer.

template<class Model>
Multi_model_recorder< Model >::BOOST_CONCEPT_ASSERT ( (BaseModel< Model >)  )
protected
template<class Model>
const Value_type& Multi_model_recorder< Model >::get ( ) const
inline

Useless: returns void. Call the original recorders' get() methods directly.

template<class Model>
template<class RecorderOut >
const RecorderOut::Value_type& Multi_model_recorder< Model >::get ( size_t  i) const
inline
template<class Model>
template<class RecorderOut >
const RecorderOut& Multi_model_recorder< Model >::get_recorder ( size_t  i) const
inline
template<class Model>
virtual void Multi_model_recorder< Model >::operator() ( const Model &  m,
const Step_log< Model > &  step_log 
)
inlinevirtual
template<class Model>
template<class RecorderIn >
void Multi_model_recorder< Model >::push_back ( const RecorderIn &  r)
inline
Warning
DEPRECATED. Use add() instead.
template<class Model>
size_t Multi_model_recorder< Model >::size ( ) const
inline

Member Data Documentation

template<class Model>
std::vector<bool> Multi_model_recorder< Model >::is_reference_
protected
template<class Model>
std::vector<typename Model_recorder<Model>::Type > Multi_model_recorder< Model >::record_callbacks_
protected
template<class Model>
std::vector<boost::any> Multi_model_recorder< Model >::recorders_
protected

The documentation for this class was generated from the following file: