Make PackageDepends a type, rather than repeating it's definition everywhere. --- IniDBBuilderPackage.h | 2 +- Makefile.am | 1 + desktop.cc | 1 - package_db.cc | 2 +- package_depends.h | 21 +++++++++++++++++++++ package_version.cc | 8 ++++---- package_version.h | 9 +++++---- prereq.cc | 4 ++-- 8 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 package_depends.h
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h index ef1a6bf..4df1bdb 100644 --- a/IniDBBuilderPackage.h +++ b/IniDBBuilderPackage.h @@ -72,7 +72,7 @@ private: packagemeta *csp; packageversion cspv; PackageSpecification *currentSpec; - std::vector<PackageSpecification *> *currentNodeList; + PackageDepends *currentNodeList; int trust; IniParseFeedback const &_feedback; }; diff --git a/Makefile.am b/Makefile.am index 7d5e1e3..f0f36f7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -202,6 +202,7 @@ inilint_SOURCES = \ nio-http.h \ package_db.cc \ package_db.h \ + package_depends.h \ package_meta.cc \ package_meta.h \ package_source.cc \ diff --git a/desktop.cc b/desktop.cc index 81278dd..24908f8 100644 --- a/desktop.cc +++ b/desktop.cc @@ -39,7 +39,6 @@ #include "filemanip.h" #include "io_stream.h" #include "getopt++/BoolOption.h" -#include "PackageSpecification.h" #include "LogFile.h" static BoolOption NoShortcutsOption (false, 'n', "no-shortcuts", "Disable creation of desktop and start menu shortcuts"); diff --git a/package_db.cc b/package_db.cc index e97eea1..3978421 100644 --- a/package_db.cc +++ b/package_db.cc @@ -312,7 +312,7 @@ ConnectedLoopFinder::visit(packagemeta *nodeToVisit) nodesInStronglyConnectedComponent.push(nodeToVisit); /* walk through each node */ - std::vector <PackageSpecification *>::const_iterator dp = nodeToVisit->installed.depends()->begin(); + PackageDepends::const_iterator dp = nodeToVisit->installed.depends()->begin(); while (dp != nodeToVisit->installed.depends()->end()) { /* check for an installed match */ diff --git a/package_depends.h b/package_depends.h new file mode 100644 index 0000000..05e0dc6 --- /dev/null +++ b/package_depends.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017 Jon Turney + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + */ + +#ifndef PACKAGE_DEPENDS_H +#define PACKAGE_DEPENDS_H + +#include <vector> + +typedef std::vector <PackageSpecification *> PackageDepends; + +#endif // PACKAGE_DEPENDS_H diff --git a/package_version.cc b/package_version.cc index cd2d509..6a903c5 100644 --- a/package_version.cc +++ b/package_version.cc @@ -229,13 +229,13 @@ packageversion::setSourcePackageSpecification (PackageSpecification const &spec) data->setSourcePackageSpecification(spec); } -vector <PackageSpecification *> * +PackageDepends * packageversion::depends() { return &data->depends; } -const vector <PackageSpecification *> * +const PackageDepends * packageversion::depends() const { return &data->depends; @@ -414,13 +414,13 @@ _packageversion::scripts() } void -dumpAndList (std::vector <PackageSpecification *> const *currentList, +dumpAndList (PackageDepends const *currentList, std::ostream &logger) { if (currentList) { Log (LOG_BABBLE) << "( "; - std::vector <PackageSpecification *>::const_iterator i = currentList->begin(); + PackageDepends::const_iterator i = currentList->begin(); while (true) { if (i == currentList->end()) break; diff --git a/package_version.h b/package_version.h index 2f277bf..ff16eb8 100644 --- a/package_version.h +++ b/package_version.h @@ -43,6 +43,7 @@ class CategoryList; #include "package_source.h" #include "PackageSpecification.h" #include "PackageTrust.h" +#include "package_depends.h" #include "script.h" #include <vector> @@ -110,8 +111,8 @@ public: void setSourcePackageSpecification (PackageSpecification const &); /* invariant: these never return NULL */ - std::vector <PackageSpecification *> *depends(); - const std::vector <PackageSpecification *> *depends() const; + PackageDepends *depends(); + const PackageDepends *depends() const; bool picked() const; /* true if this version is to be installed */ void pick(bool, packagemeta *); /* trigger an install/reinsall */ @@ -171,7 +172,7 @@ public: virtual PackageSpecification & sourcePackageSpecification (); virtual void setSourcePackageSpecification (PackageSpecification const &); - std::vector <PackageSpecification *> depends; + PackageDepends depends; virtual void pick(bool const &newValue) { picked = newValue;} bool picked; /* non zero if this version is to be installed */ @@ -196,6 +197,6 @@ protected: }; // not sure where this belongs :}. -void dumpAndList (std::vector <PackageSpecification *> const *currentList, std::ostream &); +void dumpAndList (PackageDepends const *currentList, std::ostream &); #endif /* SETUP_PACKAGE_VERSION_H */ diff --git a/prereq.cc b/prereq.cc index 7477f79..eb8e21f 100644 --- a/prereq.cc +++ b/prereq.cc @@ -211,10 +211,10 @@ PrereqChecker::isMet () // Fetch the dependencies of the package. This assumes that the // dependencies of all versions are all the same. - const std::vector <PackageSpecification *> *deps = pack->curr.depends (); + const PackageDepends *deps = pack->curr.depends (); // go through the package's dependencies - for (std::vector <PackageSpecification *>::const_iterator d = + for (PackageDepends::const_iterator d = deps->begin (); d != deps->end (); ++d) { PackageSpecification *dep_spec = *d; -- 2.12.3