fei_FieldMask.hpp

00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #ifndef _fei_FieldMask_hpp_
00010 #define _fei_FieldMask_hpp_
00011 
00012 #include "fei_macros.hpp"
00013 
00014 #include <vector>
00015 
00016 namespace fei {
00017 
00030   class FieldMask {
00031   public:
00033     FieldMask();
00034 
00036     FieldMask(const FieldMask& fm);
00037 
00039     FieldMask(int numFields,
00040         const int* fieldIDs,
00041         const int* fieldSizes,
00042         const int* numInstancesOfThisFieldPerID);
00043 
00045     virtual ~FieldMask();
00046 
00048     int getMaskID() { return( maskID_ ); }
00049 
00051     static int calculateMaskID(int numFields,
00052              const int* fieldIDs,
00053              const int* numInstancesPerID);
00054 
00056     static int calculateMaskID(const FieldMask& fm,
00057              int fieldID,
00058              int numInstances);
00059 
00061     void addField(int fieldID,
00062       int fieldSize,
00063       int numInstances=1);
00064 
00066     bool hasFieldID(int fieldID) const;
00067 
00069     size_t getNumFields() const { return(fieldIDs_.size()); }
00070 
00074     int getNumIndices() const { return( numIndices_ ); }
00075 
00079     void setNumIndices(int numInd) { numIndices_ = numInd; }
00080 
00082     std::vector<int>& getFieldIDs() { return(fieldIDs_); }
00083 
00085     const std::vector<int>& getFieldIDs() const { return(fieldIDs_); }
00086 
00088     std::vector<int>& getFieldSizes() { return(fieldSizes_); }
00089 
00091     const std::vector<int>& getFieldSizes() const { return(fieldSizes_); }
00092 
00095     std::vector<int>& getFieldInstances() { return(fieldInstances_); }
00096 
00100     void getFieldEqnOffset(int fieldID, int& offset, int& numInstancesPerID) const;
00101 
00103     bool operator==(const FieldMask& fm) const
00104       { return( maskID_ == fm.maskID_ ); }
00105 
00107     bool operator!=(const FieldMask& fm) const
00108       { return( maskID_ != fm.maskID_ ); }
00109 
00114     bool isSubSetOf(const FieldMask& fm) const
00115       {
00116   for(unsigned i=0; i<fieldIDs_.size(); ++i) {
00117     if (!fm.hasFieldID(fieldIDs_[i])) return(false);
00118   }
00119   return(true);
00120       }
00121 
00122   private:
00123     FieldMask& operator=(const FieldMask& src);
00124 
00125     int calculateMaskID();
00126 
00127     int maskID_;
00128 
00129     std::vector<int> fieldIDs_;
00130     std::vector<int> fieldSizes_;
00131     std::vector<int> fieldInstances_;
00132     std::vector<int> fieldEqnOffsets_;
00133 
00134     int numFields_;
00135     int numIndices_;
00136     int* fieldIDsPtr_;
00137     int* fieldInstancesPtr_;
00138     int* fieldEqnOffsetsPtr_;
00139   };
00140 
00141 } //namespace fei
00142 
00143 #endif // _fei_FieldMask_hpp_
00144 

Generated on Wed May 12 21:30:41 2010 for FEI by  doxygen 1.4.7