DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Assembly.cc
Go to the documentation of this file.
1
10#include "VolumeBuilderTypes.hh"
11#include "VolumeBuilder.hh"
13#include "StructureBuilder.hpp"
14#include "Assembly.hh"
15
16namespace DLG4::VolumeBuilders {
17 Assembly::Assembly(const Assembly &other) :
18 StructureBuilder<Assembly>(other) {
19 // Call base class copy constructor
20 set_shared_from_this_enabled(false);
21 set_shared_from_this_enabled(true);
22 }
23
24
25 AssemblyPtr CreateAssembly(G4String name) {
26 // Haha... assemblies actually are builders!!!
27 auto object = AssemblyPtr(new Assembly());
28 // ... with is_builder set to false.
29 object->placement_configs_->is_builder = false;
30 //We're storing a pointer to the view in the builder by writing to the builder through that same view!
31 BuilderView builder_view = object->ToBuilderView();
32 builder_view->StoreBuilderView(builder_view);
33 // Then store itself in its new builder (that links to its data).
34 //object->builder_configs_->builder_view->StoreIStructurePtr(IStructurePtr(object.get())); // this is the owning copy.
35 // ... and viewed through a reduced StructureView interface:
36 object->SetName(name);
37 auto return_obj = AssemblyPtr(object);
38 return return_obj;
39
40 // This let's us reuse builder methods!
41 }
42
43 AssemblyPtr Assembly::AddStructure(const StructureView &other) {
44 this->placement_configs_->children.emplace_back(other);
45 return this->shared_from_this();
46 }
47}
48
49//
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
Definition Assembly.hh:46
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