Node mapper using QtScript to return a value for a node.
#include <Mesh/DataStructures/nodescriptmapper.h>
◆ NodeScriptMapper() [1/2]
◆ NodeScriptMapper() [2/2]
◆ ~NodeScriptMapper()
◆ clone()
- Returns
- A clone of this object.
- Note
- Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.
Implements NodeMapper.
◆ createMementoData()
- Parameters
-
model | The model that will be used for mapping nodes to values. |
- Returns
- A memento object which client code cannot do anything useful with except pass it around. The memento is ultimately only useful to the getValue() function. It holds internal data the mapper will use to perform the required mapping.
Implements NodeMapper.
◆ getFunctionName()
const QString & getFunctionName |
( |
| ) |
const |
- Returns
- The name of the function that will be called to map each node to a value.
The default function name is an empty string, however the convention is to use mapToValue
as the function name. The default is empty because it allows the script contents to be as trivial as possible. See setFunctionName() for more details on this issue.
- See also
- setFunctionName()
◆ getScript()
const QString & getScript |
( |
| ) |
const |
- Returns
- The script being used by the mapper.
- See also
- setScript()
◆ getValue()
- Parameters
-
node | The node for which a mapped value is required. |
mementoData | The data from the memento created by a previous call to createMementoData(). It is used internally by this function to work out what value needs to be returned. |
- Returns
- The value for the requested node. If mementoData is invalid, which can happen if the script for this mapper generates an exception, this function returns 0.
Implements NodeMapper.
◆ operator=()
◆ setFunctionName()
void setFunctionName |
( |
const QString & |
functionName | ) |
|
- Parameters
-
functionName | The name of the function to call to map each node to a value. |
The functionName should refer to a valid function defined in the script provided to the mapper. If it does not, an error will occur and the mapper will fail (and therefore return 0 for all values). The one exception to this is if functionName is empty. In this case, the contents of the script are assumed to be just the body of a function and the mapper should wrap it in its own function. This is not as clear, since the script still needs to have return statements but the script itself won't show what is being returned from. Still, some users may find this "feature" useful if their script contents are more or less trivial.
- See also
- getFunctionName()
◆ setScript()
void setScript |
( |
const QString & |
script | ) |
|
- Parameters
-
script | The script to use for the mapper. |
- See also
- getScript()