本文整理汇总了C++中GmatCommand::GetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ GmatCommand::GetNext方法的具体用法?C++ GmatCommand::GetNext怎么用?C++ GmatCommand::GetNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GmatCommand
的用法示例。
在下文中一共展示了GmatCommand::GetNext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMatchingEnd
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetMatchingEnd(GmatCommand *cmd, bool getMatchingElse)
{
if (cmd == NULL)
return NULL;
#ifdef DEBUG_MATCHING_END
ShowCommand
("===> GmatCommandUtil::GetMatchingEnd() cmd = ", cmd);
#endif
if (cmd->GetTypeName() != "BeginScript" && !cmd->IsOfType("BranchCommand"))
return NULL;
GmatCommand *current = cmd;
if (cmd->GetTypeName() == "BeginScript")
{
Integer scriptEventCount = 0;
while (current != NULL)
{
if (current->GetTypeName() == "BeginScript")
scriptEventCount++;
if (current->GetTypeName() == "EndScript")
scriptEventCount--;
#ifdef DEBUG_MATCHING_END
MessageInterface::ShowMessage
(" scriptEventCount=%d, current=<%p><%s>\n", scriptEventCount, current,
current->GetTypeName().c_str());
#endif
if (scriptEventCount == 0)
break;
current = current->GetNext();
}
#ifdef DEBUG_MATCHING_END
ShowCommand("===> GmatCommandUtil::GetMatchingEnd() returning ", current);
#endif
return current;
}
else
{
GmatCommand *child = NULL;
Integer branch = 0;
bool elseFound = false;
while ((current->GetChildCommand(branch)) != NULL)
{
child = current->GetChildCommand(branch);
while (child != NULL)
{
#ifdef DEBUG_MATCHING_END
ShowCommand(" child = ", child);
#endif
if (child->IsOfType("BranchEnd"))
{
if (child->GetTypeName() == "Else")
{
elseFound = true;
if (getMatchingElse)
break;
branch++;
}
break;
}
child = child->GetNext();
}
if (elseFound && branch == 1)
{
elseFound = false;
continue;
}
else
break;
}
#ifdef DEBUG_MATCHING_END
ShowCommand("===> GmatCommandUtil::GetMatchingEnd() returning ", child);
#endif
return child;
}
}
示例2: RemoveCommand
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::RemoveCommand(GmatCommand *seq, GmatCommand *cmd)
{
#ifdef DEBUG_COMMAND_DELETE
ShowCommand("==========> CommandUtil::RemoveCommand() removing ", cmd,
" from ", seq);
#endif
if (cmd == NULL)
return NULL;
GmatCommand *remvCmd;
if (cmd->GetTypeName() != "BeginScript")
{
GmatCommand *remvCmd = seq->Remove(cmd);
#ifdef DEBUG_COMMAND_DELETE
ShowCommand(" Removed = ", remvCmd);
#endif
#ifdef DEBUG_COMMAND_DELETE
ShowCommand("==========> CommandUtil::RemoveCommand() Returning ", remvCmd);
#endif
return remvCmd;
}
//-------------------------------------------------------
// Remove commands inside Begin/EndScript block
//-------------------------------------------------------
// Check for previous command, it should not be NULL,
// since "NoOp" is the first command
GmatCommand *prevCmd = cmd->GetPrevious();
if (prevCmd == NULL)
{
MessageInterface::PopupMessage
(Gmat::ERROR_, "CommandUtil::RemoveCommand() *** INTERNAL ERROR *** \n"
"The previous command cannot be NULL.\n");
return NULL;
}
////GmatCommand *first = GetFirstCommand();
GmatCommand *first = seq;
#ifdef DEBUG_COMMAND_DELETE
std::string cmdString1 = GmatCommandUtil::GetCommandSeqString(first);
MessageInterface::ShowMessage(" ==> Current sequence:");
MessageInterface::ShowMessage(cmdString1);
#endif
GmatCommand *current = cmd->GetNext();
#ifdef DEBUG_COMMAND_DELETE
GmatCommand *nextCmd = GmatCommandUtil::GetNextCommand(cmd);
ShowCommand(" prevCmd = ", prevCmd, " nextCmd = ", nextCmd);
#endif
// Get matching EndScript for BeginScript
GmatCommand *endScript = GmatCommandUtil::GetMatchingEnd(cmd);
#ifdef DEBUG_COMMAND_DELETE
ShowCommand(" endScript = ", endScript);
#endif
GmatCommand* next;
while (current != NULL)
{
#ifdef DEBUG_COMMAND_DELETE
ShowCommand(" current = ", current);
#endif
if (current == endScript)
break;
next = current->GetNext();
#ifdef DEBUG_COMMAND_DELETE
ShowCommand(" removing and deleting ", current);
#endif
remvCmd = cmd->Remove(current);
// per kw report - check remvCmd first
if (remvCmd != NULL)
{
remvCmd->ForceSetNext(NULL);
#ifdef DEBUG_MEMORY
MemoryTracker::Instance()->Remove
(remvCmd, remvCmd->GetTypeName(), "CommandUtil::RemoveCommand()");
#endif
delete remvCmd;
}
current = next;
}
//-------------------------------------------------------
//.........这里部分代码省略.........
示例3: if
//------------------------------------------------------------------------------
// void GetSubCommandString(GmatCommand* brCmd, Integer level, std::string &cmdseq,
// bool showAddr = true, bool showGenStr = false,
// bool showSummaryName = false,
// const std::string &indentStr = "---")
//------------------------------------------------------------------------------
void GmatCommandUtil::
GetSubCommandString(GmatCommand* brCmd, Integer level, std::string &cmdseq,
bool showAddr, bool showGenStr, bool showSummaryName,
const std::string &indentStr)
{
char buf[13];
GmatCommand* current = brCmd;
Integer childNo = 0;
GmatCommand* nextInBranch;
GmatCommand* child;
std::string cmdstr, genStr;
buf[0] = '\0';
while((child = current->GetChildCommand(childNo)) != NULL)
{
nextInBranch = child;
while ((nextInBranch != NULL) && (nextInBranch != current))
{
for (int i=0; i<=level; i++)
{
cmdseq.append(indentStr);
#ifdef DEBUG_COMMAND_SEQ_STRING
MessageInterface::ShowMessage(indentStr);
#endif
}
if (showAddr)
sprintf(buf, "(%p)", nextInBranch);
genStr = "";
if (showGenStr)
{
if (nextInBranch->GetTypeName() == "BeginScript")
genStr = "<BeginScript>";
else if (nextInBranch->GetTypeName() == "EndScript")
genStr = "<EndScript>";
else
genStr = " <" + nextInBranch->GetGeneratingString(Gmat::NO_COMMENTS) + ">";
}
else if (showSummaryName)
{
// Show summary name
genStr = "(" + nextInBranch->GetSummaryName() + ")";
}
// if indentation string is not blank, use it from the first sub level
if (indentStr.find(" ") == indentStr.npos)
cmdstr = indentStr + " " + std::string(buf) + nextInBranch->GetTypeName() + genStr + "\n";
else
cmdstr = std::string(buf) + nextInBranch->GetTypeName() + genStr + "\n";
cmdseq.append(cmdstr);
#ifdef DEBUG_COMMAND_SEQ_STRING
MessageInterface::ShowMessage("%s", cmdstr.c_str());
#endif
if (nextInBranch->GetChildCommand() != NULL)
GetSubCommandString(nextInBranch, level+1, cmdseq, showAddr, showGenStr,
showSummaryName, indentStr);
nextInBranch = nextInBranch->GetNext();
}
++childNo;
}
}
示例4: 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;
}
示例5: Execute
//.........这里部分代码省略.........
(wxT("......Function re-executing <%p><%s> [%s]\n"), current,
current->GetTypeName().c_str(),
current->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
if (!(current->Execute()))
return false;
}
catch (HardwareException &he)
{
// Ignore for hardware exception since spacecraft is associated with Thruster
// but Thruster binds with Tank later in the fcs
}
catch (BaseException &be)
{
throw FunctionException
(wxT("During initialization of local objects before \"") +
current->GetGeneratingString(Gmat::NO_COMMENTS) + wxT("\", ") +
e.GetFullMessage());
}
}
// If current command is BranchCommand and still executing, continue to next
// command in the branch (LOJ: 2009.03.24)
if (current->IsOfType(wxT("BranchCommand")) && current->IsExecuting())
{
#ifdef DEBUG_FUNCTION_EXEC
MessageInterface::ShowMessage
(wxT("In Function '%s', still executing current command is <%p><%s>\n"),
functionName.c_str(), current, current ? current->GetTypeName().c_str() : wxT("NULL"));
#endif
continue;
}
current = current->GetNext();
#ifdef DEBUG_FUNCTION_EXEC
MessageInterface::ShowMessage
(wxT("In Function '%s', the next command is <%p><%s>\n"), functionName.c_str(),
current, current ? current->GetTypeName().c_str() : wxT("NULL"));
#endif
}
// Set ObjectMap from the last command to Validator in order to create
// valid output wrappers (loj: 2008.11.12)
validator->SetObjectMap(last->GetObjectMap());
#ifdef DEBUG_FUNCTION_EXEC
MessageInterface::ShowMessage
(wxT(" Now about to create %d output wrapper(s) to set results, objectsInitialized=%d\n"),
outputNames.size(), objectsInitialized);
#endif
// create output wrappers and put into map
GmatBase *obj;
wrappersToDelete.clear();
for (unsigned int jj = 0; jj < outputNames.size(); jj++)
{
if (!(obj = FindObject(outputNames.at(jj))))
{
wxString errMsg = wxT("Function: Output \"") + outputNames.at(jj);
errMsg += wxT(" not found for function \"") + functionName + wxT("\"");
throw FunctionException(errMsg);
}
wxString outName = outputNames.at(jj);
ElementWrapper *outWrapper =
validator->CreateElementWrapper(outName, false, false);
#ifdef DEBUG_MORE_MEMORY
MessageInterface::ShowMessage
(wxT("+++ GmatFunction::Execute() *outWrapper = validator->")
wxT("CreateElementWrapper(%s), <%p> '%s'\n"), outName.c_str(), outWrapper,
outWrapper->GetDescription().c_str());
#endif
outWrapper->SetRefObject(obj);
// nested CallFunction crashes if old outWrappers are deleted here. (loj: 2008.11.24)
// so collect here and delete when FunctionRunner completes.
wrappersToDelete.push_back(outWrapper);
// Set new outWrapper
outputArgMap[outName] = outWrapper;
#ifdef DEBUG_FUNCTION_EXEC // --------------------------------------------------- debug ---
MessageInterface::ShowMessage(wxT("GmatFunction: Output wrapper created for %s\n"),
(outputNames.at(jj)).c_str());
#endif // -------------------------------------------------------------- end debug ---
}
#ifdef DEBUG_FUNCTION_EXEC
MessageInterface::ShowMessage
(wxT("GmatFunction::Execute() exiting true for '%s'\n"), functionName.c_str());
#endif
#ifdef DEBUG_TRACE
ShowTrace(callCount, t1, wxT("GmatFunction::Execute() exiting"), true);
#endif
return true;
}
示例6: Initialize
//.........这里部分代码省略.........
while (current)
{
#ifdef DEBUG_FUNCTION_INIT
if (!current) MessageInterface::ShowMessage(wxT("Current is NULL!!!\n"));
else MessageInterface::ShowMessage(wxT(" =====> Current command is %s <%s>\n"),
(current->GetTypeName()).c_str(),
current->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
current->SetObjectMap(objectStore);
current->SetGlobalObjectMap(globalObjectStore);
current->SetSolarSystem(solarSys);
current->SetInternalCoordSystem(internalCoordSys);
current->SetTransientForces(forces);
#ifdef DEBUG_FUNCTION_INIT
MessageInterface::ShowMessage
(wxT(" Now about to set object map of type %s to Validator\n"),
(current->GetTypeName()).c_str());
#endif
// (Re)set object map on Validator (necessary because objects may have been added to the
// Local Object Store or Global Object Store during initialization of previous commands)
validatorStore.clear();
for (omi = objectStore->begin(); omi != objectStore->end(); ++omi)
validatorStore.insert(std::make_pair(omi->first, omi->second));
for (omi = globalObjectStore->begin(); omi != globalObjectStore->end(); ++omi)
validatorStore.insert(std::make_pair(omi->first, omi->second));
validator->SetObjectMap(&validatorStore);
#ifdef DEBUG_FUNCTION_INIT
MessageInterface::ShowMessage
(wxT(" Now about to call Validator->ValidateCommand() of type %s\n"),
current->GetTypeName().c_str());
#endif
// Let's try to ValidateCommand here, this will validate the command
// and create wrappers also
if (!validator->ValidateCommand(current, false, 2))
{
// get error message (loj: 2008.06.04)
StringArray errList = validator->GetErrorList();
wxString msg; // Check for empty errList (loj: 2009.03.17)
if (errList.empty())
msg = wxT("Error occurred");
else
msg = errList[0];
throw FunctionException(msg + wxT(" in the function \"") + functionPath + wxT("\""));
}
#ifdef DEBUG_FUNCTION_INIT
MessageInterface::ShowMessage
(wxT(" Now about to initialize command of type %s\n"), current->GetTypeName().c_str());
#endif
// catch exception and add function name to message (loj: 2008.09.23)
try
{
if (!(current->Initialize()))
{
#ifdef DEBUG_FUNCTION_INIT
MessageInterface::ShowMessage
(wxT("Exiting GmatFunction::Initialize for function '%s' with false\n"),
functionName.c_str());
#endif
return false;
}
}
catch (BaseException &e)
{
throw FunctionException(wxT("Cannot continue due to ") + e.GetFullMessage() +
wxT(" in the function \"") + functionPath + wxT("\""));
}
// Check to see if the command needs a server startup (loj: 2008.07.25)
if (current->NeedsServerStartup())
if (validator->StartMatlabServer(current) == false)
throw FunctionException(wxT("Unable to start the server needed by the ") +
(current->GetTypeName()) + wxT(" command"));
current = current->GetNext();
}
// Get automatic global object list and check if they are used in the function
// command sequence so that when any global object is declared in the main script
// but not used in the function, they can be ignored during function local object
// initialization. (LOJ: 2009.12.18)
BuildUnusedGlobalObjectList();
fcsFinalized = false;
#ifdef DEBUG_FUNCTION_INIT
MessageInterface::ShowMessage
(wxT("GmatFunction::Initialize() exiting for function '%s' with true\n"),
functionName.c_str());
#endif
#ifdef DEBUG_TRACE
ShowTrace(callCount, t1, wxT("GmatFunction::Initialize() exiting"), true);
#endif
return true;
}