Skip to content

Refactor the config objects into singleton-like objects #5

@curieos

Description

@curieos

Currently the module config object and plant config object are not instanced anywhere, as only their static methods and members are accessed.

class ModuleConfig {
public:
static void ReadConfigFromFile();
static void WriteConfigToFile();
static void AddNetwork(const char *ssid, const char *password);
static std::vector<Network> GetNetworks() { return networks; }
static const char *GetName() { return name; }
static int32_t GetTimezoneOffset() { return timezone_offset; }
static void SetupModule(const char *raw_config);
private:
static char name[100];
static int32_t timezone_offset;
static std::vector<Network> networks;
};
class PlantConfig {
public:
static const char *GetName() { return name; }
static void SetupPlant(const char *raw_config);
private:
static char name[100];
};

This should be changed so each object that requires them has them injected in their constructor, and a single instance of each is created in the root file, or with the dependency injection framework used in #3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions