Added: #1440 Initial functionality for DllDirectory

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent c1279c1a6e
commit 8946674dd0

@ -237,9 +237,11 @@ void CClassDirectory3::disown()
const CClassEntry *CClassDirectory3::get(uint16 index) const const CClassEntry *CClassDirectory3::get(uint16 index) const
{ {
nlassert(!ChunksOwnsPointers); nlassert(!ChunksOwnsPointers);
nlassert(index < m_Entries.size());
return m_Entries[index]; return m_Entries[index];
} }
// Parallel to CDllDirectory
void CClassDirectory3::reset() void CClassDirectory3::reset()
{ {
nlassert(!ChunksOwnsPointers); nlassert(!ChunksOwnsPointers);
@ -251,6 +253,7 @@ void CClassDirectory3::reset()
m_ClassIdToIndex.clear(); m_ClassIdToIndex.clear();
} }
// Parallel to CDllDirectory
uint16 CClassDirectory3::getOrCreateIndex(const ISceneClassDesc *sceneClassDesc) uint16 CClassDirectory3::getOrCreateIndex(const ISceneClassDesc *sceneClassDesc)
{ {
nlassert(!ChunksOwnsPointers); nlassert(!ChunksOwnsPointers);

@ -140,15 +140,19 @@ void CDllDirectory::parse(uint16 version, TParseLevel level)
switch (id) switch (id)
{ {
case 0x2038: // DllEntry case 0x2038: // DllEntry
if (parsedDllEntry && (lastCached != id))
throw EStorageParse(); // There were chunks inbetween
if (!parsedDllEntry)
{ {
m_ChunkCache.push_back(TStorageObjectWithId(id, NULL)); // Dummy entry to know the location if (parsedDllEntry && (lastCached != id))
lastCached = id; throw EStorageParse(); // There were chunks inbetween
parsedDllEntry = true; if (!parsedDllEntry)
{
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);
} }
m_Entries.push_back(static_cast<CDllEntry *>(it->second));
break; break;
default: default:
m_ChunkCache.push_back(*it); // Dummy entry to know the location m_ChunkCache.push_back(*it); // Dummy entry to know the location
@ -222,6 +226,7 @@ void CDllDirectory::disown()
CStorageContainer::disown(); CStorageContainer::disown();
m_ChunkCache.clear(); m_ChunkCache.clear();
m_Entries.clear(); m_Entries.clear();
m_InternalNameToIndex.clear();
// Ownership goes back to Chunks // Ownership goes back to Chunks
ChunksOwnsPointers = true; ChunksOwnsPointers = true;
@ -233,6 +238,37 @@ const CDllEntry *CDllDirectory::get(uint16 index) const
return m_Entries[index]; return m_Entries[index];
} }
// Parallel to CClassDirectory3
void CDllDirectory::reset()
{
nlassert(!ChunksOwnsPointers);
for (std::vector<CDllEntry *>::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit)
{
delete (*subit);
}
m_Entries.clear();
m_InternalNameToIndex.clear();
}
// Parallel to CClassDirectory3
uint16 CDllDirectory::getOrCreateIndex(const IDllPluginDesc *dllPluginDesc)
{
nlassert(!ChunksOwnsPointers);
std::map<ucstring, uint16>::iterator it = m_InternalNameToIndex.find(NLMISC::toLower(ucstring(dllPluginDesc->internalName())));
// Return existing index
if (it != m_InternalNameToIndex.end())
return it->second;
// Create new entry
/*CClassEntry *classEntry = new CClassEntry(sceneClassDesc);
uint16 index = m_Entries.size();
m_ClassIdToIndex[classEntry->classId()] = index;
m_Entries.push_back(classEntry);
return index;*/
return 0xFFFF;
}
IStorageObject *CDllDirectory::createChunkById(uint16 id, bool container) IStorageObject *CDllDirectory::createChunkById(uint16 id, bool container)
{ {
if (container) if (container)

@ -36,6 +36,7 @@
// Project includes // Project includes
#include "storage_object.h" #include "storage_object.h"
#include "storage_value.h" #include "storage_value.h"
#include "dll_plugin_desc.h"
namespace PIPELINE { namespace PIPELINE {
namespace MAX { namespace MAX {
@ -63,7 +64,12 @@ public:
virtual void disown(); virtual void disown();
// 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(uint16 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 IDllPluginDesc *dllPluginDesc);
protected: protected:
virtual IStorageObject *createChunkById(uint16 id, bool container); virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -71,6 +77,7 @@ protected:
private: private:
TStorageObjectContainer m_ChunkCache; TStorageObjectContainer m_ChunkCache;
std::vector<CDllEntry *> m_Entries; std::vector<CDllEntry *> m_Entries;
std::map<ucstring, uint16> m_InternalNameToIndex;
}; /* class CDllDirectory */ }; /* class CDllDirectory */

@ -53,6 +53,8 @@ const ucchar *CDllPluginDescBuiltin::internalName() const
return value.c_str(); return value.c_str();
} }
const CDllPluginDescBuiltin DllPluginDescBuiltin;
const ucchar *CDllPluginDescScript::displayName() const const ucchar *CDllPluginDescScript::displayName() const
{ {
static const ucstring value = ucstring("Script"); static const ucstring value = ucstring("Script");
@ -65,6 +67,8 @@ const ucchar *CDllPluginDescScript::internalName() const
return value.c_str(); return value.c_str();
} }
const CDllPluginDescScript DllPluginDescScript;
} /* namespace MAX */ } /* namespace MAX */
} /* namespace PIPELINE */ } /* namespace PIPELINE */

@ -82,6 +82,8 @@ class CDllPluginDescBuiltin : public IDllPluginDescInternal
virtual const ucchar *internalName() const; virtual const ucchar *internalName() const;
}; /* class CDllPluginDescBuiltin */ }; /* class CDllPluginDescBuiltin */
extern const CDllPluginDescBuiltin DllPluginDescBuiltin;
/** /**
* \brief CDllPluginDescScript * \brief CDllPluginDescScript
* \date 2012-08-20 09:59GMT * \date 2012-08-20 09:59GMT
@ -95,6 +97,8 @@ class CDllPluginDescScript : public IDllPluginDescInternal
virtual const ucchar *internalName() const; virtual const ucchar *internalName() const;
}; /* class CDllPluginDescScript */ }; /* class CDllPluginDescScript */
extern const CDllPluginDescScript DllPluginDescScript;
} /* namespace MAX */ } /* namespace MAX */
} /* namespace PIPELINE */ } /* namespace PIPELINE */

Loading…
Cancel
Save