diff --git a/BaseLib/CPUTime.h b/BaseLib/CPUTime.h index ae0c8fa16bd337003ce4ea48acbd32a10d563ba6..71d0d7486e0d77c12a92edc8168e7843582eab3a 100644 --- a/BaseLib/CPUTime.h +++ b/BaseLib/CPUTime.h @@ -26,16 +26,16 @@ class CPUTime /// Start the timer. void start() { - _start_time = clock(); + start_time_ = clock(); } /// Get the elapsed time after started. double elapsed() const { - return (clock() - _start_time)/static_cast<double>(CLOCKS_PER_SEC); + return (clock() - start_time_)/static_cast<double>(CLOCKS_PER_SEC); } private: - double _start_time = 0.; + double start_time_ = 0.; }; } // end namespace BaseLib diff --git a/BaseLib/ConfigTree-impl.h b/BaseLib/ConfigTree-impl.h index 3b7191313aef7a59b9756576988bed8020047cf6..071f4c3460ca390e04ad6f735faeb3a89181b5c6 100644 --- a/BaseLib/ConfigTree-impl.h +++ b/BaseLib/ConfigTree-impl.h @@ -22,17 +22,17 @@ class Range { public: explicit Range(Iterator begin, Iterator end) - : _begin(std::move(begin)), _end(std::move(end)) + : begin_(std::move(begin)), end_(std::move(end)) {} - Iterator begin() const { return _begin; } - Iterator end() const { return _end; } - std::size_t size() const { return std::distance(_begin, _end); } + Iterator begin() const { return begin_; } + Iterator end() const { return end_; } + std::size_t size() const { return std::distance(begin_, end_); } bool empty() const { return size() == 0; } private: - Iterator _begin; - Iterator _end; + Iterator begin_; + Iterator end_; }; template<typename T> @@ -120,7 +120,7 @@ getConfigParameterList(std::string const& param) const checkUnique(param); markVisited<T>(param, Attr::TAG, true); - auto p = _tree->equal_range(param); + auto p = tree_->equal_range(param); return Range<ValueIterator<T> >( ValueIterator<T>(p.first, param, *this), ValueIterator<T>(p.second, param, *this)); @@ -133,7 +133,7 @@ peekConfigParameter(std::string const& param) const { checkKeyname(param); - if (auto p = _tree->get_child_optional(param)) + if (auto p = tree_->get_child_optional(param)) { try { @@ -176,16 +176,16 @@ T ConfigTree:: getValue() const { - if (_have_read_data) { + if (have_read_data_) { error("The data of this subtree has already been read."); } - _have_read_data = true; + have_read_data_ = true; - if (auto v = _tree->get_value_optional<T>()) { + if (auto v = tree_->get_value_optional<T>()) { return *v; } - error("Value `" + shortString(_tree->data()) + + error("Value `" + shortString(tree_->data()) + "' is not convertible to the desired type."); } @@ -221,7 +221,7 @@ std::optional<T> ConfigTree::getConfigAttributeOptional( checkUniqueAttr(attr); auto& ct = markVisited<T>(attr, Attr::ATTR, true); - if (auto attrs = _tree->get_child_optional("<xmlattr>")) { + if (auto attrs = tree_->get_child_optional("<xmlattr>")) { if (auto a = attrs->get_child_optional(attr)) { ++ct.count; // count only if attribute has been found if (auto v = a->get_value_optional<T>()) { @@ -244,7 +244,7 @@ markVisited(std::string const& key, Attr const is_attr, { auto const type = std::type_index(typeid(T)); - auto p = _visited_params.emplace(std::make_pair(is_attr, key), + auto p = visited_params_.emplace(std::make_pair(is_attr, key), CountType{peek_only ? 0 : 1, type}); if (!p.second) { // no insertion happened diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp index e99c2770991782c713eb3661eac724cc34571aed..3bcb78ea2cb27c21cac25b71cb065f82bb765d0b 100644 --- a/BaseLib/ConfigTree.cpp +++ b/BaseLib/ConfigTree.cpp @@ -36,15 +36,15 @@ ConfigTree::ConfigTree(PTree const& tree, std::string filename, Callback error_cb, Callback warning_cb) - : _tree(&tree), - _filename(std::move(filename)), - _onerror(std::move(error_cb)), - _onwarning(std::move(warning_cb)) + : tree_(&tree), + filename_(std::move(filename)), + onerror_(std::move(error_cb)), + onwarning_(std::move(warning_cb)) { - if (!_onerror) { + if (!onerror_) { OGS_FATAL("ConfigTree: No valid error handler provided."); } - if (!_onwarning) { + if (!onwarning_) { OGS_FATAL("ConfigTree: No valid warning handler provided."); } } @@ -52,24 +52,24 @@ ConfigTree::ConfigTree(PTree const& tree, ConfigTree:: ConfigTree(PTree const& tree, ConfigTree const& parent, std::string const& root) - : _tree(&tree), _path(joinPaths(parent._path, root)), - _filename(parent._filename), - _onerror(parent._onerror), _onwarning(parent._onwarning) + : tree_(&tree), path_(joinPaths(parent.path_, root)), + filename_(parent.filename_), + onerror_(parent.onerror_), onwarning_(parent.onwarning_) { checkKeyname(root); } ConfigTree:: ConfigTree(ConfigTree && other) - : _tree (other._tree) - , _path (std::move(other._path)) - , _filename (std::move(other._filename)) - , _visited_params(std::move(other._visited_params)) - , _have_read_data (other._have_read_data) - , _onerror (std::move(other._onerror)) - , _onwarning (std::move(other._onwarning)) -{ - other._tree = nullptr; + : tree_ (other.tree_) + , path_ (std::move(other.path_)) + , filename_ (std::move(other.filename_)) + , visited_params_(std::move(other.visited_params_)) + , have_read_data_ (other.have_read_data_) + , onerror_ (std::move(other.onerror_)) + , onwarning_ (std::move(other.onwarning_)) +{ + other.tree_ = nullptr; } ConfigTree::~ConfigTree() @@ -96,14 +96,14 @@ operator=(ConfigTree&& other) { checkAndInvalidate(); - _tree = other._tree; - other._tree = nullptr; - _path = std::move(other._path); - _filename = std::move(other._filename); - _visited_params = std::move(other._visited_params); - _have_read_data = other._have_read_data; - _onerror = std::move(other._onerror); - _onwarning = std::move(other._onwarning); + tree_ = other.tree_; + other.tree_ = nullptr; + path_ = std::move(other.path_); + filename_ = std::move(other.filename_); + visited_params_ = std::move(other.visited_params_); + have_read_data_ = other.have_read_data_; + onerror_ = std::move(other.onerror_); + onwarning_ = std::move(other.onwarning_); return *this; } @@ -138,7 +138,7 @@ getConfigParameterList(const std::string ¶m) const checkUnique(param); markVisited(param, Attr::TAG, true); - auto p = _tree->equal_range(param); + auto p = tree_->equal_range(param); return Range<ParameterIterator>( ParameterIterator(p.first, param, *this), @@ -160,7 +160,7 @@ std::optional<ConfigTree> ConfigTree::getConfigSubtreeOptional( { checkUnique(root); - if (auto subtree = _tree->get_child_optional(root)) { + if (auto subtree = tree_->get_child_optional(root)) { markVisited(root, Attr::TAG, false); return ConfigTree(*subtree, *this, root); } @@ -175,7 +175,7 @@ getConfigSubtreeList(std::string const& root) const checkUnique(root); markVisited(root, Attr::TAG, true); - auto p = _tree->equal_range(root); + auto p = tree_->equal_range(root); return Range<SubtreeIterator>( SubtreeIterator(p.first, root, *this), @@ -186,7 +186,7 @@ void ConfigTree::ignoreConfigParameter(const std::string ¶m) const { checkUnique(param); // if not found, peek only - bool peek_only = _tree->find(param) == _tree->not_found(); + bool peek_only = tree_->find(param) == tree_->not_found(); markVisited(param, Attr::TAG, peek_only); } @@ -195,8 +195,8 @@ void ConfigTree::ignoreConfigAttribute(const std::string &attr) const checkUniqueAttr(attr); // Exercise: Guess what not! (hint: if not found, peek only) - // Btw. (not a hint) _tree->find() does not seem to work here. - bool peek_only = !_tree->get_child_optional("<xmlattr>." + attr); + // Btw. (not a hint) tree_->find() does not seem to work here. + bool peek_only = !tree_->get_child_optional("<xmlattr>." + attr); markVisited(attr, Attr::ATTR, peek_only); } @@ -206,7 +206,7 @@ void ConfigTree::ignoreConfigParameterAll(const std::string ¶m) const checkUnique(param); auto& ct = markVisited(param, Attr::TAG, true); - auto p = _tree->equal_range(param); + auto p = tree_->equal_range(param); for (auto it = p.first; it != p.second; ++it) { ++ct.count; } @@ -215,7 +215,7 @@ void ConfigTree::ignoreConfigParameterAll(const std::string ¶m) const void ConfigTree::error(const std::string& message) const { - _onerror(_filename, _path, message); + onerror_(filename_, path_, message); OGS_FATAL( "ConfigTree: The error handler does not break out of the normal " "control flow."); @@ -223,7 +223,7 @@ void ConfigTree::error(const std::string& message) const void ConfigTree::warning(const std::string& message) const { - _onwarning(_filename, _path, message); + onwarning_(filename_, path_, message); } @@ -307,7 +307,7 @@ void ConfigTree::checkUnique(const std::string &key) const { checkKeyname(key); - if (_visited_params.find({Attr::TAG, key}) != _visited_params.end()) { + if (visited_params_.find({Attr::TAG, key}) != visited_params_.end()) { error("Key <" + key + "> has already been processed."); } } @@ -338,7 +338,7 @@ void ConfigTree::checkUniqueAttr(const std::string &attr) const checkKeyname(attr); } - if (_visited_params.find({Attr::ATTR, attr}) != _visited_params.end()) { + if (visited_params_.find({Attr::ATTR, attr}) != visited_params_.end()) { error("Attribute '" + attr + "' has already been processed."); } } @@ -356,7 +356,7 @@ markVisitedDecrement(Attr const is_attr, std::string const& key) const { auto const type = std::type_index(typeid(nullptr)); - auto p = _visited_params.emplace(std::make_pair(is_attr, key), + auto p = visited_params_.emplace(std::make_pair(is_attr, key), CountType{-1, type}); if (!p.second) { // no insertion happened @@ -368,7 +368,7 @@ markVisitedDecrement(Attr const is_attr, std::string const& key) const bool ConfigTree::hasChildren() const { - auto const& tree = *_tree; + auto const& tree = *tree_; if (tree.begin() == tree.end()) { return false; // no children @@ -384,7 +384,7 @@ ConfigTree::hasChildren() const void ConfigTree::checkAndInvalidate() { - if (!_tree) + if (!tree_) { return; } @@ -392,13 +392,13 @@ ConfigTree::checkAndInvalidate() // Note: due to a limitation in boost::property_tree it is not possible // to discriminate between <tag></tag> and <tag/> in the input file. // In both cases data() will be empty. - if ((!_have_read_data) && !_tree->data().empty()) { - warning("The immediate data `" + shortString(_tree->data()) + if ((!have_read_data_) && !tree_->data().empty()) { + warning("The immediate data `" + shortString(tree_->data()) +"' of this tag has not been read."); } // iterate over children - for (auto const& p : *_tree) { + for (auto const& p : *tree_) { if (p.first != "<xmlattr>") { // attributes are handled below markVisitedDecrement(Attr::TAG, p.first); @@ -406,13 +406,13 @@ ConfigTree::checkAndInvalidate() } // iterate over attributes - if (auto attrs = _tree->get_child_optional("<xmlattr>")) { + if (auto attrs = tree_->get_child_optional("<xmlattr>")) { for (auto const& p : *attrs) { markVisitedDecrement(Attr::ATTR, p.first); } } - for (auto const& p : _visited_params) + for (auto const& p : visited_params_) { auto const& tag = p.first.second; auto const& count = p.second.count; @@ -444,7 +444,7 @@ ConfigTree::checkAndInvalidate() // The following invalidates this instance, s.t. it can not be read from it anymore, // but it also prevents double-checking. - _tree = nullptr; + tree_ = nullptr; } diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h index a9026e83e5cebb354aa6eacdda164059b846f8c1..b3b7895f361709b64312702e4fe1d3b681e914f0 100644 --- a/BaseLib/ConfigTree.h +++ b/BaseLib/ConfigTree.h @@ -109,40 +109,40 @@ public: explicit SubtreeIterator(Iterator const& it, std::string const& root, ConfigTree const& parent) - : _it(it), _tagname(root), _parent(parent) + : it_(it), tagname_(root), parent_(parent) {} SubtreeIterator& operator++() { - ++_it; - _has_incremented = true; + ++it_; + has_incremented_ = true; return *this; } ConfigTree operator*() { // if this iterator has been incremented since the last dereference, - // tell the _parent instance that a subtree now has been parsed. - if (_has_incremented) { - _has_incremented = false; - _parent.markVisited(_tagname, Attr::TAG, false); + // tell the parent_ instance that a subtree now has been parsed. + if (has_incremented_) { + has_incremented_ = false; + parent_.markVisited(tagname_, Attr::TAG, false); } - return ConfigTree(_it->second, _parent, _tagname); + return ConfigTree(it_->second, parent_, tagname_); } bool operator==(SubtreeIterator const& other) const { - return _it == other._it; + return it_ == other.it_; } bool operator!=(SubtreeIterator const& other) const { - return _it != other._it; + return it_ != other.it_; } private: - bool _has_incremented = true; - Iterator _it; + bool has_incremented_ = true; + Iterator it_; protected: - std::string const _tagname; - ConfigTree const& _parent; + std::string const tagname_; + ConfigTree const& parent_; }; /*! A wrapper around a Boost Iterator for iterating over ranges of parameters. @@ -160,7 +160,7 @@ public: auto st = SubtreeIterator::operator*(); if (st.hasChildren()) { - _parent.error("The requested parameter <" + _tagname + + parent_.error("The requested parameter <" + tagname_ + "> has child elements."); } return st; @@ -183,38 +183,38 @@ public: explicit ValueIterator(Iterator const& it, std::string const& root, ConfigTree const& parent) - : _it(it), _tagname(root), _parent(parent) + : it_(it), tagname_(root), parent_(parent) {} ValueIterator<ValueType>& operator++() { - ++_it; - _has_incremented = true; + ++it_; + has_incremented_ = true; return *this; } ValueType operator*() { // if this iterator has been incremented since the last dereference, - // tell the _parent instance that a setting now has been parsed. - if (_has_incremented) { - _has_incremented = false; - _parent.markVisited<ValueType>(_tagname, Attr::TAG, false); + // tell the parent_ instance that a setting now has been parsed. + if (has_incremented_) { + has_incremented_ = false; + parent_.markVisited<ValueType>(tagname_, Attr::TAG, false); } - return ConfigTree(_it->second, _parent, _tagname).getValue<ValueType>(); + return ConfigTree(it_->second, parent_, tagname_).getValue<ValueType>(); } bool operator==(ValueIterator<ValueType> const& other) const { - return _it == other._it; + return it_ == other.it_; } bool operator!=(ValueIterator<ValueType> const& other) const { - return _it != other._it; + return it_ != other.it_; } private: - bool _has_incremented = true; - Iterator _it; - std::string const _tagname; - ConfigTree const& _parent; + bool has_incremented_ = true; + Iterator it_; + std::string const tagname_; + ConfigTree const& parent_; }; //! The tree being wrapped by this class. @@ -253,7 +253,7 @@ public: /*! This constructor is deleted in order to prevent the user from passing * temporary instances of \c PTree. - * Doing so would lead to a dangling reference \c _tree and to program crash. + * Doing so would lead to a dangling reference \c tree_ and to program crash. */ explicit ConfigTree(PTree&&, std::string const&, Callback const&, Callback const&) = delete; @@ -273,7 +273,7 @@ public: ConfigTree& operator=(ConfigTree&& other); //! Used to get the project file name. - std::string const& getProjectFileName() const { return _filename; } + std::string const& getProjectFileName() const { return filename_; } /*! \name Methods for directly accessing parameter values * @@ -603,13 +603,13 @@ private: static std::string shortString(std::string const& s); //! The wrapped tree. - boost::property_tree::ptree const* _tree; + boost::property_tree::ptree const* tree_; //! A path printed in error/warning messages. - std::string _path; + std::string path_; //! The path of the file from which this tree has been read. - std::string _filename; + std::string filename_; //! A pair (is attribute, tag/attribute name). using KeyType = std::pair<Attr, std::string>; @@ -621,13 +621,13 @@ private: //! Therefore it has to be mutable in order to be able to read from //! constant instances, e.g., those passed as constant references to //! temporaries. - mutable std::map<KeyType, CountType> _visited_params; + mutable std::map<KeyType, CountType> visited_params_; //! Indicates if the plain data contained in this tree has already been read. - mutable bool _have_read_data = false; + mutable bool have_read_data_ = false; - Callback _onerror; //!< Custom error callback. - Callback _onwarning; //!< Custom warning callback. + Callback onerror_; //!< Custom error callback. + Callback onwarning_; //!< Custom warning callback. //! Character separating two path components. static const char pathseparator; diff --git a/BaseLib/ConfigTreeUtil.cpp b/BaseLib/ConfigTreeUtil.cpp index 44cd4424a829e09d31989e2ffc221f12ee7ff5bf..55f31d2eb5c53380521bec26400107d5391376f4 100644 --- a/BaseLib/ConfigTreeUtil.cpp +++ b/BaseLib/ConfigTreeUtil.cpp @@ -22,25 +22,25 @@ namespace BaseLib ConfigTreeTopLevel::ConfigTreeTopLevel(const std::string& filepath, const bool be_ruthless, ConfigTree::PTree&& ptree) - : _ptree(std::move(ptree)), - _ctree(_ptree, filepath, ConfigTree::onerror, + : ptree_(std::move(ptree)), + ctree_(ptree_, filepath, ConfigTree::onerror, be_ruthless ? ConfigTree::onerror : ConfigTree::onwarning) { } ConfigTree const& ConfigTreeTopLevel::operator*() const { - return _ctree; + return ctree_; } ConfigTree const* ConfigTreeTopLevel::operator->() const { - return &_ctree; + return &ctree_; } void ConfigTreeTopLevel::checkAndInvalidate() { - ::BaseLib::checkAndInvalidate(_ctree); + ::BaseLib::checkAndInvalidate(ctree_); } // Adapted from diff --git a/BaseLib/ConfigTreeUtil.h b/BaseLib/ConfigTreeUtil.h index 3327e1104602cb36dd6f6e08f087eabc6a648356..05705100c4de547597ff0e858386e5223ec8d4a5 100644 --- a/BaseLib/ConfigTreeUtil.h +++ b/BaseLib/ConfigTreeUtil.h @@ -36,7 +36,7 @@ public: /*! Access the contained ConfigTree. * * The non-const version of this method has not been implemented in order to prevent invalidating - * the \c _ctree when it is passed around. In order to check and invalidate \c _ctree use the provided + * the \c ctree_ when it is passed around. In order to check and invalidate \c ctree_ use the provided * member function. */ ConfigTree const& operator*() const; @@ -44,7 +44,7 @@ public: /*! Access the contained ConfigTree. * * The non-const version of this method has not been implemented in order to prevent invalidating - * the \c _ctree when it is passed around. In order to check and invalidate \c _ctree use the provided + * the \c ctree_ when it is passed around. In order to check and invalidate \c ctree_ use the provided * member function. */ ConfigTree const* operator->() const; @@ -58,8 +58,8 @@ public: void checkAndInvalidate(); private: - ConfigTree::PTree const _ptree; //!< <tt>boost::property_tree</tt> that underlies \c _ctree - ConfigTree _ctree; //!< ConfigTree depending on \c _ptree + ConfigTree::PTree const ptree_; //!< <tt>boost::property_tree</tt> that underlies \c ctree_ + ConfigTree ctree_; //!< ConfigTree depending on \c ptree_ }; /*! Create a ConfigTree from an XML file. diff --git a/BaseLib/Histogram.h b/BaseLib/Histogram.h index 88e7972a99986591d825248ddcb03e6a196b38b9..65a9b8a3c1642ece91b15690f22bf191f820e036 100644 --- a/BaseLib/Histogram.h +++ b/BaseLib/Histogram.h @@ -49,7 +49,7 @@ public: template <typename InputIterator> Histogram(InputIterator first, InputIterator last, const int nr_bins = 16, const bool computeHistogram = true ) - : _data(first, last), _nr_bins(nr_bins), _dirty(true) + : data_(first, last), nr_bins_(nr_bins), dirty_(true) { init(computeHistogram); } @@ -62,12 +62,12 @@ public: */ explicit Histogram(std::vector<T> data, const unsigned int nr_bins = 16, const bool computeHistogram = true) - : _data(std::move(data)), _nr_bins(nr_bins), _dirty(true) + : data_(std::move(data)), nr_bins_(nr_bins), dirty_(true) { init(computeHistogram); } - /** Updates histogram using sorted \c _data vector. + /** Updates histogram using sorted \c data_ vector. * * Start histogram creation with first element. Then find first element in * the next histogram bin. Number of elements in the bin is the difference @@ -79,47 +79,47 @@ public: */ void update() { - if (!_dirty) + if (!dirty_) { return; } - _bin_width = (_max - _min) / _nr_bins; + bin_width_ = (max_ - min_) / nr_bins_; - auto it = _data.begin(); - for (unsigned int bin = 0; bin < _nr_bins; bin++) + auto it = data_.begin(); + for (unsigned int bin = 0; bin < nr_bins_; bin++) { - auto itEnd = std::upper_bound(it, _data.end(), - _min + (bin + 1) * _bin_width); - _histogram[bin] = std::distance(it, itEnd); + auto itEnd = std::upper_bound(it, data_.end(), + min_ + (bin + 1) * bin_width_); + histogram_[bin] = std::distance(it, itEnd); it = itEnd; } - _dirty = false; + dirty_ = false; } - void setMinimum(const T& minimum) { _min = minimum; _dirty = true; } - void setMaximum(const T& maximum) { _max = maximum; _dirty = true; } + void setMinimum(const T& minimum) { min_ = minimum; dirty_ = true; } + void setMaximum(const T& maximum) { max_ = maximum; dirty_ = true; } - const Data& getSortedData() const { return _data; } - const std::vector<std::size_t>& getBinCounts() const { return _histogram; } - const unsigned int& getNumberOfBins() const { return _nr_bins; } - const T& getMinimum() const { return _min; } - const T& getMaximum() const { return _max; } - const T& getBinWidth() const { return _bin_width; } + const Data& getSortedData() const { return data_; } + const std::vector<std::size_t>& getBinCounts() const { return histogram_; } + const unsigned int& getNumberOfBins() const { return nr_bins_; } + const T& getMinimum() const { return min_; } + const T& getMaximum() const { return max_; } + const T& getBinWidth() const { return bin_width_; } void prettyPrint(std::ostream& os, const unsigned int line_width = 16) const { const std::size_t count_max = - *std::max_element(_histogram.begin(), _histogram.end()); - for (unsigned int bin = 0; bin < _nr_bins; ++bin) + *std::max_element(histogram_.begin(), histogram_.end()); + for (unsigned int bin = 0; bin < nr_bins_; ++bin) { - os << "[" << _min + bin * _bin_width << ", " << _min + - (bin + 1) * _bin_width << ")\t"; - os << _histogram[bin] << "\t"; + os << "[" << min_ + bin * bin_width_ << ", " << min_ + + (bin + 1) * bin_width_ << ")\t"; + os << histogram_[bin] << "\t"; const int n_stars = - std::ceil(line_width * ((double)_histogram[bin] / count_max)); + std::ceil(line_width * ((double)histogram_[bin] / count_max)); for (int star = 0; star < n_stars; star++) { os << "*"; @@ -162,27 +162,27 @@ protected: */ void init(const bool computeHistogram = true) { - std::sort(_data.begin(), _data.end()); - _histogram.resize(_nr_bins); - _min = _data.front(); - _max = _data.back(); - _bin_width = (_max - _min) / _nr_bins; + std::sort(data_.begin(), data_.end()); + histogram_.resize(nr_bins_); + min_ = data_.front(); + max_ = data_.back(); + bin_width_ = (max_ - min_) / nr_bins_; - _dirty = true; + dirty_ = true; if (computeHistogram) { update(); } } - Data _data; - const unsigned int _nr_bins; - std::vector<std::size_t> _histogram; - T _min, _max; ///< Minimum and maximum input data values. - T _bin_width; + Data data_; + const unsigned int nr_bins_; + std::vector<std::size_t> histogram_; + T min_, max_; ///< Minimum and maximum input data values. + T bin_width_; private: - bool _dirty; ///< When set \c update() will recompute histogram. + bool dirty_; ///< When set \c update() will recompute histogram. }; /** Writes histogram to output stream. diff --git a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp index f413563fc093c524e0ed4b26a9fda2f9c74287b6..71089941dc391c80c4e458a840b71f4a8abbb127 100644 --- a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp +++ b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp @@ -30,12 +30,12 @@ namespace BaseLib namespace IO { XMLQtInterface::XMLQtInterface(QString schemaFile) - : _schemaFile(std::move(schemaFile)) + : schemaFile_(std::move(schemaFile)) {} int XMLQtInterface::readFile(const QString &fileName) { - _fileName = fileName; + fileName_ = fileName; QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -43,7 +43,7 @@ int XMLQtInterface::readFile(const QString &fileName) fileName.toStdString()); return 0; } - _fileData = file.readAll(); + fileData_ = file.readAll(); file.close(); if (!checkHash()) @@ -57,16 +57,16 @@ int XMLQtInterface::readFile(const QString &fileName) int XMLQtInterface::isValid() const { QXmlSchema schema; - if(_schemaFile.length() > 0) + if(schemaFile_.length() > 0) { - auto path = QDir(QCoreApplication::applicationDirPath()).filePath(_schemaFile); + auto path = QDir(QCoreApplication::applicationDirPath()).filePath(schemaFile_); auto url = QUrl::fromLocalFile(path); schema.load(url); } if ( schema.isValid() ) { QXmlSchemaValidator validator( schema ); - if (validator.validate(_fileData)) + if (validator.validate(fileData_)) { return 1; } @@ -74,14 +74,14 @@ int XMLQtInterface::isValid() const INFO( "XMLQtInterface::isValid(): XML file {:s} is invalid (in reference " "to schema {:s}).", - _fileName.toStdString(), _schemaFile.toStdString()); + fileName_.toStdString(), schemaFile_.toStdString()); } else { // The following validator (without constructor arguments) automatically // searches for the xsd given in the xml file. QXmlSchemaValidator validator; - if (validator.validate(_fileData)) + if (validator.validate(fileData_)) { return 1; } @@ -89,15 +89,15 @@ int XMLQtInterface::isValid() const INFO( "XMLQtInterface::isValid(): XML file {:s} is invalid (in reference " "to its schema).", - _fileName.toStdString()); + fileName_.toStdString()); } return 0; } bool XMLQtInterface::checkHash() const { - QString md5FileName(_fileName + ".md5"); - QByteArray fileHash = QCryptographicHash::hash(_fileData, QCryptographicHash::Md5); + QString md5FileName(fileName_ + ".md5"); + QByteArray fileHash = QCryptographicHash::hash(fileData_, QCryptographicHash::Md5); QFile file(md5FileName); if (file.open(QIODevice::ReadOnly)) @@ -132,7 +132,7 @@ bool XMLQtInterface::checkHash() const QByteArray const& XMLQtInterface::getContent() const { - return _fileData; + return fileData_; } } // namespace IO } // namespace BaseLib diff --git a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.h b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.h index a6363a7bcea086c4b03349a2203c6814e11e1689..522f84066d77c5ebd3d840d048158bfdb248adca 100644 --- a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.h +++ b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.h @@ -52,12 +52,12 @@ private: private: /// The actual file name when reading. - QString _fileName; + QString fileName_; - QString _schemaFile; + QString schemaFile_; /// Caches the actual file contents when reading. - QByteArray _fileData; + QByteArray fileData_; }; } // end namespace IO diff --git a/BaseLib/MemWatch.cpp b/BaseLib/MemWatch.cpp index ecce7e696e114bd36771eec8d5c072e92e90f112..75bf0876519ee2adbc80a5676e3c6273df39b67f 100644 --- a/BaseLib/MemWatch.cpp +++ b/BaseLib/MemWatch.cpp @@ -47,7 +47,7 @@ unsigned MemWatch::updateMemUsage () } in >> pages; - _vmem_size = static_cast<unsigned long>(pages) * + vmem_size_ = static_cast<unsigned long>(pages) * static_cast<unsigned long>(getpagesize()); in.close (); #endif @@ -58,7 +58,7 @@ unsigned MemWatch::updateMemUsage () unsigned long MemWatch::getVirtMemUsage () { updateMemUsage (); - return _vmem_size; + return vmem_size_; } } // end namespace BaseLib diff --git a/BaseLib/MemWatch.h b/BaseLib/MemWatch.h index c3940a323a837bda37c9f006c8398e339b655c7f..03af40148547afc2269fd7bad3d4e8a7a3165dd5 100644 --- a/BaseLib/MemWatch.h +++ b/BaseLib/MemWatch.h @@ -23,7 +23,7 @@ public: private: unsigned updateMemUsage (); - unsigned long _vmem_size = 0; + unsigned long vmem_size_ = 0; }; } // namespace BaseLib diff --git a/BaseLib/RunTime.h b/BaseLib/RunTime.h index ceb08b7f77ec7085bd643b85ab4cc3c110c77cef..c8d1c5cd360b686a5ccfc3ddb255dd7e092efe4a 100644 --- a/BaseLib/RunTime.h +++ b/BaseLib/RunTime.h @@ -30,9 +30,9 @@ public: void start() { #ifdef USE_PETSC - _start_time = MPI_Wtime(); + start_time_ = MPI_Wtime(); #else - _start_time = std::chrono::system_clock::now(); + start_time_ = std::chrono::system_clock::now(); #endif } @@ -40,18 +40,18 @@ public: double elapsed() const { #ifdef USE_PETSC - return MPI_Wtime() - _start_time; + return MPI_Wtime() - start_time_; #else using namespace std::chrono; - return duration<double>(system_clock::now() - _start_time).count(); + return duration<double>(system_clock::now() - start_time_).count(); #endif } private: #ifdef USE_PETSC - double _start_time = std::numeric_limits<double>::quiet_NaN(); + double start_time_ = std::numeric_limits<double>::quiet_NaN(); #else - std::chrono::time_point<std::chrono::system_clock> _start_time; + std::chrono::time_point<std::chrono::system_clock> start_time_; #endif }; diff --git a/BaseLib/Subdivision.cpp b/BaseLib/Subdivision.cpp index ee9eb78d1423f08837d6f012669e87fda6b261e4..052cbc8d99958a2598f349975d329c5f34098d91 100644 --- a/BaseLib/Subdivision.cpp +++ b/BaseLib/Subdivision.cpp @@ -21,7 +21,7 @@ GradualSubdivision::GradualSubdivision(const double L, const double dL0, const double max_dL, const double multiplier) - : _length(L), _dL0(dL0), _max_dL(max_dL), _multiplier(multiplier) + : length_(L), dL0_(dL0), max_dL_(max_dL), multiplier_(multiplier) { // Check if accumulated subdivisions can ever sum up to length. // Cf. geometric series formula. @@ -43,20 +43,20 @@ std::vector<double> GradualSubdivision::operator()() const unsigned i = 0; do { vec_x.push_back(x); - x += std::min(_max_dL, - _dL0 * std::pow(_multiplier, static_cast<double>(i))); + x += std::min(max_dL_, + dL0_ * std::pow(multiplier_, static_cast<double>(i))); i++; - } while (x < _length); + } while (x < length_); - if (vec_x.back() < _length) { + if (vec_x.back() < length_) { double last_dx = vec_x[vec_x.size() - 1] - vec_x[vec_x.size() - 2]; - if (_length - vec_x.back() < last_dx) + if (length_ - vec_x.back() < last_dx) { - vec_x[vec_x.size() - 1] = _length; + vec_x[vec_x.size() - 1] = length_; } else { - vec_x.push_back(_length); + vec_x.push_back(length_); } } return vec_x; @@ -64,36 +64,36 @@ std::vector<double> GradualSubdivision::operator()() const GradualSubdivisionFixedNum::GradualSubdivisionFixedNum( const double L, const std::size_t num_subdivisions, const double multiplier) - : _length{L}, _num_subdivisions{num_subdivisions}, _multiplier{multiplier} + : length_{L}, num_subdivisions_{num_subdivisions}, multiplier_{multiplier} { } std::vector<double> GradualSubdivisionFixedNum::operator()() const { std::vector<double> subdivisions; - subdivisions.reserve(_num_subdivisions + 1); + subdivisions.reserve(num_subdivisions_ + 1); subdivisions.push_back(0.0); - auto const q = _multiplier; + auto const q = multiplier_; if (q == 1.0) { - double const dx = _length / _num_subdivisions; + double const dx = length_ / num_subdivisions_; - for (std::size_t i = 1; i < _num_subdivisions; ++i) { + for (std::size_t i = 1; i < num_subdivisions_; ++i) { subdivisions.push_back(dx * i); } } else { // compute initial subdivision size auto const a = - _length * (q - 1.0) / (std::pow(q, _num_subdivisions) - 1.0); + length_ * (q - 1.0) / (std::pow(q, num_subdivisions_) - 1.0); double qi = q; // q^i - for (std::size_t i = 1; i < _num_subdivisions; ++i) { + for (std::size_t i = 1; i < num_subdivisions_; ++i) { subdivisions.push_back(a * (qi - 1.0) / (q - 1.0)); qi *= q; } } - subdivisions.push_back(_length); + subdivisions.push_back(length_); return subdivisions; } diff --git a/BaseLib/Subdivision.h b/BaseLib/Subdivision.h index 87cfa009d76a01de3fc43ba8096f404178148bc0..850e9e57e560890cc53d3c10c26fb662528db095 100644 --- a/BaseLib/Subdivision.h +++ b/BaseLib/Subdivision.h @@ -39,15 +39,15 @@ public: * @param n_subdivision the number of subdivision */ UniformSubdivision(double length, std::size_t n_subdivision) - : _length(length), _n_subdivision(n_subdivision) {} + : length_(length), n_subdivision_(n_subdivision) {} /// Returns a vector of subdivided points std::vector<double> operator()() const override { std::vector<double> x; - x.reserve(_n_subdivision+1); - const double dL = _length/static_cast<double>(_n_subdivision); - for (std::size_t i = 0; i < _n_subdivision + 1; i++) + x.reserve(n_subdivision_+1); + const double dL = length_/static_cast<double>(n_subdivision_); + for (std::size_t i = 0; i < n_subdivision_ + 1; i++) { x.push_back(i * dL); } @@ -55,12 +55,12 @@ public: } private: - const double _length; - const std::size_t _n_subdivision; + const double length_; + const std::size_t n_subdivision_; }; /** - * Gradual subdivision operator with a constant _multiplier + * Gradual subdivision operator with a constant multiplier_ */ class GradualSubdivision : public ISubdivision { @@ -82,14 +82,14 @@ public: std::vector<double> operator()() const override; private: - const double _length; - const double _dL0; - const double _max_dL; - const double _multiplier; + const double length_; + const double dL0_; + const double max_dL_; + const double multiplier_; }; /** - * Gradual subdivision operator with a constant _multiplier. + * Gradual subdivision operator with a constant multiplier_. * * In this class the number of subdivisions is known a priori. */ @@ -110,9 +110,9 @@ public: std::vector<double> operator()() const override; private: - const double _length; - const std::size_t _num_subdivisions; - const double _multiplier; + const double length_; + const std::size_t num_subdivisions_; + const double multiplier_; }; } // namespace BaseLib diff --git a/BaseLib/TCLAPCustomOutput.h b/BaseLib/TCLAPCustomOutput.h index 7ba0dcade79d37d9ac92328ff2d69ac8b8fd3fd5..84b60ecc2b246ea0da53fcfd426f54bacc7056bf 100644 --- a/BaseLib/TCLAPCustomOutput.h +++ b/BaseLib/TCLAPCustomOutput.h @@ -34,62 +34,62 @@ public: /** * Prints the usage to stdout. Can be overridden to * produce alternative behavior. - * \param _cmd - The CmdLine object the output is generated for. + * \param cmd_ - The CmdLine object the output is generated for. */ - virtual void usage(TCLAP::CmdLineInterface& _cmd); + virtual void usage(TCLAP::CmdLineInterface& cmd_); /** * Prints (to stderr) an error message, short usage * Can be overridden to produce alternative behavior. - * \param _cmd - The CmdLine object the output is generated for. + * \param cmd_ - The CmdLine object the output is generated for. * \param e - The ArgException that caused the failure. */ - virtual void failure(TCLAP::CmdLineInterface& _cmd, TCLAP::ArgException& e); + virtual void failure(TCLAP::CmdLineInterface& cmd_, TCLAP::ArgException& e); protected: /** * Writes a brief usage message with short args. - * \param _cmd - The CmdLine object the output is generated for. + * \param cmd_ - The CmdLine object the output is generated for. * \param os - The stream to write the message to. */ - void _shortUsage(TCLAP::CmdLineInterface& _cmd, std::ostream& os) const; + void shortUsage_(TCLAP::CmdLineInterface& cmd_, std::ostream& os) const; /** * Writes a longer usage message with long and short args, * provides descriptions and prints message. - * \param _cmd - The CmdLine object the output is generated for. + * \param cmd_ - The CmdLine object the output is generated for. * \param os - The stream to write the message to. */ - void _longUsage(TCLAP::CmdLineInterface& _cmd, std::ostream& os) const; + void longUsage_(TCLAP::CmdLineInterface& cmd_, std::ostream& os) const; }; -inline void TCLAPCustomOutput::usage(TCLAP::CmdLineInterface& _cmd ) +inline void TCLAPCustomOutput::usage(TCLAP::CmdLineInterface& cmd_ ) { std::cout << std::endl << "USAGE: " << std::endl << std::endl; - _shortUsage( _cmd, std::cout ); + shortUsage_( cmd_, std::cout ); std::cout << std::endl << std::endl << "Where: " << std::endl << std::endl; - _longUsage( _cmd, std::cout ); + longUsage_( cmd_, std::cout ); std::cout << std::endl; } -inline void TCLAPCustomOutput::failure( TCLAP::CmdLineInterface& _cmd, +inline void TCLAPCustomOutput::failure( TCLAP::CmdLineInterface& cmd_, TCLAP::ArgException& e ) { - std::string progName = _cmd.getProgramName(); + std::string progName = cmd_.getProgramName(); std::cerr << "PARSE ERROR: " << e.argId() << std::endl << " " << e.error() << std::endl << std::endl; - if ( _cmd.hasHelpAndVersion() ) + if ( cmd_.hasHelpAndVersion() ) { std::cerr << "Brief USAGE: " << std::endl; - _shortUsage( _cmd, std::cerr ); + shortUsage_( cmd_, std::cerr ); std::cerr << std::endl << "For complete USAGE and HELP type: " << std::endl << " " << progName << " --help" @@ -97,19 +97,19 @@ inline void TCLAPCustomOutput::failure( TCLAP::CmdLineInterface& _cmd, } else { - usage(_cmd); + usage(cmd_); } throw TCLAP::ExitException(1); } inline void -TCLAPCustomOutput::_shortUsage( TCLAP::CmdLineInterface& _cmd, +TCLAPCustomOutput::shortUsage_( TCLAP::CmdLineInterface& cmd_, std::ostream& os ) const { - std::list<TCLAP::Arg*> argList = _cmd.getArgList(); - std::string progName = _cmd.getProgramName(); - TCLAP::XorHandler xorHandler = _cmd.getXorHandler(); + std::list<TCLAP::Arg*> argList = cmd_.getArgList(); + std::string progName = cmd_.getProgramName(); + TCLAP::XorHandler xorHandler = cmd_.getXorHandler(); std::vector< std::vector<TCLAP::Arg*> > xorList = xorHandler.getXorList(); std::string s = progName + " "; @@ -148,12 +148,12 @@ TCLAPCustomOutput::_shortUsage( TCLAP::CmdLineInterface& _cmd, } inline void -TCLAPCustomOutput::_longUsage( TCLAP::CmdLineInterface& _cmd, +TCLAPCustomOutput::longUsage_( TCLAP::CmdLineInterface& cmd_, std::ostream& os ) const { - std::list<TCLAP::Arg*> argList = _cmd.getArgList(); - std::string message = _cmd.getMessage(); - TCLAP::XorHandler xorHandler = _cmd.getXorHandler(); + std::list<TCLAP::Arg*> argList = cmd_.getArgList(); + std::string message = cmd_.getMessage(); + TCLAP::XorHandler xorHandler = cmd_.getXorHandler(); std::vector< std::vector<TCLAP::Arg*> > xorList = xorHandler.getXorList(); // first the xor