This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 10/14] Remove packageversion class
- From: Jon Turney <jon dot turney at dronecode dot org dot uk>
- To: cygwin-apps at cygwin dot com
- Cc: Jon Turney <jon dot turney at dronecode dot org dot uk>
- Date: Wed, 31 May 2017 11:50:11 +0100
- Subject: [PATCH setup 10/14] Remove packageversion class
- Authentication-results: sourceware.org; auth=none
- References: <20170531105015.162228-1-jon.turney@dronecode.org.uk>
Remove packageversion, _packageversion, defaultversion classes
---
Makefile.am | 2 -
PickPackageLine.cc | 1 -
PickView.cc | 1 -
choose.cc | 1 -
desktop.cc | 1 -
download.cc | 1 -
package_db.cc | 2 -
package_meta.cc | 3 -
package_version.cc | 334 -----------------------------------------------------
package_version.h | 168 ---------------------------
10 files changed, 514 deletions(-)
delete mode 100644 package_version.cc
delete mode 100644 package_version.h
diff --git a/Makefile.am b/Makefile.am
index 27bb8f1..7ea9d89 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -208,8 +208,6 @@ inilint_SOURCES = \
package_meta.h \
package_source.cc \
package_source.h \
- package_version.cc \
- package_version.h \
PackageSpecification.cc \
PackageSpecification.h \
PackageTrust.h \
diff --git a/PickPackageLine.cc b/PickPackageLine.cc
index 95c1557..6f44192 100644
--- a/PickPackageLine.cc
+++ b/PickPackageLine.cc
@@ -16,7 +16,6 @@
#include "PickPackageLine.h"
#include "PickView.h"
#include "package_db.h"
-#include "package_version.h"
void
PickPackageLine::paint (HDC hdc, HRGN unused, int x, int y, int col_num, int show_cat)
diff --git a/PickView.cc b/PickView.cc
index 4c728f8..5bc7504 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -21,7 +21,6 @@
#include "PickPackageLine.h"
#include "PickCategoryLine.h"
#include "package_db.h"
-#include "package_version.h"
#include "dialog.h"
#include "resource.h"
/* For 'source' */
diff --git a/choose.cc b/choose.cc
index 1bc4c0b..abfc14a 100644
--- a/choose.cc
+++ b/choose.cc
@@ -48,7 +48,6 @@
#include "package_db.h"
#include "package_meta.h"
-#include "package_version.h"
#include "threebar.h"
#include "Generic.h"
diff --git a/desktop.cc b/desktop.cc
index 24908f8..927c02f 100644
--- a/desktop.cc
+++ b/desktop.cc
@@ -35,7 +35,6 @@
#include "mklink2.h"
#include "package_db.h"
#include "package_meta.h"
-#include "package_version.h"
#include "filemanip.h"
#include "io_stream.h"
#include "getopt++/BoolOption.h"
diff --git a/download.cc b/download.cc
index a2237a7..fda175f 100644
--- a/download.cc
+++ b/download.cc
@@ -38,7 +38,6 @@
#include "package_db.h"
#include "package_meta.h"
-#include "package_version.h"
#include "package_source.h"
#include "threebar.h"
diff --git a/package_db.cc b/package_db.cc
index 2d6d22c..ae71900 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -31,8 +31,6 @@
#include "compress.h"
#include "filemanip.h"
-
-#include "package_version.h"
#include "package_db.h"
#include "package_meta.h"
#include "Exception.h"
diff --git a/package_meta.cc b/package_meta.cc
index 3d1d666..ab358b9 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -35,10 +35,7 @@ using namespace std;
/* this goes at the same time */
#include "win32.h"
-
#include "script.h"
-
-#include "package_version.h"
#include "package_db.h"
#include <algorithm>
diff --git a/package_version.cc b/package_version.cc
deleted file mode 100644
index 2d4416e..0000000
--- a/package_version.cc
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (c) 2001, 2003 Robert Collins.
- *
- * 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/
- *
- * Written by Robert Collins <rbtcollins@hotmail.com>
- *
- */
-
-/* this is the parent class for all package operations.
- */
-
-#include "package_version.h"
-#include "package_db.h"
-#include "package_meta.h"
-#include "LogSingleton.h"
-#include "state.h"
-#include "resource.h"
-#include <algorithm>
-#include "csu_util/version_compare.h"
-
-using namespace std;
-
-/* a default class to avoid special casing empty packageversions */
-
-/* TODO place into the class header */
-class _defaultversion : public _packageversion
-{
-public:
- _defaultversion()
- {
- // never try to free me!
- ++references;
- }
- const std::string Name(){return std::string();}
- const std::string Vendor_version() {return std::string();}
- const std::string Package_version() {return std::string();}
- const std::string Canonical_version() {return std::string();}
- void setCanonicalVersion (const std::string& ) {}
- package_stability_t Stability (){return TRUST_UNKNOWN;}
- void SetStability (package_stability_t) {}
- package_type_t Type () {return package_binary;}
- const std::string SDesc () {return std::string();}
- void set_sdesc (const std::string& ) {}
- const std::string LDesc () {return std::string();}
- void set_ldesc (const std::string& ) {}
-};
-static _defaultversion defaultversion;
-
-/* the wrapper class */
-packageversion::packageversion() : data (&defaultversion)
-{
- ++data->references;
-}
-
-/* Create from an actual package */
-packageversion::packageversion (_packageversion *pkg)
-{
- if (pkg)
- data = pkg;
- else
- data = &defaultversion;
- ++data->references;
-}
-
-packageversion::packageversion (packageversion const &existing) :
-data(existing.data)
-{
- ++data->references;
-}
-
-packageversion::~packageversion()
-{
- if (--data->references == 0)
- delete data;
-}
-
-packageversion &
-packageversion::operator= (packageversion const &rhs)
-{
- ++rhs.data->references;
- if (--data->references == 0)
- delete data;
- data = rhs.data;
- return *this;
-}
-
-bool
-packageversion::operator ! () const
-{
- return !data->Name().size();
-}
-
-packageversion::operator bool () const
-{
- return data->Name().size();
-}
-
-bool
-packageversion::operator == (packageversion const &rhs) const
-{
- if (this == &rhs || data == rhs.data)
- return true;
- else
- return data->Name () == rhs.data->Name() && data->Canonical_version () == rhs.data->Canonical_version();
-}
-
-bool
-packageversion::operator != (packageversion const &rhs) const
-{
- return ! (*this == rhs);
-}
-
-bool
-packageversion::operator < (packageversion const &rhs) const
-{
- int t = casecompare(data->Name(), rhs.data->Name());
- if (t < 0)
- return true;
- else if (t > 0)
- return false;
- else if (casecompare (data->Canonical_version(), rhs.data->Canonical_version()) < 0)
- return true;
- return false;
-}
-
-const std::string
-packageversion::Name () const
-{
- return data->Name ();
-}
-
-const std::string
-packageversion::Vendor_version() const
-{
- return data->Vendor_version();
-}
-
-const std::string
-packageversion::Package_version() const
-{
- return data->Package_version();
-}
-
-const std::string
-packageversion::Canonical_version() const
-{
- return data->Canonical_version();
-}
-
-void
-packageversion::setCanonicalVersion (const std::string& ver)
-{
- data->setCanonicalVersion (ver);
-}
-
-package_stability_t
-packageversion::Stability () const
-{
- return data->Stability ();
-}
-
-void
-packageversion::SetStability (package_stability_t stability)
-{
- data->SetStability (stability);
-}
-
-package_type_t
-packageversion::Type () const
-{
- return data->Type ();
-}
-
-const std::string
-packageversion::SDesc () const
-{
- return data->SDesc ();
-}
-
-void
-packageversion::set_sdesc (const std::string& sdesc)
-{
- data->set_sdesc (sdesc);
-}
-
-const std::string
-packageversion::LDesc () const
-{
- return data->LDesc ();
-}
-
-void
-packageversion::set_ldesc (const std::string& ldesc)
-{
- data->set_ldesc (ldesc);
-}
-
-packageversion
-packageversion::sourcePackage() const
-{
- return data->sourcePackage();
-}
-
-PackageSpecification &
-packageversion::sourcePackageSpecification () const
-{
- return data->sourcePackageSpecification ();
-}
-
-void
-packageversion::setSourcePackageSpecification (PackageSpecification const &spec)
-{
- data->setSourcePackageSpecification(spec);
-}
-
-void
-packageversion::setDepends(const PackageDepends _depends)
-{
- data->depends = _depends;
-}
-
-const PackageDepends
-packageversion::depends() const
-{
- return data->depends;
-}
-
-packagesource *
-packageversion::source () const
-{
- return &data->source;
-}
-
-bool
-packageversion::accessible() const
-{
- return data->accessible();
-}
-
-
-int
-packageversion::compareVersions(const packageversion &a, const packageversion &b)
-{
- /* Compare Vendor_version */
- int comparison = version_compare(a.Vendor_version(), b.Vendor_version());
-
-#if DEBUG
- Log (LOG_BABBLE) << "vendor version comparison " << a.Vendor_version() << " and " << b.Vendor_version() << ", result was " << comparison << endLog;
-#endif
-
- if (comparison != 0)
- {
- return comparison;
- }
-
- /* Vendor_version are tied, compare Package_version */
-#if DEBUG
- Log (LOG_BABBLE) << "package version comparison " << a.Package_version() << " and " << b.Package_version() << ", result was " << comparison << endLog;
-#endif
-
- comparison = version_compare(a.Package_version(), b.Package_version());
- return comparison;
-}
-
-/* the parent data class */
-
-_packageversion::_packageversion ():picked (false), references (0)
-{
-}
-
-_packageversion::~_packageversion ()
-{
-}
-
-PackageSpecification &
-_packageversion::sourcePackageSpecification ()
-{
- return _sourcePackage;
-}
-
-void
-_packageversion::setSourcePackageSpecification (PackageSpecification const &spec)
-{
- _sourcePackage = spec;
-}
-
-packageversion
-_packageversion::sourcePackage ()
-{
- if (!sourceVersion)
- {
- packagedb db;
- packagemeta * pkg;
- pkg = db.findSource (_sourcePackage);
- /* no valid source meta available, just return the default
- (blank) package version
- */
- if (!pkg)
- return sourceVersion;
- set<packageversion>::iterator i=pkg->versions.begin();
- while (i != pkg->versions.end())
- {
- packageversion const & ver = * i;
- if (_sourcePackage.satisfies (ver))
- sourceVersion = ver;
- ++i;
- }
- }
- return sourceVersion;
-}
-
-// is archive accessible
-bool
-_packageversion::accessible() const
-{
- // cached ?
- if (source.Cached ())
- return true;
- // net access allowed?
- if (::source == IDC_SOURCE_LOCALDIR)
- return false;
- // retrievable ?
- if (source.sites.size() || source.Cached ())
- return true;
- // otherwise, not accessible
- return false;
-}
diff --git a/package_version.h b/package_version.h
deleted file mode 100644
index 21d053e..0000000
--- a/package_version.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2001, 2003 Robert Collins.
- *
- * 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/
- *
- * Written by Robert Collins <rbtcollins@hotmail.com>
- *
- */
-
-#ifndef SETUP_PACKAGE_VERSION_H
-#define SETUP_PACKAGE_VERSION_H
-
-/* This is a package version abstrct class, that should be able to
- * arbitrate acceess to cygwin binary packages, cygwin source package,
- * and the rpm and deb equivalents of the same.
- */
-
-/* standard binary package metadata:
- * Name (ie mutt
- * Vendor Version (ie 2.5.1)
- * Package Version (ie 16)
- * Stability
- * Files
- */
-
-/* For non installed files, this class can be populated via information about
- * what is available on the net, or by parsing a specific package file.
- * for installed packages, this class should represent what is currently installed,
- * - updated by what net metadata has about it.
- * i.e. the stability of this version will change simply because the net mirrors
- * now consider it old.
- */
-
-class CategoryList;
-
-/*Required for parsing */
-#include "package_source.h"
-#include "PackageSpecification.h"
-#include "PackageTrust.h"
-#include "package_depends.h"
-
-typedef trusts package_stability_t;
-
-typedef enum
-{
- package_binary,
- package_source
-}
-package_type_t;
-
-/* A wrapper class to be copied by value that
- references the same package.
- Nothing is virtual, because the wrapper cannot be inherited.
- However, as all the methods are implemented in the referenced
- _packageversion, that class allows virtual overriding.
- */
-
-class _packageversion;
-class packagemeta;
-
-/* This class has pointer semantics
- Specifically: a=b does not alter the value of *a.
- */
-class packageversion
-{
-public:
- packageversion (); /* creates an empty packageversion */
- packageversion (_packageversion *); /* used when creating an instance */
- packageversion (packageversion const &);
- ~packageversion ();
- packageversion &operator= (packageversion const &);
- bool operator ! () const; /* true if the package is invalid. (i.e.
- uninitialised */
- operator bool () const; /* returns ! !() */
- bool operator == (packageversion const &) const; /* equality */
- bool operator != (packageversion const &) const;
- bool operator < (packageversion const &) const;
- bool operator <= (packageversion const &) const;
- bool operator > (packageversion const &) const;
- bool operator >= (packageversion const &) const;
-
- const std::string Name () const;
- const std::string Vendor_version () const;
- const std::string Package_version () const;
- const std::string Canonical_version () const;
- void setCanonicalVersion (const std::string& );
- package_stability_t Stability () const;
- void SetStability (package_stability_t);
- package_type_t Type () const;
- const std::string SDesc () const;
- void set_sdesc (const std::string& );
- const std::string LDesc () const;
- void set_ldesc (const std::string& );
- packageversion sourcePackage () const;
- PackageSpecification & sourcePackageSpecification () const;
- void setSourcePackageSpecification (PackageSpecification const &);
-
- void setDepends(const PackageDepends);
- const PackageDepends depends() const;
-
- /* invariant: never null */
- packagesource *source() const; /* where can we source the file from */
-
- bool accessible () const;
-
- /* ensure that the depends clause is satisfied */
- int set_requirements (trusts deftrust, size_t depth = 0);
-
- /* utility function to compare package versions */
- static int compareVersions(const packageversion &a, const packageversion &b);
-
-private:
- _packageversion *data; /* Invariant: * data is always valid */
-};
-
-class _packageversion
-{
-public:
- _packageversion();
- virtual ~_packageversion();
- /* for list inserts/mgmt. */
- std::string key;
- /* name is needed here, because if we are querying a file, the data may be embedded in
- the file */
- virtual const std::string Name () = 0;
- virtual const std::string Vendor_version () = 0;
- virtual const std::string Package_version () = 0;
- virtual const std::string Canonical_version () = 0;
- virtual void setCanonicalVersion (const std::string& ) = 0;
- virtual package_stability_t Stability () = 0;
- virtual void SetStability (package_stability_t) = 0;
- virtual package_type_t Type () = 0;
- virtual const std::string SDesc () = 0;
- virtual void set_sdesc (const std::string& ) = 0;
- virtual const std::string LDesc () = 0;
- virtual void set_ldesc (const std::string& ) = 0;
- /* only semantically meaningful for binary packages */
- /* direct link to the source package for this binary */
- /* if multiple versions exist and the source doesn't discriminate
- then the most recent is used
- */
- virtual packageversion sourcePackage ();
- virtual PackageSpecification & sourcePackageSpecification ();
- virtual void setSourcePackageSpecification (PackageSpecification const &);
-
- PackageDepends depends;
-
- packagesource source; /* where can we source the file from */
-
- virtual bool accessible () const;
-
- /* TODO: Implement me:
- static package_meta * scan_package (io_stream *);
- */
- size_t references;
-protected:
- /* only meaningful for binary packages */
- PackageSpecification _sourcePackage;
- packageversion sourceVersion;
-};
-
-#endif /* SETUP_PACKAGE_VERSION_H */
--
2.12.3