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>
19#include "VolumeBuilder.hh"
20#include "ISolidBuilder.hh"
21#include <BuilderFactories.hh>
22
24 namespace VB=DLG4::VolumeBuilders;
25 using namespace VB;
26
27 template <typename T>
28 class VolumeBuilder;
29 class RZBuilder;
30
43 class VolumeBuilderReference final: public VolumeBuilder<VolumeBuilderReference> {
44 template <typename T>
45 friend class VolumeBuilder;
46 friend AssemblyPtr VB::CreateAssembly(G4String name);
47 template <typename T>
48 friend class StructureBuilder;
49
50 template <typename T>
51 friend class i_shared_ptr;
52
53 public:
54 G4VSolid *SolidConstructor(const G4String &name) override;
55
56 private:
57 //allow i_shared_ptr access to our converting ctors
58 //This way they get instantly wrapped!
60
68 template <typename T>
69 VolumeBuilderReference(i_shared_ptr<T> other, // NOLINT(*-explicit-constructor)
70 std::enable_if_t<std::is_base_of_v<IStructureBuilder, T>, int> = 0) : VolumeBuilder<
72 }
73
74 /* Constructor to make a builder from an Existing Geant solid
75 * This is mostly meant for use in parameter signatures
76 * Where you need to get a free solid or Builder with a solid
77 * @param G4VSolid pointer
78 * @return The builder
79 */
80 VolumeBuilderReference(G4VSolid *solid);
81
82 /* Constructor to make a builder from an Existing Geant logical_volume
83 * This is mostly meant for use in parameter signatures
84 * Where you need to get a logical volume or a Builder with a solid
85 * @param G4VSolid pointer
86 * @return The builder */
87 VolumeBuilderReference(G4LogicalVolume *volume);
88
89 /* Constructor to make a builder from an Existing Geant logical_volume.
90 * This is mostly meant for use in parameter signatures
91 * where you need to get a logical volume or a Builder with a solid
92 * @param G4VPhysicalVolume pointer
93 * @return The builder */
94 VolumeBuilderReference(G4VPhysicalVolume *volume);
95
97
98
99 VolumeBuilderReference(const VolumeBuilderReference &other) = default;
100
101 VolumeBuilderReference() = default;
102
103 protected:
105
106 BuilderView ToBuilderView() const override {
107 // we're already type erased, so just return ourselves.
108 return shared_mutable_this(this);
109 }
110
111 public:
113 };
114}
115#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
VolumeBuilderReference & operator=(const VolumeBuilderReference &other)=delete
VolumeBuilder: Common functionality for volume builder classes.
AssemblyPtr CreateAssembly(G4String name)
Assembly of strucures, ie builders and/or other assemblies.
Definition Assembly.cc:18
std::shared_ptr< T > shared_mutable_this(const std::enable_shared_from_this< T > *obj)