Apollo  6.0
Open source self driving car software
participant.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_TRANSPORT_RTPS_PARTICIPANT_H_
18 #define CYBER_TRANSPORT_RTPS_PARTICIPANT_H_
19 
20 #include <atomic>
21 #include <memory>
22 #include <mutex>
23 #include <string>
24 
26 #include "fastrtps/Domain.h"
27 #include "fastrtps/attributes/ParticipantAttributes.h"
28 #include "fastrtps/participant/Participant.h"
29 #include "fastrtps/participant/ParticipantListener.h"
30 #include "fastrtps/rtps/common/Locator.h"
31 
32 namespace apollo {
33 namespace cyber {
34 namespace transport {
35 
36 class Participant;
37 using ParticipantPtr = std::shared_ptr<Participant>;
38 
39 class Participant {
40  public:
41  Participant(const std::string& name, int send_port,
42  eprosima::fastrtps::ParticipantListener* listener = nullptr);
43  virtual ~Participant();
44 
45  void Shutdown();
46 
47  eprosima::fastrtps::Participant* fastrtps_participant();
48  bool is_shutdown() const { return shutdown_.load(); }
49 
50  private:
51  void CreateFastRtpsParticipant(
52  const std::string& name, int send_port,
53  eprosima::fastrtps::ParticipantListener* listener);
54 
55  std::atomic<bool> shutdown_;
56  std::string name_;
57  int send_port_;
58  eprosima::fastrtps::ParticipantListener* listener_;
59  UnderlayMessageType type_;
60  eprosima::fastrtps::Participant* fastrtps_participant_;
61  std::mutex mutex_;
62 };
63 
64 } // namespace transport
65 } // namespace cyber
66 } // namespace apollo
67 
68 #endif // CYBER_TRANSPORT_RTPS_PARTICIPANT_H_
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
This class represents the TopicDataType of the type UnderlayMessage defined by the user in the IDL fi...
Definition: underlay_message_type.h:32
bool is_shutdown() const
Definition: participant.h:48
Definition: participant.h:39
std::shared_ptr< Participant > ParticipantPtr
Definition: participant.h:37
Participant(const std::string &name, int send_port, eprosima::fastrtps::ParticipantListener *listener=nullptr)
eprosima::fastrtps::Participant * fastrtps_participant()