Apollo 11.0
自动驾驶开放平台
scene_service.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#pragma once
17
18#include <memory>
19#include <string>
20
21#include "cyber/common/macros.h"
24
25namespace apollo {
26namespace perception {
27namespace lidar {
28
30
32 public:
34 virtual ~SceneServiceContent() = default;
35 // @brief: get service content name
36 // @return: name
37 virtual std::string Name() const = 0;
38 // @brief: get a copy of this service content
39 // @param [out]: copy of the service content
40 virtual void GetCopy(SceneServiceContent* content) const = 0;
41 // @brief: set service content from outside
42 // @param [in]: input service content
43 virtual void SetContent(const SceneServiceContent& content) = 0;
44 // @brief: whether service is ready
45 // @return: status
46 bool IsServiceReady() const { return service_ready_; }
47
48 protected:
49 bool service_ready_ = false;
50
51 private:
53};
54
56#define PERCEPTION_REGISTER_SCENESERVICECONTENT(name) \
57 PERCEPTION_REGISTER_CLASS(SceneServiceContent, name)
58
59typedef std::shared_ptr<SceneServiceContent> SceneServiceContentPtr;
60typedef std::shared_ptr<const SceneServiceContent> SceneServiceContentConstPtr;
61
63
65 public:
66 SceneService() = default;
67 virtual ~SceneService() = default;
68 // @brief: initialize scene service
69 // @param [in]: init options
70 virtual bool Init(
72 // @brief: get service name
73 // @return: name
74 virtual std::string Name() const = 0;
75 // @brief: get a copy of service content
76 // @param [in]: service content
78 std::lock_guard<std::mutex> lock(mutex_);
79 self_content_->GetCopy(content);
80 }
81 // @brief: update service content from copy
82 // @param [in]: service content
84 std::lock_guard<std::mutex> lock(mutex_);
85 self_content_->SetContent(content);
86 }
87
88 protected:
90 std::mutex mutex_;
91
92 private:
94};
95
97#define PERCEPTION_REGISTER_SCENESERVICE(name) \
98 PERCEPTION_REGISTER_CLASS(SceneService, name)
99
100typedef std::shared_ptr<SceneService> SceneServicePtr;
101typedef std::shared_ptr<const SceneService> SceneServiceConstPtr;
102
103} // namespace lidar
104} // namespace perception
105} // namespace apollo
virtual void SetContent(const SceneServiceContent &content)=0
virtual std::string Name() const =0
virtual void GetCopy(SceneServiceContent *content) const =0
void UpdateServiceContent(const SceneServiceContent &content)
virtual std::string Name() const =0
virtual bool Init(const SceneServiceInitOptions &options=SceneServiceInitOptions())=0
void GetServiceContentCopy(SceneServiceContent *content)
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
std::shared_ptr< const SceneServiceContent > SceneServiceContentConstPtr
std::shared_ptr< const SceneService > SceneServiceConstPtr
std::shared_ptr< SceneService > SceneServicePtr
std::shared_ptr< SceneServiceContent > SceneServiceContentPtr
class register implement
Definition arena_queue.h:37
#define PERCEPTION_REGISTER_REGISTERER(base_class)
Definition registerer.h:92