parent
fa32c4d664
commit
6f1125b97a
@ -0,0 +1,263 @@
|
||||
/**
|
||||
* \file app_data.cpp
|
||||
* \brief CAppData
|
||||
* \date 2012-08-21 11:47GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CAppData
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include "app_data.h"
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
// #include <nel/misc/debug.h>
|
||||
|
||||
// Project includes
|
||||
|
||||
using namespace std;
|
||||
// using namespace NLMISC;
|
||||
|
||||
namespace PIPELINE {
|
||||
namespace MAX {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NLMAXFILE_APP_DATA_HEADER_CHUNK_ID 0x0100
|
||||
#define NLMAXFILE_APP_DATA_ENTRY_CHUNK_ID 0x0110
|
||||
#define NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID 0x0120
|
||||
#define NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID 0x0130
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CAppData::TKey::TKey(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId) : ClassId(classId), SuperClassId(superClassId), SubId(subId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CAppData::TKey::operator<(const CAppData::TKey &right) const
|
||||
{
|
||||
if (ClassId < right.ClassId)
|
||||
return true;
|
||||
if (ClassId > right.ClassId)
|
||||
return false;
|
||||
if (SuperClassId < right.SuperClassId)
|
||||
return true;
|
||||
if (SuperClassId > right.SuperClassId)
|
||||
return false;
|
||||
if (SubId < right.SubId)
|
||||
return true;
|
||||
if (SubId > right.SubId)
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAppData::TKey::operator>(const CAppData::TKey &right) const
|
||||
{
|
||||
if (ClassId > right.ClassId)
|
||||
return true;
|
||||
if (ClassId < right.ClassId)
|
||||
return false;
|
||||
if (SuperClassId > right.SuperClassId)
|
||||
return true;
|
||||
if (SuperClassId < right.SuperClassId)
|
||||
return false;
|
||||
if (SubId > right.SubId)
|
||||
return true;
|
||||
if (SubId < right.SubId)
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAppData::TKey::operator==(const CAppData::TKey &right) const
|
||||
{
|
||||
return ClassId == right.ClassId && SuperClassId == right.SuperClassId && SubId == right.SubId;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CAppData::CAppData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAppData::~CAppData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string CAppData::getClassName()
|
||||
{
|
||||
return "AppData";
|
||||
}
|
||||
|
||||
void CAppData::toString(std::ostream &ostream, const std::string &pad)
|
||||
{
|
||||
CStorageContainer::toString(ostream, pad);
|
||||
}
|
||||
|
||||
void CAppData::parse(uint16 version, TParseLevel level)
|
||||
{
|
||||
CStorageContainer::parse(version, level);
|
||||
}
|
||||
|
||||
void CAppData::clean()
|
||||
{
|
||||
CStorageContainer::clean();
|
||||
}
|
||||
|
||||
void CAppData::build(uint16 version)
|
||||
{
|
||||
CStorageContainer::build(version);
|
||||
}
|
||||
|
||||
void CAppData::disown()
|
||||
{
|
||||
CStorageContainer::disown();
|
||||
}
|
||||
|
||||
IStorageObject *CAppData::createChunkById(uint16 id, bool container)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case NLMAXFILE_APP_DATA_HEADER_CHUNK_ID:
|
||||
nlassert(!container);
|
||||
return new CStorageValue<uint32>();
|
||||
break;
|
||||
case NLMAXFILE_APP_DATA_ENTRY_CHUNK_ID:
|
||||
nlassert(container);
|
||||
return new CAppDataEntry();
|
||||
break;
|
||||
}
|
||||
return CStorageContainer::createChunkById(id, container);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CAppDataEntryKey::CAppDataEntryKey()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAppDataEntryKey::~CAppDataEntryKey()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string CAppDataEntryKey::getClassName()
|
||||
{
|
||||
return "AppDataEntryKey";
|
||||
}
|
||||
|
||||
void CAppDataEntryKey::serial(NLMISC::IStream &stream)
|
||||
{
|
||||
stream.serial(ClassId);
|
||||
stream.serial(SuperClassId);
|
||||
stream.serial(SubId);
|
||||
stream.serial(Size);
|
||||
}
|
||||
|
||||
void CAppDataEntryKey::toString(std::ostream &ostream, const std::string &pad)
|
||||
{
|
||||
ostream << "(" << getClassName() << ") { ";
|
||||
ostream << "\n" << pad << "ClassId: " << NLMISC::toString(ClassId);
|
||||
ostream << "\n" << pad << "SuperClassId: " << SuperClassId;
|
||||
ostream << "\n" << pad << "SubId: " << SubId;
|
||||
ostream << "\n" << pad << "Size: " << Size;
|
||||
ostream << " } ";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CAppDataEntry::CAppDataEntry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAppDataEntry::~CAppDataEntry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string CAppDataEntry::getClassName()
|
||||
{
|
||||
return "AppDataEntry";
|
||||
}
|
||||
|
||||
void CAppDataEntry::toString(std::ostream &ostream, const std::string &pad)
|
||||
{
|
||||
CStorageContainer::toString(ostream, pad);
|
||||
}
|
||||
|
||||
void CAppDataEntry::parse(uint16 version, TParseLevel level)
|
||||
{
|
||||
CStorageContainer::parse(version, level);
|
||||
}
|
||||
|
||||
void CAppDataEntry::clean()
|
||||
{
|
||||
CStorageContainer::clean();
|
||||
}
|
||||
|
||||
void CAppDataEntry::build(uint16 version)
|
||||
{
|
||||
CStorageContainer::build(version);
|
||||
}
|
||||
|
||||
void CAppDataEntry::disown()
|
||||
{
|
||||
CStorageContainer::disown();
|
||||
}
|
||||
|
||||
IStorageObject *CAppDataEntry::createChunkById(uint16 id, bool container)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID:
|
||||
nlassert(!container);
|
||||
return new CAppDataEntryKey();
|
||||
case NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID:
|
||||
nlassert(!container);
|
||||
return new CStorageRaw();
|
||||
}
|
||||
return CStorageContainer::createChunkById(id, container);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} /* namespace MAX */
|
||||
} /* namespace PIPELINE */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,156 @@
|
||||
/**
|
||||
* \file app_data.h
|
||||
* \brief CAppData
|
||||
* \date 2012-08-21 11:47GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CAppData
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIPELINE_APP_DATA_H
|
||||
#define PIPELINE_APP_DATA_H
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/class_id.h>
|
||||
|
||||
// Project includes
|
||||
#include "../typedefs.h"
|
||||
#include "../storage_object.h"
|
||||
#include "../storage_value.h"
|
||||
|
||||
namespace PIPELINE {
|
||||
namespace MAX {
|
||||
|
||||
#define NLMAXFILE_APP_DATA_CHUNK_ID 0x2150
|
||||
|
||||
class CAppDataEntry;
|
||||
|
||||
/**
|
||||
* \brief CAppData
|
||||
* \date 2012-08-21 11:47GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* This implements the AppData chunk in the storage
|
||||
*/
|
||||
class CAppData : public CStorageContainer
|
||||
{
|
||||
private:
|
||||
struct TKey
|
||||
{
|
||||
TKey(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId);
|
||||
NLMISC::CClassId ClassId;
|
||||
TSClassId SuperClassId;
|
||||
uint32 SubId;
|
||||
bool operator<(const TKey &right) const;
|
||||
bool operator>(const TKey &right) const;
|
||||
bool operator==(const TKey &right) const;
|
||||
};
|
||||
|
||||
public:
|
||||
CAppData();
|
||||
virtual ~CAppData();
|
||||
|
||||
// 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();
|
||||
|
||||
// public
|
||||
/// Gets a pointer to an appdata chunk buffer. Returns NULL if it does not exist. Size is returned in the size parameter.
|
||||
const uint8 *read(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 &size) const;
|
||||
/// Locks a pointer to an appdata chunk buffer for writing to with specified capacity.
|
||||
uint8 *lock(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 capacity);
|
||||
/// Unlocks a pointer to an appdata chunk buffer, setting the final written size.
|
||||
void unlock(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 size);
|
||||
/// Fills an appdata chunk buffer with specified data, which will be copied.
|
||||
void fill(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint8 *buffer, uint32 size);
|
||||
/// Erases an appdata chunk.
|
||||
void erase(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId);
|
||||
|
||||
protected:
|
||||
virtual IStorageObject *createChunkById(uint16 id, bool container);
|
||||
|
||||
private:
|
||||
std::map<TKey, CAppDataEntry *> m_Entries;
|
||||
|
||||
}; /* class CAppData */
|
||||
|
||||
/**
|
||||
* \brief CAppDataEntryKey
|
||||
* \date 2012-08-18 18:01GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CAppDataEntryKey
|
||||
*/
|
||||
class CAppDataEntryKey : public IStorageObject
|
||||
{
|
||||
public:
|
||||
CAppDataEntryKey();
|
||||
virtual ~CAppDataEntryKey();
|
||||
|
||||
// public data
|
||||
NLMISC::CClassId ClassId;
|
||||
TSClassId SuperClassId;
|
||||
uint32 SubId;
|
||||
uint32 Size;
|
||||
|
||||
// inherited
|
||||
virtual std::string getClassName();
|
||||
virtual void serial(NLMISC::IStream &stream);
|
||||
virtual void toString(std::ostream &ostream, const std::string &pad = "");
|
||||
|
||||
}; /* class CAppDataEntryKey */
|
||||
|
||||
/**
|
||||
* \brief CAppDataEntry
|
||||
* \date 2012-08-21 11:47GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* This implements an entry in the AppData chunk in the storage
|
||||
*/
|
||||
class CAppDataEntry : public CStorageContainer
|
||||
{
|
||||
public:
|
||||
CAppDataEntry();
|
||||
virtual ~CAppDataEntry();
|
||||
|
||||
// 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();
|
||||
|
||||
protected:
|
||||
virtual IStorageObject *createChunkById(uint16 id, bool container);
|
||||
|
||||
}; /* class CAppDataEntry */
|
||||
|
||||
} /* namespace MAX */
|
||||
} /* namespace PIPELINE */
|
||||
|
||||
#endif /* #ifndef PIPELINE_APP_DATA_H */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* \file typedefs.cpp
|
||||
* \brief CTypeDefs
|
||||
* \date 2012-08-21 12:14GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CTypeDefs
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include "typedefs.h"
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
// #include <nel/misc/debug.h>
|
||||
|
||||
// Project includes
|
||||
|
||||
using namespace std;
|
||||
// using namespace NLMISC;
|
||||
|
||||
namespace PIPELINE {
|
||||
namespace MAX {
|
||||
|
||||
void blahblahblah_typedefs() { }
|
||||
|
||||
} /* namespace MAX */
|
||||
} /* namespace PIPELINE */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* \file typedefs.h
|
||||
* \brief CTypeDefs
|
||||
* \date 2012-08-21 12:14GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* CTypeDefs
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIPELINE_TYPEDEFS_H
|
||||
#define PIPELINE_TYPEDEFS_H
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
// STL includes
|
||||
|
||||
// NeL includes
|
||||
|
||||
// Project includes
|
||||
|
||||
namespace PIPELINE {
|
||||
namespace MAX {
|
||||
|
||||
// Don't really care about superclass IDs right now, but we have to.
|
||||
typedef uint32 TSClassId;
|
||||
|
||||
// Application versions
|
||||
const uint16 VersionUnknown = 0x0000;
|
||||
const uint16 Version3 = 0x2004;
|
||||
const uint16 Version4 = 0x2006;
|
||||
const uint16 Version5 = 0x2008;
|
||||
const uint16 Version6 = 0x2009;
|
||||
const uint16 Version7 = 0x200A;
|
||||
const uint16 Version8 = 0x200B;
|
||||
const uint16 Version9 = 0x200E;
|
||||
const uint16 Version2008 = 0x200F;
|
||||
const uint16 Version2010 = 0x2012;
|
||||
|
||||
} /* namespace MAX */
|
||||
} /* namespace PIPELINE */
|
||||
|
||||
#endif /* #ifndef PIPELINE_TYPEDEFS_H */
|
||||
|
||||
/* end of file */
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue