Hi,
I have a little problem ... There is a class KernelDensity declared as follows in the type.xml file: <DataType defaultSuperType='libraryClass'>QuantLib::KernelDensity</DataType> There is a second class RiskEngine with a member function which returns a shared_ptr<KerndelDensity>. In QuantLib: boost::shared_ptr<KernelDensity> kernelDensity(string name, int method); The xml for the declaration of this member function looks like this: <ReturnValue> <type>QuantLib::KernelDensity</type> <tensorRank>scalar</tensorRank> </ReturnValue> When I compile the whole thing I get error C2440: 'Initialisierung': 'boost::shared_ptr<T>' kann nicht in 'std::basic_string<_Elem,_Traits,_Ax>' konvertiert werden with 2> T=QuantLib::KernelDensity 2> and 2> _Elem=char, 2> _Traits=std::char_traits<char>, 2> _Ax=std::allocator<char> I did not find an example in the existing code where an object (other than native types) is returned, so can someone explain to me, how to do this? Thanks a lot in advance, best regards Peter ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Peter
On Fri, Jun 11, 2010 at 6:03 PM, Peter Caspers <[hidden email]> wrote: > a member function which returns a shared_ptr<KerndelDensity> > [...] > I did not find an example in the existing code where an object > (other than native types) is returned, so can someone explain > to me, how to do this? in QLXL if you have to return a shared_ptr<T> it's equivalent to create a new Object in the repository, i.e. a new pointer to a new or already existing object Take a look at trunk\QuantLibAddin\qlo\vanillaswap.hpp for examples. One can create a VanillaSwap in the classic way, or using helper factories (MakeVanillaSwap, MakeIMMSwap), or can retrieve a new pointer to an existing instance (SwapIndex->underlyingSwap(), SwapRateHelper->swap()( Let me know if you need more help ciao -- Nando ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Nando,
thanks a lot. Sorry for my ignorance of QLXL first of all. I have no problem exporting a constructor to excel which creates say an object of type B. What I do not manage is to export a member function in another object of type A which returns a shared_ptr to another type B. As far as I understood exporting member functions requires only an xml of the form <Member name='qlMemberFunctionWhichReturnsB' type='QuantLib::A'> ... <ReturnValue> <type>QuantLib::B</type> <superType>libraryClass</type> <tensorRank>scalar</tensorRank> </ReturnValue> ... </Member> but exactly this automatism does not work, because in the generated files at some point "string" meets "shared_ptr" and compilation crashes. I looked at the files recommended by you, but in qlo / vanillaswap.hpp I only see constructors. Also I do not see that the underlyingSwap() method of swapindex is exported to excel (at least not the way I want to do it). My workaround is to export another constructor for type B which takes A as an argument and mimics the member function I originally wanted to export. Does this make sense? Can you help? Or to put the question more simple: Is there any example in the xml files where a member function is exported which returns a reference to a QuantLib Object, which is not a native type or convertible to a native type? Thanks a lot again, best Peter "Ferdinando M. Ametrano" <ferdinando@ametr An ano.net> Peter Caspers <[hidden email]> 15.06.2010 12:32 Kopie [hidden email] Thema Re: [Quantlib-dev] Return object in QLXL Hi Peter On Fri, Jun 11, 2010 at 6:03 PM, Peter Caspers <[hidden email]> wrote: > a member function which returns a shared_ptr<KerndelDensity> > [...] > I did not find an example in the existing code where an object > (other than native types) is returned, so can someone explain > to me, how to do this? in QLXL if you have to return a shared_ptr<T> it's equivalent to create a new Object in the repository, i.e. a new pointer to a new or already existing object Take a look at trunk\QuantLibAddin\qlo\vanillaswap.hpp for examples. One can create a VanillaSwap in the classic way, or using helper factories (MakeVanillaSwap, MakeIMMSwap), or can retrieve a new pointer to an existing instance (SwapIndex->underlyingSwap(), SwapRateHelper->swap()( Let me know if you need more help ciao -- Nando ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev ------------------------------------------------------------------------------------------------------------------------------------------------------ WGZ BANK AG Westdeutsche Genossenschafts-Zentralbank Sitz: Düsseldorf, Registergericht: Amtsgericht Düsseldorf, HRB 52363 Vorstand: Werner Böhnke (Vors.), Karl-Heinz Moll, Hans-Bernd Wolberg, Uwe Berghaus (stellv.), Dr. Christian Brauckmann (stellv.), Michael Speth (stellv.) Vorsitzender des Aufsichtsrats: Dieter Philipp Ueber das Internet versandte E-Mails koennen unter fremdem Namen erstellt oder inhaltlich veraendert werden. Aus diesem Grund sind unsere als E-Mail verschickten Nachrichten grundsaetzlich keine rechtsverbindlichen Erklaerungen. Der Inhalt dieser E-Mail samt Anlagen ist vertraulich und u. U. rechtlich geschuetzt. Der Inhalt ist ausschließlich an einen bestimmten Empfaenger gerichtet. Eine Weitergabe, die Herstellung von Kopien oder der sonstige Gebrauch durch Nichtadressaten ist nicht erlaubt. Messages sent by e-mail can be manipulated by third parties. For this reason our e-mail messages are generally not legally binding. This electronic message (including any attachments) contains confidential information and may be privileged or otherwise protected from disclosure. The information is intended to be for the use of the intended addressee only. Please be aware that any copy, distribution or use of the contents of this message by any other person than the intended addressee is prohibited. ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Peter
> What I do not manage is to export a member function in another object of > type A which returns a shared_ptr to another type B. here it is, namely a SwapRateHelper returning a shared_ptr<VanillaSwap> using its own SwapRateHelper::swap() method: VanillaSwap::VanillaSwap( const shared_ptr<ValueObject>& properties, const shared_ptr<QuantLib::SwapRateHelper>& swapRH, bool permanent) : Swap(properties, permanent) { libraryObject_ = swapRH->swap(); } and the wrapping code is auto-generated by the following xml: <Constructor name='qlVanillaSwapFromSwapRateHelper'> <libraryFunction>VanillaSwap</libraryFunction>
<SupportedPlatforms> <SupportedPlatform name='Excel'/>
<SupportedPlatform name='Cpp'/> </SupportedPlatforms>
<ParameterList> <Parameters>
<Parameter name='SwapRateHelper'> <type>QuantLib::SwapRateHelper</type>
<tensorRank>scalar</tensorRank> <description>SwapRateHelper object ID.</description>
</Parameter> </Parameters>
</ParameterList> </Constructor>
The key point here is that even if in C++ swap() is just a method of SwapRateHelper returning shared_ptr<VanillaSwap>, in QLXL is used as "constructor" of a new Object wrapping the shared_ptr<VanillaSwap>
does this answer your question?
ciao -- Nando
------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Nando,
I think so. This looks similar to my workaround except that it is done only in the QuantlibObjects Layer, invoking the Quantlib member function from there. This is much better than my solution and exactly what I need. Makes me happy, really. Thanks a lot, best regards Peter "Ferdinando M. Ametrano" <ferdinando@ametr An ano.net> Peter Caspers <[hidden email]> 16.06.2010 18:01 Kopie [hidden email] Thema Re: Re: [Quantlib-dev] Return object in QLXL Hi Peter > What I do not manage is to export a member function in another object of > type A which returns a shared_ptr to another type B. here it is, namely a SwapRateHelper returning a shared_ptr<VanillaSwap> using its own SwapRateHelper::swap() method: VanillaSwap::VanillaSwap( const shared_ptr<ValueObject>& properties, const shared_ptr<QuantLib::SwapRateHelper>& swapRH, bool permanent) : Swap(properties, permanent) { libraryObject_ = swapRH->swap(); } and the wrapping code is auto-generated by the following xml: <Constructor name='qlVanillaSwapFromSwapRateHelper'> <libraryFunction>VanillaSwap</libraryFunction> <SupportedPlatforms> <SupportedPlatform name='Excel'/> <SupportedPlatform name='Cpp'/> </SupportedPlatforms> <ParameterList> <Parameters> <Parameter name='SwapRateHelper'> <type>QuantLib::SwapRateHelper</type> <tensorRank>scalar</tensorRank> <description>SwapRateHelper object ID.</description> </Parameter> </Parameters> </ParameterList> </Constructor> The key point here is that even if in C++ swap() is just a method of SwapRateHelper returning shared_ptr<VanillaSwap>, in QLXL is used as "constructor" of a new Object wrapping the shared_ptr<VanillaSwap> does this answer your question? ciao -- Nando ------------------------------------------------------------------------------------------------------------------------------------------------------ WGZ BANK AG Westdeutsche Genossenschafts-Zentralbank Sitz: Düsseldorf, Registergericht: Amtsgericht Düsseldorf, HRB 52363 Vorstand: Werner Böhnke (Vors.), Karl-Heinz Moll, Hans-Bernd Wolberg, Uwe Berghaus (stellv.), Dr. Christian Brauckmann (stellv.), Michael Speth (stellv.) Vorsitzender des Aufsichtsrats: Dieter Philipp Ueber das Internet versandte E-Mails koennen unter fremdem Namen erstellt oder inhaltlich veraendert werden. Aus diesem Grund sind unsere als E-Mail verschickten Nachrichten grundsaetzlich keine rechtsverbindlichen Erklaerungen. Der Inhalt dieser E-Mail samt Anlagen ist vertraulich und u. U. rechtlich geschuetzt. Der Inhalt ist ausschließlich an einen bestimmten Empfaenger gerichtet. Eine Weitergabe, die Herstellung von Kopien oder der sonstige Gebrauch durch Nichtadressaten ist nicht erlaubt. Messages sent by e-mail can be manipulated by third parties. For this reason our e-mail messages are generally not legally binding. This electronic message (including any attachments) contains confidential information and may be privileged or otherwise protected from disclosure. The information is intended to be for the use of the intended addressee only. Please be aware that any copy, distribution or use of the contents of this message by any other person than the intended addressee is prohibited. ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |