Posted by
Bojan Nikolic on
Feb 29, 2012; 11:57pm
URL: http://quantlib.414.s1.nabble.com/Re-QuantLib-SWIG-the-observer-pattern-and-destructor-call-during-update-tp8917p8918.html
Hi Luigi,
I haven't fully worked this one out, but I think that it is possible to
some progress on this by making the destructor of the Observer class
private and then creating some helper classes (probably inheriting from
shared_pointer) that are friends of Observer and define proper clean
order, i.e., disconnect the Observables before starting the main
destruction.
This approach would enforce code correctness at compile time (because
non-safe destruction of Observer objects would be a compile time error)
but would obviously require changes to existing code. It should play
fairly well with SWIG which is I think already aware of the implications
of a private destructor.
There is no less invasive way I can think of at moment -- the goal of
having easy composition of objects in C++ makes it very hard to re-order
destruction operations! Possibly one can do something very clever with
clone()-able objects and overriding the operator new() for Observer but
that would be getting really complicated....
Best,
Bojan
--
Bojan Nikolic ||
http://www.bnikolic.co.uk------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev