//------------------------------------------------------------------------------ void MathElement::SetWrapperObject(GmatBase *obj, const std::string &name) { #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetWrapperObject() obj=<%p>, name='%s'\n", obj, name.c_str()); #endif refObject = (Parameter*) obj; refObjectType = refObject->GetTypeName().c_str(); // go through wrapperObjectNames for (UnsignedInt i=0; i<wrapperObjectNames.size(); i++) { if (name == wrapperObjectNames[i]) { #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage (" wrapperName = '%s'\n", wrapperObjectNames[i].c_str()); #endif // Handle array index Integer row, col; std::string newName; GmatStringUtil::GetArrayIndex(wrapperObjectNames[i], row, col, newName); // Check if name is the same if (newName != name) throw MathException ("MathElement::SetRefObject() Cannot find parameter name:" + name); if (refObjectType == "Array") { Array *arr = (Array*)refObject; elementType = Gmat::RMATRIX_TYPE; Integer theRowCount = arr->GetRowCount(); Integer theColCount = arr->GetColCount(); #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetRefObject() elementType=%d, theRowCount=%d, " "theColCount=%d\n", elementType, theRowCount, theColCount); #endif if (!matrix.IsSized()) matrix.SetSize(theRowCount, theColCount); else { #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetRefObject() matrix already sized. " "matrix.size=%d, %d\n", matrix.GetNumRows(), matrix.GetNumColumns()); #endif } matrix = arr->GetRmatrix(); // initial value #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetRefObject() name=%s, matrix=\n%s\n", name.c_str(), matrix.ToString().c_str()); #endif } else if (refObject->GetReturnType() == Gmat::REAL_TYPE) { elementType = Gmat::REAL_TYPE; realValue = refObject->GetReal(); // initial value #ifdef DEBUG_WRAPPERS MessageInterface::ShowMessage ("MathElement::SetRefObject() name=%s, elementType=%d, " "realValue=%f\n", GetName().c_str(), elementType, realValue); #endif } } } }