DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Assembly.hh
Go to the documentation of this file.
1#pragma once
2#ifndef DLG4_ASSEMBLY_HPP
3#define DLG4_ASSEMBLY_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// Assemblies for treating a collection of builders as a single unit.
9//#include "StructureBuilder.hh"
10#include "Linkable.hh"
11#include "i_shared_ptr.hh"
12#include <stdexcept>
13#include <VolumeBuilder.hh>
14#include <VolumeBuilderTypes.hh>
15#include <StructureBuilder.hh>
16
18 template <typename T>
19 class VolumeBuilder;
20 // class StructureBuilder;
21
27 AssemblyPtr CreateAssembly(G4String name);
28
46 class Assembly final: public StructureBuilder<Assembly> {
47 template <typename T>
48 friend class VolumeBuilder;
49 template <typename T>
50 friend class StructureBuilder;
51 friend AssemblyPtr CreateAssembly(G4String name);
52
53 friend class i_shared_ptr<Assembly>;
54
55 public:
57
58 private:
59 //ctor used by factory. Will construct an assembly from a builder actually.
60 template <typename T>
61 Assembly(i_shared_ptr<T> other, // NOLINT(*-explicit-constructor)
62 std::enable_if_t<std::is_base_of_v<IStructureBuilder, T>,
63 int> = 0) : StructureBuilder<Assembly>(other, SET_LINK) {
64 }
65
66 [[noreturn]]
67 G4VSolid *SolidConstructor(const G4String &name) override {
68 throw std::runtime_error(
69 "Error in StructureBuilderReference::SolidConstructor(const G4String &name) "
70 + this->builder_configs_->name + " \n" +
71 "SolidConstructor(const G4String &name) is not implemented.");
72 }
73
74 template <typename T>
75 friend class i_shared_ptr;
76
77
78 Assembly(const Assembly &other);
79 Assembly() = default;
80
81 protected:
82 // Clone impl, this returns a type-erased ISolidPtr
83 // But in reality must bee a BuilderPtr here to be downcast by Clone().
84
85 public:
86 Assembly &operator=(const Assembly &other) = delete;
87 };
88}
89
90
91#endif
#define SET_LINK
Definition Linkable.hh:63
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
Definition Assembly.hh:46
friend AssemblyPtr CreateAssembly(G4String name)
Assembly of strucures, ie builders and/or other assemblies.
Definition Assembly.cc:25
Assembly & operator=(const Assembly &other)=delete
AssemblyPtr AddStructure(const StructureView &other)
Definition Assembly.cc:43
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
VolumeBuilder: Common functionality for volume builder classes.
A wrapper for std::shared_ptr that allows and facilitates many implicit(i) type conversions.
AssemblyPtr CreateAssembly(G4String name)
Assembly of strucures, ie builders and/or other assemblies.
Definition Assembly.cc:25
SharedPtr< Assembly > AssemblyPtr