[QuantLibAddin-cvs] QuantLibAddin/qlo conversions.hpp,1.18,1.19
Brought to you by:
ericehlers,
nando
|
From: Eric E. <eri...@us...> - 2006-11-07 14:26:13
|
Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22051/qlo Modified Files: conversions.hpp Log Message: handleToLib - add support for an additional dynamic cast for cases where the requested reference is not the same class as the original Index: conversions.hpp =================================================================== RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/conversions.hpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** conversions.hpp 30 Oct 2006 10:30:57 -0000 1.18 --- conversions.hpp 7 Nov 2006 14:26:06 -0000 1.19 *************** *** 77,93 **** // 3) Otherwise the Object is of an unexpected class so raise an exception ! template <class qlClass, class qloClass> inline boost::shared_ptr<qlClass> handleToLib(const std::string &id) { OH_GET_OBJECT(objectPointer, id, ObjHandler::Object) ! boost::shared_ptr<QuantLibAddin::Handle<qlClass> > handlePointer = ! boost::dynamic_pointer_cast<QuantLibAddin::Handle<qlClass> >(objectPointer); if (handlePointer) { ! return handlePointer->getHandle().currentLink(); } else { boost::shared_ptr<qloClass> qloPointer = boost::dynamic_pointer_cast<qloClass>(objectPointer); - if (qloPointer) { boost::shared_ptr<qlClass> ret; --- 77,113 ---- // 3) Otherwise the Object is of an unexpected class so raise an exception ! template <class qlClass2, class qlClass, class qloClass> inline boost::shared_ptr<qlClass> handleToLib(const std::string &id) { OH_GET_OBJECT(objectPointer, id, ObjHandler::Object) ! boost::shared_ptr<QuantLibAddin::Handle<qlClass2> > handlePointer = ! boost::dynamic_pointer_cast<QuantLibAddin::Handle<qlClass2> >(objectPointer); if (handlePointer) { ! boost::shared_ptr<qlClass2> qlPointer2 = ! handlePointer->getHandle().currentLink(); ! if (!qlPointer2) { ! std::ostringstream msg; ! msg << "error retrieving object with id '" << id ! << "' from repository - unable to retrieve reference " ! << "contained in handle"; ! throw ObjHandler::Exception(msg.str()); ! } ! boost::shared_ptr<qlClass> qlPointer1 = ! boost::dynamic_pointer_cast<qlClass>(qlPointer2); ! if (qlPointer1) ! return qlPointer1; ! else { ! std::ostringstream msg; ! msg << "error retrieving object with id '" << id ! << "' from repository - unable to convert class from " ! << " " << typeid(qlClass2).name() ! << std::endl << " to " ! << " " << typeid(qlClass).name(); ! throw ObjHandler::Exception(msg.str()); ! } } else { boost::shared_ptr<qloClass> qloPointer = boost::dynamic_pointer_cast<qloClass>(objectPointer); if (qloPointer) { boost::shared_ptr<qlClass> ret; |