Skip to content
Snippets Groups Projects
Commit 27d27001 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[BL] move checkAndInvalidate()

The access now must be done through some non-member functions.
parent ca43f661
No related branches found
No related tags found
No related merge requests found
...@@ -246,4 +246,20 @@ ConfigTreeNew::checkAndInvalidate() ...@@ -246,4 +246,20 @@ ConfigTreeNew::checkAndInvalidate()
_tree = nullptr; _tree = nullptr;
} }
void checkAndInvalidate(ConfigTreeNew &conf)
{
conf.checkAndInvalidate();
}
void checkAndInvalidate(ConfigTreeNew* const conf)
{
if (conf) conf->checkAndInvalidate();
}
void checkAndInvalidate(std::unique_ptr<ConfigTreeNew> const& conf)
{
if (conf) conf->checkAndInvalidate();
}
} }
...@@ -15,10 +15,27 @@ ...@@ -15,10 +15,27 @@
#include <map> #include <map>
#include <functional> #include <functional>
#include <memory>
namespace BaseLib namespace BaseLib
{ {
class ConfigTreeNew;
/*! Check if \c conf has been read entirely and invalidate it.
*
* This method can savely be called on \c nullptr's.
*
* \see ConfigTreeNew::checkAndInvalidate()
*/
void checkAndInvalidate(ConfigTreeNew* const conf);
//! \overload
void checkAndInvalidate(std::unique_ptr<ConfigTreeNew> const& conf);
//! \overload
void checkAndInvalidate(ConfigTreeNew& conf);
template<typename Iterator> class Range; template<typename Iterator> class Range;
/*! /*!
...@@ -305,13 +322,6 @@ public: ...@@ -305,13 +322,6 @@ public:
*/ */
void ignoreConfParamAll(std::string const& param) const; void ignoreConfParamAll(std::string const& param) const;
/*! Checks if the top level of this tree has been read entirely (and not too often).
*
* Caution: This method also invalidates the instance, i.e., afterwards it can not
* be read from the tree anymore!
*/
void checkAndInvalidate();
//! The destructor performs the check if all nodes at the current level of the tree //! The destructor performs the check if all nodes at the current level of the tree
//! have been read. //! have been read.
~ConfigTreeNew(); ~ConfigTreeNew();
...@@ -372,6 +382,13 @@ private: ...@@ -372,6 +382,13 @@ private:
//! and the number of times it exists in the ConfigTree //! and the number of times it exists in the ConfigTree
void markVisitedDecrement(std::string const& key) const; void markVisitedDecrement(std::string const& key) const;
/*! Checks if the top level of this tree has been read entirely (and not too often).
*
* Caution: This method also invalidates the instance, i.e., afterwards it can not
* be read from the tree anymore!
*/
void checkAndInvalidate();
//! returns a short string at suitable for error/warning messages //! returns a short string at suitable for error/warning messages
static std::string shortString(std::string const& s); static std::string shortString(std::string const& s);
...@@ -401,6 +418,10 @@ private: ...@@ -401,6 +418,10 @@ private:
//! Set of allowed characters in a key name. //! Set of allowed characters in a key name.
static const std::string key_chars; static const std::string key_chars;
friend void checkAndInvalidate(ConfigTreeNew* const conf);
friend void checkAndInvalidate(ConfigTreeNew& conf);
friend void checkAndInvalidate(std::unique_ptr<ConfigTreeNew> const& conf);
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment