diff --git a/code/nel/tools/pipeline/max/storage_object.cpp b/code/nel/tools/pipeline/max/storage_object.cpp index 2b43b5a09..8221e932d 100644 --- a/code/nel/tools/pipeline/max/storage_object.cpp +++ b/code/nel/tools/pipeline/max/storage_object.cpp @@ -157,13 +157,17 @@ void CStorageContainer::serial(CStorageChunks &chunks) while (chunks.enterChunk()) { uint16 id = chunks.getChunkId(); - IStorageObject *storageObject = createChunkById(id, chunks.isChunkContainer()); + bool cont = chunks.isChunkContainer(); + IStorageObject *storageObject = createChunkById(id, cont); storageObject->setSize(chunks.getChunkSize()); if (storageObject->isContainer()) static_cast(storageObject)->serial(chunks); else storageObject->serial(chunks.stream()); Chunks.push_back(TStorageObjectWithId(id, storageObject)); if (chunks.leaveChunk()) // bytes were skipped while reading throw EStorage(); + TStorageObjectContainer::iterator soit = Chunks.end(); + --soit; + serialized(soit, cont); } } else @@ -189,6 +193,11 @@ IStorageObject *CStorageContainer::createChunkById(uint16 id, bool container) } } +void CStorageContainer::serialized(TStorageObjectContainer::iterator soit, bool container) +{ + +} + //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// diff --git a/code/nel/tools/pipeline/max/storage_object.h b/code/nel/tools/pipeline/max/storage_object.h index d6a141964..1e0c00109 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -71,7 +71,7 @@ class CStorageContainer : public IStorageObject public: // public data typedef std::pair TStorageObjectWithId; - typedef std::vector TStorageObjectContainer; + typedef std::list TStorageObjectContainer; TStorageObjectContainer Chunks; // inherited @@ -86,7 +86,10 @@ public: // should be protected but that doesn't compile, nice c++! protected: // override in subclasses, default to parent if not handled virtual void serial(CStorageChunks &chunks); + // Create a storage object by id, override to provide custom serialization virtual IStorageObject *createChunkById(uint16 id, bool container); + // Callback when a storage object has been serialized and put in the chunks list, override to index them + virtual void serialized(TStorageObjectContainer::iterator soit, bool container); }; // CStorageRaw : serializes raw data, use for unknown data diff --git a/code/nel/tools/pipeline/max/storage_value.cpp b/code/nel/tools/pipeline/max/storage_value.cpp new file mode 100644 index 000000000..de3e7c3ec --- /dev/null +++ b/code/nel/tools/pipeline/max/storage_value.cpp @@ -0,0 +1,47 @@ +/** + * \file storage_value.cpp + * \brief CStorageValue + * \date 2012-08-18 15:00GMT + * \author Jan Boon (Kaetemi) + * CStorageValue + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE PIPELINE. If not, see + * . + */ + +#include +#include "storage_value.h" + +// STL includes + +// NeL includes +// #include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace PIPELINE { + +void dummy_storage_value_cpp() { } + +} /* namespace PIPELINE */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/max/storage_value.h b/code/nel/tools/pipeline/max/storage_value.h new file mode 100644 index 000000000..9661033c3 --- /dev/null +++ b/code/nel/tools/pipeline/max/storage_value.h @@ -0,0 +1,137 @@ +/** + * \file storage_value.h + * \brief CStorageValue + * \date 2012-08-18 15:00GMT + * \author Jan Boon (Kaetemi) + * CStorageValue + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE PIPELINE. If not, see + * . + */ + +#ifndef PIPELINE_STORAGE_VALUE_H +#define PIPELINE_STORAGE_VALUE_H +#include + +// STL includes + +// NeL includes +#include + +// Project includes +#include "storage_object.h" + +namespace PIPELINE { +namespace MAX { + +template +class CStorageValue : public IStorageObject +{ +public: + // public data + typedef T TType; + TType Value; + + // inherited + virtual std::string getClassName(); + virtual void serial(NLMISC::IStream &stream); + virtual void toString(std::ostream &ostream, const std::string &pad = ""); + +public: // should be protected but that doesn't compile, nice c++! + // Sets size when reading + virtual void setSize(sint32 size); + // Gets the size when writing, return false if unknown + virtual bool getSize(sint32 &size) const; +}; + +template +std::string getClassName() +{ + return "CStorageValue"; +} + +template +void CStorageValue::serial(NLMISC::IStream &stream) +{ + stream.serial(Value); +} + +template <> +void CStorageValue::serial(NLMISC::IStream &stream) +{ + stream.serialBuffer(static_cast(static_cast(&Value[0])), Value.size()); +} + +template <> +void CStorageValue::serial(NLMISC::IStream &stream) +{ + stream.serialBuffer(static_cast(static_cast(&Value[0])), Value.size() * 2); +} + +template +void CStorageValue::toString(std::ostream &ostream, const std::string &pad) +{ + ostream << "(" << getClassName() << ") { " << Value << " } "; +} + +template +void CStorageValue::setSize(sint32 size) +{ + if (size != sizeof(Value)) + nlerror("Size does not match value type"); + IStorageObject::setSize(size); +} + +template <> +void CStorageValue::setSize(sint32 size) +{ + Value.resize(size); +} + +template <> +void CStorageValue::setSize(sint32 size) +{ + Value.resize(size / 2); +} + +template +bool CStorageValue::getSize(sint32 &size) const +{ + size = sizeof(Value); + return true; +} + +template <> +bool CStorageValue::getSize(sint32 &size) const +{ + return Value.size(); +} + +template <> +bool CStorageValue::getSize(sint32 &size) const +{ + return Value.size() * 2; +} + +} /* namespace MAX */ +} /* namespace PIPELINE */ + +#endif /* #ifndef PIPELINE_STORAGE_VALUE_H */ + +/* end of file */