source: XIOS/dev/dev_olga/src/declare_attribute.hpp @ 1077

Last change on this file since 1077 was 1025, checked in by mhnguyen, 7 years ago

Merging working version of coupler

+) Add some changes of domain and axis: Retransfer the atttributes in a generic ways for each level of client (or server)
+) Remove some spoiled files from the previous commits

Test
+) No test

  • 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: 10.5 KB
RevLine 
[591]1#ifndef __XIOS_DECLARE_ATTRIBUTE__
2#define __XIOS_DECLARE_ATTRIBUTE__
[219]3
4/// ///////////////////////////// Macros ///////////////////////////// ///
[1025]5#define DECLARE_ATTRIBUTE(type, name, ...)                        \
[369]6   class name##_attr : public CAttributeTemplate<type>            \
7   {                                                              \
[219]8      public :                                                    \
[1025]9         name##_attr(void)                                        \
[219]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)); } \
[1025]15         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \
16         bool helper(bool returnTrue=true) const { return returnTrue; }   \
17         virtual ~name##_attr(void)                               \
[219]18         { /* Ne rien faire de plus */ }                          \
19   } name;
20
[1025]21#define DECLARE_ATTRIBUTE_PRIVATE(type, name, ...)                \
22   class name##_attr : public CAttributeTemplate<type>            \
[775]23   {                                                              \
24      public :                                                    \
[1025]25         name##_attr(void)                                        \
[775]26            : CAttributeTemplate<type>                            \
27            (#name, *CAttributeMap::Current)                      \
28         { /* Ne rien faire de plus */ }                          \
29         type operator=(const type & value)                       \
30         { return (CAttributeTemplate<type>::operator=(value)); } \
[778]31         virtual bool isPublic() const                            \
[775]32         { return false; }                                        \
[1025]33         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \
34         bool helper(bool returnTrue=true) const { return returnTrue; }   \
[775]35         virtual ~name##_attr(void)                               \
36         { /* Ne rien faire de plus */ }                          \
37   } name;
38
[1025]39#define DECLARE_ARRAY(T_num, T_rank, name, ...)                   \
[369]40   class name##_attr : public CAttributeArray<T_num, T_rank>      \
41   {                                                              \
42      public :                                                    \
[415]43         using CAttributeArray<T_num, T_rank>::operator = ;       \
[369]44         name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \
[1025]45         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \
46         bool helper(bool returnTrue=true) const { return returnTrue; }   \
[369]47         virtual ~name##_attr(void) {}                            \
[219]48   } name;
[775]49
[1025]50#define DECLARE_ARRAY_PRIVATE(T_num, T_rank, name, ...)           \
[775]51   class name##_attr : public CAttributeArray<T_num, T_rank>      \
52   {                                                              \
53      public :                                                    \
54         using CAttributeArray<T_num, T_rank>::operator = ;       \
55         name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \
[778]56         virtual bool isPublic() const                            \
[775]57         { return false; }                                        \
[1025]58         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \
59         bool helper(bool returnTrue=true) const { return returnTrue; }   \
[775]60         virtual ~name##_attr(void) {}                            \
61   } name;
62
[1025]63#define DECLARE_CLASS_ENUM(name, ...)                             \
64   class name##_attr : public CAttributeEnum<Enum_##name>         \
[369]65   {                                                              \
66      public :                                                    \
67         name##_attr(void) : CAttributeEnum<Enum_##name>(#name, *CAttributeMap::Current) { } \
[1025]68         virtual bool doSend() const { return helper(## __VA_ARGS__); }   \
69         bool helper(bool returnTrue=true) const { return returnTrue; }   \
70         virtual ~name##_attr(void) {}                            \
[369]71   } name;
[775]72
[369]73#define DECLARE_ENUM2(name,arg1,arg2)                             \
74   class Enum_##name                                              \
75   {                                                              \
76     public:                                                      \
77     enum t_enum { arg1=0, arg2} ;                                \
78     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2 } ; return enumStr ; }   \
79     int getSize(void) const { return 2 ; }                       \
80   } ;                                                            \
81   DECLARE_CLASS_ENUM(name)
[775]82
[1025]83#define DECLARE_ENUM3(name,arg1,arg2,arg3)                        \
[369]84   class Enum_##name                                              \
85   {                                                              \
86     public:                                                      \
[1025]87     enum t_enum { arg1=0, arg2, arg3} ;                          \
[369]88     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3 } ; return enumStr ; }   \
89     int getSize(void) const { return 3 ; }                       \
90   } ;                                                            \
91   DECLARE_CLASS_ENUM(name)
[219]92
[1025]93#define DECLARE_ENUM4(name,arg1,arg2,arg3,arg4)                   \
[369]94   class Enum_##name                                              \
95   {                                                              \
96     public:                                                      \
[1025]97     enum t_enum { arg1=0, arg2, arg3,arg4} ;                     \
[369]98     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4 } ; return enumStr ; }   \
99     int getSize(void) const { return 4 ; }                       \
100   } ;                                                            \
101   DECLARE_CLASS_ENUM(name)
102
[1025]103#define DECLARE_ENUM5(name,arg1,arg2,arg3,arg4,arg5)              \
[369]104   class Enum_##name                                              \
105   {                                                              \
106     public:                                                      \
[1025]107     enum t_enum { arg1=0, arg2, arg3,arg4,arg5} ;                \
[369]108     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5 } ; return enumStr ; }   \
109     int getSize(void) const { return 5 ; }                       \
110   } ;                                                            \
111   DECLARE_CLASS_ENUM(name)
112
[1025]113#define DECLARE_ENUM6(name,arg1,arg2,arg3,arg4,arg5,arg6)         \
[369]114   class Enum_##name                                              \
115   {                                                              \
116     public:                                                      \
[1025]117     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6} ;           \
[369]118     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6 } ; return enumStr ; }   \
119     int getSize(void) const { return 6 ; }                       \
120   } ;                                                            \
121   DECLARE_CLASS_ENUM(name)
122
[1025]123#define DECLARE_ENUM7(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7)    \
[369]124   class Enum_##name                                              \
125   {                                                              \
126     public:                                                      \
[1025]127     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7} ;      \
[369]128     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7 } ; return enumStr ; }   \
129     int getSize(void) const { return 7 ; }                       \
130   } ;                                                            \
131   DECLARE_CLASS_ENUM(name)
132
133#define DECLARE_ENUM8(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)                             \
134   class Enum_##name                                              \
135   {                                                              \
136     public:                                                      \
[1025]137     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8} ; \
[369]138     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7,#arg8 } ; return enumStr ; }   \
139     int getSize(void) const { return 8 ; }                       \
140   } ;                                                            \
141   DECLARE_CLASS_ENUM(name)
142
143  #define DECLARE_ENUM9(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)                             \
144   class Enum_##name                                              \
145   {                                                              \
146     public:                                                      \
147     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8,arg9} ;                                \
148     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7,#arg8,#arg9 } ; return enumStr ; }   \
[522]149     int getSize(void) const { return 9 ; }                       \
[369]150   } ;                                                            \
[775]151   DECLARE_CLASS_ENUM(name)
[369]152
[527]153  #define DECLARE_TYPE(name)                                      \
154   class Enum_##name                                              \
155   {                                                              \
156     public:                                                      \
157     enum t_enum { t_bool=0, t_int16, t_int, t_int32, t_int64, t_float, t_double, t_string }; \
158     const char** getStr(void) const { static const char * enumStr[] = { "bool", "int16", "int", "int32", "int64", "float", "double", "string" }; return enumStr; } \
159     int getSize(void) const { return 8; }                        \
160   };                                                             \
161   DECLARE_CLASS_ENUM(name)
[369]162
[219]163#define BEGIN_DECLARE_ATTRIBUTE_MAP(type)                  \
[369]164   class type##Attributes : public virtual CAttributeMap   \
165   {                                                       \
[219]166      public :
167
168#define END_DECLARE_ATTRIBUTE_MAP(type)            \
169         type##Attributes (void) : CAttributeMap() \
170         { /* Ne rien faire de plus */ }           \
171         virtual ~type##Attributes (void)          \
172         { /* Ne rien faire de plus */ }           \
173   };
174
[591]175#endif // __XIOS_DECLARE_ATTRIBUTE__
Note: See TracBrowser for help on using the repository browser.