| 1 |
/* WorkvectorPool.cpp |
| 2 |
* |
| 3 |
* Copyright (C) 2024 David Weenink |
| 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. See the GNU |
| 13 |
* 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 "WorkvectorPool.h" |
| 20 |
|
| 21 |
#include "oo_DESTROY.h" |
| 22 |
#include "WorkvectorPool_def.h" |
| 23 |
#include "oo_COPY.h" |
| 24 |
#include "WorkvectorPool_def.h" |
| 25 |
#include "oo_EQUAL.h" |
| 26 |
#include "WorkvectorPool_def.h" |
| 27 |
#include "oo_CAN_WRITE_AS_ENCODING.h" |
| 28 |
#include "WorkvectorPool_def.h" |
| 29 |
#include "oo_READ_TEXT.h" |
| 30 |
#include "WorkvectorPool_def.h" |
| 31 |
#include "oo_WRITE_TEXT.h" |
| 32 |
#include "WorkvectorPool_def.h" |
| 33 |
#include "oo_READ_BINARY.h" |
| 34 |
#include "WorkvectorPool_def.h" |
| 35 |
#include "oo_WRITE_BINARY.h" |
| 36 |
#include "WorkvectorPool_def.h" |
| 37 |
#include "oo_DESCRIPTION.h" |
| 38 |
#include "WorkvectorPool_def.h" |
| 39 |
|
| 40 |
Thing_implement (WorkvectorPool, Daata, 0); |
| 41 |
|
| 42 |
autoWorkvectorPool WorkvectorPool_create (constINTVEC const& vectorSizes, bool reusable) { |
| 43 |
try { |
| 44 |
autoWorkvectorPool me = Thing_new (WorkvectorPool); |
| 45 |
my numberOfVectors = vectorSizes.size; |
| 46 |
Melder_assert (my numberOfVectors > 0); |
| 47 |
my reusable = reusable; |
| 48 |
|
| 49 |
my vectorStart = raw_INTVEC (my numberOfVectors); |
| 50 |
integer vecstart = 1; |
| 51 |
for (integer ivec = 1; ivec <= my numberOfVectors; ivec ++) { |
| 52 |
Melder_assert (vectorSizes [ivec] > 0); |
| 53 |
my vectorStart [ivec] = vecstart; |
| 54 |
vecstart += vectorSizes [ivec]; |
| 55 |
} |
| 56 |
my poolMemorySize = vecstart - 1; |
| 57 |
my vectorSizes = copy_INTVEC (vectorSizes); |
| 58 |
my inuse = zero_BOOLVEC (my numberOfVectors); |
| 59 |
my memoryPool = raw_VEC (my poolMemorySize); |
| 60 |
return me; |
| 61 |
} catch (MelderError) { |
| 62 |
Melder_throw (U"WorkvectorPool not created."); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
/* End of file WorkvectorPool.cpp */ |