feat:replace boost library with C++11 std library
This commit is contained in:
@@ -23,15 +23,15 @@
|
||||
//
|
||||
|
||||
#include "command_channel.h"
|
||||
#include <boost/bind.hpp>
|
||||
#include <functional>
|
||||
#include <atomic>
|
||||
#include "base/logging.h"
|
||||
#include "base/network_util.h"
|
||||
#include "command_impl.h"
|
||||
#include "device_manager.h"
|
||||
#include "livox_def.h"
|
||||
|
||||
using boost::atomic_uint16_t;
|
||||
using boost::bind;
|
||||
using std::bind;
|
||||
using std::list;
|
||||
using std::make_pair;
|
||||
using std::map;
|
||||
@@ -182,7 +182,7 @@ void CommandChannel::HeartBeat(apr_time_t t) {
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
boost::shared_ptr<CommandCallback>());
|
||||
std::shared_ptr<CommandCallback>());
|
||||
SendInternal(command);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ void CommandChannel::SendInternal(const Command &command) {
|
||||
}
|
||||
|
||||
uint16_t CommandChannel::GenerateSeq() {
|
||||
static atomic_uint16_t seq(1);
|
||||
static std::atomic<std::uint16_t> seq(1);
|
||||
uint16_t value = seq.load();
|
||||
uint16_t desired = 0;
|
||||
do {
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
|
||||
#ifndef LIVOX_COMMAND_CHANNEL_H_
|
||||
#define LIVOX_COMMAND_CHANNEL_H_
|
||||
#include <boost/smart_ptr.hpp>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include "apr_network_io.h"
|
||||
@@ -36,7 +37,7 @@ namespace livox {
|
||||
typedef struct TagCommand {
|
||||
uint8_t handle;
|
||||
CommPacket packet;
|
||||
boost::shared_ptr<CommandCallback> cb;
|
||||
std::shared_ptr<CommandCallback> cb;
|
||||
uint32_t time_out;
|
||||
TagCommand() : packet(), time_out(0) {}
|
||||
TagCommand(uint8_t _handle,
|
||||
@@ -47,7 +48,7 @@ typedef struct TagCommand {
|
||||
uint8_t *data,
|
||||
uint16_t length,
|
||||
uint32_t _time_out,
|
||||
const boost::shared_ptr<CommandCallback> &_cb)
|
||||
const std::shared_ptr<CommandCallback> &_cb)
|
||||
: handle(_handle), packet(), cb(_cb) {
|
||||
packet.packet_type = _cmd_type;
|
||||
packet.cmd_set = _cmd_set;
|
||||
@@ -115,7 +116,7 @@ class CommandChannel : public IOLoop::IOLoopDelegate {
|
||||
IOLoop *loop_;
|
||||
CommandChannelDelegate *callback_;
|
||||
std::map<uint16_t, std::pair<Command, apr_time_t> > commands_;
|
||||
boost::scoped_ptr<CommPort> comm_port_;
|
||||
std::unique_ptr<CommPort> comm_port_;
|
||||
apr_time_t heartbeat_time_;
|
||||
std::string remote_ip_;
|
||||
apr_time_t last_heartbeat_;
|
||||
|
||||
@@ -23,17 +23,16 @@
|
||||
//
|
||||
|
||||
#include "command_handler.h"
|
||||
#include <boost/thread/lock_guard.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <mutex>
|
||||
#include "base/logging.h"
|
||||
#include "command_impl.h"
|
||||
#include "device_manager.h"
|
||||
#include "hub_command_handler.h"
|
||||
#include "lidar_command_handler.h"
|
||||
|
||||
using boost::lock_guard;
|
||||
using boost::mutex;
|
||||
using boost::shared_ptr;
|
||||
using std::lock_guard;
|
||||
using std::mutex;
|
||||
using std::shared_ptr;
|
||||
using std::list;
|
||||
using std::make_pair;
|
||||
using std::multimap;
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
#ifndef LIVOX_COMMAND_HANDLER_H_
|
||||
#define LIVOX_COMMAND_HANDLER_H_
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include "base/command_callback.h"
|
||||
#include "base/util.h"
|
||||
#include "command_channel.h"
|
||||
@@ -51,12 +52,12 @@ class CommandHandler : public noncopyable {
|
||||
uint8_t command_id,
|
||||
uint8_t *data,
|
||||
uint16_t length,
|
||||
const boost::shared_ptr<CommandCallback> &cb);
|
||||
const std::shared_ptr<CommandCallback> &cb);
|
||||
|
||||
livox_status RegisterPush(uint8_t handle,
|
||||
uint8_t command_set,
|
||||
uint8_t command_id,
|
||||
const boost::shared_ptr<CommandCallback> &cb);
|
||||
const std::shared_ptr<CommandCallback> &cb);
|
||||
|
||||
void OnCommand(uint8_t handle, const Command &command);
|
||||
|
||||
@@ -71,8 +72,8 @@ class CommandHandler : public noncopyable {
|
||||
private:
|
||||
std::multimap<uint16_t, Command> message_registers_;
|
||||
apr_pool_t *mem_pool_;
|
||||
boost::scoped_ptr<CommandHandlerImpl> impl_;
|
||||
boost::mutex mutex_;
|
||||
std::unique_ptr<CommandHandlerImpl> impl_;
|
||||
std::mutex mutex_;
|
||||
IOLoop *loop_;
|
||||
};
|
||||
|
||||
|
||||
@@ -211,6 +211,7 @@ bool ParseRmcTime(const char* rmc, uint16_t rmc_len, LidarSetUtcSyncTimeRequest*
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
utc_time_req->hour = hour;
|
||||
utc_time_req->mircrosecond = (minute * 60 * 1000 + second * 1000 + millisecond) * 1000;
|
||||
return true;
|
||||
}
|
||||
@@ -339,9 +340,16 @@ livox_status GetDeviceIpInformation(uint8_t handle, GetDeviceIpInformationCallba
|
||||
}
|
||||
|
||||
livox_status RebootDevice(uint8_t handle, uint16_t timeout, CommonCommandCallback cb, void * client_data) {
|
||||
if(device_manager().IsLidarMid40(handle)) {
|
||||
return kStatusNotSupported;
|
||||
if (device_manager().IsLidarMid40(handle)) {
|
||||
uint32_t firm_ver = 0;
|
||||
// Mid40 firmware version 03.07.0000
|
||||
uint32_t min_firm_ver = (uint32_t)3 << 24 | 7 << 16 | 0 << 8 | 0;
|
||||
device_manager().GetLidarFirmwareVersion(handle, firm_ver);
|
||||
if (firm_ver < min_firm_ver) {
|
||||
return kStatusNotSupported;
|
||||
}
|
||||
}
|
||||
|
||||
livox_status result = command_handler().SendCommand(handle,
|
||||
kCommandSetGeneral,
|
||||
kCommandIDGeneralRebootDevice,
|
||||
@@ -735,10 +743,19 @@ livox_status LidarSetRmcSyncTime(uint8_t handle,
|
||||
uint16_t rmc_length,
|
||||
CommonCommandCallback cb,
|
||||
void *client_data) {
|
||||
if (device_manager().device_mode() != kDeviceModeLidar
|
||||
|| device_manager().IsLidarMid40(handle)) {
|
||||
if (device_manager().device_mode() != kDeviceModeLidar) {
|
||||
return kStatusNotSupported;
|
||||
}
|
||||
|
||||
if (device_manager().IsLidarMid40(handle)) {
|
||||
uint32_t firm_ver = 0;
|
||||
// Mid40 firmware version 03.07.0000
|
||||
uint32_t min_firm_ver = (uint32_t)3 << 24 | 7 << 16 | 0 << 8 | 0;
|
||||
device_manager().GetLidarFirmwareVersion(handle, firm_ver);
|
||||
if (firm_ver < min_firm_ver) {
|
||||
return kStatusNotSupported;
|
||||
}
|
||||
}
|
||||
|
||||
LidarSetUtcSyncTimeRequest utc_time_req;
|
||||
if (!ParseRmcTime(rmc, rmc_length, &utc_time_req)) {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#ifndef LIVOX_HUB_COMMAND_HANDLER_H_
|
||||
#define LIVOX_HUB_COMMAND_HANDLER_H_
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <memory>
|
||||
#include "command_handler.h"
|
||||
|
||||
namespace livox {
|
||||
@@ -43,7 +43,7 @@ class HubCommandHandlerImpl : public CommandHandlerImpl {
|
||||
IOLoop *loop_;
|
||||
bool is_valid_;
|
||||
DeviceInfo hub_info_;
|
||||
boost::scoped_ptr<CommandChannel> channel_;
|
||||
std::unique_ptr<CommandChannel> channel_;
|
||||
};
|
||||
} // namespace livox
|
||||
#endif // LIVOX_HUB_COMMAND_HANDLER_H_
|
||||
|
||||
@@ -33,8 +33,8 @@ void LidarCommandHandlerImpl::Uninit() {
|
||||
}
|
||||
|
||||
bool LidarCommandHandlerImpl::AddDevice(const DeviceInfo &info) {
|
||||
boost::shared_ptr<CommandChannel> channel =
|
||||
boost::make_shared<CommandChannel>(info.cmd_port, info.handle, info.ip, this, mem_pool_);
|
||||
std::shared_ptr<CommandChannel> channel =
|
||||
std::make_shared<CommandChannel>(info.cmd_port, info.handle, info.ip, this, mem_pool_);
|
||||
channel->Bind(loop_);
|
||||
|
||||
DeviceItem item = {channel, info};
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#ifndef LIVOX_LIDAR_COMMAND_HANDLER_H_
|
||||
#define LIVOX_LIDAR_COMMAND_HANDLER_H_
|
||||
#include <boost/smart_ptr.hpp>
|
||||
#include <memory>
|
||||
#include "command_handler.h"
|
||||
|
||||
namespace livox {
|
||||
@@ -42,7 +42,7 @@ class LidarCommandHandlerImpl : public CommandHandlerImpl {
|
||||
|
||||
private:
|
||||
typedef struct {
|
||||
boost::shared_ptr<CommandChannel> channel;
|
||||
std::shared_ptr<CommandChannel> channel;
|
||||
DeviceInfo info;
|
||||
} DeviceItem;
|
||||
apr_pool_t *mem_pool_;
|
||||
|
||||
Reference in New Issue
Block a user