knx
ETS configurable knx-stack
table_object.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "interface_object.h"
4 
5 class Memory;
6 
7 typedef void (*BeforeTablesUnloadCallback)();
8 
13 {
14  friend class Memory;
15 
16  public:
21  TableObject(Memory& memory, uint32_t staticTableAdr = 0, uint32_t staticTableSize = 0);
22 
26  virtual ~TableObject();
31  uint8_t* save(uint8_t* buffer) override;
32  const uint8_t* restore(const uint8_t* buffer) override;
33  uint16_t saveSize() override;
34 
37 
38  protected:
44  virtual void beforeStateChange(LoadState& newState);
45 
50  uint8_t* data();
55 
56  void initializeProperties(size_t propertiesSize, Property** properties) override;
57 
59 
61 
62  private:
63  uint32_t tableReference();
64  bool allocTable(uint32_t size, bool doFill, uint8_t fillByte);
65  void allocTableStatic();
66  void initializeDynTableProperties(size_t propertiesSize, Property** properties);
67  void loadEvent(const uint8_t* data);
68  void loadEventUnloaded(const uint8_t* data);
69  void loadEventLoading(const uint8_t* data);
70  void loadEventLoaded(const uint8_t* data);
71  void loadEventError(const uint8_t* data);
72  void additionalLoadControls(const uint8_t* data);
73 
81  void loadState(LoadState newState);
82  LoadState _state = LS_UNLOADED;
83  uint8_t* _data = 0;
84  static uint8_t _tableUnloadCount;
85  uint32_t _staticTableAdr;
86  uint32_t _staticTableSize;
87 
93  uint32_t _size = 0;
94 };
This class represents and interface object.
Definition: memory.h:37
This class provides common functionality for interface objects that are configured by ETS with MemorW...
Definition: table_object.h:13
void initializeProperties(size_t propertiesSize, Property **properties) override
Intializes the Property-array the the supplied values.
LoadState loadState()
This method returns the LoadState of the interface object.
Memory & _memory
Definition: table_object.h:60
virtual ~TableObject()
The destructor.
static BeforeTablesUnloadCallback _beforeTablesUnload
Definition: table_object.h:58
static BeforeTablesUnloadCallback beforeTablesUnloadCallback()
uint8_t * data()
returns the internal data of the interface object.
virtual void beforeStateChange(LoadState &newState)
This method is called before the interface object enters a new LoadState.
void errorCode(ErrorCode errorCode)
Set the reason for a state change failure.
const uint8_t * restore(const uint8_t *buffer) override
This method is called when the object should restore its state from the buffer.
uint16_t saveSize() override
TableObject(Memory &memory, uint32_t staticTableAdr=0, uint32_t staticTableSize=0)
The constuctor.
uint8_t * save(uint8_t *buffer) override
This method is called when the object should save its state to the buffer.
ErrorCode
Definition: property.h:218
LoadState
Definition: property.h:198
@ LS_UNLOADED
Definition: property.h:199
void(* BeforeTablesUnloadCallback)()
Definition: table_object.h:7