Apollo 10.0
自动驾驶开放平台
node.cc
浏览该文件的文档.
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#include "cyber/node/node.h"
18
19namespace apollo {
20namespace cyber {
21
22Node::Node(const std::string& node_name, const std::string& name_space)
23 : node_name_(node_name), name_space_(name_space) {
24 node_channel_impl_.reset(new NodeChannelImpl(node_name));
25 node_service_impl_.reset(new NodeServiceImpl(node_name));
26}
27
29
30const std::string& Node::Name() const { return node_name_; }
31
32void Node::Observe() {
33 for (auto& reader : readers_) {
34 reader.second->Observe();
35 }
36}
37
38void Node::ClearData() {
39 for (auto& reader : readers_) {
40 reader.second->ClearData();
41 }
42}
43
44bool Node::DeleteReader(const std::string& channel_name) {
45 std::lock_guard<std::mutex> lg(readers_mutex_);
46 int result = readers_.erase(channel_name);
47 if (1 == result) return true;
48 return false;
49}
50
51bool Node::DeleteReader(const proto::RoleAttributes& role_attr) {
52 std::lock_guard<std::mutex> lg(readers_mutex_);
53 int result = readers_.erase(role_attr.channel_name());
54 if (1 == result) return true;
55 return false;
56}
57
58bool Node::DeleteReader(const ReaderConfig& config) {
59 std::lock_guard<std::mutex> lg(readers_mutex_);
60 int result = readers_.erase(config.channel_name);
61 if (1 == result) return true;
62 return false;
63}
64} // namespace cyber
65} // namespace apollo
~Node()
Definition node.cc:24
Node()
Definition node.cc:22
class register implement
Definition arena_queue.h:37