Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
SensorFactory Class Reference

Factory for creating sensor instances. More...

#include <SensorFactory.h>

Static Public Member Functions

static ISensorcreateSensor (SensorType type)
 Create a sensor instance based on the specified type.
static const char * getSensorTypeName (SensorType type)
 Get sensor type name as string.

Detailed Description

Factory for creating sensor instances.

This centralizes sensor creation and makes it easy to switch sensors without modifying the main application code.

Definition at line 58 of file SensorFactory.h.

Member Function Documentation

◆ createSensor()

ISensor * SensorFactory::createSensor ( SensorType type)
inlinestatic

Create a sensor instance based on the specified type.

Parameters
typeThe sensor type to instantiate
Returns
Pointer to ISensor implementation, or nullptr if type not implemented
Note
To add a new sensor:
  1. Create the sensor class implementing ISensor
  2. Add the include at the top of this file
  3. Add a case statement here

Definition at line 71 of file SensorFactory.h.

References PIRSensor::instance(), and PIR.

Referenced by SensorManager::initializeFromConfig().

◆ getSensorTypeName()

const char * SensorFactory::getSensorTypeName ( SensorType type)
inlinestatic

Get sensor type name as string.

Parameters
typeThe sensor type
Returns
const char* name of the sensor type (string literal, no allocation)

Definition at line 97 of file SensorFactory.h.

References ACCEL_PRESENCE, DISTANCE, INDOOR_OCCUPANCY, LORA_GATEWAY, OPENMV_OCCUPANCY, OUTDOOR_OCCUPANCY, PIR, RAIN_BUCKET, SOIL_MOISTURE, VEHICLE_MAGNETOMETER, VEHICLE_PRESSURE, VIBRATION_ADVANCED, and VIBRATION_BASIC.


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