CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
MonitorElementData::Path Struct Reference

#include <MonitorElementCollection.h>

Public Types

enum  Type { Type::DIR, Type::DIR_AND_NAME }
 

Public Member Functions

std::string const & getDirname () const
 
std::string getFullname () const
 
std::string const & getObjectname () const
 
bool operator== (Path const &other) const
 
void set (std::string path, Path::Type type)
 

Private Attributes

std::string dirname_
 
std::string objname_
 

Detailed Description

Definition at line 163 of file MonitorElementCollection.h.

Member Enumeration Documentation

◆ Type

Enumerator
DIR 
DIR_AND_NAME 

Definition at line 170 of file MonitorElementCollection.h.

170 { DIR, DIR_AND_NAME };

Member Function Documentation

◆ getDirname()

std::string const& MonitorElementData::Path::getDirname ( ) const
inline

Definition at line 172 of file MonitorElementCollection.h.

References dirname_.

Referenced by dqm::impl::MonitorElement::syncCoreObject().

172 { return dirname_; }

◆ getFullname()

std::string MonitorElementData::Path::getFullname ( ) const
inline

◆ getObjectname()

std::string const& MonitorElementData::Path::getObjectname ( ) const
inline

Definition at line 173 of file MonitorElementCollection.h.

References objname_.

Referenced by dqm::impl::MonitorElement::syncCoreObject().

173 { return objname_; }

◆ operator==()

bool MonitorElementData::Path::operator== ( Path const &  other) const
inline

Definition at line 244 of file MonitorElementCollection.h.

References trackingPlots::other.

244  {
245  return this->dirname_ == other.dirname_ && this->objname_ == other.objname_;
246  }

◆ set()

void MonitorElementData::Path::set ( std::string  path,
Path::Type  type 
)
inline

Definition at line 182 of file MonitorElementCollection.h.

References DIR, dirname_, eostools::move(), objname_, and castor_dqm_sourceclient_file_cfg::path.

182  {
183  //rebuild 'path' to be in canonical form
184 
185  //remove any leading '/'
186  while (not path.empty() and path.front() == '/') {
187  path.erase(path.begin());
188  }
189 
190  //handle '..' and '//'
191  // the 'dir' tokens are separate by a single '/'
192  std::string::size_type tokenStartPos = 0;
193  while (tokenStartPos < path.size()) {
194  auto tokenEndPos = path.find('/', tokenStartPos);
195  if (tokenEndPos == std::string::npos) {
196  tokenEndPos = path.size();
197  }
198  if (0 == tokenEndPos - tokenStartPos) {
199  //we are sitting on a '/'
200  path.erase(path.begin() + tokenStartPos);
201  continue;
202  } else if (2 == tokenEndPos - tokenStartPos) {
203  if (path[tokenStartPos] == '.' and path[tokenStartPos + 1] == '.') {
204  //need to go backwards and remove previous directory
205  auto endOfLastToken = tokenStartPos;
206  if (tokenStartPos > 1) {
207  endOfLastToken -= 2;
208  }
209  auto startOfLastToken = path.rfind('/', endOfLastToken);
210  if (startOfLastToken == std::string::npos) {
211  //we are at the very beginning of 'path' since no '/' found
212  path.erase(path.begin(), path.begin() + tokenEndPos);
213  tokenStartPos = 0;
214  } else {
215  path.erase(path.begin() + startOfLastToken + 1, path.begin() + tokenEndPos);
216  tokenStartPos = startOfLastToken + 1;
217  }
218  continue;
219  }
220  }
221  tokenStartPos = tokenEndPos + 1;
222  }
223 
224  //separate into objname_ and dirname_;
225  objname_.clear();
226  if (type == Path::Type::DIR) {
227  if (not path.empty() and path.back() != '/') {
228  path.append(1, '/');
229  }
231  } else {
232  auto lastSlash = path.rfind('/');
233  if (lastSlash == std::string::npos) {
235  dirname_.clear();
236  } else {
237  objname_ = path.substr(lastSlash + 1);
238  path.erase(path.begin() + lastSlash + 1, path.end());
240  }
241  }
242  }
uint16_t size_type
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ dirname_

std::string MonitorElementData::Path::dirname_
private

Definition at line 166 of file MonitorElementCollection.h.

Referenced by getDirname(), getFullname(), and set().

◆ objname_

std::string MonitorElementData::Path::objname_
private

Definition at line 167 of file MonitorElementCollection.h.

Referenced by getFullname(), getObjectname(), and set().