| 130 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 131 | |
| 132 | bool Parameter::valueValid( const Object *value, std::string *reason ) const |
| 133 | { |
| 134 | if( !value ) |
| 135 | { |
| 136 | if( reason ) |
| 137 | { |
| 138 | *reason = "Value is a null pointer."; |
| 139 | } |
| 140 | return false; |
| 141 | } |
| 142 | if( value->typeId()==NullObject::staticTypeId() ) |
| 143 | { |
| 144 | if( reason ) |
| 145 | { |
| 146 | *reason = "Value is of type NullObject."; |
| 147 | } |
| 148 | return false; |
| 149 | } |
| 150 | if( !m_presetsOnly ) |
| 151 | { |
| 152 | return true; |
| 153 | } |
| 154 | const PresetsContainer &pr = getPresets(); |
| 155 | for( PresetsContainer::const_iterator it = pr.begin(); it!=pr.end(); it++ ) |
| 156 | { |
| 157 | if( it->second->isEqualTo( value ) ) |
| 158 | { |
| 159 | return true; |
| 160 | } |
| 161 | } |
| 162 | if( reason ) |
| 163 | { |
| 164 | *reason = "Value not present in presets."; |
| 165 | } |
| 166 | return false; |
| 167 | } |
| 168 | |
| 169 | bool Parameter::valueValid( std::string *reason ) const |
| 170 | { |