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