17 #ifndef CYBER_SERVICE_DISCOVERY_SPECIFIC_MANAGER_MANAGER_H_ 18 #define CYBER_SERVICE_DISCOVERY_SPECIFIC_MANAGER_MANAGER_H_ 25 #include "fastrtps/Domain.h" 26 #include "fastrtps/attributes/PublisherAttributes.h" 27 #include "fastrtps/attributes/SubscriberAttributes.h" 28 #include "fastrtps/participant/Participant.h" 29 #include "fastrtps/publisher/Publisher.h" 30 #include "fastrtps/subscriber/Subscriber.h" 33 #include "cyber/proto/topology_change.pb.h" 38 namespace service_discovery {
40 using proto::ChangeMsg;
41 using proto::ChangeType;
42 using proto::OperateType;
43 using proto::RoleAttributes;
44 using proto::RoleType;
54 using ChangeFunc = std::function<void(const ChangeMsg&)>;
99 bool Join(
const RoleAttributes& attr, RoleType role,
100 bool need_publish =
true);
111 bool Leave(
const RoleAttributes& attr, RoleType role);
142 virtual bool Check(
const RoleAttributes& attr) = 0;
143 virtual void Dispose(
const ChangeMsg& msg) = 0;
144 virtual bool NeedPublish(
const ChangeMsg& msg)
const;
146 void Convert(
const RoleAttributes& attr, RoleType role, OperateType opt,
149 void Notify(
const ChangeMsg& msg);
150 bool Publish(
const ChangeMsg& msg);
173 #endif // CYBER_SERVICE_DISCOVERY_SPECIFIC_MANAGER_MANAGER_H_ std::string host_name_
Definition: manager.h:158
void OnRemoteChange(const std::string &msg_str)
bool StartDiscovery(RtpsParticipant *participant)
Startup topology discovery.
void(* func)(void *)
Definition: routine_context.h:41
int process_id_
Definition: manager.h:159
int allowed_role_
Definition: manager.h:156
std::string channel_name_
Definition: manager.h:160
std::function< void(const ChangeMsg &)> ChangeFunc
Definition: manager.h:54
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
virtual bool Check(const RoleAttributes &attr)=0
void StopDiscovery()
Stop topology discovery.
eprosima::fastrtps::PublisherAttributes RtpsPublisherAttr
Definition: manager.h:58
eprosima::fastrtps::Participant RtpsParticipant
Definition: manager.h:57
eprosima::fastrtps::Publisher * publisher_
Definition: manager.h:161
Base class for management of Topology elements. Manager can Join/Leave the Topology, and Listen the topology change.
Definition: manager.h:51
SubscriberListener * listener_
Definition: manager.h:164
virtual void Shutdown()
Shutdown module.
bool CreateSubscriber(RtpsParticipant *participant)
virtual void OnTopoModuleLeave(const std::string &host_name, int process_id)=0
Called when a process' topology manager instance leave.
Definition: subscriber_listener.h:33
ChangeConnection AddChangeListener(const ChangeFunc &func)
Add topology change listener, when topology changed, func will be called.
bool CreatePublisher(RtpsParticipant *participant)
std::atomic< bool > is_discovery_started_
Definition: manager.h:155
std::atomic< bool > is_shutdown_
Definition: manager.h:154
bool Leave(const RoleAttributes &attr, RoleType role)
Leave the topology.
virtual bool NeedPublish(const ChangeMsg &msg) const
std::mutex lock_
Definition: manager.h:162
ChangeType change_type_
Definition: manager.h:157
eprosima::fastrtps::Subscriber * subscriber_
Definition: manager.h:163
virtual void Dispose(const ChangeMsg &msg)=0
Manager()
Construct a new Manager object.
bool Publish(const ChangeMsg &msg)
virtual ~Manager()
Destroy the Manager object.
bool IsFromSameProcess(const ChangeMsg &msg)
void Notify(const ChangeMsg &msg)
void Convert(const RoleAttributes &attr, RoleType role, OperateType opt, ChangeMsg *msg)
ChangeSignal signal_
Definition: manager.h:166
void RemoveChangeListener(const ChangeConnection &conn)
Remove our listener for topology change.
bool Join(const RoleAttributes &attr, RoleType role, bool need_publish=true)
Join the topology.
eprosima::fastrtps::SubscriberAttributes RtpsSubscriberAttr
Definition: manager.h:59