3from .Attribute
import Attribute
9 Wrapper around C++ enumerations which is not a datatype supported
12 The attribute has two-fold meaning. It defines a enum class subtype
13 within the generated code and it creates a new attribute of this
19 Something that can become a C++ identifier
22 Sequence of strings. The strings have to be something C++ accepts
23 as enumeration identifiers.
32 qualifier=Attribute.Qualifier.NONE,
35 if qualifier != Attribute.Qualifier.NONE:
36 raise NotImplementedError(
37 f
"Attribute {name}: This data type can't work with qualifiers"
40 self, name, ifdefs=ifdefs, qualifier=qualifier, initval=initval
68 def get_methods(self, _full_qualified_name, for_declaration=True):
71 toStringQualifier =
""
73 toStringQualifier =
"static"
77 "get" + accessor_name +
"() const",
78 _full_qualified_name +
"::" + accessor_name,
80 (
"set" + accessor_name +
"(" + accessor_name +
" value)",
"void"),
83 "toString(" + accessor_name +
" value)",
84 toStringQualifier +
" std::string",
96 return " return _dataStore._" + self.
_name_name +
";\n"
98 return " _dataStore._" + self.
_name_name +
" = value;\n"
103 elif signature.startswith(
"toString")
and not self.
use_data_store:
110 return [(
"MPI_INT", 1)]
114 This function generates the method body for the toString(value)
115 method. The idea is to have an easy way to access enum variants as
116 strings for meaningful printouts, such as in the yourDataModel.toString()
119 For developing and debugging purposes, it can be useful to have a way
120 of accessing these names, so this method gets a standalone definition.
122 result =
" std::ostringstream out;\n out "
126 result +=
"(value =="
134 result +=
" return out.str();\n"
140 This function generates the method body which is called in
141 yourDataModel.toString() method.
144 varname =
"_" + self.
name
148 return "toString(" + varname +
")"
Represents one attribute.
get_accessor_name(self)
Generate the accessor name used throughout dastgen2 to create variables, function names,...
name(self)
I expect that there's at least one setter/getter pair.
Wrapper around C++ enumerations which is not a datatype supported natively by MPI.
__init__(self, name, variants, ifdefs=[], qualifier=Attribute.Qualifier.NONE, initval=None)
name: String This is a plain string which has to follow the C++ naming conventions,...
_get_to_string_method_body(self)
This function generates the method body for the toString(value) method.
get_public_fields(self)
Return string that is to be embedded into the public part of the class definition.
get_native_MPI_type(self)
Return native (built-in) MPI datatype.
get_plain_C_attributes(self, for_constructor=False)
Return list of n-tuples.
get_methods(self, _full_qualified_name, for_declaration=True)
Return sequence of methods that are defined for this attribute.
get_to_string(self)
This function generates the method body which is called in yourDataModel.toString() method.
get_method_body(self, signature)
I hand in the method signature (see get_methods()) and wanna get the whole implementation.