Beispiel #1
0
	Chunk * Composite::GetProperty(ChildNode const * pNode, ID idProp) const
	{
		// search backward for ID
		
		ChildNode * pFindNode = GetPrevChild(pNode, idProp);
		
		if (pFindNode) return pFindNode->GetChunk();
		
		// if not found, search parent backwards, for "PROP ...." then get that
		// and if not in the parent, search its parent similarly
		// provided all these parents are of type LIST ....
		
		for (Composite const * pThis = this; pThis->m_pParent && pThis->m_pParent->m_idCk == ID("LIST"); pThis = pThis->m_pParent)
		{
			if (pThis->m_pNode)
			{
				for (ChildNode * pFindProp = pThis->m_pParent->GetPrevChild(pThis->m_pNode,"PROP"); pFindProp; pFindProp = pThis->m_pParent->GetPrevChild(pFindProp,"PROP"))
				{
					Composite * pProp = static_cast<Composite *>(pFindProp->GetChunk());
					if (pProp->m_idData == m_idData)
					{
						ChildNode * pFindNode = pProp->GetLastChild(idProp);
						
						if (pFindNode) return pFindNode->GetChunk();
					}
				}
				
			}
		}
		
		return NULL;
	}
Beispiel #2
0
	ChildNode * Composite::GetPrevChild(ChildNode const * pNode, ID idMatch)
	{
		for (ChildNode * pSrchNode = GetPrevChild(pNode); pSrchNode; pSrchNode = GetPrevChild(pSrchNode))
		{
			if (pSrchNode->GetChunk()->m_idCk == idMatch && !pSrchNode->GetChunk()->IsUnknown()) return pSrchNode;
		}
		return NULL;
	}
Beispiel #3
0
	ChildNode * Composite::GetLastChild(ID idMatch) const
	{
		for (ChildNode * pSrchNode = m_pLast; pSrchNode; pSrchNode = GetPrevChild(pSrchNode))
		{
			if (pSrchNode->GetChunk()->m_idCk == idMatch && !pSrchNode->GetChunk()->IsUnknown()) return pSrchNode;
		}
		return NULL;
	}
Beispiel #4
0
	bool List::EnumChildren(ID idData, ID idChunk, bool (* pfnCallback) (Chunk *, void *), void * pData) const
	{
		for (ChildNode * pNode = GetFirstChild(); pNode; pNode = GetNextChild(pNode))
		{
			Composite const * pComposite = static_cast<Composite const *>(pNode->GetChunk());
			if (pComposite->m_idData == idData && !pComposite->EnumChildren(idData,idChunk,pfnCallback,pData)) return false;
		}
		
		return true;
	}
Beispiel #5
0
	bool Composite::EnumChildren(ID idData, ID idChunk, bool (* pfnCallback) (Chunk *, void *), void * pData) const
	{
		if (m_idData != idData) return true;
		
		for (ChildNode * pNode = GetFirstChild(idChunk); pNode; pNode = GetNextChild(pNode,idChunk))
		{
			if (!pfnCallback(pNode->GetChunk(),pData)) return false;
		}
		
		return true;
	}
Beispiel #6
0
	void Composite::Serialize(Archive * pArchv)
	{
		pArchv->Transfer(m_idData);
		
		if (pArchv->m_bIsLoading)
		{
			DeleteAllChildren();
			
			while (pArchv->GetSize())
			{
				Chunk * pChunk = LoadChunk(pArchv);
				InsertChildLast(pChunk);
				pChunk->Release();
			}
		}
		else
		{
			for (ChildNode * pNode = m_pFirst; pNode; pNode = GetNextChild(pNode))
			{
				pNode->GetChunk()->Write(pArchv);
			}
		}
	}