00001 00002 00003 00015 00016 // Copyright (C) 1997-2010 by Pawel Pilarczyk. 00017 // 00018 // This file is part of the Homology Library. This library is free software; 00019 // you can redistribute it and/or modify it under the terms of the GNU 00020 // General Public License as published by the Free Software Foundation; 00021 // either version 2 of the License, or (at your option) any later version. 00022 // 00023 // This library is distributed in the hope that it will be useful, 00024 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00026 // GNU General Public License for more details. 00027 // 00028 // You should have received a copy of the GNU General Public License along 00029 // with this software; see the file "license.txt". If not, write to the 00030 // Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00031 // MA 02111-1307, USA. 00032 00033 // Started in January 2002. Last revision: June 2, 2007. 00034 00035 00036 #ifndef _CHOMP_HOMOLOGY_KNOWN_H_ 00037 #define _CHOMP_HOMOLOGY_KNOWN_H_ 00038 00039 #include "chomp/system/config.h" 00040 #include "chomp/system/textfile.h" 00041 #include "chomp/struct/bitfield.h" 00042 00043 namespace chomp { 00044 namespace homology { 00045 00046 00047 // -------------------------------------------------- 00048 // ------------------- BitFields -------------------- 00049 // -------------------------------------------------- 00050 00054 class BitFields 00055 { 00056 public: 00058 BitFields (); 00059 00061 ~BitFields (); 00062 00067 void setkblimit (int limit = -1, int dim = -1); 00068 00070 int getkblimit (int dim = 0) const; 00071 00074 SetOfBitFields *operator [] (int dim); 00075 00077 void forget (int dim = -1); 00078 00079 private: 00081 SetOfBitFields **tab; 00082 00084 int len; 00085 00087 int *maxkb; 00088 00090 void extend (int n); 00091 00093 void allocate (int dim); 00094 00095 }; /* class BitFields */ 00096 00097 // -------------------------------------------------- 00098 00099 inline BitFields::BitFields () 00100 { 00101 tab = NULL; 00102 len = 0; 00103 maxkb = NULL; 00104 return; 00105 } /* BitFields::BitFields */ 00106 00107 inline SetOfBitFields *BitFields::operator [] (int dim) 00108 { 00109 // make sure the dimension is positive 00110 if (dim <= 0) 00111 throw "Trying to get a bit field set of non-positive dim."; 00112 00113 // extend the tables if necessary 00114 if (dim >= len) 00115 extend (dim + 1); 00116 00117 // allocate the bit field set if necessary 00118 if (!tab [dim] && maxkb [dim]) 00119 allocate (dim); 00120 00121 // return the pointer to the requested bit field set 00122 return tab [dim]; 00123 } /* BitFields::operator [] */ 00124 00125 // -------------------------------------------------- 00126 00129 extern BitFields knownbits; 00130 00131 00132 } // namespace homology 00133 } // namespace chomp 00134 00135 #endif // _CHOMP_HOMOLOGY_KNOWN_H_ 00136 00138