DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
VolumeBuilderCore.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 BuilderView parameter or by emplace_back to vector<BuilderView>().
10// If explicit use is needed VolumeReferencePtr(builder_object), object.VolumeReferencePtr() work.
11//
12//
13//
14//#include "VolumeBuilderCore.hh"
15#include "Linkable.hh"
16#include "i_shared_ptr.hh"
17#include <stdexcept>
19#include "VolumeBuilderBase.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 VolumeBuilderBase;
29 class RZBuilderCore;
30
43 class VolumeBuilderCore final: public VolumeBuilderBase<VolumeBuilderCore> {
44 template <typename T>
45 friend class VolumeBuilderBase;
46 friend Assembly VB::CreateAssembly(G4String name);
47 template <typename T>
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!
59 friend class i_shared_ptr<VolumeBuilderCore>;
60
68 template <typename T>
69 VolumeBuilderCore(i_shared_ptr<T> other, // NOLINT(*-explicit-constructor)
70 std::enable_if_t<std::is_base_of_v<IStructureBuilder, T>, int> = 0) : VolumeBuilderBase<
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 VolumeBuilderCore(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 VolumeBuilderCore(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 VolumeBuilderCore(G4VPhysicalVolume *volume);
95
97
98
99 VolumeBuilderCore(const VolumeBuilderCore &other) = default;
100
101 VolumeBuilderCore() = default;
102
103 protected:
105
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.".
VolumeBuilder: Common functionality for volume builder classes.
A polymorphic, type-erased "view" of any specialized builder.
SharedPtr< IStructureBuilder > clone_impl() const override
G4VSolid * SolidConstructor(const G4String &name) override
polymorphic access to solid construction
VolumeBuilderCore & operator=(const VolumeBuilderCore &other)=delete
Assembly CreateAssembly(G4String name)
Assembly of strucures, ie builders and/or other assemblies.
std::shared_ptr< T > shared_mutable_this(const std::enable_shared_from_this< T > *obj)