本文整理汇总了C++中GmatCommand::GetGeneratingString方法的典型用法代码示例。如果您正苦于以下问题:C++ GmatCommand::GetGeneratingString方法的具体用法?C++ GmatCommand::GetGeneratingString怎么用?C++ GmatCommand::GetGeneratingString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GmatCommand
的用法示例。
在下文中一共展示了GmatCommand::GetGeneratingString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetChildString
//------------------------------------------------------------------------------
const wxString BeginScript::GetChildString(const wxString &prefix,
GmatCommand *cmd,
GmatCommand *parent)
{
#ifdef DEBUG_BEGINSCRIPT
MessageInterface::ShowMessage(wxT("BeginScript::GetChildString entered\n"));
#endif
wxString sstr;
wxString cmdstr;
Integer whichOne, start;
GmatCommand *current = cmd;
while ((current != parent) && (current != NULL))
{
cmdstr = current->GetGeneratingString();
start = 0;
while (cmdstr[start] == wxT(' '))
++start;
cmdstr = cmdstr.substr(start);
sstr << prefix << cmdstr << wxT("\n");
whichOne = 0;
GmatCommand* child = current->GetChildCommand(whichOne);
while ((child != NULL) && (child != cmd))
{
sstr << GetChildString(prefix + wxT(" "), child, current);
++whichOne;
child = current->GetChildCommand(whichOne);
}
current = current->GetNext();
}
return sstr;
}
示例2: 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;
}
}
示例3: Execute
//------------------------------------------------------------------------------
// bool GmatFunction::Execute(ObjectInitializer *objInit, bool reinitialize)
//------------------------------------------------------------------------------
bool GmatFunction::Execute(ObjectInitializer *objInit, bool reinitialize)
{
if (!fcs) return false;
if (!objInit) return false;
#ifdef DEBUG_TRACE
static Integer callCount = 0;
callCount++;
clock_t t1 = clock();
ShowTrace(callCount, t1, wxT("GmatFunction::Execute() entered"));
#endif
#ifdef DEBUG_FUNCTION_EXEC
MessageInterface::ShowMessage
(wxT("======================================================================\n")
wxT("GmatFunction::Execute() entered for '%s'\n internalCS is <%p>, ")
wxT("reinitialize = %d\n"), functionName.c_str(), internalCoordSys, reinitialize);
#endif
GmatCommand *current = fcs;
GmatCommand *last = NULL;
// We want to initialize local objects with new object map,
// so do it everytime (loj: 2008.09.26)
// This causes to slow down function execution, so initialize if necessary
if (reinitialize)
objectsInitialized = false;
// Reinitialize CoordinateSystem to fix bug 1599 (LOJ: 2009.11.05)
// Reinitialize Parameters to fix bug 1519 (LOJ: 2009.09.16)
if (objectsInitialized)
{
if (!objInit->InitializeObjects(true, Gmat::COORDINATE_SYSTEM))
throw FunctionException
(wxT("Failed to re-initialize Parameters in the \"") + functionName + wxT("\""));
if (!objInit->InitializeObjects(true, Gmat::PARAMETER))
throw FunctionException
(wxT("Failed to re-initialize Parameters in the \"") + functionName + wxT("\""));
}
// Go through each command in the sequence and execute.
// Once it gets to a real command, initialize local and automatic objects.
while (current)
{
// Call to IsNextAFunction is necessary for branch commands in particular
#ifdef DEBUG_FUNCTION_EXEC
MessageInterface::ShowMessage
(wxT("......Function executing <%p><%s> [%s]\n"), current, current->GetTypeName().c_str(),
current->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
MessageInterface::ShowMessage(wxT(" objectsInitialized=%d\n"), objectsInitialized);
#endif
last = current;
if (!objectsInitialized)
{
// Since we don't know where actual mission sequence starts, just check
// for command that is not NoOp, Create, Global, and GMAT with equation.
// Can we have simple command indicating beginning of the sequence,
// such as BeginSequence? (loj: 2008.06.19)
// @todo: Now we have BeginMissionSequence, but not all functions have it,
// so check it first otherwise do in the old way. (loj: 2010.07.16)
Function *func = current->GetCurrentFunction();
bool isEquation = false;
wxString cmdType = current->GetTypeName();
if (func && cmdType == wxT("GMAT"))
if (((Assignment*)current)->GetMathTree() != NULL)
isEquation = true;
if (cmdType != wxT("NoOp") && cmdType != wxT("Create") && cmdType != wxT("Global"))
{
bool beginInit = true;
if (cmdType == wxT("GMAT") && !isEquation)
beginInit = false;
if (cmdType == wxT("BeginMissionSequence") || cmdType == wxT("BeginScript"))
beginInit = true;
if (beginInit)
{
objectsInitialized = true;
validator->HandleCcsdsEphemerisFile(objectStore, true);
#ifdef DEBUG_FUNCTION_EXEC
MessageInterface::ShowMessage
(wxT("============================ Initializing LocalObjects at current\n")
wxT("%s\n"), current->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
#endif
InitializeLocalObjects(objInit, current, true);
}
}
}
// Now execute the function sequence
try
{
#ifdef DEBUG_FUNCTION_EXEC
MessageInterface::ShowMessage
//.........这里部分代码省略.........
示例4: Initialize
//------------------------------------------------------------------------------
// bool Initialize()
//------------------------------------------------------------------------------
bool GmatFunction::Initialize()
{
#ifdef DEBUG_TRACE
static Integer callCount = 0;
callCount++;
clock_t t1 = clock();
ShowTrace(callCount, t1, wxT("GmatFunction::Initialize() entered"));
#endif
#ifdef DEBUG_FUNCTION_INIT
MessageInterface::ShowMessage
(wxT("======================================================================\n")
wxT("GmatFunction::Initialize() entered for function '%s'\n"), functionName.c_str());
MessageInterface::ShowMessage(wxT(" and FCS is %s set.\n"), (fcs? wxT("correctly") : wxT("NOT")));
MessageInterface::ShowMessage(wxT(" Pointer for FCS is %p\n"), fcs);
MessageInterface::ShowMessage(wxT(" First command in fcs is %s\n"),
(fcs->GetTypeName()).c_str());
MessageInterface::ShowMessage(wxT(" internalCS is %p\n"), internalCoordSys);
#endif
if (!fcs) return false;
Function::Initialize();
// Initialize the Validator - I think I need to do this each time - or do I?
validator->SetFunction(this);
validator->SetSolarSystem(solarSys);
std::map<wxString, GmatBase *>::iterator omi;
// add automatic objects such as sat.X to the FOS (well, actually, clones of them)
for (omi = automaticObjectMap.begin(); omi != automaticObjectMap.end(); ++omi)
{
wxString autoObjName = omi->first;
// if name not found, clone it and add to map (loj: 2008.12.15)
if (objectStore->find(autoObjName) == objectStore->end())
{
GmatBase *autoObj = (omi->second)->Clone();
#ifdef DEBUG_MEMORY
MemoryTracker::Instance()->Add
(autoObj, autoObjName, wxT("GmatFunction::Initialize()"),
wxT("autoObj = (omi->second)->Clone()"));
#endif
#ifdef DEBUG_FUNCTION_INIT
try
{
MessageInterface::ShowMessage
(wxT(" autoObj->EvaluateReal() = %f\n"), autoObj->GetRealParameter(wxT("Value")));
}
catch (BaseException &e)
{
MessageInterface::ShowMessage(e.GetFullMessage());
}
#endif
autoObj->SetIsLocal(true);
objectStore->insert(std::make_pair(autoObjName, autoObj));
}
}
// first, send all the commands the object store, solar system, etc
GmatCommand *current = fcs;
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
//.........这里部分代码省略.........