Apollo  6.0
Open source self driving car software
parameter_server.h
Go to the documentation of this file.
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_PARAMETER_PARAMETER_SERVER_H_
18 #define CYBER_PARAMETER_PARAMETER_SERVER_H_
19 
20 #include <memory>
21 #include <string>
22 #include <unordered_map>
23 #include <vector>
24 
25 #include "cyber/proto/parameter.pb.h"
26 
28 #include "cyber/service/service.h"
29 
30 namespace apollo {
31 namespace cyber {
32 
33 class Node;
34 
45  public:
46  using Param = apollo::cyber::proto::Param;
47  using NodeName = apollo::cyber::proto::NodeName;
48  using ParamName = apollo::cyber::proto::ParamName;
49  using BoolResult = apollo::cyber::proto::BoolResult;
50  using Params = apollo::cyber::proto::Params;
56  explicit ParameterServer(const std::shared_ptr<Node>& node);
57 
63  void SetParameter(const Parameter& parmeter);
64 
73  bool GetParameter(const std::string& parameter_name, Parameter* parameter);
74 
80  void ListParameters(std::vector<Parameter>* parameters);
81 
82  private:
83  std::shared_ptr<Node> node_;
84  std::shared_ptr<Service<ParamName, Param>> get_parameter_service_;
85  std::shared_ptr<Service<Param, BoolResult>> set_parameter_service_;
86  std::shared_ptr<Service<NodeName, Params>> list_parameters_service_;
87 
88  std::mutex param_map_mutex_;
89  std::unordered_map<std::string, Param> param_map_;
90 };
91 
92 } // namespace cyber
93 } // namespace apollo
94 
95 #endif // CYBER_PARAMETER_PARAMETER_SERVER_H_
Parameter Service is a very important function of auto-driving. If you want to set a key-value...
Definition: parameter_server.h:44
Definition: node.h:31
void SetParameter(const Parameter &parmeter)
Set the Parameter object.
apollo::cyber::proto::NodeName NodeName
Definition: parameter_server.h:47
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
A Parameter holds an apollo::cyber::proto::Param, It&#39;s more human-readable, you can use basic-value t...
Definition: parameter.h:42
apollo::cyber::proto::Param Param
Definition: parameter_server.h:46
ParameterServer(const std::shared_ptr< Node > &node)
Construct a new ParameterServer object.
bool GetParameter(const std::string &parameter_name, Parameter *parameter)
Get the Parameter object.
apollo::cyber::proto::ParamName ParamName
Definition: parameter_server.h:48
apollo::cyber::proto::BoolResult BoolResult
Definition: parameter_server.h:49
void ListParameters(std::vector< Parameter > *parameters)
get all the parameters
apollo::cyber::proto::Params Params
Definition: parameter_server.h:50