mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 20:00:54 +00:00
ADDED: #1471 added a global db manager for the GUI library, also added support for resizeing the CDB bank handler.
--HG-- branch : gui-refactoring
This commit is contained in:
parent
f769f6fb0c
commit
b834d9ea17
6 changed files with 129 additions and 0 deletions
47
code/nel/include/nel/gui/db_manager.h
Normal file
47
code/nel/include/nel/gui/db_manager.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program 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.
|
||||||
|
//
|
||||||
|
// This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DBMANAGER_H
|
||||||
|
#define DBMANAGER_H
|
||||||
|
|
||||||
|
#include "nel/misc/cdb_manager.h"
|
||||||
|
|
||||||
|
namespace NLGUI
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDBManager : public NLMISC::CCDBManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static CDBManager* getInstance();
|
||||||
|
static void release();
|
||||||
|
|
||||||
|
NLMISC::CCDBNodeLeaf* getDbProp( const std::string &name, bool create = true );
|
||||||
|
void delDbProp( const std::string &name );
|
||||||
|
sint32 getDbValue32( const std::string &name );
|
||||||
|
NLMISC::CCDBNodeBranch* getDB() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CDBManager();
|
||||||
|
~CDBManager();
|
||||||
|
|
||||||
|
static CDBManager *instance;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -113,6 +113,12 @@ public:
|
||||||
*/
|
*/
|
||||||
uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; }
|
uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Resizes the bank holders. WARNING: Resets data contained.
|
||||||
|
@param newSize - The new maximum number of banks.
|
||||||
|
*/
|
||||||
|
void resize( uint newSize );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Mapping from server database index to client database index (first-level nodes)
|
/// Mapping from server database index to client database index (first-level nodes)
|
||||||
std::vector< std::vector< uint > > _CDBBankToUnifiedIndexMapping;
|
std::vector< std::vector< uint > > _CDBBankToUnifiedIndexMapping;
|
||||||
|
|
|
@ -171,6 +171,12 @@ namespace NLMISC{
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void resetBank( uint gc, uint bank );
|
void resetBank( uint gc, uint bank );
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Resizes the bank holders. WARNING: Resets data contained.
|
||||||
|
@param newSize - The new maximum number of banks.
|
||||||
|
*/
|
||||||
|
void resizeBanks( uint newSize );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CCDBBankHandler bankHandler;
|
CCDBBankHandler bankHandler;
|
||||||
|
|
53
code/nel/src/gui/db_manager.cpp
Normal file
53
code/nel/src/gui/db_manager.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#include "nel/gui/db_manager.h"
|
||||||
|
|
||||||
|
namespace NLGUI
|
||||||
|
{
|
||||||
|
CDBManager* CDBManager::instance = NULL;
|
||||||
|
|
||||||
|
CDBManager::CDBManager() :
|
||||||
|
NLMISC::CCDBManager( "ROOT", 0 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CDBManager::~CDBManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CDBManager* CDBManager::getInstance()
|
||||||
|
{
|
||||||
|
if( instance == NULL )
|
||||||
|
instance = new CDBManager();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDBManager::release()
|
||||||
|
{
|
||||||
|
nlassert( instance != NULL );
|
||||||
|
delete instance;
|
||||||
|
instance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLMISC::CCDBNodeLeaf* CDBManager::getDbProp( const std::string &name, bool create )
|
||||||
|
{
|
||||||
|
return getDbLeaf( name, create );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDBManager::delDbProp( const std::string &name )
|
||||||
|
{
|
||||||
|
delDbNode( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
sint32 CDBManager::getDbValue32( const std::string &name )
|
||||||
|
{
|
||||||
|
NLMISC::CCDBNodeLeaf *node = getDbProp( name, false );
|
||||||
|
if( node != NULL )
|
||||||
|
return node->getValue32();
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLMISC::CCDBNodeBranch* CDBManager::getDB() const
|
||||||
|
{
|
||||||
|
return _Database;
|
||||||
|
}
|
||||||
|
}
|
|
@ -91,6 +91,18 @@ _FirstLevelIdBitsByBank( maxbanks )
|
||||||
_FirstLevelIdBitsByBank[ bank ] = idb;
|
_FirstLevelIdBitsByBank[ bank ] = idb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCDBBankHandler::resize( uint newSize )
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
|
||||||
|
_CDBBankNames.clear();
|
||||||
|
_CDBBankToUnifiedIndexMapping.clear();
|
||||||
|
_FirstLevelIdBitsByBank.clear();
|
||||||
|
|
||||||
|
_CDBBankToUnifiedIndexMapping.reserve( newSize );
|
||||||
|
_FirstLevelIdBitsByBank.reserve( newSize );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -146,4 +146,9 @@ namespace NLMISC{
|
||||||
_Database->resetNode( gc, bankHandler.getUIDForBank( bank ) );
|
_Database->resetNode( gc, bankHandler.getUIDForBank( bank ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCDBManager::resizeBanks( uint newSize )
|
||||||
|
{
|
||||||
|
bankHandler.resize( newSize );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue