| 65 | } |
| 66 | |
| 67 | bool ObjectParameter::valueValid( const Object *value, std::string *reason ) const |
| 68 | { |
| 69 | if( !Parameter::valueValid( value, reason ) ) |
| 70 | { |
| 71 | return false; |
| 72 | } |
| 73 | |
| 74 | for( TypeIdSet::const_iterator it=m_validTypes.begin(); it!=m_validTypes.end(); it++ ) |
| 75 | { |
| 76 | if( value->isInstanceOf( *it ) ) |
| 77 | { |
| 78 | return true; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | if( reason ) |
| 83 | { |
| 84 | *reason = "Object is not of type "; |
| 85 | int n = 1; int s = m_validTypes.size(); |
| 86 | for( TypeIdSet::const_iterator it=m_validTypes.begin(); it!=m_validTypes.end(); it++ ) |
| 87 | { |
| 88 | *reason += Object::typeNameFromTypeId( *it ); |
| 89 | if( n==s - 1 ) |
| 90 | { |
| 91 | *reason += " or "; |
| 92 | } |
| 93 | else if( n<s ) |
| 94 | { |
| 95 | *reason += ", "; |
| 96 | } |
| 97 | n++; |
| 98 | } |
| 99 | } |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | const ObjectParameter::TypeIdSet &ObjectParameter::validTypes() const |
| 104 | { |
no test coverage detected