Xdmf.i 12.4 KB
Newer Older
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
1
2
3
4
5
/*
XdmfPython.cpp:
swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
*/

6
7
%module Xdmf
%{
8
	// XdmfCore Includes
9
	#include <XdmfArray.hpp>
10
	#include <XdmfArrayType.hpp>
11
12
13
14
	#include <XdmfCoreItemFactory.hpp>
	#include <XdmfCoreReader.hpp>
	#include <XdmfHDF5Controller.hpp>
	#include <XdmfHDF5Writer.hpp>
15
	#include <XdmfInformation.hpp>
16
17
	#include <XdmfItem.hpp>
	#include <XdmfItemProperty.hpp>
18
	#include <XdmfSystemUtils.hpp>
19
20
21
22
	#include <XdmfVisitor.hpp>
	#include <XdmfWriter.hpp>

	// Xdmf Includes
23
24
25
26
27
28
29
	#include <XdmfAttribute.hpp>
	#include <XdmfAttributeCenter.hpp>
	#include <XdmfAttributeType.hpp>
	#include <XdmfDomain.hpp>
	#include <XdmfGeometry.hpp>
	#include <XdmfGeometryType.hpp>
	#include <XdmfGrid.hpp>
30
31
	#include <XdmfGridCollection.hpp>
	#include <XdmfGridCollectionType.hpp>
32
	#include <XdmfItemFactory.hpp>
33
	#include <XdmfMap.hpp>
34
	#include <XdmfReader.hpp>
35
36
	#include <XdmfSet.hpp>
	#include <XdmfSetType.hpp>
37
	#include <XdmfTime.hpp>
38
39
40
	#include <XdmfTopology.hpp>
	#include <XdmfTopologyType.hpp>
%}
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
41

42
43
%import XdmfCore.i

44
45
46
47
48
49
50
51
52
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
80
81
82
83
84
85
86
87
#ifdef SWIGJAVA
    %extend XdmfAttributeCenter {
        bool equals(boost::shared_ptr<XdmfAttributeCenter> attributeCenter) {
            return(self->IsEqual(attributeCenter));
        }
    };
    %extend XdmfAttributeType {
        bool equals(boost::shared_ptr<XdmfAttributeType> attributeType) {
            return(self->IsEqual(attributeType));
        }
    };
    %extend XdmfGeometryType {
        bool equals(boost::shared_ptr<XdmfGeometryType> geometryType) {
            return(self->IsEqual(geometryType));
        }
    };
    %extend XdmfGridCollectionType {
        bool equals(boost::shared_ptr<XdmfGridCollectionType> collectionType) {
            return(self->IsEqual(collectionType));
        }
    };
    %extend XdmfSetType {
        bool equals(boost::shared_ptr<XdmfSetType> setType) {
            return(self->IsEqual(setType));
        }
    };
    %extend XdmfTopologyType {
        bool equals(boost::shared_ptr<XdmfTopologyType> topologyType) {
            return(self->IsEqual(topologyType));
        }
    };
    %ignore XdmfTopologyType::operator==(const XdmfTopologyType & topologyType) const;
    %ignore XdmfTopologyType::operator!=(const XdmfTopologyType & topologyType) const;
    %ignore XdmfSetType::operator==(const XdmfSetType & setType) const;
    %ignore XdmfSetType::operator!=(const XdmfSetType & setType) const;
    %ignore XdmfGridCollectionType::operator==(const XdmfGridCollectionType & collectionType) const;
    %ignore XdmfGridCollectionType::operator!=(const XdmfGridCollectionType & collectionType) const;
    %ignore XdmfAttributeCenter::operator==(const XdmfAttributeCenter & attributeCenter) const;
    %ignore XdmfAttributeCenter::operator!=(const XdmfAttributeCenter & attributeCenter) const;
    %ignore XdmfGeometryType::operator==(const XdmfGeometryType & geometryType) const;
    %ignore XdmfGeometryType::operator!=(const XdmfGeometryType & geometryType) const;
    %ignore XdmfAttributeType::operator==(const XdmfAttributeType & attributeType) const;
    %ignore XdmfAttributeType::operator!=(const XdmfAttributeType & attributeType) const;

