メイン・コンテンツまでスキップ

AbstractPartition

This type defines an abstract interface to a storage partition for allocating memory slots of equal size. The "partition" is not aware of the actual types stored in the partition memory, hence it provides no mechanism for deleting C++ objects when clear()'ed.

Inherited by: Partition< ListOfTypes, NUMBER_OF_ELEMENTS >

Public Functions

template <typename T >
void *
allocate()
Gets the address of the next available storage slot.
virtual void *allocate(uint16_t size)
Gets the address of the next available storage slot.
template <typename T >
void *
allocateAt(uint16_t index)
Gets the address of the specified storage slot.
virtual void *allocateAt(uint16_t index, uint16_t size)
Gets the address of the specified index.
template <typename T >
T &
at(const uint16_t index)
Gets the object at the specified index.
template <typename T >
const T &
at(const uint16_t index) const
const version of at().
virtual uint16_tcapacity() const =0
Gets the capacity, i.e.
virtual voidclear()
Prepares the Partition for new allocations.
voiddec()
Decreases number of allocations.
virtual uint32_telement_size() =0
Access to concrete element-size.
template <class T >
Pair< T *, uint16_t >
find(const void * pT)
Determines if the specified object could have been previously allocated in the partition.
virtual uint16_tgetAllocationCount() const
Gets allocation count.
virtual uint16_tindexOf(const void * address)
Determines index of previously allocated location.
virtual ~AbstractPartition()
Finalizes an instance of the AbstractPartition class.

Protected Functions

AbstractPartition()
Initializes a new instance of the AbstractPartition class.
virtual const void *element(uint16_t index) const =0
Access to stored element, const version.
virtual void *element(uint16_t index) =0
Access to stored element.

Public Functions Documentation

allocate

void * allocate()

Gets the address of the next available storage slot.

The slot size is determined from the size of type T.

Template Parameters:
TGeneric type parameter.
Returns:

The address of an empty storage slot.

Note

Asserts if T is too large, or the storage is depleted.

allocate

virtual void * allocate(uint16_tsize)

Gets the address of the next available storage slot.

The slot size is compared with the specified size.

Parameters:
sizeThe size.
Returns:

The address of an empty storage slot which contains minimum 'size' bytes.

Note

Asserts if 'size' is too large, or the storage is depleted.

allocateAt

void * allocateAt(uint16_tindex)

Gets the address of the specified storage slot.

The slot size is determined from the size of type T.

Template Parameters:
TGeneric type parameter.
Parameters:
indexZero-based index of the.
Returns:

The address of the appropriate storage slot.

Note

Asserts if T is too large.

allocateAt

virtual void * allocateAt(uint16_tindex ,
uint16_tsize
)

Gets the address of the specified index.

Parameters:
indexZero-based index of the.
sizeThe size.
Returns:

The address of the appropriate storage slot which contains minimum 'size' bytes.

Note

Asserts if 'size' is too large.

at

T & at(const uint16_tindex)

Gets the object at the specified index.

Template Parameters:
TGeneric type parameter.
Parameters:
indexThe index into the Partition storage where the returned object is located.
Returns:

A typed reference to the object at the specified index.

at

const T & at(const uint16_tindex)

const version of at().

Template Parameters:
TGeneric type parameter.
Parameters:
indexZero-based index of the.
Returns:

A T&

capacity

virtual uint16_t capacity()const =0

Gets the capacity, i.e.

the maximum allocation count.

Returns:

The maximum allocation count.

Reimplemented by: touchgfx::Partition::capacity

clear

virtual void clear()

Prepares the Partition for new allocations.

Any objects present in the Partition shall not be used after invoking this method.

dec

void dec()

Decreases number of allocations.

element_size

virtual uint32_t element_size()=0

Access to concrete element-size.

Used internally.

Returns:

An uint32_t.

Reimplemented by: touchgfx::Partition::element_size

find

Pair< T *, uint16_t > find(const void *pT)

Determines if the specified object could have been previously allocated in the partition.

Since the Partition concept is loosely typed this method shall be used with care. The method does not guarantee that the found object at the returned index is a valid object. It only tests whether or not the object is within the bounds of the current partition allocations.

Template Parameters:
TGeneric type parameter.
Parameters:
pTPointer to the object to look up.
Returns:

If the object seems to be allocated in the Partition, a Pair object containing a typed pointer to the object and an index into the Partition storage is returned. Otherwise, a Pair<0, 0> is returned.

getAllocationCount

virtual uint16_t getAllocationCount()const

Gets allocation count.

Returns:

The currently allocated storage slots.

indexOf

virtual uint16_t indexOf(const void *address)

Determines index of previously allocated location.

Since the Partition concept is loosely typed this method shall be used with care. The method does not guarantee that the found object at the returned index is a valid object. It only tests whether or not the object is within the bounds of the current partition allocations.

Parameters:
addressThe location address to lookup.
Returns:

An uint16_t.

~AbstractPartition

Finalizes an instance of the AbstractPartition class.

Protected Functions Documentation

AbstractPartition

Initializes a new instance of the AbstractPartition class.

element

virtual const void * element(uint16_tindex)

Access to stored element, const version.

Parameters:
indexZero-based index of the.
Returns:

null if it fails, else a void*.

Reimplemented by: touchgfx::Partition::element

element

virtual void * element(uint16_tindex)

Access to stored element.

Used internally.

Parameters:
indexZero-based index of the.
Returns:

null if it fails, else a void*.

Reimplemented by: touchgfx::Partition::element