Commit 8beb127c authored by peastman's avatar peastman
Browse files

Detect if user specifies an unknown property name

parent 911e27da
......@@ -88,7 +88,12 @@ const string& Platform::getPropertyDefaultValue(const string& property) const {
}
void Platform::setPropertyDefaultValue(const string& property, const string& value) {
defaultProperties[property] = value;
for (int i = 0; i < (int) platformProperties.size(); i++)
if (platformProperties[i] == property) {
defaultProperties[property] = value;
return;
}
throw OpenMMException("setPropertyDefaultValue: Illegal property name");
}
void Platform::contextCreated(ContextImpl& context, const map<string, string>& properties) const {
......
......@@ -75,6 +75,20 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
throw OpenMMException("A constraint cannot involve a massless particle");
}
// Validate the list of properties.
const vector<string>& platformProperties = platform->getPropertyNames();
for (map<string, string>::const_iterator iter = properties.begin(); iter != properties.end(); ++iter) {
bool valid = false;
for (int i = 0; i < (int) platformProperties.size(); i++)
if (platformProperties[i] == iter->first) {
valid = true;
break;
}
if (!valid)
throw OpenMMException("Illegal property name: "+iter->first);
}
// Find the list of kernels required.
vector<string> kernelNames;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment