Re: Tutorial to use ObjectHandler outside of QuantLibXL
Posted by Lisa Ann on Aug 25, 2015; 3:30pm
URL: http://quantlib.414.s1.nabble.com/Tutorial-to-use-ObjectHandler-outside-of-QuantLibXL-tp16776p16849.html
I picked the third one: #include <oh/auto_link.hpp> in MyValueObject.h.
Finally, some good news (thanks to your holy patience and hints, Eric).
This seems to be the the first working step:
#include <iostream>
#include <exception>
#include "MyValueObject.h"
void makeObject(
const std::string& objectID)
{
boost::shared_ptr< ObjectHandler::ValueObject > valueObject(new MyValueObject(objectID, "", false));
boost::shared_ptr< ObjectHandler::Object > object(new ObjectHandler::Object(valueObject, false));
ObjectHandler::Repository::instance().storeObject(objectID, object, true);
};
std::string getObject(
const std::string& objectID) const
{
boost::shared_ptr< ObjectHandler::Object > object;
ObjectHandler::Repository::instance().retrieveObject(object, objectID);
boost::shared_ptr< ObjectHandler::ValueObject > valueObject = object->properties();
return valueObject->objectId();
};
int main()
{
try
{
ObjectHandler::Repository repository;
makeObject("Object1");
std::cout << getObject("Object1");
}
catch(const std::exception &e)
{
std::cout << "Exception " << e.what() << std::endl;
return 1;
}
catch(...)
{
std::cout << "Exception" << std::endl;
return 1;
}
}
Runtime gives "Object1", which is the proper ID :)
Now it's time to see how it works in Excel... thank you!