Added: #1440 Internal DllDirectory indices

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent b175f4e8bc
commit 0286e6bf72

@ -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<ucstring, uint16>::iterator it = m_InternalNameToIndex.find(NLMISC::toLower(ucstring(dllPluginDesc->internalName())));
std::map<ucstring, sint32>::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)

@ -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<ucstring> *m_DllDescription;
CStorageValue<ucstring> *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<CDllEntry *> m_Entries;
std::map<ucstring, uint16> m_InternalNameToIndex;
std::map<ucstring, sint32> 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<ucstring> *m_DllDescription;
CStorageValue<ucstring> *m_DllFilename;
const CDllEntry m_DllEntryBuiltin;
const CDllEntry m_DllEntryScript;
}; /* class CDllDirectory */

@ -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 */

Loading…
Cancel
Save