source: XIOS/trunk/src/declare_attribute.hpp @ 775

Last change on this file since 775 was 775, checked in by mhnguyen, 8 years ago

Implementing the reading of attributes of an axis from a file

+) 3d grid can be read directly from a file
+) Clean some redundant codes
+) Add new attribute declaration that allows to output only desired attributes

Test
+) On Curie
+) test_remap passes and result is correct

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 9.9 KB
Line 
1#ifndef __XIOS_DECLARE_ATTRIBUTE__
2#define __XIOS_DECLARE_ATTRIBUTE__
3
4/// ///////////////////////////// Macros ///////////////////////////// ///
5#define DECLARE_ATTRIBUTE(type, name)                             \
6   class name##_attr : public CAttributeTemplate<type>            \
7   {                                                              \
8      public :                                                    \
9         name##_attr(void)                                          \
10            : CAttributeTemplate<type>                            \
11            (#name, *CAttributeMap::Current)                      \
12         { /* Ne rien faire de plus */ }                          \
13         type operator=(const type & value)                       \
14         { return (CAttributeTemplate<type>::operator=(value)); } \
15         virtual ~name##_attr(void)                                 \
16         { /* Ne rien faire de plus */ }                          \
17   } name;
18
19#define DECLARE_ATTRIBUTE_PRIVATE(type, name)                    \
20   class name##_attr : public CAttributeTemplate<type>           \
21   {                                                              \
22      public :                                                    \
23         name##_attr(void)                                          \
24            : CAttributeTemplate<type>                            \
25            (#name, *CAttributeMap::Current)                      \
26         { /* Ne rien faire de plus */ }                          \
27         type operator=(const type & value)                       \
28         { return (CAttributeTemplate<type>::operator=(value)); } \
29         virtual bool isAttributePublic()                         \
30         { return false; }                                        \
31         virtual ~name##_attr(void)                               \
32         { /* Ne rien faire de plus */ }                          \
33   } name;
34
35#define DECLARE_ARRAY(T_num, T_rank, name)                        \
36   class name##_attr : public CAttributeArray<T_num, T_rank>      \
37   {                                                              \
38      public :                                                    \
39         using CAttributeArray<T_num, T_rank>::operator = ;       \
40         name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \
41         virtual ~name##_attr(void) {}                            \
42   } name;
43
44#define DECLARE_ARRAY_PRIVATE(T_num, T_rank, name)                        \
45   class name##_attr : public CAttributeArray<T_num, T_rank>      \
46   {                                                              \
47      public :                                                    \
48         using CAttributeArray<T_num, T_rank>::operator = ;       \
49         name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \
50         virtual bool isAttributePublic()                         \
51         { return false; }                                        \
52         virtual ~name##_attr(void) {}                            \
53   } name;
54
55#define DECLARE_CLASS_ENUM(name)                                   \
56   class name##_attr : public CAttributeEnum<Enum_##name>          \
57   {                                                              \
58      public :                                                    \
59         name##_attr(void) : CAttributeEnum<Enum_##name>(#name, *CAttributeMap::Current) { } \
60         virtual ~name##_attr(void) {}                           \
61   } name;
62
63#define DECLARE_ENUM2(name,arg1,arg2)                             \
64   class Enum_##name                                              \
65   {                                                              \
66     public:                                                      \
67     enum t_enum { arg1=0, arg2} ;                                \
68     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2 } ; return enumStr ; }   \
69     int getSize(void) const { return 2 ; }                       \
70   } ;                                                            \
71   DECLARE_CLASS_ENUM(name)
72
73#define DECLARE_ENUM3(name,arg1,arg2,arg3)                             \
74   class Enum_##name                                              \
75   {                                                              \
76     public:                                                      \
77     enum t_enum { arg1=0, arg2, arg3} ;                                \
78     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3 } ; return enumStr ; }   \
79     int getSize(void) const { return 3 ; }                       \
80   } ;                                                            \
81   DECLARE_CLASS_ENUM(name)
82
83#define DECLARE_ENUM4(name,arg1,arg2,arg3,arg4)                             \
84   class Enum_##name                                              \
85   {                                                              \
86     public:                                                      \
87     enum t_enum { arg1=0, arg2, arg3,arg4} ;                                \
88     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4 } ; return enumStr ; }   \
89     int getSize(void) const { return 4 ; }                       \
90   } ;                                                            \
91   DECLARE_CLASS_ENUM(name)
92
93#define DECLARE_ENUM5(name,arg1,arg2,arg3,arg4,arg5)                             \
94   class Enum_##name                                              \
95   {                                                              \
96     public:                                                      \
97     enum t_enum { arg1=0, arg2, arg3,arg4,arg5} ;                                \
98     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5 } ; return enumStr ; }   \
99     int getSize(void) const { return 5 ; }                       \
100   } ;                                                            \
101   DECLARE_CLASS_ENUM(name)
102
103#define DECLARE_ENUM6(name,arg1,arg2,arg3,arg4,arg5,arg6)                             \
104   class Enum_##name                                              \
105   {                                                              \
106     public:                                                      \
107     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6} ;                                \
108     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6 } ; return enumStr ; }   \
109     int getSize(void) const { return 6 ; }                       \
110   } ;                                                            \
111   DECLARE_CLASS_ENUM(name)
112
113#define DECLARE_ENUM7(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7)                             \
114   class Enum_##name                                              \
115   {                                                              \
116     public:                                                      \
117     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7} ;                                \
118     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7 } ; return enumStr ; }   \
119     int getSize(void) const { return 7 ; }                       \
120   } ;                                                            \
121   DECLARE_CLASS_ENUM(name)
122
123#define DECLARE_ENUM8(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)                             \
124   class Enum_##name                                              \
125   {                                                              \
126     public:                                                      \
127     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8} ;                                \
128     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7,#arg8 } ; return enumStr ; }   \
129     int getSize(void) const { return 8 ; }                       \
130   } ;                                                            \
131   DECLARE_CLASS_ENUM(name)
132
133  #define DECLARE_ENUM9(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)                             \
134   class Enum_##name                                              \
135   {                                                              \
136     public:                                                      \
137     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8,arg9} ;                                \
138     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7,#arg8,#arg9 } ; return enumStr ; }   \
139     int getSize(void) const { return 9 ; }                       \
140   } ;                                                            \
141   DECLARE_CLASS_ENUM(name)
142
143  #define DECLARE_TYPE(name)                                      \
144   class Enum_##name                                              \
145   {                                                              \
146     public:                                                      \
147     enum t_enum { t_bool=0, t_int16, t_int, t_int32, t_int64, t_float, t_double, t_string }; \
148     const char** getStr(void) const { static const char * enumStr[] = { "bool", "int16", "int", "int32", "int64", "float", "double", "string" }; return enumStr; } \
149     int getSize(void) const { return 8; }                        \
150   };                                                             \
151   DECLARE_CLASS_ENUM(name)
152
153#define BEGIN_DECLARE_ATTRIBUTE_MAP(type)                  \
154   class type##Attributes : public virtual CAttributeMap   \
155   {                                                       \
156      public :
157
158#define END_DECLARE_ATTRIBUTE_MAP(type)            \
159         type##Attributes (void) : CAttributeMap() \
160         { /* Ne rien faire de plus */ }           \
161         virtual ~type##Attributes (void)          \
162         { /* Ne rien faire de plus */ }           \
163   };
164
165#endif // __XIOS_DECLARE_ATTRIBUTE__
Note: See TracBrowser for help on using the repository browser.