Apollo 10.0
自动驾驶开放平台
apollo::drivers::canbus::CanClientFactory类 参考

CanClientFactory inherites apollo::common::util::Factory. 更多...

#include <can_client_factory.h>

类 apollo::drivers::canbus::CanClientFactory 继承关系图:
apollo::drivers::canbus::CanClientFactory 的协作图:

Public 成员函数

void RegisterCanClients ()
 Register the CAN clients of all brands.
 
std::unique_ptr< CanClientCreateCANClient (const CANCardParameter &parameter)
 Create a pointer to a specified brand of CAN client.
 
- Public 成员函数 继承自 apollo::common::util::Factory< CANCardParameter::CANCardBrand, CanClient >
bool Register (const CANCardParameter::CANCardBrand &id, CanClient *(*)() creator)
 Registers the class given by the creator function, linking it to id.
 
bool Contains (const CANCardParameter::CANCardBrand &id)
 
bool Unregister (const CANCardParameter::CANCardBrand &id)
 Unregisters the class with the given identifier
 
void Clear ()
 
bool Empty () const
 
std::unique_ptr< CanClient > CreateObjectOrNull (const CANCardParameter::CANCardBrand &id, Args &&... args)
 Creates and transfers membership of an object of type matching id.
 
std::unique_ptr< CanClient > CreateObject (const CANCardParameter::CANCardBrand &id, Args &&... args)
 Creates and transfers membership of an object of type matching id.
 

详细描述

成员函数说明

◆ CreateCANClient()

std::unique_ptr< CanClient > apollo::drivers::canbus::CanClientFactory::CreateCANClient ( const CANCardParameter parameter)

Create a pointer to a specified brand of CAN client.

The brand is set in the parameter.

参数
parameterThe parameter to create the CAN client.
返回
A pointer to the created CAN client.

在文件 can_client_factory.cc53 行定义.

54 {
55 auto factory = CreateObject(parameter.brand());
56 if (!factory) {
57 AERROR << "Failed to create CAN client with parameter: "
58 << parameter.DebugString();
59 } else if (!factory->Init(parameter)) {
60 AERROR << "Failed to initialize CAN card with parameter: "
61 << parameter.DebugString();
62 }
63 return factory;
64}
std::unique_ptr< CanClient > CreateObject(const CANCardParameter::CANCardBrand &id, Args &&... args)
Creates and transfers membership of an object of type matching id.
Definition factory.h:115
#define AERROR
Definition log.h:44

◆ RegisterCanClients()

void apollo::drivers::canbus::CanClientFactory::RegisterCanClients ( )

Register the CAN clients of all brands.

This function call the Function apollo::common::util::Factory::Register() for all of the CAN clients.

在文件 can_client_factory.cc37 行定义.

37 {
38 AINFO << "CanClientFactory::RegisterCanClients";
40 []() -> CanClient* { return new can::FakeCanClient(); });
41#if USE_ESD_CAN
42 AINFO << "register can: " << CANCardParameter::ESD_CAN;
44 []() -> CanClient* { return new can::EsdCanClient(); });
45#endif
47 []() -> CanClient* { return new can::SocketCanClientRaw(); });
48
50 []() -> CanClient* { return new can::HermesCanClient(); });
51}
bool Register(const CANCardParameter::CANCardBrand &id, CanClient *(*)() creator)
Registers the class given by the creator function, linking it to id.
Definition factory.h:70
#define AINFO
Definition log.h:42

该类的文档由以下文件生成: