void CScriptGameObject::StopTalk()
{
	CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object());
	if(!pInventoryOwner) return;
	pInventoryOwner->StopTalk();
}
 forceinline void
 SharedArray<T>::init(int n) {
   assert(object() == NULL);
   object(new SAO(n));
 }
 forceinline int
 SharedArray<T>::size(void) const {
   assert(object() != NULL);
   return static_cast<SAO*>(object())->size();
 }
示例#4
0
SEQSEQ(ANY) SAL_CALL CalcAddins_impl::qlRangeAccrualFloatersCouponFromLeg(
        const ANY &ObjectId,
        const ANY &RangeAccrualLeg,
        const ANY &Position,
        const sal_Int32 Permanent,
        const ANY &Trigger,
        const sal_Int32 Overwrite) throw(RuntimeException) {
    try {

        // convert input datatypes to C++ datatypes

        std::string ObjectIdCpp;
        calcToScalar(ObjectIdCpp, ObjectId);

        std::string RangeAccrualLegCpp;
        calcToScalar(RangeAccrualLegCpp, RangeAccrualLeg);

        long PositionCpp;
        calcToScalar(PositionCpp, Position);

        bool PermanentCpp;
        calcToScalar(PermanentCpp, Permanent);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Size PositionLib;
        calcToScalar(PositionLib, Position);

        // convert object IDs into library objects

        OH_GET_UNDERLYING(RangeAccrualLegLibObj, RangeAccrualLegCpp,
            QuantLibAddin::Leg, QuantLib::Leg)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlRangeAccrualFloatersCouponFromLeg(
                ObjectIdCpp,
                RangeAccrualLegCpp,
                PositionCpp,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::RangeAccrualFloatersCoupon(
                valueObject,
                RangeAccrualLegLibObj,
                PositionLib,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectIdCpp, object, Overwrite, valueObject);

        // Convert and return the return value



        ANY returnValueCalc;
        scalarToCalc(returnValueCalc, returnValue);

        SEQSEQ(ANY) retAnyArray;
        retAnyArray.realloc(1);
        SEQ(ANY) retAnyVector(1);
        retAnyVector[0] = returnValueCalc;
        retAnyArray[0] = retAnyVector;        
        return retAnyArray;

    } catch (const std::exception &e) {
        do { 
            std::ostringstream errorMsg; 
            errorMsg << "ERROR: qlRangeAccrualFloatersCouponFromLeg: " << e.what(); 
            OH_LOG_MESSAGE(errorMsg.str());
        
            SEQSEQ(ANY) retAnyArray;
            retAnyArray.realloc(1);
            SEQ(ANY) retAnyVector(1);
            STRING s = STRFROMASCII( errorMsg.str().c_str() );    
            retAnyVector[0] = CSS::uno::makeAny( s );
            retAnyArray[0] = retAnyVector;	    
            return retAnyArray;
        } while (false);
    }
}
示例#5
0
SEQSEQ(ANY) SAL_CALL CalcAddins_impl::qlRangeAccrualPricerByBgm(
        const ANY &ObjectId,
        const ANY &Correlation,
        const ANY &SmileOnStartDateID,
        const ANY &SmileOnEndDateID,
        const sal_Int32 WithSmile,
        const sal_Int32 ByCallSpread,
        const sal_Int32 Permanent,
        const ANY &Trigger,
        const sal_Int32 Overwrite) throw(RuntimeException) {
    try {

        // convert input datatypes to C++ datatypes

        std::string ObjectIdCpp;
        calcToScalar(ObjectIdCpp, ObjectId);

        double CorrelationCpp;
        calcToScalar(CorrelationCpp, Correlation);

        std::string SmileOnStartDateIDCpp;
        calcToScalar(SmileOnStartDateIDCpp, SmileOnStartDateID);

        std::string SmileOnEndDateIDCpp;
        calcToScalar(SmileOnEndDateIDCpp, SmileOnEndDateID);

        bool WithSmileCpp;
        calcToScalar(WithSmileCpp, WithSmile);

        bool ByCallSpreadCpp;
        calcToScalar(ByCallSpreadCpp, ByCallSpread);

        bool PermanentCpp;
        calcToScalar(PermanentCpp, Permanent);

        // convert object IDs into library objects

        OH_GET_REFERENCE(SmileOnStartDateIDLibObjPtr, SmileOnStartDateIDCpp,
            QuantLibAddin::SmileSection, QuantLib::SmileSection)

        OH_GET_REFERENCE(SmileOnEndDateIDLibObjPtr, SmileOnEndDateIDCpp,
            QuantLibAddin::SmileSection, QuantLib::SmileSection)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlRangeAccrualPricerByBgm(
                ObjectIdCpp,
                CorrelationCpp,
                SmileOnStartDateIDCpp,
                SmileOnEndDateIDCpp,
                WithSmileCpp,
                ByCallSpreadCpp,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::RangeAccrualPricerByBgm(
                valueObject,
                CorrelationCpp,
                SmileOnStartDateIDLibObjPtr,
                SmileOnEndDateIDLibObjPtr,
                WithSmileCpp,
                ByCallSpreadCpp,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectIdCpp, object, Overwrite, valueObject);

        // Convert and return the return value



        ANY returnValueCalc;
        scalarToCalc(returnValueCalc, returnValue);

        SEQSEQ(ANY) retAnyArray;
        retAnyArray.realloc(1);
        SEQ(ANY) retAnyVector(1);
        retAnyVector[0] = returnValueCalc;
        retAnyArray[0] = retAnyVector;        
        return retAnyArray;

    } catch (const std::exception &e) {
        do { 
            std::ostringstream errorMsg; 
            errorMsg << "ERROR: qlRangeAccrualPricerByBgm: " << e.what(); 
            OH_LOG_MESSAGE(errorMsg.str());
        
            SEQSEQ(ANY) retAnyArray;
            retAnyArray.realloc(1);
            SEQ(ANY) retAnyVector(1);
            STRING s = STRFROMASCII( errorMsg.str().c_str() );    
            retAnyVector[0] = CSS::uno::makeAny( s );
            retAnyArray[0] = retAnyVector;	    
            return retAnyArray;
        } while (false);
    }
}
示例#6
0
 explicit tuple(T const& sequence)
     : base(object(sequence))
 {
 }
XLL_DEC char *qlEvolutionDescription(
        char *ObjectId,
        OPER *RateTimes,
        OPER *EvolutionTimes,
        OPER *Permanent,
        OPER *Trigger,
        bool *Overwrite) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlEvolutionDescription"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert input datatypes to C++ datatypes

        std::vector<double> RateTimesCpp =
            ObjectHandler::operToVector<double>(*RateTimes, "RateTimes");

        std::vector<double> EvolutionTimesCpp =
            ObjectHandler::operToVector<double>(*EvolutionTimes, "EvolutionTimes");

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            ObjectHandler::ConvertOper(*Permanent), "Permanent", false);

        // Strip the Excel cell update counter suffix from Object IDs
        
        std::string ObjectIdStrip = ObjectHandler::CallingRange::getStub(ObjectId);

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlEvolutionDescription(
                ObjectIdStrip,
                RateTimesCpp,
                EvolutionTimesCpp,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::EvolutionDescription(
                valueObject,
                RateTimesCpp,
                EvolutionTimesCpp,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::RepositoryXL::instance().storeObject(ObjectIdStrip, object, *Overwrite, valueObject);

        // Convert and return the return value

        static char ret[XL_MAX_STR_LEN];
        ObjectHandler::stringToChar(returnValue, ret);
        return ret;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
示例#8
0
DLLEXPORT char *createForwardCurveFX(char *objectID,
                                     OPER *anchorDate,
                                     double spot,
                                     OPER *spotDate,
                                     char *domesticDRSID,
                                     char *foreignDRSID,
                                     bool *stochastic,
                                     char *vrsID,
                                     bool *permanent) 
{
    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;
    static char ret[XL_MAX_STR_LEN];
    try 
    {
        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>
            (new ObjectHandler::FunctionCall("createForwardCurveFX"));

        QuantLib::Date AnchorDateLib = ObjectHandler::convert2<QuantLib::Date>(
            ObjectHandler::ConvertOper(*anchorDate), "AnchorDate");

        QuantLib::Date SpotDateLib = ObjectHandler::convert2<QuantLib::Date>(
            ObjectHandler::ConvertOper(*anchorDate), "SpotDate");

        if (SpotDateLib < AnchorDateLib)
        {
            ObjectHandler::stringToChar("Spot Date cannot preceed Anchor Date", ret);
            return ret;
        }
         
        OH_GET_OBJECT(DomesticDRSIdLibObjPtr, domesticDRSID, sjdObjects::DiscountRateSource)    
        OH_GET_OBJECT(ForeignDRSIdLibObjPtr, foreignDRSID, sjdObjects::DiscountRateSource)    

        // Strip the Excel cell update counter suffix from Object IDs        
        std::string ObjectIdStrip = ObjectHandler::CallingRange::getStub(objectID);
        // Construct the Value Object
        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new sjdObjects::ValueObjects::GenericUnimplementedValueObject(ObjectIdStrip,false));

        std::string returnValue;
        if (!(*stochastic))
        {
            sjdObjects::ForwardRateSourceDeterministic *sfc;                
            sfc = new sjdObjects::ForwardCurveDeterministicFX(valueObject, 
                                                              AnchorDateLib,
                                                              spot, 
                                                              SpotDateLib, 
                                                              DomesticDRSIdLibObjPtr, 
                                                              ForeignDRSIdLibObjPtr, 
                                                              *permanent);
            boost::shared_ptr<ObjectHandler::Object> object(sfc);
            if (!sfc->isOK()) 
            {
                returnValue = sfc->getErrorMessages();
            }
            else 
            {
                returnValue =
                    ObjectHandler::RepositoryXL::instance().storeObject(ObjectIdStrip, object, true);
            }
        }
        else
        {
            sjdObjects::ForwardRateSourceStochastic *sfc;    
              OH_GET_OBJECT(VolIdLibObjPtr, vrsID, sjdObjects::VolatilityRateSource)    
            sfc = new sjdObjects::ForwardCurveStochasticFX(valueObject,
                                                           AnchorDateLib,
                                                           spot, 
                                                           SpotDateLib, 
                                                           DomesticDRSIdLibObjPtr, 
                                                           ForeignDRSIdLibObjPtr, 
                                                           VolIdLibObjPtr,
                                                           *permanent);
            boost::shared_ptr<ObjectHandler::Object> object(sfc);
            if (!sfc->isOK()) 
            {
                returnValue = sfc->getErrorMessages();
            }
            else 
            {
                returnValue =
                    ObjectHandler::RepositoryXL::instance().storeObject(ObjectIdStrip, object, true);
            }
        }
        // Convert and return the return value
        ObjectHandler::stringToChar(returnValue, ret);
        return ret;
    } 
   SJD_XLL_CATCH_STRING()
}
示例#9
0
DLLEXPORT OPER *rollFRSStochastic(char *OutputDRSId, char *InputDRSID, OPER *toDates,  OPER *rvs, bool *permanent) 
{
    // declare a shared pointer to the Function Call object
    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;
    static XLOPER returnValue;
    try 
    {
        // instantiate the Function Call object
        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("rollFRSStochastic"));

        std::vector<QuantLib::Date> datesLib =
            ObjectHandler::operToVector<QuantLib::Date>(*toDates, "Dates");
        if (datesLib.size() == 0)
        {
            ObjectHandler::scalarToOper("No input date(s)", returnValue);        
            return &returnValue;
        }
        std::set<QuantLib::Date> datesSet = std::set<QuantLib::Date>(datesLib.begin(), datesLib.end());
        datesLib = std::vector<QuantLib::Date>(datesSet.begin(), datesSet.end());

        std::vector<double> randomNumbers =
            ObjectHandler::operToVector<double>(*rvs, "Random Numbers");
        if (randomNumbers.size() != datesLib.size())
        {
            ObjectHandler::scalarToOper("Sorted dates without duplicates not the same size as the random number input", returnValue);        
            return &returnValue;
        }

        OH_GET_OBJECT(ObjectIdLibObjPtr, InputDRSID, sjdObjects::ForwardRateSourceStochastic)    
        if (!ObjectIdLibObjPtr->isInRange(datesLib.back()))
        {
            ObjectHandler::scalarToOper("Dates not FRS range", returnValue);        
            return &returnValue;
        }
        if (!ObjectIdLibObjPtr->isOK())
        {
            ObjectHandler::scalarToOper(ObjectIdLibObjPtr->getErrorMessages(), returnValue);        
            return &returnValue;
        }

        std::string ObjectIdStrip = ObjectHandler::CallingRange::getStub(OutputDRSId);
        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new sjdObjects::ValueObjects::GenericUnimplementedValueObject(ObjectIdStrip,false));


        vector<boost::shared_ptr<sjdObjects::ForwardRateSource> > frss = 
            ObjectIdLibObjPtr->rollForward(valueObject, datesSet, randomNumbers, *permanent);
        vector<string> objectNames = vector<string>(frss.size());

        for (size_t i = 0; i < frss.size(); ++i)
        {
            stringstream objDescription;
            objDescription << ObjectIdStrip << "_" << (QuantLib::io::iso_date(datesLib[i]));

            boost::shared_ptr<ObjectHandler::Object> object(frss[i]);
            boost::shared_ptr<sjd::ForwardRateSource> sjdFrs;
            frss[i]->getLibraryObject(sjdFrs);
            std::string returnValue;
            if (!sjdFrs->isOK()) 
            {
                objectNames[i] = sjdFrs->getErrorMessagesAsString();
            }
            else 
            {
                objectNames[i] =
                    ObjectHandler::RepositoryXL::instance().storeObject(objDescription.str(), object, true);
            }
        }
        ObjectHandler::vectorToOper(objectNames, returnValue);
        return &returnValue;
    }
   SJD_XLL_CATCH_OPER()
}
u32 CScriptGameObject::Money	()
{
	CInventoryOwner* pOurOwner		= smart_cast<CInventoryOwner*>(&object()); VERIFY(pOurOwner);
	return pOurOwner->get_money();
}
int	CScriptGameObject::GetAttitude			(CScriptGameObject* pToWho)
{
	CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object());VERIFY(pInventoryOwner);
	CInventoryOwner* pOthersInventoryOwner = smart_cast<CInventoryOwner*>(&pToWho->object());VERIFY(pOthersInventoryOwner);
	return RELATION_REGISTRY().GetAttitude(pInventoryOwner, pOthersInventoryOwner);
}
bool CScriptGameObject::IsInvUpgradeEnabled		()
{
	CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object());
	if(!pInventoryOwner) return false;
	return pInventoryOwner->IsInvUpgradeEnabled();
}
void CScriptGameObject::DisableInvUpgrade		()
{
	CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object());
	if(!pInventoryOwner) return;
	pInventoryOwner->DisableInvUpgrade();
}
void CScriptGameObject::EnableTrade			()
{
	CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object());
	if(!pInventoryOwner) return;
	pInventoryOwner->EnableTrade();
}
示例#15
0
XLL_DEC char *qlDaAsianOption(
        char *ObjectId,
        char *AverageType,
        double *RunningAccumulator,
        long *PastFixings,
        OPER *FixingDates,
        char *Payoff,
        char *Exercise,
        OPER *Permanent,
        OPER *Trigger,
        bool *Overwrite) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlDaAsianOption"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert input datatypes to C++ datatypes

        std::vector<ObjectHandler::property_t> FixingDatesCpp =
            ObjectHandler::operToVector<ObjectHandler::property_t>(*FixingDates, "FixingDates");

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            ObjectHandler::ConvertOper(*Permanent), "Permanent", false);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Size PastFixingsLib;
        QuantLibAddin::cppToLibrary(*PastFixings, PastFixingsLib);

        std::vector<QuantLib::Date> FixingDatesLib =
            ObjectHandler::operToVector<QuantLib::Date>(*FixingDates, "FixingDates");

        // convert input datatypes to QuantLib enumerated datatypes

        QuantLib::Average::Type AverageTypeEnum =
            ObjectHandler::Create<QuantLib::Average::Type>()(AverageType);

        // convert object IDs into library objects

        OH_GET_REFERENCE(PayoffLibObjPtr, Payoff,
            QuantLibAddin::StrikedTypePayoff, QuantLib::StrikedTypePayoff)

        OH_GET_REFERENCE(ExerciseLibObjPtr, Exercise,
            QuantLibAddin::Exercise, QuantLib::Exercise)

        // Strip the Excel cell update counter suffix from Object IDs
        
        std::string ObjectIdStrip = ObjectHandler::CallingRange::getStub(ObjectId);
        std::string PayoffStrip = ObjectHandler::CallingRange::getStub(Payoff);
        std::string ExerciseStrip = ObjectHandler::CallingRange::getStub(Exercise);

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlDaAsianOption(
                ObjectIdStrip,
                AverageType,
                *RunningAccumulator,
                *PastFixings,
                FixingDatesCpp,
                PayoffStrip,
                ExerciseStrip,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::DiscreteAveragingAsianOption(
                valueObject,
                AverageTypeEnum,
                *RunningAccumulator,
                PastFixingsLib,
                FixingDatesLib,
                PayoffLibObjPtr,
                ExerciseLibObjPtr,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::RepositoryXL::instance().storeObject(ObjectIdStrip, object, *Overwrite, valueObject);

        // Convert and return the return value

        static char ret[XL_MAX_STR_LEN];
        ObjectHandler::stringToChar(returnValue, ret);
        return ret;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
示例#16
0
/*======================================================================================
Create an instance of the object sjdObjects::ForwardCurveStochasticFwdVol and return 
its ID
=======================================================================================*/
DLLEXPORT char *createForwardCurve(char *objectID,
                                   OPER *anchorDate,
                                   OPER *dates,
                                   OPER *futures,
                                   OPER *interpolation,
                                   bool *cma,
                                   bool *stochastic,
                                   char *vrsID,
                                   bool *useSpotVol,
                                   bool *permanent) 
{

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;
    static char ret[XL_MAX_STR_LEN];
    try 
    {
        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>
            (new ObjectHandler::FunctionCall("createForwardCurve"));

        QuantLib::Date AnchorDateLib = ObjectHandler::convert2<QuantLib::Date>(
            ObjectHandler::ConvertOper(*anchorDate), "AnchorDate");

        std::vector<QuantLib::Date> CurveDatesLib =
            ObjectHandler::operToVector<QuantLib::Date>(*dates, "CurveDates");

        std::vector<double> FuturesCpp =
            ObjectHandler::operToVector<double>(*futures, "Futures");

        std::string InterpolationType = ObjectHandler::convert2<std::string>(
            ObjectHandler::ConvertOper(*interpolation), "Interpolation");
        sjd::ArrayInterpolatorType sjdType; // = sjd::LINEAR;
        boost::to_lower(InterpolationType);
        boost::trim(InterpolationType);
        if (InterpolationType.compare("linear") == 0) 
        {
            sjdType = sjd::LINEAR;
        }
        else if (InterpolationType.compare("cubic") == 0) 
        {
            sjdType = sjd::CUBIC;
        }
        else 
        {
            ObjectHandler::stringToChar("Interpolator type must be either LINEAR or CUBIC", ret);
            return ret;
        }
        // Strip the Excel cell update counter suffix from Object IDs        
        std::string ObjectIdStrip = ObjectHandler::CallingRange::getStub(objectID);
        // Construct the Value Object
        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new sjdObjects::ValueObjects::GenericUnimplementedValueObject(ObjectIdStrip,false));

        std::string returnValue;
        if (!(*stochastic))
        {
            sjdObjects::ForwardRateSourceDeterministic *sfc;                
            if (!(*cma))
            {
                sfc = new sjdObjects::ForwardCurveDeterministic(valueObject, 
                                                                AnchorDateLib,
                                                                CurveDatesLib, 
                                                                FuturesCpp, 
                                                                sjdType, 
                                                                false, 
                                                                *permanent);
            }
            else 
            {
                sfc = new sjdObjects::ForwardCurveCMADeterministic(valueObject,
                                                                   AnchorDateLib,
                                                                   CurveDatesLib,
                                                                   FuturesCpp,
                                                                   sjdType,
                                                                   false,
                                                                   *permanent);
            }
            boost::shared_ptr<ObjectHandler::Object> object(sfc);
            if (!sfc->isOK()) 
            {
                returnValue = sfc->getErrorMessages();
            }
            else 
            {
                returnValue =
                    ObjectHandler::RepositoryXL::instance().storeObject(ObjectIdStrip, object, true);
            }
        }
        else
        {
            sjdObjects::ForwardRateSourceStochastic *sfc;    
              OH_GET_OBJECT(ObjectIdLibObjPtr, vrsID, sjdObjects::VolatilityRateSource)    
            if (!ObjectIdLibObjPtr->isOK())
            {
                ObjectHandler::stringToChar(ObjectIdLibObjPtr->getErrorMessages(), ret);
                return ret;
            }

            if (*cma)
            {
                if (!(*useSpotVol))
                {
                    sfc = new sjdObjects::ForwardCurveCMAStochastic(valueObject,
                                                                   AnchorDateLib,
                                                                   CurveDatesLib,
                                                                   FuturesCpp,
                                                                   sjdType,
                                                                   false,
                                                                   ObjectIdLibObjPtr,
                                                                   *permanent);
                }
                else 
                {
                    ObjectHandler::stringToChar(returnValue, "Not jet implemenented");
                    return ret;
                }
            }
            else 
            {
                if (!(*useSpotVol))
                {
                    sfc = new sjdObjects::ForwardCurveStochasticFwdVol(valueObject,
                                                                       AnchorDateLib,
                                                                       CurveDatesLib,
                                                                       FuturesCpp,
                                                                       sjdType,
                                                                       false,
                                                                       ObjectIdLibObjPtr,
                                                                       *permanent);
                }
                else 
                {
                    sfc = new sjdObjects::ForwardCurveStochasticSpotVol(valueObject,
                                                                        AnchorDateLib,
                                                                        CurveDatesLib,
                                                                        FuturesCpp,
                                                                        sjdType,
                                                                        false,
                                                                        ObjectIdLibObjPtr,
                                                                        *permanent);
                }
            }
            boost::shared_ptr<ObjectHandler::Object> object(sfc);
            if (!sfc->isOK()) 
            {
                returnValue = sfc->getErrorMessages();
            }
            else 
            {
                returnValue =
                    ObjectHandler::RepositoryXL::instance().storeObject(ObjectIdStrip, object, true);
            }
        }
        // Convert and return the return value
        ObjectHandler::stringToChar(returnValue, ret);
        return ret;
    } 
   SJD_XLL_CATCH_STRING()
}
示例#17
0
XLL_DEC char *qlQuantoVanillaOption(
        char *ObjectId,
        char *Payoff,
        char *Exercise,
        OPER *Permanent,
        OPER *Trigger,
        bool *Overwrite) {

    // declare a shared pointer to the Function Call object

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall;

    try {

        // instantiate the Function Call object

        functionCall = boost::shared_ptr<ObjectHandler::FunctionCall>(
            new ObjectHandler::FunctionCall("qlQuantoVanillaOption"));

        ObjectHandler::validateRange(Trigger, "Trigger");

        // initialize the session ID (if enabled)

        SET_SESSION_ID

        // convert input datatypes to C++ datatypes

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            ObjectHandler::ConvertOper(*Permanent), "Permanent", false);

        // convert object IDs into library objects

        OH_GET_REFERENCE(PayoffLibObjPtr, Payoff,
            QuantLibAddin::StrikedTypePayoff, QuantLib::StrikedTypePayoff)

        OH_GET_REFERENCE(ExerciseLibObjPtr, Exercise,
            QuantLibAddin::Exercise, QuantLib::Exercise)

        // Strip the Excel cell update counter suffix from Object IDs
        
        std::string ObjectIdStrip = ObjectHandler::CallingRange::getStub(ObjectId);
        std::string PayoffStrip = ObjectHandler::CallingRange::getStub(Payoff);
        std::string ExerciseStrip = ObjectHandler::CallingRange::getStub(Exercise);

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlQuantoVanillaOption(
                ObjectIdStrip,
                PayoffStrip,
                ExerciseStrip,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::QuantoVanillaOption(
                valueObject,
                PayoffLibObjPtr,
                ExerciseLibObjPtr,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::RepositoryXL::instance().storeObject(ObjectIdStrip, object, *Overwrite, valueObject);

        // Convert and return the return value

        static char ret[XL_MAX_STR_LEN];
        ObjectHandler::stringToChar(returnValue, ret);
        return ret;

    } catch (const std::exception &e) {
        ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall);
        return 0;
    } catch (...) {
        ObjectHandler::RepositoryXL::instance().logError("unkown error type", functionCall);
        return 0;
    }

}
示例#18
0
    std::string qlVanillaSwap(
            const std::string &ObjectId,
            const ObjectHandler::property_t &PayerReceiver,
            const ObjectHandler::property_t &Nominal,
            const std::string &FixSchedule,
            const ObjectHandler::property_t &FixedRate,
            const std::string &FixDayCounter,
            const std::string &FloatingLegSchedule,
            const std::string &IborIndex,
            const ObjectHandler::property_t &Spread,
            const std::string &FloatingLegDayCounter,
            const ObjectHandler::property_t &PaymentConvention,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        std::string PayerReceiverCpp = ObjectHandler::convert2<std::string>(
            PayerReceiver, "PayerReceiver", "Payer");

        double NominalCpp = ObjectHandler::convert2<double>(
            Nominal, "Nominal", 100);

        double FixedRateCpp = ObjectHandler::convert2<double>(
            FixedRate, "FixedRate", 0.0);

        double SpreadCpp = ObjectHandler::convert2<double>(
            Spread, "Spread", 0.0);

        std::string PaymentConventionCpp = ObjectHandler::convert2<std::string>(
            PaymentConvention, "PaymentConvention", "Following");

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert input datatypes to QuantLib enumerated datatypes

        QuantLib::VanillaSwap::Type PayerReceiverEnum =
            ObjectHandler::Create<QuantLib::VanillaSwap::Type>()(PayerReceiverCpp);

        QuantLib::DayCounter FixDayCounterEnum =
            ObjectHandler::Create<QuantLib::DayCounter>()(FixDayCounter);

        QuantLib::DayCounter FloatingLegDayCounterEnum =
            ObjectHandler::Create<QuantLib::DayCounter>()(FloatingLegDayCounter);

        QuantLib::BusinessDayConvention PaymentConventionEnum =
            ObjectHandler::Create<QuantLib::BusinessDayConvention>()(PaymentConventionCpp);

        // convert object IDs into library objects

        OH_GET_REFERENCE(FixScheduleLibObjPtr, FixSchedule,
            QuantLibAddin::Schedule, QuantLib::Schedule)

        OH_GET_REFERENCE(FloatingLegScheduleLibObjPtr, FloatingLegSchedule,
            QuantLibAddin::Schedule, QuantLib::Schedule)

        OH_GET_REFERENCE(IborIndexLibObjPtr, IborIndex,
            QuantLibAddin::IborIndex, QuantLib::IborIndex)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlVanillaSwap(
                ObjectId,
                PayerReceiverCpp,
                NominalCpp,
                FixSchedule,
                FixedRateCpp,
                FixDayCounter,
                FloatingLegSchedule,
                IborIndex,
                SpreadCpp,
                FloatingLegDayCounter,
                PaymentConventionCpp,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::VanillaSwap(
                valueObject,
                PayerReceiverEnum,
                NominalCpp,
                FixScheduleLibObjPtr,
                FixedRateCpp,
                FixDayCounterEnum,
                FloatingLegScheduleLibObjPtr,
                IborIndexLibObjPtr,
                SpreadCpp,
                FloatingLegDayCounterEnum,
                PaymentConventionEnum,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite, valueObject);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function qlVanillaSwap : " << e.what());
        }
    }
示例#19
0
//------------------------------------------------------------------------------
// isPlayerStateUpdateRequired() -- check to see if an update is required
//------------------------------------------------------------------------------
bool Nib::isPlayerStateUpdateRequired(const double curExecTime)
{
   enum { NO, YES, UNSURE } result = UNSURE;

   // ---
   // 1) Make sure that we have a valid player and entity type
   // ---
   const models::Player* player = getPlayer();
   if (player == nullptr || isEntityTypeInvalid()) result = NO;

   // ---
   // 2) Mode changes
   // ---
   if ( (result == UNSURE) && isNotMode( player->getMode()) ) result = YES;

   // 2-a) NIB is being deleted, send one more update to deactivate the entity
   if ( (result == UNSURE) && isMode( models::Player::DELETE_REQUEST ) ) result = YES;

   // ---
   // 3) When we're a local player, check for one of the following ...
   // ---
   if ( (result == UNSURE) && player->isLocalPlayer()) {

      //double drTime = curExecTime - getTimeExec();
      models::SynchronizedState playerState = player->getSynchronizedState();
      const double drTime = static_cast<double>(playerState.getTimeExec()) - getTimeExec();

      // 3-a) Freeze flag has changed
      if ( (player->isFrozen() && isNotFrozen()) || (!player->isFrozen() && isFrozen()) ) {
         result = YES;
      }

      // 3-b) Max DR timeout
      if (result == UNSURE) {
         if ( drTime >= getNetIO()->getMaxTimeDR(this) ) {
            result = YES;
         }
      }

      // 3-c) Appearance has changed
      if (result == UNSURE &&
         (player->getDamage() != getDamage() ||
         player->getSmoke()  != getSmoke()   ||
         player->getFlames() != getFlames() ||
         player->getCamouflageType() != getCamouflageType() )
         ) {
            result = YES;
      }

      // 3-d) Check dead reckoning errors
      if (result == UNSURE && isNotFrozen()) {

         // Compute our dead reckoned position and angles, which are
         // based on our last packet sent.
         base::Vec3d drPos;
         base::Vec3d drAngles;
         mainDeadReckoning(drTime, &drPos, &drAngles);

         // 3-d-1) Position error
         if (!player->isPositionFrozen() && !player->isAltitudeFrozen()) {

            // max position error (meters)
            const double maxPosErr = getNetIO()->getMaxPositionErr(this);
            const double maxPosErr2 = maxPosErr*maxPosErr;  // squared

            // Check if the length of the position error (squared) is greater
            // than the max error (squared)
            //base::Vec3d ppos = player->getGeocPosition();
            const base::Vec3d ppos = playerState.getGeocPosition();
            const base::Vec3d errPos = drPos - ppos;
            if (errPos.length2() >= maxPosErr2) {
               result = YES;
            }
         }

         // 3-d-2) Orientation error
         if (result == UNSURE && !player->isAttitudeFrozen()) {

            // max angle error (radians)
            const double maxAngleErr = getNetIO()->getMaxOrientationErr(this);

            // Compute angular error
            //base::Vec3 errAngles = drAngles - player->getGeocEulerAngles();
            base::Vec3d errAngles = drAngles - playerState.getGeocEulerAngles();

            // Check if any angle error is greater than the max error
            errAngles[0] = std::fabs( base::angle::aepcdDeg(errAngles[0]) );
            if (errAngles[0] >= maxAngleErr) result = YES;

            errAngles[1] = std::fabs( base::angle::aepcdDeg(errAngles[1]) );
            if (errAngles[1] >= maxAngleErr) result = YES;

            errAngles[2] = std::fabs( base::angle::aepcdDeg(errAngles[2]) );
            if (errAngles[2] >= maxAngleErr) result = YES;
         }
      }
   }

   // ---
   // 4) Check for air vehicle articulated and attached parts (always check this)
   // ---
   if ( player != nullptr && player->isMajorType(models::Player::AIR_VEHICLE) ) {

      const models::AirVehicle* av = static_cast<const models::AirVehicle*>(player);

      // (4-a) Check wing sweep angle.  We only send out wing sweep as
      // an part if the position is greater than zero or if we've previously been
      // sending the wing sweep (count > 0).
      {
         const double angle = av->getWingSweepAngle();  //  radians
         if (angle > 0 || apartWingSweepCnt > 0) {
            // Check if the angle has changed.
            if (angle != apartWingSweep) {
               apartWingSweep = angle;
               apartWingSweepCnt++;
               result = YES;
            }
         }
      }

      // (4-b) Check landing gear position.  We only send out gear position as
      // an part if the gear is not up (pos != 0) or if we've previously been
      // sending the gear position (count > 0).
      {
         const double pos = av->getLandingGearPosition(); // (0% up; 100% down)
         if (pos > 0 || apartGearPosCnt > 0) {
            // Check if the pos has changed.
            if (pos != apartLandingGear) {
               apartLandingGear = pos;
               apartGearPosCnt++;
               result = YES;
            }
         }
      }

      // (4-c) Check bay door position.  We only send out bay door posiiton as
      // an part if the door is not closed (pos != 0) or if we've previously been
      // sending the door position (count > 0).
      {
         const double pos = av->getWeaponBayDoorPosition(); // % (0% closed; 100% open)
         if (pos > 0 || apartBayDoorCnt > 0) {
            // Check if the pos has changed.
            if (pos != apartBayDoor) {
               apartBayDoor = pos;
               apartBayDoorCnt++;
               result = YES;
            }
         }
      }

   }

   // ---
   // 5) Check for ground vehicle articulated and attached parts (always check this)
   // ---
   if ( player != nullptr && player->isMajorType(models::Player::GROUND_VEHICLE) ) {

      const models::GroundVehicle* gv = static_cast<const models::GroundVehicle*>(player);

      // (5-a) Send launcher elevation angle and for an attached missile
      //       (on SamVehicles and Artillery only)
      if ( gv->isClassType(typeid(models::SamVehicle)) || gv->isClassType(typeid(models::Artillery)) ) {

         const double angle = gv->getLauncherPosition();  //  (radians)

         // First pass --
         if (apartLnchrElevCnt == 0) {

            // find all missiles missiles
            const models::StoresMgr* sm = gv->getStoresManagement();
            if (sm != nullptr) {
               const base::PairStream* stores = sm->getStores();
               if (stores != nullptr) {
                  const base::List::Item* item = stores->getFirstItem();
                  while (item != nullptr && apartNumMissiles < MAX_AMSL) {
                     const auto pair = static_cast<const base::Pair*>(item->getValue());
                     if (pair != nullptr) {
                        const auto msl = dynamic_cast<const models::Missile*>( pair->object() );
                        if (msl != nullptr) {
                           // Save the pointer to the missile, set the missile's change count to 1,
                           // and up the missile count
                           msl->ref();
                           apartMsl[apartNumMissiles] = msl;
                           apartMslAttached[apartNumMissiles] = !(msl->isMode(models::Player::LAUNCHED));
                           apartMslCnt[apartNumMissiles] = 1;
                           apartNumMissiles++;
                        }
                     }
                     item = item->getNext();
                  }
                  stores->unref();
                  stores = nullptr;
               }

            }

            // If we have missile then set the launcher angle
            if (apartNumMissiles > 0) {
               apartLnchrElev = angle;
               apartLnchrElevCnt++;
            }
         }

         // If we have the launcher angle and missiles then check for changes
         if (apartLnchrElevCnt != 0) {

            // Check if the pos has changed
            if (angle != apartLnchrElev) {
               apartLnchrElev = angle;
               apartLnchrElevCnt++;
               result = YES;
            }

            // Check all missiles for change in launched status
            for (unsigned int i = 0; i < apartNumMissiles; i++) {
               bool attached = !(apartMsl[i]->isMode(models::Player::LAUNCHED));
               if (attached != apartMslAttached[i]) {
                  // There's been a change in status
                  apartMslAttached[i] = attached;
                  apartMslCnt[i]++;
               }
            }

         }

      }

   }

   // ---
   // 6) When we're a network player -- Update when the exec time of the
   //    last input (player's NIB) is different that our exec time.
   // ---
   if ( (result == UNSURE) && player->isNetworkedPlayer() ) {
      const auto playerNib = dynamic_cast<const Nib*>(player->getNib());
      if (playerNib->getTimeExec() != getTimeExec()) {
         result = YES;
      }
   }

   return (result == YES);
}
示例#20
0
    std::string qlMakeIMMSwap(
            const std::string &ObjectId,
            const std::string &SwapTenor,
            const std::string &IborIndex,
            const ObjectHandler::property_t &FixedRate,
            const ObjectHandler::property_t &FirstImmDate,
            const ObjectHandler::property_t &FixDayCounter,
            const ObjectHandler::property_t &Spread,
            const std::string &PricingEngineID,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        double FixedRateCpp = ObjectHandler::convert2<double>(
            FixedRate, "FixedRate", QuantLib::Null<QuantLib::Rate>());

        std::string FixDayCounterCpp = ObjectHandler::convert2<std::string>(
            FixDayCounter, "FixDayCounter", "30/360 (Bond Basis)");

        double SpreadCpp = ObjectHandler::convert2<double>(
            Spread, "Spread", 0.0);

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Period SwapTenorLib;
        QuantLibAddin::cppToLibrary(SwapTenor, SwapTenorLib);

        QuantLib::Date FirstImmDateLib = ObjectHandler::convert2<QuantLib::Date>(
            FirstImmDate, "FirstImmDate", QuantLib::Date());

        // convert input datatypes to QuantLib enumerated datatypes

        QuantLib::DayCounter FixDayCounterEnum =
            ObjectHandler::Create<QuantLib::DayCounter>()(FixDayCounterCpp);

        // convert object IDs into library objects

        OH_GET_REFERENCE(IborIndexLibObjPtr, IborIndex,
            QuantLibAddin::IborIndex, QuantLib::IborIndex)

        OH_GET_REFERENCE(PricingEngineIDLibObjPtr, PricingEngineID,
            QuantLibAddin::PricingEngine, QuantLib::PricingEngine)

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlMakeIMMSwap(
                ObjectId,
                SwapTenor,
                IborIndex,
                FixedRateCpp,
                FirstImmDate,
                FixDayCounterCpp,
                SpreadCpp,
                PricingEngineID,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::VanillaSwap(
                valueObject,
                SwapTenorLib,
                IborIndexLibObjPtr,
                FixedRateCpp,
                FirstImmDateLib,
                FixDayCounterEnum,
                SpreadCpp,
                PricingEngineIDLibObjPtr,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite, valueObject);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function qlMakeIMMSwap : " << e.what());
        }
    }
示例#21
0
object list_base::pop(ssize_t index)
{
    return this->pop(object(index));
}
void ShadowReceiverDrawable::draw(const Matrix4& transformationMatrix, SceneGraph::Camera3D& camera) {
    _shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix);
    _shader->setModelMatrix(object().transformationMatrix());

    _mesh->draw(*_shader);
}
示例#23
0
SEQSEQ(ANY) SAL_CALL CalcAddins_impl::qlRangeAccrualFloatersCoupon(
        const ANY &ObjectId,
        const ANY &Nominal,
        const ANY &PaymentDate,
        const ANY &IborIndex,
        const ANY &StartDate,
        const ANY &EndDate,
        const ANY &FixingDays,
        const ANY &DayCountID,
        const ANY &Gearings,
        const ANY &Spreads,
        const ANY &RefPeriodStart,
        const ANY &RefPeriodEnd,
        const ANY &ObserSchedID,
        const ANY &LowerTrigger,
        const ANY &UpperTrigger,
        const sal_Int32 Permanent,
        const ANY &Trigger,
        const sal_Int32 Overwrite) throw(RuntimeException) {
    try {

        // convert input datatypes to C++ datatypes

        std::string ObjectIdCpp;
        calcToScalar(ObjectIdCpp, ObjectId);

        double NominalCpp;
        calcToScalar(NominalCpp, Nominal);

        ObjectHandler::property_t PaymentDateCpp;
        calcToScalar(PaymentDateCpp, PaymentDate);

        std::string IborIndexCpp;
        calcToScalar(IborIndexCpp, IborIndex);

        ObjectHandler::property_t StartDateCpp;
        calcToScalar(StartDateCpp, StartDate);

        ObjectHandler::property_t EndDateCpp;
        calcToScalar(EndDateCpp, EndDate);

        long FixingDaysCpp;
        calcToScalar(FixingDaysCpp, FixingDays);

        std::string DayCountIDCpp;
        calcToScalar(DayCountIDCpp, DayCountID);

        double GearingsCpp;
        calcToScalar(GearingsCpp, Gearings);

        double SpreadsCpp;
        calcToScalar(SpreadsCpp, Spreads);

        ObjectHandler::property_t RefPeriodStartCpp;
        calcToScalar(RefPeriodStartCpp, RefPeriodStart);

        ObjectHandler::property_t RefPeriodEndCpp;
        calcToScalar(RefPeriodEndCpp, RefPeriodEnd);

        std::string ObserSchedIDCpp;
        calcToScalar(ObserSchedIDCpp, ObserSchedID);

        double LowerTriggerCpp;
        calcToScalar(LowerTriggerCpp, LowerTrigger);

        double UpperTriggerCpp;
        calcToScalar(UpperTriggerCpp, UpperTrigger);

        bool PermanentCpp;
        calcToScalar(PermanentCpp, Permanent);

        // convert input datatypes to QuantLib datatypes

        QuantLib::Date PaymentDateLib;
        calcToScalar(PaymentDateLib, PaymentDate);

        QuantLib::Date StartDateLib;
        calcToScalar(StartDateLib, StartDate);

        QuantLib::Date EndDateLib;
        calcToScalar(EndDateLib, EndDate);

        QuantLib::Date RefPeriodStartLib;
        calcToScalar(RefPeriodStartLib, RefPeriodStart);

        QuantLib::Date RefPeriodEndLib;
        calcToScalar(RefPeriodEndLib, RefPeriodEnd);

        // convert object IDs into library objects

        OH_GET_REFERENCE(IborIndexLibObjPtr, IborIndexCpp,
            QuantLibAddin::IborIndex, QuantLib::IborIndex)

        OH_GET_REFERENCE(ObserSchedIDLibObjPtr, ObserSchedIDCpp,
            QuantLibAddin::Schedule, QuantLib::Schedule)

        // convert input datatypes to QuantLib enumerated datatypes

        QuantLib::DayCounter DayCountIDEnum =
            ObjectHandler::Create<QuantLib::DayCounter>()(DayCountIDCpp);

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::qlRangeAccrualFloatersCoupon(
                ObjectIdCpp,
                NominalCpp,
                PaymentDateCpp,
                IborIndexCpp,
                StartDateCpp,
                EndDateCpp,
                FixingDaysCpp,
                DayCountIDCpp,
                GearingsCpp,
                SpreadsCpp,
                RefPeriodStartCpp,
                RefPeriodEndCpp,
                ObserSchedIDCpp,
                LowerTriggerCpp,
                UpperTriggerCpp,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::RangeAccrualFloatersCoupon(
                valueObject,
                NominalCpp,
                PaymentDateLib,
                IborIndexLibObjPtr,
                StartDateLib,
                EndDateLib,
                FixingDaysCpp,
                DayCountIDEnum,
                GearingsCpp,
                SpreadsCpp,
                RefPeriodStartLib,
                RefPeriodEndLib,
                ObserSchedIDLibObjPtr,
                LowerTriggerCpp,
                UpperTriggerCpp,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectIdCpp, object, Overwrite, valueObject);

        // Convert and return the return value



        ANY returnValueCalc;
        scalarToCalc(returnValueCalc, returnValue);

        SEQSEQ(ANY) retAnyArray;
        retAnyArray.realloc(1);
        SEQ(ANY) retAnyVector(1);
        retAnyVector[0] = returnValueCalc;
        retAnyArray[0] = retAnyVector;        
        return retAnyArray;

    } catch (const std::exception &e) {
        do { 
            std::ostringstream errorMsg; 
            errorMsg << "ERROR: qlRangeAccrualFloatersCoupon: " << e.what(); 
            OH_LOG_MESSAGE(errorMsg.str());
        
            SEQSEQ(ANY) retAnyArray;
            retAnyArray.realloc(1);
            SEQ(ANY) retAnyVector(1);
            STRING s = STRFROMASCII( errorMsg.str().c_str() );    
            retAnyVector[0] = CSS::uno::makeAny( s );
            retAnyArray[0] = retAnyVector;	    
            return retAnyArray;
        } while (false);
    }
}
示例#24
0
    std::string CALCmsMarket(
            const std::string &ObjectId,
            const std::vector<ObjectHandler::property_t>& SwapLengths,
            const std::vector<std::string>& SwapIndexes,
            const std::string &IborIndex,
            const std::vector<std::vector <ObjectHandler::property_t> >& BidAskSpreads,
            const std::vector<std::string>& CmsCouponPricers,
            const std::string &YieldCurve,
            const ObjectHandler::property_t &Permanent,
            const ObjectHandler::property_t &Trigger,
            const bool &Overwrite) {

        try {

        // convert input datatypes to C++ datatypes

        bool PermanentCpp = ObjectHandler::convert2<bool>(
            Permanent, "Permanent", false);

        // convert input datatypes to QuantLib datatypes

        std::vector<QuantLib::Period> SwapLengthsLib =
            ObjectHandler::vector::convert2<QuantLib::Period>(SwapLengths, "SwapLengths");

        // convert object IDs into library objects

        std::vector<boost::shared_ptr<QuantLib::SwapIndex> > SwapIndexesLibObjPtr =
            ObjectHandler::getLibraryObjectVector<QuantLibAddin::SwapIndex, QuantLib::SwapIndex>(SwapIndexes);

        OH_GET_REFERENCE(IborIndexLibObjPtr, IborIndex,
            QuantLibAddin::IborIndex, QuantLib::IborIndex)

        std::vector<std::vector<QuantLib::Handle<QuantLib::Quote> > > BidAskSpreadsLibObj =
            ObjectHandler::matrix::convert2<QuantLib::Handle<QuantLib::Quote> >(BidAskSpreads, "BidAskSpreads");

        std::vector<boost::shared_ptr<QuantLib::CmsCouponPricer> > CmsCouponPricersLibObjPtr =
            ObjectHandler::getLibraryObjectVector<QuantLibAddin::CmsCouponPricer, QuantLib::CmsCouponPricer>(CmsCouponPricers);

        OH_GET_OBJECT(YieldCurveCoerce, YieldCurve, ObjectHandler::Object)
        QuantLib::Handle<QuantLib::YieldTermStructure> YieldCurveLibObj =
            QuantLibAddin::CoerceHandle<
                QuantLibAddin::YieldTermStructure,
                QuantLib::YieldTermStructure>()(
                    YieldCurveCoerce);

        // Construct the Value Object

        boost::shared_ptr<ObjectHandler::ValueObject> valueObject(
            new QuantLibAddin::ValueObjects::CALCmsMarket(
                ObjectId,
                SwapLengths,
                SwapIndexes,
                IborIndex,
                BidAskSpreads,
                CmsCouponPricers,
                YieldCurve,
                PermanentCpp));

        // Construct the Object
        
        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::CmsMarket(
                valueObject,
                SwapLengthsLib,
                SwapIndexesLibObjPtr,
                IborIndexLibObjPtr,
                BidAskSpreadsLibObj,
                CmsCouponPricersLibObjPtr,
                YieldCurveLibObj,
                PermanentCpp));

        // Store the Object in the Repository

        std::string returnValue =
            ObjectHandler::Repository::instance().storeObject(ObjectId, object, Overwrite);

        // Convert and return the return value

        return returnValue;

        } catch (const std::exception &e) {
            OH_FAIL("Error in function CALCmsMarket : " << e.what());
        }
    }
