ModelParamAuxImpl Class Reference

Helper implementation class for NModelParam and OModelParam. More...

#include <Component/ModelParam.H>

Collaboration diagram for ModelParamAuxImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ModelParamAuxImpl (OptionedModelParam *self, const ModelOptionDef *def, ParamClient *client, const ParamFlag flags, const std::type_info &valtype)
 Construct from a ModelOptionDef*.
 ModelParamAuxImpl (ModelParamBase *self, const std::string &nam, ParamClient *client)
 Construct with a string name only.
 ~ModelParamAuxImpl ()
 Destructor.
std::string getName () const
 get the ModelParamAuxImpl's name
const ModelOptionDefgetOptionDef () const
 get the associated option def
void printout (std::ostream &s, const std::string &prefix) const
 Print out our name and contents, mostly for debugging.
void writeTo (ParamMap &pmap) const
 Write parameter value to ParamMap.
void readFrom (const ParamMap &pmap, const bool noerr)
 Get parameter value from ParamMap.
ParamClient::ChangeStatus sendChangedMessage (bool didchange)
 Call paramChanged() on our client.
pthread_mutex_t * readLock () const
 Get a mutex for locking the parameter value for reading.
pthread_mutex_t * writeLock () const
 Get a mutex for locking the parameter value for writing.

Static Public Member Functions

static const char * defaultValueOf (const ModelOptionDef *def)
 Convenience function to retrieve def->defval.

Detailed Description

Helper implementation class for NModelParam and OModelParam.

Definition at line 61 of file ModelParam.H.


Constructor & Destructor Documentation

ModelParamAuxImpl::ModelParamAuxImpl ( OptionedModelParam self,
const ModelOptionDef def,
ParamClient client,
const ParamFlag  flags,
const std::type_info &  valtype 
)

Construct from a ModelOptionDef*.

This model param will get its name from the ModelOptionDef*.

Parameters:
self pointer to the object that is using this impl
client the ParamClient we are attached to
nam the name of the TModelParamBase, that will be used to store its value in a ParamMap and fetch command-line option configuration data.
flags can be set to USE_MY_VAL in order to take this param's value as the new default value, otherwise pass 0 for flags
valtype the typeid of the parameter; we will check to make sure this matches the typeid declared by the ModelOptionDef

Definition at line 79 of file ModelParam.C.

References ASSERT, rutz::demangled_name(), ModelOptionDef::name, ParamClient::registerOptionedParam(), and ModelOptionDef::type.

ModelParamAuxImpl::ModelParamAuxImpl ( ModelParamBase self,
const std::string nam,
ParamClient client 
)

Construct with a string name only.

This model param will NOT be associated with any ModelOptionDef -- to get that, use the other constructor that takes a ModelOptionDef* instead of a name.

Parameters:
self pointer to the object that is using this impl
client the ParamClient we are attached to
nam the name of the ModelParamAuxImpl, that will be used to store its value in a ParamMap and fetch command-line option configuration data.

Definition at line 120 of file ModelParam.C.

References ASSERT, and ParamClient::registerParam().

ModelParamAuxImpl::~ModelParamAuxImpl (  ) 

Destructor.

Definition at line 145 of file ModelParam.C.

References ASSERT, and ParamClient::unregisterParam().


Member Function Documentation

const char * ModelParamAuxImpl::defaultValueOf ( const ModelOptionDef def  )  [static]

Convenience function to retrieve def->defval.

The reason we have this here is so that we don't have to include ModelOptionDef.H from this widely-used header file.

Definition at line 235 of file ModelParam.C.

References ModelOptionDef::defval.

std::string ModelParamAuxImpl::getName ( void   )  const

get the ModelParamAuxImpl's name

Definition at line 163 of file ModelParam.C.

References ASSERT.

Referenced by NModelParam< uint >::getName(), and OModelParam< Point2D< float > >::getName().

const ModelOptionDef * ModelParamAuxImpl::getOptionDef (  )  const

get the associated option def

Definition at line 171 of file ModelParam.C.

References ASSERT.

Referenced by OModelParam< Point2D< float > >::getOptionDef().

void ModelParamAuxImpl::printout ( std::ostream &  s,
const std::string prefix 
) const

Print out our name and contents, mostly for debugging.

Definition at line 181 of file ModelParam.C.

References ASSERT, and ModelParamBase::getValString().

Referenced by OModelParam< Point2D< float > >::printout(), and NModelParam< uint >::printout().

void ModelParamAuxImpl::readFrom ( const ParamMap pmap,
const bool  noerr 
)

Get parameter value from ParamMap.

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

Definition at line 197 of file ModelParam.C.

References ASSERT, ParamMap::CHANGED, ModelParamBase::getValString(), ParamMap::MISSING, ParamMap::queryStringParam(), and ModelParamBase::setValString().

Referenced by OModelParam< Point2D< float > >::readFrom(), and NModelParam< uint >::readFrom().

pthread_mutex_t* ModelParamAuxImpl::readLock (  )  const [inline]

Get a mutex for locking the parameter value for reading.

We only return an actual mutex if we were passed ALLOW_ONLINE_CHANGES in our constructor (i.e., ModelParamBase::allowsOnlineChanges() returns true); that's because we assume that if online parameter changes are disabled, then there is no need for between-thread synchronization of our parameter value.

The returned mutex, if non-null, will be a recursive mutex so that we can allow reentrant calls to getVal() from within a setVal() in the same thread, while still blocking getVal() calls from other threads during a setVal() call.

Definition at line 138 of file ModelParam.H.

Referenced by NModelParam< uint >::getVal(), OModelParam< Point2D< float > >::getVal(), OModelParam< Point2D< float > >::setVal(), and NModelParam< uint >::setVal().

ParamClient::ChangeStatus ModelParamAuxImpl::sendChangedMessage ( bool  didchange  ) 

Call paramChanged() on our client.

Definition at line 213 of file ModelParam.C.

References ParamClient::paramChanged().

Referenced by OModelParam< Point2D< float > >::setVal(), and NModelParam< uint >::setVal().

pthread_mutex_t* ModelParamAuxImpl::writeLock (  )  const [inline]

Get a mutex for locking the parameter value for writing.

We only return an actual mutex if we were passed ALLOW_ONLINE_CHANGES in our constructor (i.e., ModelParamBase::allowsOnlineChanges() returns true); that's because we assume that if online parameter changes are disabled, then there is no need for between-thread synchronization of our parameter value.

The returned mutex, if non-null, will be an error-checking mutex so that we can detect attempts to acquire the lock more than once from within the same thread. These attempts would represent reentrant setVal() calls, such as when setVal() triggers a paramChanged() call that in turn triggers another setVal() of the same parameter (which is forbidden by design).

Definition at line 156 of file ModelParam.H.

Referenced by OModelParam< Point2D< float > >::setVal(), and NModelParam< uint >::setVal().

void ModelParamAuxImpl::writeTo ( ParamMap pmap  )  const

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