Class NetworkPublisher<T>

  • Type Parameters:
    T - The type of value to be published
    All Implemented Interfaces:
    java.lang.AutoCloseable
    Direct Known Subclasses:
    MapNetworkPublisher, ROSMessagePublisher

    public abstract class NetworkPublisher<T>
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Manages the interface between the PublishAnnotatedOperation and the actual network protocol implemented by a specific Manager. This class is designed to be in one of two states, either the set of keys will be empty. In which case the name will be used as the publish key. In the other case the keys list will be populated and each value will need to be published with a specific key.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected NetworkPublisher()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkNamePresent()
      Checks that the name is present before performing any operation.
      abstract void close()
      Close the network publisher.
      abstract void publish​(T publish)
      Should be called to pass a value to be published to the NetworkPublisher.
      protected abstract void publishNameChanged​(java.util.Optional<java.lang.String> oldName, java.lang.String newName)
      Called when when the name assigned to the publisher changes.
      void setName​(java.lang.String name)
      Sets the name for the publisher.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NetworkPublisher

        protected NetworkPublisher()
    • Method Detail

      • setName

        public final void setName​(java.lang.String name)
        Sets the name for the publisher. It is acceptable to set the name to the existing name without consequence. If the name for the publisher changes publishNameChanged(Optional, String) will be called.
        Parameters:
        name - The new/existing name for the publisher.
      • checkNamePresent

        protected final void checkNamePresent()
        Checks that the name is present before performing any operation.
      • publish

        public abstract void publish​(T publish)
        Should be called to pass a value to be published to the NetworkPublisher.
        Parameters:
        publish - The value to publish
      • publishNameChanged

        protected abstract void publishNameChanged​(java.util.Optional<java.lang.String> oldName,
                                                   java.lang.String newName)
        Called when when the name assigned to the publisher changes. This method should not be called directly, instead, call setName(String).
        Parameters:
        oldName - the old name for the publisher. Will be empty if the name was never set before.
        newName - the new name for the publisher. Will not be an empty string.
      • close

        public abstract void close()
        Close the network publisher. This should not throw an exception.
        Specified by:
        close in interface java.lang.AutoCloseable