RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
RumPi::ComponentCreationContext Class Reference

Everything a component creator needs, bundled so every creator can share one signature and live in the factory's lookup map. More...

#include <ComponentCreationContext.h>

Collaboration diagram for RumPi::ComponentCreationContext:
[legend]

Public Member Functions

 ComponentCreationContext (const nlohmann::json &entry, std::map< std::string, IAnalogDigitalConverterComponent * > &adcsByType, const RumPiConfig &config)
 Binds the references the component creators read from. More...
 
const nlohmann::json & GetEntry () const
 Gets the manifest entry describing the component to build. More...
 
std::map< std::string, IAnalogDigitalConverterComponent * > & GetAdcsByType ()
 Gets the map of ADC providers created so far, keyed by type name. More...
 
const RumPiConfigGetConfig () const
 Gets the loaded library configuration, for components whose settings come from config. More...
 

Private Attributes

const nlohmann::json & myEntry
 The manifest entry (a JSON object) describing the component to build - its "type" and its parameters. More...
 
std::map< std::string, IAnalogDigitalConverterComponent * > & myAdcsByType
 ADC providers created earlier in the build pass, keyed by type name. More...
 
const RumPiConfigmyConfig
 The loaded library configuration, for components whose settings come from config (e.g. TSL2591 cutoffs). More...
 

Detailed Description

Everything a component creator needs, bundled so every creator can share one signature and live in the factory's lookup map.

The members are references bound once (by the dispatcher) and only read by the creators, so this exposes getters but no setters - a reference cannot be re-pointed after construction.

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ ComponentCreationContext()

RumPi::ComponentCreationContext::ComponentCreationContext ( const nlohmann::json &  entry,
std::map< std::string, IAnalogDigitalConverterComponent * > &  adcsByType,
const RumPiConfig config 
)

Binds the references the component creators read from.

The members are references, so they must be set here (in the initializer list) and cannot be re-pointed afterwards.

Author
Eddie O'Hagan
Date
8/13/2026
ComponentCreationContext context(entry, adcsByType, config);
BaseComponent* component = CreateComponent(context);
ComponentCreationContext(const nlohmann::json &entry, std::map< std::string, IAnalogDigitalConverterComponent * > &adcsByType, const RumPiConfig &config)
Binds the references the component creators read from.
Definition: ComponentCreationContext.cpp:21
static BaseComponent * CreateComponent(const std::string &type, const nlohmann::json &entry, std::map< std::string, IAnalogDigitalConverterComponent * > &adcsByType, const RumPiConfig &config)
Builds a single component from one manifest entry by matching its "type" to the right CreateX functio...
Definition: ComponentFactory.cpp:761
Parameters
[in]entryThe manifest entry describing the component to build.
[in,out]adcsByTypeThe ADC providers created so far, keyed by type name.
[in]configThe loaded library configuration.

Member Function Documentation

◆ GetAdcsByType()

std::map< std::string, IAnalogDigitalConverterComponent * > & RumPi::ComponentCreationContext::GetAdcsByType ( )

Gets the map of ADC providers created so far, keyed by type name.

A creator that is an ADC registers itself here; a creator that reads through one looks its ADC up here.

Author
Eddie O'Hagan
Date
8/13/2026
IAnalogDigitalConverterComponent* adc = context.GetAdcsByType()["PCF8591"];
Returns
The ADC-provider map (mutable, so a creator can register itself).

◆ GetConfig()

const RumPiConfig & RumPi::ComponentCreationContext::GetConfig ( ) const

Gets the loaded library configuration, for components whose settings come from config.

Author
Eddie O'Hagan
Date
8/13/2026
float darkCutoff = context.GetConfig().GetLightCutoffDark();
Returns
The library configuration.

◆ GetEntry()

const nlohmann::json & RumPi::ComponentCreationContext::GetEntry ( ) const

Gets the manifest entry describing the component to build.

Author
Eddie O'Hagan
Date
8/13/2026
std::string type = context.GetEntry().value("type", std::string(""));
Returns
The manifest entry (a JSON object).

Member Data Documentation

◆ myAdcsByType

std::map<std::string, IAnalogDigitalConverterComponent*>& RumPi::ComponentCreationContext::myAdcsByType
private

ADC providers created earlier in the build pass, keyed by type name.

A creator that IS an ADC registers itself here; a creator that reads through one (e.g. the wind or gas sensors) looks its ADC up here.

◆ myConfig

const RumPiConfig& RumPi::ComponentCreationContext::myConfig
private

The loaded library configuration, for components whose settings come from config (e.g. TSL2591 cutoffs).

◆ myEntry

const nlohmann::json& RumPi::ComponentCreationContext::myEntry
private

The manifest entry (a JSON object) describing the component to build - its "type" and its parameters.


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