Apollo 10.0
自动驾驶开放平台
macros.h 文件参考
#include <iostream>
#include <memory>
#include <mutex>
#include <type_traits>
#include <utility>
#include "cyber/base/macros.h"
macros.h 的引用(Include)关系图:

浏览源代码.

宏定义

#define UNUSED(param)   (void)param
 
#define DISALLOW_COPY_AND_ASSIGN(classname)
 
#define DECLARE_SINGLETON(classname)
 

函数

template<typename T >
std::enable_if< HasShutdown< T >::value >::type CallShutdown (T *instance)
 
template<typename T >
std::enable_if<!HasShutdown< T >::value >::type CallShutdown (T *instance)
 

宏定义说明

◆ DECLARE_SINGLETON

#define DECLARE_SINGLETON (   classname)
值:
public: \
static classname *Instance(bool create_if_needed = true) { \
static classname *instance = nullptr; \
if (!instance && create_if_needed) { \
static std::once_flag flag; \
std::call_once(flag, \
[&] { instance = new (std::nothrow) classname(); }); \
} \
return instance; \
} \
\
static void CleanUp() { \
auto instance = Instance(false); \
if (instance != nullptr) { \
CallShutdown(instance); \
} \
} \
\
private: \
classname(); \
DISALLOW_COPY_AND_ASSIGN(classname)

在文件 macros.h52 行定义.

53 : \
54 static classname *Instance(bool create_if_needed = true) { \
55 static classname *instance = nullptr; \
56 if (!instance && create_if_needed) { \
57 static std::once_flag flag; \
58 std::call_once(flag, \
59 [&] { instance = new (std::nothrow) classname(); }); \
60 } \
61 return instance; \
62 } \
63 \
64 static void CleanUp() { \
65 auto instance = Instance(false); \
66 if (instance != nullptr) { \
67 CallShutdown(instance); \
68 } \
69 } \
70 \
71 private: \
72 classname(); \
73 DISALLOW_COPY_AND_ASSIGN(classname)

◆ DISALLOW_COPY_AND_ASSIGN

#define DISALLOW_COPY_AND_ASSIGN (   classname)
值:
classname(const classname &) = delete; \
classname &operator=(const classname &) = delete;

在文件 macros.h48 行定义.

◆ UNUSED

#define UNUSED (   param)    (void)param

在文件 macros.h46 行定义.

函数说明

◆ CallShutdown() [1/2]

template<typename T >
std::enable_if< HasShutdown< T >::value >::type CallShutdown ( T *  instance)

在文件 macros.h31 行定义.

31 {
32 instance->Shutdown();
33}

◆ CallShutdown() [2/2]

template<typename T >
std::enable_if<!HasShutdown< T >::value >::type CallShutdown ( T *  instance)

在文件 macros.h36 行定义.

37 {
38 (void)instance;
39}