Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:32:47

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //  \author  Markus Frank
0011 //  \date    2016-08-30
0012 //  \version 1.0
0013 //
0014 //==========================================================================
0015 #ifndef DD4HEP_PATH_H
0016 #define DD4HEP_PATH_H
0017 
0018 // Framework include files
0019 
0020 // C/C++ include files
0021 #include <string>
0022 
0023 // Forward declartions
0024 
0025 /// Namespace for the AIDA detector description toolkit
0026 namespace dd4hep {
0027 
0028 
0029   /// Path handling class.
0030   /**
0031    *  Normally this could as well be replaced by 
0032    *  boost::filesystem::path.
0033    *
0034    *  However, the LC folks do not like the additional link-dependency.
0035    *  Hence this small extraction.
0036    *  The main code comes from the boost implementation.
0037    *
0038    *  See http://www.boost.org/LICENSE_1_0.txt for the license and
0039    *  the filesystem library home page: http://www.boost.org/libs/filesystem
0040    *
0041    *  \author  M.Frank
0042    *  \version 1.0
0043    *  \ingroup DD4HEP
0044    */
0045   class Path : public std::string {
0046   public:
0047     /// Default constructor
0048     Path() : std::string()                            {                    }
0049     /// Initializing constructor
0050     Path(const std::string& copy) : std::string(copy) {                    }
0051     /// Initializing constructor
0052     Path(std::string&& copy) : std::string(std::move(copy)) {              }
0053     /// Copy constructor
0054     Path(const Path& copy) : std::string(copy)        {                    }
0055     /// Move constructor
0056     Path(Path&& copy) : std::string(std::move(copy))  {                    }
0057     /// Assigning constructor
0058     template <class Iter> Path(Iter _begin,Iter _end) {
0059       if ( _begin != _end )  {
0060         std::string str(_begin, _end);
0061         this->std::string::operator=(std::move(str));
0062       }
0063     }
0064     /// Default destructor
0065     ~Path() {}
0066     /// Assignment operator from Path object
0067     Path& operator=(const Path& copy)          {
0068       this->std::string::operator=(copy);
0069       return *this;
0070     }
0071     /// Assignment operator from string object
0072     Path& operator=(const std::string& copy)   {
0073       this->std::string::operator=(copy);
0074       return *this;
0075     }
0076     /// Move assignment operator from Path object
0077     Path& operator=(Path&& copy)          {
0078       this->std::string::operator=(std::move(copy));
0079       return *this;
0080     }
0081     /// Assignment operator from string object
0082     Path& operator=(std::string&& copy)   {
0083       this->std::string::operator=(std::move(copy));
0084       return *this;
0085     }
0086     /// Append operation
0087     Path& append(const std::string& copy);
0088     /// Append operation
0089     Path& operator/=(const Path& copy)         {    return append(copy);   }
0090     /// Append operation
0091     Path& operator/=(const std::string& copy)  {    return append(copy);   }
0092     /// Normalize path name
0093     Path  normalize()  const;
0094     /// Parent's path
0095     Path  parent_path() const;
0096     /// The file name of the path
0097     Path  filename() const;
0098     /// The full file path of the object
0099     Path  file_path() const;
0100     /// Manipulator: remove the file name part. Leaves the parent path
0101     Path& remove_filename();
0102     
0103     /// String representation of thre Path object
0104     const std::string& native() const       {    return *this;       }
0105     /// String representation of thre Path object
0106     const char* string_data() const { return this->std::string::c_str(); }
0107     /// Index of the parent's path end
0108     size_t parent_path_end() const;
0109     /// Helpers
0110     class detail  {
0111     public:
0112       /// Path representing "."
0113       static const Path& dot_path();
0114       /// Path representing ".."
0115       static const Path& dot_dot_path();
0116     };
0117   };
0118 }         /* End namespace dd4hep           */
0119 #endif // DD4HEP_PATH_H