Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:17:11

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/ObjectInterface.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <string>
0012 #include <string_view>
0013 
0014 #include "corecel/Config.hh"
0015 
0016 #include "corecel/Macros.hh"
0017 
0018 #include "CsgTypes.hh"
0019 
0020 namespace celeritas
0021 {
0022 struct JsonPimpl;
0023 
0024 namespace orangeinp
0025 {
0026 //---------------------------------------------------------------------------//
0027 namespace detail
0028 {
0029 class VolumeBuilder;
0030 }
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Base class for constructing high-level CSG objects in ORANGE.
0035  */
0036 class ObjectInterface
0037 {
0038   public:
0039     //!@{
0040     //! \name Type aliases
0041     using SPConstObject = std::shared_ptr<ObjectInterface const>;
0042     using VolumeBuilder = detail::VolumeBuilder;
0043     //!@}
0044 
0045   public:
0046     //! Short unique name of this object
0047     virtual std::string_view label() const = 0;
0048 
0049     //! Construct a volume from this object
0050     virtual NodeId build(VolumeBuilder&) const = 0;
0051 
0052     //! Write the region to a JSON object
0053     virtual void output(JsonPimpl*) const = 0;
0054 
0055   protected:
0056     //!@{
0057     //! Allow construction and assignment only through daughter classes
0058     ObjectInterface() = default;
0059     virtual ~ObjectInterface() = default;
0060     CELER_DEFAULT_COPY_MOVE(ObjectInterface);
0061     //!@}
0062 };
0063 
0064 //---------------------------------------------------------------------------//
0065 // Get a JSON string representing an object
0066 std::string to_string(ObjectInterface const&);
0067 
0068 //---------------------------------------------------------------------------//
0069 }  // namespace orangeinp
0070 }  // namespace celeritas