Apollo  6.0
Open source self driving car software
Macros | Functions
macros.h File Reference
#include <iostream>
#include <memory>
#include <mutex>
#include <type_traits>
#include <utility>
#include "cyber/base/macros.h"
Include dependency graph for macros.h:

Go to the source code of this file.

Macros

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

Functions

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)
 

Macro Definition Documentation

◆ DECLARE_SINGLETON

#define DECLARE_SINGLETON (   classname)
Value:
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)

◆ DISALLOW_COPY_AND_ASSIGN

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

◆ UNUSED

#define UNUSED (   param)    (void)param

Function Documentation

◆ CallShutdown() [1/2]

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

◆ CallShutdown() [2/2]

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