RE: [Quantlib-users] Observable Python objects
Posted by Andre Louw-2 on Nov 10, 2003; 9:07pm
URL: http://quantlib.414.s1.nabble.com/Observable-Python-objects-tp10448p10449.html
Luigi,
I probably did not express myself properly.
The Observer side works well (even using inheritance), the problem being
that Python objects can only observe QuantLib C++ objects (those defined as
type 'isObservable' in their SWIG interface files). I'm looking at the other
side where a Python object becomes observable by other Python objects.
Something in the line of
class Foo(Observable):
def __init__(self):
Observable.__init__(self)
def changeMe(self):
self.notifyObservers()
class FooObserver:
def __init__(self):
self.obs = QuantLib.Observer(self.update)
def update(self):
print "Happens when Foo changed"
def registerWith(self,o):
self.obs.registerWith(o)
f = Foo()
fo = FooObserver()
fo.registerWith(f)
f.changeMe() --> should result in an update in FooObserver...
Andre