Apollo  6.0
Open source self driving car software
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
apollo::cyber::service_discovery::Manager Class Referenceabstract

Base class for management of Topology elements. Manager can Join/Leave the Topology, and Listen the topology change. More...

#include <manager.h>

Inheritance diagram for apollo::cyber::service_discovery::Manager:
Inheritance graph
Collaboration diagram for apollo::cyber::service_discovery::Manager:
Collaboration graph

Public Types

using ChangeSignal = base::Signal< const ChangeMsg & >
 
using ChangeFunc = std::function< void(const ChangeMsg &)>
 
using ChangeConnection = base::Connection< const ChangeMsg & >
 
using RtpsParticipant = eprosima::fastrtps::Participant
 
using RtpsPublisherAttr = eprosima::fastrtps::PublisherAttributes
 
using RtpsSubscriberAttr = eprosima::fastrtps::SubscriberAttributes
 

Public Member Functions

 Manager ()
 Construct a new Manager object. More...
 
virtual ~Manager ()
 Destroy the Manager object. More...
 
bool StartDiscovery (RtpsParticipant *participant)
 Startup topology discovery. More...
 
void StopDiscovery ()
 Stop topology discovery. More...
 
virtual void Shutdown ()
 Shutdown module. More...
 
bool Join (const RoleAttributes &attr, RoleType role, bool need_publish=true)
 Join the topology. More...
 
bool Leave (const RoleAttributes &attr, RoleType role)
 Leave the topology. More...
 
ChangeConnection AddChangeListener (const ChangeFunc &func)
 Add topology change listener, when topology changed, func will be called. More...
 
void RemoveChangeListener (const ChangeConnection &conn)
 Remove our listener for topology change. More...
 
virtual void OnTopoModuleLeave (const std::string &host_name, int process_id)=0
 Called when a process' topology manager instance leave. More...
 

Protected Member Functions

bool CreatePublisher (RtpsParticipant *participant)
 
bool CreateSubscriber (RtpsParticipant *participant)
 
virtual bool Check (const RoleAttributes &attr)=0
 
virtual void Dispose (const ChangeMsg &msg)=0
 
virtual bool NeedPublish (const ChangeMsg &msg) const
 
void Convert (const RoleAttributes &attr, RoleType role, OperateType opt, ChangeMsg *msg)
 
void Notify (const ChangeMsg &msg)
 
bool Publish (const ChangeMsg &msg)
 
void OnRemoteChange (const std::string &msg_str)
 
bool IsFromSameProcess (const ChangeMsg &msg)
 

Protected Attributes

std::atomic< bool > is_shutdown_
 
std::atomic< bool > is_discovery_started_
 
int allowed_role_
 
ChangeType change_type_
 
std::string host_name_
 
int process_id_
 
std::string channel_name_
 
eprosima::fastrtps::Publisher * publisher_
 
std::mutex lock_
 
eprosima::fastrtps::Subscriber * subscriber_
 
SubscriberListenerlistener_
 
ChangeSignal signal_
 

Detailed Description

Base class for management of Topology elements. Manager can Join/Leave the Topology, and Listen the topology change.

Member Typedef Documentation

◆ ChangeConnection

◆ ChangeFunc

using apollo::cyber::service_discovery::Manager::ChangeFunc = std::function<void(const ChangeMsg&)>

◆ ChangeSignal

◆ RtpsParticipant

using apollo::cyber::service_discovery::Manager::RtpsParticipant = eprosima::fastrtps::Participant

◆ RtpsPublisherAttr

using apollo::cyber::service_discovery::Manager::RtpsPublisherAttr = eprosima::fastrtps::PublisherAttributes

◆ RtpsSubscriberAttr

using apollo::cyber::service_discovery::Manager::RtpsSubscriberAttr = eprosima::fastrtps::SubscriberAttributes

Constructor & Destructor Documentation

◆ Manager()

apollo::cyber::service_discovery::Manager::Manager ( )

Construct a new Manager object.

◆ ~Manager()

virtual apollo::cyber::service_discovery::Manager::~Manager ( )
virtual

Destroy the Manager object.

Member Function Documentation

◆ AddChangeListener()

ChangeConnection apollo::cyber::service_discovery::Manager::AddChangeListener ( const ChangeFunc func)

Add topology change listener, when topology changed, func will be called.

Parameters
functhe callback function
Returns
ChangeConnection Store it to use when you want to stop listening.

◆ Check()

