C# Class fCraft.BlockDB

Database of block changes. Each BlockDB object is associated with a world. Provides controls for storage/retention, and methods to look up data.
Inheritance: IDisposable
Show file Open project: GlennMR/800craft Class Usage Examples

Private Properties

Property Type Description
AddEntry void
BlockDB System
CacheClear void
CheckAlignment void
CountNewerEntries int
EnforceLimit void
EnforceTimeLimit void
EnsureCapacity void
Flush void
Init void
LimitCapacity void
Lookup fCraft.BlockDBEntry[]
OnPlayerPlacedBlock void
OpenAppend System.IO.FileStream
OpenRead System.IO.FileStream
Preload void
TrimFile void

Public Methods

Method Description
AutoToggleIfNeeded ( ) : bool

If EnabledState is set to Auto, calling this auto-enables / auto-disables BlockDB depending on world's BuildSecurity.MinRank and BlockDBAutoEnableRank config key.

Clear ( ) : void

Clears cache and deletes the .fbdb file.

GetReadLock ( ) : IDisposable

Acquires and returns a shared (read) lock for this BlockDB. Disposing the object returned by this method releases the lock.

GetWriteLock ( ) : IDisposable

Acquires and returns an exclusive (write) lock for this BlockDB. Disposing the object returned by this method releases the lock.

LoadSettings ( System.Xml.Linq.XElement el ) : void
Lookup ( int max ) : fCraft.BlockDBEntry[]
Lookup ( int max, System.TimeSpan span ) : fCraft.BlockDBEntry[]
Lookup ( int max, Vector3I coords ) : fCraft.BlockDBEntry[]

Returns list of all changes done to the map at the given coordinate, newest to oldest.

Lookup ( int max, [ area ) : fCraft.BlockDBEntry[]
Lookup ( int max, [ area, System.TimeSpan span ) : fCraft.BlockDBEntry[]
Lookup ( int max, [ area, [ info, bool exclude ) : fCraft.BlockDBEntry[]
Lookup ( int max, [ area, [ info, bool exclude, System.TimeSpan span ) : fCraft.BlockDBEntry[]
Lookup ( int max, [ info, bool exclude ) : fCraft.BlockDBEntry[]
Lookup ( int max, [ info, bool exclude, System.TimeSpan span ) : fCraft.BlockDBEntry[]
SaveSettings ( ) : System.Xml.Linq.XElement
SaveSettings ( string rootName ) : System.Xml.Linq.XElement
Traverse ( [ processor ) : void

Traverses the database, newest to oldest entries, processing each entry with the given IBlockDBQueryProcessor.

Private Methods

Method Description
AddEntry ( BlockDBEntry item ) : void
BlockDB ( [ world ) : System
CacheClear ( ) : void
CheckAlignment ( ) : void
CountNewerEntries ( System.TimeSpan age ) : int

Counts entries that are newer than the given age.

EnforceLimit ( ) : void
EnforceTimeLimit ( ) : void
EnsureCapacity ( int min ) : void
Flush ( bool enforceLimits ) : void
Init ( ) : void
LimitCapacity ( int max ) : void
Lookup ( int max, BlockDBSearchType searchType, bool>.[ selector ) : fCraft.BlockDBEntry[]
OnPlayerPlacedBlock ( object sender, [ e ) : void
OpenAppend ( ) : FileStream
OpenRead ( ) : FileStream
Preload ( ) : void
TrimFile ( int maxCapacity ) : void

Method Details

AutoToggleIfNeeded() public method

If EnabledState is set to Auto, calling this auto-enables / auto-disables BlockDB depending on world's BuildSecurity.MinRank and BlockDBAutoEnableRank config key.
public AutoToggleIfNeeded ( ) : bool
return bool

Clear() public method

Clears cache and deletes the .fbdb file.
public Clear ( ) : void
return void

GetReadLock() public method

Acquires and returns a shared (read) lock for this BlockDB. Disposing the object returned by this method releases the lock.
public GetReadLock ( ) : IDisposable
return IDisposable

GetWriteLock() public method

Acquires and returns an exclusive (write) lock for this BlockDB. Disposing the object returned by this method releases the lock.
public GetWriteLock ( ) : IDisposable
return IDisposable

LoadSettings() public method

public LoadSettings ( System.Xml.Linq.XElement el ) : void
el System.Xml.Linq.XElement
return void

Lookup() public method

public Lookup ( int max ) : fCraft.BlockDBEntry[]
max int
return fCraft.BlockDBEntry[]

Lookup() public method

public Lookup ( int max, System.TimeSpan span ) : fCraft.BlockDBEntry[]
max int
span System.TimeSpan
return fCraft.BlockDBEntry[]

Lookup() public method

Returns list of all changes done to the map at the given coordinate, newest to oldest.
Given coordinates are outside the map.
public Lookup ( int max, Vector3I coords ) : fCraft.BlockDBEntry[]
max int Maximum number of changes to return.
coords Vector3I Coordinate to search at.
return fCraft.BlockDBEntry[]

Lookup() public method

public Lookup ( int max, [ area ) : fCraft.BlockDBEntry[]
max int
area [
return fCraft.BlockDBEntry[]

Lookup() public method

public Lookup ( int max, [ area, System.TimeSpan span ) : fCraft.BlockDBEntry[]
max int
area [
span System.TimeSpan
return fCraft.BlockDBEntry[]

Lookup() public method

public Lookup ( int max, [ area, [ info, bool exclude ) : fCraft.BlockDBEntry[]
max int
area [
info [
exclude bool
return fCraft.BlockDBEntry[]

Lookup() public method

public Lookup ( int max, [ area, [ info, bool exclude, System.TimeSpan span ) : fCraft.BlockDBEntry[]
max int
area [
info [
exclude bool
span System.TimeSpan
return fCraft.BlockDBEntry[]

Lookup() public method

public Lookup ( int max, [ info, bool exclude ) : fCraft.BlockDBEntry[]
max int
info [
exclude bool
return fCraft.BlockDBEntry[]

Lookup() public method

public Lookup ( int max, [ info, bool exclude, System.TimeSpan span ) : fCraft.BlockDBEntry[]
max int
info [
exclude bool
span System.TimeSpan
return fCraft.BlockDBEntry[]

SaveSettings() public method

public SaveSettings ( ) : System.Xml.Linq.XElement
return System.Xml.Linq.XElement

SaveSettings() public method

public SaveSettings ( string rootName ) : System.Xml.Linq.XElement
rootName string
return System.Xml.Linq.XElement

Traverse() public method

Traverses the database, newest to oldest entries, processing each entry with the given IBlockDBQueryProcessor.
processor is null. BlockDB is disabled. The end of FBDB file is reached prematurely (corrupted file, or outside interference). FBDB file is not aligned to 20 bytes (likely corrupted). An I/O error occurrs while trying to read FBDB file from disk.
public Traverse ( [ processor ) : void
processor [ Processor to use for each BlockDBEntry.
return void