_MEMBER_FUNCTION_IMPL(xml, getNodeAttribute) { // Get the XML instance pointer CXML * pXML = sq_getinstance< CXML* >( pVM ); // Is the xml instance valid? if( pXML ) { // Get the XML node pointer CXMLNode * pNode = sq_getpointer< CXMLNode* >( pVM, 2 ); // Is the node valid? if( pNode ) { // Get the attribute name const char * szName; sq_getstring( pVM, 3, &szName ); // Get the attribute value const char * szValue = pNode->GetAttribute( szName ); sq_pushstring( pVM, szValue, strlen(szValue) ); return 1; } } sq_pushbool( pVM, false ); return 1; }
Bool CMaterialResource::Init() { CXMLDocument document; document.Load( m_FilePath.c_str() ); CXMLNode rootNode = document.GetRootNode(); //Read out textures CXMLNode childNode = rootNode.GetChildNode( "Texture2D" ); while ( childNode.IsEmpty() == false ) { CXMLAttribute attribute = childNode.GetAttribute( "Hash" ); const Uint hash = (Uint)strtoul( attribute.GetValue(), NULL, 0 ); AddDependentHash( hash ); childNode = childNode.GetNextSibling(); } if ( m_DependenciesLeft == 0 ) { return true; } return false; }
CXMLNode* CFactory::GetPrototypeXML(const string &AName) { CPrototype *proto = Get<CPrototype>(AName); if (!proto) { Log("ERROR", "No such prototype: '%s'", AName.c_str()); return NULL; } CXMLNode *xml = proto->GetRootNode(); if (xml->IsErroneous() || !xml->HasAttribute("Name") || xml->GetAttribute("Name") != AName) { Log("ERROR", "Prototype '%s' XML contains an error", AName.c_str()); return NULL; } return xml; }
/** * expand parallel. * * copies expand attribute from old node to new node and call function * recursively for children. * stops, if number of children is not equal. * * @param rtNodeNew: new node * @param rtNodeNew: old node * @return - * @exception - * @see - */ void CInstanceTree::ExpandParallel(CXMLNode& rtNodeNew, CXMLNode& rtNodeOld) { CXMLNode tNodeChildNew; CXMLNode tNodeChildOld; CXMLNodeList tChildListNew; CXMLNodeList tChildListOld; long lNumChildrenNew; long lNumChildrenOld; long lChild; CString strExpanded; if(rtNodeOld.GetAttribute(CE_XMLATTR_EXPANDED, strExpanded)) { rtNodeNew.SetAttribute(CE_XMLATTR_EXPANDED, strExpanded); } if(!rtNodeNew.GetChildNodeList(tChildListNew) || !rtNodeOld.GetChildNodeList(tChildListOld)) { return; } lNumChildrenNew = tChildListNew.GetLength(); lNumChildrenOld = tChildListOld.GetLength(); if(lNumChildrenNew != lNumChildrenOld) { return; } for(lChild = 0; lChild < lNumChildrenNew; ++lChild) { if(tChildListNew.Item(lChild, tNodeChildNew) && tChildListOld.Item(lChild, tNodeChildOld)) { ExpandParallel(tNodeChildNew, tNodeChildOld); } } }
void CCameraSceneNode::Load( const CXMLNode& a_XMLNode ) { LoadCommonValues( a_XMLNode ); LoadChildren( a_XMLNode ); // Do own stuff m_Camera = new CCamera(); float FOV, screenHeight, screenWidth, aspectRatio, nearPlaneDist, farPlaneDist; CXMLAttribute attribute = a_XMLNode.GetAttribute( "Active" ); m_Active = (bool)atoi( attribute.GetValue( "0" ) ); attribute = a_XMLNode.GetAttribute( "FOV" ); FOV = (float)atof( attribute.GetValue( "60" ) ); attribute = a_XMLNode.GetAttribute( "ScrHeight" ); screenHeight = (float)atof( attribute.GetValue( "3" ) ); attribute = a_XMLNode.GetAttribute( "ScrWidth" ); screenWidth = (float)atof( attribute.GetValue( "4" ) ); attribute = a_XMLNode.GetAttribute( "Near" ); nearPlaneDist = (float)atof( attribute.GetValue( "0.1" ) ); attribute = a_XMLNode.GetAttribute( "Far" ); farPlaneDist = (float)atof( attribute.GetValue( "100.0" ) ); aspectRatio = screenWidth / screenHeight; printf( "Loaded camera %s, FOV %.1f, Aspect %.4f, Near %.5f, Far %.3f, Active %i\n", m_Name.c_str(), FOV, aspectRatio, nearPlaneDist, farPlaneDist, m_Active ); glm::mat4 perspectiveMatrix = glm::perspective( FOV, aspectRatio, nearPlaneDist, farPlaneDist ); perspectiveMatrix[1].y *= -1.0f; m_Camera->SetProjectionMatrix( perspectiveMatrix ); m_Camera->SetTransformationMatrix( m_WorldMatrix ); m_Camera->SetPosition( m_Position ); m_Camera->SetRotation( m_Rotation ); m_Camera->SetFarPlaneDistance( farPlaneDist ); m_Camera->SetNearPlaneDistance( nearPlaneDist ); }
bool CResourceManager::StartResource( const char * szResource ) { // Is the resource already running? if( IsResourceRunning( szResource ) ) { CLogFile::Printf( "Failed to start resource '%s'. (Resource is already running)", szResource ); return false; } // Get the resource path String strPath( "resources/%s", szResource ); // Does the path not exist? if( !SharedUtility::Exists( strPath.Get() ) ) { CLogFile::Printf( "Failed to load resource '%s'. (Path doesn't exist)", szResource ); return false; } // Get the meta file String strMeta( "%s/meta.xml", strPath.Get() ); // Does the file not exist? if( !SharedUtility::Exists( strMeta.Get() ) ) { CLogFile::Printf( "Failed to load resource '%s'. (Can't find meta.xml)", szResource ); return false; } // Load the XML file CXML * pFile = new CXML( strMeta.Get() ); // Is the file invalid? if( !pFile ) return false; // Create the resource structure SResource resource; resource.strName.Set ( szResource ); resource.strPath = strPath; resource.iScripts = 0; resource.iFiles = 0; // Get the root node CXMLNode * pRootNode = pFile->GetRootNode(); // Is the root node invalid? if( !pRootNode ) { // Delete the xml file SAFE_DELETE( pFile ); return false; } // Get all the root node children std::list< CXMLNode* > children = pRootNode->GetChildren(); // Loop all the children in the root node for( std::list< CXMLNode* >::iterator iter = children.begin(); iter != children.end(); iter++ ) { // Get a pointer to the current node CXMLNode * pCurNode = *iter; // Is the current node valid? if( pCurNode ) { // Get the current node type const char * szNodeType = pCurNode->GetName(); // Get the current node data const char * szNodeData = pCurNode->GetValue(); // Is this node a script? if( !strcmp( szNodeType, "script" ) ) { // Create the script struct SScript script; // Set the script name script.strName.Set ( szNodeData ); // Set the script type const char * szScriptType = pCurNode->GetAttribute( "type" ); // Update the path strPath.Format( "resources/%s/%s", szResource, szScriptType ); // Is this a client script? if( !strcmp( szScriptType, "client" ) ) { // Load the clientscript if( !pCore->GetClientScriptingManager()->Start( szNodeData, strPath ) ) continue; // Set the script type script.eType = E_SCRIPT_CLIENT; // Increase the resource script count resource.iScripts++; } else if( !strcmp( szScriptType, "server" ) ) { // Load the script CSquirrel * pScript = pCore->GetScriptingManager()->Load( szNodeData, String( "%s/%s", strPath.Get(), szNodeData ) ); // Did the script fail to load? if( !pScript ) continue; // Set the script type script.eType = E_SCRIPT_SERVER; // Increase the resource script count resource.iScripts++; } else { SAFE_DELETE( pFile ); CLogFile::Printf( "WARNING: Unknown script type '%s' in resource '%s'.", szScriptType, szResource ); continue; } // Add this script to the resource's script list resource.scripts.push_back( script ); } else if( !strcmp( szNodeType, "file" ) ) { // Update the path strPath.Format( "resources/%s/files", szResource ); // Load the file with the client scripting manager if( !pCore->GetClientScriptingManager()->Start( szNodeData, strPath ) ) continue; // Increase the resource file count resource.iFiles++; } } } // Add this to the resource list m_resourceList.push_back( resource ); return true; }
bool CBanManager::Load( const char * szFileName ) { bool bParse = true; // Create the xml ban file instance m_pBanFile = new CXML( szFileName ); // Get the root node m_pRootNode = m_pBanFile->GetRootNode(); // Is the root node invalid? if( !m_pRootNode ) { // Create the root node m_pRootNode = m_pBanFile->CreateRootNode( "bans" ); // Save the file m_pBanFile->Save(); // Mark as no need to parse bParse = false; } // Should we parse the file? if( bParse ) { // CXMLNode * pNode = NULL; unsigned int uiCount = m_pRootNode->GetChildCount(); // Is there no bans? if( uiCount == 0 ) return true; // Loop over all children for( unsigned int i = 0; i < uiCount; i++ ) { // Get the current node pNode = m_pRootNode->GetNode( i ); // Is the node invalid? if( !pNode ) continue; // Get the current node name const char * szName = pNode->GetName(); // Is this a ban? if( !strcmp( szName, "ban" ) ) { const char *szSerial = "", *szBanner = "", *szReason = ""; unsigned long ulBanTime, ulUnbanTime; // Get the ban data szSerial = pNode->GetValue(); szBanner = pNode->GetAttribute( "banner" ); ulBanTime = (unsigned long)atol( pNode->GetAttribute( "time" ) ); ulUnbanTime = (unsigned long)atol( pNode->GetAttribute( "unban" ) ); szReason = pNode->GetAttribute( "reason" ); // Add the ban to the manager Add( szSerial, szBanner, ulBanTime, ulUnbanTime, szReason, false ); // Increase the total loaded bans m_iTotalBansLoaded++; } } // Mark as bans loaded m_bBansLoaded = true; // Pulse the ban manager Pulse( true ); // Were any bans loaded? if( m_iTotalBansLoaded > 0 ) { // Subtract the total purged bans from the total loaded. m_iTotalBansLoaded -= m_iTotalUnbans; // Did we purge ALL bans? if( m_iTotalBansLoaded == 0 ) CLogFile::Printf( "Successfully purged %d bans.", m_iTotalUnbans ); else CLogFile::Printf( "Successfully loaded %d bans. (%d purged)", m_iTotalBansLoaded, m_iTotalUnbans ); // Reset the total unban count m_iTotalUnbans = 0; } return true; } return false; }
void CMaterialResource::Load() { m_IsLoaded = true; CXMLDocument document; document.Load( m_FilePath.c_str() ); CXMLNode rootNode = document.GetRootNode(); //Read out shaders CXMLNode childNode = rootNode.GetChildNode( "Shader" ); CXMLAttribute attribute = childNode.GetAttribute( "File" ); std::string shaderPath; shaderPath += "../Content/"; shaderPath += attribute.GetValue(); //Read out defines childNode = rootNode.GetChildNode( "ShaderDefine" ); while ( childNode.IsEmpty() == false ) { attribute = childNode.GetAttribute( "Name" ); const Char* name = attribute.GetValue( "" ); if ( strcmp( name, "" ) != 0 ) { m_ShaderDefines.push_back( name ); } childNode = childNode.GetNextSibling(); } //Build hash Uint hash = HashString( shaderPath.c_str() ); hash += m_ShaderDefines.size(); for ( Uint i = 0; i < m_ShaderDefines.size(); ++i ) { hash += HashString( m_ShaderDefines[i].c_str() ); } CResource* shaderResource; if ( ( shaderResource = CResourceManager::GetInstance()->GetResourceByHash( hash ) ) == NULL ) { shaderResource = CResourceManager::GetInstance()->AddShaderResource( shaderPath.c_str(), hash, m_ShaderDefines ); } m_ShaderResource = (CShaderResource*)shaderResource; m_Shader = m_ShaderResource->GetShader(); //Read terms childNode = rootNode.GetChildNode( "Terms" ); //Emmisive CXMLNode termNode = childNode.GetChildNode( "Emissive" ); attribute = termNode.GetAttribute( "R" ); m_EmissiveTerm.X = (Float)atof( attribute.GetValue() ); attribute = termNode.GetAttribute( "G" ); m_EmissiveTerm.Y = (Float)atof( attribute.GetValue() ); attribute = termNode.GetAttribute( "B" ); m_EmissiveTerm.Z = (Float)atof( attribute.GetValue() ); //Diffuse termNode = childNode.GetChildNode( "Diffuse" ); attribute = termNode.GetAttribute( "R" ); m_DiffuseTerm.X = (Float)atof( attribute.GetValue() ); attribute = termNode.GetAttribute( "G" ); m_DiffuseTerm.Y = (Float)atof( attribute.GetValue() ); attribute = termNode.GetAttribute( "B" ); m_DiffuseTerm.Z = (Float)atof( attribute.GetValue() ); //Specular termNode = childNode.GetChildNode( "Specular" ); attribute = termNode.GetAttribute( "R" ); m_SpecularTerm.X = (Float)atof( attribute.GetValue() ); attribute = termNode.GetAttribute( "G" ); m_SpecularTerm.Y = (Float)atof( attribute.GetValue() ); attribute = termNode.GetAttribute( "B" ); m_SpecularTerm.Z = (Float)atof( attribute.GetValue() ); //Ambient termNode = childNode.GetChildNode( "Ambient" ); attribute = termNode.GetAttribute( "R" ); m_AmbientTerm.X = (Float)atof( attribute.GetValue() ); attribute = termNode.GetAttribute( "G" ); m_AmbientTerm.Y = (Float)atof( attribute.GetValue() ); attribute = termNode.GetAttribute( "B" ); m_AmbientTerm.Z = (Float)atof( attribute.GetValue() ); //Specular power termNode = childNode.GetChildNode( "SpecularPower" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_SpecularPower = (Float)atof( attribute.GetValue( "1.0f" ) ); } termNode = childNode.GetChildNode( "Reflection" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_Reflection = (Float)atof( attribute.GetValue( "0.0f" ) ); } termNode = childNode.GetChildNode( "Refraction" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_Refraction = (Float)atof( attribute.GetValue( "0.0f" ) ); } termNode = childNode.GetChildNode( "Transmittance" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_Transmittance = (Float)atof( attribute.GetValue( "0.0f" ) ); } termNode = childNode.GetChildNode( "FresnelPower" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_FresnelValues.X = (Float)atof( attribute.GetValue( "1.0f" ) ); } termNode = childNode.GetChildNode( "FresnelScale" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_FresnelValues.Y = (Float)atof( attribute.GetValue( "1.0f" ) ); } termNode = childNode.GetChildNode( "FresnelBias" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_FresnelValues.Z = (Float)atof( attribute.GetValue( "0.0f" ) ); } termNode = childNode.GetChildNode( "TextureWeight" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_TextureWeight = (Float)atof( attribute.GetValue( "0.0f" ) ); } termNode = childNode.GetChildNode( "ParallaxScale" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_ParallaxScale = (Float)atof( attribute.GetValue( "0.0f" ) ); } termNode = childNode.GetChildNode( "ParallaxBias" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "Value" ); m_ParallaxBias = (Float)atof( attribute.GetValue( "0.0f" ) ); } termNode = childNode.GetChildNode( "RefractiveIndices" ); if ( termNode.IsEmpty() == false ) { attribute = termNode.GetAttribute( "R" ); m_RefractiveIndices.X = (Float)atof( attribute.GetValue( "1.0f" ) ); attribute = termNode.GetAttribute( "G" ); m_RefractiveIndices.Y = (Float)atof( attribute.GetValue( "1.0f" ) ); attribute = termNode.GetAttribute( "B" ); m_RefractiveIndices.Z = (Float)atof( attribute.GetValue( "1.0f" ) ); } //Read out textures childNode = rootNode.GetChildNode( "Texture2D" ); while ( childNode.IsEmpty() == false ) { attribute = childNode.GetAttribute( "Name" ); const Char* name = attribute.GetValue(); attribute = childNode.GetAttribute( "Hash" ); const Uint hash = (Uint)strtoul( attribute.GetValue(), NULL, 0 ); //Check if the resource already exists and is loaded CResource* resource = m_DependentResources.find( hash )->second; Uint textureID = 0; if ( resource != NULL ) { CTextureResource* textureResource = (CTextureResource*)resource; if ( textureResource->IsLoaded() ) { textureID = textureResource->GetTextureID(); } } attribute = childNode.GetAttribute( "Type" ); const Char* type = attribute.GetValue(); attribute = childNode.GetAttribute( "UVChannel" ); const Uint uvChannel = atoi( attribute.GetValue() ); attribute = childNode.GetAttribute( "Mapping" ); const Char* mapping = attribute.GetValue(); CXMLNode mapNode = childNode.GetChildNode( "MapMode" ); attribute = mapNode.GetAttribute( "X" ); const Char* mapModeX = attribute.GetValue(); attribute = mapNode.GetAttribute( "Y" ); const Char* mapModeY = attribute.GetValue(); TextureMapMode mapModes[2]; mapModes[0] = (TextureMapMode)ConvertMapMode( mapModeX ); mapModes[1] = (TextureMapMode)ConvertMapMode( mapModeY ); CTexture2D* texture = new CTexture2D( name, hash, (TextureMapping)ConvertMapping( mapping ), mapModes, (TextureMapType)ConvertTextureType( type ), uvChannel, textureID ); m_2DTextures.push_back( texture ); childNode = childNode.GetNextSibling(); } childNode = rootNode.GetChildNode( "TextureCube" ); while ( childNode.IsEmpty() == false ) { attribute = childNode.GetAttribute( "FileBase" ); const Char* fileBase = attribute.GetValue(); attribute = childNode.GetAttribute( "UniformName" ); const Char* uniformName = attribute.GetValue(); attribute = childNode.GetAttribute( "Extension" ); const Char* extension = attribute.GetValue(); CTextureCube* texture = new CTextureCube( fileBase, uniformName, extension ); m_3DTextures.push_back( texture ); childNode = childNode.GetNextSibling(); } }
BOOL CInstanceTree::UpdateTargets() { // only do update if something has changed in the target view if (!(m_pProjectManager->GetTargetTree())->m_bTargetTreeChanged) { return TRUE; } BOOL ret; CXMLDocument tTargetDoc; TStringList listNewTargets; CXMLNode nodeTargetRoot; CXMLNode nodeInstanceRoot; // update lists TStringList listUpdateChanged; TStringList listUpdateNew; TStringList listUpdateDeleted; (m_pProjectManager->GetTargetTree())->m_bTargetTreeChanged = FALSE; // get instance tree root node if (!m_domDocument.GetRootNode(nodeInstanceRoot)) { return FALSE; } // get root node of target view IUnknown* pTmp = NULL; HRESULT hr = m_pProjectManager->GetTargetViewDOM(&pTmp); if(hr != S_OK) { return FALSE; } tTargetDoc.SetIXMLDocument(pTmp); pTmp->Release(); // add target nodes as children if(!tTargetDoc.GetRootNode(nodeTargetRoot)) { return FALSE; } // get new targets from target view if (!GetTargetsFromTargetTree(listNewTargets)) { return FALSE; } // empty xml tree nodeInstanceRoot.RemoveAllChilds(); // mark all nodes not used: POSITION posH = m_mapInstanceTargets.GetStartPosition(); while(posH) { CString strId; TInstanceTargetInfo* pInfo; m_mapInstanceTargets.GetNextAssoc(posH, strId, pInfo); if (pInfo) { pInfo->bUsed = FALSE; } } // look at all new targets, hang targets into the tree: // test if target is a new target or the attributes have changed or it is the same // in the last two cases, take the old node and only change attributes if necessary POSITION posNewTargets = listNewTargets.GetHeadPosition(); while(posNewTargets) { CXMLNode nodeTarget; CXMLNode nodeInstance; CXMLNode nodeLink; // attributes of the target node CString strTText; // node text CString strTId; // node id CString strTType; // node type (KAD type) CString strTAddress; // connect info CString strTUserAddress; // user connect info CString strTConsoleAddress; // console address CString strTAssignedResource; // assigned resource CString strTSource; // source file for add on action CString strParseSource; // parser source help var CString strParseSourceNew; // parser source CString strInstType; // type of the instance node CString strIdPathTarg; // id path of target node in target tree CString strIdPathInst; // id path of target instance in instance tree CString strTargetId; CString strWaitForTarget; strIdPathTarg = listNewTargets.GetNext(posNewTargets); strTargetId = strIdPathTarg; int iFind = strTargetId.ReverseFind(CE_XML_IDPATH_SEP_CHAR); ASSERT(iFind>0); if (iFind>0) { strTargetId = strTargetId.Mid(iFind+1); } // get target node ret = nodeTargetRoot.GetNodeFromIdPath(strIdPathTarg, nodeTarget); ASSERT(ret); if (!ret) { continue; } // get attributes of the target node nodeTarget.GetAttribute(CE_XMLATTR_TEXT, strTText); nodeTarget.GetAttribute(CE_XMLATTR_ID, strTId); nodeTarget.GetAttribute(CE_XMLATTR_TYPE, strTType); nodeTarget.GetAttribute(CE_XMLATTR_ADDR, strTAddress); nodeTarget.GetAttribute(CE_XMLATTR_USERADDR, strTUserAddress); nodeTarget.GetAttribute(CE_XMLATTR_CONSOLE_ADDR, strTConsoleAddress); nodeTarget.GetAttribute(CE_XMLATTR_RESOURCE, strTAssignedResource); nodeTarget.GetAttribute(CE_XMLATTR_SOURCE, strTSource); nodeTarget.GetAttribute(CE_XMLATTR_WAIT_TARGET_CONN , strWaitForTarget); strInstType = strTType + CE_XML_INST_ADD; strParseSource = strTId + _T(".") + CE_INSTANCE_EXT; strParseSourceNew = CString(CE_GEN_PATH) + _T("\\") + strTId + _T("\\") + strParseSource; // does node already exist in instance tree: TInstanceTargetInfo* pInstTargetInfo = NULL; CString strLowerId = strTargetId; strLowerId.MakeLower(); if (m_mapInstanceTargets.Lookup(strLowerId, pInstTargetInfo)) { // *** existing node *** ASSERT(pInstTargetInfo); pInstTargetInfo->bUsed = TRUE; nodeInstance = pInstTargetInfo->xmlNode; ret = nodeInstanceRoot.AppendChild(nodeInstance, TRUE); ASSERT(ret); // check if attributes have changed // get instance node attributes CString strInstText; CString strInstId; //CString strInstType; CString strInstAddress; CString strInstUserAddress; CString strInstConsoleAddress; CString strInstAssignedResource; CString strInstSource; nodeInstance.GetAttribute(CE_XMLATTR_TEXT, strInstText); nodeInstance.GetAttribute(CE_XMLATTR_ID, strInstId); //nodeInstance.GetAttribute(CE_XMLATTR_TYPE, strInstType); // type can't change nodeInstance.GetAttribute(CE_XMLATTR_ADDR, strInstAddress); nodeInstance.GetAttribute(CE_XMLATTR_USERADDR, strInstUserAddress); nodeInstance.GetAttribute(CE_XMLATTR_CONSOLE_ADDR, strInstConsoleAddress); nodeInstance.GetAttribute(CE_XMLATTR_RESOURCE, strInstAssignedResource); nodeInstance.GetAttribute(CE_XMLATTR_SOURCE, strInstSource); if ((strInstText.CompareNoCase(strTText)!=0) || (strInstId.CompareNoCase(strTId)!=0) //|| (strInstType.CompareNoCase(strType)!=0) || (strInstAddress.CompareNoCase(strTAddress)!=0) || (strInstConsoleAddress.CompareNoCase(strTConsoleAddress)!=0) || (strInstAssignedResource.CompareNoCase(strTAssignedResource)!=0) || (strInstSource.CompareNoCase(strTSource) != 0)) { // node has changed -> update nodes nodeInstance.SetAttribute(CE_XMLATTR_TEXT, strTText); nodeInstance.SetAttribute(CE_XMLATTR_ID, strTId); //nodeInstance.SetAttribute(CE_XMLATTR_TYPE, strType); nodeInstance.SetAttribute(CE_XMLATTR_ADDR, strTAddress); nodeInstance.SetAttribute(CE_XMLATTR_USERADDR, strTUserAddress); nodeInstance.SetAttribute(CE_XMLATTR_CONSOLE_ADDR, strTConsoleAddress); nodeInstance.SetAttribute(CE_XMLATTR_RESOURCE, strTAssignedResource); nodeInstance.SetAttribute(CE_XMLATTR_SOURCE, strTSource); listUpdateChanged.AddTail(pInstTargetInfo->strIdPath); } } else // *** new node *** { if(!m_domDocument.CreateNode(nodeInstance, CE_XMLTAG_NODE)) { continue; } // set attributes of target instance node nodeInstance.SetAttribute(CE_XMLATTR_TEXT, strTText); nodeInstance.SetAttribute(CE_XMLATTR_ID, strTId); nodeInstance.SetAttribute(CE_XMLATTR_ADDR, strTAddress); nodeInstance.SetAttribute(CE_XMLATTR_USERADDR, strTUserAddress); nodeInstance.SetAttribute(CE_XMLATTR_CONSOLE_ADDR, strTConsoleAddress); nodeInstance.SetAttribute(CE_XMLATTR_RESOURCE, strTAssignedResource); nodeInstance.SetAttribute(CE_XMLATTR_TARGET_TYPE, strTType); nodeInstance.SetAttribute(CE_XMLATTR_SOURCE, strTSource); nodeInstance.SetAttribute(CE_XMLATTR_TYPE, strInstType); if (!strWaitForTarget.IsEmpty()) { nodeInstance.SetAttribute(CE_XMLATTR_WAIT_TARGET_CONN, strWaitForTarget); } // create new instance info struct ASSERT(pInstTargetInfo==NULL); pInstTargetInfo = new TInstanceTargetInfo; ASSERT(pInstTargetInfo); if (!pInstTargetInfo) { continue; } ret = nodeInstanceRoot.AppendChild(nodeInstance, TRUE); ASSERT(ret); nodeInstance.GetIdPath(strIdPathInst); pInstTargetInfo->strIdPath = strIdPathInst; pInstTargetInfo->strTargetId = strTId; pInstTargetInfo->xmlNode = nodeInstance; pInstTargetInfo->bUsed = TRUE; strLowerId = strTId; strLowerId.MakeLower(); m_mapInstanceTargets.SetAt(strLowerId, pInstTargetInfo); // add to update list (new node) listUpdateNew.AddTail(strIdPathInst); // now create target link node: the link that will be replaced by compiler outpu if((!m_domDocument.CreateNode(nodeLink, CE_XMLTAG_LINK)) ||(!nodeInstance.AppendChild(nodeLink)) ) { continue; } nodeLink.SetAttribute(CE_XMLATTR_PARSERSOURCE, strParseSourceNew); nodeLink.SetAttribute(CE_XMLATTR_ID, strTId); TSourceFileInfo* pFileInfo; pFileInfo = CreateSourceFileInfo(strParseSourceNew, nodeLink, ""); SourceFileMap_SetAt(strParseSourceNew, pFileInfo, m_mapSourceFiles); AddSourceFileToReparse(strParseSourceNew); } } // find deleted nodes: posH = m_mapInstanceTargets.GetStartPosition(); while(posH) { CString strId; TInstanceTargetInfo* pInfo; m_mapInstanceTargets.GetNextAssoc(posH, strId, pInfo); if (pInfo) { if (pInfo->bUsed == FALSE) { listUpdateDeleted.AddTail(pInfo->strIdPath); delete pInfo; m_mapInstanceTargets.RemoveKey(strId); } } } if (m_bInit) { return TRUE; } // send update messages POSITION lPos; lPos = listUpdateDeleted.GetHeadPosition(); while(lPos) { CString strIdPath = listUpdateDeleted.GetNext(lPos); if (!strIdPath.IsEmpty()) { FireUpdateTree(strIdPath, eUpdateDelete); CString strId = strIdPath; int iFind = strId.ReverseFind(CE_XML_IDPATH_SEP_CHAR); ASSERT(iFind>0); if (iFind>0) { strId = strId.Mid(iFind+1); } CComBSTR sId = strId; m_pProjectManager->Fire_TargetInstanceRemoved(sId); } } lPos = listUpdateChanged.GetHeadPosition(); while(lPos) { CString strIdPath = listUpdateChanged.GetNext(lPos); if (!strIdPath.IsEmpty()) { FireUpdateTree(strIdPath, eUpdateAttributes); CString strId = strIdPath; int iFind = strId.ReverseFind(CE_XML_IDPATH_SEP_CHAR); ASSERT(iFind>0); if (iFind>0) { strId = strId.Mid(iFind+1); } CComBSTR sId = strId; CComBSTR sIdPath = strIdPath; m_pProjectManager->Fire_TargetInstanceAdded(sId, sIdPath); } } lPos = listUpdateNew.GetHeadPosition(); while(lPos) { CString strIdPath = listUpdateNew.GetNext(lPos); if (!strIdPath.IsEmpty()) { FireUpdateTree(strIdPath, eUpdateInsert); CString strId = strIdPath; int iFind = strId.ReverseFind(CE_XML_IDPATH_SEP_CHAR); ASSERT(iFind>0); if (iFind>0) { strId = strId.Mid(iFind+1); } CComBSTR sId = strId; CComBSTR sIdPath = strIdPath; m_pProjectManager->Fire_TargetInstanceAdded(sId, sIdPath); } } Reparse(FALSE); return TRUE; }
bool CCeWatchElement::LoadFromNode(CXMLNode& rtNode, CCeSymbol* pRootSymbol) { bool bReturn = true; CString str; int iPos = -1; Init(); rtNode.GetAttribute(CEWATCH_XMLATTR_EXPRESSION, str); iPos = str.Find(CEWATCH_EXP_EQ); if(iPos == -1) { m_Name = str; } else { m_Name = str.Mid(iPos+1); } // 15.12.05 SIS >> // remove array range from name // otherwise it will be shown twice int iFound = m_Name.Find(_T(", [")); if(iFound != -1) { m_strIndexRange = m_Name.Mid(iFound); m_Name = m_Name.Left(iFound); } // 14.12.05 SIS << m_Name.TrimLeft(); m_Name.TrimRight(); rtNode.GetAttribute(CEWATCH_XMLATTR_TYPE, str); CCeWatchType type; if (type.SetByName(str)) { SetType(type); PresetHistory(); //last value - don't read it rtNode.GetAttribute(CEWATCH_XMLATTR_VALUE, m_strValue); rtNode.GetAttribute(CEWATCH_XMLATTR_FORMAT, m_strFormat); rtNode.GetAttribute(CEWATCH_XMLATTR_EXPANDED, str); if(atoi(str) == 1) { m_bInitExpanded = true; } CXMLNodeList tChildList; CXMLNode tNodeChild; CCeWatchElement* pChild = NULL; if(rtNode.GetChildNodeList(tChildList)) { long lNumChildren = tChildList.GetLength(); for(long lChild = 0; lChild < lNumChildren; ++lChild) { tChildList.Item(lChild, tNodeChild); pChild = new CCeWatchElement(); AddChild(pChild); bReturn &= pChild->LoadFromNode(tNodeChild, pRootSymbol); } } } if(!bReturn) { Init(); } return bReturn; }