G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
G4OCCTAssemblyRegistry Class Reference

Singleton registry for named G4OCCTAssemblyVolume instances. More...

#include <G4OCCTAssemblyRegistry.hh>

Public Member Functions

void Register (const std::string &name, G4OCCTAssemblyVolume *assembly)
 
G4OCCTAssemblyVolumeGet (const std::string &name) const
 
G4OCCTAssemblyVolumeRelease (const std::string &name)
 
std::size_t Size () const
 

Static Public Member Functions

static G4OCCTAssemblyRegistryInstance ()
 Return the singleton instance.
 

Detailed Description

Singleton registry for named G4OCCTAssemblyVolume instances.

Stores heap-allocated G4OCCTAssemblyVolume objects by name and takes ownership of them. This is primarily used by the DD4hep plugin to keep assemblies alive past the plugin build phase, where local variables would otherwise be destroyed too early.

Ownership

The registry owns all registered assemblies. They are deleted when Release() is called or when the registry is destroyed.

Usage

auto* assembly = G4OCCTAssemblyVolume::FromSTEP("detector.step", matMap);
G4OCCTAssemblyRegistry::Instance().Register("myDetector", assembly);
// Later:
G4OCCTAssemblyVolume * Get(const std::string &name) const
static G4OCCTAssemblyRegistry & Instance()
Return the singleton instance.
void Register(const std::string &name, G4OCCTAssemblyVolume *assembly)
Extends Geant4's G4AssemblyVolume with an OCCT XDE label reference.
static G4OCCTAssemblyVolume * FromSTEP(const std::string &path, const G4OCCTMaterialMap &materialMap)

Definition at line 38 of file G4OCCTAssemblyRegistry.hh.

Member Function Documentation

◆ Get()

G4OCCTAssemblyVolume * G4OCCTAssemblyRegistry::Get ( const std::string &  name) const

Retrieve an assembly by name.

Parameters
nameAssembly name as passed to Register().
Returns
Pointer to the assembly, or nullptr if not found.

Definition at line 35 of file G4OCCTAssemblyRegistry.cc.

Referenced by G4OCCTAssemblySDSetup::Apply().

◆ Instance()

G4OCCTAssemblyRegistry & G4OCCTAssemblyRegistry::Instance ( )
static

Return the singleton instance.

Definition at line 13 of file G4OCCTAssemblyRegistry.cc.

Referenced by G4OCCTAssemblySDSetup::Apply(), and G4OCCT_ImportSTEPAssembly().

◆ Register()

void G4OCCTAssemblyRegistry::Register ( const std::string &  name,
G4OCCTAssemblyVolume assembly 
)

Register a named assembly (takes ownership).

Parameters
nameUnique name for this assembly.
assemblyNon-null pointer to the assembly to register.
Exceptions
std::runtime_errorif name is already registered.

Definition at line 24 of file G4OCCTAssemblyRegistry.cc.

Referenced by G4OCCT_ImportSTEPAssembly().

◆ Release()

G4OCCTAssemblyVolume * G4OCCTAssemblyRegistry::Release ( const std::string &  name)

Remove an assembly from the registry and return ownership to the caller.

Parameters
nameAssembly name to release.
Returns
The previously registered pointer, or nullptr if not found. The caller is responsible for deleting the returned object.

Definition at line 40 of file G4OCCTAssemblyRegistry.cc.

◆ Size()

std::size_t G4OCCTAssemblyRegistry::Size ( ) const

Return the number of registered assemblies.

Definition at line 50 of file G4OCCTAssemblyRegistry.cc.


The documentation for this class was generated from the following files: