summaryrefslogtreecommitdiff
path: root/datamodel/dependencygraph.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /datamodel/dependencygraph.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'datamodel/dependencygraph.h')
-rw-r--r--datamodel/dependencygraph.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/datamodel/dependencygraph.h b/datamodel/dependencygraph.h
new file mode 100644
index 0000000..1383c4a
--- /dev/null
+++ b/datamodel/dependencygraph.h
@@ -0,0 +1,62 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef DEPENDENCYGRAPH_H
+#define DEPENDENCYGRAPH_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "tier1/utlvector.h"
+#include "tier1/utlhash.h"
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CDmAttribute;
+class IDmeOperator;
+struct COperatorNode;
+class CAttributeNode;
+
+
+//-----------------------------------------------------------------------------
+// CDependencyGraph class - sorts operators based upon the input/output graph
+//-----------------------------------------------------------------------------
+class CDependencyGraph
+{
+public:
+ CDependencyGraph();
+ ~CDependencyGraph();
+
+ void Reset( const CUtlVector< IDmeOperator * > &operators );
+
+ // caches only the operators that need to be evaluated, sorted by dependencies
+ // returns true if a cycle found - in this case, an arbitrary link of the cycle will be ignored
+ bool CullAndSortOperators();
+
+ const CUtlVector< IDmeOperator* > &GetSortedOperators() const { return m_operators; }
+
+private:
+ static bool GetOperatorOrdering( CUtlVector< COperatorNode* > &pOpNodes, CUtlVector< IDmeOperator * > &operators );
+ static void DBG_PrintOperator( const char *pIndent, IDmeOperator *pOp );
+
+ friend class CDmElementFramework;
+
+ void Cleanup();
+ void FindRoots();
+ CAttributeNode *FindAttrNode( CDmAttribute *pAttr );
+
+ CUtlVector< COperatorNode* > m_opRoots;
+// CUtlVector< COperatorNode* > m_opLeaves;
+
+ CUtlVector< COperatorNode* > m_opNodes;
+
+ CUtlHash< CAttributeNode* > m_attrNodes;
+
+ CUtlVector< IDmeOperator* > m_operators;
+};
+
+#endif // DEPENDENCYGRAPH_H