Changed: #1440 Make template for unknown classes so they can be based on the superclasses

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 96ebef489d
commit 9775de10ea

@ -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<IStorageObject *>(new CSceneClassUnknown<CSceneClass>(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<IStorageObject *>(new CSceneClassUnknown(dllEntry, classEntry));
return static_cast<IStorageObject *>(new CSceneClassUnknown<CSceneClass>(dllEntry, classEntry));
}
}

@ -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()
{

@ -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);

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

@ -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 <typename TSuperClass>
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;

Loading…
Cancel
Save