storage.cpp 7.39 KB
Newer Older
Kirill Terekhov's avatar
Kirill Terekhov committed
1
2
3
4
5
6
7
#include "inmost.h"

#if defined(USE_MESH)
#include <new>

namespace INMOST
{
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
8
9
10
	Storage & Storage::operator =(Storage const & other) 
	{
		handle = other.handle; 
Kirill Terekhov's avatar
Kirill Terekhov committed
11
12
		if( handle_link != NULL ) *handle_link = handle; 
		//else handle_link = other.handle_link; //if other have remote link this will copy this link and current will also be remote
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
13
14
15
		m_link = other.m_link; 
		return *this;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
16
17
	
	INMOST_DATA_ENUM_TYPE Storage::GetDataSize(const Tag & tag) const
Kirill Terekhov's avatar
Kirill Terekhov committed
18
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
19
20
21
22
23
24
		return GetMeshLink()->GetDataSize(GetHandle(),tag);
	}

	void Storage::SetDataSize(const Tag & tag,INMOST_DATA_ENUM_TYPE new_size) const
	{
		GetMeshLink()->SetDataSize(GetHandle(),tag,new_size);
Kirill Terekhov's avatar
Kirill Terekhov committed
25
26
	}
	
Kirill Terekhov's avatar
Kirill Terekhov committed
27
28
29
	void Storage::GetData(const Tag & tag,INMOST_DATA_ENUM_TYPE shift, INMOST_DATA_ENUM_TYPE size, void * data_out) const
	{
		GetMeshLink()->GetData(GetHandle(),tag,shift,size,data_out);
Kirill Terekhov's avatar
Kirill Terekhov committed
30
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
31
32
	
	void Storage::SetData(const Tag & tag,INMOST_DATA_ENUM_TYPE shift, INMOST_DATA_ENUM_TYPE size, const void * data_in) const
Kirill Terekhov's avatar
Kirill Terekhov committed
33
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
34
		GetMeshLink()->SetData(GetHandle(),tag,shift,size,data_in);
Kirill Terekhov's avatar
Kirill Terekhov committed
35
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
36
37
	
	void Storage::DelData(const Tag & tag) const
Kirill Terekhov's avatar
Kirill Terekhov committed
38
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
39
40
		GetMeshLink()->DelData(GetHandle(),tag);
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
41

Kirill Terekhov's avatar
Kirill Terekhov committed
42
43
44
	void Storage::DelDenseData(const Tag & tag) const
	{
		GetMeshLink()->DelDenseData(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
45
46
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
47
48
49
50
	void Storage::DelSparseData(const Tag & tag) const
	{
		GetMeshLink()->DelSparseData(GetHandle(),tag);
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
51
52


Kirill Terekhov's avatar
Kirill Terekhov committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	void Storage::SetMarker(MarkerType n)  const
	{
		assert( isValid() );
		GetMeshLink()->SetMarker(GetHandle(),n);
	}
	bool Storage::GetMarker(MarkerType n) const  
	{
		assert( isValid() );
		return GetMeshLink()->GetMarker(GetHandle(),n);
	}
	void Storage::RemMarker(MarkerType n)  const
	{
		assert( isValid() );
		GetMeshLink()->RemMarker(GetHandle(),n);
	}
	void Storage::ClearMarkerSpace()  const
	{
		GetMeshLink()->ClearMarkerSpace(GetHandle());
	}
	void Storage::GetMarkerSpace(Storage::bulk copy[MarkerFields]) const 
	{
		GetMeshLink()->GetMarkerSpace(GetHandle(),copy);
	}
	void Storage::SetMarkerSpace(Storage::bulk source[MarkerFields])  const
	{
		GetMeshLink()->SetMarkerSpace(GetHandle(),source);
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
80

Kirill Terekhov's avatar
Kirill Terekhov committed
81
82
83
84
85
86
87
88
89
90
91
92
	bool Storage::HaveData(const Tag & tag) const
	{
		assert(isValid());
		return GetMeshLink()->HaveData(GetHandle(),tag);
	}
	Storage::real      &              Storage::Real            (const Tag & tag) const
	{
		return GetMeshLink()->Real(GetHandle(),tag);
	}
	
	Storage::integer   &              Storage::Integer         (const Tag & tag)  const
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
93
		
Kirill Terekhov's avatar
Kirill Terekhov committed
94
95
96
97
98
99
		return GetMeshLink()->Integer(GetHandle(),tag);
	}
	
	Storage::bulk      &              Storage::Bulk            (const Tag & tag)  const
	{
		return GetMeshLink()->Bulk(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
100
101
	}
	
Kirill Terekhov's avatar
Kirill Terekhov committed
102
103
104
105
	Storage::reference &              Storage::Reference       (const Tag & tag)  const
	{
		return GetMeshLink()->Reference(GetHandle(),tag);
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
106
	
Kirill Terekhov's avatar
Kirill Terekhov committed
107
	Storage::real_array               Storage::RealArray       (const Tag & tag)  const
Kirill Terekhov's avatar
Kirill Terekhov committed
108
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
109
		return GetMeshLink()->RealArray(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
110
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
111
112
113
114
115
116
117
118
119
120
121
122
	
	Storage::integer_array            Storage::IntegerArray    (const Tag & tag)  const
	{
		return GetMeshLink()->IntegerArray(GetHandle(),tag);
	}
	
	Storage::bulk_array               Storage::BulkArray       (const Tag & tag)  const
	{
		return GetMeshLink()->BulkArray(GetHandle(),tag);
	}
	
	Storage::reference_array          Storage::ReferenceArray  (const Tag & tag)  const
Kirill Terekhov's avatar
Kirill Terekhov committed
123
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
124
125
		return GetMeshLink()->ReferenceArray(GetHandle(),tag);
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
126
		
Kirill Terekhov's avatar
Kirill Terekhov committed
127
128
129
	Storage::real_array               Storage::RealArrayDF     (const Tag & tag)  const
	{
		return GetMeshLink()->RealArrayDF(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
130
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
131
	Storage::integer_array            Storage::IntegerArrayDF  (const Tag & tag)  const
Kirill Terekhov's avatar
Kirill Terekhov committed
132
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
133
		return GetMeshLink()->IntegerArrayDF(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
134
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
135
	Storage::bulk_array               Storage::BulkArrayDF     (const Tag & tag)  const
Kirill Terekhov's avatar
Kirill Terekhov committed
136
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
137
		return GetMeshLink()->BulkArrayDF(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
138
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
139
	Storage::reference_array          Storage::ReferenceArrayDF(const Tag & tag)  const
Kirill Terekhov's avatar
Kirill Terekhov committed
140
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
141
		return GetMeshLink()->ReferenceArrayDF(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
142
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
143
	Storage::real      &              Storage::RealDF          (const Tag & tag)  const
Kirill Terekhov's avatar
Kirill Terekhov committed
144
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
145
		return GetMeshLink()->RealDF(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
146
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
147
	Storage::integer   &              Storage::IntegerDF       (const Tag & tag)  const
Kirill Terekhov's avatar
Kirill Terekhov committed
148
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
149
		return GetMeshLink()->IntegerDF(GetHandle(),tag);
Kirill Terekhov's avatar
Kirill Terekhov committed
150
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
151
	Storage::bulk      &              Storage::BulkDF          (const Tag & tag)  const
Kirill Terekhov's avatar
Kirill Terekhov committed
152
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
		return GetMeshLink()->BulkDF(GetHandle(),tag);
	}
	Storage::reference &              Storage::ReferenceDF     (const Tag & tag)  const
	{
		return GetMeshLink()->ReferenceDF(GetHandle(),tag);
	}
		
	Storage::real_array               Storage::RealArrayDV     (const Tag & tag)  const
	{
		return GetMeshLink()->RealArrayDV(GetHandle(),tag);
	}
	Storage::integer_array            Storage::IntegerArrayDV  (const Tag & tag)  const
	{
		return GetMeshLink()->IntegerArrayDV(GetHandle(),tag);	
	}
	Storage::bulk_array               Storage::BulkArrayDV     (const Tag & tag)  const
	{
		return GetMeshLink()->BulkArrayDV(GetHandle(),tag);
	}
	Storage::reference_array          Storage::ReferenceArrayDV(const Tag & tag)  const
	{
		return GetMeshLink()->ReferenceArrayDV(GetHandle(),tag);
	}
	Storage::real      &              Storage::RealDV          (const Tag & tag)  const
	{
		return GetMeshLink()->RealDV(GetHandle(),tag);
	}
	Storage::integer   &              Storage::IntegerDV       (const Tag & tag)  const
	{
		return GetMeshLink()->IntegerDV(GetHandle(),tag);
	}
	Storage::bulk      &              Storage::BulkDV          (const Tag & tag)  const
	{
		return GetMeshLink()->BulkDV(GetHandle(),tag);
	}
	Storage::reference &              Storage::ReferenceDV     (const Tag & tag)  const
	{
		return GetMeshLink()->ReferenceDV(GetHandle(),tag);
	}
		
	bool Storage::isValid() const 
	{
		return handle != InvalidHandle() && GetMeshLink()->isValidElement(handle);
Kirill Terekhov's avatar
Kirill Terekhov committed
196
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
197

Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
198
199
200
201
202
	Element Storage::reference_array::operator [](size_type n)  
	{
		return Element(m,&shell<HandleType>::operator[](n));
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
203
204
205
206
207
208
209
	Element Storage::reference_array::operator [](size_type n) const 
	{
		return Element(m,shell<HandleType>::operator[](n));
	}

	Element Storage::reference_array::iterator::operator->()
	{
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
210
		return Element(m,&shell<HandleType>::iterator::operator *());
Kirill Terekhov's avatar
Kirill Terekhov committed
211
212
213
214
215
216
	}

	Element Storage::reference_array::const_iterator::operator->()
	{
		return Element(m,shell<HandleType>::const_iterator::operator *());
	}
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
217
	
Kirill Terekhov's avatar
Kirill Terekhov committed
218
219
	Element Storage::reference_array::reverse_iterator::operator->()
	{
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
220
		return Element(m,&shell<HandleType>::reverse_iterator::operator *());
Kirill Terekhov's avatar
Kirill Terekhov committed
221
222
223
224
225
226
	}

	Element Storage::reference_array::const_reverse_iterator::operator->()
	{
		return Element(m,shell<HandleType>::const_reverse_iterator::operator *());
	}
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
227
228
229
230
231
232
233

	void Storage::reference_array::push_back(const Storage & ref) {shell<reference>::push_back(ref->GetHandle());}

	Storage::integer                  Storage::DataLocalID     () const
	{
		return GetMeshLink()->DataLocalID(GetHandle());
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
234
235
236
237
238
239
  Element Storage::getAsElement() const {assert(GetElementType() & (NODE | EDGE | FACE | CELL | ESET) ); return Element(GetMeshLink(), GetHandle());}
  Node Storage::getAsNode() const {assert(GetElementType() == NODE); return Node(GetMeshLink(),GetHandle());}
	Edge Storage::getAsEdge() const {assert(GetElementType() == EDGE); return Edge(GetMeshLink(),GetHandle());}
	Face Storage::getAsFace() const {assert(GetElementType() == FACE); return Face(GetMeshLink(),GetHandle());} 
	Cell Storage::getAsCell() const {assert(GetElementType() == CELL); return Cell(GetMeshLink(),GetHandle());}
	ElementSet Storage::getAsSet() const {assert(GetElementType() == ESET); return ElementSet(GetMeshLink(),GetHandle());}
Kirill Terekhov's avatar
Kirill Terekhov committed
240
241
242
}

#endif