smartinspectpython.siprotocolfactory
Creates Protocol instances and registers custom protocols.
This class is responsible for creating instances of Protocol subclasses and registering custom protocol implementations. To add a custom protocol, please have a look at the documentation and example of the RegisterProtocol method.
Threadsafety:
This class is fully thread-safe.
Creates an instance of a Protocol subclass.
Arguments:
- name (str): The protocol name to search for.
- options (str): The options to apply to the new SIProtocol instance. Can be null.
Returns:
A new instance of a SIProtocol subclass.
Raises:
- SmartInspectException: Unknown protocol or invalid options syntax.
This method tries to create an instance of a SIProtocol subclass using the name parameter. If you, for example, specify "file" as name parameter, this method returns an instance of the SIFileProtocol class. If the creation of such an instance has been successful, the supplied options will be applied to the protocol.
For a list of available protocols, please refer to the SIProtocol class. Additionally, to add your own custom protocol, please have a look at the RegisterProtocol method.
Please note that if the name argument is null, then the return value of this method is null as well.
Registers a custom protocol implementation to the SmartInspect library.
Arguments:
- name (str): The name of the custom protocol to register.
- protocolClass (type): The class of your custom protocol. It needs to be a class derived from the SIProtocol class.
This method enables you to register your own custom protocols. This can be used to extend the built-in capabilities of the SmartInspect Python library. To add your own protocol, derive your custom protocol class from .siprotocol, choose a name and pass this name and the type to this method. After registering your protocol, you are able to use it in the SmartInspect.Connections" property just like any other (standard) protocol.
If one of the supplied arguments is null or the supplied type is not derived from the SIProtocol class then no custom protocol is added.