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  private:
127 
128  // Helper function for construction.
129  void getEnvironment();
130  void initialize_();
131  };
132 
133  // Free swap function
134  inline
135  void
137  {
138  a.swap(b);
139  }
140 
141  inline std::ostream&
142  operator<< (std::ostream& os, const edm::FileInPath& fip)
143  {
144  fip.write(os);
145  return os;
146  }
147 
148  inline std::istream&
149  operator>> (std::istream& is, FileInPath& fip)
150  {
151  fip.read(is);
152  return is;
153  }
154 
155  inline bool
157  edm::FileInPath const& b)
158  {
159  return a.location() == b.location() && a.relativePath() == b.relativePath();
160  }
161 
162 }
163 
164 #endif
std::string canonicalFilename_
Definition: FileInPath.h:121
void write(std::ostream &os) const
Definition: FileInPath.cc:190
void swap(FileInPath &other)
Definition: FileInPath.cc:159
std::string dataTop_
Definition: FileInPath.h:125
std::istream & operator>>(std::istream &is, FileInPath &fip)
Definition: FileInPath.h:149
void getEnvironment()
Definition: FileInPath.cc:393
std::string searchPath_
Definition: FileInPath.h:126
std::string releaseTop_
Definition: FileInPath.h:124
LocationCode location_
Definition: FileInPath.h:122
void read(std::istream &is)
Definition: FileInPath.cc:253
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:178
void initialize_()
Definition: FileInPath.cc:427
double b
Definition: hdecay.h:120
std::string relativePath_
Definition: FileInPath.h:120
HLT enums.
double a
Definition: hdecay.h:121
FileInPath & operator=(FileInPath const &other)
Definition: FileInPath.cc:151
std::string fullPath() const
Definition: FileInPath.cc:184
void readFromParameterSetBlob(std::istream &is)
Definition: FileInPath.cc:332
std::string relativePath() const
Definition: FileInPath.cc:171
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
std::string localTop_
Definition: FileInPath.h:123