Monday, September 17, 2007

Note 01: Typical Example for using QuantLibAddin C++ client

#include  #include 
using namespace std;
using namespace QuantLib;
using namespace ObjHandler;
using namespace QuantLibAddin;

int main() {
// deal with errors
try {
// setup log file
setLogFile("*****.log");
// direct log messages to stdout
setConsole(1);
// write log message to log file
logMessage("************");

ObjHandler::obj_ptr MyObject(new *****(***));...

// store "MyObject"
storeObject("MyObject",Myobject) ;
//ObjectHandler::Repository::instance().storeObject("MyObject", Myobject);

// write to log file the object's ID
logObject("Myobject");

// retrieve "MyObject" Retrieve the object with the
//given ID and recast it to the desired type
// retrieveObject("MyObJect",Myobject);

return 0;
} catch (const std::exception &e) {
std::ostringstream s;
s << "Error: " << e.what();
ObjectHandler::logMessage(s.str(), 1); return 1;
} catch (...)
{ ObjectHandler::logMessage("Error", 1);
return 1; }

No comments: