ObjectHandler::ohObjectLoad & Usage in standalone C++ Program

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

ObjectHandler::ohObjectLoad & Usage in standalone C++ Program

michael_ql
I have an XML file representation of a Schedule object which I have saved down from Excel that I wish to load into a standalone C++ program.

I have the following code that would load and use the object.

                        ObjectHandler::SerializationFactory::instance().loadObject(
                                "c:/temp",
                                "asched.xml",
                                false,
                                true);

                        OH_GET_REFERENCE(ObjectIdLibObjPtr, "sched",
                                QuantLibAddin::Schedule, QuantLib::Schedule)

For this to work I need to register the appropriate factories (Processor, Serialisation).

Is there a recommended way of getting this to work in a standalone C++ application?

Reply | Threaded
Open this post in threaded view
|

Re: ObjectHandler::ohObjectLoad & Usage in standalone C++ Program

michael_ql
I managed to get this working. Here is my code.

                        // Initialise all objects so that we can load from the object factory
                        auto obj1 = ObjectHandler::ProcessorFactory();
                        auto obj2 = QuantLibAddin::SerializationFactory();
                        auto obj3 = ObjectHandler::EnumTypeRegistry();
                        auto obj4 = ObjectHandler::Repository();

                        // Initialize the Enumeration Registry
                        QuantLibAddin::registerEnumeratedTypes();

                        // load object
                        ObjectHandler::SerializationFactory::instance().loadObject(
                                scheduleFileDirectory,
                                scheduleFile,
                                false,
                                true);

                        OH_GET_REFERENCE(ObjectIdLibObjPtr, "sched", QuantLibAddin::Schedule, QuantLib::Schedule)

                        // READ DATES
                        std::vector<Date> dates = ObjectIdLibObjPtr->dates();