SundanceSubsetManager.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_SUBSETMANAGER_H
00032 #define SUNDANCE_SUBSETMANAGER_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceMap.hpp"
00036 #include "SundanceSet.hpp"
00037 #include "SundanceCellFilter.hpp"
00038 #include "SundanceCellFilterBase.hpp"
00039 
00040 namespace Sundance
00041 {
00042 /** 
00043  * SubsetManager keeps maps from cell filters to their subsets. This is
00044  * a device to avoid circular references between subset and superset.
00045  */
00046 
00047 class SubsetManager
00048 {
00049 public:
00050   /** */
00051   static void registerSubset(const CellFilter& filter, 
00052     const CellFilter& subset)
00053     {
00054       if (!subsetMap().containsKey(filter))
00055         subsetMap().put(filter, Sundance::Set<CellFilter>());
00056       subsetMap().get(filter).put(subset);
00057     }
00058 
00059   /** */
00060   static void registerDisjoint(const CellFilter& filter, 
00061     const CellFilter& subset)
00062     {
00063       if (!disjointMap().containsKey(filter))
00064         disjointMap().put(filter, Sundance::Set<CellFilter>());
00065       disjointMap().get(filter).put(subset);
00066     }
00067 
00068   /** */
00069   static void registerLabeledSubset(const CellFilter& filter, 
00070     const Set<int>& label, const CellFilter& subset)
00071     {
00072       if (!labeledMap().containsKey(filter))
00073         labeledMap().put(filter, Sundance::Map<Set<int>, CellFilter>());
00074       labeledMap().get(filter).put(label, subset);
00075     }
00076 
00077 
00078   /** */
00079   static const Sundance::Set<CellFilter>& getSubsets(const CellFilter& filter)
00080     {
00081       if (!subsetMap().containsKey(filter))
00082         subsetMap().put(filter, Sundance::Set<CellFilter>());
00083       return subsetMap().get(filter);
00084     }
00085 
00086   /** */
00087   static const Sundance::Set<CellFilter>& getDisjoints(const CellFilter& filter)
00088     {
00089       if (!disjointMap().containsKey(filter))
00090         disjointMap().put(filter, Sundance::Set<CellFilter>());
00091       return disjointMap().get(filter);
00092     }
00093 
00094   /** */
00095   static const Sundance::Map<Set<int>, CellFilter>& 
00096   getLabeledSubsets(const CellFilter& filter)
00097     {
00098       if (!labeledMap().containsKey(filter))
00099         labeledMap().put(filter, Sundance::Map<Set<int>, CellFilter>());
00100       return labeledMap().get(filter);
00101     }
00102 
00103 private:
00104   
00105   /** */
00106   static Sundance::Map<CellFilter, Sundance::Set<CellFilter> >& subsetMap()
00107     {
00108       static Sundance::Map<CellFilter, Sundance::Set<CellFilter> > rtn;
00109       return rtn;
00110     }
00111   
00112   /** */
00113   static Sundance::Map<CellFilter, Sundance::Set<CellFilter> >& disjointMap()
00114     {
00115       static Sundance::Map<CellFilter, Sundance::Set<CellFilter> > rtn;
00116       return rtn;
00117     }
00118   
00119   /** */
00120   static Sundance::Map<CellFilter, Sundance::Map<Set<int>, CellFilter> >& labeledMap()
00121     {
00122       static Sundance::Map<CellFilter, Sundance::Map<Set<int>, CellFilter> > rtn;
00123       return rtn;
00124     }
00125 };
00126 
00127 }
00128 
00129 
00130 
00131 #endif

Site Contact