Changed: #1440 Removed parse level

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 76b33139e2
commit 359ee113a7

@ -65,9 +65,9 @@ const TSClassId CAnimatable::SuperClassId = 0x77a60fbd; /* Not official, please
const CAnimatableClassDesc AnimatableClassDesc(&DllPluginDescBuiltin); const CAnimatableClassDesc AnimatableClassDesc(&DllPluginDescBuiltin);
const CAnimatableSuperClassDesc AnimatableSuperClassDesc(&AnimatableClassDesc); const CAnimatableSuperClassDesc AnimatableSuperClassDesc(&AnimatableClassDesc);
void CAnimatable::parse(uint16 version, TParseLevel level) void CAnimatable::parse(uint16 version)
{ {
CSceneClass::parse(version, level); CSceneClass::parse(version);
if (!m_ChunksOwnsPointers) if (!m_ChunksOwnsPointers)
{ {
m_AppData = static_cast<STORAGE::CAppData *>(getChunk(PMBS_APP_DATA_CHUNK_ID)); m_AppData = static_cast<STORAGE::CAppData *>(getChunk(PMBS_APP_DATA_CHUNK_ID));

@ -67,7 +67,7 @@ public:
static const TSClassId SuperClassId; static const TSClassId SuperClassId;
// inherited // inherited
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -44,6 +44,7 @@
#include "i_node.h" #include "i_node.h"
#include "node_impl.h" #include "node_impl.h"
#include "root_node.h"
// using namespace std; // using namespace std;
// using namespace NLMISC; // using namespace NLMISC;
@ -228,6 +229,7 @@ void CBuiltin::registerClasses(CSceneClassRegistry *registry)
{ {
registry->add(&NodeClassDesc); registry->add(&NodeClassDesc);
registry->add(&NodeImplClassDesc); registry->add(&NodeImplClassDesc);
registry->add(&RootNodeClassDesc);
} }
// unimplemented // unimplemented

@ -60,9 +60,9 @@ const TSClassId INode::SuperClassId = 0x00000001;
const CNodeClassDesc NodeClassDesc(&DllPluginDescBuiltin); const CNodeClassDesc NodeClassDesc(&DllPluginDescBuiltin);
const CNodeSuperClassDesc NodeSuperClassDesc(&NodeClassDesc); const CNodeSuperClassDesc NodeSuperClassDesc(&NodeClassDesc);
void INode::parse(uint16 version, TParseLevel level) void INode::parse(uint16 version)
{ {
CReferenceTarget::parse(version, level); CReferenceTarget::parse(version);
} }
void INode::clean() void INode::clean()
@ -99,6 +99,28 @@ const ISceneClassDesc *INode::classDesc() const
void INode::toStringLocal(std::ostream &ostream, const std::string &pad) const void INode::toStringLocal(std::ostream &ostream, const std::string &pad) const
{ {
CReferenceTarget::toStringLocal(ostream, pad); CReferenceTarget::toStringLocal(ostream, pad);
// Children: IMPLICIT { } - print the implied connected children
}
INode *INode::parent()
{
nlerror("Unkown node class, cannot get parent node");
return NULL;
}
void INode::setParent(INode *node)
{
nlerror("Unkown node class, cannot set parent node");
}
void INode::addChild(INode *node)
{
m_Children.insert(node);
}
void INode::removeChild(INode *node)
{
m_Children.erase(node);
} }
IStorageObject *INode::createChunkById(uint16 id, bool container) IStorageObject *INode::createChunkById(uint16 id, bool container)

@ -60,7 +60,7 @@ public:
static const TSClassId SuperClassId; static const TSClassId SuperClassId;
// inherited // inherited
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -69,10 +69,21 @@ public:
virtual const ISceneClassDesc *classDesc() const; virtual const ISceneClassDesc *classDesc() const;
virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const;
// node interface
virtual INode *parent();
virtual void setParent(INode *node);
virtual void addChild(INode *node);
virtual void removeChild(INode *node); // does not delete
/// The children that are linked to this node by the parent tag
inline const std::set<INode *> &children() const { return m_Children; }
protected: protected:
// inherited // inherited
virtual IStorageObject *createChunkById(uint16 id, bool container); virtual IStorageObject *createChunkById(uint16 id, bool container);
protected:
std::set<INode *> m_Children;
}; /* class INode */ }; /* class INode */
typedef CSceneClassDesc<INode> CNodeClassDesc; typedef CSceneClassDesc<INode> CNodeClassDesc;

