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 
00029   class FieldMask {
00030   public:
00032     FieldMask();
00033 
00035     FieldMask(const FieldMask& fm);
00036 
00038     FieldMask(int numFields,
00039         const int* fieldIDs,
00040         const int* fieldSizes,
00041         const int* numInstancesOfThisFieldPerID);
00042 
00044     virtual ~FieldMask();
00045 
00047     int getMaskID() { return( maskID_ ); }
00048 
00050     static int calculateMaskID(int numFields,
00051              const int* fieldIDs,
00052              const int* numInstancesPerID);
00053 
00055     static int calculateMaskID(const FieldMask& fm,
00056              int fieldID,
00057              int numInstances);
00058 
00060     void addField(int fieldID,
00061       int fieldSize,
00062       int numInstances=1);
00063 
00065     bool hasFieldID(int fieldID) const;
00066 
00068     size_t getNumFields() const { return(fieldIDs_.size()); }
00069 
00073     int getNumIndices() const { return( numIndices_ ); }
00074 
00078     void setNumIndices(int numInd) { numIndices_ = numInd; }
00079 
00081     std::vector<int>& getFieldIDs() { return(fieldIDs_); }
00082 
00084     const std::vector<int>& getFieldIDs() const { return(fieldIDs_); }
00085 
00087     std::vector<int>& getFieldSizes() { return(fieldSizes_); }
00088 
00090     const std::vector<int>& getFieldSizes() const { return(fieldSizes_); }
00091 
00094     std::vector<int>& getFieldInstances() { return(fieldInstances_); }
00095 
00099     void getFieldEqnOffset(int fieldID, int& offset, int& numInstancesPerID) const;
00100 
00102     bool operator==(const FieldMask& fm) const
00103       { return( maskID_ == fm.maskID_ ); }
00104 
00106     bool operator!=(const FieldMask& fm) const
00107       { return( maskID_ != fm.maskID_ ); }
00108 
00113     bool isSubSetOf(const FieldMask& fm) const
00114       {
00115         for(unsigned i=0; i<fieldIDs_.size(); ++i) {
00116           if (!fm.hasFieldID(fieldIDs_[i])) return(false);
00117         }
00118         return(true);
00119       }
00120 
00121   private:
00122     FieldMask& operator=(const FieldMask& src);
00123 
00124     int calculateMaskID();
00125 
00126     int maskID_;
00127 
00128     std::vector<int> fieldIDs_;
00129     std::vector<int> fieldSizes_;
00130     std::vector<int> fieldInstances_;
00131     std::vector<int> fieldEqnOffsets_;
00132 
00133     int numFields_;
00134     int numIndices_;
00135     int* fieldIDsPtr_;
00136     int* fieldInstancesPtr_;
00137     int* fieldEqnOffsetsPtr_;
00138   };
00139 
00140 } //namespace fei
00141 
00142 #endif // _fei_FieldMask_hpp_
00143 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:23 2011 for FEI by  doxygen 1.6.3