VMan  1.0
Library for voxel managment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
vman.cpp File Reference
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "vman.h"
#include "Volume.h"
#include "Access.h"
+ Include dependency graph for vman.cpp:

Go to the source code of this file.

Functions

void vmanPanicExit ()
 
void vmanInitVolumeParameters (vmanVolumeParameters *parameters)
 
vmanVolume vmanCreateVolume (const vmanVolumeParameters *parameters)
 
void vmanDeleteVolume (const vmanVolume volume)
 
void vmanSetUnusedChunkTimeout (const vmanVolume volume, int seconds)
 
void vmanSetModifiedChunkTimeout (const vmanVolume volume, int seconds)
 
void vmanResetStatistics (const vmanVolume volume)
 
bool vmanGetStatistics (const vmanVolume volume, vmanStatistics *statisticsDestination)
 
vmanAccess vmanCreateAccess (const vmanVolume volume)
 
void vmanDeleteAccess (const vmanAccess access)
 
void vmanSelect (vmanAccess access, const vmanSelection *selection)
 
void vmanLockAccess (vmanAccess access, int mode)
 
int vmanTryLockAccess (vmanAccess access, int mode)
 
void vmanUnlockAccess (vmanAccess access)
 
const void * vmanReadVoxelLayer (const vmanAccess access, int x, int y, int z, int layer)
 
void * vmanReadWriteVoxelLayer (const vmanAccess access, int x, int y, int z, int layer)
 

Function Documentation

void vmanPanicExit ( )

Call this function on abnormal or abprupt program termination.

Definition at line 14 of file vman.cpp.

+ Here is the call graph for this function:

void vmanInitVolumeParameters ( vmanVolumeParameters parameters)

Initializes a volume parameter structure.

Definition at line 19 of file vman.cpp.

vmanVolume vmanCreateVolume ( const vmanVolumeParameters parameters)

Creates a new volume object.

Parameters
parametersParameter structure. Should be initialized using vmanInitVolumeParameters before.
Returns
NULL when something went wrong.

Definition at line 24 of file vman.cpp.

void vmanDeleteVolume ( const vmanVolume  volume)

Deletes the given volume object and all its allocated resources.

Definition at line 29 of file vman.cpp.

void vmanSetUnusedChunkTimeout ( const vmanVolume  volume,
int  seconds 
)

Timeout after that unreferenced chunks are unloaded.

Negative values disable this behaviour.

Definition at line 35 of file vman.cpp.

void vmanSetModifiedChunkTimeout ( const vmanVolume  volume,
int  seconds 
)

Timeout after that modified chunks are saved to disk.

Negative values disable this behaviour.

Definition at line 41 of file vman.cpp.

void vmanResetStatistics ( const vmanVolume  volume)

Resets all statistics to zero.

Definition at line 47 of file vman.cpp.

bool vmanGetStatistics ( const vmanVolume  volume,
vmanStatistics statisticsDestination 
)

Writes the current statistics to statisticsDestination.

Parameters
statisticsDestinationStatistics are written to this structure.
Returns
whether the operation succeeded. May return false even if statistics were enabled.

Definition at line 53 of file vman.cpp.

vmanAccess vmanCreateAccess ( const vmanVolume  volume)

Creates an access object, which provides r/w access to the volume.

Will preload chunks as soon as a valid selection is set. Initially the selection will be invalid and all r/w operations will fail.

Returns
NULL when something went wrong.

Definition at line 59 of file vman.cpp.

void vmanDeleteAccess ( const vmanAccess  access)

Deleting a locked access object will cause an error!

Definition at line 65 of file vman.cpp.

void vmanSelect ( vmanAccess  access,
const vmanSelection selection 
)

Updates the selection.

At this point the affected chunks will be precached and preloaded. Setting the selection to NULL renders it invalid and will prevent any r/w operations.

Definition at line 71 of file vman.cpp.

void vmanLockAccess ( vmanAccess  access,
int  mode 
)

Locks access to the specified selection.

May block when intersecting chunks are already locked by other access objects. May also block while affected chunks are loaded from disk. Multiple access objects may read simultaneously from the same chunk.

Parameters
modeAccess mode bitmask.
See Also
vmanAccessMode

Definition at line 77 of file vman.cpp.

int vmanTryLockAccess ( vmanAccess  access,
int  mode 
)

Behaves like vmanLockAccess, except that it returns 0 if the selection is already locked.

Returns a positive value on success.

See Also
vmanLockAccess

Definition at line 83 of file vman.cpp.

void vmanUnlockAccess ( vmanAccess  access)

Unlocks access.

Definition at line 92 of file vman.cpp.

const void* vmanReadVoxelLayer ( const vmanAccess  access,
int  x,
int  y,
int  z,
int  layer 
)
Returns
A read only pointer to the voxel data in the specified layer. Will return NULL if the voxel lies outside the selection or an incomplatible access mode has been selected.

Definition at line 98 of file vman.cpp.

void* vmanReadWriteVoxelLayer ( const vmanAccess  access,
int  x,
int  y,
int  z,
int  layer 
)
Returns
A pointer to the voxel data in the specified layer. Will return NULL if the voxel lies outside the selection or an incomplatible access mode has been selected. Read operations may yield undefined values if write only is active.

Definition at line 104 of file vman.cpp.