FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_FieldMask.hpp
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 #ifndef _fei_FieldMask_hpp_
10 #define _fei_FieldMask_hpp_
11 
12 #include "fei_macros.hpp"
13 
14 #include <vector>
15 
16 namespace fei {
17 
29  class FieldMask {
30  public:
32  FieldMask();
33 
35  FieldMask(const FieldMask& fm);
36 
38  FieldMask(int numFields,
39  const int* fieldIDs,
40  const int* fieldSizes);
41 
43  virtual ~FieldMask();
44 
46  int getMaskID() { return( maskID_ ); }
47 
49  static int calculateMaskID(int numFields,
50  const int* fieldIDs);
51 
53  static int calculateMaskID(const FieldMask& fm,
54  int fieldID);
55 
57  void addField(int fieldID,
58  int fieldSize);
59 
61  bool hasFieldID(int fieldID) const
62  {
63  for(size_t i=0; i<fieldIDs_.size(); ++i)
64  if (fieldIDs_[i] == fieldID) return true;
65  return false;
66  }
67 
69  size_t getNumFields() const { return(fieldIDs_.size()); }
70 
74  int getNumIndices() const { return( numIndices_ ); }
75 
79  void setNumIndices(int numInd) { numIndices_ = numInd; }
80 
82  std::vector<int>& getFieldIDs() { return(fieldIDs_); }
83 
85  const std::vector<int>& getFieldIDs() const { return(fieldIDs_); }
86 
88  std::vector<int>& getFieldSizes() { return(fieldSizes_); }
89 
91  const std::vector<int>& getFieldSizes() const { return(fieldSizes_); }
92 
97  int getFieldEqnOffset(int fieldID, int& offset) const;
98 
100  bool operator==(const FieldMask& fm) const
101  { return( maskID_ == fm.maskID_ ); }
102 
104  bool operator!=(const FieldMask& fm) const
105  { return( maskID_ != fm.maskID_ ); }
106 
111  bool isSubSetOf(const FieldMask& fm) const
112  {
113  for(unsigned i=0; i<fieldIDs_.size(); ++i) {
114  if (!fm.hasFieldID(fieldIDs_[i])) return(false);
115  }
116  return(true);
117  }
118 
119  private:
120  FieldMask& operator=(const FieldMask& src);
121 
122  int calculateMaskID();
123 
124  int maskID_;
125 
126  std::vector<int> fieldIDs_;
127  std::vector<int> fieldSizes_;
128  std::vector<int> fieldEqnOffsets_;
129 
130  int numFields_;
131  int numIndices_;
132  };
133 
134 } //namespace fei
135 
136 #endif // _fei_FieldMask_hpp_
137 
bool operator==(const FieldMask &fm) const
int getNumIndices() const
bool operator!=(const FieldMask &fm) const
void setNumIndices(int numInd)
virtual ~FieldMask()
size_t getNumFields() const
static int calculateMaskID(int numFields, const int *fieldIDs)
std::vector< int > & getFieldSizes()
std::vector< int > & getFieldIDs()
bool hasFieldID(int fieldID) const
bool isSubSetOf(const FieldMask &fm) const
void addField(int fieldID, int fieldSize)
int getFieldEqnOffset(int fieldID, int &offset) const