CMS 3D CMS Logo

FileInPath.h
Go to the documentation of this file.
1 #ifndef FWCore_ParameterSet_FileInPath_h
2 #define FWCore_ParameterSet_FileInPath_h
3 
5 
7 
45 
46 // Notes:
47 //
48 // 1. We do not deal well with paths that contain spaces; this is because
49 // of the way the ParameterSet system's 'encode' and 'decode' functions
50 // are implemented for FileInPath objects. This could be fixed, if it
51 // is important to handle filenames or paths with embedded spaces.
52 //
53 // 2. All environment variables are read only once, when the FileInPath object is constructed.
54 // Therefore, any changes made to these variables externally during the lifetime of
55 // a FileInPath object will have no effect.
56 
57 // TODO: Find the correct package for this class to reside. It
58 // doesn't seem well-suited for ParameterSet.
59 
60 #include <iosfwd>
61 #include <string>
62 
63 namespace edm {
64  class FileInPath {
65  public:
66  enum LocationCode { Unknown = 0, Local = 1, Release = 2, Data = 3 };
67 
70  FileInPath();
71 
73  explicit FileInPath(const std::string& r);
74  explicit FileInPath(const char* r);
75 
76  FileInPath(FileInPath const& other);
77  FileInPath& operator=(FileInPath const& other);
78  ~FileInPath();
79  void swap(FileInPath& other);
80 
84  std::string relativePath() const;
85 
87  LocationCode location() const;
88 
97  std::string fullPath() const;
98 
101  void write(std::ostream& os) const;
102 
105  void read(std::istream& is);
106 
107  void readFromParameterSetBlob(std::istream& is);
108 
110  static void disableFileLookup();
111 
112  private:
120 
121  // Helper function for construction.
122  void getEnvironment();
123  void initialize_();
124  };
125 
126  // Free swap function
127  inline void swap(FileInPath& a, FileInPath& b) { a.swap(b); }
128 
129  inline std::ostream& operator<<(std::ostream& os, const edm::FileInPath& fip) {
130  fip.write(os);
131  return os;
132  }
133 
134  inline std::istream& operator>>(std::istream& is, FileInPath& fip) {
135  fip.read(is);
136  return is;
137  }
138 
139  inline bool operator==(edm::FileInPath const& a, edm::FileInPath const& b) {
140  return a.location() == b.location() && a.relativePath() == b.relativePath();
141  }
142 
143 } // namespace edm
144 
145 #endif
std::string canonicalFilename_
Definition: FileInPath.h:114
void write(std::ostream &os) const
Definition: FileInPath.cc:165
void swap(FileInPath &other)
Definition: FileInPath.cc:149
static void disableFileLookup()
Should only be called while the edmWriteConfigs executable runs.
Definition: FileInPath.cc:436
std::string dataTop_
Definition: FileInPath.h:118
std::istream & operator>>(std::istream &is, FileInPath &fip)
Definition: FileInPath.h:134
void getEnvironment()
Definition: FileInPath.cc:333
std::string searchPath_
Definition: FileInPath.h:119
std::string releaseTop_
Definition: FileInPath.h:117
LocationCode location_
Definition: FileInPath.h:115
void read(std::istream &is)
Definition: FileInPath.cc:204
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:161
void initialize_()
Definition: FileInPath.cc:364
double b
Definition: hdecay.h:120
std::string relativePath_
Definition: FileInPath.h:113
HLT enums.
double a
Definition: hdecay.h:121
FileInPath & operator=(FileInPath const &other)
Definition: FileInPath.cc:143
std::string fullPath() const
Definition: FileInPath.cc:163
void readFromParameterSetBlob(std::istream &is)
Definition: FileInPath.cc:275
std::string relativePath() const
Definition: FileInPath.cc:159
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
std::string localTop_
Definition: FileInPath.h:116