2020-09-29 14:51:08 +02:00
|
|
|
#ifndef FSFW_STORAGEMANAGER_STOREADDRESS_H_
|
|
|
|
#define FSFW_STORAGEMANAGER_STOREADDRESS_H_
|
|
|
|
|
2020-05-29 16:37:46 +02:00
|
|
|
#include <cstdint>
|
|
|
|
|
2020-10-15 13:43:23 +02:00
|
|
|
namespace storeId {
|
|
|
|
static constexpr uint32_t INVALID_STORE_ADDRESS = 0xffffffff;
|
|
|
|
}
|
|
|
|
|
2020-05-29 16:37:46 +02:00
|
|
|
/**
|
|
|
|
* This union defines the type that identifies where a data packet is
|
|
|
|
* stored in the store. It comprises of a raw part to read it as raw value and
|
|
|
|
* a structured part to use it in pool-like stores.
|
|
|
|
*/
|
|
|
|
union store_address_t {
|
2020-10-15 13:43:23 +02:00
|
|
|
|
2020-05-29 16:37:46 +02:00
|
|
|
/**
|
|
|
|
* Default Constructor, initializing to INVALID_ADDRESS
|
|
|
|
*/
|
2020-10-15 13:43:23 +02:00
|
|
|
store_address_t(): raw(storeId::INVALID_STORE_ADDRESS){}
|
2020-05-29 16:37:46 +02:00
|
|
|
/**
|
|
|
|
* Constructor to create an address object using the raw address
|
|
|
|
*
|
|
|
|
* @param rawAddress
|
|
|
|
*/
|
|
|
|
store_address_t(uint32_t rawAddress):raw(rawAddress){}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor to create an address object using pool
|
|
|
|
* and packet indices
|
|
|
|
*
|
|
|
|
* @param poolIndex
|
|
|
|
* @param packetIndex
|
|
|
|
*/
|
|
|
|
store_address_t(uint16_t poolIndex, uint16_t packetIndex):
|
2020-10-15 13:43:23 +02:00
|
|
|
poolIndex(poolIndex), packetIndex(packetIndex){}
|
2020-05-29 16:37:46 +02:00
|
|
|
/**
|
|
|
|
* A structure with two elements to access the store address pool-like.
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
/**
|
|
|
|
* The index in which pool the packet lies.
|
|
|
|
*/
|
2020-10-15 13:43:23 +02:00
|
|
|
uint16_t poolIndex;
|
2020-05-29 16:37:46 +02:00
|
|
|
/**
|
|
|
|
* The position in the chosen pool.
|
|
|
|
*/
|
2020-10-15 13:43:23 +02:00
|
|
|
uint16_t packetIndex;
|
2020-05-29 16:37:46 +02:00
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Alternative access to the raw value.
|
|
|
|
*/
|
|
|
|
uint32_t raw;
|
|
|
|
|
|
|
|
bool operator==(const store_address_t& other) const {
|
|
|
|
return raw == other.raw;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-09-29 14:51:08 +02:00
|
|
|
#endif /* FSFW_STORAGEMANAGER_STOREADDRESS_H_ */
|