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);
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
edm::FileInPath::swap
void swap(FileInPath &other)
Definition: FileInPath.cc:149
edm::FileInPath::readFromParameterSetBlob
void readFromParameterSetBlob(std::istream &is)
Definition: FileInPath.cc:275
edm::FileInPath::dataTop_
std::string dataTop_
Definition: FileInPath.h:118
edm::FileInPath::canonicalFilename_
std::string canonicalFilename_
Definition: FileInPath.h:114
edm::FileInPath::getEnvironment
void getEnvironment()
Definition: FileInPath.cc:333
edm::FileInPath::Release
Definition: FileInPath.h:66
edm::FileInPath::localTop_
std::string localTop_
Definition: FileInPath.h:116
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:115
edm::FileInPath::Local
Definition: FileInPath.h:66
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:436
edm::FileInPath
Definition: FileInPath.h:64
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:117
edm::FileInPath::searchPath_
std::string searchPath_
Definition: FileInPath.h:119
trackingPlots.other
other
Definition: trackingPlots.py:1467
edm::operator>>
std::istream & operator>>(std::istream &is, FileInPath &fip)
Definition: FileInPath.h:134
b
double b
Definition: hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::FileInPath::location
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:161
edm::FileInPath::read
void read(std::istream &is)
Definition: FileInPath.cc:204
a
double a
Definition: hdecay.h:119
edm::FileInPath::Data
Definition: FileInPath.h:66
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::FileInPath::LocationCode
LocationCode
Definition: FileInPath.h:66
edm::FileInPath::initialize_
void initialize_()
Definition: FileInPath.cc:364
edm::FileInPath::Unknown
Definition: FileInPath.h:66
edm::FileInPath::operator=
FileInPath & operator=(FileInPath const &other)
Definition: FileInPath.cc:143
edm::FileInPath::relativePath_
std::string relativePath_
Definition: FileInPath.h:113
edm::FileInPath::write
void write(std::ostream &os) const
Definition: FileInPath.cc:165
edm::FileInPath::~FileInPath
~FileInPath()
Definition: FileInPath.cc:141
edm::FileInPath::relativePath
std::string relativePath() const
Definition: FileInPath.cc:159
edm::FileInPath::FileInPath
FileInPath()
Definition: FileInPath.cc:106
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163