Moved setname to corething

This commit is contained in:
Pascal Serrarens 2024-12-16 09:13:59 +01:00
parent df8e065003
commit fec44b0397
4 changed files with 9 additions and 26 deletions

View File

@ -17,6 +17,9 @@ CoreThing::CoreThing(unsigned char networkId, unsigned char thingType) {
void CoreThing::Init() {}
void CoreThing::SetName(const char *name) { this->name = name; }
// All things
CoreThing *CoreThing::allThings[256] = {nullptr};
CoreThing *CoreThing::Get(unsigned char networkId, unsigned char thingId) {

View File

@ -32,13 +32,16 @@ public:
ExternalSensor,
};
private:
static CoreThing *allThings[];
public:
CoreThing(unsigned char networkId = 0,
unsigned char thingType = (unsigned char)Type::Undetermined);
void SetName(const char *name);
// All things
private:
static CoreThing *allThings[];
static CoreThing *Get(unsigned char networkId, unsigned char thingId);
static int Add(CoreThing *thing);

View File

@ -14,8 +14,6 @@ Thing::Thing() : CoreThing() {
this->children = nullptr;
}
void Thing::SetName(const char *name) { this->name = name; }
const unsigned int Thing::SwitchType = SensorType | (unsigned int)Type::Switch;
const unsigned int Thing::DistanceSensorType =
SensorType | (unsigned int)Type::DistanceSensor;

21
Thing.h
View File

@ -15,10 +15,6 @@ public:
/// @brief Default constructor for a Thing
Thing();
// unsigned char id;
void SetName(const char *name);
// I hate this, better is to have an additional field stating the thing
// classificaton Motor, Sensor etc.
/// @brief The type of a switch sensor
@ -117,23 +113,6 @@ protected:
static const unsigned int RoboidType = 0x2000;
static const unsigned char CustomType = 0x80;
/// @brief Basic Thing types
// enum class Type {
// Undetermined,
// // Sensor,
// Switch,
// DistanceSensor,
// DirectionalSensor,
// TemperatureSensor,
// // Motor,
// ControlledMotor,
// UncontrolledMotor,
// Servo,
// // Other
// Humanoid,
// ExternalSensor,
// };
Thing *parent = nullptr;
Thing **children = nullptr;