summaryrefslogtreecommitdiff
path: root/datamodel/DmElementFramework.h
blob: 6cb9098ca98b157e3d67cc9a96675b685b03b3e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================

#ifndef DMELEMENTFRAMEWORK_H
#define DMELEMENTFRAMEWORK_H

#ifdef _WIN32
#pragma once
#endif

#include "datamodel/idatamodel.h"
#include "tier1/utlvector.h"
#include "dependencygraph.h"


//-----------------------------------------------------------------------------
// element framework implementation
//-----------------------------------------------------------------------------
class CDmElementFramework : public IDmElementFramework
{
public:
	CDmElementFramework();

public:
	// Methods of IAppSystem
	virtual bool Connect( CreateInterfaceFn factory );
	virtual void Disconnect();
	virtual void *QueryInterface( const char *pInterfaceName );
	virtual InitReturnVal_t Init();
	virtual void Shutdown();

	// Methods of IDmElementFramework
	virtual DmPhase_t GetPhase();
	virtual void SetOperators( const CUtlVector< IDmeOperator* > &operators );
	virtual void BeginEdit(); // ends in edit phase, forces apply/resolve if from edit phase
	virtual void Operate( bool bResolve ); // ends in output phase
	virtual void Resolve();

public:
	// Other public methods
	void AddElementToDirtyList( DmElementHandle_t hElement );
	void RemoveCleanElementsFromDirtyList();

	// Non-virtual methods of identical virtual functions
	DmPhase_t FastGetPhase();


private:
	void EditApply();

	// Invoke the resolve method
	void Resolve( bool clearDirtyFlags );

	CDependencyGraph m_dependencyGraph;
	CUtlVector< DmElementHandle_t > m_dirtyElements;
	DmPhase_t m_phase;
};


//-----------------------------------------------------------------------------
// Singleton
//-----------------------------------------------------------------------------
extern CDmElementFramework *g_pDmElementFrameworkImp;


//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline DmPhase_t CDmElementFramework::FastGetPhase()
{
	return m_phase;
}


#endif // DMELEMENTFRAMEWORK_H