SHiP Geometry
SHiP experiment geometry implementation using GeoModel.
Loading...
Searching...
No Matches
SubsystemRegistry.h File Reference
#include "SHiP/geometry/SubsystemDescriptor.h"
#include <GeoModelKernel/GeoPhysVol.h>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <map>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
Include dependency graph for SubsystemRegistry.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SHiP::geometry::SubsystemInfo
 A registered subsystem: its descriptor plus how to build it. More...
class  SHiP::geometry::UnknownSubsystem
 Thrown when a subsystem name is not in the registry. More...

Namespaces

namespace  SHiP
namespace  SHiP::geometry

Macros

#define REGISTER_SUBSYSTEM(FACTORY)
 Register a subsystem factory with the global registry.

Functions

std::map< std::string, SubsystemInfo > & SHiP::geometry::registry ()
 The global subsystem registry.
bool SHiP::geometry::registerSubsystem (const SubsystemDescriptor &desc, std::function< GeoVPhysVol *(Materials &)> build)
 Add a subsystem to the registry.
GeoPhysVol * SHiP::geometry::assembleGeometry (const std::vector< std::string > &only={})
 Assemble the world plus a selection of registered subsystems.
GeoVPhysVol * SHiP::geometry::buildSubsystem (const std::string &name)
 Build a single subsystem on its own, in its local frame.
std::vector< std::string > SHiP::geometry::subsystemNames ()
 The names of every registered subsystem, sorted.

Macro Definition Documentation

◆ REGISTER_SUBSYSTEM

#define REGISTER_SUBSYSTEM ( FACTORY)
Value:
namespace { \
[[maybe_unused]] const bool FACTORY##_registered = ::SHiP::geometry::registerSubsystem( \
FACTORY::descriptor(), [](::SHiP::geometry::Materials& materials) -> ::GeoVPhysVol* { \
return FACTORY(materials).build(); \
}); \
} \
void FACTORY##_linkAnchor(); \
void FACTORY##_linkAnchor() {}
Central material manager for the SHiP detector.
Definition Materials.h:22
bool registerSubsystem(const SubsystemDescriptor &desc, std::function< GeoVPhysVol *(Materials &)> build)
Add a subsystem to the registry.
Definition SubsystemRegistry.h:62

Register a subsystem factory with the global registry.

Placed once in each subsystem's own .cpp (inside namespace SHiP::geometry). The factory must expose static SubsystemDescriptor descriptor() and be constructible from Materials& with a build() returning a volume.

It also defines FACTORY_linkAnchor(), an empty function. Nothing else references the registration, so without it the linker would drop the subsystem library (under –as-needed, or from a static archive) and the initialiser would never run. src/CMakeLists.txt generates a call to the anchor of every subsystem in SHIP_SUBSYSTEMS, assuming the factory of subsystem <Name> is called <Name>Factory.