added type check for parser in AgilexBase

This commit is contained in:
Ruixiang Du
2021-07-16 17:57:04 +08:00
parent 2a94b95f4a
commit 8f134c8822

View File

@@ -24,12 +24,21 @@
#include "ugv_sdk/details/async_port/async_can.hpp" #include "ugv_sdk/details/async_port/async_can.hpp"
#include "ugv_sdk/details/interface/robot_common_interface.hpp" #include "ugv_sdk/details/interface/robot_common_interface.hpp"
#include "ugv_sdk/details/interface/parser_interface.hpp"
namespace westonrobot { namespace westonrobot {
template <typename ParserType> template <typename ParserType>
class AgilexBase : public RobotCommonInterface { class AgilexBase : public RobotCommonInterface {
public: public:
AgilexBase() = default; AgilexBase() {
static_assert(
std::is_base_of<ParserInterface<ProtocolVersion::AGX_V1>,
ParserType>::value ||
std::is_base_of<ParserInterface<ProtocolVersion::AGX_V2>,
ParserType>::value,
"Incompatible parser for the AgilexBase class, expecting one derived "
"from ParserInterface!");
};
virtual ~AgilexBase() { DisconnectPort(); } virtual ~AgilexBase() { DisconnectPort(); }
// do not allow copy or assignment // do not allow copy or assignment