@ -58,9 +58,9 @@ const NLMISC::CClassId CNodeImpl::ClassId = NLMISC::CClassId(0x00000001, 0x00000
const TSClassId CNodeImpl::SuperClassId = INode::SuperClassId; const TSClassId CNodeImpl::SuperClassId = INode::SuperClassId;
const CNodeImplClassDesc NodeImplClassDesc(&DllPluginDescBuiltin); const CNodeImplClassDesc NodeImplClassDesc(&DllPluginDescBuiltin);
void CNodeImpl::parse(uint16 version, TParseLevel level) void CNodeImpl::parse(uint16 version)
{ {
INode::parse(version, level); INode::parse(version);
} }
void CNodeImpl::clean() void CNodeImpl::clean()

@ -59,7 +59,7 @@ public:
static const TSClassId SuperClassId; static const TSClassId SuperClassId;
// inherited // inherited
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -86,9 +86,9 @@ const TSClassId CReferenceMaker::SuperClassId = 0x00000100;
const CReferenceMakerClassDesc ReferenceMakerClassDesc(&DllPluginDescBuiltin); const CReferenceMakerClassDesc ReferenceMakerClassDesc(&DllPluginDescBuiltin);
const CReferenceMakerSuperClassDesc ReferenceMakerSuperClassDesc(&ReferenceMakerClassDesc); const CReferenceMakerSuperClassDesc ReferenceMakerSuperClassDesc(&ReferenceMakerClassDesc);
void CReferenceMaker::parse(uint16 version, TParseLevel level) void CReferenceMaker::parse(uint16 version)
{ {
CAnimatable::parse(version, level); CAnimatable::parse(version);
if (!m_ChunksOwnsPointers) if (!m_ChunksOwnsPointers)
{ {
CStorageArray<sint32> *references2034 = static_cast<CStorageArray<sint32> *>(getChunk(PMB_REFERENCES_2034_CHUNK_ID)); CStorageArray<sint32> *references2034 = static_cast<CStorageArray<sint32> *>(getChunk(PMB_REFERENCES_2034_CHUNK_ID));

@ -61,7 +61,7 @@ public:
static const TSClassId SuperClassId; static const TSClassId SuperClassId;
// inherited // inherited
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -60,9 +60,9 @@ const TSClassId CReferenceTarget::SuperClassId = 0x00000200;
const CReferenceTargetClassDesc ReferenceTargetClassDesc(&DllPluginDescBuiltin); const CReferenceTargetClassDesc ReferenceTargetClassDesc(&DllPluginDescBuiltin);
const CReferenceTargetSuperClassDesc ReferenceTargetSuperClassDesc(&ReferenceTargetClassDesc); const CReferenceTargetSuperClassDesc ReferenceTargetSuperClassDesc(&ReferenceTargetClassDesc);
void CReferenceTarget::parse(uint16 version, TParseLevel level) void CReferenceTarget::parse(uint16 version)
{ {
CReferenceMaker::parse(version, level); CReferenceMaker::parse(version);
} }
void CReferenceTarget::clean() void CReferenceTarget::clean()

@ -61,7 +61,7 @@ public:
static const TSClassId SuperClassId; static const TSClassId SuperClassId;
// inherited // inherited
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -0,0 +1,111 @@
/**
* \file root_node.cpp
* \brief CRootNode
* \date 2012-08-22 19:45GMT
* \author Jan Boon (Kaetemi)
* CRootNode
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE PIPELINE.
* RYZOM CORE PIPELINE is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* RYZOM CORE PIPELINE is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE PIPELINE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <nel/misc/types_nl.h>
#include "root_node.h"
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
// Project includes
using namespace std;
// using namespace NLMISC;
namespace PIPELINE {
namespace MAX {
namespace BUILTIN {
CRootNode::CRootNode(CScene *scene) : INode(scene)
{
}
CRootNode::~CRootNode()
{
}
const ucstring CRootNode::DisplayName = ucstring("RootNode");
const char *CRootNode::InternalName = "RootNode";
const NLMISC::CClassId CRootNode::ClassId = NLMISC::CClassId(0x00000002, 0x00000000);
const TSClassId CRootNode::SuperClassId = INode::SuperClassId;
const CRootNodeClassDesc RootNodeClassDesc(&DllPluginDescBuiltin);
void CRootNode::parse(uint16 version)
{
INode::parse(version);
}
void CRootNode::clean()
{
INode::clean();
}
void CRootNode::build(uint16 version)
{
INode::build(version);
}
void CRootNode::disown()
{
INode::disown();
}
void CRootNode::init()
{
INode::init();
}
bool CRootNode::inherits(const NLMISC::CClassId classId) const
{
if (classId == classDesc()->classId()) return true;
return INode::inherits(classId);
}
const ISceneClassDesc *CRootNode::classDesc() const
{
return &RootNodeClassDesc;
}
void CRootNode::toStringLocal(std::ostream &ostream, const std::string &pad) const
{
INode::toStringLocal(ostream, pad);
}
IStorageObject *CRootNode::createChunkById(uint16 id, bool container)
{
return INode::createChunkById(id, container);
}
} /* namespace BUILTIN */
} /* namespace MAX */
} /* namespace PIPELINE */
/* end of file */

@ -0,0 +1,86 @@
/**
* \file root_node.h
* \brief CRootNode
* \date 2012-08-22 19:45GMT
* \author Jan Boon (Kaetemi)
* CRootNode
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE PIPELINE.
* RYZOM CORE PIPELINE is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* RYZOM CORE PIPELINE is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE PIPELINE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_ROOT_NODE_H
#define PIPELINE_ROOT_NODE_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
// Project includes
#include "i_node.h"
namespace PIPELINE {
namespace MAX {
namespace BUILTIN {
/**
* \brief CRootNode
* \date 2012-08-22 20:01GMT
* \author Jan Boon (Kaetemi)
* CRootNode
*/
class CRootNode : public INode
{
public:
CRootNode(CScene *scene);
virtual ~CRootNode();
// class desc
static const ucstring DisplayName;
static const char *InternalName;
static const NLMISC::CClassId ClassId;
static const TSClassId SuperClassId;
// inherited
virtual void parse(uint16 version);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
virtual void init();
virtual bool inherits(const NLMISC::CClassId classId) const;
virtual const ISceneClassDesc *classDesc() const;
virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const;
protected:
// inherited
virtual IStorageObject *createChunkById(uint16 id, bool container);
}; /* class CRootNode */
typedef CSceneClassDesc<CRootNode> CRootNodeClassDesc;
extern const CRootNodeClassDesc RootNodeClassDesc;
} /* namespace BUILTIN */
} /* namespace MAX */
} /* namespace PIPELINE */
#endif /* #ifndef PIPELINE_ROOT_NODE_H */
/* end of file */

@ -58,9 +58,9 @@ const NLMISC::CClassId CSceneImpl::ClassId = NLMISC::CClassId(0x00002222, 0x0000
const TSClassId CSceneImpl::SuperClassId = CReferenceMaker::SuperClassId; const TSClassId CSceneImpl::SuperClassId = CReferenceMaker::SuperClassId;
const CSceneImplClassDesc SceneImplClassDesc(&DllPluginDescBuiltin); const CSceneImplClassDesc SceneImplClassDesc(&DllPluginDescBuiltin);
void CSceneImpl::parse(uint16 version_, TParseLevel level) void CSceneImpl::parse(uint16 version)
{ {
CReferenceMaker::parse(version_, level); CReferenceMaker::parse(version);
nlassert(m_MaterialEditor); nlassert(m_MaterialEditor);
nlassert(m_MtlBaseLib); nlassert(m_MtlBaseLib);
nlassert(m_Sound); nlassert(m_Sound);
@ -72,7 +72,7 @@ void CSceneImpl::parse(uint16 version_, TParseLevel level)
nlassert(m_RenderEffects); nlassert(m_RenderEffects);
nlassert(m_ShadowMap); nlassert(m_ShadowMap);
nlassert(m_LayerManager); nlassert(m_LayerManager);
if (version() > Version3) nlassert(m_TrackSetList); if (version > Version3) nlassert(m_TrackSetList);
} }
void CSceneImpl::clean() void CSceneImpl::clean()
@ -139,6 +139,10 @@ CReferenceMaker *CSceneImpl::getReference(uint index) const
return m_LayerManager; return m_LayerManager;
case 11: case 11:
return m_TrackSetList; return m_TrackSetList;
default:
if (index > 0)
nlerror("Invalid index %i", index);
return NULL;
} }
} }
@ -182,6 +186,9 @@ void CSceneImpl::setReference(uint index, CReferenceMaker *reference)
case 11: case 11:
m_TrackSetList = reference; m_TrackSetList = reference;
break; break;
default:
nlerror("Unknown reference index %i entry <ptr=0x%x> (%s, 0x%x)", index, (uint32)(uint64)(void *)reference, reference->classDesc()->classId().toString().c_str(), reference->classDesc()->superClassId());
break;
} }
} }

@ -59,7 +59,7 @@ public:
static const TSClassId SuperClassId; static const TSClassId SuperClassId;
// inherited // inherited
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -149,7 +149,7 @@ void CAppData::toString(std::ostream &ostream, const std::string &pad) const
} }
} }
void CAppData::parse(uint16 version, TParseLevel level) void CAppData::parse(uint16 version)
{ {
/*if (level & PARSE_BUILTIN) /*if (level & PARSE_BUILTIN)
{*/ {*/
@ -157,7 +157,7 @@ void CAppData::parse(uint16 version, TParseLevel level)
if (!m_ChunksOwnsPointers) { nlerror("Already parsed"); return; } if (!m_ChunksOwnsPointers) { nlerror("Already parsed"); return; }
// First parse all the child nodes // First parse all the child nodes
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
// Verify // Verify
if (m_Chunks.size() < 2) { nlwarning("Bad container size %i", m_Chunks.size()); disown(); return; } if (m_Chunks.size() < 2) { nlwarning("Bad container size %i", m_Chunks.size()); disown(); return; }
@ -390,9 +390,9 @@ void CAppDataEntry::toString(std::ostream &ostream, const std::string &pad) cons
} }
} }
void CAppDataEntry::parse(uint16 version, TParseLevel level) void CAppDataEntry::parse(uint16 version)
{ {
// CStorageContainer::parse(version, level); // CStorageContainer::parse(version);
// if (!m_ChunksOwnsPointers) { nlwarning("Already parsed"); return; } // if (!m_ChunksOwnsPointers) { nlwarning("Already parsed"); return; }
if (m_Chunks.size() != 2) { nlwarning("Bad container size"); disown(); return; } if (m_Chunks.size() != 2) { nlwarning("Bad container size"); disown(); return; }

@ -76,7 +76,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -149,7 +149,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -65,9 +65,9 @@ void CClassData::toString(std::ostream &ostream, const std::string &pad) const
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CClassData::parse(uint16 version, TParseLevel level) void CClassData::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CClassData::clean() void CClassData::clean()
@ -122,9 +122,9 @@ void CClassDataEntry::toString(std::ostream &ostream, const std::string &pad) co
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CClassDataEntry::parse(uint16 version, TParseLevel level) void CClassDataEntry::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CClassDataEntry::clean() void CClassDataEntry::clean()

@ -56,7 +56,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -81,7 +81,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -120,52 +120,49 @@ void CClassDirectory3::toString(std::ostream &ostream, const std::string &pad) c
} }
// Parallel to CDllDirectory // Parallel to CDllDirectory
void CClassDirectory3::parse(uint16 version, TParseLevel level) void CClassDirectory3::parse(uint16 version)
{ {
if (level & PARSE_INTERNAL) // Ensure not yet parsed
{ nlassert(m_ChunkCache.empty());
// Ensure not yet parsed nlassert(m_Entries.empty());
nlassert(m_ChunkCache.empty());
nlassert(m_Entries.empty());
// Parse entries first // Parse entries first
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
// Initialize // Initialize
uint16 lastCached = 0xFFFF; uint16 lastCached = 0xFFFF;
bool parsedDllEntry = false; bool parsedDllEntry = false;
// Parse chunks // Parse chunks
for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it)
{
uint16 id = it->first;
switch (id)
{ {
uint16 id = it->first; case 0x2040: // ClassEntry
switch (id)
{ {
case 0x2040: // ClassEntry if (parsedDllEntry && (lastCached != id))
throw EStorageParse(); // There were chunks inbetween
if (!parsedDllEntry)
{ {
if (parsedDllEntry && (lastCached != id)) m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location
throw EStorageParse(); // There were chunks inbetween lastCached = id;
if (!parsedDllEntry) parsedDllEntry = true;
{
m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location
lastCached = id;
parsedDllEntry = true;
}
CClassEntry *classEntry = static_cast<CClassEntry *>(it->second);
m_ClassIdToIndex[classEntry->classId()] = m_Entries.size();
m_Entries.push_back(classEntry);
break;
} }
default: CClassEntry *classEntry = static_cast<CClassEntry *>(it->second);
m_ChunkCache.push_back(*it); // Dummy entry to know the location m_ClassIdToIndex[classEntry->classId()] = m_Entries.size();
lastCached = id; m_Entries.push_back(classEntry);
break; break;
} }
default:
m_ChunkCache.push_back(*it); // Dummy entry to know the location
lastCached = id;
break;
} }
// Now ownership of the pointers lies in m_ChunkCache and m_Entries
m_ChunksOwnsPointers = false;
} }
// Now ownership of the pointers lies in m_ChunkCache and m_Entries
m_ChunksOwnsPointers = false;
} }
// Parallel to CDllDirectory // Parallel to CDllDirectory
@ -337,9 +334,9 @@ void CClassEntry::toString(std::ostream &ostream, const std::string &pad) const
} }
} }
void CClassEntry::parse(uint16 version, TParseLevel level) void CClassEntry::parse(uint16 version)
{ {
// CStorageContainer::parse(version, level); // CStorageContainer::parse(version);
nlassert(m_ChunksOwnsPointers); nlassert(m_ChunksOwnsPointers);
nlassert(m_Chunks.size() == 2); nlassert(m_Chunks.size() == 2);
TStorageObjectContainer::iterator it = m_Chunks.begin(); TStorageObjectContainer::iterator it = m_Chunks.begin();

@ -66,7 +66,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -131,7 +131,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -66,9 +66,9 @@ void CConfig::toString(std::ostream &ostream, const std::string &pad) const
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CConfig::parse(uint16 version, TParseLevel level) void CConfig::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CConfig::clean() void CConfig::clean()
@ -133,9 +133,9 @@ void CConfig20a0::toString(std::ostream &ostream, const std::string &pad) const
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CConfig20a0::parse(uint16 version, TParseLevel level) void CConfig20a0::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CConfig20a0::clean() void CConfig20a0::clean()
@ -198,9 +198,9 @@ void CConfig20a0Entry::toString(std::ostream &ostream, const std::string &pad) c
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CConfig20a0Entry::parse(uint16 version, TParseLevel level) void CConfig20a0Entry::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CConfig20a0Entry::clean() void CConfig20a0Entry::clean()
@ -290,9 +290,9 @@ void CConfigScript::toString(std::ostream &ostream, const std::string &pad) cons
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CConfigScript::parse(uint16 version, TParseLevel level) void CConfigScript::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CConfigScript::clean() void CConfigScript::clean()
@ -347,9 +347,9 @@ void CConfigScriptEntry::toString(std::ostream &ostream, const std::string &pad)
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CConfigScriptEntry::parse(uint16 version, TParseLevel level) void CConfigScriptEntry::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CConfigScriptEntry::clean() void CConfigScriptEntry::clean()
@ -445,9 +445,9 @@ void CConfigScriptMetaContainer::toString(std::ostream &ostream, const std::stri
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CConfigScriptMetaContainer::parse(uint16 version, TParseLevel level) void CConfigScriptMetaContainer::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CConfigScriptMetaContainer::clean() void CConfigScriptMetaContainer::clean()

@ -56,7 +56,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -81,7 +81,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -106,7 +106,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -131,7 +131,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -156,7 +156,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -205,7 +205,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -118,53 +118,50 @@ void CDllDirectory::toString(std::ostream &ostream, const std::string &pad) cons
} }
// Parallel to CClassDirectory3 // Parallel to CClassDirectory3
void CDllDirectory::parse(uint16 version, TParseLevel level) void CDllDirectory::parse(uint16 version)
{ {
if (level & PARSE_INTERNAL) // Ensure not yet parsed
{ nlassert(m_ChunkCache.empty());
// Ensure not yet parsed nlassert(m_Entries.empty());
nlassert(m_ChunkCache.empty());
nlassert(m_Entries.empty());
// Parse entries first // Parse entries first
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
// Initialize // Initialize
addInternalIndices(); addInternalIndices();
uint16 lastCached = 0xFFFF; uint16 lastCached = 0xFFFF;
bool parsedDllEntry = false; bool parsedDllEntry = false;
// Parse chunks // Parse chunks
for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) for (TStorageObjectContainer::iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it)
{
uint16 id = it->first;
switch (id)
{ {
uint16 id = it->first; case 0x2038: // DllEntry
switch (id)
{ {
case 0x2038: // DllEntry if (parsedDllEntry && (lastCached != id))
throw EStorageParse(); // There were chunks inbetween
if (!parsedDllEntry)
{ {
if (parsedDllEntry && (lastCached != id)) m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location
throw EStorageParse(); // There were chunks inbetween lastCached = id;
if (!parsedDllEntry) parsedDllEntry = true;
{
m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location
lastCached = id;
parsedDllEntry = true;
}
CDllEntry *dllEntry = static_cast<CDllEntry *>(it->second);
m_InternalNameToIndex[NLMISC::toLower(dllEntry->dllFilename())] = m_Entries.size();
m_Entries.push_back(dllEntry);
} }
break; CDllEntry *dllEntry = static_cast<CDllEntry *>(it->second);
default: m_InternalNameToIndex[NLMISC::toLower(dllEntry->dllFilename())] = m_Entries.size();
m_ChunkCache.push_back(*it); // Dummy entry to know the location m_Entries.push_back(dllEntry);
lastCached = id;
break;
} }
break;
default:
m_ChunkCache.push_back(*it); // Dummy entry to know the location
lastCached = id;
break;
} }
// Now ownership of the pointers lies in m_ChunkCache and m_Entries
m_ChunksOwnsPointers = false;
} }
// Now ownership of the pointers lies in m_ChunkCache and m_Entries
m_ChunksOwnsPointers = false;
} }
// Parallel to CClassDirectory3 // Parallel to CClassDirectory3
@ -363,9 +360,9 @@ void CDllEntry::toString(std::ostream &ostream, const std::string &pad) const
} }
} }
void CDllEntry::parse(uint16 version, TParseLevel level) void CDllEntry::parse(uint16 version)
{ {
// CStorageContainer::parse(version, level); // CStorageContainer::parse(version);
nlassert(m_ChunksOwnsPointers); nlassert(m_ChunksOwnsPointers);
nlassert(m_Chunks.size() == 2); nlassert(m_Chunks.size() == 2);
TStorageObjectContainer::iterator it = m_Chunks.begin(); TStorageObjectContainer::iterator it = m_Chunks.begin();

@ -57,7 +57,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -94,7 +94,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -72,9 +72,9 @@ void CScene::toString(std::ostream &ostream, const std::string &pad) const
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CScene::parse(uint16 version, TParseLevel level) void CScene::parse(uint16 version)
{ {
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
nlassert(m_Chunks.size() == 1); nlassert(m_Chunks.size() == 1);
} }
@ -140,7 +140,7 @@ void CSceneClassContainer::toString(std::ostream &ostream, const std::string &pa
CStorageContainer::toString(ostream, pad); CStorageContainer::toString(ostream, pad);
} }
void CSceneClassContainer::parse(uint16 version, TParseLevel level) void CSceneClassContainer::parse(uint16 version)
{ {
// Temporary 'readonly' implementation, not modifying m_Chunks! // Temporary 'readonly' implementation, not modifying m_Chunks!
m_StorageObjectByIndex.resize(m_Chunks.size()); m_StorageObjectByIndex.resize(m_Chunks.size());
@ -154,7 +154,7 @@ void CSceneClassContainer::parse(uint16 version, TParseLevel level)
nlassert(builtinScene); nlassert(builtinScene);
m_BuiltinScene = dynamic_cast<BUILTIN::CSceneImpl *>(builtinScene); m_BuiltinScene = dynamic_cast<BUILTIN::CSceneImpl *>(builtinScene);
nlassert(m_BuiltinScene); nlassert(m_BuiltinScene);
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
} }
void CSceneClassContainer::clean() void CSceneClassContainer::clean()

@ -71,7 +71,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();
@ -105,7 +105,7 @@ public:
// inherited // inherited
virtual std::string className() const; virtual std::string className() const;
virtual void toString(std::ostream &ostream, const std::string &pad = "") const; virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
virtual void clean(); virtual void clean();
virtual void build(uint16 version); virtual void build(uint16 version);
virtual void disown(); virtual void disown();

@ -125,13 +125,13 @@ void CSceneClass::toString(std::ostream &ostream, const std::string &pad) const
} }
} }
void CSceneClass::parse(uint16 version, TParseLevel level) void CSceneClass::parse(uint16 version)
{ {
// Cannot be parsed yet // Cannot be parsed yet
if (!m_ChunksOwnsPointers) { nlerror("Already parsed"); return; } // Already parsed, illegal to call twice if (!m_ChunksOwnsPointers) { nlerror("Already parsed"); return; } // Already parsed, illegal to call twice
// Parse all child chunks // Parse all child chunks
CStorageContainer::parse(version, level); CStorageContainer::parse(version);
// Orphanize all child chunk // Orphanize all child chunk
m_OrphanedChunks.insert(m_OrphanedChunks.end(), m_Chunks.begin(), m_Chunks.end()); m_OrphanedChunks.insert(m_OrphanedChunks.end(), m_Chunks.begin(), m_Chunks.end());

@ -82,7 +82,7 @@ public:
//! \name Inherited functions called through the storage loading and saving system //! \name Inherited functions called through the storage loading and saving system
//@{ //@{
/// Override this to read a chunk from the chunks stream. Call the parent's parse function first. Get the necessary chunks implemented by your class using getChunk. See the getChunk function for further information. In case of failure, call disown. If m_ChunksOwnsPointers is true, the parsing has failed, warnings have already been printed, and nothing should happen. Chunks are already parsed when you get them from getChunk /// Override this to read a chunk from the chunks stream. Call the parent's parse function first. Get the necessary chunks implemented by your class using getChunk. See the getChunk function for further information. In case of failure, call disown. If m_ChunksOwnsPointers is true, the parsing has failed, warnings have already been printed, and nothing should happen. Chunks are already parsed when you get them from getChunk
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
/// Override this if the chunks you are using are not needed after they have been parsed. You may delete any chunks you own. Call the parent's clean first. You must call clean on any chunks you own if they implement this function /// Override this if the chunks you are using are not needed after they have been parsed. You may delete any chunks you own. Call the parent's clean first. You must call clean on any chunks you own if they implement this function
virtual void clean(); virtual void clean();
/// Override this to write a chunk to the chunks stream. If you create a new chunk, the creating class owns it, and should delete it when clean is called. You no longer own any created chunks when disown has been called. Use putChunk to add the chunk. Call the parent's build first. The putChunk function calls build on added chunks /// Override this to write a chunk to the chunks stream. If you create a new chunk, the creating class owns it, and should delete it when clean is called. You no longer own any created chunks when disown has been called. Use putChunk to add the chunk. Call the parent's build first. The putChunk function calls build on added chunks

@ -194,14 +194,14 @@ void CStorageContainer::toString(std::ostream &ostream, const std::string &pad)
ostream << "} "; ostream << "} ";
} }
void CStorageContainer::parse(uint16 version, TParseLevel level) void CStorageContainer::parse(uint16 version)
{ {
nlassert(m_ChunksOwnsPointers); // Can only use this when m_Chunks still has ownership. nlassert(m_ChunksOwnsPointers); // Can only use this when m_Chunks still has ownership.
for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it)
{ {
if (it->second->isContainer()) if (it->second->isContainer())
{ {
static_cast<CStorageContainer *>(it->second)->parse(version, level); static_cast<CStorageContainer *>(it->second)->parse(version);
} }
} }
} }

@ -112,7 +112,7 @@ public:
// virtual // virtual
// Parse this class with given version and parse level filter // Parse this class with given version and parse level filter
virtual void parse(uint16 version, TParseLevel level); virtual void parse(uint16 version);
// Clean up built data or duplicate unparsed source data, call after serializing build and after parse // Clean up built data or duplicate unparsed source data, call after serializing build and after parse
virtual void clean(); virtual void clean();
// Build the storage structure needed to store the parsed data back // Build the storage structure needed to store the parsed data back

@ -110,7 +110,7 @@ int main(int argc, char **argv)
g_object_unref(input); g_object_unref(input);
//dllDirectory.toString(std::cout); //dllDirectory.toString(std::cout);
//std::cout << "\n"; //std::cout << "\n";
dllDirectory.parse(PIPELINE::MAX::VersionUnknown, PIPELINE::MAX::PARSE_INTERNAL); // parse the structure to readable data dllDirectory.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data
dllDirectory.clean(); // cleanup unused file structure dllDirectory.clean(); // cleanup unused file structure
dllDirectory.toString(std::cout); dllDirectory.toString(std::cout);
std::cout << "\n"; std::cout << "\n";
@ -132,7 +132,7 @@ int main(int argc, char **argv)
g_object_unref(input); g_object_unref(input);
//classDirectory3.toString(std::cout); //classDirectory3.toString(std::cout);
//std::cout << "\n"; //std::cout << "\n";
classDirectory3.parse(PIPELINE::MAX::VersionUnknown, PIPELINE::MAX::PARSE_INTERNAL); // parse the structure to readable data classDirectory3.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data
classDirectory3.clean(); // cleanup unused file structure classDirectory3.clean(); // cleanup unused file structure
classDirectory3.toString(std::cout); classDirectory3.toString(std::cout);
std::cout << "\n"; std::cout << "\n";
@ -155,9 +155,7 @@ int main(int argc, char **argv)
g_object_unref(input); g_object_unref(input);
//classDirectory3.toString(std::cout); //classDirectory3.toString(std::cout);
//std::cout << "\n"; //std::cout << "\n";
scene.parse(PIPELINE::MAX::VersionUnknown, (PIPELINE::MAX::TParseLevel)( scene.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data
PIPELINE::MAX::PARSE_INTERNAL
| PIPELINE::MAX::PARSE_BUILTIN)); // parse the structure to readable data
scene.clean(); // cleanup unused file structure scene.clean(); // cleanup unused file structure
// TEST -> // TEST ->
nldebug("BUILD"); nldebug("BUILD");
@ -165,9 +163,7 @@ int main(int argc, char **argv)
nldebug("DISOWN"); nldebug("DISOWN");
scene.disown(); scene.disown();
nldebug("PARSE"); nldebug("PARSE");
scene.parse(PIPELINE::MAX::VersionUnknown, (PIPELINE::MAX::TParseLevel)( scene.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data
PIPELINE::MAX::PARSE_INTERNAL
| PIPELINE::MAX::PARSE_BUILTIN)); // parse the structure to readable data
nldebug("CLEAN"); nldebug("CLEAN");
scene.clean(); // cleanup unused file structure scene.clean(); // cleanup unused file structure
// <- TEST // <- TEST

Loading…
Cancel
Save