88
89
    %rename(getAttributeUIntConst) XdmfSet::getAttribute(unsigned int const) const;
    %rename(getAttributeStrConst) XdmfSet::getAttribute(std::string const &) const;
90
91
92
93
94
95
96
97
98
#endif


#ifdef SWIGPYTHON
%extend XdmfAttributeCenter {
  bool __eq__(boost::shared_ptr<XdmfAttributeCenter> attributeCenter) {
    return(self->IsEqual(attributeCenter));
  }
};
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
%extend XdmfAttributeType {
  bool __eq__(boost::shared_ptr<XdmfAttributeType> attributeType) {
    return(self->IsEqual(attributeType));
  }
};
%extend XdmfGeometryType {
  bool __eq__(boost::shared_ptr<XdmfGeometryType> geometryType) {
    return(self->IsEqual(geometryType));
  }
};
%extend XdmfGridCollectionType {
  bool __eq__(boost::shared_ptr<XdmfGridCollectionType> collectionType) {
    return(self->IsEqual(collectionType));
  }
};
%extend XdmfSetType {
  bool __eq__(boost::shared_ptr<XdmfSetType> setType) {
    return(self->IsEqual(setType));
  }
};
%extend XdmfTopologyType {
  bool __eq__(boost::shared_ptr<XdmfTopologyType> topologyType) {
    return(self->IsEqual(topologyType));
  }
};
124
125
126
#endif


127
#ifdef SWIGPYTHON
128
129
130
%pythoncode {
	from XdmfCore import *
}
131
132
133
134
135
136
137
%typemap(out) boost::shared_ptr<XdmfItem> {
	if(boost::shared_ptr<XdmfAttribute> attribute = boost::shared_dynamic_cast<XdmfAttribute>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfAttribute>(attribute)), SWIGTYPE_p_boost__shared_ptrT_XdmfAttribute_t, SWIG_POINTER_OWN);
	}
	else if(boost::shared_ptr<XdmfDomain> domain = boost::shared_dynamic_cast<XdmfDomain>($1))
	{
138
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfDomain>(domain)), SWIGTYPE_p_boost__shared_ptrT_XdmfDomain_t, SWIG_POINTER_OWN);
139
140
141
142
143
144
145
146
147
148
149
150
151
	}
	else if(boost::shared_ptr<XdmfGeometry> geometry = boost::shared_dynamic_cast<XdmfGeometry>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGeometry>(geometry)), SWIGTYPE_p_boost__shared_ptrT_XdmfGeometry_t, SWIG_POINTER_OWN);
	}
	else if(boost::shared_ptr<XdmfGrid> grid = boost::shared_dynamic_cast<XdmfGrid>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGrid>(grid)), SWIGTYPE_p_boost__shared_ptrT_XdmfGrid_t, SWIG_POINTER_OWN);
	}
	else if(boost::shared_ptr<XdmfGridCollection> gridCollection = boost::shared_dynamic_cast<XdmfGridCollection>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfGridCollection>(gridCollection)), SWIGTYPE_p_boost__shared_ptrT_XdmfGridCollection_t, SWIG_POINTER_OWN);
	}
152
153
154
155
	else if(boost::shared_ptr<XdmfInformation> information = boost::shared_dynamic_cast<XdmfInformation>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfInformation>(information)), SWIGTYPE_p_boost__shared_ptrT_XdmfInformation_t, SWIG_POINTER_OWN);
	}
156
157
158
159
	else if(boost::shared_ptr<XdmfMap> map = boost::shared_dynamic_cast<XdmfMap>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfMap>(map)), SWIGTYPE_p_boost__shared_ptrT_XdmfMap_t, SWIG_POINTER_OWN);
	}
