3from .Attribute
import Attribute
4from .Integer
import Integer
15 qualifier=Attribute.Qualifier.NONE,
18 if qualifier != Attribute.Qualifier.NONE:
19 raise NotImplementedError(
20 f
"Attribute {name}: This data type can't work with qualifiers (yet)"
22 if initval
is not None:
23 raise NotImplementedError(
24 f
"Attribute {name}: Can't generate arrays with initial values (yet)."
27 self, name, ifdefs=ifdefs, qualifier=qualifier, initval=initval
32 self.
compress = min_value !=
None or max_value !=
None
37 Cannot use the default copy constructor, as it is an array,
38 i.e. we need some manual deep copying.
43 def get_methods(self, _full_qualified_class_name, for_declaration=True):
44 accessor_name = self.
_name[:1].title() + self.
_name[1:]
46 (
"get" + accessor_name +
"() const",
"const int*"),
48 "set" + accessor_name +
"(const int value[" + self.
_cardinality +
"])",
51 (
"get" + accessor_name +
"(int index) const",
"int"),
52 (
"set" + accessor_name +
"(int index, int value)",
"void"),
61 "[[clang::pack_range("
72 return [(
"_" + self.
_name +
"[0]",
"int")]
76 name =
" _dataStore._" + self.
_name
78 name =
" _" + self.
_name
79 if signature.startswith(
"get")
and "index" in signature:
80 return " return " + name +
"[index];\n"
81 elif signature.startswith(
"set")
and "index" in signature:
82 return name +
"[index] = value;\n"
83 elif signature.startswith(
"get"):
84 return " return " + name +
";\n"
85 elif signature.startswith(
"set"):
86 return " std::copy_n(value, " + self.
_cardinality +
", " + name +
" );\n"
97 Return string representation of attribute.
101 return "_dataStore._" + self.
_name +
'[0] << ",..."'
103 return "_" + self.
_name +
'[0] << ",..."'
get_method_body(self, signature)
I hand in the method signature (see get_methods()) and wanna get the whole implementation.
get_to_string(self)
Return string representation of attribute.
get_methods(self, _full_qualified_class_name, for_declaration=True)
Return sequence of methods that are defined for this attribute.
__init__(self, name, cardinality, min_value=None, max_value=None, ifdefs=[], qualifier=Attribute.Qualifier.NONE, initval=None)
min_value: None or integer value Has to be smaller than max_value.
get_plain_C_attributes(self, for_constructor=False)
Return list of n-tuples.
get_native_MPI_type(self)
Return native (built-in) MPI datatype.
get_first_plain_C_attribute(self)
For MPI for example, I need to know the first attribute.
use_default_copy_constructor(self)
Cannot use the default copy constructor, as it is an array, i.e.