1 """Package for dumping purposes.
13 instance.__call__ = lambda: instance
17 ## @ingroup CPPHighAPI
18 # Collect information about features that may be dumped and stores the model as a Python script
20 class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper):
24 ModelHighAPI.ModelHighAPI_Dumper.__init__(self)
25 ModelHighAPI.ModelHighAPI_Dumper.setInstance(self)
26 self.collectFeatures()
28 ## Collect feature wrappers, which allow dumping (have method dump)
29 def collectFeatures(self):
31 for aModule in sys.modules:
32 for aName, anObj in inspect.getmembers(sys.modules[aModule], inspect.isclass):
33 if issubclass(anObj, ModelHighAPI.ModelHighAPI_Interface) and hasattr(anObj, "ID") and anObj.dump != ModelHighAPI.ModelHighAPI_Interface.dump:
34 self.myFeatures[anObj.ID()] = anObj
36 ## Create wrapper for a given feature and dump it
37 def dumpFeature(self, theFeature, theForce):
38 aFeatureKind = theFeature.getKind()
39 if aFeatureKind in self.myFeatures:
40 # Dump only feature created by user (in history).
41 # For all other features, just keep their name.
42 if theForce or aFeatureKind == "Parameter" or theFeature.isInHistory():
43 self.myFeatures[aFeatureKind](theFeature).dump(self)
47 ## Return getter for specified attribute
48 def attributeGetter(self, theFeature, theAttrName):
49 aFeatureKind = theFeature.getKind()
50 if aFeatureKind in self.myFeatures:
51 return self.myFeatures[aFeatureKind](theFeature).attributeGetter(theAttrName)
55 dumper = DumpAssistant