160
161
162
163
	else if(boost::shared_ptr<XdmfSet> set = boost::shared_dynamic_cast<XdmfSet>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfSet>(set)), SWIGTYPE_p_boost__shared_ptrT_XdmfSet_t, SWIG_POINTER_OWN);
	}
164
165
166
167
	else if(boost::shared_ptr<XdmfTime> time = boost::shared_dynamic_cast<XdmfTime>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfTime>(time)), SWIGTYPE_p_boost__shared_ptrT_XdmfTime_t, SWIG_POINTER_OWN);
	}
168
169
170
171
172
173
174
175
176
	else if(boost::shared_ptr<XdmfTopology> topology = boost::shared_dynamic_cast<XdmfTopology>($1))
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfTopology>(topology)), SWIGTYPE_p_boost__shared_ptrT_XdmfTopology_t, SWIG_POINTER_OWN);
	}
	else
	{
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfItem>($1)), SWIGTYPE_p_boost__shared_ptrT_XdmfItem_t, SWIG_POINTER_OWN);
	}
}
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#endif

#if 0
%include std_set.i
%template(std_set_uint) std::set<unsigned int>;

// Abstract Base Classes
%template() Loki::Visitor<XdmfSet>;
#endif

#ifdef SWIGJAVA

// Typemaps that work for Java

%typemap(out)  boost::shared_ptr<XdmfItem> {
        if(boost::shared_ptr<XdmfAttribute> value = boost::shared_dynamic_cast<XdmfAttribute>($1))
        {
                *(boost::shared_ptr< XdmfAttribute > **)&($result) = value ? new boost::shared_ptr< XdmfAttribute >(value) : 0;
        }
        else if(boost::shared_ptr<XdmfDomain> value = boost::shared_dynamic_cast<XdmfDomain>($1))
        {
                *(boost::shared_ptr< XdmfDomain > **)&($result) = value ? new boost::shared_ptr< XdmfDomain >(value) : 0;
        }
        else if(boost::shared_ptr<XdmfGeometry> value = boost::shared_dynamic_cast<XdmfGeometry>($1))
        {
                *(boost::shared_ptr< XdmfGeometry > **)&($result) = value ? new boost::shared_ptr< XdmfGeometry >(value) : 0;
        }
        else if(boost::shared_ptr<XdmfGrid> value = boost::shared_dynamic_cast<XdmfGrid>($1))
        {
                *(boost::shared_ptr< XdmfGrid > **)&($result) = value ? new boost::shared_ptr< XdmfGrid >(value) : 0;
        }
        else if(boost::shared_ptr<XdmfGridCollection> value = boost::shared_dynamic_cast<XdmfGridCollection>($1))
        {
                *(boost::shared_ptr< XdmfGridCollection > **)&($result) = value ? new boost::shared_ptr< XdmfGridCollection >(value) : 0;
        }
        else if(boost::shared_ptr<XdmfInformation> value = boost::shared_dynamic_cast<XdmfInformation>($1))
        {
                *(boost::shared_ptr< XdmfInformation > **)&($result) = value ? new boost::shared_ptr< XdmfInformation >(value) : 0;
        }
        else if(boost::shared_ptr<XdmfSet> value = boost::shared_dynamic_cast<XdmfSet>($1))
        {
                *(boost::shared_ptr< XdmfSet > **)&($result) = value ? new boost::shared_ptr< XdmfSet >(value) : 0;
        }
        else if(boost::shared_ptr<XdmfTime> value = boost::shared_dynamic_cast<XdmfTime>($1))
        {
               *(boost::shared_ptr< XdmfTime > **)&($result) = value ? new boost::shared_ptr< XdmfTime >(value) : 0;
        }
        else if(boost::shared_ptr<XdmfTopology> value = boost::shared_dynamic_cast<XdmfTopology>($1))
        {
                *(boost::shared_ptr< XdmfTopology > **)&($result) = value ? new boost::shared_ptr< XdmfTopology >(value) : 0;
        }
        else
        {
                *(boost::shared_ptr< XdmfItem > **)&($result) = &($1);
        }
}

