

#pragma once

#include <deque>
#include <memory>
#include <string>
#include <thread>

#include "cyber/base/concurrent_object_pool.h"
#include "cyber/cyber.h"

#include "modules/drivers/velodyne/parser/convert.h"
#include "modules/drivers/velodyne/proto/config.pb.h"
#include "modules/drivers/velodyne/proto/velodyne.pb.h"

namespace apollo {
namespace drivers {
namespace velodyne {

using apollo::cyber::Component;
using apollo::cyber::Reader;
using apollo::cyber::Writer;
using apollo::cyber::base::CCObjectPool;
using apollo::drivers::PointCloud;
using apollo::drivers::velodyne::VelodyneScan;

class VelodyneConvertComponent : public Component<VelodyneScan> {
 public:
  bool Init() override;
  bool Proc(const std::shared_ptr<VelodyneScan>& scan_msg) override;

 private:
  std::shared_ptr<Writer<PointCloud>> writer_;
  std::unique_ptr<Convert> conv_ = nullptr;
  std::shared_ptr<CCObjectPool<PointCloud>> point_cloud_pool_ = nullptr;
  int pool_size_ = 8;
};

CYBER_REGISTER_COMPONENT(VelodyneConvertComponent)

}  // namespace velodyne
}  // namespace drivers
}  // namespace apollo
