TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class PyramidFileCache in Tinman.Terrain.Pyramids

An file-based cache for IPixelPyramid s and ITexelPyramid s.

sealed class PyramidFileCache extends Disposable
  implements IConfigurable
  IFlushable
  IPathInfo

Remarks

Instances of PyramidFileCache are automatically shared between threads of the same process. This is transparent to the using code. Pyramid file caches can also be shared between multiple processes resp. machines, with the restriction that all shared pyramid file caches must be opened read-only mode (see Open), which implies that the shared pyramid file cache must have been warmed up in a pre-processing step.

The following table shows the binary layout of a pyramid cache (multibyte values are encoded as LittleEndian).

Offset     | Type  | Count | Description
-----------+-------+-------+----------------------------------------------------
#0  ..  #7 |  int8 |     8 | Magic value that identifies a file used by a
           |       |       | pyramid cache:
           |       |       | 0x89 0x50 0x59 0x43 0x0D 0x0A 0x1A 0x0A
-----------+-------+-------+----------------------------------------------------
#8  ..  #9 | int16 |     1 | Binary format version (currently 1).
-----------+-------+-------+----------------------------------------------------
#10 .. #17 | int64 |     1 | Maximum file size, in bytes.
-----------+-------+-------+----------------------------------------------------
#18 .. #21 | int32 |     1 | Maximum tile age, in seconds.
-----------+-------+-------+----------------------------------------------------
#22 .. #39 |  int8 |    18 | Reserved (must be all zero).
-----------+-------+-------+----------------------------------------------------
#40 .. #47 | int64 |     1 | Block ID of root of primary tile index.
-----------+-------+-------+----------------------------------------------------
#48 .. #55 |  int8 |     8 | Reserved, must be zero.
-----------+-------+-------+----------------------------------------------------
#56 .. #63 | int64 |     1 | Block ID of root of timestamp index "LastUsed".
-----------+-------+-------+----------------------------------------------------
#64 .. EOF |  int8 |     ? | Data area of pyramid cache.
-----------+-------+-------+----------------------------------------------------
The data area of a pyramid cache dataset is managed by an embedded BlockStorage.

Configuration

Config

The configurator object for this type.

public static property Config { get }
type IConfigurator<PyramidFileCache>
value [not-null] The configurator object.

ToConfig

Returns the configuration value that describes this object.

public method ToConfig ()
type ConfigValue
returns [not-null] The configuration value.
implements IConfigurable.ToConfig

Remarks:

All configurable objects need to implement this interface. For simple types, it is preferable to delegate to ToValue.

The returned value may be of type Invalid, which means that this object in its current state cannot be described with the configuration API.

Before returning the resulting configuration value, Cache must be called on it, passing this IConfigurable object as parameter.

Exceptions:

Public / Attributes

IsReadOnly

Is the pyramid file cache in read-only mode?

public property IsReadOnly { get }
type bool
value true if the pyramid file cache is in read-only mode,
false if the pyramid file cache is in read-write mode.

Remarks:

In read-only mode, the cache file will not be updated (e.g. add new tiles, updated timestamps, remove expired tiles). In effect, pyramid files that are not present in the cache will be loaded from the underlying pyramid, and the resulting pyramid tile will not be stored in the cache file.

IsSoleOwnership

Will this object be disposed upon the next call to Dispose?

[ThreadSafe]
public property IsSoleOwnership { get }
type bool
value true if the object will be disposed when Dispose is called,
false if the object will not be disposed, because some other code is still holding shared ownership (see AcquireBase).
inherited Disposable.IsSoleOwnership

LifecycleState

Returns the lifecycle state of this object.

public property LifecycleState { get }
type LifecycleState
value The lifecycle state.
inherited Disposable.LifecycleState

Locked

Is the pyramid file cache currently in locked mode?

public property Locked { get set }
type bool
value true if the pyramid file cache is in locked mode,
false if the pyramid file cache is in unlocked mode.

Remarks:

In locked mode, only those pyramid files that are already present in the cache file will be returned. In effect, the underlying pyramids will never be accessed.

Defaults to false.

PathInfo

Returns a Path object that represents the file path this object is associated with.

public property PathInfo { get }
type Path
value [not-null] The path info.
implements IPathInfo.PathInfo

Remarks:

Objects that do not have a meaningful file path association simply return Unknown.

Public / Constructors

Create

Creates a new pyramid file cache.

[OwnerReturn]
public static method Create (Path filePath, PyramidFileCacheOptions options = null)
type PyramidFileCache
params filePath [not-null] Path to the cache file.
  options The options to use. If null, the default options will be used.
returns [not-null] The pyramid file cache.

Exceptions:

CreateOrOpen

Opens an existing pyramid file cache or creates a new one if necessary.

[OwnerReturn]
public static method CreateOrOpen (Path filePath, PyramidFileCacheOptions options = null)
type PyramidFileCache
params filePath [not-null] Path to the cache file.
  options The options to use. If null, the default options will be used.
returns [not-null] The pyramid file cache.

Remarks:

If the given file path points to a non-existent file, a new pyramid file cache with the given properties will be created. If the file path refers to an existing pyramid file cache, it will be opened iff its options match options; otherwise a new pyramid file cache is created and the existing one is overwritten.

Exceptions:

Open

Opens an existing pyramid file cache.

[OwnerReturn]
public static method Open (Path filePath, bool readOnly = false)
type PyramidFileCache
params filePath [not-null] Path to the cache file.
  readOnly Open pyramid file cache in read-only mode? Use this for sharing warmed-up file caches between multiple processes or machines. Defaults to false.
returns [not-null] The pyramid file cache.

Exceptions:

Public / Methods

AcquireBase

Acquires a strong reference to this disposable object.

[OwnerReturn, Pure]
public method AcquireBase (bool allowNull = false)
type IDisposable
params allowNull Depicts what to do when this object is no longer valid:
true: return null
false: throw an exception
returns The strong reference to this disposable object or null iff allowNull is true and this object is no longer valid.
inherited Disposable.AcquireBase

Remarks:

The object will not be actually disposed by calls to IDisposable when there is at least one strong reference left. Code that calls this method is responsible for calling the IDisposable method accordingly.

This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.

Using this method usually requires type casting. Subclasses may additionally implement IDisposableGeneric, in order to provide some syntactic sugar for that.

Exceptions:

Clear

Clears all cached pyramid tile data from the cache.

[ThreadSafe]
public method Clear ()

Exceptions:

Dispose

Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.

[Dispose, OwnerThis, ThreadSafe]
public method Dispose ()
inherited Disposable.Dispose

Remarks:

The Dispose method silently returns if the object has already been disposed.

Implementing methods must not throw any exceptions.

Flush

Flushes all cached data.

public method Flush ()
implements IFlushable.Flush

Remarks:

Performing a flush may result in I/O work. Depending on the semantics of the implementing class, this work may need to be wrapped in special Begin/End method calls. See the documentation of the implementing classes for details.

In case this object represents a read-only resource, calling the Flush method has no effect.

Exceptions:

Logging

Logger

The logger object of this class.

public static readonly field Logger
type ILogger