88 Finally construct the output
90 Pass in an instance of the output object. We use this output
91 object only to register the generated C++ file with the build
92 environment. This part is exactly the same as for a plain 1:1
95 Further to the default generator, this routine does a little bit
98 - Make a deep copy of the data object and replace each instance of
99 a smart pointer with its plain counterpart. This new data object
100 is identified by the extension _Flattened.
101 - Make the new helper data structure include the original class with
103 - Declare this one as an embedded type via using.
104 - Add a new copy constructor/conversion routine which really just maps
105 the two data types onto each other by using the setters and getters.
106 - Replace the MPI aspect in the original object with an with the
107 variant for smart pointers
110 full_qualified_name =
""
111 for i
in self.
_data.namespace:
112 full_qualified_name += i
113 full_qualified_name +=
"::"
114 full_qualified_name += self.
_data.name
116 print(
"No of aspects for {}: {}".format( full_qualified_name, len(self.
_data.data._aspects) ))
119 flattened_data_object = copy.copy(self.
_data.data)
120 old_attributes = self.
_data.data._attributes
121 old_aspects = flattened_data_object._aspects
122 flattened_data_object._attributes = []
123 self.
_data.data._aspects = []
124 for attribute
in old_attributes:
127 cardinality = attribute._cardinality,
128 ifdefs = attribute.ifdefs
131 flattened_data_object._attributes.append( attribute )
133 for aspect
in old_aspects:
137 self.
_data.peano4_mpi_and_storage_aspect = aspect
138 self.
_data.data._aspects.append( self.
_data.peano4_mpi_and_storage_aspect )
140 self.
_data.data._aspects.append( aspect )
142 extension =
"_Flattened"
143 full_qualified_name_flattened = full_qualified_name + extension
144 full_qualified_file_without_extension_flattened = self.
_data.subdirectory + self.
_data.namespace[-1] +
"/" + self.
_data.name + extension
146 self.
_data.data.set_full_qualified_name(full_qualified_name)
147 self.
_data.data.write_header_file( self.
_data.subdirectory + self.
_data.namespace[-1] +
"/" + self.
_data.name +
".h" )
148 self.
_data.data.write_implementation_file( self.
_data.subdirectory + self.
_data.namespace[-1] +
"/" + self.
_data.name +
".cpp" )
149 output.makefile.add_cpp_file( self.
_data.subdirectory + self.
_data.namespace[-1] +
"/" + self.
_data.name +
".cpp", generated=
True )
151 flattened_data_object.set_full_qualified_name(full_qualified_name_flattened)
152 flattened_data_object.write_header_file( full_qualified_file_without_extension_flattened +
".h" )
153 flattened_data_object.write_implementation_file( full_qualified_file_without_extension_flattened +
".cpp" )
154 output.makefile.add_cpp_file( full_qualified_file_without_extension_flattened +
".cpp", generated=
True )