WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
FileLocation.h
1 
10 #ifndef WRENCH_FILELOCATION_H
11 #define WRENCH_FILELOCATION_H
12 
13 #include <memory>
14 #include <iostream>
15 
16 
17 namespace wrench {
18 
19  /***********************/
21  /***********************/
22 
23 
24  class StorageService;
25 
29  class FileLocation {
30 
31  public:
32 
33  ~FileLocation();
34 
38  static std::shared_ptr<FileLocation> SCRATCH;
39 
40  static std::shared_ptr<FileLocation> LOCATION(std::shared_ptr<StorageService> ss);
41 
42  static std::shared_ptr<FileLocation> LOCATION(std::shared_ptr<StorageService> ss,
43  std::shared_ptr<StorageService> server_ss);
44 
45  static std::shared_ptr<FileLocation> LOCATION(std::shared_ptr<StorageService> ss,
46  std::string absolute_path);
47 
48  std::shared_ptr<StorageService> getStorageService();
49  std::shared_ptr<StorageService> getServerStorageService();
50  std::string getMountPoint();
51  std::string getAbsolutePathAtMountPoint();
52  std::string getFullAbsolutePath();
53 
54  std::string toString();
55 
65  static bool equal(const std::shared_ptr<FileLocation> &lhs,
66  const std::shared_ptr<FileLocation> &rhs) {
67  return ((lhs->getStorageService() == rhs->getStorageService()) and
68  (lhs->getFullAbsolutePath() == rhs->getFullAbsolutePath()));
69  }
70 
71 
72  static std::string sanitizePath(std::string path);
73  static bool properPathPrefix(std::string path1, std::string path2);
74 
75  private:
76 
77  friend class LogicalFileSystem;
78 
84  FileLocation(std::shared_ptr<StorageService> ss, std::string mp, std::string apamp) :
85  storage_service(ss), mount_point(mp), absolute_path_at_mount_point(apamp) { }
86 
87  std::shared_ptr<StorageService> storage_service;
88  std::shared_ptr<StorageService> server_storage_service;
89  std::string mount_point;
90  std::string absolute_path_at_mount_point;
91 
92 
93  };
94 
95  /***********************/
97  /***********************/
98 
99 
100 }
101 
102 
103 #endif //WRENCH_FILELOCATION_H
wrench::FileLocation::getFullAbsolutePath
std::string getFullAbsolutePath()
Get the location's full absolute path.
Definition: FileLocation.cpp:176
wrench::FileLocation::getServerStorageService
std::shared_ptr< StorageService > getServerStorageService()
Get the location's server storage service.
Definition: FileLocation.cpp:146
wrench::FileLocation::SCRATCH
static std::shared_ptr< FileLocation > SCRATCH
Static location that denotes a compute service's scratch space.
Definition: FileLocation.h:38
wrench::FileLocation::LOCATION
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:39
wrench
Definition: Action.cpp:28
wrench::FileLocation::sanitizePath
static std::string sanitizePath(std::string path)
Method to sanitize an absolute path (and make it absolute if it's not)
Definition: FileLocation.cpp:189
wrench::FileLocation::getStorageService
std::shared_ptr< StorageService > getStorageService()
Get the location's storage service.
Definition: FileLocation.cpp:135
wrench::FileLocation::getAbsolutePathAtMountPoint
std::string getAbsolutePathAtMountPoint()
Get the location's path at mount point.
Definition: FileLocation.cpp:165
wrench::FileLocation::properPathPrefix
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:258
wrench::FileLocation::equal
static bool equal(const std::shared_ptr< FileLocation > &lhs, const std::shared_ptr< FileLocation > &rhs)
Method to compare two file locations.
Definition: FileLocation.h:65
wrench::FileLocation
A class that encodes a file location.
Definition: FileLocation.h:29
wrench::LogicalFileSystem
A class that implements a weak file system abstraction.
Definition: LogicalFileSystem.h:34
wrench::FileLocation::getMountPoint
std::string getMountPoint()
Get the location's mount point.
Definition: FileLocation.cpp:154
wrench::FileLocation::toString
std::string toString()
Give a <ss1 name>:<mount point>:<dir>" string for the location.
Definition: FileLocation.cpp:122