renormalized line endings
This commit is contained in:
@ -1,40 +1,40 @@
|
||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
||||
|
||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||
#include "../../serialize/SerializeAdapter.h"
|
||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
||||
|
||||
class ApidMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||
private:
|
||||
uint16_t apid;
|
||||
public:
|
||||
ApidMatcher(uint16_t setApid) :
|
||||
apid(setApid) {
|
||||
}
|
||||
ApidMatcher(TmPacketMinimal* test) :
|
||||
apid(test->getAPID()) {
|
||||
}
|
||||
bool match(TmPacketMinimal* packet) {
|
||||
if (packet->getAPID() == apid) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
size_t getSerializedSize() const {
|
||||
return SerializeAdapter::getSerializedSize(&apid);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */
|
||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
||||
|
||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||
#include "../../serialize/SerializeAdapter.h"
|
||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
||||
|
||||
class ApidMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||
private:
|
||||
uint16_t apid;
|
||||
public:
|
||||
ApidMatcher(uint16_t setApid) :
|
||||
apid(setApid) {
|
||||
}
|
||||
ApidMatcher(TmPacketMinimal* test) :
|
||||
apid(test->getAPID()) {
|
||||
}
|
||||
bool match(TmPacketMinimal* packet) {
|
||||
if (packet->getAPID() == apid) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
size_t getSerializedSize() const {
|
||||
return SerializeAdapter::getSerializedSize(&apid);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */
|
||||
|
@ -1,195 +1,195 @@
|
||||
#include "../../tmtcpacket/packetmatcher/ApidMatcher.h"
|
||||
#include "../../tmtcpacket/packetmatcher/PacketMatchTree.h"
|
||||
#include "../../tmtcpacket/packetmatcher/ServiceMatcher.h"
|
||||
#include "../../tmtcpacket/packetmatcher/SubserviceMatcher.h"
|
||||
|
||||
PacketMatchTree::PacketMatchTree(Node* root) :
|
||||
MatchTree<TmPacketMinimal*>(root, 2), factoryBackend(0, POOL_SIZES,
|
||||
N_ELEMENTS, false, true), factory(&factoryBackend) {
|
||||
}
|
||||
|
||||
PacketMatchTree::PacketMatchTree(iterator root) :
|
||||
MatchTree<TmPacketMinimal*>(root.element, 2), factoryBackend(0,
|
||||
POOL_SIZES, N_ELEMENTS, false, true), factory(&factoryBackend) {
|
||||
}
|
||||
|
||||
PacketMatchTree::PacketMatchTree() :
|
||||
MatchTree<TmPacketMinimal*>((Node*) NULL, 2), factoryBackend(0,
|
||||
POOL_SIZES, N_ELEMENTS, false, true), factory(&factoryBackend) {
|
||||
}
|
||||
|
||||
PacketMatchTree::~PacketMatchTree() {
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type,
|
||||
uint8_t subtype) {
|
||||
//We assume adding APID is always requested.
|
||||
TmPacketMinimal::TmPacketMinimalPointer data;
|
||||
data.data_field.service_type = type;
|
||||
data.data_field.service_subtype = subtype;
|
||||
TmPacketMinimal testPacket((uint8_t*) &data);
|
||||
testPacket.setAPID(apid);
|
||||
iterator lastTest;
|
||||
iterator rollback;
|
||||
ReturnValue_t result = findOrInsertMatch<TmPacketMinimal*, ApidMatcher>(
|
||||
this->begin(), &testPacket, &lastTest);
|
||||
if (result == NEW_NODE_CREATED) {
|
||||
rollback = lastTest;
|
||||
} else if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
if (type == 0) {
|
||||
//Check if lastTest has no children, otherwise, delete them,
|
||||
//as a more general check is requested.
|
||||
if (lastTest.left() != this->end()) {
|
||||
removeElementAndAllChildren(lastTest.left());
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
//Type insertion required.
|
||||
result = findOrInsertMatch<TmPacketMinimal*, ServiceMatcher>(
|
||||
lastTest.left(), &testPacket, &lastTest);
|
||||
if (result == NEW_NODE_CREATED) {
|
||||
if (rollback == this->end()) {
|
||||
rollback = lastTest;
|
||||
}
|
||||
} else if (result != RETURN_OK) {
|
||||
if (rollback != this->end()) {
|
||||
removeElementAndAllChildren(rollback);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (subtype == 0) {
|
||||
if (lastTest.left() != this->end()) {
|
||||
//See above
|
||||
removeElementAndAllChildren(lastTest.left());
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
//Subtype insertion required.
|
||||
result = findOrInsertMatch<TmPacketMinimal*, SubServiceMatcher>(
|
||||
lastTest.left(), &testPacket, &lastTest);
|
||||
if (result == NEW_NODE_CREATED) {
|
||||
return RETURN_OK;
|
||||
} else if (result != RETURN_OK) {
|
||||
if (rollback != this->end()) {
|
||||
removeElementAndAllChildren(rollback);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename VALUE_T, typename INSERTION_T>
|
||||
ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test,
|
||||
iterator* lastTest) {
|
||||
bool attachToBranch = AND;
|
||||
iterator iter = startAt;
|
||||
while (iter != this->end()) {
|
||||
bool isMatch = iter->match(test);
|
||||
attachToBranch = OR;
|
||||
*lastTest = iter;
|
||||
if (isMatch) {
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
//Go down OR branch.
|
||||
iter = iter.right();
|
||||
}
|
||||
}
|
||||
//Only reached if nothing was found.
|
||||
SerializeableMatcherIF<VALUE_T>* newContent = factory.generate<INSERTION_T>(
|
||||
test);
|
||||
if (newContent == NULL) {
|
||||
return FULL;
|
||||
}
|
||||
Node* newNode = factory.generate<Node>(newContent);
|
||||
if (newNode == NULL) {
|
||||
//Need to make sure partially generated content is deleted, otherwise, that's a leak.
|
||||
factory.destroy<INSERTION_T>(static_cast<INSERTION_T*>(newContent));
|
||||
return FULL;
|
||||
}
|
||||
*lastTest = insert(attachToBranch, *lastTest, newNode);
|
||||
if (*lastTest == end()) {
|
||||
//This actaully never fails, so creating a dedicated returncode seems an overshoot.
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return NEW_NODE_CREATED;
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type,
|
||||
uint8_t subtype) {
|
||||
TmPacketMinimal::TmPacketMinimalPointer data;
|
||||
data.data_field.service_type = type;
|
||||
data.data_field.service_subtype = subtype;
|
||||
TmPacketMinimal testPacket((uint8_t*) &data);
|
||||
testPacket.setAPID(apid);
|
||||
iterator foundElement = findMatch(begin(), &testPacket);
|
||||
if (foundElement == this->end()) {
|
||||
return NO_MATCH;
|
||||
}
|
||||
if (type == 0) {
|
||||
if (foundElement.left() == end()) {
|
||||
return removeElementAndReconnectChildren(foundElement);
|
||||
} else {
|
||||
return TOO_GENERAL_REQUEST;
|
||||
}
|
||||
}
|
||||
//Go down AND branch. Will abort if empty.
|
||||
foundElement = findMatch(foundElement.left(), &testPacket);
|
||||
if (foundElement == this->end()) {
|
||||
return NO_MATCH;
|
||||
}
|
||||
if (subtype == 0) {
|
||||
if (foundElement.left() == end()) {
|
||||
return removeElementAndReconnectChildren(foundElement);
|
||||
} else {
|
||||
return TOO_GENERAL_REQUEST;
|
||||
}
|
||||
}
|
||||
//Again, go down AND branch.
|
||||
foundElement = findMatch(foundElement.left(), &testPacket);
|
||||
if (foundElement == end()) {
|
||||
return NO_MATCH;
|
||||
}
|
||||
return removeElementAndReconnectChildren(foundElement);
|
||||
}
|
||||
|
||||
PacketMatchTree::iterator PacketMatchTree::findMatch(iterator startAt,
|
||||
TmPacketMinimal* test) {
|
||||
iterator iter = startAt;
|
||||
while (iter != end()) {
|
||||
bool isMatch = iter->match(test);
|
||||
if (isMatch) {
|
||||
break;
|
||||
} else {
|
||||
iter = iter.right(); //next OR element
|
||||
}
|
||||
}
|
||||
return iter;
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::initialize() {
|
||||
return factoryBackend.initialize();
|
||||
}
|
||||
|
||||
const uint16_t PacketMatchTree::POOL_SIZES[N_POOLS] = { sizeof(ServiceMatcher),
|
||||
sizeof(SubServiceMatcher), sizeof(ApidMatcher),
|
||||
sizeof(PacketMatchTree::Node) };
|
||||
//Maximum number of types and subtypes to filter should be more than sufficient.
|
||||
const uint16_t PacketMatchTree::N_ELEMENTS[N_POOLS] = { 10, 20, 2, 40 };
|
||||
|
||||
ReturnValue_t PacketMatchTree::changeMatch(bool addToMatch, uint16_t apid,
|
||||
uint8_t type, uint8_t subtype) {
|
||||
if (addToMatch) {
|
||||
return addMatch(apid, type, subtype);
|
||||
} else {
|
||||
return removeMatch(apid, type, subtype);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::cleanUpElement(iterator position) {
|
||||
factory.destroy(position.element->value);
|
||||
//Go on anyway, there's nothing we can do.
|
||||
//SHOULDDO: Throw event, or write debug message?
|
||||
return factory.destroy(position.element);
|
||||
}
|
||||
#include "../../tmtcpacket/packetmatcher/ApidMatcher.h"
|
||||
#include "../../tmtcpacket/packetmatcher/PacketMatchTree.h"
|
||||
#include "../../tmtcpacket/packetmatcher/ServiceMatcher.h"
|
||||
#include "../../tmtcpacket/packetmatcher/SubserviceMatcher.h"
|
||||
|
||||
PacketMatchTree::PacketMatchTree(Node* root) :
|
||||
MatchTree<TmPacketMinimal*>(root, 2), factoryBackend(0, POOL_SIZES,
|
||||
N_ELEMENTS, false, true), factory(&factoryBackend) {
|
||||
}
|
||||
|
||||
PacketMatchTree::PacketMatchTree(iterator root) :
|
||||
MatchTree<TmPacketMinimal*>(root.element, 2), factoryBackend(0,
|
||||
POOL_SIZES, N_ELEMENTS, false, true), factory(&factoryBackend) {
|
||||
}
|
||||
|
||||
PacketMatchTree::PacketMatchTree() :
|
||||
MatchTree<TmPacketMinimal*>((Node*) NULL, 2), factoryBackend(0,
|
||||
POOL_SIZES, N_ELEMENTS, false, true), factory(&factoryBackend) {
|
||||
}
|
||||
|
||||
PacketMatchTree::~PacketMatchTree() {
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type,
|
||||
uint8_t subtype) {
|
||||
//We assume adding APID is always requested.
|
||||
TmPacketMinimal::TmPacketMinimalPointer data;
|
||||
data.data_field.service_type = type;
|
||||
data.data_field.service_subtype = subtype;
|
||||
TmPacketMinimal testPacket((uint8_t*) &data);
|
||||
testPacket.setAPID(apid);
|
||||
iterator lastTest;
|
||||
iterator rollback;
|
||||
ReturnValue_t result = findOrInsertMatch<TmPacketMinimal*, ApidMatcher>(
|
||||
this->begin(), &testPacket, &lastTest);
|
||||
if (result == NEW_NODE_CREATED) {
|
||||
rollback = lastTest;
|
||||
} else if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
if (type == 0) {
|
||||
//Check if lastTest has no children, otherwise, delete them,
|
||||
//as a more general check is requested.
|
||||
if (lastTest.left() != this->end()) {
|
||||
removeElementAndAllChildren(lastTest.left());
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
//Type insertion required.
|
||||
result = findOrInsertMatch<TmPacketMinimal*, ServiceMatcher>(
|
||||
lastTest.left(), &testPacket, &lastTest);
|
||||
if (result == NEW_NODE_CREATED) {
|
||||
if (rollback == this->end()) {
|
||||
rollback = lastTest;
|
||||
}
|
||||
} else if (result != RETURN_OK) {
|
||||
if (rollback != this->end()) {
|
||||
removeElementAndAllChildren(rollback);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (subtype == 0) {
|
||||
if (lastTest.left() != this->end()) {
|
||||
//See above
|
||||
removeElementAndAllChildren(lastTest.left());
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
//Subtype insertion required.
|
||||
result = findOrInsertMatch<TmPacketMinimal*, SubServiceMatcher>(
|
||||
lastTest.left(), &testPacket, &lastTest);
|
||||
if (result == NEW_NODE_CREATED) {
|
||||
return RETURN_OK;
|
||||
} else if (result != RETURN_OK) {
|
||||
if (rollback != this->end()) {
|
||||
removeElementAndAllChildren(rollback);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
template<typename VALUE_T, typename INSERTION_T>
|
||||
ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test,
|
||||
iterator* lastTest) {
|
||||
bool attachToBranch = AND;
|
||||
iterator iter = startAt;
|
||||
while (iter != this->end()) {
|
||||
bool isMatch = iter->match(test);
|
||||
attachToBranch = OR;
|
||||
*lastTest = iter;
|
||||
if (isMatch) {
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
//Go down OR branch.
|
||||
iter = iter.right();
|
||||
}
|
||||
}
|
||||
//Only reached if nothing was found.
|
||||
SerializeableMatcherIF<VALUE_T>* newContent = factory.generate<INSERTION_T>(
|
||||
test);
|
||||
if (newContent == NULL) {
|
||||
return FULL;
|
||||
}
|
||||
Node* newNode = factory.generate<Node>(newContent);
|
||||
if (newNode == NULL) {
|
||||
//Need to make sure partially generated content is deleted, otherwise, that's a leak.
|
||||
factory.destroy<INSERTION_T>(static_cast<INSERTION_T*>(newContent));
|
||||
return FULL;
|
||||
}
|
||||
*lastTest = insert(attachToBranch, *lastTest, newNode);
|
||||
if (*lastTest == end()) {
|
||||
//This actaully never fails, so creating a dedicated returncode seems an overshoot.
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return NEW_NODE_CREATED;
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type,
|
||||
uint8_t subtype) {
|
||||
TmPacketMinimal::TmPacketMinimalPointer data;
|
||||
data.data_field.service_type = type;
|
||||
data.data_field.service_subtype = subtype;
|
||||
TmPacketMinimal testPacket((uint8_t*) &data);
|
||||
testPacket.setAPID(apid);
|
||||
iterator foundElement = findMatch(begin(), &testPacket);
|
||||
if (foundElement == this->end()) {
|
||||
return NO_MATCH;
|
||||
}
|
||||
if (type == 0) {
|
||||
if (foundElement.left() == end()) {
|
||||
return removeElementAndReconnectChildren(foundElement);
|
||||
} else {
|
||||
return TOO_GENERAL_REQUEST;
|
||||
}
|
||||
}
|
||||
//Go down AND branch. Will abort if empty.
|
||||
foundElement = findMatch(foundElement.left(), &testPacket);
|
||||
if (foundElement == this->end()) {
|
||||
return NO_MATCH;
|
||||
}
|
||||
if (subtype == 0) {
|
||||
if (foundElement.left() == end()) {
|
||||
return removeElementAndReconnectChildren(foundElement);
|
||||
} else {
|
||||
return TOO_GENERAL_REQUEST;
|
||||
}
|
||||
}
|
||||
//Again, go down AND branch.
|
||||
foundElement = findMatch(foundElement.left(), &testPacket);
|
||||
if (foundElement == end()) {
|
||||
return NO_MATCH;
|
||||
}
|
||||
return removeElementAndReconnectChildren(foundElement);
|
||||
}
|
||||
|
||||
PacketMatchTree::iterator PacketMatchTree::findMatch(iterator startAt,
|
||||
TmPacketMinimal* test) {
|
||||
iterator iter = startAt;
|
||||
while (iter != end()) {
|
||||
bool isMatch = iter->match(test);
|
||||
if (isMatch) {
|
||||
break;
|
||||
} else {
|
||||
iter = iter.right(); //next OR element
|
||||
}
|
||||
}
|
||||
return iter;
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::initialize() {
|
||||
return factoryBackend.initialize();
|
||||
}
|
||||
|
||||
const uint16_t PacketMatchTree::POOL_SIZES[N_POOLS] = { sizeof(ServiceMatcher),
|
||||
sizeof(SubServiceMatcher), sizeof(ApidMatcher),
|
||||
sizeof(PacketMatchTree::Node) };
|
||||
//Maximum number of types and subtypes to filter should be more than sufficient.
|
||||
const uint16_t PacketMatchTree::N_ELEMENTS[N_POOLS] = { 10, 20, 2, 40 };
|
||||
|
||||
ReturnValue_t PacketMatchTree::changeMatch(bool addToMatch, uint16_t apid,
|
||||
uint8_t type, uint8_t subtype) {
|
||||
if (addToMatch) {
|
||||
return addMatch(apid, type, subtype);
|
||||
} else {
|
||||
return removeMatch(apid, type, subtype);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PacketMatchTree::cleanUpElement(iterator position) {
|
||||
factory.destroy(position.element->value);
|
||||
//Go on anyway, there's nothing we can do.
|
||||
//SHOULDDO: Throw event, or write debug message?
|
||||
return factory.destroy(position.element);
|
||||
}
|
||||
|
@ -1,36 +1,36 @@
|
||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
||||
|
||||
#include "../../container/PlacementFactory.h"
|
||||
#include "../../globalfunctions/matching/MatchTree.h"
|
||||
#include "../../storagemanager/LocalPool.h"
|
||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
||||
|
||||
class PacketMatchTree: public MatchTree<TmPacketMinimal*>, public HasReturnvaluesIF {
|
||||
public:
|
||||
PacketMatchTree(Node* root);
|
||||
PacketMatchTree(iterator root);
|
||||
PacketMatchTree();
|
||||
virtual ~PacketMatchTree();
|
||||
ReturnValue_t changeMatch(bool addToMatch, uint16_t apid, uint8_t type = 0,
|
||||
uint8_t subtype = 0);
|
||||
ReturnValue_t addMatch(uint16_t apid, uint8_t type = 0,
|
||||
uint8_t subtype = 0);
|
||||
ReturnValue_t removeMatch(uint16_t apid, uint8_t type = 0,
|
||||
uint8_t subtype = 0);
|
||||
ReturnValue_t initialize();
|
||||
protected:
|
||||
ReturnValue_t cleanUpElement(iterator position);
|
||||
private:
|
||||
static const uint8_t N_POOLS = 4;
|
||||
LocalPool<N_POOLS> factoryBackend;
|
||||
PlacementFactory factory;
|
||||
static const uint16_t POOL_SIZES[N_POOLS];
|
||||
static const uint16_t N_ELEMENTS[N_POOLS];
|
||||
template<typename VALUE_T, typename INSERTION_T>
|
||||
ReturnValue_t findOrInsertMatch(iterator startAt, VALUE_T test, iterator* lastTest);
|
||||
iterator findMatch(iterator startAt, TmPacketMinimal* test);
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_ */
|
||||
|
||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
||||
|
||||
#include "../../container/PlacementFactory.h"
|
||||
#include "../../globalfunctions/matching/MatchTree.h"
|
||||
#include "../../storagemanager/LocalPool.h"
|
||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
||||
|
||||
class PacketMatchTree: public MatchTree<TmPacketMinimal*>, public HasReturnvaluesIF {
|
||||
public:
|
||||
PacketMatchTree(Node* root);
|
||||
PacketMatchTree(iterator root);
|
||||
PacketMatchTree();
|
||||
virtual ~PacketMatchTree();
|
||||
ReturnValue_t changeMatch(bool addToMatch, uint16_t apid, uint8_t type = 0,
|
||||
uint8_t subtype = 0);
|
||||
ReturnValue_t addMatch(uint16_t apid, uint8_t type = 0,
|
||||
uint8_t subtype = 0);
|
||||
ReturnValue_t removeMatch(uint16_t apid, uint8_t type = 0,
|
||||
uint8_t subtype = 0);
|
||||
ReturnValue_t initialize();
|
||||
protected:
|
||||
ReturnValue_t cleanUpElement(iterator position);
|
||||
private:
|
||||
static const uint8_t N_POOLS = 4;
|
||||
LocalPool<N_POOLS> factoryBackend;
|
||||
PlacementFactory factory;
|
||||
static const uint16_t POOL_SIZES[N_POOLS];
|
||||
static const uint16_t N_ELEMENTS[N_POOLS];
|
||||
template<typename VALUE_T, typename INSERTION_T>
|
||||
ReturnValue_t findOrInsertMatch(iterator startAt, VALUE_T test, iterator* lastTest);
|
||||
iterator findMatch(iterator startAt, TmPacketMinimal* test);
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_ */
|
||||
|
||||
|
@ -1,39 +1,39 @@
|
||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_SERVICEMATCHER_H_
|
||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_SERVICEMATCHER_H_
|
||||
|
||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||
#include "../../serialize/SerializeAdapter.h"
|
||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
||||
|
||||
class ServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||
private:
|
||||
uint8_t service;
|
||||
public:
|
||||
ServiceMatcher(uint8_t setService) :
|
||||
service(setService) {
|
||||
}
|
||||
ServiceMatcher(TmPacketMinimal* test) :
|
||||
service(test->getService()) {
|
||||
}
|
||||
bool match(TmPacketMinimal* packet) {
|
||||
if (packet->getService() == service) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
return SerializeAdapter::serialize(&service, buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
size_t getSerializedSize() const {
|
||||
return SerializeAdapter::getSerializedSize(&service);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
return SerializeAdapter::deSerialize(&service, buffer, size, streamEndianness);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_SERVICEMATCHER_H_ */
|
||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_SERVICEMATCHER_H_
|
||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_SERVICEMATCHER_H_
|
||||
|
||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||
#include "../../serialize/SerializeAdapter.h"
|
||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
||||
|
||||
class ServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||
private:
|
||||
uint8_t service;
|
||||
public:
|
||||
ServiceMatcher(uint8_t setService) :
|
||||
service(setService) {
|
||||
}
|
||||
ServiceMatcher(TmPacketMinimal* test) :
|
||||
service(test->getService()) {
|
||||
}
|
||||
bool match(TmPacketMinimal* packet) {
|
||||
if (packet->getService() == service) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
return SerializeAdapter::serialize(&service, buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
size_t getSerializedSize() const {
|
||||
return SerializeAdapter::getSerializedSize(&service);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
return SerializeAdapter::deSerialize(&service, buffer, size, streamEndianness);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_SERVICEMATCHER_H_ */
|
||||
|
@ -1,40 +1,40 @@
|
||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
||||
|
||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||
#include "../../serialize/SerializeAdapter.h"
|
||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
||||
|
||||
class SubServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||
public:
|
||||
SubServiceMatcher(uint8_t subService) :
|
||||
subService(subService) {
|
||||
}
|
||||
SubServiceMatcher(TmPacketMinimal* test) :
|
||||
subService(test->getSubService()) {
|
||||
}
|
||||
bool match(TmPacketMinimal* packet) {
|
||||
if (packet->getSubService() == subService) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
return SerializeAdapter::serialize(&subService, buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
size_t getSerializedSize() const {
|
||||
return SerializeAdapter::getSerializedSize(&subService);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
return SerializeAdapter::deSerialize(&subService, buffer, size, streamEndianness);
|
||||
}
|
||||
private:
|
||||
uint8_t subService;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_ */
|
||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
||||
|
||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||
#include "../../serialize/SerializeAdapter.h"
|
||||
#include "../../tmtcpacket/pus/TmPacketMinimal.h"
|
||||
|
||||
class SubServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||
public:
|
||||
SubServiceMatcher(uint8_t subService) :
|
||||
subService(subService) {
|
||||
}
|
||||
SubServiceMatcher(TmPacketMinimal* test) :
|
||||
subService(test->getSubService()) {
|
||||
}
|
||||
bool match(TmPacketMinimal* packet) {
|
||||
if (packet->getSubService() == subService) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
return SerializeAdapter::serialize(&subService, buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
size_t getSerializedSize() const {
|
||||
return SerializeAdapter::getSerializedSize(&subService);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
return SerializeAdapter::deSerialize(&subService, buffer, size, streamEndianness);
|
||||
}
|
||||
private:
|
||||
uint8_t subService;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_ */
|
||||
|
Reference in New Issue
Block a user