From: Tito I. <tit...@ya...> - 2009-10-31 14:16:07
|
Hi Andrea, Another approach you may consider is illustrated in the DiscreteHedging.java example. Here I wanted to use Quantlib's MC capabilities but wanted the pricer to be implemented in java. By pulling the MonteCarloModel impl into java I was able to use a pathpricer implemented in java. Not sure if this is applicable to your problem, but it's an approach I've used in a number of cases to integrate quantlib and java. You may also implement your Payoff in C++ and then expose it yourself via swig to your java.... Best, Tito. ----- Original Message ---- From: Andrea <mar...@go...> To: qua...@li... Sent: Thu, October 29, 2009 1:59:42 PM Subject: Re: [Quantlib-dev] QuantLib-SWING: is it possible to use polymorphism? On 29/10/09 16:03, Luigi Ballabio wrote: > On Wed, 2009-10-21 at 17:58 +0100, Andrea wrote: >> On 21/10/09 15:55, Luigi Ballabio wrote: >>> unfortunately, polymorphism doesn't currently work across >> languages. >>> >> Indeed. >> I've tried to use directors and it seems to work well if there are no >> shared_ptr involved. >> >> My problem now is [...] I don't seem to be able to create a shared_ptr >> in the target language. > > There would be quite a bit of work to do. You would have to: > - add a constructor to boost::shared_ptr in common.i so that it takes a > pointer; I've got a big doubt here. Is it safe to stick the raw pointer into a shared_ptr? Is it already owned by some other swig mechanism? > - modify the exported payoff classes so that they no longer hide the > shared_ptr (e.g., export the actual PlainVanillaPayoff, not > PlainVanillaPayoffPtr) and enable directors; > - export the shared_ptr<Payoff> as a separate class; > - fix the other interfaces so that they work with the new classes. > > Let me know if you get stuck in any of the steps. > > Luigi > > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ QuantLib-dev mailing list Qua...@li... https://lists.sourceforge.net/lists/listinfo/quantlib-dev |