James Kuszmaul | 590e33e | 2024-01-14 17:54:00 -0800 | [diff] [blame] | 1 | namespace frc971.fbs; |
| 2 | |
| 3 | enum StorageOrder : ubyte { |
| 4 | // Column-major; i.e., for a matrix |
| 5 | // [1 2] |
| 6 | // [3 4] |
| 7 | // The memory layout will be 1 3 2 4. |
| 8 | ColMajor = 0, |
| 9 | // Row-major; i.e., for a matrix |
| 10 | // [1 2] |
| 11 | // [3 4] |
| 12 | // The memory layout will be 1 2 3 4. |
| 13 | RowMajor = 1, |
| 14 | } |
| 15 | |
| 16 | // Represents a dynamically-sized 2-D matrix that is either row-major or column-major. |
| 17 | table Matrix { |
| 18 | // rows and cols must both be greater than zero. |
| 19 | rows:uint (id: 0); |
| 20 | cols:uint (id: 1); |
| 21 | storage_order:StorageOrder = ColMajor (id: 2); |
| 22 | // data must be present and must have a length of rows * cols. |
| 23 | data:[double] (id: 3); |
| 24 | } |
| 25 | |
| 26 | // The below enums are used in C++ code for communicating errors in parsing |
| 27 | // the matrix; they are mostly only defined in the fbs file so that we get |
| 28 | // pre-generated functions for converting the enum values to strings. |
| 29 | enum MatrixField : ubyte { |
| 30 | kRows = 0, |
| 31 | kCols, |
| 32 | kStorageOrder, |
| 33 | kData, |
| 34 | } |
| 35 | |
| 36 | enum FieldError : ubyte { |
| 37 | kInconsistentWithTemplate = 0, |
| 38 | kMissing, |
| 39 | } |