From 3cb3c099bb79a1f4602f0d9efc127f0c41ddf83d Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 28 Aug 2022 16:15:57 +0200 Subject: [PATCH] App: minor improvements: * use 'using' instead of 'typedef' [modernize-use-using] * fix bugprone-reserved-identifier * fix whitespace/comma --- src/App/Document.cpp | 70 ++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 45871cd5e1..fdfdf6cf1e 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -134,7 +134,7 @@ using namespace zipios; namespace fs = boost::filesystem; // typedef boost::property VertexProperty; -typedef boost::adjacency_list < +using DependencyList = boost::adjacency_list < boost::vecS, // class OutEdgeListS : a Sequence or an AssociativeContainer boost::vecS, // class VertexListS : a Sequence or a RandomAccessContainer boost::directedS, // class DirectedS : This is a directed graph @@ -142,25 +142,25 @@ boost::no_property, // class VertexProperty: boost::no_property, // class EdgeProperty: boost::no_property, // class GraphProperty: boost::listS // class EdgeListS: -> DependencyList; -typedef boost::graph_traits Traits; -typedef Traits::vertex_descriptor Vertex; -typedef Traits::edge_descriptor Edge; -typedef std::vector Node; -typedef std::vector Path; +>; +using Traits = boost::graph_traits; +using Vertex = Traits::vertex_descriptor; +using Edge = Traits::edge_descriptor; +using Node = std::vector ; +using Path = std::vector ; namespace App { -static bool _IsRestoring; -static bool _IsRelabeling; +static bool globalIsRestoring; +static bool globalIsRelabeling; // Pimpl class struct DocumentP { // Array to preserve the creation order of created objects std::vector objectArray; std::unordered_set touchedObjs; - std::unordered_map objectMap; - std::unordered_map objectIdMap; + std::unordered_map objectMap; + std::unordered_map objectIdMap; std::unordered_map partialLoadObjects; std::vector pendingRemove; long lastObjectId; @@ -180,8 +180,8 @@ struct DocumentP std::string programVersion; #ifdef USE_OLD_DAG DependencyList DepList; - std::map VertexObjectList; - std::map vertexMap; + std::map VertexObjectList; + std::map vertexMap; #endif //USE_OLD_DAG std::multimap > _RecomputeLog; @@ -189,7 +189,7 @@ struct DocumentP DocumentP() { static std::random_device _RD; static std::mt19937 _RGEN(_RD()); - static std::uniform_int_distribution<> _RDIST(0,5000); + static std::uniform_int_distribution<> _RDIST(0, 5000); // Set some random offset to reduce likelihood of ID collision when // copying shape from other document. It is probably better to randomize // on each object ID. @@ -210,11 +210,11 @@ struct DocumentP } void addRecomputeLog(const char *why, App::DocumentObject *obj) { - addRecomputeLog(new DocumentObjectExecReturn(why,obj)); + addRecomputeLog(new DocumentObjectExecReturn(why, obj)); } void addRecomputeLog(const std::string &why, App::DocumentObject *obj) { - addRecomputeLog(new DocumentObjectExecReturn(why,obj)); + addRecomputeLog(new DocumentObjectExecReturn(why, obj)); } void addRecomputeLog(DocumentObjectExecReturn *returnCode) { @@ -223,7 +223,7 @@ struct DocumentP return; } _RecomputeLog.emplace(returnCode->Which, std::unique_ptr(returnCode)); - returnCode->Which->setStatus(ObjectStatus::Error,true); + returnCode->Which->setStatus(ObjectStatus::Error, true); } void clearRecomputeLog(const App::DocumentObject *obj=nullptr) { @@ -281,16 +281,16 @@ void Document::writeDependencyGraphViz(std::ostream &out) //for(std::map::const_iterator It1= _DepConMap.begin();It1 != _DepConMap.end(); ++It1) // VertexMap[It1->second] = It1->first; - out << "digraph G {" << endl; - out << "\tordering=out;" << endl; - out << "\tnode [shape = box];" << endl; + out << "digraph G {" << std::endl; + out << "\tordering=out;" << std::endl; + out << "\tnode [shape = box];" << std::endl; - for (auto It = d->objectMap.begin(); It != d->objectMap.end();++It) { - out << "\t" << It->first << ";" < OutList = It->second->getOutList(); - for (std::vector::const_iterator It2=OutList.begin();It2!=OutList.end();++It2) - if (*It2) - out << "\t" << It->first << "->" << (*It2)->getNameInDocument() << ";" <objectMap) { + out << "\t" << It.first << ";" << std::endl; + std::vector OutList = It.second->getOutList(); + for (const auto &It2 : OutList) + if (It2) + out << "\t" << It.first << "->" << It2->getNameInDocument() << ";" << std::endl; } /* @@ -1324,7 +1324,7 @@ void Document::clearDocument() GetApplication().signalNewDocument(*this,false); } - Base::FlagToggler<> flag(_IsRestoring,false); + Base::FlagToggler<> flag(globalIsRestoring, false); setStatus(Document::PartialDoc,false); @@ -1451,7 +1451,7 @@ void Document::onChanged(const Property* prop) // the Name property is a label for display purposes if (prop == &Label) { - Base::FlagToggler<> flag(_IsRelabeling); + Base::FlagToggler<> flag(globalIsRelabeling); App::GetApplication().signalRelabelDocument(*this); } else if(prop == &ShowHidden) { App::GetApplication().signalShowHidden(*this); @@ -1493,10 +1493,10 @@ void Document::onBeforeChangeProperty(const TransactionalObject *Who, const Prop { if(Who->isDerivedFrom(App::DocumentObject::getClassTypeId())) signalBeforeChangeObject(*static_cast(Who), *What); - if(!d->rollback && !_IsRelabeling) { - _checkTransaction(nullptr,What,__LINE__); + if(!d->rollback && !globalIsRelabeling) { + _checkTransaction(nullptr, What, __LINE__); if (d->activeUndoTransaction) - d->activeUndoTransaction->addObjectChange(Who,What); + d->activeUndoTransaction->addObjectChange(Who, What); } } @@ -2151,7 +2151,7 @@ void Document::addRecomputeObject(DocumentObject *obj) { std::vector Document::importObjects(Base::XMLReader& reader) { - Base::FlagToggler<> flag(_IsRestoring,false); + Base::FlagToggler<> flag(globalIsRestoring, false); Base::ObjectStatusLocker restoreBit(Status::Restoring, this); Base::ObjectStatusLocker restoreBit2(Status::Importing, this); ExpressionParser::ExpressionImporter expImporter(reader); @@ -2705,7 +2705,7 @@ bool Document::saveToFile(const char* filename) const } bool Document::isAnyRestoring() { - return _IsRestoring; + return globalIsRestoring; } // Open the document @@ -2723,7 +2723,7 @@ void Document::restore (const char *filename, d->clearDocument(); } - Base::FlagToggler<> flag(_IsRestoring,false); + Base::FlagToggler<> flag(globalIsRestoring, false); setStatus(Document::PartialDoc,false); @@ -2788,7 +2788,7 @@ void Document::restore (const char *filename, } bool Document::afterRestore(bool checkPartial) { - Base::FlagToggler<> flag(_IsRestoring,false); + Base::FlagToggler<> flag(globalIsRestoring, false); if(!afterRestore(d->objectArray,checkPartial)) { FC_WARN("Reload partial document " << getName()); GetApplication().signalPendingReloadDocument(*this);