predictor_factory.cc 1.7 KB
Newer Older
C
Calvin Miao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#include "modules/prediction/predictor/predictor_factory.h"

#include "modules/common/log.h"
20 21
#include "modules/prediction/predictor/vehicle/free_move_predictor.h"
#include "modules/prediction/predictor/vehicle/lane_sequence_predictor.h"
C
Calvin Miao 已提交
22 23 24 25

namespace apollo {
namespace prediction {

26 27 28
PredictorFactory::PredictorFactory() {
  RegisterPredictor();
}
C
Calvin Miao 已提交
29 30

void PredictorFactory::RegisterPredictor() {
31 32 33 34
    Register(ObstacleConf::LANE_SEQUENCE_PREDICTOR,
        []() -> Predictor* { return new LaneSequencePredictor(); });
    Register(ObstacleConf::FREE_MOVE_PREDICTOR,
        []() -> Predictor* { return new FreeMovePredictor(); });
C
Calvin Miao 已提交
35 36 37
}

std::unique_ptr<Predictor> PredictorFactory::CreatePredictor(
38 39
    const ObstacleConf::PredictorType& type) {
  auto predictor = CreateObject(type);
C
Calvin Miao 已提交
40
  if (!predictor) {
41
    AERROR << "Failed to create a predictor with " << type;
C
Calvin Miao 已提交
42
  } else {
43
    ADEBUG << "Succeeded in creating a predictor with " << type;
C
Calvin Miao 已提交
44 45 46 47
  }
  return predictor;
}

C
Calvin Miao 已提交
48 49
}  // namespace prediction
}  // namespace apollo