VMan  1.0
Library for voxel managment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
vman.cpp
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <string.h>
3 #include <assert.h>
4 #include "vman.h"
5 #include "Volume.h"
6 #include "Access.h"
7 
8 /*
9  Just check the 'this' pointers for NULL here,
10  everything else should be done in the apropriate methods.
11 */
12 
13 
15 {
17 }
18 
20 {
21  memset(parameters, 0, sizeof(vmanVolumeParameters));
22 }
23 
25 {
26  return (vmanVolume)new vman::Volume(parameters);
27 }
28 
29 void vmanDeleteVolume( const vmanVolume volume )
30 {
31  assert(volume != NULL);
32  delete (const vman::Volume*)volume;
33 }
34 
35 void vmanSetUnusedChunkTimeout( const vmanVolume volume, int seconds )
36 {
37  assert(volume != NULL);
38  ((vman::Volume*)volume)->setUnusedChunkTimeout(seconds);
39 }
40 
41 void vmanSetModifiedChunkTimeout( const vmanVolume volume, int seconds )
42 {
43  assert(volume != NULL);
44  ((vman::Volume*)volume)->setModifiedChunkTimeout(seconds);
45 }
46 
47 void vmanResetStatistics( const vmanVolume volume )
48 {
49  assert(volume != NULL);
50  ((vman::Volume*)volume)->resetStatistics();
51 }
52 
53 bool vmanGetStatistics( const vmanVolume volume, vmanStatistics* statisticsDestination )
54 {
55  assert(volume != NULL);
56  return ((vman::Volume*)volume)->getStatistics(statisticsDestination);
57 }
58 
60 {
61  assert(volume != NULL);
62  return new vman::Access((vman::Volume*)volume);
63 }
64 
65 void vmanDeleteAccess( const vmanAccess access )
66 {
67  assert(access != NULL);
68  delete (vman::Access*)access;
69 }
70 
71 void vmanSelect( vmanAccess access, const vmanSelection* selection )
72 {
73  assert(access != NULL);
74  ((vman::Access*)access)->select(selection);
75 }
76 
77 void vmanLockAccess( vmanAccess access, int mode )
78 {
79  assert(access != NULL);
80  ((vman::Access*)access)->lock(mode);
81 }
82 
83 int vmanTryLockAccess( vmanAccess access, int mode )
84 {
85  assert(access != NULL);
86  if( ((vman::Access*)access)->tryLock(mode) )
87  return 1;
88  else
89  return 0;
90 }
91 
93 {
94  assert(access != NULL);
95  ((vman::Access*)access)->unlock();
96 }
97 
98 const void* vmanReadVoxelLayer( const vmanAccess access, int x, int y, int z, int layer )
99 {
100  assert(access != NULL);
101  return ((vman::Access*)access)->readVoxelLayer(x,y,z, layer);
102 }
103 
104 void* vmanReadWriteVoxelLayer( const vmanAccess access, int x, int y, int z, int layer )
105 {
106  assert(access != NULL);
107  return ((vman::Access*)access)->readWriteVoxelLayer(x,y,z, layer);
108 }
109