Defines a class to manipulate State objects.
#include <Mesh/DataStructures/statecontrol.h>
|
| StateControl () |
|
virtual | ~StateControl ()=default |
|
void | addIntegerState (const QString &name, long defaultVal=0) |
|
void | AddIntegerState (const QString &name, long defaultVal=0) |
|
void | addScalarState (const QString &name, double defaultVal=0) |
|
void | AddScalarState (const QString &name, double defaultVal=0) |
|
void | addVectorState (const QString &name, const Vector3d &defaultVal=Vector3d()) |
|
void | AddVectorState (const QString &name, const Vector3d &defaultVal=Vector3d()) |
|
void | assignDefaultState (State &object) const |
|
void | AssignDefaultState (State &object) const |
|
void | copyOnReallocateOff () |
|
void | CopyOnReallocateOff () |
|
void | copyOnReallocateOn () |
|
void | CopyOnReallocateOn () |
|
void | CopyWholeState (const State &object0, State &object1) const |
|
void | copyWholeState (const State &stateFrom, State &stateTo) const |
|
void | EnsureAllStatesSupported (const StateInfoArray &stateNames) |
|
void | ensureAllStatesSupported (const StateInfoArray &states) |
|
StateInfoArray | getAllStateInfo () const |
|
StateInfoArray | GetAllStateInfo () const |
|
bool | getInitStates () const |
|
bool | GetInitStates () const |
|
int | getStateIndex (const QString &stateName) const |
|
int | GetStateIndex (const QString &stateName) const |
|
NameIndexMap | getStateIndices () const |
|
NameIndexMap | GetStateIndices () const |
|
void | getStateIndices (NameIndexMap &stateIndices) const |
|
void | GetStateIndices (NameIndexMap &stateIndices) const |
|
StateInfo | getStateInfo (const QString &stateName) const |
|
StateInfo | GetStateInfo (const QString &stateName) const |
|
bool | haveState (const QString &name) const |
|
bool | HaveState (const QString &name) const |
|
void | InterpolateWholeState (const State &object0, const State &object1, State &interpObject, double p) const |
|
void | interpolateWholeState (const State &state0, const State &state1, const State &state2, const State &state3, State &interpState) const |
|
void | interpolateWholeState (const State &state0, const State &state1, State &interpState, double p) const |
|
void | makeStatesCompatible (const StateControl &states) |
|
void | reallocate () |
|
void | Reallocate () |
|
void | reallocationOff () |
|
void | ReallocationOff () |
|
void | reallocationOn () |
|
void | ReallocationOn () |
|
void | removeAllStates () |
|
void | RemoveAllStates () |
|
void | removeState (const QString &name) |
|
void | RemoveState (const QString &name) |
|
bool | renameState (const QString &from, const QString &to) |
|
bool | RenameState (const QString &from, const QString &to) |
|
void | setInitStates (bool b) |
|
void | SetInitStates (bool b) |
|
void | setInitStatesOff () |
|
void | SetInitStatesOff () |
|
void | setInitStatesOn () |
|
void | SetInitStatesOn () |
|
|
unsigned | getDoublesStateSize () const |
|
unsigned | getIntegerStateSize () const |
|
virtual void | resizeDoubles (const IndexMappings &mappings, const StateInfoArray &updatedStates, unsigned updatedDoublesStateSize)=0 |
|
template<typename IteratorT > |
void | resizeDoublesStates (IteratorT iterBegin, IteratorT iterEnd, const IndexMappings &mappings, const StateInfoArray &updatedStates, unsigned updatedDoublesStateSize) |
|
virtual void | resizeIntegers (const IndexMappings &mappings, const StateInfoArray &updatedStates, unsigned updatedIntegerStateSize)=0 |
|
template<typename IteratorT > |
void | resizeIntegerStates (IteratorT iterBegin, IteratorT iterEnd, const IndexMappings &mappings, const StateInfoArray &updatedStates, unsigned updatedIntegerStateSize) |
|
|
(Note that these are not member functions.)
|
typedef std::map< QString, unsigned > | NameIndexMap |
|
◆ StateControl()
The default constructor creates a StateControl object that will initialise the state of every new stateful object created. It will also copy states whenever they are reallocated. These two features ensure that no information is ever lost or uninitialised by default.
◆ ~StateControl()
◆ addIntegerState()
void addIntegerState |
( |
const QString & |
name, |
|
|
long |
defaultVal = 0 |
|
) |
| |
- Parameters
-
name | The name of the state to add or modify. |
defaultVal | The value to assign to this part of the state for any new stateful object. |
This function can be called more than once with the same value for name. This would make sense only if you wanted to change the default value, since there is no other effect when calling this with name set to an existing state. Note that it is the caller's responsibility to ensure that an existing state with the same name is also the same type.
The states will usually be reallocated automatically unless ReallocationOff() has been called (reallocation will then be triggered when ReallocationOn() is called).
◆ AddIntegerState()
void AddIntegerState |
( |
const QString & |
name, |
|
|
long |
defaultVal = 0 |
|
) |
| |
|
inline |
◆ addScalarState()
void addScalarState |
( |
const QString & |
name, |
|
|
double |
defaultVal = 0 |
|
) |
| |
- Parameters
-
name | The name of the state to add or modify. |
defaultVal | The value to assign to this part of the state for any new stateful object. |
This function can be called more than once with the same value for name. This would make sense only if you wanted to change the default value, since there is no other effect when calling this with name set to an existing state. Note that it is the caller's responsibility to ensure that an existing state with the same name is also the same type.
The states will usually be reallocated automatically unless ReallocationOff() has been called (reallocation will then be triggered when ReallocationOn() is called).
◆ AddScalarState()
void AddScalarState |
( |
const QString & |
name, |
|
|
double |
defaultVal = 0 |
|
) |
| |
|
inline |
◆ addVectorState()
void addVectorState |
( |
const QString & |
name, |
|
|
const Vector3d & |
defaultVal = Vector3d() |
|
) |
| |
- Parameters
-
name | The name of the state to add or modify. |
defaultVal | The value to assign to this part of the state for any new stateful object. |
This function can be called more than once with the same value for name. This would make sense only if you wanted to change the default value, since there is no other effect when calling this with name set to an existing state. Note that it is the caller's responsibility to ensure that an existing state with the same name is also the same type.
The states will usually be reallocated automatically unless ReallocationOff() has been called (reallocation will then be triggered when ReallocationOn() is called).
◆ AddVectorState()
void AddVectorState |
( |
const QString & |
name, |
|
|
const Vector3d & |
defaultVal = Vector3d() |
|
) |
| |
|
inline |
◆ assignDefaultState()
void assignDefaultState |
( |
State & |
object | ) |
const |
Overwrite the current state for object with the default initialisation values.
◆ AssignDefaultState()
void AssignDefaultState |
( |
State & |
object | ) |
const |
|
inline |
◆ copyOnReallocateOff()
void copyOnReallocateOff |
( |
| ) |
|
|
inline |
Don't bother preserving state data when adding or removing names.
◆ CopyOnReallocateOff()
void CopyOnReallocateOff |
( |
| ) |
|
|
inline |
◆ copyOnReallocateOn()
void copyOnReallocateOn |
( |
| ) |
|
|
inline |
Preserve state data when adding or removing names. This is the default.
◆ CopyOnReallocateOn()
void CopyOnReallocateOn |
( |
| ) |
|
|
inline |
◆ CopyWholeState()
void CopyWholeState |
( |
const State & |
object0, |
|
|
State & |
object1 |
|
) |
| const |
|
inline |
◆ copyWholeState()
void copyWholeState |
( |
const State & |
stateFrom, |
|
|
State & |
stateTo |
|
) |
| const |
- Parameters
-
stateFrom | State to copy from. |
stateTo | State to copy into. |
This will copy scalar, vector and integer states.
◆ EnsureAllStatesSupported()
◆ ensureAllStatesSupported()
Ensure that every state in states is supported by this object. If new states are added as a result of this call, the usual reallocation mechanism is invoked. The states will be reallocated automatically unless ReallocationOff() has been called (reallocation will then be triggered when ReallocationOn() is called).
◆ getAllStateInfo()
- Returns
- An array of info for each state, whether scalar, vector or integer.
◆ GetAllStateInfo()
◆ getDoublesStateSize()
unsigned getDoublesStateSize |
( |
| ) |
const |
|
inlineprotected |
◆ getInitStates()
bool getInitStates |
( |
| ) |
const |
|
inline |
- Returns
- True if all the states for a new object are initialised to default values.
◆ GetInitStates()
bool GetInitStates |
( |
| ) |
const |
|
inline |
◆ getIntegerStateSize()
unsigned getIntegerStateSize |
( |
| ) |
const |
|
inlineprotected |
◆ getStateIndex()
int getStateIndex |
( |
const QString & |
stateName | ) |
const |
- Parameters
-
stateName | The name of the state for which to get the index. |
Note that two different states can have the same index. This is because the states are not all stored in the same array. The name of a state is sufficient to identify which array needs to be looked up internally.
- Returns
- The index into the state array of stateName, or -1 if stateName is not supported by the state.
◆ GetStateIndex()
int GetStateIndex |
( |
const QString & |
stateName | ) |
const |
|
inline |
◆ getStateIndices() [1/2]
- Returns
- A map of the state names and indices.
This function is merely a convenience wrapper around getStateIndices(NameIndexMap&)
◆ GetStateIndices() [1/2]
◆ getStateIndices() [2/2]
Compile a map of the state indices and store it in stateIndices. Any previous contents of stateIndices are discarded.
◆ GetStateIndices() [2/2]
◆ getStateInfo()
StateInfo getStateInfo |
( |
const QString & |
stateName | ) |
const |
- Parameters
-
stateName | The name of the state for which to get the info. |
- Returns
- The StateInfo for stateName. If stateName is not a state supported by this object, a valid StateInfo object is still returned, but it will return false for isDefined() and -1 for getIndex().
◆ GetStateInfo()
StateInfo GetStateInfo |
( |
const QString & |
stateName | ) |
const |
|
inline |
◆ haveState()
bool haveState |
( |
const QString & |
name | ) |
const |
- Returns
- True if there is already a state called name (this could be a scalar double, vector double or an integer).
◆ HaveState()
bool HaveState |
( |
const QString & |
name | ) |
const |
|
inline |
These functions have been renamed to conform to the coding standard. The only changes are that their new names have the first letter changed to lowercase and std::string has been replaced with CSIRO::String.
◆ InterpolateWholeState()
void InterpolateWholeState |
( |
const State & |
object0, |
|
|
const State & |
object1, |
|
|
State & |
interpObject, |
|
|
double |
p |
|
) |
| const |
|
inline |
◆ interpolateWholeState() [1/2]
void interpolateWholeState |
( |
const State & |
state0, |
|
|
const State & |
state1, |
|
|
const State & |
state2, |
|
|
const State & |
state3, |
|
|
State & |
interpState |
|
) |
| const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters
-
state0 | State at corner 0 of the quadrilateral. |
state1 | State at corner 1 of the quadrilateral. |
state2 | State at corner 2 of the quadrilateral (diagonally opposite state0). |
state3 | State at corner 3 of the quadrilateral (diagonally opposite state1). |
interpState | This will hold the state at the interpolation point at exit. |
This will perform a bilinear interpolation of the scalar and vector states with the assumption that state0, state1, state2, state3 are the corners of a quadrilateral. The interpolation point is assumed to be the centroid of the quadrilateral.
The integer states will be a copy of state0 rather than being interpolated.
◆ interpolateWholeState() [2/2]
void interpolateWholeState |
( |
const State & |
state0, |
|
|
const State & |
state1, |
|
|
State & |
interpState, |
|
|
double |
p |
|
) |
| const |
- Parameters
-
state0 | State at start of interpolation interval. |
state1 | State at end of interpolation interval. |
interpState | This will hold the state at the interpolation point at exit. |
p | The interpolation interval between state0 and state1. This should generally be in the range 0 to 1, with 0 resulting in interpState being the same as state0 and with 1 resulting in interpState being the same as state1. Values outside the range 0 to 1 will result in extrapolated values. |
This will interpolate the scalar and vector states between state0 and state1. The integer states will be a copy of one of the two states rather than being interpolated. If p < 0.5, integer states from state0 will be retained. Otherwise, those of state1 will be retained.
◆ makeStatesCompatible()
Make the states in this list have compatible state setup with states. No attempt is made to try to preserve any state information.
◆ reallocate()
Reallocate the state and integer data arrays for each object in the list as necessary. Clients do not need to call this directly. The StateControl class will call it whenever a state or integer data name is added or removed. Existing state data is preserved if possible, unless this has been explicitly turned off by a call to copyOnReallocateOff(). New states will have their data initialised unless this has been explicitly turned off by a call to setInitStatesOff().
Clients should call reallocationOn() rather than this function (it can safely be called repeatedly, even if reallocation is not currently turned off).
◆ Reallocate()
◆ reallocationOff()
Temporarily prevent reallocation when a state name is added or removed. You should call ReallocationOn() once you have finished manipulating the names, and it is critical that adding or removing names is the only thing you do between the two calls.
◆ ReallocationOff()
◆ reallocationOn()
Turn reallocation back on. If any names have been added or removed, calling this function will immediately trigger reallocation. If none have been added, no reallocation is performed.
◆ ReallocationOn()
◆ removeAllStates()
Remove all states. If reallocation is currently on, or when it is next turned on, all state arrays will be reduced to zero size.
◆ RemoveAllStates()
◆ removeState()
void removeState |
( |
const QString & |
name | ) |
|
- Parameters
-
name | The name of the state to remove. The type of the state (scalar, vector or integer) is determined automatically. |
The states will usually be reallocated automatically unless ReallocationOff() has been called (reallocation will then be triggered when ReallocationOn() is called).
◆ RemoveState()
void RemoveState |
( |
const QString & |
name | ) |
|
|
inline |
◆ renameState()
bool renameState |
( |
const QString & |
from, |
|
|
const QString & |
to |
|
) |
| |
- Parameters
-
from | The name of the state to change. |
to | The new name for the state. |
- Returns
- True if the state could be renamed. If from is not a current state or if to already exists as a state, this function will do nothing and return false. It will also return false and do nothing if there are any state changes scheduled (this can only occur if immediate reallocation is turned off and states have been added or removed).
◆ RenameState()
bool RenameState |
( |
const QString & |
from, |
|
|
const QString & |
to |
|
) |
| |
|
inline |
◆ resizeDoubles()
◆ resizeDoublesStates()
void resizeDoublesStates |
( |
IteratorT |
iterBegin, |
|
|
IteratorT |
iterEnd, |
|
|
const IndexMappings & |
mappings, |
|
|
const StateInfoArray & |
updatedStates, |
|
|
unsigned |
updatedDoublesStateSize |
|
) |
| |
|
inlineprotected |
◆ resizeIntegers()
◆ resizeIntegerStates()
void resizeIntegerStates |
( |
IteratorT |
iterBegin, |
|
|
IteratorT |
iterEnd, |
|
|
const IndexMappings & |
mappings, |
|
|
const StateInfoArray & |
updatedStates, |
|
|
unsigned |
updatedIntegerStateSize |
|
) |
| |
|
inlineprotected |
◆ setInitStates()
void setInitStates |
( |
bool |
b | ) |
|
|
inline |
If b is true, initialise all states to default values when a new object is created.
◆ SetInitStates()
void SetInitStates |
( |
bool |
b | ) |
|
|
inline |
◆ setInitStatesOff()
void setInitStatesOff |
( |
| ) |
|
|
inline |
When a new object is created, do not initialise any of its states to default values. This would generally only be used to improve performance when the states will shortly be explicitly filled with non-default values.
◆ SetInitStatesOff()
void SetInitStatesOff |
( |
| ) |
|
|
inline |
◆ setInitStatesOn()
When a new object is created, initialise all its states to default values.
◆ SetInitStatesOn()
◆ NameIndexMap
Convenience type for mapping a name to an index. For example, if you create a NameIndexMap object called myMap, then in C++ you would use it like so:
◆ initStates_