CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 161 of file MonitorElementCollection.h.

Member Enumeration Documentation

Enumerator
DIR 
DIR_AND_NAME 

Definition at line 168 of file MonitorElementCollection.h.

168 { DIR, DIR_AND_NAME };

Member Function Documentation

std::string const& MonitorElementData::Path::getDirname ( ) const
inline
std::string MonitorElementData::Path::getFullname ( ) const
inline
std::string const& MonitorElementData::Path::getObjectname ( ) const
inline
bool MonitorElementData::Path::operator== ( Path const &  other) const
inline

Definition at line 242 of file MonitorElementCollection.h.

References dirname_, and objname_.

242  {
243  return this->dirname_ == other.dirname_ && this->objname_ == other.objname_;
244  }
void MonitorElementData::Path::set ( std::string  path,
Path::Type  type 
)
inline

Definition at line 180 of file MonitorElementCollection.h.

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

Referenced by dqm::implementation::IBooker::bookME(), dqm::implementation::IGetter::get(), dqm::implementation::IGetter::getAllContents(), dqm::implementation::IGetter::getContents(), DQMTTreeIO::TreeReaderBase::makeKey(), and dqm::implementation::NavigatorBase::setCurrentFolder().

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

Member Data Documentation

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

Definition at line 164 of file MonitorElementCollection.h.

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

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

Definition at line 165 of file MonitorElementCollection.h.

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