DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
VolumeBuilderReference.hh
Go to the documentation of this file.
1#pragma once
2#ifndef VolumeReference_HPP
3#define VolumeReference_HPP
4//
5// Created by Douglas S. Leonard on 6/8/25. All rights Reserved
6// See related files for license, if any is provided.
7//
8// A type erasing class to hold all kinds of SolidBuilders and VolumeBuilders
9// Use is indirect, by passing to a VolumeReferencePtr parameter or by emplace_back to vector<VolumeReferencePtr().
10// If explicit use is needed VolumeReferencePtr(builder_object), object.VolumeReferencePtr() work.
11//
12//
13//
14//#include "VolumeBuilderReference.hh"
15#include "Linkable.hh"
16#include "i_shared_ptr.hh"
17#include <stdexcept>
18#include <VolumeBuilderTypes.hh>
19#include "VolumeBuilder.hh"
20#include "ISolidBuilder.hh"
21
22namespace DLG4::VolumeBuilders {
23 template <typename T>
24 class VolumeBuilder;
25 class RZBuilder;
26
39 class VolumeBuilderReference final: public VolumeBuilder<VolumeBuilderReference> {
40 template <typename T>
41 friend class VolumeBuilder;
42 friend AssemblyPtr CreateAssembly(G4String name);
43 template <typename T>
44 friend class StructureBuilder;
45
46 template <typename T>
47 friend class i_shared_ptr;
48
49 public:
50 G4VSolid *SolidConstructor(const G4String &name) override;
51
52 private:
53 //allow i_shared_ptr access to our converting ctors
54 //This way they get instantly wrapped!
56
64 template <typename T>
65 VolumeBuilderReference(i_shared_ptr<T> other, // NOLINT(*-explicit-constructor)
66 std::enable_if_t<std::is_base_of_v<IStructureBuilder, T>, int> = 0) : VolumeBuilder<
68 }
69
70 /* Constructor to make a builder from an Existing Geant solid
71 * This is mostly meant for use in parameter signatures
72 * Where you need to get a free solid or Builder with a solid
73 * @param G4VSolid pointer
74 * @return The builder
75 */
76 VolumeBuilderReference(G4VSolid *solid);
77
78 /* Constructor to make a builder from an Existing Geant logical_volume
79 * This is mostly meant for use in parameter signatures
80 * Where you need to get a logical volume or a Builder with a solid
81 * @param G4VSolid pointer
82 * @return The builder */
83 VolumeBuilderReference(G4LogicalVolume *volume);
84
85 /* Constructor to make a builder from an Existing Geant logical_volume.
86 * This is mostly meant for use in parameter signatures
87 * where you need to get a logical volume or a Builder with a solid
88 * @param G4VPhysicalVolume pointer
89 * @return The builder */
90 VolumeBuilderReference(G4VPhysicalVolume *volume);
91
93
94
95 VolumeBuilderReference(const VolumeBuilderReference &other) = default;
96
97 VolumeBuilderReference() = default;
98
99 protected:
101
102 BuilderView ToBuilderView() const override {
103 // we're already type erased, so just return ourselves.
104 return shared_mutable_this(this);
105 }
106
107 public:
109 };
110}
111#endif //VolumeReference_HPP
#define SET_LINK
Definition Linkable.hh:63
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
A polymorphic, type-erased builder referencing any specialized builder.
SharedPtr< IStructureBuilder > clone_impl() const override
G4VSolid * SolidConstructor(const G4String &name) override
polymorphic access to solid construction
friend AssemblyPtr CreateAssembly(G4String name)
Assembly of strucures, ie builders and/or other assemblies.
Definition Assembly.cc:25
VolumeBuilderReference & operator=(const VolumeBuilderReference &other)=delete
VolumeBuilder: Common functionality for volume builder classes.
A wrapper for std::shared_ptr that allows and facilitates many implicit(i) type conversions.
std::shared_ptr< T > shared_mutable_this(const std::enable_shared_from_this< T > *obj)