3from .Attribute
import Attribute
9 Wrapper around user-defined attribute
11 Wrapper around user-defined object, i.e. an instance of a proper class that
12 is not built into C++. At the moment, we support this only for static
13 attributes. On the one hand, having real object attributes which stem from
14 user code is tricky (are there appropriate to string methods, appropriate
15 constructors) for a "normal", serial code. It becomes close to impossible
16 to map complex nested classes onto MPI. Therefore, this constraint to
27 qualifier=Attribute.Qualifier.NONE,
29 getter_returns_reference=True,
30 user_type_has_toString_method=True,
36 @param name Name of the attribute
38 @param type Fully qualified type of the attribute as string separated
41 @param include String which holds the include of the type
43 For all other attributes see superclass' constructor.
52 expose_in_header_file=qualifier == Attribute.Qualifier.CONSTEXPR,
61 qualifier == Attribute.Qualifier.STATIC
62 or qualifier == Attribute.Qualifier.CONST_STATIC
67 def get_methods(self, _full_qualified_class_name, for_declaration=True):
73 getter = (
"get" + accessor_name +
"()",
"static " + self.
_type +
"& ")
75 getter = (
"get" + accessor_name +
"()",
"static " + self.
_type)
77 getter = (
"get" + accessor_name +
"()", self.
_type +
"& ")
79 getter = (
"get" + accessor_name +
"()", self.
_type)
83 getter = (
"get" + accessor_name +
"()",
"static " + self.
_type +
"& ")
85 getter = (
"get" + accessor_name +
"()",
"static " + self.
_type)
87 getter = (
"get" + accessor_name +
"()", self.
_type +
"& ")
89 getter = (
"get" + accessor_name +
"()", self.
_type)
92 getter = (
"get" + accessor_name +
"() const",
"const " + self.
_type)
95 getter = (
"get" + accessor_name +
"() const",
"constexpr " + self.
_type)
99 getter = (
"get" + accessor_name +
"() const", self.
_type)
101 methods.append(getter)
111 (
"set" + accessor_name +
"(const " + self.
_type +
"& value)",
"void")
117 typestring = self.
_type
118 namestring =
"_" + self.
_name
122 typestring =
"inline static " + self.
_type
124 namestring +=
" = " + str(self.
_initval)
127 typestring =
"inline const static " + self.
_type
128 namestring +=
" = " + str(self.
_initval)
131 typestring =
"const " + self.
_type
132 namestring +=
" = " + str(self.
_initval)
135 typestring =
"constexpr static " + self.
_type
136 namestring +=
" = " + str(self.
_initval)
143 if self.
_initval is not None and not for_constructor:
144 namestring +=
" = " + str(self.
_initval)
146 return [(namestring, typestring,
"")]
150 return " return _dataStore._" + self.
_name +
";\n"
152 return " return _" + self.
_name +
";\n"
154 return " _dataStore._" + self.
_name +
" = value;\n"
156 return " _" + self.
_name +
" = value;\n"
164 I map the type onto a byte field,but it is not clear if this
165 actually works. At the moment, we do not use the MPI data
166 implicitly, as we support user-defined attributes if and only
167 if they are static. That is, we never exchange them as part of
168 an object. That is, at the moment this routine is kind of
172 return [(
"MPI_BYTE",
"sizeof(" + self.
_type +
")")]
177 Return string representation of attribute.
181 return "_dataStore._" + self.
_name +
".toString()"
183 return "_" + self.
_name +
".toString()"
185 return """ "<no toString() method>" """
Represents one attribute.
get_accessor_name(self)
Generate the accessor name used throughout dastgen2 to create variables, function names,...
Wrapper around user-defined attribute.
_getter_returns_reference
_user_type_has_toString_method
get_plain_C_attributes(self, for_constructor=False)
Return list of n-tuples.
get_to_string(self)
Return string representation of attribute.
__init__(self, name, type, include, ifdefs=[], qualifier=Attribute.Qualifier.NONE, initval=None, getter_returns_reference=True, user_type_has_toString_method=True)
Create attribute.
get_methods(self, _full_qualified_class_name, for_declaration=True)
Return sequence of methods that are defined for this attribute.
get_method_body(self, signature)
I hand in the method signature (see get_methods()) and wanna get the whole implementation.
get_native_MPI_type(self)
I map the type onto a byte field,but it is not clear if this actually works.