continue;
}
- Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketId());
+ Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(),
+ packet.GetPacketId());
CommandHandlerFunctor* commandHandlerFunctor =
m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(),
namespace profiling
{
-Version PacketVersionResolver::ResolvePacketVersion(uint32_t packetId) const
+bool PacketKey::operator<(const PacketKey& rhs) const
+{
+ bool result = true;
+ if (m_FamilyId == rhs.m_FamilyId)
+ {
+ result = m_PacketId < rhs.m_PacketId;
+ }
+ else if (m_FamilyId > rhs.m_FamilyId)
+ {
+ result = false;
+ }
+ return result;
+}
+
+bool PacketKey::operator>(const PacketKey& rhs) const
+{
+ return rhs < *this;
+}
+
+bool PacketKey::operator<=(const PacketKey& rhs) const
+{
+ return !(*this > rhs);
+}
+
+bool PacketKey::operator>=(const PacketKey& rhs) const
+{
+ return !(*this < rhs);
+}
+
+bool PacketKey::operator==(const PacketKey& rhs) const
+{
+ return m_FamilyId == rhs.m_FamilyId && m_PacketId == rhs.m_PacketId;
+}
+
+bool PacketKey::operator!=(const PacketKey& rhs) const
+{
+ return !(*this == rhs);
+}
+
+Version PacketVersionResolver::ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const
{
// NOTE: For now every packet specification is at version 1.0.0
return Version(1, 0, 0);
namespace profiling
{
+class PacketKey final
+{
+public:
+ PacketKey(uint32_t familyId, uint32_t packetId) : m_FamilyId(familyId), m_PacketId(packetId) {}
+
+ uint32_t GetFamilyId() { return m_FamilyId; }
+ uint32_t GetPacketId() { return m_PacketId; }
+
+ bool operator< (const PacketKey& rhs) const;
+ bool operator> (const PacketKey& rhs) const;
+ bool operator<=(const PacketKey& rhs) const;
+ bool operator>=(const PacketKey& rhs) const;
+ bool operator==(const PacketKey& rhs) const;
+ bool operator!=(const PacketKey& rhs) const;
+
+private:
+ uint32_t m_FamilyId;
+ uint32_t m_PacketId;
+};
+
class PacketVersionResolver final
{
public:
PacketVersionResolver() = default;
~PacketVersionResolver() = default;
- Version ResolvePacketVersion(uint32_t packetId) const;
+ Version ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const;
};
} // namespace profiling
, m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this)
, m_ConnectionAcknowledgedCommandHandler(0,
1,
- m_PacketVersionResolver.ResolvePacketVersion(1).GetEncodedValue(),
+ m_PacketVersionResolver.ResolvePacketVersion(0, 1).GetEncodedValue(),
m_StateMachine)
, m_RequestCounterDirectoryCommandHandler(0,
3,
- m_PacketVersionResolver.ResolvePacketVersion(3).GetEncodedValue(),
+ m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue(),
m_CounterDirectory,
m_SendCounterPacket,
m_StateMachine)
, m_PeriodicCounterSelectionCommandHandler(0,
4,
- m_PacketVersionResolver.ResolvePacketVersion(4).GetEncodedValue(),
+ m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(),
m_Holder,
m_PeriodicCounterCapture,
*this,
m_StateMachine)
, m_PerJobCounterSelectionCommandHandler(0,
5,
- m_PacketVersionResolver.ResolvePacketVersion(4).GetEncodedValue(),
+ m_PacketVersionResolver.ResolvePacketVersion(0, 5).GetEncodedValue(),
m_StateMachine)
{
// Register the "Connection Acknowledged" command handler
BOOST_CHECK(vect == expectedVect);
}
+BOOST_AUTO_TEST_CASE(CheckPacketKeyComparisons)
+{
+ PacketKey key0(0,0);
+ PacketKey key1(0,0);
+ PacketKey key2(0,1);
+ PacketKey key3(0,2);
+ PacketKey key4(1,0);
+ PacketKey key5(1,0);
+ PacketKey key6(1,1);
+
+ BOOST_CHECK(!(key0 < key1));
+ BOOST_CHECK(!(key0 > key1));
+ BOOST_CHECK(key0 <= key1);
+ BOOST_CHECK(key0 >= key1);
+ BOOST_CHECK(key0 == key1);
+ BOOST_CHECK(key0 < key2);
+ BOOST_CHECK(key2 < key3);
+ BOOST_CHECK(key3 > key0);
+ BOOST_CHECK(key4 == key5);
+ BOOST_CHECK(key4 > key0);
+ BOOST_CHECK(key5 < key6);
+ BOOST_CHECK(key5 <= key6);
+ BOOST_CHECK(key5 != key6);
+}
+
BOOST_AUTO_TEST_CASE(CheckCommandHandler)
{
PacketVersionResolver packetVersionResolver;
for (unsigned int i = 0u; i < numTests; ++i)
{
+ const uint32_t familyId = distribution(generator);
const uint32_t packetId = distribution(generator);
- Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(packetId);
+ Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(familyId, packetId);
BOOST_TEST(resolvedVersion == expectedVersion);
}
// This functor will receive back the selection response packet.
armnn::gatordmock::PeriodicCounterSelectionResponseHandler periodicCounterSelectionResponseHandler(
- 0, 4, packetVersionResolver.ResolvePacketVersion(4).GetEncodedValue());
+ 0, 4, packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue());
// This functor will receive the counter data.
armnn::gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(
- 1, 0, packetVersionResolver.ResolvePacketVersion(0).GetEncodedValue());
+ 1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue());
// Register different derived functors
registry.RegisterFunctor(&periodicCounterSelectionResponseHandler);
m_HandlerRegistry
.GetFunctor(packetRx.GetPacketFamily(),
packetRx.GetPacketId(),
- packetVersionResolver.ResolvePacketVersion(packetRx.GetPacketId()).GetEncodedValue())
+ packetVersionResolver.ResolvePacketVersion(packetRx.GetPacketFamily(),
+ packetRx.GetPacketId()).GetEncodedValue())
->operator()(packetRx);
return packetRx;
PeriodicCounterCaptureCommandHandler(uint32_t familyId,
uint32_t packetId,
uint32_t version,
- bool quietOperation = false)
+ bool quietOperation = true)
: CommandHandlerFunctor(familyId, packetId, version)
, m_QuietOperation(quietOperation)
{}