Reference Guide
2.5.0
|
Public Member Functions | |
def | __new__ (cls, name) |
def | __call__ (self) |
Static Public Member Functions | |
def | init () |
This class implements a singleton that manages LFRic types. Using the 'call' interface, you can query the data type for LFRic types, e.g.: >>> from psyclone.configuration import Config >>> from psyclone.domain.lfric import LFRicTypes >>> config = Config.get() >>> num_dofs_class = LFRicTypes("NumberOfUniqueDofsDataSymbol") >>> my_var = num_dofs_class("my_num_dofs") >>> print(my_var.name) my_num_dofs It uses the __new__ function to implement the access to the internal dictionary. This is done to minimise the required code for getting a value, e. g. compared with ``LFRicTypes.get()("something")``, or ``LFRicType.get("something")``.
Definition at line 52 of file lfric_types.py.
def psyclone.domain.lfric.lfric_types.LFRicTypes.__call__ | ( | self | ) |
This function is only here to trick pylint into thinking that the object returned from __new__ is callable, meaning that code like: ``LFRicTypes("LFRicIntegerScalarDataType")()`` does not trigger a pylint warning about not being callable.
Definition at line 109 of file lfric_types.py.
def psyclone.domain.lfric.lfric_types.LFRicTypes.__new__ | ( | cls, | |
name | |||
) |
The class creation function __new__ is used to actually provide the object the user is querying. It is well documented that __new__ can return a different instance. This function will first make sure that the static internal dictionary is initialised (so it acts like a singleton in that regard). Then it will return the value the user asked for. :param str name: the name to query for. :returns: the corresponding object, which can be a class or an \ instance. :rtype: object (various types) :raises InternalError: if there specified name is not a name for \ an object managed here.
Definition at line 80 of file lfric_types.py.
|
static |
This method constructs the required classes and instances, and puts them into the dictionary.
Definition at line 118 of file lfric_types.py.
References psyclone.psyir.nodes.intrinsic_call.IntrinsicCall.intrinsic(), psyclone.psyir.symbols.datatypes.ScalarType.intrinsic, psyclone.psyir.symbols.datatypes.ArrayType.intrinsic(), and psyclone.psyir.symbols.intrinsic_symbol.IntrinsicSymbol.intrinsic().