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
e78c723b
Commit
e78c723b
authored
Apr 20, 2014
by
Robert McGibbon
Browse files
magic bytes
parent
0ab3aa3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
openmmapi/src/ContextImpl.cpp
openmmapi/src/ContextImpl.cpp
+6
-5
No files found.
openmmapi/src/ContextImpl.cpp
View file @
e78c723b
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
const
static
char
CHECKPOINT_MAGIC_BYTES
[]
=
"
\x1C\xEB\x00\xDA
"
;
const
static
char
CHECKPOINT_MAGIC_BYTES
[]
=
"
OpenMM Binary Checkpoint
\n
"
;
ContextImpl
::
ContextImpl
(
Context
&
owner
,
const
System
&
system
,
Integrator
&
integrator
,
Platform
*
platform
,
const
map
<
string
,
string
>&
properties
)
:
ContextImpl
::
ContextImpl
(
Context
&
owner
,
const
System
&
system
,
Integrator
&
integrator
,
Platform
*
platform
,
const
map
<
string
,
string
>&
properties
)
:
...
@@ -401,7 +401,7 @@ static string readString(istream& stream) {
...
@@ -401,7 +401,7 @@ static string readString(istream& stream) {
}
}
void
ContextImpl
::
createCheckpoint
(
ostream
&
stream
)
{
void
ContextImpl
::
createCheckpoint
(
ostream
&
stream
)
{
stream
.
write
(
CHECKPOINT_MAGIC_BYTES
,
4
);
stream
.
write
(
CHECKPOINT_MAGIC_BYTES
,
sizeof
(
CHECKPOINT_MAGIC_BYTES
)
/
sizeof
(
CHECKPOINT_MAGIC_BYTES
[
0
])
);
writeString
(
stream
,
getPlatform
().
getName
());
writeString
(
stream
,
getPlatform
().
getName
());
int
numParticles
=
getSystem
().
getNumParticles
();
int
numParticles
=
getSystem
().
getNumParticles
();
stream
.
write
((
char
*
)
&
numParticles
,
sizeof
(
int
));
stream
.
write
((
char
*
)
&
numParticles
,
sizeof
(
int
));
...
@@ -416,9 +416,10 @@ void ContextImpl::createCheckpoint(ostream& stream) {
...
@@ -416,9 +416,10 @@ void ContextImpl::createCheckpoint(ostream& stream) {
}
}
void
ContextImpl
::
loadCheckpoint
(
istream
&
stream
)
{
void
ContextImpl
::
loadCheckpoint
(
istream
&
stream
)
{
char
magicbytes
[
4
];
static
const
int
magiclength
=
sizeof
(
CHECKPOINT_MAGIC_BYTES
)
/
sizeof
(
CHECKPOINT_MAGIC_BYTES
[
0
]);
stream
.
read
(
magicbytes
,
4
);
char
magicbytes
[
magiclength
];
if
(
memcmp
(
magicbytes
,
CHECKPOINT_MAGIC_BYTES
,
4
*
sizeof
(
char
))
!=
0
)
stream
.
read
(
magicbytes
,
magiclength
);
if
(
memcmp
(
magicbytes
,
CHECKPOINT_MAGIC_BYTES
,
magiclength
)
!=
0
)
throw
OpenMMException
(
"loadCheckpoint: Checkpoint header was not correct"
);
throw
OpenMMException
(
"loadCheckpoint: Checkpoint header was not correct"
);
string
platformName
=
readString
(
stream
);
string
platformName
=
readString
(
stream
);
...
...
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