/* -*- Mode: C++; tab-width: 8; c-basic-offset: 8 -*-
 *
 */

#ifndef __LFSInode_h__
#define __LFSInode_h__

#include "LFSBlock.h"
#include "LFSSegment.h"
#include "Iterator.h"

class CLFSFileSystem;
class CLFSBlock;
class CLFSInodeBlock;

class CLFSInode {
public:
	CLFSInode(CLFSInodeBlock& block);

	// Returns the address of the specified block in the inode.
	unsigned long
	GetDataBlockAddr(unsigned long blocknr);

	// Returns the actual datablock
	CLFSBlock*
	GetDataBlock(unsigned long blocknr);

	// Returns the number of blocks in the inode.
	unsigned long
	GetDataBlockCount();

	CIterator*
	GetDataBlocks();

	CIterator*
	GetAllBlocks();

	CLFSFileSystem&
	GetFS();

protected:
	CLFSInodeBlock& m_block;
};



class CLFSIMap : public CLFSInode {
public:
	CLFSIMap(CLFSInodeBlock& block);

	// Return an iterator that will produce CLFSInode objects.
	CIterator*
	GetInodes();

	CLFSInodeBlock*
	GetInode(unsigned long ino);
};


class CLFSSMap : public CLFSInode {
public:
	CLFSSMap(CLFSInodeBlock& block);

	CIterator*
	GetSegments();


	CLFSSegment*
	GetSegment(unsigned short nr);
};


#endif __LFSInode_h__

