Apollo 11.0
自动驾驶开放平台
apollo::cyber::context::Context类 参考

#include <context.h>

apollo::cyber::context::Context 的协作图:

Public 成员函数

 Context ()=default
 
 ~Context ()=default
 
template<typename T >
void Set (const std::string &key, const std::shared_ptr< T > &value)
 Set value to context.
 
template<typename T >
void Set (const std::string &key, const T &value)
 Set value to context.
 
template<typename T >
std::shared_ptr< T > Get (const std::string &key) const
 Get value from context.
 
template<typename T >
void SafeSet (const std::string &key, const std::shared_ptr< T > &value)
 Set value to context safely.
 
template<typename T >
void SafeSet (const std::string &key, const T &value)
 Set value to context safely.
 
template<typename T >
std::shared_ptr< T > SafeGet (const std::string &key) const
 Get value from context safely.
 

详细描述

在文件 context.h 第 28 行定义.

构造及析构函数说明

◆ Context()

apollo::cyber::context::Context::Context ( )
default

◆ ~Context()

apollo::cyber::context::Context::~Context ( )
default

成员函数说明

◆ Get()

template<typename T >
std::shared_ptr< T > apollo::cyber::context::Context::Get ( const std::string &  key) const

Get value from context.

模板参数
Ttype of value
参数
keystring key
返回
std::shared_ptr<T> value of key in context or nullptr if not exist

在文件 context.h 第 108 行定义.

108 {
109 auto it = m_map_.find(key);
110 if (it != m_map_.end()) {
111 return std::static_pointer_cast<T>(it->second);
112 }
113 return nullptr;
114}

◆ SafeGet()

template<typename T >
std::shared_ptr< T > apollo::cyber::context::Context::SafeGet ( const std::string &  key) const

Get value from context safely.

模板参数
Ttype of value
参数
keystring key
返回
std::shared_ptr<T> value of key in context or nullptr if not exist

在文件 context.h 第 129 行定义.

129 {
130 std::lock_guard<std::mutex> lock(m_mutex_);
131 return Get<T>(key);
132}

◆ SafeSet() [1/2]

template<typename T >
void apollo::cyber::context::Context::SafeSet ( const std::string &  key,
const std::shared_ptr< T > &  value 
)

Set value to context safely.

模板参数
Ttype of value
参数
keystring key
valueshared_ptr of T

在文件 context.h 第 117 行定义.

117 {
118 std::lock_guard<std::mutex> lock(m_mutex_);
119 return Set(key, value);
120}
void Set(const std::string &key, const std::shared_ptr< T > &value)
Set value to context.
Definition context.h:99

◆ SafeSet() [2/2]

template<typename T >
void apollo::cyber::context::Context::SafeSet ( const std::string &  key,
const T &  value 
)

Set value to context safely.

模板参数
Ttype of value
参数
keystring key
valueT value

在文件 context.h 第 123 行定义.

123 {
124 std::lock_guard<std::mutex> lock(m_mutex_);
125 return Set(key, value);
126}

◆ Set() [1/2]

template<typename T >
void apollo::cyber::context::Context::Set ( const std::string &  key,
const std::shared_ptr< T > &  value 
)

Set value to context.

模板参数
Ttype of value
参数
keystring key
valueshared_ptr of T

在文件 context.h 第 99 行定义.

99 {
100 m_map_[key] = value;
101}

◆ Set() [2/2]

template<typename T >
void apollo::cyber::context::Context::Set ( const std::string &  key,
const T &  value 
)

Set value to context.

模板参数
Ttype of value
参数
keystring key
valueT value

在文件 context.h 第 104 行定义.

104 {
105 m_map_[key] = std::make_shared<T>(value);
106}

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