CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FileInPath.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_FileInPath_h
2 #define FWCore_Utilities_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 Utilities 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 #include <iosfwd>
58 #include <string>
59 
60 namespace edm {
61  class FileInPath {
62  public:
63  enum LocationCode { Unknown = 0, Local = 1, Release = 2, Data = 3 };
64 
67  FileInPath();
68 
70  explicit FileInPath(const std::string& r);
71  explicit FileInPath(const char* r);
72 
73  FileInPath(FileInPath const& other);
74  FileInPath& operator=(FileInPath const& other);
75  ~FileInPath();
76  void swap(FileInPath& other);
77 
81  std::string relativePath() const;
82 
84  LocationCode location() const;
85 
94  std::string fullPath() const;
95 
98  void write(std::ostream& os) const;
99 
102  void read(std::istream& is);
103 
104  void readFromParameterSetBlob(std::istream& is);
105 
107  static void disableFileLookup();
108 
109  private:
117 
118  // Helper function for construction.
119  void getEnvironment();
120  void initialize_();
121  };
122 
123  // Free swap function
124  inline void swap(FileInPath& a, FileInPath& b) { a.swap(b); }
125 
126  inline std::ostream& operator<<(std::ostream& os, const edm::FileInPath& fip) {
127  fip.write(os);
128  return os;
129  }
130 
131  inline std::istream& operator>>(std::istream& is, FileInPath& fip) {
132  fip.read(is);
133  return is;
134  }
135 
136  inline bool operator==(edm::FileInPath const& a, edm::FileInPath const& b) {
137  return a.location() == b.location() && a.relativePath() == b.relativePath();
138  }
139 
140 } // namespace edm
141 
142 #endif
std::string canonicalFilename_
Definition: FileInPath.h:111
constexpr bool operator==(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
void write(std::ostream &os) const
Definition: FileInPath.cc:163
void swap(FileInPath &other)
Definition: FileInPath.cc:147
static void disableFileLookup()
Should only be called while the edmWriteConfigs executable runs.
Definition: FileInPath.cc:437
std::string dataTop_
Definition: FileInPath.h:115
std::unique_ptr< ParameterDescriptionCases< bool > > operator>>(bool caseValue, ParameterDescriptionNode const &node)
void getEnvironment()
Definition: FileInPath.cc:331
std::string searchPath_
Definition: FileInPath.h:116
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
std::string releaseTop_
Definition: FileInPath.h:114
LocationCode location_
Definition: FileInPath.h:112
void read(std::istream &is)
Definition: FileInPath.cc:202
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:159
void initialize_()
Definition: FileInPath.cc:362
double b
Definition: hdecay.h:118
std::string relativePath_
Definition: FileInPath.h:110
double a
Definition: hdecay.h:119
FileInPath & operator=(FileInPath const &other)
Definition: FileInPath.cc:141
std::string fullPath() const
Definition: FileInPath.cc:161
void readFromParameterSetBlob(std::istream &is)
Definition: FileInPath.cc:273
std::string relativePath() const
Definition: FileInPath.cc:157
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
std::string localTop_
Definition: FileInPath.h:113