| 1 | #ifndef _Label_h_ |
| 2 | #define _Label_h_ |
| 3 | /* Label.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2005,2007,2011,2012,2015-2018,2022 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "Collection.h" |
| 22 | #include "Function.h" |
| 23 | |
| 24 | |
| 25 | #pragma mark - class Autosegment |
| 26 | |
| 27 | Thing_define (Autosegment, Function) { |
| 28 | void v1_copy (Daata data_to) const |
| 29 | override; |
| 30 | bool v1_equal (Daata otherData) |
| 31 | override; |
| 32 | static Data_Description s_description; |
| 33 | Data_Description v_description () |
| 34 | override { return s_description; } |
| 35 | }; |
| 36 | |
| 37 | autoAutosegment Autosegment_create (double tmin, double tmax, conststring32 label); |
| 38 | /* |
| 39 | Function: |
| 40 | create a new instance of Autosegment. |
| 41 | Return value: |
| 42 | the new Autosegment. |
| 43 | Preconditions: |
| 44 | tmax > tmin; |
| 45 | label may be null; |
| 46 | Postconditions: |
| 47 | result -> tmin == tmin; |
| 48 | result -> tmax == tmax; |
| 49 | if (label) |
| 50 | result -> name == nullptr; |
| 51 | else |
| 52 | result -> name [] == label []; // 'label' copied into 'name' |
| 53 | */ |
| 54 | |
| 55 | |
| 56 | #pragma mark - class Tier |
| 57 | |
| 58 | Collection_define (Tier, SortedOf, Autosegment) { |
| 59 | |
| 60 | /** |
| 61 | Initialize a new Tier containing one Autosegment from -1e30 to 1e30. |
| 62 | @post |
| 63 | this->size == 1; |
| 64 | this->at [1] -> classInfo == classAutosegment; |
| 65 | this->at [1] -> xmin == -1e30; |
| 66 | this->at [1] -> xmax == 1e30; |
| 67 | this->at [1] -> name == nullptr; |
| 68 | */ |
| 69 | structTier () { |
| 70 | our classInfo = classTier; |
| 71 | our addItem_move (Autosegment_create (-1e30, 1e30, nullptr)); |
| 72 | } |
| 73 | |
| 74 | static int compareHook (Autosegment me, Autosegment thee) { |
| 75 | if (my xmin < thy xmin) return -1; |
| 76 | if (my xmin > thy xmin) return 1; |
| 77 | if (my xmax < thy xmax) return -1; |
| 78 | if (my xmax > thy xmax) return 1; |
| 79 | return 0; |
| 80 | } |
| 81 | SortedOf<structAutosegment>::CompareHook v_getCompareHook () override { return compareHook; } |
| 82 | }; |
| 83 | |
| 84 | /** |
| 85 | @return |
| 86 | index, or 0 if the tier is empty or t is very large. |
| 87 | @post |
| 88 | result == 0 || my item [i] -> xmin <= result < my item [i] -> xmax; |
| 89 | */ |
| 90 | integer Tier_timeToIndex (Tier me, double t); |
| 91 | |
| 92 | |
| 93 | #pragma mark - class Label |
| 94 | |
| 95 | Collection_define (Label, OrderedOf, Tier) { |
| 96 | }; |
| 97 | |
| 98 | void Label_addTier (Label me); |
| 99 | |
| 100 | void Label_suggestDomain (Label me, double *tmin, double *tmax); |
| 101 | |
| 102 | |
| 103 | /* End of file Label.h */ |
| 104 | #endif |