Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

mdfsdb.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           mdfsdb.h  -  description
00003                              -------------------
00004     begin                : Fri Jan 2 2004
00005     copyright            : (C) 2004 by Mickael Faivre-Macon
00006     email                : mickael@easyplay.com.tw
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef MDFSDBH
00019 #define MDFSDBH
00020 
00021 #include "mdfsdbbase.h"
00022 //#include "db.h"
00023 
00024 namespace mdfs {
00025 
00026 typedef std::vector<std::string> MStringList;
00027 
00028 //---------------------------------------------------------------------------
00035 class MDFSDB : public MDFSDBBase {
00036 
00037 public:
00038 
00039    enum MOptions {DEFAULT=0, URL, LOCAL};
00040    class MEntry {
00041    public:
00042       MEntry() : Updated(false) {}
00043       MFile File;
00044       bool Updated;
00045       };
00046 
00047    MDFSDB();
00048    ~MDFSDB();
00049 
00054    virtual bool UpdateFile(const MFile& f, int options=0);
00055 
00057    void AddFile(const MFile& f);
00058 
00059    virtual bool GetFile(MFile& f, int options=0); 
00060    bool GetEntry(const MFile& f, MEntry*& e, int options=0);
00061    virtual void GetList(MQuery& q, MFileList& list); 
00062    void GetDirContent(MQuery& q, MFileList& list); 
00063 
00067    int RemoveLocalOrphan(MStringList* shares = NULL);
00070    int RemoveRemoteFiles();
00071 
00072 private:
00073    boost::mutex Mutex;
00074    typedef std::list<MEntry*> MMemDB;
00075    MMemDB DB;
00076 
00077    int  Unmarshall(MFile& f, const unsigned char *p, int maxsize);
00078    int  Marshall(const MFile& f,  unsigned char *p, int maxsize);
00079    void Load();
00080    void Save();
00081 
00082    };
00083    
00084 //---------------------------------------------------------------------------
00085 
00086 } // namespace
00087 
00088 #endif



MDFS SourceForge project page and download

SourceForge.net Logo

Generated on Sat Jan 3 03:14:20 2004 for MDFS by doxygen1.3.5