示例#25
0
bool TmxObjectGroup2D::Load(const XMLElement& element, const TileMapInfo2D& info)
{
    LoadInfo(element);

    for (XMLElement objectElem = element.GetChild("object"); objectElem; objectElem = objectElem.GetNext("object"))
    {
        SharedPtr<TileMapObject2D> object(new TileMapObject2D());

        if (objectElem.HasAttribute("name"))
            object->name_ = objectElem.GetAttribute("name");
        if (objectElem.HasAttribute("type"))
            object->type_ = objectElem.GetAttribute("type");

        Vector2 position(objectElem.GetFloat("x"), objectElem.GetFloat("y"));

        if (objectElem.HasAttribute("width") || objectElem.HasAttribute("height"))
        {
            if (!objectElem.HasChild("ellipse"))
                object->objectType_ = OT_RECTANGLE;
            else
                object->objectType_ = OT_ELLIPSE;

            Vector2 size(objectElem.GetFloat("width"), objectElem.GetFloat("height"));

            object->position_ = info.ConvertPosition(Vector2(position.x_, position.y_ + size.y_));
            object->size_ = Vector2(size.x_ * PIXEL_SIZE, size.y_ * PIXEL_SIZE);
        }
        else if (objectElem.HasAttribute("gid"))
        {
            object->objectType_ = OT_TILE;
            object->position_ = info.ConvertPosition(position);
            object->gid_ = objectElem.GetInt("gid");
            object->sprite_ = tmxFile_->GetTileSprite(object->gid_);
        }
        else
        {
            Vector<String> points;

            if (objectElem.HasChild("polygon"))
            {
                object->objectType_ = OT_POLYGON;

                XMLElement polygonElem = objectElem.GetChild("polygon");
                points = polygonElem.GetAttribute("points").Split(' ');
            }
            else if (objectElem.HasChild("polyline"))
            {
                object->objectType_ = OT_POLYLINE;

                XMLElement polylineElem = objectElem.GetChild("polyline");
                points = polylineElem.GetAttribute("points").Split(' ');
            }
            else
                return false;

            if (points.Size() <= 1)
                continue;

            object->points_.Resize(points.Size());

            for (unsigned i = 0; i < points.Size(); ++i)
            {
                points[i].Replace(',', ' ');
                Vector2 point = position + ToVector2(points[i]);
                object->points_[i] = info.ConvertPosition(point);
            }
        }

        if (objectElem.HasChild("properties"))
        {
            object->propertySet_ = new PropertySet2D();
            object->propertySet_->Load(objectElem.GetChild("properties"));
        }

        objects_.Push(object);
    }

    if (element.HasChild("properties"))
        LoadPropertySet(element.GetChild("properties"));

    return true;
}
示例#26
0
 value perform(T *ptr) {
   if (!ptr)
     return object();
   return *static_cast<object const *>(ptr);
 }
