#include "canDb_Mock.h"
#include <algorithm>
#include <cstring>
#include <iterator>
tResult CANDb_MOCK::GetMessageCount(tUInt32 * pnMessageCount) const
{
*pnMessageCount = static_cast<tUInt32>(mapMessages.size());
RETURN_NOERROR;
}
tResult CANDb_MOCK::GetMessageID(const tChar * strMessageName, tMessageID * pnMessageID, tBool * pbExtended) const
{
auto it = std::find_if(mapMessages.begin(), mapMessages.end(), [&strMessageName](const auto& it) -> tBool
{
return (std::strcmp(strMessageName,it.second) == 0);
});
if (it != mapMessages.end())
{
*pbExtended = tFalse;
*pnMessageID = it->first;
RETURN_NOERROR;
}
RETURN_ERROR(ERR_INVALID_ARG);
}
tResult CANDb_MOCK::GetMessageName(tMessageID nMessageID, tBool , const tChar **pMessageName) const
{
*pMessageName = mapMessages.at(nMessageID);
RETURN_NOERROR;
}
tResult CANDb_MOCK::GetMessageInfo(tMessageID , tBool ,
const tMessageInfo** )
const
{
RETURN_ERROR(ERR_NOT_IMPL);
}
tResult CANDb_MOCK::GetSignalCount(tUInt32 * pnSignalCount) const
{
*pnSignalCount = static_cast<tUInt32>(setSignals.size());
RETURN_NOERROR;
}
tResult CANDb_MOCK::GetSignalID(const tChar * strSignalName, tSignalID * pnSignalID) const
{
auto it = find_if(setSignals.begin(), setSignals.end(), [&strSignalName](const tChar* it)->bool
{
return (std::strcmp(strSignalName, it) == 0);
});
if (it != setSignals.end())
{
*pnSignalID = static_cast<tSignalID>(std::distance(it, setSignals.begin()));
RETURN_NOERROR;
}
RETURN_ERROR(ERR_INVALID_ARG);
}
tResult CANDb_MOCK::GetSignalName(tSignalID nSignalID, const tChar** pSignalName) const
{
*pSignalName = setSignals.at(nSignalID);
RETURN_NOERROR;
}
tResult CANDb_MOCK::GetSignalUnit(tSignalID , const tChar** ) const
{
RETURN_ERROR(ERR_NOT_IMPL);
}
tResult CANDb_MOCK::GetSignalDescription(tSignalID , const tChar** ) const
{
RETURN_ERROR(ERR_NOT_IMPL);
}
tResult CANDb_MOCK::GetSignalInfo(tSignalID ,
const tSignalInfo** )
const
{
RETURN_ERROR(ERR_NOT_IMPL);
}
tResult CANDb_MOCK::GetNetworkNodes(std::vector<const tChar*>& astrNetworkNodes) const
{
astrNetworkNodes = setNetworkNodes;
RETURN_NOERROR;
}
tResult CANDb_MOCK::GetNetworkNames(std::vector<const tChar*>& astrNetworkNames) const
{
astrNetworkNames = setNetworkNames;
RETURN_NOERROR;
}
Namespace for functionality provided by V3.0.0.