dmlite  0.4
Catalog.h
Go to the documentation of this file.
1 /// @file core/builtin/Catalog.h
2 /// @brief Implementation of a Catalog using other plugins, as INode.
3 /// @details Intended to ease the development of database backends.
4 /// @author Alejandro Álvarez Ayllon <aalvarez@cern.ch>
5 #ifndef BUILTIN_CATALOG_H
6 #define BUILTIN_CATALOG_H
7 
8 #include <dmlite/cpp/catalog.h>
9 #include <dmlite/cpp/inode.h>
10 #include <dmlite/cpp/poolmanager.h>
11 #include <dmlite/cpp/pooldriver.h>
12 
13 namespace dmlite {
14 
15  struct BuiltInDir: public Directory {
16  virtual ~BuiltInDir() {};
19  };
20 
21  class BuiltInCatalog: public Catalog {
22  public:
23  BuiltInCatalog(bool updateATime, unsigned symLinkLimit) throw (DmException);
25 
26  std::string getImplId(void) const throw();
27 
28  void setStackInstance(StackInstance* si) throw (DmException);
29 
30  void setSecurityContext(const SecurityContext*) throw (DmException);
31 
32  void changeDir (const std::string&) throw (DmException);
33  std::string getWorkingDir (void) throw (DmException);
34 
35  ExtendedStat extendedStat(const std::string& path,
36  bool followSym = true) throw (DmException);
37 
38  void addReplica (const Replica& replica) throw (DmException);
39  void deleteReplica(const Replica& replica) throw (DmException);
40 
41  std::vector<Replica> getReplicas(const std::string& path) throw (DmException);
42  Location get(const std::string& path) throw (DmException);
43 
44  Location put(const std::string& path) throw (DmException);
45  void putDone(const std::string& host, const std::string& rfn,
46  const std::map<std::string, std::string>& params) throw (DmException);
47 
48  void symlink(const std::string& oldpath,
49  const std::string& newpath) throw (DmException);
50  std::string readLink(const std::string& path) throw (DmException);
51 
52  void unlink(const std::string& path) throw (DmException);
53 
54  void create(const std::string& path, mode_t mode) throw (DmException);
55 
56  void makeDir (const std::string& path, mode_t mode) throw (DmException);
57  void removeDir(const std::string& path) throw (DmException);
58 
59  void rename(const std::string& oldPath,
60  const std::string& newPath) throw (DmException);
61 
62  mode_t umask(mode_t mask) throw ();
63 
64  void setMode (const std::string& path, mode_t mode) throw (DmException);
65  void setOwner (const std::string& path, uid_t newUid, gid_t newGid,
66  bool followSymLink = true) throw (DmException);
67 
68  void setSize (const std::string& path, size_t newSize) throw (DmException);
69  void setChecksum(const std::string& path, const std::string& csumtype,
70  const std::string& csumvalue) throw (DmException);
71 
72  void setAcl(const std::string& path, const Acl& acls) throw (DmException);
73 
74  void utime(const std::string& path, const struct utimbuf* buf) throw (DmException);
75 
76  std::string getComment(const std::string& path) throw (DmException);
77  void setComment(const std::string& path,
78  const std::string& comment) throw (DmException);
79 
80  void setGuid(const std::string& path,
81  const std::string &guid) throw (DmException);
82 
83  void updateExtendedAttributes(const std::string& path,
84  const Extensible& attr) throw (DmException);
85 
86  Directory* openDir (const std::string& path) throw (DmException);
87  void closeDir(Directory* dir) throw (DmException);
88  struct dirent* readDir (Directory* dir) throw (DmException);
90 
91  Replica getReplica(const std::string& rfn) throw (DmException);
92  void updateReplica(const Replica& replica) throw (DmException);
93 
94  protected:
95  /// Get the parent of a directory.
96  /// @param path The path to split.
97  /// @param parentPath Where to put the parent path.
98  /// @param name Where to put the file name (stripping last /).
99  /// @return The parent metadata.
100  ExtendedStat getParent(const std::string& path, std::string* parentPath,
101  std::string* name) throw (DmException);
102 
103  /// Update access time (if updateATime is true)
104  void updateAccessTime(const ExtendedStat& meta) throw (DmException);
105 
106  /// Traverse backwards to check permissions.
107  /// @param meta The file at the end
108  /// @note Throws an exception if it is not possible.
109  void traverseBackwards(const ExtendedStat& meta) throw (DmException);
110 
111  private:
113 
115 
116  std::string cwdPath_;
117  ino_t cwd_;
118 
119  mode_t umask_;
121  unsigned symLinkLimit_;
122  };
123 
124  /// Plug-ins must implement a concrete factory to be instantiated.
126  public:
129 
130  void configure(const std::string&, const std::string&) throw (DmException);
131 
133 
134  private:
136  unsigned symLinkLimit_;
137  };
138 
139 };
140 
141 #endif // BUILTIN_CATALOG_H