Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NModelParam< T > Class Template Reference

#include <Component/ModelParam.H>

Inheritance diagram for NModelParam< T >:

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

Collaboration graph
[legend]
List of all members.

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.

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>.

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.


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(), BeoSubMotor::BeoSubMotor(), StereoChannel::buildSubChans(), MotionChannel::buildSubChans(), SingleOpponentChannel::centerSurround(), SingleChannel::centerSurround(), SDLdisplay::closeDisplay(), SingleChannel::combineSubMaps(), SingleChannel::computePyramid(), StereoChannel::dispChan(), PsychoDisplay::displayFixation(), PsychoDisplay::displayRedDotFixation(), StereoChannel::doInput(), SOColorChannel::doInput(), MultiConvolveChannel::doInput(), InformationChannel::doInput(), FlickerChannel::doInput(), EntropyChannel::doInput(), DisparityChannel::doInput(), ColorChannel::doInput(), IntegerSimpleChannel::doInputInt(), SimulationViewerStd::drawEye(), SimulationViewerStd::drawFOA(), SimulationViewerNerdCam::drawFOA(), SimulationViewerStd::drawHead(), SimulationViewerStd::drawMegaCombo(), Serial::enablePort(), SubController::genPIDImage(), ArmController::genPIDImage(), BeoSubBallast::get(), NeoBrain::getBigErrFramesThresh(), Serial::getDeviceDescriptor(), NeoBrain::getDistTolerance(), NeoBrain::getErrTolerance(), SingleOpponentChannel::getFeatures(), SingleChannel::getFeatures(), SingleOpponentChannel::getFeaturesBatch(), SingleChannel::getFeaturesBatch(), EnvSegmenterCannyContour::getFoa(), EnvInferoTemporal::getLabeledImages(), SingleChannel::getMinPyrLevel(), NeoBrain::getNoMoveFramesThresh(), IntegerSimpleChannel::getOutputInt(), IntegerSimpleChannel::getRawCSmapInt(), NeoBrain::getRelaxNeck(), EnvSegmenterCannyContour::getSquares(), IntegerSimpleChannel::getSubmapInt(), SingleChannelSurprise< SMODEL >::getSurpriseMap(), NeoBrain::getTargetFramesThresh(), SimulationViewerStd::getTraj(), SimulationViewerCompress::getTraj(), NeoBrain::getUseHead(), NModelParam< T >::getValGeneric(), BeoSubBallast::input(), ArmController::isControllerOn(), NeoBrain::isSleeping(), BeoChip::lcdGotoXY(), BeoChip::lcdPrintf(), SimulationViewerStd::linkEyes(), SimulationViewerStd::linkFOAs(), SimulationViewerNerdCam::linkFOAs(), SimulationViewerStd::linkHeads(), modelparam_xx_getset_xx_1(), modelparam_xx_getset_xx_3(), NeoBrain::moveHeadToTarget(), MovementController::paramChanged(), NeoBrain::paramChanged(), EnvInferoTemporal::paramChanged(), StereoChannel::paramChanged(), DisparityChannel::phase(), SingleChannel::postProcessMap(), SimulationViewerStd::prepMapForDisplay(), lcd::printf(), Staircase::reset1(), GaborChannel::resetPyramid(), SimulationViewerNerdCam::saveResults(), BeoSubMotor::SendCh(), BeoSubBallast::set(), Staircase::setResponse(), SingleChannelSurprise< SMODEL >::start1(), ParPort::start1(), JoyStick::start1(), BeoChip::start1(), PedestrianChannel::start1(), MultiConvolveChannel::start1(), Staircase::start2(), SDLdisplay::start2(), Serial::start2(), Staircase::stop1(), ParPort::stop2(), BeoSubTwoBal::thrust(), BeoSubOneBal::thrust(), NeoBrain::updateExcitement(), SubController::updatePID(), ArmController::updatePID(), PWiiController::updateWiimote(), 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(), SRC_POS, rutz::throw_bad_cast(), and RefHolder::type().

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.

Referenced by modelparam_xx_getset_xx_1(), and modelparam_xx_getset_xx_2().

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.

Referenced by BeoChip::BeoChip(), Pololu::Pololu(), SC8000::SC8000(), SSC::SSC(), and RadioDecoder::start1().

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.

Referenced by modelparam_xx_readfrom_xx_1().

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(), GaborChannel::GaborChannel(), SimulationViewerStd::getTraj(), NeoBrain::gotoSleep(), 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(), modelparam_xx_getset_xx_1(), modelparam_xx_getset_xx_3(), MSTChannel::MSTChannel(), RedChannel::RedChannel(), RedGreenChannel::RedGreenChannel(), RGBConvolveChannel::RGBConvolveChannel(), SaturationChannel::SaturationChannel(), NeoBrain::setBigErrFramesThresh(), Serial::setBlocking(), Serial::setCharBits(), SingleChannel::setComputeFullPyramid(), ArmController::setControllerOn(), NeoBrain::setDistTolerance(), NeoBrain::setErrTolerance(), Serial::setFlowControl(), SubController::setMotorsOn(), ArmController::setMotorsOn(), NeoBrain::setNoMoveFramesThresh(), IntegerSimpleChannel::setNormalizeOutput(), Serial::setParity(), SubController::setPidOn(), ArmController::setPidOn(), NeoBrain::setRelaxNeck(), Serial::setSpeed(), Serial::setStopBits(), IntegerSimpleChannel::setTakeAbs(), NeoBrain::setTargetFramesThresh(), NeoBrain::setUseHead(), NModelParam< T >::setValGeneric(), NModelParam< uint >::setValString(), SIFTChannel::SIFTChannel(), SobelChannel::SobelChannel(), IntegerDirectionChannel::start1(), SimulationViewerStd::start2(), SimulationViewerNerdCam::start2(), DirectionChannel::start2(), NeoBrain::trackObject(), NeoBrain::updateExcitement(), PWiiController::updateWiimote(), ValueIntensityChannel::ValueIntensityChannel(), NeoBrain::wakeUp(), 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(), SRC_POS, rutz::throw_bad_cast(), and RefHolder::type().

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.

Referenced by modelparam_xx_getset_xx_1(), and modelparam_xx_getset_xx_2().

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.

Referenced by modelparam_xx_writeto_xx_1().


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 13:46:06 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4