From f105aaba433f5a8b9c4326dd0d704501bf07d1e5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 Nov 2014 12:53:59 +0100 Subject: better non-virtual metaIndex.LocalFileName() implementation We can't add a new virtual method without breaking the ABI, but we can freely add new methods, so for older ABIs we just implement this method with a dynamic_cast, so that clients can be more ignorant about the API here and especially don't need to pull a very dirty trick by assuming internal knowledge (like apt-get did here). --- apt-pkg/metaindex.h | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'apt-pkg/metaindex.h') diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h index ae73c27dd..6c3d2880b 100644 --- a/apt-pkg/metaindex.h +++ b/apt-pkg/metaindex.h @@ -41,8 +41,8 @@ class metaIndex // interface to to query it #if APT_PKG_ABI >= 413 - // returns the path of the local file (or "" if its not available) - virtual std::string LocalFileName() const {return "";}; + /** \return the path of the local file (or "" if its not available) */ + virtual std::string LocalFileName() const; #else std::string LocalFileName() const; #endif @@ -50,25 +50,12 @@ class metaIndex // Interface for acquire virtual std::string ArchiveURI(std::string const& File) const = 0; virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const = 0; - virtual std::vector *GetIndexFiles() = 0; + virtual std::vector *GetIndexFiles() = 0; virtual bool IsTrusted() const = 0; - metaIndex(std::string const &URI, std::string const &Dist, - char const * const Type) - : Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(false) - { - /* nothing */ - } - - virtual ~metaIndex() - { - if (Indexes == 0) - return; - for (std::vector::iterator I = (*Indexes).begin(); - I != (*Indexes).end(); ++I) - delete *I; - delete Indexes; - } + metaIndex(std::string const &URI, std::string const &Dist, + char const * const Type); + virtual ~metaIndex(); }; #endif -- cgit v1.2.3