Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-29 09:13:54

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file geocel/UniqueVolumeToString.hh
0006 //! \sa test/geocel/Volume.test.cc
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <string>
0012 #include <vector>
0013 
0014 #include "Types.hh"
0015 
0016 namespace celeritas
0017 {
0018 class VolumeParams;
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Convert a unique volume instance ID to a slash-separated instance path.
0022  *
0023  * The value \c nullid, which corresponds to "outside", returns an empty
0024  * string. All other strings are slash-separated labels starting with the world
0025  * instance.
0026  */
0027 class UniqueVolumeToString
0028 {
0029   public:
0030     //!@{
0031     //! \name Type aliases
0032     using SPVolumeParams = std::shared_ptr<VolumeParams const>;
0033     //!@}
0034 
0035   public:
0036     // Construct with non-owning shared pointer (limited lifetime)
0037     static UniqueVolumeToString from_ref(VolumeParams const&);
0038 
0039     // Construct with shared volume metadata
0040     explicit UniqueVolumeToString(SPVolumeParams vols);
0041 
0042     // Apply conversion
0043     std::string operator()(VolumeUniqueInstanceId uid);
0044 
0045   private:
0046     SPVolumeParams vols_;
0047     VolumeInstanceId world_instance_;
0048     std::vector<VolumeInstanceId> path_buffer_;
0049 };
0050 
0051 //---------------------------------------------------------------------------//
0052 }  // namespace celeritas