vcglib/apps/nexus/borderserver.h

90 lines
3.4 KiB
C
Raw Normal View History

2005-02-08 13:43:03 +01:00
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 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 General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
****************************************************************************/
2004-10-09 13:09:13 +02:00
#ifndef NXS_BORDERSERVER_H
#define NXS_BORDERSERVER_H
2005-01-14 16:25:29 +01:00
#include <list>
#include <map>
#include "index_file.h"
2004-10-09 13:09:13 +02:00
#include "border.h"
2005-01-14 16:25:29 +01:00
/*nell'header ci sta scritto solo:
spazio riservato: 2 * sizeof(Link);
magic: nxb0 (4 bytes)
offset: (int64) */
2004-10-09 13:09:13 +02:00
namespace nxs {
2005-01-18 23:24:23 +01:00
//This should be Border class!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2005-01-21 18:09:13 +01:00
/*struct BorderEntry {
2005-01-14 16:25:29 +01:00
unsigned int start; //granuralita' Link
2005-01-18 23:24:23 +01:00
unsigned short size; //in Links //TODO what are this? be clear!
2005-01-14 16:25:29 +01:00
unsigned short used; //in Links
Link *links;
2005-01-21 18:09:13 +01:00
};*/
2004-10-09 13:09:13 +02:00
2005-01-21 18:09:13 +01:00
class BorderServer: public IndexFile<Border> {
2004-10-09 13:09:13 +02:00
public:
2005-01-14 16:25:29 +01:00
BorderServer(): ram_max(1000000), ram_used(0) {}
~BorderServer() { Close(); }
bool Create(const std::string &file);
bool Load(const std::string &file, bool readonly = true);
void Close();
void Flush();
2005-01-21 18:09:13 +01:00
void AddBorder(unsigned short size, unsigned int used = 0);
Border &GetBorder(unsigned int border, bool flush = true);
void ResizeBorder(unsigned int border, unsigned int size);
2004-10-09 13:09:13 +02:00
2005-01-21 18:09:13 +01:00
/*unsigned int BorderSize(unsigned int i) {
2005-01-14 16:25:29 +01:00
return operator[](i).used;
2004-10-09 13:09:13 +02:00
}
unsigned int BorderCapacity(unsigned int i) {
2005-01-14 16:25:29 +01:00
return operator[](i).size;
2005-01-21 18:09:13 +01:00
} */
2005-01-14 16:25:29 +01:00
protected:
unsigned int ram_max;
unsigned int ram_used;
std::list<unsigned int> pqueue;
std::map<unsigned int, std::list<unsigned int>::iterator> index;
bool LoadHeader();
void SaveHeader();
2004-10-09 13:09:13 +02:00
2005-01-14 16:25:29 +01:00
void FlushBorder(unsigned int border);
Link *GetRegion(unsigned int start, unsigned int size); //size in links.
2004-10-09 13:09:13 +02:00
};
}
#endif