Go to the documentation of this file. 1 #ifndef DAMSEL_UTIL_HPP
2 #define DAMSEL_UTIL_HPP
3
4 #include "moab/Forward.hpp"
5 #include "moab/ErrorHandler.hpp"
6 #include "DebugOutput.hpp"
7
8 #include "damsel.h"
9 #include "damsel-internal.h"
10
11
12
13
14 #define CHK_DMSL_ERR( A, B ) \
15 do \
16 { \
17 if( DMSL_OK.id != ( A ).id ) \
18 { \
19 MB_SET_ERR_CONT( B ); \
20 return error( MB_FAILURE ); \
21 } \
22 } while( false )
23
24 #define CHK_DMSL_ERR_NM( A ) \
25 do \
26 { \
27 if( DMSL_OK.id != ( A ).id ) \
28 { \
29 MB_CHK_ERR_CONT( MB_FAILURE ); \
30 return error( MB_FAILURE ); \
31 } \
32 } while( false )
33
34 namespace moab
35 {
36
37 class DamselUtil
38 {
39 public:
40 friend class WriteDamsel;
41 friend class ReadDamsel;
42
43
44 DamselUtil();
45
46 static damsel_data_type mtod_data_type[MB_MAX_DATA_TYPE + 1];
47
48 static enum DataType dtom_data_type[DAMSEL_DATA_TYPE_PREDEFINED_WATERMARK + 1];
49
50 static enum damsel_entity_type mtod_entity_type[MBMAXTYPE + 1];
51
52 static enum EntityType dtom_entity_type[DAMSEL_ENTITY_TYPE_ALL_TYPES + 1];
53
54
55
56 static ErrorCode container_to_range( damsel_model m, damsel_container& cont, Range& range );
57
58
59 class tinfo
60 {
61 public:
62 tinfo( Tag mt, damsel_handle dt, TagType tt ) : mTagh( mt ), dTagh( dt ), tagType( tt ) {}
63 tinfo() : mTagh( 0 ), dTagh( 0 ), tagType( MB_TAG_ANY ) {}
64
65 Tag mTagh;
66 damsel_handle dTagh;
67 TagType tagType;
68 };
69
70 template < class T >
71 struct MtagP
72 {
73
74 typedef T argument_type;
75 typedef bool result_type;
76
77 public:
78 MtagP( const Tag& th )
79 {
80 tH = th;
81 }
82 bool operator()( const T& tclass )
83 {
84 return tclass.mTagh == tH;
85 }
86 Tag tH;
87 };
88
89 template < class T >
90 struct DtagP
91 {
92
93 typedef T argument_type;
94 typedef bool result_type;
95
96 public:
97 DtagP( const damsel_handle& th )
98 {
99 tH = th;
100 }
101 bool operator()( const T& tclass )
102 {
103 return tclass.dTagh == tH;
104 }
105 damsel_handle tH;
106 };
107
108 private:
109
110 damsel_library dmslLib;
111
112
113 damsel_model dmslModel;
114
115
116 tinfo xcoordsTag, ycoordsTag, zcoordsTag, collFlagsTag, parentsTag, childrenTag;
117
118
119 std::vector< tinfo > tagMap;
120
121
122 damsel_handle_type moabHandleType;
123 };
124
125
126
127 static inline ErrorCode error( ErrorCode rval )
128 {
129 return rval;
130 }
131
132 }
133
134 #endif