From 0286e6bf72ad874c9327b56b9effa06a43e993c8 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 20 Aug 2012 15:22:13 +0200 Subject: [PATCH] Added: #1440 Internal DllDirectory indices --HG-- branch : build_pipeline_v3 --- code/nel/tools/pipeline/max/dll_directory.cpp | 40 +++++++++-- code/nel/tools/pipeline/max/dll_directory.h | 72 ++++++++++--------- code/nel/tools/pipeline/max/dll_plugin_desc.h | 2 + 3 files changed, 73 insertions(+), 41 deletions(-) diff --git a/code/nel/tools/pipeline/max/dll_directory.cpp b/code/nel/tools/pipeline/max/dll_directory.cpp index c38232c5e..ad2d799bd 100644 --- a/code/nel/tools/pipeline/max/dll_directory.cpp +++ b/code/nel/tools/pipeline/max/dll_directory.cpp @@ -46,7 +46,7 @@ namespace MAX { //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -CDllDirectory::CDllDirectory() +CDllDirectory::CDllDirectory() : m_DllEntryBuiltin(&DllPluginDescBuiltin), m_DllEntryScript(&DllPluginDescScript) { } @@ -130,6 +130,7 @@ void CDllDirectory::parse(uint16 version, TParseLevel level) CStorageContainer::parse(version, level); // Initialize + addInternalIndices(); uint16 lastCached = 0xFFFF; bool parsedDllEntry = false; @@ -233,11 +234,29 @@ void CDllDirectory::disown() } // Parallel to CClassDirectory3 -const CDllEntry *CDllDirectory::get(uint16 index) const +const CDllEntry *CDllDirectory::get(sint32 index) const { nlassert(!ChunksOwnsPointers); - nlassert(index < m_Entries.size()); - return m_Entries[index]; + if (index < 0) + { + // Handle internal dummy values + switch (index) + { + case -1: + return &m_DllEntryBuiltin; + case -2: + return &m_DllEntryScript; + default: + nlerror("Bad dll entry index"); + } + } + else + { + nlassert(index < (sint32)m_Entries.size()); + return m_Entries[index]; + } + nlassert(false); + return NULL; } // Parallel to CClassDirectory3 @@ -250,13 +269,14 @@ void CDllDirectory::reset() } m_Entries.clear(); m_InternalNameToIndex.clear(); + addInternalIndices(); } // Parallel to CClassDirectory3 -uint16 CDllDirectory::getOrCreateIndex(const IDllPluginDescInternal *dllPluginDesc) +sint32 CDllDirectory::getOrCreateIndex(const IDllPluginDescInternal *dllPluginDesc) { nlassert(!ChunksOwnsPointers); - std::map::iterator it = m_InternalNameToIndex.find(NLMISC::toLower(ucstring(dllPluginDesc->internalName()))); + std::map::iterator it = m_InternalNameToIndex.find(NLMISC::toLower(ucstring(dllPluginDesc->internalName()))); // Return existing index if (it != m_InternalNameToIndex.end()) @@ -264,12 +284,18 @@ uint16 CDllDirectory::getOrCreateIndex(const IDllPluginDescInternal *dllPluginDe // Create new entry CDllEntry *dllEntry = new CDllEntry(dllPluginDesc); - uint16 index = m_Entries.size(); + sint32 index = m_Entries.size(); m_InternalNameToIndex[NLMISC::toLower(dllEntry->dllFilename())] = index; m_Entries.push_back(dllEntry); return index; } +void CDllDirectory::addInternalIndices() +{ + m_InternalNameToIndex[NLMISC::toLower(ucstring(DllPluginDescBuiltin.internalName()))] = -1; + m_InternalNameToIndex[NLMISC::toLower(ucstring(DllPluginDescScript.internalName()))] = -2; +} + IStorageObject *CDllDirectory::createChunkById(uint16 id, bool container) { if (container) diff --git a/code/nel/tools/pipeline/max/dll_directory.h b/code/nel/tools/pipeline/max/dll_directory.h index f4020de39..5823ac7c8 100644 --- a/code/nel/tools/pipeline/max/dll_directory.h +++ b/code/nel/tools/pipeline/max/dll_directory.h @@ -41,7 +41,36 @@ namespace PIPELINE { namespace MAX { -class CDllEntry; +/** + * \brief CDllEntry + * \date 2012-08-18 09:01GMT + * \author Jan Boon (Kaetemi) + * CDllEntry + */ +class CDllEntry : public CStorageContainer +{ +public: + CDllEntry(); + CDllEntry(const IDllPluginDescInternal *dllPluginDesc); + virtual ~CDllEntry(); + + // inherited + 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(); + + const ucstring &dllDescription() const { return m_DllDescription->Value; } + const ucstring &dllFilename() const { return m_DllFilename->Value; } + +protected: + virtual IStorageObject *createChunkById(uint16 id, bool container); + CStorageValue *m_DllDescription; + CStorageValue *m_DllFilename; + +}; /* class CDllDirectory */ /** * \brief CDllDirectory @@ -72,11 +101,14 @@ public: // public // Get a dll entry corresponding to a chunk index, pointers become invalid after reset - const CDllEntry *get(uint16 index) const; + const CDllEntry *get(sint32 index) const; // Reset the dll directory, all dll entry pointers become invalid, use internal name and dll plugin registry void reset(); // Get or create the chunk index for a dll by dll plugin description - uint16 getOrCreateIndex(const IDllPluginDescInternal *dllPluginDesc); + sint32 getOrCreateIndex(const IDllPluginDescInternal *dllPluginDesc); + +private: + void addInternalIndices(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -84,38 +116,10 @@ protected: private: TStorageObjectContainer m_ChunkCache; std::vector m_Entries; - std::map m_InternalNameToIndex; + std::map m_InternalNameToIndex; -}; /* class CDllDirectory */ - -/** - * \brief CDllEntry - * \date 2012-08-18 09:01GMT - * \author Jan Boon (Kaetemi) - * CDllDirectory - */ -class CDllEntry : public CStorageContainer -{ -public: - CDllEntry(); - CDllEntry(const IDllPluginDescInternal *dllPluginDesc); - virtual ~CDllEntry(); - - // inherited - 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(); - - const ucstring &dllDescription() const { return m_DllDescription->Value; } - const ucstring &dllFilename() const { return m_DllFilename->Value; } - -protected: - virtual IStorageObject *createChunkById(uint16 id, bool container); - CStorageValue *m_DllDescription; - CStorageValue *m_DllFilename; + const CDllEntry m_DllEntryBuiltin; + const CDllEntry m_DllEntryScript; }; /* class CDllDirectory */ diff --git a/code/nel/tools/pipeline/max/dll_plugin_desc.h b/code/nel/tools/pipeline/max/dll_plugin_desc.h index 5fc951ef9..3aa76cd39 100644 --- a/code/nel/tools/pipeline/max/dll_plugin_desc.h +++ b/code/nel/tools/pipeline/max/dll_plugin_desc.h @@ -78,6 +78,7 @@ public: */ class CDllPluginDescBuiltin : public IDllPluginDescInternal { +public: virtual const ucchar *displayName() const; virtual const ucchar *internalName() const; }; /* class CDllPluginDescBuiltin */ @@ -93,6 +94,7 @@ extern const CDllPluginDescBuiltin DllPluginDescBuiltin; */ class CDllPluginDescScript : public IDllPluginDescInternal { +public: virtual const ucchar *displayName() const; virtual const ucchar *internalName() const; }; /* class CDllPluginDescScript */