Apollo 10.0
自动驾驶开放平台
environment.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#ifndef CYBER_COMMON_ENVIRONMENT_H_
18#define CYBER_COMMON_ENVIRONMENT_H_
19
20#include <cassert>
21#include <string>
22
23#include "cyber/common/log.h"
24
25namespace apollo {
26namespace cyber {
27namespace common {
28
29inline std::string GetEnv(const std::string& var_name,
30 const std::string& default_value = "") {
31 const char* var = std::getenv(var_name.c_str());
32 if (var == nullptr) {
33 AWARN << "Environment variable [" << var_name << "] not set, fallback to "
34 << default_value;
35 return default_value;
36 }
37 return std::string(var);
38}
39
40inline const std::string WorkRoot() {
41 std::string work_root = GetEnv("CYBER_PATH");
42 if (work_root.empty()) {
43 work_root = "/apollo/cyber";
44 }
45 return work_root;
46}
47
48} // namespace common
49} // namespace cyber
50} // namespace apollo
51
52#endif // CYBER_COMMON_ENVIRONMENT_H_
#define AWARN
Definition log.h:43
std::string GetEnv(const std::string &var_name, const std::string &default_value="")
Definition environment.h:29
const std::string WorkRoot()
Definition environment.h:40
class register implement
Definition arena_queue.h:37