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 
00023 class MetaData;
00024 
00025 
00040 class Selector {
00041 public:
00043   ~Selector();
00044 
00046   Selector();
00047 
00049   Selector( const Selector & selector);
00050 
00052   Selector & operator = ( const Selector & B );
00053 
00055   Selector( const Part & part);
00056 
00058   Selector & operator &= ( const Selector & selector);
00059 
00061   Selector & operator |= ( const Selector & selector);
00062 
00066   Selector & complement();
00067 
00069   Selector operator ! () const
00070     { Selector S( *this ); return S.complement(); }
00071 
00075   bool operator()( const Bucket & candidate ) const ;
00076 
00078   friend std::ostream & operator << ( std::ostream & out, const Selector & selector);
00079 
00080 private:
00081 
00083   struct OpType {
00084     unsigned       m_part_id ; 
00085     unsigned short m_unary ;   
00086     unsigned short m_count ;   
00087 
00088     OpType() : m_part_id(0), m_unary(0), m_count(0) {}
00089     OpType( unsigned part_id , unsigned unary , unsigned count )
00090       : m_part_id( part_id ), m_unary( unary ), m_count( count ) {}
00091     OpType( const OpType & opType );
00092     OpType & operator = ( const OpType & opType );
00093   };
00094 
00096   friend class std::vector<OpType> ;
00097 
00099   const MetaData * m_mesh_meta_data ;
00100 
00102   std::vector< OpType > m_op ;
00103 
00105   void verify_compatible( const Selector & B ) const;
00106 
00108   void verify_compatible( const Bucket & B ) const;
00109 
00111   bool apply( 
00112       unsigned part_id , 
00113       const Bucket & candidate 
00114       ) const;
00115 
00117   bool apply( 
00118       std::vector<OpType>::const_iterator start,
00119       std::vector<OpType>::const_iterator finish,
00120       const Bucket & candidate
00121       ) const;
00122 
00124   void compoundAll();
00125 
00127   std::string printExpression(
00128       const std::vector<OpType>::const_iterator start,
00129       const std::vector<OpType>::const_iterator finish
00130       ) const;
00131 
00132 };
00133 
00137 Selector operator & ( const Part & A , const Part & B );
00138 
00142 Selector operator & ( const Part & A , const Selector & B );
00143 
00147 Selector operator & ( const Selector & A, const Part & B );
00148 
00152 Selector operator & ( const Selector & A, const Selector & B );
00153 
00157 Selector operator | ( const Part & A , const Part & B );
00158 
00162 Selector operator | ( const Part & A , const Selector & B );
00163 
00167 Selector operator | ( const Selector & A, const Part & B  );
00168 
00172 Selector operator | ( const Selector & A , const Selector & B );
00173 
00177 Selector operator ! ( const Part & A );
00178 
00179 
00183 Selector selectUnion( const PartVector& union_part_vector );
00184 
00188 Selector selectIntersection( const PartVector& intersection_part_vector );
00189 
00192 } // namespace mesh 
00193 } // namespace stk 
00194 
00195 #endif // stk_mesh_Selector_hpp
00196 

Generated on Tue Jul 13 09:27:32 2010 for Sierra Toolkit by  doxygen 1.4.7