FEI Version of the Day
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 
00043     virtual ~FieldMask();
00044 
00046     int getMaskID() { return( maskID_ ); }
00047 
00049     static int calculateMaskID(int numFields,
00050              const int* fieldIDs);
00051 
00053     static int calculateMaskID(const FieldMask& fm,
00054              int fieldID);
00055 
00057     void addField(int fieldID,
00058       int fieldSize);
00059 
00061     bool hasFieldID(int fieldID) const
00062     {
00063       for(size_t i=0; i<fieldIDs_.size(); ++i)
00064         if (fieldIDs_[i] == fieldID) return true;
00065       return false;
00066     }
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 
00096     void getFieldEqnOffset(int fieldID, int& offset) const;
00097 
00099     bool operator==(const FieldMask& fm) const
00100       { return( maskID_ == fm.maskID_ ); }
00101 
00103     bool operator!=(const FieldMask& fm) const
00104       { return( maskID_ != fm.maskID_ ); }
00105 
00110     bool isSubSetOf(const FieldMask& fm) const
00111       {
00112         for(unsigned i=0; i<fieldIDs_.size(); ++i) {
00113           if (!fm.hasFieldID(fieldIDs_[i])) return(false);
00114         }
00115         return(true);
00116       }
00117 
00118   private:
00119     FieldMask& operator=(const FieldMask& src);
00120 
00121     int calculateMaskID();
00122 
00123     int maskID_;
00124 
00125     std::vector<int> fieldIDs_;
00126     std::vector<int> fieldSizes_;
00127     std::vector<int> fieldEqnOffsets_;
00128 
00129     int numFields_;
00130     int numIndices_;
00131   };
00132 
00133 } //namespace fei
00134 
00135 #endif // _fei_FieldMask_hpp_
00136 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends