Team Fortress 2 Source Code as on 22/4/2020
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.

527 lines
21 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef DATAMODEL_H
  7. #define DATAMODEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "datamodel/dmattribute.h"
  12. #include "datamodel/idatamodel.h"
  13. #include "datamodel/dmelement.h"
  14. #include "datamodel/dmehandle.h"
  15. #include "tier1/uniqueid.h"
  16. #include "tier1/utlsymbol.h"
  17. #include "tier1/utllinkedlist.h"
  18. #include "tier1/utldict.h"
  19. #include "tier1/utlstring.h"
  20. #include "tier1/utlhandletable.h"
  21. #include "tier1/utlhash.h"
  22. #include "tier2/tier2.h"
  23. #include "clipboardmanager.h"
  24. #include "undomanager.h"
  25. #include "tier1/convar.h"
  26. #include "tier0/vprof.h"
  27. //-----------------------------------------------------------------------------
  28. // forward declarations
  29. //-----------------------------------------------------------------------------
  30. class IDmElementFramework;
  31. class IUndoElement;
  32. class CDmElement;
  33. enum DmHandleReleasePolicy
  34. {
  35. HR_ALWAYS,
  36. HR_NEVER,
  37. HR_IF_NOT_REFERENCED,
  38. };
  39. //-----------------------------------------------------------------------------
  40. // memory categories
  41. //-----------------------------------------------------------------------------
  42. enum
  43. {
  44. MEMORY_CATEGORY_OUTER,
  45. MEMORY_CATEGORY_ELEMENT_INTERNAL,
  46. MEMORY_CATEGORY_DATAMODEL,
  47. MEMORY_CATEGORY_REFERENCES,
  48. MEMORY_CATEGORY_ATTRIBUTE_TREE,
  49. MEMORY_CATEGORY_ATTRIBUTE_OVERHEAD,
  50. MEMORY_CATEGORY_ATTRIBUTE_DATA,
  51. MEMORY_CATEGORY_ATTRIBUTE_COUNT,
  52. MEMORY_CATEGORY_COUNT,
  53. };
  54. //-----------------------------------------------------------------------------
  55. // hash map of id->element, with the id storage optimized out
  56. //-----------------------------------------------------------------------------
  57. class CElementIdHash : public CUtlHash< DmElementHandle_t >
  58. {
  59. public:
  60. CElementIdHash( int nBucketCount = 0, int nGrowCount = 0, int nInitCount = 0 )
  61. : CUtlHash< DmElementHandle_t >( nBucketCount, nGrowCount, nInitCount, CompareFunc, KeyFunc )
  62. {
  63. }
  64. protected:
  65. typedef CUtlHash< DmElementHandle_t > BaseClass;
  66. static bool CompareFunc( DmElementHandle_t const& a, DmElementHandle_t const& b ) { return a == b; }
  67. static bool IdCompareFunc( DmElementHandle_t const& hElement, DmObjectId_t const& id )
  68. {
  69. CDmElement *pElement = g_pDataModel->GetElement( hElement );
  70. Assert( pElement );
  71. if ( !pElement )
  72. return false;
  73. return IsUniqueIdEqual( id, pElement->GetId() );
  74. }
  75. static unsigned int KeyFunc( DmElementHandle_t const& hElement )
  76. {
  77. CDmElement *pElement = g_pDataModel->GetElement( hElement );
  78. Assert( pElement );
  79. if ( !pElement )
  80. return 0;
  81. return *( unsigned int* )&pElement->GetId();
  82. }
  83. static unsigned int IdKeyFunc( DmObjectId_t const &src )
  84. {
  85. return *(unsigned int*)&src;
  86. }
  87. protected:
  88. bool DoFind( DmObjectId_t const &src, unsigned int *pBucket, int *pIndex )
  89. {
  90. // generate the data "key"
  91. unsigned int key = IdKeyFunc( src );
  92. // hash the "key" - get the correct hash table "bucket"
  93. unsigned int ndxBucket;
  94. if( m_bPowerOfTwo )
  95. {
  96. *pBucket = ndxBucket = ( key & m_ModMask );
  97. }
  98. else
  99. {
  100. int bucketCount = m_Buckets.Count();
  101. *pBucket = ndxBucket = key % bucketCount;
  102. }
  103. int ndxKeyData;
  104. CUtlVector< DmElementHandle_t > &bucket = m_Buckets[ndxBucket];
  105. int keyDataCount = bucket.Count();
  106. for( ndxKeyData = 0; ndxKeyData < keyDataCount; ndxKeyData++ )
  107. {
  108. if( IdCompareFunc( bucket.Element( ndxKeyData ), src ) )
  109. break;
  110. }
  111. if( ndxKeyData == keyDataCount )
  112. return false;
  113. *pIndex = ndxKeyData;
  114. return true;
  115. }
  116. public:
  117. UtlHashHandle_t Find( DmElementHandle_t const &src ) { return BaseClass::Find( src ); }
  118. UtlHashHandle_t Find( DmObjectId_t const &src )
  119. {
  120. unsigned int ndxBucket;
  121. int ndxKeyData;
  122. if ( DoFind( src, &ndxBucket, &ndxKeyData ) )
  123. return BuildHandle( ndxBucket, ndxKeyData );
  124. return InvalidHandle();
  125. }
  126. };
  127. //-----------------------------------------------------------------------------
  128. // struct to hold the set of elements in any given file
  129. //-----------------------------------------------------------------------------
  130. struct FileElementSet_t
  131. {
  132. FileElementSet_t( UtlSymId_t filename = UTL_INVAL_SYMBOL, UtlSymId_t format = UTL_INVAL_SYMBOL ) :
  133. m_filename( filename ), m_format( format ),
  134. m_hRoot( DMELEMENT_HANDLE_INVALID ),
  135. m_bLoaded( true ),
  136. m_nElements( 0 )
  137. {
  138. }
  139. FileElementSet_t( const FileElementSet_t& that ) : m_filename( that.m_filename ), m_format( that.m_format ), m_hRoot( DMELEMENT_HANDLE_INVALID ), m_bLoaded( that.m_bLoaded ), m_nElements( that.m_nElements )
  140. {
  141. // the only time this should be copy constructed is when passing in an empty set to the parent array
  142. // otherwise it could get prohibitively expensive time and memory wise
  143. Assert( that.m_nElements == 0 );
  144. }
  145. UtlSymId_t m_filename;
  146. UtlSymId_t m_format;
  147. CDmeCountedHandle m_hRoot;
  148. bool m_bLoaded;
  149. int m_nElements;
  150. };
  151. //-----------------------------------------------------------------------------
  152. // Purpose: Versionable factor for element types
  153. //-----------------------------------------------------------------------------
  154. class CDataModel : public CBaseAppSystem< IDataModel >
  155. {
  156. typedef CBaseAppSystem< IDataModel > BaseClass;
  157. public:
  158. CDataModel();
  159. virtual ~CDataModel();
  160. // External interface
  161. public:
  162. // Methods of IAppSystem
  163. virtual bool Connect( CreateInterfaceFn factory );
  164. virtual void *QueryInterface( const char *pInterfaceName );
  165. virtual InitReturnVal_t Init();
  166. virtual void Shutdown();
  167. // Methods of IDataModel
  168. virtual void AddElementFactory( const char *pClassName, IDmElementFactory *pFactory );
  169. virtual bool HasElementFactory( const char *pElementType ) const;
  170. virtual void SetDefaultElementFactory( IDmElementFactory *pFactory );
  171. virtual int GetFirstFactory() const;
  172. virtual int GetNextFactory( int index ) const;
  173. virtual bool IsValidFactory( int index ) const;
  174. virtual char const *GetFactoryName( int index ) const;
  175. virtual DmElementHandle_t CreateElement( UtlSymId_t typeSymbol, const char *pElementName, DmFileId_t fileid, const DmObjectId_t *pObjectID = NULL );
  176. virtual DmElementHandle_t CreateElement( const char *pTypeName, const char *pElementName, DmFileId_t fileid, const DmObjectId_t *pObjectID = NULL );
  177. virtual void DestroyElement( DmElementHandle_t hElement );
  178. virtual CDmElement* GetElement( DmElementHandle_t hElement ) const;
  179. virtual UtlSymId_t GetElementType( DmElementHandle_t hElement ) const;
  180. virtual const char* GetElementName( DmElementHandle_t hElement ) const;
  181. virtual const DmObjectId_t& GetElementId( DmElementHandle_t hElement ) const;
  182. virtual const char *GetAttributeNameForType( DmAttributeType_t attType ) const;
  183. virtual DmAttributeType_t GetAttributeTypeForName( const char *name ) const;
  184. virtual void AddSerializer( IDmSerializer *pSerializer );
  185. virtual void AddLegacyUpdater( IDmLegacyUpdater *pUpdater );
  186. virtual void AddFormatUpdater( IDmFormatUpdater *pUpdater );
  187. virtual const char* GetFormatExtension( const char *pFormatName );
  188. virtual const char* GetFormatDescription( const char *pFormatName );
  189. virtual int GetFormatCount() const;
  190. virtual const char * GetFormatName( int i ) const;
  191. virtual const char * GetDefaultEncoding( const char *pFormatName );
  192. virtual int GetEncodingCount() const;
  193. virtual const char * GetEncodingName( int i ) const;
  194. virtual bool IsEncodingBinary( const char *pEncodingName ) const;
  195. virtual bool DoesEncodingStoreVersionInFile( const char *pEncodingName ) const;
  196. virtual void SetSerializationDelimiter( CUtlCharConversion *pConv );
  197. virtual void SetSerializationArrayDelimiter( const char *pDelimiter );
  198. virtual bool IsUnserializing();
  199. virtual bool Serialize( CUtlBuffer &outBuf, const char *pEncodingName, const char *pFormatName, DmElementHandle_t hRoot );
  200. virtual bool Unserialize( CUtlBuffer &buf, const char *pEncodingName, const char *pSourceFormatName, const char *pFormatHint,
  201. const char *pFileName, DmConflictResolution_t idConflictResolution, DmElementHandle_t &hRoot );
  202. virtual bool UpdateUnserializedElements( const char *pSourceFormatName, int nSourceFormatVersion,
  203. DmFileId_t fileid, DmConflictResolution_t idConflictResolution, CDmElement **ppRoot );
  204. virtual IDmSerializer* FindSerializer( const char *pEncodingName ) const;
  205. virtual IDmLegacyUpdater* FindLegacyUpdater( const char *pLegacyFormatName ) const;
  206. virtual IDmFormatUpdater* FindFormatUpdater( const char *pFormatName ) const;
  207. virtual bool SaveToFile( char const *pFileName, char const *pPathID, const char *pEncodingName, const char *pFormatName, CDmElement *pRoot );
  208. virtual DmFileId_t RestoreFromFile( char const *pFileName, char const *pPathID, const char *pFormatHint, CDmElement **ppRoot, DmConflictResolution_t idConflictResolution = CR_DELETE_NEW, DmxHeader_t *pHeaderOut = NULL );
  209. virtual void SetKeyValuesElementCallback( IElementForKeyValueCallback *pCallbackInterface );
  210. virtual const char * GetKeyValuesElementName( const char *pszKeyName, int iNestingLevel );
  211. virtual UtlSymId_t GetSymbol( const char *pString );
  212. virtual const char * GetString( UtlSymId_t sym ) const;
  213. virtual int GetElementsAllocatedSoFar();
  214. virtual int GetMaxNumberOfElements();
  215. virtual int GetAllocatedAttributeCount();
  216. virtual int GetAllocatedElementCount();
  217. virtual DmElementHandle_t FirstAllocatedElement();
  218. virtual DmElementHandle_t NextAllocatedElement( DmElementHandle_t hElement );
  219. virtual int EstimateMemoryUsage( DmElementHandle_t hElement, TraversalDepth_t depth = TD_DEEP );
  220. virtual void SetUndoEnabled( bool enable );
  221. virtual bool IsUndoEnabled() const;
  222. virtual bool UndoEnabledForElement( const CDmElement *pElement ) const;
  223. virtual bool IsDirty() const;
  224. virtual bool CanUndo() const;
  225. virtual bool CanRedo() const;
  226. virtual void StartUndo( const char *undodesc, const char *redodesc, int nChainingID = 0 );
  227. virtual void FinishUndo();
  228. virtual void AbortUndoableOperation();
  229. virtual void ClearRedo();
  230. virtual const char *GetUndoDesc();
  231. virtual const char *GetRedoDesc();
  232. virtual void Undo();
  233. virtual void Redo();
  234. virtual void TraceUndo( bool state ); // if true, undo records spew as they are added
  235. virtual void ClearUndo();
  236. virtual void GetUndoInfo( CUtlVector< UndoInfo_t >& list );
  237. virtual const char * GetUndoString( UtlSymId_t sym );
  238. virtual void AddUndoElement( IUndoElement *pElement );
  239. virtual UtlSymId_t GetUndoDescInternal( const char *context );
  240. virtual UtlSymId_t GetRedoDescInternal( const char *context );
  241. virtual void EmptyClipboard();
  242. virtual void SetClipboardData( CUtlVector< KeyValues * >& data, IClipboardCleanup *pfnOptionalCleanuFunction = 0 );
  243. virtual void AddToClipboardData( KeyValues *add );
  244. virtual void GetClipboardData( CUtlVector< KeyValues * >& data );
  245. virtual bool HasClipboardData() const;
  246. virtual CDmAttribute * GetAttribute( DmAttributeHandle_t h );
  247. virtual bool IsAttributeHandleValid( DmAttributeHandle_t h ) const;
  248. virtual void OnlyCreateUntypedElements( bool bEnable );
  249. virtual int NumFileIds();
  250. virtual DmFileId_t GetFileId( int i );
  251. virtual DmFileId_t FindOrCreateFileId( const char *pFilename );
  252. virtual void RemoveFileId( DmFileId_t fileid );
  253. virtual DmFileId_t GetFileId( const char *pFilename );
  254. virtual const char * GetFileName( DmFileId_t fileid );
  255. virtual void SetFileName( DmFileId_t fileid, const char *pFileName );
  256. virtual const char * GetFileFormat( DmFileId_t fileid );
  257. virtual void SetFileFormat( DmFileId_t fileid, const char *pFormat );
  258. virtual DmElementHandle_t GetFileRoot( DmFileId_t fileid );
  259. virtual void SetFileRoot( DmFileId_t fileid, DmElementHandle_t hRoot );
  260. virtual bool IsFileLoaded( DmFileId_t fileid );
  261. virtual void MarkFileLoaded( DmFileId_t fileid );
  262. virtual void UnloadFile( DmFileId_t fileid );
  263. virtual int NumElementsInFile( DmFileId_t fileid );
  264. virtual void DontAutoDelete( DmElementHandle_t hElement );
  265. virtual void MarkHandleInvalid( DmElementHandle_t hElement );
  266. virtual void MarkHandleValid( DmElementHandle_t hElement );
  267. virtual DmElementHandle_t FindElement( const DmObjectId_t &id );
  268. virtual DmAttributeReferenceIterator_t FirstAttributeReferencingElement( DmElementHandle_t hElement );
  269. virtual DmAttributeReferenceIterator_t NextAttributeReferencingElement( DmAttributeReferenceIterator_t hAttrIter );
  270. virtual CDmAttribute * GetAttribute( DmAttributeReferenceIterator_t hAttrIter );
  271. virtual bool InstallNotificationCallback( IDmNotify *pNotify );
  272. virtual void RemoveNotificationCallback( IDmNotify *pNotify );
  273. virtual bool IsSuppressingNotify( ) const;
  274. virtual void SetSuppressingNotify( bool bSuppress );
  275. virtual void PushNotificationScope( const char *pReason, int nNotifySource, int nNotifyFlags );
  276. virtual void PopNotificationScope( bool bAbort );
  277. virtual void SetUndoDepth( int nSize );
  278. virtual void DisplayMemoryStats();
  279. public:
  280. // Internal public methods
  281. int GetCurrentFormatVersion( const char *pFormatName );
  282. // CreateElement references the attribute list passed in via ref, so don't edit or purge ref's attribute list afterwards
  283. CDmElement* CreateElement( const DmElementReference_t &ref, const char *pElementType, const char *pElementName, DmFileId_t fileid, const DmObjectId_t *pObjectID );
  284. void DeleteElement( DmElementHandle_t hElement, DmHandleReleasePolicy hrp = HR_ALWAYS );
  285. // element handle related methods
  286. DmElementHandle_t AcquireElementHandle();
  287. void ReleaseElementHandle( DmElementHandle_t hElement );
  288. // Handles to attributes
  289. DmAttributeHandle_t AcquireAttributeHandle( CDmAttribute *pAttribute );
  290. void ReleaseAttributeHandle( DmAttributeHandle_t hAttribute );
  291. // remove orphaned element subtrees
  292. void FindAndDeleteOrphanedElements();
  293. // Event "mailing list"
  294. DmMailingList_t CreateMailingList();
  295. void DestroyMailingList( DmMailingList_t list );
  296. void AddElementToMailingList( DmMailingList_t list, DmElementHandle_t h );
  297. // Returns false if the mailing list is empty now
  298. bool RemoveElementFromMailingList( DmMailingList_t list, DmElementHandle_t h );
  299. // Returns false if the mailing list is empty now (can happen owing to stale attributes)
  300. bool PostAttributeChanged( DmMailingList_t list, CDmAttribute *pAttribute );
  301. void GetInvalidHandles( CUtlVector< DmElementHandle_t > &handles );
  302. void MarkHandlesValid( CUtlVector< DmElementHandle_t > &handles );
  303. void MarkHandlesInvalid( CUtlVector< DmElementHandle_t > &handles );
  304. // search id->handle table (both loaded and unloaded) for id, and if not found, create a new handle, map it to the id and return it
  305. DmElementHandle_t FindOrCreateElementHandle( const DmObjectId_t &id );
  306. // changes an element's id and associated mappings - generally during unserialization
  307. DmElementHandle_t ChangeElementId( DmElementHandle_t hElement, const DmObjectId_t &oldId, const DmObjectId_t &newId );
  308. DmElementReference_t *FindElementReference( DmElementHandle_t hElement, DmObjectId_t **ppId = NULL );
  309. void RemoveUnreferencedElements();
  310. void RemoveElementFromFile( DmElementHandle_t hElement, DmFileId_t fileid );
  311. void AddElementToFile( DmElementHandle_t hElement, DmFileId_t fileid );
  312. void NotifyState( int nNotifyFlags );
  313. int EstimateMemoryOverhead() const;
  314. bool IsCreatingUntypedElements() const { return m_bOnlyCreateUntypedElements; }
  315. unsigned short GetSymbolCount() const;
  316. private:
  317. struct MailingList_t
  318. {
  319. CUtlVector<DmElementHandle_t> m_Elements;
  320. };
  321. struct ElementIdHandlePair_t
  322. {
  323. DmObjectId_t m_id;
  324. DmElementReference_t m_ref;
  325. ElementIdHandlePair_t() {}
  326. explicit ElementIdHandlePair_t( const DmObjectId_t &id ) : m_ref()
  327. {
  328. CopyUniqueId( id, &m_id );
  329. }
  330. ElementIdHandlePair_t( const DmObjectId_t &id, const DmElementReference_t &ref ) : m_ref( ref )
  331. {
  332. CopyUniqueId( id, &m_id );
  333. }
  334. ElementIdHandlePair_t( const ElementIdHandlePair_t& that ) : m_ref( that.m_ref )
  335. {
  336. CopyUniqueId( that.m_id, &m_id );
  337. }
  338. ElementIdHandlePair_t &operator=( const ElementIdHandlePair_t &that )
  339. {
  340. CopyUniqueId( that.m_id, &m_id );
  341. m_ref = that.m_ref;
  342. return *this;
  343. }
  344. static unsigned int HashKey( const ElementIdHandlePair_t& that )
  345. {
  346. return *( unsigned int* )&that.m_id.m_Value;
  347. }
  348. static bool Compare( const ElementIdHandlePair_t& a, const ElementIdHandlePair_t& b )
  349. {
  350. return IsUniqueIdEqual( a.m_id, b.m_id );
  351. }
  352. };
  353. private:
  354. CDmElement *Unserialize( CUtlBuffer& buf );
  355. void Serialize( CDmElement *element, CUtlBuffer& buf );
  356. // Read the header, return the version (or false if it's not a DMX file)
  357. bool ReadDMXHeader( CUtlBuffer &inBuf, DmxHeader_t *pHeader ) const;
  358. const char *GetEncodingFromLegacyFormat( const char *pLegacyFormatName ) const;
  359. bool IsValidNonDMXFormat( const char *pFormatName ) const;
  360. bool IsLegacyFormat( const char *pFormatName ) const;
  361. // Returns the current undo manager
  362. CUndoManager* GetUndoMgr();
  363. const CUndoManager* GetUndoMgr() const;
  364. CClipboardManager *GetClipboardMgr();
  365. const CClipboardManager *GetClipboardMgr() const;
  366. void UnloadFile( DmFileId_t fileid, bool bDeleteElements );
  367. friend class CDmeElementRefHelper;
  368. friend class CDmAttribute;
  369. template< class T > friend class CDmArrayAttributeOp;
  370. void OnElementReferenceAdded ( DmElementHandle_t hElement, CDmAttribute *pAttribute );
  371. void OnElementReferenceRemoved( DmElementHandle_t hElement, CDmAttribute *pAttribute );
  372. void OnElementReferenceAdded ( DmElementHandle_t hElement, bool bRefCount );
  373. void OnElementReferenceRemoved( DmElementHandle_t hElement, bool bRefCount );
  374. private:
  375. CUtlVector< IDmSerializer* > m_Serializers;
  376. CUtlVector< IDmLegacyUpdater* > m_LegacyUpdaters;
  377. CUtlVector< IDmFormatUpdater* > m_FormatUpdaters;
  378. IDmElementFactory *m_pDefaultFactory;
  379. CUtlDict< IDmElementFactory*, int > m_Factories;
  380. CUtlSymbolTable m_SymbolTable;
  381. CUtlHandleTable< CDmElement, 20 > m_Handles;
  382. CUtlHandleTable< CDmAttribute, 20 > m_AttributeHandles;
  383. CUndoManager m_UndoMgr;
  384. CUtlLinkedList< MailingList_t, DmMailingList_t > m_MailingLists;
  385. bool m_bIsUnserializing : 1;
  386. bool m_bUnableToSetDefaultFactory : 1;
  387. bool m_bOnlyCreateUntypedElements : 1;
  388. bool m_bUnableToCreateOnlyUntypedElements : 1;
  389. bool m_bDeleteOrphanedElements : 1;
  390. CUtlHandleTable< FileElementSet_t, 20 > m_openFiles;
  391. CElementIdHash m_elementIds;
  392. CUtlHash< ElementIdHandlePair_t > m_unloadedIdElementMap;
  393. CUtlVector< DmObjectId_t > m_unreferencedElementIds;
  394. CUtlVector< DmElementHandle_t > m_unreferencedElementHandles;
  395. CClipboardManager m_ClipboardMgr;
  396. IElementForKeyValueCallback *m_pKeyvaluesCallbackInterface;
  397. int m_nElementsAllocatedSoFar;
  398. int m_nMaxNumberOfElements;
  399. };
  400. //-----------------------------------------------------------------------------
  401. // Singleton
  402. //-----------------------------------------------------------------------------
  403. extern CDataModel *g_pDataModelImp;
  404. //-----------------------------------------------------------------------------
  405. // Inline methods
  406. //-----------------------------------------------------------------------------
  407. inline CUndoManager* CDataModel::GetUndoMgr()
  408. {
  409. return &m_UndoMgr;
  410. }
  411. inline const CUndoManager* CDataModel::GetUndoMgr() const
  412. {
  413. return &m_UndoMgr;
  414. }
  415. inline void CDataModel::NotifyState( int nNotifyFlags )
  416. {
  417. GetUndoMgr()->NotifyState( nNotifyFlags );
  418. }
  419. inline CClipboardManager *CDataModel::GetClipboardMgr()
  420. {
  421. return &m_ClipboardMgr;
  422. }
  423. inline const CClipboardManager *CDataModel::GetClipboardMgr() const
  424. {
  425. return &m_ClipboardMgr;
  426. }
  427. //-----------------------------------------------------------------------------
  428. // Methods of DmElement which are public to datamodel
  429. //-----------------------------------------------------------------------------
  430. class CDmeElementAccessor
  431. {
  432. public:
  433. static void Purge( CDmElement *pElement ) { pElement->Purge(); }
  434. static void SetId( CDmElement *pElement, const DmObjectId_t &id ) { pElement->SetId( id ); }
  435. static bool IsDirty( const CDmElement *pElement ) { return pElement->IsDirty(); }
  436. static void MarkDirty( CDmElement *pElement, bool dirty = true ) { pElement->MarkDirty( dirty ); }
  437. static void MarkAttributesClean( CDmElement *pElement ) { pElement->MarkAttributesClean(); }
  438. static void MarkBeingUnserialized( CDmElement *pElement, bool beingUnserialized = true ) { pElement->MarkBeingUnserialized( beingUnserialized ); }
  439. static bool IsBeingUnserialized( const CDmElement *pElement ) { return pElement->IsBeingUnserialized(); }
  440. static void AddAttributeByPtr( CDmElement *pElement, CDmAttribute *ptr ) { pElement->AddAttributeByPtr( ptr ); }
  441. static void RemoveAttributeByPtrNoDelete( CDmElement *pElement, CDmAttribute *ptr ) { pElement->RemoveAttributeByPtrNoDelete( ptr); }
  442. static void ChangeHandle( CDmElement *pElement, DmElementHandle_t handle ) { pElement->ChangeHandle( handle ); }
  443. static DmElementReference_t *GetReference( CDmElement *pElement ) { return pElement->GetReference(); }
  444. static void SetReference( CDmElement *pElement, const DmElementReference_t &ref ) { pElement->SetReference( ref ); }
  445. static int EstimateMemoryUsage( CDmElement *pElement, CUtlHash< DmElementHandle_t > &visited, TraversalDepth_t depth, int *pCategories ) { return pElement->EstimateMemoryUsage( visited, depth, pCategories ); }
  446. static void PerformConstruction( CDmElement *pElement ) { pElement->PerformConstruction(); }
  447. static void PerformDestruction( CDmElement *pElement ) { pElement->PerformDestruction(); }
  448. };
  449. #endif // DATAMODEL_H