Today's the day. Renamed platform to framework.
This commit is contained in:
85
privatepool/PrivatePoolEntry.h
Normal file
85
privatepool/PrivatePoolEntry.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* PrivatePoolEntry.h
|
||||
*
|
||||
* Created on: 13.03.2014
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef PRIVATEPOOLENTRY_H_
|
||||
#define PRIVATEPOOLENTRY_H_
|
||||
|
||||
#include <framework/container/IsDerivedFrom.h>
|
||||
#include <framework/container/SinglyLinkedList.h>
|
||||
#include <framework/privatepool/PrivatePoolIF.h>
|
||||
#include <framework/serialize/SerializeAdapter.h>
|
||||
#include <utility>
|
||||
|
||||
template<class T, typename = void>
|
||||
class PrivatePoolEntry: public PrivatePoolIF, public LinkedElement<PrivatePoolIF> {
|
||||
public:
|
||||
PrivatePoolEntry() : LinkedElement<PrivatePoolIF>(this),
|
||||
address(0), element(0) {
|
||||
}
|
||||
PrivatePoolEntry(uint32_t address, T value) : LinkedElement<PrivatePoolIF>(this),
|
||||
address(address), element(value) {
|
||||
}
|
||||
|
||||
uint32_t address;
|
||||
|
||||
T element;
|
||||
|
||||
operator T() {
|
||||
return element;
|
||||
}
|
||||
|
||||
PrivatePoolEntry<T> &operator =(T value) {
|
||||
element = value;
|
||||
return *this;
|
||||
}
|
||||
ReturnValue_t handleMemoryLoad(uint32_t address, const uint8_t* data, uint32_t size, uint8_t** dataPointer) {
|
||||
return handleMemoryDump(address, size, dataPointer, NULL);
|
||||
}
|
||||
ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size, uint8_t** dataPointer, uint8_t* dumpTarget ) {
|
||||
if (this->address != address) {
|
||||
return INVALID_ADDRESS;
|
||||
}
|
||||
if (size != sizeof(element)) {
|
||||
return INVALID_SIZE;
|
||||
}
|
||||
*dataPointer = (uint8_t*)&element;
|
||||
return POINTS_TO_VARIABLE;
|
||||
}
|
||||
ReturnValue_t setAddress(uint32_t* setAddress ) {
|
||||
address = *setAddress;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
return SerializeAdapter<T>::serialize(&element, buffer, size, max_size, bigEndian);
|
||||
}
|
||||
|
||||
uint32_t getSerializedSize() const {
|
||||
return SerializeAdapter<T>::getSerializedSize(&element);
|
||||
}
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return SerializeAdapter<T>::deSerialize(&element, buffer, size, bigEndian);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class PrivatePoolEntry<T, typename enable_if<IsDerivedFrom<T, PrivatePoolIF>::Is>::type> : public LinkedElement<PrivatePoolIF>, public T {
|
||||
public:
|
||||
//TODO: Have a look on how std::forward works.
|
||||
template<typename... Args>
|
||||
PrivatePoolEntry(Args... args) : LinkedElement<PrivatePoolIF>(this), T(std::forward<Args>(args)...) {
|
||||
|
||||
}
|
||||
virtual ~PrivatePoolEntry() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* PRIVATEPOOLENTRY_H_ */
|
22
privatepool/PrivatePoolIF.h
Normal file
22
privatepool/PrivatePoolIF.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* PrivatePoolIF.h
|
||||
*
|
||||
* Created on: 20.03.2014
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef PRIVATEPOOLIF_H_
|
||||
#define PRIVATEPOOLIF_H_
|
||||
#include <framework/memory/HasMemoryIF.h>
|
||||
#include <framework/serialize/SerializeIF.h>
|
||||
|
||||
class PrivatePoolIF : public HasMemoryIF, public SerializeIF {
|
||||
public:
|
||||
virtual ~PrivatePoolIF() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* PRIVATEPOOLIF_H_ */
|
29
privatepool/SetAddressListAdapter.h
Normal file
29
privatepool/SetAddressListAdapter.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* SetAddressListAdapter.h
|
||||
*
|
||||
* Created on: 24.04.2014
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef SETADDRESSLISTADAPTER_H_
|
||||
#define SETADDRESSLISTADAPTER_H_
|
||||
#include <framework/container/SinglyLinkedList.h>
|
||||
#include <framework/memory/HasMemoryIF.h>
|
||||
|
||||
template <typename T>
|
||||
class SetAddressListAdapter {
|
||||
public:
|
||||
static ReturnValue_t setAddresses(const LinkedElement<T>* element, uint32_t startFrom) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) {
|
||||
result = element->value->setAddress(&startFrom);
|
||||
element = element->getNext();
|
||||
startFrom++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* SETADDRESSLISTADAPTER_H_ */
|
Reference in New Issue
Block a user