示例#27
0
 forceinline const T&
 SharedArray<T>::operator [](int i) const {
   assert(object() != NULL);
   return (*static_cast<SAO*>(object()))[i];
 }
示例#28
0
std::pair <bool,bool> OBJECTLOADER::ContinueObjectLoad(	TRACK* track, 
	std::map <std::string, MODEL_JOE03> & model_library,
	std::map <std::string, TEXTURE_GL> & texture_library,
	std::list <TRACK_OBJECT> & objects,
 	const std::string & texture_size)
{
	std::string model_name;

	if (error)
		return std::pair <bool,bool> (true, false);

	if (!(GetParam(objectfile, model_name)))
	{
		info_output << "Track loaded: " << model_library.size() << " models, " << texture_library.size() << " textures, " << /*surfaces.size() << " surfaces" << */std::endl;
		return std::pair <bool,bool> (false, false);
	}

	assert(objectfile.good());

	std::string diffuse_texture_name;
	bool mipmap;
	bool nolighting;
	bool skybox;
	int transparent_blend;
	float bump_wavelength;
	float bump_amplitude;
	bool driveable;
	bool collideable;
	float friction_notread;
	float friction_tread;
	float rolling_resistance;
	float rolling_drag;
	bool isashadow(false);
	int clamptexture(0);
	int surface_type(2);

	std::string otherjunk;

	GetParam(objectfile, diffuse_texture_name);
	GetParam(objectfile, mipmap);
	GetParam(objectfile, nolighting);
	GetParam(objectfile, skybox);
	GetParam(objectfile, transparent_blend);
	GetParam(objectfile, bump_wavelength);
	GetParam(objectfile, bump_amplitude);
	GetParam(objectfile, driveable);
	GetParam(objectfile, collideable);
	GetParam(objectfile, friction_notread);
	GetParam(objectfile, friction_tread);
	GetParam(objectfile, rolling_resistance);
	GetParam(objectfile, rolling_drag);
	
	if (params_per_object >= 15)
		GetParam(objectfile, isashadow);
	
	if (params_per_object >= 16)
		GetParam(objectfile, clamptexture);
	
	if (params_per_object >= 17)
		GetParam(objectfile, surface_type);
		
		
	for (int i = 0; i < params_per_object - expected_params; i++)
		GetParam(objectfile, otherjunk);

	MODEL * model(NULL);

	if (model_library.find(model_name) == model_library.end())
	{
		if (packload)
		{
			if (!model_library[model_name].Load(model_name, error_output, true, &pack))
			{
				error_output << "Error loading model: " << objectpath + "/" + model_name << " from pack " << objectpath + "/objects.jpk" << std::endl;
				return std::pair <bool, bool> (true, false); //fail the entire track loading
			}
		}
		else/**/
		{
			if (!model_library[model_name].Load(objectpath + "/" + model_name, /*NULL,*/ error_output))
			{
				error_output << "Error loading model: " << objectpath + "/" + model_name << std::endl;
				return std::pair <bool, bool> (true, false); //fail the entire track loading
			}
		}
		model = &model_library[model_name];
	}

	bool skip = false;
	bool bNewMtr = false;///
	
	if (dynamicshadowsenabled && isashadow)
		skip = true;

	if (texture_library.find(diffuse_texture_name) == texture_library.end())
	{
		bNewMtr = true;///
		TEXTUREINFO texinfo;
		texinfo.SetName(objectpath + "/" + diffuse_texture_name);
		texinfo.SetMipMap(mipmap || anisotropy); //always mipmap if anisotropy is on
		texinfo.SetAnisotropy(anisotropy);
		bool clampu = clamptexture == 1 || clamptexture == 2;
		bool clampv = clamptexture == 1 || clamptexture == 3;
		texinfo.SetRepeat(!clampu, !clampv);
		if (!texture_library[diffuse_texture_name].Load(texinfo, error_output, texture_size))
		{
			error_output << "Error loading texture: " << objectpath + "/" + diffuse_texture_name << ", skipping object " << model_name << " and continuing" << std::endl;
			skip = true; //fail the loading of this model only
		}
	}

	if (!skip)
	{
		reseatable_reference <TEXTURE_GL> miscmap1;
		std::string miscmap1_texture_name = diffuse_texture_name.substr(0,std::max(0,(int)diffuse_texture_name.length()-4));
		miscmap1_texture_name += std::string("-misc1.png");
		if (texture_library.find(miscmap1_texture_name) == texture_library.end())
		{
			TEXTUREINFO texinfo;
			std::string filepath = objectpath + "/" + miscmap1_texture_name;
			texinfo.SetName(filepath);
			texinfo.SetMipMap(mipmap);
			texinfo.SetAnisotropy(anisotropy);

			std::ifstream filecheck(filepath.c_str());
			if (filecheck)
			{
				if (!texture_library[miscmap1_texture_name].Load(texinfo, error_output, texture_size))
				{
					error_output << "Error loading texture: " << objectpath + "/" + miscmap1_texture_name << " for object " << model_name << ", continuing" << std::endl;
					texture_library.erase(miscmap1_texture_name);
					//don't fail, this isn't a critical error
				}
				else
					miscmap1 = texture_library[miscmap1_texture_name];
			}
		}
		else
			miscmap1 = texture_library.find(miscmap1_texture_name)->second;

		TEXTURE_GL * diffuse = &texture_library[diffuse_texture_name];
		
		TRACK_OBJECT object(model, diffuse, /*surfacePtr*/collideable || driveable );
		objects.push_back(object);

		///-------------  push for ogre
		//bool mipmap;	bool nolighting;
		//bool isashadow(false);
		//int clamptexture(0);

		OGRE_MESH om;
		om.found = true;
		om.sky = skybox;
		om.alpha = transparent_blend;

		om.newMtr = bNewMtr;
		om.name = model_name;
		om.material = diffuse_texture_name;
		om.mesh = &model->mesh;
		
		track->ogre_meshes.push_back(om);///
	}

	return std::pair <bool, bool> (false, true);
}
示例#29
0
 forceinline typename SharedArray<T>::const_iterator
 SharedArray<T>::begin(void) const {
   assert(object() != NULL);
   return static_cast<SAO*>(object())->begin();
 }
bool CScriptGameObject::IsTalking()
{
	CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object());
	if(!pInventoryOwner) return false;
	return			pInventoryOwner->IsTalking();
}