Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.8 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef DEPENDENCYGRAPH_H
  7. #define DEPENDENCYGRAPH_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/utlvector.h"
  12. #include "tier1/utlhash.h"
  13. //-----------------------------------------------------------------------------
  14. // Forward declarations
  15. //-----------------------------------------------------------------------------
  16. class CDmAttribute;
  17. class IDmeOperator;
  18. struct COperatorNode;
  19. class CAttributeNode;
  20. //-----------------------------------------------------------------------------
  21. // CDependencyGraph class - sorts operators based upon the input/output graph
  22. //-----------------------------------------------------------------------------
  23. class CDependencyGraph
  24. {
  25. public:
  26. CDependencyGraph();
  27. ~CDependencyGraph();
  28. void Reset( const CUtlVector< IDmeOperator * > &operators );
  29. // caches only the operators that need to be evaluated, sorted by dependencies
  30. // returns true if a cycle found - in this case, an arbitrary link of the cycle will be ignored
  31. bool CullAndSortOperators();
  32. const CUtlVector< IDmeOperator* > &GetSortedOperators() const { return m_operators; }
  33. private:
  34. static bool GetOperatorOrdering( CUtlVector< COperatorNode* > &pOpNodes, CUtlVector< IDmeOperator * > &operators );
  35. static void DBG_PrintOperator( const char *pIndent, IDmeOperator *pOp );
  36. friend class CDmElementFramework;
  37. void Cleanup();
  38. void FindRoots();
  39. CAttributeNode *FindAttrNode( CDmAttribute *pAttr );
  40. CUtlVector< COperatorNode* > m_opRoots;
  41. // CUtlVector< COperatorNode* > m_opLeaves;
  42. CUtlVector< COperatorNode* > m_opNodes;
  43. CUtlHash< CAttributeNode* > m_attrNodes;
  44. CUtlVector< IDmeOperator* > m_operators;
  45. };
  46. #endif // DEPENDENCYGRAPH_H