ArrayBase.h
Go to the documentation of this file.
1 
20 #pragma once
21 
22 #include "Object.h"
23 #include "Pool.h"
24 
25 namespace ConfigDB
26 {
30 class ArrayBase : public Object
31 {
32 public:
33  using Object::Object;
34 
35  unsigned getItemCount() const
36  {
37  return getId() ? getArray().getCount() : 0;
38  }
39 
40  bool removeItem(unsigned index)
41  {
42  return getArray().remove(index);
43  }
44 
45  void* getItem(unsigned index)
46  {
47  return getArray()[index];
48  }
49 
50  const void* getItem(unsigned index) const
51  {
52  return getArray()[index];
53  }
54 
55  void addItem(const void* value)
56  {
57  getArray().add(value);
58  }
59 
60  void clear();
61 
62  void dispose();
63 
64 protected:
66  {
67  return static_cast<PropertyData*>(getDataPtr())->array;
68  }
69 
70  ArrayId getId() const
71  {
72  return static_cast<const PropertyData*>(getDataPtr())->array;
73  }
74 
76  const ArrayData& getArray() const;
77 };
78 
79 } // namespace ConfigDB
Base class to provide array of properties.
Definition: ArrayBase.h:31
unsigned getItemCount() const
Definition: ArrayBase.h:35
bool removeItem(unsigned index)
Definition: ArrayBase.h:40
ArrayId getId() const
Definition: ArrayBase.h:70
ArrayId & getId()
Definition: ArrayBase.h:65
void * getItem(unsigned index)
Definition: ArrayBase.h:45
void addItem(const void *value)
Definition: ArrayBase.h:55
const ArrayData & getArray() const
const void * getItem(unsigned index) const
Definition: ArrayBase.h:50
ArrayData & getArray()
An array of fixed-sized items.
Definition: Pool.h:222
void * add(const void *data=nullptr, size_t itemCount=1)
Definition: Pool.h:228
bool remove(unsigned index)
An object can contain other objects, properties and arrays.
Definition: Libraries/ConfigDB/src/include/ConfigDB/Object.h:37
Object()
Definition: Libraries/ConfigDB/src/include/ConfigDB/Object.h:39
void * getDataPtr()
size_t getCount() const
Definition: Pool.h:46
Definition: Array.h:26
Identifies array storage within array pool.
Definition: PropertyData.h:31
Definition: PropertyData.h:44