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 
58 // TODO: Find the correct package for this class to reside. It
59 // doesn't seem well-suited for ParameterSet.
60 
61 
62 #include <iosfwd>
63 #include <string>
64 
65 
66 namespace edm
67 {
68  class FileInPath
69  {
70  public:
71 
72  enum LocationCode {
73  Unknown = 0,
74  Local = 1,
75  Release = 2,
76  Data = 3
77  };
78 
81  FileInPath();
82 
84  explicit FileInPath(const std::string& r);
85  explicit FileInPath(const char* r);
86 
87  FileInPath(FileInPath const& other);
89  ~FileInPath();
90  void swap(FileInPath& other);
91 
95  std::string relativePath() const;
96 
98  LocationCode location() const;
99 
108  std::string fullPath() const;
109 
112  void write(std::ostream& os) const;
113 
116  void read(std::istream& is);
117 
118  void readFromParameterSetBlob(std::istream& is);
119 
121  static void disableFileLookup();
122 
123  private:
131 
132  // Helper function for construction.
133  void getEnvironment();
134  void initialize_();
135  };
136 
137  // Free swap function
138  inline
139  void
141  {
142  a.swap(b);
143  }
144 
145  inline std::ostream&
146  operator<< (std::ostream& os, const edm::FileInPath& fip)
147  {
148  fip.write(os);
149  return os;
150  }
151 
152  inline std::istream&
153  operator>> (std::istream& is, FileInPath& fip)
154  {
155  fip.read(is);
156  return is;
157  }
158 
159  inline bool
161  edm::FileInPath const& b)
162  {
163  return a.location() == b.location() && a.relativePath() == b.relativePath();
164  }
165 
166 }
167 
168 #endif
std::string canonicalFilename_
Definition: FileInPath.h:125
void write(std::ostream &os) const
Definition: FileInPath.cc:203
void swap(FileInPath &other)
Definition: FileInPath.cc:172
static void disableFileLookup()
Should only be called while the edmWriteConfigs executable runs.
Definition: FileInPath.cc:524
std::string dataTop_
Definition: FileInPath.h:129
std::istream & operator>>(std::istream &is, FileInPath &fip)
Definition: FileInPath.h:153
void getEnvironment()
Definition: FileInPath.cc:406
std::string searchPath_
Definition: FileInPath.h:130
std::string releaseTop_
Definition: FileInPath.h:128
LocationCode location_
Definition: FileInPath.h:126
void read(std::istream &is)
Definition: FileInPath.cc:266
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:191
void initialize_()
Definition: FileInPath.cc:440
double b
Definition: hdecay.h:120
std::string relativePath_
Definition: FileInPath.h:124
HLT enums.
double a
Definition: hdecay.h:121
FileInPath & operator=(FileInPath const &other)
Definition: FileInPath.cc:164
std::string fullPath() const
Definition: FileInPath.cc:197
void readFromParameterSetBlob(std::istream &is)
Definition: FileInPath.cc:345
std::string relativePath() const
Definition: FileInPath.cc:184
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
std::string localTop_
Definition: FileInPath.h:127