本文整理汇总了C++中GmatCommand::GetRefObjectNameArray方法的典型用法代码示例。如果您正苦于以下问题:C++ GmatCommand::GetRefObjectNameArray方法的具体用法?C++ GmatCommand::GetRefObjectNameArray怎么用?C++ GmatCommand::GetRefObjectNameArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GmatCommand
的用法示例。
在下文中一共展示了GmatCommand::GetRefObjectNameArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindObject
//------------------------------------------------------------------------------
bool GmatCommandUtil::FindObject(GmatCommand *cmd, Gmat::ObjectType objType,
const std::string &objName, std::string &cmdName,
GmatCommand **cmdUsing, bool checkWrappers)
{
if (cmd == NULL)
return false;
GmatCommand *current = cmd;
std::string cmdstr = cmd->GetTypeName();
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("===> GmatCommandUtil::FindObject() entered, objType=%d, objName='%s', "
"cmd=<%p><%s>\n", objType, objName.c_str(), cmd, cmdstr.c_str());
#endif
while (current != NULL)
{
cmdstr = "--- " + current->GetTypeName() + "\n";
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage(cmdstr);
#endif
try
{
StringArray names = current->GetRefObjectNameArray(objType);
for (UnsignedInt i=0; i<names.size(); i++)
{
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage("names[%d]=%s\n", i, names[i].c_str());
#endif
if (names[i] == objName)
{
cmdName = current->GetTypeName();
*cmdUsing = current;
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("CommandUtil::FindObject() returning true, cmdName='%s', "
"cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
(*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
return true;
}
}
}
catch (BaseException &e)
{
// Use exception to remove Visual C++ warning
e.GetMessageType();
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage("*** INTERNAL WARNING *** " + e.GetFullMessage());
#endif
}
// go through sub commands
if ((current->GetChildCommand(0)) != NULL)
{
if (FindObjectFromSubCommands(current, 0, objType, objName, cmdName, cmdUsing, checkWrappers))
{
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("CommandUtil::FindObject() returning true, cmdName='%s', "
"cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
(*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
return true;
}
}
// Check for references in the wrappers, if requested
if (checkWrappers)
{
if (current->HasOtherReferenceToObject(objName))
{
cmdName = current->GetTypeName();
*cmdUsing = current;
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("CommandUtil::FindObject() returning true (for wrappers), cmdName='%s', "
"cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
(*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
return true;
}
}
current = current->GetNext();
}
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("===> GmatCommandUtil::FindObject() returning false\n");
#endif
return false;
//.........这里部分代码省略.........
示例2: FindObjectFromSubCommands
//------------------------------------------------------------------------------
bool GmatCommandUtil::FindObjectFromSubCommands(GmatCommand *brCmd, Integer level,
Gmat::ObjectType objType, const std::string &objName,
std::string &cmdName, GmatCommand **cmdUsing, bool checkWrappers)
{
GmatCommand* current = brCmd;
Integer childNo = 0;
GmatCommand* nextInBranch = NULL;
GmatCommand* child;
std::string cmdstr;
while((child = current->GetChildCommand(childNo)) != NULL)
{
nextInBranch = child;
while ((nextInBranch != NULL) && (nextInBranch != current))
{
#ifdef DEBUG_COMMAND_FIND_OBJECT
for (int i=0; i<=level; i++)
cmdstr = "---" + cmdstr;
cmdstr = "--- " + nextInBranch->GetTypeName() + "\n";
MessageInterface::ShowMessage("%s", cmdstr.c_str());
#endif
try
{
StringArray names = nextInBranch->GetRefObjectNameArray(objType);
for (UnsignedInt i=0; i<names.size(); i++)
{
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage("names[%d]=%s\n", i, names[i].c_str());
#endif
if (names[i] == objName)
{
cmdName = nextInBranch->GetTypeName();
*cmdUsing = nextInBranch;
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("CommandUtil::FindObjectFromSubCommands() returning true, "
"cmdName='%s', cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
(*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
return true;
}
}
}
catch (BaseException &e)
{
// Use exception to remove Visual C++ warning
e.GetMessageType();
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage("*** INTERNAL WARNING *** " + e.GetFullMessage());
#endif
}
if (nextInBranch->GetChildCommand() != NULL)
if (FindObjectFromSubCommands(nextInBranch, level+1, objType, objName, cmdName,
cmdUsing, checkWrappers))
{
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("CommandUtil::FindObjectFromSubCommands() returning true, "
"cmdName='%s', cmdUsing=<%p>'%s'\n", cmdName.c_str(), cmdUsing,
(*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
return true;
}
// Check for references in the wrappers, if requested
if (checkWrappers)
{
if (nextInBranch->HasOtherReferenceToObject(objName))
{
cmdName = nextInBranch->GetTypeName();
*cmdUsing = nextInBranch;
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("CommandUtil::FindObjectFromSubCommands() returning true (for wrappers), cmdName='%s', "
"cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
(*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
return true;
}
}
nextInBranch = nextInBranch->GetNext();
}
++childNo;
}
#ifdef DEBUG_COMMAND_FIND_OBJECT
MessageInterface::ShowMessage
("===> GmatCommandUtil::FindObjectFromSubCommands() returning false\n");
#endif
return false;
}