26 #include <boost/tuple/tuple_comparison.hpp>
27 #include <boost/unordered_set.hpp>
31 namespace RobotRaconteur
36 class Discovery_nodestorage;
37 class ServiceInfo2Subscription_client;
38 class ServiceSubscription_client;
39 class ServiceSubscription_retrytimer;
40 class WireSubscription_connection;
41 class PipeSubscription_connection;
42 class WireSubscription_send_iterator;
43 class PipeSubscription_send_iterator;
44 class ServiceSubscription_custom_member_subscribers;
45 class ServiceSubscriptionManager_subscription;
48 class ROBOTRACONTEUR_CORE_API WireConnectionBase;
51 class ROBOTRACONTEUR_CORE_API WireSubscriptionBase;
53 class WireSubscription;
55 class ROBOTRACONTEUR_CORE_API PipeEndpointBase;
58 class ROBOTRACONTEUR_CORE_API PipeSubscriptionBase;
60 class PipeSubscription;
61 class ROBOTRACONTEUR_CORE_API SubObjectSubscription;
62 class ROBOTRACONTEUR_CORE_API ServiceSubscriptionManager;
160 bool IsMatch(boost::string_ref name, boost::string_ref value)
const;
168 bool IsMatch(
const std::vector<std::string>& values)
const;
192 bool IsMatch(
const std::map<std::string, std::string>& values)
const;
221 ROBOTRACONTEUR_CORE_API
223 boost::string_ref combined_identifier);
242 boost::string_ref name, boost::string_ref identifier_name, boost::string_ref uuid_string);
272 std::vector<ServiceSubscriptionFilterAttributeGroup>
Groups;
299 std::vector<ServiceSubscriptionFilterAttribute> attributes);
307 std::vector<ServiceSubscriptionFilterAttributeGroup> groups);
334 bool IsMatch(
const std::vector<std::string>& values)
const;
358 bool IsMatch(
const std::map<std::string, std::string>& values)
const;
360 bool IsMatch(
const RR_INTRUSIVE_PTR<RRValue>& value)
const;
376 std::vector<RR_SHARED_PTR<ServiceSubscriptionFilterNode> >
Nodes;
382 std::map<std::string, ServiceSubscriptionFilterAttributeGroup>
Attributes;
434 class IServiceSubscription
437 friend class detail::Discovery;
440 virtual void Init(
const std::vector<std::string>& service_types,
441 const RR_SHARED_PTR<ServiceSubscriptionFilter>& filter) = 0;
442 virtual void NodeUpdated(RR_SHARED_PTR<detail::Discovery_nodestorage> storage) = 0;
443 virtual void NodeLost(RR_SHARED_PTR<detail::Discovery_nodestorage> storage) = 0;
446 virtual void Close() = 0;
447 virtual ~IServiceSubscription(){};
461 public RR_ENABLE_SHARED_FROM_THIS<ServiceInfo2Subscription>,
462 private boost::noncopyable
465 friend class detail::Discovery;
468 typedef boost::signals2::connection event_connection;
524 RR_OVIRTUAL
void Close() RR_OVERRIDE;
529 boost::mutex this_lock;
536 RR_WEAK_PTR<detail::Discovery> parent;
538 std::vector<std::
string> service_types;
541 uint32_t retry_delay;
555 RR_OVIRTUAL
void Init(const std::vector<std::
string>& service_types,
557 RR_OVIRTUAL
void NodeUpdated(RR_SHARED_PTR<detail::Discovery_nodestorage> storage) RR_OVERRIDE;
558 RR_OVIRTUAL
void NodeLost(RR_SHARED_PTR<detail::Discovery_nodestorage> storage) RR_OVERRIDE;
566 template <
typename T>
567 void AsyncGetDefaultClient_handler_adapter(
568 const boost::function<
void(
const RR_SHARED_PTR<T>&,
const RR_SHARED_PTR<RobotRaconteurException>&)>& handler,
569 const RR_SHARED_PTR<RRObject>& obj,
const RR_SHARED_PTR<RobotRaconteurException>& err)
573 handler(RR_SHARED_PTR<T>(), err);
577 RR_SHARED_PTR<T> obj1 = RR_DYNAMIC_POINTER_CAST<T>(obj);
580 handler(RR_SHARED_PTR<T>(), RR_MAKE_SHARED<ConnectionException>(
"Cannot cast client to requested type"));
584 handler(obj1, RR_SHARED_PTR<RobotRaconteurException>());
611 public RR_ENABLE_SHARED_FROM_THIS<ServiceSubscription>,
612 private boost::noncopyable
615 friend class detail::Discovery;
616 friend class detail::ServiceSubscription_retrytimer;
619 friend class detail::ServiceSubscription_custom_member_subscribers;
623 typedef boost::signals2::connection event_connection;
657 const RR_SHARED_PTR<RRObject>&)>
674 const RR_SHARED_PTR<RRObject>&)>
692 const std::vector<std::string>&,
const RR_SHARED_PTR<RobotRaconteurException>&)>
701 RR_OVIRTUAL
void Close() RR_OVERRIDE;
712 virtual
void ClaimClient(const RR_SHARED_PTR<
RRObject>& client);
721 virtual
void ReleaseClient(const RR_SHARED_PTR<
RRObject>& client);
730 uint32_t GetConnectRetryDelay();
739 void SetConnectRetryDelay(uint32_t delay_milliseconds);
757 template <typename T>
758 RR_SHARED_PTR<
WireSubscription<T> > SubscribeWire(boost::string_ref membername, boost::string_ref servicepath = "")
760 RR_SHARED_PTR<WireSubscription<T> > o =
761 RR_MAKE_SHARED<WireSubscription<T> >(shared_from_this(), membername, servicepath);
782 template <
typename T>
783 RR_SHARED_PTR<PipeSubscription<T> >
SubscribePipe(boost::string_ref membername, boost::string_ref servicepath =
"",
784 uint32_t max_recv_packets = std::numeric_limits<uint32_t>::max())
786 RR_SHARED_PTR<PipeSubscription<T> > o =
787 RR_MAKE_SHARED<PipeSubscription<T> >(shared_from_this(), membername, servicepath, max_recv_packets);
807 template <
typename T>
810 return rr_cast<T>(GetDefaultClientBase());
824 template <
typename T>
827 RR_SHARED_PTR<RRObject> c;
828 if (!TryGetDefaultClientBase(c))
832 RR_SHARED_PTR<T> c1 = RR_DYNAMIC_POINTER_CAST<T>(c);
856 template <
typename T>
859 return rr_cast<T>(GetDefaultClientWaitBase(timeout));
874 template <
typename T>
877 RR_SHARED_PTR<RRObject> c;
878 if (!TryGetDefaultClientWaitBase(c, timeout))
882 RR_SHARED_PTR<T> c1 = RR_DYNAMIC_POINTER_CAST<T>(c);
899 template <
typename T>
901 boost::function<
void(
const RR_SHARED_PTR<T>&,
const RR_SHARED_PTR<RobotRaconteurException>&)> handler,
904 AsyncGetDefaultClientBase(boost::bind(&detail::AsyncGetDefaultClient_handler_adapter<T>, handler,
905 RR_BOOST_PLACEHOLDERS(_1), RR_BOOST_PLACEHOLDERS(_2)),
936 boost::string_ref object_type =
"",
bool close_connected =
false);
951 void UpdateServiceURL(
const std::vector<std::string>& url, boost::string_ref username =
"",
954 boost::string_ref object_type =
"",
bool close_connected =
false);
966 const std::vector<std::string>& service_types,
967 const RR_SHARED_PTR<ServiceSubscriptionFilter>& filter = RR_SHARED_PTR<ServiceSubscriptionFilter>());
986 boost::string_ref objecttype =
"");
988 RR_SHARED_PTR<RobotRaconteurNode> GetNode();
991 boost::mutex this_lock;
995 std::map<ServiceSubscriptionClientID, RR_SHARED_PTR<detail::ServiceSubscription_client> > clients;
997 RR_WEAK_PTR<RobotRaconteurNode> node;
998 RR_WEAK_PTR<detail::Discovery> parent;
1000 std::vector<std::string> service_types;
1001 RR_SHARED_PTR<ServiceSubscriptionFilter> filter;
1003 uint32_t retry_delay;
1006 const RR_SHARED_PTR<RRObject>&)>
1009 const RR_SHARED_PTR<RRObject>&)>
1010 disconnect_listeners;
1012 const std::vector<std::string>&,
const RR_SHARED_PTR<RobotRaconteurException>&)>
1013 connect_failed_listeners;
1015 RR_SHARED_PTR<RR_BOOST_ASIO_STRAND> listener_strand;
1017 boost::unordered_set<RR_SHARED_PTR<WireSubscriptionBase> > wire_subscriptions;
1018 boost::unordered_set<RR_SHARED_PTR<PipeSubscriptionBase> > pipe_subscriptions;
1020 bool use_service_url;
1021 std::vector<std::string> service_url;
1022 std::string service_url_username;
1023 RR_INTRUSIVE_PTR<RRMap<std::string, RRValue> > service_url_credentials;
1030 RR_OVIRTUAL
void Init(
const std::vector<std::string>& service_types,
1031 const RR_SHARED_PTR<ServiceSubscriptionFilter>& filter) RR_OVERRIDE;
1032 virtual void InitServiceURL(
const std::vector<std::string>& url, boost::string_ref username =
"",
1035 boost::string_ref objecttype =
"");
1036 RR_OVIRTUAL
void NodeUpdated(RR_SHARED_PTR<detail::Discovery_nodestorage> storage) RR_OVERRIDE;
1037 RR_OVIRTUAL
void NodeLost(RR_SHARED_PTR<detail::Discovery_nodestorage> storage) RR_OVERRIDE;
1039 void ClientConnected(
const RR_SHARED_PTR<RRObject>& c,
const RR_SHARED_PTR<RobotRaconteurException>& err,
1040 const RR_SHARED_PTR<detail::ServiceSubscription_client>& c2,
1041 const std::vector<std::string>& url);
1042 void ConnectRetry(
const RR_SHARED_PTR<detail::ServiceSubscription_client>& c2);
1043 void ConnectRetry2(
const RR_SHARED_PTR<detail::ServiceSubscription_client>& c2);
1045 static void ClientEvent(RR_WEAK_PTR<ServiceSubscription> this_,
const RR_SHARED_PTR<ClientContext>& ctx,
1047 RR_WEAK_PTR<detail::ServiceSubscription_client> c2);
1051 const RR_SHARED_PTR<RRObject>& client);
1053 const std::vector<std::string>& url,
1054 const RR_SHARED_PTR<RobotRaconteurException>& err);
1056 void SubscribeWire1(
const RR_SHARED_PTR<WireSubscriptionBase>& s);
1057 void SubscribePipe1(
const RR_SHARED_PTR<PipeSubscriptionBase>& s);
1059 void WireSubscriptionClosed(
const RR_SHARED_PTR<WireSubscriptionBase>& s);
1060 void PipeSubscriptionClosed(
const RR_SHARED_PTR<PipeSubscriptionBase>& s);
1062 RR_SHARED_PTR<RRObject> GetDefaultClientBase();
1063 bool TryGetDefaultClientBase(RR_SHARED_PTR<RRObject>& client_out);
1066 bool TryGetDefaultClientWaitBase(RR_SHARED_PTR<RRObject>& client_out, int32_t timeout =
RR_TIMEOUT_INFINITE);
1068 void AsyncGetDefaultClientBase(
1069 boost::function<
void(
const RR_SHARED_PTR<RRObject>&,
const RR_SHARED_PTR<RobotRaconteurException>&)> handler,
1082 private boost::noncopyable
1087 friend class detail::WireSubscription_connection;
1088 friend class detail::WireSubscription_send_iterator;
1090 typedef boost::signals2::connection event_connection;
1094 RR_INTRUSIVE_PTR<RRValue> GetInValueBase(
TimeSpec* time = NULL,
1095 RR_SHARED_PTR<WireConnectionBase>* connection = NULL);
1096 bool TryGetInValueBase(RR_INTRUSIVE_PTR<RRValue>& val,
TimeSpec* time = NULL,
1097 RR_SHARED_PTR<WireConnectionBase>* connection = NULL);
1158 void SetOutValueAllBase(
const RR_INTRUSIVE_PTR<RRValue>& val);
1169 WireSubscriptionBase(
const RR_SHARED_PTR<ServiceSubscription>& parent, boost::string_ref membername,
1170 boost::string_ref servicepath);
1172 RR_SHARED_PTR<RobotRaconteurNode> GetNode();
1178 void WireConnectionClosed(
const RR_SHARED_PTR<detail::WireSubscription_connection>& wire);
1179 void WireValueChanged(
const RR_SHARED_PTR<detail::WireSubscription_connection>& wire,
1180 const RR_INTRUSIVE_PTR<RRValue>& value,
const TimeSpec& time);
1182 boost::mutex this_lock;
1183 boost::unordered_map<ServiceSubscriptionClientID, RR_SHARED_PTR<detail::WireSubscription_connection> > connections;
1184 boost::initialized<bool> closed;
1185 RR_WEAK_PTR<RobotRaconteurNode> node;
1186 RR_WEAK_PTR<ServiceSubscription> parent;
1188 RR_INTRUSIVE_PTR<RRValue> in_value;
1190 boost::initialized<bool> in_value_valid;
1191 RR_SHARED_PTR<WireConnectionBase> in_value_connection;
1192 int32_t in_value_lifespan;
1193 boost::posix_time::ptime in_value_time_local;
1195 boost::condition_variable in_value_wait;
1197 boost::initialized<bool> ignore_in_value;
1199 std::string membername;
1200 std::string servicepath;
1202 virtual void fire_WireValueChanged(
const RR_INTRUSIVE_PTR<RRValue>& value,
const TimeSpec& time,
1203 const RR_SHARED_PTR<WireConnectionBase>& connection);
1204 virtual bool isempty_WireValueChanged();
1205 RR_SHARED_PTR<detail::async_signal_pool_semaphore> wire_value_changed_semaphore;
1231 template <
typename T>
1235 WireSubscription(
const RR_SHARED_PTR<ServiceSubscription>& parent, boost::string_ref membername,
1236 boost::string_ref servicepath)
1251 RR_SHARED_PTR<WireConnectionBase> connection1;
1252 T o = RRPrimUtil<T>::PreUnpack(GetInValueBase(time, &connection1));
1255 *connection = RR_DYNAMIC_POINTER_CAST<WireConnection<T> >(connection1);
1274 RR_INTRUSIVE_PTR<RRValue> o;
1275 RR_SHARED_PTR<WireConnectionBase> connection1;
1276 if (!TryGetInValueBase(o, time, &connection1))
1278 val = RRPrimUtil<T>::PreUnpack(o);
1279 if (connection && connection1)
1281 *connection = RR_DYNAMIC_POINTER_CAST<WireConnection<T> >(connection1);
1295 void SetOutValueAll(
const T& val) { SetOutValueAllBase(RRPrimUtil<T>::PrePack(val)); }
1311 return wire_value_changed.connect(f);
1318 RR_OVIRTUAL
void fire_WireValueChanged(
const RR_INTRUSIVE_PTR<RRValue>& value,
const TimeSpec& time,
1319 const RR_SHARED_PTR<WireConnectionBase>& connection) RR_OVERRIDE
1321 RR_UNUSED(connection);
1323 RRPrimUtil<T>::PreUnpack(value), time);
1326 RR_OVIRTUAL
bool isempty_WireValueChanged() RR_OVERRIDE {
return wire_value_changed.empty(); }
1336 private boost::noncopyable
1339 friend class PipeConnectionBase;
1341 friend class detail::PipeSubscription_connection;
1342 friend class detail::PipeSubscription_send_iterator;
1344 typedef boost::signals2::connection event_connection;
1348 RR_INTRUSIVE_PTR<RRValue> ReceivePacketBase();
1349 bool TryReceivePacketBase(RR_INTRUSIVE_PTR<RRValue>& packet);
1350 bool TryReceivePacketBaseWait(RR_INTRUSIVE_PTR<RRValue>& packet, int32_t timeout =
RR_TIMEOUT_INFINITE,
1351 bool peek =
false, RR_SHARED_PTR<PipeEndpointBase>* ep = NULL);
1388 void AsyncSendPacketAllBase(
const RR_INTRUSIVE_PTR<RRValue>& packet);
1399 PipeSubscriptionBase(
const RR_SHARED_PTR<ServiceSubscription>& parent, boost::string_ref membername,
1400 boost::string_ref servicepath =
"", int32_t max_recv_packets = -1,
1401 int32_t max_send_backlog = 5);
1403 RR_SHARED_PTR<RobotRaconteurNode> GetNode();
1409 void PipeEndpointClosed(
const RR_SHARED_PTR<detail::PipeSubscription_connection>& pipe);
1410 void PipeEndpointPacketReceived(
const RR_SHARED_PTR<detail::PipeSubscription_connection>& pipe,
1411 const RR_INTRUSIVE_PTR<RRValue>& value);
1413 boost::mutex this_lock;
1414 boost::unordered_map<ServiceSubscriptionClientID, RR_SHARED_PTR<detail::PipeSubscription_connection> > connections;
1415 boost::initialized<bool> closed;
1416 RR_WEAK_PTR<ServiceSubscription> parent;
1417 RR_WEAK_PTR<RobotRaconteurNode> node;
1419 std::deque<boost::tuple<RR_INTRUSIVE_PTR<RRValue>, RR_SHARED_PTR<PipeEndpointBase> > > recv_packets;
1420 boost::condition_variable recv_packets_wait;
1422 std::string membername;
1423 std::string servicepath;
1425 boost::initialized<int32_t> max_recv_packets;
1426 boost::initialized<bool> ignore_incoming_packets;
1428 boost::initialized<int32_t> max_send_backlog;
1430 virtual void fire_PipePacketReceived();
1431 virtual bool isempty_PipePacketReceived();
1432 RR_SHARED_PTR<detail::async_signal_pool_semaphore> pipe_packet_received_semaphore;
1458 template <
typename T>
1462 PipeSubscription(
const RR_SHARED_PTR<ServiceSubscription>& parent, boost::string_ref membername,
1463 boost::string_ref servicepath =
"", int32_t max_recv_packets = -1, int32_t max_send_backlog = 5)
1466 RR_UNUSED(max_send_backlog);
1491 RR_INTRUSIVE_PTR<RRValue> o;
1492 if (!TryReceivePacketBase(o))
1494 packet = RRPrimUtil<T>::PreUnpack(o);
1512 RR_INTRUSIVE_PTR<RRValue> o;
1513 RR_SHARED_PTR<PipeEndpointBase> ep1;
1514 if (!TryReceivePacketBaseWait(o, timeout, peek, &ep1))
1516 packet = RRPrimUtil<T>::PreUnpack(o);
1519 *ep = RR_DYNAMIC_POINTER_CAST<PipeEndpoint<T> >(ep1);
1550 return pipe_packet_received.connect(f);
1554 boost::signals2::signal<void(
const RR_SHARED_PTR<
PipeSubscription<T> >&)> pipe_packet_received;
1556 RR_OVIRTUAL
void fire_PipePacketReceived() RR_OVERRIDE
1561 RR_OVIRTUAL
bool isempty_PipePacketReceived() RR_OVERRIDE {
return pipe_packet_received.empty(); }
1579 private boost::noncopyable
1599 template <
typename T>
1602 return rr_cast<T>(GetDefaultClientBase());
1616 template <
typename T>
1619 RR_SHARED_PTR<RRObject> c;
1620 if (!TryGetDefaultClientBase(c))
1624 RR_SHARED_PTR<T> c1 = RR_DYNAMIC_POINTER_CAST<T>(c);
1647 template <
typename T>
1650 return rr_cast<T>(GetDefaultClientWaitBase(timeout));
1665 template <
typename T>
1668 RR_SHARED_PTR<RRObject> c;
1669 if (!TryGetDefaultClientWaitBase(c, timeout))
1673 RR_SHARED_PTR<T> c1 = RR_DYNAMIC_POINTER_CAST<T>(c);
1692 template <
typename T>
1694 boost::function<
void(
const RR_SHARED_PTR<T>&,
const RR_SHARED_PTR<RobotRaconteurException>&)> handler,
1697 AsyncGetDefaultClientBase(boost::bind(&detail::AsyncGetDefaultClient_handler_adapter<T>, handler,
1698 RR_BOOST_PLACEHOLDERS(_1), RR_BOOST_PLACEHOLDERS(_2)),
1713 SubObjectSubscription(
const RR_SHARED_PTR<ServiceSubscription>& parent, boost::string_ref servicepath,
1714 boost::string_ref objecttype);
1716 RR_SHARED_PTR<RobotRaconteurNode> GetNode();
1719 RR_SHARED_PTR<RRObject> GetDefaultClientBase();
1720 bool TryGetDefaultClientBase(RR_SHARED_PTR<RRObject>& client_out);
1723 bool TryGetDefaultClientWaitBase(RR_SHARED_PTR<RRObject>& client_out, int32_t timeout =
RR_TIMEOUT_INFINITE);
1725 void AsyncGetDefaultClientBase(
1726 boost::function<
void(
const RR_SHARED_PTR<RRObject>&,
const RR_SHARED_PTR<RobotRaconteurException>&)> handler,
1729 RR_WEAK_PTR<ServiceSubscription> parent;
1730 RR_WEAK_PTR<RobotRaconteurNode> node;
1731 std::string servicepath;
1732 std::string objecttype;
1772 RR_SHARED_PTR<ServiceSubscriptionFilter>
Filter;
1792 const boost::string_ref& Name,
1794 ServiceSubscriptionManager_CONNECTION_METHOD_DEFAULT,
1795 const std::vector<std::string>& Urls = std::vector<std::string>(),
const boost::string_ref& UrlUsername =
"",
1798 const std::vector<std::string>& ServiceTypes = std::vector<std::string>(),
1799 const RR_SHARED_PTR<ServiceSubscriptionFilter>& Filter = RR_SHARED_PTR<ServiceSubscriptionFilter>(),
1800 bool Enabled =
true);
1829 void Init(
const std::vector<ServiceSubscriptionManagerDetails>& details);
1868 RR_SHARED_PTR<ServiceSubscription>
GetSubscription(
const boost::string_ref& name,
bool force_create =
true);
1891 void Close(
bool close_subscriptions =
true);
1915 RR_WEAK_PTR<RobotRaconteurNode> node;
1917 boost::mutex this_lock;
1919 boost::unordered_map<std::string, detail::ServiceSubscriptionManager_subscription> subscriptions;
1923 void UpdateSubscription(detail::ServiceSubscriptionManager_subscription& sub,
1929 class ROBOTRACONTEUR_CORE_API WireSubscription_send_iterator
1932 RR_SHARED_PTR<WireSubscriptionBase> subscription;
1933 boost::mutex::scoped_lock subscription_lock;
1934 boost::unordered_map<ServiceSubscriptionClientID, RR_SHARED_PTR<WireSubscription_connection> >::iterator
1935 connections_iterator;
1936 boost::unordered_map<ServiceSubscriptionClientID, RR_SHARED_PTR<WireSubscription_connection> >::iterator
1940 WireSubscription_send_iterator(
const RR_SHARED_PTR<WireSubscriptionBase>& subscription);
1941 RR_SHARED_PTR<WireConnectionBase> Next();
1942 void SetOutValue(
const RR_INTRUSIVE_PTR<RRValue>& value);
1943 virtual ~WireSubscription_send_iterator();
1946 class ROBOTRACONTEUR_CORE_API PipeSubscription_send_iterator
1949 RR_SHARED_PTR<PipeSubscriptionBase> subscription;
1950 boost::mutex::scoped_lock subscription_lock;
1951 boost::unordered_map<ServiceSubscriptionClientID, RR_SHARED_PTR<PipeSubscription_connection> >::iterator
1952 connections_iterator;
1953 boost::unordered_map<ServiceSubscriptionClientID, RR_SHARED_PTR<PipeSubscription_connection> >::iterator
1957 PipeSubscription_send_iterator(
const RR_SHARED_PTR<PipeSubscriptionBase>& subscription);
1958 RR_SHARED_PTR<PipeEndpointBase> Next();
1959 void AsyncSendPacket(
const RR_INTRUSIVE_PTR<RRValue>& packet);
1960 virtual ~PipeSubscription_send_iterator();
1963 class ROBOTRACONTEUR_CORE_API ServiceSubscription_custom_member_subscribers
1966 static void SubscribeWire(
const RR_SHARED_PTR<ServiceSubscription>& s,
1967 const RR_SHARED_PTR<WireSubscriptionBase>& o);
1968 static void SubscribePipe(
const RR_SHARED_PTR<ServiceSubscription>& s,
1969 const RR_SHARED_PTR<PipeSubscriptionBase>& o);
1973 #ifndef ROBOTRACONTEUR_NO_CXX11_TEMPLATE_ALIASES
1983 template <
typename T>
1986 template <
typename T>
ClientServiceListenerEventType
Enum of client listener events.
Definition: RobotRaconteurConstants.h:500
#define RR_TIMEOUT_INFINITE
Disable timeout for asynchronous operations.
Definition: RobotRaconteurConstants.h:566
boost::shared_ptr< ServiceInfo2Subscription > ServiceInfo2SubscriptionPtr
Convenience alias for ServiceInfo2Subscription shared_ptr.
Definition: Subscription.h:1979
boost::shared_ptr< ServiceSubscription > ServiceSubscriptionPtr
Convenience alias for ServiceSubscription shared_ptr.
Definition: Subscription.h:1981
boost::shared_ptr< ServiceSubscriptionFilterNode > ServiceSubscriptionFilterNodePtr
Convenience alias for ServiceSubscriptionFilterNode shared_ptr.
Definition: Subscription.h:1975
ServiceSubscriptionFilterAttribute CreateServiceSubscriptionFilterAttributeIdentifier(boost::string_ref identifier_name, boost::string_ref uuid_string)
Create a ServiceSubscriptionFilterAttribute from an identifier.
boost::shared_ptr< SubObjectSubscription > SubObjectSubscriptionPtr
Convenience alias for SubObjectSubscription shared_ptr.
Definition: Subscription.h:1989
boost::shared_ptr< WireSubscription< T > > WireSubscriptionPtr
Convenience alias for WireSubscription shared_ptr.
Definition: Subscription.h:1987
ServiceSubscriptionFilterAttribute CreateServiceSubscriptionFilterAttributeRegex(boost::string_ref regex_value)
Create a ServiceSubscriptionFilterAttribute from a regex string.
boost::shared_ptr< PipeSubscription< T > > PipeSubscriptionPtr
Convenience alias for PipeSubscription shared_ptr.
Definition: Subscription.h:1984
ServiceSubscriptionManager_CONNECTION_METHOD
Connection method for ServiceSubscriptionManager subscription.
Definition: Subscription.h:1742
@ ServiceSubscriptionManager_CONNECTION_METHOD_URL
Use URLs types for subscription.
Definition: Subscription.h:1746
@ ServiceSubscriptionManager_CONNECTION_METHOD_TYPE
Use service types for subscription.
Definition: Subscription.h:1748
@ ServiceSubscriptionManager_CONNECTION_METHOD_DEFAULT
Implicitly select between URL and service types.
Definition: Subscription.h:1744
boost::shared_ptr< ServiceSubscriptionFilter > ServiceSubscriptionFilterPtr
Convenience alias for ServiceSubscriptionFilter shared_ptr.
Definition: Subscription.h:1977
ServiceSubscriptionFilterAttributeGroupOperation
Comparison operations for ServiceSubscriptionFilterAttributeGroup.
Definition: Subscription.h:249
@ ServiceSubscriptionFilterAttributeGroupOperation_NAND
NAND operation.
Definition: Subscription.h:257
@ ServiceSubscriptionFilterAttributeGroupOperation_AND
AND operation.
Definition: Subscription.h:253
@ ServiceSubscriptionFilterAttributeGroupOperation_NOR
NOR operation. Also used for NOT.
Definition: Subscription.h:255
@ ServiceSubscriptionFilterAttributeGroupOperation_OR
OR operation.
Definition: Subscription.h:251
ServiceSubscriptionFilterAttribute CreateServiceSubscriptionFilterAttributeCombinedIdentifier(boost::string_ref combined_identifier)
Create a ServiceSubscriptionFilterAttribute from a combined identifier string.
NodeID UUID storage and generation.
Definition: NodeID.h:58
Pipe endpoint used to transmit reliable or unreliable data streams.
Definition: PipeMember.h:282
Base class for PipeSubscription.
Definition: Subscription.h:1337
size_t Available()
Get the number of packets available to receive.
void Close()
Closes the pipe subscription.
void SetIgnoreReceived(bool ignore)
Set if incoming packets should be ignored.
bool GetIgnoreReceived()
Get if incoming packets are currently being ignored.
size_t GetActivePipeEndpointCount()
Get the number of pipe endpoints currently connected.
Subscription for pipe members that aggregates incoming packets from client pipe endpoints.
Definition: Subscription.h:1460
event_connection AddPipePacketReceivedListener(boost::function< void(const boost::shared_ptr< PipeSubscription< T > > &)> f)
Adds a pipe packet received event listener function.
Definition: Subscription.h:1548
T ReceivePacket()
Dequeue a packet from the receive queue.
Definition: Subscription.h:1476
bool TryReceivePacketWait(T &packet, int32_t timeout=RR_TIMEOUT_INFINITE, bool peek=false, boost::shared_ptr< PipeEndpoint< T > > *ep=NULL)
Try dequeuing a packet from the receive queue, optionally waiting or peeking the packet.
Definition: Subscription.h:1509
void AsyncSendPacketAll(const T &packet)
Sends a packet to all connected pipe endpoints.
Definition: Subscription.h:1532
bool TryReceivePacket(T &packet)
Try dequeuing a packet from the receive queue.
Definition: Subscription.h:1489
Numeric primitive or character array value type.
Definition: DataTypes.h:580
List container value type.
Definition: DataTypes.h:921
Map container value type.
Definition: DataTypes.h:795
Base class for all Robot Raconteur objects.
Definition: DataTypes.h:227
The central node implementation.
Definition: RobotRaconteurNode.h:132
static boost::shared_ptr< RobotRaconteurNode > sp()
Singleton shared_ptr accessor.
Contains information about a service found using discovery.
Definition: Discovery.h:49
Subscription for information about detected services.
Definition: Subscription.h:463
event_connection AddServiceLostListener(boost::function< void(const boost::shared_ptr< ServiceInfo2Subscription > &, const ServiceSubscriptionClientID &, const ServiceInfo2 &)> handler)
Add a listener callback that is invoked when a service is lost.
std::map< ServiceSubscriptionClientID, ServiceInfo2 > GetDetectedServiceInfo2()
Returns a map of detected services.
event_connection AddServiceDetectedListener(boost::function< void(const boost::shared_ptr< ServiceInfo2Subscription > &, const ServiceSubscriptionClientID &, const ServiceInfo2 &)> handler)
Add a listener callback that is invoked when a service is detected.
ClientID for use with ServiceSubscription.
Definition: Subscription.h:401
ServiceSubscriptionClientID(const ::RobotRaconteur::NodeID &nodeid, boost::string_ref service_name)
Construct a ServiceSubscriptionClientID.
std::string ServiceName
Definition: Subscription.h:406
bool operator!=(const ServiceSubscriptionClientID &id2) const
bool operator<(const ServiceSubscriptionClientID &id2) const
::RobotRaconteur::NodeID NodeID
Definition: Subscription.h:404
ServiceSubscriptionClientID()
Construct an empty ServiceSubscriptionClientID.
bool operator==(const ServiceSubscriptionClientID &id2) const
Subscription filter attribute group for use with ServiceSubscriptionFilter.
Definition: Subscription.h:267
bool SplitStringAttribute
True if string attributes will be split into a list with delimiter (default ",")
Definition: Subscription.h:277
bool IsMatch(const std::vector< std::string > &values) const
Compare the group to a list of values.
bool IsMatch(const boost::intrusive_ptr< RRList< RRValue > > &values) const
Compare the group to a list of values.
bool IsMatch(boost::string_ref value) const
Compare the group to a value.
std::vector< ServiceSubscriptionFilterAttributeGroup > Groups
The nested groups in the group.
Definition: Subscription.h:272
ServiceSubscriptionFilterAttributeGroupOperation Operation
The operation to use for matching the attributes and groups.
Definition: Subscription.h:274
ServiceSubscriptionFilterAttributeGroup()
Construct a new Service Subscription Filter Attribute Group object.
ServiceSubscriptionFilterAttributeGroup(ServiceSubscriptionFilterAttributeGroupOperation operation, std::vector< ServiceSubscriptionFilterAttribute > attributes)
Construct a new Service Subscription Filter Attribute Group object.
char SplitStringDelimiter
Delimiter to use to split string attributes (default ",")
Definition: Subscription.h:279
ServiceSubscriptionFilterAttributeGroup(ServiceSubscriptionFilterAttributeGroupOperation operation)
Construct a new Service Subscription Filter Attribute Group object.
bool IsMatch(const boost::intrusive_ptr< RRMap< std::string, RRValue > > &values) const
Compare the group to a map of values.
bool IsMatch(boost::intrusive_ptr< RRArray< char > > &value) const
Compare the group to a value.
std::vector< ServiceSubscriptionFilterAttribute > Attributes
The attributes in the group.
Definition: Subscription.h:270
bool IsMatch(const std::map< std::string, std::string > &values) const
Compare the group to a map of values.
ServiceSubscriptionFilterAttributeGroup(ServiceSubscriptionFilterAttributeGroupOperation operation, std::vector< ServiceSubscriptionFilterAttributeGroup > groups)
Construct a new Service Subscription Filter Attribute Group object.
Subscription filter attribute for use with ServiceSubscriptionFilter.
Definition: Subscription.h:92
bool IsMatch(const std::map< std::string, std::string > &values) const
Compare the attribute to a value map using OR logic.
bool IsMatch(boost::string_ref value) const
Compare the attribute to a value.
bool IsMatch(const boost::intrusive_ptr< RRList< RRValue > > &values) const
Compare the attribute to a value list using OR logic.
bool IsMatch(boost::string_ref name, boost::string_ref value) const
Compare the attribute to a named value.
std::string Name
The attribute name. Empty for no name.
Definition: Subscription.h:95
ServiceSubscriptionFilterAttribute(boost::string_ref value)
Construct a new Service Subscription Filter Attribute object.
bool IsMatch(const std::vector< std::string > &values) const
Compare the attribute to a value list using OR logic.
std::string Value
The string value of the attribute.
Definition: Subscription.h:97
ServiceSubscriptionFilterAttribute(boost::string_ref name, boost::string_ref value)
Construct a new Service Subscription Filter Attribute object.
bool UseRegex
True if ValueRegex is used, otherwise Value is matched.
Definition: Subscription.h:101
ServiceSubscriptionFilterAttribute(boost::string_ref name, const boost::regex &value_regex)
Construct a new Service Subscription Filter Attribute object.
bool IsMatch(const boost::intrusive_ptr< RRMap< std::string, RRValue > > &values) const
Compare the attribute to a value map using OR logic.
ServiceSubscriptionFilterAttribute()
Construct a new Service Subscription Filter Attribute object.
boost::regex ValueRegex
The regex value of the attribute.
Definition: Subscription.h:99
ServiceSubscriptionFilterAttribute(const boost::regex &value_regex)
Construct a new Service Subscription Filter Attribute object.
Subscription filter.
Definition: Subscription.h:373
ServiceSubscriptionFilterAttributeGroupOperation AttributesMatchOperation
Definition: Subscription.h:384
std::map< std::string, ServiceSubscriptionFilterAttributeGroup > Attributes
Definition: Subscription.h:382
boost::function< bool(const ServiceInfo2 &)> Predicate
Definition: Subscription.h:386
std::vector< std::string > ServiceNames
Definition: Subscription.h:378
std::vector< boost::shared_ptr< ServiceSubscriptionFilterNode > > Nodes
Definition: Subscription.h:376
uint32_t MaxConnections
Definition: Subscription.h:388
std::vector< std::string > TransportSchemes
Definition: Subscription.h:380
Subscription filter node information.
Definition: Subscription.h:75
boost::intrusive_ptr< RRMap< std::string, RRValue > > Credentials
Definition: Subscription.h:84
::RobotRaconteur::NodeID NodeID
Definition: Subscription.h:78
std::string Username
Definition: Subscription.h:82
std::string NodeName
Definition: Subscription.h:80
Subscription that automatically connects services and manages lifecycle of connected services.
Definition: Subscription.h:613
boost::shared_ptr< SubObjectSubscription > SubscribeSubObject(boost::string_ref servicepath, boost::string_ref objecttype="")
Creates a sub object subscription.
std::vector< std::string > GetServiceURL()
Get the service connection URL.
bool TryGetDefaultClientWait(boost::shared_ptr< T > &client_out, int32_t timeout=RR_TIMEOUT_INFINITE)
Try getting the "default client" connection, waiting with timeout if not connected.
Definition: Subscription.h:875
void UpdateServiceURL(const std::vector< std::string > &url, boost::string_ref username="", const boost::intrusive_ptr< RRMap< std::string, RRValue > > &credentials=(boost::intrusive_ptr< RRMap< std::string, RRValue > >()), boost::string_ref object_type="", bool close_connected=false)
Update the service connection URL.
boost::shared_ptr< T > GetDefaultClientWait(int32_t timeout=RR_TIMEOUT_INFINITE)
Get the "default client" connection, waiting with timeout if not connected.
Definition: Subscription.h:857
boost::shared_ptr< PipeSubscription< T > > SubscribePipe(boost::string_ref membername, boost::string_ref servicepath="", uint32_t max_recv_packets=std::numeric_limits< uint32_t >::max())
Creates a pipe subscription.
Definition: Subscription.h:783
event_connection AddClientConnectFailedListener(boost::function< void(const boost::shared_ptr< ServiceSubscription > &, const ServiceSubscriptionClientID &, const std::vector< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler)
Add a listener callback that is invoked when a client connection attempt fails.
bool TryGetDefaultClient(boost::shared_ptr< T > &client_out)
Try getting the "default client" connection.
Definition: Subscription.h:825
void UpdateServiceByType(const std::vector< std::string > &service_types, const boost::shared_ptr< ServiceSubscriptionFilter > &filter=boost::shared_ptr< ServiceSubscriptionFilter >())
Update the service type and filter for subscription.
event_connection AddClientConnectListener(boost::function< void(const boost::shared_ptr< ServiceSubscription > &, const ServiceSubscriptionClientID &, const boost::shared_ptr< RRObject > &)> handler)
Add a listener callback that is invoked when a client is connected.
event_connection AddClientDisconnectListener(boost::function< void(const boost::shared_ptr< ServiceSubscription > &, const ServiceSubscriptionClientID &, const boost::shared_ptr< RRObject > &)> handler)
Add a listener callback that is invoked when a client is disconnected.
void UpdateServiceURL(boost::string_ref url, boost::string_ref username="", const boost::intrusive_ptr< RRMap< std::string, RRValue > > &credentials=(boost::intrusive_ptr< RRMap< std::string, RRValue > >()), boost::string_ref object_type="", bool close_connected=false)
Update the service connection URL.
void AsyncGetDefaultClient(boost::function< void(const boost::shared_ptr< T > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
Asynchronously get the default client, with optional timeout.
Definition: Subscription.h:900
boost::shared_ptr< T > GetDefaultClient()
Get the "default client" connection.
Definition: Subscription.h:808
std::map< ServiceSubscriptionClientID, boost::shared_ptr< RRObject > > GetConnectedClients()
Returns a map of connected clients.
Class to manage multiple subscriptions to services.
Definition: Subscription.h:1813
std::vector< std::string > GetSubscriptionNames()
Get the names of all subscriptions.
bool IsEnabled(const boost::string_ref &name)
Get if a subscription is enabled.
void EnableSubscription(const boost::string_ref &name)
Enable a subscription.
ServiceSubscriptionManager(const boost::shared_ptr< RobotRaconteurNode > &node=RobotRaconteurNode::sp())
Construct a new ServiceSubscriptionManager object.
void DisableSubscription(const boost::string_ref &name, bool close=true)
Disable a subscription.
void RemoveSubscription(const boost::string_ref &name, bool close=true)
Remove a subscription from the manager.
std::vector< ServiceSubscriptionManagerDetails > GetSubscriptionDetails()
Get the details of all subscriptions.
void AddSubscription(const ServiceSubscriptionManagerDetails &details)
Add a subscription to the manager.
void Close(bool close_subscriptions=true)
Close the subscription manager.
bool IsConnected(const boost::string_ref &name)
Get if a subscription is connected.
void Init(const std::vector< ServiceSubscriptionManagerDetails > &details)
Initialize the subscription manager with a list of subscriptions.
boost::shared_ptr< RobotRaconteurNode > GetNode()
Get the node used by the subscription manager.
boost::shared_ptr< ServiceSubscription > GetSubscription(const boost::string_ref &name, bool force_create=true)
Get a subscription by name.
Subscription for sub objects of the default client.
Definition: Subscription.h:1580
boost::shared_ptr< T > GetDefaultClientWait(int32_t timeout=RR_TIMEOUT_INFINITE)
Get the "default client" sub object, waiting for a specified timeout.
Definition: Subscription.h:1648
bool TryGetDefaultClientWait(boost::shared_ptr< T > &client_out, int32_t timeout=RR_TIMEOUT_INFINITE)
Try getting the "default client" sub object, waiting for a specified timeout.
Definition: Subscription.h:1666
boost::shared_ptr< T > GetDefaultClient()
Get the "default client" sub object.
Definition: Subscription.h:1600
void AsyncGetDefaultClient(boost::function< void(const boost::shared_ptr< T > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
Asynchronously get the "default client" sub object.
Definition: Subscription.h:1693
bool TryGetDefaultClient(boost::shared_ptr< T > &client_out)
Try getting the "default client" sub object.
Definition: Subscription.h:1617
void Close()
Closes the sub object subscription.
Represents. a point in time. Used by wire members to timestamp packets.
Definition: DataTypes.h:2666
Base class for WireConnection.
Definition: WireMember.h:58
Wire connection used to transmit "most recent" values.
Definition: WireMember.h:350
Base class for WireSubscription.
Definition: Subscription.h:1083
size_t GetActiveWireConnectionCount()
Get the number of wire connections currently connected.
bool WaitInValueValid(int32_t timeout=RR_TIMEOUT_INFINITE)
Wait for a valid InValue to be received from a client.
void SetIgnoreInValue(bool ignore)
Set if InValue should be ignored.
void Close()
Closes the wire subscription.
void SetInValueLifespan(int32_t millis)
Set the InValue lifespan in milliseconds.
int32_t GetInValueLifespan()
Get the InValue lifespan in milliseconds.
bool GetIgnoreInValue()
Get if InValue is currently being ignored.
Subscription for wire members that aggregates the values from client wire connections.
Definition: Subscription.h:1233
bool TryGetInValue(T &val, TimeSpec *time=NULL, typename boost::shared_ptr< WireConnection< T > > *connection=NULL)
Try getting the current InValue and metadata.
Definition: Subscription.h:1272
T GetInValue(TimeSpec *time=NULL, typename boost::shared_ptr< WireConnection< T > > *connection=NULL)
Get the current InValue and metadata.
Definition: Subscription.h:1249
void SetOutValueAll(const T &val)
Set the OutValue for all active wire connections.
Definition: Subscription.h:1295
event_connection AddWireValueChangedListener(boost::function< void(const boost::shared_ptr< WireSubscription< T > > &, const T &, const TimeSpec &)> f)
Adds a wire value changed event listener function.
Definition: Subscription.h:1308
ServiceSubscriptionManager subscription connection information.
Definition: Subscription.h:1758
bool Enabled
If the subscription is enabled.
Definition: Subscription.h:1774
boost::shared_ptr< ServiceSubscriptionFilter > Filter
The filter to use for subscription when service type is used (optional)
Definition: Subscription.h:1772
ServiceSubscriptionManager_CONNECTION_METHOD ConnectionMethod
The connection method to use, URL or service type.
Definition: Subscription.h:1762
std::vector< std::string > Urls
The URLs to use for subscription.
Definition: Subscription.h:1764
ServiceSubscriptionManagerDetails(const boost::string_ref &Name, ServiceSubscriptionManager_CONNECTION_METHOD ConnectionMethod=ServiceSubscriptionManager_CONNECTION_METHOD_DEFAULT, const std::vector< std::string > &Urls=std::vector< std::string >(), const boost::string_ref &UrlUsername="", const boost::intrusive_ptr< RRMap< std::string, RRValue > > &UrlCredentials=boost::intrusive_ptr< RRMap< std::string, RRValue > >(), const std::vector< std::string > &ServiceTypes=std::vector< std::string >(), const boost::shared_ptr< ServiceSubscriptionFilter > &Filter=boost::shared_ptr< ServiceSubscriptionFilter >(), bool Enabled=true)
Construct a new ServiceSubscriptionManagerDetails object with parameters.
std::string UrlUsername
The username to use for URLs (optional)
Definition: Subscription.h:1766
std::string Name
The local name of the subscription.
Definition: Subscription.h:1760
std::vector< std::string > ServiceTypes
The service types to use for subscription.
Definition: Subscription.h:1770
boost::intrusive_ptr< RRMap< std::string, RRValue > > UrlCredentials
The credentials to use for URLs (optional)
Definition: Subscription.h:1768
ServiceSubscriptionManagerDetails()
Construct a new ServiceSubscriptionManagerDetails object.