VMan  1.0
Library for voxel managment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Volume Class Reference

#include <Volume.h>

+ Collaboration diagram for Volume:

Public Types

enum  CheckCause { CHECK_CAUSE_UNUSED, CHECK_CAUSE_MODIFIED }
 

Public Member Functions

 Volume (const vmanVolumeParameters *parameters)
 
 ~Volume ()
 
int getChunkEdgeLength () const
 
int getVoxelsPerChunk () const
 
int getMaxLayerVoxelSize () const
 
int getLayerCount () const
 
const vmanLayergetLayer (int index) const
 
int getLayerIndexByName (const char *name) const
 
const char * getBaseDir () const
 
std::string getChunkFileName (int chunkX, int chunkY, int chunkZ) const
 
void voxelToChunkCoordinates (const int voxelX, const int voxelY, const int voxelZ, int *chunkX, int *chunkY, int *chunkZ)
 
void voxelToChunkSelection (const vmanSelection *voxelSelection, vmanSelection *chunkSelection)
 
void getSelection (const vmanSelection *chunkSelection, Chunk **chunksOut, int priority)
 
void setUnusedChunkTimeout (int seconds)
 
int getUnusedChunkTimeout () const
 
void setModifiedChunkTimeout (int seconds)
 
int getModifiedChunkTimeout () const
 
void saveModifiedChunks ()
 
void scheduleCheck (CheckCause cause, Chunk *chunk)
 
void log (vmanLogLevel level, const char *format,...) const
 
void resetStatistics ()
 
void incStatistic (Statistic statistic, int amount=1)
 
void decStatistic (Statistic statistic, int amount=1)
 
void minStatistic (Statistic statistic, int value)
 
void maxStatistic (Statistic statistic, int value)
 
bool getStatistics (vmanStatistics *statisticsDestination) const
 
tthread::mutex * getMutex ()
 

Static Public Member Functions

static void PanicExit ()
 

Detailed Description

Definition at line 44 of file Volume.h.

Member Enumeration Documentation

enum CheckCause
Enumerator
CHECK_CAUSE_UNUSED 
CHECK_CAUSE_MODIFIED 

Definition at line 188 of file Volume.h.

Constructor & Destructor Documentation

Volume ( const vmanVolumeParameters parameters)
See Also
vmanVolumeParameters

Definition at line 18 of file Volume.cpp.

+ Here is the call graph for this function:

~Volume ( )

Definition at line 83 of file Volume.cpp.

+ Here is the call graph for this function:

Member Function Documentation

int getChunkEdgeLength ( ) const

Is thread safe.

Returns
The edge length of the chunks cube.

Definition at line 207 of file Volume.cpp.

+ Here is the caller graph for this function:

int getVoxelsPerChunk ( ) const

Is thread safe.

Returns
The amount of voxels a chunk contains. edgeLength^3

Definition at line 187 of file Volume.cpp.

+ Here is the caller graph for this function:

int getMaxLayerVoxelSize ( ) const

Is thread safe.

Returns
The maximum size a voxel may occupy.

Definition at line 182 of file Volume.cpp.

+ Here is the caller graph for this function:

int getLayerCount ( ) const

Is thread safe.

Returns
The amount of voxel layers registered.

Definition at line 177 of file Volume.cpp.

+ Here is the caller graph for this function:

const vmanLayer * getLayer ( int  index) const

Is thread safe.

Returns
A read only pointer to the layer definition or NULL when something went wrong. (e.g. out of bounds)
See Also
getLayerCount

Definition at line 192 of file Volume.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int getLayerIndexByName ( const char *  name) const

Searches for a layer with the given name and returns its index.

Is thread safe.

Returns
The layers index or -1 on failure.

Definition at line 199 of file Volume.cpp.

+ Here is the caller graph for this function:

const char * getBaseDir ( ) const

Directory where the chunks are stored.

Is thread safe.

Returns
Base dir or NULL if saving to disk has been disabled.

Definition at line 212 of file Volume.cpp.

+ Here is the caller graph for this function:

std::string getChunkFileName ( int  chunkX,
int  chunkY,
int  chunkZ 
) const

Generates the file name where a specific chunk could be stored.

