DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
StructureBuilderReference.cc
Go to the documentation of this file.
1
10#include "VolumeBuilderTypes.hh"
11#include "ISolidBuilder.hh"
12#include "VolumeBuilder.hh"
15#include "StructureBuilder.hh"
16#include "StructureBuilder.hpp"
17
18
19namespace DLG4::VolumeBuilders {
21 if (builder_configs_->istructure_ptr) {
22 // have the erased base clone itself ex: new RZBuilder(*this); :
23 IStructurePtr copy = builder_configs_->istructure_ptr->clone_impl();
24 // Then have it create a builderPtr from itself:
25 // These are non owning views, won't keep the temp copy:
26 BuilderView builder_view = copy->ToBuilderView();
27 StructureView structure_view = copy->ToStructureView();
28 // Then store itself in its new builder (that links to its data).
29 builder_view->StoreIStructurePtr(copy); // this is the owning copy.
30 //We're storing the view in the builder by writing to the builder through that same view!
31 builder_view->StoreBuilderView(builder_view);
32 return structure_view; // and return the builder
33 } else {
34 // not sure we should get here:
35 auto x = static_cast<SharedPtr<IStructureBuilder>>(shared_mutable_this(this));
36 return x;
37 }
38 }
39
41 // we're already type erased, so just return ourselves.
42 auto x = shared_mutable_this(this);
43 return x;
44 }
45}
46
47//
SharedPtr< IStructureBuilder > clone_impl() const override
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)