BVB Source Codes

CRYENGINE Show FlowBaseXmlNode.cpp Source code

Return Download CRYENGINE: download FlowBaseXmlNode.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   FlowBaseXmlNode.cpp
  5. //  Description: Flowgraph nodes to read/write Xml files
  6. // -------------------------------------------------------------------------
  7. //  History:
  8. //    - 8/16/08 : File created - Kevin Kirst
  9. //    - 09/06/2011: Added to SDK - Sascha Hoba
  10. ////////////////////////////////////////////////////////////////////////////
  11.  
  12. #include "StdAfx.h"
  13. #include "FlowBaseXmlNode.h"
  14.  
  15. CGraphDocManager* CGraphDocManager::m_instance = NULL;
  16. CGraphDocManager* GDM = NULL;
  17.  
  18. ////////////////////////////////////////////////////
  19. CFlowXmlNode_Base::CFlowXmlNode_Base(SActivationInfo* pActInfo) : m_initialized(false)
  20. {
  21.  
  22. }
  23.  
  24. ////////////////////////////////////////////////////
  25. CFlowXmlNode_Base::~CFlowXmlNode_Base(void)
  26. {
  27.         if (GDM == NULL)
  28.                 return;
  29.  
  30.         if (m_actInfo.pGraph == NULL)
  31.                 return;
  32.  
  33.         GDM->DeleteXmlDocument(m_actInfo.pGraph);
  34. }
  35.  
  36. ////////////////////////////////////////////////////
  37. void CFlowXmlNode_Base::ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo)
  38. {
  39.         m_actInfo = *pActInfo;
  40.         if (eFE_Initialize == event && !m_initialized)
  41.         {
  42.                 if (GDM == NULL)
  43.                 {
  44.                         CGraphDocManager::Create();
  45.                 }
  46.  
  47.                 m_initialized = true;
  48.                 PREFAST_SUPPRESS_WARNING(6011); // gets initialized above if NULL
  49.                 GDM->MakeXmlDocument(pActInfo->pGraph);
  50.         }
  51.         else if (eFE_Activate == event && IsPortActive(pActInfo, EIP_Execute))
  52.         {
  53.                 const bool bResult = Execute(pActInfo);
  54.                 if (bResult) ActivateOutput(pActInfo, EOP_Success, true);
  55.                 else ActivateOutput(pActInfo, EOP_Fail, true);
  56.                 ActivateOutput(pActInfo, EOP_Done, bResult);
  57.         }
  58. }
  59.  
  60. ////////////////////////////////////////////////////
  61. ////////////////////////////////////////////////////
  62.  
  63. ////////////////////////////////////////////////////
  64. CGraphDocManager::CGraphDocManager()
  65. {
  66.  
  67. }
  68.  
  69. ////////////////////////////////////////////////////
  70. CGraphDocManager::~CGraphDocManager()
  71. {
  72.  
  73. }
  74.  
  75. ////////////////////////////////////////////////////
  76. void CGraphDocManager::Create()
  77. {
  78.         if (!m_instance)
  79.         {
  80.                 m_instance = new CGraphDocManager;
  81.                 GDM = m_instance;
  82.         }
  83. }
  84.  
  85. ////////////////////////////////////////////////////
  86. CGraphDocManager* CGraphDocManager::Get()
  87. {
  88.         return m_instance;
  89. }
  90.  
  91. ////////////////////////////////////////////////////
  92. void CGraphDocManager::MakeXmlDocument(IFlowGraph* pGraph)
  93. {
  94.         GraphDocMap::iterator graph = m_GraphDocMap.find(pGraph);
  95.         if (graph == m_GraphDocMap.end())
  96.         {
  97.                 SXmlDocument doc;
  98.                 doc.root = doc.active = NULL;
  99.                 doc.refCount = 1;
  100.                 m_GraphDocMap[pGraph] = doc;
  101.         }
  102.         else
  103.         {
  104.                 ++graph->second.refCount;
  105.         }
  106. }
  107.  
  108. ////////////////////////////////////////////////////
  109. void CGraphDocManager::DeleteXmlDocument(IFlowGraph* pGraph)
  110. {
  111.         GraphDocMap::iterator graph = m_GraphDocMap.find(pGraph);
  112.         if (graph != m_GraphDocMap.end() && --graph->second.refCount <= 0)
  113.         {
  114.                 m_GraphDocMap.erase(graph);
  115.         }
  116. }
  117.  
  118. ////////////////////////////////////////////////////
  119. bool CGraphDocManager::GetXmlDocument(IFlowGraph* pGraph, SXmlDocument** document)
  120. {
  121.         bool bResult = false;
  122.  
  123.         GraphDocMap::iterator graph = m_GraphDocMap.find(pGraph);
  124.         if (document && graph != m_GraphDocMap.end())
  125.         {
  126.                 *document = &(graph->second);
  127.                 bResult = true;
  128.         }
  129.  
  130.         return bResult;
  131. }
  132.  
downloadFlowBaseXmlNode.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top