virtual bool apollo::cyber::service_discovery::Manager::Check ( const RoleAttributes &  attr)
protectedpure virtual

◆ Convert()

void apollo::cyber::service_discovery::Manager::Convert ( const RoleAttributes &  attr,
RoleType  role,
OperateType  opt,
ChangeMsg *  msg 
)
protected

◆ CreatePublisher()

bool apollo::cyber::service_discovery::Manager::CreatePublisher ( RtpsParticipant participant)
protected

◆ CreateSubscriber()

bool apollo::cyber::service_discovery::Manager::CreateSubscriber ( RtpsParticipant participant)
protected

◆ Dispose()

virtual void apollo::cyber::service_discovery::Manager::Dispose ( const ChangeMsg &  msg)
protectedpure virtual

◆ IsFromSameProcess()

bool apollo::cyber::service_discovery::Manager::IsFromSameProcess ( const ChangeMsg &  msg)
protected

◆ Join()

bool apollo::cyber::service_discovery::Manager::Join ( const RoleAttributes &  attr,
RoleType  role,
bool  need_publish = true 
)

Join the topology.

Parameters
attris the attributes that will be sent to other Manager(include ourselves)
roleis one of RoleType enum
Returns
true if Join topology successfully
false if Join topology failed

◆ Leave()

bool apollo::cyber::service_discovery::Manager::Leave ( const RoleAttributes &  attr,
RoleType  role 
)

Leave the topology.

Parameters
attris the attributes that will be sent to other Manager(include ourselves)
roleif one of RoleType enum.
Returns
true if Leave topology successfully
false if Leave topology failed

◆ NeedPublish()

virtual bool apollo::cyber::service_discovery::Manager::NeedPublish ( const ChangeMsg &  msg) const
protectedvirtual

◆ Notify()

void apollo::cyber::service_discovery::Manager::Notify ( const ChangeMsg &  msg)
protected

◆ OnRemoteChange()

void apollo::cyber::service_discovery::Manager::OnRemoteChange ( const std::string &  msg_str)
protected

◆ OnTopoModuleLeave()

virtual void apollo::cyber::service_discovery::Manager::OnTopoModuleLeave ( const std::string &  host_name,
int  process_id 
)
pure virtual

Called when a process' topology manager instance leave.

Parameters
host_nameis the process's host's name
process_idis the process' id

◆ Publish()

bool apollo::cyber::service_discovery::Manager::Publish ( const ChangeMsg &  msg)
protected

◆ RemoveChangeListener()

void apollo::cyber::service_discovery::Manager::RemoveChangeListener ( const ChangeConnection conn)

Remove our listener for topology change.

Parameters
connis the return value of AddChangeListener

◆ Shutdown()

virtual void apollo::cyber::service_discovery::Manager::Shutdown ( )
virtual

Shutdown module.

◆ StartDiscovery()

bool apollo::cyber::service_discovery::Manager::StartDiscovery ( RtpsParticipant participant)

Startup topology discovery.

Parameters
participantis used to create rtps Publisher and Subscriber
Returns
true if start successfully
false if start fail

◆ StopDiscovery()

void apollo::cyber::service_discovery::Manager::StopDiscovery ( )

Stop topology discovery.

Member Data Documentation

◆ allowed_role_

int apollo::cyber::service_discovery::Manager::allowed_role_
protected

◆ change_type_

ChangeType apollo::cyber::service_discovery::Manager::change_type_
protected

◆ channel_name_

std::string apollo::cyber::service_discovery::Manager::channel_name_
protected

◆ host_name_

std::string apollo::cyber::service_discovery::Manager::host_name_
protected

◆ is_discovery_started_

std::atomic<bool> apollo::cyber::service_discovery::Manager::is_discovery_started_
protected

◆ is_shutdown_

std::atomic<bool> apollo::cyber::service_discovery::Manager::is_shutdown_
protected

◆ listener_

SubscriberListener* apollo::cyber::service_discovery::Manager::listener_
protected

◆ lock_

std::mutex apollo::cyber::service_discovery::Manager::lock_
protected

◆ process_id_

int apollo::cyber::service_discovery::Manager::process_id_
protected

◆ publisher_

eprosima::fastrtps::Publisher* apollo::cyber::service_discovery::Manager::publisher_
protected

◆ signal_

ChangeSignal apollo::cyber::service_discovery::Manager::signal_
protected

◆ subscriber_

eprosima::fastrtps::Subscriber* apollo::cyber::service_discovery::Manager::subscriber_
protected

The documentation for this class was generated from the following file: