Added: #1440 Clean duplicate unparsed data after parsing

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 93365f8618
commit 2042692ad1

@ -70,6 +70,11 @@ void CClassData::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CClassData::clean()
{
CStorageContainer::clean();
}
void CClassData::build(uint16 version)
{
CStorageContainer::build(version);
@ -122,6 +127,11 @@ void CClassDataEntry::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CClassDataEntry::clean()
{
CStorageContainer::clean();
}
void CClassDataEntry::build(uint16 version)
{
CStorageContainer::build(version);

@ -57,6 +57,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -81,6 +82,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();

@ -70,6 +70,11 @@ void CClassDirectory3::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CClassDirectory3::clean()
{
CStorageContainer::clean();
}
void CClassDirectory3::build(uint16 version)
{
CStorageContainer::build(version);
@ -122,6 +127,11 @@ void CClassEntry::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CClassEntry::clean()
{
CStorageContainer::clean();
}
void CClassEntry::build(uint16 version)
{
CStorageContainer::build(version);

@ -57,6 +57,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -81,6 +82,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();

@ -71,6 +71,11 @@ void CConfig::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CConfig::clean()
{
CStorageContainer::clean();
}
void CConfig::build(uint16 version)
{
CStorageContainer::build(version);
@ -133,6 +138,11 @@ void CConfig20a0::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CConfig20a0::clean()
{
CStorageContainer::clean();
}
void CConfig20a0::build(uint16 version)
{
CStorageContainer::build(version);
@ -193,6 +203,11 @@ void CConfig20a0Entry::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CConfig20a0Entry::clean()
{
CStorageContainer::clean();
}
void CConfig20a0Entry::build(uint16 version)
{
CStorageContainer::build(version);
@ -280,6 +295,11 @@ void CConfigScript::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CConfigScript::clean()
{
CStorageContainer::clean();
}
void CConfigScript::build(uint16 version)
{
CStorageContainer::build(version);
@ -332,6 +352,11 @@ void CConfigScriptEntry::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CConfigScriptEntry::clean()
{
CStorageContainer::clean();
}
void CConfigScriptEntry::build(uint16 version)
{
CStorageContainer::build(version);
@ -425,6 +450,11 @@ void CConfigScriptMetaContainer::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CConfigScriptMetaContainer::clean()
{
CStorageContainer::clean();
}
void CConfigScriptMetaContainer::build(uint16 version)
{
CStorageContainer::build(version);

@ -57,6 +57,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -81,6 +82,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -105,6 +107,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -129,6 +132,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -153,6 +157,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -201,6 +206,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();

@ -48,7 +48,20 @@ CDllDirectory::CDllDirectory()
CDllDirectory::~CDllDirectory()
{
// TODO: Delete m_ChunkCache and m_Entries when !ChunksOwnsPointers
// Delete m_ChunkCache and m_Entries when !ChunksOwnsPointers
if (!ChunksOwnsPointers)
{
for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it)
{
delete it->second;
}
for (std::vector<CDllEntry *>::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit)
{
delete (*subit);
}
}
m_ChunkCache.clear();
m_Entries.clear();
}
std::string CDllDirectory::getClassName()
@ -141,13 +154,35 @@ void CDllDirectory::parse(uint16 version, TParseLevel level)
}
}
void CDllDirectory::clean()
{
// Ensure parsed
nlassert(!ChunksOwnsPointers);
// Clear Chunks
Chunks.clear();
// Clean chunks
for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it)
{
if (it->second != NULL && it->second->isContainer())
{
static_cast<CStorageContainer *>(it->second)->clean();
}
}
for (std::vector<CDllEntry *>::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit)
{
(*subit)->clean();
}
}
void CDllDirectory::build(uint16 version)
{
// Ensure parsed
nlassert(!ChunksOwnsPointers);
// Initialize
Chunks.clear();
nlassert(Chunks.empty());
// Set up the Chunks list, when (CDllEntry::ID, NULL) is found write out all of the entries.
for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it)
@ -165,7 +200,7 @@ void CDllDirectory::build(uint16 version)
}
}
// Build the entries last
// Build the entries last (after Chunks is built)
CStorageContainer::build(version);
// NOTE: Ownership remains with m_ChunkCache and m_Entries
@ -251,6 +286,12 @@ void CDllEntry::parse(uint16 version, TParseLevel level)
// ++it;
}
void CDllEntry::clean()
{
// Nothing to do here! (Chunks retains ownership)
// CStorageContainer::clean();
}
void CDllEntry::build(uint16 version)
{
// Nothing to do here!

@ -59,6 +59,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -90,6 +91,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();

@ -71,6 +71,11 @@ void CScene::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CScene::clean()
{
CStorageContainer::clean();
}
void CScene::build(uint16 version)
{
CStorageContainer::build(version);
@ -120,6 +125,11 @@ void CSceneClassContainer::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CSceneClassContainer::clean()
{
CStorageContainer::clean();
}
void CSceneClassContainer::build(uint16 version)
{
CStorageContainer::build(version);
@ -170,6 +180,11 @@ void CSceneClass::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
}
void CSceneClass::clean()
{
CStorageContainer::clean();
}
void CSceneClass::build(uint16 version)
{
CStorageContainer::build(version);

@ -60,6 +60,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -84,6 +85,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
@ -110,6 +112,7 @@ public:
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();

@ -95,8 +95,12 @@ CStorageContainer::~CStorageContainer()
{
if (ChunksOwnsPointers)
{
for (TStorageObjectContainer::iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it)
{
delete it->second;
}
}
Chunks.clear();
}
std::string CStorageContainer::getClassName() // why is this not const in IClassable?
@ -180,6 +184,18 @@ void CStorageContainer::parse(uint16 version, TParseLevel level)
}
}
void CStorageContainer::clean()
{
nlassert(ChunksOwnsPointers); // Can only use the default when Chunks retains ownership.
for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it)
{
if (it->second->isContainer())
{
static_cast<CStorageContainer *>(it->second)->clean();
}
}
}
void CStorageContainer::build(uint16 version)
{
for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it)

@ -120,9 +120,11 @@ public:
// virtual
// Parse this class with given version and parse level filter
virtual void parse(uint16 version, TParseLevel level);
// Clean up built data or duplicate unparsed source data, call after serializing build and after parse
virtual void clean();
// Build the storage structure needed to store the parsed data back
virtual void build(uint16 version);
// Give ownership of the chunks back to the Chunks, must build first
// Give ownership of the chunks back to the Chunks, must call build first, call instead of clean, reduces the parse level back to 0
virtual void disown();
public: // should be protected but that doesn't compile, nice c++!

@ -86,6 +86,7 @@ int main(int argc, char **argv)
dllDirectory.toString(std::cout);
std::cout << "\n";
dllDirectory.parse(PIPELINE::MAX::VersionUnknown, PIPELINE::MAX::PARSE_INTERNAL);
dllDirectory.clean();
dllDirectory.toString(std::cout);
std::cout << "\n";
dllDirectory.build(PIPELINE::MAX::VersionUnknown);

Loading…
Cancel
Save