Exemplo n.º 1
0
//------------------------------------------------------------------------------
// 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;
   }
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
std::string GmatCommandUtil::
GetCommandSeqString(GmatCommand *cmd, bool showAddr, bool showGenStr,
                    bool showSummaryName, const std::string &indentStr)
{
   char buf[13];
   GmatCommand *current = cmd;
   std::string cmdseq, cmdstr, genStr;
   cmdstr = "\n---------- Mission Sequence ----------\n";
   cmdseq.append(cmdstr);
   buf[0] = '\0';
   
   #ifdef DEBUG_COMMAND_SEQ_STRING
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::GetCommandSeqString(%p)\n", cmd);
   MessageInterface::ShowMessage("%s", cmdstr.c_str());
   #endif
   
   
   while (current != NULL)
   {
      if (showAddr)
         sprintf(buf, "(%p)", current);
      
      genStr = "";
      if (showGenStr)
      {
         if (current->GetTypeName() == "BeginScript")
            genStr = "<BeginScript>";
         else if (current->GetTypeName() == "EndScript")
            genStr = "<EndScript>";
         else
            genStr = " <" + current->GetGeneratingString(Gmat::NO_COMMENTS) + ">";
      }
		else if (showSummaryName)
		{
			// Show summary name
         genStr = "(" + current->GetSummaryName() + ")";
		}
		
      // if indentation string is not blank, use it from the first level
      if (indentStr.find(" ") == indentStr.npos)
         cmdstr = indentStr + " " + std::string(buf) + current->GetTypeName() + genStr + "\n";
      else
         cmdstr = std::string(buf) + current->GetTypeName() + genStr + "\n";
      
      cmdseq.append(cmdstr);
      
      #ifdef DEBUG_COMMAND_SEQ_STRING
      MessageInterface::ShowMessage("%s", cmdstr.c_str());
      #endif
      
      if ((current->GetChildCommand(0)) != NULL)
         GetSubCommandString(current, 0, cmdseq, showAddr, showGenStr, showSummaryName, indentStr);
      
      current = current->GetNext();
   }
   
   cmdseq.append("\n");
   
   return cmdseq;
}