Sierra Toolkit Version of the Day
Selector.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 
00010 #ifndef stk_mesh_Selector_hpp
00011 #define stk_mesh_Selector_hpp
00012 
00013 #include <iosfwd>
00014 #include <stk_mesh/base/Types.hpp>
00015 
00016 namespace stk {
00017 namespace mesh {
00018 
00037 class Selector {
00038 public:
00040   ~Selector();
00041 
00043   Selector();
00044 
00046   Selector( const Selector & selector);
00047 
00049   Selector & operator = ( const Selector & B );
00050 
00052   Selector( const Part & part);
00053 
00055   Selector & operator &= ( const Selector & selector);
00056 
00058   Selector & operator |= ( const Selector & selector);
00059 
00063   Selector & complement();
00064 
00066   Selector operator ! () const
00067     { Selector S( *this ); return S.complement(); }
00068 
00072   bool operator()( const Bucket & candidate ) const ;
00073 
00077   bool operator()( const Bucket * candidate ) const{
00078     return operator()(*candidate);
00079   }
00080 
00084   bool operator()( const Entity & candidate ) const ;
00085 
00087   friend std::ostream & operator << ( std::ostream & out, const Selector & selector);
00088 
00089 private:
00090 
00092   struct OpType {
00093     unsigned       m_part_id ; 
00094     unsigned short m_unary ;   
00095     unsigned short m_count ;   
00096 
00097     OpType() : m_part_id(0), m_unary(0), m_count(0) {}
00098     OpType( unsigned part_id , unsigned unary , unsigned count )
00099       : m_part_id( part_id ), m_unary( unary ), m_count( count ) {}
00100     OpType( const OpType & opType );
00101     OpType & operator = ( const OpType & opType );
00102   };
00103 
00105   friend class std::vector<OpType> ;
00106 
00108   const MetaData * m_mesh_meta_data ;
00109 
00111   std::vector< OpType > m_op ;
00112 
00114   void verify_compatible( const Selector & B ) const;
00115 
00117   void verify_compatible( const Bucket & B ) const;
00118 
00120   bool apply(
00121       unsigned part_id ,
00122       const Bucket & candidate
00123       ) const;
00124 
00126   bool apply(
00127       std::vector<OpType>::const_iterator start,
00128       std::vector<OpType>::const_iterator finish,
00129       const Bucket & candidate
00130       ) const;
00131 
00133   void compoundAll();
00134 
00136   std::string printExpression(
00137       const std::vector<OpType>::const_iterator start,
00138       const std::vector<OpType>::const_iterator finish
00139       ) const;
00140 
00141 };
00142 
00146 Selector operator & ( const Part & A , const Part & B );
00147 
00151 Selector operator & ( const Part & A , const Selector & B );
00152 
00156 Selector operator & ( const Selector & A, const Part & B );
00157 
00161 Selector operator & ( const Selector & A, const Selector & B );
00162 
00166 Selector operator | ( const Part & A , const Part & B );
00167 
00171 Selector operator | ( const Part & A , const Selector & B );
00172 
00176 Selector operator | ( const Selector & A, const Part & B  );
00177 
00181 Selector operator | ( const Selector & A , const Selector & B );
00182 
00186 Selector operator ! ( const Part & A );
00187 
00188 
00192 Selector selectUnion( const PartVector& union_part_vector );
00193 
00197 Selector selectIntersection( const PartVector& intersection_part_vector );
00198 
00202 Selector selectField( const FieldBase& field );
00203 
00206 } // namespace mesh
00207 } // namespace stk
00208 
00209 #endif // stk_mesh_Selector_hpp
00210 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends