Xdmf.i 11.6 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
88
89
90
91
92
93
94
95
96
97
98
99
#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;

#endif


#ifdef SWIGPYTHON
%extend XdmfAttributeCenter {
  bool __eq__(boost::shared_ptr<XdmfAttributeCenter> attributeCenter) {
    return(self->IsEqual(attributeCenter));
  }
};
#endif


100
#ifdef SWIGPYTHON
101
102
103
%pythoncode {
	from XdmfCore import *
}
104
105
106
107
108
109
110
%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))
	{
111
		$result = SWIG_NewPointerObj(SWIG_as_voidptr(new boost::shared_ptr<XdmfDomain>(domain)), SWIGTYPE_p_boost__shared_ptrT_XdmfDomain_t, SWIG_POINTER_OWN);
112
113
114
115
116
117
118
119
120
121
122
123
124
	}
	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);
	}
125
126
127
128
	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);
	}
129
130
131
132
	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);
	}
133
134
135
136
	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);
	}
137
138
139
140
	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);
	}
141
142
143
144
145
146
147
148
149
	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);
	}
}
150
151
152
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
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
#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;
240
%ignore XdmfGridCollection::insert(const boost::shared_ptr<XdmfInformation> information);
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
%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);
    }
  }
%}

261
#endif */ SWIGJAVA */
262

263
// Shared Pointer Templates
264
%shared_ptr(XdmfAttribute)
265
266
%shared_ptr(XdmfAttributeCenter)
%shared_ptr(XdmfAttributeType)
267
268
%shared_ptr(XdmfDomain)
%shared_ptr(XdmfGeometry)
269
%shared_ptr(XdmfGeometryType)
270
271
%shared_ptr(XdmfGrid)
%shared_ptr(XdmfGridCollection)
272
273
%shared_ptr(XdmfGridCollectionType)
%shared_ptr(XdmfItemFactory)
274
%shared_ptr(XdmfMap)
275
276
277
%shared_ptr(XdmfReader)
%shared_ptr(XdmfSet)
%shared_ptr(XdmfSetType)
278
%shared_ptr(XdmfTime)
279
%shared_ptr(XdmfTopology)
280
%shared_ptr(XdmfTopologyType)
281

282
%include XdmfAttribute.hpp
283
%include XdmfAttributeCenter.hpp
284
%include XdmfAttributeType.hpp
Kenneth Leiter's avatar
Kenneth Leiter committed
285
%include XdmfDomain.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
286
%include XdmfGeometry.hpp
287
%include XdmfGeometryType.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
288
%include XdmfGrid.hpp
289
290
291
%include XdmfGridCollection.hpp
%include XdmfGridCollectionType.hpp
%include XdmfItemFactory.hpp
292
%include XdmfMap.hpp
293
%include XdmfReader.hpp
294
295
%include XdmfSet.hpp
%include XdmfSetType.hpp
296
%include XdmfTime.hpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
297
%include XdmfTopology.hpp
298
%include XdmfTopologyType.hpp