Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:56

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file orange/orangeinp/ProtoInterface.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <vector>
0012 
0013 #include "orange/OrangeInput.hh"
0014 
0015 namespace celeritas
0016 {
0017 //---------------------------------------------------------------------------//
0018 struct JsonPimpl;
0019 struct OrangeInput;
0020 
0021 namespace orangeinp
0022 {
0023 class ObjectInterface;
0024 
0025 namespace detail
0026 {
0027 class ProtoBuilder;
0028 }  // namespace detail
0029 
0030 //---------------------------------------------------------------------------//
0031 /*!
0032  * Construct a universe as part of an ORANGE geometry.
0033  *
0034  * Each Proto (for proto-universe) will result in a unique UniverseId and can
0035  * be placed into multiple other universes. Each universe has:
0036  * - a label for descriptive output,
0037  * - an "interior" CSG object that describes its boundary, so that it can be
0038  *   placed in other universes, and
0039  * - a list of daughter Protos that are placed inside the current one.
0040  *
0041  * The graph of Proto daughters must be acyclic.
0042  */
0043 class ProtoInterface
0044 {
0045   public:
0046     //!@{
0047     //! \name Type aliases
0048     using SPConstObject = std::shared_ptr<ObjectInterface const>;
0049     using SPConstProto = std::shared_ptr<ProtoInterface const>;
0050     using VecProto = std::vector<ProtoInterface const*>;
0051     using ProtoBuilder = detail::ProtoBuilder;
0052     //!@}
0053 
0054   public:
0055     //! Short unique name of this object
0056     virtual std::string_view label() const = 0;
0057 
0058     //! Get the boundary of this universe as an object
0059     virtual SPConstObject interior() const = 0;
0060 
0061     //! Get a non-owning set of all daughters referenced by this proto
0062     virtual VecProto daughters() const = 0;
0063 
0064     //! Construct a universe input from this object
0065     virtual void build(ProtoBuilder&) const = 0;
0066 
0067     //! Write the proto to a JSON object
0068     virtual void output(JsonPimpl*) const = 0;
0069 
0070   protected:
0071     //!@{
0072     //! Allow construction and assignment only through subclasses
0073     ProtoInterface() = default;
0074     virtual ~ProtoInterface() = default;
0075     CELER_DEFAULT_COPY_MOVE(ProtoInterface);
0076     //!@}
0077 };
0078 
0079 //---------------------------------------------------------------------------//
0080 // Get a JSON string representing a proto
0081 std::string to_string(ProtoInterface const&);
0082 
0083 //---------------------------------------------------------------------------//
0084 }  // namespace orangeinp
0085 }  // namespace celeritas