#include <OMKParametersAccessor.h>
Public Member Functions | |
Specialisations of template methods. | |
template<> | |
bool | getTxtValue (const std::string &textValue, std::string &value) |
Specialisation for string. | |
template<> | |
bool | setTxtValue (std::string &textValue, const std::string &value) |
Specialisation for string. | |
template<> | |
bool | getValue (const ConfigurationParameterDescriptor *nodeValue, const ConfigurationParameterDescriptor *&value, std::string &errorStr) |
Specialisation for const node. | |
template<> | |
bool | getValue (const ConfigurationParameterDescriptor *nodeValue, ConfigurationParameterDescriptor *&value, std::string &errorStr) |
Specialisation for node. | |
Static Public Member Functions | |
The get methods to read a value in a node. | |
template<typename T> | |
static bool | get (const ConfigurationParameterDescriptor *node, const std::string &name, T &value, SimulatedObject *object=0) |
Retrieves a value of type "T". | |
The get methods to read a enum in a node. | |
template<typename T> | |
static bool | get (const ConfigurationParameterDescriptor *node, const std::string &name, T &value, const std::map< std::string, T > &mapping, SimulatedObject *object=0) |
Retrieves a value of enum "T". | |
The get methods to read a object name in a node. | |
static bool | getAndCheckObject (const ConfigurationParameterDescriptor *node, const std::string &name, Name &objectName, Controller &controller, SimulatedObject *object=0) |
Retrieves a object name and check its existance in the configuration tree. | |
The set methods to write a value in a node. | |
template<typename T> | |
static ConfigurationParameterDescriptor * | set (ConfigurationParameterDescriptor *&node, const std::string &name, const T &value) |
Allows to append the data to the node. | |
static ConfigurationParameterDescriptor * | set (ConfigurationParameterDescriptor *&node, const std::string &name, ConfigurationParameterDescriptor *newNode) |
Specialisation for ConfigurationParameterDescriptor pointer. | |
The set methods to read a enum in a node. | |
template<typename T> | |
static ConfigurationParameterDescriptor * | set (ConfigurationParameterDescriptor *&node, const std::string &name, const T &value, const std::map< T, std::string > &mapping) |
Allows to append the enum "T" to the node. | |
Static Protected Member Functions | |
The getValue methods to read the value in a node. | |
Many types for many cases. | |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, bool &value, std::string &errorStr) |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, Type::Color &value, std::string &errorStr) |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, Type::Transform &value, std::string &errorStr) |
template<typename T> | |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, IAttributeBaseT< T > &value, std::string &errorStr) |
template<typename T> | |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, std::vector< T > &value, std::string &errorStr) |
template<typename T> | |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, std::list< T > &value, std::string &errorStr) |
template<typename T1, typename T2> | |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, std::pair< T1, T2 > &value, std::string &errorStr) |
template<typename TK, typename TD> | |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, std::map< TK, TD > &value, std::string &errorStr) |
template<typename T> | |
static bool | getValue (const ConfigurationParameterDescriptor *nodeValue, T &value, std::string &errorStr) |
Protected methods to convert text, find node and display error. | |
template<typename T> | |
static bool | getTxtValue (const std::string &textValue, T &value) |
Gets a value from a string Retrieves the value in the string. | |
static const ConfigurationParameterDescriptor * | getNodeValue (const ConfigurationParameterDescriptor *node, const std::string &name, std::string &errorStr) |
Retrieve the node named name in the tree. | |
static bool | displayError (const std::string &name, const std::string &functionName, SimulatedObject *object, const std::string &errorStr) |
Display the message errorStr. | |
Protected methods to convert value. | |
template<typename T> | |
static bool | setTxtValue (std::string &textValue, const T &value) |
Gets a string from a value. | |
The setValue methods to create a node with a value. | |
Many types for many cases. | |
template<typename T> | |
static ConfigurationParameterDescriptor * | setValue (const T &value, std::string &errorStr) |
static ConfigurationParameterDescriptor * | setValue (const bool &value, std::string &errorStr) |
static ConfigurationParameterDescriptor * | setValue (const Type::Color &value, std::string &errorStr) |
static ConfigurationParameterDescriptor * | setValue (const Type::Transform &value, std::string &errorStr) |
template<typename T> | |
static ConfigurationParameterDescriptor * | setValue (const IAttributeBaseT< T > &values, std::string &errorStr) |
template<typename T> | |
static ConfigurationParameterDescriptor * | setValue (const std::vector< T > &values, std::string &errorStr) |
template<typename T> | |
static ConfigurationParameterDescriptor * | setValue (const std::list< T > &value, std::string &errorStr) |
template<typename TK, typename TD> | |
static ConfigurationParameterDescriptor * | setValue (const std::map< TK, TD > &value, std::string &errorStr) |
template<typename T1, typename T2> | |
static ConfigurationParameterDescriptor * | setValue (const std::pair< T1, T2 > &value, std::string &errorStr) |
// mean true flag true flag True flag TRUE flag on flag 1 flag enable flag yes // means false flag false flag off flag 0 flag disable flag no
black [0 0 0] white [1 1 1] withAlpha [0.4 0.3 1.0 .5] fullGreen [255 0 0] darkGreen [0.5 0 0]
withAlpha "0.4 0.3 1.0 .5"
The transform is a array [translation rotation scale] where:
identity [[0 0 0]] translation [[1 1 1]] rotationEuler [[0 0 0][0 1.57 0]] // radian is implicit rotationEulerR [[0 0 0][0 1.57 0 r]] // radian rotationEulerD [[0 0 0][0 180 0 d]] // degrees rotationEulerG [[0 0 0][0 200 0 g]] // grad rotationEulerP [[0 0 0][0 1 0 p]] // faction of pi rotationMatrix [[0 0 0][1 0 0 0 1 0 0 0 1]] uniformScale [[0 0 0][0 0 0][2]] scale [[0 0 0][0 0 0][2 4 1]]
std::pair< int, std::string > myPair ; ParametersAccessor::get( node, "MyPair", myPair ) ;
MyPair [3 "is three"]
std::vector< std::string > values ; // or std::list< std::string > values ; ParametersAccessor::get( node, "ASet", values ) ;
ASet ["one" "two" "three"]
std::map< std::string, int > values ; ParametersAccessor::get( node, "AMap", values ) ;
AMap [["one" 1] ["two" 2] ["three" 3]]
std::vector< std::vector< float > > values ; ParametersAccessor::get( node, "Identity", values ) ;
Identity [[1.0 0.0 0.0][0.0 1.0 0.0][0.0 0.0 1.0]]
std::vector< std::pair< std::vector< float >, std::string > > positionsAndNames ; ParametersAccessor::get( node, "Set", positionsAndNames ) ; x = positionsAndNames[0].first[0] ; y = positionsAndNames[0].first[1] ; name = positionsAndNames[0].second ;
Set [[[1.0 1.0] "upperright"] [[-1.0 -1.0] "bottomleft"]]
The transform is a array [translation rotation scale] where:
The equivalent configuration parameter of this example are :
Animator { ... mySwitchAnimator { Class SwitchAnimator EventId SwitchStringEvent FileTab [ badTie.scene goodTie.scene ] } ...
// Creates the data for the switch animator ConfigurationParameterDescriptor * switchAnimatorNode = 0 ; ParametersAccessor::set( switchAnimatorNode, "Class", "SwitchAnimator" ) ; ParametersAccessor::set( switchAnimatorNode, "EventId", "SwitchStringEvent" ) ; std::vector< std::string > tab ; tab.push_back( "badTie.scene" ); tab.push_back( "goodTie.scene" ); ParametersAccessor::set( switchAnimatorNode, "FileTab", tab ) ; // Looking for the "Animator" node ConfigurationParameterDescriptor * animatorNode = 0 ; ParametersAccessor::get( theVisualisation->getObjectDescriptor()->getConfigurationParameters (), "Animator", animatorNode ); // adds them to the Animator field of the visualisation // Here we should test if animatorNode is not null or create it ParametersAccessor::set( animatorNode, "mySwitchAnimator", switchAnimatorNode ) ;
Definition at line 218 of file OMKParametersAccessor.h.
bool OMK::ParametersAccessor::get | ( | const ConfigurationParameterDescriptor * | node, | |
const std::string & | name, | |||
T & | value, | |||
SimulatedObject * | object = 0 | |||
) | [inline, static] |
Retrieves a value of type "T".
[in] | node | the node where is the parameter |
[in] | name | the name of the parameter to find |
[out] | value | the returned value of type T |
[in] | object | the simulated object which try to retrieve the information (default is null) only use to display error message. |
Definition at line 99 of file OMKParametersAccessor.inl.
References displayError(), getNodeValue(), and getValue().
Referenced by OMK::Vis::Animator::Animator(), OMK::Vis::AnimatorT< T >::AnimatorT(), OMK::MKMHumano::computeParameters(), OMK::Controller::Controller(), OMK::Iii::InteractorOutput::create(), OMK::Iii::IConvertorT< TypeOut, TypeIn >::create(), OMK::ExtensionManager::createExtensionsFromParameters(), OMK::Inp::InputExtension::createOISInputSystem(), OMK::StaticHumano::getInitialiseSequence(), OMK::MovingHumano::getVisualObjectPrm(), OMK::Iii::IAccessRule::IAccessRule(), OMK::Iii::IConnector::IConnector(), OMK::Vis::SwitchAnimator::init(), OMK::PluginsLoaderClass::init(), OMK::Clock::init(), OMK::IAttributeAnimatorT< PrmType, ModelType, AccessorType >::initAnimator(), OMK::Inp::InputExtension::initCallBackForKey(), OMK::Type::AddVisualObjectPrm::innerParametersLoader(), OMK::Inp::AddInputListenerPrm::innerParametersLoader(), OMK::Inp::AddInputKeyPrm::innerParametersLoader(), OMK::Type::AddAnimatorPrm::innerParametersLoader(), OMK::Inp::KeyListener::KeyListener(), OMK::Vis::OgreObjectScene::loadConfigurationParameters(), OMK::TriggerAttributeExtension::loadExtensionParameters(), OMK::DistanceToExtension::loadExtensionParameters(), OMK::MultiTriggerEmitterExtensionT< T, ModelType >::loadExtensionParameters(), OMK::TriggerEmitterExtensionT< T, ModelType >::loadExtensionParameters(), OMK::TriggerEmitterExtension::loadExtensionParameters(), OMK::MultiTriggerContainerExtension::loadExtensionParameters(), OMK::TriggerContainerExtension::loadExtensionParameters(), OMK::Inp::PlusMinusExtension< T >::loadExtensionParameters(), OMK::Inp::OverlayExtension::loadExtensionParameters(), OMK::PreOffsetExtension::loadExtensionParameters(), OMK::MKMMoveToTaskExtension::loadExtensionParameters(), OMK::MKMMotionTaskExtension::loadExtensionParameters(), OMK::Iii::JointExtension::loadExtensionParameters(), OMK::Iii::JointInteractorExtension::loadExtensionParameters(), OMK::Iii::InteractorExtension::loadExtensionParameters(), OMK::Iii::InteractiveExtension::loadExtensionParameters(), OMK::Inp::InputExtension::loadExtensionParameters(), OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::loadExtensionParameters(), OMK::DuplicatedAttributeExtension< AttributType, Type >::loadExtensionParameters(), OMK::Inp::DebugOverlayExtension::loadExtensionParameters(), OMK::ContainerExtension::loadExtensionParameters(), OMK::ExtensionManager::loadFromExtensionsParameters(), OMK::Vis::VisObjectExtension::loadObjectParameters(), OMK::Iii::JointInteractorExtension::loadObjectParameters(), OMK::ExtensionManager::loadOrder(), OMK::Trajectory::loadParameters(), OMK::Tracker::loadParameters(), OMK::Vis::OgreVis::loadParameters(), OMK::IAttribute::loadParameters(), OMK::HumanoRecorder::loadParameters(), OMK::HumanoPlayer::loadParameters(), OMK::Iii::AssociatedConnectorT< Type >::loadParameters(), OMK::IAttributeAnimatorT< PrmType, ModelType, AccessorType >::loadParameters(), OMK::IAttributeBaseT< PrmType >::loadParameters(), OMK::MultiValuedEventSignalEmitterUtilT< T, ModelType >::loadParametersUtil(), OMK::ValuedEventSignalEmitterUtilT< T, ModelType >::loadParametersUtil(), OMK::EventSignalEmitterUtil::loadParametersUtil(), OMK::loadSignalRegistrationParameters(), OMK::Vis::OgreAnimatorCommon::OgreAnimatorCommon(), OMK::PvmController::PvmController(), OMK::Vis::VisualObject::readConfigurationParameters(), OMK::Inp::DistributedCameraListener::readConfigurationParameters(), OMK::Inp::InputListener::retrieveCodeFromConfig(), and OMK::IAttribute::setOwner().
00102 { 00103 std::string errorStr ; 00104 // Get the node for the value 00105 const ConfigurationParameterDescriptor * nodeValue = getNodeValue( node, name, errorStr ) ; 00106 // if it is good, get the value else display error 00107 return ( nodeValue && getValue( nodeValue, value, errorStr ) ) 00108 || displayError( name, "get", object, errorStr ) ; 00109 } 00110
bool OMK::ParametersAccessor::get | ( | const ConfigurationParameterDescriptor * | node, | |
const std::string & | name, | |||
T & | value, | |||
const std::map< std::string, T > & | mapping, | |||
SimulatedObject * | object = 0 | |||
) | [inline, static] |
Retrieves a value of enum "T".
[in] | node | the node where is the enum parameter |
[in] | name | the name of the enum parameter to find |
[out] | value | the returned enum of type T |
[in] | mapping | the map for correspondance between enum and text |
[in] | object | the simulated object which try to retrieve the information (default is null) only use to display error message. |
For error messages details see displayError
Definition at line 115 of file OMKParametersAccessor.inl.
References displayError(), getNodeValue(), and getValue().
00119 { 00120 std::string errorStr ; 00121 // Get the node for the value 00122 const ConfigurationParameterDescriptor * nodeValue = getNodeValue( node, name, errorStr ) ; 00123 // get the value as a string and convert it with the mapping 00124 std::string txt ; 00125 bool ok = false ; 00126 if( nodeValue && getValue( nodeValue, txt, errorStr ) ) 00127 { 00128 typename std::map< std::string, T >::const_iterator i = mapping.find( txt ) ; 00129 if( i != mapping.end() ) 00130 { 00131 value = i->second ; 00132 ok = true ; 00133 } 00134 else 00135 { 00136 errorStr = "Cannot read a valid enum value in string \"" ; 00137 errorStr += txt ; 00138 errorStr += "\"" ; 00139 } 00140 } 00141 // true if it is good else display error 00142 return ok || displayError( name, "get", object, errorStr ) ; 00143 00144 } 00145
bool ParametersAccessor::getAndCheckObject | ( | const ConfigurationParameterDescriptor * | node, | |
const std::string & | name, | |||
Name & | objectName, | |||
Controller & | controller, | |||
SimulatedObject * | object = 0 | |||
) | [static] |
Retrieves a object name and check its existance in the configuration tree.
[in] | node | the node where is the parameter |
[in] | name | the name of the parameter to find |
[out] | objectName | the name of a object to find |
[in] | the | controller which manage the objects (use to check the object) |
[in] | object | the simulated object which try to retrieve the information (default is null) only use to display error message. |
Definition at line 73 of file OMKParametersAccessor.cpp.
References displayError(), OMK::Name::getCString(), getNodeValue(), OMK::Controller::getObjectDescriptorOfObject(), and getValue().
00079 { 00080 std::string errorStr ; 00081 // Get the node for the value 00082 const ConfigurationParameterDescriptor * nodeValue = getNodeValue( node, name, errorStr ) ; 00083 // if it is good, get the value else display error 00084 bool ok = ( nodeValue != NULL ) ; 00085 ok = ok && getValue( nodeValue, objectName, errorStr ) ; 00086 if( ok ) 00087 { 00088 try 00089 { 00090 //check wether paramVariable exists: if it does not, a OMKUserException is thrown 00091 controller.getObjectDescriptorOfObject( objectName ); 00092 } 00093 catch( UserException e ) 00094 { 00095 ok = false ; 00096 errorStr = "Object \"" ; 00097 errorStr += objectName.getCString(); 00098 errorStr += "\" doesn't exist" ; 00099 } 00100 } 00101 return ok || displayError( name, "getAndCheckObject", object, errorStr ) ; 00102 }
bool ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
bool & | value, | |||
std::string & | errorStr | |||
) | [static, protected] |
Definition at line 105 of file OMKParametersAccessor.cpp.
Referenced by get(), getAndCheckObject(), and getValue().
00108 { 00109 std::string str; 00110 if( !getValue( nodeValue, str, errorStr ) ) 00111 { // Error 00112 return false; 00113 } 00114 std::transform( str.begin(), str.end(), str.begin(), toupper ); 00115 flag = ( str == "TRUE" || str == "ON" || str == "ENABLE" || str == "YES" || str == "1" ) ; 00116 bool ok = flag || ( str == "FALSE" || str == "OFF" || str == "DISABLE" || str == "NO" || str == "0" ) ; 00117 if( !ok ) 00118 { 00119 errorStr = "Cannot read the boolean" ; 00120 } 00121 return ok ; 00122 }
bool ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
Type::Color & | value, | |||
std::string & | errorStr | |||
) | [static, protected] |
Definition at line 126 of file OMKParametersAccessor.cpp.
References OMK::ConfigurationParameterDescriptor::getAssociatedString(), OMK::ConfigurationParameterDescriptor::getNumberOfSubItems(), OMK::ConfigurationParameterDescriptor::getSubDescriptorByPosition(), getTxtValue(), and getValue().
00129 { 00130 if( !nodeValue ) 00131 return false; // Error no valid node 00132 00133 if( nodeValue->getAssociatedString()[0] == '{' ) 00134 { 00135 // array format => read it 00136 // rgb or rgba 00137 bool ok = ( 3 == nodeValue->getNumberOfSubItems() 00138 || 4 == nodeValue->getNumberOfSubItems() ); 00139 if ( !ok && errorStr.empty() ) 00140 errorStr = "Bad format of OMK::Type::Color (need 3 or 4 arguments)" ; 00141 // 4 values => rgb + alpha 00142 bool withAlpha = ( 4 == nodeValue->getNumberOfSubItems() ) ; 00143 float r = 0.0f; 00144 float g = 0.0f; 00145 float b = 0.0f; 00146 float a = 1.0f; 00147 if( ok ) 00148 { 00149 ok = ok && getValue( nodeValue->getSubDescriptorByPosition( 0 ), r, errorStr ) ; 00150 ok = ok && getValue( nodeValue->getSubDescriptorByPosition( 1 ), g, errorStr ) ; 00151 ok = ok && getValue( nodeValue->getSubDescriptorByPosition( 2 ), b, errorStr ) ; 00152 if( withAlpha ) ok = ok && getValue( nodeValue->getSubDescriptorByPosition( 3 ), a, errorStr ) ; 00153 if ( !ok ) 00154 errorStr += ". Cannot get one of the OMK::Type::Color argument" ; 00155 } 00156 // Normalize in [0, 1] set 00157 if( 1.0f < r || 1.0f < g || 1.0f < b ) 00158 { 00159 r /= 255.0f; 00160 g /= 255.0f; 00161 b /= 255.0f; 00162 } 00163 ok = ok 00164 && ( 0.0f <= r ) && ( r <= 1.0f ) 00165 && ( 0.0f <= g ) && ( g <= 1.0f ) 00166 && ( 0.0f <= b ) && ( b <= 1.0f ) 00167 && ( 0.0f <= a ) && ( a <= 1.0f ) ; 00168 if ( !ok && errorStr.empty() ) 00169 errorStr = "One of the OMK::Type::Color argument is not in the good range [0.0 1.0] or [0 255]" ; 00170 00171 if( ok ) 00172 { // Create the color 00173 color = OMK::Type::Color( r, g, b, a ) ; 00174 } 00175 return ok; 00176 } 00177 // string format 00178 return getTxtValue( nodeValue->getAssociatedString(), color ); 00179 }
bool ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
Type::Transform & | value, | |||
std::string & | errorStr | |||
) | [static, protected] |
Definition at line 184 of file OMKParametersAccessor.cpp.
References OMK::ConfigurationParameterDescriptor::getAssociatedString(), OMK::ConfigurationParameterDescriptor::getNumberOfSubItems(), OMK::ConfigurationParameterDescriptor::getSubDescriptorByPosition(), getTxtValue(), getValue(), OMK::Type::Transform::setRotate(), OMK::Type::Transform::setScale(), OMK::Type::Transform::setTranslate(), OMK::Type::Transform::setUniformScale(), OMK::Type::Transform::sk_identity, and OMK::Type::Transform::updateFlags().
00187 { 00188 if( !nodeValue ) 00189 return false; // Error no valid node 00190 00191 bool ok = false ; 00192 if( nodeValue->getAssociatedString()[0] == '{' ) 00193 { 00194 transform = OMK::Type::Transform::sk_identity ; 00195 00196 // array format => read it 00197 // rgb or rgba 00198 ok = ( 1 <= nodeValue->getNumberOfSubItems() 00199 && nodeValue->getNumberOfSubItems() <= 3 ); 00200 if ( !ok && errorStr.empty() ) 00201 { 00202 errorStr = "Bad format of Transform (need 1 to 3 arguments)" ; 00203 } 00204 // get the 3 sub nodes for translation, rotation and scale 00205 const ConfigurationParameterDescriptor * translationNode = 00206 nodeValue->getSubDescriptorByPosition( 0 ) ; 00207 const ConfigurationParameterDescriptor * rotationNode = 00208 ( 2 <= nodeValue->getNumberOfSubItems() ) ? nodeValue->getSubDescriptorByPosition( 1 ) : 0 ; 00209 const ConfigurationParameterDescriptor * scaleNode = 00210 ( 3 == nodeValue->getNumberOfSubItems() ) ? nodeValue->getSubDescriptorByPosition( 2 ) : 0 ; 00211 00212 // Translation 00213 Wm4::Vector3f translation = Wm4::Vector3f::ZERO ; 00214 if( ok && translationNode ) 00215 { 00216 ok = 3 == translationNode->getNumberOfSubItems() ; 00217 float t[ 3 ] = { 0.0f, 0.0f, 0.0f } ; 00218 for ( int i = 0 ; i < 3 && ok ; i++ ) 00219 { 00220 ok = ok && getValue( translationNode->getSubDescriptorByPosition( i ), t[ i ], errorStr ) ; 00221 } 00222 if ( ok ) 00223 { 00224 transform.setTranslate( Wm4::Vector3f( t ) ) ; 00225 } 00226 else 00227 { 00228 errorStr += ". Cannot get one of the translation of the Transform argument" ; 00229 } 00230 } 00231 00232 // Rotation 00233 Wm4::Matrix3f rotation = Wm4::Matrix3f::IDENTITY ; 00234 if( ok && rotationNode ) 00235 { 00236 float rm[ 9 ] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f } ; 00237 // check for 3 or 9 items 00238 int nbItems = rotationNode->getNumberOfSubItems() ; 00239 ok = 9 == nbItems || 4 == nbItems || 3 == nbItems ; 00240 char angleType( 'r' ); 00241 if( 4 == nbItems ) 00242 { // The 4th flag is the type 00243 nbItems = 3 ; // only 3 numeric values 00244 getValue( rotationNode->getSubDescriptorByPosition( 3 ), angleType, errorStr ) ; 00245 } 00246 // gets the items value 00247 for ( int i = 0 ; i < nbItems && ok ; i++ ) 00248 { 00249 ok = ok && getValue( rotationNode->getSubDescriptorByPosition( i ), rm[ i ], errorStr ) ; 00250 } 00251 if( 9 == nbItems ) 00252 { // Rotation matrix 00253 if ( ok ) 00254 { 00255 rotation = Wm4::Matrix3f( rm, true ) ; // Row major 00256 transform.setRotate( rotation ) ; 00257 } 00258 else 00259 { 00260 errorStr += ". Cannot get one of the rotation matrix of the Transform argument" ; 00261 } 00262 } 00263 else if( 3 == nbItems ) 00264 { // Rotation angles Euler Radian 00265 if ( ok ) 00266 { 00267 switch( angleType ) 00268 { 00269 case 'r' : // Radian nothing to do 00270 break; 00271 case 'd' : // Degrees 00272 rm[ 0 ] *= Wm4::Mathf::DEG_TO_RAD ; 00273 rm[ 1 ] *= Wm4::Mathf::DEG_TO_RAD ; 00274 rm[ 2 ] *= Wm4::Mathf::DEG_TO_RAD ; 00275 break ; 00276 case 'g' : // Grad 00277 rm[ 0 ] *= Wm4::Mathf::DEG_TO_RAD * 0.9f ; 00278 rm[ 1 ] *= Wm4::Mathf::DEG_TO_RAD * 0.9f ; 00279 rm[ 2 ] *= Wm4::Mathf::DEG_TO_RAD * 0.9f ; 00280 break ; 00281 case 'p' : // Fraction of pi 00282 rm[ 0 ] *= Wm4::Mathf::PI ; 00283 rm[ 1 ] *= Wm4::Mathf::PI ; 00284 rm[ 2 ] *= Wm4::Mathf::PI ; 00285 break ; 00286 default : 00287 ok = false ; 00288 errorStr += "Unknow type of angle (only 'r', 'd', 'g' and 'p' are allowed)" ; 00289 } 00290 rotation.FromEulerAnglesXYZ( rm[ 0 ] , 00291 rm[ 1 ] , 00292 rm[ 2 ] ); // Euler angles 00293 transform.setRotate( rotation ) ; 00294 } 00295 else 00296 { 00297 errorStr += ". Cannot get one of the rotation Euler angle of the Transform argument" ; 00298 } 00299 } 00300 else 00301 { 00302 errorStr += "Cannot get the rotation of the Transform argument" ; 00303 } 00304 } 00305 00306 // Scale 00307 Wm4::Vector3f scale = Wm4::Vector3f::ONE ; 00308 if( ok && scaleNode ) 00309 { 00310 int nbItems = scaleNode->getNumberOfSubItems() ; 00311 ok = 1 == nbItems || 3 == nbItems ; 00312 float s[ 3 ] = { 1.0f, 1.0f, 1.0f } ; 00313 for ( int i = 0 ; i < nbItems && ok ; i++ ) 00314 { 00315 ok = ok && getValue( scaleNode->getSubDescriptorByPosition( i ), s[ i ], errorStr ) ; 00316 } 00317 if( 1 == nbItems ) 00318 { // Uniform scale 00319 if ( ok ) 00320 { 00321 transform.setUniformScale( s[ 0 ] ) ; 00322 } 00323 else 00324 { 00325 errorStr += ". Cannot get the uniform scale of the Transform argument" ; 00326 } 00327 } 00328 else if( 3 == nbItems ) 00329 { // No uniform scale 00330 if ( ok ) 00331 { 00332 transform.setScale( Wm4::Vector3f( s ) ) ; 00333 } 00334 else 00335 { 00336 errorStr += ". Cannot get one of the scale of the Transform argument" ; 00337 } 00338 } 00339 else 00340 { 00341 errorStr += "Cannot get the scale of the Transform argument" ; 00342 } 00343 } 00344 } 00345 else 00346 { 00347 ok = getTxtValue( nodeValue->getAssociatedString(), transform ) ; 00348 } 00349 transform.updateFlags() ; 00350 00351 // string format 00352 return ok ; 00353 }
bool OMK::ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
IAttributeBaseT< T > & | value, | |||
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 150 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::getAssociatedString(), getValue(), and OMK::IAccessorT< T >::set().
00152 { 00153 T value ; 00154 bool ok = ( nodeValue != NULL ) ; 00155 ok = ok && getValue( nodeValue, value, errorStr ) ; 00156 if( ok ) 00157 { 00158 attr.set( value ) ; 00159 } 00160 else 00161 { 00162 errorStr = "Cannot read the value in string \"" ; 00163 errorStr += nodeValue ? nodeValue->getAssociatedString() : "empty" ; 00164 errorStr += "\"" ; 00165 } 00166 return ok ; 00167 } 00168
bool OMK::ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
std::vector< T > & | value, | |||
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 173 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::getNumberOfSubItems(), OMK::ConfigurationParameterDescriptor::getSubDescriptorByPosition(), and getValue().
00175 { 00176 bool ok = ( nodeValue != NULL ) ; 00177 if( ok ) 00178 { 00179 for( int i = 0 ; ok && ( i < nodeValue->getNumberOfSubItems() ) ; i++ ) 00180 { 00181 T aValue; 00182 ok = ParametersAccessor::getValue( nodeValue->getSubDescriptorByPosition( i ), aValue, errorStr ) ; 00183 if( ok ) 00184 { 00185 values.push_back(aValue); 00186 } 00187 else 00188 { 00189 std::ostringstream oss ; 00190 oss << ", cannot get the parameter number " << i ; 00191 errorStr += oss.str() ; 00192 } 00193 } 00194 } 00195 return ok ; 00196 } 00197
bool OMK::ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
std::list< T > & | value, | |||
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 202 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::getNumberOfSubItems(), OMK::ConfigurationParameterDescriptor::getSubDescriptorByPosition(), and getValue().
00204 { 00205 bool ok = ( nodeValue != NULL ) ; 00206 if( ok ) 00207 { 00208 for( int i = 0 ; ok && ( i < nodeValue->getNumberOfSubItems() ) ; i++ ) 00209 { 00210 T aValue; 00211 ok = ParametersAccessor::getValue( nodeValue->getSubDescriptorByPosition( i ), aValue, errorStr ) ; 00212 if( ok ) 00213 { 00214 values.push_back(aValue); 00215 } 00216 else 00217 { 00218 std::ostringstream oss ; 00219 oss << ", cannot get the parameter number " << i ; 00220 errorStr += oss.str() ; 00221 } 00222 } 00223 } 00224 return ok ; 00225 } 00226
bool OMK::ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
std::pair< T1, T2 > & | value, | |||
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 260 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::getAssociatedString(), OMK::ConfigurationParameterDescriptor::getNumberOfSubItems(), OMK::ConfigurationParameterDescriptor::getSubDescriptorByPosition(), and getValue().
00262 { 00263 bool ok( ( nodeValue != NULL ) && ( nodeValue->getNumberOfSubItems() == 2 ) ) ; 00264 if ( !ok && errorStr.empty() ) 00265 { 00266 errorStr = "Bad format of pair (need 2 arguments)" + nodeValue->getAssociatedString() ; 00267 } 00268 ok = ok && getValue( nodeValue->getSubDescriptorByPosition( 0 ), value.first, errorStr ) ; 00269 ok = ok && getValue( nodeValue->getSubDescriptorByPosition( 1 ), value.second, errorStr ) ; 00270 return ok ; 00271 } 00272
bool OMK::ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
std::map< TK, TD > & | value, | |||
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 231 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::getNumberOfSubItems(), OMK::ConfigurationParameterDescriptor::getSubDescriptorByPosition(), and getValue().
00233 { 00234 bool ok = ( nodeValue != NULL ) ; 00235 if( ok ) 00236 { 00237 for( int i = 0 ; ok && ( i < nodeValue->getNumberOfSubItems() ) ; i++ ) 00238 { 00239 std::pair< TK, TD > aValue; 00240 ok = ParametersAccessor::getValue( nodeValue->getSubDescriptorByPosition( i ), aValue, errorStr ) ; 00241 if( ok ) 00242 { 00243 values[ aValue.first ] = aValue.second ; 00244 } 00245 else 00246 { 00247 std::ostringstream oss ; 00248 oss << ", cannot get the parameter number " << i ; 00249 errorStr += oss.str() ; 00250 } 00251 } 00252 } 00253 return ok ; 00254 } 00255
bool OMK::ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
T & | value, | |||
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 69 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::getAssociatedString(), and getTxtValue().
00071 { 00072 bool ok = ( nodeValue != NULL ) ; 00073 ok = ok && getTxtValue( nodeValue->getAssociatedString(), value ) ; 00074 if( !ok ) 00075 { 00076 errorStr = "Cannot read the value in string \"" ; 00077 errorStr += nodeValue ? nodeValue->getAssociatedString() : "empty" ; 00078 errorStr += "\"" ; 00079 } 00080 return ok ; 00081 } 00082
bool OMK::ParametersAccessor::getTxtValue | ( | const std::string & | textValue, | |
T & | value | |||
) | [inline, static, protected] |
Gets a value from a string Retrieves the value in the string.
Uses a stream to convert the string in a value of type T
Definition at line 88 of file OMKParametersAccessor.inl.
Referenced by getValue().
00088 { 00089 std::stringstream is; 00090 is << textValue; 00091 is >> value; 00092 return 0 != (void*)is; 00093 } 00094
const ConfigurationParameterDescriptor * ParametersAccessor::getNodeValue | ( | const ConfigurationParameterDescriptor * | node, | |
const std::string & | name, | |||
std::string & | errorStr | |||
) | [static, protected] |
Retrieve the node named name in the tree.
Definition at line 29 of file OMKParametersAccessor.cpp.
References OMK::ConfigurationParameterDescriptor::getSubDescriptorByName().
Referenced by get(), and getAndCheckObject().
00033 { 00034 const ConfigurationParameterDescriptor * nodeValue = node ? node->getSubDescriptorByName( name ) : 0 ; 00035 if ( !node && errorStr.empty() ) 00036 errorStr = "Invalid ConfigurationParameterDescriptor node" ; 00037 if ( !nodeValue && errorStr.empty() ) 00038 errorStr = "Parameter not found" ; 00039 return nodeValue ; 00040 }
bool ParametersAccessor::displayError | ( | const std::string & | name, | |
const std::string & | functionName, | |||
SimulatedObject * | object, | |||
const std::string & | errorStr | |||
) | [static, protected] |
Display the message errorStr.
return ok || displayError(...) ;
at the end of the public get methods.In release mode no message will be displayed. In debug mode, if an object is given an error message is displayed, if not it is onnly a warning message.
Definition at line 46 of file OMKParametersAccessor.cpp.
References OMK::debugMsg(), OMERROR, OMK_DEBUG_OMK_OBJ, and OMTRACEID.
Referenced by get(), and getAndCheckObject().
00051 { 00052 if( !errorStr.empty() ) 00053 { 00054 if( object ) 00055 { 00056 OMERROR( "Error in ParametersAccessor::" << functionName 00057 << " with parameter [" + name + "] for " << OMK::debugMsg( object ) << std::endl 00058 << ">>> :-( " << errorStr ) ; 00059 } 00060 else 00061 { 00062 OMTRACEID( OMK_DEBUG_OMK_OBJ, "Warning in ParametersAccessor::" << functionName 00063 << " with parameter [" + name + "]" << std::endl 00064 << ">>> :-| " << errorStr ) ; 00065 } 00066 } 00067 // Return always false 00068 return false ; 00069 }
ConfigurationParameterDescriptor * OMK::ParametersAccessor::set | ( | ConfigurationParameterDescriptor *& | node, | |
const std::string & | name, | |||
const T & | value | |||
) | [inline, static] |
Allows to append the data to the node.
in/out] | node The node in which the data will be appended. if null a new node is created. | |
[in] | name | The name of the data to append. |
[in] | value | The value of the data to append. |
T | The template argument is the type of the data. |
Definition at line 278 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptorNamed(), OMERROR, and setValue().
Referenced by OMK::MovingHumano::getVisualObjectPrm(), and OMK::IAttributeAnimatorT< PrmType, ModelType, AccessorType >::loadParameters().
00281 { 00282 std::string errorStr ; 00283 ConfigurationParameterDescriptor* newNode = setValue( value, errorStr ) ; 00284 if( newNode ) 00285 { 00286 if( !node ) node = new MultipleConfigurationParameter() ; 00287 node->appendSubDescriptorNamed( name, newNode ) ; 00288 } 00289 else 00290 { 00291 OMERROR( "Warning in ParametersAccessor::Set with parameter [" + name + "]" << std::endl 00292 << ">>> :-( " << errorStr ) ; 00293 } 00294 return newNode ; 00295 } 00296
ConfigurationParameterDescriptor * ParametersAccessor::set | ( | ConfigurationParameterDescriptor *& | node, | |
const std::string & | name, | |||
ConfigurationParameterDescriptor * | newNode | |||
) | [static] |
Specialisation for ConfigurationParameterDescriptor pointer.
[in] |
Definition at line 441 of file OMKParametersAccessor.cpp.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptorNamed(), and OMERROR.
00445 { 00446 if( newNode ) 00447 { 00448 if( !node ) node = new MultipleConfigurationParameter() ; 00449 node->appendSubDescriptorNamed( name, newNode ) ; 00450 } 00451 else 00452 { 00453 OMERROR( "Warning in ParametersAccessor::Set with parameter [" + name + "]" << std::endl 00454 << ">>> :-( The node to append is null" ) ; 00455 } 00456 return newNode ; 00457 }
ConfigurationParameterDescriptor * OMK::ParametersAccessor::set | ( | ConfigurationParameterDescriptor *& | node, | |
const std::string & | name, | |||
const T & | value, | |||
const std::map< T, std::string > & | mapping | |||
) | [static] |
Allows to append the enum "T" to the node.
in/out] | node The node in which the data will be appended. if null a new node is created. | |
[in] | name | The name of the data to append. |
[in] | value | The enum value to append. |
[in] | mapping | the map for correspondance between text and enum |
T | The template argument is the enum type. |
Definition at line 300 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptorNamed(), OMERROR, and setValue().
00304 { 00305 bool ok = false ; 00306 std::string errorStr ; 00307 std::string txt ; 00308 typename std::map< T, std::string >::const_iterator i = mapping.find( value ) ; 00309 if( i != mapping.end() ) 00310 { 00311 txt = i->second ; 00312 ok = true ; 00313 } 00314 else 00315 { 00316 errorStr = "Cannot get a valid string value with the enum value #" ; 00317 errorStr += (int)value ; 00318 } 00319 00320 ConfigurationParameterDescriptor* newNode = ok ? setValue( value, errorStr ) : 0 ; 00321 if( newNode ) 00322 { 00323 if( !node ) node = new MultipleConfigurationParameter() ; 00324 node->appendSubDescriptorNamed( name, newNode ) ; 00325 } 00326 if( !ok ) 00327 { 00328 OMERROR( "Warning in ParametersAccessor::Set with parameter [" + name + "]" << std::endl 00329 << ">>> :-( " << errorStr ) ; 00330 } 00331 return newNode ; 00332 } 00333
bool OMK::ParametersAccessor::setTxtValue | ( | std::string & | textValue, | |
const T & | value | |||
) | [inline, static, protected] |
Gets a string from a value.
Converts a value in a text. Uses a stream to convert the value of type T in a string
Definition at line 339 of file OMKParametersAccessor.inl.
Referenced by setValue().
00339 { 00340 std::stringstream os; 00341 os << value ; 00342 textValue = os.str() ; 00343 return 0 != (void*)os ; 00344 } 00345
ConfigurationParameterDescriptor * OMK::ParametersAccessor::setValue | ( | const T & | value, | |
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 350 of file OMKParametersAccessor.inl.
References setTxtValue().
Referenced by set(), and setValue().
00351 { 00352 ConfigurationParameterDescriptor *node = 0 ; 00353 std::string textValue ; 00354 if( setTxtValue( textValue, value ) ) 00355 { 00356 node = new UniqueConfigurationParameter( textValue ) ; 00357 } 00358 else 00359 { 00360 errorStr = "Unable to convert the value in a string" ; 00361 } 00362 return node ; 00363 } 00364
ConfigurationParameterDescriptor * ParametersAccessor::setValue | ( | const bool & | value, | |
std::string & | errorStr | |||
) | [static, protected] |
Definition at line 355 of file OMKParametersAccessor.cpp.
00357 { 00358 return new UniqueConfigurationParameter( value ? "true" : "false" ) ; 00359 }
ConfigurationParameterDescriptor * ParametersAccessor::setValue | ( | const Type::Color & | value, | |
std::string & | errorStr | |||
) | [static, protected] |
Definition at line 362 of file OMKParametersAccessor.cpp.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptor(), OMK::Type::Color::getA(), OMK::Type::Color::getB(), OMK::Type::Color::getG(), OMK::Type::Color::getR(), and setTxtValue().
00364 { 00365 ConfigurationParameterDescriptor *node = new MultipleConfigurationParameter() ; 00366 bool ok = true ; 00367 std::string text ; 00368 ok = ok && setTxtValue( text, color.getR() ) ; 00369 if( ok ) node->appendSubDescriptor( new UniqueConfigurationParameter( text ) ) ; 00370 ok = ok && setTxtValue( text, color.getG() ) ; 00371 if( ok ) node->appendSubDescriptor( new UniqueConfigurationParameter( text ) ) ; 00372 ok = ok && setTxtValue( text, color.getB() ) ; 00373 if( ok ) node->appendSubDescriptor( new UniqueConfigurationParameter( text ) ) ; 00374 if( color.getA() != 1.0f ) 00375 { 00376 ok = ok && setTxtValue( text, color.getA() ) ; 00377 if( ok ) node->appendSubDescriptor( new UniqueConfigurationParameter( text ) ) ; 00378 } 00379 if( !ok ) 00380 { 00381 delete node ; 00382 node = 0 ; 00383 errorStr = "Unable to convert the color into a node" ; 00384 } 00385 return node ; 00386 }
ConfigurationParameterDescriptor * ParametersAccessor::setValue | ( | const Type::Transform & | value, | |
std::string & | errorStr | |||
) | [static, protected] |
Definition at line 389 of file OMKParametersAccessor.cpp.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptor(), OMK::Type::Transform::getRotate(), OMK::Type::Transform::getScale(), OMK::Type::Transform::getTranslate(), OMK::Type::Transform::getUniformScale(), OMK::Type::Transform::isUniformScale(), and setTxtValue().
00391 { 00392 bool ok = true ; 00393 bool needScale = !transf.isUniformScale() || transf.getUniformScale() != 1.0f ; 00394 std::string text ; 00395 ConfigurationParameterDescriptor *node = new MultipleConfigurationParameter() ; 00396 // Translate 00397 { 00398 ConfigurationParameterDescriptor *translateNode = new MultipleConfigurationParameter() ; 00399 node->appendSubDescriptor( translateNode ) ; 00400 for( int i = 0 ; i < 3 ; i++ ) 00401 { 00402 ok = ok && setTxtValue( text, transf.getTranslate()[ i ] ) ; 00403 if( ok ) translateNode->appendSubDescriptor( new UniqueConfigurationParameter( text ) ) ; 00404 } 00405 } 00406 // Rotate 00407 if( ok && ( needScale || transf.getRotate() != Wm4::Matrix3f::IDENTITY ) ) 00408 { 00409 ConfigurationParameterDescriptor *rotateNode = new MultipleConfigurationParameter() ; 00410 node->appendSubDescriptor( rotateNode ) ; 00411 for( int r = 0 ; r < 3 ; r++ ) 00412 { 00413 for( int c = 0 ; c < 3 ; c++ ) 00414 { 00415 ok = ok && setTxtValue( text, transf.getRotate()[r][c] ) ; 00416 if( ok ) rotateNode->appendSubDescriptor( new UniqueConfigurationParameter( text ) ) ; 00417 } 00418 } 00419 } 00420 // Scale 00421 if( ok && needScale ) 00422 { 00423 ConfigurationParameterDescriptor *scaleNode = new MultipleConfigurationParameter() ; 00424 node->appendSubDescriptor( scaleNode ) ; 00425 for( int i = 0 ; i < ( transf.isUniformScale() ? 1 : 3 ) ; i++ ) 00426 { 00427 ok = ok && setTxtValue( text, transf.getScale()[ i ] ) ; 00428 if( ok ) scaleNode->appendSubDescriptor( new UniqueConfigurationParameter( text ) ) ; 00429 } 00430 } 00431 // ok ? 00432 if( !ok ) 00433 { 00434 errorStr = "Unable to convert the tranform into a node" ; 00435 delete node ; 00436 node = 0 ; 00437 } 00438 return node ; 00439 }
ConfigurationParameterDescriptor * OMK::ParametersAccessor::setValue | ( | const IAttributeBaseT< T > & | values, | |
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 369 of file OMKParametersAccessor.inl.
References OMK::IAccessorT< T >::get(), and setTxtValue().
00370 { 00371 ConfigurationParameterDescriptor *node = 0 ; 00372 std::string textValue ; 00373 if( setTxtValue( textValue, attr.get() ) ) 00374 { 00375 node = new UniqueConfigurationParameter( textValue ) ; 00376 } 00377 else 00378 { 00379 errorStr = "Unable to convert the value of the attribut in a string" ; 00380 } 00381 return node ; 00382 } 00383
ConfigurationParameterDescriptor * OMK::ParametersAccessor::setValue | ( | const std::vector< T > & | values, | |
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 388 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptor(), and setValue().
00389 { 00390 ConfigurationParameterDescriptor *node = new MultipleConfigurationParameter() ; 00391 for( unsigned int i = 0 ; i < values.size() ; i++ ) 00392 { 00393 ConfigurationParameterDescriptor *itemNode = setValue( values[ i ], errorStr ) ; 00394 if( itemNode ) 00395 { 00396 node->appendSubDescriptor( itemNode ) ; 00397 } 00398 else 00399 { 00400 errorStr += "\nUnable to set the value #" ; 00401 errorStr += i ; 00402 } 00403 } 00404 return node ; 00405 } 00406
ConfigurationParameterDescriptor * OMK::ParametersAccessor::setValue | ( | const std::list< T > & | value, | |
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 411 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptor(), and setValue().
00412 { 00413 ConfigurationParameterDescriptor *node = new MultipleConfigurationParameter() ; 00414 for( typename std::list< T >::const_iterator i = values.begin() ; i != values.end() ; i++ ) 00415 { 00416 ConfigurationParameterDescriptor *itemNode = setValue( *i, errorStr ) ; 00417 if( itemNode ) 00418 { 00419 node->appendSubDescriptor( itemNode ) ; 00420 } 00421 else 00422 { 00423 errorStr += "\nUnable to set the value of the list" ; 00424 } 00425 } 00426 return node ; 00427 } 00428
ConfigurationParameterDescriptor * OMK::ParametersAccessor::setValue | ( | const std::map< TK, TD > & | value, | |
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 433 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptor(), and setValue().
00433 { 00434 ConfigurationParameterDescriptor *node = new MultipleConfigurationParameter() ; 00435 for( typename std::map< TK, TD >::const_iterator i = values.begin() ; i != values.end() ; i++ ) 00436 { 00437 ConfigurationParameterDescriptor *keyNode = setValue( i->first, errorStr ) ; 00438 ConfigurationParameterDescriptor *dataNode = setValue( i->second, errorStr ) ; 00439 if( keyNode && dataNode ) 00440 { 00441 ConfigurationParameterDescriptor *itemNode = new MultipleConfigurationParameter() ; 00442 itemNode->appendSubDescriptor( keyNode ) ; 00443 itemNode->appendSubDescriptor( dataNode ) ; 00444 node->appendSubDescriptor( itemNode ) ; 00445 } 00446 else 00447 { 00448 errorStr += "\nUnable to set the value of the map" ; 00449 } 00450 } 00451 return node ; 00452 } 00453 00454 //-------------------------------------------------------------------
ConfigurationParameterDescriptor * OMK::ParametersAccessor::setValue | ( | const std::pair< T1, T2 > & | value, | |
std::string & | errorStr | |||
) | [inline, static, protected] |
Definition at line 459 of file OMKParametersAccessor.inl.
References OMK::ConfigurationParameterDescriptor::appendSubDescriptor(), and setValue().
00463 { 00464 node->appendSubDescriptor( firstNode ) ; 00465 node->appendSubDescriptor( secondNode ) ; 00466 } 00467 else 00468 { 00469 errorStr += "\nUnable to set the value of the pair" ; 00470 } 00471 return node ; 00472 } 00473 } // namespace OMK 00474 00475 #endif // PSPARAMETERSACCESSOR_INL
bool OMK::ParametersAccessor::getTxtValue | ( | const std::string & | textValue, | |
std::string & | value | |||
) | [inline] |
Specialisation for string.
No need to use stream.
Definition at line 19 of file OMKParametersAccessor.inl.
bool OMK::ParametersAccessor::setTxtValue | ( | std::string & | textValue, | |
const std::string & | value | |||
) | [inline] |
Specialisation for string.
No need to use stream.
Definition at line 30 of file OMKParametersAccessor.inl.
bool OMK::ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
const ConfigurationParameterDescriptor *& | value, | |||
std::string & | errorStr | |||
) | [inline] |
Specialisation for const node.
Allows to walk through the hierarchy.
Definition at line 41 of file OMKParametersAccessor.inl.
00043 { 00044 errorStr = "The node is empty" ; 00045 // Get the value of the node 00046 value = nodeValue ; 00047 // if it is not null, return true 00048 return value != 0 ; 00049 } 00050 //-------------------------------------------------------------------
bool OMK::ParametersAccessor::getValue | ( | const ConfigurationParameterDescriptor * | nodeValue, | |
ConfigurationParameterDescriptor *& | value, | |||
std::string & | errorStr | |||
) | [inline] |
Specialisation for node.
A non const is not possible.
Definition at line 56 of file OMKParametersAccessor.inl.
00058 { 00059 value = 0 ; 00060 errorStr = "Unable to get a no-const ConfigurationParameterDescriptor*" ; 00061 return false ; 00062 }
Documentation generated on Mon Jun 9 11:46:02 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |