001/*
002 * $Id: HydraContext.java,v 1.8 2011/03/24 16:06:33 davep Exp $
003 *
004 * This file is part of McIDAS-V
005 *
006 * Copyright 2007-2011
007 * Space Science and Engineering Center (SSEC)
008 * University of Wisconsin - Madison
009 * 1225 W. Dayton Street, Madison, WI 53706, USA
010 * https://www.ssec.wisc.edu/mcidas
011 * 
012 * All Rights Reserved
013 * 
014 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
015 * some McIDAS-V source code is based on IDV and VisAD source code.  
016 * 
017 * McIDAS-V is free software; you can redistribute it and/or modify
018 * it under the terms of the GNU Lesser Public License as published by
019 * the Free Software Foundation; either version 3 of the License, or
020 * (at your option) any later version.
021 * 
022 * McIDAS-V is distributed in the hope that it will be useful,
023 * but WITHOUT ANY WARRANTY; without even the implied warranty of
024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
025 * GNU Lesser Public License for more details.
026 * 
027 * You should have received a copy of the GNU Lesser Public License
028 * along with this program.  If not, see http://www.gnu.org/licenses.
029 */
030
031package edu.wisc.ssec.mcidasv.data.hydra;
032
033import ucar.unidata.data.DataSelection;
034import ucar.unidata.data.DataSource;
035import java.util.HashMap;
036import java.util.Iterator;
037import java.util.Set;
038
039public class HydraContext {
040
041  private static HashMap<DataSource, HydraContext> dataSourceToContextMap = new HashMap<DataSource, HydraContext>(); 
042  private static HydraContext hydraContext = null;
043  private boolean useSubset = false;
044  private MultiDimensionSubset subset = null;
045
046  public static HydraContext getHydraContext(DataSource source) {
047    if (dataSourceToContextMap.isEmpty()) {
048      HydraContext hydraContext = new HydraContext();
049      dataSourceToContextMap.put(source, hydraContext);
050      return hydraContext;
051    }
052
053    if (dataSourceToContextMap.containsKey(source)) {
054      return dataSourceToContextMap.get(source);
055    }
056    else {
057      HydraContext hydraContext = new HydraContext();
058      dataSourceToContextMap.put(source, hydraContext);
059      return hydraContext;
060    }
061  }
062
063  public static HydraContext getHydraContext() {
064    if (hydraContext == null) {
065      hydraContext =  new HydraContext();
066    }
067    return hydraContext;
068  }
069 
070
071  public HydraContext() {
072  }
073
074
075  public synchronized void setMultiDimensionSubset(MultiDimensionSubset subset) {
076    this.subset = subset;
077  }
078
079
080  public synchronized MultiDimensionSubset getMultiDimensionSubset() {
081    return subset;
082  }
083
084
085}