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
f48120f9
Commit
f48120f9
authored
Mar 25, 2020
by
Charlles Abreu
Browse files
Implementation of ContinuousPeriodic1DFunction: serialization
parent
19d806da
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
6 deletions
+43
-6
serialization/include/openmm/serialization/TabulatedFunctionProxies.h
...n/include/openmm/serialization/TabulatedFunctionProxies.h
+17
-6
serialization/src/TabulatedFunctionProxies.cpp
serialization/src/TabulatedFunctionProxies.cpp
+26
-0
No files found.
serialization/include/openmm/serialization/TabulatedFunctionProxies.h
View file @
f48120f9
...
...
@@ -48,6 +48,17 @@ public:
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
/**
* This is a proxy for serializing ContinuousPeriodic1DFunction objects.
*/
class
OPENMM_EXPORT
ContinuousPeriodic1DFunctionProxy
:
public
SerializationProxy
{
public:
ContinuousPeriodic1DFunctionProxy
();
void
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
;
void
*
deserialize
(
const
SerializationNode
&
node
)
const
;
};
/**
* This is a proxy for serializing Continuous2DFunction objects.
*/
...
...
serialization/src/TabulatedFunctionProxies.cpp
View file @
f48120f9
...
...
@@ -63,6 +63,32 @@ void* Continuous1DFunctionProxy::deserialize(const SerializationNode& node) cons
return
new
Continuous1DFunction
(
values
,
node
.
getDoubleProperty
(
"min"
),
node
.
getDoubleProperty
(
"max"
));
}
ContinuousPeriodic1DFunctionProxy
::
ContinuousPeriodic1DFunctionProxy
()
:
SerializationProxy
(
"ContinuousPeriodic1DFunction"
)
{
}
void
ContinuousPeriodic1DFunctionProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
1
);
const
ContinuousPeriodic1DFunction
&
function
=
*
reinterpret_cast
<
const
ContinuousPeriodic1DFunction
*>
(
object
);
double
min
,
max
;
vector
<
double
>
values
;
function
.
getFunctionParameters
(
values
,
min
,
max
);
node
.
setDoubleProperty
(
"min"
,
min
);
node
.
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
auto
v
:
values
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
);
}
void
*
ContinuousPeriodic1DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
if
(
node
.
getIntProperty
(
"version"
)
!=
1
)
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
auto
&
child
:
valuesNode
.
getChildren
())
values
.
push_back
(
child
.
getDoubleProperty
(
"v"
));
return
new
ContinuousPeriodic1DFunction
(
values
,
node
.
getDoubleProperty
(
"min"
),
node
.
getDoubleProperty
(
"max"
));
}
Continuous2DFunctionProxy
::
Continuous2DFunctionProxy
()
:
SerializationProxy
(
"Continuous2DFunction"
)
{
}
...
...
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