INode class. Publisher, Subscriber, ServiceServer, ServiceClient now accept INode in constructor instead of the bunch of independent params. Self NodeID now being configured via setNodeID() method instead of constructor param

This commit is contained in:
Pavel Kirienko
2014-03-14 19:54:27 +04:00
parent 15cbf96378
commit 613efa49b9
22 changed files with 211 additions and 181 deletions
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#include <uavcan/node/scheduler.hpp>
#include <uavcan/node/marshal_buffer.hpp>
namespace uavcan
{
class INode
{
public:
virtual ~INode() { }
virtual IAllocator& getAllocator() = 0;
virtual Scheduler& getScheduler() = 0;
virtual const Scheduler& getScheduler() const = 0;
virtual IMarshalBufferProvider& getMarshalBufferProvider() = 0;
Dispatcher& getDispatcher() { return getScheduler().getDispatcher(); }
const Dispatcher& getDispatcher() const { return getScheduler().getDispatcher(); }
ISystemClock& getSystemClock() { return getScheduler().getSystemClock(); }
MonotonicTime getMonotonicTime() const { return getScheduler().getMonotonicTime(); }
UtcTime getUtcTime() const { return getScheduler().getUtcTime(); }
NodeID getNodeID() const { return getScheduler().getDispatcher().getNodeID(); }
bool setNodeID(NodeID nid)
{
return getScheduler().getDispatcher().setNodeID(nid);
}
int spin(MonotonicTime deadline)
{
return getScheduler().spin(deadline);
}
int spin(MonotonicDuration duration)
{
return getScheduler().spin(getMonotonicTime() + duration);
}
};
}