You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
//
// Created by zwsd
//
#pragma once
#include <functional>
#include "config_index.hpp"
#include "errorcode.hpp"
#include "packet_interface.hpp"
#include "protocol_constant.hpp"
namespace iflytop { using namespace zcr;
class ICmdParserACK { public: typedef enum { kAckType_none, kAckType_int32, kAckType_buf, } ICmdParserACKType_t;
public: int32_t ecode; ICmdParserACKType_t acktype; uint8_t rawdata[ZCANCMD_READ_BUF_MAX_SIZE + 100]; int32_t rawlen;
public: void setInt32Ack(int32_t ecode, int32_t val) { this->ecode = ecode; acktype = kAckType_int32; rawlen = sizeof(int32_t); *((int32_t *)rawdata) = val; }
void setNoneAck(int32_t ecode) { this->ecode = ecode; acktype = kAckType_none; rawlen = 0; rawdata[0] = 0; }
int32_t *getAck(int index) { if (index < 0 || index >= (int32_t)(sizeof(rawdata) / 4)) { return nullptr; } return (int32_t *)rawdata + index; }
int32_t getAckInt32Val(int index) { if (index < 0 || index >= rawlen / (int)sizeof(int32_t)) { return 0; } return *((int32_t *)rawdata + index); } int32_t getAckInt32Num() { return rawlen / (int)sizeof(int32_t); } };
typedef function<void(int32_t paramN, const char **paraV, ICmdParserACK *ack)> ICmdFunction_t;
class ICmdParser { public: virtual void regCMD(const char *cmdname, const char *helpinfo, int paraNum, ICmdFunction_t cmdimpl) = 0; };
} // namespace iflytop
|