1 /****************************************************************************** 2 * 3 * Project: OpenCPN 4 * Purpose: GRIB Plugin Friends 5 * Author: David Register 6 * 7 *************************************************************************** 8 * Copyright (C) 2010 by David S. Register * 9 * * 10 * This program is free software; you can redistribute it and/or modify * 11 * it under the terms of the GNU General Public License as published by * 12 * the Free Software Foundation; either version 2 of the License, or * 13 * (at your option) any later version. * 14 * * 15 * This program is distributed in the hope that it will be useful, * 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 * GNU General Public License for more details. * 19 * * 20 * You should have received a copy of the GNU General Public License * 21 * along with this program; if not, write to the * 22 * Free Software Foundation, Inc., * 23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 24 *************************************************************************** 25 */ 26 27 #include "GribRecord.h" 28 29 // These are indexes into the array 30 enum { Idx_WIND_VX, Idx_WIND_VX850, Idx_WIND_VX700, Idx_WIND_VX500, Idx_WIND_VX300, 31 Idx_WIND_VY, Idx_WIND_VY850, Idx_WIND_VY700, Idx_WIND_VY500, Idx_WIND_VY300, 32 Idx_WIND_GUST, Idx_PRESSURE, Idx_HTSIGW, Idx_WVDIR, Idx_WVPER, 33 Idx_SEACURRENT_VX, Idx_SEACURRENT_VY, Idx_PRECIP_TOT, Idx_CLOUD_TOT, 34 Idx_AIR_TEMP, Idx_AIR_TEMP850, Idx_AIR_TEMP700, Idx_AIR_TEMP500, Idx_AIR_TEMP300, 35 Idx_SEA_TEMP, Idx_CAPE, Idx_COMP_REFL, 36 Idx_HUMID_RE, Idx_HUMID_RE850, Idx_HUMID_RE700, Idx_HUMID_RE500, Idx_HUMID_RE300, 37 Idx_GEOP_HGT,Idx_GEOP_HGT850, Idx_GEOP_HGT700, Idx_GEOP_HGT500, Idx_GEOP_HGT300, 38 Idx_COUNT }; 39 40 class GribRecordSet { 41 public: GribRecordSet(unsigned int id)42 GribRecordSet(unsigned int id) : m_Reference_Time(-1), m_ID(id) { 43 for(int i=0; i<Idx_COUNT; i++) { 44 m_GribRecordPtrArray[i] = 0; 45 m_GribRecordUnref[i] = false; 46 } 47 } 48 ~GribRecordSet()49 virtual ~GribRecordSet() 50 { 51 RemoveGribRecords(); 52 } 53 54 /* copy and paste by plugins, keep functions in header */ SetUnRefGribRecord(int i,GribRecord * pGR)55 void SetUnRefGribRecord(int i, GribRecord *pGR ) { 56 assert (i >= 0 && i < Idx_COUNT); 57 if (m_GribRecordUnref[i] == true) { 58 delete m_GribRecordPtrArray[i]; 59 } 60 m_GribRecordPtrArray[i] = pGR; 61 m_GribRecordUnref[i] = true; 62 } 63 RemoveGribRecords()64 void RemoveGribRecords( ) { 65 for(int i=0; i<Idx_COUNT; i++) { 66 if (m_GribRecordUnref[i] == true) { 67 delete m_GribRecordPtrArray[i]; 68 } 69 } 70 } 71 72 time_t m_Reference_Time; 73 unsigned int m_ID; 74 75 GribRecord *m_GribRecordPtrArray[Idx_COUNT]; 76 private: 77 // grib records files are stored and owned by reader mapGribRecords 78 // interpolated grib are not, keep track of them 79 bool m_GribRecordUnref[Idx_COUNT]; 80 }; 81