* apt-pkg/policy.cc:
[ntk/apt.git] / apt-pkg / pkgcachegen.h
index a88c494..ff19883 100644 (file)
@@ -23,6 +23,8 @@
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/md5.h>
 
+#include <vector>
+
 class pkgSourceList;
 class OpProgress;
 class MMap;
@@ -33,18 +35,30 @@ class pkgCacheGenerator                                                     /*{{{*/
    private:
 
    pkgCache::StringItem *UniqHash[26];
-   unsigned long WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); };
-   unsigned long WriteStringInMap(const char *String);
-   unsigned long WriteStringInMap(const char *String, const unsigned long &Len);
-   unsigned long AllocateInMap(const unsigned long &size);
+   map_ptrloc WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); };
+   map_ptrloc WriteStringInMap(const char *String);
+   map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len);
+   map_ptrloc AllocateInMap(const unsigned long &size);
 
    public:
    
    class ListParser;
    friend class ListParser;
-   
+
+   template<typename Iter> class Dynamic {
+      public:
+      static std::vector<Iter*> toReMap;
+      Dynamic(Iter &I) {
+        toReMap.push_back(&I);
+      }
+
+      ~Dynamic() {
+        toReMap.pop_back();
+      }
+   };
+
    protected:
-   
+
    DynamicMMap &Map;
    pkgCache Cache;
    OpProgress *Progress;
@@ -85,6 +99,9 @@ class pkgCacheGenerator                                                       /*{{{*/
    static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
                        MMap **OutMap = 0,bool AllowMem = false);
    static bool MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap);
+   static DynamicMMap* CreateDynamicMMap(FileFd *CacheF, unsigned long Flags = 0);
+
+   void ReMap(void const * const oldMap, void const * const newMap);
 
    pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
    ~pkgCacheGenerator();
@@ -109,10 +126,10 @@ class pkgCacheGenerator::ListParser
    inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
    inline unsigned long WriteString(const string &S) {return Owner->WriteStringInMap(S);};
    inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->WriteStringInMap(S,Size);};
-   bool NewDepends(pkgCache::VerIterator Ver,const string &Package, const string &Arch,
+   bool NewDepends(pkgCache::VerIterator &Ver,const string &Package, const string &Arch,
                   const string &Version,unsigned int Op,
                   unsigned int Type);
-   bool NewProvides(pkgCache::VerIterator Ver,const string &PkgName,
+   bool NewProvides(pkgCache::VerIterator &Ver,const string &PkgName,
                    const string &PkgArch, const string &Version);
    
    public:
@@ -122,13 +139,13 @@ class pkgCacheGenerator::ListParser
    virtual string Architecture() = 0;
    virtual bool ArchitectureAll() = 0;
    virtual string Version() = 0;
-   virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
+   virtual bool NewVersion(pkgCache::VerIterator &Ver) = 0;
    virtual string Description() = 0;
    virtual string DescriptionLanguage() = 0;
    virtual MD5SumValue Description_md5() = 0;
    virtual unsigned short VersionHash() = 0;
-   virtual bool UsePackage(pkgCache::PkgIterator Pkg,
-                          pkgCache::VerIterator Ver) = 0;
+   virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
+                          pkgCache::VerIterator &Ver) = 0;
    virtual unsigned long Offset() = 0;
    virtual unsigned long Size() = 0;
    
@@ -136,7 +153,7 @@ class pkgCacheGenerator::ListParser
    
    inline bool HasFileDeps() {return FoundFileDeps;};
    virtual bool CollectFileProvides(pkgCache &Cache,
-                                   pkgCache::VerIterator Ver) {return true;};
+                                   pkgCache::VerIterator &Ver) {return true;};
 
    ListParser() : FoundFileDeps(false) {};
    virtual ~ListParser() {};