Struct Reference
A reference to a hierarchical item.
Inherited Members
Namespace: SpiceSharp.Simulations.Base
Assembly: SpiceSharp.dll
Syntax
public readonly struct Reference : IEnumerable<string>, IEnumerable, IEquatable<Reference>
Constructors
Reference(string)
Creates a new Reference.
Declaration
public Reference(string node)
Parameters
| Type | Name | Description |
|---|---|---|
| string | node | The node name. |
Reference(params string[])
Creates a new Reference.
Declaration
public Reference(params string[] path)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | path | The path. |
Properties
this[int]
Gets an element of the hierarchical reference at the specified index.
Declaration
public string this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index. |
Property Value
| Type | Description |
|---|---|
| string | Returns the path item at the specified index. |
Length
Gets the length of the path.
Declaration
public int Length { get; }
Property Value
| Type | Description |
|---|---|
| int |
Path
Gets the path of the node.
Declaration
public IReadOnlyList<string> Path { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
Methods
Equals(Reference)
Determines whether the node reference is equal to another.
Declaration
public bool Equals(Reference other)
Parameters
| Type | Name | Description |
|---|---|---|
| Reference | other | The other node reference. |
Returns
| Type | Description |
|---|---|
| bool | Returns |
Equals(object)
Determines whether the object is equal to another.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The other object. |
Returns
| Type | Description |
|---|---|
| bool | Returns |
Overrides
GetContainer(ISimulation)
Gets the behavior container that the hierarchical reference points to.
Declaration
public IBehaviorContainer GetContainer(ISimulation simulation)
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulation | simulation | The simulation. |
Returns
| Type | Description |
|---|---|
| IBehaviorContainer | Returns the behavior container. |
Exceptions
| Type | Condition |
|---|---|
| BehaviorsNotFoundException | Thrown if a behavior collection could not be found. |
GetHashCode()
Calculates a hash code for the node reference.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
GetVariable<T, S>(ISimulation)
Gets the variable that the hierarchical reference points to.
Declaration
public IVariable<T> GetVariable<T, S>(ISimulation simulation) where S : ISolverSimulationState<T>
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulation | simulation | The simulation. |
Returns
| Type | Description |
|---|---|
| IVariable<T> | Returns the variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The variable return type. |
| S | The simulation state that needs to be used to find the variable. |
Exceptions
| Type | Condition |
|---|---|
| VariableNotFoundException | Thrown if the variable could not be found. |
| StateNotFoundException | Thrown if the simulation or entities behavior does not define the state. |
| BehaviorsNotFoundException | Thrown if a behavior collection could not be found. |
GetVectorElement<T, S>(ISimulation)
Gets the right-hand side vector element that relates to the node the hierarchical reference points to.
Declaration
public Element<T> GetVectorElement<T, S>(ISimulation simulation) where S : ISolverSimulationState<T>
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulation | simulation | The simulation. |
Returns
| Type | Description |
|---|---|
| Element<T> | Returns the variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The variable return type. |
| S | The simulation state that needs to be used to find the variable. |
Exceptions
| Type | Condition |
|---|---|
| VariableNotFoundException | Thrown if the variable could not be found. |
| StateNotFoundException | Thrown if the simulation or entities behavior does not define the state. |
| BehaviorsNotFoundException | Thrown if a behavior collection could not be found. |
ToString()
Converts the node reference to a string.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The string. |
Overrides
TryGetContainer(ISimulation, out IBehaviorContainer)
Tries to find a behavior container that the hierarchical reference points to.
Declaration
public bool TryGetContainer(ISimulation simulation, out IBehaviorContainer container)
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulation | simulation | The simulation. |
| IBehaviorContainer | container | The behavior container. |
Returns
| Type | Description |
|---|---|
| bool | Returns |
TryGetVariable<T, S>(ISimulation, out IVariable<T>)
Tries to find a variable that the hierarchical reference points to.
Declaration
public bool TryGetVariable<T, S>(ISimulation simulation, out IVariable<T> variable) where S : ISolverSimulationState<T>
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulation | simulation | The simulation. |
| IVariable<T> | variable | The variable. |
Returns
| Type | Description |
|---|---|
| bool | Returns |
Type Parameters
| Name | Description |
|---|---|
| T | The variable return type. |
| S | The simulation state used to find the variable. |
TryGetVectorElement<T, S>(ISimulation, out Element<T>)
Tries to find a right-hand side vector element that relates to the node the hierarchical reference points to.
Declaration
public bool TryGetVectorElement<T, S>(ISimulation simulation, out Element<T> variable) where S : ISolverSimulationState<T>
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulation | simulation | The simulation. |
| Element<T> | variable | The variable. |
Returns
| Type | Description |
|---|---|
| bool | Returns |
Type Parameters
| Name | Description |
|---|---|
| T | The variable return type. |
| S | The simulation state used to find the variable. |
Operators
implicit operator Reference(List<string>)
Implicitly converts a list of strings to a node reference.
Declaration
public static implicit operator Reference(List<string> path)
Parameters
| Type | Name | Description |
|---|---|---|
| List<string> | path | The path. |
Returns
| Type | Description |
|---|---|
| Reference |
implicit operator Reference(string)
Implicitly converts a string to a node reference.
Declaration
public static implicit operator Reference(string node)
Parameters
| Type | Name | Description |
|---|---|---|
| string | node | The node name. |
Returns
| Type | Description |
|---|---|
| Reference |
implicit operator Reference(string[])
Implicitly converts an array of strings to a node reference.
Declaration
public static implicit operator Reference(string[] path)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | path | The path. |
Returns
| Type | Description |
|---|---|
| Reference |