def _setupForwarding(clsDict, interface, attr, attrCls): """ Define all methods declared by the interface. All defined methods will forward the call to an instance attribute using the same method signature as the target methods. @param clsDict: Class dictionary where the created methods are stored and which can then be used to create the class. (Modifies the given reference) @type clsDict: dict @param interface: Interface which is used to get the names of all the methods which should be forwarded. The class created using @param clsDict implements this interface. @type interface: zope.interface.Interface @param attr: The name of the attribute to which the calls will be forwarded. @type attr: str @param attrCls: The class of the attribute to which the calls will be forwarded. It also has to implement the interface @param interface. """ verifyClass(interface, attrCls) for name in interface.names(): clsDict[name] = _createForwardingMethod(attr, getattr(attrCls, name))
def registerCommand(self, cmdList): """ Register a command class which should be used to (de-)serialize the command which should be added. @param cmdList: List of command classes which should be registered. @type cmdList: [ core.interfaces.ISerializable ] @raise: util.interfaces.InterfaceError if the command class does not implement core.interfaces.ISerializable. """ for cmd in cmdList: verifyClass(ISerializable, cmd) self._cmdCls[cmd.IDENTIFIER] = cmd
def addCustomConverter(self, converter): """ Register a new custom Converter. @raise: errors.InternalError, util.interfaces.InterfaceError """ verifyClass(IROSConverter, converter) if converter.MESSAGE_TYPE in self._customTypes: raise InternalError('There are multiple Converters given for ' 'message type "{0}".'.format( converter.MESSAGE_TYPE)) args = converter.MESSAGE_TYPE.split('/') if len(args) != 2: raise InternalError('msg type is not valid. Has to be of the from ' 'pkg/msg, i.e. std_msgs/Int8.') self._customTypes[converter.MESSAGE_TYPE] = (converter, self._loader.loadMsg(*args))