From 9775de10eaacdad23e7cfe5a5e1e8f73024b6f16 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 21 Aug 2012 23:29:18 +0200 Subject: [PATCH] Changed: #1440 Make template for unknown classes so they can be based on the superclasses --HG-- branch : build_pipeline_v3 --- code/nel/tools/pipeline/max/scene.cpp | 8 ++- code/nel/tools/pipeline/max/scene_class.cpp | 15 +++++ code/nel/tools/pipeline/max/scene_class.h | 2 +- .../pipeline/max/scene_class_unknown.cpp | 66 +------------------ .../tools/pipeline/max/scene_class_unknown.h | 20 ++---- 5 files changed, 28 insertions(+), 83 deletions(-) diff --git a/code/nel/tools/pipeline/max/scene.cpp b/code/nel/tools/pipeline/max/scene.cpp index de125ad43..6339b4cab 100644 --- a/code/nel/tools/pipeline/max/scene.cpp +++ b/code/nel/tools/pipeline/max/scene.cpp @@ -165,7 +165,9 @@ IStorageObject *CSceneClassContainer::createChunkById(uint16 id, bool container) { // Known unknown special identifiers... case 0x2032: - return CStorageContainer::createChunkById(id, container); + case 0x2033: + return new CSceneClass(); // TODO: Make dummy dllentry and classentry for these... + // return static_cast(new CSceneClassUnknown(dllEntry, classEntry)); } const CClassEntry *classEntry = m_ClassDirectory3->get(id); CSceneClass *sceneClass = m_SceneClassRegistry->create(classEntry->classId()); @@ -175,9 +177,9 @@ IStorageObject *CSceneClassContainer::createChunkById(uint16 id, bool container) } else { - // Create an unknown scene class + // Create an unknown scene class; TODO: By TSClassId, maybe the registry should have a createUnknown(TSuperClassId) const CDllEntry *dllEntry = m_DllDirectory->get(classEntry->dllIndex()); - return static_cast(new CSceneClassUnknown(dllEntry, classEntry)); + return static_cast(new CSceneClassUnknown(dllEntry, classEntry)); } } diff --git a/code/nel/tools/pipeline/max/scene_class.cpp b/code/nel/tools/pipeline/max/scene_class.cpp index 224d025e9..4eb645c80 100644 --- a/code/nel/tools/pipeline/max/scene_class.cpp +++ b/code/nel/tools/pipeline/max/scene_class.cpp @@ -49,6 +49,21 @@ namespace MAX { //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// +// Elevate warnings to errors in this file for stricter reading +#undef nlwarning +#define nlwarning nlerror + +// Elevate debug to error in this file for debugging +// #undef nldebug +// #define nldebug nlerror + +// Chunk identifiers +// #define ... + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + CSceneClass::CSceneClass() { diff --git a/code/nel/tools/pipeline/max/scene_class.h b/code/nel/tools/pipeline/max/scene_class.h index 78e1a433e..36673fd85 100644 --- a/code/nel/tools/pipeline/max/scene_class.h +++ b/code/nel/tools/pipeline/max/scene_class.h @@ -102,7 +102,7 @@ public: protected: //! \name Methods used by inheriting classes to read and write to the storage safely //@{ - /// Use during parsing. Gets the chunk with specified id. Warnings when chunks are skipped may be elevated to errors. Remaining orphaned chunks will be appended after chunks that are written by the classes. Returns NULL when the chunk does not exist. Empty chunks are often not written by classes. You have ownership over the chunk until it is disowned. In case that the chunk cannot be parsed, call disown and abort parsing. If this function returns NULL it is also possible that the parsing has been aborted when m_ChunksOwnsPointers is true + /// Use during parsing. Gets the chunk with specified id. Warnings when chunks are skipped may be elevated to errors. Remaining orphaned chunks will be appended after chunks that are written by the classes. Returns NULL when the chunk does not exist. Empty chunks are often not written by classes. You have ownership over the chunk until it is disowned. In case that the chunk cannot be parsed, call disown and abort parsing, or you may keep the chunk as is without modifications and put it back as is during build with putChunk. If this function returns NULL it is also possible that the parsing has been aborted when m_ChunksOwnsPointers is true IStorageObject *getChunk(uint16 id); /// Use during file build. Adds a chunk to the chunks that will be written to the file. Build is called when a chunk is passed through void putChunk(uint16 id, IStorageObject *storageObject); diff --git a/code/nel/tools/pipeline/max/scene_class_unknown.cpp b/code/nel/tools/pipeline/max/scene_class_unknown.cpp index 99bacb434..94d6f1962 100644 --- a/code/nel/tools/pipeline/max/scene_class_unknown.cpp +++ b/code/nel/tools/pipeline/max/scene_class_unknown.cpp @@ -76,7 +76,7 @@ CSceneClass *CSceneClassUnknownDesc::create() const void CSceneClassUnknownDesc::destroy(CSceneClass *sc) const { - nlassert(false); + delete sc; } const ucchar *CSceneClassUnknownDesc::displayName() const @@ -86,6 +86,7 @@ const ucchar *CSceneClassUnknownDesc::displayName() const const char *CSceneClassUnknownDesc::internalName() const { + // TODO: Get by SuperClassId, make like BlahUnknown return "SceneClassUnknown"; } @@ -108,69 +109,6 @@ const IDllPluginDescInternal *CSceneClassUnknownDesc::dllPluginDesc() const //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -CSceneClassUnknown::CSceneClassUnknown(const CDllEntry *dllEntry, const CClassEntry *classEntry) : m_Desc(dllEntry, classEntry) -{ - -} - -CSceneClassUnknown::~CSceneClassUnknown() -{ - -} - -void CSceneClassUnknown::toString(std::ostream &ostream, const std::string &pad) -{ - /*nlassert(m_ChunksOwnsPointers); - ostream << "(" << getClassName() << ": " << ucstring(getClassDesc()->displayName()).toUtf8() << ", " << getClassDesc()->classId().toString() << ", " << ucstring(getClassDesc()->dllPluginDesc()->internalName()).toUtf8() << ") [" << m_Chunks.size() << "] { "; - std::string padpad = pad + "\t"; - sint i = 0; - for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) - { - std::stringstream ss; - ss << std::hex << std::setfill('0'); - ss << std::setw(4) << it->first; - ostream << "\n" << pad << i << " 0x" << ss.str() << ": "; - it->second->toString(ostream, padpad); - ++i; - } - ostream << "} ";*/ - CSceneClass::toString(ostream, pad); -} - -void CSceneClassUnknown::parse(uint16 version, TParseLevel level) -{ - CSceneClass::parse(version, level); -} - -void CSceneClassUnknown::clean() -{ - CSceneClass::clean(); -} - -void CSceneClassUnknown::build(uint16 version) -{ - CSceneClass::build(version); -} - -void CSceneClassUnknown::disown() -{ - CSceneClass::disown(); -} - -IStorageObject *CSceneClassUnknown::createChunkById(uint16 id, bool container) -{ - return CSceneClass::createChunkById(id, container); -} - -const ISceneClassDesc *CSceneClassUnknown::getClassDesc() -{ - return &m_Desc; -} - -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// - } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/scene_class_unknown.h b/code/nel/tools/pipeline/max/scene_class_unknown.h index aa4275bce..177ef3ae8 100644 --- a/code/nel/tools/pipeline/max/scene_class_unknown.h +++ b/code/nel/tools/pipeline/max/scene_class_unknown.h @@ -80,7 +80,6 @@ public: private: ucstring m_DisplayName; - std::string m_InternalName; NLMISC::CClassId m_ClassId; TSClassId m_SuperClassId; CSceneClassUnknownDllPluginDesc m_DllPluginDesc; @@ -94,24 +93,15 @@ private: * Utility class for parsing unknown scene classes and keeping them * in storage as is. */ -class CSceneClassUnknown : public CSceneClass +template +class CSceneClassUnknown : public TSuperClass { public: - CSceneClassUnknown(const CDllEntry *dllEntry, const CClassEntry *classEntry); - virtual ~CSceneClassUnknown(); + CSceneClassUnknown(const CDllEntry *dllEntry, const CClassEntry *classEntry) : m_Desc(dllEntry, classEntry) { } + virtual ~CSceneClassUnknown() { } // inherited - 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(); - - // virtual - virtual const ISceneClassDesc *getClassDesc(); - -protected: - virtual IStorageObject *createChunkById(uint16 id, bool container); + virtual const ISceneClassDesc *getClassDesc() { return &m_Desc; } private: CSceneClassUnknownDesc m_Desc;