Module: interfaces | interfaces.py | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
This module should contain all interfaces for pub. An interface is a class which documents how other classes or class instances should work. For instance the interface IOpenL documents functions that must be supported by objects like doors and books to be funtional. The interfaces are in alphabetical order. We use interfaces by using advise to make an object support the protocol. like so: class Test(pub.core.Component): advise(instancesProvide=[IOpenL]) This makes a component which we can add as a part of gameobjects. Interfaces have a very basic set of methods, these MUST be provided in components. They don't have to do anything more than just calling chain.next(). You can also have methods raising specific errors depending on what you want to do. Other methods are component specific. All methods that a component provides on behalf of an interface must be callable with the minimum of (chain). This ensures that invoke works with all these methods.
|