Commit 2def8113 authored by peastman's avatar peastman
Browse files

Merge pull request #246 from peastman/master

Detect if user specifies an unknown property name
parents 911e27da 8beb127c
...@@ -88,7 +88,12 @@ const string& Platform::getPropertyDefaultValue(const string& property) const { ...@@ -88,7 +88,12 @@ const string& Platform::getPropertyDefaultValue(const string& property) const {
} }
void Platform::setPropertyDefaultValue(const string& property, const string& value) { 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 { void Platform::contextCreated(ContextImpl& context, const map<string, string>& properties) const {
......
...@@ -75,6 +75,20 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ ...@@ -75,6 +75,20 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
throw OpenMMException("A constraint cannot involve a massless particle"); 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. // Find the list of kernels required.
vector<string> kernelNames; 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