NModelParam< T > Class Template Reference

A class for params of type T that don't have command-line options. More...

#include <Component/ModelParam.H>

Inheritance diagram for NModelParam< T >:
Inheritance graph
[legend]
Collaboration diagram for NModelParam< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Access functions

virtual std::string getName () const
 get the ModelParamAuxImpl's name
getVal () const
 Get the value.
bool setVal (const T &v)
 Set the value.
virtual std::string getValString () const
 Get the value as a string.
virtual bool setValString (const std::string &textval)
 Set the parameter value from a textual representation, notify clients of the change.
virtual void getValGeneric (RefHolder &ref) const
 Get the current value through a dynamically-typed RefHolder.
virtual bool setValGeneric (const RefHolder &ref)
 Set the current value through a dynamically-typed RefHolder.
Input/Output functions

virtual void printout (std::ostream &s, const std::string &prefix="") const
 Print out our name and contents, mostly for debugging.
virtual void writeTo (ParamMap &pmap) const
 Write parameter value to ParamMap.
virtual void readFrom (const ParamMap &pmap, const bool noerr=true)
 Get parameter value from ParamMap.

Constructors and Destructors



 NModelParam (const std::string &nam, ParamClient *client, const T &initval, const ParamFlag flags=0)
 Construct with a string name only.
static rutz::shared_ptr
< NModelParam< T > > 
make (const std::string &nam, ParamClient *client, const T &initval, const ParamFlag flags=0)
 A "pseudo-constructor" that makes a rutz::shared_ptr<NModelParam>.

Detailed Description

template<class T>
class NModelParam< T >

A class for params of type T that don't have command-line options.

NModelParam delegates its implementation to ModelParamAuxImpl. NModelParam<T> offers getVal() and setVal() for direct access to the T value.

Note that the implementation is entirely inline so that we don't have to explicitly instantiate NModelParam<T> anywhere; plus these functions are small so any compile time hit from having the functions inline is small.

Note that we have two similar template types: NModelParam and OModelParam. The 'O' is for "command-line Option", and the 'N' is for "Not a command-line option". NModelParam only implements ModelParamBase and is constructed with a string for its parameter name. On the other hand, OModelParam implements OptionedModelParam, which means that it offers getOptionDef(), and it takes a ModelOptionDef* in its constructor instead of a string (the parameter name is taken from the ModelOptionDef).

Definition at line 234 of file ModelParam.H.


Constructor & Destructor Documentation

template<class T>
NModelParam< T >::NModelParam ( const std::string nam,
ParamClient client,
const T &  initval,
const ParamFlag  flags = 0 
) [inline]

Construct with a string name only.

Same as ModelParamAuxImpl plus an initial parameter value

Parameters:
flags If flags contains ALLOW_ONLINE_CHANGES, then this param will be marked as being able to be changed while the model is active.

Definition at line 577 of file ModelParam.H.


Member Function Documentation

template<class T>
virtual std::string NModelParam< T >::getName ( void   )  const [inline, virtual]

get the ModelParamAuxImpl's name

Implements ModelParamBase.

Definition at line 284 of file ModelParam.H.

template<class T>
T NModelParam< T >::getVal (  )  const [inline]

Get the value.

Note that there is no non-const function to get a non-const reference; that's because if we handed out a non-const reference then we'd have no way to know if callers changed the value, and we wouldn't be able to properly trigger paramChanged() on our ParamClient. Thus if you need to change the value, you should call getVal() to get a copy of the value, then do your modifications, then apply those changes with setVal(), which will trigger a paramChanged().

Definition at line 296 of file ModelParam.H.

Referenced by GaborChannel::angle(), DisparityChannel::angle(), DepthMotionChannel::buildSubChans(), StereoChannel::buildSubChans(), MotionSpatioTemporalChannel::buildSubChans(), MotionChannel::buildSubChans(), SingleOpponentChannel::centerSurround(), SingleChannel::centerSurround(), SDLdisplay::closeDisplay(), SingleChannel::combineSubMaps(), SingleChannel::computePyramid(), StereoChannel::dispChan(), PsychoDisplay::displayColorDotFixation(), PsychoDisplay::displayFixation(), PsychoDisplay::displayRedDotFixation(), PsychoDisplay::displayWhiteDotFixation(), SOColorChannel::doInput(), DisparityChannel::doInput(), RawVisualCortex::doInput(), StereoChannel::doInput(), ObjDetChannel::doInput(), FlickerChannel::doInput(), MultiConvolveChannel::doInput(), EntropyChannel::doInput(), InformationChannel::doInput(), FlickerNBackChannel::doInput(), ColorChannel::doInput(), SimulationViewerStd::drawEye(), SimulationViewerNerdCam::drawFOA(), SimulationViewerStd::drawFOA(), SimulationViewerStd::drawHead(), SimulationViewerStd::drawMegaCombo(), Serial::enablePort(), BeoSubBallast::get(), IntegerSimpleChannel::getRawCSmapInt(), SingleChannelSurprise< SMODEL >::getSurpriseMap(), SimulationViewerStd::getTraj(), SimulationViewerEyeRegion::getTraj(), SimulationViewerCompress::getTraj(), NModelParam< T >::getValGeneric(), NModelParam< uint >::getValString(), BeoSubBallast::input(), BeoChip::lcdGotoXY(), BeoChip::lcdPrintf(), SimulationViewerStd::linkEyes(), SimulationViewerNerdCam::linkFOAs(), SimulationViewerStd::linkFOAs(), SimulationViewerStd::linkHeads(), StereoChannel::paramChanged(), EnvInferoTemporal::paramChanged(), MovementController::paramChanged(), NeoBrain::paramChanged(), EnvVisualCortexBase::paramChanged(), DisparityChannel::phase(), SingleChannel::postProcessMap(), SimulationViewerStd::prepMapForDisplay(), lcd::printf(), Staircase::reset1(), SimulationViewerNerdCam::saveResults(), BeoSubBallast::set(), Staircase::setResponse(), SimulationViewerEyeRegion::start1(), SimulationViewerEyeMvtNeuro::start1(), JoyStick::start1(), ParPort::start1(), GaussianPyrChannel::start1(), SingleChannelSurprise< SMODEL >::start1(), BeoChip::start1(), PedestrianChannel::start1(), MultiConvolveChannel::start1(), SDLdisplay::start2(), Serial::start2(), Staircase::start2(), ComplexChannel::start2(), Staircase::stop1(), ParPort::stop2(), BeoSubTwoBal::thrust(), BeoSubOneBal::thrust(), ChannelBase::visualFeature(), and BeoSubMotor::WritePort().

template<class T >
void NModelParam< T >::getValGeneric ( RefHolder ref  )  const [inline, virtual]

Get the current value through a dynamically-typed RefHolder.

Implements ModelParamBase.

Definition at line 588 of file ModelParam.H.

References NModelParam< T >::getVal(), and SRC_POS.

template<class T>
virtual std::string NModelParam< T >::getValString (  )  const [inline, virtual]

Get the value as a string.

Implements ModelParamBase.

Definition at line 333 of file ModelParam.H.

template<class T>
static rutz::shared_ptr<NModelParam<T> > NModelParam< T >::make ( const std::string nam,
ParamClient client,
const T &  initval,
const ParamFlag  flags = 0 
) [inline, static]

A "pseudo-constructor" that makes a rutz::shared_ptr<NModelParam>.

This can be used in places that need arrays of NModelParam objects. Since NModelParam doesn't have a default constructor, we can't make an array of NModelParam objects. But we can make an array of rutz::shared_ptr<NModelParam> objects. Then we can initialize each in a loop by doing arr[i] = NModelParam<T>::make(...).

Note that an alternative to C-style arrays (where the type must have a default constructor) is to use std::vector. Then we can do vec.push_back(NModelParam<T>(...)) and build the vector incrementally, again without needed a default constructor.

Historical note: this substitutes for the previous strategy of giving NModelParam a default constructor plus an init() method that would be called in the array-initialization loop like arr[i].init(...), plus an initialized() methed. The current approach avoids the need for either init() or initialized(), instead we can let rutz::shared_ptr worry about whether the object is initialized -- we can test rutz::shared_ptr<NModelParam<T>>get() != 0 to see if the param is initialized.