// Swig+Java will automatically create 'getter' functions for static
// variables in a class (in this case the ItemTag member variable).
// This happens to conflict with the getters that Xdmf implements to
// override the otherwise virtual functions of the parent class.  Here,
// we ask swig to ignore the static variable (thereby removing direct
// access to the variable, but leaving access to our getter function

%ignore XdmfAttribute::ItemTag;
%ignore XdmfDomain::ItemTag;
%ignore XdmfGeometry::ItemTag;
%ignore XdmfGrid::ItemTag;
%ignore XdmfGridCollection::ItemTag;
%ignore XdmfSet::ItemTag;
%ignore XdmfTime::ItemTag;
%ignore XdmfTopology::ItemTag;
%ignore XdmfMap::ItemTag;

// Swig+Java does not like 2 functions with the same prototype that
// simply return const/non-const versions of the same type.  We
// ask Swig to ignore one of the two getter functions.  We may
// have to change this to rename the function to a new name such
// that we preserve the ability to get a constant variable

%ignore XdmfDomain::getGrid(const unsigned int index) const;
%ignore XdmfDomain::getGridCollection(unsigned int const) const;
%ignore XdmfGrid::getAttribute(const unsigned int index) const;
%ignore XdmfGrid::getAttribute(const std::string & name) const;
%ignore XdmfGrid::getSet(const unsigned int index) const;
%ignore XdmfGrid::getSet(const std::string & name) const;
%ignore XdmfGrid::getGeometry() const;
%ignore XdmfGrid::getTime() const;
%ignore XdmfGrid::getTopology() const;
%ignore XdmfGridCollection::getGrid(const unsigned int index) const;
267
%ignore XdmfGridCollection::insert(const boost::shared_ptr<XdmfInformation> information);
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
%ignore XdmfGrid::getMap() const;
%ignore XdmfSet::getHDF5Controller() const;

%pragma(java) jniclasscode=%{
  static {
    try {
        System.loadLibrary("XdmfCoreJava");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load for XdmfCoreJava\n" + e);
      System.exit(1);
    }
    try {
        System.loadLibrary("XdmfJava");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load for XdmfJava\n" + e);
      System.exit(1);
    }
  }
%}

288
#endif */ SWIGJAVA */
289

290
// Shared Pointer Templates
291
%shared_ptr(XdmfAttribute)
292
293
%shared_ptr(XdmfAttributeCenter)
%shared_ptr(XdmfAttributeType)
294
295
%shared_ptr(XdmfDomain)
%shared_ptr(XdmfGeometry)
296
%shared_ptr(XdmfGeometryType)
297
298
%shared_ptr(XdmfGrid)
%shared_ptr(XdmfGridCollection)
299
300
%shared_ptr(XdmfGridCollectionType)
%shared_ptr(XdmfItemFactory)
301
%shared_ptr(XdmfMap)
302
303
304
%shared_ptr(XdmfReader)
%shared_ptr(XdmfSet)
%shared_ptr(XdmfSetType)
305
%shared_ptr(XdmfTime)
306
%shared_ptr(XdmfTopology)
307
%shared_ptr(XdmfTopologyType)
308

309
%include XdmfAttribute.hpp
310
%include XdmfAttributeCenter.hpp
311
%include XdmfAttributeType.hpp
Kenneth Leiter's avatar
Kenneth Leiter committed
312
%include XdmfDomain.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
313
%include XdmfGeometry.hpp
314
%include XdmfGeometryType.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
315
%include XdmfGrid.hpp
316
317
318
%include XdmfGridCollection.hpp
%include XdmfGridCollectionType.hpp
%include XdmfItemFactory.hpp
319
%include XdmfMap.hpp
320
%include XdmfReader.hpp
321
322
%include XdmfSet.hpp
%include XdmfSetType.hpp
323
%include XdmfTime.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
324
%include XdmfTopology.hpp
325
%include XdmfTopologyType.hpp