Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MatrixType.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.Shaders.Ast
6 {
7  /// <summary>
8  /// Matrix type.
9  /// </summary>
10  public class MatrixType : GenericType<TypeBase, Literal, Literal>
11  {
12  #region Constructors and Destructors
13 
14  /// <summary>
15  /// Initializes a new instance of the <see cref = "MatrixType" /> class.
16  /// </summary>
17  public MatrixType()
18  : base("matrix")
19  {
20  }
21 
22  /// <summary>
23  /// Initializes a new instance of the <see cref="MatrixType"/> class.
24  /// </summary>
25  /// <param name="type">
26  /// The type.
27  /// </param>
28  /// <param name="rowCount">
29  /// The row count.
30  /// </param>
31  /// <param name="columnCount">
32  /// The column count.
33  /// </param>
34  public MatrixType(ScalarType type, int rowCount, int columnCount)
35  : this()
36  {
37  Type = type;
38  RowCount = rowCount;
39  ColumnCount = columnCount;
40  }
41 
42  #endregion
43 
44  #region Public Properties
45 
46  /// <summary>
47  /// Gets or sets the column count.
48  /// </summary>
49  /// <value>
50  /// The column count.
51  /// </value>
52  public int ColumnCount
53  {
54  get
55  {
56  return (int)((Literal)Parameters[2]).Value;
57  }
58 
59  set
60  {
61  Parameters[2] = new Literal(value);
62  }
63  }
64 
65  /// <summary>
66  /// Gets or sets the row count.
67  /// </summary>
68  /// <value>
69  /// The row count.
70  /// </value>
71  public int RowCount
72  {
73  get
74  {
75  return (int)((Literal)Parameters[1]).Value;
76  }
77 
78  set
79  {
80  Parameters[1] = new Literal(value);
81  }
82  }
83 
84  /// <summary>
85  /// Gets or sets the type.
86  /// </summary>
87  /// <value>
88  /// The type.
89  /// </value>
90  public TypeBase Type
91  {
92  get
93  {
94  return (TypeBase)Parameters[0];
95  }
96 
97  set
98  {
99  Parameters[0] = value;
100  }
101  }
102 
103  #endregion
104 
105  /// <inheritdoc/>
106  public bool Equals(MatrixType other)
107  {
108  return base.Equals(other);
109  }
110 
111  /// <inheritdoc/>
112  public override bool Equals(object obj)
113  {
114  if (ReferenceEquals(null, obj))
115  {
116  return false;
117  }
118  if (ReferenceEquals(this, obj))
119  {
120  return true;
121  }
122  return Equals(obj as MatrixType);
123  }
124 
125  /// <inheritdoc/>
126  public override int GetHashCode()
127  {
128  return base.GetHashCode();
129  }
130 
131  /// <summary>
132  /// Implements the operator ==.
133  /// </summary>
134  /// <param name="left">The left.</param>
135  /// <param name="right">The right.</param>
136  /// <returns>
137  /// The result of the operator.
138  /// </returns>
139  public static bool operator ==(MatrixType left, MatrixType right)
140  {
141  return Equals(left, right);
142  }
143 
144  /// <summary>
145  /// Implements the operator !=.
146  /// </summary>
147  /// <param name="left">The left.</param>
148  /// <param name="right">The right.</param>
149  /// <returns>
150  /// The result of the operator.
151  /// </returns>
152  public static bool operator !=(MatrixType left, MatrixType right)
153  {
154  return !Equals(left, right);
155  }
156 
157  /// <summary>
158  /// Index information.
159  /// </summary>
160  public struct Indexer
161  {
162  /// <summary>
163  /// Initializes a new instance of the <see cref="Indexer"/> struct.
164  /// </summary>
165  /// <param name="row">The row.</param>
166  /// <param name="column">The column.</param>
167  public Indexer(int row, int column)
168  {
169  Row = row;
170  Column = column;
171  }
172 
173  /// <summary>
174  /// The row number, zero-based index.
175  /// </summary>
176  public int Row;
177 
178  /// <summary>
179  /// The column number, zero-based index.
180  /// </summary>
181  public int Column;
182  }
183  }
184 }
int Column
The column number, zero-based index.
Definition: MatrixType.cs:181
Indexer(int row, int column)
Initializes a new instance of the Indexer struct.
Definition: MatrixType.cs:167
Base type for all types.
Definition: TypeBase.cs:11
MatrixType()
Initializes a new instance of the MatrixType class.
Definition: MatrixType.cs:17
Base class for all generic types.
Definition: GenericType.cs:14
override bool Equals(object obj)
Definition: MatrixType.cs:112
MatrixType(ScalarType type, int rowCount, int columnCount)
Initializes a new instance of the MatrixType class.
Definition: MatrixType.cs:34
bool Equals(MatrixType other)
Definition: MatrixType.cs:106
A field of a struct.
Definition: Literal.cs:13
int Row
The row number, zero-based index.
Definition: MatrixType.cs:176