Skip to content

Commit

Permalink
get that code compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Mar 9, 2024
1 parent fb56a9c commit 92bd52d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/cif++/category.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class category

/// @brief Update the links in this category
/// @param db The enclosing @ref datablock
void update_links(datablock &db);
void update_links(const datablock &db);

/// @brief Return the global @ref validator for the data
/// @return The @ref validator or nullptr if not assigned
Expand Down
6 changes: 3 additions & 3 deletions src/category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ void category::set_validator(const validator *v, datablock &db)
update_links(db);
}

void category::update_links(datablock &db)
void category::update_links(const datablock &db)
{
m_child_links.clear();
m_parent_links.clear();
Expand All @@ -675,15 +675,15 @@ void category::update_links(datablock &db)
{
for (auto link : m_validator->get_links_for_parent(m_name))
{
auto childCat = db.get(link->m_child_category);
auto childCat = const_cast<category *>(db.get(link->m_child_category));
if (childCat == nullptr)
continue;
m_child_links.emplace_back(childCat, link);
}

for (auto link : m_validator->get_links_for_child(m_name))
{
auto parentCat = db.get(link->m_parent_category);
auto parentCat = const_cast<category *>(db.get(link->m_parent_category));
if (parentCat == nullptr)
continue;
m_parent_links.emplace_back(parentCat, link);
Expand Down
2 changes: 1 addition & 1 deletion src/datablock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ bool datablock::validate_links() const
bool result = true;

for (auto &cat : *this)
cat.update_links(*this);
const_cast<category &>(cat).update_links(*this);

for (auto &cat : *this)
result = cat.validate_links() and result;
Expand Down

0 comments on commit 92bd52d

Please sign in to comment.