FileLocation.h
1 
10 #ifndef WRENCH_FILELOCATION_H
11 #define WRENCH_FILELOCATION_H
12 
13 #include <memory>
14 
15 
16 namespace wrench {
17 
18  /***********************/
20  /***********************/
21 
22 
23  class StorageService;
24 
28  class FileLocation {
29 
30  public:
31 
35  static std::shared_ptr<FileLocation> SCRATCH;
36 
37  static std::shared_ptr<FileLocation> LOCATION(std::shared_ptr<StorageService> ss);
38 
39  static std::shared_ptr<FileLocation> LOCATION(std::shared_ptr<StorageService> ss,
40  std::string absolute_path);
41 
42  std::shared_ptr<StorageService> getStorageService();
43  std::string getMountPoint();
44  std::string getAbsolutePathAtMountPoint();
45  std::string getFullAbsolutePath();
46 
47  std::string toString();
48 
58  static bool equal(const std::shared_ptr<FileLocation> &lhs,
59  const std::shared_ptr<FileLocation> &rhs) {
60  return ((lhs->getStorageService() == rhs->getStorageService()) and
61  (lhs->getFullAbsolutePath() == rhs->getFullAbsolutePath()));
62  }
63 
64 
65  static std::string sanitizePath(std::string path);
66  static bool properPathPrefix(std::string path1, std::string path2);
67 
68  private:
69 
70  friend class LogicalFileSystem;
71 
77  FileLocation(std::shared_ptr<StorageService> ss, std::string mp, std::string apamp) :
78  storage_service(ss), mount_point(mp), absolute_path_at_mount_point(apamp) { }
79 
80  std::shared_ptr<StorageService> storage_service;
81  std::string mount_point;
82  std::string absolute_path_at_mount_point;
83 
84 
85  };
86 
87  /***********************/
89  /***********************/
90 
91 
92 }
93 
94 
95 #endif //WRENCH_FILELOCATION_H
std::string getFullAbsolutePath()
Get the location's full absolute path.
Definition: FileLocation.cpp:138
static std::shared_ptr< FileLocation > SCRATCH
Static location that denotes a compute service's scratch space.
Definition: FileLocation.h:35
static std::shared_ptr< FileLocation > LOCATION(std::shared_ptr< StorageService > ss)
File location specifier for a storage service's (single) mount point root.
Definition: FileLocation.cpp:32
Definition: Alarm.cpp:20
static std::string sanitizePath(std::string path)
Method to sanitize an absolute path (and make it absolute if it's not)
Definition: FileLocation.cpp:151
std::shared_ptr< StorageService > getStorageService()
Get the location's storage service.
Definition: FileLocation.cpp:105
std::string getAbsolutePathAtMountPoint()
Get the location's path at mount point.
Definition: FileLocation.cpp:127
static bool properPathPrefix(std::string path1, std::string path2)
Helper method to find if a path is a proper prefix of another path.
Definition: FileLocation.cpp:208
static bool equal(const std::shared_ptr< FileLocation > &lhs, const std::shared_ptr< FileLocation > &rhs)
Method to compare two file locations.
Definition: FileLocation.h:58
A class that encodes a file location.
Definition: FileLocation.h:28
std::string getMountPoint()
Get the location's mount point.
Definition: FileLocation.cpp:116
std::string toString()
Give a <ss name>:<mount point>:<dir>" string for the location.
Definition: FileLocation.cpp:92