Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
8beb127c
Commit
8beb127c
authored
Dec 13, 2013
by
peastman
Browse files
Detect if user specifies an unknown property name
parent
911e27da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
olla/src/Platform.cpp
olla/src/Platform.cpp
+6
-1
openmmapi/src/ContextImpl.cpp
openmmapi/src/ContextImpl.cpp
+14
-0
No files found.
olla/src/Platform.cpp
View file @
8beb127c
...
...
@@ -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
{
...
...
openmmapi/src/ContextImpl.cpp
View file @
8beb127c
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment