| 1 | /* Notebook.cpp |
| 2 | * |
| 3 | * Copyright (C) 2023,2026 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "Notebook.h" |
| 20 | |
| 21 | Thing_implement (Notebook, SimpleString, 0); |
| 22 | Thing_implement (NotebookSet, SortedSetOfString, 0); |
| 23 | |
| 24 | static autoNotebookSet theKnownNotebooks; |
| 25 | |
| 26 | autoNotebook Notebook_createFromFile (MelderFile file) { |
| 27 | autoNotebook me = Thing_new (Notebook); |
| 28 | my string = Melder_dup (MelderFile_peekPath (file)); |
| 29 | return me; |
| 30 | } |
| 31 | |
| 32 | void Notebook_rememberDuringThisAppSession_move (autoNotebook me) { |
| 33 | if (! theKnownNotebooks) |
| 34 | theKnownNotebooks = NotebookSet_create (); |
| 35 | TRACE |
| 36 | trace (U"Adding notebook: \"", my string.get(), U"\""); |
| 37 | theKnownNotebooks -> addItem_move (me.move()); |
| 38 | } |
| 39 | |
| 40 | Notebook Notebook_find (conststring32 filePath) { |
| 41 | const integer position = theKnownNotebooks -> lookUp (filePath); |
| 42 | Melder_assert (position != 0); |
| 43 | return theKnownNotebooks -> at [position]; |
| 44 | } |
| 45 | |
| 46 | /* End of file Notebook.cpp */ |