MIRA
Authority.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_AUTHORITY_H_
48 #define _MIRA_AUTHORITY_H_
49 
50 #ifndef _MIRA_FRAMEWORK_H_
51 # error "Authority.h must be included via the Framework.h. You must not include it directly. Use #include <fw/Framework.h> instead"
52 #endif
53 
54 #include <utils/EnumToFlags.h>
55 #include <rpc/RPCFuture.h>
56 
58 
59 #include <serialization/adapters/std/set>
61 
62 #include <fw/AbstractAuthority.h>
63 #include <fw/AuthorityRuntime.h>
64 #include <fw/Channel.h>
66 #include <fw/RPCHandler.h>
68 
69 namespace mira {
70 
72 
73 // forward declarations
74 struct TransformDesc;
75 class AuthorityManager;
76 class FrameworkTransformerNode;
77 template<typename>
79 
81 
83 #define MIRA_HIDDEN_AUTHORITY_PREFIX "#"
84 
95 {
96 public:
97 
101  enum Flags
102  {
104  NORMAL = 0x0000,
105 
111  ANONYMOUS = 0x0001,
112 
117  HIDDEN = 0x0002,
118 
126  INVISIBLE_PUBLISHER_SUBSCRIBER = 0x0004,
127 
132  INTERNAL = 0x000A,
133 
147  INDEPENDENT_SUBSCRIBER_THREAD = 0x0010,
148 
161  INDEPENDENT_RPC_THREAD = 0x0020,
162 
167  NO_MAIN_THREAD = 0x0040
168 
169  };
171 
172 public:
173 
179  Authority(Flags flags = NORMAL);
180 
196  Authority(const ResourceName& fullname, Flags flags = NORMAL);
197 
215  Authority(const ResourceName& ns, const std::string& name, Flags flags = NORMAL);
216 
232  Authority(Authority& iParent, const std::string& name, Flags flags = ANONYMOUS);
233 
241  virtual ~Authority();
242 
244  template<typename Reflector>
245  void reflect(Reflector& r)
246  {
247  r.roproperty("Status", &getStatusManager(), "The status of this authority");
248  r.property("HeartbeatInterval",
249  getter<Duration>(&DiagnosticsModule::getHeartbeatInterval,
250  (DiagnosticsModule*)this),
251  setter<Duration>(&DiagnosticsModule::setHeartbeatInterval,
252  (DiagnosticsModule*)this),
253  "The interval of the watchdog",
255  }
256 
257 public:
265 
279  void checkin(const ResourceName& fullname,
281 
296  void checkin(const ResourceName& ns, const std::string& name,
298 
311  void checkin(Authority& iParent, const ResourceName& ns,
312  const std::string& name);
313 
326  void checkin(Authority& iParent, const std::string& name);
327 
337  void checkout();
338 
343  bool isValid() const {
344  return mValid;
345  }
346 
351  void validate() const {
352  if ( !isValid() )
353  MIRA_THROW(XInvalidConfig, "Authority is not registered.");
354  }
355 
365  void startWithParent(bool start) {
366  mStartWithParent = start;
367  }
368 
376  return mRuntime;
377  }
378 
382  std::set<Authority*> getChildren() {
383  return mChildren;
384  }
385 
391  void addImmediateHandler(DiagnosticRunnablePtr runnable);
392 
399  template <typename F>
400  void addImmediateHandlerFunction(F&& fn);
401 
408  void addFinalizeHandler(DiagnosticRunnablePtr runnable);
409 
416  template <typename F>
417  void addFinalizeHandlerFunction(F&& fn);
418 
428  TimerPtr createTimer(Duration period, TimerCallback callback,
429  bool oneshot=false);
430 
443  TimerPtr createTimer(Duration period, Duration tolerance,
444  TimerCallback callback, bool oneshot=false);
445 
447  template<typename Class>
448  TimerPtr createTimer(Duration period,
449  void (Class::*f)(const Timer&), Class* obj,
450  bool oneshot=false);
451 
453  template<typename Class>
454  TimerPtr createTimer(Duration period, void (Class::*f)(const Timer&),
455  bool oneshot=false);
456 
458  template<typename Class>
459  TimerPtr createTimer(Duration period, Duration tolerance,
460  void (Class::*f)(const Timer&), Class* obj,
461  bool oneshot=false);
462 
464  template<typename Class>
465  TimerPtr createTimer(Duration period, Duration tolerance,
466  void (Class::*f)(const Timer&), bool oneshot=false);
467 
475  TimerPtr createTimer(Time time, TimerCallback callback);
476 
478  template<typename Class>
479  TimerPtr createTimer(Time time, void (Class::*f)(const Timer&), Class* obj);
480 
482  template<typename Class>
483  TimerPtr createTimer(Time time, void (Class::*f)(const Timer&));
484 
490  void removeTimer(TimerPtr timer);
491 
503  virtual void start();
504 
514  virtual void stop();
515 
530  bool spin(const Duration& maxWait = Duration::infinity());
531 
539  virtual bool hasUnrecoverableFailure() const;
540 
545  virtual bool isStarted() const;
546 
551  virtual bool isRunning() const;
552 
554 
555 public:
556 
562  void enableSubscriberCallbacks(bool enable);
563 
564 public:
565 
567  // Channel framework
574 
581  std::string resolveName(const std::string& name) const;
582 
591  std::string resolveServiceName(const std::string& name) const;
592 
611  template<typename T>
612  Channel<T> publish(const std::string& channelID)
613  {
614  static_assert(std::is_void<T>::value!=true,
615  "You must specify a typename for untyped channels");
616  return publish<T>(channelID, typeName<T>());
617  }
618 
623  template<typename T>
624  Channel<T> publish(const std::string& channelID, const Typename& type);
625 
632  void unpublish(const std::string& channelID);
633 
659  template<typename T>
660  Channel<T> subscribe(const std::string& channelID,
661  const Duration& storageDuration = Duration::seconds(0));
662 
695  template<typename T>
696  Channel<T> subscribe(const std::string& channelID,
697  boost::function<void (ChannelRead<T>)> fn,
698  const Duration& storageDuration = Duration::seconds(0),
699  bool independentThread = false);
700 
702  template<typename T>
703  Channel<T> subscribe(const std::string& channelID,
704  boost::function<void (ChannelRead<T>)> fn,
705  bool independentThread);
706 
712  template<typename T, typename Class>
713  Channel<T> subscribe(const std::string& channelID,
714  void (Class::*f)(ChannelRead<T>),
715  Class* obj,
716  const Duration& storageDuration = Duration::seconds(0),
717  bool independentThread = false);
718 
724  template<typename T, typename Class>
725  Channel<T> subscribe(const std::string& channelID,
726  void (Class::*f)(ChannelRead<T>),
727  Class* obj, bool independentThread);
728 
750  template<typename T, typename Class>
751  Channel<T> subscribe(const std::string& channelID,
752  void (Class::*f)(ChannelRead<T>),
753  const Duration& storageDuration = Duration::seconds(0),
754  bool independentThread = false)
755  {
756  Class* obj = dynamic_cast<Class*>(this);
757  assert(obj!=NULL &&
758  "Called 'Authority::subscribe(..., Class::member, ...)' on an object that is not "
759  "of type Class (you may need to provide a pointer to the correct object)!");
760  return subscribe<T>(channelID, f, obj, storageDuration, independentThread);
761  }
762 
767  template<typename T, typename Class>
768  Channel<T> subscribe(const std::string& channelID,
769  void (Class::*f)(ChannelRead<T>), bool independentThread)
770  {
771  Class* obj = dynamic_cast<Class*>(this);
772  assert(obj!=NULL &&
773  "Called 'Authority::subscribe(..., Class::member, ...)' on an object that is not "
774  "of type Class (you may need to provide a pointer to the correct object)!");
775  return subscribe<T>(channelID, f, obj, independentThread);
776  }
777 
799  template<typename T>
800  Channel<T> publishAndSubscribe(const std::string& channelID,
801  const Duration& storageDuration = Duration::seconds(0));
802 
831  template<typename T>
832  Channel<T> publishAndSubscribe(const std::string& channelID,
833  boost::function<void (ChannelRead<T>)> fn,
834  const Duration& storageDuration = Duration::seconds(0),
835  bool independentThread = false);
836 
838  template<typename T>
839  Channel<T> publishAndSubscribe(const std::string& channelID,
840  boost::function<void (ChannelRead<T>)> fn,
841  bool independentThread);
842 
848  template<typename T, typename Class>
849  Channel<T> publishAndSubscribe(const std::string& channelID,
850  void (Class::*f)(ChannelRead<T>),
851  Class* obj,
852  const Duration& storageDuration = Duration::seconds(0),
853  bool independentThread = false);
854 
860  template<typename T, typename Class>
861  Channel<T> publishAndSubscribe(const std::string& channelID,
862  void (Class::*f)(ChannelRead<T>),
863  Class* obj, bool independentThread);
864 
886  template<typename T, typename Class>
887  Channel<T> publishAndSubscribe(const std::string& channelID,
888  void (Class::*f)(ChannelRead<T>),
889  const Duration& storageDuration = Duration::seconds(0),
890  bool independentThread = false)
891  {
892  Class* obj = dynamic_cast<Class*>(this);
893  assert(obj!=NULL);
894  return publishAndSubscribe<T>(channelID, f, obj, storageDuration, independentThread);
895  }
896 
901  template<typename T, typename Class>
902  Channel<T> publishAndSubscribe(const std::string& channelID,
903  void (Class::*f)(ChannelRead<T>),
904  bool independentThread)
905  {
906  Class* obj = dynamic_cast<Class*>(this);
907  assert(obj!=NULL);
908  return publishAndSubscribe<T>(channelID, f, obj, independentThread);
909  }
910 
953  template<typename T>
954  Channel<T> subscribeInterval(const std::string& channelID,
955  boost::function<void (ChannelReadInterval<T>)> fn,
956  const Duration& storageDuration,
957  bool independentThread = false,
958  const Time& startAfter = Time::unixEpoch());
959 
960  /*
961  * Provided for simplified registration of a member function as callback
962  * function. See the above subscribe methods for more details.
963  */
964  template<typename T, typename Class>
965  Channel<T> subscribeInterval(const std::string& channelID,
966  void (Class::*f)(ChannelReadInterval<T>),
967  Class* obj,
968  const Duration& storageDuration,
969  bool independentThread = false,
970  const Time& startAfter = Time::unixEpoch());
971 
976  template<typename T, typename Class>
977  Channel<T> subscribeInterval(const std::string& channelID,
978  void (Class::*f)(ChannelReadInterval<T>),
979  const Duration& storageDuration,
980  bool independentThread = false,
981  const Time& startAfter = Time::unixEpoch());
982 
989  template<typename T, typename Class>
990  Channel<T> subscribeIntervalByElements(const std::string& channelID,
991  void (Class::*f)(ChannelRead<T>),
992  Class* obj,
993  const Duration& storageDuration = Duration::seconds(0),
994  bool independentThread = false,
995  const Time& startAfter = Time::unixEpoch());
996 
1001  template <typename T>
1002  Channel<T> subscribeIntervalByElements(const std::string& channelID,
1003  boost::function<void(ChannelRead<T>)>,
1004  const Duration& storageDuration = Duration::seconds(0),
1005  bool independentThread = false,
1006  const Time& startAfter = Time::unixEpoch());
1007 
1013  template<typename T, typename Class>
1014  Channel<T> subscribeIntervalByElements(const std::string& channelID,
1015  void (Class::*f)(ChannelRead<T>),
1016  const Duration& storageDuration = Duration::seconds(0),
1017  bool independentThread = false,
1018  const Time& startAfter = Time::unixEpoch());
1019 
1031  template <typename T>
1032  ChannelRead<T> waitForData(Channel<T> channel,
1033  Duration timeout = Duration::infinity()) const;
1034 
1047  void unsubscribe(const std::string& channelID);
1048 
1054  template <typename T>
1055  void unsubscribe(const std::string& channelID);
1056 
1074  template <typename T>
1075  Channel<T> getChannel(const std::string& channelID);
1076 
1080  bool isSubscribedOn(const std::string& channelID) const;
1081 
1082  MIRA_DEPRECATED("Please use isSubscribedOn() instead",
1084  bool hasSubscribedOn(const std::string& channelID) const) {
1085  return isSubscribedOn(channelID);
1086  }
1087 
1091  bool hasPublished(const std::string& channelID) const;
1092 
1096  bool doesChannelExist(const std::string& channelID) const;
1097 
1101  bool waitForChannel(const std::string& channelID,
1102  const Duration& timeout = Duration::infinity()) const;
1103 
1105 
1106 public:
1107 
1109  // Transform framework
1110 
1116 
1127  bool isTransformAvailable(const std::string& targetID, const std::string& sourceID) const;
1128 
1140  bool isTransformAvailable(const std::string& targetID, const std::string& sourceID,
1141  const std::string& fixedID) const;
1142 
1154  bool waitForTransform(const std::string& targetID, const std::string& sourceID,
1155  Duration timeout = Duration::invalid()) const;
1156 
1169  bool waitForTransform(const std::string& targetID, const std::string& sourceID,
1170  const std::string& fixedID, Duration timeout = Duration::invalid()) const;
1171 
1172 
1196  template<typename Transform, typename Filter>
1197  void subscribeTransform(const std::string& targetID,
1198  const std::string& sourceID,
1199  boost::function<void (Transform, Time)> fn,
1200  Filter&& filter);
1201 
1207  template<typename Transform, typename Filter, typename Class>
1208  void subscribeTransform(const std::string& targetID,
1209  const std::string& sourceID,
1210  void (Class::*f)(Transform, Time), Class* obj,
1211  Filter&& filter);
1212 
1218  template<typename Transform, typename Filter, typename Class>
1219  void subscribeTransform(const std::string& targetID,
1220  const std::string& sourceID,
1221  void (Class::*f)(Transform, Time),
1222  Filter&& filter);
1223 
1246  template<typename Transform>
1247  void subscribeTransform(const std::string& targetID,
1248  const std::string& sourceID,
1249  boost::function<void (Transform, Time)> fn);
1250 
1256  template<typename Transform, typename Class>
1257  void subscribeTransform(const std::string& targetID,
1258  const std::string& sourceID,
1259  void (Class::*f)(Transform, Time), Class* obj);
1260 
1266  template<typename Transform, typename Class>
1267  void subscribeTransform(const std::string& targetID,
1268  const std::string& sourceID,
1269  void (Class::*f)(Transform, Time));
1270 
1271 
1272 
1285  template<typename Transform, typename Filter>
1286  Transform getTransform(const std::string& targetID,
1287  const std::string& sourceID,
1288  const Time& time, Filter&& filter) const;
1289 
1298  template<typename Transform>
1299  Transform getTransform(const std::string& targetID,
1300  const std::string& sourceID,
1301  const Time& time = Time()) const
1302  {
1303  return getTransform<Transform>(targetID, sourceID, time,
1305  }
1306 
1336  template<typename Transform, typename Filter>
1337  Transform getTransform(const std::string& targetID, const Time& targetTime,
1338  const std::string& sourceID, const Time& sourceTime,
1339  const std::string& fixedID,
1340  Filter&& filter) const;
1341 
1350  template<typename Transform>
1351  Transform getTransform(const std::string& targetID, const Time& targetTime,
1352  const std::string& sourceID, const Time& sourceTime,
1353  const std::string& fixedID) const
1354  {
1355  return getTransform<Transform>(targetID, targetTime, sourceID,
1356  sourceTime, fixedID,
1358  }
1359 
1360 
1361 
1362 
1370  FrameworkTransformerNode* getTransformNode(const std::string& frameID) const;
1371 
1386  TransformDesc prepareTransform(const std::string& targetID,
1387  const std::string& sourceID) const;
1388 
1407  TransformDesc prepareTransform(const std::string& targetID,
1408  const std::string& sourceID,
1409  const std::string& fixedID) const;
1410 
1421  template<typename Transform, typename Filter>
1422  Transform getTransform(const TransformDesc& desc, const Time& time,
1423  Filter&& filter) const;
1424 
1432  template<typename Transform>
1433  Transform getTransform(const TransformDesc& desc, const Time& time = Time()) const
1434  {
1435  return getTransform<Transform>(desc, time, NearestNeighborInterpolator());
1436  }
1437 
1452  template<typename Transform, typename Filter>
1453  Transform getTransform(const TransformDesc& desc, const Time& targetTime,
1454  const Time& sourceTime, Filter&& filter) const;
1455 
1462  template<typename Transform>
1463  Transform getTransform(const TransformDesc& desc, const Time& targetTime,
1464  const Time& sourceTime) const
1465  {
1466  return getTransform<Transform>(desc, targetTime, sourceTime,
1468  }
1469 
1477  template<typename Transform>
1478  void publishTransform(const std::string& frameID, const Transform& transform,
1479  const Time& time) const;
1480 
1510  template<typename Transform, typename Filter>
1511  void publishTransformIndirect(const std::string& frameID,
1512  const std::string& targetID,
1513  const std::string& sourceID,
1514  const Transform& transform, const Time& time,
1515  Filter&& filter) const;
1516 
1526  template<typename Transform>
1527  void publishTransformIndirect(const std::string& frameID,
1528  const std::string& targetID,
1529  const std::string& sourceID,
1530  const Transform& transform, const Time& time)
1531  {
1532  publishTransformIndirect(frameID, targetID, sourceID,
1533  transform, time, NearestNeighborInterpolator());
1534  }
1535 
1543  void addTransformLink(const std::string& childID, const std::string& parentID) const;
1544 
1554  void addTransformLink(const std::string& childID,
1555  const std::string& parentID,
1557 
1559 
1560 public:
1561 
1563  // RPC Framework
1564 
1570 
1581  template<typename Service>
1582  void publishService(const std::string& name, Service& iService,
1583  RPCHandlerPtr handler = RPCHandlerPtr());
1584 
1592  template<typename Service>
1593  void publishService(Service& iService,
1594  RPCHandlerPtr handler = RPCHandlerPtr());
1595 
1600  void unpublishService();
1601 
1606  void unpublishService(const std::string& name);
1607 
1643  template<typename R, typename... ARGS>
1644  inline RPCFuture<R> callService(const std::string& iService, const std::string& method,
1645  ARGS&&... args) const;
1646 
1670  RPCFuture<JSONRPCResponse> callServiceJSON(const json::Value& jsonRequest) const;
1671 
1678  RPCFuture<JSONRPCResponse> callServiceJSON(const std::string& jsonString) const;
1679 
1693  RPCFuture<JSONRPCResponse> callServiceJSON(const std::string& service,
1694  const std::string& method,
1695  const json::Value& params = json::Value()) const;
1696 
1708  RPCFuture<JSONRPCResponse> callServiceJSON(const std::string& service,
1709  const std::string& method,
1710  const std::string& params) const;
1711 
1719  RPCFuture<JSONRPCResponse> callServiceJSON(const RPCCallDefinition& rpc) const;
1720 
1732  template<class F>
1733  [[nodiscard]] ServiceCall<F> createServiceCall(const std::string& service, std::string method,
1734  bool waitTillExists = true, bool showBootupMsg = true);
1735 
1739  bool existsService(const std::string& name) const;
1740 
1745  bool implementsInterface(const std::string& name,
1746  const std::string& interface) const;
1747 
1755  bool waitForService(const std::string& name,
1756  Duration timeout = Duration::invalid()) const;
1757 
1766  std::string waitForServiceInterface(const std::string& interface,
1767  Duration timeout = Duration::invalid()) const;
1768 
1773  std::list<std::string> queryServicesForInterface(const std::string& interface) const;
1774 
1784  void registerCallbackForInterface(const std::string& interface,
1786 
1791  template<typename Class>
1792  void registerCallbackForInterface(const std::string& interface,
1793  void (Class::*f)(const std::string&,
1794  const std::string&),
1795  Class* obj);
1796 
1798 
1799 public:
1800 
1801  StatusManager& getStatusManager();
1802 
1806  //{@
1807 
1808  virtual StatusManager::StatusMap getStatusMap();
1809 
1810  virtual boost::shared_ptr<PropertyNode> getProperties();
1811 
1812  virtual std::set<std::string> getPublishedChannels();
1813 
1814  virtual std::set<std::string> getSubscribedChannels();
1815 
1816  virtual std::set<std::string> getServiceInterfaces();
1817 
1818  virtual ChannelNameMapping getPublishedChannelNames();
1819 
1820  virtual ChannelNameMapping getSubscribedChannelNames();
1821 
1822  virtual ChannelStatusMap getSubscribedChannelStatus();
1823 
1825 
1826 protected:
1827 
1828  template<typename T>
1829  Channel<T> toProxy(ConcreteChannel<T>* channel);
1830 
1831  void setChannelReadAccess(const std::string& channelID);
1832  void setChannelWriteAccess(const std::string& channelID);
1833  void removeChannelReadAccess(const std::string& channelID);
1834  void removeChannelWriteAccess(const std::string& channelID);
1835  void insertChannelNameMapping(AbstractAuthority::ChannelNameMapping& map,
1836  const std::string& local,
1837  const std::string& global);
1838  void eraseChannelNameMapping(AbstractAuthority::ChannelNameMapping& map,
1839  const std::string& local,
1840  const std::string& global);
1841 
1842  void remotePublishService(const std::string& service) const;
1843 
1844  friend struct AuthorityService;
1845  friend class AuthorityManager;
1846 
1847  PropertyTree getPropertiesRPC();
1848 
1849  void setProperty(const std::string& property, const std::string& value);
1850  std::string getProperty(const std::string& property) const;
1851  void setPropertyJSON(const std::string& property, const json::Value& value);
1852  json::Value getPropertyJSON(const std::string& property) const;
1853 
1854 protected:
1855 
1857  struct RWAccessFlags {
1860  };
1861 
1862  typedef std::map<std::string, RWAccessFlags> RWAccessMap;
1863  typedef std::list<AbstractChannelSubscriberPtr> SubscribePtrList;
1864 
1865 private:
1866 
1867  void init();
1868 
1869 private:
1870 
1872  AuthorityRuntimePtr mRuntime;
1874  bool mOwnsRuntime;
1876  bool mValid;
1878  bool mStarted;
1880  bool mIsInternal;
1882  bool mIsInvisiblePublisherSubscriber;
1883 
1884  Flags mFlags;
1886  RWAccessMap mAccessMap;
1888  Authority* mParent;
1890  bool mStartWithParent;
1892  std::set<Authority*> mChildren;
1893 
1895  bool mSubscriberEnabled;
1896 
1897  typedef boost::shared_ptr<DispatcherThread> DispatcherThreadPtr;
1898 
1904  typedef std::list<DispatcherThreadPtr> IndependentSubscribers;
1905 
1907  IndependentSubscribers mIndependentSubscriberDispatchers;
1908 
1910  DispatcherThreadPtr mSubscriberDispatcher;
1912  DispatcherThreadPtr mRPCDispatcher;
1913 
1915  RPCHandlerPtr mRPCHandler;
1917  ServiceInterfaceHandlerPtr mServiceInterfaceHandler;
1919  SubscribePtrList mSubscriberList;
1921  std::set<std::string> mPublishedServices;
1923  boost::mutex mNameMutex;
1925  ChannelNameMapping mPublishedChannelNames;
1927  ChannelNameMapping mSubscribedChannelNames;
1929  StatusManager mStatusManager;
1930 };
1931 
1933 typedef boost::shared_ptr<Authority> AuthorityPtr;
1934 
1936 
1937 } // namespace
1938 
1939 #endif
Definition: FrameworkTransformer.h:75
boost::shared_ptr< RPCHandler > RPCHandlerPtr
Definition: RPCHandler.h:102
RWAccessFlags()
Definition: Authority.h:1858
An object that allows read access to a whole interval of channel data.
Definition: ChannelReadInterval.h:72
Manages the status of one or multiple modules inheriting from DiagnosticsModule.
Definition: Status.h:291
static Duration invalid()
Returns an invalid duration.
Definition: Time.h:252
Channel access flags.
Definition: Authority.h:1857
bool isValid() const
Returns true, if this Authority was initialized and is checked in, otherwise false.
Definition: Authority.h:343
PropertyHint spin(const T &min, const T &max, const T &s)
Sets the attribute "type" to the value "spinbox" and sets the "minimum", "maximum" and "step" attribu...
Definition: PropertyHint.h:328
DispatcherThread::TimerPtr TimerPtr
Definition: DispatcherThread.h:513
An exception that occurs whenever a channel has no data.
Definition: Channel.h:88
boost::function< void(const std::string &, const std::string &)> Callback
Definition: ServiceInterfaceHandler.h:73
Transform getTransform(const std::string &targetID, const Time &targetTime, const std::string &sourceID, const Time &sourceTime, const std::string &fixedID) const
Definition: Authority.h:1351
AuthorityRuntimePtr getRuntime()
Returns a shared_ptr to the runtime that this authority uses.
Definition: Authority.h:375
boost::shared_ptr< Authority > AuthorityPtr
Typedef for Authority pointers.
Definition: Authority.h:1933
Class representing timers and tasks that can be registered and executed by the dispatcher thread...
Definition: DispatcherThread.h:147
void setHeartbeatInterval(const Duration &interval)
Set the watchdog interval.
Definition: Status.h:153
Macros for generating logical operators for using enum values as flags.
Transform getTransform(const TransformDesc &desc, const Time &targetTime, const Time &sourceTime) const
Definition: Authority.h:1463
1D nearest neighbor interpolator.
Definition: NearestNeighborInterpolator.h:68
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
std::string Typename
Definition: Typename.h:60
Channel< T > subscribe(const std::string &channelID, void(Class::*f)(ChannelRead< T >), const Duration &storageDuration=Duration::seconds(0), bool independentThread=false)
Provided for simplified registration of a member function of a class as callback. ...
Definition: Authority.h:751
MIRA_DEPRECATED("Please use isSubscribedOn() instead", bool hasSubscribedOn(const std::string &channelID) const)
Definition: Authority.h:1082
Class object which supports some kind of class reflection.
Definition: Class.h:97
std::list< AbstractChannelSubscriberPtr > SubscribePtrList
Definition: Authority.h:1863
constexpr std::enable_if<!FunctionTraits< F >::isFunction, bool >::type isValid()
Definition: RPCPatternCheck.h:193
std::multimap< std::string, Status > StatusMap
Definition: Status.h:295
Implementation of RPCFuture.
Transform getTransform(const std::string &targetID, const std::string &sourceID, const Time &time=Time()) const
Definition: Authority.h:1299
static Time unixEpoch()
Returns the unix epoch 1.1.1970 0:0:0.000.
Definition: Time.h:514
Definition: ChannelReadWrite.h:65
Abstract base class of authorities.
An RPCFuture is a proxy for the result of an asynchronous RPC call.
Definition: RPCFuture.h:173
An object that allows read access to data of a channel.
Definition: ChannelReadWrite.h:440
Flags
Flags for creating an authority.
Definition: Authority.h:101
#define MIRA_ENUM_TO_FLAGS_INCLASS(EnumType)
Macro that can be used with enums that contain flags.
Definition: EnumToFlags.h:143
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:81
Channel< T > publish(const std::string &channelID)
Publishes a channel with the given id and marks the authority as a publisher of this channel...
Definition: Authority.h:612
Duration getHeartbeatInterval() const
Return the watchdog interval.
Definition: Status.h:166
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:421
class MIRA_FRAMEWORK_EXPORT Authority
forward declaration
Definition: RemoteConnection.h:74
Transformer manages and provides access to the transformation tree of the framework.
Marker for indicating parameters that should be ignored if they are missing in the config file...
Definition: IgnoreMissing.h:73
Helper class for representing the tree structure of properties.
void publishTransformIndirect(const std::string &frameID, const std::string &targetID, const std::string &sourceID, const Transform &transform, const Time &time)
Definition: Authority.h:1527
Filter that returns the nearest neighbor.
DispatcherThread::TimerCallback TimerCallback
Definition: DispatcherThread.h:514
Channel< T > subscribe(const std::string &channelID, void(Class::*f)(ChannelRead< T >), bool independentThread)
Provided for simplified registration of a member function as callback.
Definition: Authority.h:768
Class for storing/combining/managing resource names consisting of namespaces and names separated by &#39;...
Definition: ResourceName.h:68
#define MIRA_FRAMEWORK_EXPORT
Definition: FrameworkExports.h:61
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
This is a specialization for JSON RPC calls.
Definition: RPCFuture.h:315
sec_type seconds() const
Returns normalized number of seconds (0..59)
Definition: Time.h:283
Use this class to represent time durations.
Definition: Time.h:104
boost::shared_ptr< AuthorityRuntime > AuthorityRuntimePtr
Pointer of AuthorityRuntime.
Definition: AuthorityRuntime.h:98
Authorities act as a facade to the framework.
Definition: Authority.h:94
boost::shared_ptr< ServiceInterfaceHandler > ServiceInterfaceHandlerPtr
Definition: ServiceInterfaceHandler.h:95
boost::shared_ptr< DiagnosticRunnable > DiagnosticRunnablePtr
Definition: Runnable.h:107
Describes a path of transformations through the transformation tree.
Definition: Transformer.h:229
std::set< Authority * > getChildren()
Returns a set with all children / sub-authorities.
Definition: Authority.h:382
Type
Definition: FrameworkTransformer.h:80
Framework channel classes.
Signal handler class for signaling when service interfaces get available.
Channel< T > publishAndSubscribe(const std::string &channelID, void(Class::*f)(ChannelRead< T >), const Duration &storageDuration=Duration::seconds(0), bool independentThread=false)
Provided for simplified registration of a member function of a class as callback. ...
Definition: Authority.h:887
static Duration infinity()
Returns a special duration time representing positive infinity.
Definition: Time.h:245
json_spirit::mValue Value
A value is an abstract description of data in JSON (underlying data can either be one of the JSON bas...
Definition: JSON.h:176
Central instance that stores all created Authorities.
Definition: AuthorityManager.h:130
Signal handler class for RPC calls.
No access at all (Authority is not a publisher nor a subscriber)
Definition: Channel.h:332
void validate() const
Check if authority is checked in and therefore valid.
Definition: Authority.h:351
void startWithParent(bool start)
Select whether the authority should be started when its parent authority starts (only meaningful if i...
Definition: Authority.h:365
void reflect(Reflector &r)
reflect method
Definition: Authority.h:245
This is the abstract base class of local and remote authority classes.
Definition: AbstractAuthority.h:76
std::map< std::string, RWAccessFlags > RWAccessMap
Definition: Authority.h:1862
Stores info required to call an RPC method - service name, method name, arguments.
Definition: RPCCallDefinition.h:62
Transform getTransform(const TransformDesc &desc, const Time &time=Time()) const
Definition: Authority.h:1433
Definition: Authority.h:78
std::multimap< std::string, std::string > ChannelNameMapping
Definition: AbstractAuthority.h:139
ChannelAccessFlags flags
Definition: Authority.h:1859
Runtime class containing the threading related parts of authorities.
Base class for modules that want to use diagnostics and set the current status.
Definition: Status.h:138
Helper class that is able to hold a complete property tree structure.
Definition: PropertyTree.h:86
Channel< T > publishAndSubscribe(const std::string &channelID, void(Class::*f)(ChannelRead< T >), bool independentThread)
Provided for simplified registration of a member function as callback.
Definition: Authority.h:902
ChannelAccessFlags
Flags specifying the access rights of an authority to a channel Can be combined.
Definition: Channel.h:331