helper class OneRemoteConfigProvider

This commit is contained in:
Robin Müller 2022-09-08 16:25:19 +02:00
parent b73754dfd6
commit 34dd478848
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 24 additions and 0 deletions

View File

@ -131,3 +131,7 @@ bool cfdp::VarLenField::operator<(const cfdp::VarLenField &other) const {
bool cfdp::VarLenField::operator==(const cfdp::VarLenField &other) const {
return getWidth() == other.getWidth() and getValue() == other.getValue();
}
bool cfdp::VarLenField::operator!=(const cfdp::VarLenField &other) const {
return not(*this == other);
}

View File

@ -27,6 +27,7 @@ class VarLenField : public SerializeIF {
VarLenField(cfdp::WidthInBytes width, size_t value);
bool operator==(const VarLenField &other) const;
bool operator!=(const VarLenField &other) const;
bool operator<(const VarLenField &other) const;
ReturnValue_t setValue(cfdp::WidthInBytes, size_t value);

View File

@ -11,6 +11,25 @@ class RemoteConfigTableIF {
virtual bool getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) = 0;
};
/**
* Helper class for the common case that there is exactly one remote entity
*/
class OneRemoteConfigProvider : public RemoteConfigTableIF {
public:
explicit OneRemoteConfigProvider(RemoteEntityCfg cfg) : cfg(std::move(cfg)) {}
bool getRemoteCfg(const EntityId& remoteId, cfdp::RemoteEntityCfg** cfg_) override {
if (remoteId != cfg.remoteId) {
return false;
}
*cfg_ = &cfg;
return true;
}
private:
RemoteEntityCfg cfg;
};
} // namespace cfdp
#endif // FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H