コード例 #1
0
ファイル: MathElement.cpp プロジェクト: rockstorm101/GMAT
//------------------------------------------------------------------------------
// Real Evaluate()
//------------------------------------------------------------------------------
Real MathElement::Evaluate()
{
   #ifdef DEBUG_EVALUATE
   MessageInterface::ShowMessage
      ("MathElement::Evaluate() this='%s', refObjectName='%s', refObject=<%p>, "
       "elementType=%d\n", GetName().c_str(), refObjectName.c_str(), refObject, elementType);
   #endif
   
   // If this MathElement is function Input, just return since it is handled in
   // the FunctionRunner
   
   if (isFunctionInput)
      throw MathException("MathElement::Evaluate() Function input should "
                          "not be handled here");
   
   if (refObject)
   {
      #ifdef DEBUG_EVALUATE
      MessageInterface::ShowMessage
         ("   refObject=<%p><%p>'%s'\n", refObject, refObject->GetTypeName().c_str(),
          refObject->GetName().c_str());
      #endif
      
      ElementWrapper *wrapper = FindWrapper(refObjectName);
      
      if (elementType == Gmat::REAL_TYPE || elementType == Gmat::RMATRIX_TYPE)
      {
         #ifdef DEBUG_EVALUATE
         MessageInterface::ShowMessage
            ("   wrapper type=%d, desc='%s'\n", wrapper->GetWrapperType(),
             wrapper->GetDescription().c_str());
         #endif
         ///@note ArrayWrapper::EvaluateReal() returns 1x1 matrix as real number
         realValue = wrapper->EvaluateReal();
      }
      else
      {
         throw MathException
            ("MathElement::Evaluate() Cannot Evaluate MathElementType of \"" +
             refObjectName + "\"");
      }
      
      #ifdef DEBUG_EVALUATE
      MessageInterface::ShowMessage
         ("MathElement::Evaluate() It's a parameter: %s realValue = %f\n",
          refObject->GetName().c_str(), realValue);
      #endif
      
      return realValue;
   }
   else
   {
      #ifdef DEBUG_EVALUATE
      MessageInterface::ShowMessage
         ("MathElement::Evaluate() It's a number: realValue = %f\n", realValue);
      #endif
      
      return realValue;
   }
}