Merge remote-tracking branch 'upstream/master' into mueller_StoreAccessor
This commit is contained in:
commit
e20244b0ce
61
globalfunctions/printer.cpp
Normal file
61
globalfunctions/printer.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include <framework/globalfunctions/printer.h>
|
||||||
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
|
void printer::print(const uint8_t *data, size_t size, OutputType type,
|
||||||
|
bool printInfo, size_t maxCharPerLine) {
|
||||||
|
if(printInfo) {
|
||||||
|
sif::info << "Printing data with size " << size << ": ";
|
||||||
|
}
|
||||||
|
sif::info << "[";
|
||||||
|
if(type == OutputType::HEX) {
|
||||||
|
printer::printHex(data, size, maxCharPerLine);
|
||||||
|
}
|
||||||
|
else if (type == OutputType::DEC) {
|
||||||
|
printer::printDec(data, size, maxCharPerLine);
|
||||||
|
}
|
||||||
|
else if(type == OutputType::BIN) {
|
||||||
|
printer::printBin(data, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void printer::printHex(const uint8_t *data, size_t size,
|
||||||
|
size_t maxCharPerLine) {
|
||||||
|
sif::info << std::hex;
|
||||||
|
for(size_t i = 0; i < size; i++) {
|
||||||
|
sif::info << "0x" << static_cast<int>(data[i]);
|
||||||
|
if(i < size - 1){
|
||||||
|
sif::info << " , ";
|
||||||
|
if(i > 0 and i % maxCharPerLine == 0) {
|
||||||
|
sif::info << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
sif::info << std::dec;
|
||||||
|
sif::info << "]" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void printer::printDec(const uint8_t *data, size_t size,
|
||||||
|
size_t maxCharPerLine) {
|
||||||
|
sif::info << std::dec;
|
||||||
|
for(size_t i = 0; i < size; i++) {
|
||||||
|
sif::info << static_cast<int>(data[i]);
|
||||||
|
if(i < size - 1){
|
||||||
|
sif::info << " , ";
|
||||||
|
if(i > 0 and i % maxCharPerLine == 0) {
|
||||||
|
sif::info << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sif::info << "]" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void printer::printBin(const uint8_t *data, size_t size) {
|
||||||
|
sif::info << "\n" << std::flush;
|
||||||
|
for(size_t i = 0; i < size; i++) {
|
||||||
|
sif::info << "Byte " << i + 1 << ": 0b"<<
|
||||||
|
std::bitset<8>(data[i]) << ",\n" << std::flush;
|
||||||
|
}
|
||||||
|
sif::info << "]" << std::endl;
|
||||||
|
}
|
21
globalfunctions/printer.h
Normal file
21
globalfunctions/printer.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_
|
||||||
|
#define FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace printer {
|
||||||
|
|
||||||
|
enum class OutputType {
|
||||||
|
DEC,
|
||||||
|
HEX,
|
||||||
|
BIN
|
||||||
|
};
|
||||||
|
|
||||||
|
void print(const uint8_t* data, size_t size, OutputType type = OutputType::HEX,
|
||||||
|
bool printInfo = true, size_t maxCharPerLine = 12);
|
||||||
|
void printHex(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
||||||
|
void printDec(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
||||||
|
void printBin(const uint8_t* data, size_t size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */
|
@ -1,3 +1,12 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
/**
|
||||||
|
* @file LocalPool
|
||||||
|
* @date 02.02.2012
|
||||||
|
* @author Bastian Baetz
|
||||||
|
* @brief This file contains the definition of the LocalPool class.
|
||||||
|
*/
|
||||||
|
>>>>>>> upstream/master
|
||||||
#ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_
|
#ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_
|
||||||
#define FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_
|
#define FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_
|
||||||
|
|
||||||
@ -24,7 +33,6 @@
|
|||||||
* The local pool is NOT thread-safe.
|
* The local pool is NOT thread-safe.
|
||||||
* @author Bastian Baetz
|
* @author Bastian Baetz
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<uint8_t NUMBER_OF_POOLS = 5>
|
template<uint8_t NUMBER_OF_POOLS = 5>
|
||||||
class LocalPool: public SystemObject, public StorageManagerIF {
|
class LocalPool: public SystemObject, public StorageManagerIF {
|
||||||
public:
|
public:
|
||||||
@ -48,9 +56,10 @@ public:
|
|||||||
* number of elements for each pool is determined.
|
* number of elements for each pool is determined.
|
||||||
* The position of these values correspond to those in
|
* The position of these values correspond to those in
|
||||||
* element_sizes.
|
* element_sizes.
|
||||||
* @param registered Register the pool in object manager or not. Default is false (local pool).
|
* @param registered Register the pool in object manager or not.
|
||||||
* @param spillsToHigherPools
|
* Default is false (local pool).
|
||||||
* A variable to determine whether higher n pools are used if the store is full.
|
* @param spillsToHigherPools A variable to determine whether
|
||||||
|
* higher n pools are used if the store is full.
|
||||||
*/
|
*/
|
||||||
LocalPool(object_id_t setObjectId,
|
LocalPool(object_id_t setObjectId,
|
||||||
const uint16_t element_sizes[NUMBER_OF_POOLS],
|
const uint16_t element_sizes[NUMBER_OF_POOLS],
|
||||||
@ -117,7 +126,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief store represents the actual memory pool.
|
* @brief store represents the actual memory pool.
|
||||||
* @details It is an array of pointers to memory, which was allocated with
|
* @details It is an array of pointers to memory, which was allocated with
|
||||||
* a \c new call on construction.
|
* a @c new call on construction.
|
||||||
*/
|
*/
|
||||||
uint8_t* store[NUMBER_OF_POOLS];
|
uint8_t* store[NUMBER_OF_POOLS];
|
||||||
/**
|
/**
|
||||||
|
@ -22,11 +22,20 @@ public:
|
|||||||
//! @brief In the PoolManager's destructor all allocated memory is freed.
|
//! @brief In the PoolManager's destructor all allocated memory is freed.
|
||||||
virtual ~PoolManager();
|
virtual ~PoolManager();
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
//! @brief LocalPool overrides for thread-safety. Decorator function which
|
//! @brief LocalPool overrides for thread-safety. Decorator function which
|
||||||
//! wraps LocalPool calls with a mutex protection.
|
//! wraps LocalPool calls with a mutex protection.
|
||||||
ReturnValue_t deleteData(store_address_t) override;
|
ReturnValue_t deleteData(store_address_t) override;
|
||||||
ReturnValue_t deleteData(uint8_t* buffer, size_t size,
|
ReturnValue_t deleteData(uint8_t* buffer, size_t size,
|
||||||
store_address_t* storeId = nullptr) override;
|
store_address_t* storeId = nullptr) override;
|
||||||
|
=======
|
||||||
|
//! @brief LocalPool overrides for thread-safety.
|
||||||
|
ReturnValue_t deleteData(store_address_t) override;
|
||||||
|
ReturnValue_t deleteData(uint8_t* buffer, size_t size,
|
||||||
|
store_address_t* storeId = NULL) override;
|
||||||
|
ReturnValue_t modifyData(store_address_t packet_id, uint8_t** packet_ptr,
|
||||||
|
size_t* size) override;
|
||||||
|
>>>>>>> upstream/master
|
||||||
protected:
|
protected:
|
||||||
ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address,
|
ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address,
|
||||||
bool ignoreFault) override;
|
bool ignoreFault) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user