Code: Select all
'''Parent module, _NifParser'''
class GenericNifParser(object):
def parse_NiTextureData(self):
'''stuff'''
def parse_NiMaterial(self):
'''stuff'''
def parse_NiMesh(self):
'''stuff'''
Code: Select all
'''Module A, some other file'''
from _NifParser import GenericNifParser
class NifParser20060500(GenericNifParser):
'''20.6.5.00 nif parser'''
def parse_NiDataStream118(self):
'''Add some new methods for these new structs'''
...
Code: Select all
'''Module B, another file'''
from _NifParser import GenericNifParser
class NifParser30010000(GenericNifParser):
'''30.1.0.00 nif parser'''
...
def parse_NiMesh(self):
'''Overrides parent method'''
...
The main problem I had with that design was this:
Some formats (say, 10.1.0.0 to 20.0.0.0) may use a particular struct for one of the nodes, and then starting in a later version (say, 20.6.0.0) they decided to change it. And then that change persists until some other later version.
I would like only one copy of the first struct to exist at any given time, and I would also like only one copy of the new struct to exist at any given time as well (to reduce redundancy).
But then how would you structure the inheritance tree? I guess instead of just inheriting from a generic nif parser, you could instead inherit from one of the later nif parsers as well...? Since each version pretty much seems to build on the previous.


