94 char* errMsg =
nullptr;
96 "BEGIN TRANSACTION; DROP TABLE IF EXISTS ParameterSets;" 97 "CREATE TABLE ParameterSets(ID PRIMARY KEY, PSetBlob); COMMIT;",
104 vector<pair<string, bool>> testData{
105 {
"x: [ 1, 3, 5, 7 ]",
false},
106 {
"a2: [ oh, my, stars ]",
true},
107 {
"y1: \"Oh, home on the range\" y2: \"Where the deer and the antelope " 110 vector<pair<ParameterSet, bool>> v1(testData.size());
113 vector<function<void()>> tasks;
115 [&v1, &tasks](
size_t const i,
auto const&
p) {
117 tasks.push_back([&
entry, &
p] {
119 entry = make_pair(pset,
p.second);
122 simultaneous_function_spawner sfs{tasks};
126 std::recursive_mutex
m{};
127 auto insert_into_db = [&db, &
m](
auto const& pr) {
140 "INSERT INTO ParameterSets(ID, PSetBlob) VALUES(?, ?);",
145 auto const& pset = pr.first;
146 bool const inRegistry{pr.second};
147 string const id{pset.id().to_string()};
149 sqlite3_bind_text(oStmt, 1,
id.c_str(),
id.
size() + 1, SQLITE_STATIC);
152 string const psBlob{pset.to_compact_string()};
153 auto const rc2 = sqlite3_bind_text(
154 oStmt, 2, psBlob.c_str(), psBlob.size() + 1, SQLITE_STATIC);
158 std::lock_guard sentry{
m};
159 assert(sqlite3_step(oStmt) == SQLITE_DONE);
161 auto const rc3 = sqlite3_finalize(oStmt);
164 assert(ParameterSetRegistry::has(pset.id()) == inRegistry);
166 vector<function<void()>> tasks;
168 v1, back_inserter(tasks), [insert_into_db](
auto const& pr) {
169 return [insert_into_db, pr] { insert_into_db(pr); };
171 simultaneous_function_spawner sfs{tasks};
174 ParameterSetRegistry::importFrom(db);
180 std::recursive_mutex
m{};
181 auto read_from_registry = [&expected_size, &
m](
auto const&
p) {
182 auto const&
id =
p.first.id();
186 std::lock_guard sentry{
m};
193 std::lock_guard sentry{
m};
203 std::lock_guard sentry{
m};
208 vector<function<void()>> tasks;
210 v1, back_inserter(tasks), [read_from_registry](
auto const&
p) {
211 return [read_from_registry,
p] { read_from_registry(
p); };
213 simultaneous_function_spawner sfs{tasks};
void for_all_with_index(FwdCont &, Func)
struct sqlite3_stmt sqlite3_stmt
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
auto transform_all(Container &, OutputIt, UnaryOp)
void throwOnSQLiteFailure(int rc, char *msg=nullptr)
auto const & get(AssnsNode< L, R, D > const &r)