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

Last change on this file since 501 was 501, checked in by ymipsl, 9 years ago

Add licence copyright to all file ond directory src using the command :
svn propset -R copyright -F header_licence src

XIOS is now officialy under CeCILL licence

YM

  • 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: 7.7 KB
Line 
1#ifndef __XMLIO_DECLARE_ATTRIBUTE__
2#define __XMLIO_DECLARE_ATTRIBUTE__
3
4/// ///////////////////////////// Macros ///////////////////////////// ///
5
6#define DECLARE_ATTRIBUTE(type, name)                             \
7   class name##_attr : public CAttributeTemplate<type>            \
8   {                                                              \
9      public :                                                    \
10         name##_attr(void)                                          \
11            : CAttributeTemplate<type>                            \
12            (#name, *CAttributeMap::Current)                      \
13         { /* Ne rien faire de plus */ }                          \
14         type operator=(const type & value)                       \
15         { return (CAttributeTemplate<type>::operator=(value)); } \
16         virtual ~name##_attr(void)                                 \
17         { /* Ne rien faire de plus */ }                          \
18   } name;
19
20#define DECLARE_ARRAY(T_num, T_rank, name)                        \
21   class name##_attr : public CAttributeArray<T_num, T_rank>      \
22   {                                                              \
23      public :                                                    \
24         using CAttributeArray<T_num, T_rank>::operator = ;       \
25         name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \
26         virtual ~name##_attr(void) {}                            \
27   } name;
28   
29#define DECLARE_CLASS_ENUM(name)                                   \
30   class name##_attr : public CAttributeEnum<Enum_##name>          \
31   {                                                              \
32      public :                                                    \
33         name##_attr(void) : CAttributeEnum<Enum_##name>(#name, *CAttributeMap::Current) { } \
34         virtual ~name##_attr(void) {}                           \
35   } name;
36   
37#define DECLARE_ENUM2(name,arg1,arg2)                             \
38   class Enum_##name                                              \
39   {                                                              \
40     public:                                                      \
41     enum t_enum { arg1=0, arg2} ;                                \
42     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2 } ; return enumStr ; }   \
43     int getSize(void) const { return 2 ; }                       \
44   } ;                                                            \
45   DECLARE_CLASS_ENUM(name)
46   
47#define DECLARE_ENUM3(name,arg1,arg2,arg3)                             \
48   class Enum_##name                                              \
49   {                                                              \
50     public:                                                      \
51     enum t_enum { arg1=0, arg2, arg3} ;                                \
52     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3 } ; return enumStr ; }   \
53     int getSize(void) const { return 3 ; }                       \
54   } ;                                                            \
55   DECLARE_CLASS_ENUM(name)
56
57#define DECLARE_ENUM4(name,arg1,arg2,arg3,arg4)                             \
58   class Enum_##name                                              \
59   {                                                              \
60     public:                                                      \
61     enum t_enum { arg1=0, arg2, arg3,arg4} ;                                \
62     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4 } ; return enumStr ; }   \
63     int getSize(void) const { return 4 ; }                       \
64   } ;                                                            \
65   DECLARE_CLASS_ENUM(name)
66
67#define DECLARE_ENUM5(name,arg1,arg2,arg3,arg4,arg5)                             \
68   class Enum_##name                                              \
69   {                                                              \
70     public:                                                      \
71     enum t_enum { arg1=0, arg2, arg3,arg4,arg5} ;                                \
72     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5 } ; return enumStr ; }   \
73     int getSize(void) const { return 5 ; }                       \
74   } ;                                                            \
75   DECLARE_CLASS_ENUM(name)
76
77#define DECLARE_ENUM6(name,arg1,arg2,arg3,arg4,arg5,arg6)                             \
78   class Enum_##name                                              \
79   {                                                              \
80     public:                                                      \
81     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6} ;                                \
82     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6 } ; return enumStr ; }   \
83     int getSize(void) const { return 6 ; }                       \
84   } ;                                                            \
85   DECLARE_CLASS_ENUM(name)
86
87#define DECLARE_ENUM7(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7)                             \
88   class Enum_##name                                              \
89   {                                                              \
90     public:                                                      \
91     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7} ;                                \
92     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7 } ; return enumStr ; }   \
93     int getSize(void) const { return 7 ; }                       \
94   } ;                                                            \
95   DECLARE_CLASS_ENUM(name)
96
97#define DECLARE_ENUM8(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)                             \
98   class Enum_##name                                              \
99   {                                                              \
100     public:                                                      \
101     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8} ;                                \
102     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7,#arg8 } ; return enumStr ; }   \
103     int getSize(void) const { return 8 ; }                       \
104   } ;                                                            \
105   DECLARE_CLASS_ENUM(name)
106
107  #define DECLARE_ENUM9(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)                             \
108   class Enum_##name                                              \
109   {                                                              \
110     public:                                                      \
111     enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8,arg9} ;                                \
112     const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7,#arg8,#arg9 } ; return enumStr ; }   \
113     int getSize(void) const { return 8 ; }                       \
114   } ;                                                            \
115   DECLARE_CLASS_ENUM(name) 
116
117
118#define BEGIN_DECLARE_ATTRIBUTE_MAP(type)                  \
119   class type##Attributes : public virtual CAttributeMap   \
120   {                                                       \
121      public :
122
123#define END_DECLARE_ATTRIBUTE_MAP(type)            \
124         type##Attributes (void) : CAttributeMap() \
125         { /* Ne rien faire de plus */ }           \
126         virtual ~type##Attributes (void)          \
127         { /* Ne rien faire de plus */ }           \
128   };
129
130#endif // __XMLIO_DECLARE_ATTRIBUTE__
Note: See TracBrowser for help on using the repository browser.