Class AlgorithmManager
Singleton class that uses reflection to manage all particle algorithms, providing an interface to access their names, generation methods and parameters.
Inheritance
Namespace: AS2
Assembly: .dll
Syntax
public class AlgorithmManager
Constructors
| Edit this page View SourceAlgorithmManager()
Declaration
private AlgorithmManager()
Fields
| Edit this page View SourceGenerator_Property
Declaration
private static readonly string Generator_Property
Field Value
Type | Description |
---|---|
string |
Init_Method
Declaration
private static readonly string Init_Method
Field Value
Type | Description |
---|---|
string |
Name_Property
Declaration
private static readonly string Name_Property
Field Value
Type | Description |
---|---|
string |
algorithms
Declaration
private Dictionary<string, AlgorithmManager.AlgorithmInfo> algorithms
Field Value
Type | Description |
---|---|
Dictionary<string, AlgorithmManager.AlgorithmInfo> |
excludedAlgorithms
A list of algorithm names that should be excluded from the system. These algorithms will be skipped during algorithm discovery and will not appear in the algorithm selection dropdown menu.
Declaration
private readonly List<string> excludedAlgorithms
Field Value
Type | Description |
---|---|
List<string> |
instance
Declaration
private static AlgorithmManager instance
Field Value
Type | Description |
---|---|
AlgorithmManager |
Properties
| Edit this page View SourceInstance
The singleton instance of this class.
Declaration
public static AlgorithmManager Instance { get; }
Property Value
Type | Description |
---|---|
AlgorithmManager |
Methods
| Edit this page View SourceCallStatusInfoMethod(string, int, ParticleSystem, Particle)
Call the status info method of the algorithm with the given name.
The index idx
must be the attribute's array
index as returned by GetStatusInfoMethods(string).
Declaration
public void CallStatusInfoMethod(string name, int idx, ParticleSystem system, Particle selectedParticle)
Parameters
Type | Name | Description |
---|---|---|
string | name | The string ID of the algorithm. |
int | idx | The array index of the status info method to call. |
ParticleSystem | system | The first parameter of the status info method. |
Particle | selectedParticle | The second parameter of the status info method. |
FindAlgorithm(string)
Tries to get the algorithm with the given name.
Declaration
private AlgorithmManager.AlgorithmInfo FindAlgorithm(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The string ID of the desired algorithm. |
Returns
Type | Description |
---|---|
AlgorithmManager.AlgorithmInfo | The record of the algorithm with name |
GetAlgorithmGenerationMethod(string)
Gets the name of the given algorithm's generation method.
Declaration
public string GetAlgorithmGenerationMethod(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The string ID of the algorithm. |
Returns
Type | Description |
---|---|
string | The name of the algorithm's generation method, if a record for this algorithm exists. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the algorithm is not known. |
GetAlgorithmNames()
Gets a list of all known algorithm names.
Declaration
public List<string> GetAlgorithmNames()
Returns
Type | Description |
---|---|
List<string> | A list containing the names of all algorithms. |
GetInitParameters(string)
Gets the parameters of the algorithm's Init
method.
Declaration
public ParameterInfo[] GetInitParameters(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The string ID of the algorithm. |
Returns
Type | Description |
---|---|
ParameterInfo[] | An array containing the parameters of the
algorithm's |
GetStatusInfoMethods(string)
Gets the status info attributes defined for the given algorithm.
Declaration
public StatusInfoAttribute[] GetStatusInfoMethods(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The string ID of the algorithm. |
Returns
Type | Description |
---|---|
StatusInfoAttribute[] | An array of status info attribute instances defined for the given algorithm. The attributes contain a name, a tooltip and a default auto-call value. Call these info methods using CallStatusInfoMethod(string, int, ParticleSystem, Particle) with the index from this array. |
Initialize(string, ParticleAlgorithm, object[])
Initializes the given algorithm with the given parameters
by calling its Init
method.
Declaration
public void Initialize(string name, ParticleAlgorithm algo, object[] parameters)
Parameters
Type | Name | Description |
---|---|---|
string | name | The string ID of the algorithm type. |
ParticleAlgorithm | algo | The algorithm instance to initialize. |
object[] | parameters | The parameters to be passed to the
|
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the algorithm is not known. |
Instantiate(string, Particle)
Creates a new instance of the given algorithm for the given particle.
Declaration
public ParticleAlgorithm Instantiate(string name, Particle particle)
Parameters
Type | Name | Description |
---|---|---|
string | name | The string ID of the algorithm. |
Particle | particle | The particle that shall be controlled by the algorithm. |
Returns
Type | Description |
---|---|
ParticleAlgorithm | A new instance of the specified algorithm. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the algorithm is not known. |
IsAlgorithmKnown(string)
Checks if the given algorithm name is known.
Declaration
public bool IsAlgorithmKnown(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The string ID to check. |
Returns
Type | Description |
---|---|
bool |
|