Skip to content

Commit

Permalink
loading extra compound info changed
Browse files Browse the repository at this point in the history
cif::file constructors
  • Loading branch information
mhekkel committed Mar 6, 2024
1 parent 9eb06e9 commit a3b5ce9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
20 changes: 16 additions & 4 deletions include/cif++/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,22 @@ class file : public std::list<datablock>
}

/** @cond */
file(const file &) = default;
file(file &&) = default;
file &operator=(const file &) = default;
file &operator=(file &&) = default;
file(const file &rhs)
: std::list<datablock>(rhs)
{
}

file(file &&rhs)
{
this->swap(rhs);
}

file &operator=(file f)
{
this->swap(f);
return *this;
}

/** @endcond */

/**
Expand Down
2 changes: 1 addition & 1 deletion include/cif++/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace cif
/**
* @brief Implementation of an iterator that can return
* multiple values in a tuple. Of course, that tuple can
* then used in structured binding to receive the values
* then be used in structured binding to receive the values
* in a for loop e.g.
*
* @tparam Category The category for this iterator
Expand Down
14 changes: 11 additions & 3 deletions src/compound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class local_compound_factory_impl : public compound_factory_impl
compound *create(const std::string &id) override;

private:
const cif::file &m_local_file;
cif::file m_local_file;
};

compound *local_compound_factory_impl::create(const std::string &id)
Expand All @@ -559,11 +559,19 @@ compound *local_compound_factory_impl::create(const std::string &id)

for (auto &db : m_local_file)
{
if (db.name() == "comp_" + id)
if (db.name() == id)
{
cif::datablock db_copy(db);

result = new compound(db_copy, 1);
try
{
result = new compound(db_copy, 1);
}
catch (const std::exception &ex)
{
std::throw_with_nested(std::runtime_error("Error loading compound " + id));
}


std::shared_lock lock(mMutex);
m_compounds.push_back(result);
Expand Down

0 comments on commit a3b5ce9

Please sign in to comment.