Main framework for AutoArchive.
Mainf helps to implement architecture where an application consists of several components (which can map the logical structure). In particular, it provides a way to prevents to see eachothers package internal implementation objects and allows them to expose only public interfaces.
Each component class has to derive from IComponent interface. All IComponent classes has to be passed to MainfEngine during its initialization using the MainfEngine.addComponent() method. Components have possibility to register instances of their public interfaces implementations using the IInterfaceAccessor which is passed to them during their construction. Doing so, they make them available to other components (which can access them via the same interface).
Components should expose their interface definitions to others while classes that implements them should be hidden in private packages/modules.
Additionally, Mainf defines interface IComponentUi for a user interface that components should use to access a UI (which has to implement it).
Mainf framework is initialized by creating the MainfEngine by createMainfEngine() factory method following by populating it by component classes. Finally, calling MainfEngine.start() method, starts the application passing the appEnvironment which is an arbitrary object that will be available to components via IMainfContext component interface. Mainf in turn, instantiates all components and executes them by calling the IComponent.run() method for each.
IComponent interface.
Bases: builtins.object
Interface for components of Mainf framework.
Each component of Mainf framework has to implement this interface. Components are managed by MainfEngine and can expose their interfaces via IInterfaceAccessor.
During construction the component can get and access other’s components interfaces via interfaceAccessor. Using the same object it can register its own public interfaces as well.
See also the description of _mainf package (_mainf).
Parameters: | interfaceAccessor (IInterfaceAccessor) – Can be used to get/register public interfaces. |
---|
IComponentUi interface, UiMessageKinds and VerbosityLevels enums.
Bases: AutoArchive._mainf.iinterface_accessor.IComponentInterface
Basic interface for an UI implementation.
Defines basic methods for showing messages of various importance to a user.
Note
There should be at least one component that implements this interface in order to provide an UI access to other components.
See also the description of _mainf package (_mainf).
Present a line of text to the user.
Note
The verbosity level has no effect on presenting the line.
Parameters: | line (str) – The text that shall be presented to the user. |
---|
Show an error message to (UiMessageKinds.Error) the user.
See also: verbosity.
Parameters: | msg (str) – The message that should be shown to the user. |
---|
Show an information message (UiMessageKinds.Info) to the user.
See also: verbosity.
Parameters: | msg (str) – The message that should be shown to the user. |
---|
Show an unintrusive notification message (UiMessageKinds.Notification) to the user.
Note
If user interface implementation does not have means to support notifications then it should be presented to the user similarly as showInfo().
See also: verbosity.
Parameters: | msg (str) – The message that should be shown to the user. |
---|
Show a verbose-type message (UiMessageKinds.Verbose) to the user.
Verbose messages should be shown only if user enables it. Although this method can be called regardless of current verbosity level, the concrete implementation can decide whether it will be shown or not if verbosity level is 0. It is not recommended to call this method if verbosity level is 0 due to performance reasons. Current verbosity level can be obtained via verbosity property.
See also: verbosity.
Parameters: | msg (str) – The message that should be shown to the user. |
---|
Show a warning message (UiMessageKinds.Warning) to the user.
See also: verbosity.
Parameters: | msg (str) – The message that should be shown to the user. |
---|
Gets the verbosity level.
If verbosity level is VerbosityLevels.Quiet only messages of kind UiMessageKinds.Error are shown. For level VerbosityLevels.Normal all messages kinds except UiMessageKinds.Verbose are shown. For level VerbosityLevels.Verbose all message kinds are shown.
Return type: | VerbosityLevels |
---|
Kinds of user messages.
Verbosity levels.
IInterfaceAccessor and :class:`IComponentInterface interfaces.
Bases: builtins.object
Provides access to components public interfaces.
A component can make available its provided interfaces to other components by registering them via this interface. Registered classes has to implement IComponentInterface.
See also the description of _mainf package (_mainf).
Provides access to registered component interfaces.
See also: registerComponentInterface().
Parameters: | interfaceType (type{IComponentInterface}) – Type of the desired interface. |
---|---|
Returns: | Instance of interfaceType. |
Return type: | interfaceType |
Raises: |
|
Registers a component public interface.
Makes an interface available to other components by registering it.
See also: unregisterComponentInterface(), getComponentInterface().
Parameters: |
|
---|---|
Raises: |
|
Unregister a component interface.
See also: registerComponentInterface(), getComponentInterface()
Parameters: | interfaceType (type{IComponentInterface}) – Type of the instance that should be unregistered. |
---|---|
Raises: |
|
Bases: builtins.object
Tagging interface for components provided interfaces.
See also: IInterfaceAccessor.
IMainfContext interface.
Bases: AutoArchive._mainf.iinterface_accessor.IComponentInterface
Provides access to a various program-related objects.
Gets an appEnvironment object.
This is the object that was passed to the Mainf during its initialization. It is an arbitrary object of which structure Mainf has no knowledge.
Warning
As passing the appEnvironment object to Mainf is optional this property can be None.
Return type: | object |
---|
createMainfEngine() function.
Creates an instance of MainfEngine.
Returns: | A MainfEngine instance. |
---|---|
Return type: | MainfEngine |