QuantLibAddin member function OH_GET_OBJECT vs OH_GET_REFERENCE

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

QuantLibAddin member function OH_GET_OBJECT vs OH_GET_REFERENCE

Jerry Jin
Hello QuantLib community

I'm working on a project based on QuantLib 1.7.1 and QuantLibAddin 1.7 , I've been studying the rule xml files under QuantLibAddin/gensrc/metadata folder, and have ported some of the addin functions: the constructors and enumeration constructors.

When I started on member functions, I'm confused about when to use OH_GET_OBJECT and OH_GET_REFERENCE, I couldn't find any rule in those xml files or anywhere else.

Please kindly explain, when to use one of the 2 marco before calling member function.

Thanks a lot!

Regards
Jerry

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLibAddin member function OH_GET_OBJECT vs OH_GET_REFERENCE

Eric Ehlers-3
Hi Jerry,

OH_GET_OBJECT retrieves a shared pointer to a QuantLibAddin (wrapper)
object.

OH_GET_REFERENCE retrieves a shared pointer to the underlying QuantLib
object contained within the QuantLibAddin object.

Consider this subset of the QuantLibAddin interface:

namespace QuantLib {
    class Bond : public Instrument {
      public:
        const Calendar& calendar() const;
    };
}

namespace QuantLibAddin {
    class Bond : public Instrument {
      public:
        std::string currency();
    };
}

To call the first function, addin function qlBondCalendar uses
OH_GET_REFERENCE to retrieve a QuantLib::Bond, and it invokes the
member function on that:

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::Bond, QuantLib::Bond)

        QuantLib::Calendar returnValue = ObjectIdLibObjPtr->calendar();

To call the second function, addin function qlBondCurrency uses
OH_GET_OBJECT to retrieve a QuantLibAddin::Bond, and it invokes the
member function on that:

        OH_GET_OBJECT(ObjectIdObjPtr, ObjectId,
            QuantLibAddin::Bond)

        std::string returnValue = ObjectIdObjPtr->currency();

I hope that makes sense, don't hesitate to get back to me if you need
more info.

You are using the old build which will eventually be superseded by the
new build.  The new build uses SWIG interface files instead of the XML
files and will be easier to work with:

    http://quantlib.org/reposit/docs/latest/comparison.html

Kind Regards,
Eric

On Tue, 5 Jul 2016 10:56:36 +0800
Jerry Jin <[hidden email]> wrote:

> Hello QuantLib community
>
> I'm working on a project based on QuantLib 1.7.1 and QuantLibAddin
> 1.7 , I've been studying the rule xml files under
> QuantLibAddin/gensrc/metadata folder, and have ported some of the
> addin functions: the constructors and enumeration constructors.
>
> When I started on member functions, I'm confused about when to use
> OH_GET_OBJECT and OH_GET_REFERENCE, I couldn't find any rule in those
> xml files or anywhere else.
>
> Please kindly explain, when to use one of the 2 marco before calling
> member function.
>
> Thanks a lot!
>
> Regards
> Jerry
>

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLibAddin member function OH_GET_OBJECT vs OH_GET_REFERENCE

Jerry Jin
Thank you Eric!

I found the rule in xml:

<Member name='qlBondSettlementDays' type='QuantLib::Bond'>

the type attribute namespace drives which marco to use, if it's QuantLib, then it's get reference, if it's QuantLibAddin, it's get object.

I've used this rule in my project, the compile step passed.

Yes, I'm aware i'm using old version, I have to complete this first, and for 1.8 i'll look at SWIG interface

Regards
Jerry


On Wed, Jul 6, 2016 at 4:30 AM, Eric Ehlers <[hidden email]> wrote:
Hi Jerry,

OH_GET_OBJECT retrieves a shared pointer to a QuantLibAddin (wrapper)
object.

OH_GET_REFERENCE retrieves a shared pointer to the underlying QuantLib
object contained within the QuantLibAddin object.

Consider this subset of the QuantLibAddin interface:

namespace QuantLib {
    class Bond : public Instrument {
      public:
        const Calendar& calendar() const;
    };
}

namespace QuantLibAddin {
    class Bond : public Instrument {
      public:
        std::string currency();
    };
}

To call the first function, addin function qlBondCalendar uses
OH_GET_REFERENCE to retrieve a QuantLib::Bond, and it invokes the
member function on that:

        OH_GET_REFERENCE(ObjectIdLibObjPtr, ObjectId,
            QuantLibAddin::Bond, QuantLib::Bond)

        QuantLib::Calendar returnValue = ObjectIdLibObjPtr->calendar();

To call the second function, addin function qlBondCurrency uses
OH_GET_OBJECT to retrieve a QuantLibAddin::Bond, and it invokes the
member function on that:

        OH_GET_OBJECT(ObjectIdObjPtr, ObjectId,
            QuantLibAddin::Bond)

        std::string returnValue = ObjectIdObjPtr->currency();

I hope that makes sense, don't hesitate to get back to me if you need
more info.

You are using the old build which will eventually be superseded by the
new build.  The new build uses SWIG interface files instead of the XML
files and will be easier to work with:

    http://quantlib.org/reposit/docs/latest/comparison.html

Kind Regards,
Eric

On Tue, 5 Jul 2016 10:56:36 +0800
Jerry Jin <[hidden email]> wrote:

> Hello QuantLib community
>
> I'm working on a project based on QuantLib 1.7.1 and QuantLibAddin
> 1.7 , I've been studying the rule xml files under
> QuantLibAddin/gensrc/metadata folder, and have ported some of the
> addin functions: the constructors and enumeration constructors.
>
> When I started on member functions, I'm confused about when to use
> OH_GET_OBJECT and OH_GET_REFERENCE, I couldn't find any rule in those
> xml files or anywhere else.
>
> Please kindly explain, when to use one of the 2 marco before calling
> member function.
>
> Thanks a lot!
>
> Regards
> Jerry
>


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users