CComplexStruct::CComplexStruct (const TSortMap<CString, CString> &Src) // CComplexStruct construtor { int i; for (i = 0; i < Src.GetCount(); i++) { const CString &sKey = Src.GetKey(i); if (!sKey.IsEmpty()) SetElement(sKey, Src.GetValue(i)); } }
void GenerateTypeDependencies (CUniverse &Universe, CXMLElement *pCmdLine) { int i, j; bool bRecursive = pCmdLine->GetAttributeBool(CONSTLIT("recursive")); bool bReverse = pCmdLine->GetAttributeBool(CONSTLIT("reverse")); // Create a reverse index of all type dependencies TSortMap<DWORD, TArray<DWORD> > ReverseIndex; // Types and what they use if (!bReverse) { printf("TYPES AND WHAT THEY USE\n"); printf("-----------------------\n\n"); } for (i = 0; i < Universe.GetDesignTypeCount(); i++) { CDesignType *pType = Universe.GetDesignType(i); if (!bReverse) printf("%s\n", (char *)GetTypeDesc(pType)); // Get the list of UNIDs that this type uses TSortMap<DWORD, bool> TypesUsed; if (bRecursive) AddTypesUsedRecursive(Universe, pType->GetUNID(), &TypesUsed); else pType->AddTypesUsed(&TypesUsed); // Output the list for (j = 0; j < TypesUsed.GetCount(); j++) { CDesignType *pRequired = Universe.FindDesignType(TypesUsed.GetKey(j)); if (pRequired == NULL) continue; if (!bReverse) printf("\t%s\n", (char *)GetTypeDesc(pRequired)); // Add to reverse index TArray<DWORD> *pList = ReverseIndex.SetAt(pRequired->GetUNID()); pList->Insert(pType->GetUNID()); } } // Types and what depends on them if (bReverse) { printf("\nTYPES AND WHAT USES THEM\n"); printf( "------------------------\n\n"); for (i = 0; i < ReverseIndex.GetCount(); i++) { CDesignType *pType = Universe.FindDesignType(ReverseIndex.GetKey(i)); if (pType == NULL) continue; printf("%s\n", (char *)GetTypeDesc(pType)); TArray<DWORD> &List = ReverseIndex.GetValue(i); for (j = 0; j < List.GetCount(); j++) { CDesignType *pRequiredBy = Universe.FindDesignType(List[j]); if (pRequiredBy) printf("\t%s\n", (char *)GetTypeDesc(pRequiredBy)); } } } }
void GenerateTopology (CUniverse &Universe, CXMLElement *pCmdLine) { int i, j, k; int iCount = pCmdLine->GetAttributeIntegerBounded(COUNT_SWITCH, 1, -1, 1); STopologyStats Stats; for (k = 0; k < iCount; k++) { if (iCount > 1) printf("sample %d", k+1); TSortMap<CString, SNodeInfo> NodeData; TSortMap<CString, int> AttribCount; // Initialize the topology CString sError; Universe.GetFirstTopologyNode(); // Loop over all nodes for (i = 0; i < Universe.GetTopologyNodeCount(); i++) { CTopologyNode *pNode = Universe.GetTopologyNode(i); SNodeInfo *pNewNode = NodeData.Insert(pNode->GetID()); pNewNode->sID = pNode->GetID(); pNewNode->sName = pNode->GetSystemName(); pNewNode->dwSystemUNID = pNode->GetSystemDescUNID(); pNewNode->sAttribs = pNode->GetAttributes(); // Add the attributes in this node to the list of // attributes for this try. TArray<CString> Attribs; ParseAttributes(pNewNode->sAttribs, &Attribs); for (j = 0; j < Attribs.GetCount(); j++) { int *pCount = AttribCount.GetAt(Attribs[j]); if (pCount == NULL) { pCount = AttribCount.Insert(Attribs[j]); *pCount = 0; } *pCount = (*pCount) + 1; } } // Compute topology stats // Add the node count for this try Stats.NodeCount.Insert(NodeData.GetCount()); // Loop over all attributes that we know about. If one doesn't // exist in this try, then we set its min to 0 if (k > 0) { for (i = 0; i < Stats.Attribs.GetCount(); i++) { if (AttribCount.GetAt(Stats.Attribs.GetKey(i)) == NULL) Stats.Attribs[i].SetMin(0); } } // Loop over all attributes in this try and add them to the stats SStat *pAttribStat; for (i = 0; i < AttribCount.GetCount(); i++) { // If we have some attributes that no other try had, then // that means that the minimum value is 0. if (pAttribStat = Stats.Attribs.GetAt(AttribCount.GetKey(i))) pAttribStat->Insert(AttribCount[i]); else { pAttribStat = Stats.Attribs.Insert(AttribCount.GetKey(i)); pAttribStat->Insert(AttribCount[i]); if (k > 0) pAttribStat->SetMin(0); } } // Output all the nodes if (iCount == 1) { printf("Node\tSystemType\tName\tStargates\tAttributes\n"); for (i = 0; i < NodeData.GetCount(); i++) { SNodeInfo *pNode = &NodeData.GetValue(i); printf("%s\t%08x\t%s\t%d\t%s\n", pNode->sID.GetASCIIZPointer(), pNode->dwSystemUNID, pNode->sName.GetASCIIZPointer(), pNode->Stargates.GetCount(), pNode->sAttribs.GetASCIIZPointer()); } } else { Universe.Reinit(); printf("\n"); } } // Output stats if (iCount > 0) { printf("\n"); printf("STATS\n\n"); Stats.NodeCount.Print(CONSTLIT("Nodes"), iCount, Stats.NodeCount.GetAverage(iCount)); printf("\n"); printf("ATTRIBS\n\n"); for (i = 0; i < Stats.Attribs.GetCount(); i++) Stats.Attribs[i].Print(Stats.Attribs.GetKey(i), iCount, Stats.NodeCount.GetAverage(iCount)); printf("\n"); } }