Note that if the base dir is NULL the file name will be empty. Is thread safe.

See Also
getBaseDir

Definition at line 220 of file Volume.cpp.

+ Here is the caller graph for this function:

void voxelToChunkCoordinates ( const int  voxelX,
const int  voxelY,
const int  voxelZ,
int *  chunkX,
int *  chunkY,
int *  chunkZ 
)

Converts voxel to chunk coordinates.

Is thread safe.

Definition at line 343 of file Volume.cpp.

+ Here is the caller graph for this function:

void voxelToChunkSelection ( const vmanSelection voxelSelection,
vmanSelection chunkSelection 
)

Converts a voxel selection to an chunk selection.

I.e. the chunks that include the given voxels. Is thread safe.

Definition at line 350 of file Volume.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void getSelection ( const vmanSelection chunkSelection,
Chunk **  chunksOut,
int  priority 
)

Get the chunks of the given coordinates.

Creates a chunk if it doesn't exists yet. Chunks that need to be loaded from disk are locked.

Parameters
chunksOutThis array must have the size of the chunkSelection. It is filled with the appropriate chunk pointers. Access them with the Index3D() function.
chunkSelectionThe selection that shall be retrieved.
chunksOutAn array where the chunk pointers are copied to. Should obviously have enough space for alle chunks of chunkSelection.
priorityParameter used to sort the resulting io jobs. TODO

Definition at line 378 of file Volume.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void setUnusedChunkTimeout ( int  seconds)

Timeout after that unreferenced chunks are unloaded.

Negative values disable this behaviour.

Definition at line 523 of file Volume.cpp.

int getUnusedChunkTimeout ( ) const

Timeout after that unreferenced chunks are unloaded.

Returns
Timeout or -1 if disabled.

Definition at line 528 of file Volume.cpp.

+ Here is the caller graph for this function:

void setModifiedChunkTimeout ( int  seconds)

Timeout after that modified chunks are saved to disk.

Negative values disable this behaviour.

Definition at line 533 of file Volume.cpp.

int getModifiedChunkTimeout ( ) const

Timeout after that modified chunks are saved to disk.

Returns
Timeout or -1 if disabled.

Definition at line 538 of file Volume.cpp.

+ Here is the caller graph for this function:

void saveModifiedChunks ( )

Writes all modified chunks to disk.

Is a no-op if saving to disk has been disabled.

Definition at line 499 of file Volume.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void scheduleCheck ( CheckCause  cause,
Chunk chunk 
)

Schedules tasks that will be run in the future.

scheduled_time = now + wait_duration While the duration is defined by the tasks type. E.g. for the CHECK_CAUSE_UNUSED it uses getUnusedChunkTimeout().

Definition at line 543 of file Volume.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void log ( vmanLogLevel  level,
const char *  format,
  ... 
) const

For logging vman specific messages.

Is thread safe.

Definition at line 234 of file Volume.cpp.

+ Here is the caller graph for this function:

void resetStatistics ( )

Resets all statistics to zero.

Is thread safe.

Definition at line 285 of file Volume.cpp.

+ Here is the caller graph for this function:

void incStatistic ( Statistic  statistic,
int  amount = 1 
)

Increments a statistic.

Is thread safe.

Definition at line 292 of file Volume.cpp.

+ Here is the caller graph for this function:

void decStatistic ( Statistic  statistic,
int  amount = 1 
)

Decrements a statistic.

Is thread safe.

Definition at line 298 of file Volume.cpp.

void minStatistic ( Statistic  statistic,
int  value 
)

Sets the value if its greater than the current one.

Is thread safe.

Definition at line 311 of file Volume.cpp.

void maxStatistic ( Statistic  statistic,
int  value 
)

Sets the value if its lower than the current one.

Is thread safe.

Definition at line 304 of file Volume.cpp.

bool getStatistics ( vmanStatistics statisticsDestination) const

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 318 of file Volume.cpp.

tthread::mutex * getMutex ( )

Use this to lock the object while using methods that aren't thread safe.

Definition at line 801 of file Volume.cpp.

+ Here is the caller graph for this function:

void PanicExit ( )
static

Call this function on abnormal or abprupt program termination.

Definition at line 139 of file Volume.cpp.

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: