Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
359538e1
Commit
359538e1
authored
Sep 08, 2020
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resources, fix progress' implementations move to std::thread
parent
d45ce506
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
27 deletions
+46
-27
configure.ac
+14
-2
include/cif++/AtomType.hpp
+2
-1
src/AtomType.cpp
+3
-2
src/CifUtils.cpp
+27
-22
No files found.
configure.ac
View file @
359538e1
...
@@ -32,6 +32,19 @@ AS_IF([test x"$CCP4" != x""],
...
@@ -32,6 +32,19 @@ AS_IF([test x"$CCP4" != x""],
LDFLAGS="$LDFLAGS -L${CCP4}/lib"
LDFLAGS="$LDFLAGS -L${CCP4}/lib"
])
])
AC_ARG_VAR([USE_RSRC], [Use resources to store internal data, requires mrc])
AC_ARG_VAR([MRC], [Specify a location for the mrc executable])
dnl We really like to use mrc
if test "x$MRC" = "x"; then
AC_PATH_PROG([MRC], [mrc])
fi
if test "x$MRC" = "x"; then
AC_MSG_WARN([mrc not found, building without support for resources.])
else
USE_RSRC=1
fi
AX_BOOST_BASE([1.73])
AX_BOOST_BASE([1.73])
AX_BOOST_REGEX
AX_BOOST_REGEX
...
@@ -123,5 +136,4 @@ AX_CHECK_LIBRARY([LIBBZ2], [bzlib.h], [bz2], [],
...
@@ -123,5 +136,4 @@ AX_CHECK_LIBRARY([LIBBZ2], [bzlib.h], [bz2], [],
# [enable_debug=auto])
# [enable_debug=auto])
dnl Process files
dnl Process files
AC_OUTPUT([GNUmakefile
AC_OUTPUT([GNUmakefile])
libcif++.pc])
include/cif++/AtomType.hpp
View file @
359538e1
...
@@ -14,7 +14,6 @@ enum AtomType : uint8_t
...
@@ -14,7 +14,6 @@ enum AtomType : uint8_t
Nn
=
0
,
// Unknown
Nn
=
0
,
// Unknown
H
=
1
,
// Hydrogen
H
=
1
,
// Hydrogen
D
=
129
,
// Deuterium
He
=
2
,
// Helium
He
=
2
,
// Helium
Li
=
3
,
// Lithium
Li
=
3
,
// Lithium
...
@@ -140,6 +139,8 @@ enum AtomType : uint8_t
...
@@ -140,6 +139,8 @@ enum AtomType : uint8_t
Md
=
101
,
// Mendelevium
Md
=
101
,
// Mendelevium
No
=
102
,
// Nobelium
No
=
102
,
// Nobelium
Lr
=
103
,
// Lawrencium
Lr
=
103
,
// Lawrencium
D
=
129
,
// Deuterium
};
};
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
...
src/AtomType.cpp
View file @
359538e1
...
@@ -17,7 +17,6 @@ const AtomTypeInfo kKnownAtoms[] =
...
@@ -17,7 +17,6 @@ const AtomTypeInfo kKnownAtoms[] =
{
{
{
Nn
,
"Unknown"
,
"Nn"
,
0
,
false
,
{
kNA
,
kNA
,
kNA
,
kNA
,
kNA
,
kNA
,
kNA
}
},
// 0 Nn Unknown
{
Nn
,
"Unknown"
,
"Nn"
,
0
,
false
,
{
kNA
,
kNA
,
kNA
,
kNA
,
kNA
,
kNA
,
kNA
}
},
// 0 Nn Unknown
{
H
,
"Hydrogen"
,
"H"
,
1.008
,
false
,
{
53
,
25
,
37
,
32
,
kNA
,
kNA
,
120
}
},
// 1 H Hydrogen
{
H
,
"Hydrogen"
,
"H"
,
1.008
,
false
,
{
53
,
25
,
37
,
32
,
kNA
,
kNA
,
120
}
},
// 1 H Hydrogen
{
D
,
"Deuterium"
,
"D"
,
2.014
,
false
,
{
53
,
25
,
37
,
32
,
kNA
,
kNA
,
120
}
},
// 1 D Deuterium
{
He
,
"Helium"
,
"He"
,
4.0026
,
false
,
{
31
,
kNA
,
32
,
46
,
kNA
,
kNA
,
140
}
},
// 2 He Helium
{
He
,
"Helium"
,
"He"
,
4.0026
,
false
,
{
31
,
kNA
,
32
,
46
,
kNA
,
kNA
,
140
}
},
// 2 He Helium
{
Li
,
"Lithium"
,
"Li"
,
6.94
,
true
,
{
167
,
145
,
134
,
133
,
124
,
kNA
,
182
}
},
// 3 Li Lithium
{
Li
,
"Lithium"
,
"Li"
,
6.94
,
true
,
{
167
,
145
,
134
,
133
,
124
,
kNA
,
182
}
},
// 3 Li Lithium
{
Be
,
"Beryllium"
,
"Be"
,
9.0122
,
true
,
{
112
,
105
,
90
,
102
,
90
,
85
,
kNA
}
},
// 4 Be Beryllium
{
Be
,
"Beryllium"
,
"Be"
,
9.0122
,
true
,
{
112
,
105
,
90
,
102
,
90
,
85
,
kNA
}
},
// 4 Be Beryllium
...
@@ -134,7 +133,9 @@ const AtomTypeInfo kKnownAtoms[] =
...
@@ -134,7 +133,9 @@ const AtomTypeInfo kKnownAtoms[] =
{
Mc
,
"Moscovium"
,
"Mc"
,
290
,
true
,
{
kNA
,
kNA
,
kNA
,
162
,
kNA
,
kNA
,
kNA
}
},
// 115 Mc Moscovium
{
Mc
,
"Moscovium"
,
"Mc"
,
290
,
true
,
{
kNA
,
kNA
,
kNA
,
162
,
kNA
,
kNA
,
kNA
}
},
// 115 Mc Moscovium
{
Lv
,
"Livermorium"
,
"Lv"
,
293
,
true
,
{
kNA
,
kNA
,
kNA
,
175
,
kNA
,
kNA
,
kNA
}
},
// 116 Lv Livermorium
{
Lv
,
"Livermorium"
,
"Lv"
,
293
,
true
,
{
kNA
,
kNA
,
kNA
,
175
,
kNA
,
kNA
,
kNA
}
},
// 116 Lv Livermorium
{
Ts
,
"Tennessine"
,
"Ts"
,
294
,
true
,
{
kNA
,
kNA
,
kNA
,
165
,
kNA
,
kNA
,
kNA
}
},
// 117 Ts Tennessine
{
Ts
,
"Tennessine"
,
"Ts"
,
294
,
true
,
{
kNA
,
kNA
,
kNA
,
165
,
kNA
,
kNA
,
kNA
}
},
// 117 Ts Tennessine
{
Og
,
"Oganesson"
,
"Og"
,
294
,
true
,
{
kNA
,
kNA
,
kNA
,
157
,
kNA
,
kNA
,
kNA
}
}
// 118 Og Oganesson
{
Og
,
"Oganesson"
,
"Og"
,
294
,
true
,
{
kNA
,
kNA
,
kNA
,
157
,
kNA
,
kNA
,
kNA
}
},
// 118 Og Oganesson
{
D
,
"Deuterium"
,
"D"
,
2.014
,
false
,
{
53
,
25
,
37
,
32
,
kNA
,
kNA
,
120
}
},
// 1 D Deuterium
};
};
uint32_t
kKnownAtomsCount
=
sizeof
(
kKnownAtoms
)
/
sizeof
(
AtomTypeInfo
);
uint32_t
kKnownAtomsCount
=
sizeof
(
kKnownAtoms
)
/
sizeof
(
AtomTypeInfo
);
...
...
src/CifUtils.cpp
View file @
359538e1
...
@@ -18,9 +18,8 @@
...
@@ -18,9 +18,8 @@
#endif
#endif
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string.hpp>
#if BOOST_VERSION >= 104800
#include <boost/timer/timer.hpp>
#include <boost/timer/timer.hpp>
#
endif
#
include <boost/date_time/posix_time/posix_time.hpp>
#include "cif++/CifUtils.hpp"
#include "cif++/CifUtils.hpp"
...
@@ -440,9 +439,16 @@ struct ProgressImpl
...
@@ -440,9 +439,16 @@ struct ProgressImpl
{
{
ProgressImpl
(
int64_t
inMax
,
const
string
&
inAction
)
ProgressImpl
(
int64_t
inMax
,
const
string
&
inAction
)
:
mMax
(
inMax
),
mConsumed
(
0
),
mAction
(
inAction
),
mMessage
(
inAction
)
:
mMax
(
inMax
),
mConsumed
(
0
),
mAction
(
inAction
),
mMessage
(
inAction
)
,
mThread
(
std
::
bind
(
&
ProgressImpl
::
Run
,
this
))
{}
,
mThread
(
std
::
bind
(
&
ProgressImpl
::
Run
,
this
))
,
mStart
(
boost
::
posix_time
::
second_clock
::
local_time
())
{}
void
Run
();
void
Run
();
void
Stop
()
{
mStop
=
true
;
if
(
mThread
.
joinable
())
mThread
.
join
();
}
void
PrintProgress
();
void
PrintProgress
();
void
PrintDone
();
void
PrintDone
();
...
@@ -454,29 +460,35 @@ struct ProgressImpl
...
@@ -454,29 +460,35 @@ struct ProgressImpl
string
mAction
,
mMessage
;
string
mAction
,
mMessage
;
std
::
mutex
mMutex
;
std
::
mutex
mMutex
;
std
::
thread
mThread
;
std
::
thread
mThread
;
boost
::
timer
::
cpu_timer
boost
::
timer
::
cpu_timer
mTimer
;
mTimer
;
boost
::
posix_time
::
ptime
mStart
;
bool
mStop
=
false
;
};
};
void
ProgressImpl
::
Run
()
void
ProgressImpl
::
Run
()
{
{
using
namespace
boost
::
posix_time
;
// using namespace boost::local_time;
bool
printedAny
=
false
;
bool
printedAny
=
false
;
try
try
{
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
5
));
for
(;;)
for
(;;)
{
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
std
::
unique_lock
lock
(
mMutex
);
std
::
unique_lock
lock
(
mMutex
);
if
(
mConsumed
==
mMax
)
if
(
m
Stop
or
m
Consumed
==
mMax
)
break
;
break
;
if
(
second_clock
::
local_time
()
-
mStart
<
seconds
(
5
))
continue
;
PrintProgress
();
PrintProgress
();
printedAny
=
true
;
printedAny
=
true
;
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
}
}
}
}
catch
(...)
{}
catch
(...)
{}
...
@@ -593,11 +605,8 @@ Progress::Progress(int64_t inMax, const string& inAction)
...
@@ -593,11 +605,8 @@ Progress::Progress(int64_t inMax, const string& inAction)
Progress
::~
Progress
()
Progress
::~
Progress
()
{
{
if
(
mImpl
!=
nullptr
and
mImpl
->
mThread
.
joinable
())
if
(
mImpl
!=
nullptr
)
{
mImpl
->
Stop
();
// mImpl->mThread.interrupt();
mImpl
->
mThread
.
join
();
}
delete
mImpl
;
delete
mImpl
;
}
}
...
@@ -605,22 +614,18 @@ Progress::~Progress()
...
@@ -605,22 +614,18 @@ Progress::~Progress()
void
Progress
::
consumed
(
int64_t
inConsumed
)
void
Progress
::
consumed
(
int64_t
inConsumed
)
{
{
if
(
mImpl
!=
nullptr
and
if
(
mImpl
!=
nullptr
and
(
mImpl
->
mConsumed
+=
inConsumed
)
>=
mImpl
->
mMax
and
(
mImpl
->
mConsumed
+=
inConsumed
)
>=
mImpl
->
mMax
)
mImpl
->
mThread
.
joinable
())
{
{
// mImpl->mThread.interrupt();
mImpl
->
Stop
();
mImpl
->
mThread
.
join
();
}
}
}
}
void
Progress
::
progress
(
int64_t
inProgress
)
void
Progress
::
progress
(
int64_t
inProgress
)
{
{
if
(
mImpl
!=
nullptr
and
if
(
mImpl
!=
nullptr
and
(
mImpl
->
mConsumed
=
inProgress
)
>=
mImpl
->
mMax
and
(
mImpl
->
mConsumed
=
inProgress
)
>=
mImpl
->
mMax
)
mImpl
->
mThread
.
joinable
())
{
{
// mImpl->mThread.interrupt();
mImpl
->
Stop
();
mImpl
->
mThread
.
join
();
}
}
}
}
...
...
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