+
+# Warning: smeshInst is a singleton
+smeshInst = None
+engine = None
+doLcc = False
+
+class smeshDC(object, SMESH._objref_SMESH_Gen):
+
+ def __new__(cls):
+ global engine
+ global smeshInst
+ global doLcc
+ print "__new__", engine, smeshInst, doLcc
+
+ if smeshInst is None:
+ # smesh engine is either retrieved from engine, or created
+ smeshInst = engine
+ # Following test avoids a recursive loop
+ if doLcc:
+ if smeshInst is not None:
+ # smesh engine not created: existing engine found
+ doLcc = False
+ if doLcc:
+ doLcc = False
+ # FindOrLoadComponent called:
+ # 1. CORBA resolution of server
+ # 2. the __new__ method is called again
+ print "smeshInst = lcc.FindOrLoadComponent ", engine, smeshInst, doLcc
+ smeshInst = salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" )
+ else:
+ # FindOrLoadComponent not called
+ if smeshInst is None:
+ # smeshDC instance is created from lcc.FindOrLoadComponent
+ print "smeshInst = super(smeshDC,cls).__new__(cls) ", engine, smeshInst, doLcc
+ smeshInst = super(smeshDC,cls).__new__(cls)
+ else:
+ # smesh engine not created: existing engine found
+ print "existing ", engine, smeshInst, doLcc
+ pass
+
+ return smeshInst
+
+ return smeshInst
+
+ def __init__(self):
+ print "__init__"
+ SMESH._objref_SMESH_Gen.__init__(self)