File: XdmfObject.h

package info (click to toggle)
vtk6 6.1.0+dfsg2-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 165,164 kB
  • ctags: 226,428
  • sloc: cpp: 1,354,490; ansic: 730,748; python: 227,134; tcl: 48,285; xml: 8,290; yacc: 4,832; java: 3,827; perl: 3,108; lex: 1,809; sh: 1,437; asm: 471; makefile: 229
file content (520 lines) | stat: -rw-r--r-- 14,758 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
/*******************************************************************/
/*                               XDMF                              */
/*                   eXtensible Data Model and Format              */
/*                                                                 */
/*  Id : Id  */
/*  Date : $Date$ */
/*  Version : $Revision$ */
/*                                                                 */
/*  Author:                                                        */
/*     Jerry A. Clarke                                             */
/*     clarke@arl.army.mil                                         */
/*     US Army Research Laboratory                                 */
/*     Aberdeen Proving Ground, MD                                 */
/*                                                                 */
/*     Copyright @ 2002 US Army Research Laboratory                */
/*     All Rights Reserved                                         */
/*     See Copyright.txt or http://www.arl.hpc.mil/ice for details */
/*                                                                 */
/*     This software is distributed WITHOUT ANY WARRANTY; without  */
/*     even the implied warranty of MERCHANTABILITY or FITNESS     */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice   */
/*     for more information.                                       */
/*                                                                 */
/*******************************************************************/
/*! \mainpage XDMF Object Directory API
*
* \section intro Introduction
*
* The eXtensible Data Model and Format (XDMF) is a distributed data hub for accessing scientific data in
* High Performance Computing (HPC) applications. XDMF defines a data model and format as
* well as facilities for accessing the data in a distributed environment.
* The Data Format utilizes
* the Hierarchical Data Format Version 5 (HDF5) , from NCSA, to store large amount of data
* that can be accessed in a host independent fashion. The eXtensible Markup Language
* (XML) is used to describe the high level organization of the data in HDF5. Finally
* a built-in Distributed Shared Memory (DSM) system is used to allow distributed access to cooperating
* applications.

* Access to XDMF is provided via a C++ class library. 
* While usage of this library is not required it
* provides a convenience layer and error checking facility that 
* most users will find beneficial.
* For some users, however, accessing HDF5 via the NCSA provided Application Programmers
* Interface may be desirable in order to gain finer control
* over data access. In addition, XML is
* pervasive in WEB applications and there are a number of good, third party XML tools and
* libraries. These tools may provide useful functions not available in the XDMF convenience
* layer.

* XDMF differs from other "Data Model and Format" efforts in that the Light data is logically (
* and possibly physically ) separated from the Heavy data. Light data is considered to be both
* "data about the data" such as dimensions and name, as well as small quantities of computed
* data. Heavy data is considered to be large amounts of data. For example, in a three
* dimensional structural mechanics calculation, the size and dimensions of the computational
* grid are Light data while the actual X, Y, and Z values 
* for the grid are Heavy data. Calculated
* values like "Pressure at a node" are Heavy, while "Total Residual Mass" for the entire
* calculation is Light. As a rule of thumb, if the data is 
*  "less that 50-100" values, it's Light data.
* 
* This API is also "wrapped" using SWIG. This provides a scripting language
* interface to Tcl, Python, Perl, and Java.
*
*  
*/

#include "XdmfConfig.h"

#ifndef __XdmfObject_h
#define __XdmfObject_h


# ifndef SWIG
#if !defined( WIN32 ) || defined(__CYGWIN__)
#define UNIX
#endif /* WIN32 */

# ifdef __hpux
#  include <sys/param.h>
# endif

# ifdef UNIX
#  include "sys/file.h"
#  include "strings.h"
#  define STRCASECMP strcasecmp
#  define STRNCASECMP strncasecmp
#  define STRCMP strcmp
#  define STRNCMP strncmp
# endif

# if defined(WIN32) && !defined(__CYGWIN__)
/* winsock.h seems not being used in Xdmf, but
*  will cause conflicts with projects that includes "winsock2.h" */
/* #  include "winsock.h" */
/* String comparison routine. */
#  define STRCASECMP _stricmp
#  define STRNCASECMP _strnicmp
#  define STRCMP strcmp
#  define STRNCMP strncmp
# endif
#endif /* SWIG */

#include <string.h> /* strcmp for XdmfSetStringMacro */

#ifdef __cplusplus
/* Use ANSI C++ --------------------------------------------- */
# ifndef SWIG
#  ifdef _MSC_VER
#   pragma warning (push, 1)
#   pragma warning (disable: 4702)
#  endif
#  include <string>
#  ifdef _MSC_VER
#   pragma warning(pop)
#  endif
#  ifdef XDMF_USE_ANSI_STDLIB
#   include <iostream>
/* We'll need to migrate to sstream */
/* #   include <sstream> */
/* But for now use strstream */
/* RHEL give Deprecated warning ... ignore them for now */
#undef __DEPRECATED
#   include <strstream>
#define __DEPRECATED
#   include <fstream>
#   include <iomanip>
using std::cerr;
using std::cout;
using std::cin;
using std::ios;
using std::endl;
using std::ends;
using std::ostream;
using std::istream;
using std::ostrstream;
using std::istrstream;
using std::strstream;
using std::ofstream;
using std::ifstream;
using std::fstream;
using std::hex;



/* otherwise, non-ANSI ----------------------------------------------------- */
#  else /* XDMF_USE_ANSI_STDLIB */
#   include <iostream.h>
#   if defined(_MSC_VER)
#     include <strstrea.h>
#   else
#     include <strstream.h>
#   endif
#   include <fstream.h>
#   include <iomanip.h>
#  endif /* XDMF_USE_ANSI_STDLIB */
# endif /* SWIG */
#endif /* __cplusplus */

#ifdef XDMF_NO_STD_NAMESPACE
#  define xdmfstd
#else
#  define xdmfstd std
#endif

#include "XdmfExport.h"

#define XDMF_VERSION 2.1
#define XDMF_VERSION_STRING "2.1"

#define XDMF_SUCCESS  1
#define XDMF_FAIL  -1

#define XDMF_TRUE  1
#define XDMF_FALSE  0

#define XDMF_MAX_DIMENSION  10
#define XDMF_MAX_STRING_LENGTH  1024

/* #define XDMF_LIST_KEY  ICE_LIST_KEY */
#define XDMF_BIG_INT XDMF_64_INT 

#define XDMF_DEFAULT_INDEX  -1

#define XDMF_SELECT_SLAB    1
#define XDMF_SELECT_INDEX  2

#define  XDMF_UNKNOWN_TYPE   -1
#define  XDMF_INT8_TYPE      1
#define  XDMF_INT16_TYPE     6
#define  XDMF_INT32_TYPE     2
#define  XDMF_INT64_TYPE     3
#define  XDMF_FLOAT32_TYPE   4
#define  XDMF_FLOAT64_TYPE   5
#define  XDMF_UINT8_TYPE     7
#define  XDMF_UINT16_TYPE    8
#define  XDMF_UINT32_TYPE    9
#define XDMF_COMPOUND_TYPE  0x10

/* typedef ICE_CHAR       XDMF_CHAR; */
/* typedef ICE_PTR        XDMF_PTR; */
/* typedef ICE_8_INT      XDMF_8_INT; */
/* typedef ICE_8_U_INT    XDMF_8_UINT; */
/* typedef ICE_16_INT     XDMF_16_INT; */
/* typedef ICE_16_U_INT   XDMF_16_UINT; */
/* typedef ICE_32_INT     XDMF_32_INT; */
/* typedef ICE_32_U_INT   XDMF_32_UINT; */
/* typedef ICE_64_INT     XDMF_64_INT; */
/* typedef ICE_FLOAT      XDMF_FLOAT; */
/* typedef ICE_DOUBLE     XDMF_DOUBLE; */

#ifdef __cplusplus
# ifndef SWIG
#  include <string>
# endif 
//typedef xdmfstd::string XdmfSTDString;
#endif

#ifndef SWIG
typedef XDMF_32_INT  XdmfBoolean;
typedef XDMF_CHAR *  XdmfString;
typedef const XDMF_CHAR *  XdmfConstString;
typedef XDMF_PTR  XdmfPointer;
typedef XDMF_8_U_INT   XdmfUInt8;
typedef XDMF_16_U_INT  XdmfUInt16;
typedef XDMF_32_U_INT  XdmfUInt32;
typedef XDMF_8_INT   XdmfInt8;
typedef XDMF_16_INT  XdmfInt16;
typedef XDMF_32_INT  XdmfInt32;
typedef XDMF_64_INT  XdmfInt64;
typedef XDMF_FLOAT  XdmfFloat32;
typedef XDMF_DOUBLE  XdmfFloat64;

typedef XdmfInt8  XdmfByte;
typedef XdmfInt64  XdmfLength;
#else
/***************************************
Swig only understands certain types
and doesn't to well with typedefs
so we need to fool the interface code
***************************************/
typedef int             XdmfBoolean;
typedef char *          XdmfString;
typedef const char *    XdmfConstString;
typedef void *          XdmfPointer;
typedef unsigned char   XdmfUInt8;
typedef unsigned short  XdmfUInt16;
typedef unsigned int    XdmfUInt32;
typedef char            XdmfInt8;
typedef short           XdmfInt16;
typedef int             XdmfInt32;
typedef long long       XdmfInt64;
typedef float           XdmfFloat32;
typedef double          XdmfFloat64;

typedef unsigned char   XdmfByte;
typedef long long       XdmfLength;

#endif

#ifdef SWIG

#ifdef SWIGJAVA
%echo "Applying Special Java Typemaps .... "
#endif /* SWIGJAVA */
#ifdef SWIGTCL
%echo "Applying Special Tcl Typemaps ..... "
%include typemaps.i
/**************************************
Since the scripting view and the real
view of these types might not jive, we
need to make sure ....
**************************************/
//%typemap(tcl8, in) XdmfInt32, XdmfInt64, XdmfLength {
//  long  Value;
//  int  ArgIndex;

  // Really bad hack to get index
  // Assumes SWIG uses names : objc, objv
  // This is necessary because SWIG is messing up
  // Optional Arguments
//  sscanf("$arg", "objv[%d", &ArgIndex );
//  if( ArgIndex < objc ){
//    Tcl_GetLongFromObj( interp, $source, &Value );
//    $target = Value;
//  }
//  }
//%typemap(tcl8, out ) XdmfInt32, XdmfInt64, XdmfLength {
//  Tcl_Obj *Result;
//  long  Value;
//
//  Result = Tcl_GetObjResult(interp);
//  Value = $source;
//  Tcl_SetLongObj( Result, Value);
//  }
#endif /* SWIGTCL */

#ifdef SWIGCSHARP
%echo "Applying Special C# Typemaps .... "
%typemap(cscode) XdmfObject %{
  // Ensure that the GC doesn't collect any inserted XdmfElement instance set from C#
  public void setCMemOwn(bool val) {
    swigCMemOwn = val;
  }
%}
#endif

#ifdef SWIGPYTHON
%echo "Applying Python Typemaps ..... "
%include typemaps.i
%echo "No Special Python Typemaps Necessary"
/*
%typemap(python, in) XdmfInt32, XdmfInt64, XdmfLength {
  long  Value;

  Value = PyInt_AsLong( $source );
  $target = Value;
  }
%typemap(python, out ) XdmfInt32, XdmfInt64, XdmfLength {
  PyObject *Result;
  long  Value;

  Value = $source;
  Result = PyInt_FromLong( Value );
  $target = Result;
  }
%typemap(python, out ) XdmfString {
    PyObject *Result;

    if ($source == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }
  Result = PyString_FromString( $source );
  $target = Result;
}
*/

#endif /* SWIGPYTHON */

#endif /* SWIG */

#ifndef SWIG
#ifndef MAX
#define MAX(a,b)  ((a) > (b) ? (a) : (b))
#endif /*  MAX */

#ifndef MIN
#define MIN(a,b)  ((a) < (b) ? (a) : (b))
#endif /* MIN */


/*! Used for Parsing */

#define XDMF_WORD_CMP( a, b )  ( (a) != NULL ) && ( STRCASECMP((a),(b)) == 0 )

#define XDMF_STRING_DUPLICATE( dest, src ) \
  if ( src ) { \
    dest = new char[strlen(src) + 1]; \
    strcpy(dest, src); \
  } else { \
    dest = 0; \
  }

#define XDMF_STRING_TRIM( str ) { \
  std::string::size_type spos = str.find_first_not_of(" \n\t"); \
  std::string::size_type epos = str.find_last_not_of(" \n\t"); \
  if ( spos == str.npos ) \
    { \
    str = ""; \
    } \
  else \
    { \
    if ( epos != str.npos ) \
      { \
      epos = epos - spos + 1; \
      } \
    str = str.substr(spos, epos); \
    } \
  }

#define XDMF_WORD_TRIM( a ) { \
  size_t          StringLength; \
  char            *fp; \
  char            *st; \
  char            *ed; \
   \
  fp = (a); \
  StringLength = strlen( ( a ) ); \
  while( ( *fp <= ' ' ) && ( StringLength > 0 ) ){ \
          fp++; \
          StringLength--; \
          } \
  ed = fp;\
  st = a;\
  while(*ed) {\
    *st = *ed;\
    st++;\
    ed++;\
    }\
  /*strcpy((a), fp );*/ \
  fp = &(a)[ StringLength - 1 ]; \
  while( ( *fp <= ' ' ) && ( StringLength > 0 ) ){ \
          fp--; \
          StringLength--; \
          } \
  fp++; \
  *fp = '\0'; \
  }
#ifndef  XDMF_WORD_CMP
#define XDMF_WORD_CMP( a, b )  ( (a) != NULL ) && ( STRCASECMP((a),(b)) == 0 )
#endif

#endif /* SWIG */

#ifdef __cplusplus

#define DebugIsOn ( this->Debug || XdmfObject::GetGlobalDebug() )

#define DebugIsAbove(a)  ( ( this->Debug >= (a) ) || ( XdmfObject::GetGlobalDebug() >= (a))) 

#define XdmfDebug(x) \
{ if ( this->Debug || XdmfObject::GetGlobalDebug() ) { \
  cerr << "XDMF Debug : " << __FILE__ << " line " << __LINE__ << " ("<< x << ")" << "\n"; \
  } \
}


#define XdmfErrorMessage(x) \
  cerr << "XDMF Error in " << __FILE__ << " line " << __LINE__ << " ("<< x << ")" << "\n";

#define XdmfSetValueMacro(var,type) \
XdmfInt32 Set##var (type _arg) \
  { \
  this->var = _arg; \
  return ( XDMF_SUCCESS ); \
  }

#define XdmfSetStringMacro(var) \
XdmfInt32 Set##var (XdmfConstString _arg) \
  { \
  if ( this->var == _arg ) { return XDMF_SUCCESS; } \
  if ( this->var && _arg && strcmp(this->var, _arg) == 0 ) { return XDMF_SUCCESS; } \
  if ( this->var ) { delete [] this->var; this->var = 0; } \
  if ( _arg ) { this->var = new char[ strlen(_arg) + 1 ]; strcpy(this->var, _arg); } \
  return ( XDMF_SUCCESS ); \
  }

#define XdmfGetStringMacro(var) \
XdmfConstString Get##var () \
  { \
  return ( this->var ); \
  }

#define XdmfSetIndexValueMacro(var,type) \
XdmfInt32 Set##var ( XdmfInt64 Index, type _arg) \
  { \
  this->var[ Index ]  = _arg; \
  return ( XDMF_SUCCESS ); \
  }


#define XdmfGetValueMacro(var,type) \
type Get##var () \
  { \
  return ( this->var ); \
  }

#define XdmfGetIndexValueMacro(var,type) \
type Get##var (XdmfInt64 Index) \
  { \
  return ( this->var[ Index ]  ); \
  }

//! Base Class for All Xdmf Objects
class XDMF_EXPORT XdmfObject {
public:
  XdmfObject();
  ~XdmfObject();
  XdmfConstString GetClassName() { return("XdmfObject"); } ;

  XdmfSetValueMacro(Debug, XdmfBoolean);
  XdmfGetValueMacro(Debug, XdmfBoolean);

  XdmfBoolean GetGlobalDebug();
  void SetGlobalDebug( XdmfBoolean Value );

  void DebugOn() { XdmfObject::SetDebug( 1 ) ; };
  void DebugOff() { XdmfObject::SetDebug( 0 ) ; };

  void GlobalDebugOn() { XdmfObject::SetGlobalDebug( 1 ) ; };
  void GlobalDebugOff() { XdmfObject::SetGlobalDebug( 0 ) ; };

  XdmfConstString GetUniqueName(XdmfConstString NameBase=NULL);



protected:
  XdmfInt32 Debug;  

private:
};

XDMF_EXPORT void SetGlobalDebugOn();
XDMF_EXPORT void SetGlobalDebugOff();

XDMF_EXPORT XdmfInt32 GetGlobalDebug( void );
XDMF_EXPORT void SetGlobalDebug( XdmfInt32 DebugLevel );

XDMF_EXPORT XdmfString GetUnique( XdmfConstString Pattern = NULL );
extern XDMF_EXPORT XdmfString XdmfObjectToHandle( XdmfObject *Source );
extern XDMF_EXPORT XdmfObject *HandleToXdmfObject( XdmfConstString Source );
extern XDMF_EXPORT XdmfPointer VoidPointerHandleToXdmfPointer(XdmfConstString Source);

#ifndef SWIG
extern XDMF_EXPORT istrstream& XDMF_READ_STREAM64(istrstream& istr, XDMF_64_INT& i);
#endif

#endif /* __cplusplus */

#endif /* __XdmfObject_h */