CMS 3D CMS Logo

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);
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
edm::FileInPath::swap
void swap(FileInPath &other)
Definition: FileInPath.cc:147
edm::FileInPath::readFromParameterSetBlob
void readFromParameterSetBlob(std::istream &is)
Definition: FileInPath.cc:273
edm::FileInPath::dataTop_
std::string dataTop_
Definition: FileInPath.h:115
edm::FileInPath::canonicalFilename_
std::string canonicalFilename_
Definition: FileInPath.h:111
edm::FileInPath::getEnvironment
void getEnvironment()
Definition: FileInPath.cc:331
edm::FileInPath::Release
Definition: FileInPath.h:63
edm::FileInPath::localTop_
std::string localTop_
Definition: FileInPath.h:113
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::swap
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
edm::FileInPath::location_
LocationCode location_
Definition: FileInPath.h:112
edm::FileInPath::Local
Definition: FileInPath.h:63
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
edm::FileInPath::disableFileLookup
static void disableFileLookup()
Should only be called while the edmWriteConfigs executable runs.
Definition: FileInPath.cc:437
edm::FileInPath
Definition: FileInPath.h:61
edm::operator==
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
Definition: debugging_allocator.h:72
edm::FileInPath::releaseTop_
std::string releaseTop_
Definition: FileInPath.h:114
edm::FileInPath::searchPath_
std::string searchPath_
Definition: FileInPath.h:116
trackingPlots.other
other
Definition: trackingPlots.py:1464
b
double b
Definition: hdecay.h:118
edm::FileInPath::location
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:159
edm::FileInPath::read
void read(std::istream &is)
Definition: FileInPath.cc:202
a
double a
Definition: hdecay.h:119
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::FileInPath::Data
Definition: FileInPath.h:63
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::FileInPath::LocationCode
LocationCode
Definition: FileInPath.h:63
edm::FileInPath::initialize_
void initialize_()
Definition: FileInPath.cc:362
edm::FileInPath::Unknown
Definition: FileInPath.h:63
edm::FileInPath::operator=
FileInPath & operator=(FileInPath const &other)
Definition: FileInPath.cc:141
edm::FileInPath::relativePath_
std::string relativePath_
Definition: FileInPath.h:110
edm::FileInPath::write
void write(std::ostream &os) const
Definition: FileInPath.cc:163
edm::operator>>
std::unique_ptr< ParameterDescriptionCases< bool > > operator>>(bool caseValue, ParameterDescriptionNode const &node)
Definition: ParameterDescriptionNode.cc:133
edm::FileInPath::~FileInPath
~FileInPath()
Definition: FileInPath.cc:139
edm::FileInPath::relativePath
std::string relativePath() const
Definition: FileInPath.cc:157
edm::FileInPath::FileInPath
FileInPath()
Definition: FileInPath.cc:104
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161