Definition at line 273 of file ModelParam.H.

template<class T>
virtual void NModelParam< T >::printout ( std::ostream &  s,
const std::string prefix = "" 
) const [inline, virtual]

Print out our name and contents, mostly for debugging.

Implements ModelParamBase.

Definition at line 366 of file ModelParam.H.

template<class T>
virtual void NModelParam< T >::readFrom ( const ParamMap pmap,
const bool  noerr = true 
) [inline, virtual]

Get parameter value from ParamMap.

Parameters:
noerr will not generate an error message if the parameter does not exist in ParamMap.

Implements ModelParamBase.

Definition at line 377 of file ModelParam.H.

template<class T>
bool NModelParam< T >::setVal ( const T &  v  )  [inline]

Set the value.

Returns:
true if the change succeeded; false otherwise.

Definition at line 304 of file ModelParam.H.

Referenced by BlueChannel::BlueChannel(), BlueYellowChannel::BlueYellowChannel(), ColorBandChannel::ColorBandChannel(), Serial::configure(), Serial::configureSearch(), ConvolveChannel::ConvolveChannel(), DcolorChannel::DcolorChannel(), DirectionChannel::DirectionChannel(), FlickerChannel::FlickerChannel(), FlickerNBackChannel::FlickerNBackChannel(), GaborChannel::GaborChannel(), SimulationViewerStd::getTraj(), GreenChannel::GreenChannel(), GreenRedChannel::GreenRedChannel(), Hue1Channel::Hue1Channel(), Hue2Channel::Hue2Channel(), ImagizeAlphaChannel::ImagizeAlphaChannel(), ImagizeBetaChannel::ImagizeBetaChannel(), ImagizeLedChannel::ImagizeLedChannel(), IntegerDirectionChannel::IntegerDirectionChannel(), IntegerFlickerChannel::IntegerFlickerChannel(), IntegerIntensityChannel::IntegerIntensityChannel(), IntensityChannel::IntensityChannel(), JunctionChannel::JunctionChannel(), KcolorChannel::KcolorChannel(), ArmController::killMotors(), LcolorChannel::LcolorChannel(), MSTChannel::MSTChannel(), RedChannel::RedChannel(), RedGreenChannel::RedGreenChannel(), RGBConvolveChannel::RGBConvolveChannel(), SaturationChannel::SaturationChannel(), Serial::setBlocking(), Serial::setCharBits(), PsychoDisplay::setFixationSize(), Serial::setFlowControl(), Serial::setParity(), Serial::setSpeed(), Serial::setStopBits(), NModelParam< T >::setValGeneric(), NModelParam< uint >::setValString(), SIFTChannel::SIFTChannel(), SobelChannel::SobelChannel(), IntegerDirectionChannel::start1(), EnvVisualCortexBase::start1(), SimulationViewerNerdCam::start2(), DirectionChannel::start2(), SimulationViewerStd::start2(), ValueIntensityChannel::ValueIntensityChannel(), YellowBlueChannel::YellowBlueChannel(), and YellowChannel::YellowChannel().

template<class T >
bool NModelParam< T >::setValGeneric ( const RefHolder ref  )  [inline, virtual]

Set the current value through a dynamically-typed RefHolder.

Returns:
true if the change succeeded; false otherwise.

Implements ModelParamBase.

Definition at line 599 of file ModelParam.H.

References NModelParam< T >::setVal(), and SRC_POS.

template<class T>
virtual bool NModelParam< T >::setValString ( const std::string textval  )  [inline, virtual]

Set the parameter value from a textual representation, notify clients of the change.

Returns:
true if the change succeeded; false otherwise.

Implements ModelParamBase.

Definition at line 340 of file ModelParam.H.

template<class T>
virtual void NModelParam< T >::writeTo ( ParamMap pmap  )  const [inline, virtual]

Write parameter value to ParamMap.

Implements ModelParamBase.

Definition at line 371 of file ModelParam.H.


The documentation for this class was generated from the following file:
Generated on Sun May 8 08:43:37 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3