Catalog.h

Go to the documentation of this file.
00001 /// @file    core/builtin/Catalog.h
00002 /// @brief   Implementation of a Catalog using other plugins, as INode.
00003 /// @details Intended to ease the development of database backends.
00004 /// @author  Alejandro Álvarez Ayllon <aalvarez@cern.ch>
00005 #ifndef BUILTIN_CATALOG_H
00006 #define BUILTIN_CATALOG_H
00007 
00008 #include <dmlite/cpp/catalog.h>
00009 #include <dmlite/cpp/inode.h>
00010 #include <dmlite/cpp/poolmanager.h>
00011 #include <dmlite/cpp/pooldriver.h>
00012 
00013 namespace dmlite {
00014   
00015   struct BuiltInDir: public Directory {
00016     virtual ~BuiltInDir() {};
00017     IDirectory*  idir;
00018     ExtendedStat dir;
00019   };
00020 
00021   class BuiltInCatalog: public Catalog {
00022    public:
00023     BuiltInCatalog(bool updateATime, unsigned symLinkLimit) throw (DmException);
00024     ~BuiltInCatalog();
00025 
00026     std::string getImplId(void) const throw();
00027 
00028     void setStackInstance(StackInstance* si) throw (DmException);
00029 
00030     void setSecurityContext(const SecurityContext*) throw (DmException);  
00031 
00032     void        changeDir     (const std::string&) throw (DmException);
00033     std::string getWorkingDir (void) throw (DmException);
00034 
00035     ExtendedStat extendedStat(const std::string& path,
00036                               bool followSym = true) throw (DmException);
00037 
00038     void addReplica   (const Replica& replica) throw (DmException);
00039     void deleteReplica(const Replica& replica) throw (DmException);
00040 
00041     std::vector<Replica> getReplicas(const std::string& path) throw (DmException);
00042     Location get(const std::string& path) throw (DmException);
00043 
00044     Location put(const std::string& path) throw (DmException);
00045     void     putDone(const std::string& host, const std::string& rfn,
00046                     const std::map<std::string, std::string>& params) throw (DmException);
00047 
00048     void symlink(const std::string& oldpath,
00049                  const std::string& newpath) throw (DmException);
00050     std::string readLink(const std::string& path) throw (DmException);
00051 
00052     void unlink(const std::string& path) throw (DmException);
00053 
00054     void create(const std::string& path, mode_t mode) throw (DmException);
00055 
00056     void makeDir  (const std::string& path, mode_t mode) throw (DmException);
00057     void removeDir(const std::string& path) throw (DmException);
00058 
00059     void rename(const std::string& oldPath,
00060                 const std::string& newPath) throw (DmException);
00061 
00062     mode_t umask(mode_t mask) throw ();
00063 
00064     void setMode     (const std::string& path, mode_t mode) throw (DmException);
00065     void setOwner    (const std::string& path, uid_t newUid, gid_t newGid,
00066                       bool followSymLink = true) throw (DmException);
00067 
00068     void setSize    (const std::string& path, size_t newSize) throw (DmException);
00069     void setChecksum(const std::string& path, const std::string& csumtype,
00070                      const std::string& csumvalue) throw (DmException);
00071 
00072     void setAcl(const std::string& path, const Acl& acls) throw (DmException);
00073 
00074     void utime(const std::string& path, const struct utimbuf* buf) throw (DmException);
00075 
00076     std::string getComment(const std::string& path) throw (DmException);
00077     void        setComment(const std::string& path,
00078                            const std::string& comment) throw (DmException);
00079 
00080     void setGuid(const std::string& path,
00081                  const std::string &guid) throw (DmException);
00082 
00083     void updateExtendedAttributes(const std::string& path,
00084                                   const Extensible& attr) throw (DmException);
00085 
00086     Directory*     openDir (const std::string& path) throw (DmException);
00087     void           closeDir(Directory* dir) throw (DmException);
00088     struct dirent* readDir (Directory* dir) throw (DmException);
00089     ExtendedStat*  readDirx(Directory* dir) throw (DmException);
00090 
00091     Replica getReplica(const std::string& rfn)        throw (DmException);
00092     void    updateReplica(const Replica& replica) throw (DmException);
00093 
00094    protected:
00095     /// Get the parent of a directory.
00096     /// @param path       The path to split.
00097     /// @param parentPath Where to put the parent path.
00098     /// @param name       Where to put the file name (stripping last /).
00099     /// @return           The parent metadata.
00100     ExtendedStat getParent(const std::string& path, std::string* parentPath,
00101                           std::string* name) throw (DmException);
00102 
00103     /// Update access time (if updateATime is true)
00104     void updateAccessTime(const ExtendedStat& meta) throw (DmException);
00105 
00106     /// Traverse backwards to check permissions.
00107     /// @param meta The file at the end
00108     /// @note       Throws an exception if it is not possible.
00109     void traverseBackwards(const ExtendedStat& meta) throw (DmException);
00110 
00111    private:
00112     StackInstance*   si_;
00113 
00114     const SecurityContext* secCtx_;
00115 
00116     std::string cwdPath_;
00117     ino_t       cwd_;
00118 
00119     mode_t   umask_;
00120     bool     updateATime_;
00121     unsigned symLinkLimit_;
00122   };
00123 
00124   /// Plug-ins must implement a concrete factory to be instantiated.
00125   class BuiltInCatalogFactory: public CatalogFactory {
00126    public:
00127     BuiltInCatalogFactory();
00128     ~BuiltInCatalogFactory();
00129 
00130     void configure(const std::string&, const std::string&) throw (DmException);
00131 
00132     Catalog* createCatalog(PluginManager*) throw (DmException);
00133 
00134    private:
00135     bool     updateATime_;
00136     unsigned symLinkLimit_;
00137   };
00138   
00139 };
00140 
00141 #endif  // BUILTIN_CATALOG_H

Generated on 3 Mar 2013 for dmlite by  doxygen 1.4.7