MCPcopy Create free account
hub / github.com/ImageEngine/cortex / valueValid

Method valueValid

src/IECore/ObjectParameter.cpp:67–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67bool 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
103const ObjectParameter::TypeIdSet &ObjectParameter::validTypes() const
104{

Callers 3

testConstructorMethod · 0.95
testConstructor2Method · 0.95
testErrorMessageMethod · 0.95

Calls 4

isInstanceOfMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected