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
"
22
#include "
modules/perception/common/lib/registerer/registerer.h
"
23
#include "
modules/perception/common/lib/interface/base_init_options.h
"
24
25
namespace
apollo
{
26
namespace
perception {
27
namespace
lidar {
28
29
using
apollo::perception::BaseInitOptions
;
30
31
class
SceneServiceContent
{
32
public
:
33
SceneServiceContent
() =
default
;
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
:
52
DISALLOW_COPY_AND_ASSIGN
(
SceneServiceContent
);
53
};
54
55
PERCEPTION_REGISTER_REGISTERER
(
SceneServiceContent
);
56
#define PERCEPTION_REGISTER_SCENESERVICECONTENT(name) \
57
PERCEPTION_REGISTER_CLASS(SceneServiceContent, name)
58
59
typedef
std::shared_ptr<SceneServiceContent>
SceneServiceContentPtr
;
60
typedef
std::shared_ptr<const SceneServiceContent>
SceneServiceContentConstPtr
;
61
62
struct
SceneServiceInitOptions
:
public
BaseInitOptions
{};
63
64
class
SceneService
{
65
public
:
66
SceneService
() =
default
;
67
virtual
~SceneService
() =
default
;
68
// @brief: initialize scene service
69
// @param [in]: init options
70
virtual
bool
Init
(
71
const
SceneServiceInitOptions
& options =
SceneServiceInitOptions
()) = 0;
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
77
void
GetServiceContentCopy
(
SceneServiceContent
* 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
83
void
UpdateServiceContent
(
const
SceneServiceContent
& content) {
84
std::lock_guard<std::mutex> lock(
mutex_
);
85
self_content_
->SetContent(content);
86
}
87
88
protected
:
89
SceneServiceContentPtr
self_content_
;
90
std::mutex
mutex_
;
91
92
private
:
93
DISALLOW_COPY_AND_ASSIGN
(
SceneService
);
94
};
95
96
PERCEPTION_REGISTER_REGISTERER
(
SceneService
);
97
#define PERCEPTION_REGISTER_SCENESERVICE(name) \
98
PERCEPTION_REGISTER_CLASS(SceneService, name)
99
100
typedef
std::shared_ptr<SceneService>
SceneServicePtr
;
101
typedef
std::shared_ptr<const SceneService>
SceneServiceConstPtr
;
102
103
}
// namespace lidar
104
}
// namespace perception
105
}
// namespace apollo
base_init_options.h
apollo::perception::lidar::SceneServiceContent
Definition
scene_service.h:31
apollo::perception::lidar::SceneServiceContent::~SceneServiceContent
virtual ~SceneServiceContent()=default
apollo::perception::lidar::SceneServiceContent::SetContent
virtual void SetContent(const SceneServiceContent &content)=0
apollo::perception::lidar::SceneServiceContent::Name
virtual std::string Name() const =0
apollo::perception::lidar::SceneServiceContent::IsServiceReady
bool IsServiceReady() const
Definition
scene_service.h:46
apollo::perception::lidar::SceneServiceContent::GetCopy
virtual void GetCopy(SceneServiceContent *content) const =0
apollo::perception::lidar::SceneServiceContent::SceneServiceContent
SceneServiceContent()=default
apollo::perception::lidar::SceneServiceContent::service_ready_
bool service_ready_
Definition
scene_service.h:49
apollo::perception::lidar::SceneService
Definition
scene_service.h:64
apollo::perception::lidar::SceneService::mutex_
std::mutex mutex_
Definition
scene_service.h:90
apollo::perception::lidar::SceneService::UpdateServiceContent
void UpdateServiceContent(const SceneServiceContent &content)
Definition
scene_service.h:83
apollo::perception::lidar::SceneService::~SceneService
virtual ~SceneService()=default
apollo::perception::lidar::SceneService::SceneService
SceneService()=default
apollo::perception::lidar::SceneService::self_content_
SceneServiceContentPtr self_content_
Definition
scene_service.h:89
apollo::perception::lidar::SceneService::Name
virtual std::string Name() const =0
apollo::perception::lidar::SceneService::Init
virtual bool Init(const SceneServiceInitOptions &options=SceneServiceInitOptions())=0
apollo::perception::lidar::SceneService::GetServiceContentCopy
void GetServiceContentCopy(SceneServiceContent *content)
Definition
scene_service.h:77
macros.h
DISALLOW_COPY_AND_ASSIGN
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition
macros.h:48
apollo::perception::lidar::SceneServiceContentConstPtr
std::shared_ptr< const SceneServiceContent > SceneServiceContentConstPtr
Definition
scene_service.h:60
apollo::perception::lidar::SceneServiceConstPtr
std::shared_ptr< const SceneService > SceneServiceConstPtr
Definition
scene_service.h:101
apollo::perception::lidar::SceneServicePtr
std::shared_ptr< SceneService > SceneServicePtr
Definition
scene_service.h:100
apollo::perception::lidar::SceneServiceContentPtr
std::shared_ptr< SceneServiceContent > SceneServiceContentPtr
Definition
scene_service.h:59
apollo
class register implement
Definition
arena_queue.h:37
registerer.h
PERCEPTION_REGISTER_REGISTERER
#define PERCEPTION_REGISTER_REGISTERER(base_class)
Definition
registerer.h:92
apollo::perception::BaseInitOptions
Definition
base_init_options.h:23
apollo::perception::lidar::SceneServiceInitOptions
Definition
scene_service.h:62
modules
perception
common
lidar
scene_manager
scene_service.h